Skip to content

Commit a375fd4

Browse files
Sync packages from monorepo (a534285)
1 parent 188db2b commit a375fd4

2 files changed

Lines changed: 14 additions & 38 deletions

File tree

packages/cli/src/skills/runner.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,14 @@ import { spawnSync } from "node:child_process"
22

33
import { skillsPipeline } from "./registry.js"
44
import { verifyBuild, runCommand, gitCommit } from "../util/exec.js"
5-
import { getMcpUrl } from "./mcp-client.js"
5+
import { fetchSkillPrompt } from "./mcp-client.js"
66
import { runPipelineTUI } from "../tui/pipeline.js"
77

8-
const buildPrompt = (skillName: string, mcpUrl: string | null): string => {
9-
if (!mcpUrl) return `Run the skill "${skillName}". The game source is in the current directory.`
10-
11-
return `First, fetch the skill instructions by using WebFetch to make a POST request to:
12-
${mcpUrl}
13-
14-
With headers:
15-
- Content-Type: application/json
16-
- Accept: application/json, text/event-stream
17-
18-
And body:
19-
{"jsonrpc":"2.0","id":1,"method":"prompts/get","params":{"name":"${skillName}"}}
20-
21-
The response will be in SSE format. Parse the "data:" line to get the JSON result, which contains the skill instructions in result.messages[0].content.text.
22-
23-
Then follow those instructions. The game source is in the current directory.`
8+
/** Fetches skill instructions from the MCP server, then builds a self-contained prompt for the agent */
9+
const buildPrompt = async (skillName: string, gameDir: string): Promise<string> => {
10+
const instructions = await fetchSkillPrompt(skillName, gameDir)
11+
if (instructions) return `${instructions}\n\nThe game source is in the current directory.`
12+
return `Run the skill "${skillName}". The game source is in the current directory.`
2413
}
2514

2615
/** Invokes an LLM agent with a prompt (plain mode, stdio inherited) */
@@ -51,8 +40,7 @@ export const runSkillsPipeline = async (agent: string, gameDir: string) => {
5140
const step = i + 1
5241
console.log(`[${step}/${total}] Running skill: ${skill.name}`)
5342

54-
const mcpUrl = getMcpUrl(gameDir)
55-
const prompt = buildPrompt(skill.name, mcpUrl)
43+
const prompt = await buildPrompt(skill.name, gameDir)
5644
let result = invokeAgent(agent, prompt, gameDir)
5745

5846
if (!result.success) {

packages/cli/src/tui/pipeline.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from "node:path"
55
import { execSync } from "node:child_process"
66

77
import { skillsPipeline } from "../skills/registry.js"
8-
import { getMcpUrl } from "../skills/mcp-client.js"
8+
import { fetchSkillPrompt } from "../skills/mcp-client.js"
99

1010
type StepState = "pending" | "running" | "success" | "failed" | "skipped"
1111
type Phase = "agent" | "build" | "commit" | "idle"
@@ -58,22 +58,11 @@ const buildAgentCmd = (agent: string, prompt: string): { cmd: string; args: stri
5858
return { cmd: agent, args: [prompt] }
5959
}
6060

61-
const buildPrompt = (skillName: string, mcpUrl: string | null): string => {
62-
if (!mcpUrl) return `Run the skill "${skillName}". The game source is in the current directory.`
63-
64-
return `First, fetch the skill instructions by using WebFetch to make a POST request to:
65-
${mcpUrl}
66-
67-
With headers:
68-
- Content-Type: application/json
69-
- Accept: application/json, text/event-stream
70-
71-
And body:
72-
{"jsonrpc":"2.0","id":1,"method":"prompts/get","params":{"name":"${skillName}"}}
73-
74-
The response will be in SSE format. Parse the "data:" line to get the JSON result, which contains the skill instructions in result.messages[0].content.text.
75-
76-
Then follow those instructions. The game source is in the current directory.`
61+
/** Fetches skill instructions from the MCP server, then builds a self-contained prompt for the agent */
62+
const buildPrompt = async (skillName: string, gameDir: string): Promise<string> => {
63+
const instructions = await fetchSkillPrompt(skillName, gameDir)
64+
if (instructions) return `${instructions}\n\nThe game source is in the current directory.`
65+
return `Run the skill "${skillName}". The game source is in the current directory.`
7766
}
7867

7968
class PipelineTUI {
@@ -410,8 +399,7 @@ class PipelineTUI {
410399
this.phase = "agent"
411400
this.render()
412401

413-
const mcpUrl = getMcpUrl(this.gameDir)
414-
const prompt = buildPrompt(skill.name, mcpUrl)
402+
const prompt = await buildPrompt(skill.name, this.gameDir)
415403
let success = await this.runAgent(prompt)
416404

417405
if (!success) {

0 commit comments

Comments
 (0)