@primitive.ai/prim 0.1.0-alpha.117 → 0.1.0-alpha.119

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 (50) hide show
  1. package/README.md +21 -21
  2. package/SKILL.md +3 -3
  3. package/dist/{chunk-FTW4ZCBA.js → chunk-2AKDX4RU.js} +1 -1
  4. package/dist/{chunk-D3ZDZZYS.js → chunk-2JA524SC.js} +31 -17
  5. package/dist/{chunk-I3J344DF.js → chunk-4L7TAM5S.js} +122 -287
  6. package/dist/{chunk-3TIKBQHV.js → chunk-5BQ2NEMP.js} +2741 -2540
  7. package/dist/{chunk-LEUZDTNT.js → chunk-A6M2M5A2.js} +1 -1
  8. package/dist/{chunk-JKJ22ONL.js → chunk-CCGFRNAA.js} +6 -6
  9. package/dist/{chunk-CXMLAWC2.js → chunk-CSE44DPA.js} +2 -2
  10. package/dist/{chunk-NEQI2VLM.js → chunk-D235RJNO.js} +5 -5
  11. package/dist/{chunk-4SN5BCIG.js → chunk-GYQOZGGF.js} +2 -2
  12. package/dist/{chunk-LLKJAET2.js → chunk-HXICZG5J.js} +8 -16
  13. package/dist/chunk-JSBRDJBE.js +30 -0
  14. package/dist/chunk-KZB4ABIB.js +13 -0
  15. package/dist/{chunk-KGBMU76T.js → chunk-LBCPRHNG.js} +1 -1
  16. package/dist/{chunk-HMD5K6W7.js → chunk-LTTF4MBE.js} +2 -2
  17. package/dist/{chunk-JKO6PZWQ.js → chunk-MWNRXAEB.js} +26 -48
  18. package/dist/{chunk-6IRAGUYK.js → chunk-NQFRQ56V.js} +2 -2
  19. package/dist/{chunk-XG7S3LIL.js → chunk-P2O7NLVN.js} +887 -918
  20. package/dist/{chunk-J5HBSRAV.js → chunk-SLDZJD6Q.js} +1 -1
  21. package/dist/{chunk-4OEJ2ONG.js → chunk-TC4FTRYO.js} +2 -13
  22. package/dist/{chunk-6JHKKLA2.js → chunk-U67RBNIZ.js} +46 -46
  23. package/dist/{chunk-S55JKCHQ.js → chunk-VOC4KOOP.js} +2 -2
  24. package/dist/chunk-W27EFR7W.js +271 -0
  25. package/dist/{chunk-RLBASQJD.js → chunk-XWAKFL3T.js} +9 -7
  26. package/dist/daemon/server.js +2733 -2531
  27. package/dist/hook-runtime/daemon/server.js +2734 -2531
  28. package/dist/hook-runtime/hooks/post-commit.js +2741 -2538
  29. package/dist/hook-runtime/hooks/post-rewrite.js +2741 -2538
  30. package/dist/hook-runtime/hooks/post-tool-use.js +2883 -2579
  31. package/dist/hook-runtime/hooks/pre-commit.js +1 -0
  32. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +35089 -0
  33. package/dist/hook-runtime/hooks/pre-tool-use.js +109 -35539
  34. package/dist/hook-runtime/hooks/prim-hook.js +2875 -2571
  35. package/dist/hook-runtime/hooks/session-end.js +19 -16
  36. package/dist/hook-runtime/hooks/session-start.js +2834 -2632
  37. package/dist/hook-runtime/index.js +3030 -2830
  38. package/dist/hook-runtime/statusline-main.js +6 -2
  39. package/dist/hooks/post-commit.js +8 -7
  40. package/dist/hooks/post-rewrite.js +7 -6
  41. package/dist/hooks/post-tool-use.js +26 -22
  42. package/dist/hooks/pre-commit.js +5 -4
  43. package/dist/hooks/pre-tool-use-worker.js +264 -0
  44. package/dist/hooks/pre-tool-use.js +93 -250
  45. package/dist/hooks/prim-hook.js +26 -22
  46. package/dist/hooks/session-end.js +10 -7
  47. package/dist/hooks/session-start.js +22 -19
  48. package/dist/index.js +59 -54
  49. package/dist/statusline-main.js +5 -2
  50. package/package.json +3 -3
@@ -1,274 +1,22 @@
1
- import {
2
- isDemoStatusResponse
3
- } from "./chunk-3TIKBQHV.js";
4
1
  import {
5
2
  inspectHookRuntime
6
- } from "./chunk-JKO6PZWQ.js";
3
+ } from "./chunk-MWNRXAEB.js";
4
+ import {
5
+ isDemoStatusResponse
6
+ } from "./chunk-5BQ2NEMP.js";
7
7
  import {
8
8
  atomicWriteFile,
9
9
  primConfigDirectory,
10
10
  withFileLock,
11
11
  withFileLockSync
12
- } from "./chunk-XG7S3LIL.js";
13
-
14
- // src/hooks/pre-tool-use-scoring.ts
15
- import { isAbsolute, relative, sep } from "path";
16
- function anyUnverified(results) {
17
- return results.some((r) => r.verdict === "unavailable" || r.truncated);
18
- }
19
- function unverifiedNote(results) {
20
- const causes = [];
21
- const unavailable = results.find((r) => r.verdict === "unavailable");
22
- if (unavailable) {
23
- causes.push(
24
- unavailable.unavailable ? `decision check skipped \u2014 ${unavailable.unavailable}` : "decision check skipped \u2014 not verified"
25
- );
26
- }
27
- if (results.some((r) => r.truncated)) {
28
- causes.push("decision check partial \u2014 conflict set truncated (per-file cap hit)");
29
- }
30
- return causes.map((c) => `[primitive] ${c}`).join("\n");
31
- }
32
- function blockingReason(results) {
33
- const parts = results.filter((result) => result.verdict === "ask" || result.verdict === "deny").flatMap((result) => [result.reason, result.additionalContext]).filter((value) => value.length > 0);
34
- return [...new Set(parts)].join("\n\n") || "[primitive] conflict detected (no detail available)";
35
- }
36
- function approvalReason(results) {
37
- const summaries = results.filter((result) => result.verdict === "ask" || result.verdict === "deny").map((result) => result.reason).filter(Boolean);
38
- return [
39
- ...new Set(summaries),
40
- "Approve runs this edit once; it does not change these decisions."
41
- ].join("\n");
42
- }
43
- function agentContext(results) {
44
- return [...new Set(results.map((result) => result.additionalContext).filter(Boolean))].join(
45
- "\n\n"
46
- );
47
- }
48
- function advisoryNote(aggregate, results) {
49
- const details = results.flatMap((result) => [
50
- ...aggregate === "warn" ? [result.reason] : [],
51
- result.additionalContext
52
- ]);
53
- if (anyUnverified(results)) details.push(unverifiedNote(results));
54
- return [...new Set(details.filter((value) => value.length > 0))].join("\n\n");
55
- }
56
- function buildHookOutput(aggregate, results) {
57
- if (aggregate === "ask") {
58
- const context = agentContext(results);
59
- return {
60
- hookSpecificOutput: {
61
- hookEventName: "PreToolUse",
62
- permissionDecision: "ask",
63
- permissionDecisionReason: approvalReason(results),
64
- ...context ? { additionalContext: context } : {}
65
- }
66
- };
67
- }
68
- if (aggregate === "deny") {
69
- return {
70
- hookSpecificOutput: {
71
- hookEventName: "PreToolUse",
72
- permissionDecision: aggregate,
73
- permissionDecisionReason: blockingReason(results)
74
- }
75
- };
76
- }
77
- const notes = advisoryNote(aggregate, results);
78
- if (notes.length > 0) {
79
- return {
80
- systemMessage: notes,
81
- hookSpecificOutput: {
82
- hookEventName: "PreToolUse",
83
- permissionDecision: "allow",
84
- additionalContext: notes
85
- }
86
- };
87
- }
88
- return {
89
- hookSpecificOutput: {
90
- hookEventName: "PreToolUse",
91
- permissionDecision: "allow"
92
- }
93
- };
94
- }
95
- function buildCodexOutput(aggregate, results) {
96
- if (aggregate === "deny" || aggregate === "ask") {
97
- return {
98
- hookSpecificOutput: {
99
- hookEventName: "PreToolUse",
100
- permissionDecision: "deny",
101
- permissionDecisionReason: blockingReason(results)
102
- }
103
- };
104
- }
105
- const notes = advisoryNote(aggregate, results);
106
- return notes ? {
107
- systemMessage: notes,
108
- hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: notes }
109
- } : {};
110
- }
111
- function buildCursorOutput(aggregate, results) {
112
- if (aggregate === "deny" || aggregate === "ask") {
113
- const reason = blockingReason(results);
114
- return { permission: "deny", user_message: reason, agent_message: reason };
115
- }
116
- const notes = advisoryNote(aggregate, results);
117
- return notes ? { permission: "allow", agent_message: notes } : { permission: "allow" };
118
- }
119
- function failOpenOutput() {
120
- return {
121
- hookSpecificOutput: {
122
- hookEventName: "PreToolUse",
123
- permissionDecision: "allow"
124
- }
125
- };
126
- }
127
- function failOpenCodex() {
128
- return {};
129
- }
130
- function failOpenCursor() {
131
- return { permission: "allow" };
132
- }
133
- function buildHermesOutput(aggregate, results) {
134
- if (aggregate !== "deny" && aggregate !== "ask") {
135
- return {};
136
- }
137
- const reason = results.filter((r) => r.verdict === "deny" || r.verdict === "ask").map((r) => r.reason).filter((s) => s.length > 0).join("\n\n");
138
- const directive = results.map((r) => r.additionalContext).filter((s) => s.length > 0 && s !== reason).join("\n");
139
- const message = [reason, directive].filter((s) => s.length > 0).join("\n\n") || "[primitive] conflict detected (no detail available)";
140
- return { action: "block", message };
141
- }
142
- function failOpenHermes() {
143
- return {};
144
- }
145
- var SUPPORTED_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
146
- var APPLY_PATCH_FILE_RE = /^\*\*\* (?:Update|Add|Delete) File: (?<path>.+)$/;
147
- var MOVE_FILE_RE = /^\*\*\* Move File:\s*(?<src>.+?)\s*->\s*(?<dst>.+?)\s*$/;
148
- var MOVE_TO_RE = /^\*\*\* Move to: (?<dst>.+)$/;
149
- var LINE_SPLIT_RE = /\r?\n/;
150
- function parseApplyPatchTargets(command) {
151
- const paths = /* @__PURE__ */ new Set();
152
- let activeUpdate = false;
153
- let complete = true;
154
- for (const line of command.split(LINE_SPLIT_RE)) {
155
- const path = APPLY_PATCH_FILE_RE.exec(line)?.groups?.path;
156
- if (path) {
157
- paths.add(path);
158
- activeUpdate = line.startsWith("*** Update File:");
159
- continue;
160
- }
161
- const moveTo = MOVE_TO_RE.exec(line)?.groups?.dst;
162
- if (moveTo) {
163
- if (activeUpdate) paths.add(moveTo);
164
- else complete = false;
165
- activeUpdate = false;
166
- continue;
167
- }
168
- const move = MOVE_FILE_RE.exec(line)?.groups;
169
- if (move?.src) {
170
- paths.add(move.src);
171
- if (move.dst) {
172
- paths.add(move.dst);
173
- }
174
- activeUpdate = false;
175
- continue;
176
- }
177
- if (line === "*** Begin Patch" || line === "*** End Patch") activeUpdate = false;
178
- else if (line.startsWith("*** ")) complete = false;
179
- }
180
- return { paths: [...paths], complete: complete && paths.size > 0 };
181
- }
182
- function extractCodexFileTargets(toolName, toolInput) {
183
- if (toolName !== "apply_patch") {
184
- return null;
185
- }
186
- const text = codexPatchText(toolInput);
187
- return text !== null ? parseApplyPatchTargets(text) : { paths: [], complete: false };
188
- }
189
- function codexPatchText(toolInput) {
190
- if (typeof toolInput === "string") return toolInput;
191
- if (!toolInput || typeof toolInput !== "object") return null;
192
- const input = toolInput;
193
- for (const key of ["command", "input", "patch"]) {
194
- const value = input[key];
195
- if (typeof value === "string") return value;
196
- }
197
- return null;
198
- }
199
- var HERMES_EDITING_TOOLS = /* @__PURE__ */ new Set(["write_file", "patch"]);
200
- function extractHermesFileTargets(toolName, toolInput) {
201
- if (!HERMES_EDITING_TOOLS.has(toolName)) {
202
- return null;
203
- }
204
- if (!toolInput || typeof toolInput !== "object") {
205
- return { paths: [], complete: false };
206
- }
207
- const input = toolInput;
208
- if (toolName === "patch" && input.mode === "patch") {
209
- return typeof input.patch === "string" ? parseApplyPatchTargets(input.patch) : { paths: [], complete: false };
210
- }
211
- const paths = typeof input.path === "string" && input.path.length > 0 ? [input.path] : [];
212
- const mode = input.mode;
213
- return { paths, complete: paths.length > 0 && (mode === void 0 || mode === "replace") };
214
- }
215
- function extractCursorFileTargets(toolName, toolInput) {
216
- if (toolName !== "Write" && toolName !== "Delete") return null;
217
- if (!toolInput || typeof toolInput !== "object" || Array.isArray(toolInput)) {
218
- return { paths: [], complete: false };
219
- }
220
- const input = toolInput;
221
- const candidates = [input.file_path, input.path].filter(
222
- (value) => typeof value === "string" && value.length > 0
223
- );
224
- const paths = [...new Set(candidates)];
225
- return { paths, complete: paths.length === 1 };
226
- }
227
- function extractFileTargets(toolName, toolInput, agent = "claude_code") {
228
- if (agent === "codex") {
229
- return extractCodexFileTargets(toolName, toolInput);
230
- }
231
- if (agent === "cursor") {
232
- return extractCursorFileTargets(toolName, toolInput);
233
- }
234
- if (agent === "hermes") {
235
- return extractHermesFileTargets(toolName, toolInput);
236
- }
237
- if (!SUPPORTED_TOOLS.has(toolName)) {
238
- return null;
239
- }
240
- if (!toolInput || typeof toolInput !== "object") {
241
- return { paths: [], complete: false };
242
- }
243
- const input = toolInput;
244
- if (toolName === "NotebookEdit") {
245
- const paths2 = typeof input.notebook_path === "string" && input.notebook_path.length > 0 ? [input.notebook_path] : [];
246
- return { paths: paths2, complete: paths2.length > 0 };
247
- }
248
- const paths = typeof input.file_path === "string" && input.file_path.length > 0 ? [input.file_path] : [];
249
- return { paths, complete: paths.length > 0 };
250
- }
251
- function readHookMode(env) {
252
- if (env.PRIM_BYPASS === "1" || env.PRIM_BYPASS === "true") {
253
- return "off";
254
- }
255
- const mode = env.PRIM_HOOK_MODE;
256
- if (mode === "off" || mode === "warn") {
257
- return mode;
258
- }
259
- return "block";
260
- }
261
- function demoteForMode(verdict, mode) {
262
- if (mode === "off") {
263
- return "allow";
264
- }
265
- if (mode === "warn" && (verdict === "ask" || verdict === "deny")) {
266
- return "warn";
267
- }
268
- return verdict;
269
- }
12
+ } from "./chunk-P2O7NLVN.js";
13
+ import {
14
+ parseApplyPatchTargets
15
+ } from "./chunk-W27EFR7W.js";
270
16
 
271
17
  // src/hooks/shell-targets.ts
18
+ import { realpathSync } from "fs";
19
+ import { posix, resolve } from "path";
272
20
  import { parse } from "unbash";
273
21
 
274
22
  // src/hooks/script-targets.ts
@@ -656,7 +404,7 @@ function staticPart(part) {
656
404
  return STATIC_PARTS.has(part.type) || part.type === "DoubleQuoted" && part.parts.every(staticPart);
657
405
  }
658
406
  function staticWord(word) {
659
- if (!word || !word.value || word.value.includes("\0") || word.value.includes("\n")) return;
407
+ if (!word || word.value.includes("\0") || word.value.includes("\n")) return;
660
408
  if (word.parts ? !word.parts.every(staticPart) : word.value.startsWith("~") || /[*?\[$`]/.test(word.text))
661
409
  return;
662
410
  return word.value;
@@ -940,11 +688,66 @@ function unknown(state) {
940
688
  state.complete = false;
941
689
  state.mutation = true;
942
690
  }
691
+ function addTarget(path, state) {
692
+ if (state.cwdUncertain) {
693
+ state.complete = false;
694
+ return;
695
+ }
696
+ state.paths.add(
697
+ state.cwdPrefix && !posix.isAbsolute(path) ? posix.join(state.cwdPrefix, path) : path
698
+ );
699
+ }
700
+ function sedWriteTargets(words) {
701
+ const args = staticArgs(words);
702
+ if (!args) return;
703
+ let suffix;
704
+ let gnuInPlace = false;
705
+ const programs = [];
706
+ const files = [];
707
+ let positionalProgram = true;
708
+ let options = true;
709
+ for (let i = 0; i < args.length; i++) {
710
+ const arg = args[i];
711
+ if (options && arg === "--") {
712
+ options = false;
713
+ continue;
714
+ }
715
+ if (options && (arg === "-i" || arg === "--in-place")) {
716
+ if (suffix !== void 0) return;
717
+ suffix = "";
718
+ gnuInPlace = arg === "--in-place";
719
+ if (arg === "-i" && (args[i + 1] === "" || args[i + 1]?.startsWith("."))) suffix = args[++i];
720
+ } else if (options && (arg.startsWith("-i") || arg.startsWith("--in-place="))) {
721
+ if (suffix !== void 0) return;
722
+ gnuInPlace = arg.startsWith("--in-place=");
723
+ suffix = arg.startsWith("-i") ? arg.slice(2) : arg.slice("--in-place=".length);
724
+ } else if (options && (arg === "-e" || arg === "--expression")) {
725
+ const program = args[++i];
726
+ if (!program) return;
727
+ programs.push(program);
728
+ positionalProgram = false;
729
+ } else if (options && (arg.startsWith("-e") || arg.startsWith("--expression="))) {
730
+ programs.push(arg.startsWith("-e") ? arg.slice(2) : arg.slice("--expression=".length));
731
+ positionalProgram = false;
732
+ } else if (options && ["-E", "-r", "-n", "--regexp-extended", "--quiet", "--silent"].includes(arg)) {
733
+ } else if (options && arg.startsWith("-")) return;
734
+ else if (positionalProgram) {
735
+ programs.push(arg);
736
+ positionalProgram = false;
737
+ } else files.push(arg);
738
+ }
739
+ if (suffix === void 0 || !programs.length || !programs.every(safeSedProgram) || !files.length || files.some((file) => !file || file === "-"))
740
+ return;
741
+ if (suffix.includes("*") && !gnuInPlace) return;
742
+ return files.flatMap(
743
+ (file) => suffix ? [file, suffix.includes("*") ? suffix.replaceAll("*", file) : file + suffix] : [file]
744
+ );
745
+ }
943
746
  function recordTarget(word, state) {
944
747
  const path = staticWord(word);
945
748
  if (path === "-" || path && (SINKS.has(path) || path.startsWith("/dev/fd/"))) return;
946
749
  state.mutation = true;
947
- if (path) state.paths.add(path);
750
+ if (path) addTarget(path, state);
948
751
  else state.complete = false;
949
752
  }
950
753
  function visitRedirect(redirect, state) {
@@ -974,7 +777,7 @@ function visitApplyPatch(command, state) {
974
777
  continue;
975
778
  }
976
779
  const targets = parseApplyPatchTargets(redirect.content);
977
- for (const path of targets.paths) state.paths.add(path);
780
+ for (const path of targets.paths) addTarget(path, state);
978
781
  if (!targets.complete) state.complete = false;
979
782
  }
980
783
  if (!hasBody) state.complete = false;
@@ -1013,7 +816,7 @@ function embeddedScript(command, name, state) {
1013
816
  source = heredoc.content;
1014
817
  }
1015
818
  if (source !== void 0)
1016
- for (const path of scriptWriteTargets(source, language)) state.paths.add(path);
819
+ for (const path of scriptWriteTargets(source, language)) addTarget(path, state);
1017
820
  }
1018
821
  function changesDirectory(value) {
1019
822
  if (Array.isArray(value)) return value.some(changesDirectory);
@@ -1027,6 +830,7 @@ function changesDirectory(value) {
1027
830
  }
1028
831
  function visitCommand(command, state) {
1029
832
  const name = staticWord(command.name);
833
+ if (command.prefix.length) unknown(state);
1030
834
  const literalApplyPatch = name === "apply_patch" && !command.redirects.some((redirect) => redirect.operator === "<<-");
1031
835
  if (literalApplyPatch) {
1032
836
  visitApplyPatch(command, state);
@@ -1035,13 +839,15 @@ function visitCommand(command, state) {
1035
839
  }
1036
840
  if (name && (name === "node" || /^python(?:3(?:\.\d+)?)?$/.test(name))) {
1037
841
  embeddedScript(command, name, state);
1038
- } else if (!name || name.includes("/") || !literalApplyPatch && command.suffix.some((word) => !staticWord(word))) {
842
+ } else if (!name || name.includes("/") || !literalApplyPatch && command.suffix.some((word) => staticWord(word) === void 0)) {
1039
843
  unknown(state);
1040
844
  } else if (literalApplyPatch) {
1041
845
  } else if (!READ_ONLY_COMMANDS.has(name) && !knownNoWorktreeMutation(name, staticArgs(command.suffix))) {
1042
846
  state.mutation = true;
1043
847
  let targets;
1044
- if (name === "tee") {
848
+ if (name === "sed") {
849
+ targets = sedWriteTargets(command.suffix);
850
+ } else if (name === "tee") {
1045
851
  targets = operands(command.suffix, "ai", /* @__PURE__ */ new Set(["--append", "--ignore-interrupts"]));
1046
852
  } else if (name === "touch") {
1047
853
  targets = operands(command.suffix);
@@ -1056,7 +862,7 @@ function visitCommand(command, state) {
1056
862
  if (pair?.length === 2) targets = name === "cp" ? [pair[1]] : pair;
1057
863
  }
1058
864
  if (!targets?.length) state.complete = false;
1059
- else for (const target of targets) state.paths.add(target);
865
+ else for (const target of targets) addTarget(target, state);
1060
866
  }
1061
867
  visitNested([command.name, command.prefix, command.suffix, command.redirects], state);
1062
868
  }
@@ -1085,7 +891,45 @@ function visitStatement(statement, state) {
1085
891
  for (const redirect of statement.redirects) visitRedirect(redirect, state);
1086
892
  visitNested([statement.redirects, statement.command], state);
1087
893
  }
1088
- function analyzeShellTargets(source) {
894
+ function visitStaticDirectoryChain(script, state, cwd) {
895
+ if (script.errors?.length || script.commands.length !== 1) return false;
896
+ const statement = script.commands[0];
897
+ const chain = statement.command;
898
+ if (statement.background || statement.redirects.length || chain.type !== "AndOr" || chain.operators.some((operator) => operator !== "&&") || chain.commands.some((command) => command.type !== "Command"))
899
+ return false;
900
+ const commands = chain.commands;
901
+ if (!commands.some((command) => staticWord(command.name) === "cd")) return false;
902
+ let prefix = "";
903
+ const visits = [];
904
+ for (const command of commands) {
905
+ if (staticWord(command.name) !== "cd") {
906
+ if (changesDirectory(command)) return false;
907
+ visits.push({ command, prefix });
908
+ continue;
909
+ }
910
+ const args = staticArgs(command.suffix);
911
+ if (!args || command.prefix.length || command.redirects.length) return false;
912
+ if (args[0] === "--") args.shift();
913
+ if (args.length !== 1 || !args[0] || args[0].startsWith("-")) return false;
914
+ if (process.env.CDPATH && !args[0].startsWith(".") && !posix.isAbsolute(args[0])) return false;
915
+ prefix = posix.isAbsolute(args[0]) ? args[0] : posix.join(prefix, args[0]);
916
+ if (cwd) {
917
+ try {
918
+ const absolute = resolve(realpathSync(cwd), prefix);
919
+ if (realpathSync(absolute) !== absolute) return false;
920
+ } catch {
921
+ return false;
922
+ }
923
+ }
924
+ }
925
+ state.cwdUncertain = false;
926
+ for (const visit of visits) {
927
+ state.cwdPrefix = visit.prefix;
928
+ visitCommand(visit.command, state);
929
+ }
930
+ return true;
931
+ }
932
+ function analyzeShellTargets(source, cwd) {
1089
933
  if (!source.trim())
1090
934
  return { paths: [], coverage: "complete", mutation: "none" };
1091
935
  try {
@@ -1097,7 +941,9 @@ function analyzeShellTargets(source) {
1097
941
  definiteEdit: false,
1098
942
  cwdUncertain: changesDirectory(script)
1099
943
  };
1100
- for (const statement of script.commands) visitStatement(statement, state);
944
+ if (!visitStaticDirectoryChain(script, state, cwd)) {
945
+ for (const statement of script.commands) visitStatement(statement, state);
946
+ }
1101
947
  if (script.errors?.length) state.mutation = true;
1102
948
  return {
1103
949
  paths: [...state.paths],
@@ -1113,7 +959,7 @@ function analyzeShellTargets(source) {
1113
959
  // src/demo/state.ts
1114
960
  import { createHash, randomUUID } from "crypto";
1115
961
  import { existsSync, lstatSync, readFileSync, readdirSync } from "fs";
1116
- import { join, resolve } from "path";
962
+ import { join, resolve as resolve2 } from "path";
1117
963
  var RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
1118
964
  var demoDirectory = () => join(primConfigDirectory(), "demo");
1119
965
  var runPath = (id) => {
@@ -1156,7 +1002,7 @@ function prepareRun(agent, terminal = false) {
1156
1002
  terminal,
1157
1003
  agent,
1158
1004
  preparationKey: preparationKey(agent),
1159
- launcher: [process.execPath, resolve(process.argv[1])]
1005
+ launcher: [process.execPath, resolve2(process.argv[1])]
1160
1006
  };
1161
1007
  saveRun(run);
1162
1008
  return run;
@@ -1178,7 +1024,7 @@ function demoCommand(run, action, choice, reason) {
1178
1024
  function demoWelcomeCommand(run) {
1179
1025
  return [
1180
1026
  process.execPath,
1181
- resolve(process.argv[1]),
1027
+ resolve2(process.argv[1]),
1182
1028
  "welcome",
1183
1029
  "--after-demo",
1184
1030
  ...run.agent ? ["--agent", run.agent === "claude_code" ? "claude" : run.agent] : [],
@@ -1186,10 +1032,10 @@ function demoWelcomeCommand(run) {
1186
1032
  ].map(quote).join(" ");
1187
1033
  }
1188
1034
  function demoDiagnosticCommand(run) {
1189
- return [process.execPath, resolve(process.argv[1]), "demo", "status", run.id].map(quote).join(" ");
1035
+ return [process.execPath, resolve2(process.argv[1]), "demo", "status", run.id].map(quote).join(" ");
1190
1036
  }
1191
1037
  function demoResumeCommand(run) {
1192
- return [process.execPath, resolve(process.argv[1]), "demo", "resume", run.id].map(quote).join(" ");
1038
+ return [process.execPath, resolve2(process.argv[1]), "demo", "resume", run.id].map(quote).join(" ");
1193
1039
  }
1194
1040
  function onboardingFinished() {
1195
1041
  const path = join(demoDirectory(), "onboarding.json");
@@ -1306,17 +1152,6 @@ function isolationDiagnostics(run) {
1306
1152
  }
1307
1153
 
1308
1154
  export {
1309
- buildHookOutput,
1310
- buildCodexOutput,
1311
- buildCursorOutput,
1312
- failOpenOutput,
1313
- failOpenCodex,
1314
- failOpenCursor,
1315
- buildHermesOutput,
1316
- failOpenHermes,
1317
- extractFileTargets,
1318
- readHookMode,
1319
- demoteForMode,
1320
1155
  analyzeShellTargets,
1321
1156
  RUN_ID,
1322
1157
  runPath,