Skip to content

Conversation

@ian-pascoe
Copy link
Contributor

This pull request introduces a major refactor of the agent system, shifting from a scattered, function-based configuration and setup approach to a unified, object-oriented "defineAgent" pattern. It centralizes agent logic, simplifies agent registration, and standardizes configuration and prompt setup. The changes also update the documentation to reflect the new architecture and improve developer guidance, and update dependencies to the latest versions.

The most important changes are:

Agent System Refactor:

  • Introduced a new defineAgent factory in src/agent/agent.ts that encapsulates agent configuration, permissions, prompt setup, and utility methods into a single object, replacing the previous two-phase setup and scattered config functions.
  • Removed legacy agent setup/configuration files and types, including src/agent/compaction.ts and src/agent/types.ts, consolidating all agent logic into the new pattern. [1] [2]
  • Replaced the old setupAgentConfig and prompt setup logic in src/agent/index.ts with a single export of the new agent definition system.
  • Added a new centralized agent configuration loader in src/agent/config.ts that registers all agents, disables legacy agents, and sets up default agent selection using the new agent objects.

Documentation and Developer Experience:

  • Completely rewrote AGENTS.md to document the new architecture, including the "defineAgent" pattern, AsyncLocalStorage context usage, directory structure, naming conventions, anti-patterns, and security considerations. The new doc is much more comprehensive and actionable for developers.

Dependency and Build Updates:

  • Updated dependencies to the latest versions for @opencode-ai/plugin, @opencode-ai/sdk, and added zod for schema validation. Also updated the build watch script for improved reliability. [1] [2] [3]

@ian-pascoe ian-pascoe self-assigned this Jan 23, 2026
@ian-pascoe ian-pascoe changed the title Refactor/code cleanup refactor: code cleanup Jan 24, 2026
@ian-pascoe ian-pascoe merged commit 94ebdb1 into main Jan 24, 2026
2 checks passed
@ian-pascoe ian-pascoe deleted the refactor/code-cleanup branch January 24, 2026 10:44
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