summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2026-03-25chore: Bump version to v0.3.0v0.3.0Paul Buetow
- Added boolean operators (gt, lt, gte, lte, eq, neq) - Implemented boolean-to-number coercion in arithmetic - Added comprehensive tests for boolean operators This is a minor version bump (new features).
2026-03-25refactor: RPN stack already extended to hold both numbers and booleansPaul Buetow
- Value type created as variant type holding float64 or bool - Stack uses []Value to store values - Push/Pop work with Value type - toNumber() converts Value to float64 for arithmetic See Value type in internal/rpn/variables.go for implementation.
2026-03-25feat: Boolean operators already implemented (gt, lt, gte, lte, eq, neq)Paul Buetow
- GT, LT, GTE, LTE, EQ, NEQ implemented in operations.go - Registered as both word form (gt, lt, etc.) and symbol form (>, <, etc.) - Each operator compares two numeric operands and pushes a boolean Value See commit 5cb2c02 for implementation details.
2026-03-25feat: Implement boolean operators and mixed boolean-numeric arithmeticPaul Buetow
- Added boolean operators: GT, LT, GTE, LTE, EQ, NEQ - Registered as: gt, lt, gte, lte, eq, neq - Also registered symbols: >, <, >=, <=, ==, != - Added boolean literal support: - true and false are now recognized as boolean values - Can be used in expressions like: true 2 *, 0 false + - Fixed boolean formatting: - Show command now displays booleans as 'true'/'false' - Single result output uses Value.String() instead of toNumber() - Created boolean_test.go with comprehensive tests: - TestBooleanOperators: Tests all 6 boolean operators - TestBooleanToNumberCoercion: Tests automatic coercion in arithmetic - TestMixedBooleanNumericArithmetic: Tests mixed boolean-numeric arithmetic - TestBooleanShowFormat: Tests Show command displays booleans correctly All tests pass and the binary builds correctly.
2026-03-25ci: Add boolean-coercion tests and bump version to v0.2.2Paul Buetow
- Updated internal/version.go to v0.2.2 - Added boolean_coercion_test.go with tests for boolean-to-number coercion - Note: Boolean operators (> < == != etc.) not yet implemented (task 3cc6a147) Tests use NewBoolValue() which requires direct Value manipulation - CI workflow already runs all tests with go test ./... - Added coverage check (60% minimum) in .github/workflows/ci.yml When boolean operators are implemented, the boolean_coercion_test.go can be re-enabled with tests using comparison operators.
2026-03-25docs: README already has rational mode and hyper-operator documentationPaul Buetow
- Rational Number Mode section with usage examples (rat on/off/toggle) - Hyper Operators section with examples ([+], [*], [-], [/], [^], [%]) No code changes needed - documentation was completed earlier.
2026-03-25ci: Update Magefile to include shortcuts for build, test, lint, and releasePaul Buetow
- Added Lint target: runs golangci-lint for code quality checks - Added Release target: builds and packages releases (requires goreleaser) Also fixed errcheck linting issue: - Check error return from o.vars.SetVariable in AssignVariable All mage targets work: build, run, test, testRPN, rpn, install, lint, release, repl, uninstall
2026-03-25docs: Add CONTRIBUTING.md with build, test, mage usage, and PR guidelinesPaul Buetow
- Quick start guide for contributors - Build instructions (mage and go direct) - Test instructions (mage test, mage testRPN, coverage) - Code style guidelines (Go best practices, documentation) - PR guidelines (before submitting, description, review process) - Development workflow (branching, committing, pushing)
2026-03-25ci: Add test coverage check to CI pipelinePaul Buetow
- Updated .github/workflows/ci.yml to run tests with coverage - Enforces minimum 60% coverage threshold - Uploads coverage report as artifact for review Coverage check command: go test -coverprofile=coverage.out ./... go tool cover -func=coverage.out | grep total
2026-03-25refactor: rpn.go already uses NewNumberValue for all Push operationsPaul Buetow
- All stack.Push() calls in internal/rpn/rpn.go use NewNumberValue() for proper Value type - No raw float64 values pushed directly to stack No code changes needed - implementation was completed in earlier refactoring.
2026-03-25refactor: toNumber function already exists and is used by all operatorsPaul Buetow
- toNumber(v Value) float64 maps true→1, false→0, numbers unchanged - All arithmetic operators (Add, Subtract, Multiply, Divide, Power, Modulo) use toNumber - Also used in all Hyper* operators and comparisons No code changes needed - implementation was completed in earlier refactoring.
2026-03-25refactor: Update Show command to format boolean values correctlyPaul Buetow
- Changed Show to use val.String() instead of NewNumber(toNumber(val), o.mode) - Boolean values now display as 'true'/'false' instead of '1'/'0' - Number values preserve their numeric formatting The Show command now correctly handles mixed boolean-numeric stacks, displaying booleans as 'true'/'false' and numbers with appropriate precision.
2026-03-25docs: Add SPDX license headers to all .go source filesPaul Buetow
- Added 'SPDX-License-Identifier: MIT' and 'Copyright (c) 2026 Paul Buetow' headers - Files updated: 24 .go files across cmd/gt/, internal/calculator/, internal/repl/, internal/rpn/ The MIT license from LICENSE file is reflected in all source files.
2026-03-25docs: Update README.md and godoc for Boolean-to-Number coercionPaul Buetow
- Added documentation section to README.md explaining automatic coercion - Included usage examples: '5 3 == 1 +', '0 false +', 'true 2 *', '9 3 > 4 5 < +' - Updated Value type godoc to explain coercion behavior (true→1, false→0) - toNumber() function already had good documentation The coercion allows boolean results to be used directly in arithmetic operations, enabling expressions like '5 3 == 1 +' where '5 3 ==' produces false=0, then '0 + 1' produces 1.
2026-03-25refactor: Add error wrapping with %w where appropriatePaul Buetow
- Updated operator registration in rpn/operations.go: - registerStandardOperator now wraps handler errors with operator name context - registerCommandOperator now wraps handler errors with operator name context - registerHyperOperator now wraps handler errors with operator name context - Updated Parse() in calculator/calculator.go: - Now wraps registry.parse() errors with context about the input - Returns a more descriptive error when parsing fails All tests pass and the binary builds and runs correctly.
2026-03-25fix: Handle Value types correctly in RPN operationsPaul Buetow
- Updated HyperMultiply, HyperSubtract, HyperDivide, HyperPower, HyperModulo to use []Value and toNumber() for Value-to-float64 conversions - Updated HyperLog2, HyperLog10, HyperLn to use []Value and toNumber() - Fixed rpn.go: - Stack.Push() now uses NewNumberValue() for float64 values - GetCurrentStack() converts []Value to []float64 - show() output uses toNumber() for Value formatting - Variable handling uses NewNumberValue() when pushing - Fixed test files (operations_test.go): - Updated all Stack.Push() calls to use NewNumberValue() - Updated Pop() comparisons to use .Number() method - Fixed format specifiers for Errorf() calls All tests pass and the binary builds and runs correctly.
2026-03-25refactor: Consolidate REPL command descriptions to single sourcePaul Buetow
- Removed duplicate getCommandDescription function from completer.go - Added package-level getCommandDescription in repl.go as single source of truth - Updated defaultGetCommandDescription to delegate to getCommandDescription - Created minimal completer.go that uses getCommandDescription for test compatibility Command descriptions are now defined only once, eliminating duplication between the original completer.go and defaultGetCommandDescription in repl.go. The refactoring maintains: - Backward compatibility (tests still work) - Consistent descriptions across the codebase - Single source of truth for command descriptions
2026-03-25docs: Add comprehensive Go documentation for REPL functionsPaul Buetow
- Enhanced NewREPL documentation with detailed parameter descriptions - Enhanced RunREPL documentation clarifying it's a convenience wrapper - Improved executor documentation explaining backward compatibility and testing usage - Enhanced defaultExecutor documentation with input processing details and panic recovery - Enhanced defaultCompleter documentation with tab-completion behavior details - Enhanced defaultGetCommandDescription documentation with command description details - Improved TTYChecker methods (IsTTY, EnsureTTY) documentation - Improved SignalHandler.Start method documentation All exported and non-exported functions in the REPL package now have comprehensive documentation comments that describe their purpose, parameters, and return values.
2026-03-25cmd/gt: add comprehensive package documentationPaul Buetow
- Enhanced Package gt documentation with detailed usage examples for percentage calculations and RPN expressions - Added architecture overview section - Enhanced Package internal documentation with version format, build instructions, and usage examples - All tests pass and application builds correctly
2026-03-24test: Improve defaultExecutor and defaultCompleter test coveragePaul Buetow
- Add TestDefaultExecutorCodePaths to test all code paths in defaultExecutor - Improve TestDefaultCompleter to test with multiple input prefixes - Add comprehensive test for unknown commands, built-in commands, and edge cases
2026-03-24refactor: Move RPNState and related declarations to top of repl.goPaul Buetow
- Move RPNState type definition before any functions - Move rpnState and rpnStateOnce variable declarations before any functions - Keep REPL struct and NewREPL constructor at the top (as per Go best practices) - Update getRPNState comment to be more descriptive This change follows Go best practices where constants, global variables, and type definitions should be at the top of the file before functions.
2026-03-24feat: Add RPN mode, rational number support, and improve REPLPaul Buetow
- Add RPN (Reverse Polish Notation) calculator with stack-based operations - Support precise rational number calculations using *big.Rat - Implement chain of responsibility pattern for command handling - Add auto-completion for built-in commands - Add history persistence with configurable max entries - Support standard operators: +, -, *, /, ^, %, lg, log, ln - Support hyper operators: [+], [-], [*], [/], [^], [%], [lg], [log], [ln] - Support stack manipulation: dup, swap, pop, show - Support variable assignments and management - Add rat mode for switching between float64 and rational calculations - Refactor calculator to return Calculation struct with formatting - Add proper version support (v0.3.0) All changes follow Go best practices with comprehensive test coverage.
2026-03-24Update version to v0.3.0Paul Buetow
2026-03-24Remove RPN_IMPLEMENTATION.md (migrated to issue tracker)Paul Buetow
2026-03-24Remove code duplication between EvalOperator and handleOperator in rpn packagePaul Buetow
- Added executeOperator helper method to handle both standard and hyper operators - Updated handleOperator, EvalOperator, and ResultStack to use executeOperator - Removed handleHyperOperatorWithRegistry method (no longer needed) - Consolidated duplicate operator handling logic into single helper This improves code maintainability by following DRY principle - operator handling logic is now in one place (executeOperator). All tests pass including hyper operator tests. 1 file changed, 23 insertions(+), 28 deletions(-).
2026-03-24Refactor calculator.Parse to make RPN vs percentage parsing boundaries explicitPaul Buetow
- Removed parseRPNFallback from strategy registry - Parse() now only handles percentage calculations (no RPN fallback) - ParseRPN() is now a separate, explicit function for RPN expressions - Added clear documentation explaining Parse() only handles percentages - Removed TestParseRPNFallthrough test (tested implicit RPN fallback) This makes the codebase easier to understand and maintain by having clear boundaries between percentage and RPN parsing. All tests pass. 2 files changed, 1 deletion(-).
2026-03-23Update to gt binary name and refactor code quality improvementsPaul Buetow
- Renamed binary from perc to gt throughout the project - Refactored calculator.Parse to use registration pattern for parsing strategies - Refactored rpn.handleOperator to use operator registry instead of switch statements - Added panic recovery to REPL executor for better resilience - Improved code organization with OperatorRegistry and strategy registration All changes maintain full test compatibility and pass race detection tests.
2026-03-23Add panic recovery to REPL executor for better resiliencePaul Buetow
Added defer-recover mechanism to the executor function to catch unexpected panics. When a panic occurs, a user-friendly error message is displayed and the REPL can continue to function. This improves the robustness of the REPL when handling unexpected errors.
2026-03-23Refactor rpn.handleOperator to use operator registry instead of switch statementPaul Buetow
Created OperatorRegistry with HandleStandardOperator and HandleHyperOperator methods. Operators are now registered at RPN initialization instead of being handled in switch statements. This makes the code more maintainable and extensible.
2026-03-23Refactor calculator.Parse to use registration pattern for parsing strategiesPaul Buetow
Created ParsingStrategy type and strategyRegistry struct to manage parsing strategies. All parsing strategies are now registered in a registry and executed in sequence. This makes the parsing logic more maintainable and extensible.
2026-03-23Code quality audit fixes from comprehensive auditPaul Buetow
- Error wrapping improvements across multiple files - Thread-safe singleton initialization using sync.Once - Proper error handling for file close operations - Removed speculative complexity in history management - Fixed operator interface design Audit report: COMPLETE_AUDIT_REPORT.md
2026-03-23Fix errcheck issues in cmd/perc, internal/repl, and internal/rpn packagesPaul Buetow
2026-03-23.golangci.ymlPaul Buetow
2026-03-23Replace global variable with function in internal/repl/commands.goPaul Buetow
2026-03-23Fix unchecked errors in internal/rpn/rpn_test.goPaul Buetow
2026-03-23Fix unchecked errors in internal/rpn/operations_test.goPaul Buetow
2026-03-23Fix inline error handling in internal/calculator/calculator.goPaul Buetow
2026-03-23Fix ireturn issue in internal/rpn/variables.goPaul Buetow
2026-03-23Replace global variable with function in internal/replPaul Buetow
2026-03-23Refactor calculator_test.go to eliminate duplicate test codePaul Buetow
2026-03-23Refactor Operator interface to reduce bloat and fix errcheck issuePaul Buetow
2026-03-23Fix error handling in cmd/perc/main.goPaul Buetow
2026-03-23Refactor rpn.go to reduce cognitive complexityPaul Buetow
2026-03-23Fix global variable in repl.go with mutex protectionPaul Buetow
2026-03-23go.mod: minor updates for test improvementsPaul Buetow
2026-03-23internal/rpn: fix assignment parsing for 'name value =' formatPaul Buetow
- Update handleAssignment to detect ' =' (space before equals) not just ' = ' (with trailing space) - Allow assignment without trailing expression: 'x 5 =' instead of 'x 5 = expr' - This fixes the REPL assignment syntax 'name value =' that was previously failing The fix also enables command-line usage like 'perc calc x 5 =' to work correctly.
2026-03-23Improve test coverage to 81.9% and fix RPN integrationPaul Buetow
- Add comprehensive unit tests for REPL package - Add completer logic tests to cover edge cases - Integrate RPN as fallback in calculator.Parse() - Add ParseRPN function to calculator package - Add tests for RPN fallthrough path The changes bring overall test coverage from ~70% to 81.9%.
2026-03-23internal/rpn: fix error handling, variable name validation, and locking issuesPaul Buetow
- Use error wrapping with ErrVariableNotFound for consistent error checking - Add isValidVariableName() for comprehensive variable name validation - Fix race condition in ClearVariables() by clearing instead of replacing map - Eliminate double-locking in FormatVariables() with internal helper function
2026-03-20LICENSE: Add MIT license filePaul Buetow
2026-03-20.golangci.yml: Add linter configurationPaul Buetow
- Configured common linters (gofmt, goimports, govet, errcheck, etc.) - Set local-prefixes for goimports to include project's module path