@serkanalgur/opencode-nexus 1.4.1 → 1.5.0
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 +87 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8846,7 +8846,7 @@ class DashboardModule {
|
|
|
8846
8846
|
this.server = Bun.serve({
|
|
8847
8847
|
port,
|
|
8848
8848
|
hostname: host,
|
|
8849
|
-
fetch(req, server) {
|
|
8849
|
+
async fetch(req, server) {
|
|
8850
8850
|
const url = new URL(req.url);
|
|
8851
8851
|
if (req.method === "OPTIONS") {
|
|
8852
8852
|
return new Response(null, { headers: CORS_HEADERS });
|
|
@@ -8874,14 +8874,20 @@ class DashboardModule {
|
|
|
8874
8874
|
}
|
|
8875
8875
|
try {
|
|
8876
8876
|
const spaPath = join2(process.cwd(), "dashboard", "index.html");
|
|
8877
|
-
const
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
return new Response(spaFile, {
|
|
8877
|
+
const spaContent = await Bun.file(spaPath).text();
|
|
8878
|
+
if (spaContent.length > 100) {
|
|
8879
|
+
return new Response(spaContent, {
|
|
8881
8880
|
headers: { "Content-Type": "text/html; charset=utf-8", ...CORS_HEADERS }
|
|
8882
8881
|
});
|
|
8883
8882
|
}
|
|
8884
|
-
|
|
8883
|
+
return new Response(`SPA not found at ${spaPath} (content: ${spaContent.length} bytes)`, {
|
|
8884
|
+
headers: { "Content-Type": "text/plain", ...CORS_HEADERS }
|
|
8885
|
+
});
|
|
8886
|
+
} catch (e) {
|
|
8887
|
+
return new Response(`SPA error: ${e}`, {
|
|
8888
|
+
headers: { "Content-Type": "text/plain", ...CORS_HEADERS }
|
|
8889
|
+
});
|
|
8890
|
+
}
|
|
8885
8891
|
return new Response("Nexus Dashboard API", {
|
|
8886
8892
|
headers: {
|
|
8887
8893
|
"Content-Type": "text/plain",
|
|
@@ -11094,9 +11100,84 @@ function getTemplate(name) {
|
|
|
11094
11100
|
}
|
|
11095
11101
|
|
|
11096
11102
|
// src/index.ts
|
|
11103
|
+
import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync4, existsSync as existsSync3 } from "node:fs";
|
|
11104
|
+
import { join as join6 } from "node:path";
|
|
11105
|
+
import { homedir as homedir2 } from "node:os";
|
|
11106
|
+
var NEXUS_AGENT_CONTENT = `---
|
|
11107
|
+
description: Nexus multi-agent orchestrator — manages parallel sub-agents with cost-aware routing, self-healing, and intelligent task decomposition.
|
|
11108
|
+
mode: primary
|
|
11109
|
+
---
|
|
11110
|
+
|
|
11111
|
+
# Nexus Orchestrator Agent
|
|
11112
|
+
|
|
11113
|
+
You are the Nexus Orchestrator — an intelligent multi-agent coordinator. You manage parallel sub-agents with cost-aware model selection, self-healing on failures, and DAG-based task execution.
|
|
11114
|
+
|
|
11115
|
+
## Core Capabilities
|
|
11116
|
+
|
|
11117
|
+
- **Spawn specialized sub-agents** for each task (architect, coder, reviewer, tester, explorer, documenter)
|
|
11118
|
+
- **Cost-aware routing** — automatically selects optimal models based on task complexity and budget
|
|
11119
|
+
- **Self-healing** — retries failed tasks, transfers context to new agents, escalates if needed
|
|
11120
|
+
- **Performance tracking** — learns which model/role combinations work best
|
|
11121
|
+
- **Execution history** — tracks all past executions for analysis
|
|
11122
|
+
|
|
11123
|
+
## How to Use Nexus Tools
|
|
11124
|
+
|
|
11125
|
+
### Spawning Agents
|
|
11126
|
+
Use the \`spawn\` tool to create specialized agents:
|
|
11127
|
+
\`\`\`
|
|
11128
|
+
nexus.spawn(role="coder", task="Implement JWT authentication middleware")
|
|
11129
|
+
nexus.spawn(role="reviewer", task="Review the auth implementation for security")
|
|
11130
|
+
\`\`\`
|
|
11131
|
+
|
|
11132
|
+
Available roles: architect, coder, reviewer, tester, explorer, documenter
|
|
11133
|
+
|
|
11134
|
+
### Checking Status
|
|
11135
|
+
\`\`\`
|
|
11136
|
+
nexus.status(detailed=true) — Full orchestrator state
|
|
11137
|
+
nexus.agents(filter="working") — List active agents
|
|
11138
|
+
nexus.costs() — Cost report and budget status
|
|
11139
|
+
\`\`\`
|
|
11140
|
+
|
|
11141
|
+
### Cost Management
|
|
11142
|
+
\`\`\`
|
|
11143
|
+
nexus.forecast(tasks='[...]') — Predict costs
|
|
11144
|
+
nexus.model.costs() — Show real model pricing
|
|
11145
|
+
nexus.preset(name="balanced") — Apply a cost preset
|
|
11146
|
+
\`\`\`
|
|
11147
|
+
|
|
11148
|
+
### Performance & History
|
|
11149
|
+
\`\`\`
|
|
11150
|
+
nexus.performance.scores() — Model/role performance scores
|
|
11151
|
+
nexus.history.list(count=10) — Recent execution history
|
|
11152
|
+
\`\`\`
|
|
11153
|
+
|
|
11154
|
+
## Task Decomposition Strategy
|
|
11155
|
+
|
|
11156
|
+
When given a development request:
|
|
11157
|
+
1. **Analyze** — Break the request into discrete tasks
|
|
11158
|
+
2. **Estimate** — Use nexus.forecast to predict costs
|
|
11159
|
+
3. **Execute** — Spawn agents in parallel where possible
|
|
11160
|
+
4. **Review** — Use nexus.spawn(role="reviewer") for each delivery
|
|
11161
|
+
5. **Report** — Summarize what was done, costs, and outcomes
|
|
11162
|
+
|
|
11163
|
+
## Quality Gates
|
|
11164
|
+
|
|
11165
|
+
Never skip these steps:
|
|
11166
|
+
- Every code change must be reviewed by nexus.spawn(role="reviewer")
|
|
11167
|
+
- Run nexus.security.scan() on new code
|
|
11168
|
+
- Verify with nexus.spawn(role="tester") before marking complete
|
|
11169
|
+
`;
|
|
11097
11170
|
var src_default = define({
|
|
11098
11171
|
id: "nexus",
|
|
11099
11172
|
async setup(ctx) {
|
|
11173
|
+
try {
|
|
11174
|
+
const agentDir = join6(homedir2(), ".config", "opencode", "agents");
|
|
11175
|
+
const agentFile = join6(agentDir, "nexus-orchestrator.md");
|
|
11176
|
+
if (!existsSync3(agentFile)) {
|
|
11177
|
+
mkdirSync4(agentDir, { recursive: true });
|
|
11178
|
+
writeFileSync2(agentFile, NEXUS_AGENT_CONTENT, "utf-8");
|
|
11179
|
+
}
|
|
11180
|
+
} catch {}
|
|
11100
11181
|
const orchestrator = new NexusOrchestrator;
|
|
11101
11182
|
await orchestrator.initialize(ctx, () => {
|
|
11102
11183
|
const state = orchestrator.getState();
|