@next/codemod 16.4.0-canary.38 → 16.4.0-canary.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/agents-md.js +8 -9
- package/bin/next-codemod.js +1 -1
- package/bin/upgrade.js +1 -1
- package/lib/__tests__/agents-md-e2e.test.js +43 -47
- package/lib/agents-md.js +23 -29
- package/package.json +1 -1
package/bin/agents-md.js
CHANGED
|
@@ -37,7 +37,7 @@ async function runAgentsMd(options) {
|
|
|
37
37
|
// --version provided: --output is required
|
|
38
38
|
if (!options.output) {
|
|
39
39
|
throw new shared_1.BadInput('When using --version, --output is also required.\n' +
|
|
40
|
-
'Example: npx @next/codemod agents-md --version 15.1.3 --output
|
|
40
|
+
'Example: npx @next/codemod agents-md --version 15.1.3 --output AGENTS.md');
|
|
41
41
|
}
|
|
42
42
|
nextjsVersion = options.version;
|
|
43
43
|
targetFile = options.output;
|
|
@@ -58,7 +58,7 @@ async function runAgentsMd(options) {
|
|
|
58
58
|
nextjsVersion = promptedOptions.nextVersion;
|
|
59
59
|
targetFile = promptedOptions.targetFile;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const agentsMdPath = path_1.default.join(cwd, targetFile);
|
|
62
62
|
// Next.js >= 16.2.0 ships its docs inside the published package. When the
|
|
63
63
|
// installed version matches the requested one, index the bundled docs
|
|
64
64
|
// directly instead of downloading a copy into .next-docs.
|
|
@@ -73,8 +73,8 @@ async function runAgentsMd(options) {
|
|
|
73
73
|
let sizeBefore = 0;
|
|
74
74
|
let isNewFile = true;
|
|
75
75
|
let existingContent = '';
|
|
76
|
-
if (fs_1.default.existsSync(
|
|
77
|
-
existingContent = fs_1.default.readFileSync(
|
|
76
|
+
if (fs_1.default.existsSync(agentsMdPath)) {
|
|
77
|
+
existingContent = fs_1.default.readFileSync(agentsMdPath, 'utf-8');
|
|
78
78
|
sizeBefore = Buffer.byteLength(existingContent, 'utf-8');
|
|
79
79
|
isNewFile = false;
|
|
80
80
|
}
|
|
@@ -94,13 +94,13 @@ async function runAgentsMd(options) {
|
|
|
94
94
|
}
|
|
95
95
|
const docFiles = (0, agents_md_1.collectDocFiles)(docsPath);
|
|
96
96
|
const sections = (0, agents_md_1.buildDocTree)(docFiles);
|
|
97
|
-
const indexContent = (0, agents_md_1.
|
|
97
|
+
const indexContent = (0, agents_md_1.generateAgentsMdIndex)({
|
|
98
98
|
docsPath: docsLinkPath,
|
|
99
99
|
sections,
|
|
100
100
|
outputFile: targetFile,
|
|
101
101
|
});
|
|
102
|
-
const newContent = (0, agents_md_1.
|
|
103
|
-
fs_1.default.writeFileSync(
|
|
102
|
+
const newContent = (0, agents_md_1.injectIntoAgentsMd)(existingContent, indexContent);
|
|
103
|
+
fs_1.default.writeFileSync(agentsMdPath, newContent, 'utf-8');
|
|
104
104
|
const sizeAfter = Buffer.byteLength(newContent, 'utf-8');
|
|
105
105
|
// .next-docs only exists on the download path; bundled docs live in
|
|
106
106
|
// node_modules, which is already ignored.
|
|
@@ -136,7 +136,6 @@ async function promptForOptions(cwd) {
|
|
|
136
136
|
name: 'targetFile',
|
|
137
137
|
message: 'Target markdown file',
|
|
138
138
|
choices: [
|
|
139
|
-
{ title: 'CLAUDE.md', value: 'CLAUDE.md' },
|
|
140
139
|
{ title: 'AGENTS.md', value: 'AGENTS.md' },
|
|
141
140
|
{ title: 'Custom...', value: '__custom__' },
|
|
142
141
|
],
|
|
@@ -154,7 +153,7 @@ async function promptForOptions(cwd) {
|
|
|
154
153
|
type: 'text',
|
|
155
154
|
name: 'customFile',
|
|
156
155
|
message: 'Enter custom file path',
|
|
157
|
-
initial: '
|
|
156
|
+
initial: 'AGENTS.md',
|
|
158
157
|
validate: (value) => value.trim() ? true : 'Please enter a file path',
|
|
159
158
|
}, { onCancel: utils_1.onCancel });
|
|
160
159
|
if (customResponse.customFile === undefined) {
|
package/bin/next-codemod.js
CHANGED
|
@@ -63,7 +63,7 @@ program
|
|
|
63
63
|
.command('agents-md')
|
|
64
64
|
.description('Generate Next.js documentation index for AI coding agents (Claude, Cursor, etc.).')
|
|
65
65
|
.option('--version <version>', 'Next.js version (auto-detected if not provided)')
|
|
66
|
-
.option('--output <file>', 'Target file path (e.g.,
|
|
66
|
+
.option('--output <file>', 'Target file path (e.g., AGENTS.md)')
|
|
67
67
|
.action(async (options) => {
|
|
68
68
|
try {
|
|
69
69
|
await (0, agents_md_1.runAgentsMd)(options);
|
package/bin/upgrade.js
CHANGED
|
@@ -394,7 +394,7 @@ async function runUpgrade(revision, options) {
|
|
|
394
394
|
}
|
|
395
395
|
try {
|
|
396
396
|
if ((0, agents_md_1.refreshAgentRulesBlock)(cwd) === 'refreshed') {
|
|
397
|
-
console.log(`${picocolors_1.default.green('✔')} Refreshed the managed agent-rules block in AGENTS.md
|
|
397
|
+
console.log(`${picocolors_1.default.green('✔')} Refreshed the managed agent-rules block in AGENTS.md to match the upgraded Next.js.`);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
catch {
|
|
@@ -11,7 +11,7 @@ const { getNextjsVersion } = require('../../lib/agents-md')
|
|
|
11
11
|
* TRUE E2E TESTS
|
|
12
12
|
* These tests invoke the actual CLI entry point (runAgentsMd),
|
|
13
13
|
* simulating what happens when a user runs:
|
|
14
|
-
* npx @next/codemod agents-md --version 15.0.0 --output
|
|
14
|
+
* npx @next/codemod agents-md --version 15.0.0 --output AGENTS.md
|
|
15
15
|
*/
|
|
16
16
|
describe('agents-md e2e (CLI invocation)', () => {
|
|
17
17
|
let testProjectDir
|
|
@@ -45,7 +45,7 @@ describe('agents-md e2e (CLI invocation)', () => {
|
|
|
45
45
|
}
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
it('creates
|
|
48
|
+
it('creates AGENTS.md and .next-docs directory when run with --version and --output', async () => {
|
|
49
49
|
// Create a minimal package.json (not required, but realistic)
|
|
50
50
|
const packageJson = {
|
|
51
51
|
name: 'test-project',
|
|
@@ -67,7 +67,7 @@ describe('agents-md e2e (CLI invocation)', () => {
|
|
|
67
67
|
// Run the actual CLI command
|
|
68
68
|
await runAgentsMd({
|
|
69
69
|
version: '15.0.0',
|
|
70
|
-
output: '
|
|
70
|
+
output: 'AGENTS.md',
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
// Verify .next-docs directory was created and populated
|
|
@@ -83,20 +83,20 @@ describe('agents-md e2e (CLI invocation)', () => {
|
|
|
83
83
|
)
|
|
84
84
|
expect(mdxFiles.length).toBeGreaterThan(0)
|
|
85
85
|
|
|
86
|
-
// Verify
|
|
87
|
-
const
|
|
88
|
-
expect(fs.existsSync(
|
|
86
|
+
// Verify AGENTS.md was created
|
|
87
|
+
const agentsMdPath = path.join(testProjectDir, 'AGENTS.md')
|
|
88
|
+
expect(fs.existsSync(agentsMdPath)).toBe(true)
|
|
89
89
|
|
|
90
|
-
const
|
|
90
|
+
const agentsMdContent = fs.readFileSync(agentsMdPath, 'utf-8')
|
|
91
91
|
|
|
92
92
|
// Verify content structure
|
|
93
|
-
expect(
|
|
94
|
-
expect(
|
|
95
|
-
expect(
|
|
96
|
-
expect(
|
|
93
|
+
expect(agentsMdContent).toContain('<!-- NEXT-AGENTS-MD-START -->')
|
|
94
|
+
expect(agentsMdContent).toContain('<!-- NEXT-AGENTS-MD-END -->')
|
|
95
|
+
expect(agentsMdContent).toContain('[Next.js Docs Index]')
|
|
96
|
+
expect(agentsMdContent).toContain('root: ./.next-docs')
|
|
97
97
|
|
|
98
98
|
// Verify paths are normalized to forward slashes (cross-platform)
|
|
99
|
-
const lines =
|
|
99
|
+
const lines = agentsMdContent.split('|')
|
|
100
100
|
const pathLines = lines.filter((line) => line.includes(':'))
|
|
101
101
|
pathLines.forEach((line) => {
|
|
102
102
|
// Should not contain Windows backslashes in the output
|
|
@@ -117,19 +117,19 @@ describe('agents-md e2e (CLI invocation)', () => {
|
|
|
117
117
|
const output = consoleOutput.join('\n')
|
|
118
118
|
expect(output).toContain('Downloading Next.js')
|
|
119
119
|
expect(output).toContain('15.0.0')
|
|
120
|
-
expect(output).toContain('
|
|
120
|
+
expect(output).toContain('AGENTS.md')
|
|
121
121
|
} finally {
|
|
122
122
|
// Restore original directory
|
|
123
123
|
process.chdir(originalCwd)
|
|
124
124
|
}
|
|
125
125
|
})
|
|
126
126
|
|
|
127
|
-
it('updates existing
|
|
127
|
+
it('updates existing AGENTS.md without losing content', async () => {
|
|
128
128
|
const originalCwd = process.cwd()
|
|
129
129
|
process.chdir(testProjectDir)
|
|
130
130
|
|
|
131
131
|
try {
|
|
132
|
-
// Create existing
|
|
132
|
+
// Create existing AGENTS.md with custom content
|
|
133
133
|
const existingContent = `# My Project
|
|
134
134
|
|
|
135
135
|
This is my project documentation.
|
|
@@ -138,31 +138,28 @@ This is my project documentation.
|
|
|
138
138
|
- Feature 1
|
|
139
139
|
- Feature 2
|
|
140
140
|
`
|
|
141
|
-
fs.writeFileSync(
|
|
142
|
-
path.join(testProjectDir, 'CLAUDE.md'),
|
|
143
|
-
existingContent
|
|
144
|
-
)
|
|
141
|
+
fs.writeFileSync(path.join(testProjectDir, 'AGENTS.md'), existingContent)
|
|
145
142
|
|
|
146
143
|
// Run CLI
|
|
147
144
|
await runAgentsMd({
|
|
148
145
|
version: '15.0.0',
|
|
149
|
-
output: '
|
|
146
|
+
output: 'AGENTS.md',
|
|
150
147
|
})
|
|
151
148
|
|
|
152
149
|
// Verify file was updated, not replaced
|
|
153
|
-
const
|
|
154
|
-
path.join(testProjectDir, '
|
|
150
|
+
const agentsMdContent = fs.readFileSync(
|
|
151
|
+
path.join(testProjectDir, 'AGENTS.md'),
|
|
155
152
|
'utf-8'
|
|
156
153
|
)
|
|
157
154
|
|
|
158
155
|
// Original content should still be there
|
|
159
|
-
expect(
|
|
160
|
-
expect(
|
|
161
|
-
expect(
|
|
156
|
+
expect(agentsMdContent).toContain('# My Project')
|
|
157
|
+
expect(agentsMdContent).toContain('This is my project documentation.')
|
|
158
|
+
expect(agentsMdContent).toContain('## Features')
|
|
162
159
|
|
|
163
160
|
// New index should be injected
|
|
164
|
-
expect(
|
|
165
|
-
expect(
|
|
161
|
+
expect(agentsMdContent).toContain('<!-- NEXT-AGENTS-MD-START -->')
|
|
162
|
+
expect(agentsMdContent).toContain('[Next.js Docs Index]')
|
|
166
163
|
} finally {
|
|
167
164
|
process.chdir(originalCwd)
|
|
168
165
|
}
|
|
@@ -179,9 +176,8 @@ This is my project documentation.
|
|
|
179
176
|
output: 'AGENTS.md',
|
|
180
177
|
})
|
|
181
178
|
|
|
182
|
-
// Verify AGENTS.md was created
|
|
179
|
+
// Verify AGENTS.md was created
|
|
183
180
|
expect(fs.existsSync(path.join(testProjectDir, 'AGENTS.md'))).toBe(true)
|
|
184
|
-
expect(fs.existsSync(path.join(testProjectDir, 'CLAUDE.md'))).toBe(false)
|
|
185
181
|
|
|
186
182
|
const agentsMdContent = fs.readFileSync(
|
|
187
183
|
path.join(testProjectDir, 'AGENTS.md'),
|
|
@@ -216,11 +212,11 @@ This is my project documentation.
|
|
|
216
212
|
// Run from subdirectory - should create files in CWD (subdirectory)
|
|
217
213
|
await runAgentsMd({
|
|
218
214
|
version: '15.0.0',
|
|
219
|
-
output: '
|
|
215
|
+
output: 'AGENTS.md',
|
|
220
216
|
})
|
|
221
217
|
|
|
222
218
|
// Verify files created in subdirectory
|
|
223
|
-
expect(fs.existsSync(path.join(subDir, '
|
|
219
|
+
expect(fs.existsSync(path.join(subDir, 'AGENTS.md'))).toBe(true)
|
|
224
220
|
expect(fs.existsSync(path.join(subDir, '.next-docs'))).toBe(true)
|
|
225
221
|
} finally {
|
|
226
222
|
process.chdir(originalCwd)
|
|
@@ -234,20 +230,20 @@ This is my project documentation.
|
|
|
234
230
|
try {
|
|
235
231
|
await runAgentsMd({
|
|
236
232
|
version: '15.0.0',
|
|
237
|
-
output: '
|
|
233
|
+
output: 'AGENTS.md',
|
|
238
234
|
})
|
|
239
235
|
|
|
240
|
-
const
|
|
241
|
-
path.join(testProjectDir, '
|
|
236
|
+
const agentsMdContent = fs.readFileSync(
|
|
237
|
+
path.join(testProjectDir, 'AGENTS.md'),
|
|
242
238
|
'utf-8'
|
|
243
239
|
)
|
|
244
240
|
|
|
245
241
|
// Extract the index content between markers
|
|
246
242
|
const startMarker = '<!-- NEXT-AGENTS-MD-START -->'
|
|
247
243
|
const endMarker = '<!-- NEXT-AGENTS-MD-END -->'
|
|
248
|
-
const startIdx =
|
|
249
|
-
const endIdx =
|
|
250
|
-
const indexContent =
|
|
244
|
+
const startIdx = agentsMdContent.indexOf(startMarker) + startMarker.length
|
|
245
|
+
const endIdx = agentsMdContent.indexOf(endMarker)
|
|
246
|
+
const indexContent = agentsMdContent.slice(startIdx, endIdx)
|
|
251
247
|
|
|
252
248
|
// Parse the index (format: "dir:{file1,file2}|dir2:{file3}")
|
|
253
249
|
const sections = indexContent.split('|').filter((s) => s.includes(':'))
|
|
@@ -276,7 +272,7 @@ This is my project documentation.
|
|
|
276
272
|
// Use a known stable version
|
|
277
273
|
await runAgentsMd({
|
|
278
274
|
version: '14.2.0',
|
|
279
|
-
output: '
|
|
275
|
+
output: 'AGENTS.md',
|
|
280
276
|
})
|
|
281
277
|
|
|
282
278
|
// Verify docs were downloaded
|
|
@@ -331,7 +327,7 @@ This is my project documentation.
|
|
|
331
327
|
process.chdir(testProjectDir)
|
|
332
328
|
|
|
333
329
|
try {
|
|
334
|
-
await runAgentsMd({ output: '
|
|
330
|
+
await runAgentsMd({ output: 'AGENTS.md' })
|
|
335
331
|
|
|
336
332
|
// No .next-docs copy and no .gitignore entry for it
|
|
337
333
|
expect(fs.existsSync(path.join(testProjectDir, '.next-docs'))).toBe(
|
|
@@ -341,14 +337,14 @@ This is my project documentation.
|
|
|
341
337
|
false
|
|
342
338
|
)
|
|
343
339
|
|
|
344
|
-
const
|
|
345
|
-
path.join(testProjectDir, '
|
|
340
|
+
const agentsMdContent = fs.readFileSync(
|
|
341
|
+
path.join(testProjectDir, 'AGENTS.md'),
|
|
346
342
|
'utf-8'
|
|
347
343
|
)
|
|
348
|
-
expect(
|
|
344
|
+
expect(agentsMdContent).toContain(
|
|
349
345
|
'root: ./node_modules/next/dist/docs'
|
|
350
346
|
)
|
|
351
|
-
expect(
|
|
347
|
+
expect(agentsMdContent).toContain('01-installation.md')
|
|
352
348
|
|
|
353
349
|
const output = consoleOutput.join('\n')
|
|
354
350
|
expect(output).toContain('bundled with Next.js')
|
|
@@ -390,17 +386,17 @@ This is my project documentation.
|
|
|
390
386
|
process.chdir(testProjectDir)
|
|
391
387
|
|
|
392
388
|
try {
|
|
393
|
-
await runAgentsMd({ version: '15.0.0', output: '
|
|
389
|
+
await runAgentsMd({ version: '15.0.0', output: 'AGENTS.md' })
|
|
394
390
|
|
|
395
391
|
expect(fs.existsSync(path.join(testProjectDir, '.next-docs'))).toBe(
|
|
396
392
|
true
|
|
397
393
|
)
|
|
398
394
|
|
|
399
|
-
const
|
|
400
|
-
path.join(testProjectDir, '
|
|
395
|
+
const agentsMdContent = fs.readFileSync(
|
|
396
|
+
path.join(testProjectDir, 'AGENTS.md'),
|
|
401
397
|
'utf-8'
|
|
402
398
|
)
|
|
403
|
-
expect(
|
|
399
|
+
expect(agentsMdContent).toContain('root: ./.next-docs')
|
|
404
400
|
|
|
405
401
|
const output = consoleOutput.join('\n')
|
|
406
402
|
expect(output).toContain('Downloading')
|
package/lib/agents-md.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* agents-md: Generate Next.js documentation index for AI coding agents.
|
|
4
4
|
*
|
|
5
5
|
* Downloads docs from GitHub via git sparse-checkout, builds a compact
|
|
6
|
-
* index of all doc files, and injects it into
|
|
6
|
+
* index of all doc files, and injects it into AGENTS.md.
|
|
7
7
|
*/
|
|
8
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -16,8 +16,8 @@ exports.getBundledDocsLinkPath = getBundledDocsLinkPath;
|
|
|
16
16
|
exports.pullDocs = pullDocs;
|
|
17
17
|
exports.collectDocFiles = collectDocFiles;
|
|
18
18
|
exports.buildDocTree = buildDocTree;
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
19
|
+
exports.generateAgentsMdIndex = generateAgentsMdIndex;
|
|
20
|
+
exports.injectIntoAgentsMd = injectIntoAgentsMd;
|
|
21
21
|
exports.ensureGitignoreEntry = ensureGitignoreEntry;
|
|
22
22
|
const execa_1 = __importDefault(require("execa"));
|
|
23
23
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -26,8 +26,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
26
26
|
const AGENT_RULES_START_MARKER = '<!-- BEGIN:nextjs-agent-rules -->';
|
|
27
27
|
/**
|
|
28
28
|
* After an upgrade, refresh the managed agent-rules block in
|
|
29
|
-
* AGENTS.md
|
|
30
|
-
* that is now installed.
|
|
29
|
+
* AGENTS.md so its content matches the Next.js version that is now installed.
|
|
31
30
|
*
|
|
32
31
|
* Delegates to the installed package's own generator
|
|
33
32
|
* (`next/dist/server/lib/generate-agent-files`), so the block text is
|
|
@@ -39,17 +38,14 @@ const AGENT_RULES_START_MARKER = '<!-- BEGIN:nextjs-agent-rules -->';
|
|
|
39
38
|
* (< 16.3).
|
|
40
39
|
*/
|
|
41
40
|
function refreshAgentRulesBlock(cwd) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
if (!hostsBlock)
|
|
41
|
+
let agentsMdContent;
|
|
42
|
+
try {
|
|
43
|
+
agentsMdContent = fs_1.default.readFileSync(path_1.default.join(cwd, 'AGENTS.md'), 'utf-8');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return 'skipped';
|
|
47
|
+
}
|
|
48
|
+
if (!agentsMdContent.includes(AGENT_RULES_START_MARKER))
|
|
53
49
|
return 'skipped';
|
|
54
50
|
let writeAgentFiles;
|
|
55
51
|
try {
|
|
@@ -62,9 +58,7 @@ function refreshAgentRulesBlock(cwd) {
|
|
|
62
58
|
return 'skipped';
|
|
63
59
|
}
|
|
64
60
|
const result = writeAgentFiles(cwd);
|
|
65
|
-
return result.agentsMd === 'updated'
|
|
66
|
-
? 'refreshed'
|
|
67
|
-
: 'current';
|
|
61
|
+
return result.agentsMd === 'updated' ? 'refreshed' : 'current';
|
|
68
62
|
}
|
|
69
63
|
function getNextjsVersion(cwd) {
|
|
70
64
|
try {
|
|
@@ -263,13 +257,13 @@ function buildDocTree(files) {
|
|
|
263
257
|
}
|
|
264
258
|
return sortedSections;
|
|
265
259
|
}
|
|
266
|
-
function
|
|
260
|
+
function generateAgentsMdIndex(data) {
|
|
267
261
|
const { docsPath, sections, outputFile } = data;
|
|
268
262
|
const parts = [];
|
|
269
263
|
parts.push('[Next.js Docs Index]');
|
|
270
264
|
parts.push(`root: ${docsPath}`);
|
|
271
265
|
parts.push('STOP. What you remember about Next.js is WRONG for this project. Always search docs and read before any task.');
|
|
272
|
-
const targetFile = outputFile || '
|
|
266
|
+
const targetFile = outputFile || 'AGENTS.md';
|
|
273
267
|
parts.push(`If docs missing, run this command first: npx @next/codemod agents-md --output ${targetFile}`);
|
|
274
268
|
const allFiles = collectAllFilesFromSections(sections);
|
|
275
269
|
const grouped = groupByDirectory(allFiles);
|
|
@@ -312,17 +306,17 @@ function hasExistingIndex(content) {
|
|
|
312
306
|
function wrapWithMarkers(content) {
|
|
313
307
|
return `${START_MARKER}${content}${END_MARKER}`;
|
|
314
308
|
}
|
|
315
|
-
function
|
|
309
|
+
function injectIntoAgentsMd(agentsMdContent, indexContent) {
|
|
316
310
|
const wrappedContent = wrapWithMarkers(indexContent);
|
|
317
|
-
if (hasExistingIndex(
|
|
318
|
-
const startIdx =
|
|
319
|
-
const endIdx =
|
|
320
|
-
return (
|
|
311
|
+
if (hasExistingIndex(agentsMdContent)) {
|
|
312
|
+
const startIdx = agentsMdContent.indexOf(START_MARKER);
|
|
313
|
+
const endIdx = agentsMdContent.indexOf(END_MARKER) + END_MARKER.length;
|
|
314
|
+
return (agentsMdContent.slice(0, startIdx) +
|
|
321
315
|
wrappedContent +
|
|
322
|
-
|
|
316
|
+
agentsMdContent.slice(endIdx));
|
|
323
317
|
}
|
|
324
|
-
const separator =
|
|
325
|
-
return
|
|
318
|
+
const separator = agentsMdContent.endsWith('\n') ? '\n' : '\n\n';
|
|
319
|
+
return agentsMdContent + separator + wrappedContent + '\n';
|
|
326
320
|
}
|
|
327
321
|
const GITIGNORE_ENTRY = '.next-docs/';
|
|
328
322
|
function ensureGitignoreEntry(cwd) {
|