forgedock 1.53.0 → 1.54.1
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/.claude-plugin/marketplace.json +51 -0
- package/README.md +8 -2
- package/bin/auth/app-manifest.mjs +89 -0
- package/bin/auth/app-manifest.test.mjs +75 -0
- package/bin/auth/app-token.mjs +258 -0
- package/bin/auth/app-token.test.mjs +240 -0
- package/bin/brand.mjs +7 -0
- package/bin/config-history.mjs +151 -0
- package/bin/config-schema.mjs +115 -0
- package/bin/demo.mjs +65 -11
- package/bin/engine/outcome-codes.mjs +6 -3
- package/bin/engine/telemetry-seam.mjs +8 -2
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +57 -20
- package/bin/first-run.mjs +122 -0
- package/bin/forgedock.mjs +128 -146
- package/bin/help-text.mjs +144 -0
- package/bin/hooks/pre-tool-use.mjs +7 -0
- package/bin/journey.mjs +82 -83
- package/bin/lean/acceptance.mjs +313 -0
- package/bin/lean/acceptance.test.mjs +215 -0
- package/bin/lean/activation.mjs +18 -0
- package/bin/lean/activation.test.mjs +23 -1
- package/bin/lean/batch-health.mjs +74 -1
- package/bin/lean/batch-health.test.mjs +54 -1
- package/bin/lean/batch.test.mjs +11 -9
- package/bin/lean/branchlock.mjs +54 -0
- package/bin/lean/branchlock.test.mjs +49 -0
- package/bin/lean/ceiling.mjs +72 -0
- package/bin/lean/ceiling.test.mjs +54 -0
- package/bin/lean/ci-budget.mjs +366 -0
- package/bin/lean/ci-budget.test.mjs +167 -0
- package/bin/lean/conformance.e2e.test.mjs +7 -0
- package/bin/lean/conformance.mjs +77 -19
- package/bin/lean/conformance.test.mjs +129 -3
- package/bin/lean/context.mjs +35 -6
- package/bin/lean/context.test.mjs +27 -1
- package/bin/lean/depcache.mjs +25 -1
- package/bin/lean/depcache.test.mjs +26 -0
- package/bin/lean/e2e.mjs +18 -2
- package/bin/lean/e2e.test.mjs +26 -1
- package/bin/lean/effects.mjs +40 -11
- package/bin/lean/execution.test.mjs +24 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/fixround.mjs +14 -0
- package/bin/lean/fixround.test.mjs +25 -2
- package/bin/lean/gh-assoc.test.mjs +2 -1
- package/bin/lean/integration.mjs +100 -9
- package/bin/lean/integration.test.mjs +98 -0
- package/bin/lean/issuewatch-parity.mjs +64 -0
- package/bin/lean/issuewatch-parity.test.mjs +127 -0
- package/bin/lean/issuewatch-release.test.mjs +1 -1
- package/bin/lean/issuewatch.mjs +34 -5
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lean.mjs +316 -74
- package/bin/lean/lean.test.mjs +397 -24
- package/bin/lean/mechfix.mjs +136 -0
- package/bin/lean/mechfix.test.mjs +95 -0
- package/bin/lean/orchestrate.mjs +20 -2
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/precheck.mjs +23 -4
- package/bin/lean/precheck.test.mjs +14 -1
- package/bin/lean/prereq.mjs +28 -0
- package/bin/lean/prereq.test.mjs +20 -0
- package/bin/lean/probe.mjs +4 -2
- package/bin/lean/prodparity.mjs +52 -0
- package/bin/lean/prodparity.test.mjs +67 -0
- package/bin/lean/prompts.mjs +69 -12
- package/bin/lean/recovery.test.mjs +1 -1
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +6 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +8 -7
- package/bin/lean/release-review.mjs +67 -11
- package/bin/lean/release-review.test.mjs +128 -1
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +87 -13
- package/bin/lean/release.test.mjs +104 -0
- package/bin/lean/render.mjs +1 -1
- package/bin/lean/replan.mjs +184 -0
- package/bin/lean/replan.test.mjs +110 -0
- package/bin/lean/resume.mjs +9 -7
- package/bin/lean/resume.test.mjs +16 -0
- package/bin/lean/schedd.mjs +34 -1
- package/bin/lean/schedd.test.mjs +21 -1
- package/bin/lean/selfreview.mjs +94 -0
- package/bin/lean/selfreview.test.mjs +58 -1
- package/bin/lean/selftest-gate.mjs +22 -0
- package/bin/lean/selftest-gate.test.mjs +18 -1
- package/bin/lean/selftest-journey.mjs +234 -0
- package/bin/lean/selftest-journey.test.mjs +130 -0
- package/bin/lean/selftest-live.mjs +2 -1
- package/bin/lean/seqlease.mjs +35 -1
- package/bin/lean/seqlease.test.mjs +15 -0
- package/bin/lean/seqreserve.e2e.test.mjs +135 -0
- package/bin/lean/seqreserve.mjs +73 -0
- package/bin/lean/seqreserve.test.mjs +134 -0
- package/bin/lean/sequence.mjs +35 -6
- package/bin/lean/seqversioned.mjs +147 -0
- package/bin/lean/stagestamp.mjs +28 -0
- package/bin/lean/stagestamp.test.mjs +32 -0
- package/bin/lean/surfaces.mjs +75 -0
- package/bin/lean/surfaces.test.mjs +59 -0
- package/bin/lean/toolplace.mjs +28 -0
- package/bin/lean/toolplace.test.mjs +24 -0
- package/bin/lean/toolstats.mjs +3 -1
- package/bin/lean/toolstats.test.mjs +11 -0
- package/bin/lean/validatebest.mjs +28 -0
- package/bin/lean/validatebest.test.mjs +27 -0
- package/bin/pool/agent.mjs +9 -0
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +8 -4
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +100 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +49 -7
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +100 -19
- package/bin/stats/conformance-outcomes.test.mjs +87 -1
- package/bin/stats/depth.mjs +88 -31
- package/bin/stats/depth.test.mjs +63 -38
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/first-review.mjs +77 -0
- package/bin/stats/first-review.test.mjs +36 -0
- package/bin/stats/firstmerge.mjs +40 -0
- package/bin/stats/firstmerge.test.mjs +41 -0
- package/bin/stats/github-source.mjs +51 -13
- package/bin/stats/index.mjs +91 -15
- package/bin/stats/local-source.mjs +1 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/render.mjs +3 -1
- package/bin/stats/scoreboard.mjs +137 -0
- package/bin/stats/scoreboard.test.mjs +87 -0
- package/bin/stats/stats.test.mjs +80 -0
- package/bin/tui.mjs +3 -2
- package/commands/bootstrap.md +15 -14
- package/commands/deploy-pr.md +18 -3
- package/commands/forge-stats.md +1 -1
- package/commands/forgedock-ci-setup.md +28 -0
- package/commands/forgedock-init.md +4 -5
- package/commands/issue.md +2 -0
- package/commands/milestone.md +9 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-staging.md +4 -1
- package/commands/work-on/close.md +8 -0
- package/docs/CI.md +1 -1
- package/docs/CONFIG.md +105 -10
- package/docs/ISSUE-WATCH.md +23 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +19 -2
- package/docs/eval/README.md +6 -0
- package/docs/eval/adversarial-bench.md +68 -0
- package/docs/eval/corpus/adversarial-v1.json +285 -0
- package/docs/eval/feature-bench.md +42 -0
- package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
- package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
- package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
- package/docs/site/start-a-new-project.md +2 -1
- package/package.json +5 -2
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
- package/plugins/forgedock-splash/README.md +27 -0
- package/plugins/forgedock-splash/hooks/hooks.json +1 -0
- package/plugins/forgedock-splash/hooks/register.tsx +74 -0
- package/plugins/forgedock-splash/hooks/scene.ts +222 -0
- package/plugins/forgedock-splash/types/index.d.ts +10 -0
- package/scripts/bench-adversarial.mjs +216 -0
- package/scripts/bench-feature.mjs +170 -0
- package/scripts/bench-lightlane.mjs +2 -2
- package/scripts/bootstrap-create.mjs +2 -2
- package/scripts/bootstrap-validate.mjs +35 -2
- package/scripts/check-spec-size.sh +4 -3
- package/scripts/check-spec-size.test.sh +3 -0
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-staging-scope.test.sh +1 -1
- package/scripts/review-staging-post.sh +23 -0
- package/scripts/review-staging-post.test.sh +8 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { checkStamp, stampText, stampRule } from "./stagestamp.mjs";
|
|
4
|
+
|
|
5
|
+
describe("stage stamps (#5333)", () => {
|
|
6
|
+
it("stampText carries the issue and the contract hash, `-` before the freeze", () => {
|
|
7
|
+
assert.equal(stampText({ issue: 7, hash: "abc123def456" }), "forge-stamp: issue=7 contract=abc123def456");
|
|
8
|
+
assert.equal(stampText({ issue: 7 }), "forge-stamp: issue=7 contract=-");
|
|
9
|
+
});
|
|
10
|
+
it("a matching stamp passes and is stripped", () => {
|
|
11
|
+
const c = checkStamp("forge-stamp: issue=7 contract=abc123\n### Approach\nx", { issue: 7, hash: "abc123" });
|
|
12
|
+
assert.deepEqual(c, { ok: true, md: "### Approach\nx" });
|
|
13
|
+
});
|
|
14
|
+
it("another issue's stamp is refused (the stash-pop case)", () => {
|
|
15
|
+
const c = checkStamp("forge-stamp: issue=37641 contract=ffff\ncurl_cffi", { issue: 40194, hash: "abc123" });
|
|
16
|
+
assert.equal(c.ok, false);
|
|
17
|
+
assert.match(c.reason, /issue #37641, run is #40194/);
|
|
18
|
+
});
|
|
19
|
+
it("same issue, other contract hash is refused; an unknown run hash or `-` is not checked", () => {
|
|
20
|
+
assert.equal(checkStamp("forge-stamp: issue=7 contract=aaa\nx", { issue: 7, hash: "bbb" }).ok, false);
|
|
21
|
+
assert.equal(checkStamp("forge-stamp: issue=7 contract=aaa\nx", { issue: 7, hash: null }).ok, true);
|
|
22
|
+
assert.equal(checkStamp("forge-stamp: issue=7 contract=-\nx", { issue: 7, hash: "bbb" }).ok, true);
|
|
23
|
+
});
|
|
24
|
+
it("an unstamped note is accepted unchanged", () => {
|
|
25
|
+
assert.deepEqual(checkStamp("### Approach\nx", { issue: 7 }), { ok: true, md: "### Approach\nx" });
|
|
26
|
+
assert.equal(checkStamp(null, { issue: 7 }).md, "");
|
|
27
|
+
});
|
|
28
|
+
it("stampRule names the stamp, empty without one", () => {
|
|
29
|
+
assert.match(stampRule("forge-stamp: issue=7 contract=-"), /first line[\s\S]*forge-stamp: issue=7/);
|
|
30
|
+
assert.equal(stampRule(null), "");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* Shared surfaces (#5340): files every lane of a feature may touch (registries, route tables, migration dirs, versioned
|
|
5
|
+
* dirs, OpenAPI, i18n catalogs). forge.yaml `engine.shared_surfaces` lists them as globs, one per entry
|
|
6
|
+
* (comma-separated scalar or block list); `glob => command` marks an append-only registry the repo regenerates, which
|
|
7
|
+
* lanes must not hand-edit and which is never reserved. A lane whose frozen contract touches a declared surface takes a
|
|
8
|
+
* host reservation (one slot per repo + surface, across the milestone lane and the default branch) until its merge and
|
|
9
|
+
* records what it will add, so sibling packs show it. Pure parsing here; the lease and declaration records are in seqlease.mjs.
|
|
10
|
+
* Fail-open: no declared surface, or a failed lease, changes nothing.
|
|
11
|
+
*/
|
|
12
|
+
export const SURFACE_LANE = "*"; // the lease key spans every lane branch: the milestone lane and the default branch share a surface
|
|
13
|
+
|
|
14
|
+
const escapeRe = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
15
|
+
/** A repo-relative glob as a RegExp: `**` any depth, `*` within a segment, `?` one char; a trailing `/` means the whole dir. */
|
|
16
|
+
export function surfaceGlobRegExp(glob) {
|
|
17
|
+
let g = String(glob).trim().replace(/^\.?\/+/, "");
|
|
18
|
+
if (g.endsWith("/")) g += "**";
|
|
19
|
+
let re = "";
|
|
20
|
+
for (let i = 0; i < g.length; i++) {
|
|
21
|
+
const c = g[i];
|
|
22
|
+
if (c === "*" && g[i + 1] === "*") { re += ".*"; i++; if (g[i + 1] === "/") i++; }
|
|
23
|
+
else if (c === "*") re += "[^/]*";
|
|
24
|
+
else if (c === "?") re += "[^/]";
|
|
25
|
+
else re += escapeRe(c);
|
|
26
|
+
}
|
|
27
|
+
return new RegExp(`^${re}$`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** engine.shared_surfaces (string or array) -> [{name, generate|null, test(path)}]; blanks and duplicates dropped. */
|
|
31
|
+
export function parseSharedSurfaces(raw) {
|
|
32
|
+
const items = Array.isArray(raw) ? raw : typeof raw === "string" ? raw.split(",") : [];
|
|
33
|
+
const seen = new Set(), out = [];
|
|
34
|
+
for (const it of items) {
|
|
35
|
+
const [glob, ...rest] = String(it ?? "").split("=>");
|
|
36
|
+
const name = glob.trim().replace(/^\.?\/+/, "");
|
|
37
|
+
if (!name || seen.has(name)) continue;
|
|
38
|
+
seen.add(name);
|
|
39
|
+
const generate = rest.join("=>").trim() || null;
|
|
40
|
+
const re = surfaceGlobRegExp(name);
|
|
41
|
+
out.push({ name, generate, test: (p) => re.test(String(p).replace(/^\.?\/+/, "")) });
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The surfaces `paths` touch: `reserved` (take a slot) and `generated` (declared generator, hand-edits discouraged). */
|
|
47
|
+
export function matchSurfaces(surfaces, paths) {
|
|
48
|
+
const reserved = [], generated = [];
|
|
49
|
+
for (const s of surfaces ?? []) {
|
|
50
|
+
const files = (paths ?? []).filter((p) => s.test(p));
|
|
51
|
+
if (!files.length) continue;
|
|
52
|
+
(s.generate ? generated : reserved).push({ name: s.name, files, generate: s.generate });
|
|
53
|
+
}
|
|
54
|
+
return { reserved, generated };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Builder note for the surfaces of an append-only registry: run the generator, never hand-edit the list. */
|
|
58
|
+
export function generatorNote(generated) {
|
|
59
|
+
if (!generated?.length) return "";
|
|
60
|
+
return `\n\nGenerated shared surfaces (forge.yaml engine.shared_surfaces): do not hand-edit ${generated.map((g) => g.name).join(", ")}; regenerate with ${generated.map((g) => `\`${g.generate}\``).join(", ")}.`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Take the reserved slot of every surface the contract's deliverables touch and declare them for sibling packs.
|
|
65
|
+
* `lease` is makeSequenceLeaseIo(). @returns {Promise<{names:string[], generated:object[], waitMs:number, timedOut:boolean, release:Function}|null>}
|
|
66
|
+
* null when nothing is declared or touched.
|
|
67
|
+
*/
|
|
68
|
+
export async function claimSurfaces({ lease, repo, issue, surfaces, paths, maxWaitS = 1800 }) {
|
|
69
|
+
const { reserved, generated } = matchSurfaces(surfaces, paths);
|
|
70
|
+
if (!reserved.length) return generated.length ? { names: [], generated, waitMs: 0, timedOut: false, release() {} } : null;
|
|
71
|
+
try { await lease.declare?.({ repo, issue, surfaces: reserved.map((r) => r.name), paths: reserved.flatMap((r) => r.files) }); } catch { /* fail-open */ }
|
|
72
|
+
let g = null;
|
|
73
|
+
try { g = await lease.acquire({ repo, lane: SURFACE_LANE, dirs: reserved.map((r) => `surface:${r.name}`), issue, maxWaitS }); } catch { g = null; }
|
|
74
|
+
return { names: reserved.map((r) => r.name), generated, waitMs: g?.waitMs ?? 0, timedOut: g?.timedOut ?? false, release: () => { try { g?.release(); } catch { /* fail-open */ } } };
|
|
75
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// Shared surfaces (#5340): parse, match, reserved slots, generator exemption.
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { tmpDir } from "../tests/_tmp.mjs";
|
|
7
|
+
import { makeSequenceLeaseIo } from "./seqlease.mjs";
|
|
8
|
+
import { parseSharedSurfaces, matchSurfaces, generatorNote, claimSurfaces, surfaceGlobRegExp } from "./surfaces.mjs";
|
|
9
|
+
|
|
10
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
11
|
+
const mk = () => makeSequenceLeaseIo({ dir: tmpDir("surf-"), pickDir: tmpDir("surfpick-"), declDir: tmpDir("surfdecl-"), pollMs: 20 });
|
|
12
|
+
const SURF = parseSharedSurfaces("db/migrations/**, api/routes.ts, src/registry.ts => npm run gen:registry, , api/routes.ts");
|
|
13
|
+
|
|
14
|
+
describe("parse and match (#5340)", () => {
|
|
15
|
+
it("parses a comma scalar and a list; drops blanks and duplicates; no declaration yields none", () => {
|
|
16
|
+
assert.deepEqual(SURF.map((s) => [s.name, s.generate]), [["db/migrations/**", null], ["api/routes.ts", null], ["src/registry.ts", "npm run gen:registry"]]);
|
|
17
|
+
assert.equal(parseSharedSurfaces(["a/", "b/**"]).length, 2);
|
|
18
|
+
assert.deepEqual(parseSharedSurfaces(undefined), []);
|
|
19
|
+
});
|
|
20
|
+
it("globs: ** any depth, * one segment, trailing slash is the dir", () => {
|
|
21
|
+
assert.ok(surfaceGlobRegExp("db/**").test("db/a/b.sql"));
|
|
22
|
+
assert.ok(surfaceGlobRegExp("db/*.sql").test("db/a.sql"));
|
|
23
|
+
assert.ok(!surfaceGlobRegExp("db/*.sql").test("db/x/a.sql"));
|
|
24
|
+
assert.ok(surfaceGlobRegExp("i18n/").test("i18n/en/x.json"));
|
|
25
|
+
});
|
|
26
|
+
it("a generated registry is exempt from reservation and gets a builder note", () => {
|
|
27
|
+
const m = matchSurfaces(SURF, ["db/migrations/0001.sql", "src/registry.ts", "README.md"]);
|
|
28
|
+
assert.deepEqual(m.reserved.map((r) => r.name), ["db/migrations/**"]);
|
|
29
|
+
assert.deepEqual(m.generated.map((g) => g.name), ["src/registry.ts"]);
|
|
30
|
+
assert.match(generatorNote(m.generated), /do not hand-edit src\/registry\.ts; regenerate with `npm run gen:registry`/);
|
|
31
|
+
assert.equal(generatorNote([]), "");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("reserved slot (#5340)", () => {
|
|
36
|
+
it("two lanes on one surface cannot both be admitted: the second waits for the first's release", async () => {
|
|
37
|
+
const lease = mk(), order = [];
|
|
38
|
+
const a = await claimSurfaces({ lease, repo: "o/r", issue: 1, surfaces: SURF, paths: ["api/routes.ts"], maxWaitS: 30 });
|
|
39
|
+
const b = claimSurfaces({ lease, repo: "o/r", issue: 2, surfaces: SURF, paths: ["api/routes.ts"], maxWaitS: 30 }).then((g) => { order.push("b"); return g; });
|
|
40
|
+
await sleep(150);
|
|
41
|
+
assert.deepEqual(order, [], "b is still waiting");
|
|
42
|
+
assert.deepEqual((await lease.declared({ repo: "o/r", except: 2 })).map((d) => d.issue), [1], "in-flight declaration is readable");
|
|
43
|
+
order.push("a-release"); a.release();
|
|
44
|
+
const gb = await b;
|
|
45
|
+
assert.deepEqual(order, ["a-release", "b"]);
|
|
46
|
+
gb.release();
|
|
47
|
+
});
|
|
48
|
+
it("different surfaces do not block; nothing declared or touched claims nothing; undeclare drops the record", async () => {
|
|
49
|
+
const lease = mk();
|
|
50
|
+
const a = await claimSurfaces({ lease, repo: "o/r", issue: 1, surfaces: SURF, paths: ["api/routes.ts"], maxWaitS: 30 });
|
|
51
|
+
const b = await claimSurfaces({ lease, repo: "o/r", issue: 2, surfaces: SURF, paths: ["db/migrations/1.sql"], maxWaitS: 30 });
|
|
52
|
+
assert.equal(b.timedOut, false);
|
|
53
|
+
assert.equal(await claimSurfaces({ lease, repo: "o/r", issue: 3, surfaces: [], paths: ["api/routes.ts"] }), null);
|
|
54
|
+
assert.equal(await claimSurfaces({ lease, repo: "o/r", issue: 3, surfaces: SURF, paths: ["x.md"] }), null);
|
|
55
|
+
a.release(); b.release();
|
|
56
|
+
await lease.undeclare({ repo: "o/r", issue: 1 });
|
|
57
|
+
assert.deepEqual((await lease.declared({ repo: "o/r" })).map((d) => d.issue), [2]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* #5331: a remote target that cannot run a frozen validate command is found before the builder implements, not at the
|
|
5
|
+
* validate step. Pure, never throws. `toolMisses` filters the validate preflight's misses (run where the lane runs) to the
|
|
6
|
+
* tools a different placement could supply; `lackedTools` names the contract's tools a target is known to lack.
|
|
7
|
+
*/
|
|
8
|
+
import { preflightProbes } from "./preflight.mjs";
|
|
9
|
+
|
|
10
|
+
const TOOL_KINDS = new Set(["command", "python-module", "node-module"]);
|
|
11
|
+
|
|
12
|
+
/** `{tools, ids}` from preflight misses: executables and modules, never an unset env var (no placement fixes that). */
|
|
13
|
+
export function toolMisses(misses) {
|
|
14
|
+
const tools = new Set(), ids = new Set();
|
|
15
|
+
for (const m of Array.isArray(misses) ? misses : []) {
|
|
16
|
+
if (!m || !TOOL_KINDS.has(m.kind) || !m.tool) continue;
|
|
17
|
+
tools.add(String(m.tool));
|
|
18
|
+
for (const id of Array.isArray(m.ids) ? m.ids : []) ids.add(String(id));
|
|
19
|
+
}
|
|
20
|
+
return { tools: [...tools].sort(), ids: [...ids].sort() };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** `{tools, ids}`: tools the contract's validate/repro commands name that are in `lacks` (names a target is known to miss). */
|
|
24
|
+
export function lackedTools(contract, lacks) {
|
|
25
|
+
const lack = new Set((Array.isArray(lacks) ? lacks : lacks ? [...lacks] : []).map(String));
|
|
26
|
+
if (!lack.size || !contract || typeof contract !== "object") return { tools: [], ids: [] };
|
|
27
|
+
try { return toolMisses(preflightProbes(contract, { cap: 1000 }).probes.filter((p) => lack.has(p.tool))); } catch { return { tools: [], ids: [] }; }
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { toolMisses, lackedTools } from "./toolplace.mjs";
|
|
6
|
+
|
|
7
|
+
const C = { validate: [{ id: "V3", command: "promtool check rules alerts.yml" }, { id: "V1", command: "node --test a.test.mjs" }] };
|
|
8
|
+
|
|
9
|
+
describe("remote tool placement (#5331)", () => {
|
|
10
|
+
it("a missing command on the remote target is reported with its validate ids", () => {
|
|
11
|
+
const r = toolMisses([{ ids: ["V3"], tool: "promtool", kind: "command" }, { ids: ["V1"], tool: "FOO", kind: "env-var" }]);
|
|
12
|
+
assert.deepEqual(r, { tools: ["promtool"], ids: ["V3"] });
|
|
13
|
+
});
|
|
14
|
+
it("nothing missing stays remote", () => {
|
|
15
|
+
assert.deepEqual(toolMisses([]), { tools: [], ids: [] });
|
|
16
|
+
assert.deepEqual(toolMisses(undefined), { tools: [], ids: [] });
|
|
17
|
+
});
|
|
18
|
+
it("a frozen contract naming a tool the remote is known to lack is flagged; others are not", () => {
|
|
19
|
+
assert.deepEqual(lackedTools(C, ["promtool"]), { tools: ["promtool"], ids: ["V3"] });
|
|
20
|
+
assert.deepEqual(lackedTools(C, new Set(["docker"])), { tools: [], ids: [] });
|
|
21
|
+
assert.deepEqual(lackedTools(C, []), { tools: [], ids: [] });
|
|
22
|
+
assert.deepEqual(lackedTools(null, ["promtool"]), { tools: [], ids: [] });
|
|
23
|
+
});
|
|
24
|
+
});
|
package/bin/lean/toolstats.mjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* one tool use; a read is the Read tool's path or a file operand of `cat`, `sed -n`, `head` or `tail` in a Bash command
|
|
7
7
|
* (grep is a search, not a re-read); a re-read path is one read 3 or more times. Pure module: no I/O.
|
|
8
8
|
*/
|
|
9
|
+
import { firstEditTurn } from "./ceiling.mjs";
|
|
9
10
|
|
|
10
11
|
export const REREAD_MIN = 3;
|
|
11
12
|
const MAX_SEGMENTS = 50;
|
|
@@ -67,6 +68,7 @@ export function toolStats(toolUses) {
|
|
|
67
68
|
}
|
|
68
69
|
if (!calls) return null;
|
|
69
70
|
const hot = [...reads].filter(([, k]) => k >= REREAD_MIN).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
71
|
+
const firstEdit = firstEditTurn(toolUses); // #5346: turns-to-first-edit, the cost of a restart's re-orientation
|
|
70
72
|
return { calls, turns: msgs.size, per_turn: Math.round((calls / msgs.size) * 100) / 100, rereads: hot.length,
|
|
71
|
-
top: hot.slice(0, 5).map(([path, n]) => ({ path, reads: n })) };
|
|
73
|
+
top: hot.slice(0, 5).map(([path, n]) => ({ path, reads: n })), ...(firstEdit != null ? { first_edit_turn: firstEdit } : {}) };
|
|
72
74
|
}
|
|
@@ -45,3 +45,14 @@ describe("#4410 toolStats", () => {
|
|
|
45
45
|
assert.deepEqual(s, { calls: 3, turns: 3, per_turn: 1, rereads: 0, top: [] });
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
describe("#5347 parallel tool calls in one turn", () => {
|
|
50
|
+
it("tool_use blocks sharing one message id are one turn; a build opening with three reads in one turn averages above 2", () => {
|
|
51
|
+
const opening = [bash("sed -n 1,40p a.js", "m1"), bash("sed -n 1,40p b.js", "m1"), { msg: "m1", name: "Grep", path: null, cmd: null }];
|
|
52
|
+
const s = toolStats([...opening, bash("npm test", "m2")]);
|
|
53
|
+
assert.equal(s.turns, 2);
|
|
54
|
+
assert.equal(s.calls, 4);
|
|
55
|
+
assert.equal(s.per_turn, 2);
|
|
56
|
+
assert.equal(toolStats(opening).per_turn, 3);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* #5331: the best known result per validate id. A resumed lane used to see only the newest record, so a remote "exit 127"
|
|
5
|
+
* (the sandbox lacks the tool) hid an earlier local pass and the recovery lane re-verified from scratch. Pure, never throws.
|
|
6
|
+
*/
|
|
7
|
+
const MISSING_EXITS = new Set([126, 127]); // command not executable / not found: the environment, not the change
|
|
8
|
+
|
|
9
|
+
export const isToolMissingExit = (exit) => MISSING_EXITS.has(Number(exit));
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Rows oldest to newest: `{id?, command, exit, where?, head?}`. Returns one row per id (command when no id): a later row
|
|
13
|
+
* replaces an earlier one, except a tool-missing row never replaces a pass.
|
|
14
|
+
*/
|
|
15
|
+
export function bestResults(rows) {
|
|
16
|
+
const best = new Map();
|
|
17
|
+
for (const r of Array.isArray(rows) ? rows : []) {
|
|
18
|
+
if (!r || typeof r.command !== "string" || !Number.isInteger(r.exit)) continue;
|
|
19
|
+
const key = r.id || r.command;
|
|
20
|
+
const old = best.get(key);
|
|
21
|
+
if (old && old.exit === 0 && isToolMissingExit(r.exit)) continue;
|
|
22
|
+
best.set(key, { id: r.id ?? null, command: r.command, exit: r.exit, where: r.where ?? null, head: r.head ?? null });
|
|
23
|
+
}
|
|
24
|
+
return [...best.values()];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** True when the row passed on `head`; both heads must be known (a row with no recorded head is never "the same head"). */
|
|
28
|
+
export const passedOnHead = (row, head) => row?.exit === 0 && !!row.head && !!head && row.head === head;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { bestResults, passedOnHead, isToolMissingExit } from "./validatebest.mjs";
|
|
6
|
+
|
|
7
|
+
describe("best validate result per id (#5331)", () => {
|
|
8
|
+
it("a remote exit 127 after a local exit 0 does not replace the pass", () => {
|
|
9
|
+
const r = bestResults([{ id: "V3", command: "promtool x", exit: 0, where: "local" }, { id: "V3", command: "promtool x", exit: 127, where: "remote" }]);
|
|
10
|
+
assert.deepEqual(r, [{ id: "V3", command: "promtool x", exit: 0, where: "local", head: null }]);
|
|
11
|
+
});
|
|
12
|
+
it("a real failure after a pass replaces it; a later pass replaces a failure or a 127", () => {
|
|
13
|
+
assert.equal(bestResults([{ command: "a", exit: 0 }, { command: "a", exit: 1 }])[0].exit, 1);
|
|
14
|
+
assert.equal(bestResults([{ command: "a", exit: 127 }, { command: "a", exit: 0 }])[0].exit, 0);
|
|
15
|
+
});
|
|
16
|
+
it("ignores malformed rows and keys by id before command", () => {
|
|
17
|
+
assert.equal(bestResults([null, { command: "a" }, { id: "V1", command: "a", exit: 0 }, { id: "V2", command: "a", exit: 1 }]).length, 2);
|
|
18
|
+
assert.deepEqual(bestResults(undefined), []);
|
|
19
|
+
});
|
|
20
|
+
it("passedOnHead compares heads only when both are known", () => {
|
|
21
|
+
assert.equal(passedOnHead({ exit: 0, head: "abc" }, "abc"), true);
|
|
22
|
+
assert.equal(passedOnHead({ exit: 0, head: "abc" }, "def"), false);
|
|
23
|
+
assert.equal(passedOnHead({ exit: 0 }, "def"), false);
|
|
24
|
+
assert.equal(passedOnHead({ exit: 127 }, "def"), false);
|
|
25
|
+
assert.equal(isToolMissingExit(127), true);
|
|
26
|
+
});
|
|
27
|
+
});
|
package/bin/pool/agent.mjs
CHANGED
|
@@ -397,6 +397,15 @@ export function createAgent(cfg, { docker, now = () => Date.now(), log = console
|
|
|
397
397
|
[route("GET", "/sandboxes/:id/result"), async ({ id }) => { const r = own(id); const x = r && readResult(r); return x ? { status: 200, body: x } : { status: 404, body: { error: "no result" } }; }],
|
|
398
398
|
[route("GET", "/sandboxes/:id/usage"), async ({ id }) => { const r = own(id); return r ? { status: 200, body: { minutes: Math.round((((r.finishedAt ?? now()) - r.startedAt) / 60000) * 10) / 10 } } : { status: 404, body: {} }; }],
|
|
399
399
|
[route("POST", "/sandboxes/:id/lease"), async ({ id }) => { const r = own(id); if (!r) return { status: 404, body: { state: "gone" } }; r.lease = now(); store.save(); return { status: 200, body: { ok: true } }; }],
|
|
400
|
+
// #5274: SIGTERM the lane (PID 1) so its teardown checkpoints and reports deferred run.interrupted; the sandbox is kept, never destroyed.
|
|
401
|
+
[route("POST", "/sandboxes/:id/stop"), async ({ id }) => {
|
|
402
|
+
const r = own(id);
|
|
403
|
+
if (!r) return { status: 404, body: { state: "gone" } };
|
|
404
|
+
await refresh(r);
|
|
405
|
+
if (r.state === "exited") return { status: 200, body: { ok: true, state: "exited" } };
|
|
406
|
+
await docker.kill(r.name, "TERM");
|
|
407
|
+
return { status: 202, body: { ok: true, state: "stopping" } };
|
|
408
|
+
}],
|
|
400
409
|
[route("GET", "/usage-history"), async () => {
|
|
401
410
|
let rows = [];
|
|
402
411
|
try { rows = readFileSync(join(stateDir, "usage-history.jsonl"), "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)); } catch { /* none yet */ }
|
package/bin/pool/docker.mjs
CHANGED
|
@@ -24,6 +24,11 @@ export const dockerCli = {
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
async remove(name) { try { await docker(["rm", "-f", "-v", name], { timeoutMs: 60000 }); } catch (e) { if (!/No such container/i.test(e.stderr ?? "")) throw e; } },
|
|
27
|
+
/** Signal the container's main process (the lane). False when the container is gone or already stopped. */
|
|
28
|
+
async kill(name, signal = "TERM") {
|
|
29
|
+
try { await docker(["kill", `--signal=${signal}`, name], { timeoutMs: 20000 }); return true; }
|
|
30
|
+
catch (e) { if (/No such container|is not running/i.test(e.stderr ?? "")) return false; throw e; }
|
|
31
|
+
},
|
|
27
32
|
async listLabelled(label) {
|
|
28
33
|
const out = await docker(["ps", "-a", "--filter", `label=${label}`, "--format", "{{.Names}}"], { timeoutMs: 20000 });
|
|
29
34
|
return out ? out.split("\n").filter(Boolean) : [];
|
package/bin/pool/router.mjs
CHANGED
|
@@ -13,6 +13,9 @@ import { versionOf } from "./version.mjs";
|
|
|
13
13
|
|
|
14
14
|
const run = promisify(execFile);
|
|
15
15
|
|
|
16
|
+
/** #5274: an agent destroy (docker rm, volume rm, wipe) outlasts the 15s call default; DELETE would 502 while the destroy still succeeded. */
|
|
17
|
+
const DESTROY_TIMEOUT_MS = 180000;
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Router: the endpoint ForgeDock's remote provider talks to (POST /sandboxes, GET /sandboxes/:id[/logs|/result|/usage],
|
|
18
21
|
* DELETE /sandboxes/:id). It places each sandbox on the enrolled agent with the most free reserved CPU, forwards every
|
|
@@ -211,13 +214,13 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
|
|
|
211
214
|
return { status: 404, body: { error: "no warm sandbox ready" } };
|
|
212
215
|
}
|
|
213
216
|
|
|
214
|
-
async function forward(id, method, path) {
|
|
217
|
+
async function forward(id, method, path, timeoutMs) {
|
|
215
218
|
const s = own(sbx(), id);
|
|
216
219
|
const a = s && own(agents(), s.agent);
|
|
217
220
|
if (!a) return { status: 404, body: { state: "gone" } };
|
|
218
221
|
s.touched = now(); store.save();
|
|
219
222
|
try {
|
|
220
|
-
const r = await agentCall(a, method, path);
|
|
223
|
+
const r = await agentCall(a, method, path, undefined, timeoutMs);
|
|
221
224
|
if (method === "DELETE" && (r.ok || r.status === 404)) { delete sbx()[id]; relayQ.delete(id); store.save(); }
|
|
222
225
|
return { status: r.status, body: agentBody(r, s.agent) };
|
|
223
226
|
} catch (e) { return { status: 502, body: { error: `agent ${s.agent} unreachable: ${e.message}` } }; }
|
|
@@ -231,7 +234,7 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
|
|
|
231
234
|
if (!a) { delete sbx()[id]; continue; }
|
|
232
235
|
try {
|
|
233
236
|
if (now() - s.touched > abandonMs) {
|
|
234
|
-
const r = await agentCall(a, "DELETE", `/sandboxes/${encodeURIComponent(id)}
|
|
237
|
+
const r = await agentCall(a, "DELETE", `/sandboxes/${encodeURIComponent(id)}`, undefined, DESTROY_TIMEOUT_MS);
|
|
235
238
|
if (r.ok || r.status === 404) { delete sbx()[id]; relayQ.delete(id); log.info?.(`abandoned ${id} destroyed on ${s.agent}`); }
|
|
236
239
|
} else {
|
|
237
240
|
const r = await agentCall(a, "POST", `/sandboxes/${encodeURIComponent(id)}/lease`);
|
|
@@ -308,7 +311,8 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
|
|
|
308
311
|
})],
|
|
309
312
|
[route("GET", "/sandboxes/:id/relay"), fd(async ({ id }) => ({ status: 200, body: { requests: [...(relayQ.get(id) ?? new Map())].filter(([, r]) => !r.done).map(([rid, r]) => ({ rid, argv: r.argv })) } }))],
|
|
310
313
|
[route("POST", "/sandboxes/:id/relay/:rid"), fd(async (p, body) => relayAnswer(p, body))],
|
|
311
|
-
[route("
|
|
314
|
+
[route("POST", "/sandboxes/:id/stop"), fd(async ({ id }) => forward(id, "POST", `/sandboxes/${encodeURIComponent(id)}/stop`))], // #5274
|
|
315
|
+
[route("DELETE", "/sandboxes/:id"), fd(async ({ id }) => forward(id, "DELETE", `/sandboxes/${encodeURIComponent(id)}`, DESTROY_TIMEOUT_MS))],
|
|
312
316
|
[route("GET", "/status"), fd(async () => ({ status: 200, body: await status() }))],
|
|
313
317
|
[route("GET", "/agents"), fd(async () => ({ status: 200, body: { agents: await capacities(), sandboxes: sbx() } }))],
|
|
314
318
|
[route("POST", "/codes"), fd(async () => ({ status: 200, body: issueCode() }))],
|
package/bin/prereqs.mjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prerequisite list for setup (journey preflight) and `doctor` (#5302).
|
|
3
|
+
* One definition, so both report the same tools with the same fix commands.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import { spawnSync } from "child_process";
|
|
7
|
+
|
|
8
|
+
/** Ids of the prerequisites, in report order. */
|
|
9
|
+
export const PREREQ_IDS = ["node", "git", "claude-code", "gh", "yq"];
|
|
10
|
+
|
|
11
|
+
const GH_URL = "Install gh: https://cli.github.com/";
|
|
12
|
+
|
|
13
|
+
function installFor(id, platform) {
|
|
14
|
+
const mac = platform === "darwin";
|
|
15
|
+
const win = platform === "win32";
|
|
16
|
+
if (id === "gh") {
|
|
17
|
+
if (mac) return { fix: [GH_URL, "brew install gh"], auto: ["brew", "install", "gh"] };
|
|
18
|
+
if (win) return { fix: [GH_URL, "winget install --id GitHub.cli -e"], auto: ["winget", "install", "--id", "GitHub.cli", "-e"] };
|
|
19
|
+
return { fix: [GH_URL] };
|
|
20
|
+
}
|
|
21
|
+
if (id === "yq") {
|
|
22
|
+
if (mac) return { fix: ["brew install yq"], auto: ["brew", "install", "yq"] };
|
|
23
|
+
if (win) return { fix: ["winget install --id MikeFarah.yq -e"], auto: ["winget", "install", "--id", "MikeFarah.yq", "-e"] };
|
|
24
|
+
return { fix: ["Install yq (mikefarah, not the python one): https://github.com/mikefarah/yq#install"] };
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Probe every prerequisite.
|
|
31
|
+
* @param {{ exec: (cmd: string, args: string[]) => string, nodeVersion: string, claudeDir: string, platform?: string }} o
|
|
32
|
+
* @returns {Array<{ id: string, label: string, ok: boolean, blocking: boolean, detail: string, fix?: string[], auto?: string[] }>}
|
|
33
|
+
* `blocking` is true for a missing tool; an installed-but-unauthenticated gh fails but does not block setup.
|
|
34
|
+
*/
|
|
35
|
+
export function checkPrereqs({ exec, nodeVersion, claudeDir, platform = process.platform }) {
|
|
36
|
+
const out = [];
|
|
37
|
+
const add = (id, label, ok, detail, extra = {}) => {
|
|
38
|
+
const inst = ok ? null : installFor(id, platform);
|
|
39
|
+
out.push({
|
|
40
|
+
id, label, ok, blocking: !ok && extra.blocking !== false, detail,
|
|
41
|
+
...(ok ? {} : { fix: extra.fix ?? inst?.fix ?? [] }),
|
|
42
|
+
...(!ok && inst?.auto && extra.blocking !== false ? { auto: inst.auto } : {}),
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const major = Number(String(nodeVersion).split(".")[0]);
|
|
46
|
+
if (major >= 18) add("node", "Node", true, `v${nodeVersion}`);
|
|
47
|
+
else add("node", "Node", false, `v${nodeVersion} — need ≥18`, { fix: ["Upgrade Node: https://nodejs.org/"] });
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
add("git", "git", true, exec("git", ["--version"]).replace(/^git version\s*/, ""));
|
|
51
|
+
} catch {
|
|
52
|
+
add("git", "git", false, "not found", { fix: ["Install git: https://git-scm.com/downloads"] });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (existsSync(claudeDir)) add("claude-code", "Claude Code", true, `${claudeDir} found`);
|
|
56
|
+
else add("claude-code", "Claude Code", false, `${claudeDir} not found`, { fix: ["Install Claude Code: https://claude.com/claude-code"] });
|
|
57
|
+
|
|
58
|
+
let ghInstalled = true;
|
|
59
|
+
try {
|
|
60
|
+
exec("gh", ["--version"]);
|
|
61
|
+
} catch {
|
|
62
|
+
ghInstalled = false;
|
|
63
|
+
add("gh", "GitHub CLI", false, "not found");
|
|
64
|
+
}
|
|
65
|
+
if (ghInstalled) {
|
|
66
|
+
try {
|
|
67
|
+
exec("gh", ["auth", "status"]);
|
|
68
|
+
add("gh", "GitHub CLI", true, "authenticated");
|
|
69
|
+
} catch {
|
|
70
|
+
add("gh", "GitHub CLI", false, "not authenticated", { fix: ["Run: gh auth login"], blocking: false });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
add("yq", "yq", true, exec("yq", ["--version"]));
|
|
76
|
+
} catch {
|
|
77
|
+
add("yq", "yq", false, "not found");
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The "Not ready yet" summary for the blocking prerequisites that are missing. */
|
|
83
|
+
export function formatNotReady(missing) {
|
|
84
|
+
const n = missing.length;
|
|
85
|
+
const lines = ["", ` Not ready yet: ${n} thing${n === 1 ? "" : "s"} to install`, ""];
|
|
86
|
+
missing.forEach((m, i) => {
|
|
87
|
+
lines.push(` ${i + 1}. ${m.label} — ${m.detail}`);
|
|
88
|
+
for (const f of m.fix ?? []) lines.push(` ${f}`);
|
|
89
|
+
});
|
|
90
|
+
lines.push("", " Re-run `npx forgedock` when done.", "");
|
|
91
|
+
return lines.join("\n");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Offer to install the installable ones among `items`, asking consent for each.
|
|
96
|
+
* @returns {Promise<string[]>} ids that were installed successfully
|
|
97
|
+
*/
|
|
98
|
+
export async function offerInstall(items, { confirmFn, run = defaultRun, write = () => {} }) {
|
|
99
|
+
const done = [];
|
|
100
|
+
for (const m of items) {
|
|
101
|
+
if (!m.auto) continue;
|
|
102
|
+
if (!(await confirmFn(`Install ${m.label} now? (${m.auto.join(" ")})`, false))) continue;
|
|
103
|
+
if (run(m.auto) === 0) done.push(m.id);
|
|
104
|
+
else write(` Could not install ${m.label}; run it yourself: ${m.auto.join(" ")}\n`);
|
|
105
|
+
}
|
|
106
|
+
return done;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function defaultRun(argv) {
|
|
110
|
+
return spawnSync(argv[0], argv.slice(1), { stdio: "inherit" }).status ?? 1;
|
|
111
|
+
}
|