fix: remove process.cwd() fallback for working directory in chat route

The chat route and claude-client both fell back to process.cwd() when
working_directory was empty, causing Claude to operate in the server's
directory instead of the user's project. Since session creation now
requires a valid working_directory, these fallbacks are unnecessary
and misleading. Fall back to os.homedir() as a safer last resort.

Also update CLAUDE.md: require explicit user confirmation before
publishing releases (no auto push+tag).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-02-13 17:28:53 +08:00
1 parent 01e7e0c1e3
commit 6aca8c3870
3 files changed
+6 -2

No files matched your search

+4
View File
@@ -21,6 +21,10 @@ CodePilot — Claude Code 的桌面 GUI 客户端,基于 Electron + Next.js。
**重要:不要手动创建 GitHub Release**,否则会与 CI 自动创建的 Release 冲突。如果需要本地打包测试,使用 `npm run electron:pack:mac` 但不要手动上传到 Release。
## 发版纪律
**禁止自动发版**:不要在完成代码修改后自动执行 `git push` + `git tag` + `git push origin tag` 发版流程。必须等待用户明确指示"发版"、"发布"或类似确认后才能执行。代码提交(commit)可以正常进行,但推送和打 tag 必须由用户确认。
## Development Rules
**提交前必须详尽测试:**
+1 -1
View File
@@ -32,7 +32,7 @@ export async function POST(request: NextRequest) {
let savedContent = content;
let fileMeta: Array<{ id: string; name: string; type: string; size: number; filePath: string }> | undefined;
if (files && files.length > 0) {
const workDir = session.working_directory || process.cwd();
const workDir = session.working_directory;
const uploadDir = path.join(workDir, '.codepilot-uploads');
if (!fs.existsSync(uploadDir)) {
fs.mkdirSync(uploadDir, { recursive: true });
+1 -1
View File
@@ -316,7 +316,7 @@ export function streamClaude(options: ClaudeStreamOptions): ReadableStream<strin
const skipPermissions = getSetting('dangerously_skip_permissions') === 'true';
const queryOptions: Options = {
cwd: workingDirectory || process.cwd(),
cwd: workingDirectory || os.homedir(),
abortController,
includePartialMessages: true,
permissionMode: skipPermissions