Skip to content

About

No description, website, or topics provided.

Resources

Stars

58 stars

Watchers

0 watching

Forks

Repository files navigation

dsh-layerfs

Install with an agent

Paste the prompt below into a coding agent (Claude Code or similar) on the machine where DeepSeek Harness runs, and give it the three inputs it asks for. It installs this plugin and a LayerFS runtime built from the latest LayerFS main, pins it and proves it matches the remote tip. The same steps by hand are under Install.

Install the **dsh-layerfs** DeepSeek Harness plugin, and a LayerFS runtime built from
the **latest `main`** of Ephemeral-AI-Lab/layerfs, then pin that runtime
and prove that it matches the remote tip.

Inputs (ask me for any that are missing, and don't guess them):

- `WORK`: an absolute folder to put the checkouts in, e.g. `~/src`.
- `DSH_PROFILE`: the DSH profile to install into (normally `web`).
- `DSH_RUNNING`: whether a `dsh web` server is running now, and how it was started
  (its command, cwd and `DSH_HOME`).

## Rules

- Don't modify DeepSeek Harness or LayerFS sources. dsh-layerfs is a DSH plugin, and
  LayerFS is only built here, never edited.
- Don't hand-edit the LayerFS home (found in `~/.layerfs`, or `LAYERFS_ROOT`). Only the DSH
  app (the Runtime → Change dialog or the host API) and the `layerfs` CLI change it.
- Build LayerFS with **`--profile release`** in every step. Both build tools default
  to debug, and a debug daemon makes docker Workspaces several times slower.
- Before restarting a running `dsh web`, or stopping a docker/Lima machine that has
  open Sandboxes or mounted Workspaces, tell me what will be interrupted and wait
  for my OK. Never unmount with `--discard` or remove Store contents.
- Never print the `dsh web` URL token into chat or files.
- Use Node ≥ 24. Every command that waits gets a timeout. Report failures with their
  output and don't retry blindly.

## Steps

1. **Plugin.** In `WORK`:
   ```sh
   git clone https://github.com/Ephemeral-AI-Lab/dsh-layerfs.git
   cd dsh-layerfs && npm install && node scripts/build.mjs
   npx tsc -p tsconfig.json && node --test test/*.test.mjs
   dsh plugin --profile "$DSH_PROFILE" add link:$PWD
   ```
   If dsh-layerfs is already cloned, `git fetch`, switch to `main` (an older clone
   may still be on `layerfs_v2_0_0`) and fast-forward it instead, and merge rather
   than overwrite any local changes. The
   unit tests must all pass.

2. **LayerFS at the tip.** Clone `https://github.com/Ephemeral-AI-Lab/layerfs` into
   `WORK/layerfs` if it's missing, then:
   ```sh
   git -C "$WORK/layerfs" fetch origin main
   TIP=$(git -C "$WORK/layerfs" rev-parse origin/main)
   git -C "$WORK/layerfs" worktree add --detach "$WORK/layerfs-v2-tip" "$TIP"
   ```
   Read `WORK/layerfs-v2-tip/AGENTS.md` and `docs/general/parallel-worktrees.md`.
   Register the worktree with `python3 tools/worktree.py register --worktree
   "$WORK/layerfs-v2-tip" --owner dsh-layerfs-runtime --build-image … --runtime-image
   … --sandbox-image …`, using the LayerFS build, runtime and sandbox images already
   installed on this host (the doc says how to find them). Keep the printed
   `resources.json` path as `R`.

3. **Build the macOS pair and SDK addon** (prints the sealed build folder; keep it as `B`):
   ```sh
   python3 tools/worktree.py build --resources "$R" --platform macos --profile release \
     --features layerfs-cli/postgresql,layerfs-cli/tls,layerfs-daemon/postgresql,layerfs-node/postgresql,layerfs-node/tls
   ```

4. **Build the Linux bundle** into its own folder, so the shared default under
   `~/.cache/layerfs/bundle/` isn't overwritten:
   ```sh
   for s in daemon worker helper seal; do
     python3 tools/linux_bundle.py $s --resources "$R" --profile release --dest "$WORK/layerfs-bundles/$TIP" || break
   done
   ```
   The bundle lands in `<dest>/<version>/linux-<arch>/`, e.g.
   `$WORK/layerfs-bundles/$TIP/2.0.0/linux-aarch64`. Keep that folder (the one holding
   `bundle.json`) as `BUNDLE`.

5. **Prove it's the tip, built as release:**
   ```sh
   "$B/layerfs" --version --json          # commit == $TIP; features include machine, postgresql, tls
   git ls-remote https://github.com/Ephemeral-AI-Lab/layerfs main   # still $TIP
   grep -E '"profile"|"head"' "$BUNDLE/bundle.json"   # "release", head == $TIP
   ```
   If the branch moved during the build, start again from step 2 with the new tip.

6. **SDK for agents** (in the dsh-layerfs checkout):
   ```sh
   node scripts/install-sdk.mjs "$B"      # must say "(macos, release)" and $TIP
   ```

7. **Pin.**
   - **`dsh web` running:** open DSH → the LayerFS sidebar row → Center → Settings →
     Runtime → **Change…**. Give it `$B/layerfs`, `$B/layerfs-daemon` and `BUNDLE`.
     It copies them into `~/.layerfs/runtime/<version>-<sha>/` and pins those copies.
   - **Not running:** start `dsh web` with `DSH_LAYERFS_CLI=$B/layerfs`,
     `DSH_LAYERFS_DAEMON=$B/layerfs-daemon` and `DSH_LAYERFS_BUNDLE=$BUNDLE`.

   A host restart is needed only if the plugin's host code changed since `dsh web`
   started; follow the rule above before restarting.

8. **Machines.** Every docker or Lima machine needs a worker of the new build.
   1. List its Sandboxes.
   2. With my OK, commit (don't discard) any dirty Workspace, then unmount the
      Workspaces and close the Sandboxes.
   3. Stop and start the machine.
   4. If the new CLI refuses with "worker … of another build", pin the previous
      runtime briefly to close and stop, then pin the new one and start.

9. **Verify on the running app:**
   - Runtime status shows commit `$TIP`.
   - A `layerfs file stat` through the agent wrapper
     (`~/.layerfs/dsh/bin/layerfs`, a `#!/bin/bash` script) succeeds against a docker Store.
   - No call is refused as "of another build".
   - Logs shows lines with source `layerfs`.

## Report

Report:
- `$TIP`, `B` and `BUNDLE`;
- the CLI's `--version --json`;
- the bundle's profile and head;
- the SDK install line;
- the pinned runtime id;
- each machine you restarted, and what was open on it;
- the test results;
- anything you skipped and why.

## Updating later

When LayerFS `main` moves, repeat steps 2–9 in the same worktree
(`git -C "$WORK/layerfs-v2-tip" fetch origin main && git -C
"$WORK/layerfs-v2-tip" checkout --detach origin/main`), with a new bundle
folder per commit.

LayerFS for DeepSeek Harness: the Machines and Storage pages of LayerFS Connect and its project session mode — a project session belongs to a LayerFS project and uses the selected local folder as scratch, with native DSH conversation logs and per-turn checkpoints. Normal sessions belong to DSH workspaces and retain stock behavior. One DSH plugin bundle; DSH itself is not modified.

What it adds

Where What
Sidebar → Machines LayerFS machines (the host machine macos-host/linux-host, docker, VMs): state, Sandboxes, Stores, spec, start/stop, add machine; the pinned LayerFS runtime (CLI, daemon, home)
Sidebar → Resources Stores (SQLite, PostgreSQL), projects (import a folder), files, history and commit diffs, branches, Sandboxes, backups to buckets and restore, Store push/pull/move, home checks; a project's Sessions
Sidebar → Projects Every LayerFS project as a card holding its sessions; New session per project, New empty project / Import project… in the header, sessions stored in a project open by id
New Session row Choose No project for a normal workspace session or select a LayerFS project. The local folder chooser remains visible; in project mode that folder is scratch. Choose another project, create an empty project, or import one from a host folder before the first turn
Project sessions Owned and listed by the LayerFS project, with a private execution context. The selected local folder is scratch, even if it is also a DSH workspace. Local shell commands run in scratch; project commands use the managed LayerFS CLI. Scratch is never checkpointed or deleted on session close/forget
Turn end A checkpoint: the Workspace is committed to the branch when the turn changed files
Conversation tabs → Files, History, Sandbox Project sessions only: the project's files on the session branch (with the unsaved count), its history graph, and a map of agents → branches → sandbox workspaces that replays their LayerFS calls. These tabs have no composer. Normal workspace sessions keep only Chat and Trajectory (spec)
Session store Project conversations use unpacked native DSH JSONL under $DSH_HOME/layerfs/project-sessions, with additive layerfs.json annotations. Logs and annotations are archived inside the project for portability; normal logs remain under $DSH_HOME/sessions.
Conversation activity SDK and managed CLI invocation receipts link exact tool-call IDs to confirmed saved versions. workspace.exec has no checkpoint links; automatic saves appear separately. Saved-version labels open immutable project files

DSH's own Fork of a project session also starts its files from the checkpoint at the fork point. Subagents share their parent's project execution context. Changing the owner after work starts requires a new session.

Install

Two parts: this plugin, and a LayerFS runtime built from the tip of LayerFS main. The plugin pins no LayerFS version; it runs the runtime you pin. To have an agent do all of this, give it the prompt in Install with an agent.

1. The plugin (Node ≥ 24, DSH 0.2.2-rc.1)

lib/ is not committed, so build after cloning; the @deepseek-ai packages come from the public npm registry.

git clone https://github.com/Ephemeral-AI-Lab/dsh-layerfs.git
cd dsh-layerfs && npm install && node scripts/build.mjs
dsh plugin --profile web add link:$PWD

2. A LayerFS runtime from the latest main

Build in a LayerFS worktree registered with tools/worktree.py (LayerFS docs/general/parallel-worktrees.md). Pass --profile release everywhere: both build tools default to debug, and a debug daemon makes docker Workspaces several times slower.

git -C /path/to/layerfs fetch origin main
git -C /path/to/layerfs worktree add --detach /path/to/layerfs-v2-tip origin/main
cd /path/to/layerfs-v2-tip
# prints the registration's resources.json ($R); the images are the LayerFS build,
# runtime and sandbox images already installed on this host
python3 tools/worktree.py register --worktree "$PWD" --owner <name> \
  --build-image <build-image> --runtime-image <runtime-image> --sandbox-image <sandbox-image>
# macOS CLI, daemon and Node SDK addon; prints the sealed build folder ($B)
python3 tools/worktree.py build --resources "$R" --platform macos --profile release \
  --features layerfs-cli/postgresql,layerfs-cli/tls,layerfs-daemon/postgresql,layerfs-node/postgresql,layerfs-node/tls
# the Linux bundle docker and Lima machines run; --dest keeps the shared default untouched
for s in daemon worker helper seal; do
  python3 tools/linux_bundle.py $s --resources "$R" --profile release --dest "$HOME/layerfs-bundles/tip" || break
done

Check that it matches the remote tip: the CLI's commit equals the branch head, and the bundle says "profile": "release" with the same head.

"$B/layerfs" --version --json
git ls-remote https://github.com/Ephemeral-AI-Lab/layerfs main
grep -E '"profile"|"head"' "$HOME"/layerfs-bundles/tip/*/linux-*/bundle.json   # <dest>/<version>/linux-<arch>/

3. The Node SDK agents import, then the pin

node scripts/install-sdk.mjs "$B"     # in this checkout; must match the pinned CLI's commit

Pin it on Center → Settings → Runtime → Change… ($B/layerfs, $B/layerfs-daemon and the bundle folder), which installs the CLI, daemon and bundle into the LayerFS home (runtime/<version>-<sha>/) and pins those copies; or start dsh web with DSH_LAYERFS_CLI, DSH_LAYERFS_DAEMON and DSH_LAYERFS_BUNDLE. Then stop and start each docker or Lima machine so its worker is of the new build (close its Sandboxes first; while the new CLI refuses a worker "of another build", pin the old runtime to close and stop, then pin the new one and start). When LayerFS main moves, check out the new tip in the same worktree and repeat steps 2 and 3. The LayerFS home is LayerFS's own, apart from DSH, found in the LayerFS folder (LayerFS's root, ~/.layerfs by default): the folder itself while it holds layerfs.json, else <folder>/home. It holds LayerFS's records, its runtime, the secrets entered in the panel (secret/) and storage jobs and statistics (job/, stat/, named for no client); the bucket list is read from LayerFS's records in the home. This plugin's per-install state (runtime pin, session bindings, scratch) is in <folder>/dsh. See docs/specs/layerfs-folder.md.

Configuration (layerfs row in cordis.patch.yml)

Key Default Meaning
folder the $DSH_HOME/layerfs.json pointer, else ~/.layerfs The LayerFS folder, LayerFS's root (DSH_LAYERFS_FOLDER, then LAYERFS_ROOT, override the pointer); the LayerFS home is found in it
state <folder>/dsh The DSH x LayerFS home: runtime pin, sessions, scratch (DSH_LAYERFS_STATE overrides)
cli, daemon, bundle unset Explicit pins (otherwise saved setting, then env, then the newest runtime installed in the LayerFS home)
cacheHome unset The XDG cache home holding prepared VM OS images (<cacheHome>/layerfs/machine-images, built by LayerFS tools/machine_image.py), passed to every CLI as XDG_CACHE_HOME. Otherwise the saved setting (Machines → LayerFS runtime), then DSH_LAYERFS_CACHE_HOME, then the host's own XDG_CACHE_HOME. Without a prepared image, a new Lima machine boots the stock Ubuntu image (about 30 s instead of about 9 s)
secrets <home>/secret Where bucket keys and PostgreSQL passwords entered in the panel are saved (owner-only files LayerFS reads through file: references); DSH_LAYERFS_SECRETS overrides the default. A bucket keeps the key file it was connected with; only new saves use a changed folder
checkpoints turn off disables per-turn commits
idleMinutes 30 Close an idle session's Sandbox (it reopens on the next turn)

The bundle patch changes the following DSH rows:

Row Change
session-persistence-jsonl Replaced by layerfs-session-persistence: stock JSONL stays the normal-session backend; project ownership routes native unpacked logs to a separate root. Missing project logs can be imported from the project archive
sandbox-policy Replaced by a subclass that keeps selected scratch as the local working root and allows the bound project mount, private LayerFS runtime, and invocation receipts; normal sessions retain stock policy

A project session's step requires its project execution context to be ready: when it cannot be bound, the turn fails with LayerFS's reason. A session without a project placement is simply a plain DSH session — nothing is bound, refused or moved.

Limits

  • Project execution runs on the project's machine. On the host machine (macos-host / linux-host) a host mount is available; remote mounts stay inside their Sandbox. On both, local commands use the selected scratch folder and project commands use "$DSH_LAYERFS_CLI" workspace exec "$DSH_LAYERFS_WS" '<command>' --stream. A generated scratch folder is only a fallback. User-selected folders can be shared with other sessions and are never treated as disposable.
  • CLI tracing covers the managed CLI entry point. Direct calls to another binary are not observed. Unknown command grammar or uncertain results receive no invented checkpoint links. DSH's native tool cards remain unchanged; additive activity is rendered at the conversation turn tail through a public slot.
  • Restore and branch never rewrite history: a restore forks a new branch from the checkpoint and remounts it; the old branch stays.

Development

Specification: Project sessions and conversation handling.

See AGENTS.md. Earlier design notes: ../layerfs-connect/docs/dsh-layerfs/.

About

No description, website, or topics provided.

Resources

Stars

58 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages