devflow-kit 2.4.0 → 3.0.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 (213) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +111 -18
  3. package/dist/agents/git.md +822 -0
  4. package/dist/cli/commands/agents.js +6 -1
  5. package/dist/cli/commands/ambient.js +160 -145
  6. package/dist/cli/commands/attribution-prompts.js +1 -1
  7. package/dist/cli/commands/capture.js +29 -55
  8. package/dist/cli/commands/compliance-prompts.js +1 -1
  9. package/dist/cli/commands/compliance.js +48 -55
  10. package/dist/cli/commands/context.js +17 -32
  11. package/dist/cli/commands/debug.js +65 -26
  12. package/dist/cli/commands/flags.js +3 -3
  13. package/dist/cli/commands/hud.js +34 -10
  14. package/dist/cli/commands/init-seed.js +61 -27
  15. package/dist/cli/commands/init.js +649 -240
  16. package/dist/cli/commands/install-report.js +200 -0
  17. package/dist/cli/commands/knowledge/index.js +2 -2
  18. package/dist/cli/commands/knowledge/toggle.js +35 -37
  19. package/dist/cli/commands/learning.js +79 -57
  20. package/dist/cli/commands/legacy-hooks.js +11 -14
  21. package/dist/cli/commands/memory.js +134 -135
  22. package/dist/cli/commands/prompt-io.js +4 -4
  23. package/dist/cli/commands/proxy.js +23 -41
  24. package/dist/cli/commands/security.js +81 -29
  25. package/dist/cli/commands/skills.js +71 -7
  26. package/dist/cli/commands/tracker-prompts.js +145 -0
  27. package/dist/cli/commands/tracker.js +277 -0
  28. package/dist/cli/commands/uninstall.js +520 -169
  29. package/dist/cli.js +2 -0
  30. package/dist/commands/bug-analysis.md +58 -14
  31. package/dist/commands/code-review.md +110 -32
  32. package/dist/commands/debug.md +55 -11
  33. package/dist/commands/dynamic-build.md +344 -73
  34. package/dist/commands/dynamic-plan.md +77 -27
  35. package/dist/commands/dynamic-profile.md +25 -11
  36. package/dist/commands/dynamic-tickets.md +76 -15
  37. package/dist/commands/explore.md +37 -7
  38. package/dist/commands/implement.md +314 -62
  39. package/dist/commands/plan.md +146 -32
  40. package/dist/commands/release.md +64 -17
  41. package/dist/commands/research.md +34 -8
  42. package/dist/commands/resolve.md +196 -68
  43. package/dist/commands/self-review.md +45 -9
  44. package/dist/core/agent-models.js +55 -12
  45. package/dist/core/assets.js +58 -2
  46. package/dist/core/compliance-compose.js +27 -27
  47. package/dist/core/evidence-policy.js +363 -0
  48. package/dist/core/feature-config.js +200 -65
  49. package/dist/core/feature-switch.js +112 -0
  50. package/dist/core/flags.js +34 -6
  51. package/dist/core/fs-atomic.js +27 -0
  52. package/dist/core/hook-log-dirs.js +104 -0
  53. package/dist/core/learning-tuning-config.js +5 -3
  54. package/dist/core/ledger-root.js +102 -0
  55. package/dist/core/manifest.js +38 -10
  56. package/dist/core/mds-variants.js +798 -0
  57. package/dist/core/migrations.js +49 -23
  58. package/dist/core/model-discovery.js +12 -1
  59. package/dist/core/plugins.js +361 -12
  60. package/dist/core/project-paths.js +1 -18
  61. package/dist/core/proxy-log.js +8 -6
  62. package/dist/core/proxy-state.js +11 -8
  63. package/dist/core/reference-sweep.js +136 -0
  64. package/dist/core/same-location.js +25 -0
  65. package/dist/core/tracker.js +494 -0
  66. package/dist/hud/components/config-counts.js +15 -4
  67. package/dist/hud/components/learning-counts.js +14 -0
  68. package/dist/hud/config.js +2 -1
  69. package/dist/hud/cost-history.js +2 -4
  70. package/dist/hud/git.js +52 -7
  71. package/dist/hud/index.js +7 -9
  72. package/dist/skills/git/references/decision-markers.md +19 -0
  73. package/dist/skills/git/references/learn-conventions.md +56 -0
  74. package/dist/skills/git/references/pr/check-ci-status.md +14 -0
  75. package/dist/skills/git/references/pr/check-merge-readiness.md +28 -0
  76. package/dist/skills/git/references/pr/ensure-pr-ready.md +24 -0
  77. package/dist/skills/git/references/pr/fetch-review-threads.md +22 -0
  78. package/dist/skills/git/references/pr/post-resolution-summary.md +40 -0
  79. package/dist/skills/git/references/pr/post-review-summary.md +42 -0
  80. package/dist/skills/git/references/pr/resolve-review-threads.md +35 -0
  81. package/dist/skills/git/references/pr/update-pr-evidence.md +14 -0
  82. package/dist/skills/git/references/pr/validate-branch.md +18 -0
  83. package/dist/skills/git/references/publication-gate.md +13 -0
  84. package/dist/skills/git/references/tracker/_mcp.md +153 -0
  85. package/dist/skills/git/references/tracker/github/associate-release.md +18 -0
  86. package/dist/skills/git/references/tracker/github/backlink-shipped-issues.md +40 -0
  87. package/dist/skills/git/references/tracker/github/create-release.md +11 -0
  88. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +16 -0
  89. package/dist/skills/git/references/tracker/github/ensure-traceable-issue.md +69 -0
  90. package/dist/skills/git/references/tracker/github/fetch-issue.md +32 -0
  91. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +17 -0
  92. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +19 -0
  93. package/dist/skills/git/references/tracker/github/manage-debt.md +101 -0
  94. package/dist/skills/git/references/tracker/github/post-wave-report.md +28 -0
  95. package/dist/skills/git/references/tracker/github/setup-task.md +26 -0
  96. package/dist/skills/git/references/tracker/jira/associate-release.md +18 -0
  97. package/dist/skills/git/references/tracker/jira/backlink-shipped-issues.md +49 -0
  98. package/dist/skills/git/references/tracker/jira/create-release.md +17 -0
  99. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +22 -0
  100. package/dist/skills/git/references/tracker/jira/ensure-traceable-issue.md +53 -0
  101. package/dist/skills/git/references/tracker/jira/fetch-issue.md +14 -0
  102. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +15 -0
  103. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +18 -0
  104. package/dist/skills/git/references/tracker/jira/manage-debt.md +37 -0
  105. package/dist/skills/git/references/tracker/jira/post-wave-report.md +33 -0
  106. package/dist/skills/git/references/tracker/jira/setup-task.md +31 -0
  107. package/dist/skills/git/references/tracker/linear/associate-release.md +18 -0
  108. package/dist/skills/git/references/tracker/linear/backlink-shipped-issues.md +53 -0
  109. package/dist/skills/git/references/tracker/linear/create-release.md +17 -0
  110. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +22 -0
  111. package/dist/skills/git/references/tracker/linear/ensure-traceable-issue.md +53 -0
  112. package/dist/skills/git/references/tracker/linear/fetch-issue.md +14 -0
  113. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +15 -0
  114. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +18 -0
  115. package/dist/skills/git/references/tracker/linear/manage-debt.md +37 -0
  116. package/dist/skills/git/references/tracker/linear/post-wave-report.md +33 -0
  117. package/dist/skills/git/references/tracker/linear/setup-task.md +32 -0
  118. package/dist/skills/git/references/trust-rule.md +7 -0
  119. package/dist/targets/claude-code/claude-paths.js +59 -57
  120. package/dist/targets/claude-code/compliance-install.js +49 -65
  121. package/dist/targets/claude-code/hooks.js +108 -3
  122. package/dist/targets/claude-code/installer.js +1187 -32
  123. package/dist/targets/claude-code/legacy.js +5 -0
  124. package/dist/targets/claude-code/post-install.js +366 -151
  125. package/dist/targets/claude-code/tracker-install.js +134 -0
  126. package/package.json +8 -6
  127. package/src/assets/agents/code.md +45 -6
  128. package/src/assets/agents/design.md +2 -1
  129. package/src/assets/agents/git.mds +825 -0
  130. package/src/assets/agents/knowledge.md +3 -3
  131. package/src/assets/agents/learning.md +11 -0
  132. package/src/assets/agents/review.md +3 -1
  133. package/src/assets/agents/synthesize.md +1 -1
  134. package/src/assets/agents/test.md +16 -5
  135. package/src/assets/agents/tracker.md +474 -0
  136. package/src/assets/agents/validate.md +7 -5
  137. package/src/assets/commands/_partials/_compliance.mds +19 -1
  138. package/src/assets/commands/_partials/_decisions.mds +15 -3
  139. package/src/assets/commands/_partials/_docs_root.mds +35 -0
  140. package/src/assets/commands/_partials/_engine.mds +13 -11
  141. package/src/assets/commands/_partials/_evidence_policy.mds +30 -0
  142. package/src/assets/commands/_partials/_factory.mds +1 -1
  143. package/src/assets/commands/_partials/_knowledge.mds +27 -9
  144. package/src/assets/commands/_partials/_plan_contract.mds +22 -7
  145. package/src/assets/commands/_partials/_preamble.mds +2 -2
  146. package/src/assets/commands/_partials/_publication.mds +8 -2
  147. package/src/assets/commands/_partials/_settings.mds +28 -0
  148. package/src/assets/commands/_partials/_ticket_template.mds +3 -2
  149. package/src/assets/commands/_partials/_tracker.mds +18 -0
  150. package/src/assets/commands/_partials/_wave.mds +16 -10
  151. package/src/assets/commands/bug-analysis.mds +31 -19
  152. package/src/assets/commands/code-review.mds +67 -41
  153. package/src/assets/commands/debug.mds +13 -7
  154. package/src/assets/commands/dynamic-build.mds +274 -66
  155. package/src/assets/commands/dynamic-plan.mds +50 -23
  156. package/src/assets/commands/dynamic-profile.mds +24 -11
  157. package/src/assets/commands/dynamic-tickets.mds +63 -16
  158. package/src/assets/commands/explore.mds +4 -5
  159. package/src/assets/commands/implement.mds +234 -67
  160. package/src/assets/commands/plan.mds +91 -33
  161. package/src/assets/commands/release.md +64 -17
  162. package/src/assets/commands/research.mds +11 -9
  163. package/src/assets/commands/resolve.mds +150 -78
  164. package/src/assets/commands/self-review.mds +24 -25
  165. package/src/assets/mds/git/_pr.mds +331 -0
  166. package/src/assets/mds/git/_references.mds +135 -0
  167. package/src/assets/mds/tracker/_common.mds +156 -0
  168. package/src/assets/mds/tracker/_github.mds +472 -0
  169. package/src/assets/mds/tracker/_jira.mds +407 -0
  170. package/src/assets/mds/tracker/_linear.mds +449 -0
  171. package/src/assets/mds/tracker/_mcp.mds +305 -0
  172. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +5 -8
  173. package/src/assets/scripts/hooks/background-memory-update +40 -19
  174. package/src/assets/scripts/hooks/capture-prompt +18 -8
  175. package/src/assets/scripts/hooks/capture-question +18 -8
  176. package/src/assets/scripts/hooks/capture-turn +27 -13
  177. package/src/assets/scripts/hooks/debug-trace +11 -6
  178. package/src/assets/scripts/hooks/ensure-devflow-init +33 -6
  179. package/src/assets/scripts/hooks/ensure-proxy +9 -8
  180. package/src/assets/scripts/hooks/ensure-root-gitignore +236 -60
  181. package/src/assets/scripts/hooks/git-marker +48 -0
  182. package/src/assets/scripts/hooks/hook-log-init +3 -1
  183. package/src/assets/scripts/hooks/json-helper.cjs +228 -5
  184. package/src/assets/scripts/hooks/lib/project-paths.cjs +1 -20
  185. package/src/assets/scripts/hooks/log-paths +80 -0
  186. package/src/assets/scripts/hooks/memory-worker +22 -13
  187. package/src/assets/scripts/hooks/pre-compact-memory +44 -15
  188. package/src/assets/scripts/hooks/preamble +1 -4
  189. package/src/assets/scripts/hooks/queue-append +146 -28
  190. package/src/assets/scripts/hooks/resolve-project-root +101 -7
  191. package/src/assets/scripts/hooks/session-start-context +534 -20
  192. package/src/assets/scripts/hooks/session-start-memory +38 -15
  193. package/src/assets/scripts/lib/project-config.cjs +633 -0
  194. package/src/assets/scripts/pr-evidence.cjs +1961 -0
  195. package/src/assets/scripts/redact-secrets.cjs +490 -62
  196. package/src/assets/scripts/release-trace.cjs +1143 -0
  197. package/src/assets/scripts/resolve-evidence-policy.cjs +1145 -0
  198. package/src/assets/scripts/resolve-settings.cjs +1054 -0
  199. package/src/assets/scripts/verify-evidence.cjs +1822 -0
  200. package/src/assets/skills/compliance/SKILL.md +4 -2
  201. package/src/assets/skills/docs-framework/SKILL.md +11 -10
  202. package/src/assets/skills/docs-framework/references/patterns.md +10 -17
  203. package/src/assets/skills/gap-analysis/SKILL.md +2 -2
  204. package/src/assets/skills/git/SKILL.md +8 -78
  205. package/src/assets/skills/git/references/github-api.md +179 -141
  206. package/src/assets/skills/git/references/patterns.md +11 -6
  207. package/src/assets/skills/review-methodology/SKILL.md +1 -1
  208. package/src/assets/skills/review-methodology/references/patterns.md +6 -61
  209. package/src/assets/skills/review-methodology/references/violations.md +14 -22
  210. package/src/assets/skills/worktree-support/SKILL.md +1 -1
  211. package/src/assets/skills/worktree-support/references/roots.md +29 -0
  212. package/src/targets/claude-code/templates/managed-settings.json +25 -9
  213. package/src/assets/agents/git.md +0 -938
@@ -10,10 +10,10 @@
10
10
  */
11
11
  import { promises as fs } from 'fs';
12
12
  import * as path from 'path';
13
- import * as os from 'os';
14
13
  import { writeFileAtomicExclusive } from './fs-atomic.js';
15
14
  import { getMemoryDir } from './project-paths.js';
16
15
  import { LEGACY_AGENT_KEYS, canonicaliseAgentKeys, parseAgentMappingEnvelope } from './agent-models.js';
16
+ import { migrateLegacyTrackerConventions } from './tracker.js';
17
17
  /**
18
18
  * D31: Registry pattern over scattered `if (!applied.includes(...))` conditionals.
19
19
  *
@@ -94,23 +94,48 @@ export const MIGRATIONS = [
94
94
  return { infos, warnings };
95
95
  },
96
96
  },
97
+ {
98
+ id: 'tracker-conventions-per-provider-v1',
99
+ description: 'Move ~/.devflow/tracker.md to ~/.devflow/tracker/{provider}.md, the provider its frontmatter names',
100
+ scope: 'global',
101
+ // D-TRACKER-PER-PROVIDER-CONVENTIONS: conventions became per provider, so the
102
+ // single machine-wide file moves to the file of the provider it was learned
103
+ // for. The move and every refusal to move are migrateLegacyTrackerConventions'
104
+ // (src/core/tracker.ts); this entry maps its outcome onto the runner's
105
+ // contract. A file it leaves in place is REPORTED, once, and the migration is
106
+ // marked applied — the file is user content and nothing a re-run could do
107
+ // differently. An I/O failure THROWS instead: a throwing migration is not
108
+ // marked applied, so the runner retries it on the next `devflow init` rather
109
+ // than recording a move that never happened (the retry-forever path the
110
+ // KNOWN ISSUE above describes is bounded here by what can fail — a rename and
111
+ // an rm inside ~/.devflow).
112
+ async run(ctx) {
113
+ const outcome = await migrateLegacyTrackerConventions(ctx.devflowDir);
114
+ switch (outcome.kind) {
115
+ case 'none':
116
+ return { infos: [], warnings: [] };
117
+ case 'moved':
118
+ return { infos: [`Moved the ${outcome.provider} tracker conventions to ${outcome.to}`], warnings: [] };
119
+ case 'kept':
120
+ return { infos: [], warnings: [`tracker-conventions-per-provider-v1: ${outcome.reason}`] };
121
+ case 'failed':
122
+ throw new Error(outcome.error);
123
+ default: {
124
+ const _exhaustive = outcome;
125
+ return _exhaustive;
126
+ }
127
+ }
128
+ },
129
+ },
97
130
  ];
98
131
  const MIGRATIONS_FILE = 'migrations.json';
99
132
  /**
100
- * D30: State lives at `~/.devflow/migrations.json` (scope-independent) rather
101
- * than the install manifest because:
102
- *
103
- * - The install manifest is scope-specific: user-scope manifests live at
104
- * `~/.devflow/manifest.json` while local-scope manifests live at
105
- * `.devflow/manifest.json` inside the repo. A migration that runs on user-scope
106
- * init wouldn't be recorded in a local-scope manifest, so the migration would
107
- * re-run on the next local-scope init.
108
- * - Migration state is machine-wide: once a global migration runs on a machine it
109
- * should never re-run regardless of which project or scope triggered devflow init.
110
- * - `~/.devflow/migrations.json` is always writable (home-dir location), whereas
111
- * local-scope devflowDir may be inside a read-only checkout.
133
+ * D30: State lives at `~/.devflow/migrations.json` rather than in the install
134
+ * manifest because migration state is machine-wide: once a global migration runs
135
+ * on a machine it should never re-run regardless of which project triggered
136
+ * devflow init.
112
137
  *
113
- * @param devflowDir - absolute path to `~/.devflow` (always the home-dir location)
138
+ * @param devflowDir - absolute path to the resolved machine root (`~/.devflow`)
114
139
  */
115
140
  export async function readAppliedMigrations(devflowDir) {
116
141
  const filePath = path.join(devflowDir, MIGRATIONS_FILE);
@@ -227,7 +252,7 @@ async function runGlobalMigration(migration, ctx) {
227
252
  * additional projects) can retry the failed projects.
228
253
  *
229
254
  * D37: runPerProjectMigration is unreachable in production — MIGRATIONS holds
230
- * only a global migration (`canonicalise-agent-keys-v1`). The vacuous-truth
255
+ * only global migrations. The vacuous-truth
231
256
  * analysis is preserved for correctness: if a per-project migration is ever
232
257
  * added, an empty discoveredProjects list marks it applied (empty-discovery-marks-applied
233
258
  * intended); the applied-set write is skipped only when newlyApplied is empty,
@@ -267,19 +292,20 @@ async function runPerProjectMigration(migration, ctx, discoveredProjects) {
267
292
  * Run all unapplied migrations from MIGRATIONS.
268
293
  *
269
294
  * D32: Always-run-unapplied semantics (no fresh-vs-upgrade branch).
270
- * MIGRATIONS currently holds one global migration (`canonicalise-agent-keys-v1`);
271
- * on a fresh machine the loop executes once and writes migrations.json. On
272
- * subsequent runs the ID is already in the applied set and the loop is a no-op.
295
+ * MIGRATIONS currently holds only global migrations; on a fresh machine each
296
+ * executes once and the applied set is written to migrations.json. On subsequent
297
+ * runs every ID is already in the applied set and the loop is a no-op.
273
298
  *
274
- * @param ctx - devflowDir (memoryDir and projectRoot filled per-project)
299
+ * @param ctx - devflowDir, the resolved machine root (`~/.devflow`) that also holds
300
+ * migrations.json; memoryDir and projectRoot are filled per-project
275
301
  * @param discoveredProjects - absolute paths to discovered Claude-enabled project roots
276
302
  * @param registryOverride - override MIGRATIONS for testing (defaults to module-level MIGRATIONS)
277
303
  */
278
304
  export async function runMigrations(ctx, discoveredProjects, registryOverride) {
279
305
  const registry = registryOverride ?? MIGRATIONS;
280
- // Always read from home-dir devflow location so state is machine-wide
281
- const homeDevflowDir = path.join(os.homedir(), '.devflow');
282
- const appliedArray = await readAppliedMigrations(homeDevflowDir);
306
+ // D-ONE-HOME: state lives in the caller's resolved machine root, never a
307
+ // second, independently derived home path (D30: machine-wide state).
308
+ const appliedArray = await readAppliedMigrations(ctx.devflowDir);
283
309
  // Convert to Set once for O(1) lookups throughout the loop (issue #9)
284
310
  const applied = new Set(appliedArray);
285
311
  const newlyApplied = [];
@@ -323,7 +349,7 @@ export async function runMigrations(ctx, discoveredProjects, registryOverride) {
323
349
  }
324
350
  // Write state once at end, accumulating all newly applied IDs (issue #5 — O(N²) → O(1))
325
351
  if (newlyApplied.length > 0) {
326
- await writeAppliedMigrations(homeDevflowDir, [...appliedArray, ...newlyApplied]);
352
+ await writeAppliedMigrations(ctx.devflowDir, [...appliedArray, ...newlyApplied]);
327
353
  }
328
354
  return { newlyApplied, failures, infos, warnings };
329
355
  }
@@ -552,7 +552,18 @@ async function _discoverInternal(cacheDir, logPath, deps) {
552
552
  // completes during the spawn's SPAWN_TIMEOUT_MS window).
553
553
  const staleRawP = findStaleFallback(cacheDir, currentKey);
554
554
  // --- Live spawn ---
555
- const env = { ...scrubChildEnv(), NO_COLOR: '1' };
555
+ // @D-EFR-6 Discovery reads the runtime's built-in registry, never a user config.
556
+ // Since 0.5.0 every implicit config load merges the runtime's user-level file
557
+ // ($XDG_CONFIG_HOME/subswitch/config.json, else ~/.config/subswitch/config.json)
558
+ // under the cwd project file. Devflow's relay never sees that file — it is always
559
+ // started with an explicit SUBSWITCH_CONFIG, which bypasses the merge — so a user
560
+ // alias leaking into discovery would be offered in the picker yet never routed,
561
+ // and a malformed file would fail every live discovery. The cache key also
562
+ // assumes the catalog depends on the runtime version alone. Pointing
563
+ // XDG_CONFIG_HOME at devflow's own cache directory, which never holds a
564
+ // `subswitch/config.json`, makes the lookup a clean ENOENT. SUBSWITCH_CONFIG
565
+ // stays unset (T2): an explicit path that is missing is a hard error.
566
+ const env = { ...scrubChildEnv(), NO_COLOR: '1', XDG_CONFIG_HOME: cacheDir };
556
567
  const spawnFn = deps?.spawnAndCollect ?? buildRealSpawnAndCollect(logPath);
557
568
  let spawnResult;
558
569
  try {