@danielstyle/featflow 0.0.0-stage → 0.6.3

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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +206 -2
  3. package/README.zh-CN.md +163 -0
  4. package/bin/featflow.mjs +113 -0
  5. package/package.json +62 -4
  6. package/skills/featflow/SKILL.md +127 -0
  7. package/skills/featflow-issues/SKILL.md +104 -0
  8. package/skills/featflow-regression/SKILL.md +63 -0
  9. package/src/agent-docs.mjs +143 -0
  10. package/src/changed-files.mjs +204 -0
  11. package/src/commands/cleanup.mjs +221 -0
  12. package/src/commands/codegraph.mjs +110 -0
  13. package/src/commands/doctor.mjs +265 -0
  14. package/src/commands/finish.mjs +249 -0
  15. package/src/commands/hook-cmd.mjs +78 -0
  16. package/src/commands/hooks-cmd.mjs +238 -0
  17. package/src/commands/init.mjs +382 -0
  18. package/src/commands/issue.mjs +434 -0
  19. package/src/commands/new.mjs +311 -0
  20. package/src/commands/plan-check.mjs +75 -0
  21. package/src/commands/policy-cmd.mjs +51 -0
  22. package/src/commands/pr-cleanup.mjs +194 -0
  23. package/src/commands/regression.mjs +206 -0
  24. package/src/commands/setup.mjs +343 -0
  25. package/src/commands/size-check.mjs +137 -0
  26. package/src/commands/status.mjs +100 -0
  27. package/src/commands/sync.mjs +407 -0
  28. package/src/commands/verify.mjs +206 -0
  29. package/src/commands/worktree.mjs +205 -0
  30. package/src/config.mjs +295 -0
  31. package/src/detect.mjs +314 -0
  32. package/src/git.mjs +331 -0
  33. package/src/hook-adapters.mjs +218 -0
  34. package/src/hooks-core.mjs +420 -0
  35. package/src/index.mjs +13 -0
  36. package/src/init-args.mjs +282 -0
  37. package/src/init-hooks.mjs +312 -0
  38. package/src/init-prompts.mjs +191 -0
  39. package/src/issues-helpers.mjs +463 -0
  40. package/src/issues.mjs +521 -0
  41. package/src/plan.mjs +202 -0
  42. package/src/policy.mjs +143 -0
  43. package/src/regression.mjs +338 -0
  44. package/src/size-check.mjs +203 -0
  45. package/src/tui-select.mjs +378 -0
  46. package/templates/adapters/antigravity/hooks.json +42 -0
  47. package/templates/adapters/claude-code/settings.json +46 -0
  48. package/templates/adapters/codex/config.toml +19 -0
  49. package/templates/adapters/cursor/hooks.json +27 -0
  50. package/templates/agents/codex/codebase-locator.toml +28 -0
  51. package/templates/agents/codex/implementation-scout.toml +28 -0
  52. package/templates/agents/codex/regression-guard-planner.toml +20 -0
  53. package/templates/features/README.md +56 -0
  54. package/templates/features/_program_template.md +79 -0
  55. package/templates/features/_template.md +120 -0
  56. package/templates/features/current-feature.md +18 -0
  57. package/templates/githooks/post-merge +7 -0
  58. package/templates/githooks/pre-commit +11 -0
  59. package/templates/githooks/pre-push +10 -0
  60. package/templates/regression/regression-ledger.yml +23 -0
  61. package/templates/snippets/AGENTS-workflow.md +21 -0
@@ -0,0 +1,27 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "beforeSubmitPrompt": [
5
+ {
6
+ "command": "featflow hook cursor before-submit-prompt"
7
+ }
8
+ ],
9
+ "preToolUse": [
10
+ {
11
+ "command": "featflow hook cursor pre-tool-use",
12
+ "matcher": "Shell|Write|StrReplace|Edit|MultiEdit|Bash"
13
+ }
14
+ ],
15
+ "postToolUse": [
16
+ {
17
+ "command": "featflow hook cursor post-tool-use",
18
+ "matcher": "Write|StrReplace|Edit|MultiEdit"
19
+ }
20
+ ],
21
+ "stop": [
22
+ {
23
+ "command": "featflow hook cursor stop"
24
+ }
25
+ ]
26
+ }
27
+ }
@@ -0,0 +1,28 @@
1
+ name = "codebase-locator"
2
+ description = "Quickly locates likely owner files, symbols, tests, and follow-ups for unclear codebase tasks without editing files."
3
+ sandbox_mode = "read-only"
4
+ developer_instructions = """
5
+ You are the read-only codebase locator.
6
+
7
+ Use this agent when affected files, owning surfaces, or the shortest read path are unclear. Your job is to answer "where should the main thread look first?" with minimal context load.
8
+
9
+ Default posture:
10
+ - Read and analyze only. Do not edit files, run formatters, stage changes, commit, change branches, or create worktrees.
11
+ - Prefer CodeGraph before broad text search when a `.codegraph/` directory exists (`codegraph explore` for questions, `codegraph node` for symbols/files). Fall back to `rg` and targeted reads for docs, configs, or unindexed files.
12
+ - Locate ownership, symbols, tests, and risks. Do not design or implement the solution.
13
+
14
+ Hard budgets:
15
+ - Return at most 8 likely owner files.
16
+ - Return at most 5 key symbols or entry points.
17
+ - Read at most 5 source/test/doc snippets unless the prompt explicitly grants a larger budget.
18
+ - Do not paste long source blocks. Use file paths, line references, symbol names, and one-sentence rationale.
19
+ - Stop as soon as you can name the shortest useful read path.
20
+
21
+ Output shape:
22
+ - Likely surface: owning directory/module and why.
23
+ - Owner files: up to 8 paths with one-line rationale.
24
+ - Key symbols: up to 5 symbols, functions, classes, routes, or config keys.
25
+ - Shortest read path: ordered list of files/lines for the main thread to inspect.
26
+ - Nearby tests/checks: relevant test files or verification commands.
27
+ - Unknowns: only items that materially affect scoping.
28
+ """
@@ -0,0 +1,28 @@
1
+ name = "implementation-scout"
2
+ description = "Inspects a bounded target area and recommends the smallest safe implementation path, risks, and checks without editing files."
3
+ sandbox_mode = "read-only"
4
+ developer_instructions = """
5
+ You are the read-only implementation scout.
6
+
7
+ Use this agent after files or modules have been narrowed by the main thread, CodeGraph, or `codebase-locator`. Your job is to answer "what is the smallest safe implementation path?" without editing files.
8
+
9
+ Default posture:
10
+ - Read and analyze only. Do not edit files, run formatters, stage changes, commit, change branches, or create worktrees.
11
+ - Work strictly inside the provided target area. If scope is too vague, recommend running `codebase-locator` first and stop.
12
+ - Prefer existing local abstractions, boundaries, and test patterns over new patterns.
13
+ - Keep recommendations concise and implementation-ready; the main thread owns planning approval, edits, verification, and commits.
14
+
15
+ Hard budgets:
16
+ - Inspect at most 8 source files and 4 test/doc/config files unless explicitly granted more.
17
+ - Return at most 10 affected files.
18
+ - Do not paste long source blocks; quote only tiny signatures or field names when essential.
19
+
20
+ Output shape:
21
+ - Scope confirmation: files/modules inspected.
22
+ - Proposed minimal change: concise step-by-step path, not a patch.
23
+ - Affected files: up to 10 files with expected edit/no-edit role.
24
+ - Existing patterns to follow: helpers, contracts, and test styles.
25
+ - Risks and invariants: what must not regress.
26
+ - Suggested checks: exact narrow verification commands.
27
+ - Stop summary: one short paragraph to proceed.
28
+ """
@@ -0,0 +1,20 @@
1
+ name = "regression-guard-planner"
2
+ description = "Plans durable regression guards for bug fixes, failing tests, and GitHub Issue bugs without editing files."
3
+ sandbox_mode = "read-only"
4
+ developer_instructions = """
5
+ You are the read-only regression guard planner.
6
+
7
+ Use this agent when investigating a bug fix, failing test, regression, or fragile code path that needs durable automated guard coverage.
8
+
9
+ Default posture:
10
+ - Read and analyze only. Do not edit files, stage changes, commit, or switch branches.
11
+ - Prefer small, executable guards over memory or prose warnings.
12
+ - Inspect the repository's regression ledger (if configured in `.featflow.json`, or `featflow regression impact --json`) and nearby test suites.
13
+
14
+ Output shape:
15
+ - Bug invariant: one sentence stating what must stay true.
16
+ - Best guard: exact test/check file and why it is the smallest reliable guard.
17
+ - Existing coverage: nearby tests or ledger entries protecting this path.
18
+ - Commands: exact narrow verification commands from the repository root.
19
+ - Residual risk: anything that remains manual or unguarded.
20
+ """
@@ -0,0 +1,56 @@
1
+ # Feature Records
2
+
3
+ This directory tracks substantial project-level engineering work from discovery and planning through execution, verification, and handoff.
4
+
5
+ ## Structure
6
+
7
+ ```text
8
+ features/
9
+ README.md
10
+ _template.md
11
+ _program_template.md
12
+ active/ # Features currently being implemented
13
+ done/ # Completed feature records
14
+ paused/ # Parked work ready to resume later
15
+ programs/ # Multi-phase roadmaps linking multiple feature records
16
+ ```
17
+
18
+ > **Note on `current-feature.md`:** By default, `features/current-feature.md` is ignored by Git to avoid merge conflicts across parallel worktrees and developers. `features/active/` is the canonical active list, and `featflow status` summarizes all active and paused records automatically.
19
+
20
+ ## Workflow Summary
21
+
22
+ 1. **Discover** (read-only) relevant files, contracts, and tests.
23
+ 2. **Plan & Get Approval** before creating an implementation worktree or editing tracked files.
24
+ 3. **Isolate** work in a typed-branch worktree: `featflow worktree <prefix>/<task-name>`.
25
+ 4. **Document** the concrete `Feature Brief` and `Plan Details` in `features/active/YYYY-MM-DD-HHMM-short-kebab-title.md` (drafted and maintained by the AI, verified with `featflow plan-check`).
26
+ 5. **Implement & Verify**, updating `Execution Log`, `Decisions`, `Changed Files`, and `Verification`.
27
+ 6. **Complete**: move the record to `features/done/`, commit on the task branch, and run `featflow finish <branch>`.
28
+
29
+ ## Branch Prefixes
30
+
31
+ - `feat/` — new user-facing capability or substantial enhancement
32
+ - `fix/` — bug fix, regression, or incident repair
33
+ - `chore/` — tooling, dependencies, config, or workflow maintenance
34
+ - `docs/` — documentation-only change
35
+ - `test/` — test-only additions or hardening
36
+ - `refactor/` — behavior-preserving restructuring
37
+ - `perf/` — performance improvement
38
+ - `security/` — security hardening or vulnerability fix
39
+
40
+ ## Status Values
41
+
42
+ - `planned` — scoped, awaiting implementation
43
+ - `in_progress` — actively being implemented
44
+ - `review` — ready for or awaiting pull request review
45
+ - `blocked` — waiting on user decision or external dependency
46
+ - `paused` — intentionally parked for later resumption
47
+ - `done` — verified, merged/handed off, and archived in `features/done/`
48
+ - `cancelled` — stopped without completion
49
+
50
+ ## Naming Convention
51
+
52
+ Use local 24-hour time in `YYYY-MM-DD-HHMM-short-kebab-title.md` so multiple same-day features never collide:
53
+
54
+ ```text
55
+ features/active/2026-06-15-1430-oauth-pkce-login.md
56
+ ```
@@ -0,0 +1,79 @@
1
+ ---
2
+ id: YYYY-MM-DD-short-kebab-program
3
+ title: Short Program Title
4
+ status: planned
5
+ created: YYYY-MM-DDTHH:MM:SSZ
6
+ updated: YYYY-MM-DDTHH:MM:SSZ
7
+ owner: GIT_USER_NAME
8
+ primary_surfaces: []
9
+ current_phase:
10
+ ---
11
+
12
+ # Program Brief
13
+
14
+ ## Intent
15
+
16
+ Replace with the long-running outcome this multi-phase program delivers.
17
+
18
+ ## Why A Program
19
+
20
+ Explain why this initiative spans multiple feature records, branches, pull requests, repositories, or releases.
21
+
22
+ ## Scope
23
+
24
+ - Replace with the systems, modules, or repositories covered.
25
+ - Include operational, security, documentation, or migration scope when relevant.
26
+
27
+ ## Non-goals
28
+
29
+ - Replace with work intentionally out of scope for this program.
30
+
31
+ # Operating Model
32
+
33
+ - This program record is the canonical cross-phase roadmap and decision log.
34
+ - Each implementation phase still requires its own feature record under `features/active/` (and later `features/done/`).
35
+ - Before starting or resuming a phase, read this program record and the latest linked phase record.
36
+ - Update this record whenever a phase starts, pauses, blocks, reaches review, finishes, or changes scope.
37
+ - Never store secrets, credentials, or sensitive user data here.
38
+
39
+ # Phase Index
40
+
41
+ | Phase | Status | Feature Record | Branch / PR | Goal | Exit Criteria |
42
+ | --- | --- | --- | --- | --- | --- |
43
+ | 0 | planned | `features/active/YYYY-MM-DD-HHMM-short-kebab-title.md` | `prefix/short-kebab-title` | Replace with phase goal. | Replace with observable exit criteria. |
44
+
45
+ # Cross-Phase Architecture
46
+
47
+ ## Target Shape
48
+
49
+ - Replace with the target end-state architecture.
50
+
51
+ ## Integration Contracts
52
+
53
+ - Replace with cross-phase API, schema, CLI, or compatibility contracts.
54
+
55
+ ## Migration Strategy
56
+
57
+ - Replace with rollout, coexistence, fallback, and deprecation strategy.
58
+
59
+ # Decisions
60
+
61
+ - Decision: Replace with long-lived choices that later phases must preserve.
62
+
63
+ # Risks And Watchpoints
64
+
65
+ - Replace with cross-phase risks, security watchpoints, or open uncertainties.
66
+
67
+ # Verification Strategy
68
+
69
+ - Replace with verification gates repeated or expanded across phases.
70
+
71
+ # Resume Notes
72
+
73
+ - Next recommended phase: replace with the next concrete phase to start or resume.
74
+ - Required context before resuming: replace with records, docs, branches, or external repos to inspect.
75
+ - Blockers: `None` or concrete blocker.
76
+
77
+ # History
78
+
79
+ - YYYY-MM-DD HH:MM: Program record created.
@@ -0,0 +1,120 @@
1
+ ---
2
+ id: YYYY-MM-DD-HHMM-short-kebab-title
3
+ title: Short Feature Title
4
+ status: planned
5
+ surfaces: []
6
+ branch: prefix/short-kebab-title
7
+ created: YYYY-MM-DDTHH:MM:SSZ
8
+ updated: YYYY-MM-DDTHH:MM:SSZ
9
+ owner: GIT_USER_NAME
10
+ ---
11
+
12
+ # Feature Brief
13
+
14
+ ## Intent
15
+
16
+ Replace with the problem this feature solves and the outcome users or maintainers should observe.
17
+
18
+ ## Scope
19
+
20
+ - Replace with what will change.
21
+ - Which surfaces/modules are affected.
22
+ - What must be true before handoff.
23
+
24
+ ## Non-goals
25
+
26
+ - Replace with what is intentionally out of scope.
27
+
28
+ # Plan Details
29
+
30
+ Replace every placeholder below before editing product code. Never leave empty headings or generic placeholder text in an active feature record. If a section does not apply, write `None - <reason>`. If a detail is unknown but non-blocking, write `Unknown - <how it will be discovered>` and track it in `Open Questions`.
31
+
32
+ ## Branch Plan
33
+
34
+ - Workflow mode: `trunk | developer-branch`
35
+ - Base branch: Replace with configured base or developer branch
36
+ - Work type: `feature | fix | chore | docs | test | refactor | perf | security`
37
+ - Selected prefix: `prefix/`
38
+ - Tracked branch: `prefix/short-kebab-title`
39
+ - Worktree path: Replace with worktree path or explicit no-worktree exception
40
+ - Completion strategy: Replace with `featflow finish <branch>` (merge or PR + `featflow pr-cleanup`)
41
+
42
+ ## Pre-Implementation Approval
43
+
44
+ - Approval status: `pending | approved | skipped-by-user`
45
+ - Approval source: Replace with the user message or explicit skip-confirmation instruction.
46
+ - Approved constraints: Replace with scope, behavior, verification, or non-goal constraints confirmed by the user.
47
+ - If implementation uncovers a materially different root cause, scope, security boundary, or risk profile, pause and request approval for an updated plan.
48
+
49
+ ## Requirements
50
+
51
+ - Replace with user needs and functional requirements.
52
+ - Include compatibility, security, and edge-case constraints.
53
+
54
+ ## Acceptance Criteria
55
+
56
+ - Replace with observable conditions that define done.
57
+
58
+ ## Technical Approach
59
+
60
+ - Replace with implementation strategy grounded in inspected repository files.
61
+ - Call out architecture boundaries, existing patterns, and key tradeoffs.
62
+
63
+ ## Implementation Plan
64
+
65
+ - [ ] Complete read-only discovery and present a concrete plan to the user.
66
+ - [ ] Record explicit user approval (or skip-confirmation instruction).
67
+ - [ ] Create or switch to the typed task branch worktree.
68
+ - [ ] Replace with concrete implementation step(s).
69
+ - [ ] Replace with concrete verification step(s).
70
+ - [ ] Update `Verification`, `Changed Files`, and `Handoff`, then move this record to `features/done/`.
71
+ - [ ] Commit all changes on the task branch and run `featflow finish <tracked-branch>`.
72
+
73
+ ## Affected Files / Modules
74
+
75
+ - Replace with inspected files, packages, APIs, components, or docs expected to change.
76
+
77
+ ## Data / API / Contract Changes
78
+
79
+ - Note schema, migration, API, CLI, event, or config contract changes.
80
+ - Write `None - <reason>` if no contracts change.
81
+
82
+ ## UX / Behavior Changes
83
+
84
+ - Describe user-visible or operational behavior changes.
85
+ - Write `None - <reason>` if none apply.
86
+
87
+ ## Test Plan
88
+
89
+ - [ ] Focused unit/integration tests for touched behavior.
90
+ - [ ] Regression test or guard (required for bug fixes unless documented why impractical).
91
+ - [ ] Repository lint / typecheck / build checks as appropriate.
92
+
93
+ ## Risks
94
+
95
+ - Replace with implementation risks, potential regressions, migration hazards, or ambiguities.
96
+
97
+ ## Open Questions
98
+
99
+ - Replace with unresolved questions, or write `None`.
100
+
101
+ # Execution Log
102
+
103
+ - YYYY-MM-DD HH:MM: Started planning.
104
+
105
+ # Decisions
106
+
107
+ - Decision: Explain key tradeoffs, contracts, or architecture choices.
108
+
109
+ # Changed Files
110
+
111
+ - `path/to/file`
112
+
113
+ # Verification
114
+
115
+ - [ ] Command or manual check run.
116
+ - [ ] Skipped check with reason.
117
+
118
+ # Handoff
119
+
120
+ Summarize completion state, skipped checks, residual risks, and useful follow-up context.
@@ -0,0 +1,18 @@
1
+ ---
2
+ status: none
3
+ updated: YYYY-MM-DDTHH:MM:SSZ
4
+ active_feature:
5
+ last_completed:
6
+ ---
7
+
8
+ # Current Feature
9
+
10
+ None.
11
+
12
+ # Next Step
13
+
14
+ - Start a new feature record when beginning the next tracked task.
15
+
16
+ # Blockers
17
+
18
+ - None.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env sh
2
+
3
+ if [ -x "./node_modules/.bin/featflow" ]; then
4
+ ./node_modules/.bin/featflow cleanup --post-merge || true
5
+ elif command -v featflow >/dev/null 2>&1; then
6
+ featflow cleanup --post-merge || true
7
+ fi
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env sh
2
+ set -e
3
+
4
+ if [ -x "./node_modules/.bin/featflow" ]; then
5
+ exec ./node_modules/.bin/featflow policy pre-commit
6
+ elif command -v featflow >/dev/null 2>&1; then
7
+ exec featflow policy pre-commit
8
+ else
9
+ echo "featflow: CLI not found in ./node_modules/.bin or PATH; skipping pre-commit check." >&2
10
+ echo "Install featflow or set FEATFLOW_BOOTSTRAP=1 to silence this notice." >&2
11
+ fi
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env sh
2
+ set -e
3
+
4
+ if [ -x "./node_modules/.bin/featflow" ]; then
5
+ exec ./node_modules/.bin/featflow policy pre-push
6
+ elif command -v featflow >/dev/null 2>&1; then
7
+ exec featflow policy pre-push
8
+ else
9
+ echo "featflow: CLI not found in ./node_modules/.bin or PATH; skipping pre-push check." >&2
10
+ fi
@@ -0,0 +1,23 @@
1
+ # Regression Memory Ledger (managed by featflow)
2
+ #
3
+ # Record durable bug invariants, affected file paths/globs, and regression guard
4
+ # tests here so future changes automatically run impacted guards via:
5
+ # featflow regression impact
6
+ # featflow regression check
7
+ # featflow regression validate --strict
8
+ #
9
+ # Example entry (uncomment and customize when adding your first bug guard):
10
+ # - id: example-regression-id
11
+ # title: Short summary of the bug class that must not recur
12
+ # status: guarded
13
+ # surfaces: [core]
14
+ # symptom: What broke from the user's perspective.
15
+ # root_cause: Why the failure happened.
16
+ # invariant: The behavioral invariant that must always hold.
17
+ # files:
18
+ # - src/example.ts
19
+ # guards:
20
+ # - tests/example.test.ts
21
+ # commands:
22
+ # - npm test
23
+ # owner_notes: Extra context for future refactors.
@@ -0,0 +1,21 @@
1
+ ## Development Workflow (featflow)
2
+
3
+ ### Universal Pre-Implementation Gate
4
+
5
+ - For any write-oriented work (`feat/`, `fix/`, `chore/`, `docs/`, `test/`, `refactor/`, `perf/`, `security/`), complete **read-only discovery** first, present a concrete implementation plan, and **wait for explicit user approval** before creating a worktree, editing tracked files, committing, pushing, or opening PRs.
6
+ - The user can opt out with explicit language (e.g., "implement directly", "no confirmation needed"); record that exception in the feature record or handoff.
7
+ - Purely read-only questions, code reviews, status checks, and plan-only requests do not require approval.
8
+ - If implementation uncovers a materially different root cause, scope, security boundary, or risk profile, pause and request approval for an updated plan before continuing.
9
+
10
+ ### Branch & Worktree Isolation
11
+
12
+ - Do not edit tracked files directly on protected branches (`main`, `dev`, or your configured developer branch) unless explicitly requested.
13
+ - Check workflow status with `featflow status` (in `developer-branch` mode, run `featflow setup <branch>` once per checkout).
14
+ - Create a dedicated worktree per task with `featflow worktree <prefix>/<task-name>` and finish with `featflow finish <branch>`.
15
+
16
+ ### Feature Planning Workflow
17
+
18
+ - For substantial features, cross-module changes, long-running tasks, or multi-phase initiatives, read and follow the `featflow` skill (`.agents/skills/featflow/SKILL.md` or your globally installed skill).
19
+ - Draft complete `Feature Brief` and `Plan Details` (including `Pre-Implementation Approval`) via `featflow new <short-kebab-title>` (or `featflow new <short-kebab-title> --local` when feature records are not tracked in Git) before editing product code, and verify with `featflow plan-check`.
20
+ - Move completed records to `done/` before committing and running `featflow finish <branch>`.
21
+ - Tiny one-off edits do not require a feature record, but still follow the Universal Pre-Implementation Gate and dedicated task worktree flow.