@jmanuelcorral/bond-app 0.1.1 → 0.1.4

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 CHANGED
@@ -153,9 +153,21 @@ npm install -g @jmanuelcorral/bond-app
153
153
 
154
154
  # O desde un paquete local:
155
155
  npm pack
156
- npm install -g ./jmanuelcorral-bond-app-0.1.0.tgz
156
+ npm install -g ./jmanuelcorral-bond-app-0.1.2.tgz
157
157
  ```
158
158
 
159
+ ### Publicar en npm
160
+
161
+ La publicación va por **staged publishing** desde GitHub Actions (`.github/workflows/release.yml`), al subir un tag `vX.Y.Z`. Procedimiento:
162
+
163
+ 1. Subir `version` en `package.json` (una versión publicada no se puede sobrescribir) y commitear.
164
+ 2. Etiquetar y subir el tag: `git tag vX.Y.Z && git push origin vX.Y.Z`. El workflow comprueba que el tag coincide con `package.json`, pasa typecheck y tests unitarios, crea la release de GitHub con el `.tgz` adjunto y deja ese mismo `.tgz` en el staging de npm (`npm stage publish`). Autentifica con el secret `NPM_TOKEN` si está definido; si no, por OIDC (trusted publishing: hay que dar de alta el repo y el workflow en npmjs.com → el paquete → Trusted Publishing).
165
+ 3. Aprobar el staged package con 2FA: el workflow imprime el stage-id en el resumen del job; `npm stage approve <stage-id>` o npmjs.com → pestaña **Staged Packages** → Approve. Hasta aprobarlo, la versión no es pública.
166
+
167
+ `--provenance` (attestations SLSA) solo se pasa mientras el repo es público: sigstore rechaza repos fuente privados (`Unsupported GitHub Actions source repository visibility: "private"`). Con el repo privado el workflow publica sin procedencia y lo anuncia en el log; si el repo se hace público, las attestations vuelven solas.
168
+
169
+ Antes de publicar se puede comprobar el contenido: `npm pack --dry-run`. No deben aparecer los ficheros generados de los mods (`gpui-kit.d.ts`, `jsconfig.json`); están excluidos con patrones `!` en `files`. Si el `.npmrc` de una máquina apunta el scope a otro registro (p. ej. `@jmanuelcorral:registry=https://npm.pkg.github.com`), al instalar hay que sobrescribirlo: `npm install -g @jmanuelcorral/bond-app --@jmanuelcorral:registry=https://registry.npmjs.org/`.
170
+
159
171
  ### Comandos del binario `bond-app`
160
172
 
161
173
  - `bond-app start [opciones]` — Arranca el orquestador en primer plano.
@@ -169,7 +181,7 @@ npm install -g ./jmanuelcorral-bond-app-0.1.0.tgz
169
181
  - `bond-app status [opciones]` — Consulta el estado del orquestador y la integración con herdr-app.
170
182
  - Opciones: `--port <puerto>`, `--host <ip>`, `--data-dir <dir>`, `--home <dir>`, `--json`.
171
183
  - Código de salida: 0 si el orquestador está corriendo (o si se invoca con `--json`), 1 si está parado.
172
- - `bond-app --version` (`-v`, `version`) — Muestra la versión (`0.1.0`).
184
+ - `bond-app --version` (`-v`, `version`) — Muestra la versión (`0.1.2`).
173
185
  - `bond-app --help` (`-h`, `help`) — Muestra la ayuda de uso.
174
186
 
175
187
  ### Arranque desde bond (`bond app`)
@@ -84,11 +84,14 @@ export function buildAgentsSections(runs, tickets, selectedRunId, teamStatusByRu
84
84
  state: targetRun.state,
85
85
  rows: rows.map((r) => {
86
86
  const agent = r?.agent || {};
87
- const stateKey = agent.status === "idle-waiting" ? "idle-waiting" : (r?.state || "desconocido");
87
+ const stateKey = agent.status === "idle-waiting" || agent.status === "en espera" || r?.state === "en espera"
88
+ ? "en espera"
89
+ : (r?.state || agent.status || "desconocido");
90
+ const agentStatus = agent.status === "idle-waiting" ? "en espera" : (agent.status || r?.state || "desconocido");
88
91
  return {
89
92
  ...r,
90
93
  agentName: agent.name || agent.kind || "agente",
91
- agentStatus: agent.status || r?.state || "desconocido",
94
+ agentStatus,
92
95
  pane: agent.pane ?? null,
93
96
  question: agent.question ?? null,
94
97
  aheadLabel: formatAhead(r?.ahead),
@@ -25,6 +25,7 @@ import {
25
25
  COLUMNS, POLL_MS, buildCards, groupByColumn, loadBoard, launchTicket, cancelRun, launchSummary,
26
26
  deliverRun, nudgeRun, finishRun, approveHubFixes, deleteTicket, getDeletePreview,
27
27
  columnCounts, filterOptions, filterCards, validateNewTicket, createTicket, AGENTS, TICKET_MODES, TEAM_ENGINES,
28
+ cleanRepoChips,
28
29
  } from "./model.js";
29
30
  import { stateColor, UI } from "./brand.js";
30
31
 
@@ -44,34 +45,6 @@ function spanishStateLabel(col, status) {
44
45
  return `● ${s.toUpperCase()}`;
45
46
  }
46
47
 
47
- function cleanRepoChips(repos, hubName = "") {
48
- if (!Array.isArray(repos) || repos.length === 0) return [];
49
- const names = repos.map((r) =>
50
- String(typeof r === "object" ? (r?.name || r?.url || "") : (r ?? "")).split("/").pop().replace(/\.git$/, "")
51
- ).filter(Boolean);
52
- if (names.length > 1) {
53
- const hubClean = String(hubName).split("/").pop().replace(/\.git$/, "").replace(/-hub$/, "");
54
- if (hubClean) {
55
- const parts = hubClean.split("-");
56
- for (let i = parts.length; i >= 1; i--) {
57
- const p = parts.slice(0, i).join("-") + "-";
58
- if (names.every((n) => n.startsWith(p) && n.length > p.length)) {
59
- return names.map((n) => n.slice(p.length));
60
- }
61
- }
62
- }
63
- const first = names[0];
64
- const parts = first.split("-");
65
- if (parts.length >= 3) {
66
- const p = parts.slice(0, -2).join("-") + "-";
67
- if (p.length > 0 && names.every((n) => n.startsWith(p) && n.length > p.length)) {
68
- return names.map((n) => n.slice(p.length));
69
- }
70
- }
71
- }
72
- return names;
73
- }
74
-
75
48
  export default class BondBoard extends View {
76
49
  init(_props, cx) {
77
50
  const p = props() ?? {};
@@ -145,8 +118,15 @@ export default class BondBoard extends View {
145
118
  }
146
119
 
147
120
  // The text filter is typed here; repo and agent come from the picker (FILTER_KEY).
148
- this.search = InputState.new({ placeholder: "Buscar ticket o rama..." });
149
- this.search.on("change", (_e, cx) => cx.notify());
121
+ const filter = shared(FILTER_KEY) ?? {};
122
+ const initialText = String(filter.text ?? shared("bond.search") ?? "");
123
+ this.search = InputState.new({ value: initialText, placeholder: "Buscar ticket o rama..." });
124
+ this.search.on("change", (_e, cx) => {
125
+ const val = this.search.value();
126
+ setShared("bond.search", val);
127
+ setShared(FILTER_KEY, { ...(shared(FILTER_KEY) ?? {}), text: val });
128
+ cx.notify();
129
+ });
150
130
  this.tickets = [];
151
131
  this.runs = [];
152
132
  this.agentStatus = {};
@@ -159,10 +139,17 @@ export default class BondBoard extends View {
159
139
  // after a dialog of this mod launched, cancelled or deleted a run (it bumps the shared marker).
160
140
  cx.timer.every(1000, (cx) => {
161
141
  const marker = shared(REFRESH_KEY) ?? null;
142
+ let dirty = false;
162
143
  if (marker !== this.seenRefresh) {
163
144
  this.seenRefresh = marker;
164
145
  this.refresh(cx);
165
146
  }
147
+ const currentText = (shared(FILTER_KEY) ?? {}).text ?? shared("bond.search");
148
+ if (currentText !== undefined && currentText !== this.search.value()) {
149
+ this.search.set_value(String(currentText ?? ""));
150
+ dirty = true;
151
+ }
152
+ if (dirty) cx.notify();
166
153
  });
167
154
  }
168
155
 
@@ -374,7 +361,7 @@ export default class BondBoard extends View {
374
361
  openLaunch(card) {
375
362
  openOverlay({
376
363
  mod: "bond-board", kind: "dialog", modal: true, width: 460,
377
- props: { view: "launch", ticket: this.ticketOf(card), runs: this.runs },
364
+ props: { view: "launch", ticket: this.ticketOf(card), runs: this.runs, destinations: card.destinations },
378
365
  });
379
366
  }
380
367
 
@@ -388,7 +375,7 @@ export default class BondBoard extends View {
388
375
  openDeliver(card) {
389
376
  openOverlay({
390
377
  mod: "bond-board", kind: "dialog", modal: true, width: 460,
391
- props: { view: "deliver", runId: card.run.id, title: card.title, branch: card.branch, repo: card.repo },
378
+ props: { view: "deliver", runId: card.run.id, title: card.title, branch: card.branch, repo: card.repo, destinations: card.destinations },
392
379
  });
393
380
  }
394
381
 
@@ -693,7 +680,7 @@ export default class BondBoard extends View {
693
680
  .child(
694
681
  h_flex().gap(4).items_center().truncate()
695
682
  .child(div().text_color(t.dim).child("hub:"))
696
- .child(div().text_color(t.accent).truncate().child(hubLabel))
683
+ .child(div().text_color(t.accent).truncate().child(hubLabel.replace(/^hub\s+/i, "")))
697
684
  )
698
685
  .when(hubRepos.length > 0, (sub) =>
699
686
  sub.child(
@@ -797,7 +784,8 @@ export default class BondBoard extends View {
797
784
  .items_center()
798
785
  .justify_center()
799
786
  .rounded(UI.radius)
800
- .border_1()
787
+ .border_2()
788
+ .border_dashed()
801
789
  .border_color(t.border)
802
790
  .text_center()
803
791
  .font_family(UI.fontSans)
@@ -899,16 +887,25 @@ export default class BondBoard extends View {
899
887
  .child(String(card.branch))
900
888
  )
901
889
  )
902
- .when(Boolean(card.repo), (el) =>
903
- el.child(
890
+ .when(Boolean(card.repo), (el) => {
891
+ let repoText = "";
892
+ if (card.hub) {
893
+ const raw = (card.hub && Array.isArray(card.hub.repos)) ? card.hub.repos : [];
894
+ const rawLabel = String(card.hub.label || card.hub.url || (typeof card.hub === "string" ? card.hub : "hub"));
895
+ const chips = cleanRepoChips(raw, rawLabel);
896
+ repoText = chips.length > 0 ? `· repos: ${chips.join(", ")}` : `· hub: ${rawLabel.replace(/^hub\s+/i, "")}`;
897
+ } else {
898
+ repoText = `· repo: ${String(card.repo)}`;
899
+ }
900
+ return el.child(
904
901
  div()
905
902
  .text_size(UI.text.small)
906
903
  .font_family("JetBrains Mono")
907
904
  .text_color(t.dim)
908
905
  .truncate()
909
- .child(`· repos: ${String(card.repo)}`)
910
- )
911
- )
906
+ .child(repoText)
907
+ );
908
+ })
912
909
  // Copyable docker exec command pill (D23)
913
910
  .when(Boolean(card.containerCommand), (el) =>
914
911
  el.child(
@@ -1021,7 +1018,10 @@ export default class BondBoard extends View {
1021
1018
  const filter = shared(FILTER_KEY) ?? {};
1022
1019
  const sharedSearch = shared("bond.search");
1023
1020
  const inputSearch = this.search?.value?.() ?? "";
1024
- const searchVal = (sharedSearch ? sharedSearch : inputSearch).trim();
1021
+ const activeSearch = (typeof filter.text === "string" && filter.text.length > 0)
1022
+ ? filter.text
1023
+ : (inputSearch.length > 0 ? inputSearch : (sharedSearch ? String(sharedSearch) : ""));
1024
+ const searchVal = activeSearch.trim();
1025
1025
  const shown = filterCards(cards, { repo: filter.repo, agent: filter.agent, text: searchVal });
1026
1026
  const columns = groupByColumn(shown);
1027
1027
 
@@ -1086,8 +1086,18 @@ export default class BondBoard extends View {
1086
1086
  .child(div().w(90).child(this.field("Timeout min", input("timeout"), e.timeout))),
1087
1087
  this.field("Agente", h_flex().gap(6).flex_wrap()
1088
1088
  .children(AGENTS.map((a) => this.choice(`agent-${a}`, a, this.agent === a, () => { this.agent = a; }))), e.agent),
1089
- this.field("Motor de equipo", h_flex().gap(6).flex_wrap()
1090
- .children(TEAM_ENGINES.map((e) => this.choice(`engine-${e.id}`, e.label, this.team_engine === e.id, () => { this.team_engine = e.id; }))), null),
1089
+ ...(this.mode !== "repo"
1090
+ ? [
1091
+ this.field(
1092
+ "Motor de equipo",
1093
+ h_flex()
1094
+ .gap(6)
1095
+ .flex_wrap()
1096
+ .children(TEAM_ENGINES.map((e) => this.choice(`engine-${e.id}`, e.label, this.team_engine === e.id, () => { this.team_engine = e.id; }))),
1097
+ null
1098
+ ),
1099
+ ]
1100
+ : []),
1091
1101
  this.field("Descripción", area("description", 56), null),
1092
1102
  this.field("Encargo al agente", area("prompt", 56), null),
1093
1103
  this.field("Verificación", area("verify", 44), e.verify),
@@ -1205,8 +1215,15 @@ export default class BondBoard extends View {
1205
1215
  : ready
1206
1216
  ? div().text_size(11.5).text_color(t.dim).child(`El clon usa la sesión de GitHub${gh.login ? ` de ${gh.login}` : ""} guardada en Ajustes; llega al contenedor por stdin.`)
1207
1217
  : div().text_size(12).text_color(t.blocked).child("No hay credencial de GitHub: conéctala en Ajustes («Usar mi sesión de gh») y vuelve a lanzar.");
1218
+ const destLines = (p.destinations?.length || 0) > 0 ? [
1219
+ div().text_size(11.5).text_color(t.dim).child("Destinos de push (hub.toml):"),
1220
+ ...p.destinations.map((d) =>
1221
+ div().text_size(11.5).text_color(t.muted).child(`• ${d.name}: ${d.url || "(sin remoto)"} (base ${d.base})`)
1222
+ ),
1223
+ ] : [];
1208
1224
  return this.renderDialog(`Lanzar «${ticket.title ?? ""}»`, [
1209
1225
  div().text_size(12.5).text_color(t.muted).child(launchSummary(ticket)),
1226
+ ...destLines,
1210
1227
  ghLine,
1211
1228
  ], [
1212
1229
  this.button("dlg-cancel", "Volver", "plain", () => closeOverlay(p.overlay)),
@@ -1277,9 +1294,17 @@ export default class BondBoard extends View {
1277
1294
  ]);
1278
1295
  }
1279
1296
  if (this.view === "deliver") {
1297
+ const destLines = (p.destinations?.length || 0) > 0 ? [
1298
+ div().text_size(11.5).text_color(t.dim).child("Destinos de push (hub.toml):"),
1299
+ ...p.destinations.map((d) =>
1300
+ div().text_size(11.5).text_color(t.muted).child(`• ${d.name}: ${d.url || "(sin remoto)"} (base ${d.base})`)
1301
+ ),
1302
+ ] : [
1303
+ div().text_size(11.5).text_color(t.dim).child(`Rama ${p.branch ?? "?"} → ${p.repo ?? "?"} (solo esa rama y ese repo).`),
1304
+ ];
1280
1305
  return this.renderDialog(`Entregar «${p.title ?? ""}»`, [
1281
1306
  div().text_size(12.5).text_color(t.muted).child("Se ejecutan los comandos de verificación del ticket; si pasan, se hace commit de lo que dejó el agente, se empuja la rama y se abre el PR (en un run con hub, en cada repo con cambios y en el hub si cambió)."),
1282
- div().text_size(11.5).text_color(t.dim).child(`Rama ${p.branch ?? "?"} → ${p.repo ?? "?"} (solo esa rama y ese repo).`),
1307
+ ...destLines,
1283
1308
  ], [
1284
1309
  this.button("dlg-back", "Volver", "plain", () => closeOverlay(p.overlay)),
1285
1310
  this.button("dlg-deliver", this.busy ? "Entregando…" : "Entregar", "primary", (cx) => this.deliver(cx)),
@@ -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…";
@@ -393,7 +459,7 @@ export function validateNewTicket(form) {
393
459
  if (base && !BRANCH.test(base)) errors.base = "Rama no válida";
394
460
 
395
461
  const body = { title, agent };
396
- if (f.team_engine) {
462
+ if (mode !== "repo" && f.team_engine) {
397
463
  body.team_engine = f.team_engine === "herdr" ? "herdr" : "hc";
398
464
  }
399
465
  if (mode === "repo") {
@@ -32,20 +32,33 @@ function findNode(node, id) {
32
32
  return null;
33
33
  }
34
34
 
35
+ const FILTER_KEY = "bond.board.filter";
36
+
35
37
  export default class BondTitlebar extends View {
36
38
  init(_props, cx) {
37
- this.search = InputState.new({ placeholder: "Buscar ticket o rama..." });
39
+ const filter = shared(FILTER_KEY) ?? {};
40
+ const initialSearch = String(filter.text ?? shared("bond.search") ?? "");
41
+ this.search = InputState.new({ value: initialSearch, placeholder: "Buscar ticket o rama..." });
38
42
  this.search.on("change", (_e, cx) => {
39
- setShared("bond.search", this.search.value());
43
+ const val = this.search.value();
44
+ setShared("bond.search", val);
45
+ setShared(FILTER_KEY, { ...(shared(FILTER_KEY) ?? {}), text: val });
40
46
  cx.notify();
41
47
  });
42
48
  this.seenStats = null;
43
49
  cx.timer.every(1000, (cx) => {
44
50
  const stats = shared("bond.board_stats");
51
+ let dirty = false;
45
52
  if (stats !== this.seenStats) {
46
53
  this.seenStats = stats;
47
- cx.notify();
54
+ dirty = true;
55
+ }
56
+ const currentSearch = (shared(FILTER_KEY) ?? {}).text ?? shared("bond.search");
57
+ if (currentSearch !== undefined && currentSearch !== this.search.value()) {
58
+ this.search.set_value(String(currentSearch ?? ""));
59
+ dirty = true;
48
60
  }
61
+ if (dirty) cx.notify();
49
62
  });
50
63
  }
51
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmanuelcorral/bond-app",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Local orchestrator and hub-container runner for multi-agent tickets",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -25,7 +25,9 @@
25
25
  "app",
26
26
  "runner",
27
27
  "scripts",
28
- "README.md"
28
+ "README.md",
29
+ "!app/mods/*/gpui-kit.d.ts",
30
+ "!app/mods/*/jsconfig.json"
29
31
  ],
30
32
  "engines": {
31
33
  "node": ">=22.15.0"
@@ -300,15 +300,34 @@ function isSymlink(file: string): boolean {
300
300
  }
301
301
  }
302
302
 
303
+ /** All intermediate directories from dataDir down to filePath (inclusive). */
304
+ function intermediateDirsOf(filePath: string, dataDir: string): string[] {
305
+ const dirs: string[] = [];
306
+ const resolvedDataDir = path.resolve(dataDir);
307
+ let d = path.dirname(path.resolve(filePath));
308
+ while (d.startsWith(resolvedDataDir)) {
309
+ dirs.push(d);
310
+ if (d === resolvedDataDir) break;
311
+ d = path.dirname(d);
312
+ }
313
+ return dirs;
314
+ }
315
+
303
316
  /** Is `file` the exact copy --launcher wrote? */
304
- function ours(file: string, manifest: Record<string, string>): boolean {
305
- return !isSymlink(file) && fs.existsSync(file) && manifest[file] === sha256(file);
317
+ function ours(file: string, manifest: Record<string, string>, dataDir?: string): boolean {
318
+ if (isSymlink(file)) return false;
319
+ if (dataDir) {
320
+ for (const dir of intermediateDirsOf(file, dataDir)) {
321
+ if (isSymlink(dir)) return false;
322
+ }
323
+ }
324
+ return fs.existsSync(file) && manifest[file] === sha256(file);
306
325
  }
307
326
 
308
327
  /**
309
328
  * Refuse before writing: an unsafe data dir (it goes into a .desktop file and a sh script),
310
- * a symlink at any of our paths, or a file there that is not the copy bond-app wrote
311
- * (someone else's, or edited: --force replaces an edited one).
329
+ * a symlink at any of our paths or their intermediate directories, or a file there that is not
330
+ * the copy bond-app wrote (someone else's, or edited: --force replaces an edited one).
312
331
  */
313
332
  function checkLauncher(dataDir: string, force: boolean): void {
314
333
  if (!/^[A-Za-z0-9/._ -]+$/.test(dataDir)) {
@@ -316,11 +335,19 @@ function checkLauncher(dataDir: string, force: boolean): void {
316
335
  }
317
336
  const p = launcherPaths(dataDir);
318
337
  const manifest = readManifest(dataDir);
319
- for (const file of [p.desktop, p.icon, p.script, manifestPath(dataDir), path.dirname(p.script)]) {
338
+ const filesToCheck = [p.desktop, p.icon, p.script, manifestPath(dataDir)];
339
+ const checkedDirs = new Set<string>();
340
+ for (const file of filesToCheck) {
341
+ for (const dir of intermediateDirsOf(file, dataDir)) {
342
+ if (!checkedDirs.has(dir)) {
343
+ checkedDirs.add(dir);
344
+ if (isSymlink(dir)) throw new Error(`${dir} is a symlink: not writing through it`);
345
+ }
346
+ }
320
347
  if (isSymlink(file)) throw new Error(`${file} is a symlink: not writing through it`);
321
348
  }
322
349
  for (const file of [p.desktop, p.icon, p.script]) {
323
- if (fs.existsSync(file) && !force && !ours(file, manifest)) {
350
+ if (fs.existsSync(file) && !force && !ours(file, manifest, dataDir)) {
324
351
  throw new Error(`${file} exists and is not the copy bond-app wrote (edited, or someone else's): use --force to replace it`);
325
352
  }
326
353
  }
@@ -405,7 +432,7 @@ export function removeLauncher(dataDir: string): { removed: string[]; kept: stri
405
432
  const removed: string[] = [];
406
433
  const kept: string[] = [];
407
434
  for (const file of [p.desktop, p.icon, p.script]) {
408
- if (ours(file, manifest)) {
435
+ if (ours(file, manifest, dataDir)) {
409
436
  fs.rmSync(file);
410
437
  removed.push(file);
411
438
  } else if (fs.existsSync(file) || isSymlink(file)) {
package/src/config.ts CHANGED
@@ -38,6 +38,8 @@ export interface AppConfig {
38
38
  analysisCommand: string[] | 'off' | null;
39
39
  /** P5: time limit of the hub agent's answer. */
40
40
  analysisTimeoutMs: number;
41
+ /** D2: growing backoff delays between push/PR retries (default: [1000, 2000], up to 3 attempts). */
42
+ deliveryRetryDelaysMs: number[];
41
43
  }
42
44
 
43
45
  export function parseAnalysisCommand(raw: string | undefined): string[] | 'off' | null {
@@ -135,6 +137,7 @@ export function loadConfig(overrides: Partial<AppConfig> = {}): AppConfig {
135
137
  verifyTimeoutMs: 10 * 60 * 1000,
136
138
  analysisCommand: parseAnalysisCommand(process.env.BOND_APP_ANALYSIS_COMMAND),
137
139
  analysisTimeoutMs: 5 * 60 * 1000,
140
+ deliveryRetryDelaysMs: [1000, 2000],
138
141
  ...overrides,
139
142
  };
140
143
  }
@@ -64,23 +64,77 @@ export function bundlePathFor(name: string): string {
64
64
  /** Where the runner leaves the bundle of the run's branch for the root push. */
65
65
  export const BUNDLE_PATH = '/tmp/bond-delivery.bundle';
66
66
 
67
+ /** Exit codes of COMMIT_SCRIPT the orchestrator maps to a run outcome. */
68
+ export const COMMIT_EXIT = { treeChanged: 9 } as const;
69
+
70
+ /**
71
+ * Límite y garantías de la guarda MEDIUM-2 (M-1, M-2, M-3):
72
+ * - M-1: Si la captura del árbol de trabajo falla antes de la verificación (con verify_commands no vacío),
73
+ * la entrega falla en cerrado y el run se bloquea (no se entrega sin verificar).
74
+ * - M-2: El commit se genera directamente desde el árbol verificado usando un índice temporal
75
+ * (GIT_INDEX_FILE) y `git commit-tree`, garantizando que el índice compartido (.git/index) con el
76
+ * agente vivo no puede interponerse ni alterar el commit.
77
+ * - M-3: Para cerrar el «flip-flop», el orquestador verifica el árbol de trabajo al inicio de la
78
+ * verificación, después de cada comando de verificación y antes del commit. Como límite documentado:
79
+ * si un proceso en el contenedor mutara un archivo y lo restaurara exactamente a su estado inicial
80
+ * en medio de la ejecución de un mismo comando (flip-flop intra-comando), el árbol final verificado
81
+ * coincide idénticamente con el commit, pero para hermetismo completo contra agentes hostiles se
82
+ * requeriría congelar los procesos del contenedor (cgroups freezer) o montar el árbol en solo lectura.
83
+ *
84
+ * Runs as `runner` in the clone before verification to capture the working tree sha (MEDIUM-2).
85
+ * Args: directory (default /workspace/repo).
86
+ */
87
+ export const TREE_SCRIPT = [
88
+ 'set -eu',
89
+ 'cd "${1:-/workspace/repo}"',
90
+ 'tmp_index=$(mktemp)',
91
+ 'rm -f "$tmp_index"',
92
+ 'trap \'rm -f "$tmp_index"\' EXIT',
93
+ 'if git rev-parse --verify --quiet HEAD >/dev/null 2>&1; then',
94
+ ' GIT_INDEX_FILE="$tmp_index" git read-tree HEAD',
95
+ 'fi',
96
+ 'GIT_INDEX_FILE="$tmp_index" git -c core.hooksPath=/dev/null add -A',
97
+ 'echo "tree=$(GIT_INDEX_FILE="$tmp_index" git write-tree)"',
98
+ ].join('\n');
99
+
67
100
  /**
68
101
  * Runs as `runner` in the clone. Args: target branch, commit message, author name, author
69
- * email. Commits whatever the agent left (hooks off), refuses if the clone is not on the
70
- * run's branch, bundles that branch and prints its head sha. Nothing it prints decides
71
- * what is pushed (review HIGH-1: the agent controls the clone and /tmp): root checks the
72
- * bundle against this sha and measures the branch against the real base from GitHub.
102
+ * email, clone directory (optional), bundle path (optional), expected tree sha (optional, MEDIUM-2).
103
+ * Commits whatever the agent left (hooks off), refuses if the clone is not on the
104
+ * run's branch or if the tree changed after verification, bundles that branch and prints its head sha.
105
+ * Nothing it prints decides what is pushed (review HIGH-1: the agent controls the clone and /tmp):
106
+ * root checks the bundle against this sha and measures the branch against the real base from GitHub.
107
+ *
108
+ * M-2: Uses an isolated temporary index (GIT_INDEX_FILE) seeded from HEAD and `git commit-tree`
109
+ * so the shared .git/index cannot interfere.
73
110
  */
74
111
  export const COMMIT_SCRIPT = [
75
112
  'set -eu',
76
113
  // P5: $5 is the clone (a hub repo's worktree) and $6 the bundle; the single repo's by default.
114
+ // MEDIUM-2: $7 is the expected tree sha from before verification.
77
115
  'cd "${5:-/workspace/repo}"',
78
116
  `bundle="\${6:-${BUNDLE_PATH}}"`,
79
117
  'cur=$(git symbolic-ref --quiet --short HEAD || true)',
80
118
  'if [ "$cur" != "$1" ]; then echo "the clone is on \'$cur\', not on the run branch \'$1\'" >&2; exit 3; fi',
81
- 'git -c core.hooksPath=/dev/null add -A',
82
- 'if ! git diff --cached --quiet; then',
83
- ' git -c core.hooksPath=/dev/null -c user.name="$3" -c user.email="$4" commit -q --no-verify -m "$2"',
119
+ 'tmp_index=$(mktemp)',
120
+ 'rm -f "$tmp_index"',
121
+ 'trap \'rm -f "$tmp_index"\' EXIT',
122
+ 'if git rev-parse --verify --quiet HEAD >/dev/null 2>&1; then',
123
+ ' GIT_INDEX_FILE="$tmp_index" git read-tree HEAD',
124
+ 'fi',
125
+ 'GIT_INDEX_FILE="$tmp_index" git -c core.hooksPath=/dev/null add -A',
126
+ 'cur_tree=$(GIT_INDEX_FILE="$tmp_index" git write-tree)',
127
+ 'if [ -n "${7:-}" ]; then',
128
+ ` if [ "$cur_tree" != "$7" ]; then echo "commit failed: working tree changed after verification ($cur_tree != $7)" >&2; exit ${COMMIT_EXIT.treeChanged}; fi`,
129
+ 'fi',
130
+ 'head_tree=$(git rev-parse --verify --quiet "HEAD^{tree}" 2>/dev/null || true)',
131
+ 'if [ "$cur_tree" != "$head_tree" ]; then',
132
+ ' if git rev-parse --verify --quiet HEAD >/dev/null 2>&1; then',
133
+ ' commit_sha=$(GIT_AUTHOR_NAME="$3" GIT_AUTHOR_EMAIL="$4" GIT_COMMITTER_NAME="$3" GIT_COMMITTER_EMAIL="$4" git commit-tree "$cur_tree" -p HEAD -m "$2")',
134
+ ' else',
135
+ ' commit_sha=$(GIT_AUTHOR_NAME="$3" GIT_AUTHOR_EMAIL="$4" GIT_COMMITTER_NAME="$3" GIT_COMMITTER_EMAIL="$4" git commit-tree "$cur_tree" -m "$2")',
136
+ ' fi',
137
+ ' git update-ref "refs/heads/$1" "$commit_sha"',
84
138
  'fi',
85
139
  'rm -f -- "$bundle"',
86
140
  'git bundle create -q "$bundle" "refs/heads/$1"',