opencode-novel 0.0.1

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 (196) hide show
  1. package/README.md +110 -0
  2. package/assets/templates/bible-glossary.md +4 -0
  3. package/assets/templates/bible-rules.md +5 -0
  4. package/assets/templates/bible-world.md +8 -0
  5. package/assets/templates/chapter.md +21 -0
  6. package/assets/templates/character.md +27 -0
  7. package/assets/templates/faction.md +14 -0
  8. package/assets/templates/location.md +11 -0
  9. package/assets/templates/thread.md +16 -0
  10. package/dist/agents/editor.d.ts +2 -0
  11. package/dist/agents/experts.d.ts +13 -0
  12. package/dist/agents/index.d.ts +7 -0
  13. package/dist/agents/muse.d.ts +2 -0
  14. package/dist/agents/novel.d.ts +2 -0
  15. package/dist/agents/security.d.ts +1 -0
  16. package/dist/agents/sentinel.d.ts +2 -0
  17. package/dist/agents/types.d.ts +3 -0
  18. package/dist/cli.d.ts +2 -0
  19. package/dist/cli.js +3716 -0
  20. package/dist/config/defaults.d.ts +2 -0
  21. package/dist/config/load.d.ts +16 -0
  22. package/dist/config/schema.d.ts +203 -0
  23. package/dist/config/types.d.ts +5 -0
  24. package/dist/features/builtin-commands/commands.d.ts +2 -0
  25. package/dist/features/builtin-commands/index.d.ts +2 -0
  26. package/dist/features/builtin-commands/templates/novel-apply-candidates.d.ts +1 -0
  27. package/dist/features/builtin-commands/templates/novel-bible.d.ts +1 -0
  28. package/dist/features/builtin-commands/templates/novel-bootstrap.d.ts +1 -0
  29. package/dist/features/builtin-commands/templates/novel-chapter-draft.d.ts +1 -0
  30. package/dist/features/builtin-commands/templates/novel-chapter-plan.d.ts +1 -0
  31. package/dist/features/builtin-commands/templates/novel-chapter-review.d.ts +1 -0
  32. package/dist/features/builtin-commands/templates/novel-character-report.d.ts +1 -0
  33. package/dist/features/builtin-commands/templates/novel-character.d.ts +1 -0
  34. package/dist/features/builtin-commands/templates/novel-config-check.d.ts +1 -0
  35. package/dist/features/builtin-commands/templates/novel-continuation.d.ts +1 -0
  36. package/dist/features/builtin-commands/templates/novel-continuity-check.d.ts +1 -0
  37. package/dist/features/builtin-commands/templates/novel-entities-audit.d.ts +1 -0
  38. package/dist/features/builtin-commands/templates/novel-export.d.ts +1 -0
  39. package/dist/features/builtin-commands/templates/novel-extract-entities.d.ts +1 -0
  40. package/dist/features/builtin-commands/templates/novel-faction.d.ts +1 -0
  41. package/dist/features/builtin-commands/templates/novel-foreshadowing-audit.d.ts +1 -0
  42. package/dist/features/builtin-commands/templates/novel-graph.d.ts +1 -0
  43. package/dist/features/builtin-commands/templates/novel-import.d.ts +1 -0
  44. package/dist/features/builtin-commands/templates/novel-index.d.ts +1 -0
  45. package/dist/features/builtin-commands/templates/novel-init.d.ts +1 -0
  46. package/dist/features/builtin-commands/templates/novel-outline.d.ts +1 -0
  47. package/dist/features/builtin-commands/templates/novel-polish.d.ts +1 -0
  48. package/dist/features/builtin-commands/templates/novel-rewrite.d.ts +1 -0
  49. package/dist/features/builtin-commands/templates/novel-snapshot.d.ts +1 -0
  50. package/dist/features/builtin-commands/templates/novel-style-check.d.ts +1 -0
  51. package/dist/features/builtin-commands/templates/novel-style-guide.d.ts +1 -0
  52. package/dist/features/builtin-commands/templates/novel-summary.d.ts +1 -0
  53. package/dist/features/builtin-commands/templates/novel-thread.d.ts +1 -0
  54. package/dist/features/builtin-commands/types.d.ts +11 -0
  55. package/dist/features/builtin-skills/artifacts.d.ts +16 -0
  56. package/dist/features/builtin-skills/index.d.ts +4 -0
  57. package/dist/features/builtin-skills/skills/audience-classifier.d.ts +1 -0
  58. package/dist/features/builtin-skills/skills/emotion-classifier.d.ts +1 -0
  59. package/dist/features/builtin-skills/skills/genre-classifier.d.ts +1 -0
  60. package/dist/features/builtin-skills/skills/market-tagger.d.ts +1 -0
  61. package/dist/features/builtin-skills/skills/novel-character-expert.d.ts +1 -0
  62. package/dist/features/builtin-skills/skills/novel-continuation-expert.d.ts +1 -0
  63. package/dist/features/builtin-skills/skills/novel-continuity-sentinel.d.ts +1 -0
  64. package/dist/features/builtin-skills/skills/novel-entity-extractor.d.ts +1 -0
  65. package/dist/features/builtin-skills/skills/novel-faction-relations.d.ts +1 -0
  66. package/dist/features/builtin-skills/skills/novel-flaw-finder.d.ts +1 -0
  67. package/dist/features/builtin-skills/skills/novel-foreshadowing-unresolved.d.ts +1 -0
  68. package/dist/features/builtin-skills/skills/novel-oracle.d.ts +1 -0
  69. package/dist/features/builtin-skills/skills/novel-polish-expert.d.ts +1 -0
  70. package/dist/features/builtin-skills/skills/novel-summary-expert.d.ts +1 -0
  71. package/dist/features/builtin-skills/skills/novel-timeline-keeper.d.ts +1 -0
  72. package/dist/features/builtin-skills/skills/novel-worldbible-keeper.d.ts +1 -0
  73. package/dist/features/builtin-skills/skills/profile-aggregator.d.ts +1 -0
  74. package/dist/features/builtin-skills/skills/structure-classifier.d.ts +1 -0
  75. package/dist/features/builtin-skills/skills/taxonomy-registry.d.ts +1 -0
  76. package/dist/features/builtin-skills/skills/trope-classifier.d.ts +1 -0
  77. package/dist/features/builtin-skills/skills.d.ts +2 -0
  78. package/dist/features/builtin-skills/taxonomy/index.d.ts +3 -0
  79. package/dist/features/builtin-skills/taxonomy/references.d.ts +8 -0
  80. package/dist/features/builtin-skills/taxonomy/registry.d.ts +2 -0
  81. package/dist/features/builtin-skills/taxonomy/types.d.ts +42 -0
  82. package/dist/features/builtin-skills/types.d.ts +11 -0
  83. package/dist/index.d.ts +3 -0
  84. package/dist/index.js +61966 -0
  85. package/dist/novel.schema.json +904 -0
  86. package/dist/plugin-handlers/config-handler.d.ts +9 -0
  87. package/dist/plugin-handlers/index.d.ts +1 -0
  88. package/dist/shared/errors/diagnostics.d.ts +19 -0
  89. package/dist/shared/fs/paths.d.ts +3 -0
  90. package/dist/shared/fs/read.d.ts +5 -0
  91. package/dist/shared/fs/write.d.ts +8 -0
  92. package/dist/shared/hashing/hash8.d.ts +1 -0
  93. package/dist/shared/hashing/sha256.d.ts +2 -0
  94. package/dist/shared/markdown/frontmatter.d.ts +15 -0
  95. package/dist/shared/opencode/artifacts.d.ts +12 -0
  96. package/dist/shared/strings/chinese-number.d.ts +1 -0
  97. package/dist/shared/strings/slug.d.ts +1 -0
  98. package/dist/shared/strings/text-encoding.d.ts +2 -0
  99. package/dist/shared/tool-output.d.ts +6 -0
  100. package/dist/tools/novel-apply-candidates/index.d.ts +2 -0
  101. package/dist/tools/novel-apply-candidates/render.d.ts +2 -0
  102. package/dist/tools/novel-apply-candidates/tool.d.ts +6 -0
  103. package/dist/tools/novel-apply-candidates/types.d.ts +52 -0
  104. package/dist/tools/novel-bible/index.d.ts +2 -0
  105. package/dist/tools/novel-bible/render.d.ts +3 -0
  106. package/dist/tools/novel-bible/tool.d.ts +6 -0
  107. package/dist/tools/novel-bible/types.d.ts +26 -0
  108. package/dist/tools/novel-bootstrap/index.d.ts +2 -0
  109. package/dist/tools/novel-bootstrap/tool.d.ts +6 -0
  110. package/dist/tools/novel-bootstrap/types.d.ts +38 -0
  111. package/dist/tools/novel-candidates-write/index.d.ts +2 -0
  112. package/dist/tools/novel-candidates-write/tool.d.ts +6 -0
  113. package/dist/tools/novel-candidates-write/types.d.ts +13 -0
  114. package/dist/tools/novel-chapter-plan/index.d.ts +2 -0
  115. package/dist/tools/novel-chapter-plan/tool.d.ts +6 -0
  116. package/dist/tools/novel-chapter-plan/types.d.ts +32 -0
  117. package/dist/tools/novel-character-report/index.d.ts +2 -0
  118. package/dist/tools/novel-character-report/render.d.ts +2 -0
  119. package/dist/tools/novel-character-report/tool.d.ts +6 -0
  120. package/dist/tools/novel-character-report/types.d.ts +23 -0
  121. package/dist/tools/novel-config-check/index.d.ts +2 -0
  122. package/dist/tools/novel-config-check/tool.d.ts +4 -0
  123. package/dist/tools/novel-config-check/types.d.ts +15 -0
  124. package/dist/tools/novel-context-pack/index.d.ts +2 -0
  125. package/dist/tools/novel-context-pack/tool.d.ts +6 -0
  126. package/dist/tools/novel-context-pack/types.d.ts +37 -0
  127. package/dist/tools/novel-continuity-check/index.d.ts +2 -0
  128. package/dist/tools/novel-continuity-check/render.d.ts +9 -0
  129. package/dist/tools/novel-continuity-check/tool.d.ts +6 -0
  130. package/dist/tools/novel-continuity-check/types.d.ts +37 -0
  131. package/dist/tools/novel-entity-gaps/index.d.ts +2 -0
  132. package/dist/tools/novel-entity-gaps/render.d.ts +5 -0
  133. package/dist/tools/novel-entity-gaps/tool.d.ts +6 -0
  134. package/dist/tools/novel-entity-gaps/types.d.ts +33 -0
  135. package/dist/tools/novel-export/docx.d.ts +5 -0
  136. package/dist/tools/novel-export/epub.d.ts +10 -0
  137. package/dist/tools/novel-export/index.d.ts +2 -0
  138. package/dist/tools/novel-export/preflight.d.ts +19 -0
  139. package/dist/tools/novel-export/render.d.ts +6 -0
  140. package/dist/tools/novel-export/tool.d.ts +6 -0
  141. package/dist/tools/novel-export/types.d.ts +109 -0
  142. package/dist/tools/novel-foreshadowing-audit/index.d.ts +2 -0
  143. package/dist/tools/novel-foreshadowing-audit/render.d.ts +5 -0
  144. package/dist/tools/novel-foreshadowing-audit/tool.d.ts +6 -0
  145. package/dist/tools/novel-foreshadowing-audit/types.d.ts +40 -0
  146. package/dist/tools/novel-graph/index.d.ts +2 -0
  147. package/dist/tools/novel-graph/render.d.ts +5 -0
  148. package/dist/tools/novel-graph/tool.d.ts +6 -0
  149. package/dist/tools/novel-graph/types.d.ts +21 -0
  150. package/dist/tools/novel-import/index.d.ts +2 -0
  151. package/dist/tools/novel-import/tool.d.ts +7 -0
  152. package/dist/tools/novel-import/types.d.ts +47 -0
  153. package/dist/tools/novel-index/index.d.ts +2 -0
  154. package/dist/tools/novel-index/render.d.ts +35 -0
  155. package/dist/tools/novel-index/tool.d.ts +6 -0
  156. package/dist/tools/novel-index/types.d.ts +41 -0
  157. package/dist/tools/novel-outline/index.d.ts +2 -0
  158. package/dist/tools/novel-outline/tool.d.ts +6 -0
  159. package/dist/tools/novel-outline/types.d.ts +37 -0
  160. package/dist/tools/novel-scaffold/index.d.ts +2 -0
  161. package/dist/tools/novel-scaffold/scaffold.d.ts +18 -0
  162. package/dist/tools/novel-scaffold/templates.d.ts +5 -0
  163. package/dist/tools/novel-scaffold/tool.d.ts +6 -0
  164. package/dist/tools/novel-scaffold/types.d.ts +19 -0
  165. package/dist/tools/novel-scan/helpers.d.ts +88 -0
  166. package/dist/tools/novel-scan/index.d.ts +3 -0
  167. package/dist/tools/novel-scan/scan.d.ts +17 -0
  168. package/dist/tools/novel-scan/tool.d.ts +6 -0
  169. package/dist/tools/novel-scan/types.d.ts +106 -0
  170. package/dist/tools/novel-scene-check/index.d.ts +2 -0
  171. package/dist/tools/novel-scene-check/render.d.ts +11 -0
  172. package/dist/tools/novel-scene-check/tool.d.ts +6 -0
  173. package/dist/tools/novel-scene-check/types.d.ts +38 -0
  174. package/dist/tools/novel-setup/index.d.ts +2 -0
  175. package/dist/tools/novel-setup/tool.d.ts +6 -0
  176. package/dist/tools/novel-setup/types.d.ts +35 -0
  177. package/dist/tools/novel-snapshot/index.d.ts +2 -0
  178. package/dist/tools/novel-snapshot/tool.d.ts +6 -0
  179. package/dist/tools/novel-snapshot/types.d.ts +26 -0
  180. package/dist/tools/novel-structure-check/index.d.ts +2 -0
  181. package/dist/tools/novel-structure-check/render.d.ts +14 -0
  182. package/dist/tools/novel-structure-check/tool.d.ts +6 -0
  183. package/dist/tools/novel-structure-check/types.d.ts +42 -0
  184. package/dist/tools/novel-style-check/index.d.ts +2 -0
  185. package/dist/tools/novel-style-check/render.d.ts +8 -0
  186. package/dist/tools/novel-style-check/tool.d.ts +6 -0
  187. package/dist/tools/novel-style-check/types.d.ts +39 -0
  188. package/dist/tools/skill/index.d.ts +3 -0
  189. package/dist/tools/skill/loader.d.ts +5 -0
  190. package/dist/tools/skill/tool.d.ts +5 -0
  191. package/dist/tools/skill/types.d.ts +14 -0
  192. package/dist/tools/slashcommand/index.d.ts +3 -0
  193. package/dist/tools/slashcommand/loader.d.ts +5 -0
  194. package/dist/tools/slashcommand/tool.d.ts +6 -0
  195. package/dist/tools/slashcommand/types.d.ts +14 -0
  196. package/package.json +55 -0
@@ -0,0 +1,109 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ export type NovelExportFormat = "md" | "html" | "epub" | "docx";
3
+ export type NovelChapterOrder = "by_id" | "by_timeline" | "custom";
4
+ export type NovelDocxTemplate = "default" | "manuscript";
5
+ export type NovelExportPreflightCheck = "index" | "continuity" | "foreshadowing" | "style" | "structure" | "scene" | "arc" | "pacing";
6
+ export type NovelExportPreflightFailOn = "error" | "warn";
7
+ export type NovelExportArgs = {
8
+ rootDir?: string;
9
+ manuscriptDir?: string;
10
+ format?: NovelExportFormat;
11
+ outputDir?: string;
12
+ title?: string;
13
+ chapterOrder?: NovelChapterOrder;
14
+ customOrder?: string[];
15
+ includeFrontmatter?: boolean;
16
+ writeFile?: boolean;
17
+ docxTemplate?: NovelDocxTemplate;
18
+ preflight?: boolean;
19
+ preflightChecks?: NovelExportPreflightCheck[];
20
+ preflightFailOn?: NovelExportPreflightFailOn;
21
+ };
22
+ export type NovelExportPreflightSummary = {
23
+ enabled: boolean;
24
+ blocked: boolean;
25
+ checks: NovelExportPreflightCheck[];
26
+ failOn: NovelExportPreflightFailOn;
27
+ stats: {
28
+ errors: number;
29
+ warns: number;
30
+ infos: number;
31
+ };
32
+ reports: {
33
+ indexOutputDir?: string;
34
+ continuityReportPath?: string;
35
+ foreshadowingReportPath?: string;
36
+ styleReportPath?: string;
37
+ structureReportPath?: string;
38
+ sceneReportPath?: string;
39
+ arcReportPath?: string;
40
+ pacingReportPath?: string;
41
+ };
42
+ };
43
+ export type NovelExportManifest = {
44
+ version: 1;
45
+ title: string;
46
+ formats: NovelExportFormat[];
47
+ chapterOrder: NovelChapterOrder;
48
+ includeFrontmatter: boolean;
49
+ docxTemplate?: NovelDocxTemplate;
50
+ preflight?: {
51
+ enabled: boolean;
52
+ blocked: boolean;
53
+ failOn: NovelExportPreflightFailOn;
54
+ checks: NovelExportPreflightCheck[];
55
+ };
56
+ chapters: Array<{
57
+ chapter_id: string;
58
+ path: string;
59
+ title?: string;
60
+ contentSha256: string;
61
+ }>;
62
+ outputs: Array<{
63
+ format: NovelExportFormat;
64
+ outputPath: string;
65
+ contentSha256: string;
66
+ }>;
67
+ };
68
+ export type NovelExportResultJsonV1 = {
69
+ version: 1;
70
+ format: NovelExportFormat;
71
+ outputPath?: string;
72
+ manifestPath?: string;
73
+ docxTemplate?: NovelDocxTemplate;
74
+ chapters: {
75
+ chapter_id: string;
76
+ title?: string;
77
+ path: string;
78
+ }[];
79
+ stats: {
80
+ chapters: number;
81
+ durationMs: number;
82
+ };
83
+ preflight?: NovelExportPreflightSummary;
84
+ nextSteps?: string[];
85
+ diagnostics: Diagnostic[];
86
+ };
87
+ export type NovelExportResultJsonV2 = {
88
+ version: 2;
89
+ formats: NovelExportFormat[];
90
+ outputs: {
91
+ format: NovelExportFormat;
92
+ outputPath?: string;
93
+ }[];
94
+ manifestPath?: string;
95
+ docxTemplate?: NovelDocxTemplate;
96
+ chapters: {
97
+ chapter_id: string;
98
+ title?: string;
99
+ path: string;
100
+ }[];
101
+ stats: {
102
+ chapters: number;
103
+ durationMs: number;
104
+ };
105
+ preflight?: NovelExportPreflightSummary;
106
+ nextSteps?: string[];
107
+ diagnostics: Diagnostic[];
108
+ };
109
+ export type NovelExportResultJson = NovelExportResultJsonV1 | NovelExportResultJsonV2;
@@ -0,0 +1,2 @@
1
+ export { createNovelForeshadowingAuditTool } from "./tool";
2
+ export type { NovelForeshadowingArgs, NovelForeshadowingResultJson, ThreadAuditItem, } from "./types";
@@ -0,0 +1,5 @@
1
+ import type { ThreadAuditItem } from "./types";
2
+ export declare function renderForeshadowingAuditMd(options: {
3
+ items: ThreadAuditItem[];
4
+ stats: Record<string, number>;
5
+ }): string;
@@ -0,0 +1,6 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ export declare function createNovelForeshadowingAuditTool(deps: {
4
+ projectRoot: string;
5
+ config: NovelConfig;
6
+ }): ToolDefinition;
@@ -0,0 +1,40 @@
1
+ import type { Diagnostic, DiagnosticEvidence } from "../../shared/errors/diagnostics";
2
+ export type NovelForeshadowingArgs = {
3
+ rootDir?: string;
4
+ manuscriptDir?: string;
5
+ outputDir?: string;
6
+ writeReport?: boolean;
7
+ strictMode?: boolean;
8
+ };
9
+ export type ThreadAuditItem = {
10
+ thread_id: string;
11
+ path: string;
12
+ type?: string;
13
+ status?: string;
14
+ opened_in?: string;
15
+ expected_close_by?: string;
16
+ closed_in?: string | null;
17
+ issues: {
18
+ severity: "error" | "warn" | "info";
19
+ code: string;
20
+ message: string;
21
+ evidence?: DiagnosticEvidence[];
22
+ suggestedFix?: string;
23
+ repro?: string;
24
+ }[];
25
+ suggestedNextStep?: string;
26
+ };
27
+ export type NovelForeshadowingResultJson = {
28
+ version: 1;
29
+ reportPath?: string;
30
+ stats: {
31
+ open: number;
32
+ in_progress: number;
33
+ closed: number;
34
+ abandoned: number;
35
+ durationMs: number;
36
+ };
37
+ items: ThreadAuditItem[];
38
+ nextSteps?: string[];
39
+ diagnostics: Diagnostic[];
40
+ };
@@ -0,0 +1,2 @@
1
+ export { createNovelGraphTool } from "./tool";
2
+ export type { NovelGraphArgs, NovelGraphKind, NovelGraphResultJson } from "./types";
@@ -0,0 +1,5 @@
1
+ export declare function renderMermaidGraphTd(options: {
2
+ title: string;
3
+ nodes: string[];
4
+ edges: string[];
5
+ }): string;
@@ -0,0 +1,6 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ export declare function createNovelGraphTool(deps: {
4
+ projectRoot: string;
5
+ config: NovelConfig;
6
+ }): ToolDefinition;
@@ -0,0 +1,21 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ export type NovelGraphKind = "relationships" | "factions";
3
+ export type NovelGraphArgs = {
4
+ rootDir?: string;
5
+ manuscriptDir?: string;
6
+ outputDir?: string;
7
+ kind: NovelGraphKind;
8
+ writeFile?: boolean;
9
+ preferExplicitRelations?: boolean;
10
+ cooccurrenceMinWeight?: number;
11
+ };
12
+ export type NovelGraphResultJson = {
13
+ version: 1;
14
+ kind: NovelGraphKind;
15
+ graphPath?: string;
16
+ stats: {
17
+ nodes: number;
18
+ edges: number;
19
+ };
20
+ diagnostics: Diagnostic[];
21
+ };
@@ -0,0 +1,2 @@
1
+ export { createNovelImportTool } from "./tool";
2
+ export type { ImportMapItem, NovelImportArgs, NovelImportMode, NovelImportResultJson, } from "./types";
@@ -0,0 +1,7 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ /** 创建小说导入工具定义。 */
4
+ export declare function createNovelImportTool(deps: {
5
+ projectRoot: string;
6
+ config: NovelConfig;
7
+ }): ToolDefinition;
@@ -0,0 +1,47 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ import type { TextEncoding } from "../../shared/strings/text-encoding";
3
+ export type NovelImportMode = "copy" | "analyze";
4
+ export type NovelImportArgs = {
5
+ rootDir?: string;
6
+ fromDir?: string;
7
+ mode?: NovelImportMode;
8
+ manuscriptDir?: string;
9
+ encoding?: TextEncoding;
10
+ includeGlobs?: string[];
11
+ excludeGlobs?: string[];
12
+ writeConfigJsonc?: boolean;
13
+ writeReport?: boolean;
14
+ };
15
+ export type ImportMapItem = {
16
+ chapter_id: string;
17
+ title?: string;
18
+ source_path: string;
19
+ source_type: "md" | "txt";
20
+ source_heading_line: number;
21
+ source_range: {
22
+ startLine: number;
23
+ endLine: number;
24
+ };
25
+ output_path: string;
26
+ warnings?: string[];
27
+ };
28
+ export type NovelImportResultJson = {
29
+ version: 1;
30
+ mode: NovelImportMode;
31
+ fromDir: string;
32
+ manuscriptDir: string;
33
+ writtenChapters: string[];
34
+ conflicts: {
35
+ chapter_id: string;
36
+ existing: string;
37
+ written: string;
38
+ }[];
39
+ unclassified: {
40
+ source_path: string;
41
+ reason: string;
42
+ }[];
43
+ reportPath?: string;
44
+ importMapPath?: string;
45
+ nextSteps?: string[];
46
+ diagnostics: Diagnostic[];
47
+ };
@@ -0,0 +1,2 @@
1
+ export { createNovelIndexTool } from "./tool";
2
+ export type { NovelIndexArgs, NovelIndexResultJson } from "./types";
@@ -0,0 +1,35 @@
1
+ import type { ChapterEntity, CharacterEntity, ThreadEntity } from "../novel-scan/types";
2
+ export declare function renderIndexMd(options: {
3
+ chapters: ChapterEntity[];
4
+ characters: CharacterEntity[];
5
+ threads: Array<ThreadEntity & {
6
+ opened_in?: string;
7
+ expected_close_by?: string;
8
+ closed_in?: string | null;
9
+ }>;
10
+ factions: Array<{
11
+ id: string;
12
+ name?: string;
13
+ appearances: number;
14
+ }>;
15
+ locations: Array<{
16
+ id: string;
17
+ name?: string;
18
+ appearances: number;
19
+ }>;
20
+ characterAppearances: Map<string, {
21
+ count: number;
22
+ first?: string;
23
+ last?: string;
24
+ }>;
25
+ }): string;
26
+ export declare function renderTimelineMd(options: {
27
+ chapters: ChapterEntity[];
28
+ }): string;
29
+ export declare function renderThreadsReportMd(options: {
30
+ threads: Array<ThreadEntity & {
31
+ opened_in?: string;
32
+ expected_close_by?: string;
33
+ closed_in?: string | null;
34
+ }>;
35
+ }): string;
@@ -0,0 +1,6 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ export declare function createNovelIndexTool(deps: {
4
+ projectRoot: string;
5
+ config: NovelConfig;
6
+ }): ToolDefinition;
@@ -0,0 +1,41 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ export type NovelIndexArgs = {
3
+ rootDir?: string;
4
+ manuscriptDir?: string;
5
+ outputDir?: string;
6
+ writeDerivedFiles?: boolean;
7
+ forceWrite?: boolean;
8
+ scanMode?: "full" | "incremental";
9
+ writeCache?: boolean;
10
+ };
11
+ export type NovelIndexResultJson = {
12
+ version: 1;
13
+ generatedAt: string;
14
+ scanScope: {
15
+ manuscriptDir: string;
16
+ mode: "full" | "incremental";
17
+ };
18
+ outputDir: string;
19
+ writtenFiles: string[];
20
+ skippedFiles: string[];
21
+ stats: {
22
+ chapters: number;
23
+ characters: number;
24
+ threads: number;
25
+ durationMs: number;
26
+ scan: {
27
+ filesScanned: number;
28
+ durationMs: number;
29
+ cache: {
30
+ mode: "full" | "incremental";
31
+ loaded: boolean;
32
+ written: boolean;
33
+ fastHits: number;
34
+ hashHits: number;
35
+ misses: number;
36
+ };
37
+ };
38
+ };
39
+ nextSteps?: string[];
40
+ diagnostics: Diagnostic[];
41
+ };
@@ -0,0 +1,2 @@
1
+ export { createNovelOutlineTool } from "./tool";
2
+ export type { NovelOutlineArgs, NovelOutlineMode, NovelOutlineResultJson, OutlineAct, OutlineBeat, OutlineJson, } from "./types";
@@ -0,0 +1,6 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ export declare function createNovelOutlineTool(deps: {
4
+ projectRoot: string;
5
+ config: NovelConfig;
6
+ }): ToolDefinition;
@@ -0,0 +1,37 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ export type NovelOutlineMode = "three_act" | "beat_sheet";
3
+ export type NovelOutlineArgs = {
4
+ rootDir?: string;
5
+ title: string;
6
+ mode?: NovelOutlineMode;
7
+ acts?: number;
8
+ outputPath?: string;
9
+ writeFile?: boolean;
10
+ };
11
+ export type OutlineBeat = {
12
+ beat_id: string;
13
+ label: string;
14
+ goal: string;
15
+ risk: string;
16
+ expectedChapterSpan: string;
17
+ };
18
+ export type OutlineAct = {
19
+ act: number;
20
+ purpose: string;
21
+ conflictUpgrade: string;
22
+ beats: OutlineBeat[];
23
+ };
24
+ export type OutlineJson = {
25
+ title: string;
26
+ mode: NovelOutlineMode;
27
+ generatedAt: string;
28
+ requiredBeats: string[];
29
+ acts: OutlineAct[];
30
+ processChecklist: string[];
31
+ };
32
+ export type NovelOutlineResultJson = {
33
+ version: 1;
34
+ outlinePath?: string;
35
+ outlineJson: OutlineJson;
36
+ diagnostics: Diagnostic[];
37
+ };
@@ -0,0 +1,2 @@
1
+ export { createNovelScaffoldTool } from "./tool";
2
+ export type { NovelScaffoldArgs, NovelScaffoldResultJson } from "./types";
@@ -0,0 +1,18 @@
1
+ import type { NovelConfig } from "../../config/schema";
2
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
3
+ export declare function ensureNovelScaffold(options: {
4
+ rootDir: string;
5
+ manuscriptDirName: string;
6
+ config: NovelConfig;
7
+ bookTitle?: string;
8
+ writeConfigJsonc?: boolean;
9
+ writeTemplates?: boolean;
10
+ forceOverwriteTemplates?: boolean;
11
+ }): {
12
+ manuscriptDir: string;
13
+ createdDirs: string[];
14
+ writtenFiles: string[];
15
+ skippedExisting: string[];
16
+ configPath?: string;
17
+ diagnostics: Diagnostic[];
18
+ };
@@ -0,0 +1,5 @@
1
+ export declare function createWorldTemplate(bookTitle?: string): string;
2
+ export declare const RULES_TEMPLATE = "# \u89C4\u5219\u6761\u6B3E\uFF08Rules\uFF09\n\n## \u89C4\u5219\u6761\u6B3E\n1. R-001\uFF1A\u2026\u2026\n2. R-002\uFF1A\u2026\u2026\n";
3
+ export declare const GLOSSARY_TEMPLATE = "# \u540D\u8BCD\u8868\uFF08Glossary\uFF09\n\n- \u8BCD\u6761\uFF1A\u89E3\u91CA\n";
4
+ export declare const CHARACTERS_README_TEMPLATE = "# \u89D2\u8272\u76EE\u5F55\u8BF4\u660E\n\n\u6BCF\u4E2A\u89D2\u8272\u4E00\u4E2A\u6587\u4EF6\uFF1A`<id>.md`\uFF0C\u5EFA\u8BAE\u5305\u542B frontmatter\uFF1A\n\n- id\uFF08\u5FC5\u586B\uFF09\n- name / alias\n- motivation / desire\n- arc\uFF08\u9636\u6BB5\u4E0E\u8F6C\u6298\uFF09\n- voice\uFF08\u53E3\u7656/\u53E5\u5F0F/\u7981\u7528\u8BCD\uFF09\n- relationships\uFF08\u5173\u7CFB\uFF09\n";
5
+ export declare const THREADS_README_TEMPLATE = "# \u7EBF\u7A0B\u76EE\u5F55\u8BF4\u660E\n\n\u6BCF\u4E2A\u4F0F\u7B14/\u627F\u8BFA\u4E00\u4E2A\u6587\u4EF6\uFF1A`<thread_id>.md`\uFF0C\u5EFA\u8BAE\u5305\u542B frontmatter\uFF1A\n\n- thread_id\uFF08\u5FC5\u586B\uFF09\n- type / status\n- opened_in / expected_close_by / close_plan / closed_in\n";
@@ -0,0 +1,6 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ export declare function createNovelScaffoldTool(deps: {
4
+ projectRoot: string;
5
+ config: NovelConfig;
6
+ }): ToolDefinition;
@@ -0,0 +1,19 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ export type NovelScaffoldArgs = {
3
+ rootDir?: string;
4
+ manuscriptDir?: string;
5
+ bookTitle?: string;
6
+ writeConfigJsonc?: boolean;
7
+ writeTemplates?: boolean;
8
+ forceOverwriteTemplates?: boolean;
9
+ };
10
+ export type NovelScaffoldResultJson = {
11
+ version: 1;
12
+ manuscriptDir: string;
13
+ createdDirs: string[];
14
+ writtenFiles: string[];
15
+ skippedExisting: string[];
16
+ configPath?: string;
17
+ nextSteps?: string[];
18
+ diagnostics: Diagnostic[];
19
+ };
@@ -0,0 +1,88 @@
1
+ import type { Diagnostic } from "../../shared/errors/diagnostics";
2
+ import type { ChapterEntity, ChapterSceneEntity, ChapterStructureEntity, CharacterEntity, FactionEntity, LocationEntity, NovelFileHash, ScanCacheV1, ThreadEntity } from "./types";
3
+ export type CachedMaps = {
4
+ fileByPath: Map<string, NovelFileHash>;
5
+ chapterByPath: Map<string, ChapterEntity>;
6
+ characterByPath: Map<string, CharacterEntity>;
7
+ threadByPath: Map<string, ThreadEntity>;
8
+ factionByPath: Map<string, FactionEntity>;
9
+ locationByPath: Map<string, LocationEntity>;
10
+ perFileDiagnostics: Map<string, Diagnostic[]>;
11
+ };
12
+ export type EntityMarkdownFiles = {
13
+ chapterFiles: string[];
14
+ characterFiles: string[];
15
+ threadFiles: string[];
16
+ factionFiles: string[];
17
+ locationFiles: string[];
18
+ };
19
+ /** 递归列出目录下的 Markdown 文件,并按稳定顺序排序。 */
20
+ export declare function listMarkdownFiles(dir: string, options?: {
21
+ sortLocale?: string;
22
+ }): string[];
23
+ /** 解析 manuscript 标准实体目录并返回对应 Markdown 文件列表。 */
24
+ export declare function listEntityMarkdownFiles(manuscriptDir: string, options?: {
25
+ sortLocale?: string;
26
+ }): EntityMarkdownFiles;
27
+ /** 对 manuscript 根目录下的未知一级目录输出诊断信息。 */
28
+ export declare function reportUnknownManuscriptDirs(options: {
29
+ manuscriptDir: string;
30
+ rootDir: string;
31
+ diagnostics: Diagnostic[];
32
+ }): void;
33
+ /** 读取并校验增量扫描缓存。 */
34
+ export declare function loadScanCache(cachePath: string): ScanCacheV1 | null;
35
+ /** 基于扫描缓存构建快速查找映射。 */
36
+ export declare function buildCachedMaps(cache: ScanCacheV1 | null): CachedMaps;
37
+ /** 校验实体集合中的重复 ID。 */
38
+ export declare function validateUniqueness(diagnostics: Diagnostic[], items: Array<{
39
+ id: string;
40
+ path: string;
41
+ }>, code: string): void;
42
+ /** 编译配置中的命名正则,并在无效时输出诊断。 */
43
+ export declare function compileNamingPattern(options: {
44
+ diagnostics: Diagnostic[];
45
+ kind: string;
46
+ pattern: string;
47
+ strictMode: boolean;
48
+ }): RegExp | null;
49
+ /** 使用配置命名规则校验实体 ID。 */
50
+ export declare function validateIdAgainstPattern(options: {
51
+ diagnostics: Diagnostic[];
52
+ kind: string;
53
+ id: string;
54
+ file: string;
55
+ pattern: RegExp | null;
56
+ patternSource: string;
57
+ strictMode: boolean;
58
+ }): void;
59
+ /** 将未知数组值转换为字符串数组。 */
60
+ export declare function toStringArray(value: unknown): string[] | undefined;
61
+ /** 从 frontmatter 解析章节结构元数据。 */
62
+ export declare function parseChapterStructure(options: {
63
+ raw: unknown;
64
+ file: string;
65
+ strictMode: boolean;
66
+ diagnostics: Diagnostic[];
67
+ }): ChapterStructureEntity | undefined;
68
+ export type SceneFieldName = keyof Pick<ChapterSceneEntity, "scene_id" | "objective" | "conflict" | "outcome" | "hook">;
69
+ /** 解析章节 scenes 元数据并输出场景级诊断。 */
70
+ export declare function parseChapterScenes(options: {
71
+ raw: unknown;
72
+ file: string;
73
+ strictMode: boolean;
74
+ requiredFields: Set<SceneFieldName>;
75
+ diagnostics: Diagnostic[];
76
+ }): ChapterSceneEntity[] | undefined;
77
+ /** 基于已定义实体 ID 校验章节中的跨实体引用。 */
78
+ export declare function validateChapterReferences(options: {
79
+ diagnostics: Diagnostic[];
80
+ chapters: ChapterEntity[];
81
+ strictMode: boolean;
82
+ definedCharacters: Set<string>;
83
+ definedThreads: Set<string>;
84
+ definedFactions: Set<string>;
85
+ definedLocations: Set<string>;
86
+ }): void;
87
+ /** 判断值是否为普通对象(排除数组)。 */
88
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ export { loadOrScan, scanNovelProject } from "./scan";
2
+ export { createNovelScanTool } from "./tool";
3
+ export type { ChapterEntity, CharacterEntity, FactionEntity, LocationEntity, NovelFileHash, NovelScanArgs, NovelScanMode, NovelScanResultJson, ScanCacheV1, ThreadEntity, } from "./types";
@@ -0,0 +1,17 @@
1
+ import type { NovelConfig } from "../../config/schema";
2
+ import type { NovelScanArgs, NovelScanResultJson, ScanCacheV1 } from "./types";
3
+ /** 扫描 manuscript 实体、校验引用关系,并持久化增量缓存。 */
4
+ export declare function scanNovelProject(deps: {
5
+ projectRoot: string;
6
+ config: NovelConfig;
7
+ args: NovelScanArgs;
8
+ }): {
9
+ result: NovelScanResultJson;
10
+ cacheToWrite?: ScanCacheV1;
11
+ };
12
+ /** 加载增量扫描缓存或执行扫描,并返回标准化结果。 */
13
+ export declare function loadOrScan(deps: {
14
+ projectRoot: string;
15
+ config: NovelConfig;
16
+ args?: Partial<NovelScanArgs>;
17
+ }): NovelScanResultJson;
@@ -0,0 +1,6 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ import type { NovelConfig } from "../../config/schema";
3
+ export declare function createNovelScanTool(deps: {
4
+ projectRoot: string;
5
+ config: NovelConfig;
6
+ }): ToolDefinition;