workflow-agent-cli 2.23.0 → 2.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/dist/{auto-fix-7WAESKYO.js → auto-fix-WGRYEFLJ.js} +2 -2
- package/dist/{chunk-IWFUJ2DS.js → chunk-DWHIY7R4.js} +20 -9
- package/dist/chunk-DWHIY7R4.js.map +1 -0
- package/dist/{chunk-M6RHIUSM.js → chunk-K42R54II.js} +147 -54
- package/dist/chunk-K42R54II.js.map +1 -0
- package/dist/{chunk-XGS2VFBP.js → chunk-KJFRMHQU.js} +783 -18
- package/dist/chunk-KJFRMHQU.js.map +1 -0
- package/dist/{chunk-YELUGXOM.js → chunk-NPJJZHJG.js} +1 -1
- package/dist/chunk-NPJJZHJG.js.map +1 -0
- package/dist/{chunk-UWJ2ZGEI.js → chunk-OH6TK27N.js} +3 -3
- package/dist/{chunk-D36IFZUZ.js → chunk-PLVOGB6Y.js} +15 -4
- package/dist/chunk-PLVOGB6Y.js.map +1 -0
- package/dist/{chunk-ZLDJ2OGO.js → chunk-WK7D2AVV.js} +11 -3
- package/dist/{chunk-ZLDJ2OGO.js.map → chunk-WK7D2AVV.js.map} +1 -1
- package/dist/cli/index.js +771 -285
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/index.d.ts +78 -56
- package/dist/index.js +22 -10
- package/dist/scripts/postinstall.js +1 -1
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/sync-HHQM3GKR.js +7 -0
- package/dist/validators/index.js +1 -1
- package/dist/verify-OIHY7SGG.js +8 -0
- package/package.json +2 -2
- package/dist/chunk-3ADL5QDN.js +0 -396
- package/dist/chunk-3ADL5QDN.js.map +0 -1
- package/dist/chunk-D36IFZUZ.js.map +0 -1
- package/dist/chunk-IWFUJ2DS.js.map +0 -1
- package/dist/chunk-M6RHIUSM.js.map +0 -1
- package/dist/chunk-XGS2VFBP.js.map +0 -1
- package/dist/chunk-YELUGXOM.js.map +0 -1
- package/dist/sync-6T5TD4QS.js +0 -7
- package/dist/verify-TX6LFMI6.js +0 -8
- /package/dist/{auto-fix-7WAESKYO.js.map → auto-fix-WGRYEFLJ.js.map} +0 -0
- /package/dist/{chunk-UWJ2ZGEI.js.map → chunk-OH6TK27N.js.map} +0 -0
- /package/dist/{sync-6T5TD4QS.js.map → sync-HHQM3GKR.js.map} +0 -0
- /package/dist/{verify-TX6LFMI6.js.map → verify-OIHY7SGG.js.map} +0 -0
package/README.md
CHANGED
|
@@ -266,27 +266,27 @@ Workflow Agent provides guideline templates that are installed to your project's
|
|
|
266
266
|
|
|
267
267
|
These templates are automatically installed during `workflow init` and `workflow setup`:
|
|
268
268
|
|
|
269
|
-
| Template
|
|
270
|
-
|
|
269
|
+
| Template | Purpose |
|
|
270
|
+
| ------------------------------- | ---------------------------------------------------------------- |
|
|
271
271
|
| `AGENT_EDITING_INSTRUCTIONS.md` | Core rules for AI agents: implementation plans, coding standards |
|
|
272
|
-
| `BRANCHING_STRATEGY.md`
|
|
273
|
-
| `TESTING_STRATEGY.md`
|
|
274
|
-
| `SELF_IMPROVEMENT_MANDATE.md`
|
|
275
|
-
| `PATTERN_ANALYSIS_WORKFLOW.md`
|
|
276
|
-
| `SINGLE_SOURCE_OF_TRUTH.md`
|
|
277
|
-
| `LIBRARY_INVENTORY.md`
|
|
272
|
+
| `BRANCHING_STRATEGY.md` | Git branch naming conventions, PR requirements |
|
|
273
|
+
| `TESTING_STRATEGY.md` | Testing pyramid, patterns, when tests are required |
|
|
274
|
+
| `SELF_IMPROVEMENT_MANDATE.md` | Continuous improvement tracking, changelog requirements |
|
|
275
|
+
| `PATTERN_ANALYSIS_WORKFLOW.md` | AI workflow for analyzing and extracting patterns |
|
|
276
|
+
| `SINGLE_SOURCE_OF_TRUTH.md` | Canonical code locations, avoiding duplication |
|
|
277
|
+
| `LIBRARY_INVENTORY.md` | Dependency catalog, approved libraries, new library process |
|
|
278
278
|
|
|
279
279
|
### Optional Templates
|
|
280
280
|
|
|
281
281
|
Additional templates available via `workflow update-templates --force`:
|
|
282
282
|
|
|
283
|
-
| Template
|
|
284
|
-
|
|
285
|
-
| `DEPLOYMENT_STRATEGY.md`
|
|
286
|
-
| `COMPONENT_LIBRARY.md`
|
|
287
|
-
| `SCOPE_CREATION_WORKFLOW.md` | Workflow for creating custom scopes
|
|
288
|
-
| `CUSTOM_SCOPE_TEMPLATE.md`
|
|
289
|
-
| `PROJECT_TEMPLATE_README.md` | Meta-document describing project structure
|
|
283
|
+
| Template | Purpose |
|
|
284
|
+
| ---------------------------- | --------------------------------------------- |
|
|
285
|
+
| `DEPLOYMENT_STRATEGY.md` | Deployment workflow, environments, migrations |
|
|
286
|
+
| `COMPONENT_LIBRARY.md` | UI component patterns, design tokens |
|
|
287
|
+
| `SCOPE_CREATION_WORKFLOW.md` | Workflow for creating custom scopes |
|
|
288
|
+
| `CUSTOM_SCOPE_TEMPLATE.md` | Template for scope package definitions |
|
|
289
|
+
| `PROJECT_TEMPLATE_README.md` | Meta-document describing project structure |
|
|
290
290
|
|
|
291
291
|
### Updating Templates
|
|
292
292
|
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
applyAutoFixes,
|
|
4
4
|
autoFixConfigFile,
|
|
5
5
|
writeFixedConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NPJJZHJG.js";
|
|
7
7
|
export {
|
|
8
8
|
analyzeValidationError,
|
|
9
9
|
applyAutoFixes,
|
|
10
10
|
autoFixConfigFile,
|
|
11
11
|
writeFixedConfig
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=auto-fix-
|
|
13
|
+
//# sourceMappingURL=auto-fix-WGRYEFLJ.js.map
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// src/scripts/copilot-instructions-generator.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
readFileSync,
|
|
4
|
+
writeFileSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
readdirSync,
|
|
7
|
+
mkdirSync
|
|
8
|
+
} from "fs";
|
|
3
9
|
import { join, basename } from "path";
|
|
4
10
|
var CUSTOM_START_MARKER = "<!-- CUSTOM START -->";
|
|
5
11
|
var CUSTOM_END_MARKER = "<!-- CUSTOM END -->";
|
|
@@ -59,7 +65,9 @@ function extractKeyRules(content, maxRules = 5) {
|
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
|
-
const rulesSectionMatch = content.match(
|
|
68
|
+
const rulesSectionMatch = content.match(
|
|
69
|
+
/##\s+(?:.*(?:Rules?|Requirements?|Guidelines?|Standards?)[^\n]*)\n([\s\S]*?)(?=\n##|\n#|$)/i
|
|
70
|
+
);
|
|
63
71
|
if (rulesSectionMatch) {
|
|
64
72
|
const section = rulesSectionMatch[1];
|
|
65
73
|
const listItems = section.match(/^\s*[-*\d.]+\s+(.+)$/gm);
|
|
@@ -72,7 +80,9 @@ function extractKeyRules(content, maxRules = 5) {
|
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
|
-
const importantMatch = content.match(
|
|
83
|
+
const importantMatch = content.match(
|
|
84
|
+
/(?:Important|Critical|Key|Essential)[:\s]+([^\n]+)/gi
|
|
85
|
+
);
|
|
76
86
|
if (importantMatch) {
|
|
77
87
|
for (const match of importantMatch.slice(0, 2)) {
|
|
78
88
|
const cleaned = match.replace(/^(?:Important|Critical|Key|Essential)[:\s]+/i, "").trim();
|
|
@@ -127,10 +137,7 @@ function extractCustomContent(existingContent) {
|
|
|
127
137
|
const startIndex = existingContent.indexOf(CUSTOM_START_MARKER);
|
|
128
138
|
const endIndex = existingContent.indexOf(CUSTOM_END_MARKER);
|
|
129
139
|
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
|
|
130
|
-
return existingContent.slice(
|
|
131
|
-
startIndex + CUSTOM_START_MARKER.length,
|
|
132
|
-
endIndex
|
|
133
|
-
).trim();
|
|
140
|
+
return existingContent.slice(startIndex + CUSTOM_START_MARKER.length, endIndex).trim();
|
|
134
141
|
}
|
|
135
142
|
return null;
|
|
136
143
|
}
|
|
@@ -312,7 +319,11 @@ function generateCopilotInstructions(projectRoot, options = {}) {
|
|
|
312
319
|
const existingContent = readFileSync(outputPath, "utf-8");
|
|
313
320
|
customContent = extractCustomContent(existingContent);
|
|
314
321
|
}
|
|
315
|
-
const content = generateInstructionsContent(
|
|
322
|
+
const content = generateInstructionsContent(
|
|
323
|
+
config,
|
|
324
|
+
guidelines,
|
|
325
|
+
customContent
|
|
326
|
+
);
|
|
316
327
|
if (!existsSync(githubDir)) {
|
|
317
328
|
mkdirSync(githubDir, { recursive: true });
|
|
318
329
|
}
|
|
@@ -739,4 +750,4 @@ export {
|
|
|
739
750
|
installMandatoryTemplates,
|
|
740
751
|
updateTemplates
|
|
741
752
|
};
|
|
742
|
-
//# sourceMappingURL=chunk-
|
|
753
|
+
//# sourceMappingURL=chunk-DWHIY7R4.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 {\n readFileSync,\n writeFileSync,\n existsSync,\n readdirSync,\n mkdirSync,\n} 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 =\n \"<!-- 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 (\n line.startsWith(\"#\") ||\n line.startsWith(\"---\") ||\n line.startsWith(\"##\")\n ) {\n break;\n }\n description += line.trim() + \" \";\n // Take only first meaningful paragraph\n if (description.length > 150) break;\n }\n }\n\n return (\n description.trim().slice(0, 200) + (description.length > 200 ? \"...\" : \"\")\n );\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\n .replace(/\\*\\*/g, \"\")\n .replace(/^[-*]\\s*/, \"\")\n .trim();\n if (\n cleaned.length > 10 &&\n cleaned.length < 150 &&\n !rules.includes(cleaned)\n ) {\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(\n /##\\s+(?:.*(?:Rules?|Requirements?|Guidelines?|Standards?)[^\\n]*)\\n([\\s\\S]*?)(?=\\n##|\\n#|$)/i,\n );\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 (\n cleaned.length > 10 &&\n cleaned.length < 150 &&\n !rules.includes(cleaned)\n ) {\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(\n /(?:Important|Critical|Key|Essential)[:\\s]+([^\\n]+)/gi,\n );\n if (importantMatch) {\n for (const match of importantMatch.slice(0, 2)) {\n const cleaned = match\n .replace(/^(?:Important|Critical|Key|Essential)[:\\s]+/i, \"\")\n .trim();\n if (\n cleaned.length > 10 &&\n cleaned.length < 150 &&\n !rules.includes(cleaned)\n ) {\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 (\n cleaned.length > 15 &&\n cleaned.length < 150 &&\n !rules.includes(cleaned)\n ) {\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\n .slice(startIndex + CUSTOM_START_MARKER.length, 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${\n customContent ||\n `\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}\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(\n config,\n guidelines,\n customContent,\n );\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 * 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;AAAA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;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"]}
|
|
@@ -36,17 +36,14 @@ var RegistryClient = class {
|
|
|
36
36
|
hash: p2.hash
|
|
37
37
|
}))
|
|
38
38
|
};
|
|
39
|
-
const response = await this.request(
|
|
40
|
-
"
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
body: JSON.stringify(payload)
|
|
48
|
-
}
|
|
49
|
-
);
|
|
39
|
+
const response = await this.request("/api/patterns/push", {
|
|
40
|
+
method: "POST",
|
|
41
|
+
headers: {
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
"x-contributor-id": contributorId
|
|
44
|
+
},
|
|
45
|
+
body: JSON.stringify(payload)
|
|
46
|
+
});
|
|
50
47
|
return response;
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
@@ -205,11 +202,17 @@ async function syncCommand(options) {
|
|
|
205
202
|
const enableResult = await contributorManager.enableSync();
|
|
206
203
|
if (enableResult.success) {
|
|
207
204
|
console.log(chalk.green("\n\u2705 Sync enabled!"));
|
|
208
|
-
console.log(
|
|
205
|
+
console.log(
|
|
206
|
+
chalk.dim(
|
|
207
|
+
" Your anonymized patterns can now be shared with the community.\n"
|
|
208
|
+
)
|
|
209
|
+
);
|
|
209
210
|
} else {
|
|
210
|
-
console.log(
|
|
211
|
+
console.log(
|
|
212
|
+
chalk.red(`
|
|
211
213
|
\u274C Failed to enable sync: ${enableResult.error}
|
|
212
|
-
`)
|
|
214
|
+
`)
|
|
215
|
+
);
|
|
213
216
|
process.exit(1);
|
|
214
217
|
}
|
|
215
218
|
if (!options.push && !options.pull && !options.all && !options.solutions && !options.scopes) {
|
|
@@ -223,9 +226,11 @@ async function syncCommand(options) {
|
|
|
223
226
|
console.log(chalk.green("\n\u2705 Sync disabled!"));
|
|
224
227
|
console.log(chalk.dim(" Your patterns will no longer be shared.\n"));
|
|
225
228
|
} else {
|
|
226
|
-
console.log(
|
|
229
|
+
console.log(
|
|
230
|
+
chalk.red(`
|
|
227
231
|
\u274C Failed to disable sync: ${disableResult.error}
|
|
228
|
-
`)
|
|
232
|
+
`)
|
|
233
|
+
);
|
|
229
234
|
process.exit(1);
|
|
230
235
|
}
|
|
231
236
|
p.outro(chalk.green("Sync disabled"));
|
|
@@ -271,11 +276,17 @@ async function syncCommand(options) {
|
|
|
271
276
|
console.log(chalk.yellow("\n\u{1F4CB} DRY-RUN MODE: No changes will be synced\n"));
|
|
272
277
|
}
|
|
273
278
|
console.log(chalk.cyan("\n\u{1F4E6} Syncing:"));
|
|
274
|
-
if (syncLearn)
|
|
279
|
+
if (syncLearn)
|
|
280
|
+
console.log(chalk.dim(" \u2022 Learning patterns (fixes, blueprints)"));
|
|
275
281
|
if (syncSolutions) console.log(chalk.dim(" \u2022 Solution patterns"));
|
|
276
282
|
if (syncScopes) console.log(chalk.dim(" \u2022 Custom scopes"));
|
|
277
|
-
console.log(
|
|
278
|
-
|
|
283
|
+
console.log(
|
|
284
|
+
chalk.dim(
|
|
285
|
+
` \u2022 Direction: ${direction === "both" ? "push + pull" : direction}`
|
|
286
|
+
)
|
|
287
|
+
);
|
|
288
|
+
if (options.includePrivate)
|
|
289
|
+
console.log(chalk.dim(" \u2022 Including private patterns"));
|
|
279
290
|
console.log("");
|
|
280
291
|
const store = new PatternStore(cwd);
|
|
281
292
|
await store.initialize();
|
|
@@ -291,10 +302,18 @@ async function syncCommand(options) {
|
|
|
291
302
|
const privateFixes = stats.privateFixes;
|
|
292
303
|
const privateBlueprints = stats.privateBlueprints;
|
|
293
304
|
const privateSolutions = stats.privateSolutions;
|
|
305
|
+
void totalLocalFixes;
|
|
306
|
+
void totalLocalBlueprints;
|
|
307
|
+
void totalLocalSolutions;
|
|
308
|
+
void privateBlueprints;
|
|
294
309
|
if (options.includePrivate) {
|
|
295
310
|
const allFixes = await store.listFixPatterns({ includeDeprecated: false });
|
|
296
|
-
const allBlueprints = await store.listBlueprints({
|
|
297
|
-
|
|
311
|
+
const allBlueprints = await store.listBlueprints({
|
|
312
|
+
includeDeprecated: false
|
|
313
|
+
});
|
|
314
|
+
const allSolutions = await store.listSolutions({
|
|
315
|
+
includeDeprecated: false
|
|
316
|
+
});
|
|
298
317
|
fixes = allFixes.data ?? [];
|
|
299
318
|
blueprints = allBlueprints.data ?? [];
|
|
300
319
|
solutions = allSolutions.data ?? [];
|
|
@@ -304,12 +323,28 @@ async function syncCommand(options) {
|
|
|
304
323
|
const publicCount = fixes.length;
|
|
305
324
|
const privateCount = privateFixes;
|
|
306
325
|
if (options.includePrivate) {
|
|
307
|
-
console.log(
|
|
326
|
+
console.log(
|
|
327
|
+
chalk.dim(
|
|
328
|
+
` Found ${publicCount} fixes, ${blueprints.length} blueprints to sync (including private)`
|
|
329
|
+
)
|
|
330
|
+
);
|
|
308
331
|
} else if (publicCount === 0 && privateCount > 0) {
|
|
309
|
-
console.log(
|
|
310
|
-
|
|
332
|
+
console.log(
|
|
333
|
+
chalk.yellow(
|
|
334
|
+
` Found 0 fixes ready to sync (${privateCount} are private)`
|
|
335
|
+
)
|
|
336
|
+
);
|
|
337
|
+
console.log(
|
|
338
|
+
chalk.dim(
|
|
339
|
+
` Use --include-private to include them, or run 'workflow learn migrate --public'`
|
|
340
|
+
)
|
|
341
|
+
);
|
|
311
342
|
} else {
|
|
312
|
-
console.log(
|
|
343
|
+
console.log(
|
|
344
|
+
chalk.dim(
|
|
345
|
+
` Found ${publicCount} fixes, ${blueprints.length} blueprints ready to sync`
|
|
346
|
+
)
|
|
347
|
+
);
|
|
313
348
|
}
|
|
314
349
|
for (const fix of fixes) {
|
|
315
350
|
const result = anonymizer.anonymizeFixPattern(fix);
|
|
@@ -336,33 +371,67 @@ async function syncCommand(options) {
|
|
|
336
371
|
const publicCount = solutions.length;
|
|
337
372
|
const privateCount = privateSolutions;
|
|
338
373
|
if (options.includePrivate) {
|
|
339
|
-
console.log(
|
|
374
|
+
console.log(
|
|
375
|
+
chalk.dim(
|
|
376
|
+
` Found ${publicCount} solutions to sync (including private)`
|
|
377
|
+
)
|
|
378
|
+
);
|
|
340
379
|
} else if (publicCount === 0 && privateCount > 0 && !options.dryRun) {
|
|
341
|
-
console.log(
|
|
380
|
+
console.log(
|
|
381
|
+
chalk.yellow(
|
|
382
|
+
` Found 0 solutions ready to sync (${privateCount} are private)`
|
|
383
|
+
)
|
|
384
|
+
);
|
|
342
385
|
const shouldMigrate = await p.confirm({
|
|
343
386
|
message: `Would you like to make your ${privateCount} solution(s) public for sync?`
|
|
344
387
|
});
|
|
345
388
|
if (p.isCancel(shouldMigrate) || !shouldMigrate) {
|
|
346
|
-
console.log(
|
|
389
|
+
console.log(
|
|
390
|
+
chalk.dim(
|
|
391
|
+
` Skipping private solutions. Use --include-private to force include them.`
|
|
392
|
+
)
|
|
393
|
+
);
|
|
347
394
|
} else {
|
|
348
|
-
const allSolutions = await store.listSolutions({
|
|
395
|
+
const allSolutions = await store.listSolutions({
|
|
396
|
+
includeDeprecated: false
|
|
397
|
+
});
|
|
349
398
|
for (const sol of allSolutions.data ?? []) {
|
|
350
399
|
if (sol.isPrivate) {
|
|
351
|
-
const updated = {
|
|
400
|
+
const updated = {
|
|
401
|
+
...sol,
|
|
402
|
+
isPrivate: false,
|
|
403
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
404
|
+
};
|
|
352
405
|
await store.saveSolution(updated);
|
|
353
406
|
solutions.push(updated);
|
|
354
407
|
}
|
|
355
408
|
}
|
|
356
|
-
console.log(
|
|
409
|
+
console.log(
|
|
410
|
+
chalk.green(` \u2713 Migrated ${privateCount} solutions to public`)
|
|
411
|
+
);
|
|
357
412
|
}
|
|
358
413
|
} else if (publicCount === 0 && privateCount > 0) {
|
|
359
|
-
console.log(
|
|
360
|
-
|
|
414
|
+
console.log(
|
|
415
|
+
chalk.yellow(
|
|
416
|
+
` Found 0 solutions ready to sync (${privateCount} are private)`
|
|
417
|
+
)
|
|
418
|
+
);
|
|
419
|
+
console.log(
|
|
420
|
+
chalk.dim(
|
|
421
|
+
` Use --include-private to include them, or run 'workflow solution migrate --public'`
|
|
422
|
+
)
|
|
423
|
+
);
|
|
361
424
|
} else if (publicCount === 0 && privateCount === 0) {
|
|
362
425
|
const validationErrors = store.getValidationErrors();
|
|
363
|
-
const solutionErrors = validationErrors.filter(
|
|
426
|
+
const solutionErrors = validationErrors.filter(
|
|
427
|
+
(e) => e.type === "solution"
|
|
428
|
+
);
|
|
364
429
|
if (solutionErrors.length > 0) {
|
|
365
|
-
console.log(
|
|
430
|
+
console.log(
|
|
431
|
+
chalk.yellow(
|
|
432
|
+
` Found 0 solutions (${solutionErrors.length} failed schema validation)`
|
|
433
|
+
)
|
|
434
|
+
);
|
|
366
435
|
for (const err of solutionErrors) {
|
|
367
436
|
console.log(chalk.dim(` \u2022 ${err.file}: ${err.error}`));
|
|
368
437
|
if (err.details) {
|
|
@@ -370,7 +439,11 @@ async function syncCommand(options) {
|
|
|
370
439
|
console.log(chalk.dim(` - ${detail}`));
|
|
371
440
|
}
|
|
372
441
|
if (err.details.length > 3) {
|
|
373
|
-
console.log(
|
|
442
|
+
console.log(
|
|
443
|
+
chalk.dim(
|
|
444
|
+
` ... and ${err.details.length - 3} more issues`
|
|
445
|
+
)
|
|
446
|
+
);
|
|
374
447
|
}
|
|
375
448
|
}
|
|
376
449
|
}
|
|
@@ -400,15 +473,21 @@ async function syncCommand(options) {
|
|
|
400
473
|
console.log(chalk.yellow(" No patterns to push\n"));
|
|
401
474
|
} else {
|
|
402
475
|
const fixCount = patternsToSync.filter((p2) => p2.type === "fix").length;
|
|
403
|
-
const bpCount = patternsToSync.filter(
|
|
404
|
-
|
|
476
|
+
const bpCount = patternsToSync.filter(
|
|
477
|
+
(p2) => p2.type === "blueprint"
|
|
478
|
+
).length;
|
|
479
|
+
const solutionCount = patternsToSync.filter(
|
|
480
|
+
(p2) => p2.type === "solution"
|
|
481
|
+
).length;
|
|
405
482
|
console.log(
|
|
406
483
|
chalk.dim(
|
|
407
484
|
` Ready to push: ${fixCount} fixes, ${bpCount} blueprints, ${solutionCount} solutions`
|
|
408
485
|
)
|
|
409
486
|
);
|
|
410
487
|
if (options.dryRun) {
|
|
411
|
-
console.log(
|
|
488
|
+
console.log(
|
|
489
|
+
chalk.yellow("\n [DRY-RUN] Would push patterns to registry")
|
|
490
|
+
);
|
|
412
491
|
} else {
|
|
413
492
|
const contributorResult = await contributorManager.getOrCreateId();
|
|
414
493
|
if (!contributorResult.success || !contributorResult.data) {
|
|
@@ -440,8 +519,10 @@ async function syncCommand(options) {
|
|
|
440
519
|
}
|
|
441
520
|
}
|
|
442
521
|
console.log(
|
|
443
|
-
chalk.green(
|
|
444
|
-
|
|
522
|
+
chalk.green(
|
|
523
|
+
`
|
|
524
|
+
\u2705 Pushed ${pushResult.pushed} patterns to registry`
|
|
525
|
+
)
|
|
445
526
|
);
|
|
446
527
|
if (pushResult.skipped > 0) {
|
|
447
528
|
console.log(
|
|
@@ -465,9 +546,7 @@ async function syncCommand(options) {
|
|
|
465
546
|
if (error instanceof RateLimitedException) {
|
|
466
547
|
console.log(chalk.red("\n \u274C Rate limit exceeded"));
|
|
467
548
|
console.log(
|
|
468
|
-
chalk.dim(
|
|
469
|
-
` Try again in ${error.getTimeUntilReset()}`
|
|
470
|
-
)
|
|
549
|
+
chalk.dim(` Try again in ${error.getTimeUntilReset()}`)
|
|
471
550
|
);
|
|
472
551
|
} else if (error instanceof RegistryError) {
|
|
473
552
|
console.log(chalk.red(`
|
|
@@ -488,7 +567,9 @@ async function syncCommand(options) {
|
|
|
488
567
|
if (direction === "pull" || direction === "both") {
|
|
489
568
|
console.log(chalk.cyan("\n\u{1F4E5} Pulling patterns from registry...\n"));
|
|
490
569
|
if (options.dryRun) {
|
|
491
|
-
console.log(
|
|
570
|
+
console.log(
|
|
571
|
+
chalk.yellow(" [DRY-RUN] Would pull patterns from registry")
|
|
572
|
+
);
|
|
492
573
|
} else {
|
|
493
574
|
const registryClient = new RegistryClient();
|
|
494
575
|
try {
|
|
@@ -532,31 +613,43 @@ async function syncCommand(options) {
|
|
|
532
613
|
}
|
|
533
614
|
}
|
|
534
615
|
if (syncSolutions && typeCounts["solution"] !== void 0) {
|
|
535
|
-
console.log(
|
|
616
|
+
console.log(
|
|
617
|
+
chalk.dim(
|
|
618
|
+
` Registry has ${typeCounts["solution"]} solution(s) available`
|
|
619
|
+
)
|
|
620
|
+
);
|
|
536
621
|
}
|
|
537
622
|
if (syncLearn) {
|
|
538
623
|
const fixCount = typeCounts["fix"] ?? 0;
|
|
539
624
|
const bpCount = typeCounts["blueprint"] ?? 0;
|
|
540
|
-
console.log(
|
|
625
|
+
console.log(
|
|
626
|
+
chalk.dim(
|
|
627
|
+
` Registry has ${fixCount} fix(es), ${bpCount} blueprint(s) available`
|
|
628
|
+
)
|
|
629
|
+
);
|
|
541
630
|
}
|
|
542
631
|
if (totalPatterns === 0) {
|
|
543
632
|
console.log(chalk.dim(" No new patterns to pull"));
|
|
544
633
|
} else {
|
|
545
634
|
console.log(
|
|
546
|
-
chalk.green(
|
|
547
|
-
|
|
635
|
+
chalk.green(
|
|
636
|
+
`
|
|
637
|
+
\u2705 Pulled ${savedCount} new patterns from registry`
|
|
638
|
+
)
|
|
548
639
|
);
|
|
549
640
|
if (savedCount < totalPatterns) {
|
|
550
|
-
console.log(
|
|
641
|
+
console.log(
|
|
642
|
+
chalk.dim(
|
|
643
|
+
` (${totalPatterns - savedCount} already existed locally)`
|
|
644
|
+
)
|
|
645
|
+
);
|
|
551
646
|
}
|
|
552
647
|
}
|
|
553
648
|
} catch (error) {
|
|
554
649
|
if (error instanceof RateLimitedException) {
|
|
555
650
|
console.log(chalk.red("\n \u274C Rate limit exceeded"));
|
|
556
651
|
console.log(
|
|
557
|
-
chalk.dim(
|
|
558
|
-
` Try again in ${error.getTimeUntilReset()}`
|
|
559
|
-
)
|
|
652
|
+
chalk.dim(` Try again in ${error.getTimeUntilReset()}`)
|
|
560
653
|
);
|
|
561
654
|
} else if (error instanceof RegistryError) {
|
|
562
655
|
console.log(chalk.red(`
|
|
@@ -579,4 +672,4 @@ async function syncCommand(options) {
|
|
|
579
672
|
export {
|
|
580
673
|
syncCommand
|
|
581
674
|
};
|
|
582
|
-
//# sourceMappingURL=chunk-
|
|
675
|
+
//# sourceMappingURL=chunk-K42R54II.js.map
|