@rsconcept/rstool 0.1.0 → 0.2.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 (75) hide show
  1. package/README.md +21 -26
  2. package/dist/analysis-JiwOYDKx.d.ts +16 -0
  3. package/dist/common-DxLg3eXX.d.ts +17 -0
  4. package/dist/constituenta-Dnd6iToB.d.ts +36 -0
  5. package/dist/diagnostic-BMYvciz8.d.ts +15 -0
  6. package/dist/evaluation-CCVYH0wA.d.ts +21 -0
  7. package/dist/index.d.ts +12 -15
  8. package/dist/index.js +7 -585
  9. package/dist/mappers/model-adapter.d.ts +18 -23
  10. package/dist/mappers/model-adapter.js +183 -231
  11. package/dist/mappers/model-adapter.js.map +1 -1
  12. package/dist/mappers/schema-adapter.d.ts +16 -18
  13. package/dist/mappers/schema-adapter.js +55 -84
  14. package/dist/mappers/schema-adapter.js.map +1 -1
  15. package/dist/mappers/types.d.ts +15 -16
  16. package/dist/mappers/types.js +16 -17
  17. package/dist/mappers/types.js.map +1 -1
  18. package/dist/model-value-SFAVj0dw.d.ts +35 -0
  19. package/dist/models/analysis.d.ts +2 -18
  20. package/dist/models/analysis.js +1 -1
  21. package/dist/models/common.d.ts +2 -15
  22. package/dist/models/common.js +1 -8
  23. package/dist/models/constituenta.d.ts +2 -38
  24. package/dist/models/constituenta.js +1 -1
  25. package/dist/models/diagnostic.d.ts +2 -17
  26. package/dist/models/diagnostic.js +1 -1
  27. package/dist/models/evaluation.d.ts +2 -23
  28. package/dist/models/evaluation.js +1 -1
  29. package/dist/models/index.d.ts +10 -13
  30. package/dist/models/index.js +4 -491
  31. package/dist/models/model-value.d.ts +2 -37
  32. package/dist/models/model-value.js +1 -1
  33. package/dist/models/rstool-agent.d.ts +2 -36
  34. package/dist/models/rstool-agent.js +90 -477
  35. package/dist/models/rstool-agent.js.map +1 -1
  36. package/dist/models/session.d.ts +2 -29
  37. package/dist/models/session.js +1 -1
  38. package/dist/models/tool-contract.d.ts +2 -33
  39. package/dist/models/tool-contract.js +5 -5
  40. package/dist/models/tool-contract.js.map +1 -1
  41. package/dist/rstool-agent-DkeH5Qml.d.ts +33 -0
  42. package/dist/session/session-store.d.ts +14 -21
  43. package/dist/session/session-store.js +59 -63
  44. package/dist/session/session-store.js.map +1 -1
  45. package/dist/session-BHGCCLfQ.d.ts +24 -0
  46. package/dist/tool-contract-CsGqg_0P.d.ts +30 -0
  47. package/dist/wrapper/client.d.ts +26 -24
  48. package/dist/wrapper/client.js +90 -93
  49. package/dist/wrapper/client.js.map +1 -1
  50. package/dist/wrapper/stdio-wrapper.d.ts +1 -1
  51. package/dist/wrapper/stdio-wrapper.js +166 -664
  52. package/dist/wrapper/stdio-wrapper.js.map +1 -1
  53. package/docs/CONSTITUENTA.md +39 -23
  54. package/docs/DIAGNOSTICS.md +79 -74
  55. package/docs/DOMAIN.md +5 -3
  56. package/docs/GRAMMAR-REF.md +55 -55
  57. package/docs/PORTAL-API.md +7 -10
  58. package/docs/SYNTAX.md +32 -32
  59. package/docs/TYPIFICATION.md +14 -9
  60. package/package.json +8 -7
  61. package/skills/INSTALL.md +35 -0
  62. package/skills/README.md +17 -9
  63. package/skills/rstool-helper/EXAMPLES.md +51 -10
  64. package/skills/rstool-helper/GUIDE.md +133 -0
  65. package/skills/rstool-helper/REFERENCE.md +5 -3
  66. package/skills/rstool-helper/SKILL.md +23 -134
  67. package/dist/index.js.map +0 -1
  68. package/dist/models/analysis.js.map +0 -1
  69. package/dist/models/common.js.map +0 -1
  70. package/dist/models/constituenta.js.map +0 -1
  71. package/dist/models/diagnostic.js.map +0 -1
  72. package/dist/models/evaluation.js.map +0 -1
  73. package/dist/models/index.js.map +0 -1
  74. package/dist/models/model-value.js.map +0 -1
  75. package/dist/models/session.js.map +0 -1
@@ -6,19 +6,16 @@ When an agent needs to **inspect existing** RSForms, OSS, or RSModels persisted
6
6
 
7
7
  - **UI:** `https://portal.acconcept.ru/`
8
8
  - **REST API:** `https://api.portal.acconcept.ru/`
9
- - **Local dev:** path prefix `/api/...`, base URL from `VITE_PORTAL_BACKEND`.
10
9
 
11
10
  ## Path rewrite rules
12
11
 
13
- Drop UI hash query params (`?tab=`, etc.). Keep numeric ids exactly as the UI shows them.
14
-
15
- | Portal UI path | REST target |
16
- |----------------|-------------|
17
- | `/rsforms/:id` | `GET /api/rsforms/:id` (metadata: owner, titles) |
18
- | `/rsforms/:id` (full payload) | `GET /api/rsforms/:id/details` |
19
- | `/rsforms/:id` (a saved version) | `GET /api/library/:id/versions/:version` |
20
- | `/oss/:id` | `GET /api/oss/:id` (and the sibling OSS viewset routes) |
21
- | `/models/:id` | `GET /api/models/:id` (RSModel router) |
12
+ | Portal UI path | REST target |
13
+ | -------------------------------- | ------------------------------------------------------- |
14
+ | `/rsforms/:id` | `GET /api/rsforms/:id` (metadata: owner, titles) |
15
+ | `/rsforms/:id` (full payload) | `GET /api/rsforms/:id/details` |
16
+ | `/rsforms/:id` (a saved version) | `GET /api/library/:id/versions/:version` |
17
+ | `/oss/:id` | `GET /api/oss/:id` (and the sibling OSS viewset routes) |
18
+ | `/models/:id` | `GET /api/models/:id` (RSModel router) |
22
19
 
23
20
  ## OpenAPI
24
21
 
package/docs/SYNTAX.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RSLang syntax reference
2
2
 
3
- Distilled from the Portal help topics under `help-rslang-*`. Use this when constructing or repairing RSLang expressions. For full grammar tokens see `GRAMMAR-REF.md`. For typification rules see `TYPIFICATION.md`.
3
+ Use this when constructing or repairing RSLang expressions. For full grammar tokens see `GRAMMAR-REF.md`. For typification rules see `TYPIFICATION.md`.
4
4
 
5
5
  ## Identifier rules
6
6
 
@@ -17,22 +17,22 @@ Distilled from the Portal help topics under `help-rslang-*`. Use this when const
17
17
 
18
18
  ## Set-theoretic expressions
19
19
 
20
- | Construct | Syntax | Notes |
21
- |-----------|--------|-------|
22
- | Union | `D1 ∪ D2` | |
23
- | Intersection | `D1 ∩ D2` | |
24
- | Difference | `D1 \ D2` | |
25
- | Symmetric difference | `D1 ∆ D2` | |
26
- | Cartesian product | `X1 × X2` | typification: tuple |
27
- | Boolean / power set | `ℬ(X1)` | set of all subsets |
28
- | Tuple | `(a, b, c)` | ordered, n ≥ 2 |
29
- | Enumeration | `{a, b, c}` | unordered, n ≥ 1 |
30
- | Singleton | `bool(a)` ≡ `{a}` | |
31
- | Desingleton | `debool({a})` ≡ `a` | only for one-element sets |
32
- | Sum set | `red(S1)` | union of inner sets; `S1` must be a set of sets |
33
- | Small projection | `pr1((a1, …, an))` | returns `a1` |
34
- | Large projection | `Pr1(S1)` | set of first components of tuples in `S1` |
35
- | Filter | `Fi1[D1](S1)` | subset of `S1` whose first projection ∈ `D1` |
20
+ | Construct | Syntax | Notes |
21
+ | -------------------- | ------------------- | ----------------------------------------------- |
22
+ | Union | `D1 ∪ D2` | |
23
+ | Intersection | `D1 ∩ D2` | |
24
+ | Difference | `D1 \ D2` | |
25
+ | Symmetric difference | `D1 ∆ D2` | |
26
+ | Cartesian product | `X1 × X2` | typification: tuple |
27
+ | Boolean / power set | `ℬ(X1)` | set of all subsets |
28
+ | Tuple | `(a, b, c)` | ordered, n ≥ 2 |
29
+ | Enumeration | `{a, b, c}` | unordered, n ≥ 1 |
30
+ | Singleton | `bool(a)` ≡ `{a}` | |
31
+ | Desingleton | `debool({a})` ≡ `a` | only for one-element sets |
32
+ | Sum set | `red(S1)` | union of inner sets; `S1` must be a set of sets |
33
+ | Small projection | `pr1((a1, …, an))` | returns `a1` |
34
+ | Large projection | `Pr1(S1)` | set of first components of tuples in `S1` |
35
+ | Filter | `Fi1[D1](S1)` | subset of `S1` whose first projection ∈ `D1` |
36
36
 
37
37
  Indices `1` may be any natural number or comma-separated multi-index (`pr1,3((a1, a2, a3, a4)) = (a1, a3)`, `Fi1,2[D1](S1)`).
38
38
 
@@ -40,15 +40,15 @@ Indices `1` may be any natural number or comma-separated multi-index (`pr1,3((a1
40
40
 
41
41
  ### Set-theoretic predicates
42
42
 
43
- | Predicate | Syntax |
44
- |-----------|--------|
45
- | Membership | `ξ ∈ S` |
46
- | Non-membership | `ξ ∉ S` |
47
- | Set equality | `S1 = S2` |
48
- | Set inequality | `S1 ≠ S2` |
49
- | Inclusion | `S1 ⊆ S2` |
43
+ | Predicate | Syntax |
44
+ | ---------------- | --------- |
45
+ | Membership | `ξ ∈ S` |
46
+ | Non-membership | `ξ ∉ S` |
47
+ | Set equality | `S1 = S2` |
48
+ | Set inequality | `S1 ≠ S2` |
49
+ | Inclusion | `S1 ⊆ S2` |
50
50
  | Strict inclusion | `S1 ⊂ S2` |
51
- | Non-inclusion | `S1 ⊄ S2` |
51
+ | Non-inclusion | `S1 ⊄ S2` |
52
52
 
53
53
  ### Arithmetic predicates (typification `Logic`)
54
54
 
@@ -56,9 +56,9 @@ Indices `1` may be any natural number or comma-separated multi-index (`pr1,3((a1
56
56
 
57
57
  ### Connectives
58
58
 
59
- | Connective | Syntax |
60
- |------------|--------|
61
- | Negation | `¬A` |
59
+ | Connective | Syntax |
60
+ | ----------- | ------- |
61
+ | Negation | `¬A` |
62
62
  | Conjunction | `A & B` |
63
63
  | Disjunction | `A ∨ B` |
64
64
  | Implication | `A ⇒ B` |
@@ -68,10 +68,10 @@ The constants `TRUE` and `FALSE` are **not** used inside schema explications.
68
68
 
69
69
  ## Quantifiers
70
70
 
71
- | Form | Syntax |
72
- |------|--------|
73
- | Universal | `∀ξ∈STE (LE(ξ))` |
74
- | Existential | `∃ξ∈STE (LE(ξ))` |
71
+ | Form | Syntax |
72
+ | ------------- | ---------------------------- |
73
+ | Universal | `∀ξ∈STE (LE(ξ))` |
74
+ | Existential | `∃ξ∈STE (LE(ξ))` |
75
75
  | Tuple binding | `∀(ξ1, ξ2)∈STE (LE(ξ1, ξ2))` |
76
76
  | Variable list | `∀ξ1, ξ2 ∈ STE (LE(ξ1, ξ2))` |
77
77
 
@@ -4,14 +4,14 @@ Distilled from `help-rslang-typification`, `help-rslang-expression-structure`, a
4
4
 
5
5
  ## Grades
6
6
 
7
- A genus-structure expression `ξ` has typification (a *structure*) if `ξ ∈ H` holds, where `H` is a valid **grade**. Grades are built recursively:
7
+ A genus-structure expression `ξ` has typification (a _structure_) if `ξ ∈ H` holds, where `H` is a valid **grade**. Grades are built recursively:
8
8
 
9
- | Grade | Form | Notes |
10
- |-------|------|-------|
11
- | Element | `Xi`, `Ci` | grade of an undefined concept's elements |
12
- | Integer | `Z` | grade of integer arithmetic results |
13
- | Tuple of arity n | `(H1 × H2 × … × Hn)` | ordered structured grade |
14
- | Set | `ℬ(H)` | set of values of grade `H` |
9
+ | Grade | Form | Notes |
10
+ | ---------------- | -------------------- | ---------------------------------------- |
11
+ | Element | `Xi`, `Ci` | grade of an undefined concept's elements |
12
+ | Integer | `Z` | grade of integer arithmetic results |
13
+ | Tuple of arity n | `(H1 × H2 × … × Hn)` | ordered structured grade |
14
+ | Set | `ℬ(H)` | set of values of grade `H` |
15
15
 
16
16
  The empty set `∅` has typification `ℬ(R0)` — a set with arbitrary element structure. The radical `R0` ensures it conforms to any element grade in context.
17
17
 
@@ -41,7 +41,6 @@ Template parameterised expressions may contain notations `R1, R2, …` (and `R0`
41
41
  The contract exposes `type: Record<string, unknown> | null` because typifications are JSON-encoded by the analyzer. Useful properties exposed by `@rsconcept/domain` helpers:
42
42
 
43
43
  - `TypeID` enum: `Element`, `Integer`, `Tuple`, `Boolean`, `Logic`, `Functional` — discriminates the top-level shape.
44
- - `TypeClass` enum: `Element`, `Integer`, `Logic`, `Functional`, `Collection` (set / tuple), `Other`.
45
44
  - `TypePath` (sequence of indices) addresses positions inside a tuple-of-sets-of-tuples structure; use `makeTypePath` to construct.
46
45
  - `parseTypeText(...)` parses an ASCII representation `B(X1)`, `(X1×X2)`, etc., into a `Typification`.
47
46
 
@@ -51,6 +50,13 @@ For agents inspecting types from rstool output:
51
50
  2. Use `analysis.type` (object) only as opaque input to `@rsconcept/domain` helpers — do not pattern-match it manually.
52
51
  3. The `valueClass` companion indicates `Value`, `Property` (non-computable membership only), or `Invalid`.
53
52
 
53
+ ## Typification on `S#` vs definition on `D#`
54
+
55
+ - On a **`structure`** (`S#`), `definitionFormal` is read as **typification**. Subexpressions such as `X1×X1` describe **element shape** (here: one pair of base elements).
56
+ - On a **`term`** (`D#`), the same token sequence is a **definition** evaluated in the model. `X1×X1` alone is the Cartesian product — all ordered pairs from `X1` — not the typification of a relation stored in `S#`.
57
+
58
+ Prefer `S#` with `ℬ(X1×X1)` plus `convention` for relations; derive `D#` with `Pr*`, `Fi*`, filters, etc.
59
+
54
60
  ## Forming structures vs. derived structures
55
61
 
56
62
  Forming operations build a new grade:
@@ -72,7 +78,6 @@ Derived structures consume a grade:
72
78
 
73
79
  - Negative integer literals do not exist — use `0 - n`.
74
80
  - `debool(S)` fails if `S` is not a singleton.
75
- - `red(S)` fails unless `S : ℬ(ℬ(H))`.
76
81
  - Tuple projections require the argument to be a tuple of sufficient arity; `pr3((a, b))` is an error.
77
82
  - Filter parameter list arity must match the multi-index in `Fi[...]`.
78
83
  - A radical in the **result expression** of a template is a hard error (`radicalUsage`).
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@rsconcept/rstool",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Agent-facing library for incremental RSForm construction, RSLang analysis, diagnostics, modeling, and evaluation. Wraps @rsconcept/domain with a deterministic session contract and stdio wrapper.",
5
5
  "license": "MIT",
6
6
  "author": "IRBorisov",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/IRBorisov/ConceptPortal",
9
+ "url": "git+https://github.com/IRBorisov/ConceptPortal.git",
10
10
  "directory": "rsconcept/rstool"
11
11
  },
12
12
  "homepage": "https://portal.acconcept.ru",
@@ -33,11 +33,12 @@
33
33
  "import": "./dist/wrapper/client.js"
34
34
  },
35
35
  "./skills/rstool-helper/*": "./skills/rstool-helper/*",
36
+ "./skills/INSTALL.md": "./skills/INSTALL.md",
36
37
  "./docs/*": "./docs/*",
37
38
  "./package.json": "./package.json"
38
39
  },
39
40
  "bin": {
40
- "rstool-wrapper": "./dist/wrapper/stdio-wrapper.js"
41
+ "rstool-wrapper": "dist/wrapper/stdio-wrapper.js"
41
42
  },
42
43
  "files": [
43
44
  "dist",
@@ -48,7 +49,7 @@
48
49
  "LICENSE"
49
50
  ],
50
51
  "scripts": {
51
- "build": "tsup",
52
+ "build": "tsdown",
52
53
  "typecheck": "tsc -p tsconfig.json --noEmit",
53
54
  "test": "vitest run",
54
55
  "wrapper": "tsx src/wrapper/stdio-wrapper.ts",
@@ -64,10 +65,10 @@
64
65
  "@rsconcept/domain": "^1.0.0"
65
66
  },
66
67
  "devDependencies": {
67
- "@types/node": "^24.0.0",
68
- "tsup": "^8.5.0",
68
+ "@types/node": "^25.9.1",
69
+ "tsdown": "^0.22.0",
69
70
  "tsx": "^4.21.0",
70
- "typescript": "^5.9.3",
71
+ "typescript": "^6.0.3",
71
72
  "vitest": "^4.1.5"
72
73
  },
73
74
  "publishConfig": {
@@ -0,0 +1,35 @@
1
+ # Install `rstool-helper` (agent procedure)
2
+
3
+ Use when the user has run `npm install @rsconcept/rstool` and asks to **install** or **enable** the rstool agent skill. The user should not copy files manually.
4
+
5
+ ## Steps
6
+
7
+ 1. Confirm the package exists: `node_modules/@rsconcept/rstool/package.json`.
8
+ 2. Determine the host’s **project skills directory** (where that host loads `SKILL.md` files). Common layouts:
9
+ - `.agents/skills/<skill-name>/SKILL.md`
10
+ - `.cursor/skills/<skill-name>/SKILL.md`
11
+ - Other paths — use the host’s documentation if unsure.
12
+ 3. Create `<skills-dir>/rstool-helper/` if needed.
13
+ 4. Copy **one file** — the package entry skill:
14
+ - **From:** `node_modules/@rsconcept/rstool/skills/rstool-helper/SKILL.md`
15
+ - **To:** `<skills-dir>/rstool-helper/SKILL.md`
16
+ 5. Do **not** copy `GUIDE.md`, `REFERENCE.md`, `EXAMPLES.md`, or `docs/` into the project. The entry skill points at those files under `node_modules/@rsconcept/rstool/`.
17
+ 6. Confirm the destination `SKILL.md` exists and tell the user the skill is ready.
18
+
19
+ ### Example (`.agents/skills` layout)
20
+
21
+ Bash:
22
+
23
+ ```bash
24
+ mkdir -p .agents/skills/rstool-helper
25
+ cp node_modules/@rsconcept/rstool/skills/rstool-helper/SKILL.md .agents/skills/rstool-helper/SKILL.md
26
+ ```
27
+
28
+ PowerShell:
29
+
30
+ ```powershell
31
+ New-Item -ItemType Directory -Force -Path .agents/skills/rstool-helper | Out-Null
32
+ Copy-Item -Force node_modules/@rsconcept/rstool/skills/rstool-helper/SKILL.md .agents/skills/rstool-helper/SKILL.md
33
+ ```
34
+
35
+ Use the equivalent path for your agent host if it does not use `.agents/skills`.
package/skills/README.md CHANGED
@@ -1,15 +1,23 @@
1
- # Agent skills (rstool)
1
+ # Agent skills (`@rsconcept/rstool`)
2
2
 
3
- Versioned copy of agent skills for this package.
3
+ Each skill lives in its own subdirectory: `skills/<skill-name>/SKILL.md` (plus reference files). Shared install steps: `INSTALL.md`.
4
4
 
5
- ## `rstool-helper`
5
+ ## Layout
6
6
 
7
- Teaches agents RS language and the rstool session API. Files:
7
+ | Path | Role |
8
+ | :--- | :--- |
9
+ | `INSTALL.md` | **Agent procedure** after `npm install` |
10
+ | `rstool-helper/SKILL.md` | Thin **entry** skill — copy into the project’s agent skills folder (see `INSTALL.md`) |
11
+ | `rstool-helper/GUIDE.md` | Canonical workflow and language primer |
12
+ | `rstool-helper/REFERENCE.md` | API, stdio, contract |
13
+ | `rstool-helper/EXAMPLES.md` | Worked examples and pitfalls |
14
+ | `../docs/*.md` | Language reference (DOMAIN, SYNTAX, DIAGNOSTICS, …) |
8
15
 
9
- - `rstool-helper/SKILL.md` — entry and workflow
10
- - `rstool-helper/REFERENCE.md` — contract, stdio, grammar pointers
11
- - `rstool-helper/EXAMPLES.md` — runnable patterns
16
+ ## npm workflow
12
17
 
13
- **Also committed for Cursor:** `.agents/skills/rstool-helper/` (same files). When you change this skill, update **both** directories in the same change set so they stay identical.
18
+ 1. `npm install @rsconcept/rstool`
19
+ 2. User asks the agent to install the skill (no manual copy).
20
+ 3. Agent follows `node_modules/@rsconcept/rstool/skills/INSTALL.md`.
21
+ 4. Agent reads `GUIDE.md` and `docs/` from `node_modules/@rsconcept/rstool/` when working.
14
22
 
15
- Contract changes: see `rsconcept/rstool/AGENTS.md` (sync checklist).
23
+ Contract changes: see `AGENTS.md` in this package (sync checklist).
@@ -6,6 +6,10 @@ Install first:
6
6
  npm install @rsconcept/rstool
7
7
  ```
8
8
 
9
+ ## Kinship-lite: structure vs term
10
+
11
+ `S1` carries **typification** `ℬ(X1×X1)` (pairs over people); `D1` is a **definition** `Pr1(S1)` (parents). Do not put `X1×X1` on a `term` — that is the full Cartesian product.
12
+
9
13
  ## In-process
10
14
 
11
15
  ```ts
@@ -19,9 +23,20 @@ tool.addOrUpdateConstituenta(sessionId, {
19
23
  draft: { id: 1, alias: 'X1', cstType: CstType.BASE, definitionFormal: '' }
20
24
  });
21
25
 
22
- // Term referencing base
26
+ // Structure: typification of parent–child pairs (undefined; convention in real schemas)
27
+ tool.addOrUpdateConstituenta(sessionId, {
28
+ draft: {
29
+ id: 2,
30
+ alias: 'S1',
31
+ cstType: CstType.STRUCTURED,
32
+ definitionFormal: 'ℬ(X1×X1)',
33
+ convention: 'Elements are (parent, child) pairs with parent, child ∈ X1.'
34
+ }
35
+ });
36
+
37
+ // Term: derived definition — first projection of S1
23
38
  const { state, diagnostics } = tool.addOrUpdateConstituenta(sessionId, {
24
- draft: { id: 2, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'X1×X1' }
39
+ draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
25
40
  });
26
41
 
27
42
  console.log(state.analysis.success, diagnostics.length);
@@ -32,7 +47,7 @@ tool.analyzeExpression(sessionId, {
32
47
  cstType: CstType.TERM
33
48
  }); // success: false, syntax diagnostics
34
49
 
35
- // Set base binding and evaluate a term
50
+ // Set base binding and evaluate a scratch arithmetic term
36
51
  tool.setConstituentaValue(sessionId, {
37
52
  target: 1,
38
53
  value: { 0: 'zero', 1: 'one' }
@@ -60,11 +75,21 @@ await client.call('addOrUpdateConstituenta', {
60
75
  draft: { id: 1, alias: 'X1', cstType: CstType.BASE, definitionFormal: '' }
61
76
  }
62
77
  });
63
-
64
78
  await client.call('addOrUpdateConstituenta', {
65
79
  sessionId,
66
80
  input: {
67
- draft: { id: 2, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'X1×X1' }
81
+ draft: {
82
+ id: 2,
83
+ alias: 'S1',
84
+ cstType: CstType.STRUCTURED,
85
+ definitionFormal: 'ℬ(X1×X1)'
86
+ }
87
+ }
88
+ });
89
+ await client.call('addOrUpdateConstituenta', {
90
+ sessionId,
91
+ input: {
92
+ draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
68
93
  }
69
94
  });
70
95
 
@@ -92,8 +117,9 @@ Use the returned `sessionId` in subsequent lines:
92
117
 
93
118
  ```json
94
119
  { "id": "2", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 1, "alias": "X1", "cstType": "basic", "definitionFormal": "" } } } }
95
- { "id": "3", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 2, "alias": "D1", "cstType": "term", "definitionFormal": "X1×X1" } } } }
96
- { "id": "4", "method": "listDiagnostics", "params": { "sessionId": "..." } }
120
+ { "id": "3", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 2, "alias": "S1", "cstType": "structure", "definitionFormal": "ℬ(X1×X1)" } } } }
121
+ { "id": "4", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 3, "alias": "D1", "cstType": "term", "definitionFormal": "Pr1(S1)" } } } }
122
+ { "id": "5", "method": "listDiagnostics", "params": { "sessionId": "..." } }
97
123
  ```
98
124
 
99
125
  ## Export a small RSForm session
@@ -111,10 +137,19 @@ tool.addOrUpdateConstituenta(sessionId, {
111
137
  draft: { id: 2, alias: 'C1', cstType: CstType.CONSTANT, definitionFormal: '' }
112
138
  });
113
139
  tool.addOrUpdateConstituenta(sessionId, {
114
- draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'X1×X1' }
140
+ draft: {
141
+ id: 3,
142
+ alias: 'S1',
143
+ cstType: CstType.STRUCTURED,
144
+ definitionFormal: 'ℬ(X1×X1)',
145
+ convention: 'Pairs (parent, child) over X1.'
146
+ }
147
+ });
148
+ tool.addOrUpdateConstituenta(sessionId, {
149
+ draft: { id: 4, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
115
150
  });
116
151
  tool.addOrUpdateConstituenta(sessionId, {
117
- draft: { id: 4, alias: 'A1', cstType: CstType.AXIOM, definitionFormal: '1=1' }
152
+ draft: { id: 5, alias: 'A1', cstType: CstType.AXIOM, definitionFormal: '1=1' }
118
153
  });
119
154
 
120
155
  const payload = tool.exportSession(sessionId);
@@ -123,6 +158,10 @@ console.log(payload);
123
158
 
124
159
  ## Model and evaluation
125
160
 
161
+ Full kinship modeling (`S1` values as tuples, `Pr1(S1)`, …): `examples/build-kinship-rsmodel.ts`.
162
+
163
+ Minimal evaluation after bindings:
164
+
126
165
  ```ts
127
166
  tool.setConstituentaValue(sessionId, {
128
167
  target: 1,
@@ -130,7 +169,7 @@ tool.setConstituentaValue(sessionId, {
130
169
  });
131
170
 
132
171
  const evaluated = tool.evaluateConstituenta(sessionId, {
133
- constituentId: 3
172
+ constituentId: 4 // D1 = Pr1(S1); needs S1 interpreted — see kinship example
134
173
  });
135
174
  console.log(evaluated.success, evaluated.value);
136
175
  ```
@@ -143,6 +182,8 @@ console.log(evaluated.success, evaluated.value);
143
182
  | `D1` uses `D2` before `D2` exists | globalNotTyped / undeclared global |
144
183
  | `analyzeExpression` with wrong `cstType` | Role-specific semantic errors |
145
184
  | Non-empty formal on `C1` (`constant`) | Same as basic — definition not allowed |
185
+ | `term` with `X1×X1` when modeling a **relation** | Full Cartesian product instead of typed pairs in `S#` |
186
+ | `structure` with `Pr1(S1)` instead of a grade | Wrong role — projections belong on `term` / `F#` |
146
187
  | `setConstituentaValue` on inferrable `D1` (`term`) | Error: inferrable and cannot be set directly |
147
188
  | Evaluating before base binding set | May fail or return empty depending on expression |
148
189
 
@@ -0,0 +1,133 @@
1
+ # RS Language & rstool — Compact Guide for Agents
2
+
3
+ **RS language** is a formal scheme notation for concepts, relations, operations—extends FOL, core: membership `x∈y`; typification via set-theoretic/logical expressions.
4
+
5
+ **rstool** is the agent API for sessions, upserts, analysis, diagnostics, modeling/evaluation, (de)serialization.
6
+
7
+ - Library: `@rsconcept/rstool` (npm)
8
+ - Analyzer: `@rsconcept/domain` (dependency of rstool)
9
+ - Language reference: `docs/*.md` next to this package (see table below)
10
+
11
+ ## Docs / hints (canonical paths)
12
+
13
+ Paths below are relative to **this file** (`skills/rstool-helper/GUIDE.md`).
14
+
15
+ | Info | Location |
16
+ | :--- | :--- |
17
+ | rstool API, methods, error codes | [REFERENCE.md](REFERENCE.md) |
18
+ | Worked examples, common mistakes | [EXAMPLES.md](EXAMPLES.md) |
19
+ | Domain vocabulary (English) | [../../docs/DOMAIN.md](../../docs/DOMAIN.md) |
20
+ | Constituenta fields, validation, ordering | [../../docs/CONSTITUENTA.md](../../docs/CONSTITUENTA.md) |
21
+ | RSLang syntax (operators, quantifiers) | [../../docs/SYNTAX.md](../../docs/SYNTAX.md) |
22
+ | Typification grades, radicals | [../../docs/TYPIFICATION.md](../../docs/TYPIFICATION.md) |
23
+ | Diagnostic code → fix table | [../../docs/DIAGNOSTICS.md](../../docs/DIAGNOSTICS.md) |
24
+ | Portal REST API (live data) | [../../docs/PORTAL-API.md](../../docs/PORTAL-API.md) |
25
+ | Lezer grammar pointers | [../../docs/GRAMMAR-REF.md](../../docs/GRAMMAR-REF.md) |
26
+ | Package README | [../../README.md](../../README.md) |
27
+
28
+ When working from **npm**, the same tree lives under `node_modules/@rsconcept/rstool/` (use the Read tool on those paths from the project root).
29
+
30
+ ## Protocol Summary
31
+
32
+ 1. **Start session**: `createSession`
33
+ 2. **Add bases/constants**: type `basic` (`X*`), `constant` (`C*`) — `definitionFormal: ''`
34
+ 3. **Add derived**: terms, axioms, etc.—only after dependencies present
35
+ 4. **Analyze scratch**: `analyzeExpression`
36
+ 5. **Process diagnostics**: check `analysis.diagnostics`/`listDiagnostics`; fix by range
37
+ 6. **Checkpoint**: `commitStep` (message optional)
38
+ 7. **Model values**: `setConstituentaValue` / `setConstituentaValues` for base bindings (`{0:"a",1:"b"}`) or structured values; `getModelState`
39
+ 8. **Evaluate**: `evaluateExpression` (scratch) or `evaluateConstituenta` / `recalculateModel` (stored definitions)
40
+ 9. **Export/import**: persist with `exportSession`/`importSession` (includes `state.model`)
41
+
42
+ **Clients**:
43
+
44
+ - Node: use `RSToolWrapperClient`
45
+ - Stdio process: `npx rstool-wrapper` — JSON per line
46
+
47
+ ## API/REST
48
+
49
+ For full reference see [../../docs/PORTAL-API.md](../../docs/PORTAL-API.md). Short form:
50
+
51
+ - **Portal UI**: `https://portal.acconcept.ru`
52
+ - **API**: `https://api.portal.acconcept.ru`
53
+ - Endpoints: `GET /api/rsforms/{id}`, `GET /api/rsforms/{id}/details`, `GET /api/library/{id}/versions/{v}`, `GET /api/oss/{id}`, `GET /api/models/{id}`, OpenAPI at `GET /schema`.
54
+ - Don't scrape SPA or use UI query params (`tab=`, etc.).
55
+ - rstool itself never calls the REST API; bring data in via `addOrUpdateConstituenta` after fetching.
56
+
57
+ ## Constituent Types (`cstType`)
58
+
59
+ | cstType | Example | Formal | Notes |
60
+ | :-------- | :------ | :-------- | :-------------------------------------------------------- |
61
+ | basic | X1 | **empty** | Required |
62
+ | constant | C1 | **empty** | Required |
63
+ | nominal | S1 | allowed | Naming |
64
+ | structure | S1 | allowed | Typification grade; base concept + `convention` |
65
+ | term | D1 | allowed | Formal **definition**; derived concept, computed in model |
66
+ | axiom | A1 | allowed | Logical; computed in model; required to be TRUE |
67
+ | statement | T1 | allowed | Logical; computed in model |
68
+ | function | F1 | allowed | Parameterized; derived concept |
69
+ | predicate | P1 | allowed | Parameterized; derived concept |
70
+
71
+ - Non-empty formal for `basic`/`constant` ⇒ error `0x8862` (`definitionNotAllowed`)
72
+ - Empty `basic`/`constant` always typified
73
+ - **Interpretable** (can set value): `basic`, `constant`, `structure`
74
+ - **Inferrable** (computed, do not set directly): `term`, `axiom`, `statement`
75
+
76
+ ## Structure (`S#`) vs term (`D#`)
77
+
78
+ The same field `definitionFormal` has **different roles** depending on `cstType`:
79
+
80
+ | | `structure` (`S#`) | `term` (`D#`) |
81
+ | -------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
82
+ | Role of `definitionFormal` | **Typification** — declares grade `H` (element structure) | **Definition** — declares how the concept is built from suppliers |
83
+ | Concept class | **Undefined** — meaning from `convention` (+ axioms on `S#`) | **Derived** — meaning from the expression; no convention required |
84
+ | Model interpretation | Values are **assigned** (or constrained by axioms); domain fills `S#` per convention | Value is **computed** via `evaluateConstituenta` / `recalculateModel` |
85
+
86
+ **Same syntax, different semantics:** in `ℬ(X1×X1)` the fragment `X1×X1` is a **grade** (one ordered pair of base elements). On a **term** with body `X1×X1` alone, `×` builds the **full Cartesian product** — the set of all pairs from `X1`, not a relation typification.
87
+
88
+ **Agent rule:** for a relation over `X1` (e.g. parent–child), upsert `S1` with `definitionFormal: 'ℬ(X1×X1)'` and a `convention`, then derive terms with projections/filters (`Pr1(S1)`, `Fi2[{ξ}](S1)`, …). Do not use bare `X1×X1` on a `term` when you meant the structure’s typification.
89
+
90
+ See [EXAMPLES.md](EXAMPLES.md) (kinship-lite) and `../../examples/build-kinship-rsform.ts`.
91
+
92
+ ## Syntax
93
+
94
+ - **Globals**: `X1`, `C1`, `D1`, `F1`, `P1`, `A1`, `R1`
95
+ - **Locals**: `x`, `ξ`, `μ2`
96
+ - **Literals**: `42`, `Z`, `∅`
97
+ - Full operator + precedence table: [../../docs/SYNTAX.md](../../docs/SYNTAX.md)
98
+ - Grammar pointers: [../../docs/GRAMMAR-REF.md](../../docs/GRAMMAR-REF.md)
99
+
100
+ ## Expression Types
101
+
102
+ - **Set-theoretic**: `∪`, `∩`, `\`, `∆`, `×`, `∈`, `⊆`, `ℬ(...)`, tuples
103
+ - **Logical**: `¬`, `&`, `∨`, `⇒`, `⇔`, `∀`, `∃`, comparisons `=`, `≠`, `<`
104
+ - **Parameterized**: `[arg1∈H1, arg2∈H2] body`
105
+ - Detailed semantics in [../../docs/SYNTAX.md](../../docs/SYNTAX.md); typification grades and radicals in [../../docs/TYPIFICATION.md](../../docs/TYPIFICATION.md).
106
+
107
+ Always set `cstType` in upserts/analysis to true role.
108
+
109
+ ## Diagnostics Loop
110
+
111
+ 1. Check `analysis.success`
112
+ 2. If not, see `analysis.diagnostics` / `listDiagnostics`
113
+ 3. Map `code` → cause → fix via [../../docs/DIAGNOSTICS.md](../../docs/DIAGNOSTICS.md)
114
+ 4. Use `from`, `to` to patch `definitionFormal`; re-send
115
+
116
+ Don't infer types—always read tool output.
117
+
118
+ ## Declaration Order
119
+
120
+ 1. All `basic`, `constant`
121
+ 2. Core/critical first
122
+ 3. Topological: dependencies before dependents (e.g. `D1` before `D2` if `D2` refers to `D1`)
123
+ 4. Derived right after their sources
124
+
125
+ ## Checklist
126
+
127
+ - [ ] `sessionId` obtained & tracked
128
+ - [ ] Bases/constants are empty formal
129
+ - [ ] All dependencies exist before upsert
130
+ - [ ] Matching `cstType`
131
+ - [ ] Diagnostics handled before commit/export
132
+ - [ ] Base bindings set before evaluating expressions that reference base elements
133
+ - [ ] For other details, open [REFERENCE.md](REFERENCE.md) or linked `docs/*.md`
@@ -33,7 +33,7 @@
33
33
  {
34
34
  id: number; // stable id within session
35
35
  alias: string; // e.g. "D1", "X1"
36
- cstType: CstType; // see SKILL.md table
36
+ cstType: CstType; // see GUIDE.md table
37
37
  definitionFormal: string;
38
38
  term?: string;
39
39
  definitionText?: string;
@@ -79,7 +79,8 @@ Example chain:
79
79
 
80
80
  ```json
81
81
  {"id":"1","method":"createSession","params":{}}
82
- {"id":"2","method":"addOrUpdateConstituenta","params":{"sessionId":"…","input":{"draft":{"id":3,"alias":"D1","cstType":"term","definitionFormal":"X1×X1"}}}}
82
+ {"id":"2","method":"addOrUpdateConstituenta","params":{"sessionId":"…","input":{"draft":{"id":2,"alias":"S1","cstType":"structure","definitionFormal":"ℬ(X1×X1)"}}}}
83
+ {"id":"2b","method":"addOrUpdateConstituenta","params":{"sessionId":"…","input":{"draft":{"id":3,"alias":"D1","cstType":"term","definitionFormal":"Pr1(S1)"}}}}
83
84
  {"id":"3","method":"analyzeExpression","params":{"sessionId":"…","input":{"expression":"1+2","cstType":"term"}}}
84
85
  {"id":"4","method":"listDiagnostics","params":{"sessionId":"…"}}
85
86
  {"id":"5","method":"commitStep","params":{"sessionId":"…","message":"checkpoint"}}
@@ -104,8 +105,9 @@ interface AnalysisResult {
104
105
 
105
106
  ## RS language — conceptual model
106
107
 
107
- - **Typification**: computed structure type from a formal definition; grades include elements (`Xi`, `Ci`), `Z`, tuples `(H1×…×Hn)`, sets `ℬ(H)`, logic `Logic`, parameterized `Hr 🠔 [H1,…,Hi]`.
108
+ - **Typification**: structure type of an expression; grades include elements (`Xi`, `Ci`), `Z`, tuples `(H1×…×Hn)`, sets `ℬ(H)`, logic `Logic`, parameterized `Hr 🠔 [H1,…,Hi]`. On `structure` (`S#`), `definitionFormal` **is** the typification. On `term` (`D#`), typification is **inferred from** the definition.
108
109
  - **Term graph**: directed dependencies between constituenta via alias references in definitions.
110
+ - **`S#` vs `D#`**: same `×` token — in `ℬ(X1×X1)` on `S#` it forms a **grade** (pair type); in `X1×X1` on `D#` it is the **Cartesian product** (all pairs). Relations: `S#` + `convention`, then derived `D#` (`Pr1(S1)`, …).
109
111
 
110
112
  Intro (help): language is FOL-based; set vs logic expression split; parameterized templates for term/predicate functions; structural expressions reshape stages.
111
113