@codyswann/lisa 8.10.6 → 8.10.7

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 (108) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.json +19 -5
  3. package/package.json +4 -4
  4. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  5. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  6. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  7. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  8. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  9. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +5 -0
  10. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  11. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/workers.mjs +5 -1
  12. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  13. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  14. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  15. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +5 -0
  16. package/plugins/lisa/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  17. package/plugins/lisa/skills/lisa-session-manager/scripts/workers.mjs +5 -1
  18. package/plugins/lisa-agy/plugin.json +1 -1
  19. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  20. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  21. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  22. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +5 -0
  23. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  24. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/workers.mjs +5 -1
  25. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  27. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  28. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  32. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  34. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  35. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  36. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +5 -0
  37. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  38. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/workers.mjs +5 -1
  39. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  41. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  42. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  43. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +5 -0
  44. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  45. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/workers.mjs +5 -1
  46. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  48. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  49. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  50. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  51. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +5 -0
  52. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  53. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/workers.mjs +5 -1
  54. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  56. package/plugins/lisa-expo-agy/plugin.json +1 -1
  57. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  61. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  63. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  64. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  68. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  70. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  71. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  74. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  75. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  77. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  78. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  82. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  84. package/plugins/lisa-rails-agy/plugin.json +1 -1
  85. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  88. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  89. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  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-cursor/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  95. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  96. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  98. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  99. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  102. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  103. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-action.mjs +10 -0
  104. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
  105. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
  106. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +5 -0
  107. package/plugins/src/base/skills/lisa-session-manager/scripts/launch.mjs +5 -0
  108. package/plugins/src/base/skills/lisa-session-manager/scripts/workers.mjs +5 -1
@@ -0,0 +1,177 @@
1
+ /**
2
+ * The session manager in a Lisa-managed project (CodySwannGT/lisa#5211).
3
+ *
4
+ * The readiness gate refuses project work from a session with no ticket
5
+ * bound. The session manager binds no ticket by design: it hands tickets to
6
+ * workers, and each worker binds its own. Its work is operational: reading
7
+ * the queue, spawning workers, writing its ledger. So two things are
8
+ * admitted here with no ticket bound.
9
+ *
10
+ * - The manager's own session. `start` marks it at launch with
11
+ * `LISA_SESSION_MANAGER=<name>`. Hooks inherit the Claude process's
12
+ * environment, which a Bash `export` inside the session cannot change, and
13
+ * workers are spawned without the mark. The mark must equal the project's
14
+ * configured `sessionManager.name`. The session may do anything except edit
15
+ * project files: a file-edit tool aimed inside the repository is admitted
16
+ * only under `.lisa/`, where the manager keeps its state.
17
+ * - The operator's exact `start`, `stop`, `status` and `validate` commands,
18
+ * from any session, so an operator can run and check on the manager.
19
+ *
20
+ * Nothing here imports the session-manager skill, which is not shipped to
21
+ * every agent: a missing import would fail the whole gate closed.
22
+ */
23
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
24
+ import { dirname, join, resolve, sep } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+ import {
27
+ outsideEveryRepository,
28
+ realLocation,
29
+ writeTargets,
30
+ } from "./task-unbound.mjs";
31
+
32
+ /** This install's session-manager CLI, beside this skill. */
33
+ export const MANAGER_CLI = join(
34
+ dirname(fileURLToPath(import.meta.url)),
35
+ "..",
36
+ "..",
37
+ "lisa-session-manager",
38
+ "scripts",
39
+ "session-manager.mjs"
40
+ );
41
+ const OPERATOR = ["start", "stop", "status", "validate"];
42
+ const EDIT_TOOLS = new Set([
43
+ "Write",
44
+ "Edit",
45
+ "MultiEdit",
46
+ "NotebookEdit",
47
+ "apply_patch",
48
+ "write",
49
+ "edit",
50
+ ]);
51
+
52
+ /**
53
+ * One parsed config file, or undefined when absent or unreadable.
54
+ * @param {string} path File path.
55
+ * @returns {Record<string, any>|undefined} Parsed object.
56
+ */
57
+ function readJson(path) {
58
+ try {
59
+ const value = JSON.parse(readFileSync(path, "utf8"));
60
+ return value && typeof value === "object" ? value : undefined;
61
+ } catch {
62
+ return undefined;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * The project's configured manager name, local config over committed.
68
+ * @param {string} root Project root.
69
+ * @returns {string|null} The name, or null when none is configured.
70
+ */
71
+ export function managerName(root) {
72
+ const name = [".lisa.config.local.json", ".lisa.config.json"]
73
+ .map(file => readJson(join(root, file))?.sessionManager?.name)
74
+ .find(value => value !== undefined);
75
+ return typeof name === "string" && name !== "" ? name : null;
76
+ }
77
+
78
+ /**
79
+ * Whether a resolved path is inside the project's `.lisa/` folder.
80
+ * @param {string} target Absolute path the tool names.
81
+ * @param {string} root Project root.
82
+ * @returns {boolean} True for a path under `.lisa/`.
83
+ */
84
+ function underLisaFolder(target, root) {
85
+ const location = realLocation(resolve(target));
86
+ let lisa;
87
+ try {
88
+ lisa = join(realpathSync(root), ".lisa");
89
+ } catch {
90
+ return false;
91
+ }
92
+ return Boolean(location?.startsWith(lisa + sep));
93
+ }
94
+
95
+ /**
96
+ * Whether this event comes from the project's marked manager session, and
97
+ * is not an edit to a project file.
98
+ * @param {Record<string, any>} input Hook event.
99
+ * @param {{projectRoot: string}} cfg Task configuration.
100
+ * @param {Record<string, string|undefined>} [env] Session environment.
101
+ * @returns {boolean} True to admit it.
102
+ */
103
+ export function managerSession(input, cfg, env = process.env) {
104
+ const mark = env.LISA_SESSION_MANAGER;
105
+ if (!mark || mark !== managerName(cfg.projectRoot)) return false;
106
+ if (!EDIT_TOOLS.has(input?.tool_name)) return true;
107
+ const targets = writeTargets(input);
108
+ return (
109
+ targets !== null &&
110
+ targets.every(
111
+ target =>
112
+ outsideEveryRepository(target, cfg.projectRoot) ||
113
+ underLisaFolder(target, cfg.projectRoot)
114
+ )
115
+ );
116
+ }
117
+
118
+ /**
119
+ * A path as the one shell word that names it.
120
+ * @param {string} path Absolute path.
121
+ * @returns {string[]} The plain form when the shell reads it as one word,
122
+ * and always the single-quoted form.
123
+ */
124
+ function words(path) {
125
+ const quoted = `'${path.replaceAll("'", "'\\''")}'`;
126
+ return /^[\w./@+-]+$/u.test(path) ? [path, quoted] : [quoted];
127
+ }
128
+
129
+ /**
130
+ * The exact operator commands for this project, as the agent should type them.
131
+ * @param {string} root Project root.
132
+ * @returns {string[]} Admitted command texts; empty when the CLI is absent.
133
+ */
134
+ export function operatorCommands(root) {
135
+ if (!existsSync(MANAGER_CLI)) return [];
136
+ let real;
137
+ try {
138
+ real = realpathSync(root);
139
+ } catch {
140
+ return [];
141
+ }
142
+ return words(MANAGER_CLI).flatMap(cli =>
143
+ OPERATOR.flatMap(verb =>
144
+ words(real).map(dir => `node ${cli} ${verb} --project-root ${dir}`)
145
+ )
146
+ );
147
+ }
148
+
149
+ /**
150
+ * Whether a shell command is exactly one of the operator commands.
151
+ * @param {Record<string, any>} input Hook event.
152
+ * @param {{projectRoot: string}} cfg Task configuration.
153
+ * @returns {boolean} True to admit it.
154
+ */
155
+ export function operatorCommand(input, cfg) {
156
+ if (input?.tool_name !== "Bash") return false;
157
+ const command = input.tool_input?.command;
158
+ return (
159
+ typeof command === "string" &&
160
+ operatorCommands(cfg.projectRoot).includes(command)
161
+ );
162
+ }
163
+
164
+ /**
165
+ * The sentence an unbound refusal adds, naming the operator commands.
166
+ * @param {{projectRoot: string}} cfg Task configuration.
167
+ * @returns {string} The sentence, or "" when the CLI is absent.
168
+ */
169
+ export function operatorHint(cfg) {
170
+ const [first] = operatorCommands(cfg.projectRoot);
171
+ if (!first) return "";
172
+ const shape = first.replace(
173
+ " start --project-root ",
174
+ " <start|stop|status|validate> --project-root "
175
+ );
176
+ return `To start, stop or check on the session manager, which needs no ticket, run exactly: ${shape}.`;
177
+ }
@@ -30,7 +30,7 @@ const PATCH_TARGET =
30
30
  * @param {string} target Absolute path.
31
31
  * @returns {string|null} Resolved location, or null when unresolvable.
32
32
  */
33
- function realLocation(target) {
33
+ export function realLocation(target) {
34
34
  let existing = target;
35
35
  while (!existsSync(existing)) {
36
36
  // A link whose target is missing exists as an entry: writing through it
@@ -115,7 +115,7 @@ export function outsideEveryRepository(target, projectRoot) {
115
115
  * @param {Record<string, any>} input Hook event.
116
116
  * @returns {string[]|null} Target paths.
117
117
  */
118
- function writeTargets(input) {
118
+ export function writeTargets(input) {
119
119
  const args = input?.tool_input;
120
120
  if (!args || typeof args !== "object") return null;
121
121
  if (FILE_TOOLS.has(input.tool_name)) {
@@ -58,6 +58,11 @@ the manager.
58
58
  - **Project root.** `$ROOT` is the absolute directory the manager was started in, the one whose
59
59
  `.lisa.config.json` holds `sessionManager`. Pass `--project-root "$ROOT"` on **every** CLI call, so
60
60
  a stray `cd` can never send a ledger write into a child repo.
61
+ - **No ticket.** The manager binds no ticket; workers do. The readiness gate admits this session
62
+ because `start` launched it with `LISA_SESSION_MANAGER` set to its name, which workers never
63
+ inherit. It still may not edit project files outside `.lisa/`. From a session with no ticket
64
+ bound, an operator runs `start`, `stop`, `status` and `validate` by the exact absolute command
65
+ the gate's `work-item-unbound` refusal names (CodySwannGT/lisa#5211).
61
66
  - **Lifecycle roles.** Never hard-code a state or label name. Resolve each role you touch (`ready`,
62
67
  `claimed`, `blocked`) from config:
63
68
  `node "$SM/../../../scripts/resolve-lifecycle-role.mjs" --role <role> --vendor <tracker> --intent <read|write>`.
@@ -164,6 +164,11 @@ export function buildManagerLaunch({
164
164
  ...(telegram ? ["-e", `TELEGRAM_STATE_DIR=${stateDir}`] : []),
165
165
  "-e",
166
166
  `SM_SCRIPTS_DIR=${scriptsDir}`,
167
+ // Marks this session as the manager, which binds no ticket: the readiness
168
+ // gate lets it do operational work (#5211). A Bash export cannot set it,
169
+ // and scrubWorkerEnv keeps it from every worker.
170
+ "-e",
171
+ `LISA_SESSION_MANAGER=${name}`,
167
172
  "claude",
168
173
  "-n",
169
174
  name,
@@ -268,7 +268,11 @@ export function findLiveWorker(agents, ref) {
268
268
  */
269
269
  export function scrubWorkerEnv(env) {
270
270
  return Object.fromEntries(
271
- Object.entries(env).filter(([key]) => !key.startsWith("TELEGRAM_"))
271
+ Object.entries(env).filter(
272
+ // The manager mark (#5211) admits operational work with no ticket bound;
273
+ // a worker binds its own ticket and must stay gated.
274
+ ([key]) => !key.startsWith("TELEGRAM_") && key !== "LISA_SESSION_MANAGER"
275
+ )
272
276
  );
273
277
  }
274
278
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "8.10.6",
3
+ "version": "8.10.7",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -15,6 +15,11 @@ import {
15
15
  unboundWrite,
16
16
  } from "./task-unbound.mjs";
17
17
  import { staleBinding } from "./task-stale.mjs";
18
+ import {
19
+ managerSession,
20
+ operatorCommand,
21
+ operatorHint,
22
+ } from "./task-manager-session.mjs";
18
23
  import {
19
24
  linearIntakeRead,
20
25
  observeLinearIntake,
@@ -230,7 +235,12 @@ export function runTaskAction(argv = process.argv) {
230
235
  else if (hook && result.code === "no-active-task") {
231
236
  if (cfg.provenance?.status === "absent") return;
232
237
  if (unboundWrite(input, cfg)) return;
238
+ // The session manager binds no ticket; its own session and the
239
+ // operator's start/stop/status/validate stay possible (#5211).
240
+ if (managerSession(input, cfg) || operatorCommand(input, cfg)) return;
233
241
  result = unboundRefusal(cfg);
242
+ const hint = operatorHint(cfg);
243
+ if (hint) result.action += ` ${hint}`;
234
244
  } else if (hook && result.outcome === "NATIVE_OWNER_REQUIRED") {
235
245
  const decision = nativeAction(cfg, header, result, input);
236
246
  if (decision.allowed) result = { allowed: true, code: decision.code };
@@ -0,0 +1,177 @@
1
+ /**
2
+ * The session manager in a Lisa-managed project (CodySwannGT/lisa#5211).
3
+ *
4
+ * The readiness gate refuses project work from a session with no ticket
5
+ * bound. The session manager binds no ticket by design: it hands tickets to
6
+ * workers, and each worker binds its own. Its work is operational: reading
7
+ * the queue, spawning workers, writing its ledger. So two things are
8
+ * admitted here with no ticket bound.
9
+ *
10
+ * - The manager's own session. `start` marks it at launch with
11
+ * `LISA_SESSION_MANAGER=<name>`. Hooks inherit the Claude process's
12
+ * environment, which a Bash `export` inside the session cannot change, and
13
+ * workers are spawned without the mark. The mark must equal the project's
14
+ * configured `sessionManager.name`. The session may do anything except edit
15
+ * project files: a file-edit tool aimed inside the repository is admitted
16
+ * only under `.lisa/`, where the manager keeps its state.
17
+ * - The operator's exact `start`, `stop`, `status` and `validate` commands,
18
+ * from any session, so an operator can run and check on the manager.
19
+ *
20
+ * Nothing here imports the session-manager skill, which is not shipped to
21
+ * every agent: a missing import would fail the whole gate closed.
22
+ */
23
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
24
+ import { dirname, join, resolve, sep } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+ import {
27
+ outsideEveryRepository,
28
+ realLocation,
29
+ writeTargets,
30
+ } from "./task-unbound.mjs";
31
+
32
+ /** This install's session-manager CLI, beside this skill. */
33
+ export const MANAGER_CLI = join(
34
+ dirname(fileURLToPath(import.meta.url)),
35
+ "..",
36
+ "..",
37
+ "lisa-session-manager",
38
+ "scripts",
39
+ "session-manager.mjs"
40
+ );
41
+ const OPERATOR = ["start", "stop", "status", "validate"];
42
+ const EDIT_TOOLS = new Set([
43
+ "Write",
44
+ "Edit",
45
+ "MultiEdit",
46
+ "NotebookEdit",
47
+ "apply_patch",
48
+ "write",
49
+ "edit",
50
+ ]);
51
+
52
+ /**
53
+ * One parsed config file, or undefined when absent or unreadable.
54
+ * @param {string} path File path.
55
+ * @returns {Record<string, any>|undefined} Parsed object.
56
+ */
57
+ function readJson(path) {
58
+ try {
59
+ const value = JSON.parse(readFileSync(path, "utf8"));
60
+ return value && typeof value === "object" ? value : undefined;
61
+ } catch {
62
+ return undefined;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * The project's configured manager name, local config over committed.
68
+ * @param {string} root Project root.
69
+ * @returns {string|null} The name, or null when none is configured.
70
+ */
71
+ export function managerName(root) {
72
+ const name = [".lisa.config.local.json", ".lisa.config.json"]
73
+ .map(file => readJson(join(root, file))?.sessionManager?.name)
74
+ .find(value => value !== undefined);
75
+ return typeof name === "string" && name !== "" ? name : null;
76
+ }
77
+
78
+ /**
79
+ * Whether a resolved path is inside the project's `.lisa/` folder.
80
+ * @param {string} target Absolute path the tool names.
81
+ * @param {string} root Project root.
82
+ * @returns {boolean} True for a path under `.lisa/`.
83
+ */
84
+ function underLisaFolder(target, root) {
85
+ const location = realLocation(resolve(target));
86
+ let lisa;
87
+ try {
88
+ lisa = join(realpathSync(root), ".lisa");
89
+ } catch {
90
+ return false;
91
+ }
92
+ return Boolean(location?.startsWith(lisa + sep));
93
+ }
94
+
95
+ /**
96
+ * Whether this event comes from the project's marked manager session, and
97
+ * is not an edit to a project file.
98
+ * @param {Record<string, any>} input Hook event.
99
+ * @param {{projectRoot: string}} cfg Task configuration.
100
+ * @param {Record<string, string|undefined>} [env] Session environment.
101
+ * @returns {boolean} True to admit it.
102
+ */
103
+ export function managerSession(input, cfg, env = process.env) {
104
+ const mark = env.LISA_SESSION_MANAGER;
105
+ if (!mark || mark !== managerName(cfg.projectRoot)) return false;
106
+ if (!EDIT_TOOLS.has(input?.tool_name)) return true;
107
+ const targets = writeTargets(input);
108
+ return (
109
+ targets !== null &&
110
+ targets.every(
111
+ target =>
112
+ outsideEveryRepository(target, cfg.projectRoot) ||
113
+ underLisaFolder(target, cfg.projectRoot)
114
+ )
115
+ );
116
+ }
117
+
118
+ /**
119
+ * A path as the one shell word that names it.
120
+ * @param {string} path Absolute path.
121
+ * @returns {string[]} The plain form when the shell reads it as one word,
122
+ * and always the single-quoted form.
123
+ */
124
+ function words(path) {
125
+ const quoted = `'${path.replaceAll("'", "'\\''")}'`;
126
+ return /^[\w./@+-]+$/u.test(path) ? [path, quoted] : [quoted];
127
+ }
128
+
129
+ /**
130
+ * The exact operator commands for this project, as the agent should type them.
131
+ * @param {string} root Project root.
132
+ * @returns {string[]} Admitted command texts; empty when the CLI is absent.
133
+ */
134
+ export function operatorCommands(root) {
135
+ if (!existsSync(MANAGER_CLI)) return [];
136
+ let real;
137
+ try {
138
+ real = realpathSync(root);
139
+ } catch {
140
+ return [];
141
+ }
142
+ return words(MANAGER_CLI).flatMap(cli =>
143
+ OPERATOR.flatMap(verb =>
144
+ words(real).map(dir => `node ${cli} ${verb} --project-root ${dir}`)
145
+ )
146
+ );
147
+ }
148
+
149
+ /**
150
+ * Whether a shell command is exactly one of the operator commands.
151
+ * @param {Record<string, any>} input Hook event.
152
+ * @param {{projectRoot: string}} cfg Task configuration.
153
+ * @returns {boolean} True to admit it.
154
+ */
155
+ export function operatorCommand(input, cfg) {
156
+ if (input?.tool_name !== "Bash") return false;
157
+ const command = input.tool_input?.command;
158
+ return (
159
+ typeof command === "string" &&
160
+ operatorCommands(cfg.projectRoot).includes(command)
161
+ );
162
+ }
163
+
164
+ /**
165
+ * The sentence an unbound refusal adds, naming the operator commands.
166
+ * @param {{projectRoot: string}} cfg Task configuration.
167
+ * @returns {string} The sentence, or "" when the CLI is absent.
168
+ */
169
+ export function operatorHint(cfg) {
170
+ const [first] = operatorCommands(cfg.projectRoot);
171
+ if (!first) return "";
172
+ const shape = first.replace(
173
+ " start --project-root ",
174
+ " <start|stop|status|validate> --project-root "
175
+ );
176
+ return `To start, stop or check on the session manager, which needs no ticket, run exactly: ${shape}.`;
177
+ }
@@ -30,7 +30,7 @@ const PATCH_TARGET =
30
30
  * @param {string} target Absolute path.
31
31
  * @returns {string|null} Resolved location, or null when unresolvable.
32
32
  */
33
- function realLocation(target) {
33
+ export function realLocation(target) {
34
34
  let existing = target;
35
35
  while (!existsSync(existing)) {
36
36
  // A link whose target is missing exists as an entry: writing through it
@@ -115,7 +115,7 @@ export function outsideEveryRepository(target, projectRoot) {
115
115
  * @param {Record<string, any>} input Hook event.
116
116
  * @returns {string[]|null} Target paths.
117
117
  */
118
- function writeTargets(input) {
118
+ export function writeTargets(input) {
119
119
  const args = input?.tool_input;
120
120
  if (!args || typeof args !== "object") return null;
121
121
  if (FILE_TOOLS.has(input.tool_name)) {
@@ -58,6 +58,11 @@ the manager.
58
58
  - **Project root.** `$ROOT` is the absolute directory the manager was started in, the one whose
59
59
  `.lisa.config.json` holds `sessionManager`. Pass `--project-root "$ROOT"` on **every** CLI call, so
60
60
  a stray `cd` can never send a ledger write into a child repo.
61
+ - **No ticket.** The manager binds no ticket; workers do. The readiness gate admits this session
62
+ because `start` launched it with `LISA_SESSION_MANAGER` set to its name, which workers never
63
+ inherit. It still may not edit project files outside `.lisa/`. From a session with no ticket
64
+ bound, an operator runs `start`, `stop`, `status` and `validate` by the exact absolute command
65
+ the gate's `work-item-unbound` refusal names (CodySwannGT/lisa#5211).
61
66
  - **Lifecycle roles.** Never hard-code a state or label name. Resolve each role you touch (`ready`,
62
67
  `claimed`, `blocked`) from config:
63
68
  `node "$SM/../../../scripts/resolve-lifecycle-role.mjs" --role <role> --vendor <tracker> --intent <read|write>`.
@@ -164,6 +164,11 @@ export function buildManagerLaunch({
164
164
  ...(telegram ? ["-e", `TELEGRAM_STATE_DIR=${stateDir}`] : []),
165
165
  "-e",
166
166
  `SM_SCRIPTS_DIR=${scriptsDir}`,
167
+ // Marks this session as the manager, which binds no ticket: the readiness
168
+ // gate lets it do operational work (#5211). A Bash export cannot set it,
169
+ // and scrubWorkerEnv keeps it from every worker.
170
+ "-e",
171
+ `LISA_SESSION_MANAGER=${name}`,
167
172
  "claude",
168
173
  "-n",
169
174
  name,
@@ -268,7 +268,11 @@ export function findLiveWorker(agents, ref) {
268
268
  */
269
269
  export function scrubWorkerEnv(env) {
270
270
  return Object.fromEntries(
271
- Object.entries(env).filter(([key]) => !key.startsWith("TELEGRAM_"))
271
+ Object.entries(env).filter(
272
+ // The manager mark (#5211) admits operational work with no ticket bound;
273
+ // a worker binds its own ticket and must stay gated.
274
+ ([key]) => !key.startsWith("TELEGRAM_") && key !== "LISA_SESSION_MANAGER"
275
+ )
272
276
  );
273
277
  }
274
278
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.6",
3
+ "version": "8.10.7",
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": "8.10.6",
3
+ "version": "8.10.7",
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": "8.10.6",
3
+ "version": "8.10.7",
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": "8.10.6",
3
+ "version": "8.10.7",
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": "8.10.6",
3
+ "version": "8.10.7",
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": "8.10.6",
3
+ "version": "8.10.7",
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": "8.10.6",
3
+ "version": "8.10.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "8.10.6",
3
+ "version": "8.10.7",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -15,6 +15,11 @@ import {
15
15
  unboundWrite,
16
16
  } from "./task-unbound.mjs";
17
17
  import { staleBinding } from "./task-stale.mjs";
18
+ import {
19
+ managerSession,
20
+ operatorCommand,
21
+ operatorHint,
22
+ } from "./task-manager-session.mjs";
18
23
  import {
19
24
  linearIntakeRead,
20
25
  observeLinearIntake,
@@ -230,7 +235,12 @@ export function runTaskAction(argv = process.argv) {
230
235
  else if (hook && result.code === "no-active-task") {
231
236
  if (cfg.provenance?.status === "absent") return;
232
237
  if (unboundWrite(input, cfg)) return;
238
+ // The session manager binds no ticket; its own session and the
239
+ // operator's start/stop/status/validate stay possible (#5211).
240
+ if (managerSession(input, cfg) || operatorCommand(input, cfg)) return;
233
241
  result = unboundRefusal(cfg);
242
+ const hint = operatorHint(cfg);
243
+ if (hint) result.action += ` ${hint}`;
234
244
  } else if (hook && result.outcome === "NATIVE_OWNER_REQUIRED") {
235
245
  const decision = nativeAction(cfg, header, result, input);
236
246
  if (decision.allowed) result = { allowed: true, code: decision.code };