@lumenflow/core 2.2.2 → 2.3.2

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/dist/active-wu-detector.d.ts +1 -1
  2. package/dist/active-wu-detector.js +1 -1
  3. package/dist/arg-parser.js +51 -18
  4. package/dist/backlog-generator.d.ts +4 -4
  5. package/dist/backlog-generator.js +4 -4
  6. package/dist/backlog-sync-validator.js +1 -1
  7. package/dist/cleanup-lock.d.ts +9 -2
  8. package/dist/cleanup-lock.js +17 -7
  9. package/dist/code-path-validator.d.ts +3 -3
  10. package/dist/code-path-validator.js +3 -3
  11. package/dist/compliance-parser.d.ts +1 -1
  12. package/dist/compliance-parser.js +1 -1
  13. package/dist/constants/backlog-patterns.d.ts +1 -1
  14. package/dist/constants/backlog-patterns.js +1 -1
  15. package/dist/constants/dora-constants.d.ts +1 -1
  16. package/dist/constants/dora-constants.js +1 -1
  17. package/dist/constants/gate-constants.d.ts +1 -1
  18. package/dist/constants/gate-constants.js +1 -1
  19. package/dist/constants/linter-constants.d.ts +1 -1
  20. package/dist/constants/linter-constants.js +1 -1
  21. package/dist/constants/tokenizer-constants.d.ts +1 -1
  22. package/dist/constants/tokenizer-constants.js +1 -1
  23. package/dist/context/location-resolver.js +2 -1
  24. package/dist/context-validation-integration.d.ts +1 -0
  25. package/dist/core/scope-checker.d.ts +3 -3
  26. package/dist/core/scope-checker.js +3 -3
  27. package/dist/core/tool-runner.d.ts +5 -5
  28. package/dist/core/tool-runner.js +5 -5
  29. package/dist/core/tool.constants.d.ts +1 -1
  30. package/dist/core/tool.constants.js +1 -1
  31. package/dist/core/tool.schemas.d.ts +2 -2
  32. package/dist/core/tool.schemas.js +1 -1
  33. package/dist/core/worktree-guard.d.ts +1 -1
  34. package/dist/core/worktree-guard.js +1 -1
  35. package/dist/coverage-gate.d.ts +12 -3
  36. package/dist/coverage-gate.js +15 -8
  37. package/dist/date-utils.d.ts +4 -4
  38. package/dist/date-utils.js +4 -4
  39. package/dist/dependency-graph.d.ts +6 -0
  40. package/dist/dependency-graph.js +43 -2
  41. package/dist/dependency-guard.d.ts +2 -2
  42. package/dist/dependency-guard.js +3 -3
  43. package/dist/dependency-validator.d.ts +4 -4
  44. package/dist/dependency-validator.js +4 -7
  45. package/dist/domain/orchestration.constants.d.ts +31 -10
  46. package/dist/domain/orchestration.constants.js +45 -16
  47. package/dist/domain/orchestration.schemas.d.ts +54 -28
  48. package/dist/domain/orchestration.schemas.js +2 -2
  49. package/dist/domain/orchestration.types.d.ts +2 -2
  50. package/dist/domain/orchestration.types.js +2 -2
  51. package/dist/error-handler.d.ts +10 -10
  52. package/dist/error-handler.js +10 -10
  53. package/dist/file-classifiers.d.ts +6 -6
  54. package/dist/file-classifiers.js +6 -6
  55. package/dist/gates-config.d.ts +74 -0
  56. package/dist/gates-config.js +209 -2
  57. package/dist/git-adapter.d.ts +11 -11
  58. package/dist/git-adapter.js +11 -11
  59. package/dist/git-context-extractor.d.ts +112 -0
  60. package/dist/git-context-extractor.js +559 -0
  61. package/dist/hardcoded-strings.d.ts +1 -1
  62. package/dist/hardcoded-strings.js +1 -1
  63. package/dist/incremental-lint.d.ts +1 -1
  64. package/dist/incremental-lint.js +2 -2
  65. package/dist/incremental-test.d.ts +1 -1
  66. package/dist/incremental-test.js +1 -1
  67. package/dist/index.d.ts +13 -0
  68. package/dist/index.js +25 -0
  69. package/dist/invariants/check-automated-tests.d.ts +2 -2
  70. package/dist/invariants/check-automated-tests.js +3 -3
  71. package/dist/lane-checker.d.ts +28 -7
  72. package/dist/lane-checker.js +316 -159
  73. package/dist/lane-suggest-prompt.d.ts +108 -0
  74. package/dist/lane-suggest-prompt.js +359 -0
  75. package/dist/lane-validator.d.ts +3 -3
  76. package/dist/lane-validator.js +3 -3
  77. package/dist/logs-lib.d.ts +1 -1
  78. package/dist/logs-lib.js +1 -1
  79. package/dist/lumenflow-config-schema.d.ts +162 -0
  80. package/dist/lumenflow-config-schema.js +180 -0
  81. package/dist/manual-test-validator.d.ts +2 -2
  82. package/dist/manual-test-validator.js +3 -3
  83. package/dist/merge-lock.d.ts +8 -1
  84. package/dist/merge-lock.js +16 -7
  85. package/dist/micro-worktree.d.ts +81 -13
  86. package/dist/micro-worktree.js +98 -17
  87. package/dist/migration-deployer.d.ts +1 -1
  88. package/dist/migration-deployer.js +1 -1
  89. package/dist/orchestration-advisory-loader.d.ts +2 -2
  90. package/dist/orchestration-advisory-loader.js +10 -6
  91. package/dist/orchestration-advisory.d.ts +3 -3
  92. package/dist/orchestration-advisory.js +4 -4
  93. package/dist/orchestration-di.d.ts +4 -4
  94. package/dist/orchestration-di.js +4 -4
  95. package/dist/orchestration-rules.d.ts +4 -4
  96. package/dist/orchestration-rules.js +18 -10
  97. package/dist/orphan-detector.d.ts +3 -3
  98. package/dist/orphan-detector.js +3 -3
  99. package/dist/patrol-loop.d.ts +170 -0
  100. package/dist/patrol-loop.js +186 -0
  101. package/dist/process-detector.d.ts +5 -5
  102. package/dist/process-detector.js +5 -5
  103. package/dist/rebase-artifact-cleanup.d.ts +3 -3
  104. package/dist/rebase-artifact-cleanup.js +3 -3
  105. package/dist/resolve-policy.d.ts +195 -0
  106. package/dist/resolve-policy.js +203 -0
  107. package/dist/risk-detector.d.ts +2 -2
  108. package/dist/risk-detector.js +2 -2
  109. package/dist/rollback-utils.d.ts +1 -1
  110. package/dist/rollback-utils.js +1 -1
  111. package/dist/section-headings.d.ts +1 -1
  112. package/dist/section-headings.js +1 -1
  113. package/dist/spawn-escalation.d.ts +4 -4
  114. package/dist/spawn-escalation.js +3 -3
  115. package/dist/spawn-monitor.d.ts +4 -4
  116. package/dist/spawn-monitor.js +4 -4
  117. package/dist/spawn-recovery.d.ts +3 -3
  118. package/dist/spawn-recovery.js +3 -3
  119. package/dist/spawn-registry-schema.d.ts +2 -2
  120. package/dist/spawn-registry-schema.js +2 -2
  121. package/dist/spawn-registry-store.d.ts +2 -2
  122. package/dist/spawn-registry-store.js +2 -2
  123. package/dist/spawn-strategy.d.ts +17 -11
  124. package/dist/spawn-strategy.js +47 -44
  125. package/dist/spawn-tree.d.ts +3 -3
  126. package/dist/spawn-tree.js +3 -3
  127. package/dist/state-cleanup-core.d.ts +205 -0
  128. package/dist/state-cleanup-core.js +240 -0
  129. package/dist/state-doctor-core.d.ts +168 -0
  130. package/dist/state-doctor-core.js +251 -0
  131. package/dist/stream-error-handler.d.ts +67 -0
  132. package/dist/stream-error-handler.js +94 -0
  133. package/dist/telemetry.d.ts +1 -1
  134. package/dist/telemetry.js +1 -1
  135. package/dist/template-loader.d.ts +162 -0
  136. package/dist/template-loader.js +372 -0
  137. package/dist/test-baseline.d.ts +176 -0
  138. package/dist/test-baseline.js +282 -0
  139. package/dist/usecases/get-suggestions.usecase.d.ts +1 -1
  140. package/dist/validation/command-registry.js +37 -0
  141. package/dist/validators/backlog-sync.js +4 -2
  142. package/dist/worktree-scanner.d.ts +1 -1
  143. package/dist/worktree-scanner.js +1 -1
  144. package/dist/worktree-symlink.d.ts +3 -3
  145. package/dist/worktree-symlink.js +3 -3
  146. package/dist/wu-backlog-updater.d.ts +1 -1
  147. package/dist/wu-backlog-updater.js +1 -1
  148. package/dist/wu-claim-helpers.d.ts +1 -1
  149. package/dist/wu-claim-helpers.js +1 -1
  150. package/dist/wu-claim-resume.d.ts +1 -1
  151. package/dist/wu-claim-resume.js +1 -1
  152. package/dist/wu-consistency-checker.d.ts +1 -1
  153. package/dist/wu-consistency-checker.js +17 -11
  154. package/dist/wu-constants.d.ts +73 -21
  155. package/dist/wu-constants.js +65 -22
  156. package/dist/wu-done-branch-only.d.ts +1 -1
  157. package/dist/wu-done-branch-only.js +1 -1
  158. package/dist/wu-done-docs-generate.d.ts +1 -1
  159. package/dist/wu-done-docs-generate.js +1 -1
  160. package/dist/wu-done-messages.d.ts +2 -2
  161. package/dist/wu-done-messages.js +2 -2
  162. package/dist/wu-done-metadata.d.ts +3 -3
  163. package/dist/wu-done-metadata.js +3 -3
  164. package/dist/wu-done-pr.d.ts +1 -1
  165. package/dist/wu-done-pr.js +4 -2
  166. package/dist/wu-done-preflight.d.ts +8 -0
  167. package/dist/wu-done-preflight.js +18 -2
  168. package/dist/wu-done-ui.d.ts +3 -3
  169. package/dist/wu-done-ui.js +3 -3
  170. package/dist/wu-done-validation.d.ts +30 -0
  171. package/dist/wu-done-validation.js +106 -1
  172. package/dist/wu-done-worktree.d.ts +1 -1
  173. package/dist/wu-done-worktree.js +11 -1
  174. package/dist/wu-events-cleanup.d.ts +148 -0
  175. package/dist/wu-events-cleanup.js +401 -0
  176. package/dist/wu-helpers.d.ts +2 -2
  177. package/dist/wu-helpers.js +2 -2
  178. package/dist/wu-id-generator.d.ts +58 -0
  179. package/dist/wu-id-generator.js +103 -0
  180. package/dist/wu-lint.js +1 -1
  181. package/dist/wu-preflight-validators.d.ts +13 -1
  182. package/dist/wu-preflight-validators.js +56 -1
  183. package/dist/wu-recovery.d.ts +2 -2
  184. package/dist/wu-recovery.js +4 -4
  185. package/dist/wu-repair-core.d.ts +5 -5
  186. package/dist/wu-repair-core.js +6 -6
  187. package/dist/wu-schema-normalization.d.ts +1 -1
  188. package/dist/wu-schema-normalization.js +1 -1
  189. package/dist/wu-schema.d.ts +7 -7
  190. package/dist/wu-schema.js +8 -8
  191. package/dist/wu-spawn-context.d.ts +87 -0
  192. package/dist/wu-spawn-context.js +175 -0
  193. package/dist/wu-spawn-helpers.d.ts +1 -1
  194. package/dist/wu-spawn-helpers.js +1 -1
  195. package/dist/wu-spawn.d.ts +177 -4
  196. package/dist/wu-spawn.js +694 -72
  197. package/dist/wu-state-schema.d.ts +1 -1
  198. package/dist/wu-state-schema.js +1 -1
  199. package/dist/wu-state-store.d.ts +3 -3
  200. package/dist/wu-state-store.js +3 -3
  201. package/dist/wu-status-transition.d.ts +1 -1
  202. package/dist/wu-status-transition.js +1 -1
  203. package/dist/wu-status-updater.d.ts +3 -3
  204. package/dist/wu-status-updater.js +3 -3
  205. package/dist/wu-validation-constants.d.ts +2 -2
  206. package/dist/wu-validation-constants.js +2 -2
  207. package/dist/wu-validation.d.ts +3 -3
  208. package/dist/wu-validation.js +3 -3
  209. package/dist/wu-yaml-fixer.d.ts +2 -2
  210. package/dist/wu-yaml-fixer.js +3 -3
  211. package/dist/wu-yaml.d.ts +23 -0
  212. package/dist/wu-yaml.js +76 -2
  213. package/package.json +5 -2
@@ -25,9 +25,159 @@
25
25
  * Codex Mode:
26
26
  * When --codex is used, outputs a Codex/GPT-friendly Markdown prompt (no antml/XML escaping).
27
27
  *
28
- * @see {@link docs/04-operations/_frameworks/lumenflow/agent/onboarding/agent-invocation-guide.md} - Context loading templates
28
+ * @see {@link https://lumenflow.dev/reference/agent-invocation-guide/} - Context loading templates
29
29
  */
30
30
  import type { ClientConfig, LumenFlowConfig } from './lumenflow-config-schema.js';
31
+ /**
32
+ * WU-1253/WU-1291: Template System for Spawn Prompts
33
+ *
34
+ * DECISION (WU-1291): Template system is ACTIVATED with graceful degradation.
35
+ *
36
+ * The template system loads prompt sections from .lumenflow/templates/spawn-prompt/
37
+ * with YAML frontmatter and manifest-driven assembly order. This design provides:
38
+ *
39
+ * 1. **Maintainability**: Templates in markdown files are easier to edit than code strings
40
+ * 2. **Client extensibility**: Client-specific overrides via templates.{client}/ directories
41
+ * 3. **Conditional inclusion**: Templates selected based on WU type and policy settings
42
+ * 4. **Graceful fallback**: If template loading fails, hardcoded functions are used
43
+ *
44
+ * Template loading is attempted via tryAssembleSpawnTemplates(). If it returns null
45
+ * (templates missing or assembly fails), the spawn output uses hardcoded generator
46
+ * functions (generateTDDDirective, generateBugDiscoverySection, etc.).
47
+ *
48
+ * @see template-loader.ts for the loading and assembly implementation
49
+ * @see .lumenflow/templates/manifest.yaml for the template registry
50
+ */
51
+ import { type TemplateContext } from './template-loader.js';
52
+ import type { ResolvedPolicy } from './resolve-policy.js';
53
+ /**
54
+ * WU-1192: Truncation prevention constants (consolidated from CLI)
55
+ *
56
+ * These constants help detect when spawn output has been truncated during
57
+ * copy-paste operations or context loading. The warning banner alerts users
58
+ * to the truncation risk, and the end sentinel allows verification that
59
+ * the full output was received.
60
+ */
61
+ export declare const TRUNCATION_WARNING_BANNER = "<!-- LUMENFLOW_TRUNCATION_WARNING -->\n<!--\n \u26A0\uFE0F CRITICAL: DO NOT TRUNCATE THIS OUTPUT\n\n This spawn prompt MUST be copied verbatim. Truncation causes:\n - Missing constraints (agents ignore safety rules)\n - Missing TDD directives (agents skip tests)\n - Degraded agent performance\n\n VERIFICATION: The output MUST end with: <!-- LUMENFLOW_SPAWN_END -->\n If you don't see that sentinel at the end, the output was truncated.\n-->\n";
62
+ export declare const SPAWN_END_SENTINEL = "<!-- LUMENFLOW_SPAWN_END -->";
63
+ /**
64
+ * WU-1253/WU-1291: Try to assemble spawn prompt sections from templates.
65
+ *
66
+ * This function loads templates from .lumenflow/templates/ and assembles
67
+ * them according to the manifest order. Client-specific overrides are
68
+ * supported via templates.{client}/ directories.
69
+ *
70
+ * **Decision (WU-1291)**: Template system is ACTIVATED. This function is called
71
+ * by generateTaskInvocation() and generateCodexPrompt() to attempt template-based
72
+ * generation. If it returns null (templates missing, manifest invalid, or assembly
73
+ * fails), callers fall back to hardcoded generator functions.
74
+ *
75
+ * Template coverage (as of WU-1291):
76
+ * - Methodology directives (TDD, test-after, none)
77
+ * - Architecture directives (hexagonal, layered, none)
78
+ * - Type-specific directives (documentation, visual, refactor)
79
+ * - Agent guidance (effort-scaling, parallel-tool-calls, search-heuristics, token-budget)
80
+ * - Operational guidance (bug-discovery, quick-fix-commands, lane-selection)
81
+ * - Lane-specific guidance and constraints
82
+ *
83
+ * @param baseDir - Project root directory
84
+ * @param clientName - Client name for overrides (e.g., 'claude', 'cursor')
85
+ * @param context - Context for token replacement and condition evaluation
86
+ * @returns Assembled template content, or null if templates unavailable
87
+ */
88
+ export declare function tryAssembleSpawnTemplates(baseDir: string, clientName: string, context: TemplateContext): string | null;
89
+ /**
90
+ * Build template context from WU document.
91
+ *
92
+ * @param doc - WU YAML document
93
+ * @param id - WU ID
94
+ * @returns Context for template assembly
95
+ */
96
+ export declare function buildTemplateContext(doc: Record<string, unknown>, id: string): TemplateContext;
97
+ /**
98
+ * WU-1261: Build template context with resolved policy fields.
99
+ *
100
+ * Extends buildTemplateContext() with policy.testing and policy.architecture
101
+ * fields for template condition evaluation.
102
+ *
103
+ * @param doc - WU YAML document
104
+ * @param id - WU ID
105
+ * @param policy - Resolved policy from resolvePolicy()
106
+ * @returns Context for template assembly with policy fields
107
+ */
108
+ export declare function buildTemplateContextWithPolicy(doc: Record<string, unknown>, id: string, policy: ResolvedPolicy): TemplateContext & {
109
+ 'policy.testing': string;
110
+ 'policy.architecture': string;
111
+ };
112
+ /**
113
+ * Generate type-aware test guidance (WU-1142, WU-1192)
114
+ *
115
+ * Returns appropriate test guidance based on WU type:
116
+ * - feature/bug/tooling: Full TDD directive
117
+ * - documentation: Format check only
118
+ * - visual/design: Smoke test + manual QA
119
+ * - refactor: Existing tests must pass
120
+ *
121
+ * @param {string} wuType - WU type from YAML
122
+ * @returns {string} Test guidance section
123
+ */
124
+ export declare function generateTestGuidance(wuType: string): string;
125
+ /**
126
+ * WU-1279: Generate the Mandatory Standards section based on resolved policy
127
+ *
128
+ * Instead of hardcoding TDD/90%/Hexagonal, this function generates the
129
+ * section dynamically based on the resolved methodology policy.
130
+ *
131
+ * @param policy - Resolved policy from resolvePolicy()
132
+ * @returns Mandatory Standards section content
133
+ */
134
+ export declare function generateMandatoryStandards(policy: ResolvedPolicy): string;
135
+ /**
136
+ * WU-1261: Generate test guidance based on resolved policy
137
+ *
138
+ * Selects the appropriate test guidance based on policy.testing value:
139
+ * - 'tdd': Full TDD directive (failing test first)
140
+ * - 'test-after': Implementation first, then tests
141
+ * - 'none': Testing is optional
142
+ *
143
+ * Type overrides still apply (documentation WUs always get docs guidance).
144
+ *
145
+ * @param wuType - WU type from YAML (e.g., 'feature', 'documentation')
146
+ * @param policy - Resolved policy from resolvePolicy()
147
+ * @returns Test guidance section
148
+ */
149
+ export declare function generatePolicyBasedTestGuidance(wuType: string, policy: ResolvedPolicy): string;
150
+ /**
151
+ * WU-1261: Generate architecture guidance based on resolved policy
152
+ *
153
+ * Selects appropriate architecture guidance based on policy.architecture:
154
+ * - 'hexagonal': Ports and adapters, dependency inversion
155
+ * - 'layered': Traditional layer separation
156
+ * - 'none': No architecture constraints
157
+ *
158
+ * @param policy - Resolved policy from resolvePolicy()
159
+ * @returns Architecture guidance section, or empty string for 'none'
160
+ */
161
+ export declare function generatePolicyBasedArchitectureGuidance(policy: ResolvedPolicy): string;
162
+ /**
163
+ * WU-1261: Generate enforcement summary from resolved policy
164
+ *
165
+ * Creates a "You will be judged by" section that summarizes the active
166
+ * enforcement rules based on the resolved policy.
167
+ *
168
+ * @param policy - Resolved policy from resolvePolicy()
169
+ * @returns Enforcement summary section
170
+ */
171
+ export declare function generateEnforcementSummary(policy: ResolvedPolicy): string;
172
+ /**
173
+ * Generate worktree block recovery section (WU-1192)
174
+ *
175
+ * Provides guidance when agents encounter worktree hook blocks.
176
+ *
177
+ * @param {string} worktreePath - Path to the worktree
178
+ * @returns {string} Recovery section
179
+ */
180
+ export declare function generateWorktreeBlockRecoverySection(worktreePath: string): string;
31
181
  /**
32
182
  * Generate effort scaling rules section (WU-1986)
33
183
  *
@@ -68,15 +218,20 @@ export declare function generateTokenBudgetAwareness(id: any): string;
68
218
  */
69
219
  export declare function generateCompletionFormat(_id: any): string;
70
220
  /**
71
- * Generate agent coordination section (WU-1987)
221
+ * Generate agent coordination section (WU-1987, WU-1203)
72
222
  *
73
223
  * Provides guidance on mem:signal for parallel agent coordination,
74
- * orchestrate:status for dashboard checks, and abandoned WU handling.
224
+ * orchestrate:monitor for agent status checks, and abandoned WU handling.
225
+ *
226
+ * WU-1203: Reads progress_signals config to generate dynamic guidance.
227
+ * When enabled:true, shows "Progress Signals (Required at Milestones)" with
228
+ * configurable triggers. When enabled:false or not configured, shows
229
+ * "Progress Signals (Optional)".
75
230
  *
76
231
  * @param {string} id - WU ID
77
232
  * @returns {string} Agent coordination section
78
233
  */
79
- export declare function generateAgentCoordinationSection(id: any): string;
234
+ export declare function generateAgentCoordinationSection(id: string): string;
80
235
  /**
81
236
  * Generate quick fix commands section (WU-1987)
82
237
  *
@@ -85,6 +240,16 @@ export declare function generateAgentCoordinationSection(id: any): string;
85
240
  * @returns {string} Quick fix commands section
86
241
  */
87
242
  export declare function generateQuickFixCommands(): string;
243
+ /**
244
+ * WU-1270: Emit methodology telemetry event (opt-in)
245
+ *
246
+ * Emits privacy-preserving telemetry about methodology selection.
247
+ * Only emits if telemetry.methodology.enabled is true in config.
248
+ *
249
+ * @param config - LumenFlow configuration
250
+ * @param policy - Resolved methodology policy
251
+ */
252
+ export declare function emitMethodologyTelemetry(config: LumenFlowConfig, policy: ResolvedPolicy): void;
88
253
  /**
89
254
  * Generate Lane Selection section (WU-2107)
90
255
  *
@@ -130,6 +295,14 @@ interface SpawnOptions {
130
295
  budget?: string;
131
296
  client?: ClientContext;
132
297
  config?: LumenFlowConfig;
298
+ /** WU-1240: Base directory for memory context loading */
299
+ baseDir?: string;
300
+ /** WU-1240: Include memory context section (default: false for backward compat) */
301
+ includeMemoryContext?: boolean;
302
+ /** WU-1240: Skip memory context even if includeMemoryContext is true */
303
+ noContext?: boolean;
304
+ /** WU-1240: Memory context content (pre-generated, for async integration) */
305
+ memoryContextContent?: string;
133
306
  }
134
307
  /**
135
308
  * Generate the complete Task tool invocation