codealmanac 0.1.10 → 0.2.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 +36 -21
- package/dist/agents-A4II4YJC.js +15 -0
- package/dist/auth-S5DVUIUJ.js +18 -0
- package/dist/{chunk-Z4MWLVS2.js → chunk-447U3GQJ.js} +162 -5
- package/dist/chunk-447U3GQJ.js.map +1 -0
- package/dist/{chunk-QLHJP2XK.js → chunk-D3B2EEHL.js} +12 -8
- package/dist/{chunk-QLHJP2XK.js.map → chunk-D3B2EEHL.js.map} +1 -1
- package/dist/{chunk-AXFPUHBN.js → chunk-F53U6JQG.js} +8 -49
- package/dist/chunk-F53U6JQG.js.map +1 -0
- package/dist/{chunk-BJVZLP6O.js → chunk-MX2EW5MR.js} +3 -3
- package/dist/{chunk-Z6MBJ3D2.js → chunk-QQHIVTXT.js} +6 -4
- package/dist/{chunk-Z6MBJ3D2.js.map → chunk-QQHIVTXT.js.map} +1 -1
- package/dist/chunk-R3URPHGH.js +194 -0
- package/dist/chunk-R3URPHGH.js.map +1 -0
- package/dist/chunk-SSYMRT4I.js +126 -0
- package/dist/chunk-SSYMRT4I.js.map +1 -0
- package/dist/{chunk-QHQ6YH7U.js → chunk-V3QOQSXI.js} +5 -3
- package/dist/{chunk-QHQ6YH7U.js.map → chunk-V3QOQSXI.js.map} +1 -1
- package/dist/chunk-WRUSDYYE.js +97 -0
- package/dist/chunk-WRUSDYYE.js.map +1 -0
- package/dist/{chunk-3LC55TG6.js → chunk-ZDJSJIB6.js} +77 -126
- package/dist/chunk-ZDJSJIB6.js.map +1 -0
- package/dist/{cli-W3OYVJYH.js → cli-CMGYLJSN.js} +52 -13
- package/dist/cli-CMGYLJSN.js.map +1 -0
- package/dist/codealmanac.js +1 -1
- package/dist/doctor-BTH7GCFV.js +17 -0
- package/dist/{hook-CRJMWSSO.js → hook-2NP3UE7U.js} +2 -2
- package/dist/{register-commands-JHC2OFKM.js → register-commands-7SKQLQW4.js} +330 -32
- package/dist/register-commands-7SKQLQW4.js.map +1 -0
- package/dist/uninstall-FDIOBAAR.js +15 -0
- package/dist/uninstall-FDIOBAAR.js.map +1 -0
- package/dist/update-RAF7QRYF.js +11 -0
- package/dist/update-RAF7QRYF.js.map +1 -0
- package/hooks/almanac-capture.sh +40 -7
- package/package.json +1 -1
- package/dist/chunk-3LC55TG6.js.map +0 -1
- package/dist/chunk-AXFPUHBN.js.map +0 -1
- package/dist/chunk-Z4MWLVS2.js.map +0 -1
- package/dist/cli-W3OYVJYH.js.map +0 -1
- package/dist/doctor-ODFNJUKH.js +0 -15
- package/dist/register-commands-JHC2OFKM.js.map +0 -1
- package/dist/uninstall-HE2Z2LN2.js +0 -12
- package/dist/update-IL243I4E.js +0 -10
- /package/dist/{doctor-ODFNJUKH.js.map → agents-A4II4YJC.js.map} +0 -0
- /package/dist/{hook-CRJMWSSO.js.map → auth-S5DVUIUJ.js.map} +0 -0
- /package/dist/{chunk-BJVZLP6O.js.map → chunk-MX2EW5MR.js.map} +0 -0
- /package/dist/{uninstall-HE2Z2LN2.js.map → doctor-BTH7GCFV.js.map} +0 -0
- /package/dist/{update-IL243I4E.js.map → hook-2NP3UE7U.js.map} +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A single `CLAUDE.md` at the repo root doesn't scale past a few hundred lines, ha
|
|
|
12
12
|
|
|
13
13
|
## How it works
|
|
14
14
|
|
|
15
|
-
Each repo gets a committed `.almanac/pages/` directory of markdown files.
|
|
15
|
+
Each repo gets a committed `.almanac/pages/` directory of markdown files. Auto-capture hooks fire when Claude Code, Codex, or Cursor Agent sessions end and run `almanac capture` in the background. A writer agent reads the session transcript and existing pages, drafts changes, and runs a reviewer pass against the wider graph. The writer applies the final versions. New and updated pages show up in your next `git status`; you review them like any other commit.
|
|
16
16
|
|
|
17
17
|
The CLI never reads or writes page content except in `capture` and `bootstrap`. Every other command (`search`, `show`, `topics`, `tag`, `health`) operates on a SQLite index that rebuilds silently whenever pages are newer than the index.
|
|
18
18
|
|
|
@@ -28,8 +28,9 @@ codealmanac --yes
|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
`codealmanac` (the bare invocation) routes to a setup wizard that:
|
|
31
|
-
-
|
|
32
|
-
-
|
|
31
|
+
- lets you choose a default agent: Claude, Codex, or Cursor,
|
|
32
|
+
- checks local agent readiness,
|
|
33
|
+
- installs auto-capture hooks for Claude, Codex, and Cursor,
|
|
33
34
|
- drops two agent guides into `~/.claude/` (`codealmanac.md` mini, `codealmanac-reference.md` full),
|
|
34
35
|
- appends `@~/.claude/codealmanac.md` to `~/.claude/CLAUDE.md` so every Claude Code session loads the mini guide.
|
|
35
36
|
|
|
@@ -37,49 +38,59 @@ The setup is idempotent — safe to re-run. Opt out with `--skip-hook` or `--ski
|
|
|
37
38
|
|
|
38
39
|
Two binaries ship, both pointing at the same entry: `codealmanac` (install surface) and `almanac` (day-to-day). Requires Node 20 or 22.
|
|
39
40
|
|
|
40
|
-
`bootstrap` and `capture` invoke Claude
|
|
41
|
+
`bootstrap` and `capture` invoke your configured default agent. Claude uses the bundled Claude Agent SDK, Codex uses `codex exec --json`, and Cursor uses `cursor-agent --print --output-format stream-json`. The query commands (`search`, `show`, `health`, `topics`) need no credentials at all.
|
|
41
42
|
|
|
42
43
|
## Authentication
|
|
43
44
|
|
|
44
|
-
Pick
|
|
45
|
+
Pick the agent you want CodeAlmanac to use:
|
|
45
46
|
|
|
46
47
|
```bash
|
|
47
|
-
#
|
|
48
|
-
# use Claude Code; no separate bill, no copy-pasted keys.
|
|
48
|
+
# Claude
|
|
49
49
|
claude auth login --claudeai
|
|
50
|
-
|
|
51
|
-
# Option B — a pay-per-token API key from https://console.anthropic.com.
|
|
50
|
+
# or:
|
|
52
51
|
export ANTHROPIC_API_KEY=sk-ant-...
|
|
53
52
|
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
# Codex
|
|
54
|
+
codex login
|
|
55
|
+
|
|
56
|
+
# Cursor
|
|
57
|
+
cursor-agent login
|
|
58
|
+
|
|
59
|
+
# Verify all providers:
|
|
60
|
+
almanac agents list
|
|
57
61
|
almanac doctor
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
Set or change the default at any time:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
almanac set default-agent codex
|
|
68
|
+
almanac set model codex gpt-5.3-codex
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
codealmanac itself never stores your provider credentials. Auth stays in each agent's normal local credential store.
|
|
61
72
|
|
|
62
73
|
## Quickstart
|
|
63
74
|
|
|
64
75
|
```bash
|
|
65
76
|
npm install -g codealmanac
|
|
66
|
-
codealmanac # interactive setup wizard
|
|
77
|
+
codealmanac # interactive setup wizard; choose Claude/Codex/Cursor
|
|
67
78
|
# (or: codealmanac --yes)
|
|
68
79
|
|
|
69
80
|
cd your-repo
|
|
70
|
-
almanac bootstrap # agent reads the repo and seeds
|
|
81
|
+
almanac bootstrap # default agent reads the repo and seeds pages + topic DAG
|
|
71
82
|
|
|
72
83
|
almanac search "auth" # full-text search across pages; prints slugs one per line
|
|
73
84
|
almanac show checkout-flow # read a page
|
|
74
85
|
|
|
75
|
-
# From here on, just code as usual — the
|
|
86
|
+
# From here on, just code as usual — the installed hooks invoke
|
|
76
87
|
# `almanac capture` at session end, which writes and updates pages
|
|
77
88
|
# based on what happened in the session.
|
|
78
89
|
```
|
|
79
90
|
|
|
80
91
|
No `almanac init`. A wiki is scaffolded two ways: run `almanac bootstrap` yourself, or clone a repo that already has `.almanac/` committed (codealmanac auto-registers it on the first query).
|
|
81
92
|
|
|
82
|
-
Sanity-check the install with `almanac doctor` —
|
|
93
|
+
Sanity-check the install with `almanac doctor` and `almanac agents list` — they report binary location, native SQLite binding, provider readiness, hook status, guides, import line, and current-wiki stats.
|
|
83
94
|
|
|
84
95
|
## Command reference
|
|
85
96
|
|
|
@@ -94,10 +105,14 @@ Grouped the same way as `almanac --help`:
|
|
|
94
105
|
| Edit | `almanac tag <page> <topics...>` | Add topics; auto-creates missing ones; `--stdin` for bulk |
|
|
95
106
|
| Edit | `almanac untag <page> <topic>` | Remove a topic |
|
|
96
107
|
| Edit | `almanac topics ...` | `list`, `show`, `create`, `link`, `unlink`, `rename`, `delete`, `describe` — DAG management |
|
|
97
|
-
| Wiki lifecycle | `almanac bootstrap` | Agent reads the repo and seeds stub entity pages + topic DAG
|
|
108
|
+
| Wiki lifecycle | `almanac bootstrap [--agent claude\|codex\|cursor]` | Agent reads the repo and seeds stub entity pages + topic DAG |
|
|
98
109
|
| Wiki lifecycle | `almanac capture [transcript]` | Writer + reviewer on a session transcript (usually invoked by the hook) |
|
|
99
|
-
| Wiki lifecycle | `almanac hook install\|
|
|
110
|
+
| Wiki lifecycle | `almanac hook install [--source claude\|codex\|cursor\|all]` | Install auto-capture hooks |
|
|
111
|
+
| Wiki lifecycle | `almanac hook uninstall\|status` | Manage the Claude SessionEnd hook |
|
|
100
112
|
| Wiki lifecycle | `almanac reindex` | Force rebuild of `.almanac/index.db` |
|
|
113
|
+
| Setup | `almanac agents list` | Show Claude/Codex/Cursor readiness and configured default |
|
|
114
|
+
| Setup | `almanac set default-agent <agent>` | Change the default agent |
|
|
115
|
+
| Setup | `almanac set model <agent> [model]` | Set or reset a provider model override |
|
|
101
116
|
| Setup | `almanac setup` | Install hook + guides + CLAUDE.md import (bare `codealmanac` alias) |
|
|
102
117
|
| Setup | `almanac uninstall` | Reverse `setup`: remove hook + guides + import line |
|
|
103
118
|
| Setup | `almanac doctor` | Report on install + current wiki with one-line fixes |
|
|
@@ -172,7 +187,7 @@ PostgreSQL hosted on Supabase. Connection pooling via Supavisor.
|
|
|
172
187
|
- UUIDs as primary keys, not `serial` ([[uuid-decision]]).
|
|
173
188
|
```
|
|
174
189
|
|
|
175
|
-
When a Claude
|
|
190
|
+
When a Claude, Codex, or Cursor session ends, the installed hook backgrounds `almanac capture <transcript>`. The writer agent reads the transcript, runs `almanac search` and `almanac show` against the existing wiki, drafts changes to pages under `.almanac/pages/`, and performs a reviewer pass. Claude uses its SDK's read-only reviewer subagent; Codex and Cursor perform the reviewer pass from prompt guidance until stricter provider enforcement lands. The reviewer checks duplicates, missing wikilinks, missing topics, inference dressed as fact, and cohesion problems. The writer decides what to incorporate and writes the final versions. Capture writes nothing if nothing in the session meets the notability bar — silence is a valid outcome.
|
|
176
191
|
|
|
177
192
|
No proposal files, no `--apply` step, no state machine between writer and reviewer. The changes land in `git status` and you commit them like anything else.
|
|
178
193
|
|
|
@@ -193,7 +208,7 @@ Pages are neutral-tone encyclopedia-style prose — every sentence contains a sp
|
|
|
193
208
|
|
|
194
209
|
## Status
|
|
195
210
|
|
|
196
|
-
`v0.
|
|
211
|
+
`v0.2.0`, pre-release. Node 20.x or 22.x. Release process is documented in [RELEASE.md](./RELEASE.md). Breaking changes are possible before 1.0; they will be called out in release notes.
|
|
197
212
|
|
|
198
213
|
## Philosophy
|
|
199
214
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runAgentsList,
|
|
4
|
+
runSetAgentModel,
|
|
5
|
+
runSetDefaultAgent
|
|
6
|
+
} from "./chunk-R3URPHGH.js";
|
|
7
|
+
import "./chunk-SSYMRT4I.js";
|
|
8
|
+
import "./chunk-WRUSDYYE.js";
|
|
9
|
+
import "./chunk-7JUX4ADQ.js";
|
|
10
|
+
export {
|
|
11
|
+
runAgentsList,
|
|
12
|
+
runSetAgentModel,
|
|
13
|
+
runSetDefaultAgent
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=agents-A4II4YJC.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
UNAUTHENTICATED_MESSAGE,
|
|
4
|
+
assertClaudeAuth,
|
|
5
|
+
checkClaudeAuth,
|
|
6
|
+
defaultSpawnCli,
|
|
7
|
+
legacySdkSpawnCli,
|
|
8
|
+
resolveClaudeExecutable
|
|
9
|
+
} from "./chunk-SSYMRT4I.js";
|
|
10
|
+
export {
|
|
11
|
+
UNAUTHENTICATED_MESSAGE,
|
|
12
|
+
assertClaudeAuth,
|
|
13
|
+
checkClaudeAuth,
|
|
14
|
+
defaultSpawnCli,
|
|
15
|
+
legacySdkSpawnCli,
|
|
16
|
+
resolveClaudeExecutable
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=auth-S5DVUIUJ.js.map
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/commands/hook.ts
|
|
4
4
|
import { existsSync as existsSync2 } from "fs";
|
|
5
5
|
import { mkdir as mkdir2, readFile as readFile2, rename, writeFile } from "fs/promises";
|
|
6
|
+
import { homedir as homedir2 } from "os";
|
|
6
7
|
import path2 from "path";
|
|
7
8
|
|
|
8
9
|
// src/commands/hook/script.ts
|
|
@@ -120,6 +121,54 @@ async function runHookInstall(options = {}) {
|
|
|
120
121
|
return { stdout: "", stderr: `almanac: ${script.error}
|
|
121
122
|
`, exitCode: 1 };
|
|
122
123
|
}
|
|
124
|
+
const source = options.source ?? "claude";
|
|
125
|
+
if (source === "all") {
|
|
126
|
+
const results = [
|
|
127
|
+
await installClaudeHook(options, script.path),
|
|
128
|
+
await installGenericHook({
|
|
129
|
+
label: "Codex Stop",
|
|
130
|
+
settingsPath: path2.join(homedir2(), ".codex", "hooks.json"),
|
|
131
|
+
eventName: "Stop",
|
|
132
|
+
shape: "wrapped",
|
|
133
|
+
scriptPath: script.path
|
|
134
|
+
}),
|
|
135
|
+
await installGenericHook({
|
|
136
|
+
label: "Cursor sessionEnd",
|
|
137
|
+
settingsPath: path2.join(homedir2(), ".cursor", "hooks.json"),
|
|
138
|
+
eventName: "sessionEnd",
|
|
139
|
+
shape: "flat",
|
|
140
|
+
scriptPath: script.path
|
|
141
|
+
})
|
|
142
|
+
];
|
|
143
|
+
const failed = results.find((r) => r.exitCode !== 0);
|
|
144
|
+
if (failed !== void 0) return failed;
|
|
145
|
+
return {
|
|
146
|
+
stdout: results.map((r) => r.stdout.trimEnd()).join("\n") + "\n",
|
|
147
|
+
stderr: "",
|
|
148
|
+
exitCode: 0
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (source === "codex") {
|
|
152
|
+
return await installGenericHook({
|
|
153
|
+
label: "Codex Stop",
|
|
154
|
+
settingsPath: path2.join(homedir2(), ".codex", "hooks.json"),
|
|
155
|
+
eventName: "Stop",
|
|
156
|
+
shape: "wrapped",
|
|
157
|
+
scriptPath: script.path
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (source === "cursor") {
|
|
161
|
+
return await installGenericHook({
|
|
162
|
+
label: "Cursor sessionEnd",
|
|
163
|
+
settingsPath: path2.join(homedir2(), ".cursor", "hooks.json"),
|
|
164
|
+
eventName: "sessionEnd",
|
|
165
|
+
shape: "flat",
|
|
166
|
+
scriptPath: script.path
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return await installClaudeHook(options, script.path);
|
|
170
|
+
}
|
|
171
|
+
async function installClaudeHook(options, scriptPath) {
|
|
123
172
|
const settingsPath = resolveSettingsPath(options);
|
|
124
173
|
const settings = await readSettings(settingsPath);
|
|
125
174
|
const existing = (settings.hooks?.SessionEnd ?? []).slice();
|
|
@@ -134,7 +183,7 @@ async function runHookInstall(options = {}) {
|
|
|
134
183
|
continue;
|
|
135
184
|
}
|
|
136
185
|
const exactMatch = c.entry.hooks.some(
|
|
137
|
-
(h) => h.command ===
|
|
186
|
+
(h) => h.command === scriptPath
|
|
138
187
|
);
|
|
139
188
|
if (exactMatch && oursAlready === null) {
|
|
140
189
|
oursAlready = c.entry;
|
|
@@ -172,7 +221,7 @@ Remove or rewrap it manually in ${settingsPath} before installing.
|
|
|
172
221
|
}
|
|
173
222
|
if (oursAlready !== null && staleCount.n === 0) {
|
|
174
223
|
return {
|
|
175
|
-
stdout: `almanac: SessionEnd hook already installed at ${
|
|
224
|
+
stdout: `almanac: SessionEnd hook already installed at ${scriptPath}
|
|
176
225
|
`,
|
|
177
226
|
stderr: "",
|
|
178
227
|
exitCode: 0
|
|
@@ -183,7 +232,7 @@ Remove or rewrap it manually in ${settingsPath} before installing.
|
|
|
183
232
|
hooks: [
|
|
184
233
|
{
|
|
185
234
|
type: "command",
|
|
186
|
-
command:
|
|
235
|
+
command: scriptPath,
|
|
187
236
|
timeout: HOOK_TIMEOUT_SECONDS
|
|
188
237
|
}
|
|
189
238
|
]
|
|
@@ -193,13 +242,121 @@ Remove or rewrap it manually in ${settingsPath} before installing.
|
|
|
193
242
|
await writeSettings(settingsPath, settings);
|
|
194
243
|
return {
|
|
195
244
|
stdout: `almanac: SessionEnd hook installed
|
|
196
|
-
script: ${
|
|
245
|
+
script: ${scriptPath}
|
|
197
246
|
settings: ${settingsPath}
|
|
198
247
|
`,
|
|
199
248
|
stderr: "",
|
|
200
249
|
exitCode: 0
|
|
201
250
|
};
|
|
202
251
|
}
|
|
252
|
+
async function installGenericHook(args) {
|
|
253
|
+
const settings = await readSettings(args.settingsPath);
|
|
254
|
+
const hooksObj = settings.hooks !== void 0 && settings.hooks !== null && typeof settings.hooks === "object" ? settings.hooks : {};
|
|
255
|
+
const existing = Array.isArray(hooksObj[args.eventName]) ? hooksObj[args.eventName] : [];
|
|
256
|
+
const kept = existing.filter((entry) => !entryHasOurCommand(entry));
|
|
257
|
+
const already = existing.some(
|
|
258
|
+
(entry) => entryHasExactCommand(entry, args.scriptPath)
|
|
259
|
+
);
|
|
260
|
+
if (already && kept.length === existing.length - 1) {
|
|
261
|
+
return {
|
|
262
|
+
stdout: `almanac: ${args.label} hook already installed at ${args.scriptPath}
|
|
263
|
+
`,
|
|
264
|
+
stderr: "",
|
|
265
|
+
exitCode: 0
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const fresh = args.shape === "wrapped" ? {
|
|
269
|
+
hooks: [
|
|
270
|
+
{
|
|
271
|
+
type: "command",
|
|
272
|
+
command: args.scriptPath,
|
|
273
|
+
timeout: HOOK_TIMEOUT_SECONDS
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
} : {
|
|
277
|
+
command: args.scriptPath,
|
|
278
|
+
timeout: HOOK_TIMEOUT_SECONDS
|
|
279
|
+
};
|
|
280
|
+
hooksObj[args.eventName] = [
|
|
281
|
+
...kept,
|
|
282
|
+
fresh
|
|
283
|
+
];
|
|
284
|
+
settings.hooks = hooksObj;
|
|
285
|
+
await writeSettings(args.settingsPath, settings);
|
|
286
|
+
if (args.label.startsWith("Codex ")) {
|
|
287
|
+
await ensureCodexHooksFeature(path2.join(homedir2(), ".codex", "config.toml"));
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
stdout: `almanac: ${args.label} hook installed
|
|
291
|
+
script: ${args.scriptPath}
|
|
292
|
+
settings: ${args.settingsPath}
|
|
293
|
+
`,
|
|
294
|
+
stderr: "",
|
|
295
|
+
exitCode: 0
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function entryHasOurCommand(entry) {
|
|
299
|
+
return collectHookCommands(entry).some(isOurCommandPath);
|
|
300
|
+
}
|
|
301
|
+
function entryHasExactCommand(entry, command) {
|
|
302
|
+
return collectHookCommands(entry).some((candidate) => candidate === command);
|
|
303
|
+
}
|
|
304
|
+
function collectHookCommands(entry) {
|
|
305
|
+
if (entry === null || typeof entry !== "object") return [];
|
|
306
|
+
const obj = entry;
|
|
307
|
+
const direct = typeof obj.command === "string" ? [obj.command] : [];
|
|
308
|
+
const nested = Array.isArray(obj.hooks) ? obj.hooks.flatMap((hook) => collectHookCommands(hook)) : [];
|
|
309
|
+
return [...direct, ...nested];
|
|
310
|
+
}
|
|
311
|
+
async function ensureCodexHooksFeature(configPath) {
|
|
312
|
+
let body = "";
|
|
313
|
+
if (existsSync2(configPath)) {
|
|
314
|
+
body = await readFile2(configPath, "utf8");
|
|
315
|
+
}
|
|
316
|
+
if (/^\s*codex_hooks\s*=\s*true\s*$/m.test(body)) return;
|
|
317
|
+
const next = setTomlFeatureFlag(body, "codex_hooks", true);
|
|
318
|
+
await mkdir2(path2.dirname(configPath), { recursive: true });
|
|
319
|
+
const tmp = `${configPath}.almanac-tmp-${process.pid}`;
|
|
320
|
+
await writeFile(tmp, next.endsWith("\n") ? next : `${next}
|
|
321
|
+
`, "utf8");
|
|
322
|
+
await rename(tmp, configPath);
|
|
323
|
+
}
|
|
324
|
+
function setTomlFeatureFlag(body, key, value) {
|
|
325
|
+
const desired = `${key} = ${value ? "true" : "false"}`;
|
|
326
|
+
const lines = body.split(/\r?\n/);
|
|
327
|
+
let featuresStart = -1;
|
|
328
|
+
let featuresEnd = lines.length;
|
|
329
|
+
for (let i = 0; i < lines.length; i++) {
|
|
330
|
+
if (/^\s*\[features\]\s*$/.test(lines[i] ?? "")) {
|
|
331
|
+
featuresStart = i;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
if (featuresStart !== -1 && i > featuresStart && /^\s*\[.*\]\s*$/.test(lines[i] ?? "")) {
|
|
335
|
+
featuresEnd = i;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (featuresStart === -1) {
|
|
340
|
+
const prefix = body.trim().length === 0 ? "" : `${body.trimEnd()}
|
|
341
|
+
|
|
342
|
+
`;
|
|
343
|
+
return `${prefix}[features]
|
|
344
|
+
${desired}
|
|
345
|
+
`;
|
|
346
|
+
}
|
|
347
|
+
const keyPattern = new RegExp(`^\\s*${escapeRegex(key)}\\s*=`);
|
|
348
|
+
for (let i = featuresStart + 1; i < featuresEnd; i++) {
|
|
349
|
+
if (keyPattern.test(lines[i] ?? "")) {
|
|
350
|
+
lines[i] = desired;
|
|
351
|
+
return lines.join("\n");
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
lines.splice(featuresStart + 1, 0, desired);
|
|
355
|
+
return lines.join("\n");
|
|
356
|
+
}
|
|
357
|
+
function escapeRegex(value) {
|
|
358
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
359
|
+
}
|
|
203
360
|
async function runHookUninstall(options = {}) {
|
|
204
361
|
const settingsPath = resolveSettingsPath(options);
|
|
205
362
|
if (!existsSync2(settingsPath)) {
|
|
@@ -352,4 +509,4 @@ export {
|
|
|
352
509
|
runHookUninstall,
|
|
353
510
|
runHookStatus
|
|
354
511
|
};
|
|
355
|
-
//# sourceMappingURL=chunk-
|
|
512
|
+
//# sourceMappingURL=chunk-447U3GQJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/hook.ts","../src/commands/hook/script.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\n\nimport {\n copyToStableHooksDir,\n resolveHookScriptPath,\n resolveSettingsPath,\n type ScriptResolution,\n} from \"./hook/script.js\";\n\n/**\n * `almanac hook install|uninstall|status` — wires the bundled\n * `hooks/almanac-capture.sh` into `~/.claude/settings.json` as a\n * `SessionEnd` hook.\n *\n * Design notes:\n *\n * - **Schema.** Claude Code validates `settings.json` against a strict\n * schema: each entry in an event array (like `SessionEnd`) is a\n * `{matcher, hooks: [...]}` container, and the actual command objects\n * live in the nested `hooks` array. v0.1.0–v0.1.4 wrote command objects\n * directly at the event-array level; newer Claude Code versions now\n * reject that shape. We produce the wrapped form on install, and when\n * encountering a legacy unwrapped entry that we recognize as ours (by\n * `command` ending in `almanac-capture.sh`) we migrate it on next\n * install. `SessionEnd` never uses the `matcher` field to discriminate\n * anything — we always emit an empty `matcher: \"\"` (matches\n * everything, which is what session-end lifecycle hooks want).\n *\n * - **Idempotent.** `install` twice leaves one entry, not two. We match by\n * `command` string equality on the inner `hooks[]` entries. If the user\n * replaces our absolute path with a symlink pointing at the same\n * script, we'll treat it as foreign. That's acceptable; the `status`\n * output shows the path we'd use, so the user can reconcile manually.\n *\n * - **Refuse foreign entries.** If `SessionEnd` is already populated with\n * a command we don't recognize, we print the existing value and exit\n * non-zero. Claude Code lets users wire their own hooks (notifications,\n * git autocommit scripts, etc.) and silently replacing them would be\n * rude. Foreign wrapped containers that don't reference our script are\n * preserved byte-for-byte.\n *\n * - **Atomic write.** `settings.json` is small but heavily touched by\n * Claude Code. Writing via tmp-file + rename avoids corrupting the file\n * if we crash mid-write.\n *\n * - **Non-interactive.** No prompts, no confirmations. The caller is\n * already making an intentional choice by running `almanac hook\n * install`.\n */\n\nexport interface HookCommandOptions {\n /** Which agent app to install hooks for. Default keeps legacy Claude behavior. */\n source?: \"claude\" | \"codex\" | \"cursor\" | \"all\";\n /**\n * Override the hook script path. Production code leaves this undefined\n * and we resolve the bundled `hooks/almanac-capture.sh`. Tests pass a\n * fixture path to avoid depending on the runtime-install layout.\n */\n hookScriptPath?: string;\n /**\n * Override `~/.claude/settings.json`. Tests sandbox this to a tmpdir;\n * production code leaves it undefined.\n */\n settingsPath?: string;\n /**\n * Override the stable hooks directory where we copy the script.\n * Defaults to `~/.claude/hooks/`. Tests sandbox this to a tmpdir.\n *\n * Bug #1 fix: we always copy the bundled script to this stable path\n * before writing it into settings.json. This way the settings entry\n * points at a user-owned location that survives npm version bumps,\n * npx cache evictions, and nvm version switches — instead of an\n * ephemeral path inside ~/.npm/_npx/<sha>/... or the nvm-versioned\n * node_modules/.\n */\n stableHooksDir?: string;\n}\n\nexport interface HookCommandResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nconst HOOK_TIMEOUT_SECONDS = 10;\n\n/** A single command invocation inside a wrapper's `hooks[]` array. */\ninterface HookCommand {\n type: \"command\";\n command: string;\n timeout?: number;\n}\n\n/** A wrapped SessionEnd entry per Claude Code's schema. */\ninterface WrappedEntry {\n matcher: string;\n hooks: HookCommand[];\n}\n\n/**\n * What we read from `settings.hooks.SessionEnd`. During a read we may\n * encounter the legacy unwrapped shape (`HookCommand` directly) written\n * by v0.1.0–v0.1.4 — we recognize and migrate it. Unknown entries we\n * can't classify are preserved as-is via `unknown`.\n */\ntype RawEntry = WrappedEntry | HookCommand | unknown;\n\n/**\n * Claude Code's `settings.json` is a free-form JSON object; we only care\n * about the `hooks.SessionEnd` array. Preserve everything else verbatim\n * so we don't drop user settings when we write the file back.\n */\ntype SettingsJson = Record<string, unknown> & {\n hooks?: Record<string, RawEntry[] | undefined>;\n};\n\n/**\n * Heuristic: does this command path look like one we installed?\n *\n * We match on the filename `almanac-capture.sh` regardless of the parent\n * directory. This covers:\n * - the stable path: `~/.claude/hooks/almanac-capture.sh`\n * - legacy paths from v0.1.0–v0.1.5: inside the nvm node_modules or\n * npx cache\n * The stable path is what new installs produce; legacy paths are what\n * we migrate when the user runs `almanac hook install` again.\n */\nfunction isOurCommandPath(command: string): boolean {\n return command.endsWith(\"almanac-capture.sh\");\n}\n\n/**\n * Classify a raw SessionEnd entry. Wrapped entries are the canonical\n * shape; unwrapped-command entries are legacy output from v0.1.0–v0.1.4.\n * Anything else (random user JSON) is `unknown` and we leave it alone.\n */\ntype Classified =\n | { kind: \"wrapped\"; entry: WrappedEntry }\n | { kind: \"legacy\"; entry: HookCommand }\n | { kind: \"unknown\"; entry: unknown };\n\nfunction classifyEntry(raw: RawEntry): Classified {\n if (raw === null || typeof raw !== \"object\") {\n return { kind: \"unknown\", entry: raw };\n }\n const obj = raw as Record<string, unknown>;\n if (Array.isArray(obj.hooks)) {\n // Wrapped shape. `matcher` may be absent in hand-edited files; treat\n // absent as \"\" so we don't throw on slightly malformed input.\n const matcher = typeof obj.matcher === \"string\" ? obj.matcher : \"\";\n const hooks: HookCommand[] = [];\n for (const h of obj.hooks as unknown[]) {\n if (h !== null && typeof h === \"object\") {\n const ho = h as Record<string, unknown>;\n if (ho.type === \"command\" && typeof ho.command === \"string\") {\n const cmd: HookCommand = {\n type: \"command\",\n command: ho.command,\n };\n if (typeof ho.timeout === \"number\") cmd.timeout = ho.timeout;\n hooks.push(cmd);\n }\n }\n }\n return { kind: \"wrapped\", entry: { matcher, hooks } };\n }\n if (obj.type === \"command\" && typeof obj.command === \"string\") {\n // Legacy unwrapped shape — v0.1.0–v0.1.4 wrote this form.\n const cmd: HookCommand = {\n type: \"command\",\n command: obj.command as string,\n };\n if (typeof obj.timeout === \"number\") cmd.timeout = obj.timeout;\n return { kind: \"legacy\", entry: cmd };\n }\n return { kind: \"unknown\", entry: raw };\n}\n\n/** True when the entry references our script and is safely ours to manage. */\nfunction isOurWrapped(entry: WrappedEntry): boolean {\n return entry.hooks.some((h) => isOurCommandPath(h.command));\n}\n\nexport async function runHookInstall(\n options: HookCommandOptions = {},\n): Promise<HookCommandResult> {\n const bundled = resolveHookScriptPath(options);\n if (!bundled.ok) {\n return { stdout: \"\", stderr: `almanac: ${bundled.error}\\n`, exitCode: 1 };\n }\n\n // Copy the bundled hook script to a stable user-owned location before\n // writing that path into settings.json. This is the Bug #1 fix:\n //\n // OLD behavior: settings.json pointed at the bundled path (inside\n // ~/.nvm/versions/node/<ver>/lib/node_modules/codealmanac/hooks/... or\n // ~/.npm/_npx/<sha>/node_modules/codealmanac/hooks/...). When the user\n // switches Node versions or the npx cache is evicted, the path breaks\n // silently and captures stop firing.\n //\n // NEW behavior: we copy almanac-capture.sh to ~/.claude/hooks/ (same\n // directory Claude Code uses for its own built-in hooks, always present)\n // and point settings.json there. The stable path is independent of\n // Node version and npm cache state. When the user upgrades codealmanac,\n // `almanac hook install` copies a fresh script and updates settings.json\n // if the path changed.\n //\n // When `hookScriptPath` is explicitly provided (test injection), the\n // caller has already specified the destination path — skip the copy and\n // use that path directly. The stable-copy concern only applies to the\n // production flow where we resolved from the bundled package layout.\n const script: ScriptResolution = options.hookScriptPath !== undefined\n ? bundled // already the caller-provided path, no copy needed\n : await copyToStableHooksDir(bundled.path, options);\n if (!script.ok) {\n return { stdout: \"\", stderr: `almanac: ${script.error}\\n`, exitCode: 1 };\n }\n\n const source = options.source ?? \"claude\";\n if (source === \"all\") {\n const results = [\n await installClaudeHook(options, script.path),\n await installGenericHook({\n label: \"Codex Stop\",\n settingsPath: path.join(homedir(), \".codex\", \"hooks.json\"),\n eventName: \"Stop\",\n shape: \"wrapped\",\n scriptPath: script.path,\n }),\n await installGenericHook({\n label: \"Cursor sessionEnd\",\n settingsPath: path.join(homedir(), \".cursor\", \"hooks.json\"),\n eventName: \"sessionEnd\",\n shape: \"flat\",\n scriptPath: script.path,\n }),\n ];\n const failed = results.find((r) => r.exitCode !== 0);\n if (failed !== undefined) return failed;\n return {\n stdout: results.map((r) => r.stdout.trimEnd()).join(\"\\n\") + \"\\n\",\n stderr: \"\",\n exitCode: 0,\n };\n }\n if (source === \"codex\") {\n return await installGenericHook({\n label: \"Codex Stop\",\n settingsPath: path.join(homedir(), \".codex\", \"hooks.json\"),\n eventName: \"Stop\",\n shape: \"wrapped\",\n scriptPath: script.path,\n });\n }\n if (source === \"cursor\") {\n return await installGenericHook({\n label: \"Cursor sessionEnd\",\n settingsPath: path.join(homedir(), \".cursor\", \"hooks.json\"),\n eventName: \"sessionEnd\",\n shape: \"flat\",\n scriptPath: script.path,\n });\n }\n\n return await installClaudeHook(options, script.path);\n}\n\nasync function installClaudeHook(\n options: HookCommandOptions,\n scriptPath: string,\n): Promise<HookCommandResult> {\n\n const settingsPath = resolveSettingsPath(options);\n const settings = await readSettings(settingsPath);\n const existing = (settings.hooks?.SessionEnd ?? []).slice();\n\n // Walk existing entries and split them into buckets:\n // - `preserved` — foreign wrapped/unknown entries we leave alone.\n // - `oursAlready` — a wrapped entry that already points at OUR exact\n // script path (makes install a no-op).\n // - `oursStale` — a wrapped or legacy entry that references our\n // capture script but at a different absolute path\n // (old install, `npm i` moved us) or in the legacy\n // unwrapped shape. We'll collapse these into a\n // single fresh entry at the new path.\n const preserved: RawEntry[] = [];\n let oursAlready: WrappedEntry | null = null;\n const staleCount = { n: 0 };\n\n for (const raw of existing) {\n const c = classifyEntry(raw);\n if (c.kind === \"wrapped\") {\n if (!isOurWrapped(c.entry)) {\n preserved.push(raw);\n continue;\n }\n // Entry belongs to us. Does it already point at the exact script\n // path? If every command in its `hooks[]` that looks like ours is\n // already at `script.path`, it's up to date.\n const exactMatch = c.entry.hooks.some(\n (h) => h.command === scriptPath,\n );\n if (exactMatch && oursAlready === null) {\n oursAlready = c.entry;\n } else {\n staleCount.n += 1;\n }\n } else if (c.kind === \"legacy\") {\n if (isOurCommandPath(c.entry.command)) {\n // Legacy unwrapped entry of ours — always migrate to wrapped.\n staleCount.n += 1;\n } else {\n // Foreign legacy entry (user had their own script before\n // settings.json required wrapping). Leave it alone.\n preserved.push(raw);\n }\n } else {\n // Unknown shape — we can't classify it. Preserve verbatim.\n preserved.push(raw);\n }\n }\n\n // If every non-ours entry is a foreign unwrapped command (not a\n // wrapped one) we refuse to touch the file — Claude Code's newer\n // schema will already reject such files, but surfacing it here lets\n // the user clean up before we stack our entry on top. Wrapped foreign\n // entries are fine to leave alongside ours.\n const foreignLegacy = preserved.filter((raw) => {\n const c = classifyEntry(raw);\n return c.kind === \"legacy\";\n });\n if (foreignLegacy.length > 0) {\n const lines = foreignLegacy\n .map((raw) => {\n const c = classifyEntry(raw);\n if (c.kind === \"legacy\") return ` - ${c.entry.command}`;\n return \" - <unrecognized>\";\n })\n .join(\"\\n\");\n return {\n stdout: \"\",\n stderr:\n `almanac: SessionEnd has a foreign legacy entry:\\n${lines}\\n` +\n `Remove or rewrap it manually in ${settingsPath} before installing.\\n`,\n exitCode: 1,\n };\n }\n\n if (oursAlready !== null && staleCount.n === 0) {\n return {\n stdout: `almanac: SessionEnd hook already installed at ${scriptPath}\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n }\n\n // Build the fresh wrapped entry and append to preserved foreign\n // entries. Stale entries of ours are dropped (we only ever want a\n // single active entry; multiple copies of the capture hook would\n // double-fire on session end).\n const fresh: WrappedEntry = {\n matcher: \"\",\n hooks: [\n {\n type: \"command\",\n command: scriptPath,\n timeout: HOOK_TIMEOUT_SECONDS,\n },\n ],\n };\n\n const newEntries: RawEntry[] = [...preserved, fresh];\n\n settings.hooks = { ...(settings.hooks ?? {}), SessionEnd: newEntries };\n await writeSettings(settingsPath, settings);\n\n return {\n stdout:\n `almanac: SessionEnd hook installed\\n` +\n ` script: ${scriptPath}\\n` +\n ` settings: ${settingsPath}\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n}\n\nasync function installGenericHook(args: {\n label: string;\n settingsPath: string;\n eventName: string;\n shape: \"flat\" | \"wrapped\";\n scriptPath: string;\n}): Promise<HookCommandResult> {\n const settings = await readSettings(args.settingsPath);\n const hooksObj =\n settings.hooks !== undefined &&\n settings.hooks !== null &&\n typeof settings.hooks === \"object\"\n ? settings.hooks\n : {};\n const existing = Array.isArray(hooksObj[args.eventName])\n ? (hooksObj[args.eventName] as RawEntry[])\n : [];\n const kept = existing.filter((entry) => !entryHasOurCommand(entry));\n const already = existing.some((entry) =>\n entryHasExactCommand(entry, args.scriptPath),\n );\n if (already && kept.length === existing.length - 1) {\n return {\n stdout: `almanac: ${args.label} hook already installed at ${args.scriptPath}\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n }\n const fresh =\n args.shape === \"wrapped\"\n ? {\n hooks: [\n {\n type: \"command\",\n command: args.scriptPath,\n timeout: HOOK_TIMEOUT_SECONDS,\n },\n ],\n }\n : {\n command: args.scriptPath,\n timeout: HOOK_TIMEOUT_SECONDS,\n };\n hooksObj[args.eventName] = [\n ...kept,\n fresh,\n ];\n settings.hooks = hooksObj;\n await writeSettings(args.settingsPath, settings);\n if (args.label.startsWith(\"Codex \")) {\n await ensureCodexHooksFeature(path.join(homedir(), \".codex\", \"config.toml\"));\n }\n return {\n stdout:\n `almanac: ${args.label} hook installed\\n` +\n ` script: ${args.scriptPath}\\n` +\n ` settings: ${args.settingsPath}\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n}\n\nfunction entryHasOurCommand(entry: unknown): boolean {\n return collectHookCommands(entry).some(isOurCommandPath);\n}\n\nfunction entryHasExactCommand(entry: unknown, command: string): boolean {\n return collectHookCommands(entry).some((candidate) => candidate === command);\n}\n\nfunction collectHookCommands(entry: unknown): string[] {\n if (entry === null || typeof entry !== \"object\") return [];\n const obj = entry as Record<string, unknown>;\n const direct = typeof obj.command === \"string\" ? [obj.command] : [];\n const nested = Array.isArray(obj.hooks)\n ? obj.hooks.flatMap((hook) => collectHookCommands(hook))\n : [];\n return [...direct, ...nested];\n}\n\nasync function ensureCodexHooksFeature(configPath: string): Promise<void> {\n let body = \"\";\n if (existsSync(configPath)) {\n body = await readFile(configPath, \"utf8\");\n }\n if (/^\\s*codex_hooks\\s*=\\s*true\\s*$/m.test(body)) return;\n\n const next = setTomlFeatureFlag(body, \"codex_hooks\", true);\n await mkdir(path.dirname(configPath), { recursive: true });\n const tmp = `${configPath}.almanac-tmp-${process.pid}`;\n await writeFile(tmp, next.endsWith(\"\\n\") ? next : `${next}\\n`, \"utf8\");\n await rename(tmp, configPath);\n}\n\nfunction setTomlFeatureFlag(\n body: string,\n key: string,\n value: boolean,\n): string {\n const desired = `${key} = ${value ? \"true\" : \"false\"}`;\n const lines = body.split(/\\r?\\n/);\n let featuresStart = -1;\n let featuresEnd = lines.length;\n\n for (let i = 0; i < lines.length; i++) {\n if (/^\\s*\\[features\\]\\s*$/.test(lines[i] ?? \"\")) {\n featuresStart = i;\n continue;\n }\n if (featuresStart !== -1 && i > featuresStart && /^\\s*\\[.*\\]\\s*$/.test(lines[i] ?? \"\")) {\n featuresEnd = i;\n break;\n }\n }\n\n if (featuresStart === -1) {\n const prefix = body.trim().length === 0 ? \"\" : `${body.trimEnd()}\\n\\n`;\n return `${prefix}[features]\\n${desired}\\n`;\n }\n\n const keyPattern = new RegExp(`^\\\\s*${escapeRegex(key)}\\\\s*=`);\n for (let i = featuresStart + 1; i < featuresEnd; i++) {\n if (keyPattern.test(lines[i] ?? \"\")) {\n lines[i] = desired;\n return lines.join(\"\\n\");\n }\n }\n\n lines.splice(featuresStart + 1, 0, desired);\n return lines.join(\"\\n\");\n}\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport async function runHookUninstall(\n options: HookCommandOptions = {},\n): Promise<HookCommandResult> {\n const settingsPath = resolveSettingsPath(options);\n\n if (!existsSync(settingsPath)) {\n return {\n stdout: `almanac: SessionEnd hook not installed (no settings file)\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n }\n\n const settings = await readSettings(settingsPath);\n const existing = (settings.hooks?.SessionEnd ?? []).slice();\n\n const kept: RawEntry[] = [];\n let removed = 0;\n\n for (const raw of existing) {\n const c = classifyEntry(raw);\n if (c.kind === \"wrapped\") {\n // Filter out our command(s) from the inner hooks array. Keep\n // anything else in the array intact — a foreign wrapper that\n // happened to include our script alongside its own commands\n // (unusual, but survivable) loses our entry and keeps theirs.\n const innerKept = c.entry.hooks.filter(\n (h) => !isOurCommandPath(h.command),\n );\n const innerRemoved = c.entry.hooks.length - innerKept.length;\n removed += innerRemoved;\n if (innerKept.length === 0) {\n // Only drop the outer wrapper when it was entirely ours. A\n // foreign wrapper that never contained our script stays verbatim\n // below (handled by `innerRemoved === 0`, which leaves\n // `innerKept.length === c.entry.hooks.length`, hence we fall\n // through to the else-branch).\n if (innerRemoved === 0) kept.push(raw);\n // else: fully owned by us, drop the container.\n } else if (innerRemoved === 0) {\n // Untouched foreign wrapper — preserve the raw object to keep\n // any fields (like matcher) byte-for-byte.\n kept.push(raw);\n } else {\n // Partial: rebuild with just the kept inner entries, preserving\n // the original matcher string.\n kept.push({ matcher: c.entry.matcher, hooks: innerKept });\n }\n } else if (c.kind === \"legacy\") {\n if (isOurCommandPath(c.entry.command)) {\n removed += 1;\n } else {\n kept.push(raw);\n }\n } else {\n kept.push(raw);\n }\n }\n\n if (removed === 0) {\n return {\n stdout: `almanac: SessionEnd hook not installed\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n }\n\n if (settings.hooks !== undefined) {\n if (kept.length === 0) {\n // Empty SessionEnd array confuses some linters; drop the key when\n // nothing's left.\n const { SessionEnd: _dropped, ...rest } = settings.hooks;\n void _dropped;\n settings.hooks = rest;\n } else {\n settings.hooks = { ...settings.hooks, SessionEnd: kept };\n }\n\n // If `hooks` itself is now empty (user had only our SessionEnd entry\n // and no other hook categories), drop the `hooks` key entirely so\n // uninstall leaves the settings file in the same shape it would be\n // in had we never run install. An empty `\"hooks\": {}` is an obvious\n // breadcrumb in commit diffs.\n if (Object.keys(settings.hooks).length === 0) {\n delete settings.hooks;\n }\n }\n\n await writeSettings(settingsPath, settings);\n\n return {\n stdout: `almanac: SessionEnd hook removed\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n}\n\nexport async function runHookStatus(\n options: HookCommandOptions = {},\n): Promise<HookCommandResult> {\n const script = resolveHookScriptPath(options);\n const settingsPath = resolveSettingsPath(options);\n\n if (!existsSync(settingsPath)) {\n return {\n stdout:\n `SessionEnd hook: not installed\\n` +\n `settings: ${settingsPath} (does not exist)\\n` +\n (script.ok ? `script would be: ${script.path}\\n` : \"\"),\n stderr: \"\",\n exitCode: 0,\n };\n }\n\n const settings = await readSettings(settingsPath);\n const existing = settings.hooks?.SessionEnd ?? [];\n\n // Walk the array looking for any entry (wrapped or legacy) that\n // references our capture script. Gathering foreign entries separately\n // lets us show them to the user if nothing of ours was found.\n let ourCommand: string | null = null;\n const foreignSummary: string[] = [];\n for (const raw of existing) {\n const c = classifyEntry(raw);\n if (c.kind === \"wrapped\") {\n for (const h of c.entry.hooks) {\n if (isOurCommandPath(h.command)) {\n ourCommand ??= h.command;\n } else {\n foreignSummary.push(h.command);\n }\n }\n } else if (c.kind === \"legacy\") {\n if (isOurCommandPath(c.entry.command)) {\n ourCommand ??= c.entry.command;\n } else {\n foreignSummary.push(c.entry.command);\n }\n }\n }\n\n if (ourCommand === null) {\n const foreignLines = foreignSummary\n .map((c) => ` - ${c}`)\n .join(\"\\n\");\n return {\n stdout:\n `SessionEnd hook: not installed\\n` +\n `settings: ${settingsPath}\\n` +\n (foreignSummary.length > 0\n ? `(${foreignSummary.length} foreign entr${foreignSummary.length === 1 ? \"y\" : \"ies\"} present:\\n${foreignLines})\\n`\n : \"\") +\n (script.ok ? `script would be: ${script.path}\\n` : \"\"),\n stderr: \"\",\n exitCode: 0,\n };\n }\n\n return {\n stdout:\n `SessionEnd hook: installed\\n` +\n `script: ${ourCommand}\\n` +\n `settings: ${settingsPath}\\n`,\n stderr: \"\",\n exitCode: 0,\n };\n}\n\n// ─── Settings JSON helpers ───────────────────────────────────────────\n\nasync function readSettings(settingsPath: string): Promise<SettingsJson> {\n if (!existsSync(settingsPath)) return {};\n try {\n const raw = await readFile(settingsPath, \"utf8\");\n if (raw.trim().length === 0) return {};\n const parsed = JSON.parse(raw) as unknown;\n if (parsed === null || typeof parsed !== \"object\") return {};\n return parsed as SettingsJson;\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`failed to read ${settingsPath}: ${msg}`);\n }\n}\n\nasync function writeSettings(\n settingsPath: string,\n settings: SettingsJson,\n): Promise<void> {\n const dir = path.dirname(settingsPath);\n await mkdir(dir, { recursive: true });\n\n // Atomic write: JSON.stringify → tmp file → rename. `rename` within the\n // same filesystem is atomic on POSIX; Claude Code never sees a partial\n // file. Formatted with 2-space indent to match the existing settings.\n const tmp = `${settingsPath}.almanac-tmp-${process.pid}`;\n const body = `${JSON.stringify(settings, null, 2)}\\n`;\n await writeFile(tmp, body, \"utf8\");\n await rename(tmp, settingsPath);\n}\n","import { existsSync } from \"node:fs\";\nimport { copyFile, mkdir, readFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface HookPathOptions {\n hookScriptPath?: string;\n settingsPath?: string;\n stableHooksDir?: string;\n}\n\nexport type ScriptResolution =\n | { ok: true; path: string }\n | { ok: false; error: string };\n\nexport function resolveSettingsPath(options: HookPathOptions): string {\n if (options.settingsPath !== undefined) return options.settingsPath;\n return path.join(homedir(), \".claude\", \"settings.json\");\n}\n\n/**\n * Copy the bundled hook script to `~/.claude/hooks/almanac-capture.sh`.\n *\n * This stable, user-owned destination survives Node version switches and\n * npm/npx cache evictions. The copy is idempotent: if bytes already match\n * we skip writing so repeated setup runs do not bump mtimes.\n */\nexport async function copyToStableHooksDir(\n bundledPath: string,\n options: HookPathOptions,\n): Promise<ScriptResolution> {\n const stableHooksDir =\n options.stableHooksDir ?? path.join(homedir(), \".claude\", \"hooks\");\n const dest = path.join(stableHooksDir, \"almanac-capture.sh\");\n\n try {\n await mkdir(stableHooksDir, { recursive: true });\n const srcBytes = await readFile(bundledPath);\n let needsCopy = true;\n if (existsSync(dest)) {\n try {\n const destBytes = await readFile(dest);\n if (srcBytes.equals(destBytes)) needsCopy = false;\n } catch {\n // Can't read dest — overwrite.\n }\n }\n if (needsCopy) {\n await copyFile(bundledPath, dest);\n }\n return { ok: true, path: dest };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n ok: false,\n error: `could not copy hook script to ${dest}: ${msg}`,\n };\n }\n}\n\n/**\n * Locate the bundled `hooks/almanac-capture.sh`. Mirrors\n * `resolvePromptsDir` from `src/agent/prompts.ts`: two plausible layouts\n * (installed dist vs. source dev), probe each.\n */\nexport function resolveHookScriptPath(\n options: HookPathOptions,\n): ScriptResolution {\n if (options.hookScriptPath !== undefined) {\n return { ok: true, path: options.hookScriptPath };\n }\n\n const here = path.dirname(fileURLToPath(import.meta.url));\n\n const candidates = [\n // Bundled: `.../codealmanac/dist/codealmanac.js` → `../hooks/…`\n path.resolve(here, \"..\", \"hooks\", \"almanac-capture.sh\"),\n // Source after ts-node-style module layout or nested dist helpers.\n path.resolve(here, \"..\", \"..\", \"hooks\", \"almanac-capture.sh\"),\n // Source: `.../codealmanac/src/commands/hook/script.ts` → `../../../hooks/…`\n path.resolve(here, \"..\", \"..\", \"..\", \"hooks\", \"almanac-capture.sh\"),\n // Defensive nested fallback.\n path.resolve(here, \"..\", \"..\", \"..\", \"..\", \"hooks\", \"almanac-capture.sh\"),\n ];\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return { ok: true, path: candidate };\n }\n }\n\n return {\n ok: false,\n error:\n `could not locate hooks/almanac-capture.sh. Tried:\\n` +\n candidates.map((c) => ` - ${c}`).join(\"\\n\"),\n };\n}\n"],"mappings":";;;AAAA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,SAAAC,QAAO,YAAAC,WAAU,QAAQ,iBAAiB;AACnD,SAAS,WAAAC,gBAAe;AACxB,OAAOC,WAAU;;;ACHjB,SAAS,kBAAkB;AAC3B,SAAS,UAAU,OAAO,gBAAgB;AAC1C,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAYvB,SAAS,oBAAoB,SAAkC;AACpE,MAAI,QAAQ,iBAAiB,OAAW,QAAO,QAAQ;AACvD,SAAO,KAAK,KAAK,QAAQ,GAAG,WAAW,eAAe;AACxD;AASA,eAAsB,qBACpB,aACA,SAC2B;AAC3B,QAAM,iBACJ,QAAQ,kBAAkB,KAAK,KAAK,QAAQ,GAAG,WAAW,OAAO;AACnE,QAAM,OAAO,KAAK,KAAK,gBAAgB,oBAAoB;AAE3D,MAAI;AACF,UAAM,MAAM,gBAAgB,EAAE,WAAW,KAAK,CAAC;AAC/C,UAAM,WAAW,MAAM,SAAS,WAAW;AAC3C,QAAI,YAAY;AAChB,QAAI,WAAW,IAAI,GAAG;AACpB,UAAI;AACF,cAAM,YAAY,MAAM,SAAS,IAAI;AACrC,YAAI,SAAS,OAAO,SAAS,EAAG,aAAY;AAAA,MAC9C,QAAQ;AAAA,MAER;AAAA,IACF;AACA,QAAI,WAAW;AACb,YAAM,SAAS,aAAa,IAAI;AAAA,IAClC;AACA,WAAO,EAAE,IAAI,MAAM,MAAM,KAAK;AAAA,EAChC,SAAS,KAAc;AACrB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,OAAO,iCAAiC,IAAI,KAAK,GAAG;AAAA,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@@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
readStateForDoctor
|
|
4
|
+
} from "./chunk-V3QOQSXI.js";
|
|
2
5
|
import {
|
|
3
6
|
formatDuration
|
|
4
7
|
} from "./chunk-4CODZRHH.js";
|
|
5
|
-
import {
|
|
6
|
-
readStateForDoctor
|
|
7
|
-
} from "./chunk-QHQ6YH7U.js";
|
|
8
8
|
import {
|
|
9
9
|
BLUE,
|
|
10
10
|
BOLD,
|
|
@@ -14,13 +14,17 @@ import {
|
|
|
14
14
|
RST
|
|
15
15
|
} from "./chunk-FM3VRDK7.js";
|
|
16
16
|
import {
|
|
17
|
-
IMPORT_LINE
|
|
17
|
+
IMPORT_LINE
|
|
18
|
+
} from "./chunk-ZDJSJIB6.js";
|
|
19
|
+
import {
|
|
18
20
|
checkClaudeAuth
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SSYMRT4I.js";
|
|
22
|
+
import {
|
|
23
|
+
isNewer
|
|
24
|
+
} from "./chunk-F53U6JQG.js";
|
|
20
25
|
import {
|
|
21
|
-
isNewer,
|
|
22
26
|
readConfig
|
|
23
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-WRUSDYYE.js";
|
|
24
28
|
|
|
25
29
|
// src/commands/doctor-checks/format.ts
|
|
26
30
|
function formatReport(report, options) {
|
|
@@ -438,4 +442,4 @@ async function safeGatherWikiChecks(options) {
|
|
|
438
442
|
export {
|
|
439
443
|
runDoctor
|
|
440
444
|
};
|
|
441
|
-
//# sourceMappingURL=chunk-
|
|
445
|
+
//# sourceMappingURL=chunk-D3B2EEHL.js.map
|