@hanna84/mcp-writing 2.10.4 → 2.10.5

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/CHANGELOG.md CHANGED
@@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [v2.10.5](https://github.com/hannasdev/mcp-writing.git
8
+ /compare/v2.10.4...v2.10.5)
9
+
10
+ - refactor(index): extract workflow catalogue module [`#109`](https://github.com/hannasdev/mcp-writing.git
11
+ /pull/109)
12
+
7
13
  #### [v2.10.4](https://github.com/hannasdev/mcp-writing.git
8
14
  /compare/v2.10.3...v2.10.4)
9
15
 
16
+ > 27 April 2026
17
+
10
18
  - fix(review-bundles): guard oversized scene_ids in planner [`#108`](https://github.com/hannasdev/mcp-writing.git
11
19
  /pull/108)
20
+ - Release 2.10.4 [`6afb4e5`](https://github.com/hannasdev/mcp-writing.git
21
+ /commit/6afb4e51408ce9a42ade76087f4a2f86a6b13c19)
12
22
 
13
23
  #### [v2.10.3](https://github.com/hannasdev/mcp-writing.git
14
24
  /compare/v2.10.2...v2.10.3)
package/git.js CHANGED
@@ -35,7 +35,7 @@ export function initGitRepository(dirPath) {
35
35
  }
36
36
  return true;
37
37
  } catch (err) {
38
- throw new Error(`Failed to initialize git repository: ${err.message}`);
38
+ throw new Error(`Failed to initialize git repository: ${err.message}`, { cause: err });
39
39
  }
40
40
  }
41
41
 
@@ -98,7 +98,7 @@ export function createSnapshot(dirPath, filePath, sceneId, instruction, options
98
98
  reason: "no changes to commit",
99
99
  };
100
100
  }
101
- throw new Error(`Failed to create snapshot: ${err.message}`);
101
+ throw new Error(`Failed to create snapshot: ${err.message}`, { cause: err });
102
102
  }
103
103
  }
104
104
 
@@ -137,7 +137,7 @@ export function listSnapshots(dirPath, filePath) {
137
137
  if (err.message.includes("your current branch") || err.status === 128) {
138
138
  return [];
139
139
  }
140
- throw new Error(`Failed to list snapshots: ${err.message}`);
140
+ throw new Error(`Failed to list snapshots: ${err.message}`, { cause: err });
141
141
  }
142
142
  }
143
143
 
@@ -163,10 +163,16 @@ export function getSceneProseAtCommit(dirPath, filePath, commitHash) {
163
163
 
164
164
  return content;
165
165
  } catch (err) {
166
+ // ENOENT from execFileSync means the git binary was not found on PATH — not a missing file in the commit.
166
167
  if (err.code === "ENOENT") {
167
- throw new Error(`File not found in commit ${commitHash}`);
168
+ throw new Error("git executable not found; ensure git is installed and on PATH", { cause: err });
168
169
  }
169
- throw new Error(`Failed to retrieve scene prose: ${err.message}`);
170
+ // git exit 128 with "path ... does not exist in" or "bad object" indicates missing path/commit.
171
+ const stderr = err?.stderr ? String(err.stderr) : "";
172
+ if (err.status === 128 && (stderr.includes("does not exist in") || stderr.includes("bad object"))) {
173
+ throw new Error(`File not found in commit ${commitHash}`, { cause: err });
174
+ }
175
+ throw new Error(`Failed to retrieve scene prose: ${err.message}`, { cause: err });
170
176
  }
171
177
  }
172
178
 
package/index.js CHANGED
@@ -25,6 +25,7 @@ import { registerMetadataTools } from "./tools/metadata.js";
25
25
  import { registerReviewBundleTools } from "./tools/review-bundles.js";
26
26
  import { registerStyleguideTools } from "./tools/styleguide.js";
27
27
  import { registerEditingTools } from "./tools/editing.js";
28
+ import { WORKFLOW_CATALOGUE } from "./workflow-catalogue.js";
28
29
 
29
30
  const SYNC_DIR = process.env.WRITING_SYNC_DIR ?? "./sync";
30
31
  const DB_PATH = process.env.DB_PATH ?? "./writing.db";
@@ -357,102 +358,6 @@ function maxScenesNextStep(matchedCount) {
357
358
  return `Re-run with max_scenes set to at least ${matchedCount}.`;
358
359
  }
359
360
 
360
- const WORKFLOW_CATALOGUE = [
361
- {
362
- id: "first_time_setup",
363
- label: "First-time setup",
364
- use_when: "Connecting to a project for the first time or verifying the runtime is correctly configured.",
365
- steps: [
366
- { tool: "get_runtime_config", note: "Verify sync dir, writability, and git availability." },
367
- { tool: "sync", note: "Index scenes from disk." },
368
- ],
369
- },
370
- {
371
- id: "styleguide_setup_new",
372
- label: "Styleguide setup (new project)",
373
- use_when: "No prose styleguide config exists and you want to create one based on the manuscript's existing conventions.",
374
- steps: [
375
- { tool: "describe_workflows", note: "Check context.scene_count; use that value as max_scenes in the next call." },
376
- { tool: "bootstrap_prose_styleguide_config", note: "Detect dominant conventions. Confirm suggestions with the user before applying." },
377
- { tool: "setup_prose_styleguide_config", note: "Only if ALL context.styleguide_exists fields are false — a config at any scope is sufficient. Create at project_root scope (requires project_id and language e.g. 'english_us'), or sync_root if no project_id is known." },
378
- { tool: "update_prose_styleguide_config", note: "Apply the fields accepted from bootstrap suggestions." },
379
- ],
380
- },
381
- {
382
- id: "styleguide_drift_check",
383
- label: "Styleguide drift check",
384
- use_when: "A styleguide config exists and you want to check whether recent scenes conform to it.",
385
- steps: [
386
- { tool: "get_prose_styleguide_config", note: "Confirm the currently resolved config." },
387
- { tool: "check_prose_styleguide_drift", note: "Detect non-conforming scenes. Pass project_id from context.project_id and set max_scenes from context.scene_count." },
388
- { tool: "update_prose_styleguide_config", note: "If drift found and user approves, update config or note the outliers." },
389
- ],
390
- },
391
- {
392
- id: "manuscript_exploration",
393
- label: "Manuscript exploration",
394
- use_when: "Answering questions about the manuscript, finding scenes, or getting an overview.",
395
- steps: [
396
- { tool: "find_scenes", note: "Filter by character, beat, tag, part, chapter, or POV. No filters returns all scenes." },
397
- { tool: "get_scene_prose", note: "Load prose for specific scenes identified by find_scenes." },
398
- { tool: "get_chapter_prose", note: "Load all prose for a chapter. Use sparingly — large chapters can overflow context." },
399
- { tool: "search_metadata", note: "Full-text search across scene metadata fields." },
400
- ],
401
- },
402
- {
403
- id: "prose_editing",
404
- label: "Prose editing",
405
- use_when: "Revising scene prose. All edits require explicit user confirmation before writing.",
406
- steps: [
407
- { tool: "find_scenes", note: "Identify the target scene." },
408
- { tool: "get_scene_prose", note: "Load the current prose." },
409
- { tool: "propose_edit", note: "Stage a revision; returns a diff preview and a proposal_id." },
410
- { tool: "commit_edit", note: "Write the revision after the user confirms. Runs preflight checks before writing." },
411
- { tool: "discard_edit", note: "Reject the revision if the user does not approve." },
412
- ],
413
- },
414
- {
415
- id: "character_management",
416
- label: "Character management",
417
- use_when: "Finding characters, reading their sheets, or updating character details.",
418
- steps: [
419
- { tool: "list_characters", note: "Find character_id values." },
420
- { tool: "get_character_sheet", note: "Read full character details." },
421
- { tool: "create_character_sheet", note: "Create a new character. Requires exactly one of project_id or universe_id." },
422
- { tool: "update_character_sheet", note: "Edit character metadata." },
423
- ],
424
- },
425
- {
426
- id: "place_management",
427
- label: "Place management",
428
- use_when: "Finding locations, reading place sheets, or updating place details.",
429
- steps: [
430
- { tool: "list_places", note: "Find place_id values." },
431
- { tool: "get_place_sheet", note: "Read full place details." },
432
- { tool: "create_place_sheet", note: "Create a new place. Requires exactly one of project_id or universe_id." },
433
- { tool: "update_place_sheet", note: "Edit place metadata." },
434
- ],
435
- },
436
- {
437
- id: "review_bundle",
438
- label: "Review bundle",
439
- use_when: "Preparing a formatted bundle for human review (outline, editorial, or beta read profile).",
440
- steps: [
441
- { tool: "preview_review_bundle", note: "Check which scenes would be included and the estimated size. Requires project_id and profile." },
442
- { tool: "create_review_bundle", note: "Generate the bundle. Requires project_id." },
443
- ],
444
- },
445
- {
446
- id: "async_job_tracking",
447
- label: "Async job tracking",
448
- use_when: "A tool returned a job_id instead of an immediate result (e.g. import_scrivener_sync_async).",
449
- steps: [
450
- { tool: "get_async_job_status", note: "Poll with the job_id until status is 'completed' or 'failed'." },
451
- { tool: "sync", note: "Call after a completed job that modified files on disk." },
452
- ],
453
- },
454
- ];
455
-
456
361
  // ---------------------------------------------------------------------------
457
362
  // MCP server factory
458
363
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanna84/mcp-writing",
3
- "version": "2.10.4",
3
+ "version": "2.10.5",
4
4
  "description": "MCP service for AI-assisted reasoning and editing on long-form fiction projects",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -16,6 +16,7 @@
16
16
  "sync.js",
17
17
  "git.js",
18
18
  "world-entity-templates.js",
19
+ "workflow-catalogue.js",
19
20
  "metadata-lint.js",
20
21
  "scene-character-normalization.js",
21
22
  "review-bundles.js",
@@ -44,7 +45,7 @@
44
45
  "normalize:scene-characters": "node --experimental-sqlite scripts/normalize-scene-characters.mjs",
45
46
  "setup:openclaw-env": "sh scripts/setup-openclaw-env.sh",
46
47
  "release": "release-it",
47
- "lint": "eslint index.js importer.js db.js sync.js metadata-lint.js scripts/ tools/",
48
+ "lint": "eslint *.js scripts/ tools/",
48
49
  "docs": "node scripts/generate-tool-docs.mjs",
49
50
  "lint:metadata": "node scripts/lint-metadata.mjs",
50
51
  "test:unit": "node --experimental-sqlite --test test/unit/*.test.mjs",
@@ -16,7 +16,7 @@ export class ReviewBundlePlanError extends Error {
16
16
 
17
17
  export function normalizeRecipientDisplayName(recipientName) {
18
18
  const normalized = String(recipientName ?? "")
19
- .replace(/[\x00-\x1f\x7f]+/g, " ")
19
+ .replace(/[\x00-\x1f\x7f]+/g, " ") // eslint-disable-line no-control-regex
20
20
  .replace(/\s+/g, " ")
21
21
  .trim()
22
22
  .slice(0, 100);
@@ -7,7 +7,7 @@ import { ReviewBundlePlanError, normalizeRecipientDisplayName } from "./review-b
7
7
  function escapeMarkdown(text) {
8
8
  return String(text ?? "")
9
9
  .replace(/\\/g, "\\\\")
10
- .replace(/([*_`\[\]#])/g, "\\$1");
10
+ .replace(/([*_`[\]#])/g, "\\$1");
11
11
  }
12
12
 
13
13
  function renderBetaNoticeMarkdown({ projectId, recipientName }) {
@@ -705,7 +705,7 @@ export function mergeScrivenerProjectMetadata({
705
705
  });
706
706
  }
707
707
 
708
- let didRelocate = false;
708
+ let didRelocate;
709
709
 
710
710
  if (dryRun) {
711
711
  logger(` DRY ${filename}`);
@@ -0,0 +1,95 @@
1
+ export const WORKFLOW_CATALOGUE = [
2
+ {
3
+ id: "first_time_setup",
4
+ label: "First-time setup",
5
+ use_when: "Connecting to a project for the first time or verifying the runtime is correctly configured.",
6
+ steps: [
7
+ { tool: "get_runtime_config", note: "Verify sync dir, writability, and git availability." },
8
+ { tool: "sync", note: "Index scenes from disk." },
9
+ ],
10
+ },
11
+ {
12
+ id: "styleguide_setup_new",
13
+ label: "Styleguide setup (new project)",
14
+ use_when: "No prose styleguide config exists and you want to create one based on the manuscript's existing conventions.",
15
+ steps: [
16
+ { tool: "describe_workflows", note: "Check context.scene_count; use that value as max_scenes in the next call." },
17
+ { tool: "bootstrap_prose_styleguide_config", note: "Detect dominant conventions. Confirm suggestions with the user before applying." },
18
+ { tool: "setup_prose_styleguide_config", note: "Only if ALL context.styleguide_exists fields are false — a config at any scope is sufficient. Create at project_root scope (requires project_id and language e.g. 'english_us'), or sync_root if no project_id is known." },
19
+ { tool: "update_prose_styleguide_config", note: "Apply the fields accepted from bootstrap suggestions." },
20
+ ],
21
+ },
22
+ {
23
+ id: "styleguide_drift_check",
24
+ label: "Styleguide drift check",
25
+ use_when: "A styleguide config exists and you want to check whether recent scenes conform to it.",
26
+ steps: [
27
+ { tool: "get_prose_styleguide_config", note: "Confirm the currently resolved config." },
28
+ { tool: "check_prose_styleguide_drift", note: "Detect non-conforming scenes. Pass project_id from context.project_id and set max_scenes from context.scene_count." },
29
+ { tool: "update_prose_styleguide_config", note: "If drift found and user approves, update config or note the outliers." },
30
+ ],
31
+ },
32
+ {
33
+ id: "manuscript_exploration",
34
+ label: "Manuscript exploration",
35
+ use_when: "Answering questions about the manuscript, finding scenes, or getting an overview.",
36
+ steps: [
37
+ { tool: "find_scenes", note: "Filter by character, beat, tag, part, chapter, or POV. No filters returns all scenes." },
38
+ { tool: "get_scene_prose", note: "Load prose for specific scenes identified by find_scenes." },
39
+ { tool: "get_chapter_prose", note: "Load all prose for a chapter. Use sparingly — large chapters can overflow context." },
40
+ { tool: "search_metadata", note: "Full-text search across scene metadata fields." },
41
+ ],
42
+ },
43
+ {
44
+ id: "prose_editing",
45
+ label: "Prose editing",
46
+ use_when: "Revising scene prose. All edits require explicit user confirmation before writing.",
47
+ steps: [
48
+ { tool: "find_scenes", note: "Identify the target scene." },
49
+ { tool: "get_scene_prose", note: "Load the current prose." },
50
+ { tool: "propose_edit", note: "Stage a revision; returns a diff preview and a proposal_id." },
51
+ { tool: "commit_edit", note: "Write the revision after the user confirms. Runs preflight checks before writing." },
52
+ { tool: "discard_edit", note: "Reject the revision if the user does not approve." },
53
+ ],
54
+ },
55
+ {
56
+ id: "character_management",
57
+ label: "Character management",
58
+ use_when: "Finding characters, reading their sheets, or updating character details.",
59
+ steps: [
60
+ { tool: "list_characters", note: "Find character_id values." },
61
+ { tool: "get_character_sheet", note: "Read full character details." },
62
+ { tool: "create_character_sheet", note: "Create a new character. Requires exactly one of project_id or universe_id." },
63
+ { tool: "update_character_sheet", note: "Edit character metadata." },
64
+ ],
65
+ },
66
+ {
67
+ id: "place_management",
68
+ label: "Place management",
69
+ use_when: "Finding locations, reading place sheets, or updating place details.",
70
+ steps: [
71
+ { tool: "list_places", note: "Find place_id values." },
72
+ { tool: "get_place_sheet", note: "Read full place details." },
73
+ { tool: "create_place_sheet", note: "Create a new place. Requires exactly one of project_id or universe_id." },
74
+ { tool: "update_place_sheet", note: "Edit place metadata." },
75
+ ],
76
+ },
77
+ {
78
+ id: "review_bundle",
79
+ label: "Review bundle",
80
+ use_when: "Preparing a formatted bundle for human review (outline, editorial, or beta read profile).",
81
+ steps: [
82
+ { tool: "preview_review_bundle", note: "Check which scenes would be included and the estimated size. Requires project_id and profile." },
83
+ { tool: "create_review_bundle", note: "Generate the bundle. Requires project_id." },
84
+ ],
85
+ },
86
+ {
87
+ id: "async_job_tracking",
88
+ label: "Async job tracking",
89
+ use_when: "A tool returned a job_id instead of an immediate result (e.g. import_scrivener_sync_async).",
90
+ steps: [
91
+ { tool: "get_async_job_status", note: "Poll with the job_id until status is 'completed' or 'failed'." },
92
+ { tool: "sync", note: "Call after a completed job that modified files on disk." },
93
+ ],
94
+ },
95
+ ];