project-cypher 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/bin/cypher.js +6 -1
  2. package/package.json +1 -1
package/bin/cypher.js CHANGED
@@ -111,14 +111,19 @@ const cmds = {
111
111
  const ws = new WebSocket(`${wsOf(c.server)}/agent?token=${encodeURIComponent(c.token)}`);
112
112
  const tx = m => ws.readyState === 1 && ws.send(JSON.stringify(m));
113
113
  ws.on('open', () => { ws.opened = true; retry = 1000; tx({ type: 'hello', name: os.hostname(), projects: c.projects.map(({ id, name }) => ({ id, name })) }); console.log(`connected as ${os.hostname()} with ${c.projects.length} project(s). Ctrl+C to stop.`); });
114
+ // pick up `cypher add` / `remove` while running: re-announce projects when the config changes
115
+ let sig = JSON.stringify(load().projects.map(p => p.id));
116
+ const watch = setInterval(() => { const n = JSON.stringify(load().projects.map(p => p.id)); if (n !== sig) { sig = n; const ps = load().projects; tx({ type: 'hello', name: os.hostname(), projects: ps.map(({ id, name }) => ({ id, name })) }); console.log(`projects updated: ${ps.length}`); } }, 2000);
117
+ ws.on('close', () => clearInterval(watch));
114
118
  ws.on('message', raw => {
115
119
  let m; try { m = JSON.parse(raw); } catch { return; }
116
- const proj = c.projects.find(p => p.id === m.projectId); const ctx = { reqId: m.reqId, projectId: m.projectId };
120
+ const proj = load().projects.find(p => p.id === m.projectId); const ctx = { reqId: m.reqId, projectId: m.projectId };
117
121
  if (m.type === 'stop') return runs.get(m.projectId)?.kill('SIGINT');
118
122
  if (m.type !== 'prompt') return;
119
123
  if (!proj) return tx({ ...ctx, type: 'error', message: 'unknown project' });
120
124
  if (runs.has(proj.id)) return tx({ ...ctx, type: 'error', message: 'Claude is still working on this project.' });
121
125
  const cfg = load(); const args = ['-p', m.text, '--output-format', 'stream-json', '--verbose', '--permission-mode', cfg.permissionMode || 'acceptEdits'];
126
+ if (typeof m.model === 'string' && /^[a-z][a-z0-9.\-\[\]]{0,60}$/i.test(m.model) && m.model !== 'default') args.push('--model', m.model);
122
127
  if (cfg.sessions?.[proj.id]) args.push('--resume', cfg.sessions[proj.id]);
123
128
  console.log(`[${proj.id}] ${m.text.slice(0, 60)}`);
124
129
  const ch = spawn('claude', args, { cwd: proj.path, stdio: ['ignore', 'pipe', 'pipe'] }); runs.set(proj.id, ch);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-cypher",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Connect your machine's Claude Code projects to the Project Cypher phone app.",
5
5
  "bin": {
6
6
  "cypher": "bin/cypher.js"