authoring-cli 0.1.31 → 0.1.33

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/HELP.md CHANGED
@@ -13,16 +13,18 @@ npm install -g authoring-cli
13
13
  ```bash
14
14
  authoring-cli login
15
15
  ```
16
- This opens Chrome to your organization's login page, always in one dedicated "authoring-cli" Chrome profile stored in its own directory (`~/.authoring-cli-chrome`, created automatically the first time) — entirely separate from your everyday Chrome data, not just a different profile inside it. Once you sign in, your session is captured automatically. This is the *only* profile `login` ever reads or writes cookies for — there's no flag to point it at a different (e.g. your everyday) profile instead, so there is never any ambiguity about which Chrome window/session the CLI is actually looking at.
16
+ If you already have a still-valid session stored from a previous `login` (same environment), this is instant with no browser involved at all. Otherwise it opens Chrome to your organization's login page, always in one dedicated "authoring-cli" Chrome profile stored in its own directory (`~/.authoring-cli-chrome`, created automatically the first time) — entirely separate from your everyday Chrome data, not just a different profile inside it. Once you sign in, your session is captured automatically. This is the *only* profile `login` ever reads or writes cookies for — there's no flag to point it at a different (e.g. your everyday) profile instead, so there is never any ambiguity about which Chrome window/session the CLI is actually looking at.
17
17
 
18
- **Important:** because this profile is separate, it opens its own Chrome window and (the first time) starts out *not* signed in — even if you already have a different Chrome window open and signed in. Sign in inside the window `login` just opened, not whichever Chrome window happened to be in front already; the command's own output names the profile ("Opening Chrome (profile \"authoring-cli\") ...") so you can check its avatar in Chrome's top-right corner. Signing in to the wrong window is the most common cause of `login` waiting out its full timeout and then failing with "Not signed in" on every subsequent command — if that happens, retry and make sure you type your credentials into the new window the command opens.
18
+ **Important:** because this profile is separate, it opens its own Chrome window and (the first time) starts out *not* signed in — even if you already have a different Chrome window open and signed in. Sign in inside the window `login` just opened, not whichever Chrome window happened to be in front already; the command's own output names the profile ("Opening Chrome (profile \"authoring-cli\") ..."). Signing in to the wrong window is one cause of `login` waiting out its full timeout and then failing with "Not signed in" on every subsequent command — if that happens, retry and make sure you type your credentials into the new window the command opens. If automatic capture keeps failing for another reason (e.g. Chrome's own cookie-encryption format changed in a way this tool doesn't recognize yet), `authoring-cli login --cookie <value>` bypasses browser automation entirely: copy the session cookie's raw Value from a signed-in browser's own DevTools (Application/Storage tab → Cookies) and pass it directly.
19
19
 
20
20
  ### 3. Select a Task
21
21
  ```bash
22
22
  authoring-cli tasks --mine
23
- authoring-cli select-task --project PROJ --task PROJ-123
23
+ authoring-cli select-task --context PROJ-123 --project PROJ --task PROJ-123
24
24
  ```
25
25
 
26
+ A context name (`--context`) is required so two sessions in the same folder can never move each other's task.
27
+
26
28
  ### 4. Start Authoring
27
29
  ```bash
28
30
  authoring-cli create-concept --fsn "Hepatic structure" --parent 64572001
@@ -119,14 +121,15 @@ authoring-cli validate-review-concepts
119
121
  ## Command Reference
120
122
 
121
123
  ### Authentication
122
- - `authoring-cli login [environment]` — Sign in (environment: production, uat, dev)
124
+ - `authoring-cli login [environment] [--cookie <value>]` — Sign in (environment: production, uat, dev; `--cookie` pastes a session cookie Value from DevTools to skip browser automation entirely)
123
125
  - `authoring-cli logout` — Sign out and remove stored session
124
126
 
125
127
  ### Task Management
126
128
  - `authoring-cli projects` — List available projects
127
129
  - `authoring-cli tasks [--project PROJECT] [--mine] [--status STATUS] [--summary]` — List tasks
128
- - `authoring-cli select-task --project PROJECT --task TASK` — Select a task
129
- - `authoring-cli current-task` — Show currently selected task
130
+ - `authoring-cli select-task --context NAME --project PROJECT --task TASK` — Select a task for a context
131
+ - `authoring-cli current-task` — Show this session's task (pin or context)
132
+ - `authoring-cli contexts` — List contexts and their tasks
130
133
  - `authoring-cli create-task --project PROJECT --summary "TITLE"` — Create a task
131
134
  - `authoring-cli recover-task --project PROJECT [--task TASK]` — Recover deleted tasks (there is no delete-task command — delete a task in the Authoring Workbench UI)
132
135
 
@@ -201,8 +204,9 @@ authoring-cli validate-review-concepts
201
204
  - If your session expires during use, you'll get a `401 Unauthorized` error — run `authoring-cli login` again
202
205
 
203
206
  ### Task Selection
204
- - If you don't pass `--project` and `--task` to a command, it uses your last selected task
205
- - Use `authoring-cli current-task` to see what's currently selected
207
+ - Every session must name its task: pass `--context <name>` (after `select-task --context <name> ...`), pin it with `AUTHORING_CLI_TASK=<TASK-KEY>`, or pass `--project`/`--task` on each command. There is no shared "last selected task" — it could be changed by another session in the same folder
208
+ - A pinned session refuses a different `--task` or a `select-task` on another task
209
+ - Use `authoring-cli current-task` to see what's targeted and `authoring-cli contexts` to see every context
206
210
  - Selecting a task creates its branch if it doesn't exist yet
207
211
 
208
212
  ### Validation & Classification
@@ -300,7 +304,7 @@ https://github.com/snomed/authoring-cli
300
304
  ## FAQ
301
305
 
302
306
  **Q: Can I use this on Windows or Linux?**
303
- A: The CLI runs on any Node.js 24+ environment. Automatic session capture during login works on macOS with Chrome, and on Linux with Chromium/Chrome (including a Termux:X11 proot-distro Debian on Android — `apt install chromium sqlite3`; `login` auto-starts both the Termux:X11 app and its backend so there's no manual open-once step, provided Termux has been granted Android's "Draw over other apps" permission — a one-time device setting under Settings → Apps → Termux that can't be requested from inside the proot; without it, open the Termux:X11 app by hand once instead so `login` has a display to draw its sign-in window on). `login` doesn't require any Chrome profile to already exist — it opens (and creates, if needed) a dedicated "authoring-cli" profile, so a fresh machine or CI image that has never launched Chrome before still works on the very first run. On Windows and any other unsupported platform, `login` will fail with a clear message. You can manually pass endpoints and a session cookie using flags, but that's not yet implemented.
307
+ A: The CLI runs on any Node.js 24+ environment. Automatic session capture during login works on macOS with Chrome, and on Linux with Chromium/Chrome (including a Termux:X11 proot-distro Debian on Android — `apt install chromium sqlite3`; `login` auto-starts both the Termux:X11 app and its backend so there's no manual open-once step, provided Termux has been granted Android's "Draw over other apps" permission — a one-time device setting under Settings → Apps → Termux that can't be requested from inside the proot; without it, open the Termux:X11 app by hand once instead so `login` has a display to draw its sign-in window on). `login` doesn't require any Chrome profile to already exist — it opens (and creates, if needed) a dedicated "authoring-cli" profile, so a fresh machine or CI image that has never launched Chrome before still works on the very first run. On Windows and any other unsupported platform, `login` will fail with a clear message — but you can still sign in there using `authoring-cli login --cookie <value>` with a session cookie copied from any signed-in browser's DevTools, which needs no Chrome automation at all.
304
308
 
305
309
  **Q: How do I use this with an AI agent?**
306
310
  A: Install the bundled authoring skill (`authoring-cli install-skill`), then invoke `/authoring-cli` in Claude Code or Codex. The skill teaches the agent about Snowstorm constraints and SNOMED CT modeling rules.
@@ -321,4 +325,4 @@ A: Run commands in sequence, using `--json` output to parse results. The authori
321
325
  A: Run `authoring-cli login` again to get a fresh session.
322
326
 
323
327
  **Q: Can I target multiple projects at once?**
324
- A: No, you work on one selected task at a time. Switching between tasks is instant: `select-task --project PROJ2 --task PROJ2-456`.
328
+ A: Each session works on one task, but you can have several open in the same folder: give each its own context (`select-task --context PROJ2-456 --project PROJ2 --task PROJ2-456`) and add `--context PROJ2-456` to its commands. Selections in different contexts never interfere.
package/README.md CHANGED
@@ -64,18 +64,20 @@ authoring-cli login dev
64
64
 
65
65
  Each environment supplies all three endpoints — IMS at the base host, the terminology server at `snowstorm/snomed-ct/` under it, authoring-services at `authoring-services/` — plus that environment's IMS session cookie name.
66
66
 
67
- Opens Chrome to your organization's real IMS login page (password, SSO, Google — whatever IMS itself supports). After you complete login there, the session is captured automatically by watching that Chrome profile's own cookie jar for a fresh session cookie — no copy/paste, and no dependence on IMS's `serviceReferer` redirect actually reaching back to the CLI (that redirect, when it does land, only shows a friendly "you're signed in" page — it's not required for sign-in to complete). If you're already signed in to that environment in Chrome, the existing session is reused and no browser opens at all.
67
+ If a previous `login` already stored a still-valid session for this exact environment, that's reused directly — one check against IMS, no Chrome involved at all. Otherwise it checks whether the dedicated Chrome profile already has a valid session (no browser opens either, in that case), and failing that opens Chrome to your organization's real IMS login page (password, SSO, Google — whatever IMS itself supports). After you complete login there, the session is captured automatically — primarily by reading it straight from Chrome's own DevTools Protocol (no file decryption involved, so it keeps working regardless of how Chrome encrypts cookies on disk), with a decrypt-based fallback for the rare case that isn't available. No copy/paste, and no dependence on IMS's `serviceReferer` redirect actually reaching back to the CLI (that redirect, when it does land, only shows a friendly "you're signed in" page — it's not required for sign-in to complete).
68
+
69
+ If automatic capture ever can't complete (e.g. an unsupported platform, or Chrome's own cookie storage format changes in a way this tool doesn't recognize yet), `--cookie <value>` bypasses it entirely: copy the session cookie's raw Value from a signed-in browser's own DevTools (Application/Storage tab → Cookies) and pass it directly — `authoring-cli login production --cookie <value>`.
68
70
 
69
71
  Login prints the endpoints it actually used and where each came from, so a forgotten flag silently falling back to a different environment is visible rather than invisible:
70
72
 
71
73
  ```
72
- Signed in as Jane Doe. (reused an existing Chrome session — no browser opened.)
74
+ Signed in as Jane Doe. (reused the already-stored session — no Chrome involved at all.)
73
75
  IMS: https://authoring.ihtsdotools.org/ (production)
74
76
  Terminology server: https://authoring.ihtsdotools.org/snowstorm/snomed-ct/ (production)
75
77
  Authoring services: https://authoring.ihtsdotools.org/authoring-services/ (production)
76
78
  ```
77
79
 
78
- **Current support**: automatic session capture works on **macOS with Google Chrome**, and on **Linux with Chromium/Chrome** — including a Termux:X11 proot-distro Debian on Android, where `login` auto-starts both halves of Termux:X11's GUI stack if nothing is already serving a display: its backend process (`termux-x11 :1 &`) and, best-effort, the Termux:X11 **app** itself — no manual open-once needed, *provided* Termux has been granted Android's "Draw over other apps" permission (Settings → Apps → Termux), a one-time device setting that can't itself be requested from inside the proot. Without that permission granted, the app-start step silently does nothing and the app still needs to already be open by hand, same as before. On any other OS/browser combination, `login` fails immediately with a message naming the unsupported combination, rather than hanging or failing silently.
80
+ **Current support**: automatic session capture works on **macOS with Google Chrome**, and on **Linux with Chromium/Chrome** — including a Termux:X11 proot-distro Debian on Android, where `login` auto-starts both halves of Termux:X11's GUI stack if nothing is already serving a display: its backend process (`termux-x11 :1 &`) and, best-effort, the Termux:X11 **app** itself — no manual open-once needed, *provided* Termux has been granted Android's "Draw over other apps" permission (Settings → Apps → Termux), a one-time device setting that can't itself be requested from inside the proot. Without that permission granted, the app-start step silently does nothing and the app still needs to already be open by hand, same as before. On any other OS/browser combination, automatic capture fails immediately with a message naming the unsupported combination, rather than hanging or failing silently — `login --cookie <value>` still works there, since it doesn't touch Chrome automation at all.
79
81
 
80
82
  `logout` deletes the locally stored session. It does not sign you out of IMS in Chrome, so a subsequent `login` will reuse that browser session.
81
83
 
@@ -85,7 +87,7 @@ There's deliberately no automatic fallback to `~/.authoring-cli` if the working
85
87
 
86
88
  Set `AUTHORING_CLI_HOME` to force a specific location instead — e.g. a shared session across multiple directories, or an explicit path when the working directory can't be used. It takes priority over the default, and every command reads/writes the session through the same path, so setting it once (e.g. exported alongside the agent's launch environment) covers `login`, `select-task`, and everything else with no per-command flag.
87
89
 
88
- Optional flags, for a deployment the named environments don't cover: `--ims-endpoint`, `--terminology-server-endpoint`, `--authoring-services-endpoint` (each overrides just that one value of the selected environment), `--cookie-name <name>` (override the IMS session cookie name). `login` always signs in through one dedicated "authoring-cli" Chrome profile — never your everyday browsing profile — with no flag to point it at a different one; this keeps the profile it opens, reads an existing cookie from, and polls for a fresh one always the same, so there's never a question of which Chrome window to sign in to.
90
+ Optional flags, for a deployment the named environments don't cover: `--ims-endpoint`, `--terminology-server-endpoint`, `--authoring-services-endpoint` (each overrides just that one value of the selected environment), `--cookie-name <name>` (override the IMS session cookie name). `--cookie <value>` is different — it's the manual fallback described above, not an endpoint override: pass the session cookie's raw Value and `login` skips Chrome automation entirely. `login` always signs in through one dedicated "authoring-cli" Chrome profile — never your everyday browsing profile — with no flag to point it at a different one; this keeps the profile it opens, reads an existing cookie from, and polls for a fresh one always the same, so there's never a question of which Chrome window to sign in to.
89
91
 
90
92
  ## Pick a project and task
91
93
 
@@ -96,13 +98,20 @@ authoring-cli tasks --project PROJ # everyone's ta
96
98
  authoring-cli tasks --project PROJ --mine # just yours, in PROJ
97
99
  authoring-cli tasks --project PROJ --mine --status "In Progress" # ...and only In Progress
98
100
  authoring-cli tasks --summary # counts by project/assignee/status
99
- authoring-cli select-task --project PROJ --task PROJ-123
100
- authoring-cli current-task
101
+ authoring-cli select-task --context PROJ-123 --project PROJ --task PROJ-123
102
+ authoring-cli current-task --context PROJ-123
103
+ authoring-cli contexts
101
104
  ```
102
105
 
103
106
  `--mine` resolves "yours" server-side via authoring-services' own `my-tasks` endpoint rather than by matching names locally. Without it, `--project` lists every assignee's tasks and adds an assignee column so you can tell them apart. `--status` matches case-insensitively. `--summary` prints counts instead of one line per task, so a long list doesn't have to be tallied by eye. `projects`, `tasks` and `recover-task` all take `--json` as well.
104
107
 
105
- Once a task is selected, every action command below applies to it automatically — pass `--project`/`--task` explicitly on any individual command to override just that call.
108
+ **Every session must say which task it works on** — there is no workspace-wide "current task", because a selection stored in the shared session file could be changed by any other session working in the same directory, silently redirecting edits meant for one task onto another. Instead:
109
+
110
+ - `--context <name>` (or `AUTHORING_CLI_CONTEXT=<name>`) names a selection of its own. `select-task --context 1069 ...` stores the task in that context only; later commands with `--context 1069` and no `--project`/`--task` target it. Several tasks can be open in the same folder at once, each in its own context, and `select-task` in one never touches another. `authoring-cli contexts` lists them (and flags one task held by two contexts, which would contend for the branch lock); `contexts --remove <name>` deletes a stale one.
111
+ - `AUTHORING_CLI_TASK=<TASK-KEY>` (project derived from the key, or set `AUTHORING_CLI_PROJECT`) **pins** the process to a task with no file involved. A command given a different `--task`, or `select-task` on a different task, is refused. Best for scripts and agent batches.
112
+ - `--project`/`--task` on a command targets that task for that call only.
113
+
114
+ With none of these, task-targeting commands fail and `select-task`/`create-task`/`recover-task` (unless `--no-select`) refuse, rather than guess. A selection left in `session.json` by an older version is ignored. The login cookie stays shared by all contexts, and `select-task` never rewrites it.
106
115
 
107
116
  Selecting a task also **creates its branch** if it doesn't have one yet. A task still in status `New` has no branch — that's the moment the Authoring Workbench would create it, so `select-task` does the same, and the first edit afterwards doesn't 404.
108
117
 
@@ -114,7 +123,7 @@ authoring-cli recover-task --project PROJ # list PROJ's deleted tasks
114
123
  authoring-cli recover-task --project PROJ --task PROJ-123
115
124
  ```
116
125
 
117
- `create-task` assigns the task to you and selects it (`--assignee`/`--unassigned` and `--no-select` override that).
126
+ `create-task` assigns the task to you and selects it into the active `--context` (`--assignee`/`--unassigned` override the assignee; without a context, or in a pinned session, pass `--no-select`).
118
127
 
119
128
  There is no `delete-task` command: deleting the wrong task is easy to get wrong and hard to notice at the moment it matters, so that decision is left to a human in the Authoring Workbench UI rather than something scriptable here. Deleting a task there moves it to status `Deleted` but **leaves the branch and everything authored on it alone** — which is what makes `recover-task` a real undo rather than a re-creation: it takes the task back out of `Deleted` with its content intact and selects it again, regardless of whether the deletion happened in the UI or (from before this command existed) via this CLI.
120
129
 
@@ -124,9 +133,10 @@ There is no `delete-task` command: deleting the wrong task is easy to get wrong
124
133
  |---|---|
125
134
  | `projects` | List the projects available to you |
126
135
  | `tasks` | List tasks, filtered by project/assignee/status, or summarized |
127
- | `create-task` | Create a task and select it |
128
- | `select-task` | Set the task later commands target (creating its branch if needed) |
129
- | `current-task` | Print the locally selected task |
136
+ | `create-task` | Create a task and select it into the active context |
137
+ | `select-task` | Set the task a context targets (creating its branch if needed); needs `--context` or a matching pin |
138
+ | `contexts` | List named contexts and the task each holds |
139
+ | `current-task` | Print this session's task and whether it is pinned or from a context |
130
140
  | `recover-task` | List a project's deleted tasks, or bring one back (there is no `delete-task` — use the Authoring Workbench UI) |
131
141
  | `create-concept` | Create a new concept |
132
142
  | `get-concept` | Fetch a concept by ID |