UNPKG

@pimzino/claude-code-spec-workflow

Version:

Automated workflows for Claude Code. Includes spec-driven development (Requirements → Design → Tasks → Implementation) with intelligent task execution, optional steering documents and streamlined bug fix workflow (Report → Analyze → Fix → Verify). We have

134 lines 5.78 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTemplateContext = getTemplateContext; const path = __importStar(require("path")); const chalk_1 = __importDefault(require("chalk")); const file_cache_1 = require("./file-cache"); async function getTemplateContext(templateType, projectPath) { try { // Use provided project path or current working directory const workingDir = projectPath || process.cwd(); // Path to templates directory const templatesDir = path.join(workingDir, '.claude', 'templates'); // Check if templates directory exists if (!(0, file_cache_1.cachedFileExists)(templatesDir)) { console.log('## Template Context\n\nNo templates directory found.'); return; } // Define template categories const templateCategories = { 'spec': [ { name: 'requirements-template.md', title: 'Requirements Template' }, { name: 'design-template.md', title: 'Design Template' }, { name: 'tasks-template.md', title: 'Tasks Template' } ], 'steering': [ { name: 'product-template.md', title: 'Product Template' }, { name: 'tech-template.md', title: 'Technology Template' }, { name: 'structure-template.md', title: 'Structure Template' } ], 'bug': [ { name: 'bug-report-template.md', title: 'Bug Report Template' }, { name: 'bug-analysis-template.md', title: 'Bug Analysis Template' }, { name: 'bug-verification-template.md', title: 'Bug Verification Template' } ], 'all': [] // Will be populated with all templates }; // Populate 'all' category with all templates templateCategories.all = [ ...templateCategories.spec, ...templateCategories.steering, ...templateCategories.bug ]; // Determine which templates to load const templatesToLoad = templateType && templateCategories[templateType] ? templateCategories[templateType] : templateCategories.all; const sections = []; let hasContent = false; for (const template of templatesToLoad) { const filePath = path.join(templatesDir, template.name); if ((0, file_cache_1.cachedFileExists)(filePath)) { const content = (0, file_cache_1.getCachedFileContent)(filePath); if (content && content.trim()) { sections.push(`### ${template.title}\n${content.trim()}`); hasContent = true; } } } if (!hasContent) { const typeText = templateType ? ` for type: ${templateType}` : ''; console.log(`## Template Context\n\nNo templates found${typeText}.`); return; } // Output formatted template context const typeText = templateType ? ` (${templateType})` : ''; console.log(`## Template Context (Pre-loaded)${typeText}`); console.log('\n' + sections.join('\n\n---\n\n')); console.log('\n**Note**: Templates have been pre-loaded. Do not use get-content to fetch them again.'); } catch (error) { console.error(chalk_1.default.red('Error loading template context:'), error instanceof Error ? error.message : error); process.exit(1); } } // If this file is run directly (not imported) if (require.main === module) { const args = process.argv.slice(2); // Parse arguments: [template-type] [project-path] let templateType; let projectPath; if (args.length === 1) { // Could be either template type or project path // If it looks like a path (contains / or \), treat as project path if (args[0].includes('/') || args[0].includes('\\')) { projectPath = args[0]; } else { templateType = args[0]; } } else if (args.length >= 2) { templateType = args[0]; projectPath = args[1]; } getTemplateContext(templateType, projectPath); } //# sourceMappingURL=get-template-context.js.map