@paths.design/caws-cli 2.0.1 ā 3.1.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/index.d.ts.map +1 -1
- package/dist/index.js +1463 -121
- package/package.json +3 -2
- package/templates/agents.md +820 -0
- package/templates/apps/tools/caws/COMPLETION_REPORT.md +331 -0
- package/templates/apps/tools/caws/MIGRATION_SUMMARY.md +360 -0
- package/templates/apps/tools/caws/README.md +463 -0
- package/templates/apps/tools/caws/TEST_STATUS.md +365 -0
- package/templates/apps/tools/caws/attest.js +357 -0
- package/templates/apps/tools/caws/ci-optimizer.js +642 -0
- package/templates/apps/tools/caws/config.ts +245 -0
- package/templates/apps/tools/caws/cross-functional.js +876 -0
- package/templates/apps/tools/caws/dashboard.js +1112 -0
- package/templates/apps/tools/caws/flake-detector.ts +362 -0
- package/templates/apps/tools/caws/gates.js +198 -0
- package/templates/apps/tools/caws/gates.ts +237 -0
- package/templates/apps/tools/caws/language-adapters.ts +381 -0
- package/templates/apps/tools/caws/language-support.d.ts +367 -0
- package/templates/apps/tools/caws/language-support.d.ts.map +1 -0
- package/templates/apps/tools/caws/language-support.js +585 -0
- package/templates/apps/tools/caws/legacy-assessment.ts +408 -0
- package/templates/apps/tools/caws/legacy-assessor.js +764 -0
- package/templates/apps/tools/caws/mutant-analyzer.js +734 -0
- package/templates/apps/tools/caws/perf-budgets.ts +349 -0
- package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
- package/templates/apps/tools/caws/property-testing.js +707 -0
- package/templates/apps/tools/caws/provenance.d.ts +14 -0
- package/templates/apps/tools/caws/provenance.d.ts.map +1 -0
- package/templates/apps/tools/caws/provenance.js +132 -0
- package/templates/apps/tools/caws/provenance.js.backup +73 -0
- package/templates/apps/tools/caws/provenance.ts +211 -0
- package/templates/apps/tools/caws/schemas/waivers.schema.json +30 -0
- package/templates/apps/tools/caws/schemas/working-spec.schema.json +115 -0
- package/templates/apps/tools/caws/scope-guard.js +208 -0
- package/templates/apps/tools/caws/security-provenance.ts +483 -0
- package/templates/apps/tools/caws/shared/base-tool.ts +281 -0
- package/templates/apps/tools/caws/shared/config-manager.ts +366 -0
- package/templates/apps/tools/caws/shared/gate-checker.ts +597 -0
- package/templates/apps/tools/caws/shared/types.ts +444 -0
- package/templates/apps/tools/caws/shared/validator.ts +305 -0
- package/templates/apps/tools/caws/shared/waivers-manager.ts +174 -0
- package/templates/apps/tools/caws/spec-test-mapper.ts +391 -0
- package/templates/apps/tools/caws/templates/working-spec.template.yml +60 -0
- package/templates/apps/tools/caws/test-quality.js +578 -0
- package/templates/apps/tools/caws/tools-allow.json +331 -0
- package/templates/apps/tools/caws/validate.js +76 -0
- package/templates/apps/tools/caws/validate.ts +228 -0
- package/templates/apps/tools/caws/waivers.js +344 -0
- package/templates/apps/tools/caws/waivers.yml +19 -0
- package/templates/codemod/README.md +1 -0
- package/templates/codemod/test.js +1 -0
- package/templates/docs/README.md +150 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
[
|
|
2
|
+
"node",
|
|
3
|
+
"npm",
|
|
4
|
+
"yarn",
|
|
5
|
+
"pnpm",
|
|
6
|
+
"git",
|
|
7
|
+
"docker",
|
|
8
|
+
"kubectl",
|
|
9
|
+
"aws",
|
|
10
|
+
"azure",
|
|
11
|
+
"gcloud",
|
|
12
|
+
"terraform",
|
|
13
|
+
"ansible",
|
|
14
|
+
"curl",
|
|
15
|
+
"wget",
|
|
16
|
+
"grep",
|
|
17
|
+
"sed",
|
|
18
|
+
"awk",
|
|
19
|
+
"bash",
|
|
20
|
+
"sh",
|
|
21
|
+
"zsh",
|
|
22
|
+
"fish",
|
|
23
|
+
"python",
|
|
24
|
+
"python3",
|
|
25
|
+
"pip",
|
|
26
|
+
"pip3",
|
|
27
|
+
"virtualenv",
|
|
28
|
+
"conda",
|
|
29
|
+
"java",
|
|
30
|
+
"javac",
|
|
31
|
+
"gradle",
|
|
32
|
+
"maven",
|
|
33
|
+
"go",
|
|
34
|
+
"gofmt",
|
|
35
|
+
"rust",
|
|
36
|
+
"cargo",
|
|
37
|
+
"rustfmt",
|
|
38
|
+
"clippy",
|
|
39
|
+
"ruby",
|
|
40
|
+
"gem",
|
|
41
|
+
"bundle",
|
|
42
|
+
"rbenv",
|
|
43
|
+
"php",
|
|
44
|
+
"composer",
|
|
45
|
+
"dotnet",
|
|
46
|
+
"nuget",
|
|
47
|
+
"swift",
|
|
48
|
+
"xcodebuild",
|
|
49
|
+
"make",
|
|
50
|
+
"cmake",
|
|
51
|
+
"ninja",
|
|
52
|
+
"gcc",
|
|
53
|
+
"clang",
|
|
54
|
+
"ld",
|
|
55
|
+
"ar",
|
|
56
|
+
"strip",
|
|
57
|
+
"objdump",
|
|
58
|
+
"nm",
|
|
59
|
+
"readelf",
|
|
60
|
+
"file",
|
|
61
|
+
"hexdump",
|
|
62
|
+
"xxd",
|
|
63
|
+
"base64",
|
|
64
|
+
"openssl",
|
|
65
|
+
"ssh",
|
|
66
|
+
"scp",
|
|
67
|
+
"rsync",
|
|
68
|
+
"tar",
|
|
69
|
+
"gzip",
|
|
70
|
+
"bzip2",
|
|
71
|
+
"xz",
|
|
72
|
+
"zip",
|
|
73
|
+
"unzip",
|
|
74
|
+
"7z",
|
|
75
|
+
"jq",
|
|
76
|
+
"yq",
|
|
77
|
+
"xmlstarlet",
|
|
78
|
+
"html-xml-utils",
|
|
79
|
+
"pandoc",
|
|
80
|
+
"asciidoc",
|
|
81
|
+
"rst2html",
|
|
82
|
+
"markdown",
|
|
83
|
+
"remark",
|
|
84
|
+
"prettier",
|
|
85
|
+
"eslint",
|
|
86
|
+
"tslint",
|
|
87
|
+
"stylelint",
|
|
88
|
+
"htmlhint",
|
|
89
|
+
"csslint",
|
|
90
|
+
"jsonlint",
|
|
91
|
+
"yamllint",
|
|
92
|
+
"shellcheck",
|
|
93
|
+
"hadolint",
|
|
94
|
+
"dockerfile_lint",
|
|
95
|
+
"markdownlint",
|
|
96
|
+
"proselint",
|
|
97
|
+
"vale",
|
|
98
|
+
"alex",
|
|
99
|
+
"write-good",
|
|
100
|
+
"textlint",
|
|
101
|
+
"redpen",
|
|
102
|
+
"languagetool",
|
|
103
|
+
"grammarly",
|
|
104
|
+
"codespell",
|
|
105
|
+
"typos",
|
|
106
|
+
"aspell",
|
|
107
|
+
"hunspell",
|
|
108
|
+
"sort",
|
|
109
|
+
"uniq",
|
|
110
|
+
"cut",
|
|
111
|
+
"paste",
|
|
112
|
+
"join",
|
|
113
|
+
"split",
|
|
114
|
+
"tr",
|
|
115
|
+
"column",
|
|
116
|
+
"fold",
|
|
117
|
+
"fmt",
|
|
118
|
+
"pr",
|
|
119
|
+
"head",
|
|
120
|
+
"tail",
|
|
121
|
+
"wc",
|
|
122
|
+
"nl",
|
|
123
|
+
"od",
|
|
124
|
+
"strings",
|
|
125
|
+
"iconv",
|
|
126
|
+
"dos2unix",
|
|
127
|
+
"unix2dos",
|
|
128
|
+
"mac2unix",
|
|
129
|
+
"unix2mac",
|
|
130
|
+
"pbcopy",
|
|
131
|
+
"pbpaste",
|
|
132
|
+
"xclip",
|
|
133
|
+
"xsel",
|
|
134
|
+
"tmux",
|
|
135
|
+
"screen",
|
|
136
|
+
"vim",
|
|
137
|
+
"nvim",
|
|
138
|
+
"emacs",
|
|
139
|
+
"nano",
|
|
140
|
+
"micro",
|
|
141
|
+
"code",
|
|
142
|
+
"atom",
|
|
143
|
+
"sublime",
|
|
144
|
+
"vimr",
|
|
145
|
+
"macvim",
|
|
146
|
+
"gvim",
|
|
147
|
+
"vscode",
|
|
148
|
+
"intellij",
|
|
149
|
+
"pycharm",
|
|
150
|
+
"webstorm",
|
|
151
|
+
"phpstorm",
|
|
152
|
+
"rubymine",
|
|
153
|
+
"clion",
|
|
154
|
+
"goland",
|
|
155
|
+
"rider",
|
|
156
|
+
"datagrip",
|
|
157
|
+
"android-studio",
|
|
158
|
+
"xcode",
|
|
159
|
+
"eclipse",
|
|
160
|
+
"netbeans",
|
|
161
|
+
"idea",
|
|
162
|
+
"studio",
|
|
163
|
+
"vs",
|
|
164
|
+
"visualstudio",
|
|
165
|
+
"monodevelop",
|
|
166
|
+
"xamarin",
|
|
167
|
+
"rider",
|
|
168
|
+
"resharper",
|
|
169
|
+
"testcafe",
|
|
170
|
+
"cypress",
|
|
171
|
+
"playwright",
|
|
172
|
+
"puppeteer",
|
|
173
|
+
"selenium",
|
|
174
|
+
"webdriver",
|
|
175
|
+
"jest",
|
|
176
|
+
"mocha",
|
|
177
|
+
"jasmine",
|
|
178
|
+
"karma",
|
|
179
|
+
"vitest",
|
|
180
|
+
"testing-library",
|
|
181
|
+
"enzyme",
|
|
182
|
+
"react-testing-library",
|
|
183
|
+
"vue-test-utils",
|
|
184
|
+
"angular-testing-library",
|
|
185
|
+
"svelte-testing-library",
|
|
186
|
+
"lit-testing-library",
|
|
187
|
+
"ember-testing",
|
|
188
|
+
"backbone-testing",
|
|
189
|
+
"jquery-testing",
|
|
190
|
+
"dojo-testing",
|
|
191
|
+
"dojo",
|
|
192
|
+
"mootools",
|
|
193
|
+
"prototype",
|
|
194
|
+
"yui",
|
|
195
|
+
"extjs",
|
|
196
|
+
"sencha",
|
|
197
|
+
"backbone",
|
|
198
|
+
"marionette",
|
|
199
|
+
"chaplin",
|
|
200
|
+
"thorax",
|
|
201
|
+
"handlebars",
|
|
202
|
+
"mustache",
|
|
203
|
+
"underscore",
|
|
204
|
+
"lodash",
|
|
205
|
+
"ramda",
|
|
206
|
+
"functional",
|
|
207
|
+
"lazy",
|
|
208
|
+
"bluebird",
|
|
209
|
+
"q",
|
|
210
|
+
"deferred",
|
|
211
|
+
"async",
|
|
212
|
+
"await",
|
|
213
|
+
"generator",
|
|
214
|
+
"co",
|
|
215
|
+
"redux",
|
|
216
|
+
"mobx",
|
|
217
|
+
"flux",
|
|
218
|
+
"reflux",
|
|
219
|
+
"alt",
|
|
220
|
+
"flummox",
|
|
221
|
+
"delorean",
|
|
222
|
+
"cerebral",
|
|
223
|
+
"kea",
|
|
224
|
+
"zustand",
|
|
225
|
+
"jotai",
|
|
226
|
+
"recoil",
|
|
227
|
+
"valtio",
|
|
228
|
+
"effector",
|
|
229
|
+
"xstate",
|
|
230
|
+
"robot",
|
|
231
|
+
"easy-peasy",
|
|
232
|
+
"pullstate",
|
|
233
|
+
"akita",
|
|
234
|
+
"ngrx",
|
|
235
|
+
"ngxs",
|
|
236
|
+
"akita",
|
|
237
|
+
"elf",
|
|
238
|
+
"pinia",
|
|
239
|
+
"overmind",
|
|
240
|
+
"stately",
|
|
241
|
+
"context",
|
|
242
|
+
"useContext",
|
|
243
|
+
"useReducer",
|
|
244
|
+
"useState",
|
|
245
|
+
"useEffect",
|
|
246
|
+
"useMemo",
|
|
247
|
+
"useCallback",
|
|
248
|
+
"useRef",
|
|
249
|
+
"useImperativeHandle",
|
|
250
|
+
"useLayoutEffect",
|
|
251
|
+
"useDebugValue",
|
|
252
|
+
"useDeferredValue",
|
|
253
|
+
"useTransition",
|
|
254
|
+
"useId",
|
|
255
|
+
"useSyncExternalStore",
|
|
256
|
+
"createContext",
|
|
257
|
+
"createElement",
|
|
258
|
+
"cloneElement",
|
|
259
|
+
"isValidElement",
|
|
260
|
+
"ReactDOM",
|
|
261
|
+
"render",
|
|
262
|
+
"hydrate",
|
|
263
|
+
"createRoot",
|
|
264
|
+
"unmountComponentAtNode",
|
|
265
|
+
"findDOMNode",
|
|
266
|
+
"createPortal",
|
|
267
|
+
"unstable_batchedUpdates",
|
|
268
|
+
"flushSync",
|
|
269
|
+
"React",
|
|
270
|
+
"Component",
|
|
271
|
+
"PureComponent",
|
|
272
|
+
"memo",
|
|
273
|
+
"lazy",
|
|
274
|
+
"Suspense",
|
|
275
|
+
"ErrorBoundary",
|
|
276
|
+
"Profiler",
|
|
277
|
+
"StrictMode",
|
|
278
|
+
"Fragment",
|
|
279
|
+
"createRef",
|
|
280
|
+
"forwardRef",
|
|
281
|
+
"createContext",
|
|
282
|
+
"createElement",
|
|
283
|
+
"cloneElement",
|
|
284
|
+
"isValidElement",
|
|
285
|
+
"Children",
|
|
286
|
+
"map",
|
|
287
|
+
"forEach",
|
|
288
|
+
"count",
|
|
289
|
+
"only",
|
|
290
|
+
"toArray",
|
|
291
|
+
"ReactDOM",
|
|
292
|
+
"render",
|
|
293
|
+
"hydrate",
|
|
294
|
+
"createRoot",
|
|
295
|
+
"unmountComponentAtNode",
|
|
296
|
+
"findDOMNode",
|
|
297
|
+
"createPortal",
|
|
298
|
+
"unstable_batchedUpdates",
|
|
299
|
+
"flushSync",
|
|
300
|
+
"React",
|
|
301
|
+
"Component",
|
|
302
|
+
"PureComponent",
|
|
303
|
+
"memo",
|
|
304
|
+
"lazy",
|
|
305
|
+
"Suspense",
|
|
306
|
+
"ErrorBoundary",
|
|
307
|
+
"Profiler",
|
|
308
|
+
"StrictMode",
|
|
309
|
+
"Fragment",
|
|
310
|
+
"createRef",
|
|
311
|
+
"forwardRef",
|
|
312
|
+
"createContext",
|
|
313
|
+
"createElement",
|
|
314
|
+
"cloneElement",
|
|
315
|
+
"isValidElement",
|
|
316
|
+
"Children",
|
|
317
|
+
"map",
|
|
318
|
+
"forEach",
|
|
319
|
+
"count",
|
|
320
|
+
"only",
|
|
321
|
+
"toArray",
|
|
322
|
+
"ReactDOM",
|
|
323
|
+
"render",
|
|
324
|
+
"hydrate",
|
|
325
|
+
"createRoot",
|
|
326
|
+
"unmountComponentAtNode",
|
|
327
|
+
"findDOMNode",
|
|
328
|
+
"createPortal",
|
|
329
|
+
"unstable_batchedUpdates",
|
|
330
|
+
"flushSync"
|
|
331
|
+
]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CAWS Validation Tool
|
|
3
|
+
* @author @darianrosebrook
|
|
4
|
+
*
|
|
5
|
+
* Note: For enhanced TypeScript version with schema validation, use validate.ts
|
|
6
|
+
* This .js version provides basic validation for backward compatibility
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Validates a working specification file
|
|
11
|
+
* @param {string} specPath - Path to the working specification file
|
|
12
|
+
* @returns {Object} Validation result with valid boolean and errors array
|
|
13
|
+
*/
|
|
14
|
+
function validateWorkingSpec(specPath) {
|
|
15
|
+
try {
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const yaml = require('js-yaml');
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(specPath)) {
|
|
20
|
+
return {
|
|
21
|
+
valid: false,
|
|
22
|
+
errors: [{ message: `Specification file not found: ${specPath}` }],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const specContent = fs.readFileSync(specPath, 'utf8');
|
|
27
|
+
const spec = yaml.load(specContent);
|
|
28
|
+
|
|
29
|
+
// Basic validation
|
|
30
|
+
const errors = [];
|
|
31
|
+
|
|
32
|
+
if (!spec.id) errors.push({ message: 'Missing required field: id' });
|
|
33
|
+
if (!spec.title) errors.push({ message: 'Missing required field: title' });
|
|
34
|
+
if (!spec.risk_tier) errors.push({ message: 'Missing required field: risk_tier' });
|
|
35
|
+
|
|
36
|
+
if (spec.risk_tier && (spec.risk_tier < 1 || spec.risk_tier > 3)) {
|
|
37
|
+
errors.push({ message: 'Risk tier must be 1, 2, or 3' });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!spec.scope || !spec.scope.in || spec.scope.in.length === 0) {
|
|
41
|
+
errors.push({ message: 'Scope IN must not be empty' });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
valid: errors.length === 0,
|
|
46
|
+
errors: errors,
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
valid: false,
|
|
51
|
+
errors: [{ message: `Validation error: ${error.message}` }],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Handle direct script execution
|
|
57
|
+
if (require.main === module) {
|
|
58
|
+
const specPath = process.argv[2];
|
|
59
|
+
if (!specPath) {
|
|
60
|
+
console.error('Usage: node validate.js <spec-path>');
|
|
61
|
+
console.log('');
|
|
62
|
+
console.log('Note: For enhanced schema validation, use: npx tsx validate.ts spec <spec-path>');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const result = validateWorkingSpec(specPath);
|
|
67
|
+
if (result.valid) {
|
|
68
|
+
console.log('ā
Working specification is valid');
|
|
69
|
+
} else {
|
|
70
|
+
console.error('ā Working specification is invalid:');
|
|
71
|
+
result.errors.forEach((error) => console.error(` - ${error.message}`));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = validateWorkingSpec;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CAWS Validation Tool
|
|
5
|
+
* CLI wrapper for CawsValidator with schema validation
|
|
6
|
+
*
|
|
7
|
+
* @author @darianrosebrook
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import { CawsValidator } from './shared/validator.js';
|
|
12
|
+
import { ValidationResult } from './shared/types.js';
|
|
13
|
+
|
|
14
|
+
class ValidateCLI {
|
|
15
|
+
private validator: CawsValidator;
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
this.validator = new CawsValidator();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validate a working specification file
|
|
23
|
+
*/
|
|
24
|
+
validateWorkingSpec(specPath: string): ValidationResult {
|
|
25
|
+
try {
|
|
26
|
+
const result = this.validator.validateWorkingSpec(specPath);
|
|
27
|
+
|
|
28
|
+
if (result.passed) {
|
|
29
|
+
console.log('ā
Working specification is valid');
|
|
30
|
+
console.log(` Score: ${(result.score * 100).toFixed(0)}%`);
|
|
31
|
+
|
|
32
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
33
|
+
console.log('\nā ļø Warnings:');
|
|
34
|
+
result.warnings.forEach((warning) => console.log(` - ${warning}`));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (result.details) {
|
|
38
|
+
console.log('\nš Details:');
|
|
39
|
+
if (result.details.risk_tier) {
|
|
40
|
+
console.log(` Tier: ${result.details.risk_tier}`);
|
|
41
|
+
}
|
|
42
|
+
if (result.details.acceptance_count) {
|
|
43
|
+
console.log(` Acceptance Criteria: ${result.details.acceptance_count}`);
|
|
44
|
+
}
|
|
45
|
+
if (result.details.contract_count) {
|
|
46
|
+
console.log(` Contracts: ${result.details.contract_count}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
console.error('ā Working specification is invalid:');
|
|
51
|
+
if (result.errors && result.errors.length > 0) {
|
|
52
|
+
result.errors.forEach((error) => console.error(` - ${error}`));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(`ā Validation failed: ${error}`);
|
|
59
|
+
return {
|
|
60
|
+
passed: false,
|
|
61
|
+
errors: [`Validation error: ${error}`],
|
|
62
|
+
score: 0,
|
|
63
|
+
details: {},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Validate a provenance file
|
|
70
|
+
*/
|
|
71
|
+
validateProvenance(provenancePath: string): ValidationResult {
|
|
72
|
+
try {
|
|
73
|
+
const result = this.validator.validateProvenance(provenancePath);
|
|
74
|
+
|
|
75
|
+
if (result.passed) {
|
|
76
|
+
console.log('ā
Provenance file is valid');
|
|
77
|
+
console.log(` Score: ${(result.score * 100).toFixed(0)}%`);
|
|
78
|
+
|
|
79
|
+
if (result.details) {
|
|
80
|
+
console.log('\nš Provenance Details:');
|
|
81
|
+
if (result.details.agent) {
|
|
82
|
+
console.log(` Agent: ${result.details.agent}`);
|
|
83
|
+
}
|
|
84
|
+
if (result.details.model) {
|
|
85
|
+
console.log(` Model: ${result.details.model}`);
|
|
86
|
+
}
|
|
87
|
+
if (result.details.commit) {
|
|
88
|
+
console.log(` Commit: ${result.details.commit}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
console.error('ā Provenance file is invalid:');
|
|
93
|
+
if (result.errors && result.errors.length > 0) {
|
|
94
|
+
result.errors.forEach((error) => console.error(` - ${error}`));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return result;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error(`ā Provenance validation failed: ${error}`);
|
|
101
|
+
return {
|
|
102
|
+
passed: false,
|
|
103
|
+
errors: [`Validation error: ${error}`],
|
|
104
|
+
score: 0,
|
|
105
|
+
details: {},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Validate a JSON file against a schema
|
|
112
|
+
*/
|
|
113
|
+
validateJsonSchema(jsonPath: string, schemaPath: string): ValidationResult {
|
|
114
|
+
try {
|
|
115
|
+
const result = this.validator.validateJsonAgainstSchema(jsonPath, schemaPath);
|
|
116
|
+
|
|
117
|
+
if (result.passed) {
|
|
118
|
+
console.log('ā
JSON file is valid against schema');
|
|
119
|
+
} else {
|
|
120
|
+
console.error('ā JSON file is invalid:');
|
|
121
|
+
if (result.errors && result.errors.length > 0) {
|
|
122
|
+
result.errors.forEach((error) => console.error(` - ${error}`));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return result;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(`ā Schema validation failed: ${error}`);
|
|
129
|
+
return {
|
|
130
|
+
passed: false,
|
|
131
|
+
errors: [`Validation error: ${error}`],
|
|
132
|
+
score: 0,
|
|
133
|
+
details: {},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Validate a YAML file against a schema
|
|
140
|
+
*/
|
|
141
|
+
validateYamlSchema(yamlPath: string, schemaPath: string): ValidationResult {
|
|
142
|
+
try {
|
|
143
|
+
const result = this.validator.validateYamlAgainstSchema(yamlPath, schemaPath);
|
|
144
|
+
|
|
145
|
+
if (result.passed) {
|
|
146
|
+
console.log('ā
YAML file is valid against schema');
|
|
147
|
+
} else {
|
|
148
|
+
console.error('ā YAML file is invalid:');
|
|
149
|
+
if (result.errors && result.errors.length > 0) {
|
|
150
|
+
result.errors.forEach((error) => console.error(` - ${error}`));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return result;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(`ā Schema validation failed: ${error}`);
|
|
157
|
+
return {
|
|
158
|
+
passed: false,
|
|
159
|
+
errors: [`Validation error: ${error}`],
|
|
160
|
+
score: 0,
|
|
161
|
+
details: {},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Main CLI handler
|
|
168
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
169
|
+
const command = process.argv[2];
|
|
170
|
+
const cli = new ValidateCLI();
|
|
171
|
+
|
|
172
|
+
switch (command) {
|
|
173
|
+
case 'spec': {
|
|
174
|
+
const specPath = process.argv[3] || '.caws/working-spec.yaml';
|
|
175
|
+
const result = cli.validateWorkingSpec(specPath);
|
|
176
|
+
process.exit(result.passed ? 0 : 1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
case 'provenance': {
|
|
180
|
+
const provenancePath = process.argv[3] || '.agent/provenance.json';
|
|
181
|
+
const result = cli.validateProvenance(provenancePath);
|
|
182
|
+
process.exit(result.passed ? 0 : 1);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
case 'json': {
|
|
186
|
+
const jsonPath = process.argv[3];
|
|
187
|
+
const schemaPath = process.argv[4];
|
|
188
|
+
|
|
189
|
+
if (!jsonPath || !schemaPath) {
|
|
190
|
+
console.error('Usage: validate.ts json <json-file> <schema-file>');
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const result = cli.validateJsonSchema(jsonPath, schemaPath);
|
|
195
|
+
process.exit(result.passed ? 0 : 1);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
case 'yaml': {
|
|
199
|
+
const yamlPath = process.argv[3];
|
|
200
|
+
const schemaPath = process.argv[4];
|
|
201
|
+
|
|
202
|
+
if (!yamlPath || !schemaPath) {
|
|
203
|
+
console.error('Usage: validate.ts yaml <yaml-file> <schema-file>');
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const result = cli.validateYamlSchema(yamlPath, schemaPath);
|
|
208
|
+
process.exit(result.passed ? 0 : 1);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
default:
|
|
212
|
+
console.log('CAWS Validation Tool');
|
|
213
|
+
console.log('');
|
|
214
|
+
console.log('Commands:');
|
|
215
|
+
console.log(' spec [path] - Validate working specification');
|
|
216
|
+
console.log(' provenance [path] - Validate provenance file');
|
|
217
|
+
console.log(' json <file> <schema> - Validate JSON against schema');
|
|
218
|
+
console.log(' yaml <file> <schema> - Validate YAML against schema');
|
|
219
|
+
console.log('');
|
|
220
|
+
console.log('Examples:');
|
|
221
|
+
console.log(' validate.ts spec .caws/working-spec.yaml');
|
|
222
|
+
console.log(' validate.ts provenance .agent/provenance.json');
|
|
223
|
+
console.log(' validate.ts yaml .caws/waivers.yml schemas/waivers.schema.json');
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export { ValidateCLI };
|