@katlux/toolkit 0.1.1-alpha.145 → 0.1.1-alpha.147
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 +575 -0
- 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 -872
- package/bin/cli.mjs +81 -48
- package/bin/create-preset.mjs +1 -0
- package/bin/preset-contracts.json +2997 -0
- 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 +32 -720
- package/dist/compiled/composables/useDataProvider.mjs +39 -26
- package/dist/compiled/composables/useFilterLogic.mjs +10 -2
- package/dist/compiled/composables/useKatluxForm.mjs +13 -11
- package/dist/compiled/composables/usePresetComponent.mjs +2 -0
- package/dist/compiled/composables/useRequestQueue.mjs +3 -1
- package/dist/compiled/composables/useVirtualDataset.mjs +657 -0
- package/dist/compiled/composables/useVirtualScroll.mjs +93 -66
- 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 +58 -77
- package/dist/module.d.cts +5 -0
- package/dist/module.d.mts +4 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +54 -77
- package/dist/runtime/app.config.d.ts +3 -0
- package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +1 -1
- package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +1 -1
- package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +7 -3
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +4 -1
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +7 -3
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +12 -2
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +40 -41
- 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 +19 -10
- package/dist/runtime/components/KCalendar/KCalendar.global.vue +7 -2
- package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +19 -10
- package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +14 -201
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +67 -14
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.d.vue.ts +25 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +15 -1
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue.d.ts +25 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +21 -3
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +136 -7
- package/dist/runtime/components/KCalendar/recurringUtils.js +6 -5
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +2 -2
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +2 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +18 -3
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -4
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +18 -3
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +16 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +32 -13
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +8 -8
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +8 -8
- package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
- 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 -22
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +38 -11
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +39 -20
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +38 -11
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +31 -8
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +69 -24
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +10 -14
- package/dist/runtime/components/KDatatable/KDatatable.global.vue +6 -5
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +10 -14
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -6
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +32 -24
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +33 -15
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +60 -16
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +33 -15
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +30 -6
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +249 -59
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +2 -0
- 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 +55 -4
- package/dist/runtime/components/KGantt/KGantt.global.vue +18 -3
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +55 -4
- package/dist/runtime/components/KGantt/KGantt.logic.d.ts +33 -5
- package/dist/runtime/components/KGantt/KGantt.logic.js +39 -6
- 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 +2 -2
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
- 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 +3 -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.global.d.vue.ts +2 -2
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +2 -2
- 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.d.vue.ts +23 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +24 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue.d.ts +23 -0
- package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +3 -1
- package/dist/runtime/components/KPagination/KPagination.global.vue +2 -1
- package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +3 -1
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +2 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +74 -14
- package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRadiobox/KRadiobox.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 +2 -2
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +2 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +15 -4
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +8 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +15 -4
- 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.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 +4 -4
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +4 -4
- package/dist/runtime/components/KTree/KTree.logic.d.ts +2 -2
- package/dist/runtime/components/KTree/KTree.logic.js +37 -13
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +7 -5
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -6
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +7 -5
- 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 +40 -6
- package/dist/runtime/components/KTreeView/KTreeView.global.vue +19 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +40 -6
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +24 -4
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +105 -11
- 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 +32 -720
- package/dist/runtime/composables/useDataProvider.d.ts +5 -3
- package/dist/runtime/composables/useDataProvider.js +39 -26
- package/dist/runtime/composables/useFilterLogic.d.ts +16 -4
- package/dist/runtime/composables/useFilterLogic.js +10 -2
- package/dist/runtime/composables/useKatluxForm.d.ts +4 -4
- package/dist/runtime/composables/useKatluxForm.js +13 -11
- 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/useSortLogic.d.ts +1 -1
- package/dist/runtime/composables/useVirtualDataset.d.ts +9 -0
- package/dist/runtime/composables/useVirtualDataset.js +657 -0
- package/dist/runtime/composables/useVirtualScroll.d.ts +14 -10
- package/dist/runtime/composables/useVirtualScroll.js +93 -66
- 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 +16 -1
- package/dist/runtime/plugins/toastPlugin.client.js +2 -2
- package/dist/runtime/presets/default/assets/scss/css-variables.css +3 -0
- package/dist/runtime/presets/default/assets/scss/css-variables.scss +6 -1
- package/dist/runtime/presets/default/assets/scss/index.css +3 -0
- package/dist/runtime/presets/default/assets/svg/katlux-logo.svg +7 -0
- package/dist/runtime/presets/default/assets/svg/katlux.svg +6 -0
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.d.vue.ts +3 -2
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +31 -3
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue.d.ts +3 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +6 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +7 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +57 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +7 -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 +67 -22
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +41 -8
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +184 -174
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +41 -8
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +17 -10
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +113 -394
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +17 -10
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +6 -0
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +71 -4
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +6 -0
- 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 +11 -2
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +46 -29
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +11 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +23 -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 +3 -3
- package/dist/runtime/presets/default/components/KTree/KTree.vue +61 -56
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +3 -3
- 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/presets/default/components/KTreeView/KTreeView.d.vue.ts +11 -2
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +14 -2
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +11 -2
- 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 +18 -19
- package/dist/skills/katlux-components/SKILL.md +2 -0
- package/dist/skills/katlux-components/components/KBulkActions.md +26 -2
- package/dist/skills/katlux-components/components/KCombobox.md +2 -2
- package/dist/skills/katlux-components/components/KDataIterator.md +17 -4
- package/dist/skills/katlux-components/components/KDatatable.md +38 -0
- package/dist/skills/katlux-components/components/KDatePicker.md +3 -1
- package/dist/skills/katlux-components/components/KGantt.md +9 -0
- package/dist/skills/katlux-components/components/KIcon.md +1 -1
- package/dist/skills/katlux-components/components/KLayout.md +4 -0
- package/dist/skills/katlux-components/components/KLineChart.md +3 -0
- package/dist/skills/katlux-components/components/KLoader.md +3 -0
- package/dist/skills/katlux-components/components/KProductList.md +0 -1
- package/dist/skills/katlux-components/components/KScatterChart.md +3 -0
- package/dist/skills/katlux-components/components/KTextbox.md +1 -0
- package/dist/skills/katlux-components/components/KTreePicker.md +2 -1
- package/dist/skills/katlux-components/components/KTreeView.md +12 -0
- package/dist/skills/katlux-config/SKILL.md +27 -8
- package/dist/skills/katlux-presets/SKILL.md +163 -3
- package/dist/skills/katlux-presets/creating-a-preset.md +67 -0
- package/dist/skills/katlux-providers/SKILL.md +19 -5
- package/dist/skills/katlux-providers/providers/ADataProvider.md +17 -9
- package/dist/skills/katlux-providers/providers/CAPIFlatClientDataProvider.md +27 -3
- package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +11 -1
- package/dist/skills/katlux-providers/providers/CAPITreeServerDataProvider.md +13 -0
- package/dist/skills/katlux-providers/providers/CFlatClientDataProvider.md +19 -4
- package/dist/skills/katlux-providers/providers/CFlatServerDataProvider.md +4 -2
- package/dist/skills/katlux-providers/providers/CTreeClientDataProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/RequestProvider.md +10 -0
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +67 -20
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +23 -2
- package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +25 -11
- package/dist/skills/katlux-providers/providers/encryption-searchable.md +341 -0
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +29 -2
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +70 -1
- package/dist/skills/katlux-providers/providers/encryption.md +26 -1
- package/dist/skills/katlux-providers/providers/types.md +3 -1
- package/dist/skills/katlux-providers/providers/useDataProvider.md +2 -1
- package/dist/skills/katlux-providers/providers/useVirtualDataset.md +154 -0
- package/dist/skills/katlux-tokens/SKILL.md +2 -1
- package/dist/types.d.mts +1 -1
- package/package.json +7 -3
- package/bin/add-ai-reference.mjs +0 -259
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { basename } from 'node:path'
|
|
2
|
+
import {
|
|
3
|
+
ANSI,
|
|
4
|
+
estimateTokens,
|
|
5
|
+
formatBytes,
|
|
6
|
+
formatDateTime,
|
|
7
|
+
formatTokens
|
|
8
|
+
} from './formatAndDates.mjs'
|
|
9
|
+
import { getIdeAdapter, SUPPORTED_IDES } from './adapters/index.mjs'
|
|
10
|
+
import { generateWeekReport, listDetectedProjects } from './reportGenerator.mjs'
|
|
11
|
+
|
|
12
|
+
const { RESET, BOLD, DIM, CYAN, GREEN, YELLOW, RED, MAGENTA, BLUE } = ANSI
|
|
13
|
+
|
|
14
|
+
/** Renders the paginated conversation browser list view. */
|
|
15
|
+
export function renderConversationListView({ filteredConversations, projectFilter, searchQuery, page, limit }) {
|
|
16
|
+
const total = filteredConversations.length
|
|
17
|
+
const totalPages = Math.max(1, Math.ceil(total / limit))
|
|
18
|
+
const safePage = Math.min(page, totalPages)
|
|
19
|
+
const startIndex = (safePage - 1) * limit
|
|
20
|
+
const pageItems = filteredConversations.slice(startIndex, startIndex + limit)
|
|
21
|
+
|
|
22
|
+
console.log(`\n${BOLD}╭──────────────────────────────────────────────────────────────────────────────╮${RESET}`)
|
|
23
|
+
console.log(`${BOLD}│ ANTIGRAVITY CONVERSATIONS BROWSER │${RESET}`)
|
|
24
|
+
console.log(`${BOLD}╰──────────────────────────────────────────────────────────────────────────────╯${RESET}`)
|
|
25
|
+
if (projectFilter) console.log(` Project Filter: ${GREEN}${projectFilter}${RESET}`)
|
|
26
|
+
if (searchQuery) console.log(` Filtered by: ${YELLOW}"${searchQuery}"${RESET} (${total} matching)`)
|
|
27
|
+
console.log(` Showing Page ${BOLD}${safePage}${RESET} of ${BOLD}${totalPages}${RESET} (${total === 0 ? 0 : startIndex + 1}–${Math.min(startIndex + limit, total)} of ${total} conversations)\n`)
|
|
28
|
+
|
|
29
|
+
if (total === 0) {
|
|
30
|
+
console.log(` ${RED}No conversations found matching criteria.${RESET}\n`)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log(` ${'#'.padStart(4)} ${'ID'.padEnd(9)} ${'PROJECT'.padEnd(16)} ${'WEEK'.padEnd(6)} ${'TOPIC / PROMPT'.padEnd(34)} ${'TOKENS'.padStart(8)} ${'LAST ACTIVE'.padEnd(19)} STARTED`)
|
|
35
|
+
console.log(` ${'─'.repeat(4)} ${'─'.repeat(9)} ${'─'.repeat(16)} ${'─'.repeat(6)} ${'─'.repeat(34)} ${'─'.repeat(8)} ${'─'.repeat(19)} ${'─'.repeat(19)}`)
|
|
36
|
+
|
|
37
|
+
pageItems.forEach(conv => {
|
|
38
|
+
const preview = conv.preview
|
|
39
|
+
const indexColor = conv.originalIndex === 1 ? GREEN : CYAN
|
|
40
|
+
console.log(
|
|
41
|
+
` ${indexColor}${String(conv.originalIndex).padStart(4)}${RESET} ` +
|
|
42
|
+
`${conv.id.slice(0, 8).padEnd(9)} ` +
|
|
43
|
+
`${YELLOW}${(preview.project || 'Unknown').slice(0, 15).padEnd(16)}${RESET} ` +
|
|
44
|
+
`${DIM}${conv.weekKey.replace('2026-', '').padEnd(6)}${RESET} ` +
|
|
45
|
+
`${preview.title.padEnd(34)} ` +
|
|
46
|
+
`${BOLD}${formatTokens(preview.estimatedTokens).padStart(8)}${RESET} ` +
|
|
47
|
+
`${GREEN}${formatDateTime(conv.lastActive).padEnd(19)}${RESET} ` +
|
|
48
|
+
`${DIM}${formatDateTime(conv.createdAt)}${RESET}`
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
console.log(`\n${BOLD}Navigation & Actions:${RESET}`)
|
|
53
|
+
if (safePage < totalPages) console.log(` • Next page: ${CYAN}npm run ai:tokens -- -p ${safePage + 1}${projectFilter ? ` -P ${projectFilter}` : ''}${RESET}`)
|
|
54
|
+
if (safePage > 1) console.log(` • Previous page: ${CYAN}npm run ai:tokens -- -p ${safePage - 1}${projectFilter ? ` -P ${projectFilter}` : ''}${RESET}`)
|
|
55
|
+
console.log(` • Filter project: ${CYAN}npm run ai:tokens -- -P <projectName>${RESET}`)
|
|
56
|
+
console.log(` • Weekly report: ${CYAN}${projectFilter ? `npm run ai:tokens -- --report -P ${projectFilter}` : 'npm run ai:tokens:report'}${RESET}`)
|
|
57
|
+
console.log(` • Inspect one: ${CYAN}npm run ai:tokens -- <#>${RESET} (e.g. ${CYAN}npm run ai:tokens -- ${pageItems[0]?.originalIndex}${RESET} or ${CYAN}npm run ai:tokens -- ${pageItems[0]?.id.slice(0, 8)}${RESET})`)
|
|
58
|
+
console.log(` • Detailed steps: ${CYAN}npm run ai:tokens -- <#> -d${RESET}\n`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Renders the detailed token breakdown and optional chronology for a single session. */
|
|
62
|
+
export function renderSingleConversationDetailView(selectedConv, allConversations, showDetail, adapter = getIdeAdapter('antigravity')) {
|
|
63
|
+
const steps = adapter.parseTranscript(selectedConv.path)
|
|
64
|
+
if (!steps) {
|
|
65
|
+
console.log(`${RED}No transcript found for conversation ${selectedConv.id}${RESET}`)
|
|
66
|
+
process.exit(1)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const previewMeta = adapter.getConversationPreviewFast(selectedConv.path)
|
|
70
|
+
const data = adapter.analyzeSession(steps, selectedConv.id, selectedConv.mtime, previewMeta.project)
|
|
71
|
+
const convIndex = allConversations.findIndex(c => c.id === selectedConv.id) + 1
|
|
72
|
+
|
|
73
|
+
console.log(`\n${BOLD}╭──────────────────────────────────────────────────────────────────────────╮${RESET}`)
|
|
74
|
+
console.log(`${BOLD}│ AI CONVERSATION TOKEN LOG │${RESET}`)
|
|
75
|
+
console.log(`${BOLD}╰──────────────────────────────────────────────────────────────────────────╯${RESET}`)
|
|
76
|
+
console.log(` ${BOLD}Conversation Index:${RESET} ${GREEN}#${convIndex}${RESET} of ${allConversations.length}`)
|
|
77
|
+
console.log(` ${BOLD}Project:${RESET} ${YELLOW}${data.project}${RESET} (${CYAN}${data.weekKey}${RESET})`)
|
|
78
|
+
console.log(` ${BOLD}Conversation ID:${RESET} ${CYAN}${data.conversationId}${RESET}`)
|
|
79
|
+
console.log(` ${BOLD}Topic / Prompt:${RESET} ${YELLOW}"${data.sessionTitle}"${RESET}`)
|
|
80
|
+
console.log(` ${BOLD}Started:${RESET} ${formatDateTime(selectedConv.createdAt)}`)
|
|
81
|
+
console.log(` ${BOLD}Last Active:${RESET} ${GREEN}${formatDateTime(selectedConv.lastActive)}${RESET}`)
|
|
82
|
+
console.log(` ${BOLD}Total Steps:${RESET} ${data.totalSteps} recorded steps`)
|
|
83
|
+
console.log(` ${BOLD}Transcript Size:${RESET} ${formatBytes(data.totalChars)} total characters\n`)
|
|
84
|
+
|
|
85
|
+
console.log(`${BOLD}Token Summary (Estimated BPE):${RESET}`)
|
|
86
|
+
console.log(` ${GREEN}● Total Tokens:${RESET} ${BOLD}${formatTokens(data.totalTokens)}${RESET} tokens (~${data.totalTokens.toLocaleString()})`)
|
|
87
|
+
console.log(` ${BLUE}↳ Input Tokens:${RESET} ${formatTokens(data.inputTokens)} tokens (${Math.round((data.inputTokens / data.totalTokens) * 100 || 0)}%)`)
|
|
88
|
+
console.log(` ${MAGENTA}↳ Output Tokens:${RESET} ${formatTokens(data.outputTokens)} tokens (${Math.round((data.outputTokens / data.totalTokens) * 100 || 0)}%)\n`)
|
|
89
|
+
|
|
90
|
+
console.log(`${BOLD}Approximate Model Cost (if fresh API query):${RESET}`)
|
|
91
|
+
const geminiCost = ((data.inputTokens / 1_000_000) * 0.35 + (data.outputTokens / 1_000_000) * 1.05).toFixed(4)
|
|
92
|
+
const claudeCost = ((data.inputTokens / 1_000_000) * 3.00 + (data.outputTokens / 1_000_000) * 15.00).toFixed(4)
|
|
93
|
+
const gptCost = ((data.inputTokens / 1_000_000) * 2.50 + (data.outputTokens / 1_000_000) * 10.00).toFixed(4)
|
|
94
|
+
console.log(` Gemini 1.5/2.0 Flash : ${GREEN}$${geminiCost}${RESET}`)
|
|
95
|
+
console.log(` Claude 3.5 Sonnet : ${YELLOW}$${claudeCost}${RESET}`)
|
|
96
|
+
console.log(` GPT-4o : ${CYAN}$${gptCost}${RESET}\n`)
|
|
97
|
+
|
|
98
|
+
if (data.userPrompts.length > 0) {
|
|
99
|
+
console.log(`${BOLD}Conversation Turns (${data.userPrompts.length} User Requests):${RESET}`)
|
|
100
|
+
const formatTurn = (p, idx, timeColor = DIM) => {
|
|
101
|
+
const timeLabel = p.time ? `${timeColor}(${p.time})${RESET} ` : ''
|
|
102
|
+
console.log(` ${CYAN}Turn ${idx + 1}${RESET} [Step #${p.step}] ${timeLabel}${p.text.slice(0, 85)}${p.text.length > 85 ? '...' : ''}`)
|
|
103
|
+
}
|
|
104
|
+
if (data.userPrompts.length <= 8) {
|
|
105
|
+
data.userPrompts.forEach((p, idx) => formatTurn(p, idx))
|
|
106
|
+
} else {
|
|
107
|
+
data.userPrompts.slice(0, 2).forEach((p, idx) => formatTurn(p, idx))
|
|
108
|
+
console.log(` ${DIM}... and ${data.userPrompts.length - 8} earlier turns ...${RESET}`)
|
|
109
|
+
const startIdx = data.userPrompts.length - 6
|
|
110
|
+
data.userPrompts.slice(-6).forEach((p, i) => formatTurn(p, startIdx + i, GREEN))
|
|
111
|
+
}
|
|
112
|
+
console.log(` ${DIM}Tip: Run with -d to see full chronology of every turn and tool call.${RESET}\n`)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
console.log(`${BOLD}Token Breakdown by Event Category:${RESET}`)
|
|
116
|
+
console.log(` ${'CATEGORY'.padEnd(25)} ${'CALLS'.padStart(6)} ${'TOKENS'.padStart(10)} ${'PERCENT'.padStart(8)}`)
|
|
117
|
+
console.log(` ${'─'.repeat(25)} ${'─'.repeat(6)} ${'─'.repeat(10)} ${'─'.repeat(8)}`)
|
|
118
|
+
Object.entries(data.categories)
|
|
119
|
+
.filter(([_, cat]) => cat.count > 0)
|
|
120
|
+
.sort((a, b) => b[1].tokens - a[1].tokens)
|
|
121
|
+
.forEach(([_, cat]) => {
|
|
122
|
+
const pct = Math.round((cat.tokens / data.totalTokens) * 100) || 0
|
|
123
|
+
const color = pct > 40 ? RED : pct > 20 ? YELLOW : CYAN
|
|
124
|
+
console.log(` ${cat.label.padEnd(25)} ${String(cat.count).padStart(6)} ${BOLD}${formatTokens(cat.tokens).padStart(10)}${RESET} ${color}${String(pct + '%').padStart(8)}${RESET}`)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
if (data.topViewedFiles.length > 0 || data.topModifiedFiles.length > 0) {
|
|
128
|
+
console.log(`\n${BOLD}Key Files Touched in this Session:${RESET}`)
|
|
129
|
+
if (data.topModifiedFiles.length > 0) console.log(` ${YELLOW}Modified:${RESET} ${data.topModifiedFiles.map(([f, n]) => `${f} (${n}x)`).join(', ')}`)
|
|
130
|
+
if (data.topViewedFiles.length > 0) console.log(` ${CYAN}Viewed:${RESET} ${data.topViewedFiles.map(([f, n]) => `${f} (${n}x)`).join(', ')}`)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (data.mcpCalls && data.mcpCalls.total > 0) {
|
|
134
|
+
console.log(`\n${BOLD}MCP Introspection Invocations:${RESET}`)
|
|
135
|
+
console.log(` katlux_inspect_project : ${data.mcpCalls.inspectProject} call(s)`)
|
|
136
|
+
console.log(` katlux_validate_code : ${data.mcpCalls.validateCode} call(s)`)
|
|
137
|
+
if (data.mcpCalls.otherMcp > 0) console.log(` other MCP tools : ${data.mcpCalls.otherMcp} call(s)`)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.log(`\n${BOLD}Top 5 Largest Token Spikes in this Session:${RESET}`)
|
|
141
|
+
data.spikes.forEach((spike, idx) => {
|
|
142
|
+
console.log(` ${idx + 1}. [Step #${spike.step_index}] ${YELLOW}${formatTokens(spike.tokens)} tokens${RESET} (${spike.type})`)
|
|
143
|
+
console.log(` ${DIM}"${spike.preview}..."${RESET}`)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
if (showDetail) {
|
|
147
|
+
console.log(`\n${BOLD}Full Step Chronology:${RESET}`)
|
|
148
|
+
steps.forEach(s => {
|
|
149
|
+
let c = ''
|
|
150
|
+
if (typeof s.content === 'string') c = s.content
|
|
151
|
+
else if (s.tool_calls) c = JSON.stringify(s.tool_calls)
|
|
152
|
+
else if (s.content) c = JSON.stringify(s.content)
|
|
153
|
+
const tok = estimateTokens(c)
|
|
154
|
+
const preview = c.replace(/[\r\n\t]+/g, ' ').slice(0, 60).trim()
|
|
155
|
+
console.log(` [#${String(s.step_index).padStart(3)}] ${s.type.padEnd(20)} ${formatTokens(tok).padStart(8)} tokens ${DIM}${preview}${RESET}`)
|
|
156
|
+
})
|
|
157
|
+
} else {
|
|
158
|
+
console.log(`\n${DIM}Commands:${RESET}`)
|
|
159
|
+
console.log(` • Weekly Report: ${CYAN}npm run ai:tokens:report${RESET}`)
|
|
160
|
+
console.log(` • Browse list: ${CYAN}npm run ai:tokens -- -p 1${RESET}`)
|
|
161
|
+
console.log(` • Search topic: ${CYAN}npm run ai:tokens -- -s "<keyword>"${RESET}`)
|
|
162
|
+
console.log(` • View step log: ${CYAN}npm run ai:tokens -- ${convIndex} -d${RESET}\n`)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Parses `--ide <name>` or `--ide=<name>` from CLI args (defaults to `antigravity`). */
|
|
167
|
+
export function parseIdeArg(args = []) {
|
|
168
|
+
for (let i = 0; i < args.length; i++) {
|
|
169
|
+
const arg = args[i]
|
|
170
|
+
if (arg.startsWith('--ide=')) {
|
|
171
|
+
return arg.slice('--ide='.length).trim() || 'antigravity'
|
|
172
|
+
}
|
|
173
|
+
if (arg === '--ide' && args[i + 1] && !args[i + 1].startsWith('-')) {
|
|
174
|
+
return args[i + 1].trim()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return 'antigravity'
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** CLI argument parser and dispatcher for `katlux-tokens`. */
|
|
181
|
+
export function runAiTokensCli(args = process.argv.slice(2)) {
|
|
182
|
+
if (args.includes('-h') || args.includes('--help')) {
|
|
183
|
+
console.log(`Usage: ai-tokens [options] [index|id]`)
|
|
184
|
+
console.log(` --ide <name> IDE transcript adapter (${SUPPORTED_IDES.join(' | ')}, default: antigravity)`)
|
|
185
|
+
console.log(` -P, --project <name> Filter by project name (or 'current' / '.')`)
|
|
186
|
+
console.log(` --projects List all detected projects`)
|
|
187
|
+
console.log(` -r, --report Generate weekly token report`)
|
|
188
|
+
console.log(` -w, --week <YYYY-Www> Filter weekly report`)
|
|
189
|
+
console.log(` --md, --save Output Markdown / save report`)
|
|
190
|
+
console.log(` -s, --search <q> Search conversations`)
|
|
191
|
+
console.log(` -p, --page <n> Paginated list view`)
|
|
192
|
+
console.log(` -l, --limit <n> Items per page (default: 100)`)
|
|
193
|
+
console.log(` -d, --detail Show full step chronology`)
|
|
194
|
+
process.exit(0)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const ideName = parseIdeArg(args)
|
|
198
|
+
let adapter
|
|
199
|
+
try {
|
|
200
|
+
adapter = getIdeAdapter(ideName)
|
|
201
|
+
} catch (err) {
|
|
202
|
+
console.log(`${RED}${err.message}${RESET}`)
|
|
203
|
+
process.exit(1)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const showDetail = args.includes('-d') || args.includes('--detail')
|
|
207
|
+
|
|
208
|
+
let projectFilter = ''
|
|
209
|
+
const prjArgIdx = args.findIndex(a => a === '-P' || a === '--project')
|
|
210
|
+
if (prjArgIdx !== -1 && args[prjArgIdx + 1] && !args[prjArgIdx + 1].startsWith('-')) {
|
|
211
|
+
projectFilter = args[prjArgIdx + 1]
|
|
212
|
+
if (projectFilter === 'current' || projectFilter === '.') projectFilter = basename(process.cwd())
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (args.includes('--projects') || (args.includes('-P') && !projectFilter)) {
|
|
216
|
+
const all = adapter.getConversations().map(c => ({ ...c, preview: adapter.getConversationPreviewFast(c.path) }))
|
|
217
|
+
listDetectedProjects(all, adapter)
|
|
218
|
+
process.exit(0)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const isReport = args.includes('--report') || args.includes('-r') || args.includes('--weekly')
|
|
222
|
+
const asMarkdown = args.includes('--md') || args.includes('--markdown')
|
|
223
|
+
const saveFile = args.includes('--save')
|
|
224
|
+
|
|
225
|
+
let weekFilter = ''
|
|
226
|
+
const weekArgIdx = args.findIndex(a => a === '-w' || a === '--week')
|
|
227
|
+
if (weekArgIdx !== -1 && args[weekArgIdx + 1]) weekFilter = args[weekArgIdx + 1]
|
|
228
|
+
|
|
229
|
+
if (isReport || weekFilter) {
|
|
230
|
+
generateWeekReport({ weekFilter, projectFilter, asMarkdown, saveFile, adapter })
|
|
231
|
+
process.exit(0)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let searchQuery = ''
|
|
235
|
+
const searchArgIdx = args.findIndex(a => a === '-s' || a === '--search' || a === '-q')
|
|
236
|
+
if (searchArgIdx !== -1 && args[searchArgIdx + 1]) searchQuery = args[searchArgIdx + 1].toLowerCase()
|
|
237
|
+
|
|
238
|
+
let page = 1
|
|
239
|
+
const pageArgIdx = args.findIndex(a => a === '-p' || a === '--page')
|
|
240
|
+
if (pageArgIdx !== -1 && args[pageArgIdx + 1]) page = Math.max(1, parseInt(args[pageArgIdx + 1], 10) || 1)
|
|
241
|
+
|
|
242
|
+
let limit = 100
|
|
243
|
+
const limitArgIdx = args.findIndex(a => a === '-l' || a === '--limit')
|
|
244
|
+
if (limitArgIdx !== -1 && args[limitArgIdx + 1]) limit = Math.max(1, parseInt(args[limitArgIdx + 1], 10) || 100)
|
|
245
|
+
|
|
246
|
+
const allConversations = adapter.getConversations()
|
|
247
|
+
if (allConversations.length === 0) {
|
|
248
|
+
console.log(`${RED}${adapter.emptyMessage}${RESET}`)
|
|
249
|
+
process.exit(1)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const mappedConversations = allConversations.map((c, i) => ({
|
|
253
|
+
...c,
|
|
254
|
+
originalIndex: i + 1,
|
|
255
|
+
preview: adapter.getConversationPreviewFast(c.path, searchQuery)
|
|
256
|
+
}))
|
|
257
|
+
|
|
258
|
+
const projectFiltered = projectFilter
|
|
259
|
+
? mappedConversations.filter(c => c.preview.project.toLowerCase().includes(projectFilter.toLowerCase()))
|
|
260
|
+
: mappedConversations
|
|
261
|
+
|
|
262
|
+
const filteredConversations = searchQuery
|
|
263
|
+
? projectFiltered.filter(c =>
|
|
264
|
+
c.id.toLowerCase().includes(searchQuery) ||
|
|
265
|
+
(c.preview.fullTitle && c.preview.fullTitle.toLowerCase().includes(searchQuery)) ||
|
|
266
|
+
c.preview.matchesSearch
|
|
267
|
+
)
|
|
268
|
+
: projectFiltered
|
|
269
|
+
|
|
270
|
+
const positionalArgs = args.filter(a =>
|
|
271
|
+
!a.startsWith('-') && a !== String(page) && a !== String(limit) && a !== searchQuery && a !== weekFilter && a !== projectFilter && a !== ideName
|
|
272
|
+
)
|
|
273
|
+
const targetArg = positionalArgs[0]
|
|
274
|
+
const targetIndex = targetArg && /^\d+$/.test(targetArg) ? parseInt(targetArg, 10) : null
|
|
275
|
+
const isExplicitList = args.includes('--list') || pageArgIdx !== -1 || searchArgIdx !== -1 || projectFilter !== ''
|
|
276
|
+
|
|
277
|
+
if ((isExplicitList && !targetIndex) || (searchQuery && !targetIndex)) {
|
|
278
|
+
renderConversationListView({ filteredConversations, projectFilter, searchQuery, page, limit })
|
|
279
|
+
process.exit(0)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let selectedConv = allConversations[0]
|
|
283
|
+
if (targetIndex !== null) {
|
|
284
|
+
if (targetIndex < 1 || targetIndex > allConversations.length) {
|
|
285
|
+
console.log(`${RED}Invalid index #${targetIndex}. Available: 1 to ${allConversations.length}.${RESET}`)
|
|
286
|
+
process.exit(1)
|
|
287
|
+
}
|
|
288
|
+
selectedConv = allConversations[targetIndex - 1]
|
|
289
|
+
} else if (targetArg) {
|
|
290
|
+
const found = allConversations.find(c => c.id.toLowerCase().startsWith(targetArg.toLowerCase()))
|
|
291
|
+
if (!found) {
|
|
292
|
+
console.log(`${RED}Conversation matching "${targetArg}" not found.${RESET}`)
|
|
293
|
+
console.log(`Run ${CYAN}npm run ai:tokens -- -p 1${RESET} to view all conversations.`)
|
|
294
|
+
process.exit(1)
|
|
295
|
+
}
|
|
296
|
+
selectedConv = found
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
renderSingleConversationDetailView(selectedConv, allConversations, showDetail, adapter)
|
|
300
|
+
}
|
|
301
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { homedir } from 'node:os'
|
|
4
|
+
|
|
5
|
+
export const ANSI = {
|
|
6
|
+
RESET: '\x1b[0m',
|
|
7
|
+
BOLD: '\x1b[1m',
|
|
8
|
+
DIM: '\x1b[2m',
|
|
9
|
+
CYAN: '\x1b[36m',
|
|
10
|
+
GREEN: '\x1b[32m',
|
|
11
|
+
YELLOW: '\x1b[33m',
|
|
12
|
+
RED: '\x1b[31m',
|
|
13
|
+
MAGENTA: '\x1b[35m',
|
|
14
|
+
BLUE: '\x1b[34m'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const BRAIN_DIRS = [
|
|
18
|
+
resolve(homedir(), '.gemini/antigravity/brain'),
|
|
19
|
+
resolve(homedir(), '.gemini/antigravity-ide/brain')
|
|
20
|
+
]
|
|
21
|
+
export const BRAIN_DIR = BRAIN_DIRS.find(d => existsSync(d)) || BRAIN_DIRS[0]
|
|
22
|
+
|
|
23
|
+
/** Estimates BPE token count for code and conversation JSON (~3.75 chars per token). */
|
|
24
|
+
export function estimateTokens(input = 0) {
|
|
25
|
+
if (!input) return 0
|
|
26
|
+
const chars = typeof input === 'number' ? input : (input.length || 0)
|
|
27
|
+
return Math.ceil(chars / 3.75)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Formats integer token counts compactly (e.g. `12.4k`, `1.25M`). */
|
|
31
|
+
export function formatTokens(count) {
|
|
32
|
+
if (count >= 1_000_000) return (count / 1_000_000).toFixed(2) + 'M'
|
|
33
|
+
if (count >= 1_000) return (count / 1_000).toFixed(1) + 'k'
|
|
34
|
+
return (count || 0).toLocaleString()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Formats byte lengths into human-readable units. */
|
|
38
|
+
export function formatBytes(bytes) {
|
|
39
|
+
if (bytes >= 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(2) + ' MB'
|
|
40
|
+
if (bytes >= 1024) return (bytes / 1024).toFixed(1) + ' KB'
|
|
41
|
+
return (bytes || 0) + ' B'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Formats a Date instance into compact local date and time display. */
|
|
45
|
+
export function formatDateTime(d) {
|
|
46
|
+
if (!d) return '-'
|
|
47
|
+
const dateStr = d.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit', year: 'numeric' })
|
|
48
|
+
const timeStr = d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
49
|
+
return `${dateStr} ${timeStr}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function cleanString(val) {
|
|
53
|
+
if (!val) return ''
|
|
54
|
+
return String(val).replace(/^["']|["']$/g, '').trim()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function makeBar(percent, maxLen = 16) {
|
|
58
|
+
const filled = Math.min(maxLen, Math.round((percent / 100) * maxLen))
|
|
59
|
+
return '█'.repeat(filled) + '░'.repeat(maxLen - filled)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Calculates standard ISO Calendar Week key (e.g. `"2026-W43"`). */
|
|
63
|
+
export function getWeekKey(date) {
|
|
64
|
+
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))
|
|
65
|
+
const dayNum = d.getUTCDay() || 7
|
|
66
|
+
d.setUTCDate(d.getUTCDate() + 4 - dayNum)
|
|
67
|
+
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1))
|
|
68
|
+
const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7)
|
|
69
|
+
return `${d.getUTCFullYear()}-W${String(weekNo).padStart(2, '0')}`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Formats a calendar week key into a human-readable `Mon – Sun` range. */
|
|
73
|
+
export function getWeekDateRange(weekKey) {
|
|
74
|
+
const match = weekKey.match(/^(\d{4})-W(\d{2})$/)
|
|
75
|
+
if (!match) return weekKey
|
|
76
|
+
const year = parseInt(match[1], 10)
|
|
77
|
+
const week = parseInt(match[2], 10)
|
|
78
|
+
|
|
79
|
+
const jan4 = new Date(Date.UTC(year, 0, 4))
|
|
80
|
+
const jan4Day = jan4.getUTCDay() || 7
|
|
81
|
+
const mondayWeek1 = new Date(jan4.getTime() - (jan4Day - 1) * 86400000)
|
|
82
|
+
const monday = new Date(mondayWeek1.getTime() + (week - 1) * 7 * 86400000)
|
|
83
|
+
const sunday = new Date(monday.getTime() + 6 * 86400000)
|
|
84
|
+
|
|
85
|
+
const monStr = monday.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' })
|
|
86
|
+
const sunStr = sunday.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' })
|
|
87
|
+
return `${monStr} – ${sunStr}`
|
|
88
|
+
}
|
|
89
|
+
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { writeFileSync } from 'node:fs'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import {
|
|
4
|
+
ANSI,
|
|
5
|
+
formatTokens,
|
|
6
|
+
getWeekDateRange
|
|
7
|
+
} from './formatAndDates.mjs'
|
|
8
|
+
import { getIdeAdapter } from './adapters/index.mjs'
|
|
9
|
+
|
|
10
|
+
const { RESET, BOLD, DIM, CYAN, GREEN, YELLOW, RED } = ANSI
|
|
11
|
+
|
|
12
|
+
/** Prints all detected workspace projects with session counts and token totals. */
|
|
13
|
+
export function listDetectedProjects(conversations, adapter = getIdeAdapter('antigravity')) {
|
|
14
|
+
const headerTitle = `DETECTED ${adapter.displayName.toUpperCase()} PROJECTS`.padStart(48).padEnd(76)
|
|
15
|
+
console.log(`\n${BOLD}╭──────────────────────────────────────────────────────────────────────────────╮${RESET}`)
|
|
16
|
+
console.log(`${BOLD}│${headerTitle}│${RESET}`)
|
|
17
|
+
console.log(`${BOLD}╰──────────────────────────────────────────────────────────────────────────────╯${RESET}`)
|
|
18
|
+
|
|
19
|
+
const projectMap = new Map()
|
|
20
|
+
conversations.forEach(c => {
|
|
21
|
+
const prj = c.preview.project
|
|
22
|
+
if (prj === 'Unknown' || c.preview.rawSize === 0) return
|
|
23
|
+
if (!projectMap.has(prj)) projectMap.set(prj, { name: prj, count: 0, tokens: 0, latest: c.mtime })
|
|
24
|
+
const p = projectMap.get(prj)
|
|
25
|
+
p.count++
|
|
26
|
+
p.tokens += c.preview.estimatedTokens
|
|
27
|
+
if (c.mtime > p.latest) p.latest = c.mtime
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
console.log(` ${'#'.padStart(3)} ${'PROJECT NAME'.padEnd(26)} ${'SESSIONS'.padStart(10)} ${'TOTAL TOKENS'.padStart(14)} LAST ACTIVE`)
|
|
31
|
+
console.log(` ${'─'.repeat(3)} ${'─'.repeat(26)} ${'─'.repeat(10)} ${'─'.repeat(14)} ${'─'.repeat(16)}`)
|
|
32
|
+
|
|
33
|
+
let idx = 1
|
|
34
|
+
for (const p of projectMap.values()) {
|
|
35
|
+
const dateStr = p.latest.toLocaleDateString() + ' ' + p.latest.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
36
|
+
console.log(
|
|
37
|
+
` ${CYAN}${String(idx++).padStart(3)}${RESET} ` +
|
|
38
|
+
`${BOLD}${p.name.padEnd(26)}${RESET} ` +
|
|
39
|
+
`${String(p.count).padStart(10)} ` +
|
|
40
|
+
`${formatTokens(p.tokens).padStart(14)} ` +
|
|
41
|
+
`${DIM}${dateStr}${RESET}`
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(`\n${BOLD}Filter Commands:${RESET}`)
|
|
46
|
+
for (const p of projectMap.values()) {
|
|
47
|
+
console.log(` • View ${p.name}: ${CYAN}npm run ai:tokens -- -P ${p.name} --report${RESET}`)
|
|
48
|
+
}
|
|
49
|
+
console.log()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Generates week-by-week Markdown and visual terminal reports across conversations. */
|
|
53
|
+
export function generateWeekReport({ weekFilter = '', projectFilter = '', asMarkdown = false, saveFile = false, adapter = getIdeAdapter('antigravity') }) {
|
|
54
|
+
const all = adapter.getConversations()
|
|
55
|
+
if (all.length === 0) {
|
|
56
|
+
console.log(`${RED}${adapter.emptyMessage}${RESET}`)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const mapped = all.map((c, i) => ({
|
|
61
|
+
...c,
|
|
62
|
+
originalIndex: i + 1,
|
|
63
|
+
preview: adapter.getConversationPreviewFast(c.path)
|
|
64
|
+
}))
|
|
65
|
+
|
|
66
|
+
let filtered = mapped
|
|
67
|
+
if (projectFilter) {
|
|
68
|
+
const q = projectFilter.toLowerCase()
|
|
69
|
+
filtered = mapped.filter(c => c.preview.project.toLowerCase().includes(q))
|
|
70
|
+
if (filtered.length === 0) {
|
|
71
|
+
console.log(`\n${RED}No sessions found for project matching "${projectFilter}".${RESET}`)
|
|
72
|
+
console.log(`Run ${CYAN}npm run ai:tokens -- --projects${RESET} to view all detected projects.\n`)
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const activeConversations = filtered.filter(c => c.preview.rawSize > 0)
|
|
78
|
+
const weeklyMap = new Map()
|
|
79
|
+
|
|
80
|
+
activeConversations.forEach(conv => {
|
|
81
|
+
const wk = conv.weekKey
|
|
82
|
+
if (!weeklyMap.has(wk)) {
|
|
83
|
+
weeklyMap.set(wk, { weekKey: wk, dateRange: getWeekDateRange(wk), dirs: [] })
|
|
84
|
+
}
|
|
85
|
+
weeklyMap.get(wk).dirs.push(conv)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const weeklyStats = []
|
|
89
|
+
for (const [wk, entry] of weeklyMap.entries()) {
|
|
90
|
+
if (weekFilter && !wk.toLowerCase().includes(weekFilter.toLowerCase())) continue
|
|
91
|
+
const analyzedSessions = entry.dirs.map(d => {
|
|
92
|
+
const steps = adapter.parseTranscript(d.path)
|
|
93
|
+
return steps ? adapter.analyzeSession(steps, d.id, d.mtime, d.preview.project) : null
|
|
94
|
+
}).filter(Boolean)
|
|
95
|
+
if (analyzedSessions.length === 0) continue
|
|
96
|
+
|
|
97
|
+
const realTasks = analyzedSessions.filter(s => s.totalSteps >= 6)
|
|
98
|
+
const targetSessions = realTasks.length > 0 ? realTasks : analyzedSessions
|
|
99
|
+
const trivialCount = analyzedSessions.length - targetSessions.length
|
|
100
|
+
const count = targetSessions.length
|
|
101
|
+
const sum = (fn) => targetSessions.reduce((s, x) => s + fn(x), 0)
|
|
102
|
+
const avg = (fn) => Math.round(sum(fn) / count)
|
|
103
|
+
|
|
104
|
+
const avgInputTokens = avg(s => s.inputTokens)
|
|
105
|
+
const avgOutputTokens = avg(s => s.outputTokens)
|
|
106
|
+
const weekCategories = {}
|
|
107
|
+
const weekViewedFiles = new Map()
|
|
108
|
+
const weekModifiedFiles = new Map()
|
|
109
|
+
|
|
110
|
+
targetSessions.forEach(s => {
|
|
111
|
+
Object.entries(s.categories).forEach(([k, cat]) => {
|
|
112
|
+
if (!weekCategories[k]) weekCategories[k] = { label: cat.label, count: 0, tokens: 0 }
|
|
113
|
+
weekCategories[k].count += cat.count
|
|
114
|
+
weekCategories[k].tokens += cat.tokens
|
|
115
|
+
})
|
|
116
|
+
s.allFilesViewed.forEach((c, f) => weekViewedFiles.set(f, (weekViewedFiles.get(f) || 0) + c))
|
|
117
|
+
s.allFilesModified.forEach((c, f) => weekModifiedFiles.set(f, (weekModifiedFiles.get(f) || 0) + c))
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
weeklyStats.push({
|
|
121
|
+
weekKey: wk,
|
|
122
|
+
dateRange: entry.dateRange,
|
|
123
|
+
sessionCount: count,
|
|
124
|
+
trivialCount,
|
|
125
|
+
totalTokensSum: sum(s => s.totalTokens),
|
|
126
|
+
avgTotalTokens: avg(s => s.totalTokens),
|
|
127
|
+
avgRunCmdTokens: avg(s => s.categories.RUN_COMMAND?.tokens || 0),
|
|
128
|
+
avgViewFileTokens: avg(s => s.categories.VIEW_FILE?.tokens || 0),
|
|
129
|
+
avgMcpTokens: avg(s => s.categories.MCP_TOOL?.tokens || 0),
|
|
130
|
+
avgMcpCalls: avg(s => s.mcpCalls?.total || 0),
|
|
131
|
+
avgSteps: avg(s => s.totalSteps),
|
|
132
|
+
claudeCost: ((avgInputTokens / 1_000_000) * 3.00 + (avgOutputTokens / 1_000_000) * 15.00).toFixed(2),
|
|
133
|
+
geminiCost: ((avgInputTokens / 1_000_000) * 0.35 + (avgOutputTokens / 1_000_000) * 1.05).toFixed(3),
|
|
134
|
+
categories: weekCategories,
|
|
135
|
+
topViewed: [...weekViewedFiles.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5),
|
|
136
|
+
topModified: [...weekModifiedFiles.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
weeklyStats.sort((a, b) => b.weekKey.localeCompare(a.weekKey))
|
|
141
|
+
for (let i = 0; i < weeklyStats.length; i++) {
|
|
142
|
+
const current = weeklyStats[i]
|
|
143
|
+
const prior = weeklyStats[i + 1]
|
|
144
|
+
current.wowPct = prior && prior.avgTotalTokens > 0
|
|
145
|
+
? (((current.avgTotalTokens - prior.avgTotalTokens) / prior.avgTotalTokens) * 100).toFixed(1)
|
|
146
|
+
: null
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const projectLabel = projectFilter ? `Project: ${projectFilter}` : 'All Projects'
|
|
150
|
+
const md = [
|
|
151
|
+
`# Antigravity AI Token Usage: Week-by-Week Report`,
|
|
152
|
+
`*Scope: ${projectLabel} | Analyzed ${activeConversations.length} sessions across ${weeklyStats.length} calendar weeks*\n`,
|
|
153
|
+
`## 1. Week-by-Week Token & Efficiency Progression\n`,
|
|
154
|
+
`| Calendar Week | Date Range | Tasks | Avg Tokens / Task | Avg Test Tokens | Avg File View | Avg MCP Tokens | Avg Steps | Avg Cost (Claude) | WoW Trend |`,
|
|
155
|
+
`| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |`
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
weeklyStats.forEach((w, idx) => {
|
|
159
|
+
const isCurrent = idx === 0 ? ' **(Current)**' : ''
|
|
160
|
+
const wowStr = w.wowPct !== null ? `${Number(w.wowPct) <= 0 ? w.wowPct + '%' : '+' + w.wowPct + '%'}` : '—'
|
|
161
|
+
md.push(`| **${w.weekKey}**${isCurrent} | ${w.dateRange} | ${w.sessionCount} | **${formatTokens(w.avgTotalTokens)}** | ${formatTokens(w.avgRunCmdTokens)} | ${formatTokens(w.avgViewFileTokens)} | ${formatTokens(w.avgMcpTokens)} | ${w.avgSteps} | $${w.claudeCost} | ${wowStr} |`)
|
|
162
|
+
})
|
|
163
|
+
md.push('', `## 2. Weekly Details & Most Frequent Files\n`)
|
|
164
|
+
|
|
165
|
+
weeklyStats.forEach(w => {
|
|
166
|
+
const trivialSuffix = w.trivialCount > 0 ? ` (+${w.trivialCount} trivial)` : ''
|
|
167
|
+
md.push(`### ${w.weekKey} (${w.dateRange}) — ${w.sessionCount} Tasks${trivialSuffix} | Avg ${formatTokens(w.avgTotalTokens)} Tokens | Cost $${w.claudeCost}`)
|
|
168
|
+
if (w.topViewed.length > 0) md.push(`- **Most Read Files:** ${w.topViewed.map(([f, n]) => `\`${f}\` (${n}x)`).join(', ')}`)
|
|
169
|
+
if (w.topModified.length > 0) md.push(`- **Most Edited Files:** ${w.topModified.map(([f, n]) => `\`${f}\` (${n}x)`).join(', ')}`)
|
|
170
|
+
const totalWeekTokens = Object.values(w.categories).reduce((s, x) => s + x.tokens, 0)
|
|
171
|
+
const catPcts = Object.values(w.categories).filter(c => c.tokens > 0).sort((a, b) => b.tokens - a.tokens)
|
|
172
|
+
.map(c => `${c.label}: ${((c.tokens / totalWeekTokens) * 100).toFixed(0)}%`).slice(0, 4).join(' | ')
|
|
173
|
+
if (catPcts) md.push(`- **Key Categories:** ${catPcts}`)
|
|
174
|
+
md.push('')
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const mdOutput = md.join('\n')
|
|
178
|
+
if (saveFile) {
|
|
179
|
+
const outPath = resolve(process.cwd(), 'token-report.md')
|
|
180
|
+
writeFileSync(outPath, mdOutput, 'utf-8')
|
|
181
|
+
console.log(`${GREEN}✓ Week-by-week report saved to ${outPath}${RESET}\n`)
|
|
182
|
+
}
|
|
183
|
+
if (asMarkdown) {
|
|
184
|
+
console.log(mdOutput)
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
console.log(`\n${BOLD}╭──────────────────────────────────────────────────────────────────────────────╮${RESET}`)
|
|
189
|
+
console.log(`${BOLD}│ ANTIGRAVITY AI TOKEN USAGE: WEEK-BY-WEEK REPORT │${RESET}`)
|
|
190
|
+
console.log(`${BOLD}╰──────────────────────────────────────────────────────────────────────────────╯${RESET}`)
|
|
191
|
+
console.log(` Scope: ${BOLD}${projectLabel}${RESET} (${activeConversations.length} total sessions analyzed across ${weeklyStats.length} calendar weeks)\n`)
|
|
192
|
+
console.log(`${BOLD}1. WEEK-BY-WEEK PROGRESSION TABLE${RESET}`)
|
|
193
|
+
console.log(` ${'WEEK'.padEnd(10)} ${'DATE RANGE'.padEnd(16)} ${'TASKS'.padStart(6)} ${'AVG TOKENS'.padStart(11)} ${'TESTS'.padStart(8)} ${'VIEW'.padStart(8)} ${'MCP'.padStart(8)} ${'STEPS'.padStart(6)} ${'COST'.padStart(7)} ${'WoW TREND'.padStart(10)}`)
|
|
194
|
+
console.log(` ${'─'.repeat(10)} ${'─'.repeat(16)} ${'─'.repeat(6)} ${'─'.repeat(11)} ${'─'.repeat(8)} ${'─'.repeat(8)} ${'─'.repeat(8)} ${'─'.repeat(6)} ${'─'.repeat(7)} ${'─'.repeat(10)}`)
|
|
195
|
+
|
|
196
|
+
weeklyStats.forEach((w, idx) => {
|
|
197
|
+
const isCurrent = idx === 0
|
|
198
|
+
const weekLabel = (w.weekKey.replace('2026-', '') + (isCurrent ? '*' : '')).padEnd(10)
|
|
199
|
+
const wowColor = w.wowPct && Number(w.wowPct) <= 0 ? GREEN : (w.wowPct ? RED : DIM)
|
|
200
|
+
const wowStr = w.wowPct !== null ? (Number(w.wowPct) <= 0 ? w.wowPct + '%' : '+' + w.wowPct + '%') : '—'
|
|
201
|
+
console.log(
|
|
202
|
+
` ${isCurrent ? GREEN : CYAN}${weekLabel}${RESET} ` +
|
|
203
|
+
`${w.dateRange.padEnd(16)} ${String(w.sessionCount).padStart(6)} ` +
|
|
204
|
+
`${BOLD}${formatTokens(w.avgTotalTokens).padStart(11)}${RESET} ` +
|
|
205
|
+
`${formatTokens(w.avgRunCmdTokens).padStart(8)} ${formatTokens(w.avgViewFileTokens).padStart(8)} ` +
|
|
206
|
+
`${formatTokens(w.avgMcpTokens).padStart(8)} ${String(w.avgSteps).padStart(6)} ` +
|
|
207
|
+
`${('$' + w.claudeCost).padStart(7)} ${wowColor}${wowStr.padStart(10)}${RESET}`
|
|
208
|
+
)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
console.log(` ${DIM}* Current calendar week. Costs estimated using Claude 3.5 Sonnet.${RESET}\n`)
|
|
212
|
+
console.log(`${BOLD}2. WEEKLY DETAILS & MOST FREQUENT FILES${RESET}`)
|
|
213
|
+
weeklyStats.forEach(w => {
|
|
214
|
+
const totalWeekTokens = Object.values(w.categories).reduce((s, x) => s + x.tokens, 0)
|
|
215
|
+
const trivialSuffix = w.trivialCount > 0 ? ` (+${w.trivialCount} trivial)` : ''
|
|
216
|
+
console.log(` ${CYAN}${BOLD}[Week ${w.weekKey}: ${w.dateRange}]${RESET} — ${w.sessionCount} Tasks${trivialSuffix} | Avg ${formatTokens(w.avgTotalTokens)} Tokens | Avg Steps: ${w.avgSteps}`)
|
|
217
|
+
if (w.topViewed.length > 0) console.log(` ${CYAN}Most Read:${RESET} ${w.topViewed.map(([f, n]) => `${f} (${n}x)`).join(', ')}`)
|
|
218
|
+
if (w.topModified.length > 0) console.log(` ${YELLOW}Most Edited:${RESET} ${w.topModified.map(([f, n]) => `${f} (${n}x)`).join(', ')}`)
|
|
219
|
+
const topCats = Object.values(w.categories).filter(c => c.tokens > 0).sort((a, b) => b.tokens - a.tokens)
|
|
220
|
+
.slice(0, 4).map(c => `${c.label}: ${((c.tokens / totalWeekTokens) * 100).toFixed(0)}%`).join(' | ')
|
|
221
|
+
if (topCats) console.log(` ${DIM}Categories:${RESET} ${DIM}${topCats}${RESET}`)
|
|
222
|
+
console.log()
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
console.log(`${DIM}Commands:${RESET}`)
|
|
226
|
+
console.log(` • Filter project: ${CYAN}npm run ai:tokens -- -P <projectName> --report${RESET}`)
|
|
227
|
+
console.log(` • List projects: ${CYAN}npm run ai:tokens -- --projects${RESET}`)
|
|
228
|
+
console.log(` • Save as Markdown: ${CYAN}npm run ai:tokens -- --report --save${RESET}`)
|
|
229
|
+
console.log(` • Filter single week:${CYAN}npm run ai:tokens -- -w W43${RESET}`)
|
|
230
|
+
console.log(` • Browse sessions: ${CYAN}npm run ai:tokens -- -p 1${RESET}\n`)
|
|
231
|
+
}
|
|
232
|
+
|