@p-sw/brainbox 0.1.1 → 0.1.2-alpha.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 +285 -109
  2. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -2255,7 +2255,14 @@ register("vertex", VertexExecutor);
2255
2255
  register("copilot", CopilotExecutor);
2256
2256
  register("gitlab-duo", GitLabDuoExecutor);
2257
2257
  register("snowflake-cortex", SnowflakeCortexExecutor);
2258
- var llm = LLMExecutor.init();
2258
+ var _llm;
2259
+ var llm = new Proxy({}, {
2260
+ get(_t, prop) {
2261
+ _llm ??= LLMExecutor.init();
2262
+ const v = Reflect.get(_llm, prop, _llm);
2263
+ return typeof v === "function" ? v.bind(_llm) : v;
2264
+ }
2265
+ });
2259
2266
 
2260
2267
  // src/provider/promptLoader.ts
2261
2268
  import { existsSync as existsSync2 } from "fs";
@@ -4179,7 +4186,8 @@ import { Box, Text as Text2, render } from "ink";
4179
4186
  // src/ui/TextInput.tsx
4180
4187
  import { useEffect, useState } from "react";
4181
4188
  import { Text, useInput, useStdin } from "ink";
4182
- import { jsxDEV } from "react/jsx-dev-runtime";
4189
+
4190
+ // src/ui/pipedStdin.ts
4183
4191
  var pipedBuffer = null;
4184
4192
  var pipedSubscribers = [];
4185
4193
  function drainPiped(stdin) {
@@ -4213,6 +4221,21 @@ function drainPiped(stdin) {
4213
4221
  };
4214
4222
  tryRead();
4215
4223
  }
4224
+ function takePipedLine(stdin, onLine) {
4225
+ drainPiped(stdin);
4226
+ pipedSubscribers.push(onLine);
4227
+ if (pipedBuffer && pipedBuffer.length > 0) {
4228
+ const line = pipedBuffer.shift();
4229
+ if (line !== undefined)
4230
+ onLine(line);
4231
+ }
4232
+ return () => {
4233
+ pipedSubscribers = pipedSubscribers.filter((s) => s !== onLine);
4234
+ };
4235
+ }
4236
+
4237
+ // src/ui/TextInput.tsx
4238
+ import { jsxDEV } from "react/jsx-dev-runtime";
4216
4239
  function PipedInput({
4217
4240
  prompt,
4218
4241
  initialValue = "",
@@ -4222,16 +4245,7 @@ function PipedInput({
4222
4245
  }) {
4223
4246
  const [value] = useState(initialValue);
4224
4247
  useEffect(() => {
4225
- drainPiped(stdin);
4226
- pipedSubscribers.push(onSubmit);
4227
- if (pipedBuffer && pipedBuffer.length > 0) {
4228
- const line = pipedBuffer.shift();
4229
- if (line !== undefined)
4230
- onSubmit(line);
4231
- }
4232
- return () => {
4233
- pipedSubscribers = pipedSubscribers.filter((s) => s !== onSubmit);
4234
- };
4248
+ return takePipedLine(stdin, onSubmit);
4235
4249
  }, [stdin, onSubmit]);
4236
4250
  const shown = value.length > 0 ? value : placeholder;
4237
4251
  return /* @__PURE__ */ jsxDEV(Text, {
@@ -4758,57 +4772,223 @@ function register7(program) {
4758
4772
  }
4759
4773
 
4760
4774
  // src/commands/onboard.tsx
4761
- import { useState as useState4 } from "react";
4762
- import { Box as Box3, Text as Text4, render as render3 } from "ink";
4775
+ import { useState as useState5 } from "react";
4776
+ import { Box as Box4, Text as Text5, render as render3 } from "ink";
4763
4777
  import chalk3 from "chalk";
4764
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
4778
+
4779
+ // src/ui/Select.tsx
4780
+ import { useEffect as useEffect2, useMemo, useState as useState4 } from "react";
4781
+ import { Box as Box3, Text as Text4, useInput as useInput2, useStdin as useStdin2 } from "ink";
4782
+ import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
4783
+ function filterItems(items, query) {
4784
+ const q = query.trim().toLowerCase();
4785
+ if (!q)
4786
+ return items;
4787
+ return items.filter((i) => i.toLowerCase().includes(q));
4788
+ }
4789
+ function windowStart(cursor, total, limit) {
4790
+ if (total <= limit)
4791
+ return 0;
4792
+ return Math.max(0, Math.min(cursor - Math.floor(limit / 2), total - limit));
4793
+ }
4794
+ function resolvePiped(items, line) {
4795
+ if (items.includes(line))
4796
+ return line;
4797
+ const exact = items.find((i) => i.toLowerCase() === line.toLowerCase());
4798
+ if (exact)
4799
+ return exact;
4800
+ const filtered = filterItems(items, line);
4801
+ if (filtered.length === 1)
4802
+ return filtered[0];
4803
+ return;
4804
+ }
4805
+ function PipedSelect({
4806
+ prompt = "",
4807
+ items,
4808
+ onSelect,
4809
+ stdin
4810
+ }) {
4811
+ useEffect2(() => {
4812
+ return takePipedLine(stdin, (line) => {
4813
+ const match = resolvePiped(items, line.trim());
4814
+ if (match)
4815
+ onSelect(match);
4816
+ });
4817
+ }, [stdin, onSelect, items]);
4818
+ return /* @__PURE__ */ jsxDEV4(Box3, {
4819
+ flexDirection: "column",
4820
+ children: [
4821
+ /* @__PURE__ */ jsxDEV4(Text4, {
4822
+ children: [
4823
+ prompt,
4824
+ /* @__PURE__ */ jsxDEV4(Text4, {
4825
+ dimColor: true,
4826
+ children: "(piped)"
4827
+ }, undefined, false, undefined, this)
4828
+ ]
4829
+ }, undefined, true, undefined, this),
4830
+ /* @__PURE__ */ jsxDEV4(Text4, {
4831
+ dimColor: true,
4832
+ children: [
4833
+ "matches (",
4834
+ items.length,
4835
+ "/",
4836
+ items.length,
4837
+ "):"
4838
+ ]
4839
+ }, undefined, true, undefined, this),
4840
+ items.slice(0, 8).map((item) => /* @__PURE__ */ jsxDEV4(Text4, {
4841
+ children: [
4842
+ " ",
4843
+ item
4844
+ ]
4845
+ }, item, true, undefined, this))
4846
+ ]
4847
+ }, undefined, true, undefined, this);
4848
+ }
4849
+ function RawSelect({
4850
+ prompt = "",
4851
+ items,
4852
+ limit = 8,
4853
+ onSelect
4854
+ }) {
4855
+ const [query, setQuery] = useState4("");
4856
+ const [cursor, setCursor] = useState4(0);
4857
+ const filtered = useMemo(() => filterItems(items, query), [items, query]);
4858
+ const active = Math.min(cursor, Math.max(0, filtered.length - 1));
4859
+ const start = windowStart(active, filtered.length, limit);
4860
+ const visible = filtered.slice(start, start + limit);
4861
+ useInput2((input, key) => {
4862
+ if (key.return) {
4863
+ const item = filtered[active];
4864
+ if (item)
4865
+ onSelect(item);
4866
+ return;
4867
+ }
4868
+ if (key.upArrow) {
4869
+ setCursor((c) => Math.max(0, Math.min(c, filtered.length - 1) - 1));
4870
+ return;
4871
+ }
4872
+ if (key.downArrow) {
4873
+ setCursor((c) => Math.min(filtered.length - 1, Math.min(c, filtered.length - 1) + 1));
4874
+ return;
4875
+ }
4876
+ if (key.pageUp) {
4877
+ setCursor((c) => Math.max(0, Math.min(c, filtered.length - 1) - limit));
4878
+ return;
4879
+ }
4880
+ if (key.pageDown) {
4881
+ setCursor((c) => Math.min(filtered.length - 1, Math.min(c, filtered.length - 1) + limit));
4882
+ return;
4883
+ }
4884
+ if (key.backspace || key.delete) {
4885
+ setQuery((q) => q.slice(0, -1));
4886
+ setCursor(0);
4887
+ return;
4888
+ }
4889
+ if (key.ctrl && input === "c") {
4890
+ process.exit(130);
4891
+ }
4892
+ if (input.length > 0 && !key.ctrl && !key.meta) {
4893
+ setQuery((q) => q + input);
4894
+ setCursor(0);
4895
+ }
4896
+ });
4897
+ return /* @__PURE__ */ jsxDEV4(Box3, {
4898
+ flexDirection: "column",
4899
+ children: [
4900
+ /* @__PURE__ */ jsxDEV4(Text4, {
4901
+ children: [
4902
+ prompt,
4903
+ query,
4904
+ /* @__PURE__ */ jsxDEV4(Text4, {
4905
+ color: "cyan",
4906
+ children: "|"
4907
+ }, undefined, false, undefined, this)
4908
+ ]
4909
+ }, undefined, true, undefined, this),
4910
+ /* @__PURE__ */ jsxDEV4(Text4, {
4911
+ dimColor: true,
4912
+ children: [
4913
+ "matches (",
4914
+ filtered.length,
4915
+ "/",
4916
+ items.length,
4917
+ ") · ↑↓ · type to filter · enter"
4918
+ ]
4919
+ }, undefined, true, undefined, this),
4920
+ filtered.length === 0 ? /* @__PURE__ */ jsxDEV4(Text4, {
4921
+ dimColor: true,
4922
+ children: " (no matches)"
4923
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV4(Fragment, {
4924
+ children: [
4925
+ start > 0 && /* @__PURE__ */ jsxDEV4(Text4, {
4926
+ dimColor: true,
4927
+ children: " …"
4928
+ }, undefined, false, undefined, this),
4929
+ visible.map((item, i) => {
4930
+ const idx = start + i;
4931
+ const selected = idx === active;
4932
+ return /* @__PURE__ */ jsxDEV4(Text4, {
4933
+ color: selected ? "cyan" : undefined,
4934
+ children: [
4935
+ selected ? "> " : " ",
4936
+ item
4937
+ ]
4938
+ }, item, true, undefined, this);
4939
+ }),
4940
+ start + visible.length < filtered.length && /* @__PURE__ */ jsxDEV4(Text4, {
4941
+ dimColor: true,
4942
+ children: " …"
4943
+ }, undefined, false, undefined, this)
4944
+ ]
4945
+ }, undefined, true, undefined, this)
4946
+ ]
4947
+ }, undefined, true, undefined, this);
4948
+ }
4949
+ function Select(props) {
4950
+ const { isRawModeSupported, stdin } = useStdin2();
4951
+ if (!isRawModeSupported)
4952
+ return /* @__PURE__ */ jsxDEV4(PipedSelect, {
4953
+ ...props,
4954
+ stdin
4955
+ }, undefined, false, undefined, this);
4956
+ return /* @__PURE__ */ jsxDEV4(RawSelect, {
4957
+ ...props
4958
+ }, undefined, false, undefined, this);
4959
+ }
4960
+
4961
+ // src/commands/onboard.tsx
4962
+ import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
4765
4963
  function ProviderApp({
4766
4964
  providers,
4767
4965
  onDone
4768
4966
  }) {
4769
- const [stage, setStage] = useState4({ kind: "pick" });
4770
- const [error, setError] = useState4(null);
4967
+ const [stage, setStage] = useState5({ kind: "pick" });
4968
+ const [error, setError] = useState5(null);
4771
4969
  if (stage.kind === "pick") {
4772
- return /* @__PURE__ */ jsxDEV4(Box3, {
4970
+ return /* @__PURE__ */ jsxDEV5(Box4, {
4773
4971
  flexDirection: "column",
4774
4972
  children: [
4775
- /* @__PURE__ */ jsxDEV4(Text4, {
4973
+ /* @__PURE__ */ jsxDEV5(Text5, {
4776
4974
  children: [
4777
4975
  chalk3.bold("Step 1/4"),
4778
4976
  " — Choose your first provider"
4779
4977
  ]
4780
4978
  }, undefined, true, undefined, this),
4781
- /* @__PURE__ */ jsxDEV4(Text4, {
4979
+ /* @__PURE__ */ jsxDEV5(Text5, {
4782
4980
  dimColor: true,
4783
- children: "Enter an exact provider name (see list below)"
4981
+ children: "↑↓ to move, type to filter, enter to select"
4784
4982
  }, undefined, false, undefined, this),
4785
- /* @__PURE__ */ jsxDEV4(TextInput, {
4983
+ /* @__PURE__ */ jsxDEV5(Select, {
4786
4984
  prompt: "provider> ",
4787
- onSubmit: (v) => {
4788
- const p = v.trim();
4789
- if (!p) {
4790
- setError("Provider name is required");
4791
- return;
4792
- }
4793
- if (!providers.includes(p)) {
4794
- setError(`Unknown provider "${p}"`);
4795
- return;
4796
- }
4985
+ items: providers,
4986
+ onSelect: (p) => {
4797
4987
  setError(null);
4798
4988
  setStage({ kind: "apiKey", provider: p });
4799
4989
  }
4800
4990
  }, undefined, false, undefined, this),
4801
- /* @__PURE__ */ jsxDEV4(Text4, {
4802
- dimColor: true,
4803
- children: [
4804
- "known (",
4805
- providers.length,
4806
- "): ",
4807
- providers.slice(0, 10).join(", "),
4808
- providers.length > 10 ? "…" : ""
4809
- ]
4810
- }, undefined, true, undefined, this),
4811
- error && /* @__PURE__ */ jsxDEV4(Text4, {
4991
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
4812
4992
  color: "red",
4813
4993
  children: error
4814
4994
  }, undefined, false, undefined, this)
@@ -4817,14 +4997,14 @@ function ProviderApp({
4817
4997
  }
4818
4998
  if (stage.kind === "apiKey") {
4819
4999
  const envName = `${stage.provider.toUpperCase().replace(/-/g, "_")}_API_KEY`;
4820
- return /* @__PURE__ */ jsxDEV4(Box3, {
5000
+ return /* @__PURE__ */ jsxDEV5(Box4, {
4821
5001
  flexDirection: "column",
4822
5002
  children: [
4823
- /* @__PURE__ */ jsxDEV4(Text4, {
5003
+ /* @__PURE__ */ jsxDEV5(Text5, {
4824
5004
  children: [
4825
5005
  chalk3.bold("Step 1/4"),
4826
5006
  " — ",
4827
- /* @__PURE__ */ jsxDEV4(Text4, {
5007
+ /* @__PURE__ */ jsxDEV5(Text5, {
4828
5008
  color: "cyan",
4829
5009
  children: stage.provider
4830
5010
  }, undefined, false, undefined, this),
@@ -4832,7 +5012,7 @@ function ProviderApp({
4832
5012
  "api key"
4833
5013
  ]
4834
5014
  }, undefined, true, undefined, this),
4835
- /* @__PURE__ */ jsxDEV4(Text4, {
5015
+ /* @__PURE__ */ jsxDEV5(Text5, {
4836
5016
  dimColor: true,
4837
5017
  children: [
4838
5018
  "(blank reuses $",
@@ -4840,7 +5020,7 @@ function ProviderApp({
4840
5020
  " from env)"
4841
5021
  ]
4842
5022
  }, undefined, true, undefined, this),
4843
- /* @__PURE__ */ jsxDEV4(TextInput, {
5023
+ /* @__PURE__ */ jsxDEV5(TextInput, {
4844
5024
  prompt: "apiKey> ",
4845
5025
  onSubmit: (raw) => {
4846
5026
  const apiKey = raw.trim() || (process.env[envName] ?? "");
@@ -4864,7 +5044,7 @@ function ProviderApp({
4864
5044
  });
4865
5045
  }
4866
5046
  }, undefined, false, undefined, this),
4867
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5047
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
4868
5048
  color: "red",
4869
5049
  children: error
4870
5050
  }, undefined, false, undefined, this)
@@ -4875,28 +5055,28 @@ function ProviderApp({
4875
5055
  if (!nextField) {
4876
5056
  setProviderAuth(stage.provider, stage.values);
4877
5057
  logger.success(`Saved ${stage.provider} to auth.yaml`);
4878
- return /* @__PURE__ */ jsxDEV4(Text4, {
5058
+ return /* @__PURE__ */ jsxDEV5(Text5, {
4879
5059
  children: "Continuing…"
4880
5060
  }, undefined, false, undefined, this);
4881
5061
  }
4882
- return /* @__PURE__ */ jsxDEV4(Box3, {
5062
+ return /* @__PURE__ */ jsxDEV5(Box4, {
4883
5063
  flexDirection: "column",
4884
5064
  children: [
4885
- /* @__PURE__ */ jsxDEV4(Text4, {
5065
+ /* @__PURE__ */ jsxDEV5(Text5, {
4886
5066
  children: [
4887
5067
  chalk3.bold("Step 1/4"),
4888
5068
  " — ",
4889
5069
  stage.provider,
4890
5070
  " extra:",
4891
5071
  " ",
4892
- /* @__PURE__ */ jsxDEV4(Text4, {
5072
+ /* @__PURE__ */ jsxDEV5(Text5, {
4893
5073
  color: "cyan",
4894
5074
  children: nextField
4895
5075
  }, undefined, false, undefined, this),
4896
5076
  " (blank to skip)"
4897
5077
  ]
4898
5078
  }, undefined, true, undefined, this),
4899
- /* @__PURE__ */ jsxDEV4(TextInput, {
5079
+ /* @__PURE__ */ jsxDEV5(TextInput, {
4900
5080
  prompt: `${nextField}> `,
4901
5081
  onSubmit: (raw) => {
4902
5082
  const value = raw.trim();
@@ -4919,21 +5099,21 @@ function ModelApp2({
4919
5099
  provider,
4920
5100
  onDone
4921
5101
  }) {
4922
- const [error, setError] = useState4(null);
4923
- return /* @__PURE__ */ jsxDEV4(Box3, {
5102
+ const [error, setError] = useState5(null);
5103
+ return /* @__PURE__ */ jsxDEV5(Box4, {
4924
5104
  flexDirection: "column",
4925
5105
  children: [
4926
- /* @__PURE__ */ jsxDEV4(Text4, {
5106
+ /* @__PURE__ */ jsxDEV5(Text5, {
4927
5107
  children: [
4928
5108
  chalk3.bold("Step 1/4"),
4929
5109
  " — Default model (both slots)"
4930
5110
  ]
4931
5111
  }, undefined, true, undefined, this),
4932
- /* @__PURE__ */ jsxDEV4(Text4, {
5112
+ /* @__PURE__ */ jsxDEV5(Text5, {
4933
5113
  dimColor: true,
4934
5114
  children: [
4935
5115
  "e.g. ",
4936
- /* @__PURE__ */ jsxDEV4(Text4, {
5116
+ /* @__PURE__ */ jsxDEV5(Text5, {
4937
5117
  color: "cyan",
4938
5118
  children: [
4939
5119
  provider,
@@ -4941,13 +5121,13 @@ function ModelApp2({
4941
5121
  ]
4942
5122
  }, undefined, true, undefined, this),
4943
5123
  "model-name — fine-tune later with ",
4944
- /* @__PURE__ */ jsxDEV4(Text4, {
5124
+ /* @__PURE__ */ jsxDEV5(Text5, {
4945
5125
  color: "cyan",
4946
5126
  children: "brainbox model"
4947
5127
  }, undefined, false, undefined, this)
4948
5128
  ]
4949
5129
  }, undefined, true, undefined, this),
4950
- /* @__PURE__ */ jsxDEV4(TextInput, {
5130
+ /* @__PURE__ */ jsxDEV5(TextInput, {
4951
5131
  prompt: `${provider}/model> `,
4952
5132
  onSubmit: (raw) => {
4953
5133
  const value = raw.trim();
@@ -4965,7 +5145,7 @@ function ModelApp2({
4965
5145
  onDone();
4966
5146
  }
4967
5147
  }, undefined, false, undefined, this),
4968
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5148
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
4969
5149
  color: "red",
4970
5150
  children: error
4971
5151
  }, undefined, false, undefined, this)
@@ -4975,21 +5155,21 @@ function ModelApp2({
4975
5155
  function SuperMemoryApp({
4976
5156
  onDone
4977
5157
  }) {
4978
- const [error, setError] = useState4(null);
4979
- return /* @__PURE__ */ jsxDEV4(Box3, {
5158
+ const [error, setError] = useState5(null);
5159
+ return /* @__PURE__ */ jsxDEV5(Box4, {
4980
5160
  flexDirection: "column",
4981
5161
  children: [
4982
- /* @__PURE__ */ jsxDEV4(Text4, {
5162
+ /* @__PURE__ */ jsxDEV5(Text5, {
4983
5163
  children: [
4984
5164
  chalk3.bold("Step 2/4"),
4985
5165
  " — Supermemory API key"
4986
5166
  ]
4987
5167
  }, undefined, true, undefined, this),
4988
- /* @__PURE__ */ jsxDEV4(Text4, {
5168
+ /* @__PURE__ */ jsxDEV5(Text5, {
4989
5169
  dimColor: true,
4990
5170
  children: "powers each brain's long-term memory. Blank reuses $SUPERMEMORY_API_KEY from env."
4991
5171
  }, undefined, false, undefined, this),
4992
- /* @__PURE__ */ jsxDEV4(TextInput, {
5172
+ /* @__PURE__ */ jsxDEV5(TextInput, {
4993
5173
  prompt: "supermemory apiKey> ",
4994
5174
  onSubmit: (raw) => {
4995
5175
  const key = raw.trim() || (process.env["SUPERMEMORY_API_KEY"] ?? "");
@@ -5002,7 +5182,7 @@ function SuperMemoryApp({
5002
5182
  onDone();
5003
5183
  }
5004
5184
  }, undefined, false, undefined, this),
5005
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5185
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
5006
5186
  color: "red",
5007
5187
  children: error
5008
5188
  }, undefined, false, undefined, this)
@@ -5012,23 +5192,23 @@ function SuperMemoryApp({
5012
5192
  function BrainApp({
5013
5193
  onDone
5014
5194
  }) {
5015
- const [stage, setStage] = useState4({ kind: "name" });
5016
- const [error, setError] = useState4(null);
5195
+ const [stage, setStage] = useState5({ kind: "name" });
5196
+ const [error, setError] = useState5(null);
5017
5197
  if (stage.kind === "name") {
5018
- return /* @__PURE__ */ jsxDEV4(Box3, {
5198
+ return /* @__PURE__ */ jsxDEV5(Box4, {
5019
5199
  flexDirection: "column",
5020
5200
  children: [
5021
- /* @__PURE__ */ jsxDEV4(Text4, {
5201
+ /* @__PURE__ */ jsxDEV5(Text5, {
5022
5202
  children: [
5023
5203
  chalk3.bold("Step 3/4"),
5024
5204
  " — Brain name"
5025
5205
  ]
5026
5206
  }, undefined, true, undefined, this),
5027
- /* @__PURE__ */ jsxDEV4(Text4, {
5207
+ /* @__PURE__ */ jsxDEV5(Text5, {
5028
5208
  dimColor: true,
5029
5209
  children: "The display name your channel will see"
5030
5210
  }, undefined, false, undefined, this),
5031
- /* @__PURE__ */ jsxDEV4(TextInput, {
5211
+ /* @__PURE__ */ jsxDEV5(TextInput, {
5032
5212
  prompt: "name> ",
5033
5213
  onSubmit: (raw) => {
5034
5214
  const v = raw.trim();
@@ -5040,32 +5220,32 @@ function BrainApp({
5040
5220
  setStage({ kind: "seed", displayName: v });
5041
5221
  }
5042
5222
  }, undefined, false, undefined, this),
5043
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5223
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
5044
5224
  color: "red",
5045
5225
  children: error
5046
5226
  }, undefined, false, undefined, this)
5047
5227
  ]
5048
5228
  }, undefined, true, undefined, this);
5049
5229
  }
5050
- return /* @__PURE__ */ jsxDEV4(Box3, {
5230
+ return /* @__PURE__ */ jsxDEV5(Box4, {
5051
5231
  flexDirection: "column",
5052
5232
  children: [
5053
- /* @__PURE__ */ jsxDEV4(Text4, {
5233
+ /* @__PURE__ */ jsxDEV5(Text5, {
5054
5234
  children: [
5055
5235
  chalk3.bold("Step 3/4"),
5056
5236
  " — Seed for",
5057
5237
  " ",
5058
- /* @__PURE__ */ jsxDEV4(Text4, {
5238
+ /* @__PURE__ */ jsxDEV5(Text5, {
5059
5239
  color: "cyan",
5060
5240
  children: stage.displayName
5061
5241
  }, undefined, false, undefined, this)
5062
5242
  ]
5063
5243
  }, undefined, true, undefined, this),
5064
- /* @__PURE__ */ jsxDEV4(Text4, {
5244
+ /* @__PURE__ */ jsxDEV5(Text5, {
5065
5245
  dimColor: true,
5066
5246
  children: "One sentence about who they are. The model will expand it."
5067
5247
  }, undefined, false, undefined, this),
5068
- /* @__PURE__ */ jsxDEV4(TextInput, {
5248
+ /* @__PURE__ */ jsxDEV5(TextInput, {
5069
5249
  prompt: "seed> ",
5070
5250
  onSubmit: async (raw) => {
5071
5251
  const seed = raw.trim();
@@ -5087,7 +5267,7 @@ function BrainApp({
5087
5267
  onDone({ brainId: result.brainId, displayName: stage.displayName });
5088
5268
  }
5089
5269
  }, undefined, false, undefined, this),
5090
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5270
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
5091
5271
  color: "red",
5092
5272
  children: error
5093
5273
  }, undefined, false, undefined, this)
@@ -5099,45 +5279,41 @@ function ChannelApp({
5099
5279
  displayName,
5100
5280
  onDone
5101
5281
  }) {
5102
- const [stage, setStage] = useState4({ kind: "kind" });
5103
- const [error, setError] = useState4(null);
5282
+ const [stage, setStage] = useState5({ kind: "kind" });
5283
+ const [error, setError] = useState5(null);
5104
5284
  if (stage.kind === "kind") {
5105
- return /* @__PURE__ */ jsxDEV4(Box3, {
5285
+ return /* @__PURE__ */ jsxDEV5(Box4, {
5106
5286
  flexDirection: "column",
5107
5287
  children: [
5108
- /* @__PURE__ */ jsxDEV4(Text4, {
5288
+ /* @__PURE__ */ jsxDEV5(Text5, {
5109
5289
  children: [
5110
5290
  chalk3.bold("Step 4/4"),
5111
5291
  " — Channel for",
5112
5292
  " ",
5113
- /* @__PURE__ */ jsxDEV4(Text4, {
5293
+ /* @__PURE__ */ jsxDEV5(Text5, {
5114
5294
  color: "cyan",
5115
5295
  children: displayName
5116
5296
  }, undefined, false, undefined, this)
5117
5297
  ]
5118
5298
  }, undefined, true, undefined, this),
5119
- /* @__PURE__ */ jsxDEV4(Text4, {
5299
+ /* @__PURE__ */ jsxDEV5(Text5, {
5120
5300
  dimColor: true,
5121
- children: "discord | telegram | skip"
5301
+ children: "↑↓ to move, type to filter, enter to select"
5122
5302
  }, undefined, false, undefined, this),
5123
- /* @__PURE__ */ jsxDEV4(TextInput, {
5303
+ /* @__PURE__ */ jsxDEV5(Select, {
5124
5304
  prompt: "channel> ",
5125
- onSubmit: (raw) => {
5126
- const v = raw.trim().toLowerCase();
5305
+ items: ["discord", "telegram", "skip"],
5306
+ onSelect: (v) => {
5127
5307
  if (v === "skip") {
5128
5308
  logger.info("Skipped channel setup.");
5129
5309
  onDone();
5130
5310
  return;
5131
5311
  }
5132
- if (v !== "discord" && v !== "telegram") {
5133
- setError(`Expected "discord", "telegram", or "skip"`);
5134
- return;
5135
- }
5136
5312
  setError(null);
5137
5313
  setStage({ kind: "token", kind_: v });
5138
5314
  }
5139
5315
  }, undefined, false, undefined, this),
5140
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5316
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
5141
5317
  color: "red",
5142
5318
  children: error
5143
5319
  }, undefined, false, undefined, this)
@@ -5145,10 +5321,10 @@ function ChannelApp({
5145
5321
  }, undefined, true, undefined, this);
5146
5322
  }
5147
5323
  if (stage.kind === "token") {
5148
- return /* @__PURE__ */ jsxDEV4(Box3, {
5324
+ return /* @__PURE__ */ jsxDEV5(Box4, {
5149
5325
  flexDirection: "column",
5150
5326
  children: [
5151
- /* @__PURE__ */ jsxDEV4(Text4, {
5327
+ /* @__PURE__ */ jsxDEV5(Text5, {
5152
5328
  children: [
5153
5329
  chalk3.bold("Step 4/4"),
5154
5330
  " — ",
@@ -5156,7 +5332,7 @@ function ChannelApp({
5156
5332
  " bot token"
5157
5333
  ]
5158
5334
  }, undefined, true, undefined, this),
5159
- /* @__PURE__ */ jsxDEV4(TextInput, {
5335
+ /* @__PURE__ */ jsxDEV5(TextInput, {
5160
5336
  prompt: "token> ",
5161
5337
  onSubmit: (raw) => {
5162
5338
  const token = raw.trim();
@@ -5168,17 +5344,17 @@ function ChannelApp({
5168
5344
  setStage({ kind: "target", kind_: stage.kind_, token });
5169
5345
  }
5170
5346
  }, undefined, false, undefined, this),
5171
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5347
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
5172
5348
  color: "red",
5173
5349
  children: error
5174
5350
  }, undefined, false, undefined, this)
5175
5351
  ]
5176
5352
  }, undefined, true, undefined, this);
5177
5353
  }
5178
- return /* @__PURE__ */ jsxDEV4(Box3, {
5354
+ return /* @__PURE__ */ jsxDEV5(Box4, {
5179
5355
  flexDirection: "column",
5180
5356
  children: [
5181
- /* @__PURE__ */ jsxDEV4(Text4, {
5357
+ /* @__PURE__ */ jsxDEV5(Text5, {
5182
5358
  children: [
5183
5359
  chalk3.bold("Step 4/4"),
5184
5360
  " — Optional",
@@ -5187,7 +5363,7 @@ function ChannelApp({
5187
5363
  " (blank = pair later)"
5188
5364
  ]
5189
5365
  }, undefined, true, undefined, this),
5190
- /* @__PURE__ */ jsxDEV4(TextInput, {
5366
+ /* @__PURE__ */ jsxDEV5(TextInput, {
5191
5367
  prompt: `${stage.kind_ === "discord" ? "channelId" : "chatId"}> `,
5192
5368
  onSubmit: async (raw) => {
5193
5369
  const target = raw.trim();
@@ -5222,7 +5398,7 @@ function ChannelApp({
5222
5398
  onDone();
5223
5399
  }
5224
5400
  }, undefined, false, undefined, this),
5225
- error && /* @__PURE__ */ jsxDEV4(Text4, {
5401
+ error && /* @__PURE__ */ jsxDEV5(Text5, {
5226
5402
  color: "red",
5227
5403
  children: error
5228
5404
  }, undefined, false, undefined, this)
@@ -5233,25 +5409,25 @@ async function runOnboard() {
5233
5409
  logger.info(`Welcome — let's get ${chalk3.bold("brainbox")} ready.`);
5234
5410
  const providers = listProviderNames().slice().sort();
5235
5411
  const { promise, resolve: resolve2 } = Promise.withResolvers();
5236
- let active = render3(/* @__PURE__ */ jsxDEV4(ProviderApp, {
5412
+ let active = render3(/* @__PURE__ */ jsxDEV5(ProviderApp, {
5237
5413
  providers,
5238
5414
  onDone: (p) => {
5239
5415
  active.unmount();
5240
- active = render3(/* @__PURE__ */ jsxDEV4(ModelApp2, {
5416
+ active = render3(/* @__PURE__ */ jsxDEV5(ModelApp2, {
5241
5417
  provider: p.provider,
5242
5418
  onDone: () => {
5243
5419
  active.unmount();
5244
- active = render3(/* @__PURE__ */ jsxDEV4(SuperMemoryApp, {
5420
+ active = render3(/* @__PURE__ */ jsxDEV5(SuperMemoryApp, {
5245
5421
  onDone: () => {
5246
5422
  active.unmount();
5247
- active = render3(/* @__PURE__ */ jsxDEV4(BrainApp, {
5423
+ active = render3(/* @__PURE__ */ jsxDEV5(BrainApp, {
5248
5424
  onDone: (b) => {
5249
5425
  active.unmount();
5250
5426
  if (!b.brainId) {
5251
5427
  resolve2();
5252
5428
  return;
5253
5429
  }
5254
- active = render3(/* @__PURE__ */ jsxDEV4(ChannelApp, {
5430
+ active = render3(/* @__PURE__ */ jsxDEV5(ChannelApp, {
5255
5431
  brainId: b.brainId,
5256
5432
  displayName: b.displayName,
5257
5433
  onDone: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p-sw/brainbox",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-alpha.1",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "cli": "bun run src/index.ts",
12
12
  "format": "bun run prettier 'src/**/*.ts' -w",
13
13
  "build": "rm -rf dist && bun build ./src/index.ts --outdir dist --target node --packages external && cp -r prompts dist/prompts && chmod +x dist/index.js",
14
- "publish": "bun run scripts/publish.ts"
14
+ "prepack": "bun run build"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/node": "^25.9.1"
@@ -34,6 +34,9 @@
34
34
  "yaml": "^2.9.0",
35
35
  "zod": "^4.4.3"
36
36
  },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
37
40
  "author": {
38
41
  "name": "Shinwoo PARK",
39
42
  "email": "shinwoo.park@psw.kr",