similarbuild 0.1.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 (76) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/LICENSE +21 -0
  3. package/README.md +301 -0
  4. package/bin/install.js +256 -0
  5. package/lib/copy-templates.mjs +52 -0
  6. package/lib/install-deps.mjs +62 -0
  7. package/lib/prompt-config.mjs +83 -0
  8. package/lib/verify-env.mjs +19 -0
  9. package/package.json +63 -0
  10. package/scripts/sync-templates.mjs +71 -0
  11. package/templates/commands/build-page.md +490 -0
  12. package/templates/commands/build-site.md +548 -0
  13. package/templates/commands/clip-section.md +519 -0
  14. package/templates/memory/anti-patterns.md +212 -0
  15. package/templates/memory/design-knowledge.md +225 -0
  16. package/templates/memory/fixes.md +163 -0
  17. package/templates/memory/patterns.md +681 -0
  18. package/templates/presets/shopify-section.yaml +51 -0
  19. package/templates/presets/wp-elementor.yaml +49 -0
  20. package/templates/reports/fixtures/mock-run-1.json +115 -0
  21. package/templates/reports/fixtures/mock-run-2.json +72 -0
  22. package/templates/reports/report-renderer.mjs +218 -0
  23. package/templates/reports/report-template.html +571 -0
  24. package/templates/skills/sb-build-shopify/SKILL.md +104 -0
  25. package/templates/skills/sb-build-shopify/references/shopify-build-rules.md +563 -0
  26. package/templates/skills/sb-build-shopify/scripts/build-shopify.mjs +637 -0
  27. package/templates/skills/sb-build-shopify/scripts/tests/test-build-shopify.mjs +424 -0
  28. package/templates/skills/sb-build-wp/SKILL.md +83 -0
  29. package/templates/skills/sb-build-wp/references/wp-build-rules.md +376 -0
  30. package/templates/skills/sb-build-wp/scripts/build-wp.mjs +327 -0
  31. package/templates/skills/sb-build-wp/scripts/tests/test-build-wp.mjs +224 -0
  32. package/templates/skills/sb-compare-visual/SKILL.md +121 -0
  33. package/templates/skills/sb-compare-visual/scripts/compare-visual.mjs +387 -0
  34. package/templates/skills/sb-compare-visual/scripts/lib/compare-tokens.mjs +273 -0
  35. package/templates/skills/sb-compare-visual/scripts/tests/test-compare-tokens.mjs +350 -0
  36. package/templates/skills/sb-compare-visual/scripts/tests/test-compare-visual.mjs +626 -0
  37. package/templates/skills/sb-crawl-and-list/SKILL.md +99 -0
  38. package/templates/skills/sb-crawl-and-list/scripts/crawl-and-list.mjs +437 -0
  39. package/templates/skills/sb-crawl-and-list/scripts/lib/blocklist-filter.mjs +176 -0
  40. package/templates/skills/sb-crawl-and-list/scripts/lib/fallback-crawler.mjs +107 -0
  41. package/templates/skills/sb-crawl-and-list/scripts/lib/page-classifier.mjs +89 -0
  42. package/templates/skills/sb-crawl-and-list/scripts/lib/sitemap-parser.mjs +118 -0
  43. package/templates/skills/sb-crawl-and-list/scripts/tests/test-blocklist-filter.mjs +204 -0
  44. package/templates/skills/sb-crawl-and-list/scripts/tests/test-crawl-and-list.mjs +276 -0
  45. package/templates/skills/sb-crawl-and-list/scripts/tests/test-fallback-crawler.mjs +243 -0
  46. package/templates/skills/sb-crawl-and-list/scripts/tests/test-page-classifier.mjs +120 -0
  47. package/templates/skills/sb-crawl-and-list/scripts/tests/test-sitemap-parser.mjs +157 -0
  48. package/templates/skills/sb-extract-assets/SKILL.md +112 -0
  49. package/templates/skills/sb-extract-assets/scripts/extract-assets.mjs +484 -0
  50. package/templates/skills/sb-extract-assets/scripts/tests/test-extract-assets.mjs +112 -0
  51. package/templates/skills/sb-inspect-live/SKILL.md +105 -0
  52. package/templates/skills/sb-inspect-live/scripts/inspect-live.mjs +693 -0
  53. package/templates/skills/sb-inspect-live/scripts/tests/test-inspect-live.mjs +181 -0
  54. package/templates/skills/sb-review-checks/SKILL.md +113 -0
  55. package/templates/skills/sb-review-checks/references/review-rules.md +195 -0
  56. package/templates/skills/sb-review-checks/scripts/lib/anti-patterns.mjs +379 -0
  57. package/templates/skills/sb-review-checks/scripts/lib/cross-reference.mjs +115 -0
  58. package/templates/skills/sb-review-checks/scripts/lib/design-quality.mjs +541 -0
  59. package/templates/skills/sb-review-checks/scripts/review-checks.mjs +250 -0
  60. package/templates/skills/sb-review-checks/scripts/tests/test-anti-patterns.mjs +343 -0
  61. package/templates/skills/sb-review-checks/scripts/tests/test-cross-reference.mjs +170 -0
  62. package/templates/skills/sb-review-checks/scripts/tests/test-design-quality.mjs +493 -0
  63. package/templates/skills/sb-review-checks/scripts/tests/test-review-checks.mjs +267 -0
  64. package/templates/skills/sb-tweak/SKILL.md +130 -0
  65. package/templates/skills/sb-tweak/references/tweak-patterns.md +157 -0
  66. package/templates/skills/sb-tweak/scripts/lib/diff-summarizer.mjs +140 -0
  67. package/templates/skills/sb-tweak/scripts/lib/element-locator.mjs +507 -0
  68. package/templates/skills/sb-tweak/scripts/lib/intent-parser.mjs +324 -0
  69. package/templates/skills/sb-tweak/scripts/tests/test-diff-summarizer.mjs +248 -0
  70. package/templates/skills/sb-tweak/scripts/tests/test-element-locator.mjs +418 -0
  71. package/templates/skills/sb-tweak/scripts/tests/test-intent-parser.mjs +496 -0
  72. package/templates/skills/sb-tweak/scripts/tests/test-tweak.mjs +407 -0
  73. package/templates/skills/sb-tweak/scripts/tweak.mjs +656 -0
  74. package/templates/skills/sb-validate-render/SKILL.md +120 -0
  75. package/templates/skills/sb-validate-render/scripts/tests/test-validate-render.mjs +304 -0
  76. package/templates/skills/sb-validate-render/scripts/validate-render.mjs +645 -0
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: sb-inspect-live
3
+ description: Inspects a live URL at a given mobile viewport and returns DOM, computed tokens, screenshot, pseudo-elements, and image URLs for visual cloning. Use when the SimilarBuild orchestrator (`/build-page`, `/build-site`, `/clip-section`) requests live inspection, or when the user asks to 'inspect a live page'.
4
+ ---
5
+
6
+ # sb-inspect-live
7
+
8
+ ## Overview
9
+
10
+ Captures everything `sb-build-output` needs to reconstruct a live page faithfully: DOM tree, computed CSS tokens, full-page screenshot, pseudo-elements (`::before`/`::after`), and a normalized list of image URLs. Mobile-first by default (viewport 390×844) — desktop-only inspection masks structural differences that bite during the build (Anti-pattern #4).
11
+
12
+ All deterministic work — Playwright launch, lazy-load triggering, getComputedStyle walk, pseudo-element capture, asset URL collection — happens in `scripts/inspect-live.mjs`. This SKILL.md only describes inputs, outputs, and failure handling so the orchestrator can integrate the result.
13
+
14
+ Act as a visual-fidelity sentinel: if the script returns suspicious output (empty DOM, bot-challenge text, widget blocked), surface that flag rather than passing garbage downstream.
15
+
16
+ ## Inputs
17
+
18
+ | Argument | Required | Default | Notes |
19
+ | ----------------- | -------- | ------------- | ------------------------------------------------------------------------------------ |
20
+ | `url` | yes | — | Absolute URL to inspect. |
21
+ | `viewport-width` | no | `390` | Mobile-first. Override only if the orchestrator explicitly needs desktop. |
22
+ | `viewport-height` | no | `844` | iPhone 14-class default. |
23
+ | `selector` | no | (full page) | CSS selector to scope inspection to one element + descendants. |
24
+ | `wait-strategy` | no | `lazy-load` | `lazy-load` (step-scroll baseline), `auto` (also wait for known widgets), or a specific widget name (`kaching-bundles`, `judge-me`). |
25
+ | `output-dir` | yes | — | Directory where `screenshot.png` and `inspection.json` are written. |
26
+
27
+ If `viewport-width` is unspecified and the project has `.claude/sb-config.yaml` with `default_viewport`, use that. Otherwise 390.
28
+
29
+ ## Output
30
+
31
+ A single JSON object printed to stdout AND saved to `{output-dir}/inspection.json`:
32
+
33
+ ```json
34
+ {
35
+ "url": "https://example.com/page",
36
+ "viewport": { "width": 390, "height": 844 },
37
+ "sectionType": "hero",
38
+ "sectionBoundingBox": { "x": 0, "y": 0, "w": 390, "h": 844 },
39
+ "tokens": {
40
+ "typography": { "h1": {...}, "h2": {...}, "body": {...}, "button": {...} },
41
+ "colors": { "background": "...", "text": "...", "primary": "...", "accent": "..." },
42
+ "layout": { "container": {...}, "section": {...} }
43
+ },
44
+ "dom": [ { "tag": "...", "classes": [...], "id": "...", "text": "...", "bbox": {...}, "computed": {...}, "children": [...] } ],
45
+ "pseudoElements": [ { "selector": "...", "pseudo": "::before", "content": "...", "computed": {...} } ],
46
+ "imgUrls": [ { "url": "...", "type": "img|background|source-srcset", "context": "...", "alt": "...", "bbox": {...} } ],
47
+ "screenshot": "{output-dir}/screenshot.png",
48
+ "widgetBlocked": false
49
+ }
50
+ ```
51
+
52
+ `sectionBoundingBox` is the document-relative bbox (CSS pixels, includes scroll) of the actual section element matched by `sectionType`, when one was found by class/tag signature search. The orchestrator forwards it to `sb-compare-visual --crop-live-bbox` so a section build is diffed against a section slice of the full-page live (resolves anti-pattern #10). It's `null` in three cases: (a) `--selector` was passed (live screenshot is already element-only — no crop needed), (b) only the `h1` heuristic fallback fired (sectionType ended up `hero` but no specific section element was identifiable), or (c) `sectionType` is the generic `section`/`unknown`. Treat `null` as "do not crop".
53
+
54
+ Pseudo-elements are non-negotiable — without them, overlap/accent reconstruction silently drifts (Anti-pattern #6).
55
+
56
+ ## Dependencies
57
+
58
+ The host project must have these npm packages installed (the SimilarBuild installer handles this; for ad-hoc test runs, install at the project root):
59
+
60
+ - `playwright` (with chromium browser — `npx playwright install chromium`)
61
+ - `playwright-extra`
62
+ - `puppeteer-extra-plugin-stealth` (used through `playwright-extra` to bypass bot detection)
63
+
64
+ Node ≥ 20.
65
+
66
+ ## On Activation
67
+
68
+ 1. **Resolve inputs.** Collect `url`, `viewport-width`, `viewport-height`, `selector`, `wait-strategy`, `output-dir` from the caller. Apply defaults above. Read `default_viewport` from `{project-root}/.claude/sb-config.yaml` if it exists and viewport wasn't passed.
69
+
70
+ 2. **Ensure output-dir exists.** `mkdir -p` it.
71
+
72
+ 3. **Run the script.** From the project root:
73
+
74
+ ```bash
75
+ node {skill-root}/scripts/inspect-live.mjs \
76
+ --url "{url}" \
77
+ --viewport-width {viewport-width} \
78
+ --viewport-height {viewport-height} \
79
+ --output-dir "{output-dir}" \
80
+ --wait-strategy "{wait-strategy}" \
81
+ [--selector "{selector}"]
82
+ ```
83
+
84
+ The script handles: stealth chromium launch, iPhone user-agent, `domcontentloaded` + 3.5s settle, step-scroll (0→12000 step 400, 150ms each) to trigger lazy-load, force-eager rewrite of `<img loading="lazy">`, additional waits for known widget selectors, section-type detection, computed-token capture on key elements, depth-bounded DOM walk, pseudo-element walk, image URL collection, and screenshot capture. See `scripts/inspect-live.mjs --help` for the full flag list.
85
+
86
+ 4. **Validate the result.** Parse stdout as JSON. If the script exits non-zero, surface the stderr to the orchestrator and stop — don't fabricate output.
87
+
88
+ 5. **Forward `widgetBlocked`.** If the JSON has `widgetBlocked: true`, do NOT discard the result — pass it through. The orchestrator decides whether to invoke Plan B (ask the user for an alternative URL or scoping). Common triggers: Cloudflare challenge page, < 1KB body, or known bot-challenge text patterns.
89
+
90
+ 6. **Return the JSON unchanged** to the caller. Do not summarize, mutate, or strip fields — `sb-extract-assets` consumes `imgUrls` and `sb-build-output` consumes everything.
91
+
92
+ ## Failure modes
93
+
94
+ | Symptom | Likely cause | What to surface |
95
+ | ------------------------------------------------- | --------------------------------------- | --------------------------------------------------------------------- |
96
+ | Script exits non-zero | Network failure, invalid URL, missing browser | Pass stderr verbatim. Suggest `npx playwright install chromium` if the message mentions a missing browser binary. |
97
+ | `widgetBlocked: true` in JSON | Bot detection / Cloudflare / paywall | Forward unchanged — orchestrator handles escalation. |
98
+ | `dom` is empty but `widgetBlocked: false` | Selector matched no elements | Re-run without `--selector` or refine. The orchestrator may retry. |
99
+ | Screenshot file present but byte-size very small | Page failed to render but didn't crash | Treat as `widgetBlocked` even if not flagged; surface the byte-size. |
100
+
101
+ ## Conventions
102
+
103
+ - Bare paths (e.g. `scripts/inspect-live.mjs`) resolve from the skill root.
104
+ - `{skill-root}` resolves to this skill's installed directory.
105
+ - `{project-root}` resolves to the project working directory.