agents-inc 0.167.0 → 0.170.0

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 (200) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +18 -15
  3. package/dist/{chunk-ZR4YPKXQ.js → chunk-3G7X2WKI.js} +4 -4
  4. package/dist/{chunk-JOEA52NR.js → chunk-44TE3RKH.js} +46 -2
  5. package/dist/chunk-44TE3RKH.js.map +1 -0
  6. package/dist/{chunk-V5WXIM2F.js → chunk-52HDHJ7I.js} +11 -19
  7. package/dist/chunk-52HDHJ7I.js.map +1 -0
  8. package/dist/{chunk-V3I7VQ7N.js → chunk-6HNXYYVF.js} +39 -22
  9. package/dist/chunk-6HNXYYVF.js.map +1 -0
  10. package/dist/{chunk-MAWNVT2C.js → chunk-6ZRH5RHC.js} +10 -11
  11. package/dist/chunk-6ZRH5RHC.js.map +1 -0
  12. package/dist/{chunk-G6UREQ4V.js → chunk-7RDMTR64.js} +14 -34
  13. package/dist/chunk-7RDMTR64.js.map +1 -0
  14. package/dist/{chunk-GE3WKJ6Q.js → chunk-BMRUNMPV.js} +4 -4
  15. package/dist/{chunk-VAPTVR3J.js → chunk-CLPUWOSA.js} +4 -4
  16. package/dist/{chunk-VAPTVR3J.js.map → chunk-CLPUWOSA.js.map} +1 -1
  17. package/dist/{chunk-HWEKHVLE.js → chunk-F2BHT5C4.js} +9 -7
  18. package/dist/chunk-F2BHT5C4.js.map +1 -0
  19. package/dist/{chunk-ZXKBERQU.js → chunk-F5EBEATU.js} +2 -2
  20. package/dist/{chunk-PMJWD27C.js → chunk-HED2DAXZ.js} +3 -3
  21. package/dist/{chunk-SAYZWCH6.js → chunk-KOLDW6SF.js} +3 -3
  22. package/dist/{chunk-SAYZWCH6.js.map → chunk-KOLDW6SF.js.map} +1 -1
  23. package/dist/{chunk-A4KDXNOT.js → chunk-MQ6CGZNJ.js} +171 -522
  24. package/dist/chunk-MQ6CGZNJ.js.map +1 -0
  25. package/dist/{chunk-G4JK7WVO.js → chunk-NCWDK6L7.js} +115 -196
  26. package/dist/chunk-NCWDK6L7.js.map +1 -0
  27. package/dist/{chunk-VRXX4D6K.js → chunk-NEZ4OAOL.js} +1 -1
  28. package/dist/chunk-NEZ4OAOL.js.map +1 -0
  29. package/dist/chunk-NIHUOWE4.js +106 -0
  30. package/dist/chunk-NIHUOWE4.js.map +1 -0
  31. package/dist/{chunk-OI2H6M5I.js → chunk-NQW25DCF.js} +2 -2
  32. package/dist/chunk-NQW25DCF.js.map +1 -0
  33. package/dist/{chunk-25MPBIK3.js → chunk-OYJQUA3D.js} +3 -3
  34. package/dist/{chunk-25MPBIK3.js.map → chunk-OYJQUA3D.js.map} +1 -1
  35. package/dist/{chunk-ENGYJCTF.js → chunk-PJWGTNOX.js} +220 -254
  36. package/dist/chunk-PJWGTNOX.js.map +1 -0
  37. package/dist/{chunk-NBXXFIIW.js → chunk-RIPSGNLU.js} +3 -3
  38. package/dist/chunk-RIPSGNLU.js.map +1 -0
  39. package/dist/{chunk-Y47EV74W.js → chunk-SZYQISA2.js} +10 -13
  40. package/dist/chunk-SZYQISA2.js.map +1 -0
  41. package/dist/{chunk-TODCQFRB.js → chunk-USVBYQSQ.js} +2 -2
  42. package/dist/{chunk-Y3VIRVVE.js → chunk-V3KTSP3Q.js} +50 -42
  43. package/dist/chunk-V3KTSP3Q.js.map +1 -0
  44. package/dist/{chunk-PXWG7KFO.js → chunk-WTWMGH2C.js} +2 -2
  45. package/dist/commands/build/marketplace.js +23 -22
  46. package/dist/commands/build/marketplace.js.map +1 -1
  47. package/dist/commands/build/plugins.js +8 -9
  48. package/dist/commands/build/plugins.js.map +1 -1
  49. package/dist/commands/compile.js +19 -20
  50. package/dist/commands/compile.js.map +1 -1
  51. package/dist/commands/doctor.js +17 -18
  52. package/dist/commands/doctor.js.map +1 -1
  53. package/dist/commands/edit.js +138 -488
  54. package/dist/commands/edit.js.map +1 -1
  55. package/dist/commands/eject.js +21 -33
  56. package/dist/commands/eject.js.map +1 -1
  57. package/dist/commands/init.js +17 -45
  58. package/dist/commands/list.js +19 -17
  59. package/dist/commands/list.js.map +1 -1
  60. package/dist/commands/new/marketplace.js +11 -11
  61. package/dist/commands/new/marketplace.js.map +1 -1
  62. package/dist/commands/search.js +12 -13
  63. package/dist/commands/search.js.map +1 -1
  64. package/dist/commands/share.js +11 -12
  65. package/dist/commands/share.js.map +1 -1
  66. package/dist/commands/uninstall.js +18 -20
  67. package/dist/commands/uninstall.js.map +1 -1
  68. package/dist/commands/update.js +8 -9
  69. package/dist/commands/update.js.map +1 -1
  70. package/dist/components/common/removal-plan-confirm.js +2 -2
  71. package/dist/components/common/scroll-affordance.js +9 -0
  72. package/dist/components/common/select-list.js +2 -3
  73. package/dist/components/common/skill-agent-summary.js +11 -0
  74. package/dist/components/common/spinner.js +1 -1
  75. package/dist/{chunk-2VUYFTUB.js → components/common/summary-panel.js} +57 -31
  76. package/dist/components/common/summary-panel.js.map +1 -0
  77. package/dist/config-exports.js +1 -1
  78. package/dist/hooks/init.js +18 -46
  79. package/dist/hooks/init.js.map +1 -1
  80. package/dist/load-agent-defs-YMDWBFDP.js +14 -0
  81. package/dist/recompile-project-agents-SZ76WNTW.js +18 -0
  82. package/dist/{source-loader-7KZ3MD5O.js → source-loader-C5SQXZXI.js} +5 -5
  83. package/dist/src/agents/meta/codex-keeper/playbook.md +2 -3
  84. package/package.json +6 -4
  85. package/src/agents/meta/codex-keeper/playbook.md +2 -3
  86. package/src/schemas/project-config.schema.json +1 -1
  87. package/assets/demo.tape +0 -266
  88. package/dist/chunk-2VUYFTUB.js.map +0 -1
  89. package/dist/chunk-4NDBUJHK.js +0 -237
  90. package/dist/chunk-4NDBUJHK.js.map +0 -1
  91. package/dist/chunk-6L75SQZU.js +0 -168
  92. package/dist/chunk-6L75SQZU.js.map +0 -1
  93. package/dist/chunk-6LF4CQBY.js +0 -51
  94. package/dist/chunk-6LF4CQBY.js.map +0 -1
  95. package/dist/chunk-7JNJ52CD.js +0 -1179
  96. package/dist/chunk-7JNJ52CD.js.map +0 -1
  97. package/dist/chunk-A4KDXNOT.js.map +0 -1
  98. package/dist/chunk-DAIEQJIF.js +0 -48
  99. package/dist/chunk-DAIEQJIF.js.map +0 -1
  100. package/dist/chunk-ENGYJCTF.js.map +0 -1
  101. package/dist/chunk-G4JK7WVO.js.map +0 -1
  102. package/dist/chunk-G6UREQ4V.js.map +0 -1
  103. package/dist/chunk-HHIYT3PI.js +0 -53
  104. package/dist/chunk-HHIYT3PI.js.map +0 -1
  105. package/dist/chunk-HWEKHVLE.js.map +0 -1
  106. package/dist/chunk-JOEA52NR.js.map +0 -1
  107. package/dist/chunk-JQRJQ4SS.js +0 -118
  108. package/dist/chunk-JQRJQ4SS.js.map +0 -1
  109. package/dist/chunk-LFWLEDUG.js +0 -59
  110. package/dist/chunk-LFWLEDUG.js.map +0 -1
  111. package/dist/chunk-MAWNVT2C.js.map +0 -1
  112. package/dist/chunk-MPTNC32T.js +0 -92
  113. package/dist/chunk-MPTNC32T.js.map +0 -1
  114. package/dist/chunk-NBXXFIIW.js.map +0 -1
  115. package/dist/chunk-OI2H6M5I.js.map +0 -1
  116. package/dist/chunk-PNB3524H.js +0 -197
  117. package/dist/chunk-PNB3524H.js.map +0 -1
  118. package/dist/chunk-QHDPLLK6.js +0 -35
  119. package/dist/chunk-QHDPLLK6.js.map +0 -1
  120. package/dist/chunk-RAHSOJQ2.js +0 -25
  121. package/dist/chunk-RAHSOJQ2.js.map +0 -1
  122. package/dist/chunk-RZDXDMT6.js +0 -23
  123. package/dist/chunk-RZDXDMT6.js.map +0 -1
  124. package/dist/chunk-SCOQ34YM.js +0 -17
  125. package/dist/chunk-SCOQ34YM.js.map +0 -1
  126. package/dist/chunk-SXVHSOTH.js +0 -268
  127. package/dist/chunk-SXVHSOTH.js.map +0 -1
  128. package/dist/chunk-T6UWJAB3.js +0 -28
  129. package/dist/chunk-T6UWJAB3.js.map +0 -1
  130. package/dist/chunk-TSIU7DME.js +0 -43
  131. package/dist/chunk-TSIU7DME.js.map +0 -1
  132. package/dist/chunk-TTY6DPJN.js +0 -27
  133. package/dist/chunk-TTY6DPJN.js.map +0 -1
  134. package/dist/chunk-TZ2YJJKK.js +0 -292
  135. package/dist/chunk-TZ2YJJKK.js.map +0 -1
  136. package/dist/chunk-V3I7VQ7N.js.map +0 -1
  137. package/dist/chunk-V5WXIM2F.js.map +0 -1
  138. package/dist/chunk-VRXX4D6K.js.map +0 -1
  139. package/dist/chunk-WTJ3AY33.js +0 -31
  140. package/dist/chunk-WTJ3AY33.js.map +0 -1
  141. package/dist/chunk-WVUDLKIO.js +0 -121
  142. package/dist/chunk-WVUDLKIO.js.map +0 -1
  143. package/dist/chunk-WWIFNPJG.js +0 -317
  144. package/dist/chunk-WWIFNPJG.js.map +0 -1
  145. package/dist/chunk-XQHZPINL.js +0 -89
  146. package/dist/chunk-XQHZPINL.js.map +0 -1
  147. package/dist/chunk-XZEVWPX6.js +0 -230
  148. package/dist/chunk-XZEVWPX6.js.map +0 -1
  149. package/dist/chunk-Y3VIRVVE.js.map +0 -1
  150. package/dist/chunk-Y47EV74W.js.map +0 -1
  151. package/dist/components/wizard/category-grid.js +0 -13
  152. package/dist/components/wizard/checkbox-grid.js +0 -12
  153. package/dist/components/wizard/domain-selection.js +0 -18
  154. package/dist/components/wizard/run-wizard-session.js +0 -40
  155. package/dist/components/wizard/run-wizard-session.js.map +0 -1
  156. package/dist/components/wizard/scroll-affordance.js +0 -9
  157. package/dist/components/wizard/skill-agent-summary.js +0 -13
  158. package/dist/components/wizard/source-grid.js +0 -16
  159. package/dist/components/wizard/source-grid.js.map +0 -1
  160. package/dist/components/wizard/stack-selection.js +0 -17
  161. package/dist/components/wizard/stack-selection.js.map +0 -1
  162. package/dist/components/wizard/step-agents.js +0 -18
  163. package/dist/components/wizard/step-agents.js.map +0 -1
  164. package/dist/components/wizard/step-build.js +0 -18
  165. package/dist/components/wizard/step-build.js.map +0 -1
  166. package/dist/components/wizard/step-confirm.js +0 -18
  167. package/dist/components/wizard/step-confirm.js.map +0 -1
  168. package/dist/components/wizard/step-sources.js +0 -19
  169. package/dist/components/wizard/step-sources.js.map +0 -1
  170. package/dist/components/wizard/step-stack.js +0 -18
  171. package/dist/components/wizard/step-stack.js.map +0 -1
  172. package/dist/components/wizard/summary-panel.js +0 -17
  173. package/dist/components/wizard/summary-panel.js.map +0 -1
  174. package/dist/components/wizard/toast.js +0 -9
  175. package/dist/components/wizard/toast.js.map +0 -1
  176. package/dist/components/wizard/wizard-layout.js +0 -22
  177. package/dist/components/wizard/wizard-layout.js.map +0 -1
  178. package/dist/components/wizard/wizard-tabs.js +0 -11
  179. package/dist/components/wizard/wizard-tabs.js.map +0 -1
  180. package/dist/components/wizard/wizard.js +0 -39
  181. package/dist/components/wizard/wizard.js.map +0 -1
  182. package/dist/load-agent-defs-3C27ENC7.js +0 -14
  183. package/dist/load-agent-defs-3C27ENC7.js.map +0 -1
  184. package/dist/recompile-project-agents-DGNBCU3N.js +0 -18
  185. package/dist/recompile-project-agents-DGNBCU3N.js.map +0 -1
  186. package/dist/source-loader-7KZ3MD5O.js.map +0 -1
  187. package/dist/stores/wizard-store.js +0 -24
  188. package/dist/stores/wizard-store.js.map +0 -1
  189. /package/assets/{demo.gif → legacy-wizard.gif} +0 -0
  190. /package/dist/{chunk-ZR4YPKXQ.js.map → chunk-3G7X2WKI.js.map} +0 -0
  191. /package/dist/{chunk-GE3WKJ6Q.js.map → chunk-BMRUNMPV.js.map} +0 -0
  192. /package/dist/{chunk-ZXKBERQU.js.map → chunk-F5EBEATU.js.map} +0 -0
  193. /package/dist/{chunk-PMJWD27C.js.map → chunk-HED2DAXZ.js.map} +0 -0
  194. /package/dist/{chunk-TODCQFRB.js.map → chunk-USVBYQSQ.js.map} +0 -0
  195. /package/dist/{chunk-PXWG7KFO.js.map → chunk-WTWMGH2C.js.map} +0 -0
  196. /package/dist/components/{wizard → common}/scroll-affordance.js.map +0 -0
  197. /package/dist/components/{wizard → common}/skill-agent-summary.js.map +0 -0
  198. /package/dist/{components/wizard/category-grid.js.map → load-agent-defs-YMDWBFDP.js.map} +0 -0
  199. /package/dist/{components/wizard/checkbox-grid.js.map → recompile-project-agents-SZ76WNTW.js.map} +0 -0
  200. /package/dist/{components/wizard/domain-selection.js.map → source-loader-C5SQXZXI.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/components/common/spinner.tsx"],"sourcesContent":["import React from \"react\";\nimport { Text, type Instance } from \"ink\";\nimport { Spinner as InkSpinner } from \"@inkjs/ui\";\nimport { render } from \"../render.js\";\n\ntype SpinnerProps = {\n label: string;\n};\n\nexport const Spinner: React.FC<SpinnerProps> = ({ label }) => <InkSpinner label={label} />;\n\n/**\n * Awaits `load` behind a spinner and takes the spinner down whichever way the await ends, leaving\n * the terminal as it found it — what `init` and `edit` render next is a wizard sized to the\n * terminal's full height, so one line left above it pushes the wizard's top line off the screen.\n *\n * The cleanup is a `finally` because a load that refuses the run throws from inside this await,\n * and oclif would otherwise paint its error under an Ink tree still repainting over it. Never a\n * `catch`: the throw reaches the caller untouched, or both the error rendering and the exit code\n * change with it.\n */\nexport async function awaitUnderSpinner<T>(label: string, load: () => Promise<T>): Promise<T> {\n const spinner = render(<Spinner label={label} />);\n try {\n return await load();\n } finally {\n await takeDownWithoutTrace(spinner, label);\n }\n}\n\n/**\n * Stop the clock, paint what Ink is holding, and only then erase.\n *\n * Ink paints through a render throttle, and a spinner frame that arrives inside its window is\n * held rather than painted. `unmount()` paints whatever is held — so a spinner cleared with a\n * frame held was drawn again after the clear, where nothing erases it. A starved event loop is\n * what puts one there: a spinner tick that runs late is followed by the next one less than a\n * window later. Hence the order: the still line has no clock, so once it replaces the spinner no\n * new frame can be held; the flush paints anything already held; the clear then erases the last\n * thing painted, and `unmount()` finds nothing left to draw.\n */\nasync function takeDownWithoutTrace(spinner: Instance, label: string): Promise<void> {\n spinner.rerender(<Text>{label}</Text>);\n await spinner.waitUntilRenderFlush();\n spinner.clear();\n spinner.unmount();\n}\n"],"mappings":";;;;;;AAAA,OAAkB;AAClB,SAAS,YAA2B;AACpC,SAAS,WAAW,kBAAkB;AAOwB;AAAvD,IAAM,UAAkC,CAAC,EAAE,MAAM,MAAM,oBAAC,cAAW,OAAc;AAYxF,eAAsB,kBAAqB,OAAe,MAAoC;AAC5F,QAAM,UAAU,OAAO,oBAAC,WAAQ,OAAc,CAAE;AAChD,MAAI;AACF,WAAO,MAAM,KAAK;AAAA,EACpB,UAAE;AACA,UAAM,qBAAqB,SAAS,KAAK;AAAA,EAC3C;AACF;AAaA,eAAe,qBAAqB,SAAmB,OAA8B;AACnF,UAAQ,SAAS,oBAAC,QAAM,iBAAM,CAAO;AACrC,QAAM,QAAQ,qBAAqB;AACnC,UAAQ,MAAM;AACd,UAAQ,QAAQ;AAClB;","names":[]}
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/cli/components/wizard/hotkeys.ts
4
- var HOTKEY_INFO = { key: "i", label: "I" };
5
- var HOTKEY_ACCEPT_DEFAULTS = { key: "a", label: "A" };
6
- var HOTKEY_SCOPE = { key: "s", label: "S" };
7
- var HOTKEY_TOGGLE_LABELS = { key: "d", label: "D" };
8
- var KEY_SPACE = " ";
9
- var KEY_LABEL_ENTER = "ENTER";
10
- var KEY_LABEL_ESC = "ESC";
11
- var KEY_LABEL_SPACE = "SPACE";
12
- function isHotkey(input, hotkey) {
13
- return input.toLowerCase() === hotkey.key.toLowerCase();
14
- }
15
- function isInfoPanelAvailable(step) {
16
- return step !== "confirm";
17
- }
18
-
19
- export {
20
- HOTKEY_INFO,
21
- HOTKEY_ACCEPT_DEFAULTS,
22
- HOTKEY_SCOPE,
23
- HOTKEY_TOGGLE_LABELS,
24
- KEY_SPACE,
25
- KEY_LABEL_ENTER,
26
- KEY_LABEL_ESC,
27
- KEY_LABEL_SPACE,
28
- isHotkey,
29
- isInfoPanelAvailable
30
- };
31
- //# sourceMappingURL=chunk-WTJ3AY33.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/components/wizard/hotkeys.ts"],"sourcesContent":["/**\n * Centralized hotkey registry for wizard components.\n *\n * Every character-based hotkey and its display label lives here so that\n * changing a binding updates the key check, the footer hint, and the\n * info panel in one place.\n */\n\nimport type { WizardStep } from \"../../stores/wizard-store.js\";\n\n// ---------------------------------------------------------------------------\n// Global hotkeys (active across multiple wizard steps)\n// ---------------------------------------------------------------------------\n\nexport const HOTKEY_INFO = { key: \"i\", label: \"I\" } as const;\nexport const HOTKEY_ACCEPT_DEFAULTS = { key: \"a\", label: \"A\" } as const;\nexport const HOTKEY_SCOPE = { key: \"s\", label: \"S\" } as const;\n\n// ---------------------------------------------------------------------------\n// Build step hotkeys\n// ---------------------------------------------------------------------------\n\nexport const HOTKEY_TOGGLE_LABELS = { key: \"d\", label: \"D\" } as const;\n\n// ---------------------------------------------------------------------------\n// Sources step hotkeys\n// ---------------------------------------------------------------------------\n\n// None. The step's two bulk install-mode keys — `l` (set all local) and `p` (set\n// all plugin) — are withdrawn. They rewrote `origin` on every active skill config\n// with no scope authority behind them, so from a project edit they reached the\n// inherited global rows the same step renders locked and non-focusable: the bulk\n// key could do what the per-row control provably cannot. Per-row SPACE on the\n// grid cell is the only install-mode surface, and its own inertness on a locked\n// row is the containment.\n\n// ---------------------------------------------------------------------------\n// Common key labels (for structural keys handled via Ink key objects)\n// ---------------------------------------------------------------------------\n\n/** The spacebar input character (Ink delivers a literal space for the space key). */\nexport const KEY_SPACE = \" \";\n\nexport const KEY_LABEL_ENTER = \"ENTER\" as const;\nexport const KEY_LABEL_ESC = \"ESC\" as const;\nexport const KEY_LABEL_SPACE = \"SPACE\" as const;\nexport const KEY_LABEL_DEL = \"DEL\" as const;\nexport const KEY_LABEL_ARROWS_VERT = \"\\u2191/\\u2193\" as const;\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Case-insensitive check for a character hotkey. */\nexport function isHotkey(input: string, hotkey: { key: string }): boolean {\n return input.toLowerCase() === hotkey.key.toLowerCase();\n}\n\n/**\n * Whether `HOTKEY_INFO` does anything on `step` — the single answer both the\n * key handler in `wizard.tsx` and the footer hint in `wizard-layout.tsx` read,\n * so the wizard never advertises a key it ignores.\n *\n * The confirm step is excluded because it already renders the panel the\n * overlay would show, and the overlay REPLACES the step rather than sitting\n * over it: opening it there would unmount the confirm step's `Enter` handler\n * and strand the user on a screen nothing can complete.\n */\nexport function isInfoPanelAvailable(step: WizardStep): boolean {\n return step !== \"confirm\";\n}\n"],"mappings":";;;AAcO,IAAM,cAAc,EAAE,KAAK,KAAK,OAAO,IAAI;AAC3C,IAAM,yBAAyB,EAAE,KAAK,KAAK,OAAO,IAAI;AACtD,IAAM,eAAe,EAAE,KAAK,KAAK,OAAO,IAAI;AAM5C,IAAM,uBAAuB,EAAE,KAAK,KAAK,OAAO,IAAI;AAmBpD,IAAM,YAAY;AAElB,IAAM,kBAAkB;AACxB,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AASxB,SAAS,SAAS,OAAe,QAAkC;AACxE,SAAO,MAAM,YAAY,MAAM,OAAO,IAAI,YAAY;AACxD;AAYO,SAAS,qBAAqB,MAA2B;AAC9D,SAAO,SAAS;AAClB;","names":[]}
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- SCROLL_VIEWPORT
4
- } from "./chunk-ENGYJCTF.js";
5
-
6
- // src/cli/components/hooks/use-section-scroll.ts
7
- import { useCallback, useEffect, useRef, useState } from "react";
8
- import { measureElement } from "ink";
9
- function useSectionScroll({
10
- sectionCount,
11
- focusedIndex,
12
- availableHeight,
13
- minViewportRows = SCROLL_VIEWPORT.MIN_VIEWPORT_ROWS
14
- }) {
15
- const sectionRefs = useRef([]);
16
- const viewportRef = useRef(null);
17
- const contentRef = useRef(null);
18
- const [sectionHeights, setSectionHeights] = useState([]);
19
- const [viewportHeight, setViewportHeight] = useState(0);
20
- const [contentBoxHeight, setContentBoxHeight] = useState(0);
21
- const [focusScrollPx, setFocusScrollPx] = useState(0);
22
- const [overscrollPx, setOverscrollPx] = useState(0);
23
- const setSectionRef = useCallback((index, el) => {
24
- sectionRefs.current[index] = el;
25
- }, []);
26
- const setViewportRef = useCallback((el) => {
27
- viewportRef.current = el;
28
- }, []);
29
- const setContentRef = useCallback((el) => {
30
- contentRef.current = el;
31
- }, []);
32
- useEffect(() => {
33
- setContentBoxHeight(0);
34
- }, [sectionCount]);
35
- useEffect(() => {
36
- const heights = sectionRefs.current.map((el) => {
37
- if (el) {
38
- const { height } = measureElement(el);
39
- return height;
40
- }
41
- return 0;
42
- });
43
- setSectionHeights((prev) => {
44
- if (prev.length === heights.length && prev.every((h, i) => h === heights[i])) {
45
- return prev;
46
- }
47
- return heights;
48
- });
49
- if (viewportRef.current) {
50
- const { height } = measureElement(viewportRef.current);
51
- setViewportHeight((prev) => prev !== height ? height : prev);
52
- }
53
- if (contentRef.current) {
54
- const { height } = measureElement(contentRef.current);
55
- setContentBoxHeight((prev) => height > prev ? height : prev);
56
- }
57
- });
58
- const scrollEnabled = availableHeight > 0 && availableHeight >= minViewportRows;
59
- const contentHeight = contentBoxHeight > 0 ? contentBoxHeight : sectionHeights.reduce((sum, h) => sum + h, 0);
60
- const effectiveViewport = viewportHeight > 0 ? viewportHeight : availableHeight;
61
- const maxScrollPx = scrollEnabled ? Math.max(0, contentHeight - effectiveViewport) : 0;
62
- const maxScrollRef = useRef(0);
63
- maxScrollRef.current = maxScrollPx;
64
- const focusScrollRef = useRef(0);
65
- focusScrollRef.current = focusScrollPx;
66
- useEffect(() => {
67
- if (!scrollEnabled || sectionHeights.length === 0) return;
68
- let topOfFocused = 0;
69
- for (let i = 0; i < focusedIndex; i++) {
70
- topOfFocused += sectionHeights[i] ?? 0;
71
- }
72
- const focusedHeight = sectionHeights[focusedIndex] ?? 0;
73
- const bottomOfFocused = topOfFocused + focusedHeight;
74
- setFocusScrollPx((prev) => {
75
- if (topOfFocused < prev) {
76
- return topOfFocused;
77
- }
78
- if (bottomOfFocused > prev + effectiveViewport) {
79
- return bottomOfFocused - effectiveViewport;
80
- }
81
- return prev;
82
- });
83
- }, [focusedIndex, sectionHeights, scrollEnabled, effectiveViewport]);
84
- useEffect(() => {
85
- setOverscrollPx(0);
86
- }, [focusedIndex]);
87
- const scrollBy = useCallback((deltaRows) => {
88
- setOverscrollPx((prev) => {
89
- const maxOverscroll = Math.max(0, maxScrollRef.current - focusScrollRef.current);
90
- return Math.min(maxOverscroll, Math.max(0, prev + deltaRows));
91
- });
92
- }, []);
93
- const scrollTopPx = Math.min(maxScrollPx, focusScrollPx + overscrollPx);
94
- const hiddenAbove = scrollEnabled ? scrollTopPx : 0;
95
- const hiddenBelow = scrollEnabled ? Math.max(0, maxScrollPx - scrollTopPx) : 0;
96
- return {
97
- setSectionRef,
98
- setViewportRef,
99
- setContentRef,
100
- scrollEnabled,
101
- scrollTopPx,
102
- hiddenAbove,
103
- hiddenBelow,
104
- scrollBy
105
- };
106
- }
107
- function computeRowScrollTop(focusedRow, currentScrollTop, viewportHeight) {
108
- if (focusedRow < currentScrollTop) {
109
- return focusedRow;
110
- }
111
- if (focusedRow + 1 > currentScrollTop + viewportHeight) {
112
- return focusedRow + 1 - viewportHeight;
113
- }
114
- return currentScrollTop;
115
- }
116
-
117
- export {
118
- useSectionScroll,
119
- computeRowScrollTop
120
- };
121
- //# sourceMappingURL=chunk-WVUDLKIO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/components/hooks/use-section-scroll.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { type DOMElement, measureElement } from \"ink\";\nimport { SCROLL_VIEWPORT } from \"../../consts.js\";\n\nexport type UseSectionScrollOptions = {\n sectionCount: number;\n focusedIndex: number;\n availableHeight: number;\n /**\n * Minimum viewport rows before clipping engages (default {@link SCROLL_VIEWPORT.MIN_VIEWPORT_ROWS}).\n * Views that must clip rather than bleed at very short heights (source-grid, which pairs the clip\n * with an overflow affordance) pass a lower value so the gate does not fall back to a bleeding\n * flex layout.\n */\n minViewportRows?: number;\n};\n\nexport type UseSectionScrollResult = {\n setSectionRef: (index: number, el: DOMElement | null) => void;\n /** Attach to the clipping viewport box so overflow counts exclude header/affordance chrome. */\n setViewportRef: (el: DOMElement | null) => void;\n /**\n * Attach to the scrolled content box so overflow counts measure the WHOLE rendered content —\n * section-group margins and labels included — not just the sum of per-section row heights.\n */\n setContentRef: (el: DOMElement | null) => void;\n scrollEnabled: boolean;\n scrollTopPx: number;\n /** Content lines scrolled off the top of the viewport (0 when not scrolling). */\n hiddenAbove: number;\n /** Content lines clipped below the viewport (0 when everything fits). */\n hiddenBelow: number;\n /** Scroll the viewport past the focus-following position to reveal clipped rows (e.g. trailing inert rows). */\n scrollBy: (deltaRows: number) => void;\n};\n\n/**\n * Shared pixel-offset scroll hook for views with variable-height sections.\n *\n * Manages section refs, height measurement, and scroll position to keep the\n * focused section visible within a constrained viewport. Extracted from the\n * identical scroll plumbing in category-grid.tsx and source-grid.tsx.\n *\n * On top of focus-following it exposes an overscroll channel (`scrollBy`) that\n * moves the viewport BEYOND the focused row so rows that can never take focus —\n * trailing inert Sources rows — can still be scrolled into view, plus the\n * `hidden{Above,Below}` counts. Overscroll resets whenever focus moves, so the\n * viewport snaps back to follow focus.\n *\n * The counts are OFFERED, not obligatory. `source-grid.tsx` feeds them to a\n * `ScrollAffordance` sibling; `category-grid.tsx` (the build grid) discards them\n * deliberately — on a grid that dense a half-cut card is self-evidently \"there\n * is more\", so a counted hint would be noise and would cost the viewport a row.\n * A consumer that ignores them is exercising that choice, not overlooking one.\n */\nexport function useSectionScroll({\n sectionCount,\n focusedIndex,\n availableHeight,\n minViewportRows = SCROLL_VIEWPORT.MIN_VIEWPORT_ROWS,\n}: UseSectionScrollOptions): UseSectionScrollResult {\n const sectionRefs = useRef<(DOMElement | null)[]>([]);\n const viewportRef = useRef<DOMElement | null>(null);\n const contentRef = useRef<DOMElement | null>(null);\n const [sectionHeights, setSectionHeights] = useState<number[]>([]);\n const [viewportHeight, setViewportHeight] = useState(0);\n const [contentBoxHeight, setContentBoxHeight] = useState(0);\n const [focusScrollPx, setFocusScrollPx] = useState(0);\n const [overscrollPx, setOverscrollPx] = useState(0);\n\n const setSectionRef = useCallback((index: number, el: DOMElement | null) => {\n sectionRefs.current[index] = el;\n }, []);\n\n const setViewportRef = useCallback((el: DOMElement | null) => {\n viewportRef.current = el;\n }, []);\n\n const setContentRef = useCallback((el: DOMElement | null) => {\n contentRef.current = el;\n }, []);\n\n // A new row set (section count change) invalidates the monotonic content-height reading.\n useEffect(() => {\n setContentBoxHeight(0);\n }, [sectionCount]);\n\n // Measure section, viewport and content heights on every render\n // Ink's measurement idiom: re-measure on every render, no dependency array\n // on purpose. The setState inside is guarded to fire only when the measured\n // height actually changed, so the chain converges instead of looping — a\n // dependency array here would skip re-measures after layout changes React\n // cannot see.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => {\n const heights = sectionRefs.current.map((el) => {\n if (el) {\n const { height } = measureElement(el);\n return height;\n }\n return 0;\n });\n setSectionHeights((prev) => {\n if (prev.length === heights.length && prev.every((h, i) => h === heights[i])) {\n return prev;\n }\n return heights;\n });\n if (viewportRef.current) {\n const { height } = measureElement(viewportRef.current);\n setViewportHeight((prev) => (prev !== height ? height : prev));\n }\n if (contentRef.current) {\n const { height } = measureElement(contentRef.current);\n // Yoga under-reports a wrapped/clipped subtree in some layout passes, so the tallest reading\n // is the trustworthy one — mirrors info-panel/step-confirm. Reset above on row-set change.\n setContentBoxHeight((prev) => (height > prev ? height : prev));\n }\n });\n\n const scrollEnabled = availableHeight > 0 && availableHeight >= minViewportRows;\n\n // The measured content box includes section-group margins and labels; the per-section sum omits\n // them, so it is only the fallback for consumers that do not attach a content ref (category-grid).\n const contentHeight =\n contentBoxHeight > 0 ? contentBoxHeight : sectionHeights.reduce((sum, h) => sum + h, 0);\n // The measured viewport box excludes the header and affordance rows (both\n // siblings of it), so it is the height the sections actually get. Before the\n // first measurement, fall back to availableHeight (which category-grid always\n // uses — it has no separate header outside the viewport).\n const effectiveViewport = viewportHeight > 0 ? viewportHeight : availableHeight;\n const maxScrollPx = scrollEnabled ? Math.max(0, contentHeight - effectiveViewport) : 0;\n\n // Mirror the latest values into refs so `scrollBy` can clamp against them while\n // staying a stable callback (no re-created handler per render).\n const maxScrollRef = useRef(0);\n maxScrollRef.current = maxScrollPx;\n const focusScrollRef = useRef(0);\n focusScrollRef.current = focusScrollPx;\n\n // Keep focused section visible\n useEffect(() => {\n if (!scrollEnabled || sectionHeights.length === 0) return;\n\n let topOfFocused = 0;\n for (let i = 0; i < focusedIndex; i++) {\n topOfFocused += sectionHeights[i] ?? 0;\n }\n const focusedHeight = sectionHeights[focusedIndex] ?? 0;\n const bottomOfFocused = topOfFocused + focusedHeight;\n\n setFocusScrollPx((prev) => {\n if (topOfFocused < prev) {\n return topOfFocused;\n }\n if (bottomOfFocused > prev + effectiveViewport) {\n return bottomOfFocused - effectiveViewport;\n }\n return prev;\n });\n }, [focusedIndex, sectionHeights, scrollEnabled, effectiveViewport]);\n\n // Overscroll is user travel beyond the focus-following position. It resets on\n // focus movement so the viewport tracks the focused row again.\n useEffect(() => {\n setOverscrollPx(0);\n }, [focusedIndex]);\n\n const scrollBy = useCallback((deltaRows: number) => {\n setOverscrollPx((prev) => {\n const maxOverscroll = Math.max(0, maxScrollRef.current - focusScrollRef.current);\n return Math.min(maxOverscroll, Math.max(0, prev + deltaRows));\n });\n }, []);\n\n const scrollTopPx = Math.min(maxScrollPx, focusScrollPx + overscrollPx);\n const hiddenAbove = scrollEnabled ? scrollTopPx : 0;\n const hiddenBelow = scrollEnabled ? Math.max(0, maxScrollPx - scrollTopPx) : 0;\n\n return {\n setSectionRef,\n setViewportRef,\n setContentRef,\n scrollEnabled,\n scrollTopPx,\n hiddenAbove,\n hiddenBelow,\n scrollBy,\n };\n}\n\n/**\n * Pure function for row-based scroll offset computation.\n *\n * For views with uniform 1-line rows (step-agents, checkbox-grid),\n * computes the scroll offset (in rows) to keep `focusedRow` visible within\n * a viewport of `viewportHeight` rows.\n */\nexport function computeRowScrollTop(\n focusedRow: number,\n currentScrollTop: number,\n viewportHeight: number,\n): number {\n if (focusedRow < currentScrollTop) {\n return focusedRow;\n }\n if (focusedRow + 1 > currentScrollTop + viewportHeight) {\n return focusedRow + 1 - viewportHeight;\n }\n return currentScrollTop;\n}\n"],"mappings":";;;;;;AAAA,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AACzD,SAA0B,sBAAsB;AAsDzC,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB,gBAAgB;AACpC,GAAoD;AAClD,QAAM,cAAc,OAA8B,CAAC,CAAC;AACpD,QAAM,cAAc,OAA0B,IAAI;AAClD,QAAM,aAAa,OAA0B,IAAI;AACjD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAmB,CAAC,CAAC;AACjE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,CAAC;AACtD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,CAAC;AAC1D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC;AACpD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAElD,QAAM,gBAAgB,YAAY,CAAC,OAAe,OAA0B;AAC1E,gBAAY,QAAQ,KAAK,IAAI;AAAA,EAC/B,GAAG,CAAC,CAAC;AAEL,QAAM,iBAAiB,YAAY,CAAC,OAA0B;AAC5D,gBAAY,UAAU;AAAA,EACxB,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,YAAY,CAAC,OAA0B;AAC3D,eAAW,UAAU;AAAA,EACvB,GAAG,CAAC,CAAC;AAGL,YAAU,MAAM;AACd,wBAAoB,CAAC;AAAA,EACvB,GAAG,CAAC,YAAY,CAAC;AASjB,YAAU,MAAM;AACd,UAAM,UAAU,YAAY,QAAQ,IAAI,CAA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A,MACT;AACA,UAAI,kBAAkB,OAAO,mBAAmB;AAC9C,eAAO,kBAAkB;AAAA,MAC3B;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,gBAAgB,eAAe,iBAAiB,CAAC;AAInE,YAAU,MAAM;AACd,oBAAgB,CAAC;AAAA,EACnB,GAAG,CAAC,YAAY,CAAC;AAEjB,QAAM,WAAW,YAAY,CAAC,cAAsB;AAClD,oBAAgB,CAAC,SAAS;AACxB,YAAM,gBAAgB,KAAK,IAAI,GAAG,aAAa,UAAU,eAAe,OAAO;AAC/E,aAAO,KAAK,IAAI,eAAe,KAAK,IAAI,GAAG,OAAO,SAAS,CAAC;AAAA,IAC9D,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,cAAc,KAAK,IAAI,aAAa,gBAAgB,YAAY;AACtE,QAAM,cAAc,gBAAgB,cAAc;AAClD,QAAM,cAAc,gBAAgB,KAAK,IAAI,GAAG,cAAc,WAAW,IAAI;AAE7E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AASO,SAAS,oBACd,YACA,kBACA,gBACQ;AACR,MAAI,aAAa,kBAAkB;AACjC,WAAO;AAAA,EACT;AACA,MAAI,aAAa,IAAI,mBAAmB,gBAAgB;AACtD,WAAO,aAAa,IAAI;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
@@ -1,317 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- StepConfirm
4
- } from "./chunk-RAHSOJQ2.js";
5
- import {
6
- StepSources
7
- } from "./chunk-DAIEQJIF.js";
8
- import {
9
- StepStack
10
- } from "./chunk-SCOQ34YM.js";
11
- import {
12
- WizardLayout
13
- } from "./chunk-4NDBUJHK.js";
14
- import {
15
- DomainSelection
16
- } from "./chunk-LFWLEDUG.js";
17
- import {
18
- StepAgents
19
- } from "./chunk-XZEVWPX6.js";
20
- import {
21
- StepBuild
22
- } from "./chunk-MPTNC32T.js";
23
- import {
24
- HOTKEY_ACCEPT_DEFAULTS,
25
- HOTKEY_INFO,
26
- HOTKEY_SCOPE,
27
- isHotkey,
28
- isInfoPanelAvailable
29
- } from "./chunk-WTJ3AY33.js";
30
- import {
31
- useWizardStore
32
- } from "./chunk-7JNJ52CD.js";
33
- import {
34
- validateSelection
35
- } from "./chunk-A4KDXNOT.js";
36
- import {
37
- findStack,
38
- getSkillById,
39
- matrix
40
- } from "./chunk-V5WXIM2F.js";
41
- import {
42
- CLI_COLORS,
43
- EJECT_SOURCE,
44
- FALLBACK_DOMAIN
45
- } from "./chunk-ENGYJCTF.js";
46
-
47
- // src/cli/components/wizard/wizard.tsx
48
- import { useCallback as useCallback2, useEffect } from "react";
49
- import { useApp, useInput } from "ink";
50
- import { ThemeProvider } from "@inkjs/ui";
51
-
52
- // src/cli/components/themes/default.ts
53
- import { extendTheme, defaultTheme } from "@inkjs/ui";
54
- var VARIANT_COLORS = {
55
- error: CLI_COLORS.ERROR,
56
- warning: CLI_COLORS.WARNING,
57
- success: CLI_COLORS.SUCCESS,
58
- info: CLI_COLORS.INFO
59
- };
60
- var variantColor = (variant, fallback) => VARIANT_COLORS[String(variant)] ?? fallback;
61
- var cliTheme = extendTheme(defaultTheme, {
62
- components: {
63
- Spinner: {
64
- styles: {
65
- frame: () => ({ color: CLI_COLORS.PRIMARY }),
66
- label: () => ({ color: CLI_COLORS.NEUTRAL })
67
- }
68
- },
69
- Select: {
70
- styles: {
71
- focusIndicator: () => ({ color: CLI_COLORS.FOCUS }),
72
- label: ({ isFocused }) => ({
73
- color: isFocused ? CLI_COLORS.FOCUS : void 0
74
- })
75
- }
76
- },
77
- MultiSelect: {
78
- styles: {
79
- focusIndicator: () => ({ color: CLI_COLORS.FOCUS }),
80
- label: ({ isFocused, isSelected }) => ({
81
- color: isFocused ? CLI_COLORS.FOCUS : isSelected ? CLI_COLORS.SUCCESS : void 0
82
- }),
83
- checkboxChecked: () => ({ color: CLI_COLORS.SUCCESS })
84
- }
85
- },
86
- StatusMessage: {
87
- styles: {
88
- container: ({ variant }) => ({
89
- borderStyle: "round",
90
- borderColor: variantColor(variant, CLI_COLORS.INFO)
91
- })
92
- }
93
- },
94
- Alert: {
95
- styles: {
96
- container: ({ variant }) => ({
97
- borderColor: variantColor(variant, CLI_COLORS.INFO)
98
- }),
99
- icon: ({ variant }) => ({
100
- color: variantColor(variant, CLI_COLORS.INFO)
101
- })
102
- }
103
- },
104
- TextInput: {
105
- styles: {
106
- container: ({ isFocused }) => ({
107
- borderColor: isFocused ? CLI_COLORS.FOCUS : CLI_COLORS.NEUTRAL
108
- }),
109
- cursor: () => ({ color: CLI_COLORS.PRIMARY })
110
- }
111
- },
112
- ConfirmInput: {
113
- styles: {
114
- highlightedChoice: () => ({ color: CLI_COLORS.PRIMARY })
115
- }
116
- },
117
- Badge: {
118
- styles: {
119
- container: ({ variant }) => ({
120
- color: variantColor(variant, CLI_COLORS.PRIMARY)
121
- })
122
- }
123
- }
124
- }
125
- });
126
-
127
- // src/cli/components/hooks/use-build-step-props.ts
128
- import { useCallback } from "react";
129
- function useBuildStepProps({
130
- store,
131
- installedSkillIds
132
- }) {
133
- const currentDomain = store.getCurrentDomain();
134
- const defaultDomains = [FALLBACK_DOMAIN];
135
- const effectiveDomains = store.selectedDomains.length > 0 ? store.selectedDomains : defaultDomains;
136
- const allSelections = store.getAllSelectedTechnologies();
137
- const activeDomain = currentDomain || effectiveDomains[0] || FALLBACK_DOMAIN;
138
- const onToggle = useCallback(
139
- (categoryId, techId) => {
140
- const domain = store.getCurrentDomain() || FALLBACK_DOMAIN;
141
- const cat = matrix.categories[categoryId];
142
- const exclusive = cat?.exclusive ?? true;
143
- store.toggleTechnology(domain, categoryId, techId, exclusive);
144
- },
145
- [store]
146
- );
147
- const onContinue = useCallback(() => {
148
- if (!store.nextDomain()) {
149
- store.setStep("sources");
150
- }
151
- }, [store]);
152
- const onBack = useCallback(() => {
153
- if (!store.prevDomain()) {
154
- store.goBack();
155
- }
156
- }, [store]);
157
- return {
158
- domain: activeDomain,
159
- selectedDomains: effectiveDomains,
160
- allSelections,
161
- showLabels: store.showLabels,
162
- installedSkillIds,
163
- onToggle,
164
- onToggleLabels: store.toggleShowLabels,
165
- onContinue,
166
- onBack
167
- };
168
- }
169
-
170
- // src/cli/components/wizard/wizard.tsx
171
- import { jsx } from "react/jsx-runtime";
172
- var TOAST_DURATION_MS = 2e3;
173
- function toggleFocusedScope(isEditingFromGlobalScope, focusedId, actions) {
174
- if (isEditingFromGlobalScope) {
175
- actions.setToastMessage("Scope toggle unavailable in global context");
176
- return;
177
- }
178
- if (focusedId) {
179
- actions.toggle(focusedId);
180
- }
181
- }
182
- function resolveSelectedSkillIds(store) {
183
- if (store.selectedStackId && store.stackAction === "defaults") {
184
- const stack = findStack(store.selectedStackId);
185
- if (!stack) {
186
- throw new Error(`Stack not found: ${store.selectedStackId}`);
187
- }
188
- return [...stack.allSkillIds];
189
- }
190
- return store.getAllSelectedTechnologies().map((tech) => getSkillById(tech).id);
191
- }
192
- var Wizard = ({
193
- onComplete,
194
- onCancel,
195
- version,
196
- logo,
197
- startupMessages,
198
- initialAgents,
199
- installedSkillIds
200
- }) => {
201
- const store = useWizardStore();
202
- const { exit } = useApp();
203
- const toastMessage = useWizardStore((s) => s.toastMessage);
204
- useEffect(() => {
205
- if (!toastMessage) return;
206
- const timer = setTimeout(() => {
207
- useWizardStore.getState().setToastMessage(null);
208
- }, TOAST_DURATION_MS);
209
- return () => clearTimeout(timer);
210
- }, [toastMessage]);
211
- const buildStepProps = useBuildStepProps({
212
- store,
213
- ...installedSkillIds !== void 0 && { installedSkillIds }
214
- });
215
- useInput((input, key) => {
216
- if (store.showInfo) {
217
- if (key.escape || isHotkey(input, HOTKEY_INFO)) {
218
- store.toggleInfo();
219
- }
220
- return;
221
- }
222
- if (isInfoPanelAvailable(store.step) && isHotkey(input, HOTKEY_INFO)) {
223
- store.toggleInfo();
224
- return;
225
- }
226
- if (key.escape) {
227
- return;
228
- }
229
- if (isHotkey(input, HOTKEY_ACCEPT_DEFAULTS) && store.step === "build" && store.selectedStackId) {
230
- store.setStackAction("defaults");
231
- store.setStep("confirm");
232
- return;
233
- }
234
- if (isHotkey(input, HOTKEY_SCOPE) && store.step === "build") {
235
- toggleFocusedScope(store.isEditingFromGlobalScope, store.focusedSkillId, {
236
- toggle: store.toggleSkillScope,
237
- setToastMessage: store.setToastMessage
238
- });
239
- return;
240
- }
241
- if (isHotkey(input, HOTKEY_SCOPE) && store.step === "agents") {
242
- toggleFocusedScope(store.isEditingFromGlobalScope, store.focusedAgentId, {
243
- toggle: store.toggleAgentScope,
244
- setToastMessage: store.setToastMessage
245
- });
246
- return;
247
- }
248
- });
249
- const handleComplete = useCallback2(() => {
250
- const allSkills = resolveSelectedSkillIds(store);
251
- const skillConfigs = allSkills.map((id) => {
252
- const existing = store.skillConfigs.find((sc) => sc.id === id && !sc.excluded);
253
- return existing ?? { id, scope: "global", origin: EJECT_SOURCE };
254
- });
255
- const excludedConfigs = store.skillConfigs.filter((sc) => sc.excluded);
256
- const allSkillConfigs = [...skillConfigs, ...excludedConfigs];
257
- const validation = validateSelection(allSkills);
258
- const result = {
259
- skills: allSkillConfigs,
260
- selectedAgents: store.selectedAgents,
261
- agentConfigs: store.agentConfigs,
262
- selectedStackId: store.selectedStackId,
263
- domainSelections: store.domainSelections,
264
- selectedDomains: store.selectedDomains,
265
- unresolvableSkillIds: store.unresolvableSkillIds,
266
- foldedSkillIds: store.foldedSkillIds,
267
- cancelled: false,
268
- validation
269
- };
270
- onComplete(result);
271
- exit();
272
- }, [store, onComplete, exit]);
273
- const handleCancel = useCallback2(() => {
274
- onCancel();
275
- exit();
276
- }, [onCancel, exit]);
277
- const renderStep = () => {
278
- switch (store.step) {
279
- case "stack":
280
- return /* @__PURE__ */ jsx(StepStack, { onCancel: handleCancel });
281
- case "domains":
282
- return /* @__PURE__ */ jsx(DomainSelection, {});
283
- case "build":
284
- return /* @__PURE__ */ jsx(StepBuild, { ...buildStepProps });
285
- case "sources": {
286
- return /* @__PURE__ */ jsx(
287
- StepSources,
288
- {
289
- onContinue: () => {
290
- if (!initialAgents?.length) {
291
- store.preselectAgentsFromDomains();
292
- }
293
- store.setStep("agents");
294
- },
295
- onBack: store.goBack
296
- }
297
- );
298
- }
299
- case "agents":
300
- return /* @__PURE__ */ jsx(StepAgents, {});
301
- case "confirm": {
302
- return /* @__PURE__ */ jsx(StepConfirm, { onComplete: handleComplete, onBack: store.goBack });
303
- }
304
- default: {
305
- const _exhaustive = store.step;
306
- return _exhaustive;
307
- }
308
- }
309
- };
310
- return /* @__PURE__ */ jsx(ThemeProvider, { theme: cliTheme, children: /* @__PURE__ */ jsx(WizardLayout, { version, logo, startupMessages, children: renderStep() }) });
311
- };
312
-
313
- export {
314
- resolveSelectedSkillIds,
315
- Wizard
316
- };
317
- //# sourceMappingURL=chunk-WWIFNPJG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/components/wizard/wizard.tsx","../src/cli/components/themes/default.ts","../src/cli/components/hooks/use-build-step-props.ts"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { EJECT_SOURCE } from \"../../consts.js\";\nimport { useApp, useInput } from \"ink\";\nimport { ThemeProvider } from \"@inkjs/ui\";\nimport { useWizardStore, type WizardState } from \"../../stores/wizard-store.js\";\nimport { cliTheme } from \"../themes/default.js\";\nimport { WizardLayout } from \"./wizard-layout.js\";\nimport { StepStack } from \"./step-stack.js\";\nimport { StepBuild } from \"./step-build.js\";\nimport { StepConfirm } from \"./step-confirm.js\";\nimport { StepSources } from \"./step-sources.js\";\nimport { StepAgents } from \"./step-agents.js\";\nimport { DomainSelection } from \"./domain-selection.js\";\nimport { validateSelection } from \"../../lib/matrix/index.js\";\nimport { getSkillById } from \"../../lib/matrix/matrix-provider.js\";\nimport { findStack } from \"../../lib/matrix/matrix-provider.js\";\nimport {\n HOTKEY_ACCEPT_DEFAULTS,\n HOTKEY_INFO,\n HOTKEY_SCOPE,\n isHotkey,\n isInfoPanelAvailable,\n} from \"./hotkeys.js\";\nimport type {\n AgentName,\n Domain,\n DomainSelections,\n SelectionValidation,\n SkillId,\n StackAgentConfig,\n} from \"../../types/index.js\";\nimport type { AgentScopeConfig, SkillConfig } from \"../../types/config.js\";\nimport type { StartupMessage } from \"../../utils/logger.js\";\nimport { useBuildStepProps } from \"../hooks/use-build-step-props.js\";\n\nconst TOAST_DURATION_MS = 2000;\n\nexport type WizardResultV2 = {\n skills: SkillConfig[];\n selectedAgents: AgentName[];\n agentConfigs: AgentScopeConfig[];\n /**\n * What each sub-agent holds and what preloads, when the producer knows per `(skill, sub-agent)`.\n * A shared configuration installed with `init --from` does: it assigns each skill to named\n * sub-agents at a named load state, and that curation is the whole of what was shared.\n *\n * The wizard has no per-agent granularity — a skill is selected for the project, not for one\n * sub-agent — so it leaves this undefined and the install pipeline's ownership rules build the\n * stack as they always have.\n */\n assignedStack?: Partial<Record<AgentName, StackAgentConfig>>;\n selectedStackId: string | null;\n /**\n * What the written config should record about itself, when the producer already knows.\n *\n * A shared configuration installed with `init --from` does: its payload carries the sharer's own\n * description, because it names no stack for the install to resolve one out of. The wizard leaves\n * this undefined and the install pipeline takes the applied stack's description instead — there\n * IS a loaded stack on that path, and it is the authority on its own sentence.\n */\n description?: string;\n domainSelections: DomainSelections;\n selectedDomains: Domain[];\n /**\n * Skill ids from the saved config that could not be resolved against the loaded source matrix\n * this session. The wizard could not represent them, so they are absent from `skills` and the\n * merge removes their config entries. Carried out of the wizard so the command can NAME each\n * removal and say why it happened — a removal the user never asked for must never be silent.\n */\n unresolvableSkillIds: SkillId[];\n /**\n * The `[P][G]` pairs `s` folded into the global install, which the selection key's collapse\n * into the same config entry does not. Absent from a producer with no keys to press: a shared\n * configuration folds nothing.\n */\n foldedSkillIds?: SkillId[];\n cancelled: boolean;\n validation: SelectionValidation;\n};\n\nexport type WizardProps = {\n onComplete: (result: WizardResultV2) => void;\n onCancel: () => void;\n version: string;\n logo?: string | undefined;\n startupMessages?: StartupMessage[] | undefined;\n initialAgents?: AgentName[] | undefined;\n installedSkillIds?: SkillId[] | undefined;\n};\n\n/** S-key scope toggle: blocked (with a toast) in global context; no-op without a focused row. */\nfunction toggleFocusedScope<Id>(\n isEditingFromGlobalScope: boolean,\n focusedId: Id | null,\n actions: { toggle: (id: Id) => void; setToastMessage: (message: string) => void },\n): void {\n if (isEditingFromGlobalScope) {\n actions.setToastMessage(\"Scope toggle unavailable in global context\");\n return;\n }\n if (focusedId) {\n actions.toggle(focusedId);\n }\n}\n\n/** Selected skill ids: the chosen stack's full list under stack-defaults, else the wizard selections. */\nexport function resolveSelectedSkillIds(store: WizardState): SkillId[] {\n if (store.selectedStackId && store.stackAction === \"defaults\") {\n const stack = findStack(store.selectedStackId);\n if (!stack) {\n throw new Error(`Stack not found: ${store.selectedStackId}`);\n }\n return [...stack.allSkillIds];\n }\n return store.getAllSelectedTechnologies().map((tech) => getSkillById(tech).id);\n}\n\nexport const Wizard: React.FC<WizardProps> = ({\n onComplete,\n onCancel,\n version,\n logo,\n startupMessages,\n initialAgents,\n installedSkillIds,\n}) => {\n const store = useWizardStore();\n const { exit } = useApp();\n\n const toastMessage = useWizardStore((s) => s.toastMessage);\n\n useEffect(() => {\n if (!toastMessage) return;\n const timer = setTimeout(() => {\n useWizardStore.getState().setToastMessage(null);\n }, TOAST_DURATION_MS);\n return () => clearTimeout(timer);\n }, [toastMessage]);\n\n const buildStepProps = useBuildStepProps({\n store,\n ...(installedSkillIds !== undefined && { installedSkillIds }),\n });\n\n useInput((input, key) => {\n // Closing is never gated on the step: the panel is only ever open on a step\n // that allows it, and gating the close would strand the overlay.\n if (store.showInfo) {\n if (key.escape || isHotkey(input, HOTKEY_INFO)) {\n store.toggleInfo();\n }\n return;\n }\n\n if (isInfoPanelAvailable(store.step) && isHotkey(input, HOTKEY_INFO)) {\n store.toggleInfo();\n return;\n }\n\n if (key.escape) {\n // Steps with their own ESC handling (via useInput in child components):\n // - \"stack\": StackSelection handles ESC via onCancel prop\n // - \"domains\": DomainSelection handles ESC via CheckboxGrid onBack\n // - \"build\": StepBuild handles ESC via its own useInput\n // - \"sources\": StepSources handles ESC via onBack prop\n // - \"confirm\": StepConfirm handles ESC via onBack prop\n // - \"agents\": StepAgents handles ESC via its own useInput\n // All steps handle their own ESC, so this is a no-op.\n return;\n }\n\n if (\n isHotkey(input, HOTKEY_ACCEPT_DEFAULTS) &&\n store.step === \"build\" &&\n store.selectedStackId\n ) {\n store.setStackAction(\"defaults\");\n store.setStep(\"confirm\");\n return;\n }\n\n if (isHotkey(input, HOTKEY_SCOPE) && store.step === \"build\") {\n toggleFocusedScope(store.isEditingFromGlobalScope, store.focusedSkillId, {\n toggle: store.toggleSkillScope,\n setToastMessage: store.setToastMessage,\n });\n return;\n }\n\n if (isHotkey(input, HOTKEY_SCOPE) && store.step === \"agents\") {\n toggleFocusedScope(store.isEditingFromGlobalScope, store.focusedAgentId, {\n toggle: store.toggleAgentScope,\n setToastMessage: store.setToastMessage,\n });\n return;\n }\n });\n\n const handleComplete = useCallback(() => {\n const allSkills = resolveSelectedSkillIds(store);\n\n const skillConfigs: SkillConfig[] = allSkills.map((id) => {\n const existing = store.skillConfigs.find((sc) => sc.id === id && !sc.excluded);\n return existing ?? { id, scope: \"global\" as const, origin: EJECT_SOURCE };\n });\n\n // Append excluded entries so they flow through to config generation\n const excludedConfigs = store.skillConfigs.filter((sc) => sc.excluded);\n const allSkillConfigs = [...skillConfigs, ...excludedConfigs];\n\n const validation = validateSelection(allSkills);\n\n const result: WizardResultV2 = {\n skills: allSkillConfigs,\n selectedAgents: store.selectedAgents,\n agentConfigs: store.agentConfigs,\n selectedStackId: store.selectedStackId,\n domainSelections: store.domainSelections,\n selectedDomains: store.selectedDomains,\n unresolvableSkillIds: store.unresolvableSkillIds,\n foldedSkillIds: store.foldedSkillIds,\n cancelled: false,\n validation,\n };\n\n onComplete(result);\n exit();\n }, [store, onComplete, exit]);\n\n const handleCancel = useCallback(() => {\n onCancel();\n exit();\n }, [onCancel, exit]);\n\n const renderStep = () => {\n switch (store.step) {\n case \"stack\":\n return <StepStack onCancel={handleCancel} />;\n\n case \"domains\":\n return <DomainSelection />;\n\n case \"build\":\n return <StepBuild {...buildStepProps} />;\n\n case \"sources\": {\n return (\n <StepSources\n onContinue={() => {\n if (!initialAgents?.length) {\n store.preselectAgentsFromDomains();\n }\n store.setStep(\"agents\");\n }}\n onBack={store.goBack}\n />\n );\n }\n\n case \"agents\":\n return <StepAgents />;\n\n case \"confirm\": {\n return <StepConfirm onComplete={handleComplete} onBack={store.goBack} />;\n }\n\n default: {\n const _exhaustive: never = store.step;\n return _exhaustive;\n }\n }\n };\n\n return (\n <ThemeProvider theme={cliTheme}>\n <WizardLayout version={version} logo={logo} startupMessages={startupMessages}>\n {renderStep()}\n </WizardLayout>\n </ThemeProvider>\n );\n};\n","import { extendTheme, defaultTheme } from \"@inkjs/ui\";\nimport { CLI_COLORS } from \"../../consts.js\";\n\n/** Variant → color mapping shared by StatusMessage, Alert, and Badge; unknown variants fall back per-site. */\nconst VARIANT_COLORS: Partial<Record<string, string>> = {\n error: CLI_COLORS.ERROR,\n warning: CLI_COLORS.WARNING,\n success: CLI_COLORS.SUCCESS,\n info: CLI_COLORS.INFO,\n};\n\n/**\n * @inkjs/ui types the props it hands a style function as `any`, so reading\n * `variant` off them is an unchecked access at four call sites. Taking it as\n * `unknown` here is the boundary: the value is only ever a lookup key, and a\n * variant the map does not name falls back to what the call site passes.\n */\nconst variantColor = (variant: unknown, fallback: string): string =>\n VARIANT_COLORS[String(variant)] ?? fallback;\n\n/**\n * CLI theme matching existing picocolors styling\n *\n * Color scheme:\n * - Cyan: Focus/primary (headings, prompts, selected items)\n * - Green: Success states\n * - Red: Errors\n * - Yellow: Warnings\n * - Blue: Info messages\n */\nexport const cliTheme = extendTheme(defaultTheme, {\n components: {\n Spinner: {\n styles: {\n frame: () => ({ color: CLI_COLORS.PRIMARY }),\n label: () => ({ color: CLI_COLORS.NEUTRAL }),\n },\n },\n Select: {\n styles: {\n focusIndicator: () => ({ color: CLI_COLORS.FOCUS }),\n label: ({ isFocused }) => ({\n color: isFocused ? CLI_COLORS.FOCUS : undefined,\n }),\n },\n },\n MultiSelect: {\n styles: {\n focusIndicator: () => ({ color: CLI_COLORS.FOCUS }),\n label: ({ isFocused, isSelected }) => ({\n color: isFocused ? CLI_COLORS.FOCUS : isSelected ? CLI_COLORS.SUCCESS : undefined,\n }),\n checkboxChecked: () => ({ color: CLI_COLORS.SUCCESS }),\n },\n },\n StatusMessage: {\n styles: {\n container: ({ variant }) => ({\n borderStyle: \"round\",\n borderColor: variantColor(variant, CLI_COLORS.INFO),\n }),\n },\n },\n Alert: {\n styles: {\n container: ({ variant }) => ({\n borderColor: variantColor(variant, CLI_COLORS.INFO),\n }),\n icon: ({ variant }) => ({\n color: variantColor(variant, CLI_COLORS.INFO),\n }),\n },\n },\n TextInput: {\n styles: {\n container: ({ isFocused }) => ({\n borderColor: isFocused ? CLI_COLORS.FOCUS : CLI_COLORS.NEUTRAL,\n }),\n cursor: () => ({ color: CLI_COLORS.PRIMARY }),\n },\n },\n ConfirmInput: {\n styles: {\n highlightedChoice: () => ({ color: CLI_COLORS.PRIMARY }),\n },\n },\n Badge: {\n styles: {\n container: ({ variant }) => ({\n color: variantColor(variant, CLI_COLORS.PRIMARY),\n }),\n },\n },\n },\n});\n","import { useCallback } from \"react\";\nimport { FALLBACK_DOMAIN } from \"../../consts.js\";\nimport type { Domain, SkillId } from \"../../types/index.js\";\nimport type { WizardState } from \"../../stores/wizard-store.js\";\nimport { matrix } from \"../../lib/matrix/matrix-provider.js\";\nimport type { StepBuildProps } from \"../wizard/step-build.js\";\n\ntype UseBuildStepPropsOptions = {\n store: WizardState;\n installedSkillIds?: SkillId[];\n};\n\nexport function useBuildStepProps({\n store,\n installedSkillIds,\n}: UseBuildStepPropsOptions): StepBuildProps {\n const currentDomain = store.getCurrentDomain();\n const defaultDomains: Domain[] = [FALLBACK_DOMAIN];\n const effectiveDomains =\n store.selectedDomains.length > 0 ? store.selectedDomains : defaultDomains;\n\n const allSelections = store.getAllSelectedTechnologies();\n\n const activeDomain: Domain = currentDomain || effectiveDomains[0] || FALLBACK_DOMAIN;\n\n const onToggle = useCallback(\n (categoryId: Parameters<StepBuildProps[\"onToggle\"]>[0], techId: SkillId) => {\n const domain: Domain = store.getCurrentDomain() || FALLBACK_DOMAIN;\n const cat = matrix.categories[categoryId];\n const exclusive = cat?.exclusive ?? true;\n store.toggleTechnology(domain, categoryId, techId, exclusive);\n },\n [store],\n );\n\n const onContinue = useCallback(() => {\n if (!store.nextDomain()) {\n store.setStep(\"sources\");\n }\n }, [store]);\n\n const onBack = useCallback(() => {\n if (!store.prevDomain()) {\n store.goBack();\n }\n }, [store]);\n\n return {\n domain: activeDomain,\n selectedDomains: effectiveDomains,\n allSelections,\n showLabels: store.showLabels,\n installedSkillIds,\n onToggle,\n onToggleLabels: store.toggleShowLabels,\n onContinue,\n onBack,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,eAAAA,cAAa,iBAAiB;AAE9C,SAAS,QAAQ,gBAAgB;AACjC,SAAS,qBAAqB;;;ACH9B,SAAS,aAAa,oBAAoB;AAI1C,IAAM,iBAAkD;AAAA,EACtD,OAAO,WAAW;AAAA,EAClB,SAAS,WAAW;AAAA,EACpB,SAAS,WAAW;AAAA,EACpB,MAAM,WAAW;AACnB;AAQA,IAAM,eAAe,CAAC,SAAkB,aACtC,eAAe,OAAO,OAAO,CAAC,KAAK;AAY9B,IAAM,WAAW,YAAY,cAAc;AAAA,EAChD,YAAY;AAAA,IACV,SAAS;AAAA,MACP,QAAQ;AAAA,QACN,OAAO,OAAO,EAAE,OAAO,WAAW,QAAQ;AAAA,QAC1C,OAAO,OAAO,EAAE,OAAO,WAAW,QAAQ;AAAA,MAC5C;AAAA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;AAEA,eAAW,MAAM;AACjB,SAAK;AAAA,EACP,GAAG,CAAC,OAAO,YAAY,IAAI,CAAC;AAE5B,QAAM,eAAeA,aAAY,MAAM;AACrC,aAAS;AACT,SAAK;AAAA,EACP,GAAG,CAAC,UAAU,IAAI,CAAC;AAEnB,QAAM,aAAa,MAAM;AACvB,YAAQ,MAAM,MAAM;AAAA,MAClB,KAAK;AACH,eAAO,oBAAC,aAAU,UAAU,cAAc;AAAA,MAE5C,KAAK;AACH,eAAO,oBAAC,mBAAgB;AAAA,MAE1B,KAAK;AACH,eAAO,oBAAC,aAAW,GAAG,gBAAgB;AAAA,MAExC,KAAK,WAAW;AACd,eACE;AAAA,UAAC;AAAA;AAAA,YACC,YAAY,MAAM;AAChB,kBAAI,CAAC,eAAe,QAAQ;AAC1B,sBAAM,2BAA2B;AAAA,cACnC;AACA,oBAAM,QAAQ,QAAQ;AAAA,YACxB;AAAA,YACA,QAAQ,MAAM;AAAA;AAAA,QAChB;AAAA,MAEJ;AAAA,MAEA,KAAK;AACH,eAAO,oBAAC,cAAW;AAAA,MAErB,KAAK,WAAW;AACd,eAAO,oBAAC,eAAY,YAAY,gBAAgB,QAAQ,MAAM,QAAQ;AAAA,MACxE;AAAA,MAEA,SAAS;AACP,cAAM,cAAqB,MAAM;AACjC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,SACE,oBAAC,iBAAc,OAAO,UACpB,8BAAC,gBAAa,SAAkB,MAAY,iBACzC,qBAAW,GACd,GACF;AAEJ;","names":["useCallback","useCallback"]}
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/cli/components/hooks/use-focused-list-item.ts
4
- import { useState, useCallback, useRef } from "react";
5
- function useFocusedListItem(rowCount, getColCount, options = {}) {
6
- const {
7
- wrap = true,
8
- findValidCol,
9
- adjustCol,
10
- onChange,
11
- initialRow = 0,
12
- initialCol = 0,
13
- skipRow
14
- } = options;
15
- const [focusedRow, setFocusedRow] = useState(initialRow);
16
- const [focusedCol, setFocusedCol] = useState(initialCol);
17
- const focusedRowRef = useRef(focusedRow);
18
- const focusedColRef = useRef(focusedCol);
19
- const onChangeRef = useRef(onChange);
20
- onChangeRef.current = onChange;
21
- const applyFocus = useCallback((row, col) => {
22
- focusedRowRef.current = row;
23
- focusedColRef.current = col;
24
- setFocusedRow(row);
25
- setFocusedCol(col);
26
- onChangeRef.current?.(row, col);
27
- }, []);
28
- const setFocused = applyFocus;
29
- const currentFocus = useCallback(
30
- () => ({ row: focusedRowRef.current, col: focusedColRef.current }),
31
- []
32
- );
33
- const findNextRow = useCallback(
34
- (fromRow, direction) => {
35
- if (rowCount === 0) return fromRow;
36
- let next = fromRow;
37
- for (let i = 0; i < rowCount; i++) {
38
- if (wrap) {
39
- next = (next + direction + rowCount) % rowCount;
40
- } else {
41
- next = next + direction;
42
- if (next < 0 || next >= rowCount) return fromRow;
43
- }
44
- if (!skipRow || !skipRow(next)) return next;
45
- }
46
- return fromRow;
47
- },
48
- [rowCount, wrap, skipRow]
49
- );
50
- const moveFocus = useCallback(
51
- (direction) => {
52
- const currentRow = focusedRowRef.current;
53
- const currentCol = focusedColRef.current;
54
- if (direction === "left" || direction === "right") {
55
- const colCount = getColCount(currentRow);
56
- if (colCount === 0) return;
57
- const step = direction === "right" ? 1 : -1;
58
- if (findValidCol) {
59
- const newCol = findValidCol(currentRow, currentCol, step);
60
- applyFocus(currentRow, newCol);
61
- } else if (wrap) {
62
- const newCol = (currentCol + step + colCount) % colCount;
63
- applyFocus(currentRow, newCol);
64
- } else {
65
- const newCol = Math.max(0, Math.min(colCount - 1, currentCol + step));
66
- applyFocus(currentRow, newCol);
67
- }
68
- } else {
69
- const step = direction === "down" ? 1 : -1;
70
- const newRow = findNextRow(currentRow, step);
71
- const newColCount = getColCount(newRow);
72
- let finalCol = Math.min(currentCol, Math.max(0, newColCount - 1));
73
- if (adjustCol) {
74
- finalCol = adjustCol(newRow, finalCol);
75
- }
76
- applyFocus(newRow, finalCol);
77
- }
78
- },
79
- // skipRow is reached only through findNextRow, whose identity already
80
- // tracks it — naming it again here just churned this callback's identity.
81
- [getColCount, wrap, findValidCol, adjustCol, findNextRow, applyFocus]
82
- );
83
- return { focusedRow, focusedCol, currentFocus, setFocused, moveFocus };
84
- }
85
-
86
- export {
87
- useFocusedListItem
88
- };
89
- //# sourceMappingURL=chunk-XQHZPINL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/components/hooks/use-focused-list-item.ts"],"sourcesContent":["import { useState, useCallback, useRef } from \"react\";\n\nexport type Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\ntype UseFocusedListItemOptions = {\n /** Wrap around when reaching boundaries (default: true) */\n wrap?: boolean;\n /** Custom column finder for skipping disabled items on horizontal nav.\n * Receives the row, current column, and direction (+1 right, -1 left).\n * Should return the next valid column index. */\n findValidCol?: (row: number, currentCol: number, direction: 1 | -1) => number;\n /** Called after vertical navigation to adjust the clamped column\n * (e.g. to skip disabled items). Returns the adjusted column index. */\n adjustCol?: (row: number, clampedCol: number) => number;\n /** Called whenever focused position changes */\n onChange?: (row: number, col: number) => void;\n /** Initial row index (default: 0) */\n initialRow?: number;\n /** Initial col index (default: 0) */\n initialCol?: number;\n /** Optional predicate: when it returns true for a row index, that row is skipped during vertical navigation. */\n skipRow?: (row: number) => boolean;\n};\n\nexport type FocusedPosition = { row: number; col: number };\n\ntype UseFocusedListItemResult = {\n focusedRow: number;\n focusedCol: number;\n /**\n * The position as it stands now, for a key handler. `focusedRow`/`focusedCol` are what the last\n * render painted, and a key that follows a move in the same chunk is handled before that move\n * has rendered.\n */\n currentFocus: () => FocusedPosition;\n setFocused: (row: number, col: number) => void;\n moveFocus: (direction: Direction) => void;\n};\n\n/**\n * 2D grid focus management: tracks (row, col) position and handles\n * directional movement with wrapping, column clamping,\n * and optional disabled-column skipping.\n */\nexport function useFocusedListItem(\n rowCount: number,\n getColCount: (row: number) => number,\n options: UseFocusedListItemOptions = {},\n): UseFocusedListItemResult {\n const {\n wrap = true,\n findValidCol,\n adjustCol,\n onChange,\n initialRow = 0,\n initialCol = 0,\n skipRow,\n } = options;\n\n const [focusedRow, setFocusedRow] = useState(initialRow);\n const [focusedCol, setFocusedCol] = useState(initialCol);\n\n // The position every move starts from, written the moment focus moves rather than when the move\n // renders. Keys that arrive in one chunk — a fast typist, a paste — are handled one after another\n // with no render between them, so a copy synced during render still held the position from\n // before the burst, and the second of two moves started where the first one had.\n const focusedRowRef = useRef(focusedRow);\n const focusedColRef = useRef(focusedCol);\n\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const applyFocus = useCallback((row: number, col: number) => {\n focusedRowRef.current = row;\n focusedColRef.current = col;\n setFocusedRow(row);\n setFocusedCol(col);\n onChangeRef.current?.(row, col);\n }, []);\n\n const setFocused = applyFocus;\n\n const currentFocus = useCallback(\n (): FocusedPosition => ({ row: focusedRowRef.current, col: focusedColRef.current }),\n [],\n );\n\n const findNextRow = useCallback(\n (fromRow: number, direction: 1 | -1): number => {\n if (rowCount === 0) return fromRow;\n let next = fromRow;\n for (let i = 0; i < rowCount; i++) {\n if (wrap) {\n next = (next + direction + rowCount) % rowCount;\n } else {\n next = next + direction;\n if (next < 0 || next >= rowCount) return fromRow;\n }\n if (!skipRow || !skipRow(next)) return next;\n }\n return fromRow; // All rows skipped — stay put\n },\n [rowCount, wrap, skipRow],\n );\n\n const moveFocus = useCallback(\n (direction: Direction) => {\n const currentRow = focusedRowRef.current;\n const currentCol = focusedColRef.current;\n\n if (direction === \"left\" || direction === \"right\") {\n const colCount = getColCount(currentRow);\n if (colCount === 0) return;\n\n const step = direction === \"right\" ? 1 : -1;\n\n if (findValidCol) {\n const newCol = findValidCol(currentRow, currentCol, step);\n applyFocus(currentRow, newCol);\n } else if (wrap) {\n const newCol = (currentCol + step + colCount) % colCount;\n applyFocus(currentRow, newCol);\n } else {\n const newCol = Math.max(0, Math.min(colCount - 1, currentCol + step));\n applyFocus(currentRow, newCol);\n }\n } else {\n const step = direction === \"down\" ? 1 : -1;\n const newRow = findNextRow(currentRow, step);\n const newColCount = getColCount(newRow);\n let finalCol = Math.min(currentCol, Math.max(0, newColCount - 1));\n\n if (adjustCol) {\n finalCol = adjustCol(newRow, finalCol);\n }\n\n applyFocus(newRow, finalCol);\n }\n },\n // skipRow is reached only through findNextRow, whose identity already\n // tracks it — naming it again here just churned this callback's identity.\n [getColCount, wrap, findValidCol, adjustCol, findNextRow, applyFocus],\n );\n\n return { focusedRow, focusedCol, currentFocus, setFocused, moveFocus };\n}\n"],"mappings":";;;AAAA,SAAS,UAAU,aAAa,cAAc;AA4CvC,SAAS,mBACd,UACA,aACA,UAAqC,CAAC,GACZ;AAC1B,QAAM;AAAA,IACJ,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,aAAa;AAAA,IACb;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,UAAU;AACvD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,UAAU;AAMvD,QAAM,gBAAgB,OAAO,UAAU;AACvC,QAAM,gBAAgB,OAAO,UAAU;AAEvC,QAAM,cAAc,OAAO,QAAQ;AACnC,cAAY,UAAU;AAEtB,QAAM,aAAa,YAAY,CAAC,KAAa,QAAgB;AAC3D,kBAAc,UAAU;AACxB,kBAAc,UAAU;AACxB,kBAAc,GAAG;AACjB,kBAAc,GAAG;AACjB,gBAAY,UAAU,KAAK,GAAG;AAAA,EAChC,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa;AAEnB,QAAM,eAAe;AAAA,IACnB,OAAwB,EAAE,KAAK,cAAc,SAAS,KAAK,cAAc,QAAQ;AAAA,IACjF,CAAC;AAAA,EACH;AAEA,QAAM,cAAc;AAAA,IAClB,CAAC,SAAiB,cAA8B;AAC9C,UAAI,aAAa,EAAG,QAAO;AAC3B,UAAI,OAAO;AACX,eAAS,IAAI,GAAG,IAAI,UAAU,KAAK;AACjC,YAAI,MAA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