specweave 0.3.8 → 0.3.9

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.
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Model Selection Utilities
3
+ *
4
+ * Intelligent model selection for SpecWeave tasks based on complexity,
5
+ * instruction detail, and task characteristics.
6
+ *
7
+ * Strategy:
8
+ * - Haiku: Detailed instructions, clear acceptance criteria, mechanical work
9
+ * - Sonnet: Complex decisions, architecture, creative problem-solving
10
+ * - Opus: Critical architecture, high-stakes decisions (rare)
11
+ */
12
+ /**
13
+ * Keywords that suggest complex thinking is required (Sonnet territory)
14
+ */
15
+ const COMPLEX_KEYWORDS = [
16
+ 'design', 'architecture', 'architect', 'evaluate', 'choose', 'decide',
17
+ 'compare', 'analyze', 'research', 'investigate', 'plan', 'strategy',
18
+ 'refactor', 'optimize', 'tradeoff', 'consider', 'assess', 'review'
19
+ ];
20
+ /**
21
+ * Keywords that suggest simple implementation (Haiku territory)
22
+ */
23
+ const SIMPLE_KEYWORDS = [
24
+ 'implement', 'create', 'add', 'update', 'fix', 'write', 'install',
25
+ 'configure', 'setup', 'integrate', 'connect', 'deploy', 'build',
26
+ 'test', 'validate', 'document', 'format', 'style', 'lint'
27
+ ];
28
+ /**
29
+ * Keywords that suggest creative/critical work (Sonnet/Opus territory)
30
+ */
31
+ const CREATIVE_KEYWORDS = [
32
+ 'novel', 'innovative', 'unique', 'creative', 'original', 'new approach',
33
+ 'alternative', 'improve', 'enhance', 'redesign', 'rethink'
34
+ ];
35
+ /**
36
+ * Detects the optimal model for a given task
37
+ *
38
+ * @param task - The task to analyze
39
+ * @param options - Additional context (spec detail level, etc.)
40
+ * @returns Detection result with model recommendation and reasoning
41
+ */
42
+ export function detectModelForTask(task, options = {}) {
43
+ const taskText = `${task.content} ${task.description || ''}`.toLowerCase();
44
+ // Score-based detection
45
+ let haikuScore = 0;
46
+ let sonnetScore = 0;
47
+ let opusScore = 0;
48
+ // 1. Keyword analysis
49
+ COMPLEX_KEYWORDS.forEach(keyword => {
50
+ if (taskText.includes(keyword)) {
51
+ sonnetScore += 2;
52
+ }
53
+ });
54
+ SIMPLE_KEYWORDS.forEach(keyword => {
55
+ if (taskText.includes(keyword)) {
56
+ haikuScore += 1;
57
+ }
58
+ });
59
+ CREATIVE_KEYWORDS.forEach(keyword => {
60
+ if (taskText.includes(keyword)) {
61
+ sonnetScore += 3;
62
+ opusScore += 1;
63
+ }
64
+ });
65
+ // 2. Spec/plan reference analysis
66
+ if (task.specReference && options.specDetailLevel && options.specDetailLevel > 0.7) {
67
+ haikuScore += 3; // Has detailed spec reference
68
+ }
69
+ if (options.hasDetailedPlan) {
70
+ haikuScore += 2; // Implementation approach already defined
71
+ }
72
+ if (options.isArchitectural) {
73
+ sonnetScore += 4; // Architectural decisions need thinking
74
+ opusScore += 2;
75
+ }
76
+ // 3. Acceptance criteria analysis
77
+ if (task.acceptanceCriteria && task.acceptanceCriteria.length >= 3) {
78
+ haikuScore += 2; // Clear, specific criteria = can use Haiku
79
+ }
80
+ // 4. Priority analysis (P1 might need more careful attention)
81
+ if (task.priority === 'P1' && !options.hasDetailedPlan) {
82
+ sonnetScore += 1; // Critical work without plan = need thinking
83
+ }
84
+ // 5. Task complexity indicators
85
+ const hasFileReference = /src\/[a-zA-Z0-9\/\-_.]+\.(ts|js|tsx|jsx|py|java|go)/.test(taskText);
86
+ if (hasFileReference) {
87
+ haikuScore += 2; // Specific file paths = concrete instructions
88
+ }
89
+ const hasMultipleSteps = taskText.split(/\n|;|,/).length > 3;
90
+ if (hasMultipleSteps && options.hasDetailedPlan) {
91
+ haikuScore += 1; // Multi-step with plan = can execute mechanically
92
+ }
93
+ // Calculate confidence and select model
94
+ const totalScore = haikuScore + sonnetScore + opusScore;
95
+ const haikuConfidence = totalScore > 0 ? haikuScore / totalScore : 0;
96
+ const sonnetConfidence = totalScore > 0 ? sonnetScore / totalScore : 0;
97
+ const opusConfidence = totalScore > 0 ? opusScore / totalScore : 0;
98
+ // Decision logic
99
+ let selectedModel;
100
+ let confidence;
101
+ let reasoning;
102
+ if (opusScore > 5 && opusConfidence > 0.3) {
103
+ selectedModel = 'opus';
104
+ confidence = opusConfidence;
105
+ reasoning = 'Critical architectural decision requiring deep reasoning';
106
+ }
107
+ else if (haikuScore > sonnetScore && haikuConfidence > 0.5) {
108
+ selectedModel = 'haiku';
109
+ confidence = haikuConfidence;
110
+ reasoning = 'Clear instructions with detailed spec/plan - suitable for fast execution';
111
+ }
112
+ else if (sonnetScore > haikuScore || sonnetConfidence > 0.4) {
113
+ selectedModel = 'sonnet';
114
+ confidence = sonnetConfidence;
115
+ reasoning = 'Requires decision-making or complex implementation';
116
+ }
117
+ else {
118
+ // Default to sonnet for safety
119
+ selectedModel = 'sonnet';
120
+ confidence = 0.5;
121
+ reasoning = 'Default to sonnet for balanced quality and speed';
122
+ }
123
+ return {
124
+ model: selectedModel,
125
+ confidence,
126
+ reasoning
127
+ };
128
+ }
129
+ /**
130
+ * Batch detect models for multiple tasks
131
+ * Useful when generating tasks.md from plan.md
132
+ */
133
+ export function detectModelsForTasks(tasks, options = {}) {
134
+ const results = new Map();
135
+ tasks.forEach(task => {
136
+ const result = detectModelForTask(task, options);
137
+ results.set(task.id, result);
138
+ });
139
+ return results;
140
+ }
141
+ /**
142
+ * Format model hint for tasks.md
143
+ *
144
+ * @param model - The model tier
145
+ * @returns Formatted string for inclusion in tasks.md
146
+ */
147
+ export function formatModelHint(model) {
148
+ const icons = {
149
+ haiku: '⚡', // Fast
150
+ sonnet: '🧠', // Thinking
151
+ opus: '💎' // Premium
152
+ };
153
+ return `${icons[model]} ${model}`;
154
+ }
155
+ /**
156
+ * Parse model hint from tasks.md line
157
+ *
158
+ * @param line - A line from tasks.md
159
+ * @returns Detected model or null
160
+ */
161
+ export function parseModelHint(line) {
162
+ const haikuMatch = /⚡\s*haiku|model:\s*haiku/i.test(line);
163
+ const sonnetMatch = /🧠\s*sonnet|model:\s*sonnet/i.test(line);
164
+ const opusMatch = /💎\s*opus|model:\s*opus/i.test(line);
165
+ if (haikuMatch)
166
+ return 'haiku';
167
+ if (sonnetMatch)
168
+ return 'sonnet';
169
+ if (opusMatch)
170
+ return 'opus';
171
+ return null;
172
+ }
173
+ /**
174
+ * Cost estimation utilities
175
+ */
176
+ export function estimateTaskCost(model, estimatedTokens = 2000) {
177
+ // Approximate costs per 1M tokens (input + output blended)
178
+ const costPer1M = {
179
+ haiku: 1.25, // $0.25 input + $1.25 output = ~$1.25 blended
180
+ sonnet: 15.00, // $3 input + $15 output = ~$15 blended
181
+ opus: 75.00 // $15 input + $75 output = ~$75 blended
182
+ };
183
+ return (estimatedTokens / 1000000) * costPer1M[model];
184
+ }
185
+ /**
186
+ * Calculate total cost savings when using smart model selection
187
+ */
188
+ export function calculateCostSavings(tasksWithModels, averageTokensPerTask = 2000) {
189
+ let optimizedCost = 0;
190
+ let allSonnetCost = 0;
191
+ tasksWithModels.forEach((model) => {
192
+ optimizedCost += estimateTaskCost(model, averageTokensPerTask);
193
+ allSonnetCost += estimateTaskCost('sonnet', averageTokensPerTask);
194
+ });
195
+ const savings = allSonnetCost - optimizedCost;
196
+ const savingsPercent = (savings / allSonnetCost) * 100;
197
+ return {
198
+ optimizedCost,
199
+ allSonnetCost,
200
+ savings,
201
+ savingsPercent
202
+ };
203
+ }
204
+ //# sourceMappingURL=model-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-selection.js","sourceRoot":"","sources":["../../src/utils/model-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ;IACrE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU;IACnE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ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8CAA8C;QAC7D,MAAM,EAAE,KAAK,EAAE,uCAAuC;QACtD,IAAI,EAAE,KAAK,CAAI,wCAAwC;KACxD,CAAC;IAEF,OAAO,CAAC,eAAe,GAAG,OAAS,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,eAAuC,EACvC,uBAA+B,IAAI;IAOnC,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,aAAa,IAAI,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;QAC/D,aAAa,IAAI,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,aAAa,GAAG,aAAa,CAAC;IAC9C,MAAM,cAAc,GAAG,CAAC,OAAO,GAAG,aAAa,CAAC,GAAG,GAAG,CAAC;IAEvD,OAAO;QACL,aAAa;QACb,aAAa;QACb,OAAO;QACP,cAAc;KACf,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specweave",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
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",
@@ -23,6 +23,7 @@
23
23
  "generate:tests:skill": "ts-node scripts/generate-tests.ts",
24
24
  "test:all:generated": "bash scripts/run-all-tests.sh",
25
25
  "test:all": "npm test && npm run test:smoke && npm run test:integration",
26
+ "generate:skills-index": "ts-node src/utils/generate-skills-index.ts",
26
27
  "prepublishOnly": "npm run build",
27
28
  "install:agents": "bash bin/install-agents.sh",
28
29
  "install:skills": "bash bin/install-skills.sh",
@@ -18,9 +18,36 @@ Unlike Claude Code (native skills/agents/commands) and Cursor (simulated via .cu
18
18
  - Workspace instructions (.github/copilot/instructions.md)
19
19
  - Better code suggestions based on project context
20
20
  - Copilot Chat for Q&A
21
+ - **Progressive disclosure via SKILLS-INDEX.md** (NEW in v0.3.8) - Access all 35+ skills!
21
22
 
22
23
  ## What This Adapter Provides
23
24
 
25
+ ### 🔍 Progressive Disclosure (NEW)
26
+
27
+ SpecWeave now includes **SKILLS-INDEX.md** - enabling GitHub Copilot to discover and use all 35+ skills!
28
+
29
+ **How it works**:
30
+ 1. Read `.claude/skills/SKILLS-INDEX.md` (referenced in AGENTS.md)
31
+ 2. Match task to activation keywords
32
+ 3. Load specific SKILL.md when relevant
33
+ 4. Follow proven workflows
34
+
35
+ **Benefits**:
36
+ - ✅ **90% token savings** (5k vs 50k tokens)
37
+ - ✅ **Full skill access** - All 35+ skills now available to Copilot!
38
+ - ✅ **Consistent output** - Follow SpecWeave best practices
39
+
40
+ **Example**:
41
+ ```markdown
42
+ # From AGENTS.md, you learn about:
43
+ .claude/skills/SKILLS-INDEX.md # Single-file skill reference
44
+
45
+ # When user asks: "Plan a new feature"
46
+ # 1. Read SKILLS-INDEX.md → Find "increment-planner" skill
47
+ # 2. Load .claude/skills/increment-planner/SKILL.md
48
+ # 3. Follow the increment planning workflow
49
+ ```
50
+
24
51
  ### .github/copilot/instructions.md
25
52
  - **What**: Workspace guidance that Copilot reads automatically
26
53
  - **Contains**: Project structure, workflows, best practices
@@ -31,6 +31,35 @@ This is **meta-documentation** - teaching the AI how to behave!
31
31
 
32
32
  ## What This Adapter Provides
33
33
 
34
+ ### 🔍 Progressive Disclosure (NEW in v0.3.8)
35
+
36
+ SpecWeave now includes **SKILLS-INDEX.md** - enabling Cursor to efficiently discover and use all 35+ skills!
37
+
38
+ **How it works**:
39
+ 1. Read `.claude/skills/SKILLS-INDEX.md` (referenced in AGENTS.md)
40
+ 2. Match task to activation keywords (e.g., "feature planning" → increment-planner)
41
+ 3. Load specific SKILL.md when relevant
42
+ 4. Follow proven workflows
43
+
44
+ **Benefits**:
45
+ - ✅ **90% token savings** (5k vs 50k tokens - load only what you need)
46
+ - ✅ **Full skill access** - All 35+ skills now efficiently accessible!
47
+ - ✅ **Consistent output** - Follow SpecWeave best practices every time
48
+
49
+ **Example**:
50
+ ```markdown
51
+ # From AGENTS.md, Cursor learns about:
52
+ .claude/skills/SKILLS-INDEX.md # Single-file skill reference
53
+
54
+ # When user asks: "Plan a new feature for auth"
55
+ # 1. Read SKILLS-INDEX.md → Find "increment-planner" (matches "feature planning")
56
+ # 2. Load .claude/skills/increment-planner/SKILL.md
57
+ # 3. Follow the increment planning workflow
58
+ # Result: Proper spec.md, plan.md, tasks.md creation
59
+ ```
60
+
61
+ **Note**: While Claude Code activates skills automatically, Cursor simulates this by following the progressive disclosure pattern documented in AGENTS.md.
62
+
34
63
  ### .cursorrules (Workflow Instructions)
35
64
  - **What**: Complete workflow guide for SpecWeave
36
65
  - **How**: Teaches Cursor to act like skills/agents
@@ -59,6 +59,8 @@ The PM Agent acts as your AI Product Manager, helping you:
59
59
  └── roadmap.md # Product roadmap (if applicable)
60
60
  ```
61
61
 
62
+ **Rationale**: Internal docs = strategic, team-only content (architecture decisions, business strategy)
63
+
62
64
  **Format Rules**:
63
65
  - ✅ **Technology-agnostic** (WHAT and WHY only)
64
66
  - ✅ **Complete** (all details, no summaries)
@@ -617,7 +619,7 @@ PM Agent:
617
619
  5. Provide recommendation
618
620
 
619
621
  Output:
620
- - .specweave/docs/decisions/005-database-refactoring-business-case.md
622
+ - .specweave/docs/internal/decisions/005-database-refactoring-business-case.md
621
623
  - Stakeholder presentation (Markdown or slides)
622
624
  ```
623
625
 
@@ -17,6 +17,11 @@ You are helping the user implement a SpecWeave increment by executing tasks from
17
17
 
18
18
  # Or let it find active increment automatically
19
19
  /do
20
+
21
+ # Override model selection for all tasks (advanced)
22
+ /do <increment-id> --model haiku
23
+ /do <increment-id> --model sonnet
24
+ /do <increment-id> --model opus
20
25
  ```
21
26
 
22
27
  ## Arguments
@@ -25,6 +30,12 @@ You are helping the user implement a SpecWeave increment by executing tasks from
25
30
  - If omitted, finds the active in-progress increment automatically
26
31
  - **Smart resume**: Automatically starts from next incomplete task
27
32
 
33
+ - `--model <tier>`: Optional. Override model selection for all tasks
34
+ - `haiku`: Fast, cheap execution (3x faster, 20x cheaper than Sonnet)
35
+ - `sonnet`: Balanced quality and speed (default for complex tasks)
36
+ - `opus`: Maximum quality (rare, use only for critical decisions)
37
+ - If omitted, uses model hints from tasks.md (recommended)
38
+
28
39
  ---
29
40
 
30
41
  ## Workflow
@@ -67,6 +78,7 @@ You are helping the user implement a SpecWeave increment by executing tasks from
67
78
  1. **Parse tasks.md**:
68
79
  - Scan all tasks in order
69
80
  - Check completion status (`[x]` = complete, `[ ]` = incomplete)
81
+ - **Extract model hints** (⚡ haiku, 🧠 sonnet, 💎 opus)
70
82
  - Find first incomplete task
71
83
 
72
84
  2. **Determine starting point**:
@@ -74,17 +86,18 @@ You are helping the user implement a SpecWeave increment by executing tasks from
74
86
  - If tasks incomplete → Resume from first incomplete task
75
87
  - If no tasks started → Start from T001
76
88
 
77
- 3. **Show resume context**:
89
+ 3. **Show resume context with model optimization**:
78
90
  ```
79
91
  📊 Resume Context:
80
92
 
81
93
  Completed: 3/12 tasks (25%)
82
- ├─ [✅] T001: Setup auth module (P1)
83
- ├─ [✅] T002: Create user model (P1)
84
- ├─ [✅] T003: Implement JWT tokens (P1)
85
- └─ [⏳] T004: Add password hashing (P1) ← RESUMING HERE
94
+ ├─ [✅] T001: ⚡ haiku - Setup auth module (P1) [saved $0.04]
95
+ ├─ [✅] T002: ⚡ haiku - Create user model (P1) [saved $0.04]
96
+ ├─ [✅] T003: 🧠 sonnet - Implement JWT tokens (P1)
97
+ └─ [⏳] T004: ⚡ haiku - Add password hashing (P1) ← RESUMING HERE
86
98
 
87
99
  Remaining: 9 tasks (estimated 2 weeks)
100
+ Cost savings so far: $0.08 (67% cheaper than all-Sonnet)
88
101
  ```
89
102
 
90
103
  **Why smart resume?**
@@ -92,6 +105,7 @@ You are helping the user implement a SpecWeave increment by executing tasks from
92
105
  - ✅ Seamlessly continue after breaks
93
106
  - ✅ Prevents duplicate work
94
107
  - ✅ Shows progress at a glance
108
+ - ✅ **Cost optimization through smart model selection**
95
109
 
96
110
  ### Step 3: Update Status to In-Progress (if needed)
97
111
 
@@ -113,16 +127,23 @@ If already "in-progress", keep existing metadata.
113
127
 
114
128
  1. **Read task details**:
115
129
  - Task ID (T001, T002, etc.)
130
+ - **Model hint** (⚡ haiku, 🧠 sonnet, 💎 opus)
116
131
  - Description
117
132
  - Acceptance criteria
118
133
  - File paths affected
119
134
  - Implementation notes
120
135
 
121
- 2. **Execute task**:
136
+ 2. **Select execution model**:
137
+ - **Use model from task hint** (recommended, optimizes cost/speed)
138
+ - OR use `--model` override if specified by user
139
+ - Show selected model and reasoning
140
+
141
+ 3. **Execute task**:
122
142
  - Follow plan.md architecture
123
143
  - Implement using detected tech stack
124
144
  - Write clean, maintainable code
125
145
  - Add inline documentation
146
+ - **Track cost savings** when using Haiku
126
147
 
127
148
  3. **Mark task complete** in tasks.md:
128
149
  - Change `[ ]` → `[x]`
@@ -164,16 +185,18 @@ TASK T001: Create User model (PostgreSQL)
164
185
 
165
186
  📋 Task details:
166
187
  • File: src/models/User.ts
188
+ • Model: ⚡ haiku (clear instructions, specific file path)
167
189
  • Description: Create User model with Prisma
168
190
  • Acceptance: Model has id, email, passwordHash, createdAt fields
169
191
 
170
- 🔨 Executing...
192
+ Executing with Haiku (3x faster, ~$0.0025 vs $0.05 Sonnet)...
171
193
  ✓ Created src/models/User.ts
172
194
  ✓ Added Prisma schema definition
173
195
  ✓ Generated migration file
174
196
  ✓ Added inline documentation
175
197
 
176
198
  ✅ Task T001 completed
199
+ 💰 Cost savings: $0.0475 (95% cheaper than Sonnet)
177
200
 
178
201
  🔊 [Glass.aiff plays automatically via hook]
179
202
  🔔 Task completed! Remember to update documentation...
@@ -185,7 +208,7 @@ TASK T001: Create User model (PostgreSQL)
185
208
 
186
209
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
187
210
 
188
- Progress: 1/42 tasks (2%) | Estimated remaining: 3.9 weeks
211
+ Progress: 1/42 tasks (2%) | Cost savings so far: $0.05 | Estimated remaining: 3.9 weeks
189
212
 
190
213
  Moving to next task...
191
214
  ```