@brainbase-labs/cli 0.7.1 → 0.8.1

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.
Files changed (2) hide show
  1. package/dist/index.js +515 -349
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1056,14 +1056,14 @@ var require_foldFlowLines = __commonJS((exports) => {
1056
1056
  var FOLD_FLOW = "flow";
1057
1057
  var FOLD_BLOCK = "block";
1058
1058
  var FOLD_QUOTED = "quoted";
1059
- function foldFlowLines(text, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
1059
+ function foldFlowLines(text2, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
1060
1060
  if (!lineWidth || lineWidth < 0)
1061
- return text;
1061
+ return text2;
1062
1062
  if (lineWidth < minContentWidth)
1063
1063
  minContentWidth = 0;
1064
1064
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
1065
- if (text.length <= endStep)
1066
- return text;
1065
+ if (text2.length <= endStep)
1066
+ return text2;
1067
1067
  const folds = [];
1068
1068
  const escapedFolds = {};
1069
1069
  let end = lineWidth - indent.length;
@@ -1080,14 +1080,14 @@ var require_foldFlowLines = __commonJS((exports) => {
1080
1080
  let escStart = -1;
1081
1081
  let escEnd = -1;
1082
1082
  if (mode === FOLD_BLOCK) {
1083
- i = consumeMoreIndentedLines(text, i, indent.length);
1083
+ i = consumeMoreIndentedLines(text2, i, indent.length);
1084
1084
  if (i !== -1)
1085
1085
  end = i + endStep;
1086
1086
  }
1087
- for (let ch;ch = text[i += 1]; ) {
1087
+ for (let ch;ch = text2[i += 1]; ) {
1088
1088
  if (mode === FOLD_QUOTED && ch === "\\") {
1089
1089
  escStart = i;
1090
- switch (text[i + 1]) {
1090
+ switch (text2[i + 1]) {
1091
1091
  case "x":
1092
1092
  i += 3;
1093
1093
  break;
@@ -1105,13 +1105,13 @@ var require_foldFlowLines = __commonJS((exports) => {
1105
1105
  if (ch === `
1106
1106
  `) {
1107
1107
  if (mode === FOLD_BLOCK)
1108
- i = consumeMoreIndentedLines(text, i, indent.length);
1108
+ i = consumeMoreIndentedLines(text2, i, indent.length);
1109
1109
  end = i + indent.length + endStep;
1110
1110
  split = undefined;
1111
1111
  } else {
1112
1112
  if (ch === " " && prev && prev !== " " && prev !== `
1113
1113
  ` && prev !== "\t") {
1114
- const next = text[i + 1];
1114
+ const next = text2[i + 1];
1115
1115
  if (next && next !== " " && next !== `
1116
1116
  ` && next !== "\t")
1117
1117
  split = i;
@@ -1124,12 +1124,12 @@ var require_foldFlowLines = __commonJS((exports) => {
1124
1124
  } else if (mode === FOLD_QUOTED) {
1125
1125
  while (prev === " " || prev === "\t") {
1126
1126
  prev = ch;
1127
- ch = text[i += 1];
1127
+ ch = text2[i += 1];
1128
1128
  overflow = true;
1129
1129
  }
1130
1130
  const j2 = i > escEnd + 1 ? i - 2 : escStart - 1;
1131
1131
  if (escapedFolds[j2])
1132
- return text;
1132
+ return text2;
1133
1133
  folds.push(j2);
1134
1134
  escapedFolds[j2] = true;
1135
1135
  end = j2 + endStep;
@@ -1144,40 +1144,40 @@ var require_foldFlowLines = __commonJS((exports) => {
1144
1144
  if (overflow && onOverflow)
1145
1145
  onOverflow();
1146
1146
  if (folds.length === 0)
1147
- return text;
1147
+ return text2;
1148
1148
  if (onFold)
1149
1149
  onFold();
1150
- let res = text.slice(0, folds[0]);
1150
+ let res = text2.slice(0, folds[0]);
1151
1151
  for (let i2 = 0;i2 < folds.length; ++i2) {
1152
1152
  const fold = folds[i2];
1153
- const end2 = folds[i2 + 1] || text.length;
1153
+ const end2 = folds[i2 + 1] || text2.length;
1154
1154
  if (fold === 0)
1155
1155
  res = `
1156
- ${indent}${text.slice(0, end2)}`;
1156
+ ${indent}${text2.slice(0, end2)}`;
1157
1157
  else {
1158
1158
  if (mode === FOLD_QUOTED && escapedFolds[fold])
1159
- res += `${text[fold]}\\`;
1159
+ res += `${text2[fold]}\\`;
1160
1160
  res += `
1161
- ${indent}${text.slice(fold + 1, end2)}`;
1161
+ ${indent}${text2.slice(fold + 1, end2)}`;
1162
1162
  }
1163
1163
  }
1164
1164
  return res;
1165
1165
  }
1166
- function consumeMoreIndentedLines(text, i, indent) {
1166
+ function consumeMoreIndentedLines(text2, i, indent) {
1167
1167
  let end = i;
1168
1168
  let start = i + 1;
1169
- let ch = text[start];
1169
+ let ch = text2[start];
1170
1170
  while (ch === " " || ch === "\t") {
1171
1171
  if (i < start + indent) {
1172
- ch = text[++i];
1172
+ ch = text2[++i];
1173
1173
  } else {
1174
1174
  do {
1175
- ch = text[++i];
1175
+ ch = text2[++i];
1176
1176
  } while (ch && ch !== `
1177
1177
  `);
1178
1178
  end = i;
1179
1179
  start = i + 1;
1180
- ch = text[start];
1180
+ ch = text2[start];
1181
1181
  }
1182
1182
  }
1183
1183
  return end;
@@ -7701,8 +7701,8 @@ var require_react_development = __commonJS((exports, module) => {
7701
7701
  }
7702
7702
  var didWarnAboutMaps = false;
7703
7703
  var userProvidedKeyEscapeRegex = /\/+/g;
7704
- function escapeUserProvidedKey(text) {
7705
- return text.replace(userProvidedKeyEscapeRegex, "$&/");
7704
+ function escapeUserProvidedKey(text2) {
7705
+ return text2.replace(userProvidedKeyEscapeRegex, "$&/");
7706
7706
  }
7707
7707
  function getElementKey(element, index) {
7708
7708
  if (typeof element === "object" && element !== null && element.key != null) {
@@ -8975,26 +8975,26 @@ var require_signals = __commonJS((exports, module) => {
8975
8975
 
8976
8976
  // node_modules/signal-exit/index.js
8977
8977
  var require_signal_exit = __commonJS((exports, module) => {
8978
- var process3 = global.process;
8979
- var processOk = function(process4) {
8980
- return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
8978
+ var process4 = global.process;
8979
+ var processOk = function(process5) {
8980
+ return process5 && typeof process5 === "object" && typeof process5.removeListener === "function" && typeof process5.emit === "function" && typeof process5.reallyExit === "function" && typeof process5.listeners === "function" && typeof process5.kill === "function" && typeof process5.pid === "number" && typeof process5.on === "function";
8981
8981
  };
8982
- if (!processOk(process3)) {
8982
+ if (!processOk(process4)) {
8983
8983
  module.exports = function() {
8984
8984
  return function() {};
8985
8985
  };
8986
8986
  } else {
8987
8987
  assert = __require("assert");
8988
8988
  signals = require_signals();
8989
- isWin = /^win/i.test(process3.platform);
8989
+ isWin = /^win/i.test(process4.platform);
8990
8990
  EE = __require("events");
8991
8991
  if (typeof EE !== "function") {
8992
8992
  EE = EE.EventEmitter;
8993
8993
  }
8994
- if (process3.__signal_exit_emitter__) {
8995
- emitter = process3.__signal_exit_emitter__;
8994
+ if (process4.__signal_exit_emitter__) {
8995
+ emitter = process4.__signal_exit_emitter__;
8996
8996
  } else {
8997
- emitter = process3.__signal_exit_emitter__ = new EE;
8997
+ emitter = process4.__signal_exit_emitter__ = new EE;
8998
8998
  emitter.count = 0;
8999
8999
  emitter.emitted = {};
9000
9000
  }
@@ -9030,11 +9030,11 @@ var require_signal_exit = __commonJS((exports, module) => {
9030
9030
  loaded = false;
9031
9031
  signals.forEach(function(sig) {
9032
9032
  try {
9033
- process3.removeListener(sig, sigListeners[sig]);
9033
+ process4.removeListener(sig, sigListeners[sig]);
9034
9034
  } catch (er) {}
9035
9035
  });
9036
- process3.emit = originalProcessEmit;
9037
- process3.reallyExit = originalProcessReallyExit;
9036
+ process4.emit = originalProcessEmit;
9037
+ process4.reallyExit = originalProcessReallyExit;
9038
9038
  emitter.count -= 1;
9039
9039
  };
9040
9040
  module.exports.unload = unload;
@@ -9051,7 +9051,7 @@ var require_signal_exit = __commonJS((exports, module) => {
9051
9051
  if (!processOk(global.process)) {
9052
9052
  return;
9053
9053
  }
9054
- var listeners = process3.listeners(sig);
9054
+ var listeners = process4.listeners(sig);
9055
9055
  if (listeners.length === emitter.count) {
9056
9056
  unload();
9057
9057
  emit("exit", null, sig);
@@ -9059,7 +9059,7 @@ var require_signal_exit = __commonJS((exports, module) => {
9059
9059
  if (isWin && sig === "SIGHUP") {
9060
9060
  sig = "SIGINT";
9061
9061
  }
9062
- process3.kill(process3.pid, sig);
9062
+ process4.kill(process4.pid, sig);
9063
9063
  }
9064
9064
  };
9065
9065
  });
@@ -9075,35 +9075,35 @@ var require_signal_exit = __commonJS((exports, module) => {
9075
9075
  emitter.count += 1;
9076
9076
  signals = signals.filter(function(sig) {
9077
9077
  try {
9078
- process3.on(sig, sigListeners[sig]);
9078
+ process4.on(sig, sigListeners[sig]);
9079
9079
  return true;
9080
9080
  } catch (er) {
9081
9081
  return false;
9082
9082
  }
9083
9083
  });
9084
- process3.emit = processEmit;
9085
- process3.reallyExit = processReallyExit;
9084
+ process4.emit = processEmit;
9085
+ process4.reallyExit = processReallyExit;
9086
9086
  };
9087
9087
  module.exports.load = load;
9088
- originalProcessReallyExit = process3.reallyExit;
9088
+ originalProcessReallyExit = process4.reallyExit;
9089
9089
  processReallyExit = function processReallyExit2(code) {
9090
9090
  if (!processOk(global.process)) {
9091
9091
  return;
9092
9092
  }
9093
- process3.exitCode = code || 0;
9094
- emit("exit", process3.exitCode, null);
9095
- emit("afterexit", process3.exitCode, null);
9096
- originalProcessReallyExit.call(process3, process3.exitCode);
9093
+ process4.exitCode = code || 0;
9094
+ emit("exit", process4.exitCode, null);
9095
+ emit("afterexit", process4.exitCode, null);
9096
+ originalProcessReallyExit.call(process4, process4.exitCode);
9097
9097
  };
9098
- originalProcessEmit = process3.emit;
9098
+ originalProcessEmit = process4.emit;
9099
9099
  processEmit = function processEmit2(ev, arg) {
9100
9100
  if (ev === "exit" && processOk(global.process)) {
9101
9101
  if (arg !== undefined) {
9102
- process3.exitCode = arg;
9102
+ process4.exitCode = arg;
9103
9103
  }
9104
9104
  var ret = originalProcessEmit.apply(this, arguments);
9105
- emit("exit", process3.exitCode, null);
9106
- emit("afterexit", process3.exitCode, null);
9105
+ emit("exit", process4.exitCode, null);
9106
+ emit("afterexit", process4.exitCode, null);
9107
9107
  return ret;
9108
9108
  } else {
9109
9109
  return originalProcessEmit.apply(this, arguments);
@@ -11818,8 +11818,8 @@ var require_react_reconciler_development = __commonJS((exports, module) => {
11818
11818
  didNotFindHydratableInstanceWithinContainer(parentContainer, type, props);
11819
11819
  break;
11820
11820
  case HostText:
11821
- var text = fiber.pendingProps;
11822
- didNotFindHydratableTextInstanceWithinContainer(parentContainer, text);
11821
+ var text2 = fiber.pendingProps;
11822
+ didNotFindHydratableTextInstanceWithinContainer(parentContainer, text2);
11823
11823
  break;
11824
11824
  case SuspenseComponent:
11825
11825
  didNotFindHydratableSuspenseInstanceWithinContainer(parentContainer);
@@ -11896,8 +11896,8 @@ var require_react_reconciler_development = __commonJS((exports, module) => {
11896
11896
  return false;
11897
11897
  }
11898
11898
  case HostText: {
11899
- var text = fiber.pendingProps;
11900
- var textInstance = canHydrateTextInstance(nextInstance, text);
11899
+ var text2 = fiber.pendingProps;
11900
+ var textInstance = canHydrateTextInstance(nextInstance, text2);
11901
11901
  if (textInstance !== null) {
11902
11902
  fiber.stateNode = textInstance;
11903
11903
  hydrationParentFiber = fiber;
@@ -18602,8 +18602,8 @@ Check the render method of \`` + ownerName + "`.";
18602
18602
  } else if (node.tag === HostText) {
18603
18603
  var _instance = node.stateNode;
18604
18604
  if (needsVisibilityToggle && isHidden) {
18605
- var text = node.memoizedProps;
18606
- _instance = cloneHiddenTextInstance(_instance, text, node);
18605
+ var text2 = node.memoizedProps;
18606
+ _instance = cloneHiddenTextInstance(_instance, text2, node);
18607
18607
  }
18608
18608
  appendInitialChild(parent, _instance);
18609
18609
  } else if (node.tag === HostPortal)
@@ -18647,8 +18647,8 @@ Check the render method of \`` + ownerName + "`.";
18647
18647
  } else if (node.tag === HostText) {
18648
18648
  var _instance2 = node.stateNode;
18649
18649
  if (needsVisibilityToggle && isHidden) {
18650
- var text = node.memoizedProps;
18651
- _instance2 = cloneHiddenTextInstance(_instance2, text, node);
18650
+ var text2 = node.memoizedProps;
18651
+ _instance2 = cloneHiddenTextInstance(_instance2, text2, node);
18652
18652
  }
18653
18653
  appendChildToContainerChildSet(containerChildSet, _instance2);
18654
18654
  } else if (node.tag === HostPortal)
@@ -21223,10 +21223,10 @@ It looks like you wrote ` + hookName + "(async () => ...) or returned a Promise.
21223
21223
  value: role
21224
21224
  };
21225
21225
  }
21226
- function createTextSelector(text) {
21226
+ function createTextSelector(text2) {
21227
21227
  return {
21228
21228
  $$typeof: TEXT_TYPE,
21229
- value: text
21229
+ value: text2
21230
21230
  };
21231
21231
  }
21232
21232
  function createTestNameSelector(id) {
@@ -28583,7 +28583,7 @@ var require_jsx_dev_runtime = __commonJS((exports, module) => {
28583
28583
 
28584
28584
  // src/index.ts
28585
28585
  var import_picocolors40 = __toESM(require_picocolors(), 1);
28586
- import process13 from "node:process";
28586
+ import process14 from "node:process";
28587
28587
  import fs51 from "node:fs";
28588
28588
 
28589
28589
  // src/cli/template.ts
@@ -29449,7 +29449,7 @@ function padStart(s, n) {
29449
29449
  // package.json
29450
29450
  var package_default = {
29451
29451
  name: "@brainbase-labs/cli",
29452
- version: "0.7.1",
29452
+ version: "0.8.1",
29453
29453
  description: "Pack, share, and install agent templates across harnesses (Claude Code, Codex, ...).",
29454
29454
  type: "module",
29455
29455
  bin: {
@@ -29539,6 +29539,62 @@ function ensureNotCancelled(value) {
29539
29539
  return value;
29540
29540
  }
29541
29541
 
29542
+ // src/core/tty.ts
29543
+ import process2 from "node:process";
29544
+ function isInteractive() {
29545
+ if (process2.env.BRAINBASE_NON_INTERACTIVE === "1")
29546
+ return false;
29547
+ if (process2.env.CI)
29548
+ return false;
29549
+ return Boolean(process2.stdin.isTTY);
29550
+ }
29551
+
29552
+ // src/ui/prompt.ts
29553
+ class NonInteractiveError extends Error {
29554
+ constructor(message) {
29555
+ super(message);
29556
+ this.name = "NonInteractiveError";
29557
+ }
29558
+ }
29559
+ async function select(opts) {
29560
+ if (!isInteractive()) {
29561
+ if (opts.fallback !== undefined)
29562
+ return opts.fallback;
29563
+ const autoPick = opts.autoPick !== false;
29564
+ if (autoPick && opts.options.length === 1)
29565
+ return opts.options[0].value;
29566
+ throw new NonInteractiveError(`${opts.message} needs an interactive terminal. ${opts.flagHint}`);
29567
+ }
29568
+ const choice = await ie({
29569
+ message: opts.message,
29570
+ options: opts.options,
29571
+ ...opts.initialValue !== undefined ? { initialValue: opts.initialValue } : {}
29572
+ });
29573
+ return ensureNotCancelled(choice);
29574
+ }
29575
+ async function text(opts) {
29576
+ if (!isInteractive()) {
29577
+ if (opts.fallback !== undefined)
29578
+ return opts.fallback;
29579
+ throw new NonInteractiveError(`${opts.message} needs an interactive terminal. ${opts.flagHint}`);
29580
+ }
29581
+ const ans = await te({
29582
+ message: opts.message,
29583
+ placeholder: opts.placeholder,
29584
+ defaultValue: opts.defaultValue,
29585
+ validate: opts.validate
29586
+ });
29587
+ return ensureNotCancelled(ans);
29588
+ }
29589
+ function requireInteractive(flagHint) {
29590
+ if (!isInteractive()) {
29591
+ throw new NonInteractiveError(`This step needs an interactive terminal. ${flagHint}`);
29592
+ }
29593
+ }
29594
+ function autoProceed(yes) {
29595
+ return Boolean(yes) || !isInteractive();
29596
+ }
29597
+
29542
29598
  // src/ui/symbols.ts
29543
29599
  var import_picocolors5 = __toESM(require_picocolors(), 1);
29544
29600
  var sym = {
@@ -29631,6 +29687,7 @@ function pruneRedundant(set) {
29631
29687
  }
29632
29688
  }
29633
29689
  async function pickPaths(rootDir) {
29690
+ requireInteractive("Selecting files is interactive — run this in a real terminal.");
29634
29691
  const root = path.resolve(rootDir);
29635
29692
  const selected = new Set;
29636
29693
  let current = root;
@@ -34498,6 +34555,69 @@ ${block}
34498
34555
  fs8.writeFileSync(instructionsFile, next);
34499
34556
  }
34500
34557
 
34558
+ // src/core/mcp-proxy.ts
34559
+ var DEFAULT_MCP_PROXY_BASE = "https://brainbase-mcp-proxy.onrender.com";
34560
+ var THREAD_ID_TEMPLATE = "${BRAINBASE_THREAD_ID}";
34561
+ var PROXY_AUTH_HEADER = "Bearer ${BRAINBASE_TOKEN}";
34562
+ function mcpProxyBaseUrl() {
34563
+ const envOverride = process.env.BRAINBASE_MCP_PROXY_URL;
34564
+ if (envOverride) {
34565
+ const stripped = envOverride.replace(/\/+$/, "");
34566
+ if (stripped)
34567
+ return stripped;
34568
+ }
34569
+ return DEFAULT_MCP_PROXY_BASE;
34570
+ }
34571
+ function proxifyMcpPayload(payload) {
34572
+ if (!payload)
34573
+ return payload;
34574
+ if (!shouldProxy(payload))
34575
+ return payload;
34576
+ const base = mcpProxyBaseUrl();
34577
+ const upstreamUrl = payload.url;
34578
+ const existingHeaders = payload.headers ?? {};
34579
+ return {
34580
+ ...payload,
34581
+ url: `${base}/t/${THREAD_ID_TEMPLATE}/${upstreamUrl}`,
34582
+ headers: { ...existingHeaders, Authorization: PROXY_AUTH_HEADER }
34583
+ };
34584
+ }
34585
+ function shouldProxy(payload) {
34586
+ const url = payload.url;
34587
+ if (typeof url !== "string" || url.length === 0)
34588
+ return false;
34589
+ if (typeof payload.command === "string" && payload.command.length > 0)
34590
+ return false;
34591
+ const headers = payload.headers;
34592
+ if (headers && typeof headers === "object" && Object.keys(headers).length > 0) {
34593
+ return false;
34594
+ }
34595
+ if (url.startsWith(mcpProxyBaseUrl()))
34596
+ return false;
34597
+ if (url.includes(`/t/${THREAD_ID_TEMPLATE}/`))
34598
+ return false;
34599
+ return true;
34600
+ }
34601
+ function resolveMcpEnvTemplates(payload, env = process.env) {
34602
+ if (!payload)
34603
+ return payload;
34604
+ const sub = (s) => s.replace(/\$\{([A-Z0-9_]+)\}/g, (literal, name) => {
34605
+ const value = env[name];
34606
+ return value === undefined || value === "" ? literal : value;
34607
+ });
34608
+ const out = { ...payload };
34609
+ if (typeof out.url === "string")
34610
+ out.url = sub(out.url);
34611
+ if (out.headers && typeof out.headers === "object") {
34612
+ const resolved = {};
34613
+ for (const [k2, v2] of Object.entries(out.headers)) {
34614
+ resolved[k2] = typeof v2 === "string" ? sub(v2) : v2;
34615
+ }
34616
+ out.headers = resolved;
34617
+ }
34618
+ return out;
34619
+ }
34620
+
34501
34621
  // src/harnesses/claude-code/install.ts
34502
34622
  var MARK_START = (name) => `<!-- brainbase:start name=${name} -->`;
34503
34623
  var MARK_END = (name) => `<!-- brainbase:end name=${name} -->`;
@@ -34630,7 +34750,7 @@ async function installMcp(comp, opts, ctx) {
34630
34750
  }
34631
34751
  }
34632
34752
  }
34633
- setMcpServer(mcpStore, comp.slug, normalizeMcpPayload(payload));
34753
+ setMcpServer(mcpStore, comp.slug, normalizeMcpPayload(resolveMcpEnvTemplates(payload)));
34634
34754
  return {
34635
34755
  type: "mcp",
34636
34756
  slug: comp.slug,
@@ -36474,7 +36594,7 @@ async function installMcp2(comp, opts, ctx) {
36474
36594
  }
36475
36595
  }
36476
36596
  }
36477
- setMcpServer2(config, comp.slug, payload);
36597
+ setMcpServer2(config, comp.slug, resolveMcpEnvTemplates(payload));
36478
36598
  return {
36479
36599
  type: "mcp",
36480
36600
  slug: comp.slug,
@@ -37233,7 +37353,7 @@ async function installMcp3(comp, opts, ctx) {
37233
37353
  }
37234
37354
  }
37235
37355
  }
37236
- setMcpServer3(mcpStore, comp.slug, normalizeMcpPayload2(payload));
37356
+ setMcpServer3(mcpStore, comp.slug, normalizeMcpPayload2(resolveMcpEnvTemplates(payload)));
37237
37357
  return {
37238
37358
  type: "mcp",
37239
37359
  slug: comp.slug,
@@ -37701,11 +37821,11 @@ class LocalRegistry {
37701
37821
 
37702
37822
  // node_modules/ink/build/render.js
37703
37823
  import { Stream } from "node:stream";
37704
- import process12 from "node:process";
37824
+ import process13 from "node:process";
37705
37825
 
37706
37826
  // node_modules/ink/build/ink.js
37707
37827
  var import_react10 = __toESM(require_react(), 1);
37708
- import process11 from "node:process";
37828
+ import process12 from "node:process";
37709
37829
  // node_modules/es-toolkit/dist/function/debounce.mjs
37710
37830
  function debounce(func, debounceMs, { signal, edges } = {}) {
37711
37831
  let pendingThis = undefined;
@@ -37862,7 +37982,7 @@ __export(exports_base, {
37862
37982
  beep: () => beep,
37863
37983
  ConEmu: () => ConEmu
37864
37984
  });
37865
- import process2 from "node:process";
37985
+ import process3 from "node:process";
37866
37986
  import os2 from "node:os";
37867
37987
 
37868
37988
  // node_modules/environment/index.js
@@ -37888,12 +38008,12 @@ var ESC = "\x1B[";
37888
38008
  var OSC = "\x1B]";
37889
38009
  var BEL = "\x07";
37890
38010
  var SEP = ";";
37891
- var isTerminalApp = !isBrowser && process2.env.TERM_PROGRAM === "Apple_Terminal";
37892
- var isWindows2 = !isBrowser && process2.platform === "win32";
37893
- var isTmux = !isBrowser && (process2.env.TERM?.startsWith("screen") || process2.env.TERM?.startsWith("tmux") || process2.env.TMUX !== undefined);
38011
+ var isTerminalApp = !isBrowser && process3.env.TERM_PROGRAM === "Apple_Terminal";
38012
+ var isWindows2 = !isBrowser && process3.platform === "win32";
38013
+ var isTmux = !isBrowser && (process3.env.TERM?.startsWith("screen") || process3.env.TERM?.startsWith("tmux") || process3.env.TMUX !== undefined);
37894
38014
  var cwdFunction = isBrowser ? () => {
37895
38015
  throw new Error("`process.cwd()` only works in Node.js, not the browser.");
37896
- } : process2.cwd;
38016
+ } : process3.cwd;
37897
38017
  var wrapOsc = (sequence) => {
37898
38018
  if (isTmux) {
37899
38019
  return "\x1BPtmux;" + sequence.replaceAll("\x1B", "\x1B\x1B") + "\x1B\\";
@@ -37978,12 +38098,12 @@ var enterAlternativeScreen = ESC + "?1049h";
37978
38098
  var exitAlternativeScreen = ESC + "?1049l";
37979
38099
  var beginSynchronizedOutput = ESC + "?2026h";
37980
38100
  var endSynchronizedOutput = ESC + "?2026l";
37981
- var synchronizedOutput = (text) => beginSynchronizedOutput + text + endSynchronizedOutput;
38101
+ var synchronizedOutput = (text2) => beginSynchronizedOutput + text2 + endSynchronizedOutput;
37982
38102
  var beep = BEL;
37983
- var link = (text, url) => {
38103
+ var link = (text2, url) => {
37984
38104
  const openLink = wrapOsc(`${OSC}8${SEP}${SEP}${url}${BEL}`);
37985
38105
  const closeLink = wrapOsc(`${OSC}8${SEP}${SEP}${BEL}`);
37986
- return openLink + text + closeLink;
38106
+ return openLink + text2 + closeLink;
37987
38107
  };
37988
38108
  var image = (data, options = {}) => {
37989
38109
  let returnValue = `${OSC}1337;File=inline=1`;
@@ -39726,7 +39846,7 @@ var src_default = Yoga;
39726
39846
  // node_modules/ink/build/reconciler.js
39727
39847
  var import_react_reconciler = __toESM(require_react_reconciler(), 1);
39728
39848
  var import_constants = __toESM(require_constants(), 1);
39729
- import process3 from "node:process";
39849
+ import process4 from "node:process";
39730
39850
 
39731
39851
  // node_modules/ansi-regex/index.js
39732
39852
  function ansiRegex({ onlyFirst = false } = {}) {
@@ -39900,21 +40020,21 @@ function widestLine(string) {
39900
40020
 
39901
40021
  // node_modules/ink/build/measure-text.js
39902
40022
  var cache = {};
39903
- var measureText = (text) => {
39904
- if (text.length === 0) {
40023
+ var measureText = (text2) => {
40024
+ if (text2.length === 0) {
39905
40025
  return {
39906
40026
  width: 0,
39907
40027
  height: 0
39908
40028
  };
39909
40029
  }
39910
- const cachedDimensions = cache[text];
40030
+ const cachedDimensions = cache[text2];
39911
40031
  if (cachedDimensions) {
39912
40032
  return cachedDimensions;
39913
40033
  }
39914
- const width = widestLine(text);
39915
- const height = text.split(`
40034
+ const width = widestLine(text2);
40035
+ const height = text2.split(`
39916
40036
  `).length;
39917
- cache[text] = { width, height };
40037
+ cache[text2] = { width, height };
39918
40038
  return { width, height };
39919
40039
  };
39920
40040
  var measure_text_default = measureText;
@@ -40363,15 +40483,15 @@ function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
40363
40483
  }
40364
40484
  return wantedIndex;
40365
40485
  }
40366
- function cliTruncate(text, columns, options = {}) {
40486
+ function cliTruncate(text2, columns, options = {}) {
40367
40487
  const {
40368
40488
  position = "end",
40369
40489
  space = false,
40370
40490
  preferTruncationOnSpace = false
40371
40491
  } = options;
40372
40492
  let { truncationCharacter = "…" } = options;
40373
- if (typeof text !== "string") {
40374
- throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
40493
+ if (typeof text2 !== "string") {
40494
+ throw new TypeError(`Expected \`input\` to be a string, got ${typeof text2}`);
40375
40495
  }
40376
40496
  if (typeof columns !== "number") {
40377
40497
  throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
@@ -40382,19 +40502,19 @@ function cliTruncate(text, columns, options = {}) {
40382
40502
  if (columns === 1) {
40383
40503
  return truncationCharacter;
40384
40504
  }
40385
- const length = stringWidth(text);
40505
+ const length = stringWidth(text2);
40386
40506
  if (length <= columns) {
40387
- return text;
40507
+ return text2;
40388
40508
  }
40389
40509
  if (position === "start") {
40390
40510
  if (preferTruncationOnSpace) {
40391
- const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
40392
- return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
40511
+ const nearestSpace = getIndexOfNearestSpace(text2, length - columns + 1, true);
40512
+ return truncationCharacter + sliceAnsi(text2, nearestSpace, length).trim();
40393
40513
  }
40394
40514
  if (space === true) {
40395
40515
  truncationCharacter += " ";
40396
40516
  }
40397
- return truncationCharacter + sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
40517
+ return truncationCharacter + sliceAnsi(text2, length - columns + stringWidth(truncationCharacter), length);
40398
40518
  }
40399
40519
  if (position === "middle") {
40400
40520
  if (space === true) {
@@ -40402,36 +40522,36 @@ function cliTruncate(text, columns, options = {}) {
40402
40522
  }
40403
40523
  const half = Math.floor(columns / 2);
40404
40524
  if (preferTruncationOnSpace) {
40405
- const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
40406
- const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
40407
- return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
40525
+ const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text2, half);
40526
+ const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text2, length - (columns - half) + 1, true);
40527
+ return sliceAnsi(text2, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text2, spaceNearSecondBreakPoint, length).trim();
40408
40528
  }
40409
- return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length);
40529
+ return sliceAnsi(text2, 0, half) + truncationCharacter + sliceAnsi(text2, length - (columns - half) + stringWidth(truncationCharacter), length);
40410
40530
  }
40411
40531
  if (position === "end") {
40412
40532
  if (preferTruncationOnSpace) {
40413
- const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
40414
- return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
40533
+ const nearestSpace = getIndexOfNearestSpace(text2, columns - 1);
40534
+ return sliceAnsi(text2, 0, nearestSpace) + truncationCharacter;
40415
40535
  }
40416
40536
  if (space === true) {
40417
40537
  truncationCharacter = ` ${truncationCharacter}`;
40418
40538
  }
40419
- return sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
40539
+ return sliceAnsi(text2, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
40420
40540
  }
40421
40541
  throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
40422
40542
  }
40423
40543
 
40424
40544
  // node_modules/ink/build/wrap-text.js
40425
40545
  var cache2 = {};
40426
- var wrapText = (text, maxWidth, wrapType) => {
40427
- const cacheKey = text + String(maxWidth) + String(wrapType);
40546
+ var wrapText = (text2, maxWidth, wrapType) => {
40547
+ const cacheKey = text2 + String(maxWidth) + String(wrapType);
40428
40548
  const cachedText = cache2[cacheKey];
40429
40549
  if (cachedText) {
40430
40550
  return cachedText;
40431
40551
  }
40432
- let wrappedText = text;
40552
+ let wrappedText = text2;
40433
40553
  if (wrapType === "wrap") {
40434
- wrappedText = wrapAnsi(text, maxWidth, {
40554
+ wrappedText = wrapAnsi(text2, maxWidth, {
40435
40555
  trim: false,
40436
40556
  hard: true
40437
40557
  });
@@ -40444,7 +40564,7 @@ var wrapText = (text, maxWidth, wrapType) => {
40444
40564
  if (wrapType === "truncate-start") {
40445
40565
  position = "start";
40446
40566
  }
40447
- wrappedText = cliTruncate(text, maxWidth, { position });
40567
+ wrappedText = cliTruncate(text2, maxWidth, { position });
40448
40568
  }
40449
40569
  cache2[cacheKey] = wrappedText;
40450
40570
  return wrappedText;
@@ -40453,7 +40573,7 @@ var wrap_text_default = wrapText;
40453
40573
 
40454
40574
  // node_modules/ink/build/squash-text-nodes.js
40455
40575
  var squashTextNodes = (node) => {
40456
- let text = "";
40576
+ let text2 = "";
40457
40577
  for (let index = 0;index < node.childNodes.length; index++) {
40458
40578
  const childNode = node.childNodes[index];
40459
40579
  if (childNode === undefined) {
@@ -40470,9 +40590,9 @@ var squashTextNodes = (node) => {
40470
40590
  nodeText = childNode.internal_transform(nodeText, index);
40471
40591
  }
40472
40592
  }
40473
- text += nodeText;
40593
+ text2 += nodeText;
40474
40594
  }
40475
- return text;
40595
+ return text2;
40476
40596
  };
40477
40597
  var squash_text_nodes_default = squashTextNodes;
40478
40598
 
@@ -40544,20 +40664,20 @@ var setAttribute = (node, key, value) => {
40544
40664
  var setStyle = (node, style) => {
40545
40665
  node.style = style;
40546
40666
  };
40547
- var createTextNode = (text) => {
40667
+ var createTextNode = (text2) => {
40548
40668
  const node = {
40549
40669
  nodeName: "#text",
40550
- nodeValue: text,
40670
+ nodeValue: text2,
40551
40671
  yogaNode: undefined,
40552
40672
  parentNode: undefined,
40553
40673
  style: {}
40554
40674
  };
40555
- setTextNodeValue(node, text);
40675
+ setTextNodeValue(node, text2);
40556
40676
  return node;
40557
40677
  };
40558
40678
  var measureTextNode = function(node, width) {
40559
- const text = node.nodeName === "#text" ? node.nodeValue : squash_text_nodes_default(node);
40560
- const dimensions = measure_text_default(text);
40679
+ const text2 = node.nodeName === "#text" ? node.nodeValue : squash_text_nodes_default(node);
40680
+ const dimensions = measure_text_default(text2);
40561
40681
  if (dimensions.width <= width) {
40562
40682
  return dimensions;
40563
40683
  }
@@ -40565,7 +40685,7 @@ var measureTextNode = function(node, width) {
40565
40685
  return dimensions;
40566
40686
  }
40567
40687
  const textWrap = node.style?.textWrap ?? "wrap";
40568
- const wrappedText = wrap_text_default(text, width, textWrap);
40688
+ const wrappedText = wrap_text_default(text2, width, textWrap);
40569
40689
  return measure_text_default(wrappedText);
40570
40690
  };
40571
40691
  var findClosestYogaNode = (node) => {
@@ -40578,11 +40698,11 @@ var markNodeAsDirty = (node) => {
40578
40698
  const yogaNode = findClosestYogaNode(node);
40579
40699
  yogaNode?.markDirty();
40580
40700
  };
40581
- var setTextNodeValue = (node, text) => {
40582
- if (typeof text !== "string") {
40583
- text = String(text);
40701
+ var setTextNodeValue = (node, text2) => {
40702
+ if (typeof text2 !== "string") {
40703
+ text2 = String(text2);
40584
40704
  }
40585
- node.nodeValue = text;
40705
+ node.nodeValue = text2;
40586
40706
  markNodeAsDirty(node);
40587
40707
  };
40588
40708
 
@@ -40808,7 +40928,7 @@ var styles2 = (node, style = {}) => {
40808
40928
  var styles_default = styles2;
40809
40929
 
40810
40930
  // node_modules/ink/build/reconciler.js
40811
- if (process3.env["DEV"] === "true") {
40931
+ if (process4.env["DEV"] === "true") {
40812
40932
  try {
40813
40933
  await Promise.resolve().then(() => (init_devtools(), exports_devtools));
40814
40934
  } catch (error) {
@@ -40917,18 +41037,18 @@ var reconciler_default = import_react_reconciler.default({
40917
41037
  }
40918
41038
  return node;
40919
41039
  },
40920
- createTextInstance(text, _root, hostContext) {
41040
+ createTextInstance(text2, _root, hostContext) {
40921
41041
  if (!hostContext.isInsideText) {
40922
- throw new Error(`Text string "${text}" must be rendered inside <Text> component`);
41042
+ throw new Error(`Text string "${text2}" must be rendered inside <Text> component`);
40923
41043
  }
40924
- return createTextNode(text);
41044
+ return createTextNode(text2);
40925
41045
  },
40926
41046
  resetTextContent() {},
40927
41047
  hideTextInstance(node) {
40928
41048
  setTextNodeValue(node, "");
40929
41049
  },
40930
- unhideTextInstance(node, text) {
40931
- setTextNodeValue(node, text);
41050
+ unhideTextInstance(node, text2) {
41051
+ setTextNodeValue(node, text2);
40932
41052
  },
40933
41053
  getPublicInstance: (instance) => instance,
40934
41054
  hideInstance(node) {
@@ -41221,16 +41341,16 @@ var ansiStyles2 = assembleStyles2();
41221
41341
  var ansi_styles_default2 = ansiStyles2;
41222
41342
 
41223
41343
  // node_modules/chalk/source/vendor/supports-color/index.js
41224
- import process4 from "node:process";
41344
+ import process5 from "node:process";
41225
41345
  import os3 from "node:os";
41226
41346
  import tty from "node:tty";
41227
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process4.argv) {
41347
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process5.argv) {
41228
41348
  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
41229
41349
  const position = argv.indexOf(prefix + flag);
41230
41350
  const terminatorPosition = argv.indexOf("--");
41231
41351
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
41232
41352
  }
41233
- var { env: env2 } = process4;
41353
+ var { env: env2 } = process5;
41234
41354
  var flagForceColor;
41235
41355
  if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
41236
41356
  flagForceColor = 0;
@@ -41286,7 +41406,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
41286
41406
  if (env2.TERM === "dumb") {
41287
41407
  return min2;
41288
41408
  }
41289
- if (process4.platform === "win32") {
41409
+ if (process5.platform === "win32") {
41290
41410
  const osRelease = os3.release().split(".");
41291
41411
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
41292
41412
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
@@ -41638,15 +41758,15 @@ var renderBorder = (x3, y3, node, output) => {
41638
41758
  var render_border_default = renderBorder;
41639
41759
 
41640
41760
  // node_modules/ink/build/render-node-to-output.js
41641
- var applyPaddingToText = (node, text) => {
41761
+ var applyPaddingToText = (node, text2) => {
41642
41762
  const yogaNode = node.childNodes[0]?.yogaNode;
41643
41763
  if (yogaNode) {
41644
41764
  const offsetX = yogaNode.getComputedLeft();
41645
41765
  const offsetY = yogaNode.getComputedTop();
41646
- text = `
41647
- `.repeat(offsetY) + indentString(text, offsetX);
41766
+ text2 = `
41767
+ `.repeat(offsetY) + indentString(text2, offsetX);
41648
41768
  }
41649
- return text;
41769
+ return text2;
41650
41770
  };
41651
41771
  var renderNodeToOutput = (node, output, options) => {
41652
41772
  const { offsetX = 0, offsetY = 0, transformers = [], skipStaticElements } = options;
@@ -41665,16 +41785,16 @@ var renderNodeToOutput = (node, output, options) => {
41665
41785
  newTransformers = [node.internal_transform, ...transformers];
41666
41786
  }
41667
41787
  if (node.nodeName === "ink-text") {
41668
- let text = squash_text_nodes_default(node);
41669
- if (text.length > 0) {
41670
- const currentWidth = widestLine(text);
41788
+ let text2 = squash_text_nodes_default(node);
41789
+ if (text2.length > 0) {
41790
+ const currentWidth = widestLine(text2);
41671
41791
  const maxWidth = get_max_width_default(yogaNode);
41672
41792
  if (currentWidth > maxWidth) {
41673
41793
  const textWrap = node.style.textWrap ?? "wrap";
41674
- text = wrap_text_default(text, maxWidth, textWrap);
41794
+ text2 = wrap_text_default(text2, maxWidth, textWrap);
41675
41795
  }
41676
- text = applyPaddingToText(node, text);
41677
- output.write(x3, y3, text, { transformers: newTransformers });
41796
+ text2 = applyPaddingToText(node, text2);
41797
+ output.write(x3, y3, text2, { transformers: newTransformers });
41678
41798
  }
41679
41799
  return;
41680
41800
  }
@@ -42026,16 +42146,16 @@ class Output {
42026
42146
  this.width = width;
42027
42147
  this.height = height;
42028
42148
  }
42029
- write(x3, y3, text, options) {
42149
+ write(x3, y3, text2, options) {
42030
42150
  const { transformers } = options;
42031
- if (!text) {
42151
+ if (!text2) {
42032
42152
  return;
42033
42153
  }
42034
42154
  this.operations.push({
42035
42155
  type: "write",
42036
42156
  x: x3,
42037
42157
  y: y3,
42038
- text,
42158
+ text: text2,
42039
42159
  transformers
42040
42160
  });
42041
42161
  }
@@ -42073,16 +42193,16 @@ class Output {
42073
42193
  clips.pop();
42074
42194
  }
42075
42195
  if (operation.type === "write") {
42076
- const { text, transformers } = operation;
42196
+ const { text: text2, transformers } = operation;
42077
42197
  let { x: x3, y: y3 } = operation;
42078
- let lines = text.split(`
42198
+ let lines = text2.split(`
42079
42199
  `);
42080
42200
  const clip = clips.at(-1);
42081
42201
  if (clip) {
42082
42202
  const clipHorizontally = typeof clip?.x1 === "number" && typeof clip?.x2 === "number";
42083
42203
  const clipVertically = typeof clip?.y1 === "number" && typeof clip?.y2 === "number";
42084
42204
  if (clipHorizontally) {
42085
- const width = widestLine(text);
42205
+ const width = widestLine(text2);
42086
42206
  if (x3 + width < clip.x1 || x3 > clip.x2) {
42087
42207
  continue;
42088
42208
  }
@@ -42189,15 +42309,15 @@ var renderer = (node) => {
42189
42309
  var renderer_default = renderer;
42190
42310
 
42191
42311
  // node_modules/cli-cursor/index.js
42192
- import process6 from "node:process";
42312
+ import process7 from "node:process";
42193
42313
 
42194
42314
  // node_modules/restore-cursor/index.js
42195
42315
  var import_onetime = __toESM(require_onetime(), 1);
42196
42316
  var import_signal_exit = __toESM(require_signal_exit(), 1);
42197
- import process5 from "node:process";
42317
+ import process6 from "node:process";
42198
42318
  var restoreCursor = import_onetime.default(() => {
42199
42319
  import_signal_exit.default(() => {
42200
- process5.stderr.write("\x1B[?25h");
42320
+ process6.stderr.write("\x1B[?25h");
42201
42321
  }, { alwaysLast: true });
42202
42322
  });
42203
42323
  var restore_cursor_default = restoreCursor;
@@ -42205,14 +42325,14 @@ var restore_cursor_default = restoreCursor;
42205
42325
  // node_modules/cli-cursor/index.js
42206
42326
  var isHidden = false;
42207
42327
  var cliCursor = {};
42208
- cliCursor.show = (writableStream = process6.stderr) => {
42328
+ cliCursor.show = (writableStream = process7.stderr) => {
42209
42329
  if (!writableStream.isTTY) {
42210
42330
  return;
42211
42331
  }
42212
42332
  isHidden = false;
42213
42333
  writableStream.write("\x1B[?25h");
42214
42334
  };
42215
- cliCursor.hide = (writableStream = process6.stderr) => {
42335
+ cliCursor.hide = (writableStream = process7.stderr) => {
42216
42336
  if (!writableStream.isTTY) {
42217
42337
  return;
42218
42338
  }
@@ -42277,7 +42397,7 @@ var instances_default = instances;
42277
42397
  // node_modules/ink/build/components/App.js
42278
42398
  var import_react9 = __toESM(require_react(), 1);
42279
42399
  import { EventEmitter as EventEmitter2 } from "node:events";
42280
- import process10 from "node:process";
42400
+ import process11 from "node:process";
42281
42401
 
42282
42402
  // node_modules/ink/build/components/AppContext.js
42283
42403
  var import_react = __toESM(require_react(), 1);
@@ -42290,9 +42410,9 @@ var AppContext_default = AppContext;
42290
42410
  // node_modules/ink/build/components/StdinContext.js
42291
42411
  var import_react2 = __toESM(require_react(), 1);
42292
42412
  import { EventEmitter } from "node:events";
42293
- import process7 from "node:process";
42413
+ import process8 from "node:process";
42294
42414
  var StdinContext = import_react2.createContext({
42295
- stdin: process7.stdin,
42415
+ stdin: process8.stdin,
42296
42416
  internal_eventEmitter: new EventEmitter,
42297
42417
  setRawMode() {},
42298
42418
  isRawModeSupported: false,
@@ -42303,9 +42423,9 @@ var StdinContext_default = StdinContext;
42303
42423
 
42304
42424
  // node_modules/ink/build/components/StdoutContext.js
42305
42425
  var import_react3 = __toESM(require_react(), 1);
42306
- import process8 from "node:process";
42426
+ import process9 from "node:process";
42307
42427
  var StdoutContext = import_react3.createContext({
42308
- stdout: process8.stdout,
42428
+ stdout: process9.stdout,
42309
42429
  write() {}
42310
42430
  });
42311
42431
  StdoutContext.displayName = "InternalStdoutContext";
@@ -42313,9 +42433,9 @@ var StdoutContext_default = StdoutContext;
42313
42433
 
42314
42434
  // node_modules/ink/build/components/StderrContext.js
42315
42435
  var import_react4 = __toESM(require_react(), 1);
42316
- import process9 from "node:process";
42436
+ import process10 from "node:process";
42317
42437
  var StderrContext = import_react4.createContext({
42318
- stderr: process9.stderr,
42438
+ stderr: process10.stderr,
42319
42439
  write() {}
42320
42440
  });
42321
42441
  StderrContext.displayName = "InternalStderrContext";
@@ -42538,7 +42658,7 @@ class App extends import_react9.PureComponent {
42538
42658
  handleSetRawMode = (isEnabled) => {
42539
42659
  const { stdin } = this.props;
42540
42660
  if (!this.isRawModeSupported()) {
42541
- if (stdin === process10.stdin) {
42661
+ if (stdin === process11.stdin) {
42542
42662
  throw new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
42543
42663
  Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);
42544
42664
  } else {
@@ -42744,7 +42864,7 @@ class Ink {
42744
42864
  this.fullStaticOutput = "";
42745
42865
  this.container = reconciler_default.createContainer(this.rootNode, 0, null, false, null, "id", () => {}, null);
42746
42866
  this.unsubscribeExit = import_signal_exit2.default(this.unmount, { alwaysLast: false });
42747
- if (process11.env["DEV"] === "true") {
42867
+ if (process12.env["DEV"] === "true") {
42748
42868
  reconciler_default.injectIntoDevTools({
42749
42869
  bundleType: 0,
42750
42870
  version: "16.13.1",
@@ -42910,9 +43030,9 @@ class Ink {
42910
43030
  // node_modules/ink/build/render.js
42911
43031
  var render = (node, options) => {
42912
43032
  const inkOptions = {
42913
- stdout: process12.stdout,
42914
- stdin: process12.stdin,
42915
- stderr: process12.stderr,
43033
+ stdout: process13.stdout,
43034
+ stdin: process13.stdin,
43035
+ stderr: process13.stderr,
42916
43036
  debug: false,
42917
43037
  exitOnCtrlC: true,
42918
43038
  patchConsole: true,
@@ -42935,7 +43055,7 @@ var getOptions = (stdout = {}) => {
42935
43055
  if (stdout instanceof Stream) {
42936
43056
  return {
42937
43057
  stdout,
42938
- stdin: process12.stdin
43058
+ stdin: process13.stdin
42939
43059
  };
42940
43060
  }
42941
43061
  return stdout;
@@ -43224,6 +43344,7 @@ function formatItemLabel(item) {
43224
43344
  return `${fmtType(item.type)} ${import_picocolors7.default.bold(item.slug)} ${fmtScope(item.scope)}${desc}${size2}`;
43225
43345
  }
43226
43346
  async function runPack(cwd2) {
43347
+ requireInteractive("`brainbase template pack` is interactive — it asks which components, name, version and description to include. Run it in a real terminal.");
43227
43348
  banner("pack — bundle your agent into a template");
43228
43349
  const detections = await detectHarnesses(cwd2);
43229
43350
  const detected = detections.filter((d3) => d3.detection.detected);
@@ -43610,10 +43731,10 @@ async function request(pathname, init = {}) {
43610
43731
  } catch (err) {
43611
43732
  throw new ApiError(`Network error: ${err.message}`);
43612
43733
  }
43613
- const text = await res.text();
43614
- let body = text;
43734
+ const text2 = await res.text();
43735
+ let body = text2;
43615
43736
  try {
43616
- body = text ? JSON.parse(text) : null;
43737
+ body = text2 ? JSON.parse(text2) : null;
43617
43738
  } catch {}
43618
43739
  if (!res.ok) {
43619
43740
  const msg = (body && typeof body === "object" && "error" in body ? String(body.error) : null) ?? (body && typeof body === "object" && "message" in body ? String(body.message) : null) ?? `HTTP ${res.status}`;
@@ -43833,10 +43954,10 @@ async function jsonRequest(pathname, init = {}) {
43833
43954
  } catch (err) {
43834
43955
  throw new ApiError(`Network error: ${err.message}`);
43835
43956
  }
43836
- const text = await res.text();
43837
- let body = text;
43957
+ const text2 = await res.text();
43958
+ let body = text2;
43838
43959
  try {
43839
- body = text ? JSON.parse(text) : null;
43960
+ body = text2 ? JSON.parse(text2) : null;
43840
43961
  } catch {}
43841
43962
  if (!res.ok) {
43842
43963
  let code = null;
@@ -43947,10 +44068,10 @@ var registryApi = {
43947
44068
  } catch (err) {
43948
44069
  throw new ApiError(`Network error: ${err.message}`);
43949
44070
  }
43950
- const text = await res.text();
43951
- let body = text;
44071
+ const text2 = await res.text();
44072
+ let body = text2;
43952
44073
  try {
43953
- body = text ? JSON.parse(text) : null;
44074
+ body = text2 ? JSON.parse(text2) : null;
43954
44075
  } catch {}
43955
44076
  if (!res.ok) {
43956
44077
  throw new ApiError(`Publish failed: HTTP ${res.status}`, res.status, body);
@@ -47215,24 +47336,24 @@ var INJECTION_PHRASES = [
47215
47336
  /<\|im_start\|>/i,
47216
47337
  /\bact as (?:a |the )?(?:different|new) (?:assistant|model|system)/i
47217
47338
  ];
47218
- function stripFences(text) {
47219
- return text.replace(/```[\s\S]*?```/g, "").replace(/~~~[\s\S]*?~~~/g, "");
47339
+ function stripFences(text2) {
47340
+ return text2.replace(/```[\s\S]*?```/g, "").replace(/~~~[\s\S]*?~~~/g, "");
47220
47341
  }
47221
- function lineOf(text, index) {
47342
+ function lineOf(text2, index) {
47222
47343
  let line = 1;
47223
- for (let i = 0;i < index && i < text.length; i++) {
47224
- if (text.charCodeAt(i) === 10)
47344
+ for (let i = 0;i < index && i < text2.length; i++) {
47345
+ if (text2.charCodeAt(i) === 10)
47225
47346
  line++;
47226
47347
  }
47227
47348
  return line;
47228
47349
  }
47229
- function scanText(text, opts = {
47350
+ function scanText(text2, opts = {
47230
47351
  kind: "other"
47231
47352
  }) {
47232
47353
  const findings = [];
47233
47354
  const file = opts.relPath;
47234
47355
  const sizeCap = opts.kind === "markdown" ? MAX_MARKDOWN_BYTES : opts.kind === "readme" ? MAX_README_BYTES : Infinity;
47235
- const bytes = Buffer.byteLength(text, "utf8");
47356
+ const bytes = Buffer.byteLength(text2, "utf8");
47236
47357
  if (bytes > sizeCap) {
47237
47358
  findings.push({
47238
47359
  severity: "block",
@@ -47241,8 +47362,8 @@ function scanText(text, opts = {
47241
47362
  file
47242
47363
  });
47243
47364
  }
47244
- for (let i = 0;i < text.length; i++) {
47245
- const cp = text.codePointAt(i);
47365
+ for (let i = 0;i < text2.length; i++) {
47366
+ const cp = text2.codePointAt(i);
47246
47367
  if (cp === undefined)
47247
47368
  continue;
47248
47369
  if (isInvisibleCodepoint(cp)) {
@@ -47251,7 +47372,7 @@ function scanText(text, opts = {
47251
47372
  code: "invisible.codepoint",
47252
47373
  message: `invisible/bidi codepoint U+${cp.toString(16).toUpperCase().padStart(4, "0")} at offset ${i}`,
47253
47374
  file,
47254
- line: lineOf(text, i),
47375
+ line: lineOf(text2, i),
47255
47376
  detail: "Strip zero-width or bidi-control characters before publishing. They are usually a prompt-injection attempt."
47256
47377
  });
47257
47378
  break;
@@ -47262,7 +47383,7 @@ function scanText(text, opts = {
47262
47383
  if (opts.kind !== "markdown" && opts.kind !== "readme") {
47263
47384
  return findings;
47264
47385
  }
47265
- const stripped = stripFences(text);
47386
+ const stripped = stripFences(text2);
47266
47387
  HTML_COMMENT_RE.lastIndex = 0;
47267
47388
  let m3;
47268
47389
  while (m3 = HTML_COMMENT_RE.exec(stripped)) {
@@ -47272,7 +47393,7 @@ function scanText(text, opts = {
47272
47393
  code: "html.comment",
47273
47394
  message: `HTML comment in markdown (${m3[0].length} chars) — readers may not see this content but the model will`,
47274
47395
  file,
47275
- line: lineOf(text, text.indexOf(m3[0]))
47396
+ line: lineOf(text2, text2.indexOf(m3[0]))
47276
47397
  });
47277
47398
  break;
47278
47399
  }
@@ -47284,7 +47405,7 @@ function scanText(text, opts = {
47284
47405
  code: "base64.long",
47285
47406
  message: `long base64-like blob in instructions (${b64[0].length} chars)`,
47286
47407
  file,
47287
- line: lineOf(text, text.indexOf(b64[0])),
47408
+ line: lineOf(text2, text2.indexOf(b64[0])),
47288
47409
  detail: "If this is real content, fence it as a code block so it stops being treated as instruction text."
47289
47410
  });
47290
47411
  }
@@ -47297,7 +47418,7 @@ function scanText(text, opts = {
47297
47418
  code: "injection.phrase",
47298
47419
  message: `instruction-override phrase: "${hit[0].slice(0, 80)}"`,
47299
47420
  file,
47300
- line: lineOf(text, text.indexOf(hit[0])),
47421
+ line: lineOf(text2, text2.indexOf(hit[0])),
47301
47422
  detail: "This phrase is commonly used in prompt-injection attacks. If it is intentional, ignore this warning."
47302
47423
  });
47303
47424
  break;
@@ -47367,9 +47488,9 @@ function scanBundleDir(input) {
47367
47488
  const isText = isMarkdown || lower.endsWith(".txt") || lower.endsWith(".json") || lower.endsWith(".toml") || lower.endsWith(".yaml") || lower.endsWith(".yml");
47368
47489
  if (!isText)
47369
47490
  continue;
47370
- let text;
47491
+ let text2;
47371
47492
  try {
47372
- text = fs24.readFileSync(full, "utf8");
47493
+ text2 = fs24.readFileSync(full, "utf8");
47373
47494
  } catch {
47374
47495
  findings.push({
47375
47496
  severity: "warn",
@@ -47380,7 +47501,7 @@ function scanBundleDir(input) {
47380
47501
  continue;
47381
47502
  }
47382
47503
  const kind = isReadme ? "readme" : isMarkdown ? "markdown" : "other";
47383
- const fileFindings = scanText(text, {
47504
+ const fileFindings = scanText(text2, {
47384
47505
  kind,
47385
47506
  relPath: path28.relative(input.rootDir, full)
47386
47507
  });
@@ -47562,11 +47683,11 @@ function readFileSafe(p2, byteCap = MAX_INSTRUCTION_BYTES) {
47562
47683
  return null;
47563
47684
  }
47564
47685
  }
47565
- function truncateLines(text, max2) {
47566
- const lines = text.split(`
47686
+ function truncateLines(text2, max2) {
47687
+ const lines = text2.split(`
47567
47688
  `);
47568
47689
  if (lines.length <= max2)
47569
- return text;
47690
+ return text2;
47570
47691
  const dropped = lines.length - max2;
47571
47692
  return lines.slice(0, max2).join(`
47572
47693
  `) + `
@@ -47613,13 +47734,13 @@ function buildInstallPreview(input) {
47613
47734
  const p2 = path30.join(input.templateRoot, fname);
47614
47735
  if (!fs26.existsSync(p2))
47615
47736
  continue;
47616
- const text = readFileSafe(p2);
47617
- if (!text || text.trim().length === 0)
47737
+ const text2 = readFileSafe(p2);
47738
+ if (!text2 || text2.trim().length === 0)
47618
47739
  break;
47619
47740
  blocks.push({
47620
47741
  severity: "info",
47621
47742
  title: `${fname} — merged into harness instructions`,
47622
- lines: [truncateLines(text, MAX_INSTRUCTION_LINES)]
47743
+ lines: [truncateLines(text2, MAX_INSTRUCTION_LINES)]
47623
47744
  });
47624
47745
  break;
47625
47746
  }
@@ -47629,13 +47750,13 @@ function buildInstallPreview(input) {
47629
47750
  const file = pickInstructionFile(c2.rootDir);
47630
47751
  if (!file)
47631
47752
  continue;
47632
- const text = readFileSafe(file);
47633
- if (!text || text.trim().length === 0)
47753
+ const text2 = readFileSafe(file);
47754
+ if (!text2 || text2.trim().length === 0)
47634
47755
  continue;
47635
47756
  blocks.push({
47636
47757
  severity: "info",
47637
47758
  title: `instruction ${import_picocolors8.default.bold(c2.slug)} — merged into harness instructions`,
47638
- lines: [truncateLines(text, MAX_INSTRUCTION_LINES)]
47759
+ lines: [truncateLines(text2, MAX_INSTRUCTION_LINES)]
47639
47760
  });
47640
47761
  }
47641
47762
  for (const c2 of input.components) {
@@ -47999,7 +48120,7 @@ function buildTemplateComponents(manifest, rootDir) {
47999
48120
  rootDir: path31.join(rootDir, c2.path),
48000
48121
  description: c2.description,
48001
48122
  target: c2.target,
48002
- payload: c2.meta?.mcp,
48123
+ payload: proxifyMcpPayload(c2.meta?.mcp),
48003
48124
  meta: c2.meta,
48004
48125
  checksum: c2.checksum,
48005
48126
  source: c2.source
@@ -48007,6 +48128,8 @@ function buildTemplateComponents(manifest, rootDir) {
48007
48128
  }
48008
48129
  async function runOnboard(cwd2, args) {
48009
48130
  banner(`onboard — install ${import_picocolors9.default.bold(args.ref)}`);
48131
+ const interactive = isInteractive();
48132
+ const autoYes = args.yes || !interactive;
48010
48133
  const { name, version } = parseTemplateRef(args.ref);
48011
48134
  const registry = new LocalRegistry;
48012
48135
  let templateRef;
@@ -48025,7 +48148,7 @@ async function runOnboard(cwd2, args) {
48025
48148
  const cmp = compareSemver(templateRef.version, prior.version);
48026
48149
  if (cmp === 0) {
48027
48150
  f2.info(`Already installed at ${import_picocolors9.default.bold("@" + prior.version)} (latest version).`);
48028
- if (!args.yes) {
48151
+ if (!autoYes) {
48029
48152
  const again = await se({
48030
48153
  message: "Re-onboard anyway?",
48031
48154
  initialValue: false
@@ -48037,7 +48160,7 @@ async function runOnboard(cwd2, args) {
48037
48160
  }
48038
48161
  } else if (cmp > 0) {
48039
48162
  f2.info(`You have ${import_picocolors9.default.bold("@" + prior.version)}, latest is ${import_picocolors9.default.bold("@" + templateRef.version)}.`);
48040
- if (!args.yes) {
48163
+ if (!autoYes) {
48041
48164
  const upgrade = await se({
48042
48165
  message: "Re-onboard to update?",
48043
48166
  initialValue: true
@@ -48049,7 +48172,7 @@ async function runOnboard(cwd2, args) {
48049
48172
  }
48050
48173
  } else {
48051
48174
  f2.warn(`You have ${import_picocolors9.default.bold("@" + prior.version)}, which is newer than ${import_picocolors9.default.bold("@" + templateRef.version)}.`);
48052
- if (!args.yes) {
48175
+ if (!autoYes) {
48053
48176
  const downgrade = await se({
48054
48177
  message: "Re-onboard with the older version?",
48055
48178
  initialValue: false
@@ -48065,16 +48188,16 @@ async function runOnboard(cwd2, args) {
48065
48188
  const detected = detections.filter((d3) => d3.detection.detected);
48066
48189
  let adapterId = args.harness ?? detected[0]?.adapter.id ?? templateRef.manifest.sourceHarness;
48067
48190
  if (!args.harness && detected.length !== 1) {
48068
- const choice = await ie({
48191
+ adapterId = await select({
48069
48192
  message: "Install into which harness?",
48070
48193
  options: detections.map((d3) => ({
48071
48194
  value: d3.adapter.id,
48072
48195
  label: d3.adapter.displayName,
48073
48196
  hint: d3.detection.detected ? "detected" : "will scaffold"
48074
48197
  })),
48075
- initialValue: adapterId
48198
+ initialValue: adapterId,
48199
+ flagHint: "Pass --harness <id>."
48076
48200
  });
48077
- adapterId = ensureNotCancelled(choice);
48078
48201
  }
48079
48202
  const adapter = getAdapter(adapterId);
48080
48203
  const caps = adapter.capabilities;
@@ -48093,15 +48216,19 @@ async function runOnboard(cwd2, args) {
48093
48216
  }
48094
48217
  let scope = args.scope;
48095
48218
  if (!scope) {
48096
- const choice = await ie({
48097
- message: "Where do you want to install?",
48098
- options: [
48099
- { value: "project", label: `Project (${path31.basename(cwd2)}/.claude)` },
48100
- { value: "global", label: "Global (~/.claude)" }
48101
- ],
48102
- initialValue: "project"
48103
- });
48104
- scope = ensureNotCancelled(choice);
48219
+ if (!interactive) {
48220
+ scope = "project";
48221
+ } else {
48222
+ scope = await select({
48223
+ message: "Where do you want to install?",
48224
+ options: [
48225
+ { value: "project", label: `Project (${path31.basename(cwd2)}/.claude)` },
48226
+ { value: "global", label: "Global (~/.claude)" }
48227
+ ],
48228
+ initialValue: "project",
48229
+ flagHint: "Pass --scope project|global."
48230
+ });
48231
+ }
48105
48232
  }
48106
48233
  const allComponents = buildTemplateComponents(templateRef.manifest, templateRef.rootDir);
48107
48234
  const components = allComponents.map((c2) => ({ ...c2, scope }));
@@ -48130,7 +48257,7 @@ async function runOnboard(cwd2, args) {
48130
48257
  `)).filter((l2) => l2.length > 0)
48131
48258
  }))
48132
48259
  });
48133
- if (!args.yes) {
48260
+ if (!autoYes) {
48134
48261
  const danger = previewHasDanger(previewBlocks);
48135
48262
  const confirmed = await se({
48136
48263
  message: danger ? import_picocolors9.default.red("Dangerous components detected. Proceed?") : "Proceed?",
@@ -48144,8 +48271,8 @@ async function runOnboard(cwd2, args) {
48144
48271
  const opts = {
48145
48272
  cwd: cwd2,
48146
48273
  scope,
48147
- resolveConflict: makeConflictResolver(args.yes),
48148
- resolveSecret: makeSecretResolver(templateRef.manifest, args.yes)
48274
+ resolveConflict: makeConflictResolver(args.yes, interactive),
48275
+ resolveSecret: makeSecretResolver(templateRef.manifest, args.yes, interactive)
48149
48276
  };
48150
48277
  const installSpinner = de();
48151
48278
  installSpinner.start("Installing…");
@@ -48196,10 +48323,15 @@ async function runOnboard(cwd2, args) {
48196
48323
  hint: "brainbase template list"
48197
48324
  });
48198
48325
  }
48199
- function makeConflictResolver(autoYes) {
48200
- if (autoYes) {
48326
+ function makeConflictResolver(yes, interactive = true) {
48327
+ if (yes) {
48201
48328
  return async () => "overwrite";
48202
48329
  }
48330
+ if (!interactive) {
48331
+ return async (item) => {
48332
+ throw new NonInteractiveError(`Conflict for ${item.type} "${item.slug}": a local copy differs from the template. Re-run with --yes to overwrite, or run interactively to choose.`);
48333
+ };
48334
+ }
48203
48335
  return async (item) => {
48204
48336
  const choice = await ie({
48205
48337
  message: `Conflict for ${item.type} "${item.slug}". What do you want to do?`,
@@ -48259,13 +48391,16 @@ async function resolveWithRemoteFallback(registry, name, version) {
48259
48391
  throw err;
48260
48392
  }
48261
48393
  }
48262
- function makeSecretResolver(manifest, autoYes) {
48394
+ function makeSecretResolver(manifest, yes, interactive = true) {
48263
48395
  return async (name, description) => {
48264
48396
  const fromEnv = process.env[name];
48265
48397
  if (fromEnv)
48266
48398
  return fromEnv;
48267
- if (autoYes)
48399
+ if (yes)
48268
48400
  return null;
48401
+ if (!interactive) {
48402
+ throw new NonInteractiveError(`Secret "${name}" is needed — set the ${name} environment variable, re-run with --yes to skip it, or run interactively.`);
48403
+ }
48269
48404
  const declared = manifest.secrets?.find((s3) => s3.name === name);
48270
48405
  const ans = await re({
48271
48406
  message: `Secret needed: ${import_picocolors9.default.bold(name)}${declared?.description ? ` ${import_picocolors9.default.dim("— " + declared.description)}` : description ? ` ${import_picocolors9.default.dim("— " + description)}` : ""}`
@@ -48462,7 +48597,7 @@ async function runRemove(cwd2, args) {
48462
48597
  text: c2.slug
48463
48598
  }))
48464
48599
  });
48465
- if (!args.yes) {
48600
+ if (!autoProceed(args.yes)) {
48466
48601
  const ans = await se({ message: "Proceed?", initialValue: true });
48467
48602
  if (!ensureNotCancelled(ans))
48468
48603
  continue;
@@ -48586,10 +48721,10 @@ var skillsApi = {
48586
48721
  } catch (err) {
48587
48722
  throw new ApiError(`Network error: ${err.message}`);
48588
48723
  }
48589
- const text = await res.text();
48590
- let body = text;
48724
+ const text2 = await res.text();
48725
+ let body = text2;
48591
48726
  try {
48592
- body = text ? JSON.parse(text) : null;
48727
+ body = text2 ? JSON.parse(text2) : null;
48593
48728
  } catch {}
48594
48729
  if (!res.ok) {
48595
48730
  throw new ApiError(`Skill publish failed: HTTP ${res.status}`, res.status, body);
@@ -48894,23 +49029,20 @@ function parseRef(input) {
48894
49029
  }
48895
49030
  async function publishSkillForTemplate(opts) {
48896
49031
  const { entry, bundleRoot, ownerForFallback } = opts;
48897
- const nameAns = await te({
49032
+ const nameAns = await text({
48898
49033
  message: `Publish ${import_picocolors11.default.bold(entry.slug)} as (creator/slug)`,
48899
49034
  placeholder: `gokhan/${entry.slug}`,
48900
- initialValue: `gokhan/${entry.slug}`,
48901
- validate: (v3) => /^[a-z0-9_-]+\/[a-z0-9_-]+$/i.test(v3 ?? "") ? undefined : "Use creator/slug"
49035
+ defaultValue: `gokhan/${entry.slug}`,
49036
+ validate: (v3) => /^[a-z0-9_-]+\/[a-z0-9_-]+$/i.test(v3 ?? "") ? undefined : "Use creator/slug",
49037
+ flagHint: "Run `brainbase skill publish <creator/slug>` interactively, or keep skills inline."
48902
49038
  });
48903
- if (lD(nameAns))
48904
- return false;
48905
49039
  const [creator, pkgSlug] = nameAns.toLowerCase().split("/");
48906
- const verAns = await te({
49040
+ const version = await text({
48907
49041
  message: `Skill version`,
48908
- initialValue: "0.1.0",
48909
- validate: (v3) => /^\d+\.\d+\.\d+$/.test(v3 ?? "") ? undefined : "MAJOR.MINOR.PATCH"
49042
+ defaultValue: "0.1.0",
49043
+ validate: (v3) => /^\d+\.\d+\.\d+$/.test(v3 ?? "") ? undefined : "MAJOR.MINOR.PATCH",
49044
+ flagHint: "Run `brainbase skill publish` interactively to set a version."
48910
49045
  });
48911
- if (lD(verAns))
48912
- return false;
48913
- const version = verAns;
48914
49046
  let probe;
48915
49047
  try {
48916
49048
  probe = await skillsApi.canPublish(creator, pkgSlug);
@@ -49010,14 +49142,14 @@ async function runTemplatePublish(_cwd, args) {
49010
49142
  if (!cur || cur < ref2.version)
49011
49143
  byName.set(ref2.name, ref2.version);
49012
49144
  }
49013
- const choice = await ie({
49145
+ const picked = await select({
49014
49146
  message: "Which template do you want to publish?",
49015
49147
  options: [...byName.entries()].map(([n, v3]) => ({
49016
49148
  value: `${n}@${v3}`,
49017
49149
  label: `${import_picocolors11.default.bold(n)} ${import_picocolors11.default.dim("@" + v3)}`
49018
- }))
49150
+ })),
49151
+ flagHint: "Pass <creator/slug>[@version]."
49019
49152
  });
49020
- const picked = ensureNotCancelled(choice);
49021
49153
  const parsed = parseRef(picked);
49022
49154
  name = parsed.name;
49023
49155
  version = parsed.version;
@@ -49041,7 +49173,7 @@ async function runTemplatePublish(_cwd, args) {
49041
49173
  f2.error("Blocking issues found. Fix them and re-pack before publishing.");
49042
49174
  return;
49043
49175
  }
49044
- if (report.findings.some((f4) => f4.severity === "warn") && !args.yes) {
49176
+ if (report.findings.some((f4) => f4.severity === "warn") && !autoProceed(args.yes)) {
49045
49177
  const proceed = await se({
49046
49178
  message: "Warnings present. Publish anyway?",
49047
49179
  initialValue: false
@@ -49075,24 +49207,25 @@ async function runTemplatePublish(_cwd, args) {
49075
49207
  label: `Team — ${o2.name}`
49076
49208
  }))
49077
49209
  ];
49078
- const ownerChoice = await ie({
49210
+ const ownerChoice = await select({
49079
49211
  message: "Publish under which identity?",
49080
49212
  options: ownerOptions.map((o2, i) => ({ value: String(i), label: o2.label })),
49081
- initialValue: "0"
49213
+ initialValue: "0",
49214
+ flagHint: "Publishing picks an owner — run interactively to choose a team."
49082
49215
  });
49083
- const owner = ownerOptions[Number(ensureNotCancelled(ownerChoice))];
49216
+ const owner = ownerOptions[Number(ownerChoice)];
49084
49217
  let visibility = args.visibility;
49085
49218
  if (!visibility) {
49086
- const vc = await ie({
49219
+ visibility = await select({
49087
49220
  message: "Visibility",
49088
49221
  options: [
49089
49222
  { value: "private", label: "Private — only you / your team can install" },
49090
49223
  { value: "unlisted", label: "Unlisted — anyone with the link can install" },
49091
49224
  { value: "public", label: "Public — listed and searchable (will quarantine for review)" }
49092
49225
  ],
49093
- initialValue: "private"
49226
+ initialValue: "private",
49227
+ flagHint: "Pass --visibility public|unlisted|private."
49094
49228
  });
49095
- visibility = ensureNotCancelled(vc);
49096
49229
  }
49097
49230
  const skillEntries = ref.manifest.components.filter((c2) => c2.type === "skill");
49098
49231
  let manifestMutated = false;
@@ -49102,7 +49235,7 @@ async function runTemplatePublish(_cwd, args) {
49102
49235
  f2.info(`${import_picocolors11.default.dim("skill")} ${import_picocolors11.default.bold(entry.slug)} → ${describeSource(src)} ${import_picocolors11.default.dim("(reference)")}`);
49103
49236
  continue;
49104
49237
  }
49105
- if (args.yes)
49238
+ if (autoProceed(args.yes))
49106
49239
  continue;
49107
49240
  const mode = await ie({
49108
49241
  message: `${import_picocolors11.default.bold(entry.slug)} is locally authored. How should the template reference it?`,
@@ -49153,7 +49286,7 @@ async function runTemplatePublish(_cwd, args) {
49153
49286
  target: registryHost2(),
49154
49287
  scanWarnings: report.findings.filter((f4) => f4.severity === "warn").length
49155
49288
  });
49156
- if (!args.yes) {
49289
+ if (!autoProceed(args.yes)) {
49157
49290
  const ok = await se({ message: "Proceed?", initialValue: true });
49158
49291
  if (!ensureNotCancelled(ok)) {
49159
49292
  $e("Aborted.");
@@ -49683,13 +49816,13 @@ function declaredSkillName(dir) {
49683
49816
  const md = skillMdPath(dir);
49684
49817
  if (!md)
49685
49818
  return null;
49686
- let text;
49819
+ let text2;
49687
49820
  try {
49688
- text = fs32.readFileSync(md, "utf8");
49821
+ text2 = fs32.readFileSync(md, "utf8");
49689
49822
  } catch {
49690
49823
  return null;
49691
49824
  }
49692
- const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
49825
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text2);
49693
49826
  if (!fm)
49694
49827
  return null;
49695
49828
  const m3 = /^name:[ \t]*(.+?)[ \t]*$/m.exec(fm[1]);
@@ -49869,34 +50002,32 @@ async function runSkillAdd(cwd2, args) {
49869
50002
  if (detected.length === 1) {
49870
50003
  adapterId = detected[0].adapter.id;
49871
50004
  } else {
49872
- const choice = await ie({
50005
+ adapterId = await select({
49873
50006
  message: "Install into which harness?",
49874
50007
  options: detections.map((d3) => ({
49875
50008
  value: d3.adapter.id,
49876
50009
  label: d3.adapter.displayName,
49877
50010
  hint: d3.detection.detected ? "detected" : "will scaffold"
49878
- }))
50011
+ })),
50012
+ flagHint: "Pass --harness <id> to choose non-interactively."
49879
50013
  });
49880
- adapterId = ensureNotCancelled(choice);
49881
50014
  }
49882
50015
  }
49883
50016
  getAdapter(adapterId);
49884
- let scope = args.scope;
49885
- if (!scope) {
49886
- const choice = await ie({
49887
- message: "Where do you want to install?",
49888
- options: [
49889
- { value: "project", label: `Project (${path37.basename(cwd2)})` },
49890
- { value: "global", label: "Global (~)" }
49891
- ],
49892
- initialValue: "project"
49893
- });
49894
- scope = ensureNotCancelled(choice);
49895
- }
50017
+ const scope = args.scope ?? await select({
50018
+ message: "Where do you want to install?",
50019
+ options: [
50020
+ { value: "project", label: `Project (${path37.basename(cwd2)})` },
50021
+ { value: "global", label: "Global (~)" }
50022
+ ],
50023
+ initialValue: "project",
50024
+ fallback: "project",
50025
+ flagHint: "Pass --scope project|global."
50026
+ });
49896
50027
  const skillsRoot = skillsRootFor(adapterId, cwd2, scope);
49897
50028
  const dest = path37.join(skillsRoot, slug);
49898
50029
  if (exists(dest)) {
49899
- if (!args.yes) {
50030
+ if (!autoProceed(args.yes)) {
49900
50031
  const confirm = await se({
49901
50032
  message: `${import_picocolors13.default.bold(slug)} already exists at ${dest}. Overwrite?`,
49902
50033
  initialValue: false
@@ -50001,16 +50132,17 @@ async function runSkillRemove(cwd2, args) {
50001
50132
  }
50002
50133
  let target = candidates[0];
50003
50134
  if (candidates.length > 1) {
50004
- const choice = await ie({
50135
+ const choice = await select({
50005
50136
  message: "Which one?",
50006
50137
  options: candidates.map((c2, i) => ({
50007
50138
  value: String(i),
50008
50139
  label: `${c2.harness}/${c2.scope} — ${c2.dir}`
50009
- }))
50140
+ })),
50141
+ flagHint: "Pass --harness <id> and/or --scope <s> to disambiguate."
50010
50142
  });
50011
- target = candidates[Number(ensureNotCancelled(choice))];
50143
+ target = candidates[Number(choice)];
50012
50144
  }
50013
- if (!args.yes) {
50145
+ if (!autoProceed(args.yes)) {
50014
50146
  const ok = await se({
50015
50147
  message: `Delete ${import_picocolors15.default.bold(target.dir)}?`,
50016
50148
  initialValue: false
@@ -50065,13 +50197,14 @@ async function runSkillPublish(cwd2, args) {
50065
50197
  f2.error("Non-interactive publish (--yes) requires --name <creator/slug>.");
50066
50198
  return;
50067
50199
  }
50068
- const ans = await te({
50200
+ const ans = await text({
50069
50201
  message: "Publish as (creator/slug)",
50070
50202
  placeholder: `gokhan/${folderSlug}`,
50071
- initialValue: `gokhan/${folderSlug}`,
50072
- validate: (v3) => parseName(v3 ?? "") ? undefined : "Use creator/slug"
50203
+ defaultValue: `gokhan/${folderSlug}`,
50204
+ validate: (v3) => parseName(v3 ?? "") ? undefined : "Use creator/slug",
50205
+ flagHint: "Pass --name creator/slug."
50073
50206
  });
50074
- name = ensureNotCancelled(ans).toLowerCase();
50207
+ name = ans.toLowerCase();
50075
50208
  }
50076
50209
  const { creator, slug: pkgSlug } = parseName(name);
50077
50210
  let version = args.version;
@@ -50084,12 +50217,13 @@ async function runSkillPublish(cwd2, args) {
50084
50217
  f2.error("Non-interactive publish (--yes) requires --skill-version <MAJOR.MINOR.PATCH>.");
50085
50218
  return;
50086
50219
  }
50087
- const ans = await te({
50220
+ const ans = await text({
50088
50221
  message: "Version",
50089
- initialValue: "0.1.0",
50090
- validate: (v3) => /^\d+\.\d+\.\d+$/.test(v3 ?? "") ? undefined : "Must be MAJOR.MINOR.PATCH"
50222
+ defaultValue: "0.1.0",
50223
+ validate: (v3) => /^\d+\.\d+\.\d+$/.test(v3 ?? "") ? undefined : "Must be MAJOR.MINOR.PATCH",
50224
+ flagHint: "Pass --skill-version <x.y.z>."
50091
50225
  });
50092
- version = ensureNotCancelled(ans);
50226
+ version = ans;
50093
50227
  }
50094
50228
  let probe;
50095
50229
  try {
@@ -50122,7 +50256,7 @@ async function runSkillPublish(cwd2, args) {
50122
50256
  return;
50123
50257
  let visibility = args.visibility;
50124
50258
  if (!visibility) {
50125
- if (args.yes) {
50259
+ if (args.yes || !isInteractive()) {
50126
50260
  visibility = "private";
50127
50261
  } else {
50128
50262
  const v3 = await ie({
@@ -50171,7 +50305,7 @@ async function runSkillPublish(cwd2, args) {
50171
50305
  const sha = await sha256OfFile(tar);
50172
50306
  const size2 = fs37.statSync(tar).size;
50173
50307
  buildSp.stop(`Bundle ready (${(size2 / 1024).toFixed(1)} KB).`);
50174
- if (!args.yes) {
50308
+ if (!autoProceed(args.yes)) {
50175
50309
  const ok = await se({
50176
50310
  message: `Publish ${import_picocolors16.default.bold(skillDir)} as ${import_picocolors16.default.bold(creator + "/" + pkgSlug)}@${version}?`,
50177
50311
  initialValue: true
@@ -50260,13 +50394,12 @@ async function pickOwner(userId, email) {
50260
50394
  label: `Team — ${o2.name}`
50261
50395
  }))
50262
50396
  ];
50263
- const choice = await ie({
50397
+ const choice = await select({
50264
50398
  message: "Owner",
50265
50399
  options: opts.map((o2, i) => ({ value: String(i), label: o2.label })),
50266
- initialValue: "0"
50400
+ initialValue: "0",
50401
+ flagHint: "Publishing a NEW package picks an owner — pass --yes to use your personal namespace, or run interactively."
50267
50402
  });
50268
- if (lD(choice))
50269
- return null;
50270
50403
  return opts[Number(choice)] ?? null;
50271
50404
  }
50272
50405
 
@@ -50299,14 +50432,15 @@ async function runSkillUpdate(cwd2, args) {
50299
50432
  }
50300
50433
  let target = candidates[0];
50301
50434
  if (candidates.length > 1) {
50302
- const choice = await ie({
50435
+ const choice = await select({
50303
50436
  message: "Which one?",
50304
50437
  options: candidates.map((c2, i) => ({
50305
50438
  value: String(i),
50306
50439
  label: `${c2.harness}/${c2.scope} — ${c2.dir}`
50307
- }))
50440
+ })),
50441
+ flagHint: "Pass --harness <id> and/or --scope <s> to disambiguate."
50308
50442
  });
50309
- target = candidates[Number(ensureNotCancelled(choice))];
50443
+ target = candidates[Number(choice)];
50310
50444
  }
50311
50445
  const marker = readSkillMarker(target.dir);
50312
50446
  if (!marker) {
@@ -50322,7 +50456,7 @@ async function runSkillUpdate(cwd2, args) {
50322
50456
  f2.error(`No resolver for ${marker.source.type}.`);
50323
50457
  return;
50324
50458
  }
50325
- if (!args.yes) {
50459
+ if (!autoProceed(args.yes)) {
50326
50460
  const ok = await se({
50327
50461
  message: `Re-fetch ${import_picocolors17.default.bold(args.slug)} from ${describeSource(marker.source)}?`,
50328
50462
  initialValue: true
@@ -51462,18 +51596,19 @@ async function runLink(cwd2, args) {
51462
51596
  await handleAlreadyLinked(cwd2, existing, args);
51463
51597
  return;
51464
51598
  }
51465
- const ans = await te({
51599
+ const ans = await text({
51466
51600
  message: "Agent id (UUID)",
51467
51601
  placeholder: "paste from the web app URL",
51468
- validate: (v3) => !v3?.trim() ? "Required" : undefined
51602
+ validate: (v3) => !v3?.trim() ? "Required" : undefined,
51603
+ flagHint: "Pass --agent <id>."
51469
51604
  });
51470
- agentId = ensureNotCancelled(ans).trim();
51605
+ agentId = ans.trim();
51471
51606
  }
51472
51607
  await attachToExistingAgent(cwd2, agentId, args, existing);
51473
51608
  }
51474
51609
  async function handleAlreadyLinked(cwd2, link2, args) {
51475
51610
  f2.info(`This folder is already linked to ${import_picocolors22.default.bold(link2.name)} ${import_picocolors22.default.dim(`(${link2.slug})`)}.`);
51476
- const action = await ie({
51611
+ const next = await select({
51477
51612
  message: "What do you want to do?",
51478
51613
  options: [
51479
51614
  { value: "show", label: "Show details" },
@@ -51481,9 +51616,9 @@ async function handleAlreadyLinked(cwd2, link2, args) {
51481
51616
  { value: "unlink", label: "Unlink this folder" },
51482
51617
  { value: "cancel", label: "Cancel" }
51483
51618
  ],
51484
- initialValue: "show"
51619
+ initialValue: "show",
51620
+ flagHint: "Pass --agent <id> to link non-interactively."
51485
51621
  });
51486
- const next = ensureNotCancelled(action);
51487
51622
  if (next === "cancel") {
51488
51623
  $e("Cancelled.");
51489
51624
  return;
@@ -51493,7 +51628,7 @@ async function handleAlreadyLinked(cwd2, link2, args) {
51493
51628
  return;
51494
51629
  }
51495
51630
  if (next === "unlink") {
51496
- if (!args.yes) {
51631
+ if (!autoProceed(args.yes)) {
51497
51632
  const confirmed = await se({
51498
51633
  message: "Remove the link from this folder? (the cloud agent will stay)",
51499
51634
  initialValue: true
@@ -51508,13 +51643,14 @@ async function handleAlreadyLinked(cwd2, link2, args) {
51508
51643
  $e("Unlinked.");
51509
51644
  return;
51510
51645
  }
51511
- const ans = await te({
51646
+ const ans = await text({
51512
51647
  message: "New agent id (UUID)",
51513
51648
  placeholder: "paste from the web app URL",
51514
- validate: (v3) => !v3?.trim() ? "Required" : undefined
51649
+ validate: (v3) => !v3?.trim() ? "Required" : undefined,
51650
+ flagHint: "Pass --agent <id>."
51515
51651
  });
51516
- const newId = ensureNotCancelled(ans).trim();
51517
- if (!args.yes) {
51652
+ const newId = ans.trim();
51653
+ if (!autoProceed(args.yes)) {
51518
51654
  const confirmed = await se({
51519
51655
  message: "This will replace the current link. Continue?",
51520
51656
  initialValue: false
@@ -51685,7 +51821,7 @@ async function runUnlink(cwd2, args) {
51685
51821
  return;
51686
51822
  }
51687
51823
  f2.info(`Currently linked to ${import_picocolors23.default.bold(link2.name)} ${import_picocolors23.default.dim(`(${link2.slug})`)}.`);
51688
- if (!args.yes) {
51824
+ if (!autoProceed(args.yes)) {
51689
51825
  const ok = await se({
51690
51826
  message: "Remove the link from this folder? (the cloud agent will stay)",
51691
51827
  initialValue: true
@@ -51871,7 +52007,7 @@ async function runSync(cwd2, args) {
51871
52007
  subtitle: `updates for ${link2.name}`,
51872
52008
  rows: resultRows
51873
52009
  });
51874
- if (!args.yes) {
52010
+ if (!autoProceed(args.yes)) {
51875
52011
  const ok = await se({ message: "Apply these changes?", initialValue: true });
51876
52012
  if (!ensureNotCancelled(ok)) {
51877
52013
  $e("Aborted.");
@@ -51882,19 +52018,22 @@ async function runSync(cwd2, args) {
51882
52018
  const detected = detections.filter((d3) => d3.detection.detected);
51883
52019
  let adapterId = args.harness ?? link2.harness ?? link2.tracking?.harness ?? detected[0]?.adapter.id;
51884
52020
  if (!adapterId) {
51885
- const choice = await ie({
52021
+ adapterId = await select({
51886
52022
  message: "Install into which harness?",
51887
52023
  options: detections.map((d3) => ({
51888
52024
  value: d3.adapter.id,
51889
52025
  label: d3.adapter.displayName,
51890
52026
  hint: d3.detection.detected ? "detected" : "will scaffold"
51891
- }))
52027
+ })),
52028
+ flagHint: "Pass --harness <id> to choose non-interactively."
51892
52029
  });
51893
- adapterId = ensureNotCancelled(choice);
51894
52030
  }
51895
52031
  const adapter = getAdapter(adapterId);
51896
52032
  const scope = args.scope ?? "project";
51897
52033
  const keepLocal = new Set;
52034
+ if (diff2.localModified.length > 0) {
52035
+ requireInteractive(`${diff2.localModified.length} component(s) changed both locally and in the cloud — run \`brainbase sync\` in an interactive terminal to resolve them (or revert your local changes).`);
52036
+ }
51898
52037
  for (const c2 of diff2.localModified) {
51899
52038
  const choice = await ie({
51900
52039
  message: `${fmtType(c2.type)} ${import_picocolors24.default.bold(c2.slug)} — your version is different from your team's`,
@@ -51925,7 +52064,7 @@ async function runSync(cwd2, args) {
51925
52064
  rootDir: path45.join(stageRoot, c2.type, c2.slug),
51926
52065
  description: c2.description,
51927
52066
  meta: c2.meta,
51928
- payload: c2.meta?.mcp,
52067
+ payload: proxifyMcpPayload(c2.meta?.mcp),
51929
52068
  checksum: c2.hash
51930
52069
  }));
51931
52070
  const hasUserOrchestrationMcp = toInstall.some((c2) => c2.type === "mcp" && c2.slug === ORCHESTRATION_MCP_SLUG);
@@ -51957,7 +52096,7 @@ async function runSync(cwd2, args) {
51957
52096
  }
51958
52097
  if (diff2.deletedUpstream.length > 0) {
51959
52098
  for (const removed of diff2.deletedUpstream) {
51960
- let goAhead = args.yes ?? false;
52099
+ let goAhead = autoProceed(args.yes);
51961
52100
  if (!goAhead) {
51962
52101
  const ans = await se({
51963
52102
  message: `${fmtType(removed.type)} ${import_picocolors24.default.bold(removed.slug)} was removed by your team — remove locally?`,
@@ -52377,9 +52516,9 @@ function secretsPath(cwd2) {
52377
52516
  return path47.join(cwd2, LINK_DIR, SECRETS_FILE);
52378
52517
  }
52379
52518
  var VALID_KEY = /^[A-Z][A-Z0-9_]*$/;
52380
- function parseSecretsEnv(text) {
52519
+ function parseSecretsEnv(text2) {
52381
52520
  const out = {};
52382
- const lines = text.split(/\r?\n/);
52521
+ const lines = text2.split(/\r?\n/);
52383
52522
  for (const raw of lines) {
52384
52523
  const line = raw.replace(/^\s+/, "");
52385
52524
  if (!line || line.startsWith("#"))
@@ -52526,6 +52665,9 @@ async function runAgentPull(cwd2, args) {
52526
52665
  }
52527
52666
  }
52528
52667
  const keepLocalKeys = new Set;
52668
+ if (conflicts.length > 0) {
52669
+ requireInteractive(`${conflicts.length} file(s) changed both locally and in the cloud — resolve them in an interactive terminal, or pass --force to take the cloud copy.`);
52670
+ }
52529
52671
  for (const r2 of conflicts) {
52530
52672
  const choice = await ie({
52531
52673
  message: r2.status === "modified-both" ? `${fmtType(r2.type)} ${import_picocolors25.default.bold(r2.slug)} — both you and the cloud edited it` : `${fmtType(r2.type)} ${import_picocolors25.default.bold(r2.slug)} — you have local edits not yet pushed`,
@@ -52585,7 +52727,7 @@ async function runAgentPull(cwd2, args) {
52585
52727
  subtitle: `updates for ${cloudAgent.name}`,
52586
52728
  rows: resultRows
52587
52729
  });
52588
- if (!args.yes) {
52730
+ if (!autoProceed(args.yes)) {
52589
52731
  const msg = override ? "Apply these changes? Local edits to overlapping components will be discarded." : "Apply these changes?";
52590
52732
  const ok = await se({ message: msg, initialValue: true });
52591
52733
  if (!ensureNotCancelled(ok)) {
@@ -52609,7 +52751,7 @@ async function runAgentPull(cwd2, args) {
52609
52751
  rootDir: path48.join(stageRoot, c2.type, c2.slug),
52610
52752
  description: c2.description,
52611
52753
  meta: c2.meta,
52612
- payload: c2.meta?.mcp,
52754
+ payload: proxifyMcpPayload(c2.meta?.mcp),
52613
52755
  checksum: c2.hash,
52614
52756
  source: skillSourceFromMeta(c2)
52615
52757
  }));
@@ -53377,7 +53519,7 @@ async function runAgentPush(cwd2, args) {
53377
53519
  subtitle: `${manifest.agent.name} ← local`,
53378
53520
  rows: resultRows
53379
53521
  });
53380
- if (!args.yes) {
53522
+ if (!autoProceed(args.yes)) {
53381
53523
  const ok = await se({ message: "Send these changes?", initialValue: true });
53382
53524
  if (!ensureNotCancelled(ok)) {
53383
53525
  $e("Aborted.");
@@ -53715,8 +53857,8 @@ function divider(label, width = 56, indent = 2) {
53715
53857
  const right = import_picocolors29.default.dim(H3.repeat(Math.max(0, width - labelLen - 2)));
53716
53858
  return `${ind}${left}${import_picocolors29.default.bold(import_picocolors29.default.dim(labelText))}${right}`;
53717
53859
  }
53718
- function tip(text, indent = 2) {
53719
- return " ".repeat(indent) + import_picocolors29.default.dim("›") + " " + import_picocolors29.default.dim(text);
53860
+ function tip(text2, indent = 2) {
53861
+ return " ".repeat(indent) + import_picocolors29.default.dim("›") + " " + import_picocolors29.default.dim(text2);
53720
53862
  }
53721
53863
 
53722
53864
  // src/cli/agent-create.ts
@@ -53758,11 +53900,11 @@ async function runAgentCreate(cwd2, args) {
53758
53900
  org = orgs[0];
53759
53901
  f2.info(`Using organization ${import_picocolors30.default.bold(org.name)}.`);
53760
53902
  } else {
53761
- const orgChoice = await ie({
53903
+ const orgId = await select({
53762
53904
  message: "Pick an organization",
53763
- options: orgs.map((o2) => ({ value: o2.id, label: o2.name, hint: o2.role }))
53905
+ options: orgs.map((o2) => ({ value: o2.id, label: o2.name, hint: o2.role })),
53906
+ flagHint: "Pass --org <id> to choose non-interactively."
53764
53907
  });
53765
- const orgId = ensureNotCancelled(orgChoice);
53766
53908
  org = orgs.find((o2) => o2.id === orgId);
53767
53909
  }
53768
53910
  const teamsSpinner = de();
@@ -53784,6 +53926,15 @@ async function runAgentCreate(cwd2, args) {
53784
53926
  return;
53785
53927
  }
53786
53928
  team = found;
53929
+ } else if (!isInteractive()) {
53930
+ if (teams.length === 1) {
53931
+ team = teams[0];
53932
+ f2.info(`Using team ${import_picocolors30.default.bold(team.name)}.`);
53933
+ } else if (teams.length === 0) {
53934
+ throw new NonInteractiveError(`No teams in ${org.name} yet — create one in the web app, then re-run.`);
53935
+ } else {
53936
+ throw new NonInteractiveError(`Multiple teams in ${org.name}. Pass --team <id> to choose non-interactively.`);
53937
+ }
53787
53938
  } else {
53788
53939
  const teamOptions = [
53789
53940
  ...teams.map((t) => ({ value: t.id, label: t.name, hint: t.role })),
@@ -53817,15 +53968,15 @@ async function runAgentCreate(cwd2, args) {
53817
53968
  const harness = normalizeHarnessId(args.harness ?? manifest.harness ?? await pickHarness(cwd2));
53818
53969
  let agentName = args.name?.trim() || manifest.agent.name.trim();
53819
53970
  if (!agentName) {
53820
- const ans = await te({
53971
+ agentName = (await text({
53821
53972
  message: "Agent name",
53822
53973
  placeholder: "e.g. Customer Support Bot",
53823
- validate: (v3) => !v3?.trim() ? "Required" : undefined
53824
- });
53825
- agentName = ensureNotCancelled(ans).trim();
53974
+ validate: (v3) => !v3?.trim() ? "Required" : undefined,
53975
+ flagHint: "Pass --name <name>."
53976
+ })).trim();
53826
53977
  }
53827
53978
  let tagline = (args.tagline ?? manifest.agent.tagline)?.trim() || undefined;
53828
- if (tagline === undefined && !args.yes) {
53979
+ if (tagline === undefined && !autoProceed(args.yes)) {
53829
53980
  const ans = await te({
53830
53981
  message: "Tagline",
53831
53982
  placeholder: "optional one-line description"
@@ -53834,7 +53985,7 @@ async function runAgentCreate(cwd2, args) {
53834
53985
  if (typeof raw === "string" && raw.trim())
53835
53986
  tagline = raw.trim();
53836
53987
  }
53837
- if (!args.yes) {
53988
+ if (!autoProceed(args.yes)) {
53838
53989
  le([
53839
53990
  `${import_picocolors30.default.dim("org")} ${import_picocolors30.default.bold(org.name)}`,
53840
53991
  `${import_picocolors30.default.dim("team")} ${import_picocolors30.default.bold(team.name)}`,
@@ -53884,8 +54035,15 @@ async function runAgentCreate(cwd2, args) {
53884
54035
  let tracking;
53885
54036
  const adapter = getRouteAdapter(harness);
53886
54037
  if (adapter && !args.noTracking) {
53887
- let wantsTracking = true;
53888
- if (!args.yes) {
54038
+ let wantsTracking;
54039
+ if (args.track) {
54040
+ wantsTracking = true;
54041
+ } else if (!isInteractive()) {
54042
+ wantsTracking = false;
54043
+ f2.info(`Tracking left off (non-interactive). Re-run with ${import_picocolors30.default.cyan("--track")} to route ${harness} LLM traffic through brainbase.`);
54044
+ } else if (args.yes) {
54045
+ wantsTracking = true;
54046
+ } else {
53889
54047
  const ans = await se({
53890
54048
  message: `Track ${harness} conversations on the brainbase platform? ${import_picocolors30.default.dim("(routes LLM calls through brainbase so they appear under this agent)")}`,
53891
54049
  initialValue: true
@@ -54022,6 +54180,9 @@ async function loadOrScaffoldManifest(cwd2, args) {
54022
54180
  }
54023
54181
  f2.warn(`No ${import_picocolors30.default.bold(AGENT_MANIFEST_FILE)} here.`);
54024
54182
  if (!args.yes) {
54183
+ if (!isInteractive()) {
54184
+ throw new NonInteractiveError(`No ${AGENT_MANIFEST_FILE} here. Create one first, or re-run with --yes to scaffold a minimal one.`);
54185
+ }
54025
54186
  const ans = await se({
54026
54187
  message: `Scaffold a minimal ${import_picocolors30.default.bold(AGENT_MANIFEST_FILE)} and continue?`,
54027
54188
  initialValue: true
@@ -54057,15 +54218,15 @@ async function pickHarness(cwd2) {
54057
54218
  f2.info(`Detected harness: ${import_picocolors30.default.bold(detected[0].adapter.displayName)}.`);
54058
54219
  return detected[0].adapter.id;
54059
54220
  }
54060
- const choice = await ie({
54221
+ return await select({
54061
54222
  message: detected.length > 1 ? "Multiple harnesses detected — which one is this agent for?" : "No harness detected here. Which harness is this agent for?",
54062
54223
  options: detections.map((d3) => ({
54063
54224
  value: d3.adapter.id,
54064
54225
  label: d3.adapter.displayName,
54065
54226
  hint: d3.detection.detected ? "detected" : undefined
54066
- }))
54227
+ })),
54228
+ flagHint: "Pass --harness <claude-code|codex|kafka>."
54067
54229
  });
54068
- return ensureNotCancelled(choice);
54069
54230
  }
54070
54231
  function handleApiError4(err) {
54071
54232
  if (err instanceof ApiError) {
@@ -54116,7 +54277,7 @@ async function runAgentUnpack(cwd2, args) {
54116
54277
  } else {
54117
54278
  harness = await pickHarness2(manifest.harness);
54118
54279
  }
54119
- if (!args.yes) {
54280
+ if (!autoProceed(args.yes)) {
54120
54281
  const ok = await se({
54121
54282
  message: `Install ${import_picocolors31.default.bold(manifest.agent.name)} as ${import_picocolors31.default.bold(harness)} here?`,
54122
54283
  initialValue: true
@@ -54328,16 +54489,16 @@ function runHarnessInstall3(harnessId, components, opts, agentName) {
54328
54489
  }
54329
54490
  async function pickHarness2(current) {
54330
54491
  const initial2 = current ? normalizeHarnessId(current) : undefined;
54331
- const choice = await ie({
54492
+ return select({
54332
54493
  message: "Pick a harness to install as",
54333
54494
  options: adapters.map((a3) => ({
54334
54495
  value: a3.id,
54335
54496
  label: a3.displayName,
54336
54497
  hint: a3.id === initial2 ? "current" : undefined
54337
54498
  })),
54338
- initialValue: initial2 ?? adapters[0].id
54499
+ initialValue: initial2 ?? adapters[0].id,
54500
+ flagHint: "Pass --harness <id> to choose non-interactively."
54339
54501
  });
54340
- return ensureNotCancelled(choice);
54341
54502
  }
54342
54503
 
54343
54504
  // src/cli/agent.ts
@@ -54351,7 +54512,8 @@ async function runAgent(cwd2, sub, args, opts) {
54351
54512
  tagline: opts.tagline,
54352
54513
  orgId: opts.orgId,
54353
54514
  teamId: opts.teamId,
54354
- noTracking: opts.noTracking
54515
+ noTracking: opts.noTracking,
54516
+ track: opts.track
54355
54517
  });
54356
54518
  return;
54357
54519
  case "pull":
@@ -54623,7 +54785,7 @@ async function installAgentFresh(input) {
54623
54785
  rootDir: path53.join(stageRoot, c2.type, c2.slug),
54624
54786
  description: c2.description,
54625
54787
  meta: c2.meta,
54626
- payload: c2.meta?.mcp,
54788
+ payload: proxifyMcpPayload(c2.meta?.mcp),
54627
54789
  checksum: c2.hash
54628
54790
  }));
54629
54791
  if (needOrchestrationMcpInstall) {
@@ -54829,7 +54991,7 @@ async function runOrchestrationPull(cwd2, args) {
54829
54991
  console.log(planLines.join(`
54830
54992
  `));
54831
54993
  const isRefresh = !!existingLink;
54832
- if (!args.yes && !isRefresh) {
54994
+ if (!autoProceed(args.yes) && !isRefresh) {
54833
54995
  const ok = await se({
54834
54996
  message: `Pull into ${import_picocolors33.default.bold(cwd2)}?`,
54835
54997
  initialValue: true
@@ -55013,7 +55175,7 @@ async function runOrchestrationPush(cwd2, args) {
55013
55175
  }
55014
55176
  console.log(plan.join(`
55015
55177
  `));
55016
- if (!args.yes) {
55178
+ if (!autoProceed(args.yes)) {
55017
55179
  const ok = await se({
55018
55180
  message: args.graphOnly ? "Push graph (members + edges) only?" : "Push each member, then update the graph?",
55019
55181
  initialValue: true
@@ -55222,11 +55384,11 @@ async function runOrchestrationList(args) {
55222
55384
  if (orgs.length === 1) {
55223
55385
  orgId = orgs[0].id;
55224
55386
  } else {
55225
- const choice = await ie({
55387
+ orgId = await select({
55226
55388
  message: "Which organization?",
55227
- options: orgs.map((o2) => ({ value: o2.id, label: o2.name }))
55389
+ options: orgs.map((o2) => ({ value: o2.id, label: o2.name })),
55390
+ flagHint: "Pass --org <id>."
55228
55391
  });
55229
- orgId = ensureNotCancelled(choice);
55230
55392
  }
55231
55393
  }
55232
55394
  if (!teamId) {
@@ -55244,11 +55406,11 @@ async function runOrchestrationList(args) {
55244
55406
  if (teams.length === 1) {
55245
55407
  teamId = teams[0].id;
55246
55408
  } else {
55247
- const choice = await ie({
55409
+ teamId = await select({
55248
55410
  message: "Which team?",
55249
- options: teams.map((t) => ({ value: t.id, label: t.name }))
55411
+ options: teams.map((t) => ({ value: t.id, label: t.name })),
55412
+ flagHint: "Pass --team <id>."
55250
55413
  });
55251
- teamId = ensureNotCancelled(choice);
55252
55414
  }
55253
55415
  }
55254
55416
  let items;
@@ -55939,12 +56101,12 @@ async function runTokenCreate(args) {
55939
56101
  banner("token create — make a long-lived CLI key");
55940
56102
  let name = args.name;
55941
56103
  if (!name) {
55942
- const ans = await te({
56104
+ name = await text({
55943
56105
  message: "Token label",
55944
56106
  placeholder: "my-laptop or ci-runner",
55945
- validate: (v3) => v3.length === 0 ? "Required." : undefined
56107
+ validate: (v3) => v3.length === 0 ? "Required." : undefined,
56108
+ flagHint: "Pass --name <label>."
55946
56109
  });
55947
- name = ensureNotCancelled(ans);
55948
56110
  }
55949
56111
  const scopes = args.scopes && args.scopes.length > 0 ? args.scopes : DEFAULT_SCOPES;
55950
56112
  const spinner = de();
@@ -55986,7 +56148,7 @@ async function runTokenRevoke(args) {
55986
56148
  console.error("Usage: brainbase token revoke <id>");
55987
56149
  process.exit(1);
55988
56150
  }
55989
- if (!args.yes) {
56151
+ if (!autoProceed(args.yes)) {
55990
56152
  const ok = await se({
55991
56153
  message: `Revoke token ${import_picocolors39.default.bold(args.id)}? CIs and machines using it will stop working.`,
55992
56154
  initialValue: false
@@ -56150,6 +56312,7 @@ function help() {
56150
56312
  out.push(` ${import_picocolors40.default.dim("--yes, -y")} skip confirmations / auto-overwrite`);
56151
56313
  out.push(` ${import_picocolors40.default.dim("--agent <id>")} for link: attach this folder to an existing agent non-interactively`);
56152
56314
  out.push(` ${import_picocolors40.default.dim("--no-tracking")} for link: skip routing LLM traffic through brainbase`);
56315
+ out.push(` ${import_picocolors40.default.dim("--track")} for agent create: enable tracking non-interactively (off without a TTY)`);
56153
56316
  out.push(` ${import_picocolors40.default.dim("--shell <sh|fish>")} for agent env: pick output format (auto-detected from $SHELL)`);
56154
56317
  out.push(` ${import_picocolors40.default.dim("--all")} for template list: include installs from other folders`);
56155
56318
  out.push(` ${import_picocolors40.default.dim("--web <url>")} for login: web app URL (default https://new.usekafka.com)`);
@@ -56162,6 +56325,7 @@ function help() {
56162
56325
  out.push(` ${import_picocolors40.default.dim("BRAINBASE_REGISTRY_URL")} override the registry API URL`);
56163
56326
  out.push(` ${import_picocolors40.default.dim("BRAINBASE_TOKEN")} long-lived CLI PAT (overrides token.json)`);
56164
56327
  out.push(` ${import_picocolors40.default.dim("BRAINBASE_SKIP_AUTH")} bypass the auth gate for development`);
56328
+ out.push(` ${import_picocolors40.default.dim("BRAINBASE_NON_INTERACTIVE")} force non-interactive mode — skip/auto-default prompts (CI & agents)`);
56165
56329
  out.push("");
56166
56330
  out.push(divider("HARNESSES"));
56167
56331
  out.push("");
@@ -56196,9 +56360,9 @@ function hasFlag2(args, ...names) {
56196
56360
  async function requireAuth(cmd) {
56197
56361
  if (!PROTECTED.has(cmd))
56198
56362
  return;
56199
- if (process13.env.BRAINBASE_SKIP_AUTH === "1")
56363
+ if (process14.env.BRAINBASE_SKIP_AUTH === "1")
56200
56364
  return;
56201
- const envToken = process13.env.BRAINBASE_TOKEN;
56365
+ const envToken = process14.env.BRAINBASE_TOKEN;
56202
56366
  if (envToken && envToken.trim())
56203
56367
  return;
56204
56368
  let status = authStatus();
@@ -56219,12 +56383,12 @@ async function requireAuth(cmd) {
56219
56383
  console.error("");
56220
56384
  console.error(` Run ${import_picocolors40.default.cyan("brainbase login")} to connect this device.`);
56221
56385
  console.error("");
56222
- process13.exit(1);
56386
+ process14.exit(1);
56223
56387
  }
56224
56388
  async function main() {
56225
- const argv = process13.argv.slice(2);
56389
+ const argv = process14.argv.slice(2);
56226
56390
  const cmd = argv.shift();
56227
- const rawCwd = process13.cwd();
56391
+ const rawCwd = process14.cwd();
56228
56392
  const cwd2 = (() => {
56229
56393
  try {
56230
56394
  return fs51.realpathSync(rawCwd);
@@ -56254,6 +56418,7 @@ async function main() {
56254
56418
  const agentFlag = getFlag(argv, "--agent");
56255
56419
  const shellFlag = getFlag(argv, "--shell");
56256
56420
  const noTracking = hasFlag2(argv, "--no-tracking");
56421
+ const track = hasFlag2(argv, "--track");
56257
56422
  const forceFlag = hasFlag2(argv, "--force");
56258
56423
  const graphOnlyFlag = hasFlag2(argv, "--graph-only");
56259
56424
  const nameFlag = getFlag(argv, "--name");
@@ -56340,6 +56505,7 @@ async function main() {
56340
56505
  orgId: orgIdFlag,
56341
56506
  teamId: teamIdFlag,
56342
56507
  noTracking,
56508
+ track,
56343
56509
  force: forceFlag
56344
56510
  });
56345
56511
  break;
@@ -56368,14 +56534,14 @@ async function main() {
56368
56534
  console.error(`Unknown command: ${cmd}
56369
56535
  `);
56370
56536
  help();
56371
- process13.exit(1);
56537
+ process14.exit(1);
56372
56538
  }
56373
56539
  } catch (err) {
56374
56540
  console.error(import_picocolors40.default.red(`
56375
56541
  ${err.message}`));
56376
- if (process13.env.BRAINBASE_DEBUG)
56542
+ if (process14.env.BRAINBASE_DEBUG)
56377
56543
  console.error(err.stack);
56378
- process13.exit(1);
56544
+ process14.exit(1);
56379
56545
  }
56380
56546
  }
56381
56547
  main();