@gobing-ai/ts-rule-engine 0.3.0 → 0.3.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/dist/host/capability-registry.d.ts +9 -23
- package/dist/host/capability-registry.d.ts.map +1 -1
- package/dist/host/capability-registry.js +9 -28
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -6
- package/package.json +5 -5
- package/rules/spur-dev.yaml +1 -1
- package/src/host/capability-registry.ts +9 -41
- package/src/types.ts +13 -6
- /package/rules/{typescript → quality}/tsdoc-exports.yaml +0 -0
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
/** Typed registry used by the rule engine host. */
|
|
11
|
-
export declare class CapabilityRegistry<TCapability> {
|
|
12
|
-
private readonly kind;
|
|
13
|
-
private readonly capabilities;
|
|
14
|
-
constructor(kind: string);
|
|
15
|
-
/** Register or replace a capability. */
|
|
16
|
-
register(name: string, capability: TCapability, origin?: CapabilityOrigin): void;
|
|
17
|
-
/** Return true when a capability exists. */
|
|
18
|
-
has(name: string): boolean;
|
|
19
|
-
/** Get a registered capability or throw a clear error. */
|
|
20
|
-
get(name: string): TCapability;
|
|
21
|
-
/** List registered capability names. */
|
|
22
|
-
list(): string[];
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility re-export (ADR-010 / task 0008).
|
|
3
|
+
*
|
|
4
|
+
* The capability registry now lives in the shared plugin core
|
|
5
|
+
* (`@gobing-ai/ts-runtime/plugin`). This module re-exports it from the original
|
|
6
|
+
* path so the public barrel and existing importers keep working unchanged. New
|
|
7
|
+
* code should import from `@gobing-ai/ts-runtime/plugin` directly.
|
|
8
|
+
*/
|
|
9
|
+
export { type CapabilityEntry, type CapabilityOrigin, CapabilityRegistry } from '@gobing-ai/ts-runtime/plugin';
|
|
24
10
|
//# sourceMappingURL=capability-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-registry.d.ts","sourceRoot":"","sources":["../../src/host/capability-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"capability-registry.d.ts","sourceRoot":"","sources":["../../src/host/capability-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.capabilities.set(name, { capability, origin });
|
|
11
|
-
}
|
|
12
|
-
/** Return true when a capability exists. */
|
|
13
|
-
has(name) {
|
|
14
|
-
return this.capabilities.has(name);
|
|
15
|
-
}
|
|
16
|
-
/** Get a registered capability or throw a clear error. */
|
|
17
|
-
get(name) {
|
|
18
|
-
const entry = this.capabilities.get(name);
|
|
19
|
-
if (entry === undefined) {
|
|
20
|
-
throw new Error(`Unknown ${this.kind}: ${name}`);
|
|
21
|
-
}
|
|
22
|
-
return entry.capability;
|
|
23
|
-
}
|
|
24
|
-
/** List registered capability names. */
|
|
25
|
-
list() {
|
|
26
|
-
return [...this.capabilities.keys()];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility re-export (ADR-010 / task 0008).
|
|
3
|
+
*
|
|
4
|
+
* The capability registry now lives in the shared plugin core
|
|
5
|
+
* (`@gobing-ai/ts-runtime/plugin`). This module re-exports it from the original
|
|
6
|
+
* path so the public barrel and existing importers keep working unchanged. New
|
|
7
|
+
* code should import from `@gobing-ai/ts-runtime/plugin` directly.
|
|
8
|
+
*/
|
|
9
|
+
export { CapabilityRegistry } from '@gobing-ai/ts-runtime/plugin';
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAExD,+CAA+C;AAC/C,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAElD,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IAChC,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC3B,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,QAAQ,EAAE,YAAY,CAAC;IACvB,+BAA+B;IAC/B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,6BAA6B;IAC7B,GAAG,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC1B,4CAA4C;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EA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IAC5B,yDAAyD;IACzD,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC;CAC5C;AAED,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC7B,yCAAyC;IACzC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,gDAAgD;IAChD,KAAK,EAAE,GAAG,EAAE,CAAC;CAChB;AAED,qDAAqD;AACrD,wBAAgB,aAAa,CACzB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,GAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAM,GAC9F,iBAAiB,CAQnB;AAED,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB;;;;;;;;kBAMF,CAAC;AAE/B,+CAA+C;AAC/C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;iBAe/B,CAAC;AAyBH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;kBAOhB,CAAC;AAEd,6CAA6C;AAC7C,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOnC,CAAC;AAEH,0CAA0C;AAC1C,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;iBASjC,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertRelativeExtensionPath } from '@gobing-ai/ts-runtime/plugin';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
/** Create a finding with inherited rule severity. */
|
|
3
4
|
export function createFinding(rule, message, filePath, extras = {}) {
|
|
@@ -39,16 +40,23 @@ export const ConstraintRuleSchema = z.object({
|
|
|
39
40
|
*
|
|
40
41
|
* Rejects absolute paths and `..` traversal: extension declarations are data, and a
|
|
41
42
|
* path that escapes the declaring file's directory is a trust-boundary violation even
|
|
42
|
-
* when extension loading is explicitly allowed.
|
|
43
|
+
* when extension loading is explicitly allowed. The actual guard is the shared
|
|
44
|
+
* `assertRelativeExtensionPath` (ADR-010) so schema-time validation here and load-time
|
|
45
|
+
* validation in the shared loader use one source of truth.
|
|
43
46
|
*/
|
|
44
47
|
const relativeExtensionPath = z
|
|
45
48
|
.string()
|
|
46
49
|
.min(1)
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
.superRefine((value, ctx) => {
|
|
51
|
+
try {
|
|
52
|
+
assertRelativeExtensionPath(value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
ctx.addIssue({
|
|
56
|
+
code: 'custom',
|
|
57
|
+
message: error instanceof Error ? error.message : 'invalid extension path',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
52
60
|
});
|
|
53
61
|
/**
|
|
54
62
|
* Shared zod schema for an `extensions` block, used by both preset and rule-file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-rule-engine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "@gobing-ai/ts-rule-engine — Constraint rule schemas, loading, evaluation, and result formatting.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-rule-engine-v<version> && git push --tags' && exit 1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@gobing-ai/ts-ai-runner": "^0.3.
|
|
53
|
-
"@gobing-ai/ts-db": "^0.3.
|
|
54
|
-
"@gobing-ai/ts-runtime": "^0.3.
|
|
55
|
-
"@gobing-ai/ts-utils": "^0.3.
|
|
52
|
+
"@gobing-ai/ts-ai-runner": "^0.3.1",
|
|
53
|
+
"@gobing-ai/ts-db": "^0.3.1",
|
|
54
|
+
"@gobing-ai/ts-runtime": "^0.3.1",
|
|
55
|
+
"@gobing-ai/ts-utils": "^0.3.1",
|
|
56
56
|
"yaml": "^2.7.0",
|
|
57
57
|
"zod": "^4.1.0"
|
|
58
58
|
},
|
package/rules/spur-dev.yaml
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** Typed registry used by the rule engine host. */
|
|
13
|
-
export class CapabilityRegistry<TCapability> {
|
|
14
|
-
private readonly capabilities = new Map<string, CapabilityEntry<TCapability>>();
|
|
15
|
-
|
|
16
|
-
constructor(private readonly kind: string) {}
|
|
17
|
-
|
|
18
|
-
/** Register or replace a capability. */
|
|
19
|
-
register(name: string, capability: TCapability, origin: CapabilityOrigin = 'extension'): void {
|
|
20
|
-
this.capabilities.set(name, { capability, origin });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Return true when a capability exists. */
|
|
24
|
-
has(name: string): boolean {
|
|
25
|
-
return this.capabilities.has(name);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Get a registered capability or throw a clear error. */
|
|
29
|
-
get(name: string): TCapability {
|
|
30
|
-
const entry = this.capabilities.get(name);
|
|
31
|
-
if (entry === undefined) {
|
|
32
|
-
throw new Error(`Unknown ${this.kind}: ${name}`);
|
|
33
|
-
}
|
|
34
|
-
return entry.capability;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** List registered capability names. */
|
|
38
|
-
list(): string[] {
|
|
39
|
-
return [...this.capabilities.keys()];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility re-export (ADR-010 / task 0008).
|
|
3
|
+
*
|
|
4
|
+
* The capability registry now lives in the shared plugin core
|
|
5
|
+
* (`@gobing-ai/ts-runtime/plugin`). This module re-exports it from the original
|
|
6
|
+
* path so the public barrel and existing importers keep working unchanged. New
|
|
7
|
+
* code should import from `@gobing-ai/ts-runtime/plugin` directly.
|
|
8
|
+
*/
|
|
9
|
+
export { type CapabilityEntry, type CapabilityOrigin, CapabilityRegistry } from '@gobing-ai/ts-runtime/plugin';
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertRelativeExtensionPath } from '@gobing-ai/ts-runtime/plugin';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
|
|
3
4
|
/** Finding severity emitted by the rule engine. */
|
|
@@ -218,16 +219,22 @@ export const ConstraintRuleSchema = z.object({
|
|
|
218
219
|
*
|
|
219
220
|
* Rejects absolute paths and `..` traversal: extension declarations are data, and a
|
|
220
221
|
* path that escapes the declaring file's directory is a trust-boundary violation even
|
|
221
|
-
* when extension loading is explicitly allowed.
|
|
222
|
+
* when extension loading is explicitly allowed. The actual guard is the shared
|
|
223
|
+
* `assertRelativeExtensionPath` (ADR-010) so schema-time validation here and load-time
|
|
224
|
+
* validation in the shared loader use one source of truth.
|
|
222
225
|
*/
|
|
223
226
|
const relativeExtensionPath = z
|
|
224
227
|
.string()
|
|
225
228
|
.min(1)
|
|
226
|
-
.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
.superRefine((value, ctx) => {
|
|
230
|
+
try {
|
|
231
|
+
assertRelativeExtensionPath(value);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
ctx.addIssue({
|
|
234
|
+
code: 'custom',
|
|
235
|
+
message: error instanceof Error ? error.message : 'invalid extension path',
|
|
236
|
+
});
|
|
237
|
+
}
|
|
231
238
|
});
|
|
232
239
|
|
|
233
240
|
/**
|
|
File without changes
|