@compilr-dev/agents 0.3.0 → 0.3.2
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/dist/agent.d.ts +82 -1
- package/dist/agent.js +162 -23
- package/dist/context/manager.d.ts +8 -0
- package/dist/context/manager.js +25 -2
- package/dist/errors.d.ts +20 -1
- package/dist/errors.js +44 -2
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -1
- package/dist/messages/index.d.ts +12 -5
- package/dist/messages/index.js +53 -15
- package/dist/providers/gemini-native.d.ts +86 -0
- package/dist/providers/gemini-native.js +339 -0
- package/dist/providers/index.d.ts +7 -2
- package/dist/providers/index.js +7 -2
- package/dist/providers/ollama.d.ts +2 -2
- package/dist/providers/ollama.js +3 -3
- package/dist/providers/types.d.ts +11 -0
- package/dist/skills/index.js +474 -56
- package/dist/state/agent-state.d.ts +1 -0
- package/dist/state/agent-state.js +2 -0
- package/dist/state/serializer.js +20 -2
- package/dist/state/types.d.ts +5 -0
- package/dist/utils/index.d.ts +119 -4
- package/dist/utils/index.js +164 -13
- package/package.json +4 -1
package/dist/skills/index.js
CHANGED
|
@@ -172,93 +172,439 @@ export const builtinSkills = [
|
|
|
172
172
|
defineSkill({
|
|
173
173
|
name: 'code-review',
|
|
174
174
|
description: 'Perform a thorough code review',
|
|
175
|
-
prompt: `You are now in
|
|
175
|
+
prompt: `You are now in CODE REVIEW MODE.
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
3. **Maintainability**: Evaluate code clarity, naming, and structure
|
|
180
|
-
4. **Best Practices**: Check for anti-patterns and code smells
|
|
181
|
-
5. **Testing**: Assess test coverage and edge cases
|
|
177
|
+
## Purpose
|
|
178
|
+
Perform a thorough, actionable code review.
|
|
182
179
|
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
## When to Use
|
|
181
|
+
- User asks to review code, PR, or changes
|
|
182
|
+
- Before merging a feature branch
|
|
183
|
+
- After implementing a feature
|
|
184
|
+
|
|
185
|
+
## When NOT to Use
|
|
186
|
+
- User just wants to understand code → use explain skill
|
|
187
|
+
- Code is already in production and can't change
|
|
188
|
+
- User wants security-specific review → use security-review skill
|
|
189
|
+
|
|
190
|
+
## Workflow
|
|
191
|
+
|
|
192
|
+
### Phase 1: Understand Context
|
|
193
|
+
1. Read the files being reviewed
|
|
194
|
+
2. Check git status for what changed
|
|
195
|
+
3. Review the diff to see actual changes
|
|
196
|
+
|
|
197
|
+
### Phase 2: Review by Severity
|
|
198
|
+
|
|
199
|
+
**Critical** (must fix before merge):
|
|
200
|
+
- Security vulnerabilities (injection, XSS, auth bypass)
|
|
201
|
+
- Data loss risks
|
|
202
|
+
- Breaking changes to public APIs
|
|
203
|
+
|
|
204
|
+
**High** (should fix):
|
|
205
|
+
- Logic errors / bugs
|
|
206
|
+
- Missing error handling for likely cases
|
|
207
|
+
- Performance issues (N+1 queries, unbounded loops)
|
|
208
|
+
|
|
209
|
+
**Medium** (consider fixing):
|
|
210
|
+
- Code clarity / naming issues
|
|
211
|
+
- Missing tests for new code
|
|
212
|
+
- Inconsistent patterns
|
|
213
|
+
|
|
214
|
+
**Low** (optional):
|
|
215
|
+
- Style preferences
|
|
216
|
+
- Minor optimizations
|
|
217
|
+
|
|
218
|
+
### Phase 3: Report
|
|
219
|
+
Format findings with file:line references:
|
|
220
|
+
\`\`\`
|
|
221
|
+
## Code Review: [file/feature]
|
|
222
|
+
|
|
223
|
+
### Critical Issues
|
|
224
|
+
- **src/auth.ts:42**: SQL injection risk → use parameterized query
|
|
225
|
+
|
|
226
|
+
### High Priority
|
|
227
|
+
- **src/api.ts:15**: Missing null check → add guard
|
|
228
|
+
|
|
229
|
+
### Suggestions
|
|
230
|
+
- Consider extracting duplicate logic
|
|
231
|
+
|
|
232
|
+
### What's Good
|
|
233
|
+
- Clear naming, good test coverage
|
|
234
|
+
\`\`\`
|
|
235
|
+
|
|
236
|
+
## Rules
|
|
237
|
+
- Read the code before reviewing - never review blind
|
|
238
|
+
- Be specific with line references
|
|
239
|
+
- Suggest fixes, not just problems
|
|
240
|
+
- Distinguish blocking vs non-blocking issues
|
|
241
|
+
- Don't nitpick style if code works
|
|
242
|
+
|
|
243
|
+
## Completion Criteria
|
|
244
|
+
✓ All changed files reviewed
|
|
245
|
+
✓ Issues categorized by severity
|
|
246
|
+
✓ Actionable suggestions provided`,
|
|
185
247
|
tags: ['development', 'review'],
|
|
186
248
|
}),
|
|
187
249
|
defineSkill({
|
|
188
250
|
name: 'debug',
|
|
189
251
|
description: 'Systematic debugging approach',
|
|
190
|
-
prompt: `You are now in
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
252
|
+
prompt: `You are now in DEBUG MODE.
|
|
253
|
+
|
|
254
|
+
## Purpose
|
|
255
|
+
Systematically investigate and fix issues.
|
|
256
|
+
|
|
257
|
+
## When to Use
|
|
258
|
+
- User reports a bug or error
|
|
259
|
+
- Tests are failing
|
|
260
|
+
- Unexpected behavior occurs
|
|
261
|
+
|
|
262
|
+
## When NOT to Use
|
|
263
|
+
- User wants to add a feature → use build skill
|
|
264
|
+
- User wants to understand code → use explain skill
|
|
265
|
+
- User wants code improvements → use refactor skill
|
|
266
|
+
|
|
267
|
+
## Workflow
|
|
268
|
+
|
|
269
|
+
### Phase 1: Reproduce
|
|
270
|
+
1. Understand expected vs actual behavior
|
|
271
|
+
2. Get error messages/stack traces if available
|
|
272
|
+
3. Identify steps to reproduce
|
|
273
|
+
|
|
274
|
+
### Phase 2: Isolate
|
|
275
|
+
1. Find relevant code using grep or glob
|
|
276
|
+
2. Read the suspected files
|
|
277
|
+
3. Narrow down to specific function/line
|
|
278
|
+
|
|
279
|
+
### Phase 3: Hypothesize
|
|
280
|
+
Form theories about root cause:
|
|
281
|
+
- Input validation issue?
|
|
282
|
+
- State management bug?
|
|
283
|
+
- Race condition?
|
|
284
|
+
- Missing error handling?
|
|
285
|
+
- Wrong assumption about data?
|
|
286
|
+
|
|
287
|
+
### Phase 4: Verify
|
|
288
|
+
1. Add logging/checks to confirm hypothesis
|
|
289
|
+
2. Run tests to validate
|
|
290
|
+
3. If hypothesis wrong, return to Phase 2
|
|
291
|
+
|
|
292
|
+
### Phase 5: Fix
|
|
293
|
+
1. Make minimal change to fix the issue
|
|
294
|
+
2. Run tests to confirm fix works
|
|
295
|
+
3. Check for regressions
|
|
296
|
+
|
|
297
|
+
### Phase 6: Document
|
|
298
|
+
- Add test case for the bug if missing
|
|
299
|
+
- Add comment if fix is non-obvious
|
|
300
|
+
|
|
301
|
+
## Common Patterns
|
|
302
|
+
|
|
303
|
+
| Symptom | Likely Cause |
|
|
304
|
+
|---------|--------------|
|
|
305
|
+
| "undefined is not a function" | Missing import, typo |
|
|
306
|
+
| "Cannot read property of null" | Unhandled null case |
|
|
307
|
+
| "Network error" | API/CORS issue |
|
|
308
|
+
| Works locally, fails in CI | Environment difference |
|
|
309
|
+
|
|
310
|
+
## Rules
|
|
311
|
+
- Read the code before suggesting fixes
|
|
312
|
+
- Don't guess - investigate systematically
|
|
313
|
+
- Make minimal changes - fix the bug, don't refactor
|
|
314
|
+
- Verify the fix actually works
|
|
315
|
+
|
|
316
|
+
## Completion Criteria
|
|
317
|
+
✓ Bug is reproduced and understood
|
|
318
|
+
✓ Root cause identified
|
|
319
|
+
✓ Fix implemented and tested
|
|
320
|
+
✓ No regressions introduced`,
|
|
201
321
|
tags: ['development', 'troubleshooting'],
|
|
202
322
|
}),
|
|
203
323
|
defineSkill({
|
|
204
324
|
name: 'explain',
|
|
205
325
|
description: 'Explain code or concepts clearly',
|
|
206
|
-
prompt: `You are now in
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
326
|
+
prompt: `You are now in EXPLAIN MODE.
|
|
327
|
+
|
|
328
|
+
## Purpose
|
|
329
|
+
Clearly explain code, concepts, or architecture.
|
|
330
|
+
|
|
331
|
+
## When to Use
|
|
332
|
+
- User asks "what does X do?"
|
|
333
|
+
- User asks "how does X work?"
|
|
334
|
+
- User is learning the codebase
|
|
335
|
+
|
|
336
|
+
## When NOT to Use
|
|
337
|
+
- User wants to change the code → use appropriate skill (refactor, debug, build)
|
|
338
|
+
- User wants a code review → use code-review skill
|
|
339
|
+
- User wants security analysis → use security-review skill
|
|
340
|
+
|
|
341
|
+
## Approach
|
|
342
|
+
|
|
343
|
+
### For Code Explanation
|
|
344
|
+
1. Read the actual code first - never explain from memory
|
|
345
|
+
2. Start with high-level purpose (1-2 sentences)
|
|
346
|
+
3. Walk through key parts with line references (file.ts:42)
|
|
347
|
+
4. Explain non-obvious logic
|
|
348
|
+
5. Note dependencies and side effects
|
|
349
|
+
|
|
350
|
+
### For Concept Explanation
|
|
351
|
+
1. Start with simple definition
|
|
352
|
+
2. Use analogies if helpful
|
|
353
|
+
3. Show concrete example
|
|
354
|
+
4. Mention common pitfalls
|
|
355
|
+
|
|
356
|
+
### For Architecture Explanation
|
|
357
|
+
1. Start with component overview
|
|
358
|
+
2. Explain data flow
|
|
359
|
+
3. Note key decisions and trade-offs
|
|
360
|
+
4. Reference relevant files
|
|
361
|
+
|
|
362
|
+
## Rules
|
|
363
|
+
- Read the actual code - don't explain from memory
|
|
364
|
+
- Use line references: src/auth.ts:42
|
|
365
|
+
- Match complexity to user's apparent level
|
|
366
|
+
- Avoid jargon unless necessary
|
|
367
|
+
- If you don't know, say so
|
|
368
|
+
|
|
369
|
+
## Completion Criteria
|
|
370
|
+
✓ User's question is answered
|
|
371
|
+
✓ Explanation is grounded in actual code
|
|
372
|
+
✓ Complex parts are broken down clearly`,
|
|
216
373
|
tags: ['education', 'documentation'],
|
|
217
374
|
}),
|
|
218
375
|
defineSkill({
|
|
219
376
|
name: 'refactor',
|
|
220
377
|
description: 'Guide code refactoring',
|
|
221
|
-
prompt: `You are now in
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
378
|
+
prompt: `You are now in REFACTOR MODE.
|
|
379
|
+
|
|
380
|
+
## Purpose
|
|
381
|
+
Safely restructure code without changing behavior.
|
|
382
|
+
|
|
383
|
+
## When to Use
|
|
384
|
+
- Code is hard to understand/maintain
|
|
385
|
+
- Preparing code for a new feature
|
|
386
|
+
- Reducing duplication
|
|
387
|
+
- Improving performance
|
|
388
|
+
|
|
389
|
+
## When NOT to Use
|
|
390
|
+
- Adding new features → use build skill
|
|
391
|
+
- Fixing bugs → use debug skill (behavior change)
|
|
392
|
+
- Just cosmetic changes → not worth the risk
|
|
393
|
+
- No tests exist → add tests first
|
|
394
|
+
|
|
395
|
+
## Workflow
|
|
396
|
+
|
|
397
|
+
### Phase 1: Understand
|
|
398
|
+
1. Read the code to refactor
|
|
399
|
+
2. Identify what calls this code (find references)
|
|
400
|
+
3. Check for existing tests
|
|
401
|
+
|
|
402
|
+
### Phase 2: Ensure Safety
|
|
403
|
+
1. Run existing tests first
|
|
404
|
+
2. If no tests, consider adding them first
|
|
405
|
+
3. Note the current behavior precisely
|
|
406
|
+
|
|
407
|
+
### Phase 3: Plan
|
|
408
|
+
Identify the specific refactoring:
|
|
409
|
+
- Extract function/method
|
|
410
|
+
- Rename for clarity
|
|
411
|
+
- Reduce duplication
|
|
412
|
+
- Simplify conditionals
|
|
413
|
+
- Split large file
|
|
414
|
+
|
|
415
|
+
### Phase 4: Execute
|
|
416
|
+
1. Make ONE refactoring at a time
|
|
417
|
+
2. Run tests after each change
|
|
418
|
+
3. If tests fail, revert and try smaller step
|
|
419
|
+
|
|
420
|
+
### Phase 5: Verify
|
|
421
|
+
1. Run full test suite
|
|
422
|
+
2. Run linter
|
|
423
|
+
3. Review the diff
|
|
424
|
+
|
|
425
|
+
## Red Flags - Stop and Reconsider
|
|
426
|
+
- No tests exist for this code
|
|
427
|
+
- You're tempted to add features
|
|
428
|
+
- The change touches many files
|
|
429
|
+
- You don't fully understand the code
|
|
430
|
+
|
|
431
|
+
## Rules
|
|
432
|
+
- NEVER change behavior during refactoring
|
|
433
|
+
- Make small, reversible changes
|
|
434
|
+
- Test after every change
|
|
435
|
+
- Read the code before changing it
|
|
436
|
+
- If also fixing bugs, do that separately
|
|
437
|
+
|
|
438
|
+
## Completion Criteria
|
|
439
|
+
✓ Code is improved (clearer, simpler, less duplication)
|
|
440
|
+
✓ Behavior is unchanged (tests pass)
|
|
441
|
+
✓ No new warnings/errors introduced`,
|
|
231
442
|
tags: ['development', 'improvement'],
|
|
232
443
|
}),
|
|
233
444
|
defineSkill({
|
|
234
445
|
name: 'planning',
|
|
235
446
|
description: 'Help plan and structure work',
|
|
236
|
-
prompt: `You are now in
|
|
447
|
+
prompt: `You are now in PLANNING MODE.
|
|
448
|
+
|
|
449
|
+
## Purpose
|
|
450
|
+
Break down work into clear, actionable steps.
|
|
451
|
+
|
|
452
|
+
## When to Use
|
|
453
|
+
- Complex feature with multiple parts
|
|
454
|
+
- User asks "how should I approach X?"
|
|
455
|
+
- Before starting significant work
|
|
456
|
+
|
|
457
|
+
## When NOT to Use
|
|
458
|
+
- Simple, obvious tasks → just do them
|
|
459
|
+
- User already has a clear plan
|
|
460
|
+
- Pure research questions → use explain skill
|
|
461
|
+
|
|
462
|
+
## Workflow
|
|
463
|
+
|
|
464
|
+
### Phase 1: Clarify Goals
|
|
465
|
+
1. What is the desired outcome?
|
|
466
|
+
2. What are the constraints?
|
|
467
|
+
3. What's out of scope?
|
|
468
|
+
|
|
469
|
+
If unclear, ask the user to clarify.
|
|
470
|
+
|
|
471
|
+
### Phase 2: Assess Current State
|
|
472
|
+
1. Read relevant code
|
|
473
|
+
2. Check project structure
|
|
474
|
+
3. Identify what exists vs needs to be built
|
|
475
|
+
|
|
476
|
+
### Phase 3: Break Down
|
|
477
|
+
Create actionable items:
|
|
478
|
+
- Each item completable in one session
|
|
479
|
+
- Items have clear completion criteria
|
|
480
|
+
- Order by dependencies (what blocks what?)
|
|
481
|
+
|
|
482
|
+
### Phase 4: Identify Risks
|
|
483
|
+
- What could go wrong?
|
|
484
|
+
- What unknowns need investigation?
|
|
485
|
+
- What dependencies might cause issues?
|
|
486
|
+
|
|
487
|
+
### Phase 5: Present Plan
|
|
488
|
+
Format as:
|
|
489
|
+
\`\`\`
|
|
490
|
+
## Plan: [Feature Name]
|
|
491
|
+
|
|
492
|
+
### Goal
|
|
493
|
+
[1-2 sentences]
|
|
494
|
+
|
|
495
|
+
### Steps
|
|
496
|
+
1. [ ] [Task] - [brief description]
|
|
497
|
+
2. [ ] [Task] - [brief description]
|
|
498
|
+
...
|
|
237
499
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
500
|
+
### Risks
|
|
501
|
+
- [Risk]: [mitigation]
|
|
502
|
+
|
|
503
|
+
### Open Questions
|
|
504
|
+
- [Question needing user input]
|
|
505
|
+
\`\`\`
|
|
244
506
|
|
|
245
|
-
|
|
507
|
+
## Rules
|
|
508
|
+
- Don't plan trivial tasks - just do them
|
|
509
|
+
- Be specific - "implement auth" is too vague
|
|
510
|
+
- Consider dependencies between steps
|
|
511
|
+
- Include verification steps (tests, manual check)
|
|
512
|
+
- Don't give time estimates
|
|
513
|
+
|
|
514
|
+
## Completion Criteria
|
|
515
|
+
✓ Goal is clear
|
|
516
|
+
✓ Steps are actionable and ordered
|
|
517
|
+
✓ Risks are identified
|
|
518
|
+
✓ User agrees with the approach`,
|
|
246
519
|
tags: ['project-management', 'organization'],
|
|
247
520
|
}),
|
|
248
521
|
defineSkill({
|
|
249
522
|
name: 'security-review',
|
|
250
523
|
description: 'Focus on security aspects',
|
|
251
|
-
prompt: `You are now in
|
|
524
|
+
prompt: `You are now in SECURITY REVIEW MODE.
|
|
525
|
+
|
|
526
|
+
## Purpose
|
|
527
|
+
Identify security vulnerabilities in code.
|
|
528
|
+
|
|
529
|
+
## When to Use
|
|
530
|
+
- Before deploying to production
|
|
531
|
+
- Reviewing authentication/authorization code
|
|
532
|
+
- Handling user input or sensitive data
|
|
533
|
+
- Third-party integration code
|
|
534
|
+
|
|
535
|
+
## When NOT to Use
|
|
536
|
+
- General code quality issues → use code-review skill
|
|
537
|
+
- Performance issues → use code-optimization skill
|
|
538
|
+
- Just want to understand code → use explain skill
|
|
539
|
+
|
|
540
|
+
## Workflow
|
|
541
|
+
|
|
542
|
+
### Phase 1: Identify Attack Surface
|
|
543
|
+
1. Find entry points: APIs, forms, file uploads
|
|
544
|
+
2. Find data flows: user input → storage → output
|
|
545
|
+
3. Find sensitive operations: auth, payments, admin
|
|
546
|
+
|
|
547
|
+
### Phase 2: Check OWASP Top 10
|
|
548
|
+
|
|
549
|
+
**1. Injection (SQL, Command, XSS)**
|
|
550
|
+
- Is user input sanitized before queries?
|
|
551
|
+
- Are parameterized queries used?
|
|
552
|
+
- Is output encoded/escaped?
|
|
553
|
+
|
|
554
|
+
**2. Broken Authentication**
|
|
555
|
+
- Are passwords hashed properly (bcrypt, argon2)?
|
|
556
|
+
- Are sessions managed securely?
|
|
557
|
+
- Is MFA available for sensitive ops?
|
|
558
|
+
|
|
559
|
+
**3. Sensitive Data Exposure**
|
|
560
|
+
- Is data encrypted in transit (HTTPS)?
|
|
561
|
+
- Are secrets in environment variables (not code)?
|
|
562
|
+
- Is sensitive data logged?
|
|
563
|
+
|
|
564
|
+
**4. Broken Access Control**
|
|
565
|
+
- Are authorization checks on every endpoint?
|
|
566
|
+
- Can users access other users' data?
|
|
567
|
+
- Are admin functions protected?
|
|
568
|
+
|
|
569
|
+
**5. Security Misconfiguration**
|
|
570
|
+
- Are default credentials changed?
|
|
571
|
+
- Are error messages generic (no stack traces)?
|
|
572
|
+
- Are unnecessary features disabled?
|
|
573
|
+
|
|
574
|
+
**6. Using Vulnerable Components**
|
|
575
|
+
- Run findVulnerabilities() or npm audit
|
|
576
|
+
- Check for outdated dependencies
|
|
577
|
+
|
|
578
|
+
### Phase 3: Report Findings
|
|
579
|
+
|
|
580
|
+
Format as:
|
|
581
|
+
\`\`\`
|
|
582
|
+
## Security Review: [component]
|
|
252
583
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
5. **Dependencies**: Check for known vulnerabilities
|
|
258
|
-
6. **Configuration**: Review security settings
|
|
259
|
-
7. **Logging**: Verify security events are logged
|
|
584
|
+
### Critical (immediate action)
|
|
585
|
+
- **file:line**: [vulnerability]
|
|
586
|
+
Risk: [impact]
|
|
587
|
+
Fix: [solution]
|
|
260
588
|
|
|
261
|
-
|
|
589
|
+
### High (fix before deploy)
|
|
590
|
+
...
|
|
591
|
+
|
|
592
|
+
### Recommendations
|
|
593
|
+
- [proactive improvements]
|
|
594
|
+
\`\`\`
|
|
595
|
+
|
|
596
|
+
## Rules
|
|
597
|
+
- Be specific about the vulnerability
|
|
598
|
+
- Explain the real-world impact
|
|
599
|
+
- Provide actionable fix suggestions
|
|
600
|
+
- Don't cry wolf - prioritize real risks
|
|
601
|
+
- Check for existing security controls first
|
|
602
|
+
|
|
603
|
+
## Completion Criteria
|
|
604
|
+
✓ Attack surface identified
|
|
605
|
+
✓ OWASP categories checked
|
|
606
|
+
✓ Findings prioritized by severity
|
|
607
|
+
✓ Fix suggestions provided`,
|
|
262
608
|
tags: ['security', 'review'],
|
|
263
609
|
}),
|
|
264
610
|
defineSkill({
|
|
@@ -266,6 +612,16 @@ Apply OWASP guidelines and security best practices.`,
|
|
|
266
612
|
description: 'Guide user through project design and requirements gathering',
|
|
267
613
|
prompt: `You are in DESIGN MODE. Your goal is to gather enough information to populate the project backlog with 5-15 actionable items.
|
|
268
614
|
|
|
615
|
+
## When to Use
|
|
616
|
+
- Starting a new project from scratch
|
|
617
|
+
- User has an idea but no clear requirements
|
|
618
|
+
- Need to create initial backlog
|
|
619
|
+
|
|
620
|
+
## When NOT to Use
|
|
621
|
+
- Project already has requirements → use refine skill
|
|
622
|
+
- Quick project outline needed → use sketch skill
|
|
623
|
+
- Just need to update PRD → use prd skill
|
|
624
|
+
|
|
269
625
|
## PHASES
|
|
270
626
|
|
|
271
627
|
### Phase 1: Vision (3-5 questions)
|
|
@@ -333,6 +689,17 @@ When you have enough information:
|
|
|
333
689
|
description: 'Iteratively refine and expand project requirements',
|
|
334
690
|
prompt: `You are in REFINE MODE. Your goal is to deepen and expand existing requirements based on user feedback.
|
|
335
691
|
|
|
692
|
+
## When to Use
|
|
693
|
+
- Backlog items are too vague
|
|
694
|
+
- Need to add acceptance criteria
|
|
695
|
+
- Reprioritizing existing items
|
|
696
|
+
- Adding missing items to backlog
|
|
697
|
+
|
|
698
|
+
## When NOT to Use
|
|
699
|
+
- No backlog exists yet → use design skill
|
|
700
|
+
- Quick outline needed → use sketch skill
|
|
701
|
+
- Refining single item → use refine-item skill
|
|
702
|
+
|
|
336
703
|
## STARTUP
|
|
337
704
|
|
|
338
705
|
1. Use todo_write to create a task list:
|
|
@@ -400,6 +767,16 @@ For complex features:
|
|
|
400
767
|
description: 'Quick project outline with simple questions',
|
|
401
768
|
prompt: `You are in SKETCH MODE. Ask 6 quick questions, then create backlog items.
|
|
402
769
|
|
|
770
|
+
## When to Use
|
|
771
|
+
- Quick project kickoff
|
|
772
|
+
- User wants fast outline without deep dive
|
|
773
|
+
- Initial brainstorming session
|
|
774
|
+
|
|
775
|
+
## When NOT to Use
|
|
776
|
+
- Detailed requirements needed → use design skill
|
|
777
|
+
- Project already has backlog → use refine skill
|
|
778
|
+
- Single item focus → use refine-item skill
|
|
779
|
+
|
|
403
780
|
STEPS:
|
|
404
781
|
1. Use todo_write with 6 tasks (one per question)
|
|
405
782
|
2. Ask each question using ask_user_simple tool
|
|
@@ -429,6 +806,16 @@ RULES:
|
|
|
429
806
|
description: 'Focused refinement of a specific backlog item',
|
|
430
807
|
prompt: `You are in FOCUSED REFINE MODE. Your goal is to refine a specific backlog item.
|
|
431
808
|
|
|
809
|
+
## When to Use
|
|
810
|
+
- User wants to work on a specific backlog item
|
|
811
|
+
- Item needs more detail or breakdown
|
|
812
|
+
- Changing priority of specific item
|
|
813
|
+
|
|
814
|
+
## When NOT to Use
|
|
815
|
+
- Multiple items need refinement → use refine skill
|
|
816
|
+
- No items exist yet → use design or sketch skill
|
|
817
|
+
- Ready to implement → use build skill
|
|
818
|
+
|
|
432
819
|
## STARTUP
|
|
433
820
|
|
|
434
821
|
1. Use backlog_read with id parameter to get the specific item
|
|
@@ -487,6 +874,17 @@ Based on user's choice:
|
|
|
487
874
|
description: 'Create architecture documentation (ADRs, diagrams, data models, API designs)',
|
|
488
875
|
prompt: `You are in ARCHITECTURE MODE. Your goal is to create architecture documentation.
|
|
489
876
|
|
|
877
|
+
## When to Use
|
|
878
|
+
- Creating ADRs (Architecture Decision Records)
|
|
879
|
+
- Documenting system diagrams
|
|
880
|
+
- Designing data models or API specs
|
|
881
|
+
- Recording technical decisions
|
|
882
|
+
|
|
883
|
+
## When NOT to Use
|
|
884
|
+
- Need product requirements → use design or prd skill
|
|
885
|
+
- Need to implement features → use build skill
|
|
886
|
+
- Just want to understand existing code → use explain skill
|
|
887
|
+
|
|
490
888
|
## DOCUMENT TYPE: {{doc_type}}
|
|
491
889
|
{{#if custom_topic}}Custom Topic: {{custom_topic}}{{/if}}
|
|
492
890
|
|
|
@@ -621,6 +1019,16 @@ Generate appropriate documentation.
|
|
|
621
1019
|
description: 'Amend or enhance the Product Requirements Document',
|
|
622
1020
|
prompt: `You are in PRD MODE. Your goal is to update or enhance the existing Product Requirements Document.
|
|
623
1021
|
|
|
1022
|
+
## When to Use
|
|
1023
|
+
- Updating existing PRD sections
|
|
1024
|
+
- Adding new requirements to PRD
|
|
1025
|
+
- Refining vision or scope
|
|
1026
|
+
|
|
1027
|
+
## When NOT to Use
|
|
1028
|
+
- No PRD exists yet → use design skill first
|
|
1029
|
+
- Need architecture docs → use architecture skill
|
|
1030
|
+
- Need session summary → use session-notes skill
|
|
1031
|
+
|
|
624
1032
|
## STARTUP
|
|
625
1033
|
|
|
626
1034
|
1. Use todo_write to track your progress:
|
|
@@ -693,6 +1101,16 @@ Based on section selected:
|
|
|
693
1101
|
description: 'Create structured session notes capturing work done and decisions made',
|
|
694
1102
|
prompt: `You are in SESSION NOTES MODE. Your goal is to create a structured summary of the current session.
|
|
695
1103
|
|
|
1104
|
+
## When to Use
|
|
1105
|
+
- End of a work session
|
|
1106
|
+
- User asks to document what was done
|
|
1107
|
+
- Need to capture decisions for future reference
|
|
1108
|
+
|
|
1109
|
+
## When NOT to Use
|
|
1110
|
+
- Need product requirements → use prd skill
|
|
1111
|
+
- Need architecture docs → use architecture skill
|
|
1112
|
+
- In the middle of active work
|
|
1113
|
+
|
|
696
1114
|
## STARTUP
|
|
697
1115
|
|
|
698
1116
|
1. Use todo_write to track your progress:
|
|
@@ -22,6 +22,7 @@ export function createEmptyState(sessionId, systemPrompt) {
|
|
|
22
22
|
systemPrompt,
|
|
23
23
|
todos: [],
|
|
24
24
|
currentIteration: 0,
|
|
25
|
+
turnCount: 0,
|
|
25
26
|
totalTokensUsed: 0,
|
|
26
27
|
createdAt: now,
|
|
27
28
|
updatedAt: now,
|
|
@@ -40,6 +41,7 @@ export function createAgentState(options) {
|
|
|
40
41
|
model: options.model,
|
|
41
42
|
todos: serializeTodos(options.todos),
|
|
42
43
|
currentIteration: options.currentIteration,
|
|
44
|
+
turnCount: options.turnCount,
|
|
43
45
|
totalTokensUsed: options.totalTokensUsed,
|
|
44
46
|
createdAt: options.createdAt || now,
|
|
45
47
|
updatedAt: now,
|
package/dist/state/serializer.js
CHANGED
|
@@ -34,7 +34,11 @@ export class JsonSerializer {
|
|
|
34
34
|
throw StateError.deserialization('Invalid JSON format', error instanceof Error ? error : undefined);
|
|
35
35
|
}
|
|
36
36
|
this.validateParsed(parsed);
|
|
37
|
-
|
|
37
|
+
// Ensure turnCount has a default value for backward compatibility
|
|
38
|
+
// with saved states from before turnCount was added (pre-v2 states)
|
|
39
|
+
const partialState = parsed;
|
|
40
|
+
const turnCount = partialState.turnCount ?? partialState.messages.filter((m) => m.role === 'user').length;
|
|
41
|
+
return { ...partialState, turnCount };
|
|
38
42
|
}
|
|
39
43
|
/**
|
|
40
44
|
* Validate state before serialization (public interface method).
|
|
@@ -77,6 +81,11 @@ export class JsonSerializer {
|
|
|
77
81
|
if (typeof state.version !== 'number') {
|
|
78
82
|
throw StateError.invalidState('version must be a number');
|
|
79
83
|
}
|
|
84
|
+
// turnCount is optional for backward compatibility
|
|
85
|
+
// (old saved states may not have it)
|
|
86
|
+
if (state.turnCount !== undefined && typeof state.turnCount !== 'number') {
|
|
87
|
+
throw StateError.invalidState('turnCount must be a number if present');
|
|
88
|
+
}
|
|
80
89
|
// Version check - safe to cast since we validated it's a number
|
|
81
90
|
const version = state.version;
|
|
82
91
|
if (version > CURRENT_STATE_VERSION) {
|
|
@@ -119,7 +128,11 @@ export class CompactJsonSerializer {
|
|
|
119
128
|
throw StateError.deserialization('Invalid JSON format', error instanceof Error ? error : undefined);
|
|
120
129
|
}
|
|
121
130
|
this.validateParsed(parsed);
|
|
122
|
-
|
|
131
|
+
// Ensure turnCount has a default value for backward compatibility
|
|
132
|
+
// with saved states from before turnCount was added (pre-v2 states)
|
|
133
|
+
const partialState = parsed;
|
|
134
|
+
const turnCount = partialState.turnCount ?? partialState.messages.filter((m) => m.role === 'user').length;
|
|
135
|
+
return { ...partialState, turnCount };
|
|
123
136
|
}
|
|
124
137
|
/**
|
|
125
138
|
* Validate state before serialization (public interface method).
|
|
@@ -159,6 +172,11 @@ export class CompactJsonSerializer {
|
|
|
159
172
|
if (typeof state.version !== 'number') {
|
|
160
173
|
throw StateError.invalidState('version must be a number');
|
|
161
174
|
}
|
|
175
|
+
// turnCount is optional for backward compatibility
|
|
176
|
+
// (old saved states may not have it)
|
|
177
|
+
if (state.turnCount !== undefined && typeof state.turnCount !== 'number') {
|
|
178
|
+
throw StateError.invalidState('turnCount must be a number if present');
|
|
179
|
+
}
|
|
162
180
|
// Version check - safe to cast since we validated it's a number
|
|
163
181
|
const version = state.version;
|
|
164
182
|
if (version > CURRENT_STATE_VERSION) {
|