From eeac7a023b8ea6033b2606f7fd7d412881e7c398 Mon Sep 17 00:00:00 2001 From: zheng Date: Sat, 6 Jun 2026 01:38:33 +0800 Subject: [PATCH 1/7] refactor bash script to js script refactor bash script to js script, and make some tweaks to skills --- .github/PULL_REQUEST_TEMPLATE.md | 5 +- .github/workflows/ci.yml | 48 +- AGENTS.md | 25 +- CHANGELOG.md | 9 +- CLAUDE.md | 25 +- CONTRIBUTING.md | 1 - README-zh.md | 38 +- README.md | 38 +- assets/manifest.json | 13 +- assets/skills-zh/comet-archive/SKILL.md | 16 +- assets/skills-zh/comet-build/SKILL.md | 34 +- assets/skills-zh/comet-design/SKILL.md | 28 +- assets/skills-zh/comet-hotfix/SKILL.md | 22 +- assets/skills-zh/comet-open/SKILL.md | 18 +- assets/skills-zh/comet-tweak/SKILL.md | 22 +- assets/skills-zh/comet-verify/SKILL.md | 40 +- assets/skills-zh/comet/SKILL.md | 38 +- assets/skills/comet-archive/SKILL.md | 16 +- assets/skills/comet-build/SKILL.md | 34 +- assets/skills/comet-design/SKILL.md | 28 +- assets/skills/comet-hotfix/SKILL.md | 22 +- assets/skills/comet-open/SKILL.md | 18 +- assets/skills/comet-tweak/SKILL.md | 22 +- assets/skills/comet-verify/SKILL.md | 40 +- assets/skills/comet/SKILL.md | 38 +- assets/skills/comet/scripts/comet-archive.js | 106 ++ assets/skills/comet/scripts/comet-archive.sh | 295 ------ assets/skills/comet/scripts/comet-env.js | 21 + assets/skills/comet/scripts/comet-env.sh | 110 --- assets/skills/comet/scripts/comet-guard.js | 281 ++++++ assets/skills/comet/scripts/comet-guard.sh | 596 ------------ assets/skills/comet/scripts/comet-handoff.js | 109 +++ assets/skills/comet/scripts/comet-handoff.sh | 263 ----- assets/skills/comet/scripts/comet-lib.js | 212 ++++ assets/skills/comet/scripts/comet-state.js | 384 ++++++++ assets/skills/comet/scripts/comet-state.sh | 908 ------------------ .../comet/scripts/comet-yaml-validate.js | 68 ++ .../comet/scripts/comet-yaml-validate.sh | 200 ---- package.json | 4 +- pnpm-lock.yaml | 27 +- scripts/run-bats.js | 189 ---- test/shell/comet-state.bats | 214 ----- test/ts/comet-scripts.test.ts | 399 +++----- test/ts/run-bats.test.ts | 38 - test/ts/skills.test.ts | 25 +- 45 files changed, 1684 insertions(+), 3403 deletions(-) create mode 100644 assets/skills/comet/scripts/comet-archive.js delete mode 100644 assets/skills/comet/scripts/comet-archive.sh create mode 100644 assets/skills/comet/scripts/comet-env.js delete mode 100644 assets/skills/comet/scripts/comet-env.sh create mode 100644 assets/skills/comet/scripts/comet-guard.js delete mode 100644 assets/skills/comet/scripts/comet-guard.sh create mode 100644 assets/skills/comet/scripts/comet-handoff.js delete mode 100644 assets/skills/comet/scripts/comet-handoff.sh create mode 100644 assets/skills/comet/scripts/comet-lib.js create mode 100644 assets/skills/comet/scripts/comet-state.js delete mode 100644 assets/skills/comet/scripts/comet-state.sh create mode 100644 assets/skills/comet/scripts/comet-yaml-validate.js delete mode 100644 assets/skills/comet/scripts/comet-yaml-validate.sh delete mode 100644 scripts/run-bats.js delete mode 100644 test/shell/comet-state.bats delete mode 100644 test/ts/run-bats.test.ts diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b2be4a74..74fe9ae4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,7 +9,7 @@ - [ ] CLI commands (`init`, `status`, `doctor`, `update`) - [ ] Core installer / platform detection - [ ] Comet skills (`assets/skills/`, `assets/skills-zh/`) -- [ ] Comet shell scripts (`assets/skills/comet/scripts/`) +- [ ] Comet Node scripts (`assets/skills/comet/scripts/`) - [ ] Tests / CI - [ ] Documentation / changelog - [ ] Other: @@ -23,7 +23,6 @@ - [ ] `pnpm format:check` - [ ] `pnpm test` - [ ] `pnpm test -- test/ts/comet-scripts.test.ts` -- [ ] `pnpm test:shell` - [ ] Not run: ## ✅ Checklist @@ -33,7 +32,7 @@ - [ ] `CHANGELOG.md` is updated when behavior changes - [ ] Skill changes were made in Chinese first when applicable, then synced to English - [ ] New scripts are included in `assets/manifest.json` and relevant tests -- [ ] Shell scripts remain portable across macOS, Linux, and Windows Git Bash +- [ ] Comet Node scripts remain portable across macOS, Linux, and Windows - [ ] No unrelated generated files or local artifacts are included ## 👀 Notes for Reviewers diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03e5cc51..49f7b2d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,27 +34,6 @@ jobs: - run: pnpm test:coverage - shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Run shellcheck - uses: ludeeus/action-shellcheck@2.0.0 - with: - scandir: ./assets/skills/comet/scripts - - bats-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install bats - run: sudo apt-get install -y bats - - - name: Run shell tests - run: bats test/shell/*.bats - script-smoke: runs-on: ${{ matrix.os }} strategy: @@ -77,9 +56,6 @@ jobs: - name: Run Comet script smoke tests run: pnpm test -- test/ts/comet-scripts.test.ts - - name: Run portable shell tests - run: pnpm test:shell - init-e2e: runs-on: ${{ matrix.os }} strategy: @@ -132,11 +108,13 @@ jobs: .iflow/skills .pi/skills .qoder/skills .agents/skills \ .bob/skills .forge/skills .trae/skills .github/skills; do check_file "$PROJ/$sd/comet/SKILL.md" - check_file "$PROJ/$sd/comet/scripts/comet-guard.sh" - check_file "$PROJ/$sd/comet/scripts/comet-state.sh" - check_file "$PROJ/$sd/comet/scripts/comet-handoff.sh" - check_file "$PROJ/$sd/comet/scripts/comet-yaml-validate.sh" - check_file "$PROJ/$sd/comet/scripts/comet-archive.sh" + check_file "$PROJ/$sd/comet/scripts/comet-guard.js" + check_file "$PROJ/$sd/comet/scripts/comet-state.js" + check_file "$PROJ/$sd/comet/scripts/comet-handoff.js" + check_file "$PROJ/$sd/comet/scripts/comet-yaml-validate.js" + check_file "$PROJ/$sd/comet/scripts/comet-archive.js" + check_file "$PROJ/$sd/comet/scripts/comet-env.js" + check_file "$PROJ/$sd/comet/scripts/comet-lib.js" done echo "All 28 platforms project Comet skills: OK" shell: bash @@ -220,11 +198,13 @@ jobs: .iflow/skills .pi/skills .qoder/skills .gemini/antigravity/skills \ .bob/skills .forge/skills .trae/skills .github/skills; do check_file "$HOME_DIR/$sd/comet/SKILL.md" - check_file "$HOME_DIR/$sd/comet/scripts/comet-guard.sh" - check_file "$HOME_DIR/$sd/comet/scripts/comet-state.sh" - check_file "$HOME_DIR/$sd/comet/scripts/comet-handoff.sh" - check_file "$HOME_DIR/$sd/comet/scripts/comet-yaml-validate.sh" - check_file "$HOME_DIR/$sd/comet/scripts/comet-archive.sh" + check_file "$HOME_DIR/$sd/comet/scripts/comet-guard.js" + check_file "$HOME_DIR/$sd/comet/scripts/comet-state.js" + check_file "$HOME_DIR/$sd/comet/scripts/comet-handoff.js" + check_file "$HOME_DIR/$sd/comet/scripts/comet-yaml-validate.js" + check_file "$HOME_DIR/$sd/comet/scripts/comet-archive.js" + check_file "$HOME_DIR/$sd/comet/scripts/comet-env.js" + check_file "$HOME_DIR/$sd/comet/scripts/comet-lib.js" done echo "All 28 platforms global Comet skills: OK" shell: bash diff --git a/AGENTS.md b/AGENTS.md index 4bdd6754..fed2e4a0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,34 +1,35 @@ ## 测试 ```bash -npx vitest run test/ts/comet-scripts.test.ts # shell 脚本测试 +npx vitest run test/ts/comet-scripts.test.ts # Comet Node 脚本测试 npx vitest run # 全量测试 ``` -## Shell 脚本规范 +## Comet Node 脚本规范 -脚本位于 `assets/skills/comet/scripts/`,必须跨平台兼容(macOS / Linux / Windows Git Bash): +脚本位于 `assets/skills/comet/scripts/`,必须跨平台兼容(macOS / Linux / Windows): -- **禁止** `sed -i`(GNU/BSD 不兼容),用 `awk` 做字段替换 -- 必须兼容 `sha256sum`(GNU)和 `shasum -a 256`(BSD/macOS) -- 所有可选 grep 结果加 `|| true` 防止 `pipefail` 误杀 +- 使用 Node.js 实现,不新增 `.sh` wrapper +- 脚本间调用使用 `node