@codyswann/lisa 4.81.2 → 4.81.4

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 (190) hide show
  1. package/dist/core/lisa.d.ts.map +1 -1
  2. package/dist/core/lisa.js +3 -0
  3. package/dist/core/lisa.js.map +1 -1
  4. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  5. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  6. package/dist/core/upstream-evidence-manifest.js +47 -8
  7. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  8. package/dist/strategies/copy-contents.d.ts.map +1 -1
  9. package/dist/strategies/copy-contents.js +3 -1
  10. package/dist/strategies/copy-contents.js.map +1 -1
  11. package/dist/strategies/copy-overwrite.d.ts.map +1 -1
  12. package/dist/strategies/copy-overwrite.js +3 -0
  13. package/dist/strategies/copy-overwrite.js.map +1 -1
  14. package/dist/strategies/create-only.d.ts.map +1 -1
  15. package/dist/strategies/create-only.js +8 -0
  16. package/dist/strategies/create-only.js.map +1 -1
  17. package/dist/strategies/merge.d.ts.map +1 -1
  18. package/dist/strategies/merge.js +2 -0
  19. package/dist/strategies/merge.js.map +1 -1
  20. package/dist/strategies/package-lisa.d.ts.map +1 -1
  21. package/dist/strategies/package-lisa.js +2 -0
  22. package/dist/strategies/package-lisa.js.map +1 -1
  23. package/dist/strategies/strategy.interface.d.ts +12 -1
  24. package/dist/strategies/strategy.interface.d.ts.map +1 -1
  25. package/dist/strategies/tagged-merge.d.ts.map +1 -1
  26. package/dist/strategies/tagged-merge.js +2 -0
  27. package/dist/strategies/tagged-merge.js.map +1 -1
  28. package/dist/transaction/backup.d.ts +27 -1
  29. package/dist/transaction/backup.d.ts.map +1 -1
  30. package/dist/transaction/backup.js +65 -3
  31. package/dist/transaction/backup.js.map +1 -1
  32. package/dist/transaction/created-paths.d.ts +72 -0
  33. package/dist/transaction/created-paths.d.ts.map +1 -0
  34. package/dist/transaction/created-paths.js +176 -0
  35. package/dist/transaction/created-paths.js.map +1 -0
  36. package/package.json +4 -4
  37. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  39. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +2 -2
  40. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  41. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  42. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  43. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  44. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/config.mjs +18 -36
  45. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  46. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  47. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  48. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  49. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/token.mjs +98 -28
  50. package/plugins/lisa/.codex-plugin/skills/lisa-setup-session-manager/SKILL.md +44 -21
  51. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +2 -2
  52. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  53. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  54. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  55. package/plugins/lisa/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  56. package/plugins/lisa/skills/lisa-session-manager/scripts/config.mjs +18 -36
  57. package/plugins/lisa/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  58. package/plugins/lisa/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  59. package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  60. package/plugins/lisa/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  61. package/plugins/lisa/skills/lisa-session-manager/scripts/token.mjs +98 -28
  62. package/plugins/lisa/skills/lisa-setup-session-manager/SKILL.md +44 -21
  63. package/plugins/lisa-agy/plugin.json +1 -1
  64. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +2 -2
  65. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  66. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  67. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  68. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  69. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/config.mjs +18 -36
  70. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  71. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  72. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  73. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  74. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/token.mjs +98 -28
  75. package/plugins/lisa-agy/skills/lisa-setup-session-manager/SKILL.md +44 -21
  76. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  78. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  79. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  83. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +2 -2
  85. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  86. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  87. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  88. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  89. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/config.mjs +18 -36
  90. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  91. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  92. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  93. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  94. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/token.mjs +98 -28
  95. package/plugins/lisa-copilot/skills/lisa-setup-session-manager/SKILL.md +44 -21
  96. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +2 -2
  98. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  99. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  100. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  101. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  102. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/config.mjs +18 -36
  103. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  104. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  105. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  106. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  107. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/token.mjs +98 -28
  108. package/plugins/lisa-cursor/skills/lisa-setup-session-manager/SKILL.md +44 -21
  109. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  110. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  111. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +2 -2
  112. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  113. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  114. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  115. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  116. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/config.mjs +18 -36
  117. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  118. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  119. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  120. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  121. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/token.mjs +98 -28
  122. package/plugins/lisa-devin/skills/lisa-setup-session-manager/SKILL.md +44 -21
  123. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  124. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  125. package/plugins/lisa-expo-agy/plugin.json +1 -1
  126. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  127. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  128. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  129. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  130. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  131. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  132. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  133. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  134. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  135. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  136. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  137. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  138. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  139. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  140. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  141. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  142. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  143. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  144. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  145. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  146. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  147. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  148. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  149. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  150. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  151. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  152. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  153. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  154. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  155. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  156. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  157. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  158. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  159. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  160. package/plugins/lisa-rails-agy/plugin.json +1 -1
  161. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  162. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  163. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  164. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  165. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  166. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  167. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  168. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  169. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  170. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  171. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  172. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  173. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  174. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  175. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  176. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  177. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  178. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  179. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +2 -2
  180. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
  181. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
  182. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
  183. package/plugins/src/base/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
  184. package/plugins/src/base/skills/lisa-session-manager/scripts/config.mjs +18 -36
  185. package/plugins/src/base/skills/lisa-session-manager/scripts/launch.mjs +1 -0
  186. package/plugins/src/base/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
  187. package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
  188. package/plugins/src/base/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
  189. package/plugins/src/base/skills/lisa-session-manager/scripts/token.mjs +98 -28
  190. package/plugins/src/base/skills/lisa-setup-session-manager/SKILL.md +44 -21
@@ -18,11 +18,14 @@
18
18
  * background sessions (`claude --bg`, `claude agents`), cross-session
19
19
  * messaging and channels, which no other supported agent has. Codex, Cursor,
20
20
  * OpenCode, Antigravity, Copilot and Devin can run the setup-time subcommands
21
- * (init-config, store-token, validate, start), and `start` hosts a Claude Code
22
- * manager in tmux whatever agent ran it; they cannot run a manager cycle
21
+ * (init-config, store-token, trust-status, coexistence, validate, start), and
22
+ * `start` hosts a Claude Code manager in tmux whatever agent ran it. Note that
23
+ * trust-status reads Claude Code's own trust record, which is the one that
24
+ * matters: workers are always Claude Code. They cannot run a manager cycle
23
25
  * themselves. OpenCode copies skill folders without the plugin-level
24
- * `scripts/` directory, so `queue` and `record-cycle` (which import from it)
25
- * are unavailable there unless the npm package provides that directory.
26
+ * `scripts/` directory, and this entry point statically imports modules that
27
+ * reach into it (cli-cycle.mjs, cli-runtime.mjs), so on OpenCode every
28
+ * subcommand runs only from the npm package, never from the skill-folder copy.
26
29
  * @module session-manager
27
30
  */
28
31
  import { readFileSync, realpathSync } from "node:fs";
@@ -38,17 +41,15 @@ import {
38
41
  recordCycle,
39
42
  route,
40
43
  } from "./cli-cycle.mjs";
44
+ import { repoDir, start, status, stop, validate } from "./cli-manager.mjs";
45
+ import { queue } from "./cli-queue.mjs";
46
+ import { CliError, EXIT } from "./cli-runtime.mjs";
41
47
  import {
48
+ coexistence,
42
49
  initConfig,
43
- repoDir,
44
- start,
45
- status,
46
- stop,
47
50
  storeToken,
48
- validate,
49
- } from "./cli-manager.mjs";
50
- import { queue } from "./cli-queue.mjs";
51
- import { CliError, EXIT } from "./cli-runtime.mjs";
51
+ trustStatus,
52
+ } from "./cli-setup.mjs";
52
53
  import { USAGE } from "./cli-usage.mjs";
53
54
  import { capacity, classify, resume, spawn } from "./cli-workers.mjs";
54
55
 
@@ -67,9 +68,11 @@ const COMMANDS = {
67
68
  stop: { run: stop, options: {}, positionals: 0 },
68
69
  "store-token": {
69
70
  run: storeToken,
70
- options: { replace: flag },
71
+ options: { replace: flag, "from-clipboard": flag },
71
72
  positionals: 0,
72
73
  },
74
+ "trust-status": { run: trustStatus, options: {}, positionals: 0 },
75
+ coexistence: { run: coexistence, options: {}, positionals: 0 },
73
76
  "repo-dir": {
74
77
  run: repoDir,
75
78
  options: { repo: text, raw: flag },
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Read-only facts setup needs before it asks the operator for anything:
3
+ * which worker directories Claude Code already trusts, and whether a
4
+ * scheduled intake loop is still running alongside the manager.
5
+ *
6
+ * Both used to be manual (CodySwannGT/lisa#4465). Setup asked the operator to
7
+ * open `claude` in every worker directory to accept workspace trust, even
8
+ * where Claude Code had already recorded it; and it only warned that
9
+ * `intake-tickets` / `intake-repair` compete with the manager, leaving the
10
+ * agent to dig through run logs to find out whether either was alive.
11
+ *
12
+ * Neither check writes anything, and neither answers a trust prompt.
13
+ * @module session-manager/setup-checks
14
+ */
15
+ import * as nodeFs from "node:fs";
16
+ import path from "node:path";
17
+
18
+ /** The scheduled loops that compete with the manager for the same items. */
19
+ export const COMPETING_LOOPS = Object.freeze([
20
+ "intake-tickets",
21
+ "intake-repair",
22
+ ]);
23
+
24
+ /** A loop counts as recent when it ran within at least this long. */
25
+ const MIN_RECENT_MS = 24 * 60 * 60 * 1000;
26
+
27
+ /**
28
+ * Where Claude Code keeps its global state, including per-directory trust:
29
+ * `$CLAUDE_CONFIG_DIR/.claude.json` when that is set, else `~/.claude.json`.
30
+ * @param {{ env?: Record<string, string | undefined>, homedir: string }} input
31
+ * - Environment and home directory
32
+ * @returns {string} Absolute path
33
+ */
34
+ export function claudeStateFile({ env = {}, homedir }) {
35
+ const configDir = env.CLAUDE_CONFIG_DIR;
36
+ return configDir
37
+ ? path.join(configDir, ".claude.json")
38
+ : path.join(homedir, ".claude.json");
39
+ }
40
+
41
+ /**
42
+ * Whether Claude Code has recorded workspace trust for each directory.
43
+ *
44
+ * `true` and `false` come from Claude Code's own record
45
+ * (`projects[<dir>].hasTrustDialogAccepted`). A directory and the key Claude
46
+ * Code recorded can name the same place through different symlinks (macOS
47
+ * `/var` is `/private/var`), so a key matches when the two realpaths agree;
48
+ * only keys with the same final segment are resolved, so a large state file
49
+ * costs a handful of realpath calls. `unknown` means the record could not be
50
+ * read, so the operator still has to check that directory by hand.
51
+ * @param {{ dirs: string[], env?: Record<string, string | undefined>,
52
+ * homedir: string, fs?: Pick<typeof nodeFs, "readFileSync" | "realpathSync"> }}
53
+ * input - Worker directories, environment, home directory and fs seam
54
+ * @returns {{ file: string, dirs: Array<{ dir: string,
55
+ * trusted: true | false | "unknown" }> }} One row per directory
56
+ */
57
+ export function trustStatus({ dirs, env, homedir, fs = nodeFs }) {
58
+ const file = claudeStateFile({ env, homedir });
59
+ let projects = null;
60
+ try {
61
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
62
+ projects =
63
+ parsed && typeof parsed.projects === "object" ? parsed.projects : {};
64
+ } catch {
65
+ projects = null;
66
+ }
67
+ const realpath = dir => {
68
+ try {
69
+ return fs.realpathSync(dir);
70
+ } catch {
71
+ return dir;
72
+ }
73
+ };
74
+ const entryFor = dir => {
75
+ if (Object.hasOwn(projects, dir)) return projects[dir];
76
+ const target = realpath(dir);
77
+ const key = Object.keys(projects).find(
78
+ candidate =>
79
+ path.basename(candidate) === path.basename(dir) &&
80
+ realpath(candidate) === target
81
+ );
82
+ return key === undefined ? undefined : projects[key];
83
+ };
84
+ return {
85
+ file,
86
+ dirs: dirs.map(dir => {
87
+ if (projects === null) return { dir, trusted: "unknown" };
88
+ return { dir, trusted: entryFor(dir)?.hasTrustDialogAccepted === true };
89
+ }),
90
+ };
91
+ }
92
+
93
+ /**
94
+ * The last parseable record of a loop's run log, or null.
95
+ * @param {string} file - `.lisa/automations/runs/<loop>.jsonl`
96
+ * @param {Pick<typeof nodeFs, "readFileSync">} fs - Filesystem seam
97
+ * @returns {{ ts: string, outcome: string | null } | null} Last record
98
+ */
99
+ function lastRunRecord(file, fs) {
100
+ let text;
101
+ try {
102
+ text = fs.readFileSync(file, "utf8");
103
+ } catch {
104
+ return null;
105
+ }
106
+ const lines = text.split("\n").filter(line => line.trim());
107
+ for (const line of lines.reverse()) {
108
+ try {
109
+ const record = JSON.parse(line);
110
+ if (
111
+ typeof record?.ts === "string" &&
112
+ !Number.isNaN(Date.parse(record.ts))
113
+ ) {
114
+ return { ts: record.ts, outcome: record.outcome ?? null };
115
+ }
116
+ } catch {
117
+ // A torn or foreign line: keep looking further back.
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+
123
+ /**
124
+ * How long a loop may go without a recorded run and still count as live:
125
+ * twice the time the manager gives a silent worker before giving up on it
126
+ * (`stall.noOutputMinutes × stall.maxAttempts`), and never under a day.
127
+ * @param {{ noOutputMinutes?: number, maxAttempts?: number } | undefined} stall
128
+ * - The manager's stall settings
129
+ * @returns {number} Milliseconds
130
+ */
131
+ export function recentWindowMs(stall) {
132
+ const minutes = (stall?.noOutputMinutes ?? 60) * (stall?.maxAttempts ?? 3);
133
+ return Math.max(MIN_RECENT_MS, 2 * minutes * 60 * 1000);
134
+ }
135
+
136
+ /**
137
+ * What this project's own run logs say about each competing intake loop.
138
+ *
139
+ * A loop with a recent recorded run is probably still scheduled and will
140
+ * compete with the manager. A stale or missing log is evidence, not proof,
141
+ * that it stopped: the runtime's scheduler (claude.ai routines, Codex
142
+ * automations, GitHub Actions) is the authority, and setup lists it too.
143
+ * @param {{ root: string, now: Date, stall?: object,
144
+ * fs?: Pick<typeof nodeFs, "readFileSync"> }} input - Project root, the
145
+ * current time, the manager's stall settings and fs seam
146
+ * @returns {{ windowHours: number, loops: Array<{ loop: string,
147
+ * log: string, lastRun: { ts: string, outcome: string | null } | null,
148
+ * recent: boolean }> }} One row per competing loop
149
+ */
150
+ export function coexistence({ root, now, stall, fs = nodeFs }) {
151
+ const windowMs = recentWindowMs(stall);
152
+ return {
153
+ windowHours: windowMs / 3_600_000,
154
+ loops: COMPETING_LOOPS.map(loop => {
155
+ const log = path.join(
156
+ root,
157
+ ".lisa",
158
+ "automations",
159
+ "runs",
160
+ `${loop}.jsonl`
161
+ );
162
+ const lastRun = lastRunRecord(log, fs);
163
+ const recent =
164
+ lastRun !== null && now.getTime() - Date.parse(lastRun.ts) <= windowMs;
165
+ return { loop, log, lastRun, recent };
166
+ }),
167
+ };
168
+ }
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The Telegram bot token the manager needs: validated, stored in
3
3
  * `<stateDir>/.env` (dir 0700, file 0600), read from the operator's terminal
4
- * with echo off, and never put in argv, a return value, an error message or a
4
+ * with echo off or from the clipboard (`--from-clipboard`, for when no TTY is
5
+ * reachable), and never put in argv, a return value, an error message or a
5
6
  * log line. An existing token is replaced only on request. Split out of
6
7
  * launch.mjs, which re-exports everything here.
7
8
  * @module token
@@ -10,6 +11,7 @@ import { randomUUID } from "node:crypto";
10
11
  import * as nodeFs from "node:fs";
11
12
  import path from "node:path";
12
13
 
14
+ import { readClipboard } from "./clipboard.mjs";
13
15
  import { LaunchError, resolveStateDir } from "./state-dir.mjs";
14
16
 
15
17
  /** The shape of a BotFather token: `<bot id>:<secret>`. */
@@ -94,41 +96,110 @@ function shellQuote(word) {
94
96
  * input - Script and project locations, and whether to carry `--replace`
95
97
  * @returns {string} One shell line
96
98
  */
97
- export function buildStoreTokenCommand({ scriptsDir, projectRoot, replace }) {
99
+ export function buildStoreTokenCommand({
100
+ scriptsDir,
101
+ projectRoot,
102
+ replace,
103
+ fromClipboard = false,
104
+ }) {
98
105
  const script = shellQuote(path.join(scriptsDir, "session-manager.mjs"));
99
- const flag = replace ? " --replace" : "";
100
- return `node ${script} store-token${flag} --project-root ${shellQuote(projectRoot)}`;
106
+ const flags =
107
+ (replace ? " --replace" : "") + (fromClipboard ? " --from-clipboard" : "");
108
+ return `node ${script} store-token${flags} --project-root ${shellQuote(projectRoot)}`;
109
+ }
110
+
111
+ /** Why `store-token` cannot prompt here, and the two ways forward. */
112
+ const NO_TTY_HINT =
113
+ "No terminal to prompt on, and Claude Code's ! prefix has no TTY either. " +
114
+ "Run `command` in a separate terminal app, or copy the token from " +
115
+ "BotFather and run `clipboardCommand`.";
116
+
117
+ /** The `invalid` outcome; names the expected shape, never the input. */
118
+ const INVALID = Object.freeze({
119
+ stored: false,
120
+ reason: "invalid",
121
+ message:
122
+ "That does not look like a Telegram bot token " +
123
+ "(expected <digits>:<30 or more letters, digits, _ or ->).",
124
+ });
125
+
126
+ /**
127
+ * Refuse to overwrite an existing token unless `replace` was asked for: a
128
+ * second project that shares this state dir by mistake would otherwise
129
+ * silently take over the first project's bot.
130
+ * @param {string} stateDir - Resolved state dir
131
+ * @param {boolean} replace - `--replace`
132
+ * @param {{ fs?: { existsSync?: (p: string) => boolean } }} io - Seams
133
+ */
134
+ function assertReplaceable(stateDir, replace, io) {
135
+ const existing = path.join(stateDir, TOKEN_FILE_NAME);
136
+ const exists = io.fs?.existsSync ?? nodeFs.existsSync;
137
+ if (!replace && exists(existing)) {
138
+ throw new LaunchError(
139
+ `A bot token already exists at ${existing}. Nothing was changed. ` +
140
+ `Re-run store-token with --replace to overwrite it.`
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Store the bot token from the system clipboard, with no TTY needed.
147
+ *
148
+ * Same validation and the same existing-token rule as the prompt. The
149
+ * clipboard is cleared only after a successful store, so a failed attempt
150
+ * leaves the operator's copy in place to retry with. The token is never
151
+ * returned, and an invalid value is reported by shape, never echoed.
152
+ * @param {{ stateDir: string, replace?: boolean,
153
+ * env?: Record<string, string | undefined>, homedir?: string,
154
+ * io?: { readClipboard?: typeof readClipboard, fs?: object } }} input -
155
+ * Configured state dir, the `--replace` flag and seams
156
+ * @returns {{ stored: true, path: string, clipboardCleared: boolean } |
157
+ * { stored: false, reason: "empty" | "invalid" | "unsupported" |
158
+ * "unavailable" | "failed", message: string }} Outcome
159
+ */
160
+ export function storeTokenFromClipboard(input) {
161
+ const { replace = false, io = {} } = input;
162
+ const stateDir = resolveStateDir(input.stateDir, input);
163
+ assertReplaceable(stateDir, replace, io);
164
+ const clip = (io.readClipboard ?? readClipboard)();
165
+ if (!clip.ok) {
166
+ return { stored: false, reason: clip.reason, message: clip.message };
167
+ }
168
+ const token = clip.text.trim();
169
+ if (!token) {
170
+ return {
171
+ stored: false,
172
+ reason: "empty",
173
+ message: "The clipboard is empty.",
174
+ };
175
+ }
176
+ if (!validateBotToken(token)) return { ...INVALID };
177
+ const written = writeTokenFile(stateDir, token, io);
178
+ return { stored: true, ...written, clipboardCleared: clip.clear() };
101
179
  }
102
180
 
103
181
  /**
104
182
  * Prompt for the bot token on the operator's terminal and store it.
105
183
  *
106
- * An existing token is never overwritten without `replace`: a second project
107
- * that shares this state dir by mistake would otherwise silently take over the
108
- * first project's bot. With no TTY this does not prompt and does not fail: it
109
- * returns the exact command for the operator to run themselves, because an
110
- * agent's Bash can never answer a prompt and a hung setup looks like a slow
111
- * one.
184
+ * An existing token is never overwritten without `replace`. With no TTY this
185
+ * does not prompt and does not fail: it returns the exact command for the
186
+ * operator to run in a separate terminal app, and the `--from-clipboard` form
187
+ * of it, because an agent's Bash (and Claude Code's `!` prefix) can never
188
+ * answer a prompt and a hung setup looks like a slow one.
112
189
  * @param {{ stateDir: string, scriptsDir: string, projectRoot: string,
113
190
  * replace?: boolean, env?: Record<string, string | undefined>,
114
191
  * homedir?: string, io?: { canPrompt?: () => boolean,
115
192
  * promptSecret?: (message: string) => string, fs?: object } }} input -
116
193
  * Configured state dir, locations, the `--replace` flag and seams
117
194
  * @returns {Promise<{ stored: true, path: string } |
118
- * { stored: false, reason: "no-tty", command: string } |
195
+ * { stored: false, reason: "no-tty", message: string, command: string,
196
+ * clipboardCommand: string } |
119
197
  * { stored: false, reason: "empty" | "invalid", message: string }>} Outcome
120
198
  */
121
199
  export async function storeToken(input) {
122
200
  const { scriptsDir, projectRoot, replace = false, io = {} } = input;
123
201
  const stateDir = resolveStateDir(input.stateDir, input);
124
- const existing = path.join(stateDir, TOKEN_FILE_NAME);
125
- const exists = io.fs?.existsSync ?? nodeFs.existsSync;
126
- if (!replace && exists(existing)) {
127
- throw new LaunchError(
128
- `A bot token already exists at ${existing}. Nothing was changed. ` +
129
- `Re-run store-token with --replace to overwrite it.`
130
- );
131
- }
202
+ assertReplaceable(stateDir, replace, io);
132
203
  const loaded =
133
204
  io.canPrompt && io.promptSecret ? null : await loadPromptSecret();
134
205
  const canPrompt = io.canPrompt ?? (() => loaded.canPrompt());
@@ -138,7 +209,14 @@ export async function storeToken(input) {
138
209
  return {
139
210
  stored: false,
140
211
  reason: "no-tty",
212
+ message: NO_TTY_HINT,
141
213
  command: buildStoreTokenCommand({ scriptsDir, projectRoot, replace }),
214
+ clipboardCommand: buildStoreTokenCommand({
215
+ scriptsDir,
216
+ projectRoot,
217
+ replace,
218
+ fromClipboard: true,
219
+ }),
142
220
  };
143
221
  }
144
222
  const typed = promptSecret(
@@ -147,15 +225,7 @@ export async function storeToken(input) {
147
225
  if (!typed) {
148
226
  return { stored: false, reason: "empty", message: "Nothing entered." };
149
227
  }
150
- if (!validateBotToken(typed)) {
151
- return {
152
- stored: false,
153
- reason: "invalid",
154
- message:
155
- "That does not look like a Telegram bot token " +
156
- "(expected <digits>:<30 or more letters, digits, _ or ->).",
157
- };
158
- }
228
+ if (!validateBotToken(typed)) return { ...INVALID };
159
229
  return { stored: true, ...writeTokenFile(stateDir, typed, io) };
160
230
  }
161
231
 
@@ -42,11 +42,14 @@ writes `$SM`, and pass `--project-root "$ROOT"` (the absolute project root) on e
42
42
 
43
43
  1. Preview: `node "$SM/session-manager.mjs" init-config --project-root "$ROOT"`. It detects
44
44
  `projects/*/.lisa.config.json` and proposes `name`, `interval`, `repos`, `capacity`, `stall` and a
45
- per-project `notify.stateDir`. Show the block to the operator.
45
+ per-project `notify.stateDir`. Repo detection leaves out linked worktrees and keeps one checkout
46
+ per remote, so ticket worktrees and second clones under `projects/` are not proposed. Show the
47
+ block to the operator and ask whether any repo is missing or should not be routed.
46
48
  2. Write it: the same command with `--write`. It adds only non-secret fields and never overwrites an
47
49
  existing block (`reason: "exists"` means keep it).
48
- 3. Ask the operator to replace each repo's starter `hints` with the technologies and areas that
49
- identify it (e.g. `api`: `["NestJS","migrations"]`, `web`: `["Expo","screens"]`), and whether to
50
+ 3. Each repo's `hints` are a draft: its name plus one per well-known dependency (`NestJS`, `Expo`,
51
+ `AWS CDK`, ...). Ask the operator to correct them and add the areas that identify the repo
52
+ (e.g. `api`: `["NestJS","migrations"]`, `web`: `["Expo","screens"]`), and whether to
50
53
  set `sessionManager.trustedAuthorIds`. Without it, any author's Ready item reaches a
51
54
  bypass-permissions worker; say so plainly. The list holds stable tracker user ids as strings,
52
55
  never logins: the GitHub numeric user id (`gh api users/<login> --jq .id`), the Jira
@@ -61,8 +64,14 @@ The operator creates a bot with @BotFather, one per project. Then run
61
64
  - `stored: true`: done.
62
65
  - Exit 2 because a token already exists: keep it (re-running setup is safe). Only when the operator
63
66
  says the stored token is wrong or belongs to another project, re-run with `store-token --replace`.
64
- - `reason: "no-tty"` (an agent's Bash has no terminal): print `command` from the output and ask the
65
- operator to run it in their own terminal, where it prompts with echo off. Wait for them to confirm.
67
+ - `reason: "no-tty"` (an agent's Bash has no terminal): offer the operator both routes, and say
68
+ plainly that Claude Code's `!` prefix has no terminal either, so it fails the same way:
69
+ - **Clipboard (simplest):** they copy the token from the BotFather chat and tell you; then run
70
+ `clipboardCommand` from the output (`store-token --from-clipboard`). It validates the token,
71
+ stores it, never prints it, and clears the clipboard. On `stored: false`, say what `message`
72
+ reports and ask them to copy it again.
73
+ - **Separate terminal app:** print `command` and ask them to run it in Terminal, iTerm or similar,
74
+ outside the agent, where it prompts with echo off. Wait for them to confirm.
66
75
  - `empty` / `invalid`: say what was wrong and ask again.
67
76
 
68
77
  Never ask for the token in chat, never echo, log or commit it, and never put it in
@@ -97,14 +106,24 @@ If `.lisa/automations/session-manager.runbook.md` does not exist, copy
97
106
  `$SM/../references/runbook-template.md` there. Never overwrite an existing runbook: it is the
98
107
  project's. It is checked in, like every automation runbook (`automation-runbook-contract`).
99
108
 
100
- ## Step 7: Coexistence warning
101
-
102
- Tell the operator, before starting: if this project also runs the scheduled `intake-repair` loop, it
103
- can re-dispatch an item a local worker is still building (it treats a claimed item with no tracker
104
- activity for `intake.repair.staleAfterHours` as stalled). `intake-tickets` competes for the same
105
- Ready items. Recommend tearing down `intake-tickets` (`/lisa:tear-down-automations intake-tickets`)
106
- and either raising `intake.repair.staleAfterHours` above `stall.noOutputMinutes × stall.maxAttempts`
107
- or tearing down `intake-repair`.
109
+ ## Step 7: Check for competing intake loops
110
+
111
+ The scheduled `intake-repair` loop can re-dispatch an item a local worker is still building (it treats
112
+ a claimed item with no tracker activity for `intake.repair.staleAfterHours` as stalled), and
113
+ `intake-tickets` competes for the same Ready items. Find out whether either is running before you
114
+ start the manager; do not leave the operator to check.
115
+
116
+ 1. Run `node "$SM/session-manager.mjs" coexistence --project-root "$ROOT"`. For each loop it reports
117
+ the last run recorded in this project's run log and whether that is `recent`. `live` lists the
118
+ loops that ran recently.
119
+ 2. A run log is evidence, not proof: also list your runtime's scheduler for those loop names (Claude
120
+ Code: the `/schedule` listing of claude.ai routines; Codex: automations; a `lisa-<loop>.yml`
121
+ workflow with a `schedule:` trigger on GitHub Actions).
122
+ 3. Report what you found, per loop, in one line each. Only for a loop that is live (a recent run, or a
123
+ scheduler entry): recommend tearing down `intake-tickets` (`/lisa:tear-down-automations
124
+ intake-tickets`) and either raising `intake.repair.staleAfterHours` above
125
+ `stall.noOutputMinutes × stall.maxAttempts` or tearing down `intake-repair`. When neither is live,
126
+ say so and move on.
108
127
 
109
128
  ## Step 8: Accept workspace trust in each worker repo
110
129
 
@@ -113,12 +132,15 @@ folder?" prompt: until someone has accepted it in a directory, `claude --bg` ref
113
132
  and `spawn` exits 2 saying so. Do this once per routed repo (or once for the root on a single-repo
114
133
  project), on every machine that runs the manager:
115
134
 
116
- 1. List the directories workers start in. Single-repo: the project root. Multi-repo: for each key in
117
- `sessionManager.repos.entries`,
118
- `node "$SM/session-manager.mjs" repo-dir --repo <key> --raw --project-root "$ROOT"`.
119
- 2. Ask the operator, in their own terminal, to run `claude` once in that directory,
120
- accept the trust prompt, then exit. An agent's Bash cannot answer that prompt, so never try to
121
- accept it for them.
135
+ 1. Run `node "$SM/session-manager.mjs" trust-status --project-root "$ROOT"`. It lists every
136
+ directory workers start in (each routed repo, or the root on a single-repo project) with whether
137
+ Claude Code has already recorded trust for it. `needsTrust` lists the ones that are not
138
+ `trusted: true`. When it is empty, this step is done: say so.
139
+ 2. For each directory in `needsTrust`, ask the operator, in a separate terminal app (not the agent's
140
+ Bash or Claude Code's `!` prefix), to run `claude` once in that directory, accept the trust prompt,
141
+ then exit. An agent's Bash cannot answer that prompt, so never try to accept it for them. Then
142
+ re-run `trust-status` to confirm. (`trusted: "unknown"` means Claude Code's state file could not be
143
+ read; treat it as needing trust.)
122
144
  3. Re-run this step whenever a repo is added to `sessionManager.repos`.
123
145
 
124
146
  ## Step 9: Start and pair
@@ -152,5 +174,6 @@ confirm the "Session manager Telegram isolation?" check is green. Fix every warn
152
174
  `node "$SM/session-manager.mjs" status --project-root "$ROOT"` should show the manager running.
153
175
 
154
176
  Report: the config block written (or kept), where the token lives (the path, never the value), the
155
- plugin scope result, the runbook path, which repo dirs had workspace trust accepted, the manager's
156
- tmux session name, and the doctor result.
177
+ plugin scope result, the runbook path, which repo dirs were already trusted and which the operator
178
+ accepted trust in, what the competing-loop check found, the manager's tmux session name, and the
179
+ doctor result.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific Lisa plugin.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.81.2",
3
+ "version": "4.81.4",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -23,9 +23,9 @@ channels (Telegram) and cross-session messaging (`SendMessage`, `crossSessionInb
23
23
  | Runtime | lisa-setup-session-manager | lisa-session-manager (manager) | `managedBy=` |
24
24
  |---|---|---|---|
25
25
  | Claude Code | supported | supported (reference). Needs `claude` ≥ 2.1.224, `tmux`, `bun` | supported |
26
- | Codex | config, token and runbook are supported. `start` launches a Claude Code manager, so it works when the `claude` CLI is installed | the skill ships, but `cycle` refuses to run here (no `/loop`, channels or `SendMessage`); tell the operator to run `start` | rejected with the gap message |
26
+ | Codex | config, token (prompt or `--from-clipboard`), runbook, `trust-status` and `coexistence` are supported. `trust-status` reads Claude Code's trust record, which is the one that matters (workers are Claude Code); accepting trust needs the `claude` CLI. `coexistence` sees only run logs, so also list Codex automations. `start` launches a Claude Code manager, so it works when the `claude` CLI is installed | the skill ships, but `cycle` refuses to run here (no `/loop`, channels or `SendMessage`); tell the operator to run `start` | rejected with the gap message |
27
27
  | Cursor / Antigravity (agy) / Copilot / Devin | same as Codex | same as Codex | rejected |
28
- | OpenCode | config and token are supported; script resolution relies on the npm rung, so `queue` and `record-cycle` need the npm package | gap | rejected |
28
+ | OpenCode | same setup subcommands as Codex, but script resolution relies on the npm rung: the CLI imports plugin-level scripts the skill-folder copy lacks, so every subcommand needs the npm package | gap | rejected |
29
29
 
30
30
  On any runtime other than Claude Code, `cycle` stops with: "The session manager runs on Claude Code
31
31
  only (background sessions, channels, cross-session messaging). Run `/lisa:session-manager start`