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,104 @@
1
+ ---
2
+ name: sb-build-shopify
3
+ description: Composes a standalone Shopify section `.liquid` file from a live-page inspection plus extracted assets, with editable `{% schema %}` settings, defensive specificity against Dawn / OS 2.0, mobile-first CSS, and a11y/perf defaults baked in. Use when the SimilarBuild orchestrator (`/build-page`, `/build-site`, `/clip-section`) requests a Shopify build with `--target shopify`, or when the user asks to 'build shopify section' from an inspection + assets bundle.
4
+ ---
5
+
6
+ # sb-build-shopify
7
+
8
+ ## Overview
9
+
10
+ Produces the single `.liquid` file a merchant drops into their theme's `sections/` folder — a `{% style %}` block scoped to one root class, the matching markup with `{{ section.settings.* }}` placeholders for every editable value, optional `<script>`, and a mandatory `{% schema %}` JSON block declaring the editable fields and at least one preset. The merchant can then insert the section from "Add section" in the theme editor and edit text, colors, images, links, and toggles without touching code. The fragment must survive Dawn / Online Store 2.0's section-level CSS overrides without any post-paste tweaking.
11
+
12
+ Unlike the upstream skills (`sb-inspect-live`, `sb-extract-assets`) where a script does ~95% of the work, **this skill is creative composition**. The LLM picks the pattern, names the classes and setting `id`s, structures the markup, and decides which values to lift into `{% schema %}` settings vs. hardcode. The `scripts/build-shopify.mjs` helper handles only the deterministic plumbing: structural validation (Liquid tag balance, schema JSON parsing, anti-pattern checks) and formatted persistence to disk.
13
+
14
+ Act as a Shopify theme specialist. You know exactly which Dawn / OS 2.0 overrides bite (typography via `--font-heading-family` / `--font-body-family` CSS variables; `img { max-width: 100%; height: auto }`; section-padding scale via `--section-padding-*`) and you defend against all of them with chained-scope selectors and surgical `!important` on the four font properties only. You design the schema so a non-technical merchant can edit copy, images, and colors from the theme editor sidebar. You do NOT touch HTML for Elementor, Liquid for Webflow, or any other target — that's a different skill's job.
15
+
16
+ ## Inputs
17
+
18
+ | Argument | Required | Notes |
19
+ | ----------------- | -------- | --------------------------------------------------------------------------------------------- |
20
+ | `inspection` | yes | Path to `inspection.json` from `sb-inspect-live`. Drives section type, tokens, DOM structure. |
21
+ | `assetsMap` | yes | Path to `assets-map.json` from `sb-extract-assets`. Source of every fallback image path and inline SVG. |
22
+ | `outputPath` | yes | Where the final `.liquid` is written (parent dirs created automatically). Single-file output. |
23
+ | `designKnowledge` | no | Subset of `<plugin>/memory/design-knowledge.md` filtered by the orchestrator (a11y/perf rules relevant to this section). When absent, use the defaults in `references/shopify-build-rules.md`. |
24
+ | `fixHints` | no | JSON array from `sb-review-checks` after a failed validation cycle. When present, you are patching a previous build, not building from scratch. |
25
+ | `previousLiquidPath` | no | Path to the previous build (only meaningful with `fixHints`). Read it, apply the targeted patches, do not refactor untouched code. |
26
+
27
+ The orchestrator passes these as concrete paths or inline values — there is no CLI for this skill, the LLM drives.
28
+
29
+ ## Output
30
+
31
+ A single `.liquid` file written to `outputPath`. The file is a Shopify section fragment containing in order:
32
+
33
+ 1. Optional `{% style %}{% endstyle %}` block: universal reset → scope container (full-bleed if applicable) → mobile-first element styles with chained-scope selectors → `@media (min-width: 1000px)` desktop overrides. Liquid expressions inside the CSS are allowed and expected (background-image URLs, color settings).
34
+ 2. The scoped markup (`<section class="{scope}">...</section>` or appropriate semantic root), with `{{ section.settings.* }}` placeholders for every editable value.
35
+ 3. Optional `<script>` block for vanilla JS interactivity.
36
+ 4. Mandatory `{% schema %}{% endschema %}` JSON block with `name`, optional `tag` / `class`, `settings` array, optional `blocks` array, and a non-empty `presets` array.
37
+
38
+ No `<html>`, `<head>`, `<body>`, no Google Fonts `<link>` (Shopify owns `<head>`).
39
+
40
+ ## On Activation
41
+
42
+ 1. **Read the inputs.** Parse `inspection.json` (capture `sectionType`, `tokens`, `dom`, `pseudoElements`, `imgUrls`) and `assets-map.json` (the URL → localPath / inline-SVG dictionary). If `fixHints` is given, also read `previousLiquidPath`.
43
+
44
+ 2. **Load the build rules.** Read `references/shopify-build-rules.md` — composition contract, schema-settings lift table (which inspected values become which setting types), defensive-specificity rule, !important policy, full-bleed escape, mobile-first breakpoint, asset-substitution rule, hero rules (no 100vh), font policy (no Google Fonts `<link>`, use `font_face` filter or theme inheritance), a11y/perf defaults, patterns A-H adapted to Liquid + blocks, anti-patterns 1-9 plus Shopify-specific 10-15. Treat it as your reference manual for this build.
45
+
46
+ 3. **Layer in user-curated knowledge if present.** When `<plugin>/memory/patterns.md`, `<plugin>/memory/anti-patterns.md`, or `<plugin>/presets/shopify-section.yaml` exist in the host project, load them and let them OVERRIDE the matching defaults from `shopify-build-rules.md` — they reflect the user's most recent learning. Skip silently when missing.
47
+
48
+ 4. **Compose the .liquid.** Pick the pattern that matches `inspection.sectionType` (and the markup shape — inspect `dom` and `pseudoElements`). Apply every non-negotiable from `shopify-build-rules.md`:
49
+
50
+ - Scope class (kebab-case, `sb-`-prefixed) on the outermost element, chained as ancestor on EVERY selector inside `{% style %}`.
51
+ - Universal reset at the top.
52
+ - Full-bleed container if the section spans viewport-edge.
53
+ - Mobile-first base + `@media (min-width: 1000px)` overrides.
54
+ - Every fallback `<img src>` resolved through `assetsMap.assets[url].localPath`. Settings-driven images use `{{ image | image_url: width: N }}`.
55
+ - SVGs inlined from `assetsMap.assets[url].inline` for icons; file path for hero/content.
56
+ - No 100vh, no fabricated SVG, no Google Fonts `<link>`.
57
+ - Lift every editable value into a `{% schema %}` setting (use the type table in the rules — text, richtext, color, image_picker, url, checkbox, select, range, font_picker). Replace the hardcoded literal with `{{ section.settings.<id> }}`. For `image_picker`, pair with a `{% if %}{% else %}` Liquid fallback to the local path (no `default` field).
58
+ - Heading hierarchy unbroken, alt on every `<img>`, type="button" on every `<button>`, icon-only buttons get `aria-label`.
59
+ - At least one preset in the schema. `category` reasonable (Image, Text, Banners, Promotional).
60
+ - If the section has repeating elements (cards, FAQ entries), model them as `blocks` and emit `{{ block.shopify_attributes }}` on every iterated element.
61
+
62
+ 5. **If `fixHints` are present, patch surgically.** Read the previous output, apply each fixHint to the specific selector, markup, or schema entry it names, and keep everything else untouched. Do not rename setting `id`s — that orphans merchant edits. High-severity hints are mandatory; low-severity are optional unless they conflict.
63
+
64
+ 6. **Validate.** Write the composed `.liquid` to a temp file and run:
65
+
66
+ ```bash
67
+ node {skill-root}/scripts/build-shopify.mjs validate --liquid-file <tmp>
68
+ ```
69
+
70
+ The script reports structural errors (missing `{% schema %}`, invalid schema JSON, missing `name` / `presets`, `image_picker` with `default`, duplicate setting `id`s, unbalanced Liquid tags, missing alt/type, `data:image/svg+xml` raster impostors, `100vh` heights, Google Fonts `<link>`, block loop without `{{ block.shopify_attributes }}`) and warnings (no reset, no defensive-specificity selectors, hardcoded CDN URLs, missing `loading` attrs, `<style>` with Liquid that should be `{% style %}`). Exit code 0 means errors are clean. If it exits 3, fix the flagged issues and re-validate. Warnings are advisory.
71
+
72
+ 7. **Persist.** Pipe the validated `.liquid` into:
73
+
74
+ ```bash
75
+ node {skill-root}/scripts/build-shopify.mjs write --output-path <outputPath>
76
+ ```
77
+
78
+ The script formats with prettier when available (graceful skip when not installed), writes to `outputPath` (single file, no directory layout), and returns `{path, bytes, formatted, validatedSchema, schemaErrors}` JSON. `validatedSchema: true` confirms the persisted schema parsed clean.
79
+
80
+ 8. **Return the result** to the orchestrator: the absolute path to the written file, the validator's report (errors + warnings), and a short note on which pattern was applied and which settings were lifted into the schema. Do not return the file's contents.
81
+
82
+ ## Failure modes
83
+
84
+ | Symptom | Likely cause | What to surface |
85
+ | ---------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------- |
86
+ | Validator returns errors after first compose | Missed a non-negotiable from the rules | Fix and re-validate (up to 2 attempts). If still failing, surface the report. |
87
+ | Schema JSON fails to parse | Trailing comma, unescaped quote, comment in JSON | Strip comments, balance braces, re-validate. JSON is strict — no leniency. |
88
+ | `assetsMap.failed[]` includes a critical asset | Source 404 / network failure during extract | Drop the image (decorative) or use a literal-color placeholder (hero). Never fabricate. Comment in the output. |
89
+ | `inspection.widgetBlocked: true` | Bot challenge on inspect — DOM is unreliable | Stop. Tell the orchestrator the inspection is unusable. Do not compose from a blocked page. |
90
+ | Pattern doesn't match any section in `inspection.dom`| Section type detected but markup is ambiguous | Pick the closest pattern from A-H, document the choice in a comment, surface to the orchestrator. |
91
+ | Prettier missing | Optional dep not installed | Non-fatal — `write` reports `formatted: false, formatterSkippedReason: "prettier-not-installed"`. Output is still written. |
92
+ | liquidjs missing | Optional dep not installed | Non-fatal — full Liquid parse skipped, regex tag-balance check still runs. |
93
+
94
+ ## Conventions
95
+
96
+ - Bare paths (e.g. `scripts/build-shopify.mjs`) resolve from the skill root.
97
+ - `{skill-root}` resolves to this skill's installed directory.
98
+ - `{project-root}` resolves to the project working directory.
99
+ - `<plugin>/memory/...` and `<plugin>/presets/...` are paths inside the SimilarBuild plugin install — read them when present, fall back to bundled defaults when absent.
100
+
101
+ ## Optional npm dependencies
102
+
103
+ - `prettier` — formats the output before write. Skipped gracefully if missing.
104
+ - `liquidjs` — full Liquid parse during validate. Skipped gracefully if missing; regex tag-balance check still runs and catches the common breakage.