add codegraph support for coordinator
Release / release (push) Successful in 7s

This commit is contained in:
2026-09-11 11:19:49 +02:00
parent fb3ad11f3a
commit 4ea9b4a695
3 changed files with 178 additions and 18 deletions
+36
View File
@@ -46,6 +46,9 @@ export default Plugin.define({
Agent.ID.make("build"),
).permissions;
let permissionKey = JSON.stringify(inherited);
let hasCodegraph = false;
let codegraphTools: string[] = [];
let agentTransformReady = false;
const controller = new AbortController();
// Subscribe before the first read: configuration can publish its catalog while
// asynchronous setup is running.
@@ -80,6 +83,31 @@ export default Plugin.define({
let workers: (typeof workerNames)[number][] = [];
const active = new Set<string>();
await context.mcp.transform((editor) => {
hasCodegraph = editor.get("codegraph") !== undefined;
if (hasCodegraph)
editor.update("codegraph", (server) => {
server.codemode = false;
});
});
await context.tool.transform((editor) => {
const next = editor
.list()
.map((tool) => tool.id)
.filter((id) => id.startsWith("codegraph_"))
.sort();
if (JSON.stringify(next) === JSON.stringify(codegraphTools)) return;
codegraphTools = next;
if (agentTransformReady)
queueMicrotask(() => {
void context.agent
.reload()
.catch((error) =>
console.error("stanp-opencode agent reload failed", error),
);
});
});
await context.agent.transform((editor) => {
const deep = selected.mode === "custom" || models.has("gpt-6-astra");
const candidates = workerNames.filter((name) => deep || !name.startsWith("deep-"));
@@ -146,6 +174,13 @@ export default Plugin.define({
.filter((rule) => matches(action, rule.action))
.map((rule) => ({ ...rule, action })),
),
...(hasCodegraph
? codegraphTools.flatMap((action) =>
inherited
.filter((rule) => matches(action, rule.action))
.map((rule) => ({ ...rule, action })),
)
: []),
...workers.map((resource) => ({
action: "subagent",
resource,
@@ -154,6 +189,7 @@ export default Plugin.define({
];
});
});
agentTransformReady = true;
async function assertTodo(agentID: Agent.ID, action: string) {
const { data: agent } = await context.agent.get({ agentID });
const effect =