mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-16 18:03:53 +00:00
move pi-mono into companion-cloud as apps/companion-os
- Copy all pi-mono source into apps/companion-os/ - Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases - Update deploy-staging.yml to build pi from source (bun compile) before Docker build - Add apps/companion-os/** to path triggers - No more cross-repo dispatch needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
0250f72976
579 changed files with 206942 additions and 0 deletions
72
packages/coding-agent/test/frontmatter.test.ts
Normal file
72
packages/coding-agent/test/frontmatter.test.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
parseFrontmatter,
|
||||
stripFrontmatter,
|
||||
} from "../src/utils/frontmatter.js";
|
||||
|
||||
describe("parseFrontmatter", () => {
|
||||
it("parses keys, strips quotes, and returns body", () => {
|
||||
const input =
|
||||
"---\nname: \"skill-name\"\ndescription: 'A desc'\nfoo-bar: value\n---\n\nBody text";
|
||||
const { frontmatter, body } =
|
||||
parseFrontmatter<Record<string, string>>(input);
|
||||
expect(frontmatter.name).toBe("skill-name");
|
||||
expect(frontmatter.description).toBe("A desc");
|
||||
expect(frontmatter["foo-bar"]).toBe("value");
|
||||
expect(body).toBe("Body text");
|
||||
});
|
||||
|
||||
it("normalizes newlines and handles CRLF", () => {
|
||||
const input = "---\r\nname: test\r\n---\r\nLine one\r\nLine two";
|
||||
const { body } = parseFrontmatter<Record<string, string>>(input);
|
||||
expect(body).toBe("Line one\nLine two");
|
||||
});
|
||||
|
||||
it("throws on invalid YAML frontmatter", () => {
|
||||
const input = "---\nfoo: [bar\n---\nBody";
|
||||
expect(() => parseFrontmatter<Record<string, string>>(input)).toThrow(
|
||||
/at line 1, column 10/,
|
||||
);
|
||||
});
|
||||
|
||||
it("parses | multiline yaml syntax", () => {
|
||||
const input = "---\ndescription: |\n Line one\n Line two\n---\n\nBody";
|
||||
const { frontmatter, body } =
|
||||
parseFrontmatter<Record<string, string>>(input);
|
||||
expect(frontmatter.description).toBe("Line one\nLine two\n");
|
||||
expect(body).toBe("Body");
|
||||
});
|
||||
|
||||
it("returns original content when frontmatter is missing or unterminated", () => {
|
||||
const noFrontmatter = "Just text\nsecond line";
|
||||
const missingEnd = "---\nname: test\nBody without terminator";
|
||||
const resultNoFrontmatter =
|
||||
parseFrontmatter<Record<string, string>>(noFrontmatter);
|
||||
const resultMissingEnd =
|
||||
parseFrontmatter<Record<string, string>>(missingEnd);
|
||||
expect(resultNoFrontmatter.body).toBe("Just text\nsecond line");
|
||||
expect(resultMissingEnd.body).toBe(
|
||||
"---\nname: test\nBody without terminator"
|
||||
.replace(/\r\n/g, "\n")
|
||||
.replace(/\r/g, "\n"),
|
||||
);
|
||||
});
|
||||
|
||||
it("returns empty object for empty or comment-only frontmatter", () => {
|
||||
const input = "---\n# just a comment\n---\nBody";
|
||||
const { frontmatter } = parseFrontmatter(input);
|
||||
expect(frontmatter).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("stripFrontmatter", () => {
|
||||
it("removes frontmatter and trims body", () => {
|
||||
const input = "---\nkey: value\n---\n\nBody\n";
|
||||
expect(stripFrontmatter(input)).toBe("Body");
|
||||
});
|
||||
|
||||
it("returns body when no frontmatter present", () => {
|
||||
const input = "\n No frontmatter body \n";
|
||||
expect(stripFrontmatter(input)).toBe("\n No frontmatter body \n");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue