@manhquy/flow-skill 0.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +21 -0
  3. package/README.md +152 -0
  4. package/README_VN.md +134 -0
  5. package/SECURITY.md +69 -0
  6. package/bin/cli.mjs +382 -0
  7. package/package.json +52 -0
  8. package/skills/flow/SKILL.md +234 -0
  9. package/skills/flow/_templates/00-idea.md +16 -0
  10. package/skills/flow/_templates/00-inspect.md +42 -0
  11. package/skills/flow/_templates/01-research.md +59 -0
  12. package/skills/flow/_templates/02-scope.md +71 -0
  13. package/skills/flow/_templates/03-prd.md +57 -0
  14. package/skills/flow/_templates/04-adr.md +21 -0
  15. package/skills/flow/_templates/05-contract.md +59 -0
  16. package/skills/flow/_templates/card.md +26 -0
  17. package/skills/flow/_templates/constitution.md +22 -0
  18. package/skills/flow/eval/fixtures/f01a/flow/01-research.md +77 -0
  19. package/skills/flow/eval/fixtures/f01b/flow/01-research.md +75 -0
  20. package/skills/flow/eval/fixtures/f02a/flow/02-scope.md +56 -0
  21. package/skills/flow/eval/fixtures/f02b/flow/02-scope.md +65 -0
  22. package/skills/flow/eval/fixtures/fcda/.flow/.gitkeep +0 -0
  23. package/skills/flow/eval/fixtures/fcda/cards/C-001.md +46 -0
  24. package/skills/flow/eval/fixtures/fcdb/.flow/.gitkeep +0 -0
  25. package/skills/flow/eval/fixtures/fcdb/cards/C-001.md +35 -0
  26. package/skills/flow/eval/manifest.tsv +7 -0
  27. package/skills/flow/harness/README.md +117 -0
  28. package/skills/flow/harness/_db.py +228 -0
  29. package/skills/flow/harness/_domain.py +161 -0
  30. package/skills/flow/harness/_presence.py +109 -0
  31. package/skills/flow/harness/flow_harness.py +1103 -0
  32. package/skills/flow/harness/repo_map.py +93 -0
  33. package/skills/flow/harness/schema/001-init.sql +129 -0
  34. package/skills/flow/harness/schema/002-story-verify.sql +9 -0
  35. package/skills/flow/harness/schema/003-tool-registry.sql +15 -0
  36. package/skills/flow/harness/schema/004-intervention.sql +15 -0
  37. package/skills/flow/harness/schema/005-tool-extensions.sql +20 -0
  38. package/skills/flow/harness/schema/009-accessed-count.sql +11 -0
  39. package/skills/flow/harness/schema/010-usage-event.sql +42 -0
  40. package/skills/flow/harness/schema/011-usage-gate-reason.sql +8 -0
  41. package/skills/flow/harness/schema/012-usage-ephemeral.sql +10 -0
  42. package/skills/flow/law/CLAUDE.md +140 -0
  43. package/skills/flow/law/DESIGN.md +141 -0
  44. package/skills/flow/law/RETRO.md +13 -0
  45. package/skills/flow/playbooks/README.md +28 -0
  46. package/skills/flow/playbooks/cloudflare-ai-gateway-qwen.md +346 -0
  47. package/skills/flow/playbooks/docker-deploy-stale-cache.md +32 -0
  48. package/skills/flow/playbooks/rag-lite-postgres-cloudflare.md +192 -0
  49. package/skills/flow/playbooks/windows-gitbash-jsonl-telemetry.md +57 -0
  50. package/skills/flow/references/adversarial-review.md +197 -0
  51. package/skills/flow/references/agent-detection.md +88 -0
  52. package/skills/flow/references/agent-stage-mapping.md +114 -0
  53. package/skills/flow/references/antigravity-integration.md +92 -0
  54. package/skills/flow/references/auto-run.md +81 -0
  55. package/skills/flow/references/claudekit-skills.md +128 -0
  56. package/skills/flow/references/codex-integration.md +104 -0
  57. package/skills/flow/references/command-dispatch.md +54 -0
  58. package/skills/flow/references/debt-and-halts.md +41 -0
  59. package/skills/flow/references/design-review-checklist.md +42 -0
  60. package/skills/flow/references/gate-eval.md +186 -0
  61. package/skills/flow/references/gate-rules.md +171 -0
  62. package/skills/flow/references/ground-truth-gates.md +49 -0
  63. package/skills/flow/references/loop-harness-2026-principles.md +52 -0
  64. package/skills/flow/references/mode-work.md +37 -0
  65. package/skills/flow/references/project-types.md +42 -0
  66. package/skills/flow/references/stage-state-machine.md +47 -0
  67. package/skills/flow/references/ui-patterns-tcr.md +49 -0
  68. package/skills/flow/runner/flow.cmd +18 -0
  69. package/skills/flow/runner/flow.sh +3297 -0
  70. package/skills-manifest.json +70 -0
  71. package/src/constants.mjs +65 -0
  72. package/src/detect.mjs +36 -0
  73. package/src/help.mjs +42 -0
  74. package/src/installer.mjs +231 -0
  75. package/src/prompt.mjs +60 -0
  76. package/src/tty.mjs +11 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,60 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@manhquy/flow-skill`. Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: [SemVer](https://semver.org/).
4
+
5
+ ## [0.1.0-rc.1] — 2026-07-12
6
+
7
+ Initial release candidate. Ships to the `rc` npm dist-tag.
8
+
9
+ ### Post-implementation audit fixes (before first publish)
10
+ - **installer:** `acquireLock` was TOCTOU-racy — switched to atomic `writeFileSync(..., { flag: 'wx' })` so two `npx` runs cannot both acquire.
11
+ - **installer:** dropped `EACCES` from `withRetry` — POSIX permission errors are almost never transient; retrying only masked the honest error with ~1.3 s of latency.
12
+ - **installer:** dropped the post-copy `assertNoSymlinks(destDir)` walk — it would have rejected legitimate Windows NTFS junctions users may have placed under their skills tree. The source-side scan is the actual security control.
13
+ - **detect:** `~/foo` template resolution now uses `path.join(...)` so Windows dests no longer surface mixed separators in `--json` output.
14
+ - **cli:** removed the aspirational "hit Ctrl+C twice to hard-exit" branch — synchronous install loop cannot be preempted by signal handlers, and the second-strike `process.exit(130)` would have leaked the current install's advisory lock.
15
+ - **workflow:** `npm pack --dry-run --json` now runs with `--ignore-scripts` so `prepack` stdout does not corrupt the JSON audit payload.
16
+ - **workflow:** pre-release semver can never be published to dist-tag `latest` (belt-and-suspenders guard alongside the tag-name auto-derivation).
17
+ - **workflow:** `child_process` guard narrowed to import statements only — the old verb-based regex false-hit `RegExp.prototype.exec` and code comments containing "exec".
18
+ - **docs:** README EN + VN now recommend `@rc` (dist-tag) during the RC window and explain why `@0.1.x` will not resolve to a pre-release. Full JSONL event/field/exit-code contract table added. Troubleshooting section covers `EBUSY`/stale lock/version pin/Node floor.
19
+ - **docs:** dropped stale `import.meta.dirname` justification for the Node ≥20.11 floor — the real reasons are `node:util.parseArgs` (stable) and `node:test`.
20
+ - **docs:** SECURITY.md reframes `skills-manifest.json` as a completeness signal, not a tamper-detection primitive (that role belongs to npm provenance).
21
+ - **package.json:** dropped stale `opencode` keyword — no opencode target is shipped.
22
+
23
+ ### Pre-publish critical fixes (caught during first live `npm publish` attempt)
24
+ - **`package.json.bin`**: value was `./bin/cli.mjs` — npm strips the leading `./` and warns "invalid and removed", meaning the published tarball would have shipped with NO `flow-skill` executable. `npx @manhquy/flow-skill` would have failed to find the command. Fixed to `bin/cli.mjs` per `npm pkg fix`.
25
+ - **Tarball weight**: `skills/flow/harness/__pycache__/` was shipping 9 Python bytecode files (~230 KB) — regenerated at runtime, different for each Python minor. `scripts/sync.mjs` now filters `__pycache__/`, `*.pyc`, `*.pyo`, and OS junk during copy. Both the copy and the completeness check share one predicate so the counts still line up. Tarball dropped 786 KB → 553 KB unpacked (298 KB → 198 KB gzipped).
26
+
27
+ ### Publish-path corrections (research-driven, 2026-07 npm docs)
28
+ - **engines:** bumped from `>=20.11.0` → `>=22.14.0`. Node 20 reached end-of-life April 2026, and npm OIDC Trusted Publisher (the whole point of our publish workflow) requires npm >=11.5.1 which ships bundled with Node 22.14+. Older Node bundles npm 10.x which fails the OIDC handshake with a misleading 404. Runtime version guard in `bin/cli.mjs` matches.
29
+ - **workflow:** `.github/workflows/publish-npm-wrapper.yml` `node-version` bumped from `20.11` → `22`, plus an explicit `npm install -g npm@latest` step so the runner always has the OIDC-capable npm.
30
+ - **CI:** new `.github/workflows/ci.yml` — cross-OS matrix (`ubuntu-latest × macos-latest × windows-latest`) × Node `[22, 24]`. Runs on push/PR touching `npm-wrapper/**` or the skill content. Includes tarball-size gate and the `child_process` import guard.
31
+
32
+ ### Additional test coverage
33
+ - `test/lock-atomicity.test.mjs` — 9 tests locking down the audit-fix regressions: `acquireLock` `wx` semantics, corrupted lock reclamation, `withRetry` no-longer-retries `EACCES`, `withRetry` still retries `EBUSY`/`EPERM`/`ENOTEMPTY`, `detect.mjs` OS-separator normalization for Claude and Antigravity dests.
34
+
35
+ ### Developer tooling
36
+ - `scripts/smoke.mjs` — post-publish end-to-end verifier. Runs `npm view` for version + provenance, then `--help`, `--dry-run --json`, and a real install into a scratch `$HOME`. Invoke as `npm run smoke -- <version>`.
37
+ - `.github/ISSUE_TEMPLATE/bug-report-npm-wrapper.yml` + `.github/PULL_REQUEST_TEMPLATE.md` — structured intake.
38
+
39
+ ### Added
40
+ - `npx @manhquy/flow-skill` installer for 4 coding-agent targets: Claude Code, Codex CLI, Agents home, Antigravity (CLI + IDE).
41
+ - Interactive multi-select prompt via `@clack/prompts` when stdin/stdout are TTY.
42
+ - Non-interactive flags: `--yes`, `--target`/`-t` (repeatable + comma form), `--all`, `--project`, `--dir`, `--json`, `--dry-run`, `--help`.
43
+ - JSONL streaming (`--json`) with `plan`, `install:start`, `install:done`, and `summary` events.
44
+ - Pure Node install path — no shell/PowerShell spawn, single code path across macOS/Linux/Windows.
45
+ - Semantic parity with upstream `install.sh:24-27`: clean 6 subdirs (`runner`, `_templates`, `law`, `references`, `harness`, `playbooks`) then merge-copy. User files outside those subdirs are preserved.
46
+ - Defense: symlink rejection at sync and install time. Advisory lock to reduce concurrent-run races. `EBUSY`/`EPERM`/`ENOTEMPTY`/`EACCES` retry with 100/300/900 ms backoff.
47
+ - `chmod +x` on `runner/flow.sh` (parity with `install.sh:27`; no-op on Windows NTFS).
48
+ - `--project` scope enforced to Claude only (agent-contract limitation).
49
+ - 35 tests via `node:test` across 4 suites — installer semantics, detection markers, CLI black-box smoke, TOCTOU + retry lock-atomicity regression suite.
50
+ - Runtime Node version guard (>=22.14.0) — floor set by npm OIDC Trusted Publisher requirements (npm >=11.5.1 ships with Node 22.14+) and by Node 20 reaching end-of-life April 2026; `engines` in `package.json` matches.
51
+
52
+ ### Security
53
+ - Bundled `skills/flow` synced from upstream `flow-skill` repo via `scripts/sync.mjs`; `skills-manifest.json` records file count + list for post-hoc verification.
54
+ - No `postinstall` hook. `prepack` runs `sync.mjs` on the dev machine only and is not in the published tarball.
55
+ - GitHub Actions trusted publishing: OIDC-only, required-reviewer environment, `npm publish --provenance` (SLSA Level 2).
56
+ - README and docs pin `@0.1.x` semver rather than `@latest`.
57
+
58
+ ### Notes
59
+ - v0.1.0-rc.N is a pre-release channel. Test explicitly with `npx @manhquy/flow-skill@0.1.0-rc.1`. Pinning `@0.1.x` does not fetch pre-release versions.
60
+ - Promotion criterion from rc → stable v0.1.0: 7 days with no critical bug reports, all success criteria (documented in the project's plan artifact) manually verified across macOS + Linux + Windows, and at least one external tester install.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 manhquy <manhquy.mqy@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @manhquy/flow-skill
2
+
3
+ One-command installer that copies the [flow](https://github.com/manhquydev/flow-skill) skill into your coding agent(s).
4
+
5
+ - Pure Node — works on macOS, Linux, and Windows (cmd, PowerShell 5.1/7, Git Bash) with the same code path.
6
+ - Interactive multi-select or non-interactive CI mode.
7
+ - Preserves any user-added files in the destination outside the 6 subdirs the skill owns.
8
+ - Ships with [npm provenance](https://docs.npmjs.com/generating-provenance-statements) via GitHub Actions trusted publishing (from rc.2+).
9
+
10
+ ## Status — 2026-07-12
11
+
12
+ - ✅ Code complete, 35/35 tests green, CI matrix green (ubuntu/macos/windows × Node 22/24).
13
+ - ⏳ Not yet on npm registry. Repo public + renamed; transfer to `manhquy` account pending accept; first publish (`v0.1.0-rc.1`, manual, no provenance) queued.
14
+ - ➡️ Once published, this section will disappear and `npx @manhquy/flow-skill@rc` becomes the canonical install path.
15
+
16
+ ## Install
17
+
18
+ **A. From the git repo (works today, no npm registry needed)**
19
+
20
+ ```bash
21
+ git clone https://github.com/manhquydev/flow-skill.git
22
+ cd flow-skill/npm-wrapper
23
+ npm install
24
+ npm run sync # materializes skills/flow from ../skills/flow
25
+ npm link # exposes `flow-skill` as a global command
26
+
27
+ flow-skill --yes --all --dry-run --json # smoke check
28
+ flow-skill # interactive install
29
+ ```
30
+
31
+ To remove: `npm unlink -g @manhquy/flow-skill`.
32
+
33
+ **B. Via npx (once published)**
34
+
35
+ ```
36
+ # Pre-release channel (RC candidate — will exist after first publish)
37
+ npx @manhquy/flow-skill@rc
38
+ ```
39
+
40
+ An interactive prompt asks which agents to install to. Pick one or more, confirm, done.
41
+
42
+ > **RC phase**: pin `@rc` (dist-tag) or a specific version like `@0.1.0-rc.1`. `npx @manhquy/flow-skill@0.1.x` will start working after stable `0.1.0` is published — semver ranges do **not** match pre-release tuples by default. See [SECURITY.md](./SECURITY.md).
43
+
44
+ ## Non-interactive
45
+
46
+ ```
47
+ # Default selection (Claude + anything detected)
48
+ npx @manhquy/flow-skill@rc --yes
49
+
50
+ # Explicit targets
51
+ npx @manhquy/flow-skill@rc --yes -t claude -t codex
52
+ npx @manhquy/flow-skill@rc --yes -t claude,codex # comma form OK
53
+
54
+ # Force all four targets even if not detected
55
+ npx @manhquy/flow-skill@rc --yes --all
56
+
57
+ # Project scope (Claude only — see below)
58
+ npx @manhquy/flow-skill@rc --yes --project --dir .
59
+
60
+ # CI-friendly JSONL output
61
+ npx @manhquy/flow-skill@rc --yes --all --dry-run --json
62
+ ```
63
+
64
+ ## Targets
65
+
66
+ | Name | Label | Destination | Detection marker |
67
+ |---|---|---|---|
68
+ | `claude` | Claude Code | `~/.claude/skills/flow` | any presence of `~/.claude` (Claude is always pre-checked) |
69
+ | `codex` | Codex CLI | `~/.codex/skills/flow` | `~/.codex/skills` |
70
+ | `agents` | Agents home | `~/.agents/skills/flow` | `~/.agents/skills` |
71
+ | `antigravity` | Antigravity (CLI + IDE) | `~/.gemini/antigravity-cli/skills/flow` **and** `~/.gemini/config/skills/flow` | `~/.gemini/antigravity-cli` **or** `~/.gemini/config/skills` |
72
+
73
+ `--project` scope writes to `<dir>/.claude/skills/flow` and supports only the `claude` target. Combining `--project` with a non-Claude target exits with code `2`.
74
+
75
+ ## After install
76
+
77
+ - Claude Code: type `/flow`.
78
+ - Codex CLI: type `$flow` (restart Codex once to load).
79
+ - Antigravity: `/flow` in the IDE.
80
+ - Diagnostics: run `/flow doctor` from your agent.
81
+
82
+ ## Uninstall
83
+
84
+ Delete the target directories:
85
+
86
+ ```
87
+ # Global installs
88
+ rm -rf ~/.claude/skills/flow
89
+ rm -rf ~/.codex/skills/flow
90
+ rm -rf ~/.agents/skills/flow
91
+ rm -rf ~/.gemini/antigravity-cli/skills/flow
92
+ rm -rf ~/.gemini/config/skills/flow
93
+
94
+ # Project scope (only Claude)
95
+ rm -rf <project>/.claude/skills/flow
96
+ ```
97
+
98
+ ## Troubleshooting
99
+
100
+ - **Windows `EBUSY` / `EPERM` mid-install**: an agent (Claude Code, Codex, Antigravity IDE) is holding a file inside the destination. Close the agent and re-run. The installer already retries with 100/300/900 ms backoff before surfacing the error.
101
+ - **Stale advisory lock**: a prior run crashed. The next run detects the dead PID and reclaims the lock automatically. If it does not (very rare — the recorded PID was recycled by another live process), delete `<parent-of-dest>/.flow-skill.installing.lock`.
102
+ - **`No matching version found` on `@0.1.x`**: you are trying to install a pre-release version through a stable range. Use `@rc` (dist-tag) or an explicit `@0.1.0-rc.N` until stable `0.1.0` ships.
103
+ - **Node too old** (`requires Node.js >=20.11.0`): upgrade with your preferred version manager (`nvm install 20`, `fnm install 20`, or Node's official installer).
104
+
105
+ ## JSONL contract
106
+
107
+ `--json` streams one JSON object per line:
108
+
109
+ ```jsonl
110
+ {"event":"plan","version":"0.1.0-rc.1","dryRun":false,"scope":"global","targets":["claude","codex"]}
111
+ {"event":"install:start","target":"claude","dests":["~/.claude/skills/flow"]}
112
+ {"event":"install:done","target":"claude","dests":["~/.claude/skills/flow"],"result":"success","error":null,"warnings":[]}
113
+ {"event":"summary","success":true,"total":2,"attempted":2,"installed":2,"failed":0,"skipped":0,"aborted":false}
114
+ ```
115
+
116
+ `--json --dry-run` emits only the `plan` event. `--json` implies non-interactive; do not combine with a TTY prompt session.
117
+
118
+ ### Event contract
119
+
120
+ | Event | Required fields | Notes |
121
+ |---|---|---|
122
+ | `plan` | `version` (string), `dryRun` (bool), `scope` (`global`\|`project`), `targets` (string[]) | Always the first event. |
123
+ | `install:start` | `target` (string), `dests` (string[]) | One per selected target. |
124
+ | `install:done` | `target`, `dests`, `result` (`success`\|`failed`), `error` (string\|null), `warnings` (string[]) | Fired after each target. `error` is `null` on success. |
125
+ | `summary` | `success` (bool), `total`, `attempted`, `installed`, `failed`, `skipped`, `aborted` (bool) | Always the last event. Counts sum: `attempted = installed + failed`; `skipped = total - attempted`. |
126
+ | `error` | `message` (string), `exitCode` (int) | Emitted only when the process crashes before completing a normal flow (e.g. missing bundled skill). Then exits with `exitCode`. |
127
+
128
+ Exit codes: `0` success · `1` at least one target failed · `2` invalid usage (bad target name, `--project` with a non-Claude target, missing bundled skill) · `130` `SIGINT` (Ctrl+C).
129
+
130
+ The contract is additive within `0.1.x`. New optional fields may appear; existing fields will not be renamed or removed.
131
+
132
+ ## Requirements
133
+
134
+ - Node.js **>= 22.14.0** — Node 20 reached end-of-life in April 2026, and the publish workflow requires npm >=11.5.1 (bundled with Node 22.14+) for OIDC Trusted Publisher support
135
+
136
+ ## Provenance
137
+
138
+ Every version published from the CI workflow carries an [npm provenance](https://docs.npmjs.com/generating-provenance-statements) attestation (SLSA Build Level 2). Verify with:
139
+
140
+ ```
141
+ npm view @manhquy/flow-skill@<version> dist.attestations.provenance
142
+ ```
143
+
144
+ > **RC-window exception**: `v0.1.0-rc.1` was published manually from a developer machine to bootstrap npm's Trusted Publisher registration (Trusted Publisher cannot bind to a package that does not exist yet). npm does not generate provenance for publishes outside supported CI. All subsequent versions (`v0.1.0-rc.2` onward) publish through the workflow and are attested.
145
+
146
+ ## Security
147
+
148
+ See [SECURITY.md](./SECURITY.md) for the threat model, what the installer will and will not do, and how to report issues.
149
+
150
+ ## License
151
+
152
+ MIT © 2026 manhquy
package/README_VN.md ADDED
@@ -0,0 +1,134 @@
1
+ # @manhquy/flow-skill
2
+
3
+ Trình cài đặt một-lệnh sao chép skill [flow](https://github.com/manhquydev/flow-skill) vào (các) coding agent của bạn.
4
+
5
+ - Pure Node — chạy trên macOS, Linux, Windows (cmd, PowerShell 5.1/7, Git Bash) với cùng một code path.
6
+ - Multi-select tương tác hoặc chế độ CI không tương tác.
7
+ - Bảo toàn file người dùng đã thêm ngoài 6 subdir mà skill sở hữu.
8
+ - Ship kèm [npm provenance](https://docs.npmjs.com/generating-provenance-statements) qua GitHub Actions trusted publishing (từ rc.2+).
9
+
10
+ ## Tình trạng — 2026-07-12
11
+
12
+ - ✅ Code hoàn thiện, 35/35 test xanh, CI matrix xanh (ubuntu/macos/windows × Node 22/24).
13
+ - ⏳ Chưa lên npm registry. Repo đã public + đã rename; transfer sang `manhquy` account đang chờ accept; first publish (`v0.1.0-rc.1`, thủ công, không có provenance) đang queued.
14
+ - ➡️ Sau khi publish, section này sẽ biến mất và `npx @manhquy/flow-skill@rc` thành lệnh cài chính thức.
15
+
16
+ ## Cài đặt
17
+
18
+ **A. Từ git repo (chạy được ngay, không cần npm registry)**
19
+
20
+ ```bash
21
+ git clone https://github.com/manhquydev/flow-skill.git
22
+ cd flow-skill/npm-wrapper
23
+ npm install
24
+ npm run sync # materialize skills/flow từ ../skills/flow
25
+ npm link # expose `flow-skill` như global command
26
+
27
+ flow-skill --yes --all --dry-run --json # smoke check
28
+ flow-skill # cài tương tác
29
+ ```
30
+
31
+ Gỡ: `npm unlink -g @manhquy/flow-skill`.
32
+
33
+ **B. Qua npx (sau khi publish)**
34
+
35
+ ```
36
+ # Kênh pre-release (RC candidate — sẽ tồn tại sau first publish)
37
+ npx @manhquy/flow-skill@rc
38
+ ```
39
+
40
+ Prompt tương tác hỏi cài vào agent nào. Chọn một hoặc nhiều, xác nhận, xong.
41
+
42
+ > **Giai đoạn RC**: pin `@rc` (dist-tag) hoặc phiên bản cụ thể `@0.1.0-rc.1`. `npx @manhquy/flow-skill@0.1.x` chỉ dùng được sau khi stable `0.1.0` publish — semver range **không** match pre-release theo mặc định. Xem [SECURITY.md](./SECURITY.md).
43
+
44
+ ## Non-interactive
45
+
46
+ ```
47
+ # Chọn mặc định (Claude + những agent detect được)
48
+ npx @manhquy/flow-skill@rc --yes
49
+
50
+ # Target rõ ràng
51
+ npx @manhquy/flow-skill@rc --yes -t claude -t codex
52
+ npx @manhquy/flow-skill@rc --yes -t claude,codex # Dạng comma OK
53
+
54
+ # Ép cài cả 4 target dù không detect
55
+ npx @manhquy/flow-skill@rc --yes --all
56
+
57
+ # Project scope (chỉ Claude — xem bên dưới)
58
+ npx @manhquy/flow-skill@rc --yes --project --dir .
59
+
60
+ # JSONL cho CI
61
+ npx @manhquy/flow-skill@rc --yes --all --dry-run --json
62
+ ```
63
+
64
+ ## Targets
65
+
66
+ | Tên | Nhãn | Đích | Marker phát hiện |
67
+ |---|---|---|---|
68
+ | `claude` | Claude Code | `~/.claude/skills/flow` | bất kỳ presence của `~/.claude` (Claude luôn pre-check) |
69
+ | `codex` | Codex CLI | `~/.codex/skills/flow` | `~/.codex/skills` |
70
+ | `agents` | Agents home | `~/.agents/skills/flow` | `~/.agents/skills` |
71
+ | `antigravity` | Antigravity (CLI + IDE) | `~/.gemini/antigravity-cli/skills/flow` **và** `~/.gemini/config/skills/flow` | `~/.gemini/antigravity-cli` **hoặc** `~/.gemini/config/skills` |
72
+
73
+ Scope `--project` ghi vào `<dir>/.claude/skills/flow` và chỉ hỗ trợ target `claude`. Kết hợp `--project` với target khác → exit code `2`.
74
+
75
+ ## Sau khi cài
76
+
77
+ - Claude Code: gõ `/flow`.
78
+ - Codex CLI: gõ `$flow` (restart Codex 1 lần để load).
79
+ - Antigravity: `/flow` trong IDE.
80
+ - Chẩn đoán: chạy `/flow doctor` từ agent.
81
+
82
+ ## Gỡ cài đặt
83
+
84
+ Xóa dir target:
85
+
86
+ ```
87
+ # Global installs
88
+ rm -rf ~/.claude/skills/flow
89
+ rm -rf ~/.codex/skills/flow
90
+ rm -rf ~/.agents/skills/flow
91
+ rm -rf ~/.gemini/antigravity-cli/skills/flow
92
+ rm -rf ~/.gemini/config/skills/flow
93
+
94
+ # Project scope (chỉ Claude)
95
+ rm -rf <project>/.claude/skills/flow
96
+ ```
97
+
98
+ ## JSONL contract
99
+
100
+ `--json` stream một JSON object mỗi dòng. Xem [README.md § JSONL contract](./README.md#jsonl-contract) cho bảng đầy đủ event/field/exit code. Tóm tắt:
101
+
102
+ - `plan` — event đầu tiên; chứa `version`, `dryRun`, `scope`, `targets`.
103
+ - `install:start` / `install:done` — một cặp mỗi target; `install:done.result` = `success` hoặc `failed`.
104
+ - `summary` — event cuối cùng; `success`, `total`, `attempted`, `installed`, `failed`, `skipped`, `aborted`.
105
+ - Exit codes: `0` OK · `1` ≥1 target fail · `2` sai flag/target · `130` Ctrl+C.
106
+
107
+ Hợp đồng additive trong `0.1.x` — field mới có thể thêm, field cũ không rename/xóa.
108
+
109
+ ## Troubleshooting
110
+
111
+ - **`EBUSY`/`EPERM` giữa install trên Windows**: một agent đang giữ handle vào file trong destination. Đóng agent + re-run. Installer đã retry 100/300/900 ms trước khi báo error.
112
+ - **Advisory lock cũ**: run trước crash. Run mới tự phát hiện PID dead → reclaim. Trường hợp hiếm (PID được recycle bởi process khác đang chạy): xóa `<parent-of-dest>/.flow-skill.installing.lock`.
113
+ - **`No matching version found` với `@0.1.x`**: cài pre-release qua stable range. Dùng `@rc` hoặc `@0.1.0-rc.N` cho tới khi stable `0.1.0` ship.
114
+ - **Node quá cũ** (`requires Node.js >=20.11.0`): update bằng `nvm install 20`, `fnm install 20`, hoặc installer chính thức của Node.
115
+
116
+ ## Yêu cầu
117
+
118
+ - Node.js **>= 22.14.0** — Node 20 hết vòng đời từ 4/2026, và publish workflow cần npm >=11.5.1 (bundle theo Node 22.14+) cho OIDC Trusted Publisher
119
+
120
+ ## Provenance
121
+
122
+ Mỗi phiên bản publish có [npm provenance](https://docs.npmjs.com/generating-provenance-statements) attestation. Verify:
123
+
124
+ ```
125
+ npm view @manhquy/flow-skill@<version> dist.attestations.provenance
126
+ ```
127
+
128
+ ## Bảo mật
129
+
130
+ Threat model + WILL/WON'T list + kênh report — xem [SECURITY.md](./SECURITY.md). Tóm tắt: pure Node, không network call, không spawn shell/PowerShell, không postinstall hook, không chạm settings/hooks/MCP config.
131
+
132
+ ## License
133
+
134
+ MIT © 2026 manhquy
package/SECURITY.md ADDED
@@ -0,0 +1,69 @@
1
+ # Security policy
2
+
3
+ ## Threat model
4
+
5
+ `@manhquy/flow-skill` is a **file-copy installer** written in pure Node.js. When you run `npx @manhquy/flow-skill`, the process:
6
+
7
+ - copies files from the tarball into one or more agent home directories, and
8
+ - exits.
9
+
10
+ There are no network calls, no shell/PowerShell invocations, no `postinstall` hooks, and no long-running daemons.
11
+
12
+ ## What the installer WILL NOT do
13
+
14
+ - Run any script from the Internet at install time.
15
+ - Touch `settings.json`, `permissions`, `allowedMcpServers`, hooks, or any marketplace config.
16
+ - Modify MCP config, shell rc, PATH, or environment variables.
17
+ - Log in to npm, mint tokens, or publish anything.
18
+ - Log, save, or commit tokens, passwords, OTPs, or private keys.
19
+ - Touch any path outside the explicit list below:
20
+ - `<home>/.claude/skills/flow`
21
+ - `<home>/.codex/skills/flow`
22
+ - `<home>/.agents/skills/flow`
23
+ - `<home>/.gemini/antigravity-cli/skills/flow`
24
+ - `<home>/.gemini/config/skills/flow`
25
+ - `<project>/.claude/skills/flow` when `--project` is used
26
+ - Spawn `bash`, `sh`, `pwsh`, `powershell.exe`, or any child process (pure Node `node:fs`).
27
+
28
+ ## What the installer WILL do
29
+
30
+ For each destination the user selects, the installer performs (parity with the upstream `install.sh:24-27` contract):
31
+
32
+ 1. Acquire a best-effort advisory lock: `<parent>/.flow-skill.installing.lock`. If the file exists and its recorded PID is alive, refuse and exit `2`.
33
+ 2. Recursively scan the bundled source `skills/flow/`. If any symbolic link is present, refuse and exit — an upstream-planted symlink is treated as hostile.
34
+ 3. `mkdir -p` the destination.
35
+ 4. `rm -rf` these six subdirectories inside the destination (if present): `runner/`, `_templates/`, `law/`, `references/`, `harness/`, `playbooks/`.
36
+ 5. Recursively copy `skills/flow/` into the destination with `dereference: false` and `errorOnBrokenSymbolicLinks: true`.
37
+ 6. Rescan the destination for symlinks (defense-in-depth). Abort if any found.
38
+ 7. `chmod 755` the destination's `runner/flow.sh` if it exists.
39
+ 8. Release the lock.
40
+
41
+ Any file **outside those six subdirectories** at the destination is preserved. You may drop personal notes, custom playbooks in a different directory, etc., alongside the installed skill — the installer will not touch them.
42
+
43
+ ## Known v0.1 limitations
44
+
45
+ These match the behavior of the upstream `install.sh`; they are documented rather than hidden.
46
+
47
+ - **Not atomic across a full run.** `SIGINT` (Ctrl+C) mid-copy or a hard crash may leave a destination in an inconsistent state. Re-running the installer fixes it. The advisory lock reduces (but does not eliminate) the risk of two concurrent runs racing.
48
+ - **Antigravity has two destinations.** If the first install succeeds and the second fails, the first is **not** rolled back — matching the upstream `install.sh:52-53` behavior. The `install:done` and `summary` JSONL events report the partial state.
49
+ - **Windows `EBUSY`.** If a running agent (Claude Code, Codex, Antigravity IDE) holds a file handle inside the destination, `rm`/`cp` retries 3× with backoff (100/300/900 ms). If it still fails, the installer reports the target and asks you to close the agent.
50
+
51
+ ## Supply chain
52
+
53
+ - **Trusted publishing.** Every version is published from a tag-triggered GitHub Actions workflow (`.github/workflows/publish-npm-wrapper.yml`, or `workflow_dispatch` for validation) behind a required-reviewer environment gate. No long-lived npm token exists in CI; auth is via OIDC.
54
+ - **Provenance.** npm attaches an SLSA Build Level 2 attestation to every version published from the workflow. Verify with:
55
+ ```
56
+ npm view @manhquy/flow-skill@<version> dist.attestations.provenance
57
+ ```
58
+ **`v0.1.0-rc.1` exception**: this bootstrap version was published manually (Trusted Publisher requires the package to already exist before it can bind) and carries no attestation. All subsequent versions publish via CI and are attested. If provenance is a hard requirement for you, wait for `v0.1.0-rc.2` or later.
59
+ - **Publisher account.** npm 2FA `auth-and-writes` is enabled as defense-in-depth for the git + npm identity behind the workflow.
60
+ - **Pin your version.** During the RC window use `@rc` (dist-tag) or an explicit `@0.1.0-rc.N`. After stable ships, pin `@0.1.x` (or a specific version). `@latest` invites blind updates on a package that writes to your agent home.
61
+ - **Completeness signal (not tamper detection).** The tarball ships `skills-manifest.json` recording the synced skill's file count + list. The publish workflow re-counts the checked-out tree against this manifest to catch an incomplete sync. It is **not** a supply-chain integrity proof — that role belongs to npm provenance above. `.integrity` SHA-256 sidecar was intentionally not adopted because it would have been generated from the same source it hashed (circular trust).
62
+ - **No `postinstall`.** `package.json` has no `postinstall` script. `prepack` (dev-only) is not in the shipped tarball.
63
+
64
+ ## Reporting a security issue
65
+
66
+ - Preferred: [GitHub Security Advisory](https://github.com/manhquydev/flow-skill/security/advisories/new)
67
+ - Email: `manhquy.mqy@gmail.com` (subject: `[flow-skill security]`)
68
+
69
+ Please do not publish exploits before a fix ships. Best-effort response SLA for v0.1.