mandrel 2.87.0 → 2.89.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 +5 -2
- package/.agents/docs/configuration.md +14 -8
- package/.agents/docs/workflows.md +1 -1
- package/.agents/schemas/agentrc.schema.json +24 -5
- 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 +32 -49
- package/.agents/scripts/deliver-run.js +11 -0
- package/.agents/scripts/diagnose-friction.js +3 -3
- package/.agents/scripts/lib/audit-baselines/gate-surface.js +24 -11
- package/.agents/scripts/lib/audit-baselines/read.js +4 -2
- package/.agents/scripts/lib/audit-baselines/surface-entry.js +95 -11
- package/.agents/scripts/lib/baselines/coverage-updater-cli.js +6 -14
- package/.agents/scripts/lib/baselines/crap-preview-scan.js +3 -1
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +38 -26
- package/.agents/scripts/lib/baselines/duplication-scanner.js +20 -1
- 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 +50 -53
- package/.agents/scripts/lib/baselines/preview-gates.js +5 -1
- package/.agents/scripts/lib/baselines/refresh-service.js +65 -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/close-validation/gates.js +40 -9
- package/.agents/scripts/lib/codex/skills-projection.js +1 -12
- package/.agents/scripts/lib/config/gates/crap.schema.js +15 -0
- package/.agents/scripts/lib/config/gates/mutation.schema.js +2 -2
- 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 +49 -1
- 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 +2 -2
- package/.agents/scripts/lib/coverage-capture-affected.js +2 -1
- package/.agents/scripts/lib/coverage-capture-fullscope.js +2 -2
- package/.agents/scripts/lib/coverage-capture-incremental.js +1 -1
- package/.agents/scripts/lib/coverage-capture-passes.js +143 -0
- package/.agents/scripts/lib/coverage-capture-usage.js +1 -1
- package/.agents/scripts/lib/coverage-capture.js +45 -15
- package/.agents/scripts/lib/crap-utils.js +65 -49
- 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 +20 -2
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +4 -1
- 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/orchestration/verify-credit.js +4 -1
- 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-crap-baseline.js +11 -20
- 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 +9 -4
- 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 +42 -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 +1 -1
|
@@ -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]
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* `coverage.captureScope: "affected"`, the consumer's `test:coverage:affected`)
|
|
7
7
|
* behind the host-level full-suite lock and stamp on success. A green run that
|
|
8
8
|
* leaves no artifact at `coveragePath` fails (exit 1) and is never stamped.
|
|
9
|
+
* An own CRAP source gets a second, always full-scope pass via
|
|
10
|
+
* `crap.captureScript` (`lib/coverage-capture-passes.js`).
|
|
9
11
|
*
|
|
10
12
|
* `--require-credited` must stay an argument, never a config read: as policy
|
|
11
13
|
* it also refused the depositing run, leaving no path that could deposit.
|
|
@@ -28,6 +30,10 @@ import {
|
|
|
28
30
|
} from './lib/coverage-capture.js';
|
|
29
31
|
import { tryScopedCapture } from './lib/coverage-capture-affected.js';
|
|
30
32
|
import { runFullScopeCapture } from './lib/coverage-capture-fullscope.js';
|
|
33
|
+
import {
|
|
34
|
+
captureRefusal,
|
|
35
|
+
runCapturePasses,
|
|
36
|
+
} from './lib/coverage-capture-passes.js';
|
|
31
37
|
import { handleCoverageCaptureHelp } from './lib/coverage-capture-usage.js';
|
|
32
38
|
import { lockedCapture } from './lib/full-suite-lock.js';
|
|
33
39
|
import { Logger } from './lib/Logger.js';
|
|
@@ -97,13 +103,8 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
97
103
|
const args = parseArgs(argv);
|
|
98
104
|
const config = resolveConfigImpl({ cwd: args.cwd });
|
|
99
105
|
const { crap, coverage } = getQualityImpl(config);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
cwd: args.cwd,
|
|
103
|
-
readPackageScriptsImpl,
|
|
104
|
-
hasNpmScriptImpl,
|
|
105
|
-
logger,
|
|
106
|
-
});
|
|
106
|
+
const scripts = readPackageScriptsImpl(args.cwd);
|
|
107
|
+
const refused = captureRefusal({ crap, scripts, hasNpmScriptImpl, logger });
|
|
107
108
|
if (refused !== null) return refused;
|
|
108
109
|
|
|
109
110
|
// Outermost first: the credit probe announces or refuses the run, and only
|
|
@@ -114,25 +115,30 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
114
115
|
onLockProgress: lockHooks.onLockProgress,
|
|
115
116
|
...lockOptions,
|
|
116
117
|
});
|
|
117
|
-
const credited = artifactCheckedCapture(locked, {
|
|
118
|
-
args,
|
|
119
|
-
crap,
|
|
120
|
-
existsSync: coverageArtifactExistsImpl,
|
|
121
|
-
logger,
|
|
122
|
-
});
|
|
123
118
|
let timings = null;
|
|
124
|
-
const
|
|
125
|
-
credited({
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
const makeCapture = (source) => {
|
|
120
|
+
const credited = artifactCheckedCapture(locked, {
|
|
121
|
+
args,
|
|
122
|
+
source,
|
|
123
|
+
existsSync: coverageArtifactExistsImpl,
|
|
124
|
+
logger,
|
|
130
125
|
});
|
|
131
|
-
|
|
126
|
+
return (captureOpts) =>
|
|
127
|
+
credited({
|
|
128
|
+
...captureOpts,
|
|
129
|
+
onTimings: (t) => {
|
|
130
|
+
timings = t;
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const code = await runCapturePasses({
|
|
132
135
|
crap,
|
|
133
136
|
coverage,
|
|
134
137
|
args,
|
|
135
|
-
|
|
138
|
+
scripts,
|
|
139
|
+
hasNpmScriptImpl,
|
|
140
|
+
makeCapture,
|
|
141
|
+
runShared: runCaptureScopes,
|
|
136
142
|
deps: {
|
|
137
143
|
getChangedFilesImpl,
|
|
138
144
|
isCoverageFreshImpl,
|
|
@@ -149,41 +155,18 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
/**
|
|
152
|
-
* The credited runner, failing a green run that wrote no artifact
|
|
158
|
+
* The credited runner, failing a green run that wrote no artifact at the
|
|
159
|
+
* pass's source.
|
|
153
160
|
*
|
|
154
161
|
* @param {Function} locked
|
|
155
|
-
* @param {{ args: object,
|
|
162
|
+
* @param {{ args: object, source: { coveragePath: string, script?: string, configKey?: string }, existsSync?: Function, logger: object }} opts
|
|
156
163
|
* @returns {(opts: object) => Promise<number>}
|
|
157
164
|
*/
|
|
158
|
-
function artifactCheckedCapture(locked, { args,
|
|
165
|
+
function artifactCheckedCapture(locked, { args, source, existsSync, logger }) {
|
|
159
166
|
return requireCaptureArtifact(
|
|
160
167
|
creditedCapture(locked, { requireCredited: args.requireCredited, logger }),
|
|
161
|
-
{ cwd: args.cwd,
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** @returns {number|null} The exit code when no capture may run. */
|
|
166
|
-
function refusal({
|
|
167
|
-
crap,
|
|
168
|
-
cwd,
|
|
169
|
-
readPackageScriptsImpl,
|
|
170
|
-
hasNpmScriptImpl,
|
|
171
|
-
logger,
|
|
172
|
-
}) {
|
|
173
|
-
if (crap.enabled === false) {
|
|
174
|
-
logger.info('[coverage-capture] CRAP gate disabled — skipping capture.');
|
|
175
|
-
return 0;
|
|
176
|
-
}
|
|
177
|
-
if (hasNpmScriptImpl(readPackageScriptsImpl(cwd), 'test:coverage')) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
// Name the fix rather than propagate npm's opaque "Missing script" exit.
|
|
181
|
-
logger.error(
|
|
182
|
-
'[coverage-capture] ✖ No "test:coverage" script in package.json. ' +
|
|
183
|
-
'Add one (e.g. "test:coverage": "node --test --experimental-test-coverage") ' +
|
|
184
|
-
'or disable the CRAP gate via delivery.quality.gates.crap.enabled=false.',
|
|
168
|
+
{ ...source, cwd: args.cwd, existsSync, logger },
|
|
185
169
|
);
|
|
186
|
-
return 1;
|
|
187
170
|
}
|
|
188
171
|
|
|
189
172
|
function reportTimings(timings, logger, lockHooks) {
|
|
@@ -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...>',
|
|
@@ -5,41 +5,54 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import path from 'node:path';
|
|
8
|
-
import { ALL_KINDS, baselinePathFor
|
|
8
|
+
import { ALL_KINDS, baselinePathFor } from './kinds.js';
|
|
9
9
|
import { listFilesUnder, readJsonFile } from './read.js';
|
|
10
|
-
import { surfaceEntryFor } from './surface-entry.js';
|
|
10
|
+
import { scannerSkipDirsFor, surfaceEntryFor } from './surface-entry.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* One gate's declared `targetDirs`, deduplicated.
|
|
14
14
|
*
|
|
15
15
|
* @param {object | null | undefined} quality
|
|
16
|
+
* @param {string} kind
|
|
16
17
|
* @returns {string[]}
|
|
17
18
|
*/
|
|
18
|
-
function
|
|
19
|
+
function targetDirsOf(quality, kind) {
|
|
19
20
|
const dirs = new Set();
|
|
20
|
-
for (const
|
|
21
|
-
|
|
22
|
-
if (typeof dir === 'string' && dir.length > 0) dirs.add(dir);
|
|
23
|
-
}
|
|
21
|
+
for (const dir of quality?.gates?.[kind]?.targetDirs ?? []) {
|
|
22
|
+
if (typeof dir === 'string' && dir.length > 0) dirs.add(dir);
|
|
24
23
|
}
|
|
25
24
|
return [...dirs].sort();
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The files one gate's scanner could visit: its own `targetDirs`, walked with
|
|
29
|
+
* its own skip set.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} cwd
|
|
32
|
+
* @param {object | null | undefined} quality
|
|
33
|
+
* @param {string} kind
|
|
34
|
+
* @returns {string[]}
|
|
35
|
+
*/
|
|
36
|
+
function candidateFilesFor(cwd, quality, kind) {
|
|
37
|
+
const skip = scannerSkipDirsFor(kind);
|
|
38
|
+
return targetDirsOf(quality, kind).flatMap((dir) =>
|
|
39
|
+
listFilesUnder(cwd, dir, skip),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
/**
|
|
29
44
|
* @param {{ cwd: string, quality: object, now?: Date, run?: Function }} args
|
|
30
45
|
* @returns {{ entries: object[], baselines: Map<string, object|null> }}
|
|
31
46
|
* `baselines` is carried forward so later sections never re-read from disk.
|
|
32
47
|
*/
|
|
33
48
|
export function buildGateSurface({ cwd, quality, now = new Date(), run }) {
|
|
34
|
-
const files = declaredTargetDirs(quality).flatMap((dir) =>
|
|
35
|
-
listFilesUnder(cwd, dir),
|
|
36
|
-
);
|
|
37
49
|
const io = { cwd, run };
|
|
38
50
|
const entries = [];
|
|
39
51
|
const baselines = new Map();
|
|
40
52
|
for (const kind of ALL_KINDS) {
|
|
41
53
|
const relPath = baselinePathFor(kind, quality);
|
|
42
54
|
const read = readJsonFile(path.resolve(cwd, relPath));
|
|
55
|
+
const files = candidateFilesFor(cwd, quality, kind);
|
|
43
56
|
entries.push(
|
|
44
57
|
surfaceEntryFor({ kind, quality, read, relPath, files, now, io }),
|
|
45
58
|
);
|
|
@@ -33,10 +33,12 @@ export function readJsonFile(absolutePath) {
|
|
|
33
33
|
/**
|
|
34
34
|
* @param {string} repoRoot
|
|
35
35
|
* @param {string} rootDir repo-relative directory to walk
|
|
36
|
+
* @param {Iterable<string>} [scannerSkip] directory names a gate's scanner
|
|
37
|
+
* never descends into, skipped on top of the lens's own cost guard
|
|
36
38
|
* @returns {string[]} sorted repo-relative posix paths
|
|
37
39
|
*/
|
|
38
|
-
export function listFilesUnder(repoRoot, rootDir) {
|
|
39
|
-
const skip = new Set(['node_modules', '.git', '.worktrees']);
|
|
40
|
+
export function listFilesUnder(repoRoot, rootDir, scannerSkip = []) {
|
|
41
|
+
const skip = new Set(['node_modules', '.git', '.worktrees', ...scannerSkip]);
|
|
40
42
|
const out = [];
|
|
41
43
|
const walk = (abs) => {
|
|
42
44
|
let entries;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import picomatch from 'picomatch';
|
|
9
|
+
import { IGNORED_DIRS } from '../maintainability-utils.js';
|
|
9
10
|
import { GATE_KINDS, KIND_SPECS, measuredTotalOf, rollupOf } from './kinds.js';
|
|
10
11
|
import { stalenessOf } from './staleness.js';
|
|
11
12
|
|
|
@@ -32,19 +33,98 @@ function isStubInstrument({ rowCount, rollup }) {
|
|
|
32
33
|
return rowCount === 0 && isAllZeroRollup(rollup);
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Directory names each gate's own scanner never descends into. CRAP and
|
|
38
|
+
* maintainability share the `scanDirectory` walk; duplication runs jscpd with
|
|
39
|
+
* `gitignore: false` over its `targetDirs`, so it skips nothing. A kind absent
|
|
40
|
+
* here declares no `ignoreGlobs` and skips nothing.
|
|
41
|
+
*
|
|
42
|
+
* @type {Readonly<Record<string, ReadonlySet<string>>>}
|
|
43
|
+
*/
|
|
44
|
+
const SCANNER_SKIP_DIRS = Object.freeze({
|
|
45
|
+
crap: IGNORED_DIRS,
|
|
46
|
+
maintainability: IGNORED_DIRS,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const NO_SKIP = new Set();
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {string} kind
|
|
53
|
+
* @returns {ReadonlySet<string>}
|
|
54
|
+
*/
|
|
55
|
+
export function scannerSkipDirsFor(kind) {
|
|
56
|
+
return SCANNER_SKIP_DIRS[kind] ?? NO_SKIP;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generated or installed trees: absent from a fresh checkout, present after an
|
|
61
|
+
* install or build. A glob aimed at one is load-bearing whenever the gate's
|
|
62
|
+
* scanner would descend there, whatever is on disk today.
|
|
63
|
+
*/
|
|
64
|
+
const GENERATED_TREE_DIRS = new Set([
|
|
65
|
+
'node_modules',
|
|
66
|
+
'dist',
|
|
67
|
+
'build',
|
|
68
|
+
'out',
|
|
69
|
+
'coverage',
|
|
70
|
+
'.next',
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
const GLOB_META = /[*?[\]{}()!+@]/;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A glob is latent when one of its literal segments names a generated tree the
|
|
77
|
+
* scanner would walk into, so an empty match today is not evidence of death.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} glob
|
|
80
|
+
* @param {ReadonlySet<string>} scannerSkipDirs
|
|
81
|
+
* @returns {boolean}
|
|
82
|
+
*/
|
|
83
|
+
function isLatentGlob(glob, scannerSkipDirs) {
|
|
84
|
+
return glob
|
|
85
|
+
.split('/')
|
|
86
|
+
.some(
|
|
87
|
+
(segment) =>
|
|
88
|
+
!GLOB_META.test(segment) &&
|
|
89
|
+
GENERATED_TREE_DIRS.has(segment) &&
|
|
90
|
+
!scannerSkipDirs.has(segment),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {unknown} glob
|
|
96
|
+
* @param {ReadonlySet<string>} scannerSkipDirs
|
|
97
|
+
* @returns {boolean} a non-empty, non-latent glob string
|
|
98
|
+
*/
|
|
99
|
+
function isJudgeableGlob(glob, scannerSkipDirs) {
|
|
100
|
+
return (
|
|
101
|
+
typeof glob === 'string' &&
|
|
102
|
+
glob.length > 0 &&
|
|
103
|
+
!isLatentGlob(glob, scannerSkipDirs)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param {string} glob
|
|
109
|
+
* @param {string[]} files
|
|
110
|
+
* @returns {boolean}
|
|
111
|
+
*/
|
|
112
|
+
function matchesNothing(glob, files) {
|
|
113
|
+
const isMatch = picomatch(glob, { dot: true });
|
|
114
|
+
return !files.some((f) => isMatch(f));
|
|
115
|
+
}
|
|
116
|
+
|
|
35
117
|
/**
|
|
36
118
|
* @param {string[]} ignoreGlobs
|
|
37
|
-
* @param {string[]} files repo-relative posix paths
|
|
38
|
-
* @
|
|
119
|
+
* @param {string[]} files repo-relative posix paths the gate's scanner walks
|
|
120
|
+
* @param {ReadonlySet<string>} scannerSkipDirs
|
|
121
|
+
* @returns {string[]} non-latent globs matching zero files
|
|
39
122
|
*/
|
|
40
|
-
function findDeadIgnoreGlobs(ignoreGlobs, files) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!files.some((f) => isMatch(f))) dead.push(glob);
|
|
46
|
-
}
|
|
47
|
-
return dead;
|
|
123
|
+
function findDeadIgnoreGlobs(ignoreGlobs, files, scannerSkipDirs) {
|
|
124
|
+
return (ignoreGlobs ?? []).filter(
|
|
125
|
+
(glob) =>
|
|
126
|
+
isJudgeableGlob(glob, scannerSkipDirs) && matchesNothing(glob, files),
|
|
127
|
+
);
|
|
48
128
|
}
|
|
49
129
|
|
|
50
130
|
/**
|
|
@@ -79,7 +159,11 @@ export function surfaceEntryFor({
|
|
|
79
159
|
rowCount: rows.length,
|
|
80
160
|
measured: measuredTotalOf(kind, baseline),
|
|
81
161
|
...stalenessOf({ kind, gateBlock, rows, relPath, baseline, now, io }),
|
|
82
|
-
deadIgnoreGlobs: findDeadIgnoreGlobs(
|
|
162
|
+
deadIgnoreGlobs: findDeadIgnoreGlobs(
|
|
163
|
+
gateBlock?.ignoreGlobs,
|
|
164
|
+
files,
|
|
165
|
+
scannerSkipDirsFor(kind),
|
|
166
|
+
),
|
|
83
167
|
parseError,
|
|
84
168
|
};
|
|
85
169
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `update-coverage-baseline` CLI's testable logic. The scorer stays
|
|
3
|
-
* bespoke (not the refresh-service default) because it logs
|
|
4
|
-
* artifact
|
|
5
|
-
* `refreshBaseline` has no empty-rows guard and would write an empty baseline.
|
|
3
|
+
* bespoke (not the refresh-service default) because it logs an unreadable
|
|
4
|
+
* coverage artifact before refusing it.
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
7
|
import fs from 'node:fs';
|
|
@@ -53,19 +52,13 @@ export function resolveCoverageUpdaterScope(argv = []) {
|
|
|
53
52
|
return { fullScope, diffScopeRef };
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
* write an empty baseline; a scoped one logs it and yields `null`.
|
|
59
|
-
*
|
|
60
|
-
* @returns {object|null}
|
|
61
|
-
*/
|
|
62
|
-
function readOrReport(readCoverage, cwd, opts, logger) {
|
|
55
|
+
/** Logs a read failure and rethrows it: an empty row set would erase rows. */
|
|
56
|
+
function readOrRefuse(readCoverage, cwd, logger) {
|
|
63
57
|
try {
|
|
64
58
|
return readCoverage(cwd);
|
|
65
59
|
} catch (err) {
|
|
66
|
-
if (opts?.fullScope) throw err;
|
|
67
60
|
logger.error(`[Coverage] ❌ ${err.message}`);
|
|
68
|
-
|
|
61
|
+
throw err;
|
|
69
62
|
}
|
|
70
63
|
}
|
|
71
64
|
|
|
@@ -84,8 +77,7 @@ function buildCoverageUpdaterScorer(
|
|
|
84
77
|
) {
|
|
85
78
|
return (files, opts) => {
|
|
86
79
|
const effectiveCwd = opts?.cwd ?? cwd;
|
|
87
|
-
const raw =
|
|
88
|
-
if (raw === null) return [];
|
|
80
|
+
const raw = readOrRefuse(readCoverage, effectiveCwd, logger);
|
|
89
81
|
const c8Config = loadScope(effectiveCwd);
|
|
90
82
|
const scores = score({
|
|
91
83
|
raw,
|
|
@@ -122,7 +122,9 @@ export async function computeCrapPreviewScan({
|
|
|
122
122
|
envelope.cyclomaticAdvisories = listCyclomaticAdvisories(scan.rows);
|
|
123
123
|
// Above the drifted-row ratio every verdict is an artefact of a mis-keyed
|
|
124
124
|
// join: say so once and fail open.
|
|
125
|
-
const basis = assessComparisonBasis(result
|
|
125
|
+
const basis = assessComparisonBasis(result, {
|
|
126
|
+
captureScript: crap.captureScript,
|
|
127
|
+
});
|
|
126
128
|
if (!basis.sound) {
|
|
127
129
|
return {
|
|
128
130
|
exitCode: 0,
|