mandrel 2.94.0 → 2.95.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/runtime-deps.json +6 -6
- package/.agents/scripts/agents-bootstrap-github.js +1 -1
- package/.agents/scripts/board-backfill.js +1 -1
- package/.agents/scripts/boot-sweep.js +1 -1
- package/.agents/scripts/check-arch-cycles.js +69 -41
- package/.agents/scripts/check-doc-links.js +5 -7
- package/.agents/scripts/check-gherkin-corpus.js +2 -11
- package/.agents/scripts/clean-temp.js +1 -1
- package/.agents/scripts/cleanup-repo-test-temp.js +1 -1
- package/.agents/scripts/diagnose-friction.js +1 -1
- package/.agents/scripts/generate-lens-checklists.js +4 -4
- package/.agents/scripts/generate-skills-index.js +3 -2
- package/.agents/scripts/generate-workflows-doc.js +2 -1
- package/.agents/scripts/lib/audit-baselines/read.js +2 -1
- package/.agents/scripts/lib/audit-exceptions/adapters/tool-config.js +13 -3
- package/.agents/scripts/lib/audit-exceptions/globs.js +12 -1
- package/.agents/scripts/lib/audit-exceptions/probe.js +24 -2
- package/.agents/scripts/lib/audit-exceptions/read.js +2 -2
- package/.agents/scripts/lib/audit-to-stories/group-findings.js +77 -67
- package/.agents/scripts/lib/baselines/components.js +21 -19
- package/.agents/scripts/lib/baselines/duplication-scanner.js +4 -8
- package/.agents/scripts/lib/baselines/kinds/maintainability.js +2 -3
- package/.agents/scripts/lib/baselines/preview-gates.js +2 -2
- package/.agents/scripts/lib/baselines/refresh-service.js +4 -7
- package/.agents/scripts/lib/baselines/writer.js +2 -7
- package/.agents/scripts/lib/bdd-runner-detect.js +2 -2
- package/.agents/scripts/lib/bdd-step-index.js +3 -7
- package/.agents/scripts/lib/bootstrap/baseline-merge-driver.js +11 -7
- package/.agents/scripts/lib/bootstrap/install-ledger.js +19 -4
- package/.agents/scripts/lib/bootstrap/json-io.js +14 -0
- package/.agents/scripts/lib/bootstrap/project-bootstrap.js +20 -44
- package/.agents/scripts/lib/bootstrap/quality-bootstrap.js +38 -54
- package/.agents/scripts/lib/branch-name-guard.js +2 -3
- package/.agents/scripts/lib/claude/agents-projection.js +1 -12
- package/.agents/scripts/lib/codex/agents-projection.js +2 -5
- package/.agents/scripts/lib/codex/skills-projection.js +4 -12
- package/.agents/scripts/lib/config/defaults.js +2 -1
- package/.agents/scripts/lib/config/qa.js +4 -5
- package/.agents/scripts/lib/config-schema.js +1 -8
- package/.agents/scripts/lib/config-settings-schema.js +0 -3
- package/.agents/scripts/lib/coverage-baseline.js +2 -3
- package/.agents/scripts/lib/coverage-utils.js +2 -1
- package/.agents/scripts/lib/cpu-pool.js +0 -1
- package/.agents/scripts/lib/cyclomatic-scope.js +2 -1
- package/.agents/scripts/lib/doc-tiers.js +2 -1
- package/.agents/scripts/lib/gh-exec.js +21 -1
- package/.agents/scripts/lib/git/sync-from-base.js +1 -1
- package/.agents/scripts/lib/import-graph.js +13 -28
- package/.agents/scripts/lib/json-utils.js +11 -0
- package/.agents/scripts/lib/label-constants.js +7 -1
- package/.agents/scripts/lib/maintainability-utils.js +14 -22
- package/.agents/scripts/lib/observability/runtime-friction.js +37 -1
- package/.agents/scripts/lib/orchestration/check-baselines/phases/parse-args.js +25 -1
- package/.agents/scripts/lib/orchestration/ci-rerun-guard.js +9 -12
- package/.agents/scripts/lib/orchestration/code-review.js +1 -6
- package/.agents/scripts/lib/orchestration/deliver-recover.js +2 -1
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/fast-forward.js +7 -14
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes-ff.js +2 -21
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +11 -20
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/phase-drivers.js +65 -86
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/prompts.js +2 -2
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/stashes.js +15 -6
- package/.agents/scripts/lib/orchestration/lifecycle/emit-merge-unlanded.js +5 -2
- package/.agents/scripts/lib/orchestration/merge-block-class.js +47 -48
- package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +20 -1
- package/.agents/scripts/lib/orchestration/review-providers/claude-verdict.js +2 -3
- package/.agents/scripts/lib/orchestration/review-providers/parse-findings.js +4 -2
- package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +2 -2
- package/.agents/scripts/lib/orchestration/story-close/ratchet-shrink-writeback.js +3 -3
- package/.agents/scripts/lib/orchestration/story-handoff.js +18 -5
- package/.agents/scripts/lib/orchestration/ticketing/transition.js +17 -21
- package/.agents/scripts/lib/runtime-deps/dep-resolution.js +19 -5
- package/.agents/scripts/lib/runtime-deps/scan-imports.js +4 -10
- package/.agents/scripts/lib/skills/parse-skill.js +2 -2
- package/.agents/scripts/lib/skills/walk-skill-files.js +7 -23
- package/.agents/scripts/lib/story-body/story-body.js +4 -14
- package/.agents/scripts/lib/util/atomic-write.js +14 -3
- package/.agents/scripts/lib/util/regex.js +4 -0
- package/.agents/scripts/notify.js +1 -1
- package/.agents/scripts/plan-context.js +1 -1
- package/.agents/scripts/plan-critics.js +3 -11
- package/.agents/scripts/providers/github/auth.js +0 -4
- package/.agents/scripts/providers/github/project-board.js +0 -1
- package/.agents/scripts/providers/github/tickets.js +0 -2
- package/.agents/scripts/resync-status-column.js +1 -1
- package/.agents/scripts/run-tests.js +1 -1
- package/.agents/scripts/test-wrapper.js +1 -1
- package/.agents/scripts/update-ticket-state.js +4 -3
- package/.agents/scripts/validate-skills.js +2 -1
- package/.agents/skills/core/gates-and-baselines/reference.md +1 -0
- package/.agents/workflows/audit-baselines.md +21 -9
- package/.agents/workflows/clean-git.md +1 -1
- package/.agents/workflows/helpers/audit-lens-core.md +1 -1
- package/.agents/workflows/helpers/code-quality-guardrails.md +3 -3
- package/README.md +1 -1
- package/docs/CHANGELOG.md +34 -0
- package/lib/cli/claude-code-version.js +13 -7
- package/lib/cli/doctor-checks/llm-review.js +12 -5
- package/lib/cli/doctor-checks/merge-driver.js +10 -6
- package/lib/cli/doctor-checks/project-access.js +21 -8
- package/lib/cli/doctor-checks/read-json.js +2 -15
- package/lib/cli/doctor-checks/spawn.js +29 -9
- package/lib/cli/doctor-checks/test-credit-path.js +2 -1
- package/lib/cli/doctor-checks/toolchain.js +16 -12
- package/lib/cli/doctor.js +31 -8
- package/lib/cli/registry.js +7 -10
- package/lib/cli/sync.js +46 -10
- package/lib/cli/uninstall.js +259 -175
- package/lib/cli/update.js +3 -3
- package/package.json +23 -20
|
@@ -20,13 +20,14 @@ import {
|
|
|
20
20
|
} from './agents-md-fold.js';
|
|
21
21
|
import { LEDGER_RELATIVE_PATH } from './install-ledger.js';
|
|
22
22
|
import { ensureIssueForms } from './issue-forms-template.js';
|
|
23
|
+
import { readJsonIfExists, writeJson } from './json-io.js';
|
|
23
24
|
import { PHASE_GROUPS } from './manifest.js';
|
|
24
25
|
import { applyQualityBootstrap } from './quality-bootstrap.js';
|
|
25
26
|
|
|
26
27
|
export const SYNC_COMMAND = 'node .agents/scripts/sync-claude-commands.js';
|
|
27
28
|
|
|
28
29
|
// The agent projection runs everywhere the command projection does.
|
|
29
|
-
|
|
30
|
+
const SYNC_AGENTS_COMMAND = 'node .agents/scripts/sync-claude-agents.js';
|
|
30
31
|
|
|
31
32
|
export const BOOTSTRAP_COMMAND = 'node .agents/scripts/bootstrap.js';
|
|
32
33
|
|
|
@@ -93,26 +94,6 @@ export const GITIGNORE_BLOCKS = Object.freeze({
|
|
|
93
94
|
},
|
|
94
95
|
});
|
|
95
96
|
|
|
96
|
-
/**
|
|
97
|
-
* @param {string} p
|
|
98
|
-
* @param {typeof fs} [fsImpl]
|
|
99
|
-
* @returns {object|null}
|
|
100
|
-
*/
|
|
101
|
-
function readJsonIfExists(p, fsImpl = fs) {
|
|
102
|
-
if (!fsImpl.existsSync(p)) return null;
|
|
103
|
-
return JSON.parse(fsImpl.readFileSync(p, 'utf8'));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @param {string} p
|
|
108
|
-
* @param {object} obj
|
|
109
|
-
* @param {typeof fs} [fsImpl]
|
|
110
|
-
*/
|
|
111
|
-
function writeJson(p, obj, fsImpl = fs) {
|
|
112
|
-
fsImpl.mkdirSync(path.dirname(p), { recursive: true });
|
|
113
|
-
fsImpl.writeFileSync(p, `${JSON.stringify(obj, null, 2)}\n`, 'utf8');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
97
|
function agentRootOf(ctx) {
|
|
117
98
|
return ctx.agentRoot ?? path.join(ctx.projectRoot, '.agents');
|
|
118
99
|
}
|
|
@@ -159,7 +140,7 @@ export function checkNodeVersion(version = process.versions.node) {
|
|
|
159
140
|
* @param {typeof fs} [fsImpl]
|
|
160
141
|
* @returns {'pnpm'|'yarn'|'npm'}
|
|
161
142
|
*/
|
|
162
|
-
|
|
143
|
+
function detectPackageManager(projectRoot, fsImpl = fs) {
|
|
163
144
|
return detectPm(projectRoot, (p) => fsImpl.existsSync(p)) ?? 'npm';
|
|
164
145
|
}
|
|
165
146
|
|
|
@@ -213,7 +194,7 @@ export function ensurePrepareScript(scripts) {
|
|
|
213
194
|
* @param {object} ctx
|
|
214
195
|
* @param {typeof fs} [ctx.fsImpl]
|
|
215
196
|
*/
|
|
216
|
-
|
|
197
|
+
function ensurePackageJson(ctx) {
|
|
217
198
|
const { fsImpl = fs } = ctx;
|
|
218
199
|
const pkgPath = path.join(ctx.projectRoot, 'package.json');
|
|
219
200
|
const existing = readJsonIfExists(pkgPath, fsImpl);
|
|
@@ -253,7 +234,7 @@ export function ensurePackageJson(ctx) {
|
|
|
253
234
|
* @param {typeof fs} [ctx.fsImpl]
|
|
254
235
|
* @param {typeof defaultSpawnSync} [ctx.spawnImpl]
|
|
255
236
|
*/
|
|
256
|
-
|
|
237
|
+
function ensureDependenciesInstalled(ctx) {
|
|
257
238
|
const { fsImpl = fs, spawnImpl = defaultSpawnSync } = ctx;
|
|
258
239
|
const manager = detectPackageManager(ctx.projectRoot, fsImpl);
|
|
259
240
|
const sentinel = path.join(
|
|
@@ -290,7 +271,7 @@ export function ensureDependenciesInstalled(ctx) {
|
|
|
290
271
|
* @param {typeof fs} [ctx.fsImpl]
|
|
291
272
|
* @returns {{ action: string, path: string, source?: string }}
|
|
292
273
|
*/
|
|
293
|
-
|
|
274
|
+
function ensureAgentrc(ctx) {
|
|
294
275
|
const { fsImpl = fs } = ctx;
|
|
295
276
|
const target = path.join(ctx.projectRoot, '.agentrc.json');
|
|
296
277
|
if (fsImpl.existsSync(target)) {
|
|
@@ -442,7 +423,7 @@ function runSyncCommands(ctx) {
|
|
|
442
423
|
* @param {object} ctx
|
|
443
424
|
* @param {typeof fs} [ctx.fsImpl]
|
|
444
425
|
*/
|
|
445
|
-
|
|
426
|
+
function checkParity(ctx) {
|
|
446
427
|
const { fsImpl = fs } = ctx;
|
|
447
428
|
const workflowsDir = path.join(agentRootOf(ctx), 'workflows');
|
|
448
429
|
const commandsDir = path.join(ctx.projectRoot, '.claude', 'commands');
|
|
@@ -469,18 +450,6 @@ export function checkParity(ctx) {
|
|
|
469
450
|
};
|
|
470
451
|
}
|
|
471
452
|
|
|
472
|
-
/**
|
|
473
|
-
* Ensure `AGENTS.md` imports the system prompt — without it the framework
|
|
474
|
-
* never loads on cold start. A pre-existing `CLAUDE.md` is folded in first
|
|
475
|
-
* (the host would otherwise read it instead). Creates, appends, or no-ops.
|
|
476
|
-
*
|
|
477
|
-
* @param {object} ctx
|
|
478
|
-
* @param {typeof fs} [ctx.fsImpl]
|
|
479
|
-
*/
|
|
480
|
-
export function ensureSystemPromptWiring(ctx) {
|
|
481
|
-
return wireEntryDoc(ctx.projectRoot, ctx.fsImpl);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
453
|
/**
|
|
485
454
|
* Windows git-perf hints, warn-only; never mutates global git config.
|
|
486
455
|
*
|
|
@@ -547,10 +516,10 @@ const fatalParity = (result) =>
|
|
|
547
516
|
* Ordered bootstrap pipeline. `phaseGroup` is ledger/uninstall metadata only
|
|
548
517
|
* — every phase runs on every install.
|
|
549
518
|
*/
|
|
550
|
-
|
|
519
|
+
const BOOTSTRAP_PHASES = Object.freeze([
|
|
551
520
|
{
|
|
552
521
|
name: 'nodeCheck',
|
|
553
|
-
run: () => checkNodeVersion(),
|
|
522
|
+
run: (ctx) => checkNodeVersion(ctx.nodeVersion),
|
|
554
523
|
isFatal: true,
|
|
555
524
|
formatError: fatalNodeCheck,
|
|
556
525
|
},
|
|
@@ -578,7 +547,8 @@ export const BOOTSTRAP_PHASES = Object.freeze([
|
|
|
578
547
|
{
|
|
579
548
|
name: 'systemPromptWiring',
|
|
580
549
|
phaseGroup: PHASE_GROUPS.IDE_WIRING,
|
|
581
|
-
|
|
550
|
+
// AGENTS.md must import the system prompt; CLAUDE.md is folded in first.
|
|
551
|
+
run: (ctx) => wireEntryDoc(ctx.projectRoot, ctx.fsImpl),
|
|
582
552
|
},
|
|
583
553
|
{
|
|
584
554
|
name: 'gitignore',
|
|
@@ -623,7 +593,7 @@ export const BOOTSTRAP_PHASES = Object.freeze([
|
|
|
623
593
|
* @param {BootstrapPhase} phase
|
|
624
594
|
* @param {any} result
|
|
625
595
|
*/
|
|
626
|
-
|
|
596
|
+
function throwIfFatal(phase, result) {
|
|
627
597
|
if (!phase.isFatal) return;
|
|
628
598
|
const msg = phase.formatError?.(result);
|
|
629
599
|
if (typeof msg === 'string' && msg.length > 0) throw new Error(msg);
|
|
@@ -634,7 +604,7 @@ export function throwIfFatal(phase, result) {
|
|
|
634
604
|
* @param {object} ctx
|
|
635
605
|
* @returns {Promise<object>}
|
|
636
606
|
*/
|
|
637
|
-
|
|
607
|
+
async function runPhases(phases, ctx) {
|
|
638
608
|
const report = {};
|
|
639
609
|
for (const phase of phases) {
|
|
640
610
|
const result = await phase.run(ctx, report);
|
|
@@ -656,8 +626,14 @@ export async function runPhases(phases, ctx) {
|
|
|
656
626
|
* @param {boolean} [ctx.quiet]
|
|
657
627
|
* @param {typeof fs} [ctx.fsImpl]
|
|
658
628
|
* @param {typeof defaultSpawnSync} [ctx.spawnImpl]
|
|
629
|
+
* @param {string} [ctx.nodeVersion] - Test seam; defaults to the running Node.
|
|
630
|
+
* @param {readonly string[]} [ctx.onlyPhases] - Test seam: run only these
|
|
631
|
+
* phases (in pipeline order) instead of the whole pipeline.
|
|
659
632
|
* @returns {Promise<object>}
|
|
660
633
|
*/
|
|
661
634
|
export async function applyProjectBootstrap(ctx) {
|
|
662
|
-
|
|
635
|
+
const phases = ctx.onlyPhases
|
|
636
|
+
? BOOTSTRAP_PHASES.filter((p) => ctx.onlyPhases.includes(p.name))
|
|
637
|
+
: BOOTSTRAP_PHASES;
|
|
638
|
+
return runPhases(phases, ctx);
|
|
663
639
|
}
|
|
@@ -10,8 +10,9 @@ import { spawnSync as defaultSpawnSync } from 'node:child_process';
|
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { getAgentrcDefaults, lookupPath } from '../config/defaults.js';
|
|
13
|
-
import { deepEqual } from '../json-utils.js';
|
|
13
|
+
import { deepEqual, isObject } from '../json-utils.js';
|
|
14
14
|
import { ensureBaselineMergeDriver } from './baseline-merge-driver.js';
|
|
15
|
+
import { readJsonIfExists, writeJson } from './json-io.js';
|
|
15
16
|
|
|
16
17
|
/** The framework's own pre-commit body. */
|
|
17
18
|
const FRAMEWORK_PRE_COMMIT = `node scripts/check-version-sync.js
|
|
@@ -51,24 +52,12 @@ export const QUALITY_NPM_SCRIPTS = Object.freeze({
|
|
|
51
52
|
'quality:watch': 'node .agents/scripts/quality-watch.js',
|
|
52
53
|
});
|
|
53
54
|
|
|
54
|
-
/** `null` when absent; parse errors propagate so a corrupt config fails loudly. */
|
|
55
|
-
function readJsonIfExists(p) {
|
|
56
|
-
if (!fs.existsSync(p)) return null;
|
|
57
|
-
const raw = fs.readFileSync(p, 'utf8');
|
|
58
|
-
return JSON.parse(raw);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function writeJson(p, obj) {
|
|
62
|
-
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
63
|
-
fs.writeFileSync(p, `${JSON.stringify(obj, null, 2)}\n`, 'utf8');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
55
|
/**
|
|
67
56
|
* @param {object} ctx
|
|
68
57
|
* @param {string} ctx.projectRoot
|
|
69
58
|
* @param {string} [ctx.frameworkRoot] - Defaults to `<projectRoot>/.agents`.
|
|
70
59
|
*/
|
|
71
|
-
|
|
60
|
+
function ensureGuardrailsHelper(ctx) {
|
|
72
61
|
const projectRoot = ctx.projectRoot;
|
|
73
62
|
const target = path.join(
|
|
74
63
|
projectRoot,
|
|
@@ -103,7 +92,7 @@ export function ensureGuardrailsHelper(ctx) {
|
|
|
103
92
|
* @param {string} ctx.projectRoot
|
|
104
93
|
* @param {'framework'|'downstream'} [ctx.variant='downstream']
|
|
105
94
|
*/
|
|
106
|
-
|
|
95
|
+
function ensurePreCommitHook(ctx) {
|
|
107
96
|
const variant = ctx.variant ?? 'downstream';
|
|
108
97
|
const body =
|
|
109
98
|
variant === 'framework' ? FRAMEWORK_PRE_COMMIT : DOWNSTREAM_PRE_COMMIT;
|
|
@@ -139,7 +128,7 @@ export function ensurePreCommitHook(ctx) {
|
|
|
139
128
|
}
|
|
140
129
|
|
|
141
130
|
/** Add missing quality npm scripts; existing values always win. */
|
|
142
|
-
|
|
131
|
+
function ensureQualityNpmScripts(ctx) {
|
|
143
132
|
const pkgPath = path.join(ctx.projectRoot, 'package.json');
|
|
144
133
|
const pkg = readJsonIfExists(pkgPath);
|
|
145
134
|
if (!pkg) {
|
|
@@ -168,62 +157,57 @@ export function ensureQualityNpmScripts(ctx) {
|
|
|
168
157
|
/**
|
|
169
158
|
* Set only keys that are absent AND differ from the framework default — a
|
|
170
159
|
* default-equal write would be flagged `[REDUNDANT]` by sync-agentrc.
|
|
171
|
-
* Default-equal keys are reported in `skippedKeys`.
|
|
160
|
+
* Default-equal keys are reported in `skippedKeys`. Mutates `target`.
|
|
172
161
|
*
|
|
173
162
|
* @param {object} target
|
|
174
163
|
* @param {object} defaults
|
|
175
|
-
* @param {
|
|
164
|
+
* @param {unknown} frameworkDefaults — resolved defaults at the seed root.
|
|
176
165
|
* @param {string} prefix — dotted path under construction.
|
|
166
|
+
* @param {{ addedKeys: string[], skippedKeys: string[] }} [out]
|
|
177
167
|
*/
|
|
178
168
|
function mergeMissingKeys(
|
|
179
169
|
target,
|
|
180
170
|
defaults,
|
|
181
|
-
frameworkDefaults
|
|
182
|
-
prefix
|
|
171
|
+
frameworkDefaults,
|
|
172
|
+
prefix,
|
|
173
|
+
out = { addedKeys: [], skippedKeys: [] },
|
|
183
174
|
) {
|
|
184
|
-
const addedKeys = [];
|
|
185
|
-
const skippedKeys = [];
|
|
186
175
|
for (const [key, value] of Object.entries(defaults)) {
|
|
187
|
-
const keyPath =
|
|
188
|
-
const frameworkValue =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (!target[key] || typeof target[key] !== 'object') {
|
|
194
|
-
target[key] = {};
|
|
195
|
-
}
|
|
196
|
-
const nested = mergeMissingKeys(
|
|
197
|
-
target[key],
|
|
198
|
-
value,
|
|
199
|
-
frameworkValue ?? {},
|
|
200
|
-
keyPath,
|
|
201
|
-
);
|
|
202
|
-
addedKeys.push(...nested.addedKeys);
|
|
203
|
-
skippedKeys.push(...nested.skippedKeys);
|
|
204
|
-
if (
|
|
205
|
-
Object.keys(target[key]).length === 0 &&
|
|
206
|
-
target[key] !== frameworkDefaults?.[key]
|
|
207
|
-
) {
|
|
208
|
-
delete target[key];
|
|
209
|
-
}
|
|
176
|
+
const keyPath = `${prefix}.${key}`;
|
|
177
|
+
const frameworkValue = isObject(frameworkDefaults)
|
|
178
|
+
? frameworkDefaults[key]
|
|
179
|
+
: undefined;
|
|
180
|
+
if (isObject(value)) {
|
|
181
|
+
mergeNestedKey(target, key, value, frameworkValue, keyPath, out);
|
|
210
182
|
} else if (target[key] === undefined) {
|
|
211
|
-
|
|
212
|
-
skippedKeys.push(keyPath);
|
|
213
|
-
} else {
|
|
214
|
-
target[key] = value;
|
|
215
|
-
addedKeys.push(keyPath);
|
|
216
|
-
}
|
|
183
|
+
seedLeafKey(target, key, value, frameworkValue, keyPath, out);
|
|
217
184
|
}
|
|
218
185
|
}
|
|
219
|
-
return
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function mergeNestedKey(target, key, value, frameworkValue, keyPath, out) {
|
|
190
|
+
if (!target[key] || typeof target[key] !== 'object') target[key] = {};
|
|
191
|
+
mergeMissingKeys(target[key], value, frameworkValue ?? {}, keyPath, out);
|
|
192
|
+
if (Object.keys(target[key]).length === 0 && target[key] !== frameworkValue) {
|
|
193
|
+
delete target[key];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function seedLeafKey(target, key, value, frameworkValue, keyPath, out) {
|
|
198
|
+
if (deepEqual(value, frameworkValue)) {
|
|
199
|
+
out.skippedKeys.push(keyPath);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
target[key] = value;
|
|
203
|
+
out.addedKeys.push(keyPath);
|
|
220
204
|
}
|
|
221
205
|
|
|
222
206
|
/**
|
|
223
207
|
* Seed missing quality defaults into `.agentrc.json`; writes nothing when the
|
|
224
208
|
* file is absent (base bootstrap must run first).
|
|
225
209
|
*/
|
|
226
|
-
|
|
210
|
+
function ensureQualityConfigDefaults(ctx) {
|
|
227
211
|
const cfgPath = path.join(ctx.projectRoot, '.agentrc.json');
|
|
228
212
|
const cfg = readJsonIfExists(cfgPath);
|
|
229
213
|
if (!cfg) {
|
|
@@ -275,7 +259,7 @@ const LEGACY_EPIC_BASELINES_RELPATH = 'baselines/epic';
|
|
|
275
259
|
* @param {typeof defaultSpawnSync} [ctx.spawnImpl]
|
|
276
260
|
* @returns {{ action: 'absent'|'pruned', path: string, gitStatus?: number|null }}
|
|
277
261
|
*/
|
|
278
|
-
|
|
262
|
+
function pruneLegacyEpicBaselines(ctx) {
|
|
279
263
|
const target = path.join(ctx.projectRoot, 'baselines', 'epic');
|
|
280
264
|
if (!fs.existsSync(target)) return { action: 'absent', path: target };
|
|
281
265
|
const spawn = ctx.spawnImpl ?? defaultSpawnSync;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { isSafeBranchComponent } from './dependency-parser.js';
|
|
9
|
+
import { isObject } from './json-utils.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Names that must never be forwarded to a destructive git operation.
|
|
@@ -53,9 +54,7 @@ export function assertBranchSafe(...args) {
|
|
|
53
54
|
let names = args;
|
|
54
55
|
const last = args[args.length - 1];
|
|
55
56
|
if (
|
|
56
|
-
last
|
|
57
|
-
typeof last === 'object' &&
|
|
58
|
-
!Array.isArray(last) &&
|
|
57
|
+
isObject(last) &&
|
|
59
58
|
('protected' in last || Object.keys(last).length === 0)
|
|
60
59
|
) {
|
|
61
60
|
opts = last;
|
|
@@ -10,6 +10,7 @@ import path from 'node:path';
|
|
|
10
10
|
|
|
11
11
|
import { applyHeader } from '../command-header.js';
|
|
12
12
|
import { applyAgentModel, getAgentModels } from '../config/agent-models.js';
|
|
13
|
+
import { readJsonOrNull } from '../json-utils.js';
|
|
13
14
|
import { dirExists } from '../util/paths.js';
|
|
14
15
|
|
|
15
16
|
export const CLAUDE_AGENTS_DIR = '.claude/agents';
|
|
@@ -32,18 +33,6 @@ function agentFilesIn(dir) {
|
|
|
32
33
|
.map((e) => e.name);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
/**
|
|
36
|
-
* @param {string} file
|
|
37
|
-
* @returns {object | null}
|
|
38
|
-
*/
|
|
39
|
-
function readJsonOrNull(file) {
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
36
|
/**
|
|
48
37
|
* `agentModels` with local merged over base per role, as `resolveConfig()`
|
|
49
38
|
* would, minus AJV; invalid entries are dropped.
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
import fs from 'node:fs';
|
|
13
13
|
import path from 'node:path';
|
|
14
|
-
|
|
15
14
|
import { extractDescription } from '../mandrel-catalog.js';
|
|
15
|
+
import { toPosix } from '../util/paths.js';
|
|
16
16
|
|
|
17
17
|
/** Project-relative POSIX home of the projection. */
|
|
18
18
|
export const CODEX_AGENTS_DIR = '.codex/agents';
|
|
@@ -194,10 +194,7 @@ export function expectedCodexAgents({
|
|
|
194
194
|
role,
|
|
195
195
|
source: fs.readFileSync(sourcePath, 'utf8'),
|
|
196
196
|
baseDir: path.dirname(sourcePath),
|
|
197
|
-
sourceLabel: path
|
|
198
|
-
.relative(projectRoot, sourcePath)
|
|
199
|
-
.split(path.sep)
|
|
200
|
-
.join('/'),
|
|
197
|
+
sourceLabel: toPosix(path.relative(projectRoot, sourcePath)),
|
|
201
198
|
}),
|
|
202
199
|
);
|
|
203
200
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
collectLocalSkillFiles,
|
|
18
18
|
collectSkillFiles,
|
|
19
19
|
} from '../skills/walk-skill-files.js';
|
|
20
|
-
import { dirExists } from '../util/paths.js';
|
|
20
|
+
import { dirExists, toPosix } from '../util/paths.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Project-relative POSIX home of the projection. Outside the `core`/`stack`
|
|
@@ -83,15 +83,6 @@ function listProjectableWorkflows({ payloadSrc, localSrc }) {
|
|
|
83
83
|
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/**
|
|
87
|
-
* @param {string} projectRoot
|
|
88
|
-
* @param {string} absPath
|
|
89
|
-
* @returns {string}
|
|
90
|
-
*/
|
|
91
|
-
function toPosixRelative(projectRoot, absPath) {
|
|
92
|
-
return path.relative(projectRoot, absPath).split(path.sep).join('/');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
86
|
/**
|
|
96
87
|
* @param {string | null} description
|
|
97
88
|
* @param {string} name
|
|
@@ -149,7 +140,7 @@ export function expectedCodexSkills({
|
|
|
149
140
|
renderCodexSkill({
|
|
150
141
|
name: wf.name,
|
|
151
142
|
description: extractDescription(wf.content),
|
|
152
|
-
workflowPath:
|
|
143
|
+
workflowPath: toPosix(path.relative(projectRoot, wf.sourcePath)),
|
|
153
144
|
}),
|
|
154
145
|
);
|
|
155
146
|
}
|
|
@@ -187,7 +178,8 @@ function assertProjectableNames(projectRoot, names) {
|
|
|
187
178
|
...collectLocalSkillFiles(projectRoot),
|
|
188
179
|
]) {
|
|
189
180
|
const skillName = skillNameOf(file);
|
|
190
|
-
if (skillName)
|
|
181
|
+
if (skillName)
|
|
182
|
+
taken.set(skillName, toPosix(path.relative(projectRoot, file)));
|
|
191
183
|
}
|
|
192
184
|
for (const name of names) {
|
|
193
185
|
if (name.length > CODEX_SKILL_NAME_MAX) {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import fs from 'node:fs';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { isObject } from '../json-utils.js';
|
|
9
10
|
|
|
10
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
12
|
// .agents/scripts/lib/config/ → .agents/
|
|
@@ -58,7 +59,7 @@ export function* iterDefaultLeaves(defaults, prefix = '') {
|
|
|
58
59
|
}
|
|
59
60
|
for (const [key, value] of Object.entries(defaults)) {
|
|
60
61
|
const dotted = prefix ? `${prefix}.${key}` : key;
|
|
61
|
-
if (
|
|
62
|
+
if (isObject(value)) {
|
|
62
63
|
yield* iterDefaultLeaves(value, dotted);
|
|
63
64
|
} else {
|
|
64
65
|
yield [dotted, value];
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* one app's steps cannot vouch for another's feature.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { isObject } from '../json-utils.js';
|
|
9
|
+
|
|
8
10
|
const GHERKIN_LINT_DEFAULTS = Object.freeze({
|
|
9
11
|
exemptionTags: Object.freeze(['@skip']),
|
|
10
12
|
stepWaivers: Object.freeze([]),
|
|
@@ -37,11 +39,8 @@ function normalizeScope(name, raw) {
|
|
|
37
39
|
* } | null} `null` when the block is absent or not an object
|
|
38
40
|
*/
|
|
39
41
|
function resolveGherkinLint(raw) {
|
|
40
|
-
if (!
|
|
41
|
-
const scopesRaw =
|
|
42
|
-
raw.scopes && typeof raw.scopes === 'object' && !Array.isArray(raw.scopes)
|
|
43
|
-
? raw.scopes
|
|
44
|
-
: {};
|
|
42
|
+
if (!isObject(raw)) return null;
|
|
43
|
+
const scopesRaw = isObject(raw.scopes) ? raw.scopes : {};
|
|
45
44
|
return {
|
|
46
45
|
scopes: Object.keys(scopesRaw)
|
|
47
46
|
.sort()
|
|
@@ -3,18 +3,11 @@
|
|
|
3
3
|
// Shell-injection constants live in config-schema-shared.js so the settings
|
|
4
4
|
// schema file can import them without pulling this module's AJV bundle.
|
|
5
5
|
// Re-exported here for backward-compatible import paths.
|
|
6
|
-
export {
|
|
7
|
-
SHELL_INJECTION_PATTERN_STRING,
|
|
8
|
-
SHELL_INJECTION_RE,
|
|
9
|
-
SHELL_INJECTION_RE_STRICT,
|
|
10
|
-
} from './config-schema-shared.js';
|
|
6
|
+
export { SHELL_INJECTION_RE_STRICT } from './config-schema-shared.js';
|
|
11
7
|
|
|
12
8
|
// The full agentrc schema lives in its own module to keep this file under
|
|
13
9
|
// escomplex's Halstead-volume ceiling. Re-exported here for import stability.
|
|
14
10
|
export {
|
|
15
|
-
AGENT_SETTINGS_STRING_FIELDS,
|
|
16
11
|
AGENTRC_SCHEMA,
|
|
17
|
-
COMMENT_EVENT_NAMES,
|
|
18
12
|
getAgentrcValidator,
|
|
19
|
-
WEBHOOK_EVENT_NAMES,
|
|
20
13
|
} from './config-settings-schema.js';
|
|
@@ -41,9 +41,6 @@ const NULLABLE_NONEMPTY_SAFE_STRING = {
|
|
|
41
41
|
not: { type: 'string', pattern: SHELL_INJECTION_PATTERN_STRING },
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
/** Kept empty so existing imports still resolve. */
|
|
45
|
-
export const AGENT_SETTINGS_STRING_FIELDS = Object.freeze([]);
|
|
46
|
-
|
|
47
44
|
// project.*
|
|
48
45
|
|
|
49
46
|
const PATHS_SCHEMA = {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
captureStampPath,
|
|
13
13
|
MissingCoverageArtifactError,
|
|
14
14
|
} from './coverage-capture.js';
|
|
15
|
+
import { isObject } from './json-utils.js';
|
|
15
16
|
|
|
16
17
|
const COVERAGE_FINAL_PATH = COVERAGE_CAPTURE_DEFAULTS.coveragePath;
|
|
17
18
|
const COVERAGE_BASELINE_PATH = 'baselines/coverage.json';
|
|
@@ -106,9 +107,7 @@ export function readCoverageFinal(cwd, opts = {}, fsImpl) {
|
|
|
106
107
|
|
|
107
108
|
function isEnvelopeShape(parsed) {
|
|
108
109
|
return (
|
|
109
|
-
parsed &&
|
|
110
|
-
typeof parsed === 'object' &&
|
|
111
|
-
!Array.isArray(parsed) &&
|
|
110
|
+
isObject(parsed) &&
|
|
112
111
|
Array.isArray(parsed.rows) &&
|
|
113
112
|
typeof parsed.$schema === 'string'
|
|
114
113
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import { isObject } from './json-utils.js';
|
|
2
3
|
|
|
3
4
|
const COVERAGE_INDEX = Symbol('coverage-utils.coverage-index');
|
|
4
5
|
const ENTRY_INDEX = Symbol('coverage-utils.entry-index');
|
|
@@ -39,7 +40,7 @@ function stripLeadingDotSlash(p) {
|
|
|
39
40
|
*/
|
|
40
41
|
export function buildCoverageIndex(map) {
|
|
41
42
|
const byNormalizedSuffix = new Map();
|
|
42
|
-
if (
|
|
43
|
+
if (isObject(map)) {
|
|
43
44
|
for (const key of Object.keys(map)) {
|
|
44
45
|
byNormalizedSuffix.set(normalizeSep(key), map[key]);
|
|
45
46
|
}
|
|
@@ -103,7 +103,6 @@ export async function runOnPool(workerScript, items, opts = {}) {
|
|
|
103
103
|
const myIndex = nextIndex++;
|
|
104
104
|
if (myIndex >= itemsArr.length) break;
|
|
105
105
|
const item = itemsArr[myIndex];
|
|
106
|
-
// eslint-disable-next-line no-await-in-loop
|
|
107
106
|
const outcome = await dispatchOne(worker, item);
|
|
108
107
|
if (outcome.kind === 'ok') {
|
|
109
108
|
results[myIndex] = outcome.result;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { createGitInterface } from './git-utils.js';
|
|
12
12
|
import { isIgnoredByGlobs } from './maintainability-utils.js';
|
|
13
|
+
import { toPosix } from './util/paths.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* `diff HEAD` already covers staged and unstaged, so no `--cached` pass.
|
|
@@ -96,7 +97,7 @@ export function selectFilesToScore(
|
|
|
96
97
|
const selected = [];
|
|
97
98
|
for (const abs of files) {
|
|
98
99
|
if (isIgnoredByGlobs(abs, ignoreGlobs, cwd)) continue;
|
|
99
|
-
const rel = path.relative(cwd, abs)
|
|
100
|
+
const rel = toPosix(path.relative(cwd, abs));
|
|
100
101
|
if (scopeFiles && !scopeFiles.has(rel)) continue;
|
|
101
102
|
selected.push({ abs, rel });
|
|
102
103
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import nodeFs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
|
+
import { toPosix } from './util/paths.js';
|
|
11
12
|
import { resolveWorkflowClosures } from './workflow-closure.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -78,7 +79,7 @@ export function parseImportSpecifiers(source) {
|
|
|
78
79
|
* @returns {string}
|
|
79
80
|
*/
|
|
80
81
|
function toRepoRel(root, abs) {
|
|
81
|
-
return path.relative(root, abs)
|
|
82
|
+
return toPosix(path.relative(root, abs));
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/**
|
|
@@ -242,6 +242,9 @@ export function classify({
|
|
|
242
242
|
return new GhExecError(`gh-exec: gh exited with code ${code}`, details);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
/** Windows (libuv) reports a broken pipe on a pending write as `EOF`. */
|
|
246
|
+
const BROKEN_PIPE_CODES = new Set(['EPIPE', 'EOF']);
|
|
247
|
+
|
|
245
248
|
/**
|
|
246
249
|
* @param {object} opts
|
|
247
250
|
* @param {string[]} opts.args
|
|
@@ -294,6 +297,7 @@ export function exec({
|
|
|
294
297
|
let stdout = '';
|
|
295
298
|
let stderr = '';
|
|
296
299
|
let settled = false;
|
|
300
|
+
let stdinError = null;
|
|
297
301
|
|
|
298
302
|
child.stdout?.on('data', (chunk) => {
|
|
299
303
|
stdout += chunk.toString('utf8');
|
|
@@ -316,7 +320,7 @@ export function exec({
|
|
|
316
320
|
const timedOut =
|
|
317
321
|
spawnOpts.timeout !== undefined &&
|
|
318
322
|
(signal === 'SIGTERM' || code === null);
|
|
319
|
-
if (timedOut
|
|
323
|
+
if (timedOut) {
|
|
320
324
|
reject(
|
|
321
325
|
new GhExecTimeoutError(
|
|
322
326
|
`gh-exec: gh ${args.join(' ')} exceeded ${spawnOpts.timeout}ms`,
|
|
@@ -331,6 +335,17 @@ export function exec({
|
|
|
331
335
|
return;
|
|
332
336
|
}
|
|
333
337
|
|
|
338
|
+
// A clean exit after a failed stdin write may have run on truncated input.
|
|
339
|
+
if (stdinError) {
|
|
340
|
+
reject(
|
|
341
|
+
new GhExecError(
|
|
342
|
+
`gh-exec: writing gh stdin failed: ${stdinError.message}`,
|
|
343
|
+
{ args, stdout, stderr, code },
|
|
344
|
+
),
|
|
345
|
+
);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
|
|
334
349
|
if (wantsJson) {
|
|
335
350
|
try {
|
|
336
351
|
resolve(JSON.parse(stdout));
|
|
@@ -348,6 +363,11 @@ export function exec({
|
|
|
348
363
|
resolve({ stdout, stderr, code });
|
|
349
364
|
});
|
|
350
365
|
|
|
366
|
+
// A gh that exits before reading stdin breaks the pipe; its exit still
|
|
367
|
+
// settles the call. Any other write error rejects at 'close', never throws.
|
|
368
|
+
child.stdin?.on?.('error', (err) => {
|
|
369
|
+
if (!BROKEN_PIPE_CODES.has(err.code)) stdinError = err;
|
|
370
|
+
});
|
|
351
371
|
if (typeof input === 'string' && child.stdin) {
|
|
352
372
|
child.stdin.end(input);
|
|
353
373
|
} else if (child.stdin) {
|