brepjs-verify 0.2.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +191 -0
  3. package/README.md +85 -0
  4. package/dist/brepjs-verify.cjs +14 -0
  5. package/dist/brepjs-verify.js +2 -0
  6. package/dist/chunk-D6vf50IK.cjs +28 -0
  7. package/dist/cli/exportPart.d.ts +13 -0
  8. package/dist/cli/main.cjs +325 -0
  9. package/dist/cli/main.d.ts +3 -0
  10. package/dist/cli/main.js +323 -0
  11. package/dist/cli/scaffold.d.ts +9 -0
  12. package/dist/cli/watch.d.ts +5 -0
  13. package/dist/diff-CZ4mLtrf.cjs +869 -0
  14. package/dist/diff-D7ZBNRJG.js +778 -0
  15. package/dist/disposeShape.d.ts +1 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/loader/brepjsResolve.mjs +57 -0
  18. package/dist/snapshot/registry.cjs +50 -0
  19. package/dist/snapshot/registry.d.ts +12 -0
  20. package/dist/snapshot/registry.js +48 -0
  21. package/dist/snapshot/serve.cjs +27 -0
  22. package/dist/snapshot/serve.d.ts +12 -0
  23. package/dist/snapshot/serve.js +26 -0
  24. package/dist/snapshot/shoot.cjs +64 -0
  25. package/dist/snapshot/shoot.d.ts +14 -0
  26. package/dist/snapshot/shoot.js +61 -0
  27. package/dist/snapshot/static.cjs +100 -0
  28. package/dist/snapshot/static.d.ts +16 -0
  29. package/dist/snapshot/static.js +98 -0
  30. package/dist/verify/brepjsRuntime.d.ts +4 -0
  31. package/dist/verify/checks.d.ts +4 -0
  32. package/dist/verify/diff.d.ts +2 -0
  33. package/dist/verify/expected.d.ts +26 -0
  34. package/dist/verify/measure.d.ts +6 -0
  35. package/dist/verify/report.d.ts +75 -0
  36. package/dist/verify/runPart.d.ts +23 -0
  37. package/dist/verify/typecheck.d.ts +17 -0
  38. package/package.json +78 -0
  39. package/viewer/dist/assets/brepjs-CDZqKweN.js +57 -0
  40. package/viewer/dist/assets/index-B8QUQDqM.js +4167 -0
  41. package/viewer/dist/assets/kernelWorker-C6s5i9JH.js +1 -0
  42. package/viewer/dist/index.html +22 -0
  43. package/viewer/dist/wasm/occt-wasm.js +2 -0
  44. package/viewer/dist/wasm/occt-wasm.wasm +0 -0
@@ -0,0 +1,75 @@
1
+ export interface VerifyCheck {
2
+ name: string;
3
+ passed: boolean;
4
+ detail?: string;
5
+ }
6
+ export interface VerifyMeasurements {
7
+ volume?: number;
8
+ area?: number;
9
+ bounds?: {
10
+ xMin: number;
11
+ xMax: number;
12
+ yMin: number;
13
+ yMax: number;
14
+ zMin: number;
15
+ zMax: number;
16
+ };
17
+ }
18
+ /** A failure captured with whatever structured context it carried (a `BrepError` code/suggestion). */
19
+ export interface ErrorInfo {
20
+ message: string;
21
+ code?: string | undefined;
22
+ suggestion?: string | undefined;
23
+ }
24
+ export interface VerifyHint {
25
+ code: string;
26
+ message: string;
27
+ fix: string;
28
+ nextStep: string;
29
+ }
30
+ /** One measured-vs-expected comparison from a part's `export const expected`. */
31
+ export interface VerifyAssertion {
32
+ name: string;
33
+ expected: number;
34
+ /** The measured value, or null when the part produced no such measurement. */
35
+ actual: number | null;
36
+ passed: boolean;
37
+ }
38
+ export interface VerifyReport {
39
+ shapeType: string | null;
40
+ checks: VerifyCheck[];
41
+ measurements: VerifyMeasurements;
42
+ errors: string[];
43
+ /** Structured copies of `errors`, carrying any `BrepError` code/suggestion. Drives `hints`. */
44
+ errorInfos: ErrorInfo[];
45
+ /** Actionable, code-keyed guidance derived from `errorInfos`. */
46
+ hints: VerifyHint[];
47
+ /**
48
+ * Measured-vs-expected comparisons from a part's `export const expected`. Empty when the part
49
+ * declares no expectations; when non-empty, `ok` additionally requires every assertion pass.
50
+ */
51
+ assertions: VerifyAssertion[];
52
+ }
53
+ export interface BoundsDelta {
54
+ xMin: number;
55
+ xMax: number;
56
+ yMin: number;
57
+ yMax: number;
58
+ zMin: number;
59
+ zMax: number;
60
+ }
61
+ export interface DiffReport {
62
+ volumeDelta: number;
63
+ areaDelta: number;
64
+ bboxDelta: BoundsDelta;
65
+ symmetricDifferenceVolume: number;
66
+ errors: string[];
67
+ }
68
+ export declare function emptyReport(): VerifyReport;
69
+ export declare function pushError(r: VerifyReport, info: ErrorInfo): void;
70
+ export declare function reportOk(r: VerifyReport): boolean;
71
+ /** Synthetic code attached to validity-check failures (validSolid returns a plain string error). */
72
+ export declare const VALIDITY_FAILURE_CODE = "VALIDATION_FAILED";
73
+ export declare function hintFor(info: ErrorInfo): VerifyHint | null;
74
+ export declare function buildHints(r: VerifyReport): VerifyHint[];
75
+ export declare function serializeReport(r: VerifyReport): string;
@@ -0,0 +1,23 @@
1
+ import { AnyShape } from 'brepjs';
2
+ import { VerifyReport } from './report.js';
3
+ export interface RunPartOptions {
4
+ step?: boolean;
5
+ glb?: boolean;
6
+ /**
7
+ * Run a TypeScript type-check on the part (against the bundled/local `brepjs` types) BEFORE
8
+ * executing it. Type errors are surfaced as `TYPECHECK` error infos and the part is NOT run.
9
+ */
10
+ check?: boolean;
11
+ }
12
+ export interface RunPartResult {
13
+ /**
14
+ * The built shape, or null on failure. This is a LIVE WASM-backed kernel handle: the CLI exits
15
+ * right after use, but long-running programmatic callers own its lifetime and should release it
16
+ * (e.g. `using s = result.shape` or a `DisposalScope`) once done, or WASM memory accumulates.
17
+ */
18
+ shape: AnyShape | null;
19
+ report: VerifyReport;
20
+ step?: ArrayBuffer | undefined;
21
+ glb?: ArrayBuffer | undefined;
22
+ }
23
+ export declare function runPart(modulePath: string, opts?: RunPartOptions): Promise<RunPartResult>;
@@ -0,0 +1,17 @@
1
+ import { ErrorInfo } from './report.js';
2
+ /** Code stamped on every type-check diagnostic so the report/hints can key on it. */
3
+ export declare const TYPECHECK_CODE = "TYPECHECK";
4
+ export interface TypecheckResult {
5
+ /** True when the part has no type errors (or the check was skipped because types were unresolvable). */
6
+ ok: boolean;
7
+ errors: ErrorInfo[];
8
+ }
9
+ /**
10
+ * Type-check a single `.brep.ts` part against the bundled (or local) `brepjs` declarations.
11
+ *
12
+ * Uses a synthetic in-memory program: a `paths` mapping points the bare `brepjs` specifier at
13
+ * the resolved `.d.ts`, so the part can be checked without a real install or tsconfig. If the
14
+ * `brepjs` types cannot be resolved, the check is skipped (ok:true, no errors) rather than
15
+ * failing — `--check` should never be worse than not passing it.
16
+ */
17
+ export declare function typecheckPart(partPath: string, toolDir?: string): TypecheckResult;
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "brepjs-verify",
3
+ "version": "0.2.1",
4
+ "description": "Agent skill + verify/preview tooling for authoring parametric brepjs CAD code",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=24"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/andymai/brepjs",
14
+ "directory": "packages/brepjs-verify"
15
+ },
16
+ "main": "./dist/brepjs-verify.cjs",
17
+ "module": "./dist/brepjs-verify.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/brepjs-verify.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/brepjs-verify.cjs"
28
+ }
29
+ }
30
+ },
31
+ "bin": {
32
+ "brepjs-verify": "./dist/cli/main.js"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "viewer/dist",
37
+ "CHANGELOG.md",
38
+ "LICENSE",
39
+ "README.md"
40
+ ],
41
+ "scripts": {
42
+ "build": "vite build && vite build --config viewer/vite.config.ts",
43
+ "typecheck": "tsc --noEmit && tsc -p viewer/tsconfig.json --noEmit && tsc -p bench/tsconfig.json",
44
+ "lint": "eslint src tests viewer bench",
45
+ "test": "vitest run",
46
+ "eval": "tsx bench/run.ts",
47
+ "smoke": "node dist/cli/main.js verify tests/fixtures/validBox.brep.ts | node -e \"const r=JSON.parse(require('fs').readFileSync(0,'utf8'));if(r.ok!==true||!(r.measurements.volume>0))process.exit(1)\"",
48
+ "smoke:standalone": "node scripts/smokeStandalone.mjs",
49
+ "prepack": "npm run build"
50
+ },
51
+ "dependencies": {
52
+ "brepjs": "^18.0.0",
53
+ "commander": "^13.0.0",
54
+ "occt-wasm": "^3.0.0",
55
+ "typescript": "^6.0.3"
56
+ },
57
+ "optionalDependencies": {
58
+ "puppeteer": "^25.0.4"
59
+ },
60
+ "devDependencies": {
61
+ "@react-three/drei": "^10.7.7",
62
+ "@react-three/fiber": "^9.6.1",
63
+ "@types/node": "^25.9.1",
64
+ "@types/react": "^19.2.15",
65
+ "@types/react-dom": "^19.2.3",
66
+ "@types/three": "^0.184.1",
67
+ "@vitejs/plugin-react": "^6.0.2",
68
+ "brepjs-viewer": "^0.1.0",
69
+ "eslint": "^10.4.0",
70
+ "react": "^19.2.6",
71
+ "react-dom": "^19.2.6",
72
+ "three": "^0.184.0",
73
+ "tsx": "^4.22.3",
74
+ "vite": "^8.0.0",
75
+ "vite-plugin-dts": "^5.0.1",
76
+ "vitest": "^4.0.0"
77
+ }
78
+ }