@modeldesk/cli 0.7.0 → 0.9.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 CHANGED
@@ -34,14 +34,17 @@ modeldesk bundle pull|templates
34
34
  modeldesk note add <name>
35
35
  modeldesk template lint <dir>
36
36
 
37
- modeldesk model list [--metamodel <id>] [--owner <organization|me>] [--kind model|metamodel|all]
37
+ modeldesk model list [--metamodel <id>] [--owner <organization|me>]
38
38
  modeldesk model show <model[@ref]> identity at the ref; overview and releases are main's
39
39
  modeldesk model tree <model[@ref]> [--depth <n>] [--type <type>] [--internal]
40
40
  modeldesk model log <model[@ref]> [--include-system] [--changes]
41
41
  modeldesk model create --name <name> --metamodel <metamodel[@release]>
42
42
  [--extension <extension[@release]>]... [--owner <organization|me>]
43
- [--kind model|metamodel] [--standard-version <version>]
44
43
  modeldesk model delete <model>
44
+ modeldesk model rename <model> <name>
45
+ modeldesk model access <model> shared|individual
46
+ modeldesk model metamodel <model> [--version <version>] [--extension <id[@version]>]... [--no-extensions]
47
+ modeldesk model metadata show <model> | set <model> --record <json>
45
48
  modeldesk model import [<file>] | --url <uri> --metamodel <metamodel[@release]> [--name <name>]
46
49
  [--owner <organization>] [--extension <extension[@release]>]... [--loader <name>]
47
50
  [--review] [--timeout <seconds>]
@@ -67,18 +70,41 @@ modeldesk el relate <model[@ref]> <element> <relation> <target> [--unowned]
67
70
  modeldesk el unrelate <model[@ref]> <element> <relation> <target>
68
71
  modeldesk el bulk <model[@ref]> --where <criterion>... [--set <attr=value>]... [--json-value <attr=json>]...
69
72
  [--unset <attr>]... [--lang <tag>]
70
- every el write takes -m <message> [--request-id <id>] [--commit [--with-staged]]
73
+ modeldesk el paste <model[@ref]> <element>... [--from-model <model>] [--parent <el> --relation <r>]
74
+
75
+ modeldesk namespace create <model[@ref]> --prefix <p> --uri <iri> [--default yes|no]
76
+ modeldesk namespace set <model[@ref]> <namespace> [--prefix <p>] [--uri <iri>] [--default yes|no]
77
+ modeldesk namespace rm <model[@ref]> <namespace>
78
+ modeldesk attr-template base <model[@ref]> --base-iri <iri>
79
+ modeldesk attr-template create <model[@ref]> --attribute <a> --flavor <flavor> [--element-type <t>]
80
+ [--source <a>] [--segment <text>] [--lang <tag>] [--casing <c>] [--short-form]
81
+ modeldesk attr-template set <model[@ref]> <entry> --attribute <a> --flavor <flavor> [the same flags]
82
+ modeldesk attr-template rm <model[@ref]> <entry>
83
+ modeldesk diagram create <model[@ref]> --name <name> [--description <text> [--lang <tag>]]
84
+ [--context <el>] [--diagram-type <id>]
85
+ modeldesk diagram set <model[@ref]> <diagram> [--name <name>] [--add <el>]... [--remove <el>]...
86
+ [--orientation <o>] [--hierarchy-orientation <o>] [--published yes|no]
87
+ modeldesk diagram rm <model[@ref]> <diagram>
88
+ modeldesk diagram materialize <model[@ref]> <root> --template <id> [--orientation <o>] [--published yes|no]
89
+ modeldesk diagram rule create <model[@ref]> <diagram> --element <el> --type <type> --ref-element <el>
90
+ modeldesk diagram rule rm|mv <model[@ref]> <diagram> <rule> [--position <n>]
91
+ modeldesk diagram group create <model[@ref]> <diagram> --root <el> [--max-left <n>] [--max-right <n>]
92
+ modeldesk diagram group set <model[@ref]> <diagram> <group> --root <el> [--max-left <n>] [--max-right <n>]
93
+ modeldesk diagram group rm|mv <model[@ref]> <diagram> <group> [--position <n>]
94
+ every el, namespace, attr-template and diagram write takes
95
+ -m <message> [--request-id <id>] [--commit [--with-staged]]
71
96
 
72
97
  modeldesk search <model[@ref]> <text> [--type <type>] [--internal]
73
- modeldesk describe <model> [<type>] [--internal]
98
+ modeldesk describe <model[@ref]> [<type>] [--internal]
74
99
  modeldesk validate <model[@ref]> [--fail-on error|warning] [--limit <n>]
75
100
 
76
101
  modeldesk draft open <model@branch>
77
- modeldesk draft status <resource[@branch]>
102
+ modeldesk draft status <resource[@branch]> [--wait [--timeout <seconds>]]
78
103
  modeldesk draft diff <resource[@branch]> [--changes]
79
104
  modeldesk draft undo <resource[@branch]> [--any-surface]
80
105
  modeldesk draft commit <resource[@branch]> [-m <message>] [--expect <draft-head>] [--any-surface]
81
106
  modeldesk draft discard <resource[@branch]> [--any-surface]
107
+ modeldesk draft handoff <resource[@branch]> -m <summary>
82
108
  modeldesk draft rebase <resource[@branch]> [--drop <change-id>]...
83
109
 
84
110
  modeldesk branch list <model>
@@ -89,11 +115,13 @@ modeldesk branch merge <model@target> <source> [-m <message>] [--resolve <file|
89
115
  [--take <element>[#<field>]=target|source]... [--take-others target|source]
90
116
  [--expect <target-head>] [--expect-source <source-head>]
91
117
 
92
- modeldesk release create <model[@commit]> [--name <name>] [--description <text>]
93
- modeldesk release list <model>
94
- modeldesk release cascade <base> [--timeout <seconds>] [--instance-limit <n>] [--verify-all]
95
- modeldesk pin list <model>
118
+ modeldesk release create <model[@commit]> --name <name> [--description <text>]
119
+ modeldesk release list <model>
120
+ modeldesk pin list <model[@ref]>
96
121
  modeldesk pin set <model> <dependency@release|main>
122
+ modeldesk dependency add <model[@ref]> <target@release|main>
123
+ modeldesk dependency rm <model[@ref]> <dependency>
124
+ modeldesk dependency pin <model[@ref]> <dependency@release|main>
97
125
  ```
98
126
 
99
127
  A listing also takes `--limit <n>`, `--cursor <cursor>` and `--all`. `<model[@ref]>` is a model's
@@ -420,27 +448,29 @@ is `/`-separated (`SHACL/NodeShape/severity`), with a `/` inside a label written
420
448
  Each argument accepts some refs and gives a missing ref a meaning. **Working** means your draft
421
449
  while it holds staged changes, and the head of your working branch otherwise.
422
450
 
423
- | Argument of | Accepts | Without a ref |
424
- | ---------------------------------------------------------- | ------------------------------------- | ----------------------------------- |
425
- | `model tree`, `el show`, `search` | `@draft`, `@head`, a branch, a commit | Working |
426
- | `model show`, `validate` | `@draft`, `@head`, a branch | Working |
427
- | `model log` | `@draft`, `@head`, a branch | The working branch head |
428
- | every `el` write, `model pull` | `@draft`, `@head`, a branch | Working |
429
- | `branch create` (the branch to start from), `branch diff` | `@head`, a branch | The working branch head |
430
- | `draft open`, `branch delete`, `branch merge` (the target) | a branch | Required |
431
- | the other `draft` commands | a branch, as an assertion | Your draft, wherever it aims |
432
- | `release create` | a commit, which must be main's head | Main's head |
433
- | `pin set` (the dependency) | a release, or `@main` | Required |
434
- | `--metamodel`, `--extension` | a release | The latest stable or newest release |
435
- | the commands that read main | no ref | Main |
451
+ | Argument of | Accepts | Without a ref |
452
+ | --------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------- |
453
+ | `model tree`, `el show`, `search` | `@draft`, `@head`, a branch, a commit | Working |
454
+ | `model show`, `validate`, `describe`, `pin list` | `@draft`, `@head`, a branch | Working |
455
+ | `model log` | `@draft`, `@head`, a branch | The working branch head |
456
+ | every `el` and `dependency` write, `model pull` | `@draft`, `@head`, a branch | Working |
457
+ | `branch create` (the branch to start from), `branch diff` | `@head`, a branch | The working branch head |
458
+ | `draft open`, `branch delete`, `branch merge` (the target) | a branch | Required |
459
+ | the other `draft` commands | a branch, as an assertion | Your draft, wherever it aims |
460
+ | `release create` | a commit, which must be main's head | Main's head |
461
+ | `pin set`, `dependency pin` (the dependency), `dependency add` (the target) | a release, or `@main` | Required |
462
+ | `--metamodel`, `--extension` | a release | The latest stable or newest release |
463
+ | the commands that read main | no ref | Main |
436
464
 
437
465
  `model show` reads the model's identity and head at the ref. Its overview and releases are always
438
466
  main's, and the result labels them so (`overview.ref`). The commands that read main are
439
- `model export`, `model delete`, `describe`, `branch list`, `release list`, `release cascade`,
440
- `pin list` and the model of `pin set`. They take no ref at all, `@main` included: a ref there exits 2
441
- (`ref-unsupported`), so nothing reads main under an address that said otherwise. `describe` reads the committed metamodel resolution, which a draft cannot change, and
442
- `model export` encodes main only. When your draft aims at another branch, both say so in the `ref`
443
- block's `note` (on stderr in text mode).
467
+ `model export`, `model delete`, `branch list`, `release list` and the model of `pin set`. They take
468
+ no ref at all, `@main` included: a ref there exits 2 (`ref-unsupported`), so nothing reads main
469
+ under an address that said otherwise. `model export`
470
+ encodes main only. When your draft aims at another branch, it says so in the `ref` block's `note`
471
+ (on stderr in text mode). `describe` reads the schema at its ref, since a dependency staged in your
472
+ draft brings the metamodel of its target into it, and the `el` writes plan against the schema at
473
+ the ref they write to.
444
474
 
445
475
  A malformed address, a name where an id belongs, a ref the argument does not accept, a missing
446
476
  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 +570,61 @@ working branch. They follow these rules:
540
570
  the same one on every run, so `--request-id fix-42` and the id it reported retry alike. `model
541
571
  create` has no idempotency key: after an exit 7, check `model list` before you retry.
542
572
 
573
+ ### Stage the model's structure
574
+
575
+ The `namespace`, `attr-template` and `diagram` commands stage what a model holds besides its elements:
576
+ its namespaces, the base IRI and entries of its attribute templates, and its diagrams with their
577
+ layout rules and hierarchy groups. `el paste` stages a copy of elements, each with the subtree it
578
+ owns, from the model itself or from another model of the organization. Each follows the rules of
579
+ [a staged change](#stage-a-change) and takes `-m`, `--request-id`, `--commit` and `--with-staged` as
580
+ an `el` write does.
581
+
582
+ - **Addressing.** A namespace is named by its prefix or its id, a diagram by its name or its id, an
583
+ attribute template by the attribute it fills in or its id, and a layout rule or a hierarchy group
584
+ by its id. `search <model> <text> --internal --type @Diagram` finds the ids; the type names are
585
+ `@Namespace`, `@AttributeTemplate`, `@Diagram`, `@LayoutRule` and `@HierarchyGroup`. A layout rule
586
+ or a hierarchy group has no name, so search for `LayoutRule` or `HierarchyGroup`, the label it is
587
+ listed under.
588
+ - **A set replaces or merges as the server does.** `namespace set` and `diagram set` change what they
589
+ are given and keep the rest. `attr-template set` and `diagram group set` replace the whole entry or
590
+ group, so give every part it is to keep.
591
+ - **A copy from another model** names its elements by id; within the model a label path works too.
592
+
593
+ ### Add, remove or re-pin a dependency
594
+
595
+ `dependency add <model[@ref]> <target>@<release|main>` stages a dependency on another model of the
596
+ organization, `dependency rm <model[@ref]> <dependency>` stages the removal of one, and
597
+ `dependency pin <model[@ref]> <dependency>@<release|main>` stages a move of one to another release
598
+ of its target, or to its head now. Each follows the rules of [a staged change](#stage-a-change) and
599
+ takes `-m`, `--request-id`, `--commit` and `--with-staged` as an `el` write does.
600
+
601
+ - **The pin.** `<target>@<release>` pins that release. `<target>@main` pins the target's head as it is
602
+ when the change is staged, and it moves again only when you re-pin.
603
+ - **One change of its own.** The server checks the rest of a change against the dependencies, so a
604
+ dependency change is never sent beside another action. Stage the dependency first, then the
605
+ elements that refer to it. The schema follows: `describe` and the `el` writes read it at the ref,
606
+ so what the target's metamodel brings is there as soon as the dependency is staged.
607
+ - **A target the model already depends on is refused** (exit 4, `dependency-exists`) before anything
608
+ is sent, naming the dependency and the `dependency pin` that stages a move of its pin. A target the
609
+ model reaches only through another dependency becomes a direct one in place and keeps its id
610
+ (`promoted: true`).
611
+ - **`pin` lands with the draft.** Where `pin set` commits a move to main directly, `dependency pin`
612
+ stages it, on any branch and for a dependency your draft added too. Managed, external and
613
+ transitive dependencies are refused with the reason.
614
+ - **`rm` names the dependency** by its id or its target model's id, from `pin list`. One whose content
615
+ the model's elements still refer to is refused (exit 4), with one entry per referring element in
616
+ `details.errors`. One that another dependency still brings along stays as a transitive dependency
617
+ (`outcome: 'kept-as-transitive'`). Managed, external and transitive dependencies are refused with
618
+ the reason.
619
+ - **`--dry-run` asks the server.** It sends the same change with `dryRun: true`: the server tries it
620
+ and keeps nothing, so a dry run exits with the refusal the change would meet.
621
+ - **`pin list <model>` shows the result.** It reads your draft while it holds staged changes, so a
622
+ staged dependency is listed before it is committed. `pin set` still moves a pin on main only, so
623
+ a dependency that exists only in your draft or on a branch is listed with `settable: false`.
624
+
625
+ Only dependencies on another model are staged. A dependency on an external document is added in the
626
+ app.
627
+
543
628
  ### Commit your draft
544
629
 
545
630
  `draft commit <resource[@branch]>` lands every change the draft holds, whichever surface staged it.
@@ -580,6 +665,59 @@ own `-m`. The landing rules:
580
665
 
581
666
  Under an agent host a landing has a gate of its own; see [The agent policy](#the-agent-policy).
582
667
 
668
+ ### Hand off your draft for review
669
+
670
+ `draft handoff <model[@branch]> -m <summary>` marks your draft ready for review. The summary is stored
671
+ on the draft: the person's open model shows a notice with it, the panel header carries it, the commit
672
+ dialog starts from it, and the model list reads **Ready for review** even when the model is not open.
673
+ Nothing is staged and nothing is committed, and a second handoff replaces the first. `-m` is required
674
+ and is your own account of the draft, at most 2,000 characters, shown as plain text.
675
+
676
+ - A draft with no staged change exits 1 (`nothing-to-hand-off`). No draft exits 3.
677
+ - A draft that moved while it was handed off exits 5 (`draft-moved`), with nothing stored.
678
+ - `@<branch>` asserts where the draft aims, as on every draft command (exit 5, `draft-target-taken`).
679
+ - A dataset draft has no handoff (exit 2).
680
+
681
+ `draft status <model[@branch]> --wait` then waits for what the person does, on the model's change
682
+ stream, and reports it as `verdict` beside the status. Every verdict exits 0:
683
+
684
+ | `verdict` | What happened | Members |
685
+ | -------------- | ---------------------------------------------------------------------------------------------- | --------------------------- |
686
+ | `committed` | The draft landed with some of your changes | `commitId`, `url`, `landed` |
687
+ | `discarded` | None of your changes landed: the draft or its branch was discarded, or they were removed first | none |
688
+ | `changed` | A change was removed or undone, or the draft was rebased, in review | `changeCount` |
689
+ | `branch-moved` | The branch the draft aims at moved, or had already moved: rebase, then wait again | `branchHeadId` |
690
+
691
+ The person staging edits of their own is no verdict, and the wait goes on. A draft the branch had
692
+ already left behind when the wait began answers `branch-moved` at once, since it cannot be committed
693
+ before a rebase. Your changes are the draft's staged changes the CLI or an agent made, of your
694
+ session when one is set (see [The agent policy](#the-agent-policy)), listed by request id as the wait
695
+ begins; a rebase keeps them. A draft that holds none of them exits 1 with `type: no-own-changes`
696
+ before the wait begins, since no landing could hold one: wait from the session that staged them, or
697
+ read `draft diff <model>@<branch> --changes` to see where each change came from. The verdict is read
698
+ off the record each landing since the draft's baseline carries, so a colleague's landing is never
699
+ taken for yours.
700
+
701
+ `--timeout <seconds>` bounds the wait (600 when not given, a day at most). When it elapses, or the
702
+ stream cannot be re-established, the command exits 7 with `retryable: true`: run it again. When the
703
+ draft is gone but the landings cannot be read even after a few attempts, it exits 7 with
704
+ `type: verdict-unread`, and `model log --changes` shows whether your changes landed. No verdict exits
705
+ 6, since the person acting in the app is the expected path; an authentication failure keeps its own
706
+ code. The stream ends with the access token that opened it, or after a minute without a frame, and the
707
+ CLI opens it again with a refreshed token. Every `heads` frame is compared with what the wait holds,
708
+ so an answer that falls between two connections is still seen. Datasets have no change stream, so
709
+ `--wait` takes a model.
710
+
711
+ ```json
712
+ {
713
+ "draft": { "id": "…", "targetRefId": "…", "changeCount": 3, "target": { "id": "…", "name": "main" } },
714
+ "verdict": "committed",
715
+ "commitId": "98c4377f-8da2-438b-a54e-cebba0551168",
716
+ "url": "https://app.modeldesk.io/models/…/history/98c4377f-8da2-438b-a54e-cebba0551168",
717
+ "landed": 2
718
+ }
719
+ ```
720
+
583
721
  ### See what a landing held
584
722
 
585
723
  A commit landed from a draft records every change it landed: its request id, its message and its
@@ -929,15 +1067,16 @@ final. The table is frozen: codes are added, never renumbered, and 126, 127 and
929
1067
  The HTTP status decides the code unless the problem type is one of the few the CLI maps itself
930
1068
  (`PROBLEM_EXIT_CODES` in `src/http/client.ts`). The outcomes of drafts, branches and merges:
931
1069
 
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`) |
1070
+ | Code | Outcomes |
1071
+ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1072
+ | 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 |
1073
+ | 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`) |
1074
+ | 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 |
1075
+ | 3 | `ref-not-found` (an unknown branch name, `@draft` without a draft); `branch-gone` (a workspace's branch was deleted) |
1076
+ | 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` |
1077
+ | 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` |
1078
+ | 6 | A refusal of [the agent policy](#the-agent-policy) (`agent-policy`) |
1079
+ | 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
1080
 
942
1081
  **Errors.** Under `--json`, a failure prints one line on stderr instead of the `error:` text, and it
943
1082
  is the last line there:
@@ -980,16 +1119,32 @@ Under an agent host the CLI leaves to a person what lands content on a shared br
980
1119
  person's review, and what destroys other users' work. Every command declares the **effect** it has
981
1120
  on the server, and one table (`POLICY` in `src/commands/policy.ts`) decides what each effect needs:
982
1121
 
983
- | Effect | Under an agent host | Commands |
984
- | ------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
985
- | `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
- | `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` |
988
- | `create` | Runs | `model create`, `model import`, `model imports complete`, `delete`, `branch create` |
989
- | `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` |
991
- | `land-direct` | Needs `MODELDESK_ALLOW_COMMIT=1` | `branch merge` (into or from any branch, `agent/…` included), `release create`, `release cascade`, `pin set` |
992
- | `destroy` | Refused, with no override | `model delete`, `branch delete` |
1122
+ | Effect | Under an agent host | Commands |
1123
+ | ------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1124
+ | `read` | Runs | `auth status`, `bundle templates`, `model list`, `show`, `tree`, `log`, `export`, `diff`, `model metadata show`, `model imports list`, `show`, `el show`, `search`, `describe`, `validate`, `draft status`, `diff`, `branch list`, `diff`, `release list`, `pin list`, and every `--dry-run` |
1125
+ | `local` | Runs | `auth login`, `logout`, `bundle pull`, `note add`, `model pull` |
1126
+ | `stage` | Runs | `el create`, `set`, `unset`, `rm`, `mv`, `relate`, `unrelate`, `bulk`, `dependency add`, `rm`, `model push`, `draft open`, `draft rebase`, `draft handoff` |
1127
+ | `create` | Runs | `model create`, `model import`, `model imports complete`, `delete`, `branch create` |
1128
+ | `unstage` | Runs on the agent's own changes only | `draft undo`, `draft discard`, `draft rebase --drop` |
1129
+ | `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` |
1130
+ | `land-direct` | Needs `MODELDESK_ALLOW_COMMIT=1` | `branch merge` (into or from any branch, `agent/…` included), `pin set`, `model rename`, `access`, `metamodel`, `model metadata set` |
1131
+ | `destroy` | Refused, with no override; on the hosted server it needs `agent:commit` | `model delete`, `branch delete` |
1132
+ | `publish` | Needs `MODELDESK_ALLOW_COMMIT=1` | `release create` |
1133
+
1134
+ The hosted MCP server reads the same table as four levels, by who a change affects. A person grants
1135
+ a connected AI platform a level on the consent page, each level including the ones before it, and a
1136
+ new command joins the level of the effect it declares:
1137
+
1138
+ | Level | Who is affected | Taken back by | Effects | AI platform scope | Service account scope |
1139
+ | ------- | ------------------------------- | -------------------- | ------------------------------------------------------- | ----------------- | --------------------- |
1140
+ | Read | Nobody | Nothing to take back | `read` | `model:read` | `model:read` |
1141
+ | Propose | The person | The person | `stage`, `create`, `unstage`, `land-draft` on `agent/…` | `model:write` | no equivalent |
1142
+ | Act | The person's organization | A new commit | `land-draft` elsewhere, `land-direct`, `destroy` | `agent:commit` | `model:write` |
1143
+ | Publish | People outside the organization | Nobody | `publish` | `agent:publish` | `model:write` |
1144
+
1145
+ At a shell the gates above are all there is: `publish` needs `MODELDESK_ALLOW_COMMIT=1` as a direct
1146
+ landing does, and `destroy` is refused. The hosted server offers no tool for `destroy` or `publish`,
1147
+ and no connection can be granted `agent:publish`.
993
1148
 
994
1149
  A refusal exits 6 with `type: agent-policy`, `details: {effect, gate}`, and a hint naming the way
995
1150
  out. `MODELDESK_ALLOW_COMMIT` counts only when it is exactly `1`. Outside an agent host none of this
@@ -1019,26 +1174,10 @@ The policy is a convention the user controls, not a security boundary. The serve
1019
1174
 
1020
1175
  ### Guidance for agents
1021
1176
 
1022
- An agent with a shell drives the CLI directly. Agents without a shell will connect through a
1023
- ModelDesk-hosted MCP server, specified separately. Work on a branch of your own:
1024
-
1025
- 1. **Start on a branch of your own.** Run `modeldesk branch create <model> agent/<topic> --open`. You
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.
1177
+ An agent with a shell drives the CLI directly, and the guide for it ships with the CLI. Run
1178
+ `modeldesk agent-guide --no-json` to print it as Markdown, and point the agent at that command instead
1179
+ of copying the text: the guide moves with the CLI, and a test fails when it names a command that does
1180
+ not exist. Without `--no-json` an agent host gets the same text as the `guide` member of a JSON document.
1042
1181
 
1043
1182
  ## Contributing
1044
1183
 
@@ -1068,6 +1207,20 @@ export const elWhere = defineCommand({
1068
1207
  Dispatch, strict parsing, `--help` at every level, the globals, `--json`, the error object, the exit
1069
1208
  codes and the agent policy all follow from the declaration. Its rules:
1070
1209
 
1210
+ - A command runs on one of two contexts (`src/commands/types.ts`). `defineCommand` declares a headless
1211
+ command: its handler gets a `HeadlessContext` (the parsed flags and args, the effect, the `agent`
1212
+ principal and the request `origin`, `api`, `content`, `events`, `list`, `note`, `dryRun` and
1213
+ `webUrl`) and no terminal, file, environment or working directory, so a host without a process can
1214
+ run it as a tool. A file the command takes is read by its `prepare` step at the shell, from a
1215
+ `*.shell.ts` sibling, and its content (JSON-shaped) is the handler's second argument, which the
1216
+ handler parses and checks as it would a host's (`el create --from`, `branch merge --resolve`). A lint
1217
+ rule in `eslint.config.mjs` keeps the headless modules free of files, the process and the console.
1218
+ `defineShellCommand`
1219
+ declares a command that needs the shell (it confirms, prompts, writes files or reads its
1220
+ configuration from the working directory): its handler gets the `ShellContext`, which adds the
1221
+ globals, `env`, `cwd`, `io`, `print`, `warn`, `confirm`, `choose`, `readStdin` and `instance`, and
1222
+ it can never carry an `mcp` block. Declare a command headless unless it needs the shell.
1223
+
1071
1224
  - Flags and positionals take a type from a closed set (`string`, `number`, `boolean`, `{ enum }`,
1072
1225
  `{ list }`, `{ address, slot }`) and a one-sentence description; the same data is what a tool schema
1073
1226
  is generated from (an address is one string field whose description carries the grammar), so a
@@ -1080,14 +1233,16 @@ codes and the agent policy all follow from the declaration. Its rules:
1080
1233
  `requireOwnChanges` where it knows the draft.
1081
1234
  - The handler returns `{ result, exitCode? }`, or `{ result, refusal }` when a refused command's
1082
1235
  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`, or through `context.print` when a
1084
- command reports progressively. Never write to `process.stdout`.
1236
+ object; arrays travel inside it. Text goes through `render`, which also gets the flags, or through
1237
+ `context.print` when a shell command reports progressively. A refusal whose details are a report (a
1238
+ rebase's refused changes) is rendered by `renderRefusal`, which prints it in place of the details. A
1239
+ remark the result also carries goes through `context.note`. Never write to `process.stdout`.
1085
1240
  - Throw `CliError` (`src/errors.ts`) with the exit code that means what happened; the HTTP layer
1086
1241
  already maps statuses and problem types (`PROBLEM_EXIT_CODES` in `src/http/client.ts`).
1087
1242
  - A command that gates CI (`validate`) does not throw when its check fails: it returns the full
1088
1243
  result with `exitCode: ExitCode.Validation`, so the findings still reach stdout and exit 4 carries
1089
1244
  the verdict.
1090
- - A command that writes declares `dryRun: true` and honors `context.globals.dryRun`. The exceptions
1245
+ - A command that writes declares `dryRun: true` and honors `context.dryRun`. The exceptions
1091
1246
  are a single `el` write, which only stages and `draft undo` takes back, and `draft commit`,
1092
1247
  `undo`, `open` and `rebase`, whose target `draft status` and `draft diff` show; `policy.test.ts` holds
1093
1248
  the list. A question only
@@ -1105,9 +1260,13 @@ codes and the agent policy all follow from the declaration. Its rules:
1105
1260
  is `ELEMENT_ARG`, resolved by `resolveElement` (`src/resolve/labelPath.ts`), never matched by hand;
1106
1261
  like the app, it leaves out the platform's internal `@` elements unless the caller passes
1107
1262
  `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` (`src/webUrl.ts`),
1109
- and takes every idempotency key from `src/requestId.ts`: `mintRequestId`, `deriveRequestId`, or
1110
- `requestIdFor` for a caller's `--request-id`.
1263
+ - A command that changes server state prints and returns the app link from `context.webUrl`
1264
+ (`src/webUrl.ts`), and takes every idempotency key from `src/requestId.ts` under `context.origin`:
1265
+ `mintRequestId`, `deriveRequestId`, or `requestIdFor` for a caller's `--request-id`. The policy reads
1266
+ `context.agent` (`src/agent.ts`), undefined for a person at a shell; the origin is separate because
1267
+ `MODELDESK_AGENT_SESSION` names a session with or without a detected agent host.
1268
+ - A content read goes through `context.content` (`src/resolve/content.ts`), which `readModelContent`
1269
+ and `resolveWriteTarget` call for you; the CLI's source reads the model in full each time.
1111
1270
  - A command that stages a model change goes through `runChange` (`src/commands/el/stage.ts`), or its
1112
1271
  parts (`beginChange`, `stageChange`, `landStaged`) where its result differs, as `el bulk` does. The
1113
1272
  write target comes from `resolveWriteTarget` (`src/resolve/writeTarget.ts`), every change from the
@@ -1116,8 +1275,8 @@ codes and the agent policy all follow from the declaration. Its rules:
1116
1275
  `src/actions/`, with every attribute value typed by `src/coerce/`; nothing builds a `StagedAction`
1117
1276
  or parses a value by hand. A draft command addresses a model or a dataset through `draftHolder`
1118
1277
  (`src/commands/draft/resource.ts`), so one declaration serves both kinds.
1119
- - Config comes from `context.instance()` and the settings table in `src/config/types.ts`; a new
1120
- setting is a new row there.
1278
+ - Config comes from `context.instance()` (a shell command's) and the settings table in
1279
+ `src/config/types.ts`; a new setting is a new row there.
1121
1280
 
1122
1281
  **Merges.** `src/merge/report.ts` parses the preview and the `merge-conflict` problem into one
1123
1282
  `MergeReport`, a union by `outcome`. `src/merge/resolution.ts` is pure: `parseResolutionFile` reads
@@ -1144,38 +1303,21 @@ and `src/exportFlow/`, each beside its tests:
1144
1303
  `ModelImport.SUPPORTED_LOADERS` fails the table's unit test until it is mapped.
1145
1304
  - Files written from server data go through `writeDocuments` or `writeFileThroughTemp`
1146
1305
  (`src/exportFlow/documents.ts`): staged as temporary files, then renamed into place, files 0644 and
1147
- created directories 0755 whatever the umask. `checkSafeNames` first accepts only portable basenames
1148
- (no path, control character, Windows-forbidden character or device name, trailing dot or space), so
1149
- a write never lands outside the directory the caller gave, and `checkDistinctNames` refuses names
1150
- that differ only in case or Unicode normalization. A document for stdout goes out through
1306
+ created directories 0755 whatever the umask. `checkSafeNames` first accepts only portable relative
1307
+ paths (`/`-separated segments, none empty, `.` or `..`, and none with a control character,
1308
+ Windows-forbidden character or device name, trailing dot or space; a backslash is refused), so a
1309
+ write never lands outside the directory the caller gave, and the subdirectories a name needs are
1310
+ created. `checkDistinctNames` refuses paths that differ only in case or Unicode normalization, and
1311
+ a document that is also a folder on the way to another. A document for stdout goes out through
1151
1312
  `context.io.out`, never `print`, with control characters dropped only when `context.stdoutIsTTY`.
1152
1313
  - Server text an import returns (problem details, error messages, log entries) passes through
1153
1314
  `scrubberFor` (`src/importFlow/display.ts`), which replaces the `--url` and its secret-bearing
1154
1315
  pieces with their redacted form.
1155
1316
 
1156
- **Releases and pins.** `release create|list|cascade` and `pin list|set` serve ordinary models and
1157
- metamodel-models alike. `releaseTarget` (`src/commands/release/target.ts`) tells them apart by the
1158
- metamodel the overview names, and a caller who is not a super-admin addressing a metamodel-model is
1159
- refused with exit 6 (`super-admin-required`) before any `/metamodel-models` route, since those answer
1160
- super-admins only and no service account. `release create`, `pin set` and `release cascade` change
1161
- committed state with no draft to review, so they declare the effect `land-direct`: under an agent host
1162
- they exit 6 before any write unless `MODELDESK_ALLOW_COMMIT=1`, and `--yes` alone never confirms a
1163
- cascade there. `--dry-run`, `release list` and `pin list` stay open.
1164
-
1165
- - The cascade lives in `src/cascade/`: `read.ts` reads the family into a `CascadeGraph`, `plan.ts`
1166
- decides from it as a pure function, `execute.ts` runs the steps and stops at the first failure,
1167
- and `verify.ts` waits for the platform's instance re-pins through `pollUntil`. Resuming is
1168
- re-planning: a finished step leaves a pin that is current and a release at its head, so it plans
1169
- as a no-op. A planner case is a hand-built graph in `plan.test.ts`.
1170
- - Before its first write the cascade re-reads the heads and releases the plan rests on and exits 5
1171
- when one moved. Verification waits only on the instance models pinning a release this run moved
1172
- in place (the platform re-pins nothing else), at most `READ_CONCURRENCY` reads at a time; an
1173
- instance never read, or still behind, exits 7. `--verify-all` checks every release of the family.
1174
- - A metamodel release is named after the standard version its head declares (`readStandardVersion`),
1175
- so the release it overwrites is known before the call (`releaseOverwritten`), and its description
1176
- is re-sent when none is given: the server stores what the request carries.
1177
- - The repository side of a metamodel release (`regenerate.sh`, commit, `push-metamodels`) is printed
1178
- as `nextSteps` by `repositorySteps`, and never run.
1317
+ **Releases and pins.** `pin set` changes committed state with no draft to review, so it declares the
1318
+ effect `land-direct`; `release create` reaches people outside the organization and cannot be taken
1319
+ back, so it declares `publish`. Under an agent host both exit 6 before any write unless
1320
+ `MODELDESK_ALLOW_COMMIT=1`. `--dry-run`, `release list` and `pin list` stay open.
1179
1321
 
1180
1322
  **Model workspaces.** The engine is `src/workspace/`, pure apart from `files.ts` and `session.ts`:
1181
1323
  `materialize.ts` writes the files, `parse.ts` reads them, `opDiff.ts` compares them with the target,
@@ -1,4 +1,4 @@
1
- Third-party notices for @modeldesk/cli 0.7.0
1
+ Third-party notices for @modeldesk/cli 0.9.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