@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.
- package/LICENSE +190 -0
- package/README.md +119 -0
- package/dist/active-wu-detector.d.ts +33 -0
- package/dist/active-wu-detector.js +106 -0
- package/dist/adapters/filesystem-metrics.adapter.d.ts +108 -0
- package/dist/adapters/filesystem-metrics.adapter.js +519 -0
- package/dist/adapters/terminal-renderer.adapter.d.ts +106 -0
- package/dist/adapters/terminal-renderer.adapter.js +337 -0
- package/dist/arg-parser.d.ts +63 -0
- package/dist/arg-parser.js +560 -0
- package/dist/backlog-editor.d.ts +98 -0
- package/dist/backlog-editor.js +179 -0
- package/dist/backlog-generator.d.ts +111 -0
- package/dist/backlog-generator.js +381 -0
- package/dist/backlog-parser.d.ts +45 -0
- package/dist/backlog-parser.js +102 -0
- package/dist/backlog-sync-validator.d.ts +78 -0
- package/dist/backlog-sync-validator.js +294 -0
- package/dist/branch-drift.d.ts +34 -0
- package/dist/branch-drift.js +51 -0
- package/dist/cleanup-install-config.d.ts +33 -0
- package/dist/cleanup-install-config.js +37 -0
- package/dist/cleanup-lock.d.ts +139 -0
- package/dist/cleanup-lock.js +313 -0
- package/dist/code-path-validator.d.ts +146 -0
- package/dist/code-path-validator.js +537 -0
- package/dist/code-paths-overlap.d.ts +55 -0
- package/dist/code-paths-overlap.js +245 -0
- package/dist/commands-logger.d.ts +77 -0
- package/dist/commands-logger.js +254 -0
- package/dist/commit-message-utils.d.ts +25 -0
- package/dist/commit-message-utils.js +41 -0
- package/dist/compliance-parser.d.ts +150 -0
- package/dist/compliance-parser.js +507 -0
- package/dist/constants/backlog-patterns.d.ts +20 -0
- package/dist/constants/backlog-patterns.js +23 -0
- package/dist/constants/dora-constants.d.ts +49 -0
- package/dist/constants/dora-constants.js +53 -0
- package/dist/constants/gate-constants.d.ts +15 -0
- package/dist/constants/gate-constants.js +15 -0
- package/dist/constants/linter-constants.d.ts +16 -0
- package/dist/constants/linter-constants.js +16 -0
- package/dist/constants/tokenizer-constants.d.ts +15 -0
- package/dist/constants/tokenizer-constants.js +15 -0
- package/dist/core/scope-checker.d.ts +97 -0
- package/dist/core/scope-checker.js +163 -0
- package/dist/core/tool-runner.d.ts +161 -0
- package/dist/core/tool-runner.js +393 -0
- package/dist/core/tool.constants.d.ts +105 -0
- package/dist/core/tool.constants.js +101 -0
- package/dist/core/tool.schemas.d.ts +226 -0
- package/dist/core/tool.schemas.js +226 -0
- package/dist/core/worktree-guard.d.ts +130 -0
- package/dist/core/worktree-guard.js +242 -0
- package/dist/coverage-gate.d.ts +108 -0
- package/dist/coverage-gate.js +196 -0
- package/dist/date-utils.d.ts +75 -0
- package/dist/date-utils.js +140 -0
- package/dist/dependency-graph.d.ts +142 -0
- package/dist/dependency-graph.js +550 -0
- package/dist/dependency-guard.d.ts +54 -0
- package/dist/dependency-guard.js +142 -0
- package/dist/dependency-validator.d.ts +105 -0
- package/dist/dependency-validator.js +154 -0
- package/dist/docs-path-validator.d.ts +36 -0
- package/dist/docs-path-validator.js +95 -0
- package/dist/domain/orchestration.constants.d.ts +99 -0
- package/dist/domain/orchestration.constants.js +97 -0
- package/dist/domain/orchestration.schemas.d.ts +280 -0
- package/dist/domain/orchestration.schemas.js +211 -0
- package/dist/domain/orchestration.types.d.ts +133 -0
- package/dist/domain/orchestration.types.js +12 -0
- package/dist/error-handler.d.ts +116 -0
- package/dist/error-handler.js +136 -0
- package/dist/file-classifiers.d.ts +62 -0
- package/dist/file-classifiers.js +108 -0
- package/dist/gates-agent-mode.d.ts +81 -0
- package/dist/gates-agent-mode.js +94 -0
- package/dist/generate-traceability.d.ts +107 -0
- package/dist/generate-traceability.js +411 -0
- package/dist/git-adapter.d.ts +395 -0
- package/dist/git-adapter.js +649 -0
- package/dist/git-staged-validator.d.ts +32 -0
- package/dist/git-staged-validator.js +48 -0
- package/dist/hardcoded-strings.d.ts +61 -0
- package/dist/hardcoded-strings.js +270 -0
- package/dist/incremental-lint.d.ts +78 -0
- package/dist/incremental-lint.js +129 -0
- package/dist/incremental-test.d.ts +39 -0
- package/dist/incremental-test.js +61 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +61 -0
- package/dist/invariants/check-automated-tests.d.ts +50 -0
- package/dist/invariants/check-automated-tests.js +166 -0
- package/dist/invariants-runner.d.ts +103 -0
- package/dist/invariants-runner.js +527 -0
- package/dist/lane-checker.d.ts +50 -0
- package/dist/lane-checker.js +319 -0
- package/dist/lane-inference.d.ts +39 -0
- package/dist/lane-inference.js +195 -0
- package/dist/lane-lock.d.ts +211 -0
- package/dist/lane-lock.js +474 -0
- package/dist/lane-validator.d.ts +48 -0
- package/dist/lane-validator.js +114 -0
- package/dist/logs-lib.d.ts +104 -0
- package/dist/logs-lib.js +207 -0
- package/dist/lumenflow-config-schema.d.ts +272 -0
- package/dist/lumenflow-config-schema.js +207 -0
- package/dist/lumenflow-config.d.ts +95 -0
- package/dist/lumenflow-config.js +236 -0
- package/dist/manual-test-validator.d.ts +80 -0
- package/dist/manual-test-validator.js +200 -0
- package/dist/merge-lock.d.ts +115 -0
- package/dist/merge-lock.js +251 -0
- package/dist/micro-worktree.d.ts +159 -0
- package/dist/micro-worktree.js +427 -0
- package/dist/migration-deployer.d.ts +69 -0
- package/dist/migration-deployer.js +151 -0
- package/dist/orchestration-advisory-loader.d.ts +28 -0
- package/dist/orchestration-advisory-loader.js +87 -0
- package/dist/orchestration-advisory.d.ts +58 -0
- package/dist/orchestration-advisory.js +94 -0
- package/dist/orchestration-di.d.ts +48 -0
- package/dist/orchestration-di.js +57 -0
- package/dist/orchestration-rules.d.ts +57 -0
- package/dist/orchestration-rules.js +201 -0
- package/dist/orphan-detector.d.ts +131 -0
- package/dist/orphan-detector.js +226 -0
- package/dist/path-classifiers.d.ts +57 -0
- package/dist/path-classifiers.js +93 -0
- package/dist/piped-command-detector.d.ts +34 -0
- package/dist/piped-command-detector.js +64 -0
- package/dist/ports/dashboard-renderer.port.d.ts +112 -0
- package/dist/ports/dashboard-renderer.port.js +25 -0
- package/dist/ports/metrics-collector.port.d.ts +132 -0
- package/dist/ports/metrics-collector.port.js +26 -0
- package/dist/process-detector.d.ts +84 -0
- package/dist/process-detector.js +172 -0
- package/dist/prompt-linter.d.ts +72 -0
- package/dist/prompt-linter.js +312 -0
- package/dist/prompt-monitor.d.ts +15 -0
- package/dist/prompt-monitor.js +205 -0
- package/dist/rebase-artifact-cleanup.d.ts +145 -0
- package/dist/rebase-artifact-cleanup.js +433 -0
- package/dist/retry-strategy.d.ts +189 -0
- package/dist/retry-strategy.js +283 -0
- package/dist/risk-detector.d.ts +108 -0
- package/dist/risk-detector.js +252 -0
- package/dist/rollback-utils.d.ts +76 -0
- package/dist/rollback-utils.js +104 -0
- package/dist/section-headings.d.ts +43 -0
- package/dist/section-headings.js +49 -0
- package/dist/spawn-escalation.d.ts +90 -0
- package/dist/spawn-escalation.js +253 -0
- package/dist/spawn-monitor.d.ts +229 -0
- package/dist/spawn-monitor.js +672 -0
- package/dist/spawn-recovery.d.ts +82 -0
- package/dist/spawn-recovery.js +298 -0
- package/dist/spawn-registry-schema.d.ts +98 -0
- package/dist/spawn-registry-schema.js +108 -0
- package/dist/spawn-registry-store.d.ts +146 -0
- package/dist/spawn-registry-store.js +273 -0
- package/dist/spawn-tree.d.ts +121 -0
- package/dist/spawn-tree.js +285 -0
- package/dist/stamp-status-validator.d.ts +84 -0
- package/dist/stamp-status-validator.js +134 -0
- package/dist/stamp-utils.d.ts +100 -0
- package/dist/stamp-utils.js +229 -0
- package/dist/state-machine.d.ts +26 -0
- package/dist/state-machine.js +83 -0
- package/dist/system-map-validator.d.ts +80 -0
- package/dist/system-map-validator.js +272 -0
- package/dist/telemetry.d.ts +80 -0
- package/dist/telemetry.js +213 -0
- package/dist/token-counter.d.ts +51 -0
- package/dist/token-counter.js +145 -0
- package/dist/usecases/get-dashboard-data.usecase.d.ts +52 -0
- package/dist/usecases/get-dashboard-data.usecase.js +61 -0
- package/dist/usecases/get-suggestions.usecase.d.ts +100 -0
- package/dist/usecases/get-suggestions.usecase.js +153 -0
- package/dist/user-normalizer.d.ts +41 -0
- package/dist/user-normalizer.js +141 -0
- package/dist/validators/phi-constants.d.ts +97 -0
- package/dist/validators/phi-constants.js +152 -0
- package/dist/validators/phi-scanner.d.ts +58 -0
- package/dist/validators/phi-scanner.js +215 -0
- package/dist/worktree-ownership.d.ts +50 -0
- package/dist/worktree-ownership.js +74 -0
- package/dist/worktree-scanner.d.ts +103 -0
- package/dist/worktree-scanner.js +168 -0
- package/dist/worktree-symlink.d.ts +99 -0
- package/dist/worktree-symlink.js +359 -0
- package/dist/wu-backlog-updater.d.ts +17 -0
- package/dist/wu-backlog-updater.js +37 -0
- package/dist/wu-checkpoint.d.ts +124 -0
- package/dist/wu-checkpoint.js +233 -0
- package/dist/wu-claim-helpers.d.ts +26 -0
- package/dist/wu-claim-helpers.js +63 -0
- package/dist/wu-claim-resume.d.ts +106 -0
- package/dist/wu-claim-resume.js +276 -0
- package/dist/wu-consistency-checker.d.ts +95 -0
- package/dist/wu-consistency-checker.js +567 -0
- package/dist/wu-constants.d.ts +1275 -0
- package/dist/wu-constants.js +1382 -0
- package/dist/wu-create-validators.d.ts +42 -0
- package/dist/wu-create-validators.js +93 -0
- package/dist/wu-done-branch-only.d.ts +63 -0
- package/dist/wu-done-branch-only.js +191 -0
- package/dist/wu-done-messages.d.ts +119 -0
- package/dist/wu-done-messages.js +185 -0
- package/dist/wu-done-pr.d.ts +72 -0
- package/dist/wu-done-pr.js +174 -0
- package/dist/wu-done-retry-helpers.d.ts +85 -0
- package/dist/wu-done-retry-helpers.js +172 -0
- package/dist/wu-done-ui.d.ts +37 -0
- package/dist/wu-done-ui.js +69 -0
- package/dist/wu-done-validators.d.ts +411 -0
- package/dist/wu-done-validators.js +1229 -0
- package/dist/wu-done-worktree.d.ts +182 -0
- package/dist/wu-done-worktree.js +1097 -0
- package/dist/wu-helpers.d.ts +128 -0
- package/dist/wu-helpers.js +248 -0
- package/dist/wu-lint.d.ts +70 -0
- package/dist/wu-lint.js +234 -0
- package/dist/wu-paths.d.ts +171 -0
- package/dist/wu-paths.js +178 -0
- package/dist/wu-preflight-validators.d.ts +86 -0
- package/dist/wu-preflight-validators.js +251 -0
- package/dist/wu-recovery.d.ts +138 -0
- package/dist/wu-recovery.js +341 -0
- package/dist/wu-repair-core.d.ts +131 -0
- package/dist/wu-repair-core.js +669 -0
- package/dist/wu-schema-normalization.d.ts +17 -0
- package/dist/wu-schema-normalization.js +82 -0
- package/dist/wu-schema.d.ts +793 -0
- package/dist/wu-schema.js +881 -0
- package/dist/wu-spawn-helpers.d.ts +121 -0
- package/dist/wu-spawn-helpers.js +271 -0
- package/dist/wu-spawn.d.ts +158 -0
- package/dist/wu-spawn.js +1306 -0
- package/dist/wu-state-schema.d.ts +213 -0
- package/dist/wu-state-schema.js +156 -0
- package/dist/wu-state-store.d.ts +264 -0
- package/dist/wu-state-store.js +691 -0
- package/dist/wu-status-transition.d.ts +63 -0
- package/dist/wu-status-transition.js +382 -0
- package/dist/wu-status-updater.d.ts +25 -0
- package/dist/wu-status-updater.js +116 -0
- package/dist/wu-transaction-collectors.d.ts +116 -0
- package/dist/wu-transaction-collectors.js +272 -0
- package/dist/wu-transaction.d.ts +170 -0
- package/dist/wu-transaction.js +273 -0
- package/dist/wu-validation-constants.d.ts +60 -0
- package/dist/wu-validation-constants.js +66 -0
- package/dist/wu-validation.d.ts +118 -0
- package/dist/wu-validation.js +243 -0
- package/dist/wu-validator.d.ts +62 -0
- package/dist/wu-validator.js +325 -0
- package/dist/wu-yaml-fixer.d.ts +97 -0
- package/dist/wu-yaml-fixer.js +264 -0
- package/dist/wu-yaml.d.ts +86 -0
- package/dist/wu-yaml.js +222 -0
- package/package.json +114 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Advisory Loader
|
|
3
|
+
*
|
|
4
|
+
* Pure JavaScript implementation of mandatory agent advisory.
|
|
5
|
+
* Uses minimatch for glob pattern matching (same as TypeScript version).
|
|
6
|
+
*
|
|
7
|
+
* @module orchestration-advisory-loader
|
|
8
|
+
* @see {@link ./orchestration-advisory.mjs} - TypeScript version for tests
|
|
9
|
+
* @see {@link ./domain/orchestration.constants.mjs} - Pattern definitions
|
|
10
|
+
*/
|
|
11
|
+
import { minimatch } from 'minimatch';
|
|
12
|
+
import picocolors from 'picocolors';
|
|
13
|
+
/**
|
|
14
|
+
* Mandatory agent trigger patterns.
|
|
15
|
+
* Mirrors MANDATORY_TRIGGERS from orchestration.constants.mjs.
|
|
16
|
+
*/
|
|
17
|
+
const MANDATORY_TRIGGERS = {
|
|
18
|
+
'security-auditor': ['supabase/migrations/**', '**/auth/**', '**/rls/**', '**/permissions/**'],
|
|
19
|
+
'beacon-guardian': ['**/prompts/**', '**/classification/**', '**/detector/**', '**/llm/**'],
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Detect mandatory agents based on code paths.
|
|
23
|
+
*
|
|
24
|
+
* @param {string[]} codePaths - Array of file paths
|
|
25
|
+
* @returns {string[]} Array of mandatory agent names
|
|
26
|
+
*/
|
|
27
|
+
function detectMandatoryAgents(codePaths) {
|
|
28
|
+
if (!codePaths || codePaths.length === 0) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const triggeredAgents = new Set();
|
|
32
|
+
for (const [agentName, patterns] of Object.entries(MANDATORY_TRIGGERS)) {
|
|
33
|
+
const isTriggered = codePaths.some((filePath) => patterns.some((pattern) => minimatch(filePath, pattern)));
|
|
34
|
+
if (isTriggered) {
|
|
35
|
+
triggeredAgents.add(agentName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return Array.from(triggeredAgents);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Emit mandatory agent advisory based on code paths.
|
|
42
|
+
*
|
|
43
|
+
* @param {string[]} codePaths - Array of file paths
|
|
44
|
+
* @param {string} wuId - Work Unit ID
|
|
45
|
+
*/
|
|
46
|
+
export function emitMandatoryAgentAdvisory(codePaths, wuId) {
|
|
47
|
+
if (!codePaths || codePaths.length === 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const mandatoryAgents = detectMandatoryAgents(codePaths);
|
|
51
|
+
if (mandatoryAgents.length === 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const horizontalLine = '═'.repeat(60);
|
|
55
|
+
console.log('');
|
|
56
|
+
console.log(picocolors.yellow(horizontalLine));
|
|
57
|
+
console.log(picocolors.yellow(picocolors.bold(' MANDATORY AGENT ADVISORY ')));
|
|
58
|
+
console.log(picocolors.yellow(horizontalLine));
|
|
59
|
+
console.log('');
|
|
60
|
+
console.log(`[orchestrate] Based on code_paths in ${wuId}, the following`);
|
|
61
|
+
console.log(`[orchestrate] mandatory agents MUST be invoked BEFORE wu:done:`);
|
|
62
|
+
console.log('');
|
|
63
|
+
for (const agent of mandatoryAgents) {
|
|
64
|
+
console.log(picocolors.cyan(` • ${agent}`));
|
|
65
|
+
}
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log(picocolors.gray(`Run: pnpm orchestrate:suggest --wu ${wuId}`));
|
|
68
|
+
console.log(picocolors.yellow(horizontalLine));
|
|
69
|
+
console.log('');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check mandatory agent compliance.
|
|
73
|
+
*
|
|
74
|
+
* @param {string[]} codePaths - Array of file paths
|
|
75
|
+
* @param {string} _wuId - Work Unit ID (reserved for future telemetry lookup)
|
|
76
|
+
* @returns {{compliant: boolean, missing: string[]}}
|
|
77
|
+
*/
|
|
78
|
+
export function checkMandatoryAgentsCompliance(codePaths, _wuId) {
|
|
79
|
+
if (!codePaths || codePaths.length === 0) {
|
|
80
|
+
return { compliant: true, missing: [] };
|
|
81
|
+
}
|
|
82
|
+
const mandatoryAgents = detectMandatoryAgents(codePaths);
|
|
83
|
+
return {
|
|
84
|
+
compliant: mandatoryAgents.length === 0,
|
|
85
|
+
missing: mandatoryAgents,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Advisory Emitter
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for emitting mandatory agent advisories and checking compliance.
|
|
5
|
+
* Used by wu-claim.mjs (emit advisory) and wu-done.mjs (check compliance).
|
|
6
|
+
*
|
|
7
|
+
* @module orchestration-advisory
|
|
8
|
+
* @see {@link ./orchestration-rules.mjs} - detectMandatoryAgents function
|
|
9
|
+
* @see {@link ./domain/orchestration.constants.mjs} - MANDATORY_TRIGGERS patterns
|
|
10
|
+
*/
|
|
11
|
+
import type { MandatoryAgentName } from './domain/orchestration.types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Emit a mandatory agent advisory to the terminal.
|
|
14
|
+
*
|
|
15
|
+
* Called after wu:claim to inform the agent which mandatory agents
|
|
16
|
+
* must be invoked before wu:done.
|
|
17
|
+
*
|
|
18
|
+
* @param codePaths - Array of file paths being touched by the WU
|
|
19
|
+
* @param wuId - Work Unit ID (e.g., 'WU-1234')
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* emitMandatoryAgentAdvisory(['supabase/migrations/001.sql'], 'WU-1234');
|
|
23
|
+
* // Outputs coloured advisory box with security-auditor requirement
|
|
24
|
+
*/
|
|
25
|
+
export declare function emitMandatoryAgentAdvisory(codePaths: readonly string[], wuId: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Result of mandatory agent compliance check.
|
|
28
|
+
*/
|
|
29
|
+
export interface ComplianceResult {
|
|
30
|
+
/**
|
|
31
|
+
* True if no mandatory agents are required or all have been invoked.
|
|
32
|
+
*/
|
|
33
|
+
compliant: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* List of mandatory agent names that have not been invoked.
|
|
36
|
+
*/
|
|
37
|
+
missing: MandatoryAgentName[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if mandatory agents have been invoked for a WU.
|
|
41
|
+
*
|
|
42
|
+
* Called by wu:done to warn (non-blocking) if mandatory agents
|
|
43
|
+
* were not confirmed as invoked.
|
|
44
|
+
*
|
|
45
|
+
* Note: Current implementation returns missing based on code_paths only.
|
|
46
|
+
* Future versions will check telemetry for actual agent invocations.
|
|
47
|
+
*
|
|
48
|
+
* @param codePaths - Array of file paths touched by the WU
|
|
49
|
+
* @param _wuId - Work Unit ID (reserved for future telemetry lookup)
|
|
50
|
+
* @returns Compliance result with compliant flag and missing agents
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const result = checkMandatoryAgentsCompliance(['src/auth/login.js'], 'WU-1234');
|
|
54
|
+
* if (!result.compliant) {
|
|
55
|
+
* console.warn(`Missing agents: ${result.missing.join(', ')}`);
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
export declare function checkMandatoryAgentsCompliance(codePaths: readonly string[], _wuId: string): ComplianceResult;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Advisory Emitter
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for emitting mandatory agent advisories and checking compliance.
|
|
5
|
+
* Used by wu-claim.mjs (emit advisory) and wu-done.mjs (check compliance).
|
|
6
|
+
*
|
|
7
|
+
* @module orchestration-advisory
|
|
8
|
+
* @see {@link ./orchestration-rules.mjs} - detectMandatoryAgents function
|
|
9
|
+
* @see {@link ./domain/orchestration.constants.mjs} - MANDATORY_TRIGGERS patterns
|
|
10
|
+
*/
|
|
11
|
+
import picocolors from 'picocolors';
|
|
12
|
+
import { detectMandatoryAgents } from './orchestration-rules.js';
|
|
13
|
+
/**
|
|
14
|
+
* Log prefix for orchestration advisory messages.
|
|
15
|
+
*/
|
|
16
|
+
const ADVISORY_PREFIX = '[orchestrate]';
|
|
17
|
+
/**
|
|
18
|
+
* Box drawing characters for advisory display.
|
|
19
|
+
*/
|
|
20
|
+
const BOX_CHARS = {
|
|
21
|
+
HORIZONTAL: '═',
|
|
22
|
+
BULLET: '•',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Advisory box width in characters.
|
|
26
|
+
*/
|
|
27
|
+
const ADVISORY_BOX_WIDTH = 60;
|
|
28
|
+
/**
|
|
29
|
+
* Emit a mandatory agent advisory to the terminal.
|
|
30
|
+
*
|
|
31
|
+
* Called after wu:claim to inform the agent which mandatory agents
|
|
32
|
+
* must be invoked before wu:done.
|
|
33
|
+
*
|
|
34
|
+
* @param codePaths - Array of file paths being touched by the WU
|
|
35
|
+
* @param wuId - Work Unit ID (e.g., 'WU-1234')
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* emitMandatoryAgentAdvisory(['supabase/migrations/001.sql'], 'WU-1234');
|
|
39
|
+
* // Outputs coloured advisory box with security-auditor requirement
|
|
40
|
+
*/
|
|
41
|
+
export function emitMandatoryAgentAdvisory(codePaths, wuId) {
|
|
42
|
+
if (codePaths.length === 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const mandatoryAgents = detectMandatoryAgents(codePaths);
|
|
46
|
+
if (mandatoryAgents.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const horizontalLine = BOX_CHARS.HORIZONTAL.repeat(ADVISORY_BOX_WIDTH);
|
|
50
|
+
console.log('');
|
|
51
|
+
console.log(picocolors.yellow(horizontalLine));
|
|
52
|
+
console.log(picocolors.yellow(picocolors.bold(' MANDATORY AGENT ADVISORY ')));
|
|
53
|
+
console.log(picocolors.yellow(horizontalLine));
|
|
54
|
+
console.log('');
|
|
55
|
+
console.log(`${ADVISORY_PREFIX} Based on code_paths in ${wuId}, the following`);
|
|
56
|
+
console.log(`${ADVISORY_PREFIX} mandatory agents MUST be invoked BEFORE wu:done:`);
|
|
57
|
+
console.log('');
|
|
58
|
+
for (const agent of mandatoryAgents) {
|
|
59
|
+
console.log(picocolors.cyan(` ${BOX_CHARS.BULLET} ${agent}`));
|
|
60
|
+
}
|
|
61
|
+
console.log('');
|
|
62
|
+
console.log(picocolors.gray(`Run: pnpm orchestrate:suggest --wu ${wuId}`));
|
|
63
|
+
console.log(picocolors.yellow(horizontalLine));
|
|
64
|
+
console.log('');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if mandatory agents have been invoked for a WU.
|
|
68
|
+
*
|
|
69
|
+
* Called by wu:done to warn (non-blocking) if mandatory agents
|
|
70
|
+
* were not confirmed as invoked.
|
|
71
|
+
*
|
|
72
|
+
* Note: Current implementation returns missing based on code_paths only.
|
|
73
|
+
* Future versions will check telemetry for actual agent invocations.
|
|
74
|
+
*
|
|
75
|
+
* @param codePaths - Array of file paths touched by the WU
|
|
76
|
+
* @param _wuId - Work Unit ID (reserved for future telemetry lookup)
|
|
77
|
+
* @returns Compliance result with compliant flag and missing agents
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const result = checkMandatoryAgentsCompliance(['src/auth/login.js'], 'WU-1234');
|
|
81
|
+
* if (!result.compliant) {
|
|
82
|
+
* console.warn(`Missing agents: ${result.missing.join(', ')}`);
|
|
83
|
+
* }
|
|
84
|
+
*/
|
|
85
|
+
export function checkMandatoryAgentsCompliance(codePaths, _wuId) {
|
|
86
|
+
if (codePaths.length === 0) {
|
|
87
|
+
return { compliant: true, missing: [] };
|
|
88
|
+
}
|
|
89
|
+
const mandatoryAgents = detectMandatoryAgents(codePaths);
|
|
90
|
+
return {
|
|
91
|
+
compliant: mandatoryAgents.length === 0,
|
|
92
|
+
missing: mandatoryAgents,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Dependency Injection Composition Root
|
|
3
|
+
*
|
|
4
|
+
* Factory functions that wire infrastructure adapters to application use cases.
|
|
5
|
+
* Follows hexagonal architecture - this is the only place where concrete
|
|
6
|
+
* implementations are coupled.
|
|
7
|
+
*
|
|
8
|
+
* @module orchestration-di
|
|
9
|
+
* @see {@link ./ports/metrics-collector.port.mjs} - Input port
|
|
10
|
+
* @see {@link ./ports/dashboard-renderer.port.mjs} - Output port
|
|
11
|
+
* @see {@link ./adapters/filesystem-metrics.adapter.mjs} - Input adapter
|
|
12
|
+
* @see {@link ./adapters/terminal-renderer.adapter.mjs} - Output adapter
|
|
13
|
+
*/
|
|
14
|
+
import { GetDashboardDataUseCase } from './usecases/get-dashboard-data.usecase.js';
|
|
15
|
+
import { GetSuggestionsUseCase } from './usecases/get-suggestions.usecase.js';
|
|
16
|
+
import type { IDashboardRenderer } from './ports/dashboard-renderer.port.js';
|
|
17
|
+
/**
|
|
18
|
+
* Create a GetDashboardDataUseCase with FileSystemMetricsCollector.
|
|
19
|
+
*
|
|
20
|
+
* @param baseDir - Base directory for filesystem operations (default: process.cwd())
|
|
21
|
+
* @returns Configured use case instance
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const useCase = createDashboardUseCase();
|
|
25
|
+
* const data = await useCase.execute();
|
|
26
|
+
*/
|
|
27
|
+
export declare function createDashboardUseCase(baseDir?: string): GetDashboardDataUseCase;
|
|
28
|
+
/**
|
|
29
|
+
* Create a GetSuggestionsUseCase with FileSystemMetricsCollector.
|
|
30
|
+
*
|
|
31
|
+
* @param baseDir - Base directory for filesystem operations (default: process.cwd())
|
|
32
|
+
* @returns Configured use case instance
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const useCase = createSuggestionsUseCase();
|
|
36
|
+
* const suggestions = await useCase.execute({ codePaths: ['src/auth/login.js'] });
|
|
37
|
+
*/
|
|
38
|
+
export declare function createSuggestionsUseCase(baseDir?: string): GetSuggestionsUseCase;
|
|
39
|
+
/**
|
|
40
|
+
* Create a TerminalDashboardRenderer for CLI output.
|
|
41
|
+
*
|
|
42
|
+
* @returns Configured renderer instance
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const renderer = createRenderer();
|
|
46
|
+
* renderer.render(dashboardData);
|
|
47
|
+
*/
|
|
48
|
+
export declare function createRenderer(): IDashboardRenderer;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Dependency Injection Composition Root
|
|
3
|
+
*
|
|
4
|
+
* Factory functions that wire infrastructure adapters to application use cases.
|
|
5
|
+
* Follows hexagonal architecture - this is the only place where concrete
|
|
6
|
+
* implementations are coupled.
|
|
7
|
+
*
|
|
8
|
+
* @module orchestration-di
|
|
9
|
+
* @see {@link ./ports/metrics-collector.port.mjs} - Input port
|
|
10
|
+
* @see {@link ./ports/dashboard-renderer.port.mjs} - Output port
|
|
11
|
+
* @see {@link ./adapters/filesystem-metrics.adapter.mjs} - Input adapter
|
|
12
|
+
* @see {@link ./adapters/terminal-renderer.adapter.mjs} - Output adapter
|
|
13
|
+
*/
|
|
14
|
+
import { FileSystemMetricsCollector } from './adapters/filesystem-metrics.adapter.js';
|
|
15
|
+
import { TerminalDashboardRenderer } from './adapters/terminal-renderer.adapter.js';
|
|
16
|
+
import { GetDashboardDataUseCase } from './usecases/get-dashboard-data.usecase.js';
|
|
17
|
+
import { GetSuggestionsUseCase } from './usecases/get-suggestions.usecase.js';
|
|
18
|
+
/**
|
|
19
|
+
* Create a GetDashboardDataUseCase with FileSystemMetricsCollector.
|
|
20
|
+
*
|
|
21
|
+
* @param baseDir - Base directory for filesystem operations (default: process.cwd())
|
|
22
|
+
* @returns Configured use case instance
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const useCase = createDashboardUseCase();
|
|
26
|
+
* const data = await useCase.execute();
|
|
27
|
+
*/
|
|
28
|
+
export function createDashboardUseCase(baseDir) {
|
|
29
|
+
const collector = new FileSystemMetricsCollector(baseDir);
|
|
30
|
+
return new GetDashboardDataUseCase(collector);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a GetSuggestionsUseCase with FileSystemMetricsCollector.
|
|
34
|
+
*
|
|
35
|
+
* @param baseDir - Base directory for filesystem operations (default: process.cwd())
|
|
36
|
+
* @returns Configured use case instance
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const useCase = createSuggestionsUseCase();
|
|
40
|
+
* const suggestions = await useCase.execute({ codePaths: ['src/auth/login.js'] });
|
|
41
|
+
*/
|
|
42
|
+
export function createSuggestionsUseCase(baseDir) {
|
|
43
|
+
const collector = new FileSystemMetricsCollector(baseDir);
|
|
44
|
+
return new GetSuggestionsUseCase(collector);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a TerminalDashboardRenderer for CLI output.
|
|
48
|
+
*
|
|
49
|
+
* @returns Configured renderer instance
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const renderer = createRenderer();
|
|
53
|
+
* renderer.render(dashboardData);
|
|
54
|
+
*/
|
|
55
|
+
export function createRenderer() {
|
|
56
|
+
return new TerminalDashboardRenderer();
|
|
57
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Rules
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for agent detection and suggestion generation.
|
|
5
|
+
* Uses minimatch for glob pattern matching (NOT regex).
|
|
6
|
+
*
|
|
7
|
+
* @module orchestration-rules
|
|
8
|
+
* @see {@link ./domain/orchestration.constants.mjs} - MANDATORY_TRIGGERS patterns
|
|
9
|
+
* @see {@link ../../../ai/onboarding/agent-selection-guide.md} - Agent selection rules
|
|
10
|
+
*/
|
|
11
|
+
import { type MandatoryAgentName } from './domain/orchestration.constants.js';
|
|
12
|
+
/**
|
|
13
|
+
* Detect mandatory agents that should be invoked based on code paths.
|
|
14
|
+
*
|
|
15
|
+
* Uses minimatch glob patterns from MANDATORY_TRIGGERS to determine
|
|
16
|
+
* which agents are required for the given file paths.
|
|
17
|
+
*
|
|
18
|
+
* @param {readonly string[]} codePaths - Array of file paths being touched by the WU
|
|
19
|
+
* @returns {MandatoryAgentName[]} Array of unique mandatory agent names that should be invoked
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectMandatoryAgents(codePaths: readonly string[]): MandatoryAgentName[];
|
|
22
|
+
/**
|
|
23
|
+
* Generate suggestions for next actions based on WU progress and agent history.
|
|
24
|
+
*
|
|
25
|
+
* @param {readonly object[]} wuProgress - Array of WU progress records
|
|
26
|
+
* @param {object} _agentHistory - Record of agent metrics (reserved for future use)
|
|
27
|
+
* @returns {object[]} Array of prioritised suggestions
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateSuggestions(wuProgress: any, _agentHistory: any): any[];
|
|
30
|
+
/**
|
|
31
|
+
* WU-1542: Build a formatted error message for mandatory agent enforcement failures.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} wuId - Work Unit ID
|
|
34
|
+
* @param {readonly string[]} missingAgents - Array of mandatory agent names that were not invoked
|
|
35
|
+
* @param {readonly string[]} codePaths - Array of file paths that triggered the agents
|
|
36
|
+
* @returns {string} Formatted error message string
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildMandatoryAgentsErrorMessage(wuId: any, missingAgents: any, codePaths: any): string;
|
|
39
|
+
/**
|
|
40
|
+
* WU-1542: Check mandatory agent compliance with optional blocking mode.
|
|
41
|
+
*
|
|
42
|
+
* @param {readonly string[]} codePaths - Array of file paths being touched by the WU
|
|
43
|
+
* @param {string} wuId - Work Unit ID for error message context
|
|
44
|
+
* @param {{ blocking: boolean }} options - Options including blocking mode flag
|
|
45
|
+
* @returns {{ compliant: boolean, blocking: boolean, missing: string[], errorMessage?: string }}
|
|
46
|
+
*/
|
|
47
|
+
export declare function checkMandatoryAgentsComplianceBlocking(codePaths: any, wuId: any, options: any): {
|
|
48
|
+
compliant: boolean;
|
|
49
|
+
blocking: boolean;
|
|
50
|
+
missing: ("security-auditor" | "beacon-guardian")[];
|
|
51
|
+
errorMessage?: undefined;
|
|
52
|
+
} | {
|
|
53
|
+
compliant: boolean;
|
|
54
|
+
blocking: boolean;
|
|
55
|
+
missing: ("security-auditor" | "beacon-guardian")[];
|
|
56
|
+
errorMessage: string;
|
|
57
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Rules
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for agent detection and suggestion generation.
|
|
5
|
+
* Uses minimatch for glob pattern matching (NOT regex).
|
|
6
|
+
*
|
|
7
|
+
* @module orchestration-rules
|
|
8
|
+
* @see {@link ./domain/orchestration.constants.mjs} - MANDATORY_TRIGGERS patterns
|
|
9
|
+
* @see {@link ../../../ai/onboarding/agent-selection-guide.md} - Agent selection rules
|
|
10
|
+
*/
|
|
11
|
+
import { minimatch } from 'minimatch';
|
|
12
|
+
import { MANDATORY_TRIGGERS } from './domain/orchestration.constants.js';
|
|
13
|
+
/**
|
|
14
|
+
* Threshold for considering a WU "near completion".
|
|
15
|
+
* WUs with DoD progress >= this value trigger code-reviewer suggestion.
|
|
16
|
+
*/
|
|
17
|
+
const NEAR_COMPLETION_THRESHOLD = 8;
|
|
18
|
+
/**
|
|
19
|
+
* Detect mandatory agents that should be invoked based on code paths.
|
|
20
|
+
*
|
|
21
|
+
* Uses minimatch glob patterns from MANDATORY_TRIGGERS to determine
|
|
22
|
+
* which agents are required for the given file paths.
|
|
23
|
+
*
|
|
24
|
+
* @param {readonly string[]} codePaths - Array of file paths being touched by the WU
|
|
25
|
+
* @returns {MandatoryAgentName[]} Array of unique mandatory agent names that should be invoked
|
|
26
|
+
*/
|
|
27
|
+
export function detectMandatoryAgents(codePaths) {
|
|
28
|
+
if (codePaths.length === 0) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const triggeredAgents = new Set();
|
|
32
|
+
for (const [agentName, patterns] of Object.entries(MANDATORY_TRIGGERS)) {
|
|
33
|
+
const isTriggered = codePaths.some((filePath) => patterns.some((pattern) => minimatch(filePath, pattern)));
|
|
34
|
+
if (isTriggered) {
|
|
35
|
+
triggeredAgents.add(agentName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return Array.from(triggeredAgents);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generate suggestions for next actions based on WU progress and agent history.
|
|
42
|
+
*
|
|
43
|
+
* @param {readonly object[]} wuProgress - Array of WU progress records
|
|
44
|
+
* @param {object} _agentHistory - Record of agent metrics (reserved for future use)
|
|
45
|
+
* @returns {object[]} Array of prioritised suggestions
|
|
46
|
+
*/
|
|
47
|
+
export function generateSuggestions(wuProgress, _agentHistory) {
|
|
48
|
+
if (wuProgress.length === 0) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const suggestions = [];
|
|
52
|
+
let suggestionCounter = 0;
|
|
53
|
+
for (const wu of wuProgress) {
|
|
54
|
+
const wuSuggestions = generateWUSuggestions(wu, () => ++suggestionCounter);
|
|
55
|
+
suggestions.push(...wuSuggestions);
|
|
56
|
+
}
|
|
57
|
+
// Sort by priority: high > medium > low
|
|
58
|
+
return suggestions.sort((a, b) => {
|
|
59
|
+
const priorityOrder = {
|
|
60
|
+
high: 0,
|
|
61
|
+
medium: 1,
|
|
62
|
+
low: 2,
|
|
63
|
+
};
|
|
64
|
+
return priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate suggestions for a single WU.
|
|
69
|
+
*
|
|
70
|
+
* @param {object} wu - WU progress record
|
|
71
|
+
* @param {function} nextId - Function to generate unique suggestion IDs
|
|
72
|
+
* @returns {object[]} Array of suggestions for this WU
|
|
73
|
+
*/
|
|
74
|
+
function generateWUSuggestions(wu, nextId) {
|
|
75
|
+
const suggestions = [];
|
|
76
|
+
// Check for pending mandatory agents (HIGH priority)
|
|
77
|
+
const mandatoryAgents = ['security-auditor', 'beacon-guardian'];
|
|
78
|
+
for (const agentName of mandatoryAgents) {
|
|
79
|
+
if (wu.agents[agentName] === 'pending') {
|
|
80
|
+
suggestions.push({
|
|
81
|
+
id: `sug-${nextId().toString().padStart(3, '0')}`,
|
|
82
|
+
priority: 'high',
|
|
83
|
+
action: `Run ${agentName}`,
|
|
84
|
+
reason: `Mandatory agent pending for ${wu.wuId}`,
|
|
85
|
+
command: `pnpm orchestrate:run ${agentName} --wu ${wu.wuId}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Check for code-reviewer near completion (MEDIUM priority)
|
|
90
|
+
const isNearCompletion = wu.dodProgress >= NEAR_COMPLETION_THRESHOLD;
|
|
91
|
+
const codeReviewerStatus = wu.agents['code-reviewer'];
|
|
92
|
+
const needsCodeReviewer = isNearCompletion && codeReviewerStatus !== 'pass' && codeReviewerStatus !== 'fail';
|
|
93
|
+
if (needsCodeReviewer) {
|
|
94
|
+
suggestions.push({
|
|
95
|
+
id: `sug-${nextId().toString().padStart(3, '0')}`,
|
|
96
|
+
priority: 'medium',
|
|
97
|
+
action: `Run code-reviewer`,
|
|
98
|
+
reason: `${wu.wuId} is near completion (${wu.dodProgress}/${wu.dodTotal})`,
|
|
99
|
+
command: `pnpm orchestrate:run code-reviewer --wu ${wu.wuId}`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Check for test-engineer when tests pending (LOW priority)
|
|
103
|
+
const testEngineerStatus = wu.agents['test-engineer'];
|
|
104
|
+
const needsTestEngineer = testEngineerStatus === 'pending';
|
|
105
|
+
if (needsTestEngineer) {
|
|
106
|
+
suggestions.push({
|
|
107
|
+
id: `sug-${nextId().toString().padStart(3, '0')}`,
|
|
108
|
+
priority: 'low',
|
|
109
|
+
action: `Run test-engineer`,
|
|
110
|
+
reason: `Tests pending for ${wu.wuId}`,
|
|
111
|
+
command: `pnpm orchestrate:run test-engineer --wu ${wu.wuId}`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return suggestions;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* WU-1542: Agent trigger descriptions for error messages.
|
|
118
|
+
* Maps agent names to human-readable descriptions of their trigger patterns.
|
|
119
|
+
*/
|
|
120
|
+
const AGENT_TRIGGER_DESCRIPTIONS = {
|
|
121
|
+
'security-auditor': 'supabase/migrations/**, **/auth/**, **/rls/**, **/permissions/**',
|
|
122
|
+
'beacon-guardian': '**/prompts/**, **/classification/**, **/detector/**, **/llm/**',
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* WU-1542: Build a formatted error message for mandatory agent enforcement failures.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} wuId - Work Unit ID
|
|
128
|
+
* @param {readonly string[]} missingAgents - Array of mandatory agent names that were not invoked
|
|
129
|
+
* @param {readonly string[]} codePaths - Array of file paths that triggered the agents
|
|
130
|
+
* @returns {string} Formatted error message string
|
|
131
|
+
*/
|
|
132
|
+
export function buildMandatoryAgentsErrorMessage(wuId, missingAgents, codePaths) {
|
|
133
|
+
const lines = [
|
|
134
|
+
'',
|
|
135
|
+
'='.repeat(70),
|
|
136
|
+
' MANDATORY AGENT ENFORCEMENT FAILED (--require-agents)',
|
|
137
|
+
'='.repeat(70),
|
|
138
|
+
'',
|
|
139
|
+
`WU ${wuId} cannot be completed because the following mandatory agents`,
|
|
140
|
+
'were not confirmed as invoked before wu:done:',
|
|
141
|
+
'',
|
|
142
|
+
];
|
|
143
|
+
for (const agent of missingAgents) {
|
|
144
|
+
const description = AGENT_TRIGGER_DESCRIPTIONS[agent] || 'unknown patterns';
|
|
145
|
+
lines.push(` - ${agent}`);
|
|
146
|
+
lines.push(` Triggered by: ${description}`);
|
|
147
|
+
}
|
|
148
|
+
lines.push('');
|
|
149
|
+
lines.push('Code paths that triggered mandatory agents:');
|
|
150
|
+
for (const path of codePaths.slice(0, 5)) {
|
|
151
|
+
lines.push(` - ${path}`);
|
|
152
|
+
}
|
|
153
|
+
if (codePaths.length > 5) {
|
|
154
|
+
lines.push(` ... and ${codePaths.length - 5} more`);
|
|
155
|
+
}
|
|
156
|
+
lines.push('');
|
|
157
|
+
lines.push('Required action:');
|
|
158
|
+
lines.push(' 1. Invoke the required agents BEFORE calling wu:done');
|
|
159
|
+
lines.push(' 2. For security-auditor: Review PHI/auth/RLS implications');
|
|
160
|
+
lines.push(' 3. For beacon-guardian: Validate LLM/prompt compliance');
|
|
161
|
+
lines.push('');
|
|
162
|
+
lines.push('To bypass (NOT RECOMMENDED for PHI/auth work):');
|
|
163
|
+
lines.push(' Remove --require-agents flag from wu:done command');
|
|
164
|
+
lines.push('');
|
|
165
|
+
lines.push('See: ai/onboarding/agent-selection-guide.md for agent invocation guidance');
|
|
166
|
+
lines.push('='.repeat(70));
|
|
167
|
+
return lines.join('\n');
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* WU-1542: Check mandatory agent compliance with optional blocking mode.
|
|
171
|
+
*
|
|
172
|
+
* @param {readonly string[]} codePaths - Array of file paths being touched by the WU
|
|
173
|
+
* @param {string} wuId - Work Unit ID for error message context
|
|
174
|
+
* @param {{ blocking: boolean }} options - Options including blocking mode flag
|
|
175
|
+
* @returns {{ compliant: boolean, blocking: boolean, missing: string[], errorMessage?: string }}
|
|
176
|
+
*/
|
|
177
|
+
export function checkMandatoryAgentsComplianceBlocking(codePaths, wuId, options) {
|
|
178
|
+
const missingAgents = detectMandatoryAgents(codePaths);
|
|
179
|
+
if (missingAgents.length === 0) {
|
|
180
|
+
return {
|
|
181
|
+
compliant: true,
|
|
182
|
+
blocking: false,
|
|
183
|
+
missing: [],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// Non-blocking mode: return compliance info without error message
|
|
187
|
+
if (!options.blocking) {
|
|
188
|
+
return {
|
|
189
|
+
compliant: false,
|
|
190
|
+
blocking: false,
|
|
191
|
+
missing: missingAgents,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// Blocking mode: generate error message
|
|
195
|
+
return {
|
|
196
|
+
compliant: false,
|
|
197
|
+
blocking: true,
|
|
198
|
+
missing: missingAgents,
|
|
199
|
+
errorMessage: buildMandatoryAgentsErrorMessage(wuId, missingAgents, codePaths),
|
|
200
|
+
};
|
|
201
|
+
}
|