@intentset/cli 0.10.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.
Files changed (55) hide show
  1. package/dist/agents.d.ts.map +1 -1
  2. package/dist/agents.js +43 -2
  3. package/dist/agents.js.map +1 -1
  4. package/dist/commands/context.d.ts.map +1 -1
  5. package/dist/commands/context.js +18 -3
  6. package/dist/commands/context.js.map +1 -1
  7. package/dist/commands/graph.js +1 -1
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +10 -8
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/list.d.ts +49 -0
  12. package/dist/commands/list.d.ts.map +1 -0
  13. package/dist/commands/list.js +295 -0
  14. package/dist/commands/list.js.map +1 -0
  15. package/dist/commands/shared.d.ts +8 -0
  16. package/dist/commands/shared.d.ts.map +1 -1
  17. package/dist/commands/shared.js +15 -5
  18. package/dist/commands/shared.js.map +1 -1
  19. package/dist/glob.d.ts +4 -13
  20. package/dist/glob.d.ts.map +1 -1
  21. package/dist/glob.js +4 -57
  22. package/dist/glob.js.map +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/main.d.ts +1 -1
  28. package/dist/main.d.ts.map +1 -1
  29. package/dist/main.js +78 -5
  30. package/dist/main.js.map +1 -1
  31. package/dist/session.d.ts +1 -2
  32. package/dist/session.d.ts.map +1 -1
  33. package/dist/session.js +2 -3
  34. package/dist/session.js.map +1 -1
  35. package/dist/slices.d.ts +3 -21
  36. package/dist/slices.d.ts.map +1 -1
  37. package/dist/slices.js +3 -45
  38. package/dist/slices.js.map +1 -1
  39. package/dist/subject.d.ts +2 -0
  40. package/dist/subject.d.ts.map +1 -1
  41. package/dist/subject.js +11 -1
  42. package/dist/subject.js.map +1 -1
  43. package/package.json +9 -9
  44. package/src/agents.ts +43 -2
  45. package/src/commands/context.ts +22 -2
  46. package/src/commands/graph.ts +1 -1
  47. package/src/commands/init.ts +10 -8
  48. package/src/commands/list.ts +346 -0
  49. package/src/commands/shared.ts +20 -0
  50. package/src/glob.ts +4 -56
  51. package/src/index.ts +2 -0
  52. package/src/main.ts +85 -6
  53. package/src/session.ts +2 -3
  54. package/src/slices.ts +3 -52
  55. package/src/subject.ts +13 -1
package/src/slices.ts CHANGED
@@ -1,54 +1,5 @@
1
1
  /**
2
- * Slices, the code they claim and the records that describe them, for
3
- * `review`'s list of slices whose code changed while their records did not
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
- import { type Artifact, compareStrings, type Graph } from "@intentset/core";
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
  };