@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.
Files changed (97) hide show
  1. package/PLAN.md +497 -0
  2. package/README.md +30 -0
  3. package/dist/commands/add.d.ts +13 -0
  4. package/dist/commands/add.d.ts.map +1 -0
  5. package/dist/commands/add.js +112 -0
  6. package/dist/commands/add.js.map +1 -0
  7. package/dist/commands/config.d.ts +5 -0
  8. package/dist/commands/config.d.ts.map +1 -0
  9. package/dist/commands/config.js +42 -0
  10. package/dist/commands/config.js.map +1 -0
  11. package/dist/commands/list.d.ts +5 -0
  12. package/dist/commands/list.d.ts.map +1 -0
  13. package/dist/commands/list.js +53 -0
  14. package/dist/commands/list.js.map +1 -0
  15. package/dist/commands/remove.d.ts +13 -0
  16. package/dist/commands/remove.d.ts.map +1 -0
  17. package/dist/commands/remove.js +127 -0
  18. package/dist/commands/remove.js.map +1 -0
  19. package/dist/commands/show.d.ts +5 -0
  20. package/dist/commands/show.d.ts.map +1 -0
  21. package/dist/commands/show.js +81 -0
  22. package/dist/commands/show.js.map +1 -0
  23. package/dist/core/agent-detect.d.ts +9 -0
  24. package/dist/core/agent-detect.d.ts.map +1 -0
  25. package/dist/core/agent-detect.js +44 -0
  26. package/dist/core/agent-detect.js.map +1 -0
  27. package/dist/core/agents.d.ts +8 -0
  28. package/dist/core/agents.d.ts.map +1 -0
  29. package/dist/core/agents.js +34 -0
  30. package/dist/core/agents.js.map +1 -0
  31. package/dist/core/config-manager.d.ts +9 -0
  32. package/dist/core/config-manager.d.ts.map +1 -0
  33. package/dist/core/config-manager.js +47 -0
  34. package/dist/core/config-manager.js.map +1 -0
  35. package/dist/core/skill-hash.d.ts +12 -0
  36. package/dist/core/skill-hash.d.ts.map +1 -0
  37. package/dist/core/skill-hash.js +53 -0
  38. package/dist/core/skill-hash.js.map +1 -0
  39. package/dist/core/skill-info.d.ts +35 -0
  40. package/dist/core/skill-info.d.ts.map +1 -0
  41. package/dist/core/skill-info.js +211 -0
  42. package/dist/core/skill-info.js.map +1 -0
  43. package/dist/core/skill-install.d.ts +24 -0
  44. package/dist/core/skill-install.d.ts.map +1 -0
  45. package/dist/core/skill-install.js +123 -0
  46. package/dist/core/skill-install.js.map +1 -0
  47. package/dist/core/skill-source.d.ts +29 -0
  48. package/dist/core/skill-source.d.ts.map +1 -0
  49. package/dist/core/skill-source.js +105 -0
  50. package/dist/core/skill-source.js.map +1 -0
  51. package/dist/index.d.ts +3 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +104 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/types/index.d.ts +57 -0
  56. package/dist/types/index.d.ts.map +1 -0
  57. package/dist/types/index.js +2 -0
  58. package/dist/types/index.js.map +1 -0
  59. package/dist/utils/fuzzy-match.d.ts +16 -0
  60. package/dist/utils/fuzzy-match.d.ts.map +1 -0
  61. package/dist/utils/fuzzy-match.js +37 -0
  62. package/dist/utils/fuzzy-match.js.map +1 -0
  63. package/dist/utils/prompts.d.ts +16 -0
  64. package/dist/utils/prompts.d.ts.map +1 -0
  65. package/dist/utils/prompts.js +80 -0
  66. package/dist/utils/prompts.js.map +1 -0
  67. package/dist/utils/registry.d.ts +6 -0
  68. package/dist/utils/registry.d.ts.map +1 -0
  69. package/dist/utils/registry.js +14 -0
  70. package/dist/utils/registry.js.map +1 -0
  71. package/package.json +43 -0
  72. package/publish.sh +2 -0
  73. package/src/commands/add.ts +137 -0
  74. package/src/commands/config.ts +49 -0
  75. package/src/commands/list.ts +68 -0
  76. package/src/commands/remove.ts +152 -0
  77. package/src/commands/show.ts +93 -0
  78. package/src/core/agent-detect.ts +53 -0
  79. package/src/core/agents.ts +40 -0
  80. package/src/core/config-manager.ts +55 -0
  81. package/src/core/skill-hash.ts +61 -0
  82. package/src/core/skill-info.ts +246 -0
  83. package/src/core/skill-install.ts +165 -0
  84. package/src/core/skill-source.ts +118 -0
  85. package/src/index.ts +116 -0
  86. package/src/types/index.ts +64 -0
  87. package/src/utils/fuzzy-match.ts +48 -0
  88. package/src/utils/prompts.ts +92 -0
  89. package/src/utils/registry.ts +16 -0
  90. package/test/agents.test.ts +86 -0
  91. package/test/fuzzy-match.test.ts +58 -0
  92. package/test/registry.test.ts +48 -0
  93. package/test/skill-hash.test.ts +77 -0
  94. package/test/skill-info.test.ts +195 -0
  95. package/test/skill-source.test.ts +89 -0
  96. package/tsconfig.json +20 -0
  97. 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
+ }
@@ -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
+ });