community
This directory contains a thin WorkBuddy integration backed by a running PowerContext server. It does not embed storage or start the server. WorkBuddy keeps the user interface and agent orchestration while PowerContext provides external storage, retrieval, context preparation, Memory, and Handoff lifecycle operations.
The integration has three capability layers:
- a
UserPromptSubmithook asks the Runtime to prepare one final, bounded context value before WorkBuddy analyzes the prompt, then independently captures the prompt as Source evidence; - Streamable HTTP MCP at
http://127.0.0.1:8000/mcpgives WorkBuddy explicit Memory and work-continuity tools (search_memory,list_memory_entries,handoff_current_work,commit_handoff, and so on); - the
powercontext-project-contextSkill turns an imperative such as交接,交接当前工作, orhandoff this workinto one durable, committed Handoff, and restores project memory for continued work.
The hooks driver is pure Python 3.11+ standard library and needs no extra
dependencies. WorkBuddy support ships with a powercontext setup workbuddy
CLI installer; the manual steps below remain available as a fallback.
Install the hooks, MCP server, and Skill from a local checkout or a GitHub source in one step:
powercontext setup workbuddy --source oceanbase/powercontext --ref masterFor a local checkout, point --source at the repository root or the plugin
directory:
powercontext setup workbuddy --source /path/to/powercontextThe installer copies the hook driver, its settings modules, and the scope
resolver into ~/.workbuddy/hooks, merges the UserPromptSubmit hook into
~/.workbuddy/settings.json, registers the powercontext server in
~/.workbuddy/mcp.json, and installs the powercontext-project-context Skill under
~/.workbuddy/skills. Existing settings and other MCP servers are preserved,
and the Skill's command placeholders are resolved automatically.
Verify the result with powercontext doctor workbuddy.
Manual installation (alternative)
These steps copy the plugin into the WorkBuddy user directory, register the hook and the MCP server, install the Skill, and verify the integration.
WorkBuddy loads hook commands from its user-level hooks directory. Copy the
hook driver, its settings modules, and the scope resolver there. This guide
uses ~/.workbuddy/hooks as the hooks directory; replace it with your own
location and use the same value wherever <WORKBUDDY_HOOKS_DIR> appears below.
Use the Python executable that can import PowerContext wherever
<POWERCONTEXT_PYTHON> appears below.
PLUGIN=integrations/workbuddy/plugins/powercontext
WORKBUDDY_HOOKS_DIR="${WORKBUDDY_HOOKS_DIR:-$HOME/.workbuddy/hooks}"
mkdir -p "$WORKBUDDY_HOOKS_DIR"
cp "$PLUGIN"/hooks/workbuddy_powercontext_hook.py \
"$PLUGIN"/hooks/workbuddy_settings.py \
"$PLUGIN"/hooks/powercontext_client_config.py \
"$PLUGIN"/hooks/prepared_context.py \
"$WORKBUDDY_HOOKS_DIR"/
cp "$PLUGIN/scripts/workspace_scope.py" \
"$WORKBUDDY_HOOKS_DIR/powercontext_scope_binding.py"The resulting layout is:
<WORKBUDDY_HOOKS_DIR>/
workbuddy_powercontext_hook.py
workbuddy_settings.py
powercontext_client_config.py
prepared_context.py
powercontext_scope_binding.py
Merge the following hooks block into ~/.workbuddy/settings.json. Replace
<POWERCONTEXT_PYTHON> with the Python executable that can import PowerContext,
and <WORKBUDDY_HOOKS_DIR> with the absolute path of your hooks directory (for
example /Users/<you>/.workbuddy/hooks). The command string cannot expand
environment variables, so literal paths are required here.
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "\"<POWERCONTEXT_PYTHON>\" \"<WORKBUDDY_HOOKS_DIR>/workbuddy_powercontext_hook.py\"",
"timeout": 30,
"statusMessage": "Syncing PowerContext"
}
]
}
]
}
}A complete sample is included at
plugins/powercontext/hooks/hooks.workbuddy.json.
Merge the following mcpServers entry into ~/.workbuddy/mcp.json:
{
"mcpServers": {
"powercontext": {
"type": "http",
"url": "${POWERCONTEXT_WORKBUDDY_SERVER_URL:-http://127.0.0.1:8000}/mcp",
"headers": {
"Authorization": "${POWERCONTEXT_WORKBUDDY_AUTHORIZATION:-}"
},
"description": "PowerContext agent memory & handoff MCP server (local service on port 8000)"
}
}
}Copy the powercontext-project-context Skill into the WorkBuddy skills directory:
mkdir -p ~/.workbuddy/skills
cp -R integrations/workbuddy/plugins/powercontext/skills/powercontext-project-context \
~/.workbuddy/skills/
cat > ~/.workbuddy/skills/powercontext-project-context/.powercontext.json <<'EOF'
{"schema": 1, "owner": "powercontext", "integration": "workbuddy"}
EOFThen open ~/.workbuddy/skills/powercontext-project-context/SKILL.md. Replace
${POWERCONTEXT_PYTHON} with a shell-safe Python executable argument and
${POWERCONTEXT_SCOPE_BINDING_SCRIPT} with a shell-safe complete path to
<WORKBUDDY_HOOKS_DIR>/powercontext_scope_binding.py.
Keep the PowerContext Server running in one terminal:
powercontext server runRestart WorkBuddy so it picks up the new hook, MCP server, and Skill. Send any
prompt; the hook reports Syncing PowerContext while it runs. To verify the
recall contract directly, inspect the Server logs or run:
powercontext doctorThe MCP tools (search_memory and the Handoff tools) become available in the
WorkBuddy session when the Server is reachable.
The hook uses http://127.0.0.1:8000 by default. Environment variables
override the defaults; restart WorkBuddy after changing them.
| Variable | Purpose |
|---|---|
POWERCONTEXT_WORKBUDDY_SERVER_URL |
PowerContext server URL (default http://127.0.0.1:8000). |
POWERCONTEXT_WORKBUDDY_ALLOW_INSECURE_HTTP |
Explicit non-loopback HTTP consent; overrides common and saved consent, including false. |
POWERCONTEXT_WORKBUDDY_AUTHORIZATION |
Complete authorization header, e.g. Bearer <token> |
POWERCONTEXT_WORKBUDDY_SCOPE_ID |
Explicit server-owned Scope ID |
POWERCONTEXT_WORKBUDDY_CAPTURE_PROMPTS |
Capture user prompts as Sources (default true) |
POWERCONTEXT_WORKBUDDY_FLUSH_ON_CAPTURE |
Flush until the captured Source is processed (testing only, default false) |
POWERCONTEXT_WORKBUDDY_REQUEST_TIMEOUT_SECONDS |
Per-request HTTP timeout (default 3.0) |
POWERCONTEXT_WORKBUDDY_HTTP_BUDGET_SECONDS |
Shared wall-clock budget for one prompt (default 6.0) |
POWERCONTEXT_WORKBUDDY_FLUSH_MAX_CALLS |
Maximum flush calls (default 4) |
The hook selects its URL from POWERCONTEXT_WORKBUDDY_SERVER_URL,
POWERCONTEXT_CLIENT_SERVER_URL, saved settings, then the loopback default.
It removes a final /mcp suffix and rejects credentials, query strings, and
fragments. HTTPS and loopback HTTP work by default. To persist a non-loopback
HTTP endpoint and configure the native MCP URL consistently:
powercontext setup workbuddy --server-url http://memory.example:8000 --allow-insecure-httpNonsecret settings are stored under hosts.workbuddy in
~/.config/powercontext/clients.json; POWERCONTEXT_CLIENT_CONFIG_FILE overrides
the location. Saved consent applies only to the same normalized endpoint.
An explicit settings constructor argument overrides the host environment,
then POWERCONTEXT_CLIENT_ALLOW_INSECURE_HTTP, then saved consent. Boolean
misspellings are rejected, and explicit false disables inherited consent.
The guard applies to the PowerContext hook; WorkBuddy owns native MCP transport policy. HTTP sends request content and authorization headers without encryption. HTTPS certificate verification remains enabled.
- Recall calls
POST /v1/context/prepareonce per prompt, requests an 8000-byte total budget, strictly validatespowercontext.prepared-context.v1, and injects the returned content unchanged as untrusted history. - The query is a reduction of the joined prompt. WorkBuddy submits every user
message of the session joined into one prompt, so Recall reads the most recent
<user_query>element the host wrapped and falls back to the bounded prompt when no element carries the host's wrapper boundaries. An opening tag is a candidate only where it starts a line and its own closing tag ends at a message boundary; a pair the turn quotes itself is enclosed by the turn, which is then the element read. A reduction is reported on stderr as aquery_reductionevent. - Capture independently posts the prompt to
POST /v1/sources/contentwith stable, content-addressedsource_idvalues. - Recall, capture, and flush fail independently. An unavailable Server never blocks normal WorkBuddy work.
- For an empty result, authentication failure, version mismatch, unavailable Server, or invalid response, the hook writes one diagnostic JSON line to stderr. Diagnostics carry status codes, byte and character counts, and which query source produced them—never the query, scope, content, citation, response body, or authorization value.
Optional local bearer authentication uses POWERCONTEXT_WORKBUDDY_AUTHORIZATION,
whose value must be a complete Bearer <token> header. .mcp.json stores only
an environment-variable template for the Authorization value; WorkBuddy expands
it from the environment, and the hook reads the same variable. Missing or empty
values preserve the default unauthenticated flow. Never put the token itself in
.mcp.json or the Server URL.
- Remove the
UserPromptSubmitPowerContext entry from~/.workbuddy/settings.json. - Remove the
powercontextentry from~/.workbuddy/mcp.json. - Remove the hook files and the scope resolver from
<WORKBUDDY_HOOKS_DIR>. - Remove
~/.workbuddy/skills/powercontext-project-context. - Optionally stop the Server and delete its local data directory.