@spardutti/claude-skills 2.56.1 → 2.56.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/README.md +1 -1
- package/hooks/ship-log.mjs +20 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/hooks/ship-log.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
5
5
|
import { git, parseReport, prSize } from "./ship-log-parse.mjs";
|
|
6
6
|
import { printReport, tally } from "./ship-log-report.mjs";
|
|
@@ -45,8 +45,8 @@ function summarize(record) {
|
|
|
45
45
|
return { minutes: Math.round(minutes * 10) / 10, gateRuns: record.gate.length, gateSeconds: record.gate.reduce((n, r) => n + (r.seconds ?? 0), 0), findings: by };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function finalize(dir, path, record, tag, status, reason) {
|
|
49
|
-
Object.assign(record, { status, reason: reason ?? null, finished: now() });
|
|
48
|
+
function finalize(dir, path, record, tag, status, reason, at) {
|
|
49
|
+
Object.assign(record, { status, reason: reason ?? null, finished: at ?? now() });
|
|
50
50
|
record.summary = summarize(record);
|
|
51
51
|
const stem = `${record.app}_${record.finished.slice(0, 10)}_${tag}`;
|
|
52
52
|
let out = join(dir, `${stem}.json`);
|
|
@@ -56,8 +56,25 @@ function finalize(dir, path, record, tag, status, reason) {
|
|
|
56
56
|
console.log(`ship-log: saved ${out}`);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function prOf(branch) {
|
|
60
|
+
const r = spawnSync("gh", ["pr", "list", "--head", branch, "--state", "all", "--json", "number,createdAt", "--limit", "1"], { encoding: "utf8" });
|
|
61
|
+
try { return r.status === 0 ? JSON.parse(r.stdout)[0] : undefined; } catch { return undefined; }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Agents skip the `pr` call, so a log whose branch has a PR by now is closed at that PR.
|
|
65
|
+
function closeOpened(dir, app) {
|
|
66
|
+
const open = join(dir, "open");
|
|
67
|
+
for (const f of existsSync(open) ? readdirSync(open).filter((n) => n.startsWith(`${app}__`)) : []) {
|
|
68
|
+
const path = join(open, f), record = JSON.parse(readFileSync(path, "utf8"));
|
|
69
|
+
if (!record.gate.length && !record.findings.length) continue;
|
|
70
|
+
const pr = prOf(record.branch);
|
|
71
|
+
if (pr) finalize(dir, path, Object.assign(record, { pr: pr.number }), `pr${pr.number}`, "pr-opened", null, pr.createdAt);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
// A ship that never reached pr or end was abandoned; keep it, but never fold it into the next one.
|
|
60
76
|
function restart(dir, path, record, id) {
|
|
77
|
+
closeOpened(dir, id.app);
|
|
61
78
|
if (existsSync(path)) finalize(dir, path, record, id.branch.replace(/[^\w.-]+/g, "-"), "abandoned");
|
|
62
79
|
save(path, load(path, id));
|
|
63
80
|
}
|