@weavelogic/knowledge-graph-agent 0.11.8 → 0.12.0

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 (40) hide show
  1. package/dist/claude/hook-capture.d.ts +1 -0
  2. package/dist/claude/hook-capture.d.ts.map +1 -1
  3. package/dist/claude/hook-capture.js +24 -8
  4. package/dist/claude/hook-capture.js.map +1 -1
  5. package/dist/cli/commands/sparc.d.ts +14 -0
  6. package/dist/cli/commands/sparc.d.ts.map +1 -0
  7. package/dist/cli/commands/sparc.js +262 -0
  8. package/dist/cli/commands/sparc.js.map +1 -0
  9. package/dist/cli/index.d.ts.map +1 -1
  10. package/dist/cli/index.js +7 -1
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +12 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/node_modules/@typescript-eslint/project-service/dist/index.js +1 -1
  17. package/dist/node_modules/tinyglobby/dist/index.js +1 -1
  18. package/dist/sparc/consensus.d.ts +149 -0
  19. package/dist/sparc/consensus.d.ts.map +1 -0
  20. package/dist/sparc/consensus.js +356 -0
  21. package/dist/sparc/consensus.js.map +1 -0
  22. package/dist/sparc/decision-log.d.ts +131 -0
  23. package/dist/sparc/decision-log.d.ts.map +1 -0
  24. package/dist/sparc/decision-log.js +325 -0
  25. package/dist/sparc/decision-log.js.map +1 -0
  26. package/dist/sparc/index.d.ts +14 -0
  27. package/dist/sparc/index.d.ts.map +1 -0
  28. package/dist/sparc/index.js +15 -0
  29. package/dist/sparc/index.js.map +1 -0
  30. package/dist/sparc/review-process.d.ts +72 -0
  31. package/dist/sparc/review-process.d.ts.map +1 -0
  32. package/dist/sparc/review-process.js +609 -0
  33. package/dist/sparc/review-process.js.map +1 -0
  34. package/dist/sparc/sparc-planner.d.ts +144 -0
  35. package/dist/sparc/sparc-planner.d.ts.map +1 -0
  36. package/dist/sparc/sparc-planner.js +757 -0
  37. package/dist/sparc/sparc-planner.js.map +1 -0
  38. package/dist/sparc/types.d.ts +664 -0
  39. package/dist/sparc/types.d.ts.map +1 -0
  40. package/package.json +1 -1
@@ -0,0 +1,325 @@
1
+ import { existsSync, readFileSync, mkdirSync, writeFileSync } from "fs";
2
+ import { join, dirname } from "path";
3
+ import { createLogger } from "../utils/logger.js";
4
+ const logger = createLogger("decision-log");
5
+ class DecisionLogManager {
6
+ log;
7
+ options;
8
+ logPath;
9
+ constructor(options) {
10
+ this.options = {
11
+ autoSave: true,
12
+ ...options
13
+ };
14
+ this.logPath = join(this.options.outputDir, "decision-log.json");
15
+ this.log = this.loadOrCreate();
16
+ }
17
+ /**
18
+ * Load existing log or create new one
19
+ */
20
+ loadOrCreate() {
21
+ if (existsSync(this.logPath)) {
22
+ try {
23
+ const content = readFileSync(this.logPath, "utf-8");
24
+ const parsed = JSON.parse(content);
25
+ parsed.createdAt = new Date(parsed.createdAt);
26
+ parsed.updatedAt = new Date(parsed.updatedAt);
27
+ for (const decision of parsed.decisions) {
28
+ decision.createdAt = new Date(decision.createdAt);
29
+ decision.updatedAt = new Date(decision.updatedAt);
30
+ }
31
+ logger.info("Loaded existing decision log", {
32
+ decisions: parsed.decisions.length
33
+ });
34
+ return parsed;
35
+ } catch (error) {
36
+ logger.warn("Failed to load decision log, creating new", { error });
37
+ }
38
+ }
39
+ return this.createNewLog();
40
+ }
41
+ /**
42
+ * Create a new decision log
43
+ */
44
+ createNewLog() {
45
+ const now = /* @__PURE__ */ new Date();
46
+ return {
47
+ id: `dlog_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
48
+ planId: this.options.planId,
49
+ decisions: [],
50
+ statistics: {
51
+ total: 0,
52
+ approved: 0,
53
+ rejected: 0,
54
+ deferred: 0,
55
+ highConfidence: 0,
56
+ lowConfidence: 0,
57
+ consensusRequired: 0
58
+ },
59
+ createdAt: now,
60
+ updatedAt: now
61
+ };
62
+ }
63
+ /**
64
+ * Add a new decision to the log
65
+ */
66
+ addDecision(options) {
67
+ const now = /* @__PURE__ */ new Date();
68
+ const id = `dec_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
69
+ const decision = {
70
+ id,
71
+ title: options.title,
72
+ description: options.description,
73
+ phase: options.phase,
74
+ status: "proposed",
75
+ confidence: options.confidence,
76
+ rationale: options.rationale,
77
+ alternatives: options.alternatives || [],
78
+ impact: options.impact || "Impact assessment pending",
79
+ stakeholders: options.stakeholders || [],
80
+ relatedDecisions: options.relatedDecisions || [],
81
+ consensus: options.consensus,
82
+ createdAt: now,
83
+ updatedAt: now,
84
+ decidedBy: options.decidedBy
85
+ };
86
+ this.log.decisions.push(decision);
87
+ this.updateStatistics();
88
+ this.log.updatedAt = now;
89
+ logger.info("Added decision", {
90
+ id: decision.id,
91
+ title: decision.title,
92
+ confidence: decision.confidence
93
+ });
94
+ if (this.options.autoSave) {
95
+ this.save();
96
+ }
97
+ return decision;
98
+ }
99
+ /**
100
+ * Update decision status
101
+ */
102
+ updateDecisionStatus(decisionId, status, notes) {
103
+ const decision = this.log.decisions.find((d) => d.id === decisionId);
104
+ if (!decision) {
105
+ logger.warn("Decision not found", { decisionId });
106
+ return false;
107
+ }
108
+ decision.status = status;
109
+ decision.updatedAt = /* @__PURE__ */ new Date();
110
+ if (notes) {
111
+ decision.rationale = `${decision.rationale}
112
+
113
+ Update: ${notes}`;
114
+ }
115
+ this.updateStatistics();
116
+ this.log.updatedAt = /* @__PURE__ */ new Date();
117
+ logger.info("Updated decision status", {
118
+ id: decisionId,
119
+ status
120
+ });
121
+ if (this.options.autoSave) {
122
+ this.save();
123
+ }
124
+ return true;
125
+ }
126
+ /**
127
+ * Add consensus information to a decision
128
+ */
129
+ addConsensusInfo(decisionId, consensus) {
130
+ const decision = this.log.decisions.find((d) => d.id === decisionId);
131
+ if (!decision) {
132
+ logger.warn("Decision not found", { decisionId });
133
+ return false;
134
+ }
135
+ decision.consensus = consensus;
136
+ decision.updatedAt = /* @__PURE__ */ new Date();
137
+ if (consensus.achieved) {
138
+ decision.status = "approved";
139
+ }
140
+ this.updateStatistics();
141
+ this.log.updatedAt = /* @__PURE__ */ new Date();
142
+ logger.info("Added consensus info", {
143
+ id: decisionId,
144
+ achieved: consensus.achieved,
145
+ method: consensus.method
146
+ });
147
+ if (this.options.autoSave) {
148
+ this.save();
149
+ }
150
+ return true;
151
+ }
152
+ /**
153
+ * Get all decisions
154
+ */
155
+ getDecisions() {
156
+ return [...this.log.decisions];
157
+ }
158
+ /**
159
+ * Get decisions by phase
160
+ */
161
+ getDecisionsByPhase(phase) {
162
+ return this.log.decisions.filter((d) => d.phase === phase);
163
+ }
164
+ /**
165
+ * Get decisions by confidence level
166
+ */
167
+ getDecisionsByConfidence(confidence) {
168
+ return this.log.decisions.filter((d) => d.confidence === confidence);
169
+ }
170
+ /**
171
+ * Get low confidence decisions requiring review
172
+ */
173
+ getLowConfidenceDecisions() {
174
+ return this.log.decisions.filter(
175
+ (d) => d.confidence === "low" || d.confidence === "uncertain"
176
+ );
177
+ }
178
+ /**
179
+ * Get decisions requiring consensus
180
+ */
181
+ getDecisionsRequiringConsensus() {
182
+ return this.log.decisions.filter(
183
+ (d) => d.consensus?.required && !d.consensus?.achieved
184
+ );
185
+ }
186
+ /**
187
+ * Get decision by ID
188
+ */
189
+ getDecision(id) {
190
+ return this.log.decisions.find((d) => d.id === id);
191
+ }
192
+ /**
193
+ * Get the full log
194
+ */
195
+ getLog() {
196
+ return { ...this.log };
197
+ }
198
+ /**
199
+ * Get statistics
200
+ */
201
+ getStatistics() {
202
+ return { ...this.log.statistics };
203
+ }
204
+ /**
205
+ * Update statistics
206
+ */
207
+ updateStatistics() {
208
+ const decisions = this.log.decisions;
209
+ this.log.statistics = {
210
+ total: decisions.length,
211
+ approved: decisions.filter((d) => d.status === "approved").length,
212
+ rejected: decisions.filter((d) => d.status === "rejected").length,
213
+ deferred: decisions.filter((d) => d.status === "deferred").length,
214
+ highConfidence: decisions.filter((d) => d.confidence === "high").length,
215
+ lowConfidence: decisions.filter(
216
+ (d) => d.confidence === "low" || d.confidence === "uncertain"
217
+ ).length,
218
+ consensusRequired: decisions.filter((d) => d.consensus?.required).length
219
+ };
220
+ }
221
+ /**
222
+ * Save the log to disk
223
+ */
224
+ save() {
225
+ const dir = dirname(this.logPath);
226
+ if (!existsSync(dir)) {
227
+ mkdirSync(dir, { recursive: true });
228
+ }
229
+ writeFileSync(this.logPath, JSON.stringify(this.log, null, 2));
230
+ logger.debug("Saved decision log", { path: this.logPath });
231
+ }
232
+ /**
233
+ * Export log as markdown
234
+ */
235
+ exportMarkdown() {
236
+ const lines = [
237
+ "# Decision Log",
238
+ "",
239
+ `**Plan ID:** ${this.log.planId}`,
240
+ `**Created:** ${this.log.createdAt.toISOString()}`,
241
+ `**Updated:** ${this.log.updatedAt.toISOString()}`,
242
+ "",
243
+ "## Statistics",
244
+ "",
245
+ `| Metric | Count |`,
246
+ `|--------|-------|`,
247
+ `| Total Decisions | ${this.log.statistics.total} |`,
248
+ `| Approved | ${this.log.statistics.approved} |`,
249
+ `| Rejected | ${this.log.statistics.rejected} |`,
250
+ `| Deferred | ${this.log.statistics.deferred} |`,
251
+ `| High Confidence | ${this.log.statistics.highConfidence} |`,
252
+ `| Low Confidence | ${this.log.statistics.lowConfidence} |`,
253
+ `| Consensus Required | ${this.log.statistics.consensusRequired} |`,
254
+ "",
255
+ "## Decisions",
256
+ ""
257
+ ];
258
+ const phases = ["specification", "pseudocode", "architecture", "refinement", "completion"];
259
+ for (const phase of phases) {
260
+ const phaseDecisions = this.getDecisionsByPhase(phase);
261
+ if (phaseDecisions.length === 0) continue;
262
+ lines.push(`### ${phase.charAt(0).toUpperCase() + phase.slice(1)} Phase`);
263
+ lines.push("");
264
+ for (const decision of phaseDecisions) {
265
+ lines.push(`#### ${decision.title}`);
266
+ lines.push("");
267
+ lines.push(`- **ID:** ${decision.id}`);
268
+ lines.push(`- **Status:** ${decision.status}`);
269
+ lines.push(`- **Confidence:** ${decision.confidence}`);
270
+ lines.push(`- **Decided By:** ${decision.decidedBy}`);
271
+ lines.push(`- **Date:** ${decision.createdAt.toISOString()}`);
272
+ lines.push("");
273
+ lines.push("**Description:**");
274
+ lines.push(decision.description);
275
+ lines.push("");
276
+ lines.push("**Rationale:**");
277
+ lines.push(decision.rationale);
278
+ lines.push("");
279
+ if (decision.alternatives.length > 0) {
280
+ lines.push("**Alternatives Considered:**");
281
+ for (const alt of decision.alternatives) {
282
+ lines.push(`- ${alt}`);
283
+ }
284
+ lines.push("");
285
+ }
286
+ if (decision.impact) {
287
+ lines.push("**Impact:**");
288
+ lines.push(decision.impact);
289
+ lines.push("");
290
+ }
291
+ if (decision.consensus) {
292
+ lines.push("**Consensus:**");
293
+ lines.push(`- Required: ${decision.consensus.required}`);
294
+ lines.push(`- Achieved: ${decision.consensus.achieved}`);
295
+ lines.push(`- Method: ${decision.consensus.method}`);
296
+ lines.push(`- Outcome: ${decision.consensus.outcome}`);
297
+ lines.push("");
298
+ }
299
+ lines.push("---");
300
+ lines.push("");
301
+ }
302
+ }
303
+ return lines.join("\n");
304
+ }
305
+ /**
306
+ * Save markdown export
307
+ */
308
+ saveMarkdown() {
309
+ const mdPath = join(this.options.outputDir, "decision-log.md");
310
+ const dir = dirname(mdPath);
311
+ if (!existsSync(dir)) {
312
+ mkdirSync(dir, { recursive: true });
313
+ }
314
+ writeFileSync(mdPath, this.exportMarkdown());
315
+ logger.info("Saved decision log markdown", { path: mdPath });
316
+ }
317
+ }
318
+ function createDecisionLogManager(options) {
319
+ return new DecisionLogManager(options);
320
+ }
321
+ export {
322
+ DecisionLogManager,
323
+ createDecisionLogManager
324
+ };
325
+ //# sourceMappingURL=decision-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-log.js","sources":["../../src/sparc/decision-log.ts"],"sourcesContent":["/**\n * Decision Log Manager\n *\n * Manages the decision log throughout the SPARC planning process.\n * Tracks all decisions, their rationale, confidence levels, and consensus information.\n *\n * @module sparc/decision-log\n */\n\nimport { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { createLogger } from '../utils/index.js';\nimport type {\n DecisionLog,\n DecisionEntry,\n DecisionStatus,\n ConfidenceLevel,\n SPARCPhase,\n ConsensusInfo,\n} from './types.js';\n\nconst logger = createLogger('decision-log');\n\n/**\n * Decision log manager options\n */\nexport interface DecisionLogManagerOptions {\n /** Output directory for the log */\n outputDir: string;\n /** Plan ID */\n planId: string;\n /** Auto-save on changes */\n autoSave?: boolean;\n}\n\n/**\n * Add decision options\n */\nexport interface AddDecisionOptions {\n /** Decision title */\n title: string;\n /** Decision description */\n description: string;\n /** SPARC phase */\n phase: SPARCPhase;\n /** Confidence level */\n confidence: ConfidenceLevel;\n /** Rationale */\n rationale: string;\n /** Alternatives considered */\n alternatives?: string[];\n /** Impact assessment */\n impact?: string;\n /** Stakeholders */\n stakeholders?: string[];\n /** Related decision IDs */\n relatedDecisions?: string[];\n /** Decision maker */\n decidedBy: string;\n /** Consensus info if applicable */\n consensus?: ConsensusInfo;\n}\n\n/**\n * Decision Log Manager\n *\n * Handles creation, updating, and persistence of decision logs.\n */\nexport class DecisionLogManager {\n private log: DecisionLog;\n private readonly options: Required<DecisionLogManagerOptions>;\n private readonly logPath: string;\n\n constructor(options: DecisionLogManagerOptions) {\n this.options = {\n autoSave: true,\n ...options,\n };\n\n this.logPath = join(this.options.outputDir, 'decision-log.json');\n\n // Load existing or create new log\n this.log = this.loadOrCreate();\n }\n\n /**\n * Load existing log or create new one\n */\n private loadOrCreate(): DecisionLog {\n if (existsSync(this.logPath)) {\n try {\n const content = readFileSync(this.logPath, 'utf-8');\n const parsed = JSON.parse(content);\n // Restore Date objects\n parsed.createdAt = new Date(parsed.createdAt);\n parsed.updatedAt = new Date(parsed.updatedAt);\n for (const decision of parsed.decisions) {\n decision.createdAt = new Date(decision.createdAt);\n decision.updatedAt = new Date(decision.updatedAt);\n }\n logger.info('Loaded existing decision log', {\n decisions: parsed.decisions.length,\n });\n return parsed;\n } catch (error) {\n logger.warn('Failed to load decision log, creating new', { error });\n }\n }\n\n return this.createNewLog();\n }\n\n /**\n * Create a new decision log\n */\n private createNewLog(): DecisionLog {\n const now = new Date();\n return {\n id: `dlog_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,\n planId: this.options.planId,\n decisions: [],\n statistics: {\n total: 0,\n approved: 0,\n rejected: 0,\n deferred: 0,\n highConfidence: 0,\n lowConfidence: 0,\n consensusRequired: 0,\n },\n createdAt: now,\n updatedAt: now,\n };\n }\n\n /**\n * Add a new decision to the log\n */\n addDecision(options: AddDecisionOptions): DecisionEntry {\n const now = new Date();\n const id = `dec_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n\n const decision: DecisionEntry = {\n id,\n title: options.title,\n description: options.description,\n phase: options.phase,\n status: 'proposed',\n confidence: options.confidence,\n rationale: options.rationale,\n alternatives: options.alternatives || [],\n impact: options.impact || 'Impact assessment pending',\n stakeholders: options.stakeholders || [],\n relatedDecisions: options.relatedDecisions || [],\n consensus: options.consensus,\n createdAt: now,\n updatedAt: now,\n decidedBy: options.decidedBy,\n };\n\n this.log.decisions.push(decision);\n this.updateStatistics();\n this.log.updatedAt = now;\n\n logger.info('Added decision', {\n id: decision.id,\n title: decision.title,\n confidence: decision.confidence,\n });\n\n if (this.options.autoSave) {\n this.save();\n }\n\n return decision;\n }\n\n /**\n * Update decision status\n */\n updateDecisionStatus(decisionId: string, status: DecisionStatus, notes?: string): boolean {\n const decision = this.log.decisions.find(d => d.id === decisionId);\n if (!decision) {\n logger.warn('Decision not found', { decisionId });\n return false;\n }\n\n decision.status = status;\n decision.updatedAt = new Date();\n\n if (notes) {\n decision.rationale = `${decision.rationale}\\n\\nUpdate: ${notes}`;\n }\n\n this.updateStatistics();\n this.log.updatedAt = new Date();\n\n logger.info('Updated decision status', {\n id: decisionId,\n status,\n });\n\n if (this.options.autoSave) {\n this.save();\n }\n\n return true;\n }\n\n /**\n * Add consensus information to a decision\n */\n addConsensusInfo(decisionId: string, consensus: ConsensusInfo): boolean {\n const decision = this.log.decisions.find(d => d.id === decisionId);\n if (!decision) {\n logger.warn('Decision not found', { decisionId });\n return false;\n }\n\n decision.consensus = consensus;\n decision.updatedAt = new Date();\n\n // Update status based on consensus outcome\n if (consensus.achieved) {\n decision.status = 'approved';\n }\n\n this.updateStatistics();\n this.log.updatedAt = new Date();\n\n logger.info('Added consensus info', {\n id: decisionId,\n achieved: consensus.achieved,\n method: consensus.method,\n });\n\n if (this.options.autoSave) {\n this.save();\n }\n\n return true;\n }\n\n /**\n * Get all decisions\n */\n getDecisions(): DecisionEntry[] {\n return [...this.log.decisions];\n }\n\n /**\n * Get decisions by phase\n */\n getDecisionsByPhase(phase: SPARCPhase): DecisionEntry[] {\n return this.log.decisions.filter(d => d.phase === phase);\n }\n\n /**\n * Get decisions by confidence level\n */\n getDecisionsByConfidence(confidence: ConfidenceLevel): DecisionEntry[] {\n return this.log.decisions.filter(d => d.confidence === confidence);\n }\n\n /**\n * Get low confidence decisions requiring review\n */\n getLowConfidenceDecisions(): DecisionEntry[] {\n return this.log.decisions.filter(\n d => d.confidence === 'low' || d.confidence === 'uncertain'\n );\n }\n\n /**\n * Get decisions requiring consensus\n */\n getDecisionsRequiringConsensus(): DecisionEntry[] {\n return this.log.decisions.filter(\n d => d.consensus?.required && !d.consensus?.achieved\n );\n }\n\n /**\n * Get decision by ID\n */\n getDecision(id: string): DecisionEntry | undefined {\n return this.log.decisions.find(d => d.id === id);\n }\n\n /**\n * Get the full log\n */\n getLog(): DecisionLog {\n return { ...this.log };\n }\n\n /**\n * Get statistics\n */\n getStatistics(): DecisionLog['statistics'] {\n return { ...this.log.statistics };\n }\n\n /**\n * Update statistics\n */\n private updateStatistics(): void {\n const decisions = this.log.decisions;\n\n this.log.statistics = {\n total: decisions.length,\n approved: decisions.filter(d => d.status === 'approved').length,\n rejected: decisions.filter(d => d.status === 'rejected').length,\n deferred: decisions.filter(d => d.status === 'deferred').length,\n highConfidence: decisions.filter(d => d.confidence === 'high').length,\n lowConfidence: decisions.filter(\n d => d.confidence === 'low' || d.confidence === 'uncertain'\n ).length,\n consensusRequired: decisions.filter(d => d.consensus?.required).length,\n };\n }\n\n /**\n * Save the log to disk\n */\n save(): void {\n const dir = dirname(this.logPath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n writeFileSync(this.logPath, JSON.stringify(this.log, null, 2));\n logger.debug('Saved decision log', { path: this.logPath });\n }\n\n /**\n * Export log as markdown\n */\n exportMarkdown(): string {\n const lines: string[] = [\n '# Decision Log',\n '',\n `**Plan ID:** ${this.log.planId}`,\n `**Created:** ${this.log.createdAt.toISOString()}`,\n `**Updated:** ${this.log.updatedAt.toISOString()}`,\n '',\n '## Statistics',\n '',\n `| Metric | Count |`,\n `|--------|-------|`,\n `| Total Decisions | ${this.log.statistics.total} |`,\n `| Approved | ${this.log.statistics.approved} |`,\n `| Rejected | ${this.log.statistics.rejected} |`,\n `| Deferred | ${this.log.statistics.deferred} |`,\n `| High Confidence | ${this.log.statistics.highConfidence} |`,\n `| Low Confidence | ${this.log.statistics.lowConfidence} |`,\n `| Consensus Required | ${this.log.statistics.consensusRequired} |`,\n '',\n '## Decisions',\n '',\n ];\n\n // Group by phase\n const phases: SPARCPhase[] = ['specification', 'pseudocode', 'architecture', 'refinement', 'completion'];\n\n for (const phase of phases) {\n const phaseDecisions = this.getDecisionsByPhase(phase);\n if (phaseDecisions.length === 0) continue;\n\n lines.push(`### ${phase.charAt(0).toUpperCase() + phase.slice(1)} Phase`);\n lines.push('');\n\n for (const decision of phaseDecisions) {\n lines.push(`#### ${decision.title}`);\n lines.push('');\n lines.push(`- **ID:** ${decision.id}`);\n lines.push(`- **Status:** ${decision.status}`);\n lines.push(`- **Confidence:** ${decision.confidence}`);\n lines.push(`- **Decided By:** ${decision.decidedBy}`);\n lines.push(`- **Date:** ${decision.createdAt.toISOString()}`);\n lines.push('');\n lines.push('**Description:**');\n lines.push(decision.description);\n lines.push('');\n lines.push('**Rationale:**');\n lines.push(decision.rationale);\n lines.push('');\n\n if (decision.alternatives.length > 0) {\n lines.push('**Alternatives Considered:**');\n for (const alt of decision.alternatives) {\n lines.push(`- ${alt}`);\n }\n lines.push('');\n }\n\n if (decision.impact) {\n lines.push('**Impact:**');\n lines.push(decision.impact);\n lines.push('');\n }\n\n if (decision.consensus) {\n lines.push('**Consensus:**');\n lines.push(`- Required: ${decision.consensus.required}`);\n lines.push(`- Achieved: ${decision.consensus.achieved}`);\n lines.push(`- Method: ${decision.consensus.method}`);\n lines.push(`- Outcome: ${decision.consensus.outcome}`);\n lines.push('');\n }\n\n lines.push('---');\n lines.push('');\n }\n }\n\n return lines.join('\\n');\n }\n\n /**\n * Save markdown export\n */\n saveMarkdown(): void {\n const mdPath = join(this.options.outputDir, 'decision-log.md');\n const dir = dirname(mdPath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n writeFileSync(mdPath, this.exportMarkdown());\n logger.info('Saved decision log markdown', { path: mdPath });\n }\n}\n\n/**\n * Create a decision log manager\n */\nexport function createDecisionLogManager(options: DecisionLogManagerOptions): DecisionLogManager {\n return new DecisionLogManager(options);\n}\n"],"names":[],"mappings":";;;AAqBA,MAAM,SAAS,aAAa,cAAc;AA+CnC,MAAM,mBAAmB;AAAA,EACtB;AAAA,EACS;AAAA,EACA;AAAA,EAEjB,YAAY,SAAoC;AAC9C,SAAK,UAAU;AAAA,MACb,UAAU;AAAA,MACV,GAAG;AAAA,IAAA;AAGL,SAAK,UAAU,KAAK,KAAK,QAAQ,WAAW,mBAAmB;AAG/D,SAAK,MAAM,KAAK,aAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKQ,eAA4B;AAClC,QAAI,WAAW,KAAK,OAAO,GAAG;AAC5B,UAAI;AACF,cAAM,UAAU,aAAa,KAAK,SAAS,OAAO;AAClD,cAAM,SAAS,KAAK,MAAM,OAAO;AAEjC,eAAO,YAAY,IAAI,KAAK,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cAAc;AACvC,kBAAM,KAAK,KAAK,GAAG,EAAE;AAAA,UACvB;AACA,gBAAM,KAAK,EAAE;AAAA,QACf;AAEA,YAAI,SAAS,QAAQ;AACnB,gBAAM,KAAK,aAAa;AACxB,gBAAM,KAAK,SAAS,MAAM;AAC1B,gBAAM,KAAK,EAAE;AAAA,QACf;AAEA,YAAI,SAAS,WAAW;AACtB,gBAAM,KAAK,gBAAgB;AAC3B,gBAAM,KAAK,eAAe,SAAS,UAAU,QAAQ,EAAE;AACvD,gBAAM,KAAK,eAAe,SAAS,UAAU,QAAQ,EAAE;AACvD,gBAAM,KAAK,aAAa,SAAS,UAAU,MAAM,EAAE;AACnD,gBAAM,KAAK,cAAc,SAAS,UAAU,OAAO,EAAE;AACrD,gBAAM,KAAK,EAAE;AAAA,QACf;AAEA,cAAM,KAAK,KAAK;AAChB,cAAM,KAAK,EAAE;AAAA,MACf;AAAA,IACF;AAEA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKA,eAAqB;AACnB,UAAM,SAAS,KAAK,KAAK,QAAQ,WAAW,iBAAiB;AAC7D,UAAM,MAAM,QAAQ,MAAM;AAC1B,QAAI,CAAC,WAAW,GAAG,GAAG;AACpB,gBAAU,KAAK,EAAE,WAAW,KAAA,CAAM;AAAA,IACpC;AAEA,kBAAc,QAAQ,KAAK,gBAAgB;AAC3C,WAAO,KAAK,+BAA+B,EAAE,MAAM,QAAQ;AAAA,EAC7D;AACF;AAKO,SAAS,yBAAyB,SAAwD;AAC/F,SAAO,IAAI,mBAAmB,OAAO;AACvC;"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SPARC Planning Module
3
+ *
4
+ * Comprehensive SPARC (Specification, Pseudocode, Architecture, Refinement, Completion)
5
+ * planning system with consensus building, decision logging, and review processes.
6
+ *
7
+ * @module sparc
8
+ */
9
+ export * from './types.js';
10
+ export { DecisionLogManager, createDecisionLogManager, type DecisionLogManagerOptions, type AddDecisionOptions, } from './decision-log.js';
11
+ export { ConsensusBuilder, createConsensusBuilder, type ConsensusBuilderOptions, type AgentVote, type ConsensusOption, } from './consensus.js';
12
+ export { ReviewProcessManager, createReviewProcess, type ReviewProcessOptions, } from './review-process.js';
13
+ export { SPARCPlanner, createSPARCPlanner, type SPARCPlannerOptions, } from './sparc-planner.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sparc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DecisionLogManager, createDecisionLogManager } from "./decision-log.js";
2
+ import { ConsensusBuilder, createConsensusBuilder } from "./consensus.js";
3
+ import { ReviewProcessManager, createReviewProcess } from "./review-process.js";
4
+ import { SPARCPlanner, createSPARCPlanner } from "./sparc-planner.js";
5
+ export {
6
+ ConsensusBuilder,
7
+ DecisionLogManager,
8
+ ReviewProcessManager,
9
+ SPARCPlanner,
10
+ createConsensusBuilder,
11
+ createDecisionLogManager,
12
+ createReviewProcess,
13
+ createSPARCPlanner
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Review Process Manager
3
+ *
4
+ * Implements the 3-pass review system for SPARC plans:
5
+ * 1. Documentation review
6
+ * 2. Code review
7
+ * 3. SPARC specification review
8
+ *
9
+ * @module sparc/review-process
10
+ */
11
+ import type { ReviewFinding, ReviewResult, FindingSeverity, SPARCPlan } from './types.js';
12
+ /**
13
+ * Review process options
14
+ */
15
+ export interface ReviewProcessOptions {
16
+ /** Plan being reviewed */
17
+ plan: SPARCPlan;
18
+ /** Number of review passes (default 3) */
19
+ passes?: number;
20
+ /** Auto-fix minor issues */
21
+ autoFix?: boolean;
22
+ /** Strict mode - fail on any finding */
23
+ strictMode?: boolean;
24
+ }
25
+ /**
26
+ * Review Process Manager
27
+ *
28
+ * Executes the 3-pass review system.
29
+ */
30
+ export declare class ReviewProcessManager {
31
+ private readonly plan;
32
+ private readonly options;
33
+ private passes;
34
+ constructor(options: ReviewProcessOptions);
35
+ /**
36
+ * Execute the full review process
37
+ */
38
+ executeReview(): Promise<ReviewResult>;
39
+ /**
40
+ * Execute a single review pass
41
+ */
42
+ private executePass;
43
+ /**
44
+ * Compile all pass results into final result
45
+ */
46
+ private compileResults;
47
+ /**
48
+ * Deduplicate findings across passes
49
+ */
50
+ private deduplicateFindings;
51
+ /**
52
+ * Generate recommendations based on findings
53
+ */
54
+ private generateRecommendations;
55
+ /**
56
+ * Get findings by severity
57
+ */
58
+ getFindingsBySeverity(severity: FindingSeverity): ReviewFinding[];
59
+ /**
60
+ * Get all open findings
61
+ */
62
+ getOpenFindings(): ReviewFinding[];
63
+ /**
64
+ * Mark finding as resolved
65
+ */
66
+ resolveFinding(findingId: string, resolution: string): boolean;
67
+ }
68
+ /**
69
+ * Create a review process manager
70
+ */
71
+ export declare function createReviewProcess(options: ReviewProcessOptions): ReviewProcessManager;
72
+ //# sourceMappingURL=review-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-process.d.ts","sourceRoot":"","sources":["../../src/sparc/review-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAEV,aAAa,EAEb,YAAY,EACZ,eAAe,EACf,SAAS,EACV,MAAM,YAAY,CAAC;AAIpB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA+cD;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,MAAM,CAA0B;gBAE5B,OAAO,EAAE,oBAAoB;IAUzC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;IAsC5C;;OAEG;YACW,WAAW;IAuCzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAiCtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAe3B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAuC/B;;OAEG;IACH,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,aAAa,EAAE;IAMjE;;OAEG;IACH,eAAe,IAAI,aAAa,EAAE;IAMlC;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;CAW/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,oBAAoB,CAEvF"}