Skip to content

feat: add OpenCode agent support - #1227

Open
chensational wants to merge 1 commit into
slopus:mainfrom
chensational:feat/opencode-agent-support
Open

chensational wants to merge 1 commit into
slopus:mainfrom
chensational:feat/opencode-agent-support

Conversation

@chensational

Copy link
Copy Markdown

Summary

Adds OpenCode as a first-class Happy agent through the existing ACP runner.

The main runtime issue was that OpenCode ACP could crash or hang when Happy sessions shared the large/global OpenCode database. This PR gives Happy-launched OpenCode sessions a per-session OPENCODE_DB under the Happy home directory, while preserving an explicitly configured OPENCODE_DB.

What Changed

  • Adds happy opencode as a dedicated CLI entry point backed by ACP.
  • Lets the daemon spawn OpenCode sessions remotely.
  • Adds OpenCode to CLI availability detection and machine metadata.
  • Adds OpenCode to the app's new-session agent picker, session metadata display, icons, model defaults, and dismissed CLI warning settings.
  • Shows OpenCode only when machine CLI availability reports it detected, matching the other agents.
  • Adds focused tests for ACP args, OpenCode ACP env handling, daemon command resolution, app agent availability, and model options.

Scope Notes

  • PR 2, the iOS/Tailscale dev startup workflow, is intentionally not included here.
  • Existing happy openclaw behavior is preserved.
  • The obsolete opencodeCommand.ts approach is not included.
  • No root dependency, lockfile, temp, cert, Aeon, Playwright, or Tailscale artifact churn is included.
  • The app settings test also updates stale expectations for existing default fields so the focused app test set passes.

Verification

Passed:

pnpm --filter happy typecheck
pnpm --filter happy-app typecheck
pnpm --filter happy-agent typecheck
pnpm --filter happy exec vitest run src/agent/acp/runAcp.test.ts src/agent/acp/acpCliArgs.test.ts src/daemon/run.test.ts src/commands/codexCommand.test.ts
pnpm --filter happy-app exec vitest run sources/components/newSessionAgents.test.ts sources/components/modelModeOptions.test.ts sources/sync/settings.spec.ts
pnpm --filter happy-agent build
pnpm --filter happy-agent exec vitest run src/index.test.ts

Known unrelated existing failure:

pnpm --filter happy-agent exec vitest run

The full happy-agent suite still has 5 stale X-Happy-Client header expectation failures in src/api.test.ts and src/auth.test.ts.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25935d3bcd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

execSync(`command -v ${command} >/dev/null 2>&1`, { stdio: 'ignore' });
return true;
} catch {
return commandExistsInCommonUserPaths(command);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep availability tied to an executable command

When the daemon's PATH does not include one of these common user bin directories (for example a launchd/systemd-started daemon with opencode only at ~/.local/bin/opencode), this fallback reports the CLI as available even though the later OpenCode path still spawns opencode by name with process.env in AcpBackend, not the absolute candidate path or an augmented PATH. The app will offer the agent and the session then fails with ENOENT; either add the discovered directory to the spawned environment or only report true for commands actually resolvable from the daemon environment.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant