feat: new flag to filter blocks on creation (#132)

This commit is contained in:
Charles Packer
2025-11-27 02:12:41 -08:00
committed by GitHub
parent 135c19c7d7
commit 06ec8b9d3c
4 changed files with 251 additions and 5 deletions

View File

@@ -52,6 +52,8 @@ export async function handleHeadlessCommand(
link: { type: "boolean" },
unlink: { type: "boolean" },
sleeptime: { type: "boolean" },
"init-blocks": { type: "string" },
"base-tools": { type: "string" },
},
strict: false,
allowPositionals: true,
@@ -84,8 +86,50 @@ export async function handleHeadlessCommand(
const specifiedAgentId = values.agent as string | undefined;
const shouldContinue = values.continue as boolean | undefined;
const forceNew = values.new as boolean | undefined;
const initBlocksRaw = values["init-blocks"] as string | undefined;
const baseToolsRaw = values["base-tools"] as string | undefined;
const sleeptimeFlag = (values.sleeptime as boolean | undefined) ?? undefined;
if (initBlocksRaw && !forceNew) {
console.error(
"Error: --init-blocks can only be used together with --new to control initial memory blocks.",
);
process.exit(1);
}
let initBlocks: string[] | undefined;
if (initBlocksRaw !== undefined) {
const trimmed = initBlocksRaw.trim();
if (!trimmed || trimmed.toLowerCase() === "none") {
initBlocks = [];
} else {
initBlocks = trimmed
.split(",")
.map((name) => name.trim())
.filter((name) => name.length > 0);
}
}
if (baseToolsRaw && !forceNew) {
console.error(
"Error: --base-tools can only be used together with --new to control initial base tools.",
);
process.exit(1);
}
let baseTools: string[] | undefined;
if (baseToolsRaw !== undefined) {
const trimmed = baseToolsRaw.trim();
if (!trimmed || trimmed.toLowerCase() === "none") {
baseTools = [];
} else {
baseTools = trimmed
.split(",")
.map((name) => name.trim())
.filter((name) => name.length > 0);
}
}
// Priority 1: Try to use --agent specified ID
if (specifiedAgentId) {
try {
@@ -107,6 +151,9 @@ export async function handleHeadlessCommand(
skillsDirectory,
settings.parallelToolCalls,
sleeptimeFlag ?? settings.enableSleeptime,
undefined,
initBlocks,
baseTools,
);
}
@@ -148,6 +195,9 @@ export async function handleHeadlessCommand(
skillsDirectory,
settings.parallelToolCalls,
sleeptimeFlag ?? settings.enableSleeptime,
undefined,
undefined,
undefined,
);
}