@codyswann/lisa 3.47.1 → 3.47.3

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 (73) hide show
  1. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  2. package/dist/core/lisa-owned-hash-ledger.js +2 -0
  3. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  4. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  5. package/dist/core/upstream-evidence-manifest.js +10 -9
  6. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  7. package/package.json +1 -1
  8. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  9. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  10. package/plugins/lisa/hooks/threshold-ratchet-compare.mjs +41 -2
  11. package/plugins/lisa/scripts/install-remote-agent-aws.mjs +33 -1
  12. package/plugins/lisa-agy/plugin.json +1 -1
  13. package/plugins/lisa-agy/scripts/install-remote-agent-aws.mjs +33 -1
  14. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  15. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  16. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  17. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  19. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-copilot/hooks/threshold-ratchet-compare.mjs +41 -2
  21. package/plugins/lisa-copilot/scripts/install-remote-agent-aws.mjs +33 -1
  22. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  23. package/plugins/lisa-cursor/hooks/threshold-ratchet-compare.mjs +41 -2
  24. package/plugins/lisa-cursor/scripts/install-remote-agent-aws.mjs +33 -1
  25. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  27. package/plugins/lisa-expo-agy/plugin.json +1 -1
  28. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  32. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  33. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  37. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  38. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  42. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  43. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  47. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  48. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  52. package/plugins/lisa-rails-agy/plugin.json +1 -1
  53. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  57. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  58. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  62. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  63. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  65. package/plugins/src/base/hooks/threshold-ratchet-compare.mjs +41 -2
  66. package/plugins/src/base/scripts/install-remote-agent-aws.mjs +33 -1
  67. package/rails/copy-overwrite/scripts/threshold-ratchet-compare.mjs +41 -2
  68. package/scripts/check-derived-artifacts.mjs +3 -2
  69. package/scripts/check-duplicate-versions.mjs +3 -1
  70. package/scripts/check-required-check-promotions.mjs +3 -2
  71. package/scripts/generate-codex-plugin-artifacts.mjs +3 -4
  72. package/scripts/materialize-copy-overwrite.mjs +3 -2
  73. package/typescript/copy-overwrite/scripts/threshold-ratchet-compare.mjs +41 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, across Claude and Codex.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Ruby on Rails-specific skills and hooks for RuboCop and ast-grep scanning on edit.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
4
4
  "description": "TypeScript-specific hooks for formatting, linting, and ast-grep scanning on edit.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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": "3.47.1",
3
+ "version": "3.47.3",
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"
@@ -28,7 +28,7 @@ const KIND_ALLOW_LIST = "allow-list";
28
28
  * @typedef {object} Finding
29
29
  * @property {string} file Repo-relative path of the gate file
30
30
  * @property {string} key Dotted key path within the file
31
- * @property {"weakened"|"removed"|"exemption-added"|"file-deleted"|"allow-added"|"unparseable"} type
31
+ * @property {"weakened"|"removed"|"exemption-added"|"file-deleted"|"allow-added"|"unparseable"|"unparseable-baseline"} type
32
32
  * Which ratchet rule the change violated
33
33
  * @property {number|string} [base] Baseline value
34
34
  * @property {number|string} [current] Current value
@@ -49,6 +49,25 @@ function unparseable(relPath) {
49
49
  };
50
50
  }
51
51
 
52
+ /**
53
+ * Build the "baseline could not be parsed" finding.
54
+ *
55
+ * Separate from `unparseable` because the two send an operator to different
56
+ * files. Told only that `vitest.thresholds.json` is not valid JSON, they open
57
+ * the current file, find it well-formed, and conclude the gate is broken; the
58
+ * defect is at the base ref.
59
+ * @param {string} relPath Repo-relative path
60
+ * @returns {Finding} The unparseable-baseline finding
61
+ */
62
+ function unparseableBaseline(relPath) {
63
+ return {
64
+ file: relPath,
65
+ key: "*",
66
+ type: "unparseable-baseline",
67
+ message: `${relPath} is not valid JSON in the baseline — with no baseline to compare against, the ratchet cannot see a loosening in this file and will not see one in any later change either, until the baseline is repaired. A UTF-8 BOM, a trailing comma or an empty file all land here.`,
68
+ };
69
+ }
70
+
52
71
  /**
53
72
  * Compare two constraint maps: report removals and direction violations.
54
73
  * @param {string} relPath Repo-relative path the constraints came from
@@ -242,7 +261,27 @@ export function compareFile(relPath, baselineText, currentText) {
242
261
 
243
262
  const base = parseJson(baselineText);
244
263
  const current = parseJson(currentText);
245
- if (base === undefined) return [];
264
+ // Both sides are reported, and both used to not be. An unparseable baseline
265
+ // returned no findings at all, which did not merely miss one change: once a
266
+ // malformed threshold file is on the base branch, every later pull request
267
+ // compares against a baseline that yields no constraints, so the ratchet
268
+ // stops having an opinion about that file — permanently, and in silence.
269
+ //
270
+ // This is only reached for a file that EXISTS at the baseline and did not
271
+ // parse. A file absent from the base ref arrives as a null `baselineText`
272
+ // and returned above: new gate files have nothing to weaken, and the caller
273
+ // separates absent from present-but-unreadable with `cat-file -e` before
274
+ // calling.
275
+ //
276
+ // The allow-list carve-out is symmetric with the current side and holds for
277
+ // the same reason: an allow list nobody can read grants no exceptions, so an
278
+ // unreadable one on either side already fails closed. Reporting it would
279
+ // block every change touching the file without making anything safer.
280
+ if (base === undefined) {
281
+ return family.kind === KIND_ALLOW_LIST
282
+ ? []
283
+ : [unparseableBaseline(relPath)];
284
+ }
246
285
  if (current === undefined) {
247
286
  return family.kind === KIND_ALLOW_LIST ? [] : [unparseable(relPath)];
248
287
  }
@@ -11,11 +11,43 @@ import {
11
11
  existsSync,
12
12
  mkdirSync,
13
13
  readFileSync,
14
+ realpathSync,
14
15
  writeFileSync,
15
16
  } from "node:fs";
16
17
  import path from "node:path";
17
18
  import { fileURLToPath } from "node:url";
18
19
 
20
+ /**
21
+ * True when `moduleUrl` names the module node was asked to run.
22
+ *
23
+ * The obvious spelling — comparing `import.meta.url` against a raw
24
+ * `process.argv[1]` — is false whenever the script is reached through a
25
+ * symlinked path: a symlinked checkout, a bin shim, a git worktree, or `/tmp`
26
+ * on macOS, which is itself a symlink to `/private/tmp`. `main()` then never
27
+ * runs and the process exits 0 having done nothing. That is what this module
28
+ * used to do, and an installer that silently installs nothing reports success
29
+ * while leaving the host unconfigured.
30
+ *
31
+ * Both sides are realpath'd, not just `argv[1]`: `import.meta.url` is the real
32
+ * path by default and the symlinked one under `--preserve-symlinks-main`, so
33
+ * normalizing one side reopens the same hole on that flag.
34
+ *
35
+ * Written out rather than imported: this is a plugin payload, which has no
36
+ * `./lib/` to resolve against. Same rule and same reasoning as
37
+ * `scripts/lib/invoked-as-script.mjs`.
38
+ * @param {string} moduleUrl - The caller's own `import.meta.url`.
39
+ * @param {string | undefined} [argv1] - Entry path; defaults to `process.argv[1]`.
40
+ * @returns {boolean} Whether the caller should run its CLI body.
41
+ */
42
+ export function invokedAsScript(moduleUrl, argv1 = process.argv[1]) {
43
+ if (!argv1) return false;
44
+ try {
45
+ return realpathSync(argv1) === realpathSync(fileURLToPath(moduleUrl));
46
+ } catch {
47
+ return false;
48
+ }
49
+ }
50
+
19
51
  const SCRIPT_NAME = "remote-agent-aws-setup.sh";
20
52
  const INSTALL_COMMAND = `bash scripts/${SCRIPT_NAME}`;
21
53
  const VALID_PLATFORMS = new Set([
@@ -333,7 +365,7 @@ export function installRemoteAgentAws(arguments_ = process.argv.slice(2)) {
333
365
  return { project, platform, secretName, written };
334
366
  }
335
367
 
336
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
368
+ if (invokedAsScript(import.meta.url)) {
337
369
  try {
338
370
  process.stdout.write(
339
371
  `${JSON.stringify(installRemoteAgentAws(), null, 2)}\n`
@@ -31,7 +31,7 @@ const KIND_ALLOW_LIST = "allow-list";
31
31
  * @typedef {object} Finding
32
32
  * @property {string} file Repo-relative path of the gate file
33
33
  * @property {string} key Dotted key path within the file
34
- * @property {"weakened"|"removed"|"exemption-added"|"file-deleted"|"allow-added"|"unparseable"} type
34
+ * @property {"weakened"|"removed"|"exemption-added"|"file-deleted"|"allow-added"|"unparseable"|"unparseable-baseline"} type
35
35
  * Which ratchet rule the change violated
36
36
  * @property {number|string} [base] Baseline value
37
37
  * @property {number|string} [current] Current value
@@ -52,6 +52,25 @@ function unparseable(relPath) {
52
52
  };
53
53
  }
54
54
 
55
+ /**
56
+ * Build the "baseline could not be parsed" finding.
57
+ *
58
+ * Separate from `unparseable` because the two send an operator to different
59
+ * files. Told only that `vitest.thresholds.json` is not valid JSON, they open
60
+ * the current file, find it well-formed, and conclude the gate is broken; the
61
+ * defect is at the base ref.
62
+ * @param {string} relPath Repo-relative path
63
+ * @returns {Finding} The unparseable-baseline finding
64
+ */
65
+ function unparseableBaseline(relPath) {
66
+ return {
67
+ file: relPath,
68
+ key: "*",
69
+ type: "unparseable-baseline",
70
+ message: `${relPath} is not valid JSON in the baseline — with no baseline to compare against, the ratchet cannot see a loosening in this file and will not see one in any later change either, until the baseline is repaired. A UTF-8 BOM, a trailing comma or an empty file all land here.`,
71
+ };
72
+ }
73
+
55
74
  /**
56
75
  * Compare two constraint maps: report removals and direction violations.
57
76
  * @param {string} relPath Repo-relative path the constraints came from
@@ -245,7 +264,27 @@ export function compareFile(relPath, baselineText, currentText) {
245
264
 
246
265
  const base = parseJson(baselineText);
247
266
  const current = parseJson(currentText);
248
- if (base === undefined) return [];
267
+ // Both sides are reported, and both used to not be. An unparseable baseline
268
+ // returned no findings at all, which did not merely miss one change: once a
269
+ // malformed threshold file is on the base branch, every later pull request
270
+ // compares against a baseline that yields no constraints, so the ratchet
271
+ // stops having an opinion about that file — permanently, and in silence.
272
+ //
273
+ // This is only reached for a file that EXISTS at the baseline and did not
274
+ // parse. A file absent from the base ref arrives as a null `baselineText`
275
+ // and returned above: new gate files have nothing to weaken, and the caller
276
+ // separates absent from present-but-unreadable with `cat-file -e` before
277
+ // calling.
278
+ //
279
+ // The allow-list carve-out is symmetric with the current side and holds for
280
+ // the same reason: an allow list nobody can read grants no exceptions, so an
281
+ // unreadable one on either side already fails closed. Reporting it would
282
+ // block every change touching the file without making anything safer.
283
+ if (base === undefined) {
284
+ return family.kind === KIND_ALLOW_LIST
285
+ ? []
286
+ : [unparseableBaseline(relPath)];
287
+ }
249
288
  if (current === undefined) {
250
289
  return family.kind === KIND_ALLOW_LIST ? [] : [unparseable(relPath)];
251
290
  }
@@ -41,7 +41,8 @@
41
41
  import { execFileSync } from "node:child_process";
42
42
  import path from "node:path";
43
43
  import process from "node:process";
44
- import { fileURLToPath } from "node:url";
44
+
45
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
45
46
 
46
47
  const repoRoot = path.resolve(import.meta.dirname, "..");
47
48
 
@@ -232,6 +233,6 @@ function main() {
232
233
  process.exit(1);
233
234
  }
234
235
 
235
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
236
+ if (invokedAsScript(import.meta.url)) {
236
237
  main();
237
238
  }
@@ -93,6 +93,8 @@ import path from "node:path";
93
93
  import process from "node:process";
94
94
  import { fileURLToPath } from "node:url";
95
95
 
96
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
97
+
96
98
  const REPO_ROOT = path.resolve(
97
99
  path.dirname(fileURLToPath(import.meta.url)),
98
100
  ".."
@@ -710,6 +712,6 @@ function main() {
710
712
  if (options.strict && violations > 0) process.exitCode = 1;
711
713
  }
712
714
 
713
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
715
+ if (invokedAsScript(import.meta.url)) {
714
716
  main();
715
717
  }
@@ -137,9 +137,10 @@
137
137
  */
138
138
  import fs from "node:fs";
139
139
  import path from "node:path";
140
- import { fileURLToPath } from "node:url";
141
140
  import yaml from "js-yaml";
142
141
 
142
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
143
+
143
144
  // Literals named once — each was repeated enough times that a typo in one
144
145
  // copy would diverge silently.
145
146
  const HEADROOM_EVIDENCE_MISSING = "headroom-evidence-missing";
@@ -775,6 +776,6 @@ function main() {
775
776
  if (result.violations.length > 0) process.exitCode = 1;
776
777
  }
777
778
 
778
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
779
+ if (invokedAsScript(import.meta.url)) {
779
780
  main();
780
781
  }
@@ -38,6 +38,8 @@ import fs from "node:fs";
38
38
  import path from "node:path";
39
39
  import { fileURLToPath } from "node:url";
40
40
 
41
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
42
+
41
43
  // Literals named once — each was repeated enough times that a typo in one
42
44
  // copy would diverge silently.
43
45
  const CODEX_PLUGIN_DIR = ".codex-plugin";
@@ -1115,9 +1117,6 @@ function metadataFor(pluginName, claudeManifest) {
1115
1117
 
1116
1118
  // Run the generator only when invoked directly (e.g. via build-plugins.sh),
1117
1119
  // not when this module is imported (e.g. by unit tests for the parser).
1118
- if (
1119
- process.argv[1] &&
1120
- fileURLToPath(import.meta.url) === fs.realpathSync(process.argv[1])
1121
- ) {
1120
+ if (invokedAsScript(import.meta.url)) {
1122
1121
  main();
1123
1122
  }
@@ -25,7 +25,8 @@
25
25
  */
26
26
  import { readFileSync, writeFileSync } from "node:fs";
27
27
  import path from "node:path";
28
- import { fileURLToPath } from "node:url";
28
+
29
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
29
30
 
30
31
  /**
31
32
  * The `copy-overwrite` ownership contract, verbatim from the header #2545
@@ -151,7 +152,7 @@ export const materialize = (source, destination) => {
151
152
  );
152
153
  };
153
154
 
154
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
155
+ if (invokedAsScript(import.meta.url)) {
155
156
  const [source, destination] = process.argv.slice(2);
156
157
  if (!source || !destination) {
157
158
  console.error(
@@ -31,7 +31,7 @@ const KIND_ALLOW_LIST = "allow-list";
31
31
  * @typedef {object} Finding
32
32
  * @property {string} file Repo-relative path of the gate file
33
33
  * @property {string} key Dotted key path within the file
34
- * @property {"weakened"|"removed"|"exemption-added"|"file-deleted"|"allow-added"|"unparseable"} type
34
+ * @property {"weakened"|"removed"|"exemption-added"|"file-deleted"|"allow-added"|"unparseable"|"unparseable-baseline"} type
35
35
  * Which ratchet rule the change violated
36
36
  * @property {number|string} [base] Baseline value
37
37
  * @property {number|string} [current] Current value
@@ -52,6 +52,25 @@ function unparseable(relPath) {
52
52
  };
53
53
  }
54
54
 
55
+ /**
56
+ * Build the "baseline could not be parsed" finding.
57
+ *
58
+ * Separate from `unparseable` because the two send an operator to different
59
+ * files. Told only that `vitest.thresholds.json` is not valid JSON, they open
60
+ * the current file, find it well-formed, and conclude the gate is broken; the
61
+ * defect is at the base ref.
62
+ * @param {string} relPath Repo-relative path
63
+ * @returns {Finding} The unparseable-baseline finding
64
+ */
65
+ function unparseableBaseline(relPath) {
66
+ return {
67
+ file: relPath,
68
+ key: "*",
69
+ type: "unparseable-baseline",
70
+ message: `${relPath} is not valid JSON in the baseline — with no baseline to compare against, the ratchet cannot see a loosening in this file and will not see one in any later change either, until the baseline is repaired. A UTF-8 BOM, a trailing comma or an empty file all land here.`,
71
+ };
72
+ }
73
+
55
74
  /**
56
75
  * Compare two constraint maps: report removals and direction violations.
57
76
  * @param {string} relPath Repo-relative path the constraints came from
@@ -245,7 +264,27 @@ export function compareFile(relPath, baselineText, currentText) {
245
264
 
246
265
  const base = parseJson(baselineText);
247
266
  const current = parseJson(currentText);
248
- if (base === undefined) return [];
267
+ // Both sides are reported, and both used to not be. An unparseable baseline
268
+ // returned no findings at all, which did not merely miss one change: once a
269
+ // malformed threshold file is on the base branch, every later pull request
270
+ // compares against a baseline that yields no constraints, so the ratchet
271
+ // stops having an opinion about that file — permanently, and in silence.
272
+ //
273
+ // This is only reached for a file that EXISTS at the baseline and did not
274
+ // parse. A file absent from the base ref arrives as a null `baselineText`
275
+ // and returned above: new gate files have nothing to weaken, and the caller
276
+ // separates absent from present-but-unreadable with `cat-file -e` before
277
+ // calling.
278
+ //
279
+ // The allow-list carve-out is symmetric with the current side and holds for
280
+ // the same reason: an allow list nobody can read grants no exceptions, so an
281
+ // unreadable one on either side already fails closed. Reporting it would
282
+ // block every change touching the file without making anything safer.
283
+ if (base === undefined) {
284
+ return family.kind === KIND_ALLOW_LIST
285
+ ? []
286
+ : [unparseableBaseline(relPath)];
287
+ }
249
288
  if (current === undefined) {
250
289
  return family.kind === KIND_ALLOW_LIST ? [] : [unparseable(relPath)];
251
290
  }