@codyswann/lisa 4.97.4 → 4.98.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 (92) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  3. package/dist/core/upstream-evidence-manifest.js +42 -75
  4. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  5. package/package.json +5 -4
  6. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa/rules/reference/derived-branch-plan.md +1 -1
  9. package/plugins/lisa-agy/plugin.json +1 -1
  10. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  11. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  12. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  13. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  14. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  15. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  16. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  17. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-copilot/rules/reference/derived-branch-plan.md +1 -1
  19. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cursor/rules/derived-branch-plan-reference.mdc +1 -1
  21. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  23. package/plugins/lisa-devin/rules/reference/derived-branch-plan.md +1 -1
  24. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  26. package/plugins/lisa-expo-agy/plugin.json +1 -1
  27. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  31. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  33. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  34. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  38. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  40. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  41. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  45. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  47. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  48. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  52. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  54. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  55. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  59. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  61. package/plugins/lisa-rails-agy/plugin.json +1 -1
  62. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  66. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  69. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  73. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  74. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  75. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  76. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  80. package/plugins/src/base/rules/reference/derived-branch-plan.md +1 -1
  81. package/scripts/check-phrase-manifest-parity.mjs +83 -0
  82. package/scripts/classify-phrase-tests.mjs +54 -0
  83. package/scripts/fix-namespace-test-assertions.mjs +3 -19
  84. package/scripts/generate-phrase-manifest.mjs +98 -0
  85. package/scripts/lib/phrase-tests/ast.mjs +147 -0
  86. package/scripts/lib/phrase-tests/classify.mjs +293 -0
  87. package/scripts/lib/phrase-tests/fold.mjs +55 -0
  88. package/scripts/lib/phrase-tests/manifest.mjs +183 -0
  89. package/scripts/lib/phrase-tests/parity.mjs +74 -0
  90. package/scripts/lib/phrase-tests/record.mjs +568 -0
  91. package/scripts/lib/phrase-tests/repo.mjs +99 -0
  92. package/scripts/lib/phrase-tests/runner.mjs +256 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "Distributable LLM Wiki kernel — ingest, query, lint, and maintain a git-native markdown knowledge base across Claude and Codex.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.97.4",
3
+ "version": "4.98.0",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -139,7 +139,7 @@ This is **not** an executable control. `ready-role-filing`'s sibling guard is a
139
139
 
140
140
  The regression suite has two halves. **Why they bind differently is `falsifiable-checks`' subject, not this rule's** — read the quantifier guidance there. What belongs here is the measurement, because this contract happens to be where it was taken.
141
141
 
142
- - `runtime-behavior-change-decidability.test.ts` asserts the wording is *present* across all six generated skill roots. It pins the contract against silent deletion or a lossy regeneration, and proves nothing about any particular copy.
142
+ - `tests/phrase-manifest/required-phrases.json`, checked by `tests/unit/docs/required-phrases.test.ts`, asserts the wording is *present* across all six generated skill roots. It pins the contract against silent deletion or a lossy regeneration, and proves nothing about any particular copy.
143
143
  - `runtime-behavior-change-consistency.test.ts` asserts no copy says the *wrong* thing, over every occurrence in the corpus: every declaration marker uses the em-dash discriminator, every absence-derivation site resolves to *underivable* within its own sentence, and no phrasing maps an absent section to `false` or hands authority back to the caller.
144
144
 
145
145
  This document states its rule **twice** — once in gate S8, once in the execution step — which is what made the gap observable. `lisa-linear-validate-issue` once spelled the discriminator with an ASCII hyphen in its execution step while its own S8 used the em-dash, and 192 assertions stayed green through that mutation twice running. The fix pinned the execution step and left S8's copy bare. Mutating each site separately, whole suite, before and after the second half landed:
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Prove the required-phrases manifest carries every phrase assertion of the
4
+ * test files it replaced (CodySwannGT/lisa#4609).
5
+ *
6
+ * For every test file present at `--base` but gone from `HEAD`, the file and
7
+ * its helpers are read from the base commit (`git show`), classified, and the
8
+ * phrase-only ones are re-run under the recording runner. Their deduped
9
+ * (file, polarity, kind, value) assertions must all be in
10
+ * `tests/phrase-manifest/required-phrases.json`, and the deleted phrase-only
11
+ * files must be exactly the test files the manifest's `source` entries name.
12
+ * The full list of failure conditions is in `lib/phrase-tests/parity.mjs`;
13
+ * in particular a base that deletes nothing FAILS rather than passing empty.
14
+ *
15
+ * It replays the base's tests against the CURRENT tree's text files, so it is
16
+ * a merge-time proof of the fold. After later wording edits (which change the
17
+ * manifest by hand), the old assertions no longer hold and surface as "fails
18
+ * on the current tree" — that is expected, not a regression of the manifest.
19
+ *
20
+ * Usage:
21
+ * node scripts/check-phrase-manifest-parity.mjs --base <ref> [--exact]
22
+ * `bun run check:phrase-manifest-parity` uses the commit before the fold.
23
+ * @module scripts/check-phrase-manifest-parity
24
+ */
25
+ import { readFileSync } from "node:fs";
26
+ import path from "node:path";
27
+
28
+ import { foldPhraseTests } from "./lib/phrase-tests/fold.mjs";
29
+ import {
30
+ MANIFEST_PATH,
31
+ manifestEntries,
32
+ } from "./lib/phrase-tests/manifest.mjs";
33
+ import { parityFailures } from "./lib/phrase-tests/parity.mjs";
34
+ import {
35
+ commitReader,
36
+ REPO_ROOT,
37
+ testFilesAt,
38
+ } from "./lib/phrase-tests/repo.mjs";
39
+
40
+ const argv = process.argv.slice(2);
41
+ // The last --base wins, so `bun run check:phrase-manifest-parity --base <ref>`
42
+ // overrides the package script's default.
43
+ const baseIndex = argv.lastIndexOf("--base");
44
+ const base = baseIndex === -1 ? undefined : argv[baseIndex + 1];
45
+ if (base === undefined || base.startsWith("--")) {
46
+ console.error(
47
+ "usage: check-phrase-manifest-parity.mjs --base <ref> [--exact]"
48
+ );
49
+ process.exit(2);
50
+ }
51
+
52
+ // Phrase tests resolve relative paths against the cwd, as vitest runs them.
53
+ process.chdir(REPO_ROOT);
54
+
55
+ const onHead = new Set(testFilesAt(REPO_ROOT, "HEAD"));
56
+ const deleted = testFilesAt(REPO_ROOT, base).filter(file => !onHead.has(file));
57
+ const fold = await foldPhraseTests(deleted, {
58
+ root: REPO_ROOT,
59
+ readSource: commitReader(REPO_ROOT, base),
60
+ });
61
+ const manifest = JSON.parse(
62
+ readFileSync(path.join(REPO_ROOT, MANIFEST_PATH), "utf8")
63
+ );
64
+
65
+ console.log(`base ${base}: ${deleted.length} test file(s) deleted on HEAD`);
66
+ console.log(` phrase-only: ${fold.recordings.length}`);
67
+ console.log(` not phrase-only: ${deleted.length - fold.recordings.length}`);
68
+ console.log(
69
+ `before: ${fold.raw} runtime phrase assertions, ${fold.keys.size} distinct (file, polarity, kind, value)`
70
+ );
71
+ console.log(`after: ${manifestEntries(manifest).length} manifest entries`);
72
+
73
+ const failures = parityFailures({
74
+ deleted,
75
+ fold,
76
+ manifest,
77
+ exact: argv.includes("--exact"),
78
+ });
79
+ for (const failure of failures) console.error(`FAIL ${failure}`);
80
+ console.log(
81
+ failures.length === 0 ? "parity: OK" : `parity: ${failures.length} failure(s)`
82
+ );
83
+ process.exit(failures.length === 0 ? 0 : 1);
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * List the phrase-only test files (CodySwannGT/lisa#4609): files whose only
4
+ * I/O is reading text and whose every assertion checks a phrase is present
5
+ * or absent in that text. The rules live in `lib/phrase-tests/classify.mjs`.
6
+ *
7
+ * Usage:
8
+ * node scripts/classify-phrase-tests.mjs # one line per file
9
+ * node scripts/classify-phrase-tests.mjs --json # machine-readable
10
+ * node scripts/classify-phrase-tests.mjs --all # also rejected files, with reasons
11
+ * @module scripts/classify-phrase-tests
12
+ */
13
+ import { classifyTestSource } from "./lib/phrase-tests/classify.mjs";
14
+ import {
15
+ REPO_ROOT,
16
+ workingTreeReader,
17
+ workingTreeTestFiles,
18
+ } from "./lib/phrase-tests/repo.mjs";
19
+
20
+ const args = new Set(process.argv.slice(2));
21
+ const readSource = workingTreeReader(REPO_ROOT);
22
+ const verdicts = workingTreeTestFiles(REPO_ROOT).map(file =>
23
+ classifyTestSource(file, readSource(file) ?? "", readSource)
24
+ );
25
+ const phraseOnly = verdicts.filter(verdict => verdict.phraseOnly);
26
+ const shown = args.has("--all") ? verdicts : phraseOnly;
27
+
28
+ if (args.has("--json")) {
29
+ console.log(
30
+ JSON.stringify(
31
+ {
32
+ testFiles: verdicts.length,
33
+ phraseOnly: phraseOnly.length,
34
+ assertionSites: phraseOnly.reduce((sum, v) => sum + v.assertions, 0),
35
+ files: shown,
36
+ },
37
+ null,
38
+ 2
39
+ )
40
+ );
41
+ } else {
42
+ for (const verdict of shown) {
43
+ const tail = verdict.phraseOnly
44
+ ? ""
45
+ : ` REJECTED: ${verdict.reasons.join("; ")}`;
46
+ console.log(
47
+ `${String(verdict.assertions).padStart(5)} ${verdict.file}${tail}`
48
+ );
49
+ }
50
+ console.log(
51
+ `${phraseOnly.length} phrase-only of ${verdicts.length} test files; ` +
52
+ `${phraseOnly.reduce((sum, v) => sum + v.assertions, 0)} assertion sites`
53
+ );
54
+ }
@@ -25,17 +25,9 @@ function patchFile(file, replacements) {
25
25
  }
26
26
 
27
27
  const testPatches = [
28
- // prd-verified-lifecycle-docs skill/agent paths
29
- [
30
- "tests/unit/strategies/prd-verified-lifecycle-docs.test.ts",
31
- [
32
- [
33
- "`skills/${vendor}-prd-intake/SKILL.md`",
34
- "`skills/lisa-${vendor}-prd-intake/SKILL.md`",
35
- ],
36
- ],
37
- ],
38
- // Skill invocation refs in tests (colon → hyphen for skills)
28
+ // Skill invocation refs in tests (colon → hyphen for skills). The
29
+ // phrase-only suites this also patched were folded into
30
+ // tests/phrase-manifest/required-phrases.json (CodySwannGT/lisa#4609).
39
31
  [
40
32
  "tests/unit/strategies/prd-intake-s10-hard-gate.test.ts",
41
33
  [
@@ -43,14 +35,6 @@ const testPatches = [
43
35
  ["lisa:task-decomposition", "lisa-task-decomposition"],
44
36
  ],
45
37
  ],
46
- [
47
- "tests/unit/strategies/github-linked-pr-project-membership.test.ts",
48
- [["lisa:github-project-v2", "lisa-github-project-v2"]],
49
- ],
50
- [
51
- "tests/unit/strategies/github-writer-project-membership.test.ts",
52
- [["lisa:github-project-v2", "lisa-github-project-v2"]],
53
- ],
54
38
  // agent-transformer output uses normalized skill names
55
39
  [
56
40
  "tests/unit/codex/agent-transformer.test.ts",
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One-time fold of the phrase-only test files into the required-phrases
4
+ * manifest (CodySwannGT/lisa#4609).
5
+ *
6
+ * Classifies every test file, runs each phrase-only one under the recording
7
+ * runner, and writes `tests/phrase-manifest/required-phrases.json` from the
8
+ * files whose every runtime phrase assertion translated. With `--delete` it
9
+ * also removes those test files. Files with any untranslatable assertion are
10
+ * listed with the reason and left untouched.
11
+ *
12
+ * This is a ONE-TIME generator: once the translated files are deleted it can
13
+ * no longer re-derive their phrases, and the manifest becomes the
14
+ * hand-maintained source of truth. It therefore refuses to overwrite an
15
+ * existing manifest unless `--force` is given. Use
16
+ * `scripts/check-phrase-manifest-parity.mjs` to re-prove the fold later.
17
+ *
18
+ * Usage:
19
+ * node scripts/generate-phrase-manifest.mjs [--dry-run] [--delete] [--force] [--json]
20
+ * @module scripts/generate-phrase-manifest
21
+ */
22
+ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
23
+ import path from "node:path";
24
+
25
+ import { foldPhraseTests } from "./lib/phrase-tests/fold.mjs";
26
+ import {
27
+ buildManifest,
28
+ MANIFEST_PATH,
29
+ manifestEntries,
30
+ } from "./lib/phrase-tests/manifest.mjs";
31
+ import {
32
+ REPO_ROOT,
33
+ workingTreeReader,
34
+ workingTreeTestFiles,
35
+ } from "./lib/phrase-tests/repo.mjs";
36
+
37
+ const args = new Set(process.argv.slice(2));
38
+ const manifestFile = path.join(REPO_ROOT, MANIFEST_PATH);
39
+
40
+ // Phrase tests resolve relative paths against the cwd, as vitest runs them.
41
+ process.chdir(REPO_ROOT);
42
+
43
+ if (
44
+ existsSync(manifestFile) &&
45
+ !args.has("--force") &&
46
+ !args.has("--dry-run")
47
+ ) {
48
+ console.error(
49
+ `${MANIFEST_PATH} already exists and is hand-maintained; pass --force to overwrite it.`
50
+ );
51
+ process.exit(1);
52
+ }
53
+
54
+ const fold = await foldPhraseTests(workingTreeTestFiles(REPO_ROOT), {
55
+ root: REPO_ROOT,
56
+ readSource: workingTreeReader(REPO_ROOT),
57
+ });
58
+ const manifest = buildManifest(fold.translated);
59
+ const summary = {
60
+ testFiles: fold.testFiles,
61
+ phraseOnly: fold.recordings.length,
62
+ translated: fold.translated.map(recording => recording.file),
63
+ untranslatable: fold.untranslatable.map(({ file, raw, reasons }) => ({
64
+ file,
65
+ raw,
66
+ reasons,
67
+ })),
68
+ rawAssertions: fold.raw,
69
+ dedupedAssertions: fold.keys.size,
70
+ manifestFiles: Object.keys(manifest.files).length,
71
+ manifestEntries: manifestEntries(manifest).length,
72
+ };
73
+
74
+ if (args.has("--json")) {
75
+ console.log(JSON.stringify(summary, null, 2));
76
+ } else {
77
+ console.log(`test files: ${summary.testFiles}`);
78
+ console.log(`phrase-only: ${summary.phraseOnly}`);
79
+ console.log(`translated: ${summary.translated.length}`);
80
+ console.log(`untranslatable (kept): ${summary.untranslatable.length}`);
81
+ for (const { file, reasons } of summary.untranslatable) {
82
+ console.log(` ${file}\n ${reasons.slice(0, 3).join("\n ")}`);
83
+ }
84
+ console.log(
85
+ `runtime assertions: ${summary.rawAssertions} (deduped ${summary.dedupedAssertions})`
86
+ );
87
+ console.log(
88
+ `manifest entries: ${summary.manifestEntries} across ${summary.manifestFiles} files`
89
+ );
90
+ }
91
+
92
+ if (!args.has("--dry-run")) {
93
+ mkdirSync(path.dirname(manifestFile), { recursive: true });
94
+ writeFileSync(manifestFile, `${JSON.stringify(manifest, null, 2)}\n`);
95
+ if (args.has("--delete")) {
96
+ for (const file of summary.translated) rmSync(path.join(REPO_ROOT, file));
97
+ }
98
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Shared TypeScript-AST helpers for the phrase-test tooling
3
+ * (CodySwannGT/lisa#4609).
4
+ *
5
+ * The classifier, the manifest generator and the parity check all have to
6
+ * agree on what "an assertion site" is, so the one definition lives here:
7
+ * a site is the matcher call that terminates an `expect(...)` chain. Parsing
8
+ * goes through the TypeScript compiler API rather than regular expressions
9
+ * because a regex cannot tell a string literal from a comment. (Values such
10
+ * as `it.each` tables and path joins are not resolved here at all: the
11
+ * recorder obtains them by running the file, see `record.mjs`.)
12
+ * @module scripts/lib/phrase-tests/ast
13
+ */
14
+ import ts from "typescript";
15
+
16
+ /** Matchers that test a phrase against text, per the issue's rule 3. */
17
+ export const PHRASE_MATCHERS = Object.freeze(["toContain", "toMatch"]);
18
+
19
+ /**
20
+ * Parse a test file's text into a TypeScript source file.
21
+ * @param {string} fileName - Repository-relative name, used for diagnostics.
22
+ * @param {string} text - The file's contents.
23
+ * @returns {ts.SourceFile} The parsed source file, with parent pointers set.
24
+ */
25
+ export function parseSource(fileName, text) {
26
+ return ts.createSourceFile(
27
+ fileName,
28
+ text,
29
+ ts.ScriptTarget.Latest,
30
+ true,
31
+ ts.ScriptKind.TS
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Visit every node beneath `root`, depth first.
37
+ * @param {ts.Node} root - Where to start.
38
+ * @param {(node: ts.Node) => void} visit - Called once per node.
39
+ */
40
+ export function walk(root, visit) {
41
+ visit(root);
42
+ ts.forEachChild(root, child => walk(child, visit));
43
+ }
44
+
45
+ /**
46
+ * Whether a node is an `expect(...)` call (not `expect.soft`, not a matcher).
47
+ * @param {ts.Node} node - Any node.
48
+ * @returns {node is ts.CallExpression} True for a bare `expect(...)` call.
49
+ */
50
+ export function isExpectCall(node) {
51
+ return (
52
+ ts.isCallExpression(node) &&
53
+ ts.isIdentifier(node.expression) &&
54
+ node.expression.text === "expect"
55
+ );
56
+ }
57
+
58
+ /**
59
+ * Climb from an `expect(...)` call to the matcher call that ends its chain.
60
+ * @param {ts.CallExpression} expectCall - The `expect(...)` call.
61
+ * @returns {{ site: ts.Node, subject: ts.Expression | undefined, negated: boolean, matcher: string | undefined, args: readonly ts.Expression[] }} The chain.
62
+ */
63
+ export function readExpectChain(expectCall) {
64
+ /** @type {string[]} */
65
+ const names = [];
66
+ /** @type {ts.Expression} */
67
+ let current = expectCall;
68
+ while (
69
+ ts.isPropertyAccessExpression(current.parent) &&
70
+ current.parent.expression === current
71
+ ) {
72
+ names.push(current.parent.name.text);
73
+ current = current.parent;
74
+ }
75
+ const call =
76
+ ts.isCallExpression(current.parent) &&
77
+ current.parent.expression === current &&
78
+ names.length > 0
79
+ ? current.parent
80
+ : undefined;
81
+ const negated = names.length === 2 && names[0] === "not";
82
+ const plain = names.length === 1;
83
+ return {
84
+ site: call ?? current,
85
+ subject: expectCall.arguments[0],
86
+ negated,
87
+ matcher: call && (plain || negated) ? names.at(-1) : undefined,
88
+ args: call ? call.arguments : [],
89
+ };
90
+ }
91
+
92
+ /**
93
+ * Whether an expression is the literal `true` or `false`.
94
+ * @param {ts.Expression | undefined} node - The `toBe` argument.
95
+ * @returns {boolean | undefined} The literal's value, or undefined.
96
+ */
97
+ export function booleanLiteral(node) {
98
+ if (node?.kind === ts.SyntaxKind.TrueKeyword) return true;
99
+ if (node?.kind === ts.SyntaxKind.FalseKeyword) return false;
100
+ return undefined;
101
+ }
102
+
103
+ /**
104
+ * Whether an expression is a `<x>.includes(<y>)` call.
105
+ * @param {ts.Expression | undefined} node - The `expect` subject.
106
+ * @returns {node is ts.CallExpression & { expression: ts.PropertyAccessExpression }} True for an `.includes(...)` call with one argument.
107
+ */
108
+ export function isIncludesCall(node) {
109
+ return (
110
+ node !== undefined &&
111
+ ts.isCallExpression(node) &&
112
+ ts.isPropertyAccessExpression(node.expression) &&
113
+ node.expression.name.text === "includes" &&
114
+ node.arguments.length === 1
115
+ );
116
+ }
117
+
118
+ /**
119
+ * Whether one expect chain is a phrase assertion under the issue's rule 3:
120
+ * `toContain` / `toMatch` (optionally negated) with one argument, or
121
+ * `<text>.includes(x)` checked with `toBe(true)` / `toBe(false)`.
122
+ * @param {ReturnType<typeof readExpectChain>} chain - The parsed chain.
123
+ * @returns {boolean} True when the chain is a phrase assertion.
124
+ */
125
+ export function isPhraseChain(chain) {
126
+ if (chain.args.length !== 1 || chain.subject === undefined) return false;
127
+ if (PHRASE_MATCHERS.includes(chain.matcher ?? "")) return true;
128
+ return (
129
+ chain.matcher === "toBe" &&
130
+ booleanLiteral(chain.args[0]) !== undefined &&
131
+ isIncludesCall(chain.subject)
132
+ );
133
+ }
134
+
135
+ /**
136
+ * Every `expect(...)` chain in a file, in source order.
137
+ * @param {ts.SourceFile} sourceFile - The parsed test file.
138
+ * @returns {ReturnType<typeof readExpectChain>[]} One entry per expect call.
139
+ */
140
+ export function expectChains(sourceFile) {
141
+ /** @type {ReturnType<typeof readExpectChain>[]} */
142
+ const chains = [];
143
+ walk(sourceFile, node => {
144
+ if (isExpectCall(node)) chains.push(readExpectChain(node));
145
+ });
146
+ return chains;
147
+ }