coaia-visualizer 1.5.9 → 1.6.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.
package/STUDY_REPORT.md DELETED
@@ -1,510 +0,0 @@
1
- # coaia-visualizer — Comprehensive Project Study Report
2
-
3
- > **Purpose**: Thorough analysis for reusable package design
4
- > **Version studied**: 1.5.8
5
- > **Generated**: 2025-07-27
6
-
7
- ---
8
-
9
- ## 1. What coaia-visualizer Does
10
-
11
- **coaia-visualizer** is an interactive web-based tool that transforms coaia-narrative **JSONL memory files** into navigable, editable **Structural Tension Chart (STC)** hierarchies. It is built as a **ceremonial instrument** for practitioners of Robert Fritz's creative orientation methodology — not a project management dashboard.
12
-
13
- ### Core Capabilities
14
-
15
- | Capability | Description |
16
- |:---|:---|
17
- | **JSONL Parsing** | Ingests flat JSONL files (one JSON object per line), parsing entity and relation records into structured chart hierarchies via a 4-pass algorithm |
18
- | **Chart Visualization** | Renders charts in hierarchy (tree) or flat list mode with progress bars, level badges, summary text, and telescoped navigation |
19
- | **Chart Editing** | Inline editing of desired outcomes, current reality observations, action steps; adding/deleting/completing actions; telescoping actions into full sub-charts |
20
- | **API Access** | 6 REST API route groups (charts CRUD, search, JSONL I/O, watch, audio) with Bearer token auth |
21
- | **MCP Server** | 15 MCP tools mapped 1:1 to chart operations for AI agent integration |
22
- | **CLI & Docker** | `coaia-visualizer --memory-path ./file.jsonl` launches the full app locally or in Docker |
23
- | **Live Mode** | File-watching with auto-reload when JSONL is modified by agents |
24
- | **Narrative Beats** | Renders story-layer documentation with act numbering, dramatic types, multi-universe perspectives |
25
- | **Relation Graphs** | Displays inter-entity connections grouped by relation type (contains, creates_tension_with, advances_toward, documents) |
26
- | **Reusable Package** | Exports types, parser, components, hooks, and UI primitives via `index.tsx` for consumption by other projects |
27
-
28
- ### Structural Tension Philosophy
29
-
30
- The tool enforces **creative orientation** (not problem-solving). Every chart starts with a **Desired Outcome** (what the user wants to create), holds **Current Reality** as honest assessment, and drives **Action Steps** that advance toward the vision. The irreducible gap between reality and vision is the *structural tension* — visualized as the core UI element.
31
-
32
- ---
33
-
34
- ## 2. Architecture Overview
35
-
36
- ### Technology Stack
37
-
38
- | Layer | Technology | Version |
39
- |:---|:---|:---|
40
- | Runtime | Next.js (App Router) | 16.0.10 |
41
- | UI Framework | React | 19.2.0 |
42
- | Language | TypeScript | 5.x |
43
- | Styling | Tailwind CSS | 4.1.9 |
44
- | UI Primitives | Radix UI (20+ packages) + shadcn patterns | Various |
45
- | Charts | recharts | 2.15.4 |
46
- | Forms | react-hook-form + zod | 7.60.0 / 3.25.76 |
47
- | Icons | lucide-react | 0.454.0 |
48
- | Toast | sonner | 1.7.4 |
49
- | MCP | @modelcontextprotocol/sdk | 1.25.2 (main), 0.6.0 (mcp/) |
50
- | Themes | next-themes | 0.4.6 |
51
- | Testing | Playwright | 1.58.2 |
52
- | Deployment | Docker (node:22-alpine), Vercel, npm global | |
53
-
54
- ### Project Structure
55
-
56
- ```
57
- coaia-visualizer/
58
- ├── index.tsx # Package entry: exports types, parser, components, hooks, UI
59
- ├── cli.ts # CLI entry point (compiles to dist/cli.js)
60
- ├── package.json # v1.5.8, bin: coaia-visualizer
61
-
62
- ├── lib/ # Core logic layer
63
- │ ├── types.ts # EntityRecord, RelationRecord, Chart, ParsedData
64
- │ ├── jsonl-parser.ts # parseJSONL(), organizeData(), helpers
65
- │ ├── chart-editor.ts # ChartEditor class (576 lines, all mutation logic)
66
- │ ├── api-auth.ts # Token auth: getApiToken(), validateApiToken(), withAuth()
67
- │ └── utils.ts # cn() utility (clsx + tailwind-merge)
68
-
69
- ├── components/ # React components
70
- │ ├── chart-list.tsx # Hierarchy/flat list with ChartTree recursive component
71
- │ ├── chart-detail.tsx # Read-only chart view (retained but unused by page.tsx)
72
- │ ├── chart-detail-editable.tsx # Full editing view (primary detail component)
73
- │ ├── edit-desired-outcome.tsx # Inline desired outcome editor
74
- │ ├── edit-current-reality.tsx # Observation list editor (add/edit/delete)
75
- │ ├── edit-action-step.tsx # Action with completion toggle, telescope, date, delete
76
- │ ├── edit-chart-due-date.tsx # Calendar popover for chart due dates
77
- │ ├── add-action-step.tsx # Collapsible form for new actions
78
- │ ├── add-master-chart.tsx # Dialog for new root charts
79
- │ ├── create-chart-form.tsx # Inline chart creation form (Create tab)
80
- │ ├── narrative-beats.tsx # Narrative beat cards with universe badges
81
- │ ├── relation-graph.tsx # Grouped relation display
82
- │ ├── data-stats.tsx # 4-card summary (charts, actions, entities, relations)
83
- │ ├── file-upload.tsx # Drag-and-drop .jsonl/.txt upload
84
- │ ├── live-indicator.tsx # Green pulse dot for live mode
85
- │ ├── page-with-editing.tsx # (wrapper component)
86
- │ ├── theme-provider.tsx # next-themes wrapper
87
- │ ├── theme-toggle.tsx # Sun/Moon toggle, hydration-safe
88
- │ └── ui/ # 12 shadcn/Radix primitives
89
- │ ├── badge.tsx, button.tsx, calendar.tsx, card.tsx
90
- │ ├── dialog.tsx, input.tsx, label.tsx, popover.tsx
91
- │ ├── scroll-area.tsx, separator.tsx, tabs.tsx, textarea.tsx
92
-
93
- ├── hooks/
94
- │ ├── use-live-polling.ts # Polls /api/watch, triggers reload on new data
95
- │ └── use-toast.ts # Toast hook (inactive; sonner is used instead)
96
-
97
- ├── app/ # Next.js App Router
98
- │ ├── layout.tsx # Root layout with ThemeProvider
99
- │ ├── page.tsx # Main orchestrator (7 useState hooks, auto-load)
100
- │ ├── globals.css # Tailwind + theme CSS variables
101
- │ └── api/ # REST API routes
102
- │ ├── charts/ # CRUD + search
103
- │ ├── jsonl/ # Read/write JSONL file
104
- │ ├── watch/ # File statistics for polling
105
- │ └── audio/ # MP3 serving
106
-
107
- ├── mcp/ # Standalone MCP server (separate package)
108
- │ ├── package.json # coaia-visualizer-mcp v1.0.0
109
- │ ├── src/
110
- │ │ ├── index.ts # MCP server (stdio transport)
111
- │ │ ├── tools/index.ts # 15 tool definitions with JSON Schema
112
- │ │ └── api-client.ts # CoaiaVisualizerClient HTTP wrapper
113
- │ └── dist/ # Compiled output
114
-
115
- ├── rispecs/ # 14 RISE specification files
116
- ├── samples/ # Sample JSONL files
117
- ├── test-data/ # Test fixtures
118
- └── test-scripts/ # Playwright test specs
119
- ```
120
-
121
- ### Data Flow
122
-
123
- ```
124
- JSONL Source (file/API/CLI)
125
-
126
-
127
- parseJSONL(content) Split lines → JSON.parse each → skip malformed
128
-
129
-
130
- organizeData(records) 4-pass: separate → chart shells → populate → hierarchy
131
-
132
-
133
- ParsedData { charts[], entities Map, relations[], rootCharts[] }
134
-
135
- ┌────┴────────────────────────────┐
136
- │ │ │
137
- ChartList ChartDetailEditable DataStats
138
- (navigate) (view + edit) (summary)
139
-
140
- ChartEditor Mutation class → exportToJSONL()
141
-
142
- POST /api/jsonl Backup → write → persist
143
- ```
144
-
145
- ---
146
-
147
- ## 3. RISE Specification Summary (All 14 Files)
148
-
149
- ### 3.1 rispecs/README.md
150
- Index document listing all specs with navigation. Defines the three core pillars: Creative Orientation, Structural Tension, Advancing Patterns. Includes the full data flow diagram and a quality test checklist.
151
-
152
- ### 3.2 app.spec.md — Application Root
153
- The master spec. Defines:
154
- - What coaia-visualizer enables (8 user capabilities)
155
- - All 8 functional components with cross-references
156
- - Data flow architecture diagram
157
- - 3 creative advancement scenarios (first-time visualization, advancing through tension, AI agent workflow)
158
- - Page state management (7 useState hooks + auto-load behavior)
159
- - Complete technology stack
160
- - Core data structures (EntityRecord, RelationRecord, Chart, ParsedData)
161
-
162
- ### 3.3 jsonl-parsing-data-types.spec.md — Parsing Engine
163
- Defines:
164
- - **Type system**: EntityRecord (5 entity types), RelationRecord (4 relation types), Chart, ParsedData
165
- - **parseJSONL()**: Line splitting, JSON.parse with console.error fallback, malformed-line resilience
166
- - **organizeData()**: 4-pass algorithm:
167
- - Pass 1: Separate entities into Map, relations into array
168
- - Pass 2: Assemble chart shells from `structural_tension_chart` entities
169
- - Pass 3: Populate charts with desired_outcome, current_reality, action_step, narrative_beat
170
- - Pass 3.5: Recognize telescoped sub-charts as parent action steps (synthetic entities)
171
- - Pass 4: Build hierarchy (parent-child linking), identify rootCharts
172
- - **Helpers**: getChartSummary() (100-char truncation), getChartProgress() (completed/total %)
173
- - **Live reload**: useLivePolling hook polls /api/watch, compares beatCount
174
-
175
- ### 3.4 chart-visualization-hierarchy.spec.md — Display & Navigation
176
- Defines:
177
- - **ChartList**: Two modes — hierarchy (recursive ChartTree with expand/collapse) and flat list
178
- - **ChartItem**: ID badge, level badge, summary, narrative indicators, action count, progress bar
179
- - **ChartDetail**: Read-only view (retained but NOT rendered by page.tsx)
180
- - **ChartDetailEditable**: Primary view with back button, inline editing, telescope actions, completion toggle
181
- - **Section order**: Desired Outcome → Action Steps → Current Reality (intentional — actions bridge the gap)
182
- - **Navigation stack**: `chartNavigationStack: Chart[]` with push/pop for unlimited depth drilling
183
- - **applyEdit pattern**: ChartEditor instance → mutation → getUpdatedData() → onUpdate()
184
-
185
- ### 3.5 chart-editing-workflow.spec.md — Mutations & Creation
186
- Defines:
187
- - **ChartEditor class** (576 lines): 14 mutation methods, constructor takes ParsedData (shallow clone)
188
- - **Mutation methods**: updateDesiredOutcome, addCurrentRealityObservation, updateCurrentReality, updateCurrentRealityObservation, deleteCurrentRealityObservation, addActionStep, updateActionStep, markActionStepComplete, updateActionProgress, toggleActionCompletion, updateActionDueDate, deleteActionStep, createTelescopedChartFromAction, updateChartDueDate
189
- - **ChartUpdate interface**: 9 update types
190
- - **Edit components**: EditDesiredOutcome (hover pencil → textarea), EditCurrentReality (per-observation edit/delete + add), EditActionStep (completion toggle, telescope, hover toolbar, date picker, delete), EditChartDueDate (calendar popover)
191
- - **Creation components**: AddActionStep (collapsible form, creates telescoped sub-chart), AddMasterChart (dialog with 3 entities + 3 relations), CreateChartForm (inline card form)
192
- - **Telescoping flow**: Click telescope → ChartEditor.createTelescopedChartFromAction() → new chart at level+1 → navigate
193
- - **Save flow**: ChartEditor.exportToJSONL() → POST /api/jsonl → backup → persist
194
-
195
- ### 3.6 api-mcp-interface.spec.md — REST API & MCP Server
196
- Defines:
197
- - **Authentication**: COAIAN_API_TOKEN env var (or auto-generated 64-char hex), Bearer token validation, withAuth middleware
198
- - **REST routes**: 6 groups (see Section 4 below)
199
- - **15 MCP tools**: Mapped 1:1 to REST operations (see Section 4 below)
200
- - **MCP transport**: stdio
201
- - **CoaiaVisualizerClient**: HTTP wrapper class for MCP server → REST API communication
202
- - **Agent scenario**: Claude Desktop configuration example + typical 6-step agent session
203
-
204
- ### 3.7 cli-mode.spec.md — CLI & Deployment
205
- Defines:
206
- - **CLI flags**: --memory-path, --port, --docker, --docker-image, --pull, --live, --poll-interval, --auto-play, --audio-dir, --no-open, --help
207
- - **Environment variables**: COAIAN_MF, COAIAV_MEMORY_PATH, COAIAV_PORT, COAIAV_LIVE, etc.
208
- - **Configuration priority**: CLI flags > env vars > .env file > defaults
209
- - **Local mode**: Spawns `npm run dev`, waits 3s, auto-opens browser, SIGINT graceful shutdown
210
- - **Docker mode**: `docker run --rm -p -v -e` with CONTAINER_PORT=4321
211
- - **Dockerfile**: Two-stage node:22-alpine build, VOLUME /data, EXPOSE 4321
212
- - **npm binary**: `coaia-visualizer` → `dist/cli.js`
213
-
214
- ### 3.8 narrative-beats-display.spec.md — Story Layer
215
- Defines:
216
- - **NarrativeBeats component**: Props = `{ beats: EntityRecord[] }`
217
- - **Beat metadata**: act (number), type_dramatic (string), universes (string[]), timestamp, narrative.description, narrative.prose, narrative.lessons
218
- - **Render**: Card with act/type header, universe badges, description, quoted prose, bulleted lessons
219
- - **Three universes**: engineer-world, ceremony-world, story-engine-world
220
- - **Empty state**: "No narrative beats documented yet"
221
- - **Placement**: Between Structural Tension section and Actions/Relations tabs
222
-
223
- ### 3.9 relation-graph-visualization.spec.md — Entity Connections
224
- Defines:
225
- - **RelationGraph component**: Props = `{ chart: Chart, data: ParsedData }`
226
- - **Grouping**: Relations reduced into type-keyed groups with counts
227
- - **Display**: Badge per relation type, from→to pairs with entity observation previews
228
- - **4 relation types**: contains, creates_tension_with, advances_toward, documents
229
- - **Integration**: Tab alongside actions in chart detail views
230
-
231
- ### 3.10 ui-component-library.spec.md — UI Primitives
232
- Defines:
233
- - **12 UI primitives**: Badge (4 variants), Button (6 variants, 6 sizes), Card (+6 sub-components), Dialog, Input, Label, Textarea, Tabs, Calendar, Popover, ScrollArea, Separator
234
- - **cn() utility**: clsx + tailwind-merge for safe class composition
235
- - **Theme system**: next-themes provider (default: dark), ThemeToggle (hydration-safe)
236
- - **Color tokens**: chart-1 (teal/outcomes), chart-2 (amber/reality), chart-3 (beats), chart-4 (stats)
237
- - **DataStats**: 4-card grid (Charts, Actions completed/total, Entities, Relations)
238
- - **LiveIndicator**: Animated green pulse when live data detected
239
- - **FileUpload**: Drag-drop + click-to-browse for .jsonl/.txt
240
-
241
- ### 3.11 planning-integration.spec.md — 🔮 FUTURE
242
- Aspirational spec for visualizing charts born from coaia-planning's `plan_to_stc` tool:
243
- - Plan source badge with confidence scores
244
- - Bidirectional sync status (synced/diverged/conflict)
245
- - Plan section mapping for action provenance
246
- - Confidence-based color coding (≥0.9 default, 0.7-0.89 amber, <0.5 red)
247
- - Re-sync trigger to push edits back to plan markdown
248
- - 8 new UI components, 4 new API endpoints proposed
249
-
250
- ### 3.12 pde-integration.spec.md — 🔮 FUTURE
251
- Aspirational spec for visualizing charts born from PDE decomposition:
252
- - Four Directions Medicine Wheel quadrant layout (EAST/SOUTH/WEST/NORTH)
253
- - PDE source linking with decomposition provenance trail
254
- - Implicit intent badges (⚡ Inferred)
255
- - Confidence bars per action step
256
- - Direction-based action grouping
257
- - 8 new UI components proposed
258
-
259
- ### 3.13 accountability-responsibility.rispec.md — Accountability/Responsibility
260
- Medium-priority spec for rendering accountability/responsibility distinctions:
261
- - Chart header: accountability badge (who is accountable for the outcome)
262
- - Action steps: inline responsibility indicators
263
- - Delegation chain view (optional panel)
264
- - Filter/group by responsible entity type (human/AI/pair)
265
- - Consumes metadata.accountability and metadata.responsibility from entities
266
-
267
- ### 3.14 relation-to-mcp-structural-thinking.kin.md — Kinship Document
268
- Kinship relationship between coaia-visualizer and mcp-structural-thinking:
269
- - Envisioned: three-universe validation scores as visual badges per chart
270
- - Reactive pattern highlights inline in chart text
271
- - Consensus status (✅/❌) on chart headers
272
- - coaia-visualizer owns rendering UX; mcp-structural-thinking provides data
273
-
274
- ---
275
-
276
- ## 4. MCP Tools (15 Tools)
277
-
278
- The MCP server runs as a separate process (`mcp/src/index.ts`) communicating over stdio. It wraps the REST API via `CoaiaVisualizerClient`.
279
-
280
- | # | Tool | Required Args | Optional Args | REST Mapping |
281
- |---|------|---------------|---------------|:-------------|
282
- | 1 | `list_charts` | — | level, rootOnly | GET /api/charts |
283
- | 2 | `get_chart` | chartId | — | GET /api/charts/{id} |
284
- | 3 | `create_chart` | desiredOutcome, currentReality | dueDate, parentChartId | POST /api/charts |
285
- | 4 | `update_chart` | chartId | desiredOutcome, currentReality, dueDate | POST /api/charts/{id} |
286
- | 5 | `add_action_step` | parentChartId, actionStepTitle, currentReality | dueDate | POST /api/charts/{id} |
287
- | 6 | `update_action_step` | chartId, actionName, description | — | POST /api/charts/{id} |
288
- | 7 | `mark_action_complete` | chartId, actionStepName | — | POST /api/charts/{id} |
289
- | 8 | `update_action_progress` | chartId, actionStepName, progressObservation | updateCurrentReality | POST /api/charts/{id} |
290
- | 9 | `update_current_reality` | chartId, newObservations | — | POST /api/charts/{id} |
291
- | 10 | `toggle_action_completion` | chartId, actionName | — | POST /api/charts/{id} |
292
- | 11 | `delete_action_step` | chartId, actionName | — | POST /api/charts/{id} |
293
- | 12 | `create_telescoped_chart` | chartId, actionName | — | POST /api/charts/{id} |
294
- | 13 | `delete_chart` | chartId | — | DELETE /api/charts/{id} |
295
- | 14 | `search_charts` | — | q, level, completed, hasActions | GET /api/charts/search |
296
- | 15 | `get_chart_progress` | chartId | — | GET /api/charts/{id} + compute |
297
-
298
- ### Tool Response Format
299
- ```json
300
- {
301
- "content": [{ "type": "text", "text": "<JSON string>" }],
302
- "isError": false
303
- }
304
- ```
305
-
306
- ---
307
-
308
- ## 5. Key Patterns
309
-
310
- ### 5.1 JSONL Entity/Relation Model
311
-
312
- All data is stored as flat JSONL — one JSON object per line. Two record types:
313
-
314
- **EntityRecord** — 5 entity types:
315
- - `structural_tension_chart` — chart container
316
- - `desired_outcome` — the creative vision
317
- - `current_reality` — honest assessment of what is
318
- - `action_step` — step toward desired outcome
319
- - `narrative_beat` — story documentation
320
-
321
- **RelationRecord** — 4 relation types:
322
- - `contains` — chart contains outcome/reality/action
323
- - `creates_tension_with` — reality creates tension with outcome
324
- - `advances_toward` — action/sub-chart advances toward parent outcome
325
- - `documents` — beat documents chart activity
326
-
327
- ### 5.2 Entity Naming Convention
328
-
329
- Entities follow the pattern `{chartId}_{entityType}`:
330
- ```
331
- chart_1_chart → structural_tension_chart entity
332
- chart_1_desired_outcome → desired_outcome entity
333
- chart_1_current_reality → current_reality entity
334
- chart_1_action_1 → action_step entity
335
- chart_1_beat_1 → narrative_beat entity
336
- ```
337
-
338
- Chart IDs auto-increment: find max N from existing `chart_N` entities, new chart = `chart_(N+1)`.
339
-
340
- ### 5.3 4-Pass Organization Algorithm
341
-
342
- ```
343
- Pass 1: Separate entities → Map<name, EntityRecord>, relations → RelationRecord[]
344
- Pass 2: Chart Shells structural_tension_chart entities → Chart objects with level, parentChart
345
- Pass 3: Populate Match entities to charts by name prefix (regex /^(chart_\d+)/)
346
- Pass 3.5: Telescoped Sub-charts (level > 0) → synthetic action entities in parent chart
347
- Pass 4: Hierarchy Build parent-child tree, identify rootCharts (level === 0)
348
- ```
349
-
350
- ### 5.4 Telescoping Pattern
351
-
352
- Actions can "telescope" into full sub-charts for deeper structural exploration:
353
-
354
- 1. User clicks telescope icon on an action step
355
- 2. `ChartEditor.createTelescopedChartFromAction()` creates new `chart_N` at `level+1`
356
- 3. Action's description becomes the new chart's desired outcome
357
- 4. Default current reality: `"Starting work on this action step"`
358
- 5. Original action flagged with `isTelescopedChart: true` and `telescopedChartId`
359
- 6. Navigation stack pushes current chart, navigates to new sub-chart
360
- 7. Due date auto-calculated as midpoint between now and parent's dueDate
361
-
362
- ### 5.5 ChartEditor Mutation Pattern (applyEdit)
363
-
364
- All edits follow a consistent pattern:
365
- ```typescript
366
- function applyEdit(editFn: (editor: ChartEditor) => void) {
367
- const editor = new ChartEditor(data) // Shallow clone current state
368
- editFn(editor) // Apply mutation
369
- const updatedData = editor.getUpdatedData() // Rebuild ParsedData
370
- onUpdate(updatedData) // Propagate to parent state
371
- }
372
- ```
373
-
374
- ### 5.6 Completion Propagation
375
-
376
- When an action is marked complete:
377
- 1. `completionStatus = true`, `completedAt` set to ISO timestamp
378
- 2. Parent chart's current_reality automatically updated with "Completed: ..." observation
379
- 3. Progress bar recalculates `(completed / total) * 100`
380
-
381
- ### 5.7 Save Flow with Backup
382
-
383
- ```
384
- ChartEditor.exportToJSONL() → entities first, relations second (one per line)
385
- POST /api/jsonl → API creates timestamped backup → writes new content
386
- hasUnsavedChanges = false → toast notification
387
- ```
388
-
389
- ### 5.8 Live Polling
390
-
391
- When `NEXT_PUBLIC_LIVE_MODE=true`:
392
- 1. `useLivePolling` hook polls `GET /api/watch` at configurable interval
393
- 2. Compares `beatCount` with cached value
394
- 3. If count increased → triggers full data reload from filesystem
395
- 4. `isLive` flag flashes the LiveIndicator for 2 seconds
396
-
397
- ---
398
-
399
- ## 6. Package Exports (Reusable Surface)
400
-
401
- The `index.tsx` entry point exports everything needed for external consumption:
402
-
403
- ### Types
404
- - `EntityRecord`, `RelationRecord`, `JSONLRecord`, `Chart`, `ParsedData`
405
-
406
- ### Core Logic
407
- - `parseJSONL(content: string): JSONLRecord[]`
408
- - `organizeData(records: JSONLRecord[]): ParsedData`
409
- - `getChartSummary(chart: Chart): string`
410
- - `getChartProgress(chart: Chart): number`
411
- - `cn(...inputs: ClassValue[]): string`
412
-
413
- ### Hooks
414
- - `useLivePolling` — file-watching polling hook
415
- - `useToast` — toast hook (inactive; sonner used directly)
416
-
417
- ### Application Components (16)
418
- - `FileUpload`, `ChartList`, `ChartDetailEditable`, `ChartDetail`
419
- - `DataStats`, `CreateChartForm`, `NarrativeBeats`, `LiveIndicator`
420
- - `ThemeToggle`, `EditDesiredOutcome`, `EditCurrentReality`, `EditActionStep`
421
- - `EditChartDueDate`, `AddActionStep`, `AddMasterChart`
422
-
423
- ### UI Primitives (12)
424
- - `Badge`, `Button`, `Calendar`, `Card` (+5 sub-components)
425
- - `Dialog` (+6 sub-components), `Input`, `Label`, `Popover` (+2 sub-components)
426
- - `ScrollArea`, `Separator`, `Tabs` (+3 sub-components), `Textarea`
427
-
428
- ---
429
-
430
- ## 7. Dependencies Analysis
431
-
432
- ### Production Dependencies (42 packages)
433
-
434
- | Category | Packages |
435
- |:---|:---|
436
- | **Framework** | next 16.0.10, react 19.2.0, react-dom 19.2.0 |
437
- | **UI Primitives** | 20 @radix-ui/* packages (accordion through tooltip) |
438
- | **Styling** | class-variance-authority, clsx, tailwind-merge, tailwindcss-animate |
439
- | **Forms** | react-hook-form, @hookform/resolvers, zod |
440
- | **Charting** | recharts 2.15.4 |
441
- | **Date** | date-fns 4.1.0, react-day-picker 9.8.0 |
442
- | **MCP** | @modelcontextprotocol/sdk 1.25.2 |
443
- | **UI Extras** | lucide-react, sonner, cmdk, vaul, input-otp, embla-carousel-react, react-resizable-panels |
444
- | **Theme** | next-themes |
445
- | **CLI** | minimist, @types/minimist, dotenv |
446
- | **Validation** | @cfworker/json-schema |
447
- | **Analytics** | @vercel/analytics |
448
-
449
- ### Dev Dependencies (7 packages)
450
- - @playwright/test, @tailwindcss/postcss, @types/node, @types/react, @types/react-dom, postcss, tailwindcss, tw-animate-css, typescript
451
-
452
- ### MCP Server Dependencies (separate package)
453
- - @modelcontextprotocol/sdk ^0.6.0, dotenv ^17.2.3
454
-
455
- ### Note on Dependency Weight
456
- The 20 Radix UI packages are the heaviest dependency cluster. Many are imported by shadcn patterns but not all are actively used by current components (e.g., accordion, avatar, context-menu, hover-card, menubar, navigation-menu, radio-group, slider, switch, toggle, toggle-group are present in package.json but have no corresponding component in `components/ui/`). A reusable package extraction could trim these significantly.
457
-
458
- ---
459
-
460
- ## 8. Kinship & Ecosystem Position
461
-
462
- From KINSHIP.md:
463
-
464
- - **Ancestor**: `coaia-narrative` — defines the JSONL schema this tool reads
465
- - **Siblings**: `coaia-pde` (produces JSONL), `coaia-planning` (produces JSONL), `mia-code/miaco` (creates charts)
466
- - **Role**: Network servant — serves STC charts as interactive web UI and exposes them over MCP/API
467
- - **Steward**: Guillaume (jgwill)
468
- - **Boundaries**: Does NOT define schema (reads coaia-narrative format), does NOT decompose prompts or create charts (only visualizes/edits)
469
-
470
- ---
471
-
472
- ## 9. Reusable Package Design Considerations
473
-
474
- ### Already Reusable
475
- 1. **Type system** (`lib/types.ts`) — 40 lines, zero dependencies, fully portable
476
- 2. **JSONL parser** (`lib/jsonl-parser.ts`) — 179 lines, depends only on types.ts
477
- 3. **ChartEditor** (`lib/chart-editor.ts`) — 576 lines, depends only on types.ts
478
- 4. **Package exports** (`index.tsx`) — already structured for external consumption
479
-
480
- ### Extraction-Ready
481
- 1. **UI primitives** (`components/ui/`) — 12 shadcn components, standard patterns, theme-dependent
482
- 2. **Application components** — depend on UI primitives + lib/types + lib/jsonl-parser
483
- 3. **Hooks** — useLivePolling is self-contained (needs API endpoint)
484
-
485
- ### Tightly Coupled
486
- 1. **API routes** (`app/api/`) — Next.js App Router specific, env-var dependent
487
- 2. **MCP server** (`mcp/`) — already a separate package, couples to REST API via HTTP
488
- 3. **CLI** (`cli.ts`) — depends on package directory structure, spawns processes
489
- 4. **Page orchestrator** (`app/page.tsx`) — top-level state management, not extractable
490
-
491
- ### Recommendations for Reusable Package
492
- 1. Extract `lib/` as a standalone `coaia-visualizer-core` package (types + parser + editor, ~800 lines, zero React dependency)
493
- 2. Extract `components/` as a `coaia-visualizer-components` package (requires React 19 + Radix + Tailwind)
494
- 3. Keep `mcp/` as its own package (already structured this way)
495
- 4. Keep API routes and page orchestrator in the Next.js app
496
-
497
- ---
498
-
499
- ## 10. Quality & Testing
500
-
501
- - **Playwright tests** (`test-scripts/`) for E2E testing
502
- - **Parse resilience**: Malformed lines logged via console.error and skipped (never crash)
503
- - **Round-trip fidelity**: parseJSONL(exportToJSONL(data)) produces equivalent ParsedData
504
- - **Backup safety**: Every write operation creates timestamped backup
505
- - **Auth**: Bearer token on all mutating endpoints (COAIAN_API_TOKEN or auto-generated)
506
- - **JSONL validity**: All exported content is one JSON object per line
507
-
508
- ---
509
-
510
- *Report complete. All 14 rispecs read. All source directories explored. Ready for reusable package design work.*
package/components.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema.json",
3
- "style": "new-york",
4
- "rsc": true,
5
- "tsx": true,
6
- "tailwind": {
7
- "config": "",
8
- "css": "app/globals.css",
9
- "baseColor": "neutral",
10
- "cssVariables": true,
11
- "prefix": ""
12
- },
13
- "aliases": {
14
- "components": "@/components",
15
- "utils": "@/lib/utils",
16
- "ui": "@/components/ui",
17
- "lib": "@/lib",
18
- "hooks": "@/hooks"
19
- },
20
- "iconLibrary": "lucide"
21
- }