novelforge-agent 0.1.1 → 0.3.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 +45 -18
- package/dist/src/cli/index.js +81 -4
- package/dist/src/core/bibleStore.js +36 -0
- package/dist/src/core/characterStore.js +74 -0
- package/dist/src/core/contextBuilder.js +76 -1
- package/dist/src/core/fileNames.js +4 -0
- package/dist/src/core/index.js +4 -0
- package/dist/src/core/projectDiscovery.js +1 -0
- package/dist/src/core/projectOps.js +193 -0
- package/dist/src/core/projectStore.js +15 -1
- package/dist/src/core/prompts/en-US.js +247 -16
- package/dist/src/core/prompts/zh-CN.js +246 -15
- package/dist/src/core/retrieval/index.js +8 -0
- package/dist/src/core/schemas.js +121 -1
- package/dist/src/core/steps/architecture.js +7 -1
- package/dist/src/core/steps/architectureExtension.js +72 -0
- package/dist/src/core/steps/chapter.js +11 -1
- package/dist/src/core/steps/chapterReview.js +26 -1
- package/dist/src/core/steps/chapterRevision.js +17 -0
- package/dist/src/core/steps/index.js +4 -0
- package/dist/src/core/steps/memoryCard.js +26 -1
- package/dist/src/core/steps/novelMetadata.js +4 -2
- package/dist/src/core/steps/storyBible.js +1 -1
- package/dist/src/core/steps/styleGuide.js +12 -0
- package/dist/src/core/threadStore.js +150 -0
- package/dist/src/core/workflow.js +5 -3
- package/dist/src/mcp/tools.js +228 -20
- package/package.json +5 -1
- package/src/cli/index.ts +84 -3
- package/src/core/bibleStore.ts +57 -0
- package/src/core/characterStore.ts +93 -0
- package/src/core/contextBuilder.ts +74 -4
- package/src/core/fileNames.ts +5 -0
- package/src/core/index.ts +4 -0
- package/src/core/projectDiscovery.ts +2 -0
- package/src/core/projectOps.ts +251 -0
- package/src/core/projectStore.ts +19 -1
- package/src/core/prompts/en-US.ts +258 -25
- package/src/core/prompts/types.ts +4 -1
- package/src/core/prompts/zh-CN.ts +250 -17
- package/src/core/retrieval/index.ts +10 -0
- package/src/core/schemas.ts +133 -1
- package/src/core/steps/architecture.ts +7 -1
- package/src/core/steps/architectureExtension.ts +88 -0
- package/src/core/steps/chapter.ts +11 -1
- package/src/core/steps/chapterReview.ts +28 -1
- package/src/core/steps/chapterRevision.ts +18 -0
- package/src/core/steps/index.ts +4 -0
- package/src/core/steps/memoryCard.ts +27 -1
- package/src/core/steps/novelMetadata.ts +4 -2
- package/src/core/steps/storyBible.ts +1 -1
- package/src/core/steps/styleGuide.ts +13 -0
- package/src/core/threadStore.ts +173 -0
- package/src/core/types.ts +134 -1
- package/src/core/workflow.ts +5 -3
- package/src/mcp/tools.ts +351 -21
package/src/mcp/tools.ts
CHANGED
|
@@ -1,18 +1,47 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
3
6
|
import {
|
|
7
|
+
amendStoryBible,
|
|
8
|
+
assertProjectPath,
|
|
4
9
|
buildContext,
|
|
5
|
-
chapterFileName,
|
|
6
10
|
createProject,
|
|
11
|
+
deleteChapter,
|
|
12
|
+
forkProject,
|
|
7
13
|
getNextStep,
|
|
8
14
|
getProjectStatus,
|
|
9
15
|
listProjects,
|
|
16
|
+
listStoryBibleVersions,
|
|
17
|
+
loadState,
|
|
18
|
+
loadThreads,
|
|
19
|
+
redoStep,
|
|
10
20
|
requestSideTrack,
|
|
11
21
|
retrieve,
|
|
12
|
-
saveMarkdownFile,
|
|
13
22
|
submitStepResult,
|
|
23
|
+
updateThread,
|
|
14
24
|
} from '../core/index.js';
|
|
15
25
|
|
|
26
|
+
function packageVersion(): string {
|
|
27
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
while (true) {
|
|
29
|
+
try {
|
|
30
|
+
const raw = readFileSync(join(dir, 'package.json'), 'utf8');
|
|
31
|
+
const parsed = JSON.parse(raw) as { version?: unknown };
|
|
32
|
+
if (typeof parsed.version === 'string' && parsed.version) return parsed.version;
|
|
33
|
+
} catch {
|
|
34
|
+
// keep walking upward until the package root is found
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const parent = dirname(dir);
|
|
38
|
+
if (parent === dir) return '0.0.0';
|
|
39
|
+
dir = parent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const MCP_SERVER_VERSION = packageVersion();
|
|
44
|
+
|
|
16
45
|
export interface CreateNovelAgentServerOptions {
|
|
17
46
|
workspaceRoot: string;
|
|
18
47
|
}
|
|
@@ -27,9 +56,19 @@ function textResult(value: unknown) {
|
|
|
27
56
|
}
|
|
28
57
|
|
|
29
58
|
export function createNovelAgentServer(options: CreateNovelAgentServerOptions): McpServer {
|
|
59
|
+
function checkedProjectPath(projectPath: string): string {
|
|
60
|
+
assertProjectPath(options.workspaceRoot, projectPath);
|
|
61
|
+
return projectPath;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function checkedOutputDir(outputDir: string): string {
|
|
65
|
+
assertProjectPath(options.workspaceRoot, resolve(options.workspaceRoot, outputDir));
|
|
66
|
+
return outputDir;
|
|
67
|
+
}
|
|
68
|
+
|
|
30
69
|
const server = new McpServer({
|
|
31
70
|
name: 'novelforge-agent',
|
|
32
|
-
version:
|
|
71
|
+
version: MCP_SERVER_VERSION,
|
|
33
72
|
});
|
|
34
73
|
|
|
35
74
|
server.tool(
|
|
@@ -39,15 +78,17 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
39
78
|
prompt: z.string().min(1),
|
|
40
79
|
language: z.enum(['zh-CN', 'en-US']).default('zh-CN'),
|
|
41
80
|
outputDir: z.string().default('novels'),
|
|
42
|
-
targetChapters: z.number().int().positive().default(
|
|
81
|
+
targetChapters: z.number().int().positive().default(5),
|
|
82
|
+
plannedTotalChapters: z.number().int().positive().default(12),
|
|
43
83
|
},
|
|
44
|
-
async ({ prompt, language, outputDir, targetChapters }) => {
|
|
84
|
+
async ({ prompt, language, outputDir, targetChapters, plannedTotalChapters }) => {
|
|
45
85
|
const result = await createProject({
|
|
46
86
|
workspaceRoot: options.workspaceRoot,
|
|
47
87
|
prompt,
|
|
48
88
|
language,
|
|
49
89
|
outputDir,
|
|
50
90
|
targetChapters,
|
|
91
|
+
plannedTotalChapters,
|
|
51
92
|
});
|
|
52
93
|
return textResult({ state: result.state, next: await getNextStep(result.state.projectPath) });
|
|
53
94
|
}
|
|
@@ -59,21 +100,22 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
59
100
|
{
|
|
60
101
|
outputDir: z.string().default('novels'),
|
|
61
102
|
},
|
|
62
|
-
async ({ outputDir }) =>
|
|
103
|
+
async ({ outputDir }) =>
|
|
104
|
+
textResult(await listProjects({ workspaceRoot: options.workspaceRoot, outputDir: checkedOutputDir(outputDir) }))
|
|
63
105
|
);
|
|
64
106
|
|
|
65
107
|
server.tool(
|
|
66
108
|
'get_project_status',
|
|
67
109
|
'Return a compact, one-screen summary of a project: current step, chapters written, open threads, latest review verdict, completion state.',
|
|
68
110
|
{ projectPath: z.string().min(1) },
|
|
69
|
-
async ({ projectPath }) => textResult(await getProjectStatus(projectPath))
|
|
111
|
+
async ({ projectPath }) => textResult(await getProjectStatus(checkedProjectPath(projectPath)))
|
|
70
112
|
);
|
|
71
113
|
|
|
72
114
|
server.tool(
|
|
73
115
|
'get_next_step',
|
|
74
116
|
'Return the next required generation step for a novel project.',
|
|
75
117
|
{ projectPath: z.string().min(1) },
|
|
76
|
-
async ({ projectPath }) => textResult(await getNextStep(projectPath))
|
|
118
|
+
async ({ projectPath }) => textResult(await getNextStep(checkedProjectPath(projectPath)))
|
|
77
119
|
);
|
|
78
120
|
|
|
79
121
|
server.tool(
|
|
@@ -84,7 +126,9 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
84
126
|
step: z.enum([
|
|
85
127
|
'novel_metadata',
|
|
86
128
|
'story_bible',
|
|
129
|
+
'style_guide',
|
|
87
130
|
'architecture',
|
|
131
|
+
'architecture_extension',
|
|
88
132
|
'chapter',
|
|
89
133
|
'memory_card',
|
|
90
134
|
'continuity_review',
|
|
@@ -95,7 +139,8 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
95
139
|
]),
|
|
96
140
|
content: z.string(),
|
|
97
141
|
},
|
|
98
|
-
async ({ projectPath, step, content }) =>
|
|
142
|
+
async ({ projectPath, step, content }) =>
|
|
143
|
+
textResult(await submitStepResult({ projectPath: checkedProjectPath(projectPath), step, content }))
|
|
99
144
|
);
|
|
100
145
|
|
|
101
146
|
server.tool(
|
|
@@ -105,6 +150,8 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
105
150
|
projectPath: z.string().min(1),
|
|
106
151
|
purpose: z.enum([
|
|
107
152
|
'chapter_generation',
|
|
153
|
+
'style_guide',
|
|
154
|
+
'architecture_extension',
|
|
108
155
|
'memory_extraction',
|
|
109
156
|
'continuity_review',
|
|
110
157
|
'revision',
|
|
@@ -117,7 +164,7 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
117
164
|
},
|
|
118
165
|
async ({ projectPath, purpose, chapterNumber, start, end }) =>
|
|
119
166
|
textResult(await buildContext({
|
|
120
|
-
projectPath,
|
|
167
|
+
projectPath: checkedProjectPath(projectPath),
|
|
121
168
|
purpose,
|
|
122
169
|
chapterNumber,
|
|
123
170
|
range: start && end ? { start, end } : undefined,
|
|
@@ -126,7 +173,7 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
126
173
|
|
|
127
174
|
server.tool(
|
|
128
175
|
'save_chapter',
|
|
129
|
-
'
|
|
176
|
+
'Submit a generated chapter Markdown draft through the workflow state machine. This requires currentStep="chapter" and advances to chapter_review.',
|
|
130
177
|
{
|
|
131
178
|
projectPath: z.string().min(1),
|
|
132
179
|
chapterNumber: z.number().int().positive(),
|
|
@@ -134,9 +181,18 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
134
181
|
content: z.string().min(1),
|
|
135
182
|
},
|
|
136
183
|
async ({ projectPath, chapterNumber, title, content }) => {
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
184
|
+
const checked = checkedProjectPath(projectPath);
|
|
185
|
+
const state = await loadState(checked);
|
|
186
|
+
if (state.currentStep !== 'chapter' || state.currentChapter !== chapterNumber) {
|
|
187
|
+
throw new Error(
|
|
188
|
+
`save_chapter requires currentStep="chapter" and currentChapter=${chapterNumber}; got currentStep="${state.currentStep}", currentChapter=${state.currentChapter}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
return textResult(await submitStepResult({
|
|
192
|
+
projectPath: checked,
|
|
193
|
+
step: 'chapter',
|
|
194
|
+
content: `# ${title}\n\n${content}`,
|
|
195
|
+
}));
|
|
140
196
|
}
|
|
141
197
|
);
|
|
142
198
|
|
|
@@ -149,8 +205,8 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
149
205
|
},
|
|
150
206
|
async ({ projectPath, chapterNumber }) =>
|
|
151
207
|
textResult({
|
|
152
|
-
context: await buildContext({ projectPath, purpose: 'chapter_generation', chapterNumber }),
|
|
153
|
-
hint: 'Persist the result via
|
|
208
|
+
context: await buildContext({ projectPath: checkedProjectPath(projectPath), purpose: 'chapter_generation', chapterNumber }),
|
|
209
|
+
hint: 'Persist the result via submit_step_result(step="chapter") when the workflow currentStep is "chapter"; the workflow then requires chapter_review before memory_card.',
|
|
154
210
|
})
|
|
155
211
|
);
|
|
156
212
|
|
|
@@ -163,7 +219,7 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
163
219
|
},
|
|
164
220
|
async ({ projectPath, chapterNumber }) =>
|
|
165
221
|
textResult({
|
|
166
|
-
context: await buildContext({ projectPath, purpose: 'memory_extraction', chapterNumber }),
|
|
222
|
+
context: await buildContext({ projectPath: checkedProjectPath(projectPath), purpose: 'memory_extraction', chapterNumber }),
|
|
167
223
|
hint: 'Submit the extracted memory card via submit_step_result with step="memory_card" when the workflow currentStep matches.',
|
|
168
224
|
})
|
|
169
225
|
);
|
|
@@ -176,7 +232,7 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
176
232
|
chapterNumber: z.number().int().positive(),
|
|
177
233
|
},
|
|
178
234
|
async ({ projectPath, chapterNumber }) =>
|
|
179
|
-
textResult(await requestSideTrack({ projectPath, step: 'chapter_review', chapterNumber }))
|
|
235
|
+
textResult(await requestSideTrack({ projectPath: checkedProjectPath(projectPath), step: 'chapter_review', chapterNumber }))
|
|
180
236
|
);
|
|
181
237
|
|
|
182
238
|
server.tool(
|
|
@@ -188,7 +244,7 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
188
244
|
feedback: z.string().optional(),
|
|
189
245
|
},
|
|
190
246
|
async ({ projectPath, chapterNumber, feedback }) =>
|
|
191
|
-
textResult(await requestSideTrack({ projectPath, step: 'chapter_revision', chapterNumber, feedback }))
|
|
247
|
+
textResult(await requestSideTrack({ projectPath: checkedProjectPath(projectPath), step: 'chapter_revision', chapterNumber, feedback }))
|
|
192
248
|
);
|
|
193
249
|
|
|
194
250
|
server.tool(
|
|
@@ -204,7 +260,7 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
204
260
|
},
|
|
205
261
|
async ({ projectPath, query, topK, types, chapterStart, chapterEnd }) => {
|
|
206
262
|
const chapterRange = chapterStart && chapterEnd ? { start: chapterStart, end: chapterEnd } : undefined;
|
|
207
|
-
const hits = await retrieve(projectPath, query, { topK, types, chapterRange });
|
|
263
|
+
const hits = await retrieve(checkedProjectPath(projectPath), query, { topK, types, chapterRange });
|
|
208
264
|
return textResult({ query, hits });
|
|
209
265
|
}
|
|
210
266
|
);
|
|
@@ -219,9 +275,283 @@ export function createNovelAgentServer(options: CreateNovelAgentServerOptions):
|
|
|
219
275
|
},
|
|
220
276
|
async ({ projectPath, start, end }) => {
|
|
221
277
|
const range = start && end ? { start, end } : undefined;
|
|
222
|
-
return textResult(await requestSideTrack({ projectPath, step: 'cross_chapter_review', range }));
|
|
278
|
+
return textResult(await requestSideTrack({ projectPath: checkedProjectPath(projectPath), step: 'cross_chapter_review', range }));
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
// ----- v0.2 tools -----
|
|
283
|
+
|
|
284
|
+
server.tool(
|
|
285
|
+
'amend_story_bible',
|
|
286
|
+
'Replace the story bible with a revised version. Old version is auto-archived under story-bible-versions/ and the lexical index is rebuilt for the new content.',
|
|
287
|
+
{
|
|
288
|
+
projectPath: z.string().min(1),
|
|
289
|
+
content: z.string().min(1),
|
|
290
|
+
reason: z.string().optional(),
|
|
291
|
+
},
|
|
292
|
+
async ({ projectPath, content, reason }) =>
|
|
293
|
+
textResult(await amendStoryBible({ projectPath: checkedProjectPath(projectPath), content, reason }))
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
server.tool(
|
|
297
|
+
'list_bible_versions',
|
|
298
|
+
'List archived story-bible versions for a project (filenames sorted oldest first).',
|
|
299
|
+
{ projectPath: z.string().min(1) },
|
|
300
|
+
async ({ projectPath }) => textResult({ versions: await listStoryBibleVersions(checkedProjectPath(projectPath)) })
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
server.tool(
|
|
304
|
+
'list_threads',
|
|
305
|
+
'List foreshadow threads for a project, optionally filtered by status. Threads are aggregated from memory_card.threadActions.',
|
|
306
|
+
{
|
|
307
|
+
projectPath: z.string().min(1),
|
|
308
|
+
status: z.enum(['planted', 'building', 'paid', 'dropped']).optional(),
|
|
309
|
+
},
|
|
310
|
+
async ({ projectPath, status }) => {
|
|
311
|
+
const all = await loadThreads(checkedProjectPath(projectPath));
|
|
312
|
+
const filtered = status ? all.filter((t) => t.status === status) : all;
|
|
313
|
+
return textResult({ threads: filtered });
|
|
223
314
|
}
|
|
224
315
|
);
|
|
225
316
|
|
|
317
|
+
server.tool(
|
|
318
|
+
'update_thread',
|
|
319
|
+
'Update a single foreshadow thread (override status, plannedPayoffAt, paidOffAt, droppedAt, description, notes).',
|
|
320
|
+
{
|
|
321
|
+
projectPath: z.string().min(1),
|
|
322
|
+
id: z.string().min(1),
|
|
323
|
+
status: z.enum(['planted', 'building', 'paid', 'dropped']).optional(),
|
|
324
|
+
plannedPayoffAt: z.number().int().positive().nullable().optional(),
|
|
325
|
+
paidOffAt: z.number().int().positive().nullable().optional(),
|
|
326
|
+
droppedAt: z.number().int().positive().nullable().optional(),
|
|
327
|
+
description: z.string().min(1).optional(),
|
|
328
|
+
notes: z.string().nullable().optional(),
|
|
329
|
+
},
|
|
330
|
+
async ({ projectPath, id, ...patch }) =>
|
|
331
|
+
textResult(await updateThread(checkedProjectPath(projectPath), id, patch))
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
server.tool(
|
|
335
|
+
'fork_project',
|
|
336
|
+
'Copy an existing project to a new sibling directory with a new projectId. Use to try alternate plot branches without losing the original.',
|
|
337
|
+
{
|
|
338
|
+
sourceProjectPath: z.string().min(1),
|
|
339
|
+
label: z.string().optional(),
|
|
340
|
+
},
|
|
341
|
+
async ({ sourceProjectPath, label }) =>
|
|
342
|
+
textResult(await forkProject({ sourceProjectPath: checkedProjectPath(sourceProjectPath), label }))
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
server.tool(
|
|
346
|
+
'delete_chapter',
|
|
347
|
+
'Delete a chapter, its memory card, its single-chapter review, and all archived versions. Removes the chapter from the lexical index and rewinds the workflow if needed.',
|
|
348
|
+
{
|
|
349
|
+
projectPath: z.string().min(1),
|
|
350
|
+
chapterNumber: z.number().int().positive(),
|
|
351
|
+
},
|
|
352
|
+
async ({ projectPath, chapterNumber }) =>
|
|
353
|
+
textResult(await deleteChapter({ projectPath: checkedProjectPath(projectPath), chapterNumber }))
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
server.tool(
|
|
357
|
+
'redo_step',
|
|
358
|
+
'Roll the workflow back to a specific step. Files produced by that step (and dependent chapter content for chapter/memory_card steps) are removed; the host must regenerate.',
|
|
359
|
+
{
|
|
360
|
+
projectPath: z.string().min(1),
|
|
361
|
+
step: z.enum([
|
|
362
|
+
'novel_metadata',
|
|
363
|
+
'story_bible',
|
|
364
|
+
'style_guide',
|
|
365
|
+
'architecture',
|
|
366
|
+
'chapter',
|
|
367
|
+
'memory_card',
|
|
368
|
+
'continuity_review',
|
|
369
|
+
]),
|
|
370
|
+
chapterNumber: z.number().int().positive().optional(),
|
|
371
|
+
},
|
|
372
|
+
async ({ projectPath, step, chapterNumber }) =>
|
|
373
|
+
textResult(await redoStep({ projectPath: checkedProjectPath(projectPath), step, chapterNumber }))
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
// ===== MCP Prompts (slash commands) =====
|
|
377
|
+
|
|
378
|
+
server.prompt(
|
|
379
|
+
'nf-start',
|
|
380
|
+
'Start a brand new novel project under the configured workspace.',
|
|
381
|
+
{
|
|
382
|
+
prompt: z.string().describe('User idea / premise / genre, in any language.'),
|
|
383
|
+
chapters: z.string().optional().describe('Planning batch size as a string. Defaults to 5.'),
|
|
384
|
+
totalChapters: z.string().optional().describe('Whole-book target chapter count as a string. Defaults to 12.'),
|
|
385
|
+
},
|
|
386
|
+
({ prompt, chapters, totalChapters }) => ({
|
|
387
|
+
messages: [{
|
|
388
|
+
role: 'user' as const,
|
|
389
|
+
content: {
|
|
390
|
+
type: 'text' as const,
|
|
391
|
+
text: `Use the novelforge MCP server. Call start_novel_project with prompt="${prompt}", targetChapters=${chapters ?? '5'}, plannedTotalChapters=${totalChapters ?? '12'}, then enter the autonomous loop: read next.instruction, generate the requested content, call submit_step_result, repeat until currentStep is "complete". Show me the projectPath after start_novel_project returns.`,
|
|
392
|
+
},
|
|
393
|
+
}],
|
|
394
|
+
})
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
server.prompt(
|
|
398
|
+
'nf-next',
|
|
399
|
+
'Continue the current novelforge workflow by one step.',
|
|
400
|
+
{
|
|
401
|
+
projectPath: z.string().describe('Absolute path to the project.'),
|
|
402
|
+
},
|
|
403
|
+
({ projectPath }) => ({
|
|
404
|
+
messages: [{
|
|
405
|
+
role: 'user' as const,
|
|
406
|
+
content: {
|
|
407
|
+
type: 'text' as const,
|
|
408
|
+
text: `Use the novelforge MCP server. Call get_next_step with projectPath="${projectPath}". Read the returned instruction + context and produce the requested artifact, then call submit_step_result. Show me what step was advanced.`,
|
|
409
|
+
},
|
|
410
|
+
}],
|
|
411
|
+
})
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
server.prompt(
|
|
415
|
+
'nf-list',
|
|
416
|
+
'List all novelforge projects in the workspace.',
|
|
417
|
+
{},
|
|
418
|
+
() => ({
|
|
419
|
+
messages: [{
|
|
420
|
+
role: 'user' as const,
|
|
421
|
+
content: {
|
|
422
|
+
type: 'text' as const,
|
|
423
|
+
text: 'Use the novelforge MCP server: call list_projects with no arguments. Show me the result in a compact table (title, currentStep, chaptersWritten/plannedTotalChapters, updatedAt, projectPath).',
|
|
424
|
+
},
|
|
425
|
+
}],
|
|
426
|
+
})
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
server.prompt(
|
|
430
|
+
'nf-status',
|
|
431
|
+
'Show a one-screen status for a novelforge project.',
|
|
432
|
+
{
|
|
433
|
+
projectPath: z.string(),
|
|
434
|
+
},
|
|
435
|
+
({ projectPath }) => ({
|
|
436
|
+
messages: [{
|
|
437
|
+
role: 'user' as const,
|
|
438
|
+
content: {
|
|
439
|
+
type: 'text' as const,
|
|
440
|
+
text: `Use the novelforge MCP server: call get_project_status with projectPath="${projectPath}". Summarize: title, current step, chapters written, open threads count, latest review verdict.`,
|
|
441
|
+
},
|
|
442
|
+
}],
|
|
443
|
+
})
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
server.prompt(
|
|
447
|
+
'nf-review-chapter',
|
|
448
|
+
'Run a single-chapter editorial review.',
|
|
449
|
+
{
|
|
450
|
+
projectPath: z.string(),
|
|
451
|
+
chapterNumber: z.string(),
|
|
452
|
+
},
|
|
453
|
+
({ projectPath, chapterNumber }) => ({
|
|
454
|
+
messages: [{
|
|
455
|
+
role: 'user' as const,
|
|
456
|
+
content: {
|
|
457
|
+
type: 'text' as const,
|
|
458
|
+
text: `Use the novelforge MCP server: call review_chapter with projectPath="${projectPath}", chapterNumber=${chapterNumber}. Read the returned instruction + context, produce the JSON chapter review, then call submit_step_result with step="chapter_review". Summarize the findings for me.`,
|
|
459
|
+
},
|
|
460
|
+
}],
|
|
461
|
+
})
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
server.prompt(
|
|
465
|
+
'nf-revise-chapter',
|
|
466
|
+
'Revise a chapter based on review feedback or new instructions.',
|
|
467
|
+
{
|
|
468
|
+
projectPath: z.string(),
|
|
469
|
+
chapterNumber: z.string(),
|
|
470
|
+
feedback: z.string().optional(),
|
|
471
|
+
},
|
|
472
|
+
({ projectPath, chapterNumber, feedback }) => ({
|
|
473
|
+
messages: [{
|
|
474
|
+
role: 'user' as const,
|
|
475
|
+
content: {
|
|
476
|
+
type: 'text' as const,
|
|
477
|
+
text: `Use the novelforge MCP server: call revise_chapter with projectPath="${projectPath}", chapterNumber=${chapterNumber}${feedback ? `, feedback=${JSON.stringify(feedback)}` : ''}. Read the returned instruction + context, produce the revised Markdown chapter, then call submit_step_result with step="chapter_revision". Confirm the previous version was archived.`,
|
|
478
|
+
},
|
|
479
|
+
}],
|
|
480
|
+
})
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
server.prompt(
|
|
484
|
+
'nf-cross-review',
|
|
485
|
+
'Cross-chapter continuity review over a range.',
|
|
486
|
+
{
|
|
487
|
+
projectPath: z.string(),
|
|
488
|
+
start: z.string().optional(),
|
|
489
|
+
end: z.string().optional(),
|
|
490
|
+
},
|
|
491
|
+
({ projectPath, start, end }) => ({
|
|
492
|
+
messages: [{
|
|
493
|
+
role: 'user' as const,
|
|
494
|
+
content: {
|
|
495
|
+
type: 'text' as const,
|
|
496
|
+
text: `Use the novelforge MCP server: call cross_chapter_review with projectPath="${projectPath}"${start && end ? `, start=${start}, end=${end}` : ''}. Read the returned instruction + context, produce the JSON cross-chapter review, then call submit_step_result with step="cross_chapter_review". Summarize verdict and any issues.`,
|
|
497
|
+
},
|
|
498
|
+
}],
|
|
499
|
+
})
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
server.prompt(
|
|
503
|
+
'nf-retrieve',
|
|
504
|
+
'Lexical retrieval over a project (BM25-style).',
|
|
505
|
+
{
|
|
506
|
+
projectPath: z.string(),
|
|
507
|
+
query: z.string(),
|
|
508
|
+
},
|
|
509
|
+
({ projectPath, query }) => ({
|
|
510
|
+
messages: [{
|
|
511
|
+
role: 'user' as const,
|
|
512
|
+
content: {
|
|
513
|
+
type: 'text' as const,
|
|
514
|
+
text: `Use the novelforge MCP server: call retrieve with projectPath="${projectPath}", query=${JSON.stringify(query)}, topK=8. List the hits with chapter attribution and short excerpts.`,
|
|
515
|
+
},
|
|
516
|
+
}],
|
|
517
|
+
})
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
server.prompt(
|
|
521
|
+
'nf-amend-bible',
|
|
522
|
+
'Amend the story bible with new content (previous version auto-archived).',
|
|
523
|
+
{
|
|
524
|
+
projectPath: z.string(),
|
|
525
|
+
reason: z.string().optional(),
|
|
526
|
+
},
|
|
527
|
+
({ projectPath, reason }) => ({
|
|
528
|
+
messages: [{
|
|
529
|
+
role: 'user' as const,
|
|
530
|
+
content: {
|
|
531
|
+
type: 'text' as const,
|
|
532
|
+
text: `Use the novelforge MCP server. First call get_project_status with projectPath="${projectPath}" to confirm the project exists, then read the current story-bible.md (you may use the host's filesystem tools). Apply the following amendment intent and produce a complete revised story bible Markdown:\n\n${reason ?? '(no specific reason supplied — ask the user what to change)'}\n\nThen call amend_story_bible with projectPath="${projectPath}" and the new content. Confirm the archived version path.`,
|
|
533
|
+
},
|
|
534
|
+
}],
|
|
535
|
+
})
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
server.prompt(
|
|
539
|
+
'nf-threads',
|
|
540
|
+
'Show active foreshadow threads for a project.',
|
|
541
|
+
{
|
|
542
|
+
projectPath: z.string(),
|
|
543
|
+
status: z.enum(['planted', 'building', 'paid', 'dropped']).optional(),
|
|
544
|
+
},
|
|
545
|
+
({ projectPath, status }) => ({
|
|
546
|
+
messages: [{
|
|
547
|
+
role: 'user' as const,
|
|
548
|
+
content: {
|
|
549
|
+
type: 'text' as const,
|
|
550
|
+
text: `Use the novelforge MCP server: call list_threads with projectPath="${projectPath}"${status ? `, status="${status}"` : ''}. Show me the threads as a compact list: id, status, plantedAt, plannedPayoffAt (if set), description.`,
|
|
551
|
+
},
|
|
552
|
+
}],
|
|
553
|
+
})
|
|
554
|
+
);
|
|
555
|
+
|
|
226
556
|
return server;
|
|
227
557
|
}
|