aura-code 0.5.0 → 0.10.1

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 (294) hide show
  1. package/README.md +47 -164
  2. package/dist/agent/affect.d.ts +13 -0
  3. package/dist/agent/affect.js +34 -0
  4. package/dist/agent/affect.js.map +1 -0
  5. package/dist/agent/compactor.d.ts +27 -4
  6. package/dist/agent/compactor.js +185 -54
  7. package/dist/agent/compactor.js.map +1 -1
  8. package/dist/agent/confess.d.ts +35 -0
  9. package/dist/agent/confess.js +296 -0
  10. package/dist/agent/confess.js.map +1 -0
  11. package/dist/agent/domain-expertise.d.ts +22 -0
  12. package/dist/agent/domain-expertise.js +110 -0
  13. package/dist/agent/domain-expertise.js.map +1 -0
  14. package/dist/agent/executive-queue.d.ts +26 -0
  15. package/dist/agent/executive-queue.js +50 -0
  16. package/dist/agent/executive-queue.js.map +1 -0
  17. package/dist/agent/generational-flush.d.ts +28 -0
  18. package/dist/agent/generational-flush.js +48 -0
  19. package/dist/agent/generational-flush.js.map +1 -0
  20. package/dist/agent/loop-profile.d.ts +50 -0
  21. package/dist/agent/loop-profile.js +88 -0
  22. package/dist/agent/loop-profile.js.map +1 -0
  23. package/dist/agent/loop.d.ts +14 -5
  24. package/dist/agent/loop.js +167 -23
  25. package/dist/agent/loop.js.map +1 -1
  26. package/dist/agent/memory-consolidate.d.ts +14 -0
  27. package/dist/agent/memory-consolidate.js +141 -0
  28. package/dist/agent/memory-consolidate.js.map +1 -0
  29. package/dist/agent/mixture.d.ts +33 -0
  30. package/dist/agent/mixture.js +138 -0
  31. package/dist/agent/mixture.js.map +1 -0
  32. package/dist/agent/spawner.js +2 -2
  33. package/dist/agent/spawner.js.map +1 -1
  34. package/dist/agent/system-prompt.d.ts +1 -1
  35. package/dist/agent/system-prompt.js +49 -13
  36. package/dist/agent/system-prompt.js.map +1 -1
  37. package/dist/agent/unified-memory.d.ts +15 -0
  38. package/dist/agent/unified-memory.js +164 -0
  39. package/dist/agent/unified-memory.js.map +1 -0
  40. package/dist/checkpoints/engine.d.ts +44 -0
  41. package/dist/checkpoints/engine.js +324 -0
  42. package/dist/checkpoints/engine.js.map +1 -0
  43. package/dist/cli/command-palette.d.ts +26 -0
  44. package/dist/cli/command-palette.js +133 -0
  45. package/dist/cli/command-palette.js.map +1 -0
  46. package/dist/cli/context-health.d.ts +51 -0
  47. package/dist/cli/context-health.js +187 -0
  48. package/dist/cli/context-health.js.map +1 -0
  49. package/dist/cli/diamond.d.ts +67 -0
  50. package/dist/cli/diamond.js +222 -12
  51. package/dist/cli/diamond.js.map +1 -1
  52. package/dist/cli/dic.d.ts +2 -0
  53. package/dist/cli/dic.js +106 -0
  54. package/dist/cli/dic.js.map +1 -0
  55. package/dist/cli/diff-view.d.ts +18 -0
  56. package/dist/cli/diff-view.js +114 -0
  57. package/dist/cli/diff-view.js.map +1 -0
  58. package/dist/cli/display.d.ts +18 -4
  59. package/dist/cli/display.js +74 -146
  60. package/dist/cli/display.js.map +1 -1
  61. package/dist/cli/help-data.d.ts +7 -0
  62. package/dist/cli/help-data.js +80 -0
  63. package/dist/cli/help-data.js.map +1 -0
  64. package/dist/cli/index.js +1001 -788
  65. package/dist/cli/index.js.map +1 -1
  66. package/dist/cli/markdown.d.ts +5 -0
  67. package/dist/cli/markdown.js +128 -0
  68. package/dist/cli/markdown.js.map +1 -0
  69. package/dist/cli/model-select.d.ts +39 -0
  70. package/dist/cli/model-select.js +65 -0
  71. package/dist/cli/model-select.js.map +1 -0
  72. package/dist/cli/tui.d.ts +34 -0
  73. package/dist/cli/tui.js +1176 -0
  74. package/dist/cli/tui.js.map +1 -0
  75. package/dist/config/defaults.d.ts +6 -17
  76. package/dist/config/defaults.js +25 -39
  77. package/dist/config/defaults.js.map +1 -1
  78. package/dist/config/project-config.d.ts +2 -6
  79. package/dist/config/project-config.js +2 -2
  80. package/dist/config/project-config.js.map +1 -1
  81. package/dist/doctor/checks.d.ts +18 -0
  82. package/dist/doctor/checks.js +524 -0
  83. package/dist/doctor/checks.js.map +1 -0
  84. package/dist/doctor/index.d.ts +4 -0
  85. package/dist/doctor/index.js +229 -0
  86. package/dist/doctor/index.js.map +1 -0
  87. package/dist/doctor/repair.d.ts +19 -0
  88. package/dist/doctor/repair.js +126 -0
  89. package/dist/doctor/repair.js.map +1 -0
  90. package/dist/doctor/types.d.ts +38 -0
  91. package/dist/doctor/types.js +10 -0
  92. package/dist/doctor/types.js.map +1 -0
  93. package/dist/dream/dream.d.ts +79 -36
  94. package/dist/dream/dream.js +327 -117
  95. package/dist/dream/dream.js.map +1 -1
  96. package/dist/dream/episode.d.ts +17 -0
  97. package/dist/dream/episode.js +116 -0
  98. package/dist/dream/episode.js.map +1 -0
  99. package/dist/dream/okf.d.ts +10 -0
  100. package/dist/dream/okf.js +280 -0
  101. package/dist/dream/okf.js.map +1 -0
  102. package/dist/dream/parser.d.ts +60 -0
  103. package/dist/dream/parser.js +176 -0
  104. package/dist/dream/parser.js.map +1 -0
  105. package/dist/dream/reconcile.d.ts +69 -0
  106. package/dist/dream/reconcile.js +303 -0
  107. package/dist/dream/reconcile.js.map +1 -0
  108. package/dist/kanban/engine.d.ts +26 -0
  109. package/dist/kanban/engine.js +208 -0
  110. package/dist/kanban/engine.js.map +1 -0
  111. package/dist/kanban/types.d.ts +19 -0
  112. package/dist/kanban/types.js +9 -1
  113. package/dist/kanban/types.js.map +1 -1
  114. package/dist/machina/index.d.ts +16 -0
  115. package/dist/machina/index.js +61 -0
  116. package/dist/machina/index.js.map +1 -0
  117. package/dist/machina/render-html.d.ts +2 -0
  118. package/dist/machina/render-html.js +191 -0
  119. package/dist/machina/render-html.js.map +1 -0
  120. package/dist/machina/render-terminal.d.ts +2 -0
  121. package/dist/machina/render-terminal.js +99 -0
  122. package/dist/machina/render-terminal.js.map +1 -0
  123. package/dist/machina/repair.d.ts +23 -0
  124. package/dist/machina/repair.js +98 -0
  125. package/dist/machina/repair.js.map +1 -0
  126. package/dist/machina/spec.d.ts +61 -0
  127. package/dist/machina/spec.js +124 -0
  128. package/dist/machina/spec.js.map +1 -0
  129. package/dist/machina/verify.d.ts +39 -0
  130. package/dist/machina/verify.js +95 -0
  131. package/dist/machina/verify.js.map +1 -0
  132. package/dist/mining/extract.d.ts +34 -0
  133. package/dist/mining/extract.js +229 -0
  134. package/dist/mining/extract.js.map +1 -0
  135. package/dist/mining/refine.d.ts +28 -0
  136. package/dist/mining/refine.js +256 -0
  137. package/dist/mining/refine.js.map +1 -0
  138. package/dist/perception/extractor.js +5 -3
  139. package/dist/perception/extractor.js.map +1 -1
  140. package/dist/perception/graph-store.d.ts +0 -11
  141. package/dist/perception/graph-store.js +0 -33
  142. package/dist/perception/graph-store.js.map +1 -1
  143. package/dist/perception/index.d.ts +1 -1
  144. package/dist/perception/index.js +1 -2
  145. package/dist/perception/index.js.map +1 -1
  146. package/dist/plugins/commands.d.ts +38 -0
  147. package/dist/plugins/commands.js +134 -0
  148. package/dist/plugins/commands.js.map +1 -0
  149. package/dist/plugins/frontmatter.d.ts +14 -0
  150. package/dist/plugins/frontmatter.js +78 -0
  151. package/dist/plugins/frontmatter.js.map +1 -0
  152. package/dist/plugins/hooks.d.ts +12 -0
  153. package/dist/plugins/hooks.js +148 -0
  154. package/dist/plugins/hooks.js.map +1 -0
  155. package/dist/plugins/loader.d.ts +7 -0
  156. package/dist/plugins/loader.js +255 -0
  157. package/dist/plugins/loader.js.map +1 -0
  158. package/dist/plugins/market.d.ts +23 -0
  159. package/dist/plugins/market.js +281 -0
  160. package/dist/plugins/market.js.map +1 -0
  161. package/dist/plugins/types.d.ts +90 -0
  162. package/dist/plugins/types.js +20 -0
  163. package/dist/plugins/types.js.map +1 -0
  164. package/dist/providers/anthropic-oauth-draft.d.ts +119 -0
  165. package/dist/providers/anthropic-oauth-draft.js +414 -0
  166. package/dist/providers/anthropic-oauth-draft.js.map +1 -0
  167. package/dist/providers/anthropic.d.ts +4 -1
  168. package/dist/providers/anthropic.js +34 -6
  169. package/dist/providers/anthropic.js.map +1 -1
  170. package/dist/providers/factory.d.ts +71 -14
  171. package/dist/providers/factory.js +205 -124
  172. package/dist/providers/factory.js.map +1 -1
  173. package/dist/providers/google.js +8 -21
  174. package/dist/providers/google.js.map +1 -1
  175. package/dist/providers/live-models.d.ts +23 -0
  176. package/dist/providers/live-models.js +145 -0
  177. package/dist/providers/live-models.js.map +1 -0
  178. package/dist/providers/openai-compatible.d.ts +1 -12
  179. package/dist/providers/openai-compatible.js +71 -108
  180. package/dist/providers/openai-compatible.js.map +1 -1
  181. package/dist/providers/resilient-factory.js +1 -1
  182. package/dist/providers/resilient-factory.js.map +1 -1
  183. package/dist/rem/graph.d.ts +72 -0
  184. package/dist/rem/graph.js +139 -0
  185. package/dist/rem/graph.js.map +1 -0
  186. package/dist/rem/index.d.ts +16 -0
  187. package/dist/rem/index.js +60 -0
  188. package/dist/rem/index.js.map +1 -0
  189. package/dist/rem/render-html.d.ts +2 -0
  190. package/dist/rem/render-html.js +189 -0
  191. package/dist/rem/render-html.js.map +1 -0
  192. package/dist/rem/render-terminal.d.ts +4 -0
  193. package/dist/rem/render-terminal.js +94 -0
  194. package/dist/rem/render-terminal.js.map +1 -0
  195. package/dist/repl/queue.d.ts +22 -0
  196. package/dist/repl/queue.js +165 -0
  197. package/dist/repl/queue.js.map +1 -0
  198. package/dist/repl/side-channel.d.ts +23 -0
  199. package/dist/repl/side-channel.js +63 -0
  200. package/dist/repl/side-channel.js.map +1 -0
  201. package/dist/research/council.d.ts +5 -2
  202. package/dist/research/council.js +73 -10
  203. package/dist/research/council.js.map +1 -1
  204. package/dist/ruby/alternator.d.ts +11 -30
  205. package/dist/ruby/alternator.js +59 -38
  206. package/dist/ruby/alternator.js.map +1 -1
  207. package/dist/ruby/episode-capture.d.ts +0 -10
  208. package/dist/ruby/episode-capture.js +0 -33
  209. package/dist/ruby/episode-capture.js.map +1 -1
  210. package/dist/ruby/types.js +1 -1
  211. package/dist/ruby/types.js.map +1 -1
  212. package/dist/safety/path-jail.d.ts +17 -0
  213. package/dist/safety/path-jail.js +100 -0
  214. package/dist/safety/path-jail.js.map +1 -0
  215. package/dist/safety/permissions.d.ts +12 -21
  216. package/dist/safety/permissions.js +81 -216
  217. package/dist/safety/permissions.js.map +1 -1
  218. package/dist/safety/ssrf.d.ts +29 -0
  219. package/dist/safety/ssrf.js +185 -0
  220. package/dist/safety/ssrf.js.map +1 -0
  221. package/dist/server/index.js +64 -10
  222. package/dist/server/index.js.map +1 -1
  223. package/dist/setup/first-run.d.ts +0 -24
  224. package/dist/setup/first-run.js +10 -344
  225. package/dist/setup/first-run.js.map +1 -1
  226. package/dist/setup/key-store.d.ts +12 -0
  227. package/dist/setup/key-store.js +108 -0
  228. package/dist/setup/key-store.js.map +1 -0
  229. package/dist/setup/provider-registry.js +31 -18
  230. package/dist/setup/provider-registry.js.map +1 -1
  231. package/dist/setup/provider-test.d.ts +7 -0
  232. package/dist/setup/provider-test.js +73 -10
  233. package/dist/setup/provider-test.js.map +1 -1
  234. package/dist/setup/provider-wizard.d.ts +4 -1
  235. package/dist/setup/provider-wizard.js +92 -26
  236. package/dist/setup/provider-wizard.js.map +1 -1
  237. package/dist/setup/xiaomi.d.ts +1 -1
  238. package/dist/setup/xiaomi.js +3 -3
  239. package/dist/setup/xiaomi.js.map +1 -1
  240. package/dist/tools/browser.js +6 -4
  241. package/dist/tools/browser.js.map +1 -1
  242. package/dist/tools/clipboard.js +7 -1
  243. package/dist/tools/clipboard.js.map +1 -1
  244. package/dist/tools/dictate.d.ts +60 -0
  245. package/dist/tools/dictate.js +983 -0
  246. package/dist/tools/dictate.js.map +1 -0
  247. package/dist/tools/dictate_patched.js +1057 -0
  248. package/dist/tools/edit-file.js +10 -2
  249. package/dist/tools/edit-file.js.map +1 -1
  250. package/dist/tools/gmail-tool.d.ts +5 -1
  251. package/dist/tools/gmail-tool.js +151 -11
  252. package/dist/tools/gmail-tool.js.map +1 -1
  253. package/dist/tools/http-request.js +14 -4
  254. package/dist/tools/http-request.js.map +1 -1
  255. package/dist/tools/image-read.js +34 -2
  256. package/dist/tools/image-read.js.map +1 -1
  257. package/dist/tools/index.d.ts +16 -1
  258. package/dist/tools/index.js +59 -8
  259. package/dist/tools/index.js.map +1 -1
  260. package/dist/tools/mcp.js +12 -0
  261. package/dist/tools/mcp.js.map +1 -1
  262. package/dist/tools/read-file.js +10 -14
  263. package/dist/tools/read-file.js.map +1 -1
  264. package/dist/tools/telegram-audio-policy.d.ts +30 -0
  265. package/dist/tools/telegram-audio-policy.js +49 -0
  266. package/dist/tools/telegram-audio-policy.js.map +1 -0
  267. package/dist/tools/telegram-bot.js +1136 -539
  268. package/dist/tools/telegram-bot.js.map +1 -1
  269. package/dist/tools/telegram-voice.d.ts +18 -5
  270. package/dist/tools/telegram-voice.js +54 -12
  271. package/dist/tools/telegram-voice.js.map +1 -1
  272. package/dist/tools/telegram.d.ts +3 -3
  273. package/dist/tools/telegram.js +5 -84
  274. package/dist/tools/telegram.js.map +1 -1
  275. package/dist/tools/tools.d.ts +2 -14
  276. package/dist/tools/tools.js +79 -144
  277. package/dist/tools/tools.js.map +1 -1
  278. package/dist/tools/web-fetch.js +39 -7
  279. package/dist/tools/web-fetch.js.map +1 -1
  280. package/dist/tools/web-search.js +2 -3
  281. package/dist/tools/web-search.js.map +1 -1
  282. package/dist/util/errors.js +1 -15
  283. package/dist/util/errors.js.map +1 -1
  284. package/dist/util/json-repair.d.ts +11 -0
  285. package/dist/util/json-repair.js +31 -0
  286. package/dist/util/json-repair.js.map +1 -0
  287. package/dist/util/rate-limiter.js +2 -8
  288. package/dist/util/rate-limiter.js.map +1 -1
  289. package/dist/viz/index.js +793 -792
  290. package/dist/viz/index.js.map +1 -1
  291. package/dist/viz/reader.d.ts +33 -0
  292. package/dist/viz/reader.js +343 -0
  293. package/dist/viz/reader.js.map +1 -0
  294. package/package.json +13 -32
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.GLOBAL_LESSONS_FILE = exports.IDENTITY_FILE = void 0;
37
+ exports.loadUnifiedMemory = loadUnifiedMemory;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const os = __importStar(require("os"));
41
+ // ─────────────────────────────────────────────────────────────────────────────
42
+ // Unified Memory — one read path shared by the CLI and the Telegram bot.
43
+ //
44
+ // Aura's memory used to live in three disconnected places (see the plan/design):
45
+ // 1. key-value identity ~/.aura/memory/*.json (bot read default+user only)
46
+ // 2. episode→dream ~/.aura/episodes + dreams/ (CLI read per-project)
47
+ // 3. chat history ~/.aura/sessions
48
+ // Facts saved by one surface never reached the other. This module gives both
49
+ // surfaces ONE canonical view:
50
+ // • GLOBAL identity/facts → ~/.aura/memory/identity.json (everywhere)
51
+ // • lessons → per-project reconciled dream (CLI) OR the
52
+ // global digest ~/.aura/memory/lessons-global.md
53
+ // (the bot, which is not tied to one project)
54
+ //
55
+ // It is read-only and defensive: any missing/corrupt file is skipped, and the
56
+ // whole block is length-capped so it never bloats a prompt.
57
+ // ─────────────────────────────────────────────────────────────────────────────
58
+ const MEMORY_DIR = path.join(os.homedir(), '.aura', 'memory');
59
+ /** Canonical global identity store (created by the consolidation migration). */
60
+ exports.IDENTITY_FILE = path.join(MEMORY_DIR, 'identity.json');
61
+ /** Global episodic-lessons digest (created by runGlobalReconciliation). */
62
+ exports.GLOBAL_LESSONS_FILE = path.join(MEMORY_DIR, 'lessons-global.md');
63
+ function loadJson(file) {
64
+ try {
65
+ if (!fs.existsSync(file))
66
+ return {};
67
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
68
+ }
69
+ catch {
70
+ return {};
71
+ }
72
+ }
73
+ function readText(file) {
74
+ try {
75
+ return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
76
+ }
77
+ catch {
78
+ return '';
79
+ }
80
+ }
81
+ /**
82
+ * Identity/facts block from the canonical global store. Falls back to the
83
+ * legacy default.json + user.json if identity.json hasn't been created yet
84
+ * (so the surfaces keep working before/after the consolidation migration).
85
+ */
86
+ function identitySection(maxChars) {
87
+ let store = loadJson(exports.IDENTITY_FILE);
88
+ if (Object.keys(store).length === 0) {
89
+ // Pre-migration fallback: merge the two namespaces the bot used to read.
90
+ store = { ...loadJson(path.join(MEMORY_DIR, 'default.json')), ...loadJson(path.join(MEMORY_DIR, 'user.json')) };
91
+ }
92
+ const keys = Object.keys(store);
93
+ if (keys.length === 0)
94
+ return '';
95
+ // Most-recently-updated entries first: identity.json only grows, and a
96
+ // budget-capped walk in raw insertion order silently drops whatever was
97
+ // added most recently once older entries fill the budget — which is
98
+ // exactly backwards, since a newly-added entry is usually a standing rule
99
+ // or current fact, while old entries are stable background bio. A missing
100
+ // `updated` sorts last (oldest-equivalent), not first.
101
+ const ordered = [...keys].sort((a, b) => {
102
+ const ta = Date.parse(store[a]?.updated ?? '') || 0;
103
+ const tb = Date.parse(store[b]?.updated ?? '') || 0;
104
+ return tb - ta;
105
+ });
106
+ const lines = [];
107
+ let used = 0;
108
+ for (const k of ordered) {
109
+ const v = store[k]?.value ?? '';
110
+ if (!v)
111
+ continue;
112
+ const line = `- **${k}**: ${v}`;
113
+ if (used + line.length > maxChars)
114
+ continue; // skip, don't stop — a later (older) entry may still fit
115
+ lines.push(line);
116
+ used += line.length;
117
+ }
118
+ return lines.length ? `### Who & what Aura knows (identity/facts)\n${lines.join('\n')}` : '';
119
+ }
120
+ /**
121
+ * Lessons block. CLI passes a projectRoot → per-project reconciled dream.
122
+ * The bot passes nothing → the global lessons digest.
123
+ */
124
+ function lessonsSection(projectRoot, maxChars) {
125
+ let content = '';
126
+ if (projectRoot) {
127
+ const reconciled = path.join(projectRoot, 'dreams', '.reconciled.md');
128
+ content = readText(reconciled);
129
+ // Fall back to the latest dated dream if reconciliation hasn't run.
130
+ if (!content) {
131
+ try {
132
+ const dir = path.join(projectRoot, 'dreams');
133
+ const files = fs.readdirSync(dir).filter(f => /^\d{4}-\d{2}-\d{2}\.md$/.test(f)).sort();
134
+ if (files.length)
135
+ content = readText(path.join(dir, files[files.length - 1]));
136
+ }
137
+ catch { /* no dreams yet */ }
138
+ }
139
+ }
140
+ else {
141
+ content = readText(exports.GLOBAL_LESSONS_FILE);
142
+ }
143
+ content = content.trim();
144
+ if (!content)
145
+ return '';
146
+ if (content.length > maxChars)
147
+ content = content.slice(0, maxChars) + '\n… (truncated)';
148
+ return `### Lessons from past sessions\n${content}`;
149
+ }
150
+ /**
151
+ * The single memory block both the CLI and the Telegram bot inject into their
152
+ * system prompts. Returns '' when there's nothing to add.
153
+ */
154
+ function loadUnifiedMemory(opts = {}) {
155
+ const budget = opts.maxChars ?? 4000;
156
+ // Split the budget: identity gets the larger share, lessons the rest.
157
+ const idBlock = identitySection(Math.floor(budget * 0.6));
158
+ const lessonBlock = lessonsSection(opts.projectRoot, budget - idBlock.length);
159
+ const parts = [idBlock, lessonBlock].filter(Boolean);
160
+ if (parts.length === 0)
161
+ return '';
162
+ return `\n\n## Memory (shared across Aura CLI + Telegram)\n${parts.join('\n\n')}\n`;
163
+ }
164
+ //# sourceMappingURL=unified-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified-memory.js","sourceRoot":"","sources":["../../src/agent/unified-memory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HA,8CASC;AArID,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB,gFAAgF;AAChF,yEAAyE;AACzE,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,8CAA8C;AAC9C,6EAA6E;AAC7E,+BAA+B;AAC/B,4EAA4E;AAC5E,0EAA0E;AAC1E,+EAA+E;AAC/E,4EAA4E;AAC5E,EAAE;AACF,8EAA8E;AAC9E,4DAA4D;AAC5D,gFAAgF;AAEhF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAE9D,gFAAgF;AACnE,QAAA,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AACpE,2EAA2E;AAC9D,QAAA,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;AAI9E,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,C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AC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AACtF,CAAC"}
@@ -0,0 +1,44 @@
1
+ export interface Checkpoint {
2
+ /** Short id, e.g. "m1x2y3-4f" — used in refs and CLI commands. */
3
+ id: string;
4
+ /** Full ref name: refs/aura/checkpoints/<id> */
5
+ ref: string;
6
+ /** Commit hash of the shadow commit. */
7
+ commit: string;
8
+ /** Tree hash of the snapshot. */
9
+ tree: string;
10
+ /** Human label (usually the task that triggered the snapshot). */
11
+ label: string;
12
+ /** ISO timestamp of creation. */
13
+ createdAt: string;
14
+ }
15
+ export interface RestoreResult {
16
+ /** Files written back from the snapshot. */
17
+ restored: string[];
18
+ /** Files deleted because they did not exist at snapshot time. */
19
+ deleted: string[];
20
+ /** Checkpoint of the state just before restoring (undo the undo). */
21
+ preRestore: Checkpoint | null;
22
+ }
23
+ /** Absolute .git dir of the repo containing root, or null if not a repo. */
24
+ export declare function gitDirOf(root: string): Promise<string | null>;
25
+ /**
26
+ * Create a checkpoint of the current working tree.
27
+ * Returns null when: not a git repo, or the tree is identical to the most
28
+ * recent checkpoint (deduped — repeated calls within a burst are no-ops).
29
+ */
30
+ export declare function createCheckpoint(root: string, label: string): Promise<Checkpoint | null>;
31
+ /** All checkpoints for the repo containing root, newest first. */
32
+ export declare function listCheckpoints(root: string): Promise<Checkpoint[]>;
33
+ /**
34
+ * Restore the working tree to the state captured by checkpoint `id`
35
+ * (or the most recent checkpoint when id is omitted).
36
+ *
37
+ * Only paths that differ are touched; the user's index/HEAD stay put, so
38
+ * after a restore `git status` simply reflects the restored content.
39
+ */
40
+ export declare function restoreCheckpoint(root: string, id?: string): Promise<RestoreResult>;
41
+ /** Delete all but the newest `keep` checkpoints. Returns how many were pruned. */
42
+ export declare function pruneCheckpoints(root: string, keep: number): Promise<number>;
43
+ /** Delete a single checkpoint by id. */
44
+ export declare function deleteCheckpoint(root: string, id: string): Promise<boolean>;
@@ -0,0 +1,324 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.gitDirOf = gitDirOf;
37
+ exports.createCheckpoint = createCheckpoint;
38
+ exports.listCheckpoints = listCheckpoints;
39
+ exports.restoreCheckpoint = restoreCheckpoint;
40
+ exports.pruneCheckpoints = pruneCheckpoints;
41
+ exports.deleteCheckpoint = deleteCheckpoint;
42
+ /**
43
+ * Checkpoints — shadow-git snapshots of the working tree, so every agent
44
+ * write is cheaply reversible with `aura --undo` (or `:undo` in the REPL).
45
+ *
46
+ * How it works: before the first mutating tool call of each turn, the loop
47
+ * snapshots the ENTIRE working tree (tracked + untracked, .gitignore
48
+ * respected) into the repo's object store via a TEMPORARY index, then points
49
+ * a ref at it under `refs/aura/checkpoints/<id>`. The user's real index,
50
+ * HEAD, branches, and reflog are never touched — checkpoints are invisible
51
+ * to normal git workflows and are garbage-collectable once pruned.
52
+ *
53
+ * Restore diffs the snapshot tree against a fresh snapshot of "now", writes
54
+ * changed/added files back and deletes files that didn't exist at snapshot
55
+ * time. A pre-restore checkpoint is always taken first, so restore itself
56
+ * is undoable.
57
+ *
58
+ * Requires the project to be a git repository; in a non-repo all operations
59
+ * are silent no-ops (create returns null).
60
+ */
61
+ const child_process_1 = require("child_process");
62
+ const fs = __importStar(require("fs"));
63
+ const path = __importStar(require("path"));
64
+ const REF_PREFIX = 'refs/aura/checkpoints/';
65
+ /** Shadow commits need an ident but must never depend on user git config. */
66
+ const SHADOW_IDENT = {
67
+ GIT_AUTHOR_NAME: 'aura-checkpoint',
68
+ GIT_AUTHOR_EMAIL: 'checkpoint@aura.local',
69
+ GIT_COMMITTER_NAME: 'aura-checkpoint',
70
+ GIT_COMMITTER_EMAIL: 'checkpoint@aura.local',
71
+ };
72
+ function git(root, args, extraEnv, stdin) {
73
+ return new Promise((resolve, reject) => {
74
+ const child = (0, child_process_1.execFile)('git', args, { cwd: root, env: { ...process.env, ...SHADOW_IDENT, ...extraEnv }, maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
75
+ if (err)
76
+ reject(new Error(`git ${args[0]}: ${stderr || err.message}`));
77
+ else
78
+ resolve(stdout);
79
+ });
80
+ if (stdin !== undefined)
81
+ child.stdin?.end(stdin);
82
+ else
83
+ child.stdin?.end();
84
+ });
85
+ }
86
+ /** Absolute .git dir of the repo containing root, or null if not a repo. */
87
+ async function gitDirOf(root) {
88
+ try {
89
+ return (await git(root, ['rev-parse', '--absolute-git-dir'])).trim();
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ }
95
+ // Monotonic within the process so ids created in the same millisecond still
96
+ // sort in creation order (listCheckpoints sorts by refname).
97
+ let lastIdTs = 0;
98
+ function newId() {
99
+ lastIdTs = Math.max(Date.now(), lastIdTs + 1);
100
+ return `${lastIdTs.toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
101
+ }
102
+ /**
103
+ * Common secret patterns that should never be captured in checkpoints.
104
+ * These patterns match files that contain API keys, tokens, or other secrets.
105
+ */
106
+ const SECRET_PATTERNS = [
107
+ // Environment variable style: TOKEN=, API_KEY=, etc.
108
+ /^(?:TOKEN|API_KEY|SECRET|PASSWORD|AUTH|KEY|BEARER)\s*=/i,
109
+ // JSON style: "api_key": "sk_...", "token": "ghp_..."
110
+ /["'](?:api_key|token|secret|password|auth_key|bearer|access_token)["']?\s*:\s*["']?(?:sk_|pk_|ghp_|gho_|ghu_|glpat-|ey|Bearer)/i,
111
+ // Common API key patterns (more lenient)
112
+ /(?:sk_|pk_|ghp_|gho_|ghu_|glpat-)[a-zA-Z0-9_]{10,}/i,
113
+ // Bearer tokens
114
+ /Bearer\s+[a-zA-Z0-9_\-\.]{10,}/i,
115
+ // Private keys
116
+ /-----BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY-----/,
117
+ // Generic long base64-like strings (likely tokens)
118
+ /[a-zA-Z0-9_\-\.]{32,}/,
119
+ ];
120
+ /**
121
+ * Check if a file contains potential secrets by scanning its content.
122
+ * Returns true if any secret pattern is matched.
123
+ */
124
+ function fileContainsSecrets(content) {
125
+ for (const pattern of SECRET_PATTERNS) {
126
+ if (pattern.test(content))
127
+ return true;
128
+ }
129
+ return false;
130
+ }
131
+ /**
132
+ * Get list of files in the temporary index that should be excluded from checkpoints
133
+ * due to containing secrets.
134
+ */
135
+ async function getSecretFilesFromIndex(root, env) {
136
+ const secretFiles = [];
137
+ try {
138
+ // Get all files in the temporary index (tracked + staged untracked files)
139
+ const out = await git(root, ['ls-files', '-z'], env);
140
+ const files = out.split('\0').filter(Boolean);
141
+ for (const file of files) {
142
+ const absPath = path.join(root, file);
143
+ try {
144
+ // Only check text-based files that might contain credentials
145
+ if (/\.(json|js|ts|mjs|env|config|sh|py|ya?ml|toml|ini|conf|txt|md)$/.test(file)) {
146
+ const content = fs.readFileSync(absPath, 'utf8');
147
+ if (fileContainsSecrets(content)) {
148
+ secretFiles.push(file);
149
+ }
150
+ }
151
+ }
152
+ catch (e) { /* skip files we can't read */ }
153
+ }
154
+ }
155
+ catch (e) { /* if git ls-files fails, return empty array */ }
156
+ return secretFiles;
157
+ }
158
+ /**
159
+ * Snapshot the working tree into the object store through a temporary index.
160
+ * Returns the tree hash. Never touches the user's real index.
161
+ *
162
+ * SECURITY: Excludes files containing secrets to prevent credential leakage
163
+ * into checkpoint refs. This is a critical safety measure since checkpoint refs
164
+ * live outside normal branches and won't be caught by standard secret scanning.
165
+ */
166
+ async function writeShadowTree(root, gitDir) {
167
+ const tmpIndex = path.join(gitDir, `aura-checkpoint-index-${process.pid}`);
168
+ const env = { GIT_INDEX_FILE: tmpIndex };
169
+ try {
170
+ // Seed from HEAD when it exists so `add -A` computes a minimal update.
171
+ try {
172
+ await git(root, ['read-tree', 'HEAD'], env);
173
+ }
174
+ catch {
175
+ await git(root, ['read-tree', '--empty'], env);
176
+ }
177
+ // Add all files, respecting .gitignore (git add -A behavior)
178
+ await git(root, ['add', '-A', '--', '.'], env);
179
+ // CRITICAL: Remove any files that contain secrets (check AFTER adding to index)
180
+ const secretFiles = await getSecretFilesFromIndex(root, env);
181
+ if (secretFiles.length > 0) {
182
+ // Remove files with secrets from the index
183
+ await git(root, ['rm', '--cached', '--', ...secretFiles], env);
184
+ console.warn(`[checkpoint] Excluded ${secretFiles.length} file(s) containing secrets from checkpoint`);
185
+ }
186
+ return (await git(root, ['write-tree'], env)).trim();
187
+ }
188
+ finally {
189
+ try {
190
+ fs.unlinkSync(tmpIndex);
191
+ }
192
+ catch { /* already gone */ }
193
+ }
194
+ }
195
+ /**
196
+ * Create a checkpoint of the current working tree.
197
+ * Returns null when: not a git repo, or the tree is identical to the most
198
+ * recent checkpoint (deduped — repeated calls within a burst are no-ops).
199
+ */
200
+ async function createCheckpoint(root, label) {
201
+ const gitDir = await gitDirOf(root);
202
+ if (!gitDir)
203
+ return null;
204
+ const tree = await writeShadowTree(root, gitDir);
205
+ const existing = await listCheckpoints(root);
206
+ if (existing[0]?.tree === tree)
207
+ return null;
208
+ let head = null;
209
+ try {
210
+ head = (await git(root, ['rev-parse', '--verify', 'HEAD'])).trim();
211
+ }
212
+ catch { /* unborn branch — parentless shadow commit */ }
213
+ const cleanLabel = label.replace(/\s+/g, ' ').trim().slice(0, 120) || 'checkpoint';
214
+ const commitArgs = ['commit-tree', tree, '-m', cleanLabel];
215
+ if (head)
216
+ commitArgs.push('-p', head);
217
+ const commit = (await git(root, commitArgs)).trim();
218
+ const id = newId();
219
+ const ref = REF_PREFIX + id;
220
+ await git(root, ['update-ref', ref, commit]);
221
+ return { id, ref, commit, tree, label: cleanLabel, createdAt: new Date().toISOString() };
222
+ }
223
+ /** All checkpoints for the repo containing root, newest first. */
224
+ async function listCheckpoints(root) {
225
+ const gitDir = await gitDirOf(root);
226
+ if (!gitDir)
227
+ return [];
228
+ // Sort by refname, not creatordate: commit dates have 1-second resolution,
229
+ // while ids embed a base36 ms timestamp that sorts correctly lexically.
230
+ const out = await git(root, [
231
+ 'for-each-ref', '--sort=-refname',
232
+ '--format=%(refname)%09%(objectname)%09%(tree)%09%(creatordate:iso-strict)%09%(subject)',
233
+ REF_PREFIX,
234
+ ]);
235
+ return out.split('\n').filter(Boolean).map(line => {
236
+ const [ref, commit, tree, createdAt, ...subject] = line.split('\t');
237
+ return {
238
+ id: ref.slice(REF_PREFIX.length),
239
+ ref, commit, tree, createdAt,
240
+ label: subject.join('\t'),
241
+ };
242
+ });
243
+ }
244
+ /**
245
+ * Restore the working tree to the state captured by checkpoint `id`
246
+ * (or the most recent checkpoint when id is omitted).
247
+ *
248
+ * Only paths that differ are touched; the user's index/HEAD stay put, so
249
+ * after a restore `git status` simply reflects the restored content.
250
+ */
251
+ async function restoreCheckpoint(root, id) {
252
+ const gitDir = await gitDirOf(root);
253
+ if (!gitDir)
254
+ throw new Error('Not a git repository — checkpoints unavailable.');
255
+ const all = await listCheckpoints(root);
256
+ if (all.length === 0)
257
+ throw new Error('No checkpoints exist for this repository.');
258
+ const target = id ? all.find(c => c.id === id) : all[0];
259
+ if (!target)
260
+ throw new Error(`Checkpoint not found: ${id}`);
261
+ // Snapshot "now" first — makes the restore itself undoable, and gives us
262
+ // the tree to diff against. createCheckpoint dedupes, so when the tree
263
+ // hasn't changed since the latest checkpoint we reuse that one's tree.
264
+ const preRestore = await createCheckpoint(root, `pre-restore (before restoring ${target.id})`);
265
+ const nowTree = preRestore?.tree ?? (await listCheckpoints(root))[0].tree;
266
+ if (nowTree === target.tree)
267
+ return { restored: [], deleted: [], preRestore };
268
+ // -z output: STATUS NUL path NUL … — statuses relative nowTree → target:
269
+ // A = exists only in the snapshot (write it back)
270
+ // D = exists only now (delete it)
271
+ // M/T = content/type differs (write it back)
272
+ const raw = await git(root, ['diff-tree', '-r', '-z', '--name-status', nowTree, target.tree]);
273
+ const parts = raw.split('\0').filter(p => p.length > 0);
274
+ const toWrite = [];
275
+ const toDelete = [];
276
+ for (let i = 0; i + 1 < parts.length; i += 2) {
277
+ const status = parts[i];
278
+ const file = parts[i + 1];
279
+ if (status === 'D')
280
+ toDelete.push(file);
281
+ else
282
+ toWrite.push(file);
283
+ }
284
+ for (const file of toDelete) {
285
+ try {
286
+ fs.rmSync(path.join(root, file), { force: true });
287
+ }
288
+ catch { /* best-effort */ }
289
+ }
290
+ if (toWrite.length > 0) {
291
+ const tmpIndex = path.join(gitDir, `aura-restore-index-${process.pid}`);
292
+ const env = { GIT_INDEX_FILE: tmpIndex };
293
+ try {
294
+ await git(root, ['read-tree', target.tree], env);
295
+ await git(root, ['checkout-index', '-f', '-z', '--stdin'], env, toWrite.join('\0') + '\0');
296
+ }
297
+ finally {
298
+ try {
299
+ fs.unlinkSync(tmpIndex);
300
+ }
301
+ catch { /* already gone */ }
302
+ }
303
+ }
304
+ return { restored: toWrite, deleted: toDelete, preRestore };
305
+ }
306
+ /** Delete all but the newest `keep` checkpoints. Returns how many were pruned. */
307
+ async function pruneCheckpoints(root, keep) {
308
+ const all = await listCheckpoints(root);
309
+ const stale = all.slice(Math.max(0, keep));
310
+ for (const cp of stale) {
311
+ await git(root, ['update-ref', '-d', cp.ref]);
312
+ }
313
+ return stale.length;
314
+ }
315
+ /** Delete a single checkpoint by id. */
316
+ async function deleteCheckpoint(root, id) {
317
+ const all = await listCheckpoints(root);
318
+ const cp = all.find(c => c.id === id);
319
+ if (!cp)
320
+ return false;
321
+ await git(root, ['update-ref', '-d', cp.ref]);
322
+ return true;
323
+ }
324
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/checkpoints/engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,4BAMC;AAyGD,4CAuBC;AAGD,0CAkBC;AASD,8CAgDC;AAGD,4CAOC;AAGD,4CAMC;AAhTD;;;;;;;;;;;;;;;;;;GAkBG;AACH,iDAAyC;AACzC,uCAAyB;AACzB,2CAA6B;AA0B7B,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,YAAY,GAAG;IACnB,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,uBAAuB;IACzC,kBAAkB,EAAE,iBAAiB;IACrC,mBAAmB,EAAE,uBAAuB;CAC7C,CAAC;AAEF,SAAS,GAAG,CAAC,IAAY,EAAE,IAAc,EAAE,QAAiC,EAAE,KAAc;IAC1F,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,IAAA,wBAAQ,EACpB,KAAK,EAAE,IAAI,EACX,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE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+ /**
8
+ * All commands available in the palette. Derived from help-data.ts
9
+ * but kept as a static list here to avoid circular imports.
10
+ */
11
+ export declare const PALETTE_COMMANDS: PaletteCommand[];
12
+ /**
13
+ * Fuzzy-match a query against a command's label + id.
14
+ * Returns a score (lower = better match), or -1 for no match.
15
+ */
16
+ export declare function fuzzyMatch(query: string, text: string): number;
17
+ /**
18
+ * Filter and sort commands by fuzzy match score.
19
+ */
20
+ export declare function filterCommands(query: string): PaletteCommand[];
21
+ /**
22
+ * Render the palette overlay. Returns styled lines to draw.
23
+ * `selectedIdx` is the currently highlighted item.
24
+ * `maxVisible` controls how many items fit in the overlay.
25
+ */
26
+ export declare function renderPalette(commands: PaletteCommand[], query: string, selectedIdx: number, maxVisible: number, width: number): string[];