aegisone 1.0.21 → 1.0.23

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 (226) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -2
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -939
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/permissions.js +1 -369
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/bin/aegiscode.js +2 -914
  17. package/vendor/cli/package.json +3 -2
  18. package/vendor/cli/scripts/check.mjs +1 -52
  19. package/vendor/cli/scripts/demo.mjs +1 -94
  20. package/vendor/cli/scripts/predist.mjs +1 -75
  21. package/vendor/cli/scripts/runtests.mjs +1 -56
  22. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  23. package/vendor/cli/src/agents.js +1 -139
  24. package/vendor/cli/src/app.js +1 -2932
  25. package/vendor/cli/src/art.js +1 -289
  26. package/vendor/cli/src/autonomous.js +1 -515
  27. package/vendor/cli/src/caps.js +1 -879
  28. package/vendor/cli/src/chatflow.js +1 -3008
  29. package/vendor/cli/src/checkpoint.js +1 -90
  30. package/vendor/cli/src/clipboard.js +1 -424
  31. package/vendor/cli/src/cloudsync.js +1 -528
  32. package/vendor/cli/src/commands.js +1 -3987
  33. package/vendor/cli/src/config.js +1 -581
  34. package/vendor/cli/src/connect.js +1 -349
  35. package/vendor/cli/src/credentials.js +1 -33
  36. package/vendor/cli/src/deps.js +1 -232
  37. package/vendor/cli/src/devrun.js +1 -187
  38. package/vendor/cli/src/diff.js +1 -333
  39. package/vendor/cli/src/diffview.js +1 -296
  40. package/vendor/cli/src/engine.js +1 -297
  41. package/vendor/cli/src/entitlement.js +1 -355
  42. package/vendor/cli/src/events.js +1 -707
  43. package/vendor/cli/src/export.js +1 -67
  44. package/vendor/cli/src/fingerprint.js +1 -592
  45. package/vendor/cli/src/format.js +1 -259
  46. package/vendor/cli/src/fuzzy.js +1 -119
  47. package/vendor/cli/src/gate.js +1 -55
  48. package/vendor/cli/src/history.js +1 -401
  49. package/vendor/cli/src/init.js +1 -175
  50. package/vendor/cli/src/input.js +1 -139
  51. package/vendor/cli/src/keys.js +1 -183
  52. package/vendor/cli/src/limits.js +1 -190
  53. package/vendor/cli/src/markdown.js +1 -306
  54. package/vendor/cli/src/mcp.js +1 -694
  55. package/vendor/cli/src/models.js +1 -487
  56. package/vendor/cli/src/naming.js +1 -229
  57. package/vendor/cli/src/overlays.js +1 -461
  58. package/vendor/cli/src/panels.js +1 -1418
  59. package/vendor/cli/src/permissions.js +1 -290
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/provenance.js +2 -182
  63. package/vendor/cli/src/render.js +1 -515
  64. package/vendor/cli/src/screen.js +1 -518
  65. package/vendor/cli/src/screens.js +1 -896
  66. package/vendor/cli/src/secret.js +1 -59
  67. package/vendor/cli/src/securefs.js +1 -359
  68. package/vendor/cli/src/settings.js +1 -155
  69. package/vendor/cli/src/shared.js +1 -52
  70. package/vendor/cli/src/sharedpaths.js +1 -53
  71. package/vendor/cli/src/signup.js +1 -156
  72. package/vendor/cli/src/summarize.js +1 -95
  73. package/vendor/cli/src/sysdiag.js +1 -585
  74. package/vendor/cli/src/system.js +1 -40
  75. package/vendor/cli/src/theme.js +1 -570
  76. package/vendor/cli/src/title.js +1 -220
  77. package/vendor/cli/src/todos.js +1 -115
  78. package/vendor/cli/src/tokens.js +1 -263
  79. package/vendor/cli/src/topup.js +1 -210
  80. package/vendor/cli/src/update.js +1 -181
  81. package/vendor/cli/vendor/client/aegis.js +1 -2054
  82. package/vendor/cli/vendor/client/attest.js +1 -442
  83. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  84. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  85. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  86. package/vendor/cli/vendor/client/byok-catalog.js +1 -230
  87. package/vendor/cli/vendor/client/credentials.js +1 -494
  88. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  89. package/vendor/cli/vendor/client/drive-connect.js +1 -85
  90. package/vendor/cli/vendor/client/drive-upload.js +1 -174
  91. package/vendor/cli/vendor/client/env-file.js +1 -1273
  92. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  93. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  94. package/vendor/cli/vendor/client/google-signin.js +1 -125
  95. package/vendor/cli/vendor/client/hooks.js +1 -430
  96. package/vendor/cli/vendor/client/model-discovery.js +1 -330
  97. package/vendor/cli/vendor/client/platform.js +1 -937
  98. package/vendor/cli/vendor/client/prefs.js +1 -351
  99. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  100. package/vendor/cli/vendor/client/presence.js +1 -438
  101. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  102. package/vendor/cli/vendor/client/session-store.js +1 -548
  103. package/vendor/cli/vendor/client/topup.js +1 -297
  104. package/vendor/cli/vendor/client/touch.js +1 -458
  105. package/vendor/cli/vendor/client/update.js +1 -704
  106. package/vendor/cli/vendor/client/user-models.js +1 -381
  107. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  108. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  109. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -993
  110. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -95
  111. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3228
  112. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -654
  113. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  114. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2135
  115. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -275
  116. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  117. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -208
  118. package/vendor/cli/vendor/desktop/lib/local/shell.js +1 -680
  119. package/vendor/cli/vendor/desktop/lib/local/tools.js +1 -1238
  120. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  121. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  122. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  123. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  124. package/vendor/cli/vendor/hosts/install.js +1 -638
  125. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  126. package/vendor/cli/vendor/hosts/spec.js +1 -164
  127. package/vendor/cli/vendor/hosts/targets.js +1 -346
  128. package/vendor/cli/vendor/mcp/server.js +1 -221
  129. package/vendor/cli/vendor/mcp/tools.js +1 -408
  130. package/vendor/cli/vendor/one/src/child.js +1 -285
  131. package/vendor/cli/vendor/one/src/permissions.js +1 -369
  132. package/vendor/desktop/bin/aegis.js +1 -32
  133. package/vendor/desktop/lib/account-key.js +1 -56
  134. package/vendor/desktop/lib/auto.js +1 -430
  135. package/vendor/desktop/lib/avatar/companion.js +1 -698
  136. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  137. package/vendor/desktop/lib/avatar/events.js +1 -344
  138. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  139. package/vendor/desktop/lib/avatar/holders.js +1 -612
  140. package/vendor/desktop/lib/avatar/identity.js +1 -641
  141. package/vendor/desktop/lib/avatar/level.js +1 -368
  142. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  143. package/vendor/desktop/lib/avatar/persona.js +1 -388
  144. package/vendor/desktop/lib/avatar/profile.js +1 -977
  145. package/vendor/desktop/lib/avatar/register.js +1 -307
  146. package/vendor/desktop/lib/avatar/store.js +1 -472
  147. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  148. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  149. package/vendor/desktop/lib/avatar/turn.js +1 -216
  150. package/vendor/desktop/lib/avatar/voice.js +1 -328
  151. package/vendor/desktop/lib/avatar/xp.js +1 -404
  152. package/vendor/desktop/lib/deep-link.js +1 -120
  153. package/vendor/desktop/lib/fingerprint.js +2 -347
  154. package/vendor/desktop/lib/google-connect.js +1 -169
  155. package/vendor/desktop/lib/local/agents.js +1 -105
  156. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  157. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  158. package/vendor/desktop/lib/local/context.js +1 -95
  159. package/vendor/desktop/lib/local/engine.js +1 -3228
  160. package/vendor/desktop/lib/local/entitlement.js +1 -654
  161. package/vendor/desktop/lib/local/git-scope.js +1 -228
  162. package/vendor/desktop/lib/local/local.js +1 -2135
  163. package/vendor/desktop/lib/local/prompt.js +1 -275
  164. package/vendor/desktop/lib/local/queue.js +1 -560
  165. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  166. package/vendor/desktop/lib/local/shell.js +1 -680
  167. package/vendor/desktop/lib/local/telemetry.js +1 -470
  168. package/vendor/desktop/lib/local/tools.js +1 -1238
  169. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  170. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  171. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  172. package/vendor/desktop/lib/quick-launcher.js +1 -84
  173. package/vendor/desktop/lib/settings.js +1 -890
  174. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  175. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  176. package/vendor/desktop/lib/sync/sessions.js +1 -106
  177. package/vendor/desktop/lib/window-state.js +1 -66
  178. package/vendor/desktop/main.js +1 -4390
  179. package/vendor/desktop/package.json +3 -5
  180. package/vendor/desktop/preload.js +1 -628
  181. package/vendor/desktop/renderer/app.js +1 -6560
  182. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  183. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  184. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  185. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  186. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  187. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  188. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  189. package/vendor/desktop/renderer/budget.js +1 -168
  190. package/vendor/desktop/renderer/companion.js +1 -223
  191. package/vendor/desktop/renderer/diff.js +1 -359
  192. package/vendor/desktop/renderer/diffview.js +1 -336
  193. package/vendor/desktop/renderer/fingerprint.js +3 -720
  194. package/vendor/desktop/renderer/markdown.js +1 -168
  195. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  196. package/vendor/desktop/renderer/providers.js +1 -259
  197. package/vendor/desktop/renderer/quick.js +1 -191
  198. package/vendor/desktop/renderer/stream-policy.js +1 -306
  199. package/vendor/desktop/renderer/transcript-view.js +1 -323
  200. package/vendor/desktop/renderer/usage.js +1 -1239
  201. package/vendor/desktop/vendor/aegis.js +1 -2054
  202. package/vendor/desktop/vendor/attest.js +1 -442
  203. package/vendor/desktop/vendor/authorship-key.js +1 -410
  204. package/vendor/desktop/vendor/auto-provision.js +1 -134
  205. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  206. package/vendor/desktop/vendor/byok-catalog.js +1 -230
  207. package/vendor/desktop/vendor/credentials.js +1 -494
  208. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  209. package/vendor/desktop/vendor/drive-connect.js +1 -85
  210. package/vendor/desktop/vendor/drive-upload.js +1 -174
  211. package/vendor/desktop/vendor/env-file.js +1 -1273
  212. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  213. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  214. package/vendor/desktop/vendor/google-signin.js +1 -125
  215. package/vendor/desktop/vendor/hooks.js +1 -430
  216. package/vendor/desktop/vendor/model-discovery.js +1 -330
  217. package/vendor/desktop/vendor/platform.js +1 -937
  218. package/vendor/desktop/vendor/prefs.js +1 -351
  219. package/vendor/desktop/vendor/presence-constants.js +1 -107
  220. package/vendor/desktop/vendor/presence.js +1 -438
  221. package/vendor/desktop/vendor/record-vault.js +3 -1055
  222. package/vendor/desktop/vendor/session-store.js +1 -548
  223. package/vendor/desktop/vendor/topup.js +1 -297
  224. package/vendor/desktop/vendor/touch.js +1 -458
  225. package/vendor/desktop/vendor/update.js +1 -704
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -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};