plainstamp 0.7.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -16,6 +16,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
16
16
 
17
17
  Distribution is **npm-only**. Source remains in the operating organization's private repository; there is no public source repository host. Contact channel for issues, accuracy reports, security reports, and contribution proposals is **helpfulbutton140@agentmail.to** (see `docs/CONTRIBUTING.md`, `docs/SECURITY.md`).
18
18
 
19
+ ## [0.7.1] — 2026-05-08
20
+
21
+ ### Fixed (cross-runtime compatibility)
22
+
23
+ - New `setBundledRules(parsed)` export: allows non-Node consumers (Cloudflare Workers, Deno Deploy, browsers) to pre-load the bundled rules object explicitly, avoiding the `node:fs` + `import.meta.url` path that fails in those environments. The recommended pattern is to import the JSON directly: `import rulesJson from "plainstamp/rules/seed.json"; setBundledRules(rulesJson);`. Once the override is set, all of `disclosuresFor`, `executeMcpTool`, `getRuleById`, `listJurisdictions`, etc. work unchanged.
24
+ - The Node fs path is unchanged for Node consumers; this is a strictly additive fix.
25
+
19
26
  ## [0.7.0] — 2026-05-08
20
27
 
21
28
  ### Added (transport-independent MCP tool module)
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { lookup, generateDisclosureText, validateDisclosure, } from "./lookup.js";
2
- export { loadBundledRules, loadRulesFromPath } from "./rules-loader.js";
2
+ export { loadBundledRules, loadRulesFromPath, setBundledRules, } from "./rules-loader.js";
3
3
  export { computeCoverageMatrix, renderCoverageMarkdown, renderCoverageCsv, type CoverageMatrix, type CoverageCell, } from "./coverage.js";
4
4
  export type { DisclosureRuleT, RuleSetT, LookupQueryT, LookupResultT, ChannelT, UseCaseT, SeverityT, JurisdictionIdT, DisclosureElementT, } from "./schema.js";
5
5
  export { Channel, UseCase, Severity, JurisdictionId, LookupQuery, DisclosureElement, DisclosureRule, RuleSet, } from "./schema.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,EAAE,CAEnE;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAK5C;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,MAAM;;;;;IAKtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,EAAE,CAEnE;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAK5C;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,MAAM;;;;;IAKtB"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { lookup, generateDisclosureText, validateDisclosure, } from "./lookup.js";
2
- export { loadBundledRules, loadRulesFromPath } from "./rules-loader.js";
2
+ export { loadBundledRules, loadRulesFromPath, setBundledRules, } from "./rules-loader.js";
3
3
  export { computeCoverageMatrix, renderCoverageMarkdown, renderCoverageCsv, } from "./coverage.js";
4
4
  export { Channel, UseCase, Severity, JurisdictionId, LookupQuery, DisclosureElement, DisclosureRule, RuleSet, } from "./schema.js";
5
5
  export { mcpTools, executeMcpTool, } from "./mcp-tools.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,cAAc,GAGf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,kBAAkB,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAGnF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAmB;IAChD,OAAO,QAAQ,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB;IAC/B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,uDAAuD;AACvD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gBAAgB,EAAE,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB;IAC/B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAmB,EACnB,aAAqB;IAErB,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AAClE,CAAC"}
@@ -1,8 +1,30 @@
1
1
  import { type RuleSetT } from "./schema.js";
2
2
  /**
3
- * Loads and validates the bundled seed rules. Throws on schema violation
4
- * an invalid rules file is a hard failure because the product's correctness
5
- * depends on it.
3
+ * Provide the bundled rules object explicitly. Useful in environments
4
+ * where `import.meta.url`-based filesystem reads are unavailable or
5
+ * unreliable (Cloudflare Workers, Deno Deploy, browsers): the caller
6
+ * imports `plainstamp/rules/seed.json` directly and hands the parsed
7
+ * object to this function before any other plainstamp lookup.
8
+ *
9
+ * Idempotent. Calling with `null` clears the override.
10
+ *
11
+ * @example
12
+ * import rulesJson from "plainstamp/rules/seed.json";
13
+ * import { setBundledRules, executeMcpTool } from "plainstamp";
14
+ * setBundledRules(rulesJson);
15
+ */
16
+ export declare function setBundledRules(rules: unknown | null): void;
17
+ /**
18
+ * Loads and validates the bundled seed rules. If `setBundledRules()`
19
+ * has been called, returns that override. Otherwise reads from the
20
+ * package's `rules/seed.json` file via `node:fs` + `import.meta.url`.
21
+ *
22
+ * Throws on schema violation — an invalid rules file is a hard
23
+ * failure because the product's correctness depends on it.
24
+ *
25
+ * In non-Node environments (Workers, browsers), `import.meta.url` may
26
+ * not resolve to a usable path; in that case, callers MUST set the
27
+ * override via `setBundledRules()` before any lookup.
6
28
  */
7
29
  export declare function loadBundledRules(): RuleSetT;
8
30
  /** Loads rules from an arbitrary path. Useful for tests and for callers that maintain their own rules feed. */
@@ -1 +1 @@
1
- {"version":3,"file":"rules-loader.d.ts","sourceRoot":"","sources":["../src/rules-loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIrD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAK3C;AAED,+GAA+G;AAC/G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAIxD"}
1
+ {"version":3,"file":"rules-loader.d.ts","sourceRoot":"","sources":["../src/rules-loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIrD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAE3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,CAO3C;AAED,+GAA+G;AAC/G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAIxD"}
@@ -2,13 +2,40 @@ import { readFileSync } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { dirname, join } from "node:path";
4
4
  import { RuleSet } from "./schema.js";
5
- const here = dirname(fileURLToPath(import.meta.url));
5
+ let bundledRulesOverride = null;
6
6
  /**
7
- * Loads and validates the bundled seed rules. Throws on schema violation
8
- * an invalid rules file is a hard failure because the product's correctness
9
- * depends on it.
7
+ * Provide the bundled rules object explicitly. Useful in environments
8
+ * where `import.meta.url`-based filesystem reads are unavailable or
9
+ * unreliable (Cloudflare Workers, Deno Deploy, browsers): the caller
10
+ * imports `plainstamp/rules/seed.json` directly and hands the parsed
11
+ * object to this function before any other plainstamp lookup.
12
+ *
13
+ * Idempotent. Calling with `null` clears the override.
14
+ *
15
+ * @example
16
+ * import rulesJson from "plainstamp/rules/seed.json";
17
+ * import { setBundledRules, executeMcpTool } from "plainstamp";
18
+ * setBundledRules(rulesJson);
19
+ */
20
+ export function setBundledRules(rules) {
21
+ bundledRulesOverride = rules === null ? null : RuleSet.parse(rules);
22
+ }
23
+ /**
24
+ * Loads and validates the bundled seed rules. If `setBundledRules()`
25
+ * has been called, returns that override. Otherwise reads from the
26
+ * package's `rules/seed.json` file via `node:fs` + `import.meta.url`.
27
+ *
28
+ * Throws on schema violation — an invalid rules file is a hard
29
+ * failure because the product's correctness depends on it.
30
+ *
31
+ * In non-Node environments (Workers, browsers), `import.meta.url` may
32
+ * not resolve to a usable path; in that case, callers MUST set the
33
+ * override via `setBundledRules()` before any lookup.
10
34
  */
11
35
  export function loadBundledRules() {
36
+ if (bundledRulesOverride !== null)
37
+ return bundledRulesOverride;
38
+ const here = dirname(fileURLToPath(import.meta.url));
12
39
  const path = join(here, "..", "rules", "seed.json");
13
40
  const raw = readFileSync(path, "utf-8");
14
41
  const parsed = JSON.parse(raw);
@@ -1 +1 @@
1
- {"version":3,"file":"rules-loader.js","sourceRoot":"","sources":["../src/rules-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA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e,CAAC,KAAqB;IACnD,oBAAoB,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,oBAAoB,KAAK,IAAI;QAAE,OAAO,oBAAoB,CAAC;IAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plainstamp",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "AI disclosure compliance assistant — generates legally-grounded AI disclosure text per (jurisdiction × channel × use-case) and tracks regulatory updates. Operated by an autonomous AI agent under KS Elevated Solutions LLC.",
5
5
  "type": "module",
6
6
  "license": "MIT",