akbo-cli 1.9.4 → 2.0.0

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/dist/cli.js CHANGED
@@ -4,6 +4,7 @@ import { Command } from 'commander';
4
4
  import chalk from 'chalk';
5
5
  import path from 'node:path';
6
6
  import fs from 'node:fs';
7
+ import vm from 'node:vm';
7
8
  import { Harvester } from './harvester.js';
8
9
  import { IndexSynthesizer } from './indexer.js';
9
10
  import { UnitSynthesizer } from './unit_synthesizer.js';
@@ -17,6 +18,8 @@ import { SchemaGenerator, KNOWLEDGE_UNIT_JSON_SCHEMA, MASTER_INDEX_JSON_SCHEMA }
17
18
  import { InitService } from './init_service.js';
18
19
  import { CodebaseWatcher } from './watcher.js';
19
20
  import { SkillImporter } from './importers/skill_importer.js';
21
+ import { DreamEngine } from './dream_engine.js';
22
+ import { GuardService } from './guard_service.js';
20
23
  import { KnowledgePoolResolver } from './pool_resolver.js';
21
24
  import { CatalogStore, parseUnitsFromText } from './catalog_store.js';
22
25
  import { VERSION } from './version.js';
@@ -34,7 +37,7 @@ function findRepoRoot(startDir) {
34
37
  const program = new Command();
35
38
  program
36
39
  .name('akbo')
37
- .description('AI Knowledge Base Oracle & Operator (AKBO) - Invariant Harvester, Synthesizer & GraphRAG Engine')
40
+ .description('AI Knowledge Base Oracle & Operator (AKBO) - Deterministic AST Harvester, Memory Consolidation (Dreaming), CKG Engine & Runtime Guardrails')
38
41
  .version(VERSION, '-v, --version')
39
42
  .option('-V', 'output the version number', () => {
40
43
  console.log(VERSION);
@@ -63,21 +66,45 @@ Enterprise Staged Pipeline:
63
66
  $ akbo generate [dir] [-d <domain>] [--clean] [--cli]
64
67
  Synthesizes atomic YAML knowledge units with strict rule/do/dont directives, prioritizing
65
68
  recently authored code via Git commit recency and preserving 'authority.level: human_curated' units.
66
- Emits AI agent pre-execution hooks: AGENTS.md, GEMINI.md, CLAUDE.md, .cursorrules, and MCP configs.
69
+ Emits AI agent pre-execution hooks: AGENTS.md, GEMINI.md, CLAUDE.md, llms.txt, llms-full.txt, .cursorrules, and MCP configs.
67
70
 
68
71
  Stage 5: Schema & Federation Validator
69
72
  $ akbo validate [dir] [-j, --json]
70
73
  Verifies that all knowledge units strictly conform to runtime Zod schemas and cross-references.
71
74
 
72
- Stage 6: Model Context Protocol (MCP) Server
75
+ Stage 6: Model Context Protocol (MCP 2.0) Server
73
76
  $ akbo mcp [dir] [--pool <path>]
74
77
  $ akbo-mcp [dir]
75
78
  $ npx -y akbo-cli mcp
76
- Launches native MCP server over STDIO exposing akbo_search, akbo_impact, akbo_context,
79
+ Launches native MCP server over STDIO exposing 18 high-performance tools (akbo_search, akbo_impact, akbo_context,
77
80
  akbo_query, akbo_harvest, akbo_validate, akbo_graph, akbo_list_invariants, akbo_upsert_unit,
78
- akbo_upsert_units, akbo_get_unit, akbo_delete_unit, and akbo_import_skills tools alongside akbo://knowledge/index resource for
81
+ akbo_upsert_units, akbo_get_unit, akbo_delete_unit, akbo_import_skills, akbo_filter,
82
+ akbo_record_observation, akbo_scratchpad, akbo_dream, and akbo_guard) alongside akbo://knowledge/index resource for
79
83
  Google Antigravity, Gemini CLI, Claude Code, Cursor, Windsurf, Copilot, and Codex.
80
84
 
85
+ Agent Memory Consolidation & Ephemeral Workspaces ("Dreaming"):
86
+ 1. Offline Memory Consolidation ("Dreaming"):
87
+ $ akbo dream [dir] [--since <hours>] [--stage-only] [--agy] [--cli] [-j]
88
+ (Asynchronously reviews session transcripts and observations to synthesize durable ADRs and patch rules)
89
+
90
+ 2. Runtime Pre-Tool Invariant Guardrails:
91
+ $ akbo guard <file> -c "<code-content>" [-j]
92
+ (Pre-tool execution rail evaluating proposed changes against active 'dont' rules and deprecated patterns)
93
+
94
+ 3. Git Pre-Commit & CI Invariant Verification Gate:
95
+ $ akbo check . --staged [-j]
96
+ (Deterministic gate checking git staged diffs against repository invariants before PR merges)
97
+
98
+ 4. In-Memory Graph Projection & Query Filtering (0 Tokens):
99
+ $ akbo filter nodes . -p "n.type === 'endpoint' && n.domain === 'billing'" --fields id,label,file
100
+ $ akbo filter invariants . -p "inv.domain === 'architecture'" -j
101
+ (Executes sandboxed JS predicates against CKG without bloating context windows)
102
+
103
+ 5. Multi-Agent Ephemeral Scratchpads & Observations:
104
+ $ akbo observe . -t <topic> -f <finding> [--fix <fix>] [--agent <id>]
105
+ $ akbo scratchpad . --agent <id> [--set <text>] [--append <text>]
106
+ (Dedicated per-agent session storage preventing multi-agent write collisions)
107
+
81
108
  External Knowledge Pool (Zero-Touch Monorepo Isolation):
82
109
  Separate scanned code (targetDir) from knowledge and cache storage (poolDir):
83
110
  $ akbo harvest . --pool C:/AKBO/EnterprisePool
@@ -116,7 +143,7 @@ GraphRAG & Live Architecture Pre-Execution Engine:
116
143
 
117
144
  Developer Tooling & Curated Skill Ingestion:
118
145
  $ akbo schema . # Emits schemas/knowledge-unit.json & schemas/index-schema.json and configures .vscode/settings.json
119
- $ akbo init-hooks . # Bootstraps AGENTS.md, GEMINI.md, CLAUDE.md, .cursorrules, .cursor/mcp.json, .vscode/mcp.json
146
+ $ akbo init-hooks . # Bootstraps AGENTS.md, GEMINI.md, CLAUDE.md, llms.txt, llms-full.txt, .cursorrules, .cursor/mcp.json, .vscode/mcp.json
120
147
  $ akbo import-skills . # Ingests .agents/skills/**/SKILL.md as First-Class Skill Pointers (skill_file, reference_files, workflow_gates)
121
148
  (Configure .akb/standards.yaml to enforce modern target patterns and prohibit deprecated anti-patterns)
122
149
 
@@ -1523,6 +1550,344 @@ Examples:
1523
1550
  console.log(chalk.green(` ✔ Configured IDE settings: ${result.settingsPath}`));
1524
1551
  console.log(chalk.cyan('\nVS Code and Cursor will now provide real-time hover documentation and autocomplete for knowledge/**/*.yaml!\n'));
1525
1552
  });
1553
+ program
1554
+ .command('filter')
1555
+ .description('Filter and project CKG nodes, edges, or invariants via in-memory JavaScript expression')
1556
+ .argument('<target>', 'Target dataset to filter: nodes, edges, or invariants')
1557
+ .argument('[dir]', 'Directory of the codebase', '.')
1558
+ .option('-p, --predicate <expr>', 'JavaScript predicate expression, e.g. "n.type === \'endpoint\'"')
1559
+ .option('--fields <fields>', 'Comma-separated properties to project, e.g. "id,label,file"')
1560
+ .option('--limit <n>', 'Maximum matches to return (default: 50)', '50')
1561
+ .option('--pool <path>', 'External knowledge base and cache pool directory')
1562
+ .option('-j, --json', 'Output results in machine-readable JSON format')
1563
+ .action(async (target, dir, options) => {
1564
+ const targetDir = path.resolve(dir);
1565
+ const poolDir = options.pool || program.opts().pool;
1566
+ const poolConfig = KnowledgePoolResolver.resolve(targetDir, { explicitPoolDir: poolDir });
1567
+ const targetType = target.toLowerCase();
1568
+ if (!['nodes', 'edges', 'invariants'].includes(targetType)) {
1569
+ console.error(chalk.red(`Error: Target must be one of "nodes", "edges", or "invariants". Got "${target}".`));
1570
+ process.exit(1);
1571
+ }
1572
+ let dataset = [];
1573
+ if (targetType === 'invariants') {
1574
+ const graphBuilder = new GraphBuilder(targetDir, poolConfig.poolDir);
1575
+ dataset = graphBuilder.loadKnowledgeUnits();
1576
+ }
1577
+ else {
1578
+ const harvester = new Harvester(targetDir, undefined, poolConfig.poolDir);
1579
+ const skeleton = await harvester.harvest({ useCache: true });
1580
+ const graphBuilder = new GraphBuilder(targetDir, poolConfig.poolDir);
1581
+ const graph = await graphBuilder.buildGraph(skeleton, undefined, { useCache: true });
1582
+ dataset = targetType === 'nodes' ? graph.nodes : graph.edges;
1583
+ }
1584
+ const predicate = (options.predicate || 'true').trim();
1585
+ const limit = Math.max(1, parseInt(options.limit || '50', 10));
1586
+ const fields = options.fields ? options.fields.split(',').map((s) => s.trim()) : undefined;
1587
+ const fnCode = predicate.startsWith('(') || predicate.startsWith('function')
1588
+ ? `(${predicate})`
1589
+ : `(function(item) { var n = item, e = item, inv = item; return Boolean(${predicate}); })`;
1590
+ let filterFn;
1591
+ try {
1592
+ const sandbox = Object.create(null);
1593
+ const script = new vm.Script(fnCode);
1594
+ filterFn = script.runInNewContext(sandbox, { timeout: 200 });
1595
+ }
1596
+ catch (err) {
1597
+ console.error(chalk.red(`Error in predicate expression: ${err.message}`));
1598
+ process.exit(1);
1599
+ }
1600
+ const matches = [];
1601
+ let totalMatched = 0;
1602
+ for (const item of dataset) {
1603
+ let matched = false;
1604
+ try {
1605
+ matched = Boolean(filterFn(item));
1606
+ }
1607
+ catch {
1608
+ matched = false;
1609
+ }
1610
+ if (matched) {
1611
+ totalMatched++;
1612
+ if (matches.length < limit) {
1613
+ if (fields && fields.length > 0) {
1614
+ const projected = {};
1615
+ for (const f of fields) {
1616
+ if (item[f] !== undefined)
1617
+ projected[f] = item[f];
1618
+ }
1619
+ matches.push(projected);
1620
+ }
1621
+ else {
1622
+ matches.push(item);
1623
+ }
1624
+ }
1625
+ }
1626
+ }
1627
+ const payload = {
1628
+ target: targetType,
1629
+ totalDatasetSize: dataset.length,
1630
+ totalMatched,
1631
+ returnedCount: matches.length,
1632
+ truncated: totalMatched > matches.length,
1633
+ results: matches
1634
+ };
1635
+ if (options.json) {
1636
+ console.log(JSON.stringify(payload, null, 2));
1637
+ return;
1638
+ }
1639
+ console.log(chalk.blue.bold(`\n🔍 CKG In-Memory Filter [Target: ${targetType}]`));
1640
+ console.log(chalk.gray(`Dataset: ${dataset.length} items | Matched: ${totalMatched} | Returning: ${matches.length}\n`));
1641
+ for (const m of matches) {
1642
+ console.log(`- ${JSON.stringify(m)}`);
1643
+ }
1644
+ if (payload.truncated) {
1645
+ console.log(chalk.yellow(`\n(Results truncated at limit of ${limit}. Pass --limit to retrieve more)`));
1646
+ }
1647
+ console.log();
1648
+ });
1649
+ program
1650
+ .command('scratchpad')
1651
+ .description('Read, set, or append to an isolated multi-agent session scratchpad')
1652
+ .argument('[dir]', 'Directory of the codebase', '.')
1653
+ .option('--agent <id>', 'Agent or role identifier (default: "default")', 'default')
1654
+ .option('--set <text>', 'Set or replace scratchpad content')
1655
+ .option('--append <text>', 'Append notes to scratchpad')
1656
+ .option('--pool <path>', 'External knowledge base and cache pool directory')
1657
+ .option('-j, --json', 'Output results in machine-readable JSON format')
1658
+ .action((dir, options) => {
1659
+ const targetDir = path.resolve(dir);
1660
+ const poolDir = options.pool || program.opts().pool;
1661
+ const agentId = options.agent || 'default';
1662
+ if (options.set !== undefined) {
1663
+ const updated = CatalogStore.updateScratchpad({
1664
+ targetDir,
1665
+ poolDir,
1666
+ agentId,
1667
+ content: options.set,
1668
+ append: false
1669
+ });
1670
+ if (options.json) {
1671
+ console.log(JSON.stringify({ agentId, action: 'set', length: updated.length }, null, 2));
1672
+ }
1673
+ else {
1674
+ console.log(chalk.green(`✔ Scratchpad overwritten for agent "${agentId}" (${updated.length} chars).`));
1675
+ }
1676
+ return;
1677
+ }
1678
+ if (options.append !== undefined) {
1679
+ const updated = CatalogStore.updateScratchpad({
1680
+ targetDir,
1681
+ poolDir,
1682
+ agentId,
1683
+ content: options.append,
1684
+ append: true
1685
+ });
1686
+ if (options.json) {
1687
+ console.log(JSON.stringify({ agentId, action: 'append', length: updated.length }, null, 2));
1688
+ }
1689
+ else {
1690
+ console.log(chalk.green(`✔ Appended notes to scratchpad for agent "${agentId}".`));
1691
+ }
1692
+ return;
1693
+ }
1694
+ const content = CatalogStore.getScratchpad({ targetDir, poolDir, agentId });
1695
+ if (options.json) {
1696
+ console.log(JSON.stringify({ agentId, content }, null, 2));
1697
+ }
1698
+ else {
1699
+ console.log(chalk.blue.bold(`\n📝 Scratchpad for Agent: ${agentId}`));
1700
+ console.log(content ? content : chalk.gray('(Scratchpad is empty)\n'));
1701
+ }
1702
+ });
1703
+ program
1704
+ .command('observe')
1705
+ .description('Record an ephemeral runtime observation or convention discovered during a task')
1706
+ .argument('[dir]', 'Directory of the codebase', '.')
1707
+ .requiredOption('-t, --topic <topic>', 'Target subsystem, file, endpoint, or library')
1708
+ .requiredOption('-f, --finding <finding>', 'The discovered insight, trap, or bug workaround')
1709
+ .option('--fix <fix>', 'Actionable do/dont solution or pattern')
1710
+ .option('--files <files>', 'Comma-separated associated file paths')
1711
+ .option('--agent <id>', 'Agent or role identifier (default: "default")', 'default')
1712
+ .option('--pool <path>', 'External knowledge base and cache pool directory')
1713
+ .option('-j, --json', 'Output in machine-readable JSON format')
1714
+ .action((dir, options) => {
1715
+ const targetDir = path.resolve(dir);
1716
+ const poolDir = options.pool || program.opts().pool;
1717
+ const files = options.files ? options.files.split(',').map((s) => s.trim()) : [];
1718
+ const obs = CatalogStore.recordObservation({
1719
+ targetDir,
1720
+ poolDir,
1721
+ agentId: options.agent || 'default',
1722
+ topic: options.topic,
1723
+ finding: options.finding,
1724
+ reproducible_fix: options.fix,
1725
+ associated_files: files
1726
+ });
1727
+ if (options.json) {
1728
+ console.log(JSON.stringify(obs, null, 2));
1729
+ }
1730
+ else {
1731
+ console.log(chalk.green(`✔ Observation recorded [ID: ${obs.id}] in session "${obs.agentId}".`));
1732
+ console.log(chalk.gray(` Topic: ${obs.topic}`));
1733
+ console.log(chalk.gray(` Finding: ${obs.finding}`));
1734
+ }
1735
+ });
1736
+ program
1737
+ .command('dream')
1738
+ .description('Run out-of-band memory consolidation ("Dreaming") to synthesize durable invariants from session observations and logs')
1739
+ .argument('[dir]', 'Directory of the codebase', '.')
1740
+ .option('--since <hours>', 'Only consolidate observations recorded within the last N hours', parseFloat)
1741
+ .option('--stage-only', 'Stage proposed knowledge units into .akb/staged/ without directly modifying knowledge/index.yaml')
1742
+ .option('--no-auto-approve', 'Do not automatically approve and upsert synthesized units; stage them instead')
1743
+ .option('--provider <provider>', 'LLM provider for distillation (gemini, openai, anthropic, deepseek, groq, ollama, agy, cli)')
1744
+ .option('--api-key <key>', 'Explicit API key for distillation provider')
1745
+ .option('--model <model>', 'Explicit LLM model name for distillation')
1746
+ .option('--cli', 'Use local Gemini CLI for distillation')
1747
+ .option('--agy', 'Use Google Antigravity agy CLI for distillation')
1748
+ .option('--pool <path>', 'External knowledge base and cache pool directory')
1749
+ .option('-j, --json', 'Output consolidation report in machine-readable JSON format')
1750
+ .action(async (dir, options) => {
1751
+ const targetDir = path.resolve(dir);
1752
+ const poolDir = options.pool || program.opts().pool;
1753
+ if (!options.json) {
1754
+ console.log(chalk.blue.bold('\n🌙 AKBO Memory Consolidation Engine ("Dreaming")'));
1755
+ console.log(chalk.gray(`Target directory: ${targetDir}`));
1756
+ if (poolDir)
1757
+ console.log(chalk.gray(`Knowledge pool: ${poolDir}`));
1758
+ console.log(chalk.cyan('Ingesting session observations, error logs, and trial-and-error patterns...\n'));
1759
+ }
1760
+ const dreamEngine = new DreamEngine(targetDir, poolDir);
1761
+ const result = await dreamEngine.dream({
1762
+ targetDir,
1763
+ poolDir,
1764
+ sinceHours: options.since,
1765
+ stageOnly: options.stageOnly || options.autoApprove === false,
1766
+ autoApprove: options.autoApprove !== false,
1767
+ provider: options.provider,
1768
+ apiKey: options.apiKey,
1769
+ model: options.model,
1770
+ cli: options.cli,
1771
+ agy: options.agy
1772
+ });
1773
+ if (options.json) {
1774
+ console.log(JSON.stringify(result, null, 2));
1775
+ return;
1776
+ }
1777
+ console.log(chalk.bold(`Observations Processed: ${result.observationsProcessed}`));
1778
+ if (result.unitsCreated.length > 0) {
1779
+ console.log(chalk.green(`✔ Synthesized New Knowledge Units (${result.unitsCreated.length}):`));
1780
+ for (const u of result.unitsCreated) {
1781
+ console.log(chalk.green(` - ${u}`));
1782
+ }
1783
+ }
1784
+ if (result.unitsUpdated.length > 0) {
1785
+ console.log(chalk.green(`✔ Updated Existing Knowledge Units (${result.unitsUpdated.length}):`));
1786
+ for (const u of result.unitsUpdated) {
1787
+ console.log(chalk.green(` - ${u}`));
1788
+ }
1789
+ }
1790
+ if (result.proposalsStaged.length > 0) {
1791
+ console.log(chalk.yellow(`✎ Staged Proposals for Review (${result.proposalsStaged.length}):`));
1792
+ for (const p of result.proposalsStaged) {
1793
+ console.log(chalk.yellow(` - ${p}`));
1794
+ }
1795
+ }
1796
+ if (result.unitsCreated.length === 0 && result.unitsUpdated.length === 0 && result.proposalsStaged.length === 0) {
1797
+ console.log(chalk.gray('No new conventions or recurring failure patterns required consolidation.'));
1798
+ }
1799
+ if (result.errors.length > 0) {
1800
+ for (const err of result.errors) {
1801
+ console.log(chalk.yellow(` ⚠ ${err}`));
1802
+ }
1803
+ }
1804
+ console.log();
1805
+ });
1806
+ program
1807
+ .command('guard')
1808
+ .description('Evaluate proposed code changes against active invariants and standards as a pre-tool hook')
1809
+ .argument('<file>', 'Target file path being created or modified')
1810
+ .argument('[dir]', 'Directory of the codebase', '.')
1811
+ .option('-c, --content <text>', 'Proposed code content or diff string')
1812
+ .option('--file-content <path>', 'File containing the proposed code content')
1813
+ .option('--pool <path>', 'External knowledge base and cache pool directory')
1814
+ .option('-j, --json', 'Output evaluation in machine-readable JSON format')
1815
+ .action((file, dir, options) => {
1816
+ const targetDir = path.resolve(dir);
1817
+ const poolDir = options.pool || program.opts().pool;
1818
+ let content = options.content || '';
1819
+ if (!content && options.fileContent && fs.existsSync(options.fileContent)) {
1820
+ content = fs.readFileSync(options.fileContent, 'utf-8');
1821
+ }
1822
+ if (!content && fs.existsSync(path.resolve(targetDir, file))) {
1823
+ content = fs.readFileSync(path.resolve(targetDir, file), 'utf-8');
1824
+ }
1825
+ const guardService = new GuardService(targetDir, poolDir);
1826
+ const result = guardService.evaluate(file, content);
1827
+ if (options.json) {
1828
+ console.log(JSON.stringify(result, null, 2));
1829
+ if (!result.allowed)
1830
+ process.exit(1);
1831
+ return;
1832
+ }
1833
+ if (result.allowed) {
1834
+ console.log(chalk.green.bold(`\n✔ Action Allowed: "${file}" complies with all applicable architectural invariants.`));
1835
+ if (result.warnings.length > 0) {
1836
+ for (const w of result.warnings) {
1837
+ console.log(chalk.yellow(` ⚠ ${w}`));
1838
+ }
1839
+ }
1840
+ console.log();
1841
+ }
1842
+ else {
1843
+ console.error(chalk.red.bold(`\n🛑 Action Blocked: "${file}" violates ${result.violations.length} architectural invariant(s):`));
1844
+ for (const v of result.violations) {
1845
+ console.error(chalk.red(` ✖ [${v.invariantId}] ${v.title}`));
1846
+ console.error(chalk.gray(` Forbidden: "${v.forbiddenPattern}"`));
1847
+ console.error(chalk.gray(` Reason: ${v.reason}`));
1848
+ }
1849
+ console.log();
1850
+ process.exit(1);
1851
+ }
1852
+ });
1853
+ program
1854
+ .command('check')
1855
+ .description('Verify that git staged changes adhere strictly to active invariants (Git Pre-Commit / CI Gate)')
1856
+ .argument('[dir]', 'Directory of the codebase', '.')
1857
+ .option('--staged', 'Check all git staged files (default: true)', true)
1858
+ .option('--pool <path>', 'External knowledge base and cache pool directory')
1859
+ .option('-j, --json', 'Output verification report in machine-readable JSON format')
1860
+ .action((dir, options) => {
1861
+ const targetDir = path.resolve(dir);
1862
+ const poolDir = options.pool || program.opts().pool;
1863
+ const guardService = new GuardService(targetDir, poolDir);
1864
+ const report = guardService.checkStaged();
1865
+ if (options.json) {
1866
+ console.log(JSON.stringify(report, null, 2));
1867
+ if (!report.success)
1868
+ process.exit(1);
1869
+ return;
1870
+ }
1871
+ if (report.filesChecked === 0) {
1872
+ console.log(chalk.gray('\nNo staged git files detected for architectural verification.\n'));
1873
+ return;
1874
+ }
1875
+ if (report.success) {
1876
+ console.log(chalk.green.bold(`\n✔ Pre-Commit Gate Passed: All ${report.filesChecked} staged file(s) comply with repository invariants.\n`));
1877
+ }
1878
+ else {
1879
+ console.error(chalk.red.bold(`\n🛑 Pre-Commit Gate Failed: Invariant violations found in staged files:\n`));
1880
+ for (const [file, viols] of Object.entries(report.violations)) {
1881
+ console.error(chalk.red(`File: ${file}`));
1882
+ for (const v of viols) {
1883
+ console.error(chalk.red(` ✖ [${v.invariantId}] ${v.title} (${v.forbiddenPattern})`));
1884
+ console.error(chalk.gray(` ${v.reason}`));
1885
+ }
1886
+ }
1887
+ console.log();
1888
+ process.exit(1);
1889
+ }
1890
+ });
1526
1891
  program
1527
1892
  .command('version')
1528
1893
  .description('Display detailed version and environment information')
@@ -0,0 +1,61 @@
1
+ export interface DreamOptions {
2
+ targetDir: string;
3
+ poolDir?: string;
4
+ sinceHours?: number;
5
+ stageOnly?: boolean;
6
+ autoApprove?: boolean;
7
+ provider?: string;
8
+ apiKey?: string;
9
+ model?: string;
10
+ cli?: boolean;
11
+ agy?: boolean;
12
+ transcriptFiles?: string[];
13
+ }
14
+ export interface DreamResult {
15
+ observationsProcessed: number;
16
+ unitsCreated: string[];
17
+ unitsUpdated: string[];
18
+ proposalsStaged: string[];
19
+ errors: string[];
20
+ }
21
+ export interface SynthesizedDreamPayload {
22
+ newUnits?: Array<{
23
+ id: string;
24
+ domain: string;
25
+ type?: string;
26
+ title: string;
27
+ rule?: string;
28
+ decision?: string;
29
+ do?: string[];
30
+ dont?: string[];
31
+ reason?: string;
32
+ applies_to?: string[];
33
+ }>;
34
+ unitUpdates?: Array<{
35
+ targetUnitId: string;
36
+ appendDo?: string[];
37
+ appendDont?: string[];
38
+ reason?: string;
39
+ }>;
40
+ }
41
+ export declare class DreamEngine {
42
+ private targetDir;
43
+ private poolDir?;
44
+ constructor(targetDir?: string, poolDir?: string);
45
+ /**
46
+ * Consolidates recorded observations and error traces out-of-band into durable knowledge units or staged proposals.
47
+ */
48
+ dream(options: DreamOptions): Promise<DreamResult>;
49
+ /**
50
+ * Distills observations using an LLM provider.
51
+ */
52
+ private distillWithLLM;
53
+ /**
54
+ * Deterministically distills observations without LLM tokens.
55
+ */
56
+ private distillDeterministic;
57
+ /**
58
+ * Updates observation files in .akb/sessions/ marking processed observation IDs as consolidated.
59
+ */
60
+ private markObservationsConsolidated;
61
+ }