diff --git a/src/processes/isolation.ts b/src/processes/isolation.ts index 31deedf..b63d8d3 100644 --- a/src/processes/isolation.ts +++ b/src/processes/isolation.ts @@ -6,8 +6,8 @@ import { isNotFound } from "#common"; import type { RuntimeProfile } from "#runtime"; export function isRunnableProfileProcess(status: string, uid: number): boolean { - const owner = /^Uid:\s+(?\d+)/mu.exec(status)?.[1]; - const state = /^State:\s+(?\w)/mu.exec(status)?.[1]; + const owner = /^Uid:\s+(?\d+)/mu.exec(status)?.groups?.["uid"]; + const state = /^State:\s+(?\w)/mu.exec(status)?.groups?.["state"]; return owner !== undefined && Number(owner) === uid && state !== "Z"; } diff --git a/src/run/index.ts b/src/run/index.ts index 5d6e22b..bb2a3c8 100644 --- a/src/run/index.ts +++ b/src/run/index.ts @@ -211,10 +211,11 @@ async function renderPrompt(profile: RuntimeProfile): Promise { ]); const template = await readFile(new URL("../../prompt.md", import.meta.url), "utf8"); return { - prompt: template.replaceAll( - /\$\{(?\w+)\}/gu, - (match: string, name: string) => values.get(name) ?? match, - ), + prompt: template.replaceAll(/\$\{(?\w+)\}/gu, (match: string, ...args: unknown[]) => { + const groups = args.at(-1); + const name = isObject(groups) ? field(groups, "name") : undefined; + return typeof name === "string" ? (values.get(name) ?? match) : match; + }), reviewPath, anchorsPath, };