peppa/packages/runner/src/claude-config.ts
Асель 967f70ac09 Add runner: tmux sessions, Claude hook ingestion and watchdog
- startSession: trusts the workspace in ~/.claude.json, runs interactive
  claude in tmux with PEPPA_SESSION_ID, remain-on-exit for crash status
- answerAndDeliver: PM answers go into the terminal (permission menu keys,
  approval -> task status + instruction, free text via bracketed paste)
- peppa-hook: session-start/prompt/notification/stop/session-end update
  session status and raise PM questions; never fails the Claude session
- watchdog: detects dead panes, vanished sessions, stalls, usage limits;
  launchd agent under caffeinate (scripts/install-launchd.sh)
- CLI: peppa session start|list|send|attach|stop, peppa watchdog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:28:07 +05:00

23 lines
1005 B
TypeScript

import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
const CONFIG = process.env.PEPPA_CLAUDE_CONFIG ?? join(homedir(), ".claude.json");
/**
* Marks a workspace as trusted in ~/.claude.json. Without it Claude Code ignores the
* project's .claude/settings.json (permissions, hooks) and .mcp.json servers.
*/
export function trustWorkspace(dir: string): void {
const cfg = existsSync(CONFIG) ? (JSON.parse(readFileSync(CONFIG, "utf8")) as Record<string, any>) : {};
cfg.projects ??= {};
const p = (cfg.projects[dir] ??= {});
if (p.hasTrustDialogAccepted && p.hasCompletedProjectOnboarding) return;
p.hasTrustDialogAccepted = true;
p.hasCompletedProjectOnboarding = true;
p.enabledMcpjsonServers = Array.from(new Set([...(p.enabledMcpjsonServers ?? []), "peppa"]));
const tmp = `${CONFIG}.peppa-${process.pid}`;
writeFileSync(tmp, JSON.stringify(cfg, null, 2));
renameSync(tmp, CONFIG);
}