@shrkcrft/core 0.1.0-alpha.21 → 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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from './result/result.js';
2
2
  export * from './result/errors.js';
3
3
  export * from './delegate/delegate-recipe.js';
4
+ export * from './wiring/wiring-rule.js';
5
+ export * from './policy/policy-rule.js';
6
+ export * from './reuse/reuse-primitive.js';
4
7
  export * from './logger/log-level.js';
5
8
  export * from './logger/logger.js';
6
9
  export * from './fs/file-system.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from "./result/result.js";
2
2
  export * from "./result/errors.js";
3
3
  export * from "./delegate/delegate-recipe.js";
4
+ export * from "./wiring/wiring-rule.js";
5
+ export * from "./policy/policy-rule.js";
6
+ export * from "./reuse/reuse-primitive.js";
4
7
  export * from "./logger/log-level.js";
5
8
  export * from "./logger/logger.js";
6
9
  export * from "./fs/file-system.js";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Policy-lint rules — the "template/markup/style/ts" plane.
3
+ *
4
+ * Some violations compile AOT-green because they live on surfaces the type
5
+ * checker and structural search can't see: raw markup in `.html` files and
6
+ * inline `template:` strings, stylesheet content, and a handful of
7
+ * AOT-invisible TS shapes. `shrk policy-lint` runs deterministic, data-defined
8
+ * pattern rules over exactly those surfaces.
9
+ *
10
+ * The engine is generic — no framework or project specifics. A project supplies
11
+ * the rules as data via `sharkcraft.config.ts` `policyRules[]` (or a pack); each
12
+ * rule names a surface, a regex, and a human message (optionally a suggested
13
+ * replacement primitive). No AI.
14
+ */
15
+ /** The content surface a rule scans. */
16
+ export type PolicySurface =
17
+ /** `.html` files PLUS inline `template:` strings extracted from source files. */
18
+ 'template'
19
+ /** Stylesheet files (`.css`/`.scss`/`.sass`/`.less`/`.styl`). */
20
+ | 'style'
21
+ /** Source files — for AOT-invisible shapes a project wants to forbid. */
22
+ | 'ts';
23
+ export interface IPolicyRule {
24
+ /** Stable id, surfaced in findings and selectable with `--only`. */
25
+ readonly id: string;
26
+ /** What the rule guards / why it matters. */
27
+ readonly description?: string;
28
+ /** Which surface to scan. */
29
+ readonly surface: PolicySurface;
30
+ /**
31
+ * Project-relative globs. When omitted, a surface-appropriate default is used
32
+ * (`**\/*.html` + inline templates for `template`, common stylesheet
33
+ * extensions for `style`, `**\/*.ts`/`.tsx` for `ts`).
34
+ */
35
+ readonly files?: readonly string[];
36
+ /**
37
+ * Regex source matched against the surface content. Capture group 1, when
38
+ * present, is reported as the offending token; otherwise the whole match is.
39
+ */
40
+ readonly pattern: string;
41
+ /** Extra regex flags combined with the always-on `g` (e.g. `i`, `m`, `s`). */
42
+ readonly flags?: string;
43
+ /** Human message describing the violation. */
44
+ readonly message: string;
45
+ /** Optional remediation — e.g. the primitive/component to use instead. */
46
+ readonly suggest?: string;
47
+ /** `error` (default) fails the check; `warning` reports without failing. */
48
+ readonly severity?: 'error' | 'warning';
49
+ }
50
+ //# sourceMappingURL=policy-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-rule.d.ts","sourceRoot":"","sources":["../../src/policy/policy-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,wCAAwC;AACxC,MAAM,MAAM,aAAa;AACvB,iFAAiF;AAC/E,UAAU;AACZ,iEAAiE;GAC/D,OAAO;AACT,yEAAyE;GACvE,IAAI,CAAC;AAET,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Policy-lint rules — the "template/markup/style/ts" plane.
3
+ *
4
+ * Some violations compile AOT-green because they live on surfaces the type
5
+ * checker and structural search can't see: raw markup in `.html` files and
6
+ * inline `template:` strings, stylesheet content, and a handful of
7
+ * AOT-invisible TS shapes. `shrk policy-lint` runs deterministic, data-defined
8
+ * pattern rules over exactly those surfaces.
9
+ *
10
+ * The engine is generic — no framework or project specifics. A project supplies
11
+ * the rules as data via `sharkcraft.config.ts` `policyRules[]` (or a pack); each
12
+ * rule names a surface, a regex, and a human message (optionally a suggested
13
+ * replacement primitive). No AI.
14
+ */
15
+ export {};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Reuse primitives — the "use the existing thing" plane.
3
+ *
4
+ * The single most-violated rule in many large codebases is "reuse the canonical
5
+ * primitive instead of re-implementing it." An agent told to discover the
6
+ * primitive by `grep` / reading a barrel file structurally cannot: the symbol
7
+ * name it needs isn't in the barrel text (a barrel is `export *`), and deep
8
+ * utilities sit many levels down, ungreppable.
9
+ *
10
+ * `shrk reuse <intent>` closes that gap. A project declares its canonical
11
+ * primitives as data via `sharkcraft.config.ts` `reusePrimitives[]`, keyed by
12
+ * role/intent. The command matches the intent to a primitive, then uses the
13
+ * code graph to resolve the symbol to its real declaration, its sibling
14
+ * exports, and real consumer files to copy. For the public import path it uses
15
+ * the configured `importPath`; if omitted, it surfaces a re-exporting barrel as
16
+ * a hint (it never fabricates a module specifier from a deep file path).
17
+ *
18
+ * The registry is generic — no project specifics live in shrk. No AI.
19
+ */
20
+ export interface IReusePrimitive {
21
+ /** The canonical exported symbol to reuse (e.g. `Button`, `useDebounce`). */
22
+ readonly symbol: string;
23
+ /**
24
+ * Role / intent labels this primitive satisfies. `shrk reuse "<intent>"`
25
+ * matches the query tokens against these (plus `keywords`, `symbol`,
26
+ * `description`). e.g. `['text input', 'form control']`.
27
+ */
28
+ readonly roles: readonly string[];
29
+ /**
30
+ * The public import specifier consumers should import the symbol FROM
31
+ * (the barrel/package entry, e.g. `@scope/ui`). Strongly recommended: it is
32
+ * the only source of a copy-pasteable import line. When omitted, `shrk reuse`
33
+ * shows the declaration site and a re-exporting barrel hint instead.
34
+ */
35
+ readonly importPath?: string;
36
+ /** One-line description of when to reach for this primitive. */
37
+ readonly description?: string;
38
+ /** Extra free-text keywords to widen intent matching. */
39
+ readonly keywords?: readonly string[];
40
+ }
41
+ //# sourceMappingURL=reuse-primitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuse-primitive.d.ts","sourceRoot":"","sources":["../../src/reuse/reuse-primitive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Reuse primitives — the "use the existing thing" plane.
3
+ *
4
+ * The single most-violated rule in many large codebases is "reuse the canonical
5
+ * primitive instead of re-implementing it." An agent told to discover the
6
+ * primitive by `grep` / reading a barrel file structurally cannot: the symbol
7
+ * name it needs isn't in the barrel text (a barrel is `export *`), and deep
8
+ * utilities sit many levels down, ungreppable.
9
+ *
10
+ * `shrk reuse <intent>` closes that gap. A project declares its canonical
11
+ * primitives as data via `sharkcraft.config.ts` `reusePrimitives[]`, keyed by
12
+ * role/intent. The command matches the intent to a primitive, then uses the
13
+ * code graph to resolve the symbol to its real declaration, its sibling
14
+ * exports, and real consumer files to copy. For the public import path it uses
15
+ * the configured `importPath`; if omitted, it surfaces a re-exporting barrel as
16
+ * a hint (it never fabricates a module specifier from a deep file path).
17
+ *
18
+ * The registry is generic — no project specifics live in shrk. No AI.
19
+ */
20
+ export {};
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Wiring rules — the "completeness plane".
3
+ *
4
+ * Boundary/architecture rules cover the DIRECTION plane: which imports a file
5
+ * may NOT make. Wiring rules cover the complementary COMPLETENESS plane: a
6
+ * value/identifier that is DECLARED in one place must also be REGISTERED
7
+ * (wired up) somewhere else, or the build is green but the feature silently
8
+ * does nothing at runtime ("declared but not wired").
9
+ *
10
+ * A rule is a pure, data-defined set-membership check across files — the same
11
+ * extraction the boundary engine runs, but over captured string tokens instead
12
+ * of import paths. Each rule:
13
+ * - collects the DECLARED token set (capture group 1 of `declared.pattern`
14
+ * over the files matching `declared.files`), and
15
+ * - the REGISTERED token set (likewise from `registered`), then
16
+ * - flags every declared token that is NOT in the registered set.
17
+ *
18
+ * The engine is generic and deterministic (no AI, no language-specific
19
+ * knowledge). Projects supply the rules as data via
20
+ * `sharkcraft.config.ts` `wiringRules[]` (or a pack), so the engine never
21
+ * hard-codes any project-specific identifier.
22
+ */
23
+ /** One side (declared or registered) of a wiring rule: where to look + what to capture. */
24
+ export interface IWiringSource {
25
+ /** Project-relative globs selecting the files to scan (`**`/`*`/`?` supported). */
26
+ readonly files: readonly string[];
27
+ /**
28
+ * Regex source. Capture group 1 is the token. Matched per-file with the `g`
29
+ * flag always applied; add others (e.g. `i`, `m`) via `flags`.
30
+ */
31
+ readonly pattern: string;
32
+ /** Extra regex flags to combine with the always-on `g`. */
33
+ readonly flags?: string;
34
+ }
35
+ export interface IWiringRule {
36
+ /** Stable id, surfaced in findings and usable with `--only`. */
37
+ readonly id: string;
38
+ /** Human-readable description of what the rule guarantees. */
39
+ readonly description?: string;
40
+ /** `error` (default) fails the check / gate; `warning` reports without failing. */
41
+ readonly severity?: 'error' | 'warning';
42
+ /** Tokens that are declared/used and therefore MUST be wired up. */
43
+ readonly declared: IWiringSource;
44
+ /** The registered superset the declared tokens must belong to. */
45
+ readonly registered: IWiringSource;
46
+ /** Remediation hint shown on every violation of this rule. */
47
+ readonly hint?: string;
48
+ }
49
+ //# sourceMappingURL=wiring-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiring-rule.d.ts","sourceRoot":"","sources":["../../src/wiring/wiring-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Wiring rules — the "completeness plane".
3
+ *
4
+ * Boundary/architecture rules cover the DIRECTION plane: which imports a file
5
+ * may NOT make. Wiring rules cover the complementary COMPLETENESS plane: a
6
+ * value/identifier that is DECLARED in one place must also be REGISTERED
7
+ * (wired up) somewhere else, or the build is green but the feature silently
8
+ * does nothing at runtime ("declared but not wired").
9
+ *
10
+ * A rule is a pure, data-defined set-membership check across files — the same
11
+ * extraction the boundary engine runs, but over captured string tokens instead
12
+ * of import paths. Each rule:
13
+ * - collects the DECLARED token set (capture group 1 of `declared.pattern`
14
+ * over the files matching `declared.files`), and
15
+ * - the REGISTERED token set (likewise from `registered`), then
16
+ * - flags every declared token that is NOT in the registered set.
17
+ *
18
+ * The engine is generic and deterministic (no AI, no language-specific
19
+ * knowledge). Projects supply the rules as data via
20
+ * `sharkcraft.config.ts` `wiringRules[]` (or a pack), so the engine never
21
+ * hard-codes any project-specific identifier.
22
+ */
23
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shrkcrft/core",
3
- "version": "0.1.0-alpha.21",
3
+ "version": "0.1.0-alpha.22",
4
4
  "description": "SharkCraft core primitives: Result, AppError, logger, file-system abstraction, path/string/object utils, IDs.",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",