@prompd/cli 0.4.11 → 0.5.0-beta.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.
- package/README.md +1 -1
- package/dist/commands/package.js +5 -5
- package/dist/lib/commandExecutor.d.ts +2 -2
- package/dist/lib/commandExecutor.d.ts.map +1 -1
- package/dist/lib/commandExecutor.js +2 -2
- package/dist/lib/commandExecutor.js.map +1 -1
- package/dist/lib/nodeTypeRegistry.d.ts +1 -1
- package/dist/lib/nodeTypeRegistry.d.ts.map +1 -1
- package/dist/lib/workflowExecutor.js +64 -64
- package/package.json +124 -124
package/README.md
CHANGED
package/dist/commands/package.js
CHANGED
|
@@ -806,11 +806,11 @@ async function createPackageFromPrompdJson(workspacePath, outputDir) {
|
|
|
806
806
|
*/
|
|
807
807
|
function addContentFrontmatter(content, filename) {
|
|
808
808
|
const contentType = (0, types_1.getContentType)(filename);
|
|
809
|
-
const frontmatter = `---
|
|
810
|
-
prompd_content_file: true
|
|
811
|
-
original_filename: ${filename}
|
|
812
|
-
content_type: ${contentType}
|
|
813
|
-
---
|
|
809
|
+
const frontmatter = `---
|
|
810
|
+
prompd_content_file: true
|
|
811
|
+
original_filename: ${filename}
|
|
812
|
+
content_type: ${contentType}
|
|
813
|
+
---
|
|
814
814
|
`;
|
|
815
815
|
return frontmatter + content;
|
|
816
816
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Executes whitelisted commands via Node.js child_process with security controls.
|
|
5
5
|
* Used by workflow executor when running Command nodes in CLI environment.
|
|
6
6
|
*/
|
|
7
|
-
import { type CustomCommandConfig } from './workflowTypes
|
|
8
|
-
import type { ToolCallRequest, ToolCallResult } from './workflowExecutor
|
|
7
|
+
import { type CustomCommandConfig } from './workflowTypes';
|
|
8
|
+
import type { ToolCallRequest, ToolCallResult } from './workflowExecutor';
|
|
9
9
|
export interface CommandExecutionResult {
|
|
10
10
|
success: boolean;
|
|
11
11
|
output?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandExecutor.d.ts","sourceRoot":"","sources":["../../src/lib/commandExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAA+B,KAAK,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"commandExecutor.d.ts","sourceRoot":"","sources":["../../src/lib/commandExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAA+B,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEzE,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,cAAc,CAAC,EAAE,mBAAmB,EAAE,CAAA;IAEtC,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC7B;AAgDD;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAkGjC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,sBAA2B,GACnC,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAuDvD"}
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.executeCommand = executeCommand;
|
|
10
10
|
exports.createToolCallHandler = createToolCallHandler;
|
|
11
11
|
const child_process_1 = require("child_process");
|
|
12
|
-
const
|
|
12
|
+
const workflowTypes_1 = require("./workflowTypes");
|
|
13
13
|
/**
|
|
14
14
|
* Validates if a command is allowed to execute based on whitelist
|
|
15
15
|
*/
|
|
@@ -21,7 +21,7 @@ function validateCommand(command, customCommands = []) {
|
|
|
21
21
|
}
|
|
22
22
|
const executable = parts[0].toLowerCase();
|
|
23
23
|
// Check against built-in whitelist
|
|
24
|
-
const builtInCommands =
|
|
24
|
+
const builtInCommands = workflowTypes_1.BUILTIN_COMMAND_EXECUTABLES.map(cmd => cmd.executable.toLowerCase());
|
|
25
25
|
const customCommandExes = customCommands.map(cmd => cmd.executable.toLowerCase());
|
|
26
26
|
const allowedCommands = [...new Set([...builtInCommands, ...customCommandExes])];
|
|
27
27
|
if (!allowedCommands.includes(executable)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandExecutor.js","sourceRoot":"","sources":["../../src/lib/commandExecutor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA+EH,wCAqGC;AAMD,sDAyDC;AAjPD,iDAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"commandExecutor.js","sourceRoot":"","sources":["../../src/lib/commandExecutor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA+EH,wCAqGC;AAMD,sDAyDC;AAjPD,iDAAqC;AACrC,mDAAuF;AA2BvF;;GAEG;AACH,SAAS,eAAe,CACtB,OAAe,EACf,iBAAwC,EAAE;IAE1C,kCAAkC;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MA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AE,eAAe,CAAC,OAAO;oBAChC,MAAM,EAAE,eAAe,CAAC,MAAM,IAAI,eAAe,CAAC,KAAK;oBACvD,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B,CAAA;YACH,CAAC;YAED,KAAK,MAAM,CAAC;YACZ,KAAK,KAAK,CAAC;YACX,KAAK,MAAM,CAAC;YACZ,KAAK,UAAU;gBACb,+DAA+D;gBAC/D,+DAA+D;gBAC/D,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,cAAc,OAAO,CAAC,QAAQ,2DAA2D;iBACjG,CAAA;YAEH;gBACE,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,0BAA0B,OAAO,CAAC,QAAQ,EAAE;iBACpD,CAAA;QACL,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 3. Add execution logic in workflowExecutor.ts
|
|
14
14
|
* 4. Mirror in frontend nodeTypeRegistry.ts + node components
|
|
15
15
|
*/
|
|
16
|
-
import type { WorkflowNodeType } from './workflowTypes
|
|
16
|
+
import type { WorkflowNodeType } from './workflowTypes';
|
|
17
17
|
export interface NodeTypeEntry {
|
|
18
18
|
type: WorkflowNodeType;
|
|
19
19
|
label: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeTypeRegistry.d.ts","sourceRoot":"","sources":["../../src/lib/nodeTypeRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nodeTypeRegistry.d.ts","sourceRoot":"","sources":["../../src/lib/nodeTypeRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAMvD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAA;CAC1B;AAMD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAqGtE,CAAA;AAMD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,EAyClD,CAAA;AAMD,uDAAuD;AACvD,eAAO,MAAM,cAAc,EAAE,gBAAgB,EAA0D,CAAA;AAEvG,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,aAAa,GAAG,SAAS,CAElF"}
|
|
@@ -1358,30 +1358,30 @@ async function executeGuardrailNode(node, context, options, trace, workflowFile)
|
|
|
1358
1358
|
: JSON.stringify(inputToValidate, null, 2);
|
|
1359
1359
|
// Create a raw prompt that validates the input
|
|
1360
1360
|
// The system prompt should instruct the LLM to analyze and return a structured response
|
|
1361
|
-
const validationPrompt = `---
|
|
1362
|
-
id: guardrail-validation
|
|
1363
|
-
name: Guardrail Validation
|
|
1364
|
-
version: 1.0.0
|
|
1365
|
-
description: Validates input against guardrail criteria
|
|
1366
|
-
---
|
|
1367
|
-
|
|
1368
|
-
# System
|
|
1369
|
-
${data.systemPrompt}
|
|
1370
|
-
|
|
1371
|
-
# Input to Validate
|
|
1372
|
-
\`\`\`
|
|
1373
|
-
${inputStr}
|
|
1374
|
-
\`\`\`
|
|
1375
|
-
|
|
1376
|
-
# Instructions
|
|
1377
|
-
Analyze the input above according to the system criteria. Return your analysis as a JSON object with the following structure:
|
|
1378
|
-
\`\`\`json
|
|
1379
|
-
{
|
|
1380
|
-
"analysis": "Your analysis of the input",
|
|
1381
|
-
"score": 0.0 to 1.0,
|
|
1382
|
-
"rejected": true or false
|
|
1383
|
-
}
|
|
1384
|
-
\`\`\`
|
|
1361
|
+
const validationPrompt = `---
|
|
1362
|
+
id: guardrail-validation
|
|
1363
|
+
name: Guardrail Validation
|
|
1364
|
+
version: 1.0.0
|
|
1365
|
+
description: Validates input against guardrail criteria
|
|
1366
|
+
---
|
|
1367
|
+
|
|
1368
|
+
# System
|
|
1369
|
+
${data.systemPrompt}
|
|
1370
|
+
|
|
1371
|
+
# Input to Validate
|
|
1372
|
+
\`\`\`
|
|
1373
|
+
${inputStr}
|
|
1374
|
+
\`\`\`
|
|
1375
|
+
|
|
1376
|
+
# Instructions
|
|
1377
|
+
Analyze the input above according to the system criteria. Return your analysis as a JSON object with the following structure:
|
|
1378
|
+
\`\`\`json
|
|
1379
|
+
{
|
|
1380
|
+
"analysis": "Your analysis of the input",
|
|
1381
|
+
"score": 0.0 to 1.0,
|
|
1382
|
+
"rejected": true or false
|
|
1383
|
+
}
|
|
1384
|
+
\`\`\`
|
|
1385
1385
|
`;
|
|
1386
1386
|
// Emit beforeValidation checkpoint event
|
|
1387
1387
|
const beforeEvent = {
|
|
@@ -4476,29 +4476,29 @@ async function executeChatAgentNode(node, context, options, trace, state, workfl
|
|
|
4476
4476
|
}
|
|
4477
4477
|
// Build guardrail validation prompt
|
|
4478
4478
|
const inputStr = typeof currentInput === 'string' ? currentInput : JSON.stringify(currentInput, null, 2);
|
|
4479
|
-
const validationPrompt = `---
|
|
4480
|
-
id: chat-agent-guardrail
|
|
4481
|
-
name: Chat Agent Guardrail
|
|
4482
|
-
version: 1.0.0
|
|
4483
|
-
---
|
|
4484
|
-
|
|
4485
|
-
# System
|
|
4486
|
-
${data.guardrailSystemPrompt}
|
|
4487
|
-
|
|
4488
|
-
# Input to Validate
|
|
4489
|
-
\`\`\`
|
|
4490
|
-
${inputStr}
|
|
4491
|
-
\`\`\`
|
|
4492
|
-
|
|
4493
|
-
# Instructions
|
|
4494
|
-
Analyze the input above. Return a JSON object:
|
|
4495
|
-
\`\`\`json
|
|
4496
|
-
{
|
|
4497
|
-
"analysis": "Your analysis",
|
|
4498
|
-
"score": 0.0 to 1.0,
|
|
4499
|
-
"rejected": true or false
|
|
4500
|
-
}
|
|
4501
|
-
\`\`\`
|
|
4479
|
+
const validationPrompt = `---
|
|
4480
|
+
id: chat-agent-guardrail
|
|
4481
|
+
name: Chat Agent Guardrail
|
|
4482
|
+
version: 1.0.0
|
|
4483
|
+
---
|
|
4484
|
+
|
|
4485
|
+
# System
|
|
4486
|
+
${data.guardrailSystemPrompt}
|
|
4487
|
+
|
|
4488
|
+
# Input to Validate
|
|
4489
|
+
\`\`\`
|
|
4490
|
+
${inputStr}
|
|
4491
|
+
\`\`\`
|
|
4492
|
+
|
|
4493
|
+
# Instructions
|
|
4494
|
+
Analyze the input above. Return a JSON object:
|
|
4495
|
+
\`\`\`json
|
|
4496
|
+
{
|
|
4497
|
+
"analysis": "Your analysis",
|
|
4498
|
+
"score": 0.0 to 1.0,
|
|
4499
|
+
"rejected": true or false
|
|
4500
|
+
}
|
|
4501
|
+
\`\`\`
|
|
4502
4502
|
`;
|
|
4503
4503
|
if (!options.executePrompt) {
|
|
4504
4504
|
throw new Error('No executePrompt function provided for guardrail validation');
|
|
@@ -5178,28 +5178,28 @@ function buildSystemPromptWithTools(systemPrompt, tools, format) {
|
|
|
5178
5178
|
const toolDescriptions = tools.map(t => `- ${t.name}: ${t.description}${t.parameters?.properties ? ` (params: ${Object.keys(t.parameters.properties).join(', ')})` : ''}`).join('\n');
|
|
5179
5179
|
let formatInstructions = '';
|
|
5180
5180
|
if (format === 'xml' || format === 'auto') {
|
|
5181
|
-
formatInstructions = `
|
|
5182
|
-
|
|
5183
|
-
To use a tool, respond with XML in this format:
|
|
5184
|
-
<tool_call>
|
|
5185
|
-
<name>tool_name</name>
|
|
5186
|
-
<params>{"param1": "value1"}</params>
|
|
5187
|
-
</tool_call>
|
|
5188
|
-
|
|
5181
|
+
formatInstructions = `
|
|
5182
|
+
|
|
5183
|
+
To use a tool, respond with XML in this format:
|
|
5184
|
+
<tool_call>
|
|
5185
|
+
<name>tool_name</name>
|
|
5186
|
+
<params>{"param1": "value1"}</params>
|
|
5187
|
+
</tool_call>
|
|
5188
|
+
|
|
5189
5189
|
When you have the final answer and don't need any more tools, respond normally without XML tags.`;
|
|
5190
5190
|
}
|
|
5191
5191
|
else if (format === 'json') {
|
|
5192
|
-
formatInstructions = `
|
|
5193
|
-
|
|
5194
|
-
To use a tool, respond with JSON in this format:
|
|
5195
|
-
{"tool": "tool_name", "parameters": {"param1": "value1"}}
|
|
5196
|
-
|
|
5192
|
+
formatInstructions = `
|
|
5193
|
+
|
|
5194
|
+
To use a tool, respond with JSON in this format:
|
|
5195
|
+
{"tool": "tool_name", "parameters": {"param1": "value1"}}
|
|
5196
|
+
|
|
5197
5197
|
When you have the final answer and don't need any more tools, respond with plain text (no JSON).`;
|
|
5198
5198
|
}
|
|
5199
|
-
return `${systemPrompt}
|
|
5200
|
-
|
|
5201
|
-
You have access to the following tools:
|
|
5202
|
-
${toolDescriptions}
|
|
5199
|
+
return `${systemPrompt}
|
|
5200
|
+
|
|
5201
|
+
You have access to the following tools:
|
|
5202
|
+
${toolDescriptions}
|
|
5203
5203
|
${formatInstructions}`;
|
|
5204
5204
|
}
|
|
5205
5205
|
/**
|
package/package.json
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@prompd/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Node.js CLI for structured prompt definitions with universal LLM provider support. Also usable as a library in TypeScript/React apps.",
|
|
5
|
-
"main": "dist/lib/index.js",
|
|
6
|
-
"types": "dist/lib/index.d.ts",
|
|
7
|
-
"bin": {
|
|
8
|
-
"prompd": "./bin/prompd.js"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/lib/index.d.ts",
|
|
13
|
-
"import": "./dist/lib/index.js",
|
|
14
|
-
"require": "./dist/lib/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./cli": "./bin/prompd.js",
|
|
17
|
-
"./parser": {
|
|
18
|
-
"types": "./dist/lib/workflowParser.d.ts",
|
|
19
|
-
"import": "./dist/lib/workflowParser.js",
|
|
20
|
-
"default": "./dist/lib/workflowParser.js"
|
|
21
|
-
},
|
|
22
|
-
"./types": {
|
|
23
|
-
"types": "./dist/lib/workflowTypes.d.ts",
|
|
24
|
-
"import": "./dist/lib/workflowTypes.js",
|
|
25
|
-
"default": "./dist/lib/workflowTypes.js"
|
|
26
|
-
},
|
|
27
|
-
"./validator": {
|
|
28
|
-
"types": "./dist/lib/workflowValidator.d.ts",
|
|
29
|
-
"import": "./dist/lib/workflowValidator.js",
|
|
30
|
-
"default": "./dist/lib/workflowValidator.js"
|
|
31
|
-
},
|
|
32
|
-
"./providers": {
|
|
33
|
-
"types": "./dist/lib/providers/types.d.ts",
|
|
34
|
-
"import": "./dist/lib/providers/types.js",
|
|
35
|
-
"require": "./dist/lib/providers/types.js"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"files": [
|
|
39
|
-
"dist/",
|
|
40
|
-
"bin/",
|
|
41
|
-
"README.md"
|
|
42
|
-
],
|
|
43
|
-
"scripts": {
|
|
44
|
-
"build": "tsc",
|
|
45
|
-
"test": "jest",
|
|
46
|
-
"test:watch": "jest --watch",
|
|
47
|
-
"dev": "ts-node src/index.ts",
|
|
48
|
-
"prepublishOnly": "npm run build"
|
|
49
|
-
},
|
|
50
|
-
"keywords": [
|
|
51
|
-
"ai",
|
|
52
|
-
"llm",
|
|
53
|
-
"prompts",
|
|
54
|
-
"cli",
|
|
55
|
-
"openai",
|
|
56
|
-
"anthropic",
|
|
57
|
-
"ollama",
|
|
58
|
-
"prompt-engineering"
|
|
59
|
-
],
|
|
60
|
-
"author": "Logikbug",
|
|
61
|
-
"license": "MIT",
|
|
62
|
-
"engines": {
|
|
63
|
-
"node": ">=16.0.0"
|
|
64
|
-
},
|
|
65
|
-
"dependencies": {
|
|
66
|
-
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
67
|
-
"@types/nunjucks": "^3.2.6",
|
|
68
|
-
"adm-zip": "^0.5.16",
|
|
69
|
-
"archiver": "^6.0.1",
|
|
70
|
-
"axios": "^1.6.2",
|
|
71
|
-
"bcrypt": "^5.1.1",
|
|
72
|
-
"chalk": "^4.1.2",
|
|
73
|
-
"commander": "^11.1.0",
|
|
74
|
-
"compression": "^1.7.4",
|
|
75
|
-
"cors": "^2.8.5",
|
|
76
|
-
"express": "^4.18.2",
|
|
77
|
-
"express-rate-limit": "^7.1.5",
|
|
78
|
-
"fs-extra": "^11.2.0",
|
|
79
|
-
"glob": "^10.3.10",
|
|
80
|
-
"helmet": "^7.1.0",
|
|
81
|
-
"inquirer": "^9.2.12",
|
|
82
|
-
"js-yaml": "^4.1.0",
|
|
83
|
-
"jsonwebtoken": "^9.0.2",
|
|
84
|
-
"mammoth": "^1.11.0",
|
|
85
|
-
"nunjucks": "^3.2.4",
|
|
86
|
-
"pdf-parse": "^2.4.5",
|
|
87
|
-
"semver": "^7.5.4",
|
|
88
|
-
"sharp": "^0.34.4",
|
|
89
|
-
"tar": "^7.0.1",
|
|
90
|
-
"xlsx": "^0.18.5",
|
|
91
|
-
"yaml": "^2.3.4"
|
|
92
|
-
},
|
|
93
|
-
"devDependencies": {
|
|
94
|
-
"@types/adm-zip": "^0.5.7",
|
|
95
|
-
"@types/archiver": "^6.0.2",
|
|
96
|
-
"@types/bcrypt": "^5.0.2",
|
|
97
|
-
"@types/compression": "^1.7.5",
|
|
98
|
-
"@types/cors": "^2.8.17",
|
|
99
|
-
"@types/express": "^4.17.21",
|
|
100
|
-
"@types/fs-extra": "^11.0.4",
|
|
101
|
-
"@types/jest": "^29.5.8",
|
|
102
|
-
"@types/js-yaml": "^4.0.9",
|
|
103
|
-
"@types/jsonwebtoken": "^9.0.5",
|
|
104
|
-
"@types/node": "^20.10.4",
|
|
105
|
-
"@types/pdf-parse": "^1.1.5",
|
|
106
|
-
"@types/semver": "^7.5.6",
|
|
107
|
-
"@types/tar": "^6.1.11",
|
|
108
|
-
"jest": "^29.7.0",
|
|
109
|
-
"ts-jest": "^29.1.1",
|
|
110
|
-
"ts-node": "^10.9.1",
|
|
111
|
-
"typescript": "^5.3.3"
|
|
112
|
-
},
|
|
113
|
-
"jest": {
|
|
114
|
-
"preset": "ts-jest",
|
|
115
|
-
"testEnvironment": "node",
|
|
116
|
-
"testMatch": [
|
|
117
|
-
"**/tests/**/*.test.ts"
|
|
118
|
-
],
|
|
119
|
-
"collectCoverageFrom": [
|
|
120
|
-
"src/**/*.ts",
|
|
121
|
-
"!src/**/*.d.ts"
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@prompd/cli",
|
|
3
|
+
"version": "0.5.0-beta.1",
|
|
4
|
+
"description": "Node.js CLI for structured prompt definitions with universal LLM provider support. Also usable as a library in TypeScript/React apps.",
|
|
5
|
+
"main": "dist/lib/index.js",
|
|
6
|
+
"types": "dist/lib/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"prompd": "./bin/prompd.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/lib/index.d.ts",
|
|
13
|
+
"import": "./dist/lib/index.js",
|
|
14
|
+
"require": "./dist/lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./cli": "./bin/prompd.js",
|
|
17
|
+
"./parser": {
|
|
18
|
+
"types": "./dist/lib/workflowParser.d.ts",
|
|
19
|
+
"import": "./dist/lib/workflowParser.js",
|
|
20
|
+
"default": "./dist/lib/workflowParser.js"
|
|
21
|
+
},
|
|
22
|
+
"./types": {
|
|
23
|
+
"types": "./dist/lib/workflowTypes.d.ts",
|
|
24
|
+
"import": "./dist/lib/workflowTypes.js",
|
|
25
|
+
"default": "./dist/lib/workflowTypes.js"
|
|
26
|
+
},
|
|
27
|
+
"./validator": {
|
|
28
|
+
"types": "./dist/lib/workflowValidator.d.ts",
|
|
29
|
+
"import": "./dist/lib/workflowValidator.js",
|
|
30
|
+
"default": "./dist/lib/workflowValidator.js"
|
|
31
|
+
},
|
|
32
|
+
"./providers": {
|
|
33
|
+
"types": "./dist/lib/providers/types.d.ts",
|
|
34
|
+
"import": "./dist/lib/providers/types.js",
|
|
35
|
+
"require": "./dist/lib/providers/types.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist/",
|
|
40
|
+
"bin/",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"test": "jest",
|
|
46
|
+
"test:watch": "jest --watch",
|
|
47
|
+
"dev": "ts-node src/index.ts",
|
|
48
|
+
"prepublishOnly": "npm run build"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"ai",
|
|
52
|
+
"llm",
|
|
53
|
+
"prompts",
|
|
54
|
+
"cli",
|
|
55
|
+
"openai",
|
|
56
|
+
"anthropic",
|
|
57
|
+
"ollama",
|
|
58
|
+
"prompt-engineering"
|
|
59
|
+
],
|
|
60
|
+
"author": "Logikbug",
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=16.0.0"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
67
|
+
"@types/nunjucks": "^3.2.6",
|
|
68
|
+
"adm-zip": "^0.5.16",
|
|
69
|
+
"archiver": "^6.0.1",
|
|
70
|
+
"axios": "^1.6.2",
|
|
71
|
+
"bcrypt": "^5.1.1",
|
|
72
|
+
"chalk": "^4.1.2",
|
|
73
|
+
"commander": "^11.1.0",
|
|
74
|
+
"compression": "^1.7.4",
|
|
75
|
+
"cors": "^2.8.5",
|
|
76
|
+
"express": "^4.18.2",
|
|
77
|
+
"express-rate-limit": "^7.1.5",
|
|
78
|
+
"fs-extra": "^11.2.0",
|
|
79
|
+
"glob": "^10.3.10",
|
|
80
|
+
"helmet": "^7.1.0",
|
|
81
|
+
"inquirer": "^9.2.12",
|
|
82
|
+
"js-yaml": "^4.1.0",
|
|
83
|
+
"jsonwebtoken": "^9.0.2",
|
|
84
|
+
"mammoth": "^1.11.0",
|
|
85
|
+
"nunjucks": "^3.2.4",
|
|
86
|
+
"pdf-parse": "^2.4.5",
|
|
87
|
+
"semver": "^7.5.4",
|
|
88
|
+
"sharp": "^0.34.4",
|
|
89
|
+
"tar": "^7.0.1",
|
|
90
|
+
"xlsx": "^0.18.5",
|
|
91
|
+
"yaml": "^2.3.4"
|
|
92
|
+
},
|
|
93
|
+
"devDependencies": {
|
|
94
|
+
"@types/adm-zip": "^0.5.7",
|
|
95
|
+
"@types/archiver": "^6.0.2",
|
|
96
|
+
"@types/bcrypt": "^5.0.2",
|
|
97
|
+
"@types/compression": "^1.7.5",
|
|
98
|
+
"@types/cors": "^2.8.17",
|
|
99
|
+
"@types/express": "^4.17.21",
|
|
100
|
+
"@types/fs-extra": "^11.0.4",
|
|
101
|
+
"@types/jest": "^29.5.8",
|
|
102
|
+
"@types/js-yaml": "^4.0.9",
|
|
103
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
104
|
+
"@types/node": "^20.10.4",
|
|
105
|
+
"@types/pdf-parse": "^1.1.5",
|
|
106
|
+
"@types/semver": "^7.5.6",
|
|
107
|
+
"@types/tar": "^6.1.11",
|
|
108
|
+
"jest": "^29.7.0",
|
|
109
|
+
"ts-jest": "^29.1.1",
|
|
110
|
+
"ts-node": "^10.9.1",
|
|
111
|
+
"typescript": "^5.3.3"
|
|
112
|
+
},
|
|
113
|
+
"jest": {
|
|
114
|
+
"preset": "ts-jest",
|
|
115
|
+
"testEnvironment": "node",
|
|
116
|
+
"testMatch": [
|
|
117
|
+
"**/tests/**/*.test.ts"
|
|
118
|
+
],
|
|
119
|
+
"collectCoverageFrom": [
|
|
120
|
+
"src/**/*.ts",
|
|
121
|
+
"!src/**/*.d.ts"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
}
|