@rubytech/create-maxy-code 0.1.166 → 0.1.169

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.
Files changed (149) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/config/brand.json +1 -1
  3. package/payload/platform/plugins/.claude-plugin/marketplace.json +10 -0
  4. package/payload/platform/plugins/teaching/.claude-plugin/plugin.json +8 -0
  5. package/payload/platform/plugins/teaching/PLUGIN.md +58 -0
  6. package/payload/platform/plugins/teaching/skills/interactive-tutor/SKILL.md +59 -0
  7. package/payload/platform/plugins/teaching/skills/interactive-tutor/references/assessment.md +70 -0
  8. package/payload/platform/plugins/teaching/skills/interactive-tutor/references/classroom-conduct.md +43 -0
  9. package/payload/platform/plugins/teaching/skills/interactive-tutor/references/teaching-modes.md +83 -0
  10. package/payload/platform/plugins/teaching/skills/lesson-planner/SKILL.md +48 -0
  11. package/payload/platform/plugins/teaching/skills/lesson-planner/references/context-gathering.md +41 -0
  12. package/payload/platform/plugins/teaching/skills/lesson-planner/references/plan-structure.md +94 -0
  13. package/payload/platform/plugins/teaching/skills/study-pack-builder/SKILL.md +52 -0
  14. package/payload/platform/plugins/teaching/skills/study-pack-builder/references/disaggregation.md +49 -0
  15. package/payload/platform/plugins/teaching/skills/study-pack-builder/references/materials.md +116 -0
  16. package/payload/platform/plugins/writer-craft/.claude-plugin/plugin.json +17 -0
  17. package/payload/platform/plugins/writer-craft/PLUGIN.md +130 -0
  18. package/payload/platform/plugins/writer-craft/agents/writer-craft--manuscript-reviewer.md +96 -0
  19. package/payload/platform/plugins/writer-craft/mcp/package.json +19 -0
  20. package/payload/platform/plugins/writer-craft/mcp/scripts/smoke.mjs +152 -0
  21. package/payload/platform/plugins/writer-craft/mcp/src/index.ts +289 -0
  22. package/payload/platform/plugins/writer-craft/mcp/src/lib/neo4j.ts +56 -0
  23. package/payload/platform/plugins/writer-craft/mcp/src/lib/voice-corpus.ts +54 -0
  24. package/payload/platform/plugins/writer-craft/mcp/src/tools/voice-distil-profile.ts +303 -0
  25. package/payload/platform/plugins/writer-craft/mcp/src/tools/voice-record-feedback.ts +114 -0
  26. package/payload/platform/plugins/writer-craft/mcp/src/tools/voice-retrieve-conditioning.ts +145 -0
  27. package/payload/platform/plugins/writer-craft/mcp/src/tools/voice-tag-content.ts +117 -0
  28. package/payload/platform/plugins/writer-craft/mcp/tsconfig.json +8 -0
  29. package/payload/platform/plugins/writer-craft/skills/citation-style/SKILL.md +94 -0
  30. package/payload/platform/plugins/writer-craft/skills/citation-style/references/book-and-chapter-models.md +77 -0
  31. package/payload/platform/plugins/writer-craft/skills/citation-style/references/citation-rules.md +103 -0
  32. package/payload/platform/plugins/writer-craft/skills/citation-style/references/journal-article-models.md +74 -0
  33. package/payload/platform/plugins/writer-craft/skills/citation-style/references/other-source-models.md +146 -0
  34. package/payload/platform/plugins/writer-craft/skills/citation-style/references/reference-list-rules.md +70 -0
  35. package/payload/platform/plugins/writer-craft/skills/editorial-practice/SKILL.md +108 -0
  36. package/payload/platform/plugins/writer-craft/skills/editorial-practice/references/copyediting.md +73 -0
  37. package/payload/platform/plugins/writer-craft/skills/editorial-practice/references/developmental-editing.md +85 -0
  38. package/payload/platform/plugins/writer-craft/skills/editorial-practice/references/genre-specific-editing.md +78 -0
  39. package/payload/platform/plugins/writer-craft/skills/editorial-practice/references/line-editing.md +55 -0
  40. package/payload/platform/plugins/writer-craft/skills/editorial-practice/references/self-editing.md +89 -0
  41. package/payload/platform/plugins/writer-craft/skills/persuasive-storytelling/SKILL.md +114 -0
  42. package/payload/platform/plugins/writer-craft/skills/persuasive-storytelling/references/audience-analysis.md +73 -0
  43. package/payload/platform/plugins/writer-craft/skills/persuasive-storytelling/references/crafting-persuasive-story.md +76 -0
  44. package/payload/platform/plugins/writer-craft/skills/persuasive-storytelling/references/persuasion-case-studies.md +67 -0
  45. package/payload/platform/plugins/writer-craft/skills/persuasive-storytelling/references/transformation-framework.md +86 -0
  46. package/payload/platform/plugins/writer-craft/skills/point-of-view/SKILL.md +97 -0
  47. package/payload/platform/plugins/writer-craft/skills/point-of-view/references/indirect-narration.md +72 -0
  48. package/payload/platform/plugins/writer-craft/skills/point-of-view/references/pov-types-and-voice.md +91 -0
  49. package/payload/platform/plugins/writer-craft/skills/point-of-view/references/protagonist-filter.md +71 -0
  50. package/payload/platform/plugins/writer-craft/skills/point-of-view/references/tense-and-person.md +85 -0
  51. package/payload/platform/plugins/writer-craft/skills/prose-craft/SKILL.md +100 -0
  52. package/payload/platform/plugins/writer-craft/skills/prose-craft/references/punctuation-and-grammar.md +72 -0
  53. package/payload/platform/plugins/writer-craft/skills/prose-craft/references/repetition.md +71 -0
  54. package/payload/platform/plugins/writer-craft/skills/prose-craft/references/sound-and-rhythm.md +64 -0
  55. package/payload/platform/plugins/writer-craft/skills/prose-craft/references/word-economy.md +93 -0
  56. package/payload/platform/plugins/writer-craft/skills/reader-engagement/SKILL.md +100 -0
  57. package/payload/platform/plugins/writer-craft/skills/reader-engagement/references/cause-effect-setup-payoff.md +79 -0
  58. package/payload/platform/plugins/writer-craft/skills/reader-engagement/references/conflict-escalation.md +81 -0
  59. package/payload/platform/plugins/writer-craft/skills/reader-engagement/references/hooking-readers.md +67 -0
  60. package/payload/platform/plugins/writer-craft/skills/reader-engagement/references/neurochemistry-of-engagement.md +94 -0
  61. package/payload/platform/plugins/writer-craft/skills/review-manuscript/SKILL.md +111 -0
  62. package/payload/platform/plugins/writer-craft/skills/review-manuscript/references/review-manuscript-checklist.md +119 -0
  63. package/payload/platform/plugins/writer-craft/skills/review-prose/SKILL.md +99 -0
  64. package/payload/platform/plugins/writer-craft/skills/review-prose/references/prose-review-checklist.md +112 -0
  65. package/payload/platform/plugins/writer-craft/skills/review-scene/SKILL.md +99 -0
  66. package/payload/platform/plugins/writer-craft/skills/review-scene/references/scene-analysis-framework.md +95 -0
  67. package/payload/platform/plugins/writer-craft/skills/story-architecture/SKILL.md +106 -0
  68. package/payload/platform/plugins/writer-craft/skills/story-architecture/references/blueprinting-and-scene-cards.md +118 -0
  69. package/payload/platform/plugins/writer-craft/skills/story-architecture/references/inner-issue-and-protagonist-goal.md +66 -0
  70. package/payload/platform/plugins/writer-craft/skills/story-architecture/references/misbelief-desire-worldview.md +87 -0
  71. package/payload/platform/plugins/writer-craft/skills/story-architecture/references/origin-scenes-and-escalation.md +82 -0
  72. package/payload/platform/plugins/writer-craft/skills/story-blueprint/SKILL.md +133 -0
  73. package/payload/platform/plugins/writer-craft/skills/story-blueprint/references/blueprinting-exercises.md +118 -0
  74. package/payload/platform/plugins/writer-craft/skills/story-blueprint/references/blueprinting-process.md +128 -0
  75. package/payload/platform/plugins/writer-craft/skills/voice-mirror/SKILL.md +166 -0
  76. package/payload/platform/scripts/seed-neo4j.sh +4 -0
  77. package/payload/premium-plugins/.claude-plugin/marketplace.json +10 -0
  78. package/payload/premium-plugins/teaching/.claude-plugin/plugin.json +8 -0
  79. package/payload/premium-plugins/teaching/PLUGIN.md +58 -0
  80. package/payload/premium-plugins/teaching/skills/interactive-tutor/SKILL.md +59 -0
  81. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/assessment.md +70 -0
  82. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/classroom-conduct.md +43 -0
  83. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/teaching-modes.md +83 -0
  84. package/payload/premium-plugins/teaching/skills/lesson-planner/SKILL.md +48 -0
  85. package/payload/premium-plugins/teaching/skills/lesson-planner/references/context-gathering.md +41 -0
  86. package/payload/premium-plugins/teaching/skills/lesson-planner/references/plan-structure.md +94 -0
  87. package/payload/premium-plugins/teaching/skills/study-pack-builder/SKILL.md +52 -0
  88. package/payload/premium-plugins/teaching/skills/study-pack-builder/references/disaggregation.md +49 -0
  89. package/payload/premium-plugins/teaching/skills/study-pack-builder/references/materials.md +116 -0
  90. package/payload/premium-plugins/writer-craft/.claude-plugin/plugin.json +17 -0
  91. package/payload/premium-plugins/writer-craft/PLUGIN.md +130 -0
  92. package/payload/premium-plugins/writer-craft/agents/writer-craft--manuscript-reviewer.md +96 -0
  93. package/payload/premium-plugins/writer-craft/mcp/package.json +19 -0
  94. package/payload/premium-plugins/writer-craft/mcp/scripts/smoke.mjs +152 -0
  95. package/payload/premium-plugins/writer-craft/mcp/src/index.ts +289 -0
  96. package/payload/premium-plugins/writer-craft/mcp/src/lib/neo4j.ts +56 -0
  97. package/payload/premium-plugins/writer-craft/mcp/src/lib/voice-corpus.ts +54 -0
  98. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-distil-profile.ts +303 -0
  99. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-record-feedback.ts +114 -0
  100. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-retrieve-conditioning.ts +145 -0
  101. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-tag-content.ts +117 -0
  102. package/payload/premium-plugins/writer-craft/mcp/tsconfig.json +8 -0
  103. package/payload/premium-plugins/writer-craft/skills/citation-style/SKILL.md +94 -0
  104. package/payload/premium-plugins/writer-craft/skills/citation-style/references/book-and-chapter-models.md +77 -0
  105. package/payload/premium-plugins/writer-craft/skills/citation-style/references/citation-rules.md +103 -0
  106. package/payload/premium-plugins/writer-craft/skills/citation-style/references/journal-article-models.md +74 -0
  107. package/payload/premium-plugins/writer-craft/skills/citation-style/references/other-source-models.md +146 -0
  108. package/payload/premium-plugins/writer-craft/skills/citation-style/references/reference-list-rules.md +70 -0
  109. package/payload/premium-plugins/writer-craft/skills/editorial-practice/SKILL.md +108 -0
  110. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/copyediting.md +73 -0
  111. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/developmental-editing.md +85 -0
  112. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/genre-specific-editing.md +78 -0
  113. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/line-editing.md +55 -0
  114. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/self-editing.md +89 -0
  115. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/SKILL.md +114 -0
  116. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/audience-analysis.md +73 -0
  117. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/crafting-persuasive-story.md +76 -0
  118. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/persuasion-case-studies.md +67 -0
  119. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/transformation-framework.md +86 -0
  120. package/payload/premium-plugins/writer-craft/skills/point-of-view/SKILL.md +97 -0
  121. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/indirect-narration.md +72 -0
  122. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/pov-types-and-voice.md +91 -0
  123. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/protagonist-filter.md +71 -0
  124. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/tense-and-person.md +85 -0
  125. package/payload/premium-plugins/writer-craft/skills/prose-craft/SKILL.md +100 -0
  126. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/punctuation-and-grammar.md +72 -0
  127. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/repetition.md +71 -0
  128. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/sound-and-rhythm.md +64 -0
  129. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/word-economy.md +93 -0
  130. package/payload/premium-plugins/writer-craft/skills/reader-engagement/SKILL.md +100 -0
  131. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/cause-effect-setup-payoff.md +79 -0
  132. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/conflict-escalation.md +81 -0
  133. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/hooking-readers.md +67 -0
  134. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/neurochemistry-of-engagement.md +94 -0
  135. package/payload/premium-plugins/writer-craft/skills/review-manuscript/SKILL.md +111 -0
  136. package/payload/premium-plugins/writer-craft/skills/review-manuscript/references/review-manuscript-checklist.md +119 -0
  137. package/payload/premium-plugins/writer-craft/skills/review-prose/SKILL.md +99 -0
  138. package/payload/premium-plugins/writer-craft/skills/review-prose/references/prose-review-checklist.md +112 -0
  139. package/payload/premium-plugins/writer-craft/skills/review-scene/SKILL.md +99 -0
  140. package/payload/premium-plugins/writer-craft/skills/review-scene/references/scene-analysis-framework.md +95 -0
  141. package/payload/premium-plugins/writer-craft/skills/story-architecture/SKILL.md +106 -0
  142. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/blueprinting-and-scene-cards.md +118 -0
  143. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/inner-issue-and-protagonist-goal.md +66 -0
  144. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/misbelief-desire-worldview.md +87 -0
  145. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/origin-scenes-and-escalation.md +82 -0
  146. package/payload/premium-plugins/writer-craft/skills/story-blueprint/SKILL.md +133 -0
  147. package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-exercises.md +118 -0
  148. package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-process.md +128 -0
  149. package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +166 -0
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Boot + shape smoke test for the writer-craft MCP server.
4
+ *
5
+ * Verifies:
6
+ * 1. Every compiled tool module loads without throwing.
7
+ * 2. Every exported handler is a function with the expected name.
8
+ * 3. AUTHORSHIP_MODES enum covers the five spec-required values.
9
+ * 4. TAGGABLE_PRIMARY_LABELS covers the four content labels.
10
+ * 5. `voice-retrieve-conditioning` returns the graceful-degradation
11
+ * shape `{styleCard: null, exemplars: []}` when accountId is empty
12
+ * (the contract the calling drafting skills depend on).
13
+ *
14
+ * Runs with no external dependencies and no neo4j connection — the
15
+ * graceful-degradation case never opens a session. The four other tools
16
+ * are not exercised against the database here; their unit test coverage
17
+ * is filed as a follow-up. This smoke harness catches import errors,
18
+ * accidental contract changes on the empty-corpus return shape, and
19
+ * structural drift on the exported enum.
20
+ *
21
+ * Exit code: 0 on pass, 1 on any assertion failure. Designed for CI
22
+ * gating and `npm run smoke` in the build pipeline.
23
+ */
24
+ import { strict as assert } from "node:assert";
25
+
26
+ const errors = [];
27
+ function check(name, fn) {
28
+ try {
29
+ const result = fn();
30
+ if (result && typeof result.then === "function") {
31
+ return result.then(
32
+ () => console.log(` ok ${name}`),
33
+ (err) => {
34
+ errors.push({ name, err });
35
+ console.error(` FAIL ${name}: ${err.message}`);
36
+ },
37
+ );
38
+ }
39
+ console.log(` ok ${name}`);
40
+ } catch (err) {
41
+ errors.push({ name, err });
42
+ console.error(` FAIL ${name}: ${err.message}`);
43
+ }
44
+ }
45
+
46
+ console.log("[writer-craft smoke] starting");
47
+
48
+ // 1. Modules load.
49
+ const tagMod = await import("../dist/tools/voice-tag-content.js");
50
+ const distilMod = await import("../dist/tools/voice-distil-profile.js");
51
+ const retrieveMod = await import("../dist/tools/voice-retrieve-conditioning.js");
52
+ const feedbackMod = await import("../dist/tools/voice-record-feedback.js");
53
+ const corpusMod = await import("../dist/lib/voice-corpus.js");
54
+
55
+ await check("voice-tag-content exports voiceTagContent function", () => {
56
+ assert.equal(typeof tagMod.voiceTagContent, "function");
57
+ });
58
+ await check("voice-tag-content exports AUTHORSHIP_MODES set of 5", () => {
59
+ const expected = [
60
+ "human-only",
61
+ "human-led-agent-assisted",
62
+ "agent-led-human-reviewed",
63
+ "agent-only",
64
+ "unknown",
65
+ ];
66
+ assert.equal(tagMod.AUTHORSHIP_MODES.size, 5);
67
+ for (const m of expected) assert.ok(tagMod.AUTHORSHIP_MODES.has(m), `missing ${m}`);
68
+ });
69
+ await check("voice-distil-profile exports voiceDistilProfile function", () => {
70
+ assert.equal(typeof distilMod.voiceDistilProfile, "function");
71
+ });
72
+ await check("voice-retrieve-conditioning exports voiceRetrieveConditioning function", () => {
73
+ assert.equal(typeof retrieveMod.voiceRetrieveConditioning, "function");
74
+ });
75
+ await check("voice-record-feedback exports voiceRecordFeedback function", () => {
76
+ assert.equal(typeof feedbackMod.voiceRecordFeedback, "function");
77
+ });
78
+ await check("VOICE_CORPUS_WHERE is non-empty string with both predicates", () => {
79
+ assert.equal(typeof corpusMod.VOICE_CORPUS_WHERE, "string");
80
+ assert.ok(corpusMod.VOICE_CORPUS_WHERE.includes("authorshipMode IN"));
81
+ assert.ok(corpusMod.VOICE_CORPUS_WHERE.includes("human-only"));
82
+ assert.ok(corpusMod.VOICE_CORPUS_WHERE.includes("human-led-agent-assisted"));
83
+ assert.ok(corpusMod.VOICE_CORPUS_WHERE.includes("Section"));
84
+ });
85
+ await check("TAGGABLE_PRIMARY_LABELS covers the four content labels", () => {
86
+ const labels = [...corpusMod.TAGGABLE_PRIMARY_LABELS];
87
+ assert.deepEqual(labels.sort(), ["Email", "KnowledgeDocument", "Message", "SocialPost"]);
88
+ });
89
+
90
+ // 2. Graceful-degradation contract — the drafting skills depend on this.
91
+ // Empty accountId/adminUserId path returns the empty shape without
92
+ // opening a neo4j session. This is the load-bearing contract.
93
+ await check(
94
+ "voice-retrieve-conditioning returns empty shape on missing accountId",
95
+ async () => {
96
+ const result = await retrieveMod.voiceRetrieveConditioning({
97
+ accountId: "",
98
+ adminUserId: "u",
99
+ brief: { format: "short" },
100
+ });
101
+ assert.deepEqual(result, { styleCard: null, exemplars: [] });
102
+ },
103
+ );
104
+ await check(
105
+ "voice-retrieve-conditioning returns empty shape on missing adminUserId",
106
+ async () => {
107
+ const result = await retrieveMod.voiceRetrieveConditioning({
108
+ accountId: "acc",
109
+ adminUserId: "",
110
+ brief: { format: "long" },
111
+ });
112
+ assert.deepEqual(result, { styleCard: null, exemplars: [] });
113
+ },
114
+ );
115
+
116
+ // 3. voice-tag-content validates the mode enum before any DB work.
117
+ await check("voice-tag-content rejects an invalid mode", async () => {
118
+ await assert.rejects(
119
+ () =>
120
+ tagMod.voiceTagContent({
121
+ nodeIds: ["x"],
122
+ mode: "not-a-mode",
123
+ accountId: "acc",
124
+ }),
125
+ /invalid authorshipMode/,
126
+ );
127
+ });
128
+ await check("voice-tag-content rejects empty accountId", async () => {
129
+ await assert.rejects(
130
+ () =>
131
+ tagMod.voiceTagContent({
132
+ nodeIds: ["x"],
133
+ mode: "human-only",
134
+ accountId: "",
135
+ }),
136
+ /accountId is required/,
137
+ );
138
+ });
139
+ await check("voice-tag-content returns zero counts on empty nodeIds (no DB hit)", async () => {
140
+ const result = await tagMod.voiceTagContent({
141
+ nodeIds: [],
142
+ mode: "human-only",
143
+ accountId: "acc",
144
+ });
145
+ assert.deepEqual(result, { updated: 0, skipped: 0, skippedReasons: {} });
146
+ });
147
+
148
+ if (errors.length > 0) {
149
+ console.error(`\n[writer-craft smoke] FAILED — ${errors.length} assertion(s)`);
150
+ process.exit(1);
151
+ }
152
+ console.log("\n[writer-craft smoke] all passed");
@@ -0,0 +1,289 @@
1
+ import { initStderrTee } from "../../../../platform/lib/mcp-stderr-tee/dist/index.js";
2
+ initStderrTee("writer-craft");
3
+
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { z } from "zod";
7
+ import { voiceTagContent, AUTHORSHIP_MODES, type AuthorshipMode } from "./tools/voice-tag-content.js";
8
+ import { voiceDistilProfile } from "./tools/voice-distil-profile.js";
9
+ import { voiceRetrieveConditioning } from "./tools/voice-retrieve-conditioning.js";
10
+ import { voiceRecordFeedback } from "./tools/voice-record-feedback.js";
11
+ import { closeDriver } from "./lib/neo4j.js";
12
+
13
+ const server = new McpServer({
14
+ name: "maxy-writer-craft",
15
+ version: "0.1.0",
16
+ });
17
+
18
+ // Plugin-system boot tolerance — module-init must never throw. Per-call
19
+ // refusal preserves account isolation. Mirrors the memory plugin's
20
+ // pattern (Task 202).
21
+ const accountId = process.env.ACCOUNT_ID ?? null;
22
+ const adminUserIdEnv = process.env.ADMIN_USER_ID ?? null;
23
+ process.stderr.write(
24
+ `[writer-craft] boot accountId=${accountId ?? "null"} adminUserId=${adminUserIdEnv ?? "null"}\n`,
25
+ );
26
+
27
+ function refuseNoAccount(toolName: string) {
28
+ process.stderr.write(
29
+ `[writer-craft] tool=${toolName} refuse reason=no-account-context\n`,
30
+ );
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text" as const,
35
+ text: `${toolName} cannot execute: this MCP instance was launched without ACCOUNT_ID. Per-account graph access requires ACCOUNT_ID at spawn.`,
36
+ },
37
+ ],
38
+ isError: true as const,
39
+ };
40
+ }
41
+
42
+ function resolveAdminUserId(): string | null {
43
+ // ADMIN_USER_ID is stamped by the admin session manager at spawn time.
44
+ // When absent (e.g. specialist subagents), the operator must pass it as
45
+ // a tool argument or the tools refuse rather than orphan a profile.
46
+ return adminUserIdEnv;
47
+ }
48
+
49
+ server.tool(
50
+ "voice-tag-content",
51
+ "Stamp authorshipMode on one or many content nodes (:KnowledgeDocument | :Message | :SocialPost) the operator owns. Email threads live as :KnowledgeDocument {source:'email'} since Task 321. Valid modes: human-only, human-led-agent-assisted, agent-led-human-reviewed, agent-only, unknown.",
52
+ {
53
+ nodeIds: z.array(z.string()).min(1).describe("Element IDs of nodes to tag"),
54
+ mode: z
55
+ .enum([
56
+ "human-only",
57
+ "human-led-agent-assisted",
58
+ "agent-led-human-reviewed",
59
+ "agent-only",
60
+ "unknown",
61
+ ])
62
+ .describe("Authorship mode to apply"),
63
+ },
64
+ async ({ nodeIds, mode }) => {
65
+ if (!accountId) return refuseNoAccount("voice-tag-content");
66
+ try {
67
+ const result = await voiceTagContent({
68
+ nodeIds,
69
+ mode: mode as AuthorshipMode,
70
+ accountId,
71
+ });
72
+ return {
73
+ content: [
74
+ {
75
+ type: "text" as const,
76
+ text: `voice-tag: mode=${mode} updated=${result.updated} skipped=${result.skipped}`,
77
+ },
78
+ ],
79
+ };
80
+ } catch (err) {
81
+ return {
82
+ content: [
83
+ {
84
+ type: "text" as const,
85
+ text: `voice-tag-content failed: ${err instanceof Error ? err.message : String(err)}`,
86
+ },
87
+ ],
88
+ isError: true,
89
+ };
90
+ }
91
+ },
92
+ );
93
+
94
+ server.tool(
95
+ "voice-distil-profile",
96
+ "Two-mode tool (Task 424). mode='sample' (default) walks the operator's human-only corpus, returns the exemplars + recent operator-edit intents for the agent to read. mode='write' persists the YAML style card the agent composed from the sample-mode response. Cadence-guarded: returns skip in 'write' mode without writing if corpus didn't grow ≥20% AND <30 days passed (pass force=true to override).",
97
+ {
98
+ adminUserId: z
99
+ .string()
100
+ .optional()
101
+ .describe(
102
+ "Operator AdminUser identifier. Defaults to ADMIN_USER_ID env from spawn context.",
103
+ ),
104
+ force: z
105
+ .boolean()
106
+ .optional()
107
+ .describe("Override cadence guard; rebuild even if recent."),
108
+ mode: z
109
+ .enum(["sample", "write"])
110
+ .optional()
111
+ .describe("'sample' returns corpus exemplars + feedback for in-turn distillation; 'write' persists the agent-produced styleCardYaml."),
112
+ styleCardYaml: z
113
+ .string()
114
+ .optional()
115
+ .describe("Required for mode='write'. The YAML style card the agent composed from the sample-mode exemplars + feedback intents."),
116
+ },
117
+ async ({ adminUserId, force, mode, styleCardYaml }) => {
118
+ if (!accountId) return refuseNoAccount("voice-distil-profile");
119
+ const resolvedAdminUserId = adminUserId ?? resolveAdminUserId();
120
+ if (!resolvedAdminUserId) {
121
+ return {
122
+ content: [
123
+ {
124
+ type: "text" as const,
125
+ text:
126
+ "voice-distil-profile: adminUserId required (no ADMIN_USER_ID in spawn env).",
127
+ },
128
+ ],
129
+ isError: true,
130
+ };
131
+ }
132
+ try {
133
+ const result = await voiceDistilProfile({
134
+ accountId,
135
+ adminUserId: resolvedAdminUserId,
136
+ force: force === true,
137
+ mode,
138
+ styleCardYaml,
139
+ });
140
+ const summary = result.skipped
141
+ ? (result.exemplars
142
+ ? `voice-distil sample: corpusSize=${result.corpusSize} exemplars=${result.exemplars.length} feedbackEntries=${result.feedbackEntries}\n${JSON.stringify({ exemplars: result.exemplars, feedbackIntents: result.feedbackIntents }, null, 2)}`
143
+ : `voice-distil: skipped reason=${result.skipReason} corpusSize=${result.corpusSize}`)
144
+ : `voice-distil: ok profileId=${result.profileId} corpusSize=${result.corpusSize} feedbackEntries=${result.feedbackEntries} generatedAt=${result.generatedAt}`;
145
+ return { content: [{ type: "text" as const, text: summary }] };
146
+ } catch (err) {
147
+ return {
148
+ content: [
149
+ {
150
+ type: "text" as const,
151
+ text: `voice-distil-profile failed: ${err instanceof Error ? err.message : String(err)}`,
152
+ },
153
+ ],
154
+ isError: true,
155
+ };
156
+ }
157
+ },
158
+ );
159
+
160
+ server.tool(
161
+ "voice-retrieve-conditioning",
162
+ "Return the operator's style card and K voice-matched exemplars for a drafting brief. K=5 short-form, K=15 long-form. Token-budget bounded. Returns empty {styleCard:null,exemplars:[]} when no profile exists.",
163
+ {
164
+ adminUserId: z
165
+ .string()
166
+ .optional()
167
+ .describe("Operator AdminUser identifier. Defaults to ADMIN_USER_ID env."),
168
+ topic: z
169
+ .string()
170
+ .optional()
171
+ .describe("Drafting topic keyword (filters exemplars to relevant ones)"),
172
+ format: z
173
+ .enum(["short", "long"])
174
+ .describe("Short = email/post (K=5, 16k tokens); long = brochure/prospectus (K=15, 96k tokens)"),
175
+ register: z.string().optional().describe("Optional register hint"),
176
+ tokenBudget: z.number().int().positive().optional(),
177
+ },
178
+ async ({ adminUserId, topic, format, register, tokenBudget }) => {
179
+ if (!accountId) return refuseNoAccount("voice-retrieve-conditioning");
180
+ const resolvedAdminUserId = adminUserId ?? resolveAdminUserId();
181
+ if (!resolvedAdminUserId) {
182
+ return {
183
+ content: [
184
+ {
185
+ type: "text" as const,
186
+ text: JSON.stringify({ styleCard: null, exemplars: [] }),
187
+ },
188
+ ],
189
+ };
190
+ }
191
+ try {
192
+ const result = await voiceRetrieveConditioning({
193
+ accountId,
194
+ adminUserId: resolvedAdminUserId,
195
+ brief: { topic, format, register },
196
+ tokenBudget,
197
+ });
198
+ return {
199
+ content: [
200
+ { type: "text" as const, text: JSON.stringify(result) },
201
+ ],
202
+ };
203
+ } catch (err) {
204
+ // Graceful degradation: callers expect {styleCard:null,exemplars:[]}
205
+ // on failure, never an error response.
206
+ process.stderr.write(
207
+ `[voice-retrieve] tool error: ${err instanceof Error ? err.message : String(err)}\n`,
208
+ );
209
+ return {
210
+ content: [
211
+ {
212
+ type: "text" as const,
213
+ text: JSON.stringify({ styleCard: null, exemplars: [] }),
214
+ },
215
+ ],
216
+ };
217
+ }
218
+ },
219
+ );
220
+
221
+ server.tool(
222
+ "voice-record-feedback",
223
+ "Capture an operator's edit on an agent draft. Writes :VoiceEdit linked to :VoiceProfile via :FEEDBACK_FOR. The calling agent supplies `intent` (one sentence describing what the operator changed and what voice preference it reveals); Task 424 moved the diff-intent summarisation into the agent's turn.",
224
+ {
225
+ adminUserId: z.string().optional(),
226
+ originalText: z.string().min(1),
227
+ editedText: z.string().min(1),
228
+ intent: z
229
+ .string()
230
+ .min(1)
231
+ .describe("One sentence summarising what changed and what voice preference it reveals — produced by the calling agent in-turn from originalText vs editedText (Task 424)."),
232
+ skill: z.string().optional().describe("Calling skill name, for provenance"),
233
+ brief: z.string().optional().describe("Drafting brief that produced the original"),
234
+ },
235
+ async ({ adminUserId, originalText, editedText, intent, skill, brief }) => {
236
+ if (!accountId) return refuseNoAccount("voice-record-feedback");
237
+ const resolvedAdminUserId = adminUserId ?? resolveAdminUserId();
238
+ if (!resolvedAdminUserId) {
239
+ return {
240
+ content: [
241
+ {
242
+ type: "text" as const,
243
+ text: "voice-record-feedback: adminUserId required (no ADMIN_USER_ID in spawn env).",
244
+ },
245
+ ],
246
+ isError: true,
247
+ };
248
+ }
249
+ try {
250
+ const result = await voiceRecordFeedback({
251
+ accountId,
252
+ adminUserId: resolvedAdminUserId,
253
+ originalText,
254
+ editedText,
255
+ intent,
256
+ context: { skill, brief },
257
+ });
258
+ return {
259
+ content: [
260
+ {
261
+ type: "text" as const,
262
+ text: `voice-record-feedback: editId=${result.editId} intent="${result.intent}" hadProfile=${result.hadProfile}`,
263
+ },
264
+ ],
265
+ };
266
+ } catch (err) {
267
+ return {
268
+ content: [
269
+ {
270
+ type: "text" as const,
271
+ text: `voice-record-feedback failed: ${err instanceof Error ? err.message : String(err)}`,
272
+ },
273
+ ],
274
+ isError: true,
275
+ };
276
+ }
277
+ },
278
+ );
279
+
280
+ const transport = new StdioServerTransport();
281
+ await server.connect(transport);
282
+
283
+ process.on("SIGTERM", async () => {
284
+ await closeDriver();
285
+ process.exit(0);
286
+ });
287
+
288
+ // Surface AUTHORSHIP_MODES for downstream callers / docs.
289
+ export { AUTHORSHIP_MODES };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Minimal neo4j driver wrapper for the writer-craft MCP server.
3
+ *
4
+ * Mirrors the public surface of `platform/plugins/memory/mcp/src/lib/neo4j.ts`:
5
+ * `getSession()` returns a session, `closeDriver()` releases the singleton.
6
+ * Password resolution follows the same `PLATFORM_ROOT/config/.neo4j-password`
7
+ * convention, with an explicit `NEO4J_URI` requirement to avoid silent
8
+ * cross-account orphaning.
9
+ */
10
+ import neo4j, { Driver, Session } from "neo4j-driver";
11
+ import { readFileSync } from "node:fs";
12
+ import { resolve } from "node:path";
13
+
14
+ let driver: Driver | null = null;
15
+
16
+ function readPassword(): string {
17
+ if (process.env.NEO4J_PASSWORD) return process.env.NEO4J_PASSWORD;
18
+ const passwordFile = resolve(
19
+ process.env.PLATFORM_ROOT ?? resolve(import.meta.dirname, "../../../../../platform"),
20
+ "config/.neo4j-password",
21
+ );
22
+ try {
23
+ return readFileSync(passwordFile, "utf-8").trim();
24
+ } catch {
25
+ throw new Error(
26
+ `Neo4j password not found. Expected at ${passwordFile} or in NEO4J_PASSWORD env var.`,
27
+ );
28
+ }
29
+ }
30
+
31
+ export function getDriver(): Driver {
32
+ if (!driver) {
33
+ const uri = process.env.NEO4J_URI;
34
+ if (!uri) {
35
+ throw new Error(
36
+ "[writer-craft] NEO4J_URI unset — refusing to default to bolt://localhost:7687",
37
+ );
38
+ }
39
+ const user = process.env.NEO4J_USER ?? "neo4j";
40
+ const password = readPassword();
41
+ process.stderr.write(`[writer-craft] resolved neo4j_uri=${uri}\n`);
42
+ driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
43
+ }
44
+ return driver;
45
+ }
46
+
47
+ export function getSession(): Session {
48
+ return getDriver().session();
49
+ }
50
+
51
+ export async function closeDriver(): Promise<void> {
52
+ if (driver) {
53
+ await driver.close();
54
+ driver = null;
55
+ }
56
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Shared corpus-filter clause for the voice-mirror tools.
3
+ *
4
+ * Imported by `voice-distil-profile` (count + sample walks) and
5
+ * `voice-retrieve-conditioning` (exemplar walk). The single load-bearing
6
+ * filter — when the corpus rules change, this is the only place to edit.
7
+ *
8
+ * Two predicates:
9
+ *
10
+ * 1. `authorshipMode IN ['human-only', 'human-led-agent-assisted']`.
11
+ * `human-only` is the operator's own writing verbatim;
12
+ * `human-led-agent-assisted` is operator-authored with light agent
13
+ * polish, which still carries voice signal (the operator chose the
14
+ * claims and the structure). Including this expands the available
15
+ * corpus to match how most modern writing actually happens.
16
+ *
17
+ * 2. Label is one of the four primary content labels OR is a
18
+ * conversation-document `:Section` chunk (unguarded chat voice from
19
+ * WhatsApp / Telegram / Signal / Granola / Otter / Circleback etc.
20
+ * archives). After the Task 324 collapse, conversation transcripts
21
+ * land as `:KnowledgeDocument` parents carrying `conversationIdentity`
22
+ * with plain `:Section` children — no `:Conversation` secondary label.
23
+ * Conversation-document sections are identified by their parent's
24
+ * `conversationIdentity` property via an EXISTS sub-pattern.
25
+ * Chat captures voice in a way email rarely does — this is the
26
+ * single highest-leverage corpus addition for voice fidelity.
27
+ *
28
+ * The clause expects `$accountId` to be bound in the calling cypher
29
+ * parameters. It does not bind any other parameters.
30
+ */
31
+ export const VOICE_CORPUS_WHERE = `n.accountId = $accountId
32
+ AND n.authorshipMode IN ['human-only', 'human-led-agent-assisted']
33
+ AND (
34
+ any(lbl IN labels(n) WHERE lbl IN ['KnowledgeDocument', 'Message', 'SocialPost'])
35
+ OR ('Section' IN labels(n) AND EXISTS {
36
+ MATCH (parent:KnowledgeDocument)-[:HAS_SECTION]->(n)
37
+ WHERE parent.conversationIdentity IS NOT NULL
38
+ })
39
+ )`;
40
+
41
+ /**
42
+ * The label set the tag tool accepts when stamping `authorshipMode`.
43
+ * Mirrors the label predicate inside VOICE_CORPUS_WHERE so the tag tool
44
+ * and the corpus walk stay in lockstep. The tag tool does not filter
45
+ * by authorshipMode (that's the property it's setting).
46
+ *
47
+ * `:Email` retired with Task 321 — email threads now land as
48
+ * `:KnowledgeDocument {source:'email'}` and are already covered.
49
+ */
50
+ export const TAGGABLE_PRIMARY_LABELS = [
51
+ "KnowledgeDocument",
52
+ "Message",
53
+ "SocialPost",
54
+ ] as const;