@greatstore/cli 0.0.41 → 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 +24 -0
- package/README.md +20 -1
- package/dist/cli.js +543 -164
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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
|
+
|
|
22
|
+
## 0.0.42 — 2026-08-15
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- `gs apps list` now works outside a project. With no `.gsrc` it lists the
|
|
26
|
+
components of the store you're signed in to, instead of erroring. The
|
|
27
|
+
commands that write files or change the store — `push`, `pull`, `publish`,
|
|
28
|
+
`unpublish`, `delete` — still require a project.
|
|
29
|
+
|
|
6
30
|
## 0.0.41 — 2026-08-14
|
|
7
31
|
|
|
8
32
|
### 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
|
@@ -301,6 +301,15 @@ function requireProjectStore(input = {}) {
|
|
|
301
301
|
"No .gsrc found in this directory or any ancestor. Run `gs apps init --store <slug>` first to scaffold a GreatStore project."
|
|
302
302
|
);
|
|
303
303
|
}
|
|
304
|
+
function resolveReadStore(cwd = process.cwd()) {
|
|
305
|
+
const fromRc = findGsrc(cwd);
|
|
306
|
+
if (fromRc) return assertMatchesSignedInStore(fromRc);
|
|
307
|
+
const pinned = signedInStore();
|
|
308
|
+
if (pinned) return pinned;
|
|
309
|
+
throw new StoreResolutionError(
|
|
310
|
+
"No store selected. Run `gs login`, or run from a project with a .gsrc."
|
|
311
|
+
);
|
|
312
|
+
}
|
|
304
313
|
function signedInStore() {
|
|
305
314
|
try {
|
|
306
315
|
return read()?.store ?? null;
|
|
@@ -634,7 +643,7 @@ import { fileURLToPath } from "url";
|
|
|
634
643
|
var cache = null;
|
|
635
644
|
function loadTemplate() {
|
|
636
645
|
if (cache) return cache;
|
|
637
|
-
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));
|
|
638
647
|
return cache;
|
|
639
648
|
}
|
|
640
649
|
var TOKENS = {
|
|
@@ -867,13 +876,424 @@ function pascal(name) {
|
|
|
867
876
|
}
|
|
868
877
|
|
|
869
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
|
|
870
884
|
import * as fs5 from "fs";
|
|
871
|
-
import * as
|
|
885
|
+
import * as path6 from "path";
|
|
886
|
+
|
|
887
|
+
// src/validation/ast.ts
|
|
872
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
|
|
873
1293
|
var COMPONENTS_DIR = "components";
|
|
874
1294
|
async function buildCommand(args) {
|
|
875
1295
|
const root = process.cwd();
|
|
876
|
-
if (!
|
|
1296
|
+
if (!fs6.existsSync(path7.join(root, "package.json")) || !fs6.existsSync(path7.join(root, COMPONENTS_DIR))) {
|
|
877
1297
|
throw new Error(
|
|
878
1298
|
`\`gs apps build\` must run from a project root (contains \`package.json\` and \`${COMPONENTS_DIR}/\`). Current dir: ${root}`
|
|
879
1299
|
);
|
|
@@ -891,16 +1311,33 @@ async function buildCommand(args) {
|
|
|
891
1311
|
if (target && queue.length === 0) {
|
|
892
1312
|
throw new Error(`No component named "${target}" in ./${COMPONENTS_DIR}`);
|
|
893
1313
|
}
|
|
894
|
-
const
|
|
1314
|
+
const invalid = [];
|
|
1315
|
+
const buildable = [];
|
|
895
1316
|
for (const name of queue) {
|
|
896
|
-
const
|
|
897
|
-
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");
|
|
898
1335
|
await build({
|
|
899
1336
|
plugins: [reactPlugin()],
|
|
900
1337
|
logLevel: "warn",
|
|
901
1338
|
build: {
|
|
902
1339
|
lib: {
|
|
903
|
-
entry:
|
|
1340
|
+
entry: path7.join(dir, "component.tsx"),
|
|
904
1341
|
formats: ["es"],
|
|
905
1342
|
fileName: () => "bundle.js"
|
|
906
1343
|
},
|
|
@@ -921,8 +1358,8 @@ async function buildCommand(args) {
|
|
|
921
1358
|
sourcemap: false
|
|
922
1359
|
}
|
|
923
1360
|
});
|
|
924
|
-
const beforeBytes =
|
|
925
|
-
const src =
|
|
1361
|
+
const beforeBytes = fs6.statSync(bundlePath).size;
|
|
1362
|
+
const src = fs6.readFileSync(bundlePath, "utf8");
|
|
926
1363
|
const { code } = await transformWithEsbuild(src, bundlePath, {
|
|
927
1364
|
minify: true,
|
|
928
1365
|
legalComments: "none",
|
|
@@ -930,13 +1367,22 @@ async function buildCommand(args) {
|
|
|
930
1367
|
loader: "js",
|
|
931
1368
|
sourcemap: false
|
|
932
1369
|
});
|
|
933
|
-
|
|
1370
|
+
fs6.writeFileSync(bundlePath, code);
|
|
934
1371
|
const afterBytes = Buffer.byteLength(code, "utf8");
|
|
935
1372
|
process.stdout.write(
|
|
936
1373
|
`built ${COMPONENTS_DIR}/${name}/bundle.js (${formatBytes(afterBytes)}, ${pctSmaller(beforeBytes, afterBytes)} smaller)
|
|
937
1374
|
`
|
|
938
1375
|
);
|
|
939
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
|
+
}
|
|
940
1386
|
process.stdout.write(
|
|
941
1387
|
`
|
|
942
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).
|
|
@@ -944,10 +1390,10 @@ Built locally \u2014 nothing uploaded yet. Next: \`gs apps push\` to upload, the
|
|
|
944
1390
|
);
|
|
945
1391
|
}
|
|
946
1392
|
function listComponents(root) {
|
|
947
|
-
const dir =
|
|
948
|
-
return
|
|
949
|
-
const candidate =
|
|
950
|
-
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"));
|
|
951
1397
|
}).sort();
|
|
952
1398
|
}
|
|
953
1399
|
function formatBytes(n) {
|
|
@@ -959,7 +1405,7 @@ function pctSmaller(before, after) {
|
|
|
959
1405
|
return `${Math.round((1 - after / before) * 100)}%`;
|
|
960
1406
|
}
|
|
961
1407
|
async function loadVite(root) {
|
|
962
|
-
const localRequire =
|
|
1408
|
+
const localRequire = createRequire2(path7.join(root, "package.json"));
|
|
963
1409
|
const vitePath = resolveEsmEntry(localRequire, "vite");
|
|
964
1410
|
if (!vitePath) {
|
|
965
1411
|
throw new Error(
|
|
@@ -1007,30 +1453,30 @@ function resolveEsmEntry(req, specifier) {
|
|
|
1007
1453
|
}
|
|
1008
1454
|
const pkgJsonPath = findOwningPackageJson(anchor, specifier);
|
|
1009
1455
|
if (!pkgJsonPath) return null;
|
|
1010
|
-
const pkgDir =
|
|
1456
|
+
const pkgDir = path7.dirname(pkgJsonPath);
|
|
1011
1457
|
let pkg;
|
|
1012
1458
|
try {
|
|
1013
|
-
pkg = JSON.parse(
|
|
1459
|
+
pkg = JSON.parse(fs6.readFileSync(pkgJsonPath, "utf8"));
|
|
1014
1460
|
} catch {
|
|
1015
1461
|
return null;
|
|
1016
1462
|
}
|
|
1017
1463
|
const fromExports = pickImportEntry(pkg.exports);
|
|
1018
1464
|
const entry = fromExports ?? (typeof pkg.module === "string" ? pkg.module : null) ?? (typeof pkg.main === "string" ? pkg.main : null);
|
|
1019
1465
|
if (!entry) return null;
|
|
1020
|
-
return
|
|
1466
|
+
return path7.resolve(pkgDir, entry);
|
|
1021
1467
|
}
|
|
1022
1468
|
function findOwningPackageJson(start, specifier) {
|
|
1023
|
-
let dir =
|
|
1469
|
+
let dir = path7.dirname(start);
|
|
1024
1470
|
while (true) {
|
|
1025
|
-
const candidate =
|
|
1026
|
-
if (
|
|
1471
|
+
const candidate = path7.join(dir, "package.json");
|
|
1472
|
+
if (fs6.existsSync(candidate)) {
|
|
1027
1473
|
try {
|
|
1028
|
-
const parsed = JSON.parse(
|
|
1474
|
+
const parsed = JSON.parse(fs6.readFileSync(candidate, "utf8"));
|
|
1029
1475
|
if (parsed.name === specifier) return candidate;
|
|
1030
1476
|
} catch {
|
|
1031
1477
|
}
|
|
1032
1478
|
}
|
|
1033
|
-
const parent =
|
|
1479
|
+
const parent = path7.dirname(dir);
|
|
1034
1480
|
if (parent === dir) return null;
|
|
1035
1481
|
dir = parent;
|
|
1036
1482
|
}
|
|
@@ -1051,7 +1497,7 @@ function pickImportEntry(exports) {
|
|
|
1051
1497
|
|
|
1052
1498
|
// src/commands/apps/list.ts
|
|
1053
1499
|
async function listCommand(args) {
|
|
1054
|
-
const slug =
|
|
1500
|
+
const slug = resolveReadStore();
|
|
1055
1501
|
const url = `${apiBaseFor(slug)}/api/builder/components`;
|
|
1056
1502
|
const data = await request(url);
|
|
1057
1503
|
if (flagBool(args.flags, "json")) {
|
|
@@ -1090,36 +1536,36 @@ function pad(s, width) {
|
|
|
1090
1536
|
}
|
|
1091
1537
|
|
|
1092
1538
|
// src/commands/apps/pull.ts
|
|
1093
|
-
import * as
|
|
1094
|
-
import * as
|
|
1539
|
+
import * as fs8 from "fs";
|
|
1540
|
+
import * as path9 from "path";
|
|
1095
1541
|
|
|
1096
1542
|
// src/sync.ts
|
|
1097
1543
|
import * as crypto2 from "crypto";
|
|
1098
|
-
import * as
|
|
1099
|
-
import * as
|
|
1544
|
+
import * as fs7 from "fs";
|
|
1545
|
+
import * as path8 from "path";
|
|
1100
1546
|
var SYNC_FILE = ".gssync.json";
|
|
1101
1547
|
function hashString(text) {
|
|
1102
1548
|
return crypto2.createHash("sha256").update(text).digest("hex");
|
|
1103
1549
|
}
|
|
1104
1550
|
function hashFile(filePath) {
|
|
1105
|
-
if (!
|
|
1106
|
-
return hashString(
|
|
1551
|
+
if (!fs7.existsSync(filePath)) return null;
|
|
1552
|
+
return hashString(fs7.readFileSync(filePath, "utf8"));
|
|
1107
1553
|
}
|
|
1108
1554
|
function computeComponentHashes(componentDir) {
|
|
1109
|
-
const manifestHash = hashFile(
|
|
1555
|
+
const manifestHash = hashFile(path8.join(componentDir, "manifest.json"));
|
|
1110
1556
|
if (manifestHash === null) {
|
|
1111
1557
|
throw new Error(`Missing manifest.json in ${componentDir}`);
|
|
1112
1558
|
}
|
|
1113
1559
|
return {
|
|
1114
1560
|
manifestHash,
|
|
1115
|
-
sourceHash: hashFile(
|
|
1561
|
+
sourceHash: hashFile(path8.join(componentDir, "component.tsx"))
|
|
1116
1562
|
};
|
|
1117
1563
|
}
|
|
1118
1564
|
function readSyncState(componentDir) {
|
|
1119
|
-
const file =
|
|
1120
|
-
if (!
|
|
1565
|
+
const file = path8.join(componentDir, SYNC_FILE);
|
|
1566
|
+
if (!fs7.existsSync(file)) return null;
|
|
1121
1567
|
try {
|
|
1122
|
-
const parsed = JSON.parse(
|
|
1568
|
+
const parsed = JSON.parse(fs7.readFileSync(file, "utf8"));
|
|
1123
1569
|
if (typeof parsed.version === "number" && typeof parsed.manifestHash === "string" && typeof parsed.sourceHash === "string") {
|
|
1124
1570
|
return {
|
|
1125
1571
|
version: parsed.version,
|
|
@@ -1133,8 +1579,8 @@ function readSyncState(componentDir) {
|
|
|
1133
1579
|
}
|
|
1134
1580
|
}
|
|
1135
1581
|
function writeSyncState(componentDir, state) {
|
|
1136
|
-
|
|
1137
|
-
|
|
1582
|
+
fs7.writeFileSync(
|
|
1583
|
+
path8.join(componentDir, SYNC_FILE),
|
|
1138
1584
|
JSON.stringify(state, null, 2) + "\n"
|
|
1139
1585
|
);
|
|
1140
1586
|
}
|
|
@@ -1175,7 +1621,7 @@ async function pullCommand(args) {
|
|
|
1175
1621
|
for (const name of targets) {
|
|
1176
1622
|
const outcome = await pullOne({
|
|
1177
1623
|
slug,
|
|
1178
|
-
componentDir:
|
|
1624
|
+
componentDir: path9.join(root, "components", name),
|
|
1179
1625
|
name,
|
|
1180
1626
|
revisionQuery,
|
|
1181
1627
|
force
|
|
@@ -1204,7 +1650,7 @@ async function pullAll(opts) {
|
|
|
1204
1650
|
}
|
|
1205
1651
|
const outcomes = [];
|
|
1206
1652
|
for (const entry of list.components) {
|
|
1207
|
-
const componentDir =
|
|
1653
|
+
const componentDir = path9.join(root, "components", entry.name);
|
|
1208
1654
|
const outcome = await pullOne({
|
|
1209
1655
|
slug,
|
|
1210
1656
|
componentDir,
|
|
@@ -1232,7 +1678,7 @@ ${summary.join(", ")} (of ${outcomes.length}) \u2190 ${slug}
|
|
|
1232
1678
|
}
|
|
1233
1679
|
async function pullOne(opts) {
|
|
1234
1680
|
const { slug, componentDir, name, revisionQuery, force } = opts;
|
|
1235
|
-
if (!force &&
|
|
1681
|
+
if (!force && fs8.existsSync(componentDir)) {
|
|
1236
1682
|
const sync = readSyncState(componentDir);
|
|
1237
1683
|
if (hasLocalChanges(componentDir, sync)) {
|
|
1238
1684
|
return {
|
|
@@ -1253,14 +1699,14 @@ async function pullOne(opts) {
|
|
|
1253
1699
|
message: err instanceof Error ? err.message : String(err)
|
|
1254
1700
|
};
|
|
1255
1701
|
}
|
|
1256
|
-
|
|
1702
|
+
fs8.mkdirSync(componentDir, { recursive: true });
|
|
1257
1703
|
const manifestText = JSON.stringify(data.manifest, null, 2) + "\n";
|
|
1258
|
-
|
|
1259
|
-
|
|
1704
|
+
fs8.writeFileSync(path9.join(componentDir, "manifest.json"), manifestText);
|
|
1705
|
+
fs8.writeFileSync(path9.join(componentDir, "bundle.js"), data.bundle);
|
|
1260
1706
|
const wrote = ["manifest.json", "bundle.js"];
|
|
1261
1707
|
let sourceHash = "";
|
|
1262
1708
|
if (data.source !== null) {
|
|
1263
|
-
|
|
1709
|
+
fs8.writeFileSync(path9.join(componentDir, "component.tsx"), data.source);
|
|
1264
1710
|
wrote.push("component.tsx");
|
|
1265
1711
|
sourceHash = hashString(data.source);
|
|
1266
1712
|
}
|
|
@@ -1278,7 +1724,7 @@ async function pullOne(opts) {
|
|
|
1278
1724
|
return { name, status: "pulled", version: data.version, wrote };
|
|
1279
1725
|
}
|
|
1280
1726
|
function ensureComponentsDir(root) {
|
|
1281
|
-
|
|
1727
|
+
fs8.mkdirSync(path9.join(root, "components"), { recursive: true });
|
|
1282
1728
|
}
|
|
1283
1729
|
function buildRevisionQuery(args) {
|
|
1284
1730
|
const version = flagString(args.flags, "version");
|
|
@@ -1312,72 +1758,14 @@ function printOutcome(outcome, force) {
|
|
|
1312
1758
|
}
|
|
1313
1759
|
|
|
1314
1760
|
// src/commands/apps/push.ts
|
|
1315
|
-
import * as
|
|
1316
|
-
import * as
|
|
1317
|
-
|
|
1318
|
-
// src/commands/apps/manifest-lint.ts
|
|
1319
|
-
var MAX_SCHEMA_BYTES = 8 * 1024;
|
|
1320
|
-
var MAX_SCHEMA_FIELDS = 50;
|
|
1321
|
-
var UNION_KEYWORDS = ["anyOf", "oneOf", "allOf", "$ref", "not"];
|
|
1322
|
-
function measure(node, path12, acc) {
|
|
1323
|
-
if (Array.isArray(node)) {
|
|
1324
|
-
node.forEach((entry, i) => measure(entry, `${path12}[${i}]`, acc));
|
|
1325
|
-
return;
|
|
1326
|
-
}
|
|
1327
|
-
if (!node || typeof node !== "object") return;
|
|
1328
|
-
const record = node;
|
|
1329
|
-
for (const keyword of UNION_KEYWORDS) {
|
|
1330
|
-
if (keyword in record) acc.unionPaths.push(`${path12}.${keyword}`);
|
|
1331
|
-
}
|
|
1332
|
-
const properties = record["properties"];
|
|
1333
|
-
if (properties && typeof properties === "object" && !Array.isArray(properties)) {
|
|
1334
|
-
for (const [name, sub] of Object.entries(properties)) {
|
|
1335
|
-
acc.fields += 1;
|
|
1336
|
-
measure(sub, `${path12}.${name}`, acc);
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
if ("items" in record) measure(record["items"], `${path12}[]`, acc);
|
|
1340
|
-
}
|
|
1341
|
-
function assertSaneInputSchema(label, inputSchema) {
|
|
1342
|
-
if (!inputSchema || typeof inputSchema !== "object") return;
|
|
1343
|
-
const acc = {
|
|
1344
|
-
bytes: Buffer.byteLength(JSON.stringify(inputSchema), "utf8"),
|
|
1345
|
-
fields: 0,
|
|
1346
|
-
unionPaths: []
|
|
1347
|
-
};
|
|
1348
|
-
measure(inputSchema, "inputSchema", acc);
|
|
1349
|
-
const problems = [];
|
|
1350
|
-
if (acc.unionPaths.length > 0) {
|
|
1351
|
-
const shown = acc.unionPaths.slice(0, 3).join(", ");
|
|
1352
|
-
const more = acc.unionPaths.length > 3 ? ` (+${acc.unionPaths.length - 3} more)` : "";
|
|
1353
|
-
problems.push(
|
|
1354
|
-
`uses ${shown}${more} \u2014 declare exactly one type per field; accept alternate shapes in component code instead`
|
|
1355
|
-
);
|
|
1356
|
-
}
|
|
1357
|
-
if (acc.bytes > MAX_SCHEMA_BYTES) {
|
|
1358
|
-
problems.push(
|
|
1359
|
-
`is ${(acc.bytes / 1024).toFixed(1)} KB serialized (limit ${MAX_SCHEMA_BYTES / 1024} KB)`
|
|
1360
|
-
);
|
|
1361
|
-
}
|
|
1362
|
-
if (acc.fields > MAX_SCHEMA_FIELDS) {
|
|
1363
|
-
problems.push(
|
|
1364
|
-
`declares ${acc.fields} fields (limit ${MAX_SCHEMA_FIELDS})`
|
|
1365
|
-
);
|
|
1366
|
-
}
|
|
1367
|
-
if (problems.length === 0) return;
|
|
1368
|
-
throw new Error(
|
|
1369
|
-
`${label}: inputSchema ${problems.join("; ")}.
|
|
1370
|
-
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.`
|
|
1371
|
-
);
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
// src/commands/apps/push.ts
|
|
1761
|
+
import * as fs9 from "fs";
|
|
1762
|
+
import * as path10 from "path";
|
|
1375
1763
|
async function pushCommand(args) {
|
|
1376
1764
|
const slug = requireProjectStore();
|
|
1377
1765
|
const root = process.cwd();
|
|
1378
1766
|
rejectLegacyLayout(root);
|
|
1379
|
-
const componentsDir =
|
|
1380
|
-
if (!
|
|
1767
|
+
const componentsDir = path10.join(root, "components");
|
|
1768
|
+
if (!fs9.existsSync(componentsDir)) {
|
|
1381
1769
|
throw new Error(
|
|
1382
1770
|
"No components/ directory here. Run `gs apps init <name>` to scaffold the project root and your first component."
|
|
1383
1771
|
);
|
|
@@ -1436,53 +1824,43 @@ ${summary.join(", ")} (of ${outcomes.length}) \u2192 ${slug}
|
|
|
1436
1824
|
}
|
|
1437
1825
|
async function pushOne(opts) {
|
|
1438
1826
|
const { slug, root, name, force } = opts;
|
|
1439
|
-
const componentDir =
|
|
1440
|
-
if (!
|
|
1827
|
+
const componentDir = path10.join(root, "components", name);
|
|
1828
|
+
if (!fs9.existsSync(componentDir)) {
|
|
1441
1829
|
return {
|
|
1442
1830
|
name,
|
|
1443
1831
|
status: "failed",
|
|
1444
1832
|
message: `components/${name}/ does not exist`
|
|
1445
1833
|
};
|
|
1446
1834
|
}
|
|
1447
|
-
const manifestPath = opts.manifestPath ?
|
|
1448
|
-
const bundlePath = opts.bundlePath ?
|
|
1449
|
-
const sourcePath =
|
|
1450
|
-
if (!
|
|
1451
|
-
return { name, status: "failed", message: `manifest not found: ${manifestPath}` };
|
|
1452
|
-
}
|
|
1453
|
-
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)) {
|
|
1454
1839
|
return {
|
|
1455
1840
|
name,
|
|
1456
1841
|
status: "failed",
|
|
1457
1842
|
message: `bundle not found: ${bundlePath} (did you run \`npm run build\`?)`
|
|
1458
1843
|
};
|
|
1459
1844
|
}
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
name,
|
|
1470
|
-
status: "failed",
|
|
1471
|
-
message: `manifest is not valid JSON: ${err.message}`
|
|
1472
|
-
};
|
|
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
|
+
`);
|
|
1473
1854
|
}
|
|
1474
|
-
if (
|
|
1855
|
+
if (!report.ok) {
|
|
1475
1856
|
return {
|
|
1476
1857
|
name,
|
|
1477
1858
|
status: "failed",
|
|
1478
|
-
message:
|
|
1859
|
+
message: errorsIn(report.diagnostics).map((d) => `${d.file}: ${d.message}`).join(`
|
|
1860
|
+
${OUTCOME_INDENT}`)
|
|
1479
1861
|
};
|
|
1480
1862
|
}
|
|
1481
|
-
|
|
1482
|
-
assertSaneInputSchema(`components/${name}/manifest.json`, manifestInputSchema);
|
|
1483
|
-
} catch (err) {
|
|
1484
|
-
return { name, status: "failed", message: err.message };
|
|
1485
|
-
}
|
|
1863
|
+
const manifestText = fs9.readFileSync(manifestPath, "utf8");
|
|
1486
1864
|
if (!force) {
|
|
1487
1865
|
const hashes2 = computeComponentHashes(componentDir);
|
|
1488
1866
|
const sync = readSyncState(componentDir);
|
|
@@ -1491,8 +1869,8 @@ async function pushOne(opts) {
|
|
|
1491
1869
|
return { name, status: "unchanged" };
|
|
1492
1870
|
}
|
|
1493
1871
|
}
|
|
1494
|
-
const bundleText =
|
|
1495
|
-
const sourceText =
|
|
1872
|
+
const bundleText = fs9.readFileSync(bundlePath, "utf8");
|
|
1873
|
+
const sourceText = fs9.existsSync(sourcePath) ? fs9.readFileSync(sourcePath, "utf8") : null;
|
|
1496
1874
|
const form = new FormData();
|
|
1497
1875
|
form.append(
|
|
1498
1876
|
"manifest",
|
|
@@ -1536,15 +1914,15 @@ async function pushOne(opts) {
|
|
|
1536
1914
|
};
|
|
1537
1915
|
}
|
|
1538
1916
|
function listLocalComponents(componentsDir) {
|
|
1539
|
-
return
|
|
1540
|
-
const dir =
|
|
1541
|
-
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"));
|
|
1542
1920
|
}).sort();
|
|
1543
1921
|
}
|
|
1544
1922
|
function rejectLegacyLayout(root) {
|
|
1545
|
-
const rootManifest =
|
|
1546
|
-
const componentsDir =
|
|
1547
|
-
if (
|
|
1923
|
+
const rootManifest = path10.join(root, "manifest.json");
|
|
1924
|
+
const componentsDir = path10.join(root, "components");
|
|
1925
|
+
if (fs9.existsSync(rootManifest) && !fs9.existsSync(componentsDir)) {
|
|
1548
1926
|
throw new Error(
|
|
1549
1927
|
[
|
|
1550
1928
|
"Detected the old single-component layout (manifest.json at the project root).",
|
|
@@ -1555,6 +1933,7 @@ function rejectLegacyLayout(root) {
|
|
|
1555
1933
|
);
|
|
1556
1934
|
}
|
|
1557
1935
|
}
|
|
1936
|
+
var OUTCOME_INDENT = " ".repeat(" failed ".length);
|
|
1558
1937
|
function printOutcome2(outcome) {
|
|
1559
1938
|
switch (outcome.status) {
|
|
1560
1939
|
case "pushed":
|
|
@@ -1785,8 +2164,8 @@ function formatList(list) {
|
|
|
1785
2164
|
}
|
|
1786
2165
|
|
|
1787
2166
|
// src/commands/configure/set.ts
|
|
1788
|
-
import * as
|
|
1789
|
-
import * as
|
|
2167
|
+
import * as fs10 from "fs";
|
|
2168
|
+
import * as path11 from "path";
|
|
1790
2169
|
var TEXT_FIELDS = [
|
|
1791
2170
|
"displayName",
|
|
1792
2171
|
"assistantName",
|
|
@@ -1846,11 +2225,11 @@ async function setConfig(args) {
|
|
|
1846
2225
|
`);
|
|
1847
2226
|
}
|
|
1848
2227
|
function readTextFile(filePath, flag) {
|
|
1849
|
-
const resolved =
|
|
1850
|
-
if (!
|
|
2228
|
+
const resolved = path11.resolve(filePath);
|
|
2229
|
+
if (!fs10.existsSync(resolved)) {
|
|
1851
2230
|
throw new Error(`${flag}: file not found: ${resolved}`);
|
|
1852
2231
|
}
|
|
1853
|
-
return
|
|
2232
|
+
return fs10.readFileSync(resolved, "utf8");
|
|
1854
2233
|
}
|
|
1855
2234
|
function parseThemeJson(raw, flag) {
|
|
1856
2235
|
let parsed;
|
|
@@ -1866,8 +2245,8 @@ function parseThemeJson(raw, flag) {
|
|
|
1866
2245
|
}
|
|
1867
2246
|
|
|
1868
2247
|
// src/commands/configure/upload.ts
|
|
1869
|
-
import * as
|
|
1870
|
-
import * as
|
|
2248
|
+
import * as fs11 from "fs";
|
|
2249
|
+
import * as path12 from "path";
|
|
1871
2250
|
|
|
1872
2251
|
// src/commands/configure/shared.ts
|
|
1873
2252
|
var ASSET_KINDS = ["icon", "logoLight", "logoDark"];
|
|
@@ -1892,20 +2271,20 @@ async function uploadAsset(args) {
|
|
|
1892
2271
|
if (!filePath) {
|
|
1893
2272
|
throw new Error(`Usage: gs configure upload <${ASSET_KINDS.join("|")}> <file>`);
|
|
1894
2273
|
}
|
|
1895
|
-
const resolved =
|
|
1896
|
-
if (!
|
|
2274
|
+
const resolved = path12.resolve(filePath);
|
|
2275
|
+
if (!fs11.existsSync(resolved)) {
|
|
1897
2276
|
throw new Error(`File not found: ${resolved}`);
|
|
1898
2277
|
}
|
|
1899
|
-
const mime = MIME_BY_EXT[
|
|
2278
|
+
const mime = MIME_BY_EXT[path12.extname(resolved).toLowerCase()];
|
|
1900
2279
|
if (!mime) {
|
|
1901
2280
|
throw new Error("Unsupported image type. Use .png, .jpg, or .webp.");
|
|
1902
2281
|
}
|
|
1903
|
-
const bytes =
|
|
2282
|
+
const bytes = fs11.readFileSync(resolved);
|
|
1904
2283
|
const form = new FormData();
|
|
1905
2284
|
form.append(
|
|
1906
2285
|
"file",
|
|
1907
2286
|
new Blob([new Uint8Array(bytes)], { type: mime }),
|
|
1908
|
-
|
|
2287
|
+
path12.basename(resolved)
|
|
1909
2288
|
);
|
|
1910
2289
|
const url = `${adminApiBase(slug)}/configure/upload/${kind}`;
|
|
1911
2290
|
const data = await request(url, {
|
|
@@ -2223,9 +2602,9 @@ function recentChangelog(text, minItems = 15) {
|
|
|
2223
2602
|
}
|
|
2224
2603
|
|
|
2225
2604
|
// src/version-check.ts
|
|
2226
|
-
import * as
|
|
2605
|
+
import * as fs12 from "fs";
|
|
2227
2606
|
import * as os3 from "os";
|
|
2228
|
-
import * as
|
|
2607
|
+
import * as path13 from "path";
|
|
2229
2608
|
var REFRESH_COMMAND = "__refresh-version-cache";
|
|
2230
2609
|
var PKG = "@greatstore/cli";
|
|
2231
2610
|
var REGISTRY_URL = `https://registry.npmjs.org/${PKG}/latest`;
|
|
@@ -2286,11 +2665,11 @@ async function fetchLatest() {
|
|
|
2286
2665
|
}
|
|
2287
2666
|
}
|
|
2288
2667
|
function cachePath(home) {
|
|
2289
|
-
return
|
|
2668
|
+
return path13.join(home, ".greatstore", "version-check.json");
|
|
2290
2669
|
}
|
|
2291
2670
|
function readCache(home) {
|
|
2292
2671
|
try {
|
|
2293
|
-
const raw =
|
|
2672
|
+
const raw = fs12.readFileSync(cachePath(home), "utf8");
|
|
2294
2673
|
const parsed = JSON.parse(raw);
|
|
2295
2674
|
if (typeof parsed.latest === "string" && typeof parsed.checkedAt === "number") {
|
|
2296
2675
|
return { latest: parsed.latest, checkedAt: parsed.checkedAt };
|
|
@@ -2302,8 +2681,8 @@ function readCache(home) {
|
|
|
2302
2681
|
function writeCache(home, cache3) {
|
|
2303
2682
|
try {
|
|
2304
2683
|
const file = cachePath(home);
|
|
2305
|
-
|
|
2306
|
-
|
|
2684
|
+
fs12.mkdirSync(path13.dirname(file), { recursive: true });
|
|
2685
|
+
fs12.writeFileSync(file, JSON.stringify(cache3));
|
|
2307
2686
|
} catch {
|
|
2308
2687
|
}
|
|
2309
2688
|
}
|
|
@@ -2325,8 +2704,8 @@ function parseVer(v) {
|
|
|
2325
2704
|
}
|
|
2326
2705
|
|
|
2327
2706
|
// src/index.ts
|
|
2328
|
-
var VERSION = true ? "0.0.
|
|
2329
|
-
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.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" : "";
|
|
2330
2709
|
var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
|
|
2331
2710
|
|
|
2332
2711
|
Usage:
|