aegiscode 7.0.25 → 7.0.26

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 (113) hide show
  1. package/package.json +7 -3
  2. package/scripts/check.mjs +52 -1
  3. package/scripts/demo.mjs +94 -1
  4. package/scripts/predist.mjs +75 -1
  5. package/scripts/runtests.mjs +56 -1
  6. package/scripts/seal-gate.mjs +74 -1
  7. package/src/agents.js +139 -1
  8. package/src/app.js +2957 -1
  9. package/src/art.js +289 -1
  10. package/src/chatflow.js +3023 -1
  11. package/src/checkpoint.js +90 -1
  12. package/src/clipboard.js +424 -1
  13. package/src/cloudsync.js +528 -1
  14. package/src/commands.js +4089 -1
  15. package/src/config.js +581 -1
  16. package/src/connect.js +349 -1
  17. package/src/credentials.js +33 -1
  18. package/src/deps.js +232 -1
  19. package/src/devrun.js +187 -1
  20. package/src/diff.js +333 -1
  21. package/src/diffview.js +296 -1
  22. package/src/engine.js +297 -1
  23. package/src/entitlement.js +355 -1
  24. package/src/events.js +707 -1
  25. package/src/export.js +67 -1
  26. package/src/filepreview.js +153 -1
  27. package/src/fingerprint.js +592 -1
  28. package/src/format.js +259 -1
  29. package/src/fuzzy.js +119 -1
  30. package/src/history.js +423 -1
  31. package/src/init.js +175 -1
  32. package/src/input.js +139 -1
  33. package/src/keys.js +183 -1
  34. package/src/markdown.js +306 -1
  35. package/src/models.js +507 -1
  36. package/src/naming.js +57 -1
  37. package/src/overlays.js +462 -1
  38. package/src/panels.js +1418 -1
  39. package/src/ping.js +226 -1
  40. package/src/presence.js +238 -1
  41. package/src/render.js +516 -1
  42. package/src/screen.js +518 -1
  43. package/src/screens.js +896 -1
  44. package/src/secret.js +59 -1
  45. package/src/securefs.js +359 -1
  46. package/src/settings.js +155 -1
  47. package/src/shared.js +52 -1
  48. package/src/sharedpaths.js +53 -1
  49. package/src/signup.js +156 -1
  50. package/src/summarize.js +95 -1
  51. package/src/sysdiag.js +585 -1
  52. package/src/system.js +40 -1
  53. package/src/theme.js +570 -1
  54. package/src/title.js +220 -1
  55. package/src/todos.js +115 -1
  56. package/src/tokens.js +263 -1
  57. package/src/topup.js +210 -1
  58. package/src/update.js +191 -1
  59. package/vendor/client/aegis.js +2441 -1
  60. package/vendor/client/attest.js +518 -1
  61. package/vendor/client/authorship-key.js +410 -1
  62. package/vendor/client/auto-provision.js +134 -1
  63. package/vendor/client/brain-catalog.js +268 -1
  64. package/vendor/client/byok-catalog.js +199 -1
  65. package/vendor/client/catalog-client.js +487 -1
  66. package/vendor/client/conversation-export.js +177 -1
  67. package/vendor/client/credentials.js +494 -1
  68. package/vendor/client/device-fingerprint.js +141 -1
  69. package/vendor/client/drive-connect.js +110 -1
  70. package/vendor/client/drive-upload.js +234 -1
  71. package/vendor/client/env-file.js +1273 -1
  72. package/vendor/client/fingerprint.js +1064 -1
  73. package/vendor/client/foreign-memory.js +669 -1
  74. package/vendor/client/google-signin.js +133 -1
  75. package/vendor/client/hooks.js +430 -1
  76. package/vendor/client/model-discovery.js +373 -1
  77. package/vendor/client/naming.js +283 -1
  78. package/vendor/client/platform.js +937 -1
  79. package/vendor/client/prefs.js +351 -1
  80. package/vendor/client/presence-constants.js +107 -1
  81. package/vendor/client/presence.js +438 -1
  82. package/vendor/client/record-vault.js +1055 -3
  83. package/vendor/client/session-store.js +575 -1
  84. package/vendor/client/topup.js +297 -1
  85. package/vendor/client/touch.js +458 -1
  86. package/vendor/client/update.js +763 -1
  87. package/vendor/client/user-models.js +381 -1
  88. package/vendor/desktop/lib/local/agents.js +105 -1
  89. package/vendor/desktop/lib/local/attachments.js +276 -1
  90. package/vendor/desktop/lib/local/autonomous.js +1045 -1
  91. package/vendor/desktop/lib/local/claude-pro.js +1028 -1
  92. package/vendor/desktop/lib/local/context.js +125 -1
  93. package/vendor/desktop/lib/local/engine.js +3666 -1
  94. package/vendor/desktop/lib/local/entitlement.js +660 -1
  95. package/vendor/desktop/lib/local/git-scope.js +228 -1
  96. package/vendor/desktop/lib/local/local.js +2145 -1
  97. package/vendor/desktop/lib/local/prompt.js +280 -1
  98. package/vendor/desktop/lib/local/queue.js +560 -1
  99. package/vendor/desktop/lib/local/session-rounds.js +238 -1
  100. package/vendor/desktop/lib/local/spill.js +75 -1
  101. package/vendor/desktop/lib/local/turn-guard.js +300 -1
  102. package/vendor/desktop/lib/local/worktree-lock.js +235 -1
  103. package/vendor/desktop/lib/settings.js +890 -1
  104. package/vendor/desktop/renderer/usage.js +1239 -1
  105. package/vendor/hosts/install.js +638 -1
  106. package/vendor/hosts/openai-shim.js +515 -1
  107. package/vendor/hosts/spec.js +164 -1
  108. package/vendor/hosts/targets.js +346 -1
  109. package/vendor/mcp/server.js +221 -1
  110. package/vendor/mcp/tools.js +408 -1
  111. package/vendor/one/src/child.js +285 -1
  112. package/vendor/one/src/permissions.js +383 -1
  113. package/SOURCE-OFFER.txt +0 -9
@@ -1,3 +1,230 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- "use strict";const fs=require("node:fs"),path=require("node:path"),crypto=require("node:crypto"),{spawnSync:spawnSync}=require("node:child_process");function gitRoot(t){const e=spawnSync("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8"});return 0===e.status?e.stdout.trim():null}function contentHash(t,e){try{const n=fs.lstatSync(path.join(t,e));return n.isFile()?crypto.createHash("sha1").update(fs.readFileSync(path.join(t,e))).digest("hex"):n.isDirectory()?"nonfile:dir":"nonfile:other"}catch{return"absent"}}function gitStatusSnapshot(t){const e=gitRoot(t);if(!e)return null;const n=spawnSync("git",["status","--porcelain=v1","-z","--untracked-files=all","--no-renames"],{cwd:e,encoding:"utf8",maxBuffer:67108864});if(0!==n.status)return null;const o=new Map;for(const t of n.stdout.split("\0")){if(t.length<4)continue;const n=t.slice(3);o.set(n,contentHash(e,n))}return o}function foreignChanges(t,e){if(!e)return[];const n=gitStatusSnapshot(t);if(!n)return[];const o=[];for(const[t,s]of n)e.has(t)&&e.get(t)===s&&o.push(t);return o}function toRepoRelative(t,e,n){const o=String(null==n?"":n).trim();if(!o)return"";const s=path.isAbsolute(o)?o:path.resolve(e||t,o),r=path.relative(t,s);return!r||r.startsWith("..")||path.isAbsolute(r)?"":r.split(path.sep).join("/")}function writtenSet(t,e,n){const o=new Set;for(const s of n||[]){const n=toRepoRelative(t,e,s);n&&o.add(n)}return o}function attributedChanges(t,{before:e,written:n}={}){const o=gitRoot(t);if(!o)return null;const s=gitStatusSnapshot(t);if(!s)return null;const r=writtenSet(o,t,n),i=[],a=[];for(const[t,n]of s)e&&e.has(t)&&e.get(t)===n||!r.has(t)?a.push(t):i.push(t);return{root:o,ours:i,left:a,written:r}}function scopedCommit(t,{message:e,before:n,written:o}={}){if(!gitRoot(t))return{skipped:!0,reason:"not a git repo"};if(!n)return{ok:!1,error:"no pre-task snapshot; refusing to sweep the working tree"};const s=attributedChanges(t,{before:n,written:o});if(!s)return{skipped:!0,reason:"not a git repo"};const{root:r,ours:i,left:a}=s;if(!i.length)return{ok:!0,skipped:!0,foreign:a,identicalForeign:foreignChanges(t,n),reason:a.length?`no changes of our own (left ${a.length} change(s) this task did not write)`:"no changes"};const c=spawnSync("git",["add","-A","--pathspec-from-file=-","--pathspec-file-nul"],{cwd:r,encoding:"utf8",input:i.join("\0")});if(0!==c.status)return{ok:!1,error:c.stderr||"git add failed"};const u=spawnSync("git",["commit","-m",e],{cwd:r,encoding:"utf8"});return 0!==u.status?/nothing to commit|no changes added/i.test(u.stdout+u.stderr)?{ok:!0,skipped:!0,foreign:a,reason:"no changes"}:{ok:!1,error:u.stderr||u.stdout}:{ok:!0,message:e,foreign:a,paths:i,staged:i.length}}module.exports={gitRoot:gitRoot,contentHash:contentHash,gitStatusSnapshot:gitStatusSnapshot,foreignChanges:foreignChanges,toRepoRelative:toRepoRelative,writtenSet:writtenSet,attributedChanges:attributedChanges,scopedCommit:scopedCommit};
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
+ * Minimal git worktree introspection: where the repo root is, and what is
10
+ * dirty right now with a content hash per path.
11
+ *
12
+ * Ported from the upstream engine reference (ESM → CommonJS). `turn-guard.js`
13
+ * uses `gitRoot` and `gitStatusSnapshot`; the queue now hosts the commit path
14
+ * too, so `foreignChanges` and `scopedCommit` are carried over as well — they
15
+ * were deliberately absent while nothing here queued work, because a copy of
16
+ * code nothing calls is a copy that drifts unnoticed.
17
+ *
18
+ * ATTRIBUTION IS TWO CONDITIONS, NOT ONE. "Dirty before AND byte-identical
19
+ * now" only excludes work that nobody touched — it cannot see a concurrent
20
+ * writer who edits a file *during* the task window, because that file is no
21
+ * longer byte-identical and so looks like ours. Commit 96fb64f swept exactly
22
+ * such a file (desktop/electron-builder.yml, edited by another live session)
23
+ * into an unrelated commit that way. So `scopedCommit` also requires positive
24
+ * attribution: a path is staged only if the caller reports that THIS task's own
25
+ * tool layer wrote it (`written`). Everything else dirty — foreign, or merely
26
+ * unattributed — is left alone and reported.
27
+ */
28
+
29
+ const fs = require('node:fs');
30
+ const path = require('node:path');
31
+ const crypto = require('node:crypto');
32
+ const { spawnSync } = require('node:child_process');
33
+
34
+ /** The repo root for `cwd`, or null if it isn't inside a git work tree. */
35
+ function gitRoot(cwd) {
36
+ const r = spawnSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8' });
37
+ return r.status === 0 ? r.stdout.trim() : null;
38
+ }
39
+
40
+ /**
41
+ * Hash a path's worktree content, so "already dirty before the task ran" can
42
+ * be told apart from "this task changed it". `absent` covers deletions;
43
+ * non-files (a submodule, a directory) compare by kind.
44
+ */
45
+ function contentHash(cwd, rel) {
46
+ try {
47
+ const st = fs.lstatSync(path.join(cwd, rel));
48
+ if (!st.isFile()) return st.isDirectory() ? 'nonfile:dir' : 'nonfile:other';
49
+ return crypto.createHash('sha1').update(fs.readFileSync(path.join(cwd, rel))).digest('hex');
50
+ } catch {
51
+ return 'absent';
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Every path git reports as dirty right now, mapped to its content hash.
57
+ * `--no-renames` matters: in `-z` porcelain a rename emits the old name as a
58
+ * second NUL-terminated token, which we would otherwise hash as a change.
59
+ * Untracked files are included, since that is exactly how concurrent work
60
+ * usually arrives. Returns null if `cwd` is not a usable git repo.
61
+ */
62
+ function gitStatusSnapshot(cwd) {
63
+ // Run from the repo root: porcelain reports paths root-relative, so hashing
64
+ // must resolve them against the same directory.
65
+ const root = gitRoot(cwd);
66
+ if (!root) return null;
67
+ const r = spawnSync(
68
+ 'git',
69
+ ['status', '--porcelain=v1', '-z', '--untracked-files=all', '--no-renames'],
70
+ { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
71
+ );
72
+ if (r.status !== 0) return null;
73
+ const snap = new Map();
74
+ for (const rec of r.stdout.split('\0')) {
75
+ if (rec.length < 4) continue;
76
+ const p = rec.slice(3);
77
+ snap.set(p, contentHash(root, p));
78
+ }
79
+ return snap;
80
+ }
81
+
82
+ /**
83
+ * Paths that were dirty *before* and are byte-identical now: another agent's
84
+ * in-flight work, not ours. These must never be committed.
85
+ *
86
+ * Byte-identical is the test, not "was dirty": a path that was dirty before and
87
+ * that this task then EDITED has a different hash, so it is ours to commit. Only
88
+ * untouched foreign work is excluded.
89
+ */
90
+ function foreignChanges(cwd, before) {
91
+ if (!before) return [];
92
+ const now = gitStatusSnapshot(cwd);
93
+ if (!now) return [];
94
+ const out = [];
95
+ for (const [p, hash] of now) {
96
+ if (before.has(p) && before.get(p) === hash) out.push(p);
97
+ }
98
+ return out;
99
+ }
100
+
101
+ /**
102
+ * A path the caller reported writing, as repo-root-relative POSIX text.
103
+ *
104
+ * The tool layer reports what the MODEL asked for (`file_path` as typed), which
105
+ * may be absolute or relative to the task's own working directory — not
106
+ * necessarily this process's `cwd`. Returns '' for anything outside the repo:
107
+ * a write that cannot be attributed to a path git reports is not something this
108
+ * function may guess about.
109
+ */
110
+ function toRepoRelative(root, base, p) {
111
+ const raw = String(p == null ? '' : p).trim();
112
+ if (!raw) return '';
113
+ const abs = path.isAbsolute(raw) ? raw : path.resolve(base || root, raw);
114
+ const rel = path.relative(root, abs);
115
+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return '';
116
+ return rel.split(path.sep).join('/');
117
+ }
118
+
119
+ /** The repo-relative set of paths the task's own tool layer reported writing. */
120
+ function writtenSet(root, base, written) {
121
+ const out = new Set();
122
+ for (const p of written || []) {
123
+ const rel = toRepoRelative(root, base, p);
124
+ if (rel) out.add(rel);
125
+ }
126
+ return out;
127
+ }
128
+
129
+ /**
130
+ * Split the current dirty set by attribution. `ours` is what this task wrote
131
+ * and changed; `left` is everything else git reports as dirty — a peer's
132
+ * in-flight work, plus our own changes we cannot positively attribute (a file a
133
+ * shell command created names no path in the tool call, so it is reported, not
134
+ * assumed).
135
+ *
136
+ * @returns {null|{root:string, ours:string[], left:string[], written:Set<string>}}
137
+ */
138
+ function attributedChanges(cwd, { before, written } = {}) {
139
+ const root = gitRoot(cwd);
140
+ if (!root) return null;
141
+ const now = gitStatusSnapshot(cwd);
142
+ if (!now) return null;
143
+ const mine = writtenSet(root, cwd, written);
144
+ const ours = [];
145
+ const left = [];
146
+ for (const [p, hash] of now) {
147
+ // "Differs from the pre-task snapshot": new since then, or the bytes moved.
148
+ const changed = !(before && before.has(p) && before.get(p) === hash);
149
+ if (changed && mine.has(p)) ours.push(p);
150
+ else left.push(p);
151
+ }
152
+ return { root, ours, left, written: mine };
153
+ }
154
+
155
+ /**
156
+ * Commit only the changes this task is known to have made.
157
+ *
158
+ * The rule, in one line: stage a dirty path only if it DIFFERS from the
159
+ * pre-task snapshot AND this task's tool layer reports writing it. Two
160
+ * conditions, because either alone is unsafe: "changed since the snapshot"
161
+ * sweeps a concurrent writer who edits mid-run, and "was dirty before and is
162
+ * byte-identical now" cannot be the only exclusion because it sees only the
163
+ * writer who stopped.
164
+ *
165
+ * `before` is the `gitStatusSnapshot(cwd)` taken immediately before the task
166
+ * ran and `written` the paths the caller's tool layer wrote during it; without
167
+ * either there is no basis for attribution, and the only safe move is to refuse
168
+ * (or stage nothing) — `git add -A` here would commit a concurrent agent's
169
+ * half-finished edit under this task's message.
170
+ *
171
+ * @returns {{ok?:boolean,skipped?:boolean,reason?:string,error?:string,
172
+ * message?:string,staged?:number,paths?:string[],foreign?:string[],
173
+ * identicalForeign?:string[]}}
174
+ */
175
+ function scopedCommit(cwd, { message, before, written } = {}) {
176
+ if (!gitRoot(cwd)) return { skipped: true, reason: 'not a git repo' };
177
+
178
+ // No basis for attribution — refuse rather than sweep.
179
+ if (!before) {
180
+ return { ok: false, error: 'no pre-task snapshot; refusing to sweep the working tree' };
181
+ }
182
+
183
+ const attributed = attributedChanges(cwd, { before, written });
184
+ if (!attributed) return { skipped: true, reason: 'not a git repo' };
185
+ const { root, ours, left } = attributed;
186
+
187
+ if (!ours.length) {
188
+ const untouched = foreignChanges(cwd, before);
189
+ return {
190
+ ok: true,
191
+ skipped: true,
192
+ foreign: left,
193
+ identicalForeign: untouched,
194
+ reason: left.length
195
+ ? `no changes of our own (left ${left.length} change(s) this task did not write)`
196
+ : 'no changes',
197
+ };
198
+ }
199
+
200
+ // pathspec-from-file keeps an arbitrarily long (or space/NUL-bearing) list
201
+ // safe — a 400-file commit is fine, a path with a newline in it is not.
202
+ const add = spawnSync('git', ['add', '-A', '--pathspec-from-file=-', '--pathspec-file-nul'], {
203
+ cwd: root,
204
+ encoding: 'utf8',
205
+ input: ours.join('\0'),
206
+ });
207
+ if (add.status !== 0) return { ok: false, error: add.stderr || 'git add failed' };
208
+
209
+ const commit = spawnSync('git', ['commit', '-m', message], { cwd: root, encoding: 'utf8' });
210
+ if (commit.status !== 0) {
211
+ // "nothing to commit" is a success for our purposes: the changes we staged
212
+ // were already committed by somebody else, and the task's work is done.
213
+ if (/nothing to commit|no changes added/i.test(commit.stdout + commit.stderr)) {
214
+ return { ok: true, skipped: true, foreign: left, reason: 'no changes' };
215
+ }
216
+ return { ok: false, error: commit.stderr || commit.stdout };
217
+ }
218
+ return { ok: true, message, foreign: left, paths: ours, staged: ours.length };
219
+ }
220
+
221
+ module.exports = {
222
+ gitRoot,
223
+ contentHash,
224
+ gitStatusSnapshot,
225
+ foreignChanges,
226
+ toRepoRelative,
227
+ writtenSet,
228
+ attributedChanges,
229
+ scopedCommit,
230
+ };