Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4fb2ace

Browse files
fix: critical parity bugs - enable tools, default permissions, tool input
Tighten prompt-mode parity for the Rust CLI by enabling native tools in one-shot runs, defaulting fresh sessions to danger-full-access, and documenting the remaining TS-vs-Rust gaps. The JSON prompt path now runs through the full conversation loop so tool use and tool results are preserved without streaming terminal noise, while the tool-input accumulator keeps the streaming {} placeholder fix without corrupting legitimate non-stream empty objects. Constraint: Original TypeScript source was treated as read-only for parity analysis Constraint: No new dependencies; keep the fix localized to the Rust port Rejected: Leave JSON prompt mode on a direct non-tool API path | preserved the one-shot parity bug Rejected: Keep workspace-write as the default permission mode | contradicted requested parity target Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep prompt text and prompt JSON paths on the same tool-capable runtime semantics unless upstream behavior proves they must diverge Tested: cargo build --release; cargo test Not-tested: live remote prompt run against LayoffLabs endpoint in this session
1 parent 1a4cbbf commit 4fb2ace

5 files changed

Lines changed: 473 additions & 90 deletions

File tree

‎PARITY.md‎

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# PARITY GAP ANALYSIS
2+
3+
Scope: read-only comparison between the original TypeScript source at `/home/bellman/Workspace/claude-code/src/` and the Rust port under `rust/crates/`.
4+
5+
Method: compared feature surfaces, registries, entrypoints, and runtime plumbing only. No TypeScript source was copied.
6+
7+
## Executive summary
8+
9+
The Rust port has a good foundation for:
10+
- Anthropic API/OAuth basics
11+
- local conversation/session state
12+
- a core tool loop
13+
- MCP stdio/bootstrap support
14+
- CLAUDE.md discovery
15+
- a small but usable built-in tool set
16+
17+
It is **not feature-parity** with the TypeScript CLI.
18+
19+
Largest gaps:
20+
- **plugins** are effectively absent in Rust
21+
- **hooks** are parsed but not executed in Rust
22+
- **CLI breadth** is much narrower in Rust
23+
- **skills** are local-file only in Rust, without the TS registry/bundled pipeline
24+
- **assistant orchestration** lacks TS hook-aware orchestration and remote/structured transports
25+
- **services** beyond core API/OAuth/MCP are mostly missing in Rust
26+
27+
---
28+
29+
## tools/
30+
31+
### TS exists
32+
Evidence:
33+
- `src/tools/` contains broad tool families including `AgentTool`, `AskUserQuestionTool`, `BashTool`, `ConfigTool`, `FileReadTool`, `FileWriteTool`, `GlobTool`, `GrepTool`, `LSPTool`, `ListMcpResourcesTool`, `MCPTool`, `McpAuthTool`, `ReadMcpResourceTool`, `RemoteTriggerTool`, `ScheduleCronTool`, `SkillTool`, `Task*`, `Team*`, `TodoWriteTool`, `ToolSearchTool`, `WebFetchTool`, `WebSearchTool`.
34+
- Tool execution/orchestration is split across `src/services/tools/StreamingToolExecutor.ts`, `src/services/tools/toolExecution.ts`, `src/services/tools/toolHooks.ts`, and `src/services/tools/toolOrchestration.ts`.
35+
36+
### Rust exists
37+
Evidence:
38+
- Tool registry is centralized in `rust/crates/tools/src/lib.rs` via `mvp_tool_specs()`.
39+
- Current built-ins include shell/file/search/web/todo/skill/agent/config/notebook/repl/powershell primitives.
40+
- Runtime execution is wired through `rust/crates/tools/src/lib.rs` and `rust/crates/runtime/src/conversation.rs`.
41+
42+
### Missing or broken in Rust
43+
- No Rust equivalents for major TS tools such as `AskUserQuestionTool`, `LSPTool`, `ListMcpResourcesTool`, `MCPTool`, `McpAuthTool`, `ReadMcpResourceTool`, `RemoteTriggerTool`, `ScheduleCronTool`, `Task*`, `Team*`, and several workflow/system tools.
44+
- Rust tool surface is still explicitly an MVP registry, not a parity registry.
45+
- Rust lacks TS’s layered tool orchestration split.
46+
47+
**Status:** partial core only.
48+
49+
---
50+
51+
## hooks/
52+
53+
### TS exists
54+
Evidence:
55+
- Hook command surface under `src/commands/hooks/`.
56+
- Runtime hook machinery in `src/services/tools/toolHooks.ts` and `src/services/tools/toolExecution.ts`.
57+
- TS supports `PreToolUse`, `PostToolUse`, and broader hook-driven behaviors configured through settings and documented in `src/skills/bundled/updateConfig.ts`.
58+
59+
### Rust exists
60+
Evidence:
61+
- Hook config is parsed and merged in `rust/crates/runtime/src/config.rs`.
62+
- Hook config can be inspected via Rust config reporting in `rust/crates/commands/src/lib.rs` and `rust/crates/rusty-claude-cli/src/main.rs`.
63+
- Prompt guidance mentions hooks in `rust/crates/runtime/src/prompt.rs`.
64+
65+
### Missing or broken in Rust
66+
- No actual hook execution pipeline in `rust/crates/runtime/src/conversation.rs`.
67+
- No PreToolUse/PostToolUse mutation/deny/rewrite/result-hook behavior.
68+
- No Rust `/hooks` parity command.
69+
70+
**Status:** config-only; runtime behavior missing.
71+
72+
---
73+
74+
## plugins/
75+
76+
### TS exists
77+
Evidence:
78+
- Built-in plugin scaffolding in `src/plugins/builtinPlugins.ts` and `src/plugins/bundled/index.ts`.
79+
- Plugin lifecycle/services in `src/services/plugins/PluginInstallationManager.ts` and `src/services/plugins/pluginOperations.ts`.
80+
- CLI/plugin command surface under `src/commands/plugin/` and `src/commands/reload-plugins/`.
81+
82+
### Rust exists
83+
Evidence:
84+
- No dedicated plugin subsystem appears under `rust/crates/`.
85+
- Repo-wide Rust references to plugins are effectively absent beyond text/help mentions.
86+
87+
### Missing or broken in Rust
88+
- No plugin loader.
89+
- No marketplace install/update/enable/disable flow.
90+
- No `/plugin` or `/reload-plugins` parity.
91+
- No plugin-provided hook/tool/command/MCP extension path.
92+
93+
**Status:** missing.
94+
95+
---
96+
97+
## skills/ and CLAUDE.md discovery
98+
99+
### TS exists
100+
Evidence:
101+
- Skill loading/registry pipeline in `src/skills/loadSkillsDir.ts`, `src/skills/bundledSkills.ts`, and `src/skills/mcpSkillBuilders.ts`.
102+
- Bundled skills under `src/skills/bundled/`.
103+
- Skills command surface under `src/commands/skills/`.
104+
105+
### Rust exists
106+
Evidence:
107+
- `Skill` tool in `rust/crates/tools/src/lib.rs` resolves and reads local `SKILL.md` files.
108+
- CLAUDE.md discovery is implemented in `rust/crates/runtime/src/prompt.rs`.
109+
- Rust supports `/memory` and `/init` via `rust/crates/commands/src/lib.rs` and `rust/crates/rusty-claude-cli/src/main.rs`.
110+
111+
### Missing or broken in Rust
112+
- No bundled skill registry equivalent.
113+
- No `/skills` command.
114+
- No MCP skill-builder pipeline.
115+
- No TS-style live skill discovery/reload/change handling.
116+
- No comparable session-memory / team-memory integration around skills.
117+
118+
**Status:** basic local skill loading only.
119+
120+
---
121+
122+
## cli/
123+
124+
### TS exists
125+
Evidence:
126+
- Large command surface under `src/commands/` including `agents`, `hooks`, `mcp`, `memory`, `model`, `permissions`, `plan`, `plugin`, `resume`, `review`, `skills`, `tasks`, and many more.
127+
- Structured/remote transport stack in `src/cli/structuredIO.ts`, `src/cli/remoteIO.ts`, and `src/cli/transports/*`.
128+
- CLI handler split in `src/cli/handlers/*`.
129+
130+
### Rust exists
131+
Evidence:
132+
- Shared slash command registry in `rust/crates/commands/src/lib.rs`.
133+
- Rust slash commands currently cover `help`, `status`, `compact`, `model`, `permissions`, `clear`, `cost`, `resume`, `config`, `memory`, `init`, `diff`, `version`, `export`, `session`.
134+
- Main CLI/repl/prompt handling lives in `rust/crates/rusty-claude-cli/src/main.rs`.
135+
136+
### Missing or broken in Rust
137+
- Missing major TS command families: `/agents`, `/hooks`, `/mcp`, `/plugin`, `/skills`, `/plan`, `/review`, `/tasks`, and many others.
138+
- No Rust equivalent to TS structured IO / remote transport layers.
139+
- No TS-style handler decomposition for auth/plugins/MCP/agents.
140+
- JSON prompt mode is improved on this branch, but still not clean transport parity: empirical verification shows tool-capable JSON output can emit human-readable tool-result lines before the final JSON object.
141+
142+
**Status:** functional local CLI core, much narrower than TS.
143+
144+
---
145+
146+
## assistant/ (agentic loop, streaming, tool calling)
147+
148+
### TS exists
149+
Evidence:
150+
- Assistant/session surface at `src/assistant/sessionHistory.ts`.
151+
- Tool orchestration in `src/services/tools/StreamingToolExecutor.ts`, `src/services/tools/toolExecution.ts`, `src/services/tools/toolOrchestration.ts`.
152+
- Remote/structured streaming layers in `src/cli/structuredIO.ts` and `src/cli/remoteIO.ts`.
153+
154+
### Rust exists
155+
Evidence:
156+
- Core loop in `rust/crates/runtime/src/conversation.rs`.
157+
- Stream/tool event translation in `rust/crates/rusty-claude-cli/src/main.rs`.
158+
- Session persistence in `rust/crates/runtime/src/session.rs`.
159+
160+
### Missing or broken in Rust
161+
- No TS-style hook-aware orchestration layer.
162+
- No TS structured/remote assistant transport stack.
163+
- No richer TS assistant/session-history/background-task integration.
164+
- JSON output path is no longer single-turn only on this branch, but output cleanliness still lags TS transport expectations.
165+
166+
**Status:** strong core loop, missing orchestration layers.
167+
168+
---
169+
170+
## services/ (API client, auth, models, MCP)
171+
172+
### TS exists
173+
Evidence:
174+
- API services under `src/services/api/*`.
175+
- OAuth services under `src/services/oauth/*`.
176+
- MCP services under `src/services/mcp/*`.
177+
- Additional service layers for analytics, prompt suggestion, session memory, plugin operations, settings sync, policy limits, team memory sync, notifier, voice, and more under `src/services/*`.
178+
179+
### Rust exists
180+
Evidence:
181+
- Core Anthropic API client in `rust/crates/api/src/{client,error,sse,types}.rs`.
182+
- OAuth support in `rust/crates/runtime/src/oauth.rs`.
183+
- MCP config/bootstrap/client support in `rust/crates/runtime/src/{config,mcp,mcp_client,mcp_stdio}.rs`.
184+
- Usage accounting in `rust/crates/runtime/src/usage.rs`.
185+
- Remote upstream-proxy support in `rust/crates/runtime/src/remote.rs`.
186+
187+
### Missing or broken in Rust
188+
- Most TS service ecosystem beyond core messaging/auth/MCP is absent.
189+
- No TS-equivalent plugin service layer.
190+
- No TS-equivalent analytics/settings-sync/policy-limit/team-memory subsystems.
191+
- No TS-style MCP connection-manager/UI layer.
192+
- Model/provider ergonomics remain thinner than TS.
193+
194+
**Status:** core foundation exists; broader service ecosystem missing.
195+
196+
---
197+
198+
## Critical bug status in this worktree
199+
200+
### Fixed
201+
- **Prompt mode tools enabled**
202+
- `rust/crates/rusty-claude-cli/src/main.rs` now constructs prompt mode with `LiveCli::new(model, true, ...)`.
203+
- **Default permission mode = DangerFullAccess**
204+
- Runtime default now resolves to `DangerFullAccess` in `rust/crates/rusty-claude-cli/src/main.rs`.
205+
- Clap default also uses `DangerFullAccess` in `rust/crates/rusty-claude-cli/src/args.rs`.
206+
- Init template writes `dontAsk` in `rust/crates/rusty-claude-cli/src/init.rs`.
207+
- **Streaming `{}` tool-input prefix bug**
208+
- `rust/crates/rusty-claude-cli/src/main.rs` now strips the initial empty object only for streaming tool input, while preserving legitimate `{}` in non-stream responses.
209+
- **Unlimited max_iterations**
210+
- Verified at `rust/crates/runtime/src/conversation.rs` with `usize::MAX`.
211+
212+
### Remaining notable parity issue
213+
- **JSON prompt output cleanliness**
214+
- Tool-capable JSON mode now loops, but empirical verification still shows pre-JSON human-readable tool-result output when tools fire.

‎rust/crates/rusty-claude-cli/src/app.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ mod tests {
386386
fn session_state_tracks_config_values() {
387387
let config = SessionConfig {
388388
model: "claude".into(),
389-
permission_mode: PermissionMode::WorkspaceWrite,
389+
permission_mode: PermissionMode::DangerFullAccess,
390390
config: Some(PathBuf::from("settings.toml")),
391391
output_format: OutputFormat::Text,
392392
};
393393

394394
assert_eq!(config.model, "claude");
395-
assert_eq!(config.permission_mode, PermissionMode::WorkspaceWrite);
395+
assert_eq!(config.permission_mode, PermissionMode::DangerFullAccess);
396396
assert_eq!(config.config, Some(PathBuf::from("settings.toml")));
397397
}
398398
}

‎rust/crates/rusty-claude-cli/src/args.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Cli {
1212
#[arg(long, default_value = "claude-opus-4-6")]
1313
pub model: String,
1414

15-
#[arg(long, value_enum, default_value_t = PermissionMode::WorkspaceWrite)]
15+
#[arg(long, value_enum, default_value_t = PermissionMode::DangerFullAccess)]
1616
pub permission_mode: PermissionMode,
1717

1818
#[arg(long)]
@@ -99,4 +99,10 @@ mod tests {
9999
let logout = Cli::parse_from(["rusty-claude-cli", "logout"]);
100100
assert_eq!(logout.command, Some(Command::Logout));
101101
}
102+
103+
#[test]
104+
fn defaults_to_danger_full_access_permission_mode() {
105+
let cli = Cli::parse_from(["rusty-claude-cli"]);
106+
assert_eq!(cli.permission_mode, PermissionMode::DangerFullAccess);
107+
}
102108
}

‎rust/crates/rusty-claude-cli/src/init.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
44
const STARTER_CLAUDE_JSON: &str = concat!(
55
"{\n",
66
" \"permissions\": {\n",
7-
" \"defaultMode\": \"acceptEdits\"\n",
7+
" \"defaultMode\": \"dontAsk\"\n",
88
" }\n",
99
"}\n",
1010
);
@@ -366,7 +366,7 @@ mod tests {
366366
concat!(
367367
"{\n",
368368
" \"permissions\": {\n",
369-
" \"defaultMode\": \"acceptEdits\"\n",
369+
" \"defaultMode\": \"dontAsk\"\n",
370370
" }\n",
371371
"}\n",
372372
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /