workflow-agent-cli 2.9.1 → 2.10.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.
@@ -0,0 +1,13 @@
1
+ import {
2
+ analyzeValidationError,
3
+ applyAutoFixes,
4
+ autoFixConfigFile,
5
+ writeFixedConfig
6
+ } from "./chunk-YELUGXOM.js";
7
+ export {
8
+ analyzeValidationError,
9
+ applyAutoFixes,
10
+ autoFixConfigFile,
11
+ writeFixedConfig
12
+ };
13
+ //# sourceMappingURL=auto-fix-7WAESKYO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,98 @@
1
+ import {
2
+ WorkflowConfigSchema
3
+ } from "./chunk-YELUGXOM.js";
4
+
5
+ // src/config/index.ts
6
+ import { cosmiconfig } from "cosmiconfig";
7
+ import { join } from "path";
8
+ import { existsSync } from "fs";
9
+ var explorer = cosmiconfig("workflow", {
10
+ searchPlaces: [
11
+ "workflow.config.ts",
12
+ "workflow.config.js",
13
+ "workflow.config.json",
14
+ ".workflowrc",
15
+ ".workflowrc.json",
16
+ "package.json"
17
+ ]
18
+ });
19
+ async function loadConfig(cwd = process.cwd()) {
20
+ try {
21
+ const result = await explorer.search(cwd);
22
+ if (!result || !result.config) {
23
+ return null;
24
+ }
25
+ const validated = WorkflowConfigSchema.parse(result.config);
26
+ return validated;
27
+ } catch (error) {
28
+ if (error instanceof Error) {
29
+ throw new Error(`Failed to load workflow config: ${error.message}`);
30
+ }
31
+ throw error;
32
+ }
33
+ }
34
+ async function loadConfigSafe(cwd = process.cwd()) {
35
+ try {
36
+ const result = await explorer.search(cwd);
37
+ if (!result || !result.config) {
38
+ return {
39
+ config: null,
40
+ rawConfig: null,
41
+ configPath: null,
42
+ issues: [],
43
+ valid: true
44
+ // No config is valid (just missing)
45
+ };
46
+ }
47
+ const validated = WorkflowConfigSchema.safeParse(result.config);
48
+ if (validated.success) {
49
+ return {
50
+ config: validated.data,
51
+ rawConfig: result.config,
52
+ configPath: result.filepath,
53
+ issues: [],
54
+ valid: true
55
+ };
56
+ }
57
+ const { analyzeValidationError: analyzeValidationError2 } = await import("./auto-fix-7WAESKYO.js");
58
+ const issues = analyzeValidationError2(validated.error, result.config);
59
+ return {
60
+ config: null,
61
+ rawConfig: result.config,
62
+ configPath: result.filepath,
63
+ issues,
64
+ valid: false
65
+ };
66
+ } catch (error) {
67
+ return {
68
+ config: null,
69
+ rawConfig: null,
70
+ configPath: null,
71
+ issues: [
72
+ {
73
+ path: "",
74
+ code: "parse_error",
75
+ message: error instanceof Error ? error.message : "Unknown error"
76
+ }
77
+ ],
78
+ valid: false
79
+ };
80
+ }
81
+ }
82
+ function hasConfig(cwd = process.cwd()) {
83
+ const configPaths = [
84
+ "workflow.config.ts",
85
+ "workflow.config.js",
86
+ "workflow.config.json",
87
+ ".workflowrc",
88
+ ".workflowrc.json"
89
+ ];
90
+ return configPaths.some((path) => existsSync(join(cwd, path)));
91
+ }
92
+
93
+ export {
94
+ loadConfig,
95
+ loadConfigSafe,
96
+ hasConfig
97
+ };
98
+ //# sourceMappingURL=chunk-UWJ2ZGEI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/index.ts"],"sourcesContent":["import { cosmiconfig } from \"cosmiconfig\";\nimport { WorkflowConfig, WorkflowConfigSchema } from \"./schema.js\";\nimport { join } from \"path\";\nimport { existsSync } from \"fs\";\n\nconst explorer = cosmiconfig(\"workflow\", {\n searchPlaces: [\n \"workflow.config.ts\",\n \"workflow.config.js\",\n \"workflow.config.json\",\n \".workflowrc\",\n \".workflowrc.json\",\n \"package.json\",\n ],\n});\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<WorkflowConfig | null> {\n try {\n const result = await explorer.search(cwd);\n\n if (!result || !result.config) {\n return null;\n }\n\n // Validate config against schema\n const validated = WorkflowConfigSchema.parse(result.config);\n return validated;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to load workflow config: ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Result from safe config loading - never throws\n */\nexport interface SafeConfigResult {\n config: WorkflowConfig | null;\n rawConfig: unknown;\n configPath: string | null;\n issues: Array<{\n path: string;\n code: string;\n message: string;\n currentValue?: unknown;\n suggestedFix?: {\n description: string;\n newValue: unknown;\n };\n }>;\n valid: boolean;\n}\n\n/**\n * Load configuration without throwing on validation errors.\n * Returns detailed information about issues for graceful handling.\n */\nexport async function loadConfigSafe(\n cwd: string = process.cwd(),\n): Promise<SafeConfigResult> {\n try {\n const result = await explorer.search(cwd);\n\n if (!result || !result.config) {\n return {\n config: null,\n rawConfig: null,\n configPath: null,\n issues: [],\n valid: true, // No config is valid (just missing)\n };\n }\n\n // Use safeParse for graceful validation\n const validated = WorkflowConfigSchema.safeParse(result.config);\n\n if (validated.success) {\n return {\n config: validated.data,\n rawConfig: result.config,\n configPath: result.filepath,\n issues: [],\n valid: true,\n };\n }\n\n // Import auto-fix utilities for analyzing errors\n const { analyzeValidationError } = await import(\"./auto-fix.js\");\n const issues = analyzeValidationError(validated.error, result.config);\n\n return {\n config: null,\n rawConfig: result.config,\n configPath: result.filepath,\n issues,\n valid: false,\n };\n } catch (error) {\n return {\n config: null,\n rawConfig: null,\n configPath: null,\n issues: [\n {\n path: \"\",\n code: \"parse_error\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n ],\n valid: false,\n };\n }\n}\n\nexport function hasConfig(cwd: string = process.cwd()): boolean {\n const configPaths = [\n \"workflow.config.ts\",\n \"workflow.config.js\",\n \"workflow.config.json\",\n \".workflowrc\",\n \".workflowrc.json\",\n ];\n\n return configPaths.some((path) => existsSync(join(cwd, path)));\n}\n\nexport {\n WorkflowConfig,\n WorkflowConfigSchema,\n Scope,\n BranchType,\n ConventionalType,\n} from \"./schema.js\";\n\nexport {\n analyzeValidationError,\n applyAutoFixes,\n autoFixConfigFile,\n writeFixedConfig,\n type ConfigValidationIssue,\n type AutoFixResult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AAA,MACR,WAAW,OAAO;AAAA,MAClB,YAAY,OAAO;AAAA,MACnB;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF,SAAS,OAAO;AACd,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN;AAAA,UACE,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,QACpD;AAAA,MACF;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAAS,UAAU,MAAc,QAAQ,IAAI,GAAY;AAC9D,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,YAAY,KAAK,CAAC,SAAS,WAAW,KAAK,KAAK,IAAI,CAAC,CAAC;AAC/D;","names":["analyzeValidationError"]}
@@ -0,0 +1,335 @@
1
+ // src/config/auto-fix.ts
2
+ import { writeFile, readFile } from "fs/promises";
3
+ import { existsSync } from "fs";
4
+ import { join } from "path";
5
+
6
+ // src/config/schema.ts
7
+ import { z } from "zod";
8
+ var RESERVED_SCOPE_NAMES = [
9
+ "init",
10
+ "create",
11
+ "build",
12
+ "test",
13
+ "config",
14
+ "docs",
15
+ "ci",
16
+ "deps"
17
+ ];
18
+ var ScopeSchema = z.object({
19
+ name: z.string().min(1).max(32, "Scope name must be 32 characters or less").regex(
20
+ /^[a-z0-9-]+$/,
21
+ "Scope name must be lowercase alphanumeric with hyphens"
22
+ ).refine((name) => !RESERVED_SCOPE_NAMES.includes(name), {
23
+ message: `Scope name cannot be a reserved word: ${RESERVED_SCOPE_NAMES.join(", ")}`
24
+ }),
25
+ description: z.string().min(10, "Scope description must be at least 10 characters"),
26
+ emoji: z.string().optional(),
27
+ category: z.enum([
28
+ "auth",
29
+ "features",
30
+ "infrastructure",
31
+ "documentation",
32
+ "testing",
33
+ "performance",
34
+ "other"
35
+ ]).optional()
36
+ });
37
+ var BranchTypeSchema = z.enum([
38
+ "feature",
39
+ "bugfix",
40
+ "hotfix",
41
+ "chore",
42
+ "refactor",
43
+ "docs",
44
+ "test",
45
+ "release"
46
+ ]);
47
+ var ConventionalTypeSchema = z.enum([
48
+ "feat",
49
+ "fix",
50
+ "refactor",
51
+ "chore",
52
+ "docs",
53
+ "test",
54
+ "perf",
55
+ "style",
56
+ "ci",
57
+ "build",
58
+ "revert"
59
+ ]);
60
+ var EnforcementLevelSchema = z.enum([
61
+ "strict",
62
+ "advisory",
63
+ "learning"
64
+ ]);
65
+ var AnalyticsConfigSchema = z.object({
66
+ enabled: z.boolean().default(false),
67
+ shareAnonymous: z.boolean().default(false)
68
+ });
69
+ var CIConfigSchema = z.object({
70
+ provider: z.enum(["github", "gitlab", "azure"]).default("github"),
71
+ nodeVersions: z.array(z.string()).optional(),
72
+ defaultBranch: z.string().default("main"),
73
+ checks: z.array(z.enum(["lint", "typecheck", "format", "build", "test"])).optional()
74
+ });
75
+ var HooksConfigSchema = z.object({
76
+ preCommit: z.array(z.string()).optional(),
77
+ commitMsg: z.array(z.string()).optional(),
78
+ prePush: z.array(z.string()).optional()
79
+ });
80
+ var GuidelinesConfigSchema = z.object({
81
+ mandatoryTemplates: z.array(z.string()).optional(),
82
+ optionalTemplates: z.array(z.string()).optional(),
83
+ customTemplatesDir: z.string().optional(),
84
+ additionalMandatory: z.array(z.string()).optional(),
85
+ optionalOverrides: z.array(z.string()).optional()
86
+ });
87
+ var AdvisoryDepthSchema = z.enum([
88
+ "executive",
89
+ "quick",
90
+ "standard",
91
+ "comprehensive"
92
+ ]);
93
+ var AdvisoryQuestionSchema = z.object({
94
+ category: z.string(),
95
+ question: z.string(),
96
+ context: z.string().optional(),
97
+ priority: z.enum(["high", "medium", "low"]).optional()
98
+ });
99
+ var AdvisoryConfigSchema = z.object({
100
+ enabled: z.boolean().default(true),
101
+ defaultDepth: AdvisoryDepthSchema.default("standard"),
102
+ outputDir: z.string().default("docs/advisory"),
103
+ customQuestions: z.array(AdvisoryQuestionSchema).optional(),
104
+ riskThresholds: z.object({
105
+ high: z.number().default(0.7),
106
+ medium: z.number().default(0.4),
107
+ low: z.number().default(0.2)
108
+ }).optional(),
109
+ categories: z.array(z.string()).default([
110
+ "Technology Decisions",
111
+ "Package Utilization",
112
+ "Platform Strategy",
113
+ "Business Alignment",
114
+ "Technical Debt",
115
+ "Growth Opportunities"
116
+ ]),
117
+ excludePatterns: z.array(z.string()).optional(),
118
+ includeHealthMetrics: z.boolean().default(false)
119
+ });
120
+ var WorkflowConfigSchema = z.object({
121
+ projectName: z.string().min(1),
122
+ scopes: z.array(ScopeSchema).min(1),
123
+ branchTypes: z.array(BranchTypeSchema).optional(),
124
+ conventionalTypes: z.array(ConventionalTypeSchema).optional(),
125
+ enforcement: EnforcementLevelSchema.default("strict"),
126
+ language: z.string().default("en"),
127
+ analytics: AnalyticsConfigSchema.optional(),
128
+ adapter: z.string().optional(),
129
+ syncRemote: z.string().optional(),
130
+ ci: CIConfigSchema.optional(),
131
+ hooks: HooksConfigSchema.optional(),
132
+ guidelines: GuidelinesConfigSchema.optional(),
133
+ advisory: AdvisoryConfigSchema.optional()
134
+ });
135
+ function validateScopeDefinitions(scopes) {
136
+ const errors = [];
137
+ const seenNames = /* @__PURE__ */ new Set();
138
+ for (const scope of scopes) {
139
+ if (seenNames.has(scope.name)) {
140
+ errors.push(`Duplicate scope name: "${scope.name}"`);
141
+ }
142
+ seenNames.add(scope.name);
143
+ const result = ScopeSchema.safeParse(scope);
144
+ if (!result.success) {
145
+ result.error.errors.forEach((err) => {
146
+ errors.push(`Scope "${scope.name}": ${err.message}`);
147
+ });
148
+ }
149
+ }
150
+ return {
151
+ valid: errors.length === 0,
152
+ errors
153
+ };
154
+ }
155
+
156
+ // src/config/auto-fix.ts
157
+ var RESERVED_NAME_REPLACEMENTS = {
158
+ init: "setup",
159
+ create: "add",
160
+ build: "compile",
161
+ test: "testing",
162
+ config: "settings",
163
+ docs: "documentation",
164
+ ci: "pipeline",
165
+ deps: "dependencies"
166
+ };
167
+ function analyzeValidationError(error, rawConfig) {
168
+ const issues = [];
169
+ for (const err of error.errors) {
170
+ const pathStr = err.path.join(".");
171
+ const issue = {
172
+ path: pathStr,
173
+ code: err.code,
174
+ message: err.message,
175
+ currentValue: getValueAtPath(rawConfig, err.path)
176
+ };
177
+ if (err.path.includes("description") && err.message.includes("at least 10 characters")) {
178
+ const currentValue = issue.currentValue;
179
+ issue.suggestedFix = {
180
+ description: "Extend description to meet minimum length",
181
+ newValue: padDescription(currentValue)
182
+ };
183
+ } else if (err.path.includes("name") && err.message.includes("reserved word")) {
184
+ const currentValue = issue.currentValue;
185
+ const replacement = RESERVED_NAME_REPLACEMENTS[currentValue] || `${currentValue}-scope`;
186
+ issue.suggestedFix = {
187
+ description: `Rename from "${currentValue}" to "${replacement}"`,
188
+ newValue: replacement
189
+ };
190
+ } else if (err.code === "too_small" && err.path.includes("description")) {
191
+ const currentValue = issue.currentValue || "";
192
+ issue.suggestedFix = {
193
+ description: "Extend description to meet minimum length",
194
+ newValue: padDescription(currentValue)
195
+ };
196
+ }
197
+ issues.push(issue);
198
+ }
199
+ return issues;
200
+ }
201
+ function applyAutoFixes(rawConfig, issues) {
202
+ const changes = [];
203
+ const newConfig = JSON.parse(JSON.stringify(rawConfig));
204
+ for (const issue of issues) {
205
+ if (issue.suggestedFix) {
206
+ const path = issue.path.split(".");
207
+ setValueAtPath(newConfig, path, issue.suggestedFix.newValue);
208
+ changes.push(
209
+ `${issue.path}: ${issue.suggestedFix.description} (${JSON.stringify(issue.currentValue)} \u2192 ${JSON.stringify(issue.suggestedFix.newValue)})`
210
+ );
211
+ }
212
+ }
213
+ return {
214
+ fixed: changes.length > 0,
215
+ changes,
216
+ newConfig
217
+ };
218
+ }
219
+ async function writeFixedConfig(configPath, config) {
220
+ const content = JSON.stringify(config, null, 2);
221
+ await writeFile(configPath, content, "utf-8");
222
+ }
223
+ async function autoFixConfigFile(cwd = process.cwd()) {
224
+ const configPaths = [
225
+ "workflow.config.json",
226
+ ".workflowrc.json",
227
+ ".workflowrc"
228
+ ];
229
+ let configPath = null;
230
+ for (const path of configPaths) {
231
+ const fullPath = join(cwd, path);
232
+ if (existsSync(fullPath)) {
233
+ configPath = fullPath;
234
+ break;
235
+ }
236
+ }
237
+ if (!configPath) {
238
+ return {
239
+ success: false,
240
+ configPath: null,
241
+ changes: [],
242
+ error: "No JSON configuration file found to fix"
243
+ };
244
+ }
245
+ try {
246
+ const content = await readFile(configPath, "utf-8");
247
+ const rawConfig = JSON.parse(content);
248
+ const result = WorkflowConfigSchema.safeParse(rawConfig);
249
+ if (result.success) {
250
+ return {
251
+ success: true,
252
+ configPath,
253
+ changes: []
254
+ };
255
+ }
256
+ const issues = analyzeValidationError(result.error, rawConfig);
257
+ const fixResult = applyAutoFixes(rawConfig, issues);
258
+ if (!fixResult.fixed) {
259
+ return {
260
+ success: false,
261
+ configPath,
262
+ changes: [],
263
+ error: "No automatic fixes available for the validation errors"
264
+ };
265
+ }
266
+ const fixedResult = WorkflowConfigSchema.safeParse(fixResult.newConfig);
267
+ if (!fixedResult.success) {
268
+ return {
269
+ success: false,
270
+ configPath,
271
+ changes: fixResult.changes,
272
+ error: "Auto-fix applied but configuration still has validation errors"
273
+ };
274
+ }
275
+ await writeFixedConfig(configPath, fixResult.newConfig);
276
+ return {
277
+ success: true,
278
+ configPath,
279
+ changes: fixResult.changes
280
+ };
281
+ } catch (error) {
282
+ return {
283
+ success: false,
284
+ configPath,
285
+ changes: [],
286
+ error: error instanceof Error ? error.message : "Unknown error"
287
+ };
288
+ }
289
+ }
290
+ function padDescription(description) {
291
+ if (!description) {
292
+ return "Description for this scope";
293
+ }
294
+ if (description.length >= 10) {
295
+ return description;
296
+ }
297
+ const suffixes = [" changes", " updates", " work", " tasks"];
298
+ for (const suffix of suffixes) {
299
+ if ((description + suffix).length >= 10) {
300
+ return description + suffix;
301
+ }
302
+ }
303
+ return description + " related changes";
304
+ }
305
+ function getValueAtPath(obj, path) {
306
+ let current = obj;
307
+ for (const key of path) {
308
+ if (current === null || current === void 0) {
309
+ return void 0;
310
+ }
311
+ current = current[key];
312
+ }
313
+ return current;
314
+ }
315
+ function setValueAtPath(obj, path, value) {
316
+ let current = obj;
317
+ for (let i = 0; i < path.length - 1; i++) {
318
+ const key = path[i];
319
+ if (current[key] === void 0) {
320
+ current[key] = {};
321
+ }
322
+ current = current[key];
323
+ }
324
+ current[path[path.length - 1]] = value;
325
+ }
326
+
327
+ export {
328
+ WorkflowConfigSchema,
329
+ validateScopeDefinitions,
330
+ analyzeValidationError,
331
+ applyAutoFixes,
332
+ writeFixedConfig,
333
+ autoFixConfigFile
334
+ };
335
+ //# sourceMappingURL=chunk-YELUGXOM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/auto-fix.ts","../src/config/schema.ts"],"sourcesContent":["/**\n * Configuration Auto-Fix Utilities\n *\n * Provides automatic resolution for common configuration validation errors\n * such as reserved scope names and short descriptions.\n */\n\nimport { writeFile, readFile } from \"fs/promises\";\nimport { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport { z } from \"zod\";\nimport { WorkflowConfigSchema } from \"./schema.js\";\n\n// Suggested replacements for reserved names\nconst RESERVED_NAME_REPLACEMENTS: Record<string, string> = {\n init: \"setup\",\n create: \"add\",\n build: \"compile\",\n test: \"testing\",\n config: \"settings\",\n docs: \"documentation\",\n ci: \"pipeline\",\n deps: \"dependencies\",\n};\n\nexport interface ConfigValidationIssue {\n path: string;\n code: string;\n message: string;\n currentValue?: unknown;\n suggestedFix?: {\n description: string;\n newValue: unknown;\n };\n}\n\nexport interface ConfigLoadResult {\n config: z.infer<typeof WorkflowConfigSchema> | null;\n rawConfig: unknown;\n configPath: string | null;\n issues: ConfigValidationIssue[];\n valid: boolean;\n}\n\nexport interface AutoFixResult {\n fixed: boolean;\n changes: string[];\n newConfig: unknown;\n}\n\n/**\n * Analyze a Zod error and generate fix suggestions\n */\nexport function analyzeValidationError(\n error: z.ZodError,\n rawConfig: unknown,\n): ConfigValidationIssue[] {\n const issues: ConfigValidationIssue[] = [];\n\n for (const err of error.errors) {\n const pathStr = err.path.join(\".\");\n const issue: ConfigValidationIssue = {\n path: pathStr,\n code: err.code,\n message: err.message,\n currentValue: getValueAtPath(rawConfig, err.path),\n };\n\n // Generate fix suggestions based on error type\n if (\n err.path.includes(\"description\") &&\n err.message.includes(\"at least 10 characters\")\n ) {\n const currentValue = issue.currentValue as string;\n issue.suggestedFix = {\n description: \"Extend description to meet minimum length\",\n newValue: padDescription(currentValue),\n };\n } else if (\n err.path.includes(\"name\") &&\n err.message.includes(\"reserved word\")\n ) {\n const currentValue = issue.currentValue as string;\n const replacement =\n RESERVED_NAME_REPLACEMENTS[currentValue] || `${currentValue}-scope`;\n issue.suggestedFix = {\n description: `Rename from \"${currentValue}\" to \"${replacement}\"`,\n newValue: replacement,\n };\n } else if (err.code === \"too_small\" && err.path.includes(\"description\")) {\n const currentValue = (issue.currentValue as string) || \"\";\n issue.suggestedFix = {\n description: \"Extend description to meet minimum length\",\n newValue: padDescription(currentValue),\n };\n }\n\n issues.push(issue);\n }\n\n return issues;\n}\n\n/**\n * Apply auto-fixes to a raw configuration object\n */\nexport function applyAutoFixes(\n rawConfig: unknown,\n issues: ConfigValidationIssue[],\n): AutoFixResult {\n const changes: string[] = [];\n // Deep clone the config\n const newConfig = JSON.parse(JSON.stringify(rawConfig));\n\n for (const issue of issues) {\n if (issue.suggestedFix) {\n const path = issue.path.split(\".\");\n setValueAtPath(newConfig, path, issue.suggestedFix.newValue);\n changes.push(\n `${issue.path}: ${issue.suggestedFix.description} (${JSON.stringify(issue.currentValue)} → ${JSON.stringify(issue.suggestedFix.newValue)})`,\n );\n }\n }\n\n return {\n fixed: changes.length > 0,\n changes,\n newConfig,\n };\n}\n\n/**\n * Write fixed configuration back to file\n */\nexport async function writeFixedConfig(\n configPath: string,\n config: unknown,\n): Promise<void> {\n const content = JSON.stringify(config, null, 2);\n await writeFile(configPath, content, \"utf-8\");\n}\n\n/**\n * Attempt to auto-fix a configuration file\n */\nexport async function autoFixConfigFile(\n cwd: string = process.cwd(),\n): Promise<{\n success: boolean;\n configPath: string | null;\n changes: string[];\n error?: string;\n}> {\n const configPaths = [\n \"workflow.config.json\",\n \".workflowrc.json\",\n \".workflowrc\",\n ];\n\n let configPath: string | null = null;\n for (const path of configPaths) {\n const fullPath = join(cwd, path);\n if (existsSync(fullPath)) {\n configPath = fullPath;\n break;\n }\n }\n\n if (!configPath) {\n return {\n success: false,\n configPath: null,\n changes: [],\n error: \"No JSON configuration file found to fix\",\n };\n }\n\n try {\n const content = await readFile(configPath, \"utf-8\");\n const rawConfig = JSON.parse(content);\n\n // Try to validate\n const result = WorkflowConfigSchema.safeParse(rawConfig);\n\n if (result.success) {\n return {\n success: true,\n configPath,\n changes: [],\n };\n }\n\n // Analyze and fix issues\n const issues = analyzeValidationError(result.error, rawConfig);\n const fixResult = applyAutoFixes(rawConfig, issues);\n\n if (!fixResult.fixed) {\n return {\n success: false,\n configPath,\n changes: [],\n error: \"No automatic fixes available for the validation errors\",\n };\n }\n\n // Validate the fixed config\n const fixedResult = WorkflowConfigSchema.safeParse(fixResult.newConfig);\n if (!fixedResult.success) {\n return {\n success: false,\n configPath,\n changes: fixResult.changes,\n error:\n \"Auto-fix applied but configuration still has validation errors\",\n };\n }\n\n // Write the fixed config\n await writeFixedConfig(configPath, fixResult.newConfig);\n\n return {\n success: true,\n configPath,\n changes: fixResult.changes,\n };\n } catch (error) {\n return {\n success: false,\n configPath,\n changes: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n}\n\n// Utility functions\n\nfunction padDescription(description: string): string {\n if (!description) {\n return \"Description for this scope\";\n }\n if (description.length >= 10) {\n return description;\n }\n // Pad with meaningful suffix based on what exists\n const suffixes = [\" changes\", \" updates\", \" work\", \" tasks\"];\n for (const suffix of suffixes) {\n if ((description + suffix).length >= 10) {\n return description + suffix;\n }\n }\n // Last resort: pad with generic text\n return description + \" related changes\";\n}\n\nfunction getValueAtPath(obj: unknown, path: (string | number)[]): unknown {\n let current: unknown = obj;\n for (const key of path) {\n if (current === null || current === undefined) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[key];\n }\n return current;\n}\n\nfunction setValueAtPath(obj: unknown, path: string[], value: unknown): void {\n let current: Record<string, unknown> = obj as Record<string, unknown>;\n for (let i = 0; i < path.length - 1; i++) {\n const key = path[i];\n if (current[key] === undefined) {\n current[key] = {};\n }\n current = current[key] as Record<string, unknown>;\n }\n current[path[path.length - 1]] = value;\n}\n","import { z } from \"zod\";\n\n// Reserved scope names that cannot be used\nconst RESERVED_SCOPE_NAMES = [\n \"init\",\n \"create\",\n \"build\",\n \"test\",\n \"config\",\n \"docs\",\n \"ci\",\n \"deps\",\n];\n\nexport const ScopeSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(32, \"Scope name must be 32 characters or less\")\n .regex(\n /^[a-z0-9-]+$/,\n \"Scope name must be lowercase alphanumeric with hyphens\",\n )\n .refine((name) => !RESERVED_SCOPE_NAMES.includes(name), {\n message: `Scope name cannot be a reserved word: ${RESERVED_SCOPE_NAMES.join(\", \")}`,\n }),\n description: z\n .string()\n .min(10, \"Scope description must be at least 10 characters\"),\n emoji: z.string().optional(),\n category: z\n .enum([\n \"auth\",\n \"features\",\n \"infrastructure\",\n \"documentation\",\n \"testing\",\n \"performance\",\n \"other\",\n ])\n .optional(),\n});\n\nexport const BranchTypeSchema = z.enum([\n \"feature\",\n \"bugfix\",\n \"hotfix\",\n \"chore\",\n \"refactor\",\n \"docs\",\n \"test\",\n \"release\",\n]);\n\nexport const ConventionalTypeSchema = z.enum([\n \"feat\",\n \"fix\",\n \"refactor\",\n \"chore\",\n \"docs\",\n \"test\",\n \"perf\",\n \"style\",\n \"ci\",\n \"build\",\n \"revert\",\n]);\n\nexport const EnforcementLevelSchema = z.enum([\n \"strict\",\n \"advisory\",\n \"learning\",\n]);\n\nexport const AnalyticsConfigSchema = z.object({\n enabled: z.boolean().default(false),\n shareAnonymous: z.boolean().default(false),\n});\n\nexport const CIConfigSchema = z.object({\n provider: z.enum([\"github\", \"gitlab\", \"azure\"]).default(\"github\"),\n nodeVersions: z.array(z.string()).optional(),\n defaultBranch: z.string().default(\"main\"),\n checks: z\n .array(z.enum([\"lint\", \"typecheck\", \"format\", \"build\", \"test\"]))\n .optional(),\n});\n\nexport const HooksConfigSchema = z.object({\n preCommit: z.array(z.string()).optional(),\n commitMsg: z.array(z.string()).optional(),\n prePush: z.array(z.string()).optional(),\n});\n\nexport const GuidelinesConfigSchema = z.object({\n mandatoryTemplates: z.array(z.string()).optional(),\n optionalTemplates: z.array(z.string()).optional(),\n customTemplatesDir: z.string().optional(),\n additionalMandatory: z.array(z.string()).optional(),\n optionalOverrides: z.array(z.string()).optional(),\n});\n\nexport const AdvisoryDepthSchema = z.enum([\n \"executive\",\n \"quick\",\n \"standard\",\n \"comprehensive\",\n]);\n\nexport const AdvisoryQuestionSchema = z.object({\n category: z.string(),\n question: z.string(),\n context: z.string().optional(),\n priority: z.enum([\"high\", \"medium\", \"low\"]).optional(),\n});\n\nexport const AdvisoryConfigSchema = z.object({\n enabled: z.boolean().default(true),\n defaultDepth: AdvisoryDepthSchema.default(\"standard\"),\n outputDir: z.string().default(\"docs/advisory\"),\n customQuestions: z.array(AdvisoryQuestionSchema).optional(),\n riskThresholds: z\n .object({\n high: z.number().default(0.7),\n medium: z.number().default(0.4),\n low: z.number().default(0.2),\n })\n .optional(),\n categories: z\n .array(z.string())\n .default([\n \"Technology Decisions\",\n \"Package Utilization\",\n \"Platform Strategy\",\n \"Business Alignment\",\n \"Technical Debt\",\n \"Growth Opportunities\",\n ]),\n excludePatterns: z.array(z.string()).optional(),\n includeHealthMetrics: z.boolean().default(false),\n});\n\nexport const WorkflowConfigSchema = z.object({\n projectName: z.string().min(1),\n scopes: z.array(ScopeSchema).min(1),\n branchTypes: z.array(BranchTypeSchema).optional(),\n conventionalTypes: z.array(ConventionalTypeSchema).optional(),\n enforcement: EnforcementLevelSchema.default(\"strict\"),\n language: z.string().default(\"en\"),\n analytics: AnalyticsConfigSchema.optional(),\n adapter: z.string().optional(),\n syncRemote: z.string().optional(),\n ci: CIConfigSchema.optional(),\n hooks: HooksConfigSchema.optional(),\n guidelines: GuidelinesConfigSchema.optional(),\n advisory: AdvisoryConfigSchema.optional(),\n});\n\nexport type Scope = z.infer<typeof ScopeSchema>;\nexport type BranchType = z.infer<typeof BranchTypeSchema>;\nexport type ConventionalType = z.infer<typeof ConventionalTypeSchema>;\nexport type EnforcementLevel = z.infer<typeof EnforcementLevelSchema>;\nexport type AnalyticsConfig = z.infer<typeof AnalyticsConfigSchema>;\nexport type CIConfig = z.infer<typeof CIConfigSchema>;\nexport type HooksConfig = z.infer<typeof HooksConfigSchema>;\nexport type GuidelinesConfig = z.infer<typeof GuidelinesConfigSchema>;\nexport type AdvisoryDepth = z.infer<typeof AdvisoryDepthSchema>;\nexport type AdvisoryQuestion = z.infer<typeof AdvisoryQuestionSchema>;\nexport type AdvisoryConfig = z.infer<typeof AdvisoryConfigSchema>;\nexport type WorkflowConfig = z.infer<typeof WorkflowConfigSchema>;\n\nexport const defaultBranchTypes: BranchType[] = [\n \"feature\",\n \"bugfix\",\n \"hotfix\",\n \"chore\",\n \"refactor\",\n \"docs\",\n \"test\",\n];\n\nexport const defaultConventionalTypes: ConventionalType[] = [\n \"feat\",\n \"fix\",\n \"refactor\",\n \"chore\",\n \"docs\",\n \"test\",\n \"perf\",\n \"style\",\n];\n\n/**\n * Validates scope definitions for duplicates, description quality, and category values\n * @param scopes Array of scope definitions to validate\n * @returns Object with validation result and error messages\n */\nexport function validateScopeDefinitions(scopes: Scope[]): {\n valid: boolean;\n errors: string[];\n} {\n const errors: string[] = [];\n const seenNames = new Set<string>();\n\n for (const scope of scopes) {\n // Check for duplicate names\n if (seenNames.has(scope.name)) {\n errors.push(`Duplicate scope name: \"${scope.name}\"`);\n }\n seenNames.add(scope.name);\n\n // Validate using schema (this will catch min length, reserved names, etc.)\n const result = ScopeSchema.safeParse(scope);\n if (!result.success) {\n result.error.errors.forEach((err) => {\n errors.push(`Scope \"${scope.name}\": ${err.message}`);\n });\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n"],"mappings":";AAOA,SAAS,WAAW,gBAAgB;AACpC,SAAS,kBAAkB;AAC3B,SAAS,YAAY;;;ACTrB,SAAS,SAAS;AAGlB,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,cAAc,EAAE,OAAO;AAAA,EAClC,MAAM,EACH,OAAO,EACP,IAAI,CAAC,EACL,IAAI,IAAI,0CAA0C,EAClD;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,CAAC,SAAS,CAAC,qBAAqB,SAAS,IAAI,GAAG;AAAA,IACtD,SAAS,yCAAyC,qBAAqB,KAAK,IAAI,CAAC;AAAA,EACnF,CAAC;AAAA,EACH,aAAa,EACV,OAAO,EACP,IAAI,IAAI,kDAAkD;AAAA,EAC7D,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,UAAU,EACP,KAAK;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC,EACA,SAAS;AACd,CAAC;AAEM,IAAM,mBAAmB,EAAE,KAAK;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,yBAAyB,EAAE,KAAK;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,yBAAyB,EAAE,KAAK;AAAA,EAC3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,MACA,SAAS,CAAC;AAAA,MACV,OAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IAClD;AAAA,EACF;AACF;AAIA,SAAS,eAAe,aAA6B;AACnD,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AACA,MAAI,YAAY,UAAU,IAAI;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,CAAC,YAAY,YAAY,SAAS,QAAQ;AAC3D,aAAW,UAAU,UAAU;AAC7B,SAAK,cAAc,QAAQ,UAAU,IAAI;AACvC,aAAO,cAAc;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,cAAc;AACvB;AAEA,SAAS,eAAe,KAAc,MAAoC;AACxE,MAAI,UAAmB;AACvB,aAAW,OAAO,MAAM;AACtB,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC7C,aAAO;AAAA,IACT;AACA,cAAW,QAAoC,GAAG;AAAA,EACpD;AACA,SAAO;AACT;AAEA,SAAS,eAAe,KAAc,MAAgB,OAAsB;AAC1E,MAAI,UAAmC;AACvC,WAAS,IAAI,GAAG,IAAI,KAAK,SAAS,GAAG,KAAK;AACxC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,QAAQ,GAAG,MAAM,QAAW;AAC9B,cAAQ,GAAG,IAAI,CAAC;AAAA,IAClB;AACA,cAAU,QAAQ,GAAG;AAAA,EACvB;AACA,UAAQ,KAAK,KAAK,SAAS,CAAC,CAAC,IAAI;AACnC;","names":[]}
package/dist/cli/index.js CHANGED
@@ -19,8 +19,8 @@ import {
19
19
  import {
20
20
  hasConfig,
21
21
  loadConfig,
22
- validateScopeDefinitions
23
- } from "../chunk-DEAF7P4L.js";
22
+ loadConfigSafe
23
+ } from "../chunk-UWJ2ZGEI.js";
24
24
  import {
25
25
  SCRIPT_CATEGORIES,
26
26
  TOTAL_SCRIPTS,
@@ -32,6 +32,10 @@ import {
32
32
  templateMetadata,
33
33
  updateTemplates
34
34
  } from "../chunk-YEOQZ7XC.js";
35
+ import {
36
+ autoFixConfigFile,
37
+ validateScopeDefinitions
38
+ } from "../chunk-YELUGXOM.js";
35
39
 
36
40
  // src/cli/index.ts
37
41
  import { Command } from "commander";
@@ -789,12 +793,48 @@ async function uninstallHooks(projectPath = process.cwd()) {
789
793
  // src/cli/commands/doctor.ts
790
794
  async function doctorCommand(options) {
791
795
  console.log(chalk5.bold.cyan("\n\u{1F3E5} Workflow Agent Health Check\n"));
792
- const config = await loadConfig();
793
- if (!config) {
796
+ const result = await loadConfigSafe();
797
+ if (!result.configPath && !result.rawConfig) {
794
798
  console.error(chalk5.red("\u2717 No workflow configuration found"));
795
799
  console.log(chalk5.yellow(" Run: workflow init"));
796
800
  process.exit(1);
797
801
  }
802
+ if (!result.valid && result.issues.length > 0) {
803
+ console.log(chalk5.yellow("\u26A0 Configuration has validation issues:\n"));
804
+ for (const issue of result.issues) {
805
+ console.log(chalk5.red(` \u2717 ${issue.path}: ${issue.message}`));
806
+ if (issue.currentValue !== void 0) {
807
+ console.log(chalk5.dim(` Current value: ${JSON.stringify(issue.currentValue)}`));
808
+ }
809
+ if (issue.suggestedFix) {
810
+ console.log(chalk5.green(` Suggested fix: ${issue.suggestedFix.description}`));
811
+ console.log(chalk5.dim(` New value: ${JSON.stringify(issue.suggestedFix.newValue)}`));
812
+ }
813
+ }
814
+ const hasAutoFixes = result.issues.some((i) => i.suggestedFix);
815
+ if (hasAutoFixes) {
816
+ if (options?.fix) {
817
+ console.log(chalk5.cyan("\n\u{1F527} Attempting to auto-fix issues...\n"));
818
+ const fixResult = await autoFixConfigFile();
819
+ if (fixResult.success) {
820
+ console.log(chalk5.green("\u2713 Configuration fixed successfully!\n"));
821
+ for (const change of fixResult.changes) {
822
+ console.log(chalk5.dim(` \u2022 ${change}`));
823
+ }
824
+ console.log(chalk5.cyan("\n Run 'workflow doctor' again to verify.\n"));
825
+ process.exit(0);
826
+ } else {
827
+ console.log(chalk5.red(`\u2717 Auto-fix failed: ${fixResult.error}`));
828
+ process.exit(1);
829
+ }
830
+ } else {
831
+ console.log(chalk5.cyan("\n\u{1F4A1} Auto-fix available!"));
832
+ console.log(chalk5.dim(" Run: workflow doctor --fix\n"));
833
+ }
834
+ }
835
+ process.exit(1);
836
+ }
837
+ const config = result.config;
798
838
  console.log(chalk5.green("\u2713 Configuration loaded successfully"));
799
839
  console.log(chalk5.dim(` Project: ${config.projectName}`));
800
840
  console.log(chalk5.dim(` Scopes: ${config.scopes.length} configured`));
@@ -6281,12 +6321,39 @@ program.command("validate <type>").description("Validate branch name, commit mes
6281
6321
  "Offer improvement suggestions on validation errors"
6282
6322
  ).action(validateCommand);
6283
6323
  program.command("config <action>").description("Manage workflow configuration").argument("<action>", "Action: get, set, add, remove").argument("[key]", "Config key").argument("[value]", "Config value").action(configCommand);
6324
+ program.command("config:fix").description("Automatically fix common configuration validation issues").action(async () => {
6325
+ const chalk18 = (await import("chalk")).default;
6326
+ const { autoFixConfigFile: autoFixConfigFile2 } = await import("../config/index.js");
6327
+ console.log(chalk18.bold.cyan("\n\u{1F527} Workflow Configuration Auto-Fix\n"));
6328
+ const result = await autoFixConfigFile2();
6329
+ if (result.success) {
6330
+ if (result.changes.length === 0) {
6331
+ console.log(chalk18.green("\u2713 Configuration is already valid!"));
6332
+ } else {
6333
+ console.log(chalk18.green("\u2713 Configuration fixed successfully!\n"));
6334
+ console.log(chalk18.dim("Changes made:"));
6335
+ for (const change of result.changes) {
6336
+ console.log(chalk18.dim(` \u2022 ${change}`));
6337
+ }
6338
+ console.log();
6339
+ }
6340
+ process.exit(0);
6341
+ } else {
6342
+ if (result.configPath) {
6343
+ console.log(chalk18.red(`\u2717 Failed to fix configuration: ${result.error}`));
6344
+ } else {
6345
+ console.log(chalk18.red("\u2717 No workflow configuration file found"));
6346
+ console.log(chalk18.yellow(" Run: workflow init"));
6347
+ }
6348
+ process.exit(1);
6349
+ }
6350
+ });
6284
6351
  program.command("suggest").description("Submit an improvement suggestion").argument("<feedback>", "Your improvement suggestion").option("--author <author>", "Your name or username").option(
6285
6352
  "--category <category>",
6286
6353
  "Category: feature, bug, documentation, performance, other"
6287
6354
  ).action(suggestCommand);
6288
6355
  program.command("setup").description("Add workflow scripts to package.json").action(setupCommand);
6289
- program.command("doctor").description("Run health check and get optimization suggestions").option("--check-guidelines-only", "Only check guidelines presence").action(doctorCommand);
6356
+ program.command("doctor").description("Run health check and get optimization suggestions").option("--check-guidelines-only", "Only check guidelines presence").option("--fix", "Automatically fix validation issues in configuration").action(doctorCommand);
6290
6357
  program.command("hooks <action>").description("Manage git hooks").action(hooksCommand);
6291
6358
  program.command("scope:create").description("Create a custom scope package").option("--name <name>", 'Package name (e.g., "fintech", "gaming")').option(
6292
6359
  "--scopes <scopes>",