@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.
- package/dist/core/lisa.d.ts.map +1 -1
- package/dist/core/lisa.js +3 -0
- package/dist/core/lisa.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +47 -8
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/strategies/copy-contents.d.ts.map +1 -1
- package/dist/strategies/copy-contents.js +3 -1
- package/dist/strategies/copy-contents.js.map +1 -1
- package/dist/strategies/copy-overwrite.d.ts.map +1 -1
- package/dist/strategies/copy-overwrite.js +3 -0
- package/dist/strategies/copy-overwrite.js.map +1 -1
- package/dist/strategies/create-only.d.ts.map +1 -1
- package/dist/strategies/create-only.js +8 -0
- package/dist/strategies/create-only.js.map +1 -1
- package/dist/strategies/merge.d.ts.map +1 -1
- package/dist/strategies/merge.js +2 -0
- package/dist/strategies/merge.js.map +1 -1
- package/dist/strategies/package-lisa.d.ts.map +1 -1
- package/dist/strategies/package-lisa.js +2 -0
- package/dist/strategies/package-lisa.js.map +1 -1
- package/dist/strategies/strategy.interface.d.ts +12 -1
- package/dist/strategies/strategy.interface.d.ts.map +1 -1
- package/dist/strategies/tagged-merge.d.ts.map +1 -1
- package/dist/strategies/tagged-merge.js +2 -0
- package/dist/strategies/tagged-merge.js.map +1 -1
- package/dist/transaction/backup.d.ts +27 -1
- package/dist/transaction/backup.d.ts.map +1 -1
- package/dist/transaction/backup.js +65 -3
- package/dist/transaction/backup.js.map +1 -1
- package/dist/transaction/created-paths.d.ts +72 -0
- package/dist/transaction/created-paths.d.ts.map +1 -0
- package/dist/transaction/created-paths.js +176 -0
- package/dist/transaction/created-paths.js.map +1 -0
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/token.mjs +98 -28
- package/plugins/lisa/.codex-plugin/skills/lisa-setup-session-manager/SKILL.md +44 -21
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/lisa/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/lisa/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/lisa/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/token.mjs +98 -28
- package/plugins/lisa/skills/lisa-setup-session-manager/SKILL.md +44 -21
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/token.mjs +98 -28
- package/plugins/lisa-agy/skills/lisa-setup-session-manager/SKILL.md +44 -21
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/token.mjs +98 -28
- package/plugins/lisa-copilot/skills/lisa-setup-session-manager/SKILL.md +44 -21
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/token.mjs +98 -28
- package/plugins/lisa-cursor/skills/lisa-setup-session-manager/SKILL.md +44 -21
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/token.mjs +98 -28
- package/plugins/lisa-devin/skills/lisa-setup-session-manager/SKILL.md +44 -21
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +2 -2
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-manager.mjs +5 -76
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-setup.mjs +165 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +32 -8
- package/plugins/src/base/skills/lisa-session-manager/scripts/clipboard.mjs +119 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/config.mjs +18 -36
- package/plugins/src/base/skills/lisa-session-manager/scripts/launch.mjs +1 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/repo-detect.mjs +205 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +16 -13
- package/plugins/src/base/skills/lisa-session-manager/scripts/setup-checks.mjs +168 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/token.mjs +98 -28
- 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
|
|
22
|
-
* manager in tmux whatever agent ran it
|
|
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,
|
|
25
|
-
*
|
|
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
|
-
|
|
49
|
-
} from "./cli-
|
|
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
|
|
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({
|
|
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
|
|
100
|
-
|
|
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
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
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",
|
|
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
|
-
|
|
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`.
|
|
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.
|
|
49
|
-
|
|
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):
|
|
65
|
-
|
|
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:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
accept
|
|
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
|
|
156
|
-
tmux session name, and the
|
|
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.
|
|
@@ -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
|
|
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 |
|
|
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`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Manager
|
|
3
|
-
*
|
|
2
|
+
* Manager subcommands of the session-manager CLI: start, stop, status,
|
|
3
|
+
* repo-dir and validate. The setup ones (init-config, store-token,
|
|
4
|
+
* trust-status, coexistence) live in cli-setup.mjs.
|
|
4
5
|
*
|
|
5
6
|
* `start` hosts the manager in tmux. It refuses (exit 2) unless the bot
|
|
6
7
|
* token file exists with owner-only permissions in the project's own state
|
|
@@ -11,15 +12,11 @@
|
|
|
11
12
|
* manager's tmux session: workers hold claimed work and keep running.
|
|
12
13
|
* @module session-manager/cli-manager
|
|
13
14
|
*/
|
|
14
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
|
|
17
15
|
import {
|
|
18
16
|
CliError,
|
|
19
17
|
EXIT,
|
|
20
18
|
GLOBAL_CONFIG_FILE,
|
|
21
19
|
asSetupError,
|
|
22
|
-
asSetupErrorAsync,
|
|
23
20
|
intFlag,
|
|
24
21
|
listAgents,
|
|
25
22
|
loadProject,
|
|
@@ -28,12 +25,8 @@ import {
|
|
|
28
25
|
requireLisaRepo,
|
|
29
26
|
run,
|
|
30
27
|
} from "./cli-runtime.mjs";
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
defaultProjectSlug,
|
|
34
|
-
probeOwnSession,
|
|
35
|
-
sessionSurvives,
|
|
36
|
-
} from "./isolation.mjs";
|
|
28
|
+
import { resolveRepoDir } from "./config.mjs";
|
|
29
|
+
import { probeOwnSession, sessionSurvives } from "./isolation.mjs";
|
|
37
30
|
import {
|
|
38
31
|
assertTokenPresent,
|
|
39
32
|
buildForegroundCommand,
|
|
@@ -41,7 +34,6 @@ import {
|
|
|
41
34
|
buildManagerLaunch,
|
|
42
35
|
buildStopManager,
|
|
43
36
|
resolveStateDir,
|
|
44
|
-
storeToken as storeTokenFile,
|
|
45
37
|
} from "./launch.mjs";
|
|
46
38
|
import { readLedger } from "./ledger.mjs";
|
|
47
39
|
import { parseWorkerName, scrubWorkerEnv } from "./workers.mjs";
|
|
@@ -208,69 +200,6 @@ export function validate(ctx) {
|
|
|
208
200
|
};
|
|
209
201
|
}
|
|
210
202
|
|
|
211
|
-
/**
|
|
212
|
-
* `init-config [--slug <slug>] [--write]`: the default block for this
|
|
213
|
-
* project, written to `.lisa.config.json` only with `--write` and only when
|
|
214
|
-
* no block exists. Non-secret fields only; the token never goes here.
|
|
215
|
-
* @param {object} ctx - CLI context
|
|
216
|
-
* @returns {{ json: object }} `{written,block,...}`
|
|
217
|
-
*/
|
|
218
|
-
export function initConfig(ctx) {
|
|
219
|
-
const { global } = loadProject(ctx.root);
|
|
220
|
-
if (global?.sessionManager) {
|
|
221
|
-
return {
|
|
222
|
-
json: { written: false, reason: "exists", block: global.sessionManager },
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
const slug =
|
|
226
|
-
ctx.values.slug ?? defaultProjectSlug(ctx.root, global?.github?.repo);
|
|
227
|
-
const block = asSetupError(() =>
|
|
228
|
-
buildDefaultBlock({
|
|
229
|
-
projectSlug: slug,
|
|
230
|
-
detectedRepos: detectRepos(ctx.root),
|
|
231
|
-
})
|
|
232
|
-
);
|
|
233
|
-
if (!ctx.values.write) return { json: { written: false, block } };
|
|
234
|
-
|
|
235
|
-
const file = path.join(ctx.root, GLOBAL_CONFIG_FILE);
|
|
236
|
-
if (!existsSync(file)) {
|
|
237
|
-
throw new CliError(
|
|
238
|
-
`${file} does not exist; set up Lisa in this project first.`,
|
|
239
|
-
EXIT.SETUP
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
const current = JSON.parse(readFileSync(file, "utf8"));
|
|
243
|
-
writeFileSync(
|
|
244
|
-
file,
|
|
245
|
-
`${JSON.stringify({ ...current, sessionManager: block }, null, 2)}\n`
|
|
246
|
-
);
|
|
247
|
-
return { json: { written: true, path: file, block } };
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* `store-token [--replace]`: prompt for the bot token on the operator's
|
|
252
|
-
* terminal and write `<stateDir>/.env`. An existing token is kept (exit 2)
|
|
253
|
-
* unless `--replace` is given. With no TTY it prints the command the operator
|
|
254
|
-
* must run themselves and exits 0 with `stored:false`.
|
|
255
|
-
* @param {object} ctx - CLI context
|
|
256
|
-
* @returns {Promise<{ json: object, exitCode: number }>} Outcome
|
|
257
|
-
*/
|
|
258
|
-
export async function storeToken(ctx) {
|
|
259
|
-
const config = requireConfig(ctx);
|
|
260
|
-
const result = await asSetupErrorAsync(() =>
|
|
261
|
-
storeTokenFile({
|
|
262
|
-
stateDir: config.notify?.stateDir,
|
|
263
|
-
scriptsDir: ctx.scriptsDir,
|
|
264
|
-
projectRoot: ctx.root,
|
|
265
|
-
replace: ctx.values.replace === true,
|
|
266
|
-
env: ctx.env,
|
|
267
|
-
homedir: ctx.homedir,
|
|
268
|
-
})
|
|
269
|
-
);
|
|
270
|
-
const refused = result.stored === false && result.reason !== "no-tty";
|
|
271
|
-
return { json: result, exitCode: refused ? EXIT.SETUP : EXIT.OK };
|
|
272
|
-
}
|
|
273
|
-
|
|
274
203
|
/**
|
|
275
204
|
* `status`: is the manager's tmux session up, and what does the ledger say
|
|
276
205
|
* about each worker it dispatched.
|