Skip to content

Commit 77e5a1a

Browse files
committed
fix: prompts
1 parent 2977b3e commit 77e5a1a

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/interchainjs/prompts/migrate-to-interchainjs.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ Migrate the provided CosmJS TypeScript code snippet (available in the IDE contex
2222

2323
⚠️ IMPORTANT: This step MUST be completed before proceeding with the migration.
2424

25-
1. Analyze the code for required InterchainJS packages
25+
1. Carefully analyze the code to identify ONLY the InterchainJS packages that are directly needed for the migration
2626
2. Note the specified package manager for this project: `{{PACKAGE_MANAGER}}`.
27-
3. **CRITICAL:** You **MUST** use the specified package manager (`{{PACKAGE_MANAGER}}`) to generate the installation commands. The command format MUST be exactly: `{{PACKAGE_MANAGER}} install/add <package_name>`. ❗ **DO NOT DEVIATE FROM THIS.**
28-
4. Run the installation command(s).
29-
30-
Only after completing the package installation, proceed with the code migration.
27+
3. **CRITICAL:**
28+
- You **MUST** use the specified package manager (`{{PACKAGE_MANAGER}}`) to generate the installation commands
29+
- The command format MUST be exactly: `{{PACKAGE_MANAGER}} install/add <package_name>`
30+
- Install ONLY the packages that are actually used in the code being migrated
31+
- DO NOT install packages that aren't directly referenced in the code
32+
-**DO NOT DEVIATE FROM THIS.**
33+
4. Run the installation command(s) for only the necessary packages.
34+
35+
Only after completing the targeted package installation, proceed with the code migration.
3136

3237
### Step 2: Code Migration
3338

src/interchainjs/tools/migrate-to-interchainjs.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ ${interchainjsCode.trim()}
9999
function buildMigrationPrompt(
100100
packageManager: "npm" | "yarn" | "pnpm",
101101
): string | null {
102-
// Keep userCode parameter for potential future validation or use, even if not injected
103102
const promptTemplate = readFileContent(PROMPT_TEMPLATE_PATH);
104103
const apiMappings = readFileContent(API_MAPPINGS_PATH);
105104

@@ -121,7 +120,7 @@ function buildMigrationPrompt(
121120
console.error(
122121
`Failed to load one or both example files for '${example.title}'. CosmJS: ${example.cosmjsPath}, InterchainJS: ${example.interchainjsPath}`,
123122
);
124-
return null; // Indicate failure if any example file is missing
123+
return null;
125124
}
126125

127126
examplesMarkdown += formatExampleMarkdown(
@@ -131,7 +130,6 @@ function buildMigrationPrompt(
131130
);
132131
}
133132

134-
// Replace placeholders - first mappings, then examples, then package manager
135133
let prompt = promptTemplate.replace("{{API_MAPPINGS}}", apiMappings.trim());
136134
prompt = prompt.replace("{{MIGRATION_EXAMPLES}}", examplesMarkdown.trim());
137135
prompt = prompt.replace(/\{\{PACKAGE_MANAGER\}\}/g, packageManager);
@@ -141,15 +139,10 @@ function buildMigrationPrompt(
141139

142140
// --- MCP Tool Registration ---
143141

144-
/**
145-
* Registers the MCP tool that generates a detailed prompt for an LLM
146-
* to migrate CosmJS code to InterchainJS, using inline simple mappings
147-
* and complex examples loaded from external files.
148-
*/
149142
export function registerMigrateToInterchainjsTool(server: McpServer): void {
150143
server.tool(
151144
"migrateToInterchainjs",
152-
"Generates a prompt for an LLM to migrate CosmJS code to InterchainJS.",
145+
"Migrate CosmJS code to InterchainJS. REQUIRES the project's package manager (npm, yarn, or pnpm) to be correctly specified for proper dependency installation commands.",
153146
{
154147
packageManager: z
155148
.enum(["npm", "yarn", "pnpm"])

0 commit comments

Comments
 (0)