@skillcdn/console 0.4.4 → 0.4.6
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 +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +3 -3
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +180 -22
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +24 -4
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +78 -21
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +43 -10
- package/dist/cli/help.js.map +1 -1
- package/dist/client.d.ts +30 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -2
- package/dist/client.js.map +1 -1
- package/dist/compat.js +1 -1
- package/dist/components/board.d.ts.map +1 -1
- package/dist/components/board.js +46 -15
- package/dist/components/board.js.map +1 -1
- package/dist/components/decision-form.d.ts +0 -3
- package/dist/components/decision-form.d.ts.map +1 -1
- package/dist/components/decision-form.js +3 -15
- package/dist/components/decision-form.js.map +1 -1
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +30 -10
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/my-decisions.d.ts +20 -3
- package/dist/components/my-decisions.d.ts.map +1 -1
- package/dist/components/my-decisions.js +14 -1
- package/dist/components/my-decisions.js.map +1 -1
- package/dist/components/people.d.ts +43 -1
- package/dist/components/people.d.ts.map +1 -1
- package/dist/components/people.js +117 -9
- package/dist/components/people.js.map +1 -1
- package/dist/components/picker.d.ts +8 -0
- package/dist/components/picker.d.ts.map +1 -1
- package/dist/components/picker.js +2 -2
- package/dist/components/picker.js.map +1 -1
- package/dist/components/plugin-frame.d.ts +0 -1
- package/dist/components/plugin-frame.d.ts.map +1 -1
- package/dist/components/plugin-frame.js +38 -4
- package/dist/components/plugin-frame.js.map +1 -1
- package/dist/components/plugin-settings.d.ts +5 -1
- package/dist/components/plugin-settings.d.ts.map +1 -1
- package/dist/components/plugin-settings.js +143 -30
- package/dist/components/plugin-settings.js.map +1 -1
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +3 -1
- package/dist/components/projects.js.map +1 -1
- package/dist/components/searches.d.ts +11 -0
- package/dist/components/searches.d.ts.map +1 -0
- package/dist/components/searches.js +30 -0
- package/dist/components/searches.js.map +1 -0
- package/dist/components/task-form.d.ts.map +1 -1
- package/dist/components/task-form.js +6 -5
- package/dist/components/task-form.js.map +1 -1
- package/dist/components/ui.d.ts +16 -0
- package/dist/components/ui.d.ts.map +1 -1
- package/dist/components/ui.js +10 -0
- package/dist/components/ui.js.map +1 -1
- package/dist/console.css +362 -67
- package/dist/console.d.ts +2 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +90 -14
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +14 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +36 -1
- package/dist/data.js.map +1 -1
- package/dist/i18n/en.d.ts +89 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +87 -2
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +87 -3
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +6 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +6 -0
- package/dist/limits.js.map +1 -1
- package/dist/plugin/args.d.ts +6 -1
- package/dist/plugin/args.d.ts.map +1 -1
- package/dist/plugin/args.js +16 -11
- package/dist/plugin/args.js.map +1 -1
- package/dist/plugin/bridge.d.ts +21 -1
- package/dist/plugin/bridge.d.ts.map +1 -1
- package/dist/plugin/bridge.js +28 -0
- package/dist/plugin/bridge.js.map +1 -1
- package/dist/plugin/capabilities.d.ts +1 -1
- package/dist/plugin/capabilities.d.ts.map +1 -1
- package/dist/plugin/capabilities.js +10 -0
- package/dist/plugin/capabilities.js.map +1 -1
- package/dist/plugin/context.d.ts +165 -14
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/define.d.ts +13 -1
- package/dist/plugin/define.d.ts.map +1 -1
- package/dist/plugin/define.js +17 -1
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/limits.d.ts +4 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +4 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/manifest.d.ts +15 -0
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +61 -4
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +44 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +55 -3
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/plugin/testing.d.ts +15 -1
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +40 -4
- package/dist/plugin/testing.js.map +1 -1
- package/dist/plugin/web.d.ts +19 -0
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +17 -1
- package/dist/plugin/web.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/router.d.ts +19 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +18 -0
- package/dist/router.js.map +1 -1
- package/dist/routes.d.ts +11 -2
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +14 -1
- package/dist/routes.js.map +1 -1
- package/dist/schemas.d.ts +367 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +62 -2
- package/dist/schemas.js.map +1 -1
- package/dist/vocabulary.d.ts +1 -1
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +6 -0
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +8 -5
- package/docs/specs/plugins.md +62 -42
- package/docs/specs/rest.md +23 -6
- package/package.json +1 -1
- package/skills/building-a-plugin/SKILL.md +8 -6
- package/skills/working-the-board/SKILL.md +1 -1
- package/src/api.ts +17 -0
- package/src/cli/cli.ts +227 -19
- package/src/cli/format.ts +96 -21
- package/src/cli/help.ts +47 -10
- package/src/client.ts +74 -0
- package/src/compat.ts +1 -1
- package/src/components/board.tsx +83 -42
- package/src/components/decision-form.tsx +13 -32
- package/src/components/event-feed.tsx +36 -9
- package/src/components/my-decisions.tsx +50 -5
- package/src/components/people.tsx +394 -37
- package/src/components/picker.tsx +11 -2
- package/src/components/plugin-frame.tsx +39 -3
- package/src/components/plugin-settings.tsx +346 -137
- package/src/components/projects.tsx +14 -14
- package/src/components/searches.ts +47 -0
- package/src/components/task-form.tsx +23 -28
- package/src/components/ui.tsx +36 -0
- package/src/console.tsx +229 -40
- package/src/data.ts +53 -1
- package/src/i18n/en.ts +98 -2
- package/src/i18n/ko.ts +95 -3
- package/src/index.ts +11 -0
- package/src/limits.ts +6 -0
- package/src/plugin/args.ts +16 -11
- package/src/plugin/bridge.ts +46 -0
- package/src/plugin/capabilities.ts +11 -0
- package/src/plugin/context.ts +177 -11
- package/src/plugin/define.ts +34 -0
- package/src/plugin/limits.ts +4 -0
- package/src/plugin/manifest.ts +74 -3
- package/src/plugin/rest-schemas.ts +62 -5
- package/src/plugin/testing.ts +61 -5
- package/src/plugin/web.ts +34 -0
- package/src/plugin.ts +1 -0
- package/src/router.ts +25 -0
- package/src/routes.ts +17 -2
- package/src/schemas.ts +81 -2
- package/src/styles/console.css +362 -67
- package/src/vocabulary.ts +6 -0
|
@@ -71,25 +71,26 @@ Produces the **design**: one table, a row per thing the feature does, saying who
|
|
|
71
71
|
|---|---|
|
|
72
72
|
| An agent does it for a person, and something changes | A **command**: `defineCommand({ about, args, roles, run })`. Its `text` answer is for people, its `data` for agents (`--json`); it does one thing and does it again safely where it can. |
|
|
73
73
|
| An agent, or a page, looks something up | A **query**: `defineQuery(...)`, which writes nothing; a query may answer a file. |
|
|
74
|
-
| A person must approve, choose or confirm | A **decision** the command raises with `ctx.console.decisions.ask`, with options, addressed to the person a setting or the record names (`deciderId`), or to several of them (`deciderIds`, any of whom may answer), `about` the record it is for, its question, body and labels written once, in the language of whoever is to answer: `ctx.console.people.get(id)` says it as `language`, and where that is `null`, a person who has not opened the console yet, the plugin writes in the first of `ctx.console.workspace().languages` ([ADR-0065](/docs/adr/0065-a-plugin-writes-one-text-and-a-persons-language-is-kept-from-the-first-time-the-pages-see-them.md)); the command answers `waiting`, the agent waits as the console's own `ask` is waited for, and the plugin hears the answer in a hook on `console:decision.answered` and goes on. The plugin never answers one, and never computes what a person must choose. |
|
|
74
|
+
| A person must approve, choose or confirm | A **decision** the command raises with `ctx.console.decisions.ask`, with options, addressed to the person a setting or the record names (`deciderId`), or to several of them (`deciderIds`, any of whom may answer), anyone active of the workspace, in the board project or not: they find it among their decisions and answer it there, and whoever manages them up the reporting line may answer it too ([ADR-0068](/docs/adr/0068-a-decision-reaches-whom-it-is-addressed-to-wherever-it-is-and-a-plugins-reaches-the-managers-above-them.md)); raised in the board project for whoever called the command, in the project or not, who reads it back as its raiser and nothing else of the project, so that a requester needs no place in the project ([ADR-0080](/docs/adr/0080-a-plugin-reaches-the-projects-it-is-placed-on-and-whoever-may-use-it-is-a-requester-in-its-board-project.md)); a page sends a person to it with `frame.navigate("/decisions/<id>")`, which opens for them though the project does not; `about` the record it is for, its question, body and labels written once, in the language of whoever is to answer: `ctx.console.people.get(id)` says it as `language`, and where that is `null`, a person who has not opened the console yet, the plugin writes in the first of `ctx.console.workspace().languages` ([ADR-0065](/docs/adr/0065-a-plugin-writes-one-text-and-a-persons-language-is-kept-from-the-first-time-the-pages-see-them.md)); the command answers `waiting`, the agent waits as the console's own `ask` is waited for, and the plugin hears the answer in a hook on `console:decision.answered` and goes on. The plugin never answers one, and never computes what a person must choose. |
|
|
75
75
|
| Someone must do something later | A **task** on the board project with `ctx.console.tasks.create`, marked as the plugin's, worked by whoever takes it; its title and body, and a comment on it, one text each, written as a decision's words are, in the language of whoever it is for. |
|
|
76
|
-
| The console must tell the plugin something happened | A **hook**, `on["console:<kind>"]` (`events:console`): the plugin's board project, the projects it is on and the items it made are what it hears of. Delivery is at least once: a handler reads the record first and does nothing twice. |
|
|
76
|
+
| The console must tell the plugin something happened | A **hook**, `on["console:<kind>"]` (`events:console`): the plugin's board project, the projects it is on and the items it made are what it hears of. Delivery is at least once: a handler reads the record first and does nothing twice, and the event's `id` (one across both streams) with its `attempt` is what it keeps to tell a delivery repeated; a service that says to come back later is told to the console as `retryAfterMs` on the refusal, and the next try waits that long. A collection that grows with every event, deliveries, log lines, gets `retention: { days }` and `history: false`, so that it never reaches the quota. |
|
|
77
77
|
| Another plugin must tell it | A **hook** on `plugin:<key>:<kind>` (`events:plugins`), or a call on the other's `api` (`plugins:<key>`). |
|
|
78
78
|
| Time passes | A **job** (`jobs`), `every` or `at` in the workspace's time zone, never two at once; what it did goes into records and, where people should know, a task or a decision. |
|
|
79
79
|
| An outside service calls in | An **endpoint** (`endpoints`): a `person` endpoint for whoever holds a role, a `webhook` for nobody, verified with `ctx.secrets.verify` against a secret setting. |
|
|
80
|
-
| The plugin must call out | `ctx.fetch` to a host the manifest names (`outbound:<host>`), the
|
|
80
|
+
| The plugin must call out | `ctx.fetch` to a host the manifest names (`outbound:<host>`), with `GET`, `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE` or `OPTIONS`, the secrets put in by the console from `secret` settings (`secret` or `secrets`, each `as` a header, `bearer`, a query parameter, `basic` or `body:<field>`), never read by the plugin, nor in an answer that sends them back; what an answer gives back that is secret, the tokens of an exchange, sealed by the console into `secret` settings with `seal` before the plugin reads the answer, with their expiry, the answer's `sealed` saying what became of each (a token endpoint is asked for JSON, since the body of an answer that is no JSON is withheld), and sealed again by a job that reads `ctx.secrets.status(name)`; a callback the service is to call is `ctx.endpoints.url(name)`, the full address of one of the plugin's endpoints, and a link back to the console starts from `ctx.console.workspace().url`. |
|
|
81
|
+
| It acts for a person who did something elsewhere, or reads another plugin as itself | `people:act`, then `ctx.plugins.get(key).for(personId)` for the other plugin's api as the person, or `ctx.console.decisions.answer(id, answer, { for })` for a decision the person answered elsewhere, one on their own plate (addressed to them, or a plugin's addressed to someone they manage): the person's standing as a member decides, never their administration, and the record is theirs through the plugin. A role of another plugin, asked in the manifest's `grants` with why, is held as itself from a job or a hook, with `ctx.plugin.grants` saying what was granted ([ADR-0072](/docs/adr/0072-a-plugin-is-a-principal-it-holds-roles-granted-to-it-calls-as-itself-and-acts-for-a-person-within-what-both-may-do.md)). |
|
|
81
82
|
| People look at it, or fill a form (a calendar starts its week on `frame.context.workspace.firstDay`, the day the workspace's setting says, and reads `timeZone` beside it; faces come from `frame.people.picture(id)`, since a frame loads no image from elsewhere) | A **page** (level `workspace` or `project`) or a **widget** on the front page, which declares the `sizes` it comes in, at least one of them no wider than four cells, which is all a phone has (`small` 2×2, `medium` 4×2, `large` 4×4, `wide` 8×2, `full` 8×4, square cells of the page's grid) and lays itself out for the one it has (`frame.context.size`, `frame.onSize`), since the person arranges the page ([ADR-0061](/docs/adr/0061-the-front-page-is-one-grid-of-tiles-a-person-arranges-by-hand.md)): it shows records and calls commands and queries through the bridge; the logic stays in the server module, so that the command line and the pages do the same thing. |
|
|
82
83
|
| An agent must know how | A **skill** in the package, one per kind of work, naming the commands as `console plugin <key> <command>`, with the rules of that work; `SKILLCDN.md` at the root. The agent note of the manifest is the one line that sends an agent to them. |
|
|
83
84
|
|
|
84
85
|
Then the data. Records, unless the feature needs what records do not give: joins across many collections, more rows than a plugin's records may hold, or figures beyond counting, summing, the least and the most; then `storage:sql`, a schema and a role of the plugin's own with migrations under `migrations/`, which needs the deployment's database user to hold `CREATEROLE` and is said in the hand-over. Records are the default: the console keeps them with versions, files, links, search and aggregates, exports and purges them, and shows them to people by role; a schema is the plugin's to keep.
|
|
85
86
|
|
|
86
|
-
Then the capabilities: the list the split needs, each read as the sentence the administrator will consent to (the specification's catalogue says what each opens and what a malicious plugin could do with it). A capability no row needs is dropped; `people:read:all`, `projects:read:all`, `storage:sql` and every `outbound:<host>` are asked for only where the design shows the row that needs them. Write the design: the table, the collections with their fields, the roles, the settings, the board (`needs`, the defaults), the menu group, the pages and the widgets, and the capabilities with their sentences; stop for the checkpoint.
|
|
87
|
+
Then the capabilities: the list the split needs, each read as the sentence the administrator will consent to (the specification's catalogue says what each opens and what a malicious plugin could do with it). A capability no row needs is dropped; `people:read:all`, `people:read:email` (the work email, to match a person to an account elsewhere), `projects:read:all`, `storage:sql` and every `outbound:<host>` are asked for only where the design shows the row that needs them. Write the design: the table, the collections with their fields, the roles, the settings, the board (`needs`, the defaults), the menu group, the pages and the widgets, and the capabilities with their sentences; stop for the checkpoint.
|
|
87
88
|
|
|
88
89
|
### Phase 2: Start from the template, then fill it
|
|
89
90
|
|
|
90
91
|
Produces the **plugin as source**. `console-plugin init <dir> --key <key> --name "<Name>"` writes the smallest complete plugin: the manifest, a server module with one collection, one command and one query, a web bundle with one page and one widget, one skill with its `SKILLCDN.md`, the tests, the build and a README that says where things are; `--console` names the version of `@skillcdn/console` it depends on, the command's own unless said, and for a plugin written for a deployed console, the version that console runs (`console whoami` says it), and the manifest's `console` is written from it, the line of that version (`>=0.4.3 <0.5.0`): the consoles the plugin runs on, which the console checks when it reads the plugin and `console-plugin check` holds the dependency to; narrow it to the patch that brought what the plugin depends on, and widen it to the next line once the plugin is built against it; `--package <name>` the package's name where it is not `console-plugin-<key>`, a scoped one (`@<scope>/console-plugin-<key>`) for a repository of several plugins, published as public; `--repository <url>` with `--directory <path>` where the plugin lives in a repository, which fill `repository`, `homepage` and `bugs` and the manifest's `store`; and `--languages en,ko` the languages of its words, `en` first, which gives every language map and both manifests' translations the others as English words to translate, of which `console-plugin check` warns while they stay English. Then, in `<dir>`: `npm install`, `npm run build`, `npm test`, `npm run check`, all green before a line is changed, and `git init`.
|
|
91
92
|
|
|
92
|
-
Then the design goes in, file by file: the manifest `console-plugin.json` from the design, its `key`, names and descriptions per language, `agentNote`, `capabilities`, `roles` and `defaultRole`, `board`, `settings`, `menu`, `pages`, `widgets`, `dataVersion`; the server module `src/server/index.ts`, one `defineCollection` per collection, one `defineCommand` or `defineQuery` per row, `endpoints`, `on`, `jobs`, `api`, `onEnable` and `onDisable` where the design has them, exported by name for the tests and gathered in `definePlugin(...)` as the default export; the web bundle `src/web/index.ts` and `index.css`, where `connect()` gives the page the context (who looks, at what, in which language), `command`, `query`, `records`, `files`, `navigate
|
|
93
|
+
Then the design goes in, file by file: the manifest `console-plugin.json` from the design, its `key`, names and descriptions per language, `agentNote`, `capabilities`, `roles` (a role for managers is `follows: "reports"`, held by whoever someone reports to and granted by nobody) and `defaultRole`, `board`, `settings`, `menu`, `pages`, `widgets`, `dataVersion`; the server module `src/server/index.ts`, one `defineCollection` per collection, one `defineCommand` or `defineQuery` per row, `endpoints`, `on`, `jobs`, `api`, `onEnable` and `onDisable` where the design has them, exported by name for the tests and gathered in `definePlugin(...)` as the default export; the web bundle `src/web/index.ts` and `index.css`, where `connect()` gives the page the context (who looks, at what, in which language), `command`, `query`, `records`, `files`, `navigate` (a path of the console's), `open` (a link to the web or to mail, from the press itself, which the console's page opens in a new tab), `download`, `setTitle` and the events, every class prefixed `pl-<key>-`, the console's `sc-` classes and `--sc-*` tokens for the look, and every word a person wrote put in as text; the skills under `skills/<name>/SKILL.md`, one per kind of work, in the SkillCDN Format, and the README of the package. The server module imports only what the host allows and bundles everything it imports; it keeps no state between calls but in records, since its thread is started afresh after a fault. Where the design has `storage:sql`, `migrations/0001-<words>.sql` makes the tables, and `manifest.migrations` names the directory.
|
|
93
94
|
|
|
94
95
|
### Phase 3: Test it as the console runs it
|
|
95
96
|
|
|
@@ -118,7 +119,8 @@ The hand-over is a task on the deployment's board, written as [planning-the-boar
|
|
|
118
119
|
|
|
119
120
|
- People decide: a plugin raises decisions and waits; it never answers one, never acts as a person it is not, and never computes an approval. What it makes on a board carries its name and is reversible by people.
|
|
120
121
|
- The fewest capabilities: each one in the manifest has a row of the design that needs it, and the sentence an administrator reads for it is true of the code. `check` warns of one no definition uses; it is dropped.
|
|
121
|
-
- A secret is a `secret` setting the administrator sets, put into a request by the console or verified by it; the plugin never reads its value, logs it, keeps it in a record, or puts it in the repository, the tests or the chat.
|
|
122
|
+
- A secret is a `secret` setting the administrator sets or the console seals from an answer (`seal`), put into a request by the console within the `hosts` the setting names, or verified by it (`use: "verify"` for one that verifies alone); the plugin never reads its value, logs it, keeps it in a record, or puts it in the repository, the tests or the chat. Every form of a secret a request carried, base64 included, is taken out of the answer the plugin reads ([ADR-0079](/docs/adr/0079-a-secret-is-taken-out-of-an-answer-in-the-encodings-a-service-sends-it-back-in.md)), so a value a service sends back by design, a client id inside a token it issues, say, is no secret: it is a plain setting.
|
|
123
|
+
- A plugin acting for a person acts within what that person may do as a member and what the plugin was granted, both, and never answers a decision itself; it never calls its own api (`plugins:<its key>` is refused); a callee reads `ctx.caller.kind === "plugin"` and refuses where its rules need a person at the keyboard.
|
|
122
124
|
- Everything a person wrote is shown as text, in the pages and in a command's answer; the frame renders no HTML from a record, and its classes are prefixed `pl-<key>-`.
|
|
123
125
|
- The server module imports nothing the host refuses, reaches no network but `ctx.fetch`, no file but its own, and keeps no state between calls but in records; a hook does nothing twice.
|
|
124
126
|
- A page reaches the console through the bridge alone: a frame has no network and no WebRTC, and the console serves each script of the bundle with a line before it, so that a source map is a line out. A page that needs WebRTC asks for `outbound:webrtc`, optional where the plugin can go without it, whose reach an administrator reads before consenting: any address, from each person's browser, and no camera or microphone with it ([ADR-0066](/docs/adr/0066-webrtc-is-a-way-out-a-plugin-asks-for-and-how-a-frame-is-held-stays-in-one-place.md)).
|
|
@@ -66,7 +66,7 @@ The work happens where it happens: in the repository, the document, the tool. At
|
|
|
66
66
|
|
|
67
67
|
### Phase 4: Ask when a person must decide
|
|
68
68
|
|
|
69
|
-
A choice the body does not settle, a trade-off, a cost, a change of scope: `console ask "<question>" --option "<one>" --option "<another>" --body "<what they need to know>"`, with `--attach <file>` for a picture of what is to be chosen between, a screenshot of what was made; a picture the body names as `` is shown there ([ADR-0055](/docs/adr/0055-a-decision-carries-the-files-put-on-it-when-it-is-raised.md)). The decision is for the person you work for, who finds it among their decisions; `--to <login>` addresses it to another person of the project when the task or the rules name who decides such things ([ADR-0042](/docs/adr/0042-a-decision-is-addressed-to-a-person-its-raiser-unless-another-is-named.md)), and `--to` given again to several of them, any of whom may answer, the first answer ending it ([ADR-0057](/docs/adr/0057-a-decision-may-be-addressed-to-several-people-and-the-first-answer-ends-it.md)). The run waits for the answer; the command waits a minute and exits with `3` while it is still to come. Keep waiting with `console decision <id> --wait 100` (seconds), as often as needed, and meanwhile do only what does not depend on the answer. Act on the answer as given, which may be the person's own words rather than one of the options, marked as theirs; what was answered is not asked again. An answer that reaches you anywhere but the board is written on the decision in the person's name first (`console answer`, above) and acted on from there; a question the work overtook is answered the same way, with the person's word on it, however short. Once acted on, `console decision <id> --outcome "<what followed>"` makes the decision read as a record.
|
|
69
|
+
A choice the body does not settle, a trade-off, a cost, a change of scope: `console ask "<question>" --option "<one>" --option "<another>" --body "<what they need to know>"`, with `--attach <file>` for a picture of what is to be chosen between, a screenshot of what was made; a picture the body names as `` is shown there ([ADR-0055](/docs/adr/0055-a-decision-carries-the-files-put-on-it-when-it-is-raised.md)). The decision is for the person you work for, who finds it among their decisions; `--to <login>` addresses it to another person of the project when the task or the rules name who decides such things ([ADR-0042](/docs/adr/0042-a-decision-is-addressed-to-a-person-its-raiser-unless-another-is-named.md)), and `--to` given again to several of them, any of whom may answer, the first answer ending it ([ADR-0057](/docs/adr/0057-a-decision-may-be-addressed-to-several-people-and-the-first-answer-ends-it.md)). The run waits for the answer; the command waits a minute and exits with `3` while it is still to come. Keep waiting with `console decision <id> --wait 100` (seconds), as often as needed, and meanwhile do only what does not depend on the answer; the command finds a decision wherever it is, in the project it works in or, for a plugin's decision that waits in the plugin's own project, there ([ADR-0068](/docs/adr/0068-a-decision-reaches-whom-it-is-addressed-to-wherever-it-is-and-a-plugins-reaches-the-managers-above-them.md)). Act on the answer as given, which may be the person's own words rather than one of the options, marked as theirs; what was answered is not asked again. An answer that reaches you anywhere but the board is written on the decision in the person's name first (`console answer`, above) and acted on from there; a question the work overtook is answered the same way, with the person's word on it, however short. Once acted on, `console decision <id> --outcome "<what followed>"` makes the decision read as a record.
|
|
70
70
|
|
|
71
71
|
### Phase 5: Hand in
|
|
72
72
|
|
package/src/api.ts
CHANGED
|
@@ -108,6 +108,9 @@ export {
|
|
|
108
108
|
MAX_STREAMS_PER_PERSON,
|
|
109
109
|
MAX_SUMMARY_LENGTH,
|
|
110
110
|
MAX_TASKS_PER_PROJECT,
|
|
111
|
+
MAX_TEAM_KEY_LENGTH,
|
|
112
|
+
MAX_TEAM_NAME_LENGTH,
|
|
113
|
+
MAX_TEAMS,
|
|
111
114
|
MAX_TITLE_LENGTH,
|
|
112
115
|
MAX_TOKEN_DAYS,
|
|
113
116
|
MAX_TOKEN_NAME_LENGTH,
|
|
@@ -124,6 +127,8 @@ export {
|
|
|
124
127
|
CLAIM_PATH,
|
|
125
128
|
categoryPath,
|
|
126
129
|
connectPath,
|
|
130
|
+
decisionFilePath,
|
|
131
|
+
decisionPath,
|
|
127
132
|
isSignInFailure,
|
|
128
133
|
loginPath,
|
|
129
134
|
PROJECT_COLLECTIONS,
|
|
@@ -224,6 +229,7 @@ export {
|
|
|
224
229
|
type RestProjectRules,
|
|
225
230
|
type RestProjects,
|
|
226
231
|
type RestProvider,
|
|
232
|
+
type RestReachedDecision,
|
|
227
233
|
type RestReport,
|
|
228
234
|
type RestReportInput,
|
|
229
235
|
type RestRules,
|
|
@@ -245,6 +251,11 @@ export {
|
|
|
245
251
|
type RestTaskLink,
|
|
246
252
|
type RestTaskPatch,
|
|
247
253
|
type RestTasks,
|
|
254
|
+
type RestTeam,
|
|
255
|
+
type RestTeamInput,
|
|
256
|
+
type RestTeamMemberInput,
|
|
257
|
+
type RestTeamPatch,
|
|
258
|
+
type RestTeams,
|
|
248
259
|
type RestToken,
|
|
249
260
|
type RestTokenCreated,
|
|
250
261
|
type RestTokenInput,
|
|
@@ -324,6 +335,7 @@ export {
|
|
|
324
335
|
restProjectSchema,
|
|
325
336
|
restProjectsSchema,
|
|
326
337
|
restProviderSchema,
|
|
338
|
+
restReachedDecisionSchema,
|
|
327
339
|
restReportInputSchema,
|
|
328
340
|
restReportSchema,
|
|
329
341
|
restRulesInputSchema,
|
|
@@ -345,6 +357,11 @@ export {
|
|
|
345
357
|
restTaskPatchSchema,
|
|
346
358
|
restTaskSchema,
|
|
347
359
|
restTasksSchema,
|
|
360
|
+
restTeamInputSchema,
|
|
361
|
+
restTeamMemberInputSchema,
|
|
362
|
+
restTeamPatchSchema,
|
|
363
|
+
restTeamSchema,
|
|
364
|
+
restTeamsSchema,
|
|
348
365
|
restTokenCreatedSchema,
|
|
349
366
|
restTokenInputSchema,
|
|
350
367
|
restTokenSchema,
|
package/src/cli/cli.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { PLUGIN_LIST_LIMIT } from "../plugin/limits.js";
|
|
|
33
33
|
import { fillRules, RULES_PATH, RULES_TITLE } from "../rules.js";
|
|
34
34
|
import {
|
|
35
35
|
hostOfLogin,
|
|
36
|
+
type RestAnswerInput,
|
|
36
37
|
type RestClaim,
|
|
37
38
|
type RestDecision,
|
|
38
39
|
type RestMember,
|
|
@@ -101,6 +102,7 @@ import {
|
|
|
101
102
|
formatPersonLine,
|
|
102
103
|
formatPersonWork,
|
|
103
104
|
formatPlugin,
|
|
105
|
+
formatPluginAsks,
|
|
104
106
|
formatPluginGrantLine,
|
|
105
107
|
formatPluginHelp,
|
|
106
108
|
formatPluginRecord,
|
|
@@ -115,6 +117,7 @@ import {
|
|
|
115
117
|
formatRunLine,
|
|
116
118
|
formatTask,
|
|
117
119
|
formatTaskLine,
|
|
120
|
+
formatTeamLine,
|
|
118
121
|
formatVersion,
|
|
119
122
|
formatVersionLine,
|
|
120
123
|
formatWork,
|
|
@@ -632,9 +635,14 @@ function theTwo(positionals: readonly string[], ask: string): readonly [string,
|
|
|
632
635
|
* The decision once answered, or as it stands when the wait is over. Each request asks the
|
|
633
636
|
* console to hold it for a while, so the answer arrives as soon as a person gives it.
|
|
634
637
|
*/
|
|
638
|
+
/** Whatever waits for a decision's answer: the project's client, or the decision wherever it is (ADR-0068). */
|
|
639
|
+
interface Waiter {
|
|
640
|
+
awaitDecision(id: string, waitSeconds: number): Promise<RestDecision>;
|
|
641
|
+
}
|
|
642
|
+
|
|
635
643
|
async function waitForAnswer(
|
|
636
644
|
io: CliIo,
|
|
637
|
-
project:
|
|
645
|
+
project: Waiter,
|
|
638
646
|
decision: RestDecision,
|
|
639
647
|
seconds: number,
|
|
640
648
|
): Promise<RestDecision> {
|
|
@@ -665,7 +673,7 @@ const stillWaiting = (id: string): string =>
|
|
|
665
673
|
async function settle(
|
|
666
674
|
io: CliIo,
|
|
667
675
|
session: Session,
|
|
668
|
-
project:
|
|
676
|
+
project: Waiter,
|
|
669
677
|
decision: RestDecision,
|
|
670
678
|
seconds: number,
|
|
671
679
|
shown = false,
|
|
@@ -1919,12 +1927,18 @@ async function pluginEnable(
|
|
|
1919
1927
|
answer(io, session, enabled, () =>
|
|
1920
1928
|
[
|
|
1921
1929
|
`Enabled ${enabled.key}${enabled.board === null ? "" : `, with the board project ${enabled.board.key}`}; on ${enabled.projects === "all" || enabled.projects === null ? "every project" : enabled.projects.join(", ") || "no project"}.`,
|
|
1930
|
+
...(enabled.needsTimeZone === true
|
|
1931
|
+
? [
|
|
1932
|
+
"The workspace has no time zone: the plugin's times of day run on UTC until an administrator sets one, with console workspace edit --time-zone <zone>.",
|
|
1933
|
+
]
|
|
1934
|
+
: []),
|
|
1922
1935
|
...(enabled.settings.length === 0
|
|
1923
1936
|
? []
|
|
1924
1937
|
: [
|
|
1925
1938
|
"Settings:",
|
|
1926
1939
|
...enabled.settings.map((setting) => formatPluginSettingLine(setting, me.language)),
|
|
1927
1940
|
]),
|
|
1941
|
+
...formatPluginAsks(enabled, me.language),
|
|
1928
1942
|
].join("\n"),
|
|
1929
1943
|
);
|
|
1930
1944
|
return EXIT.ok;
|
|
@@ -1999,7 +2013,10 @@ async function pluginSecret(
|
|
|
1999
2013
|
return EXIT.ok;
|
|
2000
2014
|
}
|
|
2001
2015
|
|
|
2002
|
-
/**
|
|
2016
|
+
/**
|
|
2017
|
+
* Grants a role of the plugin to a person, to the members of a project, to another plugin, to the
|
|
2018
|
+
* members of a team, or to everyone; an administrator's.
|
|
2019
|
+
*/
|
|
2003
2020
|
async function pluginGrant(
|
|
2004
2021
|
io: CliIo,
|
|
2005
2022
|
session: Session,
|
|
@@ -2009,14 +2026,26 @@ async function pluginGrant(
|
|
|
2009
2026
|
): Promise<number> {
|
|
2010
2027
|
const { values, positionals } = parse(rest, {
|
|
2011
2028
|
person: { type: "string" },
|
|
2029
|
+
plugin: { type: "string" },
|
|
2030
|
+
team: { type: "string" },
|
|
2012
2031
|
everyone: { type: "boolean" },
|
|
2013
2032
|
});
|
|
2014
|
-
const usage = `console plugin ${client.key} grant <role> --person <login> | --project <key> | --everyone`;
|
|
2033
|
+
const usage = `console plugin ${client.key} grant <role> --person <login> | --project <key> | --plugin <key> | --team <key> | --everyone`;
|
|
2015
2034
|
const role = theOne(positionals, `Say which role: ${usage}`);
|
|
2016
2035
|
const login = text(values, "person");
|
|
2036
|
+
const other = text(values, "plugin");
|
|
2037
|
+
const teamKey = text(values, "team");
|
|
2017
2038
|
const everyone = on(values, "everyone");
|
|
2018
|
-
if (
|
|
2019
|
-
|
|
2039
|
+
if (
|
|
2040
|
+
[
|
|
2041
|
+
login !== undefined,
|
|
2042
|
+
projectKey !== undefined,
|
|
2043
|
+
other !== undefined,
|
|
2044
|
+
teamKey !== undefined,
|
|
2045
|
+
everyone,
|
|
2046
|
+
].filter(Boolean).length !== 1
|
|
2047
|
+
) {
|
|
2048
|
+
throw misuse(`Say whom, one of the five: ${usage}`);
|
|
2020
2049
|
}
|
|
2021
2050
|
let input: RestPluginGrantInput;
|
|
2022
2051
|
if (login !== undefined) {
|
|
@@ -2027,6 +2056,10 @@ async function pluginGrant(
|
|
|
2027
2056
|
input = { role, person: person.id };
|
|
2028
2057
|
} else if (projectKey !== undefined) {
|
|
2029
2058
|
input = { role, project: projectKey };
|
|
2059
|
+
} else if (other !== undefined) {
|
|
2060
|
+
input = { role, plugin: other };
|
|
2061
|
+
} else if (teamKey !== undefined) {
|
|
2062
|
+
input = { role, team: teamKey };
|
|
2030
2063
|
} else {
|
|
2031
2064
|
input = { role, everyone: true };
|
|
2032
2065
|
}
|
|
@@ -2401,14 +2434,25 @@ async function attachmentsOf(io: CliIo, paths: readonly string[]): Promise<FileU
|
|
|
2401
2434
|
/**
|
|
2402
2435
|
* A file of the project, read from the console and written on this machine: one a run handed
|
|
2403
2436
|
* in, one put in a comment or on a decision, or one attached to a page, by its id, so that an
|
|
2404
|
-
* agent can look at a picture a person put on the board.
|
|
2437
|
+
* agent can look at a picture a person put on the board. With `--decision`, a file of that
|
|
2438
|
+
* decision, read at the decision's own address (ADR-0068): wherever it is, in the project the
|
|
2439
|
+
* command works in or one it does not name.
|
|
2405
2440
|
*/
|
|
2406
2441
|
const file: Command = async (args, io) => {
|
|
2407
|
-
const { values, positionals } = parse(args, {
|
|
2408
|
-
|
|
2442
|
+
const { values, positionals } = parse(args, {
|
|
2443
|
+
out: { type: "string" },
|
|
2444
|
+
decision: { type: "string" },
|
|
2445
|
+
});
|
|
2446
|
+
const id = theOne(
|
|
2447
|
+
positionals,
|
|
2448
|
+
"Say which file: console file <id> [--decision <id>] [--out <path>]",
|
|
2449
|
+
);
|
|
2450
|
+
const decisionId = text(values, "decision");
|
|
2409
2451
|
const session = await open(io, values);
|
|
2410
|
-
const
|
|
2411
|
-
|
|
2452
|
+
const read =
|
|
2453
|
+
decisionId === undefined
|
|
2454
|
+
? await (await session.project()).readFile(id)
|
|
2455
|
+
: await session.client.readDecisionFile(decisionId, id);
|
|
2412
2456
|
const target = text(values, "out") ?? read.name;
|
|
2413
2457
|
let saved: string;
|
|
2414
2458
|
try {
|
|
@@ -2679,15 +2723,92 @@ const answering: Command = async (args, io) => {
|
|
|
2679
2723
|
}
|
|
2680
2724
|
const note = await bodyOf(io, values, text(values, "note"));
|
|
2681
2725
|
const session = await open(io, values);
|
|
2682
|
-
const
|
|
2683
|
-
const answered = await project.answerDecision(id, {
|
|
2726
|
+
const { decision: answered, atItsAddress } = await answerReached(session, id, {
|
|
2684
2727
|
...(own === undefined ? { option } : { own }),
|
|
2685
2728
|
...(note === undefined ? {} : { note }),
|
|
2686
2729
|
});
|
|
2687
|
-
answer(io, session, answered, () => formatDecision(answered));
|
|
2730
|
+
answer(io, session, answered, () => formatDecision(answered, { atItsAddress }));
|
|
2688
2731
|
return EXIT.ok;
|
|
2689
2732
|
};
|
|
2690
2733
|
|
|
2734
|
+
/** Whether a refusal says the decision is not in the project the command works in, or the project is not the person's. */
|
|
2735
|
+
const notInProject = (error: unknown): boolean =>
|
|
2736
|
+
error instanceof ApiError &&
|
|
2737
|
+
(error.code === "decision.not_found" || error.code === "project.not_found");
|
|
2738
|
+
|
|
2739
|
+
/**
|
|
2740
|
+
* One decision as the command reaches it (ADR-0068): in the project the command works in, as
|
|
2741
|
+
* before; else wherever it is, addressed to the person, raised by them, or a plugin's addressed
|
|
2742
|
+
* to someone they manage, through the console's own route for one decision. A plugin's decision
|
|
2743
|
+
* waits in the plugin's board project, which a checkout bound to another project does not name,
|
|
2744
|
+
* and which the person may not be in at all. A console from before that route answers as before.
|
|
2745
|
+
*/
|
|
2746
|
+
async function reachDecision(
|
|
2747
|
+
session: Session,
|
|
2748
|
+
id: string,
|
|
2749
|
+
): Promise<{
|
|
2750
|
+
readonly decision: RestDecision;
|
|
2751
|
+
readonly waiter: Waiter;
|
|
2752
|
+
/** Whether it was reached at its own address, outside the project the command works in. */
|
|
2753
|
+
readonly atItsAddress: boolean;
|
|
2754
|
+
}> {
|
|
2755
|
+
if ((await session.projectKey()) !== undefined) {
|
|
2756
|
+
const project = await session.project();
|
|
2757
|
+
try {
|
|
2758
|
+
return { decision: await project.decision(id), waiter: project, atItsAddress: false };
|
|
2759
|
+
} catch (error) {
|
|
2760
|
+
if (!notInProject(error)) {
|
|
2761
|
+
throw error;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
const anywhere = session.client;
|
|
2766
|
+
try {
|
|
2767
|
+
const reached = await anywhere.decision(id);
|
|
2768
|
+
return {
|
|
2769
|
+
decision: reached.decision,
|
|
2770
|
+
waiter: {
|
|
2771
|
+
awaitDecision: async (decisionId, seconds) =>
|
|
2772
|
+
(await anywhere.awaitDecision(decisionId, seconds)).decision,
|
|
2773
|
+
},
|
|
2774
|
+
atItsAddress: true,
|
|
2775
|
+
};
|
|
2776
|
+
} catch (error) {
|
|
2777
|
+
if (error instanceof ApiError && error.status === 404) {
|
|
2778
|
+
throw new ApiError(404, "decision.not_found", "The decision was not found.");
|
|
2779
|
+
}
|
|
2780
|
+
throw error;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
/** Writes an answer on a decision as the command reaches it (ADR-0068): in the project, else wherever it is. */
|
|
2785
|
+
async function answerReached(
|
|
2786
|
+
session: Session,
|
|
2787
|
+
id: string,
|
|
2788
|
+
input: RestAnswerInput,
|
|
2789
|
+
): Promise<{ readonly decision: RestDecision; readonly atItsAddress: boolean }> {
|
|
2790
|
+
if ((await session.projectKey()) !== undefined) {
|
|
2791
|
+
try {
|
|
2792
|
+
return {
|
|
2793
|
+
decision: await (await session.project()).answerDecision(id, input),
|
|
2794
|
+
atItsAddress: false,
|
|
2795
|
+
};
|
|
2796
|
+
} catch (error) {
|
|
2797
|
+
if (!notInProject(error)) {
|
|
2798
|
+
throw error;
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
try {
|
|
2803
|
+
return { decision: await session.client.answerDecision(id, input), atItsAddress: true };
|
|
2804
|
+
} catch (error) {
|
|
2805
|
+
if (error instanceof ApiError && error.status === 404) {
|
|
2806
|
+
throw new ApiError(404, "decision.not_found", "The decision was not found.");
|
|
2807
|
+
}
|
|
2808
|
+
throw error;
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2691
2812
|
const decision: Command = async (args, io) => {
|
|
2692
2813
|
const { values, positionals } = parse(args, {
|
|
2693
2814
|
wait: { type: "string" },
|
|
@@ -2701,19 +2822,19 @@ const decision: Command = async (args, io) => {
|
|
|
2701
2822
|
const seconds = secondsOf(text(values, "wait"), 0);
|
|
2702
2823
|
const outcome = await bodyOf(io, values, text(values, "outcome"));
|
|
2703
2824
|
const session = await open(io, values);
|
|
2704
|
-
const project = await session.project();
|
|
2705
2825
|
if (outcome !== undefined) {
|
|
2706
2826
|
// What followed the decision: the record grows, and is printed as it stands.
|
|
2827
|
+
const project = await session.project();
|
|
2707
2828
|
const grown = await project.updateDecision(id, { outcome });
|
|
2708
2829
|
answer(io, session, grown, () => formatDecision(grown));
|
|
2709
2830
|
return EXIT.ok;
|
|
2710
2831
|
}
|
|
2711
|
-
const found = await
|
|
2832
|
+
const { decision: found, waiter, atItsAddress } = await reachDecision(session, id);
|
|
2712
2833
|
if (seconds === 0) {
|
|
2713
|
-
answer(io, session, found, () => formatDecision(found));
|
|
2834
|
+
answer(io, session, found, () => formatDecision(found, { atItsAddress }));
|
|
2714
2835
|
return EXIT.ok;
|
|
2715
2836
|
}
|
|
2716
|
-
return settle(io, session,
|
|
2837
|
+
return settle(io, session, waiter, found, seconds);
|
|
2717
2838
|
};
|
|
2718
2839
|
|
|
2719
2840
|
const docs: Command = async (args, io) => {
|
|
@@ -3215,6 +3336,77 @@ const people: Command = async (args, io) => {
|
|
|
3215
3336
|
return EXIT.ok;
|
|
3216
3337
|
};
|
|
3217
3338
|
|
|
3339
|
+
/** The teams of the workspace (ADR-0073): each with who is in it, by login. */
|
|
3340
|
+
const teams: Command = async (args, io) => {
|
|
3341
|
+
const { values } = parse(args, {}, false);
|
|
3342
|
+
const session = await open(io, values);
|
|
3343
|
+
const [found, everyone] = await Promise.all([session.client.teams(), session.client.people()]);
|
|
3344
|
+
const loginOf = new Map(everyone.items.map((person) => [person.id, person.login]));
|
|
3345
|
+
answer(io, session, found, () =>
|
|
3346
|
+
found.items.length === 0
|
|
3347
|
+
? "No teams yet. console team new <key> <name> makes one."
|
|
3348
|
+
: found.items.map((team) => formatTeamLine(team, loginOf)).join("\n"),
|
|
3349
|
+
);
|
|
3350
|
+
return EXIT.ok;
|
|
3351
|
+
};
|
|
3352
|
+
|
|
3353
|
+
const TEAM_USAGE =
|
|
3354
|
+
'Say what to do: console team new <key> "<name>" | team rename <key> "<new name>" | team remove <key> | team add <key> <login> | team drop <key> <login>';
|
|
3355
|
+
|
|
3356
|
+
// A team is called by its key (ADR-0074), which never changes; its name is what people read.
|
|
3357
|
+
const team: Command = async (args, io) => {
|
|
3358
|
+
const what = args[0];
|
|
3359
|
+
if (what === "new") {
|
|
3360
|
+
const { values, positionals } = parse(args.slice(1), {});
|
|
3361
|
+
const [key, name] = theTwo(
|
|
3362
|
+
positionals,
|
|
3363
|
+
'Say the key and the name: console team new <key> "<name>"',
|
|
3364
|
+
);
|
|
3365
|
+
const session = await open(io, values);
|
|
3366
|
+
const made = await session.client.createTeam({ key, name });
|
|
3367
|
+
answer(io, session, made, () => formatTeamLine(made, new Map()));
|
|
3368
|
+
return EXIT.ok;
|
|
3369
|
+
}
|
|
3370
|
+
if (what === "rename") {
|
|
3371
|
+
const { values, positionals } = parse(args.slice(1), {});
|
|
3372
|
+
const [key, next] = theTwo(
|
|
3373
|
+
positionals,
|
|
3374
|
+
'Say which team and its new name: console team rename <key> "<new name>"',
|
|
3375
|
+
);
|
|
3376
|
+
const session = await open(io, values);
|
|
3377
|
+
const changed = await session.client.renameTeam(key, { name: next });
|
|
3378
|
+
answer(io, session, changed, () => formatTeamLine(changed, new Map()));
|
|
3379
|
+
return EXIT.ok;
|
|
3380
|
+
}
|
|
3381
|
+
if (what === "remove") {
|
|
3382
|
+
const { values, positionals } = parse(args.slice(1), {});
|
|
3383
|
+
const key = theOne(positionals, "Say which team: console team remove <key>");
|
|
3384
|
+
const session = await open(io, values);
|
|
3385
|
+
await session.client.removeTeam(key);
|
|
3386
|
+
answer(io, session, { removed: key }, () => `The team ${key} is no more.`);
|
|
3387
|
+
return EXIT.ok;
|
|
3388
|
+
}
|
|
3389
|
+
if (what === "add" || what === "drop") {
|
|
3390
|
+
const { values, positionals } = parse(args.slice(1), {});
|
|
3391
|
+
const [key, login] = theTwo(
|
|
3392
|
+
positionals,
|
|
3393
|
+
`Say which team and whom: console team ${what} <key> <login>`,
|
|
3394
|
+
);
|
|
3395
|
+
const session = await open(io, values);
|
|
3396
|
+
const person = await personOf(session, login);
|
|
3397
|
+
const changed =
|
|
3398
|
+
what === "add"
|
|
3399
|
+
? await session.client.addTeamMember(key, person.id)
|
|
3400
|
+
: await session.client.removeTeamMember(key, person.id);
|
|
3401
|
+
const everyone = await session.client.people();
|
|
3402
|
+
answer(io, session, changed, () =>
|
|
3403
|
+
formatTeamLine(changed, new Map(everyone.items.map((one) => [one.id, one.login]))),
|
|
3404
|
+
);
|
|
3405
|
+
return EXIT.ok;
|
|
3406
|
+
}
|
|
3407
|
+
throw misuse(TEAM_USAGE);
|
|
3408
|
+
};
|
|
3409
|
+
|
|
3218
3410
|
// The workspace's settings (ADR-0035): read by everyone, changed by an administrator, themselves
|
|
3219
3411
|
// on the Settings page or through their agent here (ADR-0021).
|
|
3220
3412
|
const WORKSPACE_FLAGS =
|
|
@@ -3291,7 +3483,7 @@ const workspace: Command = async (args, io) => {
|
|
|
3291
3483
|
};
|
|
3292
3484
|
|
|
3293
3485
|
const PERSON_USAGE =
|
|
3294
|
-
"Say what to do: console person role <login> <admin|member> | person manager <login> <manager login|none> | person add <login> [--host gh|google] | person remove <login> | person deactivate <login> | person reactivate <login>";
|
|
3486
|
+
"Say what to do: console person role <login> <admin|member> | person manager <login> <manager login|none> | person email <login> <address|none> | person add <login> [--host gh|google] | person remove <login> | person deactivate <login> | person reactivate <login>";
|
|
3295
3487
|
|
|
3296
3488
|
const person: Command = async (args, io) => {
|
|
3297
3489
|
const what = args[0];
|
|
@@ -3308,6 +3500,20 @@ const person: Command = async (args, io) => {
|
|
|
3308
3500
|
answer(io, session, changed, () => formatPersonLine(changed));
|
|
3309
3501
|
return EXIT.ok;
|
|
3310
3502
|
}
|
|
3503
|
+
if (what === "email") {
|
|
3504
|
+
const { values, positionals } = parse(args.slice(1), {});
|
|
3505
|
+
const [login, address] = theTwo(
|
|
3506
|
+
positionals,
|
|
3507
|
+
"Say whom and their address: console person email <login> <address|none>",
|
|
3508
|
+
);
|
|
3509
|
+
const session = await open(io, values);
|
|
3510
|
+
const found = await personOf(session, login);
|
|
3511
|
+
const changed = await session.client.updatePerson(found.id, {
|
|
3512
|
+
email: address === "none" ? null : address,
|
|
3513
|
+
});
|
|
3514
|
+
answer(io, session, changed, () => formatPersonLine(changed));
|
|
3515
|
+
return EXIT.ok;
|
|
3516
|
+
}
|
|
3311
3517
|
if (what === "manager") {
|
|
3312
3518
|
const { values, positionals } = parse(args.slice(1), {});
|
|
3313
3519
|
const [login, manager] = theTwo(
|
|
@@ -3769,6 +3975,8 @@ const COMMANDS: Readonly<Record<string, Command>> = {
|
|
|
3769
3975
|
plugin,
|
|
3770
3976
|
people,
|
|
3771
3977
|
person,
|
|
3978
|
+
teams,
|
|
3979
|
+
team,
|
|
3772
3980
|
workspace,
|
|
3773
3981
|
project,
|
|
3774
3982
|
members,
|