mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-21 06:04:44 +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
125
packages/coding-agent/test/sdk-skills.test.ts
Normal file
125
packages/coding-agent/test/sdk-skills.test.ts
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { createExtensionRuntime } from "../src/core/extensions/loader.js";
|
||||
import type { ResourceLoader } from "../src/core/resource-loader.js";
|
||||
import { createAgentSession } from "../src/core/sdk.js";
|
||||
import { SessionManager } from "../src/core/session-manager.js";
|
||||
|
||||
describe("createAgentSession skills option", () => {
|
||||
let tempDir: string;
|
||||
let skillsDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
tempDir = join(
|
||||
tmpdir(),
|
||||
`pi-sdk-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
||||
);
|
||||
skillsDir = join(tempDir, "skills", "test-skill");
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
|
||||
// Create a test skill in the pi skills directory
|
||||
writeFileSync(
|
||||
join(skillsDir, "SKILL.md"),
|
||||
`---
|
||||
name: test-skill
|
||||
description: A test skill for SDK tests.
|
||||
---
|
||||
|
||||
# Test Skill
|
||||
|
||||
This is a test skill.
|
||||
`,
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (tempDir) {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("should discover skills by default and expose them on session.skills", async () => {
|
||||
const { session } = await createAgentSession({
|
||||
cwd: tempDir,
|
||||
agentDir: tempDir,
|
||||
sessionManager: SessionManager.inMemory(),
|
||||
});
|
||||
|
||||
// Skills should be discovered and exposed on the session
|
||||
expect(session.resourceLoader.getSkills().skills.length).toBeGreaterThan(0);
|
||||
expect(
|
||||
session.resourceLoader
|
||||
.getSkills()
|
||||
.skills.some((s) => s.name === "test-skill"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("should have empty skills when resource loader returns none (--no-skills)", async () => {
|
||||
const resourceLoader: ResourceLoader = {
|
||||
getExtensions: () => ({
|
||||
extensions: [],
|
||||
errors: [],
|
||||
runtime: createExtensionRuntime(),
|
||||
}),
|
||||
getSkills: () => ({ skills: [], diagnostics: [] }),
|
||||
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
||||
getThemes: () => ({ themes: [], diagnostics: [] }),
|
||||
getAgentsFiles: () => ({ agentsFiles: [] }),
|
||||
getSystemPrompt: () => undefined,
|
||||
getAppendSystemPrompt: () => [],
|
||||
getPathMetadata: () => new Map(),
|
||||
extendResources: () => {},
|
||||
reload: async () => {},
|
||||
};
|
||||
|
||||
const { session } = await createAgentSession({
|
||||
cwd: tempDir,
|
||||
agentDir: tempDir,
|
||||
sessionManager: SessionManager.inMemory(),
|
||||
resourceLoader,
|
||||
});
|
||||
|
||||
expect(session.resourceLoader.getSkills().skills).toEqual([]);
|
||||
expect(session.resourceLoader.getSkills().diagnostics).toEqual([]);
|
||||
});
|
||||
|
||||
it("should use provided skills when resource loader supplies them", async () => {
|
||||
const customSkill = {
|
||||
name: "custom-skill",
|
||||
description: "A custom skill",
|
||||
filePath: "/fake/path/SKILL.md",
|
||||
baseDir: "/fake/path",
|
||||
source: "custom" as const,
|
||||
disableModelInvocation: false,
|
||||
};
|
||||
|
||||
const resourceLoader: ResourceLoader = {
|
||||
getExtensions: () => ({
|
||||
extensions: [],
|
||||
errors: [],
|
||||
runtime: createExtensionRuntime(),
|
||||
}),
|
||||
getSkills: () => ({ skills: [customSkill], diagnostics: [] }),
|
||||
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
||||
getThemes: () => ({ themes: [], diagnostics: [] }),
|
||||
getAgentsFiles: () => ({ agentsFiles: [] }),
|
||||
getSystemPrompt: () => undefined,
|
||||
getAppendSystemPrompt: () => [],
|
||||
getPathMetadata: () => new Map(),
|
||||
extendResources: () => {},
|
||||
reload: async () => {},
|
||||
};
|
||||
|
||||
const { session } = await createAgentSession({
|
||||
cwd: tempDir,
|
||||
agentDir: tempDir,
|
||||
sessionManager: SessionManager.inMemory(),
|
||||
resourceLoader,
|
||||
});
|
||||
|
||||
expect(session.resourceLoader.getSkills().skills).toEqual([customSkill]);
|
||||
expect(session.resourceLoader.getSkills().diagnostics).toEqual([]);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue