graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Task workspaces are graff-native, not another product's config
justrachb6cf3ceaca5d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e60de370..553f3971 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,7 +14,7 @@ current is part of cutting a release.- Ctrl-V screenshot paste is not killed by a leftover Esc (`clipboard helper unavailable`).- Desktop auto-update accepts 4-part hotfix versions (`0.0.302.3`), not only `0.0.xxx`.-- Task workspaces copy gitignored files (`.worktreeinclude` or Conductor `file_include_globs`) and run setup/run/archive scripts (ADR 0153). Desktop Tools: New task workspace, Run, Archive.+- Task workspaces copy gitignored files (`.worktreeinclude` or `.graff/workspace.toml` `include`) and run setup/run/archive scripts (ADR 0153). Desktop Tools: New task workspace, Run, Archive.## v0.0.302.2diff --git a/assets/skills/workspace.md b/assets/skills/workspace.mdindex e7c566c4..cc97dda4 100644--- a/assets/skills/workspace.md+++ b/assets/skills/workspace.md@@ -28,8 +28,8 @@ A new independent task is `workspace action=create`.(default `origin/main` after fetch). Independent work gets its own tree;same-branch collaboration stays in one workspace (`isolation: shared_cwd`).Create copies gitignored files matching `.worktreeinclude` (else- `file_include_globs`, else `.env*`) from the main checkout, then runs- `scripts.setup` from `.graff/workspace.toml` or `.conductor/settings.toml`.+ `include` in `.graff/workspace.toml`, else `.env*`) from the main checkout,+ then runs `scripts.setup` from `.graff/workspace.toml`.`graff worktree run <name>` is the run script; `archive` runs `scripts.archive`before removing a clean duplicate (ADR 0153). Desktop Tools: New task workspace, Run, Archive.4. If the match is ambiguous, name more of the path. Do not guess.diff --git a/docs/adr/0153-task-workspaces-copy-and-scripts.md b/docs/adr/0153-task-workspaces-copy-and-scripts.mdindex 9bd6a16a..e95956d9 100644--- a/docs/adr/0153-task-workspaces-copy-and-scripts.md+++ b/docs/adr/0153-task-workspaces-copy-and-scripts.md@@ -4,33 +4,28 @@ Status: accepted 2026-09-21## Context-Raw `git worktree add` checks out tracked files only. Coding-agent workspaces-need the rest of a local project: `.env.local`, a one-time `pnpm install`, a-dev server, and teardown that is not "the agent finished a turn."--Conductor documents this as `.worktreeinclude` / Files to copy, plus-`scripts.setup` / `scripts.run` / `scripts.archive` in-`.conductor/settings.toml`. Finish is still not archive (ADR 0147): dirty or-unique-commit trees stay.+Raw `git worktree add` checks out tracked files only. A task workspace needs+the rest of a local project: `.env.local`, a one-time install, a dev server,+and teardown that is not "the agent finished a turn." Finish is still not+archive (ADR 0147): dirty or unique-commit trees stay.## Decision- After `graff worktree create` / `workspace action=create` / auto-isolate,copy gitignored files from the **main checkout** that match `.worktreeinclude`- (else `file_include_globs` in `.graff/workspace.toml` or- `.conductor/settings.toml`, else `.env*`). Tracked files are already there.- Untracked files that Git does not ignore are not copied.-- Then run `scripts.setup` from `.graff/workspace.toml`, falling back to- `.conductor/settings.toml`. Setup failure keeps the workspace.+ (else `include` in `.graff/workspace.toml`, else `.env*`). Tracked files are+ already there. Untracked files that Git does not ignore are not copied.+- Then run `scripts.setup` from `.graff/workspace.toml`. Setup failure keeps+ the workspace.- `graff worktree run <name>` runs `scripts.run` from that checkout.- `graff worktree archive` runs `scripts.archive` only when the tree isactually going to be removed.-- Scripts see `GRAFF_WORKSPACE_*` and Conductor aliases- (`CONDUCTOR_WORKSPACE_NAME`, `CONDUCTOR_WORKSPACE_PATH`, `CONDUCTOR_ROOT_PATH`,- `CONDUCTOR_PORT`) so an existing Conductor project file works.+- Scripts see `GRAFF_WORKSPACE_NAME`, `GRAFF_WORKSPACE_PATH`, `GRAFF_ROOT_PATH`,+ and `GRAFF_WORKSPACE_PORT`. Graff does not read another product's settings+ file or export another product's environment names.## Consequences-A Conductor-configured repo is usable as a graff task workspace without a-second clone. Desktop review/merge-back UX stays #1124. Stale-tree reaping-stays #1118. Finish still does not archive.+A repo opts in with `.graff/workspace.toml` and optional `.worktreeinclude`.+Desktop review/merge-back UX stays #1124. Stale-tree reaping stays #1118.+Finish still does not archive.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 57210333..15d49bfd 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -174,7 +174,7 @@ record only when you need the evidence or the edge cases.| [0150](0150-subagent-briefs-are-structured.md) | Child briefs are headed sections plus a harness environment header; the judge stays a bare prompt. || [0151](0151-zai-coding-plan-login.md) | Z.AI Coding Plan is a `sub_login` like Kimi/xAI: `graff login zai` uses ZCode's public CLI OAuth broker, then provisions a Graff-named API key onto `/api/coding/paas/v4`. || [0152](0152-persistent-shells-snapshot-once.md) | Persistent shells snapshot immediately (`wait_ms` ignored) and stay on `/jobs`; do not poll. Finite jobs still wait until exit (ADR 0010). |-| [0153](0153-task-workspaces-copy-and-scripts.md) | Task workspaces copy gitignored include files from the main checkout and run setup/run/archive scripts (Conductor-shaped `.worktreeinclude` / `.conductor/settings.toml`). Finish is still not archive. |+| [0153](0153-task-workspaces-copy-and-scripts.md) | Task workspaces copy gitignored include files from the main checkout and run setup/run/archive scripts from `.graff/workspace.toml`. Finish is still not archive. |## When to write onediff --git a/src/workspace_prepare.zig b/src/workspace_prepare.zigindex 74c4f4e7..5590a390 100644--- a/src/workspace_prepare.zig+++ b/src/workspace_prepare.zig@@ -1,6 +1,5 @@//! After minting a task worktree: copy selected gitignored files and run-//! project scripts. Same shape as Conductor (`.worktreeinclude`, setup/run/-//! archive) without taking Conductor's product surface.+//! project scripts from `.graff/workspace.toml`.const std = @import("std");const Io = std.Io;@@ -49,27 +48,20 @@ pub fn parseScripts(text: []const u8) Scripts {}pub fn parseIncludeGlobs(text: []const u8) ?[]const u8 {- return tomlString(text, "file_include_globs");+ return tomlString(text, "include") orelse tomlString(text, "file_include_globs");}-/// `.worktreeinclude` wins; else `file_include_globs`; else `.env*`.+/// `.worktreeinclude` wins; else `include` in `.graff/workspace.toml`; else `.env*`.pub fn includeText(arena: Allocator, io: Io, root: []const u8) []const u8 {if (readOptional(io, arena, root, ".worktreeinclude")) |t| return t;if (readOptional(io, arena, root, ".graff/workspace.toml")) |t| {if (parseIncludeGlobs(t)) |g| return g;}- if (readOptional(io, arena, root, ".conductor/settings.toml")) |t| {- if (parseIncludeGlobs(t)) |g| return g;- }return ".env*\n.env\n";}pub fn loadScripts(arena: Allocator, io: Io, root: []const u8) Scripts {- if (readOptional(io, arena, root, ".graff/workspace.toml")) |t| {- const s = parseScripts(t);- if (s.setup.len + s.run.len + s.archive.len > 0) return s;- }- if (readOptional(io, arena, root, ".conductor/settings.toml")) |t| return parseScripts(t);+ if (readOptional(io, arena, root, ".graff/workspace.toml")) |t| return parseScripts(t);return .{};}@@ -223,13 +215,9 @@ fn runScript(const n1 = std.fmt.allocPrint(arena, "GRAFF_WORKSPACE_NAME={s}", .{name}) catch return false;const n2 = std.fmt.allocPrint(arena, "GRAFF_WORKSPACE_PATH={s}", .{dest}) catch return false;const n3 = std.fmt.allocPrint(arena, "GRAFF_ROOT_PATH={s}", .{root}) catch return false;- const n4 = std.fmt.allocPrint(arena, "CONDUCTOR_WORKSPACE_NAME={s}", .{name}) catch return false;- const n5 = std.fmt.allocPrint(arena, "CONDUCTOR_WORKSPACE_PATH={s}", .{dest}) catch return false;- const n6 = std.fmt.allocPrint(arena, "CONDUCTOR_ROOT_PATH={s}", .{root}) catch return false;- const n7 = std.fmt.allocPrint(arena, "CONDUCTOR_PORT={d}", .{port}) catch return false;- const n8 = std.fmt.allocPrint(arena, "GRAFF_WORKSPACE_PORT={d}", .{port}) catch return false;+ const n4 = std.fmt.allocPrint(arena, "GRAFF_WORKSPACE_PORT={d}", .{port}) catch return false;const r = runCappedWithOptions(gpa, io, &.{- "env", n1, n2, n3, n4, n5, n6, n7, n8, "/bin/sh", "-c", cmd,+ "env", n1, n2, n3, n4, "/bin/sh", "-c", cmd,}, 64 * 1024, 16 * 1024, deadline_ms, .{ .cwd = .{ .path = dest } }) catch return false;defer {gpa.free(r.stdout);diff --git a/src/workspace_prepare_tests.zig b/src/workspace_prepare_tests.zigindex eb33fc10..e2a27433 100644--- a/src/workspace_prepare_tests.zig+++ b/src/workspace_prepare_tests.zig@@ -9,19 +9,19 @@ const process_runner = @import("process_runner.zig");const runCapped = process_runner.runCapped;const ranOk = process_runner.ranOk;-test "parseScripts reads Conductor and graff toml" {+test "parseScripts reads graff workspace toml" {const s = prep.parseScripts(\\[scripts]\\setup = "pnpm install"- \\run = "pnpm dev --port $CONDUCTOR_PORT"+ \\run = "pnpm dev --port $GRAFF_WORKSPACE_PORT"\\archive = "./script/workspace-archive.sh"\\);try std.testing.expectEqualStrings("pnpm install", s.setup);- try std.testing.expectEqualStrings("pnpm dev --port $CONDUCTOR_PORT", s.run);+ try std.testing.expectEqualStrings("pnpm dev --port $GRAFF_WORKSPACE_PORT", s.run);try std.testing.expectEqualStrings("./script/workspace-archive.sh", s.archive);const globs = prep.parseIncludeGlobs(- \\file_include_globs = """+ \\include = """\\.env.local\\certs/local/**\\"""@@ -32,9 +32,9 @@ test "parseScripts reads Conductor and graff toml" {}test "workspacePort is stable per name and stays in 40000-49999" {- const a = prep.workspacePort("tokyo");- const b = prep.workspacePort("tokyo");- const c = prep.workspacePort("warsaw");+ const a = prep.workspacePort("task-a");+ const b = prep.workspacePort("task-a");+ const c = prep.workspacePort("task-b");try std.testing.expectEqual(a, b);try std.testing.expect(a != c);try std.testing.expect(a >= 40_000 and a < 50_000);@@ -72,7 +72,7 @@ test "create copies gitignored include files and runs setup" {var arena = std.heap.ArenaAllocator.init(a);defer arena.deinit();const ar = arena.allocator();- const one = try ws.create(a, io, ar, .{ .slug = "tokyo", .cwd = root });+ const one = try ws.create(a, io, ar, .{ .slug = "task-a", .cwd = root });try std.testing.expect(one.copied >= 1);try std.testing.expect(one.setup_ran);try std.testing.expect(one.setup_ok);diff --git a/src/worktree_cmd.zig b/src/worktree_cmd.zigindex 677a4c9f..b52527f2 100644--- a/src/worktree_cmd.zig+++ b/src/worktree_cmd.zig@@ -199,7 +199,7 @@ pub fn worktreeCommand(gpa: Allocator, io: Io, arena: Allocator, args: []const [break :blk if (n > 0) try arena.dupe(u8, path_buf[0..n]) else dest;};if (!@import("workspace_prepare.zig").runNamed(gpa, io, arena, ".", path, name)) {- try out.writeAll("✗ no run script — add scripts.run to .graff/workspace.toml or .conductor/settings.toml\n");+ try out.writeAll("✗ no run script — add scripts.run to .graff/workspace.toml\n");return;}try out.print("✓ run finished in {s}\n", .{path});