@hanna84/mcp-writing 2.2.0 → 2.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/CHANGELOG.md +10 -0
- package/index.js +89 -0
- package/package.json +2 -1
- package/prose-styleguide-skill.js +125 -0
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.3.0](https://github.com/hannasdev/mcp-writing.git
|
|
8
|
+
/compare/v2.2.0...v2.3.0)
|
|
9
|
+
|
|
10
|
+
- feat(styleguide): generate prose styleguide skill from resolved config [`#85`](https://github.com/hannasdev/mcp-writing.git
|
|
11
|
+
/pull/85)
|
|
12
|
+
|
|
7
13
|
#### [v2.2.0](https://github.com/hannasdev/mcp-writing.git
|
|
8
14
|
/compare/v2.1.0...v2.2.0)
|
|
9
15
|
|
|
16
|
+
> 25 April 2026
|
|
17
|
+
|
|
10
18
|
- feat(styleguide): add prose styleguide config resolution and MCP tools [`#84`](https://github.com/hannasdev/mcp-writing.git
|
|
11
19
|
/pull/84)
|
|
20
|
+
- Release 2.2.0 [`58ecb48`](https://github.com/hannasdev/mcp-writing.git
|
|
21
|
+
/commit/58ecb480200498459e3d8876c06554d8a26c2fb5)
|
|
12
22
|
|
|
13
23
|
#### [v2.1.0](https://github.com/hannasdev/mcp-writing.git
|
|
14
24
|
/compare/v2.0.4...v2.1.0)
|
package/index.js
CHANGED
|
@@ -23,6 +23,11 @@ import {
|
|
|
23
23
|
buildStyleguideConfigDraft,
|
|
24
24
|
resolveStyleguideConfig,
|
|
25
25
|
} from "./prose-styleguide.js";
|
|
26
|
+
import {
|
|
27
|
+
PROSE_STYLEGUIDE_SKILL_BASENAME,
|
|
28
|
+
PROSE_STYLEGUIDE_SKILL_DIRNAME,
|
|
29
|
+
buildProseStyleguideSkill,
|
|
30
|
+
} from "./prose-styleguide-skill.js";
|
|
26
31
|
import {
|
|
27
32
|
REVIEW_BUNDLE_PROFILES,
|
|
28
33
|
REVIEW_BUNDLE_STRICTNESS,
|
|
@@ -1513,6 +1518,90 @@ function createMcpServer() {
|
|
|
1513
1518
|
}
|
|
1514
1519
|
);
|
|
1515
1520
|
|
|
1521
|
+
s.tool(
|
|
1522
|
+
"setup_prose_styleguide_skill",
|
|
1523
|
+
"Generate skills/prose-styleguide.md from the resolved prose styleguide config and universal craft rules.",
|
|
1524
|
+
{
|
|
1525
|
+
project_id: z.string().optional().describe("Optional project ID for scoped config resolution (e.g. 'the-lamb' or 'universe-1/book-1')."),
|
|
1526
|
+
overwrite: z.boolean().optional().describe("If true, replaces an existing skills/prose-styleguide.md file."),
|
|
1527
|
+
},
|
|
1528
|
+
async ({ project_id, overwrite = false }) => {
|
|
1529
|
+
if (project_id !== undefined) {
|
|
1530
|
+
const projectIdCheck = validateProjectId(project_id);
|
|
1531
|
+
if (!projectIdCheck.ok) {
|
|
1532
|
+
return errorResponse("INVALID_PROJECT_ID", projectIdCheck.reason, { project_id });
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
if (!SYNC_DIR_WRITABLE) {
|
|
1537
|
+
return errorResponse(
|
|
1538
|
+
"SYNC_DIR_NOT_WRITABLE",
|
|
1539
|
+
"Cannot write prose styleguide skill because WRITING_SYNC_DIR is not writable in this runtime.",
|
|
1540
|
+
{ sync_dir: SYNC_DIR_ABS }
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
const resolved = resolveStyleguideConfig({
|
|
1545
|
+
syncDir: SYNC_DIR,
|
|
1546
|
+
projectId: project_id,
|
|
1547
|
+
});
|
|
1548
|
+
if (!resolved.ok) {
|
|
1549
|
+
return errorResponse(
|
|
1550
|
+
resolved.error.code,
|
|
1551
|
+
resolved.error.message,
|
|
1552
|
+
resolved.error.details
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
if (resolved.setup_required || !resolved.resolved_config) {
|
|
1556
|
+
return errorResponse(
|
|
1557
|
+
"STYLEGUIDE_CONFIG_REQUIRED",
|
|
1558
|
+
"Cannot generate prose-styleguide.md before prose-styleguide.config.yaml is set up.",
|
|
1559
|
+
{
|
|
1560
|
+
project_id: project_id ?? null,
|
|
1561
|
+
next_step: "Run setup_prose_styleguide_config first.",
|
|
1562
|
+
}
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
const skillPath = path.join(SYNC_DIR, PROSE_STYLEGUIDE_SKILL_DIRNAME, PROSE_STYLEGUIDE_SKILL_BASENAME);
|
|
1567
|
+
if (!isPathCandidateInsideSyncDir(skillPath)) {
|
|
1568
|
+
return errorResponse(
|
|
1569
|
+
"INVALID_SKILL_PATH",
|
|
1570
|
+
"Resolved prose styleguide skill path must be inside WRITING_SYNC_DIR.",
|
|
1571
|
+
{ target_path: path.resolve(skillPath), sync_dir: SYNC_DIR_ABS }
|
|
1572
|
+
);
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
if (fs.existsSync(skillPath) && !overwrite) {
|
|
1576
|
+
return errorResponse(
|
|
1577
|
+
"STYLEGUIDE_SKILL_EXISTS",
|
|
1578
|
+
"skills/prose-styleguide.md already exists. Set overwrite=true to replace it.",
|
|
1579
|
+
{ target_path: path.resolve(skillPath) }
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
const generated = buildProseStyleguideSkill({
|
|
1584
|
+
resolvedConfig: resolved.resolved_config,
|
|
1585
|
+
sources: resolved.sources,
|
|
1586
|
+
projectId: project_id ?? null,
|
|
1587
|
+
});
|
|
1588
|
+
if (!generated.ok) {
|
|
1589
|
+
return errorResponse(generated.error.code, generated.error.message);
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
fs.mkdirSync(path.dirname(skillPath), { recursive: true });
|
|
1593
|
+
fs.writeFileSync(skillPath, generated.markdown, "utf8");
|
|
1594
|
+
|
|
1595
|
+
return jsonResponse({
|
|
1596
|
+
ok: true,
|
|
1597
|
+
file_path: path.resolve(skillPath),
|
|
1598
|
+
project_id: project_id ?? null,
|
|
1599
|
+
injected_rules: generated.injected_rules,
|
|
1600
|
+
source_count: resolved.sources.length,
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
);
|
|
1604
|
+
|
|
1516
1605
|
// ---- preview_review_bundle ----------------------------------------------
|
|
1517
1606
|
s.tool(
|
|
1518
1607
|
"preview_review_bundle",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanna84/mcp-writing",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"scene-character-normalization.js",
|
|
19
19
|
"review-bundles.js",
|
|
20
20
|
"prose-styleguide.js",
|
|
21
|
+
"prose-styleguide-skill.js",
|
|
21
22
|
"scripts/",
|
|
22
23
|
"README.md",
|
|
23
24
|
"CHANGELOG.md"
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export const PROSE_STYLEGUIDE_SKILL_DIRNAME = "skills";
|
|
2
|
+
export const PROSE_STYLEGUIDE_SKILL_BASENAME = "prose-styleguide.md";
|
|
3
|
+
|
|
4
|
+
const LANGUAGE_LABELS = {
|
|
5
|
+
english_us: "English (US)",
|
|
6
|
+
english_uk: "English (UK)",
|
|
7
|
+
english_au: "English (AU)",
|
|
8
|
+
english_ca: "English (CA)",
|
|
9
|
+
swedish: "Swedish",
|
|
10
|
+
norwegian: "Norwegian",
|
|
11
|
+
danish: "Danish",
|
|
12
|
+
finnish: "Finnish",
|
|
13
|
+
french: "French",
|
|
14
|
+
italian: "Italian",
|
|
15
|
+
russian: "Russian",
|
|
16
|
+
portuguese_pt: "Portuguese (PT)",
|
|
17
|
+
portuguese_br: "Portuguese (BR)",
|
|
18
|
+
german: "German",
|
|
19
|
+
dutch: "Dutch",
|
|
20
|
+
polish: "Polish",
|
|
21
|
+
czech: "Czech",
|
|
22
|
+
hungarian: "Hungarian",
|
|
23
|
+
spanish: "Spanish",
|
|
24
|
+
irish: "Irish",
|
|
25
|
+
japanese: "Japanese",
|
|
26
|
+
korean: "Korean",
|
|
27
|
+
chinese_traditional: "Chinese (Traditional)",
|
|
28
|
+
chinese_simplified: "Chinese (Simplified)",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const CONFIG_RULE_RENDERERS = {
|
|
32
|
+
language: (value) => `Primary writing language: ${LANGUAGE_LABELS[value] ?? value}.`,
|
|
33
|
+
spelling: (value) => `Spelling variant: ${value.toUpperCase()}.`,
|
|
34
|
+
quotation_style: (value) => {
|
|
35
|
+
const labels = {
|
|
36
|
+
double: "double quotes",
|
|
37
|
+
single: "single quotes",
|
|
38
|
+
guillemets: "guillemets (« »)",
|
|
39
|
+
low9: "low-9 quotation marks",
|
|
40
|
+
dialogue_dash_en: "Scandinavian en-dash dialogue",
|
|
41
|
+
dialogue_dash_em: "Spanish/Irish em-dash dialogue",
|
|
42
|
+
corner_brackets: "corner brackets (「 」)",
|
|
43
|
+
};
|
|
44
|
+
return `Dialogue quotation style: ${labels[value] ?? value}.`;
|
|
45
|
+
},
|
|
46
|
+
quotation_style_nested: (value) => `Nested quotation style: ${value}.`,
|
|
47
|
+
em_dash_spacing: (value) => `Em dash spacing: ${value}.`,
|
|
48
|
+
ellipsis_style: (value) => `Ellipsis style: ${value}.`,
|
|
49
|
+
abbreviation_periods: (value) => `Abbreviation periods: ${value}.`,
|
|
50
|
+
oxford_comma: (value) => `Oxford comma: ${value}.`,
|
|
51
|
+
numbers: (value) => `Number formatting rule: ${value}.`,
|
|
52
|
+
date_format: (value) => `Date format: ${value}.`,
|
|
53
|
+
time_format: (value) => `Time format: ${value}.`,
|
|
54
|
+
tense: (value) => `Default narrative tense: ${value}. Flag deviations as questions, not hard errors.`,
|
|
55
|
+
pov: (value) => `Default POV: ${value}. Flag shifts as intentional-or-drift questions.`,
|
|
56
|
+
dialogue_tags: (value) => `Dialogue tag policy: ${value}.`,
|
|
57
|
+
sentence_fragments: (value) => `Sentence fragments policy: ${value}.`,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function buildProseStyleguideSkill({ resolvedConfig, sources = [], projectId = null }) {
|
|
61
|
+
if (!resolvedConfig || typeof resolvedConfig !== "object") {
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
error: {
|
|
65
|
+
code: "INVALID_STYLEGUIDE_CONFIG",
|
|
66
|
+
message: "Cannot generate prose-styleguide.md without a resolved config object.",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const injectedRules = [];
|
|
72
|
+
for (const [field, renderRule] of Object.entries(CONFIG_RULE_RENDERERS)) {
|
|
73
|
+
if (resolvedConfig[field] === undefined) continue;
|
|
74
|
+
injectedRules.push(renderRule(resolvedConfig[field]));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const sourceLines = sources.length
|
|
78
|
+
? sources.map((source) => `- ${source.scope}: ${source.file_path}`)
|
|
79
|
+
: ["- none"];
|
|
80
|
+
|
|
81
|
+
const voiceNotes = typeof resolvedConfig.voice_notes === "string" && resolvedConfig.voice_notes.trim()
|
|
82
|
+
? resolvedConfig.voice_notes.trim().split("\n").map((line) => `> ${line}`).join("\n")
|
|
83
|
+
: "> None provided.";
|
|
84
|
+
|
|
85
|
+
const markdown = [
|
|
86
|
+
"# Prose Styleguide",
|
|
87
|
+
"",
|
|
88
|
+
"## Standing Order",
|
|
89
|
+
"Apply this styleguide by default for prose critique and edits. Preserve author voice over mechanical cleanup.",
|
|
90
|
+
"",
|
|
91
|
+
"## Resolved Scope",
|
|
92
|
+
`- Project scope: ${projectId ?? "sync-root default"}`,
|
|
93
|
+
...sourceLines,
|
|
94
|
+
"",
|
|
95
|
+
"## Mechanical Conventions",
|
|
96
|
+
"These are injected from prose-styleguide.config.yaml and should be applied consistently:",
|
|
97
|
+
...injectedRules.map((rule) => `- ${rule}`),
|
|
98
|
+
"",
|
|
99
|
+
"## Universal Craft Rules",
|
|
100
|
+
"- Identify scene purpose before proposing changes.",
|
|
101
|
+
"- Require transformation (emotional, relational, narrative, or thematic).",
|
|
102
|
+
"- Prefer critique before rewrite.",
|
|
103
|
+
"- Preserve cadence and specificity; avoid flattening voice.",
|
|
104
|
+
"- Ask before normalizing intentional instability (flashbacks, POV drift, syntax breaks).",
|
|
105
|
+
"",
|
|
106
|
+
"## Review Posture",
|
|
107
|
+
"- Prioritize structural issues, then convention drift, then line-level polish.",
|
|
108
|
+
"- Treat convention drift as a question when intent may be deliberate.",
|
|
109
|
+
"",
|
|
110
|
+
"## Edit Posture",
|
|
111
|
+
"- Do not shorten unless requested.",
|
|
112
|
+
"- Apply conventions consistently while preserving tone.",
|
|
113
|
+
"- Justify significant rewrites.",
|
|
114
|
+
"",
|
|
115
|
+
"## Voice Notes",
|
|
116
|
+
voiceNotes,
|
|
117
|
+
"",
|
|
118
|
+
].join("\n");
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
ok: true,
|
|
122
|
+
markdown,
|
|
123
|
+
injected_rules: injectedRules,
|
|
124
|
+
};
|
|
125
|
+
}
|