@radicaltools/cli 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +273 -2
- package/dist/index.js +3756 -0
- package/package.json +40 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 radical.tools 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
CHANGED
|
@@ -1,3 +1,274 @@
|
|
|
1
|
-
#
|
|
1
|
+
# radical CLI
|
|
2
|
+
|
|
3
|
+
The `radical` command line for Radical Markdown model folders.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Requires Node.js 20.11 or later and Git for `diff` and `hooks`.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g @radicaltools/cli
|
|
11
|
+
radical --help
|
|
12
|
+
radical check path/to/model
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or run it without a global install:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx @radicaltools/cli check path/to/model
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## radical diff
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
radical diff path/to/model [--since <ref>] [--format json]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Lists what changed in the model folder since its version in git: the
|
|
28
|
+
elements and relations added, removed and changed, uncommitted edits
|
|
29
|
+
included, with each changed field's old and new value and each element's
|
|
30
|
+
place and relations (the component that satisfies a requirement, the
|
|
31
|
+
scenarios that verify it, the ADRs that constrain it). Only the model is
|
|
32
|
+
compared; views, positions, sizes and folding are left out. By default it
|
|
33
|
+
compares with the merge base of the current branch and the default branch
|
|
34
|
+
(`origin/main`, else `main`), so it shows every model change on the branch;
|
|
35
|
+
`--since HEAD` shows what changed since the last commit. The MCP server's
|
|
36
|
+
`get_changes` tool gives the same list to an agent that implements the
|
|
37
|
+
change. Exit status: 0 the list was written, 2 it could not be made (not a
|
|
38
|
+
git repository, an unknown ref).
|
|
39
|
+
|
|
40
|
+
`--save-base` also writes the model at the base (its elements and relations,
|
|
41
|
+
the commit, the branch and the time) to `.radical/base.json` in the folder,
|
|
42
|
+
out of git like the rest of `.radical/`. Studio has no git: it compares the
|
|
43
|
+
open model with that file as it is edited and shows the changes with
|
|
44
|
+
Changes on branch, in the list of views, on the properties card and in the
|
|
45
|
+
Inspector. `--quiet` prints nothing.
|
|
46
|
+
|
|
47
|
+
When the base is saved: a checkout (`post-checkout`), a commit
|
|
48
|
+
(`post-commit`), a pull or merge (`post-merge`), a rebase or an amend
|
|
49
|
+
(`post-rewrite`) once `radical hooks install` has added the hooks; an
|
|
50
|
+
agent's `get_changes` without `since`; and `radical diff --save-base` by
|
|
51
|
+
hand. A fetch, a reset or a stash saves nothing. Committing on a branch keeps
|
|
52
|
+
the base (the list is the whole branch); after the merge, switching to
|
|
53
|
+
`main` and pulling empties it. `--save-base --since HEAD` makes the last
|
|
54
|
+
commit the base, to list only what is not committed.
|
|
55
|
+
|
|
56
|
+
## radical hooks
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
radical hooks install path/to/model
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Adds one marked line to the repository's `post-checkout`, `post-commit`,
|
|
63
|
+
`post-merge` and `post-rewrite` hooks that runs `radical diff <folder> --save-base --quiet`, so
|
|
64
|
+
the base Studio compares with follows the branch checked out. What the hooks
|
|
65
|
+
already do stays, a second install adds nothing (or brings the line up to
|
|
66
|
+
date when the CLI or node moved), and the line never fails the git command.
|
|
67
|
+
It runs the CLI that installed it, with the `node` on the PATH, else the one
|
|
68
|
+
that installed it. In this repository `npm run hooks` builds the CLI,
|
|
69
|
+
installs the hooks for `architecture/` and saves its base once.
|
|
70
|
+
|
|
71
|
+
## radical check
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
radical check path/to/model
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Checks one model folder and prints what it finds:
|
|
78
|
+
|
|
79
|
+
- **the folder**: a valid `radical.md`, JSON sidecars that parse, no git
|
|
80
|
+
conflict markers, node files with an id and a type, no duplicate ids, and
|
|
81
|
+
views, sequences and slides that point at things the model has;
|
|
82
|
+
- **the metamodel**: the Validation list Studio shows and `get_issues`
|
|
83
|
+
returns over MCP, with the same severities;
|
|
84
|
+
- **completeness**: requirements verified by a scenario, satisfied by an
|
|
85
|
+
element, derived from a need; needs with requirements; accepted ADRs with
|
|
86
|
+
a fitness function and their date, context, decision and consequences;
|
|
87
|
+
fitness functions linked and with a threshold.
|
|
88
|
+
|
|
89
|
+
With test reports it also checks that the tests the model names passed (see
|
|
90
|
+
below). `radical check --list-rules` lists every rule and every metric a goal can
|
|
91
|
+
be set for. It reads the files only and never writes the model.
|
|
92
|
+
|
|
93
|
+
Exit status: 0 no errors (warnings allowed), 1 errors, 2 the check could not
|
|
94
|
+
run. `--format json` prints the result as JSON, `--format github` as GitHub
|
|
95
|
+
Actions annotations.
|
|
96
|
+
|
|
97
|
+
### Config
|
|
98
|
+
|
|
99
|
+
`check.json` in the model folder (or `--config <file>`) sets
|
|
100
|
+
rules by id, or one kind of metamodel issue by `metamodel/<code>`:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"rules": {
|
|
105
|
+
"metamodel": "error",
|
|
106
|
+
"adr-incomplete": "off",
|
|
107
|
+
"requirement-without-scenario": { "severity": "error", "max": 104 }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
With `max`, up to that many findings pass as warnings and one more fails the
|
|
113
|
+
check, so an existing model can adopt a rule before every gap is closed.
|
|
114
|
+
`--ratchet` lowers each `max` to the count found now and writes the config
|
|
115
|
+
back; it never raises one.
|
|
116
|
+
|
|
117
|
+
### Goals
|
|
118
|
+
|
|
119
|
+
`goals` sets the least share, in percent, of a metric: requirements with a
|
|
120
|
+
scenario, accepted ADRs with a fitness function, and with `--report`
|
|
121
|
+
requirements and ADRs verified, scenarios passing, tests the model names, …
|
|
122
|
+
(`--list-rules` lists them all):
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"goals": {
|
|
127
|
+
"requirements-with-scenario": { "min": 85 },
|
|
128
|
+
"requirements-verified": { "min": 80 }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
A metric below its goal is a finding of `goal-unmet`, an error unless the
|
|
134
|
+
config sets that rule (or `goal-unmet/<metric>`) otherwise. A metric of the
|
|
135
|
+
test reports counts only with `--report`. Where `max` says how many gaps a
|
|
136
|
+
rule may have, a goal says how much of the model must be covered, so it keeps
|
|
137
|
+
its meaning as the model grows.
|
|
138
|
+
|
|
139
|
+
### Tests no scenario names
|
|
140
|
+
|
|
141
|
+
`test-unbound` lists, per test file, the tests no scenario or fitness function
|
|
142
|
+
names. It looks only at the files its `include` matches, so that unit tests of
|
|
143
|
+
internals stay out of it; a scenario has to name a test by its title or its
|
|
144
|
+
describe block, since a fitness function that names a whole file or directory
|
|
145
|
+
(`apps/e2e/tests`) is an umbrella over many behaviours:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{ "rules": { "test-unbound": { "severity": "warning", "include": ["apps/e2e/**"], "exclude": ["**/known-issues.spec.ts"] } } }
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`--verbose` and the Inspector list the titles of those tests.
|
|
152
|
+
|
|
153
|
+
### Tests and evidence
|
|
154
|
+
|
|
155
|
+
A scenario or a fitness function names the tests that run it in its `tests`
|
|
156
|
+
property, one per line, as Vitest and Playwright print them:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
apps/cli/src/cli.test.ts › radical check › prints the result as JSON
|
|
160
|
+
apps/e2e/tests/studio/forge.spec.ts › Forge files each stage into its view
|
|
161
|
+
packages/layout/tests/geometry.test.ts › createBatchPlacer
|
|
162
|
+
apps/e2e/tests
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
An id names the test whose title it ends, otherwise every test in the
|
|
166
|
+
describe block it starts; one without a title names every test in a file or
|
|
167
|
+
directory. File paths match by suffix, so absolute paths in a report and
|
|
168
|
+
workspace-relative ones in a JUnit file both do.
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
npx vitest run --reporter=json --outputFile=reports/unit.json
|
|
172
|
+
npx playwright test --reporter=json > reports/e2e.json
|
|
173
|
+
radical check model --report reports --evidence evidence.json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`--report` takes Vitest or Jest JSON, Playwright JSON and JUnit XML, or a
|
|
177
|
+
directory of them (its .json and .xml files), and may be repeated.
|
|
178
|
+
|
|
179
|
+
In this repository `npm run test:reports` runs every workspace's tests and
|
|
180
|
+
leaves a report per workspace in `reports/`, the e2e suite adds
|
|
181
|
+
`reports/e2e.json`, and `npm run check:architecture` checks the local
|
|
182
|
+
`architecture/` model against them. CI keeps `reports/` as the
|
|
183
|
+
`test-reports` artifact (and `reports/e2e.json` in `e2e-report`). A named
|
|
184
|
+
test that failed or is gone from the report of its file (renamed, deleted)
|
|
185
|
+
is an error; one that was skipped, or whose file no report has, a warning.
|
|
186
|
+
The text output sums up how many requirements, scenarios, ADRs and fitness
|
|
187
|
+
functions the reports verify. `--evidence` writes that status per element
|
|
188
|
+
as JSON (`verified`, `broken`, `unverified` for requirements and ADRs;
|
|
189
|
+
`passed`, `failed`, `not-run`, `no-tests` for scenarios and fitness
|
|
190
|
+
functions); it never writes into the model.
|
|
191
|
+
|
|
192
|
+
With `--report` the command also keeps the test cases it read in the model
|
|
193
|
+
folder's `.radical/test-results.json` (out of git, like the rest of
|
|
194
|
+
`.radical/`). Studio's Inspector perspective reads them and the model's
|
|
195
|
+
`check.json`, and runs the same check on the model as it is edited: Model
|
|
196
|
+
quality and Implementation show the result by dimension, and Settings edit
|
|
197
|
+
`check.json` (goals, severities, baselines), marking a change that loosens
|
|
198
|
+
the gate.
|
|
199
|
+
|
|
200
|
+
## Publishing (maintainers)
|
|
201
|
+
|
|
202
|
+
The public npm package is `@radicaltools/cli`. Its private `@radical/*`
|
|
203
|
+
workspace dependencies are bundled into the build. The package ships only
|
|
204
|
+
`dist/`, this README, its manifest and the MIT license.
|
|
205
|
+
|
|
206
|
+
From the repository root, install dependencies and validate the release:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
npm ci --ignore-scripts
|
|
210
|
+
npm run typecheck -w @radicaltools/cli
|
|
211
|
+
npm run test -w @radicaltools/cli
|
|
212
|
+
npm run test:package -w @radicaltools/cli -- --out-dir ../../release
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The package check builds and packs the CLI, installs the tarball offline into
|
|
216
|
+
a temporary project outside the monorepo, and runs the installed command to
|
|
217
|
+
verify its version, help and model checks. Only after validation does it copy
|
|
218
|
+
the verified tarball into `release/`. Temporary files are removed afterwards.
|
|
219
|
+
|
|
220
|
+
Log in with an npm account authorized to publish in the `radicaltools`
|
|
221
|
+
organization, then publish the verified first-release tarball:
|
|
222
|
+
|
|
223
|
+
```sh
|
|
224
|
+
npm login --auth-type=web
|
|
225
|
+
npm whoami
|
|
226
|
+
npm publish ./release/radicaltools-cli-0.1.0.tgz --access public
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Complete npm's browser and 2FA prompts. When publishing directly from the
|
|
230
|
+
workspace, `prepublishOnly` runs the type check, unit tests and package check;
|
|
231
|
+
`prepack` builds fresh output and copies the root license. Publishing an
|
|
232
|
+
already verified tarball uploads that exact archive. The monorepo root and
|
|
233
|
+
the shared workspaces remain private.
|
|
234
|
+
|
|
235
|
+
For later releases, bump the CLI version and lockfile before publishing:
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
npm version patch -w @radicaltools/cli --no-git-tag-version
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Each package version can be published only once. After the first publish,
|
|
242
|
+
the npm organization's team settings can grant the `developers` team
|
|
243
|
+
read/write access to `@radicaltools/cli`.
|
|
244
|
+
|
|
245
|
+
### GitHub Actions with Trusted Publishing
|
|
246
|
+
|
|
247
|
+
The **Publish CLI to npm** workflow (`.github/workflows/cli-publish.yml`)
|
|
248
|
+
follows the MCP release workflow. After `@radicaltools/cli` exists on npm,
|
|
249
|
+
open its **Settings → Trusted publishing** and add GitHub Actions:
|
|
250
|
+
|
|
251
|
+
| Field | Value |
|
|
252
|
+
| --- | --- |
|
|
253
|
+
| Organization or user | `radicaltools` |
|
|
254
|
+
| Repository | `radical.tools` |
|
|
255
|
+
| Workflow filename | `cli-publish.yml` |
|
|
256
|
+
| Environment name | Leave empty |
|
|
257
|
+
| Allowed actions | Enable direct publishing with `npm publish` |
|
|
258
|
+
|
|
259
|
+
Configure this on the CLI package: the MCP package's trusted publisher does
|
|
260
|
+
not authorize CLI releases. No npm token or GitHub secret is needed. The
|
|
261
|
+
workflow uses Node 24 and npm 11, with `id-token: write` for its publish job.
|
|
262
|
+
See [npm's Trusted Publishing instructions](https://docs.npmjs.com/trusted-publishers/).
|
|
263
|
+
|
|
264
|
+
Push and merge these changes first. In GitHub **Actions → Publish CLI to npm
|
|
265
|
+
→ Run workflow**, select `main` and leave **dry-run** enabled to validate
|
|
266
|
+
and upload the npm archive without releasing. After a reviewed version bump,
|
|
267
|
+
run with **dry-run** disabled to publish. A package version can only be
|
|
268
|
+
published once, so bump past any version already published locally.
|
|
269
|
+
|
|
270
|
+
The workflow type-checks and tests the monorepo, installs and checks the CLI
|
|
271
|
+
tarball outside the repository, uploads that archive as an artifact, and
|
|
272
|
+
publishes the same archive with provenance. Publishing is refused outside
|
|
273
|
+
`main`; branch pushes and desktop release tags do not publish the CLI.
|
|
2
274
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|