Files
mtm-rpn-js/.continue/rules/project.md
T

2.7 KiB
Raw Blame History

Project rules — RPN Virtual Calculator

  • Build a browser-friendly RPN calculator as a JavaScript class, preferably in a single file.
  • Keep code names, categories, and API identifiers in English.
  • Use only read-only / generic public API methods: push, pop, clear, swap(index1, index2), remove(index), edit(index), isValidIndex(index), input(command), and command(name, ...args).
  • Expose inputValue as a string and isEditing as a boolean.
  • Constructor options:
    • maxSize (default 2048)
    • base (default 10)
    • angleMode (deg default; also rad and grad)
    • enabledCommands
  • Available constants: pi, e.
  • Supported operations must be centralized in one dictionary containing at least:
    • argCount
    • category
    • aliases
  • Allowed categories are limited to: Stack, Arithmetic, and Trigonometry.

Supported commands

  • Current commands:
    • add, sub, mul, div, mod, pow, sqr, neg, sqrt, recip, sin, cos, tan, asin, acos, atan, log, ln, dup, drop, swap, clear, enter
  • Aliases:
    • +, -, *, /, %, ^, y^x, 1/x

Behavior rules

  • mod is the percentage operator: a b % => (a * b) / 100
  • sqrt, asin, acos, log, and ln must throw clear, explicit domain errors
  • log uses Math.log10
  • ln uses Math.log
  • Trigonometric functions must support deg, rad, and grad
  • In the browser demo, degrees are the default angle mode
  • inputValue must remain a string to preserve future hexadecimal input support

Demo rules

  • The browser demo lives under samples/dev/
  • samples/dev/index.html is the demo entry page
  • samples/dev/index.css contains the calculator visual theme
  • samples/dev/index.js contains demo-side presentation helpers and UI logic
  • The demo UI must expose:
    • a stack display
    • a main display
    • a visible angle mode indicator
    • an angle mode selector for deg, rad, and grad
  • The demo may present user-facing labels such as +, , ×, ÷, y^x, 1/x, and while still using English command identifiers internally
  • The example HTML must group buttons by Stack, Arithmetic, and Trigonometry
  • The example HTML must call command(...) for actions
  • Keyboard support in the demo should remain consistent with the displayed help text

File references

  • samples/dev/index.html references src/rpn-calculator.js as the calculator engine used by the demo
  • Keep the demo aligned with the public calculator API exposed by src/rpn-calculator.js

Maintenance

  • Keep this file updated after each project change using the provided editing tools.
  • When changing the demo UI or calculator API, update these rules so they continue to match the current project behavior.