@codyswann/lisa 4.103.11 → 4.103.13

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 (110) hide show
  1. package/dist/codex/scripts/block-suppress-directives.sh +120 -26
  2. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  3. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  4. package/dist/core/upstream-evidence-manifest.js +20 -5
  5. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  6. package/dist/opencode/plugin-templates/lisa-block-suppress-directives.ts +72 -22
  7. package/package.json +4 -4
  8. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  9. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  10. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +13 -0
  11. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  12. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  13. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  14. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +13 -0
  15. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  16. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  17. package/plugins/lisa/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  18. package/plugins/lisa-agy/plugin.json +1 -1
  19. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +13 -0
  20. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  21. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  22. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  23. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  26. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  30. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +13 -0
  32. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  33. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  34. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  35. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +13 -0
  37. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  38. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  39. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  40. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  42. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +13 -0
  43. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  44. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  45. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  46. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  48. package/plugins/lisa-expo-agy/plugin.json +1 -1
  49. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  53. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  55. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  56. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  60. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  62. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  63. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  67. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  69. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  70. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  74. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  76. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  77. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  81. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  83. package/plugins/lisa-rails-agy/plugin.json +1 -1
  84. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  88. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  90. package/plugins/lisa-typescript/hooks/block-suppress-directives.sh +104 -14
  91. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  92. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  93. package/plugins/lisa-typescript-copilot/hooks/block-suppress-directives.sh +104 -14
  94. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  95. package/plugins/lisa-typescript-cursor/hooks/block-suppress-directives.sh +104 -14
  96. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  98. package/plugins/lisa-typescript-devin/hooks/block-suppress-directives.sh +104 -14
  99. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  101. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  102. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  103. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  104. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  105. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  106. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +13 -0
  107. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
  108. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
  109. package/plugins/src/base/skills/lisa-session-manager/scripts/launch.mjs +20 -0
  110. package/plugins/src/typescript/hooks/block-suppress-directives.sh +104 -14
@@ -7,51 +7,101 @@
7
7
  * underlying error. @ts-expect-error is intentionally NOT matched (it is the
8
8
  * safer alternative).
9
9
  *
10
+ * Refuses directive GROWTH, not presence (CodySwannGT/lisa#4492): a directive
11
+ * in the after text that the before text lacks (new, another copy, or reworded)
12
+ * refuses. `write` judges the whole file (disk vs content); `edit` judges only
13
+ * the replaced fragment (oldString vs newString), so a widening done purely by
14
+ * deleting text from an existing directive, or a directive assembled across
15
+ * separate edits, is NOT detected — a pre-existing limit, shared with the
16
+ * presence check this replaced. Each directive is taken from its comment
17
+ * opener to the end of its line. A `write` over something
18
+ * that exists but cannot be read, or an `edit` that brings a directive with no
19
+ * `oldString`, cannot be judged and is refused.
20
+ *
10
21
  * Port of Lisa's Codex hook `block-suppress-directives.sh`. OpenCode exposes
11
22
  * `edit` (oldString/newString) and `write` (content) tools — there is no
12
- * multi-file apply_patch — so the new text comes straight from the tool args.
13
- * Throwing in `tool.execute.before` cancels the call and surfaces the message
14
- * to the agent (verified-by-run on opencode 1.16.2).
23
+ * MultiEdit and no multi-file apply_patch — so the texts come straight from
24
+ * the tool args. Throwing in `tool.execute.before` cancels the call and
25
+ * surfaces the message to the agent (verified-by-run on opencode 1.16.2).
15
26
  *
16
27
  * NOTE: This file is a template Lisa copies verbatim into a host project's
17
28
  * `.opencode/plugin/`. It is intentionally excluded from this repo's tsconfig
18
29
  * and eslint config — it runs under OpenCode's Bun runtime, not here.
19
30
  */
20
- export const LisaBlockSuppressDirectives = async () => {
31
+ export const LisaBlockSuppressDirectives = async ({
32
+ directory,
33
+ }: { directory?: string } = {}) => {
21
34
  // Comment-syntax-only match: // or /* opener, optional whitespace, directive.
22
35
  const DIRECTIVE_RE =
23
- /(\/\/|\/\*)\s*(@ts-(ignore|nocheck)|eslint-disable|biome-ignore|prettier-ignore)/;
36
+ /(\/\/|\/\*)\s*(@ts-(ignore|nocheck)|eslint-disable|biome-ignore|prettier-ignore).*/g;
24
37
  const JS_TS = new Set(["ts", "tsx", "js", "jsx", "mjs", "cjs"]);
25
38
  const extOf = (p: string) => p.split(".").pop()?.toLowerCase() ?? "";
39
+ const directivesIn = (text: string) =>
40
+ (text.match(DIRECTIVE_RE) ?? []).map(d => d.trimEnd());
41
+ // True when `after` carries a directive `before` does not, counting copies.
42
+ const grows = (before: string, after: string) => {
43
+ const remaining = directivesIn(before);
44
+ return directivesIn(after).some(d => {
45
+ const at = remaining.indexOf(d);
46
+ if (at === -1) return true;
47
+ remaining.splice(at, 1);
48
+ return false;
49
+ });
50
+ };
51
+ // The file a write replaces; "" when absent, undefined when unreadable.
52
+ const readBefore = async (filePath: string) => {
53
+ const { lstat, readFile } = await import("node:fs/promises");
54
+ const { resolve } = await import("node:path");
55
+ const target = resolve(directory ?? process.cwd(), filePath);
56
+ const exists = await lstat(target).then(
57
+ () => true,
58
+ () => false
59
+ );
60
+ if (!exists) return "";
61
+ return readFile(target, "utf8").catch(() => undefined);
62
+ };
63
+ const refusal = (filePath: string) =>
64
+ new Error(
65
+ [
66
+ `block-suppress-directives: refusing to add an error-suppression directive to ${filePath}.`,
67
+ "",
68
+ "@ts-ignore / @ts-nocheck / eslint-disable / biome-ignore / prettier-ignore",
69
+ "silence the type checker, linter, or formatter instead of fixing the problem.",
70
+ "Fix the underlying type/lint error — add the missing annotation, narrow the",
71
+ "type, or restructure the code so the rule passes.",
72
+ "",
73
+ "Suppression is a last resort. If there is genuinely no other way, STOP and get",
74
+ "the user's approval first, prefer @ts-expect-error over @ts-ignore, scope the",
75
+ 'disable to one line and one rule, and add a "-- <reason>" description.',
76
+ ].join("\n")
77
+ );
26
78
  return {
27
79
  "tool.execute.before": async (
28
80
  input: { tool: string },
29
81
  output: {
30
- args?: { filePath?: string; content?: string; newString?: string };
82
+ args?: {
83
+ filePath?: string;
84
+ content?: string;
85
+ oldString?: string;
86
+ newString?: string;
87
+ };
31
88
  }
32
89
  ) => {
33
90
  if (input.tool !== "edit" && input.tool !== "write") return;
34
91
  const filePath = String(output.args?.filePath ?? "");
35
92
  if (!filePath || !JS_TS.has(extOf(filePath))) return;
36
- const newText =
93
+ const after =
37
94
  input.tool === "write"
38
95
  ? String(output.args?.content ?? "")
39
96
  : String(output.args?.newString ?? "");
40
- if (!DIRECTIVE_RE.test(newText)) return;
41
- throw new Error(
42
- [
43
- `block-suppress-directives: refusing to add an error-suppression directive to ${filePath}.`,
44
- "",
45
- "@ts-ignore / @ts-nocheck / eslint-disable / biome-ignore / prettier-ignore",
46
- "silence the type checker, linter, or formatter instead of fixing the problem.",
47
- "Fix the underlying type/lint error — add the missing annotation, narrow the",
48
- "type, or restructure the code so the rule passes.",
49
- "",
50
- "Suppression is a last resort. If there is genuinely no other way, STOP and get",
51
- "the user's approval first, prefer @ts-expect-error over @ts-ignore, scope the",
52
- 'disable to one line and one rule, and add a "-- <reason>" description.',
53
- ].join("\n")
54
- );
97
+ if (directivesIn(after).length === 0) return;
98
+ const before =
99
+ input.tool === "write"
100
+ ? await readBefore(filePath)
101
+ : output.args?.oldString;
102
+ if (typeof before !== "string" || grows(before, after)) {
103
+ throw refusal(filePath);
104
+ }
55
105
  },
56
106
  };
57
107
  };
package/package.json CHANGED
@@ -194,7 +194,7 @@
194
194
  "qs": "^6.16.0"
195
195
  },
196
196
  "name": "@codyswann/lisa",
197
- "version": "4.103.11",
197
+ "version": "4.103.13",
198
198
  "description": "Governance-as-code for AI coding agents: turns a repository into agent-operated software factories with guardrails, guidance and automated enforcement for Claude Code, Codex, Cursor, OpenCode, Antigravity, Copilot and Devin",
199
199
  "main": "dist/index.js",
200
200
  "exports": {
@@ -357,7 +357,7 @@
357
357
  "test": "tests"
358
358
  },
359
359
  "types": "./dist/index.d.ts",
360
- "lisaReleaseCommit": "ec2864222b8bde037dc329ab551466fab8d4b7cd",
361
- "gitHead": "ec2864222b8bde037dc329ab551466fab8d4b7cd",
362
- "lisaReleaseTag": "v4.103.11"
360
+ "lisaReleaseCommit": "5121e89309074b2199072accdbbd44c349681b73",
361
+ "gitHead": "5121e89309074b2199072accdbbd44c349681b73",
362
+ "lisaReleaseTag": "v4.103.13"
363
363
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.103.11",
3
+ "version": "4.103.13",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.103.11",
3
+ "version": "4.103.13",
4
4
  "description": "Universal governance: agents, skills, commands, hooks, and rules for all projects.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -362,6 +362,19 @@ Do these steps in order. Start each cycle by resolving `$SM`, then confirm the s
362
362
  and check again; never run a cycle from a child repo. Handle any messages that arrived since the last
363
363
  cycle first (above).
364
364
 
365
+ **Duplicate-manager check.** Decide **who** the manager is only from `status` `manager.self`; check
366
+ this session's own loops with `CronList`. When `manager.self` is true, this session **is** the
367
+ manager and its own `/loop` is the manager's loop: never report it as a second manager, and never
368
+ recommend `CronDelete` or stopping it. When `manager.self` is `null`, recommend stopping nothing;
369
+ report that self-identification failed. When `manager.running` is true, `manager.self` is false, and
370
+ this session runs its own `/lisa:session-manager cycle` loop, two managers can hand out the same
371
+ item: warn the operator and recommend stopping **this** session's loop, never the tmux manager. The
372
+ tmux manager cannot see another session's loop, so that warning comes from the other session's own
373
+ cycle and the manager must not invent one (detecting it from inside the manager is follow-up work).
374
+ `manager.self` means running inside the manager's tmux session, so another Claude started in a
375
+ second window of that same tmux session also reads true. Never infer a second manager from the tmux
376
+ session existing plus a loop being present.
377
+
365
378
  ### 1. Reconcile
366
379
 
367
380
  **Unsent questions** (only when `notify` is `telegram`). `ledger get` shows every pending question.
@@ -10,7 +10,7 @@ import path from "node:path";
10
10
 
11
11
  import { listAgents, requireConfig, run } from "./cli-runtime.mjs";
12
12
  import { notifyProvider } from "./config.mjs";
13
- import { buildHasSession } from "./launch.mjs";
13
+ import { buildCurrentSessionName, buildHasSession } from "./launch.mjs";
14
14
  import { listPendingQuestions } from "./ledger-questions.mjs";
15
15
  import { readLedger } from "./ledger.mjs";
16
16
  import { shellQuote } from "./token.mjs";
@@ -29,12 +29,44 @@ function answerCommandFor(ctx, ref) {
29
29
  return `node ${shellQuote(script)} answer ${shellQuote(ref)} --project-root ${shellQuote(ctx.root)} < answer.txt`;
30
30
  }
31
31
 
32
+ /**
33
+ * Whether the caller of `status` IS the manager: it runs inside tmux and
34
+ * tmux names the caller's own session as the manager's (#4496). Without this
35
+ * a cycle running in the manager's session saw "the tmux manager is running"
36
+ * plus its own `/loop` and reported itself as a second manager.
37
+ *
38
+ * "Self" means running inside the manager's tmux session, so a second Claude
39
+ * started in another window of that same session also reads true.
40
+ *
41
+ * Fail-safe, not fail-false: `false` only when there is no `$TMUX` or tmux
42
+ * names a different session. Inside tmux, `null` (unknown) when
43
+ * `$TMUX_PANE` is not a pane id (tmux is then not asked: untargeted, it
44
+ * answers for its most recently active client, which can be another
45
+ * session), or when the probe fails or names no session, because `false`
46
+ * there would tell the manager to stop its own loop. Nothing here throws.
47
+ * @param {{ env: Record<string, string | undefined> }} ctx - CLI context
48
+ * @param {string} name - Manager session name
49
+ * @returns {boolean | null} True for the manager's own session, false for
50
+ * another session or none, null when tmux cannot say which it is
51
+ */
52
+ function isManagerSelf(ctx, name) {
53
+ if (!ctx.env.TMUX) return false;
54
+ const argv = buildCurrentSessionName(ctx.env.TMUX_PANE);
55
+ if (argv === null) return null;
56
+ const probe = run("tmux", argv, { env: ctx.env });
57
+ const current = probe.status === 0 ? probe.stdout.trim() : "";
58
+ if (current === "") return null;
59
+ return current === name;
60
+ }
61
+
32
62
  /**
33
63
  * `status`: is the manager's tmux session up, and what does the ledger say
34
64
  * about each worker it dispatched.
35
65
  * @param {object} ctx - CLI context
36
66
  * `notify` is the configured notification provider (`telegram` or `none`),
37
- * so the manager knows each cycle whether a channel exists.
67
+ * so the manager knows each cycle whether a channel exists. `manager.self`
68
+ * (`true|false|null`) says whether the caller runs inside that tmux session
69
+ * (see {@link isManagerSelf}).
38
70
  * @returns {Promise<{ json: object }>}
39
71
  * `{manager,notify,control,workers,untracked,pendingQuestions}`
40
72
  */
@@ -49,7 +81,11 @@ export async function status(ctx) {
49
81
  const tracked = new Set(Object.values(ledger.items).map(i => i.worker));
50
82
  return {
51
83
  json: {
52
- manager: { name: config.name, running: tmux.status === 0 },
84
+ manager: {
85
+ name: config.name,
86
+ running: tmux.status === 0,
87
+ self: isManagerSelf(ctx, config.name),
88
+ },
53
89
  notify: notifyProvider(config),
54
90
  control: ledger.control,
55
91
  workers: Object.entries(ledger.items).map(([ref, item]) => ({
@@ -47,12 +47,16 @@ Workers and capacity
47
47
  pendingQuestion}], classification one of finished|waiting|requestion|
48
48
  working|stalled|dead|exhausted.
49
49
  status
50
- stdout {manager:{name,running},notify,control,workers:[{ref,worker,
51
- sessionId,repo,status,attempts,pendingQuestion,live}],untracked:[wk-
52
- names],pendingQuestions:[{ref,kind,text,askedAt,marked,answerQueued,
53
- answerCommand}]}. notify is the configured channel: "telegram" or
54
- "none". pendingQuestions lists every item waiting on a human, oldest
55
- first; answerCommand is the answer line to run at this machine.
50
+ stdout {manager:{name,running,self},notify,control,workers:[{ref,
51
+ worker,sessionId,repo,status,attempts,pendingQuestion,live}],untracked:
52
+ [wk-names],pendingQuestions:[{ref,kind,text,askedAt,marked,
53
+ answerQueued,answerCommand}]}. manager.self is true when the caller
54
+ runs inside the manager's tmux session (any window of it), false
55
+ outside tmux or in another session, null when tmux cannot say which
56
+ session the caller is in or $TMUX_PANE is not a pane id. notify is
57
+ the configured channel: "telegram" or "none". pendingQuestions lists
58
+ every item waiting on a human, oldest first; answerCommand is the
59
+ answer line to run at this machine.
56
60
 
57
61
  Manager
58
62
  start [--settle-ms <n>]
@@ -232,6 +232,26 @@ export function buildSessionPath(name) {
232
232
  ];
233
233
  }
234
234
 
235
+ /** A tmux pane id as tmux sets `$TMUX_PANE`: `%` then digits. */
236
+ const PANE_ID_PATTERN = /^%\d+$/;
237
+
238
+ /**
239
+ * tmux argv that prints the name of the session the CALLER runs in, so
240
+ * `status` can tell the manager asking about itself from another session
241
+ * asking about the manager (#4496). The target is always the caller's own
242
+ * `$TMUX_PANE`. Without `-t`, tmux answers for its "best" client (the most
243
+ * recently active one), which can be a different session, so there is no
244
+ * untargeted form: with no real pane id this returns null and the caller
245
+ * must treat the answer as unknown.
246
+ * @param {string | undefined} pane - The caller's `$TMUX_PANE`, if any
247
+ * @returns {string[] | null} argv for `spawnSync("tmux", argv)`, or null
248
+ * when `pane` is not a pane id
249
+ */
250
+ export function buildCurrentSessionName(pane) {
251
+ if (typeof pane !== "string" || !PANE_ID_PATTERN.test(pane)) return null;
252
+ return ["display-message", "-p", "-t", pane, "#{session_name}"];
253
+ }
254
+
235
255
  /**
236
256
  * tmux argv that stops the manager session and nothing else (exact name, see
237
257
  * {@link buildHasSession}). Workers are separate background sessions and keep
@@ -360,6 +360,19 @@ Do these steps in order. Start each cycle by resolving `$SM`, then confirm the s
360
360
  and check again; never run a cycle from a child repo. Handle any messages that arrived since the last
361
361
  cycle first (above).
362
362
 
363
+ **Duplicate-manager check.** Decide **who** the manager is only from `status` `manager.self`; check
364
+ this session's own loops with `CronList`. When `manager.self` is true, this session **is** the
365
+ manager and its own `/loop` is the manager's loop: never report it as a second manager, and never
366
+ recommend `CronDelete` or stopping it. When `manager.self` is `null`, recommend stopping nothing;
367
+ report that self-identification failed. When `manager.running` is true, `manager.self` is false, and
368
+ this session runs its own `/lisa:session-manager cycle` loop, two managers can hand out the same
369
+ item: warn the operator and recommend stopping **this** session's loop, never the tmux manager. The
370
+ tmux manager cannot see another session's loop, so that warning comes from the other session's own
371
+ cycle and the manager must not invent one (detecting it from inside the manager is follow-up work).
372
+ `manager.self` means running inside the manager's tmux session, so another Claude started in a
373
+ second window of that same tmux session also reads true. Never infer a second manager from the tmux
374
+ session existing plus a loop being present.
375
+
363
376
  ### 1. Reconcile
364
377
 
365
378
  **Unsent questions** (only when `notify` is `telegram`). `ledger get` shows every pending question.
@@ -10,7 +10,7 @@ import path from "node:path";
10
10
 
11
11
  import { listAgents, requireConfig, run } from "./cli-runtime.mjs";
12
12
  import { notifyProvider } from "./config.mjs";
13
- import { buildHasSession } from "./launch.mjs";
13
+ import { buildCurrentSessionName, buildHasSession } from "./launch.mjs";
14
14
  import { listPendingQuestions } from "./ledger-questions.mjs";
15
15
  import { readLedger } from "./ledger.mjs";
16
16
  import { shellQuote } from "./token.mjs";
@@ -29,12 +29,44 @@ function answerCommandFor(ctx, ref) {
29
29
  return `node ${shellQuote(script)} answer ${shellQuote(ref)} --project-root ${shellQuote(ctx.root)} < answer.txt`;
30
30
  }
31
31
 
32
+ /**
33
+ * Whether the caller of `status` IS the manager: it runs inside tmux and
34
+ * tmux names the caller's own session as the manager's (#4496). Without this
35
+ * a cycle running in the manager's session saw "the tmux manager is running"
36
+ * plus its own `/loop` and reported itself as a second manager.
37
+ *
38
+ * "Self" means running inside the manager's tmux session, so a second Claude
39
+ * started in another window of that same session also reads true.
40
+ *
41
+ * Fail-safe, not fail-false: `false` only when there is no `$TMUX` or tmux
42
+ * names a different session. Inside tmux, `null` (unknown) when
43
+ * `$TMUX_PANE` is not a pane id (tmux is then not asked: untargeted, it
44
+ * answers for its most recently active client, which can be another
45
+ * session), or when the probe fails or names no session, because `false`
46
+ * there would tell the manager to stop its own loop. Nothing here throws.
47
+ * @param {{ env: Record<string, string | undefined> }} ctx - CLI context
48
+ * @param {string} name - Manager session name
49
+ * @returns {boolean | null} True for the manager's own session, false for
50
+ * another session or none, null when tmux cannot say which it is
51
+ */
52
+ function isManagerSelf(ctx, name) {
53
+ if (!ctx.env.TMUX) return false;
54
+ const argv = buildCurrentSessionName(ctx.env.TMUX_PANE);
55
+ if (argv === null) return null;
56
+ const probe = run("tmux", argv, { env: ctx.env });
57
+ const current = probe.status === 0 ? probe.stdout.trim() : "";
58
+ if (current === "") return null;
59
+ return current === name;
60
+ }
61
+
32
62
  /**
33
63
  * `status`: is the manager's tmux session up, and what does the ledger say
34
64
  * about each worker it dispatched.
35
65
  * @param {object} ctx - CLI context
36
66
  * `notify` is the configured notification provider (`telegram` or `none`),
37
- * so the manager knows each cycle whether a channel exists.
67
+ * so the manager knows each cycle whether a channel exists. `manager.self`
68
+ * (`true|false|null`) says whether the caller runs inside that tmux session
69
+ * (see {@link isManagerSelf}).
38
70
  * @returns {Promise<{ json: object }>}
39
71
  * `{manager,notify,control,workers,untracked,pendingQuestions}`
40
72
  */
@@ -49,7 +81,11 @@ export async function status(ctx) {
49
81
  const tracked = new Set(Object.values(ledger.items).map(i => i.worker));
50
82
  return {
51
83
  json: {
52
- manager: { name: config.name, running: tmux.status === 0 },
84
+ manager: {
85
+ name: config.name,
86
+ running: tmux.status === 0,
87
+ self: isManagerSelf(ctx, config.name),
88
+ },
53
89
  notify: notifyProvider(config),
54
90
  control: ledger.control,
55
91
  workers: Object.entries(ledger.items).map(([ref, item]) => ({
@@ -47,12 +47,16 @@ Workers and capacity
47
47
  pendingQuestion}], classification one of finished|waiting|requestion|
48
48
  working|stalled|dead|exhausted.
49
49
  status
50
- stdout {manager:{name,running},notify,control,workers:[{ref,worker,
51
- sessionId,repo,status,attempts,pendingQuestion,live}],untracked:[wk-
52
- names],pendingQuestions:[{ref,kind,text,askedAt,marked,answerQueued,
53
- answerCommand}]}. notify is the configured channel: "telegram" or
54
- "none". pendingQuestions lists every item waiting on a human, oldest
55
- first; answerCommand is the answer line to run at this machine.
50
+ stdout {manager:{name,running,self},notify,control,workers:[{ref,
51
+ worker,sessionId,repo,status,attempts,pendingQuestion,live}],untracked:
52
+ [wk-names],pendingQuestions:[{ref,kind,text,askedAt,marked,
53
+ answerQueued,answerCommand}]}. manager.self is true when the caller
54
+ runs inside the manager's tmux session (any window of it), false
55
+ outside tmux or in another session, null when tmux cannot say which
56
+ session the caller is in or $TMUX_PANE is not a pane id. notify is
57
+ the configured channel: "telegram" or "none". pendingQuestions lists
58
+ every item waiting on a human, oldest first; answerCommand is the
59
+ answer line to run at this machine.
56
60
 
57
61
  Manager
58
62
  start [--settle-ms <n>]
@@ -232,6 +232,26 @@ export function buildSessionPath(name) {
232
232
  ];
233
233
  }
234
234
 
235
+ /** A tmux pane id as tmux sets `$TMUX_PANE`: `%` then digits. */
236
+ const PANE_ID_PATTERN = /^%\d+$/;
237
+
238
+ /**
239
+ * tmux argv that prints the name of the session the CALLER runs in, so
240
+ * `status` can tell the manager asking about itself from another session
241
+ * asking about the manager (#4496). The target is always the caller's own
242
+ * `$TMUX_PANE`. Without `-t`, tmux answers for its "best" client (the most
243
+ * recently active one), which can be a different session, so there is no
244
+ * untargeted form: with no real pane id this returns null and the caller
245
+ * must treat the answer as unknown.
246
+ * @param {string | undefined} pane - The caller's `$TMUX_PANE`, if any
247
+ * @returns {string[] | null} argv for `spawnSync("tmux", argv)`, or null
248
+ * when `pane` is not a pane id
249
+ */
250
+ export function buildCurrentSessionName(pane) {
251
+ if (typeof pane !== "string" || !PANE_ID_PATTERN.test(pane)) return null;
252
+ return ["display-message", "-p", "-t", pane, "#{session_name}"];
253
+ }
254
+
235
255
  /**
236
256
  * tmux argv that stops the manager session and nothing else (exact name, see
237
257
  * {@link buildHasSession}). Workers are separate background sessions and keep
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.103.11",
3
+ "version": "4.103.13",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -360,6 +360,19 @@ Do these steps in order. Start each cycle by resolving `$SM`, then confirm the s
360
360
  and check again; never run a cycle from a child repo. Handle any messages that arrived since the last
361
361
  cycle first (above).
362
362
 
363
+ **Duplicate-manager check.** Decide **who** the manager is only from `status` `manager.self`; check
364
+ this session's own loops with `CronList`. When `manager.self` is true, this session **is** the
365
+ manager and its own `/loop` is the manager's loop: never report it as a second manager, and never
366
+ recommend `CronDelete` or stopping it. When `manager.self` is `null`, recommend stopping nothing;
367
+ report that self-identification failed. When `manager.running` is true, `manager.self` is false, and
368
+ this session runs its own `/lisa:session-manager cycle` loop, two managers can hand out the same
369
+ item: warn the operator and recommend stopping **this** session's loop, never the tmux manager. The
370
+ tmux manager cannot see another session's loop, so that warning comes from the other session's own
371
+ cycle and the manager must not invent one (detecting it from inside the manager is follow-up work).
372
+ `manager.self` means running inside the manager's tmux session, so another Claude started in a
373
+ second window of that same tmux session also reads true. Never infer a second manager from the tmux
374
+ session existing plus a loop being present.
375
+
363
376
  ### 1. Reconcile
364
377
 
365
378
  **Unsent questions** (only when `notify` is `telegram`). `ledger get` shows every pending question.
@@ -10,7 +10,7 @@ import path from "node:path";
10
10
 
11
11
  import { listAgents, requireConfig, run } from "./cli-runtime.mjs";
12
12
  import { notifyProvider } from "./config.mjs";
13
- import { buildHasSession } from "./launch.mjs";
13
+ import { buildCurrentSessionName, buildHasSession } from "./launch.mjs";
14
14
  import { listPendingQuestions } from "./ledger-questions.mjs";
15
15
  import { readLedger } from "./ledger.mjs";
16
16
  import { shellQuote } from "./token.mjs";
@@ -29,12 +29,44 @@ function answerCommandFor(ctx, ref) {
29
29
  return `node ${shellQuote(script)} answer ${shellQuote(ref)} --project-root ${shellQuote(ctx.root)} < answer.txt`;
30
30
  }
31
31
 
32
+ /**
33
+ * Whether the caller of `status` IS the manager: it runs inside tmux and
34
+ * tmux names the caller's own session as the manager's (#4496). Without this
35
+ * a cycle running in the manager's session saw "the tmux manager is running"
36
+ * plus its own `/loop` and reported itself as a second manager.
37
+ *
38
+ * "Self" means running inside the manager's tmux session, so a second Claude
39
+ * started in another window of that same session also reads true.
40
+ *
41
+ * Fail-safe, not fail-false: `false` only when there is no `$TMUX` or tmux
42
+ * names a different session. Inside tmux, `null` (unknown) when
43
+ * `$TMUX_PANE` is not a pane id (tmux is then not asked: untargeted, it
44
+ * answers for its most recently active client, which can be another
45
+ * session), or when the probe fails or names no session, because `false`
46
+ * there would tell the manager to stop its own loop. Nothing here throws.
47
+ * @param {{ env: Record<string, string | undefined> }} ctx - CLI context
48
+ * @param {string} name - Manager session name
49
+ * @returns {boolean | null} True for the manager's own session, false for
50
+ * another session or none, null when tmux cannot say which it is
51
+ */
52
+ function isManagerSelf(ctx, name) {
53
+ if (!ctx.env.TMUX) return false;
54
+ const argv = buildCurrentSessionName(ctx.env.TMUX_PANE);
55
+ if (argv === null) return null;
56
+ const probe = run("tmux", argv, { env: ctx.env });
57
+ const current = probe.status === 0 ? probe.stdout.trim() : "";
58
+ if (current === "") return null;
59
+ return current === name;
60
+ }
61
+
32
62
  /**
33
63
  * `status`: is the manager's tmux session up, and what does the ledger say
34
64
  * about each worker it dispatched.
35
65
  * @param {object} ctx - CLI context
36
66
  * `notify` is the configured notification provider (`telegram` or `none`),
37
- * so the manager knows each cycle whether a channel exists.
67
+ * so the manager knows each cycle whether a channel exists. `manager.self`
68
+ * (`true|false|null`) says whether the caller runs inside that tmux session
69
+ * (see {@link isManagerSelf}).
38
70
  * @returns {Promise<{ json: object }>}
39
71
  * `{manager,notify,control,workers,untracked,pendingQuestions}`
40
72
  */
@@ -49,7 +81,11 @@ export async function status(ctx) {
49
81
  const tracked = new Set(Object.values(ledger.items).map(i => i.worker));
50
82
  return {
51
83
  json: {
52
- manager: { name: config.name, running: tmux.status === 0 },
84
+ manager: {
85
+ name: config.name,
86
+ running: tmux.status === 0,
87
+ self: isManagerSelf(ctx, config.name),
88
+ },
53
89
  notify: notifyProvider(config),
54
90
  control: ledger.control,
55
91
  workers: Object.entries(ledger.items).map(([ref, item]) => ({
@@ -47,12 +47,16 @@ Workers and capacity
47
47
  pendingQuestion}], classification one of finished|waiting|requestion|
48
48
  working|stalled|dead|exhausted.
49
49
  status
50
- stdout {manager:{name,running},notify,control,workers:[{ref,worker,
51
- sessionId,repo,status,attempts,pendingQuestion,live}],untracked:[wk-
52
- names],pendingQuestions:[{ref,kind,text,askedAt,marked,answerQueued,
53
- answerCommand}]}. notify is the configured channel: "telegram" or
54
- "none". pendingQuestions lists every item waiting on a human, oldest
55
- first; answerCommand is the answer line to run at this machine.
50
+ stdout {manager:{name,running,self},notify,control,workers:[{ref,
51
+ worker,sessionId,repo,status,attempts,pendingQuestion,live}],untracked:
52
+ [wk-names],pendingQuestions:[{ref,kind,text,askedAt,marked,
53
+ answerQueued,answerCommand}]}. manager.self is true when the caller
54
+ runs inside the manager's tmux session (any window of it), false
55
+ outside tmux or in another session, null when tmux cannot say which
56
+ session the caller is in or $TMUX_PANE is not a pane id. notify is
57
+ the configured channel: "telegram" or "none". pendingQuestions lists
58
+ every item waiting on a human, oldest first; answerCommand is the
59
+ answer line to run at this machine.
56
60
 
57
61
  Manager
58
62
  start [--settle-ms <n>]
@@ -232,6 +232,26 @@ export function buildSessionPath(name) {
232
232
  ];
233
233
  }
234
234
 
235
+ /** A tmux pane id as tmux sets `$TMUX_PANE`: `%` then digits. */
236
+ const PANE_ID_PATTERN = /^%\d+$/;
237
+
238
+ /**
239
+ * tmux argv that prints the name of the session the CALLER runs in, so
240
+ * `status` can tell the manager asking about itself from another session
241
+ * asking about the manager (#4496). The target is always the caller's own
242
+ * `$TMUX_PANE`. Without `-t`, tmux answers for its "best" client (the most
243
+ * recently active one), which can be a different session, so there is no
244
+ * untargeted form: with no real pane id this returns null and the caller
245
+ * must treat the answer as unknown.
246
+ * @param {string | undefined} pane - The caller's `$TMUX_PANE`, if any
247
+ * @returns {string[] | null} argv for `spawnSync("tmux", argv)`, or null
248
+ * when `pane` is not a pane id
249
+ */
250
+ export function buildCurrentSessionName(pane) {
251
+ if (typeof pane !== "string" || !PANE_ID_PATTERN.test(pane)) return null;
252
+ return ["display-message", "-p", "-t", pane, "#{session_name}"];
253
+ }
254
+
235
255
  /**
236
256
  * tmux argv that stops the manager session and nothing else (exact name, see
237
257
  * {@link buildHasSession}). Workers are separate background sessions and keep
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.103.11",
3
+ "version": "4.103.13",
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.103.11",
3
+ "version": "4.103.13",
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.103.11",
3
+ "version": "4.103.13",
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.103.11",
3
+ "version": "4.103.13",
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.103.11",
3
+ "version": "4.103.13",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"