oxtail 0.8.0 → 0.10.0
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 +51 -23
- package/assets/pretooluse.sh +68 -50
- package/assets/stop.sh +171 -0
- package/assets/userpromptsubmit.sh +55 -0
- package/dist/claims.js +228 -0
- package/dist/clients.js +4 -4
- package/dist/mailbox.js +1 -4
- package/dist/server.js +468 -253
- package/dist/transcripts.js +263 -50
- package/package.json +1 -1
- package/scripts/hook-constants.mjs +44 -6
- package/scripts/install-hook.mjs +69 -57
- package/scripts/uninstall-hook.mjs +40 -32
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Remove the oxtail PreToolUse
|
|
3
|
-
// ~/.claude/settings.json, and delete the installed
|
|
2
|
+
// Remove the oxtail hook entries (PreToolUse + Stop) and marker from
|
|
3
|
+
// ~/.claude/settings.json, and delete the installed scripts under
|
|
4
|
+
// ~/.oxtail/hooks/.
|
|
4
5
|
//
|
|
5
6
|
// Idempotent: a clean run on an uninstalled system exits 0 with "nothing to do."
|
|
6
7
|
|
|
@@ -12,13 +13,13 @@ import { applyEdits, modify, parse } from "jsonc-parser";
|
|
|
12
13
|
import {
|
|
13
14
|
SETTINGS_PATH,
|
|
14
15
|
HOOK_MARKER_KEY,
|
|
15
|
-
|
|
16
|
+
MANAGED_HOOKS,
|
|
16
17
|
} from "./hook-constants.mjs";
|
|
17
18
|
|
|
18
19
|
const FORMATTING = { tabSize: 2, insertSpaces: true };
|
|
19
20
|
|
|
20
|
-
function findOxtailHookIndex(parsed) {
|
|
21
|
-
const arr = parsed?.hooks?.
|
|
21
|
+
function findOxtailHookIndex(parsed, event, asset) {
|
|
22
|
+
const arr = parsed?.hooks?.[event];
|
|
22
23
|
if (!Array.isArray(arr)) return -1;
|
|
23
24
|
return arr.findIndex((entry) => {
|
|
24
25
|
if (!entry || typeof entry !== "object") return false;
|
|
@@ -28,44 +29,58 @@ function findOxtailHookIndex(parsed) {
|
|
|
28
29
|
h &&
|
|
29
30
|
typeof h === "object" &&
|
|
30
31
|
typeof h.command === "string" &&
|
|
31
|
-
h.command.includes(
|
|
32
|
+
h.command.includes(`oxtail/hooks/${asset}`),
|
|
32
33
|
);
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
async function removeScripts() {
|
|
38
|
+
for (const h of MANAGED_HOOKS) {
|
|
39
|
+
if (!existsSync(h.scriptPath)) continue;
|
|
40
|
+
try {
|
|
41
|
+
await unlink(h.scriptPath);
|
|
42
|
+
console.log(`Removed ${h.scriptPath}.`);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.warn(`Could not remove ${h.scriptPath}: ${err?.message ?? err}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
36
49
|
export async function uninstall() {
|
|
37
50
|
if (!existsSync(SETTINGS_PATH)) {
|
|
38
51
|
console.log(`No ${SETTINGS_PATH} — nothing to do.`);
|
|
39
|
-
// Still try to remove
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
await unlink(HOOK_SCRIPT_PATH);
|
|
43
|
-
console.log(`Removed ${HOOK_SCRIPT_PATH}.`);
|
|
44
|
-
} catch (err) {
|
|
45
|
-
console.warn(`Could not remove ${HOOK_SCRIPT_PATH}: ${err?.message ?? err}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
52
|
+
// Still try to remove installed scripts in case they're leftovers.
|
|
53
|
+
await removeScripts();
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
const source = await readFile(SETTINGS_PATH, "utf8");
|
|
52
58
|
const parsed = parse(source) ?? {};
|
|
53
59
|
|
|
54
|
-
const idx = findOxtailHookIndex(parsed);
|
|
55
60
|
const hasMarker =
|
|
56
61
|
parsed[HOOK_MARKER_KEY] && typeof parsed[HOOK_MARKER_KEY] === "object";
|
|
62
|
+
const anyEntry = MANAGED_HOOKS.some(
|
|
63
|
+
(h) => findOxtailHookIndex(parsed, h.event, h.asset) >= 0,
|
|
64
|
+
);
|
|
65
|
+
const anyScript = MANAGED_HOOKS.some((h) => existsSync(h.scriptPath));
|
|
57
66
|
|
|
58
|
-
if (
|
|
59
|
-
console.log("oxtail
|
|
67
|
+
if (!anyEntry && !hasMarker && !anyScript) {
|
|
68
|
+
console.log("oxtail hooks not installed — nothing to do.");
|
|
60
69
|
return;
|
|
61
70
|
}
|
|
62
71
|
|
|
72
|
+
// Remove each event's oxtail entry. Re-parse per iteration so indices stay
|
|
73
|
+
// valid after the prior edit.
|
|
63
74
|
let text = source;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
for (const h of MANAGED_HOOKS) {
|
|
76
|
+
const cur = parse(text) ?? {};
|
|
77
|
+
const idx = findOxtailHookIndex(cur, h.event, h.asset);
|
|
78
|
+
if (idx >= 0) {
|
|
79
|
+
text = applyEdits(
|
|
80
|
+
text,
|
|
81
|
+
modify(text, ["hooks", h.event, idx], undefined, { formattingOptions: FORMATTING }),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
69
84
|
}
|
|
70
85
|
if (hasMarker) {
|
|
71
86
|
text = applyEdits(
|
|
@@ -78,16 +93,9 @@ export async function uninstall() {
|
|
|
78
93
|
await mkdir(path.dirname(SETTINGS_PATH), { recursive: true });
|
|
79
94
|
await writeFile(settingsTmp, text, "utf8");
|
|
80
95
|
await rename(settingsTmp, SETTINGS_PATH);
|
|
81
|
-
console.log(`Removed oxtail
|
|
96
|
+
console.log(`Removed oxtail hooks from ${SETTINGS_PATH}.`);
|
|
82
97
|
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
await unlink(HOOK_SCRIPT_PATH);
|
|
86
|
-
console.log(`Removed ${HOOK_SCRIPT_PATH}.`);
|
|
87
|
-
} catch (err) {
|
|
88
|
-
console.warn(`Could not remove ${HOOK_SCRIPT_PATH}: ${err?.message ?? err}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
98
|
+
await removeScripts();
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
const invokedDirectly =
|