Replace NodeJS dict aliases with maps and named field reads #24
@@ -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+(?<uid>\d+)/mu.exec(status)?.[1];
|
||||
const state = /^State:\s+(?<state>\w)/mu.exec(status)?.[1];
|
||||
const owner = /^Uid:\s+(?<uid>\d+)/mu.exec(status)?.groups?.["uid"];
|
||||
const state = /^State:\s+(?<state>\w)/mu.exec(status)?.groups?.["state"];
|
||||
return owner !== undefined && Number(owner) === uid && state !== "Z";
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -211,10 +211,11 @@ async function renderPrompt(profile: RuntimeProfile): Promise<RenderedPrompt> {
|
||||
]);
|
||||
const template = await readFile(new URL("../../prompt.md", import.meta.url), "utf8");
|
||||
return {
|
||||
prompt: template.replaceAll(
|
||||
/\$\{(?<name>\w+)\}/gu,
|
||||
(match: string, name: string) => values.get(name) ?? match,
|
||||
),
|
||||
prompt: template.replaceAll(/\$\{(?<name>\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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user