@codyswann/lisa 4.87.12 → 4.87.14

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 (160) hide show
  1. package/all/copy-overwrite/scripts/check-third-party-review-evidence.mjs +40 -12
  2. package/dist/cli/doctor-git-hooks.d.ts +8 -0
  3. package/dist/cli/doctor-git-hooks.d.ts.map +1 -0
  4. package/dist/cli/doctor-git-hooks.js +49 -0
  5. package/dist/cli/doctor-git-hooks.js.map +1 -0
  6. package/dist/cli/doctor-project-type.d.ts +10 -0
  7. package/dist/cli/doctor-project-type.d.ts.map +1 -1
  8. package/dist/cli/doctor-project-type.js +16 -4
  9. package/dist/cli/doctor-project-type.js.map +1 -1
  10. package/dist/cli/doctor.d.ts.map +1 -1
  11. package/dist/cli/doctor.js +2 -2
  12. package/dist/cli/doctor.js.map +1 -1
  13. package/dist/codex/hooks-installer.d.ts.map +1 -1
  14. package/dist/codex/hooks-installer.js +52 -4
  15. package/dist/codex/hooks-installer.js.map +1 -1
  16. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  17. package/dist/core/lisa-owned-hash-ledger.js +4 -0
  18. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  19. package/dist/core/lisa.d.ts +7 -0
  20. package/dist/core/lisa.d.ts.map +1 -1
  21. package/dist/core/lisa.js +22 -0
  22. package/dist/core/lisa.js.map +1 -1
  23. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  24. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  25. package/dist/core/upstream-evidence-manifest.js +51 -8
  26. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  27. package/dist/health/hook-inspection.d.ts.map +1 -1
  28. package/dist/health/hook-inspection.js +6 -32
  29. package/dist/health/hook-inspection.js.map +1 -1
  30. package/dist/opencode/hooks-installer.d.ts.map +1 -1
  31. package/dist/opencode/hooks-installer.js +2 -0
  32. package/dist/opencode/hooks-installer.js.map +1 -1
  33. package/dist/opencode/plugin-templates/lisa-session-bootstrap.ts +14 -0
  34. package/dist/opencode/plugin-templates/rails-hooks-command.mjs +83 -0
  35. package/dist/opencode/plugin-templates/rails-hooks-inspection.mjs +138 -0
  36. package/dist/opencode/plugin-templates/rails-hooks.mjs +113 -0
  37. package/dist/opencode/support-file-resolver.d.ts.map +1 -1
  38. package/dist/opencode/support-file-resolver.js +3 -0
  39. package/dist/opencode/support-file-resolver.js.map +1 -1
  40. package/package.json +4 -4
  41. package/plugins/lisa/.claude-plugin/plugin.json +6 -1
  42. package/plugins/lisa/.codex-plugin/hooks.json +5 -0
  43. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  44. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  45. package/plugins/lisa/.codex-plugin/skills/lisa-pull-request-review/SKILL.md +18 -3
  46. package/plugins/lisa/hooks/install-rails-hooks.mjs +10 -0
  47. package/plugins/lisa/hooks/install-rails-hooks.sh +10 -0
  48. package/plugins/lisa/hooks/rails-hooks-command.mjs +83 -0
  49. package/plugins/lisa/hooks/rails-hooks-inspection.mjs +138 -0
  50. package/plugins/lisa/hooks/rails-hooks.mjs +113 -0
  51. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  52. package/plugins/lisa/skills/lisa-pull-request-review/SKILL.md +18 -3
  53. package/plugins/lisa-agy/plugin.json +1 -1
  54. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  55. package/plugins/lisa-agy/skills/lisa-pull-request-review/SKILL.md +18 -3
  56. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  59. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  63. package/plugins/lisa-copilot/.claude-plugin/plugin.json +6 -1
  64. package/plugins/lisa-copilot/hooks/install-rails-hooks.mjs +10 -0
  65. package/plugins/lisa-copilot/hooks/install-rails-hooks.sh +10 -0
  66. package/plugins/lisa-copilot/hooks/rails-hooks-command.mjs +83 -0
  67. package/plugins/lisa-copilot/hooks/rails-hooks-inspection.mjs +138 -0
  68. package/plugins/lisa-copilot/hooks/rails-hooks.mjs +113 -0
  69. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  70. package/plugins/lisa-copilot/skills/lisa-pull-request-review/SKILL.md +18 -3
  71. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-cursor/hooks/hooks.json +4 -0
  73. package/plugins/lisa-cursor/hooks/install-rails-hooks.mjs +10 -0
  74. package/plugins/lisa-cursor/hooks/install-rails-hooks.sh +10 -0
  75. package/plugins/lisa-cursor/hooks/rails-hooks-command.mjs +83 -0
  76. package/plugins/lisa-cursor/hooks/rails-hooks-inspection.mjs +138 -0
  77. package/plugins/lisa-cursor/hooks/rails-hooks.mjs +113 -0
  78. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  79. package/plugins/lisa-cursor/skills/lisa-pull-request-review/SKILL.md +18 -3
  80. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  82. package/plugins/lisa-devin/hooks/install-rails-hooks.mjs +10 -0
  83. package/plugins/lisa-devin/hooks/install-rails-hooks.sh +10 -0
  84. package/plugins/lisa-devin/hooks/rails-hooks-command.mjs +83 -0
  85. package/plugins/lisa-devin/hooks/rails-hooks-inspection.mjs +138 -0
  86. package/plugins/lisa-devin/hooks/rails-hooks.mjs +113 -0
  87. package/plugins/lisa-devin/hooks.json +5 -0
  88. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  89. package/plugins/lisa-devin/skills/lisa-pull-request-review/SKILL.md +18 -3
  90. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  92. package/plugins/lisa-expo-agy/plugin.json +1 -1
  93. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  95. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  96. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  97. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  98. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  99. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  100. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  102. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  103. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  104. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  105. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  106. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  107. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  108. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  109. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  110. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  111. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  112. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  113. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  114. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  116. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  117. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  118. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  119. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  120. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  121. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  123. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  124. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  125. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  126. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  127. package/plugins/lisa-rails-agy/plugin.json +1 -1
  128. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  129. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  130. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  131. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  132. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  133. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  134. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  135. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  136. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  137. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  138. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  139. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  140. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  141. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  142. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  143. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  144. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  145. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  146. package/plugins/materialized-artifacts.json +3 -0
  147. package/plugins/src/base/.claude-plugin/plugin.json +5 -0
  148. package/plugins/src/base/hooks/install-rails-hooks.mjs +10 -0
  149. package/plugins/src/base/hooks/install-rails-hooks.sh +10 -0
  150. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  151. package/plugins/src/base/skills/lisa-pull-request-review/SKILL.md +18 -3
  152. package/scripts/build-plugins.sh +12 -0
  153. package/scripts/copy-opencode-plugin-templates.mjs +5 -1
  154. package/scripts/lib/per-agent-hook-filter.mjs +8 -0
  155. package/scripts/lib/rails-hooks-command.mjs +80 -0
  156. package/scripts/lib/rails-hooks-inspection.mjs +135 -0
  157. package/scripts/lib/rails-hooks.d.mts +31 -0
  158. package/scripts/lib/rails-hooks.mjs +110 -0
  159. package/scripts/two-channel-couplings.json +1 -1
  160. package/typescript/create-only/.github/workflows/third-party-review-evidence.yml +2 -0
@@ -0,0 +1,138 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /** Safe read-only inspection at the hooks directory Git actually resolves. */
5
+ import { constants } from "node:fs";
6
+ import { lstat, open, realpath } from "node:fs/promises";
7
+ import path from "node:path";
8
+ import { runHookCommand } from "./rails-hooks-command.mjs";
9
+
10
+ export const RAILS_HOOK_NAMES = Object.freeze([
11
+ "commit-msg",
12
+ "pre-commit",
13
+ "pre-push",
14
+ "prepare-commit-msg",
15
+ ]);
16
+ const MAX_HOOK_BYTES = 512 * 1024;
17
+
18
+ /**
19
+ * Read an executable regular wrapper without following links or special files.
20
+ * @param {string} directory Canonical Git-selected directory.
21
+ * @param {string} name Fixed hook basename.
22
+ * @returns {Promise<boolean>} Whether the wrapper is installed.
23
+ */
24
+ async function validWrapper(directory, name) {
25
+ const file = path.join(directory, name);
26
+ try {
27
+ const before = await lstat(file);
28
+ if (
29
+ !before.isFile() ||
30
+ before.isSymbolicLink() ||
31
+ (before.mode & 0o100) === 0 ||
32
+ before.size > MAX_HOOK_BYTES ||
33
+ !(await realpath(file)).startsWith(`${directory}${path.sep}`)
34
+ )
35
+ return false;
36
+ const handle = await open(
37
+ file,
38
+ constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
39
+ );
40
+ try {
41
+ const opened = await handle.stat();
42
+ if (
43
+ !opened.isFile() ||
44
+ (opened.mode & 0o100) === 0 ||
45
+ opened.dev !== before.dev ||
46
+ opened.ino !== before.ino ||
47
+ opened.size > MAX_HOOK_BYTES
48
+ )
49
+ return false;
50
+ const buffer = Buffer.alloc(opened.size + 1);
51
+ let count = 0;
52
+ while (count < buffer.length) {
53
+ const part = await handle.read(
54
+ buffer,
55
+ count,
56
+ buffer.length - count,
57
+ count
58
+ );
59
+ if (part.bytesRead === 0) break;
60
+ count += part.bytesRead;
61
+ }
62
+ const after = await handle.stat();
63
+ return (
64
+ count <= MAX_HOOK_BYTES &&
65
+ count === opened.size &&
66
+ count === after.size &&
67
+ (after.mode & 0o100) !== 0 &&
68
+ new TextDecoder("utf8", { fatal: true })
69
+ .decode(buffer.subarray(0, count))
70
+ .toLowerCase()
71
+ .includes("lefthook")
72
+ );
73
+ } finally {
74
+ await handle.close();
75
+ }
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Observe actual installed hooks, including a worktree's shared directory.
83
+ * The Git-selected directory is the narrow authority for these four reads;
84
+ * ordinary health project-file confinement is not widened.
85
+ * @param {string} projectRoot Host checkout.
86
+ * @param {{timeoutMs?: number, signal?: AbortSignal, env?: NodeJS.ProcessEnv}} [options] Shared deadline/cancellation.
87
+ * @returns {Promise<{status: "pass"|"fail", drift: string[], directory?: string}>} Installation state.
88
+ */
89
+ export async function inspectRailsHooks(projectRoot, options = {}) {
90
+ const budget = options.timeoutMs ?? 30_000;
91
+ const deadline = Date.now() + budget;
92
+ if (!Number.isFinite(budget) || budget <= 0 || options.signal?.aborted)
93
+ return { status: "fail", drift: ["Git hooks inspection was cancelled"] };
94
+ const result = await runHookCommand(
95
+ "git",
96
+ ["rev-parse", "--git-path", "hooks"],
97
+ {
98
+ ...options,
99
+ cwd: projectRoot,
100
+ timeoutMs: budget,
101
+ capture: true,
102
+ }
103
+ );
104
+ if (
105
+ result.code !== 0 ||
106
+ result.reason !== null ||
107
+ !result.stdout.endsWith("\n") ||
108
+ /[\n\r\0]/.test(result.stdout.slice(0, -1)) ||
109
+ result.stdout.length <= 1
110
+ )
111
+ return { status: "fail", drift: ["Git hooks directory unavailable"] };
112
+ const selected = path.resolve(projectRoot, result.stdout.slice(0, -1));
113
+ let directory;
114
+ try {
115
+ directory = await realpath(selected);
116
+ if (!(await lstat(directory)).isDirectory())
117
+ throw new Error("Not a directory");
118
+ } catch {
119
+ return {
120
+ status: "fail",
121
+ drift: [...RAILS_HOOK_NAMES],
122
+ directory: selected,
123
+ };
124
+ }
125
+ const missing = await Promise.all(
126
+ RAILS_HOOK_NAMES.map(async name =>
127
+ (await validWrapper(directory, name)) ? undefined : name
128
+ )
129
+ );
130
+ const drift = missing.filter(name => name !== undefined);
131
+ if (Date.now() >= deadline || options.signal?.aborted)
132
+ return {
133
+ status: "fail",
134
+ drift: ["Git hooks inspection timed out or was cancelled"],
135
+ directory,
136
+ };
137
+ return { status: drift.length === 0 ? "pass" : "fail", drift, directory };
138
+ }
@@ -0,0 +1,113 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /** One Rails installer shared by startup, apply, doctor and health. */
5
+ import { lstat } from "node:fs/promises";
6
+ import path from "node:path";
7
+ import { inspectRailsHooks } from "./rails-hooks-inspection.mjs";
8
+ import { runHookCommand } from "./rails-hooks-command.mjs";
9
+
10
+ export { inspectRailsHooks } from "./rails-hooks-inspection.mjs";
11
+ export const RAILS_HOOK_INSTALL_COMMAND = "bundle exec lefthook install";
12
+ export const RAILS_HOOK_ENGINE_FILES = Object.freeze([
13
+ "rails-hooks.mjs",
14
+ "rails-hooks-inspection.mjs",
15
+ "rails-hooks-command.mjs",
16
+ ]);
17
+ const DEFAULT_INSTALL_BUDGET_MS = 30_000;
18
+ const CANCELLED_INSTALLATION = "installation timed out or was cancelled";
19
+
20
+ /**
21
+ * Describe a failed install without echoing Bundler output or credentials.
22
+ * @param {string} reason Bounded operator-readable cause.
23
+ * @returns {{status: "failed", detail: string}} Actionable failure.
24
+ */
25
+ function failed(reason) {
26
+ return {
27
+ status: "failed",
28
+ detail: `Rails Git hooks: ${reason}; run ${RAILS_HOOK_INSTALL_COMMAND}.`,
29
+ };
30
+ }
31
+
32
+ /**
33
+ * Install only absent/invalid wrappers through the actual supported manager.
34
+ * No package installation or interactive shell is part of this operation.
35
+ * @param {string} projectRoot Host checkout (startup may pass a subdirectory).
36
+ * @param {{timeoutMs?: number, signal?: AbortSignal, env?: NodeJS.ProcessEnv}} [options] One total bounded operation.
37
+ * @returns {Promise<{status: "not-applicable"|"already-installed"|"installed"|"failed", detail?: string}>} Outcome; callers keep startup/apply nonblocking on failure.
38
+ */
39
+ export async function ensureRailsHooks(projectRoot, options = {}) {
40
+ const budget = options.timeoutMs ?? DEFAULT_INSTALL_BUDGET_MS;
41
+ if (!Number.isFinite(budget) || budget <= 0)
42
+ return failed("invalid installation deadline");
43
+ const deadline = Date.now() + budget;
44
+ const remaining = () => Math.max(1, deadline - Date.now());
45
+ const scope = {
46
+ ...options,
47
+ cwd: projectRoot,
48
+ timeoutMs: remaining(),
49
+ capture: true,
50
+ };
51
+ const top = await runHookCommand(
52
+ "git",
53
+ ["rev-parse", "--show-toplevel"],
54
+ scope
55
+ );
56
+ const validRoot =
57
+ top.code === 0 &&
58
+ top.reason === null &&
59
+ top.stdout.endsWith("\n") &&
60
+ top.stdout.length > 1 &&
61
+ !/[\n\r\0]/.test(top.stdout.slice(0, -1));
62
+ const root = validRoot
63
+ ? path.resolve(projectRoot, top.stdout.slice(0, -1))
64
+ : projectRoot;
65
+ try {
66
+ const configuration = await lstat(path.join(root, "lefthook.yml"));
67
+ if (!configuration.isFile() || configuration.isSymbolicLink())
68
+ return failed("lefthook.yml is not a regular file");
69
+ } catch (error) {
70
+ if (error.code === "ENOENT") return { status: "not-applicable" };
71
+ return failed("lefthook.yml could not be inspected");
72
+ }
73
+ if (!validRoot) return failed("Git checkout could not be read");
74
+ if (Date.now() >= deadline || options.signal?.aborted)
75
+ return failed(CANCELLED_INSTALLATION);
76
+ const before = await inspectRailsHooks(root, {
77
+ ...options,
78
+ timeoutMs: remaining(),
79
+ });
80
+ if (before.status === "pass") return { status: "already-installed" };
81
+ if (before.directory === undefined)
82
+ return failed("Git hooks directory could not be read");
83
+ if (Date.now() >= deadline || options.signal?.aborted)
84
+ return failed(CANCELLED_INSTALLATION);
85
+ const installed = await runHookCommand(
86
+ "bundle",
87
+ ["exec", "lefthook", "install"],
88
+ {
89
+ ...options,
90
+ cwd: root,
91
+ timeoutMs: remaining(),
92
+ }
93
+ );
94
+ if (installed.code !== 0 || installed.reason !== null) {
95
+ if (installed.reason === "ENOENT") return failed("Bundler is unavailable");
96
+ if (["ETIMEDOUT", "ABORT_ERR"].includes(installed.reason))
97
+ return failed(CANCELLED_INSTALLATION);
98
+ const exitDetail =
99
+ installed.code === null ? "" : ` (exit ${installed.code})`;
100
+ return failed(`installation failed${exitDetail}`);
101
+ }
102
+ if (Date.now() >= deadline || options.signal?.aborted)
103
+ return failed(CANCELLED_INSTALLATION);
104
+ const after = await inspectRailsHooks(root, {
105
+ ...options,
106
+ timeoutMs: remaining(),
107
+ });
108
+ return after.status === "pass"
109
+ ? { status: "installed" }
110
+ : failed(
111
+ `installation left missing or invalid hooks: ${after.drift.join(", ")}`
112
+ );
113
+ }
@@ -1004,10 +1004,22 @@ verdict. Take the verdict from it, not from your own reading of the payloads
1004
1004
  above:
1005
1005
 
1006
1006
  ```bash
1007
- node scripts/check-third-party-review-evidence.mjs --sha <head-sha> --json
1007
+ node scripts/check-third-party-review-evidence.mjs --sha <head-sha> --repo <owner>/<repo> --json
1008
1008
  ```
1009
1009
 
1010
- Three cases, and each is handled differently:
1010
+ Pass the owning PR's repository explicitly in local checkouts. Without
1011
+ `--repo` or a valid `GITHUB_REPOSITORY`, the prover exits with a usage error
1012
+ before reading GitHub; this is not a review verdict.
1013
+
1014
+ **First, stop on `pull-requests-unreadable`.** The PR discovery read failed,
1015
+ so the head's review status is **unknown**. `readings: []` in this outcome is
1016
+ not a reviewer saying it did no work. Report the failed pull-request read and
1017
+ stop under `tool-access-gate`, keeping the PR open and every check enabled.
1018
+ Do not post a reviewer-specific substitute or make a merge decision from this
1019
+ outcome. Restore the configured GitHub read access before rerunning the prover;
1020
+ this instruction adds no automatic retry loop.
1021
+
1022
+ For the remaining outcomes, three cases are handled differently:
1011
1023
 
1012
1024
  1. **`satisfied`** — every configured reviewer showed its reviewed-when
1013
1025
  evidence: a status whose description is the phrase, or a check run that
@@ -1017,7 +1029,8 @@ Three cases, and each is handled differently:
1017
1029
  state, **not** a pass: say so explicitly in the report ("no third-party
1018
1030
  reviewer configured; nothing read this diff on that path"), and do not
1019
1031
  invent a substitute for a reviewer the project never asked for.
1020
- 3. **anything else** — throttled, skipped, absent, empty, unreadable, a check
1032
+ 3. **anything else** — throttled, skipped, absent, empty, unreadable reviewer
1033
+ evidence after successful PR discovery, a check
1021
1034
  run that did not succeed, or words in no configured list. **Treat every one
1022
1035
  of these as NOT REVIEWED.** The allowlist is the only thing that grants
1023
1036
  credit; a denylist of known-bad phrases fails open, and the vocabulary is
@@ -64,10 +64,21 @@ can also report through a **check run** instead, and then this command cannot
64
64
  tell you anything: the description column is empty for a check run, which
65
65
  reads `SUCCESS` when it reviewed and `NEUTRAL` — still passing a required
66
66
  check — when it was throttled. The run's result is the first line of its
67
- summary, so use `node scripts/check-third-party-review-evidence.mjs --sha <head-sha> --json`,
67
+ summary, so use `node scripts/check-third-party-review-evidence.mjs --sha <head-sha> --repo <owner>/<repo> --json`,
68
68
  which reads both representations. Never read `gh pr view --json statusCheckRollup`
69
69
  for this: it returns a commit status *without* its description.
70
70
 
71
+ Use the owning PR's repository. A missing or invalid repository is a usage
72
+ error before any GitHub read; it establishes no review verdict.
73
+
74
+ **Stop on `pull-requests-unreadable`: review status is unknown.** Report
75
+ `unknown — PR discovery unreadable (<reason>)` and stop under
76
+ `tool-access-gate`, keeping the PR open and every check enabled. Do not report
77
+ `reviewed` or `NOT REVIEWED`, post a reviewer-specific substitute, or make a
78
+ merge decision from this outcome. Restore the configured GitHub read access
79
+ before rerunning the prover; this adds no automatic retry loop. Return the
80
+ unknown report before continuing to Steps 2–4.
81
+
71
82
  Where the project ships Lisa's guard, prefer its machine-readable form, which
72
83
  also says whether the check is ruleset-required (so whether branch protection
73
84
  recorded a satisfied review gate for a review that did not happen):
@@ -91,6 +102,7 @@ Carry the finding into your Step 4 report. **Do not write "no unresolved review
91
102
  threads" on its own** — it is true of an unreviewed PR too. Say which you
92
103
  observed:
93
104
 
105
+ - `unknown — PR discovery unreadable (the open pull requests could not be read); review verdict deferred until access is restored`
94
106
  - `reviewed — CodeRabbit "Review approved", 0 unresolved threads`
95
107
  - `NOT REVIEWED — CodeRabbit success but "Review rate limited" (vacuous); 0 threads means nobody looked`
96
108
  - `NOT REVIEWED — no review check reported on this PR at all`
@@ -132,8 +144,11 @@ owns those.
132
144
 
133
145
  **Open the report with the Step 1b verdict, before the thread counts.** A thread
134
146
  summary describes what was done about review findings; it says nothing about
135
- whether a review produced any. State `reviewed` or `NOT REVIEWED (<why>)` first,
136
- then the counts. A caller that records "reviews addressed" in evidence must
147
+ whether a review produced any. State `reviewed` or `NOT REVIEWED (<why>)` first
148
+ when discovery succeeded, then the counts. Failed discovery returns the
149
+ `unknown — PR discovery unreadable (<reason>)` report in Step 1b instead;
150
+ never turn an unknown read into a reviewer doing no work.
151
+ A caller that records "reviews addressed" in evidence must
137
152
  carry that verdict through verbatim — a PR whose only review check was vacuous
138
153
  has not been reviewed, no matter how clean its thread list is.
139
154
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.87.12",
3
+ "version": "4.87.14",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.87.12",
3
+ "version": "4.87.14",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -0,0 +1,10 @@
1
+ /** Nonblocking startup adapter; the engine also serves apply/doctor/health. */
2
+ try {
3
+ const { ensureRailsHooks } = await import("./rails-hooks.mjs");
4
+ const result = await ensureRailsHooks(process.cwd());
5
+ if (result.status === "failed") process.stderr.write(`${result.detail}\n`);
6
+ } catch {
7
+ process.stderr.write(
8
+ "Rails Git hooks could not be installed; run bundle exec lefthook install.\n"
9
+ );
10
+ }
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # Install Rails Git wrappers in non-interactive agent sessions.
3
+ cat >/dev/null
4
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ if ! command -v node >/dev/null 2>&1; then
6
+ printf '%s\n' 'Rails Git hooks: Node.js is unavailable; run bundle exec lefthook install.' >&2
7
+ exit 0
8
+ fi
9
+ node "$HOOK_DIR/install-rails-hooks.mjs"
10
+ exit 0
@@ -0,0 +1,83 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /** Bounded local Git/Bundler children used by Rails hook installation. */
5
+ import { spawn } from "node:child_process";
6
+
7
+ const REPOSITORY_ENVIRONMENT = new Set([
8
+ "GIT_DIR",
9
+ "GIT_COMMON_DIR",
10
+ "GIT_WORK_TREE",
11
+ "GIT_INDEX_FILE",
12
+ "GIT_PREFIX",
13
+ ]);
14
+ const MAX_OUTPUT_BYTES = 16 * 1024;
15
+
16
+ /**
17
+ * Execute one fixed local tool, killing its owned process group at the deadline.
18
+ * @param {string} command Tool selected by the caller, never a shell expression.
19
+ * @param {string[]} args Literal arguments.
20
+ * @param {{cwd: string, timeoutMs: number, signal?: AbortSignal, env?: NodeJS.ProcessEnv, capture?: boolean}} options Execution scope.
21
+ * @returns {Promise<{code: number|null, reason: string|null, stdout: string}>} Actual child outcome.
22
+ */
23
+ export function runHookCommand(command, args, options) {
24
+ if (options.signal?.aborted)
25
+ return Promise.resolve({ code: null, reason: "ABORT_ERR", stdout: "" });
26
+ return new Promise(resolve => {
27
+ const env = Object.fromEntries(
28
+ Object.entries(options.env ?? process.env).filter(
29
+ ([name]) => !REPOSITORY_ENVIRONMENT.has(name)
30
+ )
31
+ );
32
+ const budget = Math.max(1, Math.floor(options.timeoutMs));
33
+ const grouped = process.platform !== "win32";
34
+ const child = spawn(command, args, {
35
+ cwd: options.cwd,
36
+ env,
37
+ detached: grouped,
38
+ stdio: ["ignore", options.capture ? "pipe" : "ignore", "ignore"],
39
+ // The owned timer kills the whole POSIX group first. Node's immediate-
40
+ // child timeout is a second bounded backstop, not the cleanup mechanism.
41
+ timeout: budget + 1_000,
42
+ killSignal: "SIGKILL",
43
+ windowsHide: true,
44
+ });
45
+ let finished = false;
46
+ let reason = null;
47
+ let bytes = 0;
48
+ const chunks = [];
49
+ const stop = failure => {
50
+ if (finished) return;
51
+ reason ??= failure;
52
+ try {
53
+ if (grouped && child.pid) process.kill(-child.pid, "SIGKILL");
54
+ else child.kill("SIGKILL");
55
+ } catch {
56
+ // A group that has already exited needs no further signal.
57
+ child.kill("SIGKILL");
58
+ }
59
+ };
60
+ const timer = setTimeout(() => stop("ETIMEDOUT"), budget);
61
+ const abort = () => stop("ABORT_ERR");
62
+ const complete = (code, failure) => {
63
+ if (finished) return;
64
+ finished = true;
65
+ clearTimeout(timer);
66
+ options.signal?.removeEventListener("abort", abort);
67
+ resolve({
68
+ code,
69
+ reason: reason ?? failure,
70
+ stdout: Buffer.concat(chunks).toString("utf8"),
71
+ });
72
+ };
73
+ child.stdout?.on("data", chunk => {
74
+ bytes += chunk.length;
75
+ if (bytes > MAX_OUTPUT_BYTES) stop("OUTPUT_LIMIT");
76
+ else chunks.push(chunk);
77
+ });
78
+ child.once("error", error => complete(null, error.code ?? "SPAWN_FAILED"));
79
+ child.once("close", (code, signal) => complete(code, signal));
80
+ options.signal?.addEventListener("abort", abort, { once: true });
81
+ if (options.signal?.aborted) abort();
82
+ });
83
+ }
@@ -0,0 +1,138 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /** Safe read-only inspection at the hooks directory Git actually resolves. */
5
+ import { constants } from "node:fs";
6
+ import { lstat, open, realpath } from "node:fs/promises";
7
+ import path from "node:path";
8
+ import { runHookCommand } from "./rails-hooks-command.mjs";
9
+
10
+ export const RAILS_HOOK_NAMES = Object.freeze([
11
+ "commit-msg",
12
+ "pre-commit",
13
+ "pre-push",
14
+ "prepare-commit-msg",
15
+ ]);
16
+ const MAX_HOOK_BYTES = 512 * 1024;
17
+
18
+ /**
19
+ * Read an executable regular wrapper without following links or special files.
20
+ * @param {string} directory Canonical Git-selected directory.
21
+ * @param {string} name Fixed hook basename.
22
+ * @returns {Promise<boolean>} Whether the wrapper is installed.
23
+ */
24
+ async function validWrapper(directory, name) {
25
+ const file = path.join(directory, name);
26
+ try {
27
+ const before = await lstat(file);
28
+ if (
29
+ !before.isFile() ||
30
+ before.isSymbolicLink() ||
31
+ (before.mode & 0o100) === 0 ||
32
+ before.size > MAX_HOOK_BYTES ||
33
+ !(await realpath(file)).startsWith(`${directory}${path.sep}`)
34
+ )
35
+ return false;
36
+ const handle = await open(
37
+ file,
38
+ constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
39
+ );
40
+ try {
41
+ const opened = await handle.stat();
42
+ if (
43
+ !opened.isFile() ||
44
+ (opened.mode & 0o100) === 0 ||
45
+ opened.dev !== before.dev ||
46
+ opened.ino !== before.ino ||
47
+ opened.size > MAX_HOOK_BYTES
48
+ )
49
+ return false;
50
+ const buffer = Buffer.alloc(opened.size + 1);
51
+ let count = 0;
52
+ while (count < buffer.length) {
53
+ const part = await handle.read(
54
+ buffer,
55
+ count,
56
+ buffer.length - count,
57
+ count
58
+ );
59
+ if (part.bytesRead === 0) break;
60
+ count += part.bytesRead;
61
+ }
62
+ const after = await handle.stat();
63
+ return (
64
+ count <= MAX_HOOK_BYTES &&
65
+ count === opened.size &&
66
+ count === after.size &&
67
+ (after.mode & 0o100) !== 0 &&
68
+ new TextDecoder("utf8", { fatal: true })
69
+ .decode(buffer.subarray(0, count))
70
+ .toLowerCase()
71
+ .includes("lefthook")
72
+ );
73
+ } finally {
74
+ await handle.close();
75
+ }
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Observe actual installed hooks, including a worktree's shared directory.
83
+ * The Git-selected directory is the narrow authority for these four reads;
84
+ * ordinary health project-file confinement is not widened.
85
+ * @param {string} projectRoot Host checkout.
86
+ * @param {{timeoutMs?: number, signal?: AbortSignal, env?: NodeJS.ProcessEnv}} [options] Shared deadline/cancellation.
87
+ * @returns {Promise<{status: "pass"|"fail", drift: string[], directory?: string}>} Installation state.
88
+ */
89
+ export async function inspectRailsHooks(projectRoot, options = {}) {
90
+ const budget = options.timeoutMs ?? 30_000;
91
+ const deadline = Date.now() + budget;
92
+ if (!Number.isFinite(budget) || budget <= 0 || options.signal?.aborted)
93
+ return { status: "fail", drift: ["Git hooks inspection was cancelled"] };
94
+ const result = await runHookCommand(
95
+ "git",
96
+ ["rev-parse", "--git-path", "hooks"],
97
+ {
98
+ ...options,
99
+ cwd: projectRoot,
100
+ timeoutMs: budget,
101
+ capture: true,
102
+ }
103
+ );
104
+ if (
105
+ result.code !== 0 ||
106
+ result.reason !== null ||
107
+ !result.stdout.endsWith("\n") ||
108
+ /[\n\r\0]/.test(result.stdout.slice(0, -1)) ||
109
+ result.stdout.length <= 1
110
+ )
111
+ return { status: "fail", drift: ["Git hooks directory unavailable"] };
112
+ const selected = path.resolve(projectRoot, result.stdout.slice(0, -1));
113
+ let directory;
114
+ try {
115
+ directory = await realpath(selected);
116
+ if (!(await lstat(directory)).isDirectory())
117
+ throw new Error("Not a directory");
118
+ } catch {
119
+ return {
120
+ status: "fail",
121
+ drift: [...RAILS_HOOK_NAMES],
122
+ directory: selected,
123
+ };
124
+ }
125
+ const missing = await Promise.all(
126
+ RAILS_HOOK_NAMES.map(async name =>
127
+ (await validWrapper(directory, name)) ? undefined : name
128
+ )
129
+ );
130
+ const drift = missing.filter(name => name !== undefined);
131
+ if (Date.now() >= deadline || options.signal?.aborted)
132
+ return {
133
+ status: "fail",
134
+ drift: ["Git hooks inspection timed out or was cancelled"],
135
+ directory,
136
+ };
137
+ return { status: drift.length === 0 ? "pass" : "fail", drift, directory };
138
+ }