feat(agents): add qwen adapter#127
Conversation
Greptile SummaryThis PR adds the Qwen Code agent adapter, following the same pattern as the existing cursor adapter: a
Confidence Score: 4/5Safe to merge after addressing the missing fsync in the local atomic-write helper. The hook writer in qwen/hooks.go re-implements atomicWriteFile locally instead of using the shared hookutil.AtomicWriteFile, and the local copy skips tmp.Sync(). Without the fsync, a power loss or kernel panic after the rename but before OS writeback can leave the .qwen/settings.json file empty, silently disabling all Qwen hooks. All other changed files are correct and consistent with the existing adapter pattern. backend/internal/adapters/agent/qwen/hooks.go — the atomicWriteFile implementation Important Files Changed
Sequence DiagramsequenceDiagram
participant AO as AO Daemon
participant QP as qwen.Plugin
participant FS as .qwen/settings.json
participant QB as qwen binary
AO->>QP: GetAgentHooks(ctx, cfg)
QP->>FS: readQwenSettings()
FS-->>QP: topLevel + rawHooks
QP->>QP: groupQwenHooksByEvent()
loop each managed event
QP->>QP: parseQwenHookType()
QP->>QP: qwenHookCommandExists() → skip duplicates
QP->>QP: addQwenHook()
QP->>QP: marshalQwenHookType()
end
QP->>FS: writeQwenSettings() → atomicWriteFile()
AO->>QP: GetLaunchCommand(ctx, cfg)
QP->>QP: qwenBinary() → ResolveQwenBinary()
QP-->>AO: [qwen, --approval-mode, mode, -p, prompt]
QB-->>AO: hook fires (SessionStart / UserPromptSubmit / Stop / PermissionRequest)
AO->>AO: DeriveActivityState(event) → ActivityState
Reviews (2): Last reviewed commit: "feat(agents): add qwen adapter" | Re-trigger Greptile |
Registers the qwen harness, stacked on the agent platform. Includes its own activity deriver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Re-verified both findings independently against live upstream Qwen Code sources. Both refuted — no code changes required. Finding 1: Hook event-name casing — REFUTEDUpstream docs ( The adapter already writes PascalCase JSON keys — see var qwenManagedHooks = []qwenHookSpec{
{Event: "SessionStart", Matcher: &qwenStartupMatcher, Command: qwenHookCommandPrefix + "session-start"},
{Event: "UserPromptSubmit", Command: qwenHookCommandPrefix + "user-prompt-submit"},
{Event: "PermissionRequest", Command: qwenHookCommandPrefix + "permission-request"},
{Event: "Stop", Command: qwenHookCommandPrefix + "stop"},
}
Tests confirm this:
Finding 2:
|
Adds the qwen harness, stacked on #119 (agent platform). Adapter package +
Constructors()registration + resolver test. Includes its own activity deriver.🤖 Generated with Claude Code
Stack