@radicaltools/cli 0.0.0-stage → 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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +368 -2
  3. package/dist/index.js +8105 -0
  4. package/package.json +41 -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,369 @@
1
- # Temporary Holding Version
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 export confluence
22
+
23
+ Export a particular wiki view from a Radical Markdown model folder. The full
24
+ view is exported, including its filter chain (for example, requirements with
25
+ their verifying scenarios), readable requirement sentences, Markdown fields
26
+ and links between elements. The last focused page and Single/Multi page reading
27
+ mode do not truncate the export. Local exports are complete documents.
28
+ Publishing defaults to a **page tree**: a landing page, requirement pages,
29
+ then their verifying scenario pages (or the selected view's own hierarchy).
30
+ A shared element has one page beneath its first parent and links from every
31
+ other parent. `--structure document` publishes one document instead.
32
+
33
+ Studio and the CLI use the same pure `@radical/common/wikiDocument` content
34
+ builder for view scope, hierarchy, visible fields, requirement prose and
35
+ relationships. React renders editors; the CLI serializes the document and
36
+ publishes it through the Confluence adapter.
37
+
38
+ Find a view and preview it without Confluence credentials:
39
+
40
+ ```sh
41
+ radical export confluence architecture --list-views
42
+ radical export confluence architecture --view "Tes confluence" --format html --output wiki-preview.html
43
+ radical export confluence architecture --view "Tes confluence" --format markdown --output wiki.md
44
+ ```
45
+
46
+ `--view` accepts an exact view ID or an unambiguous name. `--format storage`
47
+ (the default) produces Confluence storage XHTML; `markdown` produces a portable
48
+ document and `html` a standalone browser preview. Without `--output`, local
49
+ exports go to stdout. Output files must be outside the model folder; existing
50
+ files are never overwritten. `--source-url` adds a link back to the source
51
+ model or Studio wiki, and `--title` overrides the document/page title.
52
+
53
+ To publish to Confluence Cloud, set `CONFLUENCE_URL`, `CONFLUENCE_EMAIL` and
54
+ `CONFLUENCE_API_TOKEN` in your shell or CI secret environment, then run:
55
+
56
+ ```sh
57
+ radical export confluence architecture --view "Tes confluence" --publish --space-id 123 --parent-id 456
58
+ ```
59
+
60
+ Use the numeric space ID, not its key. `--parent-id` is optional. `--url` can
61
+ override `CONFLUENCE_URL`; use a site URL such as `https://company.atlassian.net`
62
+ or `https://company.atlassian.net/wiki`. Use an Atlassian API token suitable
63
+ for basic authentication at that site and an account that can read and
64
+ create/update pages in the space.
65
+
66
+ To use a token kept under another environment variable name, add
67
+ `--token-env TEST_WORKSPACE_ATTLASIAN_KEY` (or your chosen variable name).
68
+
69
+ The command creates a landing page with the wiki's name, then finds and
70
+ refreshes it on subsequent runs. Every element page carries its own export
71
+ marker. Stable element-to-page IDs live in small content-property buckets
72
+ on the landing page, so renames preserve page IDs and publication can resume
73
+ on another computer. Publication first creates or recovers every destination,
74
+ preserving existing bodies and marking new pages as publication in progress.
75
+ Once all destinations exist, it fills their linked content and writes the
76
+ landing page last. Up to four writes run concurrently, with checkpoints
77
+ between batches. A failed run prints the landing page ID for resuming with
78
+ `--page-id 789`. A title collision with a handwritten page fails without
79
+ changing it. Updates verify ownership, use the current Confluence version
80
+ and report concurrent-edit conflicts. Rate-limit responses get bounded retries;
81
+ uncertain network failures are not retried automatically.
82
+
83
+ To move an existing managed export under another page, pass its root page
84
+ ID with `--parent-id`; its children follow it:
85
+
86
+ ```sh
87
+ radical export confluence architecture --view "Tes confluence" --publish --page-id 789 --parent-id 456
88
+ ```
89
+
90
+ Use a destination parent in the same Confluence space. Changing the view's
91
+ hierarchy also moves its managed element pages on the next publication.
92
+ Elements removed from the view are reported and their old pages are retained.
93
+
94
+ **Radical remains the source of truth.** Publishing replaces the managed
95
+ page's body, including edits made to that body in Confluence. It does not
96
+ import Confluence changes, write source model files, or delete pages. A
97
+ source-of-truth notice and optional source link sit at the bottom of every
98
+ exported page, in a native Confluence Info panel (a note in HTML previews and
99
+ a blockquote in Markdown). Unchanged element pages
100
+ are skipped when their source hash and published Confluence version match.
101
+ Exports made by the earlier single-pass publisher are refreshed once to resolve
102
+ their forward links before unchanged pages can be skipped again.
103
+ Switching from tree to document leaves previously published child pages in
104
+ place. Absolute HTTP(S) image URLs are preserved; local
105
+ images and interactive mockup wireframes are not uploaded, and the command
106
+ reports unsupported assets. Data Center is not supported in this version.
107
+
108
+ Exit status: 0 exported/published, 2 could not export/publish. Credentials
109
+ are not accepted as command-line arguments or included in error output.
110
+ The transport follows Atlassian's [Cloud page API](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/).
111
+
112
+ ## radical diff
113
+
114
+ ```sh
115
+ radical diff path/to/model [--since <ref>] [--format json]
116
+ ```
117
+
118
+ Lists what changed in the model folder since its version in git: the
119
+ elements and relations added, removed and changed, uncommitted edits
120
+ included, with each changed field's old and new value and each element's
121
+ place and relations (the component that satisfies a requirement, the
122
+ scenarios that verify it, the ADRs that constrain it). Only the model is
123
+ compared; views, positions, sizes and folding are left out. By default it
124
+ compares with the merge base of the current branch and the default branch
125
+ (`origin/main`, else `main`), so it shows every model change on the branch;
126
+ `--since HEAD` shows what changed since the last commit. The MCP server's
127
+ `get_changes` tool gives the same list to an agent that implements the
128
+ change. Exit status: 0 the list was written, 2 it could not be made (not a
129
+ git repository, an unknown ref).
130
+
131
+ `--save-base` also writes the model at the base (its elements and relations,
132
+ the commit, the branch and the time) to `.radical/base.json` in the folder,
133
+ out of git like the rest of `.radical/`. Studio has no git: it compares the
134
+ open model with that file as it is edited and shows the changes with
135
+ Changes on branch, in the list of views, on the properties card and in the
136
+ Inspector. `--quiet` prints nothing.
137
+
138
+ When the base is saved: a checkout (`post-checkout`), a commit
139
+ (`post-commit`), a pull or merge (`post-merge`), a rebase or an amend
140
+ (`post-rewrite`) once `radical hooks install` has added the hooks; an
141
+ agent's `get_changes` without `since`; and `radical diff --save-base` by
142
+ hand. A fetch, a reset or a stash saves nothing. Committing on a branch keeps
143
+ the base (the list is the whole branch); after the merge, switching to
144
+ `main` and pulling empties it. `--save-base --since HEAD` makes the last
145
+ commit the base, to list only what is not committed.
146
+
147
+ ## radical hooks
148
+
149
+ ```sh
150
+ radical hooks install path/to/model
151
+ ```
152
+
153
+ Adds one marked line to the repository's `post-checkout`, `post-commit`,
154
+ `post-merge` and `post-rewrite` hooks that runs `radical diff <folder> --save-base --quiet`, so
155
+ the base Studio compares with follows the branch checked out. What the hooks
156
+ already do stays, a second install adds nothing (or brings the line up to
157
+ date when the CLI or node moved), and the line never fails the git command.
158
+ It runs the CLI that installed it, with the `node` on the PATH, else the one
159
+ that installed it. In this repository `npm run hooks` builds the CLI,
160
+ installs the hooks for `architecture/` and saves its base once.
161
+
162
+ ## radical check
163
+
164
+ ```sh
165
+ radical check path/to/model
166
+ ```
167
+
168
+ Checks one model folder and prints what it finds:
169
+
170
+ - **the folder**: a valid `radical.md`, JSON sidecars that parse, no git
171
+ conflict markers, node files with an id and a type, no duplicate ids, and
172
+ views, sequences and slides that point at things the model has;
173
+ - **the metamodel**: the Validation list Studio shows and `get_issues`
174
+ returns over MCP, with the same severities;
175
+ - **completeness**: requirements verified by a scenario, satisfied by an
176
+ element, derived from a need; needs with requirements; accepted ADRs with
177
+ a fitness function and their date, context, decision and consequences;
178
+ fitness functions linked and with a threshold.
179
+
180
+ With test reports it also checks that the tests the model names passed (see
181
+ below). `radical check --list-rules` lists every rule and every metric a goal can
182
+ be set for. It reads the files only and never writes the model.
183
+
184
+ Exit status: 0 no errors (warnings allowed), 1 errors, 2 the check could not
185
+ run. `--format json` prints the result as JSON, `--format github` as GitHub
186
+ Actions annotations.
187
+
188
+ ### Config
189
+
190
+ `check.json` in the model folder (or `--config <file>`) sets
191
+ rules by id, or one kind of metamodel issue by `metamodel/<code>`:
192
+
193
+ ```json
194
+ {
195
+ "rules": {
196
+ "metamodel": "error",
197
+ "adr-incomplete": "off",
198
+ "requirement-without-scenario": { "severity": "error", "max": 104 }
199
+ }
200
+ }
201
+ ```
202
+
203
+ With `max`, up to that many findings pass as warnings and one more fails the
204
+ check, so an existing model can adopt a rule before every gap is closed.
205
+ `--ratchet` lowers each `max` to the count found now and writes the config
206
+ back; it never raises one.
207
+
208
+ ### Goals
209
+
210
+ `goals` sets the least share, in percent, of a metric: requirements with a
211
+ scenario, accepted ADRs with a fitness function, and with `--report`
212
+ requirements and ADRs verified, scenarios passing, tests the model names, …
213
+ (`--list-rules` lists them all):
214
+
215
+ ```json
216
+ {
217
+ "goals": {
218
+ "requirements-with-scenario": { "min": 85 },
219
+ "requirements-verified": { "min": 80 }
220
+ }
221
+ }
222
+ ```
223
+
224
+ A metric below its goal is a finding of `goal-unmet`, an error unless the
225
+ config sets that rule (or `goal-unmet/<metric>`) otherwise. A metric of the
226
+ test reports counts only with `--report`. Where `max` says how many gaps a
227
+ rule may have, a goal says how much of the model must be covered, so it keeps
228
+ its meaning as the model grows.
229
+
230
+ ### Tests no scenario names
231
+
232
+ `test-unbound` lists, per test file, the tests no scenario or fitness function
233
+ names. It looks only at the files its `include` matches, so that unit tests of
234
+ internals stay out of it; a scenario has to name a test by its title or its
235
+ describe block, since a fitness function that names a whole file or directory
236
+ (`apps/e2e/tests`) is an umbrella over many behaviours:
237
+
238
+ ```json
239
+ { "rules": { "test-unbound": { "severity": "warning", "include": ["apps/e2e/**"], "exclude": ["**/known-issues.spec.ts"] } } }
240
+ ```
241
+
242
+ `--verbose` and the Inspector list the titles of those tests.
243
+
244
+ ### Tests and evidence
245
+
246
+ A scenario or a fitness function names the tests that run it in its `tests`
247
+ property, one per line, as Vitest and Playwright print them:
248
+
249
+ ```
250
+ apps/cli/src/cli.test.ts › radical check › prints the result as JSON
251
+ apps/e2e/tests/studio/forge.spec.ts › Forge files each stage into its view
252
+ packages/layout/tests/geometry.test.ts › createBatchPlacer
253
+ apps/e2e/tests
254
+ ```
255
+
256
+ An id names the test whose title it ends, otherwise every test in the
257
+ describe block it starts; one without a title names every test in a file or
258
+ directory. File paths match by suffix, so absolute paths in a report and
259
+ workspace-relative ones in a JUnit file both do.
260
+
261
+ ```sh
262
+ npx vitest run --reporter=json --outputFile=reports/unit.json
263
+ npx playwright test --reporter=json > reports/e2e.json
264
+ radical check model --report reports --evidence evidence.json
265
+ ```
266
+
267
+ `--report` takes Vitest or Jest JSON, Playwright JSON and JUnit XML, or a
268
+ directory of them (its .json and .xml files), and may be repeated.
269
+
270
+ In this repository `npm run test:reports` runs every workspace's tests and
271
+ leaves a report per workspace in `reports/`, the e2e suite adds
272
+ `reports/e2e.json`, and `npm run check:architecture` checks the local
273
+ `architecture/` model against them. CI keeps `reports/` as the
274
+ `test-reports` artifact (and `reports/e2e.json` in `e2e-report`). A named
275
+ test that failed or is gone from the report of its file (renamed, deleted)
276
+ is an error; one that was skipped, or whose file no report has, a warning.
277
+ The text output sums up how many requirements, scenarios, ADRs and fitness
278
+ functions the reports verify. `--evidence` writes that status per element
279
+ as JSON (`verified`, `broken`, `unverified` for requirements and ADRs;
280
+ `passed`, `failed`, `not-run`, `no-tests` for scenarios and fitness
281
+ functions); it never writes into the model.
282
+
283
+ With `--report` the command also keeps the test cases it read in the model
284
+ folder's `.radical/test-results.json` (out of git, like the rest of
285
+ `.radical/`). Studio's Inspector perspective reads them and the model's
286
+ `check.json`, and runs the same check on the model as it is edited: Model
287
+ quality and Implementation show the result by dimension, and Settings edit
288
+ `check.json` (goals, severities, baselines), marking a change that loosens
289
+ the gate.
290
+
291
+ ## Publishing (maintainers)
292
+
293
+ The public npm package is `@radicaltools/cli`. Its private `@radical/*`
294
+ workspace dependencies are bundled into the build. The package ships only
295
+ `dist/`, this README, its manifest and the MIT license.
296
+
297
+ From the repository root, install dependencies and validate the release:
298
+
299
+ ```sh
300
+ npm ci --ignore-scripts
301
+ npm run typecheck -w @radicaltools/cli
302
+ npm run test -w @radicaltools/cli
303
+ npm run test:package -w @radicaltools/cli -- --out-dir ../../release
304
+ ```
305
+
306
+ The package check builds and packs the CLI, installs the tarball offline into
307
+ a temporary project outside the monorepo, and runs the installed command to
308
+ verify its version, help and model checks. Only after validation does it copy
309
+ the verified tarball into `release/`. Temporary files are removed afterwards.
310
+
311
+ Log in with an npm account authorized to publish in the `radicaltools`
312
+ organization, then publish the verified first-release tarball:
313
+
314
+ ```sh
315
+ npm login --auth-type=web
316
+ npm whoami
317
+ npm publish ./release/radicaltools-cli-0.2.0.tgz --access public
318
+ ```
319
+
320
+ Complete npm's browser and 2FA prompts. When publishing directly from the
321
+ workspace, `prepublishOnly` runs the type check, unit tests and package check;
322
+ `prepack` builds fresh output and copies the root license. Publishing an
323
+ already verified tarball uploads that exact archive. The monorepo root and
324
+ the shared workspaces remain private.
325
+
326
+ For later releases, bump the CLI version and lockfile before publishing:
327
+
328
+ ```sh
329
+ npm version patch -w @radicaltools/cli --no-git-tag-version
330
+ ```
331
+
332
+ Each package version can be published only once. After the first publish,
333
+ the npm organization's team settings can grant the `developers` team
334
+ read/write access to `@radicaltools/cli`.
335
+
336
+ ### GitHub Actions with Trusted Publishing
337
+
338
+ The shared **Publish to npm** workflow (`.github/workflows/npm-publish.yml`)
339
+ publishes either CLI or MCP. After `@radicaltools/cli` exists on npm,
340
+ open its **Settings → Trusted publishing** and add GitHub Actions:
341
+
342
+ | Field | Value |
343
+ | --- | --- |
344
+ | Organization or user | `radicaltools` |
345
+ | Repository | `radical.tools` |
346
+ | Workflow filename | `npm-publish.yml` |
347
+ | Environment name | Leave empty |
348
+ | Allowed actions | Enable direct publishing with `npm publish` |
349
+
350
+ Configure this on each npm package that uses the workflow. If a trusted
351
+ publisher points at `cli-publish.yml` or `mcp-publish.yml`, replace it with
352
+ one using `npm-publish.yml` after merging this change. No npm token or GitHub
353
+ secret is needed. The workflow uses Node 24 and npm 11, with `id-token: write`
354
+ for its publish job.
355
+ Configure a new publisher when a release is ready: its first successful
356
+ publish must happen within two days; a dry run does not validate it.
357
+ See [npm's Trusted Publishing instructions](https://docs.npmjs.com/trusted-publishers/).
358
+
359
+ Push and merge these changes first. In GitHub **Actions → Publish to npm
360
+ → Run workflow**, select `main`, choose **package: cli**, and leave **dry-run**
361
+ enabled to validate and upload the npm archive without releasing. After a reviewed version bump,
362
+ run with **dry-run** disabled to publish. A package version can only be
363
+ published once, so bump past any version already published locally.
364
+
365
+ The workflow type-checks and tests the monorepo, installs and checks the CLI
366
+ tarball outside the repository, uploads that archive as an artifact, and
367
+ publishes the same archive with provenance. Publishing is refused outside
368
+ `main`; branch pushes and desktop release tags do not publish the CLI.
2
369
 
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.