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.
- package/README.md +47 -164
- package/dist/agent/affect.d.ts +13 -0
- package/dist/agent/affect.js +34 -0
- package/dist/agent/affect.js.map +1 -0
- package/dist/agent/compactor.d.ts +27 -4
- package/dist/agent/compactor.js +185 -54
- package/dist/agent/compactor.js.map +1 -1
- package/dist/agent/confess.d.ts +35 -0
- package/dist/agent/confess.js +296 -0
- package/dist/agent/confess.js.map +1 -0
- package/dist/agent/domain-expertise.d.ts +22 -0
- package/dist/agent/domain-expertise.js +110 -0
- package/dist/agent/domain-expertise.js.map +1 -0
- package/dist/agent/executive-queue.d.ts +26 -0
- package/dist/agent/executive-queue.js +50 -0
- package/dist/agent/executive-queue.js.map +1 -0
- package/dist/agent/generational-flush.d.ts +28 -0
- package/dist/agent/generational-flush.js +48 -0
- package/dist/agent/generational-flush.js.map +1 -0
- package/dist/agent/loop-profile.d.ts +50 -0
- package/dist/agent/loop-profile.js +88 -0
- package/dist/agent/loop-profile.js.map +1 -0
- package/dist/agent/loop.d.ts +14 -5
- package/dist/agent/loop.js +167 -23
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/memory-consolidate.d.ts +14 -0
- package/dist/agent/memory-consolidate.js +141 -0
- package/dist/agent/memory-consolidate.js.map +1 -0
- package/dist/agent/mixture.d.ts +33 -0
- package/dist/agent/mixture.js +138 -0
- package/dist/agent/mixture.js.map +1 -0
- package/dist/agent/spawner.js +2 -2
- package/dist/agent/spawner.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +1 -1
- package/dist/agent/system-prompt.js +49 -13
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/unified-memory.d.ts +15 -0
- package/dist/agent/unified-memory.js +164 -0
- package/dist/agent/unified-memory.js.map +1 -0
- package/dist/checkpoints/engine.d.ts +44 -0
- package/dist/checkpoints/engine.js +324 -0
- package/dist/checkpoints/engine.js.map +1 -0
- package/dist/cli/command-palette.d.ts +26 -0
- package/dist/cli/command-palette.js +133 -0
- package/dist/cli/command-palette.js.map +1 -0
- package/dist/cli/context-health.d.ts +51 -0
- package/dist/cli/context-health.js +187 -0
- package/dist/cli/context-health.js.map +1 -0
- package/dist/cli/diamond.d.ts +67 -0
- package/dist/cli/diamond.js +222 -12
- package/dist/cli/diamond.js.map +1 -1
- package/dist/cli/dic.d.ts +2 -0
- package/dist/cli/dic.js +106 -0
- package/dist/cli/dic.js.map +1 -0
- package/dist/cli/diff-view.d.ts +18 -0
- package/dist/cli/diff-view.js +114 -0
- package/dist/cli/diff-view.js.map +1 -0
- package/dist/cli/display.d.ts +18 -4
- package/dist/cli/display.js +74 -146
- package/dist/cli/display.js.map +1 -1
- package/dist/cli/help-data.d.ts +7 -0
- package/dist/cli/help-data.js +80 -0
- package/dist/cli/help-data.js.map +1 -0
- package/dist/cli/index.js +1001 -788
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/markdown.d.ts +5 -0
- package/dist/cli/markdown.js +128 -0
- package/dist/cli/markdown.js.map +1 -0
- package/dist/cli/model-select.d.ts +39 -0
- package/dist/cli/model-select.js +65 -0
- package/dist/cli/model-select.js.map +1 -0
- package/dist/cli/tui.d.ts +34 -0
- package/dist/cli/tui.js +1176 -0
- package/dist/cli/tui.js.map +1 -0
- package/dist/config/defaults.d.ts +6 -17
- package/dist/config/defaults.js +25 -39
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/project-config.d.ts +2 -6
- package/dist/config/project-config.js +2 -2
- package/dist/config/project-config.js.map +1 -1
- package/dist/doctor/checks.d.ts +18 -0
- package/dist/doctor/checks.js +524 -0
- package/dist/doctor/checks.js.map +1 -0
- package/dist/doctor/index.d.ts +4 -0
- package/dist/doctor/index.js +229 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/doctor/repair.d.ts +19 -0
- package/dist/doctor/repair.js +126 -0
- package/dist/doctor/repair.js.map +1 -0
- package/dist/doctor/types.d.ts +38 -0
- package/dist/doctor/types.js +10 -0
- package/dist/doctor/types.js.map +1 -0
- package/dist/dream/dream.d.ts +79 -36
- package/dist/dream/dream.js +327 -117
- package/dist/dream/dream.js.map +1 -1
- package/dist/dream/episode.d.ts +17 -0
- package/dist/dream/episode.js +116 -0
- package/dist/dream/episode.js.map +1 -0
- 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/kanban/engine.d.ts +26 -0
- package/dist/kanban/engine.js +208 -0
- package/dist/kanban/engine.js.map +1 -0
- package/dist/kanban/types.d.ts +19 -0
- package/dist/kanban/types.js +9 -1
- package/dist/kanban/types.js.map +1 -1
- 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 +191 -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 +99 -0
- package/dist/machina/render-terminal.js.map +1 -0
- package/dist/machina/repair.d.ts +23 -0
- package/dist/machina/repair.js +98 -0
- package/dist/machina/repair.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 +39 -0
- package/dist/machina/verify.js +95 -0
- package/dist/machina/verify.js.map +1 -0
- package/dist/mining/extract.d.ts +34 -0
- package/dist/mining/extract.js +229 -0
- package/dist/mining/extract.js.map +1 -0
- package/dist/mining/refine.d.ts +28 -0
- package/dist/mining/refine.js +256 -0
- package/dist/mining/refine.js.map +1 -0
- package/dist/perception/extractor.js +5 -3
- package/dist/perception/extractor.js.map +1 -1
- package/dist/perception/graph-store.d.ts +0 -11
- package/dist/perception/graph-store.js +0 -33
- package/dist/perception/graph-store.js.map +1 -1
- package/dist/perception/index.d.ts +1 -1
- package/dist/perception/index.js +1 -2
- package/dist/perception/index.js.map +1 -1
- package/dist/plugins/commands.d.ts +38 -0
- package/dist/plugins/commands.js +134 -0
- package/dist/plugins/commands.js.map +1 -0
- package/dist/plugins/frontmatter.d.ts +14 -0
- package/dist/plugins/frontmatter.js +78 -0
- package/dist/plugins/frontmatter.js.map +1 -0
- package/dist/plugins/hooks.d.ts +12 -0
- package/dist/plugins/hooks.js +148 -0
- package/dist/plugins/hooks.js.map +1 -0
- package/dist/plugins/loader.d.ts +7 -0
- package/dist/plugins/loader.js +255 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/market.d.ts +23 -0
- package/dist/plugins/market.js +281 -0
- package/dist/plugins/market.js.map +1 -0
- package/dist/plugins/types.d.ts +90 -0
- package/dist/plugins/types.js +20 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/providers/anthropic-oauth-draft.d.ts +119 -0
- package/dist/providers/anthropic-oauth-draft.js +414 -0
- package/dist/providers/anthropic-oauth-draft.js.map +1 -0
- package/dist/providers/anthropic.d.ts +4 -1
- package/dist/providers/anthropic.js +34 -6
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/factory.d.ts +71 -14
- package/dist/providers/factory.js +205 -124
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/google.js +8 -21
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/live-models.d.ts +23 -0
- package/dist/providers/live-models.js +145 -0
- package/dist/providers/live-models.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +1 -12
- package/dist/providers/openai-compatible.js +71 -108
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/providers/resilient-factory.js +1 -1
- package/dist/providers/resilient-factory.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/repl/queue.d.ts +22 -0
- package/dist/repl/queue.js +165 -0
- package/dist/repl/queue.js.map +1 -0
- package/dist/repl/side-channel.d.ts +23 -0
- package/dist/repl/side-channel.js +63 -0
- package/dist/repl/side-channel.js.map +1 -0
- package/dist/research/council.d.ts +5 -2
- package/dist/research/council.js +73 -10
- package/dist/research/council.js.map +1 -1
- package/dist/ruby/alternator.d.ts +11 -30
- package/dist/ruby/alternator.js +59 -38
- package/dist/ruby/alternator.js.map +1 -1
- package/dist/ruby/episode-capture.d.ts +0 -10
- package/dist/ruby/episode-capture.js +0 -33
- package/dist/ruby/episode-capture.js.map +1 -1
- package/dist/ruby/types.js +1 -1
- package/dist/ruby/types.js.map +1 -1
- package/dist/safety/path-jail.d.ts +17 -0
- package/dist/safety/path-jail.js +100 -0
- package/dist/safety/path-jail.js.map +1 -0
- package/dist/safety/permissions.d.ts +12 -21
- package/dist/safety/permissions.js +81 -216
- package/dist/safety/permissions.js.map +1 -1
- package/dist/safety/ssrf.d.ts +29 -0
- package/dist/safety/ssrf.js +185 -0
- package/dist/safety/ssrf.js.map +1 -0
- package/dist/server/index.js +64 -10
- package/dist/server/index.js.map +1 -1
- package/dist/setup/first-run.d.ts +0 -24
- package/dist/setup/first-run.js +10 -344
- package/dist/setup/first-run.js.map +1 -1
- package/dist/setup/key-store.d.ts +12 -0
- package/dist/setup/key-store.js +108 -0
- package/dist/setup/key-store.js.map +1 -0
- package/dist/setup/provider-registry.js +31 -18
- package/dist/setup/provider-registry.js.map +1 -1
- package/dist/setup/provider-test.d.ts +7 -0
- package/dist/setup/provider-test.js +73 -10
- package/dist/setup/provider-test.js.map +1 -1
- package/dist/setup/provider-wizard.d.ts +4 -1
- package/dist/setup/provider-wizard.js +92 -26
- package/dist/setup/provider-wizard.js.map +1 -1
- package/dist/setup/xiaomi.d.ts +1 -1
- package/dist/setup/xiaomi.js +3 -3
- package/dist/setup/xiaomi.js.map +1 -1
- package/dist/tools/browser.js +6 -4
- package/dist/tools/browser.js.map +1 -1
- package/dist/tools/clipboard.js +7 -1
- package/dist/tools/clipboard.js.map +1 -1
- package/dist/tools/dictate.d.ts +60 -0
- package/dist/tools/dictate.js +983 -0
- package/dist/tools/dictate.js.map +1 -0
- package/dist/tools/dictate_patched.js +1057 -0
- package/dist/tools/edit-file.js +10 -2
- package/dist/tools/edit-file.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/http-request.js +14 -4
- package/dist/tools/http-request.js.map +1 -1
- package/dist/tools/image-read.js +34 -2
- package/dist/tools/image-read.js.map +1 -1
- package/dist/tools/index.d.ts +16 -1
- package/dist/tools/index.js +59 -8
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcp.js +12 -0
- package/dist/tools/mcp.js.map +1 -1
- package/dist/tools/read-file.js +10 -14
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/telegram-audio-policy.d.ts +30 -0
- package/dist/tools/telegram-audio-policy.js +49 -0
- package/dist/tools/telegram-audio-policy.js.map +1 -0
- package/dist/tools/telegram-bot.js +1136 -539
- package/dist/tools/telegram-bot.js.map +1 -1
- package/dist/tools/telegram-voice.d.ts +18 -5
- package/dist/tools/telegram-voice.js +54 -12
- package/dist/tools/telegram-voice.js.map +1 -1
- package/dist/tools/telegram.d.ts +3 -3
- package/dist/tools/telegram.js +5 -84
- package/dist/tools/telegram.js.map +1 -1
- package/dist/tools/tools.d.ts +2 -14
- package/dist/tools/tools.js +79 -144
- package/dist/tools/tools.js.map +1 -1
- package/dist/tools/web-fetch.js +39 -7
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.js +2 -3
- package/dist/tools/web-search.js.map +1 -1
- package/dist/util/errors.js +1 -15
- package/dist/util/errors.js.map +1 -1
- package/dist/util/json-repair.d.ts +11 -0
- package/dist/util/json-repair.js +31 -0
- package/dist/util/json-repair.js.map +1 -0
- package/dist/util/rate-limiter.js +2 -8
- package/dist/util/rate-limiter.js.map +1 -1
- package/dist/viz/index.js +793 -792
- package/dist/viz/index.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 +13 -32
|
@@ -0,0 +1,116 @@
|
|
|
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.recordEpisode = recordEpisode;
|
|
37
|
+
exports.listEpisodes = listEpisodes;
|
|
38
|
+
exports.listEpisodesSince = listEpisodesSince;
|
|
39
|
+
exports.listAllEpisodes = listAllEpisodes;
|
|
40
|
+
/**
|
|
41
|
+
* Episode — layer 1 of the memory loop (see MEMORY.md).
|
|
42
|
+
* Auto-recorded, zero LLM calls. Atomic .tmp+rename write, namespaced
|
|
43
|
+
* per project by a hash of its root path.
|
|
44
|
+
*/
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const os = __importStar(require("os"));
|
|
48
|
+
const crypto = __importStar(require("crypto"));
|
|
49
|
+
function projectHash(root) {
|
|
50
|
+
return crypto.createHash('sha256').update(path.resolve(root)).digest('hex').slice(0, 12);
|
|
51
|
+
}
|
|
52
|
+
function episodesDir(root) {
|
|
53
|
+
return path.join(os.homedir(), '.aura', 'episodes', projectHash(root));
|
|
54
|
+
}
|
|
55
|
+
/** Record one episode. Best-effort — never throws into the caller's task flow. */
|
|
56
|
+
function recordEpisode(root, ep) {
|
|
57
|
+
try {
|
|
58
|
+
const dir = episodesDir(root);
|
|
59
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
60
|
+
const id = `${Date.now()}-${crypto.randomBytes(4).toString('hex')}`;
|
|
61
|
+
const full = { id, timestamp: Date.now(), ...ep };
|
|
62
|
+
const finalPath = path.join(dir, `${id}.json`);
|
|
63
|
+
const tmpPath = `${finalPath}.tmp`;
|
|
64
|
+
fs.writeFileSync(tmpPath, JSON.stringify(full, null, 2));
|
|
65
|
+
fs.renameSync(tmpPath, finalPath);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Episodic memory is best-effort — never let it break a task.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** All episodes for a project, oldest first. */
|
|
72
|
+
function listEpisodes(root) {
|
|
73
|
+
const dir = episodesDir(root);
|
|
74
|
+
if (!fs.existsSync(dir))
|
|
75
|
+
return [];
|
|
76
|
+
const files = fs.readdirSync(dir).filter(f => f.endsWith('.json'));
|
|
77
|
+
const episodes = [];
|
|
78
|
+
for (const f of files) {
|
|
79
|
+
try {
|
|
80
|
+
episodes.push(JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8')));
|
|
81
|
+
}
|
|
82
|
+
catch { /* skip corrupt entries */ }
|
|
83
|
+
}
|
|
84
|
+
return episodes.sort((a, b) => a.timestamp - b.timestamp);
|
|
85
|
+
}
|
|
86
|
+
/** Episodes newer than a given timestamp (used for "since last dream"). */
|
|
87
|
+
function listEpisodesSince(root, sinceMs) {
|
|
88
|
+
return listEpisodes(root).filter(e => e.timestamp > sinceMs);
|
|
89
|
+
}
|
|
90
|
+
/** All episodes across EVERY project (used for the global lessons digest). */
|
|
91
|
+
function listAllEpisodes() {
|
|
92
|
+
const base = path.join(os.homedir(), '.aura', 'episodes');
|
|
93
|
+
if (!fs.existsSync(base))
|
|
94
|
+
return [];
|
|
95
|
+
const episodes = [];
|
|
96
|
+
for (const proj of fs.readdirSync(base)) {
|
|
97
|
+
const dir = path.join(base, proj);
|
|
98
|
+
let files;
|
|
99
|
+
try {
|
|
100
|
+
if (!fs.statSync(dir).isDirectory())
|
|
101
|
+
continue;
|
|
102
|
+
files = fs.readdirSync(dir).filter(f => f.endsWith('.json'));
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
for (const f of files) {
|
|
108
|
+
try {
|
|
109
|
+
episodes.push(JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8')));
|
|
110
|
+
}
|
|
111
|
+
catch { /* skip corrupt entries */ }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return episodes.sort((a, b) => a.timestamp - b.timestamp);
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=episode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"episode.js","sourceRoot":"","sources":["../../src/dream/episode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,sCAaC;AAGD,oCAWC;AAGD,8CAEC;AAGD,0CAkBC;AAlFD;;;;GAIG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,+CAAiC;AAYjC,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,kFAAkF;AAClF,SAAgB,aAAa,CAAC,IAAY,EAAE,EAAqC;IAC/E,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,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AC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;YACxE,CAAC;YAAC,MAAM,CAAC,CAAC,0BAA0B,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReconciledBullet } from './reconcile.js';
|
|
2
|
+
/**
|
|
3
|
+
* Write an OKF v0.1 knowledge bundle from reconciled bullets.
|
|
4
|
+
*
|
|
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,SA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C,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;QACzF,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC;IAED,mBAAmB;IACnB,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,cAAc,CAAC,eAAe,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IAC9E,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;IAE/D,eAAe;IACf,MAAM,GAAG,GAAG,QAAQ,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
|