Skip to main content
Glama
file-structure.mdβ€’14.5 kB
# File Structure & Organization > **Quick Reference**: [Directory Layout](#-directory-layout) | [File Naming](#-file-naming) | [Path Utilities](#-path-utilities) ## πŸ“ Directory Layout ### Project Root Structure ``` project-root/ β”œβ”€β”€ .spec-workflow/ # All MCP workflow data β”‚ β”œβ”€β”€ specs/ # Specification documents β”‚ β”‚ └── feature-name/ # Individual specification β”‚ β”‚ β”œβ”€β”€ requirements.md # Phase 1: Requirements β”‚ β”‚ β”œβ”€β”€ design.md # Phase 2: Design β”‚ β”‚ └── tasks.md # Phase 3: Tasks β”‚ β”œβ”€β”€ steering/ # Project guidance documents β”‚ β”‚ β”œβ”€β”€ product.md # Product vision & strategy β”‚ β”‚ β”œβ”€β”€ tech.md # Technical standards β”‚ β”‚ └── structure.md # Code organization β”‚ β”œβ”€β”€ approvals/ # Approval workflow data β”‚ β”‚ └── spec-name/ # Per-spec approvals β”‚ β”‚ └── approval-id.json # Individual approval data β”‚ β”œβ”€β”€ archive/ # Completed/archived specs β”‚ β”‚ └── specs/ # Archived specification docs β”‚ └── config.toml (optional) # Project-specific configuration β”œβ”€β”€ [your existing project files] # Your actual project β”œβ”€β”€ package.json # Your project dependencies └── README.md # Your project documentation ``` ### MCP Server Source Structure **Core Implementation Files** (locations confirmed from codebase analysis): | File Path | Purpose | Key Features | |-----------|---------|--------------| | `src/server.ts:74-85` | MCP server initialization | Tool registration, project registry | | `src/core/path-utils.ts:12-35` | Cross-platform paths | Windows/Unix path handling | | `src/core/project-registry.ts:96-114` | Project registration | Global project tracking | | `src/dashboard/approval-storage.ts:20-45` | Human approval system | JSON file persistence | | `src/dashboard/multi-server.ts:45-200` | Multi-project dashboard | WebSocket, file watching | **Template System** (static content, no AI generation): ``` src/ β”œβ”€β”€ core/ # Core business logic β”‚ β”œβ”€β”€ archive-service.ts # Spec archiving functionality β”‚ β”œβ”€β”€ parser.ts # Spec parsing & analysis β”‚ β”œβ”€β”€ path-utils.ts # Cross-platform path handling β”‚ β”œβ”€β”€ project-registry.ts # Global project tracking β”‚ └── task-parser.ts # Task management & parsing β”œβ”€β”€ tools/ # MCP tool implementations β”‚ β”œβ”€β”€ index.ts # Tool registry & dispatcher β”‚ β”œβ”€β”€ spec-workflow-guide.ts # Workflow instructions β”‚ β”œβ”€β”€ steering-guide.ts # Steering doc instructions β”‚ β”œβ”€β”€ create-spec-doc.ts # Spec document creation β”‚ β”œβ”€β”€ create-steering-doc.ts # Steering doc creation β”‚ β”œβ”€β”€ get-spec-context.ts # Load spec context β”‚ β”œβ”€β”€ get-steering-context.ts # Load steering context β”‚ β”œβ”€β”€ get-template-context.ts # Load templates β”‚ β”œβ”€β”€ spec-list.ts # List all specifications β”‚ β”œβ”€β”€ spec-status.ts # Get spec status β”‚ β”œβ”€β”€ manage-tasks.ts # Task management β”‚ β”œβ”€β”€ request-approval.ts # Create approval requests β”‚ β”œβ”€β”€ get-approval-status.ts # Check approval status β”‚ └── delete-approval.ts # Clean up approvals β”œβ”€β”€ dashboard/ # Dashboard backend β”‚ β”œβ”€β”€ multi-server.ts # Multi-project Fastify server β”‚ β”œβ”€β”€ project-manager.ts # Project lifecycle management β”‚ β”œβ”€β”€ approval-storage.ts # Approval persistence β”‚ β”œβ”€β”€ parser.ts # Dashboard-specific parsing β”‚ β”œβ”€β”€ watcher.ts # File system watching β”‚ β”œβ”€β”€ utils.ts # Dashboard utilities β”‚ └── public/ # Static assets β”‚ β”œβ”€β”€ claude-icon.svg # Light mode icon β”‚ └── claude-icon-dark.svg # Dark mode icon β”œβ”€β”€ dashboard_frontend/ # React dashboard frontend β”‚ β”œβ”€β”€ src/ β”‚ β”‚ β”œβ”€β”€ modules/ β”‚ β”‚ β”‚ β”œβ”€β”€ api/ # API communication layer β”‚ β”‚ β”‚ β”œβ”€β”€ app/ # Main application component β”‚ β”‚ β”‚ β”œβ”€β”€ approvals/ # Approval UI components β”‚ β”‚ β”‚ β”œβ”€β”€ editor/ # Markdown editor β”‚ β”‚ β”‚ β”œβ”€β”€ markdown/ # Markdown rendering β”‚ β”‚ β”‚ β”œβ”€β”€ modals/ # Modal dialog components β”‚ β”‚ β”‚ β”œβ”€β”€ notifications/ # Toast notifications β”‚ β”‚ β”‚ β”œβ”€β”€ pages/ # Main page components β”‚ β”‚ β”‚ β”œβ”€β”€ theme/ # Styling & themes β”‚ β”‚ β”‚ └── ws/ # WebSocket integration β”‚ β”‚ β”œβ”€β”€ main.tsx # React application entry β”‚ β”‚ └── App.tsx # Root application component β”‚ β”œβ”€β”€ index.html # HTML template β”‚ β”œβ”€β”€ vite.config.ts # Vite build configuration β”‚ └── tailwind.config.js # Tailwind CSS config β”œβ”€β”€ markdown/ # Document templates β”‚ └── templates/ β”‚ β”œβ”€β”€ requirements-template.md # Requirements document template β”‚ β”œβ”€β”€ design-template.md # Design document template β”‚ β”œβ”€β”€ tasks-template.md # Tasks document template β”‚ β”œβ”€β”€ product-template.md # Product vision template β”‚ β”œβ”€β”€ tech-template.md # Technical standards template β”‚ └── structure-template.md # Code structure template β”œβ”€β”€ server.ts # Main MCP server class β”œβ”€β”€ index.ts # CLI entry point & argument parsing └── types.ts # TypeScript type definitions ``` ### VS Code Extension Structure ``` vscode-extension/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ extension.ts # Extension entry point β”‚ β”œβ”€β”€ extension/ β”‚ β”‚ β”œβ”€β”€ providers/ # VS Code providers β”‚ β”‚ β”‚ └── SidebarProvider.ts # Sidebar webview provider β”‚ β”‚ β”œβ”€β”€ services/ # Business logic services β”‚ β”‚ β”‚ β”œβ”€β”€ ApprovalCommandService.ts # Approval commands β”‚ β”‚ β”‚ β”œβ”€β”€ ApprovalEditorService.ts # Approval editor integration β”‚ β”‚ β”‚ β”œβ”€β”€ ArchiveService.ts # Archive functionality β”‚ β”‚ β”‚ β”œβ”€β”€ CommentModalService.ts # Comment modal handling β”‚ β”‚ β”‚ β”œβ”€β”€ FileWatcher.ts # File system watching β”‚ β”‚ β”‚ └── SpecWorkflowService.ts # Main workflow service β”‚ β”‚ β”œβ”€β”€ types.ts # Extension type definitions β”‚ β”‚ └── utils/ # Utility functions β”‚ β”‚ β”œβ”€β”€ colorUtils.ts # Color manipulation β”‚ β”‚ β”œβ”€β”€ logger.ts # Logging functionality β”‚ β”‚ └── taskParser.ts # Task parsing for extension β”‚ └── webview/ # Webview components (React) β”‚ β”œβ”€β”€ App.tsx # Main webview application β”‚ β”œβ”€β”€ components/ # Reusable UI components β”‚ β”œβ”€β”€ hooks/ # React hooks β”‚ β”œβ”€β”€ lib/ # Utility libraries β”‚ └── main.tsx # Webview entry point β”œβ”€β”€ webview-assets/ # Static webview assets β”‚ └── sounds/ # Audio notification files β”‚ β”œβ”€β”€ approval-pending.wav # Approval request sound β”‚ └── task-completed.wav # Task completion sound β”œβ”€β”€ icons/ # Extension icons β”‚ β”œβ”€β”€ activity-bar-icon.svg # Activity bar icon β”‚ └── spec-workflow.svg # General extension icon β”œβ”€β”€ package.json # Extension manifest & dependencies └── README.md # Extension documentation ``` ## πŸ“‹ File Naming Conventions ### Specification Names - **Format**: `kebab-case` (lowercase with hyphens) - **Examples**: βœ… `user-authentication`, `payment-flow`, `admin-dashboard` - **Invalid**: ❌ `UserAuth`, `payment_flow`, `Admin Dashboard` ### Document Files - **Requirements**: `requirements.md` - **Design**: `design.md` - **Tasks**: `tasks.md` - **Product**: `product.md` - **Tech**: `tech.md` - **Structure**: `structure.md` ### Approval Files - **Format**: `{spec-name}-{document}-{timestamp}.json` - **Example**: `user-auth-requirements-20241215-143022.json` - **Auto-generated**: System creates these automatically ## πŸ› οΈ Path Utilities ### Cross-Platform Path Handling The system uses `PathUtils` class for consistent path handling across Windows, macOS, and Linux: ```typescript export class PathUtils { // Get workflow root directory static getWorkflowRoot(projectPath: string): string { return normalize(join(projectPath, '.spec-workflow')); } // Get spec directory path static getSpecPath(projectPath: string, specName: string): string { return normalize(join(projectPath, '.spec-workflow', 'specs', specName)); } // Get steering documents path static getSteeringPath(projectPath: string): string { return normalize(join(projectPath, '.spec-workflow', 'steering')); } // Convert to platform-specific path static toPlatformPath(path: string): string { return path.split('/').join(sep); } // Convert to Unix-style path (for JSON/API) static toUnixPath(path: string): string { return path.split(sep).join('/'); } } ``` ### Common Path Operations ```typescript // Examples of PathUtils usage // Get spec path const specPath = PathUtils.getSpecPath('/project', 'user-auth'); // Result: /project/.spec-workflow/specs/user-auth // Get requirements file path const reqPath = join(specPath, 'requirements.md'); // Result: /project/.spec-workflow/specs/user-auth/requirements.md // Get relative path for API responses const relativePath = PathUtils.toUnixPath(reqPath.replace(projectPath, '')); // Result: .spec-workflow/specs/user-auth/requirements.md ``` ## πŸ“‚ Directory Creation & Management ### Auto-Created Directories The system automatically creates these directories as needed: ```typescript // Directories created during initialization const directories = [ '.spec-workflow/', '.spec-workflow/specs/', '.spec-workflow/steering/', '.spec-workflow/archive/', '.spec-workflow/archive/specs/' ]; // Directories created on-demand const onDemandDirectories = [ '.spec-workflow/approvals/', '.spec-workflow/approvals/{spec-name}/', '.spec-workflow/specs/{spec-name}/' ]; ``` ### Directory Validation ```typescript export async function validateProjectPath(projectPath: string): Promise<string> { // Resolve to absolute path const absolutePath = resolve(projectPath); // Check if path exists await access(absolutePath, constants.F_OK); // Ensure it's a directory const stats = await stat(absolutePath); if (!stats.isDirectory()) { throw new Error(`Project path is not a directory: ${absolutePath}`); } return absolutePath; } ``` ### Cleanup & Maintenance ```typescript // Archive completed specifications export class SpecArchiveService { async archiveSpec(specName: string): Promise<void> { const sourceDir = PathUtils.getSpecPath(this.projectPath, specName); const archiveDir = PathUtils.getArchiveSpecPath(this.projectPath, specName); // Move spec to archive await fs.rename(sourceDir, archiveDir); // Clean up approvals const approvalsDir = PathUtils.getSpecApprovalPath(this.projectPath, specName); await fs.rm(approvalsDir, { recursive: true, force: true }); } } ``` ## πŸ”’ File Permissions & Security ### Required Permissions ```bash # Minimum required permissions .spec-workflow/ # 755 (rwxr-xr-x) β”œβ”€β”€ specs/ # 755 (rwxr-xr-x) β”œβ”€β”€ steering/ # 755 (rwxr-xr-x) β”œβ”€β”€ approvals/ # 755 (rwxr-xr-x) └── archive/ # 755 (rwxr-xr-x) ``` ### Security Considerations **File Access Restrictions**: - βœ… Read/Write: Only within `.spec-workflow/` directory - βœ… Read-Only: Project files (for analysis) - ❌ Forbidden: System directories, parent directory traversal **Path Traversal Prevention**: ```typescript // All paths are normalized and validated const safePath = normalize(join(projectPath, '.spec-workflow', userInput)); // Ensure path stays within project if (!safePath.startsWith(projectPath)) { throw new Error('Path traversal attempt detected'); } ``` ## πŸ“Š Storage Considerations ### File Size Limits | File Type | Typical Size | Max Recommended | |-----------|-------------|-----------------| | Requirements | 5-20 KB | 100 KB | | Design | 10-50 KB | 200 KB | | Tasks | 5-30 KB | 150 KB | | Steering Docs | 5-20 KB | 100 KB | | Approval Data | < 1 KB | 5 KB | | Session Data | < 1 KB | 2 KB | ### Disk Usage Estimation ```typescript // Typical project disk usage interface DiskUsage { singleSpec: '50-200 KB'; // All 3 documents steeringDocs: '20-100 KB'; // All steering documents approvalData: '1-10 KB'; // Per approval workflow sessionData: '< 1 KB'; // Session tracking totalTypical: '100-500 KB'; // For small-medium project totalLarge: '1-5 MB'; // For large project with many specs } ``` ### Cleanup Strategies ```bash # Manual cleanup commands # Remove completed approvals (older than 30 days) find .spec-workflow/approvals -name "*.json" -mtime +30 -delete # Archive old specifications # (Move specs with all tasks completed to archive/) # Full reset (nuclear option) rm -rf .spec-workflow/ ``` --- **Next**: [Dashboard System β†’](dashboard.md)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Pimzino/spec-workflow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server