@kernel.chat/kbot 3.36.0 → 3.38.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/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  npm install -g @kernel.chat/kbot
20
20
  ```
21
21
 
22
- **Self-defending AI agent. 350+ tools. 26 agents. 20 providers. Forges new tools at runtime. Built-in cybersecurity suite. $0 local AI. MIT licensed.**
22
+ **Self-defending AI agent. 384+ tools. 41 agents. 20 providers. Forges new tools at runtime. Built-in cybersecurity suite. $0 local AI. MIT licensed.**
23
23
 
24
24
  > **New: [The Kernel Stack](./KERNEL_STACK.md)** — the architecture behind kbot + Claude Code. Agentic, self-improving, compound AI. Read the manifesto.
25
25
 
@@ -27,6 +27,18 @@ npm install -g @kernel.chat/kbot
27
27
 
28
28
  ## What's New
29
29
 
30
+ ### v3.37 — Dream Mode, Meta-Agent, Claude Code Plugin, Voice Mode
31
+
32
+ | Feature | What it means |
33
+ |---------|---------------|
34
+ | **Dream Mode** | `kbot dream` — offline consolidation. kbot reviews recent sessions, extracts patterns, strengthens memory connections, and prunes stale knowledge. Like sleep for an AI agent. |
35
+ | **Meta-Agent** | Self-referential self-improvement inspired by HyperAgents ([arXiv 2603.19461](https://arxiv.org/abs/2603.19461)). A two-agent loop: task agents solve problems, the Meta-Agent watches performance and rewrites task agents to be better. Unlike HyperAgents (CC BY-NC-SA), kbot is MIT — the only self-improving agent framework companies can actually use. Run `kbot meta` to trigger a cycle. |
36
+ | **Claude Code Plugin** | kbot registers its 9 core specialists as Claude Code teammates via the Agent Teams integration. Delegate tasks to `coder`, `researcher`, `guardian`, etc. directly from Claude Code sessions. |
37
+ | **Voice Mode** | `kbot voice` — full voice loop with speech-to-text input and text-to-speech output. Hands-free agentic coding. Works with system TTS and Whisper STT. |
38
+ | **OpenClaw Integration** | [`@kernel.chat/kbot-openclaw`](https://www.npmjs.com/package/@kernel.chat/kbot-openclaw) — kbot as the brain for 50+ messaging channels. Discord, Slack, Telegram, WhatsApp, iMessage, email, and more. One agent, every platform. |
39
+ | **41 agents** | 15 new specialist and domain agents since v3.28, including meta-agent, dream agent, and expanded presets. |
40
+ | **384+ tools** | 34 new tools across finance, creative, build matrix, and meta-cognition categories. |
41
+
30
42
  ### v3.28 — Self-Defense System
31
43
 
32
44
  kbot now protects its own integrity — and yours.
@@ -76,7 +88,7 @@ Other AI agents are static — fixed tools, single providers, no memory, no lear
76
88
  - **20 providers, zero lock-in** — Claude, GPT, Gemini, Grok, DeepSeek, Groq, Mistral, and 13 more. Switch anytime.
77
89
  - **Runs fully offline** — Embedded llama.cpp runs GGUF models directly. No Ollama needed. $0, fully private.
78
90
  - **Learns your patterns** — Bayesian skill ratings + pattern extraction. Gets faster and smarter over time.
79
- - **26 specialist agents** — Say "fix the auth bug" and it routes to `coder`. Say "research JWT tokens" and it routes to `researcher`. Say "analyze BTC" and it routes to `trader`. Auto-routed with probabilistic confidence.
91
+ - **41 specialist agents** — Say "fix the auth bug" and it routes to `coder`. Say "research JWT tokens" and it routes to `researcher`. Say "analyze BTC" and it routes to `trader`. Auto-routed with probabilistic confidence.
80
92
  - **Crash-proof** — Checkpoints after every tool call. Resume interrupted sessions automatically.
81
93
  - **Use as a library** — Clean SDK with typed exports. Build your own tools on top of kbot.
82
94
  - **Works in your IDE** — Built-in MCP server for VS Code, Cursor, Zed, Neovim. ACP for JetBrains.
@@ -165,7 +177,7 @@ for await (const event of agent.stream("explain this code")) {
165
177
  const files = await tools.execute('glob', { pattern: 'src/**/*.ts' })
166
178
  console.log(files.result)
167
179
 
168
- // List all 350+ tools
180
+ // List all 384+ tools
169
181
  console.log(tools.list().map(t => t.name))
170
182
  ```
171
183
 
@@ -179,15 +191,16 @@ import { ResponseStream } from '@kernel.chat/kbot' // Stream
179
191
 
180
192
  ## Specialists
181
193
 
182
- 26 agents, auto-routed by Bayesian skill ratings, or pick one with `kbot --agent <name>`:
194
+ 41 agents, auto-routed by Bayesian skill ratings, or pick one with `kbot --agent <name>`:
183
195
 
184
196
  | | Agents |
185
197
  |---|---|
186
198
  | **Core** | kernel, researcher, coder, writer, analyst |
187
199
  | **Extended** | aesthete, guardian, curator, strategist |
188
200
  | **Domain** | infrastructure, quant, investigator, oracle, chronist, sage, communicator, adapter, trader |
189
- | **System** | immune, forge |
201
+ | **System** | immune, forge, meta-agent, dream, codebase-guardian |
190
202
  | **Presets** | hacker, operator, dreamer, creative, developer, gamedev, playtester |
203
+ | **Claude Code** | kernel, coder, researcher, writer, analyst, guardian, aesthete, curator, strategist (teammate integration) |
191
204
 
192
205
  ```bash
193
206
  kbot --agent researcher "what papers cite Friston's Free Energy Principle?"
@@ -196,7 +209,7 @@ kbot --agent coder "refactor this into smaller functions"
196
209
  kbot --agent trader "analyze BTC momentum and run a paper trade"
197
210
  ```
198
211
 
199
- ## 345+ Tools
212
+ ## 384+ Tools
200
213
 
201
214
  | Category | Examples |
202
215
  |----------|---------|
@@ -436,6 +449,97 @@ kbot's agent loop runs 11 always-on cognition modules based on peer-reviewed res
436
449
 
437
450
  These aren't metaphors. They're TypeScript modules with paper citations in the headers. The interference between modules — not the modules themselves — is where intelligent behavior emerges. See the [research paper](../../docs/cognitive-module-interference.md).
438
451
 
452
+ ## Dream Mode
453
+
454
+ ```bash
455
+ kbot dream
456
+ ```
457
+
458
+ Offline memory consolidation. When you run `kbot dream`, kbot reviews recent sessions, extracts recurring patterns, strengthens high-value memory connections, and prunes stale or contradictory knowledge. Think of it as sleep for an AI agent — the work that makes tomorrow's sessions faster and more accurate.
459
+
460
+ - **Pattern extraction** — identifies recurring tool sequences, user preferences, and project conventions
461
+ - **Memory pruning** — removes outdated facts and conflicting entries
462
+ - **Skill strengthening** — reinforces Bayesian skill ratings based on real outcomes
463
+ - **Knowledge synthesis** — connects isolated learnings into higher-level insights
464
+ - **Runs fully local** — no API calls, no data leaves your machine
465
+
466
+ ## Meta-Agent
467
+
468
+ ```bash
469
+ kbot meta
470
+ ```
471
+
472
+ Self-referential self-improvement. Inspired by Meta's HyperAgents paper ([arXiv 2603.19461](https://arxiv.org/abs/2603.19461)), the Meta-Agent implements a two-agent architecture:
473
+
474
+ 1. **Task agents** solve problems (the 41 specialists you already use)
475
+ 2. **The Meta-Agent** observes their performance, identifies weaknesses, and improves them
476
+
477
+ The improvement loop runs automatically:
478
+ - **Observe** — records success/failure, duration, cost, and tool usage for every task
479
+ - **Analyze** — builds performance profiles per agent, identifies failure patterns
480
+ - **Propose** — generates targeted improvements (prompt rewrites, tool pre-selection, routing changes)
481
+ - **Apply** — auto-applies low-risk improvements (routing, tool selection); flags high-risk ones for review
482
+ - **Measure** — compares before/after performance and reverts regressions
483
+
484
+ Unlike HyperAgents (CC BY-NC-SA, non-commercial license), kbot is MIT — the only self-improving agent framework that companies can actually deploy in production.
485
+
486
+ ```bash
487
+ kbot meta # Run one improvement cycle
488
+ kbot meta stats # View cycle count, observations, active improvements
489
+ kbot meta history # Review all past improvements
490
+ ```
491
+
492
+ ## Claude Code Plugin
493
+
494
+ kbot integrates directly with Claude Code as a teammate provider. Register kbot's specialists so Claude Code can delegate tasks to the right expert:
495
+
496
+ ```typescript
497
+ import { registerTeammates, delegateToTeammate } from '@kernel.chat/kbot'
498
+
499
+ // Get teammate definitions for all 9 core specialists
500
+ const teammates = registerTeammates()
501
+ // → [{ name: 'kernel', model: 'sonnet', ... }, { name: 'coder', ... }, ...]
502
+
503
+ // Delegate a task to a specific specialist
504
+ const result = await delegateToTeammate('guardian', 'audit src/auth.ts for security issues')
505
+ console.log(result.content) // security analysis
506
+ console.log(result.toolCalls) // tools used (dep_audit, secret_scan, etc.)
507
+ ```
508
+
509
+ Each teammate definition includes:
510
+ - **name** — agent identifier (`kernel`, `coder`, `researcher`, `writer`, `analyst`, `guardian`, `aesthete`, `curator`, `strategist`)
511
+ - **model** — `opus` for complex reasoning agents (analyst, strategist, guardian, researcher), `sonnet` for fast agents
512
+ - **initialPrompt** — the specialist's full system prompt
513
+ - **tools** — preferred tool list for the specialist's domain
514
+
515
+ ## Voice Mode
516
+
517
+ ```bash
518
+ kbot voice
519
+ ```
520
+
521
+ Full voice loop — speak your tasks, hear the results. Voice mode chains speech-to-text input with text-to-speech output for hands-free agentic coding:
522
+
523
+ - **STT** — Whisper-based transcription (local or API)
524
+ - **TTS** — System speech synthesis (macOS `say`, Linux `espeak`, or cloud TTS)
525
+ - **Continuous** — voice loop stays open between turns, no re-activation needed
526
+ - **Tool narration** — kbot announces tool calls and results as it works
527
+
528
+ ## OpenClaw Integration
529
+
530
+ ```bash
531
+ npm install @kernel.chat/kbot-openclaw
532
+ ```
533
+
534
+ kbot as the brain for 50+ messaging channels. OpenClaw bridges kbot's agent loop to Discord, Slack, Telegram, WhatsApp, iMessage, email, Matrix, and more — one agent, every platform.
535
+
536
+ - **Channel-agnostic** — same agent logic regardless of input source
537
+ - **Per-channel memory** — separate conversation contexts per channel/user
538
+ - **Rate limiting** — configurable per-platform rate limits
539
+ - **Media handling** — images, files, and voice messages routed through kbot's multimodal pipeline
540
+
541
+ See [`@kernel.chat/kbot-openclaw`](https://www.npmjs.com/package/@kernel.chat/kbot-openclaw) on npm.
542
+
439
543
  ## Security
440
544
 
441
545
  kbot has two layers of security: protecting **your projects** and protecting **itself**.
@@ -514,7 +618,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, adding tools, and
514
618
  </details>
515
619
 
516
620
  <details>
517
- <summary><strong>Agent Routing</strong> — 26 specialists, auto-routed by intent</summary>
621
+ <summary><strong>Agent Routing</strong> — 41 specialists, auto-routed by intent</summary>
518
622
  <img src="../../tools/video-assets/demo-agents.gif" alt="kbot agent routing" width="700">
519
623
  </details>
520
624
 
@@ -0,0 +1,55 @@
1
+ export interface TeammateDefinition {
2
+ /** Agent identifier */
3
+ name: string;
4
+ /** What this specialist focuses on */
5
+ description: string;
6
+ /** Model tier: 'sonnet' for fast agents, 'opus' for complex reasoning */
7
+ model: 'sonnet' | 'opus';
8
+ /** System prompt that defines the specialist's behavior */
9
+ initialPrompt: string;
10
+ /** Preferred tools for this specialist */
11
+ tools: string[];
12
+ }
13
+ export interface DelegationResult {
14
+ /** The response content from the teammate */
15
+ content: string;
16
+ /** Which agent handled the task */
17
+ agent: string;
18
+ /** Model used */
19
+ model: string;
20
+ /** Number of tool calls made */
21
+ toolCalls: number;
22
+ /** Token usage, if available */
23
+ usage?: {
24
+ input_tokens: number;
25
+ output_tokens: number;
26
+ cost_usd: number;
27
+ };
28
+ }
29
+ /**
30
+ * Register kbot specialists as Claude Code teammates.
31
+ *
32
+ * Returns an array of teammate definitions — one for each of kbot's
33
+ * core and extended specialist agents (9 total).
34
+ *
35
+ * @example
36
+ * const teammates = registerTeammates()
37
+ * // teammates[0] = { name: 'kernel', model: 'sonnet', ... }
38
+ */
39
+ export declare function registerTeammates(): TeammateDefinition[];
40
+ /**
41
+ * Delegate a task to a specific kbot teammate by name.
42
+ *
43
+ * Routes the task through kbot's full agent loop (think -> plan -> execute -> learn)
44
+ * using a silent UI adapter so output is captured, not printed.
45
+ *
46
+ * @param name - The teammate/specialist ID (e.g. 'coder', 'researcher')
47
+ * @param task - The task description or prompt to execute
48
+ * @returns The delegation result with content, agent info, and usage stats
49
+ *
50
+ * @example
51
+ * const result = await delegateToTeammate('coder', 'add input validation to auth.ts')
52
+ * console.log(result.content)
53
+ */
54
+ export declare function delegateToTeammate(name: string, task: string): Promise<DelegationResult>;
55
+ //# sourceMappingURL=agent-teams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-teams.d.ts","sourceRoot":"","sources":["../src/agent-teams.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,yEAAyE;IACzE,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAA;IACxB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAA;IACrB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,gCAAgC;IAChC,KAAK,CAAC,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1E;AAgED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,EAAE,CAoBxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CA2B3B"}
@@ -0,0 +1,135 @@
1
+ // kbot Agent Teams — Claude Code Teammate Integration
2
+ //
3
+ // Registers kbot's specialist agents as Claude Code teammates so they
4
+ // can be invoked collaboratively within a Claude Code session.
5
+ //
6
+ // Usage:
7
+ // import { registerTeammates, delegateToTeammate } from './agent-teams.js'
8
+ //
9
+ // const teammates = registerTeammates()
10
+ // const result = await delegateToTeammate('coder', 'refactor auth.ts into smaller functions')
11
+ import { SPECIALISTS } from './agents/specialists.js';
12
+ import { runAgent } from './agent.js';
13
+ import { SilentUIAdapter } from './ui-adapter.js';
14
+ // ── Teammate tool mappings ──────────────────────────────────────────────────
15
+ const TOOL_PREFERENCES = {
16
+ kernel: [
17
+ 'read_file', 'write_file', 'glob', 'grep', 'bash',
18
+ 'web_search', 'memory_save', 'memory_search',
19
+ ],
20
+ coder: [
21
+ 'read_file', 'write_file', 'edit_file', 'glob', 'grep', 'bash',
22
+ 'git_status', 'git_diff', 'git_commit', 'lint', 'test_runner',
23
+ 'type_check', 'format_code',
24
+ ],
25
+ researcher: [
26
+ 'web_search', 'url_fetch', 'read_file', 'grep', 'glob',
27
+ 'arxiv_search', 'semantic_scholar', 'memory_save',
28
+ ],
29
+ writer: [
30
+ 'read_file', 'write_file', 'edit_file', 'glob', 'grep',
31
+ 'web_search', 'url_fetch',
32
+ ],
33
+ analyst: [
34
+ 'read_file', 'glob', 'grep', 'bash', 'web_search',
35
+ 'url_fetch', 'csv_read', 'csv_query',
36
+ ],
37
+ guardian: [
38
+ 'read_file', 'glob', 'grep', 'bash', 'dep_audit',
39
+ 'secret_scan', 'ssl_check', 'headers_check', 'cve_lookup',
40
+ 'port_scan', 'owasp_check',
41
+ ],
42
+ aesthete: [
43
+ 'read_file', 'write_file', 'edit_file', 'glob', 'grep',
44
+ 'bash', 'design_variants',
45
+ ],
46
+ curator: [
47
+ 'read_file', 'write_file', 'edit_file', 'glob', 'grep',
48
+ 'memory_save', 'memory_search', 'web_search',
49
+ ],
50
+ strategist: [
51
+ 'read_file', 'glob', 'grep', 'web_search', 'url_fetch',
52
+ 'bash', 'csv_read', 'csv_query',
53
+ ],
54
+ };
55
+ // Agents that benefit from complex reasoning get opus; others use sonnet for speed
56
+ const OPUS_AGENTS = new Set(['analyst', 'strategist', 'guardian', 'researcher']);
57
+ // ── Teammate descriptions ───────────────────────────────────────────────────
58
+ const DESCRIPTIONS = {
59
+ kernel: 'General-purpose assistant — handles conversation, coordination, and tasks that span multiple domains.',
60
+ coder: 'Programming specialist — writes, reviews, refactors, and debugs production-quality code across all major languages.',
61
+ researcher: 'Research specialist — finds, verifies, and synthesizes information from web, papers, and codebases.',
62
+ writer: 'Content specialist — writes docs, blog posts, changelogs, emails, and social media with appropriate tone and structure.',
63
+ analyst: 'Strategy & evaluation specialist — breaks down complex decisions with data-driven analysis and frameworks.',
64
+ guardian: 'Security specialist — audits code, scans dependencies, checks for vulnerabilities, and hardens systems.',
65
+ aesthete: 'Design specialist — evaluates and creates UI/UX, enforces design systems, and ensures accessibility.',
66
+ curator: 'Knowledge management specialist — organizes documentation, maintains knowledge bases, and fills information gaps.',
67
+ strategist: 'Business strategy specialist — connects technical decisions to business outcomes, builds roadmaps, and analyzes competitors.',
68
+ };
69
+ // ── Core API ────────────────────────────────────────────────────────────────
70
+ /**
71
+ * Register kbot specialists as Claude Code teammates.
72
+ *
73
+ * Returns an array of teammate definitions — one for each of kbot's
74
+ * core and extended specialist agents (9 total).
75
+ *
76
+ * @example
77
+ * const teammates = registerTeammates()
78
+ * // teammates[0] = { name: 'kernel', model: 'sonnet', ... }
79
+ */
80
+ export function registerTeammates() {
81
+ const teammateIds = [
82
+ 'kernel', 'coder', 'researcher', 'writer', 'analyst',
83
+ 'guardian', 'aesthete', 'curator', 'strategist',
84
+ ];
85
+ return teammateIds.map((id) => {
86
+ const specialist = SPECIALISTS[id];
87
+ if (!specialist) {
88
+ throw new Error(`Specialist "${id}" not found in SPECIALISTS registry.`);
89
+ }
90
+ return {
91
+ name: id,
92
+ description: DESCRIPTIONS[id] ?? specialist.name,
93
+ model: OPUS_AGENTS.has(id) ? 'opus' : 'sonnet',
94
+ initialPrompt: specialist.prompt,
95
+ tools: TOOL_PREFERENCES[id] ?? TOOL_PREFERENCES.kernel,
96
+ };
97
+ });
98
+ }
99
+ /**
100
+ * Delegate a task to a specific kbot teammate by name.
101
+ *
102
+ * Routes the task through kbot's full agent loop (think -> plan -> execute -> learn)
103
+ * using a silent UI adapter so output is captured, not printed.
104
+ *
105
+ * @param name - The teammate/specialist ID (e.g. 'coder', 'researcher')
106
+ * @param task - The task description or prompt to execute
107
+ * @returns The delegation result with content, agent info, and usage stats
108
+ *
109
+ * @example
110
+ * const result = await delegateToTeammate('coder', 'add input validation to auth.ts')
111
+ * console.log(result.content)
112
+ */
113
+ export async function delegateToTeammate(name, task) {
114
+ // Validate the teammate exists
115
+ const specialist = SPECIALISTS[name];
116
+ if (!specialist) {
117
+ const available = Object.keys(SPECIALISTS).join(', ');
118
+ throw new Error(`Unknown teammate "${name}". Available: ${available}`);
119
+ }
120
+ const ui = new SilentUIAdapter();
121
+ const options = {
122
+ agent: name,
123
+ stream: false,
124
+ ui,
125
+ };
126
+ const response = await runAgent(task, options);
127
+ return {
128
+ content: response.content ?? ui.content ?? '',
129
+ agent: response.agent ?? name,
130
+ model: response.model ?? '',
131
+ toolCalls: response.toolCalls ?? 0,
132
+ usage: response.usage,
133
+ };
134
+ }
135
+ //# sourceMappingURL=agent-teams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-teams.js","sourceRoot":"","sources":["../src/agent-teams.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,sEAAsE;AACtE,+DAA+D;AAC/D,EAAE;AACF,SAAS;AACT,6EAA6E;AAC7E,EAAE;AACF,0CAA0C;AAC1C,gGAAgG;AAEhG,OAAO,EAAE,WAAW,EAAsB,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAyC,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AA8BjD,+EAA+E;AAE/E,MAAM,gBAAgB,GAA6B;IACjD,MAAM,EAAE;QACN,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;QACjD,YAAY,EAAE,aAAa,EAAE,eAAe;KAC7C;IACD,KAAK,EAAE;QACL,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;QAC9D,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa;QAC7D,YAAY,EAAE,aAAa;KAC5B;IACD,UAAU,EAAE;QACV,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM;QACtD,cAAc,EAAE,kBAAkB,EAAE,aAAa;KAClD;IACD,MAAM,EAAE;QACN,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM;QACtD,YAAY,EAAE,WAAW;KAC1B;IACD,OAAO,EAAE;QACP,WAAW,EAA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EAAU,CAAC,OAAO,IAAI,EAAE;QACtD,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,IAAI;QAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;QAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,CAAC;QAClC,KAAK,EAAE,QAAQ,CAAC,KAAK;KACtB,CAAA;AACH,CAAC"}
@@ -0,0 +1,64 @@
1
+ export type FindingType = 'duplicate-pattern' | 'co-change' | 'complexity';
2
+ export interface GuardianFinding {
3
+ type: FindingType;
4
+ severity: 'info' | 'warn' | 'critical';
5
+ title: string;
6
+ description: string;
7
+ files: string[];
8
+ /** The repeated code snippet (for duplicate-pattern findings) */
9
+ pattern?: string;
10
+ /** Occurrence count (for duplicate-pattern findings) */
11
+ occurrences?: number;
12
+ /** Metric value (for complexity findings — e.g., function length) */
13
+ metric?: number;
14
+ /** Suggested action */
15
+ suggestion: string;
16
+ foundAt: string;
17
+ }
18
+ export interface GuardianReport {
19
+ analyzedAt: string;
20
+ rootDir: string;
21
+ filesScanned: number;
22
+ findings: GuardianFinding[];
23
+ summary: {
24
+ duplicates: number;
25
+ coChanges: number;
26
+ complexityWarnings: number;
27
+ totalFindings: number;
28
+ };
29
+ }
30
+ export interface ForgedGuardianTool {
31
+ name: string;
32
+ description: string;
33
+ finding: GuardianFinding;
34
+ detectPattern: string;
35
+ createdAt: string;
36
+ }
37
+ interface HistoryEntry {
38
+ report: GuardianReport;
39
+ forgedTools: string[];
40
+ }
41
+ /**
42
+ * Run the Codebase Guardian on a directory.
43
+ *
44
+ * Scans for:
45
+ * - Duplicate code patterns (3+ occurrences across files)
46
+ * - Files that always change together (from git history)
47
+ * - Growing complexity (function length, nesting depth)
48
+ *
49
+ * Returns a structured report with all findings.
50
+ */
51
+ export declare function runGuardian(path: string): Promise<GuardianReport>;
52
+ /**
53
+ * When the guardian finds a recurring pattern, forge a tool to detect (and
54
+ * optionally fix) that specific pattern in the future.
55
+ *
56
+ * The forged tool is saved to ~/.kbot/forge/guardian-{name}.json.
57
+ */
58
+ export declare function forgeGuardianTool(finding: GuardianFinding): ForgedGuardianTool;
59
+ /**
60
+ * Get history of guardian reports and forged tools.
61
+ */
62
+ export declare function getGuardianHistory(): HistoryEntry[];
63
+ export {};
64
+ //# sourceMappingURL=codebase-guardian.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebase-guardian.d.ts","sourceRoot":"","sources":["../src/codebase-guardian.ts"],"names":[],"mappings":"AAsBA,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,WAAW,GAAG,YAAY,CAAA;AAE1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAA;IACjB,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,kBAAkB,EAAE,MAAM,CAAA;QAC1B,aAAa,EAAE,MAAM,CAAA;KACtB,CAAA;CACF;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,eAAe,C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