@backburner/cli 0.1.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/LICENSE +21 -0
- package/README.md +329 -0
- package/dist/src/agents/antigravity-launch.js +162 -0
- package/dist/src/agents/antigravity.js +251 -0
- package/dist/src/agents/claude-launch.js +117 -0
- package/dist/src/agents/claude.js +271 -0
- package/dist/src/agents/codex-launch.js +82 -0
- package/dist/src/agents/codex.js +261 -0
- package/dist/src/agents/composite-runner.js +13 -0
- package/dist/src/agents/extraction.js +442 -0
- package/dist/src/agents/failure-feedback.js +132 -0
- package/dist/src/agents/gemini-launch.js +96 -0
- package/dist/src/agents/gemini.js +392 -0
- package/dist/src/agents/job-agent-assignments.js +180 -0
- package/dist/src/agents/lifecycle-feedback.js +147 -0
- package/dist/src/agents/limit-detector.js +83 -0
- package/dist/src/agents/opencode-launch.js +138 -0
- package/dist/src/agents/opencode.js +156 -0
- package/dist/src/agents/plan-breakdown-feedback.js +97 -0
- package/dist/src/agents/pool.js +168 -0
- package/dist/src/agents/prompt.js +462 -0
- package/dist/src/agents/provider-sessions.js +105 -0
- package/dist/src/agents/review-feedback.js +255 -0
- package/dist/src/agents/selection.js +113 -0
- package/dist/src/agents/service.js +1087 -0
- package/dist/src/agents/types.js +1 -0
- package/dist/src/agents/wave-assessment-feedback.js +69 -0
- package/dist/src/attention/derive.js +337 -0
- package/dist/src/capabilities/index.js +2 -0
- package/dist/src/capabilities/projection.js +183 -0
- package/dist/src/capabilities/types.js +1 -0
- package/dist/src/capabilities/validator.js +87 -0
- package/dist/src/cli/commands/broker-smoke.js +96 -0
- package/dist/src/cli/commands/broker.js +56 -0
- package/dist/src/cli/commands/init.js +4 -0
- package/dist/src/cli/commands/journal.js +43 -0
- package/dist/src/cli/commands/run-loop.js +56 -0
- package/dist/src/cli/commands/run.js +1241 -0
- package/dist/src/cli/commands/tui.js +187 -0
- package/dist/src/cli/dispatcher.js +51 -0
- package/dist/src/cli/errors.js +2 -0
- package/dist/src/cli/init.js +92 -0
- package/dist/src/cli/options.js +86 -0
- package/dist/src/cli/output.js +231 -0
- package/dist/src/cli/run-journal.js +342 -0
- package/dist/src/cli/run-types.js +1 -0
- package/dist/src/cli/run.js +32 -0
- package/dist/src/cli/runtime/dispatch-lifecycle.js +772 -0
- package/dist/src/cli/runtime/provider-runtime-types.js +1 -0
- package/dist/src/cli/runtime/provider-runtime.js +152 -0
- package/dist/src/cli/runtime/provider-tools.js +73 -0
- package/dist/src/cli/runtime/providers/antigravity.js +26 -0
- package/dist/src/cli/runtime/providers/claude.js +20 -0
- package/dist/src/cli/runtime/providers/codex.js +20 -0
- package/dist/src/cli/runtime/providers/gemini.js +20 -0
- package/dist/src/cli/runtime/providers/opencode.js +20 -0
- package/dist/src/cli/runtime/run-context.js +131 -0
- package/dist/src/cli/tui/index.js +3 -0
- package/dist/src/cli/tui/screen.js +388 -0
- package/dist/src/cli/tui/tracker.js +558 -0
- package/dist/src/cli/tui/types.js +1 -0
- package/dist/src/cli/tui/views.js +1006 -0
- package/dist/src/config/loader.js +136 -0
- package/dist/src/config/schemas.js +403 -0
- package/dist/src/config/types.js +1 -0
- package/dist/src/context/types.js +331 -0
- package/dist/src/domain/entities.js +1 -0
- package/dist/src/git/backburner-git-tool-service.js +680 -0
- package/dist/src/git/gitops-lifecycle.js +56 -0
- package/dist/src/git/merge-prep-workspace.js +357 -0
- package/dist/src/git/types.js +484 -0
- package/dist/src/github/broker-model-content.js +215 -0
- package/dist/src/github/broker-server.js +237 -0
- package/dist/src/github/broker.js +638 -0
- package/dist/src/github/composed.js +53 -0
- package/dist/src/github/gateway.js +478 -0
- package/dist/src/github/normalize.js +222 -0
- package/dist/src/github/pr-classification.js +73 -0
- package/dist/src/github/scoped-broker.js +35 -0
- package/dist/src/github/security.js +126 -0
- package/dist/src/github/service.js +332 -0
- package/dist/src/github/types.js +1 -0
- package/dist/src/github/utils.js +16 -0
- package/dist/src/journal/index.js +4 -0
- package/dist/src/journal/reader.js +62 -0
- package/dist/src/journal/renderer.js +50 -0
- package/dist/src/journal/service.js +72 -0
- package/dist/src/journal/types.js +1 -0
- package/dist/src/journal/writer.js +19 -0
- package/dist/src/mcps/bridge.js +166 -0
- package/dist/src/mcps/index.js +5 -0
- package/dist/src/mcps/reconcile.js +113 -0
- package/dist/src/mcps/smithery-client.js +186 -0
- package/dist/src/mcps/smithery.js +164 -0
- package/dist/src/mcps/types.js +1 -0
- package/dist/src/memory/json-store.js +71 -0
- package/dist/src/memory/prompt.js +16 -0
- package/dist/src/memory/scope.js +31 -0
- package/dist/src/memory/store.js +1 -0
- package/dist/src/memory/tool-service.js +142 -0
- package/dist/src/memory/types.js +12 -0
- package/dist/src/onboarding/config-writer.js +96 -0
- package/dist/src/onboarding/engine.js +86 -0
- package/dist/src/onboarding/prompt.js +102 -0
- package/dist/src/onboarding/services/provider-discovery.js +58 -0
- package/dist/src/onboarding/services/repo-discovery.js +246 -0
- package/dist/src/onboarding/steps/check-github-auth.js +32 -0
- package/dist/src/onboarding/steps/check-requirements.js +34 -0
- package/dist/src/onboarding/steps/configure-models.js +105 -0
- package/dist/src/onboarding/steps/configure-paths.js +33 -0
- package/dist/src/onboarding/steps/discover-providers.js +38 -0
- package/dist/src/onboarding/steps/discover-repos.js +39 -0
- package/dist/src/onboarding/steps/generate-config.js +106 -0
- package/dist/src/onboarding/steps/readiness-validation.js +158 -0
- package/dist/src/onboarding/steps/select-repos.js +76 -0
- package/dist/src/onboarding/steps/show-summary.js +97 -0
- package/dist/src/onboarding/steps/welcome.js +27 -0
- package/dist/src/onboarding/types.js +1 -0
- package/dist/src/onboarding/validators/git-access.js +63 -0
- package/dist/src/onboarding/validators/github-auth.js +85 -0
- package/dist/src/onboarding/validators/tool-checker.js +153 -0
- package/dist/src/onboarding/validators/workspace.js +83 -0
- package/dist/src/prompts/resolver.js +106 -0
- package/dist/src/retrospectives/candidates.js +224 -0
- package/dist/src/retrospectives/derive.js +169 -0
- package/dist/src/retrospectives/ingest.js +321 -0
- package/dist/src/retrospectives/management-prs.js +380 -0
- package/dist/src/retrospectives/proposals.js +199 -0
- package/dist/src/retrospectives/scopes.js +272 -0
- package/dist/src/retrospectives/scoring.js +171 -0
- package/dist/src/retrospectives/types.js +1 -0
- package/dist/src/state/loader.js +473 -0
- package/dist/src/state/types.js +15 -0
- package/dist/src/tasks/derivation/builders.js +70 -0
- package/dist/src/tasks/derivation/handlers/comment-response.js +169 -0
- package/dist/src/tasks/derivation/handlers/implement-plan.js +103 -0
- package/dist/src/tasks/derivation/handlers/index.js +54 -0
- package/dist/src/tasks/derivation/handlers/packet-pr-control.js +92 -0
- package/dist/src/tasks/derivation/handlers/packet-worktree.js +29 -0
- package/dist/src/tasks/derivation/handlers/plan-breakdown.js +45 -0
- package/dist/src/tasks/derivation/handlers/prepare-for-merge.js +91 -0
- package/dist/src/tasks/derivation/handlers/product-discovery.js +36 -0
- package/dist/src/tasks/derivation/handlers/retry-failed-task.js +125 -0
- package/dist/src/tasks/derivation/handlers/review-pr.js +28 -0
- package/dist/src/tasks/derivation/handlers/shared.js +24 -0
- package/dist/src/tasks/derivation/handlers/sync-parent-branch.js +100 -0
- package/dist/src/tasks/derivation/handlers/wave-assessment.js +223 -0
- package/dist/src/tasks/derivation/handlers/write-plan.js +101 -0
- package/dist/src/tasks/derivation/handlers/write-product-spec.js +49 -0
- package/dist/src/tasks/derivation/runner.js +18 -0
- package/dist/src/tasks/derivation/types.js +1 -0
- package/dist/src/tasks/derive.js +810 -0
- package/dist/src/tasks/mcp-skip.js +10 -0
- package/dist/src/tasks/retry.js +10 -0
- package/dist/src/tasks/task.js +184 -0
- package/dist/src/tasks/types.js +1 -0
- package/dist/src/utils/command-runner.js +192 -0
- package/dist/src/utils/json.js +38 -0
- package/dist/src/utils/logger.js +43 -0
- package/dist/src/utils/paths.js +38 -0
- package/dist/src/utils/slug.js +10 -0
- package/dist/src/workflows/registry.js +174 -0
- package/dist/src/workflows/triage.js +90 -0
- package/dist/src/workflows/workstream-machine/derive-events.js +121 -0
- package/dist/src/workflows/workstream-machine/evaluate.js +24 -0
- package/dist/src/workflows/workstream-machine/events.js +1 -0
- package/dist/src/workflows/workstream-machine/machine.js +355 -0
- package/dist/src/workflows/workstream-machine/selectors.js +19 -0
- package/dist/src/workflows/workstream-machine/types.js +1 -0
- package/dist/src/workstreams/branch-sync.js +87 -0
- package/dist/src/workstreams/derive.js +629 -0
- package/dist/src/workstreams/mcp-blockers.js +420 -0
- package/dist/src/workstreams/packet-candidates.js +42 -0
- package/dist/src/workstreams/packet-lifecycle-feedback.js +60 -0
- package/dist/src/workstreams/packet-lifecycle-report.js +199 -0
- package/dist/src/workstreams/packet-plan.js +597 -0
- package/dist/src/workstreams/packet-projections.js +190 -0
- package/dist/src/workstreams/parent-branch-sync-action.js +312 -0
- package/dist/src/workstreams/parent-branch-sync.js +148 -0
- package/dist/src/workstreams/phases.js +4 -0
- package/dist/src/workstreams/plan-breakdown-generator/export.js +19 -0
- package/dist/src/workstreams/plan-breakdown-generator/index.js +6 -0
- package/dist/src/workstreams/plan-breakdown-generator/inspect.js +50 -0
- package/dist/src/workstreams/plan-breakdown-generator/patch.js +139 -0
- package/dist/src/workstreams/plan-breakdown-generator/session.js +19 -0
- package/dist/src/workstreams/plan-breakdown-generator/store.js +27 -0
- package/dist/src/workstreams/plan-breakdown-generator/tools.js +407 -0
- package/dist/src/workstreams/plan-breakdown-generator/types.js +6 -0
- package/dist/src/workstreams/plan-breakdown-generator/validate.js +212 -0
- package/dist/src/workstreams/plan-breakdown-schema.js +175 -0
- package/dist/src/workstreams/utils.js +15 -0
- package/dist/src/workstreams/wave-assessment/checkpoint.js +172 -0
- package/dist/src/workstreams/wave-assessment/index.js +3 -0
- package/dist/src/workstreams/wave-assessment/session.js +84 -0
- package/dist/src/workstreams/wave-assessment/store.js +51 -0
- package/dist/src/workstreams/wave-assessment/tools.js +419 -0
- package/dist/src/workstreams/wave-assessment/types.js +1 -0
- package/dist/src/workstreams/wave-assessment/validate.js +78 -0
- package/dist/src/worktrees/service.js +839 -0
- package/dist/src/worktrees/workspace-ownership.js +34 -0
- package/dist/src/worktrees/workspace-recovery.js +177 -0
- package/package.json +61 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import * as http from "node:http";
|
|
2
|
+
import { URL } from "node:url";
|
|
3
|
+
import { toPrettyJson } from "../utils/json.js";
|
|
4
|
+
import { createModelVisibleSuccessText } from "./broker-model-content.js";
|
|
5
|
+
const MCP_PATH = "/mcp";
|
|
6
|
+
export async function startGitHubBrokerServer(options) {
|
|
7
|
+
const server = http.createServer(async (request, response) => {
|
|
8
|
+
try {
|
|
9
|
+
const httpResponse = await handleBrokerHttpRequest({
|
|
10
|
+
method: request.method ?? "GET",
|
|
11
|
+
path: request.url ?? "/",
|
|
12
|
+
body: await readRequestBody(request)
|
|
13
|
+
}, options.brokerService);
|
|
14
|
+
response.writeHead(httpResponse.statusCode, httpResponse.headers);
|
|
15
|
+
response.end(httpResponse.body);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
19
|
+
options.logger.warn(`GitHub broker request failed: ${message}`);
|
|
20
|
+
if (!response.headersSent) {
|
|
21
|
+
response.writeHead(500, { "content-type": "application/json; charset=utf-8" });
|
|
22
|
+
}
|
|
23
|
+
response.end(toPrettyJson(jsonRpcError(null, -32603, "Internal server error")));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
await new Promise((resolve, reject) => {
|
|
27
|
+
server.once("error", reject);
|
|
28
|
+
server.listen(options.port, options.host, () => {
|
|
29
|
+
server.off("error", reject);
|
|
30
|
+
resolve();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
const address = server.address();
|
|
34
|
+
if (!address || typeof address === "string") {
|
|
35
|
+
throw new Error("Broker server did not expose a TCP address");
|
|
36
|
+
}
|
|
37
|
+
const url = `http://${options.host}:${address.port}${MCP_PATH}`;
|
|
38
|
+
options.logger.info(`GitHub broker MCP listening on ${url}`);
|
|
39
|
+
return {
|
|
40
|
+
host: options.host,
|
|
41
|
+
port: address.port,
|
|
42
|
+
url,
|
|
43
|
+
close: async () => await new Promise((resolve, reject) => {
|
|
44
|
+
server.close((error) => {
|
|
45
|
+
if (error) {
|
|
46
|
+
reject(error);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
resolve();
|
|
50
|
+
});
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export async function handleBrokerHttpRequest(request, brokerService) {
|
|
55
|
+
try {
|
|
56
|
+
return await handleBrokerHttpRequestInner(request, brokerService);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
60
|
+
return {
|
|
61
|
+
statusCode: 400,
|
|
62
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
63
|
+
body: toPrettyJson(jsonRpcError(null, -32700, message))
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function handleBrokerHttpRequestInner(request, brokerService) {
|
|
68
|
+
const url = new URL(request.path, "http://localhost");
|
|
69
|
+
if (request.method === "GET" && url.pathname === "/") {
|
|
70
|
+
return {
|
|
71
|
+
statusCode: 200,
|
|
72
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
73
|
+
body: toPrettyJson({
|
|
74
|
+
ok: true,
|
|
75
|
+
service: "backburner-github-broker",
|
|
76
|
+
mcpPath: MCP_PATH
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (request.method === "GET" && url.pathname === "/health") {
|
|
81
|
+
return {
|
|
82
|
+
statusCode: 200,
|
|
83
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
84
|
+
body: toPrettyJson({ ok: true })
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (request.method === "GET" && url.pathname === MCP_PATH) {
|
|
88
|
+
return {
|
|
89
|
+
statusCode: 200,
|
|
90
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
91
|
+
body: toPrettyJson({
|
|
92
|
+
ok: true,
|
|
93
|
+
transport: "json-rpc",
|
|
94
|
+
method: "POST",
|
|
95
|
+
path: MCP_PATH
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (request.method !== "POST" || url.pathname !== MCP_PATH) {
|
|
100
|
+
return {
|
|
101
|
+
statusCode: 404,
|
|
102
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
103
|
+
body: toPrettyJson({ error: "Not found" })
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const payload = readJsonRpcRequest(request.body);
|
|
107
|
+
if (payload.method === "notifications/initialized") {
|
|
108
|
+
return {
|
|
109
|
+
statusCode: 202,
|
|
110
|
+
headers: {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (payload.jsonrpc !== "2.0" || typeof payload.method !== "string") {
|
|
114
|
+
return {
|
|
115
|
+
statusCode: 400,
|
|
116
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
117
|
+
body: toPrettyJson(jsonRpcError(payload.id ?? null, -32600, "Invalid JSON-RPC request"))
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const result = await dispatchJsonRpc(payload, brokerService);
|
|
121
|
+
return {
|
|
122
|
+
statusCode: 200,
|
|
123
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
124
|
+
body: toPrettyJson(result)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async function dispatchJsonRpc(request, brokerService) {
|
|
128
|
+
switch (request.method) {
|
|
129
|
+
case "initialize":
|
|
130
|
+
return {
|
|
131
|
+
jsonrpc: "2.0",
|
|
132
|
+
id: request.id ?? null,
|
|
133
|
+
result: {
|
|
134
|
+
protocolVersion: "2024-11-05",
|
|
135
|
+
capabilities: {
|
|
136
|
+
tools: {}
|
|
137
|
+
},
|
|
138
|
+
serverInfo: {
|
|
139
|
+
name: "backburner-github-broker",
|
|
140
|
+
version: "0.1.0"
|
|
141
|
+
},
|
|
142
|
+
instructions: "Use the typed GitHub broker tools for managed repositories instead of invoking gh directly."
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
case "tools/list":
|
|
146
|
+
return {
|
|
147
|
+
jsonrpc: "2.0",
|
|
148
|
+
id: request.id ?? null,
|
|
149
|
+
result: {
|
|
150
|
+
tools: brokerService.listTools()
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
case "tools/call": {
|
|
154
|
+
const params = expectParamsObject(request.params, '"tools/call" params must be an object');
|
|
155
|
+
const name = expectString(params.name, '"tools/call" requires a string "name"');
|
|
156
|
+
const toolResult = await brokerService.callTool(name, params.arguments);
|
|
157
|
+
return {
|
|
158
|
+
jsonrpc: "2.0",
|
|
159
|
+
id: request.id ?? null,
|
|
160
|
+
result: toolResult.ok
|
|
161
|
+
? {
|
|
162
|
+
content: [
|
|
163
|
+
{
|
|
164
|
+
type: "text",
|
|
165
|
+
text: createModelVisibleSuccessText(toolResult)
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
structuredContent: toolResult.result,
|
|
169
|
+
isError: false
|
|
170
|
+
}
|
|
171
|
+
: {
|
|
172
|
+
content: [
|
|
173
|
+
{
|
|
174
|
+
type: "text",
|
|
175
|
+
text: `GitHub broker tool "${toolResult.tool}" failed: ${toolResult.error.message}`
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
structuredContent: toolResult,
|
|
179
|
+
isError: true
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
default:
|
|
184
|
+
return jsonRpcError(request.id ?? null, -32601, `Method "${request.method}" not found`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async function readRequestBody(request) {
|
|
188
|
+
return new Promise((resolve, reject) => {
|
|
189
|
+
let body = "";
|
|
190
|
+
request.on("data", (chunk) => {
|
|
191
|
+
body += chunk.toString();
|
|
192
|
+
});
|
|
193
|
+
request.on("end", () => {
|
|
194
|
+
resolve(body);
|
|
195
|
+
});
|
|
196
|
+
request.on("error", (error) => {
|
|
197
|
+
reject(error);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function jsonRpcError(id, code, message) {
|
|
202
|
+
return {
|
|
203
|
+
jsonrpc: "2.0",
|
|
204
|
+
id,
|
|
205
|
+
error: {
|
|
206
|
+
code,
|
|
207
|
+
message
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function readJsonRpcRequest(body) {
|
|
212
|
+
if (!body) {
|
|
213
|
+
return {};
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const payload = JSON.parse(body);
|
|
217
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
218
|
+
return {};
|
|
219
|
+
}
|
|
220
|
+
return payload;
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return {};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function expectParamsObject(params, message) {
|
|
227
|
+
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
228
|
+
throw new Error(message);
|
|
229
|
+
}
|
|
230
|
+
return params;
|
|
231
|
+
}
|
|
232
|
+
function expectString(value, message) {
|
|
233
|
+
if (typeof value !== "string") {
|
|
234
|
+
throw new Error(message);
|
|
235
|
+
}
|
|
236
|
+
return value;
|
|
237
|
+
}
|