fix: resolve workspace templates from package root

This commit is contained in:
Peter Steinberger
2026-01-31 09:07:41 +00:00
parent 68ba1afb34
commit ddc5683c67
4 changed files with 109 additions and 14 deletions

View File

@@ -1,11 +1,10 @@
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { isSubagentSessionKey } from "../routing/session-key.js";
import { runCommandWithTimeout } from "../process/exec.js";
import { resolveUserPath } from "../utils.js";
import { resolveWorkspaceTemplateDir } from "./workspace-templates.js";
export function resolveDefaultAgentWorkspaceDir(
env: NodeJS.ProcessEnv = process.env,
@@ -29,11 +28,6 @@ export const DEFAULT_BOOTSTRAP_FILENAME = "BOOTSTRAP.md";
export const DEFAULT_MEMORY_FILENAME = "MEMORY.md";
export const DEFAULT_MEMORY_ALT_FILENAME = "memory.md";
const TEMPLATE_DIR = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../../docs/reference/templates",
);
function stripFrontMatter(content: string): string {
if (!content.startsWith("---")) {
return content;
@@ -49,7 +43,8 @@ function stripFrontMatter(content: string): string {
}
async function loadTemplate(name: string): Promise<string> {
const templatePath = path.join(TEMPLATE_DIR, name);
const templateDir = await resolveWorkspaceTemplateDir();
const templatePath = path.join(templateDir, name);
try {
const content = await fs.readFile(templatePath, "utf-8");
return stripFrontMatter(content);