@codyswann/lisa 8.10.1 → 8.10.3
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 +13 -6
- package/dist/opencode/plugin-templates/task-readiness-guard.mjs +1 -1
- 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/preflight-secrets.mjs +8 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
- package/plugins/lisa/hooks/task-readiness-guard.mjs +1 -1
- package/plugins/lisa/rules/reference/tool-access-gate.md +7 -2
- package/plugins/lisa/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +8 -1
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/lisa/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +8 -1
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
- 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/hooks/task-readiness-guard.mjs +1 -1
- package/plugins/lisa-copilot/rules/reference/tool-access-gate.md +7 -2
- package/plugins/lisa-copilot/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +8 -1
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/task-readiness-guard.mjs +1 -1
- package/plugins/lisa-cursor/rules/tool-access-gate-reference.mdc +7 -2
- package/plugins/lisa-cursor/rules/tracked-work-reference.mdc +2 -0
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +8 -1
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/hooks/task-readiness-guard.mjs +1 -1
- package/plugins/lisa-devin/rules/reference/tool-access-gate.md +7 -2
- package/plugins/lisa-devin/rules/reference/tracked-work.md +2 -0
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +8 -1
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
- 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/hooks/task-readiness-guard.mjs +1 -1
- package/plugins/src/base/rules/reference/tool-access-gate.md +7 -2
- package/plugins/src/base/rules/reference/tracked-work.md +2 -0
- package/plugins/src/base/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +8 -1
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-action.mjs +28 -6
- package/plugins/src/base/skills/lisa-secrets-access/scripts/task-unbound.mjs +45 -6
|
@@ -9,7 +9,11 @@ import { readTaskRequirements } from "./task-requirements.mjs";
|
|
|
9
9
|
import { lifecycleEvents, resetNativeEvent } from "./task-native-lifecycle.mjs";
|
|
10
10
|
import { intakeRead } from "./task-intake.mjs";
|
|
11
11
|
import { nativeContext } from "./task-native-context.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
outsideEveryRepository,
|
|
14
|
+
unboundRefusal,
|
|
15
|
+
unboundWrite,
|
|
16
|
+
} from "./task-unbound.mjs";
|
|
13
17
|
import {
|
|
14
18
|
linearIntakeRead,
|
|
15
19
|
observeLinearIntake,
|
|
@@ -26,17 +30,35 @@ const owner = join(
|
|
|
26
30
|
const refs = /^(?:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+#\d+|[A-Z][A-Z0-9]+-\d+)$/;
|
|
27
31
|
const quote = path => `'${path.replaceAll("'", "'\\''")}'`;
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
33
|
+
/** A file path that a shell reads as exactly one plain word. */
|
|
34
|
+
const plainPath = /^\/[A-Za-z0-9_./@+-]+$/;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Exact canonical recovery command. JSON uses structured child/terminal
|
|
38
|
+
* stdin, or a file outside every repository that an agent's shell tool can
|
|
39
|
+
* name, since it has no stdin to supply.
|
|
40
|
+
* @param {unknown} command Shell command text.
|
|
41
|
+
* @param {string} [root] Project root, for the input file's location check.
|
|
42
|
+
* @returns {boolean} True for an exact recovery command.
|
|
43
|
+
*/
|
|
44
|
+
export function readinessOwnerInvocation(command, root = process.cwd()) {
|
|
31
45
|
if (typeof command !== "string") return false;
|
|
32
46
|
for (const runtime of ["node", process.execPath, quote(process.execPath)])
|
|
33
47
|
for (const script of [owner, quote(owner)]) {
|
|
34
48
|
if (command === `${runtime} ${script} --task`) return true;
|
|
35
49
|
for (const mode of ["task", "prepare"]) {
|
|
36
50
|
const prefix = `${runtime} ${script} --${mode} --ref `;
|
|
51
|
+
if (!command.startsWith(prefix)) continue;
|
|
52
|
+
const rest = command.slice(prefix.length);
|
|
53
|
+
if (refs.test(rest)) return true;
|
|
54
|
+
const [ref, flag, file, ...extra] = rest.split(" ");
|
|
37
55
|
if (
|
|
38
|
-
|
|
39
|
-
refs.test(
|
|
56
|
+
mode === "prepare" &&
|
|
57
|
+
refs.test(ref) &&
|
|
58
|
+
flag === "--input-file" &&
|
|
59
|
+
extra.length === 0 &&
|
|
60
|
+
plainPath.test(file ?? "") &&
|
|
61
|
+
outsideEveryRepository(file, root)
|
|
40
62
|
)
|
|
41
63
|
return true;
|
|
42
64
|
}
|
|
@@ -52,7 +74,7 @@ function orientation(input) {
|
|
|
52
74
|
return true;
|
|
53
75
|
if (input?.tool_name !== "Bash") return false;
|
|
54
76
|
return (
|
|
55
|
-
readinessOwnerInvocation(input.tool_input?.command) ||
|
|
77
|
+
readinessOwnerInvocation(input.tool_input?.command, input.cwd) ||
|
|
56
78
|
[
|
|
57
79
|
"pwd",
|
|
58
80
|
"ls -la",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* an agent's scratch or memory file. The refusal names the read command for
|
|
9
9
|
* this installation, because an agent cannot guess an absolute plugin path.
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
11
|
+
import { existsSync, lstatSync, realpathSync, statSync } from "node:fs";
|
|
12
12
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
14
|
import {
|
|
@@ -33,6 +33,14 @@ const PATCH_TARGET =
|
|
|
33
33
|
function realLocation(target) {
|
|
34
34
|
let existing = target;
|
|
35
35
|
while (!existsSync(existing)) {
|
|
36
|
+
// A link whose target is missing exists as an entry: writing through it
|
|
37
|
+
// creates the target, wherever that is. It is never a new file.
|
|
38
|
+
try {
|
|
39
|
+
lstatSync(existing);
|
|
40
|
+
return null;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error.code !== "ENOENT") return null;
|
|
43
|
+
}
|
|
36
44
|
const parent = dirname(existing);
|
|
37
45
|
if (parent === existing) return null;
|
|
38
46
|
existing = parent;
|
|
@@ -45,7 +53,26 @@ function realLocation(target) {
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
/**
|
|
48
|
-
* Whether
|
|
56
|
+
* Whether `dir` is itself a git directory: a bare repository, or the inside
|
|
57
|
+
* of a `.git` folder. Git recognises one by `HEAD`, `objects` and `refs`.
|
|
58
|
+
* @param {string} dir Directory to inspect.
|
|
59
|
+
* @returns {boolean} True when it has that layout.
|
|
60
|
+
*/
|
|
61
|
+
function gitDirectory(dir) {
|
|
62
|
+
try {
|
|
63
|
+
return (
|
|
64
|
+
statSync(join(dir, "HEAD")).isFile() &&
|
|
65
|
+
statSync(join(dir, "objects")).isDirectory() &&
|
|
66
|
+
statSync(join(dir, "refs")).isDirectory()
|
|
67
|
+
);
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether any directory from `location` up to the root holds `.git` or is
|
|
75
|
+
* itself a git directory.
|
|
49
76
|
* @param {string} location Resolved absolute path.
|
|
50
77
|
* @returns {boolean} True when the path is inside a git repository.
|
|
51
78
|
*/
|
|
@@ -57,6 +84,7 @@ function insideRepository(location) {
|
|
|
57
84
|
} catch (error) {
|
|
58
85
|
if (!["ENOENT", "ENOTDIR"].includes(error.code)) return true;
|
|
59
86
|
}
|
|
87
|
+
if (gitDirectory(dir)) return true;
|
|
60
88
|
if (dirname(dir) === dir) return false;
|
|
61
89
|
}
|
|
62
90
|
}
|
|
@@ -99,7 +127,9 @@ function writeTargets(input) {
|
|
|
99
127
|
if (input.tool_name === "apply_patch" && typeof args.command === "string") {
|
|
100
128
|
const targets = args.command
|
|
101
129
|
.split("\n")
|
|
102
|
-
|
|
130
|
+
// The patch tool trims each header before acting on it, so the check
|
|
131
|
+
// must too, or an indented header is applied without being seen.
|
|
132
|
+
.map(line => PATCH_TARGET.exec(line.trim())?.[1])
|
|
103
133
|
.filter(Boolean);
|
|
104
134
|
return targets.length ? targets : null;
|
|
105
135
|
}
|
|
@@ -120,6 +150,16 @@ export function unboundWrite(input, cfg) {
|
|
|
120
150
|
);
|
|
121
151
|
}
|
|
122
152
|
|
|
153
|
+
/**
|
|
154
|
+
* This installation's prepare/read owner script as one shell word.
|
|
155
|
+
* @returns {string} The path, quoted only when it needs to be.
|
|
156
|
+
*/
|
|
157
|
+
function ownerWord() {
|
|
158
|
+
return /^[\w./@+-]+$/.test(owner)
|
|
159
|
+
? owner
|
|
160
|
+
: `'${owner.replaceAll("'", "'\\''")}'`;
|
|
161
|
+
}
|
|
162
|
+
|
|
123
163
|
/**
|
|
124
164
|
* The exact read command this installation admits with no work item bound.
|
|
125
165
|
* @param {Record<string, any>} cfg Task configuration.
|
|
@@ -127,9 +167,7 @@ export function unboundWrite(input, cfg) {
|
|
|
127
167
|
*/
|
|
128
168
|
function readCommand(cfg) {
|
|
129
169
|
const c = cfg.effective ?? {};
|
|
130
|
-
const script =
|
|
131
|
-
? owner
|
|
132
|
-
: `'${owner.replaceAll("'", "'\\''")}'`;
|
|
170
|
+
const script = ownerWord();
|
|
133
171
|
if (c.tracker === "linear" && c.linear?.teamKey)
|
|
134
172
|
return `node ${script} --tracker-intake-read --ref ${c.linear.teamKey}-<number> --read issue`;
|
|
135
173
|
if (c.tracker === "jira" && c.jira?.project)
|
|
@@ -162,6 +200,7 @@ export function unboundRefusal(cfg) {
|
|
|
162
200
|
: "",
|
|
163
201
|
"A file written outside every git repository, such as a scratch or memory file, is allowed.",
|
|
164
202
|
"To change anything in this project, bind its ticket first with lisa-track.",
|
|
203
|
+
`Its prepare step needs no shell input: write the prepare JSON to a file outside every repository, then run exactly: node ${ownerWord()} --prepare --ref <ticket> --input-file <absolute path of that file>.`,
|
|
165
204
|
]
|
|
166
205
|
.filter(Boolean)
|
|
167
206
|
.join(" "),
|
|
@@ -76,7 +76,7 @@ try {
|
|
|
76
76
|
} else if (result.status !== 0) {
|
|
77
77
|
// Only the fixed owner result is published. Environment errors never echo.
|
|
78
78
|
const safe =
|
|
79
|
-
/^(?:credential-missing|provider-unreachable|capability-unreachable|bootstrap-missing|tool-missing|config-invalid|config-unreadable|config-undiscovered|config-unknown|identity-mismatch|adapter-unsupported|requirements-stale|requirements-prepared|native-proof-needed|native-response-unrepresented): [^\n]*\n?$/.test(
|
|
79
|
+
/^(?:credential-missing|provider-unreachable|capability-unreachable|bootstrap-missing|tool-missing|config-invalid|config-unreadable|config-undiscovered|config-unknown|identity-mismatch|adapter-unsupported|requirements-stale|work-item-unbound|requirements-prepared|native-proof-needed|native-response-unrepresented): [^\n]*\n?$/.test(
|
|
80
80
|
result.stderr ?? ""
|
|
81
81
|
);
|
|
82
82
|
console.error(
|
|
@@ -23,7 +23,11 @@ the resolver or read its inputs.
|
|
|
23
23
|
|
|
24
24
|
Supply a complete values-free `required_access` array and
|
|
25
25
|
`requirements_complete: true` as JSON on stdin to the owner's
|
|
26
|
-
`--prepare --ref <canonical-ref>` mode.
|
|
26
|
+
`--prepare --ref <canonical-ref>` mode. An agent's shell tool has no stdin:
|
|
27
|
+
write the same JSON to a file outside every git repository (such a write is
|
|
28
|
+
admitted with no ticket bound) and run exactly
|
|
29
|
+
`node <owner>/preflight-secrets.mjs --prepare --ref <canonical-ref> --input-file <absolute path>`.
|
|
30
|
+
The path is one plain word; nothing may follow it. For the first context, include the complete
|
|
27
31
|
unedited `context_body` on that same stdin; it creates
|
|
28
32
|
only the fixed ignored0600 context after Git-ignore and EAS checks. Existing
|
|
29
33
|
context cannot be replaced through `context_body`. This is the bounded initial
|
|
@@ -92,7 +96,8 @@ reflect requirement identifiers/resources/paths, parse errors or provider output
|
|
|
92
96
|
Do not block unrelated tasks or require optional integrations universally.
|
|
93
97
|
|
|
94
98
|
The exact readiness owner command (`node <owner>/preflight-secrets.mjs --task
|
|
95
|
-
--ref <canonical-ref>`, or `--prepare` with that ref and JSON on terminal stdin
|
|
99
|
+
--ref <canonical-ref>`, or `--prepare` with that ref and JSON on terminal stdin
|
|
100
|
+
or in an `--input-file` outside every repository)
|
|
96
101
|
remains available during refusal. It grants no work: task mode still reports its
|
|
97
102
|
real verdict, and preparation only refreshes the ignored requirements metadata.
|
|
98
103
|
Only the exact native context Write/Add File forms above carry private metadata.
|
|
@@ -14,6 +14,8 @@ In a project with `.lisa.config.json`, the task-readiness guard enforces this. W
|
|
|
14
14
|
|
|
15
15
|
Answering a question about a ticket needs none of this. Never bind a ticket just to read one.
|
|
16
16
|
|
|
17
|
+
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.
|
|
18
|
+
|
|
17
19
|
## Resolve, claim, bind
|
|
18
20
|
|
|
19
21
|
Use `lisa-track` as the single entry point:
|
|
@@ -42,6 +42,7 @@ import { failure } from "./task-readiness.mjs";
|
|
|
42
42
|
import { runTaskAction } from "./task-action.mjs";
|
|
43
43
|
import { AccessFailure } from "./config-layers.mjs";
|
|
44
44
|
import { prepareRequirements } from "./task-requirements.mjs";
|
|
45
|
+
import { outsideEveryRepository } from "./task-unbound.mjs";
|
|
45
46
|
import { runIntakeRead } from "./task-intake-read.mjs";
|
|
46
47
|
import { runTrackerIntakeRead } from "./task-tracker-intake.mjs";
|
|
47
48
|
export { taskReadiness, credentialAvailability } from "./task-readiness.mjs";
|
|
@@ -367,7 +368,13 @@ function main() {
|
|
|
367
368
|
if (process.argv.includes("--prepare")) {
|
|
368
369
|
const cfg = readTaskConfig();
|
|
369
370
|
const index = process.argv.indexOf("--ref");
|
|
370
|
-
const
|
|
371
|
+
const fileIndex = process.argv.indexOf("--input-file");
|
|
372
|
+
// An agent's shell tool has no stdin. It writes the JSON to a file outside
|
|
373
|
+
// every repository (admitted while unbound) and names it here instead.
|
|
374
|
+
const file = fileIndex >= 0 ? process.argv[fileIndex + 1] : undefined;
|
|
375
|
+
if (fileIndex >= 0 && !outsideEveryRepository(file, cfg.projectRoot))
|
|
376
|
+
throw new AccessFailure("requirements-stale");
|
|
377
|
+
const input = JSON.parse(readFileSync(fileIndex >= 0 ? file : 0, "utf8"));
|
|
371
378
|
console.log(
|
|
372
379
|
JSON.stringify(
|
|
373
380
|
prepareRequirements(
|
|
@@ -9,7 +9,11 @@ import { readTaskRequirements } from "./task-requirements.mjs";
|
|
|
9
9
|
import { lifecycleEvents, resetNativeEvent } from "./task-native-lifecycle.mjs";
|
|
10
10
|
import { intakeRead } from "./task-intake.mjs";
|
|
11
11
|
import { nativeContext } from "./task-native-context.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
outsideEveryRepository,
|
|
14
|
+
unboundRefusal,
|
|
15
|
+
unboundWrite,
|
|
16
|
+
} from "./task-unbound.mjs";
|
|
13
17
|
import {
|
|
14
18
|
linearIntakeRead,
|
|
15
19
|
observeLinearIntake,
|
|
@@ -26,17 +30,35 @@ const owner = join(
|
|
|
26
30
|
const refs = /^(?:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+#\d+|[A-Z][A-Z0-9]+-\d+)$/;
|
|
27
31
|
const quote = path => `'${path.replaceAll("'", "'\\''")}'`;
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
33
|
+
/** A file path that a shell reads as exactly one plain word. */
|
|
34
|
+
const plainPath = /^\/[A-Za-z0-9_./@+-]+$/;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Exact canonical recovery command. JSON uses structured child/terminal
|
|
38
|
+
* stdin, or a file outside every repository that an agent's shell tool can
|
|
39
|
+
* name, since it has no stdin to supply.
|
|
40
|
+
* @param {unknown} command Shell command text.
|
|
41
|
+
* @param {string} [root] Project root, for the input file's location check.
|
|
42
|
+
* @returns {boolean} True for an exact recovery command.
|
|
43
|
+
*/
|
|
44
|
+
export function readinessOwnerInvocation(command, root = process.cwd()) {
|
|
31
45
|
if (typeof command !== "string") return false;
|
|
32
46
|
for (const runtime of ["node", process.execPath, quote(process.execPath)])
|
|
33
47
|
for (const script of [owner, quote(owner)]) {
|
|
34
48
|
if (command === `${runtime} ${script} --task`) return true;
|
|
35
49
|
for (const mode of ["task", "prepare"]) {
|
|
36
50
|
const prefix = `${runtime} ${script} --${mode} --ref `;
|
|
51
|
+
if (!command.startsWith(prefix)) continue;
|
|
52
|
+
const rest = command.slice(prefix.length);
|
|
53
|
+
if (refs.test(rest)) return true;
|
|
54
|
+
const [ref, flag, file, ...extra] = rest.split(" ");
|
|
37
55
|
if (
|
|
38
|
-
|
|
39
|
-
refs.test(
|
|
56
|
+
mode === "prepare" &&
|
|
57
|
+
refs.test(ref) &&
|
|
58
|
+
flag === "--input-file" &&
|
|
59
|
+
extra.length === 0 &&
|
|
60
|
+
plainPath.test(file ?? "") &&
|
|
61
|
+
outsideEveryRepository(file, root)
|
|
40
62
|
)
|
|
41
63
|
return true;
|
|
42
64
|
}
|
|
@@ -52,7 +74,7 @@ function orientation(input) {
|
|
|
52
74
|
return true;
|
|
53
75
|
if (input?.tool_name !== "Bash") return false;
|
|
54
76
|
return (
|
|
55
|
-
readinessOwnerInvocation(input.tool_input?.command) ||
|
|
77
|
+
readinessOwnerInvocation(input.tool_input?.command, input.cwd) ||
|
|
56
78
|
[
|
|
57
79
|
"pwd",
|
|
58
80
|
"ls -la",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* an agent's scratch or memory file. The refusal names the read command for
|
|
9
9
|
* this installation, because an agent cannot guess an absolute plugin path.
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
11
|
+
import { existsSync, lstatSync, realpathSync, statSync } from "node:fs";
|
|
12
12
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
14
|
import {
|
|
@@ -33,6 +33,14 @@ const PATCH_TARGET =
|
|
|
33
33
|
function realLocation(target) {
|
|
34
34
|
let existing = target;
|
|
35
35
|
while (!existsSync(existing)) {
|
|
36
|
+
// A link whose target is missing exists as an entry: writing through it
|
|
37
|
+
// creates the target, wherever that is. It is never a new file.
|
|
38
|
+
try {
|
|
39
|
+
lstatSync(existing);
|
|
40
|
+
return null;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error.code !== "ENOENT") return null;
|
|
43
|
+
}
|
|
36
44
|
const parent = dirname(existing);
|
|
37
45
|
if (parent === existing) return null;
|
|
38
46
|
existing = parent;
|
|
@@ -45,7 +53,26 @@ function realLocation(target) {
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
/**
|
|
48
|
-
* Whether
|
|
56
|
+
* Whether `dir` is itself a git directory: a bare repository, or the inside
|
|
57
|
+
* of a `.git` folder. Git recognises one by `HEAD`, `objects` and `refs`.
|
|
58
|
+
* @param {string} dir Directory to inspect.
|
|
59
|
+
* @returns {boolean} True when it has that layout.
|
|
60
|
+
*/
|
|
61
|
+
function gitDirectory(dir) {
|
|
62
|
+
try {
|
|
63
|
+
return (
|
|
64
|
+
statSync(join(dir, "HEAD")).isFile() &&
|
|
65
|
+
statSync(join(dir, "objects")).isDirectory() &&
|
|
66
|
+
statSync(join(dir, "refs")).isDirectory()
|
|
67
|
+
);
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether any directory from `location` up to the root holds `.git` or is
|
|
75
|
+
* itself a git directory.
|
|
49
76
|
* @param {string} location Resolved absolute path.
|
|
50
77
|
* @returns {boolean} True when the path is inside a git repository.
|
|
51
78
|
*/
|
|
@@ -57,6 +84,7 @@ function insideRepository(location) {
|
|
|
57
84
|
} catch (error) {
|
|
58
85
|
if (!["ENOENT", "ENOTDIR"].includes(error.code)) return true;
|
|
59
86
|
}
|
|
87
|
+
if (gitDirectory(dir)) return true;
|
|
60
88
|
if (dirname(dir) === dir) return false;
|
|
61
89
|
}
|
|
62
90
|
}
|
|
@@ -99,7 +127,9 @@ function writeTargets(input) {
|
|
|
99
127
|
if (input.tool_name === "apply_patch" && typeof args.command === "string") {
|
|
100
128
|
const targets = args.command
|
|
101
129
|
.split("\n")
|
|
102
|
-
|
|
130
|
+
// The patch tool trims each header before acting on it, so the check
|
|
131
|
+
// must too, or an indented header is applied without being seen.
|
|
132
|
+
.map(line => PATCH_TARGET.exec(line.trim())?.[1])
|
|
103
133
|
.filter(Boolean);
|
|
104
134
|
return targets.length ? targets : null;
|
|
105
135
|
}
|
|
@@ -120,6 +150,16 @@ export function unboundWrite(input, cfg) {
|
|
|
120
150
|
);
|
|
121
151
|
}
|
|
122
152
|
|
|
153
|
+
/**
|
|
154
|
+
* This installation's prepare/read owner script as one shell word.
|
|
155
|
+
* @returns {string} The path, quoted only when it needs to be.
|
|
156
|
+
*/
|
|
157
|
+
function ownerWord() {
|
|
158
|
+
return /^[\w./@+-]+$/.test(owner)
|
|
159
|
+
? owner
|
|
160
|
+
: `'${owner.replaceAll("'", "'\\''")}'`;
|
|
161
|
+
}
|
|
162
|
+
|
|
123
163
|
/**
|
|
124
164
|
* The exact read command this installation admits with no work item bound.
|
|
125
165
|
* @param {Record<string, any>} cfg Task configuration.
|
|
@@ -127,9 +167,7 @@ export function unboundWrite(input, cfg) {
|
|
|
127
167
|
*/
|
|
128
168
|
function readCommand(cfg) {
|
|
129
169
|
const c = cfg.effective ?? {};
|
|
130
|
-
const script =
|
|
131
|
-
? owner
|
|
132
|
-
: `'${owner.replaceAll("'", "'\\''")}'`;
|
|
170
|
+
const script = ownerWord();
|
|
133
171
|
if (c.tracker === "linear" && c.linear?.teamKey)
|
|
134
172
|
return `node ${script} --tracker-intake-read --ref ${c.linear.teamKey}-<number> --read issue`;
|
|
135
173
|
if (c.tracker === "jira" && c.jira?.project)
|
|
@@ -162,6 +200,7 @@ export function unboundRefusal(cfg) {
|
|
|
162
200
|
: "",
|
|
163
201
|
"A file written outside every git repository, such as a scratch or memory file, is allowed.",
|
|
164
202
|
"To change anything in this project, bind its ticket first with lisa-track.",
|
|
203
|
+
`Its prepare step needs no shell input: write the prepare JSON to a file outside every repository, then run exactly: node ${ownerWord()} --prepare --ref <ticket> --input-file <absolute path of that file>.`,
|
|
165
204
|
]
|
|
166
205
|
.filter(Boolean)
|
|
167
206
|
.join(" "),
|
|
@@ -76,7 +76,7 @@ try {
|
|
|
76
76
|
} else if (result.status !== 0) {
|
|
77
77
|
// Only the fixed owner result is published. Environment errors never echo.
|
|
78
78
|
const safe =
|
|
79
|
-
/^(?:credential-missing|provider-unreachable|capability-unreachable|bootstrap-missing|tool-missing|config-invalid|config-unreadable|config-undiscovered|config-unknown|identity-mismatch|adapter-unsupported|requirements-stale|requirements-prepared|native-proof-needed|native-response-unrepresented): [^\n]*\n?$/.test(
|
|
79
|
+
/^(?:credential-missing|provider-unreachable|capability-unreachable|bootstrap-missing|tool-missing|config-invalid|config-unreadable|config-undiscovered|config-unknown|identity-mismatch|adapter-unsupported|requirements-stale|work-item-unbound|requirements-prepared|native-proof-needed|native-response-unrepresented): [^\n]*\n?$/.test(
|
|
80
80
|
result.stderr ?? ""
|
|
81
81
|
);
|
|
82
82
|
console.error(
|
|
@@ -28,7 +28,11 @@ the resolver or read its inputs.
|
|
|
28
28
|
|
|
29
29
|
Supply a complete values-free `required_access` array and
|
|
30
30
|
`requirements_complete: true` as JSON on stdin to the owner's
|
|
31
|
-
`--prepare --ref <canonical-ref>` mode.
|
|
31
|
+
`--prepare --ref <canonical-ref>` mode. An agent's shell tool has no stdin:
|
|
32
|
+
write the same JSON to a file outside every git repository (such a write is
|
|
33
|
+
admitted with no ticket bound) and run exactly
|
|
34
|
+
`node <owner>/preflight-secrets.mjs --prepare --ref <canonical-ref> --input-file <absolute path>`.
|
|
35
|
+
The path is one plain word; nothing may follow it. For the first context, include the complete
|
|
32
36
|
unedited `context_body` on that same stdin; it creates
|
|
33
37
|
only the fixed ignored0600 context after Git-ignore and EAS checks. Existing
|
|
34
38
|
context cannot be replaced through `context_body`. This is the bounded initial
|
|
@@ -97,7 +101,8 @@ reflect requirement identifiers/resources/paths, parse errors or provider output
|
|
|
97
101
|
Do not block unrelated tasks or require optional integrations universally.
|
|
98
102
|
|
|
99
103
|
The exact readiness owner command (`node <owner>/preflight-secrets.mjs --task
|
|
100
|
-
--ref <canonical-ref>`, or `--prepare` with that ref and JSON on terminal stdin
|
|
104
|
+
--ref <canonical-ref>`, or `--prepare` with that ref and JSON on terminal stdin
|
|
105
|
+
or in an `--input-file` outside every repository)
|
|
101
106
|
remains available during refusal. It grants no work: task mode still reports its
|
|
102
107
|
real verdict, and preparation only refreshes the ignored requirements metadata.
|
|
103
108
|
Only the exact native context Write/Add File forms above carry private metadata.
|
|
@@ -19,6 +19,8 @@ In a project with `.lisa.config.json`, the task-readiness guard enforces this. W
|
|
|
19
19
|
|
|
20
20
|
Answering a question about a ticket needs none of this. Never bind a ticket just to read one.
|
|
21
21
|
|
|
22
|
+
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.
|
|
23
|
+
|
|
22
24
|
## Resolve, claim, bind
|
|
23
25
|
|
|
24
26
|
Use `lisa-track` as the single entry point:
|
|
@@ -42,6 +42,7 @@ import { failure } from "./task-readiness.mjs";
|
|
|
42
42
|
import { runTaskAction } from "./task-action.mjs";
|
|
43
43
|
import { AccessFailure } from "./config-layers.mjs";
|
|
44
44
|
import { prepareRequirements } from "./task-requirements.mjs";
|
|
45
|
+
import { outsideEveryRepository } from "./task-unbound.mjs";
|
|
45
46
|
import { runIntakeRead } from "./task-intake-read.mjs";
|
|
46
47
|
import { runTrackerIntakeRead } from "./task-tracker-intake.mjs";
|
|
47
48
|
export { taskReadiness, credentialAvailability } from "./task-readiness.mjs";
|
|
@@ -367,7 +368,13 @@ function main() {
|
|
|
367
368
|
if (process.argv.includes("--prepare")) {
|
|
368
369
|
const cfg = readTaskConfig();
|
|
369
370
|
const index = process.argv.indexOf("--ref");
|
|
370
|
-
const
|
|
371
|
+
const fileIndex = process.argv.indexOf("--input-file");
|
|
372
|
+
// An agent's shell tool has no stdin. It writes the JSON to a file outside
|
|
373
|
+
// every repository (admitted while unbound) and names it here instead.
|
|
374
|
+
const file = fileIndex >= 0 ? process.argv[fileIndex + 1] : undefined;
|
|
375
|
+
if (fileIndex >= 0 && !outsideEveryRepository(file, cfg.projectRoot))
|
|
376
|
+
throw new AccessFailure("requirements-stale");
|
|
377
|
+
const input = JSON.parse(readFileSync(fileIndex >= 0 ? file : 0, "utf8"));
|
|
371
378
|
console.log(
|
|
372
379
|
JSON.stringify(
|
|
373
380
|
prepareRequirements(
|
|
@@ -9,7 +9,11 @@ import { readTaskRequirements } from "./task-requirements.mjs";
|
|
|
9
9
|
import { lifecycleEvents, resetNativeEvent } from "./task-native-lifecycle.mjs";
|
|
10
10
|
import { intakeRead } from "./task-intake.mjs";
|
|
11
11
|
import { nativeContext } from "./task-native-context.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
outsideEveryRepository,
|
|
14
|
+
unboundRefusal,
|
|
15
|
+
unboundWrite,
|
|
16
|
+
} from "./task-unbound.mjs";
|
|
13
17
|
import {
|
|
14
18
|
linearIntakeRead,
|
|
15
19
|
observeLinearIntake,
|
|
@@ -26,17 +30,35 @@ const owner = join(
|
|
|
26
30
|
const refs = /^(?:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+#\d+|[A-Z][A-Z0-9]+-\d+)$/;
|
|
27
31
|
const quote = path => `'${path.replaceAll("'", "'\\''")}'`;
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
33
|
+
/** A file path that a shell reads as exactly one plain word. */
|
|
34
|
+
const plainPath = /^\/[A-Za-z0-9_./@+-]+$/;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Exact canonical recovery command. JSON uses structured child/terminal
|
|
38
|
+
* stdin, or a file outside every repository that an agent's shell tool can
|
|
39
|
+
* name, since it has no stdin to supply.
|
|
40
|
+
* @param {unknown} command Shell command text.
|
|
41
|
+
* @param {string} [root] Project root, for the input file's location check.
|
|
42
|
+
* @returns {boolean} True for an exact recovery command.
|
|
43
|
+
*/
|
|
44
|
+
export function readinessOwnerInvocation(command, root = process.cwd()) {
|
|
31
45
|
if (typeof command !== "string") return false;
|
|
32
46
|
for (const runtime of ["node", process.execPath, quote(process.execPath)])
|
|
33
47
|
for (const script of [owner, quote(owner)]) {
|
|
34
48
|
if (command === `${runtime} ${script} --task`) return true;
|
|
35
49
|
for (const mode of ["task", "prepare"]) {
|
|
36
50
|
const prefix = `${runtime} ${script} --${mode} --ref `;
|
|
51
|
+
if (!command.startsWith(prefix)) continue;
|
|
52
|
+
const rest = command.slice(prefix.length);
|
|
53
|
+
if (refs.test(rest)) return true;
|
|
54
|
+
const [ref, flag, file, ...extra] = rest.split(" ");
|
|
37
55
|
if (
|
|
38
|
-
|
|
39
|
-
refs.test(
|
|
56
|
+
mode === "prepare" &&
|
|
57
|
+
refs.test(ref) &&
|
|
58
|
+
flag === "--input-file" &&
|
|
59
|
+
extra.length === 0 &&
|
|
60
|
+
plainPath.test(file ?? "") &&
|
|
61
|
+
outsideEveryRepository(file, root)
|
|
40
62
|
)
|
|
41
63
|
return true;
|
|
42
64
|
}
|
|
@@ -52,7 +74,7 @@ function orientation(input) {
|
|
|
52
74
|
return true;
|
|
53
75
|
if (input?.tool_name !== "Bash") return false;
|
|
54
76
|
return (
|
|
55
|
-
readinessOwnerInvocation(input.tool_input?.command) ||
|
|
77
|
+
readinessOwnerInvocation(input.tool_input?.command, input.cwd) ||
|
|
56
78
|
[
|
|
57
79
|
"pwd",
|
|
58
80
|
"ls -la",
|