@jmanuelcorral/bond-app 0.1.4 → 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.
@@ -458,7 +458,11 @@ export function validateNewTicket(form) {
458
458
  const base = String(f.base ?? "").trim();
459
459
  if (base && !BRANCH.test(base)) errors.base = "Rama no válida";
460
460
 
461
+ const model = agent === "pi" && f.model ? String(f.model).trim() : null;
462
+
461
463
  const body = { title, agent };
464
+ body.bondify = f.bondify !== undefined ? Boolean(f.bondify) : true;
465
+ if (model) body.model = model;
462
466
  if (mode !== "repo" && f.team_engine) {
463
467
  body.team_engine = f.team_engine === "herdr" ? "herdr" : "hc";
464
468
  }
@@ -516,6 +520,10 @@ export function validateNewTicket(form) {
516
520
  else if (verify.some((c) => c.length > 2000)) errors.verify = "Un comando es demasiado largo";
517
521
  else body.verify_commands = verify;
518
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
+
519
527
  const issueUrl = String(f.issue_url ?? f.issue ?? "").trim();
520
528
  if (issueUrl) {
521
529
  if (!/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/issues\/[1-9][0-9]*(?:[#?].*)?$/.test(issueUrl)) {
@@ -533,6 +541,35 @@ export async function createTicket(api, body) {
533
541
  return api("/tickets", { method: "POST", body });
534
542
  }
535
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
+
536
573
  /** P7: Delete ticket and tear down all associated resources (container, network, machine, worktrees, branches). */
537
574
  export async function deleteTicket(api, ticketId, force = false) {
538
575
  const query = force ? "?force=true" : "";
@@ -543,3 +580,13 @@ export async function deleteTicket(api, ticketId, force = false) {
543
580
  export async function getDeletePreview(api, ticketId) {
544
581
  return api(`/tickets/${encodeURIComponent(ticketId)}/delete_preview`);
545
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
  };