joonecli 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/AGENTS.md +56 -0
- package/Handover.md +115 -0
- package/LICENSE +201 -0
- package/PROGRESS.md +160 -0
- package/README.md +114 -0
- package/dist/__tests__/bootstrap.test.d.ts +1 -0
- package/dist/__tests__/bootstrap.test.js +76 -0
- package/dist/__tests__/bootstrap.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +1 -0
- package/dist/__tests__/config.test.js +84 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/m55.test.d.ts +1 -0
- package/dist/__tests__/m55.test.js +160 -0
- package/dist/__tests__/m55.test.js.map +1 -0
- package/dist/__tests__/middleware.test.d.ts +1 -0
- package/dist/__tests__/middleware.test.js +169 -0
- package/dist/__tests__/middleware.test.js.map +1 -0
- package/dist/__tests__/modelFactory.test.d.ts +1 -0
- package/dist/__tests__/modelFactory.test.js +50 -0
- package/dist/__tests__/modelFactory.test.js.map +1 -0
- package/dist/__tests__/optimizations.test.d.ts +1 -0
- package/dist/__tests__/optimizations.test.js +136 -0
- package/dist/__tests__/optimizations.test.js.map +1 -0
- package/dist/__tests__/promptBuilder.test.d.ts +1 -0
- package/dist/__tests__/promptBuilder.test.js +108 -0
- package/dist/__tests__/promptBuilder.test.js.map +1 -0
- package/dist/__tests__/sandbox.test.d.ts +1 -0
- package/dist/__tests__/sandbox.test.js +78 -0
- package/dist/__tests__/sandbox.test.js.map +1 -0
- package/dist/__tests__/security.test.d.ts +1 -0
- package/dist/__tests__/security.test.js +86 -0
- package/dist/__tests__/security.test.js.map +1 -0
- package/dist/__tests__/streaming.test.d.ts +1 -0
- package/dist/__tests__/streaming.test.js +71 -0
- package/dist/__tests__/streaming.test.js.map +1 -0
- package/dist/__tests__/toolRouter.test.d.ts +1 -0
- package/dist/__tests__/toolRouter.test.js +37 -0
- package/dist/__tests__/toolRouter.test.js.map +1 -0
- package/dist/__tests__/tools.test.d.ts +1 -0
- package/dist/__tests__/tools.test.js +112 -0
- package/dist/__tests__/tools.test.js.map +1 -0
- package/dist/__tests__/tracing.test.d.ts +1 -0
- package/dist/__tests__/tracing.test.js +147 -0
- package/dist/__tests__/tracing.test.js.map +1 -0
- package/dist/cli/config.d.ts +49 -0
- package/dist/cli/config.js +86 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +625 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/modelFactory.d.ts +9 -0
- package/dist/cli/modelFactory.js +154 -0
- package/dist/cli/modelFactory.js.map +1 -0
- package/dist/cli/providers.d.ts +18 -0
- package/dist/cli/providers.js +94 -0
- package/dist/cli/providers.js.map +1 -0
- package/dist/core/agentLoop.d.ts +43 -0
- package/dist/core/agentLoop.js +245 -0
- package/dist/core/agentLoop.js.map +1 -0
- package/dist/core/errors.d.ts +62 -0
- package/dist/core/errors.js +139 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/promptBuilder.d.ts +49 -0
- package/dist/core/promptBuilder.js +84 -0
- package/dist/core/promptBuilder.js.map +1 -0
- package/dist/core/reasoningRouter.d.ts +62 -0
- package/dist/core/reasoningRouter.js +102 -0
- package/dist/core/reasoningRouter.js.map +1 -0
- package/dist/core/retry.d.ts +25 -0
- package/dist/core/retry.js +49 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/sessionResumer.d.ts +17 -0
- package/dist/core/sessionResumer.js +78 -0
- package/dist/core/sessionResumer.js.map +1 -0
- package/dist/core/sessionStore.d.ts +45 -0
- package/dist/core/sessionStore.js +167 -0
- package/dist/core/sessionStore.js.map +1 -0
- package/dist/core/tokenCounter.d.ts +17 -0
- package/dist/core/tokenCounter.js +54 -0
- package/dist/core/tokenCounter.js.map +1 -0
- package/dist/evals/dataset.d.ts +4 -0
- package/dist/evals/dataset.js +61 -0
- package/dist/evals/dataset.js.map +1 -0
- package/dist/evals/evaluator.d.ts +21 -0
- package/dist/evals/evaluator.js +68 -0
- package/dist/evals/evaluator.js.map +1 -0
- package/dist/hitl/bridge.d.ts +65 -0
- package/dist/hitl/bridge.js +120 -0
- package/dist/hitl/bridge.js.map +1 -0
- package/dist/middleware/commandSanitizer.d.ts +18 -0
- package/dist/middleware/commandSanitizer.js +50 -0
- package/dist/middleware/commandSanitizer.js.map +1 -0
- package/dist/middleware/loopDetection.d.ts +28 -0
- package/dist/middleware/loopDetection.js +49 -0
- package/dist/middleware/loopDetection.js.map +1 -0
- package/dist/middleware/permission.d.ts +17 -0
- package/dist/middleware/permission.js +59 -0
- package/dist/middleware/permission.js.map +1 -0
- package/dist/middleware/pipeline.d.ts +31 -0
- package/dist/middleware/pipeline.js +62 -0
- package/dist/middleware/pipeline.js.map +1 -0
- package/dist/middleware/preCompletion.d.ts +29 -0
- package/dist/middleware/preCompletion.js +82 -0
- package/dist/middleware/preCompletion.js.map +1 -0
- package/dist/middleware/types.d.ts +40 -0
- package/dist/middleware/types.js +8 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/sandbox/bootstrap.d.ts +38 -0
- package/dist/sandbox/bootstrap.js +107 -0
- package/dist/sandbox/bootstrap.js.map +1 -0
- package/dist/sandbox/manager.d.ts +72 -0
- package/dist/sandbox/manager.js +180 -0
- package/dist/sandbox/manager.js.map +1 -0
- package/dist/sandbox/sync.d.ts +55 -0
- package/dist/sandbox/sync.js +135 -0
- package/dist/sandbox/sync.js.map +1 -0
- package/dist/skills/loader.d.ts +55 -0
- package/dist/skills/loader.js +132 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/tools.d.ts +5 -0
- package/dist/skills/tools.js +78 -0
- package/dist/skills/tools.js.map +1 -0
- package/dist/skills/types.d.ts +13 -0
- package/dist/skills/types.js +2 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/test_cache.d.ts +1 -0
- package/dist/test_cache.js +55 -0
- package/dist/test_cache.js.map +1 -0
- package/dist/test_google.js +93 -0
- package/dist/tools/askUser.d.ts +10 -0
- package/dist/tools/askUser.js +42 -0
- package/dist/tools/askUser.js.map +1 -0
- package/dist/tools/browser.d.ts +19 -0
- package/dist/tools/browser.js +111 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.js +184 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +31 -0
- package/dist/tools/registry.js +168 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/router.d.ts +34 -0
- package/dist/tools/router.js +73 -0
- package/dist/tools/router.js.map +1 -0
- package/dist/tools/security.d.ts +28 -0
- package/dist/tools/security.js +183 -0
- package/dist/tools/security.js.map +1 -0
- package/dist/tools/webSearch.d.ts +6 -0
- package/dist/tools/webSearch.js +120 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/tracing/analyzer.d.ts +58 -0
- package/dist/tracing/analyzer.js +190 -0
- package/dist/tracing/analyzer.js.map +1 -0
- package/dist/tracing/langsmith.d.ts +38 -0
- package/dist/tracing/langsmith.js +50 -0
- package/dist/tracing/langsmith.js.map +1 -0
- package/dist/tracing/sessionTracer.d.ts +73 -0
- package/dist/tracing/sessionTracer.js +157 -0
- package/dist/tracing/sessionTracer.js.map +1 -0
- package/dist/tracing/types.d.ts +46 -0
- package/dist/tracing/types.js +5 -0
- package/dist/tracing/types.js.map +1 -0
- package/dist/ui/App.d.ts +24 -0
- package/dist/ui/App.js +172 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/components/HITLPrompt.d.ts +15 -0
- package/dist/ui/components/HITLPrompt.js +35 -0
- package/dist/ui/components/HITLPrompt.js.map +1 -0
- package/dist/ui/components/Header.d.ts +8 -0
- package/dist/ui/components/Header.js +6 -0
- package/dist/ui/components/Header.js.map +1 -0
- package/dist/ui/components/MessageBubble.d.ts +13 -0
- package/dist/ui/components/MessageBubble.js +17 -0
- package/dist/ui/components/MessageBubble.js.map +1 -0
- package/dist/ui/components/StatusBar.d.ts +21 -0
- package/dist/ui/components/StatusBar.js +34 -0
- package/dist/ui/components/StatusBar.js.map +1 -0
- package/dist/ui/components/StreamingText.d.ts +13 -0
- package/dist/ui/components/StreamingText.js +24 -0
- package/dist/ui/components/StreamingText.js.map +1 -0
- package/dist/ui/components/ToolCallPanel.d.ts +15 -0
- package/dist/ui/components/ToolCallPanel.js +18 -0
- package/dist/ui/components/ToolCallPanel.js.map +1 -0
- package/docs/01_insights_and_patterns.md +27 -0
- package/docs/02_edge_cases_and_mitigations.md +143 -0
- package/docs/03_initial_implementation_plan.md +66 -0
- package/docs/04_tech_stack_proposal.md +20 -0
- package/docs/05_prd.md +87 -0
- package/docs/06_user_stories.md +72 -0
- package/docs/07_system_architecture.md +138 -0
- package/docs/08_roadmap.md +200 -0
- package/e2b/Dockerfile +26 -0
- package/package.json +57 -0
- package/src/__tests__/bootstrap.test.ts +111 -0
- package/src/__tests__/config.test.ts +97 -0
- package/src/__tests__/m55.test.ts +238 -0
- package/src/__tests__/middleware.test.ts +219 -0
- package/src/__tests__/modelFactory.test.ts +63 -0
- package/src/__tests__/optimizations.test.ts +201 -0
- package/src/__tests__/promptBuilder.test.ts +141 -0
- package/src/__tests__/sandbox.test.ts +102 -0
- package/src/__tests__/security.test.ts +122 -0
- package/src/__tests__/streaming.test.ts +82 -0
- package/src/__tests__/toolRouter.test.ts +52 -0
- package/src/__tests__/tools.test.ts +146 -0
- package/src/__tests__/tracing.test.ts +196 -0
- package/src/agents/agentRegistry.ts +69 -0
- package/src/agents/agentSpec.ts +67 -0
- package/src/agents/builtinAgents.ts +142 -0
- package/src/cli/config.ts +124 -0
- package/src/cli/index.ts +730 -0
- package/src/cli/modelFactory.ts +174 -0
- package/src/cli/providers.ts +107 -0
- package/src/commands/builtinCommands.ts +293 -0
- package/src/commands/commandRegistry.ts +194 -0
- package/src/core/agentLoop.d.ts.map +1 -0
- package/src/core/agentLoop.ts +312 -0
- package/src/core/autoSave.ts +95 -0
- package/src/core/compactor.ts +252 -0
- package/src/core/contextGuard.ts +129 -0
- package/src/core/errors.ts +202 -0
- package/src/core/promptBuilder.d.ts.map +1 -0
- package/src/core/promptBuilder.ts +139 -0
- package/src/core/reasoningRouter.ts +121 -0
- package/src/core/retry.ts +75 -0
- package/src/core/sessionResumer.ts +90 -0
- package/src/core/sessionStore.ts +215 -0
- package/src/core/subAgent.ts +339 -0
- package/src/core/tokenCounter.ts +64 -0
- package/src/evals/dataset.ts +67 -0
- package/src/evals/evaluator.ts +81 -0
- package/src/hitl/bridge.ts +160 -0
- package/src/middleware/commandSanitizer.ts +60 -0
- package/src/middleware/loopDetection.ts +63 -0
- package/src/middleware/permission.ts +72 -0
- package/src/middleware/pipeline.ts +75 -0
- package/src/middleware/preCompletion.ts +94 -0
- package/src/middleware/types.ts +45 -0
- package/src/sandbox/bootstrap.ts +121 -0
- package/src/sandbox/manager.ts +239 -0
- package/src/sandbox/sync.ts +157 -0
- package/src/skills/loader.ts +143 -0
- package/src/skills/tools.ts +99 -0
- package/src/skills/types.ts +13 -0
- package/src/test_cache.ts +72 -0
- package/src/test_google.js +40 -0
- package/src/test_google.ts +40 -0
- package/src/tools/askUser.ts +47 -0
- package/src/tools/browser.ts +137 -0
- package/src/tools/index.d.ts.map +1 -0
- package/src/tools/index.ts +237 -0
- package/src/tools/registry.ts +198 -0
- package/src/tools/router.ts +78 -0
- package/src/tools/security.ts +220 -0
- package/src/tools/spawnAgent.ts +158 -0
- package/src/tools/webSearch.ts +142 -0
- package/src/tracing/analyzer.ts +265 -0
- package/src/tracing/langsmith.ts +63 -0
- package/src/tracing/sessionTracer.ts +202 -0
- package/src/tracing/types.ts +49 -0
- package/src/types/valyu.d.ts +37 -0
- package/src/ui/App.tsx +404 -0
- package/src/ui/components/HITLPrompt.tsx +119 -0
- package/src/ui/components/Header.tsx +51 -0
- package/src/ui/components/MessageBubble.tsx +46 -0
- package/src/ui/components/StatusBar.tsx +138 -0
- package/src/ui/components/StreamingText.tsx +48 -0
- package/src/ui/components/ToolCallPanel.tsx +80 -0
- package/tests/commands/commands.test.ts +356 -0
- package/tests/core/compactor.test.ts +217 -0
- package/tests/core/retryAndErrors.test.ts +164 -0
- package/tests/core/sessionResumer.test.ts +95 -0
- package/tests/core/sessionStore.test.ts +84 -0
- package/tests/core/stability.test.ts +165 -0
- package/tests/core/subAgent.test.ts +238 -0
- package/tests/hitl/hitlBridge.test.ts +115 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +10 -0
- package/vitest.out +48 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Welcome to the Agentic Coding Project
|
|
2
|
+
|
|
3
|
+
You are an autonomous AI Agent contributing to this codebase. To ensure consistency with the established architectural patterns (Prompt Caching + Harness Engineering), you **MUST** review the foundational documents in the `docs/` directory before proposing new features or modifying the core loop.
|
|
4
|
+
|
|
5
|
+
## Required Reading List
|
|
6
|
+
|
|
7
|
+
Before tackling complex tasks related to the context engine, middleware, or tools, please reference:
|
|
8
|
+
|
|
9
|
+
- `Handover.md`: **MUST READ FIRST if this is a new session.** Contains all key architectural decisions and current project state.
|
|
10
|
+
- `docs/01_insights_and_patterns.md`: The core thesis of the project (Prefix caching rules, Middleware hooks).
|
|
11
|
+
- `docs/02_edge_cases_and_mitigations.md`: What _not_ to do (e.g., Leaky timestamps, Mid-session model switches).
|
|
12
|
+
- `docs/07_system_architecture.md`: The REPL execution graph.
|
|
13
|
+
|
|
14
|
+
## Development Process: Red-Green-Refactor TDD
|
|
15
|
+
|
|
16
|
+
> **CRITICAL:** This project follows a strict **Test-Driven Development (TDD)** workflow using the **Red-Green-Refactor** cycle.
|
|
17
|
+
|
|
18
|
+
### TDD Skills (MUST READ)
|
|
19
|
+
|
|
20
|
+
Before writing **any** production code, you **MUST** load and follow the TDD skill instructions:
|
|
21
|
+
|
|
22
|
+
1. **Primary:** `C:\Users\Lenovo\.agents\skills\tdd\SKILL.md` — Covers vertical slicing (tracer bullets), behavior-driven testing, and anti-patterns.
|
|
23
|
+
2. **Extended:** `C:\Users\Lenovo\.agents\skills\test-driven-development\SKILL.md` — The "Iron Law": no production code without a failing test first. Includes rationalizations to watch for and a verification checklist.
|
|
24
|
+
|
|
25
|
+
### The Cycle
|
|
26
|
+
|
|
27
|
+
1. **RED** — Write a failing test first. The test defines expected behavior.
|
|
28
|
+
2. **GREEN** — Write the minimum production code to make the failing test pass.
|
|
29
|
+
3. **REFACTOR** — Clean up both test and production code while keeping all tests green.
|
|
30
|
+
|
|
31
|
+
### Rules
|
|
32
|
+
|
|
33
|
+
- **Vertical slices only.** One test → one implementation → repeat. Never write all tests first.
|
|
34
|
+
- **No production code without a failing test.** Code written before the test? Delete it. Start over.
|
|
35
|
+
- **Never refactor while RED.** Get to GREEN first.
|
|
36
|
+
|
|
37
|
+
**Test Runner:** Vitest (`npx vitest` or `npm test`).
|
|
38
|
+
|
|
39
|
+
## Tracking Progress
|
|
40
|
+
|
|
41
|
+
Any time you complete a significant milestone, you **must**:
|
|
42
|
+
|
|
43
|
+
1. Append a summary of your actions and the current state of the project to `PROGRESS.md` in the project root.
|
|
44
|
+
2. Update `Handover.md` to reflect any new architectural decisions, tool additions, or shifts in the project state.
|
|
45
|
+
|
|
46
|
+
This ensures the next agent or human developer knows exactly where to pick up and why decisions were made.
|
|
47
|
+
|
|
48
|
+
## API Key Management
|
|
49
|
+
|
|
50
|
+
> **CRITICAL:** When implementing a **new tool** that requires an API key or token, you **must**:
|
|
51
|
+
>
|
|
52
|
+
> 1. Add the key field to `JooneConfig` in `src/cli/config.ts`.
|
|
53
|
+
> 2. Add a password prompt for it in the `joone config` onboarding flow in `src/cli/index.ts` (under the "Optional Service Keys" section).
|
|
54
|
+
> 3. Ensure the key is included in the `newConfig` object that gets saved.
|
|
55
|
+
>
|
|
56
|
+
> All service keys (except the primary LLM provider key) should be **optional** — the user can press Enter to skip. Tools should gracefully degrade when their API key is not configured.
|
package/Handover.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Joone Agent: Handover & Architecture Document
|
|
2
|
+
|
|
3
|
+
This document serves as a comprehensive handover note for future agents or engineering sessions. It captures the core architectural decisions, the current state of the project, and the rationale behind the implementation of the `joone` AI coding assistant.
|
|
4
|
+
|
|
5
|
+
## 1. Project Overview & Tech Stack
|
|
6
|
+
|
|
7
|
+
**Goal:** Build a secure, terminal-based AI coding assistant that executes code in an isolated sandbox while manipulating local project files, providing a premium developer experience.
|
|
8
|
+
|
|
9
|
+
- **Runtime:** Node.js (v20+)
|
|
10
|
+
- **Module System:** ESM (`"type": "module"`)
|
|
11
|
+
- **Language:** TypeScript (`NodeNext` resolution)
|
|
12
|
+
- **Terminal UI (TUI):** Ink v6 (React for CLI) + Clack (prompts/onboarding)
|
|
13
|
+
- **Primary Sandbox:** E2B
|
|
14
|
+
- **Fallback Sandbox:** OpenSandbox (Local Docker)
|
|
15
|
+
- **AI SDKs:** `@langchain/anthropic`, `@langchain/openai`, `@google/genai` (planned/flexible via factory)
|
|
16
|
+
- **Testing:** Vitest (TDD methodology strictly enforced)
|
|
17
|
+
- **Testing:** Vitest (TDD methodology strictly enforced)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Key Architectural Decisions
|
|
22
|
+
|
|
23
|
+
### 2.1 The "Hybrid" Execution Model
|
|
24
|
+
|
|
25
|
+
- **Decision:** Split tool execution between the **Host** machine and the **Sandbox**.
|
|
26
|
+
- **Rationale:** We want the user to see file changes happen live in their IDE (Host), but we strictly do not want to run untrusted shell commands or install random dependencies on the user's machine (Sandbox).
|
|
27
|
+
- **Implementation (`src/tools/router.ts` & `src/sandbox/manager.ts`):**
|
|
28
|
+
- **Host Routing (`HOST_TOOLS`):** `read_file`, `write_file`, `search_tools`.
|
|
29
|
+
- **Sandbox Routing (`SANDBOX_TOOLS`):** `bash`, `run_tests`, `install_deps`, `security_scan`, `dep_scan`.
|
|
30
|
+
- **Wrapper Architecture:** The `SandboxManager` uses an `ISandboxWrapper`. It attempts to connect to a primary **E2B** cloud sandbox. If initialization fails (e.g., API key error, network timeout), it gracefully defaults to a robust local **OpenSandbox** deployment (`localhost:8080`).
|
|
31
|
+
- _Safe-by-default logic:_ Any unknown tool request is routed to the sandbox.
|
|
32
|
+
|
|
33
|
+
### 2.2 ESM Migration for the TUI
|
|
34
|
+
|
|
35
|
+
- **Decision:** Migrated the entire codebase from CommonJS to ESM.
|
|
36
|
+
- **Rationale:** The chosen TUI framework (Ink v6) and modern utility libraries (like Clack) are ESM-only. A premium UI requires modern tooling.
|
|
37
|
+
- **Implementation:** Updated `package.json` (`type: module`), modified TSConfig (`module: NodeNext`), and enforced `.js` extensions on all relative local imports.
|
|
38
|
+
|
|
39
|
+
### 2.3 Upload-on-Execute File Synchronization
|
|
40
|
+
|
|
41
|
+
- **Decision:** Sync files from host to sandbox _just-in-time_ before command execution.
|
|
42
|
+
- **Rationale:** Constant bidirectional syncing is slow and error-prone. Instead, when the agent uses `write_file` (on the host), the file is marked as "dirty".
|
|
43
|
+
- **Implementation (`src/sandbox/sync.ts`):** Before `SandboxManager.exec()` runs a bash command, the `FileSync` layer checks the dirty queue and uploads only the modified files to the E2B sandbox.
|
|
44
|
+
|
|
45
|
+
### 2.4 File Size & Context Guardrails
|
|
46
|
+
|
|
47
|
+
- **Decision:** Prevent the LLM from reading massive files that would blow up the context window.
|
|
48
|
+
- **Rationale:** Reading generic log files or compiled assets breaks token limits, leading to expensive failures.
|
|
49
|
+
- **Implementation (`src/tools/index.ts` -> `ReadFileTool`):**
|
|
50
|
+
- Strict 512 KB file size hard-limit.
|
|
51
|
+
- Soft 2,000-line truncation limit.
|
|
52
|
+
- Added `startLine`/`endLine` arguments for specific chunk reading.
|
|
53
|
+
- Suggests `grep` or `head` via `bash` when limits are hit.
|
|
54
|
+
|
|
55
|
+
### 2.5 Config-Driven Sandbox Strategy (Security Scanning)
|
|
56
|
+
|
|
57
|
+
- **Decision:** Support both a zero-startup-cost Production environment and a flexible Development environment.
|
|
58
|
+
- **Rationale:** Installing the Gemini CLI and OSV-Scanner inside the sandbox takes ~15 seconds, which ruins the UX if done on every session start.
|
|
59
|
+
- **Implementation (`src/sandbox/bootstrap.ts`):**
|
|
60
|
+
- **Dev Mode (Default):** `LazyInstaller` installs tools on-demand _only_ when the user actually invokes `security_scan` or `dep_scan`. Install state is cached per session.
|
|
61
|
+
- **Prod Mode (`sandboxTemplate: "joone-base"`):** Uses a pre-baked E2B template defined in `e2b/Dockerfile`. The installer detects this and skips the install phase entirely (0s startup).
|
|
62
|
+
|
|
63
|
+
### 2.6 Skills System (Multi-Directory Discovery)
|
|
64
|
+
|
|
65
|
+
- **Decision:** Skills are discovered from multiple directories with project-level overriding user-level.
|
|
66
|
+
- **Rationale:** Users may have personal skills (e.g., `~/.agents/skills/`) and project-specific skills. Project skills should take priority to allow per-project customization.
|
|
67
|
+
- **Implementation (`src/skills/loader.ts`):**
|
|
68
|
+
- Discovery paths: `./skills/`, `./.agents/skills/`, `./.agent/skills/` (project), `~/.joone/skills/`, `~/.agents/skills/` (user)
|
|
69
|
+
- YAML frontmatter parsing for `name` and `description` fields
|
|
70
|
+
- Deduplication by name; project-level wins on conflict
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 3. Current Project State
|
|
75
|
+
|
|
76
|
+
All development follows strict TDD. Currently, **95 out of 95 tests are GREEN** across 13 test suites. TypeScript compiles cleanly.
|
|
77
|
+
|
|
78
|
+
### Completed Milestones
|
|
79
|
+
|
|
80
|
+
- ✅ **M1: Core Setup:** CLI scaffolding, config manager, dynamic Model Factory.
|
|
81
|
+
- ✅ **M2: TUI & Core Loop:** Clack onboarding, Ink REPL interface, tool buffering.
|
|
82
|
+
- ✅ **M3: Hybrid Sandbox:** E2B `SandboxManager`, `FileSync`, `ToolRouter`, core tools.
|
|
83
|
+
- ✅ **M3.5: Security Tools:** `LazyInstaller`, `SecurityScanTool`, `DepScanTool`, E2B Dockerfile.
|
|
84
|
+
- ✅ **M4: Harness Engineering:** `MiddlewarePipeline`, `LoopDetectionMiddleware`, `CommandSanitizerMiddleware`, `PreCompletionMiddleware`.
|
|
85
|
+
- ✅ **M5: Advanced Optimizations:** Enhanced registry (fuzzy search + `activateTool`), `TokenCounter`, improved `compactHistory`, `ReasoningRouter`.
|
|
86
|
+
- ✅ **M5.5: Browser, Search & Skills:** `BrowserTool` (agent-browser), `WebSearchTool` (@valyu/ai-sdk), `SkillLoader` + `search_skills`/`load_skill` tools.
|
|
87
|
+
- ✅ **M6: Tracing & Refinement:** `SessionTracer` (metrics routing), `TraceAnalyzer` (offline insights), LangSmith env integration, `joone analyze` CLI command.
|
|
88
|
+
- ✅ **M8: OpenSandbox Fallback:** `ISandboxWrapper`, local docker degradation at `localhost:8080`, and documented NFRs (Rate Limits & Budgets).
|
|
89
|
+
- ✅ **M9: Persistent Sessions:** `SessionStore` (JSONL), `SessionResumer` (host drift detection), `joone sessions` dashboard, `joone start --resume <id>`.
|
|
90
|
+
- ✅ **M10: Retry, HITL, Skills Sync:** `JooneError` hierarchy + `retryWithBackoff`, `HITLBridge` + `AskUserQuestionTool` + `PermissionMiddleware`, user-level skills sandbox sync.
|
|
91
|
+
- ✅ **M11: Slash Command System:** `CommandRegistry` + 10 built-in `/commands` (`/help`, `/model`, `/clear`, `/compact`, `/tokens`, `/status`, `/exit`, `/history`, `/undo`) intercepted in TUI before agent loop (zero LLM cost).
|
|
92
|
+
|
|
93
|
+
- ✅ **M12: LLM-Powered Compaction:** LLM-driven `ConversationCompactor`, fast model mapping (`FAST_MODEL_DEFAULTS`), and seamless handoff prompts post-compaction.
|
|
94
|
+
- ✅ **M13: Sub-Agent Orchestration:** `AgentRegistry`, isolated sync/async `SubAgentManager`, and safe `spawn_agent` + `check_agent` tools (Depth-1 limits).
|
|
95
|
+
- ✅ **M14: Stability & Reliability:** `ContextGuard` (80% auto-compact, 95% emergency truncation), `AutoSave` (debounced JSONL persistence), and atomic TUI `SIGINT/SIGTERM` handling.
|
|
96
|
+
|
|
97
|
+
### Tool Routing Summary
|
|
98
|
+
|
|
99
|
+
| HOST (safe, runs on user machine) | SANDBOX (isolated, runs in E2B) |
|
|
100
|
+
| --------------------------------- | ----------------------------------- |
|
|
101
|
+
| `read_file`, `write_file` | `bash`, `run_tests`, `install_deps` |
|
|
102
|
+
| `search_tools`, `activate_tool` | `security_scan`, `dep_scan` |
|
|
103
|
+
| `web_search` (API call) | `browser` (agent-browser CLI) |
|
|
104
|
+
| `search_skills`, `load_skill` | Unknown tools (safe-by-default) |
|
|
105
|
+
| `ask_user_question` | |
|
|
106
|
+
| `/commands` (TUI-only, no LLM) | |
|
|
107
|
+
| `spawn_agent`, `check_agent` | |
|
|
108
|
+
|
|
109
|
+
### Pending Next Steps (Where to resume)
|
|
110
|
+
|
|
111
|
+
**Continue with Milestone 15:**
|
|
112
|
+
|
|
113
|
+
1. **M15: MCP Client Integration** — `@modelcontextprotocol/sdk`, stdio/HTTP transport, namespaced MCP tools.
|
|
114
|
+
|
|
115
|
+
_Reference `docs/08_roadmap.md` and the implementation plan artifact for the full checklist._
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/PROGRESS.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Project Progress & Status
|
|
2
|
+
|
|
3
|
+
_This document serves as a living changelog and status board. Any human or agent picking up this directory should read this first to understand the current state of the implementation._
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Current Status
|
|
8
|
+
|
|
9
|
+
- [x] Milestone 6: Tracing & Refinement
|
|
10
|
+
- [x] Milestone 7: Testing & Evaluations (TDD - Ongoing)
|
|
11
|
+
- [x] Milestone 8: OpenSandbox Fallback & NFRs
|
|
12
|
+
- [x] Milestone 9: Persistent Sessions
|
|
13
|
+
|
|
14
|
+
## Next Steps
|
|
15
|
+
|
|
16
|
+
1. **Milestone 7 Evals**: Hook LangSmith datasets to ExecutionHarness for regression testing.
|
|
17
|
+
2. **Dataset CI**: Build `joone eval` CLI command to assert Cache Hit Rate > 90% and Cost < $X.
|
|
18
|
+
3. **Security Tier 2 & 3 (Planned)**: OS Keychain and encrypted config.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Changelog
|
|
23
|
+
|
|
24
|
+
### 2026-02-22: Project Initialization & Context Engine
|
|
25
|
+
|
|
26
|
+
- **Docs Setup**: Extracted key insights from Harness Engineering and Prompt Caching research into the `docs/` folder (`01_insights...` through `08_roadmap...`).
|
|
27
|
+
- **Tech Stack**: Finalized TypeScript + Node + LangChain + Zod + LangSmith architecture.
|
|
28
|
+
- **Project Scaffold**: Initialized `package.json`, installed dependencies, configured strict `tsconfig.json`.
|
|
29
|
+
- **Phase 1 Complete**: Implemented `CacheOptimizedPromptBuilder` (`src/core/promptBuilder.ts`) to strictly enforce the static-to-dynamic prefix caching rules via LangChain message formatting.
|
|
30
|
+
- **Phase 1 Complete**: Implemented the base `ExecutionHarness` (`src/core/agentLoop.ts`) combining the LLM query and naive tool execution block.
|
|
31
|
+
- **Phase 2 Started**: Created the `DeferredToolsDB` and mock `SearchToolsTool` (`src/tools/registry.ts`) to support lazy loading of tools for cache preservation.
|
|
32
|
+
- **Testing & Sandbox Strategy**: Created `src/test_cache.ts` to empirically test Anthropic prompt caching locally. Outlined the architecture to use **E2B (e2b.dev)** or Docker for secure sandboxed code execution, isolating the agent's OS interactions from the host environment.
|
|
33
|
+
- **Governance**: Created `AGENTS.md` and this `PROGRESS.md` file.
|
|
34
|
+
|
|
35
|
+
### 2026-02-25: Architecture Refinements & Doc Overhaul
|
|
36
|
+
|
|
37
|
+
- **Provider Abstraction**: Refactored `ExecutionHarness` to accept any LangChain `BaseChatModel | Runnable` instead of hardcoding `ChatAnthropic`. Model selection now happens at the call site (`src/index.ts`).
|
|
38
|
+
- **AGENTS.md**: Added mandatory Red-Green-Refactor TDD workflow instructions; added reminder to use `tdd` skill if available.
|
|
39
|
+
- **PRD**: Added CLI packaging (`npx joone`), provider/model selection feature, and E2B sandbox execution as core features.
|
|
40
|
+
- **User Stories**: Added new Epics for CLI/Config (Epic 1) and E2B Sandbox Execution (Epic 3).
|
|
41
|
+
- **System Architecture**: Updated mermaid diagram to show CLI config layer routing to provider selection and E2B sandbox replacing local OS execution.
|
|
42
|
+
- **Roadmap**: Restructured milestones to include CLI Packaging (M2), E2B Sandbox Integration (M3), and made Testing & Evaluations an ongoing parallel milestone (M7) driven by TDD.
|
|
43
|
+
|
|
44
|
+
### 2026-02-25: Milestone 7 — TDD Setup & First GREEN
|
|
45
|
+
|
|
46
|
+
- **TDD Skills**: Located and verified both `tdd` and `test-driven-development` skills at `C:\Users\Lenovo\.agents\skills\`. Updated `AGENTS.md` with exact paths and instructions.
|
|
47
|
+
- **Vitest Installed**: Added `vitest` as a dev dependency.
|
|
48
|
+
- **PromptBuilder Tests (5/5 GREEN)**: Wrote 5 behavior-driven tests covering: strict prefix ordering, history appending after prefix, prefix stability across calls, `<system-reminder>` injection, and compaction. All passing.
|
|
49
|
+
|
|
50
|
+
### 2026-02-26: Milestone 2 — Detailed Planning Complete
|
|
51
|
+
|
|
52
|
+
- **PRD Updated**: Added streaming, expanded provider list (9+), tiered API key security (plain → keychain → encrypted), and dynamic provider loading.
|
|
53
|
+
- **User Stories Updated**: Added Epic 2 (Streaming), expanded Epic 1 with masked input and planned keychain onboarding (US 1.6).
|
|
54
|
+
- **System Architecture Updated**: Added Stream Handler component, Model Factory component, full provider table, and security tier roadmap.
|
|
55
|
+
- **Roadmap Updated**: Detailed Milestone 2 into 5 sub-sections (2a–2e) with a 9-step TDD vertical slice test plan.
|
|
56
|
+
- **Pending tracked items**: OS Keychain (Security Tier 2) and AES-256 encrypted config (Security Tier 3) tracked as planned items for future onboarding enhancement.
|
|
57
|
+
|
|
58
|
+
### 2026-02-27: Milestone 2 — CLI Packaging & Provider Selection (COMPLETE)
|
|
59
|
+
|
|
60
|
+
- **Config Manager** (`src/cli/config.ts`): `JooneConfig` interface, `loadConfig` (with env var fallback for 8 providers), `saveConfig` (with `chmod 600`), `DEFAULT_CONFIG`, `getProviderEnvVar`.
|
|
61
|
+
- **Model Factory** (`src/cli/modelFactory.ts`): Dynamic `import()` for Anthropic and OpenAI. API key validation, missing package detection with install instructions. Support for 9+ providers planned.
|
|
62
|
+
- **CLI Entry Point** (`src/cli/index.ts`): Commander.js with `joone` (default start) and `joone config` (interactive setup). Masked API key input via `@inquirer/prompts`. 9 provider choices + model lists.
|
|
63
|
+
- **Streaming Support** (`src/core/agentLoop.ts`): `streamStep()` method on `ExecutionHarness` — text tokens emitted via `onToken` callback, tool call JSON chunks buffered until complete.
|
|
64
|
+
- **Security Tier 1**: `saveConfig` writes with `mode: 0o600`, directory with `mode: 0o700`. Masked input in CLI. Env var fallback for API keys.
|
|
65
|
+
- **Package.json**: Updated with `"bin"`, `"build"`, `"test"`, `"test:watch"` scripts. Version bumped to `0.1.0`.
|
|
66
|
+
- **vitest.config.ts**: Created with test env vars to prevent Anthropic API key errors during testing.
|
|
67
|
+
- **Bug fix**: Deleted stale compiled `.js`/`.d.ts` files that were shadowing `.ts` sources, causing `streamStep` not to be found at runtime.
|
|
68
|
+
- **Tests**: 14/14 GREEN across 4 suites (config: 3, modelFactory: 4, promptBuilder: 5, streaming: 2).
|
|
69
|
+
|
|
70
|
+
### 2026-02-28: Milestone 2.5 — Terminal UI (Ink + Clack) (COMPLETE)
|
|
71
|
+
|
|
72
|
+
- **ESM Migration**: `package.json` → `"type": "module"`, `tsconfig.json` → `"module": "NodeNext"`, `"jsx": "react-jsx"`. All 17 relative imports updated with `.js` extensions. 14/14 tests GREEN after migration.
|
|
73
|
+
- **Dependencies**: Added `ink`, `react`, `@types/react`, `@clack/prompts`, `chalk`, `ink-spinner`. Removed `@inquirer/prompts`.
|
|
74
|
+
- **Clack Onboarding** (`src/cli/index.ts`): `joone config` rewritten with `intro()`, `outro()`, `spinner()`, `select()`, `password()`, `confirm()`, `cancel()`. Full cancellation handling with `isCancel()`. Chalk-styled terminal output for `joone start`.
|
|
75
|
+
- **Ink Components** (`src/ui/`):
|
|
76
|
+
- `App.tsx`: Main REPL layout with header, message history, streaming text, tool call panel, status bar, keyboard input (Ctrl+C to exit), elapsed time timer.
|
|
77
|
+
- `Header.tsx`: Bordered box showing provider, model, streaming status with cyan accent.
|
|
78
|
+
- `MessageBubble.tsx`: Role-based styling (user=cyan, agent=green, system=yellow).
|
|
79
|
+
- `StreamingText.tsx`: Token-by-token rendering with blinking cursor during streaming.
|
|
80
|
+
- `ToolCallPanel.tsx`: Status-colored bordered box (yellow=running, green=success, red=error) with spinner, args display, truncated result.
|
|
81
|
+
- `StatusBar.tsx`: Persistent footer with token count, cache hit rate, tool calls, elapsed time.
|
|
82
|
+
|
|
83
|
+
### 2026-02-28: Milestone 3 — Hybrid Sandbox Integration (COMPLETE)
|
|
84
|
+
|
|
85
|
+
- **SandboxManager** (`src/sandbox/manager.ts`): E2B SDK wrapper with `create()`, `destroy()`, `exec(cmd)`, `uploadFile(path, content)`, and `isActive()` lifecycle management.
|
|
86
|
+
- **FileSync** (`src/sandbox/sync.ts`): Host → sandbox file sync with `markDirty()`, `syncToSandbox()`, and `initialSync()`. Excludes `node_modules`, `.git`, `dist` on initial sync.
|
|
87
|
+
- **ToolRouter** (`src/tools/router.ts`): Routes tools to HOST (`write_file`, `read_file`, `search_tools`) or SANDBOX (`bash`, `run_tests`, `install_deps`). Unknown tools default to sandbox for safety.
|
|
88
|
+
- **Tests**: 26/26 GREEN across 6 suites (sandbox: 5, toolRouter: 7, plus existing 14).
|
|
89
|
+
|
|
90
|
+
### 2026-02-28: Milestone 3.5 — Security Scanning Tool (COMPLETE)
|
|
91
|
+
|
|
92
|
+
- **Config**: Added `sandboxTemplate?: string` to `JooneConfig` — config-driven switching between dev (lazy install) and prod (pre-baked template).
|
|
93
|
+
- **LazyInstaller** (`src/sandbox/bootstrap.ts`): Handles on-demand tool installation inside the sandbox. Caches install state per session. Skips entirely when using a custom E2B template.
|
|
94
|
+
- **SecurityScanTool** (`src/tools/security.ts`): Runs `gemini -x security:analyze` in sandbox. Supports targets: `"changes"`, `"file"`, `"deps"`. Handles CLI unavailability gracefully.
|
|
95
|
+
- **DepScanTool** (`src/tools/security.ts`): Runs OSV-Scanner with `npm audit` fallback. Supports JSON and summary output.
|
|
96
|
+
- **ToolRouter**: Added `security_scan` and `dep_scan` to `SANDBOX_TOOLS`.
|
|
97
|
+
- **E2B Dockerfile** (`e2b/Dockerfile`): Pre-baked production template with Gemini CLI + security extension + OSV-Scanner.
|
|
98
|
+
- **Tests**: 43/43 GREEN across 9 suites (bootstrap: 5, security: 5, plus existing 33).
|
|
99
|
+
|
|
100
|
+
### 2026-02-28: Milestone 4 — Harness Engineering & Middlewares (COMPLETE)
|
|
101
|
+
|
|
102
|
+
- **Middleware Types** (`src/middleware/types.ts`): `ToolCallContext` and `ToolMiddleware` interface with before/after hooks.
|
|
103
|
+
- **MiddlewarePipeline** (`src/middleware/pipeline.ts`): Chains before-hooks in order, executes tool, chains after-hooks in reverse. Short-circuits on rejection.
|
|
104
|
+
- **LoopDetectionMiddleware** (`src/middleware/loopDetection.ts`): Blocks after N identical consecutive tool calls (default: 3). Anti-doom-loop.
|
|
105
|
+
- **CommandSanitizerMiddleware** (`src/middleware/commandSanitizer.ts`): Blocks destructive (`rm -rf /`, fork bombs), interactive (`vim`, `top`), and pipe-to-shell commands.
|
|
106
|
+
- **PreCompletionMiddleware** (`src/middleware/preCompletion.ts`): Tracks test execution and blocks task completion until tests have been run.
|
|
107
|
+
- **Integration**: `ExecutionHarness.executeToolCalls()` now routes through `MiddlewarePipeline`.
|
|
108
|
+
- **Tests**: 55/55 GREEN across 10 suites (middleware: 12, plus existing 43).
|
|
109
|
+
|
|
110
|
+
### 2026-02-28: Milestone 5 — Advanced Optimizations (COMPLETE)
|
|
111
|
+
|
|
112
|
+
- **Enhanced Registry** (`src/tools/registry.ts`): Fuzzy search by name/description, `activateTool()` for dynamic mid-session tool loading, `ActivateToolTool`. Expanded stubs: git_diff, git_log, grep_search, list_dir.
|
|
113
|
+
- **Token Counter** (`src/core/tokenCounter.ts`): Character-based heuristic (~4 chars/token). `estimateTokens()`, `countMessageTokens()`, `isNearCapacity()`.
|
|
114
|
+
- **Context Compaction**: Enhanced `compactHistory()` with `keepLastN` parameter (preserves recent messages). Added `shouldCompact()` to `CacheOptimizedPromptBuilder`.
|
|
115
|
+
- **Reasoning Router** (`src/core/reasoningRouter.ts`): HIGH/MEDIUM reasoning levels. HIGH for planning + error recovery, MEDIUM for tool-heavy turns. Temperature-only adjustment (preserves cache prefix).
|
|
116
|
+
- **Tests**: 69/69 GREEN across 11 suites.
|
|
117
|
+
|
|
118
|
+
### 2026-02-28: Milestone 5.5 — Browser, Web Search & Skills (COMPLETE)
|
|
119
|
+
|
|
120
|
+
- **Browser Tool** (`src/tools/browser.ts`): Wraps `agent-browser` CLI. Actions: navigate, snapshot, click, type, screenshot, scroll. Runs in sandbox.
|
|
121
|
+
- **Web Search Tool** (`src/tools/webSearch.ts`): Wraps `@valyu/ai-sdk`. Sources: web, papers, finance, patents, SEC, companies. Dynamic import, type stub in `src/types/valyu.d.ts`.
|
|
122
|
+
- **Skills System**: `SkillLoader` (`src/skills/loader.ts`) discovers skills from project root (`./skills/`, `./.agents/skills/`) and user home (`~/.joone/skills/`, `~/.agents/skills/`). YAML frontmatter parsing, project-overrides-user deduplication.
|
|
123
|
+
- **Skills Tools** (`src/skills/tools.ts`): `search_skills` + `load_skill` tools for agent runtime use.
|
|
124
|
+
- **Config**: Added `valyuApiKey` to `JooneConfig`. Updated `ToolRouter` with browser/web_search/skills routing.
|
|
125
|
+
|
|
126
|
+
### 2026-02-28: Milestone 6 — Tracing & Refinement (COMPLETE)
|
|
127
|
+
|
|
128
|
+
- **SessionTracer** (`src/tracing/sessionTracer.ts`): Records LLM events (prompt/completion tokens), tool runs (name/args/duration/success), and errors. Saves traces to `~/.joone/traces/{id}.json`.
|
|
129
|
+
- **Harness Integration** (`src/core/agentLoop.ts`): Wired `ExecutionHarness` to automatically emit tracing events natively through `SessionTracer` during `step()`, `streamStep()`, and `executeToolCalls()`.
|
|
130
|
+
- **Trace Analyzer** (`src/tracing/analyzer.ts`): Analyzes a saved `SessionTrace` to detect doom-loops, cost hotspots (>20% total tokens), low cache efficiency (<70%), and error clusters. Generates actionable recommendations.
|
|
131
|
+
- **LangSmith Integration** (`src/tracing/langsmith.ts`): Injects configured `LANGCHAIN_TRACING_V2` environment variables from `JooneConfig` natively on CLI startup.
|
|
132
|
+
- **CLI Command** (`src/cli/index.ts`): Added `joone analyze [sessionId]` to read trace files and print the offline analysis report beautifully.
|
|
133
|
+
- **Tests**: 91/91 GREEN across 13 suites.
|
|
134
|
+
|
|
135
|
+
### 2026-03-01: Milestone 8 & Milestone 9 Completed!
|
|
136
|
+
|
|
137
|
+
The agent now supports robust **Persistent Sessions** allowing users to pause/resume tasks. It uses highly optimized JSONL appending and automatically detects Host File System Drift when waking up. Furthermore, it supports automatic fallbacks to OpenSandbox when the primary cloud sandbox (E2B) is unavailable!
|
|
138
|
+
|
|
139
|
+
- **SandboxManager (`ISandboxWrapper`)**: Refactored the core sandbox execution system to support multiple backends securely. Created `E2BSandboxWrapper` and `OpenSandboxWrapper`.
|
|
140
|
+
- **Graceful Degradation**: If E2B fails to initialize (e.g. from a network error or bad API key), the agent automatically catches the error and degrades instantly to a local Docker `OpenSandbox` container on `localhost:8080`.
|
|
141
|
+
- **SessionStore & SessionResumer**: Implemented a highly optimized JSONL-based `SessionStore` (`src/core/sessionStore.ts`) for persistent session logging and `SessionResumer` (`src/core/sessionResumer.ts`) for rehydrating agent state.
|
|
142
|
+
- **Host File System Drift Detection**: `SessionResumer` now automatically detects changes in the host file system since the last session save and prompts the user for reconciliation.
|
|
143
|
+
- **Config & CLI**: Updated `JooneConfig`, `loadConfig`/`saveConfig`, and the `joone config` Clack onboarding wizard to optionally prompt for `OpenSandbox API key` and `Domain`.
|
|
144
|
+
- **NFRs Documented**: Formally established architectural standards in `docs/05_prd.md` for Error Handling (Fallback), Rate Limiting (Budgets & Loop Breakers), Authentication (CLI keys), and Telemetry Data Retention (Local JSONs rotated at 30 days — 100% private).
|
|
145
|
+
- **Tests**: 95/95 GREEN tests ensuring the sandbox layer abstraction natively handles API mappings without breaking `BashTool`.
|
|
146
|
+
|
|
147
|
+
### 2026-03-04: Milestone 10 — Retry, HITL, and Skills Sync (COMPLETE)
|
|
148
|
+
|
|
149
|
+
- **Error Hierarchy** (`src/core/errors.ts`): `JooneError` base class with `LLMApiError`, `SandboxError`, `ToolExecutionError` subclasses. Each carries `category`, `retryable` flag, structured `context`, and `toRecoveryHint()` for self-healing. `wrapLLMError()` auto-classifies raw provider errors.
|
|
150
|
+
- **Retry** (`src/core/retry.ts`): `retryWithBackoff<T>()` generic utility with exponential backoff (1s→2s→4s + jitter). Respects `JooneError.retryable` flag. Non-retryable errors (401/403) fail immediately.
|
|
151
|
+
- **Self-Recovery** (`src/core/agentLoop.ts`): On exhausted retries, `ExecutionHarness` injects the error's `toRecoveryHint()` as a `SystemMessage` into conversation history instead of crashing. Tool errors now wrapped in `ToolExecutionError`.
|
|
152
|
+
- **HITLBridge** (`src/hitl/bridge.ts`): EventEmitter-based singleton with `askUser()` and `requestPermission()`. Configurable timeout (default 5 min) with auto-deny/auto-no-response.
|
|
153
|
+
- **AskUserQuestionTool** (`src/tools/askUser.ts`): Agent-callable tool for mid-turn clarification, preference gathering, and plan approval.
|
|
154
|
+
- **PermissionMiddleware** (`src/middleware/permission.ts`): `ToolMiddleware` implementation with 3 modes (`auto`, `ask_dangerous`, `ask_all`). Hardcoded `SAFE_TOOLS` whitelist. Uses `HITLBridge.requestPermission()` for dangerous tools.
|
|
155
|
+
- **HITLPrompt** (`src/ui/components/HITLPrompt.tsx`): Ink TUI component rendering question/permission prompts with `TextInput` capture.
|
|
156
|
+
- **Skills Sync** (`src/sandbox/sync.ts`): `syncSkillsToSandbox()` uploads user-level skill directories into `/workspace/.joone/skills/` in the sandbox.
|
|
157
|
+
- **System Prompt**: Updated `globalSystemInstructions` with `ask_user_question` awareness, permission system notice, and skills discovery instructions.
|
|
158
|
+
- **Config**: Added `permissionMode` to `JooneConfig` (default: `"auto"`).
|
|
159
|
+
- **Edge Cases**: Added 8 new scenarios covering retry/self-recovery, HITL timeouts, permission misconfiguration, and skills sync.
|
|
160
|
+
- **Tests**: 24 new tests (14 retry/errors + 10 HITL/permission) all GREEN. TypeScript build clean.
|