@prompd/cli 0.3.3
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 +162 -0
- package/bin/prompd.js +23 -0
- package/dist/commands/cache.d.ts +3 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +199 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/compile.d.ts +9 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +104 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +212 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +183 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/deps.d.ts +3 -0
- package/dist/commands/deps.d.ts.map +1 -0
- package/dist/commands/deps.js +192 -0
- package/dist/commands/deps.js.map +1 -0
- package/dist/commands/explain.d.ts +3 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +227 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/git.d.ts +3 -0
- package/dist/commands/git.d.ts.map +1 -0
- package/dist/commands/git.js +306 -0
- package/dist/commands/git.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +177 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +126 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +326 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/namespace.d.ts +3 -0
- package/dist/commands/namespace.d.ts.map +1 -0
- package/dist/commands/namespace.js +113 -0
- package/dist/commands/namespace.js.map +1 -0
- package/dist/commands/package.d.ts +23 -0
- package/dist/commands/package.d.ts.map +1 -0
- package/dist/commands/package.js +746 -0
- package/dist/commands/package.js.map +1 -0
- package/dist/commands/provider.d.ts +3 -0
- package/dist/commands/provider.d.ts.map +1 -0
- package/dist/commands/provider.js +285 -0
- package/dist/commands/provider.js.map +1 -0
- package/dist/commands/registry.d.ts +9 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +361 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +157 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/show.d.ts +3 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +90 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/uninstall.d.ts +3 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +95 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +57 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +166 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/auth.d.ts +164 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +388 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/compiler/file-system.d.ts +178 -0
- package/dist/lib/compiler/file-system.d.ts.map +1 -0
- package/dist/lib/compiler/file-system.js +440 -0
- package/dist/lib/compiler/file-system.js.map +1 -0
- package/dist/lib/compiler/formatters/anthropic.d.ts +21 -0
- package/dist/lib/compiler/formatters/anthropic.d.ts.map +1 -0
- package/dist/lib/compiler/formatters/anthropic.js +95 -0
- package/dist/lib/compiler/formatters/anthropic.js.map +1 -0
- package/dist/lib/compiler/formatters/markdown.d.ts +17 -0
- package/dist/lib/compiler/formatters/markdown.d.ts.map +1 -0
- package/dist/lib/compiler/formatters/markdown.js +114 -0
- package/dist/lib/compiler/formatters/markdown.js.map +1 -0
- package/dist/lib/compiler/formatters/openai.d.ts +21 -0
- package/dist/lib/compiler/formatters/openai.d.ts.map +1 -0
- package/dist/lib/compiler/formatters/openai.js +98 -0
- package/dist/lib/compiler/formatters/openai.js.map +1 -0
- package/dist/lib/compiler/index.d.ts +56 -0
- package/dist/lib/compiler/index.d.ts.map +1 -0
- package/dist/lib/compiler/index.js +165 -0
- package/dist/lib/compiler/index.js.map +1 -0
- package/dist/lib/compiler/language-map.d.ts +31 -0
- package/dist/lib/compiler/language-map.d.ts.map +1 -0
- package/dist/lib/compiler/language-map.js +156 -0
- package/dist/lib/compiler/language-map.js.map +1 -0
- package/dist/lib/compiler/package-resolver.d.ts +68 -0
- package/dist/lib/compiler/package-resolver.d.ts.map +1 -0
- package/dist/lib/compiler/package-resolver.js +254 -0
- package/dist/lib/compiler/package-resolver.js.map +1 -0
- package/dist/lib/compiler/pipeline.d.ts +53 -0
- package/dist/lib/compiler/pipeline.d.ts.map +1 -0
- package/dist/lib/compiler/pipeline.js +209 -0
- package/dist/lib/compiler/pipeline.js.map +1 -0
- package/dist/lib/compiler/prompd-loader.d.ts +108 -0
- package/dist/lib/compiler/prompd-loader.d.ts.map +1 -0
- package/dist/lib/compiler/prompd-loader.js +270 -0
- package/dist/lib/compiler/prompd-loader.js.map +1 -0
- package/dist/lib/compiler/section-override.d.ts +40 -0
- package/dist/lib/compiler/section-override.d.ts.map +1 -0
- package/dist/lib/compiler/section-override.js +296 -0
- package/dist/lib/compiler/section-override.js.map +1 -0
- package/dist/lib/compiler/stages/assets.d.ts +71 -0
- package/dist/lib/compiler/stages/assets.d.ts.map +1 -0
- package/dist/lib/compiler/stages/assets.js +456 -0
- package/dist/lib/compiler/stages/assets.js.map +1 -0
- package/dist/lib/compiler/stages/codegen.d.ts +17 -0
- package/dist/lib/compiler/stages/codegen.d.ts.map +1 -0
- package/dist/lib/compiler/stages/codegen.js +64 -0
- package/dist/lib/compiler/stages/codegen.js.map +1 -0
- package/dist/lib/compiler/stages/dependency.d.ts +38 -0
- package/dist/lib/compiler/stages/dependency.d.ts.map +1 -0
- package/dist/lib/compiler/stages/dependency.js +307 -0
- package/dist/lib/compiler/stages/dependency.js.map +1 -0
- package/dist/lib/compiler/stages/lexical.d.ts +19 -0
- package/dist/lib/compiler/stages/lexical.d.ts.map +1 -0
- package/dist/lib/compiler/stages/lexical.js +92 -0
- package/dist/lib/compiler/stages/lexical.js.map +1 -0
- package/dist/lib/compiler/stages/semantic.d.ts +20 -0
- package/dist/lib/compiler/stages/semantic.d.ts.map +1 -0
- package/dist/lib/compiler/stages/semantic.js +166 -0
- package/dist/lib/compiler/stages/semantic.js.map +1 -0
- package/dist/lib/compiler/stages/template.d.ts +94 -0
- package/dist/lib/compiler/stages/template.d.ts.map +1 -0
- package/dist/lib/compiler/stages/template.js +1044 -0
- package/dist/lib/compiler/stages/template.js.map +1 -0
- package/dist/lib/compiler/types.d.ts +200 -0
- package/dist/lib/compiler/types.d.ts.map +1 -0
- package/dist/lib/compiler/types.js +137 -0
- package/dist/lib/compiler/types.js.map +1 -0
- package/dist/lib/config.d.ts +29 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +375 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +19 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +47 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/executor.d.ts +18 -0
- package/dist/lib/executor.d.ts.map +1 -0
- package/dist/lib/executor.js +372 -0
- package/dist/lib/executor.js.map +1 -0
- package/dist/lib/git.d.ts +74 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +254 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/index.d.ts +43 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +108 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/mcp.d.ts +42 -0
- package/dist/lib/mcp.d.ts.map +1 -0
- package/dist/lib/mcp.js +477 -0
- package/dist/lib/mcp.js.map +1 -0
- package/dist/lib/model-updater.d.ts +51 -0
- package/dist/lib/model-updater.d.ts.map +1 -0
- package/dist/lib/model-updater.js +275 -0
- package/dist/lib/model-updater.js.map +1 -0
- package/dist/lib/parser.d.ts +9 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +197 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/registry.d.ts +183 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +786 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/rpc-server.d.ts +78 -0
- package/dist/lib/rpc-server.d.ts.map +1 -0
- package/dist/lib/rpc-server.js +404 -0
- package/dist/lib/rpc-server.js.map +1 -0
- package/dist/lib/security.d.ts +120 -0
- package/dist/lib/security.d.ts.map +1 -0
- package/dist/lib/security.js +478 -0
- package/dist/lib/security.js.map +1 -0
- package/dist/lib/validation.d.ts +106 -0
- package/dist/lib/validation.d.ts.map +1 -0
- package/dist/lib/validation.js +398 -0
- package/dist/lib/validation.js.map +1 -0
- package/dist/lib/version.d.ts +29 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +202 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/lib/workflow-engine.d.ts +161 -0
- package/dist/lib/workflow-engine.d.ts.map +1 -0
- package/dist/lib/workflow-engine.js +422 -0
- package/dist/lib/workflow-engine.js.map +1 -0
- package/dist/lib/workflow.d.ts +102 -0
- package/dist/lib/workflow.d.ts.map +1 -0
- package/dist/lib/workflow.js +228 -0
- package/dist/lib/workflow.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +134 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.d.ts +116 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +144 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +104 -0
package/dist/lib/git.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Git utility functions for programmatic use
|
|
4
|
+
* These functions can be imported and used directly by the IDE or other tools
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.GitSecurityError = void 0;
|
|
8
|
+
exports.execGitCommand = execGitCommand;
|
|
9
|
+
exports.getBranch = getBranch;
|
|
10
|
+
exports.isGitRepo = isGitRepo;
|
|
11
|
+
exports.getStatus = getStatus;
|
|
12
|
+
exports.stageFile = stageFile;
|
|
13
|
+
exports.unstageFile = unstageFile;
|
|
14
|
+
exports.discardChanges = discardChanges;
|
|
15
|
+
exports.commit = commit;
|
|
16
|
+
exports.getRecentCommits = getRecentCommits;
|
|
17
|
+
exports.initRepo = initRepo;
|
|
18
|
+
exports.getFileHistory = getFileHistory;
|
|
19
|
+
const child_process_1 = require("child_process");
|
|
20
|
+
const security_1 = require("./security");
|
|
21
|
+
Object.defineProperty(exports, "GitSecurityError", { enumerable: true, get: function () { return security_1.GitSecurityError; } });
|
|
22
|
+
/**
|
|
23
|
+
* Execute a git command with security validation
|
|
24
|
+
* @param args Git command arguments
|
|
25
|
+
* @param cwd Working directory (optional)
|
|
26
|
+
* @returns Promise with command result
|
|
27
|
+
*/
|
|
28
|
+
async function execGitCommand(args, cwd) {
|
|
29
|
+
// Whitelist of allowed git commands for security
|
|
30
|
+
const allowedCommands = [
|
|
31
|
+
'status', 'branch', 'add', 'restore', 'commit', 'log', 'init',
|
|
32
|
+
'diff', 'show', 'tag', 'reset', 'rm'
|
|
33
|
+
];
|
|
34
|
+
const gitCommand = args[0];
|
|
35
|
+
if (!allowedCommands.includes(gitCommand)) {
|
|
36
|
+
return {
|
|
37
|
+
success: false,
|
|
38
|
+
output: '',
|
|
39
|
+
error: `Git command '${gitCommand}' not allowed`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
const gitProcess = (0, child_process_1.spawn)('git', args, {
|
|
44
|
+
cwd: cwd || process.cwd(),
|
|
45
|
+
shell: false // Important: don't use shell to prevent injection
|
|
46
|
+
});
|
|
47
|
+
let stdout = '';
|
|
48
|
+
let stderr = '';
|
|
49
|
+
gitProcess.stdout?.on('data', (data) => {
|
|
50
|
+
stdout += data.toString();
|
|
51
|
+
});
|
|
52
|
+
gitProcess.stderr?.on('data', (data) => {
|
|
53
|
+
stderr += data.toString();
|
|
54
|
+
});
|
|
55
|
+
gitProcess.on('close', (code) => {
|
|
56
|
+
if (code === 0) {
|
|
57
|
+
resolve({ success: true, output: stdout });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
resolve({ success: false, output: stdout, error: stderr || `Exit code ${code}` });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
gitProcess.on('error', (err) => {
|
|
64
|
+
resolve({ success: false, output: '', error: err.message });
|
|
65
|
+
});
|
|
66
|
+
// Timeout after 30 seconds
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
gitProcess.kill();
|
|
69
|
+
resolve({ success: false, output: '', error: 'Git command timed out' });
|
|
70
|
+
}, 30000);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get current branch name
|
|
75
|
+
*/
|
|
76
|
+
async function getBranch(cwd) {
|
|
77
|
+
const result = await execGitCommand(['branch', '--show-current'], cwd);
|
|
78
|
+
if (result.success) {
|
|
79
|
+
return result.output.trim() || 'HEAD';
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if directory is a git repository
|
|
85
|
+
*/
|
|
86
|
+
async function isGitRepo(cwd) {
|
|
87
|
+
const result = await execGitCommand(['branch', '--show-current'], cwd);
|
|
88
|
+
return result.success;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get git status for prompd files (.prmd, .pdflow)
|
|
92
|
+
* @param cwd Working directory
|
|
93
|
+
* @param filterPrompdOnly Only return .prmd and .pdflow files (default: true)
|
|
94
|
+
*/
|
|
95
|
+
async function getStatus(cwd, filterPrompdOnly = true) {
|
|
96
|
+
const result = await execGitCommand(['status', '--porcelain'], cwd);
|
|
97
|
+
if (!result.success) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const files = [];
|
|
101
|
+
const lines = result.output.split('\n').filter(l => l.trim());
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
const filePath = line.substring(3).trim();
|
|
104
|
+
// Filter for prompd files if requested
|
|
105
|
+
if (filterPrompdOnly && !filePath.endsWith('.prmd') && !filePath.endsWith('.pdflow')) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const indexStatus = line[0];
|
|
109
|
+
const workTreeStatus = line[1];
|
|
110
|
+
// Determine status type
|
|
111
|
+
const getStatusType = (char) => {
|
|
112
|
+
switch (char) {
|
|
113
|
+
case 'M': return 'modified';
|
|
114
|
+
case 'A': return 'added';
|
|
115
|
+
case 'D': return 'deleted';
|
|
116
|
+
case '?': return 'untracked';
|
|
117
|
+
default: return 'modified';
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
// If file is staged (index has changes)
|
|
121
|
+
if (indexStatus !== ' ' && indexStatus !== '?') {
|
|
122
|
+
files.push({
|
|
123
|
+
path: filePath,
|
|
124
|
+
status: getStatusType(indexStatus),
|
|
125
|
+
staged: true,
|
|
126
|
+
indexStatus,
|
|
127
|
+
workTreeStatus
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
// If file has working tree changes
|
|
131
|
+
if (workTreeStatus !== ' ') {
|
|
132
|
+
files.push({
|
|
133
|
+
path: filePath,
|
|
134
|
+
status: workTreeStatus === '?' ? 'untracked' : getStatusType(workTreeStatus),
|
|
135
|
+
staged: false,
|
|
136
|
+
indexStatus,
|
|
137
|
+
workTreeStatus
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return files;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Stage a file
|
|
145
|
+
*/
|
|
146
|
+
async function stageFile(filePath, cwd) {
|
|
147
|
+
try {
|
|
148
|
+
const safePath = (0, security_1.validateGitFilePath)(filePath);
|
|
149
|
+
return await execGitCommand(['add', safePath], cwd);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error instanceof security_1.GitSecurityError) {
|
|
153
|
+
return { success: false, output: '', error: error.message };
|
|
154
|
+
}
|
|
155
|
+
return { success: false, output: '', error: String(error) };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Unstage a file
|
|
160
|
+
*/
|
|
161
|
+
async function unstageFile(filePath, cwd) {
|
|
162
|
+
try {
|
|
163
|
+
const safePath = (0, security_1.validateGitFilePath)(filePath);
|
|
164
|
+
return await execGitCommand(['restore', '--staged', safePath], cwd);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error instanceof security_1.GitSecurityError) {
|
|
168
|
+
return { success: false, output: '', error: error.message };
|
|
169
|
+
}
|
|
170
|
+
return { success: false, output: '', error: String(error) };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Discard changes to a file
|
|
175
|
+
*/
|
|
176
|
+
async function discardChanges(filePath, cwd) {
|
|
177
|
+
try {
|
|
178
|
+
const safePath = (0, security_1.validateGitFilePath)(filePath);
|
|
179
|
+
return await execGitCommand(['restore', safePath], cwd);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error instanceof security_1.GitSecurityError) {
|
|
183
|
+
return { success: false, output: '', error: error.message };
|
|
184
|
+
}
|
|
185
|
+
return { success: false, output: '', error: String(error) };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Commit staged changes
|
|
190
|
+
*/
|
|
191
|
+
async function commit(message, cwd) {
|
|
192
|
+
try {
|
|
193
|
+
const safeMessage = (0, security_1.validateGitMessage)(message);
|
|
194
|
+
return await execGitCommand(['commit', '-m', safeMessage], cwd);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (error instanceof security_1.GitSecurityError) {
|
|
198
|
+
return { success: false, output: '', error: error.message };
|
|
199
|
+
}
|
|
200
|
+
return { success: false, output: '', error: String(error) };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get recent commits
|
|
205
|
+
*/
|
|
206
|
+
async function getRecentCommits(cwd, limit = 10) {
|
|
207
|
+
const safeLimit = Math.min(Math.max(1, limit), 100);
|
|
208
|
+
const result = await execGitCommand([
|
|
209
|
+
'log',
|
|
210
|
+
'--oneline',
|
|
211
|
+
`-n`, String(safeLimit),
|
|
212
|
+
'--format=%h|%s|%an|%ar'
|
|
213
|
+
], cwd);
|
|
214
|
+
if (!result.success || !result.output.trim()) {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
return result.output.trim().split('\n').map(line => {
|
|
218
|
+
const [hash, message, author, date] = line.split('|');
|
|
219
|
+
return { hash, message, author, date };
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Initialize a git repository
|
|
224
|
+
*/
|
|
225
|
+
async function initRepo(cwd) {
|
|
226
|
+
return await execGitCommand(['init'], cwd);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get file history
|
|
230
|
+
*/
|
|
231
|
+
async function getFileHistory(filePath, cwd, limit = 10) {
|
|
232
|
+
try {
|
|
233
|
+
const safePath = (0, security_1.validateGitFilePath)(filePath);
|
|
234
|
+
const safeLimit = Math.min(Math.max(1, limit), 100);
|
|
235
|
+
const result = await execGitCommand([
|
|
236
|
+
'log',
|
|
237
|
+
`--max-count=${safeLimit}`,
|
|
238
|
+
'--format=%h|%s|%an|%ar',
|
|
239
|
+
'--',
|
|
240
|
+
safePath
|
|
241
|
+
], cwd);
|
|
242
|
+
if (!result.success || !result.output.trim()) {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
return result.output.trim().split('\n').map(line => {
|
|
246
|
+
const [hash, message, author, date] = line.split('|');
|
|
247
|
+
return { hash, message, author, date };
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/lib/git.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuCH,wCAsDC;AAKD,8BAMC;AAKD,8BAGC;AAOD,8BA0DC;AAKD,8BAaC;AAKD,kCAaC;AAKD,wCAaC;AAKD,wBAaC;AAKD,4CAoBC;AAKD,4BAEC;AAKD,wCA4BC;AAxTD,iDAAsC;AACtC,yCAKoB;AAEX,iGAHP,2BAAgB,OAGO;AAuBzB;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAClC,IAAc,EACd,GAAY;IAEZ,iDAAiD;IACjD,MAAM,eAAe,GAAG;QACtB,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM;QAC7D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI;KACrC,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,OAAO;YACL,OAAO,EAAE,KAAK;YACd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E,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;QAEpD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;YAClC,KAAK;YACL,eAAe,SAAS,EAAE;YAC1B,wBAAwB;YACxB,IAAI;YACJ,QAAQ;SACT,EAAE,GAAG,CAAC,CAAC;QAER,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACjD,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompd Library - Core exports for use in TypeScript/React applications
|
|
3
|
+
*
|
|
4
|
+
* This module exports the core functionality of the Prompd CLI as a library
|
|
5
|
+
* that can be imported and used programmatically.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { PrompdParser, ConfigManager, PrompdCompiler, MemoryFileSystem } from '@prompd/cli';
|
|
10
|
+
*
|
|
11
|
+
* // Parse a .prmd file
|
|
12
|
+
* const parser = new PrompdParser();
|
|
13
|
+
* const prompd = await parser.parseFile('./example.prmd');
|
|
14
|
+
*
|
|
15
|
+
* // Validate a file
|
|
16
|
+
* const issues = await parser.validateFile('./example.prmd');
|
|
17
|
+
*
|
|
18
|
+
* // Work with configuration
|
|
19
|
+
* const config = new ConfigManager();
|
|
20
|
+
* const currentConfig = config.load();
|
|
21
|
+
*
|
|
22
|
+
* // Compile from memory (server-side)
|
|
23
|
+
* const fs = new MemoryFileSystem({
|
|
24
|
+
* '/main.prmd': '...'
|
|
25
|
+
* });
|
|
26
|
+
* const compiler = new PrompdCompiler();
|
|
27
|
+
* const result = await compiler.compile('/main.prmd', { fileSystem: fs });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export { PrompdParser } from './parser';
|
|
31
|
+
export type { PrompdFile, PrompdMetadata, PrompdParameter, ValidationIssue, CustomProvider, RegistryConfig, Config, LLMResponse, ExecuteOptions } from '../types';
|
|
32
|
+
export { ConfigManager } from './config';
|
|
33
|
+
export { SecurityManager } from './security';
|
|
34
|
+
export { validatePackageName, validateVersion, validateNamespace, validateRegistryUrl, sanitizeFilePath, detectSecrets, validateFileExtension, validateOptionName, validateParameterKey, sanitizeParameterKey, validateGitRef, validateModelName, validateProviderName, validateEmail, containsMaliciousContent, validateNumericRange, validateStringLength, sanitizeForDisplay, validateJSON, validateYAML, SecurityError, ValidationError } from './validation';
|
|
35
|
+
export { PrompdCompiler, compile, CompilerPipeline, CompilationContext, CompilationOptions, CompilationDiagnostic, CompilerStage, OutputFormatter, CompiledPrompt, SectionInfo, LexicalAnalysisStage, DependencyResolutionStage, SemanticAnalysisStage, AssetExtractionStage, TemplateProcessingStage, CodeGenerationStage, SectionOverrideProcessor, MarkdownFormatter, OpenAIFormatter, AnthropicFormatter, IFileSystem, MemoryFileSystem, NodeFileSystem, getDefaultFileSystem } from './compiler';
|
|
36
|
+
export { execGitCommand, getBranch, isGitRepo, getStatus, stageFile, unstageFile, discardChanges, commit, getRecentCommits, initRepo, getFileHistory, GitSecurityError } from './git';
|
|
37
|
+
export type { GitCommandResult, GitFileStatus, GitCommitInfo } from './git';
|
|
38
|
+
export { RegistryClient } from './registry';
|
|
39
|
+
export type { RegistryClientOptions, PackageMetadata, PublishOptions, SearchQuery, SearchResult, InstallOptions } from './registry';
|
|
40
|
+
export { createPackageFromPrompdJson } from '../commands/package';
|
|
41
|
+
export type { CreatePackageResult } from '../commands/package';
|
|
42
|
+
export declare const VERSION = "0.3.3";
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,MAAM,EACN,WAAW,EACX,cAAc,EACf,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAElB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,cAAc,EACd,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,gBAAgB,EACjB,MAAM,OAAO,CAAC;AACf,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACd,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EACZ,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompd Library - Core exports for use in TypeScript/React applications
|
|
4
|
+
*
|
|
5
|
+
* This module exports the core functionality of the Prompd CLI as a library
|
|
6
|
+
* that can be imported and used programmatically.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { PrompdParser, ConfigManager, PrompdCompiler, MemoryFileSystem } from '@prompd/cli';
|
|
11
|
+
*
|
|
12
|
+
* // Parse a .prmd file
|
|
13
|
+
* const parser = new PrompdParser();
|
|
14
|
+
* const prompd = await parser.parseFile('./example.prmd');
|
|
15
|
+
*
|
|
16
|
+
* // Validate a file
|
|
17
|
+
* const issues = await parser.validateFile('./example.prmd');
|
|
18
|
+
*
|
|
19
|
+
* // Work with configuration
|
|
20
|
+
* const config = new ConfigManager();
|
|
21
|
+
* const currentConfig = config.load();
|
|
22
|
+
*
|
|
23
|
+
* // Compile from memory (server-side)
|
|
24
|
+
* const fs = new MemoryFileSystem({
|
|
25
|
+
* '/main.prmd': '...'
|
|
26
|
+
* });
|
|
27
|
+
* const compiler = new PrompdCompiler();
|
|
28
|
+
* const result = await compiler.compile('/main.prmd', { fileSystem: fs });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.commit = exports.discardChanges = exports.unstageFile = exports.stageFile = exports.getStatus = exports.isGitRepo = exports.getBranch = exports.execGitCommand = exports.getDefaultFileSystem = exports.NodeFileSystem = exports.MemoryFileSystem = exports.AnthropicFormatter = exports.OpenAIFormatter = exports.MarkdownFormatter = exports.SectionOverrideProcessor = exports.CodeGenerationStage = exports.TemplateProcessingStage = exports.AssetExtractionStage = exports.SemanticAnalysisStage = exports.DependencyResolutionStage = exports.LexicalAnalysisStage = exports.CompilationContext = exports.CompilerPipeline = exports.compile = exports.PrompdCompiler = exports.ValidationError = exports.SecurityError = exports.validateYAML = exports.validateJSON = exports.sanitizeForDisplay = exports.validateStringLength = exports.validateNumericRange = exports.containsMaliciousContent = exports.validateEmail = exports.validateProviderName = exports.validateModelName = exports.validateGitRef = exports.sanitizeParameterKey = exports.validateParameterKey = exports.validateOptionName = exports.validateFileExtension = exports.detectSecrets = exports.sanitizeFilePath = exports.validateRegistryUrl = exports.validateNamespace = exports.validateVersion = exports.validatePackageName = exports.SecurityManager = exports.ConfigManager = exports.PrompdParser = void 0;
|
|
33
|
+
exports.VERSION = exports.createPackageFromPrompdJson = exports.RegistryClient = exports.GitSecurityError = exports.getFileHistory = exports.initRepo = exports.getRecentCommits = void 0;
|
|
34
|
+
// Parser exports
|
|
35
|
+
var parser_1 = require("./parser");
|
|
36
|
+
Object.defineProperty(exports, "PrompdParser", { enumerable: true, get: function () { return parser_1.PrompdParser; } });
|
|
37
|
+
// Config exports
|
|
38
|
+
var config_1 = require("./config");
|
|
39
|
+
Object.defineProperty(exports, "ConfigManager", { enumerable: true, get: function () { return config_1.ConfigManager; } });
|
|
40
|
+
// Security exports
|
|
41
|
+
var security_1 = require("./security");
|
|
42
|
+
Object.defineProperty(exports, "SecurityManager", { enumerable: true, get: function () { return security_1.SecurityManager; } });
|
|
43
|
+
// Validation utilities
|
|
44
|
+
var validation_1 = require("./validation");
|
|
45
|
+
Object.defineProperty(exports, "validatePackageName", { enumerable: true, get: function () { return validation_1.validatePackageName; } });
|
|
46
|
+
Object.defineProperty(exports, "validateVersion", { enumerable: true, get: function () { return validation_1.validateVersion; } });
|
|
47
|
+
Object.defineProperty(exports, "validateNamespace", { enumerable: true, get: function () { return validation_1.validateNamespace; } });
|
|
48
|
+
Object.defineProperty(exports, "validateRegistryUrl", { enumerable: true, get: function () { return validation_1.validateRegistryUrl; } });
|
|
49
|
+
Object.defineProperty(exports, "sanitizeFilePath", { enumerable: true, get: function () { return validation_1.sanitizeFilePath; } });
|
|
50
|
+
Object.defineProperty(exports, "detectSecrets", { enumerable: true, get: function () { return validation_1.detectSecrets; } });
|
|
51
|
+
Object.defineProperty(exports, "validateFileExtension", { enumerable: true, get: function () { return validation_1.validateFileExtension; } });
|
|
52
|
+
Object.defineProperty(exports, "validateOptionName", { enumerable: true, get: function () { return validation_1.validateOptionName; } });
|
|
53
|
+
Object.defineProperty(exports, "validateParameterKey", { enumerable: true, get: function () { return validation_1.validateParameterKey; } });
|
|
54
|
+
Object.defineProperty(exports, "sanitizeParameterKey", { enumerable: true, get: function () { return validation_1.sanitizeParameterKey; } });
|
|
55
|
+
Object.defineProperty(exports, "validateGitRef", { enumerable: true, get: function () { return validation_1.validateGitRef; } });
|
|
56
|
+
Object.defineProperty(exports, "validateModelName", { enumerable: true, get: function () { return validation_1.validateModelName; } });
|
|
57
|
+
Object.defineProperty(exports, "validateProviderName", { enumerable: true, get: function () { return validation_1.validateProviderName; } });
|
|
58
|
+
Object.defineProperty(exports, "validateEmail", { enumerable: true, get: function () { return validation_1.validateEmail; } });
|
|
59
|
+
Object.defineProperty(exports, "containsMaliciousContent", { enumerable: true, get: function () { return validation_1.containsMaliciousContent; } });
|
|
60
|
+
Object.defineProperty(exports, "validateNumericRange", { enumerable: true, get: function () { return validation_1.validateNumericRange; } });
|
|
61
|
+
Object.defineProperty(exports, "validateStringLength", { enumerable: true, get: function () { return validation_1.validateStringLength; } });
|
|
62
|
+
Object.defineProperty(exports, "sanitizeForDisplay", { enumerable: true, get: function () { return validation_1.sanitizeForDisplay; } });
|
|
63
|
+
Object.defineProperty(exports, "validateJSON", { enumerable: true, get: function () { return validation_1.validateJSON; } });
|
|
64
|
+
Object.defineProperty(exports, "validateYAML", { enumerable: true, get: function () { return validation_1.validateYAML; } });
|
|
65
|
+
Object.defineProperty(exports, "SecurityError", { enumerable: true, get: function () { return validation_1.SecurityError; } });
|
|
66
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_1.ValidationError; } });
|
|
67
|
+
// Compiler exports (6-stage compilation pipeline)
|
|
68
|
+
var compiler_1 = require("./compiler");
|
|
69
|
+
Object.defineProperty(exports, "PrompdCompiler", { enumerable: true, get: function () { return compiler_1.PrompdCompiler; } });
|
|
70
|
+
Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compiler_1.compile; } });
|
|
71
|
+
Object.defineProperty(exports, "CompilerPipeline", { enumerable: true, get: function () { return compiler_1.CompilerPipeline; } });
|
|
72
|
+
Object.defineProperty(exports, "CompilationContext", { enumerable: true, get: function () { return compiler_1.CompilationContext; } });
|
|
73
|
+
Object.defineProperty(exports, "LexicalAnalysisStage", { enumerable: true, get: function () { return compiler_1.LexicalAnalysisStage; } });
|
|
74
|
+
Object.defineProperty(exports, "DependencyResolutionStage", { enumerable: true, get: function () { return compiler_1.DependencyResolutionStage; } });
|
|
75
|
+
Object.defineProperty(exports, "SemanticAnalysisStage", { enumerable: true, get: function () { return compiler_1.SemanticAnalysisStage; } });
|
|
76
|
+
Object.defineProperty(exports, "AssetExtractionStage", { enumerable: true, get: function () { return compiler_1.AssetExtractionStage; } });
|
|
77
|
+
Object.defineProperty(exports, "TemplateProcessingStage", { enumerable: true, get: function () { return compiler_1.TemplateProcessingStage; } });
|
|
78
|
+
Object.defineProperty(exports, "CodeGenerationStage", { enumerable: true, get: function () { return compiler_1.CodeGenerationStage; } });
|
|
79
|
+
Object.defineProperty(exports, "SectionOverrideProcessor", { enumerable: true, get: function () { return compiler_1.SectionOverrideProcessor; } });
|
|
80
|
+
Object.defineProperty(exports, "MarkdownFormatter", { enumerable: true, get: function () { return compiler_1.MarkdownFormatter; } });
|
|
81
|
+
Object.defineProperty(exports, "OpenAIFormatter", { enumerable: true, get: function () { return compiler_1.OpenAIFormatter; } });
|
|
82
|
+
Object.defineProperty(exports, "AnthropicFormatter", { enumerable: true, get: function () { return compiler_1.AnthropicFormatter; } });
|
|
83
|
+
Object.defineProperty(exports, "MemoryFileSystem", { enumerable: true, get: function () { return compiler_1.MemoryFileSystem; } });
|
|
84
|
+
Object.defineProperty(exports, "NodeFileSystem", { enumerable: true, get: function () { return compiler_1.NodeFileSystem; } });
|
|
85
|
+
Object.defineProperty(exports, "getDefaultFileSystem", { enumerable: true, get: function () { return compiler_1.getDefaultFileSystem; } });
|
|
86
|
+
// Git utilities (for IDE integration)
|
|
87
|
+
var git_1 = require("./git");
|
|
88
|
+
Object.defineProperty(exports, "execGitCommand", { enumerable: true, get: function () { return git_1.execGitCommand; } });
|
|
89
|
+
Object.defineProperty(exports, "getBranch", { enumerable: true, get: function () { return git_1.getBranch; } });
|
|
90
|
+
Object.defineProperty(exports, "isGitRepo", { enumerable: true, get: function () { return git_1.isGitRepo; } });
|
|
91
|
+
Object.defineProperty(exports, "getStatus", { enumerable: true, get: function () { return git_1.getStatus; } });
|
|
92
|
+
Object.defineProperty(exports, "stageFile", { enumerable: true, get: function () { return git_1.stageFile; } });
|
|
93
|
+
Object.defineProperty(exports, "unstageFile", { enumerable: true, get: function () { return git_1.unstageFile; } });
|
|
94
|
+
Object.defineProperty(exports, "discardChanges", { enumerable: true, get: function () { return git_1.discardChanges; } });
|
|
95
|
+
Object.defineProperty(exports, "commit", { enumerable: true, get: function () { return git_1.commit; } });
|
|
96
|
+
Object.defineProperty(exports, "getRecentCommits", { enumerable: true, get: function () { return git_1.getRecentCommits; } });
|
|
97
|
+
Object.defineProperty(exports, "initRepo", { enumerable: true, get: function () { return git_1.initRepo; } });
|
|
98
|
+
Object.defineProperty(exports, "getFileHistory", { enumerable: true, get: function () { return git_1.getFileHistory; } });
|
|
99
|
+
Object.defineProperty(exports, "GitSecurityError", { enumerable: true, get: function () { return git_1.GitSecurityError; } });
|
|
100
|
+
// Registry client (for package installation)
|
|
101
|
+
var registry_1 = require("./registry");
|
|
102
|
+
Object.defineProperty(exports, "RegistryClient", { enumerable: true, get: function () { return registry_1.RegistryClient; } });
|
|
103
|
+
// Package creation (programmatic API)
|
|
104
|
+
var package_1 = require("../commands/package");
|
|
105
|
+
Object.defineProperty(exports, "createPackageFromPrompdJson", { enumerable: true, get: function () { return package_1.createPackageFromPrompdJson; } });
|
|
106
|
+
// Version information
|
|
107
|
+
exports.VERSION = '0.3.3';
|
|
108
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;;AAEH,iBAAiB;AACjB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAarB,iBAAiB;AACjB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AAEtB,mBAAmB;AACnB,uCAA6C;AAApC,2GAAA,eAAe,OAAA;AAExB,uBAAuB;AACvB,2CAuBsB;AAtBpB,iHAAA,mBAAmB,OAAA;AACnB,6GAAA,eAAe,OAAA;AACf,+GAAA,iBAAiB,OAAA;AACjB,iHAAA,mBAAmB,OAAA;AACnB,8GAAA,gBAAgB,OAAA;AAChB,2GAAA,aAAa,OAAA;AACb,mHAAA,qBAAqB,OAAA;AAC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C,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAUvB,sCAAsC;AACtC,+CAAkE;AAAzD,sHAAA,2BAA2B,OAAA;AAGpC,sBAAsB;AACT,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface MCPServerConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
execute?: boolean;
|
|
5
|
+
provider?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
allowedTools?: string[];
|
|
9
|
+
maxRequestSize?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class PrompdMCPServer {
|
|
12
|
+
private server;
|
|
13
|
+
private parser;
|
|
14
|
+
private executor?;
|
|
15
|
+
private workflowExecutor;
|
|
16
|
+
private registeredTools;
|
|
17
|
+
private registeredWorkflows;
|
|
18
|
+
private config;
|
|
19
|
+
private mcpSdk;
|
|
20
|
+
private securityMiddleware;
|
|
21
|
+
constructor(config: MCPServerConfig);
|
|
22
|
+
private initializeMCP;
|
|
23
|
+
private setupHandlers;
|
|
24
|
+
private createInputSchema;
|
|
25
|
+
private mapParameterType;
|
|
26
|
+
private validateParameters;
|
|
27
|
+
private validateParameterType;
|
|
28
|
+
private renderPrompt;
|
|
29
|
+
private executeWithLLM;
|
|
30
|
+
private reconstructPrompdFile;
|
|
31
|
+
registerTool(name: string, prompdFile: string): Promise<void>;
|
|
32
|
+
registerDirectory(directory: string): Promise<void>;
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
stop(): Promise<void>;
|
|
35
|
+
getRegisteredTools(): string[];
|
|
36
|
+
getRegisteredPrompts(): string[];
|
|
37
|
+
getRegisteredWorkflows(): string[];
|
|
38
|
+
registerWorkflow(name: string, workflowFile: string): Promise<void>;
|
|
39
|
+
private createWorkflowInputSchema;
|
|
40
|
+
private validateWorkflowParameters;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=mcp.d.ts.map
|
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