skilltally 0.0.0-stage → 1.0.1
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/.agents/plugins/marketplace.json +21 -0
- package/.claude-plugin/marketplace.json +18 -0
- package/.claude-plugin/plugin.json +13 -0
- package/.codex-plugin/plugin.json +39 -0
- package/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +146 -2
- package/bin/cli.mjs +321 -0
- package/bin/track.mjs +331 -0
- package/gemini-extension.json +5 -0
- package/hooks/agy-fast-track.sh +28 -0
- package/hooks/claude-codex-hooks.json +18 -0
- package/hooks.json +16 -0
- package/package.json +53 -4
- package/plugin.json +17 -0
- package/skills/skilltally/SKILL.md +59 -0
- package/src/backfill/antigravity.mjs +150 -0
- package/src/backfill/claude.mjs +129 -0
- package/src/backfill/codex.mjs +200 -0
- package/src/backfill/gemini.mjs +152 -0
- package/src/backfill/index.mjs +83 -0
- package/src/core/config.mjs +33 -0
- package/src/core/debug.mjs +58 -0
- package/src/core/detect.mjs +9 -0
- package/src/core/normalize.mjs +78 -0
- package/src/core/store.mjs +99 -0
- package/src/install/antigravity.mjs +135 -0
- package/src/install/claude.mjs +116 -0
- package/src/install/codex.mjs +187 -0
- package/src/install/doctor.mjs +268 -0
- package/src/install/gemini.mjs +93 -0
- package/src/install/index.mjs +110 -0
- package/src/install/runtime.mjs +210 -0
- package/src/inventory/scan.mjs +397 -0
- package/src/report/aggregate.mjs +217 -0
- package/src/report/export.mjs +93 -0
- package/src/report/format.mjs +271 -0
- package/src/report/timeline.mjs +117 -0
package/bin/track.mjs
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// skilltally standalone hook entry & shared detection primitives.
|
|
3
|
+
// Contract when executed directly: NEVER throw, ALWAYS exit 0, ALWAYS print "{}".
|
|
4
|
+
import {
|
|
5
|
+
appendFileSync,
|
|
6
|
+
existsSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
realpathSync,
|
|
10
|
+
renameSync,
|
|
11
|
+
statSync,
|
|
12
|
+
} from 'node:fs';
|
|
13
|
+
import { homedir } from 'node:os';
|
|
14
|
+
import { basename, join } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
|
|
17
|
+
export const SKILL_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
18
|
+
export const SKILL_PATH_RE =
|
|
19
|
+
/((?:[A-Za-z]:|~)?[^\s"'`<>|;(){}\[\]]*?[\\/]skills[\\/]([A-Za-z0-9][A-Za-z0-9._-]{0,127})[\\/]SKILL\.md)(?=$|[\s"'`<>|;),}\]])/gi;
|
|
20
|
+
|
|
21
|
+
const PATH_KEYS = ['Path', 'AbsolutePath', 'TargetFile', 'file_path', 'path', 'absolute_path'];
|
|
22
|
+
const CMD_KEYS = ['CommandLine', 'command', 'cmd', 'input', 'argv'];
|
|
23
|
+
const WRITE_TOOL_RE = /^(write|edit|replace|apply_patch|multiedit|notebookedit|create_file|delete_file)/i;
|
|
24
|
+
const READ_CMD_RE = /^(cat|sed|head|tail|less|more|bat|nl|awk|type|Get-Content)\b/i;
|
|
25
|
+
const MUTATE_CMD_RE = /(?:^|\s)(?:sed|awk)\s+(?:[^\n]*\s)?(?:-i\S*|--in-place\b)|>{1,2}\s*[^\s]*SKILL\.md/i;
|
|
26
|
+
const CODEX_EXEC_CMD_RE = /\bcmd\s*:\s*("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/g;
|
|
27
|
+
|
|
28
|
+
function argValue(flag, argv = process.argv) {
|
|
29
|
+
const i = argv.indexOf(flag);
|
|
30
|
+
return i > 0 ? argv[i + 1] : undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function unwrapArg(val) {
|
|
34
|
+
if (typeof val !== 'string') return val;
|
|
35
|
+
if (val.length >= 2 && val[0] === '"' && val[val.length - 1] === '"') {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(val);
|
|
38
|
+
if (typeof parsed === 'string') return parsed;
|
|
39
|
+
} catch {
|
|
40
|
+
return val.slice(1, -1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function refineAntigravityHost(payload) {
|
|
47
|
+
const tp = String(payload?.transcriptPath ?? payload?.artifactDirectoryPath ?? '');
|
|
48
|
+
if (/[\\/]antigravity-ide[\\/]/i.test(tp)) return 'antigravity-ide';
|
|
49
|
+
if (/[\\/]antigravity-cli[\\/]/i.test(tp)) return 'antigravity-cli';
|
|
50
|
+
return 'antigravity';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolveHost(hostFlag, payload, env = process.env) {
|
|
54
|
+
if (hostFlag && hostFlag !== 'auto') {
|
|
55
|
+
if (hostFlag === 'antigravity') return refineAntigravityHost(payload);
|
|
56
|
+
return hostFlag;
|
|
57
|
+
}
|
|
58
|
+
if (payload?.toolCall) return refineAntigravityHost(payload);
|
|
59
|
+
if (payload?.hook_event_name === 'AfterTool' || env.GEMINI_PROJECT_DIR) return 'gemini';
|
|
60
|
+
const tp = String(payload?.transcript_path ?? '');
|
|
61
|
+
if (
|
|
62
|
+
env.CODEX_THREAD_ID ||
|
|
63
|
+
tp.includes('/.codex/') ||
|
|
64
|
+
tp.includes('\\.codex\\') ||
|
|
65
|
+
(env.PLUGIN_DATA && !env.CLAUDE_PLUGIN_ROOT)
|
|
66
|
+
) {
|
|
67
|
+
return 'codex';
|
|
68
|
+
}
|
|
69
|
+
if (env.CLAUDE_PLUGIN_ROOT || tp.includes('/.claude/') || tp.includes('\\.claude\\')) {
|
|
70
|
+
return 'claude';
|
|
71
|
+
}
|
|
72
|
+
return 'unknown';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function normalizeHookPayload(host, payload) {
|
|
76
|
+
const p = payload && typeof payload === 'object' ? payload : {};
|
|
77
|
+
if (String(host).startsWith('antigravity') || p.toolCall) {
|
|
78
|
+
const cwd = p.cwd ?? (Array.isArray(p.workspacePaths) ? p.workspacePaths[0] : undefined);
|
|
79
|
+
return {
|
|
80
|
+
tool: p.toolCall?.name,
|
|
81
|
+
args: p.toolCall?.args ?? {},
|
|
82
|
+
callId: p.toolCall?.id,
|
|
83
|
+
sessionId: p.conversationId,
|
|
84
|
+
cwd,
|
|
85
|
+
model: p.modelName,
|
|
86
|
+
failed: Boolean(p.error),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const resp = p.tool_response;
|
|
90
|
+
const failed =
|
|
91
|
+
Boolean(p.error) ||
|
|
92
|
+
resp?.is_error === true ||
|
|
93
|
+
(typeof resp?.exit_code === 'number' && resp.exit_code !== 0);
|
|
94
|
+
return {
|
|
95
|
+
tool: p.tool_name,
|
|
96
|
+
args: p.tool_input ?? {},
|
|
97
|
+
callId: p.tool_use_id ?? p.call_id,
|
|
98
|
+
sessionId: p.session_id,
|
|
99
|
+
cwd: p.cwd,
|
|
100
|
+
model: p.model,
|
|
101
|
+
failed,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function resolveSource(skillPath, cwd = '', homeDir = homedir()) {
|
|
106
|
+
if (!skillPath) return 'unknown';
|
|
107
|
+
const normHome = String(homeDir).replace(/\\/g, '/').replace(/\/+$/, '');
|
|
108
|
+
const normCwd = String(cwd || '').replace(/\\/g, '/').replace(/\/+$/, '');
|
|
109
|
+
let p = String(skillPath).replace(/\\/g, '/');
|
|
110
|
+
if (p.startsWith('~/')) p = `${normHome}${p.slice(1)}`;
|
|
111
|
+
|
|
112
|
+
const cacheMatch = p.match(/\/plugins\/cache\/[^/]+\/([^/]+)\//);
|
|
113
|
+
if (cacheMatch) return `plugin:${cacheMatch[1]}`;
|
|
114
|
+
|
|
115
|
+
const pluginMatch = p.match(/\/plugins\/([^/]+)\//);
|
|
116
|
+
if (pluginMatch) return `plugin:${pluginMatch[1]}`;
|
|
117
|
+
|
|
118
|
+
if (/\/builtin\/skills\//.test(p)) return 'builtin';
|
|
119
|
+
|
|
120
|
+
const personalRoots = [
|
|
121
|
+
`${normHome}/.gemini/config/skills/`,
|
|
122
|
+
`${normHome}/.gemini/skills/`,
|
|
123
|
+
`${normHome}/.agents/skills/`,
|
|
124
|
+
`${normHome}/.codex/skills/`,
|
|
125
|
+
`${normHome}/.claude/skills/`,
|
|
126
|
+
];
|
|
127
|
+
if (personalRoots.some((root) => p.startsWith(root))) return 'personal';
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
(normCwd && p.startsWith(`${normCwd}/`)) ||
|
|
131
|
+
/\/(?:\.agents|\.agent|\.claude|\.gemini)\/skills\//.test(p)
|
|
132
|
+
) {
|
|
133
|
+
return 'project';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return 'unknown';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function extractCodexCommandStrings(text) {
|
|
140
|
+
const extracted = [];
|
|
141
|
+
for (const m of text.matchAll(CODEX_EXEC_CMD_RE)) {
|
|
142
|
+
const lit = m[1];
|
|
143
|
+
if (lit[0] === '"') {
|
|
144
|
+
try {
|
|
145
|
+
extracted.push(JSON.parse(lit));
|
|
146
|
+
} catch {
|
|
147
|
+
extracted.push(lit.slice(1, -1));
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
extracted.push(lit.slice(1, -1).replace(/\\(['\\])/g, '$1'));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return extracted.length > 0 ? extracted : [text];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function detectSkillCalls({ tool, args, cwd = '', homeDir = homedir(), allowShell = true }) {
|
|
157
|
+
const safeArgs = args && typeof args === 'object' ? args : {};
|
|
158
|
+
|
|
159
|
+
if (tool === 'Skill' && safeArgs.skill) {
|
|
160
|
+
const rawSkill = String(safeArgs.skill).trim();
|
|
161
|
+
if (!rawSkill) return [];
|
|
162
|
+
const colon = rawSkill.indexOf(':');
|
|
163
|
+
if (colon > 0 && colon < rawSkill.length - 1) {
|
|
164
|
+
const ns = rawSkill.slice(0, colon).trim();
|
|
165
|
+
const name = rawSkill.slice(colon + 1).trim();
|
|
166
|
+
if (SKILL_NAME_RE.test(name)) {
|
|
167
|
+
return [{ skill: name, raw_skill: rawSkill, source: `plugin:${ns}`, via: 'skill_tool' }];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return [{ skill: rawSkill, via: 'skill_tool' }];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (tool === 'activate_skill') {
|
|
174
|
+
const raw = safeArgs.name ?? safeArgs.skill;
|
|
175
|
+
if (raw) {
|
|
176
|
+
const name = String(raw).trim();
|
|
177
|
+
if (name) return [{ skill: name, via: 'activate_skill' }];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (WRITE_TOOL_RE.test(tool ?? '')) return [];
|
|
182
|
+
|
|
183
|
+
const hits = [];
|
|
184
|
+
const seenPaths = new Set();
|
|
185
|
+
|
|
186
|
+
const collectFromText = (text, via) => {
|
|
187
|
+
if (!text.toLowerCase().includes('skill.md')) return;
|
|
188
|
+
SKILL_PATH_RE.lastIndex = 0;
|
|
189
|
+
for (const m of text.matchAll(SKILL_PATH_RE)) {
|
|
190
|
+
const skillPath = m[1];
|
|
191
|
+
const skill = m[2];
|
|
192
|
+
const normKey = skillPath.replace(/\\/g, '/');
|
|
193
|
+
if (seenPaths.has(normKey)) continue;
|
|
194
|
+
seenPaths.add(normKey);
|
|
195
|
+
hits.push({
|
|
196
|
+
skill,
|
|
197
|
+
skill_path: skillPath,
|
|
198
|
+
source: resolveSource(skillPath, cwd, homeDir),
|
|
199
|
+
via,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
for (const key of PATH_KEYS) {
|
|
205
|
+
if (typeof safeArgs[key] === 'string') {
|
|
206
|
+
collectFromText(unwrapArg(safeArgs[key]), 'read');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (hits.length > 0) return hits;
|
|
210
|
+
|
|
211
|
+
if (!allowShell) return [];
|
|
212
|
+
|
|
213
|
+
const shellInputs = [];
|
|
214
|
+
if (typeof args === 'string') shellInputs.push(args);
|
|
215
|
+
for (const key of CMD_KEYS) {
|
|
216
|
+
const val = safeArgs[key];
|
|
217
|
+
if (Array.isArray(val)) shellInputs.push(val.map(String).join(' '));
|
|
218
|
+
else if (typeof val === 'string') shellInputs.push(val);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
for (const rawVal of shellInputs) {
|
|
222
|
+
const text = unwrapArg(rawVal);
|
|
223
|
+
if (!text.toLowerCase().includes('skill.md')) continue;
|
|
224
|
+
const candidates = extractCodexCommandStrings(text);
|
|
225
|
+
for (const cand of candidates) {
|
|
226
|
+
for (const rawSeg of cand.split(/&&|\|\||;|\n/)) {
|
|
227
|
+
if (!rawSeg.toLowerCase().includes('skill.md')) continue;
|
|
228
|
+
const seg = rawSeg.trim().replace(/^(?:[A-Za-z_]\w*=\S+\s+)+/, '');
|
|
229
|
+
if (!READ_CMD_RE.test(seg)) continue;
|
|
230
|
+
if (MUTATE_CMD_RE.test(seg)) continue;
|
|
231
|
+
collectFromText(seg, 'shell_read');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return hits;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function readStoreCwdFlag(home) {
|
|
240
|
+
try {
|
|
241
|
+
const cfg = JSON.parse(readFileSync(join(home, 'config.json'), 'utf8'));
|
|
242
|
+
return cfg?.store_cwd === true;
|
|
243
|
+
} catch {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function maybeRotateEvents(home, eventsPath) {
|
|
249
|
+
const maxBytes = Number(process.env.SKILLTALLY_ROTATE_BYTES) || 20 * 1024 * 1024;
|
|
250
|
+
if (!existsSync(eventsPath)) return;
|
|
251
|
+
try {
|
|
252
|
+
if (statSync(eventsPath).size < maxBytes) return;
|
|
253
|
+
const month = new Date().toISOString().slice(0, 7);
|
|
254
|
+
let archivePath = join(home, `events-${month}.jsonl`);
|
|
255
|
+
let suffix = 1;
|
|
256
|
+
while (existsSync(archivePath)) {
|
|
257
|
+
archivePath = join(home, `events-${month}-${suffix}.jsonl`);
|
|
258
|
+
suffix += 1;
|
|
259
|
+
}
|
|
260
|
+
renameSync(eventsPath, archivePath);
|
|
261
|
+
} catch {}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function main() {
|
|
265
|
+
const hostFlag = argValue('--host') ?? 'auto';
|
|
266
|
+
const raw = readFileSync(0, 'utf8');
|
|
267
|
+
const home = process.env.SKILLTALLY_HOME || join(homedir(), '.skilltally');
|
|
268
|
+
const debugOn = process.env.SKILLTALLY_DEBUG === '1' || existsSync(join(home, '.debug'));
|
|
269
|
+
|
|
270
|
+
if (debugOn) {
|
|
271
|
+
mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
272
|
+
appendFileSync(
|
|
273
|
+
join(home, 'debug.jsonl'),
|
|
274
|
+
JSON.stringify({ ts: new Date().toISOString(), host: hostFlag, raw }) + '\n',
|
|
275
|
+
{ mode: 0o600 }
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (!raw || !raw.trim()) return;
|
|
280
|
+
const payload = JSON.parse(raw);
|
|
281
|
+
const host = resolveHost(hostFlag, payload);
|
|
282
|
+
const n = normalizeHookPayload(host, payload);
|
|
283
|
+
const hits = detectSkillCalls({ tool: n.tool, args: n.args, cwd: n.cwd });
|
|
284
|
+
if (hits.length === 0) return;
|
|
285
|
+
|
|
286
|
+
mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
287
|
+
const storeCwd = readStoreCwdFlag(home);
|
|
288
|
+
const ts = new Date().toISOString();
|
|
289
|
+
|
|
290
|
+
const lines = hits.map((h, idx) =>
|
|
291
|
+
JSON.stringify({
|
|
292
|
+
v: 1,
|
|
293
|
+
id: `${host}:${n.sessionId ?? '-'}:${n.callId ?? ts}#${idx}`,
|
|
294
|
+
ts,
|
|
295
|
+
host,
|
|
296
|
+
skill: h.skill,
|
|
297
|
+
...(h.raw_skill && h.raw_skill !== h.skill ? { raw_skill: h.raw_skill } : {}),
|
|
298
|
+
...(h.skill_path ? { skill_path: h.skill_path } : {}),
|
|
299
|
+
source: h.source ?? resolveSource(h.skill_path, n.cwd),
|
|
300
|
+
via: h.via,
|
|
301
|
+
...(n.tool ? { tool: n.tool } : {}),
|
|
302
|
+
...(n.sessionId ? { session_id: n.sessionId } : {}),
|
|
303
|
+
...(n.cwd ? { project: basename(n.cwd) } : {}),
|
|
304
|
+
...(storeCwd && n.cwd ? { cwd: n.cwd } : {}),
|
|
305
|
+
...(n.model ? { model: n.model } : {}),
|
|
306
|
+
origin: 'hook',
|
|
307
|
+
ok: !n.failed,
|
|
308
|
+
})
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const eventsPath = join(home, 'events.jsonl');
|
|
312
|
+
maybeRotateEvents(home, eventsPath);
|
|
313
|
+
appendFileSync(eventsPath, lines.join('\n') + '\n', { mode: 0o600 });
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
let isMain = false;
|
|
317
|
+
try {
|
|
318
|
+
if (process.argv[1]) {
|
|
319
|
+
isMain = realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
320
|
+
}
|
|
321
|
+
} catch {}
|
|
322
|
+
|
|
323
|
+
if (isMain) {
|
|
324
|
+
try {
|
|
325
|
+
main();
|
|
326
|
+
} catch {
|
|
327
|
+
// Swallow all errors: tracking must never break the agent loop.
|
|
328
|
+
}
|
|
329
|
+
process.stdout.write('{}');
|
|
330
|
+
process.exit(0);
|
|
331
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Fast-path wrapper for Antigravity PostToolUse hook.
|
|
3
|
+
# Avoids spawning Node.js (and path subshells) when stdin does not mention SKILL.md.
|
|
4
|
+
|
|
5
|
+
in=$(cat)
|
|
6
|
+
|
|
7
|
+
run_node=0
|
|
8
|
+
if [ "${SKILLTALLY_DEBUG:-0}" = "1" ] || [ -f "${SKILLTALLY_HOME:-$HOME/.skilltally}/.debug" ]; then
|
|
9
|
+
run_node=1
|
|
10
|
+
else
|
|
11
|
+
case "$in" in
|
|
12
|
+
*SKILL.md*) run_node=1 ;;
|
|
13
|
+
esac
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if [ "$run_node" = "1" ]; then
|
|
17
|
+
if [ -n "${PLUGIN_ROOT:-}" ]; then
|
|
18
|
+
PLUGIN_DIR="$PLUGIN_ROOT"
|
|
19
|
+
else
|
|
20
|
+
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
21
|
+
PLUGIN_DIR=$(dirname -- "$SCRIPT_DIR")
|
|
22
|
+
fi
|
|
23
|
+
printf '%s' "$in" | node "$PLUGIN_DIR/bin/track.mjs" --host antigravity 2>/dev/null || printf '{}'
|
|
24
|
+
else
|
|
25
|
+
printf '{}'
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
exit 0
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PostToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Skill|Read|Bash|exec|exec_command|shell|shell_command|local_shell",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/bin/track.mjs\" --host auto",
|
|
10
|
+
"async": true,
|
|
11
|
+
"timeout": 5,
|
|
12
|
+
"statusMessage": "skilltally"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
package/hooks.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skilltally",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Real-time skill usage tracking via hooks for Antigravity, Claude Code, Codex & Gemini CLI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"skilltally": "bin/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"src",
|
|
15
|
+
"skills",
|
|
16
|
+
"hooks",
|
|
17
|
+
"hooks.json",
|
|
18
|
+
"plugin.json",
|
|
19
|
+
"gemini-extension.json",
|
|
20
|
+
".claude-plugin",
|
|
21
|
+
".codex-plugin",
|
|
22
|
+
".agents",
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"README.md",
|
|
25
|
+
"CHANGELOG.md"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "node --test && node scripts/check-versions.mjs",
|
|
29
|
+
"check:pack": "npm pack --dry-run"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"agent-skills",
|
|
33
|
+
"skills",
|
|
34
|
+
"claude-code",
|
|
35
|
+
"codex",
|
|
36
|
+
"gemini-cli",
|
|
37
|
+
"antigravity",
|
|
38
|
+
"analytics",
|
|
39
|
+
"hooks"
|
|
40
|
+
],
|
|
41
|
+
"author": "112516101106",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/112516101106/skilltally.git"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/112516101106/skilltally#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/112516101106/skilltally/issues"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"provenance": true
|
|
54
|
+
}
|
|
55
|
+
}
|
package/plugin.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skilltally",
|
|
3
|
+
"displayName": "SkillTally",
|
|
4
|
+
"description": "Real-time skill usage tracking via hooks for Antigravity, Claude Code, Codex & Gemini CLI. See which skills you actually use and which eat context.",
|
|
5
|
+
"version": "1.0.1",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "112516101106",
|
|
8
|
+
"url": "https://github.com/112516101106"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/112516101106/skilltally",
|
|
11
|
+
"repository": "https://github.com/112516101106/skilltally",
|
|
12
|
+
"suggestedPrompts": [
|
|
13
|
+
"Which agent skills do I use the most in the last 30 days?",
|
|
14
|
+
"Show unused skills and how many context tokens disabling them would save",
|
|
15
|
+
"Backfill skill usage history from local agent logs and summarize stats"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skilltally
|
|
3
|
+
description: >-
|
|
4
|
+
Report which agent skills are used most, least, or never, across Antigravity,
|
|
5
|
+
Claude Code, Codex, and Gemini CLI. Use when the user asks about skill usage,
|
|
6
|
+
frequency, statistics, "which skills do I use", unused skills to clean up, or
|
|
7
|
+
context token savings from disabling unused plugins.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# skilltally
|
|
11
|
+
|
|
12
|
+
Local, zero-telemetry skill-usage analytics. Events live in `~/.skilltally/events.jsonl` (written in real time by hooks) and `~/.skilltally/events.backfill.jsonl` (imported from local session logs).
|
|
13
|
+
|
|
14
|
+
## How to run the CLI
|
|
15
|
+
|
|
16
|
+
Prefer the fastest available invocation:
|
|
17
|
+
1. `skilltally <subcommand>` (if installed on `PATH`)
|
|
18
|
+
2. `node "$PLUGIN_ROOT/bin/cli.mjs" <subcommand>` (when running inside an installed plugin; instant & offline)
|
|
19
|
+
3. `npx -y skilltally <subcommand>` (fallback)
|
|
20
|
+
|
|
21
|
+
## Common commands
|
|
22
|
+
|
|
23
|
+
1. **Overall usage & top skills** (default 30 days):
|
|
24
|
+
```bash
|
|
25
|
+
skilltally stats --since 30d
|
|
26
|
+
```
|
|
27
|
+
Add `--json` for structured output, `--host <name>` to filter by host, or `--by-source` to separate duplicate skill names across sources.
|
|
28
|
+
2. **Top N skills**:
|
|
29
|
+
```bash
|
|
30
|
+
skilltally top -n 20 --since 30d --metric activations
|
|
31
|
+
```
|
|
32
|
+
3. **Unused skills & Context Tax savings**:
|
|
33
|
+
```bash
|
|
34
|
+
skilltally unused --since 90d
|
|
35
|
+
```
|
|
36
|
+
Shows enabled installed skills with zero activations in the window, grouped by source with estimated `KB` and `~tokens/session` saved by disabling unused plugins.
|
|
37
|
+
4. **Timeline & export**:
|
|
38
|
+
```bash
|
|
39
|
+
skilltally timeline --skill <name> --by week
|
|
40
|
+
skilltally export --format csv -o skilltally-events.csv
|
|
41
|
+
```
|
|
42
|
+
5. **Import history from local logs** (Antigravity, Codex, Claude Code, Gemini CLI):
|
|
43
|
+
```bash
|
|
44
|
+
skilltally backfill
|
|
45
|
+
```
|
|
46
|
+
6. **Inspect installed inventory & verify hooks**:
|
|
47
|
+
```bash
|
|
48
|
+
skilltally inventory --json
|
|
49
|
+
skilltally doctor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If `stats` shows zero events, run `skilltally doctor` to check hook installation, then suggest `skilltally install` and `skilltally backfill`.
|
|
53
|
+
|
|
54
|
+
## Rules
|
|
55
|
+
|
|
56
|
+
- **Never delete, uninstall, or disable skills or plugins yourself**; present the findings and let the user decide.
|
|
57
|
+
- Report **activations** (unique `session × skill` pairs) as the primary metric and **reads** (total invocations) as secondary.
|
|
58
|
+
- When reporting unused skills or plugins, include the **Context Tax** (`KB` and `~tokens/session`) so the user knows the context benefit of disabling a plugin.
|
|
59
|
+
- Always state the time window (`--since`) and which hosts contributed data.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { basename, join } from 'node:path';
|
|
4
|
+
import { detectSkillCalls, unwrapArg } from '../core/detect.mjs';
|
|
5
|
+
|
|
6
|
+
const TARGET_TOOLS = new Set(['read_file', 'view_file', 'run_command']);
|
|
7
|
+
const PRODUCT_DIRS = ['antigravity', 'antigravity-cli', 'antigravity-ide'];
|
|
8
|
+
|
|
9
|
+
function findTranscripts(homeDir) {
|
|
10
|
+
const results = [];
|
|
11
|
+
for (const product of PRODUCT_DIRS) {
|
|
12
|
+
const brainDir = join(homeDir, '.gemini', product, 'brain');
|
|
13
|
+
if (!existsSync(brainDir)) continue;
|
|
14
|
+
let convs;
|
|
15
|
+
try {
|
|
16
|
+
convs = readdirSync(brainDir, { withFileTypes: true });
|
|
17
|
+
} catch {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
for (const entry of convs) {
|
|
21
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
22
|
+
const transcript = join(brainDir, entry.name, '.system_generated', 'logs', 'transcript.jsonl');
|
|
23
|
+
if (existsSync(transcript)) {
|
|
24
|
+
results.push({
|
|
25
|
+
host: product,
|
|
26
|
+
sessionId: entry.name,
|
|
27
|
+
transcriptPath: transcript,
|
|
28
|
+
fullPath: join(brainDir, entry.name, '.system_generated', 'logs', 'transcript_full.jsonl'),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return results;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function loadFullRecord(fullLinesCache, fullPath, lineIdx, stepIndex) {
|
|
37
|
+
if (fullLinesCache.lines === undefined) {
|
|
38
|
+
if (existsSync(fullPath)) {
|
|
39
|
+
try {
|
|
40
|
+
fullLinesCache.lines = readFileSync(fullPath, 'utf8').split('\n');
|
|
41
|
+
} catch {
|
|
42
|
+
fullLinesCache.lines = null;
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
fullLinesCache.lines = null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const lines = fullLinesCache.lines;
|
|
49
|
+
if (!lines) return null;
|
|
50
|
+
|
|
51
|
+
if (lineIdx < lines.length && lines[lineIdx]) {
|
|
52
|
+
try {
|
|
53
|
+
const candidate = JSON.parse(lines[lineIdx]);
|
|
54
|
+
if (candidate?.step_index === stepIndex) return candidate;
|
|
55
|
+
} catch {}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const raw of lines) {
|
|
59
|
+
if (!raw || !raw.includes('"tool_calls"')) continue;
|
|
60
|
+
try {
|
|
61
|
+
const candidate = JSON.parse(raw);
|
|
62
|
+
if (candidate?.step_index === stepIndex) return candidate;
|
|
63
|
+
} catch {}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function backfillAntigravity({ homeDir = homedir(), since = null } = {}) {
|
|
69
|
+
const transcripts = findTranscripts(homeDir);
|
|
70
|
+
const sinceMs = since instanceof Date ? since.getTime() : since ? Date.parse(since) : null;
|
|
71
|
+
const events = [];
|
|
72
|
+
|
|
73
|
+
for (const item of transcripts) {
|
|
74
|
+
let raw;
|
|
75
|
+
try {
|
|
76
|
+
raw = readFileSync(item.transcriptPath, 'utf8');
|
|
77
|
+
} catch {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const lines = raw.split('\n');
|
|
82
|
+
const fullCache = { lines: undefined };
|
|
83
|
+
|
|
84
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
85
|
+
const line = lines[lineIdx];
|
|
86
|
+
if (!line) continue;
|
|
87
|
+
if (!line.includes('SKILL.md') && !line.includes('truncated_fields')) continue;
|
|
88
|
+
|
|
89
|
+
let obj;
|
|
90
|
+
try {
|
|
91
|
+
obj = JSON.parse(line);
|
|
92
|
+
} catch {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (Array.isArray(obj.truncated_fields) && obj.truncated_fields.includes('tool_calls')) {
|
|
97
|
+
const fullObj = loadFullRecord(fullCache, item.fullPath, lineIdx, obj.step_index);
|
|
98
|
+
if (fullObj) obj = fullObj;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const toolCalls = obj.tool_calls;
|
|
102
|
+
if (!Array.isArray(toolCalls) || toolCalls.length === 0) continue;
|
|
103
|
+
|
|
104
|
+
const ts = obj.created_at;
|
|
105
|
+
if (sinceMs !== null && ts) {
|
|
106
|
+
const tsMs = Date.parse(ts);
|
|
107
|
+
if (Number.isFinite(tsMs) && tsMs < sinceMs) continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const stepIdx = obj.step_index ?? lineIdx;
|
|
111
|
+
let stepHitIdx = 0;
|
|
112
|
+
|
|
113
|
+
for (const tc of toolCalls) {
|
|
114
|
+
if (!tc || !TARGET_TOOLS.has(tc.name)) continue;
|
|
115
|
+
const args = tc.args && typeof tc.args === 'object' ? tc.args : {};
|
|
116
|
+
const cwdRaw = unwrapArg(args.Cwd);
|
|
117
|
+
const cwd = typeof cwdRaw === 'string' ? cwdRaw : '';
|
|
118
|
+
const hits = detectSkillCalls({
|
|
119
|
+
tool: tc.name,
|
|
120
|
+
args,
|
|
121
|
+
cwd,
|
|
122
|
+
homeDir,
|
|
123
|
+
allowShell: true,
|
|
124
|
+
});
|
|
125
|
+
for (const h of hits) {
|
|
126
|
+
events.push({
|
|
127
|
+
v: 1,
|
|
128
|
+
id: `${item.host}:${item.sessionId}:${stepIdx}#${stepHitIdx++}`,
|
|
129
|
+
ts: ts || new Date(0).toISOString(),
|
|
130
|
+
host: item.host,
|
|
131
|
+
skill: h.skill,
|
|
132
|
+
...(h.skill_path ? { skill_path: h.skill_path } : {}),
|
|
133
|
+
source: h.source,
|
|
134
|
+
via: h.via,
|
|
135
|
+
tool: tc.name,
|
|
136
|
+
session_id: item.sessionId,
|
|
137
|
+
...(cwd ? { project: basename(cwd) } : {}),
|
|
138
|
+
origin: 'backfill',
|
|
139
|
+
ok: obj.status !== 'ERROR',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
files: transcripts.length,
|
|
148
|
+
events,
|
|
149
|
+
};
|
|
150
|
+
}
|