@danielstyle/featflow 0.6.4 → 0.7.0

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/README.md CHANGED
@@ -133,7 +133,8 @@ main (release, protected)
133
133
 
134
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
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`.
136
+ - `featflow sync-dev` syncs the latest `origin/dev` back into `alice` (also runs automatically before `featflow worktree` and `featflow finish` by default; aborts cleanly on merge conflicts and can be skipped with `--no-sync-dev` or configured via `syncIntegration` in `.featflow.json`).
137
+ - `featflow finish feat/alice-oauth-pkce` syncs `origin/dev` into `alice`, merges into `alice`, pushes `alice`, removes the clean task worktree and local branch, and never merges directly into `dev` or `main`.
137
138
  - Team integration (`alice -> dev`) and release promotion (`dev -> main`) happen via explicit pull requests.
138
139
 
139
140
  ---
@@ -142,15 +143,17 @@ main (release, protected)
142
143
 
143
144
  | Command | Description |
144
145
  | --- | --- |
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 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` (or enable `"featureStorage": "notes"`) to store active records under `.featflow/features/` (excluded via `.git/info/exclude`, zero tracked files). |
147
+ | `featflow notes <subcommand>` | Manage Git Notes feature storage (`refs/notes/featflow`) & dual-source queries: `list`, `show`, `search`, `history`, `archive`, `sync`, and `migrate` (with top-level aliases `featflow list\|show\|search\|history`). Transparently reads both `refs/notes/featflow` and legacy `features/done/*.md`. |
146
148
  | `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
149
  | `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
150
  | `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
151
  | `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`. |
152
+ | `featflow sync-dev [options]` | Sync the shared integration branch (e.g. `origin/dev`) back into your personal developer branch in `developer-branch` mode (`--no-push`, `--abort-on-conflict`, `--dry-run`). |
150
153
  | `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 status` | Inspect workflow mode, branch/remote status, commits behind `origin/dev`, all worktrees, active/paused feature records, and next recommended step. |
155
+ | `featflow worktree <branch> [path] [base]` | Create a typed task branch in a dedicated sibling worktree (auto-syncing `origin/dev` into your developer branch first in `developer-branch` mode; `--no-sync-dev` to skip) and run configured `postWorktreeCreate` commands. |
156
+ | `featflow finish <branch>` | Merge/push a verified task branch (auto-syncing `origin/dev` in `developer-branch` mode), safely exit the task worktree, delete the clean worktree & local branch, and prune other merged task branches. Supports `--no-push`, `--no-sync-dev`, `--pr`, `--dry-run`, `--keep-worktree`, `--keep-branch`. |
154
157
  | `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
158
  | `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
159
  | `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. |
@@ -180,6 +183,14 @@ main (release, protected)
180
183
  "developerBranchConfigKey": "featflow.developerBranch",
181
184
  "worktreeParent": null,
182
185
  "featuresDir": "features",
186
+ "featureStorage": "files",
187
+ "notes": {
188
+ "ref": "refs/notes/featflow",
189
+ "autoSync": true,
190
+ "autoArchiveOnFinish": true,
191
+ "recallInPromptHook": true,
192
+ "recallLimit": 3
193
+ },
183
194
  "trackFeaturesInGit": true,
184
195
  "trackCurrentFeaturePointer": false,
185
196
  "prefixes": ["feat", "fix", "chore", "docs", "test", "refactor", "perf", "security"],
package/README.zh-CN.md CHANGED
@@ -133,7 +133,8 @@ main (发布分支,受保护)
133
133
 
134
134
  - 每个本地克隆首次执行一次:`featflow setup alice`(自动 fetch 远端分支,若远端缺少 `origin/dev` 会交互引导创建并推送——或传 `--bootstrap-integration`——随后基于 `origin/dev` 创建/跟踪 `alice`,写入 `git config featflow.developerBranch alice`,并安全启用 hooks)。在 `developer-branch` 模式下运行 `featflow init` 也可直接联动完成此步骤。
135
135
  - 日常任务从 `alice` 分叉,命名为 `<prefix>/alice-<task>`(不要用 `alice/...`,因为 Git 不允许同名分支与命名空间前缀并存)。
136
- - `featflow finish feat/alice-oauth-pkce` 合回并推送 `alice`,清理干净的任务 worktree 与本地分支,**绝不直接改动 `dev` 或 `main`**。
136
+ - `featflow sync-dev` 可随时将最新 `origin/dev` 同步回 `alice`(默认也会在 `featflow worktree` 和 `featflow finish` 前自动执行;遇冲突自动 `git merge --abort` 安全中止,可用 `--no-sync-dev` 单次跳过或在 `.featflow.json` 的 `syncIntegration` 中配置)。
137
+ - `featflow finish feat/alice-oauth-pkce` 先同步 `origin/dev` 到 `alice`,再合并并推送 `alice`,清理干净的任务 worktree 与本地分支,**绝不直接改动 `dev` 或 `main`**。
137
138
  - 需要团队集成(`alice -> dev`)或发布(`dev -> main`)时再显式提 PR。
138
139
 
139
140
  ---
@@ -142,15 +143,17 @@ main (发布分支,受保护)
142
143
 
143
144
  | 命令 | 说明 |
144
145
  | --- | --- |
145
- | `featflow new <slug>` | 使用项目模板或 `featflow` 内置模板新建 feature(或 `--program`)记录,自动填入时间戳、`owner` 与分支;加 `--local` 存到 `.featflow/features/` 并写入 `.git/info/exclude` 实现零入侵。 |
146
+ | `featflow new <slug>` | 使用项目模板或 `featflow` 内置模板新建 feature(或 `--program`)记录,自动填入时间戳、`owner` 与分支;加 `--local`(或开启 `"featureStorage": "notes"`)存到 `.featflow/features/` 并写入 `.git/info/exclude` 实现零入侵。 |
147
+ | `featflow notes <subcommand>` | 管理 Git Notes(`refs/notes/featflow`)feature 归档与双源检索:`list` / `show` / `search` / `history` / `archive` / `sync` / `migrate`(并提供顶层别名 `featflow list\|show\|search\|history`),透明兼容老 `features/done/*.md`。 |
146
148
  | `featflow skills <install\|status\|uninstall>` | 直接从已安装的 `@danielstyle/featflow` 包离线安装/更新/体检全局 Agent Skills(`featflow`、`featflow-issues`、`featflow-regression`),自动同步到 `~/.agents/skills/` 及已检测的 `~/.claude/skills/`、`~/.codex/skills/`、`~/.cursor/skills/`。 |
147
149
  | `featflow hooks <install\|uninstall\|status>` | 管理 Git hooks:`--local`(默认)在 `.git/hooks/` 中无损增删托管块,保留已有自定义 hook 且不改仓库文件;`--repo` 生成入库的 `.githooks/`。 |
148
150
  | `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
151
  | `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` 按需同步。 |
152
+ | `featflow sync-dev` | 在 `developer-branch` 模式下将最新集成分支(如 `origin/dev`)安全合并回个人开发分支(支持 `--no-push`、`--abort-on-conflict`、`--dry-run`)。 |
150
153
  | `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 status` | 查看当前模式、分支状态、落后 `origin/dev` 提交数、所有 worktree、进行中/暂停中的 feature 记录和下一步建议。 |
155
+ | `featflow worktree <branch>` | 为任务分支创建独立 worktree(`developer-branch` 模式下默认先将 `origin/dev` 同步回个人开发分支,可用 `--no-sync-dev` 跳过),并自动执行 `.featflow.json` 中配置的 `postWorktreeCreate` 命令。 |
156
+ | `featflow finish <branch>` | 完成并收尾任务分支(`developer-branch` 模式下默认先同步 `origin/dev`,再合并/推送、自动切出待删 worktree、移除干净 worktree 与本地分支)。支持 `--no-push`、`--no-sync-dev`、`--pr`、`--dry-run`、`--keep-worktree`、`--keep-branch`。 |
154
157
  | `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
158
  | `featflow size-check [options]` | 可选的多语言文件行数预算守卫(支持历史基线只减不增棘轮、`--changed`、`--update-baseline`、`--json` 及 `post-tool-use` / `pre-commit` 即时拦截),通过 `.featflow.json` 的 `fileSizeBudget` 按需启用。 |
156
159
  | `featflow regression <impact\|check\|validate>` | 可选的回归守卫账本 CLI(支持 YAML/JSON 账本):按改动文件检索命中的历史 Bug 不变量、运行守卫命令或校验账本完整性,配套可选 `featflow-regression` Skill。 |
@@ -180,6 +183,14 @@ main (发布分支,受保护)
180
183
  "developerBranchConfigKey": "featflow.developerBranch",
181
184
  "worktreeParent": null,
182
185
  "featuresDir": "features",
186
+ "featureStorage": "files",
187
+ "notes": {
188
+ "ref": "refs/notes/featflow",
189
+ "autoSync": true,
190
+ "autoArchiveOnFinish": true,
191
+ "recallInPromptHook": true,
192
+ "recallLimit": 3
193
+ },
183
194
  "trackFeaturesInGit": true,
184
195
  "trackCurrentFeaturePointer": false,
185
196
  "prefixes": ["feat", "fix", "chore", "docs", "test", "refactor", "perf", "security"],
package/bin/featflow.mjs CHANGED
@@ -13,6 +13,7 @@ import { runHooks } from "../src/commands/hooks-cmd.mjs";
13
13
  import { runInit } from "../src/commands/init.mjs";
14
14
  import { runIssue } from "../src/commands/issue.mjs";
15
15
  import { runNew } from "../src/commands/new.mjs";
16
+ import { runNotes } from "../src/commands/notes-cmd.mjs";
16
17
  import { runPlanCheck } from "../src/commands/plan-check.mjs";
17
18
  import { runPolicy } from "../src/commands/policy-cmd.mjs";
18
19
  import { runPrCleanup } from "../src/commands/pr-cleanup.mjs";
@@ -21,6 +22,7 @@ import { runSetup } from "../src/commands/setup.mjs";
21
22
  import { runSizeCheck } from "../src/commands/size-check.mjs";
22
23
  import { runSkills } from "../src/commands/skills.mjs";
23
24
  import { runStatus } from "../src/commands/status.mjs";
25
+ import { runSyncDev } from "../src/commands/sync-dev.mjs";
24
26
  import { runSync } from "../src/commands/sync.mjs";
25
27
  import { runVerify } from "../src/commands/verify.mjs";
26
28
  import { runWorktree } from "../src/commands/worktree.mjs";
@@ -35,10 +37,16 @@ Usage:
35
37
 
36
38
  Commands:
37
39
  new Create a feature or program record from repo or built-in template (--local for zero-footprint)
40
+ notes Git Notes feature records & dual-source queries (list | show | search | history | archive | sync | migrate)
41
+ list Alias for "featflow notes list"
42
+ show Alias for "featflow notes show"
43
+ search Alias for "featflow notes search"
44
+ history Alias for "featflow notes history"
38
45
  skills Install/sync/inspect global Agent Skills across Antigravity, Claude Code, Codex, and Cursor
39
46
  hooks Install/uninstall/inspect Git hooks (--local into .git/hooks/ or --repo into .githooks/)
40
47
  init Auto-detect repo config, inject AGENTS.md block, and scaffold featflow (--minimal for lightweight)
41
48
  sync Sync managed Skill, templates, .githooks, and AGENTS.md blocks (--check for CI)
49
+ sync-dev Sync integration branch (e.g. origin/dev) back into your personal developer branch
42
50
  setup Configure developer branch (if applicable) and safely enable Git hooks
43
51
  status Show workflow mode, branch/worktree state, active features, and next step
44
52
  worktree Create a typed task branch in a dedicated Git worktree
@@ -64,10 +72,17 @@ Run "featflow <command> --help" for command-specific options.
64
72
 
65
73
  const commands = {
66
74
  new: runNew,
75
+ notes: runNotes,
76
+ list: (rest) => runNotes(rest, "list"),
77
+ show: (rest) => runNotes(rest, "show"),
78
+ search: (rest) => runNotes(rest, "search"),
79
+ history: (rest) => runNotes(rest, "history"),
67
80
  skills: runSkills,
68
81
  hooks: runHooks,
69
82
  init: runInit,
70
83
  sync: runSync,
84
+ "sync-dev": runSyncDev,
85
+ "sync-integration": runSyncDev,
71
86
  setup: runSetup,
72
87
  status: runStatus,
73
88
  worktree: runWorktree,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielstyle/featflow",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "AI-native feature workflow: Skill + CLI + Git/Agent Hooks for discovery-first planning, Git worktree isolation, GitHub Issues closed loop, and safe branch lifecycles.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,7 +46,11 @@
46
46
  "./issues": "./src/issues.mjs",
47
47
  "./size-check": "./src/size-check.mjs",
48
48
  "./regression": "./src/regression.mjs",
49
- "./skills": "./src/skills-manager.mjs"
49
+ "./skills": "./src/skills-manager.mjs",
50
+ "./notes": "./src/notes.mjs",
51
+ "./notes-query": "./src/notes-query.mjs",
52
+ "./notes-recall": "./src/notes-recall.mjs",
53
+ "./notes-migrate": "./src/notes-migrate.mjs"
50
54
  },
51
55
  "files": [
52
56
  "bin/",
@@ -12,11 +12,11 @@ Use this skill from the active repository checkout or task worktree root. It kee
12
12
  `featflow` works in **three flexible modes** — from zero-footprint global usage (0 tracked repo files) to full repo-tracked team workflows:
13
13
 
14
14
  - `.featflow.json` (optional): repository configuration (branch mode, protected branches, worktree parent, product paths, post-create hooks, verification hints). When absent, `featflow` defaults to `trunk` mode (`main`).
15
- - `features/` (repo-tracked) **or** `.featflow/features/` (local zero-footprint via `featflow new --local`, excluded in `.git/info/exclude`):
15
+ - `features/` (repo-tracked) **or** `.featflow/features/` (local zero-footprint via `featflow new --local` or `"featureStorage": "notes"`, excluded in `.git/info/exclude`):
16
16
  - `active/`: feature records currently being implemented.
17
- - `done/`: completed feature records.
17
+ - `done/`: completed feature records (in `"featureStorage": "notes"` mode, completed records are automatically archived into `refs/notes/featflow` on `featflow finish` instead of accumulating in the working tree; legacy `features/done/*.md` remain readable transparently).
18
18
  - `paused/`: parked feature records ready to resume later.
19
- - `programs/`: long-running program records linking multiple feature phases.
19
+ - `programs/`: long-running program records linking multiple feature phases (always stay as Markdown files).
20
20
  - `_template.md` / `_program_template.md` (optional in repo): `featflow new` automatically uses the repo template when present and falls back to its built-in template otherwise.
21
21
  - `features/current-feature.md` (optional local pointer): short summary of the active worktree's current feature. In parallel worktree setups, treat `active/` as the canonical list rather than a single shared pointer file.
22
22
 
@@ -45,8 +45,9 @@ Inspect `.featflow.json` (or run `featflow status`) to determine the repository'
45
45
  - **`developer-branch` mode (team workflow)**:
46
46
  - Protected branches: `main` (release) and `dev` (team integration).
47
47
  - Personal developer branch: stored in `git config featflow.developerBranch` (configured once via `featflow setup <name>`).
48
+ - Integration sync: `featflow sync-dev` merges the latest `origin/dev` into your personal developer branch; `featflow worktree` and `featflow finish` also auto-sync `origin/dev` into your developer branch by default (cleanly aborting with `git merge --abort` on conflicts; configurable via `.featflow.json` `syncIntegration` or skipped once with `--no-sync-dev`).
48
49
  - Task branch format: `<prefix>/<developer>-<short-kebab-title>` (e.g., `feat/alice-oauth-pkce`). Never use `<developer>/...` because Git cannot store both `<developer>` and `<developer>/...` refs simultaneously.
49
- - Finish: `featflow finish <branch>` merges into the personal developer branch, pushes it (unless `--no-push`), and removes the clean worktree and local task branch. Open `<developer> -> dev` or `dev -> main` PRs only when the user explicitly requests team integration or release promotion.
50
+ - Finish: `featflow finish <branch>` syncs `origin/dev` into the personal developer branch, merges the task branch, pushes it (unless `--no-push`), and removes the clean worktree and local task branch. Open `<developer> -> dev` or `dev -> main` PRs only when the user explicitly requests team integration or release promotion.
50
51
 
51
52
  ## Branch Prefix Policy
52
53
 
@@ -74,7 +75,7 @@ Use a program record (`features/programs/YYYY-MM-DD-short-kebab-program.md` from
74
75
  ## Start A Feature
75
76
 
76
77
  1. **Check Git state**: inspect `git status --short` and current branch. Never discard or relocate unrelated uncommitted changes without asking.
77
- 2. **Read-only discovery**: inspect the relevant files, architecture boundaries, contracts, and closest existing tests.
78
+ 2. **Read-only discovery**: inspect the relevant files, architecture boundaries, contracts, and closest existing tests. When prior design context or past feature decisions may be relevant (especially in repos using `"featureStorage": "notes"`), consult historical records via `featflow history <path...>` (matches both commit notes and `# Changed Files`), `featflow search <query>`, or `featflow show <id|path|sha>` (works seamlessly across both `refs/notes/featflow` and legacy `features/done/*.md`).
78
79
  3. **Present plan & wait for approval**: share the concrete plan in conversation — intended change, affected files/surfaces, technical approach, verification plan, risks, and open questions. Stop and wait unless the user already gave explicit approval or opted out.
79
80
  4. **Verify workflow setup**:
80
81
  - In `developer-branch` mode, verify the configured developer branch (`featflow status`). If unset, stop and ask the user to run `featflow setup <your-branch>`.
@@ -111,8 +112,10 @@ Use a program record (`features/programs/YYYY-MM-DD-short-kebab-program.md` from
111
112
 
112
113
  1. Run required verification checks in the task worktree.
113
114
  2. Update `Verification` (commands run, skipped checks with reasons), `Changed Files`, and `Handoff` (residual risks and follow-ups).
114
- 3. Set `status: done`, refresh `updated`, and move the record from `features/active/` to `features/done/`.
115
- 4. If linked to a program, update the program's phase index row to `done` and refresh `Resume Notes`.
115
+ 3. Set `status: done`, refresh `updated`, and:
116
+ - In default `files` storage mode: move the record from `features/active/` to `features/done/` and commit it with your changes.
117
+ - In `notes` storage mode (`"featureStorage": "notes"`): keep the updated active record in `.featflow/features/active/` (zero working-tree diff) and commit only your code/test changes — `featflow finish <branch>` will automatically mark it `done`, archive it into `refs/notes/featflow` attached to the task tip commit, and push the notes ref.
118
+ 4. If linked to a program, update the program's phase index row to `done` and refresh `Resume Notes` (old `features/done/...` links resolve automatically via `featflow show`).
116
119
  5. If the repository tracks `features/current-feature.md`, clear `active_feature:`, set `status: none`, and update `last_completed`.
117
120
  6. Commit all changes (including the `done` record) on the task branch with a focused Conventional Commit message.
118
121
  7. Run `featflow finish <branch>` (or pass `--no-push` for local-only, or `--pr` if opening a pull request):
@@ -9,6 +9,7 @@ import {
9
9
  } from "../agent-docs.mjs";
10
10
  import { loadConfig } from "../config.mjs";
11
11
  import { commandExists, findGitCommonDir, findRepoRoot, gitConfigGet, localBranchExists } from "../git.mjs";
12
+ import { inspectNotesGitConfig, isNotesStorageEnabled, listNoteEntries } from "../notes.mjs";
12
13
  import { validateActiveFeaturePlan } from "../plan.mjs";
13
14
  import {
14
15
  inspectCliAvailability,
@@ -200,6 +201,24 @@ export async function runDoctor(argv) {
200
201
  ledgerExists ? config.regression.ledgerFile : `configured "${config.regression.ledgerFile}" not found`,
201
202
  );
202
203
  }
204
+ if (isNotesStorageEnabled(config) || config.notes) {
205
+ const notesState = inspectNotesGitConfig(repoRoot, config);
206
+ const noteCount = listNoteEntries(repoRoot, notesState.notesRef).length;
207
+ const missingCfg = [];
208
+ if (notesState.hasRemote && !notesState.hasFetchRefspec) missingCfg.push(`remote.${notesState.remote}.fetch`);
209
+ if (!notesState.hasRewriteRef) missingCfg.push("notes.rewriteRef");
210
+ if (!notesState.rewriteAmend) missingCfg.push("notes.rewrite.amend");
211
+ if (!notesState.rewriteRebase) missingCfg.push("notes.rewrite.rebase");
212
+ if (missingCfg.length === 0) {
213
+ add("PASS", "Git Notes storage", `${notesState.notesRef} (${noteCount} annotated commit(s), sync/rewrite configured)`);
214
+ } else {
215
+ add(
216
+ "WARN",
217
+ "Git Notes storage",
218
+ `${notesState.notesRef} (${noteCount} annotated commit(s)); missing git config: ${missingCfg.join(", ")} (run \`featflow setup\`)`,
219
+ );
220
+ }
221
+ }
203
222
 
204
223
  if (configuredAgentHooks.length > 0) {
205
224
  add("PASS", "AI Agent hooks", configuredAgentHooks.join(", "));
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
 
3
- import { loadConfig, resolveWorktreeParent } from "../config.mjs";
3
+ import { loadConfig, resolveSyncIntegrationConfig, resolveWorktreeParent } from "../config.mjs";
4
4
  import {
5
5
  ensureCleanWorktree,
6
6
  fail,
@@ -11,20 +11,25 @@ import {
11
11
  localBranchExists,
12
12
  remoteExists,
13
13
  remoteTrackingBranchExists,
14
+ runRead,
14
15
  runWrite,
15
16
  sanitizeBranchForDir,
16
17
  validateTaskBranchName,
17
18
  } from "../git.mjs";
19
+ import { isNotesStorageEnabled, syncNotesWithRemote } from "../notes.mjs";
20
+ import { archiveFeatureFileToNotes } from "../notes-migrate.mjs";
18
21
  import { setupInstructions } from "../policy.mjs";
19
22
  import { cleanupMergedTaskBranches } from "./cleanup.mjs";
23
+ import { syncDeveloperBranchWithIntegration } from "./sync-dev.mjs";
20
24
 
21
25
  const usage = `
22
26
  Usage:
23
27
  featflow finish <task-branch> [options]
24
28
 
25
29
  Completes a verified task branch:
26
- - In developer-branch mode: merges into your personal developer branch,
27
- pushes it (unless --no-push or offline), and removes the clean task worktree & branch.
30
+ - In developer-branch mode: syncs the integration branch (e.g. origin/dev)
31
+ into your personal developer branch (unless --no-sync-dev or --no-push),
32
+ merges the task branch, pushes it, and removes the clean task worktree & branch.
28
33
  - In trunk mode (finishTarget=merge): merges into baseBranch, pushes if remote exists
29
34
  (unless --no-push), and removes the clean task worktree & branch.
30
35
  - In trunk mode (finishTarget=pr or --pr): pushes the task branch so you can open a PR,
@@ -36,6 +41,7 @@ Options:
36
41
  --worktree <path> Override the task worktree path.
37
42
  --pr Push task branch for a pull request instead of merging locally.
38
43
  --no-push Skip fetching from and pushing to the remote.
44
+ --no-sync-dev Skip syncing the integration branch into your developer branch.
39
45
  --dry-run Print mutating commands without running them.
40
46
  --keep-worktree Do not remove the task worktree.
41
47
  --keep-branch Do not delete the local task branch.
@@ -49,6 +55,7 @@ function parseArgs(argv) {
49
55
  keepBranch: false,
50
56
  keepWorktree: false,
51
57
  noPush: false,
58
+ noSyncDev: false,
52
59
  pr: false,
53
60
  remote: "",
54
61
  taskBranch: "",
@@ -70,6 +77,10 @@ function parseArgs(argv) {
70
77
  options.noPush = true;
71
78
  continue;
72
79
  }
80
+ if (arg === "--no-sync-dev") {
81
+ options.noSyncDev = true;
82
+ continue;
83
+ }
73
84
  if (arg === "--pr") {
74
85
  options.pr = true;
75
86
  continue;
@@ -149,12 +160,39 @@ export async function runFinish(argv) {
149
160
  }
150
161
 
151
162
  const hasRemote = !options.noPush && remoteExists(remote, repoRoot);
163
+ const isPrMode = options.pr || (config.mode === "trunk" && config.finishTarget === "pr");
164
+ const shouldArchiveNotes = isNotesStorageEnabled(config) && config.notes?.autoArchiveOnFinish !== false;
165
+ const taskTipSha = runRead("git", ["rev-parse", options.taskBranch], repoRoot);
166
+
167
+ let archivedNote = null;
168
+ if (shouldArchiveNotes && taskWorktree) {
169
+ archivedNote = archiveFeatureFileToNotes(repoRoot, config, {
170
+ worktreePath: taskWorktree.path,
171
+ branch: options.taskBranch,
172
+ commit: taskTipSha,
173
+ dryRun: options.dryRun,
174
+ moveLocalDone: !isPrMode && options.keepWorktree,
175
+ sync: false,
176
+ });
177
+ if (archivedNote.archived) {
178
+ const verb = options.dryRun ? "[dry-run] Would archive" : "Archived";
179
+ console.log(`${verb} feature record ${archivedNote.id} -> ${archivedNote.notesRef} @ ${taskTipSha.slice(0, 8)}`);
180
+ }
181
+ }
152
182
 
153
183
  // PR-based finish (trunk + pr strategy or explicit --pr)
154
- if (options.pr || (config.mode === "trunk" && config.finishTarget === "pr")) {
184
+ if (isPrMode) {
155
185
  const pushCwd = taskWorktree?.path ?? repoRoot;
156
186
  if (hasRemote) {
157
187
  runWrite("git", ["push", "-u", remote, options.taskBranch], pushCwd, { dryRun: options.dryRun });
188
+ if (archivedNote?.archived || (isNotesStorageEnabled(config) && config.notes?.autoSync !== false)) {
189
+ syncNotesWithRemote(pushCwd, config, {
190
+ remote,
191
+ push: true,
192
+ dryRun: options.dryRun,
193
+ bestEffort: !archivedNote?.archived,
194
+ });
195
+ }
158
196
  }
159
197
  const base = config.mode === "developer-branch" ? config.integrationBranch : config.baseBranch;
160
198
  console.log(`Task branch ready for pull request: ${options.taskBranch}`);
@@ -198,6 +236,30 @@ export async function runFinish(argv) {
198
236
  }
199
237
  }
200
238
 
239
+ const syncCfg = resolveSyncIntegrationConfig(config);
240
+ if (
241
+ config.mode === "developer-branch" &&
242
+ syncCfg.onFinish &&
243
+ !options.noSyncDev &&
244
+ !options.noPush
245
+ ) {
246
+ try {
247
+ syncDeveloperBranchWithIntegration(repoRoot, config, {
248
+ developer: targetBranch,
249
+ remote,
250
+ targetWorktreePath: targetWorktree.path,
251
+ dryRun: options.dryRun,
252
+ dryRunMissing: Boolean(targetWorktree.dryRunMissing),
253
+ fetch: hasRemote,
254
+ push: false,
255
+ abortOnConflict: true,
256
+ skipIfMissingIntegration: true,
257
+ });
258
+ } catch (error) {
259
+ fail(error instanceof Error ? error.message : String(error));
260
+ }
261
+ }
262
+
201
263
  // Move out of task worktree BEFORE merging so post-merge hooks & worktree removal succeed
202
264
  if (taskWorktree && !options.keepWorktree && isInsidePath(process.cwd(), taskWorktree.path)) {
203
265
  process.chdir(targetWorktree.path);
@@ -213,6 +275,17 @@ export async function runFinish(argv) {
213
275
  dryRun: options.dryRun,
214
276
  env: internalEnv,
215
277
  });
278
+ if (archivedNote?.archived || (isNotesStorageEnabled(config) && config.notes?.autoSync !== false)) {
279
+ const notesSync = syncNotesWithRemote(targetWorktree.path, config, {
280
+ remote,
281
+ push: true,
282
+ dryRun: options.dryRun,
283
+ bestEffort: !archivedNote?.archived,
284
+ });
285
+ if (notesSync.pushed) {
286
+ console.log(`Synced feature notes: ${notesSync.notesRef} -> ${remote}`);
287
+ }
288
+ }
216
289
  }
217
290
 
218
291
  const remainingTaskWorktree = findWorktreeForBranch(gitWorktrees(targetWorktree.path), options.taskBranch);
@@ -6,10 +6,12 @@ import {
6
6
  CONFIG_FILENAME,
7
7
  DEFAULT_FILE_SIZE_BUDGET,
8
8
  DEFAULT_ISSUES_CONFIG,
9
+ DEFAULT_NOTES_CONFIG,
9
10
  DEFAULT_REGRESSION_CONFIG,
10
11
  packageRoot,
11
12
  presetConfig,
12
13
  } from "../config.mjs";
14
+ import { configureNotesGitConfig } from "../notes.mjs";
13
15
  import { applyDetectedConfig, detectRepoEnvironment } from "../detect.mjs";
14
16
  import { fail, findRepoRoot, gitConfigGet } from "../git.mjs";
15
17
  import { INIT_USAGE, parseInitArgs } from "../init-args.mjs";
@@ -102,6 +104,13 @@ export async function runInit(argv) {
102
104
  config.regression = { ...DEFAULT_REGRESSION_CONFIG };
103
105
  configChangedInMerge = true;
104
106
  }
107
+ if (options.featureStorage && config.featureStorage !== options.featureStorage) {
108
+ config.featureStorage = options.featureStorage;
109
+ if (options.featureStorage === "notes" && !config.notes) {
110
+ config.notes = { ...DEFAULT_NOTES_CONFIG };
111
+ }
112
+ configChangedInMerge = true;
113
+ }
105
114
  } else {
106
115
  try {
107
116
  config = presetConfig(options.mode);
@@ -116,6 +125,12 @@ export async function runInit(argv) {
116
125
  });
117
126
  }
118
127
  if (options.featuresDir) config.featuresDir = options.featuresDir;
128
+ if (options.featureStorage) {
129
+ config.featureStorage = options.featureStorage;
130
+ if (options.featureStorage === "notes") {
131
+ config.notes = { ...DEFAULT_NOTES_CONFIG };
132
+ }
133
+ }
119
134
  if (options.finishTarget) {
120
135
  if (config.mode !== "trunk" || !["merge", "pr"].includes(options.finishTarget)) {
121
136
  fail(`--finish-target "${options.finishTarget}" is only valid in trunk mode ("merge" or "pr").`, INIT_USAGE);
@@ -300,6 +315,19 @@ export async function runInit(argv) {
300
315
  }
301
316
  }
302
317
 
318
+ if (config.featureStorage === "notes") {
319
+ try {
320
+ const notesCfg = configureNotesGitConfig(repoRoot, config);
321
+ if (notesCfg.applied.length > 0) {
322
+ notices.push(`Configured Git notes (${notesCfg.notesRef}): ${notesCfg.applied.join(", ")}.`);
323
+ }
324
+ } catch (error) {
325
+ notices.push(
326
+ `[WARN] Could not configure Git notes settings automatically: ${error instanceof Error ? error.message : String(error)}`,
327
+ );
328
+ }
329
+ }
330
+
303
331
  let ignoredAdded = [];
304
332
  if (options.updateGitignore) {
305
333
  const entries = [".featflow/"];
@@ -9,6 +9,7 @@ import {
9
9
  findRepoRoot,
10
10
  gitConfigGet,
11
11
  } from "../git.mjs";
12
+ import { isNotesStorageEnabled, resolveNotesRef } from "../notes.mjs";
12
13
 
13
14
  const LOCAL_FEATURES_DIR = ".featflow/features";
14
15
 
@@ -26,6 +27,7 @@ Options:
26
27
  --status <status> Initial status (default: planned).
27
28
  --program Create a multi-phase program record under programs/ instead of active/.
28
29
  --local Write to .featflow/features/ and add to .git/info/exclude (zero tracked files).
30
+ --tracked Force writing under config.featuresDir even when featureStorage="notes".
29
31
  --dir <path> Override features base directory.
30
32
  --update-pointer Update current-feature.md pointer file when creating a feature record.
31
33
  --template Print the resolved template to stdout without writing any file.
@@ -41,6 +43,7 @@ function parseArgs(argv) {
41
43
  status: "planned",
42
44
  program: false,
43
45
  local: false,
46
+ tracked: false,
44
47
  dir: "",
45
48
  updatePointer: false,
46
49
  templateOnly: false,
@@ -62,6 +65,10 @@ function parseArgs(argv) {
62
65
  options.local = true;
63
66
  continue;
64
67
  }
68
+ if (arg === "--tracked") {
69
+ options.tracked = true;
70
+ continue;
71
+ }
65
72
  if (arg === "--update-pointer") {
66
73
  options.updatePointer = true;
67
74
  continue;
@@ -211,8 +218,10 @@ export async function runNew(argv) {
211
218
  }
212
219
 
213
220
  const { config } = loadConfig(repoRoot);
214
- const featuresBaseDir = options.dir || (options.local ? LOCAL_FEATURES_DIR : config.featuresDir);
215
- const rawTemplate = loadTemplate(repoRoot, featuresBaseDir, options.program);
221
+ const useNotesLocal = !options.program && !options.tracked && !options.dir && isNotesStorageEnabled(config);
222
+ const isLocalStorage = options.local || useNotesLocal;
223
+ const featuresBaseDir = options.dir || (isLocalStorage ? LOCAL_FEATURES_DIR : config.featuresDir);
224
+ const rawTemplate = loadTemplate(repoRoot, options.dir || config.featuresDir, options.program);
216
225
 
217
226
  if (options.templateOnly) {
218
227
  process.stdout.write(rawTemplate);
@@ -270,11 +279,14 @@ export async function runNew(argv) {
270
279
  mkdirSync(path.dirname(absPath), { recursive: true });
271
280
  writeFileSync(absPath, rendered, "utf8");
272
281
 
273
- if (options.local) {
282
+ if (isLocalStorage) {
274
283
  ensureGitInfoExclude(repoRoot, [".featflow/"]);
275
284
  }
276
285
 
277
- if (!options.program && (options.updatePointer || existsSync(path.resolve(repoRoot, featuresBaseDir, "current-feature.md")))) {
286
+ if (
287
+ !options.program &&
288
+ (options.updatePointer || (!useNotesLocal && existsSync(path.resolve(repoRoot, featuresBaseDir, "current-feature.md"))))
289
+ ) {
278
290
  const pointerPath = path.resolve(repoRoot, featuresBaseDir, "current-feature.md");
279
291
  const existingPointer = existsSync(pointerPath) ? readFileSync(pointerPath, "utf8") : "";
280
292
  const lastCompletedMatch = existingPointer.match(/^last_completed:[ \t]*([^\r\n]*)$/m);
@@ -304,7 +316,11 @@ export async function runNew(argv) {
304
316
  }
305
317
 
306
318
  console.log(`Created ${options.program ? "program" : "feature"} record: ${relPath}`);
307
- if (options.local) {
319
+ if (useNotesLocal) {
320
+ console.log(
321
+ `Stored locally under .featflow/features/ (zero tracked files; \`featflow finish\` will archive it to ${resolveNotesRef(config)}).`,
322
+ );
323
+ } else if (options.local) {
308
324
  console.log("Stored locally under .featflow/features/ (excluded via .git/info/exclude; zero tracked files added).");
309
325
  }
310
326
  console.log(`Next: fill Plan Details and run \`featflow plan-check ${relPath}\`.`);