@intentius/chant 0.124.61 → 0.124.63
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/dist/cli/handlers/approve.d.ts +18 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +142 -16
- package/dist/cli/handlers/plan.d.ts +10 -0
- package/dist/cli/handlers/plan.d.ts.map +1 -0
- package/dist/cli/handlers/plan.js +71 -0
- package/dist/cli/handlers/release.d.ts +6 -4
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +13 -7
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +34 -5
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.js +2 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -0
- package/dist/cli/registry.d.ts +13 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/gate-decision.d.ts +1 -1
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +4 -2
- package/dist/gate-statement.schema.json +44 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
- package/dist/lifecycle/gate-ledger.d.ts +17 -3
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.d.ts +39 -3
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +50 -10
- package/dist/lifecycle/gate-statement.d.ts +70 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +74 -0
- package/dist/lifecycle/gate-webauthn.d.ts +79 -0
- package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
- package/dist/lifecycle/gate-webauthn.js +105 -0
- package/dist/lifecycle/git.d.ts +1 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +24 -19
- package/dist/lifecycle/ledger-remote.d.ts +37 -0
- package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
- package/dist/lifecycle/ledger-remote.js +42 -0
- package/dist/lifecycle/plan-stale.d.ts +76 -0
- package/dist/lifecycle/plan-stale.d.ts.map +1 -0
- package/dist/lifecycle/plan-stale.js +121 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
- package/dist/lifecycle/publish-credentials.js +2 -0
- package/dist/lifecycle/publish-declaration.d.ts +87 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +87 -1
- package/dist/lifecycle/publish-forge.d.ts +5 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +14 -4
- package/dist/lifecycle/publish-github.d.ts +69 -0
- package/dist/lifecycle/publish-github.d.ts.map +1 -0
- package/dist/lifecycle/publish-github.js +153 -0
- package/dist/lifecycle/publish-homebrew.d.ts +66 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +173 -0
- package/dist/lifecycle/publish-marketplace.d.ts +51 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +254 -0
- package/dist/lifecycle/publish-targets.d.ts +6 -0
- package/dist/lifecycle/publish-targets.d.ts.map +1 -1
- package/dist/lifecycle/publish-targets.js +15 -0
- package/dist/lifecycle/publish-tauri.d.ts +61 -0
- package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
- package/dist/lifecycle/publish-tauri.js +182 -0
- package/dist/lifecycle/release-publish.d.ts +5 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.js +17 -9
- package/dist/lifecycle/test-passkey.d.ts +25 -0
- package/dist/lifecycle/test-passkey.d.ts.map +1 -0
- package/dist/lifecycle/test-passkey.js +39 -0
- package/dist/notify.d.ts +23 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -2
- package/dist/notify.schema.json +12 -3
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +61 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +331 -330
- package/dist/workspace/ci-builds.d.ts +21 -0
- package/dist/workspace/ci-builds.d.ts.map +1 -1
- package/dist/workspace/ci-builds.js +14 -0
- package/dist/workspace/ci-green-workflow.d.ts +2 -0
- package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
- package/dist/workspace/ci-green-workflow.js +9 -0
- package/dist/workspace/ci-green.d.ts +45 -2
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +127 -9
- package/dist/workspace/ci-quarantine-report.d.ts +80 -0
- package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine-report.js +205 -0
- package/dist/workspace/ci-quarantine.d.ts +73 -0
- package/dist/workspace/ci-quarantine.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine.js +171 -0
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +7 -4
- package/dist/workspace/class-data.d.ts +3 -1
- package/dist/workspace/class-data.d.ts.map +1 -1
- package/dist/workspace/class-data.js +4 -1
- package/dist/workspace/declaration.d.ts +45 -2
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +45 -2
- package/dist/workspace/declaration.schema.json +51 -3
- package/dist/workspace/forge-work.d.ts +76 -0
- package/dist/workspace/forge-work.d.ts.map +1 -0
- package/dist/workspace/forge-work.js +160 -0
- package/dist/workspace/identity-gate-rule.d.ts +3 -2
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +5 -7
- package/dist/workspace/identity.d.ts +3 -2
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/identity.js +6 -3
- package/dist/workspace/intent-cli.d.ts +3 -2
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-cli.js +26 -5
- package/dist/workspace/intent-record.d.ts +3 -0
- package/dist/workspace/intent-record.d.ts.map +1 -1
- package/dist/workspace/intent-record.schema.json +32 -0
- package/dist/workspace/intent.d.ts +9 -0
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +3 -0
- package/dist/workspace/intent.schema.json +32 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +2 -1
- package/dist/workspace/kinds.d.ts +6 -1
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +8 -3
- package/dist/workspace/plan-stale.schema.json +286 -0
- package/dist/workspace/release-candidates.d.ts +33 -6
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +49 -20
- package/dist/workspace/release-candidates.schema.json +48 -2
- package/dist/workspace/trust/policy.d.ts +10 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +19 -1
- package/dist/workspace/trust/run-commits.d.ts.map +1 -1
- package/dist/workspace/trust/run-commits.js +2 -1
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +34 -3
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +6 -1
- package/package.json +2 -1
- package/src/cli/handlers/approve-external-signature.test.ts +226 -0
- package/src/cli/handlers/approve.ts +174 -16
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/release.ts +12 -7
- package/src/cli/main.ts +34 -5
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +24 -0
- package/src/cli/registry.ts +13 -1
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +44 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +17 -3
- package/src/lifecycle/gate-seal.ts +62 -9
- package/src/lifecycle/gate-statement.ts +107 -0
- package/src/lifecycle/gate-webauthn.test.ts +77 -0
- package/src/lifecycle/gate-webauthn.ts +133 -0
- package/src/lifecycle/git.ts +23 -19
- package/src/lifecycle/ledger-remote.test.ts +183 -0
- package/src/lifecycle/ledger-remote.ts +46 -0
- package/src/lifecycle/plan-stale.test.ts +150 -0
- package/src/lifecycle/plan-stale.ts +173 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +93 -1
- package/src/lifecycle/publish-forge.ts +15 -4
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +179 -0
- package/src/lifecycle/publish-homebrew.ts +187 -0
- package/src/lifecycle/publish-marketplace.test.ts +254 -0
- package/src/lifecycle/publish-marketplace.ts +259 -0
- package/src/lifecycle/publish-target-context.test.ts +2 -2
- package/src/lifecycle/publish-targets.test.ts +23 -0
- package/src/lifecycle/publish-targets.ts +15 -0
- package/src/lifecycle/publish-tauri.test.ts +163 -0
- package/src/lifecycle/publish-tauri.ts +199 -0
- package/src/lifecycle/release-publish.ts +5 -3
- package/src/lifecycle/snapshot-store.ts +16 -9
- package/src/lifecycle/test-passkey.ts +55 -0
- package/src/notify-bundle.test.ts +3 -1
- package/src/notify.schema.json +12 -3
- package/src/notify.ts +20 -3
- package/src/override-gate-bundle.test.ts +2 -0
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +38 -0
- package/src/pr-forge.ts +68 -5
- package/src/release-floors.ts +1 -1
- package/src/stage-hooks-bundle.test.ts +2 -0
- package/src/wave-runtime-bundle.test.ts +3 -2
- package/src/workspace/ci-builds.ts +27 -0
- package/src/workspace/ci-green-stale.test.ts +193 -0
- package/src/workspace/ci-green-workflow.test.ts +9 -0
- package/src/workspace/ci-green-workflow.ts +9 -0
- package/src/workspace/ci-green.ts +141 -10
- package/src/workspace/ci-quarantine-report.test.ts +146 -0
- package/src/workspace/ci-quarantine-report.ts +235 -0
- package/src/workspace/ci-quarantine.test.ts +161 -0
- package/src/workspace/ci-quarantine.ts +189 -0
- package/src/workspace/ci-serve.ts +7 -4
- package/src/workspace/class-data.ts +5 -1
- package/src/workspace/declaration.schema.json +51 -3
- package/src/workspace/declaration.test.ts +1 -0
- package/src/workspace/declaration.ts +88 -5
- package/src/workspace/forge-work.test.ts +143 -0
- package/src/workspace/forge-work.ts +195 -0
- package/src/workspace/identity-gate-rule.ts +6 -8
- package/src/workspace/identity.ts +6 -3
- package/src/workspace/intent-cli.ts +24 -5
- package/src/workspace/intent-record.schema.json +32 -0
- package/src/workspace/intent-record.ts +3 -0
- package/src/workspace/intent.schema.json +32 -0
- package/src/workspace/intent.ts +10 -0
- package/src/workspace/kind-readers.ts +2 -1
- package/src/workspace/kinds.test.ts +13 -0
- package/src/workspace/kinds.ts +12 -3
- package/src/workspace/plan-stale.schema.json +286 -0
- package/src/workspace/release-candidates.schema.json +48 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +62 -20
- package/src/workspace/trust/policy.ts +24 -1
- package/src/workspace/trust/run-commits.ts +2 -1
- package/src/workspace/trust/seal.ts +35 -3
- package/src/workspace/trust/trust-files.test.ts +5 -0
- package/src/workspace/trust/trust-files.ts +15 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work items from the forge (#4649): the issues a squash-merged pull request
|
|
3
|
+
* closes.
|
|
4
|
+
*
|
|
5
|
+
* A project that squash-merges pull requests and tracks its work in forge
|
|
6
|
+
* issues writes no `Chant-Record` trailer. Its commit subjects end in
|
|
7
|
+
* `(#<n>)`, the pull request, and the pull request closes issues. Asked to
|
|
8
|
+
* (`--forge-issues`), `release candidates` and `workspace graph --intent` ask
|
|
9
|
+
* the forge which issues each pull request closes, through the forge clients
|
|
10
|
+
* of `../pr-forge.ts` ({@link PrForge.closingIssues}): one call per pull
|
|
11
|
+
* request, each answer kept for the rest of the read.
|
|
12
|
+
*
|
|
13
|
+
* The forge is the CI job's when the read runs in one ({@link detectForge}),
|
|
14
|
+
* else the one `origin` points at: github.com and hosts named for GitHub,
|
|
15
|
+
* hosts named for GitLab, and codeberg.org and hosts named for Forgejo or
|
|
16
|
+
* Gitea. The token is read in {@link FORGE_TOKEN_ORDER}, with
|
|
17
|
+
* `CHANT_FORGE_TOKEN` first, and on GitHub `gh auth token` for the host last.
|
|
18
|
+
*
|
|
19
|
+
* Nothing here fails a read. Without a forge or a token, offline, or when the
|
|
20
|
+
* forge answers an error, a pull request is `resolved: false` with the
|
|
21
|
+
* reason, and its number still stands. After a network failure, a 401 or a
|
|
22
|
+
* 403, the rest are answered with the same reason without another call.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { execFileSync } from "node:child_process";
|
|
26
|
+
import { remoteRepoPath } from "../op/activities/forge-pull-request";
|
|
27
|
+
import { remoteHost } from "../op/activities/gh-host";
|
|
28
|
+
import { detectForge, FORGE_TOKEN_ORDER, ForgeApiError, forgeClient, forgeTargetFromEnv, type ForgeFetch, type ForgeKind, type ForgeTarget, type PrForge } from "../pr-forge";
|
|
29
|
+
|
|
30
|
+
/** What the forge says one pull request closes. */
|
|
31
|
+
export interface PullRequestCloses {
|
|
32
|
+
/** Whether the forge answered. When false, `issues` is empty and `reason` says why. */
|
|
33
|
+
resolved: boolean;
|
|
34
|
+
/** The issues of the repository the pull request closes, ascending. */
|
|
35
|
+
issues: number[];
|
|
36
|
+
/** Why the forge was not read, or null when it was. */
|
|
37
|
+
reason: string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The forge a {@link ForgeWorkReader} reads, as the read found it. */
|
|
41
|
+
export interface ForgeWorkSource {
|
|
42
|
+
kind: ForgeKind;
|
|
43
|
+
host: string;
|
|
44
|
+
/** `owner/name`, or the GitLab project path. */
|
|
45
|
+
repo: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ForgeWorkReader {
|
|
49
|
+
/** The forge read, or null when none could be worked out. */
|
|
50
|
+
source: ForgeWorkSource | null;
|
|
51
|
+
/** What pull request `pr` closes. Asked twice, the forge is called once. */
|
|
52
|
+
closes(pr: number): Promise<PullRequestCloses>;
|
|
53
|
+
/** {@link closes} for each of `prs`, a few at a time. */
|
|
54
|
+
closesAll(prs: Iterable<number>): Promise<Map<number, PullRequestCloses>>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ForgeWorkOptions {
|
|
58
|
+
/** Default `process.env`. */
|
|
59
|
+
env?: Record<string, string | undefined>;
|
|
60
|
+
fetch?: ForgeFetch;
|
|
61
|
+
/** `origin`'s URL. Default `git remote get-url origin` in `top`; null for none. */
|
|
62
|
+
remoteUrl?: string | null;
|
|
63
|
+
/** The token `gh` holds for a GitHub host, or undefined. Default `gh auth token --hostname <host>`. */
|
|
64
|
+
ghToken?: (host: string) => string | undefined;
|
|
65
|
+
/** How long one call may take. Default 15 seconds. */
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** How many pull requests are asked about at once. */
|
|
70
|
+
const CONCURRENCY = 4;
|
|
71
|
+
|
|
72
|
+
function gitRemote(top: string): string | null {
|
|
73
|
+
try {
|
|
74
|
+
return execFileSync("git", ["remote", "get-url", "origin"], { cwd: top, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim() || null;
|
|
75
|
+
} catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ghAuthToken(host: string): string | undefined {
|
|
81
|
+
try {
|
|
82
|
+
return execFileSync("gh", ["auth", "token", "--hostname", host], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 5_000 }).trim() || undefined;
|
|
83
|
+
} catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The forge kind a remote host is: github.com and hosts named for GitHub, GitLab, or Forgejo and Gitea (codeberg.org too). Null for any other. */
|
|
89
|
+
export function forgeKindOfHost(host: string): ForgeKind | null {
|
|
90
|
+
const h = host.toLowerCase().replace(/:\d+$/, "");
|
|
91
|
+
if (h === "github.com" || /(^|[.-])github([.-]|$)/.test(h)) return "github";
|
|
92
|
+
if (h === "gitlab.com" || /(^|[.-])gitlab([.-]|$)/.test(h)) return "gitlab";
|
|
93
|
+
if (h === "codeberg.org" || /(^|[.-])(forgejo|gitea)([.-]|$)/.test(h)) return "forgejo";
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The REST base of a forge at `host`, as the clients take it. */
|
|
98
|
+
export function forgeApiBase(kind: ForgeKind, host: string): string {
|
|
99
|
+
if (kind === "github") return host === "github.com" ? "https://api.github.com" : `https://${host}/api/v3`;
|
|
100
|
+
return kind === "gitlab" ? `https://${host}/api/v4` : `https://${host}/api/v1`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Where the issues are read from, or why they can't be. */
|
|
104
|
+
function locate(top: string, opts: ForgeWorkOptions): { target: ForgeTarget } | { source: ForgeWorkSource | null; reason: string } {
|
|
105
|
+
const env = opts.env ?? process.env;
|
|
106
|
+
const job = detectForge(env);
|
|
107
|
+
if (job) {
|
|
108
|
+
try {
|
|
109
|
+
return { target: forgeTargetFromEnv(env, { kind: job }) };
|
|
110
|
+
} catch (err) {
|
|
111
|
+
return { source: null, reason: err instanceof Error ? err.message : String(err) };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const url = opts.remoteUrl !== undefined ? opts.remoteUrl : gitRemote(top);
|
|
115
|
+
if (!url) return { source: null, reason: "there is no origin remote to name the forge" };
|
|
116
|
+
const host = remoteHost(url);
|
|
117
|
+
const repo = remoteRepoPath(url);
|
|
118
|
+
const kind = host ? forgeKindOfHost(host) : null;
|
|
119
|
+
if (!host || !repo || !kind) return { source: null, reason: `origin (${url}) is not on a forge chant reads issues from: GitHub, GitLab or Forgejo` };
|
|
120
|
+
const source = { kind, host, repo };
|
|
121
|
+
const names = ["CHANT_FORGE_TOKEN", ...FORGE_TOKEN_ORDER[kind]];
|
|
122
|
+
const tokenSource = names.find((n) => env[n]?.trim());
|
|
123
|
+
const token = tokenSource ? env[tokenSource]!.trim() : kind === "github" ? (opts.ghToken ?? ghAuthToken)(host) : undefined;
|
|
124
|
+
if (!token) return { source, reason: `no token for ${host}: set ${names.join(", ")}${kind === "github" ? ", or log in with gh auth login" : ""}` };
|
|
125
|
+
return { target: { kind, apiBase: forgeApiBase(kind, host), repo, host, token, tokenSource: tokenSource ?? "gh auth token" } };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Why a failed call stops the rest: the forge can't be reached, or won't let this token read. */
|
|
129
|
+
function stopsTheRest(err: unknown): boolean {
|
|
130
|
+
return !(err instanceof ForgeApiError) || err.status === 401 || err.status === 403;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A reader of what pull requests close, for the repository at `top`. */
|
|
134
|
+
export function forgeWorkReader(top: string, opts: ForgeWorkOptions = {}): ForgeWorkReader {
|
|
135
|
+
const where = locate(top, opts);
|
|
136
|
+
const cache = new Map<number, Promise<PullRequestCloses>>();
|
|
137
|
+
let stopped: string | null = "reason" in where ? where.reason : null;
|
|
138
|
+
const client: PrForge | null = "target" in where ? forgeClient(where.target, opts.fetch) : null;
|
|
139
|
+
const source: ForgeWorkSource | null = "target" in where ? { kind: where.target.kind, host: where.target.host, repo: where.target.repo } : where.source;
|
|
140
|
+
const timeoutMs = opts.timeoutMs ?? 15_000;
|
|
141
|
+
const unresolved = (reason: string): PullRequestCloses => ({ resolved: false, issues: [], reason });
|
|
142
|
+
|
|
143
|
+
const ask = async (pr: number): Promise<PullRequestCloses> => {
|
|
144
|
+
if (stopped !== null) return unresolved(stopped);
|
|
145
|
+
if (!client?.closingIssues) return unresolved(`the ${source?.kind ?? "forge"} client can't list the issues a pull request closes`);
|
|
146
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
147
|
+
try {
|
|
148
|
+
const timeout = new Promise<never>((_, reject) => {
|
|
149
|
+
timer = setTimeout(() => reject(new Error(`no answer in ${timeoutMs / 1000}s`)), timeoutMs);
|
|
150
|
+
});
|
|
151
|
+
const issues = await Promise.race([client.closingIssues(pr), timeout]);
|
|
152
|
+
return { resolved: true, issues, reason: null };
|
|
153
|
+
} catch (err) {
|
|
154
|
+
const message = `${source?.host ?? "the forge"} could not be read: ${err instanceof Error ? err.message : String(err)}`;
|
|
155
|
+
if (stopsTheRest(err)) stopped = message;
|
|
156
|
+
return unresolved(message);
|
|
157
|
+
} finally {
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const closes = (pr: number): Promise<PullRequestCloses> => {
|
|
163
|
+
let hit = cache.get(pr);
|
|
164
|
+
if (!hit) {
|
|
165
|
+
hit = ask(pr);
|
|
166
|
+
cache.set(pr, hit);
|
|
167
|
+
}
|
|
168
|
+
return hit;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
source,
|
|
173
|
+
closes,
|
|
174
|
+
async closesAll(prs) {
|
|
175
|
+
const queue = [...new Set(prs)];
|
|
176
|
+
const out = new Map<number, PullRequestCloses>();
|
|
177
|
+
const worker = async (): Promise<void> => {
|
|
178
|
+
for (let pr = queue.shift(); pr !== undefined; pr = queue.shift()) out.set(pr, await closes(pr));
|
|
179
|
+
};
|
|
180
|
+
await Promise.all(Array.from({ length: Math.min(CONCURRENCY, queue.length) }, worker));
|
|
181
|
+
return out;
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Set `closes` on each commit from what its `pullRequest` closes, asking the
|
|
188
|
+
* forge once per pull request; null for a commit with none. For
|
|
189
|
+
* `workspace graph --intent --forge-issues`, over the graph's commit nodes or
|
|
190
|
+
* a record walk's commits.
|
|
191
|
+
*/
|
|
192
|
+
export async function setCommitCloses(commits: { pullRequest: number | null; closes?: PullRequestCloses | null }[], reader: ForgeWorkReader): Promise<void> {
|
|
193
|
+
const closed = await reader.closesAll(commits.map((c) => c.pullRequest).filter((n): n is number => n !== null));
|
|
194
|
+
for (const c of commits) c.closes = c.pullRequest !== null ? (closed.get(c.pullRequest) ?? null) : null;
|
|
195
|
+
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* else: no zod, no ajv, no package loading, so it bundles small.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { checkGateSignature, gateSealPayload, namespaceAllowed, sshKeyFingerprint, sshSignatureKey, unlistedWhat, unlistedWhere, verifySshSignatureWith, type PasskeySigner, type SealedGateApproval } from "../lifecycle/gate-seal";
|
|
18
18
|
import type { Signer } from "./trust/trust-files";
|
|
19
19
|
|
|
20
20
|
/** The core classes, in the order a principal's roles are tried; `human` holds no role and is the rest. */
|
|
@@ -46,8 +46,8 @@ export interface GateAdmissionRule {
|
|
|
46
46
|
gate: string;
|
|
47
47
|
/** The class the approver must be in, or null for any signer. */
|
|
48
48
|
class: string | null;
|
|
49
|
-
/** The signers file at base: its path, whether it exists, and its signers. */
|
|
50
|
-
signers: { signersPath: string; active: boolean; signers: readonly Signer[] };
|
|
49
|
+
/** The signers file at base: its path, whether it exists, and its signers, with the passkeys `.chant/trust.json` lists (#4646). */
|
|
50
|
+
signers: { signersPath: string; active: boolean; signers: readonly Signer[]; passkeys?: readonly PasskeySigner[] };
|
|
51
51
|
/** The role grants at base (`.chant/trust.json` `roles`). */
|
|
52
52
|
roles: Readonly<Record<string, readonly string[]>>;
|
|
53
53
|
/** Every class the rule knows, core first, then domain classes in pin order. */
|
|
@@ -185,9 +185,7 @@ function sealRefusal(gate: string, signers: GateAdmissionRule["signers"], a: Sea
|
|
|
185
185
|
}
|
|
186
186
|
if (normalise(seal.signer) !== normalise(a.resolvedBy)) return `the seal on ${what} is by ${seal.signer}, and its approver is ${a.resolvedBy || "empty"}`;
|
|
187
187
|
const where = `${signers.signersPath} at base`;
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
const r = verifySshSignatureWith(seal.signature, gateSealPayload(a), GATE_SEAL_NAMESPACE, keys);
|
|
192
|
-
return r.ok ? null : `the seal does not verify for ${a.resolvedBy} against ${where}: ${r.reason}`;
|
|
188
|
+
const r = checkGateSignature(signers, a.resolvedBy, seal as { signature: string }, gateSealPayload(a));
|
|
189
|
+
if (r.ok) return null;
|
|
190
|
+
return r.unlisted ? `${a.resolvedBy} has no ${unlistedWhat(seal)} in ${unlistedWhere(seal, where)}, so the seal can't count` : `the seal does not verify for ${a.resolvedBy} against ${where}: ${r.reason}`;
|
|
193
191
|
}
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* it to chant's write commands (`--by`, `--actor`). chant records what it is
|
|
7
7
|
* given and says which form it is:
|
|
8
8
|
*
|
|
9
|
-
* - `signer`: a principal `.chant/allowed_signers` lists at base
|
|
10
|
-
*
|
|
9
|
+
* - `signer`: a principal `.chant/allowed_signers` lists at base, or one with
|
|
10
|
+
* a passkey in `.chant/trust.json` (#4646). A seal made with that
|
|
11
|
+
* principal's key (`--sign`) or passkey (`--signature`) attests it.
|
|
11
12
|
* - `forge`: a forge identity, `github:<login>`, `gitlab:<login>`, or
|
|
12
13
|
* `<forge>@<host>:<login>` (forgejo, gitea, or a self-hosted github or
|
|
13
14
|
* gitlab). The surface that signed the person in vouches for it; nothing
|
|
@@ -90,7 +91,9 @@ const NON_PERSON_CLASSES = new Set(["agent", "runner", "service"]);
|
|
|
90
91
|
export function identify(principal: string, policy: TrustPolicy, declaration: Declaration | null = null): Identified {
|
|
91
92
|
const name = normalisePrincipal(principal);
|
|
92
93
|
const forge = parseForgeIdentity(principal);
|
|
93
|
-
|
|
94
|
+
// #4646: a principal with a passkey at base signs like one with a key.
|
|
95
|
+
const listed = (s: { principal: string }) => normalisePrincipal(s.principal) === name;
|
|
96
|
+
if (policy.active && (policy.signers.some(listed) || (policy.passkeys ?? []).some(listed))) return { principal, form: "signer", forge };
|
|
94
97
|
if (forge) return { principal, form: "forge", forge };
|
|
95
98
|
const session = (declaration?.agents ?? []).some((a) => a.principals.some((p) => normalisePrincipal(p) === name));
|
|
96
99
|
if (session || classesOf(coreClassRegistry(), policy, principal).some((c) => NON_PERSON_CLASSES.has(c))) return { principal, form: "role", forge: null };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `chant workspace graph --intent <path[:start-end]|path#symbol|member/node|sha> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]`
|
|
2
|
+
* `chant workspace graph --intent <path[:start-end]|path#symbol|member/node|sha> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--forge-issues] [--json]`
|
|
3
3
|
* (#2651, #3034): the intent graph over one region (`intent.ts`), printed as JSON
|
|
4
4
|
* with `--json` or as a walk, one line per node, in the order of #2650
|
|
5
5
|
* section B: the region, its decisions, their artifacts, the commits, and the
|
|
@@ -9,18 +9,33 @@
|
|
|
9
9
|
* to the person about it (#2656). Without `--kind`, the walk reads every
|
|
10
10
|
* record kind the declaration names (#2680). Last comes the why chain (#4023):
|
|
11
11
|
* each commit's work item, ci tag and release, and each release's gates and
|
|
12
|
-
* deploys.
|
|
12
|
+
* deploys. With `--forge-issues` (#4649), each commit with a pull request
|
|
13
|
+
* also carries the issues the forge says it closes (`./forge-work.ts`).
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
import { resolve } from "node:path";
|
|
16
17
|
import { formatError } from "../cli/format";
|
|
17
18
|
import type { CommandContext } from "../cli/registry";
|
|
19
|
+
import type { PullRequestCloses } from "./forge-work";
|
|
18
20
|
import { intentRecord, type IntentRecordDocument } from "./intent-record";
|
|
19
21
|
import type { IntentTrace, TraceGate } from "./intent-trace";
|
|
20
22
|
import { intentGraph, type ArtifactNode, type CommitNode, type DecisionNode, type IntentDocument, type IntentEdge, type IntentNode, type RunNode, type WhyAnswer, type WorkNode } from "./intent";
|
|
21
23
|
|
|
22
|
-
const USAGE = "chant workspace graph --intent <path[:start-end]|path#symbol|member/node|sha> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]";
|
|
23
|
-
const RECORD_USAGE = "chant workspace graph --intent --record <id> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]";
|
|
24
|
+
const USAGE = "chant workspace graph --intent <path[:start-end]|path#symbol|member/node|sha> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--forge-issues] [--json]";
|
|
25
|
+
const RECORD_USAGE = "chant workspace graph --intent --record <id> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--forge-issues] [--json]";
|
|
26
|
+
|
|
27
|
+
/** With `--forge-issues` (#4649): set each commit's `closes` from the forge. */
|
|
28
|
+
async function withCloses(cwd: string, commits: { pullRequest: number | null; closes?: PullRequestCloses | null }[]): Promise<void> {
|
|
29
|
+
const { forgeWorkReader, setCommitCloses } = await import("./forge-work");
|
|
30
|
+
await setCommitCloses(commits, forgeWorkReader(cwd));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** ` closes #1, #2`, ` (issues not read: why)`, or nothing, after a pull request in the text. */
|
|
34
|
+
function closesText(closes: PullRequestCloses | null | undefined): string {
|
|
35
|
+
if (!closes) return "";
|
|
36
|
+
if (!closes.resolved) return ` (issues not read: ${closes.reason})`;
|
|
37
|
+
return closes.issues.length > 0 ? ` closes ${closes.issues.map((n) => `#${n}`).join(", ")}` : "";
|
|
38
|
+
}
|
|
24
39
|
|
|
25
40
|
type Result = Exclude<IntentDocument, { error: unknown }>;
|
|
26
41
|
type RecordResult = Exclude<IntentRecordDocument, { error: unknown }>;
|
|
@@ -113,6 +128,7 @@ function commitLine(doc: Result, c: CommitNode): string[] {
|
|
|
113
128
|
for (const s of edgesFrom(doc, e.to, "cites-evidence")) out.push(` evidence ${s.to.slice("evidence:".length)}`);
|
|
114
129
|
}
|
|
115
130
|
out.push(...joinLines(c.joins));
|
|
131
|
+
if (c.closes && c.pullRequest !== null) out.push(` pr #${c.pullRequest}${closesText(c.closes)}`);
|
|
116
132
|
if (c.squash) {
|
|
117
133
|
const s = c.squash;
|
|
118
134
|
out.push(` squash #${s.pullRequest}${s.followed ? `: ${s.commits.length} original ${s.commits.length === 1 ? "commit" : "commits"} from ${s.ref}${s.fetched ? ", fetched" : ""}` : ", not followed"}`);
|
|
@@ -254,7 +270,8 @@ export function formatIntentRecord(doc: RecordResult): string {
|
|
|
254
270
|
: "nothing else accounts for it";
|
|
255
271
|
const runs = (c.runs ?? []).map((r) => `run ${r.id}${r.model ? ` (${r.model})` : ""}${r.joinedBy?.includes("squash") && !r.joinedBy.some((j) => j !== "squash") ? " through the squash" : ""}`).join(", ");
|
|
256
272
|
const squash = c.squash ? `; squash of #${c.squash.pullRequest}${c.squash.followed ? `, ${c.squash.commits.length} original ${c.squash.commits.length === 1 ? "commit" : "commits"}` : ", not followed"}` : "";
|
|
257
|
-
|
|
273
|
+
const pr = c.closes && c.pullRequest !== null ? `; #${c.pullRequest}${closesText(c.closes)}` : "";
|
|
274
|
+
out.push(`${c.bucket.padEnd(12)} ${short(c.sha)} ${c.date.slice(0, 10)} ${c.subject}; ${why}${runs ? `; ${runs}` : ""}${squash}${pr}; ${c.files.join(", ") || c.entries.join(", ")}`);
|
|
258
275
|
}
|
|
259
276
|
for (const x of doc.reasons) out.push(`reason ${x.code}: ${x.message}`);
|
|
260
277
|
const n = doc.counts;
|
|
@@ -265,6 +282,7 @@ export function formatIntentRecord(doc: RecordResult): string {
|
|
|
265
282
|
async function runRecord(ctx: CommandContext, cwd: string, kinds: string[] | undefined): Promise<number> {
|
|
266
283
|
const { args } = ctx;
|
|
267
284
|
const { doc, failed } = await intentRecord({ cwd, record: args.record!, at: args.at, kinds: kinds?.map((k) => resolve(k)), followSquash: args.followSquash });
|
|
285
|
+
if (args.forgeIssues && !("error" in doc)) await withCloses(cwd, doc.commits);
|
|
268
286
|
if (args.json) console.log(JSON.stringify(doc, null, 2));
|
|
269
287
|
if ("error" in doc) {
|
|
270
288
|
console.error(formatError({ message: `${doc.error.code}: ${doc.error.message}`, hint: RECORD_USAGE }));
|
|
@@ -290,6 +308,7 @@ export async function runWorkspaceIntent(ctx: CommandContext, cwd: string): Prom
|
|
|
290
308
|
// No --kind: undefined, so the walk reads the kinds the declaration names (#2680).
|
|
291
309
|
const kinds = args.kinds ?? (args.kind !== undefined ? [args.kind] : undefined);
|
|
292
310
|
const { doc, failed } = await intentGraph({ cwd, region: args.intent, at: args.at, kinds: kinds?.map((k) => resolve(k)), followSquash: args.followSquash });
|
|
311
|
+
if (args.forgeIssues && !("error" in doc)) await withCloses(cwd, ofKind(doc, "commit"));
|
|
293
312
|
if (args.json) console.log(JSON.stringify(doc, null, 2));
|
|
294
313
|
if ("error" in doc) {
|
|
295
314
|
console.error(formatError({ message: `${doc.error.code}: ${doc.error.message}`, hint: USAGE }));
|
|
@@ -359,6 +359,38 @@
|
|
|
359
359
|
],
|
|
360
360
|
"description": "The number in a (#n) that ends the subject, as a squash merge writes it, or null."
|
|
361
361
|
},
|
|
362
|
+
"closes": {
|
|
363
|
+
"type": [
|
|
364
|
+
"object",
|
|
365
|
+
"null"
|
|
366
|
+
],
|
|
367
|
+
"required": [
|
|
368
|
+
"resolved",
|
|
369
|
+
"issues",
|
|
370
|
+
"reason"
|
|
371
|
+
],
|
|
372
|
+
"properties": {
|
|
373
|
+
"resolved": {
|
|
374
|
+
"type": "boolean",
|
|
375
|
+
"description": "Whether the forge answered. False without a forge chant reads, without a token, offline, or when the forge answered an error."
|
|
376
|
+
},
|
|
377
|
+
"issues": {
|
|
378
|
+
"type": "array",
|
|
379
|
+
"items": {
|
|
380
|
+
"type": "integer"
|
|
381
|
+
},
|
|
382
|
+
"description": "The issues of the repository the pull request closes, ascending. Empty when not resolved."
|
|
383
|
+
},
|
|
384
|
+
"reason": {
|
|
385
|
+
"type": [
|
|
386
|
+
"string",
|
|
387
|
+
"null"
|
|
388
|
+
],
|
|
389
|
+
"description": "Why the forge was not read, or null when it was."
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"description": "Only with --forge-issues (#4649): what the forge says pullRequest closes, or null for a commit with no pull request. Added within version 1 by chant 0.124.63."
|
|
393
|
+
},
|
|
362
394
|
"unit": {
|
|
363
395
|
"type": [
|
|
364
396
|
"string",
|
|
@@ -60,6 +60,7 @@ import type { RecordView } from "./records-cli";
|
|
|
60
60
|
import { addSquashRuns, runsForCommits, type RunRef } from "./runs";
|
|
61
61
|
import { followSquashes, type Forge, type SquashFollow } from "./squash";
|
|
62
62
|
import { readTrailerJoins, type CommitTrailerJoins } from "./trailer-joins";
|
|
63
|
+
import type { PullRequestCloses } from "./forge-work";
|
|
63
64
|
import { joinPath } from "./tree";
|
|
64
65
|
import { locateWorkspace } from "./which-chant";
|
|
65
66
|
import { idList } from "./work";
|
|
@@ -97,6 +98,8 @@ export interface RecordCommit {
|
|
|
97
98
|
date: string;
|
|
98
99
|
trailers: Record<string, string[]>;
|
|
99
100
|
pullRequest: number | null;
|
|
101
|
+
/** What the forge says `pullRequest` closes (#4649), only with `--forge-issues`: null for a commit with no pull request. */
|
|
102
|
+
closes?: PullRequestCloses | null;
|
|
100
103
|
/** The unit a plugin joined the commit to, or null. */
|
|
101
104
|
unit: string | null;
|
|
102
105
|
/** What chant's own trailers join the commit to (#3149), as a commit node in `graph --intent` reports it. */
|
|
@@ -484,6 +484,38 @@
|
|
|
484
484
|
],
|
|
485
485
|
"description": "The number in a (#n) that ends the subject, as a squash merge writes it, or null."
|
|
486
486
|
},
|
|
487
|
+
"closes": {
|
|
488
|
+
"type": [
|
|
489
|
+
"object",
|
|
490
|
+
"null"
|
|
491
|
+
],
|
|
492
|
+
"required": [
|
|
493
|
+
"resolved",
|
|
494
|
+
"issues",
|
|
495
|
+
"reason"
|
|
496
|
+
],
|
|
497
|
+
"properties": {
|
|
498
|
+
"resolved": {
|
|
499
|
+
"type": "boolean",
|
|
500
|
+
"description": "Whether the forge answered. False without a forge chant reads, without a token, offline, or when the forge answered an error."
|
|
501
|
+
},
|
|
502
|
+
"issues": {
|
|
503
|
+
"type": "array",
|
|
504
|
+
"items": {
|
|
505
|
+
"type": "integer"
|
|
506
|
+
},
|
|
507
|
+
"description": "The issues of the repository the pull request closes, ascending. Empty when not resolved."
|
|
508
|
+
},
|
|
509
|
+
"reason": {
|
|
510
|
+
"type": [
|
|
511
|
+
"string",
|
|
512
|
+
"null"
|
|
513
|
+
],
|
|
514
|
+
"description": "Why the forge was not read, or null when it was."
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
"description": "Only with --forge-issues (#4649): what the forge says pullRequest closes, or null for a commit with no pull request. Added within version 1 by chant 0.124.63."
|
|
518
|
+
},
|
|
487
519
|
"signature": {
|
|
488
520
|
"type": "object",
|
|
489
521
|
"required": [
|
package/src/workspace/intent.ts
CHANGED
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
import { execFileSync } from "node:child_process";
|
|
61
61
|
import { realpathSync } from "node:fs";
|
|
62
62
|
import { basename, dirname, relative, resolve, sep } from "node:path";
|
|
63
|
+
import { NEXT_RELEASE } from "../release-floors";
|
|
64
|
+
import type { PullRequestCloses } from "./forge-work";
|
|
63
65
|
import { declaredRecordKinds, readDeclaration, readerVersion, resolveGroups, WORKSPACE_ERROR_CODES, WorkspaceReadError, type Declaration } from "./declaration";
|
|
64
66
|
import { declaredKindFile } from "./declared-kinds";
|
|
65
67
|
import { isGeneratedPath } from "./generated-files";
|
|
@@ -88,6 +90,8 @@ import { idList, isDecided, WORK_WARNING_CODES, type WorkLink, type WorkWarningC
|
|
|
88
90
|
|
|
89
91
|
/** The version of the `intent` document this chant writes. */
|
|
90
92
|
export const INTENT_CONTRACT_VERSION = 1;
|
|
93
|
+
/** The first chant whose intent graph and record walk carry a commit's `closes`, with `--forge-issues` (#4649). */
|
|
94
|
+
export const INTENT_CLOSES_FLOOR = NEXT_RELEASE;
|
|
91
95
|
|
|
92
96
|
/** `$id` of the JSON Schema for the document, shipped beside this file. */
|
|
93
97
|
export const INTENT_OUTPUT_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/intent/v1/intent.schema.json";
|
|
@@ -245,6 +249,12 @@ export interface CommitNode {
|
|
|
245
249
|
trailers: Record<string, string[]>;
|
|
246
250
|
/** The pull request number the subject ends with, as a squash merge writes it, or null. */
|
|
247
251
|
pullRequest: number | null;
|
|
252
|
+
/**
|
|
253
|
+
* What the forge says `pullRequest` closes (#4649), only with
|
|
254
|
+
* `--forge-issues`: null for a commit with no pull request. Added within
|
|
255
|
+
* contract 1 by chant {@link INTENT_CLOSES_FLOOR}.
|
|
256
|
+
*/
|
|
257
|
+
closes?: PullRequestCloses | null;
|
|
248
258
|
signature: { level: ProvenanceLevel; reason: string; principal?: string };
|
|
249
259
|
/** The line ranges the commit changed in the region, in the commit's own version of the file; null for a file or directory region. */
|
|
250
260
|
lines: LineRange[] | null;
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
import { mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
36
36
|
import { tmpdir } from "node:os";
|
|
37
37
|
import { join } from "node:path";
|
|
38
|
+
import { CHANT_INSTALL } from "./class-data";
|
|
38
39
|
import { findInstalledPackage, lexiconPackageName, substituteGraphConfig } from "./kinds";
|
|
39
40
|
import type { MemberPlan, RunUnit, SkippedEntry } from "./member-commands";
|
|
40
41
|
|
|
@@ -65,7 +66,7 @@ function lexiconModules(unit: RunUnit, root: string): { modules: string } | { me
|
|
|
65
66
|
const reader = unit.reader!;
|
|
66
67
|
if (!reader.lexicon) return { message: `kind ${unit.kind} names no lexicon` };
|
|
67
68
|
const name = lexiconPackageName(reader.lexicon);
|
|
68
|
-
const installed = findInstalledPackage(name, root);
|
|
69
|
+
const installed = findInstalledPackage(name, root) ?? findInstalledPackage(name, CHANT_INSTALL);
|
|
69
70
|
if (!installed) {
|
|
70
71
|
return {
|
|
71
72
|
message: `kind ${unit.kind} is read by the ${reader.lexicon} lexicon, and ${name} is not installed in a node_modules at or above ${root}; install it there to read this member`,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
kindsFileShips,
|
|
15
15
|
loadKindRegistry,
|
|
16
16
|
parseKindData,
|
|
17
|
+
pinnedPackageDir,
|
|
17
18
|
probeKind,
|
|
18
19
|
readPackageKinds,
|
|
19
20
|
resolveKind,
|
|
@@ -259,6 +260,18 @@ describe("loadKindRegistry: kinds from the pins", () => {
|
|
|
259
260
|
expect(existsSync(join(root, "node_modules/plain/IMPORTED"))).toBe(false);
|
|
260
261
|
});
|
|
261
262
|
|
|
263
|
+
test("a pin the checkout does not hold is found beside chant's own install, at the pinned version", () => {
|
|
264
|
+
const checkout = dir({});
|
|
265
|
+
const install = dir(pkg("tf-kinds", "1.0.0", [tf]));
|
|
266
|
+
expect(pinnedPackageDir({ package: "tf-kinds", version: "1.0.0", path: null }, checkout, install)).toEqual({
|
|
267
|
+
dir: join(install, "node_modules/tf-kinds"),
|
|
268
|
+
source: "tf-kinds",
|
|
269
|
+
});
|
|
270
|
+
expect(pinnedPackageDir({ package: "tf-kinds", version: "2.0.0", path: null }, checkout, install)).toEqual({
|
|
271
|
+
problem: expect.stringContaining("tf-kinds is pinned at 2.0.0"),
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
|
|
262
275
|
test("reads a local plugin by path, and leaves out a kind two sources both supply", () => {
|
|
263
276
|
const root = dir({
|
|
264
277
|
"plugins/tf/package.json": JSON.stringify({ name: "tf", exports: { "./workspace-kinds": "./k.json" } }),
|
package/src/workspace/kinds.ts
CHANGED
|
@@ -23,7 +23,7 @@ import schema from "./workspace-kinds.schema.json" with { type: "json" };
|
|
|
23
23
|
import type { WorkspaceTree } from "./tree";
|
|
24
24
|
import { joinPath, skippedDir } from "./tree";
|
|
25
25
|
import { checkPinIntegrity } from "./pin-integrity";
|
|
26
|
-
import { dataExportTarget, findInstalledPackage } from "./class-data";
|
|
26
|
+
import { CHANT_INSTALL, dataExportTarget, findInstalledPackage } from "./class-data";
|
|
27
27
|
import { loadAjv2020 } from "./ajv2020";
|
|
28
28
|
import yaml from "js-yaml";
|
|
29
29
|
|
|
@@ -747,10 +747,19 @@ export interface LoadedKinds {
|
|
|
747
747
|
* directory, checked against its integrity digest when it has one. Null for
|
|
748
748
|
* a pin that names neither. Shared by the kinds and the principal classes
|
|
749
749
|
* (#3080), so both read a pin the same way.
|
|
750
|
+
*
|
|
751
|
+
* A package the checkout does not hold is looked up from `beside`, this chant's
|
|
752
|
+
* own install (plywood#54): a product's image carries chant and the pinned
|
|
753
|
+
* package together, and a checkout needs no copy of its own. The version check
|
|
754
|
+
* below still applies.
|
|
750
755
|
*/
|
|
751
|
-
export function pinnedPackageDir(
|
|
756
|
+
export function pinnedPackageDir(
|
|
757
|
+
pin: PinLike,
|
|
758
|
+
workspaceRoot: string,
|
|
759
|
+
beside: string = CHANT_INSTALL,
|
|
760
|
+
): { dir: string; source: string } | { problem: string } | null {
|
|
752
761
|
if (pin.package) {
|
|
753
|
-
const dir = findInstalledPackage(pin.package, workspaceRoot);
|
|
762
|
+
const dir = findInstalledPackage(pin.package, workspaceRoot) ?? findInstalledPackage(pin.package, beside);
|
|
754
763
|
if (!dir) return { problem: `pinned package ${pin.package} is not installed; install it to read the kinds it supplies` };
|
|
755
764
|
let installed: unknown;
|
|
756
765
|
try {
|