({ api, project, port }: { api?: Pick<AtlasApi, 'repoInfo'>; project?: string; port: number })
| 8 | `python3 ~/Downloads/cbm-atlas-trace.py --install-claude --root ${shellWord(root)} --project ${shellWord(project)} --daemon-url ${shellWord(`http://127.0.0.1:${port}`)}`; |
| 9 | |
| 10 | export default function AgentSetup({ api, project, port }: { api?: Pick<AtlasApi, 'repoInfo'>; project?: string; port: number }) { |
| 11 | const [open, setOpen] = useState(false); |
| 12 | const [reading, setReading] = useState<{ project: string; root: string; error: string }>(); |
| 13 | const [copied, setCopied] = useState(''); |
| 14 | useEffect(() => { |
| 15 | if (!open || !api || !project) return; |
| 16 | let disposed = false; |
| 17 | setReading(undefined); setCopied(''); |
| 18 | void api.repoInfo(project).then(info => { |
| 19 | if (!disposed) setReading({ project, root: info.rootPath, error: info.rootPath ? '' : 'The daemon did not report this repository root.' }); |
| 20 | }).catch(error => { |
| 21 | if (!disposed) setReading({ project, root: '', error: error instanceof Error ? error.message : String(error) }); |
| 22 | }); |
| 23 | return () => { disposed = true; }; |
| 24 | }, [open, api, project]); |
| 25 | const current = reading?.project === project ? reading : undefined; |
| 26 | const command = current?.root && project ? agentInstallCommand(current.root, project, port) : ''; |
| 27 | const download = () => { |
| 28 | const url = URL.createObjectURL(new Blob([hookSource], { type: 'text/x-python;charset=utf-8' })); |
| 29 | const anchor = document.createElement('a'); anchor.href = url; anchor.download = 'cbm-atlas-trace.py'; |
| 30 | anchor.click(); setTimeout(() => URL.revokeObjectURL(url), 1000); |
| 31 | }; |
| 32 | return <details className="cbm-agent-setup" onToggle={event => setOpen(event.currentTarget.open)}> |
| 33 | <summary>Connect your agent</summary> |
| 34 | <p>Claude Code on macOS/Linux · Python 3 required. This installs a project-local PostToolUse hook. Connecting the browser only reads history; it does not configure your coding client.</p> |
| 35 | {!project || !api ? <p>Select an indexed project to generate its setup command.</p> : <> |
| 36 | <ol> |
| 37 | <li><button type="button" onClick={download}>Download hook</button> Save <code>cbm-atlas-trace.py</code> in Downloads, or adjust its path in the command below.</li> |
| 38 | <li>Review and run this command in your terminal. It copies the hook into <code>.claude/hooks/</code> and adds it to <code>.claude/settings.local.json</code>, preserving unrelated settings. Conflicting existing hooks are refused. |
| 39 | {current?.error ? <p role="alert">Setup unavailable: {current.error}</p> : command ? <> |
| 40 | <pre>{command}</pre><button type="button" onClick={() => { void navigator.clipboard.writeText(command).then(() => setCopied('Command copied')).catch(() => setCopied('Clipboard unavailable; select and copy the command.')); }}>Copy setup command</button> <span role="status">{copied}</span> |
| 41 | </> : <p>Reading the indexed repository root…</p>} |
| 42 | </li> |
| 43 | <li>Start a new Claude Code session in that repository and perform a tool call. Then choose <strong>Load recorded activity</strong> here. A new recorded event is the evidence that the hook reached this daemon.</li> |
| 44 | </ol> |
| 45 | <p>Destination: <code>http://127.0.0.1:{port}/api/agent-events</code> · Project: <code>{project}</code>. No bridge or extra listener. Pending events retry on the next tool call.</p> |
| 46 | </>} |
| 47 | <p>The hook records tool names, paths, timestamps, optional line spans and up to 180 characters of a command or search pattern. It records no file contents or tool results. Metadata stays in the local daemon; commands and paths can still contain sensitive information.</p> |
| 48 | <p>To remove it, delete only the entry referencing <code>cbm-atlas-trace.py</code> from this project's <code>PostToolUse</code> hooks. Other coding clients need their own event adapter; their activity is not inferred.</p> |
| 49 | </details>; |
| 50 | } |
nothing calls this directly
no test coverage detected