@aliyunrds/ctxdb 1.0.7 → 1.0.8-beta.1

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.
@@ -1,18 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureParsedMessages
4
- } from "../chunk-DC5NWGDW.js";
5
- import "../chunk-X2BX6LR6.js";
4
+ } from "../chunk-SGRMPSZU.js";
5
+ import "../chunk-3B7J5VUT.js";
6
+ import {
7
+ shouldSkipHooks
8
+ } from "../chunk-5ML4VSXN.js";
6
9
  import {
7
10
  HttpClient,
8
11
  agentFromArgvWithFallback,
9
12
  debug,
10
13
  load,
11
14
  setDebug
12
- } from "../chunk-S5W4FQ7M.js";
13
- import {
14
- shouldSkipHooks
15
- } from "../chunk-UEKR2Z3S.js";
15
+ } from "../chunk-KYW76CL7.js";
16
+ import "../chunk-R67JELM7.js";
17
+ import "../chunk-VIG4SYLU.js";
16
18
 
17
19
  // src/hooks/hermes-post-llm-call.ts
18
20
  import { pathToFileURL } from "url";
@@ -2,17 +2,20 @@
2
2
  import {
3
3
  HOOK_TIMEOUT_MS,
4
4
  composeSessionStart
5
- } from "../chunk-NFTGG6WK.js";
5
+ } from "../chunk-TYW6ABNS.js";
6
6
  import {
7
7
  composeUserPromptSubmit
8
- } from "../chunk-R2QS6ACP.js";
8
+ } from "../chunk-LTAO6USK.js";
9
9
  import {
10
10
  fetchKbCatalogBlock
11
- } from "../chunk-DPLMBHLU.js";
12
- import "../chunk-QVXDI77N.js";
11
+ } from "../chunk-NF5KFV2P.js";
13
12
  import {
14
13
  isCircuitOpen
15
- } from "../chunk-X2BX6LR6.js";
14
+ } from "../chunk-3B7J5VUT.js";
15
+ import {
16
+ shouldSkipHooks
17
+ } from "../chunk-5ML4VSXN.js";
18
+ import "../chunk-NFAPLK4C.js";
16
19
  import {
17
20
  HttpClient,
18
21
  agentFromArgvWithFallback,
@@ -20,10 +23,9 @@ import {
20
23
  isComplete,
21
24
  load,
22
25
  setDebug
23
- } from "../chunk-S5W4FQ7M.js";
24
- import {
25
- shouldSkipHooks
26
- } from "../chunk-UEKR2Z3S.js";
26
+ } from "../chunk-KYW76CL7.js";
27
+ import "../chunk-R67JELM7.js";
28
+ import "../chunk-VIG4SYLU.js";
27
29
 
28
30
  // src/hooks/hermes-pre-llm-call.ts
29
31
  import { pathToFileURL } from "url";
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  shouldSkipHooks
4
- } from "../chunk-UEKR2Z3S.js";
4
+ } from "../chunk-5ML4VSXN.js";
5
+ import "../chunk-VIG4SYLU.js";
5
6
 
6
7
  // src/hooks/pre-tool-use.ts
7
8
  async function main() {
@@ -3,12 +3,15 @@ import {
3
3
  HOOK_TIMEOUT_MS,
4
4
  composeSessionStart,
5
5
  formatSessionStartStdout
6
- } from "../chunk-NFTGG6WK.js";
7
- import "../chunk-DPLMBHLU.js";
8
- import "../chunk-QVXDI77N.js";
6
+ } from "../chunk-TYW6ABNS.js";
7
+ import "../chunk-NF5KFV2P.js";
9
8
  import {
10
9
  isCircuitOpen
11
- } from "../chunk-X2BX6LR6.js";
10
+ } from "../chunk-3B7J5VUT.js";
11
+ import {
12
+ shouldSkipHooks
13
+ } from "../chunk-5ML4VSXN.js";
14
+ import "../chunk-NFAPLK4C.js";
12
15
  import {
13
16
  HttpClient,
14
17
  agentFromArgvWithFallback,
@@ -16,10 +19,9 @@ import {
16
19
  isComplete,
17
20
  load,
18
21
  setDebug
19
- } from "../chunk-S5W4FQ7M.js";
20
- import {
21
- shouldSkipHooks
22
- } from "../chunk-UEKR2Z3S.js";
22
+ } from "../chunk-KYW76CL7.js";
23
+ import "../chunk-R67JELM7.js";
24
+ import "../chunk-VIG4SYLU.js";
23
25
 
24
26
  // src/hooks/session-start.ts
25
27
  import { pathToFileURL } from "url";
@@ -1,18 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureTurn
4
- } from "../chunk-DC5NWGDW.js";
5
- import "../chunk-X2BX6LR6.js";
4
+ } from "../chunk-SGRMPSZU.js";
5
+ import "../chunk-3B7J5VUT.js";
6
+ import {
7
+ shouldSkipHooks
8
+ } from "../chunk-5ML4VSXN.js";
6
9
  import {
7
10
  HttpClient,
8
11
  agentFromArgvWithFallback,
9
12
  debug,
10
13
  load,
11
14
  setDebug
12
- } from "../chunk-S5W4FQ7M.js";
13
- import {
14
- shouldSkipHooks
15
- } from "../chunk-UEKR2Z3S.js";
15
+ } from "../chunk-KYW76CL7.js";
16
+ import "../chunk-R67JELM7.js";
17
+ import "../chunk-VIG4SYLU.js";
16
18
 
17
19
  // src/hooks/stop.ts
18
20
  async function readStdinJson() {
@@ -2,12 +2,15 @@
2
2
  import {
3
3
  composeUserPromptSubmit,
4
4
  formatUserPromptSubmitStdout
5
- } from "../chunk-R2QS6ACP.js";
6
- import "../chunk-DPLMBHLU.js";
7
- import "../chunk-QVXDI77N.js";
5
+ } from "../chunk-LTAO6USK.js";
6
+ import "../chunk-NF5KFV2P.js";
8
7
  import {
9
8
  isCircuitOpen
10
- } from "../chunk-X2BX6LR6.js";
9
+ } from "../chunk-3B7J5VUT.js";
10
+ import {
11
+ shouldSkipHooks
12
+ } from "../chunk-5ML4VSXN.js";
13
+ import "../chunk-NFAPLK4C.js";
11
14
  import {
12
15
  HttpClient,
13
16
  agentFromArgvWithFallback,
@@ -15,10 +18,9 @@ import {
15
18
  isComplete,
16
19
  load,
17
20
  setDebug
18
- } from "../chunk-S5W4FQ7M.js";
19
- import {
20
- shouldSkipHooks
21
- } from "../chunk-UEKR2Z3S.js";
21
+ } from "../chunk-KYW76CL7.js";
22
+ import "../chunk-R67JELM7.js";
23
+ import "../chunk-VIG4SYLU.js";
22
24
 
23
25
  // src/hooks/user-prompt-submit.ts
24
26
  import { pathToFileURL } from "url";
@@ -1,7 +1,10 @@
1
+ // <define:__CTXDB_DISTRIBUTION_MANIFEST__>
2
+ var define_CTXDB_DISTRIBUTION_MANIFEST_default = { id: "public", packageName: "@aliyunrds/ctxdb", packageRegistry: null, capabilities: { interactiveLogin: false, managedCredentials: false } };
3
+
1
4
  // src/config.ts
2
- import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
5
+ import { readFileSync as readFileSync2, existsSync as existsSync2, statSync as statSync2 } from "fs";
3
6
  import { homedir as homedir2 } from "os";
4
- import { join as join2 } from "path";
7
+ import { dirname as dirname2, join as join2 } from "path";
5
8
 
6
9
  // ../shared/src/graph-context.ts
7
10
  var GRAPH_CONTEXT_TAG = "graphrag";
@@ -828,6 +831,18 @@ function isRecallTraceRecord(value) {
828
831
  return isNonNegativeFinite(record.duration_ms) && typeof record.outcome === "string" && TRACE_OUTCOMES.has(record.outcome) && (typeof record.failure_reason === "string" || record.failure_reason === null) && Array.isArray(record.returned_memories) && Array.isArray(record.returned_knowledge) && Boolean(selection) && Array.isArray(selection?.selected) && Array.isArray(selection?.excluded) && isNonNegativeFinite(selection?.token_estimate) && typeof record.recall_context === "string";
829
832
  }
830
833
 
834
+ // src/distribution-capabilities.ts
835
+ var PUBLIC_DISTRIBUTION = {
836
+ id: "public",
837
+ packageName: "@aliyunrds/ctxdb",
838
+ packageRegistry: null,
839
+ capabilities: {
840
+ interactiveLogin: false,
841
+ managedCredentials: false
842
+ }
843
+ };
844
+ var DISTRIBUTION_MANIFEST = typeof define_CTXDB_DISTRIBUTION_MANIFEST_default === "undefined" ? PUBLIC_DISTRIBUTION : define_CTXDB_DISTRIBUTION_MANIFEST_default;
845
+
831
846
  // src/config.ts
832
847
  var DEFAULT_BASE_URL = "https://context-database.aliyuncs.com";
833
848
  var DEFAULT_USER_ID = "default";
@@ -893,6 +908,40 @@ function applyDebugPolicy(cfg) {
893
908
  cfg.debugReason = policy.debugReason;
894
909
  return cfg;
895
910
  }
911
+ function managedCredential(path) {
912
+ if (!existsSync2(path)) return null;
913
+ if (process.platform !== "win32" && (statSync2(path).mode & 63) !== 0) {
914
+ throw new Error(`credentials: ${path} must be owner-only (run chmod 600)`);
915
+ }
916
+ const raw = JSON.parse(readFileSync2(path, "utf8"));
917
+ if (raw.version !== 1 || !raw.records || typeof raw.records !== "object") {
918
+ throw new Error("credentials: unsupported credentials.json schema");
919
+ }
920
+ const unknownKeys = Object.keys(raw.records).filter(
921
+ (key) => key !== "contextdb/active"
922
+ );
923
+ if (unknownKeys.length > 0) {
924
+ throw new Error(`credentials: unsupported record key ${unknownKeys[0]}`);
925
+ }
926
+ const record = raw.records["contextdb/active"];
927
+ if (!record) return null;
928
+ if (record.kind !== "api-key" || typeof record.payload?.api_key !== "string" || !record.payload.api_key || typeof record.payload?.base_url !== "string" || !record.payload.base_url) {
929
+ throw new Error("credentials: invalid contextdb/active record");
930
+ }
931
+ let baseUrl;
932
+ try {
933
+ baseUrl = new URL(record.payload.base_url);
934
+ } catch {
935
+ throw new Error("credentials: invalid contextdb/active base_url");
936
+ }
937
+ if (!["https:", "http:"].includes(baseUrl.protocol) || baseUrl.username || baseUrl.password || baseUrl.search || baseUrl.hash) {
938
+ throw new Error("credentials: invalid contextdb/active base_url");
939
+ }
940
+ return {
941
+ apiKey: record.payload.api_key,
942
+ baseUrl: baseUrl.toString().replace(/\/$/, "")
943
+ };
944
+ }
896
945
  function loadOpencodeConfig(options = {}) {
897
946
  const env = options.env ?? process.env;
898
947
  const path = options.path ?? defaultPath(env);
@@ -918,6 +967,13 @@ function loadOpencodeConfig(options = {}) {
918
967
  debugReason: null,
919
968
  kbCatalogInjection: coerceKbCatalogInjection(section.kb_catalog_injection)
920
969
  };
970
+ const managed = DISTRIBUTION_MANIFEST.capabilities.managedCredentials && options.managedCredentials !== false ? managedCredential(
971
+ options.credentialsPath ?? join2(dirname2(path), "credentials.json")
972
+ ) : null;
973
+ if (managed) {
974
+ cfg.apiKey = managed.apiKey;
975
+ cfg.baseUrl = managed.baseUrl;
976
+ }
921
977
  return applyEnv(cfg, env);
922
978
  }
923
979
  function isConfigured(cfg) {
@@ -19,7 +19,7 @@ description: contextdb 知识库高频操作(查询 / 浏览 KB / 上传或更
19
19
 
20
20
  ## 2. 高频 recipes
21
21
 
22
- > 命令里的 `--agent={{agent}}` 是当前 skill 安装目标。不要把示例改成 `qoder`;如果读到未替换的双花括号 agent 模板,先按 §6 判定真实 agent,再替换成 `qoder` / `qoderwork` / `codex` / `claude` / `opencode` / `hermes` / `default`。
22
+ > 命令里的 `--agent={{agent}}` 是当前 skill 安装目标。不要把示例改成 `qoder`;如果读到未替换的双花括号 agent 模板,先按 §6 判定真实 agent,再替换成 `qoder` / `qoderwork` / `qwenwork` / `codex` / `claude` / `opencode` / `hermes` / `workbuddy` / `default`。
23
23
 
24
24
  ### Recipe 1:在已知 KB 中查内容(最常见)
25
25
 
@@ -239,18 +239,18 @@ init 使用 PUT,part/complete 保持原协议;网络结果不明确时不自
239
239
 
240
240
  | 参数 | 说明 |
241
241
  |------|------|
242
- | `--agent=<name>` | **必填**。指定操作哪个 agent 的配置桶(`qoder` / `qoderwork` / `codex` / `claude` / `opencode` / `hermes` / `default`) |
242
+ | `--agent=<name>` | **必填**。指定操作哪个 agent 的配置桶(`qoder` / `qoderwork` / `qwenwork` / `codex` / `claude` / `opencode` / `hermes` / `workbuddy` / `default`) |
243
243
 
244
244
  `--agent` 解析顺序:
245
245
  1. 命令行显式 `--agent=<name>` → 用它
246
246
  2. 缺省 → 读 `CTXDB_AGENT` 环境变量
247
247
  3. env 也没有 → 落到 `"default"` 桶
248
- 4. 新版本 `ctxdb setup --agent <qoder|qoderwork|qwenwork|codex|claude|opencode|hermes>` 会在 `agents.default` 缺失时复制当前 agent 配置作为兜底
248
+ 4. 新版本 `ctxdb setup --agent <qoder|qoderwork|qwenwork|codex|claude|opencode|hermes|workbuddy>` 会在 `agents.default` 缺失时复制当前 agent 配置作为兜底
249
249
  5. 若 `"default"` 桶仍不存在或未配置完整 → exit 2 "config incomplete for agent default"
250
250
 
251
251
  ## 7. 配置
252
252
 
253
- - 配置文件:`~/.ctxdb/ctxdb.json`,分 `agents.<name>` 段(`qoder` / `qoderwork` / `codex` / `claude` / `opencode` / `hermes` / `default`),互不复用
253
+ - 配置文件:`~/.ctxdb/ctxdb.json`,分 `agents.<name>` 段(`qoder` / `qoderwork` / `qwenwork` / `codex` / `claude` / `opencode` / `hermes` / `workbuddy` / `default`),互不复用
254
254
  - 配置命令:`ctxdb setup --agent <name> --api-key=<key> --base-url=<url> [--user-id=<id>]`
255
255
  - 带 `--agent` 时还会装 hooks + skill;若 `agents.default` 缺失,会复制当前 agent 配置作为 CLI 兜底
256
256
  - `--agent default` 只写 `agents.default` 段(仅 CLI 用,不装 hooks / skill)
@@ -18,7 +18,7 @@ description: contextdb 长期记忆高频操作(主动记忆 / 搜索过往 /
18
18
 
19
19
  ## 2. 高频 recipes
20
20
 
21
- > 命令里的 `--agent={{agent}}` 是当前 skill 安装目标。不要把示例改成 `qoder`;如果读到未替换的双花括号 agent 模板,先按 §6 判定真实 agent,再替换成 `qoder` / `qoderwork` / `codex` / `claude` / `opencode` / `hermes` / `default`。
21
+ > 命令里的 `--agent={{agent}}` 是当前 skill 安装目标。不要把示例改成 `qoder`;如果读到未替换的双花括号 agent 模板,先按 §6 判定真实 agent,再替换成 `qoder` / `qoderwork` / `qwenwork` / `codex` / `claude` / `opencode` / `hermes` / `workbuddy` / `default`。
22
22
 
23
23
  ### Recipe 1:主动记忆("记住 X")
24
24
 
@@ -165,18 +165,18 @@ ctxdb memory delete <memory-id> --agent={{agent}}
165
165
 
166
166
  | 参数 | 说明 |
167
167
  |------|------|
168
- | `--agent=<name>` | **必填**。指定操作哪个 agent 的配置桶(`qoder` / `qoderwork` / `codex` / `claude` / `opencode` / `hermes` / `default`) |
168
+ | `--agent=<name>` | **必填**。指定操作哪个 agent 的配置桶(`qoder` / `qoderwork` / `qwenwork` / `codex` / `claude` / `opencode` / `hermes` / `workbuddy` / `default`) |
169
169
 
170
170
  `--agent` 解析顺序:
171
171
  1. 命令行显式 `--agent=<name>` → 用它
172
172
  2. 缺省 → 读 `CTXDB_AGENT` 环境变量
173
173
  3. env 也没有 → 落到 `"default"` 桶
174
- 4. 新版本 `ctxdb setup --agent <qoder|qoderwork|qwenwork|codex|claude|opencode|hermes>` 会在 `agents.default` 缺失时复制当前 agent 配置作为兜底
174
+ 4. 新版本 `ctxdb setup --agent <qoder|qoderwork|qwenwork|codex|claude|opencode|hermes|workbuddy>` 会在 `agents.default` 缺失时复制当前 agent 配置作为兜底
175
175
  5. 若 `"default"` 桶仍不存在或未配置完整 → exit 2 "config incomplete for agent default"
176
176
 
177
177
  ## 7. 配置
178
178
 
179
- - 配置文件:`~/.ctxdb/ctxdb.json`,分 `agents.<name>` 段(`qoder` / `qoderwork` / `codex` / `claude` / `opencode` / `hermes` / `default`),互不复用
179
+ - 配置文件:`~/.ctxdb/ctxdb.json`,分 `agents.<name>` 段(`qoder` / `qoderwork` / `qwenwork` / `codex` / `claude` / `opencode` / `hermes` / `workbuddy` / `default`),互不复用
180
180
  - 配置命令:`ctxdb setup --agent <name> --api-key=<key> --base-url=<url> [--user-id=<id>]`
181
181
  - 带 `--agent` 时还会装 hooks + skill;若 `agents.default` 缺失,会复制当前 agent 配置作为 CLI 兜底
182
182
  - `--agent default` 只写 `agents.default` 段(仅 CLI 用,不装 hooks / skill)
@@ -4,7 +4,9 @@ import {
4
4
  recordVersionCheckFailure,
5
5
  recordVersionCheckSuccess,
6
6
  releaseVersionCheckLock
7
- } from "../chunk-Z6OHSEF2.js";
7
+ } from "../chunk-ULAWTBBC.js";
8
+ import "../chunk-R67JELM7.js";
9
+ import "../chunk-VIG4SYLU.js";
8
10
 
9
11
  // src/workers/version-check.ts
10
12
  import { fileURLToPath } from "url";
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aliyunrds/ctxdb",
3
- "version": "1.0.7",
3
+ "version": "1.0.8-beta.1",
4
4
  "type": "module",
5
- "description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot `setup --agent <qoder|qoderwork|codex|claude|opencode|hermes>` installer, per-agent config, hooks/plugins, and SKILL.md.",
5
+ "description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot multi-agent installer, per-agent config, hooks/plugins, and SKILL.md.",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "rds-context-database",
@@ -10,8 +10,10 @@
10
10
  "memory",
11
11
  "knowledge-base",
12
12
  "qoder",
13
+ "qwenwork",
13
14
  "codex",
14
15
  "claude-code",
16
+ "workbuddy",
15
17
  "opencode",
16
18
  "hermes",
17
19
  "hooks"
@@ -44,6 +46,10 @@
44
46
  },
45
47
  "scripts": {
46
48
  "build": "tsup && pnpm --dir ../opencode build && mkdir -p dist/setup dist/opencode && cp ../opencode/dist/index.js dist/opencode/index.js && cp -r src/setup/skills dist/setup/ && chmod +x dist/hooks/*.js dist/cli/main.js",
49
+ "build:internal": "tsup --config tsup.internal.config.ts && pnpm --dir ../opencode build:internal && mkdir -p dist-internal/setup dist-internal/opencode && cp ../opencode/dist-internal/index.js dist-internal/opencode/index.js && cp -r src/setup/skills dist-internal/setup/ && chmod +x dist-internal/hooks/*.js dist-internal/cli/internal-main.js && node scripts/prepare-internal-package.mjs",
50
+ "test:distributions": "node scripts/smoke-distribution-builds.mjs",
51
+ "test:e2e:distributions:prepared": "node scripts/prepare-distribution-e2e.mjs && vitest run --config vitest.e2e.config.ts",
52
+ "test:e2e:distributions": "pnpm --dir ../shared build && pnpm build && pnpm build:internal && pnpm test:e2e:distributions:prepared",
47
53
  "test": "vitest run"
48
54
  }
49
55
  }
File without changes