@lumenflow/core 1.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 (263) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +119 -0
  3. package/dist/active-wu-detector.d.ts +33 -0
  4. package/dist/active-wu-detector.js +106 -0
  5. package/dist/adapters/filesystem-metrics.adapter.d.ts +108 -0
  6. package/dist/adapters/filesystem-metrics.adapter.js +519 -0
  7. package/dist/adapters/terminal-renderer.adapter.d.ts +106 -0
  8. package/dist/adapters/terminal-renderer.adapter.js +337 -0
  9. package/dist/arg-parser.d.ts +63 -0
  10. package/dist/arg-parser.js +560 -0
  11. package/dist/backlog-editor.d.ts +98 -0
  12. package/dist/backlog-editor.js +179 -0
  13. package/dist/backlog-generator.d.ts +111 -0
  14. package/dist/backlog-generator.js +381 -0
  15. package/dist/backlog-parser.d.ts +45 -0
  16. package/dist/backlog-parser.js +102 -0
  17. package/dist/backlog-sync-validator.d.ts +78 -0
  18. package/dist/backlog-sync-validator.js +294 -0
  19. package/dist/branch-drift.d.ts +34 -0
  20. package/dist/branch-drift.js +51 -0
  21. package/dist/cleanup-install-config.d.ts +33 -0
  22. package/dist/cleanup-install-config.js +37 -0
  23. package/dist/cleanup-lock.d.ts +139 -0
  24. package/dist/cleanup-lock.js +313 -0
  25. package/dist/code-path-validator.d.ts +146 -0
  26. package/dist/code-path-validator.js +537 -0
  27. package/dist/code-paths-overlap.d.ts +55 -0
  28. package/dist/code-paths-overlap.js +245 -0
  29. package/dist/commands-logger.d.ts +77 -0
  30. package/dist/commands-logger.js +254 -0
  31. package/dist/commit-message-utils.d.ts +25 -0
  32. package/dist/commit-message-utils.js +41 -0
  33. package/dist/compliance-parser.d.ts +150 -0
  34. package/dist/compliance-parser.js +507 -0
  35. package/dist/constants/backlog-patterns.d.ts +20 -0
  36. package/dist/constants/backlog-patterns.js +23 -0
  37. package/dist/constants/dora-constants.d.ts +49 -0
  38. package/dist/constants/dora-constants.js +53 -0
  39. package/dist/constants/gate-constants.d.ts +15 -0
  40. package/dist/constants/gate-constants.js +15 -0
  41. package/dist/constants/linter-constants.d.ts +16 -0
  42. package/dist/constants/linter-constants.js +16 -0
  43. package/dist/constants/tokenizer-constants.d.ts +15 -0
  44. package/dist/constants/tokenizer-constants.js +15 -0
  45. package/dist/core/scope-checker.d.ts +97 -0
  46. package/dist/core/scope-checker.js +163 -0
  47. package/dist/core/tool-runner.d.ts +161 -0
  48. package/dist/core/tool-runner.js +393 -0
  49. package/dist/core/tool.constants.d.ts +105 -0
  50. package/dist/core/tool.constants.js +101 -0
  51. package/dist/core/tool.schemas.d.ts +226 -0
  52. package/dist/core/tool.schemas.js +226 -0
  53. package/dist/core/worktree-guard.d.ts +130 -0
  54. package/dist/core/worktree-guard.js +242 -0
  55. package/dist/coverage-gate.d.ts +108 -0
  56. package/dist/coverage-gate.js +196 -0
  57. package/dist/date-utils.d.ts +75 -0
  58. package/dist/date-utils.js +140 -0
  59. package/dist/dependency-graph.d.ts +142 -0
  60. package/dist/dependency-graph.js +550 -0
  61. package/dist/dependency-guard.d.ts +54 -0
  62. package/dist/dependency-guard.js +142 -0
  63. package/dist/dependency-validator.d.ts +105 -0
  64. package/dist/dependency-validator.js +154 -0
  65. package/dist/docs-path-validator.d.ts +36 -0
  66. package/dist/docs-path-validator.js +95 -0
  67. package/dist/domain/orchestration.constants.d.ts +99 -0
  68. package/dist/domain/orchestration.constants.js +97 -0
  69. package/dist/domain/orchestration.schemas.d.ts +280 -0
  70. package/dist/domain/orchestration.schemas.js +211 -0
  71. package/dist/domain/orchestration.types.d.ts +133 -0
  72. package/dist/domain/orchestration.types.js +12 -0
  73. package/dist/error-handler.d.ts +116 -0
  74. package/dist/error-handler.js +136 -0
  75. package/dist/file-classifiers.d.ts +62 -0
  76. package/dist/file-classifiers.js +108 -0
  77. package/dist/gates-agent-mode.d.ts +81 -0
  78. package/dist/gates-agent-mode.js +94 -0
  79. package/dist/generate-traceability.d.ts +107 -0
  80. package/dist/generate-traceability.js +411 -0
  81. package/dist/git-adapter.d.ts +395 -0
  82. package/dist/git-adapter.js +649 -0
  83. package/dist/git-staged-validator.d.ts +32 -0
  84. package/dist/git-staged-validator.js +48 -0
  85. package/dist/hardcoded-strings.d.ts +61 -0
  86. package/dist/hardcoded-strings.js +270 -0
  87. package/dist/incremental-lint.d.ts +78 -0
  88. package/dist/incremental-lint.js +129 -0
  89. package/dist/incremental-test.d.ts +39 -0
  90. package/dist/incremental-test.js +61 -0
  91. package/dist/index.d.ts +42 -0
  92. package/dist/index.js +61 -0
  93. package/dist/invariants/check-automated-tests.d.ts +50 -0
  94. package/dist/invariants/check-automated-tests.js +166 -0
  95. package/dist/invariants-runner.d.ts +103 -0
  96. package/dist/invariants-runner.js +527 -0
  97. package/dist/lane-checker.d.ts +50 -0
  98. package/dist/lane-checker.js +319 -0
  99. package/dist/lane-inference.d.ts +39 -0
  100. package/dist/lane-inference.js +195 -0
  101. package/dist/lane-lock.d.ts +211 -0
  102. package/dist/lane-lock.js +474 -0
  103. package/dist/lane-validator.d.ts +48 -0
  104. package/dist/lane-validator.js +114 -0
  105. package/dist/logs-lib.d.ts +104 -0
  106. package/dist/logs-lib.js +207 -0
  107. package/dist/lumenflow-config-schema.d.ts +272 -0
  108. package/dist/lumenflow-config-schema.js +207 -0
  109. package/dist/lumenflow-config.d.ts +95 -0
  110. package/dist/lumenflow-config.js +236 -0
  111. package/dist/manual-test-validator.d.ts +80 -0
  112. package/dist/manual-test-validator.js +200 -0
  113. package/dist/merge-lock.d.ts +115 -0
  114. package/dist/merge-lock.js +251 -0
  115. package/dist/micro-worktree.d.ts +159 -0
  116. package/dist/micro-worktree.js +427 -0
  117. package/dist/migration-deployer.d.ts +69 -0
  118. package/dist/migration-deployer.js +151 -0
  119. package/dist/orchestration-advisory-loader.d.ts +28 -0
  120. package/dist/orchestration-advisory-loader.js +87 -0
  121. package/dist/orchestration-advisory.d.ts +58 -0
  122. package/dist/orchestration-advisory.js +94 -0
  123. package/dist/orchestration-di.d.ts +48 -0
  124. package/dist/orchestration-di.js +57 -0
  125. package/dist/orchestration-rules.d.ts +57 -0
  126. package/dist/orchestration-rules.js +201 -0
  127. package/dist/orphan-detector.d.ts +131 -0
  128. package/dist/orphan-detector.js +226 -0
  129. package/dist/path-classifiers.d.ts +57 -0
  130. package/dist/path-classifiers.js +93 -0
  131. package/dist/piped-command-detector.d.ts +34 -0
  132. package/dist/piped-command-detector.js +64 -0
  133. package/dist/ports/dashboard-renderer.port.d.ts +112 -0
  134. package/dist/ports/dashboard-renderer.port.js +25 -0
  135. package/dist/ports/metrics-collector.port.d.ts +132 -0
  136. package/dist/ports/metrics-collector.port.js +26 -0
  137. package/dist/process-detector.d.ts +84 -0
  138. package/dist/process-detector.js +172 -0
  139. package/dist/prompt-linter.d.ts +72 -0
  140. package/dist/prompt-linter.js +312 -0
  141. package/dist/prompt-monitor.d.ts +15 -0
  142. package/dist/prompt-monitor.js +205 -0
  143. package/dist/rebase-artifact-cleanup.d.ts +145 -0
  144. package/dist/rebase-artifact-cleanup.js +433 -0
  145. package/dist/retry-strategy.d.ts +189 -0
  146. package/dist/retry-strategy.js +283 -0
  147. package/dist/risk-detector.d.ts +108 -0
  148. package/dist/risk-detector.js +252 -0
  149. package/dist/rollback-utils.d.ts +76 -0
  150. package/dist/rollback-utils.js +104 -0
  151. package/dist/section-headings.d.ts +43 -0
  152. package/dist/section-headings.js +49 -0
  153. package/dist/spawn-escalation.d.ts +90 -0
  154. package/dist/spawn-escalation.js +253 -0
  155. package/dist/spawn-monitor.d.ts +229 -0
  156. package/dist/spawn-monitor.js +672 -0
  157. package/dist/spawn-recovery.d.ts +82 -0
  158. package/dist/spawn-recovery.js +298 -0
  159. package/dist/spawn-registry-schema.d.ts +98 -0
  160. package/dist/spawn-registry-schema.js +108 -0
  161. package/dist/spawn-registry-store.d.ts +146 -0
  162. package/dist/spawn-registry-store.js +273 -0
  163. package/dist/spawn-tree.d.ts +121 -0
  164. package/dist/spawn-tree.js +285 -0
  165. package/dist/stamp-status-validator.d.ts +84 -0
  166. package/dist/stamp-status-validator.js +134 -0
  167. package/dist/stamp-utils.d.ts +100 -0
  168. package/dist/stamp-utils.js +229 -0
  169. package/dist/state-machine.d.ts +26 -0
  170. package/dist/state-machine.js +83 -0
  171. package/dist/system-map-validator.d.ts +80 -0
  172. package/dist/system-map-validator.js +272 -0
  173. package/dist/telemetry.d.ts +80 -0
  174. package/dist/telemetry.js +213 -0
  175. package/dist/token-counter.d.ts +51 -0
  176. package/dist/token-counter.js +145 -0
  177. package/dist/usecases/get-dashboard-data.usecase.d.ts +52 -0
  178. package/dist/usecases/get-dashboard-data.usecase.js +61 -0
  179. package/dist/usecases/get-suggestions.usecase.d.ts +100 -0
  180. package/dist/usecases/get-suggestions.usecase.js +153 -0
  181. package/dist/user-normalizer.d.ts +41 -0
  182. package/dist/user-normalizer.js +141 -0
  183. package/dist/validators/phi-constants.d.ts +97 -0
  184. package/dist/validators/phi-constants.js +152 -0
  185. package/dist/validators/phi-scanner.d.ts +58 -0
  186. package/dist/validators/phi-scanner.js +215 -0
  187. package/dist/worktree-ownership.d.ts +50 -0
  188. package/dist/worktree-ownership.js +74 -0
  189. package/dist/worktree-scanner.d.ts +103 -0
  190. package/dist/worktree-scanner.js +168 -0
  191. package/dist/worktree-symlink.d.ts +99 -0
  192. package/dist/worktree-symlink.js +359 -0
  193. package/dist/wu-backlog-updater.d.ts +17 -0
  194. package/dist/wu-backlog-updater.js +37 -0
  195. package/dist/wu-checkpoint.d.ts +124 -0
  196. package/dist/wu-checkpoint.js +233 -0
  197. package/dist/wu-claim-helpers.d.ts +26 -0
  198. package/dist/wu-claim-helpers.js +63 -0
  199. package/dist/wu-claim-resume.d.ts +106 -0
  200. package/dist/wu-claim-resume.js +276 -0
  201. package/dist/wu-consistency-checker.d.ts +95 -0
  202. package/dist/wu-consistency-checker.js +567 -0
  203. package/dist/wu-constants.d.ts +1275 -0
  204. package/dist/wu-constants.js +1382 -0
  205. package/dist/wu-create-validators.d.ts +42 -0
  206. package/dist/wu-create-validators.js +93 -0
  207. package/dist/wu-done-branch-only.d.ts +63 -0
  208. package/dist/wu-done-branch-only.js +191 -0
  209. package/dist/wu-done-messages.d.ts +119 -0
  210. package/dist/wu-done-messages.js +185 -0
  211. package/dist/wu-done-pr.d.ts +72 -0
  212. package/dist/wu-done-pr.js +174 -0
  213. package/dist/wu-done-retry-helpers.d.ts +85 -0
  214. package/dist/wu-done-retry-helpers.js +172 -0
  215. package/dist/wu-done-ui.d.ts +37 -0
  216. package/dist/wu-done-ui.js +69 -0
  217. package/dist/wu-done-validators.d.ts +411 -0
  218. package/dist/wu-done-validators.js +1229 -0
  219. package/dist/wu-done-worktree.d.ts +182 -0
  220. package/dist/wu-done-worktree.js +1097 -0
  221. package/dist/wu-helpers.d.ts +128 -0
  222. package/dist/wu-helpers.js +248 -0
  223. package/dist/wu-lint.d.ts +70 -0
  224. package/dist/wu-lint.js +234 -0
  225. package/dist/wu-paths.d.ts +171 -0
  226. package/dist/wu-paths.js +178 -0
  227. package/dist/wu-preflight-validators.d.ts +86 -0
  228. package/dist/wu-preflight-validators.js +251 -0
  229. package/dist/wu-recovery.d.ts +138 -0
  230. package/dist/wu-recovery.js +341 -0
  231. package/dist/wu-repair-core.d.ts +131 -0
  232. package/dist/wu-repair-core.js +669 -0
  233. package/dist/wu-schema-normalization.d.ts +17 -0
  234. package/dist/wu-schema-normalization.js +82 -0
  235. package/dist/wu-schema.d.ts +793 -0
  236. package/dist/wu-schema.js +881 -0
  237. package/dist/wu-spawn-helpers.d.ts +121 -0
  238. package/dist/wu-spawn-helpers.js +271 -0
  239. package/dist/wu-spawn.d.ts +158 -0
  240. package/dist/wu-spawn.js +1306 -0
  241. package/dist/wu-state-schema.d.ts +213 -0
  242. package/dist/wu-state-schema.js +156 -0
  243. package/dist/wu-state-store.d.ts +264 -0
  244. package/dist/wu-state-store.js +691 -0
  245. package/dist/wu-status-transition.d.ts +63 -0
  246. package/dist/wu-status-transition.js +382 -0
  247. package/dist/wu-status-updater.d.ts +25 -0
  248. package/dist/wu-status-updater.js +116 -0
  249. package/dist/wu-transaction-collectors.d.ts +116 -0
  250. package/dist/wu-transaction-collectors.js +272 -0
  251. package/dist/wu-transaction.d.ts +170 -0
  252. package/dist/wu-transaction.js +273 -0
  253. package/dist/wu-validation-constants.d.ts +60 -0
  254. package/dist/wu-validation-constants.js +66 -0
  255. package/dist/wu-validation.d.ts +118 -0
  256. package/dist/wu-validation.js +243 -0
  257. package/dist/wu-validator.d.ts +62 -0
  258. package/dist/wu-validator.js +325 -0
  259. package/dist/wu-yaml-fixer.d.ts +97 -0
  260. package/dist/wu-yaml-fixer.js +264 -0
  261. package/dist/wu-yaml.d.ts +86 -0
  262. package/dist/wu-yaml.js +222 -0
  263. package/package.json +114 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Dependency Guard (WU-1783)
3
+ *
4
+ * Detects dependency-mutating pnpm commands and provides blocking/guidance
5
+ * for worktree discipline enforcement.
6
+ *
7
+ * Used by:
8
+ * - pre-tool-use-hook.sh to block dependency mutations on main
9
+ * - deps:add and deps:remove wrapper commands
10
+ *
11
+ * @see {@link .claude/hooks/pre-tool-use-hook.sh} - PreToolUse hook
12
+ * @see {@link tools/deps-add.mjs} - Safe wrapper for pnpm add
13
+ * @see {@link tools/deps-remove.mjs} - Safe wrapper for pnpm remove
14
+ */
15
+ import { EMOJI } from './wu-constants.js';
16
+ /**
17
+ * pnpm subcommands that mutate dependencies.
18
+ *
19
+ * These commands modify package.json, pnpm-lock.yaml, and/or node_modules.
20
+ * Running them on main checkout violates worktree isolation.
21
+ *
22
+ * Includes both full names and shorthand aliases:
23
+ * - add: Add packages to dependencies
24
+ * - install/i: Install packages from lockfile
25
+ * - remove/rm/uninstall: Remove packages from dependencies
26
+ * - update/up: Update packages to latest
27
+ */
28
+ export const DEPENDENCY_MUTATING_COMMANDS = [
29
+ 'add',
30
+ 'install',
31
+ 'i', // shorthand for install
32
+ 'remove',
33
+ 'rm', // shorthand for remove
34
+ 'uninstall', // alias for remove
35
+ 'update',
36
+ 'up', // shorthand for update
37
+ ];
38
+ /**
39
+ * Check if a command is a dependency-mutating pnpm command.
40
+ *
41
+ * @param {string|null|undefined} command - Command string to check
42
+ * @returns {boolean} True if the command mutates dependencies
43
+ *
44
+ * @example
45
+ * isDependencyMutatingCommand('pnpm add react'); // true
46
+ * isDependencyMutatingCommand('pnpm run test'); // false
47
+ * isDependencyMutatingCommand('npm install'); // false (not pnpm)
48
+ */
49
+ export function isDependencyMutatingCommand(command) {
50
+ // Handle null/undefined/empty
51
+ if (!command) {
52
+ return false;
53
+ }
54
+ const trimmed = command.trim();
55
+ if (!trimmed) {
56
+ return false;
57
+ }
58
+ // Only check pnpm commands
59
+ if (!trimmed.startsWith('pnpm ') && trimmed !== 'pnpm') {
60
+ return false;
61
+ }
62
+ // Extract the subcommand (first argument after 'pnpm')
63
+ // Handle: pnpm add, pnpm --filter web add, etc.
64
+ const parts = trimmed.split(/\s+/);
65
+ // Find the first non-flag argument after 'pnpm'
66
+ for (let i = 1; i < parts.length; i++) {
67
+ const part = parts[i];
68
+ // Skip flags (start with -)
69
+ if (part.startsWith('-')) {
70
+ // Handle --filter=value format
71
+ if (part.includes('=')) {
72
+ continue;
73
+ }
74
+ // Handle --filter value format (skip next part too)
75
+ if (part === '--filter' || part === '-F') {
76
+ i++; // Skip the filter value
77
+ continue;
78
+ }
79
+ continue;
80
+ }
81
+ // This is the subcommand
82
+ return DEPENDENCY_MUTATING_COMMANDS.includes(part);
83
+ }
84
+ return false;
85
+ }
86
+ /**
87
+ * Build a blocking message for dependency-mutating commands on main.
88
+ *
89
+ * @param {string} command - The blocked command
90
+ * @returns {string} Formatted error message with guidance
91
+ *
92
+ * @example
93
+ * const message = buildDependencyBlockMessage('pnpm add react');
94
+ * // Returns multi-line message with guidance
95
+ */
96
+ export function buildDependencyBlockMessage(command) {
97
+ // Extract the pnpm subcommand for targeted guidance
98
+ const parts = command.trim().split(/\s+/);
99
+ let subcommand = '';
100
+ for (let i = 1; i < parts.length; i++) {
101
+ if (!parts[i].startsWith('-')) {
102
+ subcommand = parts[i];
103
+ break;
104
+ }
105
+ }
106
+ const wrapperCommand = subcommand === 'add' || subcommand === 'i' || subcommand === 'install'
107
+ ? 'pnpm deps:add'
108
+ : subcommand === 'remove' || subcommand === 'rm' || subcommand === 'uninstall'
109
+ ? 'pnpm deps:remove'
110
+ : 'the corresponding deps:* wrapper';
111
+ return `
112
+ ${EMOJI.BLOCKED} BLOCKED: Dependency mutation on main checkout
113
+
114
+ Command: ${command}
115
+
116
+ REASON: Running ${subcommand || 'dependency'} commands on main bypasses worktree isolation.
117
+ This can cause:
118
+ - Dirty lockfile diffs that block other agents
119
+ - pnpm virtual-store mismatches
120
+ - Wedged wu:done workflows
121
+
122
+ TO FIX:
123
+ 1. Claim a WU first (if not already claimed):
124
+ pnpm wu:claim --id WU-XXXX --lane "Your Lane"
125
+
126
+ 2. Navigate to the worktree:
127
+ cd worktrees/<lane>-wu-<id>/
128
+
129
+ 3. Run your command there, or use the safe wrapper:
130
+ ${wrapperCommand}
131
+
132
+ The safe wrapper (${wrapperCommand}) enforces worktree context
133
+ and runs the underlying pnpm command with proper isolation.
134
+
135
+ See: CLAUDE.md section 2 'Daily Operating Loop'
136
+ See: docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md
137
+ `;
138
+ }
139
+ /**
140
+ * Log prefix for dependency guard output
141
+ */
142
+ export const DEPS_LOG_PREFIX = '[deps-guard]';
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Dependency Validator (WU-2202)
3
+ *
4
+ * Validates that required dependencies are available before tool execution.
5
+ * Prevents silent failures when node_modules is corrupted or incomplete.
6
+ *
7
+ * Background: During INIT-038 orchestration, wu:spawn incorrectly reported
8
+ * lanes as occupied when the yaml package was missing from node_modules.
9
+ * The tool read lock files but failed silently and reported wrong data.
10
+ *
11
+ * This module provides:
12
+ * - validateDependencies(): Check if packages can be imported
13
+ * - formatDependencyError(): Generate clear error messages
14
+ * - TOOL_DEPENDENCIES: Map of tools to their required packages
15
+ *
16
+ * @see WU-2202 - Fix false lane occupancy when deps broken
17
+ */
18
+ /**
19
+ * Map of tools to their required npm packages.
20
+ *
21
+ * Each tool lists the packages it needs to function correctly.
22
+ * These are checked before tool execution to prevent silent failures.
23
+ *
24
+ * @type {Record<string, string[]>}
25
+ */
26
+ export declare const TOOL_DEPENDENCIES: Readonly<{
27
+ 'wu:spawn': string[];
28
+ 'wu:claim': string[];
29
+ 'wu:done': string[];
30
+ 'wu:block': string[];
31
+ 'wu:unblock': string[];
32
+ 'mem:inbox': string[];
33
+ 'mem:signal': string[];
34
+ 'mem:ready': string[];
35
+ 'mem:checkpoint': string[];
36
+ }>;
37
+ /**
38
+ * Validate that required dependencies are available.
39
+ *
40
+ * @param {string[]} packages - List of package names to check
41
+ * @returns {Promise<{valid: boolean, missing: string[]}>} Validation result
42
+ *
43
+ * @example
44
+ * const result = await validateDependencies(['yaml', 'ms']);
45
+ * if (!result.valid) {
46
+ * console.error(`Missing: ${result.missing.join(', ')}`);
47
+ * }
48
+ */
49
+ export declare function validateDependencies(packages: any): Promise<{
50
+ valid: boolean;
51
+ missing: any[];
52
+ }>;
53
+ /**
54
+ * Format an error message for missing dependencies.
55
+ *
56
+ * @param {string} toolName - Name of the tool (e.g., 'wu:spawn')
57
+ * @param {string[]} missing - List of missing package names
58
+ * @returns {string} Formatted error message with fix instructions
59
+ *
60
+ * @example
61
+ * const msg = formatDependencyError('wu:spawn', ['yaml']);
62
+ * console.error(msg);
63
+ */
64
+ export declare function formatDependencyError(toolName: any, missing: any): string;
65
+ /**
66
+ * Validate dependencies for wu:spawn.
67
+ *
68
+ * Convenience function that validates wu:spawn's required packages.
69
+ * Called before lane lock check to prevent false positives.
70
+ *
71
+ * @returns {Promise<{valid: boolean, missing: string[]}>} Validation result
72
+ */
73
+ export declare function validateSpawnDependencies(): Promise<{
74
+ valid: boolean;
75
+ missing: any[];
76
+ }>;
77
+ /**
78
+ * Validate dependencies for mem:inbox.
79
+ *
80
+ * Convenience function that validates mem:inbox's required packages.
81
+ *
82
+ * @returns {Promise<{valid: boolean, missing: string[]}>} Validation result
83
+ */
84
+ export declare function validateInboxDependencies(): Promise<{
85
+ valid: boolean;
86
+ missing: any[];
87
+ }>;
88
+ /**
89
+ * Validate dependencies for a specific tool.
90
+ *
91
+ * @param {string} toolName - Name of the tool (e.g., 'wu:spawn', 'mem:inbox')
92
+ * @returns {Promise<{valid: boolean, missing: string[], toolName: string}>} Validation result
93
+ *
94
+ * @example
95
+ * const result = await validateToolDependencies('wu:spawn');
96
+ * if (!result.valid) {
97
+ * console.error(formatDependencyError(result.toolName, result.missing));
98
+ * process.exit(1);
99
+ * }
100
+ */
101
+ export declare function validateToolDependencies(toolName: any): Promise<{
102
+ toolName: any;
103
+ valid: boolean;
104
+ missing: any[];
105
+ }>;
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Dependency Validator (WU-2202)
3
+ *
4
+ * Validates that required dependencies are available before tool execution.
5
+ * Prevents silent failures when node_modules is corrupted or incomplete.
6
+ *
7
+ * Background: During INIT-038 orchestration, wu:spawn incorrectly reported
8
+ * lanes as occupied when the yaml package was missing from node_modules.
9
+ * The tool read lock files but failed silently and reported wrong data.
10
+ *
11
+ * This module provides:
12
+ * - validateDependencies(): Check if packages can be imported
13
+ * - formatDependencyError(): Generate clear error messages
14
+ * - TOOL_DEPENDENCIES: Map of tools to their required packages
15
+ *
16
+ * @see WU-2202 - Fix false lane occupancy when deps broken
17
+ */
18
+ import { EMOJI, LOG_PREFIX } from './wu-constants.js';
19
+ /**
20
+ * Map of tools to their required npm packages.
21
+ *
22
+ * Each tool lists the packages it needs to function correctly.
23
+ * These are checked before tool execution to prevent silent failures.
24
+ *
25
+ * @type {Record<string, string[]>}
26
+ */
27
+ export const TOOL_DEPENDENCIES = Object.freeze({
28
+ 'wu:spawn': ['yaml', 'minimatch', 'commander'],
29
+ 'wu:claim': ['yaml', 'commander'],
30
+ 'wu:done': ['yaml', 'commander'],
31
+ 'wu:block': ['yaml', 'commander'],
32
+ 'wu:unblock': ['yaml', 'commander'],
33
+ 'mem:inbox': ['ms', 'commander'],
34
+ 'mem:signal': ['commander'],
35
+ 'mem:ready': ['commander'],
36
+ 'mem:checkpoint': ['commander'],
37
+ });
38
+ /**
39
+ * Check if a package can be imported.
40
+ *
41
+ * Uses dynamic import to test package availability.
42
+ * Returns false if the package cannot be loaded.
43
+ *
44
+ * @param {string} packageName - Name of the package to check
45
+ * @returns {Promise<boolean>} True if package is available
46
+ */
47
+ async function canImport(packageName) {
48
+ try {
49
+ await import(packageName);
50
+ return true;
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ }
56
+ /**
57
+ * Validate that required dependencies are available.
58
+ *
59
+ * @param {string[]} packages - List of package names to check
60
+ * @returns {Promise<{valid: boolean, missing: string[]}>} Validation result
61
+ *
62
+ * @example
63
+ * const result = await validateDependencies(['yaml', 'ms']);
64
+ * if (!result.valid) {
65
+ * console.error(`Missing: ${result.missing.join(', ')}`);
66
+ * }
67
+ */
68
+ export async function validateDependencies(packages) {
69
+ if (!packages || packages.length === 0) {
70
+ return { valid: true, missing: [] };
71
+ }
72
+ const missing = [];
73
+ for (const pkg of packages) {
74
+ const available = await canImport(pkg);
75
+ if (!available) {
76
+ missing.push(pkg);
77
+ }
78
+ }
79
+ return {
80
+ valid: missing.length === 0,
81
+ missing,
82
+ };
83
+ }
84
+ /**
85
+ * Format an error message for missing dependencies.
86
+ *
87
+ * @param {string} toolName - Name of the tool (e.g., 'wu:spawn')
88
+ * @param {string[]} missing - List of missing package names
89
+ * @returns {string} Formatted error message with fix instructions
90
+ *
91
+ * @example
92
+ * const msg = formatDependencyError('wu:spawn', ['yaml']);
93
+ * console.error(msg);
94
+ */
95
+ export function formatDependencyError(toolName, missing) {
96
+ const packageList = missing.map((p) => ` - ${p}`).join('\n');
97
+ return `${EMOJI.FAILURE} ${toolName} cannot run: missing dependencies
98
+
99
+ The following packages are required but not available:
100
+ ${packageList}
101
+
102
+ This usually means node_modules is corrupted or incomplete.
103
+
104
+ TO FIX:
105
+ 1. Run: pnpm install
106
+ 2. If that fails, try: rm -rf node_modules && pnpm install
107
+
108
+ If the issue persists, check that the packages are listed in package.json
109
+ and that there are no pnpm virtual-store errors.
110
+
111
+ ${LOG_PREFIX} Missing packages: ${missing.join(', ')}`;
112
+ }
113
+ /**
114
+ * Validate dependencies for wu:spawn.
115
+ *
116
+ * Convenience function that validates wu:spawn's required packages.
117
+ * Called before lane lock check to prevent false positives.
118
+ *
119
+ * @returns {Promise<{valid: boolean, missing: string[]}>} Validation result
120
+ */
121
+ export async function validateSpawnDependencies() {
122
+ return validateDependencies(TOOL_DEPENDENCIES['wu:spawn']);
123
+ }
124
+ /**
125
+ * Validate dependencies for mem:inbox.
126
+ *
127
+ * Convenience function that validates mem:inbox's required packages.
128
+ *
129
+ * @returns {Promise<{valid: boolean, missing: string[]}>} Validation result
130
+ */
131
+ export async function validateInboxDependencies() {
132
+ return validateDependencies(TOOL_DEPENDENCIES['mem:inbox']);
133
+ }
134
+ /**
135
+ * Validate dependencies for a specific tool.
136
+ *
137
+ * @param {string} toolName - Name of the tool (e.g., 'wu:spawn', 'mem:inbox')
138
+ * @returns {Promise<{valid: boolean, missing: string[], toolName: string}>} Validation result
139
+ *
140
+ * @example
141
+ * const result = await validateToolDependencies('wu:spawn');
142
+ * if (!result.valid) {
143
+ * console.error(formatDependencyError(result.toolName, result.missing));
144
+ * process.exit(1);
145
+ * }
146
+ */
147
+ export async function validateToolDependencies(toolName) {
148
+ const deps = TOOL_DEPENDENCIES[toolName] || [];
149
+ const result = await validateDependencies(deps);
150
+ return {
151
+ ...result,
152
+ toolName,
153
+ };
154
+ }
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Docs Path Validator
4
+ *
5
+ * Validates that files staged for commit in a docs-only WU
6
+ * are restricted to documentation paths only.
7
+ *
8
+ * Allowed paths:
9
+ * - memory-bank/**
10
+ * - docs/**
11
+ * - ai/**
12
+ * - .claude/**
13
+ * - *.md (markdown files anywhere)
14
+ * - .beacon/stamps/**
15
+ * - .beacon/state/wu-events.jsonl (tooling-managed metadata)
16
+ *
17
+ * Forbidden paths:
18
+ * - apps/**
19
+ * - packages/** (except test files)
20
+ * - supabase/**
21
+ * - tools/** (except test files)
22
+ */
23
+ /**
24
+ * Validate a list of staged files for docs-only WU
25
+ * @param {string[]} stagedFiles - Array of file paths
26
+ * @returns {{valid: boolean, violations: string[]}} - Validation result
27
+ */
28
+ export declare function validateDocsOnly(stagedFiles: any): {
29
+ valid: boolean;
30
+ violations: any[];
31
+ };
32
+ /**
33
+ * Get a human-readable description of allowed paths
34
+ * @returns {string} - Description of allowed paths
35
+ */
36
+ export declare function getAllowedPathsDescription(): string;
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Docs Path Validator
4
+ *
5
+ * Validates that files staged for commit in a docs-only WU
6
+ * are restricted to documentation paths only.
7
+ *
8
+ * Allowed paths:
9
+ * - memory-bank/**
10
+ * - docs/**
11
+ * - ai/**
12
+ * - .claude/**
13
+ * - *.md (markdown files anywhere)
14
+ * - .beacon/stamps/**
15
+ * - .beacon/state/wu-events.jsonl (tooling-managed metadata)
16
+ *
17
+ * Forbidden paths:
18
+ * - apps/**
19
+ * - packages/** (except test files)
20
+ * - supabase/**
21
+ * - tools/** (except test files)
22
+ */
23
+ import path from 'node:path';
24
+ import { WU_EVENTS_FILE_NAME } from './wu-state-store.js';
25
+ import { BEACON_PATHS, DIRECTORIES, FILE_EXTENSIONS, STRING_LITERALS } from './wu-constants.js';
26
+ const POSIX = path.posix;
27
+ const DOCS_ONLY_PREFIXES = Object.freeze([
28
+ DIRECTORIES.DOCS,
29
+ DIRECTORIES.AI,
30
+ DIRECTORIES.CLAUDE,
31
+ DIRECTORIES.MEMORY_BANK,
32
+ ]);
33
+ const TOOLS_TESTS_PREFIX = `${POSIX.join(DIRECTORIES.TOOLS, '__tests__')}${STRING_LITERALS.SLASH}`;
34
+ const STAMPS_PREFIX = `${BEACON_PATHS.STAMPS_DIR}${STRING_LITERALS.SLASH}`;
35
+ const WU_EVENTS_PATH = POSIX.join(BEACON_PATHS.STATE_DIR, WU_EVENTS_FILE_NAME);
36
+ /**
37
+ * Check if a file path is allowed for docs-only WUs
38
+ * @param {string} filePath - The file path to validate
39
+ * @returns {boolean} - True if the path is allowed
40
+ */
41
+ function isAllowedPath(filePath) {
42
+ if (!filePath)
43
+ return false;
44
+ if (filePath === WU_EVENTS_PATH)
45
+ return true;
46
+ if (filePath.startsWith(STAMPS_PREFIX))
47
+ return true;
48
+ if (filePath.startsWith(TOOLS_TESTS_PREFIX))
49
+ return true;
50
+ if (filePath.startsWith(DIRECTORIES.PACKAGES)) {
51
+ const testsSegment = `${STRING_LITERALS.SLASH}__tests__${STRING_LITERALS.SLASH}`;
52
+ return filePath.includes(testsSegment);
53
+ }
54
+ if (filePath.endsWith(FILE_EXTENSIONS.MARKDOWN))
55
+ return true;
56
+ for (const prefix of DOCS_ONLY_PREFIXES) {
57
+ if (filePath.startsWith(prefix)) {
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ }
63
+ /**
64
+ * Validate a list of staged files for docs-only WU
65
+ * @param {string[]} stagedFiles - Array of file paths
66
+ * @returns {{valid: boolean, violations: string[]}} - Validation result
67
+ */
68
+ export function validateDocsOnly(stagedFiles) {
69
+ const violations = [];
70
+ for (const file of stagedFiles) {
71
+ if (!isAllowedPath(file)) {
72
+ violations.push(file);
73
+ }
74
+ }
75
+ return {
76
+ valid: violations.length === 0,
77
+ violations,
78
+ };
79
+ }
80
+ /**
81
+ * Get a human-readable description of allowed paths
82
+ * @returns {string} - Description of allowed paths
83
+ */
84
+ export function getAllowedPathsDescription() {
85
+ return `Docs-only WUs can only modify:
86
+ - memory-bank/** (task definitions, workflow docs)
87
+ - ai/** (agent documentation, onboarding)
88
+ - .claude/** (agent configuration and skills)
89
+ - docs/** (technical documentation)
90
+ - *.md (markdown files)
91
+ - .beacon/stamps/** (completion stamps)
92
+ - .beacon/state/${WU_EVENTS_FILE_NAME} (WU lifecycle event log)
93
+ - tools/__tests__/** (test files only)
94
+ - packages/**/__tests__/** (test files only)`;
95
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Orchestration Domain Constants
3
+ *
4
+ * Centralised constants for the agent orchestration dashboard.
5
+ * Avoids magic numbers and hardcoded strings throughout the orchestration layer.
6
+ *
7
+ * @module orchestration.constants
8
+ * @see {@link ../ports/dashboard-renderer.port.mjs} - Uses these constants
9
+ * @see {@link ../ports/metrics-collector.port.mjs} - Uses these constants
10
+ */
11
+ /**
12
+ * Total number of Definition of Done checkpoints.
13
+ * Used by dashboard to show DoD progress (X/11).
14
+ */
15
+ export declare const DOD_TOTAL = 11;
16
+ /**
17
+ * Valid lane names in the LumenFlow system.
18
+ * Used for type-safe lane validation.
19
+ */
20
+ export declare const LANES: readonly ["Intelligence", "Experience", "Core Systems", "Operations", "Discovery"];
21
+ /** Type for valid lane names */
22
+ export type Lane = (typeof LANES)[number];
23
+ /**
24
+ * Known agent names in the orchestration system.
25
+ * Includes both mandatory (Tier 1) and suggested (Tier 2) agents.
26
+ */
27
+ export declare const AGENT_NAMES: readonly ["security-auditor", "beacon-guardian", "test-engineer", "code-reviewer"];
28
+ /** Type for agent names */
29
+ export type AgentName = (typeof AGENT_NAMES)[number];
30
+ /**
31
+ * Alert severity levels for dashboard display.
32
+ * HIGH = action required immediately
33
+ * MEDIUM = action suggested
34
+ * LOW = informational
35
+ */
36
+ export declare const SEVERITY_LEVELS: readonly ["high", "medium", "low"];
37
+ /** Type for severity levels */
38
+ export type SeverityLevel = (typeof SEVERITY_LEVELS)[number];
39
+ /**
40
+ * Default timeline window for dashboard display (hours).
41
+ */
42
+ export declare const TIMELINE_WINDOW_HOURS = 24;
43
+ /**
44
+ * Maximum alerts to display in dashboard.
45
+ */
46
+ export declare const MAX_ALERTS_DISPLAY = 10;
47
+ /**
48
+ * Agent result statuses for WU progress tracking.
49
+ */
50
+ export declare const AGENT_RESULT_STATUSES: readonly ["pending", "pass", "fail", "skipped"];
51
+ /** Type for agent result statuses */
52
+ export type AgentResultStatus = (typeof AGENT_RESULT_STATUSES)[number];
53
+ /**
54
+ * Timeline event types for orchestration history.
55
+ */
56
+ export declare const TIMELINE_EVENT_TYPES: readonly ["claim", "done", "block", "agent", "gates"];
57
+ /** Type for timeline event types */
58
+ export type TimelineEventType = (typeof TIMELINE_EVENT_TYPES)[number];
59
+ /**
60
+ * Event severity levels for timeline display.
61
+ */
62
+ export declare const EVENT_SEVERITY_LEVELS: readonly ["info", "warning", "error"];
63
+ /** Type for event severity levels */
64
+ export type EventSeverityLevel = (typeof EVENT_SEVERITY_LEVELS)[number];
65
+ /**
66
+ * User choice options for execution plan confirmation.
67
+ */
68
+ export declare const USER_CHOICE_OPTIONS: readonly ["approve", "reject", "edit"];
69
+ /** Type for user choice options */
70
+ export type UserChoiceOption = (typeof USER_CHOICE_OPTIONS)[number];
71
+ /**
72
+ * Mandatory agent names (subset of AGENT_NAMES)
73
+ */
74
+ export declare const MANDATORY_AGENT_NAMES: readonly ["security-auditor", "beacon-guardian"];
75
+ /** Type for mandatory agent names */
76
+ export type MandatoryAgentName = (typeof MANDATORY_AGENT_NAMES)[number];
77
+ /**
78
+ * Mandatory agent triggers - glob patterns that indicate when agents must be invoked.
79
+ * Uses minimatch patterns (NOT regex) for file path matching.
80
+ *
81
+ * @example
82
+ * // Check if a path triggers security-auditor:
83
+ * import { minimatch } from 'minimatch';
84
+ * const triggers = MANDATORY_TRIGGERS['security-auditor'];
85
+ * const shouldTrigger = triggers.some(pattern => minimatch(filePath, pattern));
86
+ */
87
+ export declare const MANDATORY_TRIGGERS: Record<MandatoryAgentName, readonly string[]>;
88
+ /**
89
+ * File system paths for metrics collection.
90
+ * Used by FileSystemMetricsCollector to avoid hardcoded strings.
91
+ */
92
+ export declare const FILESYSTEM_PATHS: {
93
+ WU_DIR: string;
94
+ STATUS_FILE: string;
95
+ BACKLOG_FILE: string;
96
+ TELEMETRY_DIR: string;
97
+ STAMPS_DIR: string;
98
+ SESSION_FILE: string;
99
+ };