devflow-kit 3.0.0 → 3.1.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 (134) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/agents/git.md +2 -2
  3. package/dist/cli/agents-view/index.js +1 -1
  4. package/dist/cli/agents-view/render.js +2 -2
  5. package/dist/cli/agents-view/state.js +2 -2
  6. package/dist/cli/agents-view/terminal.js +5 -5
  7. package/dist/cli/commands/agents.js +7 -6
  8. package/dist/cli/commands/ambient.js +1 -1
  9. package/dist/cli/commands/attribution-prompts.js +8 -8
  10. package/dist/cli/commands/capture.js +1 -1
  11. package/dist/cli/commands/compliance-prompts.js +8 -8
  12. package/dist/cli/commands/compliance.js +8 -7
  13. package/dist/cli/commands/flags.js +33 -31
  14. package/dist/cli/commands/hud.js +1 -1
  15. package/dist/cli/commands/init-seed.js +9 -9
  16. package/dist/cli/commands/init.js +34 -32
  17. package/dist/cli/commands/install-report.js +10 -10
  18. package/dist/cli/commands/learning.js +267 -129
  19. package/dist/cli/commands/memory.js +1 -1
  20. package/dist/cli/commands/proxy.js +23 -23
  21. package/dist/cli/commands/rules.js +6 -5
  22. package/dist/cli/commands/tracker-prompts.js +6 -6
  23. package/dist/cli/commands/tracker.js +9 -9
  24. package/dist/cli/commands/uninstall.js +20 -20
  25. package/dist/cli/flags-view/render.js +5 -5
  26. package/dist/cli/flags-view/state.js +9 -9
  27. package/dist/cli/flags-view/terminal.js +4 -4
  28. package/dist/cli/tui/cells.js +1 -1
  29. package/dist/cli/tui/terminal.js +6 -6
  30. package/dist/commands/dynamic-build.md +18 -4
  31. package/dist/commands/dynamic-plan.md +19 -5
  32. package/dist/commands/dynamic-profile.md +17 -3
  33. package/dist/commands/dynamic-tickets.md +18 -4
  34. package/dist/commands/release.md +15 -1
  35. package/dist/commands/research.md +1 -1
  36. package/dist/commands/resolve.md +8 -9
  37. package/dist/core/agent-frontmatter.js +3 -3
  38. package/dist/core/agent-models.js +6 -6
  39. package/dist/core/agent-state.js +2 -2
  40. package/dist/core/ansi.js +2 -2
  41. package/dist/core/cache.js +7 -8
  42. package/dist/core/codex-auth-inspect.js +4 -4
  43. package/dist/core/compliance-compose.js +3 -3
  44. package/dist/core/compliance.js +3 -4
  45. package/dist/core/evidence-policy.js +14 -13
  46. package/dist/core/external-models.js +1 -1
  47. package/dist/core/feature-config.js +3 -3
  48. package/dist/core/feature-switch.js +3 -3
  49. package/dist/core/flags.js +25 -25
  50. package/dist/core/fs-atomic.js +6 -7
  51. package/dist/core/learning-queue-cleanup.js +16 -80
  52. package/dist/core/learning-store.js +61 -0
  53. package/dist/core/manifest.js +5 -5
  54. package/dist/core/mds-variants.js +13 -13
  55. package/dist/core/model-discovery.js +8 -8
  56. package/dist/core/observations.js +17 -101
  57. package/dist/core/orphan-sweep.js +4 -4
  58. package/dist/core/plugins.js +4 -5
  59. package/dist/core/project-paths.js +9 -13
  60. package/dist/core/proxy-log.js +8 -8
  61. package/dist/core/proxy-state.js +3 -3
  62. package/dist/core/reference-sweep.js +6 -6
  63. package/dist/core/teammate-mode-cleanup.js +1 -1
  64. package/dist/core/tracker.js +14 -14
  65. package/dist/hud/colors.js +2 -2
  66. package/dist/hud/components/learning-counts.js +2 -16
  67. package/dist/hud/components/version-badge.js +1 -1
  68. package/dist/skills/git/references/pr/resolve-review-threads.md +2 -2
  69. package/dist/targets/claude-code/compliance-install.js +17 -15
  70. package/dist/targets/claude-code/hooks.js +2 -2
  71. package/dist/targets/claude-code/installer.js +24 -24
  72. package/dist/targets/claude-code/legacy.js +1 -1
  73. package/dist/targets/claude-code/post-install.js +25 -11
  74. package/dist/targets/claude-code/tracker-install.js +2 -2
  75. package/package.json +1 -1
  76. package/src/assets/agents/code.md +1 -4
  77. package/src/assets/agents/design.md +2 -2
  78. package/src/assets/agents/diagnose.md +1 -1
  79. package/src/assets/agents/git.mds +2 -2
  80. package/src/assets/agents/knowledge.md +3 -3
  81. package/src/assets/agents/learning.md +281 -196
  82. package/src/assets/agents/research.md +1 -1
  83. package/src/assets/agents/review.md +3 -3
  84. package/src/assets/agents/scrutinize.md +1 -1
  85. package/src/assets/agents/skim.md +1 -1
  86. package/src/assets/agents/triage.md +9 -9
  87. package/src/assets/commands/_partials/_decisions.mds +8 -3
  88. package/src/assets/commands/_partials/_docs_root.mds +3 -3
  89. package/src/assets/commands/_partials/_engine.mds +1 -1
  90. package/src/assets/commands/_partials/_preamble.mds +6 -2
  91. package/src/assets/commands/_partials/_settings.mds +2 -2
  92. package/src/assets/commands/dynamic-build.mds +1 -1
  93. package/src/assets/commands/dynamic-plan.mds +3 -3
  94. package/src/assets/commands/dynamic-profile.mds +1 -1
  95. package/src/assets/commands/dynamic-tickets.mds +2 -2
  96. package/src/assets/commands/release.md +15 -1
  97. package/src/assets/commands/research.mds +1 -1
  98. package/src/assets/commands/resolve.mds +8 -9
  99. package/src/assets/mds/git/_pr.mds +3 -3
  100. package/src/assets/mds/tracker/_common.mds +1 -1
  101. package/src/assets/mds/tracker/_github.mds +1 -1
  102. package/src/assets/mds/tracker/_jira.mds +1 -1
  103. package/src/assets/mds/tracker/_linear.mds +1 -1
  104. package/src/assets/mds/tracker/_mcp.mds +6 -5
  105. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +1 -0
  106. package/src/assets/scripts/hooks/background-memory-update +28 -22
  107. package/src/assets/scripts/hooks/capture-turn +1 -17
  108. package/src/assets/scripts/hooks/ensure-devflow-init +1 -1
  109. package/src/assets/scripts/hooks/ensure-proxy +5 -6
  110. package/src/assets/scripts/hooks/ensure-root-gitignore +1 -1
  111. package/src/assets/scripts/hooks/is-hex-sha +1 -1
  112. package/src/assets/scripts/hooks/json-helper.cjs +348 -814
  113. package/src/assets/scripts/hooks/json-parse +3 -2
  114. package/src/assets/scripts/hooks/lib/decisions-format.cjs +205 -156
  115. package/src/assets/scripts/hooks/lib/learning-store.cjs +3102 -0
  116. package/src/assets/scripts/hooks/lib/mkdir-lock.cjs +7 -5
  117. package/src/assets/scripts/hooks/lib/project-paths.cjs +13 -19
  118. package/src/assets/scripts/hooks/lib/render-decisions.cjs +253 -226
  119. package/src/assets/scripts/hooks/queue-append +2 -2
  120. package/src/assets/scripts/hooks/resolve-project-root +3 -4
  121. package/src/assets/scripts/hooks/session-start-context +40 -18
  122. package/src/assets/scripts/lib/project-config.cjs +2 -2
  123. package/src/assets/scripts/pr-evidence.cjs +3 -3
  124. package/src/assets/scripts/redact-secrets.cjs +20 -20
  125. package/src/assets/scripts/release-trace.cjs +1 -1
  126. package/src/assets/scripts/resolve-evidence-policy.cjs +3 -3
  127. package/src/assets/scripts/resolve-settings.cjs +3 -3
  128. package/src/assets/scripts/verify-evidence.cjs +2 -2
  129. package/src/assets/skills/apply-decisions/SKILL.md +37 -17
  130. package/src/assets/skills/docs-framework/SKILL.md +2 -2
  131. package/src/assets/skills/feature-knowledge/SKILL.md +6 -5
  132. package/src/targets/claude-code/templates/managed-settings.json +3 -3
  133. package/dist/core/observation-io.js +0 -50
  134. package/src/assets/scripts/hooks/decisions-usage-scan.cjs +0 -131
@@ -1,7 +1,9 @@
1
1
  // src/assets/scripts/hooks/lib/mkdir-lock.cjs
2
2
  //
3
- // Shared mkdir-based locking helpers used by json-helper.cjs, render-decisions.cjs,
4
- // and any other CJS hook that needs exclusive access to a shared resource.
3
+ // Shared mkdir-based locking helpers used by learning-store.cjs — whose
4
+ // withDecisionsLock every learning op that writes and the render CLI take, and
5
+ // whose queue claim also takes the queue's own lock — and any other CJS hook that
6
+ // needs exclusive access to a shared resource.
5
7
  //
6
8
  // DESIGN: mkdir is atomic on POSIX — the kernel guarantees that only one caller
7
9
  // succeeds on a given path. On EEXIST we check staleness (mtime > staleMs) and
@@ -44,12 +46,12 @@ function _idleSleep50() {
44
46
  /**
45
47
  * Acquire a mkdir-based lock. Returns true on success, false on timeout.
46
48
  *
47
- * Stale-break window (applies ADR-017): a lock directory older than `staleMs`
49
+ * Stale-break window: a lock directory older than `staleMs`
48
50
  * (default 60 s) is forcibly removed and the caller retries. This protects against
49
51
  * crashed holders but creates a narrow TOCTOU window: if a holder is actively
50
52
  * working and takes longer than 60 s, its lock can be stolen — leading to concurrent
51
- * ledger writes. Current callers (assign-anchor, retire-anchor, refresh-anchor, render CLI) perform
52
- * only synchronous file I/O + JSON parse and complete well under 60 s in practice,
53
+ * ledger writes. Current callers (the learning ops through withDecisionsLock, and the
54
+ * render CLI) perform only synchronous file I/O + JSON parse and complete well under 60 s in practice,
53
55
  * so this window is not reachable under normal operation. For long-running callers
54
56
  * call refreshLock(lockDir) periodically to reset the mtime and push the deadline
55
57
  * out by another staleMs interval.
@@ -57,11 +57,16 @@ function getLearningPendingTurnsPath(projectRoot) {
57
57
  return path.join(projectRoot, '.devflow', 'learning', '.pending-turns.jsonl');
58
58
  }
59
59
 
60
- /** .devflow/learning/.pending-turns.processing — atomic claim held by the Learning agent while processing */
60
+ /** .devflow/learning/.pending-turns.processing — the claimed batch a Learning run holds while it processes it */
61
61
  function getLearningPendingTurnsProcessingPath(projectRoot) {
62
62
  return path.join(projectRoot, '.devflow', 'learning', '.pending-turns.processing');
63
63
  }
64
64
 
65
+ /** .devflow/learning/.pending-turns.owner — the token of the run that holds the claim (learning-store.cjs) */
66
+ function getLearningClaimOwnerPath(projectRoot) {
67
+ return path.join(projectRoot, '.devflow', 'learning', '.pending-turns.owner');
68
+ }
69
+
65
70
  // ---------------------------------------------------------------------------
66
71
  // Learning content files
67
72
  // ---------------------------------------------------------------------------
@@ -96,31 +101,21 @@ function getDecisionsArchivePath(projectRoot) {
96
101
  return path.join(projectRoot, '.devflow', 'learning', 'decisions-log.archive.jsonl');
97
102
  }
98
103
 
104
+ /** .devflow/learning/decisions-history.jsonl — prior content versions of rewritten entries (learning-store.cjs) */
105
+ function getDecisionsHistoryPath(projectRoot) {
106
+ return path.join(projectRoot, '.devflow', 'learning', 'decisions-history.jsonl');
107
+ }
108
+
99
109
  /** .devflow/learning/.decisions.lock — mkdir-based lock directory */
100
110
  function getDecisionsLockDir(projectRoot) {
101
111
  return path.join(projectRoot, '.devflow', 'learning', '.decisions.lock');
102
112
  }
103
113
 
104
- /** .devflow/learning/.decisions-usage.json */
105
- function getDecisionsUsagePath(projectRoot) {
106
- return path.join(projectRoot, '.devflow', 'learning', '.decisions-usage.json');
107
- }
108
-
109
- /** .devflow/learning/.decisions-usage.lock/ — mkdir-based lock directory for usage file */
110
- function getDecisionsUsageLockDir(projectRoot) {
111
- return path.join(projectRoot, '.devflow', 'learning', '.decisions-usage.lock');
112
- }
113
-
114
114
  /** .devflow/learning/index.md — pre-rendered compact index written by render-decisions.cjs */
115
115
  function getDecisionsIndexPath(projectRoot) {
116
116
  return path.join(projectRoot, '.devflow', 'learning', 'index.md');
117
117
  }
118
118
 
119
- /** .devflow/learning/.observations.lock — mkdir-based lock directory for observation log writes */
120
- function getObservationsLockDir(projectRoot) {
121
- return path.join(projectRoot, '.devflow', 'learning', '.observations.lock');
122
- }
123
-
124
119
  // ---------------------------------------------------------------------------
125
120
  // Memory / working-memory files
126
121
  // ---------------------------------------------------------------------------
@@ -185,6 +180,7 @@ module.exports = {
185
180
  // Learning queue files
186
181
  getLearningPendingTurnsPath,
187
182
  getLearningPendingTurnsProcessingPath,
183
+ getLearningClaimOwnerPath,
188
184
  // Learning content files
189
185
  getDecisionsFilePath,
190
186
  getPitfallsFilePath,
@@ -192,10 +188,8 @@ module.exports = {
192
188
  getDecisionsLedgerPath,
193
189
  getDecisionsLogPath,
194
190
  getDecisionsArchivePath,
191
+ getDecisionsHistoryPath,
195
192
  getDecisionsLockDir,
196
- getObservationsLockDir,
197
- getDecisionsUsagePath,
198
- getDecisionsUsageLockDir,
199
193
  getDecisionsIndexPath,
200
194
  // Memory files
201
195
  getWorkingMemoryPath,