Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 183 additions & 18 deletions bun.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "owflow",
"version": "0.1.6",
"version": "0.2.0",
"description": "Spec-driven development AI workflow for OpenCode",
"type": "module",
"module": "index.ts",
Expand All @@ -15,7 +15,8 @@
"build": "rm -rf dist && tsc && bun run copy-markdowns",
"copy-markdowns": "node ./scripts/copy-markdowns.js",
"prepack": "bun run build",
"test": "bun test"
"test": "bun test",
"type-check": "tsc --noEmit"
},
"keywords": [
"opencode",
Expand All @@ -30,10 +31,11 @@
},
"license": "MIT",
"dependencies": {
"effect": "4.0.0-beta.98",
"gray-matter": "^4.0.3"
},
"devDependencies": {
"@opencode-ai/plugin": "^1.14.44",
"@opencode-ai/plugin": "^0.0.0-next-15919",
"@types/bun": "^1.3.13"
},
"peerDependencies": {
Expand Down
55 changes: 34 additions & 21 deletions src/__tests__/verify_template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect, test, describe, beforeAll, afterAll } from "bun:test";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { Effect } from "effect";
import { verify_template } from "../tools/verify_template";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand All @@ -11,6 +12,7 @@ describe("verify_template tool", () => {
const testDir = path.join(__dirname, "test_tmp_dir");
const testTemplateName = "test-template.yml";
const testTemplatePath = path.join(templatesDir, testTemplateName);
const originalCwd = process.cwd();

beforeAll(() => {
// Ensure templates dir exists
Expand All @@ -31,9 +33,12 @@ key2:
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}

process.chdir(testDir);
});

afterAll(() => {
process.chdir(originalCwd);
// Cleanup
if (fs.existsSync(testTemplatePath)) {
fs.rmSync(testTemplatePath);
Expand All @@ -44,10 +49,10 @@ key2:
});

test("should return error if file not found", async () => {
const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath: "nonexistent.yml", templateName: testTemplateName },
{ directory: testDir } as any,
);
{} as any
));
expect((result as any).output).toContain(
"File not found at nonexistent.yml",
);
Expand All @@ -57,10 +62,10 @@ key2:
const filePath = "target.yml";
fs.writeFileSync(path.join(testDir, filePath), "key1: value");

const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath, templateName: "nonexistent-template.yml" },
{ directory: testDir } as any,
);
{} as any
));
expect((result as any).output).toContain(
"Template 'nonexistent-template.yml' not found",
);
Expand All @@ -70,10 +75,10 @@ key2:
const filePath = "invalid.yml";
fs.writeFileSync(path.join(testDir, filePath), "key1: : value\n invalid");

const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath, templateName: testTemplateName },
{ directory: testDir } as any,
);
{} as any
));
expect((result as any).output).toContain(
"YAML Syntax Error in invalid.yml",
);
Expand All @@ -84,10 +89,10 @@ key2:
// Missing key2
fs.writeFileSync(path.join(testDir, filePath), "key1: some-value");

const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath, templateName: testTemplateName },
{ directory: testDir } as any,
);
{} as any
));
expect((result as any).output).toContain(
"YAML Structure Validation Failed",
);
Expand All @@ -106,10 +111,10 @@ extraKey: this is fine
`,
);

const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath, templateName: testTemplateName },
{ directory: testDir } as any,
);
{} as any
));
expect((result as any).output).toBe(
"File exists and follows the correct YAML structure.",
);
Expand All @@ -126,10 +131,10 @@ extraKey: this is fine
"key: something\nother: 456",
);

const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath, templateName: nullTemplateName },
{ directory: testDir } as any,
);
{} as any
));

expect((result as any).output).toBe(
"File exists and follows the correct YAML structure.",
Expand All @@ -149,14 +154,22 @@ extraKey: this is fine
// templates dir might not exist or be readable in some contexts, though beforeAll ensures it exists
}

beforeAll(() => {
process.chdir(templatesDir);
});

afterAll(() => {
process.chdir(testDir);
});

for (const templateName of templateFiles) {
test(`should successfully validate a valid instance of ${templateName}`, async () => {
// We use the templates directory as the working directory
// and the template name as the filePath, effectively comparing the template to itself to ensure it's structurally valid.
const result = await verify_template.execute(
const result = await Effect.runPromise(verify_template.execute(
{ filePath: templateName, templateName },
{ directory: templatesDir } as any,
);
{} as any
));
expect((result as any).output).toBe(
"File exists and follows the correct YAML structure.",
);
Expand Down
Loading