kspec 1.0.13 → 1.0.14
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/package.json +1 -1
- package/src/index.js +182 -35
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -106,6 +106,9 @@ async function confirm(question) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
function chat(message, agent) {
|
|
109
|
+
// Refresh context before each chat to ensure LLM has latest state
|
|
110
|
+
refreshContext();
|
|
111
|
+
|
|
109
112
|
const cli = requireCli();
|
|
110
113
|
const args = agent ? ['chat', '--agent', agent, message] : ['chat', message];
|
|
111
114
|
const child = spawn(cli, args, { stdio: 'inherit' });
|
|
@@ -175,6 +178,101 @@ function getTaskStats(folder) {
|
|
|
175
178
|
return { total, done, remaining: total - done };
|
|
176
179
|
}
|
|
177
180
|
|
|
181
|
+
function getCurrentTask(folder) {
|
|
182
|
+
const tasksFile = path.join(folder, 'tasks.md');
|
|
183
|
+
if (!fs.existsSync(tasksFile)) return null;
|
|
184
|
+
|
|
185
|
+
const content = fs.readFileSync(tasksFile, 'utf8');
|
|
186
|
+
const lines = content.split('\n');
|
|
187
|
+
for (const line of lines) {
|
|
188
|
+
if (/^-\s*\[ \]/.test(line)) {
|
|
189
|
+
return line.replace(/^-\s*\[ \]\s*/, '').trim();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function refreshContext() {
|
|
196
|
+
const contextFile = path.join(KSPEC_DIR, 'CONTEXT.md');
|
|
197
|
+
const current = getCurrentSpec();
|
|
198
|
+
|
|
199
|
+
if (!current) {
|
|
200
|
+
// No current spec - create minimal context
|
|
201
|
+
const content = `# kspec Context
|
|
202
|
+
|
|
203
|
+
No active spec. Run: \`kspec spec "Feature Name"\`
|
|
204
|
+
`;
|
|
205
|
+
ensureDir(KSPEC_DIR);
|
|
206
|
+
fs.writeFileSync(contextFile, content);
|
|
207
|
+
return content;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const specName = path.basename(current);
|
|
211
|
+
const stats = getTaskStats(current);
|
|
212
|
+
const currentTask = getCurrentTask(current);
|
|
213
|
+
|
|
214
|
+
// Read spec-lite if exists
|
|
215
|
+
const specLiteFile = path.join(current, 'spec-lite.md');
|
|
216
|
+
let specLite = '';
|
|
217
|
+
if (fs.existsSync(specLiteFile)) {
|
|
218
|
+
specLite = fs.readFileSync(specLiteFile, 'utf8');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Read memory if exists
|
|
222
|
+
const memoryFile = path.join(current, 'memory.md');
|
|
223
|
+
let memory = '';
|
|
224
|
+
if (fs.existsSync(memoryFile)) {
|
|
225
|
+
memory = fs.readFileSync(memoryFile, 'utf8');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Build context
|
|
229
|
+
let content = `# kspec Context
|
|
230
|
+
> Auto-generated. Always read this first after context compression.
|
|
231
|
+
|
|
232
|
+
## Current Spec
|
|
233
|
+
**${specName}**
|
|
234
|
+
Path: \`${current}\`
|
|
235
|
+
|
|
236
|
+
`;
|
|
237
|
+
|
|
238
|
+
if (stats) {
|
|
239
|
+
content += `## Progress
|
|
240
|
+
- Tasks: ${stats.done}/${stats.total} completed
|
|
241
|
+
- Remaining: ${stats.remaining}
|
|
242
|
+
`;
|
|
243
|
+
if (currentTask) {
|
|
244
|
+
content += `- **Current Task**: ${currentTask}
|
|
245
|
+
`;
|
|
246
|
+
}
|
|
247
|
+
content += '\n';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (specLite) {
|
|
251
|
+
content += `## Requirements Summary
|
|
252
|
+
${specLite}
|
|
253
|
+
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (memory) {
|
|
258
|
+
content += `## Decisions & Learnings
|
|
259
|
+
${memory}
|
|
260
|
+
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
content += `## Quick Commands
|
|
265
|
+
- \`kspec build\` - Continue building tasks
|
|
266
|
+
- \`kspec verify\` - Verify implementation
|
|
267
|
+
- \`kspec status\` - Show current status
|
|
268
|
+
- \`kspec context\` - Refresh this file
|
|
269
|
+
`;
|
|
270
|
+
|
|
271
|
+
ensureDir(KSPEC_DIR);
|
|
272
|
+
fs.writeFileSync(contextFile, content);
|
|
273
|
+
return content;
|
|
274
|
+
}
|
|
275
|
+
|
|
178
276
|
// Templates
|
|
179
277
|
const steeringTemplates = {
|
|
180
278
|
'product.md': `# Product Overview
|
|
@@ -221,10 +319,15 @@ const agentTemplates = {
|
|
|
221
319
|
tools: ['read', 'write'],
|
|
222
320
|
allowedTools: ['read', 'write'],
|
|
223
321
|
resources: [
|
|
322
|
+
'file://.kspec/CONTEXT.md',
|
|
224
323
|
'file://.kiro/steering/**/*.md',
|
|
225
324
|
'file://.kspec/**/*.md'
|
|
226
325
|
],
|
|
227
|
-
prompt: `You are the kspec analyser.
|
|
326
|
+
prompt: `You are the kspec analyser.
|
|
327
|
+
|
|
328
|
+
FIRST: Read .kspec/CONTEXT.md for current state and spec summary.
|
|
329
|
+
|
|
330
|
+
Your job:
|
|
228
331
|
1. Analyse the codebase structure, tech stack, patterns
|
|
229
332
|
2. Review .kiro/steering/ docs
|
|
230
333
|
3. Suggest updates to steering based on actual codebase
|
|
@@ -242,25 +345,31 @@ Output a clear analysis report. Propose specific steering doc updates.`,
|
|
|
242
345
|
tools: ['read', 'write'],
|
|
243
346
|
allowedTools: ['read', 'write'],
|
|
244
347
|
resources: [
|
|
348
|
+
'file://.kspec/CONTEXT.md',
|
|
245
349
|
'file://.kiro/steering/**/*.md',
|
|
246
350
|
'file://.kspec/**/*.md'
|
|
247
351
|
],
|
|
248
|
-
prompt: `You are the kspec specification writer.
|
|
352
|
+
prompt: `You are the kspec specification writer.
|
|
353
|
+
|
|
354
|
+
WORKFLOW (do this autonomously):
|
|
249
355
|
1. Read .kiro/steering/ for project context
|
|
250
|
-
2. Create
|
|
356
|
+
2. Create spec folder: .kspec/specs/YYYY-MM-DD-{feature-slug}/
|
|
357
|
+
- Use today's date and a short slug (2-4 words from feature name)
|
|
358
|
+
3. Create spec.md in that folder with:
|
|
251
359
|
- Problem/Context
|
|
252
360
|
- Requirements (functional + non-functional)
|
|
253
361
|
- Constraints
|
|
254
362
|
- High-level design
|
|
255
363
|
- Acceptance criteria
|
|
256
|
-
|
|
257
|
-
- Concise version
|
|
364
|
+
4. Create spec-lite.md (CRITICAL - under 500 words):
|
|
365
|
+
- Concise version for context retention after compression
|
|
258
366
|
- Key requirements only
|
|
259
|
-
|
|
367
|
+
5. Update .kspec/.current with the spec folder path
|
|
368
|
+
6. Update .kspec/CONTEXT.md with current state
|
|
260
369
|
|
|
261
|
-
|
|
370
|
+
After completion, suggest: "Switch to kspec-tasks agent to generate implementation tasks"`,
|
|
262
371
|
keyboardShortcut: 'ctrl+s',
|
|
263
|
-
welcomeMessage: 'Ready to create specification.'
|
|
372
|
+
welcomeMessage: 'Ready to create specification. Describe your feature.'
|
|
264
373
|
},
|
|
265
374
|
|
|
266
375
|
'kspec-tasks.json': {
|
|
@@ -270,21 +379,29 @@ Always create both files. spec-lite.md is critical for context retention.`,
|
|
|
270
379
|
tools: ['read', 'write'],
|
|
271
380
|
allowedTools: ['read', 'write'],
|
|
272
381
|
resources: [
|
|
382
|
+
'file://.kspec/CONTEXT.md',
|
|
273
383
|
'file://.kiro/steering/**/*.md',
|
|
274
384
|
'file://.kspec/**/*.md'
|
|
275
385
|
],
|
|
276
|
-
prompt: `You are the kspec task generator.
|
|
277
|
-
|
|
278
|
-
|
|
386
|
+
prompt: `You are the kspec task generator.
|
|
387
|
+
|
|
388
|
+
WORKFLOW:
|
|
389
|
+
1. Read .kspec/CONTEXT.md for current spec location
|
|
390
|
+
2. Read .kspec/.current to get spec folder path
|
|
391
|
+
3. Read spec.md and spec-lite.md from that folder
|
|
392
|
+
4. Generate tasks.md in the spec folder with:
|
|
279
393
|
- Checkbox format: "- [ ] Task description"
|
|
280
394
|
- TDD approach: test first, then implement
|
|
281
395
|
- Logical ordering (models → services → API → UI)
|
|
282
396
|
- Dependencies noted
|
|
283
397
|
- File paths where changes occur
|
|
398
|
+
5. Update .kspec/CONTEXT.md with task count
|
|
399
|
+
|
|
400
|
+
Tasks must be atomic and independently verifiable.
|
|
284
401
|
|
|
285
|
-
|
|
402
|
+
After completion, suggest: "Switch to kspec-build agent to start implementing tasks"`,
|
|
286
403
|
keyboardShortcut: 'ctrl+t',
|
|
287
|
-
welcomeMessage: '
|
|
404
|
+
welcomeMessage: 'Reading current spec and generating tasks...'
|
|
288
405
|
},
|
|
289
406
|
|
|
290
407
|
'kspec-build.json': {
|
|
@@ -294,24 +411,34 @@ Tasks must be atomic and independently verifiable.`,
|
|
|
294
411
|
tools: ['read', 'write', 'shell'],
|
|
295
412
|
allowedTools: ['read', 'write', 'shell'],
|
|
296
413
|
resources: [
|
|
414
|
+
'file://.kspec/CONTEXT.md',
|
|
297
415
|
'file://.kiro/steering/**/*.md',
|
|
298
416
|
'file://.kspec/**/*.md'
|
|
299
417
|
],
|
|
300
|
-
prompt: `You are the kspec builder.
|
|
301
|
-
|
|
302
|
-
|
|
418
|
+
prompt: `You are the kspec builder.
|
|
419
|
+
|
|
420
|
+
WORKFLOW:
|
|
421
|
+
1. Read .kspec/CONTEXT.md for current spec and task progress
|
|
422
|
+
2. Read .kspec/.current to get spec folder path
|
|
423
|
+
3. Read tasks.md from spec folder, find first uncompleted task (- [ ])
|
|
424
|
+
4. For each task:
|
|
303
425
|
a) Write test first (TDD)
|
|
304
426
|
b) Implement minimal code to pass
|
|
305
427
|
c) Run tests
|
|
306
428
|
d) Mark task complete: change "- [ ]" to "- [x]"
|
|
307
429
|
e) Update tasks.md file
|
|
308
|
-
|
|
430
|
+
f) Update .kspec/CONTEXT.md with new progress
|
|
431
|
+
5. Commit after each task with descriptive message
|
|
309
432
|
|
|
310
|
-
CRITICAL:
|
|
311
|
-
|
|
312
|
-
|
|
433
|
+
CRITICAL:
|
|
434
|
+
- Always update tasks.md after completing each task
|
|
435
|
+
- Update .kspec/CONTEXT.md with current task and progress
|
|
436
|
+
- NEVER delete .kiro or .kspec folders
|
|
437
|
+
- Use non-interactive flags for commands (--yes, -y)
|
|
438
|
+
|
|
439
|
+
When all tasks complete, suggest: "Switch to kspec-verify agent to verify implementation"`,
|
|
313
440
|
keyboardShortcut: 'ctrl+b',
|
|
314
|
-
welcomeMessage: '
|
|
441
|
+
welcomeMessage: 'Reading current task and building...'
|
|
315
442
|
},
|
|
316
443
|
|
|
317
444
|
'kspec-verify.json': {
|
|
@@ -321,10 +448,15 @@ Use non-interactive flags for commands (--yes, -y).`,
|
|
|
321
448
|
tools: ['read', 'shell'],
|
|
322
449
|
allowedTools: ['read', 'shell'],
|
|
323
450
|
resources: [
|
|
451
|
+
'file://.kspec/CONTEXT.md',
|
|
324
452
|
'file://.kiro/steering/**/*.md',
|
|
325
453
|
'file://.kspec/**/*.md'
|
|
326
454
|
],
|
|
327
|
-
prompt: `You are the kspec verifier.
|
|
455
|
+
prompt: `You are the kspec verifier.
|
|
456
|
+
|
|
457
|
+
FIRST: Read .kspec/CONTEXT.md for current spec and progress.
|
|
458
|
+
|
|
459
|
+
Based on what you're asked to verify:
|
|
328
460
|
|
|
329
461
|
VERIFY-SPEC:
|
|
330
462
|
- Check spec covers all requirements
|
|
@@ -356,10 +488,15 @@ Output a clear verification report with pass/fail status.`,
|
|
|
356
488
|
tools: ['read', 'shell'],
|
|
357
489
|
allowedTools: ['read', 'shell'],
|
|
358
490
|
resources: [
|
|
491
|
+
'file://.kspec/CONTEXT.md',
|
|
359
492
|
'file://.kiro/steering/**/*.md',
|
|
360
493
|
'file://.kspec/**/*.md'
|
|
361
494
|
],
|
|
362
|
-
prompt: `You are the kspec code reviewer.
|
|
495
|
+
prompt: `You are the kspec code reviewer.
|
|
496
|
+
|
|
497
|
+
FIRST: Read .kspec/CONTEXT.md for current spec context.
|
|
498
|
+
|
|
499
|
+
Your job:
|
|
363
500
|
1. Review code changes (git diff or specified files)
|
|
364
501
|
2. Check compliance with .kiro/steering/
|
|
365
502
|
3. Evaluate:
|
|
@@ -632,13 +769,13 @@ Output: APPROVE or REQUEST_CHANGES with specifics.`, 'kspec-review');
|
|
|
632
769
|
|
|
633
770
|
status() {
|
|
634
771
|
const current = getCurrentSpec();
|
|
635
|
-
|
|
772
|
+
|
|
636
773
|
console.log('\nkspec Status\n');
|
|
637
774
|
console.log(`CLI: ${detectCli() || '(not installed)'}`);
|
|
638
775
|
console.log(`Initialized: ${config.initialized ? 'yes' : 'no'}`);
|
|
639
776
|
console.log(`Date format: ${config.dateFormat || 'YYYY-MM-DD'}`);
|
|
640
777
|
console.log(`Auto-execute: ${config.autoExecute || 'ask'}`);
|
|
641
|
-
|
|
778
|
+
|
|
642
779
|
if (current) {
|
|
643
780
|
console.log(`\nCurrent spec: ${path.basename(current)}`);
|
|
644
781
|
const stats = getTaskStats(current);
|
|
@@ -658,6 +795,12 @@ Output: APPROVE or REQUEST_CHANGES with specifics.`, 'kspec-review');
|
|
|
658
795
|
console.log('');
|
|
659
796
|
},
|
|
660
797
|
|
|
798
|
+
context() {
|
|
799
|
+
const content = refreshContext();
|
|
800
|
+
console.log(content);
|
|
801
|
+
console.log(`Context saved to: .kspec/CONTEXT.md\n`);
|
|
802
|
+
},
|
|
803
|
+
|
|
661
804
|
agents() {
|
|
662
805
|
console.log(`
|
|
663
806
|
kspec Agents
|
|
@@ -679,7 +822,7 @@ Switch: /agent swap or use keyboard shortcuts
|
|
|
679
822
|
console.log(`
|
|
680
823
|
kspec - Spec-driven development for Kiro CLI
|
|
681
824
|
|
|
682
|
-
Workflow:
|
|
825
|
+
CLI Workflow (outside kiro-cli):
|
|
683
826
|
kspec init Interactive setup
|
|
684
827
|
kspec analyse Analyse codebase, update steering
|
|
685
828
|
kspec spec "Feature" Create specification
|
|
@@ -690,22 +833,26 @@ Workflow:
|
|
|
690
833
|
kspec verify Verify implementation
|
|
691
834
|
kspec done Complete spec, harvest memory
|
|
692
835
|
|
|
836
|
+
Inside kiro-cli (recommended):
|
|
837
|
+
/agent swap kspec-spec → Describe feature → creates spec
|
|
838
|
+
/agent swap kspec-tasks → Generates tasks from spec
|
|
839
|
+
/agent swap kspec-build → Builds tasks with TDD
|
|
840
|
+
/agent swap kspec-verify → Verifies implementation
|
|
841
|
+
|
|
842
|
+
Agents read .kspec/CONTEXT.md automatically for state.
|
|
843
|
+
|
|
693
844
|
Other:
|
|
845
|
+
kspec context Refresh/view context file
|
|
694
846
|
kspec review [target] Code review
|
|
695
847
|
kspec list List all specs
|
|
696
848
|
kspec status Current status
|
|
697
849
|
kspec agents List agents
|
|
698
850
|
kspec help Show this help
|
|
699
|
-
kspec --help, -h Show this help
|
|
700
|
-
kspec --version, -v Show version
|
|
701
851
|
|
|
702
852
|
Examples:
|
|
703
|
-
kspec init
|
|
704
|
-
kspec spec "User
|
|
705
|
-
kspec
|
|
706
|
-
kspec build
|
|
707
|
-
kspec verify
|
|
708
|
-
kspec done
|
|
853
|
+
kspec init # First time setup
|
|
854
|
+
kspec spec "User Auth" # CLI mode
|
|
855
|
+
kiro-cli --agent kspec-spec # Direct agent mode
|
|
709
856
|
`);
|
|
710
857
|
}
|
|
711
858
|
};
|
|
@@ -732,4 +879,4 @@ async function run(args) {
|
|
|
732
879
|
}
|
|
733
880
|
}
|
|
734
881
|
|
|
735
|
-
module.exports = { run, commands, loadConfig, detectCli, requireCli, agentTemplates, getTaskStats };
|
|
882
|
+
module.exports = { run, commands, loadConfig, detectCli, requireCli, agentTemplates, getTaskStats, refreshContext, getCurrentTask };
|