@storystick/cli 0.0.0-stage → 0.2.0-rc.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/CONTENT-IMPORT.md +349 -0
- package/LICENSE +112 -0
- package/PUBLIC-API.md +30 -0
- package/README.md +263 -2
- package/assets/next-v1/app/[[...pathname]]/error.tsx +10 -0
- package/assets/next-v1/app/[[...pathname]]/not-found.tsx +8 -0
- package/assets/next-v1/app/[[...pathname]]/page.tsx +38 -0
- package/assets/next-v1/app/api/storystick/[...action]/route.ts +4 -0
- package/assets/next-v1/app/layout.tsx +28 -0
- package/assets/next-v1/app/sitemap.ts +3 -0
- package/assets/next-v1/env.local.example +13 -0
- package/assets/next-v1/globals.css +17 -0
- package/assets/next-v1/lib/site.ts +10 -0
- package/assets/next-v1/next.config.ts +4 -0
- package/assets/skills/storystick-development/SKILL.md +79 -0
- package/assets/skills/storystick-development/references/setup.md +152 -0
- package/assets/skills/storystick-development/references/story-and-next.md +49 -0
- package/dist/_backfill-recommendation.d.ts +12 -0
- package/dist/_backfill-recommendation.js +18 -0
- package/dist/asset-import.d.ts +50 -0
- package/dist/asset-import.js +160 -0
- package/dist/assistant-read-client.d.ts +3 -0
- package/dist/assistant-read-client.js +8 -0
- package/dist/auth-device.d.ts +153 -0
- package/dist/auth-device.js +390 -0
- package/dist/bootstrap-client.d.ts +52 -0
- package/dist/bootstrap-client.js +19 -0
- package/dist/cli-error.d.ts +54 -0
- package/dist/cli-error.js +107 -0
- package/dist/cli.d.ts +68 -0
- package/dist/cli.js +1520 -0
- package/dist/commands/archive.d.ts +17 -0
- package/dist/commands/archive.js +86 -0
- package/dist/commands/backfill-refs.d.ts +54 -0
- package/dist/commands/backfill-refs.js +217 -0
- package/dist/commands/connect.d.ts +11 -0
- package/dist/commands/connect.js +124 -0
- package/dist/commands/connection.d.ts +57 -0
- package/dist/commands/connection.js +83 -0
- package/dist/commands/content.d.ts +11 -0
- package/dist/commands/content.js +107 -0
- package/dist/commands/delivery.d.ts +22 -0
- package/dist/commands/delivery.js +99 -0
- package/dist/commands/info.d.ts +35 -0
- package/dist/commands/info.js +62 -0
- package/dist/commands/list.d.ts +28 -0
- package/dist/commands/list.js +116 -0
- package/dist/commands/migrate.d.ts +80 -0
- package/dist/commands/migrate.js +550 -0
- package/dist/commands/release.d.ts +8 -0
- package/dist/commands/release.js +60 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.js +58 -0
- package/dist/commands/slice-previews.d.ts +17 -0
- package/dist/commands/slice-previews.js +233 -0
- package/dist/commands/source.d.ts +82 -0
- package/dist/commands/source.js +192 -0
- package/dist/content-import.d.ts +78 -0
- package/dist/content-import.js +210 -0
- package/dist/generated-transaction.d.ts +22 -0
- package/dist/generated-transaction.js +330 -0
- package/dist/hub-client.d.ts +72 -0
- package/dist/hub-client.js +178 -0
- package/dist/init-operation.d.ts +98 -0
- package/dist/init-operation.js +427 -0
- package/dist/init-readiness.d.ts +10 -0
- package/dist/init-readiness.js +50 -0
- package/dist/init-scaffold.d.ts +54 -0
- package/dist/init-scaffold.js +439 -0
- package/dist/init.d.ts +51 -0
- package/dist/init.js +789 -0
- package/dist/mcp-execution.d.ts +15 -0
- package/dist/mcp-execution.js +90 -0
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.js +41 -0
- package/dist/migration-artifact.d.ts +13 -0
- package/dist/migration-artifact.js +154 -0
- package/dist/operations-client.d.ts +137 -0
- package/dist/operations-client.js +130 -0
- package/dist/output.d.ts +347 -0
- package/dist/output.js +771 -0
- package/dist/project-access.d.ts +18 -0
- package/dist/project-access.js +1 -0
- package/dist/project-connection.d.ts +62 -0
- package/dist/project-connection.js +347 -0
- package/dist/project-execution-client.d.ts +2 -0
- package/dist/project-execution-client.js +33 -0
- package/dist/push-client.d.ts +100 -0
- package/dist/push-client.js +160 -0
- package/dist/release-context.d.ts +13 -0
- package/dist/release-context.js +39 -0
- package/dist/release-schema-client.d.ts +16 -0
- package/dist/release-schema-client.js +33 -0
- package/dist/release-sync.d.ts +36 -0
- package/dist/release-sync.js +31 -0
- package/dist/resolve.d.ts +15 -0
- package/dist/resolve.js +80 -0
- package/dist/runtime-config.d.ts +18 -0
- package/dist/runtime-config.js +86 -0
- package/dist/schema-export.d.ts +10 -0
- package/dist/schema-export.js +28 -0
- package/dist/setup.d.ts +65 -0
- package/dist/setup.js +135 -0
- package/dist/source-git.d.ts +36 -0
- package/dist/source-git.js +197 -0
- package/dist/starter-resolver.d.ts +82 -0
- package/dist/starter-resolver.js +495 -0
- package/dist/sync-transaction.d.ts +29 -0
- package/dist/sync-transaction.js +159 -0
- package/dist/transport.d.ts +8 -0
- package/dist/transport.js +73 -0
- package/examples/sanity/README.md +79 -0
- package/examples/sanity/convert.mjs +228 -0
- package/examples/sanity/fixture/data.ndjson +7 -0
- package/examples/sanity/fixture/mapping.json +44 -0
- package/examples/sanity/fixture/originals/mark.svg +1 -0
- package/examples/sanity/stories/articleBody.story +23 -0
- package/examples/sanity/stories/copy.story +7 -0
- package/examples/sanity/stories/page.story +19 -0
- package/examples/sanity/stories/picture.story +7 -0
- package/examples/sanity/stories/settings.story +9 -0
- package/examples/sanity/stories/stack.story +10 -0
- package/package.json +75 -3
package/README.md
CHANGED
|
@@ -1,3 +1,264 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @storystick/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The developing [content import interface](CONTENT-IMPORT.md) provides planning,
|
|
4
|
+
bounded native writes, resumable receipts and readback for Main drafts.
|
|
5
|
+
|
|
6
|
+
The Storystick command-line interface. It compiles Story V1 schemas, connects a
|
|
7
|
+
Next application to a Storystick project, and publishes schema changes through
|
|
8
|
+
the Storystick gateway.
|
|
9
|
+
|
|
10
|
+
## Commands
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
storystick init [project-name] [--link <shortId>] [--team <shortId> | --new-team <name>]
|
|
14
|
+
[--into <dir>] [--starter <id>] [--origin <url>] --locale <tag>
|
|
15
|
+
[--site-url <origin>] [--force] [--json]
|
|
16
|
+
storystick generate [--root <dir>] [--output <dir>] [--stories <dirs>]
|
|
17
|
+
[--check] [--verbose | --quiet] [--json]
|
|
18
|
+
storystick push [--root <dir>] [--stories <dirs>] [--dry-run]
|
|
19
|
+
[--verbose | --quiet] [--json]
|
|
20
|
+
storystick sync [--root <dir>] [--output <dir>] [--stories <dirs>]
|
|
21
|
+
[--dry-run] [--verbose | --quiet] [--json]
|
|
22
|
+
storystick login [--gateway-url <origin>] [--hub-url <origin>]
|
|
23
|
+
storystick logout [--local] [--gateway-url <origin>] [--root <dir>]
|
|
24
|
+
storystick whoami [--json] [--gateway-url <origin>] [--root <dir>]
|
|
25
|
+
storystick list [--all] [--json]
|
|
26
|
+
storystick info [shortId] [--root <dir>] [--json]
|
|
27
|
+
storystick connect <shortId> [--root <dir>] [--origin <url>]
|
|
28
|
+
[--dry-run] [--json]
|
|
29
|
+
storystick archive <shortId> [--yes] [--json]
|
|
30
|
+
storystick migrate preview <module> [--root <dir>] [--run <id>] [--json]
|
|
31
|
+
storystick migrate activate <module> --app-url <candidate-origin>
|
|
32
|
+
--serving-url <public-origin> [--preview-proof <reference>] [--yes] [--json]
|
|
33
|
+
storystick backfill-refs [--storyType <name> | --document <shortId>]
|
|
34
|
+
[--dry-run] [--root <dir>] [--verbose | --quiet] [--json]
|
|
35
|
+
storystick slice-previews sync [--root <dir>] [--manifest <file>]
|
|
36
|
+
[--project <shortId>] [--dry-run] [--verbose | --quiet] [--json]
|
|
37
|
+
storystick mcp --project <shortId> [--root <dir>] [--write]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Run `storystick <command> --help` for the complete option and environment
|
|
41
|
+
contract. `storystick --version` is read from this package's version.
|
|
42
|
+
|
|
43
|
+
## Project tools for coding assistants
|
|
44
|
+
|
|
45
|
+
`storystick mcp` serves the native Studio assistant's editorial tools over stdio.
|
|
46
|
+
The default profile allows reads for viewers and editors: schema, document
|
|
47
|
+
search and content, translations, retained snapshots, media and documentary
|
|
48
|
+
resources. `--write` enables the existing editor capabilities, including content
|
|
49
|
+
changes, notes, document actions and conditional Undo. The server derives its
|
|
50
|
+
catalog, descriptions and input validation from the native declarations; feature
|
|
51
|
+
flags and the operator's current permissions still apply.
|
|
52
|
+
|
|
53
|
+
Sign in with `storystick login` first. The matching Central deployment must
|
|
54
|
+
include `/api/cli/project-execution`. Configure the host to run `storystick`
|
|
55
|
+
with `mcp --project <shortId> --root <dir>` (and `--write` for editing). For a
|
|
56
|
+
repository build, use `node` with the absolute path to `dist/cli.js`, followed
|
|
57
|
+
by those arguments. `--root` supplies gateway configuration; `--project` fixes
|
|
58
|
+
the project outside tool arguments. Discovery requires an authenticated session.
|
|
59
|
+
The server never starts interactive login; authentication failures direct the
|
|
60
|
+
operator to sign in separately. Only protocol frames go to stdout.
|
|
61
|
+
|
|
62
|
+
Begin with `beginSession` and the user's intent. Its result includes the pinned
|
|
63
|
+
project, document and resource context, session expiry and exact readable/writable
|
|
64
|
+
targets. Document IDs and locales are explicit; variant and release targets keep
|
|
65
|
+
their native isolation. Use `requestScope` after observing an additional target;
|
|
66
|
+
the same session continues with the new scope. A read profile cannot acquire
|
|
67
|
+
write authority, even for an editor. Membership is rechecked on each call.
|
|
68
|
+
|
|
69
|
+
Keep `sessionId` and a unique `requestId` per operation. Reuse a request ID only
|
|
70
|
+
with identical arguments. If an acknowledgement is lost, inspect `sessionStatus`
|
|
71
|
+
before attempting another effect: it reconciles authoritative native receipts,
|
|
72
|
+
and an unresolved outcome remains explicitly uncertain. Call `endSession` when
|
|
73
|
+
finished. The journal remains available in Studio; reopen its `threadId`, then
|
|
74
|
+
use `readTurnHistory` and `reverseTurn` for conditional Undo.
|
|
75
|
+
|
|
76
|
+
Follow pagination and observation requirements before claiming completeness or
|
|
77
|
+
editing. Resource content remains untrusted source data. Outputs preserve exact
|
|
78
|
+
revisions, provenance and typed Studio destinations; these locators are not
|
|
79
|
+
public website URLs. `readMedia` supplies bounded image blocks to capable hosts,
|
|
80
|
+
with an explicit notice when pixels are unavailable. Replay returns historical
|
|
81
|
+
metadata; use a fresh request ID to inspect currently authorized pixels.
|
|
82
|
+
|
|
83
|
+
The external host owns the model loop. No native provider invocation or sandbox
|
|
84
|
+
is required for editorial work. Optional code workspace tools retain their own
|
|
85
|
+
requirements. Editing does not publish; the separate `releasePublication` tool
|
|
86
|
+
requires explicit user authorization and its exact prepared approval digest.
|
|
87
|
+
Code/delivery effects are outside editorial Undo. Closing stdin or terminating
|
|
88
|
+
the process cancels pending transport work; it does not prove an effect failed.
|
|
89
|
+
|
|
90
|
+
## Guided schema migrations
|
|
91
|
+
|
|
92
|
+
`migrate preview` analyzes and prepares an isolated B generation using the
|
|
93
|
+
client-owned module. It reuses a matching active server run (or `--run` for an
|
|
94
|
+
older/ambiguous run); it never publishes drafts or transfers authority. Fix
|
|
95
|
+
reported issues in A or the module, then resume/re-run. A verified preparation
|
|
96
|
+
is not an activation.
|
|
97
|
+
|
|
98
|
+
Before `migrate activate`, deploy a candidate application with a unique
|
|
99
|
+
`STORYSTICK_APP_BUILD_ID=app:<build-id>` and its build-system SHA-256 as
|
|
100
|
+
`STORYSTICK_APP_BUILD_DIGEST`. Mount `site.handlers` at the standard
|
|
101
|
+
`/api/storystick/[...action]` route. The CLI reads that endpoint's
|
|
102
|
+
`migration-readback`, checks the project and generated query schema, and asks
|
|
103
|
+
for a reference to a manually verified B Preview. This is explicitly a
|
|
104
|
+
**manual prepared attestation**: the public endpoint still reads A before
|
|
105
|
+
activation, so it cannot independently prove B Preview at this stage.
|
|
106
|
+
|
|
107
|
+
`activate` requires a separate confirmation (`--yes` in non-interactive mode).
|
|
108
|
+
After authority moves to B, the command checks the public origin, records a
|
|
109
|
+
distinct serving readback only when that exact build reads the target schema,
|
|
110
|
+
then waits for the projection ACK and server receipt. If promotion or projection
|
|
111
|
+
is pending, run the same command again; `--serving-url` explicitly names the
|
|
112
|
+
public origin, even when it equals the candidate URL. The CLI does not
|
|
113
|
+
deploy or promote the application. During this window a promoted candidate
|
|
114
|
+
build can read B while retained builds still read A; the public authority
|
|
115
|
+
remains pending until the serving proof and projection ACK. `status`, `issues`, `resume`, `attest` and
|
|
116
|
+
the original three-identifier `activate` form remain available for recovery.
|
|
117
|
+
|
|
118
|
+
## Slice Library captures
|
|
119
|
+
|
|
120
|
+
Repository-managed captures stay outside `.story` files. Declare the explicit
|
|
121
|
+
base/variation mapping in `slice-previews.json`:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"version": 1,
|
|
126
|
+
"previews": [
|
|
127
|
+
{ "slice": "hero", "file": "captures/hero/base.png" },
|
|
128
|
+
{
|
|
129
|
+
"slice": "hero",
|
|
130
|
+
"variation": "centered",
|
|
131
|
+
"file": "captures/hero/centered.png"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Run `storystick slice-previews sync`. The agent-friendly
|
|
138
|
+
`--dry-run --json` form validates the complete mapping without network or
|
|
139
|
+
storage effects. Every referenced file must remain inside the project root,
|
|
140
|
+
including after symlink resolution.
|
|
141
|
+
|
|
142
|
+
## Schema workflow
|
|
143
|
+
|
|
144
|
+
`generate` resolves `.story` files and atomically publishes one immutable local
|
|
145
|
+
generation. `--check` compares the expected bytes without modifying the
|
|
146
|
+
filesystem.
|
|
147
|
+
|
|
148
|
+
`push` asks the server for a change plan before publishing. Initial, additive,
|
|
149
|
+
presentation-only, and unchanged plans are accepted. Breaking or unknown
|
|
150
|
+
changes are refused; V1 deliberately has no generic `--force` or universal
|
|
151
|
+
migration engine. `push --dry-run` returns the server plan without creating a
|
|
152
|
+
schema row or outbox event.
|
|
153
|
+
|
|
154
|
+
`sync` combines both operations without lying about their order: it stages the
|
|
155
|
+
generated bytes, publishes the same schema version, and only then moves the
|
|
156
|
+
local generation pointer. If the process stops after a confirmed push, the next
|
|
157
|
+
identical `sync` completes the local commit from
|
|
158
|
+
`.storystick/sync-operation.json` without contacting the server again.
|
|
159
|
+
`sync --dry-run` writes neither staged artifacts nor remote schema state.
|
|
160
|
+
|
|
161
|
+
## Init, link, and connect
|
|
162
|
+
|
|
163
|
+
`init` selects an external starter from the Storystick catalog. Catalog entries
|
|
164
|
+
pin an immutable HTTPS archive with its SHA-256 digest and content-tree digest;
|
|
165
|
+
the CLI verifies both before exposing its files in the target directory. No
|
|
166
|
+
GitHub account or GitHub credential is required. The V2 catalogue and archives
|
|
167
|
+
must be hosted before this local candidate can support public onboarding.
|
|
168
|
+
`minimal-next` is the default reference starter, not a limit on the catalog:
|
|
169
|
+
blog, event, landing-page, or third-party maintained starters can coexist as
|
|
170
|
+
separate immutable entries. `STORYSTICK_STARTER_CATALOG_URL` can point to an
|
|
171
|
+
alternate HTTPS catalog.
|
|
172
|
+
|
|
173
|
+
For an existing Next App Router project, use `--into .`. The CLI applies the
|
|
174
|
+
same Next integration kernel and the starter's declared content overlay. It
|
|
175
|
+
preserves customer files and fails with an explicit conflict unless `--force`
|
|
176
|
+
authorizes replacement. Starter verification and Story preparation happen
|
|
177
|
+
before authentication, project creation, or secret writes.
|
|
178
|
+
|
|
179
|
+
For Next integrations, missing `@storystick/next` and `@storystick/cli`
|
|
180
|
+
dependencies use the versions declared in the verified starter's `package.json`.
|
|
181
|
+
Existing application declarations are preserved. The starter must declare both
|
|
182
|
+
versions as non-empty strings; an incomplete or invalid contract is refused
|
|
183
|
+
during planning, before application files are written.
|
|
184
|
+
|
|
185
|
+
`--locale` records the site's canonical BCP 47 primary locale and creates new
|
|
186
|
+
projects as explicit monolingual projects. `--site-url` records the production
|
|
187
|
+
origin used by canonical URLs, `hreflang`, and sitemaps. It may be omitted
|
|
188
|
+
during local onboarding, but a production build fails until it is configured.
|
|
189
|
+
|
|
190
|
+
Create and link flows are resumable through the secret-free
|
|
191
|
+
`.storystick/init-operation.json` receipt. The four connection values are
|
|
192
|
+
validated and committed to `.env.local` as one atomic unit:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
STORYSTICK_PROJECT_ID
|
|
196
|
+
NEXT_PUBLIC_STORYSTICK_PROJECT_ID
|
|
197
|
+
STORYSTICK_API_KEY
|
|
198
|
+
NEXT_PUBLIC_STORYSTICK_PUBLISHABLE_KEY
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`connect` replaces that complete unit for an existing application; it never
|
|
202
|
+
switches only the project ID. `--dry-run` redacts both keys.
|
|
203
|
+
|
|
204
|
+
## Authentication and automation
|
|
205
|
+
|
|
206
|
+
`login` uses an explicit browser device flow. CLI sessions have a fixed server
|
|
207
|
+
lifetime and are revocable with `logout`; `logout --local` only forgets the
|
|
208
|
+
selected local credential. Sessions are stored separately for each canonical
|
|
209
|
+
gateway issuer. `logout` and `whoami` accept `--gateway-url` and `--root` to
|
|
210
|
+
select that environment. Credentials without an issuer are refused and require
|
|
211
|
+
an explicit new login. A nonstandard gateway selected through project/env
|
|
212
|
+
configuration cannot start a device flow automatically: run `storystick login
|
|
213
|
+
--gateway-url <origin>` explicitly. The prompt shows the recipient gateway before
|
|
214
|
+
the verification URL and code. This destination binding is distinct from the JWT
|
|
215
|
+
issuer claim. A remote logout succeeds only after `{ revoked: true }`;
|
|
216
|
+
a network error, redirect, HTTP 401 or missing receipt preserves the local session.
|
|
217
|
+
Runtime URLs require HTTPS, except HTTP on localhost/127.0.0.1/[::1]. JSON and non-interactive commands never start a prompt or
|
|
218
|
+
device flow implicitly.
|
|
219
|
+
|
|
220
|
+
Short commands emit one JSON envelope on stdout:
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{ "ok": true, "command": "push", "version": "1", "data": {}, "diagnostics": [] }
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`backfill-refs --json` is the sole streaming exception: it emits JSONL progress
|
|
227
|
+
records followed by one final record. Status text uses stderr. Failures are
|
|
228
|
+
non-zero, SIGINT exits 130, and credentials are redacted from output and
|
|
229
|
+
receipts.
|
|
230
|
+
|
|
231
|
+
Optional runtime overrides are `STORYSTICK_HUB_URL` and
|
|
232
|
+
`STORYSTICK_GATEWAY_URL`. `STORYSTICK_NO_BROWSER=1` disables automatic browser
|
|
233
|
+
opening during explicit login.
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
pnpm --filter @storystick/cli run test
|
|
239
|
+
pnpm --filter @storystick/cli run build
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The build cleans `dist/` before compiling so removed commands cannot remain in
|
|
243
|
+
the package. `pnpm starter:qualify` packs every SDK dependency and the CLI,
|
|
244
|
+
installs the reference starter outside the workspace, then runs generation,
|
|
245
|
+
typecheck, and a production Next build. `ci:packages` runs that qualification
|
|
246
|
+
after auditing every publishable tarball.
|
|
247
|
+
|
|
248
|
+
Licensed under FSL-1.1-MIT (see `LICENSE`).
|
|
249
|
+
|
|
250
|
+
Project creation always asks which team should own the project, including when
|
|
251
|
+
only one team exists. Choose an existing team or create a new one. Headless
|
|
252
|
+
creation requires `--team` or `--new-team`. Team and project creation share the
|
|
253
|
+
bootstrap operation, so resuming a lost response does not create duplicates.
|
|
254
|
+
|
|
255
|
+
`init` completes after the pushed schema's persisted checkpoint is readable
|
|
256
|
+
through the Content Plane. An unavailable projection produces a resumable partial
|
|
257
|
+
result after a bounded wait, preserving the local connection and remote project.
|
|
258
|
+
The minimal starter contains schemas and components, not published pages.
|
|
259
|
+
|
|
260
|
+
## Candidate distribution contract
|
|
261
|
+
|
|
262
|
+
See [PUBLIC-API.md](./PUBLIC-API.md) for supported entries, reserved SDK contracts,
|
|
263
|
+
the qualified runtime matrix and the candidate cohort. Upgrade Storystick
|
|
264
|
+
packages together.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
export default function ErrorPage({ error, reset }: { error: Error & { digest?: string }; reset(): void }) {
|
|
4
|
+
return <main>
|
|
5
|
+
<h1>Something went wrong</h1>
|
|
6
|
+
{process.env.NODE_ENV !== 'production' ? <pre>{error.message}</pre> : null}
|
|
7
|
+
{error.digest ? <p>Reference: {error.digest}</p> : null}
|
|
8
|
+
<button onClick={reset}>Try again</button>
|
|
9
|
+
</main>
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { notFound, redirect, permanentRedirect } from 'next/navigation'
|
|
2
|
+
import { SliceZone } from '@storystick/next'
|
|
3
|
+
import { components } from '../../components/slices'
|
|
4
|
+
import { site } from '../../lib/site'
|
|
5
|
+
|
|
6
|
+
type PageProps = {
|
|
7
|
+
params: Promise<{ pathname?: string[] }>
|
|
8
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default async function Page(props: PageProps) {
|
|
12
|
+
const route = await site.resolvePage(props)
|
|
13
|
+
if (route.type === 'redirect') {
|
|
14
|
+
const navigate = route.permanent ? permanentRedirect : redirect
|
|
15
|
+
navigate(route.redirectTo)
|
|
16
|
+
}
|
|
17
|
+
if (route.type !== 'document') notFound()
|
|
18
|
+
const document = route.document
|
|
19
|
+
return <main>
|
|
20
|
+
<SliceZone
|
|
21
|
+
slices={document.fields[{{SLICES_FIELD}}]}
|
|
22
|
+
components={components}
|
|
23
|
+
fallback={() => <p className="slice-error">This section is temporarily unavailable.</p>}
|
|
24
|
+
/>
|
|
25
|
+
</main>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function generateMetadata(props: PageProps) {
|
|
29
|
+
const route = await site.resolvePage(props)
|
|
30
|
+
if (route.type !== 'document') return site.metadata(route)
|
|
31
|
+
const fields = route.document.fields
|
|
32
|
+
return site.metadata(route, {
|
|
33
|
+
title: fields[{{TITLE_FIELD}}],
|
|
34
|
+
description: fields[{{DESCRIPTION_FIELD}}],
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const dynamic = 'force-dynamic'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { previewTextProps, Storystick } from '@storystick/next'
|
|
2
|
+
import Link from 'next/link'
|
|
3
|
+
import { site } from '../lib/site'
|
|
4
|
+
import './globals.css'
|
|
5
|
+
|
|
6
|
+
// The shared header also reads live CMS data on built-in routes such as 404.
|
|
7
|
+
export const dynamic = 'force-dynamic'
|
|
8
|
+
|
|
9
|
+
async function Header() {
|
|
10
|
+
const client = await site.client()
|
|
11
|
+
const settings = await client.query({{SITE_SETTINGS_STORY}}).select({ {{SITE_NAME_FIELD}}: true }).fetch()
|
|
12
|
+
if (!settings) return null
|
|
13
|
+
return <header className="site-header">
|
|
14
|
+
<Link href="/" className="site-name" {...previewTextProps(settings.fields.{{SITE_NAME_FIELD}})} />
|
|
15
|
+
</header>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
|
19
|
+
return <html lang={await site.locale()}>
|
|
20
|
+
<body>
|
|
21
|
+
|
|
22
|
+
<Header />
|
|
23
|
+
{children}
|
|
24
|
+
<Storystick />
|
|
25
|
+
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
STORYSTICK_PROJECT_ID=
|
|
2
|
+
STORYSTICK_API_KEY=
|
|
3
|
+
NEXT_PUBLIC_STORYSTICK_PROJECT_ID=
|
|
4
|
+
NEXT_PUBLIC_STORYSTICK_PUBLISHABLE_KEY=
|
|
5
|
+
|
|
6
|
+
# Required for <html lang>, including synthetic monolingual projects.
|
|
7
|
+
# Required in production for canonical URLs, hreflang and the sitemap.
|
|
8
|
+
STORYSTICK_SITE_URL=
|
|
9
|
+
|
|
10
|
+
# Optional: required only for signed publish webhooks.
|
|
11
|
+
STORYSTICK_WEBHOOK_SECRET=
|
|
12
|
+
|
|
13
|
+
NEXT_PUBLIC_STORYSTICK_GATEWAY_SYNC_URL=
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createSite } from '@storystick/next/server'
|
|
2
|
+
import * as definition from '#storystick/query'
|
|
3
|
+
|
|
4
|
+
const siteUrl = process.env.STORYSTICK_SITE_URL
|
|
5
|
+
if (!siteUrl) throw new Error('STORYSTICK_SITE_URL is required for canonical metadata and sitemap.')
|
|
6
|
+
|
|
7
|
+
export const site = createSite({
|
|
8
|
+
definition,
|
|
9
|
+
siteUrl,
|
|
10
|
+
})
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: storystick-development
|
|
3
|
+
description: Develop a Storystick site's sections, story schema and Next.js rendering together. Use when configuring a project, connecting source or hosting, adding or adapting a slice, changing a .story file, generating bindings, or working on code inside a Storystick release.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Storystick development
|
|
7
|
+
|
|
8
|
+
Read the repository's `AGENTS.md` / `CLAUDE.md`, package scripts, the closest
|
|
9
|
+
existing section and its `.story` definition first. The repository's design
|
|
10
|
+
system and reusable fragments are the starting point. Do not invent a second
|
|
11
|
+
agent, CMS, routing layer or SDK API to complete a section.
|
|
12
|
+
|
|
13
|
+
## Configure a project
|
|
14
|
+
|
|
15
|
+
Run `storystick setup --json` first. It inspects the checkout without executing
|
|
16
|
+
scripts or changing remote state. Read `storystick guide --reference setup` for
|
|
17
|
+
local, starter and GitHub paths, source transfer and hosting configuration.
|
|
18
|
+
Reuse a connected project; setup is not a reason to create another project.
|
|
19
|
+
|
|
20
|
+
## Find the existing grammar
|
|
21
|
+
|
|
22
|
+
Use ordinary terminal tools (`rg`, file reads, package scripts). Search the whole
|
|
23
|
+
repository when needed. A file catalogue is orientation, not an editing boundary.
|
|
24
|
+
Use `grep` / `find` when `rg` is unavailable. Invoke the project's installed CLI
|
|
25
|
+
through its package runner (for example `pnpm exec storystick guide`) rather than
|
|
26
|
+
assuming a global binary. `cwd` is relative to the repository root; paths in the
|
|
27
|
+
command are relative to that working directory.
|
|
28
|
+
Find the page's composition field, its permitted slices, the component registry,
|
|
29
|
+
and generated bindings. A component existing on disk does not make it available
|
|
30
|
+
in the editor: its story must be included in the page's composition grammar and
|
|
31
|
+
that grammar must be synchronized to the selected release.
|
|
32
|
+
|
|
33
|
+
Prefer existing slices. If none expresses the intended content well, inspect a
|
|
34
|
+
Storystick UI Library reference, then adapt its content model and presentation
|
|
35
|
+
to this repository. Reuse fragments and existing document references. Do not copy
|
|
36
|
+
example data, add an alternate design system or silently create a submission
|
|
37
|
+
backend for a visual contact form.
|
|
38
|
+
|
|
39
|
+
## Work in the selected release
|
|
40
|
+
|
|
41
|
+
The workspace supplies `STORYSTICK_RELEASE_ID` and a short-lived CLI session.
|
|
42
|
+
`storystick push` / `storystick sync` use that release automatically. Outside a
|
|
43
|
+
workspace, use `storystick release list --project <id>`, then
|
|
44
|
+
`storystick release use <id> --project <id>`; `--release <id>` is also explicit.
|
|
45
|
+
`storystick release create <name>` creates a draft. Inspect `--help` and existing
|
|
46
|
+
scripts for root, story directories and generation output. Do not change the
|
|
47
|
+
workspace's supplied destination or credentials.
|
|
48
|
+
|
|
49
|
+
Studio and MCP use the same release, schema and content tools and the same
|
|
50
|
+
domain writers. MCP session context reports the CLI selection as
|
|
51
|
+
`cliReleaseContext`; `sessionStatus` refreshes it. This is the destination used
|
|
52
|
+
by CLI schema commands, not an implicit change to a document's write scope.
|
|
53
|
+
Choose the matching `releaseId` for schema reads and new content, and acquire
|
|
54
|
+
the exact release document scope before editing existing content. Main remains
|
|
55
|
+
an explicit choice for independent work. Code and schema preparation do not
|
|
56
|
+
silently move unrelated content into a release.
|
|
57
|
+
|
|
58
|
+
`generate` produces local bindings. `sync` generates and admits the matching
|
|
59
|
+
schema in the selected release; `push` admits the schema without generation.
|
|
60
|
+
Inspect an admission failure and change the actual cause before retrying. Do not
|
|
61
|
+
retry an unchanged rejected schema or refetch a library reference already read.
|
|
62
|
+
A schema admission is not publication. Publication and scheduling are outside
|
|
63
|
+
this workflow. Existing content remains available in Main until publication.
|
|
64
|
+
|
|
65
|
+
## Complete the change
|
|
66
|
+
|
|
67
|
+
Edit the story, component and registry as one coherent change. Run the project's
|
|
68
|
+
relevant checks; use their diagnostics to repair the implementation. A form that
|
|
69
|
+
has no configured submission destination must say so in the result.
|
|
70
|
+
|
|
71
|
+
The terminal saves source changes after each command, including failed commands.
|
|
72
|
+
Git ignored dependencies and build caches are not durable source. Keep authored
|
|
73
|
+
assets in tracked/non-ignored paths. Do not print credentials or put them in files.
|
|
74
|
+
The dev preview updates from the working source; ordinary styling edits do not
|
|
75
|
+
need a new sandbox. Report separately what was saved, checked, admitted and seen
|
|
76
|
+
in preview. If a check failed, report that evidence instead of claiming success.
|
|
77
|
+
|
|
78
|
+
Read `references/story-and-next.md` (`storystick guide --reference story-and-next`) for the boundary between stories, generated
|
|
79
|
+
bindings and the existing Next.js API.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Connect a Storystick project
|
|
2
|
+
|
|
3
|
+
Keep one project identity while adding capabilities. Content editing does not
|
|
4
|
+
require a source upload or hosting connection. A local Vercel link is not a
|
|
5
|
+
Storystick connection and does not authorize publishing.
|
|
6
|
+
|
|
7
|
+
## Inspect before changing
|
|
8
|
+
|
|
9
|
+
Run `storystick setup --json` in the application directory. It reads local facts
|
|
10
|
+
without executing package scripts. `setup --remote --json` adds the project's
|
|
11
|
+
current schema, source and hosting facts through your CLI login. Use `--help`
|
|
12
|
+
for options. Authentication requiring human consent is explicit: run
|
|
13
|
+
`storystick login`, never print or request credentials in a chat.
|
|
14
|
+
|
|
15
|
+
If connected, reuse that short ID. Otherwise choose:
|
|
16
|
+
- Existing code: `storystick connect <shortId> --dry-run --json`, then repeat
|
|
17
|
+
without `--dry-run` after reviewing the target. Use `init` to create a project
|
|
18
|
+
only when one does not already exist.
|
|
19
|
+
- New site for a Studio project: `storystick init --link <shortId> --starter
|
|
20
|
+
minimal-next --into ./website --locale <tag> --json`. Supply the intended
|
|
21
|
+
locale explicitly in agent/noninteractive runs; never infer it from the
|
|
22
|
+
machine locale. Keep the initializer's receipt and use its
|
|
23
|
+
reported resume command after interruption. Do not start another initialization.
|
|
24
|
+
|
|
25
|
+
Read repository instructions and existing generation/sync scripts. Connecting
|
|
26
|
+
credentials does not upload the schema; the repository's `sync` or `push` does.
|
|
27
|
+
|
|
28
|
+
## Add Studio code editing
|
|
29
|
+
|
|
30
|
+
For a single Next.js application at the Git root with npm or pnpm:
|
|
31
|
+
1. Export its schema locally with `storystick schema --json`. This validates but
|
|
32
|
+
does not admit the schema or change any remote content.
|
|
33
|
+
2. `storystick source configure --schema generated/storystick-schema.json --json`
|
|
34
|
+
creates `.storystick/source.json`. Inspect its install, generation, check and
|
|
35
|
+
preview commands. The preset requires the CLI installed in the application.
|
|
36
|
+
3. Commit the intended source with ordinary Git. `source prepare --dry-run --json`
|
|
37
|
+
lists the exact committed paths and revision to be transferred. Dirty files
|
|
38
|
+
are not included. Check that the schema version and source commit agree.
|
|
39
|
+
4. `storystick source prepare --json` transfers that commit. It does not publish.
|
|
40
|
+
`setup --remote --json` reads back the prepared source. Workspace access may
|
|
41
|
+
still need enabling by the Storystick operator.
|
|
42
|
+
|
|
43
|
+
Monorepos and custom frameworks use `source configure --config <proposal.json>`.
|
|
44
|
+
Include the application **and its workspace dependencies**, lockfile and package
|
|
45
|
+
configuration. Set command `cwd` explicitly where required. Consult
|
|
46
|
+
`source configure --help`; derive commands from the repository, not a guessed
|
|
47
|
+
folder layout. Existing configuration is never overwritten automatically.
|
|
48
|
+
|
|
49
|
+
A proposal uses the same recipe as remote execution. For example, adapt this
|
|
50
|
+
shape to the actual monorepo; these paths and scripts are illustrative:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"scope": {
|
|
55
|
+
"appRoot": "apps/website",
|
|
56
|
+
"include": ["apps/website", "packages/ui", "package.json", "pnpm-lock.yaml", "pnpm-workspace.yaml"],
|
|
57
|
+
"exclude": ["node_modules", "apps/website/.next", "apps/website/generated"]
|
|
58
|
+
},
|
|
59
|
+
"schemaVersion": "<version from the locally exported schema>",
|
|
60
|
+
"recipe": {
|
|
61
|
+
"install": [
|
|
62
|
+
{ "argv": ["pnpm", "install", "--frozen-lockfile"] },
|
|
63
|
+
{ "argv": ["pnpm", "exec", "storystick", "generate"], "cwd": "apps/website" }
|
|
64
|
+
],
|
|
65
|
+
"checks": [
|
|
66
|
+
{ "name": "schema", "argv": ["pnpm", "exec", "storystick", "schema"], "cwd": "apps/website" },
|
|
67
|
+
{ "name": "build", "argv": ["pnpm", "run", "build"], "cwd": "apps/website" }
|
|
68
|
+
],
|
|
69
|
+
"schemaCheck": "schema",
|
|
70
|
+
"schemaOutput": "apps/website/generated/storystick-schema.json",
|
|
71
|
+
"preview": { "argv": ["pnpm", "run", "dev", "--hostname", "0.0.0.0", "--port", "3000"], "cwd": "apps/website", "port": 3000 },
|
|
72
|
+
"allowedHosts": []
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Command directories and `schemaOutput` are relative to the repository root.
|
|
78
|
+
Include the full transitive workspace dependency closure, not just `packages/ui`.
|
|
79
|
+
Keep credentials in the project's protected environment, not command arguments
|
|
80
|
+
or this proposal. Configure from the Git root with `--root` when necessary.
|
|
81
|
+
|
|
82
|
+
## Return source changes
|
|
83
|
+
|
|
84
|
+
Use `source status <workspaceId>` before exporting. `source export` requires its
|
|
85
|
+
current revision and a new output directory. `source apply --change <directory>
|
|
86
|
+
--out <new-checkout>` performs a three-way merge and preserves the original local
|
|
87
|
+
checkout. Resolve conflicts and review before merging into your own branch.
|
|
88
|
+
Use `source import` only with the reviewed commit and current workspace revision.
|
|
89
|
+
|
|
90
|
+
GitHub is optional. A connected GitHub App supports `source github-status`,
|
|
91
|
+
`github-inspect`, `github-prepare`, `github-import` and `propose`.
|
|
92
|
+
`source github-inspect --project <id> --json` reads metadata at an immutable commit
|
|
93
|
+
without executing package scripts. Use `--app-root <folder>` for a monorepo and
|
|
94
|
+
`--ref <commit>` to keep that same commit while reviewing application folders.
|
|
95
|
+
Use `--config <proposal.json>` to check an edited scope and recipe against that
|
|
96
|
+
same commit before preparation; use its matching `--app-root` for a monorepo.
|
|
97
|
+
The result includes the proposed configuration, issues, existing prepared base
|
|
98
|
+
and `connectionRevision`. Save the reviewed configuration as a local JSON file,
|
|
99
|
+
then pass that file to `source github-prepare --config <file> --ref <commit>
|
|
100
|
+
--connection-revision <revision> --project <id> --json`. A changed/revoked
|
|
101
|
+
connection or a different prepared base is refused. Studio Project setup uses
|
|
102
|
+
these same inspection and preparation operations; neither starts a workspace
|
|
103
|
+
nor publishes a release.
|
|
104
|
+
`propose` opens a draft PR; configured CI may run. Adding GitHub later must retain
|
|
105
|
+
the same project and a verifiable common source base. If the histories differ,
|
|
106
|
+
reconcile them first; do not overwrite the workspace or invent a new project.
|
|
107
|
+
|
|
108
|
+
## Connect a provider account
|
|
109
|
+
|
|
110
|
+
`storystick connection status --json` reports the same connections as Project
|
|
111
|
+
setup in the Studio. For GitHub or Vercel, `connection begin --provider <provider>
|
|
112
|
+
--json` returns an attempt ID and an authorization URL. The account holder opens
|
|
113
|
+
that URL and authorizes access; an agent must not invent authorization or ask for
|
|
114
|
+
the account's password/token. Return to `connection status` after confirmation.
|
|
115
|
+
|
|
116
|
+
For an authorized attempt, `connection resources --attempt <id> --json` lists
|
|
117
|
+
accessible targets. For GitHub, first choose an installation, then list its
|
|
118
|
+
repositories with `--installation <id>`. Follow the returned pagination cursor
|
|
119
|
+
with `--cursor` when needed. Use the exact IDs returned by the provider:
|
|
120
|
+
|
|
121
|
+
- GitHub: `connection select --provider github --attempt <id> --installation
|
|
122
|
+
<id> --repository <id> --full-name <owner/repository> --branch <branch> --json`.
|
|
123
|
+
- Vercel: `connection select --provider vercel --attempt <id> --destination
|
|
124
|
+
<projectId> --json`.
|
|
125
|
+
|
|
126
|
+
Use `--project <shortId>` outside a connected checkout. Selecting a target does
|
|
127
|
+
not transfer source, create a repository, configure build commands, or deploy.
|
|
128
|
+
Continue with the existing source/delivery operations. An expired attempt needs
|
|
129
|
+
a new `begin`; do not create another Storystick project. If provider registration
|
|
130
|
+
is unavailable on this installation, local source transfer remains independent.
|
|
131
|
+
|
|
132
|
+
## Add release deployment separately
|
|
133
|
+
|
|
134
|
+
Use `delivery status --json` to inspect current configuration. For an existing
|
|
135
|
+
Vercel project, `delivery configure --from-vercel --site-url https://example.com
|
|
136
|
+
--dry-run --json` reads IDs from `.vercel/project.json` and previews the proposal.
|
|
137
|
+
Without a local link use `--team <teamId> --destination <projectId>`. Review root
|
|
138
|
+
and build overrides, then repeat without `--dry-run`. Readback confirms saving.
|
|
139
|
+
`delivery verify --json` checks account/project/domain access without deploying.
|
|
140
|
+
It does not prove build success or write permission.
|
|
141
|
+
|
|
142
|
+
Connected customer grants are resolved on the server, never in source or command
|
|
143
|
+
arguments. A disconnected/revoked grant must be reauthorized; it never falls back
|
|
144
|
+
to the operator's credentials. Existing operator pilot configuration is used only when
|
|
145
|
+
no customer connection record exists. The current setup screen supports Vercel. Other
|
|
146
|
+
hosting workflows can keep serving the site and editorial revalidation; do not
|
|
147
|
+
claim that an unwired provider supports coordinated code publication.
|
|
148
|
+
|
|
149
|
+
Storystick owns coordinated release publication. If Git already auto-promotes
|
|
150
|
+
production deployments, settle that trigger with the builder before enabling a
|
|
151
|
+
second publisher. A source push, a preview and production activation are distinct.
|
|
152
|
+
Content-only releases keep their existing revalidation path.
|