@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,112 @@
1
+ /**
2
+ * Dashboard Renderer Port
3
+ *
4
+ * Hexagonal Architecture - Output Port
5
+ * Defines the contract for rendering orchestration dashboard data to any UI.
6
+ * This abstraction allows the application layer to remain independent of
7
+ * specific rendering implementations.
8
+ *
9
+ * Current Implementations:
10
+ * - TerminalDashboardRenderer (WU-1322) - ASCII/ANSI terminal output
11
+ *
12
+ * Future Implementations:
13
+ * - WebDashboardRenderer - Browser-based UI
14
+ * - VSCodeWebviewRenderer - VS Code extension panel
15
+ *
16
+ * SOLID Principles:
17
+ * - Dependency Inversion: Use cases depend on this abstraction, not concrete renderers
18
+ * - Interface Segregation: Focused on rendering, no data fetching concerns
19
+ * - Open/Closed: New renderers can be added without modifying existing code
20
+ *
21
+ * @module dashboard-renderer.port
22
+ * @see {@link ../domain/orchestration.types.ts} - Types used in this interface
23
+ * @see {@link ../../adapters/terminal-renderer.adapter.ts} - Terminal implementation (WU-1322)
24
+ */
25
+ import type { DashboardData, Suggestion, ExecutionPlan, UserChoice } from '../domain/orchestration.types.js';
26
+ /**
27
+ * Dashboard Renderer Port Interface
28
+ *
29
+ * Implementers must provide methods to render all dashboard sections
30
+ * and handle user interactions for execution plan approval.
31
+ *
32
+ * @example
33
+ * // Implementing a custom renderer
34
+ * class CustomRenderer implements IDashboardRenderer {
35
+ * render(data: DashboardData): void {
36
+ * // Render global status, agent metrics, WU progress, timeline, alerts
37
+ * }
38
+ *
39
+ * renderSuggestions(suggestions: Suggestion[]): void {
40
+ * // Display prioritised suggestions
41
+ * }
42
+ *
43
+ * renderPlan(plan: ExecutionPlan): Promise<UserChoice> {
44
+ * // Show plan and get user approval
45
+ * }
46
+ *
47
+ * clear(): void {
48
+ * // Clear previous output
49
+ * }
50
+ * }
51
+ *
52
+ * @example
53
+ * // Using in a use case
54
+ * class GetDashboardDataUseCase {
55
+ * constructor(
56
+ * private readonly renderer: IDashboardRenderer,
57
+ * private readonly collector: IMetricsCollector,
58
+ * ) {}
59
+ *
60
+ * async execute(): Promise<void> {
61
+ * const data = await this.collectData();
62
+ * this.renderer.render(data);
63
+ * }
64
+ * }
65
+ */
66
+ export interface IDashboardRenderer {
67
+ /**
68
+ * Render the complete dashboard with all sections.
69
+ *
70
+ * Sections to render:
71
+ * 1. Global Status - Active WUs, completed, blocked, gates failing
72
+ * 2. Agent Small Multiples - Per-agent metrics comparison
73
+ * 3. WU Progress - DoD progress bars with agent status
74
+ * 4. Timeline - Recent orchestration events
75
+ * 5. Alerts - Items requiring attention
76
+ *
77
+ * @param data - Complete dashboard data from metrics collector
78
+ */
79
+ render(data: DashboardData): void;
80
+ /**
81
+ * Render a list of prioritised suggestions.
82
+ *
83
+ * Suggestions should be displayed with:
84
+ * - Priority indicator (HIGH/MEDIUM/LOW)
85
+ * - Action description
86
+ * - Reason for suggestion
87
+ * - Command to execute
88
+ *
89
+ * @param suggestions - Ordered list of suggestions (highest priority first)
90
+ */
91
+ renderSuggestions(suggestions: Suggestion[]): void;
92
+ /**
93
+ * Render an execution plan and get user approval.
94
+ *
95
+ * Should display:
96
+ * - WU being executed
97
+ * - Ordered list of steps
98
+ * - Estimated token cost
99
+ * - Approval prompt (approve/reject/edit)
100
+ *
101
+ * @param plan - Proposed execution plan
102
+ * @returns User's choice (approve, reject, or edit with modifications)
103
+ */
104
+ renderPlan(plan: ExecutionPlan): Promise<UserChoice>;
105
+ /**
106
+ * Clear any previous dashboard output.
107
+ *
108
+ * Used before re-rendering to prevent stale data display.
109
+ * Implementation depends on output medium (e.g., clear terminal, DOM update).
110
+ */
111
+ clear(): void;
112
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Dashboard Renderer Port
3
+ *
4
+ * Hexagonal Architecture - Output Port
5
+ * Defines the contract for rendering orchestration dashboard data to any UI.
6
+ * This abstraction allows the application layer to remain independent of
7
+ * specific rendering implementations.
8
+ *
9
+ * Current Implementations:
10
+ * - TerminalDashboardRenderer (WU-1322) - ASCII/ANSI terminal output
11
+ *
12
+ * Future Implementations:
13
+ * - WebDashboardRenderer - Browser-based UI
14
+ * - VSCodeWebviewRenderer - VS Code extension panel
15
+ *
16
+ * SOLID Principles:
17
+ * - Dependency Inversion: Use cases depend on this abstraction, not concrete renderers
18
+ * - Interface Segregation: Focused on rendering, no data fetching concerns
19
+ * - Open/Closed: New renderers can be added without modifying existing code
20
+ *
21
+ * @module dashboard-renderer.port
22
+ * @see {@link ../domain/orchestration.types.ts} - Types used in this interface
23
+ * @see {@link ../../adapters/terminal-renderer.adapter.ts} - Terminal implementation (WU-1322)
24
+ */
25
+ export {};
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Metrics Collector Port
3
+ *
4
+ * Hexagonal Architecture - Input Port
5
+ * Defines the contract for collecting orchestration metrics from various sources.
6
+ * This abstraction allows the application layer to remain independent of
7
+ * specific data sources (filesystem, database, API, etc.).
8
+ *
9
+ * Current Implementations:
10
+ * - FileSystemMetricsCollector (WU-1321) - Reads WU YAML, status.md, telemetry
11
+ *
12
+ * Future Implementations:
13
+ * - DatabaseMetricsCollector - Query from Supabase
14
+ * - APIMetricsCollector - Fetch from external service
15
+ * - MockMetricsCollector - Testing purposes
16
+ *
17
+ * SOLID Principles:
18
+ * - Dependency Inversion: Use cases depend on this abstraction, not concrete collectors
19
+ * - Interface Segregation: Each method has a single responsibility
20
+ * - Open/Closed: New collectors can be added without modifying existing code
21
+ *
22
+ * @module metrics-collector.port
23
+ * @see {@link ../domain/orchestration.types.ts} - Types returned by this interface
24
+ * @see {@link ../../adapters/filesystem-metrics.adapter.ts} - Filesystem implementation (WU-1321)
25
+ */
26
+ import type { GlobalStatus, AgentMetric, WUProgress, TimelineEvent, Alert } from '../domain/orchestration.types.js';
27
+ /**
28
+ * Metrics Collector Port Interface
29
+ *
30
+ * Implementers must provide methods to collect all metrics needed
31
+ * for dashboard rendering. Each method should be independently callable
32
+ * to allow selective data fetching.
33
+ *
34
+ * @example
35
+ * // Implementing a custom collector
36
+ * class CustomCollector implements IMetricsCollector {
37
+ * async getGlobalStatus(): Promise<GlobalStatus> {
38
+ * // Collect active WUs, completed count, blocked count, etc.
39
+ * }
40
+ *
41
+ * async getAgentMetrics(): Promise<Record<string, AgentMetric>> {
42
+ * // Collect per-agent invocation counts, pass rates, timing
43
+ * }
44
+ *
45
+ * // ... other methods
46
+ * }
47
+ *
48
+ * @example
49
+ * // Using in a use case
50
+ * class GetDashboardDataUseCase {
51
+ * constructor(private readonly collector: IMetricsCollector) {}
52
+ *
53
+ * async execute(): Promise<DashboardData> {
54
+ * const [globalStatus, agentMetrics, wuProgress, timeline, alerts] =
55
+ * await Promise.all([
56
+ * this.collector.getGlobalStatus(),
57
+ * this.collector.getAgentMetrics(),
58
+ * this.collector.getWUProgress(),
59
+ * this.collector.getTimeline(this.since24h()),
60
+ * this.collector.getAlerts(),
61
+ * ]);
62
+ *
63
+ * return { globalStatus, agentMetrics, wuProgress, timeline, alerts };
64
+ * }
65
+ * }
66
+ */
67
+ export interface IMetricsCollector {
68
+ /**
69
+ * Get global orchestration status.
70
+ *
71
+ * Should aggregate:
72
+ * - Count of WUs in 'in_progress' state
73
+ * - Count of WUs completed in last 24 hours
74
+ * - Count of currently blocked WUs
75
+ * - Count of WUs with failing gates
76
+ * - Longest running WU information
77
+ * - List of WUs with pending mandatory agents
78
+ *
79
+ * @returns Global status metrics
80
+ */
81
+ getGlobalStatus(): Promise<GlobalStatus>;
82
+ /**
83
+ * Get metrics for all known agents.
84
+ *
85
+ * Should collect for each agent:
86
+ * - Total invocation count
87
+ * - Pass rate (percentage)
88
+ * - Average duration in milliseconds
89
+ * - Information about most recent run
90
+ *
91
+ * @returns Record mapping agent names to their metrics
92
+ */
93
+ getAgentMetrics(): Promise<Record<string, AgentMetric>>;
94
+ /**
95
+ * Get progress for all active WUs.
96
+ *
97
+ * Should collect for each active WU:
98
+ * - WU ID and title
99
+ * - Lane assignment
100
+ * - DoD checkpoint progress
101
+ * - Agent run statuses
102
+ * - Headline sentence (Tufte principle)
103
+ *
104
+ * @returns Array of WU progress records, sorted by lane then WU ID
105
+ */
106
+ getWUProgress(): Promise<WUProgress[]>;
107
+ /**
108
+ * Get timeline events since a given date.
109
+ *
110
+ * Should collect events of types:
111
+ * - claim: WU claimed
112
+ * - done: WU completed
113
+ * - block: WU blocked
114
+ * - agent: Agent invoked with result
115
+ * - gates: Gates run with result
116
+ *
117
+ * @param since - Only return events after this timestamp
118
+ * @returns Array of timeline events, sorted by timestamp descending
119
+ */
120
+ getTimeline(since: Date): Promise<TimelineEvent[]>;
121
+ /**
122
+ * Get current alerts requiring attention.
123
+ *
124
+ * Should generate alerts for:
125
+ * - Mandatory agents not yet invoked (HIGH)
126
+ * - WUs near completion needing review (MEDIUM)
127
+ * - Available lanes with ready WUs (LOW)
128
+ *
129
+ * @returns Array of alerts, sorted by severity (high first)
130
+ */
131
+ getAlerts(): Promise<Alert[]>;
132
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Metrics Collector Port
3
+ *
4
+ * Hexagonal Architecture - Input Port
5
+ * Defines the contract for collecting orchestration metrics from various sources.
6
+ * This abstraction allows the application layer to remain independent of
7
+ * specific data sources (filesystem, database, API, etc.).
8
+ *
9
+ * Current Implementations:
10
+ * - FileSystemMetricsCollector (WU-1321) - Reads WU YAML, status.md, telemetry
11
+ *
12
+ * Future Implementations:
13
+ * - DatabaseMetricsCollector - Query from Supabase
14
+ * - APIMetricsCollector - Fetch from external service
15
+ * - MockMetricsCollector - Testing purposes
16
+ *
17
+ * SOLID Principles:
18
+ * - Dependency Inversion: Use cases depend on this abstraction, not concrete collectors
19
+ * - Interface Segregation: Each method has a single responsibility
20
+ * - Open/Closed: New collectors can be added without modifying existing code
21
+ *
22
+ * @module metrics-collector.port
23
+ * @see {@link ../domain/orchestration.types.ts} - Types returned by this interface
24
+ * @see {@link ../../adapters/filesystem-metrics.adapter.ts} - Filesystem implementation (WU-1321)
25
+ */
26
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Background Process Detector (WU-1381)
3
+ *
4
+ * Detects running background processes that might interfere with wu:done
5
+ * gates execution. Warns agents when pnpm/node processes are running
6
+ * in the worktree directory to prevent confusion from mixed output.
7
+ *
8
+ * This is a NON-BLOCKING pre-flight check - it warns but doesn't fail wu:done.
9
+ *
10
+ * @see {@link tools/wu-done.mjs} - Integrates this as pre-flight check
11
+ * @see {@link tools/lib/wu-constants.mjs} - Constants for log prefixes
12
+ */
13
+ /**
14
+ * Re-export interfering process names for external consumers.
15
+ * Source of truth is PROCESS_DETECTION.INTERFERING_NAMES in wu-constants.mjs
16
+ */
17
+ export declare const INTERFERING_PROCESS_NAMES: string[];
18
+ /**
19
+ * Filter processes that might interfere with wu:done in a specific worktree.
20
+ *
21
+ * A process is considered interfering if:
22
+ * 1. Its command contains the worktree path (directly running in worktree)
23
+ * 2. Its name matches known interfering process names (may affect gates)
24
+ *
25
+ * @param {Array<{pid: number, name: string, cmd?: string}>} processes - Process list from ps-list
26
+ * @param {string|null|undefined} worktreePath - Path to the worktree directory
27
+ * @returns {Array<{pid: number, name: string, cmd?: string}>} Filtered processes
28
+ *
29
+ * @example
30
+ * const processes = await psList();
31
+ * const interfering = filterProcessesForWorktree(processes, '/path/to/worktree');
32
+ */
33
+ export declare function filterProcessesForWorktree(processes: any, worktreePath: any): any;
34
+ /**
35
+ * Build a warning message for detected background processes.
36
+ *
37
+ * @param {Array<{pid: number, name: string, cmd?: string}>} processes - Detected processes
38
+ * @returns {string} Formatted warning message
39
+ */
40
+ export declare function buildWarningMessage(processes: any): string;
41
+ /**
42
+ * Detect background processes that might interfere with wu:done.
43
+ *
44
+ * Queries running processes and filters for those that might cause
45
+ * issues during gates execution. Returns detection result with
46
+ * warning messages suitable for display.
47
+ *
48
+ * @param {string} worktreePath - Path to the worktree directory
49
+ * @returns {Promise<{hasProcesses: boolean, processes: Array, warnings: string[], error?: string}>}
50
+ *
51
+ * @example
52
+ * const result = await detectBackgroundProcesses('/path/to/worktree');
53
+ * if (result.hasProcesses) {
54
+ * console.warn(result.warnings.join('\n'));
55
+ * }
56
+ */
57
+ export declare function detectBackgroundProcesses(worktreePath: any): Promise<{
58
+ hasProcesses: boolean;
59
+ processes: any[];
60
+ warnings: any[];
61
+ } | {
62
+ hasProcesses: boolean;
63
+ processes: any;
64
+ warnings: string[];
65
+ } | {
66
+ error: any;
67
+ hasProcesses: boolean;
68
+ processes: any[];
69
+ warnings: any[];
70
+ }>;
71
+ /**
72
+ * Run background process detection as a pre-flight check.
73
+ *
74
+ * This is the main entry point for wu-done.mjs integration.
75
+ * Logs warnings if background processes are detected but does NOT fail.
76
+ *
77
+ * @param {string} worktreePath - Path to the worktree directory
78
+ * @returns {Promise<void>}
79
+ *
80
+ * @example
81
+ * // In wu-done.mjs pre-flight checks:
82
+ * await runBackgroundProcessCheck(worktreePath);
83
+ */
84
+ export declare function runBackgroundProcessCheck(worktreePath: any): Promise<void>;
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Background Process Detector (WU-1381)
3
+ *
4
+ * Detects running background processes that might interfere with wu:done
5
+ * gates execution. Warns agents when pnpm/node processes are running
6
+ * in the worktree directory to prevent confusion from mixed output.
7
+ *
8
+ * This is a NON-BLOCKING pre-flight check - it warns but doesn't fail wu:done.
9
+ *
10
+ * @see {@link tools/wu-done.mjs} - Integrates this as pre-flight check
11
+ * @see {@link tools/lib/wu-constants.mjs} - Constants for log prefixes
12
+ */
13
+ import psList from 'ps-list';
14
+ import { LOG_PREFIX, EMOJI, PROCESS_DETECTION, STRING_LITERALS } from './wu-constants.js';
15
+ /**
16
+ * Re-export interfering process names for external consumers.
17
+ * Source of truth is PROCESS_DETECTION.INTERFERING_NAMES in wu-constants.mjs
18
+ */
19
+ export const INTERFERING_PROCESS_NAMES = PROCESS_DETECTION.INTERFERING_NAMES;
20
+ /**
21
+ * Filter processes that might interfere with wu:done in a specific worktree.
22
+ *
23
+ * A process is considered interfering if:
24
+ * 1. Its command contains the worktree path (directly running in worktree)
25
+ * 2. Its name matches known interfering process names (may affect gates)
26
+ *
27
+ * @param {Array<{pid: number, name: string, cmd?: string}>} processes - Process list from ps-list
28
+ * @param {string|null|undefined} worktreePath - Path to the worktree directory
29
+ * @returns {Array<{pid: number, name: string, cmd?: string}>} Filtered processes
30
+ *
31
+ * @example
32
+ * const processes = await psList();
33
+ * const interfering = filterProcessesForWorktree(processes, '/path/to/worktree');
34
+ */
35
+ export function filterProcessesForWorktree(processes, worktreePath) {
36
+ // Handle null/undefined worktree path
37
+ if (!worktreePath) {
38
+ return [];
39
+ }
40
+ // Handle empty processes array
41
+ if (!processes || processes.length === 0) {
42
+ return [];
43
+ }
44
+ return processes.filter((proc) => {
45
+ const cmd = proc.cmd || '';
46
+ // Include only processes running in the worktree (cmd contains worktree path)
47
+ // We require worktree context to avoid flagging unrelated system processes
48
+ return cmd.includes(worktreePath);
49
+ });
50
+ }
51
+ /**
52
+ * Build a warning message for detected background processes.
53
+ *
54
+ * @param {Array<{pid: number, name: string, cmd?: string}>} processes - Detected processes
55
+ * @returns {string} Formatted warning message
56
+ */
57
+ export function buildWarningMessage(processes) {
58
+ if (!processes || processes.length === 0) {
59
+ return '';
60
+ }
61
+ const processCount = processes.length;
62
+ const cmdLimit = PROCESS_DETECTION.CMD_DISPLAY_LIMIT;
63
+ const processList = processes
64
+ .map((p) => {
65
+ const cmd = p.cmd
66
+ ? ` (${p.cmd.slice(0, cmdLimit)}${p.cmd.length > cmdLimit ? '...' : ''})`
67
+ : '';
68
+ return ` - PID ${p.pid}: ${p.name}${cmd}`;
69
+ })
70
+ .join(STRING_LITERALS.NEWLINE);
71
+ const killCommands = processes.map((p) => `kill ${p.pid}`).join(' && ');
72
+ return `
73
+ ${EMOJI.WARNING} BACKGROUND PROCESSES DETECTED ${EMOJI.WARNING}
74
+
75
+ Found ${processCount} process(es) that may interfere with wu:done:
76
+
77
+ ${processList}
78
+
79
+ These processes may cause:
80
+ - Mixed stdout/stderr output (confusing errors)
81
+ - File lock conflicts during tests
82
+ - Resource contention affecting gate performance
83
+
84
+ Options:
85
+ 1. Wait for processes to complete naturally
86
+ 2. Kill interfering processes:
87
+ ${killCommands}
88
+ 3. Proceed anyway (output may be mixed)
89
+
90
+ This is a NON-BLOCKING warning. wu:done will continue.
91
+ `;
92
+ }
93
+ /**
94
+ * Detect background processes that might interfere with wu:done.
95
+ *
96
+ * Queries running processes and filters for those that might cause
97
+ * issues during gates execution. Returns detection result with
98
+ * warning messages suitable for display.
99
+ *
100
+ * @param {string} worktreePath - Path to the worktree directory
101
+ * @returns {Promise<{hasProcesses: boolean, processes: Array, warnings: string[], error?: string}>}
102
+ *
103
+ * @example
104
+ * const result = await detectBackgroundProcesses('/path/to/worktree');
105
+ * if (result.hasProcesses) {
106
+ * console.warn(result.warnings.join('\n'));
107
+ * }
108
+ */
109
+ export async function detectBackgroundProcesses(worktreePath) {
110
+ const noProcessesResult = {
111
+ hasProcesses: false,
112
+ processes: [],
113
+ warnings: [],
114
+ };
115
+ // Handle invalid worktree path
116
+ if (!worktreePath) {
117
+ return noProcessesResult;
118
+ }
119
+ try {
120
+ // Get all running processes
121
+ const allProcesses = await psList();
122
+ // Filter for worktree-related interfering processes
123
+ const interferingProcesses = filterProcessesForWorktree(allProcesses, worktreePath);
124
+ // Exclude the current process (wu-done itself)
125
+ const currentPid = process.pid;
126
+ const externalProcesses = interferingProcesses.filter((p) => p.pid !== currentPid);
127
+ if (externalProcesses.length === 0) {
128
+ return noProcessesResult;
129
+ }
130
+ // Build warning message
131
+ const warningMessage = buildWarningMessage(externalProcesses);
132
+ return {
133
+ hasProcesses: true,
134
+ processes: externalProcesses,
135
+ warnings: [warningMessage],
136
+ };
137
+ }
138
+ catch (error) {
139
+ // Handle ps-list errors gracefully (permission issues, etc.)
140
+ // Don't block wu:done on process detection failure
141
+ console.warn(`${LOG_PREFIX.DONE} ${EMOJI.WARNING} Could not detect background processes: ${error.message}`);
142
+ return {
143
+ ...noProcessesResult,
144
+ error: error.message,
145
+ };
146
+ }
147
+ }
148
+ /**
149
+ * Run background process detection as a pre-flight check.
150
+ *
151
+ * This is the main entry point for wu-done.mjs integration.
152
+ * Logs warnings if background processes are detected but does NOT fail.
153
+ *
154
+ * @param {string} worktreePath - Path to the worktree directory
155
+ * @returns {Promise<void>}
156
+ *
157
+ * @example
158
+ * // In wu-done.mjs pre-flight checks:
159
+ * await runBackgroundProcessCheck(worktreePath);
160
+ */
161
+ export async function runBackgroundProcessCheck(worktreePath) {
162
+ console.log(`${LOG_PREFIX.DONE} Checking for background processes...`);
163
+ const result = await detectBackgroundProcesses(worktreePath);
164
+ if (result.hasProcesses) {
165
+ // Log warning but don't fail
166
+ console.warn(`\n${LOG_PREFIX.DONE} ${result.warnings.join(STRING_LITERALS.NEWLINE)}`);
167
+ console.log(`${LOG_PREFIX.DONE} ${EMOJI.INFO} Proceeding with wu:done despite background processes`);
168
+ }
169
+ else {
170
+ console.log(`${LOG_PREFIX.DONE} ${EMOJI.SUCCESS} No interfering background processes detected`);
171
+ }
172
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Prompt Linter with 3-Tier Token Budget Enforcement
3
+ *
4
+ * Enforces token budget constraints on LLM prompts:
5
+ * - BLOCK: >450 tokens OR +>120 delta (exit 1)
6
+ * - WARN: ≥400 tokens OR +>50 delta (continue, log warning)
7
+ * - LOG: Always log tokenCount, delta, hash, top 3 longest lines
8
+ *
9
+ * Uses proper telemetry via getLogger() (no console spam).
10
+ *
11
+ * Part of WU-676: Single-Call LLM Orchestrator token budget enforcement.
12
+ */
13
+ /**
14
+ * Load config from YAML file with fallback to defaults
15
+ * @param {string} configPath - Path to config file (optional)
16
+ * @returns {Object} Configuration object
17
+ */
18
+ export declare function loadConfig(configPath?: string): {
19
+ version: any;
20
+ token_budgets: {
21
+ default: {
22
+ hard_cap: any;
23
+ warn_threshold: any;
24
+ };
25
+ retry: {
26
+ hard_cap: any;
27
+ };
28
+ };
29
+ delta_budgets: {
30
+ warn: any;
31
+ block: any;
32
+ };
33
+ retry_pattern: any;
34
+ };
35
+ /**
36
+ * Options for linting prompts
37
+ */
38
+ export interface LintPromptsOptions {
39
+ /** Suppress non-essential output */
40
+ quiet?: boolean;
41
+ /** Enable verbose output */
42
+ verbose?: boolean;
43
+ }
44
+ /**
45
+ * Main linter function
46
+ * @param {string[]} filePaths - Prompt files to lint (optional, finds all if empty)
47
+ * @param {string} mode - Mode (pre-commit, pre-push, ci, local)
48
+ * @param {string} configPath - Optional config file path
49
+ * @param {LintPromptsOptions} [options] - Output options
50
+ * @returns {Promise<{passed: boolean, results: Array, config: Object}>}
51
+ */
52
+ export declare function lintPrompts(filePaths?: any[], mode?: string, configPath?: any, options?: LintPromptsOptions): Promise<{
53
+ passed: boolean;
54
+ results: any[];
55
+ config: {
56
+ version: any;
57
+ token_budgets: {
58
+ default: {
59
+ hard_cap: any;
60
+ warn_threshold: any;
61
+ };
62
+ retry: {
63
+ hard_cap: any;
64
+ };
65
+ };
66
+ delta_budgets: {
67
+ warn: any;
68
+ block: any;
69
+ };
70
+ retry_pattern: any;
71
+ };
72
+ }>;