Merge pull request #1786 from paperclipai/fix/opencode-disable-project-config
fix(opencode): prevent opencode.json pollution in workspace
This commit is contained in:
commit
c5c6c62bd7
4 changed files with 12 additions and 1 deletions
|
|
@ -37,4 +37,7 @@ Notes:
|
||||||
- Paperclip requires an explicit \`model\` value for \`opencode_local\` agents.
|
- Paperclip requires an explicit \`model\` value for \`opencode_local\` agents.
|
||||||
- Runs are executed with: opencode run --format json ...
|
- Runs are executed with: opencode run --format json ...
|
||||||
- Sessions are resumed with --session when stored session cwd matches current cwd.
|
- Sessions are resumed with --session when stored session cwd matches current cwd.
|
||||||
|
- The adapter sets OPENCODE_DISABLE_PROJECT_CONFIG=true to prevent OpenCode from \
|
||||||
|
writing an opencode.json config file into the project working directory. Model \
|
||||||
|
selection is passed via the --model CLI flag instead.
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,11 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
||||||
for (const [key, value] of Object.entries(envConfig)) {
|
for (const [key, value] of Object.entries(envConfig)) {
|
||||||
if (typeof value === "string") env[key] = value;
|
if (typeof value === "string") env[key] = value;
|
||||||
}
|
}
|
||||||
|
// Prevent OpenCode from writing an opencode.json config file into the
|
||||||
|
// project working directory (which would pollute the git repo). Model
|
||||||
|
// selection is already handled via the --model CLI flag. Set after the
|
||||||
|
// envConfig loop so user overrides cannot disable this guard.
|
||||||
|
env.OPENCODE_DISABLE_PROJECT_CONFIG = "true";
|
||||||
if (!hasExplicitApiKey && authToken) {
|
if (!hasExplicitApiKey && authToken) {
|
||||||
env.PAPERCLIP_API_KEY = authToken;
|
env.PAPERCLIP_API_KEY = authToken;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ export async function discoverOpenCodeModels(input: {
|
||||||
// /etc/passwd entry (e.g. `docker run --user 1234` with a minimal
|
// /etc/passwd entry (e.g. `docker run --user 1234` with a minimal
|
||||||
// image). Fall back to process.env.HOME.
|
// image). Fall back to process.env.HOME.
|
||||||
}
|
}
|
||||||
const runtimeEnv = normalizeEnv(ensurePathInEnv({ ...process.env, ...env, ...(resolvedHome ? { HOME: resolvedHome } : {}) }));
|
// Prevent OpenCode from writing an opencode.json into the working directory.
|
||||||
|
const runtimeEnv = normalizeEnv(ensurePathInEnv({ ...process.env, ...env, ...(resolvedHome ? { HOME: resolvedHome } : {}), OPENCODE_DISABLE_PROJECT_CONFIG: "true" }));
|
||||||
|
|
||||||
const result = await runChildProcess(
|
const result = await runChildProcess(
|
||||||
`opencode-models-${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
`opencode-models-${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ export async function testEnvironment(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent OpenCode from writing an opencode.json into the working directory.
|
||||||
|
env.OPENCODE_DISABLE_PROJECT_CONFIG = "true";
|
||||||
const runtimeEnv = normalizeEnv(ensurePathInEnv({ ...process.env, ...env }));
|
const runtimeEnv = normalizeEnv(ensurePathInEnv({ ...process.env, ...env }));
|
||||||
|
|
||||||
const cwdInvalid = checks.some((check) => check.code === "opencode_cwd_invalid");
|
const cwdInvalid = checks.some((check) => check.code === "opencode_cwd_invalid");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue