Add mathcalc package#227
Conversation
There was a problem hiding this comment.
Thank you.
A short maths package with two very similar triggers calling a Python eval script. The script is pretty safe as long as executable code isn't pasted into the form, which is unlikely to occur in a user-environment.
I'll let Copilot do its stuff and run the automated checks to ensure it can be merged, but I have made a couple of suggestions, and the use of a script extension instead of shell is necessary, please.
Please restore the repository README.md.
There was a problem hiding this comment.
Pull request overview
Adds a new mathcalc package (v0.1.0) that evaluates math expressions inline by shelling out to Python via PowerShell, exposing two triggers (:calc for result-only, :xcalc for expression = result). The PR also (apparently inadvertently) deletes the repository's top-level README.md.
Changes:
- New package
packages/mathcalc/0.1.0/with_manifest.yml,package.yml, andREADME.md. - Two triggers (
:calc,:xcalc) using a PowerShell + Pythonevalpipeline. - Deletion of the repo-root
README.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| README.md | Repo-level README removed entirely — appears unintentional. |
| packages/mathcalc/0.1.0/_manifest.yml | Manifest for the new package; homepage looks like a placeholder. |
| packages/mathcalc/0.1.0/package.yml | Defines :calc and :xcalc matches via duplicated PowerShell+Python eval commands (Windows-only). |
| packages/mathcalc/0.1.0/README.md | User-facing docs and examples for the new package. |
Comments suppressed due to low confidence (1)
README.md:1
- This PR deletes the entire repository README.md. This appears to be unintentional and unrelated to adding a new package. Please restore the README.md file.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| type: shell | ||
| params: | ||
| shell: powershell | ||
| cmd: "python -c \"from math import *; x = '{{input.val}}'.replace('^', '**'); r = eval(x); print(int(r) if r == int(r) else round(r, 10))\"" |
|
Thanks for the feedback!
|
|
Hi, additional changes applied:
Ready for re-review, thanks! |
| from math import * | ||
| x = '{{input.val}}'.replace('^', '**') | ||
| r = eval(x) | ||
| print(int(r) if r == int(r) else round(r, 10)) |
| - `sin(pi/2)` → `1` | ||
| - `log10(1000)` → `3` | ||
| - `factorial(6)` → `720` | ||
| - `(sqrt(2)+1)^2` → `5.828427124` |
|
Thank you. The package should appear in the Hub in a few hours. |
Inline math calculator using Python's math engine. Supports +, -, *, /, ^, sqrt, trig, log, factorial and more. Two triggers: :calc (result only) and :xcalc (expression = result)