fix(shared): discover global rules at ~/Cline/Rules (#13614)

The VS Code Rules tab resolves the Documents folder via
'xdg-user-dir DOCUMENTS', which prints bare $HOME when no user-dirs
config exists (WSL/headless installs), so it reads and writes global
rules at ~/Cline/Rules. The SDK's rule search paths only covered
~/Documents/Cline/Rules, so those rules never reached the system prompt.
Add the missing path to the search list.

Fixes #13542

Co-authored-by: Saoud Rizwan <saoudrizwan@users.noreply.github.com>
This commit is contained in:
Saoud Rizwan
2026-08-27 14:44:25 -07:00
committed by GitHub
parent c97e4af8fa
commit 691fcb6b67
2 changed files with 12 additions and 1 deletions
@@ -1,6 +1,6 @@
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { dirname, join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import {
AGENT_CONFIG_DIRECTORY_NAME,
@@ -204,6 +204,12 @@ describe("storage path resolution", () => {
expect.arrayContaining([
resolveGlobalAgentsRulesPath(),
join("/tmp/home", ".cline", RULES_CONFIG_DIRECTORY_NAME),
// xdg-user-dir's unconfigured Documents fallback (cline/cline#13542)
join(
dirname(dirname(resolveGlobalAgentsRulesPath())),
"Cline",
"Rules",
),
]),
);
expect(resolveRulesConfigSearchPaths()).not.toContain(
+5
View File
@@ -514,6 +514,11 @@ export function resolveRulesConfigSearchPaths(
...wsPaths,
resolveGlobalAgentsRulesPath(),
join(resolveClineDir(), RULES_CONFIG_DIRECTORY_NAME),
// The VS Code Rules tab resolves Documents via `xdg-user-dir DOCUMENTS`,
// which prints bare $HOME when unconfigured (WSL/headless), putting
// global rules at ~/Cline/Rules instead of ~/Documents/Cline/Rules
// (cline/cline#13542).
join(HOME_DIR, "Cline", "Rules"),
resolveDocumentsExtensionPath("Rules"),
]);
}