@aliyunrds/ctxdb 1.0.8-beta.4 → 1.0.9-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ Unified access layer for RDS ContextDatabase. One `ctxdb` CLI (memory + KB ops),
11
11
  | **claude** | ✅ UserPromptSubmit + Stop + SessionStart | `~/.claude/skills/ctxdb/` | hooks-driven (auto capture/recall) |
12
12
  | **opencode** | Plugin shim (`~/.config/opencode/plugins/ctxdb.ts`) | `~/.config/opencode/skills/` | in-process plugin (auto capture/recall + KB catalog injection) |
13
13
  | **hermes** | ✅ `pre_llm_call` + `post_llm_call` | `~/.hermes/skills/` | shell hooks (auto capture/recall + first-turn warmup) |
14
- | **workbuddy** | ✅ UserPromptSubmit + Stop + SessionStart | `~/.workbuddy-ai/skills/ctxdb/` | hooks-driven (auto capture/recall); Claude-Code-isomorphic (exec form) |
14
+ | **workbuddy** | ✅ UserPromptSubmit + Stop + SessionStart | `~/.workbuddy/skills/` and `~/.workbuddy-ai/skills/` (existing homes) | CodeBuddy command hooks (complete shell command, no separate `args`) |
15
15
 
16
16
  Config and logs live under `~/.ctxdb/`. `~/.ctxdb/ctxdb.json` is one file, but runtime config is isolated per agent under `agents.qoder`, `agents.qoderwork`, `agents.qwenwork`, `agents.codex`, `agents.claude`, `agents.opencode`, `agents.hermes`, and `agents.workbuddy`. (Pre-2026-05-23 installs used `~/.ctxdb.json` at the home root; running `ctxdb setup --agent <name>` migrates the file into the selected agent section.)
17
17
 
@@ -20,34 +20,96 @@ Config and logs live under `~/.ctxdb/`. `~/.ctxdb/ctxdb.json` is one file, but r
20
20
  ### Public Device Flow login (requires the enabled Core/API phase 2 service)
21
21
 
22
22
  ```sh
23
- ctxdb login --agent qoder --server https://<core-host> --no-browser
24
- # Complete the displayed user code through the console/independent POP test client.
25
- ctxdb auth status --agent qoder --json
26
- ctxdb setup --agent qoder
27
- ctxdb logout --agent qoder --json
23
+ ctxdb login --agent codex
24
+ # Authorize in the console; this command also installs hooks/skills and validates the connection.
25
+ # To share one login across several Agents instead:
26
+ ctxdb login --base-url https://<core-host> --no-browser
27
+ # Complete the displayed user code through the console/independent POP client.
28
+ ctxdb setup --agent codex
29
+ ctxdb setup --agent opencode
30
+ ctxdb auth status --all --json
31
+ # Explicitly choose another identity for one Agent:
32
+ ctxdb login --agent codex --base-url https://<core-host>
33
+ ctxdb setup --agent codex --login default
34
+ ctxdb auth unbind --agent codex
35
+ ctxdb logout --login default --yes --json
28
36
  ```
29
37
 
30
- Public login uses Core Device Flow only; it never calls POP, starts a localhost callback,
31
- or uses the internal login server. `--device-code` explicitly selects the same default flow.
32
- Device Flow always uses `default`, following the current Member permissions and resource ACLs.
33
- `login` does not accept `--scope`; creation and approval do not send a scope selector.
34
- Login does not install hooks/skills. Run setup separately for each selected Agent.
35
-
36
- Each profile contains only an `oauth_credential_ref`; AT/RT live in owner-only files under
37
- `~/.ctxdb/oauth-credentials/`. `CTXDB_CONFIG_PATH` can select an isolated configuration file;
38
- the OAuth directory is its sibling. CLI, Hooks and OpenCode share a cross-process, single-flight
39
- refresh implementation. A lost refresh response or crashed refresh requires a new login, not
40
- a retry of the old RT. Managed failure/logout never falls back to an API key or another profile.
41
- Re-login replaces only the selected profile; logout reports remote-revoke failure separately.
42
- AT/RT must not be copied into Agent/Skill configuration or handed to a sandbox.
43
-
38
+ Public login uses Core Device Flow; `--device-code` selects the same default flow.
39
+ The scope is always `default`, following current Member permissions and resource ACLs;
40
+ `--scope` is not accepted. Login for a non-default Agent also runs setup, using the endpoint
41
+ selected by that login. Default login and `--login` reauthorization only manage authentication.
42
+ If setup fails, login exits nonzero with `authenticated: true` and setup diagnostics; the saved
43
+ session remains available for `ctxdb setup --agent <name>` to retry. Hermes approval requirements
44
+ remain explicit, and successful setup includes the usual host restart/trust reminders.
45
+ Ordinary setup preserves
46
+ existing authentication and binds the default login only for an Agent without an authentication
47
+ choice. Without `--base-url`, setup resets the selected credential's DATA endpoint to
48
+ `https://api.cn-hangzhou.agentcontext.aliyuncs.com`, including existing keys and logins.
49
+ All Agents sharing that login use its updated endpoint. `setup --all` applies the same policy to detected Agents.
50
+ An explicit invalid `--base-url` (including a missing or empty value) fails before configuration
51
+ changes and suggests the current production URL; it never acts like an omitted option.
52
+
53
+ New credentials share `credentials.json` version 2. Every record has exactly
54
+ `kind`, `payload`, and `metadata`; kinds are `api-key` and `oauth-session`.
55
+ `payload` contains only the API Key or AT/RT. Service addresses, identity, scope,
56
+ expiry and lifecycle fields live in `metadata` and remain validated atomically
57
+ with the credential. Uncertain refreshes retain metadata with an empty payload; retired logins are deleted.
58
+ Agent API keys use `credential_ref`, and shared sessions use
59
+ `access_credential -> logins.<ID>.credential_ref`. New login IDs use the creating Agent
60
+ and eight random hexadecimal characters (for example, `default-e0c3f323` or `codex-a71e900a`).
61
+ Sharing and reauthorizing the same login keep its ID. Ownership, state and revision live in
62
+ metadata. Referenced credentials also own their service address: Agent sections no longer
63
+ write `base_url`. Leftover config addresses cannot redirect a referenced credential; explicit
64
+ address overrides must match its metadata. Legacy config keys and environment credentials
65
+ keep their existing address selection. No new secrets are written to `ctxdb.json` and no OAuth directory is created.
66
+ Released internal v1 credentials and legacy config API keys remain readable without
67
+ migration on ordinary reads. Unreleased OAuth-directory test sessions require login again.
68
+ See [unified credential storage and compatibility](../../docs/unified-credentials.md).
69
+
70
+ CLI, hooks and OpenCode use shared authentication resolution and one cross-process refresh lock.
71
+ Unbind only removes a local binding. `logout --agent` detaches that Agent, retaining the
72
+ session while another Agent uses it; the last logout deletes its login and credential records
73
+ and revokes the remote session. `logout --login` explicitly logs out all sharing Agents. Reauthorizing
74
+ default or `login --login <ID>` updates all Agents still sharing that login. Independent
75
+ `login --agent <name>` creates a new record and retires the previous session if it has no users.
76
+ Successful login and logout also collect historical unreferenced login records.
77
+ Logout performs this collection even when the selected Agent has no current login; unconfirmed
78
+ remote cleanup returns a failure status while active shared sessions and API keys are preserved.
79
+ Changes affecting other Agents list them and require confirmation (`--yes` for non-interactive execution).
80
+ Failed/ambiguous refresh, damaged references, origin mismatch and revoked sessions never fall back
81
+ to an older key or another login. Runtime environment credentials keep their original priority
82
+ and are not persisted; explicit auth switches reject masking environment overrides before writing.
83
+
84
+ Upgrade the CLI and the actual hooks/plugin artifacts together before enabling sharing.
85
+ New CLI reading old v2 configuration is supported; old CLI reading shared-login configuration is not.
86
+ See [共享登录、完整命令与兼容契约](../../docs/cli-shared-login.md) for migration and concurrency details.
87
+
88
+ The production Core origin `https://api.cn-hangzhou.agentcontext.aliyuncs.com` defaults to the console page
89
+ `https://rdsnext.console.aliyun.com/contextDbCliAuthorization/cn-hangzhou`. CLI appends the current
90
+ `user_code`; the console route uses the fixed `cn-hangzhou` region.
91
+ Ordinary DATA requests and artifact-only `upgrade` keep the configured origin, without endpoint fallback.
92
+ `setup` and every `login`, including reauthorization, use the default production origin unless
93
+ `--base-url` is supplied. Relogin no longer inherits the previous session's origin.
94
+ Explicitly selecting the legacy Core origin `https://context-database.aliyuncs.com` keeps the same console mapping.
95
+ Use `--base-url` to select the Core service and `--login-url` to supply the HTTPS console page
96
+ for this invocation. The latter does not change the service origin or persist a console mapping.
97
+ The legacy `--server` alias for `--base-url` remains accepted; do not pass both.
44
98
  The optional sibling `device-environments.json` (`version: 1`, `environments: [{core_url,
45
- authorization_url}]`) maps a Core origin to a deployment-approved HTTPS console page.
46
- CLI appends only `user_code` to that locally configured URL. There is no server discovery or
47
- invented default console page. Without a mapping, the code can be used with the independent POP
48
- test client. This phase never opens a browser automatically; `--no-browser` is supported.
49
-
50
- POSIX uses private files/directories; Windows validates an owner-only ACL using local PowerShell.
99
+ authorization_url}]`) overrides the console page for an exactly matching Core origin.
100
+ The page must use HTTPS without credentials, query parameters or a fragment. Unmatched entries
101
+ retain the production default. Preproduction and custom Core origins have no built-in console
102
+ mapping: tests pass `--base-url` and `--login-url` explicitly, or use the code with the independent POP test client.
103
+ Console page priority is `--login-url`, then the local mapping, then the production default.
104
+ URLs never come from server discovery. When a console URL is available, login opens the default
105
+ browser and keeps polling. It always prints the URL and code; if opening fails, use that URL
106
+ manually. Pass `--no-browser` to print the link without opening a browser.
107
+
108
+ Credential storage trusts the user's local environment and relies on OS access control.
109
+ New POSIX directories/files request modes `0700`/`0600`; Windows uses normal inherited permissions.
110
+ Reads and writes do not reject an accessible file based on its owner, mode bits or ACL, and do not
111
+ invoke PowerShell to inspect or change permissions. File type/symlink checks, JSON validation,
112
+ atomic replacement and concurrency locks still apply.
51
113
  Native Windows acceptance remains separate from the macOS local test record.
52
114
 
53
115
  ### Internal browser-login distribution
@@ -59,7 +121,7 @@ and `ctxdb auth status`. The default login uses a browser loopback callback;
59
121
  provider-neutral protocol and use PKCE. The selected Workspace is represented
60
122
  by the returned API key, so the CLI does not persist a separate Workspace id.
61
123
 
62
- Internal login stores its single active connection in owner-only
124
+ Internal login stores its single active connection in
63
125
  `~/.ctxdb/credentials.json`. It then runs the normal Agent setup lifecycle
64
126
  without writing an `api_key` field into the Agent or default profile; an
65
127
  existing field in either updated profile is removed. At runtime this managed
@@ -78,7 +140,7 @@ environment-variable or file-existence check. The `public` manifest disables
78
140
  internal-protocol flags `interactiveLogin` and `managedCredentials`, and enables `deviceFlow`;
79
141
  the `internal` manifest enables the former two and disables `deviceFlow`. The CLI hooks and the separately bundled OpenCode plugin receive the
80
142
  same manifest, so installing a public build on a machine that happens to have
81
- `~/.ctxdb/credentials.json` does not make that build consume the file.
143
+ `~/.ctxdb/credentials.json` does not make the public build consume the internal active record.
82
144
 
83
145
  Internal users install the package from Ali NPM. The internal version is
84
146
  managed independently in `internal-release.json`; it does not inherit the
@@ -199,7 +261,7 @@ ctxdb setup --agent hermes --api-key ctxdb-...
199
261
  # Detect and configure every supported Agent already used on this host.
200
262
  ctxdb setup --all --api-key ctxdb-...
201
263
 
202
- # --base-url defaults to https://context-database.aliyuncs.com (public prod).
264
+ # --base-url defaults to https://api.cn-hangzhou.agentcontext.aliyuncs.com (public prod).
203
265
  # Pass --base-url <host> only if you target a different deployment
204
266
  # (e.g., a pre / staging host, or a self-hosted instance).
205
267
  # --user-id defaults to "default". Pass --user-id <bucket> only if you
@@ -245,7 +307,7 @@ ctxdb setup --agent codex --api-key 'ctxdb-new-...'
245
307
  ctxdb status --agent codex --json
246
308
  ```
247
309
 
248
- Setup first checks that the target agent home exists (`~/.qoder`, `~/.qoderwork`, `~/.qwenwork`, `~/.codex`, `~/.claude`, or `~/.workbuddy-ai`; the declared CN variant home also satisfies this check). Setup writes hooks and skills only into homes that already exist, so a CN-only install does not create the international product home, and vice versa. If no home exists, install or start that agent once before running `ctxdb setup --agent <name>`. OpenCode and Hermes are config-dir style: setup creates `~/.config/opencode` / `~/.hermes` when they are missing.
310
+ Setup first checks that the target agent home exists (`~/.qoder`, `~/.qoderwork`, `~/.qwenwork`, `~/.codex`, `~/.claude`, or either WorkBuddy home: `~/.workbuddy` / `~/.workbuddy-ai`; other declared CN variant homes also satisfy this check). Setup writes hooks and skills into every existing home, so a CN-only install does not create the international product home, and vice versa. If no home exists, install or start that agent once before running `ctxdb setup --agent <name>`. OpenCode and Hermes are config-dir style: setup creates `~/.config/opencode` / `~/.hermes` when they are missing.
249
311
 
250
312
  For **qoder**, **qoderwork**, **qwenwork**, **codex**, **claude**, and **workbuddy**, restart the harness (CLI: just exit + restart; app: Cmd+R or quit/relaunch) so it picks up the new hooks/skill. For **codex**, setup also writes `[features].hooks = true` into `~/.codex/config.toml` (creating the file if missing) — Codex won't fire any hook entries without it. On first use Codex may prompt you to trust the new hook commands. For **opencode**, restart OpenCode so it loads `~/.config/opencode/plugins/ctxdb.ts`. For **hermes**, setup also checks `~/.hermes/shell-hooks-allowlist.json`; it reports setup as incomplete until both ctxdb hook commands are approved.
251
313
 
@@ -314,12 +376,15 @@ For **hermes**, `ctxdb setup --agent hermes` writes two shell hooks under `~/.he
314
376
 
315
377
  `ctxdb` ships grouped non-interactive commands:
316
378
 
317
- - **Top-level**: `setup` / `status` / `ping` / `debug` / `uninstall` / `update` (`upgrade` alias)
379
+ - **Top-level**: `setup` / `status` / `ping` / `debug` / `uninstall` / `upgrade` (`update` alias)
318
380
  - **Memory**: `memory add|search|list|get|update|delete`, plus the `memory promotion` subgroup (记忆成文): `memory promotion generate|list|get|approve|reject|batch-action|batch-delete|resolve-doubts` and the `memory promotion template list|create|get|update|delete|set-default|clear-default` / `memory promotion settings get|update` sub-subgroups
319
- - **KB**: `kb upload-text|upload-file|update-text|update-file|list|documents-list|document-get|search`, plus the `kb review` subgroup: `kb review list|get|action|resolve-conflicts|batch-action|batch-delete|delete`, `kb review template list|create|update|delete|get|set-default|clear-default`, `kb review settings get|update`
381
+ - **KB**: `kb create|upload-text|upload-file|update-text|update-file|list|documents-list|document-get|search|entities|entity-get|entity-chunks|relations`, plus the `kb review` subgroup: `kb review list|get|action|resolve-conflicts|batch-action|batch-delete|delete`, `kb review template list|create|update|delete|get|set-default|clear-default`, `kb review settings get|update`
320
382
 
321
-
322
- See `ctxdb --help`.
383
+ Help is progressive: `ctxdb --help` lists command domains, group help such as
384
+ `ctxdb kb --help` lists direct subcommands, and a leaf such as
385
+ `ctxdb kb search --help` provides its complete arguments, constraints, output
386
+ modes, and examples. Agents can use `ctxdb help --all` for a bounded command
387
+ index or `ctxdb help kb search --json` for versioned structured discovery.
323
388
 
324
389
  ### Debug control and recall replay
325
390
 
@@ -338,7 +403,8 @@ Agent resolution follows the rest of the CLI: explicit `--agent`, then
338
403
  only `agents.<name>.debug`, makes no network request, and does not reinstall
339
404
  hooks, plugins, or skills. It requires that profile to already exist.
340
405
 
341
- The only official-production URL currently allowlisted is exactly
406
+ The official-production URL allowlist contains
407
+ `https://api.cn-hangzhou.agentcontext.aliyuncs.com` and the legacy
342
408
  `https://context-database.aliyuncs.com` (a trailing slash is equivalent).
343
409
  Policy is evaluated after profile/default inheritance and `CTXDB_BASE_URL`.
344
410
  Any other complete URL—including pre-production domains, numeric IPs,
@@ -375,6 +441,14 @@ fact-extraction). Use it when the user explicitly asks for a verbatim
375
441
  memory ("记住 / 请记忆 / 原文记下"); without `--no-infer` the server may
376
442
  rewrite, merge, or skip details.
377
443
 
444
+ `memory add [<text>] --image=<local-path>` adds an image-backed memory.
445
+ Repeat `--image` to attach multiple PNG, JPEG, or WebP files; text is optional
446
+ when at least one image is present. Image requests require inference, so they
447
+ cannot be combined with `--no-infer`. The command prints the server's
448
+ `PENDING` response and `event_id` immediately and does not poll for completion.
449
+ Recall remains text-based because the service converts image observations into
450
+ text facts.
451
+
378
452
  ### Memory promotion (记忆成文)
379
453
 
380
454
  The promotion commands live under the Memory group (`ctxdb memory promotion ...`) and cover the server's memory promotion pipeline: turn
@@ -382,7 +456,7 @@ accumulated memories into reviewed knowledge-base documents.
382
456
 
383
457
  ```sh
384
458
  # Task lifecycle
385
- ctxdb memory promotion generate "<topic>" [--knowledge-base-id=<kb-id>]
459
+ ctxdb memory promotion generate "<topic>" [--knowledge-base-id=<kb-id>] [--wait|--no-wait]
386
460
  ctxdb memory promotion list [--status=pending_review] [--page=N] [--page-size=N] \
387
461
  [--sort-by=quality_score] [--sort-order=asc|desc]
388
462
  ctxdb memory promotion get <promotion-id>
@@ -432,6 +506,42 @@ Notes:
432
506
 
433
507
  ### KB create/update completion mode
434
508
 
509
+ Knowledge-base lifecycle commands use the same Data API credential:
510
+
511
+ ```sh
512
+ ctxdb kb create <kb-name> [--description=<desc>] [--graph-enabled|--no-graph-enabled] [--review-enabled|--no-review-enabled]
513
+ ctxdb kb get (--id=<kb-id> | --name=<kb-name>)
514
+ ctxdb kb update <kb-id> [--name=<new-name>] [--description=<desc>] [--graph-enabled|--no-graph-enabled] [--review-enabled|--no-review-enabled]
515
+ ctxdb kb delete (--id=<kb-id> | --name=<kb-name>)
516
+ ```
517
+
518
+ `ctxdb kb list` defaults to the compact management fields needed to identify,
519
+ sort, and inspect each knowledge base. Pass `--raw` only when the complete
520
+ server rows, including large configuration and entity fields, are required.
521
+
522
+ `get` and `delete` require exactly one locator. `update` requires the canonical
523
+ knowledge-base ID and at least one mutable field.
524
+
525
+ Knowledge-base permissions use the same DATA API credential and server-side
526
+ authorization. Resolve a KB name with `kb get --name=...`, then use its ID:
527
+
528
+ ```sh
529
+ ctxdb kb acl subjects <kb-id> [--principal-type=member|group] [--principal-status=active|disabled] [--page=N] [--page-size=N] --json
530
+ ctxdb kb acl list <kb-id> [--principal-type=member|group] [--principal-id=<id>] [--permission=read|write|kb_manage] [--page=N] [--page-size=N] --json
531
+ ctxdb kb acl set <kb-id> --principal-type=member --principal-id=<member-id> --permission=read --json
532
+ ctxdb kb acl delete <acl-id> --json
533
+ ```
534
+
535
+ `subjects` retains the API's effective permission, source, direct grant, and
536
+ available-action fields; `list` returns explicit ACL grants. Both retain pagination
537
+ metadata (default page 1, page size 100). Page through the returned total for a
538
+ complete result. `set` changes one direct grant; members accept `read`, `write`,
539
+ or `kb_manage`, while groups accept only `read` or `write`. `delete` removes only
540
+ the specified ACL ID, so inherited access may remain; read `subjects` again to
541
+ verify the effective result. All commands accept `--raw` for the original envelope.
542
+ Writes require advanced permission mode and appropriate server-side authority;
543
+ the CLI propagates a refusal without enabling the mode or using another identity.
544
+
435
545
  `kb upload-text`, `kb upload-file`, `kb update-text`, and `kb update-file`
436
546
  return as soon as the service accepts the document. The returned document may still have
437
547
  `ingest_status: "processing"`; acceptance does not mean ingestion succeeded.
@@ -441,6 +551,14 @@ return as soon as the service accepts the document. The returned document may st
441
551
  - Existing `--no-wait` calls remain valid and behave like the new default.
442
552
  - `--wait` and `--no-wait` cannot be combined.
443
553
 
554
+ With `--wait`, the CLI writes one `document_accepted` JSON receipt to stderr
555
+ before polling, containing the returned `document_id`, `knowledge_base_id` (when
556
+ available), and `ingest_status`. This is acceptance, not proof of completed
557
+ ingestion. Keep stderr separate when parsing the final stdout JSON. If the wait
558
+ is interrupted, query the receipt's ID and current logical document before
559
+ deciding whether another write is necessary; an older ID may still expose an
560
+ older version's chunks. The receipt contains no document body or credentials.
561
+
444
562
  Scripts that relied on implicit terminal polling must migrate to:
445
563
 
446
564
  ```sh
@@ -480,6 +598,61 @@ Every successful update returns the canonical `document.id` and
480
598
  same-content updates may reuse it. Callers must retain the returned ID for the
481
599
  next update; `--wait` also polls the returned ID/KB pair rather than caller input.
482
600
 
601
+ ### Knowledge graph read commands
602
+
603
+ `kb entities` / `kb entity-get` / `kb entity-chunks` / `kb relations` cover the
604
+ four knowledge-graph read DATA APIs (`GET /v1/knowledge/entities`,
605
+ `/v1/knowledge/entities/detail`, `/v1/knowledge/entities/chunks`,
606
+ `/v1/knowledge/entity-relations`). They give agents real entity navigation
607
+ instead of re-querying `kb search` with rewritten keywords. Every command
608
+ accepts `--agent` (`CTXDB_AGENT`) and `--json`, and follows the three-tier
609
+ projection (`kb search` discipline): default prints a minimal agent view,
610
+ `--verbose` adds provenance/alias fields, `--raw` ships the server response
611
+ verbatim (Box envelope included for `entity-get`). Value validation (mode
612
+ enum, page-size clamps, the 20-id cap, the limit range) belongs to the
613
+ kernel — its 400s are surfaced, never swallowed or preempted; missing
614
+ required flags or malformed integers print usage and exit 2 before any
615
+ request is sent.
616
+
617
+ ```sh
618
+ # List / search entities. No keyword = paginated list; keyword enters name
619
+ # search and --mode picks the matching rule (exact | fuzzy | semantic).
620
+ ctxdb kb entities [--kb=<kb-id>] [--page=N] [--page-size=N]
621
+ ctxdb kb entities "graph rag" --kb=<kb-id> --mode=semantic
622
+
623
+ # Single entity detail — both locators required; full untruncated
624
+ # source_document_ids + aliases.
625
+ ctxdb kb entity-get --kb=<kb-id> --entity-id=<id>
626
+
627
+ # Source-chunk evidence behind up to 20 entities (limit 1..200, default 20).
628
+ ctxdb kb entity-chunks --kb=<kb-id> --entity-ids=<id1>,<id2> [--limit=N]
629
+
630
+ # Relations. The two entity filters are NOT aliases:
631
+ # --entity-id=X → 1-hop expansion, EITHER endpoint matches X
632
+ # --entity-ids=A,B → induced subgraph, BOTH endpoints must be in the set
633
+ ctxdb kb relations --kb=<kb-id> --entity-id=<id>
634
+ ctxdb kb relations --kb=<kb-id> --entity-ids=<a>,<b> [--relation-type=<t>] \
635
+ [--page=N] [--page-size=N] [--max-nodes=N] [--max-edges=N]
636
+ ```
637
+
638
+ Output semantics worth knowing:
639
+
640
+ - List responses (`entities` / `relations`) carry `total` + `page` +
641
+ `page_size`; there is no `truncated` flag on these endpoints.
642
+ - Under `--mode=semantic`, `total` is the size of the bounded candidate pool,
643
+ **not** the full match count.
644
+ - In entity list items, `source_document_ids` is truncated (20 max) —
645
+ `source_document_count` is the truth; fetch `entity-get` for full
646
+ provenance.
647
+ - `entity-chunks` carries `total`, `candidate_total` and `truncated` so you
648
+ can tell "that's all the evidence" from "the limit budget ran out".
649
+ Entities that don't exist or have no provenance are silently skipped —
650
+ partial hits are normal batch behavior.
651
+ - `relations --verbose` adds `nodes[]`: the hydrated endpoint entities with
652
+ their `(knowledge_base_id, entity_id)` locator pairs. `nodes` may be
653
+ incomplete by design (deleted endpoints are omitted); relation items always
654
+ keep denormalized endpoint names.
655
+
483
656
  ### Knowledge review commands
484
657
 
485
658
  `kb review` covers the Knowledge Review DATA APIs: review-queue handling
@@ -600,7 +773,7 @@ Lives at `~/.ctxdb/ctxdb.json` (co-located with logs at `~/.ctxdb/logs/`). Schem
600
773
  "agents": {
601
774
  "qoder": {
602
775
  "api_key": "ctxdb-...",
603
- "base_url": "https://context-database.aliyuncs.com",
776
+ "base_url": "https://api.cn-hangzhou.agentcontext.aliyuncs.com",
604
777
  "user_id": "default",
605
778
  "auto_capture": true,
606
779
  "auto_recall": true,
@@ -701,7 +874,7 @@ ctxdb uninstall --purge-logs # also deletes ~/.ctxdb/logs/
701
874
 
702
875
  ### What uninstall does (and doesn't) touch
703
876
 
704
- - **Hook entries in `~/.qoder/settings.json`, `~/.qoderwork/settings.json`, `~/.qwenwork/settings.json`, `~/.codex/hooks.json`, `~/.claude/settings.json`, `~/.workbuddy-ai/settings.json`, and `~/.hermes/config.yaml`**: stripped precisely by marker (`_ctxdb = @aliyunrds/ctxdb`, plus legacy keys `_ctxdbQoder` / `_ctxdbPackage` and the legacy `@aliyunrds/ctxdb-qoder` value for installs predating the unified marker). Any hooks you added yourself stay. A timestamped `*.bak-ctxdb-<TS>` is written before each modification (rotation keeps the 5 most recent).
877
+ - **Hook entries in `~/.qoder/settings.json`, `~/.qoderwork/settings.json`, `~/.qwenwork/settings.json`, `~/.codex/hooks.json`, `~/.claude/settings.json`, `~/.workbuddy/settings.json`, `~/.workbuddy-ai/settings.json`, and `~/.hermes/config.yaml`**: stripped precisely by marker (`_ctxdb = @aliyunrds/ctxdb`, plus legacy keys `_ctxdbQoder` / `_ctxdbPackage` and the legacy `@aliyunrds/ctxdb-qoder` value for installs predating the unified marker). Any hooks you added yourself stay. A timestamped `*.bak-ctxdb-<TS>` is written before each modification (rotation keeps the 5 most recent).
705
878
  - **Skill directories**: `~/.<agent>/skills/ctxdb/` for each set-up agent, plus legacy dirs (`ctxdb-qoder`, `rds-ctxdb-qoder`, `qoder-ctxdb`) under `~/.qoder/skills/` from older package names.
706
879
  - **`~/.ctxdb/` state**: only with `--purge-config` / `--purge-logs` / `--purge-all`. Defensive: `--purge-all` removes the `~/.ctxdb/` root only if it's empty after the named files are deleted (won't blanket-rm an unknown directory).
707
880
  - **`~/.codex/config.toml` `[features].hooks`**: **NOT** reverted. Setup adds `hooks = true` so Codex will fire ctxdb's hook entries; uninstall leaves the flag alone because (a) the user may have wanted it on for non-ctxdb hooks, and (b) it's harmless when `~/.codex/hooks.json` is empty. If you want it off, edit the file by hand.
@@ -735,3 +908,7 @@ Maintainer-facing docs (source layout, dev/test workflows, server-config archive
735
908
  ## License
736
909
 
737
910
  Apache-2.0
911
+
912
+ 上传时可用 `ctxdb kb upload-text` 或 `ctxdb kb upload-file` 的 `--review-enabled` / `--no-review-enabled` 覆盖本次文档评审开关;不传时沿用服务端默认,不修改知识库策略。两标志互斥,分片上传保留同一选择。上传回执不代表评审或入库完成,应查询实际状态。
913
+
914
+ `memory get <fact-id> --verbose` 通过原生 Fact 详情接口读取状态、关联实体 ID、来源及参考/记录时间;默认 `memory get` 的 mem0 输出保持兼容。召回统计可从同一身份的 `memory list` 中按 ID 对应读取。