workflow-agent-cli 2.21.2 → 2.22.0

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.
@@ -1 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ declare function isGlobalInstall(): boolean;
3
+ declare function findProjectRoot(): string | null;
4
+ declare function removeDeprecatedScripts(scripts: Record<string, string>): string[];
5
+ declare function addWorkflowScript(scripts: Record<string, string>): {
6
+ added: boolean;
7
+ updated: boolean;
8
+ };
9
+ declare function addScriptsToPackageJson(): void;
10
+
11
+ export { addScriptsToPackageJson, addWorkflowScript, findProjectRoot, isGlobalInstall, removeDeprecatedScripts };
@@ -1,16 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  DEPRECATED_SCRIPTS,
4
- SCRIPT_CATEGORIES,
5
- TOTAL_SCRIPTS,
6
- VALID_COMMANDS,
7
4
  WORKFLOW_SCRIPTS,
8
5
  WORKFLOW_SCRIPTS_VERSION,
9
6
  findTemplatesDirectory,
10
7
  generateCopilotInstructions,
11
8
  installMandatoryTemplates,
12
9
  validateAllScripts
13
- } from "../chunk-YR2X64TH.js";
10
+ } from "../chunk-WR3AL26Z.js";
14
11
 
15
12
  // src/scripts/postinstall.ts
16
13
  import { readFileSync, writeFileSync, existsSync } from "fs";
@@ -32,6 +29,37 @@ function findProjectRoot() {
32
29
  }
33
30
  return null;
34
31
  }
32
+ function removeDeprecatedScripts(scripts) {
33
+ const removedScripts = [];
34
+ for (const deprecatedScript of DEPRECATED_SCRIPTS) {
35
+ if (scripts[deprecatedScript] !== void 0) {
36
+ delete scripts[deprecatedScript];
37
+ removedScripts.push(deprecatedScript);
38
+ }
39
+ }
40
+ const oldScripts = validateAllScripts(scripts);
41
+ for (const oldScript of oldScripts) {
42
+ if (scripts[oldScript] !== void 0) {
43
+ delete scripts[oldScript];
44
+ if (!removedScripts.includes(oldScript)) {
45
+ removedScripts.push(oldScript);
46
+ }
47
+ }
48
+ }
49
+ return removedScripts;
50
+ }
51
+ function addWorkflowScript(scripts) {
52
+ const scriptName = "workflow";
53
+ const scriptCommand = WORKFLOW_SCRIPTS.workflow;
54
+ if (!scripts[scriptName]) {
55
+ scripts[scriptName] = scriptCommand;
56
+ return { added: true, updated: false };
57
+ } else if (scripts[scriptName] !== scriptCommand) {
58
+ scripts[scriptName] = scriptCommand;
59
+ return { added: false, updated: true };
60
+ }
61
+ return { added: false, updated: false };
62
+ }
35
63
  function addScriptsToPackageJson() {
36
64
  try {
37
65
  if (isGlobalInstall()) {
@@ -50,95 +78,48 @@ function addScriptsToPackageJson() {
50
78
  if (!packageJson.scripts) {
51
79
  packageJson.scripts = {};
52
80
  }
53
- const addedScripts = [];
54
- const updatedScripts = [];
55
- const removedScripts = [];
56
- for (const deprecatedScript of DEPRECATED_SCRIPTS) {
57
- if (packageJson.scripts[deprecatedScript] !== void 0) {
58
- delete packageJson.scripts[deprecatedScript];
59
- removedScripts.push(deprecatedScript);
60
- }
61
- }
62
- const existingWorkflowScripts = Object.keys(packageJson.scripts).filter(
63
- (name) => name.startsWith("workflow:")
64
- );
65
- const invalidScripts = validateAllScripts(
66
- Object.fromEntries(existingWorkflowScripts.map((s) => [s, ""]))
67
- );
68
- if (invalidScripts.length > 0) {
69
- console.log(
70
- `
71
- \u26A0\uFE0F Warning: Found ${invalidScripts.length} workflow scripts with non-standard naming:`
72
- );
73
- for (const script of invalidScripts) {
74
- console.log(` - ${script}`);
75
- }
76
- console.log(`
77
- Valid top-level commands are: ${VALID_COMMANDS.join(", ")}`);
78
- console.log(` Scripts must follow: workflow:<command>[-<action>[-<subaction>]]
79
- `);
80
- }
81
- for (const [scriptName, scriptCommand] of Object.entries(
82
- WORKFLOW_SCRIPTS
83
- )) {
84
- if (!packageJson.scripts[scriptName]) {
85
- packageJson.scripts[scriptName] = scriptCommand;
86
- addedScripts.push(scriptName);
87
- } else if (packageJson.scripts[scriptName] !== scriptCommand) {
88
- packageJson.scripts[scriptName] = scriptCommand;
89
- updatedScripts.push(scriptName);
90
- }
91
- }
92
- const totalChanges = addedScripts.length + updatedScripts.length + removedScripts.length;
93
- if (totalChanges > 0) {
81
+ const removedScripts = removeDeprecatedScripts(packageJson.scripts);
82
+ const { added, updated } = addWorkflowScript(packageJson.scripts);
83
+ const hasChanges = removedScripts.length > 0 || added || updated;
84
+ if (hasChanges) {
94
85
  writeFileSync(
95
86
  packageJsonPath,
96
87
  JSON.stringify(packageJson, null, 2) + "\n",
97
88
  "utf-8"
98
89
  );
99
- const summaryParts = [];
100
- if (addedScripts.length > 0) {
101
- summaryParts.push(`${addedScripts.length} new`);
102
- }
103
- if (updatedScripts.length > 0) {
104
- summaryParts.push(`${updatedScripts.length} updated`);
90
+ console.log(`
91
+ \u2713 Workflow Agent v${WORKFLOW_SCRIPTS_VERSION} configured`);
92
+ if (added) {
93
+ console.log(`
94
+ Added "workflow" script to package.json`);
95
+ } else if (updated) {
96
+ console.log(`
97
+ Updated "workflow" script in package.json`);
105
98
  }
106
99
  if (removedScripts.length > 0) {
107
- summaryParts.push(`${removedScripts.length} deprecated removed`);
108
- }
109
- console.log(
110
- `
111
- \u2713 Workflow scripts configured in package.json (${summaryParts.join(", ")}):`
112
- );
113
- if (removedScripts.length > 0) {
114
- console.log(`
115
- \u26A0\uFE0F Removed deprecated scripts:`);
116
- for (const script of removedScripts) {
117
- console.log(` - ${script}`);
118
- }
119
100
  console.log(
120
101
  `
121
- \u{1F4A1} Updated to workflow-agent v${WORKFLOW_SCRIPTS_VERSION} with new command syntax.`
102
+ \u26A0\uFE0F Removed ${removedScripts.length} deprecated scripts`
103
+ );
104
+ console.log(
105
+ ` (Old workflow:* scripts replaced by single "workflow" command)`
122
106
  );
123
- console.log(` Old: workflow-agent learn:list`);
124
- console.log(` New: workflow-agent learn list
125
- `);
126
- }
127
- for (const [category, scripts] of Object.entries(SCRIPT_CATEGORIES)) {
128
- console.log(`
129
- ${category}:`);
130
- for (const script of scripts) {
131
- const isNew = addedScripts.includes(script);
132
- const isUpdated = updatedScripts.includes(script);
133
- const marker = isNew ? " (new)" : isUpdated ? " (updated)" : "";
134
- console.log(` - ${script}${marker}`);
135
- }
136
107
  }
137
108
  console.log(`
138
- Total: ${TOTAL_SCRIPTS} scripts available`);
139
- console.log(
140
- "\nRun them with: npm run workflow:init (or pnpm run workflow:init)\n"
141
- );
109
+ Usage:`);
110
+ console.log(` npm run workflow -- init`);
111
+ console.log(` npm run workflow -- solution list`);
112
+ console.log(` npm run workflow -- --help`);
113
+ console.log(`
114
+ Or with pnpm:`);
115
+ console.log(` pnpm workflow init`);
116
+ console.log(` pnpm workflow solution list`);
117
+ console.log(` pnpm workflow --help`);
118
+ console.log(`
119
+ Or if installed globally:`);
120
+ console.log(` workflow-agent init`);
121
+ console.log(` workflow-agent --help
122
+ `);
142
123
  }
143
124
  const guidelinesDir = join(projectRoot, "guidelines");
144
125
  if (!existsSync(guidelinesDir)) {
@@ -172,4 +153,11 @@ function addScriptsToPackageJson() {
172
153
  }
173
154
  }
174
155
  addScriptsToPackageJson();
156
+ export {
157
+ addScriptsToPackageJson,
158
+ addWorkflowScript,
159
+ findProjectRoot,
160
+ isGlobalInstall,
161
+ removeDeprecatedScripts
162
+ };
175
163
  //# sourceMappingURL=postinstall.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/scripts/postinstall.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Post-install script that automatically adds workflow scripts to package.json\n * when installed as a local dependency (not global).\n *\n * On package update, this will also add any new scripts that were added in newer versions.\n */\n\nimport { readFileSync, writeFileSync, existsSync } from \"fs\";\nimport { join, dirname } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport {\n WORKFLOW_SCRIPTS,\n DEPRECATED_SCRIPTS,\n WORKFLOW_SCRIPTS_VERSION,\n SCRIPT_CATEGORIES,\n TOTAL_SCRIPTS,\n validateAllScripts,\n VALID_COMMANDS,\n} from \"./workflow-scripts.js\";\nimport { generateCopilotInstructions } from \"./copilot-instructions-generator.js\";\nimport {\n installMandatoryTemplates,\n findTemplatesDirectory,\n} from \"./template-installer.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nfunction isGlobalInstall(): boolean {\n // Check if we're being installed globally\n const installPath = process.env.npm_config_global;\n return installPath === \"true\";\n}\n\nfunction findProjectRoot(): string | null {\n // When installed as a dependency, npm/pnpm runs postinstall from the package directory\n // which is inside node_modules/@hawkinside_out/workflow-agent\n // We need to find the project root (the directory containing node_modules)\n\n const currentDir = process.cwd();\n\n // Check if we're inside node_modules\n if (currentDir.includes(\"node_modules\")) {\n // Split on 'node_modules' and take everything before it\n // This handles both node_modules/@scope/package and node_modules/package\n const parts = currentDir.split(\"node_modules\");\n if (parts.length > 0 && parts[0]) {\n // Remove trailing slash\n return parts[0].replace(/\\/$/, \"\");\n }\n }\n\n // If not in node_modules, we're probably in a monorepo workspace during development\n // Don't modify package.json in this case\n return null;\n}\n\nfunction addScriptsToPackageJson(): void {\n try {\n // Don't run for global installs\n if (isGlobalInstall()) {\n return;\n }\n\n const projectRoot = findProjectRoot();\n if (!projectRoot) {\n return;\n }\n\n const packageJsonPath = join(projectRoot, \"package.json\");\n\n if (!existsSync(packageJsonPath)) {\n return;\n }\n\n // Read existing package.json\n const packageJsonContent = readFileSync(packageJsonPath, \"utf-8\");\n const packageJson = JSON.parse(packageJsonContent);\n\n // Initialize scripts object if it doesn't exist\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n // Track changes\n const addedScripts: string[] = [];\n const updatedScripts: string[] = [];\n const removedScripts: string[] = [];\n\n // Step 1: Remove deprecated scripts\n for (const deprecatedScript of DEPRECATED_SCRIPTS) {\n if (packageJson.scripts[deprecatedScript] !== undefined) {\n delete packageJson.scripts[deprecatedScript];\n removedScripts.push(deprecatedScript);\n }\n }\n\n // Step 1.5: Validate existing workflow: scripts follow the naming pattern\n const existingWorkflowScripts = Object.keys(packageJson.scripts).filter(\n (name) => name.startsWith(\"workflow:\"),\n );\n const invalidScripts = validateAllScripts(\n Object.fromEntries(existingWorkflowScripts.map((s) => [s, \"\"])),\n );\n if (invalidScripts.length > 0) {\n console.log(\n `\\nāš ļø Warning: Found ${invalidScripts.length} workflow scripts with non-standard naming:`,\n );\n for (const script of invalidScripts) {\n console.log(` - ${script}`);\n }\n console.log(`\\n Valid top-level commands are: ${VALID_COMMANDS.join(\", \")}`);\n console.log(` Scripts must follow: workflow:<command>[-<action>[-<subaction>]]\\n`);\n }\n\n // Step 2: Add/update all workflow scripts (ensures updates get new scripts)\n for (const [scriptName, scriptCommand] of Object.entries(\n WORKFLOW_SCRIPTS,\n )) {\n if (!packageJson.scripts[scriptName]) {\n // Script doesn't exist - add it\n packageJson.scripts[scriptName] = scriptCommand;\n addedScripts.push(scriptName);\n } else if (packageJson.scripts[scriptName] !== scriptCommand) {\n // Script exists but has different value - update it\n packageJson.scripts[scriptName] = scriptCommand;\n updatedScripts.push(scriptName);\n }\n // If script exists with same value, do nothing (already up to date)\n }\n\n const totalChanges =\n addedScripts.length + updatedScripts.length + removedScripts.length;\n\n if (totalChanges > 0) {\n // Write back to package.json with proper formatting\n writeFileSync(\n packageJsonPath,\n JSON.stringify(packageJson, null, 2) + \"\\n\",\n \"utf-8\",\n );\n\n // Build summary message\n const summaryParts: string[] = [];\n if (addedScripts.length > 0) {\n summaryParts.push(`${addedScripts.length} new`);\n }\n if (updatedScripts.length > 0) {\n summaryParts.push(`${updatedScripts.length} updated`);\n }\n if (removedScripts.length > 0) {\n summaryParts.push(`${removedScripts.length} deprecated removed`);\n }\n\n console.log(\n `\\nāœ“ Workflow scripts configured in package.json (${summaryParts.join(\", \")}):`,\n );\n\n // Log removed deprecated scripts\n if (removedScripts.length > 0) {\n console.log(`\\n āš ļø Removed deprecated scripts:`);\n for (const script of removedScripts) {\n console.log(` - ${script}`);\n }\n console.log(\n `\\n šŸ’” Updated to workflow-agent v${WORKFLOW_SCRIPTS_VERSION} with new command syntax.`,\n );\n console.log(` Old: workflow-agent learn:list`);\n console.log(` New: workflow-agent learn list\\n`);\n }\n\n // Display scripts by category\n for (const [category, scripts] of Object.entries(SCRIPT_CATEGORIES)) {\n console.log(`\\n ${category}:`);\n for (const script of scripts) {\n const isNew = addedScripts.includes(script);\n const isUpdated = updatedScripts.includes(script);\n const marker = isNew ? \" (new)\" : isUpdated ? \" (updated)\" : \"\";\n console.log(` - ${script}${marker}`);\n }\n }\n\n console.log(`\\n Total: ${TOTAL_SCRIPTS} scripts available`);\n console.log(\n \"\\nRun them with: npm run workflow:init (or pnpm run workflow:init)\\n\",\n );\n }\n\n // Install mandatory templates if guidelines directory doesn't exist\n const guidelinesDir = join(projectRoot, \"guidelines\");\n if (!existsSync(guidelinesDir)) {\n const templatesDir = findTemplatesDirectory(__dirname);\n if (templatesDir) {\n const templateResult = installMandatoryTemplates(\n projectRoot,\n templatesDir,\n { silent: false, skipIfExists: true, mandatoryOnly: true },\n );\n if (templateResult.installed.length > 0) {\n console.log(\n `āœ“ Installed ${templateResult.installed.length} mandatory guideline templates`,\n );\n }\n }\n }\n\n // Generate .github/copilot-instructions.md if guidelines exist\n if (existsSync(guidelinesDir)) {\n const result = generateCopilotInstructions(projectRoot, { silent: true });\n if (result.success) {\n const status = result.isNew ? \"Generated\" : \"Updated\";\n console.log(\n `āœ“ ${status} .github/copilot-instructions.md from ${result.guidelinesCount} guidelines`,\n );\n if (result.preservedCustomContent) {\n console.log(\" (Custom content preserved)\");\n }\n }\n }\n } catch (error) {\n // Silently fail - this is a nice-to-have feature\n // We don't want to break the installation if something goes wrong\n }\n}\n\n// Run the script\naddScriptsToPackageJson();\n"],"mappings":";;;;;;;;;;;;;;;AASA,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAgB9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AAEpC,SAAS,kBAA2B;AAElC,QAAM,cAAc,QAAQ,IAAI;AAChC,SAAO,gBAA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src/scripts/postinstall.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Post-install script that automatically adds the workflow script to package.json\n * when installed as a local dependency (not global).\n *\n * On package update, this will also remove deprecated scripts from older versions.\n */\n\nimport { readFileSync, writeFileSync, existsSync } from \"fs\";\nimport { join, dirname } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport {\n WORKFLOW_SCRIPTS,\n DEPRECATED_SCRIPTS,\n WORKFLOW_SCRIPTS_VERSION,\n validateAllScripts,\n} from \"./workflow-scripts.js\";\nimport { generateCopilotInstructions } from \"./copilot-instructions-generator.js\";\nimport {\n installMandatoryTemplates,\n findTemplatesDirectory,\n} from \"./template-installer.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Check if we're being installed globally\n */\nexport function isGlobalInstall(): boolean {\n const installPath = process.env.npm_config_global;\n return installPath === \"true\";\n}\n\n/**\n * Find the project root by navigating out of node_modules\n */\nexport function findProjectRoot(): string | null {\n const currentDir = process.cwd();\n\n // Check if we're inside node_modules\n if (currentDir.includes(\"node_modules\")) {\n const parts = currentDir.split(\"node_modules\");\n if (parts.length > 0 && parts[0]) {\n return parts[0].replace(/\\/$/, \"\");\n }\n }\n\n // If not in node_modules, we're probably in a monorepo workspace during development\n return null;\n}\n\n/**\n * Remove deprecated scripts from package.json\n */\nexport function removeDeprecatedScripts(\n scripts: Record<string, string>\n): string[] {\n const removedScripts: string[] = [];\n\n // Remove explicitly deprecated scripts\n for (const deprecatedScript of DEPRECATED_SCRIPTS) {\n if (scripts[deprecatedScript] !== undefined) {\n delete scripts[deprecatedScript];\n removedScripts.push(deprecatedScript);\n }\n }\n\n // Also remove any remaining workflow:* or workflow-* scripts (catch-all)\n const oldScripts = validateAllScripts(scripts);\n for (const oldScript of oldScripts) {\n if (scripts[oldScript] !== undefined) {\n delete scripts[oldScript];\n if (!removedScripts.includes(oldScript)) {\n removedScripts.push(oldScript);\n }\n }\n }\n\n return removedScripts;\n}\n\n/**\n * Add the workflow script to package.json\n */\nexport function addWorkflowScript(\n scripts: Record<string, string>\n): { added: boolean; updated: boolean } {\n const scriptName = \"workflow\";\n const scriptCommand = WORKFLOW_SCRIPTS.workflow;\n\n if (!scripts[scriptName]) {\n scripts[scriptName] = scriptCommand;\n return { added: true, updated: false };\n } else if (scripts[scriptName] !== scriptCommand) {\n scripts[scriptName] = scriptCommand;\n return { added: false, updated: true };\n }\n\n return { added: false, updated: false };\n}\n\n/**\n * Main function to configure workflow scripts in package.json\n */\nexport function addScriptsToPackageJson(): void {\n try {\n // Don't run for global installs\n if (isGlobalInstall()) {\n return;\n }\n\n const projectRoot = findProjectRoot();\n if (!projectRoot) {\n return;\n }\n\n const packageJsonPath = join(projectRoot, \"package.json\");\n\n if (!existsSync(packageJsonPath)) {\n return;\n }\n\n // Read existing package.json\n const packageJsonContent = readFileSync(packageJsonPath, \"utf-8\");\n const packageJson = JSON.parse(packageJsonContent);\n\n // Initialize scripts object if it doesn't exist\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n // Step 1: Remove deprecated scripts\n const removedScripts = removeDeprecatedScripts(packageJson.scripts);\n\n // Step 2: Add the workflow script\n const { added, updated } = addWorkflowScript(packageJson.scripts);\n\n const hasChanges = removedScripts.length > 0 || added || updated;\n\n if (hasChanges) {\n // Write back to package.json with proper formatting\n writeFileSync(\n packageJsonPath,\n JSON.stringify(packageJson, null, 2) + \"\\n\",\n \"utf-8\"\n );\n\n console.log(`\\nāœ“ Workflow Agent v${WORKFLOW_SCRIPTS_VERSION} configured`);\n\n if (added) {\n console.log(`\\n Added \"workflow\" script to package.json`);\n } else if (updated) {\n console.log(`\\n Updated \"workflow\" script in package.json`);\n }\n\n // Log removed deprecated scripts\n if (removedScripts.length > 0) {\n console.log(\n `\\n āš ļø Removed ${removedScripts.length} deprecated scripts`\n );\n console.log(\n ` (Old workflow:* scripts replaced by single \"workflow\" command)`\n );\n }\n\n console.log(`\\n Usage:`);\n console.log(` npm run workflow -- init`);\n console.log(` npm run workflow -- solution list`);\n console.log(` npm run workflow -- --help`);\n console.log(`\\n Or with pnpm:`);\n console.log(` pnpm workflow init`);\n console.log(` pnpm workflow solution list`);\n console.log(` pnpm workflow --help`);\n console.log(`\\n Or if installed globally:`);\n console.log(` workflow-agent init`);\n console.log(` workflow-agent --help\\n`);\n }\n\n // Install mandatory templates if guidelines directory doesn't exist\n const guidelinesDir = join(projectRoot, \"guidelines\");\n if (!existsSync(guidelinesDir)) {\n const templatesDir = findTemplatesDirectory(__dirname);\n if (templatesDir) {\n const templateResult = installMandatoryTemplates(\n projectRoot,\n templatesDir,\n { silent: false, skipIfExists: true, mandatoryOnly: true }\n );\n if (templateResult.installed.length > 0) {\n console.log(\n `āœ“ Installed ${templateResult.installed.length} mandatory guideline templates`\n );\n }\n }\n }\n\n // Generate .github/copilot-instructions.md if guidelines exist\n if (existsSync(guidelinesDir)) {\n const result = generateCopilotInstructions(projectRoot, { silent: true });\n if (result.success) {\n const status = result.isNew ? \"Generated\" : \"Updated\";\n console.log(\n `āœ“ ${status} .github/copilot-instructions.md from ${result.guidelinesCount} guidelines`\n );\n if (result.preservedCustomContent) {\n console.log(\" (Custom content preserved)\");\n }\n }\n }\n } catch (error) {\n // Silently fail - this is a nice-to-have feature\n // We don't want to break the installation if something goes wrong\n }\n}\n\n// Run the script\naddScriptsToPackageJson();\n"],"mappings":";;;;;;;;;;;;AASA,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAa9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AAK7B,SAAS,kBAA2B;AACzC,QAAM,cAAc,QAAQ,IAAI;AAChC,SAAO,gBAAgB;AACzB;AAKO,SAAS,kBAAiC;AAC/C,QAAM,aAAa,QAAQ,IAAI;AAG/B,MAAI,WAAW,SAAS,cAAc,GAAG;AACvC,UAAM,QAAQ,WAAW,MAAM,cAAc;AAC7C,QAA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,SAAS,GAAG;AACvC,kBAAQ;AAAA,YACN,oBAAe,eAAe,UAAU,MAAM;AAAA,UAChD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAGA,QAAI,WAAW,aAAa,GAAG;AAC7B,YAAM,SAAS,4BAA4B,aAAa,EAAE,QAAQ,KAAK,CAAC;AACxE,UAAI,OAAO,SAAS;AAClB,cAAM,SAAS,OAAO,QAAQ,cAAc;AAC5C,gBAAQ;AAAA,UACN,UAAK,MAAM,yCAAyC,OAAO,eAAe;AAAA,QAC5E;AACA,YAAI,OAAO,wBAAwB;AACjC,kBAAQ,IAAI,8BAA8B;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AAAA,EAGhB;AACF;AAGA,wBAAwB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow-agent-cli",
3
- "version": "2.21.2",
3
+ "version": "2.22.0",
4
4
  "description": "A self-evolving workflow management system for AI agent development",
5
5
  "keywords": [
6
6
  "workflow",
@@ -1 +0,0 @@
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 * 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 content += `- ${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.21.0: Script restructuring - strict `workflow:<command>-<action>` format\n * Valid top-level commands: version, init, validate, config, suggest, setup, doctor,\n * scope, verify, pre-commit, learn, solution, sync, docs\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.21.0\";\n\n/**\n * The 13 valid top-level commands for the workflow CLI\n * All script names MUST follow: workflow:<command>[-<action>[-<subaction>]]\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 follows the required naming pattern\n * @param scriptName - The script name to validate (e.g., \"workflow:scope-hooks-install\")\n * @returns true if valid, false otherwise\n */\nexport function validateScriptName(scriptName: string): boolean {\n if (!scriptName.startsWith(\"workflow:\")) {\n return false;\n }\n \n const command = scriptName.slice(\"workflow:\".length);\n const topLevelCommand = command.split(\"-\")[0];\n \n return VALID_COMMANDS.includes(topLevelCommand as ValidCommand);\n}\n\n/**\n * Validates all script names in an object\n * @param scripts - Object with script names as keys\n * @returns Array of invalid script names\n */\nexport function validateAllScripts(scripts: Record<string, string>): string[] {\n return Object.keys(scripts).filter(name => !validateScriptName(name));\n}\n\n/**\n * Deprecated scripts that should be removed from package.json\n * These are old colon-style commands replaced by the new subcommand structure\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 (now under docs)\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 (now under docs)\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 without prefix\n \"verify\",\n \"verify:fix\",\n \"pre-commit\",\n\n // Old colon-style verify\n \"workflow:verify:fix\",\n\n // Old standalone hooks commands (now under scope hooks)\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 (now setup-auto)\n \"workflow:auto-setup\",\n] as const;\n\nexport type DeprecatedScriptName = (typeof DEPRECATED_SCRIPTS)[number];\n\nexport const WORKFLOW_SCRIPTS = {\n // Version marker for tracking\n \"workflow:version\": \"workflow-agent --version\",\n\n // Core Commands\n \"workflow:init\": \"workflow-agent init\",\n \"workflow:validate\": \"workflow-agent validate\",\n \"workflow:config\": \"workflow-agent config show\",\n \"workflow:config-show\": \"workflow-agent config show\",\n \"workflow:config-set\": \"workflow-agent config set\",\n \"workflow:suggest\": \"workflow-agent suggest\",\n \"workflow:setup\": \"workflow-agent setup\",\n \"workflow:setup-auto\": \"workflow-agent setup auto\",\n \"workflow:doctor\": \"workflow-agent doctor\",\n\n // Scope Commands (new subcommand syntax)\n \"workflow:scope\": \"workflow-agent scope list\",\n \"workflow:scope-list\": \"workflow-agent scope list\",\n \"workflow:scope-create\": \"workflow-agent scope create\",\n \"workflow:scope-migrate\": \"workflow-agent scope migrate\",\n \"workflow:scope-add\": \"workflow-agent scope add\",\n \"workflow:scope-remove\": \"workflow-agent scope remove\",\n \"workflow:scope-sync\": \"workflow-agent scope sync\",\n \"workflow:scope-analyze\": \"workflow-agent scope analyze\",\n\n // Scope Hooks Commands (hooks moved under scope)\n \"workflow:scope-hooks\": \"workflow-agent scope hooks status\",\n \"workflow:scope-hooks-status\": \"workflow-agent scope hooks status\",\n \"workflow:scope-hooks-install\": \"workflow-agent scope hooks install\",\n \"workflow:scope-hooks-uninstall\": \"workflow-agent scope hooks uninstall\",\n \"workflow:scope-hooks-test\": \"workflow-agent scope hooks test\",\n\n // Verification\n \"workflow:verify\": \"workflow-agent verify\",\n \"workflow:verify-fix\": \"workflow-agent verify --fix\",\n \"workflow:pre-commit\": \"workflow-agent pre-commit\",\n\n // Learning System Commands (new subcommand syntax)\n \"workflow:learn\": \"workflow-agent learn list\",\n \"workflow:learn-list\": \"workflow-agent learn list\",\n \"workflow:learn-analyze\": \"workflow-agent learn analyze\",\n \"workflow:learn-capture\": \"workflow-agent learn capture\",\n \"workflow:learn-apply\": \"workflow-agent learn apply\",\n \"workflow:learn-export\": \"workflow-agent learn export\",\n \"workflow:learn-import\": \"workflow-agent learn import\",\n \"workflow:learn-status\": \"workflow-agent learn status\",\n \"workflow:learn-stats\": \"workflow-agent learn stats\",\n \"workflow:learn-clean\": \"workflow-agent learn clean\",\n \"workflow:learn-config\": \"workflow-agent learn config --show\",\n \"workflow:learn-config-enable\": \"workflow-agent learn config --enable-sync\",\n \"workflow:learn-config-disable\": \"workflow-agent learn config --disable-sync\",\n \"workflow:learn-sync\": \"workflow-agent learn sync\",\n \"workflow:learn-sync-push\": \"workflow-agent learn sync --push\",\n \"workflow:learn-sync-pull\": \"workflow-agent learn sync --pull\",\n\n // Solution Pattern Commands (new subcommand syntax)\n \"workflow:solution\": \"workflow-agent solution list\",\n \"workflow:solution-list\": \"workflow-agent solution list\",\n \"workflow:solution-create\": \"workflow-agent solution create\",\n \"workflow:solution-show\": \"workflow-agent solution show\",\n \"workflow:solution-search\": \"workflow-agent solution search\",\n \"workflow:solution-apply\": \"workflow-agent solution apply\",\n \"workflow:solution-export\": \"workflow-agent solution export\",\n \"workflow:solution-import\": \"workflow-agent solution import\",\n \"workflow:solution-analyze\": \"workflow-agent solution analyze\",\n\n // Sync Commands (new unified sync)\n \"workflow:sync\": \"workflow-agent sync status\",\n \"workflow:sync-status\": \"workflow-agent sync status\",\n \"workflow:sync-push\": \"workflow-agent sync push\",\n \"workflow:sync-pull\": \"workflow-agent sync pull\",\n\n // Docs Commands (new subcommand syntax)\n \"workflow:docs\": \"workflow-agent docs validate\",\n \"workflow:docs-validate\": \"workflow-agent docs validate\",\n \"workflow:docs-validate-fix\": \"workflow-agent docs validate --fix\",\n \"workflow:docs-advisory\": \"workflow-agent docs advisory\",\n \"workflow:docs-advisory-quick\": \"workflow-agent docs advisory --depth quick\",\n \"workflow:docs-advisory-standard\": \"workflow-agent docs advisory --depth standard\",\n \"workflow:docs-advisory-comprehensive\": \"workflow-agent docs advisory --depth comprehensive\",\n \"workflow:docs-advisory-executive\": \"workflow-agent docs advisory --depth executive\",\n \"workflow:docs-advisory-ci\": \"workflow-agent docs advisory --ci\",\n \"workflow:docs-generate\": \"workflow-agent docs generate\",\n \"workflow:docs-update\": \"workflow-agent docs update\",\n \"workflow:docs-update-force\": \"workflow-agent docs update --force\",\n} as const;\n\nexport type WorkflowScriptName = keyof typeof WORKFLOW_SCRIPTS;\n\n/**\n * Script categories for organized console output\n */\nexport const SCRIPT_CATEGORIES = {\n \"Core Commands\": [\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 ],\n \"Scope Commands\": [\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 ],\n \"Scope Hooks\": [\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 ],\n Verification: [\n \"workflow:verify\",\n \"workflow:verify-fix\",\n \"workflow:pre-commit\",\n ],\n \"Learning System\": [\n \"workflow:learn\",\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 ],\n \"Solution Patterns\": [\n \"workflow:solution\",\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 ],\n Sync: [\n \"workflow:sync\",\n \"workflow:sync-status\",\n \"workflow:sync-push\",\n \"workflow:sync-pull\",\n ],\n Documentation: [\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 ],\n Meta: [\"workflow:version\"],\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,SAA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F;AAEA,QAAI;AACF,YAAM,WAAWC,cAAa,YAAY,OAAO;AACjD,YAAM,WAAW,eAAe,UAAU,OAAO;AACjD,MAAAI,eAAc,UAAU,UAAU,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"]}