@kairyou/agent-tools 0.13.0 → 0.13.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.
- package/dist/log/hook.mjs +16 -9
- package/integrations/log/hook.mjs +26 -13
- package/package.json +1 -1
package/dist/log/hook.mjs
CHANGED
|
@@ -899,7 +899,7 @@ async function main() {
|
|
|
899
899
|
await fs.mkdir(CACHE_ROOT, { recursive: true });
|
|
900
900
|
await cleanupCache(day);
|
|
901
901
|
const state = await loadState(statePath, day);
|
|
902
|
-
await handleEvent(state, hookInput, { now, snapshotsRoot, effective, scopeKey });
|
|
902
|
+
await handleEvent(state, hookInput, { now, snapshotsRoot, effective, scopeKey, scopePath: scope?.path || "" });
|
|
903
903
|
await writeFileAtomic(statePath, `${JSON.stringify(state, null, 2)}
|
|
904
904
|
`);
|
|
905
905
|
if (effective.format === "detailed") {
|
|
@@ -981,11 +981,11 @@ async function handleEvent(state, input, context) {
|
|
|
981
981
|
session.last_time = timestamp;
|
|
982
982
|
if (eventName === "UserPromptSubmit") {
|
|
983
983
|
session.turns.push(
|
|
984
|
-
createTurn(session, timestamp, getPromptText(input), resolveProjectLabel(input), context.scopeKey)
|
|
984
|
+
createTurn(session, timestamp, getPromptText(input), resolveProjectLabel(input, context.scopePath), context.scopeKey)
|
|
985
985
|
);
|
|
986
986
|
return;
|
|
987
987
|
}
|
|
988
|
-
const turn = ensureCurrentTurn(session, timestamp, resolveProjectLabel(input), context.scopeKey);
|
|
988
|
+
const turn = ensureCurrentTurn(session, timestamp, resolveProjectLabel(input, context.scopePath), context.scopeKey);
|
|
989
989
|
turn.last_time = timestamp;
|
|
990
990
|
if (eventName === "PreToolUse") {
|
|
991
991
|
if (context.effective.format === "detailed") {
|
|
@@ -1003,14 +1003,21 @@ async function handleEvent(state, input, context) {
|
|
|
1003
1003
|
}
|
|
1004
1004
|
recordToolUse(turn, input, { timestamp });
|
|
1005
1005
|
}
|
|
1006
|
-
function resolveProjectLabel(input) {
|
|
1006
|
+
function resolveProjectLabel(input, scopePath) {
|
|
1007
1007
|
const cwd = eventCwd(input);
|
|
1008
1008
|
const result = spawnSync("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
1009
1009
|
encoding: "utf8",
|
|
1010
1010
|
windowsHide: true
|
|
1011
1011
|
});
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1012
|
+
const base = result.status === 0 && result.stdout.trim() || cwd;
|
|
1013
|
+
if (scopePath) {
|
|
1014
|
+
const baseKey = pathKey(base);
|
|
1015
|
+
const scopeKey = pathKey(scopePath);
|
|
1016
|
+
if (scopeKey === baseKey || scopeKey.startsWith(`${baseKey}/`)) {
|
|
1017
|
+
return path.basename(scopePath);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
return path.basename(base);
|
|
1014
1021
|
}
|
|
1015
1022
|
async function cleanupCache(day) {
|
|
1016
1023
|
let entries = [];
|
|
@@ -1175,9 +1182,9 @@ function dailyItemText(turn) {
|
|
|
1175
1182
|
const outcome = String(turn.result_summary || "");
|
|
1176
1183
|
if (!hasSubstantiveTurn(request, outcome) || isTrivialTurn(request, outcome)) return "";
|
|
1177
1184
|
const source = outcome || request;
|
|
1178
|
-
const
|
|
1179
|
-
if (!
|
|
1180
|
-
return
|
|
1185
|
+
const flattened = source.split("\n").map((line) => line.replace(/^[#>*\-\s`|]+/, "").trim()).filter(Boolean).join(" ");
|
|
1186
|
+
if (!flattened) return "";
|
|
1187
|
+
return flattened.length > DAILY_ITEM_MAX_CHARS ? `${flattened.slice(0, DAILY_ITEM_MAX_CHARS - 3)}...` : flattened;
|
|
1181
1188
|
}
|
|
1182
1189
|
async function updateDailyFile(outputFile, day, items) {
|
|
1183
1190
|
if (items.length === 0) return;
|
|
@@ -70,7 +70,7 @@ async function main() {
|
|
|
70
70
|
await cleanupCache(day);
|
|
71
71
|
|
|
72
72
|
const state = await loadState(statePath, day);
|
|
73
|
-
await handleEvent(state, hookInput, { now, snapshotsRoot, effective, scopeKey });
|
|
73
|
+
await handleEvent(state, hookInput, { now, snapshotsRoot, effective, scopeKey, scopePath: scope?.path || "" });
|
|
74
74
|
await writeFileAtomic(statePath, `${JSON.stringify(state, null, 2)}\n`);
|
|
75
75
|
|
|
76
76
|
if (effective.format === "detailed") {
|
|
@@ -174,12 +174,12 @@ async function handleEvent(state, input, context) {
|
|
|
174
174
|
// let this prompt's Stop overwrite the previous result summary. Trivial
|
|
175
175
|
// turns are filtered at render time instead.
|
|
176
176
|
session.turns.push(
|
|
177
|
-
createTurn(session, timestamp, getPromptText(input), resolveProjectLabel(input), context.scopeKey)
|
|
177
|
+
createTurn(session, timestamp, getPromptText(input), resolveProjectLabel(input, context.scopePath), context.scopeKey)
|
|
178
178
|
);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
const turn = ensureCurrentTurn(session, timestamp, resolveProjectLabel(input), context.scopeKey);
|
|
182
|
+
const turn = ensureCurrentTurn(session, timestamp, resolveProjectLabel(input, context.scopePath), context.scopeKey);
|
|
183
183
|
turn.last_time = timestamp;
|
|
184
184
|
|
|
185
185
|
if (eventName === "PreToolUse") {
|
|
@@ -202,14 +202,24 @@ async function handleEvent(state, input, context) {
|
|
|
202
202
|
recordToolUse(turn, input, { timestamp });
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function resolveProjectLabel(input) {
|
|
205
|
+
function resolveProjectLabel(input, scopePath) {
|
|
206
206
|
const cwd = eventCwd(input);
|
|
207
207
|
const result = spawnSync("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
208
208
|
encoding: "utf8",
|
|
209
209
|
windowsHide: true,
|
|
210
210
|
});
|
|
211
|
-
const
|
|
212
|
-
|
|
211
|
+
const base = (result.status === 0 && result.stdout.trim()) || cwd;
|
|
212
|
+
// A scope deeper than the repo (a monorepo team dir such as src/webfront)
|
|
213
|
+
// labels entries better than the repo name; a scope broader than the repo
|
|
214
|
+
// (a directory holding many repos) keeps the repo name.
|
|
215
|
+
if (scopePath) {
|
|
216
|
+
const baseKey = pathKey(base);
|
|
217
|
+
const scopeKey = pathKey(scopePath);
|
|
218
|
+
if (scopeKey === baseKey || scopeKey.startsWith(`${baseKey}/`)) {
|
|
219
|
+
return path.basename(scopePath);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return path.basename(base);
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
async function cleanupCache(day) {
|
|
@@ -417,14 +427,17 @@ function dailyItemText(turn) {
|
|
|
417
427
|
const outcome = String(turn.result_summary || "");
|
|
418
428
|
if (!hasSubstantiveTurn(request, outcome) || isTrivialTurn(request, outcome)) return "";
|
|
419
429
|
const source = outcome || request;
|
|
420
|
-
|
|
430
|
+
// Flattened rather than first-line: a structured summary often opens with a
|
|
431
|
+
// preamble line, and the substance sits in the lines after it.
|
|
432
|
+
const flattened = source
|
|
421
433
|
.split("\n")
|
|
422
|
-
.map((line) => line.replace(/^[#>*\-\s
|
|
423
|
-
.
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
434
|
+
.map((line) => line.replace(/^[#>*\-\s`|]+/, "").trim())
|
|
435
|
+
.filter(Boolean)
|
|
436
|
+
.join(" ");
|
|
437
|
+
if (!flattened) return "";
|
|
438
|
+
return flattened.length > DAILY_ITEM_MAX_CHARS
|
|
439
|
+
? `${flattened.slice(0, DAILY_ITEM_MAX_CHARS - 3)}...`
|
|
440
|
+
: flattened;
|
|
428
441
|
}
|
|
429
442
|
|
|
430
443
|
async function updateDailyFile(outputFile, day, items) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kairyou/agent-tools",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Reusable Agent Skills, plus integrations (statusline, provider usage, vision) that install into Codex, Claude Code, and opencode.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|