@rsconcept/rstool 0.2.1 → 0.4.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 (50) hide show
  1. package/README.md +3 -1
  2. package/dist/index-uhkmwruf.d.ts +46 -0
  3. package/dist/index.d.ts +5 -4
  4. package/dist/index.js +2 -2
  5. package/dist/mappers/model-adapter.d.ts +1 -1
  6. package/dist/mappers/schema-adapter.d.ts +1 -1
  7. package/dist/models/index.d.ts +5 -4
  8. package/dist/models/index.js +2 -2
  9. package/dist/models/rstool-agent.d.ts +1 -1
  10. package/dist/models/rstool-agent.js +1 -92
  11. package/dist/models/session.d.ts +1 -1
  12. package/dist/models/tool-contract.d.ts +1 -1
  13. package/dist/models/tool-contract.js +1 -1
  14. package/dist/models/tool-contract.js.map +1 -1
  15. package/dist/rstool-agent-BZi5jO1y.js +158 -0
  16. package/dist/rstool-agent-BZi5jO1y.js.map +1 -0
  17. package/dist/{rstool-agent-DkeH5Qml.d.ts → rstool-agent-pRaPnZay.d.ts} +6 -4
  18. package/dist/session/session-store.d.ts +2 -1
  19. package/dist/session/session-store.js +3 -0
  20. package/dist/session/session-store.js.map +1 -1
  21. package/dist/{session-BHGCCLfQ.d.ts → session-BPgsE80c.d.ts} +12 -1
  22. package/dist/{tool-contract-CsGqg_0P.d.ts → tool-contract-n1ghUOrK.d.ts} +5 -3
  23. package/dist/wrapper/stdio-wrapper.js +13 -1
  24. package/dist/wrapper/stdio-wrapper.js.map +1 -1
  25. package/docs/CONCEPTUAL-SCHEMA.md +50 -140
  26. package/docs/CONSTITUENTA.md +37 -62
  27. package/docs/DIAGNOSTICS.md +85 -130
  28. package/docs/DOMAIN.md +68 -91
  29. package/docs/GRAMMAR-REF.md +35 -86
  30. package/docs/MODEL-TESTING.md +57 -0
  31. package/docs/PORTAL-API.md +22 -36
  32. package/docs/README.md +14 -13
  33. package/docs/SYNTAX.md +49 -104
  34. package/docs/TYPIFICATION.md +41 -60
  35. package/package.json +1 -1
  36. package/skills/README.md +6 -8
  37. package/skills/rstool-helper/EXAMPLES.md +91 -105
  38. package/skills/rstool-helper/GUIDE.md +67 -114
  39. package/skills/rstool-helper/REFERENCE.md +43 -11
  40. package/skills/rstool-helper/SKILL.md +5 -8
  41. package/src/index.ts +6 -0
  42. package/src/models/index.ts +8 -0
  43. package/src/models/portal-json.ts +45 -0
  44. package/src/models/rstool-agent.test.ts +98 -0
  45. package/src/models/rstool-agent.ts +72 -4
  46. package/src/models/session.ts +11 -0
  47. package/src/models/tool-contract.ts +3 -1
  48. package/src/session/session-store.ts +3 -0
  49. package/src/wrapper/stdio-wrapper.ts +14 -0
  50. package/dist/models/rstool-agent.js.map +0 -1
@@ -1,45 +1,31 @@
1
- # Portal REST API (read-only reference)
1
+ # Portal REST API
2
2
 
3
- When an agent needs to **inspect existing** RSForms, OSS, or RSModels persisted on the Portal, use the REST API on `api.portal.acconcept.ru`. The rstool library itself never calls the Portal API it always works on in-memory sessions. This document is for agents that combine rstool sessions with data fetched from a live Portal.
3
+ Справка только для чтения существующих КС, ОСС и RSModel. `rstool` сам не ходит в REST API: он работает с in-memory сессиями.
4
4
 
5
- ## Hosts
5
+ ## Хосты
6
6
 
7
- - **UI:** `https://portal.acconcept.ru/`
8
- - **REST API:** `https://api.portal.acconcept.ru/`
7
+ - UI: `https://portal.acconcept.ru/`
8
+ - REST API: `https://api.portal.acconcept.ru/`
9
9
 
10
- ## Path rewrite rules
10
+ ## Пути
11
11
 
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) |
12
+ - `/rsforms/:id` в UI `GET /api/rsforms/:id` для метаданных.
13
+ - Полная КС `GET /api/rsforms/:id/details`.
14
+ - Версия КС → `GET /api/library/:id/versions/:version`.
15
+ - ОСС `GET /api/oss/:id` и соседние routes viewset.
16
+ - Модель `GET /api/models/:id`.
17
+ - OpenAPI JSON → `GET https://api.portal.acconcept.ru/schema`.
19
18
 
20
- ## OpenAPI
19
+ ## Как перенести КС в rstool
21
20
 
22
- Machine-readable schema:
21
+ 1. Получи `GET /api/rsforms/:id/details`.
22
+ 2. Создай `createSession`.
23
+ 3. Перенеси конституенты через `addOrUpdateConstituenta`: `alias`, `cstType`, `definitionFormal`, `term`, `definitionText`, `convention`.
24
+ 4. Работай локально: анализ, правки, вычисления.
25
+ 5. Для передачи результата используй `exportSession`.
23
26
 
24
- ```
25
- GET https://api.portal.acconcept.ru/schema
26
- ```
27
+ ## Не делай
27
28
 
28
- Prefer `/schema` for JSON. The Swagger UI is separate.
29
-
30
- ## What rstool consumes
31
-
32
- rstool itself works with in-memory sessions via `RSToolAgent` or the stdio wrapper. To bridge between the REST payload and a rstool session, the typical flow is:
33
-
34
- 1. `GET /api/rsforms/:id/details` to fetch the persisted RSForm.
35
- 2. Convert the response (constituents, formal definitions, term, convention, etc.) into a series of `addOrUpdateConstituenta` calls inside a fresh `createSession`.
36
- 3. Operate offline: analyse, edit, evaluate, then `exportSession` for hand-off.
37
-
38
- There is no backend write path in rstool: edits never round-trip to the Portal automatically. Publish changes back to the Portal through the existing Portal UI or REST writes.
39
-
40
- ## Don'ts
41
-
42
- - Do not scrape the SPA HTML.
43
- - Do not pass UI hash params (`?tab=editor`, etc.) to REST.
44
- - Do not call `/api/rsforms/:id/details` for trivial metadata — `GET /api/rsforms/:id` is cheaper.
45
- - Do not assume the API host is the same as the UI host in production — they are different.
29
+ - Не парси HTML SPA.
30
+ - Не переноси UI query/hash вроде `?tab=editor` в REST.
31
+ - Не запрашивай `/details`, если нужны только метаданные.
package/docs/README.md CHANGED
@@ -1,16 +1,17 @@
1
- # rstool docs
1
+ # Документация rstool
2
2
 
3
- Standalone English reference distilled from the Portal manuals and `CONTEXT.md`. Bundled with `@rsconcept/rstool` so external agents never need to read the Portal frontend source tree.
3
+ Краткая русская справка для агентов.
4
4
 
5
- | File | Read when |
6
- |------|-----------|
7
- | [`DOMAIN.md`](DOMAIN.md) | You need the Concept Portal vocabulary (constituenta, conceptual schema/model, OSS, synthesis). |
8
- | [`CONCEPTUAL-SCHEMA.md`](CONCEPTUAL-SCHEMA.md) | You are designing/reviewing a conceptual schema as a system (thesaurus value, closed-world text definitions, genus structures, axioms). |
9
- | [`CONSTITUENTA.md`](CONSTITUENTA.md) | You are upserting constituents — fields, `cstType` table, validation rules, recommended order. |
10
- | [`SYNTAX.md`](SYNTAX.md) | You are constructing RSLang expressions — operators, quantifiers, parameterised functions, examples. |
11
- | [`TYPIFICATION.md`](TYPIFICATION.md) | You are interpreting `AnalysisResult.type` / `valueClass` or constructing template expressions with radicals. |
12
- | [`DIAGNOSTICS.md`](DIAGNOSTICS.md) | You received `analysis.diagnostics` and need to map error codes to fixes. |
13
- | [`PORTAL-API.md`](PORTAL-API.md) | You need to fetch an existing RSForm/OSS/RSModel from the live Portal REST API. |
14
- | [`GRAMMAR-REF.md`](GRAMMAR-REF.md) | You need a compact token / precedence table; the full grammar lives in `@rsconcept/domain`. |
5
+ ## Какой файл читать
15
6
 
16
- For the rstool agent contract itself (methods, types, stdio protocol) see [`../skills/rstool-helper/REFERENCE.md`](../skills/rstool-helper/REFERENCE.md).
7
+ - **DOMAIN.md** термины Portal: конституента, концептуальная схема/модель, ОСС, синтез.
8
+ - **CONCEPTUAL-SCHEMA.md** — проектирование и ревью концептуальных схем.
9
+ - **CONSTITUENTA.md** — структура и правила конституент.
10
+ - **SYNTAX.md** — операторы, кванторы, функции и примеры выражений.
11
+ - **TYPIFICATION.md** — типизация (`AnalysisResult.type`, `valueClass`).
12
+ - **MODEL-TESTING.md** — проверка семантики определений на маленьких концептуальных моделях.
13
+ - **DIAGNOSTICS.md** — диагностики анализа и способы исправления ошибок.
14
+ - **PORTAL-API.md** — объекты REST API Portal.
15
+ - **GRAMMAR-REF.md** — краткая карта токенов и приоритетов.
16
+
17
+ Контракт агента `rstool` см. в `../skills/rstool-helper/REFERENCE.md`.
package/docs/SYNTAX.md CHANGED
@@ -1,139 +1,84 @@
1
- # RSLang syntax reference
1
+ # Синтаксис RSLang
2
2
 
3
- Use this when constructing or repairing RSLang expressions. For full grammar tokens see `GRAMMAR-REF.md`. For typification rules see `TYPIFICATION.md`.
3
+ Читай, когда строишь или исправляешь `definitionFormal`. Токены и приоритеты в `GRAMMAR-REF.md`, типизация в `TYPIFICATION.md`.
4
4
 
5
- ## Identifier rules
5
+ ## Имена и литералы
6
6
 
7
- - **Globals** (concept aliases): uppercase Latin letter + digits — `X1`, `C2`, `S3`, `D11`, `F7`, `P4`, `A6`, `T9`, `N12`. The leading letter must match the constituent's role.
8
- - **Radicals**: identifiers starting with `R` — used inside template parameterised expressions to denote arbitrary typifications (`R1`, `R2`).
9
- - **Locals** (bound variables): lowercase Latin or Greek letter, optionally with digits — `x`, `ξ`, `μ2`, `y1`.
10
- - **Special identifiers** reserved tokens (`Z`, `∅`, operators).
7
+ - Глобальные алиасы: `X1`, `C2`, `S3`, `D11`, `F7`, `P4`, `A6`, `T9`; буква совпадает с ролью.
8
+ - Радикалы: `R1`, `R2` — шаблонные ступени в параметрах.
9
+ - Локальные переменные: `x`, `ξ`, `μ2`, `y1`.
10
+ - Целые: `0`, `42`; отрицательного литерала нет, пиши `0 - 5`.
11
+ - `Z` — множество целых, `∅` — пустое множество с типизацией `ℬ(R0)`.
11
12
 
12
- ## Literals
13
+ ## Теоретико-множественные выражения (STE)
13
14
 
14
- - **Integers**: digit sequence, no negative literal: `0`, `42`. Negation is a binary subtraction `0 - n`.
15
- - **Integer set**: `Z`.
16
- - **Empty set**: `∅` (typification `ℬ(R0)` — set of arbitrary element structure).
15
+ - `D1 D2`, `D1 D2`, `D1 \ D2`, `D1 D2` операции над множествами.
16
+ - `X1 × X2` — декартово произведение.
17
+ - `ℬ(X1)` — булеан, множество всех подмножеств.
18
+ - `(a, b, c)` — кортеж, арность минимум 2.
19
+ - `{a, b, c}` — перечисление.
20
+ - `bool(a)` — синглетон, `debool(S)` — извлечение единственного элемента.
21
+ - `red(S)` — суммарное множество; `S` должно иметь ступень `ℬ(ℬ(H))`.
22
+ - `pr1(tuple)` — малая проекция кортежа.
23
+ - `Pr1(S)` — большая проекция множества кортежей.
24
+ - `Fi1[D](S)` — фильтр по принадлежности выбранной проекции в `D`.
17
25
 
18
- ## Set-theoretic expressions
26
+ Мультииндексы разрешены: `pr1,3(...)`, `Pr2,4(S1)`, `Fi1,2[D1](S1)`.
19
27
 
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` |
28
+ ## Логические выражения (LE)
36
29
 
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)`).
30
+ - Предикаты множеств: S`, S`, `S1 = S2`, `S1 S2`, `S1 S2`, `S1 ⊂ S2`, `S1 ⊄ S2`.
31
+ - Арифметические предикаты: `=`, `≠`, `<`, `≤`, `>`, `≥` над `Z`.
32
+ - Связки: `¬A`, `A & B`, `A ∨ B`, `A ⇒ B`, `A ⇔ B`.
38
33
 
39
- ## Logical expressions
34
+ `TRUE` и `FALSE` в экспликации КС не используют.
40
35
 
41
- ### Set-theoretic predicates
36
+ ## Кванторы
42
37
 
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
- | Strict inclusion | `S1 ⊂ S2` |
51
- | Non-inclusion | `S1 ⊄ S2` |
38
+ - `∀ξ∈D1 (LE(ξ))` — всеобщность.
39
+ - `∃ξ∈D1 (LE(ξ))` существование.
40
+ - `∀(ξ1, ξ2)S1 (LE(ξ1, ξ2))` — объявление кортежа.
41
+ - `∀ξ1, ξ2∈D1 (LE(ξ1, ξ2))` — сокращение вложенных кванторов.
52
42
 
53
- ### Arithmetic predicates (typification `Logic`)
43
+ Скобки вокруг `LE` можно опустить для атомарного логического выражения.
54
44
 
55
- `a = b`, `a ≠ b`, `a < b`, `a ≤ b`, `a > b`, `a ≥ b`.
45
+ ## Арифметика
56
46
 
57
- ### Connectives
47
+ `a + b`, `a - b`, `a * b` дают `Z`. `card(S)` возвращает мощность конечного множества.
58
48
 
59
- | Connective | Syntax |
60
- | ----------- | ------- |
61
- | Negation | `¬A` |
62
- | Conjunction | `A & B` |
63
- | Disjunction | `A ∨ B` |
64
- | Implication | `A ⇒ B` |
65
- | Equivalence | `A ⇔ B` |
49
+ ## Параметризованные выражения
66
50
 
67
- The constants `TRUE` and `FALSE` are **not** used inside schema explications.
68
-
69
- ## Quantifiers
70
-
71
- | Form | Syntax |
72
- | ------------- | ---------------------------- |
73
- | Universal | `∀ξ∈STE (LE(ξ))` |
74
- | Existential | `∃ξ∈STE (LE(ξ))` |
75
- | Tuple binding | `∀(ξ1, ξ2)∈STE (LE(ξ1, ξ2))` |
76
- | Variable list | `∀ξ1, ξ2 ∈ STE (LE(ξ1, ξ2))` |
77
-
78
- Parentheses around `LE` may be omitted for atomic logical expressions.
79
-
80
- ## Arithmetic
81
-
82
- Operations `a + b`, `a - b`, `a * b` form set-theoretic expressions with typification `Z`. Negative numbers are computed, never literal.
83
-
84
- `card(S)` returns the integer cardinality of `S` (always finite in practice).
85
-
86
- ## Parameterised expressions
87
-
88
- ### Term-function declaration
89
-
90
- ```
51
+ ```text
91
52
  F1 ::= [α1∈STE1, α2∈STE2(α1)] STE(α1, α2)
92
- ```
93
-
94
- - Inside `[]` is an ordered list of parameter declarations separated by commas.
95
- - A parameter is declared with `∈`: `local_var ∈ domain`.
96
- - A declared variable can appear in subsequent parameter domains and in the result STE.
97
-
98
- ### Predicate-function declaration
99
-
100
- ```
101
53
  P1 ::= [α1∈STE1, α2∈STE2(α1)] LE(α1, α2)
102
54
  ```
103
55
 
104
- The only difference from a term-function is that the body is a logical expression.
56
+ - В `[]` идут параметры через `∈`.
57
+ - Параметр доступен в следующих доменах и теле.
58
+ - Вызов позиционный: `F1[ξ1, S1]`, `P1[ξ1\ξ2, ξ3]`.
59
+ - `F#` возвращает теоретико-множественное выражение, `P#` — логическое.
105
60
 
106
- ### Calling parameterised functions
61
+ ## Радикалы
107
62
 
108
- `F1[ξ1, S1]`, `P1[ξ1\ξ2, ξ3]` — arguments are positional and listed in square brackets after the function name. Argument typifications are checked against parameter typifications. Result is an STE (term-function) or LE (predicate-function).
109
-
110
- ### Template expressions
111
-
112
- Functions that use radicals as parameter typifications are templates:
113
-
114
- ```
63
+ ```text
115
64
  F2 ::= [α1∈R1×R2, α2∈R1] α2 = pr1(α1)
116
65
  ```
117
66
 
118
- - Radical values are **inferred** from the call-site argument typifications. All inferred values for the same radical index must agree.
119
- - Different radical indices are independent.
120
- - Radicals may only appear in parameter domains — never in the result expression.
67
+ - `R#` выводится по типизациям аргументов в месте вызова.
68
+ - Все вхождения одного `R#` должны совпасть.
69
+ - Радикалы допустимы только в доменах параметров.
121
70
 
122
- ## Examples
71
+ ## Примеры
123
72
 
124
73
  - `¬α ∈ S1`
125
- - `D1 ∈ S1 ⇒ 2 + 2 = 5`
126
74
  - `D1 ⊆ D2 ⇔ ∀x∈D1 x∈D2`
127
75
  - `∀x∈D1 ∃y∈D2 (x, y)∈S1 & (x, x)∈S1`
128
76
  - `(4 + 5) * 3`, `card(X1) > 5`
129
- - `ℬ(2) = {{}, {1}, {2}, {1, 2}}`
130
77
  - `pr2((5, 4, 3, 2, 1)) = 4`
131
78
  - `red({{1, 2, 3}, {3, 4}}) = {1, 2, 3, 4}`
132
- - `Fi2[{2, 4}]({((1, 2), (3, 4), (5, 6))}) = {((1, 2), (3, 4))}`
133
79
 
134
- ## Correctness model
80
+ ## Корректность
135
81
 
136
- - Expression checking happens in the **global context**: known typifications and bijective portability of every referenced identifier. Unknown identifiers are errors.
137
- - Set-theoretic rules follow from bijective portability of the membership predicate — an element must match the typification of the set it is tested against.
138
- - Logical consistency cannot generally be checked automatically. The existence of an interpretation example in a conceptual model is a basis for accepting consistency.
139
- - All formal definitions must be **bijectively portable**: values are independent of any bijective replacement of undefined-concept interpretations.
82
+ - Анализ идет в глобальном контексте: все алиасы должны быть известны и типизированы.
83
+ - Формальные определения должны быть биективно переносимыми (гарантируется семантическим анализатором).
84
+ - Логическая непротиворечивость проверяется примером интерпретации в модели.
@@ -1,84 +1,65 @@
1
- # Typification reference
1
+ # Типизация
2
2
 
3
- Distilled from `help-rslang-typification`, `help-rslang-expression-structure`, and `help-rslang-expression-parameter`. Agents must understand grades to interpret `AnalysisResult.type` and to construct correct expressions.
3
+ Читай, когда разбираешь `AnalysisResult.type`, `valueClass` или радикалы.
4
4
 
5
- ## Grades
5
+ ## Ступени
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
+ Выражение типизировано, если его значения принадлежат ступени `H`.
8
8
 
9
- | Grade | Form | Notes |
10
- | ---------------- | -------------------- | ------------------------------------ |
11
- | Element | `Xi`, `Ci` | grade of a basic concept's elements |
12
- | Integer | `Z` | grade of integer |
13
- | Tuple of arity n | `(H1 × H2 × … × Hn)` | ordered structured grade |
14
- | Set | `ℬ(H)` | unordered set of values of grade `H` |
9
+ - `Xi`, `Ci` — элемент базисного или константного множества.
10
+ - `Z` целое число.
11
+ - `(H1 × H2 × ... × Hn)` — кортеж.
12
+ - `ℬ(H)` множество значений ступени `H`.
15
13
 
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.
14
+ `∅` имеет типизацию `ℬ(R0)`: пустое множество подстраивается под контекст.
17
15
 
18
- ## Extended typifications
16
+ ## Дополнительные типизации
19
17
 
20
- Beyond set-theoretic grades, RSLang uses two additional grade-like markers:
18
+ - `Logic` логические выражения: аксиомы, высказывания, тела предикат-функций.
19
+ - `Hr <- [H1, H2, ..., Hi]` — параметризованная типизация функций: результат и аргументы.
21
20
 
22
- - **Logic** — typification of logical expressions (axioms, statements, predicate bodies) that evaluate to TRUE or FALSE.
23
- - **Parameterised** — typification of term-functions and predicate-functions:
21
+ ## Радикалы
24
22
 
25
- ```
26
- Hr 🠔 [H1, H2, …, Hi]
27
- ```
23
+ `R1`, `R2`, ... — шаблонные ступени.
28
24
 
29
- where `Hr` is the result typification (an STE grade or `Logic`) and `H1 Hi` are the argument typifications.
25
+ - Значение `R#` выводится по аргументам в месте вызова.
26
+ - Все вхождения одного `R#` должны дать одну ступень.
27
+ - Разные `R#` независимы.
28
+ - Радикалы можно писать только в доменах параметров; в теле результата будет `radicalUsage`.
30
29
 
31
- ## Radicals
30
+ ## `AnalysisResult.type`
32
31
 
33
- Template parameterised expressions may contain notations `R1, R2, …` (and `R0` for `∅`). Each radical corresponds to an arbitrary grade that is **inferred** from the typifications of the arguments at the point of use.
32
+ `type` приходит как JSON анализатора: `Record<string, unknown> | null`.
34
33
 
35
- - All occurrences of the same radical index must resolve to the same grade.
36
- - Radicals with different indices are independent.
37
- - Radicals may only appear in parameter domains, **not in the result expression**.
34
+ Правила:
38
35
 
39
- ## Encoded shape in `AnalysisResult.type`
36
+ 1. Сначала проверь `analysis.success === true` и `analysis.type !== null`.
37
+ 2. Не разбирай объект вручную; используй helpers из `@rsconcept/domain`.
38
+ 3. `valueClass` уточняет вычислимость: `Value`, `Property`, `Invalid`.
40
39
 
41
- The contract exposes `type: Record<string, unknown> | null` because typifications are JSON-encoded by the analyzer. Useful properties exposed by `@rsconcept/domain` helpers:
40
+ Полезные API: `TypeID`, `TypePath`, `makeTypePath`, `parseTypeText(...)`.
42
41
 
43
- - `TypeID` enum: `Element`, `Integer`, `Tuple`, `Boolean`, `Logic`, `Functional` — discriminates the top-level shape.
44
- - `TypePath` (sequence of indices) addresses positions inside a tuple-of-sets-of-tuples structure; use `makeTypePath` to construct.
45
- - `parseTypeText(...)` parses an ASCII representation `B(X1)`, `(X1×X2)`, etc., into a `Typification`.
42
+ ## `S#` и `D#`
46
43
 
47
- For agents inspecting types from rstool output:
44
+ - У `structure` (`S#`) `definitionFormal` читается как типизация. `ℬ(X1×X1)` описывает множество пар.
45
+ - У `term` (`D#`) `definitionFormal` читается как определение. `X1×X1` строит декартов продукт.
48
46
 
49
- 1. Check `analysis.success === true` and `analysis.type !== null`.
50
- 2. Use `analysis.type` (object) only as opaque input to `@rsconcept/domain` helpers — do not pattern-match it manually.
51
- 3. The `valueClass` companion indicates `Value`, `Property` (non-computable membership only), or `Invalid`.
47
+ Для отношений предпочитай `S#` с `ℬ(X1×X1)` и конвенцией; выводимые понятия делай через `Pr*`, `Fi*`, фильтры и функции.
52
48
 
53
- ## Typification on `S#` vs definition on `D#`
49
+ ## Операции
54
50
 
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#`.
51
+ Создают ступень: `ℬ(H)`, `H1 × H2`, `(a, b)`, `{a, b}`, `bool(a)`.
57
52
 
58
- Prefer `S#` with `ℬ(X1×X1)` plus `convention` for relations; derive `D#` with `Pr*`, `Fi*`, filters, etc.
53
+ Требуют подходящую ступень:
59
54
 
60
- ## Forming structures vs. derived structures
55
+ - `red(S)` нужно `S : ℬ(ℬ(H))`.
56
+ - `debool(S)` — нужно одноэлементное множество.
57
+ - `pr1(tuple)`, `Pr1(S)` — нужна достаточная арность.
58
+ - `Fi1[D](S)` — `D` должен соответствовать выбранной проекции.
61
59
 
62
- Forming operations build a new grade:
60
+ ## Частые ошибки
63
61
 
64
- - `ℬ(H)` power set
65
- - `H1 × H2` Cartesian product
66
- - `(a, b, c)` tuple
67
- - `{a, b, c}` enumeration
68
- - `bool(a)` — singleton
69
-
70
- Derived structures consume a grade:
71
-
72
- - `red(S)` — union of inner sets; requires `S : ℬ(ℬ(H))`
73
- - `debool({a})` — extracts the single element of a singleton
74
- - `pr1((a1, …, an))`, `Pr1(S)` — projections (multi-indices allowed: `pr1,3`, `Pr2,4`)
75
- - `Fi1[D](S)` — filters by membership in `D`; multi-index variants must match parameter arity
76
-
77
- ## Common typification pitfalls
78
-
79
- - Negative integer literals do not exist — use `0 - n`.
80
- - `debool(S)` fails if `S` is not a singleton.
81
- - Tuple projections require the argument to be a tuple of sufficient arity; `pr3((a, b))` is an error.
82
- - Filter parameter list arity must match the multi-index in `Fi[...]`.
83
- - A radical in the **result expression** of a template is a hard error (`radicalUsage`).
84
- - An `axiom` or `statement` must have typification `Logic`; non-logical formal definitions raise `expectedLogic`.
62
+ - `debool(S)` без гарантии синглетона.
63
+ - `pr3((a, b))`: индекс вне арности.
64
+ - `Fi1,2[D](S)`: параметр `D` не совпал с двумя проекциями.
65
+ - `A#` и `T#` не имеют `Logic`: будет `expectedLogic`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsconcept/rstool",
3
- "version": "0.2.1",
3
+ "version": "0.4.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",
package/skills/README.md CHANGED
@@ -4,14 +4,12 @@ Each skill lives in its own subdirectory: `skills/<skill-name>/SKILL.md` (plus r
4
4
 
5
5
  ## Layout
6
6
 
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, …) |
7
+ - `INSTALL.md`: agent procedure after `npm install`
8
+ - `rstool-helper/SKILL.md`: thin entry skill — copy into the project’s agent skills folder (see `INSTALL.md`)
9
+ - `rstool-helper/GUIDE.md`: canonical workflow and language primer
10
+ - `rstool-helper/REFERENCE.md`: API, stdio, contract
11
+ - `rstool-helper/EXAMPLES.md`: worked examples and pitfalls
12
+ - `../docs/*.md`: language reference (DOMAIN, SYNTAX, DIAGNOSTICS, …)
15
13
 
16
14
  ## npm workflow
17
15