Skip to content

feat(agents): add cline adapter#133

Closed
yyovil wants to merge 2 commits into
agents/13-devinfrom
agents/14-cline
Closed

feat(agents): add cline adapter#133
yyovil wants to merge 2 commits into
agents/13-devinfrom
agents/14-cline

Conversation

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

Adds the Cline headless agent adapter: binary resolution, launch/restore command building, workspace-local hook installation, activity derivation, and registration in the adapter registry and activity-dispatch map.

  • cline.go / hooks.go / activity.go form the complete adapter: atomic hook-script writes, idempotent install/uninstall that preserves user-authored hooks, and a four-event activity deriver wired into the existing dispatch table.
  • registry.go and activitydispatch/dispatch.go each receive a single-line registration; wiring_test.go extends the resolver smoke-test to cover domain.HarnessCline.

Confidence Score: 5/5

Safe to merge — the adapter is well-structured, the AcceptEdits inversion noted in a previous review has been corrected, and the remaining notes are comment-level clarifications with no runtime impact.

The adapter correctly resolves the binary, builds launch/restore argv, writes atomic hook scripts, and derives activity state. The hook idempotency and user-hook preservation logic are tested end-to-end. The two findings are a misleading inline comment and a note about Cline CLI's binary --auto-approve flag making AcceptEdits and Auto equivalent — neither affects runtime correctness.

backend/internal/adapters/agent/cline/cline.go — the appendApprovalFlags comment for --yolo and the AcceptEdits/Auto equivalence are worth a second glance before merging.

Important Files Changed

Filename Overview
backend/internal/adapters/agent/cline/cline.go Core adapter — binary resolution, launch/restore commands, SessionInfo, and appendApprovalFlags. The AcceptEdits inversion from a previous review has been fixed; a misleading comment remains on the --yolo arm.
backend/internal/adapters/agent/cline/hooks.go Installs/uninstalls workspace-local hook scripts; atomic write, idempotent install, user-hook preservation all implemented correctly.
backend/internal/adapters/agent/cline/activity.go Activity deriver maps the four AO hook sub-commands to the expected domain states; fallback to the lifecycle reaper is documented.
backend/internal/adapters/agent/cline/cline_test.go Comprehensive tests covering launch flags, restore command, session info, hook install/uninstall idempotency, and context cancellation.
backend/internal/adapters/agent/registry/registry.go cline.New() appended to Constructors(); clean, single-edit registration pattern.
backend/internal/adapters/agent/activitydispatch/dispatch.go "cline" token registered to cline.DeriveActivityState; consistent with every other adapter in the map.
backend/internal/daemon/wiring_test.go domain.HarnessCline added to the resolver smoke-test table; validates end-to-end wiring from harness token to registered adapter.

Sequence Diagram

sequenceDiagram
    participant AO as AO Daemon
    participant Plugin as cline.Plugin
    participant FS as Filesystem
    participant Cline as Cline CLI
    participant Dispatch as activitydispatch

    AO->>Plugin: GetAgentHooks(WorkspaceHookConfig)
    Plugin->>FS: atomicWriteFile(TaskStart, UserPromptSubmit, PreToolUse, TaskCancel)
    FS-->>Plugin: ok
    AO->>Plugin: GetLaunchCommand(LaunchConfig)
    Plugin-->>AO: cline --json flags -- prompt
    AO->>Cline: exec
    Cline->>FS: TaskStart hook
    FS->>Dispatch: ao hooks cline session-start
    Dispatch-->>FS: ActivityActive
    FS-->>Cline: cancel false
    Cline->>FS: PreToolUse hook
    FS->>Dispatch: ao hooks cline permission-request
    Dispatch-->>FS: ActivityWaitingInput
    FS-->>Cline: cancel false
    Cline->>FS: TaskCancel hook
    FS->>Dispatch: ao hooks cline stop
    Dispatch-->>FS: ActivityIdle
    FS-->>Cline: cancel false
Loading

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

Comment thread backend/internal/adapters/agent/cline/cline.go Outdated
Registers the cline harness, stacked on the agent platform. Includes its own activity deriver.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yyovil yyovil force-pushed the agents/13-devin branch from baeef77 to 0cb96f6 Compare June 6, 2026 03:31
@yyovil yyovil force-pushed the agents/14-cline branch from 4a34b6c to 3925e6b Compare June 6, 2026 03:31
* feat(agents): add kimi adapter

Registers the kimi harness, stacked on the agent platform.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agents/kimi): drop approval flags on -p and --session paths

Kimi rejects `--prompt` combined with `--yolo`/`--auto`/`--plan`, and
rejects `--yolo`/`--auto` combined with `--session`/`--continue`
(non-interactive and resumed sessions inherit the auto permission
policy). The previous mapping appended one of those flags before `-p`
on every launch and before `--session` on every restore, so every
non-interactive launch would fail at startup. The local binary
(v1.37.0) additionally has no `--auto` option at all, which would
fail even on otherwise-permissible paths.

- GetLaunchCommand: emit approval flags only on the interactive path
  (no prompt). The `-p <prompt>` path is now bare.
- GetRestoreCommand: never emit approval flags; resumed sessions
  inherit the original session's approval settings.
- Tests assert no approval/plan flag leaks onto either path for any
  PermissionMode, and keep the interactive mapping unchanged.

Refs: https://moonshotai.github.io/kimi-code/en/reference/kimi-command.html

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: harshitsinghbhandari <24b4506@iitb.ac.in>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yyovil has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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