pi-landstrip 0.17.38 → 0.17.40

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/dist/index.ts CHANGED
@@ -192,7 +192,7 @@ function normalizeOpenCode(value, path) {
192
192
  result.showLocalAgents = showLocalAgents;
193
193
  return result;
194
194
  }
195
- function readConfig(path) {
195
+ function readConfig(path, isGlobal = false) {
196
196
  if (!existsSync(path))
197
197
  return {};
198
198
  let value;
@@ -209,6 +209,14 @@ function readConfig(path) {
209
209
  throw new Error(`${path}: unknown top-level field ${key}`);
210
210
  }
211
211
  }
212
+ if (!isGlobal) {
213
+ if ("maxSubagents" in value) {
214
+ throw new Error(`${path}: maxSubagents is only allowed in global subagents.json`);
215
+ }
216
+ if ("opencode" in value) {
217
+ throw new Error(`${path}: opencode is only allowed in global subagents.json`);
218
+ }
219
+ }
212
220
  const config = {};
213
221
  if ("maxSubagents" in value) {
214
222
  if (typeof value.maxSubagents !== "number") {
@@ -256,24 +264,26 @@ function getPiConfigPaths(cwd, fileName, agentDir = getAgentDir()) {
256
264
  };
257
265
  }
258
266
  async function setMaxSubagentsConfigForScope(cwd, maxSubagents, scope, agentDir = getAgentDir()) {
267
+ if (scope !== "global") {
268
+ throw new Error("maxSubagents is only allowed in global subagents.json");
269
+ }
259
270
  if (!Number.isInteger(maxSubagents) || maxSubagents < 0 || maxSubagents > MAX_SUBAGENTS) {
260
271
  throw new Error(`maxSubagents must be an integer from 0 to ${MAX_SUBAGENTS}`);
261
272
  }
262
- const { globalPath, projectPath } = getPiConfigPaths(cwd, "subagents.json", agentDir);
263
- const path = scope === "project" ? projectPath : globalPath;
264
- await withFileMutationQueue(path, async () => {
265
- const config = readConfig(path);
273
+ const { globalPath } = getPiConfigPaths(cwd, "subagents.json", agentDir);
274
+ await withFileMutationQueue(globalPath, async () => {
275
+ const config = readConfig(globalPath, true);
266
276
  config.maxSubagents = maxSubagents;
267
- mkdirSync(dirname(path), { recursive: true });
268
- writeFileSync(path, `${JSON.stringify(config, null, 2)}
277
+ mkdirSync(dirname(globalPath), { recursive: true });
278
+ writeFileSync(globalPath, `${JSON.stringify(config, null, 2)}
269
279
  `, { mode: 384 });
270
280
  });
271
281
  }
272
282
  function loadLandstripConfig(cwd, includeProject = true, agentDir = getAgentDir()) {
273
283
  const { globalPath, projectPath } = getPiConfigPaths(cwd, "subagents.json", agentDir);
274
- const builtInConfig = readConfig(join2(packageDir, "subagents.json"));
275
- const globalConfig = readConfig(globalPath);
276
- const projectConfig = includeProject ? readConfig(projectPath) : undefined;
284
+ const builtInConfig = readConfig(join2(packageDir, "subagents.json"), false);
285
+ const globalConfig = readConfig(globalPath, true);
286
+ const projectConfig = includeProject ? readConfig(projectPath, false) : undefined;
277
287
  const agentSources = new Map;
278
288
  recordAgentSources(agentSources, builtInConfig, "built-in");
279
289
  recordAgentSources(agentSources, globalConfig, "global");
@@ -282,7 +292,8 @@ function loadLandstripConfig(cwd, includeProject = true, agentDir = getAgentDir(
282
292
  let config = mergeValue(builtInConfig, globalConfig);
283
293
  if (projectConfig)
284
294
  config = mergeValue(config, projectConfig);
285
- if (!Number.isInteger(config.maxSubagents) || (config.maxSubagents ?? -1) < 0 || (config.maxSubagents ?? MAX_SUBAGENTS + 1) > MAX_SUBAGENTS) {
295
+ const maxSubagents = config.maxSubagents ?? 0;
296
+ if (!Number.isInteger(maxSubagents) || maxSubagents < 0 || maxSubagents > MAX_SUBAGENTS) {
286
297
  throw new Error(`maxSubagents must be an integer from 0 to ${MAX_SUBAGENTS}`);
287
298
  }
288
299
  if (!isRecord2(config.subagents))
@@ -291,7 +302,7 @@ function loadLandstripConfig(cwd, includeProject = true, agentDir = getAgentDir(
291
302
  ...DEFAULT_OPENCODE,
292
303
  ...config.opencode
293
304
  };
294
- return { ...config, opencode, agentSources };
305
+ return { ...config, maxSubagents, opencode, agentSources };
295
306
  }
296
307
 
297
308
  // opencode-agents.ts
@@ -1,5 +1,4 @@
1
1
  {
2
- "maxSubagents": 0,
3
2
  "subagents": {
4
3
  "agent": {
5
4
  "build": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-landstrip",
3
- "version": "0.17.38",
3
+ "version": "0.17.40",
4
4
  "description": "Sandbox-aware Pi subagents and interactive command permissions",
5
5
  "keywords": [
6
6
  "landstrip",
@@ -40,7 +40,7 @@
40
40
  "ci:test": "npm run test"
41
41
  },
42
42
  "dependencies": {
43
- "@landstrip/landstrip": "^0.17.38",
43
+ "@landstrip/landstrip": "^0.17.40",
44
44
  "minimatch": "^10.2.5",
45
45
  "yaml": "^2.9.0"
46
46
  },
package/subagents.json CHANGED
@@ -1,5 +1,4 @@
1
1
  {
2
- "maxSubagents": 0,
3
2
  "subagents": {
4
3
  "agent": {
5
4
  "build": {