refactor: code cleanup #9
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
defineAgentfactory insrc/agent/agent.tsthat encapsulates agent configuration, permissions, prompt setup, and utility methods into a single object, replacing the previous two-phase setup and scattered config functions.src/agent/compaction.tsandsrc/agent/types.ts, consolidating all agent logic into the new pattern. [1] [2]setupAgentConfigand prompt setup logic insrc/agent/index.tswith a single export of the new agent definition system.src/agent/config.tsthat registers all agents, disables legacy agents, and sets up default agent selection using the new agent objects.Documentation and Developer Experience:
AGENTS.mdto 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:
@opencode-ai/plugin,@opencode-ai/sdk, and addedzodfor schema validation. Also updated the build watch script for improved reliability. [1] [2] [3]