Skip to content

feat(agents): add kilocode adapter#136

Closed
yyovil wants to merge 1 commit into
agents/16-kirofrom
agents/17-kilocode
Closed

feat(agents): add kilocode adapter#136
yyovil wants to merge 1 commit into
agents/16-kirofrom
agents/17-kilocode

Conversation

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

Adds the kilocode agent adapter — a fork of sst/opencode — following the same two-layer bridge pattern used by the opencode adapter: an embedded TypeScript plugin installs into .kilocode/plugins/ to forward lifecycle events, and a Go adapter registers the deriver and builds launch/restore argv.

  • Go adapter (kilocode.go, hooks.go, activity.go): Implements the full ports.Agent interface — binary resolution with cache, permission mode delivery via KILO_CONFIG_CONTENT env (the TUI has no --auto flag), atomic sentinel-guarded plugin install/uninstall, and a four-event activity deriver (session-start, user-prompt-submit, permission-request, stop).
  • TypeScript plugin (ao-activity.ts): Bridges Kilo's native events (session.created, message.updated, message.part.updated, session.status, permission.ask) to AO hook calls via Bun.spawnSync with a 30 s timeout; includes a MESSAGE_STORE_MAX = 256 guard on messageStore.
  • Registration: registry.Constructors(), dispatch.Derivers, and the wiring integration test are all updated; test coverage includes every permission mode, hook lifecycle, foreign-file protection, and context cancellation.

Confidence Score: 5/5

Safe to merge; the adapter is self-contained, follows the established opencode/codex pattern, and is well-tested.

The adapter is a clean, well-tested addition of a new agent harness. All hooks are sentinel-guarded, writes are atomic, and the activity dispatch and registry wiring are correct. The only finding is a minor bounded-growth omission in the TypeScript plugin's promptReports map — symmetric with the messageStore cap already added in this PR — which has no correctness impact on normal-path behavior.

No files require special attention.

Important Files Changed

Filename Overview
backend/internal/adapters/agent/kilocode/assets/ao-activity.ts TypeScript plugin bridging Kilo lifecycle events to AO hooks; messageStore is now bounded (MESSAGE_STORE_MAX=256) but promptReports has no equivalent cap and grows linearly with user messages in a long session.
backend/internal/adapters/agent/kilocode/hooks.go Installs/uninstalls AO's plugin file using sentinel-guarded atomic writes; foreign-file protection and idempotency are well-handled.
backend/internal/adapters/agent/kilocode/kilocode.go Main adapter: binary resolution with cache, permission env prefix rendering, launch/restore/session-info commands — clean and mirrors the opencode/codex pattern throughout.
backend/internal/adapters/agent/kilocode/kilocode_test.go Comprehensive tests: all permission modes, hook install/uninstall/foreign-file guards, restore command, session info, activity deriver, and context cancellation.
backend/internal/adapters/agent/kilocode/activity.go Simple DeriveActivityState switch mapping the four managed events to AO domain states; correct and minimal.
backend/internal/adapters/agent/activitydispatch/dispatch.go Registers kilocode deriver in the Derivers map alongside the other adapters; no logic change.
backend/internal/adapters/agent/registry/registry.go Adds kilocode.New() to Constructors(); one-line registration following the existing pattern.
backend/internal/daemon/wiring_test.go Adds domain.HarnessKilocode to the resolver integration test; straightforward extension of existing test table.

Sequence Diagram

sequenceDiagram
    participant K as Kilo Code CLI
    participant P as ao-activity.ts plugin
    participant AO as ao hooks kilocode

    K->>P: "session.created { id }"
    P->>AO: "session-start { session_id }"
    Note over AO: DeriveActivityState → ActivityActive

    K->>P: "message.updated { role:user, id, sessionID }"
    P->>P: rememberMessage(id, msg)
    P->>AO: "user-prompt-submit { session_id, prompt:"" }"
    Note over AO: DeriveActivityState → ActivityActive

    K->>P: "message.part.updated { messageID, type:text, text }"
    P->>P: lookup msg in messageStore
    P->>AO: "user-prompt-submit { session_id, prompt:text }"
    P->>P: messageStore.delete(messageID)

    K->>P: "permission.ask { sessionID }"
    P->>AO: "permission-request { session_id }"
    Note over AO: DeriveActivityState → ActivityWaitingInput

    K->>P: "session.status { status.type:"idle", sessionID }"
    P->>AO: "stop { session_id }"
    Note over AO: DeriveActivityState → ActivityIdle
Loading

Reviews (2): Last reviewed commit: "feat(agents): add kilocode adapter" | Re-trigger Greptile

Comment thread backend/internal/adapters/agent/kilocode/kilocode.go
Comment thread backend/internal/adapters/agent/kilocode/assets/ao-activity.ts
Registers the kilocode harness, stacked on the agent platform. Includes its own activity deriver.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants