@yigemo/portal 0.2.5 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +587 -3
  2. package/dist/cli.js +1 -1
  3. package/package.json +10 -5
package/README.md CHANGED
@@ -107,18 +107,89 @@ ygmp zhixu auth status --json
107
107
  ygmp zhixu catalog --json
108
108
  ygmp zhixu organizations list --json
109
109
  ygmp zhixu organizations service ORGANIZATION_UUID --json
110
+ ygmp zhixu organizations lifecycle plan ORGANIZATION_UUID --json
111
+ ygmp zhixu organizations lifecycle notices ORGANIZATION_UUID --limit 20 --json
110
112
  ygmp zhixu organizations export ORGANIZATION_UUID --output organization.json
111
113
  ygmp zhixu orders list --organization ORGANIZATION_UUID --json
112
114
  ygmp zhixu orders list --organization ORGANIZATION_UUID --before NEXT_CURSOR --json
113
115
  ygmp zhixu orders get ORDER_UUID --json
114
116
  ```
115
117
 
118
+ The current organization owner can prepare an acknowledgement with
119
+ `ygmp zhixu operations prepare --organization ORGANIZATION_UUID --action acknowledge_data_lifecycle_notice --target NOTICE_UUID --file acknowledgement.json --idempotency-key ORIGINAL_KEY`,
120
+ where `acknowledgement.json` contains `{}`. Inspect the preview and keep the
121
+ operation reference for confirmation and recovery.
122
+
116
123
  To develop locally, use `--env local --zhixu-api-base-url http://127.0.0.1:3010`
117
124
  and the local Accounts issuer. `YGMP_ZHIXU_ACCESS_TOKEN` may supply a Zhixu
118
125
  session for that configured origin; tokens are never command-line flags.
119
126
  Exports create a private file and never overwrite an existing path. Reads
120
127
  and exports remain subject to enterprise permissions and retention.
121
128
 
129
+ ### Saved Zhixu accounts
130
+
131
+ Save separate Accounts-authorized sessions and give them local names:
132
+
133
+ ```bash
134
+ ygmp --env prod zhixu login --account personal
135
+ ygmp --env prod zhixu login --account work
136
+ ygmp --env prod zhixu auth list --json
137
+ ygmp --env prod zhixu auth use personal --json
138
+ ygmp --env prod zhixu --account work me --json
139
+ ygmp --env prod zhixu --account work banks list --personal --json
140
+ ygmp --env prod zhixu --account work auth refresh --json
141
+ ygmp --env prod zhixu --account work logout --json
142
+ ```
143
+
144
+ Successful login selects the saved account. Without a name, the first login
145
+ generates one; subsequent unnamed logins reauthorize the current default and
146
+ refuse a different browser identity. Reauthorizing the same user under a new
147
+ name reuses the existing account and reports its existing name. Names must
148
+ start with a letter or number and contain 1–64 ASCII letters, numbers, dots,
149
+ underscores or hyphens. The name never grants permissions.
150
+
151
+ `auth use` verifies the target identity online before changing the default;
152
+ valid sessions need no browser login. A failed switch preserves the previous
153
+ default. `--account` selects an account for only that command; it also works
154
+ after nested subcommands. Scripts should specify it on every step. A running
155
+ command keeps its original account even if another terminal changes the default.
156
+ The personal or organization target remains explicit and independent.
157
+
158
+ Saved sessions and defaults are isolated by application, environment, issuer,
159
+ OAuth client and API origin. `YGMP_ZHIXU_ACCESS_TOKEN` retains its existing
160
+ priority for commands without an account name. Combining it with `--account`
161
+ fails before business requests. Unset it before login, `auth use` or refresh.
162
+ `auth status` separates the saved default from the effective credential source;
163
+ environment identity is unverified until read through `me`. Lists/status show
164
+ cached metadata, not a guarantee of current server authorization. Scoped
165
+ management writes report the selected identity on stderr, keeping stdout JSON
166
+ compatible.
167
+
168
+ `logout` revokes and forgets only the selected account. Removing the default
169
+ clears the selection; it never selects a different account automatically.
170
+ An unconfirmed revocation retains the account for an explicit logout retry.
171
+ `logout --local-only` forgets local credentials without claiming server
172
+ revocation. Unnamed logout still reports `environmentTokenStillSet` when an
173
+ environment credential remains. Accounts browser sessions and other apps remain
174
+ independent; issued access tokens follow the server's existing expiry policy.
175
+
176
+ The private `~/.yigemo/portal/accounts-v3.json` file stores Zhixu sessions.
177
+ Matching legacy `tokens.json` sessions migrate after identity verification;
178
+ other application entries are preserved. End older CLI processes before the
179
+ first migration, and do not share a refresh family between old/new binaries.
180
+ After migration, the CLI never reimports a legacy entry for this app. Downgrades
181
+ may require a fresh login; do not restore an already rotated refresh token.
182
+ These are plaintext credential files protected by owner checks, private modes
183
+ and atomic writes. No password or Accounts ID token is persisted.
184
+
185
+ Cross-process locks serialize refresh, logout and file changes. An interrupted
186
+ or uncertain rotation requires login instead of retrying the old refresh token.
187
+ If a process dies with a lock, the CLI reports `AUTH_LOCK_OWNER_EXITED` and the
188
+ specific lock path. Confirm its owner has exited and no older CLI is running
189
+ before removing only that lock file, then retry. Live locks are never reclaimed
190
+ on a timer. Chapterly/admin retain their existing authentication behavior;
191
+ their multi-account commands and Travel handoff storage are outside this feature.
192
+
122
193
  Purchases and human service requests default to a dry-run. Use the current
123
194
  catalog item's SKU and its own `version`, exactly one recipient, and a stable
124
195
  idempotency key. Reuse that key when retrying the same operation.
@@ -191,6 +262,385 @@ The browser entry is `/app?view=subjective`. Personal Accounts sessions are
191
262
  required; enterprise workspaces and API/MCP credentials are not enabled for this
192
263
  workflow. These commands require a server release containing APIS-91.
193
264
 
265
+ ## Zhixu capability discovery and original operations
266
+
267
+ Canonical self reads use the same owning service as MCP and the built-in
268
+ assistant. Select the workspace context explicitly; it grants no organization
269
+ membership or business access:
270
+
271
+ ```bash
272
+ ygmp zhixu profile get --personal --json
273
+ ygmp zhixu preferences get --personal --json
274
+ ygmp zhixu connections setup --personal --json
275
+ ygmp zhixu organizations memberships --organization <organization-id> --json
276
+ ygmp zhixu organizations creation-entitlement --personal --json
277
+ ygmp zhixu subjective ai-capabilities --personal --json
278
+ ```
279
+
280
+ Membership and creation reads require explicit `organizations:read` and
281
+ `organizations:create` machine scopes. Membership results contain only minimal
282
+ own active metadata within the current credential or immutable task space;
283
+ OAuth also intersects its current organization grants. Setup returns guidance,
284
+ never a credential or a new grant. Existing `organizations list` keeps its
285
+ legacy wire fields.
286
+
287
+ The subjective AI snapshot requires explicit `subjective:read` for a machine
288
+ credential and a personal workspace. PAT issuance still requires an explicit
289
+ typed subjective bank range; this read does not grant access to answers. It
290
+ reports current rollout and the existing explain quota without issuing quota,
291
+ reserving usage or calling a model. Review writes remain separately gated.
292
+
293
+ Connection metadata reads require `connections:read` and keep the exact
294
+ selected connection separate from pagination:
295
+
296
+ ```bash
297
+ ygmp zhixu connections list --personal --json
298
+ ygmp zhixu connections get <connection-id> --personal --json
299
+ ygmp zhixu connections audit <connection-id> --personal --limit 20 --json
300
+ ```
301
+
302
+ OAuth can read only its current connection. The API and CLI verify the echoed
303
+ connection selector; the built-in executor retains it in the original step
304
+ hash and recovery input. Audit reads re-project historical rows and exclude
305
+ credentials and raw request/model bodies. These reads do not issue credentials,
306
+ change consent or grant access to the resources named in a connection.
307
+
308
+ These require the matching Agent contract API. They validate the bundled wire
309
+ contract and perform a logical read without write flags or an operation key.
310
+ The existing `me` command and login/session probes keep their legacy endpoint
311
+ so an API contract upgrade does not interfere with credential recovery.
312
+
313
+ `capabilities contract` reads the contract bundled with this CLI offline.
314
+ `capabilities summary` reads the live public feature and rollout summary without
315
+ signing in. `capabilities list/get` evaluates the current customer identity and selected
316
+ workspace through the API. A catalog entry or visible tool does not grant access.
317
+ The original-operation commands require an API version with the same contract
318
+ digest; a mismatch stops preparation and execution. They are implemented in
319
+ source and local acceptance, and are not yet available on production.
320
+
321
+ ```bash
322
+ ygmp zhixu capabilities contract --json
323
+ ygmp zhixu capabilities summary --json
324
+ ygmp zhixu capabilities list --personal --limit 20 --json
325
+ ygmp zhixu capabilities get update_bank --personal --target BANK_UUID --json
326
+ ygmp zhixu operations prepare --personal --action update_bank --target BANK_UUID --file bank-update.json --idempotency-key reviewed-update-1 --json
327
+ ygmp zhixu operations get OPERATION_UUID --personal --json
328
+ ygmp zhixu operations preview OPERATION_UUID --personal --json
329
+ ygmp zhixu operations execute OPERATION_UUID --personal --execute --confirmation-token TOKEN --json
330
+ ygmp zhixu operations wait OPERATION_UUID --personal --wait-timeout 30000 --json
331
+ ```
332
+
333
+ For example, `bank-update.json` contains `{"description":"Reviewed description"}`.
334
+ Preparation stores a reference and returns a preview without changing the bank.
335
+ Preserve `operation.operationRef.id`. Execution defaults to preview; a business
336
+ write requires `--execute` and the matching transient confirmation token. Use
337
+ `--execute --yes` only when the user has explicitly authorized that same change;
338
+ it obtains a fresh preview before execution. Production preparation and execution
339
+ also require `--allow-prod-write`.
340
+
341
+ For AI study actions, prepare `explain_attempt` against the original personal
342
+ attempt with an empty JSON object. Prepare `analyze_mistakes` against one
343
+ personal bank with `{"windowDays":7}` or `{"windowDays":30}`. Both previews
344
+ show one unit of the applicable AI allowance and the maximum provider cost.
345
+ If the provider receipt is pending, preserve the operation ID and use
346
+ `operations get` or `operations wait` to check the same operation.
347
+
348
+ ```bash
349
+ ygmp zhixu operations prepare --personal --action explain_attempt --target ATTEMPT_UUID --file empty.json --idempotency-key explanation-1 --json
350
+ ygmp zhixu operations prepare --personal --action analyze_mistakes --target BANK_UUID --file analysis-window.json --idempotency-key analysis-1 --json
351
+ ```
352
+
353
+ To request a platform AI review, use `review_subjective_with_ai` with an
354
+ empty JSON object and the exact ID of your submitted subjective answer.
355
+ The platform reads the original answer and rubric and saves one review.
356
+ If a review already exists, the preview shows zero cost and allowance.
357
+
358
+ ```bash
359
+ ygmp zhixu operations prepare --personal --action review_subjective_with_ai --target ATTEMPT_UUID --file empty.json --idempotency-key subjective-ai-review-1 --json
360
+ ```
361
+
362
+ To prepare an export, put `{"components":["banks"]}` in `export.json`. Add
363
+ `bankIds` to select specific banks, or use `--organization ORGANIZATION_UUID`
364
+ in place of `--personal`. Review the data categories and bank count before
365
+ executing with the preview's token.
366
+
367
+ ```bash
368
+ ygmp zhixu operations prepare --personal --action create_data_export --file export.json --idempotency-key export-1 --json
369
+ ygmp zhixu operations execute OPERATION_UUID --personal --execute --confirmation-token TOKEN --json
370
+ ygmp zhixu transfers exports get JOB_UUID --personal --json
371
+ ```
372
+
373
+ Use `receipt.result.id` as the job UUID. If the execute response is unavailable,
374
+ read the original operation for its job UUID. The job continues in the transfer
375
+ worker using the authorized selection from the confirmed preview.
376
+
377
+ Prepare an import with `create_data_import`. The payload accepts either a
378
+ supported manifest object or an authorized ready export's `exportJobId` and
379
+ `manifestHash`. The completed receipt contains `receipt.result.job.id`.
380
+
381
+ ```bash
382
+ ygmp zhixu transfers imports files JOB_UUID --personal --json
383
+ ygmp zhixu transfers imports upload JOB_UUID part-000001 --file part-000001.jsonl.gz --personal --execute --json
384
+ ygmp zhixu transfers imports preview JOB_UUID --personal --execute --json
385
+ ygmp zhixu transfers imports confirm JOB_UUID --personal --plan-hash REVIEWED_PLAN_HASH --idempotency-key import-confirm-1 --execute --json
386
+ ygmp zhixu transfers imports verify JOB_UUID --personal --execute --json
387
+ ```
388
+
389
+ The upload command verifies the local bytes and reads the original checkpoint
390
+ before sending a file. If the connection drops, rerun the same command on the
391
+ same job and part. Wait for `awaiting_confirmation` after preflight and use
392
+ `confirm` without `--execute` to review the selected plan. The CLI uses the
393
+ transient confirmation credential internally.
394
+
395
+ The MCP tool `upload_data_import_file` returns the original job and upload
396
+ progress. Use that job UUID with `transfers imports files` and
397
+ `transfers imports upload`. The tool does not accept file bytes or credentials.
398
+ The authenticated upload checks the manifest digest, part length and current
399
+ authorization before recording completion.
400
+
401
+ For shared preflight and verification receipts, supply an explicit stable key
402
+ to `transfers imports preview` or `transfers imports verify`. Repeat the same
403
+ job, scope, action and key to read the original receipt and current status.
404
+
405
+ ```bash
406
+ ygmp zhixu transfers imports preview JOB_UUID --personal --idempotency-key import-preflight-1 --execute --json
407
+ ygmp zhixu transfers imports verify JOB_UUID --personal --idempotency-key import-verification-1 --execute --json
408
+ ```
409
+
410
+ Run verification after the import completes. The shared preflight reports the
411
+ reviewed plan digest once available. Its receipt never includes a confirmation
412
+ credential.
413
+
414
+ For a receipt shared across Agent entries, use the original-operation adapter.
415
+ Save the reviewed digest as `{"planHash":"REVIEWED_PLAN_HASH"}` in
416
+ `import-confirm.json`, then prepare and review the exact operation:
417
+
418
+ ```bash
419
+ ygmp zhixu operations prepare --personal --action confirm_data_import --target JOB_UUID --file import-confirm.json --idempotency-key import-confirm-1 --json
420
+ ygmp zhixu operations execute OPERATION_UUID --personal --execute --yes --json
421
+ ygmp zhixu operations get OPERATION_UUID --personal --json
422
+ ```
423
+
424
+ Use `--execute --yes` only after explicit approval of the preview. After an
425
+ unknown response, read the original operation before taking further action.
426
+ Its receipt points to the same import job. Organization operations use
427
+ `--organization ORGANIZATION_UUID`.
428
+
429
+ To retry a failed transfer, use its job UUID as the target. Save `{}` in
430
+ `transfer-retry.json`. The server reads the transfer type and saved progress
431
+ from the original job.
432
+
433
+ ```bash
434
+ ygmp zhixu operations prepare --personal --action retry_data_transfer --target JOB_UUID --file transfer-retry.json --idempotency-key transfer-retry-1 --json
435
+ ygmp zhixu operations execute OPERATION_UUID --personal --execute --yes --json
436
+ ```
437
+
438
+ Review the failure and saved progress before approving. An expired execution
439
+ window or revoked required authorization prevents the transfer from resuming.
440
+
441
+ Organization creation uses your existing allowance. Prepare it in personal
442
+ space with a JSON payload such as `{"name":"Training team"}`. An owner can
443
+ rename an existing organization by supplying its UUID as both workspace and
444
+ target. Review each preview before executing.
445
+
446
+ ```bash
447
+ ygmp zhixu operations prepare --personal --action create_organization --file organization.json --idempotency-key organization-create-1 --json
448
+ ygmp zhixu operations prepare --organization ORG_UUID --action update_organization --target ORG_UUID --file organization.json --idempotency-key organization-rename-1 --json
449
+ ```
450
+
451
+ `export_exam_entry` uses the same original-operation flow. Prepare it in the exam's organization with `--target EXAM_UUID` and a payload such as `{"format":"png"}`. After reviewing and confirming the preview, claim the file from the same Accounts user session.
452
+
453
+ ```bash
454
+ ygmp zhixu exams entry download OPERATION_UUID --organization ORG_UUID --output private-entry.png
455
+ ```
456
+
457
+ The command writes a new private file and prints only its receipt metadata. File delivery expires within ten minutes and requires the entry revision and issuing access to remain valid. The existing `exams entry export` command still provides explicit private export for direct Accounts use.
458
+
459
+ Personal subjective content uses the same original-operation flow:
460
+
461
+ ```bash
462
+ ygmp zhixu operations prepare --personal --action create_subjective_bank --file subjective-create.json --idempotency-key subjective-content-1 --json
463
+ ygmp zhixu operations prepare --personal --action import_subjective_archive --file subjective-archive.json --idempotency-key subjective-content-2 --json
464
+ ```
465
+
466
+ Both files contain `{"input":...,"rightsConfirmed":true}` using the existing
467
+ subjective v1 content or v2 complete archive schema. Machine credentials need
468
+ both `banks:write` and `subjective:write`, with an explicit subjective
469
+ `all_banks` range. Built-in grants require their independent subjective creation
470
+ permission. No objective bank range grants subjective creation. The shared JSON
471
+ adapter accepts up to 256 KiB of incoming payload; large file adapters remain
472
+ pending. Imported submissions stay archived history and do not create live
473
+ attempts, self reviews or platform AI reviews. Preserve the returned operation
474
+ reference for execution, task reads and recovery across authorized credentials.
475
+
476
+ Prepare an assistant review of an already submitted personal attempt with:
477
+
478
+ ```bash
479
+ ygmp zhixu operations prepare --personal --action add_subjective_review --target ATTEMPT_UUID --file subjective-review.json --idempotency-key subjective-review-1 --json
480
+ ```
481
+
482
+ The payload contains `reviewerKind: "assistant"`, `expectedRevision`, `summary`
483
+ and one `criteria` entry per rubric item. A positive score requires a quote from
484
+ the submitted answer. Current credentials need `banks:read`, `banks:write`,
485
+ `subjective:read` and `subjective:write` on the owning subjective bank. The
486
+ preview shows the score and attempt revision. Execute the same reference after
487
+ confirmation. The submitted answer and submission time remain intact when the
488
+ review increments the attempt revision.
489
+
490
+ Read the typed receipt for a completed subjective creation, archive import, or
491
+ assistant review with:
492
+
493
+ ```bash
494
+ ygmp zhixu subjective operation-receipt opref_OPERATION_UUID --personal --json
495
+ ```
496
+
497
+ Replace `OPERATION_UUID` with `operation.operationRef.id`. The `opref_` form
498
+ supports credential handoff. An unprefixed key resolves only within the current
499
+ credential's original operation namespace. A receipt needs current access to
500
+ the actual subjective bank and the original action's scopes. An unresolved
501
+ receipt preserves the original reference for later lookup. The existing
502
+ `subjective receipt` command serves legacy user learning commands.
503
+
504
+ After a lost response, read or wait on the same reference. These reads never
505
+ retry the write. HTTP 403, missing receipts, invalid responses and timeouts do
506
+ not establish that execution did not happen. Keep the original reference, key
507
+ and input; do not switch credentials to prepare a replacement. Another currently
508
+ authorized credential can read the reference and obtain a fresh preview for the
509
+ same stored operation. Revoked credentials cannot continue. Resume accepts no
510
+ new payload, identity or key. Other domains still use their existing task flows.
511
+
512
+ The build checks exact API-exported contract bytes and the manifest digest.
513
+ Maintainers explicitly sync from a clean committed API checkout with
514
+ `node scripts/zhixu-contract.mjs --sync --api-root /absolute/path/to/api`.
515
+ When unrelated work is in progress in that checkout, add
516
+ `--source-commit <exact-full-commit-id>` to read only immutable, regular Git
517
+ blobs from that commit. This mode never captures worktree changes. Both modes
518
+ verify every selected artifact against the committed manifest.
519
+ Normal builds and installed CLI commands do not read a sibling API repository.
520
+
521
+ ## Zhixu existing tasks
522
+
523
+ `tasks get/wait/watch` reads one original typed task under current authorization.
524
+ It never cancels, retries a write or creates a replacement. These adapters are
525
+ implemented locally and require the new API; they are not deployed or published.
526
+
527
+ ```bash
528
+ ygmp zhixu tasks get import IMPORT_UUID --personal --json
529
+ ygmp zhixu tasks wait management_request REQUEST_UUID --organization ORGANIZATION_UUID --wait-timeout 30000 --json
530
+ ygmp zhixu tasks watch data_export EXPORT_UUID --personal --wait-timeout 30000
531
+ ```
532
+
533
+ Kinds are `import`, `data_export`, `data_import`, `management_request`,
534
+ `maintenance_operation`, `exam_save_operation`, and `agent_run`. Use only IDs
535
+ returned by the owning domain. Exam save uses the persistent original operation
536
+ ID for `create_exam/edit_exam`, not an exam or request ID. `agent_run` is reserved
537
+ and currently returns unavailable. Transfers and unlinked legacy receipts retain
538
+ their original credential namespace; a different credential is not sufficient
539
+ merely because it belongs to the same user.
540
+
541
+ Wait and watch have a 100–60000ms polling budget after authentication and a
542
+ 100–10000ms interval. Each GET is bounded by the remaining budget. They stop on
543
+ terminal states or `awaiting_user/reconciling`; a successful read does not mean
544
+ the business task succeeded. Missing progress remains null. Keep the same
545
+ reference after timeout, revocation, invalid output or an unknown result.
546
+
547
+ Watch always writes JSONL, including with `--json`. Frames use
548
+ `zhixu.task-watch/v1`, increasing `sequence`, the same `taskRef` and workspace,
549
+ and types `snapshot`, `terminal`, `attention`, `timeout`, or `error`. Timeout and
550
+ error exit 1; terminal and attention exit 0 as completed observations. Validation
551
+ errors before the stream starts use ordinary CLI errors. File references require
552
+ the owning download API to authorize delivery; they contain no signed URLs.
553
+
554
+ ## Zhixu exam and organization reports
555
+
556
+ `exams list`, `exams get` and `exams results` require an explicit organization.
557
+ They check anonymous API contract metadata, then use the authenticated common
558
+ management dispatcher, including when signed in with a product JWT. These reads
559
+ do not enroll members or settle overdue attempts. Persisted pending scores stay
560
+ null; candidate interaction and the existing scheduled job own settlement.
561
+ An older contract stops the CLI before its business read. Public metadata does
562
+ not grant access; the dispatcher checks current authorization on every request.
563
+ List/detail require `exams:read`; results require `results:read`, with the current
564
+ owner/admin role and authorized source banks. A `canManage` field describes the
565
+ domain role and does not grant write scopes.
566
+
567
+ These read commands use the shared API report contracts and require the new API
568
+ implementation. They are locally verified source changes, not a production or
569
+ npm release. Existing `results:read` or `organizations:read` alone does not grant
570
+ the new report capabilities.
571
+
572
+ ```bash
573
+ ygmp zhixu exams analysis EXAM_UUID --organization ORGANIZATION_UUID --json
574
+ ygmp zhixu exams review EXAM_UUID --organization ORGANIZATION_UUID --member MEMBER_UUID --attempt-number 1 --json
575
+ ygmp zhixu organizations reports ORGANIZATION_UUID --json
576
+ ```
577
+
578
+ Analysis requires `results:read` and `exams:analysis:read`; completed-paper review
579
+ requires `results:read` and `exams:review:read`. Organization reports require
580
+ `organizations:read` and `organizations:reports:read`. The server rechecks the
581
+ current owner/admin membership, organization grant, exam bank range and retained
582
+ data access. A selected-bank organization report counts only authorized original
583
+ banks, not the entire enterprise.
584
+
585
+ Report reads do not start, save, submit, settle or archive attempts. Review reads
586
+ only submitted rounds and preserves the frozen question/option order. Analysis
587
+ uses the domain's existing effective-score policy; pending settlement is not a
588
+ new score. The CLI validates the pinned input/output and rejects a response for
589
+ a different organization, exam, member or requested round. Revocation and scope
590
+ loss remain failures; reads are not retried as writes or replacement tasks.
591
+
592
+ ## Zhixu exam editor handoff
593
+
594
+ Editor drafts belong to the current customer, one explicit organization and
595
+ `new` or an existing exam UUID. The CLI uses the same revisioned cloud draft as
596
+ the web editor. These commands are implemented in source and local acceptance;
597
+ they are not yet published to npm or deployed to production.
598
+
599
+ ```bash
600
+ ygmp zhixu capabilities get save_exam_editor_draft --organization ORGANIZATION_UUID --target-key new --json
601
+ ygmp zhixu exams editor-drafts get new --organization ORGANIZATION_UUID --json
602
+ ygmp zhixu exams editor-drafts save new --organization ORGANIZATION_UUID --file editor-proposal.json --json
603
+ ygmp zhixu exams editor-drafts save new --organization ORGANIZATION_UUID --file editor-proposal.json --execute --yes --json
604
+ ygmp zhixu exams editor-drafts discard new --organization ORGANIZATION_UUID --expected-revision 4 --execute --yes --json
605
+ ```
606
+
607
+ The proposal file contains `expectedRevision`, `baseExamRevision` and the full
608
+ unfinished `state` from the shared schema. For an existing exam, preserve its
609
+ known base revision. The organization and target come from command arguments;
610
+ the file cannot override them or the current identity. Blank fields are valid
611
+ unfinished state, and saving does not create or publish a formal exam.
612
+
613
+ Save and discard default to a checked proposal without dispatching a write.
614
+ Actual writes require an explicitly authorized `--execute --yes`; production
615
+ also requires `--allow-prod-write`. Checks before dispatch verify the pinned
616
+ contract and current capability. The service checks the exact revision, formal
617
+ base and selected references again when saving. Read requires `exams:read` plus
618
+ `exams:drafts:read`; save/discard require `exams:manage` plus `exams:drafts:write`.
619
+ Old grants do not receive the new groups automatically.
620
+
621
+ To retain an operation that the built-in assistant, CLI, or MCP can read back,
622
+ use the shared original-operation commands. Omit `--target` for the `new`
623
+ editor copy and pass the exam UUID for an existing exam. Use the same
624
+ `editor-proposal.json` as above. For discard, the file contains only
625
+ `expectedRevision`. Prepare returns a preview. Execution requires confirmation
626
+ of that preview and the original operation ID. The durable receipt reports
627
+ the target and revision. Read the editor copy separately for its contents.
628
+
629
+ ```bash
630
+ ygmp zhixu operations prepare --organization ORGANIZATION_UUID --action save_exam_editor_draft --file editor-proposal.json --idempotency-key original-editor-save --json
631
+ ygmp zhixu operations get OPERATION_UUID --organization ORGANIZATION_UUID --json
632
+ ```
633
+
634
+ Keep the original local proposal after any uncertain write response. Read the
635
+ same draft to reconcile it; do not substitute the latest revision into stale
636
+ content. Identical content can be replayed with its original expected revision
637
+ without another write. Different stale content conflicts. Discard only the
638
+ revision the user confirmed; tombstones retain their increasing revision.
639
+
640
+ The capability catalog lists all 139 target actions. An unavailable entry with
641
+ `CAPABILITY_EVALUATOR_PENDING` declares a remaining adapter gap; catalog presence
642
+ does not authorize execution. The CLI bundles 51 exact API contract files.
643
+
194
644
  ## Zhixu bank append, recycle and merge
195
645
 
196
646
  One bank can contain questions from multiple materials. Objective imports keep
@@ -208,14 +658,18 @@ ygmp zhixu banks restore BANK_UUID --personal --lifecycle-revision 1 --idempoten
208
658
  ygmp zhixu banks merge --personal --into TARGET_UUID --from SOURCE_A_UUID --from SOURCE_B_UUID --file merge-revisions.json --idempotency-key merge-banks-1 --json
209
659
  ygmp zhixu banks merged --personal --json
210
660
  ygmp zhixu banks history SOURCE_A_UUID --personal --json
661
+ ygmp zhixu banks maintenance-sources BANK_UUID --personal --json
211
662
  ygmp zhixu banks operation --personal --idempotency-key merge-banks-1 --json
212
663
  ygmp zhixu banks operation OPERATION_UUID --personal --json
213
664
  ```
214
665
 
215
666
  For subjective banks, use the same commands under `subjective banks`, including
216
- `delete`, `restore`, `recycle`, `merge`, `merged`, `history` and `operation`.
217
- This first release supports personal workspaces. New maintenance operations
218
- require their server-side authorization; they never use an administrator path.
667
+ `delete`, `restore`, `recycle`, `merge`, `merged`, `history`, `maintenance-sources` and `operation`.
668
+ For enterprise objective banks, use `--organization ORGANIZATION_UUID` with
669
+ `delete`, `restore`, `recycle` or `operation`. The organization role and bank
670
+ grant are checked on the server. Add `organizations:banks:recycle` alongside
671
+ `banks:delete` for writes or `banks:read` to list the recycle bin. The other
672
+ maintenance commands in this section use personal workspaces.
219
673
 
220
674
  `delete` means moving the bank to its **30-day recycle bin**. It is not permanent
221
675
  deletion. Recovery preserves IDs and learning records, while closed public shares
@@ -412,3 +866,133 @@ The npm package contains a bundled executable, this README, the security
412
866
  policy, and the proprietary license. It intentionally excludes source maps,
413
867
  type declarations, repository design documents, tests, and internal operator
414
868
  documentation.
869
+
870
+
871
+ ### Shared commerce and MCP metadata reads
872
+
873
+ `catalog`, `orders list` and `orders get` now use the same canonical read adapter
874
+ as MCP and the built-in assistant. Catalog output keeps its existing `skus` key.
875
+ These order snapshots do not generate payment links, reconcile with a provider,
876
+ reserve a purchase, create a service request, or alter financial facts.
877
+
878
+ ```sh
879
+ ygmp zhixu catalog --personal --json
880
+ ygmp zhixu purchase eligibility --personal --json
881
+ ygmp zhixu connections metadata --personal --json
882
+ ygmp zhixu orders list --personal --json
883
+ ygmp zhixu orders get ORDER_UUID --personal --json
884
+ ygmp zhixu orders requests ORDER_UUID --personal --json
885
+ ```
886
+
887
+ Order and service-request reads require an explicitly granted
888
+ `organizations:service:read` machine scope. New personal credentials may request
889
+ this fine-grained scope for their actual payer's records; existing organization
890
+ credentials remain fixed to their original organization. The scope alone does
891
+ not grant bank or organization business access. An explicit `orders list
892
+ --organization ORG_UUID` filter also requires `organizations:read`, current owner
893
+ or admin membership, and readable retention state. Use `--organization` for an
894
+ organization-scoped credential. Existing `catalog`, `orders list` and `orders
895
+ get` invocations without a scope default to personal payer metadata; the new
896
+ `purchase eligibility`, `connections metadata` and `orders requests` commands
897
+ require an explicit workspace. Conflicting scope flags are rejected.
898
+
899
+ All reads check the pinned public contract before calling the authenticated
900
+ common endpoint. The named `orderId` remains outside the payload, is echoed in
901
+ the response, and is verified against the original selection. Unknown or signed
902
+ payment results fail closed. The contract synchronizer takes the complete shared
903
+ read list from the fixed API policy rather than maintaining another action list.
904
+
905
+ `ygmp zhixu changes get CHANGE_SET_UUID --personal --json` reads a controlled
906
+ change proposal through the same shared snapshot. Machine credentials need both
907
+ `banks:read` and `changes:propose`, current access to the actual owning bank, and
908
+ the existing feature availability. An expired proposal is displayed as expired
909
+ without saving status, clearing a nonce, issuing confirmation, applying changes,
910
+ or publishing the bank. The command verifies the original `changeSetId` in both
911
+ the response envelope and proposal. It requires an explicit personal workspace.
912
+
913
+ `ygmp zhixu changes preview-application CHANGE_SET_UUID --personal --json`
914
+ prints a local request preview without contacting the server. Add `--execute`
915
+ to check the current frozen proposal and rotate its temporary one-time nonce;
916
+ production also requires `--allow-prod-write`. This credential preflight requires
917
+ all of `banks:write`, `changes:propose`, and `changes:apply`, plus current access to
918
+ the actual personal owning bank. Its nonce is returned only as the transient
919
+ protocol response. No change is applied and no user approval or durable business
920
+ operation is created. Application continues through a separately reviewed
921
+ `operations prepare --action apply_change_set` intent containing `diffHash`,
922
+ followed by explicit confirmation of that original operation.
923
+
924
+ The `shares` commands cover six read views:
925
+
926
+ ```bash
927
+ ygmp zhixu shares public SHARE_CODE --json
928
+ ygmp zhixu shares questions SHARE_CODE MEMBER_UUID --json
929
+ ygmp zhixu shares list --personal --json
930
+ ygmp zhixu shares preview --banks BANK_UUID --personal --json
931
+ ygmp zhixu shares sessions --personal --json
932
+ ygmp zhixu shares mistakes SHARE_CODE MEMBER_UUID --personal --limit 30 --json
933
+ ```
934
+
935
+ Public lookup uses the exact case-sensitive code and reads the current published
936
+ version without sending a saved account credential. List and preview require
937
+ current authorization for every source bank. Sessions and mistakes are bound to
938
+ the current learner. Closed shares can remain visible in session history, while
939
+ current content and mistakes require an active share.
940
+
941
+ To create a share, put `title` and the exact `bankIds` array in the payload.
942
+ The current personal credential needs `banks:read`, `shares:manage` and
943
+ access to every published source. The preview identifies whether the operation
944
+ will create a public link or reuse an existing share for that group.
945
+
946
+ ```bash
947
+ ygmp zhixu operations prepare --action create_share \
948
+ --file share.json --idempotency-key ORIGINAL_KEY --personal --json
949
+ ```
950
+
951
+ To rename, close or reopen an owned share, pass the exact share UUID and the
952
+ current `expectedRevision` in the update payload. Include `title` and/or
953
+ `status` (`active` or `closed`). The current credential needs `shares:manage`
954
+ and access to every source bank.
955
+
956
+ ```bash
957
+ ygmp zhixu operations prepare --action update_share --target SHARE_UUID \
958
+ --file update.json --idempotency-key ORIGINAL_KEY --personal --json
959
+ ygmp zhixu operations preview OPERATION_UUID --personal --json
960
+ ```
961
+
962
+ Review the returned change before explicitly authorizing execution of that
963
+ operation. Use `operations get` with the same UUID to recover its receipt.
964
+
965
+ To copy published members of a share, use the exact case-sensitive
966
+ `shareCode`, `memberKeys`, and the member-to-version `expectedContentTokens`
967
+ object from the public share read. Prepare the original operation with a
968
+ personal credential that has `shares:acquire`, `banks:write`, and permission
969
+ to create objective banks.
970
+
971
+ ```bash
972
+ ygmp zhixu operations prepare --action acquire_shared_banks \
973
+ --file copy.json --idempotency-key ORIGINAL_KEY --personal --json
974
+ ```
975
+
976
+ To prepare an unanswered practice queue, pass `shareCode`, `memberKey`,
977
+ `contentToken` and optional practice settings with `practice:write`.
978
+ Use `shares receipt` to recover a create, acquire or practice receipt with
979
+ current authorization. An empty result only means the receipt was not observed.
980
+
981
+ ```bash
982
+ ygmp zhixu operations prepare --action create_share_practice_session \
983
+ --file practice.json --idempotency-key ORIGINAL_KEY --personal --json
984
+ ygmp zhixu shares receipt practice opref_OPERATION_UUID --personal --json
985
+ ```
986
+
987
+ For personal practice, prepare a new unanswered queue with
988
+ `create_practice_session`, the bank UUID, and a payload such as `{"count":20}`.
989
+ Use `end_practice_session` to abandon an active session, or
990
+ `resume_practice_session` to resume a session still frozen after its bank was
991
+ restored. Both use the session UUID and its current `sessionRevision`. Review
992
+ the preview and use the original operation UUID for execution and recovery.
993
+
994
+ ```bash
995
+ ygmp zhixu operations prepare --action create_practice_session --target BANK_UUID \
996
+ --file practice.json --idempotency-key ORIGINAL_KEY --personal --json
997
+ ygmp zhixu operations get OPERATION_UUID --personal --json
998
+ ```