@serkanalgur/opencode-nexus 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -0
- package/dist/tui.js +99 -71
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11455,6 +11455,24 @@ The currency of the whole orchestration is the **validated commit**: a delivery
|
|
|
11455
11455
|
|
|
11456
11456
|
Execute the five phases in order. Never skip the quality gate.
|
|
11457
11457
|
|
|
11458
|
+
## ⛔ STRICT RULE: You Are an Orchestrator, Not a Worker
|
|
11459
|
+
|
|
11460
|
+
**You NEVER do the work yourself. You ONLY decompose and delegate.**
|
|
11461
|
+
|
|
11462
|
+
This means:
|
|
11463
|
+
- **NEVER read source files yourself** — delegate to nexus.spawn(role="explorer")
|
|
11464
|
+
- **NEVER write code yourself** — delegate to nexus.spawn(role="coder")
|
|
11465
|
+
- **NEVER review code yourself** — delegate to nexus.spawn(role="reviewer")
|
|
11466
|
+
- **NEVER write tests yourself** — delegate to nexus.spawn(role="tester")
|
|
11467
|
+
- **NEVER explore codebases yourself** — delegate to nexus.spawn(role="explorer")
|
|
11468
|
+
- **NEVER write documentation yourself** — delegate to nexus.spawn(role="documenter")
|
|
11469
|
+
|
|
11470
|
+
Your job is to: analyze the request → decompose into tasks → select models → spawn agents → monitor progress → review results → integrate. Nothing else.
|
|
11471
|
+
|
|
11472
|
+
If you find yourself reading a file, STOP. Spawn an explorer agent instead.
|
|
11473
|
+
If you find yourself writing code, STOP. Spawn a coder agent instead.
|
|
11474
|
+
If you find yourself thinking "I'll just quickly check this", STOP. Spawn an explorer agent.
|
|
11475
|
+
|
|
11458
11476
|
## ⛔ STRICT RULE: Agent Spawning
|
|
11459
11477
|
|
|
11460
11478
|
**NEVER use OpenCode's built-in \`subagent\` tool. It bypasses Nexus entirely — no cost tracking, no sidebar updates, no self-healing, no session linking.**
|
package/dist/tui.js
CHANGED
|
@@ -34745,89 +34745,117 @@ var tui_default = define({
|
|
|
34745
34745
|
});
|
|
34746
34746
|
let lastPollTime = 0;
|
|
34747
34747
|
const pollChildSessions = () => {
|
|
34748
|
-
|
|
34749
|
-
|
|
34750
|
-
|
|
34751
|
-
|
|
34752
|
-
|
|
34753
|
-
|
|
34754
|
-
|
|
34755
|
-
|
|
34756
|
-
|
|
34757
|
-
|
|
34758
|
-
|
|
34759
|
-
|
|
34760
|
-
|
|
34761
|
-
|
|
34762
|
-
|
|
34763
|
-
|
|
34764
|
-
|
|
34765
|
-
|
|
34766
|
-
|
|
34767
|
-
|
|
34768
|
-
|
|
34769
|
-
|
|
34770
|
-
|
|
34771
|
-
|
|
34772
|
-
|
|
34773
|
-
if (!session)
|
|
34774
|
-
return null;
|
|
34775
|
-
const meta = session.metadata || {};
|
|
34776
|
-
return {
|
|
34777
|
-
id,
|
|
34778
|
-
name: meta.nexusRole ? `${meta.nexusRole.charAt(0).toUpperCase() + meta.nexusRole.slice(1)}` : session?.title || id.slice(0, 12),
|
|
34779
|
-
role: meta.nexusRole || "agent",
|
|
34780
|
-
status: context.data.session.status(id) === "running" ? "working" : "completed",
|
|
34781
|
-
model: meta.nexusModel || "",
|
|
34782
|
-
sessionID: id,
|
|
34783
|
-
spawnedAt: new Date().toISOString(),
|
|
34784
|
-
tasksCompleted: 0,
|
|
34785
|
-
tasksFailed: 0
|
|
34786
|
-
};
|
|
34787
|
-
}).filter(Boolean);
|
|
34788
|
-
if (newAgents.length > 0) {
|
|
34789
|
-
setSidebarState((draft) => {
|
|
34790
|
-
for (const agent of newAgents) {
|
|
34791
|
-
const existing = draft.agents.find((a) => a.sessionID === agent.sessionID);
|
|
34792
|
-
if (existing) {
|
|
34793
|
-
existing.status = agent.status;
|
|
34794
|
-
existing.name = agent.name;
|
|
34795
|
-
existing.model = agent.model;
|
|
34796
|
-
} else {
|
|
34797
|
-
draft.agents.push(agent);
|
|
34748
|
+
try {
|
|
34749
|
+
const now = Date.now();
|
|
34750
|
+
if (now - lastPollTime < 2000)
|
|
34751
|
+
return;
|
|
34752
|
+
lastPollTime = now;
|
|
34753
|
+
const currentRoute = context.ui.router.current();
|
|
34754
|
+
if (!currentRoute || currentRoute.type !== "session")
|
|
34755
|
+
return;
|
|
34756
|
+
const currentSessionID = currentRoute.sessionID;
|
|
34757
|
+
if (!currentSessionID)
|
|
34758
|
+
return;
|
|
34759
|
+
const family = context.data.session.family(currentSessionID);
|
|
34760
|
+
if (!family || !Array.isArray(family))
|
|
34761
|
+
return;
|
|
34762
|
+
const childIDs = family.filter((id) => id !== currentSessionID);
|
|
34763
|
+
try {
|
|
34764
|
+
const allSessions = context.data.session.list();
|
|
34765
|
+
if (allSessions && Array.isArray(allSessions)) {
|
|
34766
|
+
for (const s of allSessions) {
|
|
34767
|
+
if (!s || !s.id)
|
|
34768
|
+
continue;
|
|
34769
|
+
const meta = s.metadata;
|
|
34770
|
+
if (meta?.nexusRole && !childIDs.includes(s.id) && s.id !== currentSessionID) {
|
|
34771
|
+
childIDs.push(s.id);
|
|
34772
|
+
}
|
|
34798
34773
|
}
|
|
34799
34774
|
}
|
|
34800
|
-
|
|
34801
|
-
|
|
34802
|
-
|
|
34775
|
+
} catch {}
|
|
34776
|
+
if (childIDs.length === 0) {
|
|
34777
|
+
setSidebarState((draft) => {
|
|
34778
|
+
draft.agents = draft.agents.filter((a) => a.status === "completed" || a.status === "failed");
|
|
34779
|
+
});
|
|
34780
|
+
return;
|
|
34781
|
+
}
|
|
34782
|
+
const newAgents = childIDs.map((id) => {
|
|
34783
|
+
try {
|
|
34784
|
+
const session = context.data.session.get(id);
|
|
34785
|
+
if (!session)
|
|
34786
|
+
return null;
|
|
34787
|
+
const meta = session.metadata || {};
|
|
34788
|
+
let status = "completed";
|
|
34789
|
+
try {
|
|
34790
|
+
status = context.data.session.status(id) === "running" ? "working" : "completed";
|
|
34791
|
+
} catch {}
|
|
34792
|
+
return {
|
|
34793
|
+
id,
|
|
34794
|
+
name: meta.nexusRole ? `${meta.nexusRole.charAt(0).toUpperCase() + meta.nexusRole.slice(1)}` : session?.title || id.slice(0, 12),
|
|
34795
|
+
role: meta.nexusRole || "agent",
|
|
34796
|
+
status,
|
|
34797
|
+
model: meta.nexusModel || "",
|
|
34798
|
+
sessionID: id,
|
|
34799
|
+
spawnedAt: new Date().toISOString(),
|
|
34800
|
+
tasksCompleted: 0,
|
|
34801
|
+
tasksFailed: 0
|
|
34802
|
+
};
|
|
34803
|
+
} catch {
|
|
34804
|
+
return null;
|
|
34805
|
+
}
|
|
34806
|
+
}).filter(Boolean);
|
|
34807
|
+
if (newAgents.length > 0) {
|
|
34808
|
+
setSidebarState((draft) => {
|
|
34809
|
+
for (const agent of newAgents) {
|
|
34810
|
+
const existing = draft.agents.find((a) => a.sessionID === agent.sessionID);
|
|
34811
|
+
if (existing) {
|
|
34812
|
+
existing.status = agent.status;
|
|
34813
|
+
existing.name = agent.name;
|
|
34814
|
+
existing.model = agent.model;
|
|
34815
|
+
} else {
|
|
34816
|
+
draft.agents.push(agent);
|
|
34817
|
+
}
|
|
34818
|
+
}
|
|
34819
|
+
draft.agents = draft.agents.filter((a) => a.sessionID && childIDs.includes(a.sessionID) || a.status === "completed" || a.status === "failed");
|
|
34820
|
+
});
|
|
34821
|
+
}
|
|
34822
|
+
} catch {}
|
|
34803
34823
|
};
|
|
34804
34824
|
const unsubSessionSucceeded = context.data.on("session.execution.succeeded", (event) => {
|
|
34805
|
-
|
|
34806
|
-
|
|
34807
|
-
|
|
34808
|
-
|
|
34809
|
-
agent
|
|
34810
|
-
|
|
34811
|
-
|
|
34812
|
-
|
|
34825
|
+
try {
|
|
34826
|
+
const sessionId = event.data.sessionID;
|
|
34827
|
+
setSidebarState((draft) => {
|
|
34828
|
+
const agent = draft.agents.find((a) => a.sessionID === sessionId);
|
|
34829
|
+
if (agent) {
|
|
34830
|
+
agent.status = "completed";
|
|
34831
|
+
agent.tasksCompleted++;
|
|
34832
|
+
}
|
|
34833
|
+
});
|
|
34834
|
+
} catch {}
|
|
34813
34835
|
});
|
|
34814
34836
|
const unsubSessionFailed = context.data.on("session.execution.failed", (event) => {
|
|
34815
|
-
|
|
34816
|
-
|
|
34817
|
-
|
|
34818
|
-
|
|
34819
|
-
agent
|
|
34820
|
-
|
|
34821
|
-
|
|
34822
|
-
|
|
34837
|
+
try {
|
|
34838
|
+
const sessionId = event.data.sessionID;
|
|
34839
|
+
setSidebarState((draft) => {
|
|
34840
|
+
const agent = draft.agents.find((a) => a.sessionID === sessionId);
|
|
34841
|
+
if (agent) {
|
|
34842
|
+
agent.status = "failed";
|
|
34843
|
+
agent.tasksFailed++;
|
|
34844
|
+
}
|
|
34845
|
+
});
|
|
34846
|
+
} catch {}
|
|
34823
34847
|
});
|
|
34824
34848
|
const unsubSessionCreated = context.data.on("session.created", (event) => {
|
|
34825
|
-
|
|
34849
|
+
try {
|
|
34850
|
+
setTimeout(pollChildSessions, 100);
|
|
34851
|
+
} catch {}
|
|
34826
34852
|
});
|
|
34827
34853
|
const unsubSidebar = context.ui.slot({
|
|
34828
34854
|
append: "sidebar.content",
|
|
34829
34855
|
render: (props) => {
|
|
34830
|
-
|
|
34856
|
+
try {
|
|
34857
|
+
pollChildSessions();
|
|
34858
|
+
} catch {}
|
|
34831
34859
|
const agents = sidebarState.agents;
|
|
34832
34860
|
if (!agents || agents.length === 0) {
|
|
34833
34861
|
return null;
|