@sysprompthub/sdk 0.1.0 → 0.2.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/README.md +17 -101
- package/dist/assistant-manager.d.ts +21 -0
- package/dist/assistant-manager.d.ts.map +1 -0
- package/dist/assistant-manager.js +31 -0
- package/dist/assistant-manager.js.map +1 -0
- package/dist/assistant.d.ts +16 -0
- package/dist/assistant.d.ts.map +1 -0
- package/dist/assistant.js +22 -0
- package/dist/assistant.js.map +1 -0
- package/dist/base-config-manager.d.ts +46 -0
- package/dist/base-config-manager.d.ts.map +1 -0
- package/dist/base-config-manager.js +65 -0
- package/dist/base-config-manager.js.map +1 -0
- package/dist/client.d.ts +24 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +41 -3
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +6 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -61
- package/dist/config.js.map +1 -1
- package/dist/default-config-manager.d.ts +22 -0
- package/dist/default-config-manager.d.ts.map +1 -0
- package/dist/default-config-manager.js +31 -0
- package/dist/default-config-manager.js.map +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/node-file-system.d.ts +52 -0
- package/dist/node-file-system.d.ts.map +1 -0
- package/dist/node-file-system.js +87 -0
- package/dist/node-file-system.js.map +1 -0
- package/dist/prompt.d.ts +31 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +46 -0
- package/dist/prompt.js.map +1 -0
- package/dist/sync.d.ts +9 -4
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +29 -21
- package/dist/sync.js.map +1 -1
- package/dist/types.d.ts +36 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -1
- package/dist/types.js.map +1 -1
- package/dist/vscode-config-manager.d.ts +23 -0
- package/dist/vscode-config-manager.d.ts.map +1 -0
- package/dist/vscode-config-manager.js +50 -0
- package/dist/vscode-config-manager.js.map +1 -0
- package/dist/vscode-config.d.ts +4 -26
- package/dist/vscode-config.d.ts.map +1 -1
- package/dist/vscode-config.js +4 -89
- package/dist/vscode-config.js.map +1 -1
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -11,114 +11,30 @@ npm install @sysprompthub/sdk
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { SyncManager,
|
|
14
|
+
import { SyncManager, NodeFileSystem } from '@sysprompthub/sdk';
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
const
|
|
16
|
+
// Example 1: Sync with explicit config and Node.js file system
|
|
17
|
+
const fs = new NodeFileSystem();
|
|
18
|
+
|
|
19
|
+
const syncManager = new SyncManager();
|
|
18
20
|
await syncManager.sync({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
config: {
|
|
22
|
+
packName: 'user/pack/latest',
|
|
23
|
+
assistants: ['copilot', 'claude']
|
|
24
|
+
},
|
|
25
|
+
fs
|
|
22
26
|
});
|
|
23
27
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for (const assistant of assistantManager.getAssistants()) {
|
|
32
|
-
await assistant.writePrompt('/path/to/project', prompt);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Configuration management
|
|
36
|
-
const configManager = new ConfigManager(process.cwd());
|
|
37
|
-
const config = await configManager.load();
|
|
38
|
-
await configManager.update({
|
|
39
|
-
packName: 'user/pack/latest',
|
|
40
|
-
assistants: ['copilot']
|
|
28
|
+
// Example 2: Sync to a custom path
|
|
29
|
+
await syncManager.sync({
|
|
30
|
+
config: {
|
|
31
|
+
packName: 'user/pack/latest',
|
|
32
|
+
path: 'docs/system-prompt.md'
|
|
33
|
+
},
|
|
34
|
+
fs
|
|
41
35
|
});
|
|
42
36
|
```
|
|
43
37
|
|
|
44
|
-
## API
|
|
45
|
-
|
|
46
|
-
### `SyncManager`
|
|
47
|
-
|
|
48
|
-
Manages syncing prompt packs to your project.
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
const syncManager = new SyncManager(cwd);
|
|
52
|
-
const prompt = await syncManager.sync(options);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### `SysPromptHubClient`
|
|
56
|
-
|
|
57
|
-
Client for fetching prompt packs from the API.
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
const client = new SysPromptHubClient(apiUrl?);
|
|
61
|
-
const prompt = await client.fetchPack(packName);
|
|
62
|
-
client.clearCache();
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### `ConfigManager`
|
|
66
|
-
|
|
67
|
-
Manages `.sysprompthub.json` configuration files.
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
const configManager = new ConfigManager(cwd);
|
|
71
|
-
const config = await configManager.load();
|
|
72
|
-
await configManager.update(updates);
|
|
73
|
-
await configManager.save(config);
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### `VscodeConfigManager`
|
|
77
|
-
|
|
78
|
-
Manages `.vscode/settings.json` for VSCode integration.
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
const vscodeManager = new VscodeConfigManager(cwd);
|
|
82
|
-
const config = await vscodeManager.load();
|
|
83
|
-
await vscodeManager.update(updates);
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### `AssistantManager`
|
|
87
|
-
|
|
88
|
-
Manages AI assistants (Copilot, Claude).
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
const manager = new AssistantManager(['copilot', 'claude']);
|
|
92
|
-
const assistants = manager.getAssistants();
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### `Assistant`
|
|
96
|
-
|
|
97
|
-
Individual assistant for writing prompts.
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
const assistant = new Assistant('copilot', '.github/copilot-instructions.md');
|
|
101
|
-
await assistant.writePrompt(baseDir, prompt);
|
|
102
|
-
await assistant.clearPrompt(baseDir);
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Supported Assistants
|
|
106
|
-
|
|
107
|
-
- **GitHub Copilot**: Writes to `.github/copilot-instructions.md`
|
|
108
|
-
- **Claude**: Writes to `.claude/system.md`
|
|
109
|
-
|
|
110
|
-
## Types
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
import type {
|
|
114
|
-
AssistantType,
|
|
115
|
-
SyncOptions,
|
|
116
|
-
Config,
|
|
117
|
-
Environment,
|
|
118
|
-
InitVscodeOptions
|
|
119
|
-
} from '@sysprompthub/sdk';
|
|
120
|
-
```
|
|
121
|
-
|
|
122
38
|
## Development
|
|
123
39
|
|
|
124
40
|
```bash
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AssistantType } from './types.js';
|
|
2
|
+
import { Assistant } from "./assistant.js";
|
|
3
|
+
/**
|
|
4
|
+
* Manages registered AI assistants and their configurations
|
|
5
|
+
*/
|
|
6
|
+
export declare class AssistantManager {
|
|
7
|
+
private static readonly ASSISTANTS;
|
|
8
|
+
/**
|
|
9
|
+
* Iterates over specified assistant types and invokes callback for each
|
|
10
|
+
* @param types - Array of assistant types to iterate over
|
|
11
|
+
* @param callback - Function to call for each assistant
|
|
12
|
+
*/
|
|
13
|
+
forEach(types: AssistantType[], callback: (assistant: Assistant) => void): void;
|
|
14
|
+
/**
|
|
15
|
+
* Gets an assistant by type
|
|
16
|
+
* @param type - The assistant type
|
|
17
|
+
* @returns The Assistant instance
|
|
18
|
+
*/
|
|
19
|
+
get(type: AssistantType): Assistant;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=assistant-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-manager.d.ts","sourceRoot":"","sources":["../src/assistant-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAG/B;IAEH;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI;IAIxE;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS;CAGpC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssistantManager = void 0;
|
|
4
|
+
const assistant_js_1 = require("./assistant.js");
|
|
5
|
+
/**
|
|
6
|
+
* Manages registered AI assistants and their configurations
|
|
7
|
+
*/
|
|
8
|
+
class AssistantManager {
|
|
9
|
+
static ASSISTANTS = Object.freeze({
|
|
10
|
+
copilot: new assistant_js_1.Assistant('copilot', '.github/copilot-instructions.md'),
|
|
11
|
+
claude: new assistant_js_1.Assistant('claude', '.claude/system.md')
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Iterates over specified assistant types and invokes callback for each
|
|
15
|
+
* @param types - Array of assistant types to iterate over
|
|
16
|
+
* @param callback - Function to call for each assistant
|
|
17
|
+
*/
|
|
18
|
+
forEach(types, callback) {
|
|
19
|
+
types.forEach(type => callback(AssistantManager.ASSISTANTS[type]));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets an assistant by type
|
|
23
|
+
* @param type - The assistant type
|
|
24
|
+
* @returns The Assistant instance
|
|
25
|
+
*/
|
|
26
|
+
get(type) {
|
|
27
|
+
return AssistantManager.ASSISTANTS[type];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.AssistantManager = AssistantManager;
|
|
31
|
+
//# sourceMappingURL=assistant-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-manager.js","sourceRoot":"","sources":["../src/assistant-manager.ts"],"names":[],"mappings":";;;AACA,iDAAyC;AAEzC;;GAEG;AACH,MAAa,gBAAgB;IACnB,MAAM,CAAU,UAAU,GAA+C,MAAM,CAAC,MAAM,CAAC;QAC7F,OAAO,EAAE,IAAI,wBAAS,CAAC,SAAS,EAAE,iCAAiC,CAAC;QACpE,MAAM,EAAE,IAAI,wBAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC;KACrD,CAAC,CAAC;IAEH;;;;OAIG;IACH,OAAO,CAAC,KAAsB,EAAE,QAAwC;QACtE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAmB;QACrB,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;;AAtBH,4CAuBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AssistantType } from "./types.js";
|
|
2
|
+
import { Prompt } from "./prompt.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents an AI assistant configuration with its prompt file location
|
|
5
|
+
*/
|
|
6
|
+
export declare class Assistant {
|
|
7
|
+
readonly type: AssistantType;
|
|
8
|
+
readonly prompt: Prompt;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Assistant
|
|
11
|
+
* @param type - The type of assistant (e.g., 'copilot', 'claude')
|
|
12
|
+
* @param promptPath - Relative path to the prompt file
|
|
13
|
+
*/
|
|
14
|
+
constructor(type: AssistantType, promptPath: string);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=assistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.d.ts","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAY,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC;;GAEG;AACH,qBAAa,SAAS;IACpB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;;OAIG;gBACS,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM;CAIpD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Assistant = void 0;
|
|
4
|
+
const prompt_js_1 = require("./prompt.js");
|
|
5
|
+
/**
|
|
6
|
+
* Represents an AI assistant configuration with its prompt file location
|
|
7
|
+
*/
|
|
8
|
+
class Assistant {
|
|
9
|
+
type;
|
|
10
|
+
prompt;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Assistant
|
|
13
|
+
* @param type - The type of assistant (e.g., 'copilot', 'claude')
|
|
14
|
+
* @param promptPath - Relative path to the prompt file
|
|
15
|
+
*/
|
|
16
|
+
constructor(type, promptPath) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.prompt = new prompt_js_1.Prompt(promptPath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Assistant = Assistant;
|
|
22
|
+
//# sourceMappingURL=assistant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.js","sourceRoot":"","sources":["../src/assistant.ts"],"names":[],"mappings":";;;AAEA,2CAAmC;AAEnC;;GAEG;AACH,MAAa,SAAS;IACX,IAAI,CAAgB;IACpB,MAAM,CAAS;IAExB;;;;OAIG;IACH,YAAY,IAAmB,EAAE,UAAkB;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAM,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AAbD,8BAaC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Config, ConfigManager, FileSystem } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for configuration managers with serialization support
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseConfigManager implements ConfigManager {
|
|
6
|
+
protected readonly configPath: string;
|
|
7
|
+
protected constructor(configPath: string);
|
|
8
|
+
/**
|
|
9
|
+
* Checks if configuration file exists
|
|
10
|
+
* @param fs - File system to check
|
|
11
|
+
* @returns True if config file exists
|
|
12
|
+
*/
|
|
13
|
+
exists(fs: FileSystem): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Loads configuration from file system
|
|
16
|
+
* @param fs - File system to load from
|
|
17
|
+
* @returns The configuration or null if not found
|
|
18
|
+
*/
|
|
19
|
+
load(fs: FileSystem): Promise<Config | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Updates configuration with partial values
|
|
22
|
+
* @param fs - File system to write to
|
|
23
|
+
* @param updates - Partial configuration updates
|
|
24
|
+
*/
|
|
25
|
+
update(fs: FileSystem, updates: Partial<Config>): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Deserializes configuration from string format
|
|
28
|
+
* @param content - String content to deserialize
|
|
29
|
+
* @returns Parsed configuration
|
|
30
|
+
*/
|
|
31
|
+
protected abstract deserialize(content: string): Config;
|
|
32
|
+
/**
|
|
33
|
+
* Serializes configuration to string format
|
|
34
|
+
* @param config - Configuration to serialize
|
|
35
|
+
* @param fs - File system for reading existing data if needed
|
|
36
|
+
* @returns Serialized configuration string
|
|
37
|
+
*/
|
|
38
|
+
protected abstract serialize(config: Config, fs: FileSystem): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Loads raw configuration data from file system
|
|
41
|
+
* @param fs - File system to load from
|
|
42
|
+
* @returns Raw configuration string or null if not found
|
|
43
|
+
*/
|
|
44
|
+
protected loadConfigData(fs: FileSystem): Promise<string | null>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=base-config-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-config-manager.d.ts","sourceRoot":"","sources":["../src/base-config-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,aAAa,EAAkB,UAAU,EAAC,MAAM,YAAY,CAAC;AAG7E;;GAEG;AACH,8BAAsB,iBAAkB,YAAW,aAAa;IACxC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM;IAA3D,SAAS,aAAgC,UAAU,EAAE,MAAM;IAE3D;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxC;;;;OAIG;IACG,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAWlD;;;;OAIG;IACG,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASrE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAEvD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAE7E;;;;OAIG;cACa,cAAc,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAOvE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseConfigManager = void 0;
|
|
4
|
+
const types_js_1 = require("./types.js");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Base class for configuration managers with serialization support
|
|
8
|
+
*/
|
|
9
|
+
class BaseConfigManager {
|
|
10
|
+
configPath;
|
|
11
|
+
constructor(configPath) {
|
|
12
|
+
this.configPath = configPath;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Checks if configuration file exists
|
|
16
|
+
* @param fs - File system to check
|
|
17
|
+
* @returns True if config file exists
|
|
18
|
+
*/
|
|
19
|
+
exists(fs) {
|
|
20
|
+
return fs.exists(this.configPath);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Loads configuration from file system
|
|
24
|
+
* @param fs - File system to load from
|
|
25
|
+
* @returns The configuration or null if not found
|
|
26
|
+
*/
|
|
27
|
+
async load(fs) {
|
|
28
|
+
const content = await this.loadConfigData(fs);
|
|
29
|
+
if (content === null)
|
|
30
|
+
return null;
|
|
31
|
+
try {
|
|
32
|
+
return this.deserialize(content);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Updates configuration with partial values
|
|
40
|
+
* @param fs - File system to write to
|
|
41
|
+
* @param updates - Partial configuration updates
|
|
42
|
+
*/
|
|
43
|
+
async update(fs, updates) {
|
|
44
|
+
const currentConfig = await this.load(fs) || types_js_1.DEFAULT_CONFIG;
|
|
45
|
+
const newConfig = { ...currentConfig, ...updates };
|
|
46
|
+
const serialized = await this.serialize(newConfig, fs);
|
|
47
|
+
await fs.createDir((0, path_1.dirname)(this.configPath));
|
|
48
|
+
await fs.write(this.configPath, serialized);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Loads raw configuration data from file system
|
|
52
|
+
* @param fs - File system to load from
|
|
53
|
+
* @returns Raw configuration string or null if not found
|
|
54
|
+
*/
|
|
55
|
+
async loadConfigData(fs) {
|
|
56
|
+
try {
|
|
57
|
+
return await fs.read(this.configPath);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.BaseConfigManager = BaseConfigManager;
|
|
65
|
+
//# sourceMappingURL=base-config-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-config-manager.js","sourceRoot":"","sources":["../src/base-config-manager.ts"],"names":[],"mappings":";;;AAAA,yCAA6E;AAC7E,+BAA6B;AAE7B;;GAEG;AACH,MAAsB,iBAAiB;IACI;IAAzC,YAAyC,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;IAAG,CAAC;IAE/D;;;;OAIG;IACH,MAAM,CAAC,EAAc;QACnB,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,EAAc;QACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAElC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,EAAc,EAAE,OAAwB;QACnD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,yBAAc,CAAC;QAC5D,MAAM,SAAS,GAAG,EAAC,GAAG,aAAa,EAAE,GAAG,OAAO,EAAC,CAAC;QAEjD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,CAAC,SAAS,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC7C,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAiBD;;;;OAIG;IACO,KAAK,CAAC,cAAc,CAAC,EAAc;QAC3C,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AArED,8CAqEC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
+
import { Environment } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Client for fetching system prompt packs from SysPromptHub API
|
|
4
|
+
*/
|
|
1
5
|
export declare class SysPromptHubClient {
|
|
2
6
|
private readonly apiUrl;
|
|
3
7
|
private cache;
|
|
4
|
-
|
|
8
|
+
private static readonly API_URLS;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new SysPromptHub client
|
|
11
|
+
* @param environment - The API environment to use
|
|
12
|
+
*/
|
|
13
|
+
constructor(environment?: Environment);
|
|
14
|
+
/**
|
|
15
|
+
* Validates pack name format (user/pack/version)
|
|
16
|
+
* @param packName - Pack name to validate
|
|
17
|
+
* @returns True if pack name is valid
|
|
18
|
+
*/
|
|
19
|
+
static validatePackName(packName: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches a system prompt pack from the API
|
|
22
|
+
* @param packName - Pack name in format user/pack/version
|
|
23
|
+
* @returns The prompt pack content
|
|
24
|
+
*/
|
|
5
25
|
fetchPack(packName: string): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Clears the pack cache
|
|
28
|
+
*/
|
|
6
29
|
clearCache(): void;
|
|
7
30
|
}
|
|
8
31
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,KAAK,CAAkC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAsB,MAAM,YAAY,CAAC;AAE5D;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,KAAK,CAAkC;IAE/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAK9B;IAEF;;;OAGG;gBACS,WAAW,GAAE,WAAiC;IAI1D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKlD;;;;OAIG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBlD;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB"}
|
package/dist/client.js
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SysPromptHubClient = void 0;
|
|
4
|
+
const types_js_1 = require("./types.js");
|
|
5
|
+
/**
|
|
6
|
+
* Client for fetching system prompt packs from SysPromptHub API
|
|
7
|
+
*/
|
|
8
|
+
class SysPromptHubClient {
|
|
2
9
|
apiUrl;
|
|
3
10
|
cache = new Map();
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
static API_URLS = {
|
|
12
|
+
local: 'http://localhost:3000',
|
|
13
|
+
development: 'https://api-dev.sysprompthub.com',
|
|
14
|
+
staging: 'https://api-stg.sysprompthub.com',
|
|
15
|
+
production: 'https://api.sysprompthub.com',
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new SysPromptHub client
|
|
19
|
+
* @param environment - The API environment to use
|
|
20
|
+
*/
|
|
21
|
+
constructor(environment = types_js_1.DEFAULT_ENVIRONMENT) {
|
|
22
|
+
this.apiUrl = SysPromptHubClient.API_URLS[environment];
|
|
6
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Validates pack name format (user/pack/version)
|
|
26
|
+
* @param packName - Pack name to validate
|
|
27
|
+
* @returns True if pack name is valid
|
|
28
|
+
*/
|
|
29
|
+
static validatePackName(packName) {
|
|
30
|
+
const pattern = /^[a-z][a-z0-9-]*[a-z0-9]\/[a-z][a-z0-9-]*[a-z0-9]\/(latest|\d{1,5})$/;
|
|
31
|
+
return pattern.test(packName);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fetches a system prompt pack from the API
|
|
35
|
+
* @param packName - Pack name in format user/pack/version
|
|
36
|
+
* @returns The prompt pack content
|
|
37
|
+
*/
|
|
7
38
|
async fetchPack(packName) {
|
|
39
|
+
if (!SysPromptHubClient.validatePackName(packName)) {
|
|
40
|
+
throw new Error(`Invalid pack name: ${packName}`);
|
|
41
|
+
}
|
|
8
42
|
if (this.cache.has(packName)) {
|
|
9
43
|
return this.cache.get(packName);
|
|
10
44
|
}
|
|
@@ -17,8 +51,12 @@ export class SysPromptHubClient {
|
|
|
17
51
|
this.cache.set(packName, content);
|
|
18
52
|
return content;
|
|
19
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Clears the pack cache
|
|
56
|
+
*/
|
|
20
57
|
clearCache() {
|
|
21
58
|
this.cache.clear();
|
|
22
59
|
}
|
|
23
60
|
}
|
|
61
|
+
exports.SysPromptHubClient = SysPromptHubClient;
|
|
24
62
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,yCAA4D;AAE5D;;GAEG;AACH,MAAa,kBAAkB;IACZ,MAAM,CAAS;IACxB,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEvC,MAAM,CAAU,QAAQ,GAAgC;QAC9D,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE,kCAAkC;QAC3C,UAAU,EAAE,8BAA8B;KAC3C,CAAC;IAEF;;;OAGG;IACH,YAAY,cAA2B,8BAAmB;QACxD,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAgB;QACtC,MAAM,OAAO,GAAG,sEAAsE,CAAC;QACvF,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,QAAgB;QAC9B,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;QACnC,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,MAAM,QAAQ,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,qCAAqC,QAAQ,KAAK,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,MAAM,GAAG,CAC7F,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;;AA9DH,gDA+DC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DefaultConfigManager } from "./default-config-manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration manager instance
|
|
4
|
+
*/
|
|
5
|
+
export declare const ConfigManager: typeof DefaultConfigManager;
|
|
3
6
|
export declare const CONFIG_FILE_NAME = ".sysprompthub.json";
|
|
4
|
-
export
|
|
5
|
-
export declare class ConfigManager {
|
|
6
|
-
private readonly cwd;
|
|
7
|
-
private readonly vscodeManager;
|
|
8
|
-
constructor(cwd?: string);
|
|
9
|
-
static getApiUrl(environment?: Environment): string;
|
|
10
|
-
static validatePackName(packName: string): boolean;
|
|
11
|
-
load(): Promise<Config | null>;
|
|
12
|
-
update(updates: Partial<Config>): Promise<void>;
|
|
13
|
-
getVscodeManager(): VscodeConfigManager;
|
|
14
|
-
}
|
|
7
|
+
export { DEFAULT_ENVIRONMENT } from "./types.js";
|
|
15
8
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,aAAa,6BAAuB,CAAC;AAClD,eAAO,MAAM,gBAAgB,uBAAiC,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,62 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
development: 'https://api-dev.sysprompthub.com'
|
|
9
|
-
};
|
|
10
|
-
export class ConfigManager {
|
|
11
|
-
cwd;
|
|
12
|
-
vscodeManager;
|
|
13
|
-
constructor(cwd = process.cwd()) {
|
|
14
|
-
this.cwd = cwd;
|
|
15
|
-
this.vscodeManager = new VscodeConfigManager(cwd);
|
|
16
|
-
}
|
|
17
|
-
static getApiUrl(environment = DEFAULT_ENVIRONMENT) {
|
|
18
|
-
return API_URLS[environment];
|
|
19
|
-
}
|
|
20
|
-
static validatePackName(packName) {
|
|
21
|
-
const pattern = /^[a-z][a-z0-9-]*[a-z0-9]\/[a-z][a-z0-9-]*[a-z0-9]\/(latest|\d{1,5})$/;
|
|
22
|
-
return pattern.test(packName);
|
|
23
|
-
}
|
|
24
|
-
async load() {
|
|
25
|
-
// First, try to load .vscode/settings.json
|
|
26
|
-
const vscodeConfig = await this.vscodeManager.load();
|
|
27
|
-
if (vscodeConfig) {
|
|
28
|
-
return vscodeConfig;
|
|
29
|
-
}
|
|
30
|
-
// Fall back to .sysprompthub.json
|
|
31
|
-
try {
|
|
32
|
-
const configPath = join(this.cwd, CONFIG_FILE_NAME);
|
|
33
|
-
const content = await readFile(configPath, 'utf-8');
|
|
34
|
-
return JSON.parse(content);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async update(updates) {
|
|
41
|
-
const configPath = join(this.cwd, CONFIG_FILE_NAME);
|
|
42
|
-
try {
|
|
43
|
-
const content = await readFile(configPath, 'utf-8');
|
|
44
|
-
const config = JSON.parse(content);
|
|
45
|
-
const updatedConfig = { ...config, ...updates };
|
|
46
|
-
await writeFile(configPath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// Config file doesn't exist, create it
|
|
50
|
-
const newConfig = {
|
|
51
|
-
packName: updates.packName,
|
|
52
|
-
assistants: updates.assistants || ['copilot'],
|
|
53
|
-
environment: updates.environment || DEFAULT_ENVIRONMENT
|
|
54
|
-
};
|
|
55
|
-
await writeFile(configPath, JSON.stringify(newConfig, null, 2), 'utf-8');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
getVscodeManager() {
|
|
59
|
-
return this.vscodeManager;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
import { DefaultConfigManager } from "./default-config-manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration manager instance
|
|
4
|
+
*/
|
|
5
|
+
export const ConfigManager = DefaultConfigManager;
|
|
6
|
+
export const CONFIG_FILE_NAME = DefaultConfigManager.FILE_NAME;
|
|
7
|
+
export { DEFAULT_ENVIRONMENT } from "./types.js";
|
|
62
8
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,SAAS,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Config } from './types.js';
|
|
2
|
+
import { BaseConfigManager } from "./base-config-manager.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default configuration manager using .sysprompthub.json file
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultConfigManager extends BaseConfigManager {
|
|
7
|
+
static readonly FILE_NAME = ".sysprompthub.json";
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Deserializes configuration from JSON string
|
|
11
|
+
* @param content - JSON string to parse
|
|
12
|
+
* @returns Parsed configuration
|
|
13
|
+
*/
|
|
14
|
+
protected deserialize(content: string): Config;
|
|
15
|
+
/**
|
|
16
|
+
* Serializes configuration to JSON string
|
|
17
|
+
* @param config - Configuration to serialize
|
|
18
|
+
* @returns JSON string
|
|
19
|
+
*/
|
|
20
|
+
protected serialize(config: Config): Promise<string>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=default-config-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-config-manager.d.ts","sourceRoot":"","sources":["../src/default-config-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,MAAM,CAAC,QAAQ,CAAC,SAAS,wBAAwB;;IAMjD;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI9C;;;;OAIG;cACa,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG3D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultConfigManager = void 0;
|
|
4
|
+
const base_config_manager_js_1 = require("./base-config-manager.js");
|
|
5
|
+
/**
|
|
6
|
+
* Default configuration manager using .sysprompthub.json file
|
|
7
|
+
*/
|
|
8
|
+
class DefaultConfigManager extends base_config_manager_js_1.BaseConfigManager {
|
|
9
|
+
static FILE_NAME = '.sysprompthub.json';
|
|
10
|
+
constructor() {
|
|
11
|
+
super(DefaultConfigManager.FILE_NAME);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Deserializes configuration from JSON string
|
|
15
|
+
* @param content - JSON string to parse
|
|
16
|
+
* @returns Parsed configuration
|
|
17
|
+
*/
|
|
18
|
+
deserialize(content) {
|
|
19
|
+
return JSON.parse(content);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Serializes configuration to JSON string
|
|
23
|
+
* @param config - Configuration to serialize
|
|
24
|
+
* @returns JSON string
|
|
25
|
+
*/
|
|
26
|
+
async serialize(config) {
|
|
27
|
+
return JSON.stringify(config, null, 2);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.DefaultConfigManager = DefaultConfigManager;
|
|
31
|
+
//# sourceMappingURL=default-config-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-config-manager.js","sourceRoot":"","sources":["../src/default-config-manager.ts"],"names":[],"mappings":";;;AACA,qEAA2D;AAE3D;;GAEG;AACH,MAAa,oBAAqB,SAAQ,0CAAiB;IACzD,MAAM,CAAU,SAAS,GAAG,oBAAoB,CAAC;IAEjD;QACE,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACO,WAAW,CAAC,OAAe;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAW,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,SAAS,CAAC,MAAc;QACtC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;;AAvBH,oDAwBC"}
|