@ai-gui/plugin-physics 0.10.0 → 0.11.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +63 -0
  3. package/package.json +10 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-gui/plugin-physics
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f84cb1d]
8
+ - @ai-gui/core@0.11.1
9
+
10
+ ## 0.11.0
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [58d1b6c]
15
+ - @ai-gui/core@0.11.0
16
+
3
17
  ## 0.10.0
4
18
 
5
19
  ### Minor Changes
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # @ai-gui/plugin-physics
2
+
3
+ Force and vector diagrams for [AIGUI](../../README.md). The plugin claims one `physics` fence and draws the bodies, surfaces, vectors and angles it declares as SVG.
4
+
5
+ It is a drawing, not a simulation. A mechanics lesson needs the picture a textbook draws — a body, the forces on it as labelled arrows, their angles, one force resolved into components. A rigid-body engine gives a teacher no way to label the intermediate quantities, stop at three seconds, or show a force that is in equilibrium and therefore never moves anything. So this takes coordinates and draws them; the numbers are the model's to get right.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ pnpm add @ai-gui/plugin-physics
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { physics, physicsCss } from "@ai-gui/plugin-physics"
17
+ import { AIRenderer } from "@ai-gui/react"
18
+
19
+ <style>{physicsCss}</style>
20
+ <AIRenderer plugins={[physics()]} />
21
+ ```
22
+
23
+ A block on a 30° incline, gravity resolved along it:
24
+
25
+ ```physics
26
+ {"version":1,"title":"斜面上的物块",
27
+ "bodies":[{"at":[0,0],"shape":"box","width":60,"height":40,"rotation":30,"label":"m"}],
28
+ "surfaces":[{"from":[-120,-70],"to":[120,65],"hatch":true}],
29
+ "vectors":[
30
+ {"magnitude":90,"angle":-90,"style":"force","label":"mg"},
31
+ {"magnitude":78,"angle":120,"style":"force","label":"N"},
32
+ {"magnitude":45,"angle":-150,"style":"component","dashed":true,"label":"mg sin θ"}],
33
+ "angles":[{"at":[-120,-70],"from":0,"to":30,"label":"θ = 30°"}]}
34
+ ```
35
+
36
+ `y` increases upwards and angles are counter-clockwise from the positive x axis, because that is how a mechanics problem states them: gravity points at angle `-90`, an incline is `30`. The flip to screen coordinates happens once for the whole drawing, and labels flip back so text stays upright.
37
+
38
+ A vector is given either as `to` (its tip) or as `magnitude` with `angle`. Omit `from` and it starts at the first body. `"style":"component"` with `"dashed":true` is the convention for a resolved component.
39
+
40
+ `hatch` on a surface marks the solid side — the ground, a wall.
41
+
42
+ The same y-up convention is used by [`@ai-gui/plugin-figure`](../plugin-figure), for diagrams whose point is naming the parts.
43
+
44
+ ## API
45
+
46
+ - `physics(options?)` creates the AIGUI plugin.
47
+ - `physicsPromptSpec(options?)` returns the model-facing protocol description.
48
+ - `parsePhysicsDiagram(source, options?)` strictly parses and validates a block.
49
+ - `renderPhysicsSVG(diagram, options?)` renders a parsed diagram.
50
+ - `physicsCss` contains the package styling.
51
+
52
+ ## Options
53
+
54
+ - `width?: number`: the rendered maximum width in px, default `460`.
55
+ - `height?: number`: the rendered maximum height in px, default `340`.
56
+ - `maxElements?: number`: per element list, default `40`.
57
+ - `maxSourceBytes?: number`: default 8 KiB.
58
+
59
+ Unknown fields, URLs, non-finite coordinates, unknown shapes and vector styles, and oversized blocks are rejected, and the block renders an error in place rather than a confident drawing of something the model did not mean.
60
+
61
+ Colours come from `currentColor` and `--aigui-physics-*` custom properties, so a diagram on a dark page is not drawn in ink chosen for a light one. Output is marked `trusted` because it is built from coordinates rather than from model markup; a sanitizer would otherwise strip the drawing.
62
+
63
+ There is no runtime dependency beyond `@ai-gui/core`.
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@ai-gui/plugin-physics",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Force and vector diagrams for teaching mechanics, rendered as SVG from a declarative block.",
5
5
  "keywords": [
6
6
  "llm",
7
7
  "ai",
8
- "chemistry",
9
- "molecule",
10
- "smiles",
11
- "molfile",
12
- "3d",
8
+ "physics",
9
+ "mechanics",
10
+ "free-body",
11
+ "vector",
12
+ "diagram",
13
+ "svg",
14
+ "teaching",
13
15
  "plugin",
14
16
  "aigui"
15
17
  ],
@@ -18,7 +20,7 @@
18
20
  "repository": {
19
21
  "type": "git",
20
22
  "url": "git+https://github.com/liliang-cn/aigui.git",
21
- "directory": "packages/plugin-molecule"
23
+ "directory": "packages/plugin-physics"
22
24
  },
23
25
  "homepage": "https://github.com/liliang-cn/aigui#readme",
24
26
  "bugs": "https://github.com/liliang-cn/aigui/issues",
@@ -52,7 +54,7 @@
52
54
  "access": "public"
53
55
  },
54
56
  "dependencies": {
55
- "@ai-gui/core": "0.10.0"
57
+ "@ai-gui/core": "0.11.1"
56
58
  },
57
59
  "scripts": {
58
60
  "build": "tsdown",