Skip to content

Commit 594623a

Browse files
author
SolonCode
committed
重构配置器初始化逻辑,提前加载命令并提取服务器添加方法
1 parent 3ce10c0 commit 594623a

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

soloncode-cli/src/main/java/org/noear/solon/codecli/Configurator.java

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,32 @@ public HarnessEngine agentRuntime(AgentSettings settings) throws Exception {
134134
engine.addMount(MountDir.builder().alias("@global-agents").type(MountType.AGENTS).path("~/" + engine.getHarnessAgents()).primary(true).build());
135135
engine.addMount(MountDir.builder().alias("@workspace-agents").type(MountType.AGENTS).path("./" + engine.getHarnessAgents()).primary(true).build());
136136

137+
138+
engine.getCommandRegistry().load(Paths.get(AgentFlags.getUserHome(), engine.getHarnessCommands()));
139+
engine.getCommandRegistry().load(Paths.get(workspace, engine.getHarnessCommands()));
140+
141+
engine.getCommandRegistry().register(new ExitCommand());
142+
engine.getCommandRegistry().register(new ClearCommand());
143+
engine.getCommandRegistry().register(new ContinueCommand());
144+
engine.getCommandRegistry().register(new RerunCommand());
145+
engine.getCommandRegistry().register(new RewindCommand());
146+
engine.getCommandRegistry().register(new ModelCommand());
147+
148+
engine.getLspTalent().setEnabled(settings.getGeneral().getLspEnabled());
149+
150+
RunUtil.async(() -> addServers(engine));
151+
152+
// loop scheduler
153+
this.loopScheduler = new LoopScheduler(engine, AgentFlags.getHarnessLoopWorktrees());
154+
engine.getCommandRegistry().register(new LoopCommand(loopScheduler));
155+
156+
157+
engine.addExtension(new ManagerExtension(engine, agentSettings));
158+
159+
return engine;
160+
}
161+
162+
private void addServers(HarnessEngine engine){
137163
for (Map.Entry<String, McpServerDo> entry : agentSettings.getMcpServers().entrySet()) {
138164
engine.addMcpServer(entry.getKey(), entry.getValue());
139165
}
@@ -163,26 +189,6 @@ public HarnessEngine agentRuntime(AgentSettings settings) throws Exception {
163189
addSystemLspServer(engine, agentSettings, "kotlin", Arrays.asList("kotlin-language-server"), Arrays.asList(".kt", ".kts"));
164190
addSystemLspServer(engine, agentSettings, "yaml", Arrays.asList("yaml-language-server", "--stdio"), Arrays.asList(".yaml", ".yml"));
165191

166-
engine.getCommandRegistry().load(Paths.get(AgentFlags.getUserHome(), engine.getHarnessCommands()));
167-
engine.getCommandRegistry().load(Paths.get(workspace, engine.getHarnessCommands()));
168-
169-
engine.getCommandRegistry().register(new ExitCommand());
170-
engine.getCommandRegistry().register(new ClearCommand());
171-
engine.getCommandRegistry().register(new ContinueCommand());
172-
engine.getCommandRegistry().register(new RerunCommand());
173-
engine.getCommandRegistry().register(new RewindCommand());
174-
engine.getCommandRegistry().register(new ModelCommand());
175-
176-
engine.getLspTalent().setEnabled(settings.getGeneral().getLspEnabled());
177-
178-
// loop scheduler
179-
this.loopScheduler = new LoopScheduler(engine, AgentFlags.getHarnessLoopWorktrees());
180-
engine.getCommandRegistry().register(new LoopCommand(loopScheduler));
181-
182-
183-
engine.addExtension(new ManagerExtension(engine, agentSettings));
184-
185-
return engine;
186192
}
187193

188194
@Init

0 commit comments

Comments
 (0)