@greatstore/cli 0.0.42 → 0.0.43
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.
- package/CHANGELOG.md +16 -0
- package/README.md +20 -1
- package/dist/cli.js +533 -163
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to `@greatstore/cli` are recorded here. The format
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
|
|
6
|
+
## 0.0.43 — 2026-08-18
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- `gs apps build` and `gs apps push` now check each component before
|
|
10
|
+
building or uploading it. Findings are reported as **errors** (a
|
|
11
|
+
blocker — the component isn't built or uploaded) or **warnings** (it
|
|
12
|
+
builds and is ready to publish, but something is worth improving),
|
|
13
|
+
and a single run reports everything it found rather than stopping at
|
|
14
|
+
the first problem.
|
|
15
|
+
- New check: a component's props and its `inputSchema.properties` must
|
|
16
|
+
agree. A schema field the component doesn't accept is an error; a prop
|
|
17
|
+
the schema doesn't declare is a warning, since nothing will ever pass
|
|
18
|
+
it. The props GreatStore injects (`onSendMessage`, `onCallTool`,
|
|
19
|
+
`onUpdateModelContext`, `onShowLightbox`, `onClose`, `storeData`,
|
|
20
|
+
`Image`) are exempt.
|
|
21
|
+
|
|
6
22
|
## 0.0.42 — 2026-08-15
|
|
7
23
|
|
|
8
24
|
### Changed
|
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ working.
|
|
|
60
60
|
| Command | What it does |
|
|
61
61
|
| ------------------------------------------------------ | -------------------------------------------------- |
|
|
62
62
|
| `gs apps init <name> [--out <dir>] [--store <s>]` | Scaffold a working component project. |
|
|
63
|
-
| `gs apps build [<name>]` |
|
|
63
|
+
| `gs apps build [<name>]` | Check and build component bundle(s); no args = all. |
|
|
64
64
|
| `gs apps list [--json]` | List components in the current store. |
|
|
65
65
|
| `gs apps pull <name> [--draft\|--live\|--version N] [-o <dir>]` | Download a component to disk. |
|
|
66
66
|
| `gs apps push [<name>] [--manifest path] [--bundle path]` | Upload local changes. |
|
|
@@ -68,6 +68,25 @@ working.
|
|
|
68
68
|
| `gs apps unpublish <name>` | Hide a published component. |
|
|
69
69
|
| `gs apps delete <name> [--yes]` | Remove the component. |
|
|
70
70
|
|
|
71
|
+
### Component checks
|
|
72
|
+
|
|
73
|
+
`gs apps build` and `gs apps push` check each component before they do
|
|
74
|
+
their work, and report what they find as either:
|
|
75
|
+
|
|
76
|
+
- **error** — a blocker. The component isn't built or uploaded until it's
|
|
77
|
+
fixed.
|
|
78
|
+
- **warning** — the component builds and is ready to publish, but
|
|
79
|
+
something is worth improving.
|
|
80
|
+
|
|
81
|
+
The checks cover the manifest (valid JSON, a `name` matching the folder,
|
|
82
|
+
an `inputSchema` simple enough for the assistant to fill reliably) and
|
|
83
|
+
the component's props: every prop it declares should be a field in
|
|
84
|
+
`inputSchema.properties`, apart from the props GreatStore injects
|
|
85
|
+
(`onSendMessage`, `onCallTool`, `onUpdateModelContext`,
|
|
86
|
+
`onShowLightbox`, `onClose`, `storeData`, `Image`). A prop nothing
|
|
87
|
+
declares is a warning — nothing will ever pass it. A schema field the
|
|
88
|
+
component doesn't accept is an error.
|
|
89
|
+
|
|
71
90
|
### Agent skill
|
|
72
91
|
|
|
73
92
|
| Command | What it does |
|
package/dist/cli.js
CHANGED
|
@@ -643,7 +643,7 @@ import { fileURLToPath } from "url";
|
|
|
643
643
|
var cache = null;
|
|
644
644
|
function loadTemplate() {
|
|
645
645
|
if (cache) return cache;
|
|
646
|
-
cache = true ? JSON.parse('{"component/component.tsx":"import React from \\"react\\";\\n\\n// Add your tool args (matching manifest.json#inputSchema.properties)\\n// alongside the GreatStore-injected lifecycle props. See AGENTS.md for\\n// what each lifecycle prop does.\\ninterface Props {\\n onSendMessage: (text: string) => void;\\n onCallTool: (name: string, args: Record<string, unknown>) => void;\\n onUpdateModelContext: (context: string) => void;\\n onShowLightbox: (options: { src: string; originRect?: DOMRect }) => void;\\n onClose: () => void;\\n // Drop-in for <img>: `<Image src=\u2026 alt=\u2026 />`. See AGENTS.md.\\n Image: React.ElementType<React.ComponentProps<\\"img\\">>;\\n}\\n\\n// See AGENTS.md for the design rules (em-based sizing, brand CSS\\n// variables), the lifecycle props, and how to write an async,\\n// backend-backed component.\\nexport default function __GS_PASCAL__(_props: Props): React.ReactElement {\\n return (\\n <div\\n style={{\\n padding: \\"1em\\",\\n border: \\"1px solid var(--color-border-default)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n background: \\"var(--color-surface)\\",\\n color: \\"var(--color-foreground)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n >\\n <strong>__GS_NAME__</strong> \u2014 hello from your component!\\n </div>\\n );\\n}\\n","component/manifest.json":"{\\n \\"name\\": \\"__GS_NAME__\\",\\n \\"displayName\\": \\"__GS_DISPLAY_NAME__\\",\\n \\"description\\": \\"Renders the __GS_NAME__ widget.\\",\\n \\"displayMode\\": \\"inline\\",\\n \\"inputSchema\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {}\\n }\\n}\\n","root/.gitignore":"node_modules/\\ncomponents/*/bundle.js\\ncomponents/*/.gssync.json\\n*.tsbuildinfo\\n.DS_Store\\n","root/.gsrc":"{\\n \\"store\\": \\"__GS_STORE__\\"\\n}\\n","root/AGENTS.md":"# AGENTS.md\\n\\nGuidance for AI coding agents working on the components in this project.\\n`CLAUDE.md` and `GEMINI.md` are symlinks to this file.\\n\\nThese components render inside arbitrary publisher websites (the embed\\nwidget mounts on a host page) as well as the GreatStore storefront. You\\ncontrol neither the host page\'s base font size nor its color scheme, and\\nthe store owner controls the look from GreatStore theme settings. The\\nrules below keep components portable across both.\\n\\n## Design requirements\\n\\n### Never use `rem` for fonts and sizing \u2014 always use `em`\\n\\n`rem` resolves against the host page\'s root font size, which is\\narbitrary and outside our control. A host that sets `html { font-size:\\n8px }` (or 200%) will shrink or blow up every `rem`-based dimension.\\n`em` resolves against the component\'s own font size, so it stays\\nself-consistent wherever the component is mounted.\\n\\nUse `em` for font sizes, padding, margins, gaps, widths, heights,\\nand any other length. Borders may stay in `px` (hairlines should not\\nscale with text).\\n\\n```tsx\\n// Bad \u2014 breaks on hosts with a non-default root font size\\n<div style={{ padding: \\"1rem\\", fontSize: \\"0.875rem\\" }} />\\n\\n// Good\\n<div style={{ padding: \\"1em\\", fontSize: \\"0.875em\\" }} />\\n```\\n\\n### Don\'t hardcode colors, fonts, or corner radius \u2014 use GreatStore brand variables\\n\\nThe store owner themes the assistant from GreatStore settings. Hardcoded\\nvalues ignore that and make the component clash with the rest of the\\nstore. Read from the CSS variables GreatStore injects on the surface\\ninstead, so the component restyles itself when the theme changes.\\n\\nAvailable variables:\\n\\n| Purpose | Variable |\\n| --- | --- |\\n| Surface background | `--color-surface` |\\n| Secondary surface | `--color-surface-secondary` |\\n| Accent surface | `--color-surface-accent` |\\n| Hover surface | `--color-surface-hover` |\\n| Foreground text | `--color-foreground` |\\n| Secondary text | `--color-foreground-secondary` |\\n| Muted text | `--color-foreground-muted` |\\n| Accent text | `--color-foreground-accent` |\\n| Border | `--color-border-default` |\\n| Focus border | `--color-border-focus` |\\n| Primary / brand | `--color-primary` |\\n| Text on primary | `--color-primary-foreground` |\\n| Primary hover | `--color-primary-hover` |\\n| Primary muted | `--color-primary-muted` |\\n| Text on primary muted | `--color-primary-muted-foreground` |\\n| Primary tint | `--color-primary-tint` |\\n| Link | `--color-link` |\\n| Font family | `--font-primary` |\\n| Secondary font family | `--font-secondary` |\\n| Corner radius (scale) | `--radius-xs` \u2026 `--radius-4xl`, `--radius-pill` |\\n\\nThe store owner can set a secondary font family in their GreatStore\\ntheme settings, exposed as `--font-secondary` (it falls back to\\n`--font-primary` when unset). Reach for it to add a tasteful second\\nlayer of typography \u2014 pair `--font-primary` for body copy with\\n`--font-secondary` for headings, prices, or other accents \u2014 so the\\ncomponent reflects the store\'s full type system instead of a single\\nface.\\n\\n```tsx\\n// Bad \u2014 hardcoded, ignores the store\'s theme\\n<button style={{ background: \\"#4f46e5\\", borderRadius: 8, fontFamily: \\"Inter\\" }} />\\n\\n// Good\\n<button\\n style={{\\n background: \\"var(--color-primary)\\",\\n color: \\"var(--color-primary-foreground)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n/>\\n```\\n\\nProvide a sensible fallback only when a value might be absent, e.g.\\n`var(--color-primary, currentColor)`.\\n\\n## Component props\\n\\nEach component receives its tool args (the fields you declare in\\n`manifest.json#inputSchema.properties`) plus these GreatStore-injected\\nlifecycle props, which are always present:\\n\\n| Prop | What it does |\\n| --- | --- |\\n| `onSendMessage(text)` | Send text into the chat as if the shopper typed it. |\\n| `onCallTool(name, args)` | Chain into another remote-component tool by name. |\\n| `onUpdateModelContext(context)` | Inject invisible background context for the model (selected variant, configured options, current step). Replaces the prior value \u2014 never appends; pass `\\"\\"` to clear. Read on the next chat turn. Use it when the assistant should *know* in-component state without a visible message; use `onSendMessage` when you want a turn to happen now. |\\n| `onShowLightbox({ src, originRect? })` | Expand an image in the chat\'s shared full-screen lightbox \u2014 an on-brand zoom overlay your component can\'t render itself (it\'s boxed inside its own bounds and shadow root). Pass the image `src`; for a smooth zoom, also pass the clicked element\'s `getBoundingClientRect()` as `originRect` (omit it and the image grows from the viewport centre). |\\n| `onClose()` | Dismiss the host slot. Over-input clears the overlay, fullscreen reverts the pane, inline is a no-op. |\\n| `Image` | A drop-in for `<img>`: render `<Image src=\u2026 alt=\u2026 />` instead of `<img>` and your images are automatically served at the right size for the store. Takes the same props as `<img>` (`src`, `alt`, `style`, `loading`, `onClick`, \u2026). Previewing the component outside the store? Pass `Image={\\"img\\"}` (or your own component) to render a plain image. |\\n\\n## Async components (backend-backed, render-blocking data)\\n\\nIf a component must load data from a backend/API before it can render\\ncorrectly, make it async \u2014 don\'t render an empty shell and fetch in a\\n`useEffect`. Set `\\"async\\": true` in `manifest.json` and export an async\\ndefault. GreatStore waits for your promise (showing a normal loading\\nstate, so you don\'t render your own placeholder), then renders what it\\nresolves to. Components that render purely from their props stay\\nsynchronous.\\n\\nA thrown error is a **retry signal**: the in-store AI sees it and\\nusually re-calls the tool. So only throw when a *different* call could\\nhelp:\\n\\n1. `await` the backend call, then return the finished JSX.\\n2. Validate the AI-passed props first and throw on bad input \u2014 the AI\\n can fix the args and retry. (Don\'t validate the API\'s *output* and\\n throw: the AI can\'t fix the backend, it\'ll just loop.)\\n3. Broadcast a backend failure ONLY when retrying differently could\\n succeed, and say what to change (e.g. empty search \u2192 \\"try a broader\\n keyword\\"). For idempotent failures (500, timeout, missing record)\\n re-running the same call changes nothing \u2014 render a graceful fallback\\n instead of throwing.\\n\\n```tsx\\nexport default async function Example(props: Props) {\\n if (!props.query?.trim()) throw new Error(\\"missing required prop: query\\");\\n const res = await fetch(`/api/search?q=${encodeURIComponent(props.query)}`);\\n if (res.ok) {\\n const { results } = await res.json();\\n if (results.length === 0)\\n throw new Error(`no results for \\"${props.query}\\" \u2014 try a broader keyword`);\\n return <ul>{/* render results */}</ul>;\\n }\\n return <p>Couldn\'t load results right now.</p>; // idempotent: don\'t throw\\n}\\n```\\n","root/README.md":"# GreatStore components\\n\\nCustom React components published to your GreatStore tenant. Each\\ncomponent lives in its own folder under `components/`.\\n\\n```\\nnpm install\\ngs apps init <component_name> # add a new component\\ngs apps build # builds every components/<name>/bundle.js\\ngs apps push # uploads every changed component as a draft\\ngs apps publish <component_name> # promote a specific component to live\\n```\\n\\n- `gs apps push` (no args) hashes each component and only uploads the ones\\n that have changed since the last sync.\\n- `gs apps pull` (no args) refreshes every remote component into\\n `components/<name>/`. Components with unsaved local edits are skipped\\n with a warning; pass `--force` to overwrite.\\n\\nSee `AGENTS.md` for the design rules every component must follow\\n(em-based sizing, brand CSS variables) \u2014 it doubles as guidance for AI\\ncoding agents (`CLAUDE.md` / `GEMINI.md` symlink to it).\\n","root/package.json":"{\\n \\"name\\": \\"greatstore-components\\",\\n \\"version\\": \\"0.0.1\\",\\n \\"private\\": true,\\n \\"type\\": \\"module\\",\\n \\"scripts\\": {\\n \\"build\\": \\"gs apps build\\",\\n \\"push\\": \\"gs apps build && gs apps push\\"\\n },\\n \\"dependencies\\": {\\n \\"react\\": \\"^19.0.0\\",\\n \\"react-dom\\": \\"^19.0.0\\"\\n },\\n \\"devDependencies\\": {\\n \\"@types/react\\": \\"^19.0.0\\",\\n \\"@types/react-dom\\": \\"^19.0.0\\",\\n \\"@vitejs/plugin-react\\": \\"^4.3.0\\",\\n \\"typescript\\": \\"^5.6.0\\",\\n \\"vite\\": \\"^5.4.0\\"\\n }\\n}\\n","root/tsconfig.json":"{\\n \\"compilerOptions\\": {\\n \\"target\\": \\"ES2022\\",\\n \\"module\\": \\"ESNext\\",\\n \\"moduleResolution\\": \\"Bundler\\",\\n \\"jsx\\": \\"react-jsx\\",\\n \\"lib\\": [\\"ES2022\\", \\"DOM\\"],\\n \\"strict\\": true,\\n \\"esModuleInterop\\": true,\\n \\"skipLibCheck\\": true,\\n \\"isolatedModules\\": true,\\n \\"noEmit\\": true\\n },\\n \\"include\\": [\\"components/**/component.tsx\\", \\"vite.config.ts\\"]\\n}\\n","root/vite.config.ts":"import { defineConfig } from \\"vite\\";\\nimport react from \\"@vitejs/plugin-react\\";\\n\\n// Real builds happen in `gs build` (one Vite invocation per\\n// component, externals + runtime shim paths owned by the CLI). This\\n// file exists only so editors / language servers can resolve the\\n// React plugin when inspecting components/*/component.tsx.\\nexport default defineConfig({\\n plugins: [react()],\\n});\\n"}') : readTreeFromDisk(new URL("../template/", import.meta.url));
|
|
646
|
+
cache = true ? JSON.parse('{"component/component.tsx":"import React from \\"react\\";\\n\\n// Add your tool args (matching manifest.json#inputSchema.properties)\\n// alongside the GreatStore-injected lifecycle props. See AGENTS.md for\\n// what each lifecycle prop does.\\ninterface Props {\\n onSendMessage: (text: string) => void;\\n onCallTool: (name: string, args: Record<string, unknown>) => void;\\n onUpdateModelContext: (context: string) => void;\\n onShowLightbox: (options: { src: string; originRect?: DOMRect }) => void;\\n onClose: () => void;\\n // Drop-in for <img>: `<Image src=\u2026 alt=\u2026 />`. See AGENTS.md.\\n Image: React.ElementType<React.ComponentProps<\\"img\\">>;\\n}\\n\\n// See AGENTS.md for the design rules (em-based sizing, brand CSS\\n// variables), the lifecycle props, and how to write an async,\\n// backend-backed component.\\nexport default function __GS_PASCAL__(_props: Props): React.ReactElement {\\n return (\\n <div\\n style={{\\n padding: \\"1em\\",\\n border: \\"1px solid var(--color-border-default)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n background: \\"var(--color-surface)\\",\\n color: \\"var(--color-foreground)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n >\\n <strong>__GS_NAME__</strong> \u2014 hello from your component!\\n </div>\\n );\\n}\\n","component/manifest.json":"{\\n \\"name\\": \\"__GS_NAME__\\",\\n \\"displayName\\": \\"__GS_DISPLAY_NAME__\\",\\n \\"description\\": \\"Renders the __GS_NAME__ widget.\\",\\n \\"displayMode\\": \\"inline\\",\\n \\"inputSchema\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {}\\n }\\n}\\n","root/.gitignore":"node_modules/\\ncomponents/*/bundle.js\\ncomponents/*/.gssync.json\\n*.tsbuildinfo\\n.DS_Store\\n","root/.gsrc":"{\\n \\"store\\": \\"__GS_STORE__\\"\\n}\\n","root/AGENTS.md":"# AGENTS.md\\n\\nGuidance for AI coding agents working on the components in this project.\\n`CLAUDE.md` and `GEMINI.md` are symlinks to this file.\\n\\nThese components render inside arbitrary publisher websites (the embed\\nwidget mounts on a host page) as well as the GreatStore storefront. You\\ncontrol neither the host page\'s base font size nor its color scheme, and\\nthe store owner controls the look from GreatStore theme settings. The\\nrules below keep components portable across both.\\n\\n## Design requirements\\n\\n### Never use `rem` for fonts and sizing \u2014 always use `em`\\n\\n`rem` resolves against the host page\'s root font size, which is\\narbitrary and outside our control. A host that sets `html { font-size:\\n8px }` (or 200%) will shrink or blow up every `rem`-based dimension.\\n`em` resolves against the component\'s own font size, so it stays\\nself-consistent wherever the component is mounted.\\n\\nUse `em` for font sizes, padding, margins, gaps, widths, heights,\\nand any other length. Borders may stay in `px` (hairlines should not\\nscale with text).\\n\\n```tsx\\n// Bad \u2014 breaks on hosts with a non-default root font size\\n<div style={{ padding: \\"1rem\\", fontSize: \\"0.875rem\\" }} />\\n\\n// Good\\n<div style={{ padding: \\"1em\\", fontSize: \\"0.875em\\" }} />\\n```\\n\\n### Don\'t hardcode colors, fonts, or corner radius \u2014 use GreatStore brand variables\\n\\nThe store owner themes the assistant from GreatStore settings. Hardcoded\\nvalues ignore that and make the component clash with the rest of the\\nstore. Read from the CSS variables GreatStore injects on the surface\\ninstead, so the component restyles itself when the theme changes.\\n\\nAvailable variables:\\n\\n| Purpose | Variable |\\n| --- | --- |\\n| Surface background | `--color-surface` |\\n| Secondary surface | `--color-surface-secondary` |\\n| Accent surface | `--color-surface-accent` |\\n| Hover surface | `--color-surface-hover` |\\n| Foreground text | `--color-foreground` |\\n| Secondary text | `--color-foreground-secondary` |\\n| Muted text | `--color-foreground-muted` |\\n| Accent text | `--color-foreground-accent` |\\n| Border | `--color-border-default` |\\n| Focus border | `--color-border-focus` |\\n| Primary / brand | `--color-primary` |\\n| Text on primary | `--color-primary-foreground` |\\n| Primary hover | `--color-primary-hover` |\\n| Primary muted | `--color-primary-muted` |\\n| Text on primary muted | `--color-primary-muted-foreground` |\\n| Primary tint | `--color-primary-tint` |\\n| Link | `--color-link` |\\n| Font family | `--font-primary` |\\n| Secondary font family | `--font-secondary` |\\n| Corner radius (scale) | `--radius-xs` \u2026 `--radius-4xl`, `--radius-pill` |\\n\\nThe store owner can set a secondary font family in their GreatStore\\ntheme settings, exposed as `--font-secondary` (it falls back to\\n`--font-primary` when unset). Reach for it to add a tasteful second\\nlayer of typography \u2014 pair `--font-primary` for body copy with\\n`--font-secondary` for headings, prices, or other accents \u2014 so the\\ncomponent reflects the store\'s full type system instead of a single\\nface.\\n\\n```tsx\\n// Bad \u2014 hardcoded, ignores the store\'s theme\\n<button style={{ background: \\"#4f46e5\\", borderRadius: 8, fontFamily: \\"Inter\\" }} />\\n\\n// Good\\n<button\\n style={{\\n background: \\"var(--color-primary)\\",\\n color: \\"var(--color-primary-foreground)\\",\\n borderRadius: \\"var(--radius-lg)\\",\\n fontFamily: \\"var(--font-primary)\\",\\n }}\\n/>\\n```\\n\\nProvide a sensible fallback only when a value might be absent, e.g.\\n`var(--color-primary, currentColor)`.\\n\\n## Component props\\n\\nEach component receives its tool args (the fields you declare in\\n`manifest.json#inputSchema.properties`) plus these GreatStore-injected\\nlifecycle props, which are always present:\\n\\n| Prop | What it does |\\n| --- | --- |\\n| `onSendMessage(text)` | Send text into the chat as if the shopper typed it. |\\n| `onCallTool(name, args)` | Chain into another remote-component tool by name. |\\n| `onUpdateModelContext(context)` | Inject invisible background context for the model (selected variant, configured options, current step). Replaces the prior value \u2014 never appends; pass `\\"\\"` to clear. Read on the next chat turn. Use it when the assistant should *know* in-component state without a visible message; use `onSendMessage` when you want a turn to happen now. |\\n| `onShowLightbox({ src, originRect? })` | Expand an image in the chat\'s shared full-screen lightbox \u2014 an on-brand zoom overlay your component can\'t render itself (it\'s boxed inside its own bounds and shadow root). Pass the image `src`; for a smooth zoom, also pass the clicked element\'s `getBoundingClientRect()` as `originRect` (omit it and the image grows from the viewport centre). |\\n| `onClose()` | Dismiss the host slot. Over-input clears the overlay, fullscreen reverts the pane, inline is a no-op. |\\n| `Image` | A drop-in for `<img>`: render `<Image src=\u2026 alt=\u2026 />` instead of `<img>` and your images are automatically served at the right size for the store. Takes the same props as `<img>` (`src`, `alt`, `style`, `loading`, `onClick`, \u2026). Previewing the component outside the store? Pass `Image={\\"img\\"}` (or your own component) to render a plain image. |\\n\\nYour props and `inputSchema.properties` must line up: `gs apps build`\\nerrors if the schema declares a field your component doesn\'t accept, and\\nwarns if your component declares a prop the schema doesn\'t (nothing will\\never pass it). The injected props above are exempt.\\n\\n## Async components (backend-backed, render-blocking data)\\n\\nIf a component must load data from a backend/API before it can render\\ncorrectly, make it async \u2014 don\'t render an empty shell and fetch in a\\n`useEffect`. Set `\\"async\\": true` in `manifest.json` and export an async\\ndefault. GreatStore waits for your promise (showing a normal loading\\nstate, so you don\'t render your own placeholder), then renders what it\\nresolves to. Components that render purely from their props stay\\nsynchronous.\\n\\nA thrown error is a **retry signal**: the in-store AI sees it and\\nusually re-calls the tool. So only throw when a *different* call could\\nhelp:\\n\\n1. `await` the backend call, then return the finished JSX.\\n2. Validate the AI-passed props first and throw on bad input \u2014 the AI\\n can fix the args and retry. (Don\'t validate the API\'s *output* and\\n throw: the AI can\'t fix the backend, it\'ll just loop.)\\n3. Broadcast a backend failure ONLY when retrying differently could\\n succeed, and say what to change (e.g. empty search \u2192 \\"try a broader\\n keyword\\"). For idempotent failures (500, timeout, missing record)\\n re-running the same call changes nothing \u2014 render a graceful fallback\\n instead of throwing.\\n\\n```tsx\\nexport default async function Example(props: Props) {\\n if (!props.query?.trim()) throw new Error(\\"missing required prop: query\\");\\n const res = await fetch(`/api/search?q=${encodeURIComponent(props.query)}`);\\n if (res.ok) {\\n const { results } = await res.json();\\n if (results.length === 0)\\n throw new Error(`no results for \\"${props.query}\\" \u2014 try a broader keyword`);\\n return <ul>{/* render results */}</ul>;\\n }\\n return <p>Couldn\'t load results right now.</p>; // idempotent: don\'t throw\\n}\\n```\\n","root/README.md":"# GreatStore components\\n\\nCustom React components published to your GreatStore tenant. Each\\ncomponent lives in its own folder under `components/`.\\n\\n```\\nnpm install\\ngs apps init <component_name> # add a new component\\ngs apps build # builds every components/<name>/bundle.js\\ngs apps push # uploads every changed component as a draft\\ngs apps publish <component_name> # promote a specific component to live\\n```\\n\\n- `gs apps push` (no args) hashes each component and only uploads the ones\\n that have changed since the last sync.\\n- `gs apps pull` (no args) refreshes every remote component into\\n `components/<name>/`. Components with unsaved local edits are skipped\\n with a warning; pass `--force` to overwrite.\\n\\nSee `AGENTS.md` for the design rules every component must follow\\n(em-based sizing, brand CSS variables) \u2014 it doubles as guidance for AI\\ncoding agents (`CLAUDE.md` / `GEMINI.md` symlink to it).\\n","root/package.json":"{\\n \\"name\\": \\"greatstore-components\\",\\n \\"version\\": \\"0.0.1\\",\\n \\"private\\": true,\\n \\"type\\": \\"module\\",\\n \\"scripts\\": {\\n \\"build\\": \\"gs apps build\\",\\n \\"push\\": \\"gs apps build && gs apps push\\"\\n },\\n \\"dependencies\\": {\\n \\"react\\": \\"^19.0.0\\",\\n \\"react-dom\\": \\"^19.0.0\\"\\n },\\n \\"devDependencies\\": {\\n \\"@types/react\\": \\"^19.0.0\\",\\n \\"@types/react-dom\\": \\"^19.0.0\\",\\n \\"@vitejs/plugin-react\\": \\"^4.3.0\\",\\n \\"typescript\\": \\"^5.6.0\\",\\n \\"vite\\": \\"^5.4.0\\"\\n }\\n}\\n","root/tsconfig.json":"{\\n \\"compilerOptions\\": {\\n \\"target\\": \\"ES2022\\",\\n \\"module\\": \\"ESNext\\",\\n \\"moduleResolution\\": \\"Bundler\\",\\n \\"jsx\\": \\"react-jsx\\",\\n \\"lib\\": [\\"ES2022\\", \\"DOM\\"],\\n \\"strict\\": true,\\n \\"esModuleInterop\\": true,\\n \\"skipLibCheck\\": true,\\n \\"isolatedModules\\": true,\\n \\"noEmit\\": true\\n },\\n \\"include\\": [\\"components/**/component.tsx\\", \\"vite.config.ts\\"]\\n}\\n","root/vite.config.ts":"import { defineConfig } from \\"vite\\";\\nimport react from \\"@vitejs/plugin-react\\";\\n\\n// Real builds happen in `gs build` (one Vite invocation per\\n// component, externals + runtime shim paths owned by the CLI). This\\n// file exists only so editors / language servers can resolve the\\n// React plugin when inspecting components/*/component.tsx.\\nexport default defineConfig({\\n plugins: [react()],\\n});\\n"}') : readTreeFromDisk(new URL("../template/", import.meta.url));
|
|
647
647
|
return cache;
|
|
648
648
|
}
|
|
649
649
|
var TOKENS = {
|
|
@@ -876,13 +876,424 @@ function pascal(name) {
|
|
|
876
876
|
}
|
|
877
877
|
|
|
878
878
|
// src/commands/apps/build.ts
|
|
879
|
+
import * as fs6 from "fs";
|
|
880
|
+
import * as path7 from "path";
|
|
881
|
+
import { createRequire as createRequire2 } from "module";
|
|
882
|
+
|
|
883
|
+
// src/validation/context.ts
|
|
879
884
|
import * as fs5 from "fs";
|
|
880
|
-
import * as
|
|
885
|
+
import * as path6 from "path";
|
|
886
|
+
|
|
887
|
+
// src/validation/ast.ts
|
|
881
888
|
import { createRequire } from "module";
|
|
889
|
+
import * as path5 from "path";
|
|
890
|
+
function analyzeComponentProps(root, sourcePath, sourceText) {
|
|
891
|
+
const ts = loadTypeScript(root);
|
|
892
|
+
if (!ts) {
|
|
893
|
+
return {
|
|
894
|
+
ok: false,
|
|
895
|
+
reason: "couldn't check props against the manifest \u2014 `typescript` isn't installed in this project (run `npm install`)"
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
try {
|
|
899
|
+
const sourceFile = ts.createSourceFile(
|
|
900
|
+
sourcePath,
|
|
901
|
+
sourceText,
|
|
902
|
+
ts.ScriptTarget.Latest,
|
|
903
|
+
true,
|
|
904
|
+
ts.ScriptKind.TSX
|
|
905
|
+
);
|
|
906
|
+
const fn = findDefaultExport(ts, sourceFile);
|
|
907
|
+
if (!fn) {
|
|
908
|
+
return {
|
|
909
|
+
ok: false,
|
|
910
|
+
reason: "couldn't find a default-exported component function to check props against \u2014 export the component as `export default function \u2026`"
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
return propsOfParameter(ts, sourceFile, fn);
|
|
914
|
+
} catch (err) {
|
|
915
|
+
return {
|
|
916
|
+
ok: false,
|
|
917
|
+
reason: `couldn't check props against the manifest \u2014 ${path5.basename(sourcePath)} could not be parsed (${err.message})`
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
function loadTypeScript(root) {
|
|
922
|
+
const localRequire = createRequire(path5.join(root, "package.json"));
|
|
923
|
+
try {
|
|
924
|
+
return localRequire("typescript");
|
|
925
|
+
} catch {
|
|
926
|
+
return null;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
function findDefaultExport(ts, sourceFile) {
|
|
930
|
+
let assigned = null;
|
|
931
|
+
for (const statement of sourceFile.statements) {
|
|
932
|
+
if (ts.isFunctionDeclaration(statement) && hasDefaultModifier(ts, statement)) {
|
|
933
|
+
return statement;
|
|
934
|
+
}
|
|
935
|
+
if (ts.isExportAssignment(statement) && !statement.isExportEquals) {
|
|
936
|
+
assigned = statement.expression;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (!assigned) return null;
|
|
940
|
+
const expression = unwrap(ts, assigned);
|
|
941
|
+
if (ts.isArrowFunction(expression) || ts.isFunctionExpression(expression)) {
|
|
942
|
+
return expression;
|
|
943
|
+
}
|
|
944
|
+
if (ts.isIdentifier(expression)) {
|
|
945
|
+
return findLocalFunction(ts, sourceFile, expression.text);
|
|
946
|
+
}
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
function hasDefaultModifier(ts, node) {
|
|
950
|
+
return node.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword) ?? false;
|
|
951
|
+
}
|
|
952
|
+
function unwrap(ts, node) {
|
|
953
|
+
let current = node;
|
|
954
|
+
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current)) {
|
|
955
|
+
current = current.expression;
|
|
956
|
+
}
|
|
957
|
+
return current;
|
|
958
|
+
}
|
|
959
|
+
function findLocalFunction(ts, sourceFile, name) {
|
|
960
|
+
for (const statement of sourceFile.statements) {
|
|
961
|
+
if (ts.isFunctionDeclaration(statement) && statement.name?.text === name) {
|
|
962
|
+
return statement;
|
|
963
|
+
}
|
|
964
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
965
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
966
|
+
if (!ts.isIdentifier(declaration.name) || declaration.name.text !== name) continue;
|
|
967
|
+
if (!declaration.initializer) continue;
|
|
968
|
+
const initializer = unwrap(ts, declaration.initializer);
|
|
969
|
+
if (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) {
|
|
970
|
+
return initializer;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
function propsOfParameter(ts, sourceFile, fn) {
|
|
977
|
+
const parameter = fn.parameters[0];
|
|
978
|
+
if (!parameter) return { ok: true, props: { names: [], open: false } };
|
|
979
|
+
if (parameter.type) {
|
|
980
|
+
const fromType = namesFromTypeNode(ts, sourceFile, parameter.type, /* @__PURE__ */ new Set());
|
|
981
|
+
if (fromType) return { ok: true, props: fromType };
|
|
982
|
+
}
|
|
983
|
+
if (ts.isObjectBindingPattern(parameter.name)) {
|
|
984
|
+
return { ok: true, props: namesFromBindingPattern(ts, parameter.name) };
|
|
985
|
+
}
|
|
986
|
+
return {
|
|
987
|
+
ok: false,
|
|
988
|
+
reason: "couldn't check props against the manifest \u2014 declare the component's props as a local `interface`/`type` or destructure them in the signature"
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
function namesFromTypeNode(ts, sourceFile, node, seen) {
|
|
992
|
+
if (ts.isTypeLiteralNode(node)) {
|
|
993
|
+
return propsFromMembers(ts, node.members);
|
|
994
|
+
}
|
|
995
|
+
if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName)) {
|
|
996
|
+
return namesFromTypeName(ts, sourceFile, node.typeName.text, seen);
|
|
997
|
+
}
|
|
998
|
+
if (ts.isIntersectionTypeNode(node)) {
|
|
999
|
+
const parts = node.types.map((t) => namesFromTypeNode(ts, sourceFile, t, seen));
|
|
1000
|
+
if (parts.every((p) => p === null)) return null;
|
|
1001
|
+
return mergeProps(parts.map((p) => p ?? { names: [], open: true }));
|
|
1002
|
+
}
|
|
1003
|
+
return null;
|
|
1004
|
+
}
|
|
1005
|
+
function namesFromTypeName(ts, sourceFile, name, seen) {
|
|
1006
|
+
if (seen.has(name)) return { names: [], open: false };
|
|
1007
|
+
seen.add(name);
|
|
1008
|
+
for (const statement of sourceFile.statements) {
|
|
1009
|
+
if (ts.isInterfaceDeclaration(statement) && statement.name.text === name) {
|
|
1010
|
+
const own = propsFromMembers(ts, statement.members);
|
|
1011
|
+
const bases = (statement.heritageClauses ?? []).flatMap(
|
|
1012
|
+
(clause) => clause.types.map(
|
|
1013
|
+
(base) => ts.isIdentifier(base.expression) ? namesFromTypeName(ts, sourceFile, base.expression.text, seen) ?? {
|
|
1014
|
+
names: [],
|
|
1015
|
+
open: true
|
|
1016
|
+
} : { names: [], open: true }
|
|
1017
|
+
)
|
|
1018
|
+
);
|
|
1019
|
+
return mergeProps([own, ...bases]);
|
|
1020
|
+
}
|
|
1021
|
+
if (ts.isTypeAliasDeclaration(statement) && statement.name.text === name) {
|
|
1022
|
+
return namesFromTypeNode(ts, sourceFile, statement.type, seen);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
function propsFromMembers(ts, members) {
|
|
1028
|
+
const names = [];
|
|
1029
|
+
let open = false;
|
|
1030
|
+
for (const member of members) {
|
|
1031
|
+
if (ts.isIndexSignatureDeclaration(member)) {
|
|
1032
|
+
open = true;
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
if (!ts.isPropertySignature(member) && !ts.isMethodSignature(member)) continue;
|
|
1036
|
+
const memberName = staticMemberName(ts, member.name);
|
|
1037
|
+
if (memberName === null) {
|
|
1038
|
+
open = true;
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
names.push(memberName);
|
|
1042
|
+
}
|
|
1043
|
+
return { names, open };
|
|
1044
|
+
}
|
|
1045
|
+
function namesFromBindingPattern(ts, pattern) {
|
|
1046
|
+
const names = [];
|
|
1047
|
+
let open = false;
|
|
1048
|
+
for (const element of pattern.elements) {
|
|
1049
|
+
if (element.dotDotDotToken) {
|
|
1050
|
+
open = true;
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
const key = element.propertyName ?? element.name;
|
|
1054
|
+
const name = staticMemberName(ts, key);
|
|
1055
|
+
if (name === null) open = true;
|
|
1056
|
+
else names.push(name);
|
|
1057
|
+
}
|
|
1058
|
+
return { names, open };
|
|
1059
|
+
}
|
|
1060
|
+
function staticMemberName(ts, name) {
|
|
1061
|
+
if (ts.isIdentifier(name)) return name.text;
|
|
1062
|
+
if (ts.isStringLiteral(name)) return name.text;
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
function mergeProps(parts) {
|
|
1066
|
+
const names = [];
|
|
1067
|
+
let open = false;
|
|
1068
|
+
for (const part of parts) {
|
|
1069
|
+
for (const name of part.names) {
|
|
1070
|
+
if (!names.includes(name)) names.push(name);
|
|
1071
|
+
}
|
|
1072
|
+
open ||= part.open;
|
|
1073
|
+
}
|
|
1074
|
+
return { names, open };
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// src/validation/context.ts
|
|
1078
|
+
function buildContext(paths) {
|
|
1079
|
+
const { root, name } = paths;
|
|
1080
|
+
const componentDir = path6.join(root, "components", name);
|
|
1081
|
+
const manifestPath = paths.manifestPath ?? path6.join(componentDir, "manifest.json");
|
|
1082
|
+
const sourcePath = paths.sourcePath ?? path6.join(componentDir, "component.tsx");
|
|
1083
|
+
const manifestFile = relative4(root, manifestPath);
|
|
1084
|
+
const sourceFile = relative4(root, sourcePath);
|
|
1085
|
+
const diagnostics = [];
|
|
1086
|
+
let manifest = null;
|
|
1087
|
+
const manifestText = readIfPresent(manifestPath);
|
|
1088
|
+
if (manifestText === null) {
|
|
1089
|
+
diagnostics.push({
|
|
1090
|
+
severity: "error",
|
|
1091
|
+
rule: "manifest/missing",
|
|
1092
|
+
file: manifestFile,
|
|
1093
|
+
message: "manifest not found."
|
|
1094
|
+
});
|
|
1095
|
+
} else {
|
|
1096
|
+
try {
|
|
1097
|
+
const parsed = JSON.parse(manifestText);
|
|
1098
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1099
|
+
diagnostics.push({
|
|
1100
|
+
severity: "error",
|
|
1101
|
+
rule: "manifest/invalid",
|
|
1102
|
+
file: manifestFile,
|
|
1103
|
+
message: "manifest must be a JSON object."
|
|
1104
|
+
});
|
|
1105
|
+
} else {
|
|
1106
|
+
manifest = parsed;
|
|
1107
|
+
}
|
|
1108
|
+
} catch (err) {
|
|
1109
|
+
diagnostics.push({
|
|
1110
|
+
severity: "error",
|
|
1111
|
+
rule: "manifest/invalid",
|
|
1112
|
+
file: manifestFile,
|
|
1113
|
+
message: `manifest is not valid JSON: ${err.message}`
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
const sourceText = readIfPresent(sourcePath);
|
|
1118
|
+
const props = sourceText === null ? { ok: false, reason: `couldn't check props against the manifest \u2014 ${sourceFile} not found` } : analyzeComponentProps(root, sourcePath, sourceText);
|
|
1119
|
+
return {
|
|
1120
|
+
ctx: { name, manifestFile, sourceFile, manifest, props },
|
|
1121
|
+
diagnostics
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
function readIfPresent(file) {
|
|
1125
|
+
try {
|
|
1126
|
+
return fs5.readFileSync(file, "utf8");
|
|
1127
|
+
} catch {
|
|
1128
|
+
return null;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
function relative4(root, target) {
|
|
1132
|
+
const rel = path6.relative(root, target);
|
|
1133
|
+
return rel.startsWith("..") ? target : rel.split(path6.sep).join("/");
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// src/validation/injected-props.ts
|
|
1137
|
+
var INJECTED_PROPS = /* @__PURE__ */ new Set([
|
|
1138
|
+
"onSendMessage",
|
|
1139
|
+
"onCallTool",
|
|
1140
|
+
"onClose",
|
|
1141
|
+
"onUpdateModelContext",
|
|
1142
|
+
"onShowLightbox",
|
|
1143
|
+
"storeData",
|
|
1144
|
+
"Image"
|
|
1145
|
+
]);
|
|
1146
|
+
|
|
1147
|
+
// src/validation/rules/component-props.ts
|
|
1148
|
+
function componentPropsRule(ctx) {
|
|
1149
|
+
if (!ctx.manifest) return [];
|
|
1150
|
+
const schemaFields = schemaFieldNames(ctx.manifest.inputSchema);
|
|
1151
|
+
if (schemaFields === null) return [];
|
|
1152
|
+
if (!ctx.props.ok) {
|
|
1153
|
+
return [
|
|
1154
|
+
{
|
|
1155
|
+
severity: "warning",
|
|
1156
|
+
rule: "props/not-analyzable",
|
|
1157
|
+
file: ctx.sourceFile,
|
|
1158
|
+
message: `${ctx.props.reason}.`
|
|
1159
|
+
}
|
|
1160
|
+
];
|
|
1161
|
+
}
|
|
1162
|
+
if (ctx.props.props.open) return [];
|
|
1163
|
+
const declared = new Set(ctx.props.props.names);
|
|
1164
|
+
const schema = new Set(schemaFields);
|
|
1165
|
+
const diagnostics = [];
|
|
1166
|
+
for (const prop of ctx.props.props.names) {
|
|
1167
|
+
if (INJECTED_PROPS.has(prop) || schema.has(prop)) continue;
|
|
1168
|
+
diagnostics.push({
|
|
1169
|
+
severity: "warning",
|
|
1170
|
+
rule: "props/undeclared",
|
|
1171
|
+
file: ctx.sourceFile,
|
|
1172
|
+
message: `prop \`${prop}\` is not declared in ${ctx.manifestFile}#inputSchema.properties, so nothing will ever pass it. Declare it in the schema, or drop it from the component.`
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
for (const field of schemaFields) {
|
|
1176
|
+
if (declared.has(field)) continue;
|
|
1177
|
+
diagnostics.push({
|
|
1178
|
+
severity: "error",
|
|
1179
|
+
rule: "props/missing",
|
|
1180
|
+
file: ctx.sourceFile,
|
|
1181
|
+
message: `${ctx.manifestFile} declares inputSchema field \`${field}\`, but the component does not accept a \`${field}\` prop. Add it to the component's props, or remove it from the schema.`
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
return diagnostics;
|
|
1185
|
+
}
|
|
1186
|
+
function schemaFieldNames(inputSchema) {
|
|
1187
|
+
if (!inputSchema || typeof inputSchema !== "object") return null;
|
|
1188
|
+
const properties = inputSchema["properties"];
|
|
1189
|
+
if (!properties || typeof properties !== "object" || Array.isArray(properties)) {
|
|
1190
|
+
return null;
|
|
1191
|
+
}
|
|
1192
|
+
return Object.keys(properties);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// src/validation/rules/input-schema-complexity.ts
|
|
1196
|
+
var MAX_SCHEMA_BYTES = 8 * 1024;
|
|
1197
|
+
var MAX_SCHEMA_FIELDS = 50;
|
|
1198
|
+
var UNION_KEYWORDS = ["anyOf", "oneOf", "allOf", "$ref", "not"];
|
|
1199
|
+
function measure(node, path14, acc) {
|
|
1200
|
+
if (Array.isArray(node)) {
|
|
1201
|
+
node.forEach((entry, i) => measure(entry, `${path14}[${i}]`, acc));
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (!node || typeof node !== "object") return;
|
|
1205
|
+
const record = node;
|
|
1206
|
+
for (const keyword of UNION_KEYWORDS) {
|
|
1207
|
+
if (keyword in record) acc.unionPaths.push(`${path14}.${keyword}`);
|
|
1208
|
+
}
|
|
1209
|
+
const properties = record["properties"];
|
|
1210
|
+
if (properties && typeof properties === "object" && !Array.isArray(properties)) {
|
|
1211
|
+
for (const [name, sub] of Object.entries(properties)) {
|
|
1212
|
+
acc.fields += 1;
|
|
1213
|
+
measure(sub, `${path14}.${name}`, acc);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if ("items" in record) measure(record["items"], `${path14}[]`, acc);
|
|
1217
|
+
}
|
|
1218
|
+
function inputSchemaComplexityRule(ctx) {
|
|
1219
|
+
const inputSchema = ctx.manifest?.inputSchema;
|
|
1220
|
+
if (!inputSchema || typeof inputSchema !== "object") return [];
|
|
1221
|
+
const acc = {
|
|
1222
|
+
bytes: Buffer.byteLength(JSON.stringify(inputSchema), "utf8"),
|
|
1223
|
+
fields: 0,
|
|
1224
|
+
unionPaths: []
|
|
1225
|
+
};
|
|
1226
|
+
measure(inputSchema, "inputSchema", acc);
|
|
1227
|
+
const problems = [];
|
|
1228
|
+
if (acc.unionPaths.length > 0) {
|
|
1229
|
+
const shown = acc.unionPaths.slice(0, 3).join(", ");
|
|
1230
|
+
const more = acc.unionPaths.length > 3 ? ` (+${acc.unionPaths.length - 3} more)` : "";
|
|
1231
|
+
problems.push(
|
|
1232
|
+
`uses ${shown}${more} \u2014 declare exactly one type per field; accept alternate shapes in component code instead`
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
if (acc.bytes > MAX_SCHEMA_BYTES) {
|
|
1236
|
+
problems.push(
|
|
1237
|
+
`is ${(acc.bytes / 1024).toFixed(1)} KB serialized (limit ${MAX_SCHEMA_BYTES / 1024} KB)`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
if (acc.fields > MAX_SCHEMA_FIELDS) {
|
|
1241
|
+
problems.push(`declares ${acc.fields} fields (limit ${MAX_SCHEMA_FIELDS})`);
|
|
1242
|
+
}
|
|
1243
|
+
if (problems.length === 0) return [];
|
|
1244
|
+
return [
|
|
1245
|
+
{
|
|
1246
|
+
severity: "error",
|
|
1247
|
+
rule: "manifest/input-schema-too-complex",
|
|
1248
|
+
file: ctx.manifestFile,
|
|
1249
|
+
message: `inputSchema ${problems.join("; ")}.
|
|
1250
|
+
A schema this complex is usually a sign the component is overengineered, and the assistant will fill it unreliably or stop calling the tool altogether. Keep it to a small set of flat, single-type fields (one canonical name per concept \u2014 no aliases), and let component code handle formatting, fallbacks, and edge cases.`
|
|
1251
|
+
}
|
|
1252
|
+
];
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
// src/validation/rules/manifest-name.ts
|
|
1256
|
+
function manifestNameRule(ctx) {
|
|
1257
|
+
const declared = ctx.manifest?.name;
|
|
1258
|
+
if (typeof declared !== "string" || declared === ctx.name) return [];
|
|
1259
|
+
return [
|
|
1260
|
+
{
|
|
1261
|
+
severity: "error",
|
|
1262
|
+
rule: "manifest/name-mismatch",
|
|
1263
|
+
file: ctx.manifestFile,
|
|
1264
|
+
message: `manifest name "${declared}" does not match folder name "${ctx.name}".`
|
|
1265
|
+
}
|
|
1266
|
+
];
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// src/validation/types.ts
|
|
1270
|
+
function errorsIn(diagnostics) {
|
|
1271
|
+
return diagnostics.filter((d) => d.severity === "error");
|
|
1272
|
+
}
|
|
1273
|
+
function warningsIn(diagnostics) {
|
|
1274
|
+
return diagnostics.filter((d) => d.severity === "warning");
|
|
1275
|
+
}
|
|
1276
|
+
function formatDiagnostic(d) {
|
|
1277
|
+
return `${d.severity === "error" ? "error" : "warning"} ${d.file}: ${d.message}`;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// src/validation/index.ts
|
|
1281
|
+
var RULES = [
|
|
1282
|
+
manifestNameRule,
|
|
1283
|
+
inputSchemaComplexityRule,
|
|
1284
|
+
componentPropsRule
|
|
1285
|
+
];
|
|
1286
|
+
function validateComponent(paths) {
|
|
1287
|
+
const { ctx, diagnostics } = buildContext(paths);
|
|
1288
|
+
for (const rule of RULES) diagnostics.push(...rule(ctx));
|
|
1289
|
+
return { diagnostics, ok: errorsIn(diagnostics).length === 0 };
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// src/commands/apps/build.ts
|
|
882
1293
|
var COMPONENTS_DIR = "components";
|
|
883
1294
|
async function buildCommand(args) {
|
|
884
1295
|
const root = process.cwd();
|
|
885
|
-
if (!
|
|
1296
|
+
if (!fs6.existsSync(path7.join(root, "package.json")) || !fs6.existsSync(path7.join(root, COMPONENTS_DIR))) {
|
|
886
1297
|
throw new Error(
|
|
887
1298
|
`\`gs apps build\` must run from a project root (contains \`package.json\` and \`${COMPONENTS_DIR}/\`). Current dir: ${root}`
|
|
888
1299
|
);
|
|
@@ -900,16 +1311,33 @@ async function buildCommand(args) {
|
|
|
900
1311
|
if (target && queue.length === 0) {
|
|
901
1312
|
throw new Error(`No component named "${target}" in ./${COMPONENTS_DIR}`);
|
|
902
1313
|
}
|
|
903
|
-
const
|
|
1314
|
+
const invalid = [];
|
|
1315
|
+
const buildable = [];
|
|
904
1316
|
for (const name of queue) {
|
|
905
|
-
const
|
|
906
|
-
const
|
|
1317
|
+
const report = validateComponent({ root, name });
|
|
1318
|
+
for (const diagnostic of report.diagnostics) {
|
|
1319
|
+
process.stdout.write(` ${formatDiagnostic(diagnostic)}
|
|
1320
|
+
`);
|
|
1321
|
+
}
|
|
1322
|
+
(report.ok ? buildable : invalid).push(name);
|
|
1323
|
+
}
|
|
1324
|
+
if (buildable.length === 0) {
|
|
1325
|
+
process.stdout.write(`
|
|
1326
|
+
Nothing built \u2014 fix the errors above.
|
|
1327
|
+
`);
|
|
1328
|
+
process.exitCode = 1;
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
const { build, reactPlugin, transformWithEsbuild } = await loadVite(root);
|
|
1332
|
+
for (const name of buildable) {
|
|
1333
|
+
const dir = path7.join(root, COMPONENTS_DIR, name);
|
|
1334
|
+
const bundlePath = path7.join(dir, "bundle.js");
|
|
907
1335
|
await build({
|
|
908
1336
|
plugins: [reactPlugin()],
|
|
909
1337
|
logLevel: "warn",
|
|
910
1338
|
build: {
|
|
911
1339
|
lib: {
|
|
912
|
-
entry:
|
|
1340
|
+
entry: path7.join(dir, "component.tsx"),
|
|
913
1341
|
formats: ["es"],
|
|
914
1342
|
fileName: () => "bundle.js"
|
|
915
1343
|
},
|
|
@@ -930,8 +1358,8 @@ async function buildCommand(args) {
|
|
|
930
1358
|
sourcemap: false
|
|
931
1359
|
}
|
|
932
1360
|
});
|
|
933
|
-
const beforeBytes =
|
|
934
|
-
const src =
|
|
1361
|
+
const beforeBytes = fs6.statSync(bundlePath).size;
|
|
1362
|
+
const src = fs6.readFileSync(bundlePath, "utf8");
|
|
935
1363
|
const { code } = await transformWithEsbuild(src, bundlePath, {
|
|
936
1364
|
minify: true,
|
|
937
1365
|
legalComments: "none",
|
|
@@ -939,13 +1367,22 @@ async function buildCommand(args) {
|
|
|
939
1367
|
loader: "js",
|
|
940
1368
|
sourcemap: false
|
|
941
1369
|
});
|
|
942
|
-
|
|
1370
|
+
fs6.writeFileSync(bundlePath, code);
|
|
943
1371
|
const afterBytes = Buffer.byteLength(code, "utf8");
|
|
944
1372
|
process.stdout.write(
|
|
945
1373
|
`built ${COMPONENTS_DIR}/${name}/bundle.js (${formatBytes(afterBytes)}, ${pctSmaller(beforeBytes, afterBytes)} smaller)
|
|
946
1374
|
`
|
|
947
1375
|
);
|
|
948
1376
|
}
|
|
1377
|
+
if (invalid.length > 0) {
|
|
1378
|
+
process.stdout.write(
|
|
1379
|
+
`
|
|
1380
|
+
Not built (fix the errors above): ${invalid.join(", ")}
|
|
1381
|
+
`
|
|
1382
|
+
);
|
|
1383
|
+
process.exitCode = 1;
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
949
1386
|
process.stdout.write(
|
|
950
1387
|
`
|
|
951
1388
|
Built locally \u2014 nothing uploaded yet. Next: \`gs apps push\` to upload, then \`gs apps publish <name>\` to ship. If you're an AI assistant: confirm with the user before running these (or just run them if they already asked you to ship end-to-end).
|
|
@@ -953,10 +1390,10 @@ Built locally \u2014 nothing uploaded yet. Next: \`gs apps push\` to upload, the
|
|
|
953
1390
|
);
|
|
954
1391
|
}
|
|
955
1392
|
function listComponents(root) {
|
|
956
|
-
const dir =
|
|
957
|
-
return
|
|
958
|
-
const candidate =
|
|
959
|
-
return
|
|
1393
|
+
const dir = path7.join(root, COMPONENTS_DIR);
|
|
1394
|
+
return fs6.readdirSync(dir).filter((entry) => {
|
|
1395
|
+
const candidate = path7.join(dir, entry);
|
|
1396
|
+
return fs6.statSync(candidate).isDirectory() && fs6.existsSync(path7.join(candidate, "component.tsx"));
|
|
960
1397
|
}).sort();
|
|
961
1398
|
}
|
|
962
1399
|
function formatBytes(n) {
|
|
@@ -968,7 +1405,7 @@ function pctSmaller(before, after) {
|
|
|
968
1405
|
return `${Math.round((1 - after / before) * 100)}%`;
|
|
969
1406
|
}
|
|
970
1407
|
async function loadVite(root) {
|
|
971
|
-
const localRequire =
|
|
1408
|
+
const localRequire = createRequire2(path7.join(root, "package.json"));
|
|
972
1409
|
const vitePath = resolveEsmEntry(localRequire, "vite");
|
|
973
1410
|
if (!vitePath) {
|
|
974
1411
|
throw new Error(
|
|
@@ -1016,30 +1453,30 @@ function resolveEsmEntry(req, specifier) {
|
|
|
1016
1453
|
}
|
|
1017
1454
|
const pkgJsonPath = findOwningPackageJson(anchor, specifier);
|
|
1018
1455
|
if (!pkgJsonPath) return null;
|
|
1019
|
-
const pkgDir =
|
|
1456
|
+
const pkgDir = path7.dirname(pkgJsonPath);
|
|
1020
1457
|
let pkg;
|
|
1021
1458
|
try {
|
|
1022
|
-
pkg = JSON.parse(
|
|
1459
|
+
pkg = JSON.parse(fs6.readFileSync(pkgJsonPath, "utf8"));
|
|
1023
1460
|
} catch {
|
|
1024
1461
|
return null;
|
|
1025
1462
|
}
|
|
1026
1463
|
const fromExports = pickImportEntry(pkg.exports);
|
|
1027
1464
|
const entry = fromExports ?? (typeof pkg.module === "string" ? pkg.module : null) ?? (typeof pkg.main === "string" ? pkg.main : null);
|
|
1028
1465
|
if (!entry) return null;
|
|
1029
|
-
return
|
|
1466
|
+
return path7.resolve(pkgDir, entry);
|
|
1030
1467
|
}
|
|
1031
1468
|
function findOwningPackageJson(start, specifier) {
|
|
1032
|
-
let dir =
|
|
1469
|
+
let dir = path7.dirname(start);
|
|
1033
1470
|
while (true) {
|
|
1034
|
-
const candidate =
|
|
1035
|
-
if (
|
|
1471
|
+
const candidate = path7.join(dir, "package.json");
|
|
1472
|
+
if (fs6.existsSync(candidate)) {
|
|
1036
1473
|
try {
|
|
1037
|
-
const parsed = JSON.parse(
|
|
1474
|
+
const parsed = JSON.parse(fs6.readFileSync(candidate, "utf8"));
|
|
1038
1475
|
if (parsed.name === specifier) return candidate;
|
|
1039
1476
|
} catch {
|
|
1040
1477
|
}
|
|
1041
1478
|
}
|
|
1042
|
-
const parent =
|
|
1479
|
+
const parent = path7.dirname(dir);
|
|
1043
1480
|
if (parent === dir) return null;
|
|
1044
1481
|
dir = parent;
|
|
1045
1482
|
}
|
|
@@ -1099,36 +1536,36 @@ function pad(s, width) {
|
|
|
1099
1536
|
}
|
|
1100
1537
|
|
|
1101
1538
|
// src/commands/apps/pull.ts
|
|
1102
|
-
import * as
|
|
1103
|
-
import * as
|
|
1539
|
+
import * as fs8 from "fs";
|
|
1540
|
+
import * as path9 from "path";
|
|
1104
1541
|
|
|
1105
1542
|
// src/sync.ts
|
|
1106
1543
|
import * as crypto2 from "crypto";
|
|
1107
|
-
import * as
|
|
1108
|
-
import * as
|
|
1544
|
+
import * as fs7 from "fs";
|
|
1545
|
+
import * as path8 from "path";
|
|
1109
1546
|
var SYNC_FILE = ".gssync.json";
|
|
1110
1547
|
function hashString(text) {
|
|
1111
1548
|
return crypto2.createHash("sha256").update(text).digest("hex");
|
|
1112
1549
|
}
|
|
1113
1550
|
function hashFile(filePath) {
|
|
1114
|
-
if (!
|
|
1115
|
-
return hashString(
|
|
1551
|
+
if (!fs7.existsSync(filePath)) return null;
|
|
1552
|
+
return hashString(fs7.readFileSync(filePath, "utf8"));
|
|
1116
1553
|
}
|
|
1117
1554
|
function computeComponentHashes(componentDir) {
|
|
1118
|
-
const manifestHash = hashFile(
|
|
1555
|
+
const manifestHash = hashFile(path8.join(componentDir, "manifest.json"));
|
|
1119
1556
|
if (manifestHash === null) {
|
|
1120
1557
|
throw new Error(`Missing manifest.json in ${componentDir}`);
|
|
1121
1558
|
}
|
|
1122
1559
|
return {
|
|
1123
1560
|
manifestHash,
|
|
1124
|
-
sourceHash: hashFile(
|
|
1561
|
+
sourceHash: hashFile(path8.join(componentDir, "component.tsx"))
|
|
1125
1562
|
};
|
|
1126
1563
|
}
|
|
1127
1564
|
function readSyncState(componentDir) {
|
|
1128
|
-
const file =
|
|
1129
|
-
if (!
|
|
1565
|
+
const file = path8.join(componentDir, SYNC_FILE);
|
|
1566
|
+
if (!fs7.existsSync(file)) return null;
|
|
1130
1567
|
try {
|
|
1131
|
-
const parsed = JSON.parse(
|
|
1568
|
+
const parsed = JSON.parse(fs7.readFileSync(file, "utf8"));
|
|
1132
1569
|
if (typeof parsed.version === "number" && typeof parsed.manifestHash === "string" && typeof parsed.sourceHash === "string") {
|
|
1133
1570
|
return {
|
|
1134
1571
|
version: parsed.version,
|
|
@@ -1142,8 +1579,8 @@ function readSyncState(componentDir) {
|
|
|
1142
1579
|
}
|
|
1143
1580
|
}
|
|
1144
1581
|
function writeSyncState(componentDir, state) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1582
|
+
fs7.writeFileSync(
|
|
1583
|
+
path8.join(componentDir, SYNC_FILE),
|
|
1147
1584
|
JSON.stringify(state, null, 2) + "\n"
|
|
1148
1585
|
);
|
|
1149
1586
|
}
|
|
@@ -1184,7 +1621,7 @@ async function pullCommand(args) {
|
|
|
1184
1621
|
for (const name of targets) {
|
|
1185
1622
|
const outcome = await pullOne({
|
|
1186
1623
|
slug,
|
|
1187
|
-
componentDir:
|
|
1624
|
+
componentDir: path9.join(root, "components", name),
|
|
1188
1625
|
name,
|
|
1189
1626
|
revisionQuery,
|
|
1190
1627
|
force
|
|
@@ -1213,7 +1650,7 @@ async function pullAll(opts) {
|
|
|
1213
1650
|
}
|
|
1214
1651
|
const outcomes = [];
|
|
1215
1652
|
for (const entry of list.components) {
|
|
1216
|
-
const componentDir =
|
|
1653
|
+
const componentDir = path9.join(root, "components", entry.name);
|
|
1217
1654
|
const outcome = await pullOne({
|
|
1218
1655
|
slug,
|
|
1219
1656
|
componentDir,
|
|
@@ -1241,7 +1678,7 @@ ${summary.join(", ")} (of ${outcomes.length}) \u2190 ${slug}
|
|
|
1241
1678
|
}
|
|
1242
1679
|
async function pullOne(opts) {
|
|
1243
1680
|
const { slug, componentDir, name, revisionQuery, force } = opts;
|
|
1244
|
-
if (!force &&
|
|
1681
|
+
if (!force && fs8.existsSync(componentDir)) {
|
|
1245
1682
|
const sync = readSyncState(componentDir);
|
|
1246
1683
|
if (hasLocalChanges(componentDir, sync)) {
|
|
1247
1684
|
return {
|
|
@@ -1262,14 +1699,14 @@ async function pullOne(opts) {
|
|
|
1262
1699
|
message: err instanceof Error ? err.message : String(err)
|
|
1263
1700
|
};
|
|
1264
1701
|
}
|
|
1265
|
-
|
|
1702
|
+
fs8.mkdirSync(componentDir, { recursive: true });
|
|
1266
1703
|
const manifestText = JSON.stringify(data.manifest, null, 2) + "\n";
|
|
1267
|
-
|
|
1268
|
-
|
|
1704
|
+
fs8.writeFileSync(path9.join(componentDir, "manifest.json"), manifestText);
|
|
1705
|
+
fs8.writeFileSync(path9.join(componentDir, "bundle.js"), data.bundle);
|
|
1269
1706
|
const wrote = ["manifest.json", "bundle.js"];
|
|
1270
1707
|
let sourceHash = "";
|
|
1271
1708
|
if (data.source !== null) {
|
|
1272
|
-
|
|
1709
|
+
fs8.writeFileSync(path9.join(componentDir, "component.tsx"), data.source);
|
|
1273
1710
|
wrote.push("component.tsx");
|
|
1274
1711
|
sourceHash = hashString(data.source);
|
|
1275
1712
|
}
|
|
@@ -1287,7 +1724,7 @@ async function pullOne(opts) {
|
|
|
1287
1724
|
return { name, status: "pulled", version: data.version, wrote };
|
|
1288
1725
|
}
|
|
1289
1726
|
function ensureComponentsDir(root) {
|
|
1290
|
-
|
|
1727
|
+
fs8.mkdirSync(path9.join(root, "components"), { recursive: true });
|
|
1291
1728
|
}
|
|
1292
1729
|
function buildRevisionQuery(args) {
|
|
1293
1730
|
const version = flagString(args.flags, "version");
|
|
@@ -1321,72 +1758,14 @@ function printOutcome(outcome, force) {
|
|
|
1321
1758
|
}
|
|
1322
1759
|
|
|
1323
1760
|
// src/commands/apps/push.ts
|
|
1324
|
-
import * as
|
|
1325
|
-
import * as
|
|
1326
|
-
|
|
1327
|
-
// src/commands/apps/manifest-lint.ts
|
|
1328
|
-
var MAX_SCHEMA_BYTES = 8 * 1024;
|
|
1329
|
-
var MAX_SCHEMA_FIELDS = 50;
|
|
1330
|
-
var UNION_KEYWORDS = ["anyOf", "oneOf", "allOf", "$ref", "not"];
|
|
1331
|
-
function measure(node, path12, acc) {
|
|
1332
|
-
if (Array.isArray(node)) {
|
|
1333
|
-
node.forEach((entry, i) => measure(entry, `${path12}[${i}]`, acc));
|
|
1334
|
-
return;
|
|
1335
|
-
}
|
|
1336
|
-
if (!node || typeof node !== "object") return;
|
|
1337
|
-
const record = node;
|
|
1338
|
-
for (const keyword of UNION_KEYWORDS) {
|
|
1339
|
-
if (keyword in record) acc.unionPaths.push(`${path12}.${keyword}`);
|
|
1340
|
-
}
|
|
1341
|
-
const properties = record["properties"];
|
|
1342
|
-
if (properties && typeof properties === "object" && !Array.isArray(properties)) {
|
|
1343
|
-
for (const [name, sub] of Object.entries(properties)) {
|
|
1344
|
-
acc.fields += 1;
|
|
1345
|
-
measure(sub, `${path12}.${name}`, acc);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
if ("items" in record) measure(record["items"], `${path12}[]`, acc);
|
|
1349
|
-
}
|
|
1350
|
-
function assertSaneInputSchema(label, inputSchema) {
|
|
1351
|
-
if (!inputSchema || typeof inputSchema !== "object") return;
|
|
1352
|
-
const acc = {
|
|
1353
|
-
bytes: Buffer.byteLength(JSON.stringify(inputSchema), "utf8"),
|
|
1354
|
-
fields: 0,
|
|
1355
|
-
unionPaths: []
|
|
1356
|
-
};
|
|
1357
|
-
measure(inputSchema, "inputSchema", acc);
|
|
1358
|
-
const problems = [];
|
|
1359
|
-
if (acc.unionPaths.length > 0) {
|
|
1360
|
-
const shown = acc.unionPaths.slice(0, 3).join(", ");
|
|
1361
|
-
const more = acc.unionPaths.length > 3 ? ` (+${acc.unionPaths.length - 3} more)` : "";
|
|
1362
|
-
problems.push(
|
|
1363
|
-
`uses ${shown}${more} \u2014 declare exactly one type per field; accept alternate shapes in component code instead`
|
|
1364
|
-
);
|
|
1365
|
-
}
|
|
1366
|
-
if (acc.bytes > MAX_SCHEMA_BYTES) {
|
|
1367
|
-
problems.push(
|
|
1368
|
-
`is ${(acc.bytes / 1024).toFixed(1)} KB serialized (limit ${MAX_SCHEMA_BYTES / 1024} KB)`
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
|
-
if (acc.fields > MAX_SCHEMA_FIELDS) {
|
|
1372
|
-
problems.push(
|
|
1373
|
-
`declares ${acc.fields} fields (limit ${MAX_SCHEMA_FIELDS})`
|
|
1374
|
-
);
|
|
1375
|
-
}
|
|
1376
|
-
if (problems.length === 0) return;
|
|
1377
|
-
throw new Error(
|
|
1378
|
-
`${label}: inputSchema ${problems.join("; ")}.
|
|
1379
|
-
A schema this complex is usually a sign the component is overengineered, and the assistant will fill it unreliably or stop calling the tool altogether. Keep it to a small set of flat, single-type fields (one canonical name per concept \u2014 no aliases), and let component code handle formatting, fallbacks, and edge cases.`
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
// src/commands/apps/push.ts
|
|
1761
|
+
import * as fs9 from "fs";
|
|
1762
|
+
import * as path10 from "path";
|
|
1384
1763
|
async function pushCommand(args) {
|
|
1385
1764
|
const slug = requireProjectStore();
|
|
1386
1765
|
const root = process.cwd();
|
|
1387
1766
|
rejectLegacyLayout(root);
|
|
1388
|
-
const componentsDir =
|
|
1389
|
-
if (!
|
|
1767
|
+
const componentsDir = path10.join(root, "components");
|
|
1768
|
+
if (!fs9.existsSync(componentsDir)) {
|
|
1390
1769
|
throw new Error(
|
|
1391
1770
|
"No components/ directory here. Run `gs apps init <name>` to scaffold the project root and your first component."
|
|
1392
1771
|
);
|
|
@@ -1445,53 +1824,43 @@ ${summary.join(", ")} (of ${outcomes.length}) \u2192 ${slug}
|
|
|
1445
1824
|
}
|
|
1446
1825
|
async function pushOne(opts) {
|
|
1447
1826
|
const { slug, root, name, force } = opts;
|
|
1448
|
-
const componentDir =
|
|
1449
|
-
if (!
|
|
1827
|
+
const componentDir = path10.join(root, "components", name);
|
|
1828
|
+
if (!fs9.existsSync(componentDir)) {
|
|
1450
1829
|
return {
|
|
1451
1830
|
name,
|
|
1452
1831
|
status: "failed",
|
|
1453
1832
|
message: `components/${name}/ does not exist`
|
|
1454
1833
|
};
|
|
1455
1834
|
}
|
|
1456
|
-
const manifestPath = opts.manifestPath ?
|
|
1457
|
-
const bundlePath = opts.bundlePath ?
|
|
1458
|
-
const sourcePath =
|
|
1459
|
-
if (!
|
|
1460
|
-
return { name, status: "failed", message: `manifest not found: ${manifestPath}` };
|
|
1461
|
-
}
|
|
1462
|
-
if (!fs8.existsSync(bundlePath)) {
|
|
1835
|
+
const manifestPath = opts.manifestPath ? path10.resolve(opts.manifestPath) : path10.join(componentDir, "manifest.json");
|
|
1836
|
+
const bundlePath = opts.bundlePath ? path10.resolve(opts.bundlePath) : path10.join(componentDir, "bundle.js");
|
|
1837
|
+
const sourcePath = path10.join(componentDir, "component.tsx");
|
|
1838
|
+
if (!fs9.existsSync(bundlePath)) {
|
|
1463
1839
|
return {
|
|
1464
1840
|
name,
|
|
1465
1841
|
status: "failed",
|
|
1466
1842
|
message: `bundle not found: ${bundlePath} (did you run \`npm run build\`?)`
|
|
1467
1843
|
};
|
|
1468
1844
|
}
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
name,
|
|
1479
|
-
status: "failed",
|
|
1480
|
-
message: `manifest is not valid JSON: ${err.message}`
|
|
1481
|
-
};
|
|
1845
|
+
const report = validateComponent({
|
|
1846
|
+
root,
|
|
1847
|
+
name,
|
|
1848
|
+
manifestPath,
|
|
1849
|
+
sourcePath
|
|
1850
|
+
});
|
|
1851
|
+
for (const diagnostic of warningsIn(report.diagnostics)) {
|
|
1852
|
+
process.stdout.write(` ${formatDiagnostic(diagnostic)}
|
|
1853
|
+
`);
|
|
1482
1854
|
}
|
|
1483
|
-
if (
|
|
1855
|
+
if (!report.ok) {
|
|
1484
1856
|
return {
|
|
1485
1857
|
name,
|
|
1486
1858
|
status: "failed",
|
|
1487
|
-
message:
|
|
1859
|
+
message: errorsIn(report.diagnostics).map((d) => `${d.file}: ${d.message}`).join(`
|
|
1860
|
+
${OUTCOME_INDENT}`)
|
|
1488
1861
|
};
|
|
1489
1862
|
}
|
|
1490
|
-
|
|
1491
|
-
assertSaneInputSchema(`components/${name}/manifest.json`, manifestInputSchema);
|
|
1492
|
-
} catch (err) {
|
|
1493
|
-
return { name, status: "failed", message: err.message };
|
|
1494
|
-
}
|
|
1863
|
+
const manifestText = fs9.readFileSync(manifestPath, "utf8");
|
|
1495
1864
|
if (!force) {
|
|
1496
1865
|
const hashes2 = computeComponentHashes(componentDir);
|
|
1497
1866
|
const sync = readSyncState(componentDir);
|
|
@@ -1500,8 +1869,8 @@ async function pushOne(opts) {
|
|
|
1500
1869
|
return { name, status: "unchanged" };
|
|
1501
1870
|
}
|
|
1502
1871
|
}
|
|
1503
|
-
const bundleText =
|
|
1504
|
-
const sourceText =
|
|
1872
|
+
const bundleText = fs9.readFileSync(bundlePath, "utf8");
|
|
1873
|
+
const sourceText = fs9.existsSync(sourcePath) ? fs9.readFileSync(sourcePath, "utf8") : null;
|
|
1505
1874
|
const form = new FormData();
|
|
1506
1875
|
form.append(
|
|
1507
1876
|
"manifest",
|
|
@@ -1545,15 +1914,15 @@ async function pushOne(opts) {
|
|
|
1545
1914
|
};
|
|
1546
1915
|
}
|
|
1547
1916
|
function listLocalComponents(componentsDir) {
|
|
1548
|
-
return
|
|
1549
|
-
const dir =
|
|
1550
|
-
return
|
|
1917
|
+
return fs9.readdirSync(componentsDir).filter((entry) => {
|
|
1918
|
+
const dir = path10.join(componentsDir, entry);
|
|
1919
|
+
return fs9.statSync(dir).isDirectory() && fs9.existsSync(path10.join(dir, "manifest.json"));
|
|
1551
1920
|
}).sort();
|
|
1552
1921
|
}
|
|
1553
1922
|
function rejectLegacyLayout(root) {
|
|
1554
|
-
const rootManifest =
|
|
1555
|
-
const componentsDir =
|
|
1556
|
-
if (
|
|
1923
|
+
const rootManifest = path10.join(root, "manifest.json");
|
|
1924
|
+
const componentsDir = path10.join(root, "components");
|
|
1925
|
+
if (fs9.existsSync(rootManifest) && !fs9.existsSync(componentsDir)) {
|
|
1557
1926
|
throw new Error(
|
|
1558
1927
|
[
|
|
1559
1928
|
"Detected the old single-component layout (manifest.json at the project root).",
|
|
@@ -1564,6 +1933,7 @@ function rejectLegacyLayout(root) {
|
|
|
1564
1933
|
);
|
|
1565
1934
|
}
|
|
1566
1935
|
}
|
|
1936
|
+
var OUTCOME_INDENT = " ".repeat(" failed ".length);
|
|
1567
1937
|
function printOutcome2(outcome) {
|
|
1568
1938
|
switch (outcome.status) {
|
|
1569
1939
|
case "pushed":
|
|
@@ -1794,8 +2164,8 @@ function formatList(list) {
|
|
|
1794
2164
|
}
|
|
1795
2165
|
|
|
1796
2166
|
// src/commands/configure/set.ts
|
|
1797
|
-
import * as
|
|
1798
|
-
import * as
|
|
2167
|
+
import * as fs10 from "fs";
|
|
2168
|
+
import * as path11 from "path";
|
|
1799
2169
|
var TEXT_FIELDS = [
|
|
1800
2170
|
"displayName",
|
|
1801
2171
|
"assistantName",
|
|
@@ -1855,11 +2225,11 @@ async function setConfig(args) {
|
|
|
1855
2225
|
`);
|
|
1856
2226
|
}
|
|
1857
2227
|
function readTextFile(filePath, flag) {
|
|
1858
|
-
const resolved =
|
|
1859
|
-
if (!
|
|
2228
|
+
const resolved = path11.resolve(filePath);
|
|
2229
|
+
if (!fs10.existsSync(resolved)) {
|
|
1860
2230
|
throw new Error(`${flag}: file not found: ${resolved}`);
|
|
1861
2231
|
}
|
|
1862
|
-
return
|
|
2232
|
+
return fs10.readFileSync(resolved, "utf8");
|
|
1863
2233
|
}
|
|
1864
2234
|
function parseThemeJson(raw, flag) {
|
|
1865
2235
|
let parsed;
|
|
@@ -1875,8 +2245,8 @@ function parseThemeJson(raw, flag) {
|
|
|
1875
2245
|
}
|
|
1876
2246
|
|
|
1877
2247
|
// src/commands/configure/upload.ts
|
|
1878
|
-
import * as
|
|
1879
|
-
import * as
|
|
2248
|
+
import * as fs11 from "fs";
|
|
2249
|
+
import * as path12 from "path";
|
|
1880
2250
|
|
|
1881
2251
|
// src/commands/configure/shared.ts
|
|
1882
2252
|
var ASSET_KINDS = ["icon", "logoLight", "logoDark"];
|
|
@@ -1901,20 +2271,20 @@ async function uploadAsset(args) {
|
|
|
1901
2271
|
if (!filePath) {
|
|
1902
2272
|
throw new Error(`Usage: gs configure upload <${ASSET_KINDS.join("|")}> <file>`);
|
|
1903
2273
|
}
|
|
1904
|
-
const resolved =
|
|
1905
|
-
if (!
|
|
2274
|
+
const resolved = path12.resolve(filePath);
|
|
2275
|
+
if (!fs11.existsSync(resolved)) {
|
|
1906
2276
|
throw new Error(`File not found: ${resolved}`);
|
|
1907
2277
|
}
|
|
1908
|
-
const mime = MIME_BY_EXT[
|
|
2278
|
+
const mime = MIME_BY_EXT[path12.extname(resolved).toLowerCase()];
|
|
1909
2279
|
if (!mime) {
|
|
1910
2280
|
throw new Error("Unsupported image type. Use .png, .jpg, or .webp.");
|
|
1911
2281
|
}
|
|
1912
|
-
const bytes =
|
|
2282
|
+
const bytes = fs11.readFileSync(resolved);
|
|
1913
2283
|
const form = new FormData();
|
|
1914
2284
|
form.append(
|
|
1915
2285
|
"file",
|
|
1916
2286
|
new Blob([new Uint8Array(bytes)], { type: mime }),
|
|
1917
|
-
|
|
2287
|
+
path12.basename(resolved)
|
|
1918
2288
|
);
|
|
1919
2289
|
const url = `${adminApiBase(slug)}/configure/upload/${kind}`;
|
|
1920
2290
|
const data = await request(url, {
|
|
@@ -2232,9 +2602,9 @@ function recentChangelog(text, minItems = 15) {
|
|
|
2232
2602
|
}
|
|
2233
2603
|
|
|
2234
2604
|
// src/version-check.ts
|
|
2235
|
-
import * as
|
|
2605
|
+
import * as fs12 from "fs";
|
|
2236
2606
|
import * as os3 from "os";
|
|
2237
|
-
import * as
|
|
2607
|
+
import * as path13 from "path";
|
|
2238
2608
|
var REFRESH_COMMAND = "__refresh-version-cache";
|
|
2239
2609
|
var PKG = "@greatstore/cli";
|
|
2240
2610
|
var REGISTRY_URL = `https://registry.npmjs.org/${PKG}/latest`;
|
|
@@ -2295,11 +2665,11 @@ async function fetchLatest() {
|
|
|
2295
2665
|
}
|
|
2296
2666
|
}
|
|
2297
2667
|
function cachePath(home) {
|
|
2298
|
-
return
|
|
2668
|
+
return path13.join(home, ".greatstore", "version-check.json");
|
|
2299
2669
|
}
|
|
2300
2670
|
function readCache(home) {
|
|
2301
2671
|
try {
|
|
2302
|
-
const raw =
|
|
2672
|
+
const raw = fs12.readFileSync(cachePath(home), "utf8");
|
|
2303
2673
|
const parsed = JSON.parse(raw);
|
|
2304
2674
|
if (typeof parsed.latest === "string" && typeof parsed.checkedAt === "number") {
|
|
2305
2675
|
return { latest: parsed.latest, checkedAt: parsed.checkedAt };
|
|
@@ -2311,8 +2681,8 @@ function readCache(home) {
|
|
|
2311
2681
|
function writeCache(home, cache3) {
|
|
2312
2682
|
try {
|
|
2313
2683
|
const file = cachePath(home);
|
|
2314
|
-
|
|
2315
|
-
|
|
2684
|
+
fs12.mkdirSync(path13.dirname(file), { recursive: true });
|
|
2685
|
+
fs12.writeFileSync(file, JSON.stringify(cache3));
|
|
2316
2686
|
} catch {
|
|
2317
2687
|
}
|
|
2318
2688
|
}
|
|
@@ -2334,8 +2704,8 @@ function parseVer(v) {
|
|
|
2334
2704
|
}
|
|
2335
2705
|
|
|
2336
2706
|
// src/index.ts
|
|
2337
|
-
var VERSION = true ? "0.0.
|
|
2338
|
-
var CHANGELOG = true ? "# Changelog\n\nAll notable changes to `@greatstore/cli` are recorded here. The format\nfollows [Keep a Changelog](https://keepachangelog.com/).\n\n## 0.0.42 \u2014 2026-08-15\n\n### Changed\n- `gs apps list` now works outside a project. With no `.gsrc` it lists the\n components of the store you're signed in to, instead of erroring. The\n commands that write files or change the store \u2014 `push`, `pull`, `publish`,\n `unpublish`, `delete` \u2014 still require a project.\n\n## 0.0.41 \u2014 2026-08-14\n\n### Changed\n- Internal authentication rework. Re-run `gs login` after updating.\n\n## 0.0.40 \u2014 2026-07-24\n\n### Removed\n- `gs configure set` no longer accepts `--salesGuide` or\n `--salesGuideFile`, and `gs configure show` no longer lists the field.\n\n## 0.0.39 \u2014 2026-07-21\n\n### Added\n- Components now receive an `Image` prop \u2014 a drop-in for `<img>` that\n serves images at the size they're displayed. Render `<Image src=\u2026 />`\n instead of `<img>`; pass `Image={\"img\"}` to preview a component\n outside a store. Scaffolded into `gs apps init` and documented in\n `AGENTS.md`.\n\n## 0.0.38 \u2014 2026-07-13\n\n### Added\n- `gs login --store <slug>` skips the store picker and signs in\n directly to that store \u2014 fails immediately if your account doesn't\n have access to it, instead of falling back to the picker.\n\n## 0.0.37 \u2014 2026-07-10\n\n### Added\n- Signing in now ends by choosing which store to work on \u2014 skipped\n automatically when your account has exactly one. Commands default to\n that store, so `--store` is rarely needed anymore.\n- `gs switch [<slug>]` changes the working store without signing in\n again.\n- `gs apps init` no longer requires `--store` when your sign-in already\n selected a store.\n\n### Changed\n- A `--store` flag or project `.gsrc` that names a different store than\n the one you signed in to is now an error, so work can't accidentally\n target the wrong store. Run `gs switch` to change stores.\n\n## 0.0.33 \u2014 2026-07-10\n\n### Changed\n- `gs apps push` now rejects a component whose `inputSchema` is too\n complex for the assistant to call reliably: union keywords\n (`anyOf`/`oneOf`/`allOf`/`$ref`/`not`), more than 8 KB serialized, or\n more than 50 declared fields. Keep schemas to a small set of flat,\n single-type fields \u2014 one canonical name per concept \u2014 and handle\n aliases or edge cases in component code instead.\n\n## 0.0.32 \u2014 2026-06-18\n\n### Added\n- Chat components can expand an image into a full-screen, on-brand\n lightbox via a new `onShowLightbox({ src, originRect })` prop. Wire it\n to an image's `onClick` \u2014 pass the image URL and, for a smooth zoom,\n the clicked element's `getBoundingClientRect()`. Use it for product\n photos, swatches, or size charts the shopper may want to inspect up\n close, instead of building your own overlay.\n\n## 0.0.31 \u2014 2026-06-18\n\n### Added\n- Components can read a secondary brand font from `--font-secondary`,\n for a second layer of typography. Falls back to the primary font.\n\n### Changed\n- The brand font variable is now `--font-primary` (was `--font-sans`).\n\n## 0.0.30 \u2014 2026-06-17\n\n### Added\n- The agent skill documents a new way to give the assistant background\n context without sending a visible message:\n `window.GreatStore.updateModelContext(text)` on the page, and the\n matching `onUpdateModelContext(text)` prop inside a chat component. Use\n it to keep the assistant aware of what the shopper is doing \u2014 the\n product they're viewing, what's in their cart, the variant they just\n selected \u2014 so its replies stay on point. Each call replaces the previous\n value, and nothing renders in the chat.\n\n## 0.0.29 \u2014 2026-06-12\n\n### Fixed\n- The \"update available\" notice actually fires now. It previously raced\n a 1-second timeout against the npm registry and usually lost, so most\n installs never saw it. The notice is now served instantly from a local\n cache, refreshed in the background after each day's first invocation \u2014\n it can lag one run behind a release, but it no longer adds latency or\n goes silent on slow networks.\n\n## 0.0.28 \u2014 2026-06-12\n\n### Added\n- `gs configure` \u2014 view and edit the store configuration from the CLI:\n display name, assistant name, sales guide, store link, extra origins,\n theme, CSP host lists, and icon/logo uploads. Same fields and\n behaviour as the dashboard's Configure panel.\n- `gs connectors` \u2014 manage the store's MCP connectors: list, add (with\n a discovery probe before saving), remove, enable/disable, toggle the\n Maker MCP, and health-check. Same behaviour as the dashboard's\n Connectors panel.\n- `--store <slug>` on the new admin commands, so they work outside a\n scaffolded component project (a `.gsrc` is still used when present).\n- The agent skill gains a store-administration reference: coding agents\n can read the store's configuration and connectors to ground their\n work, self-serve additive changes like origin allowlists and CSP\n hosts (read-merge-write), and are told which changes need the\n merchant's go-ahead first.\n\n### Changed\n- Component commands now live under `gs apps` (`gs apps push`,\n `gs apps build`, \u2026), matching the dashboard's Apps panel. The old\n top-level forms keep working as aliases, so existing scripts and\n scaffolded projects are unaffected.\n- The skill's structured-content guide now teaches \"point, don't\n paste\": name the SKU/product/collection and let GreatStore research\n the catalog itself instead of inlining fetched specs; validate with\n `gs connectors` that a connector exists for the data a prompt or\n schema depends on (research can't exceed the wired-up connectors);\n and never put shopper data in prompts \u2014 GreatStore already knows the\n shopper, and identified shoppers get per-shopper cached responses.\n\n## 0.0.27 \u2014 2026-06-11\n\n### Changed\n- Skill code samples now carry an explicit reference-only disclaimer:\n coding agents are told to re-express the logic in the host repo's\n framework (React, Vue, Shopify Liquid, Svelte, \u2026) instead of\n retrofitting the framework-free samples as-is.\n\n## 0.0.26 \u2014 2026-06-11\n\n### Added\n- The agent skill gains a \"GreatStore launchers\" recipe: a horizontally\n scrollable row of AI-generated chips, each an engaging first-person\n question about the current page that's sent to the assistant on tap.\n\n### Changed\n- Skill recipes are now one file each under `recipes/`, indexed from\n SKILL.md by a table with description and use-case columns.\n\n## 0.0.25 \u2014 2026-06-11\n\n### Added\n- `gs skill` installs the GreatStore agent skill \u2014 a guide AI coding\n agents use to build with GreatStore: AI content for your own UI, chat\n entry points, page tools, custom in-chat components, push\n notifications, and the store's MCP endpoints. Installs into\n `./.claude/skills/`; use `--global` for `~/.claude/skills/`, or\n `--dir <path>` for agents that read skills from somewhere else. Run\n it again any time to update an installed copy.\n\n## 0.0.24 \u2014 2026-06-03\n\n### Changed\n- `gs init` in an existing project now fills in any scaffold files that\n are missing (for example, the `AGENTS.md` design guide added in\n 0.0.23) and leaves your own files alone. Pass `--force` to refresh\n every scaffold file to the latest version. Your pinned store\n (`.gsrc`) is never rewritten either way.\n\n## 0.0.23 \u2014 2026-06-03\n\n### Added\n- `gs init` now scaffolds an `AGENTS.md` (with `CLAUDE.md` and\n `GEMINI.md` symlinked to it) documenting the design rules every\n component should follow \u2014 use `em` rather than `rem` for sizing, and\n style from the provided brand CSS variables so components match the\n store's theme. It doubles as guidance for AI coding agents.\n\n## 0.0.22 \u2014 2026-06-02\n\n### Added\n- `gs list` now shows a link to each component's page in the dashboard,\n so you can jump straight to a component to preview or publish it. The\n link is also included in `gs list --json`.\n\n## 0.0.21 \u2014 2026-05-31\n\n### Changed\n- The `gs init` component scaffold now shows how to write **async**\n components that load data before they render \u2014 including validating\n inputs up front and signalling a failure by throwing. The scaffolded\n component no longer includes an `onError` prop; throw from an async\n component to report a failure instead.\n\n## 0.0.20 \u2014 2026-05-29\n\n### Added\n- `gs pull`, `gs push`, and `gs publish` now accept several component\n names at once (e.g. `gs publish header footer cart`). Each component\n is reported on its own line and one failure no longer stops the rest.\n\n## 0.0.19 \u2014 2026-05-28\n\n### Fixed\n- `gs login` on Windows no longer opens a sign-in URL with parameters\n stripped, which surfaced as a \"Missing redirect_uri or state\n parameter\" page in the browser.\n\n## 0.0.18 \u2014 2026-05-28\n\n### Changed\n- Push and publish errors now name the specific reason \u2014 including\n every failing field in `manifest.json` \u2014 instead of the previous\n generic message.\n\n## 0.0.17 \u2014 2026-05-28\n\n### Added\n- Each command now prints a one-line upgrade notice when a newer\n `@greatstore/cli` is available on npm.\n\n## 0.0.16 \u2014 2026-05-28\n\n### Changed\n- Simplified error messages.\n\n## 0.0.15 \u2014 2026-05-24\n\n### Added\n- Scaffolded `component.tsx` now declares the four injected lifecycle\n props (`onSendMessage`, `onCallTool`, `onClose`, `onError`) on\n `Props`. Use `onError(message)` to report expected failures (failed\n fetch, host action rejected, invalid host state) so the AI can\n recover on its next turn. Render-time crashes are reported for you.\n\n## 0.0.14 \u2014 2026-05-24\n\n### Changed\n- `gs build` output is now whitespace-minified \u2014 typically ~50% smaller.\n\n## 0.0.13 \u2014 2026-05-24\n\n### Changed\n- `gs build` prints the next-step hint (`gs push`, then `gs publish`).\n\n## 0.0.12 \u2014 2026-05-24\n\n### Fixed\n- `gs build` failing to load Vite in some setups.\n\n## 0.0.11 \u2014 2026-05-24\n\n### Added\n- Multi-component projects. `gs init` (no args) scaffolds the project\n root; `gs init <name>` adds a component under `components/<name>/`.\n- `gs build [<name>]` \u2014 compiles every `components/<name>/bundle.js`.\n- `gs push` (no args) uploads only the components that changed.\n- `gs pull` (no args, or `*`) downloads every component. Locally\n edited components are skipped; pass `--force` to overwrite.\n- Public `CHANGELOG.md`; `gs --version` prints recent entries.\n\n### Changed\n- A project folder ships to exactly one store. Only `gs init` accepts\n `--store`; every other command reads the slug from `.gsrc`. The old\n single-component layout is rejected with a migration hint.\n- `gs init` requires `--store <slug>` for a fresh root, and rejects\n `--store` on an existing root.\n- `gs init` no longer writes `build.mjs` \u2014 scripts call `gs build`.\n\n## 0.0.10 \u2014 2026-05-23\n\n### Changed\n- The sign-in browser tab auto-closes once `gs login` finishes.\n\n## 0.0.9 \u2014 2026-05-23\n\n### Changed\n- Scaffolded manifests include a `displayName` so the admin UI has a\n friendlier label.\n\n## 0.0.8 \u2014 2026-05-23\n\n### Changed\n- `gs push` and `gs publish` print a link to view the component.\n\n## 0.0.6 \u2014 2026-05-23\n\n### Changed\n- `gs --version` reads from the published package version.\n\n## 0.0.4 \u2014 2026-05-23\n\n### Changed\n- Scaffolded projects produce browser-ready bundles out of the box.\n\n## 0.0.3 \u2014 2026-05-23\n\n### Changed\n- Trimmed public README to the essentials.\n\n## 0.0.2 \u2014 2026-05-23\n\n### Fixed\n- Sign-in callback parameter handling.\n" : "";
|
|
2707
|
+
var VERSION = true ? "0.0.43" : "0.0.0-dev";
|
|
2708
|
+
var CHANGELOG = true ? "# Changelog\n\nAll notable changes to `@greatstore/cli` are recorded here. The format\nfollows [Keep a Changelog](https://keepachangelog.com/).\n\n## 0.0.43 \u2014 2026-08-18\n\n### Added\n- `gs apps build` and `gs apps push` now check each component before\n building or uploading it. Findings are reported as **errors** (a\n blocker \u2014 the component isn't built or uploaded) or **warnings** (it\n builds and is ready to publish, but something is worth improving),\n and a single run reports everything it found rather than stopping at\n the first problem.\n- New check: a component's props and its `inputSchema.properties` must\n agree. A schema field the component doesn't accept is an error; a prop\n the schema doesn't declare is a warning, since nothing will ever pass\n it. The props GreatStore injects (`onSendMessage`, `onCallTool`,\n `onUpdateModelContext`, `onShowLightbox`, `onClose`, `storeData`,\n `Image`) are exempt.\n\n## 0.0.42 \u2014 2026-08-15\n\n### Changed\n- `gs apps list` now works outside a project. With no `.gsrc` it lists the\n components of the store you're signed in to, instead of erroring. The\n commands that write files or change the store \u2014 `push`, `pull`, `publish`,\n `unpublish`, `delete` \u2014 still require a project.\n\n## 0.0.41 \u2014 2026-08-14\n\n### Changed\n- Internal authentication rework. Re-run `gs login` after updating.\n\n## 0.0.40 \u2014 2026-07-24\n\n### Removed\n- `gs configure set` no longer accepts `--salesGuide` or\n `--salesGuideFile`, and `gs configure show` no longer lists the field.\n\n## 0.0.39 \u2014 2026-07-21\n\n### Added\n- Components now receive an `Image` prop \u2014 a drop-in for `<img>` that\n serves images at the size they're displayed. Render `<Image src=\u2026 />`\n instead of `<img>`; pass `Image={\"img\"}` to preview a component\n outside a store. Scaffolded into `gs apps init` and documented in\n `AGENTS.md`.\n\n## 0.0.38 \u2014 2026-07-13\n\n### Added\n- `gs login --store <slug>` skips the store picker and signs in\n directly to that store \u2014 fails immediately if your account doesn't\n have access to it, instead of falling back to the picker.\n\n## 0.0.37 \u2014 2026-07-10\n\n### Added\n- Signing in now ends by choosing which store to work on \u2014 skipped\n automatically when your account has exactly one. Commands default to\n that store, so `--store` is rarely needed anymore.\n- `gs switch [<slug>]` changes the working store without signing in\n again.\n- `gs apps init` no longer requires `--store` when your sign-in already\n selected a store.\n\n### Changed\n- A `--store` flag or project `.gsrc` that names a different store than\n the one you signed in to is now an error, so work can't accidentally\n target the wrong store. Run `gs switch` to change stores.\n\n## 0.0.33 \u2014 2026-07-10\n\n### Changed\n- `gs apps push` now rejects a component whose `inputSchema` is too\n complex for the assistant to call reliably: union keywords\n (`anyOf`/`oneOf`/`allOf`/`$ref`/`not`), more than 8 KB serialized, or\n more than 50 declared fields. Keep schemas to a small set of flat,\n single-type fields \u2014 one canonical name per concept \u2014 and handle\n aliases or edge cases in component code instead.\n\n## 0.0.32 \u2014 2026-06-18\n\n### Added\n- Chat components can expand an image into a full-screen, on-brand\n lightbox via a new `onShowLightbox({ src, originRect })` prop. Wire it\n to an image's `onClick` \u2014 pass the image URL and, for a smooth zoom,\n the clicked element's `getBoundingClientRect()`. Use it for product\n photos, swatches, or size charts the shopper may want to inspect up\n close, instead of building your own overlay.\n\n## 0.0.31 \u2014 2026-06-18\n\n### Added\n- Components can read a secondary brand font from `--font-secondary`,\n for a second layer of typography. Falls back to the primary font.\n\n### Changed\n- The brand font variable is now `--font-primary` (was `--font-sans`).\n\n## 0.0.30 \u2014 2026-06-17\n\n### Added\n- The agent skill documents a new way to give the assistant background\n context without sending a visible message:\n `window.GreatStore.updateModelContext(text)` on the page, and the\n matching `onUpdateModelContext(text)` prop inside a chat component. Use\n it to keep the assistant aware of what the shopper is doing \u2014 the\n product they're viewing, what's in their cart, the variant they just\n selected \u2014 so its replies stay on point. Each call replaces the previous\n value, and nothing renders in the chat.\n\n## 0.0.29 \u2014 2026-06-12\n\n### Fixed\n- The \"update available\" notice actually fires now. It previously raced\n a 1-second timeout against the npm registry and usually lost, so most\n installs never saw it. The notice is now served instantly from a local\n cache, refreshed in the background after each day's first invocation \u2014\n it can lag one run behind a release, but it no longer adds latency or\n goes silent on slow networks.\n\n## 0.0.28 \u2014 2026-06-12\n\n### Added\n- `gs configure` \u2014 view and edit the store configuration from the CLI:\n display name, assistant name, sales guide, store link, extra origins,\n theme, CSP host lists, and icon/logo uploads. Same fields and\n behaviour as the dashboard's Configure panel.\n- `gs connectors` \u2014 manage the store's MCP connectors: list, add (with\n a discovery probe before saving), remove, enable/disable, toggle the\n Maker MCP, and health-check. Same behaviour as the dashboard's\n Connectors panel.\n- `--store <slug>` on the new admin commands, so they work outside a\n scaffolded component project (a `.gsrc` is still used when present).\n- The agent skill gains a store-administration reference: coding agents\n can read the store's configuration and connectors to ground their\n work, self-serve additive changes like origin allowlists and CSP\n hosts (read-merge-write), and are told which changes need the\n merchant's go-ahead first.\n\n### Changed\n- Component commands now live under `gs apps` (`gs apps push`,\n `gs apps build`, \u2026), matching the dashboard's Apps panel. The old\n top-level forms keep working as aliases, so existing scripts and\n scaffolded projects are unaffected.\n- The skill's structured-content guide now teaches \"point, don't\n paste\": name the SKU/product/collection and let GreatStore research\n the catalog itself instead of inlining fetched specs; validate with\n `gs connectors` that a connector exists for the data a prompt or\n schema depends on (research can't exceed the wired-up connectors);\n and never put shopper data in prompts \u2014 GreatStore already knows the\n shopper, and identified shoppers get per-shopper cached responses.\n\n## 0.0.27 \u2014 2026-06-11\n\n### Changed\n- Skill code samples now carry an explicit reference-only disclaimer:\n coding agents are told to re-express the logic in the host repo's\n framework (React, Vue, Shopify Liquid, Svelte, \u2026) instead of\n retrofitting the framework-free samples as-is.\n\n## 0.0.26 \u2014 2026-06-11\n\n### Added\n- The agent skill gains a \"GreatStore launchers\" recipe: a horizontally\n scrollable row of AI-generated chips, each an engaging first-person\n question about the current page that's sent to the assistant on tap.\n\n### Changed\n- Skill recipes are now one file each under `recipes/`, indexed from\n SKILL.md by a table with description and use-case columns.\n\n## 0.0.25 \u2014 2026-06-11\n\n### Added\n- `gs skill` installs the GreatStore agent skill \u2014 a guide AI coding\n agents use to build with GreatStore: AI content for your own UI, chat\n entry points, page tools, custom in-chat components, push\n notifications, and the store's MCP endpoints. Installs into\n `./.claude/skills/`; use `--global` for `~/.claude/skills/`, or\n `--dir <path>` for agents that read skills from somewhere else. Run\n it again any time to update an installed copy.\n\n## 0.0.24 \u2014 2026-06-03\n\n### Changed\n- `gs init` in an existing project now fills in any scaffold files that\n are missing (for example, the `AGENTS.md` design guide added in\n 0.0.23) and leaves your own files alone. Pass `--force` to refresh\n every scaffold file to the latest version. Your pinned store\n (`.gsrc`) is never rewritten either way.\n\n## 0.0.23 \u2014 2026-06-03\n\n### Added\n- `gs init` now scaffolds an `AGENTS.md` (with `CLAUDE.md` and\n `GEMINI.md` symlinked to it) documenting the design rules every\n component should follow \u2014 use `em` rather than `rem` for sizing, and\n style from the provided brand CSS variables so components match the\n store's theme. It doubles as guidance for AI coding agents.\n\n## 0.0.22 \u2014 2026-06-02\n\n### Added\n- `gs list` now shows a link to each component's page in the dashboard,\n so you can jump straight to a component to preview or publish it. The\n link is also included in `gs list --json`.\n\n## 0.0.21 \u2014 2026-05-31\n\n### Changed\n- The `gs init` component scaffold now shows how to write **async**\n components that load data before they render \u2014 including validating\n inputs up front and signalling a failure by throwing. The scaffolded\n component no longer includes an `onError` prop; throw from an async\n component to report a failure instead.\n\n## 0.0.20 \u2014 2026-05-29\n\n### Added\n- `gs pull`, `gs push`, and `gs publish` now accept several component\n names at once (e.g. `gs publish header footer cart`). Each component\n is reported on its own line and one failure no longer stops the rest.\n\n## 0.0.19 \u2014 2026-05-28\n\n### Fixed\n- `gs login` on Windows no longer opens a sign-in URL with parameters\n stripped, which surfaced as a \"Missing redirect_uri or state\n parameter\" page in the browser.\n\n## 0.0.18 \u2014 2026-05-28\n\n### Changed\n- Push and publish errors now name the specific reason \u2014 including\n every failing field in `manifest.json` \u2014 instead of the previous\n generic message.\n\n## 0.0.17 \u2014 2026-05-28\n\n### Added\n- Each command now prints a one-line upgrade notice when a newer\n `@greatstore/cli` is available on npm.\n\n## 0.0.16 \u2014 2026-05-28\n\n### Changed\n- Simplified error messages.\n\n## 0.0.15 \u2014 2026-05-24\n\n### Added\n- Scaffolded `component.tsx` now declares the four injected lifecycle\n props (`onSendMessage`, `onCallTool`, `onClose`, `onError`) on\n `Props`. Use `onError(message)` to report expected failures (failed\n fetch, host action rejected, invalid host state) so the AI can\n recover on its next turn. Render-time crashes are reported for you.\n\n## 0.0.14 \u2014 2026-05-24\n\n### Changed\n- `gs build` output is now whitespace-minified \u2014 typically ~50% smaller.\n\n## 0.0.13 \u2014 2026-05-24\n\n### Changed\n- `gs build` prints the next-step hint (`gs push`, then `gs publish`).\n\n## 0.0.12 \u2014 2026-05-24\n\n### Fixed\n- `gs build` failing to load Vite in some setups.\n\n## 0.0.11 \u2014 2026-05-24\n\n### Added\n- Multi-component projects. `gs init` (no args) scaffolds the project\n root; `gs init <name>` adds a component under `components/<name>/`.\n- `gs build [<name>]` \u2014 compiles every `components/<name>/bundle.js`.\n- `gs push` (no args) uploads only the components that changed.\n- `gs pull` (no args, or `*`) downloads every component. Locally\n edited components are skipped; pass `--force` to overwrite.\n- Public `CHANGELOG.md`; `gs --version` prints recent entries.\n\n### Changed\n- A project folder ships to exactly one store. Only `gs init` accepts\n `--store`; every other command reads the slug from `.gsrc`. The old\n single-component layout is rejected with a migration hint.\n- `gs init` requires `--store <slug>` for a fresh root, and rejects\n `--store` on an existing root.\n- `gs init` no longer writes `build.mjs` \u2014 scripts call `gs build`.\n\n## 0.0.10 \u2014 2026-05-23\n\n### Changed\n- The sign-in browser tab auto-closes once `gs login` finishes.\n\n## 0.0.9 \u2014 2026-05-23\n\n### Changed\n- Scaffolded manifests include a `displayName` so the admin UI has a\n friendlier label.\n\n## 0.0.8 \u2014 2026-05-23\n\n### Changed\n- `gs push` and `gs publish` print a link to view the component.\n\n## 0.0.6 \u2014 2026-05-23\n\n### Changed\n- `gs --version` reads from the published package version.\n\n## 0.0.4 \u2014 2026-05-23\n\n### Changed\n- Scaffolded projects produce browser-ready bundles out of the box.\n\n## 0.0.3 \u2014 2026-05-23\n\n### Changed\n- Trimmed public README to the essentials.\n\n## 0.0.2 \u2014 2026-05-23\n\n### Fixed\n- Sign-in callback parameter handling.\n" : "";
|
|
2339
2709
|
var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
|
|
2340
2710
|
|
|
2341
2711
|
Usage:
|