fix: biome 2.4.16 migration, reduce scanWorkflowDir complexity, fix formatting
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
||||||
"files": {
|
"files": {
|
||||||
"includes": [
|
"includes": [
|
||||||
"**",
|
"**",
|
||||||
|
|||||||
@@ -279,11 +279,17 @@ describe("Strategy 3: Local Discovery", () => {
|
|||||||
await makeUwfStore(storageRoot);
|
await makeUwfStore(storageRoot);
|
||||||
const workflowDir = join(projectRoot, ".workflow");
|
const workflowDir = join(projectRoot, ".workflow");
|
||||||
await mkdir(workflowDir, { recursive: true });
|
await mkdir(workflowDir, { recursive: true });
|
||||||
await writeFile(join(workflowDir, "solve-issue.yaml"), await createWorkflowYaml("solve-issue", "flat"));
|
await writeFile(
|
||||||
|
join(workflowDir, "solve-issue.yaml"),
|
||||||
|
await createWorkflowYaml("solve-issue", "flat"),
|
||||||
|
);
|
||||||
|
|
||||||
const folderDir = join(workflowDir, "solve-issue");
|
const folderDir = join(workflowDir, "solve-issue");
|
||||||
await mkdir(folderDir, { recursive: true });
|
await mkdir(folderDir, { recursive: true });
|
||||||
await writeFile(join(folderDir, "index.yaml"), await createWorkflowYaml("solve-issue", "folder"));
|
await writeFile(
|
||||||
|
join(folderDir, "index.yaml"),
|
||||||
|
await createWorkflowYaml("solve-issue", "folder"),
|
||||||
|
);
|
||||||
|
|
||||||
const result = await cmdThreadStart(storageRoot, "solve-issue", "prompt", projectRoot);
|
const result = await cmdThreadStart(storageRoot, "solve-issue", "prompt", projectRoot);
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,9 @@ export async function cmdWorkflowAdd(
|
|||||||
|
|
||||||
let raw: unknown;
|
let raw: unknown;
|
||||||
try {
|
try {
|
||||||
raw = parse(text, { customTags: [createIncludeTag(dirname(resolvePath(filePath)))] }) as unknown;
|
raw = parse(text, {
|
||||||
|
customTags: [createIncludeTag(dirname(resolvePath(filePath)))],
|
||||||
|
}) as unknown;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
fail(`invalid YAML: ${e instanceof Error ? e.message : String(e)}`);
|
fail(`invalid YAML: ${e instanceof Error ? e.message : String(e)}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,30 @@ export type ProjectWorkflowEntry = {
|
|||||||
filePath: string;
|
filePath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Extract workflow name from a YAML filename (strip .yaml/.yml extension). */
|
||||||
|
function stemFromYaml(name: string): string {
|
||||||
|
if (name.endsWith(".yaml")) return name.slice(0, -5);
|
||||||
|
if (name.endsWith(".yml")) return name.slice(0, -4);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check if a directory contains an index.yaml or index.yml workflow file. */
|
||||||
|
async function findIndexWorkflow(
|
||||||
|
dir: string,
|
||||||
|
dirName: string,
|
||||||
|
): Promise<ProjectWorkflowEntry | null> {
|
||||||
|
for (const indexName of ["index.yaml", "index.yml"]) {
|
||||||
|
const indexPath = join(dir, dirName, indexName);
|
||||||
|
try {
|
||||||
|
await access(indexPath);
|
||||||
|
return { name: dirName, filePath: indexPath };
|
||||||
|
} catch {
|
||||||
|
// not found, try next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan a single directory for workflow entries (flat YAML files + folder/index.yaml).
|
* Scan a single directory for workflow entries (flat YAML files + folder/index.yaml).
|
||||||
* Returns discovered entries. Returns empty array if directory does not exist.
|
* Returns discovered entries. Returns empty array if directory does not exist.
|
||||||
@@ -39,18 +63,11 @@ async function scanWorkflowDir(dir: string): Promise<ProjectWorkflowEntry[]> {
|
|||||||
const result: ProjectWorkflowEntry[] = [];
|
const result: ProjectWorkflowEntry[] = [];
|
||||||
for (const entry of dirents) {
|
for (const entry of dirents) {
|
||||||
if (entry.isFile() && (entry.name.endsWith(".yaml") || entry.name.endsWith(".yml"))) {
|
if (entry.isFile() && (entry.name.endsWith(".yaml") || entry.name.endsWith(".yml"))) {
|
||||||
const stem = entry.name.endsWith(".yaml") ? entry.name.slice(0, -5) : entry.name.slice(0, -4);
|
result.push({ name: stemFromYaml(entry.name), filePath: join(dir, entry.name) });
|
||||||
result.push({ name: stem, filePath: join(dir, entry.name) });
|
|
||||||
} else if (entry.isDirectory()) {
|
} else if (entry.isDirectory()) {
|
||||||
for (const indexName of ["index.yaml", "index.yml"]) {
|
const found = await findIndexWorkflow(dir, entry.name);
|
||||||
const indexPath = join(dir, entry.name, indexName);
|
if (found !== null) {
|
||||||
try {
|
result.push(found);
|
||||||
await access(indexPath);
|
|
||||||
result.push({ name: entry.name, filePath: indexPath });
|
|
||||||
break;
|
|
||||||
} catch {
|
|
||||||
// not found, try next
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user