tycono-server 0.1.0-beta.2 → 0.1.0-beta.4

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-server",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.4",
4
4
  "description": "Tycono AI team orchestration server. Dispatch, supervise, and observe AI agents working as a team.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -101,7 +101,8 @@ export function createHttpServer(): http.Server {
101
101
  const app = createExpressApp();
102
102
 
103
103
  const server = http.createServer((req, res) => {
104
- const url = req.url ?? '';
104
+ const rawUrl = req.url ?? '';
105
+ const url = rawUrl.split('?')[0]; // Strip query string for route matching
105
106
  const method = req.method ?? '';
106
107
 
107
108
  // GET /api/waves/active — restore active waves after refresh
@@ -150,8 +151,8 @@ export function createHttpServer(): http.Server {
150
151
  return;
151
152
  }
152
153
 
153
- // Non-SSE exec/jobs endpoints (GET, DELETE)
154
- if ((url.startsWith('/api/exec/') || url.startsWith('/api/jobs')) && (method === 'GET' || method === 'DELETE')) {
154
+ // Non-SSE exec/jobs/waves endpoints (GET, DELETE)
155
+ if ((url.startsWith('/api/exec/') || url.startsWith('/api/jobs') || url.startsWith('/api/waves/')) && (method === 'GET' || method === 'DELETE')) {
155
156
  setExecCors(req, res);
156
157
  handleExecRequest(req, res);
157
158
  return;
@@ -83,6 +83,17 @@ interface RawRoleYaml {
83
83
  };
84
84
  }
85
85
 
86
+ /* ─── Default Roles (fallback when no roles/ directory) ── */
87
+
88
+ const DEFAULT_ROLES: Array<{ id: string; name: string; level: 'c-level' | 'member'; reportsTo: string; persona: string }> = [
89
+ { id: 'cto', name: 'CTO', level: 'c-level', reportsTo: 'ceo', persona: 'Chief Technology Officer. Leads technical architecture and manages Engineer + QA.' },
90
+ { id: 'cbo', name: 'CBO', level: 'c-level', reportsTo: 'ceo', persona: 'Chief Business Officer. Leads product vision and manages PM + Designer.' },
91
+ { id: 'engineer', name: 'Engineer', level: 'member', reportsTo: 'cto', persona: 'Software Engineer. Writes working code.' },
92
+ { id: 'qa', name: 'QA', level: 'member', reportsTo: 'cto', persona: 'QA Engineer. Tests and validates.' },
93
+ { id: 'pm', name: 'PM', level: 'member', reportsTo: 'cbo', persona: 'Product Manager. Writes specs and requirements.' },
94
+ { id: 'designer', name: 'Designer', level: 'member', reportsTo: 'cbo', persona: 'UI/UX Designer.' },
95
+ ];
96
+
86
97
  /* ─── Build ──────────────────────────────────── */
87
98
 
88
99
  export function buildOrgTree(companyRoot: string, presetId?: string): OrgTree {
@@ -167,6 +178,27 @@ export function buildOrgTree(companyRoot: string, presetId?: string): OrgTree {
167
178
  }
168
179
  }
169
180
 
181
+ // Fallback: if no C-Level roles found, use built-in defaults
182
+ const hasCLevel = Array.from(tree.nodes.values()).some(
183
+ n => n.id !== 'ceo' && n.level === 'c-level'
184
+ );
185
+ if (!hasCLevel) {
186
+ for (const def of DEFAULT_ROLES) {
187
+ if (tree.nodes.has(def.id)) continue;
188
+ tree.nodes.set(def.id, {
189
+ id: def.id,
190
+ name: def.name,
191
+ level: def.level,
192
+ reportsTo: def.reportsTo,
193
+ children: [],
194
+ persona: def.persona,
195
+ authority: { autonomous: [], needsApproval: [] },
196
+ knowledge: { reads: [], writes: [] },
197
+ reports: { daily: '', weekly: '' },
198
+ });
199
+ }
200
+ }
201
+
170
202
  // Wire up children from reportsTo
171
203
  for (const [id, node] of tree.nodes) {
172
204
  if (id === 'ceo') continue;
@@ -126,6 +126,32 @@ export function handleExecRequest(req: IncomingMessage, res: ServerResponse): vo
126
126
  return;
127
127
  }
128
128
 
129
+ // ── GET /api/waves/:waveId — Single wave status ──
130
+ const waveDetailMatch = url.match(/^\/api\/waves\/([^/]+)$/);
131
+ if (method === 'GET' && waveDetailMatch) {
132
+ const waveId = waveDetailMatch[1];
133
+ // Try active waves first
134
+ const activeWaves = waveMultiplexer.getActiveWaves();
135
+ const active = activeWaves.find((w: { waveId: string }) => w.waveId === waveId);
136
+ if (active) {
137
+ jsonResponse(res, 200, active);
138
+ return;
139
+ }
140
+ // Fallback: read wave file from disk
141
+ const wavePath = path.join(COMPANY_ROOT, '.tycono', 'waves', `${waveId}.json`);
142
+ if (fs.existsSync(wavePath)) {
143
+ try {
144
+ const waveData = JSON.parse(fs.readFileSync(wavePath, 'utf-8'));
145
+ jsonResponse(res, 200, waveData);
146
+ } catch {
147
+ jsonResponse(res, 500, { error: 'Failed to read wave file' });
148
+ }
149
+ return;
150
+ }
151
+ jsonResponse(res, 404, { error: 'Wave not found' });
152
+ return;
153
+ }
154
+
129
155
  // ── Legacy /api/exec/* routes ──
130
156
  const sessionMatch = url.match(/\/api\/exec\/session\/([^/]+)\/message$/);
131
157
 
@@ -66,6 +66,16 @@ export function ensureClaudeMd(companyRoot: string): void {
66
66
  // Skip if already up-to-date
67
67
  if (storedVersion === currentVersion) return;
68
68
 
69
+ // Plugin mode: if CLAUDE.md exists but has no tycono:managed marker, don't touch it.
70
+ // This means the user (or plugin scaffold) owns CLAUDE.md — server should not overwrite.
71
+ if (fs.existsSync(claudeMdPath)) {
72
+ const existing = fs.readFileSync(claudeMdPath, 'utf-8');
73
+ if (!existing.includes('tycono:managed')) {
74
+ console.log(`[CLAUDE.md] Skipping — existing CLAUDE.md is not Tycono-managed`);
75
+ return;
76
+ }
77
+ }
78
+
69
79
  // Backup existing CLAUDE.md (first time only — don't overwrite previous backup)
70
80
  if (fs.existsSync(claudeMdPath) && !fs.existsSync(backupPath)) {
71
81
  fs.copyFileSync(claudeMdPath, backupPath);
@@ -300,14 +300,14 @@ class WaveMultiplexer {
300
300
  getActiveWaves(): Array<{
301
301
  id: string;
302
302
  directive: string;
303
- dispatches: Array<{ sessionId: string; roleId: string; roleName: string }>;
303
+ dispatches: Array<{ sessionId: string; roleId: string; roleName: string; status: string }>;
304
304
  startedAt: number;
305
305
  sessionIds: string[];
306
306
  }> {
307
307
  const result: Array<{
308
308
  id: string;
309
309
  directive: string;
310
- dispatches: Array<{ sessionId: string; roleId: string; roleName: string }>;
310
+ dispatches: Array<{ sessionId: string; roleId: string; roleName: string; status: string }>;
311
311
  startedAt: number;
312
312
  sessionIds: string[];
313
313
  }> = [];
@@ -316,12 +316,13 @@ class WaveMultiplexer {
316
316
  const hasActive = Array.from(sessions.values()).some(e => e.status === 'running' || e.status === 'awaiting_input');
317
317
  if (!hasActive) continue;
318
318
 
319
+ // Include ALL sessions (not just root) so plugin can show full team status
319
320
  const rootSessions = Array.from(sessions.values())
320
- .filter(e => !e.parentSessionId || !sessions.has(e.parentSessionId))
321
321
  .map(e => ({
322
322
  sessionId: e.sessionId,
323
323
  roleId: e.roleId,
324
324
  roleName: e.roleId.toUpperCase(),
325
+ status: e.status,
325
326
  }));
326
327
 
327
328
  const firstExec = rootSessions.length > 0
@@ -1,237 +1,150 @@
1
- # Company Rules
1
+ # Your Knowledge Base
2
2
 
3
- > Powered by [Tycono](https://tycono.ai) — AI Company Operating Platform
3
+ > Powered by [Tycono](https://tycono.ai)
4
4
 
5
5
  ---
6
6
 
7
- ## Task Routing
7
+ ## AKB Core Concept
8
8
 
9
- | Task | Read First | Role |
10
- |------|-----------|------|
11
- | Product planning | `projects/` | PM |
12
- | Technical design | `architecture/` | CTO |
13
- | Implementation | `projects/*/tasks.md` | Engineer |
14
- | UI/UX Design | `projects/*/design/` | Designer |
15
- | Testing/QA | `projects/*/tasks.md` | QA |
16
- | E2E Testing | `e2e-experiments/tui-e2e-testcases.md` | QA |
17
- | Operations | `marketing/` | PM |
18
- | Business/Revenue | `company.md` | CBO |
19
- | Domain knowledge | `knowledge.md` | CBO |
20
-
21
- ---
22
-
23
- ## AKB Core Concepts
24
-
25
- > **AKB** = A file-based knowledge system where AI uses **search (Grep/Glob)** to find and **contextual links** to navigate
26
- >
27
- > Full reference: `methodologies/agentic-knowledge-base.md`
9
+ > **AKB** = File-based knowledge system where AI finds via **Search (Grep/Glob)** and navigates via **Contextual Links**
28
10
 
29
11
  | Layer | Role | AI Usage |
30
12
  |-------|------|----------|
31
13
  | **Root** (CLAUDE.md) | Minimal routing | Auto-injected as system prompt |
32
- | **Hub** ({folder}.md) | TOC + tool/guide references | **Check before starting work** |
33
- | **Node** (*.md) | Actual information | Search directly via Grep/Glob |
14
+ | **Hub** ({folder}.md) | Human TOC + guides | **Check before starting work** |
15
+ | **Node** (*.md) | Actual information | Direct search via Grep/Glob |
34
16
 
35
17
  ---
36
18
 
37
- ## AI Work Rules
38
-
39
- ### The Loop (Work Cycle)
40
-
41
- Every task follows this cycle. Implementing without completing the cycle is only half the job.
42
-
43
- | Step | Action | Why |
44
- |------|--------|-----|
45
- | ① Knowledge | Check/research related docs | Without context, direction goes wrong |
46
- | ② Task | Define task from docs | Without requirements, you'll rework |
47
- | ③ Implement | Execute the actual work | Value creation |
48
- | ④ Knowledge Update | Update docs with new insights | Prevents knowledge decay |
49
- | ⑤ Task Update | Update task status, check next work | Ensures continuity |
50
-
51
- **C-Level**: Execute The Loop autonomously — decompose tasks, analyze dependencies, dispatch independent tasks in parallel, collect results.
52
- **Member**: After implementation, always complete steps ④ and ⑤.
19
+ ## AI Working Rules (CRITICAL)
53
20
 
54
21
  ### Hub-First Principle
55
22
 
56
- > ⛔ **Read the relevant Hub document before starting any work.**
23
+ > ⛔ **Read Hub document BEFORE implementing/testing**
24
+
25
+ Based on AKB observations, AI tends to skip Hubs and search directly.
26
+ But **Hubs contain existing tools/scripts/guides** - missing them causes redundant work.
57
27
 
58
- Check the Task Routing table above to find the right "Read First" path.
59
28
  Every folder has a Hub file (`{folder-name}.md`) as its entry point.
60
29
  Read the Hub's existing tools/scripts/guides before starting work.
61
30
 
62
- ### Skill Check Principle
31
+ ### Required Check Situations
63
32
 
64
- > **If `.claude/skills/{role-id}/SKILL.md` exists, you MUST read it.**
33
+ | Situation | Read First | What to Find |
34
+ |-----------|------------|--------------|
35
+ | Debugging/Testing | Hub → guides/ | Existing debug tools |
36
+ | API Calls | Hub → related Node | Documented methods |
37
+ | New Feature | Hub | Similar existing features |
38
+ | Strategy/Design | Hub + detail docs | Design philosophy, past decisions |
65
39
 
66
- Skill files define the tools, commands, and guides for each Role.
67
- Working without reading skills means missing existing tools and starting from scratch.
40
+ ### Correct Patterns
68
41
 
69
- ### Custom Rules (CRITICAL)
70
-
71
- > **Before starting work, check if `custom-rules.md` exists and read it.**
72
- > This file contains company-specific rules, constraints, and processes.
73
- > If the file doesn't exist, ignore this section.
74
-
75
- ### Git Rules
42
+ ```
43
+ ✅ Debugging
44
+ {domain}.md (Hub) guides/debugging.md
45
+ Use existing debug scripts
76
46
 
77
- - Source code changes: feature branch → PR → merge
78
- - Direct push to main is prohibited
47
+ Testing
48
+ {domain}.md (Hub) test utilities
79
49
 
80
- ### Knowledge Gate
50
+ API Integration
51
+ → api.md (Hub) → existing client libraries
52
+ ```
81
53
 
82
- > **Before creating a new document, search existing docs first.**
54
+ ### Anti-Patterns
83
55
 
84
56
  ```
85
- 1. Summarize the insight + 3-5 keywords
86
- 2. Search existing docs with those keywords (grep 3+ terms)
87
- 3. Decide:
88
- - Overlap 70%+ -> Add to existing document
89
- - Overlap 30-70% -> New doc + cross-link to existing
90
- - Overlap <30% -> New document (register in Hub)
91
- - Temporary info -> Journal only (no new doc)
92
- 4. Cross-link to related docs
93
- 5. Register in the relevant Hub
57
+ Skip Hub curl API directly
58
+ Skip Hub Write scripts from scratch
59
+ Skip Hub → Start with assumptions
94
60
  ```
95
61
 
96
- ### Document Hygiene
97
-
98
- | Rule | Description |
99
- |------|-------------|
100
- | No orphan docs | Every document must be reachable from a Hub |
101
- | Hub pattern | Each folder's entry point is `{folder}.md` |
102
- | Prefer existing | Adding 1 doc = maintenance cost. Strengthen existing > create new |
103
- | Cross-link | New docs must reference at least 1 related doc |
104
- | Source attribution | External research must cite source and date |
105
-
106
- ### Skills
107
-
108
- Roles have equipped **Skills** -- modular capability guides in `.claude/skills/`.
109
-
110
- - Role-specific skills: `.claude/skills/{role-id}/SKILL.md`
111
- - Shared skills: `.claude/skills/_shared/{skill-id}/SKILL.md`
112
- - Each Role's equipped skills are listed in `role.yaml` under `skills:`
113
- - **Always read SKILL.md before starting work** for that Role
62
+ ---
114
63
 
115
- ### Agent Dispatch Rules (CRITICAL)
64
+ ## Exploration Depth Principle
116
65
 
117
- > **Sub-agents (Agent/Task) do NOT automatically receive CLAUDE.md.**
118
- > **You MUST instruct them to read CLAUDE.md in the first line of the prompt.**
66
+ > **For strategy/idea questions, Hub alone is NOT enough. Explore detail docs.**
119
67
 
120
- Without the Root (CLAUDE.md), sub-agents skip Hubs and dive straight into code,
121
- missing existing tools, guides, and constraints.
68
+ AI tends to read a few Hubs and judge "sufficient".
69
+ But **strategic questions need specific context** - shallow exploration leads to superficial answers.
122
70
 
123
- #### Required Prompt Pattern
71
+ ### Exploration Depth by Question Type
124
72
 
125
- Every sub-agent prompt **must include**:
73
+ | Question Type | Minimum | Additional |
74
+ |---------------|---------|------------|
75
+ | Implementation | Hub | Related Nodes |
76
+ | Debugging/Testing | Hub → guides/ | Existing tools |
77
+ | **Strategy/Ideas** | Hub | **Design philosophy, core problems, phase docs** |
78
+ | **Connecting A and B** | **Both Hubs** | **Both core docs (design, business, phases)** |
126
79
 
127
- 1. Instruction to read CLAUDE.md
128
- 2. **Required skill file paths** for the Role
80
+ ### When Deep Exploration is Needed
129
81
 
130
82
  ```
131
- AKB Rule: Read CLAUDE.md before starting work.
132
- Find the relevant Hub from the "Task Routing" table and read it first.
133
- Check the Hub's existing tools/guides/constraints before exploring code.
134
- Read the required skill files below and use the tools/commands defined in them.
83
+ "How to connect System A and System B?"
84
+ system-a.md + system-b.md (both Hubs)
85
+ architecture.md (system design)
86
+ security-model.md (design philosophy)
87
+ → business-requirements.md (business context)
88
+
89
+ ✅ "Ideas for improving performance?"
90
+ → {domain}.md (Hub)
91
+ → performance-analysis.md (problem details, current approach)
92
+
93
+ ✅ "Apply this architecture to another domain?"
94
+ → architecture.md (Hub)
95
+ → design-philosophy.md (domain-independent principles)
135
96
  ```
136
97
 
137
- #### Role Skill Mapping
138
-
139
- | Role | Required Skills (path: `.claude/skills/{name}/SKILL.md`) |
140
- |------|--------------------------------------------------------|
141
- | Each Role | `{role-id}` + shared skills listed in `role.yaml` |
142
-
143
- > Check each Role's `role.yaml` `skills:` field for the exact list.
144
-
145
- ### Self-Verification Before Escalation (CRITICAL)
146
-
147
- > **Before saying "I can't" or "user action needed", check your own tools/skills first.**
148
-
149
- #### Checklist (before reporting inability)
98
+ ### Risks of Shallow Exploration
150
99
 
151
100
  ```
152
- 1. Check CLAUDE.md routing table for relevant skills/tools
153
- 2. Glob search .claude/skills/ for related skills
154
- 3. Read the skill and determine if it can solve the problem
155
- □ 4. Only if all above fail → Report: "Tried X but unable due to [specific reason]"
101
+ Read only a few Hubs "sufficient" judgment → superficial ideas
102
+ List only technical features No connection to actual problems
103
+ Deep dive one side only Forced fitting (bad integration)
156
104
  ```
157
105
 
158
- ### Exploration Depth
106
+ > **Domain ≠ Core Problem**
107
+ > Knowing "what the service is" but not "what's the core problem" → Technology pushing happens.
108
+ > AKB Hubs specify core problems, enabling "problem-centered" connections.
159
109
 
160
- > **Don't stop at Hubs. Explore detailed documents for thorough understanding.**
161
-
162
- | Question Type | Minimum | Additional |
163
- |--------------|---------|------------|
164
- | Implementation | Hub | Related Node |
165
- | Debugging | Hub | Related issues/logs |
166
- | **Strategy/Design** | Hub | **Design docs, past decisions, architecture details** |
167
- | **New Feature** | Hub | **Existing implementation patterns, related architecture** |
168
-
169
- ### Skill Synchronization (CRITICAL)
110
+ ---
170
111
 
171
- > **When changing code/processes, update related `.claude/skills/` SKILL.md files too.**
112
+ ## Knowledge Gate
172
113
 
173
- | Change Type | Skill Update |
174
- |-------------|-------------|
175
- | API endpoint change | Update API reference |
176
- | New tool/script added | Add to tool listing |
177
- | Process change | Update procedure guide |
178
- | Feature removed | Remove related section |
114
+ > **Before creating a new document, search existing docs first.**
179
115
 
180
- ### AKB Management (CRITICAL)
116
+ ```
117
+ 1. Summarize the insight + 3-5 keywords
118
+ 2. Search existing docs with those keywords (grep 3+ terms)
119
+ 3. Decide:
120
+ - Overlap 70%+ -> Add to existing document
121
+ - Overlap 30-70% -> New doc + cross-link to existing
122
+ - Overlap <30% -> New document (register in Hub)
123
+ - Temporary info -> Journal only (no new doc)
124
+ 4. Cross-link to related docs
125
+ 5. Register in the relevant Hub
126
+ ```
181
127
 
182
- > **Every Role manages knowledge as part of their work. Don't just code and stop.**
128
+ ---
183
129
 
184
- After completing any task, check:
130
+ ## Document Hygiene
185
131
 
186
- | # | Item | Description |
187
- |---|------|-------------|
188
- | 1 | **New knowledge?** | Did this task produce new insights/decisions/analysis? |
189
- | 2 | **Search existing docs** | Are there related docs already? (grep 3+ keywords) |
190
- | 3 | **Decide location** | Add to existing doc vs create new (prefer existing) |
191
- | 4 | **Hub connection** | Is the new/updated doc reachable from a Hub? |
192
- | 5 | **Cross-link** | Are there mutual references between related docs? |
193
- | 6 | **Task update** | Is the task status updated? Next work identified? |
132
+ | Rule | Description |
133
+ |------|-------------|
134
+ | No orphan docs | Every document must be reachable from a Hub |
135
+ | Hub pattern | Each folder's entry point is `{folder}.md` |
136
+ | Prefer existing | Adding 1 doc = maintenance cost. Strengthen existing > create new |
137
+ | Cross-link | New docs must reference at least 1 related doc |
138
+ | Source attribution | External research must cite source and date |
194
139
 
195
140
  ---
196
141
 
197
- ## Folder Structure
142
+ ## Writing Rules (4 Principles)
198
143
 
199
- ```
200
- {project}/
201
- ├── knowledge/ ← Tycono world. AI agent's cwd. Git root.
202
- │ ├── CLAUDE.md ← Only AI entry point
203
- │ ├── .claude/skills/ ← Role skill guides
204
- │ │ ├── _shared/
205
- │ │ └── {role-id}/SKILL.md
206
- │ ├── roles/
207
- │ │ ├── roles.md ← Hub
208
- │ │ └── {role-id}/
209
- │ │ ├── role.yaml
210
- │ │ ├── profile.md
211
- │ │ └── journal/
212
- │ ├── architecture/ ← Hub (technical architecture)
213
- │ ├── projects/ ← Hub (project tracking)
214
- │ ├── decisions/ ← CEO decisions
215
- │ ├── methodologies/ ← Frameworks & principles
216
- │ ├── presets/ ← Team presets
217
- │ ├── marketing/ ← Hub (SNS, launch, SEO)
218
- │ ├── e2e-experiments/ ← Hub (E2E test records)
219
- │ ├── company.md ← Company info
220
- │ ├── custom-rules.md ← Company custom rules (user owned)
221
- │ └── knowledge.md ← Hub (domain knowledge index)
222
-
223
- ├── .tycono/ ← Operational data (outside git)
224
- │ ├── config.json ← Engine settings, codeRoots
225
- │ ├── tycono.db ← SQLite (conversation history)
226
- │ ├── preferences.json ← UI settings
227
- │ ├── waves/ ← Wave execution logs
228
- │ ├── sessions/ ← Session state
229
- │ ├── standup/ ← Daily standups
230
- │ ├── cost/ ← Token cost tracking
231
- │ └── activity-streams/ ← SSE event logs (runtime)
232
-
233
- └── apps/ ← Code (default monorepo, outside git)
234
- ```
144
+ 1. **TL;DR Required**: Include searchable keywords (bold)
145
+ 2. **Contextual Links**: Place links in body text with context
146
+ 3. **Keyword-Optimized Filenames**: `wallet-security.md` not `security.md`
147
+ 4. **Atomicity**: One topic per document, under 200 lines
235
148
 
236
149
  ---
237
150