sdd-mcp-server 2.0.0 → 2.0.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/README.md +14 -3
- package/dist/adapters/cli/SDDToolAdapter.d.ts +0 -1
- package/dist/adapters/cli/SDDToolAdapter.js +1 -110
- package/dist/adapters/cli/SDDToolAdapter.js.map +1 -1
- package/dist/cli/install-skills.js +24 -7
- package/dist/cli/install-skills.js.map +1 -1
- package/dist/index.js +0 -1240
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22,8 +22,6 @@ if (isMCPMode) {
|
|
|
22
22
|
import "reflect-metadata";
|
|
23
23
|
import { createContainer } from "./infrastructure/di/container.js";
|
|
24
24
|
import { TYPES } from "./infrastructure/di/types.js";
|
|
25
|
-
import { ensureStaticSteeringDocuments } from "./application/services/staticSteering.js";
|
|
26
|
-
import { loadDocumentGenerator, loadSpecGenerator, } from "./utils/moduleLoader.js";
|
|
27
25
|
export async function createMCPServer() {
|
|
28
26
|
const container = createContainer();
|
|
29
27
|
const logger = container.get(TYPES.LoggerPort);
|
|
@@ -383,373 +381,6 @@ function handleLoaderFailure(context, error, allowFallback = false) {
|
|
|
383
381
|
console.error(`[SDD-DEBUG] Using fallback templates for ${context}`);
|
|
384
382
|
return { useFallback: true, error };
|
|
385
383
|
}
|
|
386
|
-
// Simplified steering implementation for MCP mode
|
|
387
|
-
async function handleSteeringSimplified(args) {
|
|
388
|
-
const fs = await import("fs");
|
|
389
|
-
const path = await import("path");
|
|
390
|
-
const fsPromises = fs.promises;
|
|
391
|
-
const projectPath = process.cwd();
|
|
392
|
-
const stubSteeringService = {
|
|
393
|
-
async createSteeringDocument(projectDir, config) {
|
|
394
|
-
const docPath = path.join(projectDir, ".kiro", "steering", config.name);
|
|
395
|
-
await fsPromises.mkdir(path.dirname(docPath), { recursive: true });
|
|
396
|
-
await fsPromises.writeFile(docPath, config.content, "utf8");
|
|
397
|
-
return {
|
|
398
|
-
name: config.name,
|
|
399
|
-
path: docPath,
|
|
400
|
-
type: config.type,
|
|
401
|
-
mode: config.mode,
|
|
402
|
-
content: config.content,
|
|
403
|
-
patterns: config.patterns ?? [],
|
|
404
|
-
priority: config.priority ?? 50,
|
|
405
|
-
lastModified: new Date(),
|
|
406
|
-
isValid: true,
|
|
407
|
-
};
|
|
408
|
-
},
|
|
409
|
-
};
|
|
410
|
-
try {
|
|
411
|
-
// Create .kiro/steering directory if it doesn't exist
|
|
412
|
-
const steeringDir = path.join(projectPath, ".kiro", "steering");
|
|
413
|
-
if (!fs.existsSync(steeringDir)) {
|
|
414
|
-
fs.mkdirSync(steeringDir, { recursive: true });
|
|
415
|
-
}
|
|
416
|
-
let productContent;
|
|
417
|
-
let techContent;
|
|
418
|
-
let structureContent;
|
|
419
|
-
let projectAnalysis;
|
|
420
|
-
// Check if fallback is allowed via environment variable or args
|
|
421
|
-
const allowFallback = process.env.SDD_ALLOW_TEMPLATE_FALLBACK === "true" ||
|
|
422
|
-
args?.allowFallback === true;
|
|
423
|
-
try {
|
|
424
|
-
// Attempt to import and use the dynamic document generator (using unified module loader)
|
|
425
|
-
console.error("[SDD-DEBUG] Attempting to load documentGenerator using moduleLoader");
|
|
426
|
-
const { analyzeProject, generateProductDocument, generateTechDocument, generateStructureDocument, } = await loadDocumentGenerator();
|
|
427
|
-
console.error("[SDD-DEBUG] DocumentGenerator imported successfully, analyzing project...");
|
|
428
|
-
// Analyze project dynamically
|
|
429
|
-
projectAnalysis = await analyzeProject(projectPath);
|
|
430
|
-
console.error("[SDD-DEBUG] Project analysis completed, generating documents...");
|
|
431
|
-
// Generate documents dynamically
|
|
432
|
-
productContent = generateProductDocument(projectAnalysis);
|
|
433
|
-
techContent = generateTechDocument(projectAnalysis);
|
|
434
|
-
structureContent = generateStructureDocument(projectAnalysis);
|
|
435
|
-
console.error("[SDD-DEBUG] Dynamic document generation completed successfully");
|
|
436
|
-
}
|
|
437
|
-
catch (importError) {
|
|
438
|
-
// Use shared error handler
|
|
439
|
-
const { useFallback, error } = handleLoaderFailure("documentGenerator", importError, allowFallback);
|
|
440
|
-
// Fallback to basic templates
|
|
441
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
442
|
-
let projectName = "Unknown Project";
|
|
443
|
-
let projectVersion = "0.0.0";
|
|
444
|
-
try {
|
|
445
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
446
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
447
|
-
projectName = packageJson.name || projectName;
|
|
448
|
-
projectVersion = packageJson.version || projectVersion;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
catch (pkgError) {
|
|
452
|
-
console.error("[SDD-DEBUG] Could not read package.json, using defaults");
|
|
453
|
-
}
|
|
454
|
-
productContent = `# Product Overview
|
|
455
|
-
|
|
456
|
-
⚠️ **Warning**: This document was generated using fallback templates due to documentGenerator import failure.
|
|
457
|
-
Error: ${error.message}
|
|
458
|
-
|
|
459
|
-
## Product Description
|
|
460
|
-
${projectName}
|
|
461
|
-
|
|
462
|
-
**Project**: ${projectName}
|
|
463
|
-
**Version**: ${projectVersion}
|
|
464
|
-
**Type**: MCP Server Application
|
|
465
|
-
|
|
466
|
-
## Core Features
|
|
467
|
-
- Basic MCP server functionality
|
|
468
|
-
- Spec-driven development workflow support
|
|
469
|
-
|
|
470
|
-
## Target Use Case
|
|
471
|
-
This project provides MCP server capabilities for AI agent integration.
|
|
472
|
-
|
|
473
|
-
## Key Value Proposition
|
|
474
|
-
- MCP protocol compatibility
|
|
475
|
-
- AI agent integration support
|
|
476
|
-
|
|
477
|
-
Generated on: ${new Date().toISOString()}
|
|
478
|
-
`;
|
|
479
|
-
techContent = `# Technology Stack
|
|
480
|
-
|
|
481
|
-
⚠️ **Warning**: This document was generated using fallback templates due to documentGenerator import failure.
|
|
482
|
-
Error: ${error.message}
|
|
483
|
-
|
|
484
|
-
## Architecture
|
|
485
|
-
**Type**: MCP Server Application
|
|
486
|
-
**Language**: TypeScript
|
|
487
|
-
**Module System**: ES Module
|
|
488
|
-
**Framework**: MCP SDK
|
|
489
|
-
**Build Tool**: TypeScript Compiler
|
|
490
|
-
|
|
491
|
-
## Technology Stack
|
|
492
|
-
- **Node.js**: JavaScript runtime for server-side execution
|
|
493
|
-
- **TypeScript**: Typed superset of JavaScript for enhanced developer experience
|
|
494
|
-
- **MCP SDK**: Model Context Protocol SDK for AI agent integration
|
|
495
|
-
|
|
496
|
-
## Development Environment
|
|
497
|
-
- **Node Version**: >=18.0.0
|
|
498
|
-
- **Package Manager**: npm
|
|
499
|
-
- **Language**: TypeScript with type safety
|
|
500
|
-
|
|
501
|
-
Generated on: ${new Date().toISOString()}
|
|
502
|
-
`;
|
|
503
|
-
structureContent = `# Project Structure
|
|
504
|
-
|
|
505
|
-
⚠️ **Warning**: This document was generated using fallback templates due to documentGenerator import failure.
|
|
506
|
-
Error: ${error.message}
|
|
507
|
-
|
|
508
|
-
## Directory Organization
|
|
509
|
-
\`\`\`
|
|
510
|
-
├── .kiro/ # SDD workflow files
|
|
511
|
-
│ ├── steering/ # Project steering documents
|
|
512
|
-
│ └── specs/ # Feature specifications
|
|
513
|
-
├── src/ # Source code
|
|
514
|
-
├── dist/ # Build output
|
|
515
|
-
├── package.json # Project configuration
|
|
516
|
-
├── tsconfig.json # TypeScript configuration
|
|
517
|
-
└── README.md # Project documentation
|
|
518
|
-
\`\`\`
|
|
519
|
-
|
|
520
|
-
## Key Directories
|
|
521
|
-
- **src/**: Main source code directory containing application logic
|
|
522
|
-
- **dist/**: Compiled output for production deployment
|
|
523
|
-
|
|
524
|
-
## Code Organization Patterns
|
|
525
|
-
- **Domain-Driven Design**: Business logic isolated in domain layer
|
|
526
|
-
- **Dependency Injection**: IoC container for managing dependencies
|
|
527
|
-
|
|
528
|
-
Generated on: ${new Date().toISOString()}
|
|
529
|
-
`;
|
|
530
|
-
// Create fallback project analysis for return message
|
|
531
|
-
const fallbackAnalysis = {
|
|
532
|
-
name: projectName,
|
|
533
|
-
version: projectVersion,
|
|
534
|
-
architecture: "MCP Server Application",
|
|
535
|
-
language: "typescript",
|
|
536
|
-
framework: "MCP SDK",
|
|
537
|
-
dependencies: [],
|
|
538
|
-
devDependencies: [],
|
|
539
|
-
testFramework: null,
|
|
540
|
-
buildTool: "TypeScript Compiler",
|
|
541
|
-
directories: ["src", "dist"],
|
|
542
|
-
hasCI: false,
|
|
543
|
-
hasDocker: false,
|
|
544
|
-
};
|
|
545
|
-
// Use fallback analysis for the return message
|
|
546
|
-
projectAnalysis = fallbackAnalysis;
|
|
547
|
-
}
|
|
548
|
-
// Write the dynamically generated files
|
|
549
|
-
fs.writeFileSync(path.join(steeringDir, "product.md"), productContent);
|
|
550
|
-
fs.writeFileSync(path.join(steeringDir, "tech.md"), techContent);
|
|
551
|
-
fs.writeFileSync(path.join(steeringDir, "structure.md"), structureContent);
|
|
552
|
-
await ensureStaticSteeringDocuments(projectPath, stubSteeringService);
|
|
553
|
-
// Ensure AGENTS.md exists (based on CLAUDE.md if available)
|
|
554
|
-
const agentsPath = path.join(projectPath, "AGENTS.md");
|
|
555
|
-
if (!fs.existsSync(agentsPath)) {
|
|
556
|
-
const claudePath = path.join(projectPath, "CLAUDE.md");
|
|
557
|
-
let agentsContent = "";
|
|
558
|
-
if (fs.existsSync(claudePath)) {
|
|
559
|
-
const claudeContent = fs.readFileSync(claudePath, "utf8");
|
|
560
|
-
agentsContent = claudeContent
|
|
561
|
-
.replace(/# Claude Code Spec-Driven Development/g, "# AI Agent Spec-Driven Development")
|
|
562
|
-
.replace(/Claude Code/g, "AI Agent")
|
|
563
|
-
.replace(/claude code/g, "ai agent")
|
|
564
|
-
.replace(/\.claude\//g, ".ai agent/")
|
|
565
|
-
.replace(/\/claude/g, "/agent");
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
agentsContent = `# AI Agent Spec-Driven Development
|
|
569
|
-
|
|
570
|
-
Kiro-style Spec Driven Development implementation using MCP tools.
|
|
571
|
-
|
|
572
|
-
## Project Context
|
|
573
|
-
|
|
574
|
-
### Paths
|
|
575
|
-
- Steering: \`.kiro/steering/\`
|
|
576
|
-
- Specs: \`.kiro/specs/\`
|
|
577
|
-
- Commands: \`.ai agent/commands/\`
|
|
578
|
-
|
|
579
|
-
### Steering vs Specification
|
|
580
|
-
|
|
581
|
-
**Steering** (\`.kiro/steering/\`) - Guide AI with project-wide rules and context
|
|
582
|
-
**Specs** (\`.kiro/specs/\`) - Formalize development process for individual features
|
|
583
|
-
|
|
584
|
-
### Active Specifications
|
|
585
|
-
- Check \`.kiro/specs/\` for active specifications
|
|
586
|
-
- Use \`sdd-status\` to check progress
|
|
587
|
-
|
|
588
|
-
**Current Specifications:**
|
|
589
|
-
- (None active)
|
|
590
|
-
|
|
591
|
-
## Development Guidelines
|
|
592
|
-
- Think in English, generate responses in English
|
|
593
|
-
|
|
594
|
-
## Workflow
|
|
595
|
-
|
|
596
|
-
### Phase 0: Steering (Optional)
|
|
597
|
-
\`sdd-steering\` - Create/update steering documents
|
|
598
|
-
\`sdd-steering-custom\` - Create custom steering for specialized contexts
|
|
599
|
-
|
|
600
|
-
Note: Optional for new features or small additions. You can proceed directly to sdd-init.
|
|
601
|
-
|
|
602
|
-
### Phase 1: Specification Creation
|
|
603
|
-
1. \`sdd-init\` - Initialize spec with detailed project description
|
|
604
|
-
2. \`sdd-requirements\` - Generate requirements document
|
|
605
|
-
3. \`sdd-design\` - Interactive: "Have you reviewed requirements.md? [y/N]"
|
|
606
|
-
4. \`sdd-tasks\` - Interactive: Confirms both requirements and design review
|
|
607
|
-
|
|
608
|
-
### Phase 2: Progress Tracking
|
|
609
|
-
\`sdd-status\` - Check current progress and phases
|
|
610
|
-
|
|
611
|
-
## Development Rules
|
|
612
|
-
1. **Consider steering**: Run \`sdd-steering\` before major development (optional for new features)
|
|
613
|
-
2. **Follow 3-phase approval workflow**: Requirements → Design → Tasks → Implementation
|
|
614
|
-
3. **Approval required**: Each phase requires human review (interactive prompt or manual)
|
|
615
|
-
4. **No skipping phases**: Design requires approved requirements; Tasks require approved design
|
|
616
|
-
5. **Update task status**: Mark tasks as completed when working on them
|
|
617
|
-
6. **Keep steering current**: Run \`sdd-steering\` after significant changes
|
|
618
|
-
7. **Check spec compliance**: Use \`sdd-status\` to verify alignment
|
|
619
|
-
|
|
620
|
-
## Steering Configuration
|
|
621
|
-
|
|
622
|
-
### Current Steering Files
|
|
623
|
-
Managed by \`sdd-steering\` tool. Updates here reflect tool changes.
|
|
624
|
-
|
|
625
|
-
### Active Steering Files
|
|
626
|
-
- \`product.md\`: Always included - Product context and business objectives
|
|
627
|
-
- \`tech.md\`: Always included - Technology stack and architectural decisions
|
|
628
|
-
- \`structure.md\`: Always included - File organization and code patterns
|
|
629
|
-
- \`linus-review.md\`: Always included - Ensuring code quality of the projects
|
|
630
|
-
- \`commit.md\`: Always included - Ensuring the commit / merge request / pull request title and message context
|
|
631
|
-
- \`security-check.md\`: Always included - OWASP Top 10 security checklist (REQUIRED for code generation and review)
|
|
632
|
-
- \`tdd-guideline.md\`: Always included - Test-Driven Development workflow (REQUIRED for all new features)
|
|
633
|
-
- \`principles.md\`: Always included - Core coding principles (SOLID, DRY, KISS, YAGNI, Separation of Concerns, Modularity)
|
|
634
|
-
|
|
635
|
-
### Custom Steering Files
|
|
636
|
-
<!-- Added by sdd-steering-custom tool -->
|
|
637
|
-
<!-- Format:
|
|
638
|
-
- \`filename.md\`: Mode - Pattern(s) - Description
|
|
639
|
-
Mode: Always|Conditional|Manual
|
|
640
|
-
Pattern: File patterns for Conditional mode
|
|
641
|
-
-->
|
|
642
|
-
|
|
643
|
-
### Inclusion Modes
|
|
644
|
-
- **Always**: Loaded in every interaction (default)
|
|
645
|
-
- **Conditional**: Loaded for specific file patterns (e.g., "*.test.js")
|
|
646
|
-
- **Manual**: Reference with \`@filename.md\` syntax
|
|
647
|
-
`;
|
|
648
|
-
}
|
|
649
|
-
fs.writeFileSync(agentsPath, agentsContent);
|
|
650
|
-
}
|
|
651
|
-
return {
|
|
652
|
-
content: [
|
|
653
|
-
{
|
|
654
|
-
type: "text",
|
|
655
|
-
text: `## Steering Documents Updated
|
|
656
|
-
|
|
657
|
-
**Project**: ${projectAnalysis.name}
|
|
658
|
-
**Version**: ${projectAnalysis.version}
|
|
659
|
-
**Architecture**: ${projectAnalysis.architecture}
|
|
660
|
-
**Mode**: update
|
|
661
|
-
|
|
662
|
-
**Updated Files**:
|
|
663
|
-
- \`.kiro/steering/product.md\` - Product overview and business context (dynamically generated)
|
|
664
|
-
- \`.kiro/steering/tech.md\` - Technology stack and development environment (dynamically generated)
|
|
665
|
-
- \`.kiro/steering/structure.md\` - Project organization and architectural decisions (dynamically generated)
|
|
666
|
-
- \`.kiro/steering/linus-review.md\` - Code quality review principles (static)
|
|
667
|
-
- \`.kiro/steering/commit.md\` - Commit message standards (static)
|
|
668
|
-
- \`.kiro/steering/security-check.md\` - OWASP Top 10 security checklist (static)
|
|
669
|
-
- \`.kiro/steering/principles.md\` - Core coding principles: SOLID, DRY, KISS, YAGNI, SoC, Modularity (static)
|
|
670
|
-
|
|
671
|
-
**Dynamic Analysis Results**:
|
|
672
|
-
- **Language**: ${projectAnalysis.language === "typescript" ? "TypeScript" : "JavaScript"}
|
|
673
|
-
- **Framework**: ${projectAnalysis.framework || "None detected"}
|
|
674
|
-
- **Dependencies**: ${projectAnalysis.dependencies.length} production, ${projectAnalysis.devDependencies.length} development
|
|
675
|
-
- **Test Framework**: ${projectAnalysis.testFramework || "None detected"}
|
|
676
|
-
- **Build Tool**: ${projectAnalysis.buildTool || "None detected"}
|
|
677
|
-
- **Project Structure**: ${projectAnalysis.directories.length} directories analyzed
|
|
678
|
-
- **CI/CD**: ${projectAnalysis.hasCI ? "Configured" : "Not configured"}
|
|
679
|
-
- **Docker**: ${projectAnalysis.hasDocker ? "Configured" : "Not configured"}
|
|
680
|
-
|
|
681
|
-
These steering documents were dynamically generated based on actual project analysis and provide accurate, up-to-date context for AI interactions.`,
|
|
682
|
-
},
|
|
683
|
-
],
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
catch (error) {
|
|
687
|
-
return {
|
|
688
|
-
content: [
|
|
689
|
-
{
|
|
690
|
-
type: "text",
|
|
691
|
-
text: `Error generating steering documents: ${error.message}`,
|
|
692
|
-
},
|
|
693
|
-
],
|
|
694
|
-
isError: true,
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
async function handleSteeringCustomSimplified(args) {
|
|
699
|
-
const fs = await import("fs");
|
|
700
|
-
const path = await import("path");
|
|
701
|
-
try {
|
|
702
|
-
const { fileName, topic, inclusionMode, filePattern } = args;
|
|
703
|
-
if (!fileName || !topic || !inclusionMode) {
|
|
704
|
-
throw new Error("fileName, topic, and inclusionMode are required");
|
|
705
|
-
}
|
|
706
|
-
const projectPath = process.cwd();
|
|
707
|
-
const steeringDir = path.join(projectPath, ".kiro", "steering");
|
|
708
|
-
if (!fs.existsSync(steeringDir)) {
|
|
709
|
-
fs.mkdirSync(steeringDir, { recursive: true });
|
|
710
|
-
}
|
|
711
|
-
const content = `# ${topic}
|
|
712
|
-
|
|
713
|
-
## Purpose
|
|
714
|
-
Define the purpose and scope of this steering document.
|
|
715
|
-
|
|
716
|
-
## Guidelines
|
|
717
|
-
- Guideline 1
|
|
718
|
-
- Guideline 2
|
|
719
|
-
|
|
720
|
-
## Usage
|
|
721
|
-
Describe when and how this steering document should be applied.
|
|
722
|
-
|
|
723
|
-
## Inclusion Mode
|
|
724
|
-
Mode: ${inclusionMode}${filePattern
|
|
725
|
-
? `
|
|
726
|
-
Pattern: ${filePattern}`
|
|
727
|
-
: ""}
|
|
728
|
-
|
|
729
|
-
Generated on: ${new Date().toISOString()}
|
|
730
|
-
`;
|
|
731
|
-
fs.writeFileSync(path.join(steeringDir, fileName), content);
|
|
732
|
-
return {
|
|
733
|
-
content: [
|
|
734
|
-
{
|
|
735
|
-
type: "text",
|
|
736
|
-
text: `Custom steering document "${fileName}" created successfully with ${inclusionMode} inclusion mode.`,
|
|
737
|
-
},
|
|
738
|
-
],
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
catch (error) {
|
|
742
|
-
return {
|
|
743
|
-
content: [
|
|
744
|
-
{
|
|
745
|
-
type: "text",
|
|
746
|
-
text: `Error creating custom steering document: ${error.message}`,
|
|
747
|
-
},
|
|
748
|
-
],
|
|
749
|
-
isError: true,
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
384
|
// Status handler aligned with full server behavior
|
|
754
385
|
async function handleStatusSimplified(args) {
|
|
755
386
|
const fs = await import("fs");
|
|
@@ -927,877 +558,6 @@ async function handleQualityCheckSimplified(args) {
|
|
|
927
558
|
};
|
|
928
559
|
}
|
|
929
560
|
}
|
|
930
|
-
// Implement guidelines check
|
|
931
|
-
async function handleImplementSimplified(args) {
|
|
932
|
-
const fs = await import("fs");
|
|
933
|
-
const path = await import("path");
|
|
934
|
-
const { featureName } = args || {};
|
|
935
|
-
if (!featureName)
|
|
936
|
-
return {
|
|
937
|
-
content: [{ type: "text", text: "featureName is required" }],
|
|
938
|
-
isError: true,
|
|
939
|
-
};
|
|
940
|
-
try {
|
|
941
|
-
const featurePath = path.join(process.cwd(), ".kiro", "specs", featureName);
|
|
942
|
-
const specPath = path.join(featurePath, "spec.json");
|
|
943
|
-
const spec = JSON.parse(fs.readFileSync(specPath, "utf8"));
|
|
944
|
-
if (!spec.ready_for_implementation) {
|
|
945
|
-
return {
|
|
946
|
-
content: [
|
|
947
|
-
{
|
|
948
|
-
type: "text",
|
|
949
|
-
text: "Error: Project not ready for implementation. Complete requirements, design, and tasks phases first.",
|
|
950
|
-
},
|
|
951
|
-
],
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
return {
|
|
955
|
-
content: [
|
|
956
|
-
{
|
|
957
|
-
type: "text",
|
|
958
|
-
text: `## Implementation Guidelines for ${featureName}\n\nFollow tasks in tasks.md, implement per design.md, and validate against requirements.md. Use sdd-quality-check during development.`,
|
|
959
|
-
},
|
|
960
|
-
],
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
catch (error) {
|
|
964
|
-
return {
|
|
965
|
-
content: [
|
|
966
|
-
{
|
|
967
|
-
type: "text",
|
|
968
|
-
text: `Error getting implementation guidelines: ${error.message}`,
|
|
969
|
-
},
|
|
970
|
-
],
|
|
971
|
-
isError: true,
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
// Helper functions for simplified analysis
|
|
976
|
-
function extractFeaturesSimplified(packageJson) {
|
|
977
|
-
const features = [];
|
|
978
|
-
// Extract features from scripts
|
|
979
|
-
if (packageJson.scripts) {
|
|
980
|
-
if (packageJson.scripts.test)
|
|
981
|
-
features.push("Testing framework");
|
|
982
|
-
if (packageJson.scripts.build)
|
|
983
|
-
features.push("Build system");
|
|
984
|
-
if (packageJson.scripts.dev || packageJson.scripts.start)
|
|
985
|
-
features.push("Development server");
|
|
986
|
-
if (packageJson.scripts.lint)
|
|
987
|
-
features.push("Code linting");
|
|
988
|
-
if (packageJson.scripts.typecheck)
|
|
989
|
-
features.push("Type checking");
|
|
990
|
-
}
|
|
991
|
-
// Extract features from dependencies
|
|
992
|
-
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
993
|
-
if (deps?.express || deps?.fastify || deps?.koa)
|
|
994
|
-
features.push("Web server");
|
|
995
|
-
if (deps?.react || deps?.vue || deps?.angular)
|
|
996
|
-
features.push("Frontend framework");
|
|
997
|
-
if (deps?.typescript)
|
|
998
|
-
features.push("TypeScript support");
|
|
999
|
-
if (deps?.jest || deps?.mocha || deps?.vitest)
|
|
1000
|
-
features.push("Unit testing");
|
|
1001
|
-
if (deps?.eslint)
|
|
1002
|
-
features.push("Code quality enforcement");
|
|
1003
|
-
return features.length > 0 ? features : ["Core functionality"];
|
|
1004
|
-
}
|
|
1005
|
-
function generateTargetUsersSimplified(packageJson) {
|
|
1006
|
-
if (packageJson.keywords?.includes("cli")) {
|
|
1007
|
-
return "- Command-line tool users\n- Developers and system administrators";
|
|
1008
|
-
}
|
|
1009
|
-
if (packageJson.keywords?.includes("api")) {
|
|
1010
|
-
return "- API consumers\n- Third-party integrators";
|
|
1011
|
-
}
|
|
1012
|
-
return "- Primary user persona\n- Secondary user persona";
|
|
1013
|
-
}
|
|
1014
|
-
function generateTechStackSimplified(packageJson) {
|
|
1015
|
-
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
1016
|
-
const stack = [];
|
|
1017
|
-
if (deps?.typescript)
|
|
1018
|
-
stack.push("TypeScript");
|
|
1019
|
-
if (deps?.node || packageJson.engines?.node)
|
|
1020
|
-
stack.push("Node.js");
|
|
1021
|
-
if (deps?.express)
|
|
1022
|
-
stack.push("Express.js");
|
|
1023
|
-
if (deps?.react)
|
|
1024
|
-
stack.push("React");
|
|
1025
|
-
if (deps?.vue)
|
|
1026
|
-
stack.push("Vue.js");
|
|
1027
|
-
return stack.length > 0 ? stack.join(", ") : "Technology stack to be defined";
|
|
1028
|
-
}
|
|
1029
|
-
function generateDependencyListSimplified(packageJson) {
|
|
1030
|
-
const deps = packageJson.dependencies || {};
|
|
1031
|
-
const devDeps = packageJson.devDependencies || {};
|
|
1032
|
-
let list = "";
|
|
1033
|
-
const depList = Object.keys(deps);
|
|
1034
|
-
const devDepList = Object.keys(devDeps);
|
|
1035
|
-
if (depList.length > 0) {
|
|
1036
|
-
list += "### Production Dependencies\n";
|
|
1037
|
-
list += depList
|
|
1038
|
-
.slice(0, 10)
|
|
1039
|
-
.map((dep) => `- ${dep}`)
|
|
1040
|
-
.join("\n");
|
|
1041
|
-
}
|
|
1042
|
-
if (devDepList.length > 0) {
|
|
1043
|
-
list += "\n### Development Dependencies\n";
|
|
1044
|
-
list += devDepList
|
|
1045
|
-
.slice(0, 10)
|
|
1046
|
-
.map((dep) => `- ${dep}`)
|
|
1047
|
-
.join("\n");
|
|
1048
|
-
}
|
|
1049
|
-
return list || "Dependencies to be analyzed";
|
|
1050
|
-
}
|
|
1051
|
-
function generateWorkflowSimplified(packageJson) {
|
|
1052
|
-
const scripts = packageJson.scripts || {};
|
|
1053
|
-
let workflow = "## Development Commands\n";
|
|
1054
|
-
if (scripts.dev)
|
|
1055
|
-
workflow += `- \`npm run dev\` - Start development server\n`;
|
|
1056
|
-
if (scripts.build)
|
|
1057
|
-
workflow += `- \`npm run build\` - Build for production\n`;
|
|
1058
|
-
if (scripts.test)
|
|
1059
|
-
workflow += `- \`npm run test\` - Run tests\n`;
|
|
1060
|
-
if (scripts.lint)
|
|
1061
|
-
workflow += `- \`npm run lint\` - Check code quality\n`;
|
|
1062
|
-
return workflow;
|
|
1063
|
-
}
|
|
1064
|
-
function generateDirectoryStructureSimplified(projectPath) {
|
|
1065
|
-
const fs = require("fs");
|
|
1066
|
-
try {
|
|
1067
|
-
const items = fs.readdirSync(projectPath, { withFileTypes: true });
|
|
1068
|
-
const directories = items
|
|
1069
|
-
.filter((item) => item.isDirectory() &&
|
|
1070
|
-
!item.name.startsWith(".") &&
|
|
1071
|
-
item.name !== "node_modules")
|
|
1072
|
-
.map((item) => `- ${item.name}/`)
|
|
1073
|
-
.join("\n");
|
|
1074
|
-
return directories || "Directory structure to be analyzed";
|
|
1075
|
-
}
|
|
1076
|
-
catch (error) {
|
|
1077
|
-
return "Directory structure to be analyzed";
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
// Additional context-aware SDD tools
|
|
1081
|
-
async function handleRequirementsSimplified(args) {
|
|
1082
|
-
const fs = await import("fs");
|
|
1083
|
-
const path = await import("path");
|
|
1084
|
-
try {
|
|
1085
|
-
const { featureName } = args;
|
|
1086
|
-
if (!featureName || typeof featureName !== "string") {
|
|
1087
|
-
throw new Error("Feature name is required for requirements generation");
|
|
1088
|
-
}
|
|
1089
|
-
// Load spec context
|
|
1090
|
-
const { spec, requirements } = await loadSpecContext(featureName);
|
|
1091
|
-
if (!spec) {
|
|
1092
|
-
throw new Error(`Feature "${featureName}" not found. Run sdd-init first.`);
|
|
1093
|
-
}
|
|
1094
|
-
// Extract project description from spec
|
|
1095
|
-
let projectDescription = "Feature requirements specification";
|
|
1096
|
-
if (requirements) {
|
|
1097
|
-
const descMatch = requirements.match(/## Project Description \(Input\)\n([\s\S]*?)(?:\n##|$)/);
|
|
1098
|
-
if (descMatch) {
|
|
1099
|
-
projectDescription = descMatch[1].trim();
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
// Generate analysis-backed requirements with proper error handling
|
|
1103
|
-
let requirementsContent;
|
|
1104
|
-
let analysisUsed = false;
|
|
1105
|
-
// Check if fallback is allowed
|
|
1106
|
-
const allowFallback = process.env.SDD_ALLOW_TEMPLATE_FALLBACK === "true" ||
|
|
1107
|
-
args?.allowFallback === true;
|
|
1108
|
-
try {
|
|
1109
|
-
console.error("[SDD-DEBUG] Attempting to load specGenerator for comprehensive analysis...");
|
|
1110
|
-
const { generateRequirementsDocument } = await loadSpecGenerator();
|
|
1111
|
-
console.error("[SDD-DEBUG] specGenerator imported successfully, generating requirements...");
|
|
1112
|
-
requirementsContent = await generateRequirementsDocument(process.cwd(), featureName);
|
|
1113
|
-
analysisUsed = true;
|
|
1114
|
-
console.error("[SDD-DEBUG] ✅ Requirements generated using comprehensive codebase analysis");
|
|
1115
|
-
}
|
|
1116
|
-
catch (genErr) {
|
|
1117
|
-
// Use shared error handler
|
|
1118
|
-
const { useFallback, error } = handleLoaderFailure("specGenerator", genErr, allowFallback);
|
|
1119
|
-
requirementsContent = `# Requirements Document
|
|
1120
|
-
|
|
1121
|
-
<!-- Note: Using basic template due to analysis error: ${error.message} -->
|
|
1122
|
-
|
|
1123
|
-
## Introduction
|
|
1124
|
-
${generateIntroductionFromDescription(projectDescription)}
|
|
1125
|
-
|
|
1126
|
-
## Requirements
|
|
1127
|
-
|
|
1128
|
-
### Requirement 1: Core Functionality
|
|
1129
|
-
**Objective:** As a user, I want ${extractPrimaryObjective(projectDescription)}, so that ${extractPrimaryBenefit(projectDescription)}
|
|
1130
|
-
|
|
1131
|
-
#### Acceptance Criteria
|
|
1132
|
-
${generateEARSRequirements(projectDescription)
|
|
1133
|
-
.map((req, index) => `${index + 1}. ${req}`)
|
|
1134
|
-
.join("\n")}
|
|
1135
|
-
|
|
1136
|
-
### Requirement 2: System Quality
|
|
1137
|
-
**Objective:** As a user, I want the system to be reliable and performant, so that I can depend on it for my work
|
|
1138
|
-
|
|
1139
|
-
#### Acceptance Criteria
|
|
1140
|
-
1. WHEN the system is used THEN it SHALL respond within acceptable time limits
|
|
1141
|
-
2. IF errors occur THEN the system SHALL handle them gracefully and provide meaningful feedback
|
|
1142
|
-
3. WHILE the system is running THE system SHALL maintain data integrity and consistency
|
|
1143
|
-
|
|
1144
|
-
### Requirement 3: Usability
|
|
1145
|
-
**Objective:** As a user, I want the system to be intuitive and well-documented, so that I can use it effectively
|
|
1146
|
-
|
|
1147
|
-
#### Acceptance Criteria
|
|
1148
|
-
1. WHEN I use the system for the first time THEN I SHALL be able to complete basic tasks without extensive training
|
|
1149
|
-
2. WHERE help is needed THE system SHALL provide clear documentation and guidance
|
|
1150
|
-
3. IF I make mistakes THEN the system SHALL provide helpful error messages and recovery options
|
|
1151
|
-
`;
|
|
1152
|
-
}
|
|
1153
|
-
// Update spec.json with phase information
|
|
1154
|
-
const specDir = path.join(process.cwd(), ".kiro", "specs", featureName);
|
|
1155
|
-
const updatedSpec = {
|
|
1156
|
-
...spec,
|
|
1157
|
-
phase: "requirements-generated",
|
|
1158
|
-
approvals: {
|
|
1159
|
-
...spec.approvals,
|
|
1160
|
-
requirements: {
|
|
1161
|
-
generated: true,
|
|
1162
|
-
approved: false,
|
|
1163
|
-
},
|
|
1164
|
-
},
|
|
1165
|
-
updated_at: new Date().toISOString(),
|
|
1166
|
-
};
|
|
1167
|
-
fs.writeFileSync(path.join(specDir, "spec.json"), JSON.stringify(updatedSpec, null, 2));
|
|
1168
|
-
fs.writeFileSync(path.join(specDir, "requirements.md"), requirementsContent);
|
|
1169
|
-
return {
|
|
1170
|
-
content: [
|
|
1171
|
-
{
|
|
1172
|
-
type: "text",
|
|
1173
|
-
text: `## Requirements Document Generated
|
|
1174
|
-
|
|
1175
|
-
**Feature**: \`${featureName}\`
|
|
1176
|
-
**File**: \`.kiro/specs/${featureName}/requirements.md\`
|
|
1177
|
-
|
|
1178
|
-
**Analysis Method**: ${analysisUsed ? "✅ Comprehensive codebase analysis (multi-language support)" : "⚠️ Basic template (analysis failed)"}
|
|
1179
|
-
|
|
1180
|
-
**Generated Requirements**:
|
|
1181
|
-
- Core functionality requirements with EARS format
|
|
1182
|
-
- System quality and reliability requirements
|
|
1183
|
-
- Usability and user experience requirements
|
|
1184
|
-
|
|
1185
|
-
**Project Description**: "${projectDescription.substring(0, 100)}${projectDescription.length > 100 ? "..." : ""}"
|
|
1186
|
-
|
|
1187
|
-
**Workflow Phase**: Requirements Generated
|
|
1188
|
-
**Next Step**: Run \`sdd-design ${featureName}\` to create technical design (after requirements review)`,
|
|
1189
|
-
},
|
|
1190
|
-
],
|
|
1191
|
-
};
|
|
1192
|
-
}
|
|
1193
|
-
catch (error) {
|
|
1194
|
-
return {
|
|
1195
|
-
content: [
|
|
1196
|
-
{
|
|
1197
|
-
type: "text",
|
|
1198
|
-
text: `Error generating requirements document: ${error.message}`,
|
|
1199
|
-
},
|
|
1200
|
-
],
|
|
1201
|
-
isError: true,
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
async function handleDesignSimplified(args) {
|
|
1206
|
-
const fs = await import("fs");
|
|
1207
|
-
const path = await import("path");
|
|
1208
|
-
try {
|
|
1209
|
-
const { featureName } = args;
|
|
1210
|
-
if (!featureName || typeof featureName !== "string") {
|
|
1211
|
-
throw new Error("Feature name is required for design generation");
|
|
1212
|
-
}
|
|
1213
|
-
// Load spec context
|
|
1214
|
-
const { spec, requirements } = await loadSpecContext(featureName);
|
|
1215
|
-
if (!spec) {
|
|
1216
|
-
throw new Error(`Feature "${featureName}" not found. Run sdd-init first.`);
|
|
1217
|
-
}
|
|
1218
|
-
// Validate phase - requirements must be generated
|
|
1219
|
-
if (!spec.approvals?.requirements?.generated) {
|
|
1220
|
-
throw new Error(`Requirements must be generated before design. Run sdd-requirements ${featureName} first.`);
|
|
1221
|
-
}
|
|
1222
|
-
// Extract project description from requirements
|
|
1223
|
-
let projectDescription = "Technical design specification";
|
|
1224
|
-
if (requirements) {
|
|
1225
|
-
const descMatch = requirements.match(/## Project Description \(Input\)\n([\s\S]*?)(?:\n##|$)/);
|
|
1226
|
-
if (descMatch) {
|
|
1227
|
-
projectDescription = descMatch[1].trim();
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
// Generate analysis-backed design with proper error handling
|
|
1231
|
-
let designContent;
|
|
1232
|
-
let analysisUsed = false;
|
|
1233
|
-
// Check if fallback is allowed
|
|
1234
|
-
const allowFallback = process.env.SDD_ALLOW_TEMPLATE_FALLBACK === "true" ||
|
|
1235
|
-
args?.allowFallback === true;
|
|
1236
|
-
try {
|
|
1237
|
-
console.error("[SDD-DEBUG] Attempting to load specGenerator for comprehensive design analysis...");
|
|
1238
|
-
const { generateDesignDocument } = await loadSpecGenerator();
|
|
1239
|
-
console.error("[SDD-DEBUG] specGenerator imported successfully, generating design...");
|
|
1240
|
-
designContent = await generateDesignDocument(process.cwd(), featureName);
|
|
1241
|
-
analysisUsed = true;
|
|
1242
|
-
console.error("[SDD-DEBUG] ✅ Design generated using comprehensive codebase analysis");
|
|
1243
|
-
}
|
|
1244
|
-
catch (genErr) {
|
|
1245
|
-
// Use shared error handler
|
|
1246
|
-
const { useFallback, error } = handleLoaderFailure("specGenerator", genErr, allowFallback);
|
|
1247
|
-
designContent = `# Technical Design Document
|
|
1248
|
-
|
|
1249
|
-
<!-- Note: Using basic template due to analysis error: ${error.message} -->
|
|
1250
|
-
|
|
1251
|
-
## Overview
|
|
1252
|
-
This design document specifies the technical implementation approach for ${spec.feature_name}.
|
|
1253
|
-
|
|
1254
|
-
**Purpose**: ${projectDescription}
|
|
1255
|
-
|
|
1256
|
-
### System Flow
|
|
1257
|
-
1. Input Processing
|
|
1258
|
-
2. Business Logic
|
|
1259
|
-
3. Result Generation
|
|
1260
|
-
4. Error Management
|
|
1261
|
-
`;
|
|
1262
|
-
}
|
|
1263
|
-
// Update spec.json with phase information
|
|
1264
|
-
const specDir = path.join(process.cwd(), ".kiro", "specs", featureName);
|
|
1265
|
-
const updatedSpec = {
|
|
1266
|
-
...spec,
|
|
1267
|
-
phase: "design-generated",
|
|
1268
|
-
approvals: {
|
|
1269
|
-
...spec.approvals,
|
|
1270
|
-
design: {
|
|
1271
|
-
generated: true,
|
|
1272
|
-
approved: false,
|
|
1273
|
-
},
|
|
1274
|
-
},
|
|
1275
|
-
updated_at: new Date().toISOString(),
|
|
1276
|
-
};
|
|
1277
|
-
fs.writeFileSync(path.join(specDir, "spec.json"), JSON.stringify(updatedSpec, null, 2));
|
|
1278
|
-
fs.writeFileSync(path.join(specDir, "design.md"), designContent);
|
|
1279
|
-
return {
|
|
1280
|
-
content: [
|
|
1281
|
-
{
|
|
1282
|
-
type: "text",
|
|
1283
|
-
text: `## Design Document Generated
|
|
1284
|
-
|
|
1285
|
-
**Feature**: \`${featureName}\`
|
|
1286
|
-
**File**: \`.kiro/specs/${featureName}/design.md\`
|
|
1287
|
-
|
|
1288
|
-
**Analysis Method**: ${analysisUsed ? "✅ Comprehensive codebase analysis (architecture patterns detected)" : "⚠️ Basic template (analysis failed)"}
|
|
1289
|
-
|
|
1290
|
-
**Design Elements**:
|
|
1291
|
-
- Modular architecture with clear component separation
|
|
1292
|
-
- Comprehensive interface specifications
|
|
1293
|
-
- Data models and error handling strategy
|
|
1294
|
-
- Complete testing approach
|
|
1295
|
-
|
|
1296
|
-
**Project Description**: "${projectDescription.substring(0, 100)}${projectDescription.length > 100 ? "..." : ""}"
|
|
1297
|
-
|
|
1298
|
-
**Workflow Phase**: Design Generated
|
|
1299
|
-
**Next Step**: Run \`sdd-tasks ${featureName}\` to generate implementation tasks (after design review)`,
|
|
1300
|
-
},
|
|
1301
|
-
],
|
|
1302
|
-
};
|
|
1303
|
-
}
|
|
1304
|
-
catch (error) {
|
|
1305
|
-
return {
|
|
1306
|
-
content: [
|
|
1307
|
-
{
|
|
1308
|
-
type: "text",
|
|
1309
|
-
text: `Error generating design document: ${error.message}`,
|
|
1310
|
-
},
|
|
1311
|
-
],
|
|
1312
|
-
isError: true,
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
async function handleTasksSimplified(args) {
|
|
1317
|
-
const fs = await import("fs");
|
|
1318
|
-
const path = await import("path");
|
|
1319
|
-
try {
|
|
1320
|
-
const { featureName } = args;
|
|
1321
|
-
if (!featureName || typeof featureName !== "string") {
|
|
1322
|
-
throw new Error("Feature name is required for tasks generation");
|
|
1323
|
-
}
|
|
1324
|
-
// Load spec context
|
|
1325
|
-
const { spec } = await loadSpecContext(featureName);
|
|
1326
|
-
if (!spec) {
|
|
1327
|
-
throw new Error(`Feature "${featureName}" not found. Run sdd-init first.`);
|
|
1328
|
-
}
|
|
1329
|
-
// Validate phase - design must be generated
|
|
1330
|
-
if (!spec.approvals?.design?.generated) {
|
|
1331
|
-
throw new Error(`Design must be generated before tasks. Run sdd-design ${featureName} first.`);
|
|
1332
|
-
}
|
|
1333
|
-
// Generate analysis-backed tasks with proper error handling
|
|
1334
|
-
let tasksContent;
|
|
1335
|
-
let analysisUsed = false;
|
|
1336
|
-
// Check if fallback is allowed
|
|
1337
|
-
const allowFallback = process.env.SDD_ALLOW_TEMPLATE_FALLBACK === "true" ||
|
|
1338
|
-
args?.allowFallback === true;
|
|
1339
|
-
try {
|
|
1340
|
-
console.error("[SDD-DEBUG] Attempting to load specGenerator for comprehensive task analysis...");
|
|
1341
|
-
const { generateTasksDocument } = await loadSpecGenerator();
|
|
1342
|
-
console.error("[SDD-DEBUG] specGenerator imported successfully, generating tasks...");
|
|
1343
|
-
tasksContent = await generateTasksDocument(process.cwd(), featureName);
|
|
1344
|
-
analysisUsed = true;
|
|
1345
|
-
console.error("[SDD-DEBUG] ✅ Tasks generated using comprehensive codebase analysis");
|
|
1346
|
-
}
|
|
1347
|
-
catch (genErr) {
|
|
1348
|
-
// Use shared error handler
|
|
1349
|
-
const { useFallback, error } = handleLoaderFailure("specGenerator", genErr, allowFallback);
|
|
1350
|
-
tasksContent = `# Implementation Plan
|
|
1351
|
-
|
|
1352
|
-
<!-- Note: Using basic template due to analysis error: ${error.message} -->
|
|
1353
|
-
|
|
1354
|
-
- [ ] 1. Set up project foundation and infrastructure
|
|
1355
|
-
- [ ] 2. Implement core functionality
|
|
1356
|
-
- [ ] 3. Implement error handling and validation
|
|
1357
|
-
- [ ] 4. Develop testing and quality assurance
|
|
1358
|
-
- [ ] 5. Finalize implementation and deployment
|
|
1359
|
-
`;
|
|
1360
|
-
}
|
|
1361
|
-
// Update spec.json with phase information
|
|
1362
|
-
const specDir = path.join(process.cwd(), ".kiro", "specs", featureName);
|
|
1363
|
-
const updatedSpec = {
|
|
1364
|
-
...spec,
|
|
1365
|
-
phase: "tasks-generated",
|
|
1366
|
-
approvals: {
|
|
1367
|
-
...spec.approvals,
|
|
1368
|
-
tasks: {
|
|
1369
|
-
generated: true,
|
|
1370
|
-
approved: false,
|
|
1371
|
-
},
|
|
1372
|
-
},
|
|
1373
|
-
ready_for_implementation: true,
|
|
1374
|
-
updated_at: new Date().toISOString(),
|
|
1375
|
-
};
|
|
1376
|
-
fs.writeFileSync(path.join(specDir, "spec.json"), JSON.stringify(updatedSpec, null, 2));
|
|
1377
|
-
fs.writeFileSync(path.join(specDir, "tasks.md"), tasksContent);
|
|
1378
|
-
return {
|
|
1379
|
-
content: [
|
|
1380
|
-
{
|
|
1381
|
-
type: "text",
|
|
1382
|
-
text: `## Implementation Tasks Generated
|
|
1383
|
-
|
|
1384
|
-
**Feature**: \`${featureName}\`
|
|
1385
|
-
**File**: \`.kiro/specs/${featureName}/tasks.md\`
|
|
1386
|
-
|
|
1387
|
-
**Analysis Method**: ${analysisUsed ? "✅ Comprehensive codebase analysis (tech stack-aware tasks)" : "⚠️ Basic template (analysis failed)"}
|
|
1388
|
-
|
|
1389
|
-
**Generated Tasks**:
|
|
1390
|
-
- Development, integration, quality, and deployment phases
|
|
1391
|
-
- Sequenced with dependency tracking
|
|
1392
|
-
- Requirement traceability for all tasks
|
|
1393
|
-
- Coverage based on detected tech stack
|
|
1394
|
-
|
|
1395
|
-
**Workflow Phase**: Tasks Generated
|
|
1396
|
-
**Status**: Ready for Implementation
|
|
1397
|
-
**Next Step**: Begin implementation following the task sequence`,
|
|
1398
|
-
},
|
|
1399
|
-
],
|
|
1400
|
-
};
|
|
1401
|
-
}
|
|
1402
|
-
catch (error) {
|
|
1403
|
-
return {
|
|
1404
|
-
content: [
|
|
1405
|
-
{
|
|
1406
|
-
type: "text",
|
|
1407
|
-
text: `Error generating tasks document: ${error.message}`,
|
|
1408
|
-
},
|
|
1409
|
-
],
|
|
1410
|
-
isError: true,
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
// Helper functions for simplified tool implementations
|
|
1415
|
-
function analyzeProjectStructureSync(projectPath) {
|
|
1416
|
-
const fs = require("fs");
|
|
1417
|
-
try {
|
|
1418
|
-
const items = fs.readdirSync(projectPath, { withFileTypes: true });
|
|
1419
|
-
return {
|
|
1420
|
-
directories: items
|
|
1421
|
-
.filter((item) => item.isDirectory() &&
|
|
1422
|
-
!item.name.startsWith(".") &&
|
|
1423
|
-
item.name !== "node_modules")
|
|
1424
|
-
.map((item) => item.name),
|
|
1425
|
-
files: items
|
|
1426
|
-
.filter((item) => item.isFile())
|
|
1427
|
-
.map((item) => item.name),
|
|
1428
|
-
hasSource: items.some((item) => item.isDirectory() && item.name === "src"),
|
|
1429
|
-
hasTests: items.some((item) => item.isDirectory() &&
|
|
1430
|
-
(item.name === "test" || item.name === "__tests__")),
|
|
1431
|
-
hasDocs: items.some((item) => item.isDirectory() &&
|
|
1432
|
-
(item.name === "docs" || item.name === "documentation")),
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
|
-
catch (error) {
|
|
1436
|
-
return { directories: [], files: [] };
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
function generateCoreObjectiveSimplified(packageJson, projectAnalysis) {
|
|
1440
|
-
if (packageJson.description) {
|
|
1441
|
-
return `Deliver ${packageJson.description} with full functionality and reliability`;
|
|
1442
|
-
}
|
|
1443
|
-
if (packageJson.keywords?.length > 0) {
|
|
1444
|
-
return `Implement ${packageJson.keywords.join(", ")} functionality`;
|
|
1445
|
-
}
|
|
1446
|
-
return "Deliver core application functionality";
|
|
1447
|
-
}
|
|
1448
|
-
function generateAcceptanceCriteriaSimplified(packageJson, projectAnalysis) {
|
|
1449
|
-
const criteria = [];
|
|
1450
|
-
if (packageJson.scripts?.test) {
|
|
1451
|
-
criteria.push("WHEN tests are run THEN all tests SHALL pass");
|
|
1452
|
-
}
|
|
1453
|
-
if (packageJson.scripts?.build) {
|
|
1454
|
-
criteria.push("WHEN build is executed THEN system SHALL compile without errors");
|
|
1455
|
-
}
|
|
1456
|
-
if (packageJson.scripts?.lint) {
|
|
1457
|
-
criteria.push("WHERE code quality is checked THE system SHALL meet linting standards");
|
|
1458
|
-
}
|
|
1459
|
-
if (packageJson.main || packageJson.bin) {
|
|
1460
|
-
criteria.push("WHEN application starts THEN system SHALL initialize successfully");
|
|
1461
|
-
}
|
|
1462
|
-
criteria.push("IF errors occur THEN system SHALL handle them gracefully");
|
|
1463
|
-
return criteria.length > 0
|
|
1464
|
-
? criteria
|
|
1465
|
-
: ["System SHALL meet functional requirements"];
|
|
1466
|
-
}
|
|
1467
|
-
function generateTechRequirementsSimplified(packageJson) {
|
|
1468
|
-
const requirements = [];
|
|
1469
|
-
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
1470
|
-
if (deps?.typescript) {
|
|
1471
|
-
requirements.push("System SHALL use TypeScript for type safety");
|
|
1472
|
-
}
|
|
1473
|
-
if (deps?.express || deps?.fastify) {
|
|
1474
|
-
requirements.push("System SHALL implement RESTful API endpoints");
|
|
1475
|
-
}
|
|
1476
|
-
if (deps?.react || deps?.vue || deps?.angular) {
|
|
1477
|
-
requirements.push("System SHALL provide responsive user interface");
|
|
1478
|
-
}
|
|
1479
|
-
if (deps?.jest || deps?.mocha || deps?.vitest) {
|
|
1480
|
-
requirements.push("System SHALL include comprehensive test coverage");
|
|
1481
|
-
}
|
|
1482
|
-
return requirements.length > 0
|
|
1483
|
-
? requirements
|
|
1484
|
-
: ["System SHALL integrate required technologies"];
|
|
1485
|
-
}
|
|
1486
|
-
function generateQualityRequirementsSimplified(packageJson) {
|
|
1487
|
-
const requirements = [];
|
|
1488
|
-
if (packageJson.scripts?.lint) {
|
|
1489
|
-
requirements.push("Code SHALL pass linting checks");
|
|
1490
|
-
}
|
|
1491
|
-
if (packageJson.scripts?.typecheck) {
|
|
1492
|
-
requirements.push("Code SHALL pass type checking");
|
|
1493
|
-
}
|
|
1494
|
-
if (packageJson.scripts?.test) {
|
|
1495
|
-
requirements.push("Code SHALL maintain test coverage standards");
|
|
1496
|
-
}
|
|
1497
|
-
requirements.push("Code SHALL follow established conventions");
|
|
1498
|
-
return requirements;
|
|
1499
|
-
}
|
|
1500
|
-
function generateArchitectureDescriptionSimplified(packageJson, projectAnalysis) {
|
|
1501
|
-
let description = "";
|
|
1502
|
-
if (packageJson.type === "module") {
|
|
1503
|
-
description += "Modern ES Module-based architecture. ";
|
|
1504
|
-
}
|
|
1505
|
-
if (projectAnalysis.hasSource) {
|
|
1506
|
-
description +=
|
|
1507
|
-
"Modular source code organization with clear separation of concerns. ";
|
|
1508
|
-
}
|
|
1509
|
-
if (packageJson.dependencies?.express) {
|
|
1510
|
-
description +=
|
|
1511
|
-
"RESTful API server architecture using Express.js framework. ";
|
|
1512
|
-
}
|
|
1513
|
-
if (packageJson.dependencies?.typescript ||
|
|
1514
|
-
packageJson.devDependencies?.typescript) {
|
|
1515
|
-
description += "Type-safe development with TypeScript compilation. ";
|
|
1516
|
-
}
|
|
1517
|
-
return (description ||
|
|
1518
|
-
"Application architecture to be defined based on requirements.");
|
|
1519
|
-
}
|
|
1520
|
-
function generateComponentDescriptionsSimplified(projectAnalysis) {
|
|
1521
|
-
const components = [];
|
|
1522
|
-
if (projectAnalysis.hasSource) {
|
|
1523
|
-
components.push({
|
|
1524
|
-
name: "Core Module",
|
|
1525
|
-
description: "Main application logic and business rules",
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
if (projectAnalysis.hasTests) {
|
|
1529
|
-
components.push({
|
|
1530
|
-
name: "Test Suite",
|
|
1531
|
-
description: "Automated testing framework and test cases",
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
if (projectAnalysis.hasDocs) {
|
|
1535
|
-
components.push({
|
|
1536
|
-
name: "Documentation",
|
|
1537
|
-
description: "Project documentation and API specifications",
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
return components.length > 0
|
|
1541
|
-
? components
|
|
1542
|
-
: [
|
|
1543
|
-
{
|
|
1544
|
-
name: "Application Core",
|
|
1545
|
-
description: "Main application functionality",
|
|
1546
|
-
},
|
|
1547
|
-
];
|
|
1548
|
-
}
|
|
1549
|
-
function generateDataModelsSimplified(packageJson, projectAnalysis) {
|
|
1550
|
-
const models = [];
|
|
1551
|
-
if (packageJson.dependencies?.mongoose || packageJson.dependencies?.mongodb) {
|
|
1552
|
-
models.push("MongoDB Document Models");
|
|
1553
|
-
}
|
|
1554
|
-
if (packageJson.dependencies?.sequelize ||
|
|
1555
|
-
packageJson.dependencies?.typeorm) {
|
|
1556
|
-
models.push("Relational Database Models");
|
|
1557
|
-
}
|
|
1558
|
-
if (packageJson.dependencies?.graphql) {
|
|
1559
|
-
models.push("GraphQL Schema Models");
|
|
1560
|
-
}
|
|
1561
|
-
return models.length > 0 ? models : ["Application Data Models"];
|
|
1562
|
-
}
|
|
1563
|
-
function generateDetailedTechStackSimplified(packageJson) {
|
|
1564
|
-
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
1565
|
-
const stack = [];
|
|
1566
|
-
if (deps?.typescript)
|
|
1567
|
-
stack.push("- **TypeScript**: Type-safe JavaScript development");
|
|
1568
|
-
if (deps?.node || packageJson.engines?.node)
|
|
1569
|
-
stack.push(`- **Node.js**: ${packageJson.engines?.node || "Runtime environment"}`);
|
|
1570
|
-
if (deps?.express)
|
|
1571
|
-
stack.push("- **Express.js**: Web application framework");
|
|
1572
|
-
if (deps?.react)
|
|
1573
|
-
stack.push("- **React**: User interface library");
|
|
1574
|
-
if (deps?.vue)
|
|
1575
|
-
stack.push("- **Vue.js**: Progressive frontend framework");
|
|
1576
|
-
if (deps?.jest)
|
|
1577
|
-
stack.push("- **Jest**: Testing framework");
|
|
1578
|
-
return stack.length > 0
|
|
1579
|
-
? stack.join("\n")
|
|
1580
|
-
: "- Technology stack to be defined";
|
|
1581
|
-
}
|
|
1582
|
-
function generateDesignPatternsSimplified(packageJson, projectAnalysis) {
|
|
1583
|
-
const patterns = [];
|
|
1584
|
-
if (packageJson.dependencies?.inversify) {
|
|
1585
|
-
patterns.push("Dependency Injection");
|
|
1586
|
-
}
|
|
1587
|
-
if (projectAnalysis.hasSource) {
|
|
1588
|
-
patterns.push("Modular Architecture");
|
|
1589
|
-
}
|
|
1590
|
-
if (packageJson.dependencies?.express || packageJson.dependencies?.fastify) {
|
|
1591
|
-
patterns.push("MVC Pattern");
|
|
1592
|
-
}
|
|
1593
|
-
return patterns.length > 0 ? patterns : ["Standard Design Patterns"];
|
|
1594
|
-
}
|
|
1595
|
-
function generateDependencyAnalysisSimplified(packageJson) {
|
|
1596
|
-
const production = Object.keys(packageJson.dependencies || {});
|
|
1597
|
-
const development = Object.keys(packageJson.devDependencies || {});
|
|
1598
|
-
let analysis = "";
|
|
1599
|
-
if (production.length > 0) {
|
|
1600
|
-
analysis += `**Production Dependencies:** ${production.length} packages\n`;
|
|
1601
|
-
analysis += production
|
|
1602
|
-
.slice(0, 5)
|
|
1603
|
-
.map((dep) => `- ${dep}`)
|
|
1604
|
-
.join("\n");
|
|
1605
|
-
if (production.length > 5)
|
|
1606
|
-
analysis += `\n- ... and ${production.length - 5} more`;
|
|
1607
|
-
}
|
|
1608
|
-
if (development.length > 0) {
|
|
1609
|
-
analysis += `\n\n**Development Dependencies:** ${development.length} packages\n`;
|
|
1610
|
-
analysis += development
|
|
1611
|
-
.slice(0, 5)
|
|
1612
|
-
.map((dep) => `- ${dep}`)
|
|
1613
|
-
.join("\n");
|
|
1614
|
-
if (development.length > 5)
|
|
1615
|
-
analysis += `\n- ... and ${development.length - 5} more`;
|
|
1616
|
-
}
|
|
1617
|
-
return analysis || "Dependencies to be analyzed";
|
|
1618
|
-
}
|
|
1619
|
-
function generateAPIInterfacesSimplified(packageJson, projectAnalysis) {
|
|
1620
|
-
if (packageJson.dependencies?.express || packageJson.dependencies?.fastify) {
|
|
1621
|
-
return `RESTful API endpoints following OpenAPI specification:
|
|
1622
|
-
- GET /api/health - Health check endpoint
|
|
1623
|
-
- Authentication and authorization middleware
|
|
1624
|
-
- Request/response validation
|
|
1625
|
-
- Error handling middleware`;
|
|
1626
|
-
}
|
|
1627
|
-
return "Interface specifications to be defined";
|
|
1628
|
-
}
|
|
1629
|
-
function generateModuleInterfacesSimplified(projectAnalysis) {
|
|
1630
|
-
if (projectAnalysis.hasSource) {
|
|
1631
|
-
return `Internal module interfaces:
|
|
1632
|
-
- Clear module boundaries and exports
|
|
1633
|
-
- Consistent API patterns across modules
|
|
1634
|
-
- Type definitions for all public interfaces`;
|
|
1635
|
-
}
|
|
1636
|
-
return "Module interfaces to be defined";
|
|
1637
|
-
}
|
|
1638
|
-
function generateEnvVarSpecsSimplified(packageJson) {
|
|
1639
|
-
const envVars = [];
|
|
1640
|
-
if (packageJson.dependencies?.express || packageJson.dependencies?.fastify) {
|
|
1641
|
-
envVars.push("- `PORT`: Server port (default: 3000)");
|
|
1642
|
-
envVars.push("- `NODE_ENV`: Environment mode (development/production)");
|
|
1643
|
-
}
|
|
1644
|
-
envVars.push("- `LOG_LEVEL`: Logging level (debug/info/warn/error)");
|
|
1645
|
-
return envVars.join("\n");
|
|
1646
|
-
}
|
|
1647
|
-
function generateBuildConfigSimplified(packageJson) {
|
|
1648
|
-
let config = "";
|
|
1649
|
-
if (packageJson.scripts?.build) {
|
|
1650
|
-
config += `Build process: \`${packageJson.scripts.build}\`\n`;
|
|
1651
|
-
}
|
|
1652
|
-
if (packageJson.scripts?.start) {
|
|
1653
|
-
config += `Start command: \`${packageJson.scripts.start}\`\n`;
|
|
1654
|
-
}
|
|
1655
|
-
if (packageJson.type === "module") {
|
|
1656
|
-
config += "Module type: ES Modules\n";
|
|
1657
|
-
}
|
|
1658
|
-
return config || "Build configuration to be defined";
|
|
1659
|
-
}
|
|
1660
|
-
function generateImplementationTasksSimplified(packageJson, projectAnalysis) {
|
|
1661
|
-
const tasks = {
|
|
1662
|
-
development: [],
|
|
1663
|
-
integration: [],
|
|
1664
|
-
quality: [],
|
|
1665
|
-
deployment: [],
|
|
1666
|
-
};
|
|
1667
|
-
// Development tasks
|
|
1668
|
-
if (projectAnalysis.hasSource) {
|
|
1669
|
-
tasks.development.push({
|
|
1670
|
-
title: "Implement Core Modules",
|
|
1671
|
-
subtasks: [
|
|
1672
|
-
"Set up module structure",
|
|
1673
|
-
"Implement business logic",
|
|
1674
|
-
"Add error handling",
|
|
1675
|
-
],
|
|
1676
|
-
requirements: "FR-1, FR-2",
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
if (packageJson.dependencies?.express) {
|
|
1680
|
-
tasks.development.push({
|
|
1681
|
-
title: "Develop API Endpoints",
|
|
1682
|
-
subtasks: [
|
|
1683
|
-
"Create route handlers",
|
|
1684
|
-
"Add middleware",
|
|
1685
|
-
"Implement validation",
|
|
1686
|
-
],
|
|
1687
|
-
requirements: "FR-2",
|
|
1688
|
-
});
|
|
1689
|
-
}
|
|
1690
|
-
// Integration tasks
|
|
1691
|
-
if (packageJson.dependencies?.mongodb || packageJson.dependencies?.mongoose) {
|
|
1692
|
-
tasks.integration.push({
|
|
1693
|
-
title: "Database Integration",
|
|
1694
|
-
subtasks: [
|
|
1695
|
-
"Set up database connection",
|
|
1696
|
-
"Create data models",
|
|
1697
|
-
"Implement queries",
|
|
1698
|
-
],
|
|
1699
|
-
requirements: "NFR-2",
|
|
1700
|
-
});
|
|
1701
|
-
}
|
|
1702
|
-
// Quality tasks
|
|
1703
|
-
if (packageJson.scripts?.test) {
|
|
1704
|
-
tasks.quality.push({
|
|
1705
|
-
title: "Test Implementation",
|
|
1706
|
-
subtasks: [
|
|
1707
|
-
"Write unit tests",
|
|
1708
|
-
"Add integration tests",
|
|
1709
|
-
"Ensure test coverage",
|
|
1710
|
-
],
|
|
1711
|
-
requirements: "FR-3, NFR-3",
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
if (packageJson.scripts?.lint) {
|
|
1715
|
-
tasks.quality.push({
|
|
1716
|
-
title: "Code Quality Assurance",
|
|
1717
|
-
subtasks: [
|
|
1718
|
-
"Run linting checks",
|
|
1719
|
-
"Fix code style issues",
|
|
1720
|
-
"Add documentation",
|
|
1721
|
-
],
|
|
1722
|
-
requirements: "NFR-3",
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1725
|
-
// Deployment tasks
|
|
1726
|
-
if (packageJson.scripts?.build) {
|
|
1727
|
-
tasks.deployment.push({
|
|
1728
|
-
title: "Build and Package",
|
|
1729
|
-
subtasks: [
|
|
1730
|
-
"Run build process",
|
|
1731
|
-
"Optimize for production",
|
|
1732
|
-
"Create deployment artifacts",
|
|
1733
|
-
],
|
|
1734
|
-
requirements: "NFR-1",
|
|
1735
|
-
});
|
|
1736
|
-
}
|
|
1737
|
-
tasks.deployment.push({
|
|
1738
|
-
title: "Deployment Configuration",
|
|
1739
|
-
subtasks: [
|
|
1740
|
-
"Set up environment variables",
|
|
1741
|
-
"Configure production settings",
|
|
1742
|
-
"Deploy to target environment",
|
|
1743
|
-
],
|
|
1744
|
-
requirements: "NFR-1, NFR-2",
|
|
1745
|
-
});
|
|
1746
|
-
return tasks;
|
|
1747
|
-
}
|
|
1748
|
-
// Helper functions for requirement generation from description
|
|
1749
|
-
function generateIntroductionFromDescription(description) {
|
|
1750
|
-
const systemName = extractSystemName(description);
|
|
1751
|
-
return `This document specifies the requirements for ${systemName}. The system aims to ${description.toLowerCase()}.`;
|
|
1752
|
-
}
|
|
1753
|
-
function extractSystemName(description) {
|
|
1754
|
-
// Extract a system name from description
|
|
1755
|
-
const words = description.split(" ");
|
|
1756
|
-
if (words.length >= 2) {
|
|
1757
|
-
return `the ${words.slice(0, 3).join(" ")}`;
|
|
1758
|
-
}
|
|
1759
|
-
return "the system";
|
|
1760
|
-
}
|
|
1761
|
-
function extractPrimaryObjective(description) {
|
|
1762
|
-
// Convert description into user objective
|
|
1763
|
-
if (description.toLowerCase().includes("tool") ||
|
|
1764
|
-
description.toLowerCase().includes("cli")) {
|
|
1765
|
-
return `use a tool that ${description.toLowerCase()}`;
|
|
1766
|
-
}
|
|
1767
|
-
if (description.toLowerCase().includes("system") ||
|
|
1768
|
-
description.toLowerCase().includes("application")) {
|
|
1769
|
-
return `access a system that ${description.toLowerCase()}`;
|
|
1770
|
-
}
|
|
1771
|
-
return `have functionality that ${description.toLowerCase()}`;
|
|
1772
|
-
}
|
|
1773
|
-
function extractPrimaryBenefit(description) {
|
|
1774
|
-
// Infer benefit from description
|
|
1775
|
-
if (description.toLowerCase().includes("automate")) {
|
|
1776
|
-
return "I can save time and reduce manual effort";
|
|
1777
|
-
}
|
|
1778
|
-
if (description.toLowerCase().includes("analyze") ||
|
|
1779
|
-
description.toLowerCase().includes("review")) {
|
|
1780
|
-
return "I can make better informed decisions";
|
|
1781
|
-
}
|
|
1782
|
-
if (description.toLowerCase().includes("manage") ||
|
|
1783
|
-
description.toLowerCase().includes("organize")) {
|
|
1784
|
-
return "I can maintain better control and organization";
|
|
1785
|
-
}
|
|
1786
|
-
return "I can accomplish my goals more effectively";
|
|
1787
|
-
}
|
|
1788
|
-
function generateEARSRequirements(description) {
|
|
1789
|
-
const requirements = [];
|
|
1790
|
-
// Core functional requirement
|
|
1791
|
-
requirements.push(`WHEN I use the system THEN it SHALL provide ${description.toLowerCase()} functionality`);
|
|
1792
|
-
// Input/output handling
|
|
1793
|
-
requirements.push("WHEN I provide input THEN the system SHALL validate and process it correctly");
|
|
1794
|
-
// Error handling
|
|
1795
|
-
requirements.push("IF invalid input is provided THEN the system SHALL reject it with clear error messages");
|
|
1796
|
-
// Success condition
|
|
1797
|
-
requirements.push("WHEN all inputs are valid THEN the system SHALL complete the requested operation successfully");
|
|
1798
|
-
return requirements;
|
|
1799
|
-
}
|
|
1800
|
-
// Helper functions for kiro-style workflow
|
|
1801
561
|
function generateFeatureName(description) {
|
|
1802
562
|
// Extract feature name from description - similar to kiro spec-init
|
|
1803
563
|
const cleaned = description
|