openfox 2.0.65 → 2.0.67

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 (64) hide show
  1. package/README.md +1 -0
  2. package/dist/agent-defaults/builder.agent.md +1 -1
  3. package/dist/agent-defaults/code-reviewer.agent.md +0 -1
  4. package/dist/agent-defaults/explorer.agent.md +0 -1
  5. package/dist/agent-defaults/planner.agent.md +1 -1
  6. package/dist/{branch.api-LAN42BA5.js → branch.api-3YJSWOZG.js} +5 -1
  7. package/dist/{chat-handler-MC3XZ3OV.js → chat-handler-72DFHK5K.js} +16 -13
  8. package/dist/{chunk-Z6H7SFQR.js → chunk-2GRUQN2B.js} +435 -170
  9. package/dist/{chunk-LBGHZLLH.js → chunk-4QBDV6LX.js} +17 -14
  10. package/dist/{chunk-RYIREJAW.js → chunk-5EO6SEGV.js} +2 -2
  11. package/dist/{chunk-N4K3PNOS.js → chunk-B6JUWVTK.js} +95 -29
  12. package/dist/{chunk-QBYQ7KDX.js → chunk-B7WGOK7G.js} +16 -15
  13. package/dist/{chunk-Z6W4YHJB.js → chunk-BL5LOLVA.js} +17 -1
  14. package/dist/{chunk-TMUBLQFC.js → chunk-C3VLGVSQ.js} +3 -3
  15. package/dist/{chunk-ZPIZLTWU.js → chunk-GMXKJGJ2.js} +5 -1
  16. package/dist/{chunk-YQ3SOPBI.js → chunk-KXVFHMSM.js} +2 -2
  17. package/dist/{chunk-4UYKN6JU.js → chunk-MQHMT5WF.js} +3 -3
  18. package/dist/{chunk-VWPY2KWH.js → chunk-PYRH4G2J.js} +9 -35
  19. package/dist/{chunk-BGTEIA2S.js → chunk-TFCHWMOJ.js} +23 -30
  20. package/dist/{chunk-AIJE3RYH.js → chunk-TFDK6VSG.js} +33 -7
  21. package/dist/{chunk-X5YCWKNS.js → chunk-TJO4QFDQ.js} +59 -86
  22. package/dist/{chunk-QJ5FH5DP.js → chunk-TMHWQYWE.js} +4 -4
  23. package/dist/chunk-VLV3XWZS.js +191 -0
  24. package/dist/chunk-WGMJCFCE.js +14 -0
  25. package/dist/chunk-X5DOUA3Z.js +66 -0
  26. package/dist/{chunk-PXJ4NOP4.js → chunk-XUPKS5FL.js} +6 -4
  27. package/dist/{chunk-UEIQKG5P.js → chunk-YU6DZAVA.js} +303 -360
  28. package/dist/{chunk-OESYKZCM.js → chunk-ZLON3JTI.js} +3 -3
  29. package/dist/cli/dev.js +1 -1
  30. package/dist/cli/index.js +1 -1
  31. package/dist/{client-LAKW7TA5.js → client-BUX62J2K.js} +3 -3
  32. package/dist/{client-pure-DO3S675T.js → client-pure-U6ZYUPJQ.js} +6 -4
  33. package/dist/{compactor-I3N56PSJ.js → compactor-74CZVUWI.js} +9 -7
  34. package/dist/{events-52XADT6Y.js → events-CDQ4HASP.js} +4 -4
  35. package/dist/{folding-2BGFLV5J.js → folding-V2K34EGN.js} +2 -2
  36. package/dist/{inspect-proxy-BV25JERQ.js → inspect-proxy-OVEFBJ26.js} +4 -4
  37. package/dist/{manager-344C5JLZ.js → manager-JXYRGR6B.js} +6 -2
  38. package/dist/{orchestrator-IYJRQQKB.js → orchestrator-FEMPJOZD.js} +15 -14
  39. package/dist/package.json +2 -1
  40. package/dist/platform-AB3GIEGO.js +21 -0
  41. package/dist/{processor-LUXKVIED.js → processor-QB3NMRMO.js} +16 -13
  42. package/dist/{project-creator-IDW7RACH.js → project-creator-EMGRSPYS.js} +18 -5
  43. package/dist/{projects-BY227WT2.js → projects-7HSBZY2D.js} +3 -3
  44. package/dist/{protocol-Cq66hdDX.d.ts → protocol-42f_Png6.d.ts} +1 -1
  45. package/dist/provider/index.d.ts +4 -4
  46. package/dist/{provider-GYOW4OWQ.js → provider-BDH6JGZB.js} +4 -4
  47. package/dist/{provider-manager-HRHNF73A.js → provider-manager-D3KIOD5E.js} +4 -4
  48. package/dist/{serve-ZRTWVOL2.js → serve-32FAA4FX.js} +20 -17
  49. package/dist/server/index.d.ts +26 -8
  50. package/dist/server/index.js +19 -16
  51. package/dist/server-OYE7GERR.js +37 -0
  52. package/dist/{settings-JA4XUR3W.js → settings-6ZPWOBWL.js} +3 -3
  53. package/dist/shared/index.d.ts +3 -3
  54. package/dist/{tools-ZZM36DAZ.js → tools-INWP6FGV.js} +14 -11
  55. package/dist/{types-CDZakn7f.d.ts → types-apiMd7Df.d.ts} +1 -1
  56. package/dist/{types-akHmgvBk.d.ts → types-vezAEt_y.d.ts} +3 -1
  57. package/dist/web/assets/{index-Dc05znz4.css → index-BELeAs12.css} +1 -1
  58. package/dist/web/assets/index-C3n65CNu.js +303 -0
  59. package/dist/web/index.html +2 -2
  60. package/dist/web/sw.js +1 -1
  61. package/dist/worktree-6U45P63P.js +30 -0
  62. package/package.json +2 -1
  63. package/dist/server-PXXGMFBT.js +0 -34
  64. package/dist/web/assets/index-Bsi_le80.js +0 -303
@@ -9,30 +9,27 @@ import {
9
9
  startProcess,
10
10
  updateStatus
11
11
  } from "./chunk-PK2RMVMB.js";
12
+ import {
13
+ getPlatformShell
14
+ } from "./chunk-X5DOUA3Z.js";
12
15
 
13
- // src/server/tools/background-process/manager.ts
16
+ // src/server/utils/shell.ts
14
17
  import { spawn } from "child_process";
15
-
16
- // src/server/utils/platform.ts
17
- import os from "os";
18
- function getPlatformShell() {
19
- if (process.platform === "win32") {
20
- return { command: "cmd.exe", args: ["/c"] };
21
- }
22
- const userShell = os.userInfo().shell;
23
- if (userShell) {
24
- return { command: userShell, args: ["-c"] };
25
- }
26
- return { command: "sh", args: ["-c"] };
18
+ function checkAborted(signal) {
19
+ return !!signal?.aborted;
27
20
  }
28
- function getPathSeparator() {
29
- return process.platform === "win32" ? ";" : ":";
30
- }
31
- function isWindowsPath(path) {
32
- return /^[A-Za-z]:[/\\]/.test(path);
21
+ function spawnShell(command, options) {
22
+ const shell = getPlatformShell();
23
+ return spawn(shell.command, [...shell.args, command], {
24
+ cwd: options.cwd,
25
+ env: { ...process.env },
26
+ stdio: options.stdio ?? ["ignore", "pipe", "pipe"],
27
+ windowsHide: true,
28
+ ...options.detached ? { detached: true } : {}
29
+ });
33
30
  }
34
- function isAbsolutePath(path) {
35
- return path.startsWith("/") || isWindowsPath(path);
31
+ function spawnShellProcess(command, cwd, _signal, detached = false) {
32
+ return spawnShell(command, { cwd, detached });
36
33
  }
37
34
 
38
35
  // src/server/tools/background-process/manager.ts
@@ -64,13 +61,9 @@ function createProcess2(sessionId, name, command, cwd, timeout) {
64
61
  function startProcessCommand(processId, sessionId, command, cwd) {
65
62
  const proc = startProcess(processId, sessionId, 0);
66
63
  if (!proc) return null;
67
- const shell = getPlatformShell();
68
- const child = spawn(shell.command, [...shell.args, command], {
64
+ const child = spawnShell(command, {
69
65
  cwd,
70
- env: { ...process.env, FORCE_COLOR: "1" },
71
- stdio: ["ignore", "pipe", "pipe"],
72
- detached: true,
73
- windowsHide: true
66
+ detached: true
74
67
  });
75
68
  proc.pid = child.pid ?? null;
76
69
  updateStatus(processId, sessionId, "running");
@@ -143,9 +136,9 @@ function getProcessLogs(processId, since = 0, maxLines) {
143
136
  }
144
137
 
145
138
  export {
146
- getPlatformShell,
147
- getPathSeparator,
148
- isAbsolutePath,
139
+ checkAborted,
140
+ spawnShell,
141
+ spawnShellProcess,
149
142
  onProcessEvent,
150
143
  createProcess2 as createProcess,
151
144
  startProcessCommand,
@@ -154,4 +147,4 @@ export {
154
147
  getSessionProcesses2 as getSessionProcesses,
155
148
  getProcessLogs
156
149
  };
157
- //# sourceMappingURL=chunk-BGTEIA2S.js.map
150
+ //# sourceMappingURL=chunk-TFCHWMOJ.js.map
@@ -5,10 +5,10 @@ import {
5
5
  foldContextState,
6
6
  foldSessionState,
7
7
  spreadOptionalMessageFields
8
- } from "./chunk-TMUBLQFC.js";
8
+ } from "./chunk-C3VLGVSQ.js";
9
9
  import {
10
10
  getDatabase
11
- } from "./chunk-ZPIZLTWU.js";
11
+ } from "./chunk-GMXKJGJ2.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-K44MW7JJ.js";
@@ -680,21 +680,33 @@ function getProjectDangerLevel(projectId) {
680
680
  return "normal";
681
681
  }
682
682
  }
683
- function createSession(projectId, workdir, title, providerId, providerModel) {
683
+ function createSession(projectId, workdir, title, providerId, providerModel, worktree) {
684
684
  const db = getDatabase();
685
685
  const now = (/* @__PURE__ */ new Date()).toISOString();
686
686
  const id = crypto.randomUUID();
687
687
  const dangerLevel = getProjectDangerLevel(projectId);
688
688
  db.prepare(
689
689
  `
690
- INSERT INTO sessions (id, project_id, workdir, phase, mode, workflow_phase, is_running, created_at, updated_at, title, provider_id, provider_model, danger_level)
691
- VALUES (?, ?, ?, 'idle', 'planner', 'plan', 0, ?, ?, ?, ?, ?, ?)
690
+ INSERT INTO sessions (id, project_id, workdir, worktree, phase, mode, workflow_phase, is_running, created_at, updated_at, title, provider_id, provider_model, danger_level)
691
+ VALUES (?, ?, ?, ?, 'idle', 'planner', 'plan', 0, ?, ?, ?, ?, ?, ?)
692
692
  `
693
- ).run(id, projectId, workdir, now, now, title ?? null, providerId ?? null, providerModel ?? null, dangerLevel);
693
+ ).run(
694
+ id,
695
+ projectId,
696
+ workdir,
697
+ worktree ?? null,
698
+ now,
699
+ now,
700
+ title ?? null,
701
+ providerId ?? null,
702
+ providerModel ?? null,
703
+ dangerLevel
704
+ );
694
705
  return {
695
706
  id,
696
707
  projectId,
697
708
  workdir,
709
+ ...worktree ? { worktree } : {},
698
710
  mode: "planner",
699
711
  phase: "plan",
700
712
  isRunning: false,
@@ -843,6 +855,7 @@ function listSessions() {
843
855
  s.id,
844
856
  s.project_id,
845
857
  s.workdir,
858
+ s.worktree,
846
859
  s.mode,
847
860
  s.workflow_phase,
848
861
  s.is_running,
@@ -866,6 +879,7 @@ function listSessionsByProject(projectId, limit = 20, offset = 0) {
866
879
  s.id,
867
880
  s.project_id,
868
881
  s.workdir,
882
+ s.worktree,
869
883
  s.mode,
870
884
  s.workflow_phase,
871
885
  s.is_running,
@@ -885,6 +899,16 @@ function listSessionsByProject(projectId, limit = 20, offset = 0) {
885
899
  const sessions = rows.slice(0, limit).map(mapSessionSummaryRow);
886
900
  return { sessions, hasMore };
887
901
  }
902
+ function updateSessionWorkdir(id, workdir, worktree) {
903
+ const db = getDatabase();
904
+ const now = (/* @__PURE__ */ new Date()).toISOString();
905
+ db.prepare("UPDATE sessions SET workdir = ?, worktree = ?, updated_at = ? WHERE id = ?").run(
906
+ workdir,
907
+ worktree,
908
+ now,
909
+ id
910
+ );
911
+ }
888
912
  function deleteSession(id) {
889
913
  const db = getDatabase();
890
914
  db.prepare("DELETE FROM sessions WHERE id = ?").run(id);
@@ -894,6 +918,7 @@ function mapSessionBase(row) {
894
918
  id: row.id,
895
919
  projectId: row.project_id,
896
920
  workdir: row.workdir,
921
+ ...row.worktree ? { worktree: row.worktree } : {},
897
922
  mode: row.mode ?? "planner",
898
923
  phase: row.workflow_phase ?? "plan",
899
924
  isRunning: Boolean(row.is_running),
@@ -1396,6 +1421,7 @@ export {
1396
1421
  getSessionCachedPrompt,
1397
1422
  listSessions,
1398
1423
  listSessionsByProject,
1424
+ updateSessionWorkdir,
1399
1425
  deleteSession,
1400
1426
  loadConfig,
1401
1427
  setRuntimeConfig,
@@ -1434,4 +1460,4 @@ export {
1434
1460
  truncateSessionMessages,
1435
1461
  getRecentUserPromptsForSession
1436
1462
  };
1437
- //# sourceMappingURL=chunk-AIJE3RYH.js.map
1463
+ //# sourceMappingURL=chunk-TFDK6VSG.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ getPlatformShell
3
+ } from "./chunk-X5DOUA3Z.js";
1
4
  import {
2
5
  streamWithSegments
3
6
  } from "./chunk-J2GP3J3X.js";
@@ -9,7 +12,7 @@ import {
9
12
  } from "./chunk-YHEQTVFV.js";
10
13
  import {
11
14
  buildModelParams
12
- } from "./chunk-Z6W4YHJB.js";
15
+ } from "./chunk-BL5LOLVA.js";
13
16
  import {
14
17
  logger
15
18
  } from "./chunk-K44MW7JJ.js";
@@ -33,6 +36,7 @@ function computeEffectiveTools(allowedTools, type) {
33
36
  }
34
37
 
35
38
  // src/server/chat/prompts.ts
39
+ import { basename } from "path";
36
40
  function buildBasePrompt(workdir, customInstructions, skills, modelName) {
37
41
  const instructionsSection = customInstructions ? `
38
42
 
@@ -47,120 +51,91 @@ Today's date is ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0].repla
47
51
 
48
52
  ## ENVIRONMENT
49
53
  Working directory: ${workdir}
50
- Platform: ${process.platform} (${process.arch})${modelLine}
54
+ Platform: ${process.platform} (${process.arch})
55
+ Shell (run_command): ${basename(getPlatformShell().command)}${modelLine}
51
56
 
52
57
  ## CORE BEHAVIOR
53
- - Help the user complete any tasks safely and efficiently.
54
- - Do everything in your capacity to satisfy user requirements.
55
- - Read code before changing it.
56
- - Prefer precise, minimal changes.
57
- - Use available tools when needed.
58
- - Explain tradeoffs clearly when requirements are ambiguous.
59
- - Follow repository and project instructions exactly.
58
+ Help user complete tasks safely and efficiently.
59
+ Do everything to satisfy user requirements.
60
+ Read file before editing.
61
+ Prefer precise, minimal changes.
62
+ Use available tools when needed.
63
+ Explain tradeoffs clearly when requirements are ambiguous.
64
+ Follow repository and project instructions exactly.
60
65
 
61
66
  ## MODE CONTROL
62
- - OpenFox may append system-generated runtime control messages as USER-role messages wrapped in <system-reminder>...</system-reminder>.
63
- - These reminders are authoritative framework instructions from OpenFox.
64
- - Treat them as higher-priority operational constraints than normal user task wording for the current turn.
65
- - Do not describe them as "the user reminded me"; they are runtime mode/control metadata injected by OpenFox.
67
+ OpenFox appends runtime control as USER-role messages wrapped in <system-reminder>...</system-reminder>.
68
+ These reminders are authoritative, treat them as higher-priority operational constraints.
69
+ Never say "user reminded me"; they are runtime mode injected by OpenFox.
66
70
 
67
71
  ## WORKFLOW
68
- - If the current runtime reminder says planning mode, focus on understanding, exploration, clarification, and criteria quality.
69
- - If the current runtime reminder says build mode, focus on implementation, verification, and completing approved criteria.
70
- - Respect tool and permission constraints enforced by the server even if the conversation suggests otherwise.
71
-
72
- ## FILE REFERENCES
73
- - The user may reference files or directories with an @ prefix, e.g. @src/index.ts or @web/components/.
74
- - These are paths relative to the working directory above. Strip the leading @ and resolve against the working directory \u2014 never treat an @-reference as an absolute path.
75
-
76
- ## IMPORTANT GUARDRAILS
77
- - NEVER delete/git checkout an already modified file: that would result in a data loss.
78
-
79
-
80
- # Tone and style
81
- You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
82
- Remember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
83
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
84
- If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
85
- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
86
- IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
87
- IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
88
- IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
89
- <example>
72
+ Reminder = planning mode: focus on understanding, exploration, clarification, criteria quality.
73
+ Reminder = build mode: focus on implementation, verification, completing approved criteria.
74
+
75
+ ## TONE AND STYLE
76
+ Be concise, direct, and to the point.
77
+ Explain non-trivial bash commands (what & why).
78
+ Output renders as CLI markdown (CommonMark).
79
+ Only use tools for tasks, not communication.
80
+ No emojis unless asked.
81
+ Minimize tokens, stay on-topic.
82
+ No preamble/postamble.
83
+ Keep responses under ~4 lines unless detail requested.
84
+
85
+ ### Examples
90
86
  user: 2 + 2
91
87
  assistant: 4
92
- </example>
93
-
94
- <example>
95
- user: what is 2+2?
96
- assistant: 4
97
- </example>
98
-
99
- <example>
100
- user: is 11 a prime number?
101
- assistant: Yes
102
- </example>
103
88
 
104
- <example>
105
89
  user: what command should I run to list files in the current directory?
106
90
  assistant: ls
107
- </example>
108
91
 
109
- <example>
110
92
  user: what command should I run to watch files in the current directory?
111
93
  assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
112
- npm run dev
113
- </example>
94
+ npm run dev
114
95
 
115
- <example>
116
- user: How many golf balls fit inside a jetta?
117
- assistant: 150000
118
- </example>
119
-
120
- <example>
121
96
  user: what files are in the directory src/?
122
97
  assistant: [runs ls and sees foo.c, bar.c, baz.c]
123
98
  user: which file contains the implementation of foo?
124
99
  assistant: src/foo.c
125
- </example>
126
100
 
127
- <example>
128
101
  user: write tests for new feature
129
- assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
130
- </example>
102
+ assistant: [uses run_command tool to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
103
+
104
+ ## FILE REFERENCES
105
+ @ prefix, e.g. @src/index.ts or @web/components/.
106
+ Relative to the working directory above. Strip leading @ and resolve against working directory, never treat as absolute path.
107
+
108
+ ## IMPORTANT GUARDRAILS
109
+ NEVER delete/git checkout already modified file: would result in data loss.
131
110
 
132
111
  # Proactiveness
133
- You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
112
+ Allowed to be proactive, but only when user asks you to do something. Balance:
134
113
  1. Doing the right thing when asked, including taking actions and follow-up actions
135
- 2. Not surprising the user with actions you take without asking
136
- For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
137
- 3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
114
+ 2. Not surprising user with actions you take without asking
115
+ For example, if user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
116
+ 3. Do not add additional code explanation summary unless requested by user. After working on a file, just stop, rather than providing an explanation of what you did.
138
117
 
139
118
  # Following conventions
140
- When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
141
- - NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
142
- - When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
143
- - When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
144
- - Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
119
+ Understand file's code conventions. Mimic code style, use existing libraries and utilities, follow existing patterns.
120
+ NEVER assume that a given library is available. To use library or framework, first check that codebase already uses given library.
121
+ When you create new component, first look at existing components to see how written; then consider framework choice, naming conventions, typing, other conventions.
122
+ When you edit code, look at code's surrounding context (imports) to understand code's choice of frameworks and libraries. Then consider how to make given change in way that is most idiomatic.
123
+ Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
145
124
 
146
125
  # Code style
147
- - IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
126
+ IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
148
127
 
149
128
  # Doing tasks
150
- The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
151
- - Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
152
- - Implement the solution using all tools available to you
153
- - Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
154
- - VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.
155
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
156
-
157
- - Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
129
+ User will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
130
+ Use run_command or Explorer sub-agent to understand the codebase and user's query.
131
+ Implement solution using all tools available to you.
132
+ Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check README or search codebase to determine testing approach.
133
+ VERY IMPORTANT: When you have completed a task, you MUST run lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with run_command to ensure your code is correct.
134
+ NEVER commit changes unless user explicitly asks you to. VERY IMPORTANT only commit when explicitly asked, otherwise user will feel that you are being too proactive.
158
135
 
159
136
  # Tool usage policy
160
- - When doing file search, prefer to use the Task tool in order to reduce context usage.
161
- - You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
162
-
163
- You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
137
+ When doing file search, prefer to use the call_sub_agent tool with the "explorer" in order to reduce context usage, except if this would take less than 3 calls to get the information.
138
+ You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.
164
139
 
165
140
  ${instructionsSection}
166
141
  ${buildSkillsSection(skills)}
@@ -256,7 +231,6 @@ function buildAgentSmallReminder(name) {
256
231
  Reminder: you are in '${name}' mode.
257
232
  </system-reminder>`;
258
233
  }
259
- var WORKFLOW_KICKOFF_PROMPT = (criteriaCount) => `Implement the task and make sure you fulfil the ${criteriaCount} criteria.`;
260
234
  var COMPACTION_PROMPT = `You are a helpful AI assistant tasked with summarizing conversations for continuation.
261
235
 
262
236
  Summarize the conversation history concisely, preserving:
@@ -694,7 +668,6 @@ export {
694
668
  buildTopLevelSystemPrompt,
695
669
  buildAgentReminder,
696
670
  buildAgentSmallReminder,
697
- WORKFLOW_KICKOFF_PROMPT,
698
671
  COMPACTION_PROMPT,
699
672
  streamLLMPure,
700
673
  TurnMetrics,
@@ -705,4 +678,4 @@ export {
705
678
  createChatDoneEvent,
706
679
  consumeStreamGenerator
707
680
  };
708
- //# sourceMappingURL=chunk-X5YCWKNS.js.map
681
+ //# sourceMappingURL=chunk-TJO4QFDQ.js.map
@@ -2,11 +2,11 @@ import {
2
2
  getEventStore,
3
3
  getRuntimeConfig,
4
4
  updateSessionMetadata
5
- } from "./chunk-AIJE3RYH.js";
5
+ } from "./chunk-TFDK6VSG.js";
6
6
  import {
7
7
  buildMessagesFromStoredEvents,
8
8
  foldPendingConfirmations
9
- } from "./chunk-TMUBLQFC.js";
9
+ } from "./chunk-C3VLGVSQ.js";
10
10
  import {
11
11
  createContextStateMessage,
12
12
  createSessionStateMessage
@@ -135,7 +135,7 @@ async function generateSessionNameForSession(sessionId, userMessage, deps, signa
135
135
  client = deps.getLLMClient();
136
136
  client.setModel(providerConfig.model);
137
137
  } else if (providerConfig) {
138
- const { createLLMClient } = await import("./client-LAKW7TA5.js");
138
+ const { createLLMClient } = await import("./client-BUX62J2K.js");
139
139
  client = createLLMClient({
140
140
  llm: {
141
141
  baseUrl: providerConfig.baseUrl,
@@ -184,4 +184,4 @@ export {
184
184
  buildRunChatTurnParams,
185
185
  generateSessionNameForSession
186
186
  };
187
- //# sourceMappingURL=chunk-QJ5FH5DP.js.map
187
+ //# sourceMappingURL=chunk-TMHWQYWE.js.map
@@ -0,0 +1,191 @@
1
+ import {
2
+ gitSpawnEnv
3
+ } from "./chunk-WGMJCFCE.js";
4
+ import {
5
+ logger
6
+ } from "./chunk-K44MW7JJ.js";
7
+
8
+ // src/server/git/worktree.ts
9
+ import { spawn } from "child_process";
10
+ import { mkdir, readFile, appendFile, stat, symlink } from "fs/promises";
11
+ import { resolve } from "path";
12
+ import copy from "@danieldietrich/copy";
13
+ function captureStdout(cwd, args) {
14
+ return new Promise((resolvePromise) => {
15
+ const proc = spawn("git", args, { cwd, env: gitSpawnEnv(), stdio: ["ignore", "pipe", "ignore"] });
16
+ let out = "";
17
+ proc.stdout.on("data", (d) => {
18
+ out += d.toString();
19
+ });
20
+ proc.on("close", (code) => resolvePromise(code === 0 ? out : null));
21
+ proc.on("error", () => resolvePromise(null));
22
+ });
23
+ }
24
+ function runGit(cwd, args) {
25
+ return new Promise((resolvePromise, reject) => {
26
+ const proc = spawn("git", args, { cwd, env: gitSpawnEnv(), stdio: ["ignore", "pipe", "pipe"] });
27
+ let stderr = "";
28
+ proc.stderr.on("data", (d) => {
29
+ stderr += d.toString();
30
+ });
31
+ proc.on("close", (code) => {
32
+ if (code === 0) resolvePromise();
33
+ else reject(new Error(stderr.trim() || `git ${args[0]} failed (code ${code})`));
34
+ });
35
+ proc.on("error", (err) => reject(err));
36
+ });
37
+ }
38
+ function getGitBranch(cwd) {
39
+ return captureStdout(cwd, ["rev-parse", "--abbrev-ref", "HEAD"]).then((r) => r?.trim() ?? null);
40
+ }
41
+ function listWorktrees(cwd) {
42
+ return captureStdout(cwd, ["worktree", "list", "--porcelain"]).then((out) => {
43
+ if (!out) return [];
44
+ const entries = [];
45
+ let current = {};
46
+ for (const line of out.split("\n")) {
47
+ if (line.startsWith("worktree ")) current.path = line.slice(9);
48
+ else if (line.startsWith("branch ")) current.branch = line.slice(7).replace("refs/heads/", "");
49
+ else if (line === "" && current.path && current.branch) {
50
+ entries.push({ path: current.path, branch: current.branch });
51
+ current = {};
52
+ }
53
+ }
54
+ if (current.path && current.branch) entries.push({ path: current.path, branch: current.branch });
55
+ return entries;
56
+ });
57
+ }
58
+ function validateRef(cwd, name) {
59
+ return runGit(cwd, ["check-ref-format", `refs/heads/${name}`]);
60
+ }
61
+ function addWorktree(cwd, args) {
62
+ return runGit(cwd, ["worktree", "add", ...args]);
63
+ }
64
+ async function ensureWorktreesIgnored(projectDir) {
65
+ const gitignorePath = resolve(projectDir, ".gitignore");
66
+ let content = "";
67
+ try {
68
+ content = await readFile(gitignorePath, "utf-8");
69
+ } catch {
70
+ }
71
+ const lines = content.split("\n");
72
+ const hasWorktreesIgnore = lines.some(
73
+ (line) => line.trim() === "worktrees/" || line.trim() === "/worktrees/" || line.trim() === "worktrees"
74
+ );
75
+ if (hasWorktreesIgnore) return;
76
+ const entry = content.length > 0 && !content.endsWith("\n") ? "\nworktrees/\n" : "worktrees/\n";
77
+ await appendFile(gitignorePath, entry);
78
+ }
79
+ function listBranches(cwd) {
80
+ return captureStdout(cwd, ["branch", "--format", "%(refname:short)%09%(HEAD)"]).then((out) => {
81
+ if (!out) return [];
82
+ const branches = [];
83
+ for (const line of out.trim().split("\n")) {
84
+ if (!line) continue;
85
+ const [name, head] = line.split(" ");
86
+ if (name) branches.push({ name, current: head === "*" });
87
+ }
88
+ return branches;
89
+ });
90
+ }
91
+ function checkoutBranch(cwd, name) {
92
+ return runGit(cwd, ["checkout", name]);
93
+ }
94
+ function createBranch(cwd, name) {
95
+ return runGit(cwd, ["checkout", "-b", name]);
96
+ }
97
+ function branchExists(cwd, name) {
98
+ return captureStdout(cwd, ["rev-parse", "--verify", `refs/heads/${name}`]).then((r) => r !== null);
99
+ }
100
+ async function ensureWorktree(projectDir, name, startBranch) {
101
+ await validateRef(projectDir, name);
102
+ const worktreesDir = resolve(projectDir, "worktrees");
103
+ const wtPath = resolve(worktreesDir, name.replace(/\//g, "-"));
104
+ await mkdir(worktreesDir, { recursive: true });
105
+ await ensureWorktreesIgnored(projectDir).catch((err) => {
106
+ logger.warn("Failed to update .gitignore", { projectDir, error: String(err) });
107
+ });
108
+ const startBranchResolved = startBranch ?? await getGitBranch(projectDir) ?? "main";
109
+ try {
110
+ const st = await stat(wtPath);
111
+ if (st.isDirectory()) return { path: wtPath, name };
112
+ } catch {
113
+ }
114
+ try {
115
+ await addWorktree(projectDir, ["-b", name, wtPath, startBranchResolved]);
116
+ } catch (err) {
117
+ const exists = await branchExists(projectDir, name);
118
+ if (exists) {
119
+ await addWorktree(projectDir, [wtPath, name]);
120
+ } else {
121
+ throw err;
122
+ }
123
+ }
124
+ return { path: wtPath, name };
125
+ }
126
+ async function getIgnoredDirectories(projectDir) {
127
+ const out = await captureStdout(projectDir, [
128
+ "ls-files",
129
+ "--others",
130
+ "--ignored",
131
+ "--exclude-standard",
132
+ "--directory"
133
+ ]);
134
+ if (!out) return [];
135
+ return out.trim().split("\n").filter(Boolean);
136
+ }
137
+ function resolveStrategy(relPath, config) {
138
+ const normalized = relPath.replace(/\/$/, "");
139
+ const basename = normalized.split("/").pop() ?? normalized;
140
+ return config.overrides?.[normalized] ?? config.overrides?.[basename] ?? config.ignoredAssets;
141
+ }
142
+ async function syncIgnoredAssets(projectDir, worktreePath, config) {
143
+ const ignoredPaths = await getIgnoredDirectories(projectDir);
144
+ if (ignoredPaths.length === 0) return;
145
+ const results = [];
146
+ for (const relPath of ignoredPaths) {
147
+ const sourcePath = resolve(projectDir, relPath);
148
+ const targetPath = resolve(worktreePath, relPath);
149
+ try {
150
+ await stat(sourcePath);
151
+ } catch {
152
+ continue;
153
+ }
154
+ const strategy = resolveStrategy(relPath, config);
155
+ if (strategy === "skip") continue;
156
+ try {
157
+ if (strategy === "symlink") {
158
+ try {
159
+ await stat(targetPath);
160
+ continue;
161
+ } catch {
162
+ }
163
+ await symlink(sourcePath, targetPath);
164
+ results.push(`symlink ${relPath}`);
165
+ } else if (strategy === "copy") {
166
+ await copy(sourcePath, targetPath);
167
+ results.push(`copy ${relPath}`);
168
+ }
169
+ } catch (err) {
170
+ logger.warn("Failed to sync ignored asset to worktree", { relPath, strategy, error: String(err) });
171
+ }
172
+ }
173
+ if (results.length > 0) {
174
+ logger.info("Synced ignored assets to worktree", { count: results.length, actions: results });
175
+ }
176
+ }
177
+
178
+ export {
179
+ getGitBranch,
180
+ listWorktrees,
181
+ validateRef,
182
+ addWorktree,
183
+ ensureWorktreesIgnored,
184
+ listBranches,
185
+ checkoutBranch,
186
+ createBranch,
187
+ ensureWorktree,
188
+ getIgnoredDirectories,
189
+ syncIgnoredAssets
190
+ };
191
+ //# sourceMappingURL=chunk-VLV3XWZS.js.map
@@ -0,0 +1,14 @@
1
+ // src/server/git/env.ts
2
+ function gitSpawnEnv() {
3
+ const env = { ...process.env };
4
+ delete env["GIT_DIR"];
5
+ delete env["GIT_INDEX_FILE"];
6
+ delete env["GIT_WORK_TREE"];
7
+ delete env["GIT_PREFIX"];
8
+ return env;
9
+ }
10
+
11
+ export {
12
+ gitSpawnEnv
13
+ };
14
+ //# sourceMappingURL=chunk-WGMJCFCE.js.map