@spardutti/claude-skills 2.56.0 → 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-report.mjs +3 -1
- package/hooks/ship-log.mjs +20 -3
- package/hooks/ship-mark.sh +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@ function records(dir) {
|
|
|
6
6
|
return [...read(dir), ...read(join(dir, "open"))].flatMap((f) => {
|
|
7
7
|
try {
|
|
8
8
|
const r = JSON.parse(readFileSync(f, "utf8"));
|
|
9
|
-
|
|
9
|
+
const log = r?.v === 1 && Array.isArray(r.gate) && Array.isArray(r.findings);
|
|
10
|
+
// A /ship that only merged opens a log and never fills it.
|
|
11
|
+
return log && (r.gate.length || r.findings.length) ? [r] : [];
|
|
10
12
|
} catch { return []; }
|
|
11
13
|
});
|
|
12
14
|
}
|
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
|
}
|
package/hooks/ship-mark.sh
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
2
3
|
cd "${CLAUDE_PROJECT_DIR:-$PWD}" 2>/dev/null || exit 1
|
|
4
|
+
NO_LOG=""; [ "${2:-}" = "--no-log" ] && { NO_LOG=1; set -- "$1" "${@:3}"; }
|
|
3
5
|
# The shared .git dir, so a worktree's mark is found from the main folder.
|
|
4
6
|
COMMON=$(cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd) || exit 1
|
|
5
7
|
BRANCH=${2:-$(git branch --show-current 2>/dev/null)}
|
|
@@ -8,7 +10,11 @@ MARK="/tmp/claude-ship-$(printf '%s %s' "$COMMON" "$BRANCH" | cksum | cut -d' '
|
|
|
8
10
|
|
|
9
11
|
# A mark lasts 12 hours, so a branch reused later (dev, for a release) needs /ship again.
|
|
10
12
|
case "${1:-}" in
|
|
11
|
-
begin)
|
|
13
|
+
begin)
|
|
14
|
+
touch "$MARK"
|
|
15
|
+
# The log opens here, not in ship.md: agents skipped that step. A failed log never fails the mark.
|
|
16
|
+
[ -z "$NO_LOG" ] && command -v node >/dev/null && node "$HERE/ship-log.mjs" start >/dev/null 2>&1
|
|
17
|
+
true ;;
|
|
12
18
|
check) [ -n "$(find "$MARK" -mmin -720 2>/dev/null)" ] ;;
|
|
13
|
-
*) echo "usage: ship-mark.sh begin | check [branch]" >&2; exit 2 ;;
|
|
19
|
+
*) echo "usage: ship-mark.sh begin [--no-log] | check [branch]" >&2; exit 2 ;;
|
|
14
20
|
esac
|