@danielstyle/featflow 0.0.0-stage → 0.6.4
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.
- package/LICENSE +21 -0
- package/README.md +249 -2
- package/README.zh-CN.md +250 -0
- package/bin/featflow.mjs +116 -0
- package/package.json +63 -4
- package/skills/featflow/SKILL.md +127 -0
- package/skills/featflow-issues/SKILL.md +104 -0
- package/skills/featflow-regression/SKILL.md +63 -0
- package/src/agent-docs.mjs +143 -0
- package/src/changed-files.mjs +204 -0
- package/src/commands/cleanup.mjs +221 -0
- package/src/commands/codegraph.mjs +108 -0
- package/src/commands/doctor.mjs +303 -0
- package/src/commands/finish.mjs +249 -0
- package/src/commands/hook-cmd.mjs +78 -0
- package/src/commands/hooks-cmd.mjs +247 -0
- package/src/commands/init.mjs +477 -0
- package/src/commands/issue.mjs +434 -0
- package/src/commands/new.mjs +311 -0
- package/src/commands/plan-check.mjs +75 -0
- package/src/commands/policy-cmd.mjs +55 -0
- package/src/commands/pr-cleanup.mjs +194 -0
- package/src/commands/regression.mjs +206 -0
- package/src/commands/setup.mjs +343 -0
- package/src/commands/size-check.mjs +137 -0
- package/src/commands/skills.mjs +181 -0
- package/src/commands/status.mjs +100 -0
- package/src/commands/sync.mjs +421 -0
- package/src/commands/verify.mjs +206 -0
- package/src/commands/worktree.mjs +205 -0
- package/src/config.mjs +295 -0
- package/src/detect.mjs +314 -0
- package/src/git.mjs +331 -0
- package/src/hook-adapters.mjs +218 -0
- package/src/hooks-core.mjs +420 -0
- package/src/index.mjs +14 -0
- package/src/init-args.mjs +294 -0
- package/src/init-hooks.mjs +312 -0
- package/src/init-prompts.mjs +191 -0
- package/src/issues-helpers.mjs +463 -0
- package/src/issues.mjs +521 -0
- package/src/plan.mjs +202 -0
- package/src/policy.mjs +143 -0
- package/src/regression.mjs +338 -0
- package/src/size-check.mjs +203 -0
- package/src/skills-manager.mjs +348 -0
- package/src/tui-select.mjs +378 -0
- package/templates/adapters/antigravity/hooks.json +42 -0
- package/templates/adapters/claude-code/settings.json +46 -0
- package/templates/adapters/codex/config.toml +19 -0
- package/templates/adapters/cursor/hooks.json +27 -0
- package/templates/agents/codex/codebase-locator.toml +28 -0
- package/templates/agents/codex/implementation-scout.toml +28 -0
- package/templates/agents/codex/regression-guard-planner.toml +20 -0
- package/templates/features/README.md +56 -0
- package/templates/features/_program_template.md +79 -0
- package/templates/features/_template.md +120 -0
- package/templates/features/current-feature.md +18 -0
- package/templates/githooks/post-merge +10 -0
- package/templates/githooks/pre-commit +14 -0
- package/templates/githooks/pre-push +13 -0
- package/templates/regression/regression-ledger.yml +23 -0
- package/templates/snippets/AGENTS-workflow.md +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel
|
|
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
CHANGED
|
@@ -1,3 +1,250 @@
|
|
|
1
|
-
#
|
|
1
|
+
# featflow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**AI-native feature workflow: Skill + CLI + Git & Agent Hooks.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@danielstyle/featflow)
|
|
6
|
+
[](https://github.com/daniel-style/featflow/actions/workflows/ci.yml)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](https://github.com/daniel-style/featflow/blob/main/LICENSE)
|
|
9
|
+
|
|
10
|
+
[中文文档](https://github.com/daniel-style/featflow/blob/main/README.zh-CN.md)
|
|
11
|
+
|
|
12
|
+
`featflow` gives human developers and AI coding agents (Codex, Claude Code, Cursor, Antigravity, and any Agent Skills-compatible client) a disciplined, resumable engineering loop:
|
|
13
|
+
|
|
14
|
+
1. **Read-only Discovery** before touching files or branches.
|
|
15
|
+
2. **Concrete Plan & Explicit Approval** before implementation.
|
|
16
|
+
3. **Isolated Git Worktrees** per task branch so parallel sessions never collide.
|
|
17
|
+
4. **Canonical Feature & Program Records** under `features/` so long-running tasks survive context compaction, session handoffs, and multi-phase initiatives.
|
|
18
|
+
5. **Programmatic Guardrails** via Git hooks (`pre-commit` branch protection & file-size budget, `pre-push`, `post-merge`) and optional Coding Agent hooks (`UserPromptSubmit` / `PreInvocation` / `beforeSubmitPrompt`, `PreToolUse`, `PostToolUse`, `Stop`) that enforce branch protection, plan completeness, and file-size budgets.
|
|
19
|
+
|
|
20
|
+
Zero runtime dependencies. Pure Node.js ESM (`>=20`). Cross-platform (macOS, Linux, Windows).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Flexible Adoption (Global-First or Repo-Embedded)
|
|
25
|
+
|
|
26
|
+
Install `featflow` **once globally** and adapt its footprint per repository — no need to add dependencies or boilerplate to every project:
|
|
27
|
+
|
|
28
|
+
| Mode | Footprint in target repo | Best for |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| **1. Zero-Footprint Global (Recommended)** | **0 files** (global Skills via `featflow skills install`, built-in templates via `featflow new --local`, `.git/hooks/` via `featflow hooks install --local`) | Personal repos, Python/Go/Rust repos, contributing to external OSS repos without touching tracked files |
|
|
31
|
+
| **2. Project Workflow (`featflow init` / `--minimal`)** | **Project config & hooks only** (`.featflow.json` + managed `AGENTS.md` block + hooks/templates; **reuses global Skills** so updates never drift or get shadowed) | Solo & multi-repo developers wanting full guardrails (`fileSizeBudget`, Regression Guardian, Issues, 4 AI agent hooks) without duplicating `SKILL.md` into every repo |
|
|
32
|
+
| **3. Team Repo-Locked (`--with-repo-skills`)** | `package.json` + `.featflow.json` + `AGENTS.md` block + embedded `.agents/skills/` + templates/`.githooks/` + CI `featflow sync --check` | Teams requiring zero global setup for new contributors with every Skill and template locked in Git |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### Option A — Global Install (Recommended, works across all repos & languages)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# 1. Install the CLI globally once from npm
|
|
42
|
+
npm install -g @danielstyle/featflow
|
|
43
|
+
|
|
44
|
+
# 2. Sync bundled Agent Skills globally once (offline, version-matched across ~/.agents, ~/.claude, ~/.codex, ~/.cursor)
|
|
45
|
+
featflow skills install
|
|
46
|
+
|
|
47
|
+
# Alternative: install via the skills.sh CLI from GitHub
|
|
48
|
+
npx skills add https://github.com/daniel-style/featflow --skill featflow -g
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Use immediately inside **any** Git repository (zero repo files modified):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Optional: enable local branch-protection & auto-cleanup hooks in .git/hooks/ (0 tracked files)
|
|
55
|
+
featflow hooks install --local
|
|
56
|
+
|
|
57
|
+
# Create a task branch in a dedicated worktree
|
|
58
|
+
featflow worktree feat/oauth-pkce
|
|
59
|
+
|
|
60
|
+
# Draft a feature plan (stored locally in .featflow/features/ via .git/info/exclude)
|
|
61
|
+
cd ../my-repo-worktrees/feat-oauth-pkce
|
|
62
|
+
featflow new oauth-pkce --local
|
|
63
|
+
|
|
64
|
+
# After verifying & committing, merge back and clean up automatically
|
|
65
|
+
featflow finish feat/oauth-pkce
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Want one-command project onboarding (auto-detected `baseBranch`, `productPaths`, `verifyCommands`, managed `AGENTS.md` workflow block, and local `.git/hooks/`) without touching `package.json` or copying boilerplate? Run:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
featflow init --minimal
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Upgrade the global CLI & global Skills anytime in one line (or run one-off commands without installing via the scoped package name):
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install -g @danielstyle/featflow@latest && featflow skills install
|
|
78
|
+
# One-off without global/local install:
|
|
79
|
+
npx @danielstyle/featflow status
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Option B — Embed in a Team JS/TS Repository
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install -D @danielstyle/featflow
|
|
86
|
+
|
|
87
|
+
# Interactive wizard with arrow-key single-select & multi-select checkboxes (uses global Skills by default):
|
|
88
|
+
npx featflow init
|
|
89
|
+
|
|
90
|
+
# One-command full bundle (size budget + pre-commit guard + Regression Guardian + Issues + Codex subagents + all 4 AI agent hooks):
|
|
91
|
+
npx featflow init --preset full --yes
|
|
92
|
+
|
|
93
|
+
# Need repo-locked .agents/skills/ so teammates don't have to install global Skills? Opt in explicitly:
|
|
94
|
+
npx featflow init --preset full --with-repo-skills --yes
|
|
95
|
+
|
|
96
|
+
# Non-destructively upgrade an existing repo (adds universal agent hooks, regression ledger, and auto-generates legacy file-size baseline):
|
|
97
|
+
npx featflow init --merge --with-all-hooks --with-size-budget --with-regression
|
|
98
|
+
|
|
99
|
+
# Upgrade later and sync managed templates, hooks, AGENTS.md blocks (and repo skills if embedded):
|
|
100
|
+
npm install -D @danielstyle/featflow@latest && npx featflow sync
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
> Tip: AI coding-agent hooks (`.agents/hooks.json`, `.claude/settings.json`, `.codex/config.toml`, `.cursor/hooks.json`) invoke `featflow hook ...` from `PATH`. Even in team repos with `devDependencies`, installing `@danielstyle/featflow` globally once ensures hooks work seamlessly across all worktrees. `featflow init` and `featflow doctor` automatically verify both CLI and global Skill readiness.
|
|
104
|
+
|
|
105
|
+
`featflow init` automatically injects a non-destructive `<!-- FEATFLOW_START --> ... <!-- FEATFLOW_END -->` workflow block into `AGENTS.md` / `CLAUDE.md` (opt out with `--no-agent-docs`) and keeps it synced via `featflow sync`.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Supported Branch Topologies
|
|
110
|
+
|
|
111
|
+
### 1. `trunk` Mode (Default — Solo, Small Teams, OSS)
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
main (protected)
|
|
115
|
+
├── feat/oauth-pkce (dedicated worktree)
|
|
116
|
+
└── fix/retry-timeout (dedicated worktree)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- `featflow worktree feat/oauth-pkce` creates `../<repo>-worktrees/feat-oauth-pkce` from `main`.
|
|
120
|
+
- With `"finishTarget": "merge"` (default): `featflow finish feat/oauth-pkce` merges into `main`, pushes if a remote exists (skip with `--no-push`), and removes the clean worktree and local task branch.
|
|
121
|
+
- With `"finishTarget": "pr"` (or `--pr`): `featflow finish feat/oauth-pkce --pr` pushes the branch for a pull request; after GitHub merges it, run `featflow pr-cleanup <pr-number>`.
|
|
122
|
+
|
|
123
|
+
### 2. `developer-branch` Mode (Multi-Developer High-Velocity Teams)
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
main (release, protected)
|
|
127
|
+
└── dev (team integration, protected)
|
|
128
|
+
├── alice (personal developer branch)
|
|
129
|
+
│ ├── feat/alice-oauth-pkce (task worktree)
|
|
130
|
+
│ └── fix/alice-retry-timeout (task worktree)
|
|
131
|
+
└── bob (personal developer branch)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- Run once per checkout: `featflow setup alice` (auto-fetches remote branches, interactively offers to bootstrap a missing `origin/dev` — or pass `--bootstrap-integration` — creates/tracks `alice` from `origin/dev`, saves `git config featflow.developerBranch alice`, and enables hooks). `featflow init` can also trigger this step directly in `developer-branch` mode.
|
|
135
|
+
- Daily tasks branch from `alice` as `<prefix>/alice-<task>` (never `alice/...`, because Git cannot store both `alice` and `alice/...` refs simultaneously).
|
|
136
|
+
- `featflow finish feat/alice-oauth-pkce` merges into `alice`, pushes `alice`, removes the clean task worktree and local branch, and never merges directly into `dev` or `main`.
|
|
137
|
+
- Team integration (`alice -> dev`) and release promotion (`dev -> main`) happen via explicit pull requests.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## CLI Reference
|
|
142
|
+
|
|
143
|
+
| Command | Description |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `featflow new <slug> [options]` | Create a feature (or `--program`) record from the repo template or `featflow`'s built-in template, auto-filling timestamps, `owner`, and branch. Pass `--local` to store under `.featflow/features/` (excluded via `.git/info/exclude`, zero tracked files). |
|
|
146
|
+
| `featflow skills <install\|status\|uninstall>` | Install, inspect, or uninstall global Agent Skills (`featflow`, `featflow-issues`, `featflow-regression`) directly from the installed package into `~/.agents/skills/` and detected `~/.claude/skills/`, `~/.codex/skills/`, `~/.cursor/skills/` (offline, always version-matched with your CLI). |
|
|
147
|
+
| `featflow hooks <install\|uninstall\|status>` | Manage Git hooks: `--local` (default) adds/removes fenced blocks inside `.git/hooks/` without modifying repo files or overwriting custom hooks; `--repo` installs tracked `.githooks/`. |
|
|
148
|
+
| `featflow init [options]` | Auto-detect repo config, inject managed `AGENTS.md`/`CLAUDE.md` block, check global Skills & CLI readiness, and interactively pick guardrails & AI coding-agent hooks with arrow-key single/multi-select prompts. Reuses global Skills by default (pass `--with-repo-skills` to embed `.agents/skills/` in the repo, or `--install-global-skills` to auto-sync global skills). Supports `--preset <minimal\|standard\|full>`, `--minimal`, `--merge`, `--with-codex-agents`, `--agent-hooks <antigravity,claude-code,codex,cursor\|all\|none>`, and `--yes`. |
|
|
149
|
+
| `featflow sync [options]` | Sync repo-managed templates, `.githooks/`, `AGENTS.md`/`CLAUDE.md` blocks, and repo-embedded Skills (when present or opted in via `--with-repo-skills`) without modifying `.featflow.json`, feature records, or custom doc content. Pass `--check` in CI to fail on drift, or `--only skill,issues-skill,regression-skill,templates,githooks,agent-docs`. |
|
|
150
|
+
| `featflow setup [dev-branch]` | Configure personal developer branch (in `developer-branch` mode), auto-fetch remote branches, optionally bootstrap a missing integration branch (`--bootstrap-integration`), and safely enable Git hooks without clobbering Husky/Lefthook. |
|
|
151
|
+
| `featflow status` | Inspect workflow mode, branch/remote status, all worktrees, active/paused feature records, and next recommended step. |
|
|
152
|
+
| `featflow worktree <branch> [path] [base]` | Create a typed task branch in a dedicated sibling worktree and run configured `postWorktreeCreate` commands. |
|
|
153
|
+
| `featflow finish <branch>` | Merge/push a verified task branch, safely exit the task worktree, delete the clean worktree & local branch, and prune other merged task branches. Supports `--no-push`, `--pr`, `--dry-run`, `--keep-worktree`, `--keep-branch`. |
|
|
154
|
+
| `featflow issue <subcommand>` | Optional GitHub Issues closed-loop CLI (`create`, `list`, `view`, `claim`, `review`, `release`, `labels:sync`) powered by `gh`. Atomically preflights worktree creation before claiming, supports optional screenshot uploads via `issues.assetsRepo`, and syncs optional `featflow-issues` Skill via `featflow init --with-issues` / `featflow sync`. |
|
|
155
|
+
| `featflow size-check [options]` | Optional multi-language file line-count budget checker with legacy baseline ratchet (`--changed`, `--update-baseline`, `--json`), configured via `fileSizeBudget` in `.featflow.json`. |
|
|
156
|
+
| `featflow regression <impact\|check\|validate>` | Optional Regression Guardian CLI for YAML/JSON regression ledgers (`regression.ledgerFile`): find impacted bug invariants for changed files, run guard commands, or validate ledger integrity. |
|
|
157
|
+
| `featflow verify [options]` | Run configured `verifyCommands` matching changed files (`--all`, `--with-size`, `--with-regression`, `--dry-run`, `--json`). |
|
|
158
|
+
| `featflow codegraph [bootstrap\|status]` | Initialize or sync local `.codegraph/codegraph.db` index (skips cleanly in CI or when `codegraph` CLI is absent). |
|
|
159
|
+
| `featflow cleanup` | Clean local task branches and clean worktrees already merged into the base/developer branch. Also runs on `post-merge` via `--post-merge`. |
|
|
160
|
+
| `featflow pr-cleanup <pr>` | After a GitHub PR merges (via `gh`), sync the local base branch, remove the clean PR worktree, delete local/remote branch, and prune refs. |
|
|
161
|
+
| `featflow plan-check [path]` | Validate required `Plan Details` headings, placeholder resolution (ignoring code spans/fences), and recorded pre-implementation approval. |
|
|
162
|
+
| `featflow policy <pre-commit\|pre-push>` | Git hook guard blocking direct commits/pushes to protected branches and staged files exceeding `fileSizeBudget` when `enforceInPreCommit: true` (bypass once with `FEATFLOW_BOOTSTRAP=1` / `FEATFLOW_SKIP_SIZE_CHECK=1`). |
|
|
163
|
+
| `featflow hook <antigravity\|claude-code\|codex\|cursor> <event>` | Universal AI coding-agent hook adapter supporting Antigravity (`.agents/hooks.json`), Claude Code (`.claude/settings.json`), OpenAI Codex (`.codex/config.toml`), and Cursor (`.cursor/hooks.json`). |
|
|
164
|
+
| `featflow doctor` | Run repository health checks across Git, config, templates, Skill, managed docs, agent/Git hooks, CodeGraph, and active feature plan. |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Configuration (`.featflow.json`)
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"mode": "trunk",
|
|
173
|
+
"remote": "origin",
|
|
174
|
+
"requireRemote": false,
|
|
175
|
+
"baseBranch": "main",
|
|
176
|
+
"integrationBranch": "main",
|
|
177
|
+
"releaseBranch": "main",
|
|
178
|
+
"protectedBranches": ["main"],
|
|
179
|
+
"finishTarget": "merge",
|
|
180
|
+
"developerBranchConfigKey": "featflow.developerBranch",
|
|
181
|
+
"worktreeParent": null,
|
|
182
|
+
"featuresDir": "features",
|
|
183
|
+
"trackFeaturesInGit": true,
|
|
184
|
+
"trackCurrentFeaturePointer": false,
|
|
185
|
+
"prefixes": ["feat", "fix", "chore", "docs", "test", "refactor", "perf", "security"],
|
|
186
|
+
"productPaths": ["src/", "apps/", "services/", "packages/", "lib/"],
|
|
187
|
+
"postWorktreeCreate": [],
|
|
188
|
+
"verifyCommands": {
|
|
189
|
+
"src/": "npm test"
|
|
190
|
+
},
|
|
191
|
+
"dangerousCommands": {
|
|
192
|
+
"blockDestructiveGit": true,
|
|
193
|
+
"blockForcePush": true,
|
|
194
|
+
"blockEnvWrite": true,
|
|
195
|
+
"blockedPackageManagers": []
|
|
196
|
+
},
|
|
197
|
+
"fileSizeBudget": {
|
|
198
|
+
"production": 600,
|
|
199
|
+
"style": 700,
|
|
200
|
+
"test": 900,
|
|
201
|
+
"extensions": [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".css"],
|
|
202
|
+
"ignore": [],
|
|
203
|
+
"baselineFile": ".featflow-size-baseline.json",
|
|
204
|
+
"enforceInPostToolUse": true,
|
|
205
|
+
"enforceInStopGate": true,
|
|
206
|
+
"enforceInPreCommit": true
|
|
207
|
+
},
|
|
208
|
+
"regression": {
|
|
209
|
+
"ledgerFile": "context/regression-ledger.yml",
|
|
210
|
+
"enforceInStopGate": false
|
|
211
|
+
},
|
|
212
|
+
"issues": {
|
|
213
|
+
"provider": "github",
|
|
214
|
+
"repo": null,
|
|
215
|
+
"assetsRepo": "owner/issue-assets",
|
|
216
|
+
"assetsBranch": "main",
|
|
217
|
+
"assetsPrefix": "assets",
|
|
218
|
+
"autoWorktree": true
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
> Notes:
|
|
224
|
+
> - In `developer-branch` mode, `baseBranch` and `integrationBranch` default to `"dev"`, `protectedBranches` defaults to `["main", "dev"]`, `requireRemote` defaults to `true`, and `finishTarget` is `"developer-branch"`.
|
|
225
|
+
> - `"fileSizeBudget"`, `"regression"`, and `"issues"` are all **optional** (omitted by default). Enable them selectively with `featflow init --with-size-budget` / `--with-regression` / `--with-issues` or all at once via `--preset full`. `issues.assetsRepo` is only needed when uploading/downloading local screenshots via `--attach` / `--download-images`.
|
|
226
|
+
|
|
227
|
+
### Notable Design Choices
|
|
228
|
+
|
|
229
|
+
- **No Husky / Lefthook clobbering**: If `git config core.hooksPath` is already set to another manager (e.g., `.husky`), `featflow init --with-githooks` and `featflow setup` refuse to overwrite it and print the exact one-liners to append to your existing hook files.
|
|
230
|
+
- **No `current-feature.md` merge conflicts**: By default, `trackCurrentFeaturePointer` is `false` (added to `.gitignore`), while `features/active/` serves as the canonical multi-worktree active list.
|
|
231
|
+
- **Tracked vs. Local-only `features/`**: Prefer keeping AI planning records out of Git history? Pass `featflow init --local-features` to ignore `features/` while keeping the full Skill, CLI, and plan-gate workflow locally.
|
|
232
|
+
- **Smart `PreToolUse` plan gating**: Unlike naive keyword regexes, `featflow hook` distinguishes read-only shell commands (`rg`, `cat`, `git diff`) from mutating writes, strips Markdown code spans/fences before checking template placeholders, and checks that `Pre-Implementation Approval` is no longer `pending`.
|
|
233
|
+
- **Optional post-worktree hooks**: Need automatic dependency install (`pnpm install --frozen-lockfile --offline`) or local index bootstrap (`codegraph init`) when creating a worktree? Add them to `postWorktreeCreate` in `.featflow.json`.
|
|
234
|
+
- **Multi-repository sync without drift**: Upgrade `@danielstyle/featflow` in any project and run `featflow sync` to refresh the managed Skills, templates, `.githooks/`, and `AGENTS.md`/`CLAUDE.md` blocks while keeping `.featflow.json`, active/done records, and custom doc content untouched. Add `featflow sync --check` to CI so repositories stay aligned with their pinned `featflow` version.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Development & Testing
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npm run smoke
|
|
242
|
+
npm run lint:size
|
|
243
|
+
npm test
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
All tests run with Node's built-in test runner (`node:test`) against isolated temporary Git repositories.
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
[MIT](https://github.com/daniel-style/featflow/blob/main/LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# featflow
|
|
2
|
+
|
|
3
|
+
**面向 AI 编程的工程化特性工作流:Skill + CLI + Git / Agent Hooks。**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@danielstyle/featflow)
|
|
6
|
+
[](https://github.com/daniel-style/featflow/actions/workflows/ci.yml)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](https://github.com/daniel-style/featflow/blob/main/LICENSE)
|
|
9
|
+
|
|
10
|
+
[English README](https://github.com/daniel-style/featflow/blob/main/README.md)
|
|
11
|
+
|
|
12
|
+
`featflow` 为人类开发者和 AI Coding Agents(Codex、Claude Code、Cursor、Antigravity 等支持 Agent Skills 的工具)提供一套经过高频实战打磨的闭环工作流:
|
|
13
|
+
|
|
14
|
+
1. **先只读探索(Discovery)**:改代码和建分支前,先读清真实代码、契约与测试。
|
|
15
|
+
2. **先出方案并等待审批(Pre-Implementation Gate)**:任何写操作之前输出具体方案,获批后再动手。
|
|
16
|
+
3. **任务级 Git Worktree 隔离**:每个需求/修复独立分支与独立目录,多任务并行互不干扰。
|
|
17
|
+
4. **结构化 Feature & Program 记录**:在 `features/` 下沉淀需求 brief、详细实现计划、决策与验证结果,跨会话/长周期项目随时可恢复。
|
|
18
|
+
5. **程序化硬护栏**:通过 Git Hooks(`pre-commit` 保护分支与代码行数拦截、`pre-push`、`post-merge`)与可选的 Agent Hooks(`UserPromptSubmit` / `PreInvocation` / `beforeSubmitPrompt`、`PreToolUse`、`PostToolUse`、`Stop`),真正拦截保护分支误写、“计划没填完就改产品代码”以及文件行数超限。
|
|
19
|
+
|
|
20
|
+
零第三方运行时依赖,纯 Node.js ESM(`>=20`),支持 macOS / Linux / Windows。
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 灵活接入(推荐全局安装,按项目按需选档)
|
|
25
|
+
|
|
26
|
+
**不需要每个项目都内置依赖或拷模板!** 本机全局安装一次后,每个仓库可以按实际情况选择侵入程度:
|
|
27
|
+
|
|
28
|
+
| 模式 | 目标仓库改动 | 适用场景 |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| **1. 纯全局零入侵(推荐)** | **0 个文件**(`featflow skills install` 同步全局 Skill;`featflow new --local` 写到 `.featflow/features/` 并写入 `.git/info/exclude`;`featflow hooks install --local` 装在 `.git/hooks/`) | 个人项目、Python/Go/Rust 等非 JS 项目、给外部开源项目提 PR |
|
|
31
|
+
| **2. 项目接入(`featflow init` / `--minimal`)** | **只放项目专属配置与钩子**(`.featflow.json` + `AGENTS.md` 托管块 + 钩子/模板;**默认直接复用全局 Skill**,避免项目副本覆盖全局新版) | 个人与多仓库团队,需要完整护栏(代码行数限制、回归守卫、Issues、四大 Agent Hooks)且不想往每个仓库拷重复 `SKILL.md` |
|
|
32
|
+
| **3. 团队强锁入库(`--with-repo-skills`)** | `package.json` + `.featflow.json` + `AGENTS.md` 托管块 + 入库 `.agents/skills/` + 模板/`.githooks/` + CI `featflow sync --check` | 多人协作仓库,希望新人克隆即可用、无需全局装 Skill 且 CI 强锁版本 |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 快速开始
|
|
37
|
+
|
|
38
|
+
### 方式 A:全局安装(推荐,跨所有项目与语言通用)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# 1. 从 npm 本机全局安装一次 CLI
|
|
42
|
+
npm install -g @danielstyle/featflow
|
|
43
|
+
|
|
44
|
+
# 2. 一键同步内置 Agent Skills 到全局(离线、与 CLI 版本严格一致,自动覆盖 ~/.agents、~/.claude、~/.codex、~/.cursor)
|
|
45
|
+
featflow skills install
|
|
46
|
+
|
|
47
|
+
# 备选:也可通过 skills.sh CLI 从 GitHub 安装
|
|
48
|
+
npx skills add https://github.com/daniel-style/featflow --skill featflow -g
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
在**任意** Git 仓库里立即可用(0 文件入侵):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 可选:在 .git/hooks/ 启用本地保护分支与自动清理钩子(不改仓库任何 tracked 文件)
|
|
55
|
+
featflow hooks install --local
|
|
56
|
+
|
|
57
|
+
# 创建隔离任务 worktree
|
|
58
|
+
featflow worktree feat/oauth-pkce
|
|
59
|
+
|
|
60
|
+
# 用内置模板生成 feature 计划记录(--local 存本地并自动写入 .git/info/exclude)
|
|
61
|
+
cd ../my-repo-worktrees/feat-oauth-pkce
|
|
62
|
+
featflow new oauth-pkce --local
|
|
63
|
+
|
|
64
|
+
# 验证并 commit 后,一键合并收尾并清理 worktree
|
|
65
|
+
featflow finish feat/oauth-pkce
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
想在一个新项目或已有项目里一条命令完成自动探测(主干/保护分支、源码目录、测试命令)、注入 `AGENTS.md` 托管块并启用本地钩子,同时不拷冗余模板、不动 `package.json`?直接运行:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
featflow init --minimal
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
随时一条命令同步升级全局 CLI 与全局 Skills,或在未安装时通过带 scope 的包名临时执行:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install -g @danielstyle/featflow@latest && featflow skills install
|
|
78
|
+
# 未安装时临时运行(需带 @danielstyle/ scope):
|
|
79
|
+
npx @danielstyle/featflow status
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 方式 B:多人 JS/TS 项目内置锁定版本
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install -D @danielstyle/featflow
|
|
86
|
+
|
|
87
|
+
# 交互式初始化向导:TTY 下带方向键单选与多选勾选框(默认复用全局 Skills,缺失时交互引导一键同步)
|
|
88
|
+
npx featflow init
|
|
89
|
+
|
|
90
|
+
# 一条命令开启全家桶(600 行代码限制 + pre-commit 兜底 + 回归守卫 + Issues 闭环 + Codex 只读子代理 + 四大 Agent Hooks):
|
|
91
|
+
npx featflow init --preset full --yes
|
|
92
|
+
|
|
93
|
+
# 如团队希望把 .agents/skills/ 一并提交入库(新人无需全局安装 Skill),显式加上 --with-repo-skills:
|
|
94
|
+
npx featflow init --preset full --with-repo-skills --yes
|
|
95
|
+
|
|
96
|
+
# 已有项目无损升级(保留原配置,增量合并新 hooks / 回归账本 / 行数预算并自动生成历史行数基线):
|
|
97
|
+
npx featflow init --merge --with-all-hooks --with-size-budget --with-regression
|
|
98
|
+
|
|
99
|
+
# 后续升级并一键同步项目内模板、钩子与 AGENTS.md 块(若项目内置了 Skill 也会同步):
|
|
100
|
+
npm install -D @danielstyle/featflow@latest && npx featflow sync
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
> 提示:四大 AI Coding Agent Hooks(`.agents/hooks.json`、`.claude/settings.json`、`.codex/config.toml`、`.cursor/hooks.json`)会直接调用 `PATH` 上的 `featflow hook ...`,因此即便项目内已装 `devDependency`,也建议本机全局安装一次 `npm install -g @danielstyle/featflow`,确保所有 worktree 下无缝触发。`featflow init` 与 `featflow doctor` 会自动体检 CLI 与全局 Skill 的就绪状态。
|
|
104
|
+
|
|
105
|
+
`featflow init` 默认会用 `<!-- FEATFLOW_START --> ... <!-- FEATFLOW_END -->` 托管块无损写入项目的 `AGENTS.md` / `CLAUDE.md`(可用 `--no-agent-docs` 跳过),后续升级可通过 `featflow sync` 一键同步。
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 支持的两种分支模式
|
|
110
|
+
|
|
111
|
+
### 1. `trunk` 模式(默认:个人 / 小团队 / 开源项目)
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
main (保护分支)
|
|
115
|
+
├── feat/oauth-pkce (独立 worktree)
|
|
116
|
+
└── fix/retry-timeout (独立 worktree)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- `featflow worktree feat/oauth-pkce` 从 `main` 拉出分支并建好 `../<repo>-worktrees/feat-oauth-pkce`。
|
|
120
|
+
- `"finishTarget": "merge"`(默认):`featflow finish feat/oauth-pkce` 合并回 `main`、有远端则推送(可用 `--no-push` 仅本地),并自动删掉干净的 worktree 和任务分支。
|
|
121
|
+
- `"finishTarget": "pr"`(或命令加 `--pr`):`featflow finish feat/oauth-pkce --pr` 推送任务分支供提 PR;合并后执行 `featflow pr-cleanup <pr-number>` 同步 `main` 并清理本地环境。
|
|
122
|
+
|
|
123
|
+
### 2. `developer-branch` 模式(多人高频协作团队)
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
main (发布分支,受保护)
|
|
127
|
+
└── dev (团队集成分支,受保护)
|
|
128
|
+
├── alice (个人长期开发分支)
|
|
129
|
+
│ ├── feat/alice-oauth-pkce (任务 worktree)
|
|
130
|
+
│ └── fix/alice-retry-timeout (任务 worktree)
|
|
131
|
+
└── bob (个人长期开发分支)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- 每个本地克隆首次执行一次:`featflow setup alice`(自动 fetch 远端分支,若远端缺少 `origin/dev` 会交互引导创建并推送——或传 `--bootstrap-integration`——随后基于 `origin/dev` 创建/跟踪 `alice`,写入 `git config featflow.developerBranch alice`,并安全启用 hooks)。在 `developer-branch` 模式下运行 `featflow init` 也可直接联动完成此步骤。
|
|
135
|
+
- 日常任务从 `alice` 分叉,命名为 `<prefix>/alice-<task>`(不要用 `alice/...`,因为 Git 不允许同名分支与命名空间前缀并存)。
|
|
136
|
+
- `featflow finish feat/alice-oauth-pkce` 合回并推送 `alice`,清理干净的任务 worktree 与本地分支,**绝不直接改动 `dev` 或 `main`**。
|
|
137
|
+
- 需要团队集成(`alice -> dev`)或发布(`dev -> main`)时再显式提 PR。
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 常用 CLI 命令
|
|
142
|
+
|
|
143
|
+
| 命令 | 说明 |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `featflow new <slug>` | 使用项目模板或 `featflow` 内置模板新建 feature(或 `--program`)记录,自动填入时间戳、`owner` 与分支;加 `--local` 存到 `.featflow/features/` 并写入 `.git/info/exclude` 实现零入侵。 |
|
|
146
|
+
| `featflow skills <install\|status\|uninstall>` | 直接从已安装的 `@danielstyle/featflow` 包离线安装/更新/体检全局 Agent Skills(`featflow`、`featflow-issues`、`featflow-regression`),自动同步到 `~/.agents/skills/` 及已检测的 `~/.claude/skills/`、`~/.codex/skills/`、`~/.cursor/skills/`。 |
|
|
147
|
+
| `featflow hooks <install\|uninstall\|status>` | 管理 Git hooks:`--local`(默认)在 `.git/hooks/` 中无损增删托管块,保留已有自定义 hook 且不改仓库文件;`--repo` 生成入库的 `.githooks/`。 |
|
|
148
|
+
| `featflow init` | 自动探测项目配置、无损注入 `AGENTS.md`/`CLAUDE.md` 托管块、体检全局 Skill 与 CLI 就绪状态,并在 TTY 下提供方向键单选与多选勾选框。默认直接复用全局 Skills(需入库可显式加 `--with-repo-skills`,非交互自动同步全局可加 `--install-global-skills`)。支持 `--preset <minimal\|standard\|full>`、`--minimal`、`--merge`、`--with-codex-agents`、`--agent-hooks <antigravity,claude-code,codex,cursor\|all\|none>` 与 `--yes`。 |
|
|
149
|
+
| `featflow sync` | 从当前安装的 `featflow` 同步更新项目内模板、`.githooks/`、`AGENTS.md`/`CLAUDE.md` 托管块,以及已入库(或显式 `--with-repo-skills`)的项目级 Skill,不改动 `.featflow.json`、已有记录及托管块外自定义文档。支持 `--check` 放进 CI 防漂移、`--only skill,issues-skill,regression-skill,templates,githooks,agent-docs` 按需同步。 |
|
|
150
|
+
| `featflow setup [branch]` | 初始化个人开发分支(`developer-branch` 模式)、自动 fetch 远端分支、按需引导创建缺失的集成分支(`--bootstrap-integration`)并安全配置 Git hooks。 |
|
|
151
|
+
| `featflow status` | 查看当前模式、分支状态、所有 worktree、进行中/暂停中的 feature 记录和下一步建议。 |
|
|
152
|
+
| `featflow worktree <branch>` | 为任务分支创建独立 worktree,并自动执行 `.featflow.json` 中配置的 `postWorktreeCreate` 命令。 |
|
|
153
|
+
| `featflow finish <branch>` | 完成并收尾任务分支(合并/推送、自动切出待删 worktree、移除干净 worktree 与本地分支)。支持 `--no-push`、`--pr`、`--dry-run`、`--keep-worktree`、`--keep-branch`。 |
|
|
154
|
+
| `featflow issue <subcommand>` | 可选的 GitHub Issues 闭环 CLI(`create` / `list` / `view` / `claim` / `review` / `release` / `labels:sync`,仅在调用时依赖 `gh`)。认领前先预检本地 worktree 再改远端状态,支持通过 `.featflow.json` 的 `issues.assetsRepo` 托管截图,并可通过 `featflow init --with-issues` / `featflow sync` 同步可选 `featflow-issues` Skill。 |
|
|
155
|
+
| `featflow size-check [options]` | 可选的多语言文件行数预算守卫(支持历史基线只减不增棘轮、`--changed`、`--update-baseline`、`--json` 及 `post-tool-use` / `pre-commit` 即时拦截),通过 `.featflow.json` 的 `fileSizeBudget` 按需启用。 |
|
|
156
|
+
| `featflow regression <impact\|check\|validate>` | 可选的回归守卫账本 CLI(支持 YAML/JSON 账本):按改动文件检索命中的历史 Bug 不变量、运行守卫命令或校验账本完整性,配套可选 `featflow-regression` Skill。 |
|
|
157
|
+
| `featflow verify [options]` | 按改动文件匹配执行 `.featflow.json` 中的 `verifyCommands`(支持 `--all`、`--with-size`、`--with-regression`、`--dry-run`、`--json`)。 |
|
|
158
|
+
| `featflow codegraph [bootstrap\|status]` | 一键初始化或同步本地 `.codegraph/codegraph.db` 索引(CI 环境或未装 CLI 时静默跳过)。 |
|
|
159
|
+
| `featflow cleanup` | 清理已合入目标分支且工作区干净的本地任务分支与 worktree(也挂在 `post-merge` 钩子自动执行)。 |
|
|
160
|
+
| `featflow pr-cleanup <pr>` | GitHub PR 合并后(依赖 `gh` CLI)同步目标基线分支、删除干净 worktree 与本地/远端分支并 prune。 |
|
|
161
|
+
| `featflow plan-check [path]` | 校验当前 active feature 记录的 `Plan Details` 章节完整度、占位符清理与审批状态。 |
|
|
162
|
+
| `featflow policy <pre-commit\|pre-push>` | Git hooks 护栏:拦截保护分支直提交/直推送,以及 `enforceInPreCommit: true` 时拦截超出 `fileSizeBudget` 的暂存文件(一次性放行可用 `FEATFLOW_BOOTSTRAP=1` / `FEATFLOW_SKIP_SIZE_CHECK=1`)。 |
|
|
163
|
+
| `featflow hook <antigravity\|claude-code\|codex\|cursor> <event>` | 通用 AI Coding Agent Hook 适配器,原生支持 Antigravity(`.agents/hooks.json`)、Claude Code(`.claude/settings.json`)、OpenAI Codex(`.codex/config.toml`)与 Cursor(`.cursor/hooks.json`)。 |
|
|
164
|
+
| `featflow doctor` | 体检 Git、配置、模板、Skill、托管文档、Agent/Git Hooks、CodeGraph 与当前 feature 计划状态。 |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 配置参考(`.featflow.json`)
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"mode": "trunk",
|
|
173
|
+
"remote": "origin",
|
|
174
|
+
"requireRemote": false,
|
|
175
|
+
"baseBranch": "main",
|
|
176
|
+
"integrationBranch": "main",
|
|
177
|
+
"releaseBranch": "main",
|
|
178
|
+
"protectedBranches": ["main"],
|
|
179
|
+
"finishTarget": "merge",
|
|
180
|
+
"developerBranchConfigKey": "featflow.developerBranch",
|
|
181
|
+
"worktreeParent": null,
|
|
182
|
+
"featuresDir": "features",
|
|
183
|
+
"trackFeaturesInGit": true,
|
|
184
|
+
"trackCurrentFeaturePointer": false,
|
|
185
|
+
"prefixes": ["feat", "fix", "chore", "docs", "test", "refactor", "perf", "security"],
|
|
186
|
+
"productPaths": ["src/", "apps/", "services/", "packages/", "lib/"],
|
|
187
|
+
"postWorktreeCreate": [],
|
|
188
|
+
"verifyCommands": {
|
|
189
|
+
"src/": "npm test"
|
|
190
|
+
},
|
|
191
|
+
"dangerousCommands": {
|
|
192
|
+
"blockDestructiveGit": true,
|
|
193
|
+
"blockForcePush": true,
|
|
194
|
+
"blockEnvWrite": true,
|
|
195
|
+
"blockedPackageManagers": []
|
|
196
|
+
},
|
|
197
|
+
"fileSizeBudget": {
|
|
198
|
+
"production": 600,
|
|
199
|
+
"style": 700,
|
|
200
|
+
"test": 900,
|
|
201
|
+
"extensions": [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".css"],
|
|
202
|
+
"ignore": [],
|
|
203
|
+
"baselineFile": ".featflow-size-baseline.json",
|
|
204
|
+
"enforceInPostToolUse": true,
|
|
205
|
+
"enforceInStopGate": true,
|
|
206
|
+
"enforceInPreCommit": true
|
|
207
|
+
},
|
|
208
|
+
"regression": {
|
|
209
|
+
"ledgerFile": "context/regression-ledger.yml",
|
|
210
|
+
"enforceInStopGate": false
|
|
211
|
+
},
|
|
212
|
+
"issues": {
|
|
213
|
+
"provider": "github",
|
|
214
|
+
"repo": null,
|
|
215
|
+
"assetsRepo": "owner/issue-assets",
|
|
216
|
+
"assetsBranch": "main",
|
|
217
|
+
"assetsPrefix": "assets",
|
|
218
|
+
"autoWorktree": true
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
> 说明:
|
|
224
|
+
> - 在 `developer-branch` 模式下,`baseBranch` 与 `integrationBranch` 默认为 `"dev"`,`protectedBranches` 默认为 `["main", "dev"]`,`requireRemote` 默认为 `true`,`finishTarget` 为 `"developer-branch"`。
|
|
225
|
+
> - `"fileSizeBudget"`、`"regression"` 和 `"issues"` 均为**可选配置块**(默认省略),可通过 `featflow init --with-size-budget` / `--with-regression` / `--with-issues` 按需开启,或通过 `--preset full` 一键启用;其中 `issues.assetsRepo` 仅在使用 `--attach` / `--download-images` 上传或下载截图时需要配置。
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 关键工程细节
|
|
230
|
+
|
|
231
|
+
- **绝不覆盖已有 Husky / Lefthook**:检测到 `core.hooksPath` 已被其他工具占用时不会粗暴覆盖,而是提示如何把单行 `featflow policy ...` 接入现有钩子。
|
|
232
|
+
- **消除 `current-feature.md` 合并冲突**:默认忽略 `features/current-feature.md`,用 `features/active/` 作为多 worktree 唯一真源;需要共享指针时可加 `--track-pointer`。
|
|
233
|
+
- **支持记录不入库(本地模式)**:不希望把 AI 规划文档提交进 Git 历史?运行 `featflow init --local-features` 即可将 `features/` 写入 `.gitignore`,同时保留完整的规划校验与 worktree 自动化。
|
|
234
|
+
- **更精准的 `PreToolUse` 校验**:区分只读命令(`rg`、`cat`、`git diff`)与真实写操作,检测占位符前自动剥离 Markdown 代码块与行内代码避免误拦,且校验 `Pre-Implementation Approval` 非 `pending`。
|
|
235
|
+
- **可扩展的 `postWorktreeCreate` 钩子**:需要在建完 worktree 后自动装依赖(如 `pnpm install --frozen-lockfile --offline`)或构建索引(如 `codegraph init`),直接配置到 `.featflow.json` 的 `postWorktreeCreate` 数组即可。
|
|
236
|
+
- **多仓库一键同步防漂移**:在业务仓库升级 `@danielstyle/featflow` 后运行 `featflow sync` 即可同步最新 Skill(含可选 `featflow-issues` / `featflow-regression`)、模板、`.githooks/` 与 `AGENTS.md`/`CLAUDE.md` 托管块,不会覆盖项目自身的 `.featflow.json` 或托管块外自定义文档;把 `featflow sync --check` 放进 CI 可自动防止文档/模板与 CLI 版本脱节。
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 本地测试
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npm run smoke
|
|
244
|
+
npm run lint:size
|
|
245
|
+
npm test
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 开源协议
|
|
249
|
+
|
|
250
|
+
[MIT](https://github.com/daniel-style/featflow/blob/main/LICENSE)
|
package/bin/featflow.mjs
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
import { packageRoot } from "../src/config.mjs";
|
|
7
|
+
import { runCleanup } from "../src/commands/cleanup.mjs";
|
|
8
|
+
import { runCodegraph } from "../src/commands/codegraph.mjs";
|
|
9
|
+
import { runDoctor } from "../src/commands/doctor.mjs";
|
|
10
|
+
import { runFinish } from "../src/commands/finish.mjs";
|
|
11
|
+
import { runHook } from "../src/commands/hook-cmd.mjs";
|
|
12
|
+
import { runHooks } from "../src/commands/hooks-cmd.mjs";
|
|
13
|
+
import { runInit } from "../src/commands/init.mjs";
|
|
14
|
+
import { runIssue } from "../src/commands/issue.mjs";
|
|
15
|
+
import { runNew } from "../src/commands/new.mjs";
|
|
16
|
+
import { runPlanCheck } from "../src/commands/plan-check.mjs";
|
|
17
|
+
import { runPolicy } from "../src/commands/policy-cmd.mjs";
|
|
18
|
+
import { runPrCleanup } from "../src/commands/pr-cleanup.mjs";
|
|
19
|
+
import { runRegression } from "../src/commands/regression.mjs";
|
|
20
|
+
import { runSetup } from "../src/commands/setup.mjs";
|
|
21
|
+
import { runSizeCheck } from "../src/commands/size-check.mjs";
|
|
22
|
+
import { runSkills } from "../src/commands/skills.mjs";
|
|
23
|
+
import { runStatus } from "../src/commands/status.mjs";
|
|
24
|
+
import { runSync } from "../src/commands/sync.mjs";
|
|
25
|
+
import { runVerify } from "../src/commands/verify.mjs";
|
|
26
|
+
import { runWorktree } from "../src/commands/worktree.mjs";
|
|
27
|
+
|
|
28
|
+
const pkg = JSON.parse(readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
29
|
+
|
|
30
|
+
const usage = `
|
|
31
|
+
featflow v${pkg.version} — AI-native feature workflow (Skill + CLI + Hooks)
|
|
32
|
+
|
|
33
|
+
Usage:
|
|
34
|
+
featflow <command> [options]
|
|
35
|
+
|
|
36
|
+
Commands:
|
|
37
|
+
new Create a feature or program record from repo or built-in template (--local for zero-footprint)
|
|
38
|
+
skills Install/sync/inspect global Agent Skills across Antigravity, Claude Code, Codex, and Cursor
|
|
39
|
+
hooks Install/uninstall/inspect Git hooks (--local into .git/hooks/ or --repo into .githooks/)
|
|
40
|
+
init Auto-detect repo config, inject AGENTS.md block, and scaffold featflow (--minimal for lightweight)
|
|
41
|
+
sync Sync managed Skill, templates, .githooks, and AGENTS.md blocks (--check for CI)
|
|
42
|
+
setup Configure developer branch (if applicable) and safely enable Git hooks
|
|
43
|
+
status Show workflow mode, branch/worktree state, active features, and next step
|
|
44
|
+
worktree Create a typed task branch in a dedicated Git worktree
|
|
45
|
+
finish Merge/push a verified task branch and clean up its worktree
|
|
46
|
+
issue GitHub Issues closed-loop CLI (create | list | view | claim | review | release | labels:sync)
|
|
47
|
+
size-check Check files against configured fileSizeBudget (with legacy baseline ratchet)
|
|
48
|
+
regression Inspect or validate the regression memory ledger (impact | check | validate)
|
|
49
|
+
verify Run verifyCommands matching changed files (--all for full)
|
|
50
|
+
codegraph Bootstrap or inspect local CodeGraph index (.codegraph/codegraph.db)
|
|
51
|
+
cleanup Remove clean worktrees and local task branches already merged into base
|
|
52
|
+
pr-cleanup Sync base branch and clean up local worktree/branch after a GitHub PR merge
|
|
53
|
+
plan-check Validate that the active feature record has complete, approved Plan Details
|
|
54
|
+
policy Run Git hook guards (pre-commit | pre-push)
|
|
55
|
+
hook Run AI coding-agent hook adapters (antigravity | claude-code | codex | cursor)
|
|
56
|
+
doctor Check repository configuration, hooks, templates, and active feature health
|
|
57
|
+
|
|
58
|
+
Global Options:
|
|
59
|
+
-h, --help Show help
|
|
60
|
+
-v, --version Show version
|
|
61
|
+
|
|
62
|
+
Run "featflow <command> --help" for command-specific options.
|
|
63
|
+
`.trim();
|
|
64
|
+
|
|
65
|
+
const commands = {
|
|
66
|
+
new: runNew,
|
|
67
|
+
skills: runSkills,
|
|
68
|
+
hooks: runHooks,
|
|
69
|
+
init: runInit,
|
|
70
|
+
sync: runSync,
|
|
71
|
+
setup: runSetup,
|
|
72
|
+
status: runStatus,
|
|
73
|
+
worktree: runWorktree,
|
|
74
|
+
finish: runFinish,
|
|
75
|
+
issue: runIssue,
|
|
76
|
+
issues: runIssue,
|
|
77
|
+
"size-check": runSizeCheck,
|
|
78
|
+
regression: runRegression,
|
|
79
|
+
"regression-impact": (rest) => runRegression(rest, "impact"),
|
|
80
|
+
verify: runVerify,
|
|
81
|
+
codegraph: runCodegraph,
|
|
82
|
+
cleanup: runCleanup,
|
|
83
|
+
"pr-cleanup": runPrCleanup,
|
|
84
|
+
"plan-check": runPlanCheck,
|
|
85
|
+
policy: runPolicy,
|
|
86
|
+
hook: runHook,
|
|
87
|
+
doctor: runDoctor,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
async function main() {
|
|
91
|
+
const [command, ...rest] = process.argv.slice(2);
|
|
92
|
+
|
|
93
|
+
if (!command || command === "-h" || command === "--help") {
|
|
94
|
+
console.log(usage);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (command === "-v" || command === "--version") {
|
|
99
|
+
console.log(pkg.version);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const handler = commands[command];
|
|
104
|
+
if (!handler) {
|
|
105
|
+
console.error(`error: Unknown command "${command}".\n`);
|
|
106
|
+
console.error(usage);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await handler(rest);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
main().catch((error) => {
|
|
114
|
+
console.error(`error: ${error instanceof Error ? error.message : String(error)}`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
});
|