Skip to content

feat: make workspace path configurable via CLI flag - #98

Merged
pavelanni merged 3 commits into
mainfrom
feature/configurable-workspace-path
Jul 1, 2026
Merged

pavelanni merged 3 commits into
mainfrom
feature/configurable-workspace-path

Conversation

@pavelanni

@pavelanni pavelanni commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add --workspace flag and DOCSCLAW_WORKSPACE env var to the serve command
  • Priority: agent-config.yaml tools.workspace > --workspace flag/env > default (/workspace)
  • Unify workspace resolution into a single resolveWorkspace function, replacing two inline resolution blocks

Closes #96

Test plan

  • Unit test: config file value takes precedence over flag
  • Unit test: flag value used when config is empty
  • Unit test: default /workspace when both are empty
  • golangci-lint run ./internal/cmd/... — zero issues
  • make test — no regressions

Note: make lint has pre-existing failures in demo/batch/ and internal/logger/ — unrelated to this change.

Assisted-By: Claude (Anthropic AI) [email protected]

Summary by CodeRabbit

  • New Features
    • Added a configurable workspace path for the service, with support for a command-line option and environment-based fallback.
  • Bug Fixes
    • Improved workspace selection precedence to consistently use the config file first, then the command-line/environment value, and finally the default path (whitespace-only config is ignored).
  • Documentation
    • Clarified workspace precedence, access limits, and that workspace context loads in both phases.
  • Tests
    • Added coverage for workspace precedence and whitespace-handling behavior.
  • Chores
    • Updated deployment manifest comments for an optional fallback workspace variable.

Add --workspace flag and DOCSCLAW_WORKSPACE env var to the serve
command, allowing operators to override the workspace directory
without editing the ConfigMap. Priority: agent-config.yaml >
flag/env > default (/workspace).

Unifies workspace resolution into a single resolveWorkspace
function, replacing two ad-hoc inline resolution blocks.

Closes #96

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 16e2af59-173d-474d-9552-53a836fef5c8

📥 Commits

Reviewing files that changed from the base of the PR and between 08d8e9c and d25677f.

📒 Files selected for processing (2)
  • docs/agent-config-guide.md
  • internal/cmd/workspace_test.go
✅ Files skipped from review due to trivial changes (1)
  • docs/agent-config-guide.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/cmd/workspace_test.go

📝 Walkthrough

Walkthrough

This PR makes the serve workspace path configurable through CLI/config input, updates workspace precedence handling in runtime code, and refreshes documentation, deployment examples, and tests to match the new resolution rules.

Changes

Workspace override flow

Layer / File(s) Summary
CLI config and resolver
internal/cmd/serve.go
Adds a --workspace flag, maps it into config, and introduces resolveWorkspace to choose between config, flag/env, and the default workspace.
Serve wiring
internal/cmd/serve.go
Computes the effective workspace once in runServe, then reuses it for workspace directory handling and system-prompt context loading after removing older inline selection logic.
Docs, manifest, and tests
deploy/standalone-agent.yaml, docs/agent-config-guide.md, internal/cmd/workspace_test.go
Adds a commented deployment example, updates workspace precedence documentation, and extends resolver tests for precedence and whitespace handling.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: making the workspace path configurable via CLI flag.
Linked Issues check ✅ Passed The PR matches #96 by adding workspace override support, precedence logic, tests, and the commented deployment example.
Out of Scope Changes check ✅ Passed The changes stay within the workspace-configuration scope and only add related docs, tests, and manifest examples.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/configurable-workspace-path

Comment @coderabbitai help to get the list of available commands.

- Clarify DOCSCLAW_WORKSPACE comment in deployment manifest to
  note it is a fallback, not an override, when agent-config.yaml
  sets tools.workspace
- Trim whitespace in resolveWorkspace to reject blank strings

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni marked this pull request as ready for review July 1, 2026 20:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
docs/agent-config-guide.md (1)

102-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fix dangling sentence fragment.

Static analysis flags a missing subject: "Can also be set via --workspace flag..." reads as a fragment.

✏️ Proposed fix
-| `workspace` | `string` | `/workspace` | Root directory for `read_file` and `write_file`. The agent cannot access files outside this path. Can also be set via `--workspace` flag or `DOCSCLAW_WORKSPACE` env var (config file takes precedence). |
+| `workspace` | `string` | `/workspace` | Root directory for `read_file` and `write_file`. The agent cannot access files outside this path. It can also be set via the `--workspace` flag or `DOCSCLAW_WORKSPACE` env var (config file takes precedence). |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/agent-config-guide.md` at line 102, The `workspace` description in the
docs reads as a dangling fragment because the sentence starts with “Can also be
set…”. Update the text in the table entry so it has an explicit subject, using
the same `workspace` option description to make it a complete sentence while
preserving the note about `--workspace`, `DOCSCLAW_WORKSPACE`, and config-file
precedence.

Source: Linters/SAST tools

internal/cmd/workspace_test.go (1)

170-190: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a whitespace-trimming test case.

The commit message notes blank/whitespace-only workspace values are trimmed and rejected, but no test here exercises resolveWorkspace(" ", "/from-flag") or similar to lock in that behavior.

func TestResolveWorkspaceWhitespaceConfigIgnored(t *testing.T) {
	result := resolveWorkspace("   ", "/from-flag")
	if result != "/from-flag" {
		t.Fatalf("expected /from-flag, got %q", result)
	}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cmd/workspace_test.go` around lines 170 - 190, Add a
whitespace-trimming test for resolveWorkspace to lock in the blank-value
behavior: create a test like TestResolveWorkspaceWhitespaceConfigIgnored
alongside TestResolveWorkspaceConfigWins, TestResolveWorkspaceFlagFallback, and
TestResolveWorkspaceDefault, and verify that a config value containing only
spaces is treated as empty so the flag value is returned instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/agent-config-guide.md`:
- Line 102: The `workspace` description in the docs reads as a dangling fragment
because the sentence starts with “Can also be set…”. Update the text in the
table entry so it has an explicit subject, using the same `workspace` option
description to make it a complete sentence while preserving the note about
`--workspace`, `DOCSCLAW_WORKSPACE`, and config-file precedence.

In `@internal/cmd/workspace_test.go`:
- Around line 170-190: Add a whitespace-trimming test for resolveWorkspace to
lock in the blank-value behavior: create a test like
TestResolveWorkspaceWhitespaceConfigIgnored alongside
TestResolveWorkspaceConfigWins, TestResolveWorkspaceFlagFallback, and
TestResolveWorkspaceDefault, and verify that a config value containing only
spaces is treated as empty so the flag value is returned instead.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: d49eaed1-ca6f-4f6c-82eb-f28b64f6be2e

📥 Commits

Reviewing files that changed from the base of the PR and between 853a4bb and 08d8e9c.

📒 Files selected for processing (4)
  • deploy/standalone-agent.yaml
  • docs/agent-config-guide.md
  • internal/cmd/serve.go
  • internal/cmd/workspace_test.go

- Reword workspace table entry to a complete sentence
- Add whitespace-trimming test for resolveWorkspace

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni merged commit 94d5dc7 into main Jul 1, 2026
4 checks passed
@pavelanni
pavelanni deleted the feature/configurable-workspace-path branch July 1, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: make agent workspace path configurable via CLI flag

1 participant