pactwright 0.0.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.
- package/LICENSE +201 -0
- package/README.md +68 -0
- package/dist/adapter/claude-code.d.ts +53 -0
- package/dist/adapter/claude-code.js +241 -0
- package/dist/adapter/commands.d.ts +19 -0
- package/dist/adapter/commands.js +162 -0
- package/dist/atomic.d.ts +6 -0
- package/dist/atomic.js +11 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +561 -0
- package/dist/config/config.d.ts +55 -0
- package/dist/config/config.js +199 -0
- package/dist/config/lifecycle.d.ts +34 -0
- package/dist/config/lifecycle.js +81 -0
- package/dist/config/lock.d.ts +43 -0
- package/dist/config/lock.js +141 -0
- package/dist/context.d.ts +59 -0
- package/dist/context.js +111 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +25 -0
- package/dist/eval/case.d.ts +123 -0
- package/dist/eval/case.js +17 -0
- package/dist/eval/core-suite.d.ts +3 -0
- package/dist/eval/core-suite.js +431 -0
- package/dist/eval/runner.d.ts +75 -0
- package/dist/eval/runner.js +159 -0
- package/dist/eval/sandbox.d.ts +39 -0
- package/dist/eval/sandbox.js +143 -0
- package/dist/extension/manage.d.ts +65 -0
- package/dist/extension/manage.js +372 -0
- package/dist/extension/manifest.d.ts +36 -0
- package/dist/extension/manifest.js +164 -0
- package/dist/extension/resolve.d.ts +77 -0
- package/dist/extension/resolve.js +271 -0
- package/dist/graph/edge-schema.d.ts +55 -0
- package/dist/graph/edge-schema.js +0 -0
- package/dist/graph/edges.d.ts +22 -0
- package/dist/graph/edges.js +63 -0
- package/dist/graph/ids.d.ts +14 -0
- package/dist/graph/ids.js +38 -0
- package/dist/graph/lineage.d.ts +48 -0
- package/dist/graph/lineage.js +226 -0
- package/dist/graph/mutations.d.ts +108 -0
- package/dist/graph/mutations.js +356 -0
- package/dist/graph/nodes.d.ts +46 -0
- package/dist/graph/nodes.js +137 -0
- package/dist/graph/revision.d.ts +50 -0
- package/dist/graph/revision.js +75 -0
- package/dist/graph/schema.d.ts +54 -0
- package/dist/graph/schema.js +90 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +33 -0
- package/dist/init.d.ts +47 -0
- package/dist/init.js +132 -0
- package/dist/lifecycle/engine.d.ts +75 -0
- package/dist/lifecycle/engine.js +146 -0
- package/dist/lifecycle/record.d.ts +18 -0
- package/dist/lifecycle/record.js +157 -0
- package/dist/lifecycle/run.d.ts +62 -0
- package/dist/lifecycle/run.js +167 -0
- package/dist/loader.d.ts +38 -0
- package/dist/loader.js +64 -0
- package/dist/pack/capabilities.d.ts +22 -0
- package/dist/pack/capabilities.js +31 -0
- package/dist/pack/locate.d.ts +22 -0
- package/dist/pack/locate.js +80 -0
- package/dist/pack/manifest.d.ts +34 -0
- package/dist/pack/manifest.js +168 -0
- package/dist/pack/resolve.d.ts +92 -0
- package/dist/pack/resolve.js +238 -0
- package/dist/project.d.ts +22 -0
- package/dist/project.js +37 -0
- package/dist/sync.d.ts +54 -0
- package/dist/sync.js +98 -0
- package/dist/validate.d.ts +23 -0
- package/dist/validate.js +32 -0
- package/dist/validation.d.ts +24 -0
- package/dist/validation.js +83 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +8 -0
- package/dist/yaml.d.ts +12 -0
- package/dist/yaml.js +32 -0
- package/package.json +65 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects problems for one file. Every `expect*` helper records a problem
|
|
3
|
+
* and returns `undefined` on failure so parsers can keep going and report
|
|
4
|
+
* everything wrong with a file in one pass.
|
|
5
|
+
*/
|
|
6
|
+
export class Checker {
|
|
7
|
+
path;
|
|
8
|
+
problems = [];
|
|
9
|
+
constructor(path) {
|
|
10
|
+
this.path = path;
|
|
11
|
+
}
|
|
12
|
+
fail(code, message) {
|
|
13
|
+
this.problems.push({ code, message, path: this.path });
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
get ok() {
|
|
17
|
+
return this.problems.length === 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function isRecord(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
/*
|
|
24
|
+
* Every `expect*` helper treats `undefined` (an absent key) as already
|
|
25
|
+
* reported: `requireKeys` owns the missing-field problem, so a required
|
|
26
|
+
* field never produces two problems.
|
|
27
|
+
*/
|
|
28
|
+
export function expectRecord(c, value, label) {
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (!isRecord(value))
|
|
32
|
+
return c.fail("invalid-type", `${label} must be a mapping`);
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
export function expectString(c, value, label) {
|
|
36
|
+
if (value === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
39
|
+
return c.fail("invalid-type", `${label} must be a non-empty string`);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
export function expectInteger(c, value, label) {
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
47
|
+
return c.fail("invalid-type", `${label} must be an integer`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
export function expectBoolean(c, value, label) {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
if (typeof value !== "boolean")
|
|
55
|
+
return c.fail("invalid-type", `${label} must be a boolean`);
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
export function expectEnum(c, value, label, allowed) {
|
|
59
|
+
if (value === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (typeof value !== "string" || !allowed.includes(value)) {
|
|
62
|
+
return c.fail("invalid-value", `${label} must be one of: ${allowed.join(", ")}`);
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
export function expectVersion(c, value, label, expected) {
|
|
67
|
+
const version = expectInteger(c, value, label);
|
|
68
|
+
if (version !== undefined && version !== expected) {
|
|
69
|
+
c.fail("unsupported-version", `${label} must be ${expected}, found ${version}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function requireKeys(c, record, label, keys) {
|
|
73
|
+
for (const key of keys) {
|
|
74
|
+
if (!(key in record))
|
|
75
|
+
c.fail("missing-field", `${label} is missing required field "${key}"`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function rejectUnknownKeys(c, record, label, allowed) {
|
|
79
|
+
for (const key of Object.keys(record)) {
|
|
80
|
+
if (!allowed.includes(key))
|
|
81
|
+
c.fail("unknown-field", `${label} has unknown field "${key}"`);
|
|
82
|
+
}
|
|
83
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
/** The runtime package version, read from the package manifest shipped with the build. */
|
|
4
|
+
export function runtimeVersion() {
|
|
5
|
+
const manifestPath = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
6
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
7
|
+
return manifest.version;
|
|
8
|
+
}
|
package/dist/yaml.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Problem } from "./errors.js";
|
|
2
|
+
export interface YamlReadResult {
|
|
3
|
+
readonly value: unknown;
|
|
4
|
+
readonly problems: readonly Problem[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Parses YAML text with the YAML core schema: no timestamp, merge or
|
|
8
|
+
* binary coercion, so `created: 2026-01-01` stays a string.
|
|
9
|
+
* Returns problems instead of throwing so callers can aggregate.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseYaml(text: string, path: string): YamlReadResult;
|
|
12
|
+
export declare function readYamlFile(path: string): YamlReadResult;
|
package/dist/yaml.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { CORE_SCHEMA, load, YAMLException } from "js-yaml";
|
|
3
|
+
/**
|
|
4
|
+
* Parses YAML text with the YAML core schema: no timestamp, merge or
|
|
5
|
+
* binary coercion, so `created: 2026-01-01` stays a string.
|
|
6
|
+
* Returns problems instead of throwing so callers can aggregate.
|
|
7
|
+
*/
|
|
8
|
+
export function parseYaml(text, path) {
|
|
9
|
+
try {
|
|
10
|
+
const value = load(text, { schema: CORE_SCHEMA, filename: path });
|
|
11
|
+
return { value: value === undefined ? null : value, problems: [] };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const message = error instanceof YAMLException ? error.reason : String(error);
|
|
15
|
+
return {
|
|
16
|
+
value: null,
|
|
17
|
+
problems: [{ code: "invalid-yaml", message: `invalid YAML: ${message}`, path }],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function readYamlFile(path) {
|
|
22
|
+
let text;
|
|
23
|
+
try {
|
|
24
|
+
text = readFileSync(path, "utf8");
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const code = error.code;
|
|
28
|
+
const message = code === "ENOENT" ? "file not found" : `cannot read file: ${String(error)}`;
|
|
29
|
+
return { value: null, problems: [{ code: "missing-file", message, path }] };
|
|
30
|
+
}
|
|
31
|
+
return parseYaml(text, path);
|
|
32
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pactwright",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Graph-native AI software delivery: intent, decision, contract, brief and evidence recorded in the repository.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pactwright",
|
|
7
|
+
"delivery",
|
|
8
|
+
"spec-graph",
|
|
9
|
+
"claude-code"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"private": false,
|
|
13
|
+
"type": "module",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/sb-dev/pactwright.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/sb-dev/pactwright#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/sb-dev/pactwright/issues"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22 <23 || >=24 <25"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"pactwright": "dist/cli.js"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"js-yaml": "^4.1.0",
|
|
43
|
+
"@pactwright/standard": "0.0.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@eslint/js": "^9.0.0",
|
|
47
|
+
"@types/js-yaml": "^4.0.9",
|
|
48
|
+
"@types/node": "^22.15.0",
|
|
49
|
+
"eslint": "^9.0.0",
|
|
50
|
+
"prettier": "^3.6.0",
|
|
51
|
+
"tsx": "^4.19.0",
|
|
52
|
+
"typescript": "^5.8.0",
|
|
53
|
+
"typescript-eslint": "^8.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "pnpm --filter @pactwright/standard build && tsc -p tsconfig.build.json",
|
|
57
|
+
"pactwright": "node dist/cli.js",
|
|
58
|
+
"format": "prettier --write .",
|
|
59
|
+
"format:check": "prettier --check .",
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"test": "node --test --import tsx tests/*.test.ts",
|
|
63
|
+
"verify": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build"
|
|
64
|
+
}
|
|
65
|
+
}
|