@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
@@ -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.