feat: !include YAML tag and folder-based workflow layout

- Add !include custom YAML tag for referencing external files (Fixes #582)
  - .md/.txt files included as strings
  - .json files parsed as JSON objects
  - .yaml/.yml files parsed as YAML objects
  - Paths resolved relative to the workflow YAML file

- Support foo/index.yaml as alternative to foo.yaml (Fixes #583)
  - Updated discoverProjectWorkflows(), findWorkflowInDir()
  - Updated workflowNameFromPath() for index.yaml detection
  - Flat files take priority over folder layout

- Added tests for both features
This commit is contained in:
2026-05-31 04:12:11 +00:00
parent 9fb817a99c
commit 88c251fc14
7 changed files with 160 additions and 14 deletions
+25
View File
@@ -0,0 +1,25 @@
import { readFileSync } from "node:fs";
import { extname, resolve } from "node:path";
import { parse as parseYaml } from "yaml";
/**
* Create a YAML customTags entry for !include that resolves file paths
* relative to the given base directory.
*/
export function createIncludeTag(baseDir: string) {
return {
tag: "!include",
resolve(str: string) {
const filePath = resolve(baseDir, str);
const content = readFileSync(filePath, "utf8");
const ext = extname(filePath).toLowerCase();
if (ext === ".json") {
return JSON.parse(content);
}
if (ext === ".yaml" || ext === ".yml") {
return parseYaml(content);
}
return content;
},
};
}