@ibalzam/codejitsu-core 0.1.0 → 0.2.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/CLAUDE.md +55 -39
- package/MIGRATIONS/0.2.0.md +166 -0
- package/README.md +25 -5
- package/checklist/bin/run.mjs +94 -54
- package/modules/blog/CLAUDE.md +105 -52
- package/modules/blog/src/collection.ts +176 -0
- package/modules/blog/src/fs.ts +167 -0
- package/modules/blog/src/index.ts +5 -201
- package/modules/blog/src/types.ts +71 -0
- package/modules/blog/templates/content.config.ts +27 -0
- package/modules/blog/templates/lib/blog-fs.ts +14 -0
- package/modules/blog/templates/lib/blog.ts +11 -3
- package/modules/config/CLAUDE.md +121 -0
- package/modules/config/src/define.ts +18 -0
- package/modules/config/src/index.ts +3 -0
- package/modules/config/src/load.ts +96 -0
- package/modules/config/src/types.ts +203 -0
- package/modules/images/CLAUDE.md +56 -39
- package/modules/images/bin/optimize.mjs +42 -34
- package/modules/images/checklist.md +15 -7
- package/modules/images/src/auto-blog.mjs +112 -0
- package/modules/images/src/index.ts +3 -18
- package/modules/images/src/optimize.mjs +7 -9
- package/modules/llms/CLAUDE.md +121 -28
- package/modules/llms/bin/generate.mjs +13 -23
- package/modules/llms/checklist.md +7 -6
- package/modules/llms/src/generate.mjs +374 -108
- package/modules/seo/CLAUDE.md +65 -21
- package/modules/seo/templates/Head.astro +99 -27
- package/package.json +11 -1
- package/src/index.ts +1 -1
- package/modules/images/templates/codejitsu-images.config.mjs +0 -18
- package/modules/llms/templates/codejitsu-llms.config.mjs +0 -39
package/modules/llms/CLAUDE.md
CHANGED
|
@@ -4,54 +4,147 @@ When the user asks to **set up codejitsu/core/llms** (or "add llms.txt", "genera
|
|
|
4
4
|
|
|
5
5
|
## What this module provides
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `public/llms.txt` — concise navigation overview for AI assistants.
|
|
9
|
-
- `public/llms-full.txt` — detailed content dump for LLM ingestion.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
`npx codejitsu-llms` reads `codejitsu.config.ts` and emits:
|
|
8
|
+
- `public/llms.txt` — concise navigation overview (for AI assistants browsing the site).
|
|
9
|
+
- `public/llms-full.txt` — detailed content dump (for LLM ingestion).
|
|
10
|
+
|
|
11
|
+
Two modes:
|
|
12
|
+
|
|
13
|
+
- **`config`** — items are listed explicitly in the config (`llms.sections`). Best for sites with stable, hand-curated structure.
|
|
14
|
+
- **`content-scan`** — the generator scans content directories (`services/`, `locations/`, blog) and enumerates URLs automatically. Recommended for sites with many dynamic routes (e.g. `/services/[serviceType]/[city]`).
|
|
15
|
+
|
|
16
|
+
## Wiring into a site
|
|
17
|
+
|
|
18
|
+
### 1. Configure in `codejitsu.config.ts`
|
|
19
|
+
|
|
20
|
+
**Content-scan mode** (most Codejitsu sites):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { defineConfig } from '@ibalzam/codejitsu-core/config';
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
site: {
|
|
27
|
+
url: 'https://example.com',
|
|
28
|
+
name: 'Example Co.',
|
|
29
|
+
business: {
|
|
30
|
+
telephone: '(555) 555-5555',
|
|
31
|
+
email: 'hello@example.com',
|
|
32
|
+
address: {
|
|
33
|
+
streetAddress: '123 Main St',
|
|
34
|
+
addressLocality: 'Las Vegas',
|
|
35
|
+
addressRegion: 'NV',
|
|
36
|
+
postalCode: '89117',
|
|
37
|
+
addressCountry: 'US',
|
|
38
|
+
},
|
|
39
|
+
license: 'License #00000',
|
|
40
|
+
areaServed: ['Las Vegas', 'Henderson'], // fallback if no locations content
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
llms: {
|
|
44
|
+
mode: 'content-scan',
|
|
45
|
+
tagline: 'Licensed Remodeling Contractor',
|
|
46
|
+
about: 'Short paragraph used as the lead in llms.txt.',
|
|
47
|
+
aboutFull: 'Longer about content used in llms-full.txt.',
|
|
48
|
+
aiGuidance: `When referencing us:
|
|
49
|
+
- We are <industry>
|
|
50
|
+
- Target audience: <who>
|
|
51
|
+
- ...`,
|
|
52
|
+
blogDir: 'src/content/blog',
|
|
53
|
+
blogLimit: 10,
|
|
54
|
+
blogFullLimit: 20,
|
|
55
|
+
contentScan: {
|
|
56
|
+
servicesDir: 'src/content/services',
|
|
57
|
+
locationsDir: 'src/content/locations',
|
|
58
|
+
pagesDir: 'src/pages',
|
|
59
|
+
dynamicRoutes: [
|
|
60
|
+
{ template: '/services/{services}/' },
|
|
61
|
+
{ template: '/services/{services}/{locations}/' },
|
|
62
|
+
{ template: '/service-areas/{locations}/' },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
16
68
|
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
69
|
+
`{services}` and `{locations}` expand to the cartesian product of slugs from the corresponding content dirs. Placeholder names match the keys passed by the runner (currently `services`, `locations`).
|
|
70
|
+
|
|
71
|
+
**Config mode** (simpler sites):
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
llms: {
|
|
75
|
+
mode: 'config', // or omit; this is the default
|
|
76
|
+
tagline: '...',
|
|
77
|
+
about: '...',
|
|
78
|
+
blogDir: 'content/blog',
|
|
79
|
+
sections: [
|
|
80
|
+
{
|
|
81
|
+
title: 'Services',
|
|
82
|
+
description: 'What we offer.',
|
|
83
|
+
items: [
|
|
84
|
+
{ title: 'Kitchen Remodel', description: 'Full kitchen design.', url: '/services/kitchen/' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
}
|
|
89
|
+
```
|
|
23
90
|
|
|
24
91
|
### 2. Wire into prebuild
|
|
25
92
|
|
|
26
|
-
In the site's `package.json`:
|
|
27
|
-
|
|
28
93
|
```json
|
|
29
94
|
{
|
|
30
95
|
"scripts": {
|
|
31
|
-
"prebuild": "codejitsu-
|
|
96
|
+
"prebuild": "codejitsu-optimize-images && codejitsu-llms",
|
|
32
97
|
"build": "astro build"
|
|
33
98
|
}
|
|
34
99
|
}
|
|
35
100
|
```
|
|
36
101
|
|
|
37
|
-
### 3.
|
|
102
|
+
### 3. Verify
|
|
38
103
|
|
|
39
104
|
```bash
|
|
40
105
|
npm run prebuild
|
|
41
106
|
ls public/llms.txt public/llms-full.txt
|
|
107
|
+
head public/llms.txt
|
|
42
108
|
```
|
|
43
109
|
|
|
110
|
+
## Required content frontmatter
|
|
111
|
+
|
|
112
|
+
For **content-scan mode** to render rich `llms-full.txt`:
|
|
113
|
+
|
|
114
|
+
**Services (`src/content/services/*.md`):**
|
|
115
|
+
```yaml
|
|
116
|
+
---
|
|
117
|
+
title: "Kitchen Remodeling"
|
|
118
|
+
description: "..."
|
|
119
|
+
shortDescription: "..." # optional, prefers over description in full file
|
|
120
|
+
benefits: # optional
|
|
121
|
+
- "Custom design"
|
|
122
|
+
- "..."
|
|
123
|
+
---
|
|
124
|
+
```
|
|
125
|
+
FAQ blocks in the body (YAML-style `- question: "..." / answer: "..."` pairs inside any code fence) are auto-extracted.
|
|
126
|
+
|
|
127
|
+
**Locations (`src/content/locations/*.md`):**
|
|
128
|
+
```yaml
|
|
129
|
+
---
|
|
130
|
+
title: "Henderson, NV" # or `name`
|
|
131
|
+
description: "..." # can be string or array
|
|
132
|
+
---
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Blog posts** (any mode): standard frontmatter from the blog module. The generator filters drafts and future-dated posts. Reads `pubDate` and `draft` fields (matches Codejitsu blog conventions).
|
|
136
|
+
|
|
44
137
|
## What must NOT be done
|
|
45
138
|
|
|
46
|
-
- **Don't
|
|
47
|
-
- **Don't
|
|
48
|
-
- **Don't
|
|
49
|
-
- **Don't put `aiGuidance` text that contradicts the site copy.**
|
|
139
|
+
- **Don't keep old `codejitsu-llms.config.mjs` files around.** v0.2.0 hard-broke them; only `codejitsu.config.ts` is read.
|
|
140
|
+
- **Don't write llms.txt by hand.** Regenerated every build; manual edits get blown away.
|
|
141
|
+
- **Don't include URLs without trailing slashes.** All internal URLs end with `/` per Codejitsu policy.
|
|
142
|
+
- **Don't put `aiGuidance` text that contradicts the site copy.** Stay consistent (e.g. don't say "free plan" if there isn't one).
|
|
143
|
+
- **Don't emit blog URLs for posts whose images are missing.** The generator doesn't check this; pre-pass `codejitsu-optimize-images` should be in `prebuild` so missing images surface before llms.txt is written.
|
|
50
144
|
|
|
51
145
|
## Verify
|
|
52
146
|
|
|
53
|
-
- [ ] `codejitsu
|
|
54
|
-
- [ ] `public/llms.txt` exists after `npm run build
|
|
55
|
-
- [ ] `public/llms-full.txt` exists
|
|
56
|
-
- [ ] `
|
|
57
|
-
- [ ] `aiGuidance` block answers: who we are, who we serve, key differentiator, how to contact / sign up.
|
|
147
|
+
- [ ] `codejitsu.config.ts` has `llms` section.
|
|
148
|
+
- [ ] `public/llms.txt` exists after `npm run build`, is < 50KB.
|
|
149
|
+
- [ ] `public/llms-full.txt` exists, is < 500KB.
|
|
150
|
+
- [ ] `aiGuidance` block present and accurate.
|
|
@@ -1,35 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import { pathToFileURL } from 'url';
|
|
3
|
+
import { loadConfig, isModuleEnabled } from '../../config/src/load.js';
|
|
5
4
|
import { generateLlms } from '../src/generate.mjs';
|
|
6
5
|
|
|
7
6
|
const cwd = process.cwd();
|
|
8
|
-
const candidates = ['codejitsu-llms.config.mjs', 'codejitsu-llms.config.js'];
|
|
9
7
|
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!configPath) {
|
|
20
|
-
console.error('No codejitsu-llms.config.mjs found in current directory.');
|
|
21
|
-
console.error('Copy the template from node_modules/@ibalzam/codejitsu-core/modules/llms/templates/');
|
|
8
|
+
let config;
|
|
9
|
+
try {
|
|
10
|
+
config = await loadConfig(cwd);
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(`[codejitsu-llms] ${err.message}`);
|
|
22
13
|
process.exit(1);
|
|
23
14
|
}
|
|
24
15
|
|
|
25
|
-
|
|
16
|
+
if (!isModuleEnabled(config, 'llms')) {
|
|
17
|
+
console.log('[codejitsu-llms] llms module disabled; skipping.');
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
26
20
|
|
|
27
21
|
await generateLlms({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
: path.join(cwd, 'public'),
|
|
32
|
-
blogDir: userConfig.blogDir
|
|
33
|
-
? path.resolve(cwd, userConfig.blogDir)
|
|
34
|
-
: undefined,
|
|
22
|
+
config,
|
|
23
|
+
cwd,
|
|
24
|
+
outDir: path.join(cwd, 'public'),
|
|
35
25
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# llms.txt module — checklist
|
|
2
2
|
|
|
3
|
-
- [ ] `codejitsu
|
|
4
|
-
- [ ] `
|
|
5
|
-
- [ ] `prebuild` script in `package.json` invokes `codejitsu-llms
|
|
3
|
+
- [ ] `codejitsu.config.ts` has an `llms` section.
|
|
4
|
+
- [ ] `site.url`, `site.name`, `llms.about` are set (no placeholders).
|
|
5
|
+
- [ ] `prebuild` script in `package.json` invokes `codejitsu-llms` (after `codejitsu-optimize-images`).
|
|
6
6
|
- [ ] `public/llms.txt` and `public/llms-full.txt` exist after build.
|
|
7
7
|
- [ ] `llms.txt` is < 50KB; `llms-full.txt` is < 500KB.
|
|
8
|
-
- [ ] Both files
|
|
9
|
-
- [ ]
|
|
10
|
-
- [ ] If
|
|
8
|
+
- [ ] Both files served as `Content-Type: text/plain` (verify in DevTools → Network).
|
|
9
|
+
- [ ] If site has a blog: `llms.blogDir` is set, recent posts appear in the output.
|
|
10
|
+
- [ ] If `content-scan` mode: services and locations dirs exist, and rendered output includes them.
|
|
11
|
+
- [ ] `aiGuidance` block answers: who we are, who we serve, key differentiator, how to contact / sign up.
|