clavarium 0.2.14 → 0.2.15

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.
@@ -26,4 +26,10 @@ if [ -f "$chat/server.mjs" ] && ! grep -q "\"$chat/server.mjs\"" "$HOME/.claude.
26
26
  claude mcp add --scope user parley -- node "$chat/server.mjs" --dir "$chat" >/dev/null 2>&1 \
27
27
  || echo "launch: Parley was not given to Claude Code as tools: the command parley still works" >&2
28
28
  fi
29
+ # ITS PULSE: Claude Code's own hooks say to the chat that it acts, and when its turn ends, so that
30
+ # the person sees "Working..." while it works without a word (parley pulse; nothing posted).
31
+ if [ -f "$chat/server.mjs" ]; then
32
+ node "$(dirname "$0")/claude-pulse.mjs" "$chat" \
33
+ || echo "launch: the chat will not say when Claude Code works without a word" >&2
34
+ fi
29
35
  exec "$@"
@@ -0,0 +1,43 @@
1
+ /* claude-pulse CHAT: Claude Code's hooks tell the chat CHAT (a Parley folder)
2
+ * that the agent acts -- before each tool it uses, and when it is woken --
3
+ * and when its turn ends or it waits for the person, so that the person sees "Working..." while it works
4
+ * without a word. Written in ~/.claude/settings.json among the hooks already
5
+ * there, which are kept; ours are known by their command and written again.
6
+ * Written only when it changes, readable by its owner alone. A file that is
7
+ * not a JSON object is not touched (exit 3), like json-set.
8
+ *
9
+ * The hooks print nothing and never fail: a hook's output may reach the
10
+ * agent, and a failing one may stop it.
11
+ */
12
+ import { readFileSync, writeFileSync, mkdirSync, renameSync } from 'node:fs';
13
+ import { dirname, join, isAbsolute } from 'node:path';
14
+ import { homedir } from 'node:os';
15
+
16
+ const [chat] = process.argv.slice(2);
17
+ if (!chat || !isAbsolute(chat) || !/^[A-Za-z0-9._/-]+$/.test(chat)) { console.error('usage: claude-pulse <the chat folder, a whole path>'); process.exit(64); }
18
+ const ours = (end) => `parley pulse${end ? ' --end' : ''} --dir ${chat} >/dev/null 2>&1 || true`;
19
+ /* Notification: it asks the person in its terminal (leave to act), or waits for them: not working. */
20
+ const WANTED = { PreToolUse: ours(false), UserPromptSubmit: ours(false), Stop: ours(true), Notification: ours(true) };
21
+ const isOurs = (h) => typeof h?.command === 'string' && /^parley pulse\b/.test(h.command);
22
+
23
+ const at = join(homedir(), '.claude', 'settings.json');
24
+ let data = {};
25
+ try { data = JSON.parse(readFileSync(at, 'utf8')); } catch (error) {
26
+ if (error.code !== 'ENOENT') { console.error('claude-pulse: .claude/settings.json is not JSON: left as it is'); process.exit(3); }
27
+ }
28
+ if (!data || typeof data !== 'object' || Array.isArray(data)) { console.error('claude-pulse: .claude/settings.json is not a JSON object: left as it is'); process.exit(3); }
29
+ if (data.hooks !== undefined && (!data.hooks || typeof data.hooks !== 'object' || Array.isArray(data.hooks))) { console.error('claude-pulse: its hooks are not an object: left as they are'); process.exit(3); }
30
+ const was = JSON.stringify(data);
31
+ const hooks = { ...(data.hooks ?? {}) };
32
+ for (const [event, command] of Object.entries(WANTED)) {
33
+ const groups = Array.isArray(hooks[event]) ? hooks[event] : [];
34
+ /* Every other hook kept; a group left empty by taking ours out goes. */
35
+ const others = groups.map((g) => (g && Array.isArray(g.hooks) ? { ...g, hooks: g.hooks.filter((h) => !isOurs(h)) } : g)).filter((g) => !(g && Array.isArray(g.hooks) && g.hooks.length === 0));
36
+ hooks[event] = [...others, { ...(event === 'PreToolUse' ? { matcher: '*' } : {}), hooks: [{ type: 'command', command }] }];
37
+ }
38
+ data.hooks = hooks;
39
+ if (JSON.stringify(data) !== was) {
40
+ mkdirSync(dirname(at), { recursive: true, mode: 0o700 });
41
+ writeFileSync(`${at}.new`, `${JSON.stringify(data, null, 2)}\n`, { mode: 0o600 });
42
+ renameSync(`${at}.new`, at);
43
+ }
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.14",
9
+ "version": "0.2.15",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
- "clavarium-parley": "0.10.3",
14
+ "clavarium-parley": "0.11.0",
15
15
  "mermaid": "11.17.2",
16
16
  "node-pty": "^1.1.0",
17
17
  "pdfjs-dist": "6.4.299",
@@ -686,9 +686,9 @@
686
686
  }
687
687
  },
688
688
  "node_modules/clavarium-parley": {
689
- "version": "0.10.3",
690
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.10.3.tgz",
691
- "integrity": "sha512-v3clCXTJqqttJiXid1vhcMQ2Ds9FqfwxhOg6z3drZCWXGTXMugw6mdRUuYS+QiN4YuVrBbIVJ0xctV/0NDPBjQ==",
689
+ "version": "0.11.0",
690
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.11.0.tgz",
691
+ "integrity": "sha512-r80L/JqPUVjyRQBCM/mfk2IqSgnB0F+TiiKEP7yiKh9zSsThiaCosAriPTNh2BSQc54LonSoI9iqiC8yVJ5gzQ==",
692
692
  "license": "MIT",
693
693
  "bin": {
694
694
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-parley": "0.10.3",
47
+ "clavarium-parley": "0.11.0",
48
48
  "mermaid": "11.17.2",
49
49
  "node-pty": "^1.1.0",
50
50
  "pdfjs-dist": "6.4.299",