owflow 0.1.1 → 0.1.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 (104) hide show
  1. package/README.md +8 -1
  2. package/dist/agents/bottleneck-analyzer.md +329 -0
  3. package/dist/agents/code-quality-pragmatist.md +354 -0
  4. package/dist/agents/code-reviewer.md +239 -0
  5. package/dist/agents/codebase-analysis-reporter.md +246 -0
  6. package/dist/agents/docs-operator.md +23 -0
  7. package/dist/agents/e2e-test-verifier.md +448 -0
  8. package/dist/agents/gap-analyzer.md +502 -0
  9. package/dist/agents/implementation-completeness-checker.md +220 -0
  10. package/dist/agents/implementation-planner.md +309 -0
  11. package/dist/agents/information-gatherer.md +691 -0
  12. package/dist/agents/production-readiness-checker.md +279 -0
  13. package/dist/agents/project-analyzer.md +404 -0
  14. package/dist/agents/reality-assessor.md +366 -0
  15. package/dist/agents/research-planner.md +447 -0
  16. package/dist/agents/research-synthesizer.md +401 -0
  17. package/dist/agents/solution-brainstormer.md +257 -0
  18. package/dist/agents/solution-designer.md +372 -0
  19. package/dist/agents/spec-auditor.md +298 -0
  20. package/dist/agents/specification-creator.md +334 -0
  21. package/dist/agents/task-classifier.md +462 -0
  22. package/dist/agents/task-group-implementer.md +284 -0
  23. package/dist/agents/test-suite-runner.md +195 -0
  24. package/dist/agents/ui-mockup-generator.md +369 -0
  25. package/dist/agents/user-docs-generator.md +509 -0
  26. package/dist/commands/development.md +37 -0
  27. package/dist/commands/flow-init.md +37 -0
  28. package/dist/commands/migration.md +37 -0
  29. package/dist/commands/performance.md +37 -0
  30. package/dist/commands/product-design.md +37 -0
  31. package/dist/commands/quick-bugfix.md +37 -0
  32. package/dist/commands/quick-dev.md +140 -0
  33. package/dist/commands/quick-plan.md +132 -0
  34. package/dist/commands/research.md +37 -0
  35. package/dist/commands/reviews-code.md +90 -0
  36. package/dist/commands/reviews-pragmatic.md +99 -0
  37. package/dist/commands/reviews-production-readiness.md +113 -0
  38. package/dist/commands/reviews-reality-check.md +110 -0
  39. package/dist/commands/reviews-spec-audit.md +114 -0
  40. package/dist/commands/standards-discover.md +37 -0
  41. package/dist/commands/standards-update.md +37 -0
  42. package/dist/commands/work.md +284 -0
  43. package/dist/index.js +3 -2
  44. package/dist/skills/codebase-analyzer/SKILL.md +162 -0
  45. package/dist/skills/codebase-analyzer/references/code-analysis.md +63 -0
  46. package/dist/skills/codebase-analyzer/references/combined.md +31 -0
  47. package/dist/skills/codebase-analyzer/references/context-discovery.md +63 -0
  48. package/dist/skills/codebase-analyzer/references/file-discovery.md +51 -0
  49. package/dist/skills/codebase-analyzer/references/migration-target.md +23 -0
  50. package/dist/skills/codebase-analyzer/references/pattern-mining.md +22 -0
  51. package/dist/skills/development/SKILL.md +669 -0
  52. package/dist/skills/docs-manager/SKILL.md +379 -0
  53. package/dist/skills/docs-manager/docs/INDEX.md +199 -0
  54. package/dist/skills/docs-manager/docs/standards/backend/api.md +25 -0
  55. package/dist/skills/docs-manager/docs/standards/backend/migrations.md +22 -0
  56. package/dist/skills/docs-manager/docs/standards/backend/models.md +25 -0
  57. package/dist/skills/docs-manager/docs/standards/backend/queries.md +22 -0
  58. package/dist/skills/docs-manager/docs/standards/frontend/accessibility.md +25 -0
  59. package/dist/skills/docs-manager/docs/standards/frontend/components.md +28 -0
  60. package/dist/skills/docs-manager/docs/standards/frontend/css.md +16 -0
  61. package/dist/skills/docs-manager/docs/standards/frontend/responsive.md +28 -0
  62. package/dist/skills/docs-manager/docs/standards/global/coding-style.md +25 -0
  63. package/dist/skills/docs-manager/docs/standards/global/commenting.md +10 -0
  64. package/dist/skills/docs-manager/docs/standards/global/conventions.md +31 -0
  65. package/dist/skills/docs-manager/docs/standards/global/error-handling.md +22 -0
  66. package/dist/skills/docs-manager/docs/standards/global/minimal-implementation.md +22 -0
  67. package/dist/skills/docs-manager/docs/standards/global/validation.md +28 -0
  68. package/dist/skills/docs-manager/docs/standards/testing/test-writing.md +25 -0
  69. package/dist/skills/docs-manager/references/claude-md-template.md +29 -0
  70. package/dist/skills/docs-manager/references/index-md-template.md +73 -0
  71. package/dist/skills/flow-init/SKILL.md +198 -0
  72. package/dist/skills/flow-init/references/architecture-template.md +45 -0
  73. package/dist/skills/flow-init/references/roadmap-templates.md +93 -0
  74. package/dist/skills/flow-init/references/tech-stack-template.md +70 -0
  75. package/dist/skills/flow-init/references/vision-templates.md +75 -0
  76. package/dist/skills/implementation-plan-executor/SKILL.md +378 -0
  77. package/dist/skills/implementation-verifier/SKILL.md +307 -0
  78. package/dist/skills/migration/SKILL.md +380 -0
  79. package/dist/skills/migration/references/migration-strategies.md +397 -0
  80. package/dist/skills/migration/references/migration-types.md +437 -0
  81. package/dist/skills/orchestrator-framework/SKILL.md +65 -0
  82. package/dist/skills/orchestrator-framework/references/orchestrator-creation-checklist.md +47 -0
  83. package/dist/skills/orchestrator-framework/references/orchestrator-patterns.md +329 -0
  84. package/dist/skills/performance/SKILL.md +418 -0
  85. package/dist/skills/performance/references/performance-optimization-guide.md +365 -0
  86. package/dist/skills/product-design/SKILL.md +843 -0
  87. package/dist/skills/product-design/references/characteristic-detection.md +92 -0
  88. package/dist/skills/product-design/references/interaction-patterns.md +206 -0
  89. package/dist/skills/product-design/references/visual-companion.md +190 -0
  90. package/dist/skills/product-design/server/index.ts +359 -0
  91. package/dist/skills/product-design/server/template.html +256 -0
  92. package/dist/skills/quick-bugfix/SKILL.md +241 -0
  93. package/dist/skills/research/SKILL.md +493 -0
  94. package/dist/skills/research/references/brainstorming-techniques.md +84 -0
  95. package/dist/skills/research/references/design-techniques.md +40 -0
  96. package/dist/skills/research/references/research-methodologies.md +710 -0
  97. package/dist/skills/standards-discover/SKILL.md +236 -0
  98. package/dist/skills/standards-discover/references/aggregation-strategy.md +76 -0
  99. package/dist/skills/standards-discover/references/code-pattern-prompt.md +68 -0
  100. package/dist/skills/standards-discover/references/config-analyzer-prompt.md +67 -0
  101. package/dist/skills/standards-discover/references/docs-extractor-prompt.md +65 -0
  102. package/dist/skills/standards-discover/references/external-analyzer-prompt.md +75 -0
  103. package/dist/skills/standards-update/SKILL.md +159 -0
  104. package/package.json +44 -43
@@ -0,0 +1,92 @@
1
+ # Characteristic Detection
2
+
3
+ Guides how the product-design orchestrator detects design characteristics to adapt phase depth. Prevents "specification as bureaucracy" for simple tasks while ensuring complex designs get thorough exploration.
4
+
5
+ ---
6
+
7
+ ## Purpose
8
+
9
+ Not every design task needs the same depth. A quick "add a settings page" should not go through the same 8-question exploration as "design a new SaaS product from scratch." Characteristic detection runs once during Phase 0 (Initialization) and shapes every subsequent phase.
10
+
11
+ **Core idea**: Detect early, confirm with user, adapt throughout.
12
+
13
+ ---
14
+
15
+ ## Six Design Characteristics
16
+
17
+ | Characteristic | Detection Signals | Mutually Exclusive With |
18
+ | ---------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------- |
19
+ | `is_greenfield` | No existing codebase, "new product/app/tool" language, no `.owflow/docs/` present | `is_enhancement` |
20
+ | `is_enhancement` | Existing codebase, "add/improve/enhance/extend" language, references existing features | `is_greenfield` |
21
+ | `is_ui_focused` | "UI/UX/interface/page/screen/dashboard/form" language, UI framework detected in codebase | -- (can coexist with `is_backend`) |
22
+ | `is_backend` | "API/endpoint/service/data/model/schema" language, no UI framework detected | -- (can coexist with `is_ui_focused`) |
23
+ | `is_complex` | Long description (>200 words), multiple user types mentioned, cross-cutting concerns, safety-critical domain | `is_simple` |
24
+ | `is_simple` | Short description (<50 words), single clear feature, well-defined scope | `is_complex` |
25
+
26
+ **Mutual exclusivity**: `is_greenfield` and `is_enhancement` cannot both be true. `is_complex` and `is_simple` cannot both be true. UI and backend characteristics can coexist (full-stack designs).
27
+
28
+ **Default when ambiguous**: When signals are mixed or insufficient, default to higher complexity. Better to ask too many questions and have the user approve-and-move-on than to miss critical context.
29
+
30
+ ---
31
+
32
+ ## Phase Activation Matrix
33
+
34
+ Characteristics gate which phases activate and at what depth.
35
+
36
+ | Phase | is_greenfield | is_enhancement | is_ui_focused | is_backend | is_complex | is_simple |
37
+ | ----------------------- | ----------------------- | -------------------------------- | ------------- | ---------- | -------------- | ------------ |
38
+ | 1 (Context Synthesis) | User context only | Codebase + user context | -- | -- | -- | -- |
39
+ | 2 (Problem Exploration) | Full depth (8-10 Qs) | Abbreviated (2-3 Qs) | -- | -- | Full depth | Abbreviated |
40
+ | 3 (Personas) | Full (2-3 personas) | Skipped | -- | -- | Full | Skipped |
41
+ | 4 (Ideation) | Full brainstorm | Constrained by existing patterns | -- | -- | Full | Abbreviated |
42
+ | 5 (Convergence) | Multiple decision areas | Focused on enhancement scope | -- | -- | Multiple areas | 1-2 areas |
43
+ | 6 (Specification) | Comprehensive sections | Targeted sections | -- | -- | 6-8 sections | 3-4 sections |
44
+ | 7 (Visual Prototyping) | -- | -- | Active | Skipped | -- | -- |
45
+ | 8 (Refinement) | Full review | Targeted review | -- | -- | Full review | Quick review |
46
+
47
+ **Reading the matrix**: "--" means the characteristic does not influence that phase. Multiple characteristics combine: a `is_greenfield + is_complex + is_ui_focused` task gets full depth everywhere plus visual prototyping.
48
+
49
+ ---
50
+
51
+ ## Adaptive Depth Scaling
52
+
53
+ The complexity axis (`is_simple` / standard / `is_complex`) controls depth across interactive phases.
54
+
55
+ | Complexity | Exploration Questions | Convergence Areas | Spec Sections | Section Depth | Refinement Patience |
56
+ | -------------------- | --------------------- | ----------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
57
+ | Simple | 2-3 | 1-2 | 3-4 | Summary: captures _what_ to build (~20-50 lines/section) | 2 iterations (soft cap) |
58
+ | Standard | 4-6 | 2-3 | 5-6 | Design-level: _what_ + key _how_ decisions (~50-100 lines/section) | 3 iterations (soft cap) |
59
+ | Complex / Greenfield | 8-10 | 3-5 | 6-8 | Implementation-level: _what_ + _how_ + edge cases + schemas/contracts (~100-300 lines/section). Developer should be able to start implementation from sections alone. | 3 iterations (soft cap) |
60
+
61
+ **Standard** is the implicit default when neither `is_simple` nor `is_complex` is detected.
62
+
63
+ **Refinement patience**: The soft cap on iterative refinement loops before suggesting approval. Not a hard limit -- users can always extend with "One more revision."
64
+
65
+ ---
66
+
67
+ ## User Override Pattern
68
+
69
+ Detected characteristics are presented to the user at the Phase 0 exit gate for confirmation.
70
+
71
+ **Flow**:
72
+
73
+ 1. Orchestrator detects characteristics from task description and codebase signals
74
+ 2. Phase 0 exit gate presents detected characteristics with rationale
75
+ 3. User confirms or corrects misclassification
76
+ 4. Override updates `design_characteristics` in orchestrator-state.yml before any phase uses them
77
+
78
+ **Why this matters**: Automated detection can misread intent. A short description might describe a complex system. An existing codebase might be getting a greenfield module. User confirmation prevents the workflow from optimizing for the wrong depth.
79
+
80
+ ---
81
+
82
+ ## Detection Quality Guidance
83
+
84
+ **Prefer over-detection**: When description is ambiguous, lean toward higher complexity. The cost of unnecessary depth (user approves-and-moves-on through questions) is much lower than the cost of insufficient depth (missing critical requirements discovered during implementation).
85
+
86
+ **Codebase signals supplement, not override**: A detected UI framework suggests `is_ui_focused`, but the user's task description takes precedence. If they say "add an API endpoint" in a React codebase, trust the description.
87
+
88
+ **Re-detection is not supported**: Characteristics are set once during Phase 0 and confirmed by the user. They do not change mid-workflow. If scope changes significantly, the user should start a new design task.
89
+
90
+ ---
91
+
92
+ This reference provides detection patterns and depth-scaling frameworks. The orchestrator's SKILL.md defines the specific phase logic that consumes these characteristics.
@@ -0,0 +1,206 @@
1
+ # Interaction Patterns
2
+
3
+ Guides interaction quality in the product-design orchestrator's interactive phases. Defines two cognitive modes, the iterative refinement loop, and question option design.
4
+
5
+ ---
6
+
7
+ ## Purpose
8
+
9
+ Product design is a conversation, not a form. The orchestrator alternates between exploring the problem space and converging on solutions. These patterns ensure that interaction feels like working with a thoughtful design partner rather than filling out a requirements template.
10
+
11
+ **Core idea**: Exploration opens possibilities. Convergence narrows them. Both require different interaction strategies.
12
+
13
+ ---
14
+
15
+ ## Cognitive Mode Framework
16
+
17
+ ### Exploration Mode
18
+
19
+ **When**: Phases 2 (Problem Exploration) and 3 (Persona Development)
20
+
21
+ **Purpose**: Understand the design space before proposing solutions. Discover constraints, motivations, and context that shape the design.
22
+
23
+ **Principles**:
24
+
25
+ - **Avoid anchoring bias**: Do not propose solutions during exploration. Premature solutions close off discovery.
26
+ - **One major question at a time**: Deep understanding of one area before moving to the next. Batch questions overwhelm and produce shallow answers.
27
+ - **Context-aware questions**: Reference codebase analysis findings, user-supplied context, and previous answers. Generic questions waste the user's time.
28
+ - **"Need more info" escape hatches**: Always allow the user to say "I need to think about this" or "Not sure yet" without blocking progress.
29
+
30
+ **Signal to user**: Announce exploration mode explicitly to set expectations.
31
+
32
+ > "Let's explore who this feature is really for and what problem it solves..."
33
+
34
+ **Anti-pattern**: Asking "What do you want?" when you have enough context to ask something specific. Exploration questions should demonstrate understanding of the domain.
35
+
36
+ ### Convergence Mode
37
+
38
+ **When**: Phases 5 (Idea Convergence), 6 (Specification), 7 (Visual Prototyping review), 8 (Specification Refinement)
39
+
40
+ **Purpose**: Narrow down from explored possibilities to concrete decisions. Present drafts for reaction rather than asking open-ended questions.
41
+
42
+ **Principles**:
43
+
44
+ - **Propose-and-refine**: "Editing is cognitively easier than creating." Present concrete drafts for the user to react to rather than asking them to create from scratch.
45
+ - **Structured drafts**: Present complete artifacts (not summaries or bullet points) so the user can evaluate the actual output.
46
+ - **Aspect-specific feedback**: Guide refinement toward specific dimensions rather than asking "What would you change?"
47
+
48
+ **Signal to user**: Announce convergence mode to mark the narrative transition.
49
+
50
+ > "Based on our exploration, here's what I think we've agreed on..."
51
+
52
+ ### Mode Transition
53
+
54
+ Explicitly announce transitions between modes. This creates a narrative arc that helps the user understand where they are in the process.
55
+
56
+ > "We've explored the problem space thoroughly. Now let me synthesize what we've discussed into a concrete direction."
57
+
58
+ **Why explicit transitions matter**: Without them, the shift from open-ended questions to concrete proposals feels abrupt. The user may still be in exploration mindset when you need them to evaluate specifics.
59
+
60
+ ---
61
+
62
+ ## Iterative Refinement Loop Pattern
63
+
64
+ A new owflow pattern for convergence points where artifacts need user approval.
65
+
66
+ ### When to Apply
67
+
68
+ At every convergence point where the orchestrator produces a draft artifact:
69
+
70
+ - Phase 2: Problem statement synthesis
71
+ - Phase 5: Idea convergence and direction selection
72
+ - Phase 6: Specification sections
73
+ - Phase 7: Visual mockups
74
+ - Phase 8: Final specification review
75
+
76
+ ### Flow
77
+
78
+ ```
79
+ Present complete draft → question (approve / change / rethink / add detail / explain)
80
+ → [revision] → present complete revised draft → question (same options)
81
+ → [after soft cap] → question (approve current / one more revision / step back)
82
+ ```
83
+
84
+ **Standard options**: "Approve and continue", "Change [aspect A]", "Change [aspect B]", "Rethink the approach", "Add more detail", "Let me explain my thinking"
85
+
86
+ **Soft cap options** (after iteration limit): "Approve current version and move on", "One more revision", "Step back and rethink"
87
+
88
+ ### Key Rules
89
+
90
+ **Complete drafts always**: Every revision presents the COMPLETE updated artifact. Never present a diff, a summary of changes, or a table of what changed. The user should be able to evaluate the artifact on its own merits without referencing the previous version.
91
+
92
+ **Soft cap, not hard limit**: `refinement_iterations.[phase]` tracks iteration count in orchestrator-state.yml. After reaching the soft cap (2 for simple tasks, 3 for standard/complex), the options shift to encourage approval. But the user can always choose "One more revision."
93
+
94
+ **"Rethink the approach"**: This is a significant action. It signals that incremental changes will not fix the problem. The orchestrator should step back, re-examine assumptions, and present a substantially different draft -- not a minor variation of the previous one.
95
+
96
+ **Special option in Phase 5**: "Explore more" triggers re-generation by returning to Phase 4 (Ideation) for fresh brainstorming. This acknowledges that sometimes none of the converged ideas feel right.
97
+
98
+ ### State Tracking
99
+
100
+ ```yaml
101
+ refinement_iterations:
102
+ phase_2: 1
103
+ phase_5: 0
104
+ phase_6_section_user_stories: 2
105
+ phase_7: 1
106
+ ```
107
+
108
+ Track per-phase (or per-section in Phase 6) to apply soft caps independently. A heavily-iterated persona definition should not consume the refinement budget for specification sections.
109
+
110
+ ---
111
+
112
+ ## question Option Design
113
+
114
+ Options are not just UI -- they shape the conversation. Well-designed options anticipate what the user is likely thinking.
115
+
116
+ ### Exploration Mode Options
117
+
118
+ Structure: topical choices + escape hatches
119
+
120
+ **Pattern**:
121
+
122
+ - 2-4 topical options that advance exploration in specific directions
123
+ - "Need more info" or "Not sure yet" option (does not block progress)
124
+ - "Let me explain my thinking" (open-ended escape hatch)
125
+
126
+ **Example** (Phase 2 exploration):
127
+
128
+ ```
129
+ - "The main problem is [user frustration with X]"
130
+ - "Actually, it's more about [business need Y]"
131
+ - "Both are important, but prioritize [X]"
132
+ - "Let me explain my thinking"
133
+ ```
134
+
135
+ **Why topical options work in exploration**: They demonstrate that the orchestrator is listening and synthesizing. The user confirms, corrects, or elaborates -- all of which deepen understanding faster than open-ended "What else should I know?"
136
+
137
+ ### Convergence Mode Options
138
+
139
+ Structure: approve + aspect-specific changes + structural options + escape hatch
140
+
141
+ **Pattern**:
142
+
143
+ - "Approve and continue" (always first)
144
+ - "Change [aspect A]" / "Change [aspect B]" (2-3 specific refinement targets)
145
+ - "Rethink the approach" / "Add more detail" (structural options)
146
+ - "Let me explain my thinking" (open-ended escape hatch)
147
+
148
+ **Aspect-specific "Change" options**: Anticipate the most likely refinement areas for the artifact type:
149
+
150
+ - For a persona: "Change role", "Change goals", "Change pain points"
151
+ - For a problem statement: "Change scope", "Change priority", "Change constraints"
152
+ - For a spec section: "Change requirements", "Change acceptance criteria", "Change scope"
153
+ - For a mockup: "Change layout", "Change content", "Change interactions"
154
+
155
+ ### Universal Rules
156
+
157
+ **Always include an open-ended escape hatch**: "Let me explain my thinking" covers cases where none of the structured options match the user's intent. Without it, users feel trapped in a multiple-choice quiz.
158
+
159
+ **Never present all decision areas in a single batch**: One area at a time with full context. Batch decisions produce shallow answers because users optimize for completion speed rather than quality.
160
+
161
+ **Order matters**: Put the most likely action first. In convergence, that is usually "Approve" (most drafts are close enough). In exploration, lead with the option that advances the conversation most.
162
+
163
+ ---
164
+
165
+ ## Interaction Quality Principles
166
+
167
+ ### Prose is the Conversation
168
+
169
+ Rich contextual prose BETWEEN question calls is the actual design conversation. question calls are punctuation marks -- they structure the conversation but do not replace it.
170
+
171
+ **Before asking**: Synthesize what you have learned. Show the user that their previous answer was heard and integrated.
172
+
173
+ > "Got it -- so the key constraint is that existing users should not need to re-learn navigation. That means we need to extend the current sidebar pattern rather than introducing a new navigation model."
174
+
175
+ **After receiving an answer**: Acknowledge and bridge to the next question or draft.
176
+
177
+ > "That makes sense. The two-persona approach (admin vs. viewer) gives us clear boundaries for feature scoping. Let me draft the admin persona first since they have the more complex workflow."
178
+
179
+ ### Synthesis Over Repetition
180
+
181
+ After each answer, synthesize -- do not merely acknowledge. The synthesis shows understanding and gives the user a chance to correct misinterpretation before it compounds.
182
+
183
+ **Pattern**: "So what I'm hearing is [synthesis]. [Bridge to next step]."
184
+
185
+ ### Mode Labels at Transitions
186
+
187
+ Every phase transition between exploration and convergence gets an explicit label. This is not optional -- users need the narrative context to understand why the interaction style is changing.
188
+
189
+ ---
190
+
191
+ ## Anti-Patterns
192
+
193
+ | Anti-Pattern | Why It Fails | Better Approach |
194
+ | ---------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------- |
195
+ | Summary table of changes across iterations | User must mentally diff two versions | Present complete revised draft every time |
196
+ | Skipping mode labels | User is confused by sudden shift from questions to proposals | Always announce "Now let's converge..." |
197
+ | Single-round approve-or-reject | No room for iterative refinement | Use the refinement loop with aspect-specific options |
198
+ | "What do you want?" in convergence | Shifts cognitive burden to user when you have enough to propose | Use propose-and-refine: present a draft |
199
+ | All decision areas in one batch | Produces shallow answers | One area at a time with full context |
200
+ | Form-filling: rapid-fire questions without synthesis | Feels like a bureaucratic intake process | Synthesize between questions, show understanding |
201
+ | Proposing solutions during exploration | Anchors thinking, closes off discovery | Explore fully before proposing |
202
+ | Generic questions ignoring context | Wastes user's time, signals lack of understanding | Reference codebase analysis and prior answers |
203
+
204
+ ---
205
+
206
+ This reference provides interaction patterns and frameworks. The orchestrator's SKILL.md defines the specific phase logic that applies these patterns.
@@ -0,0 +1,190 @@
1
+ # Visual Companion
2
+
3
+ Documents the browser-based visual companion architecture for the product-design orchestrator. Provides high-fidelity visual feedback by rendering HTML/CSS mockups in a browser during design sessions.
4
+
5
+ ---
6
+
7
+ ## Purpose
8
+
9
+ Terminal-based ASCII mockups are useful but limited. For UI-focused design tasks, seeing actual rendered HTML/CSS in a browser gives qualitatively better feedback. The visual companion provides this without requiring any external tools, npm packages, or design software.
10
+
11
+ **Core idea**: Orchestrator generates HTML/CSS, sends to a local server, browser renders it, user reviews and provides feedback in the terminal. Browser is read-only visual output -- all interaction stays in the terminal via question.
12
+
13
+ ---
14
+
15
+ ## Architecture Overview
16
+
17
+ ```
18
+ Orchestrator → POST /update → Node.js Server → SSE "refresh" → Browser (renders mockup)
19
+ ↓ user views
20
+ Terminal (question)
21
+ ```
22
+
23
+ **Data flow is one-directional**: Orchestrator pushes content to server, server pushes to browser, user reviews in browser, feedback flows through terminal. The browser never sends data back to the orchestrator.
24
+
25
+ ---
26
+
27
+ ## Zero-Dependency Principle
28
+
29
+ The server uses ONLY Node.js built-in modules: `http`, `fs`, `path`, `url`. No npm install required. No package.json needed.
30
+
31
+ **SSE over WebSocket**: Server-Sent Events replace WebSocket for simplicity. SSE works with the native browser `EventSource` API, requires no client library, and handles reconnection automatically. One-directional push (server to browser) is all we need.
32
+
33
+ **Why zero-dependency matters**: The visual companion starts inside a product-design workflow. Requiring `npm install` would add failure modes, slow down startup, and create version compatibility issues. Node.js built-in modules are sufficient for a local development server.
34
+
35
+ ---
36
+
37
+ ## Communication Protocol
38
+
39
+ | Endpoint | Method | Purpose | Request/Response |
40
+ |---|---|---|---|
41
+ | `/status` | GET | Health check | Response: `{"status":"ok","version":"1.0.0"}` |
42
+ | `/` | GET | Current mockup | Response: HTML page with mockup wrapped in template |
43
+ | `/events` | GET | SSE stream | Response: `text/event-stream`, sends `data: refresh\n\n` on update |
44
+ | `/update` | POST | Push new mockup | Body: `{type, title, html, css, annotations}` |
45
+
46
+ ### POST /update Body Schema
47
+
48
+ ```json
49
+ {
50
+ "type": "mockup",
51
+ "title": "Settings Page - Desktop",
52
+ "html": "<div class='settings'>...</div>",
53
+ "css": ".settings { padding: 1rem; }",
54
+ "annotations": [
55
+ {"selector": ".settings", "text": "Reuses existing card component"}
56
+ ]
57
+ }
58
+ ```
59
+
60
+ **Annotations**: Positioned tooltips overlaid on mockup elements. Togglable via the "Annotations" button in the UI header (on by default, preference persists via localStorage). Use for component reuse hints, integration points, and interaction hints — NOT for feature descriptions or requirements.
61
+
62
+ Example annotations:
63
+ - `{"selector": ".patient-card", "note": "Reuses existing <PatientCard> component"}`
64
+ - `{"selector": ".save-btn", "note": "Triggers webhook notification"}`
65
+ - `{"selector": ".drag-handle", "note": "Drag to reorder"}`
66
+
67
+ ---
68
+
69
+ ## Lifecycle
70
+
71
+ ### Startup
72
+
73
+ 1. Spawn server process: `node ${SKILL_DIR}/server/index.mjs`
74
+ 2. Port allocation: try 3847, fallback through 3848-3850
75
+ 3. Verify ready: poll `GET /status` until ok (timeout after 3 seconds)
76
+
77
+ ### Browser Opening
78
+
79
+ 1. **Primary**: Playwright MCP `browser_navigate` (if configured)
80
+ 2. **Fallback 1**: `open` command (macOS) / `xdg-open` (Linux)
81
+ 3. **Fallback 2**: Log URL for manual opening, continue with terminal-only review
82
+
83
+ ### Teardown
84
+
85
+ Kill server via `POST /shutdown` endpoint on:
86
+ - Workflow completion (Phase 8 sends POST /shutdown after final approval)
87
+ - Workflow cancellation
88
+
89
+ **PID file**: Server writes its PID to `{taskPath}/analysis/mockups/.visual-companion.pid` on startup. Cleaned up on shutdown, SIGTERM, and SIGINT. Enables reliable process identification.
90
+
91
+ **Stale server detection**: Phase 7 checks `/status` before starting a new server. The response includes `taskPath` — if it belongs to a different task, the server is stale and gets shut down via `POST /shutdown` before starting a new one.
92
+
93
+ ---
94
+
95
+ ## Graceful Degradation Matrix
96
+
97
+ The visual companion is an enhancement, not a requirement. Every failure has a fallback.
98
+
99
+ | Scenario | Detection | Fallback |
100
+ |---|---|---|
101
+ | Node.js not available | `which node` fails | ASCII mockups via ui-mockup-generator agent |
102
+ | Port 3847 in use | Server startup error (EADDRINUSE) | Try ports 3848-3850, then ASCII fallback |
103
+ | Playwright MCP not configured | MCP tool call fails | Log URL for manual browser opening |
104
+ | Browser fails to open | Playwright error + open command error | Log URL, continue with terminal-only review |
105
+ | Server crashes mid-session | `GET /status` returns error or timeout | Restart server; if 2nd failure, ASCII fallback |
106
+ | No issues | `GET /status` returns ok | Full visual companion experience |
107
+
108
+ **Degradation principle**: Never block the design workflow because the visual companion failed. The core design conversation happens in the terminal. Visual rendering is additive value.
109
+
110
+ ---
111
+
112
+ ## HTML Template Pattern
113
+
114
+ The server wraps mockup content in a base template that provides:
115
+
116
+ - **Viewport meta**: Responsive rendering matching common device widths
117
+ - **CSS reset**: Minimal reset so mockup styles render predictably
118
+ - **SSE client script**: `EventSource` connection to `/events` with auto-reconnect on disconnect
119
+ - **Annotation overlay script**: Renders positioned tooltips from annotation data
120
+ - **Placeholder state**: "Waiting for design mockup..." shown before first `POST /update`
121
+
122
+ **Template is server-side, not orchestrator-side**: The orchestrator sends only the mockup `html` and `css`. The server wraps it in the template. This keeps the orchestrator focused on design content rather than boilerplate.
123
+
124
+ **Auto-refresh behavior**: When the SSE stream receives a `refresh` event, the page reloads to fetch the updated mockup from `GET /`. No manual refresh needed.
125
+
126
+ ---
127
+
128
+ ## Integration with Phase 7 (Visual Prototyping)
129
+
130
+ Phase 7 follows this sequence when visual companion is available:
131
+
132
+ 1. **Check availability**: `GET /status` to see if server is already running
133
+ 2. **Start server if needed**: Spawn Node.js process, verify ready
134
+ 3. **Open browser**: Playwright MCP or open command or log URL
135
+ 4. **Generate mockup**: Create HTML/CSS from spec context and design decisions
136
+ 5. **Push to server**: `POST /update` with mockup content
137
+ 6. **Present for review**: question in terminal (user views mockup in browser)
138
+ 7. **Iterative refinement**: Revise mockup, re-POST, re-review (follows refinement loop pattern)
139
+ 8. **Save approved mockup**: Write final HTML/CSS to `analysis/mockups/` in task directory
140
+
141
+ **When visual companion is unavailable**: Phase 7 falls back to the `ui-mockup-generator` agent for ASCII mockups. The iterative refinement loop still applies -- only the rendering medium changes.
142
+
143
+ ### Mockup Generation Guidance
144
+
145
+ The orchestrator generates mockup HTML/CSS based on:
146
+ - Specification sections from Phase 6
147
+ - Design decisions from Phase 5 convergence
148
+ - Existing codebase UI patterns (from Phase 1 codebase analysis, if enhancement)
149
+ - Persona workflows from Phase 3 (if greenfield)
150
+
151
+ **Fidelity target**: Mid-fidelity. Enough structure and styling to evaluate layout, hierarchy, and flow. Not pixel-perfect production CSS. Focus on communicating the design intent, not building the final UI.
152
+
153
+ **What to generate** (user-facing wireframes/screens):
154
+ - Dashboard views, settings pages, list/detail screens
155
+ - Forms, modals, navigation bars, sidebars
156
+ - Data tables, cards, search/filter interfaces
157
+ - Empty states, error states, loading states
158
+ - Responsive layouts (desktop and mobile variations)
159
+
160
+ **What NOT to generate** (technical diagrams — these belong in analysis artifacts):
161
+ - System architecture diagrams
162
+ - Data flow charts, sequence diagrams
163
+ - Entity relationship diagrams
164
+ - Component dependency graphs
165
+
166
+ **Multiple screens**: Complex designs need multiple screens. The visual companion maintains a gallery — each `POST /update` adds a screen. Give each a descriptive title (e.g., "Patient Dashboard", "Settings - Notifications", "Error State - Network Failure"). The user can browse all screens via the gallery at `GET /`.
167
+
168
+ **Screen-to-screen navigation**: Add `data-screen="slug"` to interactive elements (links, buttons, cards) in mockup HTML. Clicking navigates to the target screen in the visual companion. The slug is the lowercase-hyphenated version of the screen title (e.g., "Settings Page" → `data-screen="settings-page"`). This creates an interactive prototype experience where the user can click through the flow.
169
+
170
+ ---
171
+
172
+ ## Server State & Persistence
173
+
174
+ The server maintains a screen gallery in memory and persists to disk:
175
+
176
+ - **Mockups array**: All POSTed screens (ordered, accessible by slug ID)
177
+ - **SSE clients**: Active EventSource connections for refresh notifications
178
+ - **Version counter**: Incremented on each update
179
+ - **Disk persistence**: Each POST automatically saves the rendered HTML to `{task_path}/analysis/mockups/{slug}.html` — pass `--task-path` when starting the server
180
+
181
+ **Routes**:
182
+ - `GET /` → Gallery index (grid of all screen cards)
183
+ - `GET /screen/{id}` → Individual screen with prev/next navigation
184
+ - `GET /latest` → Most recently POSTed screen (SSE refresh target)
185
+
186
+ Screens are saved to disk immediately on POST — if the session drops, mockups survive in `analysis/mockups/`.
187
+
188
+ ---
189
+
190
+ This reference provides the visual companion architecture and integration patterns. The server implementation lives in `server/index.mjs` and the orchestrator's SKILL.md defines the specific phase logic that uses the visual companion.