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
|
@@ -15,7 +15,13 @@ function normalizeLabels(issue) {
|
|
|
15
15
|
return [];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Fields every REST-issue mapper shares.
|
|
20
|
+
*
|
|
21
|
+
* @param {object} issue
|
|
22
|
+
* @returns {object}
|
|
23
|
+
*/
|
|
24
|
+
function baseIssueFields(issue) {
|
|
19
25
|
const labels = normalizeLabels(issue);
|
|
20
26
|
return {
|
|
21
27
|
id: issue.number,
|
|
@@ -25,24 +31,22 @@ export function issueToTicket(issue) {
|
|
|
25
31
|
body: issue.body ?? '',
|
|
26
32
|
labels,
|
|
27
33
|
labelSet: new Set(labels),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function issueToTicket(issue) {
|
|
38
|
+
return {
|
|
39
|
+
...baseIssueFields(issue),
|
|
28
40
|
assignees: (issue.assignees ?? []).map((a) => a.login),
|
|
29
41
|
state: issue.state,
|
|
30
42
|
// Distinguishes a landed Story from a superseded one; both are `closed`.
|
|
31
43
|
stateReason: issue.state_reason ?? null,
|
|
44
|
+
closedAt: issue.closed_at ?? null,
|
|
32
45
|
};
|
|
33
46
|
}
|
|
34
47
|
|
|
35
48
|
export function issueToEpic(issue) {
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
id: issue.number,
|
|
39
|
-
internalId: issue.id,
|
|
40
|
-
nodeId: issue.node_id,
|
|
41
|
-
title: issue.title,
|
|
42
|
-
body: issue.body ?? '',
|
|
43
|
-
labels,
|
|
44
|
-
labelSet: new Set(labels),
|
|
45
|
-
};
|
|
49
|
+
return baseIssueFields(issue);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
export function subIssueNodeToTicket(node) {
|
|
@@ -80,15 +84,8 @@ export function subIssueNodesToTickets(nodes) {
|
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
export function issueToListItem(issue) {
|
|
83
|
-
const labels = normalizeLabels(issue);
|
|
84
87
|
return {
|
|
85
|
-
|
|
86
|
-
internalId: issue.id,
|
|
87
|
-
nodeId: issue.node_id,
|
|
88
|
-
title: issue.title,
|
|
89
|
-
body: issue.body ?? '',
|
|
90
|
-
labels,
|
|
91
|
-
labelSet: new Set(labels),
|
|
88
|
+
...baseIssueFields(issue),
|
|
92
89
|
state: issue.state,
|
|
93
90
|
};
|
|
94
91
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Projects V2 GraphQL shim. Token: `
|
|
2
|
+
* Projects V2 GraphQL shim. Token: `auth.js#resolveToken`.
|
|
3
3
|
* Soft-fails on INSUFFICIENT_SCOPES via `{scopesMissing:true}` /
|
|
4
4
|
* `status:'scopes-missing'` / `unavailable:true` envelopes.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { resolveToken } from './auth.js';
|
|
7
7
|
import { withTransientRetry } from './errors.js';
|
|
8
|
+
import { ensureIdentityForQuery } from './identity.js';
|
|
8
9
|
|
|
9
10
|
// Resolve an owner node id per-scope. Querying `user` and `organization`
|
|
10
11
|
// together in one request makes GitHub return a NOT_FOUND error for whichever
|
|
@@ -30,40 +31,6 @@ const opt = (name, id) => ({
|
|
|
30
31
|
description: '',
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
function readGhCliToken() {
|
|
34
|
-
try {
|
|
35
|
-
const cliToken = execSync('gh auth token', {
|
|
36
|
-
encoding: 'utf8',
|
|
37
|
-
timeout: 5000,
|
|
38
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
39
|
-
}).trim();
|
|
40
|
-
return cliToken || null;
|
|
41
|
-
} catch {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function readEnvToken() {
|
|
47
|
-
return process.env.GITHUB_TOKEN || process.env.GH_TOKEN || null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function memoizeEnvToken(token) {
|
|
51
|
-
if (!process.env.GITHUB_TOKEN) process.env.GITHUB_TOKEN = token;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function resolveToken() {
|
|
55
|
-
const envToken = readEnvToken();
|
|
56
|
-
if (envToken) return envToken;
|
|
57
|
-
const ghToken = readGhCliToken();
|
|
58
|
-
if (!ghToken) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
'[GitHubProvider] No GitHub token (set GITHUB_TOKEN or run `gh auth login`).',
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
memoizeEnvToken(ghToken);
|
|
64
|
-
return ghToken;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
34
|
export const isInsufficientScopes = (err) =>
|
|
68
35
|
Boolean(err) &&
|
|
69
36
|
SCOPES_RE.test(err.message ?? err.toString?.() ?? String(err));
|
|
@@ -71,6 +38,7 @@ export const isScopesMissingEnvelope = (value) =>
|
|
|
71
38
|
Boolean(value) && typeof value === 'object' && value.scopesMissing === true;
|
|
72
39
|
|
|
73
40
|
async function gql(ctx, query, variables, { retry = false } = {}) {
|
|
41
|
+
await ensureIdentityForQuery(ctx, query);
|
|
74
42
|
const run = async () => {
|
|
75
43
|
const fetchImpl = ctx.fetchImpl ?? globalThis.fetch;
|
|
76
44
|
const response = await fetchImpl('https://api.github.com/graphql', {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Logger } from '../../lib/Logger.js';
|
|
6
|
+
import { concurrentMap } from '../../lib/util/concurrent-map.js';
|
|
6
7
|
import { withTransientRetry } from './errors.js';
|
|
7
8
|
|
|
8
9
|
export const DEFAULT_PAGE_CAP = 50;
|
|
@@ -80,3 +81,46 @@ export async function paginateRest(ghFacade, endpoint, opts = {}) {
|
|
|
80
81
|
}
|
|
81
82
|
return items;
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* POST one request per edge, `concurrency` in flight; never throws — a failed
|
|
87
|
+
* POST is warned (`describe(edge): message`) and counted.
|
|
88
|
+
*
|
|
89
|
+
* @param {{
|
|
90
|
+
* edges: Array<*>,
|
|
91
|
+
* endpointFor: (edge: *) => string,
|
|
92
|
+
* bodyFor: (edge: *) => object,
|
|
93
|
+
* describe: (edge: *) => string,
|
|
94
|
+
* gh: object,
|
|
95
|
+
* concurrency: number,
|
|
96
|
+
* }} opts
|
|
97
|
+
* @returns {Promise<{ added: number, failed: number }>}
|
|
98
|
+
*/
|
|
99
|
+
export async function postEdges({
|
|
100
|
+
edges,
|
|
101
|
+
endpointFor,
|
|
102
|
+
bodyFor,
|
|
103
|
+
describe,
|
|
104
|
+
gh,
|
|
105
|
+
concurrency,
|
|
106
|
+
}) {
|
|
107
|
+
const perEdge = await concurrentMap(
|
|
108
|
+
edges,
|
|
109
|
+
async (edge) => {
|
|
110
|
+
try {
|
|
111
|
+
await gh.api({
|
|
112
|
+
method: 'POST',
|
|
113
|
+
endpoint: endpointFor(edge),
|
|
114
|
+
body: bodyFor(edge),
|
|
115
|
+
});
|
|
116
|
+
return true;
|
|
117
|
+
} catch (err) {
|
|
118
|
+
Logger.warn(`${describe(edge)}: ${err.message}`);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{ concurrency },
|
|
123
|
+
);
|
|
124
|
+
const added = perEdge.filter(Boolean).length;
|
|
125
|
+
return { added, failed: perEdge.length - added };
|
|
126
|
+
}
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { Logger } from '../../lib/Logger.js';
|
|
14
|
-
import {
|
|
15
|
-
import { paginateRest } from './request-helpers.js';
|
|
14
|
+
import { paginateRest, postEdges } from './request-helpers.js';
|
|
16
15
|
|
|
17
16
|
/** Kept modest for GitHub's secondary rate limits. */
|
|
18
17
|
const EDGE_CONCURRENCY = 5;
|
|
@@ -82,32 +81,16 @@ export async function addSubIssueEdges({
|
|
|
82
81
|
const missing = ids.filter((id) => !existingSet.has(id));
|
|
83
82
|
const skipped = ids.length - missing.length;
|
|
84
83
|
|
|
85
|
-
const
|
|
86
|
-
missing,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
} catch (err) {
|
|
96
|
-
Logger.warn(
|
|
97
|
-
`[sub-issue-add] Failed to link child(id=${childId}) under #${issueNumber}: ${err.message}`,
|
|
98
|
-
);
|
|
99
|
-
return { added: 0, failed: 1 };
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
{ concurrency: EDGE_CONCURRENCY },
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
let added = 0;
|
|
106
|
-
let failed = 0;
|
|
107
|
-
for (const r of perEdge) {
|
|
108
|
-
added += r.added;
|
|
109
|
-
failed += r.failed;
|
|
110
|
-
}
|
|
84
|
+
const { added, failed } = await postEdges({
|
|
85
|
+
edges: missing,
|
|
86
|
+
endpointFor: () =>
|
|
87
|
+
`/repos/${owner}/${repo}/issues/${issueNumber}/sub_issues`,
|
|
88
|
+
bodyFor: (childId) => ({ sub_issue_id: childId }),
|
|
89
|
+
describe: (childId) =>
|
|
90
|
+
`[sub-issue-add] Failed to link child(id=${childId}) under #${issueNumber}`,
|
|
91
|
+
gh,
|
|
92
|
+
concurrency: EDGE_CONCURRENCY,
|
|
93
|
+
});
|
|
111
94
|
|
|
112
95
|
return { added, skipped, failed };
|
|
113
96
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
isTransientByCodeOrMessage,
|
|
18
18
|
isTransientStatus,
|
|
19
19
|
} from './github/errors.js';
|
|
20
|
+
import { gateProviderGh } from './github/identity.js';
|
|
20
21
|
import * as projects from './github/projects-v2-graphql.js';
|
|
21
22
|
|
|
22
23
|
export {
|
|
@@ -45,8 +46,15 @@ export class GitHubProvider extends ITicketingProvider {
|
|
|
45
46
|
this._explicitToken = opts.token ?? null;
|
|
46
47
|
this._memoizedToken = opts.token ?? null;
|
|
47
48
|
// An injected `opts.gh` is honored as-is (test seam).
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
// Sets `_gh` (writes gated on the identity preflight) and `_ensureIdentity`.
|
|
50
|
+
Object.assign(
|
|
51
|
+
this,
|
|
52
|
+
gateProviderGh(
|
|
53
|
+
opts.gh ?? createGh(undefined, { timeoutMs: GH_DEFAULT_TIMEOUT_MS }),
|
|
54
|
+
this.operatorHandle,
|
|
55
|
+
opts,
|
|
56
|
+
),
|
|
57
|
+
);
|
|
50
58
|
this._cache = createInlineTicketCache();
|
|
51
59
|
composeGateways(this);
|
|
52
60
|
}
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
* scored for the branch's own work, not everything the base landed.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import path from 'node:path';
|
|
10
9
|
import process from 'node:process';
|
|
11
10
|
import {
|
|
12
11
|
runCrapPreview,
|
|
13
12
|
runMaintainabilityPreview,
|
|
14
13
|
} from './lib/baselines/preview-gates.js';
|
|
15
14
|
import { resolveMergeHead } from './lib/changed-files.js';
|
|
16
|
-
import {
|
|
15
|
+
import { runAsCli } from './lib/cli-utils.js';
|
|
17
16
|
import { CODING_GUARDRAILS } from './lib/config/quality.js';
|
|
18
17
|
|
|
19
18
|
const USAGE = {
|
|
@@ -537,20 +536,8 @@ export async function runCli({
|
|
|
537
536
|
};
|
|
538
537
|
}
|
|
539
538
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
const normalizedSelf = /^\/[A-Za-z]:/.test(self) ? self.slice(1) : self;
|
|
546
|
-
return path.resolve(normalizedSelf) === invoked;
|
|
547
|
-
} catch {
|
|
548
|
-
return false;
|
|
549
|
-
}
|
|
550
|
-
})();
|
|
551
|
-
|
|
552
|
-
if (isDirect && !respondToHelp(process.argv.slice(2), USAGE)) {
|
|
553
|
-
runCli().then(({ exitCode }) => {
|
|
554
|
-
process.exit(exitCode);
|
|
555
|
-
});
|
|
556
|
-
}
|
|
539
|
+
runAsCli(import.meta.url, async () => (await runCli()).exitCode, {
|
|
540
|
+
source: 'quality:preview',
|
|
541
|
+
propagateExitCode: true,
|
|
542
|
+
usage: USAGE,
|
|
543
|
+
});
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
} from './lib/orchestration/story-deliver-terminal.js';
|
|
46
46
|
import { PROJECT_ROOT } from './lib/project-root.js';
|
|
47
47
|
import { createProvider } from './lib/provider-factory.js';
|
|
48
|
-
import {
|
|
48
|
+
import { confirmAndLand } from './lib/single-story/confirm-and-land.js';
|
|
49
49
|
|
|
50
50
|
const progress = Logger.createProgress('single-story-confirm-merge', {
|
|
51
51
|
stderr: true,
|
|
@@ -292,8 +292,8 @@ function readCloseArmEvidence({ storyId, config, readCloseEnvelopeFn }) {
|
|
|
292
292
|
/**
|
|
293
293
|
* `--wait` runs the SAME phase as close so the cumulative budget give-up
|
|
294
294
|
* (the only path to `merge.unlanded` / `agent::blocked`) is reachable from a
|
|
295
|
-
* resume. The budget is anchored at the
|
|
296
|
-
* not restart the clock. The Story worktree is resolved (and recreated when
|
|
295
|
+
* resume. The budget is anchored at the latest auto-merge arm, which a
|
|
296
|
+
* resume does not move, so resuming does not restart the clock. The Story worktree is resolved (and recreated when
|
|
297
297
|
* missing) exactly as close does, so a DIRTY PR syncs there.
|
|
298
298
|
*/
|
|
299
299
|
async function resumeMergeWait(ctx) {
|
|
@@ -348,7 +348,7 @@ async function resumeMergeWait(ctx) {
|
|
|
348
348
|
async function probeMergeOnce(ctx) {
|
|
349
349
|
const { storyId, storyBranch, baseBranch, prNumber, cwd, provider, config } =
|
|
350
350
|
ctx;
|
|
351
|
-
const confirmation = await
|
|
351
|
+
const { confirmation, tail } = await confirmAndLand({
|
|
352
352
|
provider,
|
|
353
353
|
storyId,
|
|
354
354
|
prNumber,
|
|
@@ -359,24 +359,12 @@ async function probeMergeOnce(ctx) {
|
|
|
359
359
|
injectedGh: ctx.gh,
|
|
360
360
|
injectedNotify: ctx.injectedNotify,
|
|
361
361
|
readPrMergeStateFn: ctx.injectedReadPrMergeState,
|
|
362
|
+
storyBranch,
|
|
363
|
+
baseBranch,
|
|
364
|
+
// Bound at this module's own import, so a test's module mock reaches it.
|
|
365
|
+
runPostLandTailFn: runPostLandTail,
|
|
362
366
|
});
|
|
363
367
|
|
|
364
|
-
// The same shared land tail close runs. Gated on `merged`, not
|
|
365
|
-
// `action === 'done'`: an already-done Story (`noop`, merged) still needs
|
|
366
|
-
// the belated backfill. Every tail step is idempotent.
|
|
367
|
-
const tail =
|
|
368
|
-
confirmation.merged === true
|
|
369
|
-
? await runPostLandTail({
|
|
370
|
-
storyId,
|
|
371
|
-
storyBranch,
|
|
372
|
-
baseBranch,
|
|
373
|
-
cwd,
|
|
374
|
-
provider,
|
|
375
|
-
config,
|
|
376
|
-
progress,
|
|
377
|
-
})
|
|
378
|
-
: null;
|
|
379
|
-
|
|
380
368
|
const terminal = buildConfirmTerminal({
|
|
381
369
|
storyId,
|
|
382
370
|
storyBranch,
|
|
@@ -383,6 +383,62 @@ function reservationNote(withheld) {
|
|
|
383
383
|
return `${parts.join(' ')} Neither is a wedge and neither is a failure.`;
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
const isPositiveInt = (v) => Number.isInteger(v) && v > 0;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* @param {number[]} dependsOn
|
|
390
|
+
* @param {string} where `DAG entry at index <i> (id=<id>)`
|
|
391
|
+
* @returns {string|null}
|
|
392
|
+
*/
|
|
393
|
+
function dependsOnError(dependsOn, where) {
|
|
394
|
+
const j = dependsOn.findIndex((dep) => !isPositiveInt(dep));
|
|
395
|
+
return j === -1
|
|
396
|
+
? null
|
|
397
|
+
: `${where}: dependsOn[${j}] must be a positive integer`;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @param {unknown} files
|
|
402
|
+
* @returns {boolean}
|
|
403
|
+
*/
|
|
404
|
+
function isStringArray(files) {
|
|
405
|
+
return Array.isArray(files) && files.every((f) => typeof f === 'string');
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* One DAG entry → its node, or the first validation error.
|
|
410
|
+
*
|
|
411
|
+
* @param {unknown} entry
|
|
412
|
+
* @param {number} i
|
|
413
|
+
* @returns {{ node: {id: number, dependsOn: number[], files?: string[]}|null, error: string|null }}
|
|
414
|
+
*/
|
|
415
|
+
function validateDagEntry(entry, i) {
|
|
416
|
+
const at = `DAG entry at index ${i}`;
|
|
417
|
+
if (!entry || typeof entry !== 'object') {
|
|
418
|
+
return { node: null, error: `${at} must be an object` };
|
|
419
|
+
}
|
|
420
|
+
const { id, dependsOn, files } = entry;
|
|
421
|
+
if (!isPositiveInt(id)) {
|
|
422
|
+
return { node: null, error: `${at} must have a positive integer "id"` };
|
|
423
|
+
}
|
|
424
|
+
const where = `${at} (id=${id})`;
|
|
425
|
+
if (!Array.isArray(dependsOn)) {
|
|
426
|
+
return { node: null, error: `${where} must have a "dependsOn" array` };
|
|
427
|
+
}
|
|
428
|
+
const depError = dependsOnError(dependsOn, where);
|
|
429
|
+
if (depError) return { node: null, error: depError };
|
|
430
|
+
const node = { id, dependsOn: [...dependsOn] };
|
|
431
|
+
if (files === undefined) return { node, error: null };
|
|
432
|
+
if (!isStringArray(files)) {
|
|
433
|
+
return {
|
|
434
|
+
node: null,
|
|
435
|
+
error: `${where}: "files" must be an array of strings`,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
node.files = [...files];
|
|
439
|
+
return { node, error: null };
|
|
440
|
+
}
|
|
441
|
+
|
|
386
442
|
/**
|
|
387
443
|
* Validate the raw DAG array. An optional `files` footprint is forwarded so
|
|
388
444
|
* the overlap guard is active in flag mode too.
|
|
@@ -394,54 +450,10 @@ export function parseDag(raw) {
|
|
|
394
450
|
if (!Array.isArray(raw)) {
|
|
395
451
|
return { nodes: null, error: 'DAG input must be a JSON array' };
|
|
396
452
|
}
|
|
397
|
-
if (raw.length === 0) {
|
|
398
|
-
return { nodes: [], error: null };
|
|
399
|
-
}
|
|
400
453
|
const nodes = [];
|
|
401
454
|
for (let i = 0; i < raw.length; i++) {
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
return {
|
|
405
|
-
nodes: null,
|
|
406
|
-
error: `DAG entry at index ${i} must be an object`,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
const id = entry.id;
|
|
410
|
-
if (!Number.isInteger(id) || id <= 0) {
|
|
411
|
-
return {
|
|
412
|
-
nodes: null,
|
|
413
|
-
error: `DAG entry at index ${i} must have a positive integer "id"`,
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
const dependsOn = entry.dependsOn;
|
|
417
|
-
if (!Array.isArray(dependsOn)) {
|
|
418
|
-
return {
|
|
419
|
-
nodes: null,
|
|
420
|
-
error: `DAG entry at index ${i} (id=${id}) must have a "dependsOn" array`,
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
for (let j = 0; j < dependsOn.length; j++) {
|
|
424
|
-
const dep = dependsOn[j];
|
|
425
|
-
if (!Number.isInteger(dep) || dep <= 0) {
|
|
426
|
-
return {
|
|
427
|
-
nodes: null,
|
|
428
|
-
error: `DAG entry at index ${i} (id=${id}): dependsOn[${j}] must be a positive integer`,
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
const node = { id, dependsOn: [...dependsOn] };
|
|
433
|
-
if (entry.files !== undefined) {
|
|
434
|
-
if (
|
|
435
|
-
!Array.isArray(entry.files) ||
|
|
436
|
-
entry.files.some((f) => typeof f !== 'string')
|
|
437
|
-
) {
|
|
438
|
-
return {
|
|
439
|
-
nodes: null,
|
|
440
|
-
error: `DAG entry at index ${i} (id=${id}): "files" must be an array of strings`,
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
node.files = [...entry.files];
|
|
444
|
-
}
|
|
455
|
+
const { node, error } = validateDagEntry(raw[i], i);
|
|
456
|
+
if (error) return { nodes: null, error };
|
|
445
457
|
nodes.push(node);
|
|
446
458
|
}
|
|
447
459
|
return { nodes, error: null };
|
|
@@ -963,6 +975,7 @@ export async function runProbedStoriesWaveTick({
|
|
|
963
975
|
doneIds,
|
|
964
976
|
inFlight,
|
|
965
977
|
blockedIds = [],
|
|
978
|
+
confirmIds = [],
|
|
966
979
|
stalledDispatch = [],
|
|
967
980
|
foreignHeld = [],
|
|
968
981
|
inFlightRecords = [],
|
|
@@ -989,6 +1002,7 @@ export async function runProbedStoriesWaveTick({
|
|
|
989
1002
|
epilogueDue,
|
|
990
1003
|
blocked: blockedIds,
|
|
991
1004
|
blockedReason: blockedReasonFor(blockedIds),
|
|
1005
|
+
confirm: confirmIds,
|
|
992
1006
|
stalledDispatch,
|
|
993
1007
|
foreignHeld,
|
|
994
1008
|
foreignHeldReason: foreignHeldReasonFor(foreignHeld),
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
* @see .agents/scripts/lib/orchestration/story-handoff.js
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
18
|
+
import { parseStoryCwdArgv } from './lib/cli-args.js';
|
|
20
19
|
import { runAsCli } from './lib/cli-utils.js';
|
|
21
20
|
import { resolveConfig } from './lib/config-resolver.js';
|
|
22
21
|
import { runStoryHandoff } from './lib/orchestration/story-handoff.js';
|
|
@@ -37,26 +36,6 @@ const USAGE = {
|
|
|
37
36
|
],
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
/**
|
|
41
|
-
* @param {string[]} argv
|
|
42
|
-
* @returns {{ storyId: number|null, cwd: string|null }}
|
|
43
|
-
*/
|
|
44
|
-
function parseArgv(argv) {
|
|
45
|
-
const { values } = parseArgs({
|
|
46
|
-
args: argv,
|
|
47
|
-
options: {
|
|
48
|
-
story: { type: 'string' },
|
|
49
|
-
cwd: { type: 'string' },
|
|
50
|
-
},
|
|
51
|
-
strict: false,
|
|
52
|
-
});
|
|
53
|
-
const storyId = Number.parseInt(values.story ?? '', 10);
|
|
54
|
-
return {
|
|
55
|
-
storyId: Number.isInteger(storyId) && storyId > 0 ? storyId : null,
|
|
56
|
-
cwd: values.cwd ?? null,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
39
|
/**
|
|
61
40
|
* @param {string[]} [argv]
|
|
62
41
|
* @param {{
|
|
@@ -79,7 +58,7 @@ export async function runStoryHandoffCli(
|
|
|
79
58
|
stderr = process.stderr,
|
|
80
59
|
cwd: defaultCwd = process.cwd(),
|
|
81
60
|
} = deps;
|
|
82
|
-
const { storyId, cwd } =
|
|
61
|
+
const { storyId, cwd } = parseStoryCwdArgv(argv);
|
|
83
62
|
if (!storyId) {
|
|
84
63
|
throw new Error(
|
|
85
64
|
'story-handoff: --story <id> is required (a positive integer).',
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
* findings; 1 only on a usage error or a provider throw.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
18
|
+
import { parseStoryCwdArgv } from './lib/cli-args.js';
|
|
20
19
|
import { runAsCli } from './lib/cli-utils.js';
|
|
21
20
|
import { resolveConfig } from './lib/config-resolver.js';
|
|
22
21
|
import { getStoryBranch, gitSpawn } from './lib/git-utils.js';
|
|
@@ -44,25 +43,7 @@ const USAGE = {
|
|
|
44
43
|
],
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
* @param {string[]} argv
|
|
49
|
-
* @returns {{ storyId: number|null, cwd: string|null }}
|
|
50
|
-
*/
|
|
51
|
-
export function parseArgv(argv) {
|
|
52
|
-
const { values } = parseArgs({
|
|
53
|
-
args: argv,
|
|
54
|
-
options: {
|
|
55
|
-
story: { type: 'string' },
|
|
56
|
-
cwd: { type: 'string' },
|
|
57
|
-
},
|
|
58
|
-
strict: false,
|
|
59
|
-
});
|
|
60
|
-
const storyId = Number.parseInt(values.story ?? '', 10);
|
|
61
|
-
return {
|
|
62
|
-
storyId: Number.isInteger(storyId) && storyId > 0 ? storyId : null,
|
|
63
|
-
cwd: values.cwd ?? null,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
46
|
+
export { parseStoryCwdArgv as parseArgv };
|
|
66
47
|
|
|
67
48
|
/**
|
|
68
49
|
* @param {object} severity
|
|
@@ -160,7 +141,7 @@ export async function runStoryReviewComputeCli(
|
|
|
160
141
|
cwd: defaultCwd = process.cwd(),
|
|
161
142
|
...computeDeps
|
|
162
143
|
} = deps;
|
|
163
|
-
const { storyId, cwd } =
|
|
144
|
+
const { storyId, cwd } = parseStoryCwdArgv(argv);
|
|
164
145
|
if (!storyId) {
|
|
165
146
|
throw new Error(
|
|
166
147
|
'story-review-compute: --story <id> is required (a positive integer).',
|
|
@@ -17,6 +17,7 @@ import { applyHeader } from './lib/command-header.js';
|
|
|
17
17
|
import { applyAgentModel, getAgentModels } from './lib/config/agent-models.js';
|
|
18
18
|
import { resolveConfig } from './lib/config-resolver.js';
|
|
19
19
|
import { Logger } from './lib/Logger.js';
|
|
20
|
+
import { dirExists } from './lib/util/paths.js';
|
|
20
21
|
|
|
21
22
|
// cwd, never `__dirname/../..`, which lands inside node_modules when installed.
|
|
22
23
|
const PROJECT_ROOT = process.cwd();
|
|
@@ -37,18 +38,6 @@ export const HEADER =
|
|
|
37
38
|
export const LOCAL_HEADER =
|
|
38
39
|
'<!-- AUTO-GENERATED from .agents/local/ — do not edit. Source of truth: .agents/local/agents/ -->\n<!-- Re-run: npm run sync:agents -->\n\n';
|
|
39
40
|
|
|
40
|
-
/**
|
|
41
|
-
* @param {string} dir
|
|
42
|
-
* @returns {boolean}
|
|
43
|
-
*/
|
|
44
|
-
function dirExists(dir) {
|
|
45
|
-
try {
|
|
46
|
-
return fs.statSync(dir).isDirectory();
|
|
47
|
-
} catch {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
41
|
fs.mkdirSync(DEST_DIR, { recursive: true });
|
|
53
42
|
|
|
54
43
|
const isTopLevelAgent = (entry) => entry.isFile() && entry.name.endsWith('.md');
|
|
@@ -16,6 +16,7 @@ import path from 'node:path';
|
|
|
16
16
|
import { syncCodexSkills } from './lib/codex/skills-projection.js';
|
|
17
17
|
import { applyHeader, isCommandExcluded } from './lib/command-header.js';
|
|
18
18
|
import { Logger } from './lib/Logger.js';
|
|
19
|
+
import { dirExists } from './lib/util/paths.js';
|
|
19
20
|
|
|
20
21
|
// The root is cwd, never `__dirname/../..`: installed under node_modules that
|
|
21
22
|
// climb lands on the package dir and would write commands inside it.
|
|
@@ -37,18 +38,6 @@ export const HEADER =
|
|
|
37
38
|
export const LOCAL_HEADER =
|
|
38
39
|
'<!-- AUTO-GENERATED from .agents/local/ — do not edit. Source of truth: .agents/local/workflows/ -->\n<!-- Re-run: npm run sync:commands -->\n\n';
|
|
39
40
|
|
|
40
|
-
/**
|
|
41
|
-
* @param {string} dir
|
|
42
|
-
* @returns {boolean}
|
|
43
|
-
*/
|
|
44
|
-
function dirExists(dir) {
|
|
45
|
-
try {
|
|
46
|
-
return fs.statSync(dir).isDirectory();
|
|
47
|
-
} catch {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
41
|
/**
|
|
53
42
|
* Remove any on-disk plugin projection and marketplace listing, which would
|
|
54
43
|
* shadow the flat commands. Idempotent; skipped for fixture runs.
|