@katlux/toolkit 0.1.1-alpha.146 → 0.1.1-alpha.148
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.
- package/README.md +32 -22
- package/bin/ai-init.mjs +71 -13
- package/bin/ai-tokens/adapters/antigravityAdapter.mjs +22 -0
- package/bin/ai-tokens/adapters/claudeCodeAdapter.mjs +192 -0
- package/bin/ai-tokens/adapters/codexAdapter.mjs +176 -0
- package/bin/ai-tokens/adapters/cursorAdapter.mjs +202 -0
- package/bin/ai-tokens/adapters/index.mjs +30 -0
- package/bin/ai-tokens/cliViews.mjs +301 -0
- package/bin/ai-tokens/formatAndDates.mjs +89 -0
- package/bin/ai-tokens/reportGenerator.mjs +232 -0
- package/bin/ai-tokens/transcriptParser.mjs +299 -0
- package/bin/ai-tokens.mjs +38 -1030
- package/bin/cli.mjs +14 -10
- package/bin/preset-contracts.json +66 -10
- package/dist/compiled/composables/locales/asianAndPacific.mjs +296 -0
- package/dist/compiled/composables/locales/northernAndEasternEuropean.mjs +342 -0
- package/dist/compiled/composables/locales/westernEuropean.mjs +268 -0
- package/dist/compiled/composables/locales.mjs +28 -895
- package/dist/compiled/composables/useDataProvider.mjs +3 -1
- package/dist/compiled/composables/useKatluxForm.mjs +7 -7
- package/dist/compiled/composables/usePresetComponent.mjs +2 -0
- package/dist/compiled/composables/useRequestQueue.mjs +3 -1
- package/dist/compiled/composables/useVirtualDataset.mjs +322 -354
- package/dist/compiled/composables/useVirtualScroll.mjs +69 -62
- package/dist/compiled/composables/virtualDataset/cacheStateHelpers.mjs +76 -0
- package/dist/compiled/composables/virtualDataset/keyboardNavHelpers.mjs +60 -0
- package/dist/compiled/composables/virtualDataset/treeSelectionHelpers.mjs +103 -0
- package/dist/compiled/composables/virtualDataset/types.mjs +0 -0
- package/dist/compiled/utils/deprecation.mjs +44 -0
- package/dist/compiled/utils/dom.mjs +124 -0
- package/dist/module.cjs +0 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -6
- package/dist/runtime/app.config.d.ts +3 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +8 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +21 -55
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
- package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +4 -4
- package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +4 -4
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +8 -4
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +4 -0
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +2 -0
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +41 -26
- package/dist/runtime/components/KCalendar/recurringUtils.js +6 -5
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +17 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -4
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +17 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +10 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +32 -13
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +1 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue +4 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.d.ts +24 -4
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +43 -27
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +24 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +19 -7
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +24 -1
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +20 -0
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +54 -14
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +6 -5
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +6 -4
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +45 -26
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +6 -4
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +2 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +66 -20
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +3 -3
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +3 -2
- package/dist/runtime/components/KDropdown/KDropdown.logic.js +14 -13
- package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +3 -1
- package/dist/runtime/components/KGantt/KGantt.global.vue +7 -1
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +3 -1
- package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
- package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
- package/dist/runtime/components/KLayout/KLayout.global.d.vue.ts +4 -1
- package/dist/runtime/components/KLayout/KLayout.global.vue +4 -1
- package/dist/runtime/components/KLayout/KLayout.global.vue.d.ts +4 -1
- package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +9 -0
- package/dist/runtime/components/KLoader/KLoader.global.vue +1 -0
- package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +9 -0
- package/dist/runtime/components/KLoader/KLoader.logic.d.ts +5 -0
- package/dist/runtime/components/KLoader/KLoader.logic.js +4 -0
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +30 -7
- package/dist/runtime/components/KMultiTabs/KMultiTabs.logic.d.ts +1 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +6 -4
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +17 -9
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTabs/KTabs.logic.js +33 -11
- package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +12 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +8 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +12 -1
- package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +5 -0
- package/dist/runtime/components/KTextbox/KTextbox.logic.js +4 -0
- package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.logic.d.ts +11 -2
- package/dist/runtime/components/KTooltip/KTooltip.logic.js +7 -5
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTree/KTree.logic.js +21 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +8 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +8 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +10 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +1 -1
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +36 -12
- package/dist/runtime/composables/locales/asianAndPacific.d.ts +11 -0
- package/dist/runtime/composables/locales/asianAndPacific.js +296 -0
- package/dist/runtime/composables/locales/northernAndEasternEuropean.d.ts +12 -0
- package/dist/runtime/composables/locales/northernAndEasternEuropean.js +342 -0
- package/dist/runtime/composables/locales/westernEuropean.d.ts +10 -0
- package/dist/runtime/composables/locales/westernEuropean.js +268 -0
- package/dist/runtime/composables/locales.d.ts +4 -24
- package/dist/runtime/composables/locales.js +28 -895
- package/dist/runtime/composables/useDataProvider.js +3 -1
- package/dist/runtime/composables/useKatluxForm.js +7 -7
- package/dist/runtime/composables/usePresetComponent.js +2 -0
- package/dist/runtime/composables/useRequestQueue.d.ts +2 -0
- package/dist/runtime/composables/useRequestQueue.js +3 -1
- package/dist/runtime/composables/useVirtualDataset.d.ts +6 -118
- package/dist/runtime/composables/useVirtualDataset.js +322 -354
- package/dist/runtime/composables/useVirtualScroll.d.ts +9 -9
- package/dist/runtime/composables/useVirtualScroll.js +69 -62
- package/dist/runtime/composables/virtualDataset/cacheStateHelpers.d.ts +49 -0
- package/dist/runtime/composables/virtualDataset/cacheStateHelpers.js +76 -0
- package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.d.ts +26 -0
- package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.js +60 -0
- package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.d.ts +24 -0
- package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.js +103 -0
- package/dist/runtime/composables/virtualDataset/types.d.ts +113 -0
- package/dist/runtime/composables/virtualDataset/types.js +0 -0
- package/dist/runtime/directives/clickOutside.d.ts +1 -1
- package/dist/runtime/directives/clickOutside.js +41 -13
- package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -1
- package/dist/runtime/plugins/nuxtCompatPlugin.js +7 -0
- package/dist/runtime/plugins/toastPlugin.client.js +2 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +24 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +6 -5
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +27 -17
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +10 -10
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +60 -21
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +12 -1
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +109 -15
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +12 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +14 -0
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +5 -2
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +15 -12
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +5 -2
- package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +10 -0
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +23 -69
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +10 -0
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +22 -8
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue.d.ts +6 -2
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue +2 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue +13 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -94
- package/dist/runtime/presets/default/components/KMultiTabs/KMultiTabs.vue +69 -4
- package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +18 -46
- package/dist/runtime/presets/default/components/KSlider/KSlider.vue +11 -23
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +24 -8
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KTree/KTree.vue +51 -80
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue +12 -2
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue.d.ts +1 -0
- package/dist/runtime/server/middleware/session.js +7 -0
- package/dist/runtime/utils/deprecation.d.ts +14 -0
- package/dist/runtime/utils/deprecation.js +44 -0
- package/dist/runtime/utils/dom.d.ts +31 -0
- package/dist/runtime/utils/dom.js +124 -0
- package/dist/skills/KATLUX_INDEX.md +15 -19
- package/dist/skills/katlux-components/components/KBulkActions.md +1 -1
- package/dist/skills/katlux-components/components/KDataIterator.md +5 -0
- package/dist/skills/katlux-components/components/KLayout.md +4 -0
- package/dist/skills/katlux-components/components/KLoader.md +3 -0
- package/dist/skills/katlux-components/components/KTextbox.md +1 -0
- package/dist/skills/katlux-config/SKILL.md +15 -7
- package/dist/skills/katlux-presets/SKILL.md +42 -2
- package/dist/skills/katlux-providers/SKILL.md +12 -0
- package/dist/skills/katlux-providers/providers/ADataProvider.md +1 -0
- package/dist/skills/katlux-providers/providers/CAPITreeServerDataProvider.md +13 -0
- package/dist/skills/katlux-providers/providers/RequestProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +5 -2
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +5 -2
- package/dist/skills/katlux-providers/providers/encryption-searchable.md +150 -27
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +4 -1
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +12 -6
- package/dist/skills/katlux-providers/providers/encryption.md +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,50 +1,60 @@
|
|
|
1
1
|
# @katlux/toolkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@katlux/toolkit)
|
|
4
|
+
[](./LICENSE)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Core UI toolkit, WAI-ARIA accessible components, preset system, and Nuxt 3 module for the Katlux framework.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## Installation
|
|
8
9
|
|
|
9
|
-
### Option 1:
|
|
10
|
-
Use the Nuxt CLI to
|
|
10
|
+
### Option 1: Nuxt CLI (Recommended)
|
|
11
|
+
Use the Nuxt CLI to install `@katlux/toolkit` (or a preset such as `@katlux/preset-modern`) and register it in `nuxt.config.ts`:
|
|
11
12
|
```bash
|
|
12
|
-
npx nuxi module add @katlux/
|
|
13
|
+
npx nuxi module add @katlux/toolkit@alpha
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
### Option 2: Manual Installation
|
|
16
|
-
1. Install the preset package via your favorite package manager:
|
|
17
17
|
```bash
|
|
18
|
-
npm install @katlux/
|
|
18
|
+
npm install @katlux/toolkit@alpha
|
|
19
19
|
```
|
|
20
|
-
*(This automatically installs `@katlux/toolkit@alpha` and data providers under the hood)*
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
Add the module to your `nuxt.config.ts`:
|
|
23
22
|
```ts
|
|
24
23
|
export default defineNuxtConfig({
|
|
25
24
|
modules: [
|
|
26
|
-
'@katlux/
|
|
25
|
+
'@katlux/toolkit'
|
|
27
26
|
]
|
|
28
27
|
})
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
- Globally
|
|
33
|
-
-
|
|
34
|
-
-
|
|
30
|
+
Katlux automatically:
|
|
31
|
+
- Globally auto-imports all `K*` UI components, `C*` data providers, and `E*` enums.
|
|
32
|
+
- Installs `@nuxtjs/i18n` with default English fallbacks if you haven't already configured `@nuxtjs/i18n`.
|
|
33
|
+
- Registers Nitro SSR session isolation middleware and CSS design token variables.
|
|
34
|
+
- Keeps `katluxToolkit.autoAiReference` disabled (`false`) by default for zero unexpected file writes during `nuxt dev`.
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## CLI Utilities
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
```bash
|
|
39
|
+
# Install AI skill references (.agents/skills/) into your project
|
|
40
|
+
npx @katlux/toolkit katlux-ai-init --all
|
|
41
|
+
|
|
42
|
+
# Scaffold a custom visual preset
|
|
43
|
+
npx @katlux/toolkit create-preset my-preset
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Documentation & Changelog
|
|
47
|
+
|
|
48
|
+
- **Monorepo Repository**: [https://github.com/katlux-ui/KatluxShowcase](https://github.com/katlux-ui/KatluxShowcase)
|
|
49
|
+
- **Changelog & Migration Guide**: [CHANGELOG.md](https://github.com/katlux-ui/KatluxShowcase/blob/dev/CHANGELOG.md)
|
|
40
50
|
|
|
41
51
|
## Attributions
|
|
42
52
|
|
|
43
|
-
This project includes SVG icons from [Lucide](https://lucide.dev/),
|
|
53
|
+
This project includes SVG icons from [Lucide](https://lucide.dev/), licensed under the ISC License.
|
|
44
54
|
|
|
45
55
|
## License & Trademark Policy
|
|
46
56
|
|
|
47
|
-
The code in this repository is completely free and open-source under the Apache 2.0 License.
|
|
48
|
-
However, **Katlux™** and the Katlux logo are unregistered trademarks of the Katlux project.
|
|
57
|
+
The code in this repository is completely free and open-source under the **Apache 2.0 License** (see [LICENSE](./LICENSE)).
|
|
58
|
+
However, **Katlux™** and the Katlux logo are unregistered trademarks of the Katlux project.
|
|
49
59
|
|
|
50
|
-
To protect our users from fraud, you may not use the "Katlux" name or logo to brand your own modified forks, derivative works, or malicious distributions without explicit permission. You are, however, completely free to state "Built with Katlux" in your projects!
|
|
60
|
+
To protect our users from fraud, you may not use the "Katlux" name or logo to brand your own modified forks, derivative works, or malicious distributions without explicit permission. You are, however, completely free to state "Built with Katlux" in your projects!
|
package/bin/ai-init.mjs
CHANGED
|
@@ -64,8 +64,8 @@ export function stripJsonComments(jsonString) {
|
|
|
64
64
|
* Determines current Katlux package version and compatible MCP version.
|
|
65
65
|
*/
|
|
66
66
|
export function resolvePackageVersions(projectRoot) {
|
|
67
|
-
let toolkitVersion = '0.1.1-alpha.
|
|
68
|
-
let mcpVersion = '0.1.0-alpha.
|
|
67
|
+
let toolkitVersion = '0.1.1-alpha.147'
|
|
68
|
+
let mcpVersion = '0.1.0-alpha.26'
|
|
69
69
|
|
|
70
70
|
try {
|
|
71
71
|
const pkgPath = resolve(__dirname, '../package.json')
|
|
@@ -77,7 +77,7 @@ export function resolvePackageVersions(projectRoot) {
|
|
|
77
77
|
} catch {}
|
|
78
78
|
|
|
79
79
|
try {
|
|
80
|
-
const mcpPkgPath = resolve(__dirname, '../../katlux-mcp/package.json')
|
|
80
|
+
const mcpPkgPath = resolve(__dirname, '../../katlux-mcp-core/package.json')
|
|
81
81
|
if (existsSync(mcpPkgPath)) {
|
|
82
82
|
const mcpPkg = JSON.parse(readFileSync(mcpPkgPath, 'utf-8'))
|
|
83
83
|
if (mcpPkg.version) mcpVersion = mcpPkg.version
|
|
@@ -86,7 +86,7 @@ export function resolvePackageVersions(projectRoot) {
|
|
|
86
86
|
|
|
87
87
|
if (projectRoot) {
|
|
88
88
|
try {
|
|
89
|
-
const consumerMcpPkg = resolve(projectRoot, 'node_modules/@katlux/mcp/package.json')
|
|
89
|
+
const consumerMcpPkg = resolve(projectRoot, 'node_modules/@katlux/mcp-core/package.json')
|
|
90
90
|
if (existsSync(consumerMcpPkg)) {
|
|
91
91
|
const mcpPkg = JSON.parse(readFileSync(consumerMcpPkg, 'utf-8'))
|
|
92
92
|
if (mcpPkg.version) mcpVersion = mcpPkg.version
|
|
@@ -139,8 +139,8 @@ export function updateMcpConfig({
|
|
|
139
139
|
type: 'stdio',
|
|
140
140
|
command: isMonorepo ? 'node' : 'npx',
|
|
141
141
|
args: isMonorepo
|
|
142
|
-
? ['packages/katlux-mcp/bin/katlux-mcp.mjs']
|
|
143
|
-
: ['-y', `@katlux/mcp@${mcpVersion}`]
|
|
142
|
+
? ['packages/katlux-mcp-core/bin/katlux-mcp-core.mjs']
|
|
143
|
+
: ['-y', `@katlux/mcp-core@${mcpVersion}`]
|
|
144
144
|
}
|
|
145
145
|
} else {
|
|
146
146
|
// Cursor & Antigravity/Agents format uses root "mcpServers"
|
|
@@ -150,8 +150,8 @@ export function updateMcpConfig({
|
|
|
150
150
|
config.mcpServers.katlux = {
|
|
151
151
|
command: isMonorepo ? 'node' : 'npx',
|
|
152
152
|
args: isMonorepo
|
|
153
|
-
? ['packages/katlux-mcp/bin/katlux-mcp.mjs']
|
|
154
|
-
: ['-y', `@katlux/mcp@${mcpVersion}`]
|
|
153
|
+
? ['packages/katlux-mcp-core/bin/katlux-mcp-core.mjs']
|
|
154
|
+
: ['-y', `@katlux/mcp-core@${mcpVersion}`]
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -167,6 +167,48 @@ export function updateMcpConfig({
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Updates VS Code workspace settings (.vscode/settings.json) non-destructively
|
|
172
|
+
* to enable MCP server autostart and discovery.
|
|
173
|
+
*/
|
|
174
|
+
export function updateVsCodeSettings({ filePath, dryRun = false }) {
|
|
175
|
+
const dir = dirname(filePath)
|
|
176
|
+
let rawContent = ''
|
|
177
|
+
let config = {}
|
|
178
|
+
|
|
179
|
+
if (existsSync(filePath)) {
|
|
180
|
+
try {
|
|
181
|
+
rawContent = readFileSync(filePath, 'utf-8')
|
|
182
|
+
const cleanJson = stripJsonComments(rawContent)
|
|
183
|
+
config = JSON.parse(cleanJson)
|
|
184
|
+
} catch (err) {
|
|
185
|
+
return {
|
|
186
|
+
status: 'parse_error',
|
|
187
|
+
error: err.message,
|
|
188
|
+
filePath
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
|
|
194
|
+
config = {}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
config['chat.mcp.autostart'] = 'newAndOutdated'
|
|
198
|
+
config['chat.mcp.discovery.enabled'] = true
|
|
199
|
+
|
|
200
|
+
if (!dryRun) {
|
|
201
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
202
|
+
writeFileSync(filePath, JSON.stringify(config, null, 2) + '\n', 'utf-8')
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
status: 'success',
|
|
207
|
+
filePath,
|
|
208
|
+
config
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
170
212
|
/**
|
|
171
213
|
* Scaffolds AGENTS.md and .agents/rules/rules.md only if missing.
|
|
172
214
|
*/
|
|
@@ -213,7 +255,7 @@ This file serves as the main entry point for AI agents to understand the workspa
|
|
|
213
255
|
|
|
214
256
|
## Katlux AI Pairing & Token Efficiency Standards
|
|
215
257
|
|
|
216
|
-
1. **MCP Tools First**: Always call Katlux MCP tools (\`
|
|
258
|
+
1. **MCP Tools First**: Always call Katlux MCP tools (\`katlux_inspect_project\`, \`katlux_query\`, \`katlux_scaffold\`, \`katlux_validate_code\`) for exact component APIs, slots, props, and provider options (~200 tokens) instead of searching or reading deep package source files.
|
|
217
259
|
2. **Surgical File Reads**: When inspecting code, use targeted line ranges (30–50 lines maximum). Pinpoint lines with symbol searches or grep before reading.
|
|
218
260
|
3. **Compact Test Execution**: When running tests during AI pairing, use compact flags (e.g. \`--changed\`, \`--reporter=summary\`, or \`--reporter=agent\`) to prevent verbose logs from consuming context tokens.
|
|
219
261
|
4. **Focused Sessions**: Complete one feature or bug per conversation session. Start a fresh session when moving to an unrelated task to keep the AI context lean and token-efficient.
|
|
@@ -385,7 +427,7 @@ ${BOLD}Options:${RESET}
|
|
|
385
427
|
const withVsCode = args.includes('--vscode') || args.includes('--all') || options.vscode || false
|
|
386
428
|
const withScripts = args.includes('--scripts') || options.scripts || false
|
|
387
429
|
|
|
388
|
-
const localMcpPath = resolve(projectRoot, 'packages/katlux-mcp/bin/katlux-mcp.mjs')
|
|
430
|
+
const localMcpPath = resolve(projectRoot, 'packages/katlux-mcp-core/bin/katlux-mcp-core.mjs')
|
|
389
431
|
const isMonorepo = existsSync(localMcpPath)
|
|
390
432
|
|
|
391
433
|
const { toolkitVersion, mcpVersion } = resolvePackageVersions(projectRoot)
|
|
@@ -439,7 +481,7 @@ ${BOLD}Options:${RESET}
|
|
|
439
481
|
dryRun
|
|
440
482
|
})
|
|
441
483
|
if (agentsMcp.status === 'success') {
|
|
442
|
-
log(GREEN, ' configured', `.agents/mcp_config.json ${DIM}(@katlux/mcp@${mcpVersion})${RESET}`)
|
|
484
|
+
log(GREEN, ' configured', `.agents/mcp_config.json ${DIM}(@katlux/mcp-core@${mcpVersion})${RESET}`)
|
|
443
485
|
} else {
|
|
444
486
|
log(YELLOW, ' warning', `Failed to parse .agents/mcp_config.json: ${agentsMcp.error}. File was left untouched.`)
|
|
445
487
|
}
|
|
@@ -478,8 +520,19 @@ ${BOLD}Options:${RESET}
|
|
|
478
520
|
} else {
|
|
479
521
|
log(YELLOW, ' warning', `Failed to parse .vscode/mcp.json: ${vscodeMcp.error}. File was left untouched.`)
|
|
480
522
|
}
|
|
523
|
+
|
|
524
|
+
const vscodeSettingsPath = resolve(projectRoot, '.vscode/settings.json')
|
|
525
|
+
const vscodeSettings = updateVsCodeSettings({
|
|
526
|
+
filePath: vscodeSettingsPath,
|
|
527
|
+
dryRun
|
|
528
|
+
})
|
|
529
|
+
if (vscodeSettings.status === 'success') {
|
|
530
|
+
log(GREEN, ' configured', `.vscode/settings.json ${DIM}(chat.mcp.autostart & discovery enabled)${RESET}`)
|
|
531
|
+
} else {
|
|
532
|
+
log(YELLOW, ' warning', `Failed to parse .vscode/settings.json: ${vscodeSettings.error}. File was left untouched.`)
|
|
533
|
+
}
|
|
481
534
|
} else {
|
|
482
|
-
log(DIM, ' info', `Run with --vscode to configure VS Code (.vscode/mcp.json)`)
|
|
535
|
+
log(DIM, ' info', `Run with --vscode to configure VS Code (.vscode/mcp.json & .vscode/settings.json)`)
|
|
483
536
|
}
|
|
484
537
|
|
|
485
538
|
// 6. Scripts injection if requested
|
|
@@ -499,7 +552,12 @@ ${BOLD}Options:${RESET}
|
|
|
499
552
|
console.log(` ${CYAN}Index:${RESET} .agents/skills/KATLUX_INDEX.md`)
|
|
500
553
|
console.log(` ${CYAN}Context:${RESET} AGENTS.md`)
|
|
501
554
|
console.log(` ${CYAN}Rules:${RESET} .agents/rules/rules.md`)
|
|
502
|
-
console.log(` ${CYAN}MCP Server:${RESET} @katlux/mcp@${mcpVersion}`)
|
|
555
|
+
console.log(` ${CYAN}MCP Server:${RESET} @katlux/mcp-core@${mcpVersion}`)
|
|
556
|
+
if (withVsCode) {
|
|
557
|
+
console.log()
|
|
558
|
+
console.log(` ${DIM}💡 VS Code Notice:${RESET} Ensure ${CYAN}Workspace Trust${RESET} is granted and Copilot is in ${CYAN}Agent Mode${RESET}.`)
|
|
559
|
+
console.log(` MCP tools connect on the first prompt or via ${CYAN}MCP: List Servers${RESET}.`)
|
|
560
|
+
}
|
|
503
561
|
console.log()
|
|
504
562
|
return 0
|
|
505
563
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BRAIN_DIR } from '../formatAndDates.mjs'
|
|
2
|
+
import {
|
|
3
|
+
analyzeSession,
|
|
4
|
+
getConversationPreviewFast,
|
|
5
|
+
getConversations,
|
|
6
|
+
parseTranscript
|
|
7
|
+
} from '../transcriptParser.mjs'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Antigravity IDE transcript adapter.
|
|
11
|
+
* Wraps the default transcriptParser functions for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export const antigravityAdapter = {
|
|
14
|
+
name: 'antigravity',
|
|
15
|
+
displayName: 'Antigravity',
|
|
16
|
+
emptyMessage: `No conversations found in ${BRAIN_DIR}`,
|
|
17
|
+
getConversations,
|
|
18
|
+
getConversationPreviewFast,
|
|
19
|
+
parseTranscript,
|
|
20
|
+
analyzeSession
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { basename, dirname, join } from 'node:path'
|
|
4
|
+
import { estimateTokens, getWeekKey } from '../formatAndDates.mjs'
|
|
5
|
+
import { analyzeSession } from '../transcriptParser.mjs'
|
|
6
|
+
|
|
7
|
+
export const getClaudeProjectsDir = () =>
|
|
8
|
+
process.env.CLAUDE_PROJECTS_DIR || join(homedir(), '.claude', 'projects')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Extracts a readable project name from a Claude Code project directory slug
|
|
12
|
+
* (e.g. `-home-user-projects-MyApp` -> `MyApp`).
|
|
13
|
+
*/
|
|
14
|
+
function projectFromSlug(slug) {
|
|
15
|
+
if (!slug) return 'Unknown'
|
|
16
|
+
const parts = slug.split('-').filter(Boolean)
|
|
17
|
+
return parts[parts.length - 1] || slug
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Extracts plain text from a Claude Code message content field
|
|
22
|
+
* (which may be a string or an array of content blocks).
|
|
23
|
+
*/
|
|
24
|
+
function extractTextFromContent(content) {
|
|
25
|
+
if (typeof content === 'string') return content
|
|
26
|
+
if (!Array.isArray(content)) return ''
|
|
27
|
+
return content
|
|
28
|
+
.filter(block => block && (block.type === 'text' || typeof block.text === 'string'))
|
|
29
|
+
.map(block => block.text || '')
|
|
30
|
+
.join('\n')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Extracts tool_use blocks from a Claude Code assistant message content array.
|
|
35
|
+
*/
|
|
36
|
+
function extractToolCalls(content) {
|
|
37
|
+
if (!Array.isArray(content)) return undefined
|
|
38
|
+
const calls = content
|
|
39
|
+
.filter(block => block && block.type === 'tool_use')
|
|
40
|
+
.map(block => ({
|
|
41
|
+
name: block.name || 'unknown_tool',
|
|
42
|
+
arguments: block.input ? JSON.stringify(block.input) : ''
|
|
43
|
+
}))
|
|
44
|
+
return calls.length > 0 ? calls : undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Discovers Claude Code `.jsonl` session transcripts under `CLAUDE_PROJECTS_DIR`.
|
|
49
|
+
*/
|
|
50
|
+
export function getConversations(projectsDir = getClaudeProjectsDir()) {
|
|
51
|
+
if (!existsSync(projectsDir)) return []
|
|
52
|
+
|
|
53
|
+
const results = []
|
|
54
|
+
const projectDirs = readdirSync(projectsDir, { withFileTypes: true })
|
|
55
|
+
|
|
56
|
+
for (const pDir of projectDirs) {
|
|
57
|
+
if (!pDir.isDirectory() || pDir.name.startsWith('.')) continue
|
|
58
|
+
const fullProjectDir = join(projectsDir, pDir.name)
|
|
59
|
+
const files = readdirSync(fullProjectDir, { withFileTypes: true })
|
|
60
|
+
|
|
61
|
+
for (const f of files) {
|
|
62
|
+
if (!f.isFile() || !f.name.endsWith('.jsonl')) continue
|
|
63
|
+
const filePath = join(fullProjectDir, f.name)
|
|
64
|
+
const stat = statSync(filePath)
|
|
65
|
+
results.push({
|
|
66
|
+
id: f.name.replace(/\.jsonl$/, ''),
|
|
67
|
+
path: filePath,
|
|
68
|
+
createdAt: stat.birthtimeMs ? new Date(stat.birthtimeMs) : stat.mtime,
|
|
69
|
+
lastActive: stat.mtime,
|
|
70
|
+
mtime: stat.mtime,
|
|
71
|
+
weekKey: getWeekKey(stat.mtime),
|
|
72
|
+
project: projectFromSlug(pDir.name)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return results.sort((a, b) => b.lastActive.getTime() - a.lastActive.getTime())
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Fast preview metadata extractor for a Claude Code `.jsonl` transcript file.
|
|
82
|
+
*/
|
|
83
|
+
export function getConversationPreviewFast(filePath, searchQuery = '') {
|
|
84
|
+
if (!existsSync(filePath)) {
|
|
85
|
+
return {
|
|
86
|
+
title: '(Empty)',
|
|
87
|
+
fullTitle: '',
|
|
88
|
+
project: 'Unknown',
|
|
89
|
+
estimatedTokens: 0,
|
|
90
|
+
rawSize: 0,
|
|
91
|
+
matchesSearch: false
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const raw = readFileSync(filePath, 'utf8')
|
|
96
|
+
const rawSize = Buffer.byteLength(raw, 'utf8')
|
|
97
|
+
const estimatedTokens = estimateTokens(rawSize)
|
|
98
|
+
const matchesSearch = searchQuery ? raw.toLowerCase().includes(searchQuery.toLowerCase()) : false
|
|
99
|
+
|
|
100
|
+
let fullTitle = ''
|
|
101
|
+
let project = projectFromSlug(basename(dirname(filePath)))
|
|
102
|
+
|
|
103
|
+
for (const line of raw.split('\n')) {
|
|
104
|
+
if (!line.trim()) continue
|
|
105
|
+
try {
|
|
106
|
+
const entry = JSON.parse(line)
|
|
107
|
+
if (entry.cwd && project === 'Unknown') {
|
|
108
|
+
project = basename(entry.cwd)
|
|
109
|
+
}
|
|
110
|
+
if (entry.type === 'user' && entry.message) {
|
|
111
|
+
const text = extractTextFromContent(entry.message.content).replace(/[\r\n\t]+/g, ' ').trim()
|
|
112
|
+
if (text) {
|
|
113
|
+
fullTitle = text
|
|
114
|
+
break
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
// Skip malformed lines
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const title = fullTitle
|
|
123
|
+
? (fullTitle.length > 32 ? fullTitle.slice(0, 31) + '…' : fullTitle)
|
|
124
|
+
: '(No user prompt)'
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
title,
|
|
128
|
+
fullTitle,
|
|
129
|
+
project,
|
|
130
|
+
estimatedTokens,
|
|
131
|
+
rawSize,
|
|
132
|
+
matchesSearch
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Parses a Claude Code `.jsonl` transcript into the shared step format
|
|
138
|
+
* consumed by `analyzeSession`.
|
|
139
|
+
*/
|
|
140
|
+
export function parseTranscript(filePath) {
|
|
141
|
+
if (!existsSync(filePath)) return null
|
|
142
|
+
const raw = readFileSync(filePath, 'utf8')
|
|
143
|
+
const lines = raw.split('\n').filter(l => l.trim())
|
|
144
|
+
const steps = []
|
|
145
|
+
|
|
146
|
+
lines.forEach((line, idx) => {
|
|
147
|
+
try {
|
|
148
|
+
const entry = JSON.parse(line)
|
|
149
|
+
const msg = entry.message || {}
|
|
150
|
+
const role = msg.role || entry.type
|
|
151
|
+
const createdAt = entry.timestamp || entry.createdAt || undefined
|
|
152
|
+
|
|
153
|
+
if (role === 'user' || entry.type === 'user') {
|
|
154
|
+
const text = extractTextFromContent(msg.content ?? entry.content)
|
|
155
|
+
const hasToolResult = Array.isArray(msg.content) && msg.content.some(b => b?.type === 'tool_result')
|
|
156
|
+
steps.push({
|
|
157
|
+
step_index: idx + 1,
|
|
158
|
+
type: hasToolResult && !text ? 'TOOL_RESULT' : 'USER_INPUT',
|
|
159
|
+
content: text || (hasToolResult ? JSON.stringify(msg.content) : ''),
|
|
160
|
+
created_at: createdAt
|
|
161
|
+
})
|
|
162
|
+
} else if (role === 'assistant' || entry.type === 'assistant') {
|
|
163
|
+
const text = extractTextFromContent(msg.content ?? entry.content)
|
|
164
|
+
const toolCalls = extractToolCalls(msg.content)
|
|
165
|
+
steps.push({
|
|
166
|
+
step_index: idx + 1,
|
|
167
|
+
type: 'PLANNER_RESPONSE',
|
|
168
|
+
content: text,
|
|
169
|
+
tool_calls: toolCalls,
|
|
170
|
+
created_at: createdAt
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
// Skip malformed lines
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
return steps
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const claudeCodeAdapter = {
|
|
182
|
+
name: 'claude-code',
|
|
183
|
+
displayName: 'Claude Code',
|
|
184
|
+
get emptyMessage() {
|
|
185
|
+
return `No conversations found in ${getClaudeProjectsDir()}`
|
|
186
|
+
},
|
|
187
|
+
getConversations: () => getConversations(),
|
|
188
|
+
getConversationPreviewFast,
|
|
189
|
+
parseTranscript,
|
|
190
|
+
analyzeSession
|
|
191
|
+
}
|
|
192
|
+
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { basename, join } from 'node:path'
|
|
4
|
+
import { estimateTokens, getWeekKey } from '../formatAndDates.mjs'
|
|
5
|
+
import { analyzeSession } from '../transcriptParser.mjs'
|
|
6
|
+
|
|
7
|
+
export const getCodexSessionsDir = () =>
|
|
8
|
+
process.env.CODEX_SESSIONS_DIR || join(homedir(), '.codex', 'sessions')
|
|
9
|
+
|
|
10
|
+
function collectJsonlFiles(dir) {
|
|
11
|
+
const files = []
|
|
12
|
+
if (!existsSync(dir)) return files
|
|
13
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
14
|
+
const full = join(dir, entry.name)
|
|
15
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
16
|
+
files.push(...collectJsonlFiles(full))
|
|
17
|
+
} else if (entry.isFile() && entry.name.endsWith('.jsonl')) {
|
|
18
|
+
files.push(full)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return files
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function extractText(content) {
|
|
25
|
+
if (typeof content === 'string') return content
|
|
26
|
+
if (!Array.isArray(content)) return ''
|
|
27
|
+
return content
|
|
28
|
+
.filter(b => b && (b.type === 'input_text' || b.type === 'output_text' || b.type === 'text' || typeof b.text === 'string'))
|
|
29
|
+
.map(b => b.text || '')
|
|
30
|
+
.join('\n')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Discovers OpenAI Codex CLI `.jsonl` session transcripts under `CODEX_SESSIONS_DIR`.
|
|
35
|
+
*/
|
|
36
|
+
export function getConversations(sessionsDir = getCodexSessionsDir()) {
|
|
37
|
+
if (!existsSync(sessionsDir)) return []
|
|
38
|
+
|
|
39
|
+
const results = collectJsonlFiles(sessionsDir).map(filePath => {
|
|
40
|
+
const stat = statSync(filePath)
|
|
41
|
+
return {
|
|
42
|
+
id: basename(filePath, '.jsonl'),
|
|
43
|
+
path: filePath,
|
|
44
|
+
createdAt: stat.birthtimeMs ? new Date(stat.birthtimeMs) : stat.mtime,
|
|
45
|
+
lastActive: stat.mtime,
|
|
46
|
+
mtime: stat.mtime,
|
|
47
|
+
weekKey: getWeekKey(stat.mtime)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return results.sort((a, b) => b.lastActive.getTime() - a.lastActive.getTime())
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Fast preview metadata extractor for a Codex `.jsonl` session file.
|
|
56
|
+
*/
|
|
57
|
+
export function getConversationPreviewFast(filePath, searchQuery = '') {
|
|
58
|
+
if (!existsSync(filePath)) {
|
|
59
|
+
return {
|
|
60
|
+
title: '(Empty)',
|
|
61
|
+
fullTitle: '',
|
|
62
|
+
project: 'Unknown',
|
|
63
|
+
estimatedTokens: 0,
|
|
64
|
+
rawSize: 0,
|
|
65
|
+
matchesSearch: false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const raw = readFileSync(filePath, 'utf8')
|
|
70
|
+
const rawSize = Buffer.byteLength(raw, 'utf8')
|
|
71
|
+
const estimatedTokens = estimateTokens(rawSize)
|
|
72
|
+
const matchesSearch = searchQuery ? raw.toLowerCase().includes(searchQuery.toLowerCase()) : false
|
|
73
|
+
|
|
74
|
+
let project = 'Unknown'
|
|
75
|
+
let fullTitle = ''
|
|
76
|
+
|
|
77
|
+
for (const line of raw.split('\n')) {
|
|
78
|
+
if (!line.trim()) continue
|
|
79
|
+
try {
|
|
80
|
+
const entry = JSON.parse(line)
|
|
81
|
+
const payload = entry.payload || entry
|
|
82
|
+
if (entry.type === 'session_meta' && payload.cwd) {
|
|
83
|
+
project = basename(payload.cwd)
|
|
84
|
+
}
|
|
85
|
+
if (!fullTitle && entry.type === 'response_item' && payload.role === 'user') {
|
|
86
|
+
const text = extractText(payload.content).replace(/[\r\n\t]+/g, ' ').trim()
|
|
87
|
+
if (text) fullTitle = text
|
|
88
|
+
}
|
|
89
|
+
if (project !== 'Unknown' && fullTitle) break
|
|
90
|
+
} catch {
|
|
91
|
+
// Skip malformed lines
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const title = fullTitle
|
|
96
|
+
? (fullTitle.length > 32 ? fullTitle.slice(0, 31) + '…' : fullTitle)
|
|
97
|
+
: '(No user prompt)'
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
title,
|
|
101
|
+
fullTitle,
|
|
102
|
+
project,
|
|
103
|
+
estimatedTokens,
|
|
104
|
+
rawSize,
|
|
105
|
+
matchesSearch
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Parses a Codex `.jsonl` session into the shared step format
|
|
111
|
+
* consumed by `analyzeSession`.
|
|
112
|
+
*/
|
|
113
|
+
export function parseTranscript(filePath) {
|
|
114
|
+
if (!existsSync(filePath)) return null
|
|
115
|
+
const raw = readFileSync(filePath, 'utf8')
|
|
116
|
+
const lines = raw.split('\n').filter(l => l.trim())
|
|
117
|
+
const steps = []
|
|
118
|
+
|
|
119
|
+
lines.forEach((line, idx) => {
|
|
120
|
+
try {
|
|
121
|
+
const entry = JSON.parse(line)
|
|
122
|
+
const payload = entry.payload || entry
|
|
123
|
+
const createdAt = entry.timestamp || undefined
|
|
124
|
+
|
|
125
|
+
if (entry.type === 'response_item') {
|
|
126
|
+
if (payload.role === 'user') {
|
|
127
|
+
steps.push({
|
|
128
|
+
step_index: idx + 1,
|
|
129
|
+
type: 'USER_INPUT',
|
|
130
|
+
content: extractText(payload.content),
|
|
131
|
+
created_at: createdAt
|
|
132
|
+
})
|
|
133
|
+
} else if (payload.role === 'assistant') {
|
|
134
|
+
steps.push({
|
|
135
|
+
step_index: idx + 1,
|
|
136
|
+
type: 'PLANNER_RESPONSE',
|
|
137
|
+
content: extractText(payload.content),
|
|
138
|
+
created_at: createdAt
|
|
139
|
+
})
|
|
140
|
+
} else if (payload.type === 'function_call') {
|
|
141
|
+
steps.push({
|
|
142
|
+
step_index: idx + 1,
|
|
143
|
+
type: 'PLANNER_RESPONSE',
|
|
144
|
+
content: '',
|
|
145
|
+
tool_calls: [{ name: payload.name || 'unknown_tool', arguments: payload.arguments || '' }],
|
|
146
|
+
created_at: createdAt
|
|
147
|
+
})
|
|
148
|
+
} else if (payload.type === 'function_call_output') {
|
|
149
|
+
steps.push({
|
|
150
|
+
step_index: idx + 1,
|
|
151
|
+
type: 'TOOL_RESULT',
|
|
152
|
+
content: typeof payload.output === 'string' ? payload.output : JSON.stringify(payload.output ?? ''),
|
|
153
|
+
created_at: createdAt
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
// Skip malformed lines
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
return steps
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const codexAdapter = {
|
|
166
|
+
name: 'codex',
|
|
167
|
+
displayName: 'Codex',
|
|
168
|
+
get emptyMessage() {
|
|
169
|
+
return `No conversations found in ${getCodexSessionsDir()}`
|
|
170
|
+
},
|
|
171
|
+
getConversations: () => getConversations(),
|
|
172
|
+
getConversationPreviewFast,
|
|
173
|
+
parseTranscript,
|
|
174
|
+
analyzeSession
|
|
175
|
+
}
|
|
176
|
+
|