@rubytech/create-maxy-code 0.1.167 → 0.1.170

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 (136) 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 +0 -5
  4. package/payload/platform/plugins/docs/references/platform.md +1 -1
  5. package/payload/premium-plugins/.claude-plugin/marketplace.json +10 -0
  6. package/payload/premium-plugins/teaching/.claude-plugin/plugin.json +8 -0
  7. package/payload/premium-plugins/teaching/PLUGIN.md +58 -0
  8. package/payload/premium-plugins/teaching/skills/interactive-tutor/SKILL.md +59 -0
  9. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/assessment.md +70 -0
  10. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/classroom-conduct.md +43 -0
  11. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/teaching-modes.md +83 -0
  12. package/payload/premium-plugins/teaching/skills/lesson-planner/SKILL.md +48 -0
  13. package/payload/premium-plugins/teaching/skills/lesson-planner/references/context-gathering.md +41 -0
  14. package/payload/premium-plugins/teaching/skills/lesson-planner/references/plan-structure.md +94 -0
  15. package/payload/premium-plugins/teaching/skills/study-pack-builder/SKILL.md +52 -0
  16. package/payload/premium-plugins/teaching/skills/study-pack-builder/references/disaggregation.md +49 -0
  17. package/payload/premium-plugins/teaching/skills/study-pack-builder/references/materials.md +116 -0
  18. package/payload/premium-plugins/writer-craft/.claude-plugin/plugin.json +17 -0
  19. package/payload/premium-plugins/writer-craft/PLUGIN.md +130 -0
  20. package/payload/premium-plugins/writer-craft/agents/writer-craft--manuscript-reviewer.md +96 -0
  21. package/payload/premium-plugins/writer-craft/mcp/package.json +19 -0
  22. package/payload/premium-plugins/writer-craft/mcp/scripts/smoke.mjs +152 -0
  23. package/payload/premium-plugins/writer-craft/mcp/src/index.ts +289 -0
  24. package/payload/premium-plugins/writer-craft/mcp/src/lib/neo4j.ts +56 -0
  25. package/payload/premium-plugins/writer-craft/mcp/src/lib/voice-corpus.ts +54 -0
  26. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-distil-profile.ts +303 -0
  27. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-record-feedback.ts +114 -0
  28. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-retrieve-conditioning.ts +145 -0
  29. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-tag-content.ts +117 -0
  30. package/payload/premium-plugins/writer-craft/mcp/tsconfig.json +8 -0
  31. package/payload/premium-plugins/writer-craft/skills/citation-style/SKILL.md +94 -0
  32. package/payload/premium-plugins/writer-craft/skills/citation-style/references/book-and-chapter-models.md +77 -0
  33. package/payload/premium-plugins/writer-craft/skills/citation-style/references/citation-rules.md +103 -0
  34. package/payload/premium-plugins/writer-craft/skills/citation-style/references/journal-article-models.md +74 -0
  35. package/payload/premium-plugins/writer-craft/skills/citation-style/references/other-source-models.md +146 -0
  36. package/payload/premium-plugins/writer-craft/skills/citation-style/references/reference-list-rules.md +70 -0
  37. package/payload/premium-plugins/writer-craft/skills/editorial-practice/SKILL.md +108 -0
  38. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/copyediting.md +73 -0
  39. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/developmental-editing.md +85 -0
  40. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/genre-specific-editing.md +78 -0
  41. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/line-editing.md +55 -0
  42. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/self-editing.md +89 -0
  43. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/SKILL.md +114 -0
  44. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/audience-analysis.md +73 -0
  45. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/crafting-persuasive-story.md +76 -0
  46. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/persuasion-case-studies.md +67 -0
  47. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/transformation-framework.md +86 -0
  48. package/payload/premium-plugins/writer-craft/skills/point-of-view/SKILL.md +97 -0
  49. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/indirect-narration.md +72 -0
  50. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/pov-types-and-voice.md +91 -0
  51. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/protagonist-filter.md +71 -0
  52. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/tense-and-person.md +85 -0
  53. package/payload/premium-plugins/writer-craft/skills/prose-craft/SKILL.md +100 -0
  54. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/punctuation-and-grammar.md +72 -0
  55. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/repetition.md +71 -0
  56. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/sound-and-rhythm.md +64 -0
  57. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/word-economy.md +93 -0
  58. package/payload/premium-plugins/writer-craft/skills/reader-engagement/SKILL.md +100 -0
  59. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/cause-effect-setup-payoff.md +79 -0
  60. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/conflict-escalation.md +81 -0
  61. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/hooking-readers.md +67 -0
  62. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/neurochemistry-of-engagement.md +94 -0
  63. package/payload/premium-plugins/writer-craft/skills/review-manuscript/SKILL.md +111 -0
  64. package/payload/premium-plugins/writer-craft/skills/review-manuscript/references/review-manuscript-checklist.md +119 -0
  65. package/payload/premium-plugins/writer-craft/skills/review-prose/SKILL.md +99 -0
  66. package/payload/premium-plugins/writer-craft/skills/review-prose/references/prose-review-checklist.md +112 -0
  67. package/payload/premium-plugins/writer-craft/skills/review-scene/SKILL.md +99 -0
  68. package/payload/premium-plugins/writer-craft/skills/review-scene/references/scene-analysis-framework.md +95 -0
  69. package/payload/premium-plugins/writer-craft/skills/story-architecture/SKILL.md +106 -0
  70. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/blueprinting-and-scene-cards.md +118 -0
  71. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/inner-issue-and-protagonist-goal.md +66 -0
  72. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/misbelief-desire-worldview.md +87 -0
  73. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/origin-scenes-and-escalation.md +82 -0
  74. package/payload/premium-plugins/writer-craft/skills/story-blueprint/SKILL.md +133 -0
  75. package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-exercises.md +118 -0
  76. package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-process.md +128 -0
  77. package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +166 -0
  78. package/payload/server/{chunk-3TRIXQSJ.js → chunk-L2YK2VK3.js} +17 -29
  79. package/payload/server/maxy-edge.js +1 -1
  80. package/payload/server/server.js +1 -1
  81. package/payload/platform/plugins/venture-studio/.claude-plugin/plugin.json +0 -8
  82. package/payload/platform/plugins/venture-studio/PLUGIN.md +0 -119
  83. package/payload/platform/plugins/venture-studio/bin/scaffold.sh +0 -116
  84. package/payload/platform/plugins/venture-studio/skills/brand-pack/SKILL.md +0 -256
  85. package/payload/platform/plugins/venture-studio/skills/brand-pack/references/color-psychology.md +0 -118
  86. package/payload/platform/plugins/venture-studio/skills/investor-data-room/SKILL.md +0 -376
  87. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/business-plan-template.md +0 -64
  88. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/compliance-research-checklist.md +0 -53
  89. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/data-room-structure.md +0 -88
  90. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/deck-blueprint-template.md +0 -39
  91. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/design-tokens-application.md +0 -79
  92. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/html-pdf-pipeline.md +0 -236
  93. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/internal-workings-scrub.md +0 -33
  94. package/payload/platform/plugins/venture-studio/skills/investor-data-room/references/termsheet-template.md +0 -88
  95. package/payload/platform/plugins/venture-studio/skills/investor-data-room/templates/prospectus/index.html +0 -1565
  96. package/payload/platform/plugins/venture-studio/skills/investor-data-room/templates/prospectus/render-pdf.mjs +0 -91
  97. package/payload/platform/plugins/venture-studio/skills/investor-data-room/templates/prospectus/term_sheet.html +0 -715
  98. package/payload/platform/plugins/venture-studio/skills/office-hours/SKILL.md +0 -587
  99. package/payload/platform/plugins/venture-studio/skills/prototype-host/SKILL.md +0 -179
  100. package/payload/platform/plugins/venture-studio/skills/prototype-host/references/cloudflared-ingress-edit.md +0 -81
  101. package/payload/platform/plugins/venture-studio/skills/prototype-host/references/scaffold-frameworks.md +0 -60
  102. package/payload/platform/plugins/venture-studio/skills/prototype-host/references/systemd-user-service.md +0 -104
  103. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/SKILL.md +0 -336
  104. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/aarrr-metrics.md +0 -275
  105. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/assumption-testing.md +0 -93
  106. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/boolean-search.md +0 -308
  107. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/build-measure-learn.md +0 -262
  108. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/business-model-canvas.md +0 -171
  109. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/commitment-signals.md +0 -246
  110. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/design-thinking.md +0 -183
  111. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/earlyvangelist.md +0 -190
  112. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/first-principles.md +0 -58
  113. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/fishbone.md +0 -114
  114. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/five-whys.md +0 -43
  115. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/ice-scoring.md +0 -237
  116. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/innovation-accounting.md +0 -290
  117. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/jtbd.md +0 -105
  118. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/landing-page.md +0 -361
  119. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/market-type.md +0 -167
  120. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/mom-test.md +0 -193
  121. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/mvp-types.md +0 -200
  122. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/og-images.md +0 -239
  123. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/pareto.md +0 -103
  124. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/persona-development.md +0 -291
  125. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/pivot-types.md +0 -225
  126. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/positioning-statement.md +0 -179
  127. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/prd.md +0 -363
  128. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/pre-mortem.md +0 -74
  129. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/problem-validation.md +0 -253
  130. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/product-market-fit.md +0 -256
  131. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/research-synthesis.md +0 -276
  132. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/three-engines-of-growth.md +0 -248
  133. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/validation-tests.md +0 -89
  134. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/value-proposition-canvas.md +0 -121
  135. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/win-loss-analysis.md +0 -242
  136. package/payload/platform/plugins/venture-studio/skills/zero-to-prototype/references/workflow-mapping.md +0 -271
@@ -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;