refactor(appkit): split the agents plugin into focused modules (stacked on #543) - #547
Open
MarioCadenas wants to merge 4 commits into
Open
refactor(appkit): split the agents plugin into focused modules (stacked on #543)#547MarioCadenas wants to merge 4 commits into
MarioCadenas wants to merge 4 commits into
Conversation
…ules Step 1 of splitting the ~2.5k-line agents plugin. Moves module-scope pure functions/constants out of agents.ts verbatim (behavior-preserving): - approval.ts requiresApproval - prompt.ts composePromptForAgent - builtin-tools.ts LOAD_SKILL_TOOL_DEF, READ_SKILL_FILE_TOOL_DEF - adapter-extensions.ts buildAdapterExtensions, supervisorToolDescription, warnOnCapabilityMismatch agents.ts: 2512 -> 2331 lines. typecheck + 394 agent tests green. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
…ader Step 2 of splitting the agents plugin. Moves skill discovery, per-agent catalog resolution, and the load_skill/read_skill_file dispatch into skill-loader.ts as free functions; the class keeps thin delegators (call sites unchanged) and skillWorkspaceClient() as the OBO credential seam. agents.ts: 2331 -> 2152 lines. typecheck + 394 agent tests green. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
Step 3 of splitting the agents plugin. Moves the decoupled boot-time assembly helpers into registry.ts: loadCodeAgents, hasCodeAgentSources (now internal), resolveDefaultAgent, and the AgentSource type. buildAgentRegistry stays as the orchestrator that wires them. Also merges a duplicate import in skill-loader.ts. agents.ts: 2152 -> 2088 lines. typecheck + 394 agent tests green. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
…tch.ts Step 4 (final) of splitting the agents plugin. Moves dispatchToolCall + runSubAgent — the tool-call budget, approval gate, and sub-agent recursion — into tool-dispatch.ts as free functions over RunState + a ToolDispatchDeps object. The plugin builds deps via toolDispatchDeps(); the two executeTool closures call the free function. RunState moves with them. Tests updated to invoke the free functions (deps built from the plugin's own builder). agents.ts: 2088 -> 1839 lines (2512 -> 1839 across all four steps). typecheck + 394 agent tests green. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Behavior-preserving refactor of the ~2,500-line
agents.tsgod-file into focused modules. Stacked on #543 (it only touchesagents.ts, which #543 owns) — independent of #544.No behavior changes: every commit keeps
pnpm --filter=@databricks/appkit typecheckand the agent test suite (394 tests) green.agents.ts: 2,512 → 1,839 lines (−673, ~27%). The plugin is now an orchestrator (registry wiring + route handlers + SSE plumbing) delegating cohesive concerns to focused modules.Commits
approval.ts,prompt.ts,builtin-tools.ts,adapter-extensions.ts(module-scope pure functions/constants). 2512 → 2331.skill-loader.ts(discovery, catalog resolution,load_skill/read_skill_filedispatch). 2331 → 2152.registry.ts(loadCodeAgents,hasCodeAgentSources,resolveDefaultAgent,AgentSource).buildAgentRegistrystays as the orchestrator. 2152 → 2088.tool-dispatch.ts(RunState+dispatchToolCall+runSubAgent: tool-call budget, approval gate, sub-agent recursion) as free functions over aToolDispatchDepsobject. 2088 → 1839.Notes
skillWorkspaceClient()stays as the OBO credential seam.buildToolIndex+ the HTTP handlers — they're context/MCP-coupled orchestration where extraction would widen interfaces more than it'd clarify (a wide dependency interface fails the deep-module test).dispatch-tool-call.test.ts/dos-limits.test.tsupdated to call the now-freedispatchToolCall/runSubAgent, building deps via the plugin's owntoolDispatchDeps().Merge order
Stacked on #543; auto-retargets to
mainonce #543 merges. Merge after #543.