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
11 changes: 10 additions & 1 deletion src/commands/skill/skill.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mkdir, readFile, rm, stat } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { homedir, tmpdir } from 'node:os'
import { join } from 'node:path'
import { captureConsole, createTestProgram } from '@doist/cli-core/testing'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
Expand Down Expand Up @@ -102,6 +102,15 @@ describe('installer paths', () => {
}
})

describe('Pi installer paths', () => {
it('installs global skills under the Pi agent directory', () => {
const expectedPath = join(homedir(), '.pi', 'agent', 'skills', 'comms-cli', 'SKILL.md')

expect(skillInstallers.pi.getInstallPath({})).toBe(expectedPath)
expect(skillInstallers.pi.getInstallPath({ local: false })).toBe(expectedPath)
})
})

describe('installer operations', () => {
let testDir: string
const originalCwd = process.cwd()
Expand Down
4 changes: 3 additions & 1 deletion src/lib/skills/create-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ interface InstallerConfig {
name: string
description: string
dirName: string
globalDirName?: string
}

export function createInstaller(config: InstallerConfig): SkillInstaller {
function getInstallPath(options: { local?: boolean }): string {
const base = options.local ? process.cwd() : homedir()
return join(base, config.dirName, 'skills', SKILL_NAME, 'SKILL.md')
const dirName = options.local ? config.dirName : (config.globalDirName ?? config.dirName)
return join(base, dirName, 'skills', SKILL_NAME, 'SKILL.md')
}

return {
Expand Down
1 change: 1 addition & 0 deletions src/lib/skills/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const skillInstallers: Record<string, SkillInstaller> = {
name: 'pi',
description: 'Pi skill for Comms CLI',
dirName: '.pi',
globalDirName: '.pi/agent',
}),
universal: createInstaller({
name: 'universal',
Expand Down
Loading