@codyswann/lisa 8.10.0 → 8.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.json +17 -5
  3. package/package.json +4 -4
  4. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  5. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  6. package/plugins/lisa/.codex-plugin/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  7. package/plugins/lisa/.codex-plugin/skills/lisa-linear-read-issue/SKILL.md +2 -0
  8. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  9. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  10. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
  11. package/plugins/lisa/rules/reference/tracked-work.md +8 -0
  12. package/plugins/lisa/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  13. package/plugins/lisa/skills/lisa-linear-read-issue/SKILL.md +2 -0
  14. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  15. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  16. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
  17. package/plugins/lisa-agy/plugin.json +1 -1
  18. package/plugins/lisa-agy/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  19. package/plugins/lisa-agy/skills/lisa-linear-read-issue/SKILL.md +2 -0
  20. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  21. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  22. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
  23. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  26. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  30. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-copilot/rules/reference/tracked-work.md +8 -0
  32. package/plugins/lisa-copilot/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  33. package/plugins/lisa-copilot/skills/lisa-linear-read-issue/SKILL.md +2 -0
  34. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  35. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  36. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
  37. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa-cursor/rules/tracked-work-reference.mdc +8 -0
  39. package/plugins/lisa-cursor/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  40. package/plugins/lisa-cursor/skills/lisa-linear-read-issue/SKILL.md +2 -0
  41. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  42. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  43. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
  44. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  46. package/plugins/lisa-devin/rules/reference/tracked-work.md +8 -0
  47. package/plugins/lisa-devin/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  48. package/plugins/lisa-devin/skills/lisa-linear-read-issue/SKILL.md +2 -0
  49. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  50. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  51. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
  52. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  54. package/plugins/lisa-expo-agy/plugin.json +1 -1
  55. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  59. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  61. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  62. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  66. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  69. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  73. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  74. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  75. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  76. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  80. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  82. package/plugins/lisa-rails-agy/plugin.json +1 -1
  83. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  87. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  88. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  89. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  90. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  93. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  94. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  95. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  96. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  97. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  98. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  99. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  101. package/plugins/src/base/rules/reference/tracked-work.md +8 -0
  102. package/plugins/src/base/skills/lisa-jira-read-ticket/SKILL.md +2 -0
  103. package/plugins/src/base/skills/lisa-linear-read-issue/SKILL.md +2 -0
  104. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-action.mjs +3 -1
  105. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-context-write.mjs +40 -9
  106. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-unbound.mjs +169 -0
@@ -0,0 +1,169 @@
1
+ /**
2
+ * What a session with no work item bound may still do, and what it is told.
3
+ *
4
+ * With no binding and no prepared context there is no task whose access could
5
+ * be proved, so the guard refuses project work. Two things are not project
6
+ * work and stay possible: reading (the fixed read commands the guard already
7
+ * admits), and writing a file that lands in no git repository at all, such as
8
+ * an agent's scratch or memory file. The refusal names the read command for
9
+ * this installation, because an agent cannot guess an absolute plugin path.
10
+ */
11
+ import { existsSync, realpathSync, statSync } from "node:fs";
12
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+ import {
15
+ configuredIssueRepository,
16
+ issueFields,
17
+ } from "../../lisa-github-read-issue/read-contract.mjs";
18
+
19
+ const owner = join(
20
+ dirname(fileURLToPath(import.meta.url)),
21
+ "preflight-secrets.mjs"
22
+ );
23
+ const FILE_TOOLS = new Set(["Write", "Edit", "MultiEdit", "write", "edit"]);
24
+ const PATCH_TARGET =
25
+ /^\*\*\* (?:Add File|Update File|Delete File|Move to): (.*)$/;
26
+
27
+ /**
28
+ * The real location a path would be written to: the deepest existing
29
+ * ancestor's real path, with the not-yet-existing remainder appended.
30
+ * @param {string} target Absolute path.
31
+ * @returns {string|null} Resolved location, or null when unresolvable.
32
+ */
33
+ function realLocation(target) {
34
+ let existing = target;
35
+ while (!existsSync(existing)) {
36
+ const parent = dirname(existing);
37
+ if (parent === existing) return null;
38
+ existing = parent;
39
+ }
40
+ try {
41
+ return join(realpathSync(existing), relative(existing, target));
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Whether any directory from `location` up to the root holds `.git`.
49
+ * @param {string} location Resolved absolute path.
50
+ * @returns {boolean} True when the path is inside a git repository.
51
+ */
52
+ function insideRepository(location) {
53
+ for (let dir = location; ; dir = dirname(dir)) {
54
+ try {
55
+ statSync(join(dir, ".git"));
56
+ return true;
57
+ } catch (error) {
58
+ if (!["ENOENT", "ENOTDIR"].includes(error.code)) return true;
59
+ }
60
+ if (dirname(dir) === dir) return false;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Whether a write to `target` changes no project: it resolves outside the
66
+ * project and outside every git repository. Any doubt is a refusal.
67
+ * @param {unknown} target The path the tool names.
68
+ * @param {string} projectRoot This project's root.
69
+ * @returns {boolean} True when the write touches no repository.
70
+ */
71
+ export function outsideEveryRepository(target, projectRoot) {
72
+ if (typeof target !== "string" || !isAbsolute(target)) return false;
73
+ const location = realLocation(resolve(target));
74
+ if (!location) return false;
75
+ let root;
76
+ try {
77
+ root = realpathSync(projectRoot);
78
+ } catch {
79
+ return false;
80
+ }
81
+ if (location === root || location.startsWith(root + sep)) return false;
82
+ return !insideRepository(location);
83
+ }
84
+
85
+ /**
86
+ * Every path a file-writing tool call names, or null for any other shape.
87
+ * @param {Record<string, any>} input Hook event.
88
+ * @returns {string[]|null} Target paths.
89
+ */
90
+ function writeTargets(input) {
91
+ const args = input?.tool_input;
92
+ if (!args || typeof args !== "object") return null;
93
+ if (FILE_TOOLS.has(input.tool_name)) {
94
+ const target = args.file_path ?? args.filePath;
95
+ return typeof target === "string" ? [target] : null;
96
+ }
97
+ if (input.tool_name === "NotebookEdit")
98
+ return typeof args.notebook_path === "string" ? [args.notebook_path] : null;
99
+ if (input.tool_name === "apply_patch" && typeof args.command === "string") {
100
+ const targets = args.command
101
+ .split("\n")
102
+ .map(line => PATCH_TARGET.exec(line)?.[1])
103
+ .filter(Boolean);
104
+ return targets.length ? targets : null;
105
+ }
106
+ return null;
107
+ }
108
+
109
+ /**
110
+ * Whether an unbound session's tool call only writes outside every repository.
111
+ * @param {Record<string, any>} input Hook event.
112
+ * @param {{projectRoot: string}} cfg Task configuration.
113
+ * @returns {boolean} True to admit it.
114
+ */
115
+ export function unboundWrite(input, cfg) {
116
+ const targets = writeTargets(input);
117
+ return (
118
+ targets !== null &&
119
+ targets.every(target => outsideEveryRepository(target, cfg.projectRoot))
120
+ );
121
+ }
122
+
123
+ /**
124
+ * The exact read command this installation admits with no work item bound.
125
+ * @param {Record<string, any>} cfg Task configuration.
126
+ * @returns {string|null} Command text with a placeholder ticket, or null.
127
+ */
128
+ function readCommand(cfg) {
129
+ const c = cfg.effective ?? {};
130
+ const script = /^[\w./@+-]+$/.test(owner)
131
+ ? owner
132
+ : `'${owner.replaceAll("'", "'\\''")}'`;
133
+ if (c.tracker === "linear" && c.linear?.teamKey)
134
+ return `node ${script} --tracker-intake-read --ref ${c.linear.teamKey}-<number> --read issue`;
135
+ if (c.tracker === "jira" && c.jira?.project)
136
+ return `node ${script} --tracker-intake-read --ref ${c.jira.project}-<number> --read issue`;
137
+ const repo = c.github && configuredIssueRepository(c.github);
138
+ if (repo && (!c.tracker || c.tracker === "github"))
139
+ return `gh issue view <number> --repo ${repo} --json ${issueFields}`;
140
+ return null;
141
+ }
142
+
143
+ /**
144
+ * The refusal for a session with no work item bound, in plain English.
145
+ * @param {Record<string, any>} cfg Task configuration.
146
+ * @returns {{allowed: false, code: string, action: string}} Refusal.
147
+ */
148
+ export function unboundRefusal(cfg) {
149
+ const read = readCommand(cfg);
150
+ const comments =
151
+ read && read.includes("--read issue")
152
+ ? " Use `--read comments` for its comments."
153
+ : "";
154
+ return {
155
+ allowed: false,
156
+ code: "work-item-unbound",
157
+ action: [
158
+ "No work item is bound to this checkout, so only reading is allowed.",
159
+ "Read files with the Read, Grep and Glob tools.",
160
+ read
161
+ ? `Read a ticket with exactly this command, with the ticket's number in place of <number>: ${read}.${comments}`
162
+ : "",
163
+ "A file written outside every git repository, such as a scratch or memory file, is allowed.",
164
+ "To change anything in this project, bind its ticket first with lisa-track.",
165
+ ]
166
+ .filter(Boolean)
167
+ .join(" "),
168
+ };
169
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -19,6 +19,8 @@ node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intak
19
19
  node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intake-read --ref PROJ-123 --read comments
20
20
  ```
21
21
 
22
+ The same two commands are the read for a session with no ticket bound, for example a question about an issue: the task-readiness guard admits them, and its `work-item-unbound` refusal names them with the installed path. Do not bind a ticket just to read one.
23
+
22
24
  The token route returns the full issue and remote links, and the comments command reads all pages in order. If the token is unavailable, the command can read the issue through an already authenticated `acli` session on the configured site. That route reports `remoteLinks: null` and returns comments only when the embedded page is complete. Use the Atlassian access owner's native Jira issue and remote-link reads against the configured cloud and issue key to fill missing data. Check the embedded comment total before treating native context as complete.
23
25
 
24
26
  ## Phase 1 — Resolve Context
@@ -25,6 +25,8 @@ node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intak
25
25
  node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intake-read --ref ENG-123 --read comments
26
26
  ```
27
27
 
28
+ The same two commands are the read for a session with no ticket bound, for example a question about an issue: the task-readiness guard admits them, and its `work-item-unbound` refusal names them with the installed path. Do not bind a ticket just to read one.
29
+
28
30
  The issue response includes the primary body, team, and related graph fields. The comments command returns the entire paginated comment list or fails. Fetch related issues in the configured team with the same command and their issue keys. If a graph field reports another page, record the context as incomplete until those related records can be read through the access owner.
29
31
 
30
32
  If the token route is unavailable, load `lisa-linear-access` and use its native Linear MCP fallback. List teams with the configured team key as `query`, verify the configured workspace and team, then read the issue by its key. Use the resulting issue identifier or UUID for the comment pages. This read-only path leaves the requirements header and access check to the normal task flow.
@@ -9,6 +9,7 @@ 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 { unboundRefusal, unboundWrite } from "./task-unbound.mjs";
12
13
  import {
13
14
  linearIntakeRead,
14
15
  observeLinearIntake,
@@ -177,7 +178,8 @@ export function runTaskAction(argv = process.argv) {
177
178
  result = failure("requirements-stale");
178
179
  else if (hook && result.code === "no-active-task") {
179
180
  if (cfg.provenance?.status === "absent") return;
180
- result = failure("requirements-stale");
181
+ if (unboundWrite(input, cfg)) return;
182
+ result = unboundRefusal(cfg);
181
183
  } else if (hook && result.outcome === "NATIVE_OWNER_REQUIRED") {
182
184
  const decision = nativeAction(cfg, header, result, input);
183
185
  if (decision.allowed) result = { allowed: true, code: decision.code };
@@ -90,19 +90,29 @@ export function writeRequirementsContext(
90
90
  if (error.code !== "ENOENT") fail();
91
91
  initial = true;
92
92
  }
93
+ const freshBody =
94
+ typeof input.context_body === "string" &&
95
+ !input.context_body.startsWith(marker);
96
+ // Re-binding the checkout to another item leaves the previous item's
97
+ // context behind. With the binding already naming `ref`, that context
98
+ // belongs to no current work: a fresh body for `ref` replaces it, so the
99
+ // prepare step that follows a re-bind does not dead-end the session.
100
+ let replacing = false;
93
101
  if (initial) {
94
- if (
95
- typeof input.context_body !== "string" ||
96
- input.context_body.startsWith(marker)
97
- )
98
- fail();
102
+ if (!freshBody) fail();
99
103
  } else {
100
104
  try {
101
- if (realpathSync(path) !== path || input.context_body !== undefined)
102
- fail();
105
+ if (realpathSync(path) !== path) fail();
103
106
  } catch {
104
107
  fail();
105
108
  }
109
+ const previous = previousItem(readFileSync(path, "utf8"), marker);
110
+ replacing =
111
+ freshBody &&
112
+ binding?.ref === ref &&
113
+ previous !== null &&
114
+ previous !== ref;
115
+ if (input.context_body !== undefined && !replacing) fail();
106
116
  }
107
117
  const eas = join(cfg.projectRoot, ".easignore");
108
118
  if (
@@ -113,7 +123,8 @@ export function writeRequirementsContext(
113
123
  )
114
124
  fail();
115
125
  ensureIgnored(cfg.projectRoot);
116
- let body = initial ? input.context_body : readFileSync(path, "utf8");
126
+ let body =
127
+ initial || replacing ? input.context_body : readFileSync(path, "utf8");
117
128
  if (body.startsWith(marker)) {
118
129
  const end = body.indexOf("\n-->\n");
119
130
  if (end < 0) fail();
@@ -154,5 +165,25 @@ export function writeRequirementsContext(
154
165
  } finally {
155
166
  rmSync(staging, { recursive: true, force: true });
156
167
  }
157
- return { code: "requirements-prepared", body_preserved: true };
168
+ return { code: "requirements-prepared", body_preserved: !replacing };
169
+ }
170
+
171
+ /**
172
+ * The work item a prepared context names, or null when it names none.
173
+ * @param {string} current The context file's text.
174
+ * @param {string} marker The requirements header's opening line.
175
+ * @returns {string|null} The previous work item reference.
176
+ */
177
+ function previousItem(current, marker) {
178
+ if (!current.startsWith(marker)) return null;
179
+ const end = current.indexOf("\n-->\n");
180
+ if (end < 0) return null;
181
+ try {
182
+ const header = JSON.parse(current.slice(marker.length, end));
183
+ return typeof header?.work_item_ref === "string"
184
+ ? header.work_item_ref
185
+ : null;
186
+ } catch {
187
+ return null;
188
+ }
158
189
  }
@@ -0,0 +1,169 @@
1
+ /**
2
+ * What a session with no work item bound may still do, and what it is told.
3
+ *
4
+ * With no binding and no prepared context there is no task whose access could
5
+ * be proved, so the guard refuses project work. Two things are not project
6
+ * work and stay possible: reading (the fixed read commands the guard already
7
+ * admits), and writing a file that lands in no git repository at all, such as
8
+ * an agent's scratch or memory file. The refusal names the read command for
9
+ * this installation, because an agent cannot guess an absolute plugin path.
10
+ */
11
+ import { existsSync, realpathSync, statSync } from "node:fs";
12
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+ import {
15
+ configuredIssueRepository,
16
+ issueFields,
17
+ } from "../../lisa-github-read-issue/read-contract.mjs";
18
+
19
+ const owner = join(
20
+ dirname(fileURLToPath(import.meta.url)),
21
+ "preflight-secrets.mjs"
22
+ );
23
+ const FILE_TOOLS = new Set(["Write", "Edit", "MultiEdit", "write", "edit"]);
24
+ const PATCH_TARGET =
25
+ /^\*\*\* (?:Add File|Update File|Delete File|Move to): (.*)$/;
26
+
27
+ /**
28
+ * The real location a path would be written to: the deepest existing
29
+ * ancestor's real path, with the not-yet-existing remainder appended.
30
+ * @param {string} target Absolute path.
31
+ * @returns {string|null} Resolved location, or null when unresolvable.
32
+ */
33
+ function realLocation(target) {
34
+ let existing = target;
35
+ while (!existsSync(existing)) {
36
+ const parent = dirname(existing);
37
+ if (parent === existing) return null;
38
+ existing = parent;
39
+ }
40
+ try {
41
+ return join(realpathSync(existing), relative(existing, target));
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Whether any directory from `location` up to the root holds `.git`.
49
+ * @param {string} location Resolved absolute path.
50
+ * @returns {boolean} True when the path is inside a git repository.
51
+ */
52
+ function insideRepository(location) {
53
+ for (let dir = location; ; dir = dirname(dir)) {
54
+ try {
55
+ statSync(join(dir, ".git"));
56
+ return true;
57
+ } catch (error) {
58
+ if (!["ENOENT", "ENOTDIR"].includes(error.code)) return true;
59
+ }
60
+ if (dirname(dir) === dir) return false;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Whether a write to `target` changes no project: it resolves outside the
66
+ * project and outside every git repository. Any doubt is a refusal.
67
+ * @param {unknown} target The path the tool names.
68
+ * @param {string} projectRoot This project's root.
69
+ * @returns {boolean} True when the write touches no repository.
70
+ */
71
+ export function outsideEveryRepository(target, projectRoot) {
72
+ if (typeof target !== "string" || !isAbsolute(target)) return false;
73
+ const location = realLocation(resolve(target));
74
+ if (!location) return false;
75
+ let root;
76
+ try {
77
+ root = realpathSync(projectRoot);
78
+ } catch {
79
+ return false;
80
+ }
81
+ if (location === root || location.startsWith(root + sep)) return false;
82
+ return !insideRepository(location);
83
+ }
84
+
85
+ /**
86
+ * Every path a file-writing tool call names, or null for any other shape.
87
+ * @param {Record<string, any>} input Hook event.
88
+ * @returns {string[]|null} Target paths.
89
+ */
90
+ function writeTargets(input) {
91
+ const args = input?.tool_input;
92
+ if (!args || typeof args !== "object") return null;
93
+ if (FILE_TOOLS.has(input.tool_name)) {
94
+ const target = args.file_path ?? args.filePath;
95
+ return typeof target === "string" ? [target] : null;
96
+ }
97
+ if (input.tool_name === "NotebookEdit")
98
+ return typeof args.notebook_path === "string" ? [args.notebook_path] : null;
99
+ if (input.tool_name === "apply_patch" && typeof args.command === "string") {
100
+ const targets = args.command
101
+ .split("\n")
102
+ .map(line => PATCH_TARGET.exec(line)?.[1])
103
+ .filter(Boolean);
104
+ return targets.length ? targets : null;
105
+ }
106
+ return null;
107
+ }
108
+
109
+ /**
110
+ * Whether an unbound session's tool call only writes outside every repository.
111
+ * @param {Record<string, any>} input Hook event.
112
+ * @param {{projectRoot: string}} cfg Task configuration.
113
+ * @returns {boolean} True to admit it.
114
+ */
115
+ export function unboundWrite(input, cfg) {
116
+ const targets = writeTargets(input);
117
+ return (
118
+ targets !== null &&
119
+ targets.every(target => outsideEveryRepository(target, cfg.projectRoot))
120
+ );
121
+ }
122
+
123
+ /**
124
+ * The exact read command this installation admits with no work item bound.
125
+ * @param {Record<string, any>} cfg Task configuration.
126
+ * @returns {string|null} Command text with a placeholder ticket, or null.
127
+ */
128
+ function readCommand(cfg) {
129
+ const c = cfg.effective ?? {};
130
+ const script = /^[\w./@+-]+$/.test(owner)
131
+ ? owner
132
+ : `'${owner.replaceAll("'", "'\\''")}'`;
133
+ if (c.tracker === "linear" && c.linear?.teamKey)
134
+ return `node ${script} --tracker-intake-read --ref ${c.linear.teamKey}-<number> --read issue`;
135
+ if (c.tracker === "jira" && c.jira?.project)
136
+ return `node ${script} --tracker-intake-read --ref ${c.jira.project}-<number> --read issue`;
137
+ const repo = c.github && configuredIssueRepository(c.github);
138
+ if (repo && (!c.tracker || c.tracker === "github"))
139
+ return `gh issue view <number> --repo ${repo} --json ${issueFields}`;
140
+ return null;
141
+ }
142
+
143
+ /**
144
+ * The refusal for a session with no work item bound, in plain English.
145
+ * @param {Record<string, any>} cfg Task configuration.
146
+ * @returns {{allowed: false, code: string, action: string}} Refusal.
147
+ */
148
+ export function unboundRefusal(cfg) {
149
+ const read = readCommand(cfg);
150
+ const comments =
151
+ read && read.includes("--read issue")
152
+ ? " Use `--read comments` for its comments."
153
+ : "";
154
+ return {
155
+ allowed: false,
156
+ code: "work-item-unbound",
157
+ action: [
158
+ "No work item is bound to this checkout, so only reading is allowed.",
159
+ "Read files with the Read, Grep and Glob tools.",
160
+ read
161
+ ? `Read a ticket with exactly this command, with the ticket's number in place of <number>: ${read}.${comments}`
162
+ : "",
163
+ "A file written outside every git repository, such as a scratch or memory file, is allowed.",
164
+ "To change anything in this project, bind its ticket first with lisa-track.",
165
+ ]
166
+ .filter(Boolean)
167
+ .join(" "),
168
+ };
169
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific Lisa plugin.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "8.10.0",
3
+ "version": "8.10.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -6,6 +6,14 @@ Apply `do-it-now` before creating work from incidental findings. Declining an ob
6
6
 
7
7
  The project tracker is the durable operator-facing record for project work. Every session that will produce a durable project outcome must establish exactly one live configured-tracker leaf before the first durable mutation. Durable outcomes include code, tests, configuration, documentation, committed research or plans, investigation findings, commits, and pull requests. Read-only questions, discussion, and repository orientation are exempt until they turn into durable work.
8
8
 
9
+ In a project with `.lisa.config.json`, the task-readiness guard enforces this. With no ticket bound, it refuses shell commands and project writes with `work-item-unbound`, and admits only:
10
+
11
+ - the Read, Grep and Glob tools;
12
+ - the fixed ticket read commands. The refusal names the exact one for that installation: `preflight-secrets.mjs --tracker-intake-read --ref <KEY> --read issue|comments` for Linear and Jira, `gh issue view <n> --repo <org>/<repo> --json …` for GitHub;
13
+ - a write that lands in no git repository, such as a scratch or memory file.
14
+
15
+ Answering a question about a ticket needs none of this. Never bind a ticket just to read one.
16
+
9
17
  ## Resolve, claim, bind
10
18
 
11
19
  Use `lisa-track` as the single entry point:
@@ -19,6 +19,8 @@ node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intak
19
19
  node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intake-read --ref PROJ-123 --read comments
20
20
  ```
21
21
 
22
+ The same two commands are the read for a session with no ticket bound, for example a question about an issue: the task-readiness guard admits them, and its `work-item-unbound` refusal names them with the installed path. Do not bind a ticket just to read one.
23
+
22
24
  The token route returns the full issue and remote links, and the comments command reads all pages in order. If the token is unavailable, the command can read the issue through an already authenticated `acli` session on the configured site. That route reports `remoteLinks: null` and returns comments only when the embedded page is complete. Use the Atlassian access owner's native Jira issue and remote-link reads against the configured cloud and issue key to fill missing data. Check the embedded comment total before treating native context as complete.
23
25
 
24
26
  ## Phase 1 — Resolve Context
@@ -25,6 +25,8 @@ node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intak
25
25
  node /absolute/lisa-secrets-access/scripts/preflight-secrets.mjs --tracker-intake-read --ref ENG-123 --read comments
26
26
  ```
27
27
 
28
+ The same two commands are the read for a session with no ticket bound, for example a question about an issue: the task-readiness guard admits them, and its `work-item-unbound` refusal names them with the installed path. Do not bind a ticket just to read one.
29
+
28
30
  The issue response includes the primary body, team, and related graph fields. The comments command returns the entire paginated comment list or fails. Fetch related issues in the configured team with the same command and their issue keys. If a graph field reports another page, record the context as incomplete until those related records can be read through the access owner.
29
31
 
30
32
  If the token route is unavailable, load `lisa-linear-access` and use its native Linear MCP fallback. List teams with the configured team key as `query`, verify the configured workspace and team, then read the issue by its key. Use the resulting issue identifier or UUID for the comment pages. This read-only path leaves the requirements header and access check to the normal task flow.
@@ -9,6 +9,7 @@ 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 { unboundRefusal, unboundWrite } from "./task-unbound.mjs";
12
13
  import {
13
14
  linearIntakeRead,
14
15
  observeLinearIntake,
@@ -177,7 +178,8 @@ export function runTaskAction(argv = process.argv) {
177
178
  result = failure("requirements-stale");
178
179
  else if (hook && result.code === "no-active-task") {
179
180
  if (cfg.provenance?.status === "absent") return;
180
- result = failure("requirements-stale");
181
+ if (unboundWrite(input, cfg)) return;
182
+ result = unboundRefusal(cfg);
181
183
  } else if (hook && result.outcome === "NATIVE_OWNER_REQUIRED") {
182
184
  const decision = nativeAction(cfg, header, result, input);
183
185
  if (decision.allowed) result = { allowed: true, code: decision.code };
@@ -90,19 +90,29 @@ export function writeRequirementsContext(
90
90
  if (error.code !== "ENOENT") fail();
91
91
  initial = true;
92
92
  }
93
+ const freshBody =
94
+ typeof input.context_body === "string" &&
95
+ !input.context_body.startsWith(marker);
96
+ // Re-binding the checkout to another item leaves the previous item's
97
+ // context behind. With the binding already naming `ref`, that context
98
+ // belongs to no current work: a fresh body for `ref` replaces it, so the
99
+ // prepare step that follows a re-bind does not dead-end the session.
100
+ let replacing = false;
93
101
  if (initial) {
94
- if (
95
- typeof input.context_body !== "string" ||
96
- input.context_body.startsWith(marker)
97
- )
98
- fail();
102
+ if (!freshBody) fail();
99
103
  } else {
100
104
  try {
101
- if (realpathSync(path) !== path || input.context_body !== undefined)
102
- fail();
105
+ if (realpathSync(path) !== path) fail();
103
106
  } catch {
104
107
  fail();
105
108
  }
109
+ const previous = previousItem(readFileSync(path, "utf8"), marker);
110
+ replacing =
111
+ freshBody &&
112
+ binding?.ref === ref &&
113
+ previous !== null &&
114
+ previous !== ref;
115
+ if (input.context_body !== undefined && !replacing) fail();
106
116
  }
107
117
  const eas = join(cfg.projectRoot, ".easignore");
108
118
  if (
@@ -113,7 +123,8 @@ export function writeRequirementsContext(
113
123
  )
114
124
  fail();
115
125
  ensureIgnored(cfg.projectRoot);
116
- let body = initial ? input.context_body : readFileSync(path, "utf8");
126
+ let body =
127
+ initial || replacing ? input.context_body : readFileSync(path, "utf8");
117
128
  if (body.startsWith(marker)) {
118
129
  const end = body.indexOf("\n-->\n");
119
130
  if (end < 0) fail();
@@ -154,5 +165,25 @@ export function writeRequirementsContext(
154
165
  } finally {
155
166
  rmSync(staging, { recursive: true, force: true });
156
167
  }
157
- return { code: "requirements-prepared", body_preserved: true };
168
+ return { code: "requirements-prepared", body_preserved: !replacing };
169
+ }
170
+
171
+ /**
172
+ * The work item a prepared context names, or null when it names none.
173
+ * @param {string} current The context file's text.
174
+ * @param {string} marker The requirements header's opening line.
175
+ * @returns {string|null} The previous work item reference.
176
+ */
177
+ function previousItem(current, marker) {
178
+ if (!current.startsWith(marker)) return null;
179
+ const end = current.indexOf("\n-->\n");
180
+ if (end < 0) return null;
181
+ try {
182
+ const header = JSON.parse(current.slice(marker.length, end));
183
+ return typeof header?.work_item_ref === "string"
184
+ ? header.work_item_ref
185
+ : null;
186
+ } catch {
187
+ return null;
188
+ }
158
189
  }