Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Claudiu is a native desktop app, written in Rust with [Rune](https://github.com/

## What it does

Each session is your own `claude` process in a real terminal, and sign-in stays with Claude Code. Around it, Claudiu adds a sidebar of running and recent sessions, notifications when a background session finishes or asks something, an editor mode (Ctrl+Shift+E), usage meters, a GitHub pane, cards Claude draws inline, sessions that move between git worktrees, extra accounts that share one configuration, and Codex and OpenCode subagents (Settings → Custom subagents). Codex subagents need Node and a `codex login`, OpenCode subagents need `opencode` on PATH, and with Allow edits on, either acts without Claude Code's permission rules. With Codex subagents on, the sidebar also shows Codex's 5-hour and 7-day limits, which Claudiu reads from the session logs in `~/.codex`. Settings lists the rest.
Each session is your own `claude` process in a real terminal, and sign-in stays with Claude Code. Around it, Claudiu adds a sidebar of running and recent sessions, notifications when a background session finishes or asks something, an editor mode (Ctrl+Shift+E), usage meters, a GitHub pane, cards Claude draws inline, sessions that move between git worktrees, extra accounts that share one configuration, and Codex, OpenCode and Google Antigravity subagents (Settings → Custom subagents). Codex subagents need Node and a `codex login`, OpenCode subagents need `opencode` on PATH, Antigravity subagents need the Antigravity CLI (`agy`) installed and signed in, and with Allow edits on, each acts without Claude Code's permission rules. Read-only Antigravity runs from its own folder in Claudiu's data, whose hook refuses every tool but reading and searching, so your own Antigravity rules, skills and MCP servers don't load there. With Codex subagents on, the sidebar also shows Codex's 5-hour and 7-day limits, which Claudiu reads from the session logs in `~/.codex`; with Antigravity subagents on, it shows Antigravity's limits for each group of models, from `agy`'s own `/usage`, asked every five minutes at no token cost. Their last saved readings show at launch and refresh in the background. Settings lists the rest.

While a custom subagent works, its own view in Claude Code's tasks list streams its messages, reasoning, plan and tool steps and command output. The main conversation stays as it is until the subagent hands back its report. The first Codex run takes longer while npm downloads the adapter. Claude can choose a Codex subagent's effort when it starts one (`max` runs as Codex's `xhigh`); otherwise Codex uses the effort in `~/.codex/config.toml`.

A message Claude sends a running Codex subagent reaches it in the task it is working on, and its answer streams like the rest. OpenCode takes such messages too if its version supports them. Otherwise, and once the subagent has finished, Claude Code sends the message as a follow-up.
A message Claude sends a running Codex subagent reaches it in the task it is working on, and its answer streams like the rest. OpenCode takes such messages too if its version supports them. Antigravity and older OpenCode versions get the message as a follow-up once the current turn ends, as does a subagent that has already finished. Antigravity takes the effort Claude asks for, capped at the highest thinking level its model offers.

## What it touches

Claudiu never calls the Anthropic API or deletes a transcript, and it changes Claude Code's settings only when you flip a switch. Its network use is GitHub (the update check and the GitHub pane), plus npm and OpenAI once you turn on Codex subagents, and the providers you set up in OpenCode once you turn on OpenCode subagents. Terminal contents are never logged.
Claudiu never calls the Anthropic API or deletes a transcript, and it changes Claude Code's settings only when you flip a switch. Its network use is GitHub (the update check and the GitHub pane), plus npm and OpenAI once you turn on Codex subagents, the providers you set up in OpenCode once you turn on OpenCode subagents, and Google once you turn on Antigravity subagents. Terminal contents are never logged.

## Development

Expand Down
21 changes: 21 additions & 0 deletions assets/LICENSE-LOBE-ICONS
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 LobeHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 9 additions & 11 deletions mod/hooks/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// paints the live card over them. Claudiu's measured height comes back in `CLAUDIU_VISUAL_PREFIX<call>.rows`.
// - One-shot completions: runs requests from `CLAUDIU_ASK_FILE` (commit messages, session titles) with
// `$.model.complete`, on this session's own client, so Claudiu needs no `claude -p`.
// - Custom subagents: registers the Codex and OpenCode agent types `CLAUDIU_SUBAGENTS` lists. Claude never runs for
// - Custom subagents: registers the provider agent types `CLAUDIU_SUBAGENTS` lists. Claude never runs for
// those agents: each turn is answered here with what the agent writes through `CLAUDIU_EXE --acp`, and its last
// message is handed back with SubagentHandback.

Expand Down Expand Up @@ -56,9 +56,8 @@ let askPoll // watches CLAUDIU_ASK_FILE
let askSeen = null // id of the last request looked at
let asking = false // a completion is running; a poll that finds another request waits for it
const cardRows = new Map() // show_visual call id -> rows reserved for its card
const AGENT_NAMES = { codex: 'Codex', opencode: 'OpenCode' } // the agents of `claude/subagents.rs`, by their key
const AGENT_PREFIX = 'Claudiu:' // what Claude Code puts before an agent type this plugin registers
const customTypes = new Map() // agent type name -> { agent, model, edits } of each custom agent type Claudiu defined
const customTypes = new Map() // agent type name -> { agent, model, edits, name } of each custom agent type Claudiu defined
const customRuns = new Map() // agent id -> { type, prompt, effort, turnId, report, steps } of each custom subagent started
const agentCalls = new Map() // Agent call id -> { type, description, effort } of each running call that asked for an effort
const published = new Set() // call ids whose card file this process wrote from the transcript
Expand Down Expand Up @@ -364,14 +363,14 @@ async function registerSubagents($) {
} catch {
return
}
for (const agent of Object.keys(AGENT_NAMES)) {
for (const agent of Object.keys(agents ?? {})) {
const listing = agents?.[agent]
for (const { name, model, description, prompt } of listing?.types ?? []) {
if (![name, model, description, prompt].every(v => typeof v === 'string')) continue
// Claude never runs for this agent (customStep answers its turns) unless this module lost track of it; the
// prompt then says so.
await $.agent.register({ name, description, prompt, model: 'haiku', tools: [] })
.then(() => customTypes.set(AGENT_PREFIX + name, { agent, model, edits: listing.edits === true }))
.then(() => customTypes.set(AGENT_PREFIX + name, { agent, model, edits: listing.edits === true, name: typeof listing.name === 'string' ? listing.name : agent }))
.catch(() => {})
}
}
Expand Down Expand Up @@ -417,7 +416,7 @@ async function customRun($, agentId) {

// The task for this turn: the newest message to the agent, read from its transcript. A message sent to a finished
// subagent starts a turn of its own, and Claude Code spawns the agent again for it, so the run noted at spawn knows only
// that message. Each turn also starts Codex or OpenCode afresh, so a follow-up carries the first task and the last
// that message. Each turn also starts the provider afresh, so a follow-up carries the first task and the last
// report handed back before it.
async function customTask($, run, agentId) {
const messages = await $.session.messages({ agentId }).catch(() => [])
Expand All @@ -436,14 +435,14 @@ async function customTask($, run, agentId) {

// The report with the steps the agent took added under it. Claude Code counts none of them as the subagent's tool
// calls, so without this list the caller can't tell a report written from the files from one written from the task
// alone.
// alone. The heading says so too: a caller that saw a tool count of 0 has asked for the whole task again.
function withSteps(report, name, steps) {
if (steps.length === 0) return `${report}\n\n---\n${name} ran no steps.`
// A step can be a multi-line command; on one line it can't be mistaken for report text or a step of its own.
const oneLine = steps.map(s => s.replace(/\s+/g, ' ').trim())
const listed = oneLine.slice(0, STEPS_LISTED).map(s => '- ' + (s.length > STEP_CHARS ? s.slice(0, STEP_CHARS - 1) + '…' : s))
if (steps.length > STEPS_LISTED) listed.push(`- and ${steps.length - STEPS_LISTED} more`)
return `${report}\n\n---\nSteps ${name} ran (${steps.length}):\n${listed.join('\n')}`
return `${report}\n\n---\nSteps ${name} ran (${steps.length}), outside Claude Code, which counts them as 0 tool uses:\n${listed.join('\n')}`
}

function displayText(text) {
Expand Down Expand Up @@ -491,8 +490,7 @@ async function* customStep($, e, next, run) {
run.turnId = e.turnId
run.handedBack = 0
run.steps = []
const { agent, model, edits } = customTypes.get(run.type)
const name = AGENT_NAMES[agent]
const { agent, model, edits, name } = customTypes.get(run.type)
yield { kind: 'text', index: 0, text: `${name} on ${model}, ${edits ? 'edits allowed' : 'read-only'}\n\n` }
run.report = null
let previousKind
Expand Down Expand Up @@ -545,7 +543,7 @@ async function* customStep($, e, next, run) {
if (next.signal?.aborted) return
run.report ??= `${name} failed: the helper stopped without an answer.`
}
const message = withSteps(run.report, AGENT_NAMES[customTypes.get(run.type).agent], run.steps)
const message = withSteps(run.report, customTypes.get(run.type).name, run.steps)
if (run.handedBack >= 2) {
yield { kind: 'text', index: 1, text: message }
yield { kind: 'stop', stopReason: 'end_turn', usage: null }
Expand Down
35 changes: 30 additions & 5 deletions mod/hooks/subagents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function type(name: string, model: string) {
return { name, model, description: `Runs the task on ${model}.`, prompt: 'Say the mod lost track.' }
}

const SUBAGENTS = JSON.stringify({ codex: { edits: false, types: [type('codex-gpt-5-5', 'gpt-5.5')] } })
const SUBAGENTS = JSON.stringify({ codex: { name: 'Codex', edits: false, types: [type('codex-gpt-5-5', 'gpt-5.5')] } })

// What the engine answers beneath the mod for a session with Codex on. `helper` is what `claudiu --acp` writes;
// `requests` collects what the mod sent it.
Expand Down Expand Up @@ -65,7 +65,7 @@ test('activity streams in the subagent and leaves the main conversation alone',
expect(text).toContain('Thinking\nChecking the parser.')
expect(text).toContain('▸ Run tests · failed')
expect(text).toContain('Tool output\ntest failed')
expect(JSON.parse(chunks.find(c => c.kind === 'input').json).message).toBe('Parser test failed.\n\n---\nSteps Codex ran (1):\n- Run tests')
expect(JSON.parse(chunks.find(c => c.kind === 'input').json).message).toBe('Parser test failed.\n\n---\nSteps Codex ran (1), outside Claude Code, which counts them as 0 tool uses:\n- Run tests')
})

async function step($: any, turnId: string, index: number, agentId?: string) {
Expand Down Expand Up @@ -187,7 +187,7 @@ test('a Codex subagent runs the task in Codex and hands back its last message',
const tool = chunks.find(c => c.kind === 'tool')
expect(tool.name).toBe('SubagentHandback')
// The report names the steps, since Claude Code counts none of Codex's tool calls as the subagent's.
const report = 'The bug is on line 12.\n\n---\nSteps Codex ran (1):\n- Read src/a.rs'
const report = 'The bug is on line 12.\n\n---\nSteps Codex ran (1), outside Claude Code, which counts them as 0 tool uses:\n- Read src/a.rs'
const input = chunks.filter(c => c.kind === 'input').map(c => c.json).join('')
expect(JSON.parse(input)).toEqual({ message: report })

Expand Down Expand Up @@ -260,7 +260,7 @@ test('a report with many steps lists the first ones, each cut short', async ($,
await $.agent.spawn({ subagentType: 'Claudiu:codex-gpt-5-5', prompt: 'Find the bug' })
const chunks = await step($, 't1', 0, 'a1')
const lines = JSON.parse(chunks.filter(c => c.kind === 'input').map(c => c.json).join('')).message.split('\n')
expect(lines.slice(0, 6)).toEqual(['Done.', '', '---', 'Steps Codex ran (32):', '- ' + 'x'.repeat(119) + '…', '- bash cat <<EOF a EOF'])
expect(lines.slice(0, 6)).toEqual(['Done.', '', '---', 'Steps Codex ran (32), outside Claude Code, which counts them as 0 tool uses:', '- ' + 'x'.repeat(119) + '…', '- bash cat <<EOF a EOF'])
expect(lines.slice(-2)).toEqual(['- Read src/f30.rs', '- and 2 more'])
})

Expand Down Expand Up @@ -304,7 +304,7 @@ test('an OpenCode subagent runs the task in OpenCode and names it', async ($, on
const requests: any[] = []
const subagents = JSON.stringify({
codex: { edits: false, types: [type('codex-gpt-5-5', 'gpt-5.5')] },
opencode: { edits: true, types: [type('opencode-openai-gpt-6-1-sol', 'openai/gpt-6.1-sol')] },
opencode: { name: 'OpenCode', edits: true, types: [type('opencode-openai-gpt-6-1-sol', 'openai/gpt-6.1-sol')] },
})
engine(on, [JSON.stringify({ kind: 'failed', reason: 'opencode was not found on PATH. OpenCode subagents need OpenCode installed.' })], requests, subagents)
await $.session.start({ cwd: '/work', surface: 'terminal', isInteractive: true })
Expand All @@ -317,6 +317,31 @@ test('an OpenCode subagent runs the task in OpenCode and names it', async ($, on
expect(input.message).toBe('OpenCode failed: opencode was not found on PATH. OpenCode subagents need OpenCode installed.\n\n---\nOpenCode ran no steps.')
})

test('Antigravity uses the display name supplied by Claudiu', async ($, on) => {
const requests: any[] = []
const registered = engine(on, [JSON.stringify({ kind: 'report', text: 'Done.' })], requests, JSON.stringify({
antigravity: { name: 'Antigravity', edits: false, types: [type('antigravity-gemini-4-neon', 'gemini-4-neon')] },
}))
await $.session.start({ cwd: '/work', surface: 'terminal', isInteractive: true })
expect(registered.map(r => r.name)).toEqual(['antigravity-gemini-4-neon'])
await $.agent.spawn({ subagentType: 'Claudiu:antigravity-gemini-4-neon', prompt: 'Find the bug' })
const chunks = await step($, 't1', 0, 'a1')
expect(requests[0].input.agent).toBe('antigravity')
expect(chunks.filter(c => c.kind === 'text').map(c => c.text).join('')).toBe('Antigravity on gemini-4-neon, read-only\n\n')
expect(JSON.parse(chunks.find(c => c.kind === 'input').json).message).toContain('Antigravity ran no steps.')
})

test('a provider without a display name falls back to its key', async ($, on) => {
engine(on, [JSON.stringify({ kind: 'report', text: 'Done.' })], [], JSON.stringify({
fourth: { edits: false, types: [type('fourth-model', 'model')] },
}))
await $.session.start({ cwd: '/work', surface: 'terminal', isInteractive: true })
await $.agent.spawn({ subagentType: 'Claudiu:fourth-model', prompt: 'Find the bug' })
const chunks = await step($, 't1', 0, 'a1')
expect(chunks.filter(c => c.kind === 'text').map(c => c.text).join('')).toBe('fourth on model, read-only\n\n')
expect(JSON.parse(chunks.find(c => c.kind === 'input').json).message).toContain('fourth ran no steps.')
})

test('a failure is handed back as the report', async ($, on) => {
engine(on, [JSON.stringify({ kind: 'failed', reason: "Codex isn't signed in. Run `codex login`, then try again." })], [])
await $.session.start({ cwd: '/work', surface: 'terminal', isInteractive: true })
Expand Down
Loading
Loading