@katlux/toolkit 0.1.1-alpha.144 → 0.1.1-alpha.146

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 (207) hide show
  1. package/bin/ai-init.mjs +517 -0
  2. package/bin/ai-tokens.mjs +1043 -0
  3. package/bin/cli.mjs +80 -43
  4. package/bin/create-preset.mjs +1 -0
  5. package/bin/preset-contracts.json +2941 -0
  6. package/dist/compiled/composables/locales.mjs +204 -25
  7. package/dist/compiled/composables/useDataProvider.mjs +36 -25
  8. package/dist/compiled/composables/useFilterLogic.mjs +10 -2
  9. package/dist/compiled/composables/useKatluxForm.mjs +6 -4
  10. package/dist/compiled/composables/useVirtualDataset.mjs +689 -0
  11. package/dist/compiled/composables/useVirtualScroll.mjs +29 -9
  12. package/dist/module.cjs +63 -77
  13. package/dist/module.d.cts +5 -0
  14. package/dist/module.d.mts +4 -1
  15. package/dist/module.json +1 -1
  16. package/dist/module.mjs +60 -78
  17. package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +2 -2
  18. package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +2 -2
  19. package/dist/runtime/components/KAlert/KAlert.global.d.vue.ts +1 -1
  20. package/dist/runtime/components/KAlert/KAlert.global.vue.d.ts +1 -1
  21. package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +7 -3
  22. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +4 -1
  23. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +7 -3
  24. package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +4 -2
  25. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +70 -37
  26. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +2 -2
  27. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +2 -2
  28. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  29. package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +19 -10
  30. package/dist/runtime/components/KCalendar/KCalendar.global.vue +7 -2
  31. package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +19 -10
  32. package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +14 -201
  33. package/dist/runtime/components/KCalendar/KCalendar.logic.js +60 -11
  34. package/dist/runtime/components/KCalendar/KCalendarMonth.global.d.vue.ts +25 -5
  35. package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +11 -1
  36. package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue.d.ts +25 -5
  37. package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +19 -3
  38. package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +115 -1
  39. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +2 -2
  40. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +2 -2
  41. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +9 -9
  42. package/dist/runtime/components/KCombobox/KCombobox.global.vue +1 -1
  43. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +9 -9
  44. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +7 -1
  45. package/dist/runtime/components/KCombobox/KCombobox.logic.js +1 -1
  46. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +14 -14
  47. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +14 -14
  48. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
  49. package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +5 -0
  50. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +22 -18
  51. package/dist/runtime/components/KDatatable/KDataIterator.global.vue +23 -16
  52. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +22 -18
  53. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +13 -10
  54. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +25 -20
  55. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +9 -13
  56. package/dist/runtime/components/KDatatable/KDatatable.global.vue +6 -5
  57. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +9 -13
  58. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -6
  59. package/dist/runtime/components/KDatatable/KDatatable.logic.js +26 -19
  60. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +31 -15
  61. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +38 -13
  62. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +31 -15
  63. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +28 -6
  64. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +197 -53
  65. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +3 -3
  66. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +3 -3
  67. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +2 -0
  68. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
  69. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
  70. package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +55 -6
  71. package/dist/runtime/components/KGantt/KGantt.global.vue +12 -3
  72. package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +55 -6
  73. package/dist/runtime/components/KGantt/KGantt.logic.d.ts +33 -5
  74. package/dist/runtime/components/KGantt/KGantt.logic.js +39 -6
  75. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
  76. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
  77. package/dist/runtime/components/KHourSelect/KHourSelect.global.d.vue.ts +1 -1
  78. package/dist/runtime/components/KHourSelect/KHourSelect.global.vue.d.ts +1 -1
  79. package/dist/runtime/components/KLoader/KLoader.global.vue +2 -0
  80. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +2 -2
  81. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +2 -2
  82. package/dist/runtime/components/KMultiTabs/MultiTabs.global.d.vue.ts +23 -0
  83. package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +22 -0
  84. package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue.d.ts +23 -0
  85. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +4 -2
  86. package/dist/runtime/components/KPagination/KPagination.global.vue +2 -1
  87. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +4 -2
  88. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
  89. package/dist/runtime/components/KPagination/KPagination.logic.js +57 -5
  90. package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
  91. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +1 -1
  92. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
  93. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
  94. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
  95. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
  96. package/dist/runtime/components/KTabs/KTabs.global.d.vue.ts +2 -2
  97. package/dist/runtime/components/KTabs/KTabs.global.vue.d.ts +2 -2
  98. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +2 -2
  99. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +2 -2
  100. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +3 -3
  101. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +3 -3
  102. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +3 -3
  103. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +3 -3
  104. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  105. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  106. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +7 -7
  107. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +7 -7
  108. package/dist/runtime/components/KTree/KTree.logic.d.ts +2 -2
  109. package/dist/runtime/components/KTree/KTree.logic.js +16 -12
  110. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +7 -9
  111. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +1 -5
  112. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +7 -9
  113. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +39 -5
  114. package/dist/runtime/components/KTreeView/KTreeView.global.vue +19 -1
  115. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +39 -5
  116. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +23 -3
  117. package/dist/runtime/components/KTreeView/KTreeView.logic.js +76 -6
  118. package/dist/runtime/composables/locales.js +204 -25
  119. package/dist/runtime/composables/useDataProvider.d.ts +5 -3
  120. package/dist/runtime/composables/useDataProvider.js +36 -25
  121. package/dist/runtime/composables/useFilterLogic.d.ts +16 -4
  122. package/dist/runtime/composables/useFilterLogic.js +10 -2
  123. package/dist/runtime/composables/useKatluxForm.d.ts +4 -4
  124. package/dist/runtime/composables/useKatluxForm.js +6 -4
  125. package/dist/runtime/composables/useSortLogic.d.ts +1 -1
  126. package/dist/runtime/composables/useVirtualDataset.d.ts +121 -0
  127. package/dist/runtime/composables/useVirtualDataset.js +689 -0
  128. package/dist/runtime/composables/useVirtualScroll.d.ts +8 -4
  129. package/dist/runtime/composables/useVirtualScroll.js +29 -9
  130. package/dist/runtime/plugins/nuxtCompatPlugin.js +9 -1
  131. package/dist/runtime/presets/default/assets/scss/css-variables.css +3 -0
  132. package/dist/runtime/presets/default/assets/scss/css-variables.scss +6 -1
  133. package/dist/runtime/presets/default/assets/scss/index.css +3 -0
  134. package/dist/runtime/presets/default/assets/svg/katlux-logo.svg +7 -0
  135. package/dist/runtime/presets/default/assets/svg/katlux.svg +6 -0
  136. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.d.vue.ts +3 -2
  137. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +31 -3
  138. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue.d.ts +3 -2
  139. package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +3 -0
  140. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +6 -0
  141. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +3 -0
  142. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +5 -0
  143. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +33 -2
  144. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +5 -0
  145. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +2 -2
  146. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +2 -2
  147. package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +7 -1
  148. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +30 -8
  149. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +80 -164
  150. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +30 -8
  151. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +16 -9
  152. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +99 -394
  153. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +16 -9
  154. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +6 -0
  155. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +71 -4
  156. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +6 -0
  157. package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +11 -12
  158. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +77 -14
  159. package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +11 -12
  160. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +1 -0
  161. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +2 -2
  162. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +2 -2
  163. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +4 -4
  164. package/dist/runtime/presets/default/components/KTree/KTree.vue +48 -14
  165. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +4 -4
  166. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +11 -2
  167. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +14 -2
  168. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +11 -2
  169. package/dist/skills/KATLUX_INDEX.md +9 -6
  170. package/dist/skills/katlux-components/SKILL.md +2 -0
  171. package/dist/skills/katlux-components/components/KBulkActions.md +25 -1
  172. package/dist/skills/katlux-components/components/KCombobox.md +2 -2
  173. package/dist/skills/katlux-components/components/KDataIterator.md +12 -4
  174. package/dist/skills/katlux-components/components/KDatatable.md +38 -0
  175. package/dist/skills/katlux-components/components/KDatePicker.md +3 -1
  176. package/dist/skills/katlux-components/components/KGantt.md +9 -0
  177. package/dist/skills/katlux-components/components/KIcon.md +1 -1
  178. package/dist/skills/katlux-components/components/KLineChart.md +3 -0
  179. package/dist/skills/katlux-components/components/KProductList.md +0 -1
  180. package/dist/skills/katlux-components/components/KScatterChart.md +3 -0
  181. package/dist/skills/katlux-components/components/KTreePicker.md +2 -1
  182. package/dist/skills/katlux-components/components/KTreeView.md +12 -0
  183. package/dist/skills/katlux-config/SKILL.md +19 -8
  184. package/dist/skills/katlux-presets/SKILL.md +121 -1
  185. package/dist/skills/katlux-presets/creating-a-preset.md +67 -0
  186. package/dist/skills/katlux-providers/SKILL.md +7 -5
  187. package/dist/skills/katlux-providers/providers/ADataProvider.md +16 -9
  188. package/dist/skills/katlux-providers/providers/CAPIFlatClientDataProvider.md +27 -3
  189. package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +11 -1
  190. package/dist/skills/katlux-providers/providers/CFlatClientDataProvider.md +19 -4
  191. package/dist/skills/katlux-providers/providers/CFlatServerDataProvider.md +4 -2
  192. package/dist/skills/katlux-providers/providers/CTreeClientDataProvider.md +2 -2
  193. package/dist/skills/katlux-providers/providers/RequestProvider.md +10 -0
  194. package/dist/skills/katlux-providers/providers/encryption-field-level.md +63 -19
  195. package/dist/skills/katlux-providers/providers/encryption-key-management.md +20 -2
  196. package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +25 -11
  197. package/dist/skills/katlux-providers/providers/encryption-searchable.md +218 -0
  198. package/dist/skills/katlux-providers/providers/encryption-symmetric.md +25 -1
  199. package/dist/skills/katlux-providers/providers/encryption-threat-model.md +63 -0
  200. package/dist/skills/katlux-providers/providers/encryption.md +26 -1
  201. package/dist/skills/katlux-providers/providers/types.md +3 -1
  202. package/dist/skills/katlux-providers/providers/useDataProvider.md +2 -1
  203. package/dist/skills/katlux-providers/providers/useVirtualDataset.md +154 -0
  204. package/dist/skills/katlux-tokens/SKILL.md +2 -1
  205. package/dist/types.d.mts +1 -1
  206. package/package.json +9 -3
  207. package/bin/add-ai-reference.mjs +0 -259
package/bin/cli.mjs CHANGED
@@ -4,16 +4,16 @@
4
4
  *
5
5
  * Supported commands:
6
6
  * npx @katlux/toolkit create-preset <preset-name> [--base=<base>]
7
- * npx @katlux/toolkit katlux-add-ref
8
- *
9
- * katlux-add-ref installs 5 focused AI skill files under .agents/skills/katlux-*
10
- * and scaffolds AGENTS.md + .agents/rules/rules.md if they don't exist.
7
+ * npx @katlux/toolkit katlux-ai-init [options]
8
+ * npx @katlux/toolkit tokens [--report]
9
+ * npx @katlux/toolkit mcp [args...]
11
10
  */
12
11
 
13
12
  import { spawn } from 'child_process'
14
13
  import { existsSync } from 'fs'
15
14
  import { resolve, dirname } from 'path'
16
15
  import { fileURLToPath } from 'url'
16
+ import { resolvePackageVersions } from './ai-init.mjs'
17
17
 
18
18
  const __dirname = dirname(fileURLToPath(import.meta.url))
19
19
 
@@ -21,11 +21,10 @@ const RESET = '\x1b[0m'
21
21
  const CYAN = '\x1b[36m'
22
22
  const BOLD = '\x1b[1m'
23
23
  const RED = '\x1b[31m'
24
+ const YELLOW = '\x1b[33m'
25
+ const DIM = '\x1b[2m'
24
26
 
25
- const args = process.argv.slice(2)
26
- const command = args[0]
27
-
28
- function printHelp() {
27
+ export function printHelp() {
29
28
  console.log(`
30
29
  ${BOLD}Katlux Toolkit CLI${RESET}
31
30
 
@@ -37,55 +36,93 @@ ${BOLD}Commands:${RESET}
37
36
  Scaffold a new custom preset (e.g. "cyber-brand --base=modern").
38
37
  Any preset can be token-only. Base presets leverage cascading inheritance without copying files.
39
38
 
40
- ${CYAN}katlux-add-ref${RESET}
41
- Download or update 5 focused Katlux AI skill files into .agents/skills/katlux-*/SKILL.md.
42
- Also scaffolds AGENTS.md, rules, and auto-configures MCP server for your IDE.
39
+ ${CYAN}katlux-ai-init [options]${RESET}
40
+ Initialize Katlux AI skills, context (AGENTS.md), and configure MCP server.
41
+ Flags: --cursor, --vscode, --all, --scripts, --dry-run, --force.
42
+
43
+ ${CYAN}tokens [--report] [-w <week>] [-p <page>]${RESET}
44
+ Analyze AI conversation token usage, week-by-week trends, and session logs.
43
45
 
44
46
  ${CYAN}mcp${RESET}
45
47
  Start the Katlux Model Context Protocol (MCP) server over stdio for AI coding assistants.
48
+ Pins @katlux/mcp version to match installed @katlux/toolkit.
46
49
 
47
50
  ${BOLD}Examples:${RESET}
51
+ npx @katlux/toolkit katlux-ai-init --all
52
+ npx @katlux/toolkit katlux-ai-init --cursor
53
+ npx @katlux/toolkit tokens --report
48
54
  npx @katlux/toolkit create-preset cyber-brand --base=modern
49
- npx @katlux/toolkit create-preset my-theme
50
- npx @katlux/toolkit katlux-add-ref
51
55
  npx @katlux/toolkit mcp
52
56
  `)
53
57
  }
54
58
 
55
- if (!command || command === '--help' || command === '-h' || command === 'help') {
56
- printHelp()
57
- process.exit(0)
59
+ /**
60
+ * Resolves the pinned MCP command and arguments for spawning npx.
61
+ */
62
+ export function resolveMcpCommand(projectRoot = process.cwd(), extraArgs = []) {
63
+ const { mcpVersion } = resolvePackageVersions(projectRoot)
64
+ const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx'
65
+ return {
66
+ command: npxCmd,
67
+ args: ['-y', `@katlux/mcp@${mcpVersion}`, ...extraArgs],
68
+ mcpVersion
69
+ }
58
70
  }
59
71
 
60
- let scriptPath = null
61
- let forwardedArgs = []
62
-
63
- if (command === 'create-preset') {
64
- scriptPath = resolve(__dirname, 'create-preset.mjs')
65
- forwardedArgs = args.slice(1)
66
- } else if (command === 'katlux-add-ref' || command === 'add-ref') {
67
- scriptPath = resolve(__dirname, 'add-ai-reference.mjs')
68
- forwardedArgs = args.slice(1)
69
- } else if (command === 'mcp') {
70
- const localMcpBin = resolve(__dirname, '../../katlux-mcp/bin/katlux-mcp.mjs')
71
- if (existsSync(localMcpBin)) {
72
- scriptPath = localMcpBin
73
- forwardedArgs = args.slice(1)
74
- } else {
75
- const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx'
76
- const child = spawn(npxCmd, ['-y', '@katlux/mcp', ...args.slice(1)], { stdio: 'inherit' })
72
+ /**
73
+ * Main dispatcher logic
74
+ */
75
+ export function runCli(argv = process.argv.slice(2)) {
76
+ const command = argv[0]
77
+
78
+ if (!command || command === '--help' || command === '-h' || command === 'help') {
79
+ printHelp()
80
+ return { status: 'help' }
81
+ }
82
+
83
+ let scriptPath = null
84
+ let forwardedArgs = []
85
+
86
+ if (command === 'create-preset') {
87
+ scriptPath = resolve(__dirname, 'create-preset.mjs')
88
+ forwardedArgs = argv.slice(1)
89
+ } else if (command === 'katlux-ai-init' || command === 'ai-init') {
90
+ scriptPath = resolve(__dirname, 'ai-init.mjs')
91
+ forwardedArgs = argv.slice(1)
92
+ } else if (command === 'tokens' || command === 'ai-tokens') {
93
+ scriptPath = resolve(__dirname, 'ai-tokens.mjs')
94
+ forwardedArgs = argv.slice(1)
95
+ } else if (command === 'mcp') {
96
+ const { command: npxCmd, args: mcpArgs, mcpVersion } = resolveMcpCommand(process.cwd(), argv.slice(1))
97
+ const child = spawn(npxCmd, mcpArgs, { stdio: 'inherit' })
77
98
  child.on('exit', (code) => process.exit(code ?? 0))
99
+ return { status: 'spawned', child, command: npxCmd, args: mcpArgs, mcpVersion }
100
+ } else {
101
+ console.log(`${RED}${BOLD}[katlux] ✖${RESET} Unknown command: "${command}"`)
102
+ printHelp()
103
+ process.exit(1)
104
+ }
105
+
106
+ if (scriptPath) {
107
+ const child = spawn(process.execPath, [scriptPath, ...forwardedArgs], {
108
+ stdio: 'inherit',
109
+ })
110
+
111
+ child.on('exit', (code) => {
112
+ process.exit(code ?? 0)
113
+ })
114
+ return { status: 'spawned', child, scriptPath, args: forwardedArgs }
78
115
  }
79
- } else {
80
- console.log(`${RED}${BOLD}[katlux] ✖${RESET} Unknown command: "${command}"`)
81
- printHelp()
82
- process.exit(1)
83
116
  }
84
117
 
85
- const child = spawn(process.execPath, [scriptPath, ...forwardedArgs], {
86
- stdio: 'inherit',
87
- })
118
+ // Execute directly if run as CLI script
119
+ const isMain = process.argv[1] && (
120
+ process.argv[1].endsWith('cli.mjs') ||
121
+ process.argv[1].endsWith('katlux') ||
122
+ process.argv[1].endsWith('katlux-toolkit') ||
123
+ process.argv[1].endsWith('toolkit')
124
+ )
88
125
 
89
- child.on('exit', (code) => {
90
- process.exit(code ?? 0)
91
- })
126
+ if (isMain) {
127
+ runCli()
128
+ }
@@ -602,3 +602,4 @@ const isMain = process.argv[1] && (
602
602
  if (isMain) {
603
603
  runCli()
604
604
  }
605
+