@aliyunrds/ctxdb 1.0.0-beta.3 → 1.0.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
@@ -55,7 +55,7 @@ For **qoder**, **qoderwork**, **codex**, and **claude**, hooks fire automaticall
55
55
 
56
56
  Implementation note: qoder/Claude consume the JSON `hookSpecificOutput.additionalContext` shape; Codex has been verified on this machine through `~/.codex/hooks.json`, `[features].hooks = true`, and hook audit logs, where non-empty stdout from `UserPromptSubmit`/`SessionStart` is treated as injected context. The same hook core is shared; setup passes `--agent=<name>` so each hook reads its own config section.
57
57
 
58
- For **opencode**, `ctxdb setup --agent opencode` writes a small re-export shim at `~/.config/opencode/plugins/ctxdb.ts`. The shim points into this package's bundled `dist/opencode/index.js`, so `npm update -g @aliyunrds/ctxdb` updates the plugin implementation without copying source into the user config directory. `ctxdb upgrade --agent opencode` refreshes the absolute shim target after package moves.
58
+ For **opencode**, `ctxdb setup --agent opencode` copies the self-contained plugin bundle to `~/.config/opencode/plugins/ctxdb-bundle.js` and writes a re-export shim at `~/.config/opencode/plugins/ctxdb.ts` referencing it via the relative path `./ctxdb-bundle.js` (Bun on Windows can't resolve absolute-path specifiers from a .ts shim). `ctxdb upgrade --agent opencode` re-copies the bundle + refreshes the shim.
59
59
 
60
60
  ## CLI
61
61
 
@@ -132,7 +132,7 @@ Env-var overrides apply to the selected agent config (env wins): `CTXDB_AGENT` /
132
132
  ```
133
133
  @aliyunrds/ctxdb ← this package (CLI + setup + hooks + skills)
134
134
 
135
- ├─ bundles OpenCode plugin in dist/opencode/index.js
135
+ ├─ bundles OpenCode plugin (self-contained) in dist/opencode/index.js; setup copies it to ~/.config/opencode/plugins/ctxdb-bundle.js
136
136
 
137
137
  └─ depends on @aliyunrds/ctxdb-shared ← input sanitation,
138
138
  prompt-injection defenses,
package/dist/cli/main.js CHANGED
@@ -237,8 +237,8 @@ import {
237
237
  statSync
238
238
  } from "fs";
239
239
  import { homedir } from "os";
240
- import { join, dirname } from "path";
241
- import { fileURLToPath, pathToFileURL } from "url";
240
+ import { join, dirname, resolve } from "path";
241
+ import { fileURLToPath } from "url";
242
242
  import { execFileSync } from "child_process";
243
243
  var UNINSTALL_NPM_HINT = "To also remove the npm binaries: `npm uninstall -g @aliyunrds/ctxdb @aliyunrds/ctxdb-shared`";
244
244
  var UNINSTALL_ORDER_HINT = "When you eventually want to uninstall: run `ctxdb uninstall --purge-all` FIRST, then `npm uninstall -g @aliyunrds/ctxdb @aliyunrds/ctxdb-shared`. (npm 7+ removed uninstall lifecycle hooks, so the order matters \u2014 otherwise agent settings.json hooks + ~/.ctxdb/ residue stay behind.)";
@@ -875,7 +875,7 @@ function checkOpencodeShimHealth() {
875
875
  detail: `opencode shim malformed: ${path} \u2014 re-run \`ctxdb setup --agent opencode\``
876
876
  };
877
877
  }
878
- const targetPath = target.startsWith("file:") ? fileURLToPath(target) : target;
878
+ const targetPath = target.startsWith("file:") ? fileURLToPath(target) : resolve(dirname(path), target);
879
879
  if (!existsSync(targetPath)) {
880
880
  return {
881
881
  installed: true,
@@ -1113,6 +1113,10 @@ var OPENCODE_SHIM_FILENAME = "ctxdb.ts";
1113
1113
  function opencodeShimPath() {
1114
1114
  return join(homedir(), ".config", "opencode", "plugins", OPENCODE_SHIM_FILENAME);
1115
1115
  }
1116
+ var OPENCODE_BUNDLE_FILENAME = "ctxdb-bundle.js";
1117
+ function opencodeBundlePath() {
1118
+ return join(homedir(), ".config", "opencode", "plugins", OPENCODE_BUNDLE_FILENAME);
1119
+ }
1116
1120
  function resolveOpencodePluginEntry() {
1117
1121
  const here = dirname(fileURLToPath(import.meta.url));
1118
1122
  const pkgRoot = walkUpToPackageJson(here, "@aliyunrds/ctxdb");
@@ -1125,22 +1129,28 @@ function resolveOpencodePluginEntry() {
1125
1129
  }
1126
1130
  var OPENCODE_SHIM_HEADER = "// Generated by ctxdb setup --agent opencode. Do not edit by hand.\n// To refresh after moving ctxdb's install directory, run ctxdb upgrade --agent opencode or re-run setup.\n// To remove, run: ctxdb setup --remove --agent opencode\n";
1127
1131
  function writeOpencodeShim(absEntry) {
1128
- const path = opencodeShimPath();
1129
- mkdirSync(dirname(path), { recursive: true });
1130
- const importSpec = process.platform === "win32" ? pathToFileURL(absEntry).href : absEntry.replace(/\\/g, "/");
1132
+ const shimPath = opencodeShimPath();
1133
+ const bundlePath = opencodeBundlePath();
1134
+ mkdirSync(dirname(shimPath), { recursive: true });
1135
+ copyFileSync(absEntry, bundlePath);
1136
+ const importSpec = "./" + OPENCODE_BUNDLE_FILENAME;
1131
1137
  const body = `${OPENCODE_SHIM_HEADER}export { default } from ${JSON.stringify(importSpec)};
1132
1138
  `;
1133
- writeFileSync(path, body, "utf-8");
1139
+ writeFileSync(shimPath, body, "utf-8");
1134
1140
  }
1135
1141
  function removeOpencodeShim() {
1136
- const path = opencodeShimPath();
1137
- if (!existsSync(path)) return false;
1138
- try {
1139
- unlinkSync(path);
1140
- return true;
1141
- } catch {
1142
- return false;
1142
+ const shimPath = opencodeShimPath();
1143
+ const bundlePath = opencodeBundlePath();
1144
+ let removed = false;
1145
+ for (const p of [shimPath, bundlePath]) {
1146
+ if (!existsSync(p)) continue;
1147
+ try {
1148
+ unlinkSync(p);
1149
+ removed = true;
1150
+ } catch {
1151
+ }
1143
1152
  }
1153
+ return removed;
1144
1154
  }
1145
1155
  var ENTRY_MARKER_KEY = "_ctxdb";
1146
1156
  var ENTRY_MARKER_VALUE = "@aliyunrds/ctxdb";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliyunrds/ctxdb",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot `setup --agent <qoder|qoderwork|codex|claude|opencode>` installer, per-agent config, hooks/plugins, and SKILL.md.",
6
6
  "license": "Apache-2.0",