mandrel 2.86.0 → 2.88.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/.agents/README.md +29 -0
- package/.agents/agents/auditor.md +4 -3
- package/.agents/docs/agentrc-reference.json +2 -1
- package/.agents/docs/configuration.md +44 -20
- package/.agents/docs/workflows.md +1 -1
- package/.agents/schemas/agentrc.schema.json +18 -12
- package/.agents/schemas/story-deliver-terminal.schema.json +1 -1
- package/.agents/schemas/story-progress.schema.json +5 -0
- package/.agents/scripts/audit-to-stories.js +3 -2
- package/.agents/scripts/boot-sweep.js +3 -2
- package/.agents/scripts/check-arch-cycles.js +19 -41
- package/.agents/scripts/check-context-budget.js +16 -44
- package/.agents/scripts/check-cyclomatic.js +13 -37
- package/.agents/scripts/check-dead-exports.js +16 -46
- package/.agents/scripts/clean-worktrees.js +1 -6
- package/.agents/scripts/coverage-capture.js +23 -3
- package/.agents/scripts/deliver-run.js +11 -0
- package/.agents/scripts/diagnose-friction.js +3 -3
- package/.agents/scripts/lib/baselines/bundle-size-scorer.js +115 -0
- package/.agents/scripts/lib/baselines/coverage-updater-cli.js +122 -29
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +45 -14
- package/.agents/scripts/lib/baselines/duplication-scanner.js +45 -2
- package/.agents/scripts/lib/baselines/env-overrides.js +39 -34
- package/.agents/scripts/lib/baselines/kernel.js +3 -2
- package/.agents/scripts/lib/baselines/kinds/crap.js +14 -38
- package/.agents/scripts/lib/baselines/preview-gates.js +4 -1
- package/.agents/scripts/lib/baselines/refresh-service.js +101 -22
- package/.agents/scripts/lib/baselines/writer.js +5 -1
- package/.agents/scripts/lib/bdd-runner-detect.js +7 -10
- package/.agents/scripts/lib/child-exec.js +14 -1
- package/.agents/scripts/lib/child-stream.js +122 -0
- package/.agents/scripts/lib/clean-temp.js +19 -13
- package/.agents/scripts/lib/cli-args.js +49 -0
- package/.agents/scripts/lib/codex/skills-projection.js +1 -12
- package/.agents/scripts/lib/config/gates/coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/gates/mutation.schema.js +2 -2
- package/.agents/scripts/lib/config/gates/shared.js +1 -1
- package/.agents/scripts/lib/config/gh-config-dir.js +63 -0
- package/.agents/scripts/lib/config/github.js +2 -0
- package/.agents/scripts/lib/config/paths.js +14 -3
- package/.agents/scripts/lib/config/quality.js +6 -2
- package/.agents/scripts/lib/config-resolver.js +78 -64
- package/.agents/scripts/lib/config-settings-schema-delivery.js +4 -3
- package/.agents/scripts/lib/config-settings-schema.js +7 -0
- package/.agents/scripts/lib/coverage-baseline.js +7 -6
- package/.agents/scripts/lib/coverage-capture.js +59 -0
- package/.agents/scripts/lib/crap-utils.js +59 -47
- package/.agents/scripts/lib/full-suite-lock.js +1 -10
- package/.agents/scripts/lib/gates/baseline-store.js +10 -0
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/gh-exec.js +45 -2
- package/.agents/scripts/lib/gh-transport.js +27 -0
- package/.agents/scripts/lib/git-utils.js +16 -9
- package/.agents/scripts/lib/maintainability-engine.js +27 -6
- package/.agents/scripts/lib/maintainability-utils.js +14 -1
- package/.agents/scripts/lib/observability/source-classifier.js +1 -0
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +33 -3
- package/.agents/scripts/lib/orchestration/evidence-stream.js +186 -0
- package/.agents/scripts/lib/orchestration/file-assumptions.js +2 -19
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/branches-reap.js +3 -7
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes-ff.js +34 -40
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +4 -3
- package/.agents/scripts/lib/orchestration/plan-persist/persist-helpers.js +2 -19
- package/.agents/scripts/lib/orchestration/pr-watch.js +1 -5
- package/.agents/scripts/lib/orchestration/project-meta-cache.js +17 -4
- package/.agents/scripts/lib/orchestration/reassert-status-column.js +1 -8
- package/.agents/scripts/lib/orchestration/resolve-stories.js +1 -0
- package/.agents/scripts/lib/orchestration/review-providers/native.js +2 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phase-timer.js +43 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +37 -13
- package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +264 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +68 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +106 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +43 -35
- package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +52 -0
- package/.agents/scripts/lib/orchestration/single-story-close/result.js +273 -0
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +68 -776
- package/.agents/scripts/lib/orchestration/story-close/context-budget-writeback.js +20 -9
- package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +2 -2
- package/.agents/scripts/lib/orchestration/story-close/ratchet-shrink-writeback.js +20 -12
- package/.agents/scripts/lib/orchestration/story-handoff.js +50 -21
- package/.agents/scripts/lib/orchestration/story-progress.js +32 -12
- package/.agents/scripts/lib/orchestration/ticket-validator.js +3 -13
- package/.agents/scripts/lib/qa/resolve-selection.js +1 -8
- package/.agents/scripts/lib/single-story/confirm-and-land.js +33 -0
- package/.agents/scripts/lib/single-story-sweep/reconcile-closing.js +43 -11
- package/.agents/scripts/lib/single-story-sweep/sweep-lock.js +130 -30
- package/.agents/scripts/lib/skills/parse-skill.js +1 -4
- package/.agents/scripts/lib/story-body/story-body.js +12 -1
- package/.agents/scripts/lib/suite-admission.js +3 -11
- package/.agents/scripts/lib/temp-retention.js +25 -11
- package/.agents/scripts/lib/test-run-credit.js +2 -5
- package/.agents/scripts/lib/transpile.js +193 -31
- package/.agents/scripts/lib/util/paths.js +31 -0
- package/.agents/scripts/lib/util/sleep.js +15 -0
- package/.agents/scripts/lib/validation-evidence.js +29 -3
- package/.agents/scripts/lib/wave-runner/live-probe.js +24 -0
- package/.agents/scripts/lib/workers/crap-worker.js +23 -12
- package/.agents/scripts/lib/workers/maintainability-report-worker.js +18 -12
- package/.agents/scripts/lib/workflow-closure.js +1 -8
- package/.agents/scripts/notify.js +83 -90
- package/.agents/scripts/plan-context.js +8 -4
- package/.agents/scripts/providers/github/auth.js +14 -30
- package/.agents/scripts/providers/github/blocked-by-add.js +11 -27
- package/.agents/scripts/providers/github/compose.js +1 -0
- package/.agents/scripts/providers/github/gh-token-diagnostics.js +130 -0
- package/.agents/scripts/providers/github/identity.js +158 -0
- package/.agents/scripts/providers/github/issues.js +2 -2
- package/.agents/scripts/providers/github/mappers.js +16 -19
- package/.agents/scripts/providers/github/projects-v2-graphql.js +4 -36
- package/.agents/scripts/providers/github/request-helpers.js +44 -0
- package/.agents/scripts/providers/github/sub-issue-add.js +11 -28
- package/.agents/scripts/providers/github.js +10 -2
- package/.agents/scripts/quality-preview.js +6 -19
- package/.agents/scripts/single-story-confirm-merge.js +8 -20
- package/.agents/scripts/single-story-init.js +0 -1
- package/.agents/scripts/stories-wave-tick.js +60 -46
- package/.agents/scripts/story-handoff.js +2 -23
- package/.agents/scripts/story-review-compute.js +3 -22
- package/.agents/scripts/sync-claude-agents.js +1 -12
- package/.agents/scripts/sync-claude-commands.js +1 -12
- package/.agents/scripts/update-bundle-size-baseline.js +56 -0
- package/.agents/scripts/update-coverage-baseline.js +16 -41
- package/.agents/scripts/update-crap-baseline.js +10 -19
- package/.agents/scripts/update-duplication-baseline.js +13 -3
- package/.agents/scripts/update-ticket-state.js +44 -45
- package/.agents/templates/docs/audit-sweep-runbook.md +1 -1
- package/.agents/workflows/audit-accessibility.md +1 -1
- package/.agents/workflows/audit-adrs.md +1 -1
- package/.agents/workflows/audit-architecture.md +1 -1
- package/.agents/workflows/audit-baselines.md +2 -2
- package/.agents/workflows/audit-clean-code.md +1 -1
- package/.agents/workflows/audit-data-model.md +1 -1
- package/.agents/workflows/audit-dependencies.md +1 -1
- package/.agents/workflows/audit-devops.md +1 -1
- package/.agents/workflows/audit-documentation.md +1 -1
- package/.agents/workflows/audit-exceptions.md +2 -2
- package/.agents/workflows/audit-mobile.md +1 -1
- package/.agents/workflows/audit-navigability.md +1 -1
- package/.agents/workflows/audit-performance.md +1 -1
- package/.agents/workflows/audit-privacy.md +1 -1
- package/.agents/workflows/audit-quality.md +1 -1
- package/.agents/workflows/audit-security.md +1 -1
- package/.agents/workflows/audit-seo.md +1 -1
- package/.agents/workflows/audit-sre.md +1 -1
- package/.agents/workflows/audit-to-stories.md +9 -7
- package/.agents/workflows/audit-ux-ui.md +1 -1
- package/.agents/workflows/helpers/audit-lens-core.md +8 -5
- package/.agents/workflows/helpers/deliver-digest.md +4 -5
- package/.agents/workflows/helpers/deliver-story-reference.md +4 -4
- package/.agents/workflows/mandrel-deliver.md +3 -1
- package/README.md +6 -3
- package/docs/CHANGELOG.md +36 -0
- package/lib/cli/doctor-checks/codex.js +240 -0
- package/lib/cli/doctor-checks/merge-driver.js +79 -0
- package/lib/cli/doctor-checks/payload.js +201 -0
- package/lib/cli/doctor-checks/read-json.js +16 -0
- package/lib/cli/doctor-checks/runtime-deps.js +146 -0
- package/lib/cli/doctor-checks/spawn.js +18 -0
- package/lib/cli/doctor-checks/sync-parity.js +205 -0
- package/lib/cli/doctor-checks/test-credit-path.js +270 -0
- package/lib/cli/doctor-checks/toolchain.js +137 -0
- package/lib/cli/doctor-checks/version-current.js +82 -0
- package/lib/cli/registry.js +40 -1330
- package/package.json +7 -1
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
import fs from 'node:fs';
|
|
17
17
|
import path from 'node:path';
|
|
18
18
|
import process from 'node:process';
|
|
19
|
+
import { parseGateArgv } from './lib/cli-args.js';
|
|
19
20
|
import { runAsCli } from './lib/cli-utils.js';
|
|
20
21
|
import { resolveConfig } from './lib/config-resolver.js';
|
|
21
22
|
import { resolveDocTiers, tierTotalBytes } from './lib/doc-tiers.js';
|
|
23
|
+
import { readJsonBaseline } from './lib/gates/baseline-store.js';
|
|
24
|
+
|
|
25
|
+
export { readJsonBaseline as loadBaseline };
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* Measured tiers, in report order — only those a session is forced to read.
|
|
@@ -43,48 +47,16 @@ export const DEFAULT_TOLERANCE_BYTES = 2048;
|
|
|
43
47
|
* @returns {{ baselinePath: string|null, rootPath: string|null, update: boolean, json: boolean }}
|
|
44
48
|
*/
|
|
45
49
|
export function parseArgv(argv = []) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
i += 1;
|
|
57
|
-
}
|
|
58
|
-
} else if (a === '--root') {
|
|
59
|
-
const next = argv[i + 1];
|
|
60
|
-
if (next && !next.startsWith('--')) {
|
|
61
|
-
rootPath = next;
|
|
62
|
-
i += 1;
|
|
63
|
-
}
|
|
64
|
-
} else if (a === '--update') {
|
|
65
|
-
update = true;
|
|
66
|
-
} else if (a === '--json') {
|
|
67
|
-
json = true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return { baselinePath, rootPath, update, json };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* `null` when missing or unparseable.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} baselinePath
|
|
77
|
-
* @returns {{ toleranceBytes?: number, tiers?: Record<string, { totalBytes: number, files?: Array<{ path: string, bytes: number }> }> } | null}
|
|
78
|
-
*/
|
|
79
|
-
export function loadBaseline(baselinePath) {
|
|
80
|
-
try {
|
|
81
|
-
if (!fs.existsSync(baselinePath)) return null;
|
|
82
|
-
const parsed = JSON.parse(fs.readFileSync(baselinePath, 'utf-8'));
|
|
83
|
-
if (!parsed || typeof parsed !== 'object') return null;
|
|
84
|
-
return parsed;
|
|
85
|
-
} catch {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
50
|
+
const flags = parseGateArgv(argv, {
|
|
51
|
+
strings: ['baseline', 'root'],
|
|
52
|
+
booleans: ['update', 'json'],
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
baselinePath: flags.baseline,
|
|
56
|
+
rootPath: flags.root,
|
|
57
|
+
update: flags.update,
|
|
58
|
+
json: flags.json,
|
|
59
|
+
};
|
|
88
60
|
}
|
|
89
61
|
|
|
90
62
|
/**
|
|
@@ -300,7 +272,7 @@ function renderAgentBoot(tierMap) {
|
|
|
300
272
|
* @returns {0}
|
|
301
273
|
*/
|
|
302
274
|
function writeUpdatedBaseline({ tierMap, resolvedBaselinePath, json, stdout }) {
|
|
303
|
-
const existing =
|
|
275
|
+
const existing = readJsonBaseline(resolvedBaselinePath);
|
|
304
276
|
const tolerance = Number.isFinite(existing?.toleranceBytes)
|
|
305
277
|
? existing.toleranceBytes
|
|
306
278
|
: DEFAULT_TOLERANCE_BYTES;
|
|
@@ -468,7 +440,7 @@ export async function runCli({
|
|
|
468
440
|
});
|
|
469
441
|
}
|
|
470
442
|
|
|
471
|
-
const baseline =
|
|
443
|
+
const baseline = readJsonBaseline(resolvedBaselinePath);
|
|
472
444
|
if (!baseline) {
|
|
473
445
|
return reportMissingBaseline({
|
|
474
446
|
tierMap,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import process from 'node:process';
|
|
12
|
+
import { parseGateArgv } from './lib/cli-args.js';
|
|
12
13
|
import { runAsCli } from './lib/cli-utils.js';
|
|
13
14
|
import { getQuality, resolveConfig } from './lib/config-resolver.js';
|
|
14
15
|
import {
|
|
@@ -20,47 +21,22 @@ import {
|
|
|
20
21
|
scanCyclomatic,
|
|
21
22
|
} from './lib/cyclomatic-ceiling.js';
|
|
22
23
|
import { resolveScanScope } from './lib/cyclomatic-scope.js';
|
|
24
|
+
import { readJsonBaseline } from './lib/gates/baseline-store.js';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* @param {string[]} argv
|
|
26
28
|
* @returns {{ baselinePath: string | null, json: boolean, update: boolean }}
|
|
27
29
|
*/
|
|
28
30
|
function parseArgv(argv = []) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
i += 1;
|
|
39
|
-
}
|
|
40
|
-
} else if (a === '--json') {
|
|
41
|
-
json = true;
|
|
42
|
-
} else if (a === '--update') {
|
|
43
|
-
update = true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { baselinePath, json, update };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* `null` when missing or unparseable — treated as empty, so a first run
|
|
51
|
-
* reports every breach rather than silently passing.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} baselinePath
|
|
54
|
-
* @returns {{ ceiling?: number, rows?: Array<object> } | null}
|
|
55
|
-
*/
|
|
56
|
-
function loadCyclomaticBaseline(baselinePath) {
|
|
57
|
-
try {
|
|
58
|
-
if (!fs.existsSync(baselinePath)) return null;
|
|
59
|
-
const parsed = JSON.parse(fs.readFileSync(baselinePath, 'utf-8'));
|
|
60
|
-
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
31
|
+
const flags = parseGateArgv(argv, {
|
|
32
|
+
strings: ['baseline'],
|
|
33
|
+
booleans: ['json', 'update'],
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
baselinePath: flags.baseline,
|
|
37
|
+
json: flags.json,
|
|
38
|
+
update: flags.update,
|
|
39
|
+
};
|
|
64
40
|
}
|
|
65
41
|
|
|
66
42
|
/**
|
|
@@ -145,7 +121,7 @@ function warnAboutBaseline({ baseline, mustFix, baselinePath, stderr }) {
|
|
|
145
121
|
* stderr?: { write: (s: string) => void },
|
|
146
122
|
* resolveConfigImpl?: typeof resolveConfig,
|
|
147
123
|
* scanImpl?: typeof scanCyclomatic,
|
|
148
|
-
* loadBaselineImpl?: typeof
|
|
124
|
+
* loadBaselineImpl?: typeof readJsonBaseline,
|
|
149
125
|
* writeFileImpl?: (p: string, data: string) => void,
|
|
150
126
|
* }} [opts]
|
|
151
127
|
* @returns {Promise<number>} 0 = clean / improved; 1 = ratchet breached
|
|
@@ -157,7 +133,7 @@ export async function runCli({
|
|
|
157
133
|
stderr = process.stderr,
|
|
158
134
|
resolveConfigImpl = resolveConfig,
|
|
159
135
|
scanImpl = scanCyclomatic,
|
|
160
|
-
loadBaselineImpl =
|
|
136
|
+
loadBaselineImpl = readJsonBaseline,
|
|
161
137
|
writeFileImpl = (p, data) => fs.writeFileSync(p, data),
|
|
162
138
|
} = {}) {
|
|
163
139
|
const { baselinePath, json, update } = parseArgv(argv);
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* `lib/dead-exports-mode.js`.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import fs from 'node:fs';
|
|
14
13
|
import path from 'node:path';
|
|
15
14
|
import process from 'node:process';
|
|
15
|
+
import { parseGateArgv } from './lib/cli-args.js';
|
|
16
16
|
import { runAsCli } from './lib/cli-utils.js';
|
|
17
17
|
import {
|
|
18
18
|
extractRowsFromKnip,
|
|
@@ -20,6 +20,9 @@ import {
|
|
|
20
20
|
runKnip,
|
|
21
21
|
} from './lib/dead-exports-knip.js';
|
|
22
22
|
import { resolveDeadExportsMode } from './lib/dead-exports-mode.js';
|
|
23
|
+
import { readJsonBaseline } from './lib/gates/baseline-store.js';
|
|
24
|
+
|
|
25
|
+
export { readJsonBaseline as loadBaseline };
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* `--knip-output` is a test seam: a pre-captured knip JSON instead of a spawn.
|
|
@@ -28,49 +31,16 @@ import { resolveDeadExportsMode } from './lib/dead-exports-mode.js';
|
|
|
28
31
|
* @returns {{ baselinePath: string | null, json: boolean, knipOutputPath: string | null, production: boolean }}
|
|
29
32
|
*/
|
|
30
33
|
export function parseArgv(argv = []) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
i += 1;
|
|
42
|
-
}
|
|
43
|
-
} else if (a === '--json') {
|
|
44
|
-
json = true;
|
|
45
|
-
} else if (a === '--production') {
|
|
46
|
-
production = true;
|
|
47
|
-
} else if (a === '--knip-output') {
|
|
48
|
-
const next = argv[i + 1];
|
|
49
|
-
if (next && !next.startsWith('--')) {
|
|
50
|
-
knipOutputPath = next;
|
|
51
|
-
i += 1;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return { baselinePath, json, knipOutputPath, production };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* `null` when missing or unparseable.
|
|
60
|
-
*
|
|
61
|
-
* @param {string} baselinePath
|
|
62
|
-
* @returns {{ kernelVersion?: string, rows?: Array<{file: string, symbol: string}> } | null}
|
|
63
|
-
*/
|
|
64
|
-
export function loadBaseline(baselinePath) {
|
|
65
|
-
try {
|
|
66
|
-
if (!fs.existsSync(baselinePath)) return null;
|
|
67
|
-
const raw = fs.readFileSync(baselinePath, 'utf-8');
|
|
68
|
-
const parsed = JSON.parse(raw);
|
|
69
|
-
if (!parsed || typeof parsed !== 'object') return null;
|
|
70
|
-
return parsed;
|
|
71
|
-
} catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
34
|
+
const flags = parseGateArgv(argv, {
|
|
35
|
+
strings: ['baseline', 'knip-output'],
|
|
36
|
+
booleans: ['json', 'production'],
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
baselinePath: flags.baseline,
|
|
40
|
+
json: flags.json,
|
|
41
|
+
knipOutputPath: flags['knip-output'],
|
|
42
|
+
production: flags.production,
|
|
43
|
+
};
|
|
74
44
|
}
|
|
75
45
|
|
|
76
46
|
/**
|
|
@@ -123,7 +93,7 @@ export function renderDiff(diff, label = 'dead-exports') {
|
|
|
123
93
|
* stdout?: { write: (s: string) => void },
|
|
124
94
|
* stderr?: { write: (s: string) => void },
|
|
125
95
|
* runKnipImpl?: typeof runKnip,
|
|
126
|
-
* loadBaselineImpl?: typeof
|
|
96
|
+
* loadBaselineImpl?: typeof readJsonBaseline,
|
|
127
97
|
* }} [opts]
|
|
128
98
|
* @returns {Promise<number>} exit code: 0 = clean or removals-only; 1 = added exports detected
|
|
129
99
|
*/
|
|
@@ -133,7 +103,7 @@ export async function runCli({
|
|
|
133
103
|
stdout = process.stdout,
|
|
134
104
|
stderr = process.stderr,
|
|
135
105
|
runKnipImpl = runKnip,
|
|
136
|
-
loadBaselineImpl =
|
|
106
|
+
loadBaselineImpl = readJsonBaseline,
|
|
137
107
|
} = {}) {
|
|
138
108
|
const { baselinePath, json, knipOutputPath, production } = parseArgv(argv);
|
|
139
109
|
const {
|
|
@@ -22,6 +22,7 @@ import { spawnCapture } from './lib/child-exec.js';
|
|
|
22
22
|
import { runAsCli } from './lib/cli-utils.js';
|
|
23
23
|
import { PROJECT_ROOT, resolveConfig } from './lib/config-resolver.js';
|
|
24
24
|
import * as defaultGit from './lib/git-utils.js';
|
|
25
|
+
import { STDERR_LOGGER } from './lib/Logger.js';
|
|
25
26
|
import { AGENT_LABELS } from './lib/label-constants.js';
|
|
26
27
|
import { createProvider } from './lib/provider-factory.js';
|
|
27
28
|
import { makeGhRunner } from './lib/single-story-sweep/protection-ctx.js';
|
|
@@ -46,12 +47,6 @@ export const CLASSES = Object.freeze({
|
|
|
46
47
|
const WORKTREE_DIR = '.worktrees';
|
|
47
48
|
|
|
48
49
|
/** Removal-seam diagnostics go to stderr: stdout carries the table / JSON. */
|
|
49
|
-
const STDERR_LOGGER = Object.freeze({
|
|
50
|
-
info: (m) => process.stderr.write(`${m}\n`),
|
|
51
|
-
warn: (m) => process.stderr.write(`${m}\n`),
|
|
52
|
-
error: (m) => process.stderr.write(`${m}\n`),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
50
|
const writeStdout = (text) => process.stdout.write(`${text}\n`);
|
|
56
51
|
|
|
57
52
|
const HELP = `Usage: node .agents/scripts/clean-worktrees.js [options]
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* when the gate is off, no changed file is under `crap.targetDirs`, or the
|
|
5
5
|
* content-digest stamp matches; otherwise run `test:coverage` (or, under
|
|
6
6
|
* `coverage.captureScope: "affected"`, the consumer's `test:coverage:affected`)
|
|
7
|
-
* behind the host-level full-suite lock and stamp on success.
|
|
7
|
+
* behind the host-level full-suite lock and stamp on success. A green run that
|
|
8
|
+
* leaves no artifact at `coveragePath` fails (exit 1) and is never stamped.
|
|
8
9
|
*
|
|
9
10
|
* `--require-credited` must stay an argument, never a config read: as policy
|
|
10
11
|
* it also refused the depositing run, leaving no path that could deposit.
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
creditedCapture,
|
|
22
23
|
filterFilesUnderTargets,
|
|
23
24
|
isCoverageFresh,
|
|
25
|
+
requireCaptureArtifact,
|
|
24
26
|
runCapture,
|
|
25
27
|
writeCaptureStamp,
|
|
26
28
|
} from './lib/coverage-capture.js';
|
|
@@ -67,6 +69,7 @@ export function parseArgs(argv) {
|
|
|
67
69
|
* computeContentDigestImpl?: typeof computeContentDigest,
|
|
68
70
|
* writeCaptureStampImpl?: typeof writeCaptureStamp,
|
|
69
71
|
* filterFilesUnderTargetsImpl?: typeof filterFilesUnderTargets,
|
|
72
|
+
* coverageArtifactExistsImpl?: (absPath: string) => boolean,
|
|
70
73
|
* logger?: { info: Function, warn: Function, error: Function },
|
|
71
74
|
* lockOptions?: object,
|
|
72
75
|
* env?: Record<string, string|undefined>,
|
|
@@ -85,6 +88,7 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
85
88
|
computeContentDigestImpl = computeContentDigest,
|
|
86
89
|
writeCaptureStampImpl = writeCaptureStamp,
|
|
87
90
|
filterFilesUnderTargetsImpl = filterFilesUnderTargets,
|
|
91
|
+
coverageArtifactExistsImpl,
|
|
88
92
|
logger = Logger,
|
|
89
93
|
lockOptions = {},
|
|
90
94
|
env = process.env,
|
|
@@ -110,8 +114,10 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
110
114
|
onLockProgress: lockHooks.onLockProgress,
|
|
111
115
|
...lockOptions,
|
|
112
116
|
});
|
|
113
|
-
const credited =
|
|
114
|
-
|
|
117
|
+
const credited = artifactCheckedCapture(locked, {
|
|
118
|
+
args,
|
|
119
|
+
crap,
|
|
120
|
+
existsSync: coverageArtifactExistsImpl,
|
|
115
121
|
logger,
|
|
116
122
|
});
|
|
117
123
|
let timings = null;
|
|
@@ -142,6 +148,20 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
142
148
|
return code;
|
|
143
149
|
}
|
|
144
150
|
|
|
151
|
+
/**
|
|
152
|
+
* The credited runner, failing a green run that wrote no artifact.
|
|
153
|
+
*
|
|
154
|
+
* @param {Function} locked
|
|
155
|
+
* @param {{ args: object, crap: object, existsSync?: Function, logger: object }} opts
|
|
156
|
+
* @returns {(opts: object) => Promise<number>}
|
|
157
|
+
*/
|
|
158
|
+
function artifactCheckedCapture(locked, { args, crap, existsSync, logger }) {
|
|
159
|
+
return requireCaptureArtifact(
|
|
160
|
+
creditedCapture(locked, { requireCredited: args.requireCredited, logger }),
|
|
161
|
+
{ cwd: args.cwd, coveragePath: crap.coveragePath, existsSync, logger },
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
145
165
|
/** @returns {number|null} The exit code when no capture may run. */
|
|
146
166
|
function refusal({
|
|
147
167
|
crap,
|
|
@@ -19,6 +19,7 @@ import { getPaths, resolveConfig } from './lib/config-resolver.js';
|
|
|
19
19
|
import { Logger } from './lib/Logger.js';
|
|
20
20
|
import { ensureDocsDigest } from './lib/orchestration/docs-digest.js';
|
|
21
21
|
import { resolveResumeEffort } from './lib/orchestration/resume-effort.js';
|
|
22
|
+
import { NEXT_COMMANDS } from './lib/orchestration/story-deliver-terminal.js';
|
|
22
23
|
import { expandIdList } from './lib/util/parse-id-list.js';
|
|
23
24
|
import { runProbedStoriesWaveTick } from './stories-wave-tick.js';
|
|
24
25
|
|
|
@@ -54,6 +55,7 @@ const USAGE = {
|
|
|
54
55
|
'--merge-watch-mode async is added to every close command when the run holds\nmore than one Story, and omitted for a run of one. Close sees a single Story\nand cannot make that call for itself.',
|
|
55
56
|
'Every close command carries --worker-model, and --worker-effort when the\nStory resumes after a prior block: every Story a beat hands out is\nworker-dispatched, including a one-Story resume.',
|
|
56
57
|
'Each ready[] entry carries effort: "high" after one local un-recovered\nstory-blocked signal, "xhigh" after two or more, null otherwise. Pass a\nnon-null effort as the Agent call\'s effort; omit the parameter for null.',
|
|
58
|
+
'confirm[] lists every Story in the run that is closed but not yet\nagent::done (a superseded not_planned/duplicate close excluded), each with\nthe single-story-confirm-merge.js command that finishes its flip and land\ntail. Run each verbatim on every beat, before the epilogue. It is advisory:\nit never gates done.',
|
|
57
59
|
'Exit codes:\n 0 beat emitted\n 1 input error\n 2 dependency cycle (cycleError)\n 3 wedged\n 4 blocked — the HITL pause; stop the loop, do not poll',
|
|
58
60
|
],
|
|
59
61
|
};
|
|
@@ -545,6 +547,7 @@ export async function runDeliverRunBeat(
|
|
|
545
547
|
workerEffort: effortById.get(storyId) ?? null,
|
|
546
548
|
}),
|
|
547
549
|
})),
|
|
550
|
+
confirm: renderConfirmEntries(tick.confirm),
|
|
548
551
|
done: tick.epilogueDue === true,
|
|
549
552
|
doneStories: tick.done ?? [],
|
|
550
553
|
inFlight: tick.inFlight ?? 0,
|
|
@@ -567,6 +570,14 @@ export async function runDeliverRunBeat(
|
|
|
567
570
|
};
|
|
568
571
|
}
|
|
569
572
|
|
|
573
|
+
/** Closed Stories owing the done flip; advisory, never gates `done`. */
|
|
574
|
+
function renderConfirmEntries(ids) {
|
|
575
|
+
return (Array.isArray(ids) ? ids : []).map((id) => ({
|
|
576
|
+
id,
|
|
577
|
+
command: NEXT_COMMANDS.confirmMerge(id),
|
|
578
|
+
}));
|
|
579
|
+
}
|
|
580
|
+
|
|
570
581
|
/**
|
|
571
582
|
* @param {string[]} argv
|
|
572
583
|
* @returns {{ stories?: string, handoff: string[], concurrency?: string, runId?: string, cwd?: string }}
|
|
@@ -308,16 +308,16 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
308
308
|
Logger.error(remediation);
|
|
309
309
|
Logger.error('----------------------------------------\n');
|
|
310
310
|
|
|
311
|
-
|
|
312
|
-
} else {
|
|
313
|
-
process.exit(0);
|
|
311
|
+
return abnormal?.exitCode ?? result.status;
|
|
314
312
|
}
|
|
313
|
+
return 0;
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
import { runAsCli } from './lib/cli-utils.js';
|
|
318
317
|
|
|
319
318
|
runAsCli(import.meta.url, main, {
|
|
320
319
|
source: 'DiagnoseFriction',
|
|
320
|
+
propagateExitCode: true,
|
|
321
321
|
usage: {
|
|
322
322
|
invocation:
|
|
323
323
|
'node .agents/scripts/diagnose-friction.js [--story <id>] [--epic <id>] --cmd <cmd> <args...>',
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default scorer for the bundle-size baseline: weigh each declared
|
|
3
|
+
* `gates['bundle-size'].bundles[]` artifact on disk. It never builds the
|
|
4
|
+
* project — the artifacts must already exist.
|
|
5
|
+
*
|
|
6
|
+
* Row shape (kinds/bundle-size.js): `{ bundle, rawKb, gzippedKb }`, where a
|
|
7
|
+
* bundle's size is the sum over every file its `path` glob matches.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import nodeFs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { gzipSync } from 'node:zlib';
|
|
13
|
+
import { Minimatch } from 'minimatch';
|
|
14
|
+
|
|
15
|
+
/** Directories a bundle glob never descends into. */
|
|
16
|
+
const SKIPPED_DIRS = new Set(['.git', 'node_modules']);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {number} bytes
|
|
20
|
+
* @returns {number} KB, two decimals.
|
|
21
|
+
*/
|
|
22
|
+
function toKb(bytes) {
|
|
23
|
+
return Number((bytes / 1024).toFixed(2));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The leading glob-free directory of a POSIX pattern — the walk root.
|
|
28
|
+
*
|
|
29
|
+
* @param {string[]} segments
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
function staticBase(segments) {
|
|
33
|
+
const firstMagic = segments.findIndex((s) => /[*?[\]{}()!]/.test(s));
|
|
34
|
+
const base =
|
|
35
|
+
firstMagic === -1 ? segments.slice(0, -1) : segments.slice(0, firstMagic);
|
|
36
|
+
return base.join('/');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} absDir
|
|
41
|
+
* @param {typeof nodeFs} fs
|
|
42
|
+
* @returns {string[]} Absolute file paths under `absDir`.
|
|
43
|
+
*/
|
|
44
|
+
function walkFiles(absDir, fs) {
|
|
45
|
+
if (!fs.existsSync(absDir)) return [];
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const entry of fs.readdirSync(absDir, { withFileTypes: true })) {
|
|
48
|
+
const abs = path.join(absDir, entry.name);
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
if (!SKIPPED_DIRS.has(entry.name)) out.push(...walkFiles(abs, fs));
|
|
51
|
+
} else if (entry.isFile()) {
|
|
52
|
+
out.push(abs);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Repo-relative files a bundle `path` (literal or glob) matches, sorted.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} pattern
|
|
62
|
+
* @param {string} cwd
|
|
63
|
+
* @param {typeof nodeFs} fs
|
|
64
|
+
* @returns {string[]} Absolute paths.
|
|
65
|
+
*/
|
|
66
|
+
function resolveBundleFiles(pattern, cwd, fs = nodeFs) {
|
|
67
|
+
const posix = pattern.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
68
|
+
const matcher = new Minimatch(posix, { dot: true });
|
|
69
|
+
if (!matcher.hasMagic()) {
|
|
70
|
+
const abs = path.resolve(cwd, posix);
|
|
71
|
+
return fs.existsSync(abs) && fs.statSync(abs).isFile() ? [abs] : [];
|
|
72
|
+
}
|
|
73
|
+
const base = staticBase(posix.split('/'));
|
|
74
|
+
return walkFiles(path.resolve(cwd, base), fs)
|
|
75
|
+
.filter((abs) =>
|
|
76
|
+
matcher.match(path.relative(cwd, abs).split(path.sep).join('/')),
|
|
77
|
+
)
|
|
78
|
+
.sort();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {{ name: string, path: string }} bundle
|
|
83
|
+
* @param {string} cwd
|
|
84
|
+
* @param {typeof nodeFs} fs
|
|
85
|
+
* @returns {{ bundle: string, rawKb: number, gzippedKb: number }}
|
|
86
|
+
*/
|
|
87
|
+
function measureBundle(bundle, cwd, fs) {
|
|
88
|
+
const files = resolveBundleFiles(bundle.path, cwd, fs);
|
|
89
|
+
if (files.length === 0) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`[bundle-size] declared bundle "${bundle.name}" matches no file at "${bundle.path}" — build the project before refreshing; an unbuilt artifact is never recorded as 0 KB.`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
let raw = 0;
|
|
95
|
+
let gzipped = 0;
|
|
96
|
+
for (const abs of files) {
|
|
97
|
+
const bytes = fs.readFileSync(abs);
|
|
98
|
+
raw += bytes.length;
|
|
99
|
+
gzipped += gzipSync(bytes).length;
|
|
100
|
+
}
|
|
101
|
+
return { bundle: bundle.name, rawKb: toKb(raw), gzippedKb: toKb(gzipped) };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {{ cwd: string, quality?: object, fs?: typeof nodeFs }} opts
|
|
106
|
+
* @returns {(files: string[], opts: object) => object[]}
|
|
107
|
+
*/
|
|
108
|
+
export function buildBundleSizeScorer({ cwd, quality, fs = nodeFs } = {}) {
|
|
109
|
+
const declared = quality?.gates?.['bundle-size']?.bundles;
|
|
110
|
+
const bundles = Array.isArray(declared) ? declared : [];
|
|
111
|
+
return (_files, opts) => {
|
|
112
|
+
const effectiveCwd = opts?.cwd ?? cwd ?? process.cwd();
|
|
113
|
+
return bundles.map((bundle) => measureBundle(bundle, effectiveCwd, fs));
|
|
114
|
+
};
|
|
115
|
+
}
|