Plan preview always fails "Document is outside the worktree" for non-git projects
Description
Description
When the Plan agent presents a plan in a non-git project, opening it in the Documents panel always shows "Document is outside the worktree." The plan file itself is created fine — only the preview is broken.
Root cause (from source)
For non-git projects, plan files are stored in the canonical/global plan dir
outside the worktree (~/.local/share/kilo/plans/<session-ts>-<name>.md).
This is a known, intentional case — packages/opencode/src/kilocode/plan-file.ts
(written()) explicitly admits it:
// dir check admits the canonical plan dir, outside the worktree for non-git projects
if (!containsPath(full, ctx) && !Filesystem.contains(dir, full)) continueHowever, packages/kilo-vscode/src/documents/document-reader.ts (readDocument)
rejects any file outside the session root, with no exemption for plan documents:
if (resolved !== base && !resolved.startsWith(base + path.sep))
return { error: "Document is outside the worktree." }So the backend deliberately stores plan files where the frontend preview can
never display them. In git-backed projects the plan lands in
<worktree>/.kilo/plans/ and the preview works — which is probably why this
isn't widely reported yet.
Not a duplicate of #14182 — that was a path-casing false positive for files inside the project; here the file is legitimately outside for non-git projects.
Steps to reproduce
- Open a folder that is not a git repository (no .git) as the workspace.
- Switch to Plan mode, ask for a plan, let it be presented.
- Open the plan from the Documents panel/link → "Document is outside the worktree."
- Same flow in a git repo works.
Expected behavior
Plan documents are previewable regardless of worktree membership — e.g. exempt plan files from the containment check, or pass the plan dir as root for them.
Environment
- Kilo Code: 7.8.1
- OS: Windows (VSCodium)
- Project type: non-git folder
- Plan files observed in:
~/.local/share/kilo/plans/
Plugins
no marketplace plugins
Kilo version
7.8.1
Steps to reproduce
- Open a folder that is not a git repository (no .git) as the workspace.
- Switch to Plan mode, ask for a plan, let it be presented.
- Open the plan from the Documents panel/link → "Document is outside the worktree."
- Same flow in a git repo works.
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
PowerShell 7 (pwsh) integrated terminal in VSCodium, Windows
Source: Kilo-Org/kilocode