@potential-guide/check-sdk 0.0.0-stage → 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 shazhou-ww
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,48 @@
1
- # Temporary Holding Version
1
+ # Check SDK
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared Check author library for Node >=22.13. No environment algorithms,
4
+ Engine lifecycle, publishing or second Bundle compiler.
5
+
6
+ | Import | Purpose |
7
+ | --- | --- |
8
+ | `@potential-guide/check-sdk` | `createCheckResult`, `createCheckTask`, result types; no runtime author/Schema imports |
9
+ | `@potential-guide/check-sdk/contracts` | `createCheckContract`, result/problem TypeBox Schema factories |
10
+ | `@potential-guide/check-sdk/authoring` | Check YAML Schema, `prepareCheck`, `validateReference`, `verifyCheckResources` |
11
+
12
+ Reference: [results](references/en/check-result.md),
13
+ [callbacks](references/en/check-callback.md). These files ship with npm; they
14
+ are not automatically included in business Bundles.
15
+
16
+ ## Author flow
17
+
18
+ Use the [small independent text check](examples/text/README.md).
19
+ Check Build YAML declares name/kind, source root/entry/contract, canonical
20
+ BCP 47 languages, stable problemCodes, referenceRoot and explicit per-language
21
+ check/problem mappings. Unknown properties fail; a zero-code list is valid.
22
+ Optional `resources: [{from: "assets/file.json", to: "resources/file.json"}]`
23
+ selects additional exact files, with no glob expansion.
24
+
25
+ `prepareCheck(file)` validates every declared language's `check.md` and
26
+ `problems/<code>.md`, rejects undeclared files/languages/codes, symlinks,
27
+ duplicate mappings and escaping paths, and snapshots inputs under
28
+ `dist/staging/<kind>/`. Every Reference needs YAML frontmatter containing
29
+ **only** nonempty `title` and `description` (at most 200 Unicode code points).
30
+ Bodies, sections, translations, links and anchors are not parsed or validated.
31
+ All generated inputs are under `dist/`; definitions at
32
+ `dist/definitions/<kind>.{js,d.ts}` are derived from YAML and imported by both
33
+ business code and its contract. Run preparation before TypeScript.
34
+
35
+ Call the ordinary `buildTask(prepared.buildFile)` from
36
+ `@potential-guide/pguide-task-bundle` next. It consumes only the fixed staged
37
+ business inputs. Read its CAR with `readTaskArtifact` and call
38
+ `verifyCheckResources(prepared, artifact.files)` before accepting any output.
39
+ The exact resource set **and bytes**, including `resources/check.json`, must
40
+ match. Accept candidates only after all checks succeed; never replace the
41
+ last accepted output/index on failure. The SDK does not invoke the compiler
42
+ or publish artifacts.
43
+
44
+ Bundle references are available at
45
+ `ipfs://<CID>/resources/references/<language>/check.md` and
46
+ `ipfs://<CID>/resources/references/<language>/problems/<code>.md`.
47
+ `resources/check.json` maps languages and codes to these Bundle-relative paths.
48
+ This is a Check convention, not automatic Engine document presentation.
@@ -0,0 +1,34 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ export declare const checkBuildSchema: import("@sinclair/typebox").TObject<{
3
+ name: import("@sinclair/typebox").TString;
4
+ kind: import("@sinclair/typebox").TString;
5
+ source: import("@sinclair/typebox").TObject<{
6
+ root: import("@sinclair/typebox").TString;
7
+ entry: import("@sinclair/typebox").TString;
8
+ contract: import("@sinclair/typebox").TString;
9
+ }>;
10
+ languages: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
11
+ problemCodes: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
12
+ references: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
13
+ check: import("@sinclair/typebox").TString;
14
+ problems: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
15
+ }>>;
16
+ referenceRoot: import("@sinclair/typebox").TString;
17
+ resources: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
18
+ from: import("@sinclair/typebox").TString;
19
+ to: import("@sinclair/typebox").TString;
20
+ }>>>;
21
+ }>;
22
+ export type CheckBuild = Static<typeof checkBuildSchema>;
23
+ export declare function validateReference(bytes: Uint8Array, path: string): void;
24
+ export interface PreparedCheck {
25
+ kind: string;
26
+ buildFile: string;
27
+ staging: string;
28
+ resources: ReadonlyMap<string, Buffer>;
29
+ }
30
+ /** Freeze author inputs before the ordinary Task compiler runs. */
31
+ export declare function prepareCheck(buildFile: string): Promise<PreparedCheck>;
32
+ /** Compare the CAR's actual resource set and bytes, not its author include list. */
33
+ export declare function verifyCheckResources(prepared: PreparedCheck, artifact: ReadonlyMap<string, Uint8Array>): void;
34
+ //# sourceMappingURL=authoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring.d.ts","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;EA2B5B,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAwEzD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAqBvE;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,mEAAmE;AACnE,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAmK5E;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,GACxC,IAAI,CAYN"}
@@ -0,0 +1,270 @@
1
+ import { lstat, mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { Type } from "@sinclair/typebox";
4
+ import { Value } from "@sinclair/typebox/value";
5
+ import { parseDocument, stringify } from "yaml";
6
+ const pathSchema = Type.String({ minLength: 1 });
7
+ export const checkBuildSchema = Type.Object({
8
+ name: Type.String({ minLength: 1 }),
9
+ kind: Type.String({ pattern: "^[a-z][a-z0-9-]*$" }),
10
+ source: Type.Object({ root: pathSchema, entry: pathSchema, contract: pathSchema }, { additionalProperties: false }),
11
+ languages: Type.Array(Type.String(), { minItems: 1, uniqueItems: true }),
12
+ problemCodes: Type.Array(Type.String({ pattern: "^[a-z][a-z0-9-]*$", maxLength: 4096 }), {
13
+ uniqueItems: true,
14
+ }),
15
+ references: Type.Record(Type.String(), Type.Object({ check: pathSchema, problems: Type.Record(Type.String(), pathSchema) }, { additionalProperties: false })),
16
+ referenceRoot: pathSchema,
17
+ resources: Type.Optional(Type.Array(Type.Object({ from: pathSchema, to: pathSchema }, { additionalProperties: false }))),
18
+ }, { additionalProperties: false });
19
+ function yaml(text, file) {
20
+ const document = parseDocument(text, { uniqueKeys: true });
21
+ if (document.errors.length)
22
+ throw new Error(`${file}: ${document.errors.join("; ")}`);
23
+ return document.toJS({ maxAliasCount: 0 });
24
+ }
25
+ function portable(path) {
26
+ if (!path ||
27
+ path.includes("\\") ||
28
+ path.includes("\0") ||
29
+ path.split("/").some((part) => !part || part === "." || part === "..") ||
30
+ /[:*?[\]{}]/.test(path))
31
+ throw new Error(`Invalid relative path: ${path}`);
32
+ return path;
33
+ }
34
+ async function safeFile(root, path) {
35
+ const parts = portable(path).split("/");
36
+ let current = root;
37
+ for (const [index, part] of parts.entries()) {
38
+ current = join(current, part);
39
+ const info = await lstat(current);
40
+ if (info.isSymbolicLink() || (index < parts.length - 1 ? !info.isDirectory() : !info.isFile()))
41
+ throw new Error(`Not an ordinary file path: ${current}`);
42
+ }
43
+ return readFile(current);
44
+ }
45
+ async function files(root, prefix = "") {
46
+ const info = await lstat(root);
47
+ if (!info.isDirectory() || info.isSymbolicLink())
48
+ throw new Error(`Not an ordinary directory: ${root}`);
49
+ const output = [];
50
+ for (const entry of await readdir(root, { withFileTypes: true })) {
51
+ const path = prefix ? `${prefix}/${entry.name}` : entry.name;
52
+ if (entry.isSymbolicLink())
53
+ throw new Error(`Linked input: ${path}`);
54
+ if (entry.isDirectory())
55
+ output.push(...(await files(join(root, entry.name), path)));
56
+ else if (entry.isFile())
57
+ output.push(path);
58
+ else
59
+ throw new Error(`Not an ordinary input: ${path}`);
60
+ }
61
+ return output.sort();
62
+ }
63
+ async function safeDirectory(root, path) {
64
+ let current = root;
65
+ for (const part of portable(path).split("/")) {
66
+ current = join(current, part);
67
+ const info = await lstat(current);
68
+ if (!info.isDirectory() || info.isSymbolicLink())
69
+ throw new Error(`Not an ordinary directory: ${current}`);
70
+ }
71
+ }
72
+ async function outputDirectory(root, path) {
73
+ let current = root;
74
+ for (const part of portable(path).split("/")) {
75
+ current = join(current, part);
76
+ try {
77
+ await mkdir(current);
78
+ }
79
+ catch (error) {
80
+ if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
81
+ throw error;
82
+ }
83
+ const info = await lstat(current);
84
+ if (!info.isDirectory() || info.isSymbolicLink())
85
+ throw new Error(`Not an ordinary output directory: ${current}`);
86
+ }
87
+ }
88
+ export function validateReference(bytes, path) {
89
+ const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes).replace(/^\uFEFF/, "");
90
+ const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
91
+ if (!match)
92
+ throw new Error(`${path}: missing Reference YAML frontmatter`);
93
+ const metadata = yaml(match[1] ?? "", path);
94
+ if (typeof metadata !== "object" ||
95
+ metadata === null ||
96
+ Array.isArray(metadata) ||
97
+ Object.keys(metadata).some((key) => !["title", "description"].includes(key)) ||
98
+ !("title" in metadata) ||
99
+ typeof metadata.title !== "string" ||
100
+ !metadata.title.trim() ||
101
+ !("description" in metadata) ||
102
+ typeof metadata.description !== "string" ||
103
+ !metadata.description.trim() ||
104
+ [...metadata.description].length > 200)
105
+ throw new Error(`${path}: Reference requires only nonempty title and description (<=200 code points)`);
106
+ }
107
+ /** Freeze author inputs before the ordinary Task compiler runs. */
108
+ export async function prepareCheck(buildFile) {
109
+ const root = dirname(resolve(buildFile));
110
+ const raw = yaml(await readFile(buildFile, "utf8"), buildFile);
111
+ if (!Value.Check(checkBuildSchema, raw))
112
+ throw new Error(`${buildFile}: invalid Check Build YAML: ${[...Value.Errors(checkBuildSchema, raw)].map((error) => `${error.path} ${error.message}`).join("; ")}`);
113
+ const config = raw;
114
+ const fail = (message) => {
115
+ throw new Error(`Check ${config.kind}: ${message}`);
116
+ };
117
+ for (const language of config.languages) {
118
+ try {
119
+ if (Intl.getCanonicalLocales(language)[0] !== language)
120
+ fail(`noncanonical language ${language}`);
121
+ }
122
+ catch {
123
+ fail(`invalid language ${language}`);
124
+ }
125
+ }
126
+ if (Object.keys(config.references).some((language) => !config.languages.includes(language)))
127
+ fail("unknown Reference language");
128
+ portable(config.referenceRoot);
129
+ portable(config.source.root);
130
+ if ([config.source.root, config.referenceRoot].some((path) => path.split("/")[0] === "dist"))
131
+ fail("author source/Reference roots must not overlap generated dist outputs");
132
+ await safeDirectory(root, config.source.root);
133
+ await safeDirectory(root, config.referenceRoot);
134
+ for (const entry of await readdir(join(root, config.referenceRoot), { withFileTypes: true })) {
135
+ if (!entry.isDirectory() || !config.languages.includes(entry.name))
136
+ fail(`unknown language or filename ${config.referenceRoot}/${entry.name}`);
137
+ for (const child of await readdir(join(root, config.referenceRoot, entry.name), {
138
+ withFileTypes: true,
139
+ })) {
140
+ if (child.name === "check.md" && child.isFile())
141
+ continue;
142
+ if (child.name !== "problems" || !child.isDirectory())
143
+ fail(`unknown Reference path ${config.referenceRoot}/${entry.name}/${child.name}`);
144
+ for (const problem of await readdir(join(root, config.referenceRoot, entry.name, "problems"), { withFileTypes: true }))
145
+ if (!problem.isFile() || !config.problemCodes.some((code) => problem.name === `${code}.md`))
146
+ fail(`${entry.name}: unknown problem filename ${problem.name}`);
147
+ }
148
+ }
149
+ const resources = new Map();
150
+ const selected = new Set();
151
+ for (const language of config.languages) {
152
+ const mapping = config.references[language];
153
+ if (!mapping)
154
+ return fail(`missing ${language} definition mapping`);
155
+ const required = new Map([["check.md", mapping.check]]);
156
+ if (Object.keys(mapping.problems).some((code) => !config.problemCodes.includes(code)))
157
+ fail(`${language}: unknown problem code`);
158
+ for (const code of config.problemCodes) {
159
+ const path = mapping.problems[code];
160
+ if (!path)
161
+ return fail(`${language}: missing problem ${code}`);
162
+ required.set(`problems/${code}.md`, path);
163
+ }
164
+ for (const [suffix, path] of required) {
165
+ const expected = `${config.referenceRoot}/${language}/${suffix}`;
166
+ if (path !== expected)
167
+ fail(`${language}: filename/path mismatch ${path}; expected ${expected}`);
168
+ if (selected.has(path))
169
+ fail(`${language}: duplicate mapping ${path}`);
170
+ selected.add(path);
171
+ let bytes;
172
+ try {
173
+ bytes = await safeFile(root, path);
174
+ validateReference(bytes, path);
175
+ }
176
+ catch (error) {
177
+ return fail(`${language} ${suffix} ${path}: ${String(error)}`);
178
+ }
179
+ resources.set(`resources/references/${language}/${suffix}`, bytes);
180
+ }
181
+ }
182
+ const actual = await files(join(root, config.referenceRoot));
183
+ if (actual.some((path) => !selected.has(`${config.referenceRoot}/${path}`)))
184
+ fail(`unknown language, problem code or filename in ${config.referenceRoot}: ${actual.filter((path) => !selected.has(`${config.referenceRoot}/${path}`)).join(", ")}`);
185
+ for (const resource of config.resources ?? []) {
186
+ const destination = portable(resource.to);
187
+ if (!destination.startsWith("resources/") ||
188
+ resources.has(destination) ||
189
+ destination === "resources/check.json")
190
+ fail(`duplicate or invalid resource destination ${destination}`);
191
+ resources.set(destination, await safeFile(root, resource.from));
192
+ }
193
+ const source = new Map();
194
+ for (const path of await files(join(root, config.source.root))) {
195
+ const full = `${config.source.root}/${path}`;
196
+ source.set(full, await safeFile(root, full));
197
+ }
198
+ for (const path of [config.source.entry, config.source.contract])
199
+ if (!source.has(path))
200
+ fail(`source not in source root: ${path}`);
201
+ const definitions = `dist/definitions/${config.kind}`;
202
+ const literal = JSON.stringify(config.problemCodes);
203
+ const definitionJs = Buffer.from(`export const problemCodes = Object.freeze(${literal});\n`);
204
+ const definitionTypes = Buffer.from(`export declare const problemCodes: readonly [${config.problemCodes.map((code) => JSON.stringify(code)).join(", ")}];\n`);
205
+ source.set(`${definitions}.js`, definitionJs);
206
+ source.set(`${definitions}.d.ts`, definitionTypes);
207
+ const staging = join(root, "dist", "staging", config.kind);
208
+ // Only owned staging inputs are replaced; accepted artifacts are never touched here.
209
+ await outputDirectory(root, "dist/staging");
210
+ await outputDirectory(root, "dist/definitions");
211
+ await outputDirectory(root, `dist/staging/${config.kind}`);
212
+ await rm(staging, { recursive: true, force: true });
213
+ for (const [path, bytes] of [...source, ...resources]) {
214
+ await mkdir(dirname(join(staging, path)), { recursive: true });
215
+ await writeFile(join(staging, path), bytes);
216
+ }
217
+ for (const [extension, bytes] of [
218
+ ["js", definitionJs],
219
+ ["d.ts", definitionTypes],
220
+ ]) {
221
+ const path = join(root, `${definitions}.${extension}`);
222
+ await mkdir(dirname(path), { recursive: true });
223
+ await writeFile(path, bytes);
224
+ }
225
+ const index = Buffer.from(`${JSON.stringify({
226
+ kind: config.kind,
227
+ languages: config.languages,
228
+ problemCodes: config.problemCodes,
229
+ references: Object.fromEntries(config.languages.map((language) => [
230
+ language,
231
+ {
232
+ check: `resources/references/${language}/check.md`,
233
+ problems: Object.fromEntries(config.problemCodes.map((code) => [
234
+ code,
235
+ `resources/references/${language}/problems/${code}.md`,
236
+ ])),
237
+ },
238
+ ])),
239
+ }, null, 2)}\n`);
240
+ resources.set("resources/check.json", index);
241
+ await mkdir(join(staging, "resources"), { recursive: true });
242
+ await writeFile(join(staging, "resources", "check.json"), index);
243
+ const generated = {
244
+ $schema: "https://shazhou-ww.github.io/potential-guide/schemas/artifacts/task-build/v1.json",
245
+ name: config.name,
246
+ runtime: { minVersion: "22.13.0" },
247
+ source: { entry: config.source.entry, contract: config.source.contract, mode: "explicit" },
248
+ include: [...resources.keys()].map((path) => ({
249
+ from: path,
250
+ to: `${path.slice(0, path.lastIndexOf("/") + 1)}`,
251
+ })),
252
+ outDirectory: "bundle",
253
+ };
254
+ const output = join(staging, "task.build.yaml");
255
+ await writeFile(output, stringify(generated));
256
+ return { kind: config.kind, staging, buildFile: output, resources };
257
+ }
258
+ /** Compare the CAR's actual resource set and bytes, not its author include list. */
259
+ export function verifyCheckResources(prepared, artifact) {
260
+ const actual = [...artifact.keys()]
261
+ .filter((path) => path !== "task.yaml" && path !== "worker.cjs" && !/^schemas\/\d+\.json$/.test(path))
262
+ .sort();
263
+ const expected = [...prepared.resources.keys()].sort();
264
+ if (JSON.stringify(actual) !== JSON.stringify(expected))
265
+ throw new Error(`Check ${prepared.kind}: CAR resource selection mismatch`);
266
+ for (const [path, bytes] of prepared.resources)
267
+ if (!Buffer.from(artifact.get(path) ?? []).equals(bytes))
268
+ throw new Error(`Check ${prepared.kind}: CAR resource bytes differ: ${path}`);
269
+ }
270
+ //# sourceMappingURL=authoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring.js","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEhD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CACzC;IACE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACnC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IACnD,MAAM,EAAE,IAAI,CAAC,MAAM,CACjB,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC7D,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC;IACD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACxE,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,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I,QAAQ,CAAC,SAAS;QAC5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,CAAC,IAAI,gCAAgC,IAAI,EAAE,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type Static, type TSchema } from "@sinclair/typebox";
2
+ export declare function createCheckProblemSchema<const Codes extends readonly string[]>(codes: Codes): import("@sinclair/typebox").TObject<{
3
+ target: import("@sinclair/typebox").TString;
4
+ code: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<Codes[number]>[]>;
5
+ actual: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
6
+ }>;
7
+ export declare function createCheckResultSchema<const Codes extends readonly string[]>(codes: Codes): import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
8
+ pass: import("@sinclair/typebox").TLiteral<true>;
9
+ }>, import("@sinclair/typebox").TObject<{
10
+ pass: import("@sinclair/typebox").TLiteral<false>;
11
+ problems: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
12
+ target: import("@sinclair/typebox").TString;
13
+ code: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<Codes[number]>[]>;
14
+ actual: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
15
+ }>>;
16
+ }>]>;
17
+ export type CheckProblem<Code extends string = string> = Static<ReturnType<typeof createCheckProblemSchema<readonly Code[]>>>;
18
+ export type CheckResult<Code extends string = string> = Static<ReturnType<typeof createCheckResultSchema<readonly Code[]>>>;
19
+ export declare function createCheckContract<Input extends TSchema, const Codes extends readonly string[]>(input: Input, codes: Codes): {
20
+ input: Input;
21
+ result: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
22
+ pass: import("@sinclair/typebox").TLiteral<true>;
23
+ }>, import("@sinclair/typebox").TObject<{
24
+ pass: import("@sinclair/typebox").TLiteral<false>;
25
+ problems: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
26
+ target: import("@sinclair/typebox").TString;
27
+ code: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<Codes[number]>[]>;
28
+ actual: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
29
+ }>>;
30
+ }>]>;
31
+ message: import("@sinclair/typebox").TNever;
32
+ };
33
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAKpE,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK;;;;GAU3F;AAED,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK;;;;;;;;;KAW1F;AAED,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAC7D,UAAU,CAAC,OAAO,wBAAwB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAC7D,CAAC;AACF,MAAM,MAAM,WAAW,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAC5D,UAAU,CAAC,OAAO,uBAAuB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAC5D,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,OAAO,EAAE,KAAK,CAAC,KAAK,SAAS,SAAS,MAAM,EAAE,EAC9F,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK;;;;;;;;;;;;;EAGb"}
@@ -0,0 +1,24 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { assertProblemCodes } from "./definition.js";
3
+ const text = () => Type.String({ minLength: 1, maxLength: 4096 });
4
+ export function createCheckProblemSchema(codes) {
5
+ assertProblemCodes(codes);
6
+ return Type.Object({
7
+ target: text(),
8
+ code: Type.Union(codes.map((code) => Type.Literal(code))),
9
+ actual: Type.Union([Type.String(), Type.Null()]),
10
+ }, { additionalProperties: false });
11
+ }
12
+ export function createCheckResultSchema(codes) {
13
+ return Type.Union([
14
+ Type.Object({ pass: Type.Literal(true) }, { additionalProperties: false }),
15
+ Type.Object({
16
+ pass: Type.Literal(false),
17
+ problems: Type.Array(createCheckProblemSchema(codes), { minItems: 1 }),
18
+ }, { additionalProperties: false }),
19
+ ]);
20
+ }
21
+ export function createCheckContract(input, codes) {
22
+ return { input, result: createCheckResultSchema(codes), message: Type.Never() };
23
+ }
24
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAElE,MAAM,UAAU,wBAAwB,CAAwC,KAAY;IAC1F,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC,MAAM,CAChB;QACE,MAAM,EAAE,IAAI,EAAE;QACd,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAqB,CAAC,CAAC,CAAC;QAC1E,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KACjD,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAwC,KAAY;IACzF,OAAO,IAAI,CAAC,KAAK,CAAC;QAChB,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QAC1E,IAAI,CAAC,MAAM,CACT;YACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YACzB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;SACvE,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC;KACF,CAAC,CAAC;AACL,CAAC;AASD,MAAM,UAAU,mBAAmB,CACjC,KAAY,EACZ,KAAY;IAEZ,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;AAClF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function assertProblemCodes(codes: readonly string[]): void;
2
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAMjE"}
@@ -0,0 +1,6 @@
1
+ export function assertProblemCodes(codes) {
2
+ if (new Set(codes).size !== codes.length ||
3
+ codes.some((code) => !/^[a-z][a-z0-9-]*$/.test(code) || code.length > 4096))
4
+ throw new Error("Check problem codes must be unique stable names of at most 4096 characters.");
5
+ }
6
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,KAAwB;IACzD,IACE,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM;QACpC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAE3E,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { TaskCallback, TaskContext } from "@potential-guide/task-sdk";
2
+ import type { CheckProblem, CheckResult } from "./contracts.js";
3
+ export type { CheckProblem, CheckResult } from "./contracts.js";
4
+ export declare function createCheckResult<const Codes extends readonly string[]>(codes: Codes, problems: readonly CheckProblem<Codes[number]>[]): CheckResult<Codes[number]>;
5
+ export declare function createCheckTask<Input, const Codes extends readonly string[]>(codes: Codes, inspect: (input: Input, context: TaskContext) => Promise<readonly CheckProblem<Codes[number]>[]>): TaskCallback<Input, CheckResult<Codes[number]>>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGhE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,MAAM,EAAE,EACrE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,SAAS,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,GAC/C,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAiB5B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,SAAS,SAAS,MAAM,EAAE,EAC1E,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAC/F,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAOjD"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { assertProblemCodes } from "./definition.js";
2
+ export function createCheckResult(codes, problems) {
3
+ assertProblemCodes(codes);
4
+ const allowed = new Set(codes);
5
+ const copy = problems.map((problem) => {
6
+ if (!allowed.has(problem.code))
7
+ throw new Error(`Undeclared Check problem code: ${problem.code}`);
8
+ if (typeof problem.target !== "string" ||
9
+ !problem.target.length ||
10
+ [...problem.target].length > 4096 ||
11
+ (problem.actual !== null && typeof problem.actual !== "string") ||
12
+ Object.keys(problem).some((key) => !["target", "code", "actual"].includes(key)))
13
+ throw new Error("Invalid Check problem.");
14
+ return { target: problem.target, code: problem.code, actual: problem.actual };
15
+ });
16
+ return copy.length ? { pass: false, problems: copy } : { pass: true };
17
+ }
18
+ export function createCheckTask(codes, inspect) {
19
+ return async (input, context) => {
20
+ context.signal.throwIfAborted();
21
+ const problems = await inspect(input, context);
22
+ context.signal.throwIfAborted();
23
+ return createCheckResult(codes, problems);
24
+ };
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM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,OAAgG;IAEhG,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAChC,OAAO,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ # Independent text Check
2
+
3
+ Copy this directory into an independent ESM package. Install the four
4
+ dependencies in package.json (local packed tarballs are supported), then run
5
+ `node build.mjs` or `pnpm build`. No workspace paths or environment checks are
6
+ needed. Entry: `src/main.ts`; contract: `src/contract.ts`;
7
+ configuration: `text.check.build.yaml`.
8
+
9
+ The script calls Check preparation, standard Task build and CAR resource
10
+ verification. Output: `dist/staging/text/bundle/` and
11
+ `dist/staging/text/bundle.car`, with the CID printed as JSON. Submit input
12
+ `{"text":"hello"}` for `{pass:true}`, or `{"text":" "}` for a `text-empty`
13
+ problem. The problem code is declared only in YAML. Generated literal types
14
+ also support ordinary TypeScript checking after preparation.
@@ -0,0 +1,11 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { prepareCheck, verifyCheckResources } from "@potential-guide/check-sdk/authoring";
3
+ import { buildTask } from "@potential-guide/pguide-task-bundle";
4
+ import { readTaskArtifact } from "@potential-guide/pguide-task-bundle/artifact";
5
+
6
+ const prepared = await prepareCheck(
7
+ fileURLToPath(new URL("text.check.build.yaml", import.meta.url)),
8
+ );
9
+ const artifact = await buildTask(prepared.buildFile);
10
+ verifyCheckResources(prepared, (await readTaskArtifact(artifact.car)).files);
11
+ console.log(JSON.stringify(artifact));
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "check-sdk-text-example",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "node build.mjs"
7
+ },
8
+ "dependencies": {
9
+ "@potential-guide/check-sdk": "0.1.0",
10
+ "@potential-guide/task-sdk": "0.1.0-rc.0",
11
+ "@potential-guide/pguide-task-bundle": "0.1.0-rc.0",
12
+ "@sinclair/typebox": "0.34.52"
13
+ }
14
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: Nonempty text
3
+ description: Check that the input text contains a non-whitespace character.
4
+ ---
5
+
6
+ Input is `{text:string}`. This check uses no physical resources or network.
7
+ Whitespace-only input returns [text-empty](problems/text-empty.md), otherwise
8
+ `{pass:true}`. Execution and cancellation follow the shared Check SDK contract.
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: Empty text
3
+ description: The text input contains no non-whitespace characters.
4
+ ---
5
+
6
+ `target` is `text`; `actual` is the unchanged input. Supply non-whitespace text.
7
+ This check reports the condition and does not change the input.
@@ -0,0 +1,8 @@
1
+ import { createCheckContract } from "@potential-guide/check-sdk/contracts";
2
+ import { Type } from "@sinclair/typebox";
3
+ import { problemCodes } from "../dist/definitions/text.js";
4
+
5
+ export default createCheckContract(
6
+ Type.Object({ text: Type.String() }, { additionalProperties: false }),
7
+ problemCodes,
8
+ );
@@ -0,0 +1,12 @@
1
+ import { createCheckTask } from "@potential-guide/check-sdk";
2
+ import { runTask } from "@potential-guide/task-sdk";
3
+ import type { Static } from "@sinclair/typebox";
4
+ import { problemCodes } from "../dist/definitions/text.js";
5
+ import type contract from "./contract.js";
6
+
7
+ runTask(
8
+ createCheckTask(problemCodes, async (input: Static<typeof contract.input>, context) => {
9
+ context.signal.throwIfAborted();
10
+ return input.text.trim() ? [] : [{ target: "text", code: "text-empty", actual: input.text }];
11
+ }),
12
+ );
@@ -0,0 +1,14 @@
1
+ name: Nonempty text check
2
+ kind: text
3
+ source:
4
+ root: src
5
+ entry: src/main.ts
6
+ contract: src/contract.ts
7
+ languages: [en]
8
+ problemCodes: [text-empty]
9
+ referenceRoot: references
10
+ references:
11
+ en:
12
+ check: references/en/check.md
13
+ problems:
14
+ text-empty: references/en/problems/text-empty.md
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@potential-guide/check-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Reusable Check contracts, callbacks and Task authoring inputs.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./contracts": {
13
+ "types": "./dist/contracts.d.ts",
14
+ "import": "./dist/contracts.js"
15
+ },
16
+ "./authoring": {
17
+ "types": "./dist/authoring.d.ts",
18
+ "import": "./dist/authoring.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "references",
24
+ "examples",
25
+ "README.md"
26
+ ],
27
+ "engines": {
28
+ "node": ">=22.13.0"
29
+ },
30
+ "dependencies": {
31
+ "@sinclair/typebox": "0.34.52",
32
+ "yaml": "2.9.1",
33
+ "@potential-guide/task-sdk": "^0.1.0-rc.0"
34
+ },
35
+ "devDependencies": {
36
+ "esbuild": "0.28.2",
37
+ "@potential-guide/task-engine": "^0.1.0-rc.0",
38
+ "@potential-guide/task-protocol": "^0.1.0-rc.0",
39
+ "@potential-guide/pguide-task-bundle": "^0.1.0-rc.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "license": "MIT",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/shazhou-ww/potential-guide.git",
48
+ "directory": "packages/check-sdk"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc -b && node build.mjs",
52
+ "clean": "node -e \"for (const path of ['dist', 'examples/text/dist', '../../.cache/tsbuildinfo/check-sdk.tsbuildinfo']) require('node:fs').rmSync(path, { recursive: true, force: true })\"",
53
+ "lint": "biome lint .",
54
+ "test": "tsx --test \"test/*.test.ts\"",
55
+ "typecheck": "tsc -b --pretty false"
56
+ }
6
57
  }
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Check callbacks
3
+ description: Callback, cancellation, logging and resource ownership boundaries for checks.
4
+ ---
5
+
6
+ # Check callbacks
7
+
8
+ `createCheckTask(problemCodes, inspect)` adapts an async
9
+ `inspect(input, context)` returning a readonly problem list into a Task callback.
10
+ The full Task Context is passed unchanged: use `context.log` for logs.
11
+ The adapter checks `context.signal` before and after the callback and never
12
+ catches exceptions. Execution faults remain Engine failures; cancellation
13
+ remains cancellation, never `pass:false`.
14
+
15
+ The business implementation owns timeouts, subprocesses, sockets and files.
16
+ Release them in `finally` before returning or propagating an error. The SDK
17
+ does not schedule, kill processes or mask cleanup failures.
18
+ Authors explicitly call `runTask(createCheckTask(...))` in their entrypoint.
19
+ The root import is runtime-only; import Schemas from `check-sdk/contracts`
20
+ and filesystem validation from `check-sdk/authoring`.
21
+ See [result contracts](check-result.md).
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: Check results
3
+ description: Shared result and problem contracts for Task Engine checks.
4
+ ---
5
+
6
+ # Check results
7
+
8
+ Checks report only problems: `{"pass":true}` for none, otherwise
9
+ `{"pass":false,"problems":[{"target":"node","code":"too-old","actual":"20.0.0"}]}`.
10
+ The failing list must be nonempty. No additional properties are accepted.
11
+ `target` is a nonempty string of at most 4096 characters; `actual` is a string
12
+ or null. A problem code must belong to the Check Build YAML's `problemCodes`.
13
+ That single declaration generates the literal tuple used by TypeScript,
14
+ the result Schema and runtime assembly, as well as documentation coverage.
15
+ Undeclared runtime codes throw; they are not ordinary findings.
16
+
17
+ Result compatibility deliberately keeps the existing `pass`, `problems`,
18
+ `target`, `code`, `actual` shape. Successful items are not returned.
19
+ Execution failures and cancellation are not problems; see
20
+ [callbacks](check-callback.md).