離作業交卷只剩 2.5 小時, 刻不容緩繼續進行第三次迭代.
第三次迭代要在前次基礎上添加對數與三角函數科學計算功能, 同樣使用逐步推進模式, 工作流所需指令如下 :
- /opsx:new <iteration_name> (建立迭代之專屬的工作區)
- /opsx:propose <requirements> (依需求起草提案書, 規格定義書, 架構設計書, 與任務清單)
- /opsx:apply <iteration_name> (依照 tasks.md 中的任務清單逐一實作此迭代功能)
- /opsx:archive (迭代完成歸檔)
廢話不多說以免誤了軍期, 馬上開工.
1. 建立迭代之專屬工作區 :
第三次迭代工作區取名為 calc-scientific :
> /opsx:new calc-scientific
... (略) ...
2. 根據需求填寫提案書 :
> /opsx:propose "在現有計算器專案上擴充科學計算功能, 包含三角函數 (sin, cos, tan) 與對數 (以 10 為底的 log, 以及自然對數 ln), 請務必處理以下邊界與轉換邏輯:1. 三角函數的輸入值預設為「角度 (Degree)」, 後端需自行轉換為弧度進行計算, 2. 處理 tan(90) 等無效角度的防呆機制, 3. 對數運算需阻擋小於或等於 0 的無效輸入, 並回傳明確的 HTTP 錯誤, 4. 前端介面需優雅地加入這些新按鈕. "
... (略) ...
3. 依據任務清單實作程式碼 :
> /opsx:apply calc-scientific
... (略) ...
完成專案實作馬上作人工測試, 開啟 127.0.0.1:5000 網頁果然多了很多科學計算按鈕 :
輸入 30 或 390 按 sin 都會得到正確結果 0.5 :
輸入 -30 按 sin 也得到正確結果 -0.5 :
接下來做 cos 的精度測試, 輸入 90 按 cos 得到一個接近 0 的極小值而非 0, 這是因為我們忘了要 AI 做微小誤差抹零處理之故, 可以在後續迭代中處理掉. 做對數測試, 輸入 1 按 log 得到正確 0, 輸入 0 按 log 則得到 Error (無限大) :
4. 歸檔結案 :
> /opsx: archive
... (略) ...
第三次迭代歸檔完畢, 終於搞定了, 趕緊來去交作業啦!
5. 打包專案上傳 GitHub :
作業繳交要求將專案上傳 GitHub, 然後將 repo 網址填入 Google 試算表內.
(1). 將所有變更加入暫存區 (打包) :
D:\gemini\calculator-project>git add .
warning: in the working copy of '.gemini/commands/opsx/apply.toml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/commands/opsx/archive.toml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/commands/opsx/explore.toml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/commands/opsx/propose.toml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/skills/openspec-apply-change/SKILL.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/skills/openspec-archive-change/SKILL.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/skills/openspec-explore/SKILL.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gemini/skills/openspec-propose/SKILL.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.python-version', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'main.py', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'openspec/changes/archive/2026-04-25-calc-basic/.openspec.yaml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'openspec/changes/archive/2026-04-25-calc-power-root/.openspec.yaml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'openspec/changes/archive/2026-04-25-calc-scientific/.openspec.yaml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'openspec/config.yaml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pyproject.toml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'uv.lock', LF will be replaced by CRLF the next time Git touches it
出現的這些 warning 是在 Windows 環境下執行 Git 時常見的警告, 它完全不影響程式碼功能或 GitHub 的上傳結果, 這只是 Git 在提醒換行符號的格式要統一, 因為 OpenSpec 工具或 AI 產生的檔案可能預設使用了 Unix 格式的換行字符 LF, 在 Windows 的命令提示字元下操作時 Git 偵測到這種不一致, 所以主動告知它會自動把這些檔案轉換成 Windows 標準的 CRLF, 因此毋須理會.
(2). 設定使用者名稱與 Email :
D:\gemini\calculator-project>git config --global user.name "Tony"
D:\gemini\calculator-project>git config --global user.email "blablabla@ms5.hinet.net"
(3). 提交變更 (貼標籤/存檔) :
D:\gemini\calculator-project>git commit -m "feat: 完成計算機專案 (基礎運算、次方根號、科學計算)"
[master (root-commit) 17a5d99] feat: 完成計算機專案 (基礎運算、次方根號、科學計算)
44 files changed, 2523 insertions(+)
create mode 100644 .gemini/commands/opsx/apply.toml
create mode 100644 .gemini/commands/opsx/archive.toml
create mode 100644 .gemini/commands/opsx/explore.toml
create mode 100644 .gemini/commands/opsx/propose.toml
create mode 100644 .gemini/skills/openspec-apply-change/SKILL.md
create mode 100644 .gemini/skills/openspec-archive-change/SKILL.md
create mode 100644 .gemini/skills/openspec-explore/SKILL.md
create mode 100644 .gemini/skills/openspec-propose/SKILL.md
create mode 100644 .gitignore
create mode 100644 .python-version
create mode 100644 GEMINI.md
create mode 100644 README.md
create mode 100644 calculator/__init__.py
create mode 100644 calculator/logic.py
create mode 100644 main.py
create mode 100644 openspec/changes/archive/2026-04-25-calc-basic/.openspec.yaml
create mode 100644 openspec/changes/archive/2026-04-25-calc-basic/design.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-basic/proposal.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-basic/specs/arithmetic-api/spec.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-basic/specs/calculator-ui/spec.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-basic/tasks.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-power-root/.openspec.yaml
create mode 100644 openspec/changes/archive/2026-04-25-calc-power-root/design.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-power-root/proposal.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-power-root/specs/advanced-arithmetic/spec.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-power-root/specs/calculator-ui/spec.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-power-root/tasks.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-scientific/.openspec.yaml
create mode 100644 openspec/changes/archive/2026-04-25-calc-scientific/design.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-scientific/proposal.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-scientific/specs/calculator-ui/spec.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-scientific/specs/scientific-functions/spec.md
create mode 100644 openspec/changes/archive/2026-04-25-calc-scientific/tasks.md
create mode 100644 openspec/config.yaml
create mode 100644 openspec/specs/advanced-arithmetic/spec.md
create mode 100644 openspec/specs/arithmetic-api/spec.md
create mode 100644 openspec/specs/calculator-ui/spec.md
create mode 100644 openspec/specs/scientific-functions/spec.md
create mode 100644 pyproject.toml
create mode 100644 static/index.html
create mode 100644 static/script.js
create mode 100644 static/style.css
create mode 100644 test_api.py
create mode 100644 uv.lock
(4). 在 GitHub 建立空的儲存庫 (Repository) :
建立一個空專案 (剛好 calculator-project 可用), 注意, 因為在本機已經有 README.md 與 .gitignore 檔案了, 不要勾選 "Add a README" 或 "Add .gitignore" 這兩項, 保持預設的空專案即可, 點擊 Create repository 新增 repo.
(5). 綁定並推上雲端 :
告訴本機 Git 這個專案要連線到哪個 GitHub 網址 :
D:\gemini\calculator-project>git remote add origin https://github.com/tony1966/calculator-project.git
把專案推上雲端 :
D:\gemini\calculator-project>git push -u origin main
Enumerating objects: 67, done.
Counting objects: 100% (67/67), done.
Delta compression using up to 16 threads
Compressing objects: 100% (51/51), done.
Writing objects: 100% (67/67), 39.46 KiB | 3.04 MiB/s, done.
Total 67 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/tony1966/calculator-project.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
此指令會出現詢問視窗, 用預設 manager 按 Select 鈕即可, 然後登入 GitHub 帳號即可上傳. 成功後到 Google sheet 登錄專案 repo 的 GitHub 網址即完成作業繳交啦! 我原以為時間太趕只能聽完課程, 沒想到忙了一整天居然搞定作業了, 哈哈.
心得 : 親自動手做一遍才能真正學會.
6. 跳出 Gemini CLI :
專案結束, 輸入 exit 離開專案 :
used 從 2% 到 10%, 用掉了 8% 資源. 連續按兩次 Ctrl+C 即可跳出 Gemini CLI 回到 PS 視窗.













沒有留言 :
張貼留言