@vibe-validate/config 0.9.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.
package/dist/schema.js ADDED
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Configuration Schema with Zod Validation
3
+ *
4
+ * TypeScript-first configuration system for vibe-validate.
5
+ * Provides runtime validation and type safety for all configuration options.
6
+ */
7
+ import { z } from 'zod';
8
+ /**
9
+ * Validation Step Schema
10
+ *
11
+ * Defines a single validation step (typecheck, lint, test, etc.)
12
+ */
13
+ export const ValidationStepSchema = z.object({
14
+ /** Human-readable step name (e.g., "TypeScript type checking") */
15
+ name: z.string().min(1, 'Step name cannot be empty'),
16
+ /** Command to execute (e.g., "npm run typecheck") */
17
+ command: z.string().min(1, 'Command cannot be empty'),
18
+ /** Optional: Custom timeout in milliseconds (default: inherited from phase) */
19
+ timeout: z.number().positive().optional(),
20
+ /** Optional: Continue on failure (default: false) */
21
+ continueOnError: z.boolean().optional(),
22
+ /** Optional: Environment variables for this step */
23
+ env: z.record(z.string(), z.string()).optional(),
24
+ /** Optional: Working directory for this step (default: project root) */
25
+ cwd: z.string().optional(),
26
+ });
27
+ /**
28
+ * Validation Phase Schema
29
+ *
30
+ * Defines a phase containing one or more validation steps.
31
+ * Phases are executed sequentially, but steps within a phase can be parallel.
32
+ */
33
+ export const ValidationPhaseSchema = z.object({
34
+ /** Phase name (e.g., "Pre-Qualification", "Testing") */
35
+ name: z.string().min(1, 'Phase name cannot be empty'),
36
+ /** Execute steps in parallel (default: false) */
37
+ parallel: z.boolean().optional().default(false),
38
+ /** Optional: Phase names this phase depends on */
39
+ dependsOn: z.array(z.string()).optional(),
40
+ /** Steps to execute in this phase */
41
+ steps: z.array(ValidationStepSchema).min(1, 'Phase must have at least one step'),
42
+ /** Optional: Default timeout for all steps (milliseconds, default: 300000 = 5min) */
43
+ timeout: z.number().positive().optional().default(300000),
44
+ /** Optional: Fail fast - stop on first error (default: true) */
45
+ failFast: z.boolean().optional().default(true),
46
+ });
47
+ /**
48
+ * Caching Strategy Schema
49
+ */
50
+ export const CachingStrategySchema = z.enum([
51
+ 'git-tree-hash', // Content-based hashing (default)
52
+ 'timestamp', // File modification time
53
+ 'disabled', // No caching
54
+ ]);
55
+ /**
56
+ * Validation Config Schema
57
+ */
58
+ export const ValidationConfigSchema = z.object({
59
+ /** Validation phases to execute */
60
+ phases: z.array(ValidationPhaseSchema).min(1, 'At least one phase required'),
61
+ /** Caching configuration */
62
+ caching: z.object({
63
+ /** Caching strategy (default: git-tree-hash) */
64
+ strategy: CachingStrategySchema.default('git-tree-hash'),
65
+ /** Enable caching (default: true) */
66
+ enabled: z.boolean().default(true),
67
+ /** State file path (default: .vibe-validate-state.yaml) */
68
+ statePath: z.string().default('.vibe-validate-state.yaml'),
69
+ }).default({}),
70
+ });
71
+ /**
72
+ * Output Format Schema
73
+ */
74
+ export const OutputFormatSchema = z.enum([
75
+ 'human', // Colorful, verbose output for humans
76
+ 'yaml', // Structured YAML for agents
77
+ 'json', // Machine-readable JSON
78
+ 'auto', // Auto-detect context (default)
79
+ ]);
80
+ /**
81
+ * Git Config Schema
82
+ */
83
+ export const GitConfigSchema = z.object({
84
+ /** Main branch name (default: main) */
85
+ mainBranch: z.string().default('main'),
86
+ /** Auto-sync with remote (default: false) */
87
+ autoSync: z.boolean().default(false),
88
+ /** Warn if branch is behind remote (default: true) */
89
+ warnIfBehind: z.boolean().default(true),
90
+ });
91
+ /**
92
+ * Output Config Schema
93
+ */
94
+ export const OutputConfigSchema = z.object({
95
+ /** Output format (default: auto) */
96
+ format: OutputFormatSchema.default('auto'),
97
+ /** Show progress indicators (default: true) */
98
+ showProgress: z.boolean().default(true),
99
+ /** Verbose logging (default: false) */
100
+ verbose: z.boolean().default(false),
101
+ /** Suppress ANSI colors (default: false) */
102
+ noColor: z.boolean().default(false),
103
+ });
104
+ /**
105
+ * Full Configuration Schema
106
+ *
107
+ * Root configuration object for vibe-validate.
108
+ */
109
+ export const VibeValidateConfigSchema = z.object({
110
+ /** Validation configuration */
111
+ validation: ValidationConfigSchema,
112
+ /** Git integration configuration */
113
+ git: GitConfigSchema.default({}),
114
+ /** Output formatting configuration */
115
+ output: OutputConfigSchema.default({}),
116
+ /** Optional: Preset name (typescript-library, typescript-nodejs, etc.) */
117
+ preset: z.string().optional(),
118
+ /** Optional: Extend another config file */
119
+ extends: z.string().optional(),
120
+ });
121
+ /**
122
+ * Validate configuration object
123
+ *
124
+ * @param config - Configuration object to validate
125
+ * @returns Validated configuration with defaults applied
126
+ * @throws ZodError if validation fails
127
+ */
128
+ export function validateConfig(config) {
129
+ return VibeValidateConfigSchema.parse(config);
130
+ }
131
+ /**
132
+ * Safely validate configuration with detailed error messages
133
+ *
134
+ * @param config - Configuration object to validate
135
+ * @returns Result object with success flag and data or errors
136
+ */
137
+ export function safeValidateConfig(config) {
138
+ const result = VibeValidateConfigSchema.safeParse(config);
139
+ if (result.success) {
140
+ return { success: true, data: result.data };
141
+ }
142
+ // Format Zod errors into readable messages
143
+ const errors = result.error.errors.map(err => {
144
+ const path = err.path.join('.');
145
+ return `${path}: ${err.message}`;
146
+ });
147
+ return { success: false, errors };
148
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@vibe-validate/config",
3
+ "version": "0.9.0",
4
+ "description": "Configuration system for vibe-validate with TypeScript-first design and framework presets",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "clean": "rm -rf dist"
20
+ },
21
+ "keywords": [
22
+ "validation",
23
+ "config",
24
+ "typescript",
25
+ "presets",
26
+ "framework"
27
+ ],
28
+ "author": "Jeff Dutton",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/jdutton/vibe-validate.git",
33
+ "directory": "packages/config"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "^5.7.2"
37
+ },
38
+ "dependencies": {
39
+ "tsx": "^4.20.6",
40
+ "zod": "^3.24.1"
41
+ },
42
+ "engines": {
43
+ "node": ">=20.0.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }