mandrel 2.88.0 → 2.90.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/docs/agentrc-reference.json +3 -1
- package/.agents/docs/configuration.md +9 -0
- package/.agents/schemas/agentrc.schema.json +13 -0
- package/.agents/scripts/board-backfill.js +253 -0
- package/.agents/scripts/coverage-capture.js +32 -49
- 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/crap-preview-scan.js +3 -1
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +2 -0
- package/.agents/scripts/lib/baselines/kinds/crap.js +37 -16
- package/.agents/scripts/lib/baselines/preview-gates.js +1 -0
- package/.agents/scripts/lib/close-validation/gates.js +40 -9
- package/.agents/scripts/lib/close-validation/process.js +5 -1
- package/.agents/scripts/lib/config/gates/crap.schema.js +15 -0
- package/.agents/scripts/lib/config/quality.js +49 -1
- 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 +79 -38
- package/.agents/scripts/lib/crap-utils.js +6 -2
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/maintainability-utils.js +6 -1
- package/.agents/scripts/lib/observability/source-classifier.js +1 -0
- package/.agents/scripts/lib/orchestration/board-access-latch.js +101 -0
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +1 -1
- package/.agents/scripts/lib/orchestration/column-sync.js +107 -52
- package/.agents/scripts/lib/orchestration/project-meta-resolver.js +44 -17
- package/.agents/scripts/lib/orchestration/story-handoff.js +14 -1
- package/.agents/scripts/lib/orchestration/verify-credit.js +4 -1
- package/.agents/scripts/providers/github/board-add.js +18 -9
- package/.agents/scripts/providers/github/projects-v2-graphql.js +15 -3
- package/.agents/scripts/update-crap-baseline.js +2 -2
- package/.agents/workflows/audit-baselines.md +7 -2
- package/docs/CHANGELOG.md +26 -0
- package/lib/cli/doctor-checks/project-access.js +114 -0
- package/lib/cli/registry.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// lib/cli/doctor-checks/project-access.js — Doctor check: github-project-access.
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { isInsufficientScopes } from '../../../.agents/scripts/providers/github/projects-v2-graphql.js';
|
|
7
|
+
import { readJsonSafe } from './read-json.js';
|
|
8
|
+
import { spawn } from './spawn.js';
|
|
9
|
+
|
|
10
|
+
const REMEDY = 'Run `gh auth refresh -h github.com -s project`, then re-run.';
|
|
11
|
+
|
|
12
|
+
// A gh that cannot authenticate at all is gh-auth's failure, not this one's.
|
|
13
|
+
const GH_AUTH_RE = /gh auth login|not logged in|Bad credentials|HTTP 401/i;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `github.projectNumber` / `github.owner` from `.agentrc.json`, with
|
|
17
|
+
* `.agentrc.local.json` winning per key.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} projectRoot
|
|
20
|
+
* @param {{ readFileSync: Function }} fsImpl
|
|
21
|
+
* @returns {{ projectNumber: number|null, owner: string|null }}
|
|
22
|
+
*/
|
|
23
|
+
function readBoardConfig(projectRoot, fsImpl) {
|
|
24
|
+
const base = readJsonSafe(path.join(projectRoot, '.agentrc.json'), fsImpl);
|
|
25
|
+
const local = readJsonSafe(
|
|
26
|
+
path.join(projectRoot, '.agentrc.local.json'),
|
|
27
|
+
fsImpl,
|
|
28
|
+
);
|
|
29
|
+
const github = { ...(base?.github ?? {}), ...(local?.github ?? {}) };
|
|
30
|
+
const n = Number(github.projectNumber);
|
|
31
|
+
return {
|
|
32
|
+
projectNumber: Number.isInteger(n) && n > 0 ? n : null,
|
|
33
|
+
owner:
|
|
34
|
+
typeof github.owner === 'string' && github.owner ? github.owner : null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One rung's query: `organization` / `user` by login, else `viewer`. */
|
|
39
|
+
function rungArgs(root, owner, projectNumber) {
|
|
40
|
+
const query = owner
|
|
41
|
+
? `query($owner:String!,$number:Int!){${root}(login:$owner){projectV2(number:$number){id}}}`
|
|
42
|
+
: `query($number:Int!){viewer{projectV2(number:$number){id}}}`;
|
|
43
|
+
const args = ['api', 'graphql', '-f', `query=${query}`];
|
|
44
|
+
if (owner) args.push('-f', `owner=${owner}`);
|
|
45
|
+
args.push('-F', `number=${projectNumber}`);
|
|
46
|
+
return args;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Probe one rung.
|
|
51
|
+
*
|
|
52
|
+
* @returns {'found'|'miss'|'scope'|'defer'}
|
|
53
|
+
*/
|
|
54
|
+
function probeRung(runner, root, owner, projectNumber) {
|
|
55
|
+
const r = runner('gh', rungArgs(root, owner, projectNumber), {
|
|
56
|
+
timeout: 20_000,
|
|
57
|
+
});
|
|
58
|
+
if (r.error) return 'defer';
|
|
59
|
+
const output = `${r.stdout ?? ''}\n${r.stderr ?? ''}`;
|
|
60
|
+
if (isInsufficientScopes({ message: output })) return 'scope';
|
|
61
|
+
if (r.status !== 0 && GH_AUTH_RE.test(output)) return 'defer';
|
|
62
|
+
try {
|
|
63
|
+
const json = JSON.parse(r.stdout || '{}');
|
|
64
|
+
if (json?.data?.[root]?.projectV2?.id) return 'found';
|
|
65
|
+
} catch {
|
|
66
|
+
// Non-JSON output is a miss for this rung.
|
|
67
|
+
}
|
|
68
|
+
return 'miss';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// check: github-project-access
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Can the active token read the configured Projects v2 board? No board →
|
|
75
|
+
* skipped; a gh that cannot run defers to `gh-auth`.
|
|
76
|
+
*
|
|
77
|
+
* @param {{ cwd?: () => string, fsImpl?: typeof fs, runner?: typeof spawn }} [opts]
|
|
78
|
+
* @returns {{ ok: boolean, detail: string, remedy?: string }}
|
|
79
|
+
*/
|
|
80
|
+
export function runProjectAccess({ cwd, fsImpl = fs, runner = spawn } = {}) {
|
|
81
|
+
const projectRoot = (cwd ?? (() => process.cwd()))();
|
|
82
|
+
const { projectNumber, owner } = readBoardConfig(projectRoot, fsImpl);
|
|
83
|
+
if (!projectNumber) {
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
detail: 'skipped — no github.projectNumber configured',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const roots = owner ? ['organization', 'user'] : ['viewer'];
|
|
90
|
+
const target = `project #${projectNumber}${owner ? ` for ${owner}` : ''}`;
|
|
91
|
+
for (const root of roots) {
|
|
92
|
+
const outcome = probeRung(runner, root, owner, projectNumber);
|
|
93
|
+
if (outcome === 'found') return { ok: true, detail: `${target} readable` };
|
|
94
|
+
if (outcome === 'defer') {
|
|
95
|
+
return {
|
|
96
|
+
ok: true,
|
|
97
|
+
detail: 'skipped — gh cannot run or authenticate (see gh-auth)',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (outcome === 'scope') {
|
|
101
|
+
return {
|
|
102
|
+
ok: false,
|
|
103
|
+
detail: `token lacks the "project" scope — cannot read ${target}; board adds and Status flips are being skipped`,
|
|
104
|
+
remedy: REMEDY,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
ok: false,
|
|
110
|
+
detail: `${target} not found`,
|
|
111
|
+
remedy:
|
|
112
|
+
'Check github.projectNumber and github.owner in .agentrc.json (or `gh auth refresh -h github.com -s project` if the board is private).',
|
|
113
|
+
};
|
|
114
|
+
}
|
package/lib/cli/registry.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from './doctor-checks/codex.js';
|
|
20
20
|
import { runMergeDriver } from './doctor-checks/merge-driver.js';
|
|
21
21
|
import { runAgentsDrift, runPinCurrent } from './doctor-checks/payload.js';
|
|
22
|
+
import { runProjectAccess } from './doctor-checks/project-access.js';
|
|
22
23
|
import {
|
|
23
24
|
runAgentsMaterialized,
|
|
24
25
|
runRuntimeDeps,
|
|
@@ -72,6 +73,11 @@ export const registry = [
|
|
|
72
73
|
name: 'gh-auth',
|
|
73
74
|
run: (opts) => runGhAuth(opts),
|
|
74
75
|
},
|
|
76
|
+
// Presupposes gh-auth: an unauthenticated gh defers there.
|
|
77
|
+
{
|
|
78
|
+
name: 'github-project-access',
|
|
79
|
+
run: (opts) => runProjectAccess(opts),
|
|
80
|
+
},
|
|
75
81
|
{
|
|
76
82
|
name: 'commands-in-sync',
|
|
77
83
|
run: (opts) => runCommandsInSync(opts),
|
package/package.json
CHANGED