@codyswann/lisa 8.10.5 → 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.
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.json +33 -6
- 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-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/workers.mjs +5 -1
- package/plugins/lisa/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/workers.mjs +5 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/workers.mjs +5 -1
- 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/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/workers.mjs +5 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/rules/tracked-work-reference.mdc +2 -0
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/workers.mjs +5 -1
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/workers.mjs +5 -1
- 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-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/rules/reference/tracked-work.md +2 -0
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-action.mjs +33 -1
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-manager-session.mjs +177 -0
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-unbound.mjs +2 -2
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +5 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/launch.mjs +5 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/workers.mjs +5 -1
|
@@ -17,6 +17,8 @@ Answering a question about a ticket needs none of this. Never bind a ticket just
|
|
|
17
17
|
|
|
18
18
|
To start work on an existing ticket from an unbound session, prepare it first, then bind it. Write the prepare JSON to a file outside every repository, then run the admitted `preflight-secrets.mjs --prepare --ref <ticket> --input-file <absolute path>` (see `tool-access-gate`). Once the ticket is prepared, the guard decides by that ticket's readiness, and `lisa-work-item.mjs link`, the claim and the work run normally.
|
|
19
19
|
|
|
20
|
+
A bound ticket's requirements go stale when its `.lisa/work-item-context.md` is removed, or when the project configuration changes after it was prepared (a pull can do that). The guard then refuses project work with `requirements-stale`, naming the cause, and still admits the two ways out: a write outside every repository, for the prepare input, and the exact `node scripts/lisa-work-item.mjs clear` from the project root. Refresh a ticket still in progress with the admitted prepare command; clear a finished one.
|
|
21
|
+
|
|
20
22
|
## Resolve, claim, bind
|
|
21
23
|
|
|
22
24
|
Use `lisa-track` as the single entry point:
|
|
@@ -14,6 +14,12 @@ import {
|
|
|
14
14
|
unboundRefusal,
|
|
15
15
|
unboundWrite,
|
|
16
16
|
} from "./task-unbound.mjs";
|
|
17
|
+
import { staleBinding } from "./task-stale.mjs";
|
|
18
|
+
import {
|
|
19
|
+
managerSession,
|
|
20
|
+
operatorCommand,
|
|
21
|
+
operatorHint,
|
|
22
|
+
} from "./task-manager-session.mjs";
|
|
17
23
|
import {
|
|
18
24
|
linearIntakeRead,
|
|
19
25
|
observeLinearIntake,
|
|
@@ -177,7 +183,28 @@ export function runTaskAction(argv = process.argv) {
|
|
|
177
183
|
}
|
|
178
184
|
const refIndex = argv.indexOf("--ref"),
|
|
179
185
|
ref = refIndex >= 0 ? argv[refIndex + 1] : undefined;
|
|
180
|
-
|
|
186
|
+
let header;
|
|
187
|
+
try {
|
|
188
|
+
header = readTaskRequirements(cfg, { ref });
|
|
189
|
+
} catch (error) {
|
|
190
|
+
// A stale binding keeps its ways out instead of locking the session
|
|
191
|
+
// (#5203): a scratch input file for prepare, and `clear`.
|
|
192
|
+
const stale =
|
|
193
|
+
hook &&
|
|
194
|
+
input?.hook_event_name === "PreToolUse" &&
|
|
195
|
+
error instanceof AccessFailure &&
|
|
196
|
+
error.code === "requirements-stale"
|
|
197
|
+
? staleBinding(input, cfg)
|
|
198
|
+
: null;
|
|
199
|
+
if (!stale) throw error;
|
|
200
|
+
// Rotate the native epoch as the stale refusal always did, so no
|
|
201
|
+
// earlier ready state outlives the stale read.
|
|
202
|
+
resetNativeEvent(input);
|
|
203
|
+
if (stale.allowed) return;
|
|
204
|
+
console.error(`${stale.code}: ${stale.action}`);
|
|
205
|
+
process.exitCode = 2;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
181
208
|
if (
|
|
182
209
|
hook &&
|
|
183
210
|
!header &&
|
|
@@ -208,7 +235,12 @@ export function runTaskAction(argv = process.argv) {
|
|
|
208
235
|
else if (hook && result.code === "no-active-task") {
|
|
209
236
|
if (cfg.provenance?.status === "absent") return;
|
|
210
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;
|
|
211
241
|
result = unboundRefusal(cfg);
|
|
242
|
+
const hint = operatorHint(cfg);
|
|
243
|
+
if (hint) result.action += ` ${hint}`;
|
|
212
244
|
} else if (hook && result.outcome === "NATIVE_OWNER_REQUIRED") {
|
|
213
245
|
const decision = nativeAction(cfg, header, result, input);
|
|
214
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
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a session bound to a ticket whose requirements went stale may still do
|
|
3
|
+
* (CodySwannGT/lisa#5203).
|
|
4
|
+
*
|
|
5
|
+
* A bound ticket's requirements header goes stale when its context file is
|
|
6
|
+
* removed, or when the project configuration changes under it (a pull of
|
|
7
|
+
* `main` can do that). Until this module, a stale binding refused everything
|
|
8
|
+
* except orientation, including the two ways out: a scratch file for the
|
|
9
|
+
* prepare step's input, and `clear`. Only a person could end the session's
|
|
10
|
+
* lockout. Both ways out change no project work, so they stay possible. All
|
|
11
|
+
* other work is still refused, because a stale binding proves no access.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { taskBinding } from "./task-requirements.mjs";
|
|
17
|
+
import { unboundWrite } from "./task-unbound.mjs";
|
|
18
|
+
|
|
19
|
+
const owner = join(
|
|
20
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
21
|
+
"preflight-secrets.mjs"
|
|
22
|
+
);
|
|
23
|
+
const CONTEXT = ".lisa/work-item-context.md";
|
|
24
|
+
const CLEAR = "scripts/lisa-work-item.mjs clear";
|
|
25
|
+
const shownRef =
|
|
26
|
+
/^(?:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+#\d+|[A-Z][A-Z0-9]+-\d+)$/u;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The binding of this checkout, or null when none is readable.
|
|
30
|
+
* @param {string} root Project root.
|
|
31
|
+
* @returns {{ref?: unknown}|null} The binding.
|
|
32
|
+
*/
|
|
33
|
+
function binding(root) {
|
|
34
|
+
try {
|
|
35
|
+
return taskBinding(root) ?? null;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The real path of a directory, or null.
|
|
43
|
+
* @param {unknown} dir Directory.
|
|
44
|
+
* @returns {string|null} Its real path.
|
|
45
|
+
*/
|
|
46
|
+
function real(dir) {
|
|
47
|
+
try {
|
|
48
|
+
return typeof dir === "string" ? realpathSync(dir) : null;
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Whether a shell command is exactly the work-item `clear` of this project.
|
|
56
|
+
*
|
|
57
|
+
* `clear` acts on the checkout it runs in, not the one its script lives in,
|
|
58
|
+
* so it is admitted only when run from the stale checkout's root. From
|
|
59
|
+
* anywhere else it would clear some other checkout's binding.
|
|
60
|
+
* @param {Record<string, any>} input Hook event.
|
|
61
|
+
* @param {string} root Project root.
|
|
62
|
+
* @returns {boolean} True for the exact relative form, the exact absolute
|
|
63
|
+
* form, or the absolute form shell-quoted, each run from the root.
|
|
64
|
+
*/
|
|
65
|
+
function clearCommand(input, root) {
|
|
66
|
+
if (input?.tool_name !== "Bash") return false;
|
|
67
|
+
const command = input.tool_input?.command;
|
|
68
|
+
const projectRoot = real(root);
|
|
69
|
+
if (typeof command !== "string" || !projectRoot) return false;
|
|
70
|
+
if (real(input.cwd) !== projectRoot) return false;
|
|
71
|
+
const [script, verb] = CLEAR.split(" ");
|
|
72
|
+
const absolute = join(projectRoot, script);
|
|
73
|
+
return [
|
|
74
|
+
`node ${CLEAR}`,
|
|
75
|
+
// Unquoted only when the shell reads the path as one word.
|
|
76
|
+
...(/^[\w./@+-]+$/u.test(absolute) ? [`node ${absolute} ${verb}`] : []),
|
|
77
|
+
`node '${absolute.replaceAll("'", "'\\''")}' ${verb}`,
|
|
78
|
+
].includes(command);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The guard's decision for a stale binding: admit the ways out, refuse the
|
|
83
|
+
* rest naming the cause and both exits. Null when nothing is bound, so the
|
|
84
|
+
* caller keeps its ordinary refusal.
|
|
85
|
+
* @param {Record<string, any>} input Hook event.
|
|
86
|
+
* @param {{projectRoot: string}} cfg Task configuration.
|
|
87
|
+
* @returns {{allowed: true}|{allowed: false, code: string, action: string}|null}
|
|
88
|
+
* The decision.
|
|
89
|
+
*/
|
|
90
|
+
export function staleBinding(input, cfg) {
|
|
91
|
+
const bound = binding(cfg.projectRoot);
|
|
92
|
+
if (!bound) return null;
|
|
93
|
+
if (unboundWrite(input, cfg) || clearCommand(input, cfg.projectRoot))
|
|
94
|
+
return { allowed: true };
|
|
95
|
+
const ref =
|
|
96
|
+
typeof bound.ref === "string" && shownRef.test(bound.ref)
|
|
97
|
+
? bound.ref
|
|
98
|
+
: "<bound ticket>";
|
|
99
|
+
const cause = existsSync(join(cfg.projectRoot, CONTEXT))
|
|
100
|
+
? `its ${CONTEXT} no longer matches this checkout (the project configuration or the file changed after it was prepared)`
|
|
101
|
+
: `its ${CONTEXT} is missing`;
|
|
102
|
+
return {
|
|
103
|
+
allowed: false,
|
|
104
|
+
code: "requirements-stale",
|
|
105
|
+
action: [
|
|
106
|
+
`This checkout is bound to ${ref}, but ${cause}, so no access is proved and project work is refused.`,
|
|
107
|
+
`If ${ref} is still being worked on, refresh it: write {"requirements_complete": true, "required_access": []} to a file outside every repository (add "context_body" with the ticket's full text if the context file is missing), then run exactly: node ${owner} --prepare --ref ${ref} --input-file <absolute path of that file>.`,
|
|
108
|
+
`If ${ref} is finished, run exactly: node ${CLEAR}, from the project root.`,
|
|
109
|
+
"Reading with the Read, Grep and Glob tools, and writing a file outside every git repository, stay allowed.",
|
|
110
|
+
].join(" "),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -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(
|
|
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
|
|