@sundial-ai/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PLAN.md +497 -0
- package/README.md +30 -0
- package/dist/commands/add.d.ts +13 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +112 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/config.d.ts +5 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +42 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/list.d.ts +5 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +53 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/remove.d.ts +13 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +127 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/show.d.ts +5 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +81 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/core/agent-detect.d.ts +9 -0
- package/dist/core/agent-detect.d.ts.map +1 -0
- package/dist/core/agent-detect.js +44 -0
- package/dist/core/agent-detect.js.map +1 -0
- package/dist/core/agents.d.ts +8 -0
- package/dist/core/agents.d.ts.map +1 -0
- package/dist/core/agents.js +34 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/config-manager.d.ts +9 -0
- package/dist/core/config-manager.d.ts.map +1 -0
- package/dist/core/config-manager.js +47 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/skill-hash.d.ts +12 -0
- package/dist/core/skill-hash.d.ts.map +1 -0
- package/dist/core/skill-hash.js +53 -0
- package/dist/core/skill-hash.js.map +1 -0
- package/dist/core/skill-info.d.ts +35 -0
- package/dist/core/skill-info.d.ts.map +1 -0
- package/dist/core/skill-info.js +211 -0
- package/dist/core/skill-info.js.map +1 -0
- package/dist/core/skill-install.d.ts +24 -0
- package/dist/core/skill-install.d.ts.map +1 -0
- package/dist/core/skill-install.js +123 -0
- package/dist/core/skill-install.js.map +1 -0
- package/dist/core/skill-source.d.ts +29 -0
- package/dist/core/skill-source.d.ts.map +1 -0
- package/dist/core/skill-source.js +105 -0
- package/dist/core/skill-source.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +57 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/fuzzy-match.d.ts +16 -0
- package/dist/utils/fuzzy-match.d.ts.map +1 -0
- package/dist/utils/fuzzy-match.js +37 -0
- package/dist/utils/fuzzy-match.js.map +1 -0
- package/dist/utils/prompts.d.ts +16 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +80 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/registry.d.ts +6 -0
- package/dist/utils/registry.d.ts.map +1 -0
- package/dist/utils/registry.js +14 -0
- package/dist/utils/registry.js.map +1 -0
- package/package.json +43 -0
- package/publish.sh +2 -0
- package/src/commands/add.ts +137 -0
- package/src/commands/config.ts +49 -0
- package/src/commands/list.ts +68 -0
- package/src/commands/remove.ts +152 -0
- package/src/commands/show.ts +93 -0
- package/src/core/agent-detect.ts +53 -0
- package/src/core/agents.ts +40 -0
- package/src/core/config-manager.ts +55 -0
- package/src/core/skill-hash.ts +61 -0
- package/src/core/skill-info.ts +246 -0
- package/src/core/skill-install.ts +165 -0
- package/src/core/skill-source.ts +118 -0
- package/src/index.ts +116 -0
- package/src/types/index.ts +64 -0
- package/src/utils/fuzzy-match.ts +48 -0
- package/src/utils/prompts.ts +92 -0
- package/src/utils/registry.ts +16 -0
- package/test/agents.test.ts +86 -0
- package/test/fuzzy-match.test.ts +58 -0
- package/test/registry.test.ts +48 -0
- package/test/skill-hash.test.ts +77 -0
- package/test/skill-info.test.ts +195 -0
- package/test/skill-source.test.ts +89 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +15 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import {
|
|
6
|
+
isGithubUrl,
|
|
7
|
+
isLocalPath,
|
|
8
|
+
resolveSkillSource
|
|
9
|
+
} from '../src/core/skill-source.js';
|
|
10
|
+
|
|
11
|
+
describe('skill-source', () => {
|
|
12
|
+
describe('isGithubUrl', () => {
|
|
13
|
+
it('returns true for github.com URLs', () => {
|
|
14
|
+
expect(isGithubUrl('github.com/user/repo')).toBe(true);
|
|
15
|
+
expect(isGithubUrl('https://github.com/user/repo')).toBe(true);
|
|
16
|
+
expect(isGithubUrl('http://github.com/user/repo')).toBe(true);
|
|
17
|
+
expect(isGithubUrl('github.com/user/repo/tree/main/skills/tinker')).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('returns false for non-github URLs', () => {
|
|
21
|
+
expect(isGithubUrl('gitlab.com/user/repo')).toBe(false);
|
|
22
|
+
expect(isGithubUrl('./local-path')).toBe(false);
|
|
23
|
+
expect(isGithubUrl('tinker')).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('isLocalPath', () => {
|
|
28
|
+
it('returns true for path-like inputs', () => {
|
|
29
|
+
expect(isLocalPath('./some-path')).toBe(true);
|
|
30
|
+
expect(isLocalPath('../parent-path')).toBe(true);
|
|
31
|
+
expect(isLocalPath('~/home-path')).toBe(true);
|
|
32
|
+
expect(isLocalPath('/absolute/path')).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('returns false for non-paths', () => {
|
|
36
|
+
expect(isLocalPath('tinker')).toBe(false);
|
|
37
|
+
expect(isLocalPath('github.com/user/repo')).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('resolveSkillSource', () => {
|
|
42
|
+
let tempDir: string;
|
|
43
|
+
|
|
44
|
+
beforeEach(async () => {
|
|
45
|
+
tempDir = path.join(os.tmpdir(), `sun-test-${Date.now()}`);
|
|
46
|
+
await fs.ensureDir(tempDir);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(async () => {
|
|
50
|
+
await fs.remove(tempDir);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('resolves shortcuts', () => {
|
|
54
|
+
const source = resolveSkillSource('tinker');
|
|
55
|
+
expect(source.type).toBe('shortcut');
|
|
56
|
+
expect(source.location).toContain('sundial-org/skills');
|
|
57
|
+
expect(source.originalInput).toBe('tinker');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('resolves github URLs', () => {
|
|
61
|
+
const source = resolveSkillSource('github.com/user/my-skill');
|
|
62
|
+
expect(source.type).toBe('github');
|
|
63
|
+
expect(source.location).toBe('user/my-skill');
|
|
64
|
+
expect(source.originalInput).toBe('github.com/user/my-skill');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('resolves github URLs with https prefix', () => {
|
|
68
|
+
const source = resolveSkillSource('https://github.com/user/my-skill');
|
|
69
|
+
expect(source.type).toBe('github');
|
|
70
|
+
expect(source.location).toBe('user/my-skill');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('resolves github tree URLs to degit format', () => {
|
|
74
|
+
const source = resolveSkillSource('https://github.com/sundial-org/skills/tree/main/skills/tinker');
|
|
75
|
+
expect(source.type).toBe('github');
|
|
76
|
+
expect(source.location).toBe('sundial-org/skills/skills/tinker#main');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('resolves local paths', async () => {
|
|
80
|
+
const source = resolveSkillSource(tempDir);
|
|
81
|
+
expect(source.type).toBe('local');
|
|
82
|
+
expect(source.location).toBe(tempDir);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('throws for unknown inputs', () => {
|
|
86
|
+
expect(() => resolveSkillSource('not-a-shortcut-or-path')).toThrow('Skill not found');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"resolveJsonModule": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist", "test"]
|
|
20
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
include: ['test/**/*.test.ts'],
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: 'v8',
|
|
10
|
+
reporter: ['text', 'html'],
|
|
11
|
+
include: ['src/**/*.ts'],
|
|
12
|
+
exclude: ['src/index.ts']
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|