@modeldesk/cli 0.7.0 → 0.8.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/README.md +144 -50
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/modeldesk.js +224 -220
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -70,15 +70,16 @@ modeldesk el bulk <model[@ref]> --where <criterion>... [--set <attr=value>
|
|
|
70
70
|
every el write takes -m <message> [--request-id <id>] [--commit [--with-staged]]
|
|
71
71
|
|
|
72
72
|
modeldesk search <model[@ref]> <text> [--type <type>] [--internal]
|
|
73
|
-
modeldesk describe <model> [<type>] [--internal]
|
|
73
|
+
modeldesk describe <model[@ref]> [<type>] [--internal]
|
|
74
74
|
modeldesk validate <model[@ref]> [--fail-on error|warning] [--limit <n>]
|
|
75
75
|
|
|
76
76
|
modeldesk draft open <model@branch>
|
|
77
|
-
modeldesk draft status <resource[@branch]>
|
|
77
|
+
modeldesk draft status <resource[@branch]> [--wait [--timeout <seconds>]]
|
|
78
78
|
modeldesk draft diff <resource[@branch]> [--changes]
|
|
79
79
|
modeldesk draft undo <resource[@branch]> [--any-surface]
|
|
80
80
|
modeldesk draft commit <resource[@branch]> [-m <message>] [--expect <draft-head>] [--any-surface]
|
|
81
81
|
modeldesk draft discard <resource[@branch]> [--any-surface]
|
|
82
|
+
modeldesk draft handoff <resource[@branch]> -m <summary>
|
|
82
83
|
modeldesk draft rebase <resource[@branch]> [--drop <change-id>]...
|
|
83
84
|
|
|
84
85
|
modeldesk branch list <model>
|
|
@@ -92,8 +93,10 @@ modeldesk branch merge <model@target> <source> [-m <message>] [--resolve <file|
|
|
|
92
93
|
modeldesk release create <model[@commit]> [--name <name>] [--description <text>]
|
|
93
94
|
modeldesk release list <model>
|
|
94
95
|
modeldesk release cascade <base> [--timeout <seconds>] [--instance-limit <n>] [--verify-all]
|
|
95
|
-
modeldesk pin list <model>
|
|
96
|
+
modeldesk pin list <model[@ref]>
|
|
96
97
|
modeldesk pin set <model> <dependency@release|main>
|
|
98
|
+
modeldesk dependency add <model[@ref]> <target@release|main>
|
|
99
|
+
modeldesk dependency rm <model[@ref]> <dependency>
|
|
97
100
|
```
|
|
98
101
|
|
|
99
102
|
A listing also takes `--limit <n>`, `--cursor <cursor>` and `--all`. `<model[@ref]>` is a model's
|
|
@@ -423,24 +426,26 @@ while it holds staged changes, and the head of your working branch otherwise.
|
|
|
423
426
|
| Argument of | Accepts | Without a ref |
|
|
424
427
|
| ---------------------------------------------------------- | ------------------------------------- | ----------------------------------- |
|
|
425
428
|
| `model tree`, `el show`, `search` | `@draft`, `@head`, a branch, a commit | Working |
|
|
426
|
-
| `model show`, `validate`
|
|
429
|
+
| `model show`, `validate`, `describe`, `pin list` | `@draft`, `@head`, a branch | Working |
|
|
427
430
|
| `model log` | `@draft`, `@head`, a branch | The working branch head |
|
|
428
|
-
| every `el` write, `model pull`
|
|
431
|
+
| every `el` and `dependency` write, `model pull` | `@draft`, `@head`, a branch | Working |
|
|
429
432
|
| `branch create` (the branch to start from), `branch diff` | `@head`, a branch | The working branch head |
|
|
430
433
|
| `draft open`, `branch delete`, `branch merge` (the target) | a branch | Required |
|
|
431
434
|
| the other `draft` commands | a branch, as an assertion | Your draft, wherever it aims |
|
|
432
435
|
| `release create` | a commit, which must be main's head | Main's head |
|
|
433
|
-
| `pin set` (the dependency)
|
|
436
|
+
| `pin set` (the dependency), `dependency add` (the target) | a release, or `@main` | Required |
|
|
434
437
|
| `--metamodel`, `--extension` | a release | The latest stable or newest release |
|
|
435
438
|
| the commands that read main | no ref | Main |
|
|
436
439
|
|
|
437
440
|
`model show` reads the model's identity and head at the ref. Its overview and releases are always
|
|
438
441
|
main's, and the result labels them so (`overview.ref`). The commands that read main are
|
|
439
|
-
`model export`, `model delete`, `
|
|
440
|
-
|
|
441
|
-
(`ref-unsupported`), so nothing reads main under an address that said otherwise. `
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
`model export`, `model delete`, `branch list`, `release list`, `release cascade` and
|
|
443
|
+
the model of `pin set`. They take no ref at all, `@main` included: a ref there exits 2
|
|
444
|
+
(`ref-unsupported`), so nothing reads main under an address that said otherwise. `model export`
|
|
445
|
+
encodes main only. When your draft aims at another branch, it says so in the `ref` block's `note`
|
|
446
|
+
(on stderr in text mode). `describe` reads the schema at its ref, since a dependency staged in your
|
|
447
|
+
draft brings the metamodel of its target into it, and the `el` writes plan against the schema at
|
|
448
|
+
the ref they write to.
|
|
444
449
|
|
|
445
450
|
A malformed address, a name where an id belongs, a ref the argument does not accept, a missing
|
|
446
451
|
required ref and an `@` on a dataset each exit 2 before any request. `@draft` without a draft, and a branch name the model does
|
|
@@ -540,6 +545,37 @@ working branch. They follow these rules:
|
|
|
540
545
|
the same one on every run, so `--request-id fix-42` and the id it reported retry alike. `model
|
|
541
546
|
create` has no idempotency key: after an exit 7, check `model list` before you retry.
|
|
542
547
|
|
|
548
|
+
### Add or remove a dependency
|
|
549
|
+
|
|
550
|
+
`dependency add <model[@ref]> <target>@<release|main>` stages a dependency on another model of the
|
|
551
|
+
organization, and `dependency rm <model[@ref]> <dependency>` stages the removal of one. Both follow
|
|
552
|
+
the rules of [a staged change](#stage-a-change) and take `-m`, `--request-id`, `--commit` and
|
|
553
|
+
`--with-staged` as an `el` write does.
|
|
554
|
+
|
|
555
|
+
- **The pin.** `<target>@<release>` pins that release. `<target>@main` pins the target's head as it is
|
|
556
|
+
when the change is staged, and it moves again only when you re-pin.
|
|
557
|
+
- **One change of its own.** The server checks the rest of a change against the dependencies, so a
|
|
558
|
+
dependency change is never sent beside another action. Stage the dependency first, then the
|
|
559
|
+
elements that refer to it. The schema follows: `describe` and the `el` writes read it at the ref,
|
|
560
|
+
so what the target's metamodel brings is there as soon as the dependency is staged.
|
|
561
|
+
- **A target the model already depends on is refused** (exit 4, `dependency-exists`) before anything
|
|
562
|
+
is sent, naming the dependency and the `pin set` that moves its pin, or, for one that is not on main
|
|
563
|
+
yet, the `dependency rm` to remove it and add it again. A target the model reaches only
|
|
564
|
+
through another dependency becomes a direct one in place and keeps its id (`promoted: true`).
|
|
565
|
+
- **`rm` names the dependency** by its id or its target model's id, from `pin list`. One whose content
|
|
566
|
+
the model's elements still refer to is refused (exit 4), with one entry per referring element in
|
|
567
|
+
`details.errors`. One that another dependency still brings along stays as a transitive dependency
|
|
568
|
+
(`outcome: 'kept-as-transitive'`). Managed, external and transitive dependencies are refused with
|
|
569
|
+
the reason.
|
|
570
|
+
- **`--dry-run` asks the server.** It sends the same change with `dryRun: true`: the server tries it
|
|
571
|
+
and keeps nothing, so a dry run exits with the refusal the change would meet.
|
|
572
|
+
- **`pin list <model>` shows the result.** It reads your draft while it holds staged changes, so a
|
|
573
|
+
staged dependency is listed before it is committed. `pin set` still moves a pin on main only, so
|
|
574
|
+
a dependency that exists only in your draft or on a branch is listed with `settable: false`.
|
|
575
|
+
|
|
576
|
+
Only dependencies on another model are staged. A dependency on an external document is added in the
|
|
577
|
+
app.
|
|
578
|
+
|
|
543
579
|
### Commit your draft
|
|
544
580
|
|
|
545
581
|
`draft commit <resource[@branch]>` lands every change the draft holds, whichever surface staged it.
|
|
@@ -580,6 +616,59 @@ own `-m`. The landing rules:
|
|
|
580
616
|
|
|
581
617
|
Under an agent host a landing has a gate of its own; see [The agent policy](#the-agent-policy).
|
|
582
618
|
|
|
619
|
+
### Hand off your draft for review
|
|
620
|
+
|
|
621
|
+
`draft handoff <model[@branch]> -m <summary>` marks your draft ready for review. The summary is stored
|
|
622
|
+
on the draft: the person's open model shows a notice with it, the panel header carries it, the commit
|
|
623
|
+
dialog starts from it, and the model list reads **Ready for review** even when the model is not open.
|
|
624
|
+
Nothing is staged and nothing is committed, and a second handoff replaces the first. `-m` is required
|
|
625
|
+
and is your own account of the draft, at most 2,000 characters, shown as plain text.
|
|
626
|
+
|
|
627
|
+
- A draft with no staged change exits 1 (`nothing-to-hand-off`). No draft exits 3.
|
|
628
|
+
- A draft that moved while it was handed off exits 5 (`draft-moved`), with nothing stored.
|
|
629
|
+
- `@<branch>` asserts where the draft aims, as on every draft command (exit 5, `draft-target-taken`).
|
|
630
|
+
- A dataset draft has no handoff (exit 2).
|
|
631
|
+
|
|
632
|
+
`draft status <model[@branch]> --wait` then waits for what the person does, on the model's change
|
|
633
|
+
stream, and reports it as `verdict` beside the status. Every verdict exits 0:
|
|
634
|
+
|
|
635
|
+
| `verdict` | What happened | Members |
|
|
636
|
+
| -------------- | ---------------------------------------------------------------------------------------------- | --------------------------- |
|
|
637
|
+
| `committed` | The draft landed with some of your changes | `commitId`, `url`, `landed` |
|
|
638
|
+
| `discarded` | None of your changes landed: the draft or its branch was discarded, or they were removed first | none |
|
|
639
|
+
| `changed` | A change was removed or undone, or the draft was rebased, in review | `changeCount` |
|
|
640
|
+
| `branch-moved` | The branch the draft aims at moved, or had already moved: rebase, then wait again | `branchHeadId` |
|
|
641
|
+
|
|
642
|
+
The person staging edits of their own is no verdict, and the wait goes on. A draft the branch had
|
|
643
|
+
already left behind when the wait began answers `branch-moved` at once, since it cannot be committed
|
|
644
|
+
before a rebase. Your changes are the draft's staged changes the CLI or an agent made, of your
|
|
645
|
+
session when one is set (see [The agent policy](#the-agent-policy)), listed by request id as the wait
|
|
646
|
+
begins; a rebase keeps them. A draft that holds none of them exits 1 with `type: no-own-changes`
|
|
647
|
+
before the wait begins, since no landing could hold one: wait from the session that staged them, or
|
|
648
|
+
read `draft diff <model>@<branch> --changes` to see where each change came from. The verdict is read
|
|
649
|
+
off the record each landing since the draft's baseline carries, so a colleague's landing is never
|
|
650
|
+
taken for yours.
|
|
651
|
+
|
|
652
|
+
`--timeout <seconds>` bounds the wait (600 when not given, a day at most). When it elapses, or the
|
|
653
|
+
stream cannot be re-established, the command exits 7 with `retryable: true`: run it again. When the
|
|
654
|
+
draft is gone but the landings cannot be read even after a few attempts, it exits 7 with
|
|
655
|
+
`type: verdict-unread`, and `model log --changes` shows whether your changes landed. No verdict exits
|
|
656
|
+
6, since the person acting in the app is the expected path; an authentication failure keeps its own
|
|
657
|
+
code. The stream ends with the access token that opened it, or after a minute without a frame, and the
|
|
658
|
+
CLI opens it again with a refreshed token. Every `heads` frame is compared with what the wait holds,
|
|
659
|
+
so an answer that falls between two connections is still seen. Datasets have no change stream, so
|
|
660
|
+
`--wait` takes a model.
|
|
661
|
+
|
|
662
|
+
```json
|
|
663
|
+
{
|
|
664
|
+
"draft": { "id": "…", "targetRefId": "…", "changeCount": 3, "target": { "id": "…", "name": "main" } },
|
|
665
|
+
"verdict": "committed",
|
|
666
|
+
"commitId": "98c4377f-8da2-438b-a54e-cebba0551168",
|
|
667
|
+
"url": "https://app.modeldesk.io/models/…/history/98c4377f-8da2-438b-a54e-cebba0551168",
|
|
668
|
+
"landed": 2
|
|
669
|
+
}
|
|
670
|
+
```
|
|
671
|
+
|
|
583
672
|
### See what a landing held
|
|
584
673
|
|
|
585
674
|
A commit landed from a draft records every change it landed: its request id, its message and its
|
|
@@ -929,15 +1018,16 @@ final. The table is frozen: codes are added, never renumbered, and 126, 127 and
|
|
|
929
1018
|
The HTTP status decides the code unless the problem type is one of the few the CLI maps itself
|
|
930
1019
|
(`PROBLEM_EXIT_CODES` in `src/http/client.ts`). The outcomes of drafts, branches and merges:
|
|
931
1020
|
|
|
932
|
-
| Code | Outcomes
|
|
933
|
-
| ---- |
|
|
934
|
-
| 0 | `branch merge` with nothing to merge (`outcome: 'already-merged'`); `branch merge --dry-run` that would land clean; `draft open` on a draft already there (`opened: false`); `branch create --exist-ok` on a taken name (`created: false`); `branch create` of a name outside `agent/` under an agent host, with a `note`
|
|
935
|
-
| 1 | `nothing-to-commit`; a landing without `--with-staged` over changes staged before the run; `ambiguous-merge-base`; a real merge the server refuses because the merged model would break a rule; a 403 for a missing token scope, the scope named; a `workspace.json` of format 1
|
|
936
|
-
| 2 | A malformed address; `id-required` (a name where an id belongs); a name that fits several things (a label path, a type, an organization), with `candidates` in `details`; a ref the argument does not accept, `ref-unsupported` included; a missing required ref; `@` on a dataset; a write at a commit; `branch delete` of `main`; `draft commit` without `-m` when no staged change carries a message, or on a dataset; a resolution file for another model or pair of branches; an entry left open without `--take-others`; `fields-unexpected`; `--take` or `--take-others` without both heads; `--dry-run` beside a resolution flag |
|
|
937
|
-
| 3 | `ref-not-found` (an unknown branch name, `@draft` without a draft); `branch-gone` (a workspace's branch was deleted)
|
|
938
|
-
| 4 | `change-validation-failed`, with a value that fits several attributes as `ambiguous-attribute` in `errors[]`; `chain-too-long`; `invalid-branch-name`, the names `draft`, `head`, `main` and a UUID included; `branch-limit-reached`; `invalid-resolution`; `branch merge --dry-run` with `blockers`
|
|
939
|
-
| 5 | `draft-target-taken`; `draft-moved`; `draft-head-conflict` lost twice; `draft-baseline-stale`; `rebase-conflict`; `workspace-stale`; `merge-conflict` (and `branch merge --dry-run` with conflicts); `branch-head-conflict`; `branch-has-drafts`; `branch-unmerged`; `branch-name-taken`
|
|
940
|
-
| 6 | A refusal of [the agent policy](#the-agent-policy) (`agent-policy`)
|
|
1021
|
+
| Code | Outcomes |
|
|
1022
|
+
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1023
|
+
| 0 | `branch merge` with nothing to merge (`outcome: 'already-merged'`); `branch merge --dry-run` that would land clean; `draft open` on a draft already there (`opened: false`); `branch create --exist-ok` on a taken name (`created: false`); `branch create` of a name outside `agent/` under an agent host, with a `note`; `draft status --wait` with a verdict, whichever it is |
|
|
1024
|
+
| 1 | `nothing-to-commit`; a landing without `--with-staged` over changes staged before the run; `ambiguous-merge-base`; a real merge the server refuses because the merged model would break a rule; a 403 for a missing token scope, the scope named; a `workspace.json` of format 1; `nothing-to-hand-off`; `draft status --wait` without a draft (`no-draft`), or over a draft that holds none of your changes (`no-own-changes`) |
|
|
1025
|
+
| 2 | A malformed address; `id-required` (a name where an id belongs); a name that fits several things (a label path, a type, an organization), with `candidates` in `details`; a ref the argument does not accept, `ref-unsupported` included; a missing required ref; `@` on a dataset; a write at a commit; `branch delete` of `main`; `draft commit` without `-m` when no staged change carries a message, or on a dataset; a resolution file for another model or pair of branches; an entry left open without `--take-others`; `fields-unexpected`; `--take` or `--take-others` without both heads; `--dry-run` beside a resolution flag; `draft handoff` or `draft status --wait` on a dataset; `--timeout` without `--wait`, or above 86400 |
|
|
1026
|
+
| 3 | `ref-not-found` (an unknown branch name, `@draft` without a draft); `branch-gone` (a workspace's branch was deleted) |
|
|
1027
|
+
| 4 | `change-validation-failed`, with a value that fits several attributes as `ambiguous-attribute` in `errors[]`; `chain-too-long`; `invalid-branch-name`, the names `draft`, `head`, `main` and a UUID included; `branch-limit-reached`; `invalid-resolution`; `branch merge --dry-run` with `blockers` |
|
|
1028
|
+
| 5 | `draft-target-taken`; `draft-moved`; `draft-head-conflict` lost twice; `draft-baseline-stale`; `rebase-conflict`; `workspace-stale`; `merge-conflict` (and `branch merge --dry-run` with conflicts); `branch-head-conflict`; `branch-has-drafts`; `branch-unmerged`; `branch-name-taken` |
|
|
1029
|
+
| 6 | A refusal of [the agent policy](#the-agent-policy) (`agent-policy`) |
|
|
1030
|
+
| 7 | `draft status --wait` when `--timeout` elapses (`timed-out`), the change stream cannot be re-established, or the draft is gone and its landings cannot be read (`verdict-unread`) |
|
|
941
1031
|
|
|
942
1032
|
**Errors.** Under `--json`, a failure prints one line on stderr instead of the `error:` text, and it
|
|
943
1033
|
is the last line there:
|
|
@@ -984,10 +1074,10 @@ on the server, and one table (`POLICY` in `src/commands/policy.ts`) decides what
|
|
|
984
1074
|
| ------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
985
1075
|
| `read` | Runs | `auth status`, `bundle templates`, `model list`, `show`, `tree`, `log`, `export`, `diff`, `model imports list`, `show`, `el show`, `search`, `describe`, `validate`, `draft status`, `diff`, `branch list`, `diff`, `release list`, `pin list`, and every `--dry-run` |
|
|
986
1076
|
| `local` | Runs | `auth login`, `logout`, `bundle pull`, `note add`, `model pull` |
|
|
987
|
-
| `stage` | Runs | `el create`, `set`, `unset`, `rm`, `mv`, `relate`, `unrelate`, `bulk`, `model push`, `draft open`, `draft rebase`
|
|
1077
|
+
| `stage` | Runs | `el create`, `set`, `unset`, `rm`, `mv`, `relate`, `unrelate`, `bulk`, `dependency add`, `rm`, `model push`, `draft open`, `draft rebase`, `draft handoff` |
|
|
988
1078
|
| `create` | Runs | `model create`, `model import`, `model imports complete`, `delete`, `branch create` |
|
|
989
1079
|
| `unstage` | Runs on the agent's own changes only | `draft undo`, `draft discard`, `draft rebase --drop` |
|
|
990
|
-
| `land-draft` | Runs on a branch named `agent/…`; elsewhere needs `MODELDESK_ALLOW_COMMIT=1`. Own changes only | `draft commit`, `--commit` on an `el` write or `model push`
|
|
1080
|
+
| `land-draft` | Runs on a branch named `agent/…`; elsewhere needs `MODELDESK_ALLOW_COMMIT=1`. Own changes only | `draft commit`, `--commit` on an `el` or `dependency` write or `model push` |
|
|
991
1081
|
| `land-direct` | Needs `MODELDESK_ALLOW_COMMIT=1` | `branch merge` (into or from any branch, `agent/…` included), `release create`, `release cascade`, `pin set` |
|
|
992
1082
|
| `destroy` | Refused, with no override | `model delete`, `branch delete` |
|
|
993
1083
|
|
|
@@ -1019,26 +1109,10 @@ The policy is a convention the user controls, not a security boundary. The serve
|
|
|
1019
1109
|
|
|
1020
1110
|
### Guidance for agents
|
|
1021
1111
|
|
|
1022
|
-
An agent with a shell drives the CLI directly
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
share the person's draft, one per user per model, so while it holds changes on another branch
|
|
1027
|
-
this exits 5 (`draft-target-taken`). Ask the person to commit or discard them, or run as a service
|
|
1028
|
-
account, which holds a draft of its own.
|
|
1029
|
-
2. **Always write the ref.** Address `<model>@agent/<topic>` on every invocation, never leave it out.
|
|
1030
|
-
A commit from any surface, the app included, deletes the draft, and unaddressed invocations then
|
|
1031
|
-
work on `main`.
|
|
1032
|
-
3. **Stage small steps, each with a message** (`-m`). The message is what the person reads first, in
|
|
1033
|
-
the app and in `model log --changes`.
|
|
1034
|
-
4. **Commit on the branch as you go.** Run `modeldesk draft commit <model>@agent/<topic>`, with `-m`,
|
|
1035
|
-
or without it to compose the message from your staged messages. Commit before the draft's
|
|
1036
|
-
`changeCount` in `draft status` nears `maxChanges`, since a draft holds at most 500 changes.
|
|
1037
|
-
5. **End by handing the branch to the person.** Ask them to review and merge it in the app (the
|
|
1038
|
-
branch menu's **Review and merge into main**). Once `draft handoff` exists, end with it instead.
|
|
1039
|
-
6. **Never run `branch merge`.** A merge lands on a shared branch with no draft to review, so it is
|
|
1040
|
-
refused under an agent host unless the person set `MODELDESK_ALLOW_COMMIT=1`, and even then the
|
|
1041
|
-
merge is theirs to make.
|
|
1112
|
+
An agent with a shell drives the CLI directly, and the guide for it ships with the CLI. Run
|
|
1113
|
+
`modeldesk agent-guide --no-json` to print it as Markdown, and point the agent at that command instead
|
|
1114
|
+
of copying the text: the guide moves with the CLI, and a test fails when it names a command that does
|
|
1115
|
+
not exist. Without `--no-json` an agent host gets the same text as the `guide` member of a JSON document.
|
|
1042
1116
|
|
|
1043
1117
|
## Contributing
|
|
1044
1118
|
|
|
@@ -1068,6 +1142,20 @@ export const elWhere = defineCommand({
|
|
|
1068
1142
|
Dispatch, strict parsing, `--help` at every level, the globals, `--json`, the error object, the exit
|
|
1069
1143
|
codes and the agent policy all follow from the declaration. Its rules:
|
|
1070
1144
|
|
|
1145
|
+
- A command runs on one of two contexts (`src/commands/types.ts`). `defineCommand` declares a headless
|
|
1146
|
+
command: its handler gets a `HeadlessContext` (the parsed flags and args, the effect, the `agent`
|
|
1147
|
+
principal and the request `origin`, `api`, `content`, `events`, `list`, `note`, `dryRun` and
|
|
1148
|
+
`webUrl`) and no terminal, file, environment or working directory, so a host without a process can
|
|
1149
|
+
run it as a tool. A file the command takes is read by its `prepare` step at the shell, from a
|
|
1150
|
+
`*.shell.ts` sibling, and its content (JSON-shaped) is the handler's second argument, which the
|
|
1151
|
+
handler parses and checks as it would a host's (`el create --from`, `branch merge --resolve`). A lint
|
|
1152
|
+
rule in `eslint.config.mjs` keeps the headless modules free of files, the process and the console.
|
|
1153
|
+
`defineShellCommand`
|
|
1154
|
+
declares a command that needs the shell (it confirms, prompts, writes files or reads its
|
|
1155
|
+
configuration from the working directory): its handler gets the `ShellContext`, which adds the
|
|
1156
|
+
globals, `env`, `cwd`, `io`, `print`, `warn`, `confirm`, `choose`, `readStdin` and `instance`, and
|
|
1157
|
+
it can never carry an `mcp` block. Declare a command headless unless it needs the shell.
|
|
1158
|
+
|
|
1071
1159
|
- Flags and positionals take a type from a closed set (`string`, `number`, `boolean`, `{ enum }`,
|
|
1072
1160
|
`{ list }`, `{ address, slot }`) and a one-sentence description; the same data is what a tool schema
|
|
1073
1161
|
is generated from (an address is one string field whose description carries the grammar), so a
|
|
@@ -1080,14 +1168,16 @@ codes and the agent policy all follow from the declaration. Its rules:
|
|
|
1080
1168
|
`requireOwnChanges` where it knows the draft.
|
|
1081
1169
|
- The handler returns `{ result, exitCode? }`, or `{ result, refusal }` when a refused command's
|
|
1082
1170
|
report is its result (a merge refused with conflicts). `result` is the `--json` document, always an
|
|
1083
|
-
object; arrays travel inside it. Text goes through `render`,
|
|
1084
|
-
command reports progressively.
|
|
1171
|
+
object; arrays travel inside it. Text goes through `render`, which also gets the flags, or through
|
|
1172
|
+
`context.print` when a shell command reports progressively. A refusal whose details are a report (a
|
|
1173
|
+
rebase's refused changes) is rendered by `renderRefusal`, which prints it in place of the details. A
|
|
1174
|
+
remark the result also carries goes through `context.note`. Never write to `process.stdout`.
|
|
1085
1175
|
- Throw `CliError` (`src/errors.ts`) with the exit code that means what happened; the HTTP layer
|
|
1086
1176
|
already maps statuses and problem types (`PROBLEM_EXIT_CODES` in `src/http/client.ts`).
|
|
1087
1177
|
- A command that gates CI (`validate`) does not throw when its check fails: it returns the full
|
|
1088
1178
|
result with `exitCode: ExitCode.Validation`, so the findings still reach stdout and exit 4 carries
|
|
1089
1179
|
the verdict.
|
|
1090
|
-
- A command that writes declares `dryRun: true` and honors `context.
|
|
1180
|
+
- A command that writes declares `dryRun: true` and honors `context.dryRun`. The exceptions
|
|
1091
1181
|
are a single `el` write, which only stages and `draft undo` takes back, and `draft commit`,
|
|
1092
1182
|
`undo`, `open` and `rebase`, whose target `draft status` and `draft diff` show; `policy.test.ts` holds
|
|
1093
1183
|
the list. A question only
|
|
@@ -1105,9 +1195,13 @@ codes and the agent policy all follow from the declaration. Its rules:
|
|
|
1105
1195
|
is `ELEMENT_ARG`, resolved by `resolveElement` (`src/resolve/labelPath.ts`), never matched by hand;
|
|
1106
1196
|
like the app, it leaves out the platform's internal `@` elements unless the caller passes
|
|
1107
1197
|
`INTERNAL_FLAG`'s `--internal`, and an id reaches them either way.
|
|
1108
|
-
- A command that changes server state prints and returns the app link from `webUrl`
|
|
1109
|
-
and takes every idempotency key from `src/requestId.ts
|
|
1110
|
-
`requestIdFor` for a caller's `--request-id`.
|
|
1198
|
+
- A command that changes server state prints and returns the app link from `context.webUrl`
|
|
1199
|
+
(`src/webUrl.ts`), and takes every idempotency key from `src/requestId.ts` under `context.origin`:
|
|
1200
|
+
`mintRequestId`, `deriveRequestId`, or `requestIdFor` for a caller's `--request-id`. The policy reads
|
|
1201
|
+
`context.agent` (`src/agent.ts`), undefined for a person at a shell; the origin is separate because
|
|
1202
|
+
`MODELDESK_AGENT_SESSION` names a session with or without a detected agent host.
|
|
1203
|
+
- A content read goes through `context.content` (`src/resolve/content.ts`), which `readModelContent`
|
|
1204
|
+
and `resolveWriteTarget` call for you; the CLI's source reads the model in full each time.
|
|
1111
1205
|
- A command that stages a model change goes through `runChange` (`src/commands/el/stage.ts`), or its
|
|
1112
1206
|
parts (`beginChange`, `stageChange`, `landStaged`) where its result differs, as `el bulk` does. The
|
|
1113
1207
|
write target comes from `resolveWriteTarget` (`src/resolve/writeTarget.ts`), every change from the
|
|
@@ -1116,8 +1210,8 @@ codes and the agent policy all follow from the declaration. Its rules:
|
|
|
1116
1210
|
`src/actions/`, with every attribute value typed by `src/coerce/`; nothing builds a `StagedAction`
|
|
1117
1211
|
or parses a value by hand. A draft command addresses a model or a dataset through `draftHolder`
|
|
1118
1212
|
(`src/commands/draft/resource.ts`), so one declaration serves both kinds.
|
|
1119
|
-
- Config comes from `context.instance()` and the settings table in
|
|
1120
|
-
setting is a new row there.
|
|
1213
|
+
- Config comes from `context.instance()` (a shell command's) and the settings table in
|
|
1214
|
+
`src/config/types.ts`; a new setting is a new row there.
|
|
1121
1215
|
|
|
1122
1216
|
**Merges.** `src/merge/report.ts` parses the preview and the `merge-conflict` problem into one
|
|
1123
1217
|
`MergeReport`, a union by `outcome`. `src/merge/resolution.ts` is pure: `parseResolutionFile` reads
|
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Third-party notices for @modeldesk/cli 0.
|
|
1
|
+
Third-party notices for @modeldesk/cli 0.8.0
|
|
2
2
|
|
|
3
3
|
This product incorporates the open-source packages listed below. Each entry gives the package,
|
|
4
4
|
its version, its license, and the license and notice text the package ships. Copyright in each
|