devflow-kit 3.3.0 → 3.4.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/agents/code.md +330 -0
  3. package/{src/assets → dist}/agents/design.md +1 -1
  4. package/{src/assets → dist}/agents/diagnose.md +1 -2
  5. package/dist/agents/git.md +29 -56
  6. package/{src/assets → dist}/agents/knowledge.md +4 -3
  7. package/{src/assets → dist}/agents/research.md +2 -2
  8. package/{src/assets → dist}/agents/review.md +8 -7
  9. package/{src/assets → dist}/agents/scrutinize.md +1 -1
  10. package/dist/agents/skim.md +148 -0
  11. package/{src/assets → dist}/agents/triage.md +1 -1
  12. package/dist/cli/commands/init.js +62 -0
  13. package/dist/cli/commands/learning.js +38 -3
  14. package/dist/cli/commands/uninstall.js +42 -1
  15. package/dist/commands/bug-analysis.md +30 -8
  16. package/dist/commands/code-review.md +141 -60
  17. package/dist/commands/debug.md +14 -12
  18. package/dist/commands/dynamic-build.md +37 -38
  19. package/dist/commands/dynamic-plan.md +30 -18
  20. package/dist/commands/dynamic-profile.md +27 -13
  21. package/dist/commands/dynamic-tickets.md +28 -14
  22. package/dist/commands/explore.md +15 -13
  23. package/dist/commands/implement.md +33 -28
  24. package/dist/commands/plan.md +37 -24
  25. package/dist/commands/release.md +69 -4
  26. package/dist/commands/research.md +33 -11
  27. package/dist/commands/resolve.md +35 -32
  28. package/dist/commands/self-review.md +36 -23
  29. package/dist/core/agent-models.js +43 -0
  30. package/dist/core/assets.js +55 -10
  31. package/dist/core/claude-md-audit.js +190 -0
  32. package/dist/core/feature-switch.js +20 -1
  33. package/dist/core/flags.js +28 -0
  34. package/dist/core/fs-atomic.js +8 -3
  35. package/dist/core/learning-variants.js +213 -0
  36. package/dist/core/manifest.js +62 -0
  37. package/dist/core/mds-variants.js +38 -1
  38. package/dist/core/plugins.js +71 -9
  39. package/{src/assets → dist/learning-off}/agents/code.md +6 -10
  40. package/dist/learning-off/agents/design.md +119 -0
  41. package/dist/learning-off/agents/diagnose.md +210 -0
  42. package/dist/learning-off/agents/knowledge.md +90 -0
  43. package/dist/learning-off/agents/research.md +149 -0
  44. package/dist/learning-off/agents/review.md +228 -0
  45. package/dist/learning-off/agents/scrutinize.md +117 -0
  46. package/{src/assets → dist/learning-off}/agents/skim.md +1 -8
  47. package/dist/learning-off/agents/triage.md +163 -0
  48. package/dist/learning-off/commands/bug-analysis.md +420 -0
  49. package/dist/learning-off/commands/code-review.md +525 -0
  50. package/dist/learning-off/commands/debug.md +294 -0
  51. package/dist/learning-off/commands/dynamic-build.md +1255 -0
  52. package/dist/learning-off/commands/dynamic-plan.md +424 -0
  53. package/dist/learning-off/commands/dynamic-profile.md +214 -0
  54. package/dist/learning-off/commands/dynamic-tickets.md +632 -0
  55. package/dist/learning-off/commands/explore.md +210 -0
  56. package/dist/learning-off/commands/implement.md +808 -0
  57. package/dist/learning-off/commands/plan.md +664 -0
  58. package/dist/learning-off/commands/release.md +310 -0
  59. package/dist/learning-off/commands/research.md +222 -0
  60. package/dist/learning-off/commands/resolve.md +837 -0
  61. package/dist/learning-off/commands/self-review.md +266 -0
  62. package/dist/skills/git/references/tracker/_contract.md +33 -0
  63. package/dist/skills/git/references/tracker/github/fetch-issue.md +2 -0
  64. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +2 -0
  65. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +4 -0
  66. package/dist/skills/git/references/tracker/github/post-wave-report.md +2 -0
  67. package/dist/skills/git/references/tracker/github/setup-task.md +12 -0
  68. package/dist/skills/git/references/tracker/jira/associate-release.md +1 -1
  69. package/dist/skills/git/references/tracker/jira/fetch-issue.md +2 -0
  70. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +2 -0
  71. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +4 -0
  72. package/dist/skills/git/references/tracker/jira/post-wave-report.md +2 -0
  73. package/dist/skills/git/references/tracker/jira/setup-task.md +14 -2
  74. package/dist/skills/git/references/tracker/linear/associate-release.md +1 -1
  75. package/dist/skills/git/references/tracker/linear/fetch-issue.md +2 -0
  76. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +2 -0
  77. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +4 -0
  78. package/dist/skills/git/references/tracker/linear/post-wave-report.md +2 -0
  79. package/dist/skills/git/references/tracker/linear/setup-task.md +14 -2
  80. package/dist/targets/claude-code/installer.js +72 -36
  81. package/dist/targets/claude-code/language-stamp.js +185 -0
  82. package/dist/targets/claude-code/learning-install.js +489 -0
  83. package/package.json +1 -1
  84. package/src/assets/agents/code.mds +339 -0
  85. package/src/assets/agents/design.mds +149 -0
  86. package/src/assets/agents/diagnose.mds +225 -0
  87. package/src/assets/agents/evaluate.md +1 -3
  88. package/src/assets/agents/git.mds +29 -56
  89. package/src/assets/agents/knowledge.mds +125 -0
  90. package/src/assets/agents/research.mds +176 -0
  91. package/src/assets/agents/review.mds +286 -0
  92. package/src/assets/agents/scrutinize.mds +132 -0
  93. package/src/assets/agents/skim.mds +161 -0
  94. package/src/assets/agents/triage.mds +194 -0
  95. package/src/assets/agents/validate.md +8 -6
  96. package/src/assets/commands/_partials/_compliance.mds +5 -4
  97. package/src/assets/commands/_partials/_decisions.mds +31 -0
  98. package/src/assets/commands/_partials/_engine.mds +9 -1
  99. package/src/assets/commands/_partials/_knowledge.mds +25 -12
  100. package/src/assets/commands/_partials/_preamble.mds +33 -9
  101. package/src/assets/commands/_partials/_publication.mds +5 -4
  102. package/src/assets/commands/_partials/_settings.mds +13 -5
  103. package/src/assets/commands/_partials/_wave.mds +8 -0
  104. package/src/assets/commands/bug-analysis.mds +24 -2
  105. package/src/assets/commands/code-review.mds +147 -44
  106. package/src/assets/commands/debug.mds +17 -1
  107. package/src/assets/commands/dynamic-build.mds +33 -2
  108. package/src/assets/commands/dynamic-plan.mds +36 -6
  109. package/src/assets/commands/dynamic-profile.mds +9 -1
  110. package/src/assets/commands/dynamic-tickets.mds +16 -2
  111. package/src/assets/commands/explore.mds +27 -1
  112. package/src/assets/commands/implement.mds +41 -8
  113. package/src/assets/commands/plan.mds +47 -8
  114. package/src/assets/commands/{release.md → release.mds} +27 -24
  115. package/src/assets/commands/research.mds +28 -4
  116. package/src/assets/commands/resolve.mds +43 -2
  117. package/src/assets/commands/self-review.mds +30 -5
  118. package/src/assets/mds/tracker/_contract.mds +72 -0
  119. package/src/assets/mds/tracker/_github.mds +13 -2
  120. package/src/assets/mds/tracker/_jira.mds +17 -5
  121. package/src/assets/mds/tracker/_linear.mds +17 -5
  122. package/src/assets/mds/tracker/_mcp.mds +2 -2
  123. package/src/assets/mds/tracker/_steps.mds +97 -0
  124. package/src/assets/rules/context-economy.md +10 -0
  125. package/src/assets/rules/go.md +1 -0
  126. package/src/assets/rules/java.md +1 -0
  127. package/src/assets/rules/python.md +1 -0
  128. package/src/assets/rules/rust.md +1 -0
  129. package/src/assets/rules/typescript.md +1 -0
  130. package/src/assets/scripts/claude-md-audit.cjs +611 -0
  131. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +1 -2
  132. package/src/assets/scripts/hooks/json-helper.cjs +13 -5
  133. package/src/assets/scripts/hooks/json-parse +34 -10
  134. package/src/assets/scripts/hooks/session-start-context +315 -7
  135. package/src/assets/skills/apply-decisions/SKILL.md +1 -1
  136. package/src/assets/skills/apply-feature-knowledge/SKILL.md +5 -5
  137. package/src/assets/skills/feature-knowledge/SKILL.md +43 -12
  138. package/src/assets/skills/quality-gates/SKILL.md +1 -1
@@ -0,0 +1,310 @@
1
+ ---
2
+ description: Release project using adaptive learned configuration
3
+ ---
4
+
5
+ # Release Command
6
+
7
+ Release the project using adaptive learned configuration. On first run, scans the codebase to detect the release process and stores it in `.release/RELEASE-FLOW.md`. Subsequent releases use the stored config, skipping discovery.
8
+
9
+ ## Usage
10
+
11
+ ```
12
+ /release v1.2.3 (explicit version)
13
+ /release patch (bump type: patch | minor | major)
14
+ /release --dry-run (simulate release, show plan without executing)
15
+ /release (interactive: ask for version)
16
+ ```
17
+
18
+ ## Input
19
+
20
+ What follows `/release` is bound once, here. Every later step names it `COMMAND_INPUT` and never restates it:
21
+
22
+ <command-input>
23
+ $ARGUMENTS
24
+ </command-input>
25
+
26
+ `COMMAND_INPUT` is one of:
27
+ - Explicit version: `v1.2.3` or `1.2.3`
28
+ - Bump type: `patch`, `minor`, `major`
29
+ - Flag: `--dry-run`
30
+ - Empty: interactive mode (will ask for version)
31
+
32
+ Parse from `COMMAND_INPUT`:
33
+ - `VERSION`: explicit version string if present (strip leading `v`)
34
+ - `BUMP_TYPE`: `patch | minor | major` if bump type provided
35
+ - `DRY_RUN`: true if `--dry-run` present, false otherwise
36
+
37
+ ## Phases
38
+
39
+ ### Phase 1: Load Config
40
+
41
+ **Produces:** RELEASE_CONFIG, CONFIG_STATE (`learned` | `fresh`)
42
+
43
+ **Load Companion Skills** — Load via Skill tool: `devflow:git`. If a skill fails to load, continue without it.
44
+
45
+ **Continuation detection**: Check `.release/.progress.json`. If exists, an interrupted release is in progress. Offer user:
46
+ - **Resume**: continue from last checkpoint (skip phases already completed)
47
+ - **Restart**: clean start (delete `.release/.progress.json` and begin from Phase 1)
48
+
49
+ Read `.release/RELEASE-FLOW.md`:
50
+ - If exists → parse as structured config, set CONFIG_STATE = learned, skip to Phase 4
51
+ - If missing → set CONFIG_STATE = fresh, continue to Phase 2
52
+
53
+ ### Phase 1b: Load Context
54
+
55
+ **Produces:** FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES
56
+
57
+ ### Load Feature Knowledge
58
+
59
+ Resolve `{worktree}` as the checkout's toplevel, because feature knowledge bases are committed with the branch (D-PROMPT-ROOT): from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — run
60
+
61
+ ```bash
62
+ git -C "{start}" rev-parse --show-toplevel
63
+ ```
64
+
65
+ and use its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. All paths below are relative to `{worktree}`.
66
+
67
+ **Step 1 — Read the index cache:**
68
+
69
+ Attempt to read `{worktree}/.devflow/features/index.md`. Each line follows the format:
70
+
71
+ ```
72
+ - **{slug}** — {areas} — {Use-when description}
73
+ ```
74
+
75
+ If `index.md` exists and contains at least one entry line, use it for relevance matching.
76
+
77
+ **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
78
+
79
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
80
+
81
+ **Step 3 — Pick relevant KBs:**
82
+
83
+ Match the current task area and description against each index line (or frontmatter `description` + `directories` on fallback). Select entries whose documented area overlaps the current task. This is a relevance judgment — prefer specificity over breadth.
84
+
85
+ **Step 4 — Read each selected KB's Rules:**
86
+
87
+ For each selected entry, `{kb}` is `{worktree}/.devflow/features/{slug}/KNOWLEDGE.md`:
88
+
89
+ 1. List its `##` headings with line numbers through Bash: `command grep -n '^## ' "{kb}"`. This only locates sections; the text of a KB comes from the Read view alone.
90
+ 2. Read the `## Rules` range (its line to the next heading) with the Read tool, using `offset` and `limit`, and choose the one to three bullets most relevant to the current task. The choice is yours, made per KB.
91
+ 3. If the KB has no `## Rules` section, choose one to three entries from its `## Anti-Patterns` or `## Gotchas` range the same way, and label them by that section's name instead of an ID.
92
+
93
+ When a KB contradicts the code you observe, **trust the code** — the code is the freshness mechanism; the KB may lag behind. A missing Rules section, a missing heading list and `(none)` are legitimate states, not errors.
94
+
95
+ **Step 5 — Set FEATURE_KNOWLEDGE and FEATURE_KNOWLEDGE_RULES:**
96
+
97
+ Write one block per selected KB. Paste each bullet verbatim from the Read view, never from a shell view. The path is relative to the checkout root; an agent resolves it under `WORKTREE_PATH` when one is provided.
98
+
99
+ ```
100
+ --- Feature knowledge: {slug} ---
101
+ KB: .devflow/features/{slug}/KNOWLEDGE.md
102
+ Rules:
103
+ - **KB-AP-2** {bullet text, verbatim}
104
+ - **KB-INV-1** {bullet text, verbatim}
105
+ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
106
+ ```
107
+
108
+ A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
109
+
110
+ **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
111
+
112
+ Pass `FEATURE_KNOWLEDGE` only to agents whose contract declares it; the Validate and Git agents this command spawns do not.
113
+
114
+ ### Phase 1c: Resolve the Evidence Policy
115
+
116
+ **Produces:** EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL
117
+
118
+ **Resolve the evidence policy once per run**, from the repository root, before any step reads the values:
119
+
120
+ ```bash
121
+ node "$HOME/.devflow/scripts/resolve-evidence-policy.cjs" 2>/dev/null; echo "exit=$?"
122
+ ```
123
+
124
+ Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `EVIDENCE_POLICY=<required|standard> SOURCE=<file|worktree|default|invalid|error> REF=<branch|none>[ WARN=<remote-unavailable|invalid-file|raised-by-compliance|pr-changes-policy>[,…]] ISSUE_REQUIRED=<true|false> APPLY_CONVENTIONS=<true|false> REQUIRE_NON_AUTHOR_APPROVAL=<true|false>` — these fields, in this order, nothing else, where `<branch>` is a branch name such as `main`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `EVIDENCE_POLICY=required SOURCE=error REF=none ISSUE_REQUIRED=true APPLY_CONVENTIONS=true REQUIRE_NON_AUTHOR_APPROVAL=true` instead.
125
+
126
+ Set `EVIDENCE_POLICY`, `ISSUE_REQUIRED`, `APPLY_CONVENTIONS` and `REQUIRE_NON_AUTHOR_APPROVAL` from the accepted line. Pass agents only the three mechanism inputs, never `EVIDENCE_POLICY`. Report `Evidence policy: {EVIDENCE_POLICY} (source: {SOURCE})`, plus any `WARN` tokens as advisory, once in the final report.
127
+
128
+ Reuse this result for all subsequent phases: it decides whether a real release gathers and traces its evidence (Phases 4–5), passes it to the release notes (step 4), and back-links shipped issues and associates them with the release (steps 4b–4c).
129
+
130
+ ### Phase 2: Detect Release Process (First Run Only)
131
+
132
+ **Produces:** RELEASE_SIGNALS
133
+ **Requires:** CONFIG_STATE = fresh
134
+
135
+ Tiered codebase scan to detect the project's release process:
136
+
137
+ **Tier 1** — Read these if they exist: `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `Dockerfile`, `.github/workflows/*.yml`, `CHANGELOG.md`
138
+
139
+ **Tier 2** — Broaden: monorepo indicators (`lerna.json`, `pnpm-workspace.yaml`, `turbo.json`), release tool configs (`.releaserc`, `.changeset/`, `release-please-config.json`)
140
+
141
+ **Tier 3** — Git history: `git tag -l` for tag format, `git log --oneline -20` for conventions
142
+
143
+ Skip credential files (`.env*`, `*credentials*`, `*secret*`, `*.key`). Max 20 files total.
144
+
145
+ ### Phase 3: Build Config (First Run Only)
146
+
147
+ **Produces:** RELEASE_CONFIG (written to disk)
148
+ **Requires:** RELEASE_SIGNALS
149
+
150
+ Map RELEASE_SIGNALS to `.release/RELEASE-FLOW.md` with sections: Packages, Pre-release Checks, Changelog, Build & Test, Publish, Post-release.
151
+
152
+ **Conventions naming:** Consult `.devflow/conventions.md` (the naming authority written by the Git `learn-conventions` operation) for version/tag/version-PR title conventions. When the branching model uses version PRs, follow the Version PR Titles convention recorded there; compliance defaults when the file is absent. When the repo uses a main+integration branching model, ship via a version PR per the recorded convention. Re-learn by deleting `.devflow/conventions.md` — the next Git `learn-conventions` call rewrites it.
153
+
154
+ Use AskUserQuestion for any gaps that cannot be inferred.
155
+
156
+ Lazy-init `.release/` directory. Create `.release/.gitignore` with `.progress.json` and `.lock/`.
157
+
158
+ ### Phase 4: Pre-release Checks
159
+
160
+ **Produces:** PRE_RELEASE_RESULT, VERSION, RELEASE_EVIDENCE
161
+ **Requires:** RELEASE_CONFIG, EVIDENCE_POLICY
162
+
163
+ **Version determination** (in order):
164
+ 1. Explicit version from args → use directly
165
+ 2. Bump type from args → compute from current version
166
+ 3. `semver-auto` strategy → analyze commits since the last release tag: the tag that `node "$HOME/.devflow/scripts/release-trace.cjs" last-tag`, run from the repository root, prints as `LAST_TAG <tag>` (`LAST_TAG none` ⇒ the initial commit) — never `git describe`, which can return a local marker tag
167
+ 4. None → use AskUserQuestion
168
+
169
+ Pre-release checks:
170
+ - Clean working directory (`git status --porcelain`)
171
+ - Tag does not already exist
172
+ - Custom checks from RELEASE_CONFIG
173
+
174
+ Spawn `Agent(subagent_type="Validate")` for build + test.
175
+
176
+ **Gather release evidence** — under either policy when `DRY_RUN` is true, otherwise only when `EVIDENCE_POLICY` is `required`: spawn `Agent(subagent_type="Git")` with `gather-release-evidence` operation; pass `WORKTREE_PATH` if provided. Keep `COMMIT_LIST`, `SHIPPED_ISSUES`, `### TRACE_MAP` and `### Status:` as RELEASE_EVIDENCE. The Git agent applies its own bounds (≤100 commits, ≤50 issues, 500 traced commits) and degrades gracefully per D4.
177
+
178
+ Unless `DRY_RUN` is true, write `.release/.progress.json` checkpoint, with RELEASE_EVIDENCE when it was gathered — a dry run leaves nothing to resume.
179
+
180
+ `--dry-run`: report what would happen and, when evidence was gathered, the Phase 5 traceability arms, the untraced list and the exempt counts — never asking — then **halt after this phase**.
181
+
182
+ ### Phase 5: Build Release Plan
183
+
184
+ **Produces:** RELEASE_PLAN, TRACEABILITY_EXCEPTIONS
185
+ **Requires:** PRE_RELEASE_RESULT, RELEASE_CONFIG, VERSION, RELEASE_EVIDENCE
186
+
187
+ **Traceability** (only when `EVIDENCE_POLICY` is `required`), before the confirm below. Classify RELEASE_EVIDENCE by its `### Status:` value — `READY`, `PARTIAL`, `TRUNCATED`, `DEGRADED` or `INDETERMINATE` — and by the first `### TRACE_MAP` line, `TRACE from:<ref> scanned:<n> traced:<n> untraced:<n> exempt:<n> unmatched:<n> bound:<ok|hit>`. Let *u* be its `untraced` count, and re-check traced + untraced + exempt = scanned yourself. Every arm that matches applies:
188
+
189
+ 1. **Coverage unknown** — no gather ran, its output is missing or unparseable, there is no `TRACE` line, the sum does not hold, `bound:hit`, status `INDETERMINATE`, or a status that is none of the five.
190
+ 2. **Untraced** — *u* > 0.
191
+ 3. **Partial** — status `PARTIAL`, `TRUNCATED` or `DEGRADED`: warn and continue; this arm never blocks on its own. A tracker with no closing-reference capability always lands here.
192
+ 4. **Clean** — status `READY` and *u* = 0, and no arm above.
193
+
194
+ Arm 1 or 2 ⇒ first show the attestation list, copied from `### TRACE_MAP`: every listed `untraced` line's `<sha12>` and author (≤100), the `…and <n> more` line that closes the untraced list when there is one, and each exempt kind's count with every listed exempt SHA — the commits **Record** attests to, and those the `Exempt` line prints.
195
+
196
+ Arm 1 or 2 ⇒ ask once, via AskUserQuestion: "{u} untraced commits{, coverage unknown: {cause}}. Record self-attested traceability exceptions, or halt?", with exactly two options:
197
+ - **Record** — ask for the reason in the user's own words; if it renders empty, ask once more, then halt. Compose `TRACEABILITY_EXCEPTIONS` below and add it to `.release/.progress.json`.
198
+ - **Halt** — stop now: nothing has been committed, tagged or published.
199
+
200
+ `TRACEABILITY_EXCEPTIONS` is this block, and no commit subject is ever written into it:
201
+
202
+ ```markdown
203
+ ## Traceability exceptions
204
+ - `untraced` <sha12> (<author>) self-attested by @<login> at <utc>: <reason>
205
+ - `coverage` <bound-hit|trace-unavailable|gather-indeterminate|untraced-beyond-list> self-attested by @<login> at <utc>: <reason>
206
+ Exempt (not attested): release <n> · revert <n> · bot <n> — <sha12>, …
207
+ ```
208
+
209
+ - One `untraced` line per listed untraced commit (≤100), its `<sha12>` and `<author>` copied from that `### TRACE_MAP` line. One `coverage` line per arm-1 cause — `bound-hit` for `bound:hit`, `gather-indeterminate` for status `INDETERMINATE` or none of the five, `trace-unavailable` for any other — plus `untraced-beyond-list` when an `…and <n> more` line closes the untraced list. The `Exempt` line counts each exempt kind (its listed lines plus its `…and <n> more`) and names every listed exempt SHA.
210
+ - `@<login>` is `@` followed by the output of `gh api user --jq .login` when that output matches `^[A-Za-z0-9][A-Za-z0-9-]{0,38}$`. On any other output, or a failed call, it is `(login unavailable)` instead, with no `@`.
211
+ - `<utc>` is the output of `date -u +%Y-%m-%dT%H:%M:%SZ`.
212
+ - `<reason>` is the user's own words, made inert: replace every character outside printable ASCII (newlines and tabs included) with a space, remove every `<`, `>`, `` ` ``, `[`, `]`, `\`, `/`, `#`, `@`, `&` and `$`, collapse runs of spaces, trim, keep the first 200 characters, and trim again. A reason that is empty after this is no reason.
213
+
214
+ No ask, but the trace lists an exempt commit ⇒ `TRACEABILITY_EXCEPTIONS` is the heading and the `Exempt` line alone, added to `.release/.progress.json` the same way: an exemption is self-asserted, so it is printed, never hidden.
215
+
216
+ Build ordered execution plan from RELEASE_CONFIG. For monorepo: respect dependency ordering, present package selection to user.
217
+
218
+ Confirm with user via AskUserQuestion before executing:
219
+ "Ready to release v{VERSION}. Plan: {steps summary}. Proceed?"
220
+
221
+ `--dry-run`: should already be halted from Phase 4.
222
+
223
+ ### Phase 6: Execute Release
224
+
225
+ **Produces:** RELEASE_RESULT
226
+ **Requires:** RELEASE_PLAN, VERSION, EVIDENCE_POLICY, RELEASE_EVIDENCE, TRACEABILITY_EXCEPTIONS
227
+
228
+ Sequential execution with progress checkpoints:
229
+ 1. **Version bumps** — write new version to configured files
230
+ 2. **Changelog update** — move Unreleased section to versioned entry (if configured)
231
+ 3. **Release commit** — `chore(release): v{VERSION}` (conventional commit)
232
+ 4. **Tag and GitHub Release** — spawn `Agent(subagent_type="Git")` with `create-release` operation (the agent reads `.devflow/conventions.md` for tag format and release title conventions; compliance defaults when absent); only when `EVIDENCE_POLICY` is `required`, also pass `COMMIT_LIST` and `SHIPPED_ISSUES` from RELEASE_EVIDENCE, and `TRACEABILITY_EXCEPTIONS` when composed (Record, or the no-ask exempt rule), as inputs so the agent includes them in the release notes body.
233
+ 4b. **Back-link shipped issues** (only when `EVIDENCE_POLICY` is `required`) — spawn `Agent(subagent_type="Git")` with `backlink-shipped-issues` operation, passing `VERSION` and `SHIPPED_ISSUES`; posts a marker-deduped comment on each issue (bounds and throttle enforced by the operation); degrade gracefully (D4) on any API failure — never block the release
234
+ 4c. **Associate shipped issues with the release** (only when `EVIDENCE_POLICY` is `required` and `SHIPPED_ISSUES` is non-empty) — spawn `Agent(subagent_type="Git")` with `associate-release` operation, passing `VERSION` and `SHIPPED_ISSUES`; it adds each issue to the release's tracker marker and never replaces another; degrade gracefully (D4) — never block the release
235
+ 5. **Publish** — CI-driven (report) or manual (provide instructions)
236
+ 6. **Post-release steps** — version bump to next dev
237
+
238
+ **Resume:** a checkpoint missing the RELEASE_EVIDENCE its Phase 4 gate called for is gathered again, with Phase 5's traceability step re-run, only before step 4; after step 4, report `evidence lost on resume` and continue — never block.
239
+
240
+ Delete `.release/.progress.json` on success.
241
+
242
+ ### Phase 7: Suggest Improvements
243
+
244
+ **Requires:** RELEASE_RESULT
245
+
246
+ Post-release analysis for improvement opportunities. Present as suggested diffs to RELEASE-FLOW.md. Never auto-apply. Fire-and-forget.
247
+
248
+ ## Worktree Support
249
+
250
+ If the orchestrator receives a `WORKTREE_PATH` context, pass it through to all spawned agents. Each agent's "Worktree Support" section handles path resolution.
251
+
252
+ ## Output
253
+
254
+ On completion:
255
+ - Git tag created: `v{VERSION}` (or configured tag format)
256
+ - GitHub Release created with release notes — `## Traceability exceptions` last, when composed (Record, or the no-ask exempt rule)
257
+ - Changelog updated (if configured)
258
+ - Version files bumped
259
+ - `.release/RELEASE-FLOW.md` created (first run only)
260
+
261
+ ## Architecture
262
+
263
+ ```
264
+ /release (orchestrator)
265
+ │
266
+ ├─ Phase 1: Load Config
267
+ │ └─ Read .release/RELEASE-FLOW.md (learned) or proceed to detect (fresh)
268
+ │
269
+ ├─ Phase 1b: Load Context
270
+ │ └─ Load FEATURE_KNOWLEDGE for the agents that declare it
271
+ │
272
+ ├─ Phase 2: Detect Release Process (first run only)
273
+ │ └─ Tiered scan: package.json, CI workflows, git history
274
+ │
275
+ ├─ Phase 3: Build Config (first run only)
276
+ │ └─ Write .release/RELEASE-FLOW.md
277
+ │
278
+ ├─ Phase 4: Pre-release Checks
279
+ │ ├─ Validate agent (build + test)
280
+ │ ├─ Git agent: gather release evidence + trace map (dry run, or evidence policy required)
281
+ │ └─ Write progress checkpoint
282
+ │
283
+ ├─ Phase 5: Build Release Plan
284
+ │ ├─ Traceability: classify the trace map; record exceptions or halt (evidence policy required)
285
+ │ └─ Confirm with user before executing
286
+ │
287
+ ├─ Phase 6: Execute Release
288
+ │ ├─ Version bumps → Changelog → Commit → Git agent (tag + release) → Back-link → Associate → Publish → Post-release
289
+ │ └─ Progress checkpoints between each step
290
+ │
291
+ └─ Phase 7: Suggest Improvements
292
+ └─ Suggested diffs to RELEASE-FLOW.md (never auto-applied)
293
+ ```
294
+
295
+ ## Principles
296
+
297
+ 1. **Learn once, reuse always** — discovery happens on first run; subsequent releases skip it
298
+ 2. **Config is data, not code** — structured config fields map to pre-defined operations, never raw shell commands
299
+ 3. **Checkpoint-resume** — progress file enables safe resume of interrupted releases
300
+ 4. **User confirms before execution** — release plan is presented for approval before any tags or commits
301
+
302
+ ## Error Handling
303
+
304
+ - Validate agent fails (build/test): halt, report failures, do not proceed
305
+ - User declines release plan: halt gracefully
306
+ - User halts at the traceability question: stop — nothing has been committed, tagged or published
307
+ - Git agent reports DEGRADED while gathering, back-linking or associating: warn and continue — never halt the release
308
+ - Git agent fails (tag/release): halt, report error, suggest manual steps
309
+ - Mid-release failure: progress checkpoint enables resume on next run
310
+ - Version file not found: halt, report which file is missing, ask user to update RELEASE-FLOW.md
@@ -0,0 +1,222 @@
1
+ ---
2
+ description: Research a topic using parallel multi-type Research agents with trust-aware synthesis
3
+ ---
4
+ # Research Command
5
+
6
+ Research a topic by spawning parallel Research agents across multiple research types (codebase, external, market, competitor, technology). Findings are trust-annotated and synthesized into structured output.
7
+
8
+ ## Usage
9
+
10
+ ```
11
+ /research "best caching strategies"
12
+ /research "compare React vs Svelte for our use case"
13
+ /research "what open-source competitors exist"
14
+ /research "how does our auth system work and what are the industry alternatives"
15
+ ```
16
+
17
+ ## Input
18
+
19
+ What follows `/research` is bound once, here. Every later step names it `COMMAND_INPUT` and never restates it:
20
+
21
+ <command-input>
22
+ $ARGUMENTS
23
+ </command-input>
24
+
25
+ `COMMAND_INPUT` is one of:
26
+ - Research question: "best caching strategies"
27
+ - Comparison question: "compare React vs Svelte for our use case"
28
+ - Empty: use conversation context
29
+
30
+ ## Phases
31
+
32
+ ### Phase 1: Load Context (Orchestrator-Local)
33
+
34
+ **Produces:** FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES
35
+
36
+ **Docs root (D-DOCS-ROOT).** Every `.devflow/docs/` path this command reads or writes lives at the checkout's toplevel, never under the directory the session started in. Resolve `{worktree}` from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — by running
37
+
38
+ ```bash
39
+ git -C "{start}" rev-parse --show-toplevel
40
+ ```
41
+
42
+ and using its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. Every docs path below is written `{worktree}/.devflow/docs/…`; a repo-relative docs path handed to an agent always travels with a `WORKTREE_PATH` naming the checkout it is relative to.
43
+
44
+ ### Load Feature Knowledge
45
+
46
+ Resolve `{worktree}` as the checkout's toplevel, because feature knowledge bases are committed with the branch (D-PROMPT-ROOT): from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`) — run
47
+
48
+ ```bash
49
+ git -C "{start}" rev-parse --show-toplevel
50
+ ```
51
+
52
+ and use its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. All paths below are relative to `{worktree}`.
53
+
54
+ **Step 1 — Read the index cache:**
55
+
56
+ Attempt to read `{worktree}/.devflow/features/index.md`. Each line follows the format:
57
+
58
+ ```
59
+ - **{slug}** — {areas} — {Use-when description}
60
+ ```
61
+
62
+ If `index.md` exists and contains at least one entry line, use it for relevance matching.
63
+
64
+ **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
65
+
66
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
67
+
68
+ **Step 3 — Pick relevant KBs:**
69
+
70
+ Match the current task area and description against each index line (or frontmatter `description` + `directories` on fallback). Select entries whose documented area overlaps the current task. This is a relevance judgment — prefer specificity over breadth.
71
+
72
+ **Step 4 — Read each selected KB's Rules:**
73
+
74
+ For each selected entry, `{kb}` is `{worktree}/.devflow/features/{slug}/KNOWLEDGE.md`:
75
+
76
+ 1. List its `##` headings with line numbers through Bash: `command grep -n '^## ' "{kb}"`. This only locates sections; the text of a KB comes from the Read view alone.
77
+ 2. Read the `## Rules` range (its line to the next heading) with the Read tool, using `offset` and `limit`, and choose the one to three bullets most relevant to the current task. The choice is yours, made per KB.
78
+ 3. If the KB has no `## Rules` section, choose one to three entries from its `## Anti-Patterns` or `## Gotchas` range the same way, and label them by that section's name instead of an ID.
79
+
80
+ When a KB contradicts the code you observe, **trust the code** — the code is the freshness mechanism; the KB may lag behind. A missing Rules section, a missing heading list and `(none)` are legitimate states, not errors.
81
+
82
+ **Step 5 — Set FEATURE_KNOWLEDGE and FEATURE_KNOWLEDGE_RULES:**
83
+
84
+ Write one block per selected KB. Paste each bullet verbatim from the Read view, never from a shell view. The path is relative to the checkout root; an agent resolves it under `WORKTREE_PATH` when one is provided.
85
+
86
+ ```
87
+ --- Feature knowledge: {slug} ---
88
+ KB: .devflow/features/{slug}/KNOWLEDGE.md
89
+ Rules:
90
+ - **KB-AP-2** {bullet text, verbatim}
91
+ - **KB-INV-1** {bullet text, verbatim}
92
+ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
93
+ ```
94
+
95
+ A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
96
+
97
+ **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
98
+
99
+ Use `FEATURE_KNOWLEDGE` **locally** for research framing. Pass to each Research agent in Phase 4.
100
+
101
+ ### Phase 2: Requirements
102
+
103
+ **Produces:** RESEARCH_PLAN
104
+
105
+ Analyze the research question to infer research types needed (min 2, max 5). For each type:
106
+ - `RESEARCH_TYPE`: `codebase | external | market | competitor | technology`
107
+ - `RESEARCH_QUESTION`: Focused sub-question for this type
108
+ - `OUTPUT_PATH`: `{worktree}/.devflow/docs/research/{topic-slug}/{YYYY-MM-DD_HHMM}/{type}.md`
109
+
110
+ **Tool availability check**: If WebSearch/WebFetch are unavailable, restrict to `codebase` type only.
111
+
112
+ Generate topic slug from the research question (kebab-case, lowercase, no articles).
113
+
114
+ ### Phase 3: Orient (Conditional)
115
+
116
+ **Produces:** ORIENT_OUTPUT
117
+
118
+ Only if `codebase` type is in RESEARCH_PLAN.
119
+
120
+ Spawn `Agent(subagent_type="Skim")` targeting codebase areas relevant to the research question.
121
+
122
+ Skip and set ORIENT_OUTPUT = "(none)" if `codebase` type is not in RESEARCH_PLAN.
123
+
124
+ ### Phase 4: Parallel Research agents
125
+
126
+ **Produces:** RESEARCH_OUTPUTS
127
+ **Requires:** RESEARCH_PLAN, ORIENT_OUTPUT (optional)
128
+
129
+ Spawn 2-5 `Agent(subagent_type="Research")` agents **in a single message** (parallel execution).
130
+
131
+ Each Research agent receives:
132
+ - `RESEARCH_TYPE`, `RESEARCH_QUESTION`, `OUTPUT_PATH` from RESEARCH_PLAN
133
+ - `FEATURE_KNOWLEDGE`: `{feature_knowledge}` from Phase 1
134
+ - `ORIENT_OUTPUT`: Only for `codebase` type
135
+ - `WORKTREE_PATH`: If in a worktree context
136
+
137
+ Each Research agent writes findings to disk at OUTPUT_PATH.
138
+
139
+ ### Phase 5: Synthesize
140
+
141
+ **Produces:** RESEARCH_SUMMARY
142
+ **Requires:** RESEARCH_OUTPUTS
143
+
144
+ Spawn `Agent(subagent_type="Synthesize")` in `research` mode:
145
+ - Reads Research agent outputs from RESEARCH_OUTPUTS paths
146
+ - Merges findings with trust-aware aggregation
147
+ - Writes `research-summary.md` to the same timestamped directory
148
+
149
+ Output path: `{worktree}/.devflow/docs/research/{topic-slug}/{timestamp}/research-summary.md`
150
+
151
+ ### Phase 6: Present
152
+
153
+ **Requires:** RESEARCH_SUMMARY
154
+
155
+ Present findings to user with:
156
+ - Trust annotations per finding: (trusted) for codebase, (untrusted) for web, (mixed) for technology
157
+ - Explicit conflicts between codebase and web findings
158
+ - Drill-down offer via AskUserQuestion
159
+
160
+ If external research was skipped due to tool unavailability: inform user.
161
+
162
+ ### Phase 7: Feature Knowledge Creation (Conditional)
163
+
164
+ **Requires:** RESEARCH_SUMMARY
165
+ **Produces:** FEATURE_KNOWLEDGE_STATUS (created | skipped)
166
+
167
+ 1. If `codebase` type was not in RESEARCH_PLAN → skip
168
+ 2. Check if matching feature knowledge already exists by reading `{worktree}/.devflow/features/index.md` (or globbing frontmatter if absent). If covered → skip
169
+ 3. Use AskUserQuestion: "No feature knowledge exists for {researched area}. Create one?"
170
+ 4. If user accepts: spawn `Agent(subagent_type="Knowledge")` with researched area context + worktree root, instructing it to write `KNOWLEDGE.md` and update `index.md` directly
171
+ 5. Set FEATURE_KNOWLEDGE_STATUS = created or skipped
172
+
173
+ **Failure handling**: Non-blocking. If Knowledge agent fails, log and continue.
174
+
175
+ ## Worktree Support
176
+
177
+ If the orchestrator receives a `WORKTREE_PATH` context (e.g., from multi-worktree workflows), pass it through to all spawned agents. Each agent's "Worktree Support" section handles path resolution.
178
+
179
+ ## Output
180
+
181
+ Research findings saved to `{worktree}/.devflow/docs/research/{topic-slug}/{YYYY-MM-DD_HHMM}/`:
182
+ - `{type}.md` per research type (codebase.md, external.md, etc.)
183
+ - `research-summary.md` — synthesized findings with trust annotations
184
+
185
+ ## Architecture
186
+
187
+ ```
188
+ /research (orchestrator)
189
+ │
190
+ ├─ Phase 1: Load Context (Orchestrator-Local)
191
+ │
192
+ ├─ Phase 2: Requirements
193
+ │ └─ Infer 2-5 research types from question
194
+ │
195
+ ├─ Phase 3: Orient (conditional — codebase type only)
196
+ │ └─ Skim agent (codebase overview)
197
+ │
198
+ ├─ Phase 4: Parallel Research agents
199
+ │ └─ 2-5 Research agents in single message (all types simultaneously)
200
+ │
201
+ ├─ Phase 5: Synthesize
202
+ │ └─ Synthesize agent merges findings with trust-aware aggregation
203
+ │
204
+ ├─ Phase 6: Present findings with trust annotations and drill-down offer
205
+ │
206
+ └─ Phase 7: Suggest feature knowledge creation (conditional)
207
+ └─ Knowledge agent (if codebase type researched + user accepts)
208
+ ```
209
+
210
+ ## Principles
211
+
212
+ 1. **Parallel perspectives** — Multiple research types converge on truth better than any single perspective
213
+ 2. **Trust transparency** — Every finding is labeled with its trust level (trusted/untrusted/mixed)
214
+ 3. **Conflict surfacing** — Contradictions between codebase and web findings are highlighted, not hidden
215
+ 4. **Evidence over opinion** — All claims require citations (file:line or URL)
216
+
217
+ ## Error Handling
218
+
219
+ - If WebSearch/WebFetch unavailable: restrict to codebase type, inform user
220
+ - If a Research agent fails: continue with remaining outputs, note gap in synthesis
221
+ - If Synthesize agent fails: present individual Research agent outputs directly
222
+ - If feature knowledge creation fails: log failure, report research results normally