@jmanuelcorral/bond-app 0.1.3 → 0.1.5
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/README.md +41 -1
- package/app/mods/bond-agents/config.js +4 -0
- package/app/mods/bond-agents/main.js +10 -5
- package/app/mods/bond-agents/model.js +52 -4
- package/app/mods/bond-board/config.js +4 -0
- package/app/mods/bond-board/main.js +555 -84
- package/app/mods/bond-board/model.js +115 -2
- package/app/mods/bond-settings/config.js +4 -0
- package/app/mods/bond-settings/main.js +689 -12
- package/app/mods/bond-settings/pi-models.js +144 -0
- package/app/mods/bond-status/config.js +4 -0
- package/app/mods/bond-titlebar/main.js +63 -46
- package/package.json +1 -1
- package/runner/Dockerfile +42 -13
- package/runner/SPIKE-BOND.md +85 -0
- package/runner/build-config/.none +0 -0
- package/runner/build-creds/.none +0 -0
- package/runner/config.example/README.md +27 -0
- package/runner/config.example/pi/models.json +22 -0
- package/runner/credentials.example.env +27 -0
- package/runner/setup.sh +496 -0
- package/runner/versions.env +30 -0
- package/scripts/app-install.ts +38 -7
- package/src/config.ts +11 -0
- package/src/core/delivery.ts +61 -7
- package/src/core/hub-session.ts +154 -17
- package/src/core/hub.ts +55 -20
- package/src/core/orchestrator.ts +844 -200
- package/src/core/setup.ts +178 -0
- package/src/core/watchdog.ts +2 -2
- package/src/db/database.ts +14 -0
- package/src/db/run-repo.ts +8 -1
- package/src/db/settings-repo.ts +108 -0
- package/src/db/ticket-repo.ts +34 -4
- package/src/runner/docker-client.ts +42 -0
- package/src/runner/github-client.ts +126 -2
- package/src/runner/hc-client.ts +67 -9
- package/src/runner/image-builder.ts +146 -6
- package/src/server/app.ts +263 -36
- package/src/types.ts +40 -0
|
@@ -22,6 +22,37 @@ export function shortRepo(url) {
|
|
|
22
22
|
return m ? m[1] : String(url ?? "");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Strips common prefix shared with the hub or among repos, without shortening down to bare numbers.
|
|
27
|
+
*/
|
|
28
|
+
export function cleanRepoChips(repos, hubName = "") {
|
|
29
|
+
if (!Array.isArray(repos) || repos.length === 0) return [];
|
|
30
|
+
const names = repos.map((r) =>
|
|
31
|
+
String(typeof r === "object" ? (r?.name || r?.url || "") : (r ?? "")).split("/").pop().replace(/\.git$/, "")
|
|
32
|
+
).filter(Boolean);
|
|
33
|
+
if (names.length > 1) {
|
|
34
|
+
const hubClean = String(hubName).split("/").pop().replace(/\.git$/, "").replace(/-hub$/, "");
|
|
35
|
+
if (hubClean) {
|
|
36
|
+
const parts = hubClean.split("-");
|
|
37
|
+
for (let i = parts.length; i >= 1; i--) {
|
|
38
|
+
const p = parts.slice(0, i).join("-") + "-";
|
|
39
|
+
if (names.every((n) => n.startsWith(p) && n.length > p.length && !/^\d+$/.test(n.slice(p.length)))) {
|
|
40
|
+
return names.map((n) => n.slice(p.length));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const first = names[0];
|
|
45
|
+
const parts = first.split("-");
|
|
46
|
+
if (parts.length >= 3) {
|
|
47
|
+
const p = parts.slice(0, -2).join("-") + "-";
|
|
48
|
+
if (p.length > 0 && names.every((n) => n.startsWith(p) && n.length > p.length && !/^\d+$/.test(n.slice(p.length)))) {
|
|
49
|
+
return names.map((n) => n.slice(p.length));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return names;
|
|
54
|
+
}
|
|
55
|
+
|
|
25
56
|
/**
|
|
26
57
|
* P5: where a ticket works, for the card: its hub (existing, or one the run creates from
|
|
27
58
|
* its repos) and the session's repos (from the run's analysis once there is one).
|
|
@@ -49,6 +80,37 @@ export function hubInfo(ticket, run) {
|
|
|
49
80
|
};
|
|
50
81
|
}
|
|
51
82
|
|
|
83
|
+
/**
|
|
84
|
+
* P5 (B-2): the push destinations fixed by hub.toml for an existing hub:
|
|
85
|
+
* the session repos and the hub itself with their URLs and base branches.
|
|
86
|
+
*/
|
|
87
|
+
export function hubPushDestinations(ticket, run) {
|
|
88
|
+
if (!ticket?.hub_url) return [];
|
|
89
|
+
const analysis = run?.hub_analysis ?? null;
|
|
90
|
+
const list = [];
|
|
91
|
+
if (analysis?.repos?.length) {
|
|
92
|
+
for (const r of analysis.repos) {
|
|
93
|
+
if (r && typeof r === "object") {
|
|
94
|
+
const name = r.name || (r.url ? shortRepo(r.url).split("/").pop() : "repo");
|
|
95
|
+
const url = r.url || null;
|
|
96
|
+
const base = r.base || "main";
|
|
97
|
+
list.push({ name, url, base });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} else if (ticket?.repos?.length) {
|
|
101
|
+
for (const r of ticket.repos) {
|
|
102
|
+
if (r && typeof r === "object") {
|
|
103
|
+
const name = r.name || (r.url ? shortRepo(r.url).split("/").pop() : "repo");
|
|
104
|
+
const url = r.url || null;
|
|
105
|
+
const base = r.base_branch || r.base || "main";
|
|
106
|
+
list.push({ name, url, base });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
list.push({ name: "hub", url: ticket.hub_url, base: ticket.hub_base || "main", hub: true });
|
|
111
|
+
return list;
|
|
112
|
+
}
|
|
113
|
+
|
|
52
114
|
/** P5: the hub analysis for the card: status, gaps (with their fix) and notes. */
|
|
53
115
|
export function analysisInfo(run) {
|
|
54
116
|
const a = run?.hub_analysis;
|
|
@@ -132,6 +194,7 @@ export function buildCards(tickets, runs, agentStatus = {}, now = Date.now()) {
|
|
|
132
194
|
const hcInfo = terminal ? agentStatus[terminal] ?? null : null;
|
|
133
195
|
const hub = hubInfo(t, run);
|
|
134
196
|
const analysis = analysisInfo(run);
|
|
197
|
+
const destinations = hubPushDestinations(t, run);
|
|
135
198
|
const hubBlocked = Boolean(run && run.state === "blocked" && run.failure_reason === "hub_incomplete");
|
|
136
199
|
// D23: every live run card offers «Shell del contenedor» and shows the docker exec command
|
|
137
200
|
const isLive = Boolean(run && (
|
|
@@ -149,6 +212,7 @@ export function buildCards(tickets, runs, agentStatus = {}, now = Date.now()) {
|
|
|
149
212
|
repo: hub ? `${hub.label} · ${hub.repos.length} repos` : shortRepo(t.repo_url),
|
|
150
213
|
hub,
|
|
151
214
|
analysis,
|
|
215
|
+
destinations,
|
|
152
216
|
deliveries: repoDeliveries(run),
|
|
153
217
|
branch: t.target_branch || `feat/${t.id}`,
|
|
154
218
|
agent: t.agent || "pi",
|
|
@@ -207,6 +271,9 @@ const AGENT_STATUS = {
|
|
|
207
271
|
idle: "en espera",
|
|
208
272
|
done: "en espera (terminó su turno)",
|
|
209
273
|
error: "error",
|
|
274
|
+
waiting: "en espera",
|
|
275
|
+
"idle-waiting": "en espera",
|
|
276
|
+
"en espera": "en espera",
|
|
210
277
|
};
|
|
211
278
|
|
|
212
279
|
/**
|
|
@@ -219,7 +286,6 @@ export function agentStateLabel(run, hcInfo) {
|
|
|
219
286
|
const status = statusText(hcInfo?.status);
|
|
220
287
|
if (status) return `agente: ${AGENT_STATUS[status] ?? status}`;
|
|
221
288
|
if (hcInfo?.state === "finished") return "agente: terminó";
|
|
222
|
-
if (hcInfo?.state === "live") return "agente: vivo (sin estado)";
|
|
223
289
|
if (run.state === "queued") return "arrancando…";
|
|
224
290
|
if (run.state === "analyzing") return "analizando el hub…";
|
|
225
291
|
if (run.state === "waiting") return run.failure_reason ? String(run.failure_reason) : "esperando respuesta…";
|
|
@@ -392,8 +458,12 @@ export function validateNewTicket(form) {
|
|
|
392
458
|
const base = String(f.base ?? "").trim();
|
|
393
459
|
if (base && !BRANCH.test(base)) errors.base = "Rama no válida";
|
|
394
460
|
|
|
461
|
+
const model = agent === "pi" && f.model ? String(f.model).trim() : null;
|
|
462
|
+
|
|
395
463
|
const body = { title, agent };
|
|
396
|
-
|
|
464
|
+
body.bondify = f.bondify !== undefined ? Boolean(f.bondify) : true;
|
|
465
|
+
if (model) body.model = model;
|
|
466
|
+
if (mode !== "repo" && f.team_engine) {
|
|
397
467
|
body.team_engine = f.team_engine === "herdr" ? "herdr" : "hc";
|
|
398
468
|
}
|
|
399
469
|
if (mode === "repo") {
|
|
@@ -450,6 +520,10 @@ export function validateNewTicket(form) {
|
|
|
450
520
|
else if (verify.some((c) => c.length > 2000)) errors.verify = "Un comando es demasiado largo";
|
|
451
521
|
else body.verify_commands = verify;
|
|
452
522
|
|
|
523
|
+
// La US: el cuerpo de la issue elegida (check mediante); sin esto el agente arranca sin contexto.
|
|
524
|
+
const story = String(f.story ?? "").trim();
|
|
525
|
+
if (story) body.story = story.slice(0, 8000);
|
|
526
|
+
|
|
453
527
|
const issueUrl = String(f.issue_url ?? f.issue ?? "").trim();
|
|
454
528
|
if (issueUrl) {
|
|
455
529
|
if (!/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/issues\/[1-9][0-9]*(?:[#?].*)?$/.test(issueUrl)) {
|
|
@@ -467,6 +541,35 @@ export async function createTicket(api, body) {
|
|
|
467
541
|
return api("/tickets", { method: "POST", body });
|
|
468
542
|
}
|
|
469
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Plan bond-app-nuevo-ticket (P2): issues to link a ticket to — the ones assigned to the
|
|
546
|
+
* user on the provider (open; `ready` first). The backend answers `github_not_configured`
|
|
547
|
+
* when there is no session, and `github_api_error` when the provider refuses.
|
|
548
|
+
*/
|
|
549
|
+
export async function listAssignedIssues(api, provider = "github") {
|
|
550
|
+
return api(`/issues/assigned?provider=${encodeURIComponent(provider)}`);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** Paso 1 de la búsqueda combinada: repos por nombre (buscador de GitHub). */
|
|
554
|
+
export async function searchRepos(api, term) {
|
|
555
|
+
return api(`/repos/search?provider=github&q=${encodeURIComponent(term)}`);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** Paso 2: issues abiertas de un repo (ready primero, las asignadas a mí después). */
|
|
559
|
+
export async function listRepoIssues(api, owner, repo) {
|
|
560
|
+
return api(`/issues/repo?provider=github&owner=${encodeURIComponent(owner)}&repo=${encodeURIComponent(repo)}`);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** D1: the id the backend will give the ticket for this issue (`gh-<owner>-<repo>-<n>`). */
|
|
564
|
+
export function issueTicketId(issue) {
|
|
565
|
+
const url = String(issue?.url ?? "").trim();
|
|
566
|
+
const m = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/issues\/([1-9][0-9]*)(?:[#?].*)?$/.exec(url);
|
|
567
|
+
if (!m) return null;
|
|
568
|
+
const slug = (s) => s.replace(/[^A-Za-z0-9_.-]/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
569
|
+
const id = `gh-${slug(m[1])}-${slug(m[2])}-${m[3]}`.replace(/\.{2,}/g, "-");
|
|
570
|
+
return id.length <= 80 ? id : null;
|
|
571
|
+
}
|
|
572
|
+
|
|
470
573
|
/** P7: Delete ticket and tear down all associated resources (container, network, machine, worktrees, branches). */
|
|
471
574
|
export async function deleteTicket(api, ticketId, force = false) {
|
|
472
575
|
const query = force ? "?force=true" : "";
|
|
@@ -477,3 +580,13 @@ export async function deleteTicket(api, ticketId, force = false) {
|
|
|
477
580
|
export async function getDeletePreview(api, ticketId) {
|
|
478
581
|
return api(`/tickets/${encodeURIComponent(ticketId)}/delete_preview`);
|
|
479
582
|
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* W-P2: does the board offer the setup wizard on load? Only when the orchestrator
|
|
586
|
+
* says the setup is not complete and the person has never finished the wizard
|
|
587
|
+
* (setup_done). With setup_done the wizard never bothers again; Ajustes is the
|
|
588
|
+
* permanent editor with «Reabrir asistente» (D-W2).
|
|
589
|
+
*/
|
|
590
|
+
export function needsWizard(state) {
|
|
591
|
+
return Boolean(state) && state.complete === false && state.setup_done === false;
|
|
592
|
+
}
|
|
@@ -5,4 +5,8 @@ export const CONFIG = {
|
|
|
5
5
|
api: "http://127.0.0.1:3000/api/v1",
|
|
6
6
|
// null: ~/.bond-app/token (the orchestrator's default data dir)
|
|
7
7
|
tokenFile: null,
|
|
8
|
+
// Gasto/costes fuera por defecto (decisión 2026-11-19): el orquestador sigue
|
|
9
|
+
// registrando cost_usd, pero la UI no lo muestra hasta que una configuración
|
|
10
|
+
// en Ajustes lo active. Entonces esto será el valor de esa configuración.
|
|
11
|
+
costs: false,
|
|
8
12
|
};
|