aura-code 0.5.0 → 0.6.3
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.
- package/README.md +3 -3
- package/dist/agent/context.d.ts +4 -0
- package/dist/agent/context.js +38 -0
- package/dist/agent/context.js.map +1 -1
- package/dist/agent/loop.js +16 -0
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/system-prompt.js +9 -1
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/cli/display.js +6 -1
- package/dist/cli/display.js.map +1 -1
- package/dist/cli/index.js +71 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/config/defaults.js +8 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/dream/dream.d.ts +25 -2
- package/dist/dream/dream.js +36 -6
- package/dist/dream/dream.js.map +1 -1
- package/dist/dream/okf.d.ts +10 -0
- package/dist/dream/okf.js +280 -0
- package/dist/dream/okf.js.map +1 -0
- package/dist/dream/parser.d.ts +60 -0
- package/dist/dream/parser.js +176 -0
- package/dist/dream/parser.js.map +1 -0
- package/dist/dream/reconcile.d.ts +69 -0
- package/dist/dream/reconcile.js +303 -0
- package/dist/dream/reconcile.js.map +1 -0
- package/dist/machina/index.d.ts +16 -0
- package/dist/machina/index.js +61 -0
- package/dist/machina/index.js.map +1 -0
- package/dist/machina/render-html.d.ts +2 -0
- package/dist/machina/render-html.js +189 -0
- package/dist/machina/render-html.js.map +1 -0
- package/dist/machina/render-terminal.d.ts +2 -0
- package/dist/machina/render-terminal.js +92 -0
- package/dist/machina/render-terminal.js.map +1 -0
- package/dist/machina/spec.d.ts +61 -0
- package/dist/machina/spec.js +124 -0
- package/dist/machina/spec.js.map +1 -0
- package/dist/machina/verify.d.ts +27 -0
- package/dist/machina/verify.js +85 -0
- package/dist/machina/verify.js.map +1 -0
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/factory.d.ts +33 -0
- package/dist/providers/factory.js +27 -0
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/google.js +1 -1
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/openai-compatible.js +1 -1
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/rem/graph.d.ts +72 -0
- package/dist/rem/graph.js +139 -0
- package/dist/rem/graph.js.map +1 -0
- package/dist/rem/index.d.ts +16 -0
- package/dist/rem/index.js +60 -0
- package/dist/rem/index.js.map +1 -0
- package/dist/rem/render-html.d.ts +2 -0
- package/dist/rem/render-html.js +189 -0
- package/dist/rem/render-html.js.map +1 -0
- package/dist/rem/render-terminal.d.ts +4 -0
- package/dist/rem/render-terminal.js +94 -0
- package/dist/rem/render-terminal.js.map +1 -0
- package/dist/research/council.d.ts +3 -2
- package/dist/research/council.js +47 -9
- package/dist/research/council.js.map +1 -1
- package/dist/tools/browser.js +8 -10
- package/dist/tools/browser.js.map +1 -1
- package/dist/tools/gmail-tool.d.ts +5 -1
- package/dist/tools/gmail-tool.js +151 -11
- package/dist/tools/gmail-tool.js.map +1 -1
- package/dist/tools/telegram-bot.js +6 -8
- package/dist/tools/telegram-bot.js.map +1 -1
- package/dist/tools/web-search.d.ts +20 -0
- package/dist/tools/web-search.js +134 -38
- package/dist/tools/web-search.js.map +1 -1
- package/dist/viz/reader.d.ts +33 -0
- package/dist/viz/reader.js +343 -0
- package/dist/viz/reader.js.map +1 -0
- package/package.json +2 -1
package/dist/dream/dream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dream.js","sourceRoot":"","sources":["../../src/dream/dream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"dream.js","sourceRoot":"","sources":["../../src/dream/dream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,gDAQC;AA+DD,4BA2HC;AA/PD,uCAAyB;AACzB,2CAA6B;AAC7B,mEAA0D;AAG1D,wDAA4E;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*
|
|
5
|
+
* Called after reconciliation succeeds. Best-effort — if this fails,
|
|
6
|
+
* .reconciled.md is already written and the dream is safe.
|
|
7
|
+
*
|
|
8
|
+
* The bundle directory is wiped and rebuilt each time (it's a projection).
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeOkfBundle(bullets: ReconciledBullet[], totalDreams: number, projectRoot: string): string;
|
|
@@ -0,0 +1,280 @@
|
|
|
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.writeOkfBundle = writeOkfBundle;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* OKF (Open Knowledge Format) v0.1 bundle writer.
|
|
41
|
+
*
|
|
42
|
+
* Takes the reconciled bullets from Aura's dream system and writes them
|
|
43
|
+
* as a portable OKF knowledge bundle under `<projectRoot>/knowledge/`.
|
|
44
|
+
*
|
|
45
|
+
* OKF spec: https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md
|
|
46
|
+
*
|
|
47
|
+
* Why both .reconciled.md AND an OKF bundle?
|
|
48
|
+
* - `.reconciled.md` is Aura's internal format — compact, fast, injected
|
|
49
|
+
* into the system prompt for Aura's own use.
|
|
50
|
+
* - `knowledge/` is the portable output — any other agent, tool, or human
|
|
51
|
+
* can read it. Cursor, Claude Code, LangChain agents, Obsidian, MkDocs,
|
|
52
|
+
* or any OKF consumer can consume Aura's accumulated knowledge without
|
|
53
|
+
* understanding Aura's dream format.
|
|
54
|
+
*
|
|
55
|
+
* The bundle is regenerated on every reconciliation pass. It's a projection,
|
|
56
|
+
* just like .reconciled.md — delete it and the next :dream rebuilds it.
|
|
57
|
+
*
|
|
58
|
+
* Concept types used:
|
|
59
|
+
* - "lesson" — from ## Lessons
|
|
60
|
+
* - "pattern" — from ## Patterns
|
|
61
|
+
* - "open-thread" — from ## Open threads
|
|
62
|
+
* - "conflict" — CONFLICT verdicts get their own concepts
|
|
63
|
+
*
|
|
64
|
+
* Directory structure:
|
|
65
|
+
* knowledge/
|
|
66
|
+
* index.md — bundle root index (okf_version: "0.1")
|
|
67
|
+
* log.md — reconciliation changelog
|
|
68
|
+
* lessons/
|
|
69
|
+
* index.md
|
|
70
|
+
* <slug>.md
|
|
71
|
+
* patterns/
|
|
72
|
+
* index.md
|
|
73
|
+
* <slug>.md
|
|
74
|
+
* open-threads/
|
|
75
|
+
* index.md
|
|
76
|
+
* <slug>.md
|
|
77
|
+
*/
|
|
78
|
+
const KNOWLEDGE_DIR = 'knowledge';
|
|
79
|
+
const OKF_VERSION = '0.1';
|
|
80
|
+
const SECTION_DIR = {
|
|
81
|
+
lessons: 'lessons',
|
|
82
|
+
patterns: 'patterns',
|
|
83
|
+
openThreads: 'open-threads',
|
|
84
|
+
};
|
|
85
|
+
const SECTION_TYPE = {
|
|
86
|
+
lessons: 'lesson',
|
|
87
|
+
patterns: 'pattern',
|
|
88
|
+
openThreads: 'open-thread',
|
|
89
|
+
};
|
|
90
|
+
const SECTION_LABEL = {
|
|
91
|
+
lessons: 'Lessons',
|
|
92
|
+
patterns: 'Patterns',
|
|
93
|
+
openThreads: 'Open Threads',
|
|
94
|
+
};
|
|
95
|
+
function slugify(text, tag) {
|
|
96
|
+
const base = tag ? `${tag}-${text}` : text;
|
|
97
|
+
return base
|
|
98
|
+
.toLowerCase()
|
|
99
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
100
|
+
.replace(/^-+|-+$/g, '')
|
|
101
|
+
.slice(0, 60) || 'concept';
|
|
102
|
+
}
|
|
103
|
+
function deduplicateSlug(slug, existing) {
|
|
104
|
+
if (!existing.has(slug)) {
|
|
105
|
+
existing.add(slug);
|
|
106
|
+
return slug;
|
|
107
|
+
}
|
|
108
|
+
let i = 2;
|
|
109
|
+
while (existing.has(`${slug}-${i}`))
|
|
110
|
+
i++;
|
|
111
|
+
const unique = `${slug}-${i}`;
|
|
112
|
+
existing.add(unique);
|
|
113
|
+
return unique;
|
|
114
|
+
}
|
|
115
|
+
function buildFrontmatter(fields) {
|
|
116
|
+
const lines = ['---'];
|
|
117
|
+
for (const [key, val] of Object.entries(fields)) {
|
|
118
|
+
if (val === undefined)
|
|
119
|
+
continue;
|
|
120
|
+
if (Array.isArray(val)) {
|
|
121
|
+
if (val.length > 0)
|
|
122
|
+
lines.push(`${key}: [${val.map(v => `"${v}"`).join(', ')}]`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Quote strings that contain colons or special chars
|
|
126
|
+
const needsQuote = /[:#\[\]{}"']/.test(val) || val.includes('\n');
|
|
127
|
+
lines.push(`${key}: ${needsQuote ? `"${val.replace(/"/g, '\\"')}"` : val}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
lines.push('---');
|
|
131
|
+
return lines.join('\n');
|
|
132
|
+
}
|
|
133
|
+
function buildConceptFile(bullet, totalDreams) {
|
|
134
|
+
const type = bullet.action === 'CONFLICT' ? 'conflict' : SECTION_TYPE[bullet.section];
|
|
135
|
+
const title = bullet.text.slice(0, 120);
|
|
136
|
+
const tags = bullet.tag ? [bullet.tag] : [];
|
|
137
|
+
if (bullet.action !== 'KEEP')
|
|
138
|
+
tags.push(bullet.action.toLowerCase());
|
|
139
|
+
const latestDate = bullet.sourceDates.length > 0
|
|
140
|
+
? bullet.sourceDates[bullet.sourceDates.length - 1]
|
|
141
|
+
: new Date().toISOString().slice(0, 10);
|
|
142
|
+
const timestamp = `${latestDate}T00:00:00Z`;
|
|
143
|
+
const frontmatter = buildFrontmatter({
|
|
144
|
+
type,
|
|
145
|
+
title,
|
|
146
|
+
description: bullet.text,
|
|
147
|
+
tags,
|
|
148
|
+
timestamp,
|
|
149
|
+
});
|
|
150
|
+
const bodyLines = [];
|
|
151
|
+
bodyLines.push(`# ${title}`);
|
|
152
|
+
bodyLines.push('');
|
|
153
|
+
bodyLines.push(bullet.text);
|
|
154
|
+
bodyLines.push('');
|
|
155
|
+
bodyLines.push(`*${bullet.annotation}* · confidence: ${bullet.confidence}`);
|
|
156
|
+
if (bullet.action === 'CONFLICT' && bullet.conflictsWith) {
|
|
157
|
+
bodyLines.push('');
|
|
158
|
+
bodyLines.push('## Opposing claim');
|
|
159
|
+
bodyLines.push('');
|
|
160
|
+
bodyLines.push(`> ${bullet.conflictsWith.text}`);
|
|
161
|
+
bodyLines.push(`> — *${bullet.conflictsWith.date}*`);
|
|
162
|
+
}
|
|
163
|
+
bodyLines.push('');
|
|
164
|
+
bodyLines.push(`Source dreams: ${bullet.sourceDates.join(', ')}`);
|
|
165
|
+
return `${frontmatter}\n\n${bodyLines.join('\n')}\n`;
|
|
166
|
+
}
|
|
167
|
+
function buildSectionIndex(sectionLabel, concepts) {
|
|
168
|
+
const lines = [`# ${sectionLabel}`];
|
|
169
|
+
lines.push('');
|
|
170
|
+
if (concepts.length === 0) {
|
|
171
|
+
lines.push('*No concepts in this section yet.*');
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
for (const c of concepts) {
|
|
175
|
+
lines.push(`* [${c.title}](${c.slug}.md)`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
lines.push('');
|
|
179
|
+
return lines.join('\n');
|
|
180
|
+
}
|
|
181
|
+
function buildRootIndex(sections, totalDreams, totalConcepts) {
|
|
182
|
+
const frontmatter = buildFrontmatter({ okf_version: OKF_VERSION });
|
|
183
|
+
const lines = [frontmatter, ''];
|
|
184
|
+
lines.push('# Aura Code — Knowledge Bundle');
|
|
185
|
+
lines.push('');
|
|
186
|
+
lines.push(`> OKF v${OKF_VERSION} · ${totalConcepts} concepts from ${totalDreams} dream(s)`);
|
|
187
|
+
lines.push('');
|
|
188
|
+
lines.push('This bundle is generated by [Aura Code](https://github.com/milodule3-debug/aura-code)\'s');
|
|
189
|
+
lines.push('dream reconciliation system. It contains the agent\'s accumulated knowledge about');
|
|
190
|
+
lines.push('this project — lessons learned, patterns observed, and open threads — in the');
|
|
191
|
+
lines.push('[Open Knowledge Format](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md).');
|
|
192
|
+
lines.push('');
|
|
193
|
+
lines.push('Any OKF-compatible agent, tool, or viewer can consume this bundle.');
|
|
194
|
+
lines.push('');
|
|
195
|
+
for (const [dirName, concepts] of Object.entries(sections)) {
|
|
196
|
+
const label = dirName.charAt(0).toUpperCase() + dirName.slice(1).replace(/-/g, ' ');
|
|
197
|
+
lines.push(`# ${label}`);
|
|
198
|
+
lines.push('');
|
|
199
|
+
if (concepts.length === 0) {
|
|
200
|
+
lines.push('*None yet.*');
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
for (const c of concepts) {
|
|
204
|
+
lines.push(`* [${c.title}](${dirName}/${c.slug}.md)`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
lines.push('');
|
|
208
|
+
}
|
|
209
|
+
return lines.join('\n');
|
|
210
|
+
}
|
|
211
|
+
function buildLog(totalDreams, totalConcepts, actionCounts) {
|
|
212
|
+
const now = new Date().toISOString().slice(0, 10);
|
|
213
|
+
const stats = Object.entries(actionCounts)
|
|
214
|
+
.map(([k, v]) => `${v} ${k}`)
|
|
215
|
+
.join(', ');
|
|
216
|
+
return [
|
|
217
|
+
'# Change Log',
|
|
218
|
+
'',
|
|
219
|
+
`## ${now}`,
|
|
220
|
+
'',
|
|
221
|
+
`Reconciled ${totalDreams} dream(s) into ${totalConcepts} concepts: ${stats}.`,
|
|
222
|
+
'',
|
|
223
|
+
'Generated by Aura Code · dream reconciliation · OKF v0.1.',
|
|
224
|
+
'',
|
|
225
|
+
].join('\n');
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Write an OKF v0.1 knowledge bundle from reconciled bullets.
|
|
229
|
+
*
|
|
230
|
+
* Called after reconciliation succeeds. Best-effort — if this fails,
|
|
231
|
+
* .reconciled.md is already written and the dream is safe.
|
|
232
|
+
*
|
|
233
|
+
* The bundle directory is wiped and rebuilt each time (it's a projection).
|
|
234
|
+
*/
|
|
235
|
+
function writeOkfBundle(bullets, totalDreams, projectRoot) {
|
|
236
|
+
const bundleRoot = path.join(projectRoot, KNOWLEDGE_DIR);
|
|
237
|
+
// Clean and recreate
|
|
238
|
+
if (fs.existsSync(bundleRoot)) {
|
|
239
|
+
fs.rmSync(bundleRoot, { recursive: true, force: true });
|
|
240
|
+
}
|
|
241
|
+
const sections = ['lessons', 'patterns', 'openThreads'];
|
|
242
|
+
const sectionConcepts = {};
|
|
243
|
+
const slugSets = {};
|
|
244
|
+
const actionCounts = {};
|
|
245
|
+
for (const section of sections) {
|
|
246
|
+
const dirName = SECTION_DIR[section];
|
|
247
|
+
const dirPath = path.join(bundleRoot, dirName);
|
|
248
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
249
|
+
sectionConcepts[dirName] = [];
|
|
250
|
+
slugSets[dirName] = new Set();
|
|
251
|
+
}
|
|
252
|
+
// Write concept files
|
|
253
|
+
for (const bullet of bullets) {
|
|
254
|
+
const dirName = SECTION_DIR[bullet.section];
|
|
255
|
+
const dirPath = path.join(bundleRoot, dirName);
|
|
256
|
+
const rawSlug = slugify(bullet.text, bullet.tag);
|
|
257
|
+
const slug = deduplicateSlug(rawSlug, slugSets[dirName]);
|
|
258
|
+
const title = bullet.text.slice(0, 120);
|
|
259
|
+
const content = buildConceptFile(bullet, totalDreams);
|
|
260
|
+
fs.writeFileSync(path.join(dirPath, `${slug}.md`), content);
|
|
261
|
+
sectionConcepts[dirName].push({ slug, title });
|
|
262
|
+
actionCounts[bullet.action] = (actionCounts[bullet.action] ?? 0) + 1;
|
|
263
|
+
}
|
|
264
|
+
// Write section index files
|
|
265
|
+
for (const section of sections) {
|
|
266
|
+
const dirName = SECTION_DIR[section];
|
|
267
|
+
const dirPath = path.join(bundleRoot, dirName);
|
|
268
|
+
const indexContent = buildSectionIndex(SECTION_LABEL[section], sectionConcepts[dirName]);
|
|
269
|
+
fs.writeFileSync(path.join(dirPath, 'index.md'), indexContent);
|
|
270
|
+
}
|
|
271
|
+
// Write root index
|
|
272
|
+
const totalConcepts = bullets.length;
|
|
273
|
+
const rootIndex = buildRootIndex(sectionConcepts, totalDreams, totalConcepts);
|
|
274
|
+
fs.writeFileSync(path.join(bundleRoot, 'index.md'), rootIndex);
|
|
275
|
+
// Write log.md
|
|
276
|
+
const log = buildLog(totalDreams, totalConcepts, actionCounts);
|
|
277
|
+
fs.writeFileSync(path.join(bundleRoot, 'log.md'), log);
|
|
278
|
+
return bundleRoot;
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=okf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"okf.js","sourceRoot":"","sources":["../../src/dream/okf.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8NA,wCA0DC;AAxRD,uCAAyB;AACzB,2CAA6B;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,MAAM,aAAa,GAAG,WAAW,CAAC;AAClC,MAAM,WAAW,GAAG,KAAK,CAAC;AAI1B,MAAM,WAAW,GAA4B;IAC3C,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,cAAc;CAC5B,CAAC;AAEF,MAAM,YAAY,GAA4B;IAC5C,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,aAAa;CAC3B,CAAC;AAEF,MAAM,aAAa,GAA4B;IAC7C,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,cAAc;CAC5B,CAAC;AAEF,SAAS,OAAO,CAAC,IAAY,EAAE,GAAY;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,OAAO,IAAI;SACR,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;AAC/B,CAAC;AAED,SAAS,eAAe,CAAC,IAAY,EAAE,QAAqB;IA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,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IAC/D,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IAEvD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dream parser — turns a dream markdown file back into a structured
|
|
3
|
+
* `ParsedDream` so reconciliation can dedupe, conflict-check, and project
|
|
4
|
+
* bullets across multiple days.
|
|
5
|
+
*
|
|
6
|
+
* Round-trips files written by `runDream()` in dream.ts. The contract with
|
|
7
|
+
* the writer is fixed: four sections in a fixed order, each containing
|
|
8
|
+
* bullets that may or may not start with a `[tag]` prefix. Bullets may be
|
|
9
|
+
* separated by blank lines, may have trailing whitespace, and may use
|
|
10
|
+
* either `-` or `*` markers — all real artifacts seen in production dreams.
|
|
11
|
+
*
|
|
12
|
+
* This is the FOUNDATION for memory reconciliation (CONFLICT/STRENGTHEN/
|
|
13
|
+
* SUPERSEDE/MERGE/KEEP/DROP). The reconciler reads many ParsedDreams,
|
|
14
|
+
* groups bullets by section, then asks the LLM to reconcile. The parser
|
|
15
|
+
* must be permissive on input (real dream files vary) and lossless on
|
|
16
|
+
* structure (every bullet kept, with its source date attached).
|
|
17
|
+
*
|
|
18
|
+
* What the parser does NOT do:
|
|
19
|
+
* - Validate tag values. `[foo]` is fine even if it's not a known category.
|
|
20
|
+
* - Drop empty sections — they round-trip as empty arrays.
|
|
21
|
+
* - Interpret bullet semantics. That's the reconciler's job.
|
|
22
|
+
*/
|
|
23
|
+
/** A single bullet from a dream section, with its source for annotation. */
|
|
24
|
+
export interface DreamBullet {
|
|
25
|
+
/** Optional `[tag]` prefix at the start of the bullet (e.g. "tooling"). */
|
|
26
|
+
tag?: string;
|
|
27
|
+
/** Bullet text with tag prefix and bullet marker stripped, whitespace trimmed. */
|
|
28
|
+
text: string;
|
|
29
|
+
/** Source dream date (YYYY-MM-DD), set by `parseDreamFile` from the filename. */
|
|
30
|
+
sourceDate: string;
|
|
31
|
+
}
|
|
32
|
+
/** A dream file parsed into its four canonical sections. */
|
|
33
|
+
export interface ParsedDream {
|
|
34
|
+
/** YYYY-MM-DD from the filename (e.g. "2026-06-26"). */
|
|
35
|
+
date: string;
|
|
36
|
+
/** Absolute path the dream was read from. */
|
|
37
|
+
path: string;
|
|
38
|
+
lessons: DreamBullet[];
|
|
39
|
+
patterns: DreamBullet[];
|
|
40
|
+
openThreads: DreamBullet[];
|
|
41
|
+
/** "Tomorrow brief" — free prose, not bullets. Stored as one string or empty. */
|
|
42
|
+
tomorrowBrief: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse dream markdown content. Caller supplies the source date (preferred
|
|
46
|
+
* from filename for cross-OS consistency); falls back to the title line if
|
|
47
|
+
* the filename doesn't encode it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseDreamMarkdown(md: string, sourceDate: string): Omit<ParsedDream, 'path'>;
|
|
50
|
+
/** Read and parse a single dream file from disk. */
|
|
51
|
+
export declare function parseDreamFile(filePath: string): ParsedDream;
|
|
52
|
+
/**
|
|
53
|
+
* Load and parse every `YYYY-MM-DD.md` dream file in `<projectRoot>/dreams/`.
|
|
54
|
+
* Returned oldest-first (chronological), so reconciliation can iterate
|
|
55
|
+
* forward in time when reasoning about strengthening / conflicts.
|
|
56
|
+
*
|
|
57
|
+
* Ignores `.last.json` and `.reconciled.md` (handled separately).
|
|
58
|
+
* Returns `[]` if the dreams directory doesn't exist yet.
|
|
59
|
+
*/
|
|
60
|
+
export declare function loadExistingDreams(projectRoot: string): ParsedDream[];
|
|
@@ -0,0 +1,176 @@
|
|
|
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.parseDreamMarkdown = parseDreamMarkdown;
|
|
37
|
+
exports.parseDreamFile = parseDreamFile;
|
|
38
|
+
exports.loadExistingDreams = loadExistingDreams;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const SECTION_HEADERS = {
|
|
42
|
+
lessons: /^##\s+Lessons\s*$/i,
|
|
43
|
+
patterns: /^##\s+Patterns\s*$/i,
|
|
44
|
+
openThreads: /^##\s+Open\s+threads\s*$/i,
|
|
45
|
+
tomorrowBrief: /^##\s+Tomorrow\s+brief\s*$/i,
|
|
46
|
+
};
|
|
47
|
+
/** Match a bullet line: `- text`, `* text`, optionally indented. */
|
|
48
|
+
const BULLET_RE = /^\s*[-*]\s+(.*)$/;
|
|
49
|
+
/** Match a `[tag]` prefix at the very start of bullet text. */
|
|
50
|
+
const TAG_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
51
|
+
/** Match the "# Dream — DATE" title line (em dash or plain hyphen). */
|
|
52
|
+
const TITLE_RE = /^#\s+Dream\s*[—–-]\s*(\d{4}-\d{2}-\d{2})/;
|
|
53
|
+
function extractDateFromFilename(filePath) {
|
|
54
|
+
const base = path.basename(filePath, '.md');
|
|
55
|
+
const m = base.match(/^(\d{4}-\d{2}-\d{2})$/);
|
|
56
|
+
return m ? m[1] : '';
|
|
57
|
+
}
|
|
58
|
+
function extractDateFromContent(md) {
|
|
59
|
+
for (const line of md.split(/\r?\n/)) {
|
|
60
|
+
const m = line.match(TITLE_RE);
|
|
61
|
+
if (m)
|
|
62
|
+
return m[1];
|
|
63
|
+
}
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
function parseBullet(line, sourceDate) {
|
|
67
|
+
const m = line.match(BULLET_RE);
|
|
68
|
+
if (!m)
|
|
69
|
+
return null;
|
|
70
|
+
const body = m[1].trim();
|
|
71
|
+
if (!body)
|
|
72
|
+
return null;
|
|
73
|
+
const tagMatch = body.match(TAG_RE);
|
|
74
|
+
if (tagMatch) {
|
|
75
|
+
const tag = tagMatch[1].trim();
|
|
76
|
+
const text = tagMatch[2].trim();
|
|
77
|
+
if (!text) {
|
|
78
|
+
// `- [tag]` with no actual content — treat as untagged with the tag as text
|
|
79
|
+
return { text: `[${tag}]`, sourceDate };
|
|
80
|
+
}
|
|
81
|
+
return { tag, text, sourceDate };
|
|
82
|
+
}
|
|
83
|
+
return { text: body, sourceDate };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse dream markdown content. Caller supplies the source date (preferred
|
|
87
|
+
* from filename for cross-OS consistency); falls back to the title line if
|
|
88
|
+
* the filename doesn't encode it.
|
|
89
|
+
*/
|
|
90
|
+
function parseDreamMarkdown(md, sourceDate) {
|
|
91
|
+
const date = sourceDate || extractDateFromContent(md);
|
|
92
|
+
const lines = md.split(/\r?\n/);
|
|
93
|
+
const sections = {
|
|
94
|
+
lessons: [],
|
|
95
|
+
patterns: [],
|
|
96
|
+
openThreads: [],
|
|
97
|
+
tomorrowBrief: [],
|
|
98
|
+
};
|
|
99
|
+
let current = null;
|
|
100
|
+
for (const line of lines) {
|
|
101
|
+
// Detect section transitions.
|
|
102
|
+
let matched = null;
|
|
103
|
+
for (const [key, re] of Object.entries(SECTION_HEADERS)) {
|
|
104
|
+
if (re.test(line)) {
|
|
105
|
+
matched = key;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (matched) {
|
|
110
|
+
current = matched;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
// Any other `##` heading ends the current section.
|
|
114
|
+
if (/^##\s+/.test(line)) {
|
|
115
|
+
current = null;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (current)
|
|
119
|
+
sections[current].push(line);
|
|
120
|
+
}
|
|
121
|
+
const lessons = [];
|
|
122
|
+
const patterns = [];
|
|
123
|
+
const openThreads = [];
|
|
124
|
+
for (const line of sections.lessons) {
|
|
125
|
+
const b = parseBullet(line, date);
|
|
126
|
+
if (b)
|
|
127
|
+
lessons.push(b);
|
|
128
|
+
}
|
|
129
|
+
for (const line of sections.patterns) {
|
|
130
|
+
const b = parseBullet(line, date);
|
|
131
|
+
if (b)
|
|
132
|
+
patterns.push(b);
|
|
133
|
+
}
|
|
134
|
+
for (const line of sections.openThreads) {
|
|
135
|
+
const b = parseBullet(line, date);
|
|
136
|
+
if (b)
|
|
137
|
+
openThreads.push(b);
|
|
138
|
+
}
|
|
139
|
+
// Tomorrow brief is free prose — join non-empty lines.
|
|
140
|
+
const tomorrowBrief = sections.tomorrowBrief
|
|
141
|
+
.map(l => l.trim())
|
|
142
|
+
.filter(Boolean)
|
|
143
|
+
.join(' ')
|
|
144
|
+
.trim();
|
|
145
|
+
return { date, lessons, patterns, openThreads, tomorrowBrief };
|
|
146
|
+
}
|
|
147
|
+
/** Read and parse a single dream file from disk. */
|
|
148
|
+
function parseDreamFile(filePath) {
|
|
149
|
+
const md = fs.readFileSync(filePath, 'utf8');
|
|
150
|
+
const sourceDate = extractDateFromFilename(filePath) || extractDateFromContent(md);
|
|
151
|
+
const parsed = parseDreamMarkdown(md, sourceDate);
|
|
152
|
+
return { ...parsed, path: filePath };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Load and parse every `YYYY-MM-DD.md` dream file in `<projectRoot>/dreams/`.
|
|
156
|
+
* Returned oldest-first (chronological), so reconciliation can iterate
|
|
157
|
+
* forward in time when reasoning about strengthening / conflicts.
|
|
158
|
+
*
|
|
159
|
+
* Ignores `.last.json` and `.reconciled.md` (handled separately).
|
|
160
|
+
* Returns `[]` if the dreams directory doesn't exist yet.
|
|
161
|
+
*/
|
|
162
|
+
function loadExistingDreams(projectRoot) {
|
|
163
|
+
const dir = path.join(projectRoot, 'dreams');
|
|
164
|
+
let entries;
|
|
165
|
+
try {
|
|
166
|
+
entries = fs.readdirSync(dir);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
const dreamFiles = entries
|
|
172
|
+
.filter(name => /^\d{4}-\d{2}-\d{2}\.md$/.test(name))
|
|
173
|
+
.sort(); // lexical sort works for ISO dates
|
|
174
|
+
return dreamFiles.map(name => parseDreamFile(path.join(dir, name)));
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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'../providers/types.js';
|
|
2
|
+
import type { ParsedDream } from './parser.js';
|
|
3
|
+
/**
|
|
4
|
+
* Dream reconciliation — the "sleep-time compute" layer.
|
|
5
|
+
*
|
|
6
|
+
* Takes all parsed dreams (from parser.ts's `loadExistingDreams`) and
|
|
7
|
+
* produces a RECONCILED VIEW: a single `.reconciled.md` file containing
|
|
8
|
+
* the agent's current best understanding, with annotations showing where
|
|
9
|
+
* each belief came from and how it evolved.
|
|
10
|
+
*
|
|
11
|
+
* Six verdicts:
|
|
12
|
+
* KEEP — unique claim, no conflict, retained as-is.
|
|
13
|
+
* STRENGTHEN — same claim appeared across multiple dreams. Confidence up.
|
|
14
|
+
* MERGE — two related-but-distinct claims combined into one.
|
|
15
|
+
* SUPERSEDE — newer claim replaces an older one.
|
|
16
|
+
* CONFLICT — two claims contradict each other. Both surfaced, not resolved.
|
|
17
|
+
* DROP — exact duplicate or obsolete. Removed from the projection.
|
|
18
|
+
*
|
|
19
|
+
* Confidence is MECHANICAL, not model-generated:
|
|
20
|
+
* confidence = (number of source dreams contributing to this bullet) / totalDreams
|
|
21
|
+
* This makes the number defensible. A model-generated "0.72" is theater;
|
|
22
|
+
* "appears in 8 of 14 dreams → 0.57" is data.
|
|
23
|
+
*
|
|
24
|
+
* Output: `dreams/.reconciled.md` — a projection, not a replacement.
|
|
25
|
+
* Old dream files stay untouched (append-only audit trail).
|
|
26
|
+
*
|
|
27
|
+
* The reconciliation log is also appended to today's dream file as a
|
|
28
|
+
* `## Reconciliation` section for traceability.
|
|
29
|
+
*/
|
|
30
|
+
export type VerdictAction = 'KEEP' | 'STRENGTHEN' | 'MERGE' | 'SUPERSEDE' | 'CONFLICT' | 'DROP';
|
|
31
|
+
export interface ReconciledBullet {
|
|
32
|
+
section: 'lessons' | 'patterns' | 'openThreads';
|
|
33
|
+
tag?: string;
|
|
34
|
+
text: string;
|
|
35
|
+
action: VerdictAction;
|
|
36
|
+
/** Human-readable lineage, e.g. "from 2026-06-24, strengthened 2026-06-26" */
|
|
37
|
+
annotation: string;
|
|
38
|
+
sourceDates: string[];
|
|
39
|
+
/** Mechanical: sourceDates.length / totalDreams. */
|
|
40
|
+
confidence: number;
|
|
41
|
+
/** For CONFLICT: the opposing claim and its date. */
|
|
42
|
+
conflictsWith?: {
|
|
43
|
+
text: string;
|
|
44
|
+
date: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface ReconciliationResult {
|
|
48
|
+
bullets: ReconciledBullet[];
|
|
49
|
+
totalDreams: number;
|
|
50
|
+
/** Markdown string written to .reconciled.md (also returned for appending to dream file). */
|
|
51
|
+
reconciledMd: string;
|
|
52
|
+
/** Compact log appended to today's dream file. */
|
|
53
|
+
logSection: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Run memory reconciliation across all existing dreams.
|
|
57
|
+
*
|
|
58
|
+
* Called by `runDream()` after the new dream is written, gated at ≥3 dreams.
|
|
59
|
+
* If this fails, the dream file is still intact — reconciliation is
|
|
60
|
+
* enhancement, not critical path.
|
|
61
|
+
*
|
|
62
|
+
* @returns The result, or null if reconciliation was skipped or failed.
|
|
63
|
+
*/
|
|
64
|
+
export declare function reconcileDreams(opts: {
|
|
65
|
+
projectRoot: string;
|
|
66
|
+
provider: LLMProvider;
|
|
67
|
+
/** Pre-loaded dreams (avoids re-reading disk). */
|
|
68
|
+
dreams: ParsedDream[];
|
|
69
|
+
}): Promise<ReconciliationResult | null>;
|