just-git 1.2.7 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@ await bash.exec("echo 'hello' > README.md");
31
31
  await bash.exec("git add . && git commit -m 'initial commit'");
32
32
  ```
33
33
 
34
- Pass a `Git` instance into [just-bash](https://github.com/vercel-labs/just-bash) as a custom command and you get pipes, redirects, `&&` chaining, and the full shell environment alongside git. For standalone use without just-bash, `MemoryFileSystem` provides a minimal in-memory filesystem and `git.exec` accepts a command string with basic quote-aware splitting:
34
+ Pass a `Git` instance into [just-bash](https://github.com/vercel-labs/just-bash) as a custom command and you get pipes, redirects, `&&` chaining, and the full shell environment alongside git. For standalone use without just-bash, `MemoryFileSystem` provides a minimal in-memory filesystem and `git.exec` accepts a single git command string (no shell features):
35
35
 
36
36
  ```ts
37
37
  import { createGit, MemoryFileSystem } from "just-git";
@@ -39,6 +39,7 @@ import { createGit, MemoryFileSystem } from "just-git";
39
39
  const fs = new MemoryFileSystem();
40
40
  const git = createGit({
41
41
  fs,
42
+ cwd: "/repo",
42
43
  identity: { name: "Alice", email: "alice@example.com" },
43
44
  credentials: (url) => ({ type: "bearer", token: process.env.GITHUB_TOKEN! }),
44
45
  hooks: {
@@ -49,11 +50,13 @@ const git = createGit({
49
50
  });
50
51
 
51
52
  await git.exec("git init");
52
- await fs.writeFile("/README.md", "# Hello\n");
53
+ await fs.writeFile("/repo/README.md", "# Hello\n");
53
54
  await git.exec("git add .");
54
55
  await git.exec('git commit -m "initial commit"');
55
56
  ```
56
57
 
58
+ Both `fs` and `cwd` can be set once in `createGit` and overridden per-call. `cwd` defaults to `"/"`. Set it to the repo root so every `exec` call finds `.git` automatically.
59
+
57
60
  `createGit` also supports [command restrictions, network policies, and config overrides](docs/CLIENT.md#options) for sandboxing, a [lifecycle hooks API](docs/CLIENT.md#hooks) covering pre-commit secret scanning to push gating, and [cross-VFS remote resolution](docs/CLIENT.md#multi-agent-collaboration) for multi-agent collaboration. See [CLIENT.md](docs/CLIENT.md) for the full reference.
58
61
 
59
62
  ### Server
@@ -131,16 +134,4 @@ When backed by a real filesystem (e.g. just-bash `ReadWriteFs`), interoperable w
131
134
 
132
135
  ## Examples
133
136
 
134
- Runnable examples in [`examples/`](examples/):
135
-
136
- | File | What it demonstrates |
137
- | --------------------------------------------------------------- | -------------------------------------------------------------------- |
138
- | [`usage.ts`](examples/usage.ts) | Identity, disabled commands, hooks, compose, full sandbox setup |
139
- | [`multi-agent.ts`](examples/multi-agent.ts) | Cross-VFS collaboration with clone/push/pull between isolated agents |
140
- | [`server.ts`](examples/server.ts) | VFS-backed Smart HTTP server with virtual client clone and push |
141
- | [`sqlite-server.ts`](examples/sqlite-server.ts) | SQLite-backed server with auto-creating repos, works with real `git` |
142
- | [`node-server.mjs`](examples/node-server.mjs) | Node.js HTTP server with SQLite + auth via `better-sqlite3` |
143
- | [`platform-server.ts`](examples/platform-server.ts) | GitHub-like PR workflows: create, merge, close via REST API |
144
- | [`agent-remote-workflow.ts`](examples/agent-remote-workflow.ts) | Clone from GitHub, work in sandbox, push back (requires token) |
145
-
146
- Run any example with `bun examples/<file>`.
137
+ Runnable examples in [`examples/`](examples/) — identity, hooks, multi-agent collaboration, Smart HTTP servers, and more. Run any with `bun examples/<file>`.
package/dist/index.d.ts CHANGED
@@ -38,6 +38,12 @@ interface GitOptions {
38
38
  * (just-bash always provides its own filesystem).
39
39
  */
40
40
  fs?: FileSystem;
41
+ /**
42
+ * Default working directory for {@link Git.exec}. Defaults to `"/"`.
43
+ * Per-call `cwd` in {@link ExecContext} overrides this.
44
+ * Ignored by `execute` (just-bash provides its own cwd).
45
+ */
46
+ cwd?: string;
41
47
  hooks?: GitHooks;
42
48
  credentials?: CredentialProvider;
43
49
  identity?: IdentityOverride;
@@ -72,7 +78,7 @@ interface GitOptions {
72
78
  interface ExecContext {
73
79
  /** Filesystem to operate on. Falls back to the `fs` set in {@link GitOptions}. */
74
80
  fs?: FileSystem;
75
- /** Working directory. Defaults to `"/"`. */
81
+ /** Working directory. Falls back to the `cwd` set in {@link GitOptions}, then `"/"`. */
76
82
  cwd?: string;
77
83
  env?: Record<string, string>;
78
84
  stdin?: string;
@@ -92,6 +98,7 @@ interface ExecContext {
92
98
  declare class Git {
93
99
  readonly name = "git";
94
100
  private defaultFs;
101
+ private defaultCwd;
95
102
  private blocked;
96
103
  private hooks;
97
104
  private inner;