delimit-cli 4.1.10 → 4.1.12

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.
@@ -295,10 +295,19 @@ function migrateToNestedFormat(hookGroup) {
295
295
  * 3. PreToolUse (Bash) + deploy patterns -> delimit security-audit
296
296
  */
297
297
  function installClaudeHooks(tool, hookConfig) {
298
+ // Write to global ~/.claude/settings.json
298
299
  const configPath = tool.configPath;
299
300
  const configDir = path.dirname(configPath);
300
301
  fs.mkdirSync(configDir, { recursive: true });
301
302
 
303
+ // Also write to project .claude/settings.json if the dir exists
304
+ const projectConfigDir = path.join(process.cwd(), '.claude');
305
+ const projectConfigPath = path.join(projectConfigDir, 'settings.json');
306
+ const writeTargets = [configPath];
307
+ if (fs.existsSync(projectConfigDir)) {
308
+ writeTargets.push(projectConfigPath);
309
+ }
310
+
302
311
  let config = {};
303
312
  if (fs.existsSync(configPath)) {
304
313
  try {
@@ -321,28 +330,73 @@ function installClaudeHooks(tool, hookConfig) {
321
330
  }
322
331
  const changes = [];
323
332
 
324
- // --- SessionStart hook (no condition) ---
325
- // Always update to latest version (reinstall-safe)
333
+ // --- SessionStart hook ---
334
+ // Write a standalone bash script so it works without npm in PATH
326
335
  if (hookConfig.session_start) {
336
+ const hooksDir = path.join(home, '.claude', 'hooks');
337
+ fs.mkdirSync(hooksDir, { recursive: true });
338
+ const hookScript = path.join(hooksDir, 'delimit');
339
+ const delimitHome = path.join(home, '.delimit');
340
+ fs.writeFileSync(hookScript, `#!/bin/bash
341
+ # Delimit SessionStart — generated by delimit-cli setup
342
+ DELIMIT_HOME="\${DELIMIT_HOME:-${delimitHome}}"
343
+ echo "=== Delimit Status ==="
344
+ # Governance
345
+ if [ -f "./delimit.yml" ] || [ -f "./.delimit/policies.yml" ]; then
346
+ echo "Governance: active | policy=project"
347
+ elif [ -f "$DELIMIT_HOME/delimit.yml" ]; then
348
+ echo "Governance: active | policy=user"
349
+ else
350
+ echo "Governance: not initialized -- run npx delimit-cli init"
351
+ fi
352
+ # Server + tools
353
+ SERVER="$DELIMIT_HOME/server/ai/server.py"
354
+ if [ -f "$SERVER" ]; then
355
+ TOOLS=$(grep -c '@mcp.tool' "$SERVER" 2>/dev/null || echo "0")
356
+ echo "Server: ready ($TOOLS tools)"
357
+ else
358
+ echo "Server: not installed -- run npx delimit-cli setup"
359
+ fi
360
+ # Hooks + audit
361
+ [ -f "${home}/.claude/settings.json" ] && grep -q '"hooks"' "${home}/.claude/settings.json" 2>/dev/null && HOOKS="enabled" || HOOKS="disabled"
362
+ [ -d "$DELIMIT_HOME/audit" ] && AUDIT="on" || AUDIT="off"
363
+ echo "Hooks: $HOOKS | Audit: $AUDIT"
364
+ # MCP
365
+ [ -f "${home}/.mcp.json" ] && grep -q "delimit" "${home}/.mcp.json" 2>/dev/null && echo "MCP: delimit registered" || echo "MCP: not registered"
366
+ # Models
367
+ MODELS=""
368
+ [ -n "$XAI_API_KEY" ] && MODELS="\${MODELS}Grok + "
369
+ [ -n "$GOOGLE_APPLICATION_CREDENTIALS" ] && MODELS="\${MODELS}Gemini + "
370
+ [ -n "$OPENAI_API_KEY" ] && MODELS="\${MODELS}Codex + "
371
+ [ -f "$DELIMIT_HOME/models.json" ] && MODELS=$(python3 -c "import json; d=json.load(open('$DELIMIT_HOME/models.json')); print(' + '.join(v.get('name',k) for k,v in d.items() if v.get('enabled')))" 2>/dev/null) || true
372
+ [ -n "$MODELS" ] && echo "Deliberation: \${MODELS% + }"
373
+ # Last session
374
+ SESSIONS="$DELIMIT_HOME/sessions"
375
+ if [ -d "$SESSIONS" ]; then
376
+ LATEST=$(ls -t "$SESSIONS"/session_*.json 2>/dev/null | head -1)
377
+ [ -n "$LATEST" ] && python3 -c "import json; d=json.load(open('$LATEST')); s=d.get('summary','')[:150]; print(f'Last session: {s}')" 2>/dev/null
378
+ fi
379
+ echo "=== Delimit Ready ==="
380
+ `);
381
+ fs.chmodSync(hookScript, '755');
382
+
327
383
  if (!config.hooks.SessionStart) {
328
384
  config.hooks.SessionStart = [];
329
385
  }
330
- const existing = findClaudeHookGroup(config.hooks.SessionStart, 'delimit-cli hook session-start');
331
- if (existing) {
332
- // Remove old entry so we can replace it
333
- const idx = config.hooks.SessionStart.indexOf(existing);
334
- if (idx >= 0) config.hooks.SessionStart.splice(idx, 1);
335
- }
336
- {
337
- config.hooks.SessionStart.push({
338
- matcher: '',
339
- hooks: [{
340
- type: 'command',
341
- command: `${npxCmd} hook session-start`,
342
- }],
343
- });
344
- changes.push('SessionStart');
345
- }
386
+ // Remove any old delimit hooks (both script and npm command variants)
387
+ config.hooks.SessionStart = config.hooks.SessionStart.filter(group => {
388
+ const cmds = (group.hooks || []).map(h => h.command || '');
389
+ return !cmds.some(c => c.includes('delimit'));
390
+ });
391
+ config.hooks.SessionStart.push({
392
+ matcher: '',
393
+ hooks: [{
394
+ type: 'command',
395
+ command: hookScript,
396
+ timeout: 10,
397
+ }],
398
+ });
399
+ changes.push('SessionStart');
346
400
  }
347
401
 
348
402
  // --- PreToolUse: pre-tool hook scoped to Edit/Write on spec files ---
@@ -454,7 +508,20 @@ function installClaudeHooks(tool, hookConfig) {
454
508
  }
455
509
  }
456
510
 
457
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
511
+ // Write hooks to all target settings files
512
+ const configJson = JSON.stringify(config, null, 2);
513
+ for (const target of writeTargets) {
514
+ try {
515
+ // For project settings, merge hooks into existing config
516
+ if (target !== configPath && fs.existsSync(target)) {
517
+ const existing = JSON.parse(fs.readFileSync(target, 'utf-8'));
518
+ existing.hooks = config.hooks;
519
+ fs.writeFileSync(target, JSON.stringify(existing, null, 2));
520
+ } else {
521
+ fs.writeFileSync(target, configJson);
522
+ }
523
+ } catch {}
524
+ }
458
525
  return changes;
459
526
  }
460
527
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "delimit-cli",
3
3
  "mcpName": "io.github.delimit-ai/delimit-mcp-server",
4
- "version": "4.1.10",
4
+ "version": "4.1.12",
5
5
  "description": "Unify Claude Code, Codex, Cursor, and Gemini CLI with persistent context, governance, and multi-model debate.",
6
6
  "main": "index.js",
7
7
  "files": [