@v11g/agents-rock 1.0.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 (223) hide show
  1. package/README.md +65 -0
  2. package/bin/agents-rock.mjs +4 -0
  3. package/package.json +13 -0
  4. package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
  5. package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
  6. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
  7. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
  8. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  10. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  11. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  12. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  13. package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
  14. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
  15. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
  16. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
  17. package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
  18. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
  19. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
  20. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
  21. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
  22. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
  23. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
  24. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
  25. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
  26. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
  27. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
  28. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
  29. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
  30. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
  31. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
  32. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
  33. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
  34. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
  35. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
  36. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
  37. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
  38. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
  39. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
  40. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
  41. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
  42. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
  43. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
  44. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
  45. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
  46. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
  47. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
  48. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
  49. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
  50. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
  51. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
  52. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
  53. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
  54. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
  55. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
  56. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
  57. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
  58. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
  59. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
  60. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
  61. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
  62. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
  63. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
  64. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
  65. package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
  66. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
  67. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
  68. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
  69. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
  70. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
  71. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
  72. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
  73. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
  74. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
  75. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
  76. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
  77. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
  78. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
  79. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
  80. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
  81. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
  82. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
  83. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
  84. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
  85. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
  86. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
  87. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
  88. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
  89. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
  90. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
  91. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
  92. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
  93. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
  94. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
  95. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
  96. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
  97. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
  98. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
  99. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
  100. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
  101. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
  102. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
  103. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
  104. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
  105. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
  106. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
  107. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
  108. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
  109. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
  110. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
  111. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
  112. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
  113. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
  114. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
  115. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
  116. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
  117. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
  118. package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
  119. package/plugins/solution-architect/skills/estimate/README.md +67 -0
  120. package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
  121. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
  122. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
  123. package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
  124. package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
  125. package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
  126. package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
  127. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
  128. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
  129. package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
  130. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
  131. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
  132. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
  133. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
  134. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
  135. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
  136. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
  137. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
  138. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
  139. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
  140. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
  141. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
  142. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
  143. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
  144. package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
  145. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
  146. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
  147. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
  148. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
  149. package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
  150. package/plugins/solution-architect/skills/new-lead/README.md +48 -0
  151. package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
  152. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
  153. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
  154. package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
  155. package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
  156. package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
  157. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
  158. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
  159. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
  160. package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
  161. package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
  162. package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
  163. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
  164. package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
  165. package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
  166. package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
  167. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
  168. package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
  169. package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
  170. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
  171. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
  172. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
  173. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
  174. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
  175. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
  176. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
  177. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
  178. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
  179. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
  180. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
  181. package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
  182. package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
  183. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
  184. package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
  185. package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
  186. package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
  187. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
  188. package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
  189. package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
  190. package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
  191. package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
  192. package/plugins/solution-architect/skills/proposal/README.md +36 -0
  193. package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
  194. package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
  195. package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
  196. package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
  197. package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
  198. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
  199. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
  200. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
  201. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
  202. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
  203. package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
  204. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
  205. package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
  206. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
  207. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
  208. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
  209. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
  210. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
  211. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
  212. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
  213. package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
  214. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
  215. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
  216. package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
  217. package/src/cli/agents.mjs +12 -0
  218. package/src/cli/args.mjs +46 -0
  219. package/src/cli/install.mjs +68 -0
  220. package/src/cli/main.mjs +124 -0
  221. package/src/cli/picker.mjs +78 -0
  222. package/src/cli/registry.mjs +26 -0
  223. package/src/cli/uninstall.mjs +38 -0
@@ -0,0 +1,655 @@
1
+ <!doctype html>
2
+ <!-- new-lead-dashboard v2 -->
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <meta name="description" content="Leads workspace dashboard">
8
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%230f766e'/%3E%3C/svg%3E">
9
+ <title>Leads</title>
10
+ <style>
11
+ /* Tokens: same vocabulary as the lead detail page. Full light palette on bare
12
+ :root, dark redefines only. No [data-theme] override block because this page
13
+ ships no theme control. */
14
+ :root {
15
+ color-scheme:light;
16
+ --bg:#f6f4ef; --bg-sunk:#edeae1; --card:#fffdf9; --card-raised:#fff;
17
+ --ink:#1c1b18; --ink-soft:#45423a; --ink-dim:#6c6759;
18
+ --border:#e4dfd3; --border-strong:#cec7b6;
19
+ --accent:#0f766e; --accent-ink:#0a544f; --accent-soft:rgba(15,118,110,.09); --accent-line:rgba(15,118,110,.38);
20
+ --ok:#15803d; --ok-soft:rgba(21,128,61,.1);
21
+ --warn:#a55708; --warn-soft:rgba(165,87,8,.1);
22
+ --pending-bg:#eae7dd; --pending-ink:#857f70;
23
+ --focus:#0f766e;
24
+ /* Opaque: sticky cells paint over scrolling content, so these two cannot be tints. */
25
+ --row-hover:#f2efe7; --th-active:#e6e9e4;
26
+ --scroll-thumb:#cec7b6; --scroll-thumb-hover:#b3aa95; --scroll-track:transparent;
27
+ /* Depth tiers: layered transparent shadows instead of borders. */
28
+ --tier-flat:0 0 0 1px rgba(0,0,0,.06);
29
+ --tier-raised:0 0 0 1px rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06), 0 2px 4px 0 rgba(0,0,0,.04);
30
+ --tier-raised-hover:0 0 0 1px rgba(0,0,0,.08), 0 1px 2px -1px rgba(0,0,0,.08), 0 2px 4px 0 rgba(0,0,0,.06);
31
+ --tier-hero:0 0 0 1px rgba(15,118,110,.16), 0 2px 6px -2px rgba(0,0,0,.07), 0 10px 26px -8px rgba(0,0,0,.09);
32
+ --tier-sunk:inset 0 1px 3px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.04);
33
+ --r-lg:.875rem; --r-md:.625rem; --r-sm:.5rem; --r-xs:.375rem; --r-pill:999px;
34
+ --topbar-h:3.5rem; --ease:cubic-bezier(.16, 1, .3, 1);
35
+ }
36
+ @media (prefers-color-scheme:dark) {
37
+ :root {
38
+ color-scheme:dark;
39
+ --bg:#0f1413; --bg-sunk:#0a0e0d; --card:#171d1c; --card-raised:#1c2322;
40
+ --ink:#e9e7e2; --ink-soft:#bdc4c0; --ink-dim:#8d9a95;
41
+ --border:#26312f; --border-strong:#3a4946;
42
+ --accent:#3fb3a8; --accent-ink:#74d6cc; --accent-soft:rgba(63,179,168,.13); --accent-line:rgba(63,179,168,.42);
43
+ --ok:#62c082; --ok-soft:rgba(98,192,130,.13);
44
+ --warn:#dd9247; --warn-soft:rgba(221,146,71,.13);
45
+ --pending-bg:#1f2726; --pending-ink:#8d9a95;
46
+ --focus:#74d6cc;
47
+ --row-hover:#1d2523; --th-active:#152321;
48
+ --scroll-thumb:#3a4946; --scroll-thumb-hover:#4f6360;
49
+ --tier-flat:0 0 0 1px rgba(255,255,255,.08);
50
+ --tier-raised:0 0 0 1px rgba(255,255,255,.08);
51
+ --tier-raised-hover:0 0 0 1px rgba(255,255,255,.13);
52
+ --tier-hero:0 0 0 1px rgba(116,214,204,.22), 0 10px 30px -12px rgba(0,0,0,.7);
53
+ --tier-sunk:inset 0 1px 3px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.05);
54
+ }
55
+ }
56
+
57
+ /* base */
58
+ * { box-sizing:border-box; }
59
+ html { -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; scrollbar-width:thin; scrollbar-color:var(--scroll-thumb) var(--scroll-track); }
60
+ html::-webkit-scrollbar { width:11px; height:11px; }
61
+ html::-webkit-scrollbar-track { background:var(--scroll-track); }
62
+ html::-webkit-scrollbar-thumb { background:var(--scroll-thumb); border-radius:var(--r-pill); border:3px solid transparent; background-clip:content-box; }
63
+ html::-webkit-scrollbar-thumb:hover { background:var(--scroll-thumb-hover); background-clip:content-box; }
64
+ body {
65
+ margin:0; color:var(--ink); background-color:var(--bg);
66
+ background-image:radial-gradient(ellipse 90% 45% at 50% -6%, var(--accent-soft) 0%, transparent 70%);
67
+ background-repeat:no-repeat;
68
+ font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
69
+ font-size:clamp(15px, .35vw + 14px, 16.5px); line-height:1.55; overflow-wrap:break-word;
70
+ }
71
+ .mono { font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace; font-variant-numeric:tabular-nums; }
72
+ button, select, input { font:inherit; color:inherit; }
73
+ h1, h2, h3 { margin:0; text-wrap:balance; letter-spacing:-.011em; }
74
+ p, li { text-wrap:pretty; }
75
+ a { color:var(--accent-ink); }
76
+ :focus-visible { outline:2px solid var(--focus); outline-offset:2px; border-radius:var(--r-xs); }
77
+ [hidden] { display:none !important; }
78
+
79
+ /* themed scrollbars on every scrolling region, same treatment as the detail page */
80
+ .scroll-region { scrollbar-width:thin; scrollbar-color:var(--scroll-thumb) var(--scroll-track); }
81
+ .scroll-region::-webkit-scrollbar { width:9px; height:9px; }
82
+ .scroll-region::-webkit-scrollbar-track { background:var(--scroll-track); }
83
+ .scroll-region::-webkit-scrollbar-thumb { background:var(--scroll-thumb); border-radius:var(--r-pill); border:2px solid transparent; background-clip:content-box; }
84
+ .scroll-region::-webkit-scrollbar-thumb:hover { background:var(--scroll-thumb-hover); background-clip:content-box; }
85
+ .scroll-region::-webkit-scrollbar-corner { background:transparent; }
86
+
87
+ /* Page chrome enters once, staggered. Rows and cards deliberately do not:
88
+ they are re-rendered on every keystroke, so a per-item enter would fire
89
+ continuously while typing in the search box. */
90
+ .enter { opacity:0; transform:translateY(10px); animation:enter-up 420ms var(--ease) both; animation-delay:calc(var(--i, 0) * 70ms); }
91
+ @keyframes enter-up { to { opacity:1; transform:translateY(0); } }
92
+ @media (prefers-reduced-motion:reduce) {
93
+ *, *::before, *::after {
94
+ animation-duration:.001ms !important; animation-delay:0ms !important;
95
+ transition-duration:.001ms !important; scroll-behavior:auto !important;
96
+ }
97
+ .enter { opacity:1; transform:none; }
98
+ }
99
+
100
+ /* top bar */
101
+ header {
102
+ position:sticky; top:0; z-index:30; min-height:var(--topbar-h);
103
+ display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:.3rem 1rem;
104
+ padding:.7rem max(1.25rem, calc((100% - 1160px) / 2));
105
+ background:color-mix(in srgb, var(--card) 88%, transparent);
106
+ -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px);
107
+ box-shadow:0 1px 0 0 var(--border);
108
+ }
109
+ header h1 { font-size:1.15rem; font-weight:620; }
110
+ #result-count { margin:0; font-size:.78rem; color:var(--ink-dim); font-variant-numeric:tabular-nums; }
111
+ main { max-width:1160px; margin:0 auto; padding:1.25rem 1.25rem 3rem; }
112
+ main > *, .views > *, .toolbar > * { min-width:0; }
113
+
114
+ /* stats strip: the page's anchor, so it takes the hero tier and the cards sit below it */
115
+ .stats {
116
+ display:grid; grid-template-columns:repeat(4,1fr); margin-bottom:1.05rem; overflow:hidden;
117
+ background:var(--card-raised); border-radius:var(--r-lg); box-shadow:var(--tier-hero);
118
+ }
119
+ .stat { padding:.8rem 1.05rem; border-right:1px solid var(--border); }
120
+ .stat:last-child { border-right:none; }
121
+ .stat .label { margin:0 0 .3rem; font-size:.68rem; font-weight:600; color:var(--ink-dim); text-transform:uppercase; letter-spacing:.07em; }
122
+ .stat .value { margin:0; font-size:1.25rem; font-weight:620; line-height:1.3; font-variant-numeric:tabular-nums; }
123
+ .stat .value-sm { font-size:1rem; }
124
+ .stat .value + .value { margin-top:.15rem; }
125
+ .stat .value .count { margin-left:.3rem; font-size:.7rem; font-weight:500; color:var(--ink-dim); }
126
+
127
+ /* toolbar: chrome, not content — a plain row over a divider, so the stats
128
+ strip stays the only card at the top of the page */
129
+ .toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; margin:0 0 1.05rem; padding:0 0 .85rem; border-bottom:1px solid var(--border); }
130
+ .seg { display:inline-flex; gap:2px; padding:3px; border-radius:11px; background:var(--bg-sunk); box-shadow:var(--tier-flat); } /* concentric: 8 + 3 = 11 */
131
+ .seg button {
132
+ min-height:2.125rem; padding:0 .7rem; border:0; border-radius:8px; background:transparent;
133
+ color:var(--ink-dim); font-size:.78rem; white-space:nowrap; cursor:pointer;
134
+ transition-property:background-color, color, scale; transition-duration:160ms; transition-timing-function:var(--ease);
135
+ }
136
+ .seg button:hover { color:var(--ink); }
137
+ .seg button:active { scale:.96; }
138
+ .seg button[aria-pressed="true"] { background:var(--card); color:var(--accent-ink); font-weight:620; box-shadow:var(--tier-flat); }
139
+ .toolbar input[type="search"], .toolbar select {
140
+ min-height:2.375rem; padding:0 .6rem; font-size:.82rem; border:0; border-radius:var(--r-sm);
141
+ background:var(--bg-sunk); color:var(--ink); box-shadow:var(--tier-flat);
142
+ transition-property:box-shadow; transition-duration:160ms; transition-timing-function:var(--ease);
143
+ }
144
+ .toolbar input[type="search"]:hover, .toolbar select:hover { box-shadow:var(--tier-raised-hover); }
145
+ .toolbar input[type="search"] { flex:1 1 10rem; min-width:8rem; }
146
+ .toolbar input[type="search"]::placeholder { color:var(--ink-dim); }
147
+ .spacer { flex:1 1 auto; }
148
+ .btn {
149
+ min-height:2.375rem; display:inline-flex; align-items:center; gap:.35rem; padding:0 .85rem;
150
+ font-size:.82rem; font-weight:550; border:0; border-radius:var(--r-sm);
151
+ background:var(--card); color:var(--ink); box-shadow:var(--tier-raised);
152
+ text-decoration:none; white-space:nowrap; cursor:pointer;
153
+ transition-property:box-shadow, background-color, color, scale; transition-duration:160ms; transition-timing-function:var(--ease);
154
+ }
155
+ .btn:hover { box-shadow:var(--tier-raised-hover); }
156
+ .btn:active { scale:.96; }
157
+ #dir-toggle { padding:0 .85rem 0 .72rem; } /* optical: the arrow glyph side loses 2px */
158
+
159
+ /* badges: shared tone vocabulary with the detail page; the bare .badge is a
160
+ readable fallback for a status value we have no rule for */
161
+ .badge {
162
+ display:inline-flex; align-items:center; gap:.35rem; padding:.18rem .5rem; border-radius:var(--r-pill);
163
+ font-size:.66rem; font-weight:650; letter-spacing:.045em; text-transform:uppercase; white-space:nowrap;
164
+ background:var(--pending-bg); color:var(--pending-ink);
165
+ }
166
+ .badge::before { content:""; width:.4rem; height:.4rem; border-radius:50%; background:currentColor; }
167
+ .badge-active { background:var(--accent-soft); color:var(--accent-ink); }
168
+ .badge-won { background:var(--ok-soft); color:var(--ok); }
169
+ .badge-lost { background:var(--pending-bg); color:var(--pending-ink); }
170
+
171
+ /* cards */
172
+ .cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); gap:.85rem; }
173
+ .card {
174
+ position:relative; display:flex; flex-direction:column; gap:.25rem; padding:.9rem 1rem;
175
+ border-radius:var(--r-lg); background:var(--card); box-shadow:var(--tier-raised);
176
+ transition-property:box-shadow; transition-duration:200ms; transition-timing-function:var(--ease);
177
+ }
178
+ .card:hover { box-shadow:var(--tier-raised-hover); }
179
+ .card > * { min-width:0; }
180
+ /* status rail: the one thing you scan a card grid for */
181
+ .card::before { content:""; position:absolute; left:0; top:.9rem; bottom:.9rem; width:2px; border-radius:var(--r-pill); background:var(--pending-ink); }
182
+ .card.active::before { background:var(--accent); }
183
+ .card.won::before { background:var(--ok); }
184
+ .card.lost::before { background:var(--border-strong); }
185
+ .card-head { display:flex; justify-content:space-between; align-items:start; gap:.5rem; }
186
+ .card-head h3 { font-size:.98rem; font-weight:620; line-height:1.35; }
187
+ .card-client { margin:0; font-size:.8rem; color:var(--ink-dim); }
188
+ .card-meta { display:flex; flex-wrap:wrap; gap:.1rem .6rem; margin:.2rem 0 0; font-size:.76rem; color:var(--ink-dim); }
189
+ .card-value { font-weight:620; color:var(--ink-soft); }
190
+ /* artifact tray: sunk, so the chips read as contents of the card */
191
+ .artifacts { display:flex; flex-wrap:wrap; gap:2px; margin:.55rem 0 0; padding:4px; border-radius:var(--r-md); background:var(--bg-sunk); box-shadow:var(--tier-sunk); } /* concentric: 6 + 4 = 10 */
192
+ .chip {
193
+ display:inline-flex; align-items:center; min-height:2.125rem; padding:0 .55rem;
194
+ border-radius:var(--r-xs); font-size:.72rem; text-decoration:none;
195
+ transition-property:background-color, color; transition-duration:160ms; transition-timing-function:var(--ease);
196
+ }
197
+ .chip-ready { background:var(--accent-soft); color:var(--accent-ink); font-weight:620; }
198
+ .chip-ready:hover { background:color-mix(in srgb, var(--accent) 20%, transparent); }
199
+ .chip-pending { color:var(--ink-dim); }
200
+ .card-actions { display:flex; flex-wrap:wrap; gap:.4rem; margin-top:.6rem; }
201
+ .card-actions .btn { min-height:2.125rem; padding:0 .7rem; font-size:.78rem; }
202
+ .btn-open { background:var(--accent-soft); color:var(--accent-ink); font-weight:620; box-shadow:var(--tier-flat); }
203
+ .btn-won { color:var(--ok); font-weight:620; }
204
+ .btn-lost { color:var(--ink-dim); }
205
+
206
+ /* timeline */
207
+ .month-marker {
208
+ position:sticky; top:var(--topbar-h); z-index:5; margin:1.1rem 0 .3rem; padding:.35rem 0;
209
+ font-size:.7rem; font-weight:700; letter-spacing:.13em; text-transform:uppercase; color:var(--ink-dim);
210
+ background:color-mix(in srgb, var(--bg) 92%, transparent);
211
+ -webkit-backdrop-filter:blur(8px); backdrop-filter:blur(8px);
212
+ }
213
+ .month-marker:first-child { margin-top:0; }
214
+ /* grid, never flex, on the row: flex creates an unshrinkable anonymous box */
215
+ .t-row {
216
+ display:grid; grid-template-columns:5.5rem 4.5rem minmax(0, 1fr) 5.5rem; align-items:center;
217
+ gap:.15rem .7rem; margin:0 -.5rem; padding:.45rem .5rem; border-bottom:1px solid var(--border);
218
+ transition-property:background-color; transition-duration:160ms; transition-timing-function:var(--ease);
219
+ }
220
+ .t-row:hover { background:var(--accent-soft); }
221
+ .t-row > * { min-width:0; }
222
+ .t-date { font-size:.76rem; color:var(--ink-dim); }
223
+ .t-closed { text-align:right; }
224
+ .t-bar { display:flex; align-items:center; }
225
+ .t-dot { width:.45rem; height:.45rem; border-radius:50%; background:var(--accent); flex:none; }
226
+ .t-line { height:2px; flex:1; background:var(--accent-line); }
227
+ .t-line.dashed { background:repeating-linear-gradient(90deg, var(--accent-line) 0 4px, transparent 4px 8px); }
228
+ .t-row.won .t-dot, .t-row.won .t-line { background:var(--ok); }
229
+ .t-row.lost .t-dot, .t-row.lost .t-line { background:var(--border-strong); }
230
+ .t-info { display:flex; align-items:center; flex-wrap:wrap; gap:.15rem .4rem; font-size:.84rem; }
231
+ .t-info strong { font-weight:620; }
232
+
233
+ /* wall: its own scroll region, so the header row and the ID column can hold
234
+ still while the other twelve columns move under them */
235
+ .wall-wrap { overflow:auto; max-height:calc(100dvh - 11rem); background:var(--card); border-radius:var(--r-lg); box-shadow:var(--tier-raised); }
236
+ /* separate, not collapse: collapsed borders do not travel with sticky cells */
237
+ table.wall { border-collapse:separate; border-spacing:0; width:100%; font-size:.78rem; }
238
+ table.wall th, table.wall td { padding:.4rem .7rem; text-align:left; white-space:nowrap; background:var(--card); }
239
+ table.wall td { border-bottom:1px solid var(--border); color:var(--ink-soft); }
240
+ table.wall tbody tr:last-child td { border-bottom:none; }
241
+ table.wall thead th {
242
+ position:sticky; top:0; z-index:2; background:var(--bg-sunk); color:var(--ink-dim);
243
+ font-size:.68rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em;
244
+ box-shadow:inset 0 -1px 0 var(--border-strong);
245
+ }
246
+ table.wall th:first-child, table.wall td:first-child { position:sticky; left:0; }
247
+ table.wall td:first-child { z-index:1; box-shadow:inset -1px 0 0 var(--border); }
248
+ table.wall thead th:first-child { z-index:3; box-shadow:inset 0 -1px 0 var(--border-strong), inset -1px 0 0 var(--border); }
249
+ table.wall tbody tr:hover td { background:var(--row-hover); }
250
+ table.wall th.mid, table.wall td.mid { text-align:center; }
251
+ table.wall th.right, table.wall td.right { text-align:right; }
252
+ /* sortable header is a real button, so it is reachable and takes a focus ring;
253
+ the arrow is drawn from aria-sort instead of written into the label */
254
+ .th-btn {
255
+ display:inline-flex; align-items:center; gap:.3rem; width:calc(100% + 1.4rem); min-height:2.5rem;
256
+ margin:-.4rem -.7rem; padding:.4rem .7rem; border:0; background:transparent; color:inherit;
257
+ font:inherit; letter-spacing:inherit; text-transform:inherit; border-radius:var(--r-xs); cursor:pointer;
258
+ transition-property:background-color, color; transition-duration:160ms; transition-timing-function:var(--ease);
259
+ }
260
+ .th-btn::after { content:"\2195"; opacity:.35; font-size:.9em; }
261
+ .th-btn:hover { color:var(--accent-ink); background:var(--accent-soft); }
262
+ table.wall thead th[aria-sort="ascending"], table.wall thead th[aria-sort="descending"] { background:var(--th-active); color:var(--accent-ink); }
263
+ th[aria-sort="ascending"] .th-btn::after { content:"\2191"; opacity:1; }
264
+ th[aria-sort="descending"] .th-btn::after { content:"\2193"; opacity:1; }
265
+ .tick { color:var(--ok); }
266
+ .no { color:var(--pending-ink); }
267
+
268
+ /* banner + empty states */
269
+ .banner {
270
+ display:flex; align-items:center; gap:.5rem; margin:0 0 1.05rem; padding:.65rem .9rem; font-size:.85rem;
271
+ border-radius:var(--r-md); border-left:3px solid var(--warn); background:var(--warn-soft); color:var(--warn);
272
+ }
273
+ .empty { padding:2.5rem 1.25rem; text-align:center; color:var(--ink-dim); border-radius:var(--r-lg); background:var(--bg-sunk); box-shadow:var(--tier-sunk); }
274
+ #view-cards .empty { grid-column:1/-1; }
275
+ .empty p { margin:0; font-size:.92rem; }
276
+ .empty code { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:.88em; background:var(--accent-soft); color:var(--accent-ink); padding:.1rem .35rem; border-radius:var(--r-xs); }
277
+ table.wall td.empty { background:var(--bg-sunk); border-bottom:none; box-shadow:none; white-space:normal; }
278
+
279
+ /* responsive */
280
+ @media (max-width:760px) { .spacer { display:none; } }
281
+ @media (max-width:640px) {
282
+ .stats { grid-template-columns:repeat(2,1fr); }
283
+ .stat:nth-child(2n) { border-right:none; }
284
+ .stat:nth-child(n+3) { border-top:1px solid var(--border); }
285
+ .t-row { grid-template-columns:max-content minmax(0, 1fr); }
286
+ .t-bar { display:none; }
287
+ .t-closed { grid-column:2; text-align:left; font-size:.72rem; }
288
+ }
289
+ @media (max-width:560px) {
290
+ header { padding:.6rem 1rem; }
291
+ main { padding:1rem 1rem 2.5rem; }
292
+ .toolbar input[type="search"] { flex:1 1 100%; }
293
+ .wall-wrap { max-height:calc(100dvh - 8rem); }
294
+ }
295
+ </style>
296
+ </head>
297
+ <body>
298
+ <header>
299
+ <h1>Leads</h1>
300
+ <p id="result-count" role="status"></p>
301
+ </header>
302
+ <main>
303
+ <section class="stats enter" id="stats" style="--i:0" aria-label="Pipeline stats"></section>
304
+
305
+ <div class="toolbar enter" style="--i:1">
306
+ <div class="seg" id="view-switch" role="group" aria-label="View">
307
+ <button type="button" data-view="cards">Cards</button>
308
+ <button type="button" data-view="timeline">Timeline</button>
309
+ <button type="button" data-view="wall">Wall</button>
310
+ </div>
311
+ <div class="seg" id="status-filter" role="group" aria-label="Status filter">
312
+ <button type="button" data-status="all">All</button>
313
+ <button type="button" data-status="active">Active</button>
314
+ <button type="button" data-status="won">Won</button>
315
+ <button type="button" data-status="lost">Lost</button>
316
+ </div>
317
+ <input type="search" id="search" placeholder="Search leads" aria-label="Search leads">
318
+ <div class="spacer"></div>
319
+ <select id="sort-key" aria-label="Sort by">
320
+ <option value="created">Sort: created</option>
321
+ <option value="closed">Sort: closed</option>
322
+ <option value="value">Sort: value</option>
323
+ <option value="client">Sort: client</option>
324
+ </select>
325
+ <button type="button" class="btn" id="dir-toggle" aria-label="Sort direction"></button>
326
+ </div>
327
+
328
+ <p id="banner" class="banner" role="alert" hidden></p>
329
+
330
+ <div class="views enter" style="--i:2">
331
+ <div id="empty" class="empty" hidden>
332
+ <p>No leads yet. Run <code>/new-lead</code> to create one.</p>
333
+ </div>
334
+
335
+ <section id="view-cards" class="cards"></section>
336
+
337
+ <section id="view-timeline" hidden></section>
338
+
339
+ <section id="view-wall" hidden>
340
+ <div class="wall-wrap scroll-region">
341
+ <table class="wall">
342
+ <thead><tr></tr></thead>
343
+ <tbody id="wall-body"></tbody>
344
+ </table>
345
+ </div>
346
+ </section>
347
+ </div>
348
+ </main>
349
+
350
+ <script type="module">
351
+ import { computeStats, filterLeads, sortLeads } from '/scripts/stats.mjs';
352
+
353
+ const LS = 'newlead.dashboard.';
354
+ const todayISO = new Date().toISOString().slice(0, 10);
355
+ const state = {
356
+ view: localStorage.getItem(LS + 'view') || 'cards',
357
+ status: localStorage.getItem(LS + 'status') || 'all',
358
+ text: localStorage.getItem(LS + 'text') || '',
359
+ sortKey: localStorage.getItem(LS + 'sortKey') || 'created',
360
+ sortDir: localStorage.getItem(LS + 'sortDir') || 'asc',
361
+ };
362
+ let leads = [];
363
+
364
+ function persist(key, value) {
365
+ state[key] = value;
366
+ localStorage.setItem(LS + key, value);
367
+ }
368
+
369
+ const ESCAPES = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
370
+ function esc(s) {
371
+ return String(s ?? '').replace(/[&<>"']/g, (c) => ESCAPES[c]);
372
+ }
373
+
374
+ // A lead may have no client name until /proposal supplies one.
375
+ const clientName = (l) => l.client ?? '—';
376
+
377
+ function showBanner(msg) {
378
+ const b = document.getElementById('banner');
379
+ b.textContent = msg;
380
+ b.hidden = false;
381
+ }
382
+ function clearBanner() {
383
+ document.getElementById('banner').hidden = true;
384
+ }
385
+
386
+ async function load() {
387
+ try {
388
+ const res = await fetch('/api/leads');
389
+ if (!res.ok) throw new Error(`server returned ${res.status}`);
390
+ const data = await res.json();
391
+ leads = data.leads;
392
+ } catch (err) {
393
+ showBanner(`Could not load leads (${err.message}). Try reloading the page.`);
394
+ return;
395
+ }
396
+ try {
397
+ clearBanner();
398
+ render();
399
+ } catch (err) {
400
+ showBanner(`Could not display leads (${err.message}).`);
401
+ }
402
+ }
403
+
404
+ async function setStatus(id, status) {
405
+ try {
406
+ const res = await fetch(`/api/leads/${id}`, {
407
+ method: 'POST',
408
+ headers: { 'content-type': 'application/json' },
409
+ body: JSON.stringify({ status }),
410
+ });
411
+ if (!res.ok) {
412
+ const body = await res.json().catch(() => ({}));
413
+ throw new Error(body.error || `request failed (${res.status})`);
414
+ }
415
+ await load();
416
+ } catch (err) {
417
+ showBanner(`Could not update lead: ${err.message}`);
418
+ }
419
+ }
420
+
421
+ function fmtRange(v) {
422
+ if (!v) return '';
423
+ try {
424
+ const fmt = new Intl.NumberFormat('en-US', { style: 'currency', currency: v.currency, maximumFractionDigits: 0 });
425
+ return `${fmt.format(v.low)} - ${fmt.format(v.high)}`;
426
+ } catch {
427
+ return `${esc(v.low)} - ${esc(v.high)} ${esc(v.currency)}`;
428
+ }
429
+ }
430
+
431
+ // One <p class="value"> line per currency group, each with a dim lead count -
432
+ // stacked, not a bulleted list, so one currency still reads as a single clean line.
433
+ // value-sm because a currency range is far longer than the other three tiles' values.
434
+ function pipelineValueLines(pv) {
435
+ if (!pv) return '<p class="value mono">—</p>';
436
+ return pv.map((g) => `<p class="value value-sm mono">${fmtRange(g)}&nbsp;<span class="count">(${g.count})</span></p>`).join('');
437
+ }
438
+
439
+ function renderStats() {
440
+ const s = computeStats(leads, todayISO);
441
+ const winRate = s.winRate === null ? '—' : Math.round(s.winRate * 100) + '%';
442
+ const cycle = s.avgCycleDays === null ? '—' : s.avgCycleDays + ' days';
443
+ const tiles = [
444
+ ['Won this month', `<p class="value mono">${s.wonThisMonth}</p>`],
445
+ ['Win rate', `<p class="value mono">${winRate}</p>`],
446
+ ['Pipeline value', pipelineValueLines(s.pipelineValue)],
447
+ ['Avg cycle', `<p class="value mono">${cycle}</p>`],
448
+ ];
449
+ document.getElementById('stats').innerHTML = tiles.map(([label, html]) => `
450
+ <div class="stat">
451
+ <p class="label">${label}</p>
452
+ ${html}
453
+ </div>`).join('');
454
+ }
455
+
456
+ // textContent, not innerHTML: this only ever holds numbers we computed.
457
+ function renderCount(shown, total) {
458
+ const noun = total === 1 ? 'lead' : 'leads';
459
+ document.getElementById('result-count').textContent =
460
+ total === 0 ? '' : shown === total ? `${total} ${noun}` : `${shown} of ${total} ${noun}`;
461
+ }
462
+
463
+ function artifactChip(ready, href, label) {
464
+ return ready
465
+ ? `<a class="chip chip-ready" href="${href}">${label}</a>`
466
+ : `<span class="chip chip-pending">${label} pending</span>`;
467
+ }
468
+
469
+ function statusBadge(status) {
470
+ return `<span class="badge badge-${esc(status)}">${esc(status)}</span>`;
471
+ }
472
+
473
+ function cardTemplate(l) {
474
+ const id = esc(l.id);
475
+ const dates = l.closed ? `${esc(l.created)} → ${esc(l.closed)}` : `${esc(l.created)} → open`;
476
+ const actions = l.closed ? '' : `
477
+ <button type="button" class="btn btn-won" data-action="won" data-id="${id}">Won</button>
478
+ <button type="button" class="btn btn-lost" data-action="lost" data-id="${id}">Lost</button>`;
479
+ return `
480
+ <article class="card ${esc(l.status)}">
481
+ <div class="card-head">
482
+ <h3>${esc(l.title)}</h3>
483
+ ${statusBadge(l.status)}
484
+ </div>
485
+ <p class="card-client">${esc(clientName(l))}</p>
486
+ <p class="card-meta">
487
+ <span class="mono">${dates}</span>
488
+ ${l.value ? `<span class="card-value mono">${fmtRange(l.value)}</span>` : ''}
489
+ </p>
490
+ <div class="artifacts">
491
+ ${artifactChip(l.artifacts.docs, `/leads/${id}/dist/index.html`, 'Docs')}
492
+ ${artifactChip(l.artifacts.estimate, `/leads/${id}/dist/estimate.html`, 'Estimate')}
493
+ ${artifactChip(l.artifacts.proposal, `/leads/${id}/dist/proposal.html`, 'Proposal')}
494
+ </div>
495
+ <div class="card-actions">
496
+ <a class="btn btn-open" href="/detail/${id}">Open</a>
497
+ ${actions}
498
+ </div>
499
+ </article>`;
500
+ }
501
+
502
+ const NO_MATCH = 'No leads match the current filters.';
503
+
504
+ function renderCards(list) {
505
+ document.getElementById('view-cards').innerHTML = list.length
506
+ ? list.map(cardTemplate).join('')
507
+ : `<p class="empty">${NO_MATCH}</p>`;
508
+ }
509
+
510
+ function monthLabel(iso) {
511
+ const [y, m] = iso.split('-').map(Number);
512
+ return new Date(Date.UTC(y, m - 1, 1)).toLocaleDateString('en-US', { month: 'long', year: 'numeric', timeZone: 'UTC' });
513
+ }
514
+
515
+ function timelineRow(l) {
516
+ const bar = l.closed
517
+ ? `<span class="t-dot"></span><span class="t-line"></span><span class="t-dot"></span>`
518
+ : `<span class="t-dot"></span><span class="t-line dashed"></span>`;
519
+ return `
520
+ <div class="t-row ${esc(l.status)}">
521
+ <span class="t-date mono">${esc(l.created)}</span>
522
+ <span class="t-bar">${bar}</span>
523
+ <span class="t-info"><strong>${esc(clientName(l))}</strong> ${esc(l.title)}${statusBadge(l.status)}</span>
524
+ <span class="t-date t-closed mono">${esc(l.closed || '')}</span>
525
+ </div>`;
526
+ }
527
+
528
+ function renderTimeline(list) {
529
+ if (!list.length) {
530
+ document.getElementById('view-timeline').innerHTML = `<p class="empty">${NO_MATCH}</p>`;
531
+ return;
532
+ }
533
+ // delegates to stats.mjs rather than restating its comparator
534
+ const chronological = sortLeads(list, 'created', 'asc');
535
+ let month = null;
536
+ const rows = chronological.map((l) => {
537
+ const m = l.created.slice(0, 7);
538
+ const marker = m !== month ? `<p class="month-marker">${monthLabel(l.created)}</p>` : '';
539
+ month = m;
540
+ return marker + timelineRow(l);
541
+ });
542
+ document.getElementById('view-timeline').innerHTML = rows.join('');
543
+ }
544
+
545
+ function tick(flag) {
546
+ return flag ? '<span class="tick">✓</span>' : '<span class="no">-</span>';
547
+ }
548
+
549
+ // One source of truth for the wall table: label, alignment class and cell
550
+ // content all drive both the header row and each body row, so the two can't
551
+ // drift out of sync. `cls` values are literals from this table, never lead data.
552
+ const COLUMNS = [
553
+ { label: 'ID', cls: 'mono', cell: (l) => esc(l.id) },
554
+ { label: 'Client', sort: 'client', cell: (l) => esc(clientName(l)) },
555
+ { label: 'Title', cell: (l) => esc(l.title) },
556
+ { label: 'Status', cell: (l) => statusBadge(l.status) },
557
+ { label: 'Created', sort: 'created', cls: 'mono', cell: (l) => esc(l.created) },
558
+ { label: 'Closed', sort: 'closed', cls: 'mono', cell: (l) => esc(l.closed || '-') },
559
+ { label: 'Value', sort: 'value', cls: 'mono right', cell: (l) => (l.value ? fmtRange(l.value) : '-') },
560
+ { label: 'Scenario', cell: (l) => esc(l.scenario || '-') },
561
+ { label: 'Docs', cls: 'mid', cell: (l) => tick(l.artifacts.docs) },
562
+ { label: 'Estimate', cls: 'mid', cell: (l) => tick(l.artifacts.estimate) },
563
+ { label: 'Proposal', cls: 'mid', cell: (l) => tick(l.artifacts.proposal) },
564
+ { label: 'Brief', cls: 'mid', cell: (l) => tick(l.hasBrief) },
565
+ { label: 'Notes', cls: 'mid', cell: (l) => tick(l.hasNotes) },
566
+ ];
567
+
568
+ function attr(cls) {
569
+ return cls ? ` class="${cls}"` : '';
570
+ }
571
+
572
+ function renderWallHead() {
573
+ document.querySelector('#view-wall thead tr').innerHTML = COLUMNS.map((c) => (c.sort
574
+ ? `<th${attr(c.cls)} data-sort="${c.sort}" aria-sort="none"><button type="button" class="th-btn">${c.label}</button></th>`
575
+ : `<th${attr(c.cls)}>${c.label}</th>`)).join('');
576
+ }
577
+
578
+ function wallRow(l) {
579
+ return `<tr>${COLUMNS.map((c) => `<td${attr(c.cls)}>${c.cell(l)}</td>`).join('')}</tr>`;
580
+ }
581
+
582
+ function renderWall(list) {
583
+ document.getElementById('wall-body').innerHTML = list.length
584
+ ? list.map(wallRow).join('')
585
+ : `<tr><td colspan="${COLUMNS.length}" class="empty">${NO_MATCH}</td></tr>`;
586
+ // aria-sort carries both the a11y state and the arrow glyph (drawn in CSS).
587
+ document.querySelectorAll('#view-wall th[data-sort]').forEach((th) => {
588
+ const active = th.dataset.sort === state.sortKey;
589
+ th.setAttribute('aria-sort', active ? (state.sortDir === 'asc' ? 'ascending' : 'descending') : 'none');
590
+ });
591
+ }
592
+
593
+ function syncToolbar() {
594
+ document.querySelectorAll('#view-switch button').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.view === state.view)));
595
+ document.querySelectorAll('#status-filter button').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.status === state.status)));
596
+ document.getElementById('search').value = state.text;
597
+ document.getElementById('sort-key').value = state.sortKey;
598
+ document.getElementById('dir-toggle').textContent = state.sortDir === 'asc' ? '↑ Ascending' : '↓ Descending';
599
+ }
600
+
601
+ function render() {
602
+ syncToolbar();
603
+ renderStats();
604
+ const filtered = filterLeads(leads, { status: state.status, text: state.text });
605
+ const sorted = sortLeads(filtered, state.sortKey, state.sortDir);
606
+ renderCount(filtered.length, leads.length);
607
+
608
+ document.getElementById('empty').hidden = leads.length !== 0;
609
+ ['cards', 'timeline', 'wall'].forEach((v) => {
610
+ document.getElementById('view-' + v).hidden = v !== state.view || leads.length === 0;
611
+ });
612
+ if (leads.length === 0) return;
613
+
614
+ if (state.view === 'cards') renderCards(sorted);
615
+ else if (state.view === 'timeline') renderTimeline(filtered);
616
+ else renderWall(sorted);
617
+ }
618
+
619
+ // One delegated click listener with a small dispatch table, instead of a
620
+ // separate addEventListener per control.
621
+ const CLICK_ACTIONS = [
622
+ ['#view-switch button[data-view]', (el) => { persist('view', el.dataset.view); render(); }],
623
+ ['#status-filter button[data-status]', (el) => { persist('status', el.dataset.status); render(); }],
624
+ ['#dir-toggle', () => { persist('sortDir', state.sortDir === 'asc' ? 'desc' : 'asc'); render(); }],
625
+ // setStatus manages its own re-render (via load()) once the request settles, so it
626
+ // must not be followed by an immediate render() here.
627
+ ['#view-cards button[data-action]', (el) => setStatus(el.dataset.id, el.dataset.action)],
628
+ ['#view-wall th[data-sort]', (el) => {
629
+ const key = el.dataset.sort;
630
+ const nextDir = state.sortKey === key && state.sortDir === 'asc' ? 'desc' : 'asc';
631
+ persist('sortKey', key);
632
+ persist('sortDir', nextDir);
633
+ render();
634
+ }],
635
+ ];
636
+ document.querySelector('main').addEventListener('click', (e) => {
637
+ for (const [selector, handler] of CLICK_ACTIONS) {
638
+ const el = e.target.closest(selector);
639
+ if (el) return handler(el);
640
+ }
641
+ });
642
+ document.getElementById('search').addEventListener('input', (e) => {
643
+ persist('text', e.target.value);
644
+ render();
645
+ });
646
+ document.getElementById('sort-key').addEventListener('change', (e) => {
647
+ persist('sortKey', e.target.value);
648
+ render();
649
+ });
650
+
651
+ renderWallHead();
652
+ load();
653
+ </script>
654
+ </body>
655
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ # new-lead-dashboard v2
3
+ cd "$(dirname "$0")" && exec node scripts/serve.mjs "$@"