coaia-visualizer 1.6.1 → 1.6.3

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 (49) hide show
  1. package/README.md +1 -1
  2. package/app/page.tsx +4 -23
  3. package/components/chart-detail-editable.tsx +3 -0
  4. package/components/metadata-projections.tsx +208 -0
  5. package/lib/chart-editor.ts +13 -13
  6. package/lib/jsonl-parser.ts +55 -8
  7. package/lib/jsonl-preservation.ts +405 -0
  8. package/lib/types.ts +30 -0
  9. package/package.json +31 -1
  10. package/.dockerignore +0 -9
  11. package/COMPLETE_IMPLEMENTATION_REPORT.md +0 -215
  12. package/Dockerfile +0 -61
  13. package/Dockerfile.app +0 -50
  14. package/QUICK_START_MCP_TESTING.md +0 -236
  15. package/STC.md +0 -18
  16. package/STCGOAL.md +0 -0
  17. package/STCISSUE.md +0 -36
  18. package/STCKIN.md +0 -0
  19. package/STCMASTERY.md +0 -0
  20. package/STUDY_REPORT.md +0 -510
  21. package/direct-test.sh +0 -180
  22. package/docker-build-push.sh +0 -20
  23. package/docker-compose.test.yml +0 -69
  24. package/docker-entrypoint.sh +0 -27
  25. package/jgwill.coaia-visualizer-8--496dca71-d476-4ac9-ba9f-376add118dd8--260208.txt +0 -2612
  26. package/mcp/test_mcp/.gemini/settings.json +0 -18
  27. package/rispecs/README.md +0 -170
  28. package/rispecs/accountability-responsibility.rispec.md +0 -110
  29. package/rispecs/api-mcp-interface.spec.md +0 -287
  30. package/rispecs/app.spec.md +0 -364
  31. package/rispecs/chart-editing-workflow.spec.md +0 -297
  32. package/rispecs/chart-visualization-hierarchy.spec.md +0 -235
  33. package/rispecs/cli-mode.spec.md +0 -224
  34. package/rispecs/github-project-runtime-memory-integration.spec.md +0 -381
  35. package/rispecs/jsonl-parsing-data-types.spec.md +0 -243
  36. package/rispecs/narrative-beats-display.spec.md +0 -189
  37. package/rispecs/pde-integration.spec.md +0 -280
  38. package/rispecs/planning-integration.spec.md +0 -329
  39. package/rispecs/relation-graph-visualization.spec.md +0 -171
  40. package/rispecs/relation-to-mcp-structural-thinking.kin.md +0 -65
  41. package/rispecs/ui-component-library.spec.md +0 -258
  42. package/test-data/test-master.jsonl +0 -11
  43. package/test-scripts/README.md +0 -325
  44. package/test-scripts/run-all-tests.sh +0 -38
  45. package/test-scripts/test-01-basic-operations.sh +0 -87
  46. package/test-scripts/test-02-telescope-creation.sh +0 -91
  47. package/test-scripts/test-03-navigation.sh +0 -87
  48. package/test-scripts/test-global-cli.spec.ts +0 -220
  49. package/test-scripts/verify-global-cli.sh +0 -87
@@ -1,18 +0,0 @@
1
- {
2
- "mcpServers": {
3
- "chart-coaia-narrative-legacy-mcp": {
4
- "command": "npx",
5
- "args": ["-y", "${CNCV}", "--memory-path", "${memories}/trading-chart.coaia-narrative.jsonl" ]
6
- },
7
- "charts-mcp": {
8
- "command": "node",
9
- "args": [
10
- "/workspace/repos/jgwill/coaia-visualizer-feat-4/mcp/dist/index.js"
11
- ],
12
- "env": {
13
- "COAIAN_API_TOKEN":"123",
14
- "COAIAV_API_URL":"http://localhost:4321"
15
- }
16
- }
17
- }
18
- }
package/rispecs/README.md DELETED
@@ -1,170 +0,0 @@
1
- # COAIA Visualizer — RISE Specification Directory
2
-
3
- > Complete RISE specifications for `coaia-visualizer` v1.5.5 — the interactive web-based visualizer and editor for Structural Tension Charts from coaia-narrative JSONL files.
4
-
5
- **Framework**: RISE (Reverse-engineer · Intent · Specifications · Export)
6
- **Target Audience**: LLM agents, developers, and contributors rebuilding or extending coaia-visualizer
7
- **Canonical Types**: [`coaia-visualizer/lib/types.ts`](../lib/types.ts)
8
- **Parent Kinship**: [`coaia-narrative`](../../coaia-narrative/) — data source and memory layer
9
-
10
- ---
11
-
12
- ## 📚 Main Overview
13
-
14
- - **[app.spec.md](./app.spec.md)** — Complete application specification
15
- - What coaia-visualizer enables users to create
16
- - How all components interconnect
17
- - Creative intent and structural orientation
18
-
19
- ---
20
-
21
- ## 🔧 Component Specifications
22
-
23
- 1. **[jsonl-parsing-data-types.spec.md](./jsonl-parsing-data-types.spec.md)**
24
- - JSONL parsing engine and 4-pass organization algorithm
25
- - EntityRecord, RelationRecord, Chart, ParsedData type system
26
- - KnowledgeGraph assembly from flat JSONL lines
27
- - File upload, export, and live reload
28
-
29
- 2. **[chart-visualization-hierarchy.spec.md](./chart-visualization-hierarchy.spec.md)**
30
- - ChartList with hierarchy and flat list modes
31
- - ChartDetail and ChartDetailEditable views
32
- - Telescoped navigation and sub-chart drilling
33
- - Progress bars, summary truncation, narrative beat indicators
34
-
35
- 3. **[chart-editing-workflow.spec.md](./chart-editing-workflow.spec.md)**
36
- - Edit desired outcomes, current reality observations, action steps
37
- - Due date management with calendar popover
38
- - Add/remove/toggle actions and charts
39
- - CreateChartForm and AddMasterChart creation flows
40
- - ChartEditor class mutation patterns
41
-
42
- 4. **[api-mcp-interface.spec.md](./api-mcp-interface.spec.md)**
43
- - REST API routes (charts CRUD, search, JSONL I/O, watch, audio)
44
- - MCP server with 15 tools for AI agent access
45
- - Bearer token authentication (COAIAN_API_TOKEN)
46
- - CoaiaVisualizerClient API wrapper
47
-
48
- 5. **[cli-mode.spec.md](./cli-mode.spec.md)**
49
- - CLI entry point with `--memory-path` flag
50
- - Docker and local Next.js execution modes
51
- - Environment variable configuration
52
- - Auto-open browser and graceful shutdown
53
-
54
- 6. **[narrative-beats-display.spec.md](./narrative-beats-display.spec.md)**
55
- - Narrative beat card rendering
56
- - Multi-universe perspective badges
57
- - Act sequencing, dramatic type, prose display
58
- - Lessons learned and timestamp metadata
59
-
60
- 7. **[relation-graph-visualization.spec.md](./relation-graph-visualization.spec.md)**
61
- - Inter-chart relation graph rendering
62
- - Entity connection display grouped by relation type
63
- - contains, creates_tension_with, advances_toward, documents relations
64
- - Entity observation preview
65
-
66
- 8. **[ui-component-library.spec.md](./ui-component-library.spec.md)**
67
- - Radix UI / shadcn-based component primitives
68
- - Dark/light theme support via next-themes
69
- - DataStats dashboard cards
70
- - LiveIndicator polling status display
71
- - Tailwind CSS utility patterns
72
-
73
- 9. **[accountability-responsibility.rispec.md](./accountability-responsibility.rispec.md)** *(existing)*
74
- - Rendering accountability/responsibility distinctions in chart UI
75
- - Schema consumption from entity metadata
76
-
77
- ---
78
-
79
- ## 🔮 Future Integration Specs
80
-
81
- 10. **[pde-integration.spec.md](./pde-integration.spec.md)** *(future/aspirational)*
82
- - Four Directions Medicine Wheel quadrant visualization
83
- - PDE source linking with decomposition provenance trail
84
- - Implicit intent badges and confidence indicators
85
- - Direction-based action grouping (EAST/SOUTH/WEST/NORTH)
86
- - Extends: chart-visualization-hierarchy, jsonl-parsing-data-types
87
-
88
- 11. **[planning-integration.spec.md](./planning-integration.spec.md)** *(future/aspirational)*
89
- - Plan source indicator with parse confidence scoring
90
- - Bidirectional sync status (synced/diverged/conflict)
91
- - Plan section mapping for action step provenance
92
- - Confidence-based color coding for human review focus
93
- - Re-sync trigger to push edits back to plan markdown
94
- - Extends: chart-visualization-hierarchy, chart-editing-workflow, api-mcp-interface
95
-
96
- ---
97
-
98
- ## 🎯 Core Creative Intent
99
-
100
- coaia-visualizer enables users to **create living, navigable maps of structural tension** — transforming flat JSONL memory files into interactive hierarchies where:
101
-
102
- - **Desired outcomes** are visible as aspirational anchors
103
- - **Current reality** is honestly assessed and continuously updated
104
- - **Action steps** telescope into full sub-charts, creating fractal depth
105
- - **Narrative beats** weave story across the structural work
106
- - **Relations** reveal the kinship between charts, actions, and outcomes
107
-
108
- This is **not** a dashboard for monitoring problems. It is a **ceremonial instrument** for holding creative tension — the generative gap between what is and what must become.
109
-
110
- ---
111
-
112
- ## 🏗️ Three Core Pillars
113
-
114
- ### 1. Creative Orientation (NOT Problem-Solving)
115
- Every chart begins with a **Desired Outcome** — what the user wants to create. The system refuses "fix" and "solve" framing. Current Reality is an honest assessment, never a complaint.
116
-
117
- ### 2. Structural Tension (Current Reality ↔ Desired Outcome)
118
- The irreducible gap between reality and vision generates the *mana* that drives action. The visualizer makes this tension **visible and navigable** — not as anxiety but as creative fuel.
119
-
120
- ### 3. Advancing Patterns (NOT Oscillating)
121
- Action steps advance toward outcomes. Completed actions update parent reality. Telescoped charts create depth without losing context. The system structurally prevents oscillation between problem and relief.
122
-
123
- ---
124
-
125
- ## 📐 Data Flow Architecture
126
-
127
- ```
128
- JSONL File / API
129
-
130
-
131
- parseJSONL() ─── Flat records (entities + relations)
132
-
133
-
134
- organizeData() ─── 4-pass: separate → chart assembly → populate → hierarchy
135
-
136
-
137
- ParsedData ─── Charts[], Entities Map, Relations[], RootCharts[]
138
-
139
- ├──▶ page.tsx ─── Main orchestrator (state management, routing)
140
- ├──▶ ChartList ─── Hierarchy/List navigation
141
- ├──▶ ChartDetail ─── Read-only display (unused by page.tsx)
142
- ├──▶ ChartDetailEdit ─── Full editing via ChartEditor
143
- ├──▶ NarrativeBeats ─── Story layer
144
- ├──▶ RelationGraph ─── Inter-entity connections
145
- └──▶ DataStats ─── Summary metrics
146
-
147
-
148
- ChartEditor.exportToJSONL() ─── Serialize back to JSONL
149
-
150
-
151
- POST /api/jsonl ─── Persist with backup
152
-
153
-
154
- COAIAV_MEMORY_PATH ─── Filesystem path resolved by CLI / env
155
- ```
156
-
157
- ---
158
-
159
- ## ✅ Quality Test: Can Another LLM Rebuild This?
160
-
161
- Given these specifications alone, an LLM agent should be able to:
162
-
163
- - ✅ Parse any coaia-narrative JSONL file into navigable chart hierarchies
164
- - ✅ Render structural tension (desired outcome vs current reality) with correct visual language
165
- - ✅ Implement telescoped navigation between parent and sub-charts
166
- - ✅ Build all 15 MCP tools matching the existing API surface
167
- - ✅ Create the CLI with Docker and local execution modes
168
- - ✅ Reproduce the edit workflow: desired outcome → current reality → action steps → completion
169
- - ✅ Display narrative beats with multi-universe perspectives
170
- - ✅ Maintain creative orientation framing throughout all UI text
@@ -1,110 +0,0 @@
1
- # RISPEC: Accountability & Responsibility Rendering in coaia-visualizer
2
-
3
- > How the visualizer displays accountability and responsibility distinctions in Structural Tension Charts
4
-
5
- ## 🎯 What This Enables Users to Create
6
-
7
- - Visual clarity on who holds accountability for chart outcomes
8
- - Inline responsibility attribution on action steps
9
- - Delegation chain awareness across chart hierarchies
10
- - Filtered views by responsible entity type (human / AI / pair)
11
-
12
- ## Current Reality
13
-
14
- `coaia-visualizer` renders STCs from coaia-narrative JSONL. It shows chart components (desired outcome, current reality, action steps), telescoping navigation, and completion status. There is no visual representation of:
15
- - Who is accountable for a chart's desired outcome
16
- - Who is responsible for each action step
17
- - The delegation chain between them
18
-
19
- ## Desired Result
20
-
21
- The visualizer renders accountability and responsibility as first-class visual elements:
22
- - **Chart header**: shows the accountable entity with a distinct badge
23
- - **Action steps**: show responsible entity/entities inline
24
- - **Delegation view**: optional view showing the accountability→responsibility chain
25
-
26
- ## UI Components
27
-
28
- ### Chart Header — Accountability Badge
29
-
30
- ```
31
- ┌─────────────────────────────────────────┐
32
- │ 🎯 Deploy PDE across all variants │
33
- │ ◉ Accountable: jgi (human) │
34
- │ Due: 2026-03-21 │
35
- └─────────────────────────────────────────┘
36
- ```
37
-
38
- - `◉` icon distinguishes accountability from responsibility
39
- - Color-coded by `accountableEntityType`: human (blue), ai_companion (purple), team_lead (green)
40
- - Click to view accountability context
41
-
42
- ### Action Steps — Responsibility Indicators
43
-
44
- ```
45
- □ Audit mcp-pde implementation → mia, sub-agent:south
46
- □ Update coaia-pde stc-mapper → mia
47
- ■ Research IAIP reference format → sub-agent:south ✓ completedBy: south-3
48
- ```
49
-
50
- - Responsible entities shown inline, right-aligned
51
- - `pair` type shows both entities with a link icon
52
- - Completed steps show `completedBy` if different from responsible
53
-
54
- ### Delegation Chain View (Optional Panel)
55
-
56
- ```
57
- jgi (accountable)
58
- ├── delegates → mia (NORTH actions)
59
- ├── delegates → sub-agent:south (SOUTH actions)
60
- ├── co-holds → jgi + miette (WEST actions)
61
- └── retains → jgi (EAST actions)
62
- ```
63
-
64
- ### Filter/Group Controls
65
-
66
- - Filter action steps by responsible entity
67
- - Group by responsibility type (human / AI / pair)
68
- - Highlight items where responsibility ≠ completed-by (delegation shift)
69
-
70
- ## Schema Consumption
71
-
72
- Reads from Entity.metadata:
73
-
74
- ```typescript
75
- // Chart entity
76
- metadata.accountability?.accountableEntity
77
- metadata.accountability?.accountableEntityType
78
- metadata.accountability?.accountabilityContext
79
-
80
- // Action step entity
81
- metadata.responsibility?.responsibleEntities
82
- metadata.responsibility?.responsibilityType
83
- metadata.responsibility?.delegatedFrom
84
- metadata.assignedTo // backward compat fallback
85
- ```
86
-
87
- ## Backward Compatibility
88
-
89
- When `accountability` / `responsibility` fields are absent:
90
- - Chart header shows no accountability badge (no default assumption)
91
- - Action steps show no responsibility indicator
92
- - Existing charts render identically to current behavior
93
-
94
- ## Dependency
95
-
96
- - Canonical schema: `coaia-narrative/rispecs/accountability-responsibility-distinction.rispec.md`
97
- - Data source: coaia-narrative JSONL with Entity.metadata extensions
98
-
99
- ## Priority
100
-
101
- Medium — rendering follows schema. Implement after coaia-narrative schema extension is merged.
102
-
103
- ---
104
-
105
- ## 🔗 Related Components
106
-
107
- - [chart-visualization-hierarchy.spec.md](./chart-visualization-hierarchy.spec.md) — ChartDetail/ChartDetailEditable host accountability badges in header
108
- - [chart-editing-workflow.spec.md](./chart-editing-workflow.spec.md) — EditActionStep would need responsibility indicator integration
109
- - [jsonl-parsing-data-types.spec.md](./jsonl-parsing-data-types.spec.md) — EntityRecord metadata extensions for accountability/responsibility fields
110
- - [api-mcp-interface.spec.md](./api-mcp-interface.spec.md) — API routes would need to support accountability/responsibility updates
@@ -1,287 +0,0 @@
1
- # API & MCP Interface
2
- ## RISE Specification for REST API, MCP Server, and Agent Access Patterns
3
-
4
- **Component Purpose**: Provide complete programmatic access to structural tension chart operations via REST API endpoints and a 15-tool MCP server, enabling AI agents and external tools to create, read, update, and delete charts with the same fidelity as the web UI.
5
-
6
- **Source Files**: `app/api/**/*.ts`, `mcp/src/index.ts`, `mcp/src/tools/index.ts`, `mcp/src/api-client.ts`, `lib/api-auth.ts`
7
-
8
- ---
9
-
10
- ## 🎯 What This Component Enables Users to Create
11
-
12
- - AI agent workflows that manage structural tension charts programmatically
13
- - Automated chart creation from Claude, GPT, or any MCP-compatible agent
14
- - External tool integrations via standard REST API calls
15
- - Secure multi-user access with token-based authentication
16
- - Live data synchronization between web UI and agent sessions
17
-
18
- ---
19
-
20
- ## 🌊 Structural Tension Dynamics
21
-
22
- ### Current Reality
23
- coaia-narrative stores data as JSONL files on disk. Without an API layer, agents must read/write files directly, parse JSONL manually, and implement their own chart assembly logic. The MCP protocol exists but needs a server that maps chart operations to tool definitions.
24
-
25
- ### Desired Result
26
- A complete API surface where:
27
- - 6 REST route groups expose all chart operations
28
- - 15 MCP tools provide agent-native access
29
- - Bearer token authentication protects all mutating endpoints
30
- - Every write operation creates a timestamped backup
31
- - Response formats are consistent (JSON with error/success patterns)
32
-
33
- ### Natural Resolution
34
- The REST API implements chart operations using `ChartEditor` and JSONL parsing. The MCP server wraps the REST API via `CoaiaVisualizerClient`, translating tool calls into HTTP requests. Both share the same authentication layer.
35
-
36
- ---
37
-
38
- ## 📋 Authentication (`lib/api-auth.ts`)
39
-
40
- ### Token Resolution
41
- ```
42
- 1. Check COAIAN_API_TOKEN environment variable
43
- 2. If set → use as API token
44
- 3. If not set → generate random 64-char hex token (crypto.randomBytes(32))
45
- 4. Cache generated token for process lifetime
46
- 5. Log generated token to console with warning (development convenience)
47
- ```
48
-
49
- ### Request Validation
50
- ```typescript
51
- validateApiToken(request: NextRequest): boolean
52
- 1. Extract Authorization header
53
- 2. Match regex /^Bearer\s+(.+)$/
54
- 3. Compare extracted token against getApiToken()
55
- 4. Return true only if match
56
- ```
57
-
58
- ### Middleware Pattern
59
- ```typescript
60
- withAuth(handler): wrappedHandler
61
- 1. Call validateApiToken(request)
62
- 2. If invalid → return 401 { error: "Unauthorized" }
63
- 3. If valid → delegate to handler(request, context)
64
- ```
65
-
66
- ### Response Helpers
67
- - `successResponse(data, status=200)` → `NextResponse.json(data, { status })`
68
- - `errorResponse(message, status=400)` → `NextResponse.json({ error: message }, { status })`
69
- - `unauthorizedResponse()` → 401 with explanation message
70
-
71
- ---
72
-
73
- ## 📋 REST API Routes
74
-
75
- ### GET /api/charts — List Charts
76
- **Auth**: Required (withAuth)
77
- **Query Params**:
78
- - `level` — Filter by chart depth (number)
79
- - `rootOnly` — Return only level-0 charts (boolean)
80
-
81
- **Response**: `{ charts: Chart[], total: number, memoryPath: string }`
82
-
83
- ### POST /api/charts — Create Chart
84
- **Auth**: Required (withAuth)
85
- **Body**:
86
- ```json
87
- {
88
- "desiredOutcome": "string (required)",
89
- "currentReality": "string (required)",
90
- "dueDate": "ISO date string (optional)",
91
- "parentChartId": "string (optional, for sub-charts)"
92
- }
93
- ```
94
- **Behavior**:
95
- 1. Generate new chart_N ID (max existing + 1)
96
- 2. Create 3 entities: chart, desired_outcome, current_reality
97
- 3. Create 3 relations: contains (×2), creates_tension_with
98
- 4. If parentChartId: create parent→child contains relation
99
- 5. Create timestamped backup of existing file
100
- 6. Write updated JSONL
101
-
102
- **Response**: `{ chartId: string, message: string, backup: string }`
103
-
104
- ### GET /api/charts/[id] — Get Chart
105
- **Auth**: Required
106
- **Response**: Full Chart object with all properties
107
-
108
- ### POST /api/charts/[id] — Update Chart
109
- **Auth**: Required
110
- **Body**: Object with one or more update operations:
111
-
112
- | Operation | Fields | Effect |
113
- |:---|:---|:---|
114
- | `updateDesiredOutcome` | `{ text: string }` | Replace desired outcome |
115
- | `addCurrentRealityObservation` | `{ observation: string }` | Add observation |
116
- | `updateCurrentReality` | `{ observations: string[] }` | Replace observations |
117
- | `updateCurrentRealityObservation` | `{ index, text }` | Update specific observation |
118
- | `deleteCurrentRealityObservation` | `{ index }` | Remove observation |
119
- | `addActionStep` | `{ title, currentReality, dueDate? }` | Create telescoped action |
120
- | `updateActionStep` | `{ actionName, description }` | Update action text |
121
- | `toggleActionCompletion` | `{ actionName }` | Toggle done status |
122
- | `markActionComplete` | `{ actionStepName }` | Complete + update parent |
123
- | `updateActionProgress` | `{ actionStepName, observation, updateReality? }` | Add progress |
124
- | `updateActionDueDate` | `{ actionName, dueDate }` | Change action date |
125
- | `deleteActionStep` | `{ actionName }` | Remove action |
126
- | `createTelescopedChart` | `{ actionName }` | Convert action to sub-chart |
127
- | `updateDueDate` | `{ dueDate }` | Change chart date |
128
-
129
- **Response**: `{ chart: Chart, updates: string[], backup: string, message: string }`
130
-
131
- ### DELETE /api/charts/[id] — Delete Chart
132
- **Auth**: Required
133
- **Behavior**: Recursively deletes chart + all sub-charts, their entities, and all related relations
134
- **Response**: `{ message: string, deletedEntities: string[], backup: string }`
135
-
136
- ### GET /api/charts/search — Search Charts
137
- **Auth**: Required
138
- **Query Params**:
139
- - `q` — Text search (case-insensitive, searches outcomes/reality/actions)
140
- - `level` — Filter by depth
141
- - `completed` — Boolean: all actions done?
142
- - `hasActions` — Boolean: has action steps?
143
-
144
- **Response**: `{ charts: Chart[], total: number, query: { q, level, completed, hasActions } }`
145
-
146
- ### GET /api/jsonl — Read Memory File
147
- **Auth**: Not required
148
- **Dependency**: Requires `COAIAV_MEMORY_PATH` environment variable to locate the JSONL file on disk
149
- **Filename Resolution**: Uses `COAIAV_MEMORY_DISPLAY_NAME` if set, otherwise falls back to `path.basename(COAIAV_MEMORY_PATH)`. This preserves the original filename when Docker remaps paths to `/data/memory.jsonl`.
150
- **Response**: `{ content: string, filename: string, path: string }`
151
-
152
- ### POST /api/jsonl — Write Memory File
153
- **Auth**: Not required
154
- **Body**: `{ content: string }`
155
- **Behavior**: Creates timestamped backup, writes new content
156
- **Response**: `{ success: true, backupPath: string }`
157
-
158
- ### GET /api/watch — File Statistics
159
- **Auth**: Not required
160
- **Response**: `{ lastModified: number, beatCount: number, fileSize: number, totalRecords: number }`
161
- **Purpose**: Support live polling for file change detection
162
-
163
- ### GET /api/audio/[filename] — Serve Audio
164
- **Auth**: Not required
165
- **Security**: Only serves `.mp3` files from `COAIAV_AUDIO_DIR`
166
- **Response**: Binary MP3 with 1-year cache header
167
-
168
- ---
169
-
170
- ## 📋 MCP Server (`mcp/`)
171
-
172
- ### Configuration
173
- - **Transport**: stdio (standard input/output)
174
- - **API Base URL**: `COAIAV_API_URL` env var (default fallback: `http://localhost:3000`)
175
- - **Token**: `COAIAN_API_TOKEN` env var (required — server refuses to start without it)
176
-
177
- ### 15 MCP Tools
178
-
179
- | # | Tool Name | Required Args | Optional Args | Maps To |
180
- |:---|:---|:---|:---|:---|
181
- | 1 | `list_charts` | — | level, rootOnly | GET /api/charts |
182
- | 2 | `get_chart` | chartId | — | GET /api/charts/{id} |
183
- | 3 | `create_chart` | desiredOutcome, currentReality | dueDate, parentChartId | POST /api/charts |
184
- | 4 | `update_chart` | chartId | desiredOutcome, currentReality, dueDate | POST /api/charts/{id} |
185
- | 5 | `add_action_step` | parentChartId, actionStepTitle, currentReality | dueDate | POST /api/charts/{id} |
186
- | 6 | `update_action_step` | chartId, actionName, description | — | POST /api/charts/{id} |
187
- | 7 | `mark_action_complete` | chartId, actionStepName | — | POST /api/charts/{id} |
188
- | 8 | `update_action_progress` | chartId, actionStepName, progressObservation | updateCurrentReality | POST /api/charts/{id} |
189
- | 9 | `update_current_reality` | chartId, newObservations | — | POST /api/charts/{id} |
190
- | 10 | `toggle_action_completion` | chartId, actionName | — | POST /api/charts/{id} |
191
- | 11 | `delete_action_step` | chartId, actionName | — | POST /api/charts/{id} |
192
- | 12 | `create_telescoped_chart` | chartId, actionName | — | POST /api/charts/{id} |
193
- | 13 | `delete_chart` | chartId | — | DELETE /api/charts/{id} |
194
- | 14 | `search_charts` | — | query, level, completed, hasActions | GET /api/charts/search |
195
- | 15 | `get_chart_progress` | chartId | — | GET /api/charts/{id} + compute |
196
-
197
- ### Tool Response Format
198
- ```json
199
- {
200
- "content": [{ "type": "text", "text": "JSON string of response data" }],
201
- "isError": false
202
- }
203
- ```
204
- Error responses set `isError: true` with error message in text field.
205
-
206
- ### CoaiaVisualizerClient (`mcp/src/api-client.ts`)
207
- HTTP wrapper class used by the MCP server.
208
-
209
- > **Note**: The client uses a simplified `Chart` type (plain objects, not full `EntityRecord` instances). Entity names returned by the API may differ from those used internally by `ChartEditor` (e.g., API route params use `chartId` while ChartEditor methods reference `chart.chartEntity.name`).
210
-
211
- ```typescript
212
- class CoaiaVisualizerClient {
213
- constructor(config: { baseUrl: string, token: string })
214
-
215
- listCharts(options?): Promise<Chart[]>
216
- getChart(id: string): Promise<Chart>
217
- createChart(data): Promise<{ chartId: string }>
218
- updateChart(id, updates): Promise<Chart>
219
- createTelescopedChart(chartId, actionName): Promise<Chart>
220
- deleteChart(id): Promise<void>
221
- searchCharts(query): Promise<Chart[]>
222
- getChartProgress(chart): number // Local computation
223
- getChartSummary(chart): string // Local computation (100 char truncate)
224
- }
225
- ```
226
-
227
- ---
228
-
229
- ## 📋 Agent Access Scenario
230
-
231
- ### Claude Desktop Configuration
232
- ```json
233
- {
234
- "mcpServers": {
235
- "coaia-visualizer": {
236
- "command": "node",
237
- "args": ["path/to/mcp/dist/index.js"],
238
- "env": {
239
- "COAIAN_API_TOKEN": "your-token-here",
240
- "COAIAV_API_URL": "http://localhost:3000"
241
- }
242
- }
243
- }
244
- }
245
- ```
246
-
247
- ### Typical Agent Session
248
- ```
249
- 1. Agent calls list_charts → gets all chart summaries
250
- 2. Agent calls get_chart(chartId) → gets full detail
251
- 3. Agent calls update_current_reality → adds new observations
252
- 4. Agent calls add_action_step → creates telescoped sub-chart
253
- 5. Agent calls mark_action_complete → action done + parent updated
254
- 6. Agent calls get_chart_progress → checks advancement percentage
255
- ```
256
-
257
- ---
258
-
259
- ## ✅ Quality Criteria
260
-
261
- ✅ **API Completeness**
262
- - Every operation available in the web UI is also available via API
263
- - 15 MCP tools cover all chart lifecycle operations
264
- - Search supports text, level, completion, and action filters
265
-
266
- ✅ **Authentication Security**
267
- - All chart mutation endpoints require Bearer token
268
- - Token from environment variable or auto-generated
269
- - Consistent 401 response for unauthorized requests
270
-
271
- ✅ **Data Safety**
272
- - Timestamped backup created before every write
273
- - Recursive deletion handles sub-chart cascades
274
- - Error responses include descriptive messages
275
-
276
- ✅ **Agent Ergonomics**
277
- - All responses are JSON (parseable by agents)
278
- - Tool descriptions include required/optional parameter documentation
279
- - MCP tools use JSON Schema inputSchema for parameter validation
280
-
281
- ---
282
-
283
- ## 🔗 Related Components
284
-
285
- - [chart-editing-workflow.spec.md](./chart-editing-workflow.spec.md) — ChartEditor class used by API routes
286
- - [jsonl-parsing-data-types.spec.md](./jsonl-parsing-data-types.spec.md) — types shared between API and client
287
- - [cli-mode.spec.md](./cli-mode.spec.md) — CLI starts the server that API routes run on