@langadventurellc/task-trellis-mcp 1.3.2 → 1.4.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 +0 -6
- package/dist/server.js +1 -55
- package/dist/server.js.map +1 -1
- package/package.json +15 -15
- package/dist/__tests__/copyBasicClaudeAgents.test.d.ts +0 -2
- package/dist/__tests__/copyBasicClaudeAgents.test.d.ts.map +0 -1
- package/dist/__tests__/copyBasicClaudeAgents.test.js +0 -24
- package/dist/__tests__/copyBasicClaudeAgents.test.js.map +0 -1
- package/dist/prompts/PromptArgument.d.ts +0 -16
- package/dist/prompts/PromptArgument.d.ts.map +0 -1
- package/dist/prompts/PromptArgument.js +0 -3
- package/dist/prompts/PromptArgument.js.map +0 -1
- package/dist/prompts/PromptManager.d.ts +0 -48
- package/dist/prompts/PromptManager.d.ts.map +0 -1
- package/dist/prompts/PromptManager.js +0 -151
- package/dist/prompts/PromptManager.js.map +0 -1
- package/dist/prompts/PromptMessage.d.ts +0 -11
- package/dist/prompts/PromptMessage.d.ts.map +0 -1
- package/dist/prompts/PromptMessage.js +0 -3
- package/dist/prompts/PromptMessage.js.map +0 -1
- package/dist/prompts/PromptParser.d.ts +0 -7
- package/dist/prompts/PromptParser.d.ts.map +0 -1
- package/dist/prompts/PromptParser.js +0 -141
- package/dist/prompts/PromptParser.js.map +0 -1
- package/dist/prompts/PromptRenderer.d.ts +0 -38
- package/dist/prompts/PromptRenderer.d.ts.map +0 -1
- package/dist/prompts/PromptRenderer.js +0 -128
- package/dist/prompts/PromptRenderer.js.map +0 -1
- package/dist/prompts/PromptsRegistry.d.ts +0 -43
- package/dist/prompts/PromptsRegistry.d.ts.map +0 -1
- package/dist/prompts/PromptsRegistry.js +0 -76
- package/dist/prompts/PromptsRegistry.js.map +0 -1
- package/dist/prompts/TrellisPrompt.d.ts +0 -19
- package/dist/prompts/TrellisPrompt.d.ts.map +0 -1
- package/dist/prompts/TrellisPrompt.js +0 -3
- package/dist/prompts/TrellisPrompt.js.map +0 -1
- package/dist/prompts/__tests__/PromptArgument.test.d.ts +0 -2
- package/dist/prompts/__tests__/PromptArgument.test.d.ts.map +0 -1
- package/dist/prompts/__tests__/PromptArgument.test.js +0 -60
- package/dist/prompts/__tests__/PromptArgument.test.js.map +0 -1
- package/dist/prompts/__tests__/PromptManager.test.d.ts +0 -2
- package/dist/prompts/__tests__/PromptManager.test.d.ts.map +0 -1
- package/dist/prompts/__tests__/PromptManager.test.js +0 -364
- package/dist/prompts/__tests__/PromptManager.test.js.map +0 -1
- package/dist/prompts/__tests__/PromptParser.test.d.ts +0 -2
- package/dist/prompts/__tests__/PromptParser.test.d.ts.map +0 -1
- package/dist/prompts/__tests__/PromptParser.test.js +0 -237
- package/dist/prompts/__tests__/PromptParser.test.js.map +0 -1
- package/dist/prompts/__tests__/PromptRenderer.test.d.ts +0 -2
- package/dist/prompts/__tests__/PromptRenderer.test.d.ts.map +0 -1
- package/dist/prompts/__tests__/PromptRenderer.test.js +0 -325
- package/dist/prompts/__tests__/PromptRenderer.test.js.map +0 -1
- package/dist/prompts/__tests__/TrellisPrompt.test.d.ts +0 -2
- package/dist/prompts/__tests__/TrellisPrompt.test.d.ts.map +0 -1
- package/dist/prompts/__tests__/TrellisPrompt.test.js +0 -107
- package/dist/prompts/__tests__/TrellisPrompt.test.js.map +0 -1
- package/dist/prompts/index.d.ts +0 -9
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js +0 -14
- package/dist/prompts/index.js.map +0 -1
- package/dist/prompts/registry.d.ts +0 -6
- package/dist/prompts/registry.d.ts.map +0 -1
- package/dist/prompts/registry.js +0 -60
- package/dist/prompts/registry.js.map +0 -1
- package/dist/resources/basic/prompts/create-epics.md +0 -177
- package/dist/resources/basic/prompts/create-features.md +0 -172
- package/dist/resources/basic/prompts/create-project.md +0 -128
- package/dist/resources/basic/prompts/create-tasks.md +0 -225
- package/dist/resources/basic/prompts/implement-task.md +0 -170
- package/dist/resources/basic-claude/agents/implementation-planner.md +0 -187
- package/dist/resources/basic-claude/agents/issue-verifier.md +0 -154
- package/dist/resources/basic-claude/prompts/create-epics.md +0 -204
- package/dist/resources/basic-claude/prompts/create-features.md +0 -199
- package/dist/resources/basic-claude/prompts/create-project.md +0 -155
- package/dist/resources/basic-claude/prompts/create-tasks.md +0 -252
- package/dist/resources/basic-claude/prompts/implement-task.md +0 -179
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parsePromptFile = parsePromptFile;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const yaml_1 = require("yaml");
|
|
7
|
-
/**
|
|
8
|
-
* Parses a markdown prompt file with YAML frontmatter into a TrellisPrompt object.
|
|
9
|
-
* Extracts frontmatter metadata and validates the structure.
|
|
10
|
-
*/
|
|
11
|
-
async function parsePromptFile(filePath) {
|
|
12
|
-
try {
|
|
13
|
-
const fileContent = await (0, promises_1.readFile)(filePath, "utf-8");
|
|
14
|
-
const promptName = generatePromptName(filePath);
|
|
15
|
-
const { frontmatter, body } = extractFrontmatterAndBody(fileContent);
|
|
16
|
-
const promptData = buildPromptData(promptName, frontmatter, body);
|
|
17
|
-
validatePromptData(promptData, filePath);
|
|
18
|
-
return promptData;
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
22
|
-
throw new Error(`Failed to parse prompt file ${filePath}: ${errorMessage}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// Helper functions (private, not exported)
|
|
26
|
-
/**
|
|
27
|
-
* Validates that parsed prompt data meets all requirements.
|
|
28
|
-
* Throws descriptive errors for invalid prompts.
|
|
29
|
-
*/
|
|
30
|
-
function validatePromptData(data, filePath) {
|
|
31
|
-
// Validate required fields
|
|
32
|
-
if (!data.name) {
|
|
33
|
-
throw new Error(`Missing prompt name in ${filePath}`);
|
|
34
|
-
}
|
|
35
|
-
if (!data.description) {
|
|
36
|
-
throw new Error(`Missing required 'description' field in frontmatter for ${filePath}`);
|
|
37
|
-
}
|
|
38
|
-
if (!data.userTemplate || data.userTemplate.trim().length === 0) {
|
|
39
|
-
throw new Error(`Empty prompt body in ${filePath}`);
|
|
40
|
-
}
|
|
41
|
-
// Validate kebab-case name
|
|
42
|
-
if (!/^[a-z]+(-[a-z]+)*$/.test(data.name)) {
|
|
43
|
-
throw new Error(`Invalid prompt name '${data.name}' in ${filePath}. Must be kebab-case.`);
|
|
44
|
-
}
|
|
45
|
-
// Validate unique argument names
|
|
46
|
-
const argNames = new Set();
|
|
47
|
-
for (const arg of data.arguments) {
|
|
48
|
-
if (!arg.name) {
|
|
49
|
-
throw new Error(`Missing argument name in ${filePath}`);
|
|
50
|
-
}
|
|
51
|
-
if (argNames.has(arg.name)) {
|
|
52
|
-
throw new Error(`Duplicate argument name '${arg.name}' in ${filePath}`);
|
|
53
|
-
}
|
|
54
|
-
argNames.add(arg.name);
|
|
55
|
-
// Validate argument fields
|
|
56
|
-
if (arg.type && arg.type !== "string" && arg.type !== "boolean") {
|
|
57
|
-
throw new Error(`Invalid argument type '${String(arg.type)}' for '${arg.name}' in ${filePath}`);
|
|
58
|
-
}
|
|
59
|
-
if (typeof arg.required !== "boolean") {
|
|
60
|
-
throw new Error(`Invalid 'required' value for argument '${arg.name}' in ${filePath}`);
|
|
61
|
-
}
|
|
62
|
-
if (!arg.description) {
|
|
63
|
-
throw new Error(`Missing description for argument '${arg.name}' in ${filePath}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function extractFrontmatterAndBody(content) {
|
|
68
|
-
const frontmatterRegex = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/;
|
|
69
|
-
const match = content.match(frontmatterRegex);
|
|
70
|
-
if (!match) {
|
|
71
|
-
throw new Error("Invalid format: Expected YAML frontmatter delimited by --- markers");
|
|
72
|
-
}
|
|
73
|
-
const [, yamlContent, bodyContent] = match;
|
|
74
|
-
let frontmatter;
|
|
75
|
-
try {
|
|
76
|
-
frontmatter = (0, yaml_1.parse)(yamlContent);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
throw new Error(`Invalid YAML frontmatter: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
80
|
-
}
|
|
81
|
-
if (!frontmatter ||
|
|
82
|
-
typeof frontmatter !== "object" ||
|
|
83
|
-
Array.isArray(frontmatter)) {
|
|
84
|
-
throw new Error("Invalid YAML frontmatter: Expected an object");
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
frontmatter: frontmatter,
|
|
88
|
-
body: bodyContent.trim(),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function generatePromptName(filePath) {
|
|
92
|
-
const fileName = (0, path_1.basename)(filePath, ".md");
|
|
93
|
-
return fileName.toLowerCase().replace(/_/g, "-");
|
|
94
|
-
}
|
|
95
|
-
function buildPromptData(name, frontmatter, userTemplate) {
|
|
96
|
-
// Build arguments array with default if not specified
|
|
97
|
-
const args = parseArguments(frontmatter.args);
|
|
98
|
-
return {
|
|
99
|
-
name,
|
|
100
|
-
title: typeof frontmatter.title === "string" ? frontmatter.title : undefined,
|
|
101
|
-
description: typeof frontmatter.description === "string"
|
|
102
|
-
? frontmatter.description
|
|
103
|
-
: "",
|
|
104
|
-
arguments: args,
|
|
105
|
-
userTemplate,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function parseArguments(args) {
|
|
109
|
-
// Default to single 'input' argument if not specified
|
|
110
|
-
if (!args) {
|
|
111
|
-
return [
|
|
112
|
-
{
|
|
113
|
-
name: "input",
|
|
114
|
-
required: false,
|
|
115
|
-
description: "Free-text input",
|
|
116
|
-
},
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
if (!Array.isArray(args)) {
|
|
120
|
-
throw new Error("Invalid 'args' field: Expected an array");
|
|
121
|
-
}
|
|
122
|
-
return args.map((arg, index) => {
|
|
123
|
-
if (!arg || typeof arg !== "object" || Array.isArray(arg)) {
|
|
124
|
-
throw new Error(`Invalid argument at index ${index}: Expected an object`);
|
|
125
|
-
}
|
|
126
|
-
const argObj = arg;
|
|
127
|
-
const argType = argObj.type;
|
|
128
|
-
const validatedType = argType === "boolean"
|
|
129
|
-
? "boolean"
|
|
130
|
-
: argType === "string"
|
|
131
|
-
? "string"
|
|
132
|
-
: argType;
|
|
133
|
-
return {
|
|
134
|
-
name: typeof argObj.name === "string" ? argObj.name : "",
|
|
135
|
-
type: validatedType,
|
|
136
|
-
required: Boolean(argObj.required),
|
|
137
|
-
description: typeof argObj.description === "string" ? argObj.description : "",
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=PromptParser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PromptParser.js","sourceRoot":"","sources":["../../src/prompts/PromptParser.ts"],"names":[],"mappings":";;AAUA,0CAkBC;AA5BD,0CAAuC;AACvC,+BAAgC;AAChC,+BAA6B;AAI7B;;;GAGG;AACI,KAAK,UAAU,eAAe,CACnC,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAEhD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;QAErE,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAClE,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEzC,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,YAAY,GAChB,KAAK,YA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,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC7B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,sBAAsB,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,MAAM,GAAG,GAA8B,CAAC;QAE9C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC;QAC5B,MAAM,aAAa,GACjB,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,OAAO,KAAK,QAAQ;gBACpB,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,OAAO,CAAC;QAEhB,OAAO;YACL,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACxD,IAAI,EAAE,aAAiD;YACvD,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;YAClC,WAAW,EACT,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;SACnE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { TrellisPrompt } from "./index";
|
|
2
|
-
import { PromptMessage } from "./PromptMessage";
|
|
3
|
-
/**
|
|
4
|
-
* Renders prompt templates by substituting placeholders with provided arguments.
|
|
5
|
-
* Handles both $ARGUMENTS blocks and individual ${argName} substitutions.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PromptRenderer {
|
|
8
|
-
/**
|
|
9
|
-
* Main entry point for rendering a prompt with arguments.
|
|
10
|
-
* Returns structured messages suitable for MCP API consumption.
|
|
11
|
-
*/
|
|
12
|
-
renderPrompt(prompt: TrellisPrompt, args: Record<string, string>): PromptMessage[];
|
|
13
|
-
/**
|
|
14
|
-
* Validates that all required arguments are present and non-empty after trimming
|
|
15
|
-
*/
|
|
16
|
-
private validateRequiredArguments;
|
|
17
|
-
/**
|
|
18
|
-
* Handles $ARGUMENTS placeholder substitution.
|
|
19
|
-
* Single 'input' argument: inject raw value
|
|
20
|
-
* Multiple arguments: create formatted "Inputs" section
|
|
21
|
-
*/
|
|
22
|
-
private substituteArguments;
|
|
23
|
-
/**
|
|
24
|
-
* Handles individual ${argName} placeholder substitution
|
|
25
|
-
*/
|
|
26
|
-
private substitutePlaceholders;
|
|
27
|
-
/**
|
|
28
|
-
* Formats multiple arguments as a readable "Inputs" section
|
|
29
|
-
*/
|
|
30
|
-
private formatArgumentsBlock;
|
|
31
|
-
/**
|
|
32
|
-
* Sanitizes argument values to prevent injection attacks.
|
|
33
|
-
* Escapes special characters that could break markdown formatting
|
|
34
|
-
* or introduce unwanted content.
|
|
35
|
-
*/
|
|
36
|
-
private sanitizeValue;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=PromptRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PromptRenderer.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,qBAAa,cAAc;IACzB;;;OAGG;IACH,YAAY,CACV,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,aAAa,EAAE;IA6BlB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAmBjC;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAyB3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAoC9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PromptRenderer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Renders prompt templates by substituting placeholders with provided arguments.
|
|
6
|
-
* Handles both $ARGUMENTS blocks and individual ${argName} substitutions.
|
|
7
|
-
*/
|
|
8
|
-
class PromptRenderer {
|
|
9
|
-
/**
|
|
10
|
-
* Main entry point for rendering a prompt with arguments.
|
|
11
|
-
* Returns structured messages suitable for MCP API consumption.
|
|
12
|
-
*/
|
|
13
|
-
renderPrompt(prompt, args) {
|
|
14
|
-
// Validate required arguments
|
|
15
|
-
this.validateRequiredArguments(prompt, args);
|
|
16
|
-
// Process template
|
|
17
|
-
let renderedTemplate = prompt.userTemplate;
|
|
18
|
-
// Handle $ARGUMENTS substitution
|
|
19
|
-
renderedTemplate = this.substituteArguments(renderedTemplate, prompt, args);
|
|
20
|
-
// Handle ${argName} placeholders
|
|
21
|
-
renderedTemplate = this.substitutePlaceholders(renderedTemplate, prompt, args);
|
|
22
|
-
// Build response messages
|
|
23
|
-
const messages = [];
|
|
24
|
-
// Add user message with rendered template
|
|
25
|
-
messages.push({
|
|
26
|
-
role: "user",
|
|
27
|
-
content: { type: "text", text: renderedTemplate },
|
|
28
|
-
});
|
|
29
|
-
return messages;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Validates that all required arguments are present and non-empty after trimming
|
|
33
|
-
*/
|
|
34
|
-
validateRequiredArguments(prompt, args) {
|
|
35
|
-
if (!prompt.arguments)
|
|
36
|
-
return;
|
|
37
|
-
for (const arg of prompt.arguments) {
|
|
38
|
-
if (arg.required) {
|
|
39
|
-
const value = args[arg.name];
|
|
40
|
-
if (!value || value.trim() === "") {
|
|
41
|
-
throw new Error(`Missing required argument: ${arg.name}. ` +
|
|
42
|
-
`Description: ${arg.description || "No description provided"}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Handles $ARGUMENTS placeholder substitution.
|
|
49
|
-
* Single 'input' argument: inject raw value
|
|
50
|
-
* Multiple arguments: create formatted "Inputs" section
|
|
51
|
-
*/
|
|
52
|
-
substituteArguments(template, prompt, args) {
|
|
53
|
-
const argumentsRegex = /\$ARGUMENTS/g;
|
|
54
|
-
if (!argumentsRegex.test(template)) {
|
|
55
|
-
return template;
|
|
56
|
-
}
|
|
57
|
-
// Special case: single 'input' argument
|
|
58
|
-
if (prompt.arguments?.length === 1 &&
|
|
59
|
-
prompt.arguments[0].name === "input") {
|
|
60
|
-
const value = args.input || "";
|
|
61
|
-
return template.replace(/\$ARGUMENTS/g, this.sanitizeValue(value));
|
|
62
|
-
}
|
|
63
|
-
// Multiple arguments: format as block
|
|
64
|
-
const argumentsBlock = this.formatArgumentsBlock(prompt, args);
|
|
65
|
-
return template.replace(/\$ARGUMENTS/g, argumentsBlock);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Handles individual ${argName} placeholder substitution
|
|
69
|
-
*/
|
|
70
|
-
substitutePlaceholders(template, prompt, args) {
|
|
71
|
-
// Match ${argName} placeholders
|
|
72
|
-
const placeholderRegex = /\$\{([^}]+)\}/g;
|
|
73
|
-
return template.replace(placeholderRegex, (match, argName) => {
|
|
74
|
-
const trimmedName = argName.trim();
|
|
75
|
-
// Check if argument is defined in prompt
|
|
76
|
-
const argDef = prompt.arguments?.find((a) => a.name === trimmedName);
|
|
77
|
-
if (trimmedName in args) {
|
|
78
|
-
const value = args[trimmedName];
|
|
79
|
-
return value ? this.sanitizeValue(value) : "";
|
|
80
|
-
}
|
|
81
|
-
// Handle missing optional arguments
|
|
82
|
-
if (argDef && !argDef.required) {
|
|
83
|
-
return "(not provided)";
|
|
84
|
-
}
|
|
85
|
-
// If argument not defined in prompt schema, leave placeholder as-is
|
|
86
|
-
if (!argDef) {
|
|
87
|
-
return match;
|
|
88
|
-
}
|
|
89
|
-
// This shouldn't happen if validateRequiredArguments was called
|
|
90
|
-
throw new Error(`Missing required argument in placeholder: ${trimmedName}`);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Formats multiple arguments as a readable "Inputs" section
|
|
95
|
-
*/
|
|
96
|
-
formatArgumentsBlock(prompt, args) {
|
|
97
|
-
if (!prompt.arguments || prompt.arguments.length === 0) {
|
|
98
|
-
return "";
|
|
99
|
-
}
|
|
100
|
-
const lines = ["## Inputs", ""];
|
|
101
|
-
for (const arg of prompt.arguments) {
|
|
102
|
-
const value = args[arg.name];
|
|
103
|
-
const displayValue = value && value.trim() ? this.sanitizeValue(value) : "(not provided)";
|
|
104
|
-
lines.push(`**${arg.name}**: ${displayValue}`);
|
|
105
|
-
if (arg.description) {
|
|
106
|
-
lines.push(`*${arg.description}*`);
|
|
107
|
-
}
|
|
108
|
-
lines.push("");
|
|
109
|
-
}
|
|
110
|
-
return lines.join("\n").trim();
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Sanitizes argument values to prevent injection attacks.
|
|
114
|
-
* Escapes special characters that could break markdown formatting
|
|
115
|
-
* or introduce unwanted content.
|
|
116
|
-
*/
|
|
117
|
-
sanitizeValue(value) {
|
|
118
|
-
return value
|
|
119
|
-
.replace(/\\/g, "\\\\") // Escape backslashes first
|
|
120
|
-
.replace(/`/g, "\\`") // Escape backticks
|
|
121
|
-
.replace(/\$/g, "\\$") // Escape dollar signs
|
|
122
|
-
.replace(/</g, "<") // Escape HTML tags
|
|
123
|
-
.replace(/>/g, ">")
|
|
124
|
-
.replace(/\n{3,}/g, "\n\n"); // Limit consecutive newlines
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.PromptRenderer = PromptRenderer;
|
|
128
|
-
//# sourceMappingURL=PromptRenderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PromptRenderer.js","sourceRoot":"","sources":["../../src/prompts/PromptRenderer.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,MAAa,cAAc;IACzB;;;OAGG;IACH,YAAY,CACV,MAAqB,EACrB,IAA4B;QAE5B,8BAA8B;QAC9B,IAAI,CAAC,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE7C,mBAAmB;QACnB,IAAI,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC;QAE3C,iCAAiC;QACjC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAE5E,iCAAiC;QACjC,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,CAC5C,gBAAgB,EAChB,MAAM,EACN,IAAI,CACL,CAAC;QAEF,0BAA0B;QAC1B,MAAM,QAAQ,GAAoB,EAAE,CAAC;QAErC,0CAA0C;QAC1C,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE;SAClD,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,yBAAyB,CAC/B,MAAqB,EACrB,IAA4B;QAE5B,IAAI,CAAC,MAAM,CAAC,SAAS;YAAE,OAAO;QAE9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACnC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,CAAC,KAAK,IA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AC,CAAC;YAE/C,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACpB,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC;YACrC,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,KAAa;QACjC,OAAO,KAAK;aACT,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,2BAA2B;aAClD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,mBAAmB;aACxC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,sBAAsB;aAC5C,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,mBAAmB;aACzC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,6BAA6B;IAC9D,CAAC;CACF;AA5KD,wCA4KC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry for MCP prompts that integrates PromptManager and PromptRenderer
|
|
3
|
-
* to provide slash command functionality in Claude Code.
|
|
4
|
-
*/
|
|
5
|
-
export declare class PromptsRegistry {
|
|
6
|
-
private manager;
|
|
7
|
-
private renderer;
|
|
8
|
-
private promptPackage;
|
|
9
|
-
constructor(promptPackage?: string);
|
|
10
|
-
/**
|
|
11
|
-
* Initialize the registry by loading all prompts
|
|
12
|
-
*/
|
|
13
|
-
initialize(): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Handle prompts/list endpoint - returns catalog of available prompts
|
|
16
|
-
* Omits internal-only fields like title, systemRules, and userTemplate
|
|
17
|
-
*/
|
|
18
|
-
listPrompts(): {
|
|
19
|
-
prompts: Array<{
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
arguments?: Array<{
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
required: boolean;
|
|
26
|
-
}>;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Handle prompts/get endpoint - renders template with arguments and returns messages
|
|
31
|
-
*/
|
|
32
|
-
getPrompt(name: string, args?: Record<string, string>): {
|
|
33
|
-
description?: string;
|
|
34
|
-
messages: Array<{
|
|
35
|
-
role: "system" | "user";
|
|
36
|
-
content: {
|
|
37
|
-
type: "text";
|
|
38
|
-
text: string;
|
|
39
|
-
};
|
|
40
|
-
}>;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=PromptsRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PromptsRegistry.d.ts","sourceRoot":"","sources":["../../src/prompts/PromptsRegistry.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,aAAa,CAAS;gBAElB,aAAa,GAAE,MAAgB;IAM3C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;;OAGG;IACH,WAAW,IAAI;QACb,OAAO,EAAE,KAAK,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,WAAW,EAAE,MAAM,CAAC;YACpB,SAAS,CAAC,EAAE,KAAK,CAAC;gBAChB,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,EAAE,MAAM,CAAC;gBACpB,QAAQ,EAAE,OAAO,CAAC;aACnB,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ;IAiBD;;OAEG;IACH,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B;QACD,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;YACxB,OAAO,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAE,CAAC;SACzC,CAAC,CAAC;KACJ;CAoCF"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PromptsRegistry = void 0;
|
|
4
|
-
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
5
|
-
const PromptManager_js_1 = require("./PromptManager.js");
|
|
6
|
-
const PromptRenderer_js_1 = require("./PromptRenderer.js");
|
|
7
|
-
/**
|
|
8
|
-
* Registry for MCP prompts that integrates PromptManager and PromptRenderer
|
|
9
|
-
* to provide slash command functionality in Claude Code.
|
|
10
|
-
*/
|
|
11
|
-
class PromptsRegistry {
|
|
12
|
-
manager;
|
|
13
|
-
renderer;
|
|
14
|
-
promptPackage;
|
|
15
|
-
constructor(promptPackage = "basic") {
|
|
16
|
-
this.promptPackage = promptPackage;
|
|
17
|
-
this.manager = new PromptManager_js_1.PromptManager(promptPackage);
|
|
18
|
-
this.renderer = new PromptRenderer_js_1.PromptRenderer();
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Initialize the registry by loading all prompts
|
|
22
|
-
*/
|
|
23
|
-
async initialize() {
|
|
24
|
-
await this.manager.load();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Handle prompts/list endpoint - returns catalog of available prompts
|
|
28
|
-
* Omits internal-only fields like title, systemRules, and userTemplate
|
|
29
|
-
*/
|
|
30
|
-
listPrompts() {
|
|
31
|
-
const allPrompts = this.manager.list();
|
|
32
|
-
// Convert to catalog entries, filtering out internal fields
|
|
33
|
-
const prompts = allPrompts.map((prompt) => ({
|
|
34
|
-
name: prompt.name,
|
|
35
|
-
description: prompt.description,
|
|
36
|
-
arguments: prompt.arguments.map((arg) => ({
|
|
37
|
-
name: arg.name,
|
|
38
|
-
description: arg.description || "",
|
|
39
|
-
required: arg.required || false,
|
|
40
|
-
})),
|
|
41
|
-
}));
|
|
42
|
-
return { prompts };
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Handle prompts/get endpoint - renders template with arguments and returns messages
|
|
46
|
-
*/
|
|
47
|
-
getPrompt(name, args) {
|
|
48
|
-
// Get the prompt
|
|
49
|
-
const prompt = this.manager.get(name);
|
|
50
|
-
if (!prompt) {
|
|
51
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, `Prompt not found: ${name}`);
|
|
52
|
-
}
|
|
53
|
-
// Validate required arguments
|
|
54
|
-
if (prompt.arguments) {
|
|
55
|
-
for (const arg of prompt.arguments) {
|
|
56
|
-
if (arg.required &&
|
|
57
|
-
(!args || !args[arg.name] || !args[arg.name].trim())) {
|
|
58
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, `Missing required argument: ${arg.name}. Description: ${arg.description || "No description provided"}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Render the prompt with provided arguments
|
|
63
|
-
const messages = this.renderer.renderPrompt(prompt, args || {});
|
|
64
|
-
// Convert to MCP format with rich text blocks
|
|
65
|
-
const mcpMessages = messages.map((msg) => ({
|
|
66
|
-
role: msg.role,
|
|
67
|
-
content: msg.content,
|
|
68
|
-
}));
|
|
69
|
-
return {
|
|
70
|
-
description: prompt.description,
|
|
71
|
-
messages: mcpMessages,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.PromptsRegistry = PromptsRegistry;
|
|
76
|
-
//# sourceMappingURL=PromptsRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PromptsRegistry.js","sourceRoot":"","sources":["../../src/prompts/PromptsRegistry.ts"],"names":[],"mappings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,CAAC,oBAAS,CAAC,cAAc,EAAE,qBAAqB,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,8BAA8B;QAC9B,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACnC,IACE,GAAG,CAAC,QAAQ;oBACZ,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,EACpD,CAAC;oBACD,MAAM,IAAI,mBAAQ,CAChB,oBAAS,CAAC,cAAc,EACxB,8BAA8B,GAAG,CAAC,IAAI,kBAAkB,GAAG,CAAC,WAAW,IAAI,yBAAyB,EAAE,CACvG,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,4CAA4C;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAEhE,8CAA8C;QAC9C,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACzC,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,GAAG,CAAC,OAAO;SACrB,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ,EAAE,WAAW;SACtB,CAAC;IACJ,CAAC;CACF;AAjGD,0CAiGC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PromptArgument } from "./PromptArgument";
|
|
2
|
-
/**
|
|
3
|
-
* Represents a prompt template for the Task Trellis MCP system.
|
|
4
|
-
* Prompts define reusable templates with placeholders that can be filled
|
|
5
|
-
* with specific arguments to generate contextualized user messages.
|
|
6
|
-
*/
|
|
7
|
-
export interface TrellisPrompt {
|
|
8
|
-
/** Kebab-case identifier for the prompt (e.g., "create-project") */
|
|
9
|
-
name: string;
|
|
10
|
-
/** Optional human-readable title for internal use */
|
|
11
|
-
title?: string;
|
|
12
|
-
/** Single-sentence summary displayed in slash command help */
|
|
13
|
-
description: string;
|
|
14
|
-
/** List of arguments that can be provided to fill the template */
|
|
15
|
-
arguments: PromptArgument[];
|
|
16
|
-
/** Markdown body template with placeholders for arguments */
|
|
17
|
-
userTemplate: string;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=TrellisPrompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TrellisPrompt.d.ts","sourceRoot":"","sources":["../../src/prompts/TrellisPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IAEb,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IAEpB,kEAAkE;IAClE,SAAS,EAAE,cAAc,EAAE,CAAC;IAE5B,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TrellisPrompt.js","sourceRoot":"","sources":["../../src/prompts/TrellisPrompt.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PromptArgument.test.d.ts","sourceRoot":"","sources":["../../../src/prompts/__tests__/PromptArgument.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
describe("PromptArgument", () => {
|
|
4
|
-
describe("interface structure", () => {
|
|
5
|
-
it("should accept valid argument with all required fields", () => {
|
|
6
|
-
const arg = {
|
|
7
|
-
name: "testArg",
|
|
8
|
-
required: true,
|
|
9
|
-
description: "A test argument",
|
|
10
|
-
};
|
|
11
|
-
expect(arg.name).toBe("testArg");
|
|
12
|
-
expect(arg.required).toBe(true);
|
|
13
|
-
expect(arg.description).toBeDefined();
|
|
14
|
-
expect(arg.type).toBeUndefined();
|
|
15
|
-
});
|
|
16
|
-
it("should accept argument with optional type field", () => {
|
|
17
|
-
const stringArg = {
|
|
18
|
-
name: "textInput",
|
|
19
|
-
type: "string",
|
|
20
|
-
required: true,
|
|
21
|
-
description: "A text input field",
|
|
22
|
-
};
|
|
23
|
-
const booleanArg = {
|
|
24
|
-
name: "enableFeature",
|
|
25
|
-
type: "boolean",
|
|
26
|
-
required: false,
|
|
27
|
-
description: "Toggle feature on/off",
|
|
28
|
-
};
|
|
29
|
-
expect(stringArg.type).toBe("string");
|
|
30
|
-
expect(booleanArg.type).toBe("boolean");
|
|
31
|
-
});
|
|
32
|
-
it("should handle optional arguments", () => {
|
|
33
|
-
const optionalArg = {
|
|
34
|
-
name: "optionalField",
|
|
35
|
-
required: false,
|
|
36
|
-
description: "An optional field",
|
|
37
|
-
};
|
|
38
|
-
expect(optionalArg.required).toBe(false);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe("type system validation", () => {
|
|
42
|
-
it("should only accept 'string' or 'boolean' as type values", () => {
|
|
43
|
-
const validTypes = [
|
|
44
|
-
"string",
|
|
45
|
-
"boolean",
|
|
46
|
-
undefined,
|
|
47
|
-
];
|
|
48
|
-
validTypes.forEach((type) => {
|
|
49
|
-
const arg = {
|
|
50
|
-
name: "testArg",
|
|
51
|
-
type,
|
|
52
|
-
required: true,
|
|
53
|
-
description: "Test",
|
|
54
|
-
};
|
|
55
|
-
expect([undefined, "string", "boolean"]).toContain(arg.type);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=PromptArgument.test.js.map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