specweave 0.17.6 → 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.
- package/CLAUDE.md +365 -9
- package/dist/plugins/specweave/lib/hooks/sync-living-docs.d.ts +9 -4
- package/dist/plugins/specweave/lib/hooks/sync-living-docs.d.ts.map +1 -1
- package/dist/plugins/specweave/lib/hooks/sync-living-docs.js +82 -12
- package/dist/plugins/specweave/lib/hooks/sync-living-docs.js.map +1 -1
- package/dist/plugins/specweave-github/lib/github-spec-content-sync.d.ts +2 -2
- package/dist/plugins/specweave-github/lib/github-spec-content-sync.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/github-spec-content-sync.js +69 -10
- package/dist/plugins/specweave-github/lib/github-spec-content-sync.js.map +1 -1
- package/dist/src/cli/commands/detect-project.d.ts +9 -0
- package/dist/src/cli/commands/detect-project.d.ts.map +1 -0
- package/dist/src/cli/commands/detect-project.js +85 -0
- package/dist/src/cli/commands/detect-project.js.map +1 -0
- package/dist/src/cli/commands/detect-specs.d.ts +9 -0
- package/dist/src/cli/commands/detect-specs.d.ts.map +1 -0
- package/dist/src/cli/commands/detect-specs.js +73 -0
- package/dist/src/cli/commands/detect-specs.js.map +1 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +8 -15
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/core/living-docs/content-classifier.d.ts +83 -0
- package/dist/src/core/living-docs/content-classifier.d.ts.map +1 -0
- package/dist/src/core/living-docs/content-classifier.js +393 -0
- package/dist/src/core/living-docs/content-classifier.js.map +1 -0
- package/dist/src/core/living-docs/content-distributor.d.ts +126 -0
- package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -0
- package/dist/src/core/living-docs/content-distributor.js +339 -0
- package/dist/src/core/living-docs/content-distributor.js.map +1 -0
- package/dist/src/core/living-docs/content-parser.d.ts +140 -0
- package/dist/src/core/living-docs/content-parser.d.ts.map +1 -0
- package/dist/src/core/living-docs/content-parser.js +316 -0
- package/dist/src/core/living-docs/content-parser.js.map +1 -0
- package/dist/src/core/living-docs/cross-linker.d.ts +126 -0
- package/dist/src/core/living-docs/cross-linker.d.ts.map +1 -0
- package/dist/src/core/living-docs/cross-linker.js +374 -0
- package/dist/src/core/living-docs/cross-linker.js.map +1 -0
- package/dist/src/core/living-docs/index.d.ts +89 -0
- package/dist/src/core/living-docs/index.d.ts.map +1 -0
- package/dist/src/core/living-docs/index.js +169 -0
- package/dist/src/core/living-docs/index.js.map +1 -0
- package/dist/src/core/living-docs/project-detector.d.ts +103 -0
- package/dist/src/core/living-docs/project-detector.d.ts.map +1 -0
- package/dist/src/core/living-docs/project-detector.js +314 -0
- package/dist/src/core/living-docs/project-detector.js.map +1 -0
- package/dist/src/core/repo-structure/prompt-consolidator.d.ts +1 -1
- package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
- package/dist/src/core/repo-structure/prompt-consolidator.js +51 -22
- package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts +2 -0
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
- package/dist/src/core/repo-structure/repo-structure-manager.js +126 -62
- package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
- package/dist/src/core/spec-content-sync.d.ts +6 -0
- package/dist/src/core/spec-content-sync.d.ts.map +1 -1
- package/dist/src/core/spec-content-sync.js +25 -7
- package/dist/src/core/spec-content-sync.js.map +1 -1
- package/dist/src/core/spec-detector.d.ts +54 -0
- package/dist/src/core/spec-detector.d.ts.map +1 -0
- package/dist/src/core/spec-detector.js +197 -0
- package/dist/src/core/spec-detector.js.map +1 -0
- package/dist/src/core/spec-identifier-detector.d.ts +49 -0
- package/dist/src/core/spec-identifier-detector.d.ts.map +1 -0
- package/dist/src/core/spec-identifier-detector.js +198 -0
- package/dist/src/core/spec-identifier-detector.js.map +1 -0
- package/dist/src/core/types/spec-identifier.d.ts +67 -0
- package/dist/src/core/types/spec-identifier.d.ts.map +1 -0
- package/dist/src/core/types/spec-identifier.js +23 -0
- package/dist/src/core/types/spec-identifier.js.map +1 -0
- package/dist/src/utils/docs-preview/config-generator.d.ts.map +1 -1
- package/dist/src/utils/docs-preview/config-generator.js +11 -0
- package/dist/src/utils/docs-preview/config-generator.js.map +1 -1
- package/package.json +2 -1
- package/plugins/specweave/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave/lib/hooks/sync-living-docs.js +61 -5
- package/plugins/specweave/lib/hooks/sync-living-docs.ts +102 -13
- package/plugins/specweave-ado/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-docs-preview/commands/preview.md +11 -11
- package/plugins/specweave-github/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-github/hooks/post-task-completion.sh +59 -30
- package/plugins/specweave-github/lib/github-spec-content-sync.js +55 -6
- package/plugins/specweave-github/lib/github-spec-content-sync.ts +84 -12
- package/plugins/specweave-jira/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-mobile/.claude-plugin/plugin.json +1 -4
- package/plugins/specweave-release/.claude-plugin/plugin.json +3 -15
- package/src/templates/AGENTS.md.template +297 -0
- package/dist/locales/de/.gitkeep +0 -0
- package/dist/locales/de/cli.json +0 -108
- package/dist/locales/en/cli.json +0 -287
- package/dist/locales/en/errors.json +0 -7
- package/dist/locales/en/templates.json +0 -6
- package/dist/locales/es/.gitkeep +0 -0
- package/dist/locales/es/cli.json +0 -41
- package/dist/locales/fr/.gitkeep +0 -0
- package/dist/locales/fr/cli.json +0 -108
- package/dist/locales/ja/.gitkeep +0 -0
- package/dist/locales/ja/cli.json +0 -108
- package/dist/locales/ko/.gitkeep +0 -0
- package/dist/locales/ko/cli.json +0 -108
- package/dist/locales/pt/.gitkeep +0 -0
- package/dist/locales/pt/cli.json +0 -108
- package/dist/locales/ru/.gitkeep +0 -0
- package/dist/locales/ru/cli.json +0 -269
- package/dist/locales/zh/.gitkeep +0 -0
- package/dist/locales/zh/cli.json +0 -108
- package/plugins/specweave/plugin.json +0 -22
- package/plugins/specweave-ado/plugin.json +0 -20
- package/plugins/specweave-github/plugin.json +0 -19
- package/plugins/specweave-jira/plugin.json +0 -20
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Classifier for Intelligent Living Docs Sync
|
|
3
|
+
*
|
|
4
|
+
* Classifies spec sections into content categories using heuristic rules.
|
|
5
|
+
*
|
|
6
|
+
* @module living-docs/content-classifier
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Content categories for classification
|
|
10
|
+
*/
|
|
11
|
+
export var ContentCategory;
|
|
12
|
+
(function (ContentCategory) {
|
|
13
|
+
ContentCategory["UserStory"] = "user-story";
|
|
14
|
+
ContentCategory["NFR"] = "nfr";
|
|
15
|
+
ContentCategory["Architecture"] = "architecture";
|
|
16
|
+
ContentCategory["ADR"] = "adr";
|
|
17
|
+
ContentCategory["Operations"] = "operations";
|
|
18
|
+
ContentCategory["Delivery"] = "delivery";
|
|
19
|
+
ContentCategory["Strategy"] = "strategy";
|
|
20
|
+
ContentCategory["Governance"] = "governance";
|
|
21
|
+
ContentCategory["Overview"] = "overview";
|
|
22
|
+
ContentCategory["Unknown"] = "unknown";
|
|
23
|
+
})(ContentCategory || (ContentCategory = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Content Classifier class
|
|
26
|
+
*/
|
|
27
|
+
export class ContentClassifier {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.rules = this.initializeRules();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Initialize classification rules
|
|
33
|
+
*/
|
|
34
|
+
initializeRules() {
|
|
35
|
+
return [
|
|
36
|
+
// User Story Rules (High confidence patterns)
|
|
37
|
+
{
|
|
38
|
+
category: ContentCategory.UserStory,
|
|
39
|
+
weight: 0.9,
|
|
40
|
+
matcher: (section) => /^(US|User Story|Story)[-\s]*\d+/i.test(section.heading),
|
|
41
|
+
description: 'Heading starts with US-XXX or User Story XXX',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
category: ContentCategory.UserStory,
|
|
45
|
+
weight: 0.8,
|
|
46
|
+
matcher: (section) => /as a|I want|so that/i.test(section.content),
|
|
47
|
+
description: 'Contains user story format (As a... I want... So that...)',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
category: ContentCategory.UserStory,
|
|
51
|
+
weight: 0.7,
|
|
52
|
+
matcher: (section) => /acceptance criteria|ac-|given.*when.*then/i.test(section.content),
|
|
53
|
+
description: 'Contains acceptance criteria or Given/When/Then',
|
|
54
|
+
},
|
|
55
|
+
// NFR Rules
|
|
56
|
+
{
|
|
57
|
+
category: ContentCategory.NFR,
|
|
58
|
+
weight: 0.9,
|
|
59
|
+
matcher: (section) => /^(NFR|Non-Functional Requirement)[-\s]*\d+/i.test(section.heading),
|
|
60
|
+
description: 'Heading starts with NFR-XXX',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
category: ContentCategory.NFR,
|
|
64
|
+
weight: 0.8,
|
|
65
|
+
matcher: (section) => /performance|latency|throughput|scalability|availability|reliability/i.test(section.content),
|
|
66
|
+
description: 'Contains NFR keywords (performance, scalability, etc.)',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
category: ContentCategory.NFR,
|
|
70
|
+
weight: 0.7,
|
|
71
|
+
matcher: (section) => /<\d+\s*(ms|sec|min)|>\d+\s*(req\/s|users|concurrent)/i.test(section.content),
|
|
72
|
+
description: 'Contains quantitative metrics (<30s, >1000 req/s)',
|
|
73
|
+
},
|
|
74
|
+
// Architecture Rules
|
|
75
|
+
{
|
|
76
|
+
category: ContentCategory.Architecture,
|
|
77
|
+
weight: 0.9,
|
|
78
|
+
matcher: (section) => /^(Architecture|System Design|Component Design|Data Model|HLD|LLD)/i.test(section.heading),
|
|
79
|
+
description: 'Heading indicates architecture',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
category: ContentCategory.Architecture,
|
|
83
|
+
weight: 0.8,
|
|
84
|
+
matcher: (section) => /component|service|module|class diagram|sequence diagram|entity relationship/i.test(section.content),
|
|
85
|
+
description: 'Contains architecture terms',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
category: ContentCategory.Architecture,
|
|
89
|
+
weight: 0.7,
|
|
90
|
+
matcher: (section) => section.codeBlocks.some((block) => block.language === 'mermaid' || block.language === 'plantuml'),
|
|
91
|
+
description: 'Contains diagram code blocks',
|
|
92
|
+
},
|
|
93
|
+
// ADR Rules
|
|
94
|
+
{
|
|
95
|
+
category: ContentCategory.ADR,
|
|
96
|
+
weight: 0.95,
|
|
97
|
+
matcher: (section) => /^ADR[-\s]*\d+/i.test(section.heading),
|
|
98
|
+
description: 'Heading starts with ADR-XXX',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
category: ContentCategory.ADR,
|
|
102
|
+
weight: 0.9,
|
|
103
|
+
matcher: (section) => /^(Decision|Technical Decision|Architecture Decision)/i.test(section.heading) &&
|
|
104
|
+
/context|decision|consequences|alternatives|status/i.test(section.content),
|
|
105
|
+
description: 'Contains ADR structure (context, decision, consequences)',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
category: ContentCategory.ADR,
|
|
109
|
+
weight: 0.7,
|
|
110
|
+
matcher: (section) => /why we chose|alternatives considered|trade-?offs/i.test(section.content),
|
|
111
|
+
description: 'Contains decision rationale keywords',
|
|
112
|
+
},
|
|
113
|
+
// Operations Rules
|
|
114
|
+
{
|
|
115
|
+
category: ContentCategory.Operations,
|
|
116
|
+
weight: 0.9,
|
|
117
|
+
matcher: (section) => /^(Runbook|SLO|SLI|Monitoring|Alerting|Incident|Operations)/i.test(section.heading),
|
|
118
|
+
description: 'Heading indicates operations',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
category: ContentCategory.Operations,
|
|
122
|
+
weight: 0.8,
|
|
123
|
+
matcher: (section) => /incident response|on-?call|escalation|monitoring|alerting|slo|sli/i.test(section.content),
|
|
124
|
+
description: 'Contains operations keywords',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
category: ContentCategory.Operations,
|
|
128
|
+
weight: 0.7,
|
|
129
|
+
matcher: (section) => /step \d+|procedure|troubleshooting|diagnostic/i.test(section.content),
|
|
130
|
+
description: 'Contains runbook-style content',
|
|
131
|
+
},
|
|
132
|
+
// Delivery Rules
|
|
133
|
+
{
|
|
134
|
+
category: ContentCategory.Delivery,
|
|
135
|
+
weight: 0.9,
|
|
136
|
+
matcher: (section) => /^(Delivery|Release|Test Strategy|CI\/CD|Roadmap|Branch Strategy)/i.test(section.heading),
|
|
137
|
+
description: 'Heading indicates delivery process',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
category: ContentCategory.Delivery,
|
|
141
|
+
weight: 0.8,
|
|
142
|
+
matcher: (section) => /test plan|test strategy|release plan|deployment|pipeline|continuous/i.test(section.content),
|
|
143
|
+
description: 'Contains delivery keywords',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
category: ContentCategory.Delivery,
|
|
147
|
+
weight: 0.7,
|
|
148
|
+
matcher: (section) => /git flow|pull request|code review|merge strategy/i.test(section.content),
|
|
149
|
+
description: 'Contains development workflow terms',
|
|
150
|
+
},
|
|
151
|
+
// Strategy Rules
|
|
152
|
+
{
|
|
153
|
+
category: ContentCategory.Strategy,
|
|
154
|
+
weight: 0.9,
|
|
155
|
+
matcher: (section) => /^(Strategy|Vision|Business Case|PRD|Product Requirements|OKR)/i.test(section.heading),
|
|
156
|
+
description: 'Heading indicates strategy',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
category: ContentCategory.Strategy,
|
|
160
|
+
weight: 0.8,
|
|
161
|
+
matcher: (section) => /business case|roi|market analysis|stakeholder|product vision/i.test(section.content),
|
|
162
|
+
description: 'Contains strategy keywords',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
category: ContentCategory.Strategy,
|
|
166
|
+
weight: 0.7,
|
|
167
|
+
matcher: (section) => /objective|key result|okr|metric|success criteria/i.test(section.content),
|
|
168
|
+
description: 'Contains business metrics and objectives',
|
|
169
|
+
},
|
|
170
|
+
// Governance Rules
|
|
171
|
+
{
|
|
172
|
+
category: ContentCategory.Governance,
|
|
173
|
+
weight: 0.9,
|
|
174
|
+
matcher: (section) => /^(Security|Compliance|Coding Standards|Policy|Governance)/i.test(section.heading),
|
|
175
|
+
description: 'Heading indicates governance',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
category: ContentCategory.Governance,
|
|
179
|
+
weight: 0.8,
|
|
180
|
+
matcher: (section) => /security policy|compliance|gdpr|hipaa|pci-?dss|soc 2/i.test(section.content),
|
|
181
|
+
description: 'Contains compliance keywords',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
category: ContentCategory.Governance,
|
|
185
|
+
weight: 0.7,
|
|
186
|
+
matcher: (section) => /coding standard|style guide|convention|best practice/i.test(section.content),
|
|
187
|
+
description: 'Contains coding standards keywords',
|
|
188
|
+
},
|
|
189
|
+
// Overview Rules (Catch common overview sections)
|
|
190
|
+
{
|
|
191
|
+
category: ContentCategory.Overview,
|
|
192
|
+
weight: 0.8,
|
|
193
|
+
matcher: (section) => /^(Overview|Introduction|Summary|Executive Summary|Quick Overview)/i.test(section.heading),
|
|
194
|
+
description: 'Heading indicates overview/introduction',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
category: ContentCategory.Overview,
|
|
198
|
+
weight: 0.6,
|
|
199
|
+
matcher: (section) => section.level === 2 && section.heading.toLowerCase().includes('overview'),
|
|
200
|
+
description: 'Top-level overview section',
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Classify a single section
|
|
206
|
+
*/
|
|
207
|
+
classify(section) {
|
|
208
|
+
const scores = new Map();
|
|
209
|
+
const reasoning = [];
|
|
210
|
+
// Apply all rules and accumulate scores
|
|
211
|
+
for (const rule of this.rules) {
|
|
212
|
+
if (rule.matcher(section)) {
|
|
213
|
+
const currentScore = scores.get(rule.category) || 0;
|
|
214
|
+
scores.set(rule.category, currentScore + rule.weight);
|
|
215
|
+
reasoning.push(`[${rule.category}] ${rule.description}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Find category with highest score
|
|
219
|
+
let maxScore = 0;
|
|
220
|
+
let bestCategory = ContentCategory.Unknown;
|
|
221
|
+
for (const [category, score] of scores.entries()) {
|
|
222
|
+
if (score > maxScore) {
|
|
223
|
+
maxScore = score;
|
|
224
|
+
bestCategory = category;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Normalize confidence (cap at 1.0)
|
|
228
|
+
const confidence = Math.min(maxScore, 1.0);
|
|
229
|
+
// Generate suggested filename and path
|
|
230
|
+
const { filename, path } = this.suggestFileLocation(section, bestCategory);
|
|
231
|
+
return {
|
|
232
|
+
category: bestCategory,
|
|
233
|
+
confidence,
|
|
234
|
+
reasoning,
|
|
235
|
+
suggestedFilename: filename,
|
|
236
|
+
suggestedPath: path,
|
|
237
|
+
metadata: {
|
|
238
|
+
heading: section.heading,
|
|
239
|
+
level: section.level,
|
|
240
|
+
contentLength: section.content.length,
|
|
241
|
+
hasCodeBlocks: section.codeBlocks.length > 0,
|
|
242
|
+
hasLinks: section.links.length > 0,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Classify multiple sections
|
|
248
|
+
*/
|
|
249
|
+
classifyAll(sections) {
|
|
250
|
+
return sections.map((section) => this.classify(section));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Suggest file location based on category
|
|
254
|
+
*/
|
|
255
|
+
suggestFileLocation(section, category) {
|
|
256
|
+
const slug = this.slugify(section.heading);
|
|
257
|
+
switch (category) {
|
|
258
|
+
case ContentCategory.UserStory: {
|
|
259
|
+
// Extract US ID if present (e.g., "US-016-001" → "us-016-001")
|
|
260
|
+
const usMatch = section.heading.match(/US[-\s]*(\d+[-\s]*\d+)/i);
|
|
261
|
+
const filename = usMatch
|
|
262
|
+
? `us-${usMatch[1].replace(/\s+/g, '-')}.md`
|
|
263
|
+
: `us-${slug}.md`;
|
|
264
|
+
return { filename, path: 'specs/{project}' };
|
|
265
|
+
}
|
|
266
|
+
case ContentCategory.NFR: {
|
|
267
|
+
const nfrMatch = section.heading.match(/NFR[-\s]*(\d+[-\s]*\d+)/i);
|
|
268
|
+
const filename = nfrMatch
|
|
269
|
+
? `nfr-${nfrMatch[1].replace(/\s+/g, '-')}.md`
|
|
270
|
+
: `nfr-${slug}.md`;
|
|
271
|
+
return { filename, path: 'specs/{project}' };
|
|
272
|
+
}
|
|
273
|
+
case ContentCategory.Architecture: {
|
|
274
|
+
const isHLD = /high-?level|hld|system/i.test(section.heading);
|
|
275
|
+
const isLLD = /low-?level|lld|component/i.test(section.heading);
|
|
276
|
+
const prefix = isHLD ? 'hld' : isLLD ? 'lld' : 'design';
|
|
277
|
+
return {
|
|
278
|
+
filename: `${prefix}-${slug}.md`,
|
|
279
|
+
path: 'architecture',
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
case ContentCategory.ADR: {
|
|
283
|
+
const adrMatch = section.heading.match(/ADR[-\s]*(\d+)/i);
|
|
284
|
+
const filename = adrMatch
|
|
285
|
+
? `${adrMatch[1].padStart(4, '0')}-${slug}.md`
|
|
286
|
+
: `adr-${slug}.md`;
|
|
287
|
+
return { filename, path: 'architecture/adr' };
|
|
288
|
+
}
|
|
289
|
+
case ContentCategory.Operations: {
|
|
290
|
+
const isRunbook = /runbook/i.test(section.heading);
|
|
291
|
+
const isSLO = /slo|sli/i.test(section.heading);
|
|
292
|
+
const prefix = isRunbook ? 'runbook' : isSLO ? 'slo' : 'ops';
|
|
293
|
+
return {
|
|
294
|
+
filename: `${prefix}-${slug}.md`,
|
|
295
|
+
path: 'operations',
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
case ContentCategory.Delivery: {
|
|
299
|
+
const isRoadmap = /roadmap/i.test(section.heading);
|
|
300
|
+
const isTestStrategy = /test.*strategy/i.test(section.heading);
|
|
301
|
+
const prefix = isRoadmap ? 'roadmap' : isTestStrategy ? 'test-strategy' : 'delivery';
|
|
302
|
+
return {
|
|
303
|
+
filename: `${prefix}-${slug}.md`,
|
|
304
|
+
path: 'delivery',
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
case ContentCategory.Strategy: {
|
|
308
|
+
const isPRD = /prd|product.*requirements/i.test(section.heading);
|
|
309
|
+
const prefix = isPRD ? 'prd' : 'strategy';
|
|
310
|
+
return {
|
|
311
|
+
filename: `${prefix}-${slug}.md`,
|
|
312
|
+
path: 'strategy',
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
case ContentCategory.Governance: {
|
|
316
|
+
const isSecurity = /security/i.test(section.heading);
|
|
317
|
+
const isCompliance = /compliance/i.test(section.heading);
|
|
318
|
+
const prefix = isSecurity
|
|
319
|
+
? 'security'
|
|
320
|
+
: isCompliance
|
|
321
|
+
? 'compliance'
|
|
322
|
+
: 'governance';
|
|
323
|
+
return {
|
|
324
|
+
filename: `${prefix}-${slug}.md`,
|
|
325
|
+
path: 'governance',
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
case ContentCategory.Overview: {
|
|
329
|
+
return {
|
|
330
|
+
filename: `overview-${slug}.md`,
|
|
331
|
+
path: 'specs/{project}',
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
default: {
|
|
335
|
+
return {
|
|
336
|
+
filename: `${slug}.md`,
|
|
337
|
+
path: 'specs/{project}',
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Convert text to URL-safe slug
|
|
344
|
+
*/
|
|
345
|
+
slugify(text) {
|
|
346
|
+
return text
|
|
347
|
+
.toLowerCase()
|
|
348
|
+
.replace(/[^\w\s-]/g, '')
|
|
349
|
+
.replace(/\s+/g, '-')
|
|
350
|
+
.replace(/--+/g, '-')
|
|
351
|
+
.trim();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Get sections by category
|
|
355
|
+
*/
|
|
356
|
+
filterByCategory(results, category) {
|
|
357
|
+
return results.filter((r) => r.category === category);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Get sections by minimum confidence
|
|
361
|
+
*/
|
|
362
|
+
filterByConfidence(results, minConfidence) {
|
|
363
|
+
return results.filter((r) => r.confidence >= minConfidence);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Get statistics about classifications
|
|
367
|
+
*/
|
|
368
|
+
getStatistics(results) {
|
|
369
|
+
const stats = {
|
|
370
|
+
total: results.length,
|
|
371
|
+
byCategory: {},
|
|
372
|
+
averageConfidence: 0,
|
|
373
|
+
lowConfidence: 0,
|
|
374
|
+
};
|
|
375
|
+
// Count by category
|
|
376
|
+
for (const result of results) {
|
|
377
|
+
stats.byCategory[result.category] = (stats.byCategory[result.category] || 0) + 1;
|
|
378
|
+
}
|
|
379
|
+
// Calculate average confidence
|
|
380
|
+
const totalConfidence = results.reduce((sum, r) => sum + r.confidence, 0);
|
|
381
|
+
stats.averageConfidence = totalConfidence / results.length;
|
|
382
|
+
// Count low confidence (<0.6)
|
|
383
|
+
stats.lowConfidence = results.filter((r) => r.confidence < 0.6).length;
|
|
384
|
+
return stats;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Factory function to create classifier
|
|
389
|
+
*/
|
|
390
|
+
export function createContentClassifier() {
|
|
391
|
+
return new ContentClassifier();
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=content-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-classifier.js","sourceRoot":"","sources":["../../../../src/core/living-docs/content-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,CAAN,IAA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AAO,EAAE,CAAC;YAC7B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnF,CAAC;QAED,+BAA+B;QAC/B,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC1E,KAAK,CAAC,iBAAiB,GAAG,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;QAE3D,8BAA8B;QAC9B,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;QAEvE,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,iBAAiB,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Distributor for Intelligent Living Docs Sync
|
|
3
|
+
*
|
|
4
|
+
* Distributes classified spec sections to appropriate folders with proper formatting.
|
|
5
|
+
*
|
|
6
|
+
* @module living-docs/content-distributor
|
|
7
|
+
*/
|
|
8
|
+
import { ParsedSpec } from './content-parser.js';
|
|
9
|
+
import { ClassificationResult, ContentCategory } from './content-classifier.js';
|
|
10
|
+
import { ProjectContext } from './project-detector.js';
|
|
11
|
+
/**
|
|
12
|
+
* Distribution result
|
|
13
|
+
*/
|
|
14
|
+
export interface DistributionResult {
|
|
15
|
+
created: DistributedFile[];
|
|
16
|
+
updated: DistributedFile[];
|
|
17
|
+
skipped: DistributedFile[];
|
|
18
|
+
errors: DistributionError[];
|
|
19
|
+
summary: DistributionSummary;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Distributed file information
|
|
23
|
+
*/
|
|
24
|
+
export interface DistributedFile {
|
|
25
|
+
path: string;
|
|
26
|
+
category: ContentCategory;
|
|
27
|
+
size: number;
|
|
28
|
+
sections: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Distribution error
|
|
32
|
+
*/
|
|
33
|
+
export interface DistributionError {
|
|
34
|
+
section: string;
|
|
35
|
+
category: ContentCategory;
|
|
36
|
+
error: string;
|
|
37
|
+
path?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Distribution summary statistics
|
|
41
|
+
*/
|
|
42
|
+
export interface DistributionSummary {
|
|
43
|
+
totalSections: number;
|
|
44
|
+
filesCreated: number;
|
|
45
|
+
filesUpdated: number;
|
|
46
|
+
filesSkipped: number;
|
|
47
|
+
errors: number;
|
|
48
|
+
byCategory: Record<ContentCategory, number>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Distributor options
|
|
52
|
+
*/
|
|
53
|
+
export interface DistributorOptions {
|
|
54
|
+
basePath?: string;
|
|
55
|
+
generateFrontmatter?: boolean;
|
|
56
|
+
preserveOriginal?: boolean;
|
|
57
|
+
dryRun?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Content Distributor class
|
|
61
|
+
*/
|
|
62
|
+
export declare class ContentDistributor {
|
|
63
|
+
private options;
|
|
64
|
+
constructor(options?: DistributorOptions);
|
|
65
|
+
/**
|
|
66
|
+
* Distribute parsed spec to appropriate locations
|
|
67
|
+
*/
|
|
68
|
+
distribute(incrementId: string, spec: ParsedSpec, classifications: ClassificationResult[], project: ProjectContext): Promise<DistributionResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Flatten nested sections
|
|
71
|
+
*/
|
|
72
|
+
private flattenSections;
|
|
73
|
+
/**
|
|
74
|
+
* Group sections by destination file
|
|
75
|
+
*/
|
|
76
|
+
private groupByFile;
|
|
77
|
+
/**
|
|
78
|
+
* Resolve file path with project
|
|
79
|
+
*/
|
|
80
|
+
private resolvePath;
|
|
81
|
+
/**
|
|
82
|
+
* Write a file with grouped sections
|
|
83
|
+
*/
|
|
84
|
+
private writeFile;
|
|
85
|
+
/**
|
|
86
|
+
* Generate file content with frontmatter and sections
|
|
87
|
+
*/
|
|
88
|
+
private generateFileContent;
|
|
89
|
+
/**
|
|
90
|
+
* Generate Docusaurus frontmatter
|
|
91
|
+
*/
|
|
92
|
+
private generateFrontmatter;
|
|
93
|
+
/**
|
|
94
|
+
* Generate description from sections
|
|
95
|
+
*/
|
|
96
|
+
private generateDescription;
|
|
97
|
+
/**
|
|
98
|
+
* Archive original spec for reference
|
|
99
|
+
*/
|
|
100
|
+
private archiveOriginalSpec;
|
|
101
|
+
/**
|
|
102
|
+
* Generate index file for a category
|
|
103
|
+
*/
|
|
104
|
+
generateIndex(category: ContentCategory, projectId: string, files: DistributedFile[]): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Get category display title
|
|
107
|
+
*/
|
|
108
|
+
private getCategoryTitle;
|
|
109
|
+
/**
|
|
110
|
+
* Get distribution statistics
|
|
111
|
+
*/
|
|
112
|
+
getStatistics(result: DistributionResult): {
|
|
113
|
+
totalFiles: number;
|
|
114
|
+
totalSize: number;
|
|
115
|
+
averageSize: number;
|
|
116
|
+
byCategory: Record<ContentCategory, {
|
|
117
|
+
files: number;
|
|
118
|
+
size: number;
|
|
119
|
+
}>;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Factory function to create distributor
|
|
124
|
+
*/
|
|
125
|
+
export declare function createContentDistributor(options?: DistributorOptions): ContentDistributor;
|
|
126
|
+
//# sourceMappingURL=content-distributor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-distributor.d.ts","sourceRoot":"","sources":["../../../../src/core/living-docs/content-distributor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EA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