@trohde/earos 1.1.2 → 1.3.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.
Files changed (70) hide show
  1. package/assets/init/docs/getting-started.md +1 -1
  2. package/assets/init/docs/onboarding/agent-assisted.md +19 -19
  3. package/assets/init/docs/onboarding/first-assessment.md +18 -18
  4. package/assets/init/docs/onboarding/governed-review.md +10 -10
  5. package/assets/init/docs/onboarding/overview.md +15 -15
  6. package/assets/init/docs/onboarding/scaling-optimization.md +13 -13
  7. package/assets/init/docs/plans/2026-03-23-001-refactor-site-review-findings-plan.md +195 -0
  8. package/assets/init/docs/plans/2026-03-23-002-refactor-cli-review-findings-plan.md +736 -0
  9. package/assets/init/docs/profile-authoring-guide.md +5 -9
  10. package/assets/init/docs/terminology.md +1 -1
  11. package/bin.js +156 -36
  12. package/dist/assets/{_basePickBy-PmSUrUsK.js → _basePickBy-BlC_TeV6.js} +1 -1
  13. package/dist/assets/{_baseUniq-HuZouVIz.js → _baseUniq-CVy7rcC1.js} +1 -1
  14. package/dist/assets/{arc-CJFxtF3d.js → arc-Cd8wvd7z.js} +1 -1
  15. package/dist/assets/{architectureDiagram-2XIMDMQ5-XA-oU2UG.js → architectureDiagram-2XIMDMQ5-D_f4_aMp.js} +1 -1
  16. package/dist/assets/{blockDiagram-WCTKOSBZ-Oxp-wAST.js → blockDiagram-WCTKOSBZ-B-y6N5--.js} +1 -1
  17. package/dist/assets/{c4Diagram-IC4MRINW-D8m5hQH9.js → c4Diagram-IC4MRINW-C3-v3oNT.js} +1 -1
  18. package/dist/assets/channel-BSC0F15G.js +1 -0
  19. package/dist/assets/{chunk-4BX2VUAB-D2kBTn2O.js → chunk-4BX2VUAB-CMPwQN83.js} +1 -1
  20. package/dist/assets/{chunk-55IACEB6-Dxqrf5oZ.js → chunk-55IACEB6-Bdkfhvrr.js} +1 -1
  21. package/dist/assets/{chunk-FMBD7UC4-DoOEFFQC.js → chunk-FMBD7UC4-ptKQX5uF.js} +1 -1
  22. package/dist/assets/{chunk-JSJVCQXG-BerphV2K.js → chunk-JSJVCQXG-DO0UU_OX.js} +1 -1
  23. package/dist/assets/{chunk-KX2RTZJC-CxUAqT05.js → chunk-KX2RTZJC-DRj2OZnD.js} +1 -1
  24. package/dist/assets/{chunk-NQ4KR5QH-fCqZgFkU.js → chunk-NQ4KR5QH-C4Nsf7ww.js} +1 -1
  25. package/dist/assets/{chunk-QZHKN3VN-HlpHnJEy.js → chunk-QZHKN3VN-B1GO0Nwy.js} +1 -1
  26. package/dist/assets/{chunk-WL4C6EOR-D9yxAHyd.js → chunk-WL4C6EOR-lFR6fjR8.js} +1 -1
  27. package/dist/assets/classDiagram-VBA2DB6C-BHDWMOEz.js +1 -0
  28. package/dist/assets/classDiagram-v2-RAHNMMFH-BHDWMOEz.js +1 -0
  29. package/dist/assets/clone-BdN-3iAD.js +1 -0
  30. package/dist/assets/{cose-bilkent-S5V4N54A-F5xOBvqW.js → cose-bilkent-S5V4N54A-IpR9mVIO.js} +1 -1
  31. package/dist/assets/{dagre-KLK3FWXG-CD3BTpHv.js → dagre-KLK3FWXG-B4YA6T7N.js} +1 -1
  32. package/dist/assets/{diagram-E7M64L7V-C3D9MCay.js → diagram-E7M64L7V-Do5l6es_.js} +1 -1
  33. package/dist/assets/{diagram-IFDJBPK2-zJBVM-GK.js → diagram-IFDJBPK2-D5MxfKVv.js} +1 -1
  34. package/dist/assets/{diagram-P4PSJMXO-BrmFZOLB.js → diagram-P4PSJMXO-Djr28EgW.js} +1 -1
  35. package/dist/assets/{erDiagram-INFDFZHY-aSMhKiV2.js → erDiagram-INFDFZHY-BuM-rbCL.js} +1 -1
  36. package/dist/assets/{flowDiagram-PKNHOUZH-DwgX7l8F.js → flowDiagram-PKNHOUZH-By3WGI7Q.js} +1 -1
  37. package/dist/assets/{ganttDiagram-A5KZAMGK-C57Hz6QW.js → ganttDiagram-A5KZAMGK-GLmBfK72.js} +1 -1
  38. package/dist/assets/{gitGraphDiagram-K3NZZRJ6-CuchqqGh.js → gitGraphDiagram-K3NZZRJ6-BN0iXeIv.js} +1 -1
  39. package/dist/assets/{graph-CPFGBV5J.js → graph-CDzuMtjV.js} +1 -1
  40. package/dist/assets/{index-DMt1cpG6.js → index-DoeSN_Oe.js} +130 -130
  41. package/dist/assets/{infoDiagram-LFFYTUFH-Dd_5tfX7.js → infoDiagram-LFFYTUFH-C888gaFw.js} +1 -1
  42. package/dist/assets/{ishikawaDiagram-PHBUUO56-DwosSEvT.js → ishikawaDiagram-PHBUUO56-ChIO9DG-.js} +1 -1
  43. package/dist/assets/{journeyDiagram-4ABVD52K-BuCxcsX0.js → journeyDiagram-4ABVD52K-CufMUDcs.js} +1 -1
  44. package/dist/assets/{kanban-definition-K7BYSVSG-DF_1UCkW.js → kanban-definition-K7BYSVSG-BpsSVpX8.js} +1 -1
  45. package/dist/assets/{layout-DIcS6m1g.js → layout-B8RWVBSF.js} +1 -1
  46. package/dist/assets/{linear-BXkwBhoJ.js → linear-BJwxtq9r.js} +1 -1
  47. package/dist/assets/{mindmap-definition-YRQLILUH-DcDvYagd.js → mindmap-definition-YRQLILUH-C6WPimbf.js} +1 -1
  48. package/dist/assets/{pieDiagram-SKSYHLDU-BmeDeWDM.js → pieDiagram-SKSYHLDU-DeCGMWf8.js} +1 -1
  49. package/dist/assets/{quadrantDiagram-337W2JSQ-3zfjULUM.js → quadrantDiagram-337W2JSQ-D9TWaS83.js} +1 -1
  50. package/dist/assets/{requirementDiagram-Z7DCOOCP-B2wQMJpq.js → requirementDiagram-Z7DCOOCP-DTnuXlAq.js} +1 -1
  51. package/dist/assets/{sankeyDiagram-WA2Y5GQK-__kKlCTq.js → sankeyDiagram-WA2Y5GQK-B2dplCgD.js} +1 -1
  52. package/dist/assets/{sequenceDiagram-2WXFIKYE-B7O81Vih.js → sequenceDiagram-2WXFIKYE-cBvgSSju.js} +1 -1
  53. package/dist/assets/{stateDiagram-RAJIS63D-CcJaDrAK.js → stateDiagram-RAJIS63D-Cwr7VtSX.js} +1 -1
  54. package/dist/assets/stateDiagram-v2-FVOUBMTO-B59h7VTZ.js +1 -0
  55. package/dist/assets/{timeline-definition-YZTLITO2-DSaQQqIU.js → timeline-definition-YZTLITO2-Dkp163fK.js} +1 -1
  56. package/dist/assets/{treemap-KZPCXAKY-9Hcrd8XD.js → treemap-KZPCXAKY-BUWHa5xU.js} +1 -1
  57. package/dist/assets/{vennDiagram-LZ73GAT5-BqHNyca2.js → vennDiagram-LZ73GAT5-BihD66ma.js} +1 -1
  58. package/dist/assets/{xychartDiagram-JWTSCODW-BqeYf6Fk.js → xychartDiagram-JWTSCODW-Cw4lPbuZ.js} +1 -1
  59. package/dist/index.html +1 -1
  60. package/export-docx.js +12 -4
  61. package/init.js +19 -14
  62. package/manifest-cli.mjs +32 -3
  63. package/package.json +3 -2
  64. package/serve.js +44 -19
  65. package/utils/export-markdown.js +486 -0
  66. package/dist/assets/channel-SoktpVBQ.js +0 -1
  67. package/dist/assets/classDiagram-VBA2DB6C-BT2AdZTe.js +0 -1
  68. package/dist/assets/classDiagram-v2-RAHNMMFH-BT2AdZTe.js +0 -1
  69. package/dist/assets/clone-DOjIfi5r.js +0 -1
  70. package/dist/assets/stateDiagram-v2-FVOUBMTO-B2goOPt-.js +0 -1
@@ -0,0 +1,195 @@
1
+ ---
2
+ title: "refactor: Fix all site code review findings"
3
+ type: refactor
4
+ status: completed
5
+ date: 2026-03-23
6
+ ---
7
+
8
+ # refactor: Fix all site code review findings
9
+
10
+ ## Overview
11
+
12
+ Address all 26 findings from a comprehensive 8-agent code review of the EaROS documentation site (`site/src/`). The review covered TypeScript quality, security, performance, architecture, pattern recognition, code simplicity, and agent-native parity. Findings range from render-blocking unused fonts (P1) to minor dead code (P3).
13
+
14
+ The site is a React 18 + TypeScript + MUI 7 + Vite 5 SPA deployed to GitHub Pages at `/EAROS/`.
15
+
16
+ ## Problem Statement
17
+
18
+ The site works correctly but has accumulated technical debt across several dimensions:
19
+ - **Performance:** 2.7MB unoptimized image, unused render-blocking fonts, oversized highlight.js bundle, eagerly bundled markdown content
20
+ - **Type safety:** `strict: false` in tsconfig means TypeScript provides no safety guarantees
21
+ - **Code duplication:** ~290 lines of duplicated color-mapping, sidebar, heading, and card hover patterns across 4+ files, with inconsistencies already emerging (opacity 0.08 vs 0.12 in dark mode)
22
+ - **Architecture:** 1,190-line DemoPage monolith, no 404 route, drifting theme copy, MUI in devDependencies
23
+ - **Agent accessibility:** Zero web-agent discovery mechanisms (no robots.txt, sitemap.xml, llms.txt)
24
+ - **Dead code:** Unused refs, fields, and code branches in TerminalDemo and DemoPage
25
+
26
+ ## Proposed Solution
27
+
28
+ Fix all findings in 4 phases ordered by impact and dependency. Each phase is independently shippable.
29
+
30
+ ## Implementation Phases
31
+
32
+ ### Phase 1: Quick Wins (30 min)
33
+
34
+ Trivial changes with immediate impact. No structural changes.
35
+
36
+ - [ ] **Delete unused font `<link>` tags** from `site/index.html` (lines 8-17)
37
+ - Remove Google Fonts link (Inter + Outfit) — never referenced in theme fontFamily
38
+ - Remove Material Icons link — MUI uses SVG icons via `@mui/icons-material`
39
+ - Impact: eliminates 2 render-blocking requests, saves 100-200ms FCP
40
+ - [ ] **Fix redundant ternaries** where both branches return the same value
41
+ - `site/src/components/Footer.tsx:22` — `isDark ? sapphire.gray[500] : sapphire.gray[500]` → `sapphire.gray[500]`
42
+ - `site/src/components/HeroSection.tsx:109` — same pattern
43
+ - [ ] **Remove dead code from TerminalDemo** (`site/src/components/TerminalDemo.tsx`)
44
+ - Delete `styleRef` (line 32) and its cleanup (lines 82-85) — declared but never assigned
45
+ - Delete `cssId` (line 33) and remove from dependency array (line 87) — generated but never used
46
+ - [ ] **Remove unused `number` field** from `Step` interface in `site/src/components/HowItWorksSection.tsx:9` and data entries
47
+ - [ ] **Delete dead `else` branch** in DemoPage status determination (`site/src/pages/DemoPage.tsx:253-255`) — unreachable after the preceding conditions
48
+ - [ ] **Add `loading="lazy"`** to infographic image in `site/src/components/InfographicSection.tsx:68`
49
+ - [ ] **Add `loading="lazy"`** to markdown-rendered images in `site/src/components/MarkdownRenderer.tsx:69-71`
50
+ - [ ] **Hoist ReactMarkdown plugin arrays** to module scope in `site/src/components/MarkdownRenderer.tsx:49-50`
51
+ ```typescript
52
+ const remarkPlugins = [remarkGfm, remarkSmartypants]
53
+ const rehypePlugins = [rehypeHighlight]
54
+ ```
55
+
56
+ ### Phase 2: Performance (2-3 hrs)
57
+
58
+ Larger performance improvements requiring file changes or dependency updates.
59
+
60
+ - [ ] **Optimize infographic image** (`site/public/screenshots/EaROS.jpg`)
61
+ - Resize from 2752x1536 to 1920px wide (covers 2x Retina at 960px CSS width)
62
+ - Convert to WebP format
63
+ - Expected: 2.7MB → ~300KB
64
+ - Update `InfographicSection.tsx` to reference new filename
65
+ - [ ] **Scope highlight.js languages** in `site/src/components/MarkdownRenderer.tsx`
66
+ - Configure `rehype-highlight` to register only `yaml`, `bash`, `typescript`, `json`
67
+ - Expected: MarkdownRenderer chunk reduced by ~200KB raw / ~70KB gzipped
68
+ - Approach: use `rehype-highlight` with `languages` option, or switch to explicit `hljs.registerLanguage()` imports
69
+ - [ ] **Move TerminalDemo CSS to external stylesheet** (`site/src/components/TerminalDemo.tsx:94-170`)
70
+ - Create `site/src/components/terminalDemo.css` with the 76 lines of CSS
71
+ - Import once at module level instead of rendering `<style>` per instance
72
+ - Eliminates duplicate style injection when multiple TerminalDemo instances render
73
+
74
+ ### Phase 3: Code Quality (2-3 hrs)
75
+
76
+ Type safety, dependency hygiene, and structural improvements.
77
+
78
+ - [ ] **Enable `strict: true`** in `site/tsconfig.json:14`
79
+ - Fix all resulting type errors (26-file codebase, expect 10-30 errors)
80
+ - Key areas likely needing fixes: `any` in MarkdownRenderer, implicit `undefined` in lookup functions
81
+ - [ ] **Fix `any` type** in MarkdownRenderer img handler (`site/src/components/MarkdownRenderer.tsx:64`)
82
+ - Use proper types from `react-markdown`'s `Components` type or `Record<string, unknown>`
83
+ - [ ] **Extract shared maturity color utilities** to `site/src/utils/maturityColors.ts`
84
+ - Consolidate 6 functions from 4 files into one module:
85
+ - `getLevelColor(level, isDark)` — from MaturityAssessment, OnboardingPage
86
+ - `getLevelBg(level, isDark)` — from MaturityAssessment, OnboardingPage
87
+ - `getLevelBorder(level, isDark)` — from MaturityAssessment
88
+ - `getLevelDotColor(level, isDark)` — replaces `getSidebarDotColor` from OnboardingViewPage
89
+ - `getLevelColors(level, isDark)` — replaces multi-return from MaturityBadge
90
+ - Fix opacity inconsistency: dark-mode bg opacity is `0.08` in MaturityAssessment but `0.12` in OnboardingPage — choose one value
91
+ - Update imports in: `MaturityAssessment.tsx`, `OnboardingPage.tsx`, `OnboardingViewPage.tsx`, `MaturityBadge.tsx`
92
+ - ~90 LOC net saved
93
+ - [ ] **Move MUI packages to `dependencies`** in `site/package.json`
94
+ - Move `@emotion/react`, `@emotion/styled`, `@mui/icons-material`, `@mui/material` from `devDependencies` to `dependencies`
95
+ - [ ] **Add 404 catch-all route** in `site/src/App.tsx`
96
+ - Add `<Route path="*" element={<NotFoundPage />} />` inside the Layout route
97
+ - Create minimal `site/src/pages/NotFoundPage.tsx` with back-to-home link
98
+ - [ ] **Add type declaration for termynal** — create `site/src/termynal.d.ts`
99
+ - Minimal `declare module 'termynal'` with constructor signature
100
+ - Remove `@ts-expect-error` from `TerminalDemo.tsx:2`
101
+ - [ ] **Clean up DemoPage IIFE** in `site/src/pages/DemoPage.tsx:991-997`
102
+ - Destructure `getGateChipProps()` result above the JSX instead of IIFE inside `sx` spread
103
+
104
+ ### Phase 4: Architecture & Agent-Native (4-6 hrs)
105
+
106
+ Structural improvements and agent accessibility.
107
+
108
+ - [ ] **Extract DemoPage scoring logic** from `site/src/pages/DemoPage.tsx`
109
+ - Move `CRITERIA` and `SAMPLE_ARTIFACT` to `site/src/content/demoData.ts`
110
+ - Move `computeResults`, type definitions, and `ScoringResult` to `site/src/lib/scoring.ts`
111
+ - Move `getScoreColor`, `getScoreBg`, `getGateChipProps`, `STATUS_CONFIG` to `site/src/lib/scoringColors.ts`
112
+ - DemoPage imports from these modules — becomes a pure rendering component
113
+ - `computeResults` becomes independently testable
114
+ - [ ] **Split markdown content per-route** in `site/src/content/docs.ts` and `onboarding.ts`
115
+ - Replace eager `?raw` imports with dynamic `import()` per slug
116
+ - Each markdown file becomes its own Vite chunk, loaded only when the user navigates to that page
117
+ - Update `DocViewPage.tsx` and `OnboardingViewPage.tsx` to handle async content loading (loading state)
118
+ - Expected: eliminates 137KB of unnecessary content loading per page visit
119
+ - [ ] **Add web-agent discovery files** to `site/public/`
120
+ - `robots.txt` — allow all crawlers
121
+ - `sitemap.xml` — list all routes (`/`, `/docs`, `/docs/*`, `/onboarding`, `/onboarding/*`, `/demo`)
122
+ - `llms.txt` — describe EaROS, list available documentation, point to GitHub repo for raw YAML/markdown
123
+ - [ ] **Add theme drift detection**
124
+ - Option A: Add a CI step that diffs `site/src/theme.ts` against `tools/editor/src/theme.ts` and warns on divergence
125
+ - Option B: Extract shared tokens to a workspace package (heavier, only if drift becomes a recurring issue)
126
+ - Start with Option A (simpler)
127
+ - [ ] **Validate localStorage inputs** in `site/src/main.tsx:13` and `site/src/components/MaturityAssessment.tsx:357`
128
+ - Theme mode: validate against `'light' | 'dark' | 'system'` before using
129
+ - Maturity answers: validate parsed JSON is a plain object before using
130
+
131
+ ## Technical Considerations
132
+
133
+ - **Build verification:** Run `cd site && npm run build` after each phase to confirm no regressions
134
+ - **Bundle size tracking:** Compare `dist/assets/` sizes before and after Phase 2 to verify improvements
135
+ - **TypeScript strictness:** Phase 3's `strict: true` may surface errors that require Phase 1's dead code removal first — hence the phase ordering
136
+ - **Content splitting (Phase 4):** The dynamic import approach requires adding a loading state to DocViewPage and OnboardingViewPage. The `DocsPage` index still needs metadata (title, description) eagerly — only the markdown `content` field should be lazy
137
+ - **Image optimization (Phase 2):** Use `sharp` or an online tool. The WebP conversion should maintain visual quality at the 960px display size. Keep the original JPEG in case it's needed elsewhere
138
+
139
+ ## System-Wide Impact
140
+
141
+ - **No backend changes** — this is a static frontend site
142
+ - **No breaking changes to deployed URLs** — all routes remain the same
143
+ - **GitHub Pages deployment** will be triggered by changes to `site/**` via existing `deploy-site.yml` workflow
144
+ - **Editor theme:** The theme drift detection (Phase 4) may surface existing differences that should be resolved — currently cosmetic only (`hsla()` vs `color-mix()` syntax)
145
+
146
+ ## Acceptance Criteria
147
+
148
+ ### Phase 1
149
+ - [ ] No Google Font or Material Icons font requests in browser network tab
150
+ - [ ] No dead code warnings when `strict: true` is enabled (prep for Phase 3)
151
+ - [ ] All images below the fold have `loading="lazy"`
152
+ - [ ] `npm run build` succeeds
153
+
154
+ ### Phase 2
155
+ - [ ] Infographic image is < 500KB (down from 2.7MB)
156
+ - [ ] MarkdownRenderer chunk is < 200KB (down from 360KB)
157
+ - [ ] No duplicate `<style>` blocks in DOM when multiple TerminalDemo instances render
158
+ - [ ] `npm run build` succeeds
159
+
160
+ ### Phase 3
161
+ - [ ] `tsconfig.json` has `"strict": true` with zero type errors
162
+ - [ ] No `any` types in source code (except justified `@ts-expect-error` with `.d.ts` replacement)
163
+ - [ ] Color-mapping functions exist in exactly one file (`maturityColors.ts`)
164
+ - [ ] Navigating to `/EAROS/nonexistent` shows a 404 page, not a blank layout
165
+ - [ ] MUI packages are in `dependencies` in package.json
166
+ - [ ] `npm run build` succeeds
167
+
168
+ ### Phase 4
169
+ - [ ] `DemoPage.tsx` is < 400 lines (down from 1,190)
170
+ - [ ] Each doc page loads only its own markdown chunk (verify in network tab)
171
+ - [ ] `site/public/robots.txt`, `sitemap.xml`, and `llms.txt` exist and are served
172
+ - [ ] Theme drift CI check passes (or warns on known differences)
173
+ - [ ] `npm run build` succeeds
174
+
175
+ ## Dependencies & Risks
176
+
177
+ - **Image optimization tooling:** Need `sharp` CLI or equivalent to convert JPEG to WebP. Can use an online tool as fallback.
178
+ - **highlight.js scoping:** Need to verify `rehype-highlight` supports language restriction. If not, may need to switch to a different syntax highlighter (e.g., `shiki` with explicit language scoping).
179
+ - **Content splitting complexity:** Dynamic imports change the content loading pattern from synchronous to async. Need to handle the loading state gracefully (show skeleton/spinner while content loads).
180
+ - **strict: true errors:** Unknown count until attempted. If > 50 errors, may need to use `// @ts-expect-error` temporarily and fix incrementally.
181
+
182
+ ## Sources & References
183
+
184
+ ### Internal References
185
+ - Review findings from 8 parallel agents (2026-03-23): TypeScript, Security, Performance, Architecture, Pattern Recognition, Code Simplicity, Agent-Native, Learnings Research
186
+ - `site/tsconfig.json` — TypeScript configuration
187
+ - `site/package.json` — dependency classification
188
+ - `site/vite.config.ts` — build configuration
189
+ - `site/src/theme.ts` — design token system (copy of `tools/editor/src/theme.ts`)
190
+
191
+ ### Key Files by Phase
192
+ - Phase 1: `index.html`, `Footer.tsx`, `HeroSection.tsx`, `TerminalDemo.tsx`, `HowItWorksSection.tsx`, `DemoPage.tsx`, `InfographicSection.tsx`, `MarkdownRenderer.tsx`
193
+ - Phase 2: `public/screenshots/EaROS.jpg`, `MarkdownRenderer.tsx`, `TerminalDemo.tsx`
194
+ - Phase 3: `tsconfig.json`, `package.json`, `MarkdownRenderer.tsx`, `App.tsx`, `MaturityAssessment.tsx`, `OnboardingPage.tsx`, `OnboardingViewPage.tsx`, `MaturityBadge.tsx`, `DemoPage.tsx`
195
+ - Phase 4: `DemoPage.tsx`, `content/docs.ts`, `content/onboarding.ts`, `DocViewPage.tsx`, `OnboardingViewPage.tsx`, `public/` (new files)