The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(dev-runner): tighten worktree env bootstrap
Dottaa5aed931ab34
diff --git a/scripts/dev-runner.ts b/scripts/dev-runner.tsindex 1c991b99ec..a26ef6380e 100644--- a/scripts/dev-runner.ts+++ b/scripts/dev-runner.ts@@ -23,7 +23,7 @@ type BindMode = (typeof BIND_MODES)[number];const worktreeEnvBootstrap = bootstrapDevRunnerWorktreeEnv(repoRoot, process.env);if (worktreeEnvBootstrap.missingEnv) {console.error(- `[paperclip] linked git worktree at ${repoRoot} is missing ${path.relative(repoRoot, worktreeEnvBootstrap.envPath ?? "")}. Run \`paperclipai worktree init\` in this worktree before \`pnpm dev\`.`,+ `[paperclip] linked git worktree at ${repoRoot} is missing ${path.relative(repoRoot, worktreeEnvBootstrap.envPath)}. Run \`paperclipai worktree init\` in this worktree before \`pnpm dev\`.`,);process.exit(1);}diff --git a/server/src/__tests__/dev-runner-worktree.test.ts b/server/src/__tests__/dev-runner-worktree.test.tsindex 714cb54b3a..461f2aabbf 100644--- a/server/src/__tests__/dev-runner-worktree.test.ts+++ b/server/src/__tests__/dev-runner-worktree.test.ts@@ -42,6 +42,7 @@ describe("dev-runner worktree env bootstrap", () => {"PAPERCLIP_INSTANCE_ID=feature-worktree","PAPERCLIP_IN_WORKTREE=true","PAPERCLIP_WORKTREE_NAME=feature-worktree",+ "PAPERCLIP_OPTIONAL= # comment-only value","",].join("\n"),"utf8",@@ -59,6 +60,7 @@ describe("dev-runner worktree env bootstrap", () => {expect(env.PAPERCLIP_HOME).toBe("/tmp/paperclip-worktrees");expect(env.PAPERCLIP_INSTANCE_ID).toBe("already-set");expect(env.PAPERCLIP_IN_WORKTREE).toBe("true");+ expect(env.PAPERCLIP_OPTIONAL).toBe("");});it("reports uninitialized linked worktrees so dev runner can fail fast", () => {diff --git a/server/src/dev-runner-worktree.ts b/server/src/dev-runner-worktree.tsindex 286087ef10..4e2b5d8db2 100644--- a/server/src/dev-runner-worktree.ts+++ b/server/src/dev-runner-worktree.ts@@ -17,6 +17,10 @@ function parseEnvFile(contents: string): Record<string, string> {entries[key] = "";continue;}+ if (value.startsWith("#")) {+ entries[key] = "";+ continue;+ }if ((value.startsWith("\"") && value.endsWith("\"")) ||@@ -32,6 +36,11 @@ function parseEnvFile(contents: string): Record<string, string> {return entries;}+type WorktreeEnvBootstrapResult =+ | { envPath: null; missingEnv: false }+ | { envPath: string; missingEnv: true }+ | { envPath: string; missingEnv: false };+export function isLinkedGitWorktreeCheckout(rootDir: string): boolean {const gitMetadataPath = path.join(rootDir, ".git");if (!existsSync(gitMetadataPath)) return false;@@ -49,10 +58,7 @@ export function resolveWorktreeEnvFilePath(rootDir: string): string {export function bootstrapDevRunnerWorktreeEnv(rootDir: string,env: NodeJS.ProcessEnv = process.env,-): {- envPath: string | null;- missingEnv: boolean;-} {+): WorktreeEnvBootstrapResult {if (!isLinkedGitWorktreeCheckout(rootDir)) {return {envPath: null,