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(cli): quote env values with special characters
Dotta626a8f1976c7
diff --git a/cli/src/__tests__/agent-jwt-env.test.ts b/cli/src/__tests__/agent-jwt-env.test.tsindex 40bb15544d..baf5db5128 100644--- a/cli/src/__tests__/agent-jwt-env.test.ts+++ b/cli/src/__tests__/agent-jwt-env.test.ts@@ -4,7 +4,9 @@ import path from "node:path";import { afterEach, beforeEach, describe, expect, it } from "vitest";import {ensureAgentJwtSecret,+ mergePaperclipEnvEntries,readAgentJwtSecretFromEnv,+ readPaperclipEnvEntries,resolveAgentJwtEnvFile,} from "../config/env.js";import { agentJwtSecretCheck } from "../checks/agent-jwt-secret-check.js";@@ -58,4 +60,20 @@ describe("agent jwt env helpers", () => {const result = agentJwtSecretCheck(configPath);expect(result.status).toBe("pass");});++ it("quotes hash-prefixed env values so dotenv round-trips them", () => {+ const configPath = tempConfigPath();+ const envPath = resolveAgentJwtEnvFile(configPath);++ mergePaperclipEnvEntries(+ {+ PAPERCLIP_WORKTREE_COLOR: "#439edb",+ },+ envPath,+ );++ const contents = fs.readFileSync(envPath, "utf-8");+ expect(contents).toContain('PAPERCLIP_WORKTREE_COLOR="#439edb"');+ expect(readPaperclipEnvEntries(envPath).PAPERCLIP_WORKTREE_COLOR).toBe("#439edb");+ });});diff --git a/cli/src/__tests__/worktree.test.ts b/cli/src/__tests__/worktree.test.tsindex b6e2eb471f..a8333ba508 100644--- a/cli/src/__tests__/worktree.test.ts+++ b/cli/src/__tests__/worktree.test.ts@@ -294,7 +294,7 @@ describe("worktree helpers", () => {const envContents = fs.readFileSync(envPath, "utf8");expect(envContents).toContain("PAPERCLIP_AGENT_JWT_SECRET=worktree-shared-secret");expect(envContents).toContain("PAPERCLIP_WORKTREE_NAME=repo");- expect(envContents).toMatch(/PAPERCLIP_WORKTREE_COLOR=#[0-9a-f]{6}/);+ expect(envContents).toMatch(/PAPERCLIP_WORKTREE_COLOR=\"#[0-9a-f]{6}\"/);} finally {process.chdir(originalCwd);if (originalJwtSecret === undefined) {diff --git a/cli/src/config/env.ts b/cli/src/config/env.tsindex 4bc8f16eba..a7266ea241 100644--- a/cli/src/config/env.ts+++ b/cli/src/config/env.ts@@ -22,11 +22,18 @@ function parseEnvFile(contents: string) {}}+function formatEnvValue(value: string): string {+ if (/^[A-Za-z0-9_./:@-]+$/.test(value)) {+ return value;+ }+ return JSON.stringify(value);+}+function renderEnvFile(entries: Record<string, string>) {const lines = ["# Paperclip environment variables","# Generated by Paperclip CLI commands",- ...Object.entries(entries).map(([key, value]) => `${key}=${value}`),+ ...Object.entries(entries).map(([key, value]) => `${key}=${formatEnvValue(value)}`),"",];return lines.join("\n");