aura-code 0.6.3 → 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 (265) 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/context.d.ts +0 -4
  12. package/dist/agent/context.js +0 -38
  13. package/dist/agent/context.js.map +1 -1
  14. package/dist/agent/domain-expertise.d.ts +22 -0
  15. package/dist/agent/domain-expertise.js +110 -0
  16. package/dist/agent/domain-expertise.js.map +1 -0
  17. package/dist/agent/executive-queue.d.ts +26 -0
  18. package/dist/agent/executive-queue.js +50 -0
  19. package/dist/agent/executive-queue.js.map +1 -0
  20. package/dist/agent/generational-flush.d.ts +28 -0
  21. package/dist/agent/generational-flush.js +48 -0
  22. package/dist/agent/generational-flush.js.map +1 -0
  23. package/dist/agent/loop-profile.d.ts +50 -0
  24. package/dist/agent/loop-profile.js +88 -0
  25. package/dist/agent/loop-profile.js.map +1 -0
  26. package/dist/agent/loop.d.ts +14 -5
  27. package/dist/agent/loop.js +167 -39
  28. package/dist/agent/loop.js.map +1 -1
  29. package/dist/agent/memory-consolidate.d.ts +14 -0
  30. package/dist/agent/memory-consolidate.js +141 -0
  31. package/dist/agent/memory-consolidate.js.map +1 -0
  32. package/dist/agent/mixture.d.ts +33 -0
  33. package/dist/agent/mixture.js +138 -0
  34. package/dist/agent/mixture.js.map +1 -0
  35. package/dist/agent/spawner.js +2 -2
  36. package/dist/agent/spawner.js.map +1 -1
  37. package/dist/agent/system-prompt.d.ts +1 -1
  38. package/dist/agent/system-prompt.js +50 -22
  39. package/dist/agent/system-prompt.js.map +1 -1
  40. package/dist/agent/unified-memory.d.ts +15 -0
  41. package/dist/agent/unified-memory.js +164 -0
  42. package/dist/agent/unified-memory.js.map +1 -0
  43. package/dist/checkpoints/engine.d.ts +44 -0
  44. package/dist/checkpoints/engine.js +324 -0
  45. package/dist/checkpoints/engine.js.map +1 -0
  46. package/dist/cli/command-palette.d.ts +26 -0
  47. package/dist/cli/command-palette.js +133 -0
  48. package/dist/cli/command-palette.js.map +1 -0
  49. package/dist/cli/context-health.d.ts +51 -0
  50. package/dist/cli/context-health.js +187 -0
  51. package/dist/cli/context-health.js.map +1 -0
  52. package/dist/cli/diamond.d.ts +67 -0
  53. package/dist/cli/diamond.js +222 -12
  54. package/dist/cli/diamond.js.map +1 -1
  55. package/dist/cli/dic.d.ts +2 -0
  56. package/dist/cli/dic.js +106 -0
  57. package/dist/cli/dic.js.map +1 -0
  58. package/dist/cli/diff-view.d.ts +18 -0
  59. package/dist/cli/diff-view.js +114 -0
  60. package/dist/cli/diff-view.js.map +1 -0
  61. package/dist/cli/display.d.ts +18 -4
  62. package/dist/cli/display.js +74 -151
  63. package/dist/cli/display.js.map +1 -1
  64. package/dist/cli/help-data.d.ts +7 -0
  65. package/dist/cli/help-data.js +80 -0
  66. package/dist/cli/help-data.js.map +1 -0
  67. package/dist/cli/index.js +1002 -852
  68. package/dist/cli/index.js.map +1 -1
  69. package/dist/cli/markdown.d.ts +5 -0
  70. package/dist/cli/markdown.js +128 -0
  71. package/dist/cli/markdown.js.map +1 -0
  72. package/dist/cli/model-select.d.ts +39 -0
  73. package/dist/cli/model-select.js +65 -0
  74. package/dist/cli/model-select.js.map +1 -0
  75. package/dist/cli/tui.d.ts +34 -0
  76. package/dist/cli/tui.js +1176 -0
  77. package/dist/cli/tui.js.map +1 -0
  78. package/dist/config/defaults.d.ts +6 -17
  79. package/dist/config/defaults.js +25 -46
  80. package/dist/config/defaults.js.map +1 -1
  81. package/dist/config/project-config.d.ts +2 -6
  82. package/dist/config/project-config.js +2 -2
  83. package/dist/config/project-config.js.map +1 -1
  84. package/dist/doctor/checks.d.ts +18 -0
  85. package/dist/doctor/checks.js +524 -0
  86. package/dist/doctor/checks.js.map +1 -0
  87. package/dist/doctor/index.d.ts +4 -0
  88. package/dist/doctor/index.js +229 -0
  89. package/dist/doctor/index.js.map +1 -0
  90. package/dist/doctor/repair.d.ts +19 -0
  91. package/dist/doctor/repair.js +126 -0
  92. package/dist/doctor/repair.js.map +1 -0
  93. package/dist/doctor/types.d.ts +38 -0
  94. package/dist/doctor/types.js +10 -0
  95. package/dist/doctor/types.js.map +1 -0
  96. package/dist/dream/dream.d.ts +79 -59
  97. package/dist/dream/dream.js +324 -144
  98. package/dist/dream/dream.js.map +1 -1
  99. package/dist/dream/episode.d.ts +17 -0
  100. package/dist/dream/episode.js +116 -0
  101. package/dist/dream/episode.js.map +1 -0
  102. package/dist/kanban/engine.d.ts +26 -0
  103. package/dist/kanban/engine.js +208 -0
  104. package/dist/kanban/engine.js.map +1 -0
  105. package/dist/kanban/types.d.ts +19 -0
  106. package/dist/kanban/types.js +9 -1
  107. package/dist/kanban/types.js.map +1 -1
  108. package/dist/machina/render-html.js +4 -2
  109. package/dist/machina/render-html.js.map +1 -1
  110. package/dist/machina/render-terminal.js +11 -4
  111. package/dist/machina/render-terminal.js.map +1 -1
  112. package/dist/machina/repair.d.ts +23 -0
  113. package/dist/machina/repair.js +98 -0
  114. package/dist/machina/repair.js.map +1 -0
  115. package/dist/machina/spec.js +12 -12
  116. package/dist/machina/spec.js.map +1 -1
  117. package/dist/machina/verify.d.ts +13 -1
  118. package/dist/machina/verify.js +12 -2
  119. package/dist/machina/verify.js.map +1 -1
  120. package/dist/mining/extract.d.ts +34 -0
  121. package/dist/mining/extract.js +229 -0
  122. package/dist/mining/extract.js.map +1 -0
  123. package/dist/mining/refine.d.ts +28 -0
  124. package/dist/mining/refine.js +256 -0
  125. package/dist/mining/refine.js.map +1 -0
  126. package/dist/perception/extractor.js +5 -3
  127. package/dist/perception/extractor.js.map +1 -1
  128. package/dist/perception/graph-store.d.ts +0 -11
  129. package/dist/perception/graph-store.js +0 -33
  130. package/dist/perception/graph-store.js.map +1 -1
  131. package/dist/perception/index.d.ts +1 -1
  132. package/dist/perception/index.js +1 -2
  133. package/dist/perception/index.js.map +1 -1
  134. package/dist/plugins/commands.d.ts +38 -0
  135. package/dist/plugins/commands.js +134 -0
  136. package/dist/plugins/commands.js.map +1 -0
  137. package/dist/plugins/frontmatter.d.ts +14 -0
  138. package/dist/plugins/frontmatter.js +78 -0
  139. package/dist/plugins/frontmatter.js.map +1 -0
  140. package/dist/plugins/hooks.d.ts +12 -0
  141. package/dist/plugins/hooks.js +148 -0
  142. package/dist/plugins/hooks.js.map +1 -0
  143. package/dist/plugins/loader.d.ts +7 -0
  144. package/dist/plugins/loader.js +255 -0
  145. package/dist/plugins/loader.js.map +1 -0
  146. package/dist/plugins/market.d.ts +23 -0
  147. package/dist/plugins/market.js +281 -0
  148. package/dist/plugins/market.js.map +1 -0
  149. package/dist/plugins/types.d.ts +90 -0
  150. package/dist/plugins/types.js +20 -0
  151. package/dist/plugins/types.js.map +1 -0
  152. package/dist/providers/anthropic-oauth-draft.d.ts +119 -0
  153. package/dist/providers/anthropic-oauth-draft.js +414 -0
  154. package/dist/providers/anthropic-oauth-draft.js.map +1 -0
  155. package/dist/providers/anthropic.d.ts +4 -1
  156. package/dist/providers/anthropic.js +35 -7
  157. package/dist/providers/anthropic.js.map +1 -1
  158. package/dist/providers/factory.d.ts +43 -19
  159. package/dist/providers/factory.js +183 -129
  160. package/dist/providers/factory.js.map +1 -1
  161. package/dist/providers/google.js +9 -22
  162. package/dist/providers/google.js.map +1 -1
  163. package/dist/providers/live-models.d.ts +23 -0
  164. package/dist/providers/live-models.js +145 -0
  165. package/dist/providers/live-models.js.map +1 -0
  166. package/dist/providers/openai-compatible.d.ts +1 -12
  167. package/dist/providers/openai-compatible.js +71 -108
  168. package/dist/providers/openai-compatible.js.map +1 -1
  169. package/dist/providers/resilient-factory.js +1 -1
  170. package/dist/providers/resilient-factory.js.map +1 -1
  171. package/dist/repl/queue.d.ts +22 -0
  172. package/dist/repl/queue.js +165 -0
  173. package/dist/repl/queue.js.map +1 -0
  174. package/dist/repl/side-channel.d.ts +23 -0
  175. package/dist/repl/side-channel.js +63 -0
  176. package/dist/repl/side-channel.js.map +1 -0
  177. package/dist/research/council.d.ts +2 -0
  178. package/dist/research/council.js +29 -4
  179. package/dist/research/council.js.map +1 -1
  180. package/dist/ruby/alternator.d.ts +11 -30
  181. package/dist/ruby/alternator.js +59 -38
  182. package/dist/ruby/alternator.js.map +1 -1
  183. package/dist/ruby/episode-capture.d.ts +0 -10
  184. package/dist/ruby/episode-capture.js +0 -33
  185. package/dist/ruby/episode-capture.js.map +1 -1
  186. package/dist/ruby/types.js +1 -1
  187. package/dist/ruby/types.js.map +1 -1
  188. package/dist/safety/path-jail.d.ts +17 -0
  189. package/dist/safety/path-jail.js +100 -0
  190. package/dist/safety/path-jail.js.map +1 -0
  191. package/dist/safety/permissions.d.ts +12 -21
  192. package/dist/safety/permissions.js +81 -216
  193. package/dist/safety/permissions.js.map +1 -1
  194. package/dist/safety/ssrf.d.ts +29 -0
  195. package/dist/safety/ssrf.js +185 -0
  196. package/dist/safety/ssrf.js.map +1 -0
  197. package/dist/server/index.js +64 -10
  198. package/dist/server/index.js.map +1 -1
  199. package/dist/setup/first-run.d.ts +0 -24
  200. package/dist/setup/first-run.js +10 -344
  201. package/dist/setup/first-run.js.map +1 -1
  202. package/dist/setup/key-store.d.ts +12 -0
  203. package/dist/setup/key-store.js +108 -0
  204. package/dist/setup/key-store.js.map +1 -0
  205. package/dist/setup/provider-registry.js +31 -18
  206. package/dist/setup/provider-registry.js.map +1 -1
  207. package/dist/setup/provider-test.d.ts +7 -0
  208. package/dist/setup/provider-test.js +73 -10
  209. package/dist/setup/provider-test.js.map +1 -1
  210. package/dist/setup/provider-wizard.d.ts +4 -1
  211. package/dist/setup/provider-wizard.js +92 -26
  212. package/dist/setup/provider-wizard.js.map +1 -1
  213. package/dist/setup/xiaomi.d.ts +1 -1
  214. package/dist/setup/xiaomi.js +3 -3
  215. package/dist/setup/xiaomi.js.map +1 -1
  216. package/dist/tools/browser.js +14 -10
  217. package/dist/tools/browser.js.map +1 -1
  218. package/dist/tools/clipboard.js +7 -1
  219. package/dist/tools/clipboard.js.map +1 -1
  220. package/dist/tools/dictate.d.ts +60 -0
  221. package/dist/tools/dictate.js +983 -0
  222. package/dist/tools/dictate.js.map +1 -0
  223. package/dist/tools/dictate_patched.js +1057 -0
  224. package/dist/tools/edit-file.js +10 -2
  225. package/dist/tools/edit-file.js.map +1 -1
  226. package/dist/tools/http-request.js +14 -4
  227. package/dist/tools/http-request.js.map +1 -1
  228. package/dist/tools/image-read.js +34 -2
  229. package/dist/tools/image-read.js.map +1 -1
  230. package/dist/tools/index.d.ts +16 -1
  231. package/dist/tools/index.js +59 -8
  232. package/dist/tools/index.js.map +1 -1
  233. package/dist/tools/mcp.js +12 -0
  234. package/dist/tools/mcp.js.map +1 -1
  235. package/dist/tools/read-file.js +10 -14
  236. package/dist/tools/read-file.js.map +1 -1
  237. package/dist/tools/telegram-audio-policy.d.ts +30 -0
  238. package/dist/tools/telegram-audio-policy.js +49 -0
  239. package/dist/tools/telegram-audio-policy.js.map +1 -0
  240. package/dist/tools/telegram-bot.js +1136 -537
  241. package/dist/tools/telegram-bot.js.map +1 -1
  242. package/dist/tools/telegram-voice.d.ts +18 -5
  243. package/dist/tools/telegram-voice.js +54 -12
  244. package/dist/tools/telegram-voice.js.map +1 -1
  245. package/dist/tools/telegram.d.ts +3 -3
  246. package/dist/tools/telegram.js +5 -84
  247. package/dist/tools/telegram.js.map +1 -1
  248. package/dist/tools/tools.d.ts +2 -14
  249. package/dist/tools/tools.js +79 -144
  250. package/dist/tools/tools.js.map +1 -1
  251. package/dist/tools/web-fetch.js +39 -7
  252. package/dist/tools/web-fetch.js.map +1 -1
  253. package/dist/tools/web-search.d.ts +0 -20
  254. package/dist/tools/web-search.js +40 -137
  255. package/dist/tools/web-search.js.map +1 -1
  256. package/dist/util/errors.js +1 -15
  257. package/dist/util/errors.js.map +1 -1
  258. package/dist/util/json-repair.d.ts +11 -0
  259. package/dist/util/json-repair.js +31 -0
  260. package/dist/util/json-repair.js.map +1 -0
  261. package/dist/util/rate-limiter.js +2 -8
  262. package/dist/util/rate-limiter.js.map +1 -1
  263. package/dist/viz/index.js +793 -792
  264. package/dist/viz/index.js.map +1 -1
  265. package/package.json +12 -32
@@ -0,0 +1,229 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.runDoctor = runDoctor;
40
+ exports.formatDoctorReport = formatDoctorReport;
41
+ /**
42
+ * Aura Doctor — entry point. runDoctor() runs all checks, optionally
43
+ * attempts repairs, and returns a DoctorReport. formatDoctorReport()
44
+ * renders it as a colored terminal string.
45
+ *
46
+ * Usage:
47
+ * const report = await runDoctor({ projectRoot, fix: true });
48
+ * console.log(formatDoctorReport(report));
49
+ */
50
+ const fs = __importStar(require("fs"));
51
+ const path = __importStar(require("path"));
52
+ const chalk_1 = __importDefault(require("chalk"));
53
+ const checks_js_1 = require("./checks.js");
54
+ const repair_js_1 = require("./repair.js");
55
+ async function runDoctor(opts) {
56
+ const { projectRoot, fix = false, offline = false } = opts;
57
+ const pkg = readPkgVersion(projectRoot);
58
+ // Run all sync checks
59
+ let findings = [];
60
+ for (const check of checks_js_1.ALL_CHECKS) {
61
+ try {
62
+ findings = findings.concat(check.run(projectRoot, offline));
63
+ }
64
+ catch (e) {
65
+ findings.push({
66
+ category: check.category, name: `${check.category} check`,
67
+ severity: 'error', message: `Check crashed: ${String(e).slice(0, 150)}`,
68
+ fixable: false,
69
+ });
70
+ }
71
+ }
72
+ // Async latest-version check (skipped offline)
73
+ if (!offline && pkg !== 'unknown') {
74
+ const latest = await (0, checks_js_1.checkLatestVersion)(pkg);
75
+ if (latest)
76
+ findings.push(latest);
77
+ }
78
+ // Attempt repairs
79
+ const fixed = [];
80
+ const fixFailed = [];
81
+ if (fix) {
82
+ const toFix = findings.filter(f => f.fixable);
83
+ const done = new Set();
84
+ for (const f of toFix) {
85
+ // Deduplicate by repair key — e.g. "dist directory" and "dist freshness"
86
+ // both map to "rebuild dist", so only do it once.
87
+ const result = (0, repair_js_1.attemptRepair)(projectRoot, f);
88
+ if (!result)
89
+ continue;
90
+ if (done.has(result.name))
91
+ continue;
92
+ done.add(result.name);
93
+ if (result.success) {
94
+ fixed.push(f.name);
95
+ // Flip the finding to ok
96
+ f.severity = 'ok';
97
+ f.message = `${f.message} [FIXED: ${result.message}]`;
98
+ }
99
+ else {
100
+ fixFailed.push(f.name);
101
+ f.detail = (f.detail ?? '') + `\nRepair failed: ${result.message}`;
102
+ }
103
+ }
104
+ // After repairs, re-run the build check to confirm dist is now fresh
105
+ if (fixed.some(n => n.includes('dist') || n === 'entry point' || n === 'dist directory')) {
106
+ const buildCheck = checks_js_1.ALL_CHECKS.find(c => c.category === 'build');
107
+ if (buildCheck) {
108
+ const rechecked = buildCheck.run(projectRoot, offline);
109
+ // Replace build-category findings with the rechecked ones
110
+ findings = findings.filter(f => f.category !== 'build').concat(rechecked);
111
+ }
112
+ }
113
+ }
114
+ const summary = { ok: 0, warn: 0, error: 0, fixable: 0 };
115
+ for (const f of findings)
116
+ summary[f.severity]++;
117
+ const report = {
118
+ timestamp: Date.now(),
119
+ version: pkg,
120
+ projectRoot,
121
+ findings,
122
+ summary,
123
+ fixed,
124
+ fixFailed,
125
+ };
126
+ // Persist to .aura/doctor-report.json (gitignored)
127
+ try {
128
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? '~';
129
+ const auraDir = path.join(home, '.aura');
130
+ if (!fs.existsSync(auraDir))
131
+ fs.mkdirSync(auraDir, { recursive: true });
132
+ fs.writeFileSync(path.join(auraDir, 'doctor-report.json'), JSON.stringify(report, null, 2), 'utf8');
133
+ }
134
+ catch { /* best-effort */ }
135
+ return report;
136
+ }
137
+ function readPkgVersion(root) {
138
+ try {
139
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
140
+ return pkg.version ?? 'unknown';
141
+ }
142
+ catch {
143
+ return 'unknown';
144
+ }
145
+ }
146
+ // ── Formatting ───────────────────────────────────────────────────────────────
147
+ const SEVERITY_ICON = {
148
+ ok: '✓', warn: '⚠', error: '✗', fixable: '⟳',
149
+ };
150
+ const SEVERITY_COLOR = {
151
+ ok: chalk_1.default.hex('#5a9e6e'),
152
+ warn: chalk_1.default.hex('#d4903a'),
153
+ error: chalk_1.default.hex('#b15439'),
154
+ fixable: chalk_1.default.hex('#d4903a'),
155
+ };
156
+ const CATEGORY_LABEL = {
157
+ build: 'Build', config: 'Config', source: 'Source', assets: 'Assets',
158
+ skills: 'Skills', deps: 'Dependencies', git: 'Git', env: 'Environment',
159
+ version: 'Version', memory: 'Memory', hygiene: 'Repo Hygiene',
160
+ };
161
+ function formatDoctorReport(report) {
162
+ const w = process.stdout.columns ?? 80;
163
+ const line = chalk_1.default.hex('#4e3d30')('─'.repeat(Math.min(w - 4, 60)));
164
+ const parts = [
165
+ '',
166
+ line,
167
+ chalk_1.default.hex('#cc785c').bold(' ◆ Aura Doctor — System Diagnostic'),
168
+ chalk_1.default.hex('#8a7768')(` v${report.version} · ${new Date(report.timestamp).toLocaleString()}`),
169
+ line,
170
+ '',
171
+ ];
172
+ // Group findings by category
173
+ const categories = [...new Set(report.findings.map(f => f.category))];
174
+ for (const cat of categories) {
175
+ const catFindings = report.findings.filter(f => f.category === cat);
176
+ parts.push(chalk_1.default.hex('#cc785c').bold(` ${CATEGORY_LABEL[cat] ?? cat}`));
177
+ for (const f of catFindings) {
178
+ const icon = SEVERITY_COLOR[f.severity](SEVERITY_ICON[f.severity]);
179
+ const msg = chalk_1.default.hex('#c8b5a0')(f.message);
180
+ const fixTag = f.fixable && !report.fixed.includes(f.name)
181
+ ? ' ' + chalk_1.default.hex('#d4903a')('[fixable]')
182
+ : report.fixed.includes(f.name)
183
+ ? ' ' + chalk_1.default.hex('#5a9e6e')('[fixed]')
184
+ : '';
185
+ parts.push(` ${icon} ${msg}${fixTag}`);
186
+ if (f.detail) {
187
+ for (const dl of f.detail.split('\n')) {
188
+ parts.push(chalk_1.default.hex('#4e3d30')(` ${dl}`));
189
+ }
190
+ }
191
+ if (f.fixDescription && f.fixable && !report.fixed.includes(f.name)) {
192
+ parts.push(chalk_1.default.hex('#8a7768')(` → ${f.fixDescription}`));
193
+ }
194
+ }
195
+ parts.push('');
196
+ }
197
+ // Summary
198
+ const s = report.summary;
199
+ const allOk = s.error === 0 && s.warn === 0 && s.fixable === 0;
200
+ parts.push(line);
201
+ if (allOk) {
202
+ parts.push(chalk_1.default.hex('#5a9e6e').bold(' ✓ All checks passed — Aura is healthy.'));
203
+ }
204
+ else {
205
+ const bits = [];
206
+ if (s.error > 0)
207
+ bits.push(chalk_1.default.hex('#b15439')(`${s.error} error(s)`));
208
+ if (s.warn > 0)
209
+ bits.push(chalk_1.default.hex('#d4903a')(`${s.warn} warning(s)`));
210
+ if (s.fixable > 0)
211
+ bits.push(chalk_1.default.hex('#d4903a')(`${s.fixable} fixable`));
212
+ if (s.ok > 0)
213
+ bits.push(chalk_1.default.hex('#5a9e6e')(`${s.ok} ok`));
214
+ parts.push(` ${bits.join(' · ')}`);
215
+ }
216
+ if (report.fixed.length > 0) {
217
+ parts.push(chalk_1.default.hex('#5a9e6e')(` ✓ Repaired: ${report.fixed.join(', ')}`));
218
+ }
219
+ if (report.fixFailed.length > 0) {
220
+ parts.push(chalk_1.default.hex('#b15439')(` ✗ Could not repair: ${report.fixFailed.join(', ')}`));
221
+ }
222
+ const fixableCount = report.findings.filter(f => f.fixable && !report.fixed.includes(f.name)).length;
223
+ if (fixableCount > 0 && !report.fixed.length) {
224
+ parts.push(chalk_1.default.hex('#8a7768')(` Run aura --doctor --fix to attempt ${fixableCount} repair(s).`));
225
+ }
226
+ parts.push(line + '\n');
227
+ return parts.join('\n');
228
+ }
229
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/doctor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,8BAiFC;AA0BD,gDAoEC;AA/LD;;;;;;;;GAQG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAE1B,2CAA6D;AAC7D,2CAA+D;AAExD,KAAK,UAAU,SAAS,CAAC,IAAmB;IACjD,MA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CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,yBAAyB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACrG,IAAI,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,wCAAwC,YAAY,aAAa,CAAC,CAAC,CAAC;IACtG,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACxB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { Finding } from './types.js';
2
+ export interface RepairResult {
3
+ name: string;
4
+ success: boolean;
5
+ message: string;
6
+ }
7
+ /** Rebuild dist/ from src/ via `npm run build`. */
8
+ export declare function repairBuild(root: string): RepairResult;
9
+ /** Restore a git-tracked file to its committed state via `git restore`. */
10
+ export declare function repairGitFile(root: string, fileRel: string): RepairResult;
11
+ /** Run npm install to restore missing node_modules. */
12
+ export declare function repairDeps(root: string): RepairResult;
13
+ /** Delete a corrupted file (e.g. invalid identity.json). */
14
+ export declare function repairDelete(root: string, absPath: string): RepairResult;
15
+ /**
16
+ * Attempt to repair a single finding. Returns the repair result, or null
17
+ * if the finding is not auto-repairable or doesn't map to a known repair.
18
+ */
19
+ export declare function attemptRepair(root: string, finding: Finding): RepairResult | null;
@@ -0,0 +1,126 @@
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.repairBuild = repairBuild;
37
+ exports.repairGitFile = repairGitFile;
38
+ exports.repairDeps = repairDeps;
39
+ exports.repairDelete = repairDelete;
40
+ exports.attemptRepair = attemptRepair;
41
+ /**
42
+ * Aura Doctor — repair module. Each function attempts to fix a specific
43
+ * class of finding and returns true on success, false on failure.
44
+ *
45
+ * Repairs use direct execSync / fs calls — they never go through the agent
46
+ * tool layer (the safety layer blocks git checkout/reset for telegram, and
47
+ * the agent has no git_restore tool anyway).
48
+ */
49
+ const fs = __importStar(require("fs"));
50
+ const path = __importStar(require("path"));
51
+ const child_process_1 = require("child_process");
52
+ function sh(cmd, cwd) {
53
+ try {
54
+ return (0, child_process_1.execSync)(cmd, { cwd, encoding: 'utf8', timeout: 120_000, stdio: ['pipe', 'pipe', 'pipe'] }).trim();
55
+ }
56
+ catch (e) {
57
+ throw new Error(String(e));
58
+ }
59
+ }
60
+ /** Rebuild dist/ from src/ via `npm run build`. */
61
+ function repairBuild(root) {
62
+ try {
63
+ sh('npm run build', root);
64
+ return { name: 'rebuild dist', success: true, message: 'Rebuilt dist/ via npm run build.' };
65
+ }
66
+ catch (e) {
67
+ return { name: 'rebuild dist', success: false, message: `Build failed: ${String(e).slice(0, 200)}` };
68
+ }
69
+ }
70
+ /** Restore a git-tracked file to its committed state via `git restore`. */
71
+ function repairGitFile(root, fileRel) {
72
+ try {
73
+ sh(`git restore -- "${fileRel}"`, root);
74
+ return { name: `restore ${fileRel}`, success: true, message: `Restored ${fileRel} from git.` };
75
+ }
76
+ catch (e) {
77
+ return { name: `restore ${fileRel}`, success: false, message: `Could not restore: ${String(e).slice(0, 200)}` };
78
+ }
79
+ }
80
+ /** Run npm install to restore missing node_modules. */
81
+ function repairDeps(root) {
82
+ try {
83
+ sh('npm install', root);
84
+ return { name: 'npm install', success: true, message: 'Dependencies installed.' };
85
+ }
86
+ catch (e) {
87
+ return { name: 'npm install', success: false, message: `npm install failed: ${String(e).slice(0, 200)}` };
88
+ }
89
+ }
90
+ /** Delete a corrupted file (e.g. invalid identity.json). */
91
+ function repairDelete(root, absPath) {
92
+ try {
93
+ fs.unlinkSync(absPath);
94
+ return { name: `delete ${path.basename(absPath)}`, success: true, message: `Deleted ${absPath}.` };
95
+ }
96
+ catch (e) {
97
+ return { name: `delete ${path.basename(absPath)}`, success: false, message: `Could not delete: ${String(e).slice(0, 200)}` };
98
+ }
99
+ }
100
+ /**
101
+ * Attempt to repair a single finding. Returns the repair result, or null
102
+ * if the finding is not auto-repairable or doesn't map to a known repair.
103
+ */
104
+ function attemptRepair(root, finding) {
105
+ if (!finding.fixable)
106
+ return null;
107
+ // Build staleness / missing dist
108
+ if (finding.category === 'build' && (finding.name === 'dist directory' || finding.name === 'entry point' || finding.name === 'dist freshness')) {
109
+ return repairBuild(root);
110
+ }
111
+ // Missing node_modules or key deps
112
+ if (finding.category === 'deps' && (finding.name === 'node_modules' || finding.name.startsWith('dep:'))) {
113
+ return repairDeps(root);
114
+ }
115
+ // Corrupted identity.json
116
+ if (finding.category === 'memory' && finding.name === 'identity') {
117
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? '~';
118
+ return repairDelete(root, path.join(home, '.aura', 'memory', 'identity.json'));
119
+ }
120
+ // Corrupted .aura.json — suggest deletion (don't auto-delete config the user wrote)
121
+ if (finding.category === 'config' && finding.name === '.aura.json') {
122
+ return { name: '.aura.json', success: false, message: 'Cannot auto-repair .aura.json — fix the JSON syntax manually or delete it to use defaults.' };
123
+ }
124
+ return null;
125
+ }
126
+ //# sourceMappingURL=repair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repair.js","sourceRoot":"","sources":["../../src/doctor/repair.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,kCAOC;AAGD,sCAOC;AAGD,gCAOC;AAGD,oCAOC;AAMD,sCAyBC;AAhGD;;;;;;;GAOG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAyC;AAGzC,SAAS,EAAE,CAAC,GAAW,EAAE,GAAW;IAClC,IAAI,CAAC;QACH,OAAO,IAAA,wBAAQ,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5G,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAQD,mDAAmD;AACnD,SAA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QACxG,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,0BAA0B;IAC1B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACjE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC;QAChE,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,oFAAoF;IACpF,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACnE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,4FAA4F,EAAE,CAAC;IACvJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Aura Doctor — type definitions for the self-diagnostic system.
3
+ *
4
+ * A Finding is a single check result. A DoctorReport is the full scan
5
+ * output. Everything is observational unless the caller passes fix:true,
6
+ * in which case repair.ts attempts auto-repairs and records what it did.
7
+ */
8
+ export type Severity = 'ok' | 'warn' | 'error' | 'fixable';
9
+ export type Category = 'build' | 'config' | 'source' | 'assets' | 'skills' | 'deps' | 'git' | 'env' | 'version' | 'memory' | 'hygiene';
10
+ export interface Finding {
11
+ category: Category;
12
+ name: string;
13
+ severity: Severity;
14
+ message: string;
15
+ detail?: string;
16
+ /** Whether runDoctor({fix:true}) can attempt to repair this. */
17
+ fixable: boolean;
18
+ /** Human description of what the fix does, shown when not auto-fixing. */
19
+ fixDescription?: string;
20
+ }
21
+ export interface DoctorReport {
22
+ timestamp: number;
23
+ version: string;
24
+ projectRoot: string;
25
+ findings: Finding[];
26
+ summary: Record<Severity, number>;
27
+ /** Names of findings that were auto-repaired (only when fix:true). */
28
+ fixed: string[];
29
+ /** Names of findings where repair was attempted but failed. */
30
+ fixFailed: string[];
31
+ }
32
+ export interface DoctorOptions {
33
+ projectRoot: string;
34
+ /** Attempt auto-repair for fixable findings. */
35
+ fix?: boolean;
36
+ /** Skip checks that hit the network (version check). */
37
+ offline?: boolean;
38
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Aura Doctor — type definitions for the self-diagnostic system.
4
+ *
5
+ * A Finding is a single check result. A DoctorReport is the full scan
6
+ * output. Everything is observational unless the caller passes fix:true,
7
+ * in which case repair.ts attempts auto-repairs and records what it did.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/doctor/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -1,71 +1,91 @@
1
1
  import type { LLMProvider } from '../providers/types.js';
2
2
  /**
3
- * Aura's "dream": an offline consolidation pass over recorded episodes.
4
- *
5
- * Stages:
6
- * 1. Recall — load episodes since the last dream.
7
- * 2. Consolidate — distil them into lessons + patterns via the LLM.
8
- * 3. Prepare — write a short brief of open threads for tomorrow.
9
- * 4. Reconcile — if ≥3 existing dreams, run memory reconciliation
10
- * across all dreams and write `dreams/.reconciled.md`.
11
- * 5. OKF bundle — if reconciliation succeeded, write a portable
12
- * Open Knowledge Format bundle to `knowledge/`.
13
- * Any OKF-compatible agent can consume Aura's knowledge.
14
- *
15
- * Steps 4-5 are BEST-EFFORT: if they fail, the dream file is still
16
- * written and the cutoff is advanced.
17
- *
18
- * Output is one dated Markdown file per night under `<projectRoot>/dreams/`.
19
- * The structure is deliberately stable and entity-tagged so a later pass
20
- * (`:rem`) can parse these files into a relations graph. Do not reformat the
21
- * headers without updating the parser (parser.ts).
22
- *
23
- * Memory reconciliation produces `dreams/.reconciled.md` — a PROJECTION
24
- * (materialized view) of current beliefs with annotations showing lineage.
25
- * The OKF bundle in `knowledge/` is the same data in a portable, vendor-
26
- * neutral format readable by any agent or tool.
27
- * Old dream files stay untouched as an append-only audit trail.
3
+ * Dated dream-store path for a mid-session flush (see generational-flush.ts).
4
+ * Suffixed so multiple flushes in one day don't collide with each other or
5
+ * with the end-of-session `todayFile()` dream — each is its own dream file,
6
+ * picked up the same way by `listDreamFiles`/`runReconciliation`.
28
7
  */
29
- export interface DreamResult {
30
- path: string;
31
- date: string;
32
- episodeCount: number;
33
- recalledSince: number;
34
- skipped: boolean;
35
- reason?: string;
36
- /** Set when the LLM consolidation failed — episodes are preserved and NOT burned. */
37
- providerError?: string;
38
- /** True if memory reconciliation ran successfully after the dream was written. */
39
- reconciled?: boolean;
40
- /** Path to the OKF bundle if it was written. */
41
- okfBundlePath?: string;
42
- }
43
- /** Timestamp (ms) of the last dream for this project, or 0 if never. */
44
- export declare function lastDreamTimestamp(projectRoot: string): number;
8
+ export declare function sessionFlushFile(root: string, seq: number): string;
45
9
  /**
46
- * Run a dream. Pure with respect to I/O sources: caller supplies the provider.
47
- * Never throws on an empty dayreturns { skipped: true }.
48
- *
49
- * IMPORTANT: the `.last.json` state cutoff is only advanced when the LLM
50
- * consolidation succeeds. If the primary provider fails, a single retry on a
51
- * local Ollama instance is attempted before giving up gracefully. Episodes are
52
- * NEVER burned (cut off) when the provider is unreachable.
53
- *
54
- * After a successful dream write, memory reconciliation runs (if ≥3 dreams
55
- * exist). If reconciliation succeeds, an OKF knowledge bundle is also
56
- * written to `knowledge/`. Both are best-effort if either fails, the
57
- * dream file and cutoff are already committed.
10
+ * The consolidation cutoff: the timestamp of the newest episode covered by
11
+ * the last successful dream. Stored in dreams/.state.json NOT derived from
12
+ * file mtimes, so a failed run (which writes nothing) can never advance it
13
+ * and the same episodes are re-recalled next time.
14
+ */
15
+ export declare function lastDreamTimestamp(root: string): number;
16
+ /**
17
+ * Spend one LLM call distilling `userContent` under `systemPrompt`, and
18
+ * write the result to `outPath`. The one shared distillation primitive
19
+ * `runDream` uses it for episode batches, and a mid-session context-window
20
+ * rollover (src/agent/generational-flush.ts) uses it for a recap block
21
+ * so both write into the same dream-store shape and both feed the same
22
+ * `runReconciliation()` pass.
58
23
  */
59
- export declare function runDream(opts: {
24
+ export declare function distillText(opts: {
25
+ systemPrompt: string;
26
+ userContent: string;
27
+ provider: LLMProvider;
28
+ outPath: string;
29
+ }): Promise<string>;
30
+ export interface DreamOptions {
60
31
  projectRoot: string;
61
32
  provider: LLMProvider;
62
- /** Override the "since" cutoff (ms). Defaults to last dream timestamp. */
33
+ /** Cutoff override (ms). Defaults to the stored cutoff from the last successful dream. */
63
34
  since?: number;
64
- /** If true, consolidate ALL episodes regardless of last-dream cutoff. */
35
+ /** Ignore the cutoff and consolidate every recorded episode. */
65
36
  full?: boolean;
66
37
  /**
67
- * Ollama model to use as a local fallback when the primary provider fails.
68
- * Set to false to disable. Defaults to 'llama3.2'.
38
+ * Local model to retry with when the primary provider fails (Ollama must be
39
+ * running). Pass `false` to disable the fallback entirely.
69
40
  */
70
41
  ollamaFallbackModel?: string | false;
71
- }): Promise<DreamResult>;
42
+ }
43
+ export interface DreamResult {
44
+ /** True when nothing was written — empty day, or provider failure. */
45
+ skipped: boolean;
46
+ /** Episodes recalled for this cycle (still counted on failure — they're preserved). */
47
+ episodeCount: number;
48
+ /** Why the run was skipped, for the empty-day case. */
49
+ reason?: string;
50
+ /** Written dream file, on success. */
51
+ path?: string;
52
+ /** The cutoff actually used (0 for full runs). */
53
+ recalledSince?: number;
54
+ /** Provider failure detail — set only when skipped due to LLM errors. */
55
+ providerError?: string;
56
+ /** True when >=3 dreams existed after the write and reconciliation ran. */
57
+ reconciled?: boolean;
58
+ }
59
+ /**
60
+ * Run one dream cycle: consolidate episodes since the last dream into a
61
+ * dated markdown file. Spends exactly one LLM call (plus at most one Ollama
62
+ * fallback call). Triggers reconciliation automatically once >=3 dream
63
+ * files exist.
64
+ *
65
+ * Critical invariant: episodes are NEVER burned on failure. The dream file
66
+ * and the cutoff advance together, and only after the model produced real
67
+ * content — any provider error or empty response leaves both untouched, so
68
+ * the next run re-recalls the same episodes.
69
+ */
70
+ export declare function runDream(opts: DreamOptions): Promise<DreamResult>;
71
+ /**
72
+ * Reconcile all dream files into one projection. Pure statistics:
73
+ * confidence = (number of dreams whose topicKey group contains this claim) / (total dream files).
74
+ * This is a lexical-overlap heuristic (v1) — not full semantic dedup.
75
+ */
76
+ export declare function runReconciliation(root: string): string;
77
+ /** For :rem — the current reconciled projection, or the latest dream if reconciliation hasn't triggered yet. */
78
+ export declare function getReconciledOrLatest(root: string): {
79
+ content: string;
80
+ isReconciled: boolean;
81
+ } | null;
82
+ /**
83
+ * Global lessons digest — pure statistics over EVERY project's episodes.
84
+ * Written to ~/.aura/memory/lessons-global.md for the Telegram bot (which
85
+ * isn't tied to one project). No LLM call: counts successes/failures per model
86
+ * and surfaces the most recent activity. Mirrors runReconciliation's "trust
87
+ * numbers, not a model's guess" philosophy.
88
+ */
89
+ export declare function runGlobalReconciliation(): string;
90
+ /** For system-prompt injection — the reconciled memory, truncated, or empty string if none exists. */
91
+ export declare function loadReconciledMemorySection(root: string): string;