@intentius/chant 0.124.21 → 0.124.23

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 (95) hide show
  1. package/dist/audit/rules-doc.js +1 -1
  2. package/dist/cli/handlers/graph.js +24 -1
  3. package/dist/codegen/docs-pages.d.ts +1 -0
  4. package/dist/codegen/docs-pages.d.ts.map +1 -1
  5. package/dist/codegen/docs-pages.js +1 -0
  6. package/dist/codegen/docs-sections.d.ts +2 -0
  7. package/dist/codegen/docs-sections.d.ts.map +1 -1
  8. package/dist/codegen/docs-sections.js +8 -0
  9. package/dist/codegen/docs-types.d.ts +7 -0
  10. package/dist/codegen/docs-types.d.ts.map +1 -1
  11. package/dist/codegen/docs.d.ts.map +1 -1
  12. package/dist/codegen/docs.js +20 -0
  13. package/dist/fold/subset.d.ts +3 -1
  14. package/dist/fold/subset.d.ts.map +1 -1
  15. package/dist/fold/subset.js +3 -1
  16. package/dist/graph-ir.d.ts +43 -0
  17. package/dist/graph-ir.d.ts.map +1 -1
  18. package/dist/graph-ir.js +27 -0
  19. package/dist/lexicon.d.ts +25 -1
  20. package/dist/lexicon.d.ts.map +1 -1
  21. package/dist/lint/rules/evl004-spread-non-const.d.ts.map +1 -1
  22. package/dist/lint/rules/evl004-spread-non-const.js +19 -1
  23. package/dist/wave-runtime.mjs +222 -206
  24. package/dist/workspace/checks/links.d.ts +5 -0
  25. package/dist/workspace/checks/links.d.ts.map +1 -1
  26. package/dist/workspace/checks/links.js +54 -8
  27. package/dist/workspace/checks.d.ts +4 -1
  28. package/dist/workspace/checks.d.ts.map +1 -1
  29. package/dist/workspace/checks.js +6 -2
  30. package/dist/workspace/compose-graph.d.ts +4 -1
  31. package/dist/workspace/compose-graph.d.ts.map +1 -1
  32. package/dist/workspace/compose-graph.js +3 -2
  33. package/dist/workspace/dbt-project-reader.d.ts +36 -0
  34. package/dist/workspace/dbt-project-reader.d.ts.map +1 -0
  35. package/dist/workspace/dbt-project-reader.js +290 -0
  36. package/dist/workspace/graph-cli.d.ts.map +1 -1
  37. package/dist/workspace/graph-cli.js +3 -1
  38. package/dist/workspace/graph.schema.json +41 -3
  39. package/dist/workspace/intent.js +7 -2
  40. package/dist/workspace/kind-link-readers.d.ts +84 -0
  41. package/dist/workspace/kind-link-readers.d.ts.map +1 -0
  42. package/dist/workspace/kind-link-readers.js +53 -0
  43. package/dist/workspace/kinds.d.ts +15 -0
  44. package/dist/workspace/kinds.d.ts.map +1 -1
  45. package/dist/workspace/kinds.js +11 -0
  46. package/dist/workspace/lexicon-outputs.d.ts +63 -0
  47. package/dist/workspace/lexicon-outputs.d.ts.map +1 -0
  48. package/dist/workspace/lexicon-outputs.js +241 -0
  49. package/dist/workspace/links.d.ts +29 -7
  50. package/dist/workspace/links.d.ts.map +1 -1
  51. package/dist/workspace/links.js +109 -34
  52. package/dist/workspace/member-handles.d.ts +18 -1
  53. package/dist/workspace/member-handles.d.ts.map +1 -1
  54. package/dist/workspace/member-handles.js +31 -14
  55. package/dist/workspace/records-checkout.d.ts +11 -1
  56. package/dist/workspace/records-checkout.d.ts.map +1 -1
  57. package/dist/workspace/records-checkout.js +38 -2
  58. package/dist/workspace/status.d.ts.map +1 -1
  59. package/dist/workspace/status.js +3 -2
  60. package/dist/workspace/workspace-kinds.schema.json +5 -0
  61. package/package.json +1 -1
  62. package/src/audit/rules-doc.ts +1 -1
  63. package/src/cli/handlers/graph.ts +22 -1
  64. package/src/codegen/docs-pages.ts +1 -0
  65. package/src/codegen/docs-sections.ts +8 -0
  66. package/src/codegen/docs-site/AgentPrompt.astro +153 -0
  67. package/src/codegen/docs-types.ts +7 -0
  68. package/src/codegen/docs.ts +27 -0
  69. package/src/fold/subset.ts +3 -1
  70. package/src/graph-ir.test.ts +23 -1
  71. package/src/graph-ir.ts +65 -0
  72. package/src/lexicon.ts +26 -1
  73. package/src/lint/rules/evl004-spread-non-const.test.ts +18 -0
  74. package/src/lint/rules/evl004-spread-non-const.ts +16 -1
  75. package/src/wave-loop-golden.test.ts +3 -0
  76. package/src/workspace/checks/links.ts +57 -8
  77. package/src/workspace/checks.e2e.test.ts +1 -1
  78. package/src/workspace/checks.ts +9 -2
  79. package/src/workspace/compose-graph.ts +5 -3
  80. package/src/workspace/dbt-kind.e2e.test.ts +95 -0
  81. package/src/workspace/dbt-kind.test.ts +283 -0
  82. package/src/workspace/dbt-project-reader.ts +291 -0
  83. package/src/workspace/graph-cli.ts +3 -1
  84. package/src/workspace/graph.schema.json +41 -3
  85. package/src/workspace/intent.ts +7 -2
  86. package/src/workspace/kind-link-readers.ts +109 -0
  87. package/src/workspace/kinds.ts +21 -1
  88. package/src/workspace/lexicon-outputs.ts +272 -0
  89. package/src/workspace/links.test.ts +22 -0
  90. package/src/workspace/links.ts +129 -34
  91. package/src/workspace/member-handles.ts +28 -8
  92. package/src/workspace/records-checkout.ts +36 -2
  93. package/src/workspace/records-uncommitted.test.ts +5 -1
  94. package/src/workspace/status.ts +3 -2
  95. package/src/workspace/workspace-kinds.schema.json +5 -0
@@ -11,10 +11,15 @@
11
11
  *
12
12
  * Every git call here reads. None takes the index lock or refreshes the
13
13
  * index (`--no-optional-locks`), so a read leaves the checkout as it was,
14
- * `.git` included, which the reader conformance suite checks.
14
+ * `.git` included, which the reader conformance suite checks. A diff against
15
+ * the working tree is the exception git makes: it refreshes the index even
16
+ * then, so {@link worktreeChanges} runs it on a private copy.
15
17
  */
16
18
 
17
19
  import { execFileSync } from "node:child_process";
20
+ import { copyFileSync, existsSync, mkdtempSync, rmSync } from "node:fs";
21
+ import { tmpdir } from "node:os";
22
+ import { isAbsolute, join } from "node:path";
18
23
  import { resolveBase, type BaseSource } from "./trust/provenance";
19
24
 
20
25
  /** Where a record's file stands against `HEAD`. */
@@ -55,6 +60,35 @@ function tryGit(top: string, args: string[]): string | undefined {
55
60
  }
56
61
  }
57
62
 
63
+ /**
64
+ * The paths under `spec` whose working-tree content differs from `rev`, or
65
+ * undefined when git can't say. `git diff <rev>` refreshes the index's stat
66
+ * data for a file touched without a change, and writes the index even under
67
+ * `--no-optional-locks` (git 2.54), so it runs against a copy of the index
68
+ * (`GIT_INDEX_FILE`) and the checkout's own index is never written.
69
+ */
70
+ export function worktreeChanges(top: string, rev: string, spec: string): string[] | undefined {
71
+ const scratch = mkdtempSync(join(tmpdir(), "chant-index-"));
72
+ try {
73
+ const at = tryGit(top, ["rev-parse", "--git-path", "index"])?.trim();
74
+ const index = at ? (isAbsolute(at) ? at : join(top, at)) : undefined;
75
+ const copy = join(scratch, "index");
76
+ if (index && existsSync(index)) copyFileSync(index, copy);
77
+ const out = execFileSync("git", ["--no-optional-locks", "--literal-pathspecs", "diff", "--name-only", "-z", "--no-renames", rev, "--", spec], {
78
+ cwd: top,
79
+ encoding: "utf-8",
80
+ stdio: ["ignore", "pipe", "pipe"],
81
+ maxBuffer: 256 * 1024 * 1024,
82
+ env: { ...process.env, GIT_INDEX_FILE: copy },
83
+ });
84
+ return out.split("\0").filter(Boolean);
85
+ } catch {
86
+ return undefined;
87
+ } finally {
88
+ rmSync(scratch, { recursive: true, force: true });
89
+ }
90
+ }
91
+
58
92
  /**
59
93
  * The branch, head and base of the checkout at `top`. `explicitBase` is
60
94
  * `--base`, as the trust policy takes it; otherwise the target branch is the
@@ -98,7 +132,7 @@ export function worktreeStates(
98
132
  const direct = (p: string) => p.startsWith(prefix) && !p.slice(prefix.length).includes("/");
99
133
  const spec = dir === "." ? "." : dir;
100
134
  const atHead = new Set(zList(tryGit(top, ["ls-tree", "-r", "-z", "--name-only", head, "--", spec])).filter(direct));
101
- const changed = new Set(zList(tryGit(top, ["diff", "--name-only", "-z", "--no-renames", head, "--", spec])));
135
+ const changed = new Set(worktreeChanges(top, head, spec) ?? []);
102
136
  for (const p of paths) states.set(p, !atHead.has(p) ? "new" : changed.has(p) ? "modified" : "committed");
103
137
  const present = new Set(paths);
104
138
  const deleted = [...atHead].filter((p) => !present.has(p) && match.test(p.slice(prefix.length))).sort();
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { execFileSync } from "node:child_process";
9
- import { cpSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
9
+ import { cpSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
10
10
  import { tmpdir } from "node:os";
11
11
  import { join } from "node:path";
12
12
  import Ajv2020 from "ajv/dist/2020";
@@ -101,6 +101,10 @@ describe("records in the working tree (#3160)", () => {
101
101
  const { root } = repository();
102
102
  const path = join(root, file("001"));
103
103
  writeFileSync(path, decided("001"));
104
+ // Its stat data no longer matches the index on any clock, so a read that
105
+ // refreshes the index would write it (a CI runner was slow enough to).
106
+ const later = new Date(Date.now() + 5_000);
107
+ utimesSync(path, later, later);
104
108
  const index = join(root, ".git", "index");
105
109
  const before = { bytes: readFileSync(index), mtime: statSync(index).mtimeMs };
106
110
  const doc = result(await queryRecords({ kind: KIND, cwd: root, uncommitted: true }));
@@ -41,7 +41,7 @@ import { readPathSha } from "../lifecycle/git";
41
41
  import { latestPerComponent, readReleaseLedger, type ReleaseRecord } from "../lifecycle/release-ledger";
42
42
  import { readReleasePlan, type ReleasePlan } from "../lifecycle/plan-ledger";
43
43
  import { listWorkLeases, type WorkLeaseState } from "../lifecycle/work-lease";
44
- import { readCheckoutHead, type CheckoutHead } from "./records-checkout";
44
+ import { readCheckoutHead, worktreeChanges, type CheckoutHead } from "./records-checkout";
45
45
  import { policyView, replicationState, type ReplicationState } from "./wip";
46
46
  import { findWorkspaceRoot } from "../project-root";
47
47
  import { resolveBoxes, type ResolvedIsolation } from "./box-isolation";
@@ -400,7 +400,8 @@ async function shipView(member: Member, cwd: string, read: LedgerReader): Promis
400
400
  };
401
401
  // The commit must be here: a release from a commit this checkout never had says nothing about it.
402
402
  if (lines(["cat-file", "-e", `${last.gitSha}^{commit}`]) === null) return view;
403
- const changed = lines(["diff", "--name-only", "-z", "--no-renames", last.gitSha, "--"]);
403
+ // A diff against the working tree writes the index; run it on a copy.
404
+ const changed = worktreeChanges(top, last.gitSha, ".") ?? null;
404
405
  const untracked = lines(["ls-files", "--others", "--exclude-standard", "-z"]);
405
406
  if (changed === null || untracked === null) return view;
406
407
  const bookkeeping = (path: string) => ship.bookkeeping.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
@@ -78,6 +78,11 @@
78
78
  },
79
79
  "fields": {
80
80
  "$ref": "#/$defs/fields"
81
+ },
82
+ "reader": {
83
+ "type": "string",
84
+ "pattern": "^[a-z][a-z0-9-]{0,39}$",
85
+ "description": "A link reader chant ships, by name, that derives a member's links from the member's own files (#3932): dbt-project reads a dbt project's sources. The reader is chant's code and runs offline, parsing files as data; the package supplies only the name. A name this chant doesn't have keeps the kind without a reader, and the load reports it. A chant older than this field fails a kinds file that uses it."
81
86
  }
82
87
  },
83
88
  "patternProperties": {