Reconcile with hosted features + BACK2BASE_DATA_DIR mount#2
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ports the hosted build's claude-hud HUD. statusline-extra.sh renders the namespace segment only (no auth / power-steering in OSS). migrate_5 repoints existing users' settings.json from statusline.sh to claude-hud. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
New env var bind-mounts <dir>/plans and <dir>/memories at ~/.claude/plans and ~/.claude/memories via a generated compose override, gated on the dir existing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e YAML) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR aligns the OSS runtime with hosted behavior by (1) switching the in-session statusline renderer to a vendored claude-hud build, and (2) adding an optional BACK2BASE_DATA_DIR host bind-mount mechanism for persisting Claude Code plans/memories outside the default state directory.
Changes:
- Add
BACK2BASE_DATA_DIRsupport by generating a docker-compose override to mount<dir>/{plans,memories}into the container. - Replace the legacy
statusline.shwith vendoredclaude-hud, including schema migration + bats coverage and a new--extra-cmdhelper script. - Pin all default profiles to
claude-opus-4-8[1m].
Reviewed changes
Copilot reviewed 11 out of 58 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new BACK2BASE_DATA_DIR persistence option. |
| compose.go | Generates and wires a compose override for plans/memories mounts. |
| compose_test.go | Adds unit tests for BACK2BASE_DATA_DIR override generation and env-file fallback. |
| back2base-container/Dockerfile | Vendors claude-hud into the image and swaps statusline plumbing to statusline-extra.sh. |
| back2base-container/defaults/settings.json | Bumps schema to 5 and sets the default statusLine command to claude-hud. |
| back2base-container/defaults/profiles.json | Pins profile models to claude-opus-4-8[1m]. |
| back2base-container/defaults/env.example | Documents BACK2BASE_DATA_DIR in the env template. |
| back2base-container/lib/migrate-settings.py | Adds schema 5 migration to repoint legacy statusLine to claude-hud. |
| back2base-container/lib/statusline-extra.sh | New --extra-cmd helper emitting the namespace label as JSON. |
| back2base-container/lib/statusline.sh | Removes the legacy hand-rolled statusline renderer. |
| back2base-container/test/migrate-settings.bats | Updates schema expectations and adds migration-5 coverage for statusLine repointing. |
| back2base-container/vendor/claude-hud/.upstream | Records upstream provenance/version and vendoring notes. |
| back2base-container/vendor/claude-hud/LICENSE | Includes upstream MIT license for the vendored HUD. |
| back2base-container/vendor/claude-hud/package.json | Declares the vendored HUD as ESM (runtime-only). |
| back2base-container/vendor/claude-hud/index.js | Vendored HUD entrypoint used by statusLine. |
| back2base-container/vendor/claude-hud/version.js | Vendored Claude Code version detection + caching. |
| back2base-container/vendor/claude-hud/utils/terminal.js | Vendored terminal-width detection helpers. |
| back2base-container/vendor/claude-hud/usage-api.js | Vendored usage API client (HUD). |
| back2base-container/vendor/claude-hud/types.js | Vendored HUD usage helpers. |
| back2base-container/vendor/claude-hud/transcript.js | Vendored transcript parsing + caching for HUD activity. |
| back2base-container/vendor/claude-hud/stdin.js | Vendored stdin parsing + model/context/usage helpers. |
| back2base-container/vendor/claude-hud/speed-tracker.js | Vendored output speed tracking with per-session cache. |
| back2base-container/vendor/claude-hud/memory.js | Vendored memory usage sampling + formatting. |
| back2base-container/vendor/claude-hud/git.js | Vendored git status collection for HUD rendering. |
| back2base-container/vendor/claude-hud/extra-cmd.js | Vendored --extra-cmd execution/sanitization. |
| back2base-container/vendor/claude-hud/external-usage.js | Vendored external usage snapshot support. |
| back2base-container/vendor/claude-hud/effort.js | Vendored effort-level resolution. |
| back2base-container/vendor/claude-hud/debug.js | Vendored debug logging utility. |
| back2base-container/vendor/claude-hud/cost.js | Vendored cost estimation formatting/logic. |
| back2base-container/vendor/claude-hud/context-cache.js | Vendored context-window fallback caching. |
| back2base-container/vendor/claude-hud/constants.js | Vendored constants (e.g., autocompact buffer). |
| back2base-container/vendor/claude-hud/config.js | Vendored HUD config schema + merge/validation. |
| back2base-container/vendor/claude-hud/config-reader.js | Vendored config counting + caching logic. |
| back2base-container/vendor/claude-hud/claude-config-dir.js | Vendored config-dir resolution helpers. |
| back2base-container/vendor/claude-hud/i18n/index.js | Vendored i18n runtime. |
| back2base-container/vendor/claude-hud/i18n/en.js | Vendored English strings. |
| back2base-container/vendor/claude-hud/i18n/zh.js | Vendored Chinese strings. |
| back2base-container/vendor/claude-hud/i18n/types.js | Vendored i18n typings stub. |
| back2base-container/vendor/claude-hud/render/index.js | Vendored main renderer + wrapping logic. |
| back2base-container/vendor/claude-hud/render/colors.js | Vendored ANSI color helpers. |
| back2base-container/vendor/claude-hud/render/agents-line.js | Vendored agents line renderer. |
| back2base-container/vendor/claude-hud/render/tools-line.js | Vendored tools line renderer. |
| back2base-container/vendor/claude-hud/render/todos-line.js | Vendored todos line renderer. |
| back2base-container/vendor/claude-hud/render/session-line.js | Vendored compact session line renderer. |
| back2base-container/vendor/claude-hud/render/width.js | Vendored CJK/ambiguous-width handling. |
| back2base-container/vendor/claude-hud/render/format-reset-time.js | Vendored usage reset-time formatting. |
| back2base-container/vendor/claude-hud/render/lines/index.js | Vendored expanded-layout line exports. |
| back2base-container/vendor/claude-hud/render/lines/identity.js | Vendored context line renderer. |
| back2base-container/vendor/claude-hud/render/lines/project.js | Vendored project/git line renderer. |
| back2base-container/vendor/claude-hud/render/lines/added-dirs.js | Vendored added-dirs line renderer. |
| back2base-container/vendor/claude-hud/render/lines/environment.js | Vendored environment/config-counts line renderer. |
| back2base-container/vendor/claude-hud/render/lines/usage.js | Vendored usage line renderer. |
| back2base-container/vendor/claude-hud/render/lines/memory.js | Vendored memory usage line renderer. |
| back2base-container/vendor/claude-hud/render/lines/session-tokens.js | Vendored session token line renderer. |
| back2base-container/vendor/claude-hud/render/lines/session-time.js | Vendored session time line renderer. |
| back2base-container/vendor/claude-hud/render/lines/prompt-cache.js | Vendored prompt-cache line renderer. |
| back2base-container/vendor/claude-hud/render/lines/cost.js | Vendored cost line renderer. |
| back2base-container/vendor/claude-hud/render/lines/label-align.js | Vendored label alignment helpers for expanded layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| label="" | ||
| if [ -n "${MEMORY_NAMESPACE:-}" ]; then | ||
| label="ns:${MEMORY_NAMESPACE}" | ||
| fi | ||
|
|
||
| # claude-hud truncates past 50 chars anyway; cap here to keep this self-contained. | ||
| if [ "${#label}" -gt 50 ]; then | ||
| label="${label:0:49}…" | ||
| fi | ||
|
|
||
| label=${label//\\/\\\\} | ||
| label=${label//\"/\\\"} | ||
| printf '{"label":"%s"}\n' "$label" |
There was a problem hiding this comment.
Fixed in 13cc74a. statusline-extra.sh now strips control chars from the namespace (ns=$(printf '%s' "$MEMORY_NAMESPACE" | tr -d '[:cntrl:]')) and only emits the ns: label when the sanitized value is non-empty. Verified a namespace with an embedded newline + control char now yields valid single-line JSON. Same fix applied to the hosted build's statusline-extra.sh.
Per-half %q quoting produced invalid compose YAML; the macOS managed-policy host path also contains a space, so bare %s won't do either. Quote the whole source:target:ro item as one YAML scalar. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Change the container bind-mount targets for BACK2BASE_DATA_DIR from
/home/node/.claude/{plans,memories} to /home/node/.back2base/{plans,memories}.
Update the stderr message and doc comment to match. Update the test assertions
to the new container paths; all other assertions (rw, no-env, no-quotes, host
subdir creation) are unchanged.
Update env.example and README to document the corrected mount paths and note
that the memory tool reads/writes the mounted folder directly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When BACK2BASE_DATA_DIR has bind-mounted ~/.back2base/memories, use it as the canonical memory store without wiping it (persistence is the intent). Symlink Claude Code's cwd-derived auto-memory path to the mounted dir exactly as the existing MEMORY_NAMESPACE path does, so Claude Code reads and writes it. Also mkdir -p ~/.back2base/plans and export BACK2BASE_PLANS_DIR when the mount is active. The mounted-case branch fires even when MEMORY_NAMESPACE is empty (mount is namespace-independent). When no mount is present, existing MEMORY_NAMESPACE behavior (wipe-on-start) is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…s (de-dup) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hoists the inline memory-path alignment into lib/memory-align.sh (behavior unchanged) so it's unit-testable, and adds test/memory-align.bats covering the ~/.back2base/memories symlink, no-wipe persistence, plans export, real-dir migration, and the namespaced fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
OSS deliberately has no back2base.net cloud endpoints in init-firewall.sh's allow-list; this assertion was carried over from the hosted build during the fork. Removing it makes the macOS suite deterministically green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a macOS bats job to CI (runs the container test suite from the repo root) so the critical shell tests gate every PR. Hardens the prelaunch-overview completion tests against load-induced flakes by decoupling them from the timeout (generous OVERVIEW_TIMEOUT_SECS=60; the timeout test overrides to 1s with a far-longer stub). Verified 0 failures across repeated runs at load avg 90+. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…st hygiene) - statusline-extra.sh: strip control chars from MEMORY_NAMESPACE so a pathological namespace can't emit invalid JSON / leak terminal sequences. - writeDataDirOverride: reject BACK2BASE_DATA_DIR containing CR/LF before writing the override (a raw newline would corrupt/inject the YAML). - compose_test.go: silence stderr during the test; cover the newline-reject path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
claude-opus-4-8[1m]across all 7 profiles.statusline.sh. The--extra-cmdhelper renders the namespace segment only (no auth/power-steering — neither exists in OSS).settings.json→ schema 5;migrate_5repoints existing users from the legacy script, with bats coverage.BACK2BASE_DATA_DIR: bind-mounts<dir>/plansand<dir>/memories(host subfolders) at~/.back2base/plansand~/.back2base/memoriesin the container, via a generated compose override gated on the dir existing. Volumes-only (OSS has no cloud sync).~/.back2base/memoriesbecomes the canonical memory store and Claude Code's auto-memory path is symlinked to it;BACK2BASE_PLANS_DIRis exported. The memory-path alignment logic is shared (single block) across the mounted and namespaced branches.Behavior note
When
BACK2BASE_DATA_DIRis set, the mounted memory dir is treated as persistent and is not wiped at session start (the usual namespaced-memory wipe only applies when no mount is present). If bothBACK2BASE_DATA_DIRandMEMORY_NAMESPACEare set, the mount wins — an intentional priority, but a behavior change for anyone who had both.Test Plan
go build ./... && go test ./... && go vet ./...greendocker compose config(.back2basetargets)BACK2BASE_DATA_DIR=~/b2b-data, confirm memories persist across sessions and claude-hud renders🤖 Generated with Claude Code