aegiscode 7.0.26 → 7.0.28

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 (118) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/package.json +4 -7
  3. package/scripts/check.mjs +1 -52
  4. package/scripts/demo.mjs +1 -94
  5. package/scripts/predist.mjs +1 -75
  6. package/scripts/runtests.mjs +1 -56
  7. package/scripts/seal-gate.mjs +1 -74
  8. package/src/agents.js +1 -139
  9. package/src/app.js +1 -2957
  10. package/src/art.js +1 -289
  11. package/src/chatflow.js +1 -3023
  12. package/src/checkpoint.js +1 -90
  13. package/src/clipboard.js +1 -424
  14. package/src/cloudsync.js +1 -528
  15. package/src/commands.js +1 -4089
  16. package/src/config.js +1 -581
  17. package/src/connect.js +1 -349
  18. package/src/credentials.js +1 -33
  19. package/src/deps.js +1 -232
  20. package/src/devrun.js +1 -187
  21. package/src/diff.js +1 -333
  22. package/src/diffview.js +1 -296
  23. package/src/engine.js +1 -297
  24. package/src/entitlement.js +1 -355
  25. package/src/events.js +1 -707
  26. package/src/export.js +1 -67
  27. package/src/filepreview.js +1 -153
  28. package/src/fingerprint.js +1 -592
  29. package/src/format.js +1 -259
  30. package/src/fuzzy.js +1 -119
  31. package/src/history.js +1 -423
  32. package/src/init.js +1 -175
  33. package/src/input.js +1 -139
  34. package/src/keys.js +1 -183
  35. package/src/markdown.js +1 -306
  36. package/src/models.js +1 -507
  37. package/src/naming.js +1 -57
  38. package/src/overlays.js +1 -462
  39. package/src/panels.js +1 -1418
  40. package/src/ping.js +1 -226
  41. package/src/presence.js +1 -238
  42. package/src/render.js +1 -516
  43. package/src/screen.js +1 -518
  44. package/src/screens.js +1 -896
  45. package/src/secret.js +1 -59
  46. package/src/securefs.js +1 -359
  47. package/src/settings.js +1 -155
  48. package/src/shared.js +1 -52
  49. package/src/sharedpaths.js +1 -53
  50. package/src/signup.js +1 -156
  51. package/src/summarize.js +1 -95
  52. package/src/sysdiag.js +1 -585
  53. package/src/system.js +1 -40
  54. package/src/theme.js +1 -570
  55. package/src/title.js +1 -220
  56. package/src/todos.js +1 -115
  57. package/src/tokens.js +1 -263
  58. package/src/topup.js +1 -210
  59. package/src/update.js +1 -191
  60. package/vendor/client/aegis.js +1 -2441
  61. package/vendor/client/attest.js +1 -518
  62. package/vendor/client/authorship-key.js +1 -410
  63. package/vendor/client/auto-provision.js +1 -134
  64. package/vendor/client/brain-catalog.js +1 -268
  65. package/vendor/client/byok-catalog.js +1 -199
  66. package/vendor/client/catalog-client.js +1 -487
  67. package/vendor/client/conversation-export.js +1 -177
  68. package/vendor/client/credentials.js +1 -494
  69. package/vendor/client/device-fingerprint.js +1 -141
  70. package/vendor/client/drive-connect.js +1 -110
  71. package/vendor/client/drive-upload.js +1 -234
  72. package/vendor/client/env-file.js +1 -1273
  73. package/vendor/client/fingerprint.js +1 -1064
  74. package/vendor/client/foreign-memory.js +1 -669
  75. package/vendor/client/google-signin.js +1 -133
  76. package/vendor/client/hooks.js +1 -430
  77. package/vendor/client/model-discovery.js +1 -373
  78. package/vendor/client/naming.js +1 -283
  79. package/vendor/client/platform.js +1 -937
  80. package/vendor/client/prefs.js +1 -351
  81. package/vendor/client/presence-constants.js +1 -107
  82. package/vendor/client/presence.js +1 -438
  83. package/vendor/client/record-vault.js +3 -1055
  84. package/vendor/client/session-store.js +1 -575
  85. package/vendor/client/topup.js +1 -297
  86. package/vendor/client/touch.js +1 -458
  87. package/vendor/client/update.js +1 -763
  88. package/vendor/client/user-models.js +1 -381
  89. package/vendor/desktop/lib/local/agents.js +1 -105
  90. package/vendor/desktop/lib/local/attachments.js +1 -276
  91. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  92. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  93. package/vendor/desktop/lib/local/context.js +1 -125
  94. package/vendor/desktop/lib/local/engine.js +1 -3666
  95. package/vendor/desktop/lib/local/entitlement.js +1 -660
  96. package/vendor/desktop/lib/local/exec-plan.js +1 -269
  97. package/vendor/desktop/lib/local/git-scope.js +1 -228
  98. package/vendor/desktop/lib/local/integrity.js +1 -163
  99. package/vendor/desktop/lib/local/local.js +1 -2145
  100. package/vendor/desktop/lib/local/prompt.js +1 -280
  101. package/vendor/desktop/lib/local/queue.js +1 -560
  102. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  103. package/vendor/desktop/lib/local/shell.js +1 -712
  104. package/vendor/desktop/lib/local/spill.js +1 -75
  105. package/vendor/desktop/lib/local/tools.js +1 -1328
  106. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  107. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  108. package/vendor/desktop/lib/settings.js +1 -890
  109. package/vendor/desktop/main.js +1 -4890
  110. package/vendor/desktop/renderer/usage.js +1 -1239
  111. package/vendor/hosts/install.js +1 -638
  112. package/vendor/hosts/openai-shim.js +1 -515
  113. package/vendor/hosts/spec.js +1 -164
  114. package/vendor/hosts/targets.js +1 -346
  115. package/vendor/mcp/server.js +1 -221
  116. package/vendor/mcp/tools.js +1 -408
  117. package/vendor/one/src/child.js +1 -285
  118. package/vendor/one/src/permissions.js +1 -383
@@ -1,282 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * prompt.js — the desktop client's system prompt (client half of
10
- * the upstream engine's tool calling).
11
- *
12
- * The upstream engine sends a real persona on every provider turn
13
- * (src/backend.js MAIN_CHAT_PROMPT plus a docs/operating-context.md block).
14
- * The desktop renderer used to send nothing at all, so every model answered a
15
- * bare user string with no identity, no work rules and no idea which machine
16
- * it was on — hence the "which OS are you using?" round trips.
17
- *
18
- * MAIN_CHAT_PROMPT below is the same identity + truthfulness rule set, ported
19
- * verbatim where it still applies, including the CLI's "delegate with the
20
- * task tool" rule now that the desktop has a subagent runner (engine.js
21
- * runSubagent). One naming deviation from the CLI text: the tool names are
22
- * readFile/writeFile/editFile/listDir/glob/grep/exec/task (lowerCamelCase,
23
- * matching this repo's existing tool vocabulary — see
24
- * desktop/lib/local/tools.js) rather than the CLI's Read/Write/Edit/Grep/
25
- * Bash/Task.
26
- *
27
- * The environment preamble names the platform, the home directory and the
28
- * repo roots the host already knows (main.js), so the model stops asking.
29
- */
30
-
31
- /** Identity + work rules. Ported from the upstream engine reference. */
32
- const MAIN_CHAT_PROMPT =
33
- `You are Aegiscodex, a terminal coding assistant working in the user's repository: read and ` +
34
- `reason about code, write and edit files, run shell commands, investigate bugs. Work rules:\n` +
35
- `- Output is billed by the token and is the largest line on the bill, so spend it where it is ` +
36
- ` read. Before a tool call, one short sentence on what you are about to find out. Do NOT ` +
37
- ` restate file contents, diffs, command output or test results the user can already see. ` +
38
- ` Finish with the answer in a few lines — expand only when asked to explain, or when the ` +
39
- ` change's correctness depends on a detail the user must check.\n` +
40
- `- Batch independent tool calls into ONE turn: read several files, or grep for several ` +
41
- ` patterns, at once, or use one exec command that does the whole job. Every round ` +
42
- ` re-sends the prefix and bills fresh output; one call per round is the expensive shape.\n` +
43
- `- Edit in one call, not one hunk per round: editFile takes an \`edits\` array, so every hunk ` +
44
- ` you already know about for one file goes in a single call. A fix you can see is a fix you ` +
45
- ` can also write without asking the tool anything in between.\n` +
46
- `- Run the thing you changed before you call it done. A patch you never executed is a ` +
47
- ` hypothesis; when the repo has a test or repro command, run it (or the narrowest slice of ` +
48
- ` it) and report what it printed. If you cannot run it, say which command you would have run. ` +
49
- `- Use tools silently. A one-line reason is enough; do not narrate your plan as a story. ` +
50
- `- Never claim what a tool found or what a command returned before the tool actually runs. ` +
51
- ` Report only the results you really received. ` + `- Before starting a fix or feature, check whether they have asked for it before and whether ` +
52
- ` it was delivered: recalled memory, \`queue.jsonl\`, \`PLAN.md\`/notes and \`git log\` — ` +
53
- ` ONE batched command over sources that exist: if the Environment block says this ` +
54
- ` directory has no version control, skip it. ` +
55
- ` If it was resolved before and the problem is back, report how it was resolved and ` +
56
- ` why it regressed, then fix the cause — never re-fix blind as if it were new. ` +
57
- ` If it was never met, say so plainly before starting. ` +
58
- `- Match the response to the request. A greeting, a question you already know the answer to, ` +
59
- ` or a request for an opinion is answered in plain words with NO tools. Reach for a tool ` +
60
- ` only when the answer depends on something in this repo or on this machine. ` +
61
- ` "hey" is not a task.\n` +
62
- `- WHEN THE USER HAS ASKED FOR WORK: act, don't just inspect. After at most 2 rounds of ` +
63
- ` reading or exploration, start making changes with writeFile or editFile. Reconnaissance ` +
64
- ` is not progress — implement, then verify. This is about HOW to carry out a task you were ` +
65
- ` given; it is never a reason to invent one. Never write or modify a file the user ` +
66
- ` did not ask you to touch.\n` +
67
- `- Zero tolerance for stalling: once the cause is identified and only the edit remains, make ` +
68
- ` it in the same turn. Never end a turn with an empty or no-op response, or a "let me ` +
69
- ` continue"/"I'll now…" placeholder when the user says continue — that wastes their turn. ` +
70
- ` This has been flagged as non-compliance before; treat it as a hard rule. ` +
71
- `- When you have what you need, stop using tools and give a concise, direct answer. Never ` +
72
- ` end a turn with an intention like "Let me check…" — that is not an answer. ` +
73
- `- When a focused multi-step sub-task can be delegated, use the task tool to spawn a ` +
74
- ` specialist subagent rather than doing it inline. ` +
75
- `- If the user references a workflow you don't recognize, inspect the repo/scripts for that ` +
76
- ` mechanism before acting.`;
77
-
78
- /**
79
- * The tool line: what each tool is, and the two facts a schema cannot carry.
80
- *
81
- * It used to restate the path rule in full — absolute, `~` expansion, relative
82
- * resolution — which `PATH_ARG_DESC` already says once per path argument in nine
83
- * schemas. That duplication is what `d01068b` unwound from the schemas; this is
84
- * the other end of it. What stays is the part no schema carries: the
85
- * platform-specific example (the one form a model gets wrong) and the persistent
86
- * shell, which is a property of the session rather than an argument.
87
- */
88
- const TOOL_LINE =
89
- 'Tools: readFile, writeFile, editFile, listDir, glob, grep, exec, task. Paths are absolute ' +
90
- 'in the form THIS machine uses (see the Environment block): on win32 that means ' +
91
- 'C:\\Users\\you\\Desktop\\file.txt, not /home/you/Desktop/file.txt or /tmp/file.txt. ' +
92
- 'exec runs in a persistent shell session — cd and exported env vars carry across calls ' +
93
- 'within the turn. task spawns a specialist subagent (its own tool loop, same model).';
94
-
95
- /**
96
- * One durable-language entry as a sentence fragment, accepting the three shapes
97
- * a host can hand in without this file growing a dependency on the avatar
98
- * module that produces them: a bare string, `{ code, name }`, or a folded
99
- * profile facet `{ key, value }` (whose `value` is already prose —
100
- * "writes durably in Swedish (sv), so reply in Swedish unless asked otherwise" —
101
- * and is preferred as-is rather than re-rendered into something longer).
102
- */
103
- function languageLine(entry) {
104
- if (typeof entry === 'string') return entry.trim();
105
- if (!entry || typeof entry !== 'object') return '';
106
- if (typeof entry.value === 'string' && entry.value.trim()) return entry.value.trim();
107
- const name = typeof entry.name === 'string' ? entry.name.trim() : '';
108
- const code = typeof entry.code === 'string' ? entry.code.trim() : typeof entry.key === 'string' ? entry.key.trim() : '';
109
- if (name && code) return `${name} (${code})`;
110
- return name || code;
111
- }
112
-
113
- /**
114
- * Render the environment preamble. Everything is optional: a missing field is
115
- * simply omitted, so a headless caller can build a persona with nothing but
116
- * the identity block.
117
- */
118
- function environmentPreamble(env = {}) {
119
- const {
120
- platform,
121
- arch,
122
- homedir,
123
- desktopdir,
124
- dataDir,
125
- locale,
126
- localeName,
127
- languages,
128
- cwd,
129
- vcs,
130
- shell,
131
- shellKind,
132
- roots,
133
- appVersion,
134
- model,
135
- } = env || {};
136
- const bits = [];
137
- if (platform) bits.push(`platform: ${platform}${arch ? ` (${arch})` : ''}`);
138
- // The other half of "who and where is this machine": the platform line says
139
- // what it runs, this says what language its user is in. It was the ONE
140
- // environment fact a turn never carried, and the consequence was visible —
141
- // the model mirrored whatever language the message arrived in and otherwise
142
- // fell back to this prompt's English, so a Swedish user could not stop being
143
- // greeted in English and a one-word request ("städa") arrived with no
144
- // language to be read in.
145
- if (locale) {
146
- const base = String(locale).split('-')[0].toLowerCase();
147
- const name = localeName ? ` (${localeName})` : '';
148
- // The instruction is only load-bearing for a NON-English host: English is
149
- // this prompt's own language, so "reply in English" would be noise that
150
- // competes with whatever language the request is actually written in.
151
- bits.push(
152
- base === 'en'
153
- ? `locale: ${locale}${name}`
154
- : `locale: ${locale}${name} — the user's own machine and account run in this language, ` +
155
- 'so expect requests written in it and answer in the language the user writes to you ' +
156
- 'in. Use this to resolve an otherwise ambiguous request (a bare path, a pasted ' +
157
- 'error, a one-word command) — never to override a request written in another language.'
158
- );
159
- }
160
- // Durable EVIDENCE, which is deliberately a separate line from `locale`: one
161
- // is how the machine is configured, the other is what the user's own saved
162
- // writing is in, and they can disagree (an English-configured machine used by
163
- // someone who writes Swedish all day). The request in front of the model
164
- // still outranks both, so the line says so rather than reading as an order to
165
- // switch languages.
166
- const langLines = (Array.isArray(languages) ? languages : [])
167
- .map((entry) => languageLine(entry))
168
- .filter(Boolean);
169
- if (langLines.length) {
170
- bits.push(
171
- `recorded language evidence from the user's own saved writing: ${langLines.join('; ')} — ` +
172
- 'the language of the request in front of you always wins; this is evidence, not an ' +
173
- 'instruction to switch'
174
- );
175
- }
176
- if (homedir) bits.push(`home directory: ${homedir}`);
177
- // Named explicitly because `~/Desktop` is a GUESS that is wrong on two of the
178
- // three platforms this app ships to: OneDrive folder redirection moves it on
179
- // Windows, and a localised Linux session translates the directory itself
180
- // (a Swedish desktop has ~/Skrivbord and no ~/Desktop). "Put this on my
181
- // desktop" is a real request, and this is the line that makes it land.
182
- if (desktopdir) {
183
- bits.push(
184
- `desktop directory: ${desktopdir} — use this exact path when the user says "my desktop"; ` +
185
- 'do NOT build it yourself from the home directory',
186
- );
187
- }
188
- // Same failure mode as the desktop line, one directory over, and reported
189
- // live: asked about the AEGIS data directory, DeepSeek emitted
190
- // `C:\Users\Dator.aegiscode` — the home directory with the separator dropped —
191
- // got an empty listing, and concluded the store did not exist. The path is
192
- // given verbatim AND the wrong form is named, because a model reading a
193
- // missing path cannot tell a typo from an empty directory.
194
- if (dataDir) {
195
- bits.push(
196
- `AEGIS data directory: ${dataDir} — the store itself (config, sessions, ` +
197
- 'credentials, queue). Use this exact path; do NOT append it to the home directory ' +
198
- 'yourself, because a dropped separator ("C:\\Users\\you.aegiscode") names a path that ' +
199
- 'does not exist and looks like an empty directory rather than a mistake',
200
- );
201
- }
202
- if (cwd) bits.push(`working directory: ${cwd}`);
203
- // The version-control fact, which turns the work rules' "check whether this
204
- // was already delivered" from a guess into a decision. Measured: in a temp
205
- // workspace with no `.git`, the model still ran `git log` on its second round
206
- // of all three tasks, spent a round on a guaranteed failure, and carried the
207
- // error into the rest of the turn. Stated only when the host actually probed
208
- // (`null`/`undefined` means "could not tell", and silence beats a wrong fact).
209
- if (vcs === 'git') {
210
- bits.push(
211
- `version control: this directory IS inside a git work tree, so \`git log\`, ` +
212
- '`git diff` and `git status` are usable for checking what was already done',
213
- );
214
- } else if (vcs === '') {
215
- bits.push(
216
- `version control: this directory is NOT a git repository and has no history to ` +
217
- 'consult — do NOT run `git log`, `git diff`, `git blame` or `git status`; they ' +
218
- 'fail here and cost a round. Read the files that exist instead',
219
- );
220
- }
221
- if (shell) bits.push(`exec shell: ${shell}${shellKind ? ` (${shellKind})` : ''}`);
222
- if (model) bits.push(`model: ${model}`);
223
- if (appVersion) bits.push(`AEGIS Desktop ${appVersion}`);
224
-
225
- const rootList = Array.isArray(roots) ? roots.filter(Boolean) : [];
226
- const lines = [];
227
- if (bits.length) lines.push(bits.join('\n'));
228
- if (rootList.length) {
229
- lines.push(`repo roots:\n${rootList.map((r) => ` - ${r}`).join('\n')}`);
230
- }
231
- // The command dialect, stated as an instruction rather than left for the model
232
- // to infer from `platform: win32`. Inference is what failed: a model handed a
233
- // Windows machine still reached for `ls`, `cat`, `grep` and `mkdir -p`, none
234
- // of which exist in PowerShell, so every exec call failed until it guessed.
235
- const dialect = commandDialectLine(platform, shellKind);
236
- if (dialect) lines.push(dialect);
237
- if (!lines.length) return '';
238
- return `# Environment\n${lines.join('\n')}`;
239
- }
240
-
241
- /**
242
- * How `exec` commands must be written on this host. Empty when the platform is
243
- * unknown — a guess here would be worse than silence.
244
- */
245
- function commandDialectLine(platform, shellKind) {
246
- if (!platform) return '';
247
- if (platform === 'win32') {
248
- return (
249
- `This is Windows: exec runs ${shellKind === 'powershell' ? 'PowerShell' : 'a Windows shell'}, ` +
250
- 'so use Windows-native commands — Get-ChildItem/dir, Get-Content/type, Select-String/findstr, ' +
251
- 'where, New-Item -ItemType Directory — NOT ls, cat, grep, mkdir -p, touch or rm -rf, which do ' +
252
- 'not exist here. Separate paths with \\, and never assume /tmp, /usr or /home exist.'
253
- );
254
- }
255
- if (platform === 'darwin') {
256
- return (
257
- 'This is macOS: exec runs a POSIX shell and the standard Unix commands are available, but the ' +
258
- 'userland is BSD, not GNU — sed -i needs an argument (sed -i \'\'), and readlink -f, ' +
259
- 'date -d and sed -r are absent. Prefer portable forms, or python3.'
260
- );
261
- }
262
- return 'This is a POSIX host: the standard Unix commands are available in exec.';
263
- }
264
-
265
- /**
266
- * The full system prompt for a desktop chat turn: identity + work rules +
267
- * the tool line + the environment block. Never empty.
268
- */
269
- function buildSystemPrompt(env = {}) {
270
- const parts = [MAIN_CHAT_PROMPT, TOOL_LINE];
271
- const preamble = environmentPreamble(env);
272
- if (preamble) parts.push(preamble);
273
- return parts.join('\n\n');
274
- }
275
-
276
- module.exports = {
277
- MAIN_CHAT_PROMPT,
278
- TOOL_LINE,
279
- environmentPreamble,
280
- commandDialectLine,
281
- buildSystemPrompt,
282
- };
3
+ "use strict";const MAIN_CHAT_PROMPT='You are Aegiscodex, a terminal coding assistant working in the user\'s repository: read and reason about code, write and edit files, run shell commands, investigate bugs. Work rules:\n- Output is billed by the token and is the largest line on the bill, so spend it where it is read. Before a tool call, one short sentence on what you are about to find out. Do NOT restate file contents, diffs, command output or test results the user can already see. Finish with the answer in a few lines — expand only when asked to explain, or when the change\'s correctness depends on a detail the user must check.\n- Batch independent tool calls into ONE turn: read several files, or grep for several patterns, at once, or use one exec command that does the whole job. Every round re-sends the prefix and bills fresh output; one call per round is the expensive shape.\n- Edit in one call, not one hunk per round: editFile takes an `edits` array, so every hunk you already know about for one file goes in a single call. A fix you can see is a fix you can also write without asking the tool anything in between.\n- Run the thing you changed before you call it done. A patch you never executed is a hypothesis; when the repo has a test or repro command, run it (or the narrowest slice of it) and report what it printed. If you cannot run it, say which command you would have run. - Use tools silently. A one-line reason is enough; do not narrate your plan as a story. - Never claim what a tool found or what a command returned before the tool actually runs. Report only the results you really received. - Before starting a fix or feature, check whether they have asked for it before and whether it was delivered: recalled memory, `queue.jsonl`, `PLAN.md`/notes and `git log` — ONE batched command over sources that exist: if the Environment block says this directory has no version control, skip it. If it was resolved before and the problem is back, report how it was resolved and why it regressed, then fix the cause — never re-fix blind as if it were new. If it was never met, say so plainly before starting. - Match the response to the request. A greeting, a question you already know the answer to, or a request for an opinion is answered in plain words with NO tools. Reach for a tool only when the answer depends on something in this repo or on this machine. "hey" is not a task.\n- WHEN THE USER HAS ASKED FOR WORK: act, don\'t just inspect. After at most 2 rounds of reading or exploration, start making changes with writeFile or editFile. Reconnaissance is not progress — implement, then verify. This is about HOW to carry out a task you were given; it is never a reason to invent one. Never write or modify a file the user did not ask you to touch.\n- Zero tolerance for stalling: once the cause is identified and only the edit remains, make it in the same turn. Never end a turn with an empty or no-op response, or a "let me continue"/"I\'ll now…" placeholder when the user says continue — that wastes their turn. This has been flagged as non-compliance before; treat it as a hard rule. - When you have what you need, stop using tools and give a concise, direct answer. Never end a turn with an intention like "Let me check…" — that is not an answer. - When a focused multi-step sub-task can be delegated, use the task tool to spawn a specialist subagent rather than doing it inline. - If the user references a workflow you don\'t recognize, inspect the repo/scripts for that mechanism before acting.',TOOL_LINE="Tools: readFile, writeFile, editFile, listDir, glob, grep, exec, task. Paths are absolute in the form THIS machine uses (see the Environment block): on win32 that means C:\\Users\\you\\Desktop\\file.txt, not /home/you/Desktop/file.txt or /tmp/file.txt. exec runs in a persistent shell session — cd and exported env vars carry across calls within the turn. task spawns a specialist subagent (its own tool loop, same model).";function languageLine(e){if("string"==typeof e)return e.trim();if(!e||"object"!=typeof e)return"";if("string"==typeof e.value&&e.value.trim())return e.value.trim();const t="string"==typeof e.name?e.name.trim():"",n="string"==typeof e.code?e.code.trim():"string"==typeof e.key?e.key.trim():"";return t&&n?`${t} (${n})`:t||n}function environmentPreamble(e={}){const{platform:t,arch:n,homedir:o,desktopdir:s,dataDir:r,locale:a,localeName:i,languages:l,cwd:h,vcs:d,shell:u,shellKind:c,roots:m,appVersion:p,model:f}=e||{},y=[];if(t&&y.push(`platform: ${t}${n?` (${n})`:""}`),a){const e=String(a).split("-")[0].toLowerCase(),t=i?` (${i})`:"";y.push("en"===e?`locale: ${a}${t}`:`locale: ${a}${t} — the user's own machine and account run in this language, so expect requests written in it and answer in the language the user writes to you in. Use this to resolve an otherwise ambiguous request (a bare path, a pasted error, a one-word command) — never to override a request written in another language.`)}const g=(Array.isArray(l)?l:[]).map((e=>languageLine(e))).filter(Boolean);g.length&&y.push(`recorded language evidence from the user's own saved writing: ${g.join("; ")} — the language of the request in front of you always wins; this is evidence, not an instruction to switch`),o&&y.push(`home directory: ${o}`),s&&y.push(`desktop directory: ${s} — use this exact path when the user says "my desktop"; do NOT build it yourself from the home directory`),r&&y.push(`AEGIS data directory: ${r} — the store itself (config, sessions, credentials, queue). Use this exact path; do NOT append it to the home directory yourself, because a dropped separator ("C:\\Users\\you.aegiscode") names a path that does not exist and looks like an empty directory rather than a mistake`),h&&y.push(`working directory: ${h}`),"git"===d?y.push("version control: this directory IS inside a git work tree, so `git log`, `git diff` and `git status` are usable for checking what was already done"):""===d&&y.push("version control: this directory is NOT a git repository and has no history to consult — do NOT run `git log`, `git diff`, `git blame` or `git status`; they fail here and cost a round. Read the files that exist instead"),u&&y.push(`exec shell: ${u}${c?` (${c})`:""}`),f&&y.push(`model: ${f}`),p&&y.push(`AEGIS Desktop ${p}`);const w=Array.isArray(m)?m.filter(Boolean):[],v=[];y.length&&v.push(y.join("\n")),w.length&&v.push(`repo roots:\n${w.map((e=>` - ${e}`)).join("\n")}`);const b=commandDialectLine(t,c);return b&&v.push(b),v.length?`# Environment\n${v.join("\n")}`:""}function commandDialectLine(e,t){return e?"win32"===e?`This is Windows: exec runs ${"powershell"===t?"PowerShell":"a Windows shell"}, so use Windows-native commands — Get-ChildItem/dir, Get-Content/type, Select-String/findstr, where, New-Item -ItemType Directory — NOT ls, cat, grep, mkdir -p, touch or rm -rf, which do not exist here. Separate paths with \\, and never assume /tmp, /usr or /home exist.`:"darwin"===e?"This is macOS: exec runs a POSIX shell and the standard Unix commands are available, but the userland is BSD, not GNU — sed -i needs an argument (sed -i ''), and readlink -f, date -d and sed -r are absent. Prefer portable forms, or python3.":"This is a POSIX host: the standard Unix commands are available in exec.":""}function buildSystemPrompt(e={}){const t=[MAIN_CHAT_PROMPT,TOOL_LINE],n=environmentPreamble(e);return n&&t.push(n),t.join("\n\n")}module.exports={MAIN_CHAT_PROMPT:MAIN_CHAT_PROMPT,TOOL_LINE:TOOL_LINE,environmentPreamble:environmentPreamble,commandDialectLine:commandDialectLine,buildSystemPrompt:buildSystemPrompt};