tycono 0.3.14 → 0.3.16

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tycono",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "Build an AI company. Watch them work.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -89,18 +89,18 @@ export function handleExecRequest(req: IncomingMessage, res: ServerResponse): vo
89
89
  return;
90
90
  }
91
91
 
92
- // ── /api/waves/:waveId/stop — Stop wave execution ──
92
+ // ── /api/waves/:waveId/stop — Interrupt supervisor (like Claude Code Esc) ──
93
93
  const stopMatch = url.match(/^\/api\/waves\/([^/]+)\/stop$/);
94
94
  if (method === 'POST' && stopMatch) {
95
95
  const waveId = stopMatch[1];
96
- supervisorHeartbeat.stop(waveId);
97
- // Also abort all running executions for this wave
98
- const waveSessions = listSessions().filter(s => s.waveId === waveId && s.status === 'active');
99
- let aborted = 0;
100
- for (const ses of waveSessions) {
101
- if (executionManager.abortSession(ses.id)) aborted++;
96
+ // Interrupt CEO supervisor only — children keep running naturally
97
+ // Wave stays alive for new directives (interrupt + redirect)
98
+ const state = supervisorHeartbeat.getState(waveId);
99
+ if (state?.supervisorSessionId) {
100
+ executionManager.abortSession(state.supervisorSessionId);
102
101
  }
103
- jsonResponse(res, 200, { ok: true, waveId, abortedSessions: aborted });
102
+ supervisorHeartbeat.stop(waveId);
103
+ jsonResponse(res, 200, { ok: true, waveId, interrupted: true });
104
104
  return;
105
105
  }
106
106
 
package/src/tui/app.tsx CHANGED
@@ -20,7 +20,7 @@ import { SetupWizard } from './components/SetupWizard';
20
20
  import { useApi } from './hooks/useApi';
21
21
  import { useSSE } from './hooks/useSSE';
22
22
  import { useCommand, type WaveInfo } from './hooks/useCommand';
23
- import { dispatchWave } from './api';
23
+ import { dispatchWave, stopWave } from './api';
24
24
  import type { ActiveSessionInfo, PresetSummary } from './api';
25
25
  import { buildOrgTree, flattenOrgRoleIds } from './store';
26
26
 
@@ -630,10 +630,15 @@ export const App: React.FC = () => {
630
630
  return;
631
631
  }
632
632
  if (mode === 'command' && key.tab) {
633
- // Clear terminal before Panel Mode (removes Command Mode scrollback)
634
633
  process.stdout.write('\x1b[2J\x1b[H');
635
634
  setMode('panel');
636
635
  }
636
+ // Esc in Command Mode → interrupt supervisor (like Claude Code)
637
+ if (mode === 'command' && key.escape && focusedWaveId && derivedWaveStatus === 'running') {
638
+ stopWave(focusedWaveId).then(() => {
639
+ addSystemMessage('\u23F9 Interrupted. Type to continue.', 'yellow');
640
+ }).catch(() => {});
641
+ }
637
642
  });
638
643
 
639
644
  // Loading state
@@ -100,6 +100,8 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
100
100
  const [termHeight, setTermHeight] = useState(process.stdout.rows || 30);
101
101
  const [rightTab, setRightTab] = useState<RightTab>('stream');
102
102
  const [docsIndex, setDocsIndex] = useState(0);
103
+ const [docsFilter, setDocsFilter] = useState<'all' | 'wave' | 'kb' | 'projects'>('all');
104
+ const [docsPreview, setDocsPreview] = useState(false); // true = file preview mode
103
105
 
104
106
  useEffect(() => {
105
107
  const fn = () => setTermHeight(process.stdout.rows || 30);
@@ -119,7 +121,10 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
119
121
 
120
122
  // Key handling
121
123
  useInput((input, key) => {
122
- if (key.escape) { onEscape(); return; }
124
+ if (key.escape) {
125
+ if (docsPreview) { setDocsPreview(false); return; }
126
+ onEscape(); return;
127
+ }
123
128
  if (input === 'h' || key.leftArrow) {
124
129
  const tabs: RightTab[] = ['stream', 'docs', 'info'];
125
130
  const idx = tabs.indexOf(rightTab);
@@ -145,18 +150,37 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
145
150
  }
146
151
  if (key.return) {
147
152
  if (rightTab === 'docs' && selectedDocPath) {
148
- try {
149
- const editor = process.env.EDITOR || 'vim';
150
- execSync(`${editor} "${selectedDocPath}"`, { stdio: 'inherit' });
151
- } catch { /* ignore */ }
153
+ if (docsPreview) {
154
+ // In preview open in vim
155
+ try {
156
+ const editor = process.env.EDITOR || 'vim';
157
+ execSync(`${editor} "${selectedDocPath}"`, { stdio: 'inherit' });
158
+ } catch { /* ignore */ }
159
+ setDocsPreview(false);
160
+ } else {
161
+ // In list → toggle preview
162
+ setDocsPreview(true);
163
+ }
164
+ return;
152
165
  } else {
153
166
  onSelect();
154
167
  }
155
168
  return;
156
169
  }
157
- // Wave switch 1-9
170
+ // Docs filter 1-4
171
+ if (rightTab === 'docs') {
172
+ const filters = ['all', 'wave', 'kb', 'projects'] as const;
173
+ const fi = parseInt(input, 10);
174
+ if (fi >= 1 && fi <= 4) {
175
+ setDocsFilter(filters[fi - 1]);
176
+ setDocsIndex(0);
177
+ setDocsPreview(false);
178
+ return;
179
+ }
180
+ }
181
+ // Wave switch 1-9 (not in docs filter mode)
158
182
  const num = parseInt(input, 10);
159
- if (num >= 1 && num <= 9 && num <= waves.length) {
183
+ if (rightTab !== 'docs' && num >= 1 && num <= 9 && num <= waves.length) {
160
184
  onFocusWave(waves[num - 1].waveId);
161
185
  }
162
186
  });
@@ -217,40 +241,91 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
217
241
  rightContentLines.push(`Sessions: ${waveSessionCount} Events: ${events.length}`);
218
242
  rightContentLines.push(`Stream: ${streamStatus}`);
219
243
  } else if (rightTab === 'docs') {
220
- // Docs: scan .md files with j/k scroll + Enter to open
244
+ // Docs: scan + filter + wave artifacts + preview
221
245
  try {
222
- const skip = new Set(['.git', 'node_modules', '.tycono', '.worktrees', 'dist', '.claude', '.obsidian']);
223
- const mdFiles: string[] = [];
224
- const mdPaths: string[] = []; // full paths for vim
246
+ const skipDirs = new Set(['.git', 'node_modules', '.tycono', '.worktrees', 'dist', '.claude', '.obsidian']);
247
+ const allMdFiles: Array<{ rel: string; full: string }> = [];
225
248
  const walk = (dir: string, depth: number) => {
226
- if (depth > 3 || mdFiles.length > 200) return;
249
+ if (depth > 3 || allMdFiles.length > 300) return;
227
250
  try {
228
251
  for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
229
- if (skip.has(e.name)) continue;
252
+ if (skipDirs.has(e.name)) continue;
230
253
  const full = path.join(dir, e.name);
231
254
  if (e.isDirectory()) walk(full, depth + 1);
232
255
  else if (e.name.endsWith('.md')) {
233
- mdFiles.push(full.replace(companyRoot + '/', ''));
234
- mdPaths.push(full);
256
+ allMdFiles.push({ rel: full.replace(companyRoot + '/', ''), full });
235
257
  }
236
258
  }
237
259
  } catch {}
238
260
  };
239
261
  walk(companyRoot, 0);
240
- mdFiles.sort();
241
- mdPaths.sort();
262
+ allMdFiles.sort((a, b) => a.rel.localeCompare(b.rel));
263
+
264
+ // Wave artifact files (from SSE events)
265
+ const waveFiles = new Set<string>();
266
+ for (const ev of events) {
267
+ if (ev.type === 'tool:start') {
268
+ const name = (ev.data.name as string) ?? '';
269
+ const inp = ev.data.input as Record<string, unknown> | undefined;
270
+ if (['Write', 'Edit', 'NotebookEdit'].includes(name) && inp?.file_path) {
271
+ waveFiles.add(String(inp.file_path));
272
+ }
273
+ }
274
+ }
275
+
276
+ // Apply filter
277
+ const filtered = allMdFiles.filter(f => {
278
+ if (docsFilter === 'wave') return waveFiles.has(f.full);
279
+ if (docsFilter === 'kb') return f.rel.startsWith('knowledge/');
280
+ if (docsFilter === 'projects') return f.rel.startsWith('projects/');
281
+ return true; // 'all'
282
+ });
283
+
284
+ // Sort: wave files first
285
+ filtered.sort((a, b) => {
286
+ const aw = waveFiles.has(a.full) ? 0 : 1;
287
+ const bw = waveFiles.has(b.full) ? 0 : 1;
288
+ if (aw !== bw) return aw - bw;
289
+ return a.rel.localeCompare(b.rel);
290
+ });
291
+
242
292
  // Cap docsIndex
243
- const cappedIdx = Math.min(docsIndex, mdFiles.length - 1);
244
- if (cappedIdx !== docsIndex) setDocsIndex(Math.max(0, cappedIdx));
245
- selectedDocPath = mdPaths[cappedIdx] ?? null;
246
-
247
- const maxVisible = Math.max(5, termHeight - 12);
248
- const scrollStart = Math.max(0, Math.min(cappedIdx - 3, mdFiles.length - maxVisible));
249
- rightContentLines.push(`${mdFiles.length} documents [j/k] browse [Enter] ${process.env.EDITOR || 'vim'}`);
250
- for (let i = scrollStart; i < Math.min(scrollStart + maxVisible, mdFiles.length); i++) {
251
- const selected = i === cappedIdx;
252
- const prefix = selected ? '\u25B6 ' : ' ';
253
- rightContentLines.push(`${prefix}${mdFiles[i].slice(0, rightWidth - 4)}`);
293
+ const cappedIdx = Math.min(docsIndex, Math.max(0, filtered.length - 1));
294
+ if (cappedIdx !== docsIndex) setDocsIndex(cappedIdx);
295
+ selectedDocPath = filtered[cappedIdx]?.full ?? null;
296
+
297
+ if (docsPreview && selectedDocPath) {
298
+ // === Preview mode ===
299
+ const previewLines: string[] = [];
300
+ try {
301
+ const content = fs.readFileSync(selectedDocPath, 'utf-8');
302
+ previewLines.push(...content.split('\n').slice(0, contentHeight - 3));
303
+ } catch { previewLines.push('(cannot read)'); }
304
+ const shortName = selectedDocPath.split('/').slice(-2).join('/');
305
+ rightContentLines.push(`${waveFiles.has(selectedDocPath) ? '\u2605 ' : ''}${shortName} [Esc] back [Enter] ${process.env.EDITOR || 'vim'}`);
306
+ rightContentLines.push('\u2500'.repeat(Math.min(50, rightWidth)));
307
+ for (const pl of previewLines) {
308
+ if (rightContentLines.length >= contentHeight) break;
309
+ rightContentLines.push(pl.slice(0, rightWidth));
310
+ }
311
+ } else {
312
+ // === List mode ===
313
+ const filterLabels = ['1:All', '2:\u2605Wave', '3:KB', '4:Projects'];
314
+ const filterBar = filterLabels.map((f, i) => {
315
+ const key = ['all', 'wave', 'kb', 'projects'][i];
316
+ return key === docsFilter ? `[${f}]` : ` ${f} `;
317
+ }).join(' ');
318
+ rightContentLines.push(`${filterBar} ${filtered.length} docs [j/k] browse [Enter] preview`);
319
+
320
+ const maxVisible = Math.max(5, contentHeight - 3);
321
+ const scrollStart = Math.max(0, Math.min(cappedIdx - 3, filtered.length - maxVisible));
322
+ for (let i = scrollStart; i < Math.min(scrollStart + maxVisible, filtered.length); i++) {
323
+ const selected = i === cappedIdx;
324
+ const isWave = waveFiles.has(filtered[i].full);
325
+ const prefix = selected ? '\u25B6 ' : ' ';
326
+ const star = isWave ? '\u2605' : ' ';
327
+ rightContentLines.push(`${prefix}${star} ${filtered[i].rel.slice(0, rightWidth - 6)}`);
328
+ }
254
329
  }
255
330
  } catch {
256
331
  rightContentLines.push('Cannot scan documents');
@@ -114,16 +114,16 @@ export function useCommand(options: UseCommandOptions) {
114
114
  return { type: 'sessions', message: '__sessions__' };
115
115
 
116
116
  case 'stop': {
117
- // Stop current wave execution
117
+ // Interrupt supervisor (like Esc) — wave stays alive for new directives
118
118
  const targetWaveId = args?.trim() || focusedWaveId;
119
119
  if (!targetWaveId) {
120
- return { type: 'error', message: 'No wave to stop. Use /stop or focus a wave first.' };
120
+ return { type: 'error', message: 'No wave focused. Use /stop or focus a wave first.' };
121
121
  }
122
122
  try {
123
- const result = await stopWave(targetWaveId);
124
- return { type: 'success', message: `Wave stopped. ${result.abortedSessions} sessions aborted.` };
123
+ await stopWave(targetWaveId);
124
+ return { type: 'success', message: '\u23F9 Interrupted. Type to continue.' };
125
125
  } catch (err) {
126
- return { type: 'error', message: `Stop failed: ${err instanceof Error ? err.message : 'unknown'}` };
126
+ return { type: 'error', message: `Interrupt failed: ${err instanceof Error ? err.message : 'unknown'}` };
127
127
  }
128
128
  }
129
129