skilltally 1.0.0 → 1.0.2

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.
@@ -10,7 +10,7 @@
10
10
  {
11
11
  "name": "skilltally",
12
12
  "description": "Track skill activations and identify unused skills eating context.",
13
- "version": "1.0.0",
13
+ "version": "1.0.2",
14
14
  "source": "./",
15
15
  "category": "productivity"
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skilltally",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Real-time skill usage tracking via hooks for Antigravity, Claude Code, Codex & Gemini CLI.",
5
5
  "author": {
6
6
  "name": "112516101106",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skilltally",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Real-time skill usage tracking via hooks for Antigravity, Claude Code, Codex & Gemini CLI.",
5
5
  "author": {
6
6
  "name": "112516101106",
package/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.2] - 2026-11-19
9
+
10
+ ### Added
11
+ - Realtime `UserPromptSubmit` hook and `<skill>` / `[$skill](.../SKILL.md)` backfill detection for Codex explicit `$skill` invocations (`via: "mention"`).
12
+ - Expanded hook matchers and backfill parsers across all 4 providers:
13
+ - **Antigravity**: added `run_command` to `PostToolUse` matcher and fallback `<SKILL>` slash-command detection in `backfillAntigravity`.
14
+ - **Claude Code**: added `View|Bash` to `PostToolUse` matcher and `Base directory for this skill:` slash-command detection in `backfillClaude`.
15
+ - **Gemini CLI**: added `read_file|view_file|read_many_files|run_shell_command` to `AfterTool` matcher and `read_many_files` array path support.
16
+
17
+ ### Fixed
18
+ - Verify trust status across both `post_tool_use` and `user_prompt_submit` hook indices in `~/.codex/config.toml` and clean up all hook events on `uninstall`.
19
+
20
+ ## [1.0.1] - 2026-11-19
21
+
22
+ ### Fixed
23
+ - Ignore third-party hooks in `skilltally doctor` when inspecting `~/.codex/hooks.json`, `~/.claude/settings.json`, `~/.gemini/settings.json`, and `~/.gemini/config/hooks.json` instead of flagging unrelated commands as broken paths.
24
+ - Match the exact `[hooks.state."...hooks.json:post_tool_use:<group>:<handler>"]` index in `~/.codex/config.toml` when checking Codex hook trust so third-party hooks at index `0:0` do not produce false positives.
25
+
8
26
  ## [1.0.0] - 2026-11-19
9
27
 
10
28
  ### Added
package/bin/cli.mjs CHANGED
@@ -32,7 +32,7 @@ function getVersion() {
32
32
  try {
33
33
  return JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf8')).version;
34
34
  } catch {
35
- return '1.0.0';
35
+ return '1.0.2';
36
36
  }
37
37
  }
38
38
 
package/bin/track.mjs CHANGED
@@ -17,8 +17,17 @@ import { fileURLToPath } from 'node:url';
17
17
  export const SKILL_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
18
18
  export const SKILL_PATH_RE =
19
19
  /((?:[A-Za-z]:|~)?[^\s"'`<>|;(){}\[\]]*?[\\/]skills[\\/]([A-Za-z0-9][A-Za-z0-9._-]{0,127})[\\/]SKILL\.md)(?=$|[\s"'`<>|;),}\]])/gi;
20
+ const EXPLICIT_SKILL_LINK_RE =
21
+ /\[[\$@\/]?([A-Za-z0-9][A-Za-z0-9._-]{0,127})\]\(([^()\s]*?[\\/]skills[\\/][A-Za-z0-9][A-Za-z0-9._-]{0,127}[\\/]SKILL\.md)\)/gi;
22
+ const CODEX_SKILL_TAG_RE =
23
+ /<skill>\s*<name>([^<\r\n]+)<\/name>\s*<path>([^<\r\n]*?[\\/]SKILL\.md)<\/path>/gi;
24
+ const AGY_SKILL_TAG_RE =
25
+ /<SKILL>[\s\S]*?read and use the "([^"]+)" skill\.\s*The path to the skill file is:\s*([^\s<]+?[\\/]SKILL\.md)\s*<\/SKILL>/gi;
26
+ const CLAUDE_SKILL_BASEDIR_RE =
27
+ /Base directory for this skill:\s*([^\r\n<]+?[\\/]skills[\\/]([A-Za-z0-9][A-Za-z0-9._-]{0,127}))\/?(?=\r?\n|$|<)/gi;
20
28
 
21
29
  const PATH_KEYS = ['Path', 'AbsolutePath', 'TargetFile', 'file_path', 'path', 'absolute_path'];
30
+ const ARRAY_PATH_KEYS = ['paths', 'include', 'files'];
22
31
  const CMD_KEYS = ['CommandLine', 'command', 'cmd', 'input', 'argv'];
23
32
  const WRITE_TOOL_RE = /^(write|edit|replace|apply_patch|multiedit|notebookedit|create_file|delete_file)/i;
24
33
  const READ_CMD_RE = /^(cat|sed|head|tail|less|more|bat|nl|awk|type|Get-Content)\b/i;
@@ -56,7 +65,13 @@ export function resolveHost(hostFlag, payload, env = process.env) {
56
65
  return hostFlag;
57
66
  }
58
67
  if (payload?.toolCall) return refineAntigravityHost(payload);
59
- if (payload?.hook_event_name === 'AfterTool' || env.GEMINI_PROJECT_DIR) return 'gemini';
68
+ if (
69
+ payload?.hook_event_name === 'AfterTool' ||
70
+ payload?.hook_event_name === 'BeforeAgent' ||
71
+ env.GEMINI_PROJECT_DIR
72
+ ) {
73
+ return 'gemini';
74
+ }
60
75
  const tp = String(payload?.transcript_path ?? '');
61
76
  if (
62
77
  env.CODEX_THREAD_ID ||
@@ -91,10 +106,22 @@ export function normalizeHookPayload(host, payload) {
91
106
  Boolean(p.error) ||
92
107
  resp?.is_error === true ||
93
108
  (typeof resp?.exit_code === 'number' && resp.exit_code !== 0);
109
+ const prompt =
110
+ typeof p.prompt === 'string'
111
+ ? p.prompt
112
+ : typeof p.user_prompt === 'string'
113
+ ? p.user_prompt
114
+ : typeof p.userMessage === 'string'
115
+ ? p.userMessage
116
+ : undefined;
117
+ const hookEvent = p.hook_event_name ?? p.hookEventName;
94
118
  return {
95
- tool: p.tool_name,
119
+ tool:
120
+ p.tool_name ??
121
+ (hookEvent === 'UserPromptSubmit' || hookEvent === 'BeforeAgent' ? hookEvent : undefined),
96
122
  args: p.tool_input ?? {},
97
- callId: p.tool_use_id ?? p.call_id,
123
+ ...(prompt !== undefined ? { prompt } : {}),
124
+ callId: p.tool_use_id ?? p.call_id ?? p.turn_id ?? p.prompt_id,
98
125
  sessionId: p.session_id,
99
126
  cwd: p.cwd,
100
127
  model: p.model,
@@ -153,7 +180,14 @@ function extractCodexCommandStrings(text) {
153
180
  return extracted.length > 0 ? extracted : [text];
154
181
  }
155
182
 
156
- export function detectSkillCalls({ tool, args, cwd = '', homeDir = homedir(), allowShell = true }) {
183
+ export function detectSkillCalls({
184
+ tool,
185
+ args,
186
+ prompt,
187
+ cwd = '',
188
+ homeDir = homedir(),
189
+ allowShell = true,
190
+ }) {
157
191
  const safeArgs = args && typeof args === 'object' ? args : {};
158
192
 
159
193
  if (tool === 'Skill' && safeArgs.skill) {
@@ -178,26 +212,54 @@ export function detectSkillCalls({ tool, args, cwd = '', homeDir = homedir(), al
178
212
  }
179
213
  }
180
214
 
181
- if (WRITE_TOOL_RE.test(tool ?? '')) return [];
182
-
183
215
  const hits = [];
184
216
  const seenPaths = new Set();
185
217
 
218
+ const pushPathHit = (skill, skillPath, via) => {
219
+ const cleanSkill = String(skill || '').trim();
220
+ const cleanPath = String(skillPath || '').trim();
221
+ if (!cleanSkill || !cleanPath) return;
222
+ const normKey = cleanPath.replace(/\\/g, '/');
223
+ if (seenPaths.has(normKey)) return;
224
+ seenPaths.add(normKey);
225
+ hits.push({
226
+ skill: cleanSkill,
227
+ skill_path: cleanPath,
228
+ source: resolveSource(cleanPath, cwd, homeDir),
229
+ via,
230
+ });
231
+ };
232
+
233
+ if (typeof prompt === 'string' && prompt.trim()) {
234
+ CODEX_SKILL_TAG_RE.lastIndex = 0;
235
+ for (const m of prompt.matchAll(CODEX_SKILL_TAG_RE)) {
236
+ pushPathHit(m[1], m[2], 'mention');
237
+ }
238
+ EXPLICIT_SKILL_LINK_RE.lastIndex = 0;
239
+ for (const m of prompt.matchAll(EXPLICIT_SKILL_LINK_RE)) {
240
+ pushPathHit(m[1], m[2], 'mention');
241
+ }
242
+ AGY_SKILL_TAG_RE.lastIndex = 0;
243
+ for (const m of prompt.matchAll(AGY_SKILL_TAG_RE)) {
244
+ pushPathHit(m[1], m[2], 'slash_command');
245
+ }
246
+ CLAUDE_SKILL_BASEDIR_RE.lastIndex = 0;
247
+ for (const m of prompt.matchAll(CLAUDE_SKILL_BASEDIR_RE)) {
248
+ const baseDir = m[1].trim().replace(/[\\/]+$/, '');
249
+ pushPathHit(m[2], `${baseDir}/SKILL.md`, 'slash_command');
250
+ }
251
+ if (hits.length > 0 && (!tool || tool === 'UserPromptSubmit' || tool === 'BeforeAgent' || tool === 'USER_INPUT')) {
252
+ return hits;
253
+ }
254
+ }
255
+
256
+ if (WRITE_TOOL_RE.test(tool ?? '')) return hits;
257
+
186
258
  const collectFromText = (text, via) => {
187
259
  if (!text.toLowerCase().includes('skill.md')) return;
188
260
  SKILL_PATH_RE.lastIndex = 0;
189
261
  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
- });
262
+ pushPathHit(m[2], m[1], via);
201
263
  }
202
264
  };
203
265
 
@@ -206,6 +268,15 @@ export function detectSkillCalls({ tool, args, cwd = '', homeDir = homedir(), al
206
268
  collectFromText(unwrapArg(safeArgs[key]), 'read');
207
269
  }
208
270
  }
271
+ for (const key of ARRAY_PATH_KEYS) {
272
+ if (Array.isArray(safeArgs[key])) {
273
+ for (const item of safeArgs[key]) {
274
+ if (typeof item === 'string' && !item.includes('*')) {
275
+ collectFromText(unwrapArg(item), 'read');
276
+ }
277
+ }
278
+ }
279
+ }
209
280
  if (hits.length > 0) return hits;
210
281
 
211
282
  if (!allowShell) return [];
@@ -280,7 +351,7 @@ export function main() {
280
351
  const payload = JSON.parse(raw);
281
352
  const host = resolveHost(hostFlag, payload);
282
353
  const n = normalizeHookPayload(host, payload);
283
- const hits = detectSkillCalls({ tool: n.tool, args: n.args, cwd: n.cwd });
354
+ const hits = detectSkillCalls({ tool: n.tool, args: n.args, prompt: n.prompt, cwd: n.cwd });
284
355
  if (hits.length === 0) return;
285
356
 
286
357
  mkdirSync(home, { recursive: true, mode: 0o700 });
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "skilltally",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Real-time skill usage tracking via hooks for Antigravity, Claude Code, Codex & Gemini CLI."
5
5
  }
@@ -2,7 +2,20 @@
2
2
  "hooks": {
3
3
  "PostToolUse": [
4
4
  {
5
- "matcher": "Skill|Read|Bash|exec|exec_command|shell|shell_command|local_shell",
5
+ "matcher": "Skill|Read|View|Bash|exec|exec_command|shell|shell_command|local_shell|read_file|view_file",
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
+ "UserPromptSubmit": [
18
+ {
6
19
  "hooks": [
7
20
  {
8
21
  "type": "command",
package/hooks.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "skilltally": {
3
3
  "PostToolUse": [
4
4
  {
5
- "matcher": "read_file|view_file",
5
+ "matcher": "read_file|view_file|run_command",
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skilltally",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Real-time skill usage tracking via hooks for Antigravity, Claude Code, Codex & Gemini CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "skilltally",
3
3
  "displayName": "SkillTally",
4
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.0",
5
+ "version": "1.0.2",
6
6
  "author": {
7
7
  "name": "112516101106",
8
8
  "url": "https://github.com/112516101106"
@@ -80,6 +80,8 @@ export function backfillAntigravity({ homeDir = homedir(), since = null } = {})
80
80
 
81
81
  const lines = raw.split('\n');
82
82
  const fullCache = { lines: undefined };
83
+ const convEvents = [];
84
+ const pendingUserSkills = [];
83
85
 
84
86
  for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
85
87
  const line = lines[lineIdx];
@@ -93,6 +95,41 @@ export function backfillAntigravity({ homeDir = homedir(), since = null } = {})
93
95
  continue;
94
96
  }
95
97
 
98
+ const ts = obj.created_at;
99
+ const stepIdx = obj.step_index ?? lineIdx;
100
+
101
+ if (obj.type === 'USER_INPUT' && typeof obj.content === 'string' && obj.content.includes('<SKILL>')) {
102
+ if (sinceMs !== null && ts) {
103
+ const tsMs = Date.parse(ts);
104
+ if (Number.isFinite(tsMs) && tsMs < sinceMs) continue;
105
+ }
106
+ const promptHits = detectSkillCalls({
107
+ tool: 'USER_INPUT',
108
+ args: {},
109
+ prompt: obj.content,
110
+ cwd: '',
111
+ homeDir,
112
+ allowShell: false,
113
+ });
114
+ promptHits.forEach((h, hitIdx) => {
115
+ pendingUserSkills.push({
116
+ v: 1,
117
+ id: `${item.host}:${item.sessionId}:${stepIdx}#${hitIdx}`,
118
+ ts: ts || new Date(0).toISOString(),
119
+ host: item.host,
120
+ skill: h.skill,
121
+ ...(h.skill_path ? { skill_path: h.skill_path } : {}),
122
+ source: h.source,
123
+ via: h.via,
124
+ tool: 'USER_INPUT',
125
+ session_id: item.sessionId,
126
+ origin: 'backfill',
127
+ ok: obj.status !== 'ERROR',
128
+ });
129
+ });
130
+ continue;
131
+ }
132
+
96
133
  if (Array.isArray(obj.truncated_fields) && obj.truncated_fields.includes('tool_calls')) {
97
134
  const fullObj = loadFullRecord(fullCache, item.fullPath, lineIdx, obj.step_index);
98
135
  if (fullObj) obj = fullObj;
@@ -101,13 +138,11 @@ export function backfillAntigravity({ homeDir = homedir(), since = null } = {})
101
138
  const toolCalls = obj.tool_calls;
102
139
  if (!Array.isArray(toolCalls) || toolCalls.length === 0) continue;
103
140
 
104
- const ts = obj.created_at;
105
141
  if (sinceMs !== null && ts) {
106
142
  const tsMs = Date.parse(ts);
107
143
  if (Number.isFinite(tsMs) && tsMs < sinceMs) continue;
108
144
  }
109
145
 
110
- const stepIdx = obj.step_index ?? lineIdx;
111
146
  let stepHitIdx = 0;
112
147
 
113
148
  for (const tc of toolCalls) {
@@ -123,7 +158,7 @@ export function backfillAntigravity({ homeDir = homedir(), since = null } = {})
123
158
  allowShell: true,
124
159
  });
125
160
  for (const h of hits) {
126
- events.push({
161
+ convEvents.push({
127
162
  v: 1,
128
163
  id: `${item.host}:${item.sessionId}:${stepIdx}#${stepHitIdx++}`,
129
164
  ts: ts || new Date(0).toISOString(),
@@ -141,6 +176,14 @@ export function backfillAntigravity({ homeDir = homedir(), since = null } = {})
141
176
  }
142
177
  }
143
178
  }
179
+
180
+ const readSkillSet = new Set(convEvents.map((e) => e.skill));
181
+ for (const uEv of pendingUserSkills) {
182
+ if (!readSkillSet.has(uEv.skill)) {
183
+ convEvents.push(uEv);
184
+ }
185
+ }
186
+ events.push(...convEvents);
144
187
  }
145
188
 
146
189
  return {
@@ -37,7 +37,7 @@ export function backfillClaude({ homeDir = homedir(), since = null } = {}) {
37
37
  } catch {
38
38
  continue;
39
39
  }
40
- if (!raw || (!raw.includes('"Skill"') && !raw.includes('SKILL.md'))) continue;
40
+ if (!raw || (!raw.includes('"Skill"') && !raw.includes('SKILL.md') && !raw.includes('Base directory for this skill:'))) continue;
41
41
 
42
42
  let sessionId = basename(file, '.jsonl');
43
43
  let cwd = '';
@@ -57,17 +57,50 @@ export function backfillClaude({ homeDir = homedir(), since = null } = {}) {
57
57
  if (obj.cwd) cwd = obj.cwd;
58
58
 
59
59
  const content = obj.message?.content;
60
- if (!Array.isArray(content)) continue;
61
-
62
60
  if (obj.type === 'user') {
61
+ if (typeof content === 'string') {
62
+ if (content.includes('Base directory for this skill:') || content.includes('SKILL.md') || content.includes('<skill>')) {
63
+ pendingCalls.push({
64
+ idx: pendingCalls.length,
65
+ ts: obj.timestamp,
66
+ tool: 'UserPromptSubmit',
67
+ callId: obj.uuid || `user_${pendingCalls.length}`,
68
+ input: {},
69
+ prompt: content,
70
+ cwd,
71
+ model: undefined,
72
+ });
73
+ }
74
+ continue;
75
+ }
76
+ if (!Array.isArray(content)) continue;
63
77
  for (const block of content) {
64
78
  if (block?.type === 'tool_result' && block.is_error === true && block.tool_use_id) {
65
79
  failedIds.add(block.tool_use_id);
80
+ } else if (
81
+ block?.type === 'text' &&
82
+ typeof block.text === 'string' &&
83
+ (block.text.includes('Base directory for this skill:') ||
84
+ block.text.includes('SKILL.md') ||
85
+ block.text.includes('<skill>'))
86
+ ) {
87
+ pendingCalls.push({
88
+ idx: pendingCalls.length,
89
+ ts: obj.timestamp,
90
+ tool: 'UserPromptSubmit',
91
+ callId: obj.uuid || `user_${pendingCalls.length}`,
92
+ input: {},
93
+ prompt: block.text,
94
+ cwd,
95
+ model: undefined,
96
+ });
66
97
  }
67
98
  }
68
99
  continue;
69
100
  }
70
101
 
102
+ if (!Array.isArray(content)) continue;
103
+
71
104
  if (obj.type !== 'assistant') continue;
72
105
  const model = obj.message?.model;
73
106
 
@@ -94,9 +127,10 @@ export function backfillClaude({ homeDir = homedir(), since = null } = {}) {
94
127
  const hits = detectSkillCalls({
95
128
  tool: call.tool,
96
129
  args: call.input,
130
+ prompt: call.prompt,
97
131
  cwd: call.cwd,
98
132
  homeDir,
99
- allowShell: true,
133
+ allowShell: call.tool !== 'UserPromptSubmit',
100
134
  });
101
135
 
102
136
  const ok = call.callId ? !failedIds.has(call.callId) : true;
@@ -86,7 +86,7 @@ export function backfillCodex({ homeDir = homedir(), since = null } = {}) {
86
86
  continue;
87
87
  }
88
88
  const raw = readRes.text;
89
- if (!raw || !raw.includes('SKILL.md')) continue;
89
+ if (!raw || (!raw.includes('SKILL.md') && !raw.includes('<skill>'))) continue;
90
90
 
91
91
  let sessionId = sessionIdFromFilename(file);
92
92
  let cwd = '';
@@ -94,6 +94,8 @@ export function backfillCodex({ homeDir = homedir(), since = null } = {}) {
94
94
 
95
95
  const pendingCalls = [];
96
96
  const failedCalls = new Set();
97
+ let turnIdx = 0;
98
+ const turnPromptSkills = new Set();
97
99
 
98
100
  for (const line of raw.split('\n')) {
99
101
  if (!line) continue;
@@ -115,12 +117,59 @@ export function backfillCodex({ homeDir = homedir(), since = null } = {}) {
115
117
  if (obj.type === 'turn_context' && obj.payload) {
116
118
  if (obj.payload.cwd) cwd = obj.payload.cwd;
117
119
  if (obj.payload.model) model = obj.payload.model;
120
+ turnPromptSkills.clear();
121
+ turnIdx += 1;
118
122
  continue;
119
123
  }
120
124
 
121
125
  if (obj.type !== 'response_item' || !obj.payload) continue;
122
126
  const p = obj.payload;
123
127
 
128
+ if (p.type === 'message' && p.role === 'user' && Array.isArray(p.content)) {
129
+ for (const part of p.content) {
130
+ const text = part?.text;
131
+ if (
132
+ typeof text !== 'string' ||
133
+ (!text.includes('<skill>') && !text.includes('SKILL.md'))
134
+ ) {
135
+ continue;
136
+ }
137
+ const promptHits = detectSkillCalls({
138
+ tool: 'UserPromptSubmit',
139
+ args: {},
140
+ prompt: text,
141
+ cwd,
142
+ homeDir,
143
+ allowShell: false,
144
+ });
145
+ const uniqueTurnHits = [];
146
+ for (const h of promptHits) {
147
+ const key = `${h.skill}\0${(h.skill_path || '').replace(/\\/g, '/')}`;
148
+ if (turnPromptSkills.has(key)) continue;
149
+ turnPromptSkills.add(key);
150
+ uniqueTurnHits.push(h);
151
+ }
152
+ if (uniqueTurnHits.length > 0) {
153
+ pendingCalls.push({
154
+ idx: pendingCalls.length,
155
+ ts: obj.timestamp,
156
+ tool: 'UserPromptSubmit',
157
+ callId: p.id || `prompt_${turnIdx}_${pendingCalls.length}`,
158
+ args: {},
159
+ precomputedHits: uniqueTurnHits,
160
+ cwd,
161
+ model,
162
+ });
163
+ }
164
+ }
165
+ continue;
166
+ }
167
+
168
+ if (p.type === 'message' && p.role === 'assistant') {
169
+ turnPromptSkills.clear();
170
+ continue;
171
+ }
172
+
124
173
  if (p.type === 'function_call_output' || p.type === 'custom_tool_call_output') {
125
174
  if (p.call_id && isOutputError(p.output)) {
126
175
  failedCalls.add(p.call_id);
@@ -129,6 +178,7 @@ export function backfillCodex({ homeDir = homedir(), since = null } = {}) {
129
178
  }
130
179
 
131
180
  if (p.type !== 'function_call' && p.type !== 'custom_tool_call') continue;
181
+ turnPromptSkills.clear();
132
182
 
133
183
  const textToScan = p.type === 'function_call' ? p.arguments : p.input;
134
184
  if (typeof textToScan !== 'string' || !textToScan.includes('SKILL.md')) continue;
@@ -162,13 +212,15 @@ export function backfillCodex({ homeDir = homedir(), since = null } = {}) {
162
212
  if (Number.isFinite(tsMs) && tsMs < sinceMs) continue;
163
213
  }
164
214
 
165
- const hits = detectSkillCalls({
166
- tool: call.tool,
167
- args: call.args,
168
- cwd: call.cwd,
169
- homeDir,
170
- allowShell: true,
171
- });
215
+ const hits =
216
+ call.precomputedHits ||
217
+ detectSkillCalls({
218
+ tool: call.tool,
219
+ args: call.args,
220
+ cwd: call.cwd,
221
+ homeDir,
222
+ allowShell: true,
223
+ });
172
224
 
173
225
  const ok = call.callId ? !failedCalls.has(call.callId) : true;
174
226
  hits.forEach((h, hitIdx) => {
@@ -3,7 +3,13 @@ import { homedir } from 'node:os';
3
3
  import { basename, join } from 'node:path';
4
4
  import { detectSkillCalls } from '../core/detect.mjs';
5
5
 
6
- const TARGET_TOOLS = new Set(['activate_skill', 'read_file', 'view_file', 'run_shell_command']);
6
+ const TARGET_TOOLS = new Set([
7
+ 'activate_skill',
8
+ 'read_file',
9
+ 'view_file',
10
+ 'read_many_files',
11
+ 'run_shell_command',
12
+ ]);
7
13
 
8
14
  function findGeminiChatFiles(homeDir) {
9
15
  const tmpRoot = join(homeDir, '.gemini', 'tmp');
@@ -35,7 +35,7 @@ function buildAntigravityHooksJson() {
35
35
  skilltally: {
36
36
  PostToolUse: [
37
37
  {
38
- matcher: 'read_file|view_file',
38
+ matcher: 'read_file|view_file|run_command',
39
39
  hooks: [
40
40
  {
41
41
  type: 'command',
@@ -88,7 +88,7 @@ export function installAntigravity({
88
88
 
89
89
  writeJsonAtomic(join(target, 'hooks.json'), buildAntigravityHooksJson(), 0o644);
90
90
 
91
- let version = '1.0.0';
91
+ let version = '1.0.2';
92
92
  try {
93
93
  version = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')).version || version;
94
94
  } catch {}
@@ -62,7 +62,7 @@ export function installClaude({
62
62
  const settingsPath = join(homeDir, '.claude', 'settings.json');
63
63
  const doc = readJsonObject(settingsPath);
64
64
  const { nextDoc, changed, action } = mergePostToolUseHook(doc, {
65
- matcher: 'Skill|Read',
65
+ matcher: 'Skill|Read|View|Bash',
66
66
  command,
67
67
  async: true,
68
68
  timeout: 5,
@@ -7,6 +7,7 @@ import {
7
7
  getPackageRoot,
8
8
  isSkilltallyHandler,
9
9
  mergePostToolUseHook,
10
+ mergeUserPromptSubmitHook,
10
11
  readJsonObject,
11
12
  removeSkilltallyHooks,
12
13
  syncRuntime,
@@ -56,44 +57,81 @@ export function hasCodexPluginInstalled(homeDir = homedir()) {
56
57
  }
57
58
 
58
59
  export function checkCodexHookTrust(homeDir = homedir()) {
59
- const raw = readCodexToml(homeDir);
60
60
  const hooksPath = join(homeDir, '.codex', 'hooks.json');
61
- let hasUserHook = false;
61
+ const requiredHooks = [];
62
62
  try {
63
63
  const doc = readJsonObject(hooksPath);
64
- for (const g of doc?.hooks?.PostToolUse || []) {
65
- if (Array.isArray(g?.hooks) && g.hooks.some(isSkilltallyHandler)) {
66
- hasUserHook = true;
67
- break;
64
+ for (const [eventName, snakeName] of [
65
+ ['PostToolUse', 'post_tool_use'],
66
+ ['UserPromptSubmit', 'user_prompt_submit'],
67
+ ]) {
68
+ const groups = doc?.hooks?.[eventName] || [];
69
+ for (let gi = 0; gi < groups.length; gi++) {
70
+ const handlers = groups[gi]?.hooks;
71
+ if (!Array.isArray(handlers)) continue;
72
+ let foundInEvent = false;
73
+ for (let hi = 0; hi < handlers.length; hi++) {
74
+ if (isSkilltallyHandler(handlers[hi])) {
75
+ requiredHooks.push({
76
+ snakeName,
77
+ groupIdx: gi,
78
+ handlerIdx: hi,
79
+ exactKey: `hooks.json:${snakeName}:${gi}:${hi}`,
80
+ legacyRe: new RegExp(`:hooks\\.json:${snakeName}(?:"|'|])`),
81
+ });
82
+ foundInEvent = true;
83
+ break;
84
+ }
85
+ }
86
+ if (foundInEvent) break;
68
87
  }
69
88
  }
70
89
  } catch {}
71
90
 
72
- if (!raw) return hasUserHook ? 'untrusted' : 'unknown';
91
+ const hasPlugin = hasCodexPluginInstalled(homeDir);
92
+ if (requiredHooks.length === 0 && !hasPlugin) return 'unknown';
93
+
94
+ const raw = readCodexToml(homeDir);
95
+ if (!raw) return requiredHooks.length > 0 ? 'untrusted' : 'unknown';
73
96
 
74
- let inRelevantState = false;
75
- let sawSection = false;
76
- let sawTrustedHash = false;
97
+ const stateSections = [];
98
+ let currentSection = null;
77
99
 
78
100
  for (const line of raw.split(/\r?\n/)) {
79
101
  const trimmed = line.replace(/#.*$/, '').trim();
80
102
  if (!trimmed) continue;
81
103
  if (trimmed.startsWith('[')) {
82
- if (/^\[hooks\.state\./.test(trimmed) && (trimmed.includes('skilltally') || trimmed.includes('hooks.json:post_tool_use'))) {
83
- inRelevantState = true;
84
- sawSection = true;
104
+ if (/^\[hooks\.state\./.test(trimmed)) {
105
+ currentSection = { header: trimmed, hasTrustedHash: false };
106
+ stateSections.push(currentSection);
85
107
  } else {
86
- inRelevantState = false;
108
+ currentSection = null;
87
109
  }
88
110
  continue;
89
111
  }
90
- if (inRelevantState && /^trusted_hash\s*=/.test(trimmed)) {
91
- sawTrustedHash = true;
112
+ if (currentSection && /^trusted_hash\s*=/.test(trimmed)) {
113
+ currentSection.hasTrustedHash = true;
114
+ }
115
+ }
116
+
117
+ if (requiredHooks.length > 0) {
118
+ for (const req of requiredHooks) {
119
+ const matching = stateSections.filter(
120
+ (s) =>
121
+ s.header.includes('skilltally') ||
122
+ s.header.includes(req.exactKey) ||
123
+ req.legacyRe.test(s.header)
124
+ );
125
+ if (!matching.some((s) => s.hasTrustedHash)) return 'untrusted';
92
126
  }
127
+ return 'trusted';
93
128
  }
94
129
 
95
- if (sawSection) return sawTrustedHash ? 'trusted' : 'untrusted';
96
- return hasUserHook ? 'untrusted' : 'unknown';
130
+ const pluginSections = stateSections.filter((s) => s.header.includes('skilltally'));
131
+ if (pluginSections.length > 0) {
132
+ return pluginSections.some((s) => s.hasTrustedHash) ? 'trusted' : 'untrusted';
133
+ }
134
+ return 'unknown';
97
135
  }
98
136
 
99
137
  export function installCodex({
@@ -115,13 +153,22 @@ export function installCodex({
115
153
  const command = `node "${runtime.target.replace(/\\/g, '/')}" --host codex`;
116
154
  const hooksPath = join(homeDir, '.codex', 'hooks.json');
117
155
  const doc = readJsonObject(hooksPath);
118
- const { nextDoc, changed, action } = mergePostToolUseHook(doc, {
156
+ const postRes = mergePostToolUseHook(doc, {
119
157
  matcher: 'exec|exec_command|shell|shell_command|local_shell|Bash',
120
158
  command,
121
159
  async: true,
122
160
  timeout: 5,
123
161
  statusMessage: 'skilltally',
124
162
  });
163
+ const promptRes = mergeUserPromptSubmitHook(postRes.nextDoc, {
164
+ command,
165
+ async: true,
166
+ timeout: 5,
167
+ statusMessage: 'skilltally',
168
+ });
169
+ const nextDoc = promptRes.nextDoc;
170
+ const changed = postRes.changed || promptRes.changed;
171
+ const action = postRes.action === 'added' && promptRes.action === 'added' ? 'added' : 'updated';
125
172
 
126
173
  let backup = null;
127
174
  if (changed) {
@@ -136,7 +183,7 @@ export function installCodex({
136
183
  status: changed ? (action === 'added' ? 'installed' : 'updated') : 'unchanged',
137
184
  target: hooksPath,
138
185
  backup,
139
- note: 'Run codex and open /hooks to review and trust the skilltally PostToolUse hook.',
186
+ note: 'Run codex and open /hooks to review and trust the skilltally hooks.',
140
187
  };
141
188
  }
142
189
 
@@ -11,29 +11,36 @@ import { checkCodexHookTrust, detectCodex, hasCodexPluginInstalled } from './cod
11
11
  import { detectGemini } from './gemini.mjs';
12
12
  import { extractHookCommandPath, getPackageRoot, isSkilltallyHandler, readJsonObject } from './runtime.mjs';
13
13
 
14
- function collectSkilltallyHookCommands(hooksJsonObj) {
14
+ function collectAntigravityHookCommands(hooksJsonObj) {
15
15
  const commands = [];
16
16
  if (!hooksJsonObj || typeof hooksJsonObj !== 'object') return commands;
17
17
 
18
- // Antigravity root hooks.json style: { "<name>": { PostToolUse: [...] } }
19
- for (const val of Object.values(hooksJsonObj)) {
20
- if (val && typeof val === 'object' && Array.isArray(val.PostToolUse)) {
21
- for (const group of val.PostToolUse) {
22
- for (const h of group?.hooks || []) {
23
- if (typeof h?.command === 'string') commands.push(h.command);
18
+ for (const [key, val] of Object.entries(hooksJsonObj)) {
19
+ if (key === 'hooks' || !val || typeof val !== 'object') continue;
20
+ if (!Array.isArray(val.PostToolUse)) continue;
21
+ for (const group of val.PostToolUse) {
22
+ for (const h of group?.hooks || []) {
23
+ if ((key === 'skilltally' || isSkilltallyHandler(h)) && typeof h?.command === 'string') {
24
+ commands.push(h.command);
24
25
  }
25
26
  }
26
27
  }
27
28
  }
28
29
 
29
- // Claude / Codex / Gemini style: { hooks: { PostToolUse: [...], AfterTool: [...] } }
30
- for (const eventName of ['PostToolUse', 'AfterTool']) {
31
- if (Array.isArray(hooksJsonObj?.hooks?.[eventName])) {
32
- for (const group of hooksJsonObj.hooks[eventName]) {
33
- for (const h of group?.hooks || []) {
34
- if (isSkilltallyHandler(h) && typeof h.command === 'string') {
35
- commands.push(h.command);
36
- }
30
+ return commands;
31
+ }
32
+
33
+ function collectNestedHookCommands(hooksJsonObj) {
34
+ const commands = [];
35
+ if (!hooksJsonObj || typeof hooksJsonObj !== 'object') return commands;
36
+
37
+ for (const eventName of ['PostToolUse', 'AfterTool', 'UserPromptSubmit', 'BeforeAgent']) {
38
+ const groups = hooksJsonObj?.hooks?.[eventName];
39
+ if (!Array.isArray(groups)) continue;
40
+ for (const group of groups) {
41
+ for (const h of group?.hooks || []) {
42
+ if (isSkilltallyHandler(h) && typeof h?.command === 'string') {
43
+ if (!commands.includes(h.command)) commands.push(h.command);
37
44
  }
38
45
  }
39
46
  }
@@ -146,14 +153,14 @@ export function runDoctor({
146
153
  let agyPluginCmds = [];
147
154
  if (agyPluginExists && existsSync(join(agyPluginDir, 'hooks.json'))) {
148
155
  try {
149
- agyPluginCmds = collectSkilltallyHookCommands(readJsonObject(join(agyPluginDir, 'hooks.json')));
156
+ agyPluginCmds = collectAntigravityHookCommands(readJsonObject(join(agyPluginDir, 'hooks.json')));
150
157
  } catch {}
151
158
  }
152
159
  let agyGlobalCmds = [];
153
160
  const agyGlobalHooksPath = join(homeDir, '.gemini', 'config', 'hooks.json');
154
161
  if (existsSync(agyGlobalHooksPath)) {
155
162
  try {
156
- agyGlobalCmds = collectSkilltallyHookCommands(readJsonObject(agyGlobalHooksPath));
163
+ agyGlobalCmds = collectAntigravityHookCommands(readJsonObject(agyGlobalHooksPath));
157
164
  } catch {}
158
165
  }
159
166
 
@@ -183,7 +190,7 @@ export function runDoctor({
183
190
  let claudeCmds = [];
184
191
  if (existsSync(claudeSettingsPath)) {
185
192
  try {
186
- claudeCmds = collectSkilltallyHookCommands(readJsonObject(claudeSettingsPath));
193
+ claudeCmds = collectNestedHookCommands(readJsonObject(claudeSettingsPath));
187
194
  } catch {}
188
195
  }
189
196
  const claudeSettingsInstalled = claudeCmds.length > 0;
@@ -204,7 +211,7 @@ export function runDoctor({
204
211
  let codexCmds = [];
205
212
  if (existsSync(codexHooksPath)) {
206
213
  try {
207
- codexCmds = collectSkilltallyHookCommands(readJsonObject(codexHooksPath));
214
+ codexCmds = collectNestedHookCommands(readJsonObject(codexHooksPath));
208
215
  } catch {}
209
216
  }
210
217
  const codexHooksInstalled = codexCmds.length > 0;
@@ -227,7 +234,7 @@ export function runDoctor({
227
234
  if (existsSync(geminiSettingsPath)) {
228
235
  try {
229
236
  const geminiDoc = readJsonObject(geminiSettingsPath);
230
- geminiCmds = collectSkilltallyHookCommands(geminiDoc);
237
+ geminiCmds = collectNestedHookCommands(geminiDoc);
231
238
  geminiHooksDisabled = geminiDoc?.hooksConfig?.enabled === false;
232
239
  } catch {}
233
240
  }
@@ -32,7 +32,7 @@ export function installGemini({
32
32
  const doc = readJsonObject(settingsPath);
33
33
 
34
34
  const { nextDoc, changed, action } = mergeEventHook(doc, 'AfterTool', {
35
- matcher: 'activate_skill',
35
+ matcher: 'activate_skill|read_file|view_file|read_many_files|run_shell_command',
36
36
  handler: {
37
37
  name: 'skilltally',
38
38
  type: 'command',
@@ -103,6 +103,7 @@ function handlersEqual(a, b) {
103
103
  export function mergeEventHook(doc, eventName, { matcher, handler }) {
104
104
  const nextDoc = structuredClone(doc && typeof doc === 'object' ? doc : {});
105
105
  const desired = { ...handler };
106
+ const normalizedMatcher = matcher ?? undefined;
106
107
 
107
108
  if (!nextDoc.hooks || typeof nextDoc.hooks !== 'object' || Array.isArray(nextDoc.hooks)) {
108
109
  nextDoc.hooks = {};
@@ -116,7 +117,7 @@ export function mergeEventHook(doc, eventName, { matcher, handler }) {
116
117
  for (const h of group.hooks) {
117
118
  if (isSkilltallyHandler(h)) {
118
119
  existingCount += 1;
119
- if (group.matcher === matcher && handlersEqual(h, desired)) {
120
+ if ((group.matcher ?? undefined) === normalizedMatcher && handlersEqual(h, desired)) {
120
121
  exactMatch = true;
121
122
  }
122
123
  }
@@ -137,7 +138,7 @@ export function mergeEventHook(doc, eventName, { matcher, handler }) {
137
138
  }
138
139
 
139
140
  cleaned.push({
140
- matcher,
141
+ ...(normalizedMatcher !== undefined ? { matcher: normalizedMatcher } : {}),
141
142
  hooks: [desired],
142
143
  });
143
144
  nextDoc.hooks[eventName] = cleaned;
@@ -165,6 +166,22 @@ export function mergePostToolUseHook(
165
166
  });
166
167
  }
167
168
 
169
+ export function mergeUserPromptSubmitHook(
170
+ doc,
171
+ { command, async = true, timeout = 5, statusMessage = 'skilltally' }
172
+ ) {
173
+ return mergeEventHook(doc, 'UserPromptSubmit', {
174
+ matcher: undefined,
175
+ handler: {
176
+ type: 'command',
177
+ command,
178
+ ...(async ? { async: true } : {}),
179
+ timeout,
180
+ statusMessage,
181
+ },
182
+ });
183
+ }
184
+
168
185
  export function removeSkilltallyHooksForEvent(doc, eventName) {
169
186
  const nextDoc = structuredClone(doc && typeof doc === 'object' ? doc : {});
170
187
  const list = nextDoc?.hooks?.[eventName];
@@ -206,5 +223,18 @@ export function removeSkilltallyHooksForEvent(doc, eventName) {
206
223
  }
207
224
 
208
225
  export function removeSkilltallyHooks(doc) {
209
- return removeSkilltallyHooksForEvent(doc, 'PostToolUse');
226
+ let current = structuredClone(doc && typeof doc === 'object' ? doc : {});
227
+ let totalRemoved = 0;
228
+ const eventNames =
229
+ current?.hooks && typeof current.hooks === 'object' && !Array.isArray(current.hooks)
230
+ ? Object.keys(current.hooks)
231
+ : [];
232
+ for (const eventName of eventNames) {
233
+ const res = removeSkilltallyHooksForEvent(current, eventName);
234
+ if (res.changed) {
235
+ current = res.nextDoc;
236
+ totalRemoved += res.removedCount;
237
+ }
238
+ }
239
+ return { nextDoc: current, changed: totalRemoved > 0, removedCount: totalRemoved };
210
240
  }