Install
Install with PiG
pig install npm:@aliyunrds/ctxdb-piInstall with Pi
pi install npm:@aliyunrds/ctxdb-piPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"skills": [
"./dist/skills"
],
"extensions": [
"./dist/index.js"
]
}README
Written by the package's publisher, shown as published in version 0.0.1 (README.md). PiG does not review it.
ContextDB for Pi
Connect Pi to a ContextDB workspace for automatic memory recall and capture and for knowledge-base discovery. The extension runs in the Pi process and ships with its runtime dependencies.
Install and connect
Use Pi 1.5.0 or newer and Node.js 22.19.0 or newer.
pi install npm:@aliyunrds/ctxdb-pi
npx @aliyunrds/ctxdb-pi configure --site cn
Start Pi after installing the package or run /reload in an existing session. These commands run inside Pi.
/ctxdb-loginopens browser authorization with a Device Code on the China site./ctxdb-login ctxdb-xxxxconnects with an API Key. Add--site intlto either form for the international site./ctxdb-statusshows the credential type and automatic memory settings./ctxdb-logoutdisconnects the Pi profile and cancels pending login. Shared sessions stay available to other profiles.
Pi may keep slash-command text in its editor history for the current process. Use the hidden API Key prompt in the terminal command above to avoid entering a key in Pi's editor. Add --device-code to use browser authorization from the terminal, or --key-stdin to read the key from a pipe. Pi verifies the API Key with the selected site before saving credentials or settings.
When testing a specific version or tag, use the same package suffix on both lines. Add --no-browser to authorize from another device. For scripted API Key setup use --key-stdin.
Configure from an installed package
Use the package already installed by Pi when working offline or when testing a local build.
pi_prefix="${PI_CODING_AGENT_DIR:-$HOME/.pi/agent}/npm"
npm exec --offline --prefix "$pi_prefix" -- ctxdb-pi configure --site cn --device-code
npm exec --offline --prefix "$pi_prefix" -- ctxdb-pi status
For a project-level npm install, set pi_prefix="$PWD/.pi/npm" from the project root. For a tarball installed with npm install --prefix, use that same prefix.
Change individual settings without signing in again:
npm exec --offline --prefix "$pi_prefix" -- ctxdb-pi configure --auto-capture true --capture-infer true --auto-recall true
npm exec --offline --prefix "$pi_prefix" -- ctxdb-pi configure --user-id my-user --app-id my-project --agent-id pi
npm exec --offline --prefix "$pi_prefix" -- ctxdb-pi configure --reset-app-id
Settings are stored in agents.pi in ~/.ctxdb/ctxdb.json. Credentials are kept alongside it in credentials.json. Set CTXDB_CONFIG_PATH to choose another location. Scope fields also accept their existing environment overrides. Resetting a field restores inheritance. The host session supplies the write-time run ID unless CTXDB_RUN_ID is set. Run ctxdb-pi configure --help for all settings.
Use ContextDB in Pi
Ask Pi to look up a past decision, search a named knowledge base, or list the revisions of a Wiki page. Pi exposes 13 routine tools and a ctxdb tool with 69 advanced commands. Get an argument schema with {"command":"help kb review list"}. Then run it with {"command":"kb review list","args":{"review_status":"pending"}}.
For one knowledge base, use knowledge_base_name or knowledge_base_id. Search across several libraries with one JSON array in knowledge_base_names or knowledge_base_ids. Use page and page_size when listing documents, and pass an ids array for memory batch-delete. Choose memory IDs from ctxdb_memory_list or verify them with ctxdb_memory_get before deleting.
For file upload or replacement, give Pi the local file path. Relative paths are resolved from the Pi session's working directory. Wiki edits require the current page version returned by the page detail tool. Write operations require credentials with write access to the target.
For kb delete, kb documents-batch-delete and kb acl delete, confirm the exact targets before passing yes: true. Check each item and its status when a batch deletion has partial results.
What gets sent to ContextDB
By default, the extension uses your prompt text to recall relevant memory and sends eligible text from completed user and assistant turns to generate new memories. Set --auto-recall false or --auto-capture false to disable either behavior. With capture enabled, --capture-infer false sends eligible messages for verbatim storage instead of fact extraction. Recall is added to the current model request and stays out of the saved Pi conversation.
Pi skips automatic memory capture under a read-only Device Code login and for turns that run a ContextDB write, including writes through the unified ctxdb tool.
Update or remove
pi update --extensions
pi remove npm:@aliyunrds/ctxdb-pi
Run /reload or restart Pi after changing packages. Removing the package removes its extension and Skills from Pi's loaded resources. The ContextDB profile can still be used by the CLI or a later install.
If you used the earlier CLI-installed Pi preview, move its generated extensions/ctxdb.js (or extensions/ctxdb.ts) and the three CLI-installed skills/contextdb-* directories out of the Pi agent directory before switching. Use PI_CODING_AGENT_DIR if set. The npm extension pauses when it detects a generated legacy extension so both versions cannot capture the same turn.