opencode-landstrip 0.16.13 → 0.16.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/shared.ts +18 -32
package/package.json
CHANGED
package/shared.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { binaryPath } from '@landstrip/landstrip';
|
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
8
|
import { homedir, tmpdir } from 'node:os';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
9
10
|
import { dirname, join } from 'node:path';
|
|
10
11
|
|
|
11
12
|
export interface SandboxFilesystemConfig {
|
|
@@ -36,30 +37,7 @@ export interface SandboxConfigOverrides {
|
|
|
36
37
|
filesystem?: Partial<SandboxFilesystemConfig>;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
enabled: true,
|
|
41
|
-
network: {
|
|
42
|
-
allowNetwork: false,
|
|
43
|
-
allowLocalBinding: false,
|
|
44
|
-
allowAllUnixSockets: false,
|
|
45
|
-
allowUnixSockets: [],
|
|
46
|
-
allowedDomains: [],
|
|
47
|
-
deniedDomains: [],
|
|
48
|
-
},
|
|
49
|
-
filesystem: {
|
|
50
|
-
denyRead: ['/Users', '/home'],
|
|
51
|
-
allowRead: ['.', '~/.gitconfig', '~/.config/git/config', '/dev/null'],
|
|
52
|
-
allowWrite: ['.', '/dev/null'],
|
|
53
|
-
denyWrite: [
|
|
54
|
-
'**/.env',
|
|
55
|
-
'**/.env.*',
|
|
56
|
-
'**/*.pem',
|
|
57
|
-
'**/*.key',
|
|
58
|
-
'.opencode/sandbox.json',
|
|
59
|
-
'~/.config/opencode/sandbox.json',
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
};
|
|
40
|
+
const packageDir = dirname(fileURLToPath(import.meta.url));
|
|
63
41
|
|
|
64
42
|
const LANDSTRIP_PACKAGE_NAMES = new Set([
|
|
65
43
|
'@landstrip/landstrip',
|
|
@@ -195,13 +173,18 @@ export function loadConfig(
|
|
|
195
173
|
optionOverrides: SandboxConfigOverrides,
|
|
196
174
|
): SandboxConfig {
|
|
197
175
|
const { globalPath, projectPath } = getConfigPaths(baseDirectory);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
),
|
|
203
|
-
|
|
204
|
-
|
|
176
|
+
const templatePath = join(packageDir, 'sandbox.json');
|
|
177
|
+
|
|
178
|
+
if (!existsSync(globalPath)) {
|
|
179
|
+
mkdirSync(dirname(globalPath), { recursive: true });
|
|
180
|
+
writeFileSync(globalPath, readFileSync(templatePath, 'utf-8'), 'utf-8');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const templateConfig: SandboxConfig = JSON.parse(readFileSync(templatePath, 'utf-8'));
|
|
184
|
+
const globalOverrides = readConfigFile(globalPath) ?? {};
|
|
185
|
+
const baseConfig = deepMerge(templateConfig, globalOverrides);
|
|
186
|
+
|
|
187
|
+
return deepMerge(deepMerge(baseConfig, readConfigFile(projectPath) ?? {}), optionOverrides);
|
|
205
188
|
}
|
|
206
189
|
|
|
207
190
|
export function writeConfigFile(configPath: string, update: SandboxConfigOverrides): void {
|
|
@@ -210,7 +193,10 @@ export function writeConfigFile(configPath: string, update: SandboxConfigOverrid
|
|
|
210
193
|
throw new Error(`Config file ${configPath} is corrupted; refusing to overwrite`);
|
|
211
194
|
}
|
|
212
195
|
|
|
213
|
-
const
|
|
196
|
+
const templateConfig: SandboxConfig = JSON.parse(
|
|
197
|
+
readFileSync(join(packageDir, 'sandbox.json'), 'utf-8'),
|
|
198
|
+
);
|
|
199
|
+
const next = deepMerge(deepMerge(templateConfig, current), update);
|
|
214
200
|
|
|
215
201
|
mkdirSync(dirname(configPath), { recursive: true });
|
|
216
202
|
writeFileSync(configPath, JSON.stringify(next, null, 2) + '\n');
|