@rsconcept/rstool 0.1.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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js +585 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/mappers/model-adapter.d.ts +27 -0
  7. package/dist/mappers/model-adapter.js +248 -0
  8. package/dist/mappers/model-adapter.js.map +1 -0
  9. package/dist/mappers/schema-adapter.d.ts +22 -0
  10. package/dist/mappers/schema-adapter.js +89 -0
  11. package/dist/mappers/schema-adapter.js.map +1 -0
  12. package/dist/mappers/types.d.ts +23 -0
  13. package/dist/mappers/types.js +22 -0
  14. package/dist/mappers/types.js.map +1 -0
  15. package/dist/models/analysis.d.ts +18 -0
  16. package/dist/models/analysis.js +1 -0
  17. package/dist/models/analysis.js.map +1 -0
  18. package/dist/models/common.d.ts +15 -0
  19. package/dist/models/common.js +12 -0
  20. package/dist/models/common.js.map +1 -0
  21. package/dist/models/constituenta.d.ts +38 -0
  22. package/dist/models/constituenta.js +1 -0
  23. package/dist/models/constituenta.js.map +1 -0
  24. package/dist/models/diagnostic.d.ts +17 -0
  25. package/dist/models/diagnostic.js +1 -0
  26. package/dist/models/diagnostic.js.map +1 -0
  27. package/dist/models/evaluation.d.ts +23 -0
  28. package/dist/models/evaluation.js +1 -0
  29. package/dist/models/evaluation.js.map +1 -0
  30. package/dist/models/index.d.ts +13 -0
  31. package/dist/models/index.js +491 -0
  32. package/dist/models/index.js.map +1 -0
  33. package/dist/models/model-value.d.ts +37 -0
  34. package/dist/models/model-value.js +1 -0
  35. package/dist/models/model-value.js.map +1 -0
  36. package/dist/models/rstool-agent.d.ts +36 -0
  37. package/dist/models/rstool-agent.js +480 -0
  38. package/dist/models/rstool-agent.js.map +1 -0
  39. package/dist/models/session.d.ts +29 -0
  40. package/dist/models/session.js +1 -0
  41. package/dist/models/session.js.map +1 -0
  42. package/dist/models/tool-contract.d.ts +33 -0
  43. package/dist/models/tool-contract.js +6 -0
  44. package/dist/models/tool-contract.js.map +1 -0
  45. package/dist/session/session-store.d.ts +26 -0
  46. package/dist/session/session-store.js +66 -0
  47. package/dist/session/session-store.js.map +1 -0
  48. package/dist/wrapper/client.d.ts +30 -0
  49. package/dist/wrapper/client.js +96 -0
  50. package/dist/wrapper/client.js.map +1 -0
  51. package/dist/wrapper/stdio-wrapper.d.ts +1 -0
  52. package/dist/wrapper/stdio-wrapper.js +679 -0
  53. package/dist/wrapper/stdio-wrapper.js.map +1 -0
  54. package/docs/CONSTITUENTA.md +55 -0
  55. package/docs/DIAGNOSTICS.md +125 -0
  56. package/docs/DOMAIN.md +89 -0
  57. package/docs/GRAMMAR-REF.md +98 -0
  58. package/docs/PORTAL-API.md +48 -0
  59. package/docs/README.md +15 -0
  60. package/docs/SYNTAX.md +139 -0
  61. package/docs/TYPIFICATION.md +79 -0
  62. package/package.json +76 -0
  63. package/skills/README.md +15 -0
  64. package/skills/rstool-helper/EXAMPLES.md +154 -0
  65. package/skills/rstool-helper/REFERENCE.md +169 -0
  66. package/skills/rstool-helper/SKILL.md +148 -0
  67. package/src/index.ts +43 -0
  68. package/src/mappers/model-adapter.ts +276 -0
  69. package/src/mappers/schema-adapter.ts +87 -0
  70. package/src/mappers/types.ts +35 -0
  71. package/src/models/analysis.ts +13 -0
  72. package/src/models/common.ts +17 -0
  73. package/src/models/constituenta.ts +35 -0
  74. package/src/models/diagnostic.ts +12 -0
  75. package/src/models/evaluation.ts +25 -0
  76. package/src/models/index.ts +33 -0
  77. package/src/models/model-value.ts +31 -0
  78. package/src/models/rstool-agent.test.ts +300 -0
  79. package/src/models/rstool-agent.ts +143 -0
  80. package/src/models/session.ts +22 -0
  81. package/src/models/tool-contract.ts +47 -0
  82. package/src/session/session-store.ts +81 -0
  83. package/src/wrapper/client.ts +116 -0
  84. package/src/wrapper/stdio-wrapper.ts +225 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 IRBorisov and Concept Portal contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # @rsconcept/rstool
2
+
3
+ Agent-facing library for **incremental RSForm construction**, **RSLang expression analysis**, **diagnostics**, **modeling**, and **evaluation**. It wraps [`@rsconcept/domain`](https://www.npmjs.com/package/@rsconcept/domain) with a deterministic session contract and a stdio JSON wrapper that LLM agents and Cursor/Claude clients can call directly.
4
+
5
+ ## Agent skill
6
+
7
+ RS language + rstool workflows for agents: `skills/rstool-helper/` (`SKILL.md`, `REFERENCE.md`, `EXAMPLES.md`). The companion language reference in `docs/` (`DOMAIN.md`, `SYNTAX.md`, `TYPIFICATION.md`, `CONSTITUENTA.md`, `DIAGNOSTICS.md`, `PORTAL-API.md`, `GRAMMAR-REF.md`) is distilled from the Portal manuals and ships with the npm package, so standalone agents never need to read the Portal frontend source.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @rsconcept/rstool
13
+ ```
14
+
15
+ `@rsconcept/domain` is a peer-of-dependency installed automatically. No Portal checkout is required.
16
+
17
+ ## Quick use (library)
18
+
19
+ ```ts
20
+ import { CstType, RSToolAgent } from '@rsconcept/rstool';
21
+
22
+ const tool = new RSToolAgent();
23
+ const session = tool.createSession();
24
+ const result = tool.analyzeExpression(session.sessionId, {
25
+ expression: '1+2',
26
+ cstType: CstType.TERM
27
+ });
28
+ ```
29
+
30
+ ## Quick use (stdio wrapper)
31
+
32
+ ```bash
33
+ npx rstool-wrapper # one JSON request per line on stdin, one JSON response per line on stdout
34
+ ```
35
+
36
+ Or run it as a child process from your own code:
37
+
38
+ ```ts
39
+ import { RSToolWrapperClient } from '@rsconcept/rstool/wrapper';
40
+
41
+ const client = new RSToolWrapperClient(); // spawns `rstool-wrapper` by default
42
+ await client.waitUntilReady();
43
+ const session = await client.call<{ sessionId: string }>('createSession');
44
+ await client.close();
45
+ ```
46
+
47
+ ## Scope
48
+
49
+ - Session-based incremental editing of constituents.
50
+ - Parse / syntax / semantic / type analysis for expressions.
51
+ - In-memory modeling: set base bindings and structured values; evaluate expressions and constituents.
52
+ - Deterministic diagnostics and export/import for reproducible agent workflows.
53
+ - Library API + stdio JSON wrapper as the only supported transports (MCP adapter lives in [`@rsconcept/rstool-mcp`](../rstool-mcp/)).
54
+
55
+ ## Repo scripts
56
+
57
+ This package is part of the [Concept Portal](https://github.com/IRBorisov/ConceptPortal) npm workspaces. From the repo root:
58
+
59
+ - `npm install` — install all workspaces (`@rsconcept/domain`, `frontend`, `@rsconcept/rstool`)
60
+ - `npm run typecheck -w @rsconcept/rstool`
61
+ - `npm test -w @rsconcept/rstool`
62
+ - `npm run build -w @rsconcept/rstool` — produce `dist/` via tsup
63
+ - `npm run wrapper -w @rsconcept/rstool` — dev stdio wrapper via `tsx`
64
+ - `npm run example:client -w @rsconcept/rstool`, `npm run example:build-schema -w @rsconcept/rstool`, `npm run example:build-rsmodel -w @rsconcept/rstool`
65
+
66
+ ## Stdio protocol
67
+
68
+ - Input: one JSON request per line.
69
+ - Output: one JSON response per line.
70
+ - The wrapper keeps state in memory while the process is alive.
71
+ - On startup, a ready handshake is printed.
72
+
73
+ Supported methods (current contract version: see [`CONTRACT_VERSION`](src/models/tool-contract.ts)):
74
+
75
+ - `ping`
76
+ - `methods`
77
+ - `createSession`
78
+ - `addOrUpdateConstituenta`
79
+ - `analyzeExpression`
80
+ - `getFormState`
81
+ - `listDiagnostics`
82
+ - `commitStep`
83
+ - `exportSession`
84
+ - `importSession`
85
+ - `setConstituentaValue`
86
+ - `setConstituentaValues`
87
+ - `clearConstituentaValues`
88
+ - `getModelState`
89
+ - `evaluateExpression`
90
+ - `evaluateConstituenta`
91
+ - `recalculateModel`
92
+
93
+ Example request:
94
+
95
+ ```json
96
+ { "id": "1", "method": "createSession", "params": {} }
97
+ ```
98
+
99
+ Example response:
100
+
101
+ ```json
102
+ { "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "1.2.0" } }
103
+ ```
104
+
105
+ ## Typed client example
106
+
107
+ Run:
108
+
109
+ ```bash
110
+ npm run example:client -w @rsconcept/rstool
111
+ ```
112
+
113
+ File: [`examples/agent-client.ts`](examples/agent-client.ts)
114
+
115
+ The example:
116
+
117
+ - starts the stdio wrapper as a child process
118
+ - waits for the ready handshake
119
+ - creates a session
120
+ - upserts a constituent
121
+ - runs expression analysis
122
+ - sets a base binding and evaluates a term
123
+ - fetches diagnostics
124
+
125
+ ## Installing the skill into an agent host
126
+
127
+ The package ships the skill files in `skills/rstool-helper/`. After install, copy or symlink them into your agent host's skill directory:
128
+
129
+ ```bash
130
+ # Cursor (per-project skills)
131
+ mkdir -p .agents/skills
132
+ cp -r node_modules/@rsconcept/rstool/skills/rstool-helper .agents/skills/rstool-helper
133
+ cp -r node_modules/@rsconcept/rstool/docs .agents/skills/rstool-helper/docs
134
+
135
+ # Claude Code or other hosts: consult host-specific docs
136
+ ```
137
+
138
+ PowerShell:
139
+
140
+ ```powershell
141
+ New-Item -ItemType Directory -Force .agents/skills
142
+ Copy-Item -Recurse -Force node_modules/@rsconcept/rstool/skills/rstool-helper .agents/skills/rstool-helper
143
+ Copy-Item -Recurse -Force node_modules/@rsconcept/rstool/docs .agents/skills/rstool-helper/docs
144
+ ```
145
+
146
+ The skill defers to the bundled `docs/*.md` for language reference. Copying both the skill and docs makes the installed agent skill self-contained.
147
+
148
+ ## License
149
+
150
+ MIT
@@ -0,0 +1,15 @@
1
+ export { DomainAnalysisLike, DomainErrorLike, toPublicAnalysis, toPublicError } from './mappers/types.js';
2
+ export { AnalysisResult, AnalyzeExpressionInput } from './models/analysis.js';
3
+ export { RSToolErrorDescription, RSToolValue } from './models/common.js';
4
+ export { AddOrUpdateConstituentaInput, AddOrUpdateConstituentaResult, ConstituentaDraft, ConstituentaState } from './models/constituenta.js';
5
+ export { DiagnosticRecord, ListDiagnosticsFilters } from './models/diagnostic.js';
6
+ export { EvaluateConstituentaInput, EvaluateExpressionInput, EvaluationResult } from './models/evaluation.js';
7
+ export { ClearConstituentaValuesInput, ModelValueState, RecalculateModelResult, SessionModelState, SetConstituentaValueInput, SetConstituentaValuesInput } from './models/model-value.js';
8
+ export { RSToolAgent } from './models/rstool-agent.js';
9
+ export { SessionHandle, SessionRevision, SessionState } from './models/session.js';
10
+ export { CONTRACT_VERSION, RSToolAgentContract } from './models/tool-contract.js';
11
+ export { RSToolWrapperClient, RSToolWrapperClientOptions, WrapperResponse } from './wrapper/client.js';
12
+ export { BasicBinding, EvalStatus } from '@rsconcept/domain/library/rsmodel';
13
+ export { CstType } from '@rsconcept/domain/library/rsform';
14
+ export { RSErrorCode } from '@rsconcept/domain/rslang/error';
15
+ export { ValueClass } from '@rsconcept/domain/rslang';