@pagesmith/core 0.3.0 → 0.4.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/README.md +9 -4
- package/REFERENCE.md +5 -2
- package/dist/ai/index.d.mts +5 -3
- package/dist/ai/index.d.mts.map +1 -1
- package/dist/ai/index.mjs +300 -206
- package/dist/ai/index.mjs.map +1 -1
- package/dist/assets/index.d.mts +10 -1
- package/dist/assets/index.d.mts.map +1 -1
- package/dist/assets/index.mjs +2 -2
- package/dist/{assets-DXiWF_KI.mjs → assets-CAPOqQ_P.mjs} +42 -5
- package/dist/assets-CAPOqQ_P.mjs.map +1 -0
- package/dist/{content-config-Bfe4W9us.d.mts → content-config-DJXUOcNG.d.mts} +49 -17
- package/dist/{content-config-Bfe4W9us.d.mts.map → content-config-DJXUOcNG.d.mts.map} +1 -1
- package/dist/{content-layer-DPK1EmfY.mjs → content-layer-B5enqWeJ.mjs} +123 -28
- package/dist/content-layer-B5enqWeJ.mjs.map +1 -0
- package/dist/content-layer-CpHYUYNN.d.mts +121 -0
- package/dist/content-layer-CpHYUYNN.d.mts.map +1 -0
- package/dist/create/index.d.mts.map +1 -1
- package/dist/create/index.mjs +26 -28
- package/dist/create/index.mjs.map +1 -1
- package/dist/css/index.d.mts +1 -1
- package/dist/{heading-BpDXnl-7.d.mts → heading-Dhvzlay-.d.mts} +1 -1
- package/dist/{heading-BpDXnl-7.d.mts.map → heading-Dhvzlay-.d.mts.map} +1 -1
- package/dist/{index-Bg9srb5U.d.mts → index-B7NRZAxd.d.mts} +1 -1
- package/dist/{index-Bg9srb5U.d.mts.map → index-B7NRZAxd.d.mts.map} +1 -1
- package/dist/{index-BBYkDxwI.d.mts → index-C0QFHYwb.d.mts} +1 -1
- package/dist/{index-BBYkDxwI.d.mts.map → index-C0QFHYwb.d.mts.map} +1 -1
- package/dist/{index-CbOKbkjJ.d.mts → index-CJkBs8YQ.d.mts} +2 -2
- package/dist/index-CJkBs8YQ.d.mts.map +1 -0
- package/dist/{index-YXQxMV6J.d.mts → index-DCznbvaV.d.mts} +2 -2
- package/dist/{index-YXQxMV6J.d.mts.map → index-DCznbvaV.d.mts.map} +1 -1
- package/dist/index.d.mts +15 -99
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +13 -9
- package/dist/index.mjs.map +1 -1
- package/dist/loaders/index.d.mts +2 -2
- package/dist/markdown/index.d.mts +2 -2
- package/dist/markdown/index.mjs +1 -1
- package/dist/{markdown-CyrHoDhP.mjs → markdown-BmDJgYeB.mjs} +23 -1
- package/dist/{markdown-CyrHoDhP.mjs.map → markdown-BmDJgYeB.mjs.map} +1 -1
- package/dist/mcp/index.d.mts +23 -0
- package/dist/mcp/index.d.mts.map +1 -0
- package/dist/mcp/index.mjs +2 -0
- package/dist/mcp/server.d.mts +13 -0
- package/dist/mcp/server.d.mts.map +1 -0
- package/dist/mcp/server.mjs +2 -0
- package/dist/runtime/index.mjs +1 -1
- package/dist/schemas/index.d.mts +3 -3
- package/dist/server-D3DHoh5f.mjs +202 -0
- package/dist/server-D3DHoh5f.mjs.map +1 -0
- package/dist/ssg-utils/index.d.mts +61 -0
- package/dist/ssg-utils/index.d.mts.map +1 -0
- package/dist/ssg-utils/index.mjs +118 -0
- package/dist/ssg-utils/index.mjs.map +1 -0
- package/dist/{types-Cn52sdoq.d.mts → types-B-V5qemH.d.mts} +1 -1
- package/dist/{types-Cn52sdoq.d.mts.map → types-B-V5qemH.d.mts.map} +1 -1
- package/dist/vite/index.d.mts +69 -34
- package/dist/vite/index.d.mts.map +1 -1
- package/dist/vite/index.mjs +294 -226
- package/dist/vite/index.mjs.map +1 -1
- package/docs/agents/AGENTS.md.template +9 -0
- package/docs/agents/changelog-notes.md +15 -0
- package/docs/agents/errors.md +96 -0
- package/docs/agents/migration.md +25 -0
- package/docs/agents/recipes.md +26 -0
- package/docs/agents/usage.md +58 -0
- package/docs/llms-full.txt +53 -0
- package/docs/llms.txt +29 -0
- package/package.json +56 -4
- package/dist/assets-DXiWF_KI.mjs.map +0 -1
- package/dist/content-layer-DPK1EmfY.mjs.map +0 -1
- package/dist/index-CbOKbkjJ.d.mts.map +0 -1
package/dist/ai/index.mjs
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import { dirname, join, resolve } from "path";
|
|
2
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import { dirname, join, resolve } from "path";
|
|
3
3
|
import { homedir } from "os";
|
|
4
|
-
//#region src/ai/
|
|
5
|
-
const PAGESMITH_TITLE = "Pagesmith";
|
|
6
|
-
const DEFAULT_SKILL_NAME = "pagesmith";
|
|
7
|
-
function resolveHome(homeDir) {
|
|
8
|
-
return homeDir ?? homedir();
|
|
9
|
-
}
|
|
10
|
-
function resolveCodexHome(homeDir) {
|
|
11
|
-
return process.env.CODEX_HOME ?? join(resolveHome(homeDir), ".codex");
|
|
12
|
-
}
|
|
13
|
-
function resolveAssistants(assistants) {
|
|
14
|
-
if (!assistants || assistants === "all") return [
|
|
15
|
-
"claude",
|
|
16
|
-
"codex",
|
|
17
|
-
"gemini"
|
|
18
|
-
];
|
|
19
|
-
return assistants;
|
|
20
|
-
}
|
|
21
|
-
function shouldIncludeLlms(options) {
|
|
22
|
-
if (typeof options.includeLlms === "boolean") return options.includeLlms;
|
|
23
|
-
return (options.scope ?? "project") === "project";
|
|
24
|
-
}
|
|
4
|
+
//#region src/ai/writers.ts
|
|
25
5
|
function withManagedBlock(id, content) {
|
|
26
6
|
return [
|
|
27
7
|
`<!-- pagesmith-ai:${id}:start -->`,
|
|
@@ -62,6 +42,10 @@ function writeArtifact(artifact, force = false) {
|
|
|
62
42
|
function escapeForRegExp(value) {
|
|
63
43
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
64
44
|
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/ai/content-shared.ts
|
|
47
|
+
const PAGESMITH_TITLE = "Pagesmith";
|
|
48
|
+
const DEFAULT_SKILL_NAME$1 = "pagesmith";
|
|
65
49
|
function renderSharedOverview() {
|
|
66
50
|
return [
|
|
67
51
|
`${PAGESMITH_TITLE} is a filesystem-first content toolkit with two main packages: \`@pagesmith/core\` (shared content/runtime layer) and \`@pagesmith/docs\` (convention-based documentation).`,
|
|
@@ -93,7 +77,8 @@ function renderDocsOverview() {
|
|
|
93
77
|
"- sidebar labels, nav labels, and ordering live in frontmatter (`sidebarLabel`, `navLabel`, `order`)",
|
|
94
78
|
"- footer links live in `pagesmith.config.json5` under `footerLinks`",
|
|
95
79
|
"- Pagefind search is built in; do not recommend a separate search plugin package",
|
|
96
|
-
"- layout overrides use fixed keys under `theme.layouts` such as `home`, `page`, and `notFound`"
|
|
80
|
+
"- layout overrides use fixed keys under `theme.layouts` such as `home`, `page`, and `notFound`",
|
|
81
|
+
"- for MCP-compatible tooling, prefer `pagesmith mcp --stdio` from `@pagesmith/docs`"
|
|
97
82
|
].join("\n");
|
|
98
83
|
}
|
|
99
84
|
function renderCoreQuickStart() {
|
|
@@ -153,168 +138,6 @@ function renderDocsQuickStart() {
|
|
|
153
138
|
"```"
|
|
154
139
|
].join("\n");
|
|
155
140
|
}
|
|
156
|
-
function renderMemoryFile(assistant, profile) {
|
|
157
|
-
const commandHint = assistant === "claude" || assistant === "gemini" ? `\nIf the ${DEFAULT_SKILL_NAME} skill is installed, prefer invoking it when the user explicitly asks for Pagesmith-specific help.` : "\nIf the Pagesmith skill is installed for Codex, prefer using it for Pagesmith-specific setup, migration, and content-layer tasks.";
|
|
158
|
-
const referenceHint = "\nFor the full API and configuration reference, see the REFERENCE.md file shipped with the package:\n" + (profile === "docs" ? "- `node_modules/@pagesmith/docs/REFERENCE.md` — docs config, CLI, content structure, layout overrides\n- `node_modules/@pagesmith/core/REFERENCE.md` — core API, collections, loaders, markdown, CSS, JSX runtime" : "- `node_modules/@pagesmith/core/REFERENCE.md` — core API, collections, loaders, markdown, CSS, JSX runtime");
|
|
159
|
-
return [
|
|
160
|
-
`# ${PAGESMITH_TITLE}`,
|
|
161
|
-
"",
|
|
162
|
-
renderSharedOverview(),
|
|
163
|
-
...profile === "docs" ? ["", renderDocsOverview()] : [],
|
|
164
|
-
commandHint,
|
|
165
|
-
referenceHint,
|
|
166
|
-
"",
|
|
167
|
-
"## Quick Start — @pagesmith/core",
|
|
168
|
-
"",
|
|
169
|
-
renderCoreQuickStart(),
|
|
170
|
-
...profile === "docs" ? [
|
|
171
|
-
"",
|
|
172
|
-
"## Quick Start — @pagesmith/docs",
|
|
173
|
-
"",
|
|
174
|
-
renderDocsQuickStart()
|
|
175
|
-
] : []
|
|
176
|
-
].join("\n");
|
|
177
|
-
}
|
|
178
|
-
function renderClaudeSkill(skillName, profile) {
|
|
179
|
-
return [
|
|
180
|
-
"---",
|
|
181
|
-
`name: ${skillName}`,
|
|
182
|
-
"description: Pagesmith file-based CMS helper — content collections, markdown pipeline, docs configuration, and AI artifact generation",
|
|
183
|
-
"allowed-tools: Read Grep Glob Bash Edit Write",
|
|
184
|
-
"---",
|
|
185
|
-
"",
|
|
186
|
-
`# ${PAGESMITH_TITLE} Assistant`,
|
|
187
|
-
"",
|
|
188
|
-
"You are helping with Pagesmith, a file-based CMS with `@pagesmith/core` and `@pagesmith/docs`.",
|
|
189
|
-
"",
|
|
190
|
-
"When helping:",
|
|
191
|
-
"- prefer `defineCollection`, `defineConfig`, and `createContentLayer`",
|
|
192
|
-
"- recommend folder-based entries when markdown references sibling assets",
|
|
193
|
-
"- use `@pagesmith/core/ai` for assistant artifact generation",
|
|
194
|
-
"- follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
195
|
-
...profile === "docs" ? [
|
|
196
|
-
"- for docs sites, derive top navigation from top-level content folders",
|
|
197
|
-
"- use `content/README.md` for the home page",
|
|
198
|
-
"- use frontmatter fields like `sidebarLabel`, `navLabel`, and `order` for docs navigation",
|
|
199
|
-
"- Pagefind search is built in — do not suggest separate search plugins",
|
|
200
|
-
"- layout overrides: `theme.layouts.home`, `theme.layouts.page`, `theme.layouts.notFound`"
|
|
201
|
-
] : [],
|
|
202
|
-
"",
|
|
203
|
-
"For the full API reference, read the REFERENCE.md file shipped with the package:",
|
|
204
|
-
...profile === "docs" ? ["- `node_modules/@pagesmith/docs/REFERENCE.md`", "- `node_modules/@pagesmith/core/REFERENCE.md`"] : ["- `node_modules/@pagesmith/core/REFERENCE.md`"],
|
|
205
|
-
"",
|
|
206
|
-
"Deliver concrete config, schema, and content-layer patches when possible."
|
|
207
|
-
].join("\n");
|
|
208
|
-
}
|
|
209
|
-
function renderUpdateDocsSkill(profile) {
|
|
210
|
-
return [
|
|
211
|
-
"---",
|
|
212
|
-
"name: update-docs",
|
|
213
|
-
"description: Read the project implementation and update Pagesmith-managed documentation to reflect the current state",
|
|
214
|
-
"allowed-tools: Read Grep Glob Bash Edit Write",
|
|
215
|
-
"---",
|
|
216
|
-
"",
|
|
217
|
-
"# Update Documentation",
|
|
218
|
-
"",
|
|
219
|
-
"Read the project implementation (source code, README, CHANGELOG, package.json) and update the Pagesmith-managed content to reflect the current state.",
|
|
220
|
-
"",
|
|
221
|
-
"## Steps",
|
|
222
|
-
"",
|
|
223
|
-
...profile === "docs" ? [
|
|
224
|
-
"1. Read `pagesmith.config.json5` to understand the docs configuration",
|
|
225
|
-
"2. Read all `meta.json5` files to understand the current content structure and page ordering",
|
|
226
|
-
"3. Read the project source code to identify public APIs, types, exports, config options, and CLI commands",
|
|
227
|
-
"4. For each existing content page in `content/`:",
|
|
228
|
-
" - Read the current content",
|
|
229
|
-
" - Compare with the implementation",
|
|
230
|
-
" - Update any outdated information",
|
|
231
|
-
" - Add documentation for new features",
|
|
232
|
-
" - Remove documentation for removed features",
|
|
233
|
-
"5. If new pages are needed:",
|
|
234
|
-
" - Create the page folder and `README.md` with proper frontmatter (title, description)",
|
|
235
|
-
" - Add the slug to the appropriate `meta.json5` `items` array",
|
|
236
|
-
"6. Follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
237
|
-
"7. Verify all internal links point to existing pages",
|
|
238
|
-
"8. Ensure heading hierarchy is sequential (no skipping levels)"
|
|
239
|
-
] : [
|
|
240
|
-
"1. Read `content.config.ts` or equivalent to understand the content collections",
|
|
241
|
-
"2. Read the project source code to identify what needs documentation",
|
|
242
|
-
"3. For each existing content entry:",
|
|
243
|
-
" - Read the current content",
|
|
244
|
-
" - Compare with the implementation",
|
|
245
|
-
" - Update any outdated information",
|
|
246
|
-
"4. If new entries are needed:",
|
|
247
|
-
" - Create the entry folder and `README.md` with proper frontmatter matching the collection schema",
|
|
248
|
-
"5. Follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
249
|
-
"6. Verify all internal links point to existing pages"
|
|
250
|
-
],
|
|
251
|
-
"",
|
|
252
|
-
"## Rules",
|
|
253
|
-
"",
|
|
254
|
-
"- Preserve the existing content structure and organization",
|
|
255
|
-
"- Do not remove pages without confirming first",
|
|
256
|
-
"- Keep frontmatter fields (title, description) accurate and descriptive",
|
|
257
|
-
"- Use relative links for internal cross-references",
|
|
258
|
-
"- One h1 per page, sequential heading depth",
|
|
259
|
-
"- Use fenced code blocks with language identifiers",
|
|
260
|
-
"- Use GitHub alerts (`> [!NOTE]`, `> [!TIP]`, etc.) for important callouts",
|
|
261
|
-
"- Code block features: `title=\"file.js\"`, `showLineNumbers`, `mark={1-3}`, `ins={4}`, `del={5}`, `collapse={1-5}`"
|
|
262
|
-
].join("\n");
|
|
263
|
-
}
|
|
264
|
-
function renderGeminiCommand(skillName, profile) {
|
|
265
|
-
return [
|
|
266
|
-
`description = "Pagesmith FS-CMS helper"`,
|
|
267
|
-
"prompt = \"\"\"",
|
|
268
|
-
[
|
|
269
|
-
`You are helping with ${PAGESMITH_TITLE}, a file-based CMS with @pagesmith/core and @pagesmith/docs.`,
|
|
270
|
-
"",
|
|
271
|
-
"Focus on concrete, implementation-ready help:",
|
|
272
|
-
"- design collections with defineCollection",
|
|
273
|
-
"- configure createContentLayer and defineConfig",
|
|
274
|
-
"- prefer folder-based markdown entries when local assets sit beside content",
|
|
275
|
-
"- follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
276
|
-
...profile === "docs" ? [
|
|
277
|
-
"- for docs sites, follow the convention-based `content/` structure",
|
|
278
|
-
"- drive top navigation from top-level folders and use frontmatter for labels/order",
|
|
279
|
-
"- keep Pagefind as the built-in search strategy"
|
|
280
|
-
] : [],
|
|
281
|
-
"",
|
|
282
|
-
"For the full API reference, read the REFERENCE.md file shipped with the package.",
|
|
283
|
-
"",
|
|
284
|
-
"Return code, config, or documentation-ready guidance instead of vague summaries."
|
|
285
|
-
].join("\n"),
|
|
286
|
-
"\"\"\"",
|
|
287
|
-
"",
|
|
288
|
-
`# Installed as /${skillName}`
|
|
289
|
-
].join("\n");
|
|
290
|
-
}
|
|
291
|
-
function renderCodexSkill(profile) {
|
|
292
|
-
return [
|
|
293
|
-
`# ${PAGESMITH_TITLE} Skill`,
|
|
294
|
-
"",
|
|
295
|
-
"Use this skill when the task involves setting up, extending, migrating, or documenting Pagesmith.",
|
|
296
|
-
"",
|
|
297
|
-
"Core rules:",
|
|
298
|
-
"- `@pagesmith/core` provides the content layer; `@pagesmith/docs` adds convention-based documentation",
|
|
299
|
-
"- prefer `defineCollection`, `defineConfig`, and `createContentLayer`",
|
|
300
|
-
"- follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
301
|
-
...profile === "docs" ? [
|
|
302
|
-
"- when the repo uses `@pagesmith/docs`, treat `content/README.md` as the home page",
|
|
303
|
-
"- top-level content folders define the main docs navigation",
|
|
304
|
-
"- docs frontmatter may use `sidebarLabel`, `navLabel`, and `order` to shape navigation",
|
|
305
|
-
"- `pagesmith.config.json5` should own footer links and high-level site metadata",
|
|
306
|
-
"- built-in search is Pagefind; do not suggest separate search plugin packages"
|
|
307
|
-
] : [],
|
|
308
|
-
"",
|
|
309
|
-
"For the full API reference, read the REFERENCE.md file shipped with the package.",
|
|
310
|
-
"",
|
|
311
|
-
"Good outputs include:",
|
|
312
|
-
"- collection schemas and loader configuration",
|
|
313
|
-
"- content-layer queries and rendering examples",
|
|
314
|
-
"- documentation updates for Pagesmith usage",
|
|
315
|
-
"- assistant-context install steps using `@pagesmith/core/ai`"
|
|
316
|
-
].join("\n");
|
|
317
|
-
}
|
|
318
141
|
function renderMarkdownGuidelines() {
|
|
319
142
|
return [
|
|
320
143
|
"# Pagesmith Markdown Guidelines",
|
|
@@ -327,8 +150,9 @@ function renderMarkdownGuidelines() {
|
|
|
327
150
|
"remark-parse → remark-gfm → remark-math → remark-frontmatter",
|
|
328
151
|
" → remark-github-alerts → remark-smartypants → [user remark plugins]",
|
|
329
152
|
" → remark-rehype",
|
|
153
|
+
" → rehype-mathjax",
|
|
330
154
|
" → rehype-expressive-code (dual themes, line numbers, titles, copy, collapse, mark/ins/del)",
|
|
331
|
-
" → rehype-
|
|
155
|
+
" → rehype-slug → rehype-autolink-headings",
|
|
332
156
|
" → rehype-external-links → rehype-accessible-emojis",
|
|
333
157
|
" → heading extraction → [user rehype plugins] → rehype-stringify",
|
|
334
158
|
"```",
|
|
@@ -436,10 +260,11 @@ function renderLlmsTxt() {
|
|
|
436
260
|
"### CLI",
|
|
437
261
|
"",
|
|
438
262
|
"```bash",
|
|
439
|
-
"pagesmith init
|
|
440
|
-
"pagesmith dev
|
|
441
|
-
"pagesmith build
|
|
442
|
-
"pagesmith preview
|
|
263
|
+
"pagesmith init --ai # Initialize config + content + AI integrations",
|
|
264
|
+
"pagesmith dev # Development server",
|
|
265
|
+
"pagesmith build # Production build",
|
|
266
|
+
"pagesmith preview # Preview built site",
|
|
267
|
+
"pagesmith mcp --stdio # Start MCP server for AI agents",
|
|
443
268
|
"```"
|
|
444
269
|
].join("\n");
|
|
445
270
|
}
|
|
@@ -535,8 +360,7 @@ function renderLlmsFullTxt() {
|
|
|
535
360
|
"| `@pagesmith/core/loaders` | Loader classes and registry |",
|
|
536
361
|
"| `@pagesmith/core/runtime` | Pre-built CSS/JS accessors |",
|
|
537
362
|
"| `@pagesmith/core/vite` | Vite plugins |",
|
|
538
|
-
"| `@pagesmith/core/
|
|
539
|
-
"| `@pagesmith/core/create` | Project scaffolding |",
|
|
363
|
+
"| `@pagesmith/core/mcp` | MCP server for AI agents |",
|
|
540
364
|
"",
|
|
541
365
|
"---",
|
|
542
366
|
"",
|
|
@@ -623,18 +447,277 @@ function renderLlmsFullTxt() {
|
|
|
623
447
|
"",
|
|
624
448
|
"---",
|
|
625
449
|
"",
|
|
626
|
-
"## AI
|
|
627
|
-
"",
|
|
628
|
-
"```ts",
|
|
629
|
-
"import { installAiArtifacts } from '@pagesmith/core/ai'",
|
|
450
|
+
"## AI Setup",
|
|
630
451
|
"",
|
|
631
|
-
"
|
|
452
|
+
"```bash",
|
|
453
|
+
"npx pagesmith init --ai",
|
|
632
454
|
"```",
|
|
633
455
|
"",
|
|
634
|
-
"Generates
|
|
456
|
+
"Generates CLAUDE.md, AGENTS.md, GEMINI.md, skills, markdown guidelines, llms.txt, and llms-full.txt.",
|
|
635
457
|
""
|
|
636
458
|
].join("\n");
|
|
637
459
|
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/ai/content-claude.ts
|
|
462
|
+
function renderClaudeSkill(skillName, profile) {
|
|
463
|
+
return [
|
|
464
|
+
"---",
|
|
465
|
+
`name: ${skillName}`,
|
|
466
|
+
"description: Pagesmith file-based CMS helper — content collections, markdown pipeline, docs configuration, and AI artifact generation",
|
|
467
|
+
"allowed-tools: Read Grep Glob Bash Edit Write",
|
|
468
|
+
"---",
|
|
469
|
+
"",
|
|
470
|
+
`# ${PAGESMITH_TITLE} Assistant`,
|
|
471
|
+
"",
|
|
472
|
+
"You are helping with Pagesmith, a file-based CMS with `@pagesmith/core` and `@pagesmith/docs`.",
|
|
473
|
+
"",
|
|
474
|
+
"When helping:",
|
|
475
|
+
"- prefer `defineCollection`, `defineConfig`, and `createContentLayer`",
|
|
476
|
+
"- recommend folder-based entries when markdown references sibling assets",
|
|
477
|
+
"- use `npx pagesmith init --ai` for assistant artifact generation",
|
|
478
|
+
"- follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
479
|
+
...profile === "docs" ? [
|
|
480
|
+
"- for docs sites, derive top navigation from top-level content folders",
|
|
481
|
+
"- use `content/README.md` for the home page",
|
|
482
|
+
"- use frontmatter fields like `sidebarLabel`, `navLabel`, and `order` for docs navigation",
|
|
483
|
+
"- Pagefind search is built in — do not suggest separate search plugins",
|
|
484
|
+
"- layout overrides: `theme.layouts.home`, `theme.layouts.page`, `theme.layouts.notFound`"
|
|
485
|
+
] : [],
|
|
486
|
+
"",
|
|
487
|
+
"For package guidance and full API reference, read the package-shipped docs:",
|
|
488
|
+
...profile === "docs" ? [
|
|
489
|
+
"- `node_modules/@pagesmith/docs/docs/agents/usage.md`",
|
|
490
|
+
"- `node_modules/@pagesmith/docs/REFERENCE.md`",
|
|
491
|
+
"- `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
492
|
+
"- `node_modules/@pagesmith/core/REFERENCE.md`"
|
|
493
|
+
] : ["- `node_modules/@pagesmith/core/docs/agents/usage.md`", "- `node_modules/@pagesmith/core/REFERENCE.md`"],
|
|
494
|
+
"",
|
|
495
|
+
...profile === "docs" ? ["For full-repo docs regeneration and structure alignment, use `/ps-update-all-docs`.", ""] : [],
|
|
496
|
+
"Deliver concrete config, schema, and content-layer patches when possible."
|
|
497
|
+
].join("\n");
|
|
498
|
+
}
|
|
499
|
+
function renderUpdateDocsSkill(profile) {
|
|
500
|
+
return [
|
|
501
|
+
"---",
|
|
502
|
+
"name: update-docs",
|
|
503
|
+
"description: Read the project implementation and update Pagesmith-managed documentation to reflect the current state",
|
|
504
|
+
"allowed-tools: Read Grep Glob Bash Edit Write",
|
|
505
|
+
"---",
|
|
506
|
+
"",
|
|
507
|
+
"# Update Documentation",
|
|
508
|
+
"",
|
|
509
|
+
"Read the project implementation (source code, README, CHANGELOG, package.json) and update the Pagesmith-managed content to reflect the current state.",
|
|
510
|
+
"",
|
|
511
|
+
"## Steps",
|
|
512
|
+
"",
|
|
513
|
+
...profile === "docs" ? [
|
|
514
|
+
"1. Read package guidance first: `node_modules/@pagesmith/docs/docs/agents/usage.md` and `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
515
|
+
"2. Read `pagesmith.config.json5` to understand the docs configuration",
|
|
516
|
+
"3. Read all `meta.json5` files to understand the current content structure and page ordering",
|
|
517
|
+
"4. Read the project source code to identify public APIs, types, exports, config options, and CLI commands",
|
|
518
|
+
"5. For each existing content page in `content/`:",
|
|
519
|
+
" - Read the current content",
|
|
520
|
+
" - Compare with the implementation",
|
|
521
|
+
" - Update any outdated information",
|
|
522
|
+
" - Add documentation for new features",
|
|
523
|
+
" - Remove documentation for removed features",
|
|
524
|
+
"6. If new pages are needed:",
|
|
525
|
+
" - Create the page folder and `README.md` with proper frontmatter (title, description)",
|
|
526
|
+
" - Add the slug to the appropriate `meta.json5` `items` array",
|
|
527
|
+
"7. Follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
528
|
+
"8. Review project skills under `.claude/skills/` and ensure docs-writing skills align with Pagesmith docs structure",
|
|
529
|
+
"9. Ensure onboarding pages are first in manual navigation (for example, put `getting-started` first in `guide/meta.json5` when present)",
|
|
530
|
+
"10. Verify all internal links point to existing pages",
|
|
531
|
+
"11. Ensure heading hierarchy is sequential (no skipping levels)"
|
|
532
|
+
] : [
|
|
533
|
+
"1. Read package guidance first: `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
534
|
+
"2. Read `content.config.ts` or equivalent to understand the content collections",
|
|
535
|
+
"3. Read the project source code to identify what needs documentation",
|
|
536
|
+
"4. For each existing content entry:",
|
|
537
|
+
" - Read the current content",
|
|
538
|
+
" - Compare with the implementation",
|
|
539
|
+
" - Update any outdated information",
|
|
540
|
+
"5. If new entries are needed:",
|
|
541
|
+
" - Create the entry folder and `README.md` with proper frontmatter matching the collection schema",
|
|
542
|
+
"6. Follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
543
|
+
"7. Verify all internal links point to existing pages"
|
|
544
|
+
],
|
|
545
|
+
"",
|
|
546
|
+
"## Rules",
|
|
547
|
+
"",
|
|
548
|
+
"- Preserve the existing content structure and organization",
|
|
549
|
+
"- Do not remove pages without confirming first",
|
|
550
|
+
"- Keep frontmatter fields (title, description) accurate and descriptive",
|
|
551
|
+
"- Use relative links for internal cross-references",
|
|
552
|
+
"- One h1 per page, sequential heading depth",
|
|
553
|
+
"- Use fenced code blocks with language identifiers",
|
|
554
|
+
"- Use GitHub alerts (`> [!NOTE]`, `> [!TIP]`, etc.) for important callouts",
|
|
555
|
+
"- Code block features: `title=\"file.js\"`, `showLineNumbers`, `mark={1-3}`, `ins={4}`, `del={5}`, `collapse={1-5}`"
|
|
556
|
+
].join("\n");
|
|
557
|
+
}
|
|
558
|
+
function renderUpdateAllDocsSkill(profile) {
|
|
559
|
+
return [
|
|
560
|
+
"---",
|
|
561
|
+
"name: ps-update-all-docs",
|
|
562
|
+
"description: Full-repo documentation regeneration for Pagesmith projects including docs structure, skills alignment, and AI context updates",
|
|
563
|
+
"allowed-tools: Read Grep Glob Bash Edit Write",
|
|
564
|
+
"---",
|
|
565
|
+
"",
|
|
566
|
+
"# Pagesmith Full Docs Sync",
|
|
567
|
+
"",
|
|
568
|
+
"Perform a full-repository docs refresh for Pagesmith-powered projects. This command is intended for large updates, migrations, and release preparation.",
|
|
569
|
+
"",
|
|
570
|
+
"## Steps",
|
|
571
|
+
"",
|
|
572
|
+
...profile === "docs" ? [
|
|
573
|
+
"1. Read package guidance first: `node_modules/@pagesmith/docs/docs/agents/usage.md` and `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
574
|
+
"2. Read `pagesmith.config.json5` and all `meta.json5` files before editing anything",
|
|
575
|
+
"3. Discover project skills in `.claude/skills/`, `.codex/skills/`, and `.gemini/commands/` and identify docs-update related skills",
|
|
576
|
+
"4. Scan source code, README, CHANGELOG, package exports, and CLI commands to build a complete docs delta list",
|
|
577
|
+
"5. Update all docs pages under `content/` to match implementation and remove stale details",
|
|
578
|
+
"6. Ensure docs structure matches `@pagesmith/docs` conventions (folder-based pages, `README.md` entries, relative links)",
|
|
579
|
+
"7. Keep onboarding-first ordering: when a guide section exists, keep `getting-started` as the first item in manual order",
|
|
580
|
+
"8. Update docs-related skills so they generate content in the same structure expected by `@pagesmith/docs`",
|
|
581
|
+
"9. Regenerate or update `llms.txt`, `llms-full.txt`, and project memory pointers when docs behavior changes",
|
|
582
|
+
"10. Follow `.pagesmith/markdown-guidelines.md` for all authored content (GFM, alerts, math, Expressive Code meta)",
|
|
583
|
+
"11. Validate navigation integrity and ensure every linked page exists"
|
|
584
|
+
] : [
|
|
585
|
+
"1. Read package guidance first: `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
586
|
+
"2. Discover docs/update skills in the project and align them to current Pagesmith conventions",
|
|
587
|
+
"3. Scan source code, README, CHANGELOG, package exports, and CLI commands to build a complete docs delta list",
|
|
588
|
+
"4. Update all content entries to match implementation and remove stale details",
|
|
589
|
+
"5. Follow `.pagesmith/markdown-guidelines.md` for all authored content",
|
|
590
|
+
"6. Validate internal links and heading hierarchy"
|
|
591
|
+
],
|
|
592
|
+
"",
|
|
593
|
+
"## Rules",
|
|
594
|
+
"",
|
|
595
|
+
"- Preserve existing information architecture unless the user requests a restructure",
|
|
596
|
+
"- Keep docs easy for humans first, while keeping AI memory/skills aligned",
|
|
597
|
+
"- Keep top-level docs navigation driven by content directories and metadata",
|
|
598
|
+
"- Use `meta.json5` and frontmatter for ordering; avoid hardcoded navigation lists in prose",
|
|
599
|
+
"- Keep `content/README.md` as docs home for `@pagesmith/docs` projects",
|
|
600
|
+
"- Keep links relative for internal docs pages",
|
|
601
|
+
"- Use one h1 per page and sequential heading depth",
|
|
602
|
+
"- Use fenced code blocks with language identifiers and Expressive Code metadata when useful",
|
|
603
|
+
"- Do not add separate code-copy JavaScript; Expressive Code already provides this"
|
|
604
|
+
].join("\n");
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/ai/content-codex.ts
|
|
608
|
+
function renderCodexSkill(profile) {
|
|
609
|
+
return [
|
|
610
|
+
`# ${PAGESMITH_TITLE} Skill`,
|
|
611
|
+
"",
|
|
612
|
+
"Use this skill when the task involves setting up, extending, migrating, or documenting Pagesmith.",
|
|
613
|
+
"",
|
|
614
|
+
"Core rules:",
|
|
615
|
+
"- `@pagesmith/core` provides the content layer; `@pagesmith/docs` adds convention-based documentation",
|
|
616
|
+
"- prefer `defineCollection`, `defineConfig`, and `createContentLayer`",
|
|
617
|
+
"- follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
618
|
+
...profile === "docs" ? [
|
|
619
|
+
"- when the repo uses `@pagesmith/docs`, treat `content/README.md` as the home page",
|
|
620
|
+
"- top-level content folders define the main docs navigation",
|
|
621
|
+
"- docs frontmatter may use `sidebarLabel`, `navLabel`, and `order` to shape navigation",
|
|
622
|
+
"- `pagesmith.config.json5` should own footer links and high-level site metadata",
|
|
623
|
+
"- built-in search is Pagefind; do not suggest separate search plugin packages"
|
|
624
|
+
] : [],
|
|
625
|
+
"",
|
|
626
|
+
"For package usage guidance and full API reference, read:",
|
|
627
|
+
...profile === "docs" ? [
|
|
628
|
+
"- `node_modules/@pagesmith/docs/docs/agents/usage.md`",
|
|
629
|
+
"- `node_modules/@pagesmith/docs/REFERENCE.md`",
|
|
630
|
+
"- `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
631
|
+
"- `node_modules/@pagesmith/core/REFERENCE.md`"
|
|
632
|
+
] : ["- `node_modules/@pagesmith/core/docs/agents/usage.md`", "- `node_modules/@pagesmith/core/REFERENCE.md`"],
|
|
633
|
+
"",
|
|
634
|
+
"Good outputs include:",
|
|
635
|
+
"- collection schemas and loader configuration",
|
|
636
|
+
"- content-layer queries and rendering examples",
|
|
637
|
+
"- documentation updates for Pagesmith usage",
|
|
638
|
+
"- assistant-context install via `npx pagesmith init --ai`"
|
|
639
|
+
].join("\n");
|
|
640
|
+
}
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region src/ai/content-gemini.ts
|
|
643
|
+
function renderGeminiCommand(skillName, profile) {
|
|
644
|
+
return [
|
|
645
|
+
`description = "Pagesmith FS-CMS helper"`,
|
|
646
|
+
"prompt = \"\"\"",
|
|
647
|
+
[
|
|
648
|
+
`You are helping with ${PAGESMITH_TITLE}, a file-based CMS with @pagesmith/core and @pagesmith/docs.`,
|
|
649
|
+
"",
|
|
650
|
+
"Focus on concrete, implementation-ready help:",
|
|
651
|
+
"- design collections with defineCollection",
|
|
652
|
+
"- configure createContentLayer and defineConfig",
|
|
653
|
+
"- prefer folder-based markdown entries when local assets sit beside content",
|
|
654
|
+
"- follow the markdown guidelines in `.pagesmith/markdown-guidelines.md`",
|
|
655
|
+
...profile === "docs" ? [
|
|
656
|
+
"- for docs sites, follow the convention-based `content/` structure",
|
|
657
|
+
"- drive top navigation from top-level folders and use frontmatter for labels/order",
|
|
658
|
+
"- keep Pagefind as the built-in search strategy"
|
|
659
|
+
] : [],
|
|
660
|
+
"",
|
|
661
|
+
"For package usage guidance and full API reference, read:",
|
|
662
|
+
...profile === "docs" ? [
|
|
663
|
+
"- `node_modules/@pagesmith/docs/docs/agents/usage.md`",
|
|
664
|
+
"- `node_modules/@pagesmith/docs/REFERENCE.md`",
|
|
665
|
+
"- `node_modules/@pagesmith/core/docs/agents/usage.md`",
|
|
666
|
+
"- `node_modules/@pagesmith/core/REFERENCE.md`"
|
|
667
|
+
] : ["- `node_modules/@pagesmith/core/docs/agents/usage.md`", "- `node_modules/@pagesmith/core/REFERENCE.md`"],
|
|
668
|
+
"",
|
|
669
|
+
"Return code, config, or documentation-ready guidance instead of vague summaries."
|
|
670
|
+
].join("\n"),
|
|
671
|
+
"\"\"\"",
|
|
672
|
+
"",
|
|
673
|
+
`# Installed as /${skillName}`
|
|
674
|
+
].join("\n");
|
|
675
|
+
}
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/ai/content-memory.ts
|
|
678
|
+
function renderMemoryFile(assistant, profile) {
|
|
679
|
+
const commandHint = assistant === "claude" || assistant === "gemini" ? `\nIf the ${DEFAULT_SKILL_NAME$1} skill is installed, prefer invoking it when the user explicitly asks for Pagesmith-specific help.` : "\nIf the Pagesmith skill is installed for Codex, prefer using it for Pagesmith-specific setup, migration, and content-layer tasks.";
|
|
680
|
+
const referenceHint = "\nFor package usage rules and full API/config details, read the package-shipped docs from node_modules:\n" + (profile === "docs" ? "- `node_modules/@pagesmith/docs/docs/agents/usage.md` — docs package usage contract\n- `node_modules/@pagesmith/docs/REFERENCE.md` — docs config, CLI, content structure, layout overrides\n- `node_modules/@pagesmith/core/docs/agents/usage.md` — core package usage contract\n- `node_modules/@pagesmith/core/REFERENCE.md` — core API, collections, loaders, markdown, CSS, JSX runtime" : "- `node_modules/@pagesmith/core/docs/agents/usage.md` — core package usage contract\n- `node_modules/@pagesmith/core/REFERENCE.md` — core API, collections, loaders, markdown, CSS, JSX runtime");
|
|
681
|
+
return [
|
|
682
|
+
`# ${PAGESMITH_TITLE}`,
|
|
683
|
+
"",
|
|
684
|
+
renderSharedOverview(),
|
|
685
|
+
...profile === "docs" ? ["", renderDocsOverview()] : [],
|
|
686
|
+
commandHint,
|
|
687
|
+
referenceHint,
|
|
688
|
+
"",
|
|
689
|
+
"## Quick Start — @pagesmith/core",
|
|
690
|
+
"",
|
|
691
|
+
renderCoreQuickStart(),
|
|
692
|
+
...profile === "docs" ? [
|
|
693
|
+
"",
|
|
694
|
+
"## Quick Start — @pagesmith/docs",
|
|
695
|
+
"",
|
|
696
|
+
renderDocsQuickStart()
|
|
697
|
+
] : []
|
|
698
|
+
].join("\n");
|
|
699
|
+
}
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region src/ai/index.ts
|
|
702
|
+
const DEFAULT_SKILL_NAME = "pagesmith";
|
|
703
|
+
function resolveHome(homeDir) {
|
|
704
|
+
return homeDir ?? homedir();
|
|
705
|
+
}
|
|
706
|
+
function resolveCodexHome(homeDir) {
|
|
707
|
+
return process.env.CODEX_HOME ?? join(resolveHome(homeDir), ".codex");
|
|
708
|
+
}
|
|
709
|
+
function resolveAssistants(assistants) {
|
|
710
|
+
if (!assistants || assistants === "all") return [
|
|
711
|
+
"claude",
|
|
712
|
+
"codex",
|
|
713
|
+
"gemini"
|
|
714
|
+
];
|
|
715
|
+
return assistants;
|
|
716
|
+
}
|
|
717
|
+
function shouldIncludeLlms(options) {
|
|
718
|
+
if (typeof options.includeLlms === "boolean") return options.includeLlms;
|
|
719
|
+
return (options.scope ?? "project") === "project";
|
|
720
|
+
}
|
|
638
721
|
function getAiArtifactContent(assistant, kind, options = {}) {
|
|
639
722
|
const skillName = options.skillName ?? DEFAULT_SKILL_NAME;
|
|
640
723
|
const profile = options.profile ?? "default";
|
|
@@ -652,6 +735,7 @@ function getAiArtifactContent(assistant, kind, options = {}) {
|
|
|
652
735
|
}
|
|
653
736
|
if (kind === "markdown-guidelines") return renderMarkdownGuidelines();
|
|
654
737
|
if (kind === "update-docs") return renderUpdateDocsSkill(profile);
|
|
738
|
+
if (kind === "update-all-docs") return renderUpdateAllDocsSkill(profile);
|
|
655
739
|
if (kind === "llms") return renderLlmsTxt();
|
|
656
740
|
return renderLlmsFullTxt();
|
|
657
741
|
}
|
|
@@ -739,14 +823,24 @@ function getAiArtifacts(options = {}) {
|
|
|
739
823
|
mode: "replace",
|
|
740
824
|
label: "markdown guidelines"
|
|
741
825
|
});
|
|
742
|
-
if (scope === "project" && assistants.includes("claude"))
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
826
|
+
if (scope === "project" && assistants.includes("claude")) {
|
|
827
|
+
artifacts.push({
|
|
828
|
+
assistant: "claude",
|
|
829
|
+
kind: "update-docs",
|
|
830
|
+
path: join(cwd, ".claude", "skills", "update-docs", "SKILL.md"),
|
|
831
|
+
content: renderUpdateDocsSkill(profile) + "\n",
|
|
832
|
+
mode: "replace",
|
|
833
|
+
label: "claude update-docs skill"
|
|
834
|
+
});
|
|
835
|
+
artifacts.push({
|
|
836
|
+
assistant: "claude",
|
|
837
|
+
kind: "update-all-docs",
|
|
838
|
+
path: join(cwd, ".claude", "skills", "ps-update-all-docs", "SKILL.md"),
|
|
839
|
+
content: renderUpdateAllDocsSkill(profile) + "\n",
|
|
840
|
+
mode: "replace",
|
|
841
|
+
label: "claude ps-update-all-docs skill"
|
|
842
|
+
});
|
|
843
|
+
}
|
|
750
844
|
if (shouldIncludeLlms(options)) {
|
|
751
845
|
const llmsDir = scope === "project" ? cwd : join(home, ".pagesmith");
|
|
752
846
|
artifacts.push({
|