@codyswann/lisa 4.106.0 → 4.106.2

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 (153) hide show
  1. package/dist/core/lisa.d.ts +21 -0
  2. package/dist/core/lisa.d.ts.map +1 -1
  3. package/dist/core/lisa.js +48 -0
  4. package/dist/core/lisa.js.map +1 -1
  5. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  6. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  7. package/dist/core/upstream-evidence-manifest.js +36 -11
  8. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  9. package/dist/sonar/sonar-shim-fs.d.ts +32 -0
  10. package/dist/sonar/sonar-shim-fs.d.ts.map +1 -0
  11. package/dist/sonar/sonar-shim-fs.js +70 -0
  12. package/dist/sonar/sonar-shim-fs.js.map +1 -0
  13. package/dist/sonar/sonar-shim-repoint.d.ts +71 -0
  14. package/dist/sonar/sonar-shim-repoint.d.ts.map +1 -0
  15. package/dist/sonar/sonar-shim-repoint.js +221 -0
  16. package/dist/sonar/sonar-shim-repoint.js.map +1 -0
  17. package/package.json +4 -4
  18. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  19. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  20. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +9 -3
  21. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  22. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  23. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  24. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  25. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  26. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  27. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  28. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  29. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +9 -3
  30. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  31. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  32. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  33. package/plugins/lisa/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  34. package/plugins/lisa/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  35. package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  36. package/plugins/lisa/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  37. package/plugins/lisa/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  38. package/plugins/lisa-agy/plugin.json +1 -1
  39. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +9 -3
  40. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  41. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  42. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  43. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  44. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  45. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  46. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  47. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  48. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  50. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  51. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  55. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +9 -3
  57. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  58. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  59. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  60. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  61. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  62. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  63. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  64. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  65. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +9 -3
  67. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  68. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  69. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  70. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  71. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  72. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  73. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  74. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  75. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  77. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +9 -3
  78. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  79. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  80. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  81. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  82. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  83. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  84. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  85. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  86. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  88. package/plugins/lisa-expo-agy/plugin.json +1 -1
  89. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  93. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  95. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  96. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  98. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  99. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  100. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  102. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  103. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  104. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  105. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  106. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  107. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  108. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  109. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  110. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  111. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  112. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  113. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  114. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  116. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  117. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  118. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  119. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  120. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  121. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  123. package/plugins/lisa-rails-agy/plugin.json +1 -1
  124. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  125. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  126. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  127. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  128. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  129. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  130. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  131. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  132. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  133. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  134. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  135. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  136. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  137. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  138. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  139. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  140. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  141. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  142. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +9 -3
  143. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-cycle.mjs +5 -0
  144. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +18 -5
  145. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-workers.mjs +67 -3
  146. package/plugins/src/base/skills/lisa-session-manager/scripts/first-prompt.mjs +221 -0
  147. package/plugins/src/base/skills/lisa-session-manager/scripts/ledger.mjs +25 -3
  148. package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +4 -1
  149. package/plugins/src/base/skills/lisa-session-manager/scripts/worker-launch.mjs +91 -0
  150. package/plugins/src/base/skills/lisa-session-manager/scripts/workers.mjs +10 -5
  151. package/scripts/check-shell-guard-refusal-coverage.mjs +9 -3
  152. package/scripts/lib/shell-guard-shard-runner.mjs +40 -35
  153. package/scripts/lib/shell-guard-shards.mjs +176 -11
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Whether a path is a regular, non-symlinked file, and its permission bits.
3
+ * @param absolute - Absolute path to inspect
4
+ * @returns The permission bits, or undefined when missing or not a regular file
5
+ */
6
+ export declare function regularFileMode(absolute: string): Promise<number | undefined>;
7
+ /**
8
+ * Whether a file's real parent directory lies inside the project.
9
+ *
10
+ * `lstat` on the shim only rejects a symlink at the final component; a
11
+ * symlinked ancestor such as `.claude/hooks` would still route the write to a
12
+ * directory outside the checkout. Resolving both sides closes that.
13
+ * @param projectRoot - Absolute project root
14
+ * @param absolute - Absolute path of the file about to be rewritten
15
+ * @returns True when the resolved parent is the project root or beneath it
16
+ */
17
+ export declare function parentInsideProject(projectRoot: string, absolute: string): Promise<boolean>;
18
+ /**
19
+ * Replace a file's contents atomically, keeping its permission bits.
20
+ *
21
+ * Writes a sibling temporary file, sets its mode, then renames it over the
22
+ * target, so a failure part-way leaves the working shim intact rather than
23
+ * truncated. A target the operator made unwritable is refused up front: the
24
+ * rename would otherwise succeed (it needs only directory write access) and
25
+ * silently override that choice.
26
+ * @param absolute - Absolute path of the file to replace
27
+ * @param body - New contents
28
+ * @param mode - Permission bits for the replacement
29
+ * @throws {Error} When the target is not writable or any step fails
30
+ */
31
+ export declare function replaceFileAtomically(absolute: string, body: string, mode: number): Promise<void>;
32
+ //# sourceMappingURL=sonar-shim-fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sonar-shim-fs.d.ts","sourceRoot":"","sources":["../../src/sonar/sonar-shim-fs.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAI7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Filesystem guards for repointing Sonar hook shims in place.
3
+ *
4
+ * CodySwannGT/lisa#4502. Split from `sonar-shim-repoint.ts` so the parsing
5
+ * contract and the write-safety contract each stay small enough to read whole.
6
+ * Every helper here exists to make one rewrite of a host-owned file safe: never
7
+ * write through a symlink or out of the project, never leave a truncated shim
8
+ * behind, and never overwrite a shim the operator made read-only.
9
+ * @module sonar/sonar-shim-fs
10
+ */
11
+ import { randomUUID } from "node:crypto";
12
+ import { constants } from "node:fs";
13
+ import { access, chmod, lstat, realpath, rename, rm, writeFile, } from "node:fs/promises";
14
+ import * as path from "node:path";
15
+ /**
16
+ * Whether a path is a regular, non-symlinked file, and its permission bits.
17
+ * @param absolute - Absolute path to inspect
18
+ * @returns The permission bits, or undefined when missing or not a regular file
19
+ */
20
+ export async function regularFileMode(absolute) {
21
+ const stats = await lstat(absolute).catch(() => undefined);
22
+ if (stats === undefined || !stats.isFile())
23
+ return undefined;
24
+ return stats.mode & 0o7777;
25
+ }
26
+ /**
27
+ * Whether a file's real parent directory lies inside the project.
28
+ *
29
+ * `lstat` on the shim only rejects a symlink at the final component; a
30
+ * symlinked ancestor such as `.claude/hooks` would still route the write to a
31
+ * directory outside the checkout. Resolving both sides closes that.
32
+ * @param projectRoot - Absolute project root
33
+ * @param absolute - Absolute path of the file about to be rewritten
34
+ * @returns True when the resolved parent is the project root or beneath it
35
+ */
36
+ export async function parentInsideProject(projectRoot, absolute) {
37
+ const [root, parent] = await Promise.all([
38
+ realpath(projectRoot),
39
+ realpath(path.dirname(absolute)),
40
+ ]);
41
+ const relative = path.relative(root, parent);
42
+ return !relative.startsWith("..") && !path.isAbsolute(relative);
43
+ }
44
+ /**
45
+ * Replace a file's contents atomically, keeping its permission bits.
46
+ *
47
+ * Writes a sibling temporary file, sets its mode, then renames it over the
48
+ * target, so a failure part-way leaves the working shim intact rather than
49
+ * truncated. A target the operator made unwritable is refused up front: the
50
+ * rename would otherwise succeed (it needs only directory write access) and
51
+ * silently override that choice.
52
+ * @param absolute - Absolute path of the file to replace
53
+ * @param body - New contents
54
+ * @param mode - Permission bits for the replacement
55
+ * @throws {Error} When the target is not writable or any step fails
56
+ */
57
+ export async function replaceFileAtomically(absolute, body, mode) {
58
+ await access(absolute, constants.W_OK);
59
+ const temporary = path.join(path.dirname(absolute), `.${path.basename(absolute)}.lisa-${randomUUID()}.tmp`);
60
+ try {
61
+ await writeFile(temporary, body, { flag: "wx", mode });
62
+ await chmod(temporary, mode);
63
+ await rename(temporary, absolute);
64
+ }
65
+ catch (error) {
66
+ await rm(temporary, { force: true });
67
+ throw error;
68
+ }
69
+ }
70
+ //# sourceMappingURL=sonar-shim-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sonar-shim-fs.js","sourceRoot":"","sources":["../../src/sonar/sonar-shim-fs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,EAAE,EACF,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAgB;IAEhB,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QAA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AE,CAAC,CAAC;QACrC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Shim locations `lisa-setup-sonar` §4a documents, relative to the project root.
3
+ *
4
+ * Parity gaps, deliberately not listed here: OpenCode and Devin have no vendor
5
+ * `sonar integrate` path, so there is no vendor shim for Lisa to manage; Cursor
6
+ * is wired by `/lisa:setup:sonar` and §4a does not document its shim location,
7
+ * so its repointing stays with that setup skill. Windows `.ps1` shims are also
8
+ * out of scope: the wrapper is bash-only, so those remain manual §4a patching.
9
+ */
10
+ export declare const SONAR_SHIM_PATHS: readonly string[];
11
+ /** Lisa's Sonar hook wrapper, relative to the project root. */
12
+ export declare const SONAR_WRAPPER_PATH = "scripts/lisa-hooks/sonar-secrets.sh";
13
+ /** Outcome of one repoint pass. */
14
+ export interface SonarShimRepointResult {
15
+ /** Whether the wrapper exists; nothing is rewritten when it does not. */
16
+ readonly wrapperPresent: boolean;
17
+ /** Shim paths (relative to the project root) rewritten by this pass. */
18
+ readonly repointed: readonly string[];
19
+ /**
20
+ * Shim paths that could not be read or rewritten safely: not readable, not
21
+ * writable, or reached through a symlinked folder outside the project.
22
+ */
23
+ readonly failed: readonly string[];
24
+ /**
25
+ * Shim paths that call `sonar hook` but are neither the vendor form nor
26
+ * already repointed; left untouched for an operator to patch per §4a.
27
+ */
28
+ readonly unrecognized: readonly string[];
29
+ }
30
+ /**
31
+ * Whether a shim already executes the wrapper.
32
+ * @param body - Shim file contents
33
+ * @returns True when an executable line invokes the wrapper
34
+ */
35
+ export declare function invokesWrapper(body: string): boolean;
36
+ /**
37
+ * Extract the vendor event from an unmodified vendor shim body.
38
+ * @param body - Shim file contents
39
+ * @returns The event name, or undefined when the body is already repointed,
40
+ * customised, or otherwise not exactly the vendor's guard-then-hook sequence
41
+ */
42
+ export declare function parseVendorShimEvent(body: string): string | undefined;
43
+ /**
44
+ * Render a shim that delegates to the wrapper.
45
+ * @param shebang - The original shim's shebang line, if it had one
46
+ * @param relWrapper - POSIX path from the shim's directory to the wrapper
47
+ * @param event - Vendor event name the wrapper forwards to `sonar hook`
48
+ * @returns New shim body
49
+ */
50
+ export declare function renderRepointedShim(shebang: string | undefined, relWrapper: string, event: string): string;
51
+ /**
52
+ * Called with each shim's absolute path just before it is replaced, so the
53
+ * caller can back it up (apply registers it for rollback).
54
+ */
55
+ export type BeforeShimWrite = (absolute: string) => Promise<void>;
56
+ /** Options for {@link repointSonarShims}. */
57
+ export interface RepointSonarShimsOptions {
58
+ /** Invoked before each replacement; a rejection marks the shim `failed`. */
59
+ readonly beforeWrite?: BeforeShimWrite;
60
+ }
61
+ /**
62
+ * Repoint every documented vendor shim in a project at Lisa's wrapper.
63
+ *
64
+ * A no-op when the wrapper is absent: a shim pointed at a missing wrapper would
65
+ * fail every hook, which is worse than the vendor behaviour it replaces.
66
+ * @param projectRoot - Absolute project root
67
+ * @param options - Optional pre-write hook (used by apply for rollback backup)
68
+ * @returns Whether the wrapper exists, and each shim's outcome by category
69
+ */
70
+ export declare function repointSonarShims(projectRoot: string, options?: RepointSonarShimsOptions): Promise<SonarShimRepointResult>;
71
+ //# sourceMappingURL=sonar-shim-repoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sonar-shim-repoint.d.ts","sourceRoot":"","sources":["../../src/sonar/sonar-shim-repoint.ts"],"names":[],"mappings":"AA+BA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAM7C,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AAoCxE,mCAAmC;AACnC,MAAM,WAAW,sBAAsB;IACrC,yEAAyE;IACzE,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAcD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQrE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,MAAM,CAaR;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAElE,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;CACxC;AA0FD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,sBAAsB,CAAC,CA2BjC"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Repoint `sonar integrate`-generated hook shims at Lisa's Sonar wrapper.
3
+ *
4
+ * CodySwannGT/lisa#4502. `sonar integrate <agent>` writes a shim that pipes the
5
+ * hook payload straight to `sonar hook <event>`, so an unauthenticated CLI
6
+ * blocks every prompt with a reason that reads like a real finding. #2324
7
+ * shipped `scripts/lisa-hooks/sonar-secrets.sh`, which resolves
8
+ * `SONARQUBE_CLI_TOKEN` and downgrades that case to a warning — but the shim
9
+ * is generated, not copied, so only a human following `lisa-setup-sonar` §4a
10
+ * ever repointed it. A host project whose shim predates #2324 kept blocking
11
+ * every prompt (headless workers never started), and `processSonarIntegration`
12
+ * re-runs `sonar integrate` on each apply, which restores the vendor shim.
13
+ *
14
+ * This module closes the loop at apply time. It is deliberately conservative:
15
+ * it rewrites only a shim at a documented location whose body is exactly the
16
+ * vendor's (comments aside, the `command -v sonar` guard followed by one
17
+ * `sonar hook <event>` line, in that order). A shim that already executes the
18
+ * wrapper is left alone, which makes the rewrite idempotent, and any other body
19
+ * is treated as operator-customised and never touched. Write safety (symlinked
20
+ * ancestors, atomic replacement, read-only shims) lives in `sonar-shim-fs.ts`.
21
+ * @module sonar/sonar-shim-repoint
22
+ */
23
+ import { readFile } from "node:fs/promises";
24
+ import * as path from "node:path";
25
+ import { parentInsideProject, regularFileMode, replaceFileAtomically, } from "./sonar-shim-fs.js";
26
+ /**
27
+ * Shim locations `lisa-setup-sonar` §4a documents, relative to the project root.
28
+ *
29
+ * Parity gaps, deliberately not listed here: OpenCode and Devin have no vendor
30
+ * `sonar integrate` path, so there is no vendor shim for Lisa to manage; Cursor
31
+ * is wired by `/lisa:setup:sonar` and §4a does not document its shim location,
32
+ * so its repointing stays with that setup skill. Windows `.ps1` shims are also
33
+ * out of scope: the wrapper is bash-only, so those remain manual §4a patching.
34
+ */
35
+ export const SONAR_SHIM_PATHS = [
36
+ ".claude/hooks/sonar-secrets/build-scripts/prompt-secrets.sh",
37
+ ".claude/hooks/sonar-secrets/build-scripts/pretool-secrets.sh",
38
+ ".codex/hooks/sonar-secrets/build-scripts/prompt-secrets.sh",
39
+ ".github/hooks/sonar-secrets/build-scripts/pretool-secrets.sh",
40
+ ".agents/sonar/hooks/pretool-secrets.sh",
41
+ ];
42
+ /** Lisa's Sonar hook wrapper, relative to the project root. */
43
+ export const SONAR_WRAPPER_PATH = "scripts/lisa-hooks/sonar-secrets.sh";
44
+ /**
45
+ * An executable line delegating to the wrapper. Only a real invocation counts
46
+ * as "already repointed": a comment that merely names the wrapper must not
47
+ * hide a live `sonar hook` call.
48
+ */
49
+ const WRAPPER_INVOCATION = /^exec\s+bash\s+"?[^"\s]*scripts\/lisa-hooks\/sonar-secrets\.sh"?\s+[a-z][a-z0-9-]*$/;
50
+ /**
51
+ * The vendor shim's guard, in the only order it is written: anything else (an
52
+ * early `exit 0` that disables the hook, say) is a customisation, and
53
+ * rewriting it would silently re-enable or change what it does.
54
+ */
55
+ const VENDOR_GUARD_SEQUENCE = [
56
+ /^if\s+!\s+command\s+-v\s+sonar\b[^;]*;\s*then$/,
57
+ /^exit\s+0$/,
58
+ /^fi$/,
59
+ ];
60
+ /**
61
+ * The single hook call; capture group 1 is the vendor event name.
62
+ *
63
+ * A trailing `"$@"` is recognised but dropped on rewrite: the wrapper takes the
64
+ * event as its only argument, and the vendor shim is never passed others.
65
+ */
66
+ const VENDOR_HOOK_LINE = /^(?:exec\s+)?(?:cat\s*\|\s*)?sonar\s+hook\s+([a-z][a-z0-9-]*)(?:\s+"\$@")?$/;
67
+ /** Any call of the vendor hook command, whether or not it is recognisable. */
68
+ const SONAR_HOOK_CALL = /\bsonar\s+hook\b/;
69
+ /**
70
+ * The executable lines of a shim: trimmed, without blanks or comments.
71
+ * @param body - Shim file contents
72
+ * @returns Non-blank, non-comment lines in file order
73
+ */
74
+ function executableLines(body) {
75
+ return body
76
+ .split("\n")
77
+ .map(line => line.trim())
78
+ .filter(line => line !== "" && !line.startsWith("#"));
79
+ }
80
+ /**
81
+ * Whether a shim already executes the wrapper.
82
+ * @param body - Shim file contents
83
+ * @returns True when an executable line invokes the wrapper
84
+ */
85
+ export function invokesWrapper(body) {
86
+ return executableLines(body).some(line => WRAPPER_INVOCATION.test(line));
87
+ }
88
+ /**
89
+ * Extract the vendor event from an unmodified vendor shim body.
90
+ * @param body - Shim file contents
91
+ * @returns The event name, or undefined when the body is already repointed,
92
+ * customised, or otherwise not exactly the vendor's guard-then-hook sequence
93
+ */
94
+ export function parseVendorShimEvent(body) {
95
+ const lines = executableLines(body);
96
+ if (lines.length !== VENDOR_GUARD_SEQUENCE.length + 1)
97
+ return undefined;
98
+ const guarded = VENDOR_GUARD_SEQUENCE.every((pattern, index) => pattern.test(lines[index] ?? ""));
99
+ const hookLine = lines[VENDOR_GUARD_SEQUENCE.length] ?? "";
100
+ return guarded ? VENDOR_HOOK_LINE.exec(hookLine)?.[1] : undefined;
101
+ }
102
+ /**
103
+ * Render a shim that delegates to the wrapper.
104
+ * @param shebang - The original shim's shebang line, if it had one
105
+ * @param relWrapper - POSIX path from the shim's directory to the wrapper
106
+ * @param event - Vendor event name the wrapper forwards to `sonar hook`
107
+ * @returns New shim body
108
+ */
109
+ export function renderRepointedShim(shebang, relWrapper, event) {
110
+ return [
111
+ shebang ?? "#!/bin/bash",
112
+ `# Delegates to Lisa's ${SONAR_WRAPPER_PATH}, which resolves`,
113
+ "# SONARQUBE_CLI_TOKEN and downgrades an unauthenticated scanner to a warning.",
114
+ "# Re-running `sonar integrate` restores the vendor shim; `lisa apply` repoints it.",
115
+ "if ! command -v sonar &> /dev/null; then",
116
+ " exit 0",
117
+ "fi",
118
+ 'here="$(cd -- "$(dirname -- "$0")" && pwd)"',
119
+ `exec bash "\${here}/${relWrapper}" ${event}`,
120
+ "",
121
+ ].join("\n");
122
+ }
123
+ /**
124
+ * Classify a body that is not a vendor shim.
125
+ * @param body - Shim file contents
126
+ * @returns `unrecognized` when it still calls `sonar hook` directly
127
+ */
128
+ function classifyNonVendor(body) {
129
+ if (invokesWrapper(body))
130
+ return "skipped";
131
+ const callsHook = executableLines(body).some(line => SONAR_HOOK_CALL.test(line));
132
+ return callsHook ? "unrecognized" : "skipped";
133
+ }
134
+ /**
135
+ * Classify a shim body and, when it is the vendor's, rewrite it in place.
136
+ * @param absolute - Absolute shim path
137
+ * @param relative - Shim path relative to the project root
138
+ * @param mode - Permission bits to restore after the write
139
+ * @param beforeWrite - Hook run just before the replacement
140
+ * @returns The outcome for this shim
141
+ */
142
+ async function rewriteIfVendor(absolute, relative, mode, beforeWrite) {
143
+ const body = await readFile(absolute, "utf8");
144
+ const event = invokesWrapper(body) ? undefined : parseVendorShimEvent(body);
145
+ if (event === undefined)
146
+ return classifyNonVendor(body);
147
+ const firstLine = body.split("\n", 1)[0];
148
+ const shebang = firstLine?.startsWith("#!") ? firstLine : undefined;
149
+ const relWrapper = path.posix.relative(path.posix.dirname(relative), SONAR_WRAPPER_PATH);
150
+ await beforeWrite?.(absolute);
151
+ await replaceFileAtomically(absolute, renderRepointedShim(shebang, relWrapper, event), mode);
152
+ return "repointed";
153
+ }
154
+ /**
155
+ * Repoint one shim when it is an unmodified vendor shim.
156
+ *
157
+ * Never throws: an unreadable or unwritable shim, or one whose parent folder
158
+ * resolves outside the project through a symlink, is reported as `failed`, so
159
+ * one bad file cannot abort (and roll back) the whole apply and the operator
160
+ * is told about it.
161
+ * @param projectRoot - Absolute project root
162
+ * @param relative - Shim path relative to the project root
163
+ * @param beforeWrite - Hook run just before the replacement
164
+ * @returns The outcome for this shim
165
+ */
166
+ async function repointShim(projectRoot, relative, beforeWrite) {
167
+ const absolute = path.join(projectRoot, relative);
168
+ const mode = await regularFileMode(absolute);
169
+ if (mode === undefined)
170
+ return "skipped";
171
+ try {
172
+ if (!(await parentInsideProject(projectRoot, absolute)))
173
+ return "failed";
174
+ return await rewriteIfVendor(absolute, relative, mode, beforeWrite);
175
+ }
176
+ catch {
177
+ return "failed";
178
+ }
179
+ }
180
+ /**
181
+ * Collect the shim paths that ended with one outcome.
182
+ * @param outcomes - Path/outcome pairs in {@link SONAR_SHIM_PATHS} order
183
+ * @param wanted - Outcome to select
184
+ * @returns Matching shim paths
185
+ */
186
+ function pathsWith(outcomes, wanted) {
187
+ return outcomes
188
+ .filter(([, outcome]) => outcome === wanted)
189
+ .map(([relative]) => relative);
190
+ }
191
+ /**
192
+ * Repoint every documented vendor shim in a project at Lisa's wrapper.
193
+ *
194
+ * A no-op when the wrapper is absent: a shim pointed at a missing wrapper would
195
+ * fail every hook, which is worse than the vendor behaviour it replaces.
196
+ * @param projectRoot - Absolute project root
197
+ * @param options - Optional pre-write hook (used by apply for rollback backup)
198
+ * @returns Whether the wrapper exists, and each shim's outcome by category
199
+ */
200
+ export async function repointSonarShims(projectRoot, options = {}) {
201
+ const wrapperMode = await regularFileMode(path.join(projectRoot, SONAR_WRAPPER_PATH));
202
+ if (wrapperMode === undefined) {
203
+ return {
204
+ wrapperPresent: false,
205
+ repointed: [],
206
+ failed: [],
207
+ unrecognized: [],
208
+ };
209
+ }
210
+ const outcomes = await Promise.all(SONAR_SHIM_PATHS.map(async (relative) => [
211
+ relative,
212
+ await repointShim(projectRoot, relative, options.beforeWrite),
213
+ ]));
214
+ return {
215
+ wrapperPresent: true,
216
+ repointed: pathsWith(outcomes, "repointed"),
217
+ failed: pathsWith(outcomes, "failed"),
218
+ unrecognized: pathsWith(outcomes, "unrecognized"),
219
+ };
220
+ }
221
+ //# sourceMappingURL=sonar-shim-repoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sonar-shim-repoint.js","sourceRoot":"","sources":["../../src/sonar/sonar-shim-repoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,6DAA6D;IAC7D,8DAA8D;IAC9D,4DAA4D;IAC5D,8DAA8D;IAC9D,wCAAwC;CACzC,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAExE;;;;GAIG;AACH,MAAM,kBAAkB,GACtB,qFAAqF,CAAC;AAExF;;;;GAIG;AACH,MAAM,qBAAqB,GAAsB;IAC/C,gDAAgD;IAChD,YAAY;IACZ,MAAM;CACP,CAAC;AAEF;;;;;GAKG;AACH,MAAM,gBAAgB,GACpB,6EAA6E,CAAC;AAEhF,8EAA8E;AAC9E,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAuB3C;;;;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,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,EAAE;YACV,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,gBAAgB,CAAC,GAAG,CAClB,KAAK,EAAC,QAAQ,EAAC,EAAE,CACf;QACE,QAAQ;QACR,MAAM,WAAW,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC;KACrD,CACb,CACF,CAAC;IACF,OAAO;QACL,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,WAAW,CAAC;QAC3C,MAAM,EAAE,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC;QACrC,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC;KAClD,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -194,7 +194,7 @@
194
194
  "qs": "^6.16.0"
195
195
  },
196
196
  "name": "@codyswann/lisa",
197
- "version": "4.106.0",
197
+ "version": "4.106.2",
198
198
  "description": "Governance-as-code for AI coding agents: turns a repository into agent-operated software factories with guardrails, guidance and automated enforcement for Claude Code, Codex, Cursor, OpenCode, Antigravity, Copilot and Devin",
199
199
  "main": "dist/index.js",
200
200
  "exports": {
@@ -357,7 +357,7 @@
357
357
  "test": "tests"
358
358
  },
359
359
  "types": "./dist/index.d.ts",
360
- "lisaReleaseCommit": "647f89a290cf8d76630f249a99dfa1001b434439",
361
- "gitHead": "647f89a290cf8d76630f249a99dfa1001b434439",
362
- "lisaReleaseTag": "v4.106.0"
360
+ "lisaReleaseCommit": "86346999701eb99f26e42136a47074abcc1fe94e",
361
+ "gitHead": "86346999701eb99f26e42136a47074abcc1fe94e",
362
+ "lisaReleaseTag": "v4.106.2"
363
363
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.106.0",
3
+ "version": "4.106.2",
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.106.0",
3
+ "version": "4.106.2",
4
4
  "description": "Universal governance: agents, skills, commands, hooks, and rules for all projects.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -444,6 +444,7 @@ shows them.
444
444
  | `working`, `waiting`, `finished` | Nothing. |
445
445
  | `requestion` | With Telegram: re-send the pending question once, then re-record it with `ledger set-question` (same text, new message id); that restarts the re-ping clock. With no channel: nothing to re-send; leave it pending. |
446
446
  | `stalled`, `dead` | Read the item. If it left the `claimed` role, a human moved it: do not retry or move it; `ledger finish <ref> --status FAILED` with reason "left the claimed role outside the manager". Otherwise check for a merged PR first (`gh pr list --state merged --search <ref>` in the item's repo dir). If merged, leave the state change to Lisa's lifecycle and `ledger finish <ref> --status DONE` with reason "PR merged". Otherwise `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts). |
447
+ | `setup-gap` | The worker's first prompt never ran: `setupGap.kind` is `unknown-command` (Lisa's plugin is not visible in that repo, so `/lisa:implement` is unknown there) or `prompt-blocked` (a `UserPromptSubmit` hook rejected the prompt; `setupGap.detail` is what the hook said). Retrying cannot fix it. `claude stop <worker>` if it is still listed, `ledger finish <ref> --status FAILED --setup-gap` with reason "setup gap: <kind>: <detail>" (the spawn is not counted as an attempt). Then read the item: If it left the `claimed` role, a human moved it: respect that and do not move it back to the `ready` role. Otherwise move the item back to the `ready` role. Either way post one plain-language line naming the repo and the fix to Telegram, do not respawn it, do not dispatch to that repo again until the operator fixes it, and end the cycle `recovery-required` with that line as the summary. |
447
448
  | `exhausted` | Attempts reached `stall.maxAttempts`. Stop the worker if listed, `ledger finish <ref> --status FAILED`, then follow "Mark and move on" with `--kind exhausted` and, as the reason, how many attempts failed and how each ended: it moves the item to the `blocked` role and marks it for a human. |
448
449
 
449
450
  **Blocked.** List the items in the `blocked` role (paged to completion, same access paths as the
@@ -554,8 +555,13 @@ Skip while `capacity` reports `paused`. Otherwise:
554
555
  - exit 3 (no capacity): move the item back to the `ready` role and stop dispatching.
555
556
  - exit 4 (a live worker holds it): if the ledger has no item for it, record it with
556
557
  `ledger record-spawn <ref> --worker <worker> --session-id <id> --repo <key>`; continue.
557
- - exit 2 (setup gap, e.g. workspace trust not accepted in the repo dir): move the item back to
558
- the `ready` role, post the CLI's one-line message to Telegram, and end the cycle
558
+ - exit 2 (setup gap, e.g. workspace trust not accepted in the repo dir), including a worker
559
+ whose first prompt never ran (`/lisa:implement` unknown in that repo, or a
560
+ `UserPromptSubmit` hook rejected it; the CLI already stopped that worker and recorded
561
+ nothing). If the ledger already has an item for the ref and it is still
562
+ running, run `ledger finish <ref> --status FAILED --setup-gap` with the CLI's message as
563
+ the reason, so that stale row from an earlier worker is never later read as a human
564
+ moving the item. Then move the item back to the `ready` role, post the CLI's one-line message to Telegram, and end the cycle
559
565
  `recovery-required` with that message as the summary. It is not a failed attempt; do not
560
566
  dispatch to that repo again until the operator fixes it.
561
567
  - any other exit: move the item back to the `ready` role, notify Telegram, continue.
@@ -606,7 +612,7 @@ session `start` creates), every cycle ends in **exactly one** of the six outcome
606
612
  | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled item retried. | `change-proved` |
607
613
  | An item was marked human-needed ("Mark and move on": marker and question comment written and read back), in any of the four cases, including an `exhausted` item moved to the `blocked` role, or a marked item whose question comment was re-posted after `item-answer` reported `no-question-comment`; or a worker `FAILED` moved the item to the `blocked` role with its reason comment, both read back. The summary names each ref and where to answer it. | `candidate-proposed` |
608
614
  | No item was newly marked, but a pending question was re-sent on Telegram (`requestion`) and awaits the operator, and nothing else changed. | `approval-requested` |
609
- | The tracker, a configured Telegram or `claude` was unreachable; Telegram is configured but was unavailable or unpaired (a question stayed pending with no Telegram message id); a human-needed mark could not be written or read back, or no marker is configured; an answer for a finished worker, an `exhausted` item or a `decision` no worker has picked up could not be posted on the item or read back (its question stays pending); a worker `FAILED`'s move to the `blocked` role could not be written or read back; a spawn failed after the claim (the item went back to Ready); the capacity probe failed. | `recovery-required` |
615
+ | The tracker, a configured Telegram or `claude` was unreachable; Telegram is configured but was unavailable or unpaired (a question stayed pending with no Telegram message id); a human-needed mark could not be written or read back, or no marker is configured; an answer for a finished worker, an `exhausted` item or a `decision` no worker has picked up could not be posted on the item or read back (its question stays pending); a worker `FAILED`'s move to the `blocked` role could not be written or read back; a spawn failed after the claim (the item went back to Ready); a worker classified `setup-gap` (the item went back to Ready); the capacity probe failed. | `recovery-required` |
610
616
  | The retirement condition holds. | `policy-obsolete` |
611
617
 
612
618
  `candidate-proposed` is the outcome for marking an item human-needed. The contract's section "A run
@@ -140,10 +140,15 @@ const LEDGER_ACTIONS = {
140
140
  }
141
141
  const ref = requirePositional(ctx, "ref");
142
142
  await assertSender(ctx, ref);
143
+ const setupGap = ctx.values["setup-gap"] === true;
144
+ if (setupGap && status !== "FAILED") {
145
+ throw new CliError("--setup-gap needs --status FAILED.", 2);
146
+ }
143
147
  return recordFinish(ctx.root, {
144
148
  ref,
145
149
  status,
146
150
  reason: stdinText(ctx, "reason", { required: false }),
151
+ setupGap,
147
152
  });
148
153
  },
149
154
  "validation-failed": ctx =>
@@ -33,7 +33,14 @@ Workers and capacity
33
33
  claude --bg -n wk-<token>-<MMDD-HHMM> --dangerously-skip-permissions
34
34
  --settings {"crossSessionInbound":"accept"}
35
35
  "/lisa:implement <ref> managedBy=<sessionManager.name>"
36
- Records the ledger and sessions.jsonl. stdout {ref,name,sessionId,repo,cwd}.
36
+ Then reads the worker's transcript for up to 30s
37
+ (LISA_SESSION_MANAGER_FIRST_PROMPT_MS overrides it): when the first
38
+ prompt never ran (the command is unknown in that repo, or a
39
+ UserPromptSubmit hook rejected it), stops the worker, records nothing
40
+ and exits 2 (setup gap; no attempt counted).
41
+ Records the ledger and sessions.jsonl. stdout {ref,name,sessionId,repo,
42
+ cwd,firstPrompt}, firstPrompt "alive" or "unconfirmed" (the transcript
43
+ did not resolve in time).
37
44
  resume <ref> STDIN: the message for the worker
38
45
  claude --bg --resume <full session id> -- "<stdin>" in the worker's repo
39
46
  dir, TELEGRAM_* removed; the full id comes from claude agents --json --all
@@ -42,10 +49,13 @@ Workers and capacity
42
49
  stdout {ref,worker,sessionId,resumed:true}.
43
50
  classify [<ref>]
44
51
  Classifies one ledger item (or all) from claude agents --json --all and
45
- a hash of claude logs <worker>; records the hash as progress. stdout
52
+ a hash of claude logs <worker>, plus the worker's transcript; records
53
+ the hash as progress. stdout
46
54
  [{ref,worker,sessionId,repo,classification,attempts,agentStatus,
47
- pendingQuestion}], classification one of finished|waiting|requestion|
48
- working|stalled|dead|exhausted.
55
+ pendingQuestion,setupGap}], classification one of finished|waiting|
56
+ requestion|setup-gap|working|stalled|dead|exhausted. setup-gap: the
57
+ worker's first prompt never ran; setupGap is {kind:"unknown-command"|
58
+ "prompt-blocked",detail}, else null.
49
59
  status
50
60
  stdout {manager:{name,running,self},notify,control,workers:[{ref,
51
61
  worker,sessionId,repo,status,attempts,pendingQuestion,live}],untracked:
@@ -200,8 +210,11 @@ Per cycle
200
210
  --expect-answer-at: the answerAt answer-plan returned; exit 2 and
201
211
  nothing cleared when the queued answer's at differs (the operator
202
212
  replaced it since) or no answer is queued: record the new one first.
203
- ledger finish <ref> --status DONE|FAILED [--sender <name>] STDIN: reason
213
+ ledger finish <ref> --status DONE|FAILED [--sender <name>] [--setup-gap]
214
+ STDIN: reason
204
215
  --sender: exit 2 unless the ledger's worker for <ref> is exactly <name>.
216
+ --setup-gap (FAILED only): the worker's first prompt never ran
217
+ (classify said setup-gap), so its spawn is not counted as an attempt.
205
218
  ledger validation-failed <ref> --updated-at <ts> STDIN: failing gates
206
219
  Caches a backlog item's failed validation; queue skips it until the
207
220
  item's updatedAt changes.