skilltally 1.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +15 -7
- package/bin/cli.mjs +163 -1
- package/bin/track.mjs +168 -4
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills/skilltally/SKILL.md +23 -8
- package/src/backfill/antigravity.mjs +85 -31
- package/src/backfill/claude.mjs +58 -5
- package/src/backfill/codex.mjs +56 -2
- package/src/backfill/gemini.mjs +66 -3
- package/src/backfill/index.mjs +7 -5
- package/src/core/config.mjs +2 -0
- package/src/core/detect.mjs +2 -0
- package/src/install/prune.mjs +355 -0
- package/src/inventory/scan.mjs +3 -1
- package/src/mcp/server.mjs +345 -0
- package/src/report/aggregate.mjs +421 -18
- package/src/report/chains.mjs +187 -0
- package/src/report/dashboard.mjs +1303 -0
- package/src/report/format.mjs +276 -2
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { getHomeDir, loadConfig } from '../core/config.mjs';
|
|
3
|
+
import { readAllEvents } from '../core/store.mjs';
|
|
4
|
+
import { scanInventory } from '../inventory/scan.mjs';
|
|
5
|
+
import { aggregateStats } from '../report/aggregate.mjs';
|
|
6
|
+
import { buildChains } from '../report/chains.mjs';
|
|
7
|
+
import { buildTimeline } from '../report/timeline.mjs';
|
|
8
|
+
|
|
9
|
+
const MCP_TOOLS = [
|
|
10
|
+
{
|
|
11
|
+
name: 'skilltally_stats',
|
|
12
|
+
description:
|
|
13
|
+
'Get skill activation and read statistics (including 14d sparklines, trigger ratios, and context ROI) across Antigravity, Claude Code, Codex, and Gemini CLI.',
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
since: { type: 'string', description: 'Time window: e.g. 7d, 30d, 90d, 2026-01-01, or all (default: 30d)' },
|
|
18
|
+
host: { type: 'string', description: 'Optional host filter: antigravity, claude, codex, gemini, or all' },
|
|
19
|
+
project: { type: 'string', description: 'Optional project basename filter' },
|
|
20
|
+
bySource: { type: 'boolean', description: 'Separate duplicate skill names by source' },
|
|
21
|
+
metric: { type: 'string', enum: ['activations', 'reads'], description: 'Sort metric (default: activations)' },
|
|
22
|
+
limit: { type: 'number', description: 'Optional max number of skill rows to return' },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'skilltally_unused',
|
|
28
|
+
description:
|
|
29
|
+
'List enabled installed skills with zero activations in the window and compute Context Tax (KB and ~tokens/session) grouped by source.',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
since: { type: 'string', description: 'Time window (default: 90d)' },
|
|
34
|
+
host: { type: 'string', description: 'Optional host filter' },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'skilltally_timeline',
|
|
40
|
+
description: 'Aggregate skill activations and reads over time buckets (day, week, or month).',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: {
|
|
44
|
+
skill: { type: 'string', description: 'Optional skill name filter' },
|
|
45
|
+
by: { type: 'string', enum: ['day', 'week', 'month'], description: 'Bucket granularity (default: day)' },
|
|
46
|
+
since: { type: 'string', description: 'Time window (default: 30d)' },
|
|
47
|
+
host: { type: 'string', description: 'Optional host filter' },
|
|
48
|
+
project: { type: 'string', description: 'Optional project basename filter' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'skilltally_chains',
|
|
54
|
+
description:
|
|
55
|
+
'Analyze multi-skill session workflows: ordered transitions (A -> B), 3-step sequences, and co-occurring skill pairs with Jaccard similarity.',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
since: { type: 'string', description: 'Time window (default: 30d)' },
|
|
60
|
+
host: { type: 'string', description: 'Optional host filter' },
|
|
61
|
+
project: { type: 'string', description: 'Optional project basename filter' },
|
|
62
|
+
limit: { type: 'number', description: 'Max entries per section (default: 20)' },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'skilltally_insights',
|
|
68
|
+
description:
|
|
69
|
+
'Return actionable optimization insights: Context Tax ROI, manual-only skills needing better SKILL.md descriptions, single-project scoping candidates, and model breakdown.',
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
since: { type: 'string', description: 'Time window (default: 30d)' },
|
|
74
|
+
host: { type: 'string', description: 'Optional host filter' },
|
|
75
|
+
project: { type: 'string', description: 'Optional project basename filter' },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
function toolError(id, message) {
|
|
82
|
+
return {
|
|
83
|
+
jsonrpc: '2.0',
|
|
84
|
+
id,
|
|
85
|
+
result: {
|
|
86
|
+
isError: true,
|
|
87
|
+
content: [{ type: 'text', text: String(message) }],
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function toolOk(id, payload) {
|
|
93
|
+
return {
|
|
94
|
+
jsonrpc: '2.0',
|
|
95
|
+
id,
|
|
96
|
+
result: {
|
|
97
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function handleMcpRequest(
|
|
103
|
+
msg,
|
|
104
|
+
{ dataHome = getHomeDir(), pkgVersion = '1.1.0', homeDir = homedir(), cwd = process.cwd() } = {}
|
|
105
|
+
) {
|
|
106
|
+
if (!msg || typeof msg !== 'object') {
|
|
107
|
+
return { jsonrpc: '2.0', id: null, error: { code: -32600, message: 'Invalid Request' } };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const method = msg.method;
|
|
111
|
+
const hasId = msg.id !== undefined && msg.id !== null;
|
|
112
|
+
|
|
113
|
+
if (typeof method === 'string' && method.startsWith('notifications/')) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
if (!hasId) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (method === 'initialize') {
|
|
121
|
+
return {
|
|
122
|
+
jsonrpc: '2.0',
|
|
123
|
+
id: msg.id,
|
|
124
|
+
result: {
|
|
125
|
+
protocolVersion: msg.params?.protocolVersion || '2024-11-05',
|
|
126
|
+
capabilities: { tools: {} },
|
|
127
|
+
serverInfo: { name: 'skilltally', version: pkgVersion },
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (method === 'ping') {
|
|
133
|
+
return { jsonrpc: '2.0', id: msg.id, result: {} };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (method === 'tools/list') {
|
|
137
|
+
return {
|
|
138
|
+
jsonrpc: '2.0',
|
|
139
|
+
id: msg.id,
|
|
140
|
+
result: { tools: MCP_TOOLS },
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (method === 'tools/call') {
|
|
145
|
+
const toolName = msg.params?.name;
|
|
146
|
+
const args = msg.params?.arguments && typeof msg.params.arguments === 'object' ? msg.params.arguments : {};
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
const { events, corruptLines } = readAllEvents(dataHome);
|
|
150
|
+
const config = loadConfig(dataHome);
|
|
151
|
+
const inventory = scanInventory({ homeDir, cwd, includeProject: true });
|
|
152
|
+
|
|
153
|
+
if (toolName === 'skilltally_stats') {
|
|
154
|
+
const report = aggregateStats({
|
|
155
|
+
events,
|
|
156
|
+
inventory,
|
|
157
|
+
config,
|
|
158
|
+
since: args.since ?? '30d',
|
|
159
|
+
host: args.host || null,
|
|
160
|
+
project: args.project || null,
|
|
161
|
+
bySource: Boolean(args.bySource),
|
|
162
|
+
metric: args.metric === 'reads' ? 'reads' : 'activations',
|
|
163
|
+
});
|
|
164
|
+
const limit = args.limit !== undefined ? Number(args.limit) : null;
|
|
165
|
+
if (limit !== null && (!Number.isFinite(limit) || limit < 1)) {
|
|
166
|
+
return toolError(msg.id, `Invalid limit: "${args.limit}"`);
|
|
167
|
+
}
|
|
168
|
+
const rows = limit ? report.rows.slice(0, limit) : report.rows;
|
|
169
|
+
return toolOk(msg.id, { ...report, rows, corruptLines });
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (toolName === 'skilltally_unused') {
|
|
173
|
+
const report = aggregateStats({
|
|
174
|
+
events,
|
|
175
|
+
inventory,
|
|
176
|
+
config,
|
|
177
|
+
since: args.since ?? '90d',
|
|
178
|
+
host: args.host || null,
|
|
179
|
+
});
|
|
180
|
+
return toolOk(msg.id, {
|
|
181
|
+
window: report.window,
|
|
182
|
+
inventory: report.inventory,
|
|
183
|
+
unused: report.unused,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (toolName === 'skilltally_timeline') {
|
|
188
|
+
const timeline = buildTimeline({
|
|
189
|
+
events,
|
|
190
|
+
inventory,
|
|
191
|
+
config,
|
|
192
|
+
skill: args.skill || null,
|
|
193
|
+
by: args.by ?? 'day',
|
|
194
|
+
since: args.since ?? '30d',
|
|
195
|
+
host: args.host || null,
|
|
196
|
+
project: args.project || null,
|
|
197
|
+
});
|
|
198
|
+
return toolOk(msg.id, timeline);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (toolName === 'skilltally_chains') {
|
|
202
|
+
const limit = args.limit !== undefined ? Number(args.limit) : 20;
|
|
203
|
+
if (!Number.isFinite(limit) || limit < 1) {
|
|
204
|
+
return toolError(msg.id, `Invalid limit: "${args.limit}"`);
|
|
205
|
+
}
|
|
206
|
+
const chains = buildChains({
|
|
207
|
+
events,
|
|
208
|
+
inventory,
|
|
209
|
+
config,
|
|
210
|
+
since: args.since ?? '30d',
|
|
211
|
+
host: args.host || null,
|
|
212
|
+
project: args.project || null,
|
|
213
|
+
limit,
|
|
214
|
+
});
|
|
215
|
+
return toolOk(msg.id, chains);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (toolName === 'skilltally_insights') {
|
|
219
|
+
const report = aggregateStats({
|
|
220
|
+
events,
|
|
221
|
+
inventory,
|
|
222
|
+
config,
|
|
223
|
+
since: args.since ?? '30d',
|
|
224
|
+
host: args.host || null,
|
|
225
|
+
project: args.project || null,
|
|
226
|
+
});
|
|
227
|
+
return toolOk(msg.id, {
|
|
228
|
+
window: report.window,
|
|
229
|
+
totals: report.totals,
|
|
230
|
+
inventory: report.inventory,
|
|
231
|
+
insights: report.insights,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return toolError(msg.id, `Unknown tool: "${toolName}"`);
|
|
236
|
+
} catch (err) {
|
|
237
|
+
return toolError(msg.id, err?.message || 'Tool execution failed');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
jsonrpc: '2.0',
|
|
243
|
+
id: msg.id,
|
|
244
|
+
error: { code: -32601, message: `Method not found: ${method}` },
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function sendMcpMessage(output, obj, framed) {
|
|
249
|
+
const json = JSON.stringify(obj);
|
|
250
|
+
if (framed) {
|
|
251
|
+
const bytes = Buffer.byteLength(json, 'utf8');
|
|
252
|
+
output.write(`Content-Length: ${bytes}\r\n\r\n${json}`);
|
|
253
|
+
} else {
|
|
254
|
+
output.write(`${json}\n`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function startMcpServer({
|
|
259
|
+
dataHome = getHomeDir(),
|
|
260
|
+
pkgVersion = '1.1.0',
|
|
261
|
+
homeDir = homedir(),
|
|
262
|
+
cwd = process.cwd(),
|
|
263
|
+
input = process.stdin,
|
|
264
|
+
output = process.stdout,
|
|
265
|
+
} = {}) {
|
|
266
|
+
let buf = Buffer.alloc(0);
|
|
267
|
+
|
|
268
|
+
const dispatchRaw = (rawJson, framed) => {
|
|
269
|
+
const trimmed = rawJson.trim();
|
|
270
|
+
if (!trimmed) return;
|
|
271
|
+
let parsed;
|
|
272
|
+
try {
|
|
273
|
+
parsed = JSON.parse(trimmed);
|
|
274
|
+
} catch {
|
|
275
|
+
sendMcpMessage(
|
|
276
|
+
output,
|
|
277
|
+
{ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } },
|
|
278
|
+
framed
|
|
279
|
+
);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const res = handleMcpRequest(parsed, { dataHome, pkgVersion, homeDir, cwd });
|
|
283
|
+
if (res !== null) {
|
|
284
|
+
sendMcpMessage(output, res, framed);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const drainBuffer = () => {
|
|
289
|
+
while (buf.length > 0) {
|
|
290
|
+
// Trim leading CR/LF before inspecting framing
|
|
291
|
+
let start = 0;
|
|
292
|
+
while (start < buf.length && (buf[start] === 0x0d || buf[start] === 0x0a)) {
|
|
293
|
+
start += 1;
|
|
294
|
+
}
|
|
295
|
+
if (start > 0) buf = buf.subarray(start);
|
|
296
|
+
if (buf.length === 0) break;
|
|
297
|
+
|
|
298
|
+
const prefix = buf.subarray(0, Math.min(32, buf.length)).toString('ascii');
|
|
299
|
+
if (/^content-length:/i.test(prefix)) {
|
|
300
|
+
let sepIdx = buf.indexOf('\r\n\r\n');
|
|
301
|
+
let sepLen = 4;
|
|
302
|
+
if (sepIdx === -1) {
|
|
303
|
+
sepIdx = buf.indexOf('\n\n');
|
|
304
|
+
sepLen = 2;
|
|
305
|
+
}
|
|
306
|
+
if (sepIdx === -1) break;
|
|
307
|
+
|
|
308
|
+
const header = buf.subarray(0, sepIdx).toString('ascii');
|
|
309
|
+
const m = header.match(/content-length:\s*(\d+)/i);
|
|
310
|
+
if (!m) {
|
|
311
|
+
buf = buf.subarray(sepIdx + sepLen);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const len = Number(m[1]);
|
|
315
|
+
const bodyStart = sepIdx + sepLen;
|
|
316
|
+
if (buf.length < bodyStart + len) break;
|
|
317
|
+
|
|
318
|
+
const body = buf.subarray(bodyStart, bodyStart + len).toString('utf8');
|
|
319
|
+
buf = buf.subarray(bodyStart + len);
|
|
320
|
+
dispatchRaw(body, true);
|
|
321
|
+
} else {
|
|
322
|
+
const nl = buf.indexOf(0x0a);
|
|
323
|
+
if (nl === -1) break;
|
|
324
|
+
const line = buf.subarray(0, nl).toString('utf8');
|
|
325
|
+
buf = buf.subarray(nl + 1);
|
|
326
|
+
dispatchRaw(line, false);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
input.on('data', (chunk) => {
|
|
332
|
+
const b = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
333
|
+
buf = Buffer.concat([buf, b]);
|
|
334
|
+
drainBuffer();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
input.on('end', () => {
|
|
338
|
+
drainBuffer();
|
|
339
|
+
const rest = buf.toString('utf8').trim();
|
|
340
|
+
if (rest && !/^content-length:/i.test(rest)) {
|
|
341
|
+
dispatchRaw(rest, false);
|
|
342
|
+
buf = Buffer.alloc(0);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|