@shrkcrft/config 0.1.0-alpha.20 → 0.1.0-alpha.22

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.
@@ -22,6 +22,50 @@ export declare const SharkCraftConfigSchema: z.ZodObject<{
22
22
  boundaryFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
23
  contextTestFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
24
  agentTestFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ wiringRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ id: z.ZodString;
27
+ description: z.ZodOptional<z.ZodString>;
28
+ severity: z.ZodOptional<z.ZodEnum<{
29
+ error: "error";
30
+ warning: "warning";
31
+ }>>;
32
+ declared: z.ZodObject<{
33
+ files: z.ZodArray<z.ZodString>;
34
+ pattern: z.ZodString;
35
+ flags: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strict>;
37
+ registered: z.ZodObject<{
38
+ files: z.ZodArray<z.ZodString>;
39
+ pattern: z.ZodString;
40
+ flags: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strict>;
42
+ hint: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strict>>>;
44
+ policyRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
45
+ id: z.ZodString;
46
+ description: z.ZodOptional<z.ZodString>;
47
+ surface: z.ZodEnum<{
48
+ template: "template";
49
+ style: "style";
50
+ ts: "ts";
51
+ }>;
52
+ files: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ pattern: z.ZodString;
54
+ flags: z.ZodOptional<z.ZodString>;
55
+ message: z.ZodString;
56
+ suggest: z.ZodOptional<z.ZodString>;
57
+ severity: z.ZodOptional<z.ZodEnum<{
58
+ error: "error";
59
+ warning: "warning";
60
+ }>>;
61
+ }, z.core.$strict>>>;
62
+ reusePrimitives: z.ZodOptional<z.ZodArray<z.ZodObject<{
63
+ symbol: z.ZodString;
64
+ roles: z.ZodArray<z.ZodString>;
65
+ importPath: z.ZodOptional<z.ZodString>;
66
+ description: z.ZodOptional<z.ZodString>;
67
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ }, z.core.$strict>>>;
25
69
  verificationCommands: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
70
  id: z.ZodString;
27
71
  label: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0ExB,CAAC;AAEZ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiHxB;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgFxB,CAAC;AAEZ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -21,6 +21,93 @@ const DelegateRecipeSchema = z
21
21
  verificationIds: z.array(z.string()),
22
22
  })
23
23
  .strict();
24
+ /** One side (declared / registered) of a wiring rule. */
25
+ const WiringSourceSchema = z
26
+ .object({
27
+ files: z.array(z.string()),
28
+ pattern: z.string(),
29
+ flags: z.string().optional(),
30
+ })
31
+ .strict()
32
+ .superRefine((src, ctx) => {
33
+ // Catch a bad regex / bad flags at config-load time (clear field location)
34
+ // rather than at runtime. The engine also degrades gracefully, but this
35
+ // surfaces the typo through `shrk doctor` / the loader.
36
+ let re;
37
+ try {
38
+ re = new RegExp(src.pattern, src.flags ?? '');
39
+ }
40
+ catch (e) {
41
+ ctx.addIssue({
42
+ code: z.ZodIssueCode.custom,
43
+ path: ['pattern'],
44
+ message: `invalid regular expression: ${e.message}`,
45
+ });
46
+ return;
47
+ }
48
+ // Group 1 is the token contract — a pattern with no capture group matches
49
+ // nothing useful and would silently pass.
50
+ try {
51
+ const groups = (new RegExp(re.source + '|').exec('')?.length ?? 1) - 1;
52
+ if (groups < 1) {
53
+ ctx.addIssue({
54
+ code: z.ZodIssueCode.custom,
55
+ path: ['pattern'],
56
+ message: 'pattern must contain at least one capture group (group 1 captures the token)',
57
+ });
58
+ }
59
+ }
60
+ catch {
61
+ // Can't determine group count — don't block.
62
+ }
63
+ });
64
+ /** One wiring/completeness rule (see `IWiringRule`). */
65
+ const WiringRuleSchema = z
66
+ .object({
67
+ id: z.string(),
68
+ description: z.string().optional(),
69
+ severity: z.enum(['error', 'warning']).optional(),
70
+ declared: WiringSourceSchema,
71
+ registered: WiringSourceSchema,
72
+ hint: z.string().optional(),
73
+ })
74
+ .strict();
75
+ /** One policy-lint rule (see `IPolicyRule`). */
76
+ const PolicyRuleSchema = z
77
+ .object({
78
+ id: z.string(),
79
+ description: z.string().optional(),
80
+ surface: z.enum(['template', 'style', 'ts']),
81
+ files: z.array(z.string()).optional(),
82
+ pattern: z.string(),
83
+ flags: z.string().optional(),
84
+ message: z.string(),
85
+ suggest: z.string().optional(),
86
+ severity: z.enum(['error', 'warning']).optional(),
87
+ })
88
+ .strict()
89
+ .superRefine((src, ctx) => {
90
+ try {
91
+ new RegExp(src.pattern, src.flags ?? '');
92
+ }
93
+ catch (e) {
94
+ ctx.addIssue({
95
+ code: z.ZodIssueCode.custom,
96
+ path: ['pattern'],
97
+ message: `invalid regular expression: ${e.message}`,
98
+ });
99
+ }
100
+ });
101
+ /** One reuse primitive (see `IReusePrimitive`). */
102
+ const ReusePrimitiveSchema = z
103
+ .object({
104
+ symbol: z.string(),
105
+ roles: z.array(z.string()),
106
+ importPath: z.string().optional(),
107
+ description: z.string().optional(),
108
+ keywords: z.array(z.string()).optional(),
109
+ })
110
+ .strict();
24
111
  /**
25
112
  * Zod schema for sharkcraft.config.ts. Used by the loader and the doctor to
26
113
  * surface clear errors for malformed configs. We don't replace ISharkCraftConfig
@@ -46,6 +133,12 @@ export const SharkCraftConfigSchema = z
46
133
  boundaryFiles: z.array(z.string()).optional(),
47
134
  contextTestFiles: z.array(z.string()).optional(),
48
135
  agentTestFiles: z.array(z.string()).optional(),
136
+ // Wiring/completeness rules — the "declared but not wired" plane.
137
+ wiringRules: z.array(WiringRuleSchema).optional(),
138
+ // Policy-lint rules — the template/style/ts content plane.
139
+ policyRules: z.array(PolicyRuleSchema).optional(),
140
+ // Reuse primitives — role-keyed canonical symbols for `shrk reuse`.
141
+ reusePrimitives: z.array(ReusePrimitiveSchema).optional(),
49
142
  // Verification commands available to `shrk apply --validate --verification`.
50
143
  verificationCommands: z
51
144
  .array(z.object({
@@ -40,6 +40,24 @@ export interface ISharkCraftConfig {
40
40
  boundaryFiles?: readonly string[];
41
41
  contextTestFiles?: readonly string[];
42
42
  agentTestFiles?: readonly string[];
43
+ /**
44
+ * Wiring/completeness rules — the "declared but not wired" plane. Each rule is
45
+ * a data-defined cross-file set-membership check (a declared token set must be
46
+ * a subset of a registered token set). Run via `shrk check wiring` and the
47
+ * `wiring` quality gate. The engine is generic — projects supply the patterns.
48
+ */
49
+ wiringRules?: readonly IWiringRule[];
50
+ /**
51
+ * Policy-lint rules — the template/style/ts content plane (markup + inline
52
+ * `template:` strings, stylesheets, AOT-invisible TS shapes). Run via
53
+ * `shrk policy-lint`. Generic + deterministic; projects supply the patterns.
54
+ */
55
+ policyRules?: readonly IPolicyRule[];
56
+ /**
57
+ * Reuse primitives — role-keyed canonical symbols surfaced by `shrk reuse
58
+ * <intent>` (resolved through the code graph to import path + consumers).
59
+ */
60
+ reusePrimitives?: readonly IReusePrimitive[];
43
61
  /**
44
62
  * Adaptive surface gating.
45
63
  *
@@ -77,6 +95,10 @@ export interface ISharkCraftConfig {
77
95
  }
78
96
  export type { IDelegateRecipe, IDelegateRecipeMatch } from '@shrkcrft/core';
79
97
  import type { IDelegateRecipe } from '@shrkcrft/core';
98
+ export type { IWiringRule, IWiringSource } from '@shrkcrft/core';
99
+ import type { IWiringRule } from '@shrkcrft/core';
100
+ export type { IPolicyRule, PolicySurface, IReusePrimitive } from '@shrkcrft/core';
101
+ import type { IPolicyRule, IReusePrimitive } from '@shrkcrft/core';
80
102
  /**
81
103
  * Per-recipe override, keyed by recipe id. Lets a project tune a PACK-contributed
82
104
  * recipe (or disable it) without forking it — change the model / verification /
@@ -1 +1 @@
1
- {"version":3,"file":"sharkcraft-config.d.ts","sourceRoot":"","sources":["../src/sharkcraft-config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yDAAyD;IAC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C;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD,eAAO,MAAM,uBAAuB,UAAyC,CAAC;AAC9E,eAAO,MAAM,kBAAkB,UAAqC,CAAC;AACrE,eAAO,MAAM,kBAAkB,UAAqC,CAAC;AACrE,eAAO,MAAM,sBAAsB,UAA6C,CAAC;AACjF,eAAO,MAAM,sBAAsB,UAA6C,CAAC;AACjF,eAAO,MAAM,iBAAiB,UAI7B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAEnF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shrkcrft/config",
3
- "version": "0.1.0-alpha.20",
3
+ "version": "0.1.0-alpha.22",
4
4
  "description": "SharkCraft config loader: sharkcraft.config.ts discovery, defaults, zod-validated schema.",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",
@@ -43,7 +43,7 @@
43
43
  "typecheck": "tsc --noEmit -p tsconfig.json"
44
44
  },
45
45
  "dependencies": {
46
- "@shrkcrft/core": "^0.1.0-alpha.20",
46
+ "@shrkcrft/core": "^0.1.0-alpha.22",
47
47
  "zod": "^3.25.0 || ^4.0.0"
48
48
  },
49
49
  "publishConfig": {