@40rty/ams-cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/connect.mjs +19 -0
- package/bin/commands/create.mjs +54 -0
- package/bin/commands/dev.mjs +83 -0
- package/bin/commands/doctor.mjs +111 -0
- package/bin/commands/init.mjs +58 -0
- package/bin/commands/login.mjs +74 -0
- package/bin/commands/publish.mjs +37 -0
- package/bin/commands/releases.mjs +40 -0
- package/bin/forty.mjs +44 -0
- package/bin/lib/build.mjs +193 -0
- package/bin/lib/context.mjs +99 -0
- package/bin/lib/credentials.mjs +80 -0
- package/bin/lib/tailwind.mjs +41 -0
- package/dist/wire.js +1485 -0
- package/package.json +33 -4
- package/templates/package/README.md +13 -0
- package/templates/package/gitignore +3 -0
- package/templates/package/package.json +26 -0
- package/templates/package/src/blocks.tsx +94 -0
- package/templates/package/src/catalog.ts +39 -0
- package/templates/package/src/catalogs/collectionList.md +11 -0
- package/templates/package/src/catalogs/hero.md +11 -0
- package/templates/package/src/catalogs/productGrid.md +11 -0
- package/templates/package/src/index.ts +20 -0
- package/templates/package/src/shell.tsx +81 -0
- package/templates/package/src/styles.css +10 -0
- package/templates/package/tailwind.config.js +13 -0
- package/templates/package/tsconfig.json +13 -0
- package/README.md +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@40rty/ams-cli",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"description": "The forty CLI — sign in, preview and release a 40rty spacefront package.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"40rty",
|
|
6
|
+
"spacefront",
|
|
7
|
+
"cli"
|
|
8
|
+
],
|
|
9
|
+
"bin": {
|
|
10
|
+
"forty": "bin/forty.mjs"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"esbuild": "^0.27.4"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"zod": "^3.25.0"
|
|
17
|
+
},
|
|
18
|
+
"version": "0.1.0",
|
|
19
|
+
"homepage": "https://docs.40rty.ai",
|
|
20
|
+
"license": "UNLICENSED",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/40RTY-ai/ams.git",
|
|
28
|
+
"directory": "packages/cli"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"bin",
|
|
33
|
+
"templates"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# __LABEL__ — spacefront
|
|
2
|
+
|
|
3
|
+
Your components, rendered by 40rty: the agent composes `src/catalog.ts`'s types onto
|
|
4
|
+
the canvas in `src/shell.tsx`, drawn by `src/blocks.tsx`.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install
|
|
8
|
+
npm run dev # sign in, pick your space, then every save updates your preview
|
|
9
|
+
npm run release # publish a new release — visitors see it
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`npx forty releases` lists releases; `npx forty rollback` puts the previous one back.
|
|
13
|
+
Docs: https://docs.40rty.ai
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PACKAGE__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "__LABEL__'s spacefront components — published to 40rty, which hosts the page.",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build:css": "tailwindcss -i src/styles.css -o dist/package.css --minify",
|
|
9
|
+
"dev": "npm run build:css && (tailwindcss -i src/styles.css -o dist/package.css --watch & forty dev)",
|
|
10
|
+
"release": "npm run build:css && forty publish",
|
|
11
|
+
"doctor": "forty doctor",
|
|
12
|
+
"typecheck": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@40rty/ams-sdk": "__VERSION__",
|
|
16
|
+
"react": "^18.3.1",
|
|
17
|
+
"react-dom": "^18.3.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@40rty/ams-cli": "__VERSION__",
|
|
21
|
+
"@types/react": "^18.3.0",
|
|
22
|
+
"@types/react-dom": "^18.3.0",
|
|
23
|
+
"tailwindcss": "^3.4.0",
|
|
24
|
+
"typescript": "^5.6.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {renderInline, useCanvasActions, useProductCard} from '@40rty/ams-sdk';
|
|
2
|
+
import type {Collection, Product} from '@40rty/ams-sdk';
|
|
3
|
+
import type {ReactNode} from 'react';
|
|
4
|
+
|
|
5
|
+
const GUTTER = 'px-6 md:px-10';
|
|
6
|
+
|
|
7
|
+
/** Hydrated entities arrive as objects; anything still a reference is skipped. */
|
|
8
|
+
function loaded<T>(items: Array<T | string> | undefined): T[] {
|
|
9
|
+
if (items === undefined) return [];
|
|
10
|
+
return items.filter((item): item is T => typeof item === 'object' && item !== null);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function ProductCard({product}: {product: Product}) {
|
|
14
|
+
const card = useProductCard(product);
|
|
15
|
+
const image = card.displayImage;
|
|
16
|
+
return (
|
|
17
|
+
<div className="flex flex-col gap-2">
|
|
18
|
+
<button type="button" onClick={card.onCardClick} className="text-left grid gap-3">
|
|
19
|
+
<div className="aspect-[4/5] overflow-hidden rounded bg-ink/5">
|
|
20
|
+
{image && <img className="h-full w-full object-cover" src={image.url} srcSet={image.srcSet} sizes="25vw" alt={image.altText || product.title} loading="lazy" />}
|
|
21
|
+
</div>
|
|
22
|
+
<span className="truncate">{product.title}</span>
|
|
23
|
+
<span className="text-ink/70">{card.priceLabel}</span>
|
|
24
|
+
</button>
|
|
25
|
+
<button type="button" className="rounded border border-ink/20 py-2 disabled:opacity-50" onClick={card.onQuickAdd} disabled={!product.availableForSale}>
|
|
26
|
+
{product.availableForSale ? 'Add to cart' : 'Sold out'}
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A titled grid of products. */
|
|
33
|
+
export function ProductGrid({title, products}: {title?: string; products?: Array<Product | string>}) {
|
|
34
|
+
return (
|
|
35
|
+
<section className={`grid gap-6 py-8 ${GUTTER}`}>
|
|
36
|
+
{title && <h2 className="text-2xl font-semibold">{title}</h2>}
|
|
37
|
+
<div className="grid grid-cols-2 gap-6 md:grid-cols-4">
|
|
38
|
+
{loaded(products).map((product) => (
|
|
39
|
+
<ProductCard key={product.id} product={product} />
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
</section>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Collection tiles; a tile opens that collection on the canvas. */
|
|
47
|
+
export function CollectionList({title, collections}: {title?: string; collections?: Array<Collection | string>}) {
|
|
48
|
+
const actions = useCanvasActions();
|
|
49
|
+
return (
|
|
50
|
+
<section className={`grid gap-6 py-8 ${GUTTER}`}>
|
|
51
|
+
{title && <h2 className="text-2xl font-semibold">{title}</h2>}
|
|
52
|
+
<div className="grid grid-cols-2 gap-6 md:grid-cols-4">
|
|
53
|
+
{loaded(collections).map((collection) => (
|
|
54
|
+
<button key={collection.id} type="button" className="grid gap-3 text-left" onClick={() => actions?.showCollection(collection.title)}>
|
|
55
|
+
<div className="aspect-[3/2] overflow-hidden rounded bg-ink/5">
|
|
56
|
+
{collection.image && <img className="h-full w-full object-cover" src={collection.image.url} alt={collection.title} loading="lazy" />}
|
|
57
|
+
</div>
|
|
58
|
+
<span className="font-medium">{collection.title}</span>
|
|
59
|
+
</button>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
</section>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A full-width banner over one collection's image. */
|
|
67
|
+
export function Hero({heading, byline, collection}: {heading?: string; byline?: string; collection?: Collection | string}) {
|
|
68
|
+
const actions = useCanvasActions();
|
|
69
|
+
const target = typeof collection === 'object' ? collection : undefined;
|
|
70
|
+
return (
|
|
71
|
+
<button type="button" className="relative block aspect-[2/1] w-full overflow-hidden text-left" onClick={() => target && actions?.showCollection(target.title)}>
|
|
72
|
+
{target && target.image && <img className="absolute inset-0 h-full w-full object-cover" src={target.image.url} alt={target.title} />}
|
|
73
|
+
<div className={`absolute inset-x-0 bottom-0 grid gap-2 bg-gradient-to-t from-ink/70 py-8 text-paper ${GUTTER}`}>
|
|
74
|
+
{heading && <h2 className="text-4xl font-semibold">{heading}</h2>}
|
|
75
|
+
{byline && <p className="text-lg">{byline}</p>}
|
|
76
|
+
</div>
|
|
77
|
+
</button>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The agent's prose on the canvas. */
|
|
82
|
+
export function AgentText({text}: {text?: string}) {
|
|
83
|
+
return <p className={`max-w-3xl text-lg ${GUTTER}`}>{text && renderInline(text, 'agent-text')}</p>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** One exchange: the visitor's ask, then whatever the agent composed for it. */
|
|
87
|
+
export function Turn({prompt, children}: {prompt?: string; children?: ReactNode}) {
|
|
88
|
+
return (
|
|
89
|
+
<section className="grid gap-4 border-b border-ink/10 py-6">
|
|
90
|
+
{prompt && <h2 className={`text-lg font-medium ${GUTTER}`}>“{prompt}”</h2>}
|
|
91
|
+
{children}
|
|
92
|
+
</section>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {CollectionSchema, ProductSchema, resolved, z} from '@40rty/ams-sdk';
|
|
2
|
+
import type {HostComponents} from '@40rty/ams-sdk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the agent may compose with this package. Pure data — `forty dev` and
|
|
6
|
+
* `forty publish` send it to 40rty as the agent's vocabulary. Each type is drawn
|
|
7
|
+
* by a component in `./blocks.tsx` and described to the agent in `./catalogs/`.
|
|
8
|
+
*
|
|
9
|
+
* `productGrid` and `collectionList` are required for a store: the agent's
|
|
10
|
+
* commerce instructions are written against those two names.
|
|
11
|
+
*/
|
|
12
|
+
export const catalog: HostComponents['catalog'] = {
|
|
13
|
+
productGrid: {
|
|
14
|
+
type: 'productGrid',
|
|
15
|
+
propsSchema: z.object({
|
|
16
|
+
title: z.string().describe('section heading'),
|
|
17
|
+
products: resolved(ProductSchema, 'product', {min: 1, max: 12}).describe('the products to show'),
|
|
18
|
+
}),
|
|
19
|
+
examples: [{title: 'Featured', products: ['gid://shopify/Product/<id-1>', 'gid://shopify/Product/<id-2>']}],
|
|
20
|
+
},
|
|
21
|
+
collectionList: {
|
|
22
|
+
type: 'collectionList',
|
|
23
|
+
propsSchema: z.object({
|
|
24
|
+
title: z.string().describe('section heading'),
|
|
25
|
+
collections: resolved(CollectionSchema, 'collection', {min: 2, max: 4}).describe('the collections to feature'),
|
|
26
|
+
}),
|
|
27
|
+
examples: [{title: 'Shop by category', collections: ['gid://shopify/Collection/<id-1>', 'gid://shopify/Collection/<id-2>']}],
|
|
28
|
+
},
|
|
29
|
+
hero: {
|
|
30
|
+
type: 'hero',
|
|
31
|
+
layout: 'fullbleed',
|
|
32
|
+
propsSchema: z.object({
|
|
33
|
+
heading: z.string().describe('a few words, the banner headline'),
|
|
34
|
+
byline: z.string().optional().describe('one supporting sentence'),
|
|
35
|
+
collection: resolved(CollectionSchema, 'collection', {max: 1}).describe('the collection whose image fills the banner'),
|
|
36
|
+
}),
|
|
37
|
+
examples: [{heading: 'The everyday edit', byline: 'Soft layers for every day.', collection: ['gid://shopify/Collection/<id>']}],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# collectionList
|
|
2
|
+
|
|
3
|
+
Two to four collection tiles, each with its image and name. A tile opens that collection on the canvas.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
The visitor is orienting — "what do you have?", "where do I start?" — and categories are a better first answer than specific products.
|
|
8
|
+
|
|
9
|
+
## Don't Use When
|
|
10
|
+
|
|
11
|
+
The visitor asked for specific products — use `productGrid`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# hero
|
|
2
|
+
|
|
3
|
+
A full-width banner over one collection's image, with a headline and a supporting sentence.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
Opening a fresh conversation, or introducing a single collection worth a spotlight.
|
|
8
|
+
|
|
9
|
+
## Don't Use When
|
|
10
|
+
|
|
11
|
+
The visitor asked a specific question — answer it with `productGrid` instead of a banner.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# productGrid
|
|
2
|
+
|
|
3
|
+
A titled grid of products: image, name, price, and an add-to-cart button.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
The visitor wants to see, browse or compare specific products — "show me jackets", "what's on sale". The default way to answer a product question.
|
|
8
|
+
|
|
9
|
+
## Don't Use When
|
|
10
|
+
|
|
11
|
+
The visitor is still choosing between categories — use `collectionList`.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// What 40rty loads to draw this spacefront: a component for every type the agent
|
|
2
|
+
// may compose (plus `agentText` and `turn`, how the agent speaks), the catalog
|
|
3
|
+
// that describes them, and the page shell.
|
|
4
|
+
import {adaptComponent} from '@40rty/ams-sdk';
|
|
5
|
+
import type {PackageBundleModule} from '@40rty/ams-sdk';
|
|
6
|
+
|
|
7
|
+
import {AgentText, CollectionList, Hero, ProductGrid, Turn} from './blocks';
|
|
8
|
+
import {Shell} from './shell';
|
|
9
|
+
|
|
10
|
+
export {catalog} from './catalog';
|
|
11
|
+
|
|
12
|
+
export const renderers: PackageBundleModule['renderers'] = {
|
|
13
|
+
productGrid: adaptComponent(ProductGrid),
|
|
14
|
+
collectionList: adaptComponent(CollectionList),
|
|
15
|
+
hero: adaptComponent(Hero),
|
|
16
|
+
agentText: adaptComponent(AgentText),
|
|
17
|
+
turn: adaptComponent(Turn),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const shells: PackageBundleModule['shells'] = {default: Shell};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SpacefrontCanvas,
|
|
3
|
+
renderInline,
|
|
4
|
+
useCart,
|
|
5
|
+
useComposerChipSelect,
|
|
6
|
+
useComposerDraft,
|
|
7
|
+
useFourtySession,
|
|
8
|
+
useGoHome,
|
|
9
|
+
useThreadRows,
|
|
10
|
+
} from '@40rty/ams-sdk';
|
|
11
|
+
|
|
12
|
+
/** The page: a header, the canvas the agent composes onto, and the conversation. */
|
|
13
|
+
export function Shell() {
|
|
14
|
+
const session = useFourtySession();
|
|
15
|
+
const [draft, setDraft] = useComposerDraft();
|
|
16
|
+
const {rows, isEmpty} = useThreadRows();
|
|
17
|
+
const selectChip = useComposerChipSelect();
|
|
18
|
+
const goHome = useGoHome();
|
|
19
|
+
const {cart} = useCart();
|
|
20
|
+
const chips = session.suggestions ? session.suggestions.actions : [];
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="flex min-h-screen flex-col bg-paper text-ink antialiased">
|
|
24
|
+
<header className="sticky top-0 z-40 flex h-16 items-center justify-between border-b border-ink/10 bg-paper/90 px-6 backdrop-blur md:px-10">
|
|
25
|
+
<button type="button" className="font-semibold" onClick={goHome}>
|
|
26
|
+
__LABEL__
|
|
27
|
+
</button>
|
|
28
|
+
<a href={cart ? cart.checkoutUrl : undefined} className="text-sm">
|
|
29
|
+
Cart ({cart ? cart.totalQuantity : 0})
|
|
30
|
+
</a>
|
|
31
|
+
</header>
|
|
32
|
+
|
|
33
|
+
<div className="grid flex-grow lg:grid-cols-[1fr_24rem]">
|
|
34
|
+
<main className="min-w-0">
|
|
35
|
+
<SpacefrontCanvas />
|
|
36
|
+
</main>
|
|
37
|
+
|
|
38
|
+
<aside className="flex flex-col gap-6 border-l border-ink/10 p-6 lg:sticky lg:top-16 lg:h-[calc(100vh-4rem)]">
|
|
39
|
+
<div className="grid grow content-start gap-4 overflow-y-auto">
|
|
40
|
+
{isEmpty && <p className="text-ink/60">Tell us what you’re looking for.</p>}
|
|
41
|
+
{rows.map((row) => (
|
|
42
|
+
<div key={row.key} className="grid gap-1">
|
|
43
|
+
<p className="text-sm text-ink/60">{row.visitorText}</p>
|
|
44
|
+
<p>{renderInline(row.prose, row.key)}</p>
|
|
45
|
+
</div>
|
|
46
|
+
))}
|
|
47
|
+
{session.error && <p className="text-accent">{session.error}</p>}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div className="flex flex-wrap gap-2">
|
|
51
|
+
{chips.map((chip) => (
|
|
52
|
+
<button key={chip.id} type="button" className="rounded-full border border-ink/20 px-3 py-1 text-sm" onClick={() => selectChip(chip)}>
|
|
53
|
+
{chip.label}
|
|
54
|
+
</button>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<form
|
|
59
|
+
className="flex gap-3"
|
|
60
|
+
onSubmit={(event) => {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
if (draft.trim() === '') return;
|
|
63
|
+
session.sendMessage(draft);
|
|
64
|
+
setDraft('');
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<input
|
|
68
|
+
className="w-full border-b border-ink/20 bg-transparent py-2 outline-none focus:border-ink"
|
|
69
|
+
placeholder="Ask anything…"
|
|
70
|
+
value={draft}
|
|
71
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
72
|
+
/>
|
|
73
|
+
<button type="submit" className="rounded bg-ink px-4 text-paper disabled:opacity-50" disabled={session.isRunning}>
|
|
74
|
+
Ask
|
|
75
|
+
</button>
|
|
76
|
+
</form>
|
|
77
|
+
</aside>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
export default {
|
|
3
|
+
content: ['./src/**/*.{ts,tsx}'],
|
|
4
|
+
theme: {
|
|
5
|
+
extend: {
|
|
6
|
+
colors: {
|
|
7
|
+
ink: 'rgb(var(--color-ink) / <alpha-value>)',
|
|
8
|
+
paper: 'rgb(var(--color-paper) / <alpha-value>)',
|
|
9
|
+
accent: 'rgb(var(--color-accent) / <alpha-value>)',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"noEmit": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src"]
|
|
13
|
+
}
|
package/README.md
DELETED