@katlux/toolkit 0.1.1-alpha.145 → 0.1.1-alpha.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ai-init.mjs +517 -0
- package/bin/ai-tokens.mjs +212 -54
- package/bin/cli.mjs +76 -47
- package/bin/create-preset.mjs +1 -0
- package/bin/preset-contracts.json +2941 -0
- package/dist/compiled/composables/locales.mjs +204 -25
- package/dist/compiled/composables/useDataProvider.mjs +36 -25
- package/dist/compiled/composables/useFilterLogic.mjs +10 -2
- package/dist/compiled/composables/useKatluxForm.mjs +6 -4
- package/dist/compiled/composables/useVirtualDataset.mjs +689 -0
- package/dist/compiled/composables/useVirtualScroll.mjs +29 -9
- package/dist/module.cjs +63 -77
- package/dist/module.d.cts +5 -0
- package/dist/module.d.mts +4 -1
- package/dist/module.mjs +60 -78
- 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 +4 -2
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +70 -37
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +2 -2
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +2 -2
- 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 +60 -11
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.d.vue.ts +25 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +11 -1
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue.d.ts +25 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +19 -3
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +115 -1
- 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 +3 -3
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +3 -3
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +7 -1
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +2 -2
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +2 -2
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +5 -0
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +21 -17
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +23 -16
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +21 -17
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +13 -10
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +25 -20
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +9 -13
- package/dist/runtime/components/KDatatable/KDatatable.global.vue +6 -5
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +9 -13
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -6
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +26 -19
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +30 -14
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +38 -13
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +30 -14
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +28 -6
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +197 -53
- 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/KGantt/KGantt.global.d.vue.ts +55 -6
- package/dist/runtime/components/KGantt/KGantt.global.vue +12 -3
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +55 -6
- 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/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KLoader/KLoader.global.vue +2 -0
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.d.vue.ts +23 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +22 -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 +1 -0
- package/dist/runtime/components/KPagination/KPagination.logic.js +57 -5
- 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 +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
- 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/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 +16 -12
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +5 -7
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +1 -5
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +5 -7
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +39 -5
- package/dist/runtime/components/KTreeView/KTreeView.global.vue +19 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +39 -5
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +23 -3
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +76 -6
- package/dist/runtime/composables/locales.js +204 -25
- package/dist/runtime/composables/useDataProvider.d.ts +5 -3
- package/dist/runtime/composables/useDataProvider.js +36 -25
- 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 +6 -4
- package/dist/runtime/composables/useSortLogic.d.ts +1 -1
- package/dist/runtime/composables/useVirtualDataset.d.ts +121 -0
- package/dist/runtime/composables/useVirtualDataset.js +689 -0
- package/dist/runtime/composables/useVirtualScroll.d.ts +8 -4
- package/dist/runtime/composables/useVirtualScroll.js +29 -9
- package/dist/runtime/plugins/nuxtCompatPlugin.js +9 -1
- 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 +5 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +33 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +5 -0
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +7 -1
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +30 -8
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +80 -164
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +30 -8
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +16 -9
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +99 -394
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +16 -9
- 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/KGantt/KGantt.d.vue.ts +11 -12
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +77 -14
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +11 -12
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +1 -0
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +3 -3
- package/dist/runtime/presets/default/components/KTree/KTree.vue +48 -14
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +3 -3
- 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/skills/KATLUX_INDEX.md +9 -6
- package/dist/skills/katlux-components/SKILL.md +2 -0
- package/dist/skills/katlux-components/components/KBulkActions.md +25 -1
- package/dist/skills/katlux-components/components/KCombobox.md +2 -2
- package/dist/skills/katlux-components/components/KDataIterator.md +12 -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/KLineChart.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/KTreePicker.md +2 -1
- package/dist/skills/katlux-components/components/KTreeView.md +12 -0
- package/dist/skills/katlux-config/SKILL.md +19 -8
- package/dist/skills/katlux-presets/SKILL.md +121 -1
- package/dist/skills/katlux-presets/creating-a-preset.md +67 -0
- package/dist/skills/katlux-providers/SKILL.md +7 -5
- package/dist/skills/katlux-providers/providers/ADataProvider.md +16 -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/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 +63 -19
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +20 -2
- package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +25 -11
- package/dist/skills/katlux-providers/providers/encryption-searchable.md +218 -0
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +25 -1
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +63 -0
- 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
package/bin/ai-tokens.mjs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* npx @katlux/toolkit tokens -r --save # Saves week-by-week report to token-report.md
|
|
17
17
|
* npx @katlux/toolkit tokens -r --md # Outputs pure Markdown
|
|
18
18
|
* npx @katlux/toolkit tokens -p 1 # Paginated session browser (100 per page)
|
|
19
|
-
* npx @katlux/toolkit tokens -p 1 -P
|
|
19
|
+
* npx @katlux/toolkit tokens -p 1 -P <ProjectName> # Browse sessions of a specific project
|
|
20
20
|
* npx @katlux/toolkit tokens <#|id> # Inspect details of a specific conversation
|
|
21
21
|
* npx @katlux/toolkit tokens <#|id> -d # Full step-by-step chronology
|
|
22
22
|
*/
|
|
@@ -35,7 +35,11 @@ const RED = '\x1b[31m'
|
|
|
35
35
|
const MAGENTA = '\x1b[35m'
|
|
36
36
|
const BLUE = '\x1b[34m'
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const BRAIN_DIRS = [
|
|
39
|
+
resolve(homedir(), '.gemini/antigravity/brain'),
|
|
40
|
+
resolve(homedir(), '.gemini/antigravity-ide/brain')
|
|
41
|
+
]
|
|
42
|
+
const BRAIN_DIR = BRAIN_DIRS.find(d => existsSync(d)) || BRAIN_DIRS[0]
|
|
39
43
|
|
|
40
44
|
// Standard token estimation for code and conversation JSON (~3.75 chars per token)
|
|
41
45
|
export function estimateTokens(input = 0) {
|
|
@@ -56,6 +60,13 @@ export function formatBytes(bytes) {
|
|
|
56
60
|
return (bytes || 0) + ' B'
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
export function formatDateTime(d) {
|
|
64
|
+
if (!d) return '-'
|
|
65
|
+
const dateStr = d.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit', year: 'numeric' })
|
|
66
|
+
const timeStr = d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
67
|
+
return `${dateStr} ${timeStr}`
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
function cleanString(val) {
|
|
60
71
|
if (!val) return ''
|
|
61
72
|
return String(val).replace(/^["']|["']$/g, '').trim()
|
|
@@ -96,7 +107,9 @@ export function getWeekDateRange(weekKey) {
|
|
|
96
107
|
|
|
97
108
|
// Fast 16KB header inspection to avoid loading full multimegabyte JSONL files into memory
|
|
98
109
|
export function getConversationPreviewFast(dirPath, searchQuery = '') {
|
|
99
|
-
const
|
|
110
|
+
const pFull = join(dirPath, '.system_generated/logs/transcript_full.jsonl')
|
|
111
|
+
const pNorm = join(dirPath, '.system_generated/logs/transcript.jsonl')
|
|
112
|
+
const p = existsSync(pFull) ? pFull : pNorm
|
|
100
113
|
if (!existsSync(p)) return { project: 'Unknown', title: '(empty transcript)', fullTitle: '', rawSize: 0, estimatedTokens: 0, matchesSearch: false, stepsCount: 0 }
|
|
101
114
|
|
|
102
115
|
try {
|
|
@@ -163,23 +176,49 @@ export function getConversationPreviewFast(dirPath, searchQuery = '') {
|
|
|
163
176
|
}
|
|
164
177
|
|
|
165
178
|
export function getConversations() {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
const validDirs = BRAIN_DIRS.filter(d => existsSync(d))
|
|
180
|
+
if (validDirs.length === 0) return []
|
|
181
|
+
|
|
182
|
+
const seen = new Set()
|
|
183
|
+
const results = []
|
|
184
|
+
|
|
185
|
+
for (const bDir of validDirs) {
|
|
186
|
+
const entries = readdirSync(bDir, { withFileTypes: true })
|
|
187
|
+
for (const e of entries) {
|
|
188
|
+
if (!e.isDirectory() || e.name === 'tempmediaStorage' || e.name.startsWith('.')) continue
|
|
189
|
+
if (seen.has(e.name)) continue
|
|
190
|
+
seen.add(e.name)
|
|
191
|
+
|
|
192
|
+
const dirPath = join(bDir, e.name)
|
|
193
|
+
const transcriptPath = join(dirPath, '.system_generated/logs/transcript.jsonl')
|
|
194
|
+
const dirStat = statSync(dirPath)
|
|
195
|
+
let lastActive = dirStat.mtime
|
|
196
|
+
if (existsSync(transcriptPath)) {
|
|
197
|
+
try {
|
|
198
|
+
lastActive = statSync(transcriptPath).mtime
|
|
199
|
+
} catch {}
|
|
200
|
+
}
|
|
201
|
+
results.push({
|
|
202
|
+
id: e.name,
|
|
203
|
+
path: dirPath,
|
|
204
|
+
createdAt: dirStat.mtime,
|
|
205
|
+
lastActive,
|
|
206
|
+
mtime: lastActive,
|
|
207
|
+
weekKey: getWeekKey(lastActive)
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return results.sort((a, b) => b.lastActive.getTime() - a.lastActive.getTime())
|
|
176
213
|
}
|
|
177
214
|
|
|
178
215
|
export function parseTranscript(conversationDir) {
|
|
216
|
+
const transcriptFullPath = join(conversationDir, '.system_generated/logs/transcript_full.jsonl')
|
|
179
217
|
const transcriptPath = join(conversationDir, '.system_generated/logs/transcript.jsonl')
|
|
180
|
-
|
|
218
|
+
const targetPath = existsSync(transcriptFullPath) ? transcriptFullPath : transcriptPath
|
|
219
|
+
if (!existsSync(targetPath)) return null
|
|
181
220
|
|
|
182
|
-
const raw = readFileSync(
|
|
221
|
+
const raw = readFileSync(targetPath, 'utf-8')
|
|
183
222
|
const lines = raw.trim().split('\n').filter(Boolean)
|
|
184
223
|
|
|
185
224
|
const steps = []
|
|
@@ -200,7 +239,8 @@ export function analyzeSession(steps, conversationId, mtime = new Date(), previe
|
|
|
200
239
|
const categories = {
|
|
201
240
|
USER_INPUT: { count: 0, chars: 0, tokens: 0, label: 'User Prompts' },
|
|
202
241
|
PLANNER_RESPONSE: { count: 0, chars: 0, tokens: 0, label: 'Assistant / Model' },
|
|
203
|
-
VIEW_FILE: { count: 0, chars: 0, tokens: 0, label: 'view_file
|
|
242
|
+
VIEW_FILE: { count: 0, chars: 0, tokens: 0, label: 'view_file / read_file' },
|
|
243
|
+
MCP_TOOL: { count: 0, chars: 0, tokens: 0, label: 'MCP Tools' },
|
|
204
244
|
CODE_ACTION: { count: 0, chars: 0, tokens: 0, label: 'Code Edit / Write' },
|
|
205
245
|
RUN_COMMAND: { count: 0, chars: 0, tokens: 0, label: 'run_command Outputs' },
|
|
206
246
|
GREP_SEARCH: { count: 0, chars: 0, tokens: 0, label: 'grep_search Outputs' },
|
|
@@ -214,18 +254,42 @@ export function analyzeSession(steps, conversationId, mtime = new Date(), previe
|
|
|
214
254
|
const userPrompts = []
|
|
215
255
|
const filesViewed = new Map()
|
|
216
256
|
const filesModified = new Map()
|
|
257
|
+
const mcpCalls = {
|
|
258
|
+
inspectProject: 0,
|
|
259
|
+
validateCode: 0,
|
|
260
|
+
otherMcp: 0,
|
|
261
|
+
total: 0
|
|
262
|
+
}
|
|
217
263
|
let sessionTitle = ''
|
|
218
264
|
let detectedProject = previewProject
|
|
219
265
|
|
|
266
|
+
const pendingToolCalls = []
|
|
267
|
+
|
|
220
268
|
steps.forEach(step => {
|
|
221
269
|
const type = step.type || 'OTHER'
|
|
222
270
|
let content = ''
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
271
|
+
if (type === 'PLANNER_RESPONSE') {
|
|
272
|
+
const parts = []
|
|
273
|
+
if (typeof step.content === 'string' && step.content) {
|
|
274
|
+
parts.push(step.content)
|
|
275
|
+
} else if (step.content && typeof step.content !== 'string') {
|
|
276
|
+
parts.push(JSON.stringify(step.content))
|
|
277
|
+
}
|
|
278
|
+
if (step.thinking && typeof step.thinking === 'string') {
|
|
279
|
+
parts.push(step.thinking)
|
|
280
|
+
}
|
|
281
|
+
if (step.tool_calls) {
|
|
282
|
+
parts.push(JSON.stringify(step.tool_calls))
|
|
283
|
+
}
|
|
284
|
+
content = parts.join('\n')
|
|
285
|
+
} else {
|
|
286
|
+
if (typeof step.content === 'string') {
|
|
287
|
+
content = step.content
|
|
288
|
+
} else if (step.tool_calls) {
|
|
289
|
+
content = JSON.stringify(step.tool_calls)
|
|
290
|
+
} else if (step.content) {
|
|
291
|
+
content = JSON.stringify(step.content)
|
|
292
|
+
}
|
|
229
293
|
}
|
|
230
294
|
|
|
231
295
|
if (detectedProject === 'Unknown' && content) {
|
|
@@ -241,18 +305,35 @@ export function analyzeSession(steps, conversationId, mtime = new Date(), previe
|
|
|
241
305
|
const match = content.match(/<USER_REQUEST>([\s\S]*?)<\/USER_REQUEST>/)
|
|
242
306
|
const promptText = (match ? match[1] : content).replace(/[\r\n\t]+/g, ' ').trim()
|
|
243
307
|
if (!sessionTitle) sessionTitle = promptText
|
|
244
|
-
|
|
308
|
+
const timeStr = step.created_at ? formatDateTime(new Date(step.created_at)) : ''
|
|
309
|
+
userPrompts.push({ step: step.step_index, text: promptText, time: timeStr })
|
|
245
310
|
}
|
|
246
311
|
|
|
247
312
|
// Track tool call targets
|
|
248
313
|
if (step.tool_calls && Array.isArray(step.tool_calls)) {
|
|
249
314
|
step.tool_calls.forEach(tc => {
|
|
315
|
+
pendingToolCalls.push(tc)
|
|
250
316
|
const args = tc.args || {}
|
|
251
|
-
|
|
252
|
-
|
|
317
|
+
let toolName = tc.name
|
|
318
|
+
if (tc.name === 'call_mcp_tool') {
|
|
319
|
+
toolName = cleanString(args.ToolName)
|
|
320
|
+
}
|
|
321
|
+
if (toolName === 'katlux_inspect_project') {
|
|
322
|
+
mcpCalls.inspectProject++
|
|
323
|
+
mcpCalls.total++
|
|
324
|
+
} else if (toolName === 'katlux_validate_code') {
|
|
325
|
+
mcpCalls.validateCode++
|
|
326
|
+
mcpCalls.total++
|
|
327
|
+
} else if (tc.name === 'call_mcp_tool' || (toolName && toolName.startsWith('katlux_'))) {
|
|
328
|
+
mcpCalls.otherMcp++
|
|
329
|
+
mcpCalls.total++
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if ((tc.name === 'view_file' || tc.name === 'read_file') && (args.AbsolutePath || args.Path)) {
|
|
333
|
+
const fn = basename(cleanString(args.AbsolutePath || args.Path))
|
|
253
334
|
if (fn) filesViewed.set(fn, (filesViewed.get(fn) || 0) + 1)
|
|
254
|
-
} else if ((tc.name === 'replace_file_content' || tc.name === 'multi_replace_file_content' || tc.name === 'write_to_file') && args.TargetFile) {
|
|
255
|
-
const fn = basename(cleanString(args.TargetFile))
|
|
335
|
+
} else if ((tc.name === 'replace_file_content' || tc.name === 'multi_replace_file_content' || tc.name === 'write_to_file' || tc.name === 'edit_file' || tc.name === 'write_file') && (args.TargetFile || args.Path)) {
|
|
336
|
+
const fn = basename(cleanString(args.TargetFile || args.Path))
|
|
256
337
|
if (fn) filesModified.set(fn, (filesModified.get(fn) || 0) + 1)
|
|
257
338
|
}
|
|
258
339
|
})
|
|
@@ -269,14 +350,52 @@ export function analyzeSession(steps, conversationId, mtime = new Date(), previe
|
|
|
269
350
|
inputChars += chars
|
|
270
351
|
}
|
|
271
352
|
|
|
272
|
-
|
|
353
|
+
let catType = type
|
|
354
|
+
if (type === 'READ_FILE') catType = 'VIEW_FILE'
|
|
355
|
+
if (type === 'MCP_TOOL' || type === 'CALL_MCP_TOOL') catType = 'MCP_TOOL'
|
|
356
|
+
|
|
357
|
+
if (type === 'GENERIC') {
|
|
358
|
+
const correspondingTool = pendingToolCalls.shift()
|
|
359
|
+
if (correspondingTool) {
|
|
360
|
+
const toolName = correspondingTool.name || ''
|
|
361
|
+
if (toolName === 'read_file' || toolName === 'view_file') {
|
|
362
|
+
catType = 'VIEW_FILE'
|
|
363
|
+
} else if (toolName === 'run_command' || toolName === 'manage_task') {
|
|
364
|
+
catType = 'RUN_COMMAND'
|
|
365
|
+
} else if (
|
|
366
|
+
toolName === 'edit_file' ||
|
|
367
|
+
toolName === 'write_file' ||
|
|
368
|
+
toolName === 'replace_file_content' ||
|
|
369
|
+
toolName === 'multi_replace_file_content' ||
|
|
370
|
+
toolName === 'write_to_file'
|
|
371
|
+
) {
|
|
372
|
+
catType = 'CODE_ACTION'
|
|
373
|
+
} else if (
|
|
374
|
+
toolName === 'call_mcp_tool' ||
|
|
375
|
+
toolName.startsWith('mcp_') ||
|
|
376
|
+
toolName.startsWith('katlux_')
|
|
377
|
+
) {
|
|
378
|
+
catType = 'MCP_TOOL'
|
|
379
|
+
} else if (toolName === 'grep_search') {
|
|
380
|
+
catType = 'GREP_SEARCH'
|
|
381
|
+
} else if (toolName === 'list_dir' || toolName === 'find_by_name') {
|
|
382
|
+
catType = 'LIST_DIRECTORY'
|
|
383
|
+
} else {
|
|
384
|
+
catType = 'OTHER'
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
catType = 'OTHER'
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const cat = categories[catType] || categories.OTHER
|
|
273
392
|
cat.count++
|
|
274
393
|
cat.chars += chars
|
|
275
394
|
cat.tokens += tokens
|
|
276
395
|
|
|
277
396
|
spikes.push({
|
|
278
397
|
step_index: step.step_index,
|
|
279
|
-
type,
|
|
398
|
+
type: type === 'GENERIC' && catType !== 'OTHER' ? `${type} (${catType})` : type,
|
|
280
399
|
tokens,
|
|
281
400
|
chars,
|
|
282
401
|
preview: content.replace(/[\r\n\t]+/g, ' ').slice(0, 80).trim()
|
|
@@ -304,6 +423,7 @@ export function analyzeSession(steps, conversationId, mtime = new Date(), previe
|
|
|
304
423
|
inputTokens,
|
|
305
424
|
outputTokens,
|
|
306
425
|
categories,
|
|
426
|
+
mcpCalls,
|
|
307
427
|
spikes: spikes.slice(0, 5),
|
|
308
428
|
userPrompts,
|
|
309
429
|
topViewedFiles,
|
|
@@ -415,15 +535,22 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
415
535
|
|
|
416
536
|
if (analyzedSessions.length === 0) continue
|
|
417
537
|
|
|
418
|
-
|
|
419
|
-
const
|
|
538
|
+
// Filter out trivial (< 6 steps) ping/hello sessions from task averages
|
|
539
|
+
const realTasks = analyzedSessions.filter(s => s.totalSteps >= 6)
|
|
540
|
+
const targetSessions = realTasks.length > 0 ? realTasks : analyzedSessions
|
|
541
|
+
const trivialCount = analyzedSessions.length - targetSessions.length
|
|
542
|
+
|
|
543
|
+
const count = targetSessions.length
|
|
544
|
+
const sum = (fn) => targetSessions.reduce((s, x) => s + fn(x), 0)
|
|
420
545
|
const avg = (fn) => Math.round(sum(fn) / count)
|
|
421
546
|
|
|
422
547
|
const avgTotalTokens = avg(s => s.totalTokens)
|
|
423
548
|
const avgInputTokens = avg(s => s.inputTokens)
|
|
424
549
|
const avgOutputTokens = avg(s => s.outputTokens)
|
|
425
|
-
const avgRunCmdTokens = avg(s => s.categories.RUN_COMMAND
|
|
426
|
-
const avgViewFileTokens = avg(s => s.categories.VIEW_FILE
|
|
550
|
+
const avgRunCmdTokens = avg(s => s.categories.RUN_COMMAND?.tokens || 0)
|
|
551
|
+
const avgViewFileTokens = avg(s => s.categories.VIEW_FILE?.tokens || 0)
|
|
552
|
+
const avgMcpTokens = avg(s => s.categories.MCP_TOOL?.tokens || 0)
|
|
553
|
+
const avgMcpCalls = avg(s => s.mcpCalls?.total || 0)
|
|
427
554
|
const avgSteps = avg(s => s.totalSteps)
|
|
428
555
|
|
|
429
556
|
const claudeCost = ((avgInputTokens / 1_000_000) * 3.00 + (avgOutputTokens / 1_000_000) * 15.00).toFixed(2)
|
|
@@ -434,7 +561,7 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
434
561
|
const weekViewedFiles = new Map()
|
|
435
562
|
const weekModifiedFiles = new Map()
|
|
436
563
|
|
|
437
|
-
|
|
564
|
+
targetSessions.forEach(s => {
|
|
438
565
|
Object.entries(s.categories).forEach(([k, cat]) => {
|
|
439
566
|
if (!weekCategories[k]) weekCategories[k] = { label: cat.label, count: 0, tokens: 0 }
|
|
440
567
|
weekCategories[k].count += cat.count
|
|
@@ -448,10 +575,13 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
448
575
|
weekKey: wk,
|
|
449
576
|
dateRange: entry.dateRange,
|
|
450
577
|
sessionCount: count,
|
|
578
|
+
trivialCount,
|
|
451
579
|
totalTokensSum: sum(s => s.totalTokens),
|
|
452
580
|
avgTotalTokens,
|
|
453
581
|
avgRunCmdTokens,
|
|
454
582
|
avgViewFileTokens,
|
|
583
|
+
avgMcpTokens,
|
|
584
|
+
avgMcpCalls,
|
|
455
585
|
avgSteps,
|
|
456
586
|
claudeCost,
|
|
457
587
|
geminiCost,
|
|
@@ -485,19 +615,20 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
485
615
|
md.push(`*Scope: ${projectLabel} | Analyzed ${activeConversations.length} sessions across ${weeklyStats.length} calendar weeks*\n`)
|
|
486
616
|
|
|
487
617
|
md.push(`## 1. Week-by-Week Token & Efficiency Progression\n`)
|
|
488
|
-
md.push(`| Calendar Week | Date Range | Tasks | Avg Tokens / Task | Avg Test Tokens | Avg File View | Avg Steps | Avg Cost (Claude) | WoW Trend |`)
|
|
489
|
-
md.push(`| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |`)
|
|
618
|
+
md.push(`| Calendar Week | Date Range | Tasks | Avg Tokens / Task | Avg Test Tokens | Avg File View | Avg MCP Tokens | Avg Steps | Avg Cost (Claude) | WoW Trend |`)
|
|
619
|
+
md.push(`| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |`)
|
|
490
620
|
|
|
491
621
|
weeklyStats.forEach((w, idx) => {
|
|
492
622
|
const isCurrent = idx === 0 ? ' **(Current)**' : ''
|
|
493
623
|
const wowStr = w.wowPct !== null ? `${Number(w.wowPct) <= 0 ? w.wowPct + '%' : '+' + w.wowPct + '%'}` : '—'
|
|
494
|
-
md.push(`| **${w.weekKey}**${isCurrent} | ${w.dateRange} | ${w.sessionCount} | **${formatTokens(w.avgTotalTokens)}** | ${formatTokens(w.avgRunCmdTokens)} | ${formatTokens(w.avgViewFileTokens)} | ${w.avgSteps} | $${w.claudeCost} | ${wowStr} |`)
|
|
624
|
+
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} |`)
|
|
495
625
|
})
|
|
496
626
|
md.push('')
|
|
497
627
|
|
|
498
628
|
md.push(`## 2. Weekly Details & Most Frequent Files\n`)
|
|
499
629
|
weeklyStats.forEach(w => {
|
|
500
|
-
|
|
630
|
+
const trivialSuffix = w.trivialCount > 0 ? ` (+${w.trivialCount} trivial)` : ''
|
|
631
|
+
md.push(`### ${w.weekKey} (${w.dateRange}) — ${w.sessionCount} Tasks${trivialSuffix} | Avg ${formatTokens(w.avgTotalTokens)} Tokens | Cost $${w.claudeCost}`)
|
|
501
632
|
if (w.topViewed.length > 0) {
|
|
502
633
|
md.push(`- **Most Read Files:** ${w.topViewed.map(([f, n]) => `\`${f}\` (${n}x)`).join(', ')}`)
|
|
503
634
|
}
|
|
@@ -537,8 +668,8 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
537
668
|
console.log(` Scope: ${BOLD}${projectLabel}${RESET} (${activeConversations.length} total sessions analyzed across ${weeklyStats.length} calendar weeks)\n`)
|
|
538
669
|
|
|
539
670
|
console.log(`${BOLD}1. WEEK-BY-WEEK PROGRESSION TABLE${RESET}`)
|
|
540
|
-
console.log(` ${'WEEK'.padEnd(10)} ${'DATE RANGE'.padEnd(16)} ${'TASKS'.padStart(6)} ${'AVG TOKENS'.padStart(11)} ${'TESTS'.padStart(8)} ${'VIEW'.padStart(8)} ${'STEPS'.padStart(6)} ${'COST'.padStart(7)} ${'WoW TREND'.padStart(10)}`)
|
|
541
|
-
console.log(` ${'─'.repeat(10)} ${'─'.repeat(16)} ${'─'.repeat(6)} ${'─'.repeat(11)} ${'─'.repeat(8)} ${'─'.repeat(8)} ${'─'.repeat(6)} ${'─'.repeat(7)} ${'─'.repeat(10)}`)
|
|
671
|
+
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)}`)
|
|
672
|
+
console.log(` ${'─'.repeat(10)} ${'─'.repeat(16)} ${'─'.repeat(6)} ${'─'.repeat(11)} ${'─'.repeat(8)} ${'─'.repeat(8)} ${'─'.repeat(8)} ${'─'.repeat(6)} ${'─'.repeat(7)} ${'─'.repeat(10)}`)
|
|
542
673
|
|
|
543
674
|
weeklyStats.forEach((w, idx) => {
|
|
544
675
|
const isCurrent = idx === 0
|
|
@@ -553,6 +684,7 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
553
684
|
`${BOLD}${formatTokens(w.avgTotalTokens).padStart(11)}${RESET} ` +
|
|
554
685
|
`${formatTokens(w.avgRunCmdTokens).padStart(8)} ` +
|
|
555
686
|
`${formatTokens(w.avgViewFileTokens).padStart(8)} ` +
|
|
687
|
+
`${formatTokens(w.avgMcpTokens).padStart(8)} ` +
|
|
556
688
|
`${String(w.avgSteps).padStart(6)} ` +
|
|
557
689
|
`${('$' + w.claudeCost).padStart(7)} ` +
|
|
558
690
|
`${wowColor}${wowStr.padStart(10)}${RESET}`
|
|
@@ -564,7 +696,8 @@ export function generateWeekReport({ weekFilter = '', projectFilter = '', asMark
|
|
|
564
696
|
console.log(`${BOLD}2. WEEKLY DETAILS & MOST FREQUENT FILES${RESET}`)
|
|
565
697
|
weeklyStats.forEach(w => {
|
|
566
698
|
const totalWeekTokens = Object.values(w.categories).reduce((s, x) => s + x.tokens, 0)
|
|
567
|
-
|
|
699
|
+
const trivialSuffix = w.trivialCount > 0 ? ` (+${w.trivialCount} trivial)` : ''
|
|
700
|
+
console.log(` ${CYAN}${BOLD}[Week ${w.weekKey}: ${w.dateRange}]${RESET} — ${w.sessionCount} Tasks${trivialSuffix} | Avg ${formatTokens(w.avgTotalTokens)} Tokens | Avg Steps: ${w.avgSteps}`)
|
|
568
701
|
if (w.topViewed.length > 0) {
|
|
569
702
|
console.log(` ${CYAN}Most Read:${RESET} ${w.topViewed.map(([f, n]) => `${f} (${n}x)`).join(', ')}`)
|
|
570
703
|
}
|
|
@@ -728,13 +861,14 @@ if ((isExplicitList && !targetIndex) || (searchQuery && !targetIndex)) {
|
|
|
728
861
|
process.exit(0)
|
|
729
862
|
}
|
|
730
863
|
|
|
731
|
-
console.log(` ${'#'.padStart(4)} ${'ID'.padEnd(9)} ${'PROJECT'.padEnd(16)} ${'WEEK'.padEnd(6)} ${'TOPIC / PROMPT'.padEnd(
|
|
732
|
-
console.log(` ${'─'.repeat(4)} ${'─'.repeat(9)} ${'─'.repeat(16)} ${'─'.repeat(6)} ${'─'.repeat(
|
|
864
|
+
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`)
|
|
865
|
+
console.log(` ${'─'.repeat(4)} ${'─'.repeat(9)} ${'─'.repeat(16)} ${'─'.repeat(6)} ${'─'.repeat(34)} ${'─'.repeat(8)} ${'─'.repeat(19)} ${'─'.repeat(19)}`)
|
|
733
866
|
|
|
734
867
|
pageItems.forEach(conv => {
|
|
735
868
|
const preview = conv.preview
|
|
736
869
|
const shortId = conv.id.slice(0, 8)
|
|
737
|
-
const
|
|
870
|
+
const lastActiveStr = formatDateTime(conv.lastActive)
|
|
871
|
+
const createdStr = formatDateTime(conv.createdAt)
|
|
738
872
|
const shortWeek = conv.weekKey.replace('2026-', '')
|
|
739
873
|
const prjStr = (preview.project || 'Unknown').slice(0, 15)
|
|
740
874
|
|
|
@@ -744,9 +878,10 @@ if ((isExplicitList && !targetIndex) || (searchQuery && !targetIndex)) {
|
|
|
744
878
|
`${shortId.padEnd(9)} ` +
|
|
745
879
|
`${YELLOW}${prjStr.padEnd(16)}${RESET} ` +
|
|
746
880
|
`${DIM}${shortWeek.padEnd(6)}${RESET} ` +
|
|
747
|
-
`${preview.title.padEnd(
|
|
748
|
-
`${BOLD}${formatTokens(preview.estimatedTokens).padStart(
|
|
749
|
-
`${
|
|
881
|
+
`${preview.title.padEnd(34)} ` +
|
|
882
|
+
`${BOLD}${formatTokens(preview.estimatedTokens).padStart(8)}${RESET} ` +
|
|
883
|
+
`${GREEN}${lastActiveStr.padEnd(19)}${RESET} ` +
|
|
884
|
+
`${DIM}${createdStr}${RESET}`
|
|
750
885
|
)
|
|
751
886
|
})
|
|
752
887
|
|
|
@@ -801,6 +936,8 @@ console.log(` ${BOLD}Conversation Index:${RESET} ${GREEN}#${convIndex}${RESET}
|
|
|
801
936
|
console.log(` ${BOLD}Project:${RESET} ${YELLOW}${data.project}${RESET} (${CYAN}${data.weekKey}${RESET})`)
|
|
802
937
|
console.log(` ${BOLD}Conversation ID:${RESET} ${CYAN}${data.conversationId}${RESET}`)
|
|
803
938
|
console.log(` ${BOLD}Topic / Prompt:${RESET} ${YELLOW}"${data.sessionTitle}"${RESET}`)
|
|
939
|
+
console.log(` ${BOLD}Started:${RESET} ${formatDateTime(selectedConv.createdAt)}`)
|
|
940
|
+
console.log(` ${BOLD}Last Active:${RESET} ${GREEN}${formatDateTime(selectedConv.lastActive)}${RESET}`)
|
|
804
941
|
console.log(` ${BOLD}Total Steps:${RESET} ${data.totalSteps} recorded steps`)
|
|
805
942
|
console.log(` ${BOLD}Transcript Size:${RESET} ${formatBytes(data.totalChars)} total characters\n`)
|
|
806
943
|
|
|
@@ -820,14 +957,26 @@ console.log(` GPT-4o : ${CYAN}$${gptCost}${RESET}\n`)
|
|
|
820
957
|
// User turns / questions in this conversation
|
|
821
958
|
if (data.userPrompts.length > 0) {
|
|
822
959
|
console.log(`${BOLD}Conversation Turns (${data.userPrompts.length} User Requests):${RESET}`)
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
960
|
+
if (data.userPrompts.length <= 8) {
|
|
961
|
+
data.userPrompts.forEach((p, idx) => {
|
|
962
|
+
const timeLabel = p.time ? `${DIM}(${p.time})${RESET} ` : ''
|
|
963
|
+
console.log(` ${CYAN}Turn ${idx + 1}${RESET} [Step #${p.step}] ${timeLabel}${p.text.slice(0, 85)}${p.text.length > 85 ? '...' : ''}`)
|
|
964
|
+
})
|
|
965
|
+
} else {
|
|
966
|
+
data.userPrompts.slice(0, 2).forEach((p, idx) => {
|
|
967
|
+
const timeLabel = p.time ? `${DIM}(${p.time})${RESET} ` : ''
|
|
968
|
+
console.log(` ${CYAN}Turn ${idx + 1}${RESET} [Step #${p.step}] ${timeLabel}${p.text.slice(0, 85)}${p.text.length > 85 ? '...' : ''}`)
|
|
969
|
+
})
|
|
970
|
+
console.log(` ${DIM}... and ${data.userPrompts.length - 8} earlier turns ...${RESET}`)
|
|
971
|
+
const lastTurns = data.userPrompts.slice(-6)
|
|
972
|
+
const startIdx = data.userPrompts.length - 6
|
|
973
|
+
lastTurns.forEach((p, i) => {
|
|
974
|
+
const idx = startIdx + i
|
|
975
|
+
const timeLabel = p.time ? `${GREEN}(${p.time})${RESET} ` : ''
|
|
976
|
+
console.log(` ${CYAN}Turn ${idx + 1}${RESET} [Step #${p.step}] ${timeLabel}${p.text.slice(0, 85)}${p.text.length > 85 ? '...' : ''}`)
|
|
977
|
+
})
|
|
829
978
|
}
|
|
830
|
-
console.log()
|
|
979
|
+
console.log(` ${DIM}Tip: Run with -d to see full chronology of every turn and tool call.${RESET}\n`)
|
|
831
980
|
}
|
|
832
981
|
|
|
833
982
|
console.log(`${BOLD}Token Breakdown by Event Category:${RESET}`)
|
|
@@ -859,6 +1008,15 @@ if (data.topViewedFiles.length > 0 || data.topModifiedFiles.length > 0) {
|
|
|
859
1008
|
}
|
|
860
1009
|
}
|
|
861
1010
|
|
|
1011
|
+
if (data.mcpCalls && data.mcpCalls.total > 0) {
|
|
1012
|
+
console.log(`\n${BOLD}MCP Introspection Invocations:${RESET}`)
|
|
1013
|
+
console.log(` katlux_inspect_project : ${data.mcpCalls.inspectProject} call(s)`)
|
|
1014
|
+
console.log(` katlux_validate_code : ${data.mcpCalls.validateCode} call(s)`)
|
|
1015
|
+
if (data.mcpCalls.otherMcp > 0) {
|
|
1016
|
+
console.log(` other MCP tools : ${data.mcpCalls.otherMcp} call(s)`)
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
862
1020
|
console.log(`\n${BOLD}Top 5 Largest Token Spikes in this Session:${RESET}`)
|
|
863
1021
|
data.spikes.forEach((spike, idx) => {
|
|
864
1022
|
console.log(` ${idx + 1}. [Step #${spike.step_index}] ${YELLOW}${formatTokens(spike.tokens)} tokens${RESET} (${spike.type})`)
|
package/bin/cli.mjs
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Supported commands:
|
|
6
6
|
* npx @katlux/toolkit create-preset <preset-name> [--base=<base>]
|
|
7
|
-
* npx @katlux/toolkit katlux-
|
|
8
|
-
*
|
|
9
|
-
* katlux
|
|
10
|
-
* and scaffolds AGENTS.md + .agents/rules/rules.md if they don't exist.
|
|
7
|
+
* npx @katlux/toolkit katlux-ai-init [options]
|
|
8
|
+
* npx @katlux/toolkit tokens [--report]
|
|
9
|
+
* npx @katlux/toolkit mcp [args...]
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
import { spawn } from 'child_process'
|
|
14
13
|
import { existsSync } from 'fs'
|
|
15
14
|
import { resolve, dirname } from 'path'
|
|
16
15
|
import { fileURLToPath } from 'url'
|
|
16
|
+
import { resolvePackageVersions } from './ai-init.mjs'
|
|
17
17
|
|
|
18
18
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
19
19
|
|
|
@@ -21,11 +21,10 @@ const RESET = '\x1b[0m'
|
|
|
21
21
|
const CYAN = '\x1b[36m'
|
|
22
22
|
const BOLD = '\x1b[1m'
|
|
23
23
|
const RED = '\x1b[31m'
|
|
24
|
+
const YELLOW = '\x1b[33m'
|
|
25
|
+
const DIM = '\x1b[2m'
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
const command = args[0]
|
|
27
|
-
|
|
28
|
-
function printHelp() {
|
|
27
|
+
export function printHelp() {
|
|
29
28
|
console.log(`
|
|
30
29
|
${BOLD}Katlux Toolkit CLI${RESET}
|
|
31
30
|
|
|
@@ -37,63 +36,93 @@ ${BOLD}Commands:${RESET}
|
|
|
37
36
|
Scaffold a new custom preset (e.g. "cyber-brand --base=modern").
|
|
38
37
|
Any preset can be token-only. Base presets leverage cascading inheritance without copying files.
|
|
39
38
|
|
|
40
|
-
${CYAN}katlux-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
${CYAN}katlux-ai-init [options]${RESET}
|
|
40
|
+
Initialize Katlux AI skills, context (AGENTS.md), and configure MCP server.
|
|
41
|
+
Flags: --cursor, --vscode, --all, --scripts, --dry-run, --force.
|
|
43
42
|
|
|
44
43
|
${CYAN}tokens [--report] [-w <week>] [-p <page>]${RESET}
|
|
45
44
|
Analyze AI conversation token usage, week-by-week trends, and session logs.
|
|
46
45
|
|
|
47
46
|
${CYAN}mcp${RESET}
|
|
48
47
|
Start the Katlux Model Context Protocol (MCP) server over stdio for AI coding assistants.
|
|
48
|
+
Pins @katlux/mcp version to match installed @katlux/toolkit.
|
|
49
49
|
|
|
50
50
|
${BOLD}Examples:${RESET}
|
|
51
|
+
npx @katlux/toolkit katlux-ai-init --all
|
|
52
|
+
npx @katlux/toolkit katlux-ai-init --cursor
|
|
51
53
|
npx @katlux/toolkit tokens --report
|
|
52
|
-
npx @katlux/toolkit tokens -p 1
|
|
53
54
|
npx @katlux/toolkit create-preset cyber-brand --base=modern
|
|
54
|
-
npx @katlux/toolkit create-preset my-theme
|
|
55
|
-
npx @katlux/toolkit katlux-add-ref
|
|
56
55
|
npx @katlux/toolkit mcp
|
|
57
56
|
`)
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the pinned MCP command and arguments for spawning npx.
|
|
61
|
+
*/
|
|
62
|
+
export function resolveMcpCommand(projectRoot = process.cwd(), extraArgs = []) {
|
|
63
|
+
const { mcpVersion } = resolvePackageVersions(projectRoot)
|
|
64
|
+
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx'
|
|
65
|
+
return {
|
|
66
|
+
command: npxCmd,
|
|
67
|
+
args: ['-y', `@katlux/mcp@${mcpVersion}`, ...extraArgs],
|
|
68
|
+
mcpVersion
|
|
69
|
+
}
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
scriptPath =
|
|
81
|
-
forwardedArgs =
|
|
82
|
-
} else {
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Main dispatcher logic
|
|
74
|
+
*/
|
|
75
|
+
export function runCli(argv = process.argv.slice(2)) {
|
|
76
|
+
const command = argv[0]
|
|
77
|
+
|
|
78
|
+
if (!command || command === '--help' || command === '-h' || command === 'help') {
|
|
79
|
+
printHelp()
|
|
80
|
+
return { status: 'help' }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let scriptPath = null
|
|
84
|
+
let forwardedArgs = []
|
|
85
|
+
|
|
86
|
+
if (command === 'create-preset') {
|
|
87
|
+
scriptPath = resolve(__dirname, 'create-preset.mjs')
|
|
88
|
+
forwardedArgs = argv.slice(1)
|
|
89
|
+
} else if (command === 'katlux-ai-init' || command === 'ai-init') {
|
|
90
|
+
scriptPath = resolve(__dirname, 'ai-init.mjs')
|
|
91
|
+
forwardedArgs = argv.slice(1)
|
|
92
|
+
} else if (command === 'tokens' || command === 'ai-tokens') {
|
|
93
|
+
scriptPath = resolve(__dirname, 'ai-tokens.mjs')
|
|
94
|
+
forwardedArgs = argv.slice(1)
|
|
95
|
+
} else if (command === 'mcp') {
|
|
96
|
+
const { command: npxCmd, args: mcpArgs, mcpVersion } = resolveMcpCommand(process.cwd(), argv.slice(1))
|
|
97
|
+
const child = spawn(npxCmd, mcpArgs, { stdio: 'inherit' })
|
|
85
98
|
child.on('exit', (code) => process.exit(code ?? 0))
|
|
99
|
+
return { status: 'spawned', child, command: npxCmd, args: mcpArgs, mcpVersion }
|
|
100
|
+
} else {
|
|
101
|
+
console.log(`${RED}${BOLD}[katlux] ✖${RESET} Unknown command: "${command}"`)
|
|
102
|
+
printHelp()
|
|
103
|
+
process.exit(1)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (scriptPath) {
|
|
107
|
+
const child = spawn(process.execPath, [scriptPath, ...forwardedArgs], {
|
|
108
|
+
stdio: 'inherit',
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
child.on('exit', (code) => {
|
|
112
|
+
process.exit(code ?? 0)
|
|
113
|
+
})
|
|
114
|
+
return { status: 'spawned', child, scriptPath, args: forwardedArgs }
|
|
86
115
|
}
|
|
87
|
-
} else {
|
|
88
|
-
console.log(`${RED}${BOLD}[katlux] ✖${RESET} Unknown command: "${command}"`)
|
|
89
|
-
printHelp()
|
|
90
|
-
process.exit(1)
|
|
91
116
|
}
|
|
92
117
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
// Execute directly if run as CLI script
|
|
119
|
+
const isMain = process.argv[1] && (
|
|
120
|
+
process.argv[1].endsWith('cli.mjs') ||
|
|
121
|
+
process.argv[1].endsWith('katlux') ||
|
|
122
|
+
process.argv[1].endsWith('katlux-toolkit') ||
|
|
123
|
+
process.argv[1].endsWith('toolkit')
|
|
124
|
+
)
|
|
96
125
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
126
|
+
if (isMain) {
|
|
127
|
+
runCli()
|
|
128
|
+
}
|
package/bin/create-preset.mjs
CHANGED