workflow-agent-cli 2.22.3 → 2.22.5
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/LICENSE +21 -0
- package/dist/{chunk-WR3AL26Z.js → chunk-IWFUJ2DS.js} +13 -2
- package/dist/chunk-IWFUJ2DS.js.map +1 -0
- package/dist/{chunk-G5L77VD5.js → chunk-YBRWXMVK.js} +5 -2
- package/dist/chunk-YBRWXMVK.js.map +1 -0
- package/dist/cli/index.js +128 -80
- package/dist/cli/index.js.map +1 -1
- package/dist/scripts/postinstall.js +1 -1
- package/dist/sync-TLICCJNH.js +7 -0
- package/package.json +30 -31
- package/dist/chunk-G5L77VD5.js.map +0 -1
- package/dist/chunk-WR3AL26Z.js.map +0 -1
- package/dist/sync-SOERVZT3.js +0 -7
- /package/dist/{sync-SOERVZT3.js.map → sync-TLICCJNH.js.map} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Workflow Agent Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -31,6 +31,17 @@ function extractDescription(content) {
|
|
|
31
31
|
}
|
|
32
32
|
return description.trim().slice(0, 200) + (description.length > 200 ? "..." : "");
|
|
33
33
|
}
|
|
34
|
+
function rewriteGuidelineLinks(text) {
|
|
35
|
+
return text.replace(
|
|
36
|
+
/\[([^\]]+)\]\(([A-Z_]+\.md)\)/g,
|
|
37
|
+
(match, linkText, filename) => {
|
|
38
|
+
if (!filename.includes("/")) {
|
|
39
|
+
return `[${linkText}](../guidelines/${filename})`;
|
|
40
|
+
}
|
|
41
|
+
return match;
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
34
45
|
function extractKeyRules(content, maxRules = 5) {
|
|
35
46
|
const rules = [];
|
|
36
47
|
const emphasisPatterns = [
|
|
@@ -198,7 +209,7 @@ ${guideline.description}
|
|
|
198
209
|
content += `**Key Rules:**
|
|
199
210
|
`;
|
|
200
211
|
for (const rule of guideline.keyRules) {
|
|
201
|
-
content += `- ${rule}
|
|
212
|
+
content += `- ${rewriteGuidelineLinks(rule)}
|
|
202
213
|
`;
|
|
203
214
|
}
|
|
204
215
|
content += "\n";
|
|
@@ -728,4 +739,4 @@ export {
|
|
|
728
739
|
installMandatoryTemplates,
|
|
729
740
|
updateTemplates
|
|
730
741
|
};
|
|
731
|
-
//# sourceMappingURL=chunk-
|
|
742
|
+
//# sourceMappingURL=chunk-IWFUJ2DS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scripts/copilot-instructions-generator.ts","../src/scripts/workflow-scripts.ts","../src/scripts/template-installer.ts","../src/templates/metadata.ts"],"sourcesContent":["/**\n * Copilot Instructions Generator\n *\n * Generates .github/copilot-instructions.md from the project's guidelines directory.\n * This file serves as the Single Source of Truth for AI agents (GitHub Copilot, Claude, etc.)\n * when working on the codebase.\n *\n * Features:\n * - Reads all markdown files from guidelines/\n * - Extracts key rules and summaries from each guideline\n * - Loads project config from workflow.config.json\n * - Preserves custom user content between markers\n * - Provides links to full guideline documents\n */\n\nimport { readFileSync, writeFileSync, existsSync, readdirSync, mkdirSync } from \"fs\";\nimport { join, basename } from \"path\";\n\n// Markers for custom user content that should be preserved on regeneration\nconst CUSTOM_START_MARKER = \"<!-- CUSTOM START -->\";\nconst CUSTOM_END_MARKER = \"<!-- CUSTOM END -->\";\nconst GENERATED_MARKER = \"<!-- AUTO-GENERATED BY WORKFLOW-AGENT - DO NOT EDIT ABOVE THIS LINE -->\";\n\ninterface WorkflowConfig {\n projectName?: string;\n scopes?: Array<{ name: string; description: string; emoji?: string }>;\n enforcement?: string;\n language?: string;\n}\n\ninterface GuidelineSummary {\n filename: string;\n title: string;\n description: string;\n keyRules: string[];\n}\n\n/**\n * Extract title from markdown content (first H1)\n */\nfunction extractTitle(content: string): string {\n const match = content.match(/^#\\s+(.+)$/m);\n return match ? match[1].trim() : \"Untitled\";\n}\n\n/**\n * Extract description from markdown content (first paragraph after title)\n */\nfunction extractDescription(content: string): string {\n // Look for content after the first heading, before the next heading or section\n const lines = content.split(\"\\n\");\n let foundTitle = false;\n let description = \"\";\n\n for (const line of lines) {\n if (line.startsWith(\"# \")) {\n foundTitle = true;\n continue;\n }\n if (foundTitle) {\n // Skip empty lines and blockquotes at start\n if (line.trim() === \"\" || line.startsWith(\">\")) {\n if (description) break; // End if we already have content\n continue;\n }\n // Stop at next heading or horizontal rule\n if (line.startsWith(\"#\") || line.startsWith(\"---\") || line.startsWith(\"##\")) {\n break;\n }\n description += line.trim() + \" \";\n // Take only first meaningful paragraph\n if (description.length > 150) break;\n }\n }\n\n return description.trim().slice(0, 200) + (description.length > 200 ? \"...\" : \"\");\n}\n\n/**\n * Rewrite markdown links to include ../guidelines/ prefix\n * Transforms links like [FILE.md](FILE.md) to [FILE.md](../guidelines/FILE.md)\n */\nfunction rewriteGuidelineLinks(text: string): string {\n // Match markdown links: [text](file.md) where file.md is a .md file without path\n return text.replace(\n /\\[([^\\]]+)\\]\\(([A-Z_]+\\.md)\\)/g,\n (match, linkText, filename) => {\n // Only rewrite if it's just the filename (no path)\n if (!filename.includes(\"/\")) {\n return `[${linkText}](../guidelines/${filename})`;\n }\n return match;\n }\n );\n}\n\n/**\n * Extract key rules from markdown content\n * Looks for lists, bold text, and important patterns\n */\nfunction extractKeyRules(content: string, maxRules: number = 5): string[] {\n const rules: string[] = [];\n\n // Pattern 1: Look for \"MUST\", \"NEVER\", \"ALWAYS\", \"REQUIRED\" in bold or emphasized\n const emphasisPatterns = [\n /\\*\\*(?:MUST|NEVER|ALWAYS|REQUIRED)[^*]+\\*\\*/gi,\n /(?:^|\\n)\\s*[-*]\\s+\\*\\*[^*]+\\*\\*/gm,\n ];\n\n for (const pattern of emphasisPatterns) {\n const matches = content.match(pattern);\n if (matches) {\n for (const match of matches.slice(0, 2)) {\n const cleaned = match.replace(/\\*\\*/g, \"\").replace(/^[-*]\\s*/, \"\").trim();\n if (cleaned.length > 10 && cleaned.length < 150 && !rules.includes(cleaned)) {\n rules.push(cleaned);\n }\n }\n }\n }\n\n // Pattern 2: Look for numbered or bulleted rules under headings containing \"Rules\", \"Requirements\", \"Guidelines\"\n const rulesSectionMatch = content.match(/##\\s+(?:.*(?:Rules?|Requirements?|Guidelines?|Standards?)[^\\n]*)\\n([\\s\\S]*?)(?=\\n##|\\n#|$)/i);\n if (rulesSectionMatch) {\n const section = rulesSectionMatch[1];\n const listItems = section.match(/^\\s*[-*\\d.]+\\s+(.+)$/gm);\n if (listItems) {\n for (const item of listItems.slice(0, 3)) {\n const cleaned = item.replace(/^[-*\\d.]+\\s*/, \"\").trim();\n if (cleaned.length > 10 && cleaned.length < 150 && !rules.includes(cleaned)) {\n rules.push(cleaned);\n }\n }\n }\n }\n\n // Pattern 3: Look for key points under \"Important\", \"Critical\", \"Key\"\n const importantMatch = content.match(/(?:Important|Critical|Key|Essential)[:\\s]+([^\\n]+)/gi);\n if (importantMatch) {\n for (const match of importantMatch.slice(0, 2)) {\n const cleaned = match.replace(/^(?:Important|Critical|Key|Essential)[:\\s]+/i, \"\").trim();\n if (cleaned.length > 10 && cleaned.length < 150 && !rules.includes(cleaned)) {\n rules.push(cleaned);\n }\n }\n }\n\n // Fallback: Get first few list items if we don't have enough rules\n if (rules.length < 2) {\n const listItems = content.match(/^\\s*[-*]\\s+(.+)$/gm);\n if (listItems) {\n for (const item of listItems.slice(0, 3)) {\n const cleaned = item.replace(/^[-*]\\s*/, \"\").trim();\n if (cleaned.length > 15 && cleaned.length < 150 && !rules.includes(cleaned)) {\n rules.push(cleaned);\n }\n }\n }\n }\n\n return rules.slice(0, maxRules);\n}\n\n/**\n * Parse a guideline markdown file and extract summary\n */\nfunction parseGuideline(filePath: string): GuidelineSummary | null {\n try {\n const content = readFileSync(filePath, \"utf-8\");\n const filename = basename(filePath);\n\n // Skip template example and non-guideline files\n if (filename.startsWith(\"_\") || filename === \"Guidelines.md\") {\n return null;\n }\n\n return {\n filename,\n title: extractTitle(content),\n description: extractDescription(content),\n keyRules: extractKeyRules(content),\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Load workflow config from project root\n */\nfunction loadWorkflowConfig(projectRoot: string): WorkflowConfig | null {\n const configPath = join(projectRoot, \"workflow.config.json\");\n if (!existsSync(configPath)) {\n return null;\n }\n\n try {\n const content = readFileSync(configPath, \"utf-8\");\n return JSON.parse(content) as WorkflowConfig;\n } catch {\n return null;\n }\n}\n\n/**\n * Extract preserved custom content from existing file\n */\nfunction extractCustomContent(existingContent: string): string | null {\n const startIndex = existingContent.indexOf(CUSTOM_START_MARKER);\n const endIndex = existingContent.indexOf(CUSTOM_END_MARKER);\n\n if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {\n return existingContent.slice(\n startIndex + CUSTOM_START_MARKER.length,\n endIndex\n ).trim();\n }\n\n return null;\n}\n\n/**\n * Generate the copilot-instructions.md content\n */\nfunction generateInstructionsContent(\n config: WorkflowConfig | null,\n guidelines: GuidelineSummary[],\n customContent: string | null\n): string {\n const projectName = config?.projectName || \"this project\";\n const scopes = config?.scopes || [];\n\n let content = `# Copilot Instructions for ${projectName}\n\n> **This file is the Single Source of Truth for AI agents working on this codebase.**\n> It is auto-generated from the \\`guidelines/\\` directory by workflow-agent-cli.\n> Last generated: ${new Date().toISOString().split(\"T\")[0]}\n\n${GENERATED_MARKER}\n\n## Project Overview\n\n`;\n\n if (config) {\n content += `- **Project Name**: ${projectName}\\n`;\n content += `- **Enforcement Level**: ${config.enforcement || \"strict\"}\\n`;\n if (scopes.length > 0) {\n content += `- **Available Scopes**: ${scopes.map(s => `\\`${s.name}\\``).join(\", \")}\\n`;\n }\n content += \"\\n\";\n }\n\n // Add scope reference if available\n if (scopes.length > 0) {\n content += `### Valid Scopes for Commits and Branches\n\n| Scope | Description |\n|-------|-------------|\n`;\n for (const scope of scopes.slice(0, 15)) {\n content += `| \\`${scope.name}\\` | ${scope.description} |\\n`;\n }\n if (scopes.length > 15) {\n content += `| ... | See workflow.config.json for all ${scopes.length} scopes |\\n`;\n }\n content += \"\\n\";\n }\n\n // Add guidelines summaries\n if (guidelines.length > 0) {\n content += `## Guidelines Summary\n\nThe following guidelines govern development on this project. **Read the linked documents for full details.**\n\n`;\n\n // Group by importance (mandatory templates first)\n const mandatoryFiles = [\n \"AGENT_EDITING_INSTRUCTIONS.md\",\n \"BRANCHING_STRATEGY.md\",\n \"TESTING_STRATEGY.md\",\n \"SINGLE_SOURCE_OF_TRUTH.md\",\n \"PATTERN_ANALYSIS_WORKFLOW.md\",\n \"SELF_IMPROVEMENT_MANDATE.md\",\n ];\n\n const sortedGuidelines = [...guidelines].sort((a, b) => {\n const aIndex = mandatoryFiles.indexOf(a.filename);\n const bIndex = mandatoryFiles.indexOf(b.filename);\n if (aIndex !== -1 && bIndex !== -1) return aIndex - bIndex;\n if (aIndex !== -1) return -1;\n if (bIndex !== -1) return 1;\n return a.title.localeCompare(b.title);\n });\n\n for (const guideline of sortedGuidelines) {\n content += `### ${guideline.title}\n\n📄 [See full details](../guidelines/${guideline.filename})\n\n${guideline.description}\n\n`;\n if (guideline.keyRules.length > 0) {\n content += `**Key Rules:**\n`;\n for (const rule of guideline.keyRules) {\n // Rewrite any markdown links to include ../guidelines/ prefix\n content += `- ${rewriteGuidelineLinks(rule)}\\n`;\n }\n content += \"\\n\";\n }\n }\n }\n\n // Add quick reference section\n content += `## Quick Reference\n\n### Branch Naming Convention\n\\`\\`\\`\n<type>/<scope>/<short-description>\n\\`\\`\\`\n\n**Types**: \\`feature\\`, \\`fix\\`, \\`chore\\`, \\`docs\\`, \\`refactor\\`, \\`test\\`, \\`perf\\`\n\n### Commit Message Format\n\\`\\`\\`\n<type>(<scope>): <description>\n\n[optional body]\n\n[optional footer]\n\\`\\`\\`\n\n### Before Making Changes\n1. Read the relevant guideline document in \\`guidelines/\\`\n2. Check for existing patterns in \\`workflow:solution:search\\`\n3. Create an implementation plan for multi-file changes\n4. Ensure tests are added for new functionality\n\n### Before Committing\n1. Run \\`pnpm run workflow:verify\\` to validate all changes\n2. Ensure branch name follows convention\n3. Ensure commit message follows conventional commits format\n\n`;\n\n // Add custom content section\n content += `## Project-Specific Instructions\n\n${CUSTOM_START_MARKER}\n${customContent || `\n<!-- \nAdd your project-specific instructions here.\nThis section will be preserved when the file is regenerated.\n\nExamples:\n- Specific coding patterns unique to this project\n- Custom review requirements\n- Domain-specific terminology\n- Team-specific workflows\n-->\n`}\n${CUSTOM_END_MARKER}\n\n---\n\n*This file was generated by [workflow-agent-cli](https://www.npmjs.com/package/workflow-agent-cli). Run \\`pnpm run workflow:generate-instructions\\` to regenerate.*\n`;\n\n return content;\n}\n\n/**\n * Result of generating copilot instructions\n */\nexport interface GenerateResult {\n success: boolean;\n filePath: string | null;\n guidelinesCount: number;\n isNew: boolean;\n preservedCustomContent: boolean;\n error?: string;\n}\n\n/**\n * Generate .github/copilot-instructions.md from guidelines directory\n *\n * @param projectRoot - Root directory of the project\n * @param options - Generation options\n * @returns Result of the generation\n */\nexport function generateCopilotInstructions(\n projectRoot: string,\n options: { force?: boolean; silent?: boolean } = {}\n): GenerateResult {\n const { force: _force = false, silent = false } = options;\n\n const guidelinesDir = join(projectRoot, \"guidelines\");\n const githubDir = join(projectRoot, \".github\");\n const outputPath = join(githubDir, \"copilot-instructions.md\");\n\n // Check if guidelines directory exists\n if (!existsSync(guidelinesDir)) {\n if (!silent) {\n // Guidelines don't exist yet - skip silently during postinstall\n }\n return {\n success: false,\n filePath: null,\n guidelinesCount: 0,\n isNew: false,\n preservedCustomContent: false,\n error: \"No guidelines directory found. Run 'workflow init' first.\",\n };\n }\n\n // Read all markdown files from guidelines\n const files = readdirSync(guidelinesDir).filter(f => f.endsWith(\".md\"));\n if (files.length === 0) {\n return {\n success: false,\n filePath: null,\n guidelinesCount: 0,\n isNew: false,\n preservedCustomContent: false,\n error: \"No markdown files found in guidelines directory.\",\n };\n }\n\n // Parse each guideline\n const guidelines: GuidelineSummary[] = [];\n for (const file of files) {\n const summary = parseGuideline(join(guidelinesDir, file));\n if (summary) {\n guidelines.push(summary);\n }\n }\n\n // Load workflow config\n const config = loadWorkflowConfig(projectRoot);\n\n // Check for existing file and extract custom content\n let customContent: string | null = null;\n let isNew = true;\n\n if (existsSync(outputPath)) {\n isNew = false;\n const existingContent = readFileSync(outputPath, \"utf-8\");\n customContent = extractCustomContent(existingContent);\n }\n\n // Generate the content\n const content = generateInstructionsContent(config, guidelines, customContent);\n\n // Ensure .github directory exists\n if (!existsSync(githubDir)) {\n mkdirSync(githubDir, { recursive: true });\n }\n\n // Write the file\n writeFileSync(outputPath, content, \"utf-8\");\n\n return {\n success: true,\n filePath: outputPath,\n guidelinesCount: guidelines.length,\n isNew,\n preservedCustomContent: customContent !== null,\n };\n}\n\n/**\n * Check if copilot instructions need regeneration\n * (e.g., guidelines have been modified since last generation)\n */\nexport function needsRegeneration(projectRoot: string): boolean {\n const guidelinesDir = join(projectRoot, \"guidelines\");\n const outputPath = join(projectRoot, \".github\", \"copilot-instructions.md\");\n\n if (!existsSync(outputPath)) {\n return existsSync(guidelinesDir);\n }\n\n // For now, always regenerate to ensure latest content\n // Future: could compare file modification times\n return true;\n}\n","/**\n * Shared workflow scripts definition\n * Used by postinstall.ts and setup.ts to ensure consistency\n *\n * Version 2.22.0: Simplified to single \"workflow\" script\n * Users run commands directly: npm run workflow -- init\n */\n\n/**\n * Current version of the workflow scripts schema\n * Used for tracking which version installed the scripts\n */\nexport const WORKFLOW_SCRIPTS_VERSION = \"2.22.0\";\n\n/**\n * The valid top-level commands for the workflow CLI\n * Run with: npm run workflow -- <command> [subcommand] [options]\n */\nexport const VALID_COMMANDS = [\n \"version\",\n \"init\",\n \"validate\",\n \"config\",\n \"suggest\",\n \"setup\",\n \"doctor\",\n \"scope\",\n \"verify\",\n \"pre-commit\",\n \"learn\",\n \"solution\",\n \"sync\",\n \"docs\",\n] as const;\n\nexport type ValidCommand = (typeof VALID_COMMANDS)[number];\n\n/**\n * Validates that a script name is the expected \"workflow\" script\n * @param scriptName - The script name to validate\n * @returns true if valid, false otherwise\n */\nexport function validateScriptName(scriptName: string): boolean {\n return scriptName === \"workflow\";\n}\n\n/**\n * Finds old workflow scripts that should be removed\n * @param scripts - Object with script names as keys\n * @returns Array of old workflow script names that should be removed\n */\nexport function validateAllScripts(scripts: Record<string, string>): string[] {\n return Object.keys(scripts).filter(\n (name) =>\n (name.startsWith(\"workflow:\") || name.startsWith(\"workflow-\")) &&\n name !== \"workflow\"\n );\n}\n\n/**\n * Deprecated scripts that should be removed from package.json\n * These are replaced by the single \"workflow\" script\n */\nexport const DEPRECATED_SCRIPTS = [\n // Old colon-style scope commands\n \"workflow:scope:create\",\n \"workflow:scope:migrate\",\n\n // Old colon-style learn commands\n \"workflow:learn\",\n \"workflow:learn:record\",\n \"workflow:learn:list\",\n \"workflow:learn:apply\",\n \"workflow:learn:publish\",\n \"workflow:learn:sync\",\n \"workflow:learn:sync:push\",\n \"workflow:learn:sync:pull\",\n \"workflow:learn:config\",\n \"workflow:learn:deprecate\",\n \"workflow:learn:stats\",\n\n // Old colon-style solution commands\n \"workflow:solution\",\n \"workflow:solution:capture\",\n \"workflow:solution:search\",\n \"workflow:solution:list\",\n \"workflow:solution:apply\",\n \"workflow:solution:deprecate\",\n \"workflow:solution:stats\",\n\n // Old advisory commands\n \"workflow:advisory\",\n \"workflow:advisory:quick\",\n \"workflow:advisory:standard\",\n \"workflow:advisory:comprehensive\",\n \"workflow:advisory:executive\",\n \"workflow:advisory:ci\",\n\n // Old standalone commands\n \"workflow:generate-instructions\",\n \"workflow:update-templates\",\n \"workflow:update-templates:force\",\n\n // Old colon-style docs commands\n \"workflow:docs:validate\",\n \"workflow:docs:validate:fix\",\n\n // Old verify shortcuts\n \"verify\",\n \"verify:fix\",\n \"pre-commit\",\n\n // Old colon-style verify\n \"workflow:verify:fix\",\n\n // Old hooks commands\n \"workflow:hooks\",\n \"workflow:hooks-install\",\n \"workflow:hooks-uninstall\",\n \"workflow:hooks-test\",\n \"workflow:hooks:install\",\n \"workflow:hooks:uninstall\",\n \"workflow:hooks:status\",\n\n // Old auto-setup\n \"workflow:auto-setup\",\n\n // v2.21.x dash-style scripts (deprecated in favor of single \"workflow\" command)\n \"workflow:version\",\n \"workflow:init\",\n \"workflow:validate\",\n \"workflow:config\",\n \"workflow:config-show\",\n \"workflow:config-set\",\n \"workflow:suggest\",\n \"workflow:setup\",\n \"workflow:setup-auto\",\n \"workflow:doctor\",\n \"workflow:scope\",\n \"workflow:scope-list\",\n \"workflow:scope-create\",\n \"workflow:scope-migrate\",\n \"workflow:scope-add\",\n \"workflow:scope-remove\",\n \"workflow:scope-sync\",\n \"workflow:scope-analyze\",\n \"workflow:scope-hooks\",\n \"workflow:scope-hooks-status\",\n \"workflow:scope-hooks-install\",\n \"workflow:scope-hooks-uninstall\",\n \"workflow:scope-hooks-test\",\n \"workflow:verify\",\n \"workflow:verify-fix\",\n \"workflow:pre-commit\",\n \"workflow:learn-list\",\n \"workflow:learn-analyze\",\n \"workflow:learn-capture\",\n \"workflow:learn-apply\",\n \"workflow:learn-export\",\n \"workflow:learn-import\",\n \"workflow:learn-status\",\n \"workflow:learn-stats\",\n \"workflow:learn-clean\",\n \"workflow:learn-config\",\n \"workflow:learn-config-enable\",\n \"workflow:learn-config-disable\",\n \"workflow:learn-sync\",\n \"workflow:learn-sync-push\",\n \"workflow:learn-sync-pull\",\n \"workflow:solution-list\",\n \"workflow:solution-create\",\n \"workflow:solution-show\",\n \"workflow:solution-search\",\n \"workflow:solution-apply\",\n \"workflow:solution-export\",\n \"workflow:solution-import\",\n \"workflow:solution-analyze\",\n \"workflow:sync\",\n \"workflow:sync-status\",\n \"workflow:sync-push\",\n \"workflow:sync-pull\",\n \"workflow:docs\",\n \"workflow:docs-validate\",\n \"workflow:docs-validate-fix\",\n \"workflow:docs-advisory\",\n \"workflow:docs-advisory-quick\",\n \"workflow:docs-advisory-standard\",\n \"workflow:docs-advisory-comprehensive\",\n \"workflow:docs-advisory-executive\",\n \"workflow:docs-advisory-ci\",\n \"workflow:docs-generate\",\n \"workflow:docs-update\",\n \"workflow:docs-update-force\",\n] as const;\n\nexport type DeprecatedScriptName = (typeof DEPRECATED_SCRIPTS)[number];\n\n/**\n * The only script that should be added to package.json\n * Users run commands with: npm run workflow -- init\n */\nexport const WORKFLOW_SCRIPTS = {\n workflow: \"workflow-agent\",\n} as const;\n\nexport type WorkflowScriptName = keyof typeof WORKFLOW_SCRIPTS;\n\n/**\n * Script categories - simplified\n */\nexport const SCRIPT_CATEGORIES = {\n Main: [\"workflow\"],\n} as const;\n\nexport const TOTAL_SCRIPTS = Object.keys(WORKFLOW_SCRIPTS).length;\n\n","/**\n * Silent template installer for postinstall and non-interactive contexts\n *\n * This module provides functions to copy mandatory templates without\n * user interaction, suitable for use in postinstall scripts.\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from \"fs\";\nimport { readdirSync } from \"fs\";\nimport { join, basename } from \"path\";\nimport { getMandatoryTemplateFilenames } from \"../templates/metadata.js\";\n\nexport interface InstallTemplatesOptions {\n /** Force overwrite existing files */\n force?: boolean;\n /** Skip if guidelines directory already exists */\n skipIfExists?: boolean;\n /** Silent mode - no console output */\n silent?: boolean;\n /** Only install mandatory templates (default: true) */\n mandatoryOnly?: boolean;\n}\n\nexport interface InstallTemplatesResult {\n success: boolean;\n installed: string[];\n skipped: string[];\n updated: string[];\n errors: string[];\n guidelinesExisted: boolean;\n}\n\n/**\n * Get project name from package.json or directory name\n */\nfunction getProjectName(projectRoot: string): string {\n try {\n const pkgPath = join(projectRoot, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\"));\n return pkg.name || basename(projectRoot);\n }\n } catch {\n // Ignore errors, fall back to directory name\n }\n return basename(projectRoot);\n}\n\n/**\n * Simple template variable substitution using {{variable}} syntax\n */\nfunction renderTemplate(\n template: string,\n context: Record<string, string>,\n): string {\n return template.replace(/\\{\\{(\\w+)\\}\\}/g, (match, key) => {\n return context[key] ?? match;\n });\n}\n\n/**\n * Build default template context from project info\n * Uses generic defaults when no workflow.config.json exists\n */\nfunction buildDefaultContext(projectRoot: string): Record<string, string> {\n const projectName = getProjectName(projectRoot);\n\n return {\n projectName,\n framework: \"unknown\",\n scopes: \"feat, fix, docs, refactor, test, chore\",\n scopeList: `- **feat** - New features\n- **fix** - Bug fixes\n- **docs** - Documentation\n- **refactor** - Code refactoring\n- **test** - Testing\n- **chore** - Maintenance`,\n pathStructure: \"N/A\",\n enforcement: \"strict\",\n year: new Date().getFullYear().toString(),\n };\n}\n\n/**\n * Find the templates directory relative to this module\n * Works in both development and installed contexts\n */\nexport function findTemplatesDirectory(callerDirname: string): string | null {\n // When installed: dist/scripts/template-installer.js -> ../../templates\n // Try multiple possible locations\n const possiblePaths = [\n join(callerDirname, \"../../templates\"),\n join(callerDirname, \"../templates\"),\n join(callerDirname, \"templates\"),\n ];\n\n for (const templatePath of possiblePaths) {\n if (existsSync(templatePath)) {\n return templatePath;\n }\n }\n\n return null;\n}\n\n/**\n * Install mandatory templates to a project's guidelines directory\n * Designed for non-interactive use (postinstall, CI, etc.)\n */\nexport function installMandatoryTemplates(\n projectRoot: string,\n templatesDir: string,\n options: InstallTemplatesOptions = {},\n): InstallTemplatesResult {\n const {\n force = false,\n skipIfExists = true,\n silent = false,\n mandatoryOnly = true,\n } = options;\n\n const result: InstallTemplatesResult = {\n success: true,\n installed: [],\n skipped: [],\n updated: [],\n errors: [],\n guidelinesExisted: false,\n };\n\n const guidelinesDir = join(projectRoot, \"guidelines\");\n result.guidelinesExisted = existsSync(guidelinesDir);\n\n // Skip if guidelines exists and skipIfExists is true\n if (result.guidelinesExisted && skipIfExists && !force) {\n if (!silent) {\n console.log(\" Guidelines directory already exists, skipping templates\");\n }\n return result;\n }\n\n // Get list of templates to install\n const mandatoryFiles = getMandatoryTemplateFilenames();\n\n // Check templates directory exists\n if (!existsSync(templatesDir)) {\n result.success = false;\n result.errors.push(`Templates directory not found: ${templatesDir}`);\n return result;\n }\n\n // Get available template files\n let availableFiles: string[];\n try {\n availableFiles = readdirSync(templatesDir).filter((f) => f.endsWith(\".md\"));\n } catch (error) {\n result.success = false;\n result.errors.push(`Failed to read templates directory: ${error}`);\n return result;\n }\n\n // Determine which files to install\n const filesToInstall = mandatoryOnly\n ? availableFiles.filter((f) => mandatoryFiles.includes(f))\n : availableFiles;\n\n if (filesToInstall.length === 0) {\n result.success = false;\n result.errors.push(\"No template files found to install\");\n return result;\n }\n\n // Build template context\n const context = buildDefaultContext(projectRoot);\n\n // Create guidelines directory\n try {\n mkdirSync(guidelinesDir, { recursive: true });\n } catch (error) {\n result.success = false;\n result.errors.push(`Failed to create guidelines directory: ${error}`);\n return result;\n }\n\n // Copy each template\n for (const filename of filesToInstall) {\n const sourcePath = join(templatesDir, filename);\n const destPath = join(guidelinesDir, filename);\n\n const fileExists = existsSync(destPath);\n\n // Skip if file exists and not forcing\n if (fileExists && !force) {\n result.skipped.push(filename);\n continue;\n }\n\n try {\n const template = readFileSync(sourcePath, \"utf-8\");\n const rendered = renderTemplate(template, context);\n writeFileSync(destPath, rendered, \"utf-8\");\n\n if (fileExists) {\n result.updated.push(filename);\n } else {\n result.installed.push(filename);\n }\n } catch (error) {\n result.errors.push(`Failed to install ${filename}: ${error}`);\n }\n }\n\n // Log results if not silent\n if (!silent) {\n if (result.installed.length > 0) {\n console.log(\n `\\n✓ Installed ${result.installed.length} guideline templates:`,\n );\n for (const file of result.installed) {\n console.log(` - ${file}`);\n }\n }\n if (result.updated.length > 0) {\n console.log(`\\n✓ Updated ${result.updated.length} guideline templates:`);\n for (const file of result.updated) {\n console.log(` - ${file}`);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Update templates - reinstall templates with option to force or skip existing\n */\nexport function updateTemplates(\n projectRoot: string,\n templatesDir: string,\n options: { force?: boolean; silent?: boolean } = {},\n): InstallTemplatesResult {\n return installMandatoryTemplates(projectRoot, templatesDir, {\n ...options,\n skipIfExists: false, // Don't skip - we want to update\n mandatoryOnly: false, // Install all templates during update\n });\n}\n","/**\n * Template metadata defining mandatory vs optional guidelines\n * and their associated validators for enforcement\n *\n * @fileoverview This module defines which guidelines are mandatory for projects\n * using the workflow agent. Mandatory guidelines MUST be present and cannot be\n * skipped during project initialization.\n *\n * TODO: Ensure all new templates have associated unit tests in metadata.test.ts\n */\n\nexport type TemplateCategory = \"workflow\" | \"documentation\" | \"development\";\n\nexport type ValidatorType =\n | \"branch-name\"\n | \"commit-message\"\n | \"pr-title\"\n | \"implementation-plan\"\n | \"test-coverage\"\n | \"file-exists\";\n\nexport interface TemplateMetadata {\n /** Template filename */\n filename: string;\n /** Human-readable name */\n displayName: string;\n /** Whether this template is mandatory (cannot be skipped during init) */\n mandatory: boolean;\n /** Category for grouping */\n category: TemplateCategory;\n /** Associated validators that enforce this template's rules */\n validators: ValidatorType[];\n /** Brief description of what this template covers */\n description: string;\n}\n\n/**\n * Metadata for all available templates\n * Templates marked as mandatory will be auto-generated during init\n * and checked by the doctor command\n */\nexport const templateMetadata: Record<string, TemplateMetadata> = {\n \"AGENT_EDITING_INSTRUCTIONS.md\": {\n filename: \"AGENT_EDITING_INSTRUCTIONS.md\",\n displayName: \"Agent Editing Instructions\",\n mandatory: true,\n category: \"workflow\",\n validators: [\"implementation-plan\"],\n description:\n \"Core rules for AI agents: implementation plans, coding standards, architecture\",\n },\n \"BRANCHING_STRATEGY.md\": {\n filename: \"BRANCHING_STRATEGY.md\",\n displayName: \"Branching Strategy\",\n mandatory: true,\n category: \"workflow\",\n validators: [\"branch-name\", \"pr-title\"],\n description:\n \"Git branch naming conventions, PR requirements, merge policies\",\n },\n \"TESTING_STRATEGY.md\": {\n filename: \"TESTING_STRATEGY.md\",\n displayName: \"Testing Strategy\",\n mandatory: true,\n category: \"development\",\n validators: [\"test-coverage\"],\n description:\n \"Testing pyramid, Vitest/Playwright patterns, when tests are required\",\n },\n \"SELF_IMPROVEMENT_MANDATE.md\": {\n filename: \"SELF_IMPROVEMENT_MANDATE.md\",\n displayName: \"Self-Improvement Mandate\",\n mandatory: true,\n category: \"workflow\",\n validators: [],\n description: \"Continuous improvement tracking, changelog requirements\",\n },\n \"PATTERN_ANALYSIS_WORKFLOW.md\": {\n filename: \"PATTERN_ANALYSIS_WORKFLOW.md\",\n displayName: \"Pattern Analysis Workflow\",\n mandatory: true,\n category: \"workflow\",\n validators: [],\n description:\n \"AI agent workflow for analyzing codebases, extracting patterns, and updating the central pattern store\",\n },\n \"SINGLE_SOURCE_OF_TRUTH.md\": {\n filename: \"SINGLE_SOURCE_OF_TRUTH.md\",\n displayName: \"Single Source of Truth\",\n mandatory: true,\n category: \"workflow\",\n validators: [],\n description:\n \"Canonical code locations, service patterns, avoiding duplication\",\n },\n \"COMPONENT_LIBRARY.md\": {\n filename: \"COMPONENT_LIBRARY.md\",\n displayName: \"Component Library\",\n mandatory: false,\n category: \"development\",\n validators: [],\n description: \"UI component patterns, design tokens, decision tree\",\n },\n \"DEPLOYMENT_STRATEGY.md\": {\n filename: \"DEPLOYMENT_STRATEGY.md\",\n displayName: \"Deployment Strategy\",\n mandatory: false,\n category: \"development\",\n validators: [],\n description: \"Deployment workflow, environments, migrations, rollback\",\n },\n \"LIBRARY_INVENTORY.md\": {\n filename: \"LIBRARY_INVENTORY.md\",\n displayName: \"Library Inventory\",\n mandatory: true,\n category: \"development\",\n validators: [],\n description: \"Dependency catalog, approved libraries, new library process\",\n },\n \"SCOPE_CREATION_WORKFLOW.md\": {\n filename: \"SCOPE_CREATION_WORKFLOW.md\",\n displayName: \"Scope Creation Workflow\",\n mandatory: false,\n category: \"workflow\",\n validators: [],\n description: \"Workflow for AI agents creating custom scopes\",\n },\n \"CUSTOM_SCOPE_TEMPLATE.md\": {\n filename: \"CUSTOM_SCOPE_TEMPLATE.md\",\n displayName: \"Custom Scope Template\",\n mandatory: false,\n category: \"workflow\",\n validators: [],\n description: \"Template for defining custom scope packages\",\n },\n \"PROJECT_TEMPLATE_README.md\": {\n filename: \"PROJECT_TEMPLATE_README.md\",\n displayName: \"Project Template README\",\n mandatory: false,\n category: \"documentation\",\n validators: [],\n description: \"Meta-document describing project structure\",\n },\n \"Guidelines.md\": {\n filename: \"Guidelines.md\",\n displayName: \"Custom Guidelines\",\n mandatory: false,\n category: \"documentation\",\n validators: [],\n description: \"Placeholder for custom user guidelines\",\n },\n};\n\n/**\n * Get all mandatory templates\n */\nexport function getMandatoryTemplates(): TemplateMetadata[] {\n return Object.values(templateMetadata).filter((t) => t.mandatory);\n}\n\n/**\n * Get all optional templates\n */\nexport function getOptionalTemplates(): TemplateMetadata[] {\n return Object.values(templateMetadata).filter((t) => !t.mandatory);\n}\n\n/**\n * Get templates by category\n */\nexport function getTemplatesByCategory(\n category: TemplateCategory,\n): TemplateMetadata[] {\n return Object.values(templateMetadata).filter((t) => t.category === category);\n}\n\n/**\n * Get template metadata by filename\n */\nexport function getTemplateMetadata(\n filename: string,\n): TemplateMetadata | undefined {\n return templateMetadata[filename];\n}\n\n/**\n * Check if a template is mandatory\n */\nexport function isTemplateMandatory(filename: string): boolean {\n return templateMetadata[filename]?.mandatory ?? false;\n}\n\n/**\n * Get mandatory template filenames\n */\nexport function getMandatoryTemplateFilenames(): string[] {\n return getMandatoryTemplates().map((t) => t.filename);\n}\n"],"mappings":";AAeA,SAAS,cAAc,eAAe,YAAY,aAAa,iBAAiB;AAChF,SAAS,MAAM,gBAAgB;AAG/B,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AAmBzB,SAAS,aAAa,SAAyB;AAC7C,QAAM,QAAQ,QAAQ,MAAM,aAAa;AACzC,SAAO,QAAQ,MAAM,CAAC,EAAE,KAAK,IAAI;AACnC;AAKA,SAAS,mBAAmB,SAAyB;AAEnD,QAAM,QAAQ,QAAQ,MAAM,IAAI;AAChC,MAAI,aAAa;AACjB,MAAI,cAAc;AAElB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,WAAW,IAAI,GAAG;AACzB,mBAAa;AACb;AAAA,IACF;AACA,QAAI,YAAY;AAEd,UAAI,KAAK,KAAK,MAAM,MAAM,KAAK,WAAW,GAAG,GAAG;AAC9C,YAAI,YAAa;AACjB;AAAA,MACF;AAEA,UAAI,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,KAAK,KAAK,KAAK,WAAW,IAAI,GAAG;AAC3E;AAAA,MACF;AACA,qBAAe,KAAK,KAAK,IAAI;AAE7B,UAAI,YAAY,SAAS,IAAK;AAAA,IAChC;AAAA,EACF;AAEA,SAAO,YAAY,KAAK,EAAE,MAAM,GAAG,GAAG,KAAK,YAAY,SAAS,MAAM,QAAQ;AAChF;AAMA,SAAS,sBAAsB,MAAsB;AAEnD,SAA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AAU,OAAO;AAEzC,UAAI,YAAY;AACd,eAAO,QAAQ,KAAK,QAAQ;AAAA,MAC9B,OAAO;AACL,eAAO,UAAU,KAAK,QAAQ;AAAA,MAChC;AAAA,IACF,SAAS,OAAO;AACd,aAAO,OAAO,KAAK,qBAAqB,QAAQ,KAAK,KAAK,EAAE;AAAA,IAC9D;AAAA,EACF;AAGA,MAAI,CAAC,QAAQ;AACX,QAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,cAAQ;AAAA,QACN;AAAA,mBAAiB,OAAO,UAAU,MAAM;AAAA,MAC1C;AACA,iBAAW,QAAQ,OAAO,WAAW;AACnC,gBAAQ,IAAI,SAAS,IAAI,EAAE;AAAA,MAC7B;AAAA,IACF;AACA,QAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,cAAQ,IAAI;AAAA,iBAAe,OAAO,QAAQ,MAAM,uBAAuB;AACvE,iBAAW,QAAQ,OAAO,SAAS;AACjC,gBAAQ,IAAI,SAAS,IAAI,EAAE;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,gBACd,aACA,cACA,UAAiD,CAAC,GAC1B;AACxB,SAAO,0BAA0B,aAAa,cAAc;AAAA,IAC1D,GAAG;AAAA,IACH,cAAc;AAAA;AAAA,IACd,eAAe;AAAA;AAAA,EACjB,CAAC;AACH;","names":["existsSync","readFileSync","writeFileSync","mkdirSync","readdirSync","join","basename","join","existsSync","readFileSync","basename","readdirSync","mkdirSync","writeFileSync"]}
|
|
@@ -278,7 +278,10 @@ async function syncCommand(options) {
|
|
|
278
278
|
console.log("");
|
|
279
279
|
const store = new PatternStore(cwd);
|
|
280
280
|
const anonymizer = new PatternAnonymizer();
|
|
281
|
-
const
|
|
281
|
+
const syncData = await store.getPatternsForSync();
|
|
282
|
+
const fixes = syncData.fixes ?? [];
|
|
283
|
+
const blueprints = syncData.blueprints ?? [];
|
|
284
|
+
const solutions = syncData.solutions ?? [];
|
|
282
285
|
const patternsToSync = [];
|
|
283
286
|
if (syncLearn) {
|
|
284
287
|
console.log(
|
|
@@ -493,4 +496,4 @@ async function syncCommand(options) {
|
|
|
493
496
|
export {
|
|
494
497
|
syncCommand
|
|
495
498
|
};
|
|
496
|
-
//# sourceMappingURL=chunk-
|
|
499
|
+
//# sourceMappingURL=chunk-YBRWXMVK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/sync.ts","../src/sync/registry-client.ts"],"sourcesContent":["/**\n * Unified Sync Command\n *\n * Orchestrates syncing of patterns and solutions with the registry.\n * Combines functionality from learn:sync and solution sync.\n *\n * Usage:\n * workflow sync # Interactive sync (prompts for direction)\n * workflow sync --push # Push local patterns to registry\n * workflow sync --pull # Pull patterns from registry\n * workflow sync --solutions # Include solution patterns\n * workflow sync --learn # Include learning patterns (default)\n * workflow sync --scopes # Sync custom scope packages\n * workflow sync --all # Sync everything\n * workflow sync --dry-run # Preview without syncing\n */\n\nimport * as p from \"@clack/prompts\";\nimport chalk from \"chalk\";\nimport {\n PatternStore,\n PatternAnonymizer,\n ContributorManager,\n type FixPattern,\n type Blueprint,\n type SolutionPattern,\n} from \"@hawkinside_out/workflow-improvement-tracker\";\nimport {\n RegistryClient,\n RateLimitedException,\n RegistryError,\n} from \"../../sync/registry-client.js\";\n\nexport interface UnifiedSyncOptions {\n push?: boolean;\n pull?: boolean;\n solutions?: boolean;\n learn?: boolean;\n scopes?: boolean;\n all?: boolean;\n dryRun?: boolean;\n enableSync?: boolean;\n disableSync?: boolean;\n}\n\nfunction getWorkspacePath(): string {\n return process.cwd();\n}\n\n/**\n * Unified sync command that orchestrates all sync operations\n */\nexport async function syncCommand(options: UnifiedSyncOptions): Promise<void> {\n const cwd = getWorkspacePath();\n const contributorManager = new ContributorManager(cwd);\n\n p.intro(chalk.bgBlue(\" workflow sync \"));\n\n // Handle --enable-sync option\n if (options.enableSync) {\n const enableResult = await contributorManager.enableSync();\n if (enableResult.success) {\n console.log(chalk.green(\"\\n✅ Sync enabled!\"));\n console.log(chalk.dim(\" Your anonymized patterns can now be shared with the community.\\n\"));\n } else {\n console.log(chalk.red(`\\n❌ Failed to enable sync: ${enableResult.error}\\n`));\n process.exit(1);\n }\n // If only --enable-sync was passed, exit after enabling\n if (!options.push && !options.pull && !options.all && !options.solutions && !options.scopes) {\n p.outro(chalk.green(\"Sync enabled\"));\n return;\n }\n }\n\n // Handle --disable-sync option\n if (options.disableSync) {\n const disableResult = await contributorManager.disableSync();\n if (disableResult.success) {\n console.log(chalk.green(\"\\n✅ Sync disabled!\"));\n console.log(chalk.dim(\" Your patterns will no longer be shared.\\n\"));\n } else {\n console.log(chalk.red(`\\n❌ Failed to disable sync: ${disableResult.error}\\n`));\n process.exit(1);\n }\n p.outro(chalk.green(\"Sync disabled\"));\n return;\n }\n\n // Check if sync is enabled\n const config = await contributorManager.getConfig();\n if (!config.success || !config.data?.syncOptIn) {\n console.log(chalk.yellow(\"\\n⚠️ Sync is not enabled.\\n\"));\n console.log(chalk.dim(\" To enable sync, run:\"));\n console.log(chalk.dim(\" workflow learn config --enable-sync\\n\"));\n console.log(\n chalk.dim(\n \" This allows you to share anonymized patterns with the community.\",\n ),\n );\n p.outro(chalk.yellow(\"Sync not enabled\"));\n process.exit(0);\n }\n\n // Determine what to sync\n const syncLearn = options.learn || options.all || (!options.solutions && !options.scopes);\n const syncSolutions = options.solutions || options.all;\n const syncScopes = options.scopes || options.all;\n\n // Determine direction\n let direction: \"push\" | \"pull\" | \"both\" = \"both\";\n if (options.push && !options.pull) {\n direction = \"push\";\n } else if (options.pull && !options.push) {\n direction = \"pull\";\n } else if (!options.push && !options.pull) {\n // Interactive mode - ask user\n const choice = await p.select({\n message: \"Sync direction:\",\n options: [\n { value: \"push\", label: \"📤 Push - Upload local patterns to registry\" },\n { value: \"pull\", label: \"📥 Pull - Download patterns from registry\" },\n { value: \"both\", label: \"🔄 Both - Push then pull\" },\n ],\n });\n\n if (p.isCancel(choice)) {\n p.cancel(\"Sync cancelled\");\n process.exit(0);\n }\n direction = choice as \"push\" | \"pull\" | \"both\";\n }\n\n if (options.dryRun) {\n console.log(chalk.yellow(\"\\n📋 DRY-RUN MODE: No changes will be synced\\n\"));\n }\n\n // Show what will be synced\n console.log(chalk.cyan(\"\\n📦 Sync scope:\"));\n if (syncLearn) console.log(chalk.dim(\" • Learning patterns (fixes, blueprints)\"));\n if (syncSolutions) console.log(chalk.dim(\" • Solution patterns\"));\n if (syncScopes) console.log(chalk.dim(\" • Custom scopes\"));\n console.log(chalk.dim(` • Direction: ${direction === \"both\" ? \"push + pull\" : direction}`));\n console.log(\"\");\n\n const store = new PatternStore(cwd);\n const anonymizer = new PatternAnonymizer();\n\n // Get patterns to sync (with defaults in case of undefined)\n const syncData = await store.getPatternsForSync();\n const fixes = syncData.fixes ?? [];\n const blueprints = syncData.blueprints ?? [];\n const solutions = syncData.solutions ?? [];\n\n // Filter based on options\n const patternsToSync: Array<{\n pattern: FixPattern | Blueprint | SolutionPattern;\n type: \"fix\" | \"blueprint\" | \"solution\";\n originalId: string;\n }> = [];\n\n if (syncLearn) {\n console.log(\n chalk.dim(\n ` Found ${fixes.length} fixes, ${blueprints.length} blueprints ready to sync`,\n ),\n );\n\n for (const fix of fixes) {\n const result = anonymizer.anonymizeFixPattern(fix);\n if (result.success && result.data) {\n patternsToSync.push({\n pattern: result.data,\n type: \"fix\",\n originalId: fix.id,\n });\n }\n }\n\n for (const bp of blueprints) {\n const result = anonymizer.anonymizeBlueprint(bp);\n if (result.success && result.data) {\n patternsToSync.push({\n pattern: result.data,\n type: \"blueprint\",\n originalId: bp.id,\n });\n }\n }\n }\n\n if (syncSolutions) {\n console.log(\n chalk.dim(\n ` Found ${solutions.length} solutions ready to sync`,\n ),\n );\n\n for (const solution of solutions) {\n const result = anonymizer.anonymizeSolution(solution);\n if (result.success && result.data) {\n patternsToSync.push({\n pattern: result.data,\n type: \"solution\",\n originalId: solution.id,\n });\n }\n }\n }\n\n if (syncScopes) {\n // TODO: Implement scope sync when scope registry is available\n console.log(chalk.dim(\" Scope sync: Coming soon\"));\n }\n\n // PUSH operation\n if (direction === \"push\" || direction === \"both\") {\n console.log(chalk.cyan(\"\\n📤 Pushing patterns...\\n\"));\n\n if (patternsToSync.length === 0) {\n console.log(chalk.yellow(\" No patterns to push\\n\"));\n } else {\n const fixCount = patternsToSync.filter((p) => p.type === \"fix\").length;\n const bpCount = patternsToSync.filter((p) => p.type === \"blueprint\").length;\n const solutionCount = patternsToSync.filter((p) => p.type === \"solution\").length;\n\n console.log(\n chalk.dim(\n ` Ready to push: ${fixCount} fixes, ${bpCount} blueprints, ${solutionCount} solutions`,\n ),\n );\n\n if (options.dryRun) {\n console.log(chalk.yellow(\"\\n [DRY-RUN] Would push patterns to registry\"));\n } else {\n // Get contributor ID\n const contributorResult = await contributorManager.getOrCreateId();\n if (!contributorResult.success || !contributorResult.data) {\n console.log(chalk.red(\"\\n ❌ Failed to get contributor ID\"));\n process.exit(1);\n }\n\n // Push to registry\n const registryClient = new RegistryClient();\n\n try {\n console.log(chalk.dim(\"\\n Connecting to registry...\"));\n\n const pushResult = await registryClient.push(\n patternsToSync.map((p) => ({\n pattern: p.pattern,\n type: p.type,\n })),\n contributorResult.data,\n );\n\n // Mark pushed patterns as synced\n if (pushResult.pushed > 0) {\n const pushedFixIds = patternsToSync\n .filter((p) => p.type === \"fix\")\n .map((p) => p.originalId);\n const pushedBpIds = patternsToSync\n .filter((p) => p.type === \"blueprint\")\n .map((p) => p.originalId);\n const pushedSolutionIds = patternsToSync\n .filter((p) => p.type === \"solution\")\n .map((p) => p.originalId);\n\n if (pushedFixIds.length > 0) {\n await store.markAsSynced(pushedFixIds, \"fix\");\n }\n if (pushedBpIds.length > 0) {\n await store.markAsSynced(pushedBpIds, \"blueprint\");\n }\n if (pushedSolutionIds.length > 0) {\n await store.markAsSynced(pushedSolutionIds, \"solution\");\n }\n }\n\n console.log(\n chalk.green(`\\n ✅ Pushed ${pushResult.pushed} patterns to registry`),\n );\n\n if (pushResult.skipped > 0) {\n console.log(\n chalk.dim(` (${pushResult.skipped} already existed)`),\n );\n }\n\n if (pushResult.errors && pushResult.errors.length > 0) {\n console.log(chalk.yellow(`\\n ⚠️ Some patterns had errors:`));\n for (const err of pushResult.errors) {\n console.log(chalk.dim(` - ${err}`));\n }\n }\n\n console.log(\n chalk.dim(\n `\\n Rate limit: ${pushResult.rateLimit.remaining} patterns remaining this hour`,\n ),\n );\n } catch (error) {\n if (error instanceof RateLimitedException) {\n console.log(chalk.red(\"\\n ❌ Rate limit exceeded\"));\n console.log(\n chalk.dim(\n ` Try again in ${error.getTimeUntilReset()}`,\n ),\n );\n } else if (error instanceof RegistryError) {\n console.log(chalk.red(`\\n ❌ Registry error: ${error.message}`));\n } else {\n console.log(\n chalk.red(\n `\\n ❌ Failed to push: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n process.exit(1);\n }\n }\n }\n }\n\n // PULL operation\n if (direction === \"pull\" || direction === \"both\") {\n console.log(chalk.cyan(\"\\n📥 Pulling patterns from registry...\\n\"));\n\n if (options.dryRun) {\n console.log(chalk.yellow(\" [DRY-RUN] Would pull patterns from registry\"));\n } else {\n const registryClient = new RegistryClient();\n\n try {\n console.log(chalk.dim(\" Connecting to registry...\"));\n\n // Pull patterns based on sync options - need to call separately for each type\n const pullTypes: (\"fix\" | \"blueprint\" | \"solution\")[] = [];\n if (syncLearn) {\n pullTypes.push(\"fix\", \"blueprint\");\n }\n if (syncSolutions) {\n pullTypes.push(\"solution\");\n }\n\n let totalPatterns = 0;\n let savedCount = 0;\n\n for (const pullType of pullTypes) {\n const pullResult = await registryClient.pull({\n type: pullType,\n });\n\n totalPatterns += pullResult.patterns.length;\n\n for (const pulled of pullResult.patterns) {\n try {\n if (pulled.type === \"fix\" && pulled.data) {\n await store.saveFixPattern(pulled.data as FixPattern);\n savedCount++;\n } else if (pulled.type === \"blueprint\" && pulled.data) {\n await store.saveBlueprint(pulled.data as Blueprint);\n savedCount++;\n } else if (pulled.type === \"solution\" && pulled.data) {\n await store.saveSolution(pulled.data as SolutionPattern);\n savedCount++;\n }\n } catch {\n // Pattern might already exist\n }\n }\n }\n\n if (totalPatterns === 0) {\n console.log(chalk.dim(\" No new patterns to pull\"));\n } else {\n console.log(\n chalk.green(`\\n ✅ Pulled ${savedCount} patterns from registry`),\n );\n }\n } catch (error) {\n if (error instanceof RateLimitedException) {\n console.log(chalk.red(\"\\n ❌ Rate limit exceeded\"));\n console.log(\n chalk.dim(\n ` Try again in ${error.getTimeUntilReset()}`,\n ),\n );\n } else if (error instanceof RegistryError) {\n console.log(chalk.red(`\\n ❌ Registry error: ${error.message}`));\n } else {\n console.log(\n chalk.red(\n `\\n ❌ Failed to pull: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n process.exit(1);\n }\n }\n }\n\n p.outro(chalk.green(\"Sync complete!\"));\n}\n","/**\n * Registry Client for pattern sync\n *\n * HTTP client for pushing patterns to and pulling patterns from\n * the community pattern registry.\n */\n\nimport type { FixPattern, Blueprint, SolutionPattern } from \"@hawkinside_out/workflow-improvement-tracker\";\n\n// Default registry URL\nconst DEFAULT_REGISTRY_URL = \"https://registry-api-rust.vercel.app\";\n\n/**\n * Pattern payload for push/pull operations\n */\nexport interface RegistryPattern {\n id: string;\n type: \"fix\" | \"blueprint\" | \"solution\";\n data: Record<string, unknown>;\n hash?: string;\n createdAt?: string;\n}\n\n/**\n * Push response from registry\n */\nexport interface PushResponse {\n status: \"ok\" | \"error\";\n pushed: number;\n skipped: number;\n errors?: string[];\n rateLimit: {\n remaining: number;\n resetAt: string | null;\n };\n}\n\n/**\n * Pull response from registry\n */\nexport interface PullResponse {\n patterns: RegistryPattern[];\n pagination: {\n offset: number;\n limit: number;\n total: number;\n hasMore: boolean;\n };\n}\n\n/**\n * Rate limit error details\n */\nexport interface RateLimitError {\n message: string;\n resetAt: string | null;\n remaining: number;\n}\n\n/**\n * Registry client options\n */\nexport interface RegistryClientOptions {\n /**\n * Base URL of the registry API\n * Defaults to https://patterns.workflow-agent.dev\n * Can be overridden via WORKFLOW_REGISTRY_URL env var\n */\n baseUrl?: string;\n\n /**\n * Request timeout in milliseconds\n * Defaults to 30000 (30 seconds)\n */\n timeout?: number;\n\n /**\n * Number of retry attempts for failed requests\n * Defaults to 3\n */\n retries?: number;\n}\n\n/**\n * Registry Client\n *\n * Handles HTTP communication with the pattern registry API\n */\nexport class RegistryClient {\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly retries: number;\n\n constructor(options: RegistryClientOptions = {}) {\n // Priority: options > env var > default\n this.baseUrl =\n options.baseUrl ||\n process.env.WORKFLOW_REGISTRY_URL ||\n DEFAULT_REGISTRY_URL;\n\n // Ensure no trailing slash\n this.baseUrl = this.baseUrl.replace(/\\/$/, \"\");\n\n this.timeout = options.timeout ?? 30000;\n this.retries = options.retries ?? 3;\n }\n\n /**\n * Push patterns to the registry\n *\n * @param patterns - Array of anonymized patterns to push\n * @param contributorId - Anonymous contributor ID\n * @returns Push result with count of pushed/skipped patterns\n * @throws Error if rate limited or push fails\n */\n async push(\n patterns: Array<{\n pattern: FixPattern | Blueprint | SolutionPattern;\n type: \"fix\" | \"blueprint\" | \"solution\";\n hash?: string;\n }>,\n contributorId: string,\n ): Promise<PushResponse> {\n const payload = {\n patterns: patterns.map((p) => ({\n id: p.pattern.id,\n type: p.type,\n data: p.pattern as unknown as Record<string, unknown>,\n hash: p.hash,\n })),\n };\n\n const response = await this.request<PushResponse>(\n \"/api/patterns/push\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-contributor-id\": contributorId,\n },\n body: JSON.stringify(payload),\n },\n );\n\n return response;\n }\n\n /**\n * Pull patterns from the registry\n *\n * @param options - Pull options\n * @returns Array of patterns from the registry\n */\n async pull(options: {\n type?: \"fix\" | \"blueprint\" | \"solution\";\n limit?: number;\n offset?: number;\n since?: string;\n } = {}): Promise<PullResponse> {\n const params = new URLSearchParams();\n\n if (options.type) {\n params.set(\"type\", options.type);\n }\n if (options.limit) {\n params.set(\"limit\", options.limit.toString());\n }\n if (options.offset) {\n params.set(\"offset\", options.offset.toString());\n }\n if (options.since) {\n params.set(\"since\", options.since);\n }\n\n const queryString = params.toString();\n const url = `/api/patterns/pull${queryString ? `?${queryString}` : \"\"}`;\n\n return this.request<PullResponse>(url, {\n method: \"GET\",\n });\n }\n\n /**\n * Get a single pattern by ID\n *\n * @param patternId - UUID of the pattern\n * @returns Pattern data or null if not found\n */\n async getPattern(patternId: string): Promise<RegistryPattern | null> {\n try {\n return await this.request<RegistryPattern>(`/api/patterns/${patternId}`, {\n method: \"GET\",\n });\n } catch (error) {\n if (error instanceof RegistryError && error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Check if the registry is available\n */\n async healthCheck(): Promise<boolean> {\n try {\n await this.request<{ status: string }>(\"/api/health\", {\n method: \"GET\",\n });\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Make an HTTP request to the registry\n */\n private async request<T>(\n path: string,\n options: RequestInit,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n let lastError: Error | null = null;\n\n for (let attempt = 1; attempt <= this.retries; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (response.status === 429) {\n // Rate limited\n const body = await response.json() as { message?: string; resetAt?: string | null; remaining?: number };\n throw new RateLimitedException(\n body.message || \"Rate limit exceeded\",\n body.resetAt ?? null,\n body.remaining ?? 0,\n );\n }\n\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string };\n throw new RegistryError(\n body.error || `Request failed with status ${response.status}`,\n response.status,\n body,\n );\n }\n\n return await response.json() as T;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n // Don't retry rate limit errors\n if (error instanceof RateLimitedException) {\n throw error;\n }\n\n // Don't retry on 4xx errors (except timeout)\n if (\n error instanceof RegistryError &&\n error.statusCode >= 400 &&\n error.statusCode < 500\n ) {\n throw error;\n }\n\n // Wait before retrying (exponential backoff)\n if (attempt < this.retries) {\n await new Promise((resolve) =>\n setTimeout(resolve, Math.pow(2, attempt) * 1000)\n );\n }\n }\n }\n\n throw lastError ?? new Error(\"Request failed after retries\");\n }\n}\n\n/**\n * Registry API error\n */\nexport class RegistryError extends Error {\n constructor(\n message: string,\n public readonly statusCode: number,\n public readonly body?: unknown,\n ) {\n super(message);\n this.name = \"RegistryError\";\n }\n}\n\n/**\n * Rate limit exceeded error\n */\nexport class RateLimitedException extends Error {\n constructor(\n message: string,\n public readonly resetAt: string | null,\n public readonly remaining: number,\n ) {\n super(message);\n this.name = \"RateLimitedException\";\n }\n\n /**\n * Get human-readable time until rate limit resets\n */\n getTimeUntilReset(): string {\n if (!this.resetAt) {\n return \"unknown\";\n }\n\n const resetTime = new Date(this.resetAt).getTime();\n const now = Date.now();\n const diffMs = resetTime - now;\n\n if (diffMs <= 0) {\n return \"now\";\n }\n\n const minutes = Math.ceil(diffMs / 60000);\n if (minutes < 60) {\n return `${minutes} minute${minutes === 1 ? \"\" : \"s\"}`;\n }\n\n const hours = Math.ceil(minutes / 60);\n return `${hours} hour${hours === 1 ? \"\" : \"s\"}`;\n }\n}\n"],"mappings":";AAiBA,YAAY,OAAO;AACnB,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;;;AChBP,IAAM,uBAAuB;AA8EtB,IAAM,iBAAN,MAAqB;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,UAAiC,CAAC,GAAG;AAE/C,SAAK,UACH,QAAQ,WACR,QAAQ,IAAI,yBACZ;AAGF,SAAK,UAAU,KAAK,QAAQ,QAAQ,OAAO,EAAE;AAE7C,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA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;AAAA,kBAAgB,UAAU,yBAAyB;AAAA,UACjE;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,YAAI,iBAAiB,sBAAsB;AACzC,kBAAQ,IAAI,MAAM,IAAI,gCAA2B,CAAC;AAClD,kBAAQ;AAAA,YACN,MAAM;AAAA,cACJ,qBAAqB,MAAM,kBAAkB,CAAC;AAAA,YAChD;AAAA,UACF;AAAA,QACF,WAAW,iBAAiB,eAAe;AACzC,kBAAQ,IAAI,MAAM,IAAI;AAAA,2BAAyB,MAAM,OAAO,EAAE,CAAC;AAAA,QACjE,OAAO;AACL,kBAAQ;AAAA,YACN,MAAM;AAAA,cACJ;AAAA,2BAAyB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,YACjF;AAAA,UACF;AAAA,QACF;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAEA,EAAE,QAAM,MAAM,MAAM,gBAAgB,CAAC;AACvC;","names":["p","p"]}
|
package/dist/cli/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
templateMetadata,
|
|
30
30
|
updateTemplates,
|
|
31
31
|
validateAllScripts
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-IWFUJ2DS.js";
|
|
33
33
|
import {
|
|
34
34
|
autoFixConfigFile,
|
|
35
35
|
validateScopeDefinitions
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
import "../chunk-3ADL5QDN.js";
|
|
41
41
|
import {
|
|
42
42
|
syncCommand
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-YBRWXMVK.js";
|
|
44
44
|
|
|
45
45
|
// src/cli/index.ts
|
|
46
46
|
import { Command as Command7 } from "commander";
|
|
@@ -5139,6 +5139,122 @@ async function statusHooksAction(cwd) {
|
|
|
5139
5139
|
}
|
|
5140
5140
|
}
|
|
5141
5141
|
|
|
5142
|
+
// src/cli/commands/hooks/index.ts
|
|
5143
|
+
async function installAction() {
|
|
5144
|
+
return hooksCommand("install");
|
|
5145
|
+
}
|
|
5146
|
+
async function uninstallAction() {
|
|
5147
|
+
return hooksCommand("uninstall");
|
|
5148
|
+
}
|
|
5149
|
+
async function statusAction() {
|
|
5150
|
+
return hooksCommand("status");
|
|
5151
|
+
}
|
|
5152
|
+
async function testAction(options) {
|
|
5153
|
+
console.log(chalk17.bold.cyan("\n\u{1F9EA} Testing Git Hooks\n"));
|
|
5154
|
+
const fs3 = await import("fs");
|
|
5155
|
+
const path4 = await import("path");
|
|
5156
|
+
const cwd = process.cwd();
|
|
5157
|
+
const gitDir = path4.join(cwd, ".git");
|
|
5158
|
+
const hooksDir = path4.join(gitDir, "hooks");
|
|
5159
|
+
if (!fs3.existsSync(gitDir)) {
|
|
5160
|
+
console.log(chalk17.red("\u2717 Not a git repository"));
|
|
5161
|
+
process.exit(1);
|
|
5162
|
+
}
|
|
5163
|
+
if (!fs3.existsSync(hooksDir)) {
|
|
5164
|
+
console.log(chalk17.yellow(" No hooks directory found"));
|
|
5165
|
+
console.log(chalk17.dim(" Run: workflow hooks install"));
|
|
5166
|
+
process.exit(1);
|
|
5167
|
+
}
|
|
5168
|
+
const hookTypes = ["pre-commit", "commit-msg"];
|
|
5169
|
+
let allInstalled = true;
|
|
5170
|
+
for (const hookType of hookTypes) {
|
|
5171
|
+
const hookPath = path4.join(hooksDir, hookType);
|
|
5172
|
+
const exists = fs3.existsSync(hookPath);
|
|
5173
|
+
const isExecutable = exists && (fs3.statSync(hookPath).mode & 73) !== 0;
|
|
5174
|
+
const isWorkflowHook2 = exists && fs3.readFileSync(hookPath, "utf-8").toLowerCase().includes("workflow");
|
|
5175
|
+
if (exists && isExecutable && isWorkflowHook2) {
|
|
5176
|
+
console.log(chalk17.green(` \u2713 ${hookType} - installed and executable`));
|
|
5177
|
+
} else if (exists && !isWorkflowHook2) {
|
|
5178
|
+
console.log(chalk17.yellow(` \u26A0 ${hookType} - exists but not managed by workflow-agent`));
|
|
5179
|
+
allInstalled = false;
|
|
5180
|
+
} else if (exists && !isExecutable) {
|
|
5181
|
+
console.log(chalk17.red(` \u2717 ${hookType} - exists but not executable`));
|
|
5182
|
+
allInstalled = false;
|
|
5183
|
+
} else {
|
|
5184
|
+
console.log(chalk17.red(` \u2717 ${hookType} - not installed`));
|
|
5185
|
+
allInstalled = false;
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
if (options.dryRun) {
|
|
5189
|
+
console.log(chalk17.bold.cyan("\n Dry-run hook simulation:\n"));
|
|
5190
|
+
console.log(chalk17.dim(" Simulating pre-commit hook..."));
|
|
5191
|
+
const { verifyCommand: verifyCommand2 } = await import("../verify-XGCZKY7S.js");
|
|
5192
|
+
try {
|
|
5193
|
+
await verifyCommand2({ fix: false, dryRun: true, maxRetries: "1" });
|
|
5194
|
+
} catch {
|
|
5195
|
+
}
|
|
5196
|
+
}
|
|
5197
|
+
if (!allInstalled) {
|
|
5198
|
+
console.log(chalk17.yellow("\n Some hooks are not properly installed"));
|
|
5199
|
+
console.log(chalk17.dim(" Run: workflow hooks install"));
|
|
5200
|
+
process.exit(1);
|
|
5201
|
+
}
|
|
5202
|
+
console.log(chalk17.green("\n\u2713 All hooks are properly installed"));
|
|
5203
|
+
}
|
|
5204
|
+
function createHooksCommand() {
|
|
5205
|
+
const hooksCmd = new Command3("hooks").description("Manage git hooks for the project").addHelpText(
|
|
5206
|
+
"after",
|
|
5207
|
+
`
|
|
5208
|
+
${chalk17.bold("Examples:")}
|
|
5209
|
+
$ workflow hooks install ${chalk17.dim("# Install git hooks")}
|
|
5210
|
+
$ workflow hooks uninstall ${chalk17.dim("# Remove git hooks")}
|
|
5211
|
+
$ workflow hooks status ${chalk17.dim("# Check hooks status")}
|
|
5212
|
+
$ workflow hooks test ${chalk17.dim("# Verify installation")}
|
|
5213
|
+
$ workflow hooks test --dry-run ${chalk17.dim("# Test with simulation")}
|
|
5214
|
+
`
|
|
5215
|
+
).action(() => {
|
|
5216
|
+
hooksCmd.help();
|
|
5217
|
+
});
|
|
5218
|
+
hooksCmd.command("install").description("Install git hooks for the project").addHelpText(
|
|
5219
|
+
"after",
|
|
5220
|
+
`
|
|
5221
|
+
${chalk17.bold("Details:")}
|
|
5222
|
+
Installs pre-commit and commit-msg hooks that:
|
|
5223
|
+
- Validate branch names
|
|
5224
|
+
- Validate commit message format
|
|
5225
|
+
- Run quality checks before commit
|
|
5226
|
+
|
|
5227
|
+
If existing hooks are found, they will be wrapped
|
|
5228
|
+
so both the original and workflow hooks run.
|
|
5229
|
+
`
|
|
5230
|
+
).action(installAction);
|
|
5231
|
+
hooksCmd.command("uninstall").description("Remove installed git hooks").addHelpText(
|
|
5232
|
+
"after",
|
|
5233
|
+
`
|
|
5234
|
+
${chalk17.bold("Details:")}
|
|
5235
|
+
Removes workflow agent hooks from the project.
|
|
5236
|
+
If original hooks were wrapped, they will be restored.
|
|
5237
|
+
`
|
|
5238
|
+
).action(uninstallAction);
|
|
5239
|
+
hooksCmd.command("status").description("Show current hooks installation status").addHelpText(
|
|
5240
|
+
"after",
|
|
5241
|
+
`
|
|
5242
|
+
${chalk17.bold("Details:")}
|
|
5243
|
+
Shows which git hooks are installed and whether
|
|
5244
|
+
they are managed by workflow agent.
|
|
5245
|
+
`
|
|
5246
|
+
).action(statusAction);
|
|
5247
|
+
hooksCmd.command("test").description("Test that hooks are properly installed").option("--dry-run", "Simulate hook execution without making changes").addHelpText(
|
|
5248
|
+
"after",
|
|
5249
|
+
`
|
|
5250
|
+
${chalk17.bold("Details:")}
|
|
5251
|
+
Verifies that git hooks are properly installed and executable.
|
|
5252
|
+
Use --dry-run to simulate hook execution.
|
|
5253
|
+
`
|
|
5254
|
+
).action(testAction);
|
|
5255
|
+
return hooksCmd;
|
|
5256
|
+
}
|
|
5257
|
+
|
|
5142
5258
|
// src/cli/commands/solution/index.ts
|
|
5143
5259
|
import { Command as Command4 } from "commander";
|
|
5144
5260
|
import chalk19 from "chalk";
|
|
@@ -7995,7 +8111,7 @@ ${chalk21.bold("Pro Tip:")}
|
|
|
7995
8111
|
$ workflow sync --all ${chalk21.dim("# Sync everything")}
|
|
7996
8112
|
`
|
|
7997
8113
|
).action(async (options) => {
|
|
7998
|
-
const { syncCommand: syncCommand2 } = await import("../sync-
|
|
8114
|
+
const { syncCommand: syncCommand2 } = await import("../sync-TLICCJNH.js");
|
|
7999
8115
|
return syncCommand2({ ...options, learn: true });
|
|
8000
8116
|
});
|
|
8001
8117
|
learnCmd.command("config").description("Configure learning settings").option("--enable-sync", "Enable pattern sync").option("--disable-sync", "Disable pattern sync").option("--enable-telemetry", "Enable anonymous telemetry").option("--disable-telemetry", "Disable telemetry").option("--reset-id", "Reset contributor ID").option("--show", "Show current configuration").addHelpText(
|
|
@@ -8192,7 +8308,7 @@ async function scopeRemoveCommand(name) {
|
|
|
8192
8308
|
}
|
|
8193
8309
|
async function scopeSyncCommand(options) {
|
|
8194
8310
|
console.log(chalk22.bold.cyan("\n\u{1F504} Syncing Scopes\n"));
|
|
8195
|
-
const { syncCommand: syncCommand2 } = await import("../sync-
|
|
8311
|
+
const { syncCommand: syncCommand2 } = await import("../sync-TLICCJNH.js");
|
|
8196
8312
|
await syncCommand2({
|
|
8197
8313
|
...options,
|
|
8198
8314
|
scopes: true,
|
|
@@ -8259,60 +8375,8 @@ async function scopeAnalyzeCommand() {
|
|
|
8259
8375
|
console.log(chalk22.dim(" Make sure you're in a git repository with commit history"));
|
|
8260
8376
|
}
|
|
8261
8377
|
}
|
|
8262
|
-
async function hooksTestCommand(options) {
|
|
8263
|
-
console.log(chalk22.bold.cyan("\n\u{1F9EA} Testing Git Hooks\n"));
|
|
8264
|
-
const fs3 = await import("fs");
|
|
8265
|
-
const path4 = await import("path");
|
|
8266
|
-
const cwd = process.cwd();
|
|
8267
|
-
const gitDir = path4.join(cwd, ".git");
|
|
8268
|
-
const hooksDir = path4.join(gitDir, "hooks");
|
|
8269
|
-
if (!fs3.existsSync(gitDir)) {
|
|
8270
|
-
console.log(chalk22.red("\u2717 Not a git repository"));
|
|
8271
|
-
process.exit(1);
|
|
8272
|
-
}
|
|
8273
|
-
if (!fs3.existsSync(hooksDir)) {
|
|
8274
|
-
console.log(chalk22.yellow(" No hooks directory found"));
|
|
8275
|
-
console.log(chalk22.dim(" Run: workflow scope hooks install"));
|
|
8276
|
-
process.exit(1);
|
|
8277
|
-
}
|
|
8278
|
-
const hookTypes = ["pre-commit", "commit-msg"];
|
|
8279
|
-
let allInstalled = true;
|
|
8280
|
-
for (const hookType of hookTypes) {
|
|
8281
|
-
const hookPath = path4.join(hooksDir, hookType);
|
|
8282
|
-
const exists = fs3.existsSync(hookPath);
|
|
8283
|
-
const isExecutable = exists && (fs3.statSync(hookPath).mode & 73) !== 0;
|
|
8284
|
-
const isWorkflowHook2 = exists && fs3.readFileSync(hookPath, "utf-8").includes("workflow-agent");
|
|
8285
|
-
if (exists && isExecutable && isWorkflowHook2) {
|
|
8286
|
-
console.log(chalk22.green(` \u2713 ${hookType} - installed and executable`));
|
|
8287
|
-
} else if (exists && !isWorkflowHook2) {
|
|
8288
|
-
console.log(chalk22.yellow(` \u26A0 ${hookType} - exists but not managed by workflow-agent`));
|
|
8289
|
-
allInstalled = false;
|
|
8290
|
-
} else if (exists && !isExecutable) {
|
|
8291
|
-
console.log(chalk22.red(` \u2717 ${hookType} - exists but not executable`));
|
|
8292
|
-
allInstalled = false;
|
|
8293
|
-
} else {
|
|
8294
|
-
console.log(chalk22.red(` \u2717 ${hookType} - not installed`));
|
|
8295
|
-
allInstalled = false;
|
|
8296
|
-
}
|
|
8297
|
-
}
|
|
8298
|
-
if (options.dryRun) {
|
|
8299
|
-
console.log(chalk22.bold.cyan("\n Dry-run hook simulation:\n"));
|
|
8300
|
-
console.log(chalk22.dim(" Simulating pre-commit hook..."));
|
|
8301
|
-
const { verifyCommand: verifyCommand2 } = await import("../verify-XGCZKY7S.js");
|
|
8302
|
-
try {
|
|
8303
|
-
await verifyCommand2({ fix: false, dryRun: true, maxRetries: "1" });
|
|
8304
|
-
} catch {
|
|
8305
|
-
}
|
|
8306
|
-
}
|
|
8307
|
-
if (!allInstalled) {
|
|
8308
|
-
console.log(chalk22.yellow("\n Some hooks are not properly installed"));
|
|
8309
|
-
console.log(chalk22.dim(" Run: workflow scope hooks install"));
|
|
8310
|
-
process.exit(1);
|
|
8311
|
-
}
|
|
8312
|
-
console.log(chalk22.green("\n\u2713 All hooks are properly installed"));
|
|
8313
|
-
}
|
|
8314
8378
|
function createScopeCommand() {
|
|
8315
|
-
const scopeCmd = new Command6("scope").description("Manage custom scope packages
|
|
8379
|
+
const scopeCmd = new Command6("scope").description("Manage custom scope packages").addHelpText(
|
|
8316
8380
|
"after",
|
|
8317
8381
|
`
|
|
8318
8382
|
${chalk22.bold("Examples:")}
|
|
@@ -8322,7 +8386,6 @@ ${chalk22.bold("Examples:")}
|
|
|
8322
8386
|
$ workflow scope add auth ${chalk22.dim("# Add auth scope")}
|
|
8323
8387
|
$ workflow scope remove legacy ${chalk22.dim("# Remove legacy scope")}
|
|
8324
8388
|
$ workflow scope analyze ${chalk22.dim("# Analyze scope usage")}
|
|
8325
|
-
$ workflow scope hooks install ${chalk22.dim("# Install git hooks")}
|
|
8326
8389
|
`
|
|
8327
8390
|
).action(() => {
|
|
8328
8391
|
scopeListCommand();
|
|
@@ -8386,22 +8449,6 @@ ${chalk22.bold("Details:")}
|
|
|
8386
8449
|
- Unknown scopes that could be added
|
|
8387
8450
|
`
|
|
8388
8451
|
).action(scopeAnalyzeCommand);
|
|
8389
|
-
const hooksCmd = scopeCmd.command("hooks").description("Manage git hooks for the project").addHelpText(
|
|
8390
|
-
"after",
|
|
8391
|
-
`
|
|
8392
|
-
${chalk22.bold("Examples:")}
|
|
8393
|
-
$ workflow scope hooks install ${chalk22.dim("# Install git hooks")}
|
|
8394
|
-
$ workflow scope hooks uninstall ${chalk22.dim("# Remove git hooks")}
|
|
8395
|
-
$ workflow scope hooks test ${chalk22.dim("# Verify installation")}
|
|
8396
|
-
$ workflow scope hooks test --dry-run ${chalk22.dim("# Test with simulation")}
|
|
8397
|
-
`
|
|
8398
|
-
).action(() => {
|
|
8399
|
-
hooksCommand("status");
|
|
8400
|
-
});
|
|
8401
|
-
hooksCmd.command("install").description("Install git hooks for the project").action(() => hooksCommand("install"));
|
|
8402
|
-
hooksCmd.command("uninstall").description("Remove installed git hooks").action(() => hooksCommand("uninstall"));
|
|
8403
|
-
hooksCmd.command("status").description("Show current hooks installation status").action(() => hooksCommand("status"));
|
|
8404
|
-
hooksCmd.command("test").description("Test that hooks are properly installed").option("--dry-run", "Simulate hook execution without making changes").action(hooksTestCommand);
|
|
8405
8452
|
return scopeCmd;
|
|
8406
8453
|
}
|
|
8407
8454
|
|
|
@@ -8424,6 +8471,7 @@ program.addCommand(createDocsCommand());
|
|
|
8424
8471
|
program.addCommand(createSolutionCommand());
|
|
8425
8472
|
program.addCommand(createLearnCommand());
|
|
8426
8473
|
program.addCommand(createScopeCommand());
|
|
8474
|
+
program.addCommand(createHooksCommand());
|
|
8427
8475
|
program.command("sync").description("Sync patterns and solutions with the community registry").option("--push", "Push local patterns to registry").option("--pull", "Pull patterns from registry").option("--solutions", "Include solution patterns").option("--learn", "Include learning patterns (default)").option("--scopes", "Sync custom scope packages").option("--all", "Sync everything").option("--dry-run", "Preview without syncing").option("--enable-sync", "Enable pattern sync").option("--disable-sync", "Disable pattern sync").addHelpText(
|
|
8428
8476
|
"after",
|
|
8429
8477
|
`
|
|
@@ -8492,16 +8540,16 @@ program.command("suggest").description("Submit an improvement suggestion").argum
|
|
|
8492
8540
|
).action(suggestCommand);
|
|
8493
8541
|
program.addCommand(createSetupCommand());
|
|
8494
8542
|
program.command("doctor").description("Run health check and get optimization suggestions").option("--check-guidelines-only", "Only check guidelines presence").option("--fix", "Automatically fix validation issues in configuration").action(doctorCommand);
|
|
8495
|
-
program.command("hooks:install", { hidden: true }).description("[DEPRECATED] Use: workflow
|
|
8496
|
-
deprecationWarning("workflow hooks:install", "workflow
|
|
8543
|
+
program.command("hooks:install", { hidden: true }).description("[DEPRECATED] Use: workflow hooks install").action(async () => {
|
|
8544
|
+
deprecationWarning("workflow hooks:install", "workflow hooks install");
|
|
8497
8545
|
return hooksCommand("install");
|
|
8498
8546
|
});
|
|
8499
|
-
program.command("hooks:uninstall", { hidden: true }).description("[DEPRECATED] Use: workflow
|
|
8500
|
-
deprecationWarning("workflow hooks:uninstall", "workflow
|
|
8547
|
+
program.command("hooks:uninstall", { hidden: true }).description("[DEPRECATED] Use: workflow hooks uninstall").action(async () => {
|
|
8548
|
+
deprecationWarning("workflow hooks:uninstall", "workflow hooks uninstall");
|
|
8501
8549
|
return hooksCommand("uninstall");
|
|
8502
8550
|
});
|
|
8503
|
-
program.command("hooks:status", { hidden: true }).description("[DEPRECATED] Use: workflow
|
|
8504
|
-
deprecationWarning("workflow hooks:status", "workflow
|
|
8551
|
+
program.command("hooks:status", { hidden: true }).description("[DEPRECATED] Use: workflow hooks status").action(async () => {
|
|
8552
|
+
deprecationWarning("workflow hooks:status", "workflow hooks status");
|
|
8505
8553
|
return hooksCommand("status");
|
|
8506
8554
|
});
|
|
8507
8555
|
program.command("scope:create", { hidden: true }).description("[DEPRECATED] Use: workflow scope create").option("--name <name>", 'Package name (e.g., "fintech", "gaming")').option(
|