@codyswann/lisa 8.10.5 → 8.10.6
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 +15 -2
- 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 +23 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-action.mjs +23 -1
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-action.mjs +23 -1
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- 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 +23 -1
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- 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 +23 -1
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- 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 +23 -1
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
- 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 +23 -1
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-stale.mjs +112 -0
|
@@ -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,7 @@ import {
|
|
|
14
14
|
unboundRefusal,
|
|
15
15
|
unboundWrite,
|
|
16
16
|
} from "./task-unbound.mjs";
|
|
17
|
+
import { staleBinding } from "./task-stale.mjs";
|
|
17
18
|
import {
|
|
18
19
|
linearIntakeRead,
|
|
19
20
|
observeLinearIntake,
|
|
@@ -177,7 +178,28 @@ export function runTaskAction(argv = process.argv) {
|
|
|
177
178
|
}
|
|
178
179
|
const refIndex = argv.indexOf("--ref"),
|
|
179
180
|
ref = refIndex >= 0 ? argv[refIndex + 1] : undefined;
|
|
180
|
-
|
|
181
|
+
let header;
|
|
182
|
+
try {
|
|
183
|
+
header = readTaskRequirements(cfg, { ref });
|
|
184
|
+
} catch (error) {
|
|
185
|
+
// A stale binding keeps its ways out instead of locking the session
|
|
186
|
+
// (#5203): a scratch input file for prepare, and `clear`.
|
|
187
|
+
const stale =
|
|
188
|
+
hook &&
|
|
189
|
+
input?.hook_event_name === "PreToolUse" &&
|
|
190
|
+
error instanceof AccessFailure &&
|
|
191
|
+
error.code === "requirements-stale"
|
|
192
|
+
? staleBinding(input, cfg)
|
|
193
|
+
: null;
|
|
194
|
+
if (!stale) throw error;
|
|
195
|
+
// Rotate the native epoch as the stale refusal always did, so no
|
|
196
|
+
// earlier ready state outlives the stale read.
|
|
197
|
+
resetNativeEvent(input);
|
|
198
|
+
if (stale.allowed) return;
|
|
199
|
+
console.error(`${stale.code}: ${stale.action}`);
|
|
200
|
+
process.exitCode = 2;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
181
203
|
if (
|
|
182
204
|
hook &&
|
|
183
205
|
!header &&
|
|
@@ -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
|
+
}
|
|
@@ -22,6 +22,8 @@ Answering a question about a ticket needs none of this. Never bind a ticket just
|
|
|
22
22
|
|
|
23
23
|
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.
|
|
24
24
|
|
|
25
|
+
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.
|
|
26
|
+
|
|
25
27
|
## Resolve, claim, bind
|
|
26
28
|
|
|
27
29
|
Use `lisa-track` as the single entry point:
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
unboundRefusal,
|
|
15
15
|
unboundWrite,
|
|
16
16
|
} from "./task-unbound.mjs";
|
|
17
|
+
import { staleBinding } from "./task-stale.mjs";
|
|
17
18
|
import {
|
|
18
19
|
linearIntakeRead,
|
|
19
20
|
observeLinearIntake,
|
|
@@ -177,7 +178,28 @@ export function runTaskAction(argv = process.argv) {
|
|
|
177
178
|
}
|
|
178
179
|
const refIndex = argv.indexOf("--ref"),
|
|
179
180
|
ref = refIndex >= 0 ? argv[refIndex + 1] : undefined;
|
|
180
|
-
|
|
181
|
+
let header;
|
|
182
|
+
try {
|
|
183
|
+
header = readTaskRequirements(cfg, { ref });
|
|
184
|
+
} catch (error) {
|
|
185
|
+
// A stale binding keeps its ways out instead of locking the session
|
|
186
|
+
// (#5203): a scratch input file for prepare, and `clear`.
|
|
187
|
+
const stale =
|
|
188
|
+
hook &&
|
|
189
|
+
input?.hook_event_name === "PreToolUse" &&
|
|
190
|
+
error instanceof AccessFailure &&
|
|
191
|
+
error.code === "requirements-stale"
|
|
192
|
+
? staleBinding(input, cfg)
|
|
193
|
+
: null;
|
|
194
|
+
if (!stale) throw error;
|
|
195
|
+
// Rotate the native epoch as the stale refusal always did, so no
|
|
196
|
+
// earlier ready state outlives the stale read.
|
|
197
|
+
resetNativeEvent(input);
|
|
198
|
+
if (stale.allowed) return;
|
|
199
|
+
console.error(`${stale.code}: ${stale.action}`);
|
|
200
|
+
process.exitCode = 2;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
181
203
|
if (
|
|
182
204
|
hook &&
|
|
183
205
|
!header &&
|
|
@@ -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
|
+
}
|
|
@@ -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,7 @@ import {
|
|
|
14
14
|
unboundRefusal,
|
|
15
15
|
unboundWrite,
|
|
16
16
|
} from "./task-unbound.mjs";
|
|
17
|
+
import { staleBinding } from "./task-stale.mjs";
|
|
17
18
|
import {
|
|
18
19
|
linearIntakeRead,
|
|
19
20
|
observeLinearIntake,
|
|
@@ -177,7 +178,28 @@ export function runTaskAction(argv = process.argv) {
|
|
|
177
178
|
}
|
|
178
179
|
const refIndex = argv.indexOf("--ref"),
|
|
179
180
|
ref = refIndex >= 0 ? argv[refIndex + 1] : undefined;
|
|
180
|
-
|
|
181
|
+
let header;
|
|
182
|
+
try {
|
|
183
|
+
header = readTaskRequirements(cfg, { ref });
|
|
184
|
+
} catch (error) {
|
|
185
|
+
// A stale binding keeps its ways out instead of locking the session
|
|
186
|
+
// (#5203): a scratch input file for prepare, and `clear`.
|
|
187
|
+
const stale =
|
|
188
|
+
hook &&
|
|
189
|
+
input?.hook_event_name === "PreToolUse" &&
|
|
190
|
+
error instanceof AccessFailure &&
|
|
191
|
+
error.code === "requirements-stale"
|
|
192
|
+
? staleBinding(input, cfg)
|
|
193
|
+
: null;
|
|
194
|
+
if (!stale) throw error;
|
|
195
|
+
// Rotate the native epoch as the stale refusal always did, so no
|
|
196
|
+
// earlier ready state outlives the stale read.
|
|
197
|
+
resetNativeEvent(input);
|
|
198
|
+
if (stale.allowed) return;
|
|
199
|
+
console.error(`${stale.code}: ${stale.action}`);
|
|
200
|
+
process.exitCode = 2;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
181
203
|
if (
|
|
182
204
|
hook &&
|
|
183
205
|
!header &&
|
|
@@ -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
|
+
}
|