agent-orchestrator/backend/internal
Harshit Singh Bhandari 2c08597ee6
refactor(adapters): cut ~3,100 LOC of redundancy in the agent adapter layer (#2349) (#2355)
* refactor(adapters): add shared helpers for adapter dedup (#2349)

Introduce the shared building blocks the per-adapter cleanup will use:
- ports.NormalizePermissionMode (finding 3)
- hookutil.FileExists (finding 10)
- binaryutil.ResolveBinary + BinarySpec (finding 2)
- activitystate.StandardDeriveActivityState (finding 4)
- agentbase.Base embed + StandardSessionInfo (findings 6-9)

No adapters wired up yet; behavior unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor(goose): convert to shared adapter helpers (reference) (#2349)

Reference conversion proving the shared packages against real tests:
- hooks.go collapses onto hooksjson.Manager (finding 1)
- ResolveGooseBinary via binaryutil.BinarySpec (finding 2)
- gooseMode uses ports.NormalizePermissionMode (finding 3)
- activity.go deleted; dispatch points at activitystate (findings 4, 5)
- SessionInfo via agentbase.StandardSessionInfo; Base embed drops the
  GetConfigSpec/GetPromptDeliveryStrategy no-ops (findings 6-8)
- fileExists/atomicWriteFile copies removed (findings 5, 10)

Also adds hooksjson package + activitystate test. goose: 327->~90 LOC.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor(adapters): dedup remaining 22 agent adapters onto shared helpers (#2349)

Applies the shared helpers across every remaining adapter:
- hooksjson.Manager for the matcher-group cohort (claudecode, qwen, droid)
- binaryutil.BinarySpec for 19 binary resolvers (aider/cursor/opencode/codex
  keep their special resolvers; all now use hookutil.FileExists)
- ports.NormalizePermissionMode replaces 15 private copies
- agentbase.Base embed drops the GetConfigSpec/GetPromptDeliveryStrategy no-ops
  (and GetAgentHooks/GetRestoreCommand/SessionInfo no-ops on hookless adapters)
- agentbase.StandardSessionInfo replaces the per-adapter metadata readers
- activitystate.StandardDeriveActivityState via dispatch for the 8 name-only
  derivers; their activity.go files removed (claudecode/codex/droid/agy/opencode
  keep payload-parsing derivers)
- 4 private atomicWriteFile copies missing fsync now use hookutil.AtomicWriteFile
- 23 private fileExists copies removed

Full backend build + vet + test suite green (1647 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore: format with prettier [skip ci]

* fix(binaryutil): preserve per-adapter Windows candidate order (#2349)

Review feedback: the shared resolver hardcoded Windows candidate order as
APPDATA then LOCALAPPDATA, which flipped Kiro's lookup so the npm shim
(%APPDATA%\npm\kiro-cli.*) was probed before the native install
(%LOCALAPPDATA%\Programs\kiro\kiro-cli.exe). A fixed order can't preserve every
adapter's original order (goose/vibe want APPDATA first, kiro wants LOCALAPPDATA
first), so BinarySpec now takes an ordered WinPaths []WinPath list where each
entry names its base (WinAppData/WinLocalAppData/WinHome). Every adapter's list
reproduces its pre-refactor order exactly; kiro's native path is restored to
first.

go build / vet / test all green (1647 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test(adapters): drop unused resolvedBinary writes flagged by govet (#2349)

Embedding agentbase.Base (value receiver) lets govet's unusedwrite analyzer
prove that setting resolvedBinary in tests that only call Base-promoted methods
(GetConfigSpec/GetPromptDeliveryStrategy/SessionInfo/cancellation) is a dead
write. Drop the field from those 23 constructions; GetLaunchCommand/GetRestore
tests that actually read it keep it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* style: gofmt manager_test.go struct alignment (#2349)

Inherited via the merge of main: a SessionRecord literal aligned its Metadata
field across a multi-key line, which gofmt/goimports rejects. One-line reformat
to unblock CI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(adapters): fix stale resolver fallback comments (#2349)

Review nit: 6 Resolve*Binary functions now delegate to binaryutil.ResolveBinary,
which returns a wrapped ports.ErrAgentBinaryNotFound rather than the bare binary
name. Update their doc comments (kiro, vibe, amp, agy, crush, cline) to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-07-04 20:49:15 +05:30
..
adapters refactor(adapters): cut ~3,100 LOC of redundancy in the agent adapter layer (#2349) (#2355) 2026-07-04 20:49:15 +05:30
agentlaunch feat(windows): ConPTY terminal, zellij discovery, agent launcher trampoline, codex shim resolution (#310) 2026-06-18 21:51:05 +05:30
cdc feat: ao session claim-pr + spawn --claim-pr wiring (#101) 2026-06-06 00:01:03 +05:30
cli feat: add agent catalog/auth API and safer orchestrator switching (#2309) 2026-07-04 10:59:34 +05:30
config feat: require explicit project agents (#355) 2026-06-21 06:07:53 +05:30
daemon feat: add agent catalog/auth API and safer orchestrator switching (#2309) 2026-07-04 10:59:34 +05:30
daemonmeta fix(cli): verify daemon ownership before stop signal 2026-06-01 01:45:04 +05:30
domain feat(tracker): GitHub issue intake (backend + dashboard) (#2325) 2026-07-04 02:52:14 +05:30
httpd fix: replace orchestrators through safe canonical branch handoff (#2338) 2026-07-04 11:35:03 +05:30
integration fix(daemon): stop orchestrator id-increment + OS-native daemon liveness link (#2185) 2026-06-26 18:28:32 +05:30
legacyimport feat: Global Settings (migration + update channel) + ao start download progress (#2235) 2026-06-27 23:08:55 +05:30
lifecycle feat: show multi-PR review status (#2193) 2026-06-29 18:20:28 +05:30
notify feat: add notifications v1 (#181) 2026-06-14 20:02:32 +05:30
observe feat: add agent catalog/auth API and safer orchestrator switching (#2309) 2026-07-04 10:59:34 +05:30
ports refactor(adapters): cut ~3,100 LOC of redundancy in the agent adapter layer (#2349) (#2355) 2026-07-04 20:49:15 +05:30
preview fix: clear stale preview URL from SQLite and prevent stale white screen on preview clear (#2358) 2026-07-03 15:38:43 +05:30
process fix: hide backend subprocess windows on Windows (#2179) 2026-06-25 16:21:18 +05:30
processalive refactor: simplify session lifecycle and zellij runtime (#62) 2026-06-01 08:42:49 +05:30
review feat(review): support additional reviewer harnesses (#2306) 2026-07-02 19:25:18 +05:30
runfile feat: add agent catalog/auth API and safer orchestrator switching (#2309) 2026-07-04 10:59:34 +05:30
service fix: replace orchestrators through safe canonical branch handoff (#2338) 2026-07-04 11:35:03 +05:30
session_manager fix: replace orchestrators through safe canonical branch handoff (#2338) 2026-07-04 11:35:03 +05:30
skillassets feat(skills): add using-ao skill, install it under the data dir, and wire it into session prompts (#2365) 2026-07-03 18:11:15 +05:30
storage/sqlite fix: resolve duplicate migration version 20 collision (#2294) 2026-06-30 11:23:54 +05:30
telemetrymeta Feat/posthog error tracking redaction (#329) 2026-06-21 18:50:47 +05:30
terminal Zellij to tmux + ConPTY runtime, session save/restore, crash-proof reconcile (port #404) (#2183) 2026-06-25 15:05:41 +05:30