@intentset/cli 0.9.0 → 0.12.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/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +43 -2
- package/dist/agents.js.map +1 -1
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +18 -3
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/graph.js +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +10 -8
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +49 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +295 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/shared.d.ts +8 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +15 -5
- package/dist/commands/shared.js.map +1 -1
- package/dist/glob.d.ts +4 -13
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +4 -57
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- 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 +78 -5
- package/dist/main.js.map +1 -1
- package/dist/session.d.ts +1 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +2 -3
- package/dist/session.js.map +1 -1
- package/dist/slices.d.ts +3 -21
- package/dist/slices.d.ts.map +1 -1
- package/dist/slices.js +3 -45
- package/dist/slices.js.map +1 -1
- package/dist/subject.d.ts +2 -0
- package/dist/subject.d.ts.map +1 -1
- package/dist/subject.js +11 -1
- package/dist/subject.js.map +1 -1
- package/package.json +9 -9
- package/src/agents.ts +43 -2
- package/src/commands/context.ts +22 -2
- package/src/commands/graph.ts +1 -1
- package/src/commands/init.ts +10 -8
- package/src/commands/list.ts +346 -0
- package/src/commands/shared.ts +20 -0
- package/src/glob.ts +4 -56
- package/src/index.ts +2 -0
- package/src/main.ts +85 -6
- package/src/session.ts +2 -3
- package/src/slices.ts +3 -52
- package/src/subject.ts +13 -1
package/src/slices.ts
CHANGED
|
@@ -1,54 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* (Core §10) and for `context <path>`.
|
|
5
|
-
*
|
|
6
|
-
* A slice's code is what its `source`, `backend` and `contract` claims match;
|
|
7
|
-
* its `verification` and `documentation` claims are checks and prose, not
|
|
8
|
-
* implementation. The records that describe a slice are the slice itself, the
|
|
9
|
-
* behaviors it implements, the rules that govern them, the scenarios that
|
|
10
|
-
* illustrate them, the verifications of any of those, the contracts it
|
|
11
|
-
* exposes, and the decisions that inform the slice, its behaviors or its
|
|
12
|
-
* contracts. Knowledge is left out: it explains the model to an audience, and
|
|
13
|
-
* review pins already mark it for review when the model changes.
|
|
2
|
+
* The slice helpers `review` and `context` use. They moved to `@intentset/core` in 0.11.0 (ADR 0016), where `select`
|
|
3
|
+
* shares them; the CLI re-exports them for one release, and from 0.12.0 a consumer imports them from core.
|
|
14
4
|
*/
|
|
15
|
-
|
|
16
|
-
import { matchGlob } from "./glob.ts";
|
|
17
|
-
|
|
18
|
-
const CODE_CLAIMS = new Set(["source", "backend", "contract"]);
|
|
19
|
-
|
|
20
|
-
/** Every slice that is not retired and has slice metadata, sorted by ID. */
|
|
21
|
-
export function activeSlices(graph: Graph): Artifact[] {
|
|
22
|
-
return [...graph.artifacts.values()]
|
|
23
|
-
.filter((a) => a.meta.type === "slice" && a.meta.status !== "retired" && a.meta.slice !== undefined)
|
|
24
|
-
.sort((a, b) => compareStrings(a.meta.id, b.meta.id));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** The slices with any claim matching `path`, sorted by ID. */
|
|
28
|
-
export function claimingSlices(graph: Graph, path: string): Artifact[] {
|
|
29
|
-
return activeSlices(graph).filter((slice) => slice.meta.slice?.claims.some((claim) => matchGlob(claim.path, path)));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** True when one of the slice's source, backend or contract claims matches `path`. */
|
|
33
|
-
export function isSliceCode(slice: Artifact, path: string): boolean {
|
|
34
|
-
return slice.meta.slice?.claims.some((claim) => CODE_CLAIMS.has(claim.kind) && matchGlob(claim.path, path)) ?? false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** The IDs of the records that describe a slice, the slice included, sorted. Only IDs present in the graph. */
|
|
38
|
-
export function describingRecords(graph: Graph, slice: Artifact): string[] {
|
|
39
|
-
const out = new Set<string>([slice.meta.id]);
|
|
40
|
-
const targets = (id: string, kind: string) =>
|
|
41
|
-
(graph.out.get(id) ?? []).filter((edge) => edge.kind === kind).map((edge) => edge.to);
|
|
42
|
-
const sources = (id: string, kind: string) =>
|
|
43
|
-
(graph.in.get(id) ?? []).filter((edge) => edge.kind === kind).map((edge) => edge.from);
|
|
44
|
-
|
|
45
|
-
const behaviors = targets(slice.meta.id, "implements");
|
|
46
|
-
const rules = behaviors.flatMap((id) => targets(id, "governedBy"));
|
|
47
|
-
const scenarios = behaviors.flatMap((id) => sources(id, "illustrates"));
|
|
48
|
-
const claims = [...behaviors, ...rules, ...scenarios];
|
|
49
|
-
const verifications = claims.flatMap((id) => sources(id, "verifies"));
|
|
50
|
-
const contracts = targets(slice.meta.id, "exposes");
|
|
51
|
-
const decisions = [slice.meta.id, ...behaviors, ...contracts].flatMap((id) => targets(id, "informedBy"));
|
|
52
|
-
for (const id of [...claims, ...verifications, ...contracts, ...decisions]) out.add(id);
|
|
53
|
-
return [...out].filter((id) => graph.artifacts.has(id)).sort(compareStrings);
|
|
54
|
-
}
|
|
5
|
+
export { activeSlices, claimingSlices, describingRecords, isSliceCode } from "@intentset/core";
|
package/src/subject.ts
CHANGED
|
@@ -21,6 +21,18 @@ import { changedSince } from "./git.ts";
|
|
|
21
21
|
import type { Repository } from "./repository.ts";
|
|
22
22
|
import type { Tree } from "./tree.ts";
|
|
23
23
|
|
|
24
|
+
/** Where run records are read from when no --evidence is given. Local output: not to be committed. */
|
|
25
|
+
export const EVIDENCE_DIR = ".intentset/evidence";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The run records under EVIDENCE_DIR are the toolchain's own output, never part of a subject, so a change to them
|
|
29
|
+
* says nothing about evidence and is left out of what `changedSince` answers: EVID005 would otherwise list the file
|
|
30
|
+
* `evidence import --out` has just written, until it is ignored or committed.
|
|
31
|
+
*/
|
|
32
|
+
function outsideEvidence(paths: string[] | null): string[] | null {
|
|
33
|
+
return paths === null ? null : paths.filter((path) => path !== EVIDENCE_DIR && !path.startsWith(`${EVIDENCE_DIR}/`));
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
/** The binding in force: the option, else the configuration, else the default (Core §8). */
|
|
25
37
|
export function bindingFor(repo: Repository, graph: Graph, given: EvidenceBinding | undefined): BindingDecision {
|
|
26
38
|
return resolveBinding(given ?? repo.config.evidence.binding, hasSliceClaims(graph));
|
|
@@ -56,7 +68,7 @@ export function subjectsOf(repo: Repository, graph: Graph, tree: Tree): Subjects
|
|
|
56
68
|
subjects: subjectsFor(graph, source),
|
|
57
69
|
source,
|
|
58
70
|
changedSince: (commit) => {
|
|
59
|
-
if (!asked.has(commit)) asked.set(commit, changedSince(repo.root, commit));
|
|
71
|
+
if (!asked.has(commit)) asked.set(commit, outsideEvidence(changedSince(repo.root, commit)));
|
|
60
72
|
return asked.get(commit) ?? null;
|
|
61
73
|
},
|
|
62
74
|
};
|