specweave 0.3.13 → 0.4.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.
- package/CLAUDE.md +17 -1
- package/README.md +1 -1
- package/bin/install-all.sh +9 -2
- package/bin/install-hooks.sh +57 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +55 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/core/agent-model-manager.d.ts +52 -0
- package/dist/core/agent-model-manager.d.ts.map +1 -0
- package/dist/core/agent-model-manager.js +120 -0
- package/dist/core/agent-model-manager.js.map +1 -0
- package/dist/core/cost-tracker.d.ts +108 -0
- package/dist/core/cost-tracker.d.ts.map +1 -0
- package/dist/core/cost-tracker.js +281 -0
- package/dist/core/cost-tracker.js.map +1 -0
- package/dist/core/model-selector.d.ts +57 -0
- package/dist/core/model-selector.d.ts.map +1 -0
- package/dist/core/model-selector.js +115 -0
- package/dist/core/model-selector.js.map +1 -0
- package/dist/core/phase-detector.d.ts +62 -0
- package/dist/core/phase-detector.d.ts.map +1 -0
- package/dist/core/phase-detector.js +229 -0
- package/dist/core/phase-detector.js.map +1 -0
- package/dist/types/cost-tracking.d.ts +43 -0
- package/dist/types/cost-tracking.d.ts.map +1 -0
- package/dist/types/cost-tracking.js +8 -0
- package/dist/types/cost-tracking.js.map +1 -0
- package/dist/types/model-selection.d.ts +53 -0
- package/dist/types/model-selection.d.ts.map +1 -0
- package/dist/types/model-selection.js +12 -0
- package/dist/types/model-selection.js.map +1 -0
- package/dist/utils/cost-reporter.d.ts +58 -0
- package/dist/utils/cost-reporter.d.ts.map +1 -0
- package/dist/utils/cost-reporter.js +224 -0
- package/dist/utils/cost-reporter.js.map +1 -0
- package/dist/utils/pricing-constants.d.ts +70 -0
- package/dist/utils/pricing-constants.d.ts.map +1 -0
- package/dist/utils/pricing-constants.js +71 -0
- package/dist/utils/pricing-constants.js.map +1 -0
- package/package.json +1 -1
- package/src/agents/architect/AGENT.md +3 -0
- package/src/agents/code-reviewer.md +156 -0
- package/src/agents/data-scientist/AGENT.md +181 -0
- package/src/agents/database-optimizer/AGENT.md +147 -0
- package/src/agents/devops/AGENT.md +3 -0
- package/src/agents/diagrams-architect/AGENT.md +3 -0
- package/src/agents/docs-writer/AGENT.md +3 -0
- package/src/agents/kubernetes-architect/AGENT.md +142 -0
- package/src/agents/ml-engineer/AGENT.md +150 -0
- package/src/agents/mlops-engineer/AGENT.md +201 -0
- package/src/agents/network-engineer/AGENT.md +149 -0
- package/src/agents/observability-engineer/AGENT.md +213 -0
- package/src/agents/payment-integration/AGENT.md +35 -0
- package/src/agents/performance/AGENT.md +3 -0
- package/src/agents/performance-engineer/AGENT.md +153 -0
- package/src/agents/pm/AGENT.md +3 -0
- package/src/agents/qa-lead/AGENT.md +3 -0
- package/src/agents/security/AGENT.md +3 -0
- package/src/agents/sre/AGENT.md +3 -0
- package/src/agents/tdd-orchestrator/AGENT.md +169 -0
- package/src/agents/tech-lead/AGENT.md +3 -0
- package/src/commands/specweave.costs.md +261 -0
- package/src/commands/specweave.ml-pipeline.md +292 -0
- package/src/commands/specweave.monitor-setup.md +501 -0
- package/src/commands/specweave.slo-implement.md +1055 -0
- package/src/commands/specweave.sync-github.md +1 -1
- package/src/commands/specweave.tdd-cycle.md +199 -0
- package/src/commands/specweave.tdd-green.md +842 -0
- package/src/commands/specweave.tdd-red.md +135 -0
- package/src/commands/specweave.tdd-refactor.md +165 -0
- package/src/skills/SKILLS-INDEX.md +18 -10
- package/src/skills/billing-automation/SKILL.md +559 -0
- package/src/skills/distributed-tracing/SKILL.md +438 -0
- package/src/skills/e2e-playwright/README.md +1 -1
- package/src/skills/e2e-playwright/package.json +1 -1
- package/src/skills/gitops-workflow/SKILL.md +285 -0
- package/src/skills/gitops-workflow/references/argocd-setup.md +134 -0
- package/src/skills/gitops-workflow/references/sync-policies.md +131 -0
- package/src/skills/grafana-dashboards/SKILL.md +369 -0
- package/src/skills/helm-chart-scaffolding/SKILL.md +544 -0
- package/src/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/src/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/src/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/src/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/src/skills/k8s-manifest-generator/SKILL.md +511 -0
- package/src/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
- package/src/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
- package/src/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
- package/src/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
- package/src/skills/k8s-manifest-generator/references/service-spec.md +724 -0
- package/src/skills/k8s-security-policies/SKILL.md +334 -0
- package/src/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
- package/src/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
- package/src/skills/ml-pipeline-workflow/SKILL.md +245 -0
- package/src/skills/paypal-integration/SKILL.md +467 -0
- package/src/skills/pci-compliance/SKILL.md +466 -0
- package/src/skills/prometheus-configuration/SKILL.md +392 -0
- package/src/skills/slo-implementation/SKILL.md +329 -0
- package/src/skills/stripe-integration/SKILL.md +442 -0
- package/src/skills/tdd-workflow/SKILL.md +378 -0
- package/src/templates/README.md.template +1 -1
- package/src/skills/bmad-method-expert/SKILL.md +0 -626
- package/src/skills/bmad-method-expert/scripts/analyze-project.js +0 -318
- package/src/skills/bmad-method-expert/scripts/check-setup.js +0 -208
- package/src/skills/bmad-method-expert/scripts/generate-template.js +0 -1149
- package/src/skills/bmad-method-expert/scripts/validate-documents.js +0 -340
- package/src/skills/context-optimizer/SKILL.md +0 -588
- package/src/skills/figma-designer/SKILL.md +0 -149
- package/src/skills/figma-implementer/SKILL.md +0 -148
- package/src/skills/figma-mcp-connector/SKILL.md +0 -136
- package/src/skills/figma-to-code/SKILL.md +0 -128
- package/src/skills/spec-kit-expert/SKILL.md +0 -1010
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost Report Generation
|
|
3
|
+
*
|
|
4
|
+
* Generates human-readable cost reports with multiple export formats:
|
|
5
|
+
* - JSON (machine-readable)
|
|
6
|
+
* - CSV (spreadsheet import)
|
|
7
|
+
* - ASCII Dashboard (CLI display)
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'fs-extra';
|
|
10
|
+
export class CostReporter {
|
|
11
|
+
constructor(costTracker) {
|
|
12
|
+
this.costTracker = costTracker;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generate cost report for a specific increment
|
|
16
|
+
*
|
|
17
|
+
* @param incrementId - Increment ID (e.g., '0003')
|
|
18
|
+
* @returns Aggregate cost report
|
|
19
|
+
*/
|
|
20
|
+
generateIncrementReport(incrementId) {
|
|
21
|
+
return this.costTracker.getIncrementCost(incrementId);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Export report to JSON file
|
|
25
|
+
*
|
|
26
|
+
* @param incrementId - Increment ID
|
|
27
|
+
* @param outputPath - Output file path
|
|
28
|
+
*/
|
|
29
|
+
async exportToJSON(incrementId, outputPath) {
|
|
30
|
+
const report = this.generateIncrementReport(incrementId);
|
|
31
|
+
await fs.writeJson(outputPath, report, { spaces: 2 });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Export report to CSV file
|
|
35
|
+
*
|
|
36
|
+
* @param incrementId - Increment ID
|
|
37
|
+
* @param outputPath - Output file path
|
|
38
|
+
*/
|
|
39
|
+
async exportToCSV(incrementId, outputPath) {
|
|
40
|
+
const sessions = this.costTracker.getIncrementSessions(incrementId);
|
|
41
|
+
// CSV headers
|
|
42
|
+
const headers = [
|
|
43
|
+
'Session ID',
|
|
44
|
+
'Agent',
|
|
45
|
+
'Model',
|
|
46
|
+
'Command',
|
|
47
|
+
'Started At',
|
|
48
|
+
'Ended At',
|
|
49
|
+
'Input Tokens',
|
|
50
|
+
'Output Tokens',
|
|
51
|
+
'Total Tokens',
|
|
52
|
+
'Cost ($)',
|
|
53
|
+
'Savings ($)',
|
|
54
|
+
];
|
|
55
|
+
// CSV rows
|
|
56
|
+
const rows = sessions.map((s) => [
|
|
57
|
+
s.sessionId,
|
|
58
|
+
s.agent,
|
|
59
|
+
s.model,
|
|
60
|
+
s.command || 'N/A',
|
|
61
|
+
s.startedAt,
|
|
62
|
+
s.endedAt || 'In Progress',
|
|
63
|
+
s.tokenUsage.inputTokens.toString(),
|
|
64
|
+
s.tokenUsage.outputTokens.toString(),
|
|
65
|
+
s.tokenUsage.totalTokens.toString(),
|
|
66
|
+
s.cost.toFixed(4),
|
|
67
|
+
s.savings.toFixed(4),
|
|
68
|
+
]);
|
|
69
|
+
// Generate CSV (simple implementation, no external deps)
|
|
70
|
+
const csv = [headers.join(','), ...rows.map((row) => row.join(','))].join('\n');
|
|
71
|
+
await fs.writeFile(outputPath, csv, 'utf-8');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Generate ASCII dashboard for CLI display
|
|
75
|
+
*
|
|
76
|
+
* @param incrementId - Optional increment ID (defaults to all increments)
|
|
77
|
+
* @returns ASCII table with cost breakdown
|
|
78
|
+
*/
|
|
79
|
+
generateDashboard(incrementId) {
|
|
80
|
+
if (incrementId) {
|
|
81
|
+
return this.generateIncrementDashboard(incrementId);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return this.generateOverallDashboard();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generate dashboard for a specific increment
|
|
89
|
+
*/
|
|
90
|
+
generateIncrementDashboard(incrementId) {
|
|
91
|
+
const report = this.generateIncrementReport(incrementId);
|
|
92
|
+
const sessions = this.costTracker.getIncrementSessions(incrementId);
|
|
93
|
+
if (sessions.length === 0) {
|
|
94
|
+
return `No cost data for increment ${incrementId}`;
|
|
95
|
+
}
|
|
96
|
+
const lines = [];
|
|
97
|
+
// Header
|
|
98
|
+
lines.push('');
|
|
99
|
+
lines.push('═══════════════════════════════════════════════════════════════');
|
|
100
|
+
lines.push(` Cost Report: Increment ${incrementId}`);
|
|
101
|
+
lines.push('═══════════════════════════════════════════════════════════════');
|
|
102
|
+
lines.push('');
|
|
103
|
+
// Summary
|
|
104
|
+
lines.push('SUMMARY');
|
|
105
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
106
|
+
lines.push(` Total Cost: $${report.totalCost.toFixed(4).padStart(10)}`);
|
|
107
|
+
lines.push(` Total Savings: $${report.totalSavings.toFixed(4).padStart(10)}`);
|
|
108
|
+
const baselineCost = report.totalCost + report.totalSavings;
|
|
109
|
+
const savingsPercentage = baselineCost > 0 ? (report.totalSavings / baselineCost) * 100 : 0;
|
|
110
|
+
lines.push(` Savings %: ${savingsPercentage.toFixed(1).padStart(10)}%`);
|
|
111
|
+
lines.push(` Total Tokens: ${report.totalTokens.toLocaleString().padStart(10)}`);
|
|
112
|
+
lines.push(` Sessions: ${report.sessionCount.toString().padStart(10)}`);
|
|
113
|
+
lines.push('');
|
|
114
|
+
// Cost by Model
|
|
115
|
+
lines.push('COST BY MODEL');
|
|
116
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
117
|
+
for (const [model, cost] of Object.entries(report.costByModel)) {
|
|
118
|
+
const percentage = (cost / report.totalCost) * 100;
|
|
119
|
+
lines.push(` ${model.padEnd(15)} $${cost.toFixed(4).padStart(10)} (${percentage.toFixed(1).padStart(5)}%)`);
|
|
120
|
+
}
|
|
121
|
+
lines.push('');
|
|
122
|
+
// Cost by Agent
|
|
123
|
+
lines.push('COST BY AGENT');
|
|
124
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
125
|
+
const sortedAgents = Object.entries(report.costByAgent).sort(([, a], [, b]) => b - a);
|
|
126
|
+
for (const [agent, cost] of sortedAgents.slice(0, 10)) {
|
|
127
|
+
// Top 10
|
|
128
|
+
const percentage = (cost / report.totalCost) * 100;
|
|
129
|
+
lines.push(` ${agent.padEnd(25)} $${cost.toFixed(4).padStart(8)} (${percentage.toFixed(1).padStart(5)}%)`);
|
|
130
|
+
}
|
|
131
|
+
if (sortedAgents.length > 10) {
|
|
132
|
+
lines.push(` ... and ${sortedAgents.length - 10} more agents`);
|
|
133
|
+
}
|
|
134
|
+
lines.push('');
|
|
135
|
+
// Recent Sessions (last 5)
|
|
136
|
+
lines.push('RECENT SESSIONS');
|
|
137
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
138
|
+
const recentSessions = sessions
|
|
139
|
+
.sort((a, b) => {
|
|
140
|
+
const timeA = new Date(a.startedAt).getTime();
|
|
141
|
+
const timeB = new Date(b.startedAt).getTime();
|
|
142
|
+
return timeB - timeA;
|
|
143
|
+
})
|
|
144
|
+
.slice(0, 5);
|
|
145
|
+
for (const session of recentSessions) {
|
|
146
|
+
const time = new Date(session.startedAt).toLocaleString();
|
|
147
|
+
lines.push(` ${time}`);
|
|
148
|
+
lines.push(` Agent: ${session.agent.padEnd(20)} Model: ${session.model}`);
|
|
149
|
+
lines.push(` Cost: $${session.cost.toFixed(4).padStart(8)} Savings: $${session.savings.toFixed(4).padStart(8)}`);
|
|
150
|
+
lines.push('');
|
|
151
|
+
}
|
|
152
|
+
lines.push('═══════════════════════════════════════════════════════════════');
|
|
153
|
+
lines.push('');
|
|
154
|
+
return lines.join('\n');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Generate dashboard for all increments
|
|
158
|
+
*/
|
|
159
|
+
generateOverallDashboard() {
|
|
160
|
+
const summary = this.costTracker.getSummary();
|
|
161
|
+
if (summary.totalSessions === 0) {
|
|
162
|
+
return 'No cost data available';
|
|
163
|
+
}
|
|
164
|
+
const lines = [];
|
|
165
|
+
// Header
|
|
166
|
+
lines.push('');
|
|
167
|
+
lines.push('═══════════════════════════════════════════════════════════════');
|
|
168
|
+
lines.push(' SpecWeave Cost Summary - All Increments');
|
|
169
|
+
lines.push('═══════════════════════════════════════════════════════════════');
|
|
170
|
+
lines.push('');
|
|
171
|
+
// Overall Summary
|
|
172
|
+
lines.push('OVERALL SUMMARY');
|
|
173
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
174
|
+
lines.push(` Total Cost: $${summary.totalCost.toFixed(4).padStart(10)}`);
|
|
175
|
+
lines.push(` Total Savings: $${summary.totalSavings.toFixed(4).padStart(10)}`);
|
|
176
|
+
lines.push(` Savings %: ${summary.savingsPercentage.toFixed(1).padStart(10)}%`);
|
|
177
|
+
lines.push(` Total Sessions: ${summary.totalSessions.toString().padStart(10)}`);
|
|
178
|
+
lines.push('');
|
|
179
|
+
// Agent Stats
|
|
180
|
+
if (summary.mostExpensiveAgent) {
|
|
181
|
+
lines.push('AGENT STATS');
|
|
182
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
183
|
+
lines.push(` Most Expensive: ${summary.mostExpensiveAgent}`);
|
|
184
|
+
if (summary.cheapestAgent !== summary.mostExpensiveAgent) {
|
|
185
|
+
lines.push(` Least Expensive: ${summary.cheapestAgent}`);
|
|
186
|
+
}
|
|
187
|
+
lines.push('');
|
|
188
|
+
}
|
|
189
|
+
// By Increment
|
|
190
|
+
const allSessions = this.costTracker.getAllSessions();
|
|
191
|
+
const incrementIds = [...new Set(allSessions.map((s) => s.increment).filter(Boolean))];
|
|
192
|
+
if (incrementIds.length > 0) {
|
|
193
|
+
lines.push('COST BY INCREMENT');
|
|
194
|
+
lines.push('───────────────────────────────────────────────────────────────');
|
|
195
|
+
for (const incrementId of incrementIds) {
|
|
196
|
+
const report = this.generateIncrementReport(incrementId);
|
|
197
|
+
lines.push(` ${incrementId.padEnd(30)} $${report.totalCost.toFixed(4).padStart(8)} (${report.sessionCount} sessions)`);
|
|
198
|
+
}
|
|
199
|
+
lines.push('');
|
|
200
|
+
}
|
|
201
|
+
lines.push('═══════════════════════════════════════════════════════════════');
|
|
202
|
+
lines.push('');
|
|
203
|
+
lines.push('💡 Tip: Use "/specweave.costs 0003" to see detailed report for increment 0003');
|
|
204
|
+
lines.push('');
|
|
205
|
+
return lines.join('\n');
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Generate compact one-line summary
|
|
209
|
+
*
|
|
210
|
+
* @param incrementId - Optional increment ID
|
|
211
|
+
* @returns One-line summary string
|
|
212
|
+
*/
|
|
213
|
+
generateSummaryLine(incrementId) {
|
|
214
|
+
if (incrementId) {
|
|
215
|
+
const report = this.generateIncrementReport(incrementId);
|
|
216
|
+
return `Increment ${incrementId}: $${report.totalCost.toFixed(4)} cost, $${report.totalSavings.toFixed(4)} saved (${((report.totalSavings / (report.totalCost + report.totalSavings)) * 100).toFixed(1)}%)`;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const summary = this.costTracker.getSummary();
|
|
220
|
+
return `Total: $${summary.totalCost.toFixed(4)} cost, $${summary.totalSavings.toFixed(4)} saved (${summary.savingsPercentage.toFixed(1)}%) across ${summary.totalSessions} sessions`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=cost-reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-reporter.js","sourceRoot":"","sources":["../../src/utils/cost-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,UAAU,CAAC;AAI1B,MAAM,OAAO,YAAY;IACvB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD;;;;;OAKG;IACH,uBAAuB,CAAC,WAAmB;QACzC,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,WAAmB,EAAE,UAAkB;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACzD,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,E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CAAC,WAAoB;QACtC,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;YACzD,OAAO,aAAa,WAAW,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9M,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;YAC9C,OAAO,WAAW,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,OAAO,CAAC,aAAa,WAAW,CAAC;QACvL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic API Pricing Constants
|
|
3
|
+
*
|
|
4
|
+
* Pricing as of 2025-10-31 (verified against https://www.anthropic.com/pricing)
|
|
5
|
+
*
|
|
6
|
+
* Model Tier Mapping:
|
|
7
|
+
* - sonnet → claude-sonnet-4-5-20250929 (latest Sonnet 4.5)
|
|
8
|
+
* - haiku → claude-4-5-haiku-20250110 (latest Haiku 4.5)
|
|
9
|
+
* - opus → claude-opus-4-0-... (when released)
|
|
10
|
+
*
|
|
11
|
+
* Note: This file should be updated when Anthropic releases new models.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Pricing per 1M tokens (input/output) in USD
|
|
15
|
+
*/
|
|
16
|
+
export declare const PRICING: {
|
|
17
|
+
readonly sonnet: {
|
|
18
|
+
readonly input: 0.000003;
|
|
19
|
+
readonly output: 0.000015;
|
|
20
|
+
};
|
|
21
|
+
readonly haiku: {
|
|
22
|
+
readonly input: 0.000001;
|
|
23
|
+
readonly output: 0.000005;
|
|
24
|
+
};
|
|
25
|
+
readonly opus: {
|
|
26
|
+
readonly input: 0.000015;
|
|
27
|
+
readonly output: 0.000075;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Calculate cost for a given model and token usage
|
|
32
|
+
*
|
|
33
|
+
* @param model - Model tier (sonnet, haiku, opus)
|
|
34
|
+
* @param inputTokens - Number of input tokens
|
|
35
|
+
* @param outputTokens - Number of output tokens
|
|
36
|
+
* @returns Total cost in USD
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const cost = calculateCost('haiku', 1000, 500);
|
|
41
|
+
* // Returns: 0.0035 ($0.0035 = $0.001 input + $0.0025 output)
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateCost(model: 'sonnet' | 'haiku' | 'opus', inputTokens: number, outputTokens: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Get pricing constants for a specific model
|
|
47
|
+
*
|
|
48
|
+
* @param model - Model tier
|
|
49
|
+
* @returns Pricing object with input/output costs
|
|
50
|
+
*/
|
|
51
|
+
export declare function getModelPricing(model: 'sonnet' | 'haiku' | 'opus'): {
|
|
52
|
+
readonly input: 0.000003;
|
|
53
|
+
readonly output: 0.000015;
|
|
54
|
+
} | {
|
|
55
|
+
readonly input: 0.000001;
|
|
56
|
+
readonly output: 0.000005;
|
|
57
|
+
} | {
|
|
58
|
+
readonly input: 0.000015;
|
|
59
|
+
readonly output: 0.000075;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Calculate cost savings vs baseline (all-Sonnet)
|
|
63
|
+
*
|
|
64
|
+
* @param actualModel - Model actually used
|
|
65
|
+
* @param inputTokens - Input tokens
|
|
66
|
+
* @param outputTokens - Output tokens
|
|
67
|
+
* @returns Savings amount in dollars (positive = saved money)
|
|
68
|
+
*/
|
|
69
|
+
export declare function calculateSavings(actualModel: 'sonnet' | 'haiku' | 'opus', inputTokens: number, outputTokens: number): number;
|
|
70
|
+
//# sourceMappingURL=pricing-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-constants.d.ts","sourceRoot":"","sources":["../../src/utils/pricing-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAaV,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,EAClC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM;;;;;;;;;EAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,EACxC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CAMR"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic API Pricing Constants
|
|
3
|
+
*
|
|
4
|
+
* Pricing as of 2025-10-31 (verified against https://www.anthropic.com/pricing)
|
|
5
|
+
*
|
|
6
|
+
* Model Tier Mapping:
|
|
7
|
+
* - sonnet → claude-sonnet-4-5-20250929 (latest Sonnet 4.5)
|
|
8
|
+
* - haiku → claude-4-5-haiku-20250110 (latest Haiku 4.5)
|
|
9
|
+
* - opus → claude-opus-4-0-... (when released)
|
|
10
|
+
*
|
|
11
|
+
* Note: This file should be updated when Anthropic releases new models.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Pricing per 1M tokens (input/output) in USD
|
|
15
|
+
*/
|
|
16
|
+
export const PRICING = {
|
|
17
|
+
sonnet: {
|
|
18
|
+
input: 0.000003, // $3 per 1M input tokens
|
|
19
|
+
output: 0.000015, // $15 per 1M output tokens
|
|
20
|
+
},
|
|
21
|
+
haiku: {
|
|
22
|
+
input: 0.000001, // $1 per 1M input tokens
|
|
23
|
+
output: 0.000005, // $5 per 1M output tokens
|
|
24
|
+
},
|
|
25
|
+
opus: {
|
|
26
|
+
input: 0.000015, // $15 per 1M input tokens
|
|
27
|
+
output: 0.000075, // $75 per 1M output tokens
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Calculate cost for a given model and token usage
|
|
32
|
+
*
|
|
33
|
+
* @param model - Model tier (sonnet, haiku, opus)
|
|
34
|
+
* @param inputTokens - Number of input tokens
|
|
35
|
+
* @param outputTokens - Number of output tokens
|
|
36
|
+
* @returns Total cost in USD
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const cost = calculateCost('haiku', 1000, 500);
|
|
41
|
+
* // Returns: 0.0035 ($0.0035 = $0.001 input + $0.0025 output)
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function calculateCost(model, inputTokens, outputTokens) {
|
|
45
|
+
const pricing = PRICING[model];
|
|
46
|
+
return (inputTokens * pricing.input) + (outputTokens * pricing.output);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get pricing constants for a specific model
|
|
50
|
+
*
|
|
51
|
+
* @param model - Model tier
|
|
52
|
+
* @returns Pricing object with input/output costs
|
|
53
|
+
*/
|
|
54
|
+
export function getModelPricing(model) {
|
|
55
|
+
return PRICING[model];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Calculate cost savings vs baseline (all-Sonnet)
|
|
59
|
+
*
|
|
60
|
+
* @param actualModel - Model actually used
|
|
61
|
+
* @param inputTokens - Input tokens
|
|
62
|
+
* @param outputTokens - Output tokens
|
|
63
|
+
* @returns Savings amount in dollars (positive = saved money)
|
|
64
|
+
*/
|
|
65
|
+
export function calculateSavings(actualModel, inputTokens, outputTokens) {
|
|
66
|
+
const actualCost = calculateCost(actualModel, inputTokens, outputTokens);
|
|
67
|
+
const baselineCost = calculateCost('sonnet', inputTokens, outputTokens);
|
|
68
|
+
const savedAmount = baselineCost - actualCost;
|
|
69
|
+
return savedAmount;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=pricing-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-constants.js","sourceRoot":"","sources":["../../src/utils/pricing-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM,EAAE;QACN,KAAK,EAAE,QAAQ,EAAI,yBAAyB;QAC5C,MAAM,EAAE,QAAQ,EAAG,2BAA2B;KAC/C;IACD,KAAK,EAAE;QACL,KAAK,EAAE,QAAQ,EAAI,yBAAyB;QAC5C,MAAM,EAAE,QAAQ,EAAG,0BAA0B;KAC9C;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,QAAQ,EAAI,0BAA0B;QAC7C,MAAM,EAAE,QAAQ,EAAG,2BAA2B;KAC/C;CACO,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAkC,EAClC,WAAmB,EACnB,YAAoB;IAEpB,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkC;IAChE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAwC,EACxC,WAAmB,EACnB,YAAoB;IAEpB,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACzE,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;IAE9C,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specweave",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Replace vibe coding with spec-driven development. Smart workflow: /specweave inc auto-closes previous, /specweave build auto-resumes, /specweave progress shows status. PM-led planning, 10 agents, 35+ skills. spec-weave.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -3,6 +3,9 @@ name: architect
|
|
|
3
3
|
description: System Architect and technical design expert. Creates system architecture, technical specifications, Architecture Decision Records (ADRs), component designs, API contracts, data models, and deployment architectures. Handles design patterns, scalability planning, technology stack decisions, microservices architecture, event-driven systems, CQRS, domain-driven design. Activates for: architecture, system design, technical design, ADR, architecture decision record, design patterns, microservices, API design, data model, database schema, scalability, performance architecture, technology stack, tech stack selection, distributed systems, event-driven, CQRS, DDD, domain model, component architecture, integration patterns, CAP theorem, consistency, availability, partition tolerance.
|
|
4
4
|
tools: Read, Write, Edit
|
|
5
5
|
model: claude-sonnet-4-5-20250929
|
|
6
|
+
model_preference: sonnet
|
|
7
|
+
cost_profile: planning
|
|
8
|
+
fallback_behavior: strict
|
|
6
9
|
---
|
|
7
10
|
|
|
8
11
|
# Architect Agent - System Architecture & Technical Design Expert
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-reviewer
|
|
3
|
+
description: Elite code review expert specializing in modern AI-powered code analysis, security vulnerabilities, performance optimization, and production reliability. Masters static analysis tools, security scanning, and configuration review with 2024/2025 best practices. Use PROACTIVELY for code quality assurance.
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an elite code review expert specializing in modern code analysis techniques, AI-powered review tools, and production-grade quality assurance.
|
|
8
|
+
|
|
9
|
+
## Expert Purpose
|
|
10
|
+
Master code reviewer focused on ensuring code quality, security, performance, and maintainability using cutting-edge analysis tools and techniques. Combines deep technical expertise with modern AI-assisted review processes, static analysis tools, and production reliability practices to deliver comprehensive code assessments that prevent bugs, security vulnerabilities, and production incidents.
|
|
11
|
+
|
|
12
|
+
## Capabilities
|
|
13
|
+
|
|
14
|
+
### AI-Powered Code Analysis
|
|
15
|
+
- Integration with modern AI review tools (Trag, Bito, Codiga, GitHub Copilot)
|
|
16
|
+
- Natural language pattern definition for custom review rules
|
|
17
|
+
- Context-aware code analysis using LLMs and machine learning
|
|
18
|
+
- Automated pull request analysis and comment generation
|
|
19
|
+
- Real-time feedback integration with CLI tools and IDEs
|
|
20
|
+
- Custom rule-based reviews with team-specific patterns
|
|
21
|
+
- Multi-language AI code analysis and suggestion generation
|
|
22
|
+
|
|
23
|
+
### Modern Static Analysis Tools
|
|
24
|
+
- SonarQube, CodeQL, and Semgrep for comprehensive code scanning
|
|
25
|
+
- Security-focused analysis with Snyk, Bandit, and OWASP tools
|
|
26
|
+
- Performance analysis with profilers and complexity analyzers
|
|
27
|
+
- Dependency vulnerability scanning with npm audit, pip-audit
|
|
28
|
+
- License compliance checking and open source risk assessment
|
|
29
|
+
- Code quality metrics with cyclomatic complexity analysis
|
|
30
|
+
- Technical debt assessment and code smell detection
|
|
31
|
+
|
|
32
|
+
### Security Code Review
|
|
33
|
+
- OWASP Top 10 vulnerability detection and prevention
|
|
34
|
+
- Input validation and sanitization review
|
|
35
|
+
- Authentication and authorization implementation analysis
|
|
36
|
+
- Cryptographic implementation and key management review
|
|
37
|
+
- SQL injection, XSS, and CSRF prevention verification
|
|
38
|
+
- Secrets and credential management assessment
|
|
39
|
+
- API security patterns and rate limiting implementation
|
|
40
|
+
- Container and infrastructure security code review
|
|
41
|
+
|
|
42
|
+
### Performance & Scalability Analysis
|
|
43
|
+
- Database query optimization and N+1 problem detection
|
|
44
|
+
- Memory leak and resource management analysis
|
|
45
|
+
- Caching strategy implementation review
|
|
46
|
+
- Asynchronous programming pattern verification
|
|
47
|
+
- Load testing integration and performance benchmark review
|
|
48
|
+
- Connection pooling and resource limit configuration
|
|
49
|
+
- Microservices performance patterns and anti-patterns
|
|
50
|
+
- Cloud-native performance optimization techniques
|
|
51
|
+
|
|
52
|
+
### Configuration & Infrastructure Review
|
|
53
|
+
- Production configuration security and reliability analysis
|
|
54
|
+
- Database connection pool and timeout configuration review
|
|
55
|
+
- Container orchestration and Kubernetes manifest analysis
|
|
56
|
+
- Infrastructure as Code (Terraform, CloudFormation) review
|
|
57
|
+
- CI/CD pipeline security and reliability assessment
|
|
58
|
+
- Environment-specific configuration validation
|
|
59
|
+
- Secrets management and credential security review
|
|
60
|
+
- Monitoring and observability configuration verification
|
|
61
|
+
|
|
62
|
+
### Modern Development Practices
|
|
63
|
+
- Test-Driven Development (TDD) and test coverage analysis
|
|
64
|
+
- Behavior-Driven Development (BDD) scenario review
|
|
65
|
+
- Contract testing and API compatibility verification
|
|
66
|
+
- Feature flag implementation and rollback strategy review
|
|
67
|
+
- Blue-green and canary deployment pattern analysis
|
|
68
|
+
- Observability and monitoring code integration review
|
|
69
|
+
- Error handling and resilience pattern implementation
|
|
70
|
+
- Documentation and API specification completeness
|
|
71
|
+
|
|
72
|
+
### Code Quality & Maintainability
|
|
73
|
+
- Clean Code principles and SOLID pattern adherence
|
|
74
|
+
- Design pattern implementation and architectural consistency
|
|
75
|
+
- Code duplication detection and refactoring opportunities
|
|
76
|
+
- Naming convention and code style compliance
|
|
77
|
+
- Technical debt identification and remediation planning
|
|
78
|
+
- Legacy code modernization and refactoring strategies
|
|
79
|
+
- Code complexity reduction and simplification techniques
|
|
80
|
+
- Maintainability metrics and long-term sustainability assessment
|
|
81
|
+
|
|
82
|
+
### Team Collaboration & Process
|
|
83
|
+
- Pull request workflow optimization and best practices
|
|
84
|
+
- Code review checklist creation and enforcement
|
|
85
|
+
- Team coding standards definition and compliance
|
|
86
|
+
- Mentor-style feedback and knowledge sharing facilitation
|
|
87
|
+
- Code review automation and tool integration
|
|
88
|
+
- Review metrics tracking and team performance analysis
|
|
89
|
+
- Documentation standards and knowledge base maintenance
|
|
90
|
+
- Onboarding support and code review training
|
|
91
|
+
|
|
92
|
+
### Language-Specific Expertise
|
|
93
|
+
- JavaScript/TypeScript modern patterns and React/Vue best practices
|
|
94
|
+
- Python code quality with PEP 8 compliance and performance optimization
|
|
95
|
+
- Java enterprise patterns and Spring framework best practices
|
|
96
|
+
- Go concurrent programming and performance optimization
|
|
97
|
+
- Rust memory safety and performance critical code review
|
|
98
|
+
- C# .NET Core patterns and Entity Framework optimization
|
|
99
|
+
- PHP modern frameworks and security best practices
|
|
100
|
+
- Database query optimization across SQL and NoSQL platforms
|
|
101
|
+
|
|
102
|
+
### Integration & Automation
|
|
103
|
+
- GitHub Actions, GitLab CI/CD, and Jenkins pipeline integration
|
|
104
|
+
- Slack, Teams, and communication tool integration
|
|
105
|
+
- IDE integration with VS Code, IntelliJ, and development environments
|
|
106
|
+
- Custom webhook and API integration for workflow automation
|
|
107
|
+
- Code quality gates and deployment pipeline integration
|
|
108
|
+
- Automated code formatting and linting tool configuration
|
|
109
|
+
- Review comment template and checklist automation
|
|
110
|
+
- Metrics dashboard and reporting tool integration
|
|
111
|
+
|
|
112
|
+
## Behavioral Traits
|
|
113
|
+
- Maintains constructive and educational tone in all feedback
|
|
114
|
+
- Focuses on teaching and knowledge transfer, not just finding issues
|
|
115
|
+
- Balances thorough analysis with practical development velocity
|
|
116
|
+
- Prioritizes security and production reliability above all else
|
|
117
|
+
- Emphasizes testability and maintainability in every review
|
|
118
|
+
- Encourages best practices while being pragmatic about deadlines
|
|
119
|
+
- Provides specific, actionable feedback with code examples
|
|
120
|
+
- Considers long-term technical debt implications of all changes
|
|
121
|
+
- Stays current with emerging security threats and mitigation strategies
|
|
122
|
+
- Champions automation and tooling to improve review efficiency
|
|
123
|
+
|
|
124
|
+
## Knowledge Base
|
|
125
|
+
- Modern code review tools and AI-assisted analysis platforms
|
|
126
|
+
- OWASP security guidelines and vulnerability assessment techniques
|
|
127
|
+
- Performance optimization patterns for high-scale applications
|
|
128
|
+
- Cloud-native development and containerization best practices
|
|
129
|
+
- DevSecOps integration and shift-left security methodologies
|
|
130
|
+
- Static analysis tool configuration and custom rule development
|
|
131
|
+
- Production incident analysis and preventive code review techniques
|
|
132
|
+
- Modern testing frameworks and quality assurance practices
|
|
133
|
+
- Software architecture patterns and design principles
|
|
134
|
+
- Regulatory compliance requirements (SOC2, PCI DSS, GDPR)
|
|
135
|
+
|
|
136
|
+
## Response Approach
|
|
137
|
+
1. **Analyze code context** and identify review scope and priorities
|
|
138
|
+
2. **Apply automated tools** for initial analysis and vulnerability detection
|
|
139
|
+
3. **Conduct manual review** for logic, architecture, and business requirements
|
|
140
|
+
4. **Assess security implications** with focus on production vulnerabilities
|
|
141
|
+
5. **Evaluate performance impact** and scalability considerations
|
|
142
|
+
6. **Review configuration changes** with special attention to production risks
|
|
143
|
+
7. **Provide structured feedback** organized by severity and priority
|
|
144
|
+
8. **Suggest improvements** with specific code examples and alternatives
|
|
145
|
+
9. **Document decisions** and rationale for complex review points
|
|
146
|
+
10. **Follow up** on implementation and provide continuous guidance
|
|
147
|
+
|
|
148
|
+
## Example Interactions
|
|
149
|
+
- "Review this microservice API for security vulnerabilities and performance issues"
|
|
150
|
+
- "Analyze this database migration for potential production impact"
|
|
151
|
+
- "Assess this React component for accessibility and performance best practices"
|
|
152
|
+
- "Review this Kubernetes deployment configuration for security and reliability"
|
|
153
|
+
- "Evaluate this authentication implementation for OAuth2 compliance"
|
|
154
|
+
- "Analyze this caching strategy for race conditions and data consistency"
|
|
155
|
+
- "Review this CI/CD pipeline for security and deployment best practices"
|
|
156
|
+
- "Assess this error handling implementation for observability and debugging"
|