@plures/praxis 1.3.0 → 1.4.4

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.
Files changed (74) hide show
  1. package/dist/browser/{chunk-N63K4KWS.js → chunk-4IRUGWR3.js} +1 -1
  2. package/dist/browser/chunk-6SJ44Q64.js +473 -0
  3. package/dist/browser/chunk-BQOYZBWA.js +282 -0
  4. package/dist/browser/chunk-IG5BJ2MT.js +91 -0
  5. package/dist/browser/{chunk-MJK3IYTJ.js → chunk-JZDJU2DO.js} +4 -84
  6. package/dist/browser/chunk-ZEW4LJAJ.js +353 -0
  7. package/dist/browser/{engine-YIEGSX7U.js → engine-3B5WJPGT.js} +2 -1
  8. package/dist/browser/expectations/index.d.ts +180 -0
  9. package/dist/browser/expectations/index.js +14 -0
  10. package/dist/browser/factory/index.d.ts +149 -0
  11. package/dist/browser/factory/index.js +15 -0
  12. package/dist/browser/index.d.ts +274 -3
  13. package/dist/browser/index.js +407 -54
  14. package/dist/browser/integrations/svelte.d.ts +3 -2
  15. package/dist/browser/integrations/svelte.js +3 -2
  16. package/dist/browser/project/index.d.ts +176 -0
  17. package/dist/browser/project/index.js +19 -0
  18. package/dist/browser/reactive-engine.svelte-DgVTqHLc.d.ts +223 -0
  19. package/dist/browser/{reactive-engine.svelte-DjynI82A.d.ts → rules-i1LHpnGd.d.ts} +13 -221
  20. package/dist/node/chunk-2IUFZBH3.js +87 -0
  21. package/dist/node/{chunk-WZ6B3LZ6.js → chunk-7CSWBDFL.js} +3 -56
  22. package/dist/node/chunk-AZLNISFI.js +1690 -0
  23. package/dist/node/chunk-IG5BJ2MT.js +91 -0
  24. package/dist/node/{chunk-KMJWAFZV.js → chunk-JZDJU2DO.js} +4 -89
  25. package/dist/node/chunk-PGVSB6NR.js +59 -0
  26. package/dist/node/{chunk-5JQJZADT.js → chunk-ZO2LU4G4.js} +4 -4
  27. package/dist/node/cli/index.cjs +1126 -211
  28. package/dist/node/cli/index.js +21 -2
  29. package/dist/node/{engine-FEN5IYZ5.js → engine-VFHCIEM4.js} +2 -1
  30. package/dist/node/index.cjs +5623 -2765
  31. package/dist/node/index.d.cts +1181 -1
  32. package/dist/node/index.d.ts +1181 -1
  33. package/dist/node/index.js +1646 -79
  34. package/dist/node/integrations/svelte.js +4 -3
  35. package/dist/node/{reverse-W7THPV45.js → reverse-YD3CWIGM.js} +3 -2
  36. package/dist/node/rules-4DAJ4Z4N.js +7 -0
  37. package/dist/node/server-FKLVY57V.js +363 -0
  38. package/dist/node/{validate-EN3M4FUR.js → validate-5PSWJTIC.js} +5 -3
  39. package/package.json +50 -3
  40. package/src/__tests__/chronos-project.test.ts +799 -0
  41. package/src/__tests__/decision-ledger.test.ts +857 -402
  42. package/src/__tests__/expectations.test.ts +364 -0
  43. package/src/__tests__/factory.test.ts +426 -0
  44. package/src/__tests__/mcp-server.test.ts +310 -0
  45. package/src/__tests__/project.test.ts +396 -0
  46. package/src/chronos/diff.ts +336 -0
  47. package/src/chronos/hooks.ts +227 -0
  48. package/src/chronos/index.ts +83 -0
  49. package/src/chronos/project-chronicle.ts +198 -0
  50. package/src/chronos/timeline.ts +152 -0
  51. package/src/cli/index.ts +28 -0
  52. package/src/decision-ledger/analyzer-types.ts +280 -0
  53. package/src/decision-ledger/analyzer.ts +518 -0
  54. package/src/decision-ledger/contract-verification.ts +456 -0
  55. package/src/decision-ledger/derivation.ts +158 -0
  56. package/src/decision-ledger/index.ts +59 -0
  57. package/src/decision-ledger/report.ts +378 -0
  58. package/src/decision-ledger/suggestions.ts +287 -0
  59. package/src/expectations/expectations.ts +471 -0
  60. package/src/expectations/index.ts +29 -0
  61. package/src/expectations/types.ts +95 -0
  62. package/src/factory/factory.ts +634 -0
  63. package/src/factory/index.ts +27 -0
  64. package/src/factory/types.ts +64 -0
  65. package/src/index.browser.ts +83 -0
  66. package/src/index.ts +134 -0
  67. package/src/mcp/index.ts +33 -0
  68. package/src/mcp/server.ts +485 -0
  69. package/src/mcp/types.ts +161 -0
  70. package/src/project/index.ts +31 -0
  71. package/src/project/project.ts +423 -0
  72. package/src/project/types.ts +87 -0
  73. package/dist/node/chunk-PTH6MD6P.js +0 -487
  74. /package/dist/node/{chunk-R2PSBPKQ.js → chunk-TEMFJOIH.js} +0 -0
@@ -0,0 +1,91 @@
1
+ // src/core/rule-result.ts
2
+ var RuleResult = class _RuleResult {
3
+ /** The kind of result */
4
+ kind;
5
+ /** Facts produced (only for 'emit') */
6
+ facts;
7
+ /** Fact tags to retract (only for 'retract') */
8
+ retractTags;
9
+ /** Optional reason (for noop/skip/retract — useful for debugging) */
10
+ reason;
11
+ /** The rule ID that produced this result (set by engine) */
12
+ ruleId;
13
+ constructor(kind, facts, retractTags, reason) {
14
+ this.kind = kind;
15
+ this.facts = facts;
16
+ this.retractTags = retractTags;
17
+ this.reason = reason;
18
+ }
19
+ /**
20
+ * Rule produced facts.
21
+ *
22
+ * @example
23
+ * return RuleResult.emit([
24
+ * { tag: 'sprint.behind', payload: { deficit: 5 } }
25
+ * ]);
26
+ */
27
+ static emit(facts) {
28
+ if (facts.length === 0) {
29
+ throw new Error(
30
+ "RuleResult.emit() requires at least one fact. Use RuleResult.noop() or RuleResult.skip() when a rule has nothing to say."
31
+ );
32
+ }
33
+ return new _RuleResult("emit", facts, []);
34
+ }
35
+ /**
36
+ * Rule evaluated but had nothing to report.
37
+ * Unlike returning [], this is explicit and traceable.
38
+ *
39
+ * @example
40
+ * if (ctx.completedHours >= expectedHours) {
41
+ * return RuleResult.noop('Sprint is on pace');
42
+ * }
43
+ */
44
+ static noop(reason) {
45
+ return new _RuleResult("noop", [], [], reason);
46
+ }
47
+ /**
48
+ * Rule decided to skip because preconditions were not met.
49
+ * Distinct from noop: skip means "I can't evaluate", noop means "I evaluated and found nothing".
50
+ *
51
+ * @example
52
+ * if (!ctx.sprintName) {
53
+ * return RuleResult.skip('No active sprint');
54
+ * }
55
+ */
56
+ static skip(reason) {
57
+ return new _RuleResult("skip", [], [], reason);
58
+ }
59
+ /**
60
+ * Rule retracts previously emitted facts by tag.
61
+ * Used when a condition that previously produced facts is no longer true.
62
+ *
63
+ * @example
64
+ * // Sprint was behind, but caught up
65
+ * if (ctx.completedHours >= expectedHours) {
66
+ * return RuleResult.retract(['sprint.behind'], 'Sprint caught up');
67
+ * }
68
+ */
69
+ static retract(tags, reason) {
70
+ if (tags.length === 0) {
71
+ throw new Error("RuleResult.retract() requires at least one tag.");
72
+ }
73
+ return new _RuleResult("retract", [], tags, reason);
74
+ }
75
+ /** Whether this result produced facts */
76
+ get hasFacts() {
77
+ return this.facts.length > 0;
78
+ }
79
+ /** Whether this result retracts facts */
80
+ get hasRetractions() {
81
+ return this.retractTags.length > 0;
82
+ }
83
+ };
84
+ function fact(tag, payload) {
85
+ return { tag, payload };
86
+ }
87
+
88
+ export {
89
+ RuleResult,
90
+ fact
91
+ };
@@ -1,93 +1,10 @@
1
+ import {
2
+ RuleResult
3
+ } from "./chunk-IG5BJ2MT.js";
4
+
1
5
  // src/core/protocol.ts
2
6
  var PRAXIS_PROTOCOL_VERSION = "1.0.0";
3
7
 
4
- // src/core/rule-result.ts
5
- var RuleResult = class _RuleResult {
6
- /** The kind of result */
7
- kind;
8
- /** Facts produced (only for 'emit') */
9
- facts;
10
- /** Fact tags to retract (only for 'retract') */
11
- retractTags;
12
- /** Optional reason (for noop/skip/retract — useful for debugging) */
13
- reason;
14
- /** The rule ID that produced this result (set by engine) */
15
- ruleId;
16
- constructor(kind, facts, retractTags, reason) {
17
- this.kind = kind;
18
- this.facts = facts;
19
- this.retractTags = retractTags;
20
- this.reason = reason;
21
- }
22
- /**
23
- * Rule produced facts.
24
- *
25
- * @example
26
- * return RuleResult.emit([
27
- * { tag: 'sprint.behind', payload: { deficit: 5 } }
28
- * ]);
29
- */
30
- static emit(facts) {
31
- if (facts.length === 0) {
32
- throw new Error(
33
- "RuleResult.emit() requires at least one fact. Use RuleResult.noop() or RuleResult.skip() when a rule has nothing to say."
34
- );
35
- }
36
- return new _RuleResult("emit", facts, []);
37
- }
38
- /**
39
- * Rule evaluated but had nothing to report.
40
- * Unlike returning [], this is explicit and traceable.
41
- *
42
- * @example
43
- * if (ctx.completedHours >= expectedHours) {
44
- * return RuleResult.noop('Sprint is on pace');
45
- * }
46
- */
47
- static noop(reason) {
48
- return new _RuleResult("noop", [], [], reason);
49
- }
50
- /**
51
- * Rule decided to skip because preconditions were not met.
52
- * Distinct from noop: skip means "I can't evaluate", noop means "I evaluated and found nothing".
53
- *
54
- * @example
55
- * if (!ctx.sprintName) {
56
- * return RuleResult.skip('No active sprint');
57
- * }
58
- */
59
- static skip(reason) {
60
- return new _RuleResult("skip", [], [], reason);
61
- }
62
- /**
63
- * Rule retracts previously emitted facts by tag.
64
- * Used when a condition that previously produced facts is no longer true.
65
- *
66
- * @example
67
- * // Sprint was behind, but caught up
68
- * if (ctx.completedHours >= expectedHours) {
69
- * return RuleResult.retract(['sprint.behind'], 'Sprint caught up');
70
- * }
71
- */
72
- static retract(tags, reason) {
73
- if (tags.length === 0) {
74
- throw new Error("RuleResult.retract() requires at least one tag.");
75
- }
76
- return new _RuleResult("retract", [], tags, reason);
77
- }
78
- /** Whether this result produced facts */
79
- get hasFacts() {
80
- return this.facts.length > 0;
81
- }
82
- /** Whether this result retracts facts */
83
- get hasRetractions() {
84
- return this.retractTags.length > 0;
85
- }
86
- };
87
- function fact(tag, payload) {
88
- return { tag, payload };
89
- }
90
-
91
8
  // src/core/engine.ts
92
9
  function safeClone(value) {
93
10
  if (value === null || typeof value !== "object") {
@@ -382,8 +299,6 @@ function createPraxisEngine(options) {
382
299
 
383
300
  export {
384
301
  PRAXIS_PROTOCOL_VERSION,
385
- RuleResult,
386
- fact,
387
302
  LogicEngine,
388
303
  createPraxisEngine
389
304
  };
@@ -0,0 +1,59 @@
1
+ // src/decision-ledger/types.ts
2
+ function isContract(obj) {
3
+ if (typeof obj !== "object" || obj === null) {
4
+ return false;
5
+ }
6
+ const contract = obj;
7
+ return typeof contract.ruleId === "string" && typeof contract.behavior === "string" && Array.isArray(contract.examples) && contract.examples.length > 0 && contract.examples.every(
8
+ (ex) => typeof ex === "object" && ex !== null && typeof ex.given === "string" && typeof ex.when === "string" && typeof ex.then === "string"
9
+ ) && Array.isArray(contract.invariants) && contract.invariants.every((inv) => typeof inv === "string");
10
+ }
11
+ function defineContract(options) {
12
+ if (options.examples.length === 0) {
13
+ throw new Error("Contract must have at least one example");
14
+ }
15
+ if (options.assumptions) {
16
+ for (const assumption of options.assumptions) {
17
+ if (assumption.confidence < 0 || assumption.confidence > 1) {
18
+ throw new Error(
19
+ `Assumption '${assumption.id}' has invalid confidence value ${assumption.confidence}. Must be between 0.0 and 1.0`
20
+ );
21
+ }
22
+ }
23
+ }
24
+ return {
25
+ ruleId: options.ruleId,
26
+ behavior: options.behavior,
27
+ examples: options.examples,
28
+ invariants: options.invariants,
29
+ assumptions: options.assumptions,
30
+ references: options.references,
31
+ version: options.version || "1.0.0",
32
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
33
+ };
34
+ }
35
+ function getContract(meta) {
36
+ if (!meta || !meta.contract) {
37
+ return void 0;
38
+ }
39
+ if (isContract(meta.contract)) {
40
+ return meta.contract;
41
+ }
42
+ return void 0;
43
+ }
44
+ function getContractFromDescriptor(descriptor) {
45
+ if (!descriptor) {
46
+ return void 0;
47
+ }
48
+ if (descriptor.contract && isContract(descriptor.contract)) {
49
+ return descriptor.contract;
50
+ }
51
+ return getContract(descriptor.meta);
52
+ }
53
+
54
+ export {
55
+ isContract,
56
+ defineContract,
57
+ getContract,
58
+ getContractFromDescriptor
59
+ };
@@ -1,9 +1,9 @@
1
- import {
2
- PraxisRegistry
3
- } from "./chunk-R2PSBPKQ.js";
4
1
  import {
5
2
  createPraxisEngine
6
- } from "./chunk-KMJWAFZV.js";
3
+ } from "./chunk-JZDJU2DO.js";
4
+ import {
5
+ PraxisRegistry
6
+ } from "./chunk-TEMFJOIH.js";
7
7
 
8
8
  // src/core/reactive-engine.svelte.ts
9
9
  import * as $ from "svelte/internal/client";