@sysprompthub/sdk 1.1.0 → 2.0.1

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 (57) hide show
  1. package/README.md +197 -22
  2. package/dist/assistant-manager.d.ts +15 -16
  3. package/dist/assistant-manager.d.ts.map +1 -1
  4. package/dist/assistant-manager.js +29 -19
  5. package/dist/assistant-manager.js.map +1 -1
  6. package/dist/assistant.type.d.ts +1 -0
  7. package/dist/assistant.type.d.ts.map +1 -1
  8. package/dist/assistants/base.d.ts +66 -0
  9. package/dist/assistants/base.d.ts.map +1 -0
  10. package/dist/assistants/base.js +146 -0
  11. package/dist/assistants/base.js.map +1 -0
  12. package/dist/assistants/claude.d.ts +15 -0
  13. package/dist/assistants/claude.d.ts.map +1 -0
  14. package/dist/assistants/claude.js +14 -0
  15. package/dist/assistants/claude.js.map +1 -0
  16. package/dist/assistants/copilot.d.ts +15 -0
  17. package/dist/assistants/copilot.d.ts.map +1 -0
  18. package/dist/assistants/copilot.js +14 -0
  19. package/dist/assistants/copilot.js.map +1 -0
  20. package/dist/assistants/custom.d.ts +24 -0
  21. package/dist/assistants/custom.d.ts.map +1 -0
  22. package/dist/assistants/custom.js +34 -0
  23. package/dist/assistants/custom.js.map +1 -0
  24. package/dist/assistants/index.d.ts +5 -0
  25. package/dist/assistants/index.d.ts.map +1 -0
  26. package/dist/assistants/index.js +5 -0
  27. package/dist/assistants/index.js.map +1 -0
  28. package/dist/base-config-manager.d.ts +16 -7
  29. package/dist/base-config-manager.d.ts.map +1 -1
  30. package/dist/base-config-manager.js +29 -10
  31. package/dist/base-config-manager.js.map +1 -1
  32. package/dist/config-manager.type.d.ts +4 -3
  33. package/dist/config-manager.type.d.ts.map +1 -1
  34. package/dist/config-migration.d.ts +38 -0
  35. package/dist/config-migration.d.ts.map +1 -0
  36. package/dist/config-migration.js +59 -0
  37. package/dist/config-migration.js.map +1 -0
  38. package/dist/config.type.d.ts +30 -8
  39. package/dist/config.type.d.ts.map +1 -1
  40. package/dist/config.type.js +0 -5
  41. package/dist/config.type.js.map +1 -1
  42. package/dist/default-config-manager.d.ts +3 -3
  43. package/dist/default-config-manager.d.ts.map +1 -1
  44. package/dist/default-config-manager.js.map +1 -1
  45. package/dist/index.d.ts +4 -3
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +3 -2
  48. package/dist/index.js.map +1 -1
  49. package/dist/project-config-editor.d.ts +53 -0
  50. package/dist/project-config-editor.d.ts.map +1 -0
  51. package/dist/project-config-editor.js +148 -0
  52. package/dist/project-config-editor.js.map +1 -0
  53. package/dist/sync.d.ts +9 -3
  54. package/dist/sync.d.ts.map +1 -1
  55. package/dist/sync.js +42 -19
  56. package/dist/sync.js.map +1 -1
  57. package/package.json +6 -4
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # @sysprompthub/sdk
2
2
 
3
- SDK for syncing system prompts from SysPromptHub to your projects.
3
+ Node.js SDK for managing and syncing system prompts from [SysPromptHub](https://www.sysprompthub.com) to your AI assistant configurations.
4
+
5
+ > 🌐 Please see [@sysprompthub/cli](https://www.npmjs.com/package/@sysprompthub/cli) for the command-line interface
6
+ >
7
+ > 🌐 For VS Code integration, see the [SysPromptHub Extension](https://marketplace.visualstudio.com/items?itemName=sysprompthub.sysprompthub)
8
+ >
9
+ > ⏳ Jetbrains IDE integration coming soon!
10
+
4
11
 
5
12
  ## Installation
6
13
 
@@ -8,52 +15,220 @@ SDK for syncing system prompts from SysPromptHub to your projects.
8
15
  npm install @sysprompthub/sdk
9
16
  ```
10
17
 
11
- ## Usage
18
+ ## Quick Start
12
19
 
13
20
  ```typescript
14
- import { SyncManager, NodeFileSystem } from '@sysprompthub/sdk';
21
+ import { SyncManager, NodeFileSystem, DefaultConfigManager } from '@sysprompthub/sdk';
15
22
 
16
- // Example 1: Sync with explicit config and Node.js file system
23
+ const syncManager = new SyncManager();
17
24
  const fs = new NodeFileSystem();
18
25
 
19
- const syncManager = new SyncManager();
20
26
  await syncManager.sync({
21
27
  config: {
22
- packName: 'user/pack/latest',
23
- assistants: ['copilot', 'claude']
28
+ apiKey: 'your-api-key',
29
+ packs: [
30
+ { type: 'copilot', pack: 'owner/pack-name/latest' },
31
+ { type: 'claude', pack: 'owner/pack-name/latest' }
32
+ ]
24
33
  },
25
34
  fs
26
35
  });
36
+ ```
37
+
38
+ ## Features
39
+
40
+ - 🔄 **Sync prompts** to GitHub Copilot and Claude Desktop
41
+ - 🎯 **Agent/Skill support** - Configure multiple specialized agents
42
+ - 📁 **Custom paths** - Write prompts to any location
43
+ - 🌍 **Environment support** - Development, local, and production configs
44
+ - 💾 **Project config management** - Edit `.sysprompthub.json` programmatically
45
+
46
+ ## Usage
47
+
48
+ ### Syncing Prompts
49
+
50
+ ```typescript
51
+ import { SyncManager, NodeFileSystem } from '@sysprompthub/sdk';
27
52
 
28
- // Example 2: Sync to a custom path
53
+ const syncManager = new SyncManager();
54
+ const fs = new NodeFileSystem();
55
+
56
+ // Sync multiple assistants
29
57
  await syncManager.sync({
30
58
  config: {
31
- packName: 'user/pack/latest',
32
- path: 'docs/system-prompt.md'
59
+ apiKey: process.env.SYSPROMPTHUB_API_KEY!,
60
+ packs: [
61
+ { type: 'copilot', pack: 'company/general/v1.0.0' },
62
+ { type: 'claude', pack: 'company/general/v1.0.0' },
63
+ {
64
+ type: 'copilot',
65
+ pack: 'company/python-expert/latest',
66
+ agent: {
67
+ name: 'python',
68
+ description: 'Python development expert'
69
+ }
70
+ }
71
+ ]
33
72
  },
34
73
  fs
35
74
  });
36
75
  ```
37
76
 
38
- ## Development
77
+ ### Managing Project Configuration
39
78
 
40
- ```bash
41
- # Install dependencies
42
- npm install
79
+ ```typescript
80
+ import { DefaultConfigManager, ProjectConfigEditor, NodeFileSystem } from '@sysprompthub/sdk';
81
+
82
+ const fs = new NodeFileSystem();
83
+ const manager = new DefaultConfigManager();
84
+
85
+ // Load or create config
86
+ const editor = await manager.load(fs);
87
+
88
+ // Set primary assistant pack
89
+ await editor.set({
90
+ assistant: 'copilot',
91
+ pack: 'owner/pack/latest',
92
+ environment: 'development'
93
+ });
94
+
95
+ // Add an agent
96
+ await editor.addAgent({
97
+ assistant: 'copilot',
98
+ name: 'typescript',
99
+ pack: 'owner/typescript-pack/latest',
100
+ frontMatter: {
101
+ description: 'TypeScript expert',
102
+ model: 'gpt-4'
103
+ }
104
+ });
105
+
106
+ // Add custom path
107
+ await editor.addCustom({
108
+ path: 'docs/prompt.md',
109
+ pack: 'owner/docs-pack/latest'
110
+ });
43
111
 
44
- # Build
45
- npm run build
112
+ // View current configuration
113
+ console.log(editor.packs);
46
114
 
47
- # Run tests
48
- npm test
115
+ // Remove an agent
116
+ await editor.removeAgent('copilot', 'typescript');
49
117
 
50
- # Run tests in watch mode
51
- npm run test:watch
118
+ // Clear all packs for an assistant
119
+ await editor.clearAll('copilot');
120
+ ```
121
+
122
+ ### Working with Configurations
123
+
124
+ ```typescript
125
+ import { DefaultConfigManager, UserConfigManager, NodeFileSystem } from '@sysprompthub/sdk';
52
126
 
53
- # Type check
54
- npm run typecheck
127
+ const fs = new NodeFileSystem();
128
+
129
+ // Project configuration (.sysprompthub.json)
130
+ const projectManager = new DefaultConfigManager();
131
+ const projectEditor = await projectManager.load(fs);
132
+
133
+ // User configuration (~/.sysprompthub/config.json)
134
+ const userManager = new UserConfigManager();
135
+ const userConfig = await userManager.load(fs);
136
+ if (userConfig) {
137
+ console.log('API Key:', userConfig.apiKey);
138
+ }
55
139
  ```
56
140
 
141
+ ## Configuration Format
142
+
143
+ ### Project Config (`.sysprompthub.json`)
144
+
145
+ ```json
146
+ {
147
+ "packs": [
148
+ {
149
+ "type": "copilot",
150
+ "pack": "owner/pack-name/version"
151
+ },
152
+ {
153
+ "type": "copilot",
154
+ "pack": "owner/agent-pack/version",
155
+ "agent": {
156
+ "name": "python",
157
+ "description": "Python expert"
158
+ }
159
+ },
160
+ {
161
+ "type": "claude",
162
+ "pack": "owner/pack-name/version",
163
+ "environment": "development"
164
+ },
165
+ {
166
+ "type": "custom",
167
+ "pack": "owner/custom-pack/version",
168
+ "path": "docs/prompt.md"
169
+ }
170
+ ]
171
+ }
172
+ ```
173
+
174
+ ### User Config (`~/.sysprompthub/config.json`)
175
+
176
+ ```json
177
+ {
178
+ "apiKey": "sph_..."
179
+ }
180
+ ```
181
+
182
+ ## API Reference
183
+
184
+ ### SyncManager
185
+
186
+ Syncs prompts from SysPromptHub to local files.
187
+
188
+ - `sync(workspace: Workspace): Promise<void>` - Download and write prompts
189
+
190
+ ### ProjectConfigEditor
191
+
192
+ Manages project configuration with a fluent API.
193
+
194
+ - `set(options)` - Set/replace assistant root pack
195
+ - `clear(type)` - Remove assistant root pack
196
+ - `clearAll(type)` - Remove all packs for an assistant
197
+ - `find(assistant)` - Find root pack
198
+ - `addAgent(options)` - Add/replace agent pack
199
+ - `removeAgent(assistant, name)` - Remove agent pack
200
+ - `findAgent(assistant, name)` - Find agent pack
201
+ - `addCustom(options)` - Add/replace custom pack
202
+ - `removeCustom(path)` - Remove custom pack
203
+ - `findCustom(path)` - Find custom pack by path
204
+
205
+ ### ConfigManager
206
+
207
+ Interface for loading and saving configurations.
208
+
209
+ - `load(fs)` - Load configuration, returns editor
210
+ - `save(fs, config)` - Save configuration
211
+ - `update(fs, config)` - Update existing configuration
212
+ - `exists(fs)` - Check if configuration exists
213
+
214
+ ## TypeScript Support
215
+
216
+ This package includes full TypeScript definitions.
217
+
218
+ ```typescript
219
+ import type {
220
+ PackConfig,
221
+ ProjectConfig,
222
+ UserConfig,
223
+ AssistantType,
224
+ Environment
225
+ } from '@sysprompthub/sdk';
226
+ ```
227
+
228
+ ## CLI Alternative
229
+
230
+ For command-line usage, see [@sysprompthub/cli](https://www.npmjs.com/package/@sysprompthub/cli).
231
+
57
232
  ## License
58
233
 
59
234
  ISC
@@ -1,31 +1,30 @@
1
- import { AssistantType } from './assistant.type.js';
2
- import { Assistant } from "./assistant.js";
3
- type AssistantCallback = (assistant: Assistant) => void;
1
+ import { Assistant as BaseAssistant } from './assistants/index.js';
2
+ import { PackConfigType, RemovePackConfig } from './config.type.js';
3
+ import { FileSystem } from './file-system.type.js';
4
4
  /**
5
5
  * Manages registered AI assistants and their configurations.
6
- * Provides a singleton registry of all supported assistant types.
7
6
  */
8
7
  export declare class AssistantManager {
9
8
  private static readonly ASSISTANTS;
10
9
  /**
11
- * Iterates over all assistant types and invokes callback for each
12
- * @param callback - Function to call for each assistant
10
+ * Gets an assistant class by pack config type
11
+ * @param type - The pack config type
12
+ * @returns The assistant class
13
13
  */
14
- forEach(callback: AssistantCallback): void;
14
+ getAssistantClass(type: PackConfigType): typeof BaseAssistant;
15
15
  /**
16
- * Iterates over specified assistant types and invokes callback for each
17
- * @param types - Array of assistant types to iterate over
18
- * @param callback - Function to call for each assistant
16
+ * Creates a new assistant instance by pack config type
17
+ * @param type - The pack config type
18
+ * @returns A new assistant instance
19
19
  */
20
- forEach(types: readonly AssistantType[], callback: AssistantCallback): void;
20
+ createAssistant(type: PackConfigType): BaseAssistant;
21
21
  /**
22
- * Gets an assistant by type
23
- * @param type - The assistant type
24
- * @returns The Assistant instance
22
+ * Removes a prompt file for the given pack configuration.
23
+ * @param config - The pack configuration
24
+ * @param fs - The file system interface
25
25
  */
26
- get(type: AssistantType): Assistant;
26
+ removePack(config: RemovePackConfig, fs: FileSystem): Promise<void>;
27
27
  }
28
28
  /** Singleton instance of AssistantManager for convenient access */
29
29
  export declare const assistantManager: AssistantManager;
30
- export {};
31
30
  //# sourceMappingURL=assistant-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-manager.d.ts","sourceRoot":"","sources":["../src/assistant-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAiB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,KAAK,iBAAiB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;AAExD;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAG/B;IAEH;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAC1C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAY3E;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS;CAGpC;AAED,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
1
+ {"version":3,"file":"assistant-manager.d.ts","sourceRoot":"","sources":["../src/assistant-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,SAAS,IAAI,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACrH,OAAO,EAAa,cAAc,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAGjD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAI/B;IAEH;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,aAAa;IAQ7D;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,aAAa;IAKpD;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAI1E;AAED,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
@@ -1,32 +1,42 @@
1
- import { assistantTypes } from './assistant.type.js';
2
- import { Assistant } from "./assistant.js";
1
+ import { CopilotAssistant, ClaudeAssistant, CustomAssistant } from './assistants/index.js';
3
2
  /**
4
3
  * Manages registered AI assistants and their configurations.
5
- * Provides a singleton registry of all supported assistant types.
6
4
  */
7
5
  export class AssistantManager {
8
6
  static ASSISTANTS = Object.freeze({
9
- copilot: new Assistant('copilot', '.github/copilot-instructions.md'),
10
- claude: new Assistant('claude', '.claude/system.md')
7
+ copilot: CopilotAssistant,
8
+ claude: ClaudeAssistant,
9
+ custom: CustomAssistant
11
10
  });
12
- forEach(types, callback) {
13
- if (typeof types === 'function') {
14
- callback = types;
15
- types = assistantTypes;
16
- }
17
- else {
18
- if (typeof callback !== 'function')
19
- throw new Error('Callback is required');
11
+ /**
12
+ * Gets an assistant class by pack config type
13
+ * @param type - The pack config type
14
+ * @returns The assistant class
15
+ */
16
+ getAssistantClass(type) {
17
+ const assistantClass = AssistantManager.ASSISTANTS[type];
18
+ if (!assistantClass) {
19
+ throw new Error(`Unknown assistant type: ${type}`);
20
20
  }
21
- types.forEach(type => callback(AssistantManager.ASSISTANTS[type]));
21
+ return assistantClass;
22
+ }
23
+ /**
24
+ * Creates a new assistant instance by pack config type
25
+ * @param type - The pack config type
26
+ * @returns A new assistant instance
27
+ */
28
+ createAssistant(type) {
29
+ const AssistantClass = this.getAssistantClass(type);
30
+ return new AssistantClass();
22
31
  }
23
32
  /**
24
- * Gets an assistant by type
25
- * @param type - The assistant type
26
- * @returns The Assistant instance
33
+ * Removes a prompt file for the given pack configuration.
34
+ * @param config - The pack configuration
35
+ * @param fs - The file system interface
27
36
  */
28
- get(type) {
29
- return AssistantManager.ASSISTANTS[type];
37
+ async removePack(config, fs) {
38
+ const assistant = this.createAssistant(config.type);
39
+ await assistant.remove(config, fs);
30
40
  }
31
41
  }
32
42
  /** Singleton instance of AssistantManager for convenient access */
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-manager.js","sourceRoot":"","sources":["../src/assistant-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAIzC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAU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;QACzD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,IAAoB;QAClC,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACpD,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,MAAwB,EAAE,EAAc;QACvD,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;;AAGH,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  /** Supported AI assistant types */
2
2
  export declare const assistantTypes: readonly ["copilot", "claude"];
3
3
  export type AssistantType = typeof assistantTypes[number];
4
+ export type FrontMatter = Record<string, string>;
4
5
  //# sourceMappingURL=assistant.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistant.type.d.ts","sourceRoot":"","sources":["../src/assistant.type.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,eAAO,MAAM,cAAc,gCAAiC,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"assistant.type.d.ts","sourceRoot":"","sources":["../src/assistant.type.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,eAAO,MAAM,cAAc,gCAAiC,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { AgentConfig, PackConfig, RemovePackConfig } from '../config.type.js';
2
+ import { FileSystem } from '../file-system.type.js';
3
+ export interface AssistantAgentConfig {
4
+ name: string;
5
+ names: string;
6
+ promptPath: (config: RemovePackConfig) => string;
7
+ }
8
+ /**
9
+ * Base class for all assistant implementations.
10
+ * Provides validation and writing capabilities for assistant-specific prompt configurations.
11
+ */
12
+ export declare class Assistant {
13
+ /**
14
+ * Indicates the assistant's terminology for agents.
15
+ * - String value: the term used (e.g., "agent" for Copilot, "skill" for Claude)
16
+ * - false: assistant does not support agents
17
+ */
18
+ static readonly agents: AssistantAgentConfig | false;
19
+ static readonly promptPath: string | ((config: RemovePackConfig) => string);
20
+ /**
21
+ * Validates a pack configuration for this assistant type.
22
+ * Throws an error if the configuration is invalid.
23
+ * @param config - The pack configuration to validate
24
+ */
25
+ static validate(config: PackConfig): void;
26
+ /**
27
+ * Writes a prompt to the file system according to the pack configuration.
28
+ * Subclasses should override this method.
29
+ * @param config - The pack configuration
30
+ * @param fs - The file system interface
31
+ * @param prompt - The prompt content to write
32
+ */
33
+ write(config: PackConfig, fs: FileSystem, prompt: string): Promise<void>;
34
+ /**
35
+ * Removes a prompt file from the file system according to the pack configuration.
36
+ * Subclasses should override this method.
37
+ * @param config - The pack configuration
38
+ * @param fs - The file system interface
39
+ */
40
+ remove(config: RemovePackConfig, fs: FileSystem): Promise<void>;
41
+ promptPath(config: RemovePackConfig): string;
42
+ protected get agents(): AssistantAgentConfig;
43
+ /**
44
+ * Helper to write a file with frontmatter.
45
+ * @param fs - The file system interface
46
+ * @param path - The file path
47
+ * @param agent - The agent configuration
48
+ * @param prompt - The prompt content
49
+ */
50
+ protected writePromptWithFrontmatter(fs: FileSystem, path: string, agent: AgentConfig, prompt: string): Promise<void>;
51
+ /**
52
+ * Helper to write a root prompt file without frontmatter.
53
+ * @param fs - The file system interface
54
+ * @param path - The file path
55
+ * @param prompt - The prompt content
56
+ */
57
+ protected writePrompt(fs: FileSystem, path: string, prompt: string): Promise<void>;
58
+ /**
59
+ * Formats prompt content with YAML frontmatter.
60
+ * @param agent - The agent configuration
61
+ * @param prompt - The prompt content
62
+ * @returns Formatted content with frontmatter
63
+ */
64
+ protected formatWithFrontmatter(agent: AgentConfig, prompt: string): string;
65
+ }
66
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/assistants/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAGlD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,MAAM,CAAC;CAClD;AAED;;;GAGG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,KAAK,CAAS;IAC7D,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,gBAAgB,KAAK,MAAM,CAAC,CAAK;IAEhF;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IA+CzC;;;;;;OAMG;IACG,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9E;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrE,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM;IAa5C,SAAS,KAAK,MAAM,IAAI,oBAAoB,CAM3C;IAED;;;;;;OAMG;cACa,0BAA0B,CACxC,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;OAKG;cACa,WAAW,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxF;;;;;OAKG;IACH,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;CAW5E"}
@@ -0,0 +1,146 @@
1
+ import { dirname } from 'path';
2
+ /**
3
+ * Base class for all assistant implementations.
4
+ * Provides validation and writing capabilities for assistant-specific prompt configurations.
5
+ */
6
+ export class Assistant {
7
+ /**
8
+ * Indicates the assistant's terminology for agents.
9
+ * - String value: the term used (e.g., "agent" for Copilot, "skill" for Claude)
10
+ * - false: assistant does not support agents
11
+ */
12
+ static agents = false;
13
+ static promptPath = '';
14
+ /**
15
+ * Validates a pack configuration for this assistant type.
16
+ * Throws an error if the configuration is invalid.
17
+ * @param config - The pack configuration to validate
18
+ */
19
+ static validate(config) {
20
+ // Validate pack name format: owner/pack/version
21
+ const packRegex = /^[a-z0-9_-]+\/[a-z0-9_-]+\/[a-z0-9_.-]+$/i;
22
+ if (!packRegex.test(config.pack)) {
23
+ throw new Error(`Invalid pack name format: ${config.pack}. Expected format: owner/pack/version`);
24
+ }
25
+ // Validate environment if provided
26
+ if (config.environment && !['development', 'local'].includes(config.environment)) {
27
+ throw new Error(`Invalid environment: ${config.environment}. Must be 'development' or 'local'`);
28
+ }
29
+ // Validate agent config if provided
30
+ if ('agent' in config && config.agent) {
31
+ if (this.agents === false) {
32
+ throw new Error(`${config.type} does not support agents`);
33
+ }
34
+ if (!config.agent.name) {
35
+ throw new Error('Agent name is required');
36
+ }
37
+ // Validate agent name format: lowercase alphanumeric, hyphens, underscores
38
+ const nameRegex = /^[a-z0-9_-]+$/;
39
+ if (!nameRegex.test(config.agent.name)) {
40
+ throw new Error(`Invalid agent name: ${config.agent.name}. Must contain only lowercase letters, numbers, hyphens, and underscores`);
41
+ }
42
+ // Validate all frontmatter values are strings
43
+ for (const [key, value] of Object.entries(config.agent)) {
44
+ if (value !== undefined && typeof value !== 'string') {
45
+ throw new Error(`Agent frontmatter value for '${key}' must be a string, got ${typeof value}`);
46
+ }
47
+ }
48
+ }
49
+ // Custom type must have path
50
+ if (config.type === 'custom' && !config.path) {
51
+ throw new Error('Custom pack configuration must include a path');
52
+ }
53
+ // Non-custom types must not have path
54
+ if (config.type !== 'custom' && 'path' in config) {
55
+ throw new Error(`Path is only allowed for custom pack configurations, not for ${config.type}`);
56
+ }
57
+ }
58
+ /**
59
+ * Writes a prompt to the file system according to the pack configuration.
60
+ * Subclasses should override this method.
61
+ * @param config - The pack configuration
62
+ * @param fs - The file system interface
63
+ * @param prompt - The prompt content to write
64
+ */
65
+ async write(config, fs, prompt) {
66
+ if ('agent' in config && config.agent) {
67
+ await this.writePromptWithFrontmatter(fs, this.promptPath(config), config.agent, prompt);
68
+ }
69
+ else {
70
+ await this.writePrompt(fs, this.promptPath(config), prompt);
71
+ }
72
+ }
73
+ /**
74
+ * Removes a prompt file from the file system according to the pack configuration.
75
+ * Subclasses should override this method.
76
+ * @param config - The pack configuration
77
+ * @param fs - The file system interface
78
+ */
79
+ async remove(config, fs) {
80
+ if ('agent' in config && config.agent) {
81
+ await fs.delete(this.agents.promptPath(config));
82
+ }
83
+ else {
84
+ await fs.delete(this.promptPath(config));
85
+ }
86
+ }
87
+ promptPath(config) {
88
+ if ('agent' in config && config.agent) {
89
+ return this.agents.promptPath(config);
90
+ }
91
+ const promptPath = this.constructor['promptPath'];
92
+ if (typeof promptPath === 'string') {
93
+ return promptPath;
94
+ }
95
+ else {
96
+ return promptPath(config);
97
+ }
98
+ }
99
+ get agents() {
100
+ const agents = this.constructor['agents'];
101
+ if (!agents) {
102
+ throw new Error('This assistant does not support agents');
103
+ }
104
+ return agents;
105
+ }
106
+ /**
107
+ * Helper to write a file with frontmatter.
108
+ * @param fs - The file system interface
109
+ * @param path - The file path
110
+ * @param agent - The agent configuration
111
+ * @param prompt - The prompt content
112
+ */
113
+ async writePromptWithFrontmatter(fs, path, agent, prompt) {
114
+ if (!agent) {
115
+ throw new Error('Agent config is required for frontmatter');
116
+ }
117
+ const content = this.formatWithFrontmatter(agent, prompt);
118
+ await this.writePrompt(fs, path, content);
119
+ }
120
+ /**
121
+ * Helper to write a root prompt file without frontmatter.
122
+ * @param fs - The file system interface
123
+ * @param path - The file path
124
+ * @param prompt - The prompt content
125
+ */
126
+ async writePrompt(fs, path, prompt) {
127
+ await fs.createDir(dirname(path));
128
+ await fs.write(path, prompt);
129
+ }
130
+ /**
131
+ * Formats prompt content with YAML frontmatter.
132
+ * @param agent - The agent configuration
133
+ * @param prompt - The prompt content
134
+ * @returns Formatted content with frontmatter
135
+ */
136
+ formatWithFrontmatter(agent, prompt) {
137
+ if (!agent) {
138
+ throw new Error('Agent config is required for frontmatter');
139
+ }
140
+ const frontmatterLines = Object.entries(agent)
141
+ .filter(([_, value]) => value !== undefined)
142
+ .map(([key, value]) => `${key}: ${value}`);
143
+ return `---\n${frontmatterLines.join('\n')}\n---\n\n${prompt}`;
144
+ }
145
+ }
146
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/assistants/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAQ7B;;;GAGG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAU,MAAM,GAAiC,KAAK,CAAC;IAC7D,MAAM,CAAU,UAAU,GAAoD,EAAE,CAAA;IAEhF;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAkB;QA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,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACO,qBAAqB,CAAC,KAAkB,EAAE,MAAc;QAChE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aAC3C,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;aAC3C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,KAAK,EAAE,CAAC,CAAC;QAE7C,OAAO,QAAQ,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,MAAM,EAAE,CAAC;IACjE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { Assistant } from './base.js';
2
+ import { RemovePackConfig } from "../config.type.js";
3
+ /**
4
+ * Claude assistant implementation.
5
+ * Supports both root prompts and skill-specific prompts.
6
+ */
7
+ export declare class ClaudeAssistant extends Assistant {
8
+ static readonly promptPath = ".claude/system.md";
9
+ static readonly agents: {
10
+ name: string;
11
+ names: string;
12
+ promptPath: (config: RemovePackConfig) => string;
13
+ };
14
+ }
15
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/assistants/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,EAA4B,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAE9E;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,QAAQ,CAAC,UAAU,uBAAsB;IAChD,MAAM,CAAC,QAAQ,CAAC,MAAM;;;6BAGC,gBAAgB;MACrC;CACH"}
@@ -0,0 +1,14 @@
1
+ import { Assistant } from './base.js';
2
+ /**
3
+ * Claude assistant implementation.
4
+ * Supports both root prompts and skill-specific prompts.
5
+ */
6
+ export class ClaudeAssistant extends Assistant {
7
+ static promptPath = '.claude/system.md';
8
+ static agents = {
9
+ name: 'skill',
10
+ names: 'skills',
11
+ promptPath: (config) => `.claude/skills/${config.agent.name}/SKILL.md`
12
+ };
13
+ }
14
+ //# sourceMappingURL=claude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/assistants/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAGpC;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAU,UAAU,GAAG,mBAAmB,CAAA;IAChD,MAAM,CAAU,MAAM,GAAG;QACvB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,QAAQ;QACf,UAAU,EAAE,CAAC,MAAwB,EAAE,EAAE,CAAC,kBAAmB,MAAoC,CAAC,KAAM,CAAC,IAAI,WAAW;KACzH,CAAC"}