specweave 0.17.7 → 0.17.8

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 (89) hide show
  1. package/CLAUDE.md +365 -9
  2. package/dist/plugins/specweave/lib/hooks/sync-living-docs.d.ts +9 -4
  3. package/dist/plugins/specweave/lib/hooks/sync-living-docs.d.ts.map +1 -1
  4. package/dist/plugins/specweave/lib/hooks/sync-living-docs.js +82 -12
  5. package/dist/plugins/specweave/lib/hooks/sync-living-docs.js.map +1 -1
  6. package/dist/plugins/specweave-github/lib/github-spec-content-sync.d.ts +2 -2
  7. package/dist/plugins/specweave-github/lib/github-spec-content-sync.d.ts.map +1 -1
  8. package/dist/plugins/specweave-github/lib/github-spec-content-sync.js +69 -10
  9. package/dist/plugins/specweave-github/lib/github-spec-content-sync.js.map +1 -1
  10. package/dist/src/cli/commands/detect-project.d.ts +9 -0
  11. package/dist/src/cli/commands/detect-project.d.ts.map +1 -0
  12. package/dist/src/cli/commands/detect-project.js +85 -0
  13. package/dist/src/cli/commands/detect-project.js.map +1 -0
  14. package/dist/src/cli/commands/detect-specs.d.ts +9 -0
  15. package/dist/src/cli/commands/detect-specs.d.ts.map +1 -0
  16. package/dist/src/cli/commands/detect-specs.js +73 -0
  17. package/dist/src/cli/commands/detect-specs.js.map +1 -0
  18. package/dist/src/cli/commands/init.d.ts.map +1 -1
  19. package/dist/src/cli/commands/init.js +8 -15
  20. package/dist/src/cli/commands/init.js.map +1 -1
  21. package/dist/src/core/living-docs/content-classifier.d.ts +83 -0
  22. package/dist/src/core/living-docs/content-classifier.d.ts.map +1 -0
  23. package/dist/src/core/living-docs/content-classifier.js +393 -0
  24. package/dist/src/core/living-docs/content-classifier.js.map +1 -0
  25. package/dist/src/core/living-docs/content-distributor.d.ts +126 -0
  26. package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -0
  27. package/dist/src/core/living-docs/content-distributor.js +339 -0
  28. package/dist/src/core/living-docs/content-distributor.js.map +1 -0
  29. package/dist/src/core/living-docs/content-parser.d.ts +140 -0
  30. package/dist/src/core/living-docs/content-parser.d.ts.map +1 -0
  31. package/dist/src/core/living-docs/content-parser.js +316 -0
  32. package/dist/src/core/living-docs/content-parser.js.map +1 -0
  33. package/dist/src/core/living-docs/cross-linker.d.ts +126 -0
  34. package/dist/src/core/living-docs/cross-linker.d.ts.map +1 -0
  35. package/dist/src/core/living-docs/cross-linker.js +374 -0
  36. package/dist/src/core/living-docs/cross-linker.js.map +1 -0
  37. package/dist/src/core/living-docs/index.d.ts +89 -0
  38. package/dist/src/core/living-docs/index.d.ts.map +1 -0
  39. package/dist/src/core/living-docs/index.js +169 -0
  40. package/dist/src/core/living-docs/index.js.map +1 -0
  41. package/dist/src/core/living-docs/project-detector.d.ts +103 -0
  42. package/dist/src/core/living-docs/project-detector.d.ts.map +1 -0
  43. package/dist/src/core/living-docs/project-detector.js +314 -0
  44. package/dist/src/core/living-docs/project-detector.js.map +1 -0
  45. package/dist/src/core/repo-structure/prompt-consolidator.d.ts +1 -1
  46. package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
  47. package/dist/src/core/repo-structure/prompt-consolidator.js +51 -22
  48. package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
  49. package/dist/src/core/repo-structure/repo-structure-manager.d.ts +2 -0
  50. package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
  51. package/dist/src/core/repo-structure/repo-structure-manager.js +126 -62
  52. package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
  53. package/dist/src/core/spec-content-sync.d.ts +6 -0
  54. package/dist/src/core/spec-content-sync.d.ts.map +1 -1
  55. package/dist/src/core/spec-content-sync.js +25 -7
  56. package/dist/src/core/spec-content-sync.js.map +1 -1
  57. package/dist/src/core/spec-detector.d.ts +54 -0
  58. package/dist/src/core/spec-detector.d.ts.map +1 -0
  59. package/dist/src/core/spec-detector.js +197 -0
  60. package/dist/src/core/spec-detector.js.map +1 -0
  61. package/dist/src/core/spec-identifier-detector.d.ts +49 -0
  62. package/dist/src/core/spec-identifier-detector.d.ts.map +1 -0
  63. package/dist/src/core/spec-identifier-detector.js +198 -0
  64. package/dist/src/core/spec-identifier-detector.js.map +1 -0
  65. package/dist/src/core/types/spec-identifier.d.ts +67 -0
  66. package/dist/src/core/types/spec-identifier.d.ts.map +1 -0
  67. package/dist/src/core/types/spec-identifier.js +23 -0
  68. package/dist/src/core/types/spec-identifier.js.map +1 -0
  69. package/dist/src/utils/docs-preview/config-generator.d.ts.map +1 -1
  70. package/dist/src/utils/docs-preview/config-generator.js +11 -0
  71. package/dist/src/utils/docs-preview/config-generator.js.map +1 -1
  72. package/package.json +1 -1
  73. package/plugins/specweave/.claude-plugin/plugin.json +1 -1
  74. package/plugins/specweave/lib/hooks/sync-living-docs.js +61 -5
  75. package/plugins/specweave/lib/hooks/sync-living-docs.ts +102 -13
  76. package/plugins/specweave-ado/.claude-plugin/plugin.json +1 -1
  77. package/plugins/specweave-docs-preview/commands/preview.md +11 -11
  78. package/plugins/specweave-github/.claude-plugin/plugin.json +1 -1
  79. package/plugins/specweave-github/hooks/post-task-completion.sh +59 -30
  80. package/plugins/specweave-github/lib/github-spec-content-sync.js +55 -6
  81. package/plugins/specweave-github/lib/github-spec-content-sync.ts +84 -12
  82. package/plugins/specweave-jira/.claude-plugin/plugin.json +1 -1
  83. package/plugins/specweave-mobile/.claude-plugin/plugin.json +1 -4
  84. package/plugins/specweave-release/.claude-plugin/plugin.json +3 -15
  85. package/src/templates/AGENTS.md.template +297 -0
  86. package/plugins/specweave/plugin.json +0 -22
  87. package/plugins/specweave-ado/plugin.json +0 -20
  88. package/plugins/specweave-github/plugin.json +0 -19
  89. package/plugins/specweave-jira/plugin.json +0 -20
@@ -0,0 +1,316 @@
1
+ /**
2
+ * Content Parser for Intelligent Living Docs Sync
3
+ *
4
+ * Parses increment spec.md into structured sections for classification and distribution.
5
+ *
6
+ * @module living-docs/content-parser
7
+ */
8
+ import matter from 'gray-matter';
9
+ /**
10
+ * Content Parser class
11
+ */
12
+ export class ContentParser {
13
+ constructor(options = {}) {
14
+ this.options = {
15
+ preserveCodeBlocks: options.preserveCodeBlocks ?? true,
16
+ preserveLinks: options.preserveLinks ?? true,
17
+ preserveImages: options.preserveImages ?? true,
18
+ maxDepth: options.maxDepth ?? 6,
19
+ includeRawContent: options.includeRawContent ?? true,
20
+ };
21
+ }
22
+ /**
23
+ * Parse markdown content into structured sections
24
+ */
25
+ parse(markdown, filePath) {
26
+ // 1. Extract frontmatter
27
+ const { data: frontmatter, content } = matter(markdown);
28
+ // 2. Split into lines for line number tracking
29
+ const lines = content.split('\n');
30
+ // 3. Parse sections
31
+ const sections = this.parseSections(lines, 0, lines.length);
32
+ return {
33
+ frontmatter,
34
+ sections,
35
+ raw: markdown,
36
+ filePath,
37
+ };
38
+ }
39
+ /**
40
+ * Parse sections from lines array (recursive for nested sections)
41
+ */
42
+ parseSections(lines, startIndex, endIndex, parentLevel = 0) {
43
+ const sections = [];
44
+ let currentSection = null;
45
+ let sectionContentLines = [];
46
+ let currentLine = startIndex;
47
+ while (currentLine < endIndex) {
48
+ const line = lines[currentLine];
49
+ const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
50
+ if (headingMatch) {
51
+ const level = headingMatch[1].length;
52
+ // Only process headings at or below max depth
53
+ if (level <= this.options.maxDepth) {
54
+ // Save previous section
55
+ if (currentSection) {
56
+ currentSection.content = sectionContentLines.join('\n').trim();
57
+ currentSection.endLine = currentLine - 1;
58
+ // Parse content elements
59
+ if (this.options.preserveCodeBlocks) {
60
+ currentSection.codeBlocks = this.extractCodeBlocks(currentSection.content);
61
+ }
62
+ if (this.options.preserveLinks) {
63
+ currentSection.links = this.extractLinks(currentSection.content);
64
+ }
65
+ if (this.options.preserveImages) {
66
+ currentSection.images = this.extractImages(currentSection.content);
67
+ }
68
+ sections.push(currentSection);
69
+ }
70
+ // Start new section
71
+ const heading = headingMatch[2].trim();
72
+ currentSection = {
73
+ id: this.slugify(heading),
74
+ heading,
75
+ level,
76
+ content: '',
77
+ rawContent: '',
78
+ codeBlocks: [],
79
+ links: [],
80
+ images: [],
81
+ startLine: currentLine,
82
+ endLine: currentLine,
83
+ children: [],
84
+ };
85
+ sectionContentLines = [];
86
+ }
87
+ }
88
+ else if (currentSection) {
89
+ // Add line to current section content
90
+ sectionContentLines.push(line);
91
+ }
92
+ currentLine++;
93
+ }
94
+ // Save last section
95
+ if (currentSection) {
96
+ currentSection.content = sectionContentLines.join('\n').trim();
97
+ currentSection.endLine = endIndex - 1;
98
+ if (this.options.preserveCodeBlocks) {
99
+ currentSection.codeBlocks = this.extractCodeBlocks(currentSection.content);
100
+ }
101
+ if (this.options.preserveLinks) {
102
+ currentSection.links = this.extractLinks(currentSection.content);
103
+ }
104
+ if (this.options.preserveImages) {
105
+ currentSection.images = this.extractImages(currentSection.content);
106
+ }
107
+ sections.push(currentSection);
108
+ }
109
+ // Build hierarchy (nest sub-sections)
110
+ return this.buildHierarchy(sections);
111
+ }
112
+ /**
113
+ * Build section hierarchy (nest sub-sections under parent sections)
114
+ */
115
+ buildHierarchy(sections) {
116
+ const result = [];
117
+ const stack = [];
118
+ for (const section of sections) {
119
+ // Pop stack until we find a parent with lower level
120
+ while (stack.length > 0 && stack[stack.length - 1].level >= section.level) {
121
+ stack.pop();
122
+ }
123
+ if (stack.length === 0) {
124
+ // Top-level section
125
+ result.push(section);
126
+ }
127
+ else {
128
+ // Nested section - add to parent
129
+ const parent = stack[stack.length - 1];
130
+ parent.children.push(section);
131
+ }
132
+ stack.push(section);
133
+ }
134
+ // Set raw content for each section (including children)
135
+ this.setRawContent(result);
136
+ return result;
137
+ }
138
+ /**
139
+ * Set raw content for sections (including nested children)
140
+ */
141
+ setRawContent(sections) {
142
+ for (const section of sections) {
143
+ if (this.options.includeRawContent) {
144
+ section.rawContent = this.generateRawContent(section);
145
+ }
146
+ if (section.children.length > 0) {
147
+ this.setRawContent(section.children);
148
+ }
149
+ }
150
+ }
151
+ /**
152
+ * Generate raw content for a section (including nested children)
153
+ */
154
+ generateRawContent(section) {
155
+ let content = `${'#'.repeat(section.level)} ${section.heading}\n\n`;
156
+ content += section.content;
157
+ for (const child of section.children) {
158
+ content += '\n\n' + this.generateRawContent(child);
159
+ }
160
+ return content;
161
+ }
162
+ /**
163
+ * Extract code blocks from content
164
+ */
165
+ extractCodeBlocks(content) {
166
+ const codeBlocks = [];
167
+ const lines = content.split('\n');
168
+ let inCodeBlock = false;
169
+ let currentBlock = null;
170
+ lines.forEach((line, index) => {
171
+ const codeBlockStart = line.match(/^```(\w*)/);
172
+ const codeBlockEnd = line.match(/^```\s*$/);
173
+ if (codeBlockStart && !inCodeBlock) {
174
+ inCodeBlock = true;
175
+ currentBlock = {
176
+ language: codeBlockStart[1] || 'text',
177
+ lines: [],
178
+ startLine: index,
179
+ };
180
+ }
181
+ else if (codeBlockEnd && inCodeBlock && currentBlock) {
182
+ inCodeBlock = false;
183
+ codeBlocks.push({
184
+ language: currentBlock.language,
185
+ content: currentBlock.lines.join('\n'),
186
+ startLine: currentBlock.startLine,
187
+ endLine: index,
188
+ });
189
+ currentBlock = null;
190
+ }
191
+ else if (inCodeBlock && currentBlock) {
192
+ currentBlock.lines.push(line);
193
+ }
194
+ });
195
+ return codeBlocks;
196
+ }
197
+ /**
198
+ * Extract links from content
199
+ */
200
+ extractLinks(content) {
201
+ const links = [];
202
+ // Markdown links: [text](url)
203
+ const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
204
+ let match;
205
+ while ((match = markdownLinkRegex.exec(content)) !== null) {
206
+ const [, text, url] = match;
207
+ links.push({
208
+ text,
209
+ url,
210
+ type: this.determineLinkType(url),
211
+ });
212
+ }
213
+ return links;
214
+ }
215
+ /**
216
+ * Extract images from content
217
+ */
218
+ extractImages(content) {
219
+ const images = [];
220
+ // Markdown images: ![alt](url "title")
221
+ const imageRegex = /!\[([^\]]*)\]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g;
222
+ let match;
223
+ while ((match = imageRegex.exec(content)) !== null) {
224
+ const [, alt, url, title] = match;
225
+ images.push({
226
+ alt,
227
+ url,
228
+ title,
229
+ });
230
+ }
231
+ return images;
232
+ }
233
+ /**
234
+ * Determine link type (internal/external/anchor)
235
+ */
236
+ determineLinkType(url) {
237
+ if (url.startsWith('#')) {
238
+ return 'anchor';
239
+ }
240
+ else if (url.startsWith('http://') || url.startsWith('https://')) {
241
+ return 'external';
242
+ }
243
+ else {
244
+ return 'internal';
245
+ }
246
+ }
247
+ /**
248
+ * Convert heading to URL-safe slug
249
+ */
250
+ slugify(text) {
251
+ return text
252
+ .toLowerCase()
253
+ .replace(/[^\w\s-]/g, '') // Remove special characters
254
+ .replace(/\s+/g, '-') // Replace spaces with hyphens
255
+ .replace(/--+/g, '-') // Replace multiple hyphens with single
256
+ .trim();
257
+ }
258
+ /**
259
+ * Find section by ID (recursive search)
260
+ */
261
+ findSection(sections, id) {
262
+ for (const section of sections) {
263
+ if (section.id === id) {
264
+ return section;
265
+ }
266
+ if (section.children.length > 0) {
267
+ const found = this.findSection(section.children, id);
268
+ if (found)
269
+ return found;
270
+ }
271
+ }
272
+ return null;
273
+ }
274
+ /**
275
+ * Get all sections flattened (no hierarchy)
276
+ */
277
+ flattenSections(sections) {
278
+ const result = [];
279
+ for (const section of sections) {
280
+ result.push(section);
281
+ if (section.children.length > 0) {
282
+ result.push(...this.flattenSections(section.children));
283
+ }
284
+ }
285
+ return result;
286
+ }
287
+ /**
288
+ * Get sections by level
289
+ */
290
+ getSectionsByLevel(sections, level) {
291
+ return this.flattenSections(sections).filter((s) => s.level === level);
292
+ }
293
+ /**
294
+ * Get section content without code blocks
295
+ */
296
+ getContentWithoutCode(section) {
297
+ let content = section.content;
298
+ // Remove code blocks
299
+ content = content.replace(/```[\s\S]*?```/g, '');
300
+ return content.trim();
301
+ }
302
+ }
303
+ /**
304
+ * Factory function to create parser
305
+ */
306
+ export function createContentParser(options) {
307
+ return new ContentParser(options);
308
+ }
309
+ /**
310
+ * Convenience function to parse markdown
311
+ */
312
+ export function parseMarkdown(markdown, options) {
313
+ const parser = new ContentParser(options);
314
+ return parser.parse(markdown);
315
+ }
316
+ //# sourceMappingURL=content-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parser.js","sourceRoot":"","sources":["../../../../src/core/living-docs/content-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAqEjC;;GAEG;AACH,MAAM,OAAO,aAAa;IAGxB,YAAY,UAAyB,EAAE;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,IAAI;YACtD,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;YAC5C,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;YAC9C,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;YAC/B,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,IAAI;SACrD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAgB,EAAE,QAAiB;QACvC,yBAAyB;QACzB,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAExD,+CAA+C;QAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,oBAAoB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAE5D,OAAO;YACL,WAAW;YACX,QAAQ;YACR,GAAG,EAAE,QAAQ;YACb,QAAQ;SACT,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,aAAa,CACnB,KAAe,EACf,UAAkB,EAClB,QAAgB,EAChB,cAAsB,CAAC;QAEvB,MAAM,QAAQ,GAAoB,EAAE,CA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ability.
5
+ *
6
+ * @module living-docs/cross-linker
7
+ */
8
+ import { DistributionResult } from './content-distributor.js';
9
+ /**
10
+ * Cross-link between documents
11
+ */
12
+ export interface CrossLink {
13
+ source: string;
14
+ target: string;
15
+ type: LinkType;
16
+ description?: string;
17
+ }
18
+ /**
19
+ * Link types
20
+ */
21
+ export declare enum LinkType {
22
+ Implements = "implements",// Spec implements architecture
23
+ DependsOn = "depends-on",// Operation depends on architecture
24
+ References = "references",// General reference
25
+ RelatedTo = "related-to",// Related content
26
+ DefinedIn = "defined-in",// Term/concept defined in another doc
27
+ TestsFor = "tests-for"
28
+ }
29
+ /**
30
+ * Linker options
31
+ */
32
+ export interface LinkerOptions {
33
+ basePath?: string;
34
+ generateBacklinks?: boolean;
35
+ updateExisting?: boolean;
36
+ dryRun?: boolean;
37
+ }
38
+ /**
39
+ * Cross-Linker class
40
+ */
41
+ export declare class CrossLinker {
42
+ private options;
43
+ private links;
44
+ constructor(options?: LinkerOptions);
45
+ /**
46
+ * Generate cross-links for distributed files
47
+ */
48
+ generateLinks(result: DistributionResult): Promise<CrossLink[]>;
49
+ /**
50
+ * Group files by category
51
+ */
52
+ private groupByCategory;
53
+ /**
54
+ * Generate links from specs to architecture
55
+ */
56
+ private generateArchitectureLinks;
57
+ /**
58
+ * Generate links from operations to architecture
59
+ */
60
+ private generateOperationsLinks;
61
+ /**
62
+ * Generate links from delivery to specs
63
+ */
64
+ private generateDeliveryLinks;
65
+ /**
66
+ * Generate links from strategy to specs
67
+ */
68
+ private generateStrategyLinks;
69
+ /**
70
+ * Check if two documents are related (heuristic)
71
+ */
72
+ private documentsRelated;
73
+ /**
74
+ * Generate backlinks (bidirectional)
75
+ */
76
+ private generateBacklinks;
77
+ /**
78
+ * Get reverse link type
79
+ */
80
+ private getReverseType;
81
+ /**
82
+ * Get reverse description
83
+ */
84
+ private getReverseDescription;
85
+ /**
86
+ * Update documents with generated links
87
+ */
88
+ private updateDocuments;
89
+ /**
90
+ * Update a single document with links
91
+ */
92
+ private updateDocument;
93
+ /**
94
+ * Generate markdown for links section
95
+ */
96
+ private generateLinksMarkdown;
97
+ /**
98
+ * Get link type display title
99
+ */
100
+ private getLinkTypeTitle;
101
+ /**
102
+ * Get relative path from source to target
103
+ */
104
+ private getRelativePath;
105
+ /**
106
+ * Get all links
107
+ */
108
+ getLinks(): CrossLink[];
109
+ /**
110
+ * Get links for a specific file
111
+ */
112
+ getLinksFor(filePath: string): CrossLink[];
113
+ /**
114
+ * Get statistics
115
+ */
116
+ getStatistics(): {
117
+ total: number;
118
+ byType: Record<LinkType, number>;
119
+ bidirectional: number;
120
+ };
121
+ }
122
+ /**
123
+ * Factory function to create linker
124
+ */
125
+ export declare function createCrossLinker(options?: LinkerOptions): CrossLinker;
126
+ //# sourceMappingURL=cross-linker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-linker.d.ts","sourceRoot":"","sources":["../../../../src/core/living-docs/cross-linker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAG/E;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe,CAAO,+BAA+B;IAC/D,SAAS,eAAe,CAAQ,oCAAoC;IACpE,UAAU,eAAe,CAAO,oBAAoB;IACpD,SAAS,eAAe,CAAQ,kBAAkB;IAClD,SAAS,eAAe,CAAQ,sCAAsC;IACtE,QAAQ,cAAc;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC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