@intentset/cli 0.6.1 → 0.7.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/README.md +35 -0
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +18 -10
- package/dist/agents.js.map +1 -1
- package/dist/commands/evidence-stale.d.ts +19 -0
- package/dist/commands/evidence-stale.d.ts.map +1 -0
- package/dist/commands/evidence-stale.js +118 -0
- package/dist/commands/evidence-stale.js.map +1 -0
- package/dist/commands/evidence.d.ts +7 -0
- package/dist/commands/evidence.d.ts.map +1 -1
- package/dist/commands/evidence.js +19 -2
- package/dist/commands/evidence.js.map +1 -1
- package/dist/commands/graph.js +1 -1
- package/dist/commands/guide.d.ts +5 -0
- package/dist/commands/guide.d.ts.map +1 -0
- package/dist/commands/guide.js +16 -0
- package/dist/commands/guide.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +11 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.d.ts +23 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +125 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/git.d.ts +13 -0
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +26 -0
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +146 -44
- package/dist/main.js.map +1 -1
- package/dist/reports.d.ts.map +1 -1
- package/dist/reports.js +26 -3
- package/dist/reports.js.map +1 -1
- package/dist/session.d.ts +8 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +18 -1
- package/dist/session.js.map +1 -1
- package/dist/subject.d.ts +16 -0
- package/dist/subject.d.ts.map +1 -0
- package/dist/subject.js +44 -0
- package/dist/subject.js.map +1 -0
- package/package.json +18 -10
- package/src/agents.ts +18 -10
- package/src/commands/evidence-stale.ts +151 -0
- package/src/commands/evidence.ts +30 -3
- package/src/commands/graph.ts +1 -1
- package/src/commands/guide.ts +17 -0
- package/src/commands/init.ts +12 -3
- package/src/commands/migrate.ts +136 -0
- package/src/git.ts +25 -0
- package/src/index.ts +3 -1
- package/src/main.ts +150 -44
- package/src/reports.ts +27 -3
- package/src/session.ts +26 -1
- package/src/subject.ts +61 -0
package/src/session.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type Artifact,
|
|
26
26
|
compareStrings,
|
|
27
27
|
type Diagnostic,
|
|
28
|
+
type EvidenceBinding,
|
|
28
29
|
type Graph,
|
|
29
30
|
graphHash,
|
|
30
31
|
hasErrors,
|
|
@@ -36,6 +37,7 @@ import {
|
|
|
36
37
|
} from "@intentset/core";
|
|
37
38
|
import { reviewStatus } from "@intentset/publisher";
|
|
38
39
|
import {
|
|
40
|
+
type BindingDecision,
|
|
39
41
|
checkEvidence,
|
|
40
42
|
type EvidenceCheck,
|
|
41
43
|
type EvidenceSnapshot,
|
|
@@ -46,6 +48,7 @@ import {
|
|
|
46
48
|
import { insideRoot } from "./outputs.ts";
|
|
47
49
|
import { formatDiagnostic, type Io, type Snapshot } from "./output.ts";
|
|
48
50
|
import { type CarrierName, CONFIG_PATH, findRoot, loadRepository, type Repository } from "./repository.ts";
|
|
51
|
+
import { bindingFor, subjectsOf } from "./subject.ts";
|
|
49
52
|
import { readTree, type Tree } from "./tree.ts";
|
|
50
53
|
|
|
51
54
|
/** Where run records are read from when no --evidence is given. Local output: not to be committed. */
|
|
@@ -64,12 +67,18 @@ export interface SessionOptions {
|
|
|
64
67
|
scope?: RunScope | null;
|
|
65
68
|
/** The day exceptions expire against; default today, UTC. */
|
|
66
69
|
today?: string;
|
|
70
|
+
/** L3 and above: the evidence binding asked for on the command line, overriding the configuration. */
|
|
71
|
+
binding?: EvidenceBinding;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
export interface EvidenceRun {
|
|
70
75
|
/** The files read, as repository-relative paths where they lie inside the root. */
|
|
71
76
|
files: string[];
|
|
72
77
|
records: number;
|
|
78
|
+
/** The records read, as classified; the export classifies them again under the binding its contract states. */
|
|
79
|
+
runRecords: RunRecord[];
|
|
80
|
+
/** The binding in force and why. */
|
|
81
|
+
binding: BindingDecision;
|
|
73
82
|
check: EvidenceCheck;
|
|
74
83
|
snapshot: EvidenceSnapshot;
|
|
75
84
|
}
|
|
@@ -171,17 +180,33 @@ export function openSession(command: string, options: SessionOptions, io: Io): S
|
|
|
171
180
|
}
|
|
172
181
|
shown.push(path);
|
|
173
182
|
}
|
|
183
|
+
const decision = bindingFor(repo, graph, options.binding);
|
|
174
184
|
const evidenceSnapshot: EvidenceSnapshot = {
|
|
175
185
|
commit: snapshot.commit,
|
|
176
186
|
graphHash: snapshot.graphHash,
|
|
177
187
|
scope: options.scope ?? null,
|
|
188
|
+
binding: decision.binding,
|
|
189
|
+
bindingReason: decision.reason,
|
|
178
190
|
};
|
|
191
|
+
if (decision.binding === "subject" && session.tree !== undefined && records.length > 0) {
|
|
192
|
+
const computed = subjectsOf(repo, graph, session.tree);
|
|
193
|
+
evidenceSnapshot.subjects = computed.subjects;
|
|
194
|
+
evidenceSnapshot.covers = computed.source.covers;
|
|
195
|
+
evidenceSnapshot.changedSince = computed.changedSince;
|
|
196
|
+
}
|
|
179
197
|
const check = checkEvidence(graph, records, evidenceSnapshot, {
|
|
180
198
|
level,
|
|
181
199
|
files: session.tree?.paths,
|
|
182
200
|
evidencePath: shown.length === 1 ? shown[0] : null,
|
|
183
201
|
});
|
|
184
|
-
session.evidence = {
|
|
202
|
+
session.evidence = {
|
|
203
|
+
files: shown,
|
|
204
|
+
records: records.length,
|
|
205
|
+
runRecords: records,
|
|
206
|
+
binding: decision,
|
|
207
|
+
check,
|
|
208
|
+
snapshot: evidenceSnapshot,
|
|
209
|
+
};
|
|
185
210
|
all.push(...check.diagnostics);
|
|
186
211
|
}
|
|
187
212
|
|
package/src/subject.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evidence binding in the CLI (Core §8): which binding is in force for a
|
|
3
|
+
* session, and the subjects it judges by. The file reads are the repository's
|
|
4
|
+
* own working tree, so a subject hashes what is on disk, uncommitted edits
|
|
5
|
+
* included; `evidence import` refuses an uncommitted tree for the commit it
|
|
6
|
+
* records, not for the subject.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { subjectSource } from "@intentset/architecture";
|
|
11
|
+
import type { EvidenceBinding, Graph } from "@intentset/core";
|
|
12
|
+
import {
|
|
13
|
+
type BindingDecision,
|
|
14
|
+
hasSliceClaims,
|
|
15
|
+
resolveBinding,
|
|
16
|
+
type Subject,
|
|
17
|
+
type SubjectSource,
|
|
18
|
+
subjectsFor,
|
|
19
|
+
} from "@intentset/verification";
|
|
20
|
+
import { changedSince } from "./git.ts";
|
|
21
|
+
import type { Repository } from "./repository.ts";
|
|
22
|
+
import type { Tree } from "./tree.ts";
|
|
23
|
+
|
|
24
|
+
/** The binding in force: the option, else the configuration, else the default (Core §8). */
|
|
25
|
+
export function bindingFor(repo: Repository, graph: Graph, given: EvidenceBinding | undefined): BindingDecision {
|
|
26
|
+
return resolveBinding(given ?? repo.config.evidence.binding, hasSliceClaims(graph));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The architecture's resolution over the tree, reading file contents from disk. */
|
|
30
|
+
export function sourceFor(repo: Repository, graph: Graph, tree: Tree): SubjectSource {
|
|
31
|
+
return subjectSource(graph, repo.registries, tree, {
|
|
32
|
+
globalInputs: repo.config.evidence.globalInputs,
|
|
33
|
+
readFile: (path) => {
|
|
34
|
+
try {
|
|
35
|
+
return readFileSync(join(repo.root, path));
|
|
36
|
+
} catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface Subjects {
|
|
44
|
+
subjects: Map<string, Subject>;
|
|
45
|
+
source: SubjectSource;
|
|
46
|
+
/** Files changed since a commit, asked of git once per commit. */
|
|
47
|
+
changedSince: (commit: string) => string[] | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function subjectsOf(repo: Repository, graph: Graph, tree: Tree): Subjects {
|
|
51
|
+
const source = sourceFor(repo, graph, tree);
|
|
52
|
+
const asked = new Map<string, string[] | null>();
|
|
53
|
+
return {
|
|
54
|
+
subjects: subjectsFor(graph, source),
|
|
55
|
+
source,
|
|
56
|
+
changedSince: (commit) => {
|
|
57
|
+
if (!asked.has(commit)) asked.set(commit, changedSince(repo.root, commit));
|
|
58
|
+
return asked.get(commit) ?? null;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|