@zh-xx/antu 0.10.0 → 0.12.0

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 (53) hide show
  1. package/README.md +8 -0
  2. package/assets/viewer.html +55 -55
  3. package/bin/antu-mcp.mjs +53 -53
  4. package/bin/antu.mjs +55 -55
  5. package/embed/antu-embed.d.ts +95 -0
  6. package/embed/antu-embed.js +81139 -0
  7. package/examples/agent/fact/1-minimal.en.json +8 -11
  8. package/examples/agent/fact/1-minimal.zh-CN.json +34 -9
  9. package/examples/agent/fact/2-single-actor.en.json +4 -30
  10. package/examples/agent/fact/2-single-actor.zh-CN.json +22 -10
  11. package/examples/agent/fact/{3-groups.en.json → 3-sides.en.json} +9 -9
  12. package/examples/agent/fact/{3-groups.zh-CN.json → 3-sides.zh-CN.json} +9 -9
  13. package/examples/agent/fact/4-one-side-several.en.json +44 -0
  14. package/examples/agent/fact/4-one-side-several.zh-CN.json +44 -0
  15. package/examples/agent/fact/5-duration.en.json +31 -8
  16. package/examples/agent/fact/5-duration.zh-CN.json +31 -8
  17. package/examples/agent/fact/6-sources.en.json +51 -12
  18. package/examples/agent/fact/6-sources.zh-CN.json +51 -12
  19. package/examples/agent/fact/7-undated.en.json +26 -9
  20. package/examples/agent/fact/7-undated.zh-CN.json +26 -9
  21. package/examples/fact/fang-yuan-loan-and-conflict.en.json +7 -66
  22. package/examples/fact/fang-yuan-loan-and-conflict.zh-CN.json +6 -29
  23. package/examples/fact/gym-membership-face-scan.en.json +15 -20
  24. package/examples/fact/gym-membership-face-scan.zh-CN.json +15 -20
  25. package/examples/fact/lin-fang-v-zhao-lei-private-lending.en.json +6 -19
  26. package/examples/fact/lin-fang-v-zhao-lei-private-lending.zh-CN.json +6 -19
  27. package/examples/fact/marketplace-platform-liability.en.json +5 -24
  28. package/examples/fact/marketplace-platform-liability.zh-CN.json +5 -24
  29. package/examples/fact/neighbour-corridor-charging.en.json +3 -25
  30. package/examples/fact/neighbour-corridor-charging.zh-CN.json +3 -25
  31. package/examples/fact/sample-construction-payment.en.json +8 -82
  32. package/examples/fact/sample-construction-payment.zh-CN.json +7 -25
  33. package/examples/fact/sample-four-parties-four-slots.en.json +8 -81
  34. package/examples/fact/sample-four-parties-four-slots.zh-CN.json +5 -22
  35. package/examples/fact/sample-no-groups.en.json +1 -1
  36. package/examples/fact/sample-no-groups.zh-CN.json +1 -1
  37. package/examples/fact/sample-three-slots.en.json +3 -15
  38. package/examples/fact/sample-three-slots.zh-CN.json +3 -15
  39. package/examples/fact/sample-two-actors-one-side.en.json +4 -23
  40. package/examples/fact/sample-two-actors-one-side.zh-CN.json +4 -23
  41. package/examples/fact/sample-two-parties-each-side.en.json +7 -34
  42. package/examples/fact/sample-two-parties-each-side.zh-CN.json +7 -34
  43. package/examples/raw//357/274/2102031/357/274/211/347/244/272/346/260/221/345/210/2352/345/217/267-/345/201/245/350/272/253/346/210/277/345/210/267/350/204/270/345/205/245/345/234/272/346/241/210-/344/270/200/345/256/241.md +1 -1
  44. package/lib/chunks/report-BbG7HCJA.mjs +1462 -0
  45. package/lib/html.d.ts +9 -0
  46. package/lib/html.mjs +1425 -0
  47. package/lib/validate.d.ts +38 -0
  48. package/lib/validate.mjs +1425 -0
  49. package/package.json +17 -2
  50. package/server.json +2 -2
  51. package/spec/agent/fact/guide.md +38 -38
  52. package/examples/agent/fact/4-views.en.json +0 -44
  53. package/examples/agent/fact/4-views.zh-CN.json +0 -44
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zh-xx/antu",
3
- "version": "0.10.0",
4
- "description": "Antu: legal diagrams (fact, procedure, relationship, justification) from JSON, as one offline HTML page. The command line and the MCP server.",
3
+ "version": "0.12.0",
4
+ "description": "Antu: legal diagrams (fact, procedure, relationship, justification) from JSON, as one offline HTML page. The command line, the MCP server, and the entries to embed a diagram in an application.",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "author": "Ji Cheng",
7
7
  "homepage": "https://github.com/zh-xx/Antu",
@@ -26,6 +26,21 @@
26
26
  "antu": "bin/antu.mjs",
27
27
  "antu-mcp": "bin/antu-mcp.mjs"
28
28
  },
29
+ "exports": {
30
+ "./embed": {
31
+ "types": "./embed/antu-embed.d.ts",
32
+ "default": "./embed/antu-embed.js"
33
+ },
34
+ "./validate": {
35
+ "types": "./lib/validate.d.ts",
36
+ "default": "./lib/validate.mjs"
37
+ },
38
+ "./html": {
39
+ "types": "./lib/html.d.ts",
40
+ "default": "./lib/html.mjs"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
29
44
  "engines": {
30
45
  "node": ">=18"
31
46
  },
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/zh-xx/Antu",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.10.0",
9
+ "version": "0.12.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@zh-xx/antu",
14
- "version": "0.10.0",
14
+ "version": "0.12.0",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  }
@@ -19,59 +19,60 @@ scale changes). `date`, `dateEnd` and their precision matter more there: a day-o
19
19
  drawn as the whole day. The same JSON draws in all three; `kind: "chronicle"` or
20
20
  `kind: "scale"` on `layout`, `preview` and `render` shows it.
21
21
 
22
- ## Where an event is drawn is decided by three things
22
+ ## Where an event is drawn
23
23
 
24
- ```
25
- Row (time) the order of the slots array. Earlier in the array = earlier in time.
26
- date is display-only: it never orders or reorders anything.
24
+ Down the page is time: the order of the `slots` array (earlier in the array = earlier in time;
25
+ `date` is display-only and never reorders anything). Across the page are three places: **side 1,
26
+ the axis, side 2** (left, middle, right when vertical). The `groups` list names them: the 1st group
27
+ is side 1, the 2nd is side 2, the 3rd (optional) is the axis.
28
+
29
+ **What the groups split depends on how many parties the diagram has.** Count `actors` first.
30
+
31
+ ### Two or more parties: the groups split the parties
27
32
 
28
- Column (side) groupId decides which side:
29
- the 1st group -> side 1 (left when vertical)
30
- the 2nd group -> side 2 (right when vertical)
31
- the 3rd group or none -> the axis (the middle column)
33
+ Each party says which side it is on, with `groupId` on the **party**: the 1st or the 2nd group,
34
+ never the 3rd. Events carry **no** `groupId`; an event goes where its `actorIds` put it:
32
35
 
33
- Column (lane) actorIds decides the lane:
34
- exactly 1 party -> that party's lane
35
- 2 or more, or none -> the axis
36
+ ```
37
+ actorIds where
38
+ one party that party's side, in that party's column
39
+ several, or none the axis (both sides together, several of one side together,
40
+ or an objective fact)
36
41
  ```
37
42
 
38
- **An event with several parties lands on the axis.** That is a hard rule: it means
39
- "both sides did this" or "this happened objectively", and belongs to neither side.
43
+ See `3-sides` and `4-one-side-several`.
40
44
 
41
- So list in `actorIds` **the party who did it**: "A pays B" is A's act (one party, A's lane); "A and B sign a
45
+ So list in `actorIds` **the party who did it**: "A pays B" is A's act (one party, A's side); "A and B sign a
42
46
  contract" is both's (two parties, the axis). Name the other party in the label or the summary, not in `actorIds`,
43
47
  unless both acted.
44
48
 
45
- ## What a view is
49
+ **Someone on neither side** (the police who came, the ambulance, the court that served a paper) is not a party:
50
+ write the name in the label and leave `actorIds` out. The event goes on the axis.
46
51
 
47
- The same data can be looked at in several ways. A view only changes how the two
48
- rules above are applied. It **never changes the data**:
52
+ Several parties on one side each get their own column, the earlier in `actors` the closer to the axis.
49
53
 
50
- ```json
51
- { "label": "parties side by side", "splitBy": "actor",
52
- "side1": { "label": "Huayuan Trading", "actors": ["a-1"] },
53
- "side2": { "label": "Xincheng Building Materials", "actors": ["a-2"] } }
54
- ```
54
+ ### One party (or none): the groups split the events
55
+
56
+ With a single party there is no "who is on which side", so the two sides sort its acts by kind
57
+ (performed as agreed / departed from it, act / consequence...; choose from the case). The group goes on
58
+ the **event**: the 1st group side 1, the 2nd side 2, the 3rd or none the axis. The party carries no
59
+ `groupId`.
55
60
 
56
- - `splitBy: "actor"`: split by party; `side1` / `side2` say who is on which side;
57
- - `splitBy: "group"`: split by group; no need to name parties;
58
- - `views` may be omitted; the engine then provides a single "all" view.
61
+ There are no views: a `views` field is an error. The chronicle and the time scale use the same three
62
+ places, one lane (or colour) per group.
59
63
 
60
64
  ## One limit: one event per cell
61
65
 
62
66
  **A time point holds at most one event per lane.** Two events in the same lane of the
63
- same slot means that view cannot be drawn, and it disappears from the interface options
64
- (an option that cannot be clicked is noise). `validate` checks the data once and does not call
65
- this an error, since a data set may keep a view that does not fit on purpose; it does list each such
66
- view as a note after "Validation passed", so it never goes unseen. `layout` reports the same views.
67
+ same slot is an error: `validate` reports it with the slot and the two event ids.
67
68
 
68
69
  Three ways to fix it, most common first:
69
70
 
70
71
  1. **Split the time point.** If two things happened at 9:24, one at 9:24:03 and one at
71
72
  9:24:16, make two slots and give each its exact time.
72
- 2. **Add actorIds.** If the two events belong to different parties, add `actorIds` and
73
+ 2. **Check actorIds.** If the two events belong to different parties, name the party who did each, and
73
74
  they fall into different lanes.
74
- 3. **Add groupId.** If they are of different kinds, add `groupId` and they fall on
75
+ 3. **Add groupId** (one party only). If they are of different kinds, add `groupId` and they fall on
75
76
  different sides.
76
77
 
77
78
  After splitting, check again that each slot holds exactly one event.
@@ -80,9 +81,8 @@ After splitting, check again that each slot holds exactly one event.
80
81
 
81
82
  ```
82
83
  validate reports each problem, with the field path and the event id
83
- (e.g. slots[0].events[1] (ev-2)); when it passes, notes any view that
84
- does not fit (not an error, but that view will not be offered)
85
- layout no rendering: how large, which orientation, which views do not fit
84
+ (e.g. slots[0].events[1] (ev-2))
85
+ layout no rendering: how large, which orientation, how many columns per side
86
86
  preview take a screenshot and look: are cards cramped, is the text small,
87
87
  is there too much empty space
88
88
  render produce the self-contained HTML
@@ -117,10 +117,10 @@ diagram looks good. Always run `preview` and look before delivering.
117
117
 
118
118
  Each adds one idea (`<name>.zh-CN.json`, `<name>.en.json`):
119
119
 
120
- - `1-minimal`: two parties, no `groups` (every card on the axis)
121
- - `2-single-actor`: one party
122
- - `3-groups`: `groupId` picks the side
123
- - `4-views`: the same data, two views
120
+ - `1-minimal`: two parties, each on its side
121
+ - `2-single-actor`: one party, its acts split by kind (`groupId` on the events)
122
+ - `3-sides`: two parties: `groupId` on the parties, none on the events
123
+ - `4-one-side-several`: two parties on one side, and an act of both on the axis
124
124
  - `5-duration`: spans and approximate times
125
125
  - `6-sources`: facts traced to sources
126
126
  - `7-undated`: no `date`
@@ -1,44 +0,0 @@
1
- {
2
- "type": "fact",
3
- "specVersion": 1,
4
- "title": "Views: the same data, seen two ways",
5
- "actors": [
6
- { "id": "a-1", "name": "Huayuan Trading" },
7
- { "id": "a-2", "name": "Xincheng Building Materials" }
8
- ],
9
- "groups": [
10
- { "id": "g-1", "label": "Performance as agreed" },
11
- { "id": "g-2", "label": "Deviation from the agreement" }
12
- ],
13
- "views": [
14
- {
15
- "label": "Parties side by side",
16
- "splitBy": "actor",
17
- "side1": { "label": "Huayuan Trading", "actors": ["a-1"] },
18
- "side2": { "label": "Xincheng Building Materials", "actors": ["a-2"] },
19
- "axis": { "label": "Common to both parties" }
20
- },
21
- { "label": "Split by group", "splitBy": "group" },
22
- { "label": "Huayuan Trading only", "splitBy": "actor", "side1": { "actors": ["a-1"] }, "side2": { "actors": [] } }
23
- ],
24
- "slots": [
25
- {
26
- "events": [
27
- { "id": "ev-1", "date": "2023-03-10", "label": "The loan contract is signed",
28
- "actorIds": ["a-1", "a-2"] }
29
- ]
30
- },
31
- {
32
- "events": [
33
- { "id": "ev-2", "date": "2023-03-12", "label": "Huayuan Trading disburses the loan",
34
- "groupId": "g-1", "actorIds": ["a-1"] }
35
- ]
36
- },
37
- {
38
- "events": [
39
- { "id": "ev-3", "date": "2024-03-11", "label": "Xincheng Building Materials fails to repay on time",
40
- "groupId": "g-2", "actorIds": ["a-2"] }
41
- ]
42
- }
43
- ]
44
- }
@@ -1,44 +0,0 @@
1
- {
2
- "type": "fact",
3
- "specVersion": 1,
4
- "title": "视角:同一份数据,两种看法",
5
- "actors": [
6
- { "id": "a-1", "name": "华远贸易" },
7
- { "id": "a-2", "name": "鑫城建材" }
8
- ],
9
- "groups": [
10
- { "id": "g-1", "label": "按约定履行" },
11
- { "id": "g-2", "label": "偏离约定" }
12
- ],
13
- "views": [
14
- {
15
- "label": "双方对照",
16
- "splitBy": "actor",
17
- "side1": { "label": "华远贸易", "actors": ["a-1"] },
18
- "side2": { "label": "鑫城建材", "actors": ["a-2"] },
19
- "axis": { "label": "双方共同" }
20
- },
21
- { "label": "按性质分侧", "splitBy": "group" },
22
- { "label": "只看华远贸易", "splitBy": "actor", "side1": { "actors": ["a-1"] }, "side2": { "actors": [] } }
23
- ],
24
- "slots": [
25
- {
26
- "events": [
27
- { "id": "ev-1", "date": "2023-03-10", "label": "签订借款合同",
28
- "actorIds": ["a-1", "a-2"] }
29
- ]
30
- },
31
- {
32
- "events": [
33
- { "id": "ev-2", "date": "2023-03-12", "label": "华远贸易放款",
34
- "groupId": "g-1", "actorIds": ["a-1"] }
35
- ]
36
- },
37
- {
38
- "events": [
39
- { "id": "ev-3", "date": "2024-03-11", "label": "鑫城建材逾期未还",
40
- "groupId": "g-2", "actorIds": ["a-2"] }
41
- ]
42
- }
43
- ]
44
- }