Repository navigation
feat: add OpenClaw workspace context loading - #97
Conversation
Load OpenClaw-compatible workspace files (AGENTS.md, SOUL.md, USER.md, IDENTITY.md, TOOLS.md) from the workspace directory and inject them as structured project context into the system prompt. This gives OpenClaw users a migration path to DocsClaw's leaner runtime without changing their workspace configuration. Works in both phase 1 (single-shot) and phase 2 (agentic loop). Per-file truncation at 20K chars, total at 60K chars, matching OpenClaw defaults. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📝 WalkthroughWalkthroughAdds OpenClaw-compatible workspace context loading to docsclaw, appends the loaded markdown content to the startup system prompt, and updates tests, documentation, and deployment assets for the workspace-aware flow. ChangesOpenClaw Workspace Context
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant runServe
participant loadWorkspaceContext
participant Filesystem
participant systemPrompt
runServe->>loadWorkspaceContext: call with workspace directory
loadWorkspaceContext->>Filesystem: read AGENTS.md, SOUL.md, USER.md, IDENTITY.md, TOOLS.md
Filesystem-->>loadWorkspaceContext: file contents or missing/empty results
loadWorkspaceContext->>loadWorkspaceContext: apply per-file and total rune limits
loadWorkspaceContext-->>runServe: formatted Project Context block
runServe->>systemPrompt: append workspace context
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
- Use rune-based truncation instead of byte-based to prevent splitting multi-byte UTF-8 characters at truncation boundaries - Move workspace context loading after slog.SetDefault so truncation warnings use the configured structured logger - Fix deployment manifest: use init container to seed OpenClaw files from ConfigMap into a writable emptyDir so write_file works at runtime - Add Unicode truncation test verifying rune safety Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@deploy/openclaw-workspace-agent.yaml`:
- Around line 98-100: The seed-workspace init command currently uses a raw
wildcard copy that fails when no .md files are present, causing the pod to exit
before DocsClaw starts. Update the command in the seed-workspace init container
to use a glob-safe approach, such as a shell loop or enabling nullglob, so the
copy becomes a no-op when /openclaw-files has no matches. Keep the fix localized
to the command array for seed-workspace and preserve successful startup when the
optional workspace files are absent.
In `@internal/cmd/serve.go`:
- Around line 160-162: In the workspace file loading path in serve.go, the
current os.ReadFile error handling in the file iteration treats all failures as
missing files and silently continues. Update the logic around the read of
filepath.Join(workspaceDir, name) to skip only errors matching os.ErrNotExist,
and for any other failure log a warning with the file name and error before
continuing. Keep the behavior localized to the workspace scan code so unreadable
files are surfaced without breaking the request flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: adb1df46-b758-4a13-af1f-85deea62a533
📒 Files selected for processing (10)
README.mddeploy/openclaw-workspace-agent.yamldocs/agent-config-guide.mdinternal/cmd/serve.gointernal/cmd/workspace_test.gotestdata/openclaw-workspace/AGENTS.mdtestdata/openclaw-workspace/IDENTITY.mdtestdata/openclaw-workspace/SOUL.mdtestdata/openclaw-workspace/TOOLS.mdtestdata/openclaw-workspace/USER.md
- Use a shell loop with existence check in the seed-workspace init container so it exits cleanly when no .md files are present - Log a warning for workspace file read errors other than not-found instead of silently skipping them Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Summary
## Project Contextin the system promptsystem-prompt.txtare unaffectedTest plan
golangci-lint run ./internal/cmd/...passes (zero issues in changed packages)make testpasses (no regressions)Note:
make linthas pre-existing failures indemo/batch/document-service/main.goandinternal/logger/logger.go— unrelated to this change.Assisted-By: Claude (Anthropic AI) [email protected]
Summary by CodeRabbit
New Features
Documentation
Tests