@avocadostudio-ai/skills 0.14.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Avocado Studio Contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @avocadostudio-ai/skills
2
+
3
+ Avocado Studio's setup instructions, as agent skills that ship with a version.
4
+
5
+ ```bash
6
+ npx @avocadostudio-ai/skills
7
+ ```
8
+
9
+ Run it in your project. It writes the skills an AI coding agent needs to work on
10
+ an Avocado site — and nothing else. No routes, no config, no dependencies, no
11
+ prompts.
12
+
13
+ ```
14
+ .claude/skills/ for Claude Code
15
+ .agents/skills/ for the cross-agent `skills` CLI (Cursor, Codex, Gemini)
16
+ AGENTS.md only if absent — yours is never overwritten
17
+ CLAUDE.md only if absent
18
+ ```
19
+
20
+ Then ask your agent to add Avocado to the site. It will load `avocado`, which
21
+ routes to one of `avocado-integrate`, `avocado-demo` or `avocado-blocks`.
22
+
23
+ ## Why a package and not a docs page
24
+
25
+ A web page cannot be versioned against what npm serves. Ours drifted: the
26
+ quickstart said `0.11.9` while the registry served `0.13.1`, and the two guides
27
+ written for *existing* sites taught a `registerBlock` call that does not
28
+ compile — in the one path where a reader had no working example to copy from
29
+ instead. Nothing in the repo could have caught it, because none of it was in the
30
+ repo.
31
+
32
+ These move in lockstep with the code they describe. An 0.13.1 install carries
33
+ 0.13.1's instructions, and re-running after an upgrade replaces them.
34
+
35
+ ## Options
36
+
37
+ | | |
38
+ |---|---|
39
+ | `[directory]` | Where to write. Defaults to the current directory. |
40
+ | `--dry-run` | Print what would be written, write nothing. |
41
+
42
+ Skill files are replaced on re-run — that is how an upgrade delivers new
43
+ instructions, and every file's outcome is reported so a skill you had forked
44
+ shows up as `updated` rather than changing silently. `AGENTS.md` and `CLAUDE.md`
45
+ are yours and are only ever created.
46
+
47
+ Scaffolding a new project instead? `npm create avocado-site` writes the same
48
+ skills, from this package.
49
+
50
+ Documentation: <https://docs.avocadostudio.dev>
51
+
52
+ ## License
53
+
54
+ Apache-2.0
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from "node:fs/promises";
3
+ import { basename, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { installSkills, skillNames } from "./index.js";
6
+ /*
7
+ * `npx @avocadostudio-ai/skills` — the whole command.
8
+ *
9
+ * No prompts and no dependencies, because the thing it competes with is pasting
10
+ * a 460-line prompt into an agent, and anything that takes longer than that to
11
+ * run will lose to it. It writes instructions and nothing else: no routes, no
12
+ * manifest, no config. Wiring is a decision; reading is not, which is why this
13
+ * is a separate command from the scaffolder rather than a flag on it.
14
+ */
15
+ const HELP = `avocado-skills — install Avocado Studio's agent skills into a project
16
+
17
+ npx @avocadostudio-ai/skills [directory] [options]
18
+
19
+ Writes the skills an AI coding agent needs to work on an Avocado site, matched
20
+ to the version of this package. Nothing else is touched: no routes, no config,
21
+ no dependencies.
22
+
23
+ Arguments
24
+ directory Where to write. Defaults to the current directory.
25
+
26
+ Options
27
+ --dry-run Print what would be written, write nothing.
28
+ -h, --help This.
29
+
30
+ Written
31
+ .claude/skills/ for Claude Code
32
+ .agents/skills/ for the cross-agent "skills" CLI (Cursor, Codex, Gemini)
33
+ AGENTS.md only if absent — yours is never overwritten
34
+ CLAUDE.md only if absent
35
+
36
+ Skill files are replaced on re-run, which is how an upgrade delivers new
37
+ instructions. Docs: https://docs.avocadostudio.dev
38
+ `;
39
+ async function main() {
40
+ const argv = process.argv.slice(2);
41
+ if (argv.includes("--help") || argv.includes("-h")) {
42
+ process.stdout.write(HELP);
43
+ return;
44
+ }
45
+ const dryRun = argv.includes("--dry-run");
46
+ const unknown = argv.filter((a) => a.startsWith("-") && a !== "--dry-run");
47
+ if (unknown.length > 0) {
48
+ process.stderr.write(`Unknown option: ${unknown.join(", ")}\n\n${HELP}`);
49
+ process.exitCode = 1;
50
+ return;
51
+ }
52
+ const target = resolve(argv.find((a) => !a.startsWith("-")) ?? process.cwd());
53
+ const version = await ownVersion();
54
+ const result = await installSkills(target, { siteName: await siteName(target), dryRun });
55
+ const verb = dryRun ? "Would install" : "Installed";
56
+ process.stdout.write(`${verb} ${skillNames().length} Avocado skills (${version}) into ${target}\n\n`);
57
+ for (const file of result.files) {
58
+ process.stdout.write(` ${label(file.outcome)} ${file.path}\n`);
59
+ }
60
+ if (result.pointerMissing) {
61
+ process.stdout.write(`\nYour AGENTS.md does not mention Avocado. Add a line pointing at the \`avocado\`\n` +
62
+ `skill so your agent loads it without being asked.\n`);
63
+ }
64
+ if (!dryRun) {
65
+ process.stdout.write(`\nNext: ask your coding agent to add Avocado to this site.\n`);
66
+ }
67
+ }
68
+ function label(outcome) {
69
+ return { created: "new ", updated: "updated", unchanged: "same ", kept: "kept " }[outcome] ?? outcome;
70
+ }
71
+ /** The target's own name, for the `AGENTS.md` heading. */
72
+ async function siteName(dir) {
73
+ try {
74
+ const pkg = JSON.parse(await readFile(resolve(dir, "package.json"), "utf-8"));
75
+ if (typeof pkg.name === "string" && pkg.name.length > 0)
76
+ return pkg.name;
77
+ }
78
+ catch {
79
+ // No package.json, or an unreadable one. The directory name is a fine title.
80
+ }
81
+ return basename(dir);
82
+ }
83
+ async function ownVersion() {
84
+ try {
85
+ const pkg = JSON.parse(await readFile(fileURLToPath(new URL("../package.json", import.meta.url)), "utf-8"));
86
+ return pkg.version ?? "unknown";
87
+ }
88
+ catch {
89
+ return "unknown";
90
+ }
91
+ }
92
+ main().catch((err) => {
93
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
94
+ process.exitCode = 1;
95
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Where the skills land, relative to the project root. Both roots get the same
3
+ * bytes: `.claude/skills` is Claude Code's, and `.agents/skills` is what the
4
+ * cross-agent `skills` CLI reads, so Cursor, Codex, Copilot and Gemini find
5
+ * them too.
6
+ */
7
+ export declare const SKILL_ROOTS: readonly [".claude/skills", ".agents/skills"];
8
+ /** One file to write: where it goes, and the absolute path to copy it from. */
9
+ export interface SkillFile {
10
+ /** Project-relative, POSIX-separated — it is written into a repo. */
11
+ path: string;
12
+ /** Absolute path in this package. */
13
+ source: string;
14
+ }
15
+ /** The directory this package's SKILL.md files are read from. */
16
+ export declare function skillsDir(): string;
17
+ /** The skill names shipped here, e.g. `avocado`, `avocado-integrate`. */
18
+ export declare function skillNames(): string[];
19
+ /** Every skill file, for each root. Deterministic order. */
20
+ export declare function skillFiles(): SkillFile[];
21
+ /**
22
+ * The router file every agent reads without being told to.
23
+ *
24
+ * Deliberately a pointer and not a copy: a second description of the same
25
+ * wiring is a second thing to keep true, and the skills are the ones that ship
26
+ * with the version. `CLAUDE.md` is one line pointing here for the same reason.
27
+ */
28
+ export declare function agentsMd(siteName: string): string;
29
+ export declare function claudeMd(): string;
30
+ export { installSkills } from "./install.ts";
31
+ export type { InstallOptions, InstallResult, FileOutcome } from "./install.ts";
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ import { readdirSync, statSync } from "node:fs";
2
+ import { join, posix, sep } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /*
5
+ * Avocado's setup instructions, as files that ship with a version.
6
+ *
7
+ * The setup people actually run is "point a coding agent at my repo", and a web
8
+ * page is the worst possible carrier for that: nothing versions it against the
9
+ * packages. `docs-site/quickstart.mdx` sat pinned at `0.11.9` while npm served
10
+ * `0.13.1`, and the two guides written for *existing* sites taught
11
+ * `registerBlock({ type, schema, fields })` against a function whose signature
12
+ * is `(type, { schema, meta })` — three defects in four lines, in the one place
13
+ * a reader had no working example to copy from instead. Neither could have been
14
+ * caught by anything in the repo, because neither was in it.
15
+ *
16
+ * So they live here, in a package, and move in lockstep with the code they
17
+ * describe: an 0.13.1 install carries 0.13.1's instructions.
18
+ *
19
+ * This package is the single source of those bytes. `create-avocado-site`
20
+ * depends on it and writes the same files into a scaffold, so there is one copy
21
+ * and two delivery channels — `npx @avocadostudio-ai/skills` for a repo that
22
+ * already exists, and the scaffolder for one that does not.
23
+ */
24
+ /**
25
+ * Where the skills land, relative to the project root. Both roots get the same
26
+ * bytes: `.claude/skills` is Claude Code's, and `.agents/skills` is what the
27
+ * cross-agent `skills` CLI reads, so Cursor, Codex, Copilot and Gemini find
28
+ * them too.
29
+ */
30
+ export const SKILL_ROOTS = [".claude/skills", ".agents/skills"];
31
+ /*
32
+ * Resolved relative to the package root, one level up from both `src/` and
33
+ * `dist/` — the same answer from source under tsx and from the published build.
34
+ */
35
+ const SKILLS_DIR = fileURLToPath(new URL("../skills", import.meta.url));
36
+ /** The directory this package's SKILL.md files are read from. */
37
+ export function skillsDir() {
38
+ return SKILLS_DIR;
39
+ }
40
+ /** The skill names shipped here, e.g. `avocado`, `avocado-integrate`. */
41
+ export function skillNames() {
42
+ return readdirSync(SKILLS_DIR)
43
+ .filter((entry) => statSync(join(SKILLS_DIR, entry)).isDirectory())
44
+ .sort();
45
+ }
46
+ /** Every skill file, for each root. Deterministic order. */
47
+ export function skillFiles() {
48
+ const files = walk(SKILLS_DIR);
49
+ return SKILL_ROOTS.flatMap((root) => files.map((absolute) => ({
50
+ path: posix.join(root, absolute.slice(SKILLS_DIR.length + 1).split(sep).join("/")),
51
+ source: absolute,
52
+ })));
53
+ }
54
+ /**
55
+ * The router file every agent reads without being told to.
56
+ *
57
+ * Deliberately a pointer and not a copy: a second description of the same
58
+ * wiring is a second thing to keep true, and the skills are the ones that ship
59
+ * with the version. `CLAUDE.md` is one line pointing here for the same reason.
60
+ */
61
+ export function agentsMd(siteName) {
62
+ return `# ${siteName}
63
+
64
+ ## Avocado Studio
65
+
66
+ This project uses [Avocado Studio](https://docs.avocadostudio.dev) for
67
+ chat-driven content editing.
68
+
69
+ **Load the \`avocado\` skill before changing anything it touches** — blocks,
70
+ the editor API routes, the orchestrator mount, the live preview, or the page
71
+ factory. It is in \`.claude/skills/avocado/\` and routes to the task skill for
72
+ the job:
73
+
74
+ | Working on | Skill |
75
+ |---|---|
76
+ | Wiring Avocado into this site | \`avocado-integrate\` |
77
+ | A demo, or a fresh project | \`avocado-demo\` |
78
+ | Declaring components as editable blocks | \`avocado-blocks\` |
79
+
80
+ The rule those skills exist to protect: **a component's props are not editable
81
+ until a schema declares them.** An undeclared prop cannot be reached by any
82
+ operation, prompt or model. Widening a schema to make an edit go through is a
83
+ change to this site's safety boundary — raise it, do not do it quietly.
84
+
85
+ Full documentation: https://docs.avocadostudio.dev/llms.txt
86
+ `;
87
+ }
88
+ export function claudeMd() {
89
+ return `See [AGENTS.md](./AGENTS.md).\n`;
90
+ }
91
+ function walk(dir) {
92
+ const out = [];
93
+ for (const entry of readdirSync(dir)) {
94
+ const full = join(dir, entry);
95
+ if (statSync(full).isDirectory())
96
+ out.push(...walk(full));
97
+ else
98
+ out.push(full);
99
+ }
100
+ return out.sort();
101
+ }
102
+ export { installSkills } from "./install.js";
@@ -0,0 +1,36 @@
1
+ export type FileOutcome = {
2
+ path: string;
3
+ /**
4
+ * `created` — it was not there.
5
+ * `updated` — it was there with different bytes, and this is a skill file, so
6
+ * it is ours to replace.
7
+ * `unchanged` — already byte-identical.
8
+ * `kept` — it was there and it is the project's own file, so it was left alone.
9
+ */
10
+ outcome: "created" | "updated" | "unchanged" | "kept";
11
+ };
12
+ export interface InstallOptions {
13
+ /** Heading for a generated `AGENTS.md`. Defaults to the directory name. */
14
+ siteName?: string;
15
+ /** Work out every outcome and write nothing. */
16
+ dryRun?: boolean;
17
+ }
18
+ export interface InstallResult {
19
+ files: FileOutcome[];
20
+ created: number;
21
+ updated: number;
22
+ unchanged: number;
23
+ kept: number;
24
+ /**
25
+ * Nothing in the project's `AGENTS.md` / `CLAUDE.md` names the skills, so an
26
+ * agent will not load them without being asked.
27
+ *
28
+ * This is the only thing a `kept` file can cost, and it is worth saying once.
29
+ * Saying it on *every* kept file would mean repeating the advice at somebody
30
+ * who already took it — the second run of this command writes nothing, keeps
31
+ * the `AGENTS.md` it wrote a minute ago, and has no business telling them to
32
+ * add a line that is already in it.
33
+ */
34
+ pointerMissing: boolean;
35
+ }
36
+ export declare function installSkills(dir: string, options?: InstallOptions): Promise<InstallResult>;
@@ -0,0 +1,82 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { agentsMd, claudeMd, skillFiles } from "./index.js";
4
+ /*
5
+ * Two kinds of file, two different promises, and the difference is the whole
6
+ * design of this command.
7
+ *
8
+ * The SKILL.md files are *ours*. Overwriting them is not a hazard, it is the
9
+ * point: the reason these moved out of the docs site is that stale instructions
10
+ * are invisible until an agent follows them into a compile error, so re-running
11
+ * after an upgrade has to actually deliver the new bytes. A scaffolder that
12
+ * "never clobbers" would reintroduce exactly the drift this package exists to
13
+ * end — 0.14 installed, 0.13 instructions on disk, nothing saying so.
14
+ *
15
+ * `AGENTS.md` and `CLAUDE.md` are the *project's*. People write real content in
16
+ * those, about things that have nothing to do with us, and a tool that
17
+ * overwrites one has destroyed work it never wrote. Those are only ever
18
+ * created, never replaced, and the report says `kept` so the caller can see
19
+ * that the pointer to the skills may not be there.
20
+ *
21
+ * Every outcome is reported per file, so `updated` on a skill somebody had
22
+ * forked is visible rather than silent.
23
+ */
24
+ export async function installSkills(dir, options = {}) {
25
+ const { dryRun = false } = options;
26
+ const siteName = options.siteName ?? "This project";
27
+ const ours = skillFiles().map((f) => ({ path: f.path, read: () => readFile(f.source, "utf-8") }));
28
+ const theirs = [
29
+ { path: "AGENTS.md", read: async () => agentsMd(siteName) },
30
+ { path: "CLAUDE.md", read: async () => claudeMd() },
31
+ ];
32
+ const files = [];
33
+ for (const file of ours) {
34
+ const next = await file.read();
35
+ const current = await readIfPresent(join(dir, file.path));
36
+ if (current === next) {
37
+ files.push({ path: file.path, outcome: "unchanged" });
38
+ continue;
39
+ }
40
+ if (!dryRun)
41
+ await write(join(dir, file.path), next);
42
+ files.push({ path: file.path, outcome: current === null ? "created" : "updated" });
43
+ }
44
+ // What an agent will actually read after this run: the file we kept, or the
45
+ // one we wrote. Either can carry the pointer, so both are checked together.
46
+ const effective = [];
47
+ for (const file of theirs) {
48
+ const current = await readIfPresent(join(dir, file.path));
49
+ if (current !== null) {
50
+ effective.push(current);
51
+ files.push({ path: file.path, outcome: "kept" });
52
+ continue;
53
+ }
54
+ const next = await file.read();
55
+ effective.push(next);
56
+ if (!dryRun)
57
+ await write(join(dir, file.path), next);
58
+ files.push({ path: file.path, outcome: "created" });
59
+ }
60
+ return {
61
+ files,
62
+ created: files.filter((f) => f.outcome === "created").length,
63
+ updated: files.filter((f) => f.outcome === "updated").length,
64
+ unchanged: files.filter((f) => f.outcome === "unchanged").length,
65
+ kept: files.filter((f) => f.outcome === "kept").length,
66
+ pointerMissing: !effective.some((body) => body.includes("avocado")),
67
+ };
68
+ }
69
+ async function readIfPresent(path) {
70
+ try {
71
+ return await readFile(path, "utf-8");
72
+ }
73
+ catch (err) {
74
+ if (err && typeof err === "object" && "code" in err && err.code === "ENOENT")
75
+ return null;
76
+ throw err;
77
+ }
78
+ }
79
+ async function write(path, content) {
80
+ await mkdir(dirname(path), { recursive: true });
81
+ await writeFile(path, content, "utf-8");
82
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@avocadostudio-ai/skills",
3
+ "version": "0.14.0",
4
+ "description": "Install Avocado Studio's agent skills into a project, so a coding agent reads instructions that match the version you have",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "avocado-skills": "./dist/cli.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "skills",
14
+ "README.md"
15
+ ],
16
+ "keywords": [
17
+ "avocado",
18
+ "avocado-studio",
19
+ "agent-skills",
20
+ "claude",
21
+ "agents",
22
+ "ai"
23
+ ],
24
+ "engines": {
25
+ "node": ">=22"
26
+ },
27
+ "publishConfig": {
28
+ "registry": "https://registry.npmjs.org",
29
+ "access": "public"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^22.13.10",
33
+ "tsx": "^4.19.3",
34
+ "typescript": "^5.7.3"
35
+ },
36
+ "license": "Apache-2.0",
37
+ "homepage": "https://docs.avocadostudio.dev",
38
+ "bugs": {
39
+ "url": "https://docs.avocadostudio.dev"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.build.json",
43
+ "typecheck": "tsc --noEmit",
44
+ "test": "NODE_ENV=test node ../../scripts/run-tests.mjs"
45
+ }
46
+ }
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: avocado
3
+ description: Wire Avocado Studio into a website, or work on a site that already has it — chat-driven content editing with live preview, running on the user's own Next.js or Astro app. Use when asked to add, integrate, set up, debug or extend Avocado Studio, @avocadostudio-ai/* packages, the editor API, the orchestrator, blocks, or the live preview.
4
+ ---
5
+
6
+ # Avocado Studio
7
+
8
+ Avocado adds chat-driven content editing to a site the user already owns. It is
9
+ not a CMS and not a hosting platform: it runs in their app, on their key, and
10
+ edits their content in place.
11
+
12
+ **Read this file first, then load exactly one of the task skills below.** Do not
13
+ try to do the work from this page — it deliberately holds only what is true on
14
+ every path.
15
+
16
+ ## Pick the path
17
+
18
+ | The user has | Load |
19
+ |---|---|
20
+ | A Next.js app that already exists, with its own components and content | `avocado-integrate` |
21
+ | Nothing yet, or wants to see it working before committing | `avocado-demo` |
22
+ | Either, and you are now declaring their components as editable blocks | `avocado-blocks` |
23
+
24
+ Before deciding, if the site is live, `npx avocado-scope <url>` will tell you
25
+ what one of its pages would become as blocks without installing or writing
26
+ anything. It is read-only, deterministic and free.
27
+
28
+ If it is ambiguous, ask one question: *"Is this going onto a site you already
29
+ have, or do you want a demo first?"* Do not guess — the two paths write
30
+ different files, and the integrate path must not overwrite a page the user
31
+ wrote.
32
+
33
+ ## The one rule that shapes everything
34
+
35
+ **A component's props are not editable until they are declared.** Avocado can
36
+ only change what a registered schema names. An undeclared prop is unreachable by
37
+ any operation, any prompt and any model. Declaring less is the conservative
38
+ choice and adding a field later is one line.
39
+
40
+ This is why "just let the agent edit the code" is the wrong shape for content
41
+ work, and it is the whole safety story. Do not route around it — never write an
42
+ operation that pokes at an undeclared prop, and never widen a schema to make an
43
+ edit go through without telling the user.
44
+
45
+ ## Rules that hold on every path
46
+
47
+ - **Install with the package manager the project already uses.** The lockfile
48
+ says which. Do not introduce a second one.
49
+ - **Import only from `@avocadostudio-ai/site-sdk`.** `registerBlock` and `z`
50
+ come from `@avocadostudio-ai/site-sdk/blocks`; the attribute helpers from
51
+ `@avocadostudio-ai/site-sdk/markers`. Never import `@avocadostudio-ai/shared`,
52
+ `@avocadostudio-ai/blocks`, `@avocadostudio-ai/preview-adapter` or a bare
53
+ `zod` from the user's source. Under pnpm they will not resolve; under npm's
54
+ flat hoisting they resolve today and break the first time something
55
+ re-hoists, and two copies of zod fail in ways that look like schema bugs.
56
+ - **Never import from `@avocadostudio-ai/site-sdk/editor` in anything a public
57
+ page renders.** That entry also exports `EditorOverlay` and the live-preview
58
+ provider, so a `'use client'` component reaching there for a two-line
59
+ attribute helper drags the whole editor into the public bundle — measured at
60
+ +66 kB First Load JS for byte-identical markup. Use `/markers`.
61
+ - **Do not hand-write the editor routes.** `createEditorApiHandler` serves all
62
+ five endpoints and they are security-critical: it validates `?secret=`
63
+ against `DRAFT_MODE_SECRET`, refuses non-internal redirects, sets the draft
64
+ cookie, answers CORS preflight, and refuses a publish that would delete every
65
+ page.
66
+ - **`PUBLISH_TOKEN` is not optional in production.** `/api/editor/publish`
67
+ overwrites the site's content. With no `publishSecret` configured it answers
68
+ 401 and names the variable rather than running open.
69
+ - **Wrap the Next config.** `withAvocado` from
70
+ `@avocadostudio-ai/site-sdk/next-config` sets `transpilePackages`,
71
+ `serverExternalPackages`, the matching server externals and
72
+ `skipTrailingSlashRedirect` together. Setting one of them by hand looks right
73
+ and fails quietly on the native dependencies.
74
+ - **Finish on a number, not on "it builds."** Every path ends with a
75
+ verification step that produces a count. Report it.
76
+
77
+ ## Versions
78
+
79
+ Install the packages without pinning a version and let the registry resolve —
80
+ `@avocadostudio-ai/*` ship in lockstep, so a mixed tree is the one failure mode
81
+ worth avoiding. If you must pin, pin every one of them to the same version.
82
+
83
+ ## When you are stuck
84
+
85
+ `https://docs.avocadostudio.dev/llms.txt` indexes the full documentation. Fetch
86
+ the page you need rather than guessing an API. If a symbol is not in the
87
+ published `exports` map it is not reachable from a registry install, however
88
+ well it resolves in a workspace.
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: avocado-blocks
3
+ description: Declare a site's React components as Avocado blocks — registerBlock schemas, field kinds, list fields, and the data-editable-target markup the editor needs to address a field. Use when wiring custom or existing components into Avocado Studio, or when the property panel shows the wrong control or nothing at all.
4
+ ---
5
+
6
+ # Declaring components as blocks
7
+
8
+ Read the `avocado` skill first — the import rules there apply to every line
9
+ below.
10
+
11
+ A block is one of the user's components plus a schema saying which of its props
12
+ are content. The schema is the safety boundary: an undeclared prop cannot be
13
+ reached by any operation, prompt or model.
14
+
15
+ ## The registration
16
+
17
+ ```ts
18
+ // avocado/blocks.ts
19
+ import { registerBlock, z } from "@avocadostudio-ai/site-sdk/blocks"
20
+
21
+ export function registerBlocks() {
22
+ registerBlock("PricingTier", {
23
+ schema: z.object({
24
+ name: z.string(),
25
+ price: z.string(),
26
+ blurb: z.string(),
27
+ tiers: z.array(z.object({ label: z.string(), value: z.string() })).optional(),
28
+ }),
29
+ meta: {
30
+ displayName: "Pricing Tier",
31
+ fields: { name: { kind: "text" }, price: { kind: "text" }, blurb: { kind: "richtext" } },
32
+ listFields: {
33
+ tiers: { itemFields: { label: { kind: "text" }, value: { kind: "text" } } },
34
+ },
35
+ },
36
+ })
37
+ }
38
+ ```
39
+
40
+ Four things that are each a compile error or a silent defect if you get them
41
+ wrong:
42
+
43
+ 1. **The type is the first argument**, not a `type:` key. The signature is
44
+ `registerBlock(type: string, config: { schema, meta })`.
45
+ 2. **`fields` lives under `meta`**, never at the top level.
46
+ 3. **`meta.displayName` is required.** It is what the user sees in the panel.
47
+ 4. **Array props go in `meta.listFields` with an `itemFields` map**, not in
48
+ `meta.fields`, which is for scalars only. A list declared as a scalar reaches
49
+ the panel as nothing at all.
50
+
51
+ Then hand the function to the handler rather than relying on import side
52
+ effects — Next's dev bundler does not honour source-order side effects across
53
+ RSC / SSR / route layers, and a late canonical registration can silently clobber
54
+ the site's:
55
+
56
+ ```ts
57
+ export const { GET, POST, OPTIONS } = createEditorApiHandler({
58
+ getPages,
59
+ registerBlocks,
60
+ blockTypes: ["PricingTier", "LogoWall"], // narrow the manifest to what this site renders
61
+ onPublish,
62
+ publishSecret: process.env.PUBLISH_TOKEN?.trim() || undefined,
63
+ })
64
+ ```
65
+
66
+ ## Field kinds
67
+
68
+ | The prop holds | kind |
69
+ |---|---|
70
+ | A short string | `text` |
71
+ | A document the user edits as prose | `richtext` |
72
+ | **A string of markup** rendered with `dangerouslySetInnerHTML` | `html` |
73
+ | An image path or URL | `image` |
74
+ | A list of plain strings | `stringList` |
75
+ | A list of images | `imageList` |
76
+
77
+ `richtext` and `html` are the one people get wrong. `richtext` means a
78
+ *document*. Declare a markup string as `richtext` and the panel renders the tags
79
+ literally, as visible `<span class="…">` text nobody can edit without breaking
80
+ it, and writes whatever they type over it. `html` round-trips through the same
81
+ editor and preserves the elements and attributes it cannot model.
82
+
83
+ Declare presentation props — variants, spacing, feature flags — **nowhere**. If
84
+ it is not content, leaving it out is the point.
85
+
86
+ ## Names that collide with the built-ins
87
+
88
+ Avocado ships twenty built-in types: `Hero`, `FeatureGrid`, `Testimonials`,
89
+ `FAQAccordion`, `CTA`, `Card`, `CardGrid`, `RichText`, `Banner`, `Carousel`,
90
+ `Embed`, `Footer`, `Gallery`, `Quote`, `SiteHeader`, `Stats`, `Table`, `Tabs`,
91
+ `TwoColumn`, `Video`.
92
+
93
+ - **Inventing a new block** under one of those names: don't. Prefix the type and
94
+ keep the component name as it is.
95
+ - **Existing content that already uses the name**: register over it. Renaming
96
+ the type means rewriting every stored page, and `registerBlock("Hero", …)`
97
+ deliberately replaces the built-in definition — its schema *and* its built-in
98
+ flag — with the site's. Then pass `blockTypes` naming only the types this site
99
+ renders, so the manifest stops advertising built-ins nobody implemented. Tell
100
+ the user which names were replaced.
101
+
102
+ ## Marking up the renderer
103
+
104
+ A declared field is editable in the panel. It is editable **in the preview**
105
+ only once the element that renders it carries a marker:
106
+
107
+ ```tsx
108
+ import { editableProps } from "@avocadostudio-ai/site-sdk/markers"
109
+
110
+ export function PricingTier({ blockId, name, blurb }) {
111
+ return (
112
+ <section>
113
+ <h3 {...editableProps(blockId, "name")}>{name}</h3>
114
+ <p {...editableProps(blockId, "blurb")}>{blurb}</p>
115
+ </section>
116
+ )
117
+ }
118
+ ```
119
+
120
+ Import from `/markers`, never from `/editor` — see the rule in the `avocado`
121
+ skill about the public bundle.
122
+
123
+ Two things this costs on a real site, so plan for them: subcomponents factored
124
+ for rendering often do not know their own position and need a path argument
125
+ threaded in, and the marker has to go on the element that actually renders the
126
+ text, not its wrapper.
127
+
128
+ ## Verify on a number
129
+
130
+ `@avocadostudio-ai/site-sdk/coverage` measures which declared fields a rendered
131
+ page actually marks. Run it and report the figure. "It builds" is not a result:
132
+ a site can build perfectly with every field unreachable.
133
+
134
+ Cross-check the manifest directly too — `GET /api/editor/blocks` should list
135
+ exactly the site's types, with the expected `fields` and `listFields` on each.
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: avocado-demo
3
+ description: Stand up a working Avocado Studio demo — a JSON-backed Next.js page editable by chat, in one sitting, with no CMS and no repository to clone. Use when the user wants to see Avocado working before committing to an integration, or is starting from an empty directory.
4
+ ---
5
+
6
+ # A demo you can edit by talking to it
7
+
8
+ Read the `avocado` skill first. This path creates a small, complete, runnable
9
+ site: a JSON file, two built-in blocks, the orchestrator mounted in the app.
10
+
11
+ It is a *demo*. Do not run it against a site the user cares about — for that,
12
+ load `avocado-integrate`.
13
+
14
+ The fastest route is the scaffolder, which does all of the below and installs:
15
+
16
+ ```bash
17
+ npm create avocado-site@latest
18
+ ```
19
+
20
+ Use it unless the user explicitly wants the wiring written into a project they
21
+ already created. The rest of this page is that wiring.
22
+
23
+ ## Wire it
24
+
25
+ Starting from an empty directory, create the app first:
26
+
27
+ ```bash
28
+ npx create-next-app@latest . --ts --app --tailwind --eslint \
29
+ --no-src-dir --import-alias "@/*" --use-npm --yes
30
+ npm install @avocadostudio-ai/site-sdk @avocadostudio-ai/orchestrator-core
31
+ ```
32
+
33
+ Then:
34
+
35
+ 1. **`rm app/page.tsx`.** `create-next-app` leaves a starter page there. It
36
+ matches `/` more specifically than the catch-all below, so leaving it means
37
+ the site is the Next.js starter and nothing anywhere says why.
38
+
39
+ 2. **`next.config.ts`** — `export default withAvocado({})` from
40
+ `@avocadostudio-ai/site-sdk/next-config`.
41
+
42
+ 3. **`app/globals.css`** — `@import "@avocadostudio-ai/blocks/styles.css";` as
43
+ the **first** line. Without it the page renders, and renders unstyled.
44
+
45
+ 4. **`content/pages.json`** — one page `{ id, slug: "/", title, updatedAt,
46
+ blocks: [] }` with a `Hero` (props: `heading`, `subheading`, `ctaText`,
47
+ `ctaHref`) and a `CTA` (props: `title`, `description`, `ctaText`,
48
+ `ctaHref`). Both are built-in types, so nothing needs registering.
49
+
50
+ 5. **`lib/content.ts`** — `getPage(slug)`, `getSlugs()`, `getPages()` reading
51
+ that JSON, plus `getSiteConfig()` returning a literal like
52
+ `{ name: "My Site" }`: the file holds pages and has nowhere to put site
53
+ config. Types `PageDoc` and `SiteConfig` come from
54
+ `@avocadostudio-ai/site-sdk`.
55
+
56
+ 6. **`app/api/editor/[...path]/route.ts`** — `createEditorApiHandler` from
57
+ `@avocadostudio-ai/site-sdk/routes`, with `getPages`,
58
+ `onPublish: createJsonFilePublishHandler(resolve(process.cwd(), "content/pages.json"))`
59
+ from `@avocadostudio-ai/site-sdk/publish-handlers/json-file`, and
60
+ `publishSecret: process.env.PUBLISH_TOKEN?.trim() || undefined`.
61
+
62
+ 7. **`app/api/avocado/[[...path]]/route.ts`** — `createOrchestrator` from
63
+ `@avocadostudio-ai/site-sdk/server` with `jsonFileAdapter` from
64
+ `@avocadostudio-ai/orchestrator-core/cms` pointed at the same JSON file and
65
+ passed **`writeOnPublish: true`**. It defaults to `false`, which leaves the
66
+ adapter with no `onPublish` — and Publish then reports success and writes
67
+ nothing. Add `export const runtime = "nodejs"` and
68
+ `export const dynamic = "force-dynamic"`, and assign the single returned
69
+ handler to `GET`, `POST` and `OPTIONS` rather than destructuring it.
70
+
71
+ 8. **`app/[[...slug]]/page.tsx`** — `createSitePage` from
72
+ `@avocadostudio-ai/site-sdk/page` with `siteId`, `siteName`, `getPage`,
73
+ `getSlugs`, `getSiteConfig`, and
74
+ `siteUrl: process.env.NEXT_PUBLIC_SITE_URL`. Export `default Page` **and**
75
+ `export { generateStaticParams, generateMetadata }`.
76
+
77
+ The `siteId` must be the same string as step 7's, or the page asks for a
78
+ draft session the orchestrator never seeded.
79
+
80
+ 9. **`.gitignore`** — add `.data/`. The orchestrator writes its SQLite state
81
+ there on the first request and `create-next-app`'s ignore file does not cover
82
+ it, so the first `git add .` otherwise commits a database.
83
+
84
+ 10. **`.env.local`** — one LLM key (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY` or
85
+ `GOOGLE_GENAI_API_KEY`), `ORCHESTRATOR_URL=http://localhost:3000/api/avocado`,
86
+ `NEXT_PUBLIC_SITE_URL=http://localhost:3000`, and generated values for
87
+ `DRAFT_MODE_SECRET` and `PUBLISH_TOKEN`.
88
+
89
+ A Gemini key also needs `@google/genai` installed: it is an optional peer of
90
+ `orchestrator-core`, loaded lazily, so no package manager installs it and a
91
+ Gemini plan fails at the first call without it.
92
+
93
+ ## Verify
94
+
95
+ `npm run build`, serve it, and check the bytes rather than the console:
96
+
97
+ - the page's own `<title>` and `<meta name="description">`, not the layout's
98
+ - the hero `<h1>`, carrying a `data-editable-target` attribute
99
+ - a `<link rel="canonical">` and `og:url` — these are what `siteUrl` turns on
100
+ - the blocks stylesheet linked
101
+ - an unknown slug answering a real **404**, not 200
102
+
103
+ Note that `next start` runs with `NODE_ENV=production`, where library mode
104
+ refuses every request unless a credential is set — `/api/avocado/auth/status`
105
+ reporting `mode: "closed"` there is correct, not a failure. Chat editing is a
106
+ `npm run dev` activity until the user configures `ACCESS_PASSWORD_HASH` or
107
+ `ORCHESTRATOR_ACCESS_TOKEN`.
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: avocado-integrate
3
+ description: Wire Avocado Studio into a Next.js site that already exists — its own components, its own content or CMS, its own routes. Use when adding chat-driven editing to a real site rather than scaffolding a demo.
4
+ ---
5
+
6
+ # Adding Avocado to a site that already exists
7
+
8
+ Read the `avocado` skill first. This path edits a site somebody built and cares
9
+ about: **survey before you write anything, and never overwrite a file the user
10
+ wrote without saying so.**
11
+
12
+ Work on a branch. Produce a diff the user reviews.
13
+
14
+ ## 1. Survey, and report before touching anything
15
+
16
+ Answer these from the repo, not from assumption, and tell the user the answers:
17
+
18
+ - **Next version and router.** 15 or 16; App Router or Pages. Pages Router is
19
+ not supported — stop and say so.
20
+ - **Where content lives.** A JSON file, a local CMS module, Contentful, Sanity,
21
+ Strapi, Storyblok, something bespoke. Name the module that reads it.
22
+ - **What renders a page today.** Usually a catch-all route plus a renderer that
23
+ switches on a block/section type. Name both files.
24
+ - **Which components are content-bearing**, and what their props are called.
25
+ - **Which route files exist**, and which of them serve URLs the content also
26
+ describes.
27
+ - **The package manager**, from the lockfile.
28
+
29
+ If the site already renders from a list of typed sections with props, this is a
30
+ short job. If content is embedded in JSX, it is a long one — say that before
31
+ starting, not halfway through.
32
+
33
+ If the site is reachable at a URL, run `npx avocado-scope <url>` on two or
34
+ three of its pages first. It reports how many sections each page has and what
35
+ each would become as blocks, without installing or writing anything, and it is
36
+ the fastest way to tell the user how large this job is before agreeing to it. A
37
+ page that comes back mostly `RichText` is telling you its structure lives in
38
+ JSX rather than in data.
39
+
40
+ ## 2. Install and mount
41
+
42
+ ```bash
43
+ npm install @avocadostudio-ai/site-sdk # or the project's own manager
44
+ ```
45
+
46
+ Add `@avocadostudio-ai/orchestrator-core` as well if the orchestrator is to run
47
+ inside this app ("library mode") rather than as a separate process.
48
+
49
+ **Wrap the Next config.** Whatever shape it is in — `next.config.ts`,
50
+ `next.config.js`, ESM or CommonJS — wrap the existing exported object; do not
51
+ create a second config file beside it:
52
+
53
+ ```ts
54
+ import { withAvocado } from "@avocadostudio-ai/site-sdk/next-config"
55
+ export default withAvocado(existingConfig)
56
+ ```
57
+
58
+ **The editor API, as one catch-all route** at
59
+ `app/api/editor/[...path]/route.ts`:
60
+
61
+ ```ts
62
+ import { createEditorApiHandler } from "@avocadostudio-ai/site-sdk/routes"
63
+ import { getPages, publishPages } from "@/lib/my-cms"
64
+ import { registerBlocks } from "@/avocado/blocks"
65
+
66
+ export const { GET, POST, OPTIONS } = createEditorApiHandler({
67
+ getPages: () => getPages(),
68
+ registerBlocks,
69
+ blockTypes: ["PricingTier", "LogoWall"],
70
+ onPublish: async (pages, config) => { await publishPages(pages, config); return { ok: true } },
71
+ publishSecret: process.env.PUBLISH_TOKEN?.trim() || undefined,
72
+ })
73
+ ```
74
+
75
+ **Library mode**, if the orchestrator runs in this app, at
76
+ `app/api/avocado/[[...path]]/route.ts`:
77
+
78
+ ```ts
79
+ import { createOrchestrator } from "@avocadostudio-ai/site-sdk/server"
80
+
81
+ export const runtime = "nodejs"
82
+ export const dynamic = "force-dynamic"
83
+
84
+ const handler = createOrchestrator({ adapter, siteId: "…", siteName: "…" })
85
+ export const POST = handler
86
+ export const GET = handler
87
+ export const OPTIONS = handler
88
+ ```
89
+
90
+ `createOrchestrator` returns one callable — assign it three times rather than
91
+ destructuring it. Point `ORCHESTRATOR_URL` at this mount
92
+ (`http://localhost:3000/api/avocado`); the default is a standalone orchestrator
93
+ on `:4200`, and when something else is listening there the preview silently
94
+ renders that process's content.
95
+
96
+ **The request rewrite:** Next 15 uses `middleware.ts` with
97
+ `createEditorMiddleware` from `@avocadostudio-ai/site-sdk/middleware`; Next 16
98
+ uses `proxy.ts` with `createEditorProxy` from
99
+ `@avocadostudio-ai/site-sdk/proxy`, and its `config` must be a static object
100
+ literal.
101
+
102
+ ## 3. Declare the components
103
+
104
+ Load `avocado-blocks` and follow it. On an existing site the block names are
105
+ usually already decided by the stored content, which is the case that skill's
106
+ "names that collide with the built-ins" section is about.
107
+
108
+ ## 4. Decide about the page route — carefully
109
+
110
+ `createSitePage` from `@avocadostudio-ai/site-sdk/page` is a full page factory:
111
+ it renders registered blocks, supplies `generateStaticParams` and
112
+ `generateMetadata`, and calls `notFound()` for an unknown slug.
113
+
114
+ **It replaces whatever renders pages today.** On a site with its own renderer
115
+ that is a real decision, not a step:
116
+
117
+ - *Keep the site's renderer* when it does layout the blocks do not — wrappers,
118
+ section chrome, per-page composition. The editor works fine against it; what
119
+ matters is the markers, not who renders them.
120
+ - *Adopt `createSitePage`* when the existing catch-all is thin and the site
121
+ gains metadata, canonical and Open Graph handling it did not have.
122
+
123
+ Ask before replacing. If you do adopt it, export all three symbols — without
124
+ `generateMetadata` every page inherits the root layout's title and ships no
125
+ description — and pass `siteUrl` from the environment, which is what turns on
126
+ the canonical link, `og:url`, and an absolute `og:image`.
127
+
128
+ Then **delete or move every route file whose content now comes from `getPage`**.
129
+ A more specific route keeps winning, Next reports no conflict and logs nothing,
130
+ so those URLs go on serving the old component and the integration looks dead
131
+ while being perfectly wired. List every route removed and every one left, with
132
+ the reason.
133
+
134
+ ## 5. Keep the public bundle clean
135
+
136
+ Import the attribute helpers from `@avocadostudio-ai/site-sdk/markers`. Check
137
+ the First Load JS before and after: an unchanged number is the expected result.
138
+ If it jumped by tens of kilobytes, something on a public page imported from
139
+ `/editor`.
140
+
141
+ ## 6. Verify on numbers
142
+
143
+ Do all of these and report the figures:
144
+
145
+ 1. `next build` succeeds, and the route list still shows the site's own pages.
146
+ 2. `GET /api/editor/blocks` lists exactly the site's types, with the expected
147
+ `fields` and `listFields`.
148
+ 3. The field coverage figure from `@avocadostudio-ai/site-sdk/coverage`.
149
+ 4. A page still renders the site's own markup — diff the HTML against the
150
+ pre-integration build if you can.
151
+ 5. An unknown slug still answers a real 404.
152
+
153
+ ## What not to do
154
+
155
+ - Do not overwrite the user's `next.config`, page route or `globals.css`
156
+ wholesale. Wrap, extend, or ask.
157
+ - Do not rename stored block types to avoid a collision. Register over the name.
158
+ - Do not declare presentation props to make something editable.
159
+ - Do not add `allowDelete` to get past the publish guard.
160
+ - Do not report success on "it builds."