workflow-agent-cli 2.2.0 → 2.2.2

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,13 +1,8 @@
1
- import { W as WorkflowConfig } from '../schema-C1lmnd7L.js';
2
- export { B as BranchType, C as ConventionalType, D as DEFAULT_RESERVED_SCOPE_NAMES, S as Scope, a as WorkflowConfigSchema, v as validateScopeName } from '../schema-C1lmnd7L.js';
1
+ import { W as WorkflowConfig } from '../schema-OJg7YAI_.js';
2
+ export { B as BranchType, C as ConventionalType, S as Scope, a as WorkflowConfigSchema } from '../schema-OJg7YAI_.js';
3
3
  import 'zod';
4
4
 
5
5
  declare function loadConfig(cwd?: string): Promise<WorkflowConfig | null>;
6
- declare function validateConfig(cwd?: string): Promise<{
7
- valid: boolean;
8
- errors: string[];
9
- warnings: string[];
10
- }>;
11
6
  declare function hasConfig(cwd?: string): boolean;
12
7
 
13
- export { WorkflowConfig, hasConfig, loadConfig, validateConfig };
8
+ export { WorkflowConfig, hasConfig, loadConfig };
@@ -1,17 +1,11 @@
1
1
  import {
2
- DEFAULT_RESERVED_SCOPE_NAMES,
3
2
  WorkflowConfigSchema,
4
3
  hasConfig,
5
- loadConfig,
6
- validateConfig,
7
- validateScopeName
8
- } from "../chunk-IPMSSOXR.js";
4
+ loadConfig
5
+ } from "../chunk-RDVTKGQV.js";
9
6
  export {
10
- DEFAULT_RESERVED_SCOPE_NAMES,
11
7
  WorkflowConfigSchema,
12
8
  hasConfig,
13
- loadConfig,
14
- validateConfig,
15
- validateScopeName
9
+ loadConfig
16
10
  };
17
11
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,49 @@
1
- export { hasConfig, loadConfig, validateConfig } from './config/index.js';
1
+ export { hasConfig, loadConfig } from './config/index.js';
2
2
  export { ValidationResult, discoverCustomScopes, getAllScopes, invalidateCustomScopesCache, validateBranchName, validateCommitMessage, validatePRTitle } from './validators/index.js';
3
- export { B as BranchType, C as ConventionalType, D as DEFAULT_RESERVED_SCOPE_NAMES, S as Scope, W as WorkflowConfig, a as WorkflowConfigSchema, v as validateScopeName } from './schema-C1lmnd7L.js';
3
+ export { B as BranchType, C as ConventionalType, S as Scope, W as WorkflowConfig, a as WorkflowConfigSchema } from './schema-OJg7YAI_.js';
4
4
  import 'zod';
5
+
6
+ interface CheckDefinition {
7
+ name: string;
8
+ displayName: string;
9
+ command: string;
10
+ args: string[];
11
+ fixCommand?: string;
12
+ fixArgs?: string[];
13
+ canAutoFix: boolean;
14
+ }
15
+ interface CheckResult {
16
+ check: CheckDefinition;
17
+ success: boolean;
18
+ output: string;
19
+ error?: string;
20
+ duration: number;
21
+ }
22
+ interface RunAllChecksResult {
23
+ success: boolean;
24
+ results: CheckResult[];
25
+ totalAttempts: number;
26
+ fixesApplied: number;
27
+ pendingFixes?: Array<{
28
+ check: CheckDefinition;
29
+ command: string;
30
+ }>;
31
+ }
32
+ type ProgressType = "info" | "success" | "error" | "warning";
33
+ interface CheckRunnerOptions {
34
+ maxRetries?: number;
35
+ autoFix?: boolean;
36
+ dryRun?: boolean;
37
+ onProgress?: (message: string, type: ProgressType) => void;
38
+ }
39
+ declare const QUALITY_CHECKS: CheckDefinition[];
40
+ declare function runCheck(check: CheckDefinition, cwd: string): Promise<CheckResult>;
41
+ declare function applyFix(check: CheckDefinition, cwd: string): Promise<{
42
+ success: boolean;
43
+ output: string;
44
+ }>;
45
+ declare function runAllChecks(cwd: string, options?: CheckRunnerOptions): Promise<RunAllChecksResult>;
46
+ declare function hasUncommittedChanges(cwd: string): Promise<boolean>;
47
+ declare function stageAllChanges(cwd: string): Promise<boolean>;
48
+
49
+ export { type CheckDefinition, type CheckResult, type CheckRunnerOptions, type ProgressType, QUALITY_CHECKS, type RunAllChecksResult, applyFix, hasUncommittedChanges, runAllChecks, runCheck, stageAllChanges };
package/dist/index.js CHANGED
@@ -1,3 +1,11 @@
1
+ import {
2
+ QUALITY_CHECKS,
3
+ applyFix,
4
+ hasUncommittedChanges,
5
+ runAllChecks,
6
+ runCheck,
7
+ stageAllChanges
8
+ } from "./chunk-AN6UOHBB.js";
1
9
  import {
2
10
  discoverCustomScopes,
3
11
  getAllScopes,
@@ -7,25 +15,25 @@ import {
7
15
  validatePRTitle
8
16
  } from "./chunk-NMHWD2GA.js";
9
17
  import {
10
- DEFAULT_RESERVED_SCOPE_NAMES,
11
18
  WorkflowConfigSchema,
12
19
  hasConfig,
13
- loadConfig,
14
- validateConfig,
15
- validateScopeName
16
- } from "./chunk-IPMSSOXR.js";
20
+ loadConfig
21
+ } from "./chunk-RDVTKGQV.js";
17
22
  export {
18
- DEFAULT_RESERVED_SCOPE_NAMES,
23
+ QUALITY_CHECKS,
19
24
  WorkflowConfigSchema,
25
+ applyFix,
20
26
  discoverCustomScopes,
21
27
  getAllScopes,
22
28
  hasConfig,
29
+ hasUncommittedChanges,
23
30
  invalidateCustomScopesCache,
24
31
  loadConfig,
32
+ runAllChecks,
33
+ runCheck,
34
+ stageAllChanges,
25
35
  validateBranchName,
26
36
  validateCommitMessage,
27
- validateConfig,
28
- validatePRTitle,
29
- validateScopeName
37
+ validatePRTitle
30
38
  };
31
39
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,181 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const ScopeSchema: z.ZodObject<{
4
+ name: z.ZodEffects<z.ZodString, string, string>;
5
+ description: z.ZodString;
6
+ emoji: z.ZodOptional<z.ZodString>;
7
+ category: z.ZodOptional<z.ZodEnum<["auth", "features", "infrastructure", "documentation", "testing", "performance", "other"]>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ name: string;
10
+ description: string;
11
+ emoji?: string | undefined;
12
+ category?: "auth" | "features" | "infrastructure" | "documentation" | "testing" | "performance" | "other" | undefined;
13
+ }, {
14
+ name: string;
15
+ description: string;
16
+ emoji?: string | undefined;
17
+ category?: "auth" | "features" | "infrastructure" | "documentation" | "testing" | "performance" | "other" | undefined;
18
+ }>;
19
+ declare const BranchTypeSchema: z.ZodEnum<["feature", "bugfix", "hotfix", "chore", "refactor", "docs", "test", "release"]>;
20
+ declare const ConventionalTypeSchema: z.ZodEnum<["feat", "fix", "refactor", "chore", "docs", "test", "perf", "style", "ci", "build", "revert"]>;
21
+ declare const WorkflowConfigSchema: z.ZodObject<{
22
+ projectName: z.ZodString;
23
+ scopes: z.ZodArray<z.ZodObject<{
24
+ name: z.ZodEffects<z.ZodString, string, string>;
25
+ description: z.ZodString;
26
+ emoji: z.ZodOptional<z.ZodString>;
27
+ category: z.ZodOptional<z.ZodEnum<["auth", "features", "infrastructure", "documentation", "testing", "performance", "other"]>>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ name: string;
30
+ description: string;
31
+ emoji?: string | undefined;
32
+ category?: "auth" | "features" | "infrastructure" | "documentation" | "testing" | "performance" | "other" | undefined;
33
+ }, {
34
+ name: string;
35
+ description: string;
36
+ emoji?: string | undefined;
37
+ category?: "auth" | "features" | "infrastructure" | "documentation" | "testing" | "performance" | "other" | undefined;
38
+ }>, "many">;
39
+ branchTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["feature", "bugfix", "hotfix", "chore", "refactor", "docs", "test", "release"]>, "many">>;
40
+ conventionalTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["feat", "fix", "refactor", "chore", "docs", "test", "perf", "style", "ci", "build", "revert"]>, "many">>;
41
+ enforcement: z.ZodDefault<z.ZodEnum<["strict", "advisory", "learning"]>>;
42
+ language: z.ZodDefault<z.ZodString>;
43
+ analytics: z.ZodOptional<z.ZodObject<{
44
+ enabled: z.ZodDefault<z.ZodBoolean>;
45
+ shareAnonymous: z.ZodDefault<z.ZodBoolean>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ enabled: boolean;
48
+ shareAnonymous: boolean;
49
+ }, {
50
+ enabled?: boolean | undefined;
51
+ shareAnonymous?: boolean | undefined;
52
+ }>>;
53
+ adapter: z.ZodOptional<z.ZodString>;
54
+ syncRemote: z.ZodOptional<z.ZodString>;
55
+ ci: z.ZodOptional<z.ZodObject<{
56
+ provider: z.ZodDefault<z.ZodEnum<["github", "gitlab", "azure"]>>;
57
+ nodeVersions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
58
+ defaultBranch: z.ZodDefault<z.ZodString>;
59
+ checks: z.ZodOptional<z.ZodArray<z.ZodEnum<["lint", "typecheck", "format", "build", "test"]>, "many">>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ provider: "github" | "gitlab" | "azure";
62
+ defaultBranch: string;
63
+ nodeVersions?: string[] | undefined;
64
+ checks?: ("build" | "test" | "lint" | "typecheck" | "format")[] | undefined;
65
+ }, {
66
+ provider?: "github" | "gitlab" | "azure" | undefined;
67
+ nodeVersions?: string[] | undefined;
68
+ defaultBranch?: string | undefined;
69
+ checks?: ("build" | "test" | "lint" | "typecheck" | "format")[] | undefined;
70
+ }>>;
71
+ hooks: z.ZodOptional<z.ZodObject<{
72
+ preCommit: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
+ commitMsg: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
74
+ prePush: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ preCommit?: string[] | undefined;
77
+ commitMsg?: string[] | undefined;
78
+ prePush?: string[] | undefined;
79
+ }, {
80
+ preCommit?: string[] | undefined;
81
+ commitMsg?: string[] | undefined;
82
+ prePush?: string[] | undefined;
83
+ }>>;
84
+ guidelines: z.ZodOptional<z.ZodObject<{
85
+ mandatoryTemplates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
+ optionalTemplates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
87
+ customTemplatesDir: z.ZodOptional<z.ZodString>;
88
+ additionalMandatory: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
89
+ optionalOverrides: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ mandatoryTemplates?: string[] | undefined;
92
+ optionalTemplates?: string[] | undefined;
93
+ customTemplatesDir?: string | undefined;
94
+ additionalMandatory?: string[] | undefined;
95
+ optionalOverrides?: string[] | undefined;
96
+ }, {
97
+ mandatoryTemplates?: string[] | undefined;
98
+ optionalTemplates?: string[] | undefined;
99
+ customTemplatesDir?: string | undefined;
100
+ additionalMandatory?: string[] | undefined;
101
+ optionalOverrides?: string[] | undefined;
102
+ }>>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ projectName: string;
105
+ scopes: {
106
+ name: string;
107
+ description: string;
108
+ emoji?: string | undefined;
109
+ category?: "auth" | "features" | "infrastructure" | "documentation" | "testing" | "performance" | "other" | undefined;
110
+ }[];
111
+ enforcement: "strict" | "advisory" | "learning";
112
+ language: string;
113
+ ci?: {
114
+ provider: "github" | "gitlab" | "azure";
115
+ defaultBranch: string;
116
+ nodeVersions?: string[] | undefined;
117
+ checks?: ("build" | "test" | "lint" | "typecheck" | "format")[] | undefined;
118
+ } | undefined;
119
+ branchTypes?: ("test" | "docs" | "feature" | "bugfix" | "hotfix" | "chore" | "refactor" | "release")[] | undefined;
120
+ conventionalTypes?: ("build" | "test" | "docs" | "ci" | "chore" | "refactor" | "feat" | "fix" | "perf" | "style" | "revert")[] | undefined;
121
+ analytics?: {
122
+ enabled: boolean;
123
+ shareAnonymous: boolean;
124
+ } | undefined;
125
+ adapter?: string | undefined;
126
+ syncRemote?: string | undefined;
127
+ hooks?: {
128
+ preCommit?: string[] | undefined;
129
+ commitMsg?: string[] | undefined;
130
+ prePush?: string[] | undefined;
131
+ } | undefined;
132
+ guidelines?: {
133
+ mandatoryTemplates?: string[] | undefined;
134
+ optionalTemplates?: string[] | undefined;
135
+ customTemplatesDir?: string | undefined;
136
+ additionalMandatory?: string[] | undefined;
137
+ optionalOverrides?: string[] | undefined;
138
+ } | undefined;
139
+ }, {
140
+ projectName: string;
141
+ scopes: {
142
+ name: string;
143
+ description: string;
144
+ emoji?: string | undefined;
145
+ category?: "auth" | "features" | "infrastructure" | "documentation" | "testing" | "performance" | "other" | undefined;
146
+ }[];
147
+ ci?: {
148
+ provider?: "github" | "gitlab" | "azure" | undefined;
149
+ nodeVersions?: string[] | undefined;
150
+ defaultBranch?: string | undefined;
151
+ checks?: ("build" | "test" | "lint" | "typecheck" | "format")[] | undefined;
152
+ } | undefined;
153
+ branchTypes?: ("test" | "docs" | "feature" | "bugfix" | "hotfix" | "chore" | "refactor" | "release")[] | undefined;
154
+ conventionalTypes?: ("build" | "test" | "docs" | "ci" | "chore" | "refactor" | "feat" | "fix" | "perf" | "style" | "revert")[] | undefined;
155
+ enforcement?: "strict" | "advisory" | "learning" | undefined;
156
+ language?: string | undefined;
157
+ analytics?: {
158
+ enabled?: boolean | undefined;
159
+ shareAnonymous?: boolean | undefined;
160
+ } | undefined;
161
+ adapter?: string | undefined;
162
+ syncRemote?: string | undefined;
163
+ hooks?: {
164
+ preCommit?: string[] | undefined;
165
+ commitMsg?: string[] | undefined;
166
+ prePush?: string[] | undefined;
167
+ } | undefined;
168
+ guidelines?: {
169
+ mandatoryTemplates?: string[] | undefined;
170
+ optionalTemplates?: string[] | undefined;
171
+ customTemplatesDir?: string | undefined;
172
+ additionalMandatory?: string[] | undefined;
173
+ optionalOverrides?: string[] | undefined;
174
+ } | undefined;
175
+ }>;
176
+ type Scope = z.infer<typeof ScopeSchema>;
177
+ type BranchType = z.infer<typeof BranchTypeSchema>;
178
+ type ConventionalType = z.infer<typeof ConventionalTypeSchema>;
179
+ type WorkflowConfig = z.infer<typeof WorkflowConfigSchema>;
180
+
181
+ export { type BranchType as B, type ConventionalType as C, type Scope as S, type WorkflowConfig as W, WorkflowConfigSchema as a };
@@ -1,4 +1,4 @@
1
- import { S as Scope, W as WorkflowConfig } from '../schema-C1lmnd7L.js';
1
+ import { S as Scope, W as WorkflowConfig } from '../schema-OJg7YAI_.js';
2
2
  import 'zod';
3
3
 
4
4
  interface ValidationResult {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow-agent-cli",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "A self-evolving workflow management system for AI agent development",
5
5
  "keywords": [
6
6
  "workflow",
@@ -44,12 +44,9 @@
44
44
  "scripts": {
45
45
  "build": "tsup",
46
46
  "dev": "tsup --watch",
47
- "test": "vitest run",
48
- "test:watch": "vitest",
49
- "test:coverage": "vitest run --coverage",
50
- "test:unit": "vitest run --exclude 'src/**/*.e2e.test.ts'",
51
- "test:e2e": "vitest run 'src/**/*.e2e.test.ts'",
52
- "lint": "exit 0",
47
+ "test": "echo \"No tests yet\"",
48
+ "test:coverage": "echo \"No tests yet\"",
49
+ "lint": "echo \"ESLint not configured - skipping\"",
53
50
  "typecheck": "tsc --noEmit",
54
51
  "clean": "rm -rf dist",
55
52
  "postinstall": "node dist/scripts/postinstall.js || true"
@@ -65,13 +62,11 @@
65
62
  "fast-glob": "^3.3.2",
66
63
  "mustache": "^4.2.0",
67
64
  "picocolors": "^1.0.0",
68
- "prompts": "^2.4.2",
69
65
  "zod": "^3.22.4"
70
66
  },
71
67
  "devDependencies": {
72
68
  "@types/mustache": "^4.2.5",
73
69
  "@types/node": "^20.11.5",
74
- "@types/prompts": "^2.4.9",
75
70
  "eslint": "^8.56.0",
76
71
  "tsup": "^8.0.1",
77
72
  "typescript": "^5.3.3",
@@ -1,293 +0,0 @@
1
- // src/config/index.ts
2
- import { cosmiconfig } from "cosmiconfig";
3
-
4
- // src/config/schema.ts
5
- import { z } from "zod";
6
- var DEFAULT_RESERVED_SCOPE_NAMES = [
7
- "init",
8
- "create",
9
- "build",
10
- "test",
11
- "config",
12
- "docs",
13
- "ci",
14
- "deps"
15
- ];
16
- function validateScopeName(name, reservedNames = DEFAULT_RESERVED_SCOPE_NAMES) {
17
- if (reservedNames.includes(name)) {
18
- const suggestions = {
19
- docs: "documentation",
20
- test: "testing",
21
- config: "configuration",
22
- build: "builds",
23
- ci: "cicd",
24
- deps: "dependencies"
25
- };
26
- return {
27
- valid: false,
28
- error: `Scope name "${name}" is reserved`,
29
- suggestion: suggestions[name] || `${name}-scope`
30
- };
31
- }
32
- if (!/^[a-z0-9-]+$/.test(name)) {
33
- return {
34
- valid: false,
35
- error: "Scope name must be lowercase alphanumeric with hyphens"
36
- };
37
- }
38
- if (name.length === 0 || name.length > 32) {
39
- return {
40
- valid: false,
41
- error: "Scope name must be 1-32 characters"
42
- };
43
- }
44
- return { valid: true };
45
- }
46
- var BranchTypeSchema = z.enum([
47
- "feature",
48
- "bugfix",
49
- "hotfix",
50
- "chore",
51
- "refactor",
52
- "docs",
53
- "test",
54
- "release"
55
- ]);
56
- var ConventionalTypeSchema = z.enum([
57
- "feat",
58
- "fix",
59
- "refactor",
60
- "chore",
61
- "docs",
62
- "test",
63
- "perf",
64
- "style",
65
- "ci",
66
- "build",
67
- "revert"
68
- ]);
69
- var ScopeSchema = z.object({
70
- name: z.string().min(1).max(32, "Scope name must be 32 characters or less").regex(
71
- /^[a-z0-9-]+$/,
72
- "Scope name must be lowercase alphanumeric with hyphens"
73
- ),
74
- description: z.string().min(10, "Scope description must be at least 10 characters"),
75
- allowedTypes: z.array(ConventionalTypeSchema).optional(),
76
- mandatoryGuidelines: z.array(z.string()).optional(),
77
- emoji: z.string().optional(),
78
- category: z.enum([
79
- "auth",
80
- "features",
81
- "infrastructure",
82
- "documentation",
83
- "testing",
84
- "performance",
85
- "other"
86
- ]).optional()
87
- });
88
- var EnforcementLevelSchema = z.enum([
89
- "strict",
90
- "advisory",
91
- "learning"
92
- ]);
93
- var AnalyticsConfigSchema = z.object({
94
- enabled: z.boolean().default(false),
95
- shareAnonymous: z.boolean().default(false)
96
- });
97
- var HookCheckSchema = z.enum([
98
- "validate-branch",
99
- "validate-commit",
100
- "check-guidelines",
101
- "validate-scopes"
102
- ]);
103
- var HooksConfigSchema = z.object({
104
- /** Whether hooks are enabled */
105
- enabled: z.boolean().default(true),
106
- /** Checks to run on pre-commit */
107
- preCommit: z.array(HookCheckSchema).default(["validate-branch", "check-guidelines"]),
108
- /** Checks to run on commit-msg */
109
- commitMsg: z.array(HookCheckSchema).default(["validate-commit"])
110
- });
111
- var GuidelinesConfigSchema = z.object({
112
- /** Additional templates to make mandatory (beyond the core set) */
113
- additionalMandatory: z.array(z.string()).optional(),
114
- /** Templates to make optional (override core mandatory templates) */
115
- optionalOverrides: z.array(z.string()).optional()
116
- });
117
- var CIProviderSchema = z.enum(["github", "gitlab", "bitbucket"]);
118
- var CICheckSchema = z.enum([
119
- "lint",
120
- "typecheck",
121
- "format",
122
- "test",
123
- "build"
124
- ]);
125
- var CIConfigSchema = z.object({
126
- /** Whether CI setup is enabled */
127
- enabled: z.boolean().default(true),
128
- /** CI provider (currently only github supported) */
129
- provider: CIProviderSchema.default("github"),
130
- /** Checks to run in CI pipeline */
131
- checks: z.array(CICheckSchema).default(["lint", "typecheck", "format", "build", "test"])
132
- });
133
- var WorkflowConfigSchema = z.object({
134
- projectName: z.string().min(1),
135
- scopes: z.array(ScopeSchema).min(1),
136
- branchTypes: z.array(BranchTypeSchema).optional(),
137
- conventionalTypes: z.array(ConventionalTypeSchema).optional(),
138
- enforcement: EnforcementLevelSchema.default("strict"),
139
- language: z.string().default("en"),
140
- analytics: AnalyticsConfigSchema.optional(),
141
- adapter: z.string().optional(),
142
- syncRemote: z.string().optional(),
143
- hooks: HooksConfigSchema.optional(),
144
- guidelines: GuidelinesConfigSchema.optional(),
145
- reservedScopeNames: z.array(z.string()).optional().default(DEFAULT_RESERVED_SCOPE_NAMES),
146
- ci: CIConfigSchema.optional()
147
- }).superRefine((config, ctx) => {
148
- const reservedNames = config.reservedScopeNames || DEFAULT_RESERVED_SCOPE_NAMES;
149
- config.scopes.forEach((scope, index) => {
150
- const validation = validateScopeName(scope.name, reservedNames);
151
- if (!validation.valid) {
152
- let message = validation.error || "Invalid scope name";
153
- if (validation.suggestion) {
154
- message += `. Try renaming to "${validation.suggestion}"`;
155
- }
156
- ctx.addIssue({
157
- code: z.ZodIssueCode.custom,
158
- path: ["scopes", index, "name"],
159
- message
160
- });
161
- }
162
- });
163
- });
164
- function validateScopeDefinitions(scopes) {
165
- const errors = [];
166
- const seenNames = /* @__PURE__ */ new Set();
167
- for (const scope of scopes) {
168
- if (seenNames.has(scope.name)) {
169
- errors.push(`Duplicate scope name: "${scope.name}"`);
170
- }
171
- seenNames.add(scope.name);
172
- const result = ScopeSchema.safeParse(scope);
173
- if (!result.success) {
174
- result.error.errors.forEach((err) => {
175
- errors.push(`Scope "${scope.name}": ${err.message}`);
176
- });
177
- }
178
- }
179
- return {
180
- valid: errors.length === 0,
181
- errors
182
- };
183
- }
184
-
185
- // src/config/index.ts
186
- import { join } from "path";
187
- import { existsSync } from "fs";
188
- import { z as z2 } from "zod";
189
- var explorer = cosmiconfig("workflow", {
190
- searchPlaces: [
191
- "workflow.config.ts",
192
- "workflow.config.js",
193
- "workflow.config.json",
194
- ".workflowrc",
195
- ".workflowrc.json",
196
- "package.json"
197
- ]
198
- });
199
- async function loadConfig(cwd = process.cwd()) {
200
- try {
201
- const result = await explorer.search(cwd);
202
- if (!result || !result.config) {
203
- return null;
204
- }
205
- const validated = WorkflowConfigSchema.parse(result.config);
206
- return validated;
207
- } catch (error) {
208
- if (error instanceof z2.ZodError) {
209
- const result = await explorer.search(cwd);
210
- const formattedErrors = error.errors.map((err) => {
211
- const path = err.path.join(".");
212
- if (err.path[0] === "scopes" && typeof err.path[1] === "number") {
213
- const scopeIndex = err.path[1];
214
- const scopeName = result?.config?.scopes?.[scopeIndex]?.name || `scope at index ${scopeIndex}`;
215
- const field = err.path[2] || "definition";
216
- let message = err.message;
217
- if (message.includes("reserved word")) {
218
- const reservedMatch = message.match(
219
- /Scope name "([^"]+)" is reserved/
220
- );
221
- if (reservedMatch) {
222
- const suggestions = {
223
- docs: "documentation",
224
- test: "testing",
225
- config: "configuration",
226
- build: "builds",
227
- ci: "cicd",
228
- deps: "dependencies"
229
- };
230
- const badName = reservedMatch[1];
231
- const suggestion = suggestions[badName] || `${badName}-scope`;
232
- message = `${message}. Try renaming to "${suggestion}"`;
233
- }
234
- }
235
- return field === "definition" ? `Scope "${scopeName}": ${message}` : `Scope "${scopeName}" ${field}: ${message}`;
236
- }
237
- return `${path}: ${err.message}`;
238
- }).join("\n \u2022 ");
239
- throw new Error(
240
- `Invalid workflow configuration:
241
- \u2022 ${formattedErrors}
242
-
243
- \u{1F4A1} Fix these issues in workflow.config.json or run: workflow config validate`
244
- );
245
- }
246
- if (error instanceof Error) {
247
- throw new Error(`Failed to load workflow config: ${error.message}`);
248
- }
249
- throw error;
250
- }
251
- }
252
- async function validateConfig(cwd = process.cwd()) {
253
- const errors = [];
254
- const warnings = [];
255
- try {
256
- const config = await loadConfig(cwd);
257
- if (!config) {
258
- errors.push("No configuration file found");
259
- return { valid: false, errors, warnings };
260
- }
261
- const scopeValidation = validateScopeDefinitions(config.scopes);
262
- errors.push(...scopeValidation.errors);
263
- return {
264
- valid: errors.length === 0,
265
- errors,
266
- warnings
267
- };
268
- } catch (error) {
269
- errors.push(error instanceof Error ? error.message : String(error));
270
- return { valid: false, errors, warnings };
271
- }
272
- }
273
- function hasConfig(cwd = process.cwd()) {
274
- const configPaths = [
275
- "workflow.config.ts",
276
- "workflow.config.js",
277
- "workflow.config.json",
278
- ".workflowrc",
279
- ".workflowrc.json"
280
- ];
281
- return configPaths.some((path) => existsSync(join(cwd, path)));
282
- }
283
-
284
- export {
285
- DEFAULT_RESERVED_SCOPE_NAMES,
286
- validateScopeName,
287
- WorkflowConfigSchema,
288
- validateScopeDefinitions,
289
- loadConfig,
290
- validateConfig,
291
- hasConfig
292
- };
293
- //# sourceMappingURL=chunk-IPMSSOXR.js.map