/** * GitHub Feature Sync - Universal Hierarchy Implementation * * Architecture: * - Feature (FS-XXX) → GitHub Milestone (Container) * - User Story (US-XXX) → GitHub Issue with format [FS-XXX][US-YYY] Title * - Tasks (T-XXX) → Checkboxes in User Story issue body * * This implements the Universal Hierarchy architecture for GitHub sync. * Creates ONE issue PER user story file from specs/{project}/FS-XXX/us-*.md */ import { GitHubClientV2 } from './github-client-v2.js'; export declare class GitHubFeatureSync { private client; private specsDir; private projectRoot; private calculator; private token?; private defaultBranch; constructor(client: GitHubClientV2, specsDir: string, projectRoot: string); /** * Detect the default branch from the GitHub API. * Caches the result per sync session to avoid repeated API calls. * Falls back to 'main' if API call fails. */ private detectDefaultBranch; /** * Get environment object with GH_TOKEN for gh CLI commands. * This ensures the token from .env is passed to all gh operations, * regardless of `gh auth` status. */ private getGhEnv; /** * Get the repo slug (owner/repo) for `-R` flag in gh CLI commands. * CRITICAL: All gh issue commands MUST use `-R` to target the correct repo, * not the repo inferred from the current working directory. */ private getRepoSlug; /** * Sync Feature folder to GitHub (Milestone + User Story Issues) * * Process: * 1. Create/update GitHub Milestone for Feature * 2. Find all us-*.md files across all projects * 3. Create/update GitHub Issue for EACH user story * 4. Update frontmatter with GitHub issue links */ syncFeatureToGitHub(featureId: string, projectName?: string): Promise<{ milestoneNumber: number; milestoneUrl: string; issuesCreated: number; issuesUpdated: number; userStoriesProcessed: number; rateLimitSkipped?: boolean; }>; /** * Find Feature folder in specs directory. * Falls back to auto-creating from increment spec.md if living docs don't exist. */ private findFeatureFolder; /** * Find the increment folder for a given feature ID. * Converts FS-271 -> finds 0271-xxx-xxx/ in .specweave/increments/ */ private findIncrementFolder; /** * Auto-create a feature folder (FEATURE.md + us-NNN.md files) from an * increment's spec.md. This enables GitHub sync even when the living docs * builder hasn't run yet. */ private createFeatureFolderFromSpec; /** * Parse user stories from spec.md markdown content. */ private parseUserStoriesFromSpec; /** * Build FEATURE.md content matching the living docs format. */ private buildFeatureMd; /** * Build us-NNN.md content matching the living docs format. */ private buildUserStoryMd; /** * Convert a title to a URL-safe slug. */ private slugify; /** * Backfill increment metadata.json with GitHub issue reference (v1.0.240) * * Writes in BOTH formats: * - OLD format (metadata.github.issues[]) for backward compatibility * - NEW format (metadata.externalLinks.github) for reconciler/closure flows * Non-blocking — errors are logged but don't halt sync. */ private backfillIncrementMetadata; /** * Parse FEATURE.md frontmatter */ private parseFeatureMd; /** * Find all User Story files for this feature across all projects */ private findUserStories; /** * Find all project folders (default, backend, frontend, etc.) */ private findProjectFolders; /** * Create GitHub Milestone for Feature (with duplicate detection + session cache) */ private createMilestone; /** * Create GitHub Issue for User Story with AC/Task Verification * * ✅ VERIFICATION GATE FIX: * - Verifies actual completion before closing * - Prevents premature closure on creation */ private createUserStoryIssue; /** * Update existing GitHub Issue for User Story with AC/Task Verification * * ✅ VERIFICATION GATE FIX: * - OLD: Closed based on frontmatter `status: complete` * - NEW: Closes ONLY if all ACs and tasks are [x] * * This prevents Issue #574 type bugs (premature closure) */ private updateUserStoryIssue; /** * Update status labels on GitHub issue based on completion state * * SMART LABEL MANAGEMENT: * - Only manages status:* labels (status:not_started, status:in-progress, status:completed) * - Preserves all other labels (priority, type, custom labels) * - Ensures exactly one status label is present */ private updateStatusLabels; /** * Post progress comment only if it differs from the last comment * * DEDUPLICATION FIX (2025-11-24): * - Prevents posting identical consecutive comments * - Fetches last comment from issue * - Compares content (ignoring timestamps) * - Only posts if progress has changed * * Root Cause: updateUserStoryIssue() was posting progress comments on EVERY sync, * even when progress hadn't changed, causing 4+ duplicate comments. * * @param issueNumber - GitHub issue number * @param completion - Completion status with AC/task metrics */ private postProgressCommentIfChanged; /** * Update FEATURE.md with GitHub Milestone link */ private updateFeatureMd; /** * Update User Story frontmatter with GitHub issue link */ private updateUserStoryFrontmatter; } //# sourceMappingURL=github-feature-sync.d.ts.map