@andorra-labs/code 0.1.9 → 0.1.11
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/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +56 -0
- package/dist/src/app-server/protocol.d.ts +109 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server.d.ts +59 -1
- package/dist/src/app-server.js +418 -63
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +255 -33
- package/dist/src/browser-ui/index.html +9 -9
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/cli.js +10 -5
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -2
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +9 -1
- package/dist/src/completion.js +20 -2
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.js +4 -4
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +303 -129
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +56 -7
- package/dist/src/graph-ui/icons.js +5 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +5 -5
- package/dist/src/graph-ui/skill-picker.js +5 -5
- package/dist/src/graph-ui/studio-canvas.js +16 -16
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +99 -42
- package/dist/src/graph-ui/style.css +125 -80
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +10 -3
- package/dist/src/graphs.js +15 -4
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/qa/guidance.js +6 -19
- package/dist/src/qa/index.d.ts +0 -2
- package/dist/src/qa/index.js +0 -2
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.js +134 -16
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/remote/engine-pool.js +18 -6
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +122 -0
- package/dist/src/session-changes.js +804 -0
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +15 -0
- package/dist/src/stall-recovery.js +17 -0
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +64 -20
- package/dist/src/terminal-ui.js +312 -82
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +118 -9
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +15 -3
- package/dist/src/types.d.ts +12 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
import { mkdir, readdir, rm, appendFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { executeShell } from '../../shell.js';
|
|
5
|
-
import { emptyQaState } from '../types.js';
|
|
6
|
-
import { deriveProfile } from '../profile/ProjectInspector.js';
|
|
7
|
-
import { detectChanges } from '../git/ChangeDetector.js';
|
|
8
|
-
import { reviewDiff } from '../git/DiffReviewer.js';
|
|
9
|
-
import { scanAddedLinesForSecrets } from '../security/SecretScanner.js';
|
|
10
|
-
import { runDependencyAudit } from '../security/DependencyScanner.js';
|
|
11
|
-
import { runCommandCheck } from '../runners/CommandRunner.js';
|
|
12
|
-
import { buildTestCommand } from '../runners/TestRunner.js';
|
|
13
|
-
import { runRuntimeSmoke } from '../runtime/RuntimeSmoke.js';
|
|
14
|
-
import { runApiSmokeTests } from '../api/http-runner.js';
|
|
15
|
-
import { runBrowserQa } from '../browser/PlaywrightRunner.js';
|
|
16
|
-
import { classifyChanges } from './ChangeClassifier.js';
|
|
17
|
-
import { computeMergeGate, gateVerdict } from './MergeGate.js';
|
|
18
|
-
import { describeRuntimeCapabilities } from '../runtime-detect.js';
|
|
19
|
-
const LINT_TIMEOUT_MS = 120_000;
|
|
20
|
-
const TEST_TIMEOUT_MS = 300_000;
|
|
21
|
-
const LOG_RETENTION = 20;
|
|
22
|
-
function shortRunId() {
|
|
23
|
-
return `${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Per-workspace QA session: derives/caches the project profile, runs check
|
|
27
|
-
* pipelines, records normalized results with a working-tree fingerprint for
|
|
28
|
-
* staleness, bounds the repair loop, and prunes run logs to a retention set.
|
|
29
|
-
*/
|
|
30
|
-
export class QaOrchestrator {
|
|
31
|
-
workspace;
|
|
32
|
-
state = emptyQaState();
|
|
33
|
-
profileEntry;
|
|
34
|
-
lastRunFingerprint;
|
|
35
|
-
qaRoot;
|
|
36
|
-
constructor(workspace) {
|
|
37
|
-
this.workspace = workspace;
|
|
38
|
-
this.qaRoot = path.join(workspace, '.andorra', 'runtime', 'qa');
|
|
39
|
-
}
|
|
40
|
-
async getProfile(signal) {
|
|
41
|
-
const derived = await deriveProfile(this.workspace);
|
|
42
|
-
if (!this.profileEntry || this.profileEntry.fingerprint !== derived.fingerprint)
|
|
43
|
-
this.profileEntry = derived;
|
|
44
|
-
signal.throwIfAborted();
|
|
45
|
-
return this.profileEntry.profile;
|
|
46
|
-
}
|
|
47
|
-
/** Every command this session could execute under the current profile, for pre-flight policy checks. */
|
|
48
|
-
plannedCommands(profile) {
|
|
49
|
-
const commands = [];
|
|
50
|
-
for (const key of ['lint', 'typecheck', 'unit', 'build', 'e2e']) {
|
|
51
|
-
const spec = profile.qa[key];
|
|
52
|
-
if (spec)
|
|
53
|
-
commands.push(spec.command);
|
|
54
|
-
}
|
|
55
|
-
if (profile.startup)
|
|
56
|
-
commands.push(profile.startup.command);
|
|
57
|
-
if (profile.security.dependencyScan)
|
|
58
|
-
commands.push(`${profile.project.packageManager ?? 'npm'} audit --json`);
|
|
59
|
-
if (profile.security.semgrep)
|
|
60
|
-
commands.push('semgrep scan --error --config p/default --metrics off');
|
|
61
|
-
return commands;
|
|
62
|
-
}
|
|
63
|
-
async profileSummary(signal) {
|
|
64
|
-
const profile = await this.getProfile(signal);
|
|
65
|
-
const lines = [
|
|
66
|
-
`language=${profile.project.language}${profile.project.framework ? ` framework=${profile.project.framework}` : ''}${profile.project.packageManager ? ` packageManager=${profile.project.packageManager}` : ''}`,
|
|
67
|
-
...['lint', 'typecheck', 'unit', 'build', 'e2e'].map(key => `qa.${key}: ${profile.qa[key]?.command ?? 'not configured'}`),
|
|
68
|
-
profile.startup ? `startup: ${profile.startup.command}${profile.startup.healthUrl ? ` (health ${profile.startup.healthUrl})` : ''}` : 'startup: not configured',
|
|
69
|
-
`browser: ${profile.browser.enabled ? `enabled${profile.browser.url ? ` url=${profile.browser.url}` : ' (no url configured)'}` : 'disabled'}`,
|
|
70
|
-
`merge gate: ${profile.mergeGate.join(', ')}`,
|
|
71
|
-
profile.configError ? `qa.yaml error: ${profile.configError}` : undefined,
|
|
72
|
-
].filter((line) => line !== undefined);
|
|
73
|
-
return (await lines.join('\n')) + `\n${await describeRuntimeCapabilities()}`;
|
|
74
|
-
}
|
|
75
|
-
async newRun(signal) {
|
|
76
|
-
const runId = shortRunId();
|
|
77
|
-
const logDir = path.join(this.qaRoot, runId);
|
|
78
|
-
await mkdir(logDir, { recursive: true });
|
|
79
|
-
await this.pruneLogs();
|
|
80
|
-
signal.throwIfAborted();
|
|
81
|
-
return { runId, logDir };
|
|
82
|
-
}
|
|
83
|
-
async pruneLogs() {
|
|
84
|
-
try {
|
|
85
|
-
const entries = await readdir(this.qaRoot, { withFileTypes: true });
|
|
86
|
-
const dirs = entries.filter(entry => entry.isDirectory() && entry.name !== 'processes').map(entry => entry.name);
|
|
87
|
-
if (dirs.length <= LOG_RETENTION)
|
|
88
|
-
return;
|
|
89
|
-
const stats = await Promise.all(dirs.map(async (name) => ({ name, mtime: (await statMtime(path.join(this.qaRoot, name))).getTime() })));
|
|
90
|
-
stats.sort((a, b) => b.mtime - a.mtime);
|
|
91
|
-
await Promise.all(stats.slice(LOG_RETENTION).map(entry => rm(path.join(this.qaRoot, entry.name), { recursive: true, force: true })));
|
|
92
|
-
}
|
|
93
|
-
catch { /* pruning is best-effort */ }
|
|
94
|
-
}
|
|
95
|
-
async audit(record) {
|
|
96
|
-
try {
|
|
97
|
-
await mkdir(this.qaRoot, { recursive: true });
|
|
98
|
-
await appendFile(path.join(this.qaRoot, 'audit.ndjson'), `${JSON.stringify(record)}\n`, 'utf8');
|
|
99
|
-
}
|
|
100
|
-
catch { /* audit is best-effort */ }
|
|
101
|
-
}
|
|
102
|
-
record(result, fingerprint, profile) {
|
|
103
|
-
let stored = result;
|
|
104
|
-
if (result.status === 'failed') {
|
|
105
|
-
const count = (this.state.failureCounts[result.id] ?? 0) + 1;
|
|
106
|
-
this.state.failureCounts[result.id] = count;
|
|
107
|
-
if (profile.autoRepair.enabled && count >= profile.autoRepair.maxAttemptsPerCheck) {
|
|
108
|
-
stored = { ...stored, repairExhausted: true, summary: `BLOCKED: ${result.id} still fails after ${count} repair attempts. ${stored.summary}` };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else if (result.status === 'passed') {
|
|
112
|
-
this.state.failureCounts[result.id] = 0;
|
|
113
|
-
}
|
|
114
|
-
stored = { ...stored, fingerprint };
|
|
115
|
-
this.state.checks[stored.id] = stored;
|
|
116
|
-
return stored;
|
|
117
|
-
}
|
|
118
|
-
verdictFor(results) {
|
|
119
|
-
if (results.some(result => result.status === 'failed'))
|
|
120
|
-
return 'issues';
|
|
121
|
-
if (results.some(result => result.status === 'blocked'))
|
|
122
|
-
return 'blocked';
|
|
123
|
-
return 'clean';
|
|
124
|
-
}
|
|
125
|
-
/** qa.fast: lint, typecheck, related tests, optional build, diff review and secret scan. */
|
|
126
|
-
async fast(options) {
|
|
127
|
-
const profile = await this.getProfile(options.signal);
|
|
128
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal: options.signal });
|
|
129
|
-
const { runId, logDir } = await this.newRun(options.signal);
|
|
130
|
-
const results = [];
|
|
131
|
-
const command = async (id, category, key, defaultTimeoutMs) => {
|
|
132
|
-
const spec = profile.qa[key];
|
|
133
|
-
if (!spec)
|
|
134
|
-
return { id, category, status: 'skipped', durationMs: 0, summary: `no ${key} command configured or detected` };
|
|
135
|
-
await options.authorize?.(spec.command);
|
|
136
|
-
const result = await runCommandCheck({ id, category, command: spec, workspace: this.workspace, logDir, defaultTimeoutMs, signal: options.signal });
|
|
137
|
-
await this.audit({ time: new Date().toISOString(), runId, id, command: spec.command, status: result.status, durationMs: result.durationMs });
|
|
138
|
-
return result;
|
|
139
|
-
};
|
|
140
|
-
results.push(await command('lint', 'lint', 'lint', LINT_TIMEOUT_MS));
|
|
141
|
-
results.push(await command('typecheck', 'typecheck', 'typecheck', LINT_TIMEOUT_MS));
|
|
142
|
-
const relatedFiles = changeSet.changedFiles;
|
|
143
|
-
if (!relatedFiles.length) {
|
|
144
|
-
results.push({ id: 'related_tests', category: 'unit', status: 'skipped', durationMs: 0, summary: 'no changed files to scope tests to' });
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const built = buildTestCommand(profile, { mode: 'related', files: relatedFiles });
|
|
148
|
-
if (built.blocked || !built.command) {
|
|
149
|
-
results.push({ id: 'related_tests', category: 'unit', status: 'blocked', durationMs: 0, summary: built.blocked ?? 'test command could not be built' });
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
await options.authorize?.(built.command);
|
|
153
|
-
const result = await runCommandCheck({ id: 'related_tests', category: 'unit', command: { command: built.command, timeoutMs: built.timeoutMs }, workspace: this.workspace, logDir, defaultTimeoutMs: TEST_TIMEOUT_MS, signal: options.signal });
|
|
154
|
-
if (built.note)
|
|
155
|
-
result.summary = `${result.summary} (${built.note})`;
|
|
156
|
-
await this.audit({ time: new Date().toISOString(), runId, id: 'related_tests', command: built.command, status: result.status, durationMs: result.durationMs });
|
|
157
|
-
results.push(result);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (options.includeBuild)
|
|
161
|
-
results.push(await command('build', 'build', 'build', TEST_TIMEOUT_MS));
|
|
162
|
-
else
|
|
163
|
-
results.push({ id: 'build', category: 'build', status: 'skipped', durationMs: 0, summary: 'build not requested; pass includeBuild to run it' });
|
|
164
|
-
const secretHits = scanAddedLinesForSecrets(changeSet.diff ?? '');
|
|
165
|
-
results.push(secretHits.length
|
|
166
|
-
? { id: 'secret_scan', category: 'security', status: 'failed', durationMs: 0, summary: `${secretHits.length} possible secret(s) added to the working tree`, errors: secretHits }
|
|
167
|
-
: { id: 'secret_scan', category: 'security', status: 'passed', durationMs: 0, summary: 'no credential-shaped strings added to the diff' });
|
|
168
|
-
const review = reviewDiff(changeSet, []);
|
|
169
|
-
results.push({
|
|
170
|
-
id: 'diff_review', category: 'diff',
|
|
171
|
-
status: review.passed ? 'passed' : 'failed',
|
|
172
|
-
durationMs: 0,
|
|
173
|
-
summary: `${review.stats.filesChanged} files, +${review.stats.insertions}/-${review.stats.deletions}: ${review.passed ? 'no blocking findings' : `${review.issues.filter(issue => issue.severity === 'error').length} blocking finding(s)`}`,
|
|
174
|
-
errors: review.issues.length ? review.issues : undefined,
|
|
175
|
-
});
|
|
176
|
-
const recorded = results.map(result => this.record(result, changeSet.fingerprint, profile));
|
|
177
|
-
this.state.lastFastRun = runId;
|
|
178
|
-
this.lastRunFingerprint = changeSet.fingerprint;
|
|
179
|
-
this.state.changedSinceLastQa = false;
|
|
180
|
-
return { runId, fingerprint: changeSet.fingerprint, results: recorded, verdict: this.verdictFor(recorded), changedFiles: changeSet.changedFiles };
|
|
181
|
-
}
|
|
182
|
-
/** qa.test: run the unit suite scoped by mode. */
|
|
183
|
-
async test(request, options) {
|
|
184
|
-
const { signal, authorize } = options;
|
|
185
|
-
const profile = await this.getProfile(signal);
|
|
186
|
-
const built = buildTestCommand(profile, request);
|
|
187
|
-
if (built.blocked || !built.command) {
|
|
188
|
-
return { id: 'related_tests', category: 'unit', status: 'blocked', durationMs: 0, summary: built.blocked ?? 'test command could not be built' };
|
|
189
|
-
}
|
|
190
|
-
const { runId, logDir } = await this.newRun(signal);
|
|
191
|
-
await authorize?.(built.command);
|
|
192
|
-
const result = await runCommandCheck({ id: 'related_tests', category: 'unit', command: { command: built.command, timeoutMs: built.timeoutMs }, workspace: this.workspace, logDir, defaultTimeoutMs: TEST_TIMEOUT_MS, signal });
|
|
193
|
-
if (built.note)
|
|
194
|
-
result.summary = `${result.summary} (${built.note})`;
|
|
195
|
-
await this.audit({ time: new Date().toISOString(), runId, id: 'related_tests', mode: request.mode, command: built.command, status: result.status, durationMs: result.durationMs });
|
|
196
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
197
|
-
return this.record(result, changeSet.fingerprint, profile);
|
|
198
|
-
}
|
|
199
|
-
/** qa.security: built-in secret scan, dependency audit, and semgrep when enabled. */
|
|
200
|
-
async security(options) {
|
|
201
|
-
const { signal, authorize } = options;
|
|
202
|
-
const profile = await this.getProfile(signal);
|
|
203
|
-
const { runId, logDir } = await this.newRun(signal);
|
|
204
|
-
const results = [];
|
|
205
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
206
|
-
const secretHits = scanAddedLinesForSecrets(changeSet.diff ?? '');
|
|
207
|
-
results.push(this.record(secretHits.length
|
|
208
|
-
? { id: 'secret_scan', category: 'security', status: 'failed', durationMs: 0, summary: `${secretHits.length} possible secret(s) added to the working tree`, errors: secretHits }
|
|
209
|
-
: { id: 'secret_scan', category: 'security', status: 'passed', durationMs: 0, summary: 'no credential-shaped strings added to the diff' }, changeSet.fingerprint, profile));
|
|
210
|
-
if (profile.security.dependencyScan) {
|
|
211
|
-
await authorize?.(`${profile.project.packageManager ?? 'npm'} audit --json`);
|
|
212
|
-
const audit = await runDependencyAudit({ workspace: this.workspace, packageManager: profile.project.packageManager, failOn: profile.security.failOn, signal });
|
|
213
|
-
results.push(this.record({
|
|
214
|
-
id: 'dependency_audit', category: 'security', status: audit.status, durationMs: audit.durationMs,
|
|
215
|
-
summary: audit.summary, errors: audit.issues.length ? audit.issues : undefined,
|
|
216
|
-
importantOutput: audit.importantOutput.length ? audit.importantOutput : undefined,
|
|
217
|
-
}, changeSet.fingerprint, profile));
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
results.push({ id: 'dependency_audit', category: 'security', status: 'skipped', durationMs: 0, summary: 'dependency scan disabled in configuration' });
|
|
221
|
-
}
|
|
222
|
-
if (profile.security.semgrep) {
|
|
223
|
-
results.push(this.record(await this.semgrepCheck(logDir, runId, signal, authorize), changeSet.fingerprint, profile));
|
|
224
|
-
}
|
|
225
|
-
return results;
|
|
226
|
-
}
|
|
227
|
-
async semgrepCheck(logDir, runId, signal, authorize) {
|
|
228
|
-
try {
|
|
229
|
-
await executeShell('semgrep --version', this.workspace, 10_000, signal);
|
|
230
|
-
}
|
|
231
|
-
catch {
|
|
232
|
-
return { id: 'semgrep', category: 'security', status: 'blocked', durationMs: 0, summary: 'semgrep is enabled in configuration but not installed' };
|
|
233
|
-
}
|
|
234
|
-
const command = 'semgrep scan --error --config p/default --metrics off';
|
|
235
|
-
await authorize?.(command);
|
|
236
|
-
const result = await runCommandCheck({ id: 'semgrep', category: 'security', command: { command }, workspace: this.workspace, logDir, defaultTimeoutMs: 300_000, signal });
|
|
237
|
-
await this.audit({ time: new Date().toISOString(), runId, id: 'semgrep', status: result.status, durationMs: result.durationMs });
|
|
238
|
-
return result;
|
|
239
|
-
}
|
|
240
|
-
/** qa.browser: load a URL in Playwright and report smoke/console/network(/a11y). */
|
|
241
|
-
async browser(options) {
|
|
242
|
-
const profile = await this.getProfile(options.signal);
|
|
243
|
-
const outcome = await runBrowserQa({ workspace: this.workspace, profile, ...(options.url ? { url: options.url } : {}), ...(options.accessibility !== undefined ? { accessibility: options.accessibility } : {}), signal: options.signal });
|
|
244
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal: options.signal });
|
|
245
|
-
const results = [outcome.smoke, outcome.consoleErrors, outcome.networkErrors, ...(outcome.accessibility ? [outcome.accessibility] : [])];
|
|
246
|
-
return results.map(result => this.record(result, changeSet.fingerprint, profile));
|
|
247
|
-
}
|
|
248
|
-
/** qa.deep: the full dynamic merge gate over the current change set. */
|
|
249
|
-
async deep(options) {
|
|
250
|
-
const { signal, authorize } = options;
|
|
251
|
-
const profile = await this.getProfile(signal);
|
|
252
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
253
|
-
const classification = classifyChanges(changeSet.changedFiles);
|
|
254
|
-
const steps = options.checks?.length ? options.checks : computeMergeGate(profile, classification);
|
|
255
|
-
const { runId, logDir } = await this.newRun(signal);
|
|
256
|
-
const results = [];
|
|
257
|
-
let browserOutcome;
|
|
258
|
-
for (const step of steps) {
|
|
259
|
-
signal.throwIfAborted();
|
|
260
|
-
if (step === 'browser_smoke' || step === 'console_errors' || step === 'network_errors' || step === 'accessibility') {
|
|
261
|
-
browserOutcome ??= await runBrowserQa({ workspace: this.workspace, profile, signal });
|
|
262
|
-
const pick = step === 'browser_smoke' ? browserOutcome.smoke
|
|
263
|
-
: step === 'console_errors' ? browserOutcome.consoleErrors
|
|
264
|
-
: step === 'network_errors' ? browserOutcome.networkErrors
|
|
265
|
-
: browserOutcome.accessibility ?? { id: 'accessibility', category: 'accessibility', status: 'skipped', durationMs: 0, summary: 'accessibility not requested' };
|
|
266
|
-
results.push(pick);
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
results.push(await this.gateStep(step, profile, changeSet.changedFiles, { runId, logDir }, signal, authorize));
|
|
270
|
-
}
|
|
271
|
-
const recorded = results.map(result => this.record(result, changeSet.fingerprint, profile));
|
|
272
|
-
const verdict = gateVerdict(recorded);
|
|
273
|
-
this.state.lastDeepRun = runId;
|
|
274
|
-
this.state.mergeReady = verdict === 'ready';
|
|
275
|
-
this.state.lastGateVerdict = verdict;
|
|
276
|
-
this.lastRunFingerprint = changeSet.fingerprint;
|
|
277
|
-
this.state.changedSinceLastQa = false;
|
|
278
|
-
return { runId, fingerprint: changeSet.fingerprint, results: recorded, verdict: verdict === 'ready' ? 'clean' : verdict === 'failed' ? 'issues' : 'blocked', changedFiles: changeSet.changedFiles, gate: { steps, verdict } };
|
|
279
|
-
}
|
|
280
|
-
async gateStep(step, profile, changedFiles, run, signal, authorize) {
|
|
281
|
-
switch (step) {
|
|
282
|
-
case 'lint':
|
|
283
|
-
case 'typecheck':
|
|
284
|
-
case 'build': {
|
|
285
|
-
const spec = profile.qa[step];
|
|
286
|
-
if (!spec)
|
|
287
|
-
return { id: step, category: step, status: 'skipped', durationMs: 0, summary: `no ${step} command configured or detected` };
|
|
288
|
-
await authorize?.(spec.command);
|
|
289
|
-
const result = await runCommandCheck({ id: step, category: step, command: spec, workspace: this.workspace, logDir: run.logDir, defaultTimeoutMs: step === 'build' ? TEST_TIMEOUT_MS : LINT_TIMEOUT_MS, signal });
|
|
290
|
-
await this.audit({ time: new Date().toISOString(), runId: run.runId, id: step, command: spec.command, status: result.status, durationMs: result.durationMs });
|
|
291
|
-
return result;
|
|
292
|
-
}
|
|
293
|
-
case 'related_tests': {
|
|
294
|
-
if (!changedFiles.length)
|
|
295
|
-
return { id: 'related_tests', category: 'unit', status: 'skipped', durationMs: 0, summary: 'no changed files to test' };
|
|
296
|
-
const built = buildTestCommand(profile, { mode: 'related', files: changedFiles });
|
|
297
|
-
if (built.blocked || !built.command)
|
|
298
|
-
return { id: 'related_tests', category: 'unit', status: 'blocked', durationMs: 0, summary: built.blocked ?? 'test command could not be built' };
|
|
299
|
-
await authorize?.(built.command);
|
|
300
|
-
const result = await runCommandCheck({ id: 'related_tests', category: 'unit', command: { command: built.command, timeoutMs: built.timeoutMs }, workspace: this.workspace, logDir: run.logDir, defaultTimeoutMs: TEST_TIMEOUT_MS, signal });
|
|
301
|
-
if (built.note)
|
|
302
|
-
result.summary = `${result.summary} (${built.note})`;
|
|
303
|
-
await this.audit({ time: new Date().toISOString(), runId: run.runId, id: 'related_tests', command: built.command, status: result.status, durationMs: result.durationMs });
|
|
304
|
-
return result;
|
|
305
|
-
}
|
|
306
|
-
case 'diff_review': {
|
|
307
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
308
|
-
const review = reviewDiff(changeSet, []);
|
|
309
|
-
const blocking = review.issues.filter(issue => issue.severity === 'error').length;
|
|
310
|
-
return {
|
|
311
|
-
id: 'diff_review', category: 'diff', status: review.passed ? 'passed' : 'failed', durationMs: 0,
|
|
312
|
-
summary: `${review.stats.filesChanged} files, +${review.stats.insertions}/-${review.stats.deletions}: ${review.passed ? 'no blocking findings' : `${blocking} blocking finding(s)`}`,
|
|
313
|
-
errors: review.issues.length ? review.issues : undefined,
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
case 'secret_scan': {
|
|
317
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
318
|
-
const secretHits = scanAddedLinesForSecrets(changeSet.diff ?? '');
|
|
319
|
-
return secretHits.length
|
|
320
|
-
? { id: 'secret_scan', category: 'security', status: 'failed', durationMs: 0, summary: `${secretHits.length} possible secret(s) added to the working tree`, errors: secretHits }
|
|
321
|
-
: { id: 'secret_scan', category: 'security', status: 'passed', durationMs: 0, summary: 'no credential-shaped strings added to the diff' };
|
|
322
|
-
}
|
|
323
|
-
case 'dependency_audit': {
|
|
324
|
-
if (!profile.security.dependencyScan)
|
|
325
|
-
return { id: 'dependency_audit', category: 'security', status: 'skipped', durationMs: 0, summary: 'dependency scan disabled in configuration' };
|
|
326
|
-
await authorize?.(`${profile.project.packageManager ?? 'npm'} audit --json`);
|
|
327
|
-
const audit = await runDependencyAudit({ workspace: this.workspace, packageManager: profile.project.packageManager, failOn: profile.security.failOn, signal });
|
|
328
|
-
return { id: 'dependency_audit', category: 'security', status: audit.status, durationMs: audit.durationMs, summary: audit.summary, errors: audit.issues.length ? audit.issues : undefined, importantOutput: audit.importantOutput.length ? audit.importantOutput : undefined };
|
|
329
|
-
}
|
|
330
|
-
case 'runtime_smoke': {
|
|
331
|
-
if (profile.startup)
|
|
332
|
-
await authorize?.(profile.startup.command);
|
|
333
|
-
return runRuntimeSmoke({ workspace: this.workspace, profile, logDir: run.logDir, signal });
|
|
334
|
-
}
|
|
335
|
-
case 'api_smoke':
|
|
336
|
-
return runApiSmokeTests(profile.apiSmokeTests, signal);
|
|
337
|
-
case 'migration_validation':
|
|
338
|
-
return { id: 'migration_validation', category: 'runtime', status: 'skipped', durationMs: 0, summary: 'migration validation is not implemented in this release; run migrations against a scratch database' };
|
|
339
|
-
case 'semgrep':
|
|
340
|
-
return this.semgrepCheck(run.logDir, run.runId, signal, authorize);
|
|
341
|
-
default:
|
|
342
|
-
return { id: step, category: 'runtime', status: 'skipped', durationMs: 0, summary: `gate step "${step}" is not implemented in this release` };
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
/** qa.status: session view — profile summary, last results, staleness, gate verdict. */
|
|
346
|
-
async status(signal) {
|
|
347
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
348
|
-
if (this.lastRunFingerprint !== undefined)
|
|
349
|
-
this.state.changedSinceLastQa = changeSet.fingerprint !== this.lastRunFingerprint;
|
|
350
|
-
return { summary: await this.profileSummary(signal), state: this.state };
|
|
351
|
-
}
|
|
352
|
-
/** True when results recorded at the last run no longer reflect the tree. */
|
|
353
|
-
isStale(currentFingerprint) {
|
|
354
|
-
return this.lastRunFingerprint !== undefined && this.lastRunFingerprint !== currentFingerprint;
|
|
355
|
-
}
|
|
356
|
-
async changeSnapshot(signal) {
|
|
357
|
-
const changeSet = await detectChanges({ cwd: this.workspace, signal });
|
|
358
|
-
return { changedFiles: changeSet.changedFiles, classification: classifyChanges(changeSet.changedFiles), fingerprint: changeSet.fingerprint };
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
async function statMtime(target) {
|
|
362
|
-
const { stat } = await import('node:fs/promises');
|
|
363
|
-
return (await stat(target)).mtime;
|
|
364
|
-
}
|
|
365
|
-
const orchestrators = new Map();
|
|
366
|
-
export function getQaOrchestrator(workspace) {
|
|
367
|
-
let orchestrator = orchestrators.get(workspace);
|
|
368
|
-
if (!orchestrator) {
|
|
369
|
-
orchestrator = new QaOrchestrator(workspace);
|
|
370
|
-
orchestrators.set(workspace, orchestrator);
|
|
371
|
-
}
|
|
372
|
-
return orchestrator;
|
|
373
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { QaCheckCategory, QaCheckResult, QaCommandSpec, QaIssue } from '../types.js';
|
|
2
|
-
export declare const QA_MAX_TIMEOUT_MS = 900000;
|
|
3
|
-
/** Extract actionable error lines from mixed stdout/stderr without shipping whole logs to the model. */
|
|
4
|
-
export declare function extractImportantOutput(text: string): string[];
|
|
5
|
-
/** Parse common toolchain failure formats (tsc, eslint stylish, jest/vitest, pytest) into issues. */
|
|
6
|
-
export declare function parseToolOutput(text: string): QaIssue[];
|
|
7
|
-
export interface CommandCheckOptions {
|
|
8
|
-
id: string;
|
|
9
|
-
category: QaCheckCategory;
|
|
10
|
-
command: QaCommandSpec;
|
|
11
|
-
workspace: string;
|
|
12
|
-
/** Directory receiving `<id>.log` for this run (absolute). */
|
|
13
|
-
logDir: string;
|
|
14
|
-
defaultTimeoutMs: number;
|
|
15
|
-
signal: AbortSignal;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Run one QA command through the structured shell and normalize the outcome:
|
|
19
|
-
* exit 0 passed, nonzero/timeout failed, spawn failure blocked. Full output is
|
|
20
|
-
* written to the QA run log directory and only bounded error lines are returned.
|
|
21
|
-
*/
|
|
22
|
-
export declare function runCommandCheck(options: CommandCheckOptions): Promise<QaCheckResult>;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { executeShell } from '../../shell.js';
|
|
4
|
-
export const QA_MAX_TIMEOUT_MS = 900_000;
|
|
5
|
-
const IMPORTANT_LINES = 15;
|
|
6
|
-
const IMPORTANT_LINE_WIDTH = 300;
|
|
7
|
-
/** Extract actionable error lines from mixed stdout/stderr without shipping whole logs to the model. */
|
|
8
|
-
export function extractImportantOutput(text) {
|
|
9
|
-
const important = [];
|
|
10
|
-
for (const line of text.split('\n')) {
|
|
11
|
-
const trimmed = line.trim();
|
|
12
|
-
if (!trimmed || trimmed.length > 2_000)
|
|
13
|
-
continue;
|
|
14
|
-
if (/\berror\b|Error:|FAILED|FAIL\b|✕|not ok|\bpanic\b|Traceback|assert|exit code/i.test(trimmed)) {
|
|
15
|
-
important.push(trimmed.slice(0, IMPORTANT_LINE_WIDTH));
|
|
16
|
-
if (important.length >= IMPORTANT_LINES)
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return important;
|
|
21
|
-
}
|
|
22
|
-
/** Parse common toolchain failure formats (tsc, eslint stylish, jest/vitest, pytest) into issues. */
|
|
23
|
-
export function parseToolOutput(text) {
|
|
24
|
-
const issues = [];
|
|
25
|
-
for (const line of text.split('\n')) {
|
|
26
|
-
const tsc = /^\s*(.+?)\((\d+),(\d+)\): error TS\d+: (.*)$/.exec(line) ?? /^(.+?):(\d+):(\d+) - error TS\d+: (.*)$/.exec(line);
|
|
27
|
-
if (tsc) {
|
|
28
|
-
issues.push({ file: tsc[1].trim(), line: Number(tsc[2]), column: Number(tsc[3]), severity: 'error', message: tsc[4].trim(), code: 'typecheck' });
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const stylish = /^\s+\d+:\d+\s+(error|warning)\s+(.+?)(?:\s{2,}([\w@/-]+))?\s*$/.exec(line);
|
|
32
|
-
if (stylish) {
|
|
33
|
-
issues.push({ severity: stylish[1] === 'error' ? 'error' : 'warning', message: stylish[2].trim(), code: stylish[3]?.trim() || 'lint' });
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const golang = /^.+?:\d+:\d+: (.*(?:expected|undefined|declared|imported))/.exec(line);
|
|
37
|
-
if (golang) {
|
|
38
|
-
issues.push({ severity: 'error', message: golang[1].trim(), code: 'lint' });
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const testFail = /^\s*(?:FAIL|✕|×|not ok|FAILED)\s+(\S.*?)\s*(?:\(\d+ms\))?\s*$/.exec(line);
|
|
42
|
-
if (testFail) {
|
|
43
|
-
const fileMatch = /^(\S+\.[a-z]+)(?:\s*[>»-]\s*(.*))?$/.exec(testFail[1].trim());
|
|
44
|
-
issues.push({ file: fileMatch?.[1], severity: 'error', message: fileMatch?.[2] ? `test failed: ${fileMatch[2].trim()}` : 'test file failed', code: 'test-failure' });
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return issues.slice(0, 25);
|
|
48
|
-
}
|
|
49
|
-
function firstFailureLine(text) {
|
|
50
|
-
return text.split('\n').map(line => line.trim()).filter(line => /\berror\b|Error:|FAILED|FAIL\b|✕|not ok|Traceback|assert/i.test(line))[0];
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Run one QA command through the structured shell and normalize the outcome:
|
|
54
|
-
* exit 0 passed, nonzero/timeout failed, spawn failure blocked. Full output is
|
|
55
|
-
* written to the QA run log directory and only bounded error lines are returned.
|
|
56
|
-
*/
|
|
57
|
-
export async function runCommandCheck(options) {
|
|
58
|
-
const timeout = Math.min(Math.max(options.command.timeoutMs ?? options.defaultTimeoutMs, 1_000), QA_MAX_TIMEOUT_MS);
|
|
59
|
-
let result;
|
|
60
|
-
try {
|
|
61
|
-
result = await executeShell(options.command.command, options.workspace, timeout, options.signal);
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
65
|
-
if (/aborted/i.test(message))
|
|
66
|
-
throw error;
|
|
67
|
-
return { id: options.id, category: options.category, status: 'blocked', durationMs: 0, summary: `could not start "${options.command.command}": ${message.split('\n')[0]}` };
|
|
68
|
-
}
|
|
69
|
-
const combined = `${result.stdout}${result.stderr ? `\n${result.stderr}` : ''}`;
|
|
70
|
-
const logDir = options.logDir;
|
|
71
|
-
await mkdir(logDir, { recursive: true });
|
|
72
|
-
const logPath = path.join(logDir, `${options.id}.log`);
|
|
73
|
-
await writeFile(logPath, `$ ${options.command.command}\n${combined}`, 'utf8');
|
|
74
|
-
const logRef = path.relative(options.workspace, logPath).split(path.sep).join('/');
|
|
75
|
-
const durationMs = result.durationMs;
|
|
76
|
-
if (result.timedOut) {
|
|
77
|
-
return {
|
|
78
|
-
id: options.id, category: options.category, status: 'failed', durationMs,
|
|
79
|
-
summary: `timed out after ${Math.round(timeout / 1000)}s`, logRef,
|
|
80
|
-
importantOutput: extractImportantOutput(combined),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (result.exitCode !== 0) {
|
|
84
|
-
const failures = parseToolOutput(combined);
|
|
85
|
-
const important = extractImportantOutput(combined);
|
|
86
|
-
const firstLine = firstFailureLine(combined);
|
|
87
|
-
return {
|
|
88
|
-
id: options.id, category: options.category, status: 'failed', durationMs,
|
|
89
|
-
summary: `"${options.command.command}" exited ${result.exitCode ?? result.exitSignal}${firstLine ? `: ${firstLine.slice(0, 200)}` : ''}`,
|
|
90
|
-
errors: failures.length ? failures : undefined,
|
|
91
|
-
importantOutput: important.length ? important : undefined,
|
|
92
|
-
logRef,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
return { id: options.id, category: options.category, status: 'passed', durationMs, summary: `"${options.command.command}" passed`, logRef };
|
|
96
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { QaProfile } from '../types.js';
|
|
2
|
-
export type QaTestMode = 'related' | 'file' | 'pattern' | 'all';
|
|
3
|
-
export interface TestCommandRequest {
|
|
4
|
-
mode: QaTestMode;
|
|
5
|
-
files?: string[];
|
|
6
|
-
pattern?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface TestCommandOutcome {
|
|
9
|
-
/** Absent when the mode cannot run (no unit command, missing arguments). */
|
|
10
|
-
command?: string;
|
|
11
|
-
timeoutMs?: number;
|
|
12
|
-
note?: string;
|
|
13
|
-
/** Human-readable reason the requested scope could not run as asked. */
|
|
14
|
-
blocked?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Translate a targeted test request into a concrete command. Modes that the
|
|
18
|
-
* detected runner cannot scope fall back to the full suite with an explicit
|
|
19
|
-
* degradation note; only a missing unit command blocks the check.
|
|
20
|
-
*/
|
|
21
|
-
export declare function buildTestCommand(profile: QaProfile, request: TestCommandRequest): TestCommandOutcome;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
function quote(value) {
|
|
2
|
-
return `"${value.replace(/[\\"]/g, '\\$&')}"`;
|
|
3
|
-
}
|
|
4
|
-
function joinFiles(files) {
|
|
5
|
-
return files.map(quote).join(' ');
|
|
6
|
-
}
|
|
7
|
-
function isPackageManagerWrapper(command) {
|
|
8
|
-
return /^(npm|pnpm|yarn|bun)(\s+run)?\s/.test(command);
|
|
9
|
-
}
|
|
10
|
-
function appendArgs(unit, args) {
|
|
11
|
-
return isPackageManagerWrapper(unit) ? `${unit} -- ${args}` : `${unit} ${args}`;
|
|
12
|
-
}
|
|
13
|
-
function substitute(template, placeholder, value) {
|
|
14
|
-
return template.split(`{${placeholder}}`).join(value);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Translate a targeted test request into a concrete command. Modes that the
|
|
18
|
-
* detected runner cannot scope fall back to the full suite with an explicit
|
|
19
|
-
* degradation note; only a missing unit command blocks the check.
|
|
20
|
-
*/
|
|
21
|
-
export function buildTestCommand(profile, request) {
|
|
22
|
-
const unit = profile.qa.unit;
|
|
23
|
-
if (!unit)
|
|
24
|
-
return { blocked: 'no unit test command configured or detected for this project' };
|
|
25
|
-
const runner = profile.test?.runner ?? 'other';
|
|
26
|
-
const base = { timeoutMs: unit.timeoutMs };
|
|
27
|
-
switch (request.mode) {
|
|
28
|
-
case 'all':
|
|
29
|
-
return { command: unit.command, ...base };
|
|
30
|
-
case 'related': {
|
|
31
|
-
if (!request.files?.length)
|
|
32
|
-
return { blocked: 'related mode requires files' };
|
|
33
|
-
const files = joinFiles(request.files);
|
|
34
|
-
if (profile.test?.relatedCommand)
|
|
35
|
-
return { command: substitute(profile.test.relatedCommand, 'files', files), ...base };
|
|
36
|
-
if (runner === 'jest')
|
|
37
|
-
return { command: appendArgs(unit.command, `--findRelatedTests ${files} --passWithNoTests`), ...base };
|
|
38
|
-
if (runner === 'vitest')
|
|
39
|
-
return { command: `npx vitest related ${files}`, ...base };
|
|
40
|
-
return { command: unit.command, note: `runner "${runner}" cannot select related tests; ran the full unit suite`, ...base };
|
|
41
|
-
}
|
|
42
|
-
case 'file': {
|
|
43
|
-
if (!request.files?.length)
|
|
44
|
-
return { blocked: 'file mode requires files' };
|
|
45
|
-
const files = joinFiles(request.files);
|
|
46
|
-
if (runner === 'jest' || runner === 'vitest' || runner === 'node' || runner === 'pytest') {
|
|
47
|
-
return { command: appendArgs(unit.command, files), ...base };
|
|
48
|
-
}
|
|
49
|
-
return { command: unit.command, note: `runner "${runner}" cannot target individual files; ran the full unit suite`, ...base };
|
|
50
|
-
}
|
|
51
|
-
case 'pattern': {
|
|
52
|
-
if (!request.pattern)
|
|
53
|
-
return { blocked: 'pattern mode requires a pattern' };
|
|
54
|
-
const pattern = quote(request.pattern);
|
|
55
|
-
if (profile.test?.patternCommand)
|
|
56
|
-
return { command: substitute(profile.test.patternCommand, 'pattern', pattern), ...base };
|
|
57
|
-
switch (runner) {
|
|
58
|
-
case 'jest': return { command: appendArgs(unit.command, `-t ${pattern}`), ...base };
|
|
59
|
-
case 'vitest': return { command: `npx vitest run -t ${pattern}`, ...base };
|
|
60
|
-
case 'node': return { command: appendArgs(unit.command, `--test-name-pattern ${pattern}`), ...base };
|
|
61
|
-
case 'pytest': return { command: appendArgs(unit.command, `-k ${pattern}`), ...base };
|
|
62
|
-
default: return { command: unit.command, note: `runner "${runner}" cannot filter by pattern; ran the full unit suite`, ...base };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { QaCheckResult, QaProfile } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Boot the configured startup command, wait for its health URL (or a short
|
|
4
|
-
* grace window), scan the log for crash signatures, then always stop it.
|
|
5
|
-
*/
|
|
6
|
-
export declare function runRuntimeSmoke(options: {
|
|
7
|
-
workspace: string;
|
|
8
|
-
profile: QaProfile;
|
|
9
|
-
logDir: string;
|
|
10
|
-
signal: AbortSignal;
|
|
11
|
-
}): Promise<QaCheckResult>;
|