Bash

PgFileSystem implements the just-bash IFileSystem interface. Pass it directly to get a complete bash environment: 60+ commands, pipes, redirects, variables, loops, all persisted in PostgreSQL.

Setup

npm install just-bash
import { Bash } from "just-bash"
import { PgFileSystem } from "bash-gres/postgres"

const fs = new PgFileSystem({ db: sql, workspaceId: "workspace-1" })
const bash = new Bash({ fs })

Basic Commands

await bash.exec("mkdir -p /project/src")
await bash.exec('echo "hello world" > /project/src/index.ts')

const result = await bash.exec("cat /project/src/index.ts")
// { exitCode: 0, stdout: "hello world\n", stderr: "" }

semgrep: Semantic Grep

The semgrep custom command puts chunk search inside the session. It dispatches on the handle: hybrid search when the filesystem has an embed option, BM25-only otherwise. Output is grep-style — one hit per line, exit 1 when nothing matches — and the line ranges hydrate with the session's own tools.

import { createSemgrepCommand } from "bash-gres/just-bash"

const bash = new Bash({ fs, customCommands: [createSemgrepCommand({ fs })] })

await bash.exec('semgrep -k 3 "delivery options" /docs')
// /docs/shipping.md:12-34  [0.0323]  Shipping > Costs — Shipping is free over…

await bash.exec("sed -n 12,34p /docs/shipping.md") // hydrate the hit

Usage: semgrep [-k N] "query" [path] -k caps the hits (default 5), the optional path scopes the search and resolves against the session's working directory.

For the full list of commands, pipes, redirects, variables, and more, see the just-bash documentation.