aegiscode 7.0.14 → 7.0.16

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