@mrace07/kairo 0.1.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 +141 -0
- package/dist/application/coding-agent.d.ts +85 -0
- package/dist/application/coding-agent.js +765 -0
- package/dist/application/context-manager.d.ts +22 -0
- package/dist/application/context-manager.js +174 -0
- package/dist/application/context-selector.d.ts +11 -0
- package/dist/application/context-selector.js +74 -0
- package/dist/application/evaluated-agent.d.ts +7 -0
- package/dist/application/evaluated-agent.js +16 -0
- package/dist/application/evaluation-comparison.d.ts +34 -0
- package/dist/application/evaluation-comparison.js +91 -0
- package/dist/application/evaluation-harness.d.ts +19 -0
- package/dist/application/evaluation-harness.js +217 -0
- package/dist/application/failure-analyzer.d.ts +5 -0
- package/dist/application/failure-analyzer.js +37 -0
- package/dist/application/interaction-routing.d.ts +9 -0
- package/dist/application/interaction-routing.js +20 -0
- package/dist/application/live-evaluation.d.ts +8 -0
- package/dist/application/live-evaluation.js +185 -0
- package/dist/application/model-routing.d.ts +12 -0
- package/dist/application/model-routing.js +40 -0
- package/dist/application/model-system-instruction.d.ts +4 -0
- package/dist/application/model-system-instruction.js +4 -0
- package/dist/application/self-evaluation.d.ts +26 -0
- package/dist/application/self-evaluation.js +394 -0
- package/dist/application/task-metrics.d.ts +31 -0
- package/dist/application/task-metrics.js +42 -0
- package/dist/application/verification-planner.d.ts +12 -0
- package/dist/application/verification-planner.js +97 -0
- package/dist/domain/models.d.ts +247 -0
- package/dist/domain/models.js +1 -0
- package/dist/domain/ports.d.ts +87 -0
- package/dist/domain/ports.js +1 -0
- package/dist/domain/provider-error.d.ts +18 -0
- package/dist/domain/provider-error.js +17 -0
- package/dist/infrastructure/configuration/config.d.ts +24 -0
- package/dist/infrastructure/configuration/config.js +79 -0
- package/dist/infrastructure/filesystem/platform-paths.d.ts +8 -0
- package/dist/infrastructure/filesystem/platform-paths.js +18 -0
- package/dist/infrastructure/persistence/sqlite-session-store.d.ts +82 -0
- package/dist/infrastructure/persistence/sqlite-session-store.js +447 -0
- package/dist/infrastructure/providers/gemini-provider.d.ts +14 -0
- package/dist/infrastructure/providers/gemini-provider.js +90 -0
- package/dist/infrastructure/providers/groq-provider.d.ts +16 -0
- package/dist/infrastructure/providers/groq-provider.js +101 -0
- package/dist/infrastructure/providers/jev-safety-advisor.d.ts +18 -0
- package/dist/infrastructure/providers/jev-safety-advisor.js +95 -0
- package/dist/infrastructure/providers/mistral-provider.d.ts +15 -0
- package/dist/infrastructure/providers/mistral-provider.js +137 -0
- package/dist/infrastructure/providers/openrouter-provider.d.ts +15 -0
- package/dist/infrastructure/providers/openrouter-provider.js +104 -0
- package/dist/infrastructure/providers/provider-recovery.d.ts +10 -0
- package/dist/infrastructure/providers/provider-recovery.js +108 -0
- package/dist/infrastructure/providers/provider-registry.d.ts +22 -0
- package/dist/infrastructure/providers/provider-registry.js +67 -0
- package/dist/infrastructure/repository/repository-awareness.d.ts +12 -0
- package/dist/infrastructure/repository/repository-awareness.js +25 -0
- package/dist/infrastructure/repository/repository-profiler.d.ts +35 -0
- package/dist/infrastructure/repository/repository-profiler.js +498 -0
- package/dist/infrastructure/security/macos-keychain-store.d.ts +17 -0
- package/dist/infrastructure/security/macos-keychain-store.js +73 -0
- package/dist/infrastructure/tools/workspace-tools.d.ts +30 -0
- package/dist/infrastructure/tools/workspace-tools.js +321 -0
- package/dist/interface/cli/evaluation-comparison-report.d.ts +6 -0
- package/dist/interface/cli/evaluation-comparison-report.js +46 -0
- package/dist/interface/cli/evaluation-report.d.ts +14 -0
- package/dist/interface/cli/evaluation-report.js +122 -0
- package/dist/interface/cli/index.d.ts +2 -0
- package/dist/interface/cli/index.js +238 -0
- package/dist/interface/cli/provider-setup.d.ts +16 -0
- package/dist/interface/cli/provider-setup.js +86 -0
- package/dist/interface/cli/repl.d.ts +7 -0
- package/dist/interface/cli/repl.js +19 -0
- package/dist/interface/cli/task-trace.d.ts +7 -0
- package/dist/interface/cli/task-trace.js +48 -0
- package/dist/interface/cli/tui.d.ts +147 -0
- package/dist/interface/cli/tui.js +910 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Kairo
|
|
2
|
+
<img width="1159" height="677" alt="Screenshot 2026-09-21 at 12 02 14 PM" src="https://github.com/user-attachments/assets/85024d79-f167-4f9d-a80a-3c2fccb74bba" />
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Kairo is a terminal coding agent for a local repository. It understands the codebase, plans or implements a change, asks before doing anything mutating, and verifies the result.
|
|
6
|
+
|
|
7
|
+
The focus is reliability, not agent theatre. Kairo keeps one bounded loop, safe workspace tools, resumable sessions, useful traces, and honest verification state.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
- Runs in a full-screen Ink TUI with streaming responses, a task timeline, slash-command palette, and approval cards.
|
|
12
|
+
- Builds a language-neutral repository snapshot, enriches JavaScript/TypeScript structure, ranks relevant files, and keeps model context bounded.
|
|
13
|
+
- Reads and searches freely inside the workspace. Edits, writes, and arbitrary shell commands require approval.
|
|
14
|
+
- Recommends focused checks after changes and can make bounded repair attempts when verification fails.
|
|
15
|
+
- Saves resumable sessions, plans, checkpoints, and metadata-only task traces.
|
|
16
|
+
- Supports Gemini, Groq, and Mistral coding models, with manual or optional Jev-powered routing.
|
|
17
|
+
- Includes deterministic and live evaluations for measuring the agent loop over time.
|
|
18
|
+
|
|
19
|
+
## Jev and automatic routing
|
|
20
|
+
|
|
21
|
+
[Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) is Kairo’s optional decision and safety layer. It is **not** a coding model and does not generate source code. Gemini, Groq, or Mistral still perform the actual repository work.
|
|
22
|
+
|
|
23
|
+
Open `/jev` in the TUI to add a TypeSafe API key and control four independent features:
|
|
24
|
+
|
|
25
|
+
- **Task routing** distinguishes conversation, direct answers, repository work, and requests that should become a read-only plan.
|
|
26
|
+
- **Safety context** assesses proposed operations while Kairo’s local approval and workspace rules remain authoritative.
|
|
27
|
+
- **Recovery advice** helps choose whether a failed check needs a focused repair, broader context, or escalation.
|
|
28
|
+
- **Safe autonomy** may skip a prompt only for a high-confidence, low-risk verification command that Kairo already discovered from the repository. It never grants autonomous file writes or arbitrary shell access.
|
|
29
|
+
|
|
30
|
+
`/auto` separately toggles automatic model selection. When enabled, Jev classifies each BUILD request as `fast`, `balanced`, or `strong`, then Kairo chooses from models whose credentials are available locally. Decisions below the `0.85` confidence threshold, unavailable tiers, or Jev errors fall back to your manually selected model. Quota failures can fall through to another available model.
|
|
31
|
+
|
|
32
|
+
Auto routing is opt-in. `/models` always puts you back in manual mode, and an explicit PLAN request is never silently upgraded into implementation. The footer only shows `AUTO` or `JEV` when those features are enabled.
|
|
33
|
+
|
|
34
|
+
## Repository awareness
|
|
35
|
+
|
|
36
|
+
Kairo starts with a deterministic, language-neutral snapshot instead of assuming every project is JavaScript or TypeScript. In a Git repository it inventories tracked and untracked, non-ignored files with `git ls-files`. Outside Git it uses a bounded recursive walk. Symlinked directories, dependencies, generated output, binary content, and workspace escapes are excluded from content inspection.
|
|
37
|
+
|
|
38
|
+
The snapshot records derived metadata for up to 20,000 files:
|
|
39
|
+
|
|
40
|
+
- file paths, size, modification time, and role such as source, test, manifest, CI, build, documentation, configuration, or agent instruction;
|
|
41
|
+
- detected ecosystems from manifests for Node, Python, Go, Rust, JVM, Ruby, PHP, Elixir, and .NET repositories;
|
|
42
|
+
- Git root, branch, HEAD, and changed paths when available;
|
|
43
|
+
- common source/test roots and existing JavaScript/TypeScript symbols, imports, and test relationships;
|
|
44
|
+
- Node verification commands discovered from `package.json`, with the manifest and package-manager lockfile recorded as evidence.
|
|
45
|
+
|
|
46
|
+
Kairo recognizes root and nested `AGENTS.md` and `CLAUDE.md` files, `.github/copilot-instructions.md`, and `.cursor/rules/**`. Applicable instruction text is read only for the current model request: root rules are always considered, while nested rules are included only for selected files under their directory. Each file is capped at 16 KiB and the complete instruction budget is 32 KiB.
|
|
47
|
+
|
|
48
|
+
Snapshots are versioned and fingerprinted. Kairo checks freshness when a session starts or resumes and before each model turn after tool activity. Branch, HEAD, working-tree, inventory, or high-signal control-file changes rebuild stale metadata automatically. Old repository profiles are treated as stale and rebuilt once.
|
|
49
|
+
|
|
50
|
+
Only derived metadata is persisted in SQLite. Source text, instruction contents, README contents, diffs, and command output are not stored in the snapshot. Manifests, CI files, build files, and documentation are surfaced as paths so the agent can inspect the relevant evidence on demand.
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
You’ll need Node.js 24.21+ and an API key for a supported coding-model provider.
|
|
55
|
+
|
|
56
|
+
Install Kairo globally from npm:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install --global @mrace07/kairo
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm install
|
|
64
|
+
pnpm build
|
|
65
|
+
node dist/interface/cli/index.js .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Start Kairo in any repository with:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
kairo [workspace]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The first-run flow can validate and store provider credentials in the macOS Keychain. Environment variables also work for one-off use:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
GEMINI_API_KEY=your_key_here kairo .
|
|
78
|
+
GROQ_API_KEY=your_key_here kairo .
|
|
79
|
+
MISTRAL_API_KEY=your_key_here kairo .
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## TUI workflow
|
|
83
|
+
|
|
84
|
+
Type a request normally, or type `/` to open the command palette. Arrow keys move through matches; Tab completes commands that need arguments and runs commands that do not.
|
|
85
|
+
|
|
86
|
+
- `/plan` toggles read-only planning. `/build` implements the latest saved plan.
|
|
87
|
+
- `/models` chooses a coding model and disables Auto. `/auto` toggles Jev-powered automatic routing.
|
|
88
|
+
- `/jev` manages the Jev credential, routing, safety, recovery, and autonomy features.
|
|
89
|
+
- `/new`, `/resume [session-id]`, and `/history` manage saved sessions.
|
|
90
|
+
- `/status`, `/trace [task-id]`, and `/changes` explain what happened.
|
|
91
|
+
- `/verify <command>` runs an explicit check through the approval gate; `/compact` saves a context checkpoint.
|
|
92
|
+
- `/cancel`, `/logout`, `/help`, and `/quit` handle the remaining session controls.
|
|
93
|
+
|
|
94
|
+
Press `y` or Enter to approve an action; press `n` or Escape to deny it. Use `Ctrl+O` to expand or collapse the task activity timeline.
|
|
95
|
+
|
|
96
|
+
Every successful edit invalidates older verification. A task that changed files is not complete until its latest eligible check passes.
|
|
97
|
+
|
|
98
|
+
## CLI essentials
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Credentials
|
|
102
|
+
kairo auth login [gemini|groq|mistral]
|
|
103
|
+
kairo auth logout [gemini|groq|mistral]
|
|
104
|
+
kairo auth status
|
|
105
|
+
|
|
106
|
+
# Saved sessions
|
|
107
|
+
kairo sessions list
|
|
108
|
+
kairo resume <session-id>
|
|
109
|
+
|
|
110
|
+
# Agent-loop evaluations
|
|
111
|
+
kairo eval
|
|
112
|
+
kairo eval jev
|
|
113
|
+
kairo eval live
|
|
114
|
+
kairo eval self --trials 3
|
|
115
|
+
kairo eval history
|
|
116
|
+
kairo eval show <run-id>
|
|
117
|
+
kairo eval baseline set <run-id>
|
|
118
|
+
kairo eval baseline show
|
|
119
|
+
kairo eval compare <run-id>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`kairo eval` checks deterministic plumbing. `eval jev` uses a local stub to exercise Jev integration; it is not a live latency or quality benchmark. `eval self` is the real-provider capability suite: it creates isolated Kairo snapshots, seeds defects, requires a verified result, and runs independent hidden graders.
|
|
123
|
+
|
|
124
|
+
Evaluation history and task traces are sanitized. They store IDs, operation names, timing, outcomes, counters, and verification metadata—not prompts, model responses, source contents, credentials, or raw command output.
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pnpm check
|
|
130
|
+
pnpm test
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The code is split into `domain`, `application`, `infrastructure`, and `interface/cli`. The core loop is bounded, workspace-confined, approval-gated, and designed so a successful command is evidence—not automatic proof that the task is correct.
|
|
134
|
+
|
|
135
|
+
## Direction
|
|
136
|
+
|
|
137
|
+
1. Keep the single-agent loop dependable: safer tools, better repair, stronger verification, and useful traces.
|
|
138
|
+
2. Add evidence-backed Python, Go, Rust, JVM, and other verification adapters without guessing commands from prose.
|
|
139
|
+
3. Add a lightweight repository graph, then Tree-sitter enrichment and on-demand LSP queries where deterministic retrieval needs stronger semantics.
|
|
140
|
+
4. Expand realistic broken-repository evaluations and measure reliability, cost, and latency before considering embeddings or a graph database.
|
|
141
|
+
5. Add local providers and better evidence-based routing without weakening manual control.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RepositoryAwareness } from "../infrastructure/repository/repository-awareness.js";
|
|
2
|
+
import type { Task, ModelSelection } from "../domain/models.js";
|
|
3
|
+
import type { ApprovalPolicy, ModelProvider, TaskStore, ToolDefinition, ToolExecutor, JevSafetyAdvisor, JevFeatures } from "../domain/ports.js";
|
|
4
|
+
export declare class CodingAgent {
|
|
5
|
+
private readonly provider;
|
|
6
|
+
private readonly store;
|
|
7
|
+
private readonly tools;
|
|
8
|
+
private readonly approval;
|
|
9
|
+
private readonly toolDefinitions;
|
|
10
|
+
private readonly modelSelection?;
|
|
11
|
+
private readonly jev?;
|
|
12
|
+
private readonly jevFeatures;
|
|
13
|
+
private readonly repositoryAwareness?;
|
|
14
|
+
private readonly context;
|
|
15
|
+
private readonly failureAnalyzer;
|
|
16
|
+
private readonly verificationPlanner;
|
|
17
|
+
/** Creates the coordinator with its model, durable state, tools, and approval boundary. */
|
|
18
|
+
constructor(provider: ModelProvider, store: TaskStore, tools: ToolExecutor, approval: ApprovalPolicy, toolDefinitions: ToolDefinition[], modelSelection?: ModelSelection | undefined, jev?: JevSafetyAdvisor | undefined, jevFeatures?: JevFeatures, repositoryAwareness?: RepositoryAwareness | undefined);
|
|
19
|
+
/** Starts a new persisted task and drives it until it completes, pauses, or fails. */
|
|
20
|
+
run(sessionId: string, input: string, onText: (text: string) => void): Promise<void>;
|
|
21
|
+
/** Inspects a workspace and saves a structured plan without allowing any mutation. */
|
|
22
|
+
plan(sessionId: string, input: string, onText: (text: string) => void): Promise<void>;
|
|
23
|
+
/** Answers without creating a task, loading repository context, or allowing tools. */
|
|
24
|
+
answer(sessionId: string, input: string, onText: (text: string) => void): Promise<void>;
|
|
25
|
+
/** Continues the failed task with a replacement provider after a quota exhaustion. */
|
|
26
|
+
retryAfterProviderQuota(sessionId: string, onText: (text: string) => void): Promise<void>;
|
|
27
|
+
/** Restarts the latest unfinished task using its saved conversation and repair history. */
|
|
28
|
+
resume(sessionId: string, onText: (text: string) => void): Promise<void>;
|
|
29
|
+
/** Returns the newest task state for a session without changing it. */
|
|
30
|
+
status(sessionId: string): Task | undefined;
|
|
31
|
+
/** Marks the active task as cancelled so later model turns cannot continue it. */
|
|
32
|
+
cancel(sessionId: string): Task | undefined;
|
|
33
|
+
/** Saves a compact checkpoint for the current task's long conversation. */
|
|
34
|
+
compact(sessionId: string): string | undefined;
|
|
35
|
+
/** Runs a user-requested verification command through the normal approval gate. */
|
|
36
|
+
verify(sessionId: string, command: string, onText: (text: string) => void): Promise<void>;
|
|
37
|
+
/** Executes bounded model and tool turns for one task. */
|
|
38
|
+
private executeTask;
|
|
39
|
+
/** Completes only tasks whose changed files have a successful verification result. */
|
|
40
|
+
private finish;
|
|
41
|
+
/** Records a terminal task failure and makes the reason visible in the REPL. */
|
|
42
|
+
private fail;
|
|
43
|
+
/** Appends a durable conversation message for later context reconstruction. */
|
|
44
|
+
private save;
|
|
45
|
+
/** Applies approval, executes one tool call, and persists its observable outcome. */
|
|
46
|
+
private executeTool;
|
|
47
|
+
/** Keeps planning tasks read-only and accepts their final artifact without a workspace call. */
|
|
48
|
+
private executePlanningTool;
|
|
49
|
+
/** Validates persisted plan data rather than trusting provider-produced tool arguments. */
|
|
50
|
+
private validatePlan;
|
|
51
|
+
/** Records model latency even when streaming fails; partial operations remain visible after restart. */
|
|
52
|
+
private modelTurn;
|
|
53
|
+
/** Gives planning its own strict contract while preserving the existing implementation prompt. */
|
|
54
|
+
private instruction;
|
|
55
|
+
/** Attaches identity and wall-clock time without retaining prompts or tool arguments. */
|
|
56
|
+
private event;
|
|
57
|
+
/** Executes a tool after user approval, except for the deliberately narrow Jev trust envelope. */
|
|
58
|
+
private executeApprovedTool;
|
|
59
|
+
/** Returns a normalized relative path only for scoped file writes inside the active workspace. */
|
|
60
|
+
private normalizedWritePath;
|
|
61
|
+
/** Checks a persisted, user-granted path scope without extending it to commands or other files. */
|
|
62
|
+
private taskScopedWritePath;
|
|
63
|
+
/** Auto-authorizes only known verification after a high-confidence low-risk Jev assessment. */
|
|
64
|
+
private autonomouslyApprovedVerification;
|
|
65
|
+
/** Adds an advisory Jev label while preserving user approval outside the trust envelope. */
|
|
66
|
+
private approvalDescription;
|
|
67
|
+
/** Requests a typed risk assessment once; uncertain and failed assessments fall back safely. */
|
|
68
|
+
private jevAssessment;
|
|
69
|
+
/** Records only decision metadata; low-confidence and failed decisions never change agent behavior. */
|
|
70
|
+
private jevDecision;
|
|
71
|
+
/** Builds bounded operation metadata without sending source, output, or secret-bearing edit content. */
|
|
72
|
+
private jevState;
|
|
73
|
+
private jevTaskState;
|
|
74
|
+
/** Supplies failure metadata only; provider output and source snippets remain local. */
|
|
75
|
+
private jevRecoveryState;
|
|
76
|
+
private recordRepair;
|
|
77
|
+
/** Persists a tool call that could not reach the executor, such as a denied request. */
|
|
78
|
+
private record;
|
|
79
|
+
/** Identifies commands suggested by the workspace's discovered verification scripts. */
|
|
80
|
+
private isDiscoveredVerification;
|
|
81
|
+
/** Recommends and runs one post-edit check through the ordinary approval gate. */
|
|
82
|
+
private runRecommendedVerification;
|
|
83
|
+
/** Stores selection metadata in the trace without command arguments or output. */
|
|
84
|
+
private recordVerificationSelection;
|
|
85
|
+
}
|