@puzzmo/cli 1.0.71 → 1.0.72
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/lib/agents/claude.d.ts +2 -2
- package/lib/agents/claude.js +67 -16
- package/lib/agents/claude.js.map +1 -1
- package/lib/agents/codex.js +12 -1
- package/lib/agents/codex.js.map +1 -1
- package/lib/agents/copilot.js +10 -1
- package/lib/agents/copilot.js.map +1 -1
- package/lib/agents/gemini.js +9 -1
- package/lib/agents/gemini.js.map +1 -1
- package/lib/agents/index.d.ts +1 -1
- package/lib/agents/stream-json-cli.d.ts +5 -4
- package/lib/agents/stream-json-cli.js +29 -4
- package/lib/agents/stream-json-cli.js.map +1 -1
- package/lib/agents/types.d.ts +15 -0
- package/lib/commands/game/create.js +46 -18
- package/lib/commands/game/create.js.map +1 -1
- package/lib/commands/game/seedImport.d.ts +13 -0
- package/lib/commands/game/seedImport.js +25 -0
- package/lib/commands/game/seedImport.js.map +1 -0
- package/lib/download/page-downloader.js +20 -7
- package/lib/download/page-downloader.js.map +1 -1
- package/lib/skills/context.d.ts +6 -0
- package/lib/skills/context.js +74 -0
- package/lib/skills/context.js.map +1 -0
- package/lib/skills/mcp-client.d.ts +5 -0
- package/lib/skills/mcp-client.js +21 -0
- package/lib/skills/mcp-client.js.map +1 -1
- package/lib/skills/registry.d.ts +24 -3
- package/lib/skills/registry.js +47 -11
- package/lib/skills/registry.js.map +1 -1
- package/lib/skills/runner.d.ts +3 -6
- package/lib/skills/runner.js +45 -94
- package/lib/skills/runner.js.map +1 -1
- package/lib/skills/step.d.ts +25 -0
- package/lib/skills/step.js +29 -0
- package/lib/skills/step.js.map +1 -0
- package/lib/tui/pipeline.d.ts +3 -1
- package/lib/tui/pipeline.js +138 -65
- package/lib/tui/pipeline.js.map +1 -1
- package/lib/util/duration.d.ts +7 -0
- package/lib/util/duration.js +25 -0
- package/lib/util/duration.js.map +1 -0
- package/lib/util/exec.d.ts +15 -3
- package/lib/util/exec.js +37 -7
- package/lib/util/exec.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/__fixtures__/README.md +1 -0
- package/src/agents/__fixtures__/claude-bash.jsonl +114 -0
- package/src/agents/claude.ts +64 -16
- package/src/agents/codex.ts +12 -1
- package/src/agents/copilot.ts +10 -1
- package/src/agents/gemini.ts +9 -1
- package/src/agents/index.ts +1 -1
- package/src/agents/parse-line.test.ts +40 -6
- package/src/agents/stream-json-cli.ts +32 -8
- package/src/agents/types.ts +16 -0
- package/src/commands/game/create.ts +47 -18
- package/src/commands/game/seedImport.ts +30 -0
- package/src/download/page-downloader.ts +22 -7
- package/src/skills/context.ts +75 -0
- package/src/skills/mcp-client.ts +24 -0
- package/src/skills/registry.ts +66 -11
- package/src/skills/runner.ts +52 -103
- package/src/skills/step.ts +47 -0
- package/src/tui/pipeline.ts +141 -61
- package/src/util/duration.test.ts +37 -0
- package/src/util/duration.ts +25 -0
- package/src/util/exec.ts +40 -7
- package/templates/minesweeper/README.md +3 -1
- package/templates/minesweeper/package.json +3 -1
|
@@ -7,9 +7,12 @@ import * as p from "@clack/prompts"
|
|
|
7
7
|
import { agentNames } from "../../agents/index.js"
|
|
8
8
|
import { detectAgent } from "../../wizard/agent-detect.js"
|
|
9
9
|
import { downloadPage } from "../../download/page-downloader.js"
|
|
10
|
-
import { runCommand, gitCommit, isGitInstalled } from "../../util/exec.js"
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { runCommand, gitCommit, isGitInstalled, resolveBuildCommand, type PackageManagerName } from "../../util/exec.js"
|
|
11
|
+
import { runAgentWithBuildLoop, runSelectedSkills } from "../../skills/runner.js"
|
|
12
|
+
import { runPipelineTUI } from "../../tui/pipeline.js"
|
|
13
|
+
import { newSession, type PipelineContext } from "../../skills/step.js"
|
|
14
|
+
import { importPipeline, optionalPromptSkills, type SkillDefinition } from "../../skills/registry.js"
|
|
15
|
+
import { seedImportedGame, importedSourceDir, referenceDir } from "./seedImport.js"
|
|
13
16
|
import { login } from "../login.js"
|
|
14
17
|
import { getDefaultToken } from "../../util/config.js"
|
|
15
18
|
import { slugify } from "../../util/slugify.js"
|
|
@@ -237,10 +240,11 @@ const buildRepoContext = (repo: RepoContext, repoType: RepoType): string => {
|
|
|
237
240
|
type PromptStrategyArgs = {
|
|
238
241
|
userPrompt: string
|
|
239
242
|
displayName: string
|
|
243
|
+
buildCmd: string
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
/** Composes the prompt sent to the agent for the "from prompt" strategy */
|
|
243
|
-
const buildPromptStrategyMessage = ({ userPrompt, displayName }: PromptStrategyArgs): string =>
|
|
247
|
+
const buildPromptStrategyMessage = ({ userPrompt, displayName, buildCmd }: PromptStrategyArgs): string =>
|
|
244
248
|
`You are scaffolding a Puzzmo game called "${displayName}" in the current directory.
|
|
245
249
|
The starter is a working Vite + Puzzmo SDK Minesweeper. Replace the gameplay with the game described below.
|
|
246
250
|
|
|
@@ -251,7 +255,7 @@ Constraints:
|
|
|
251
255
|
- Keep puzzmo.json valid (do not remove the slug or displayName fields).
|
|
252
256
|
- Use the Puzzmo SDK lifecycle: gameReady → gameLoaded → on("start"|"retry") → updateGameState → gameCompleted.
|
|
253
257
|
- Replace fixtures in fixtures/puzzles/ with puzzles for the new game.
|
|
254
|
-
- Keep the build green (\`
|
|
258
|
+
- Keep the build green (\`${buildCmd}\` should succeed).`
|
|
255
259
|
|
|
256
260
|
/** Main game create wizard */
|
|
257
261
|
export const gameCreate = async (opts: CreateOptions) => {
|
|
@@ -348,15 +352,23 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
348
352
|
|
|
349
353
|
const slug = opts.slug ?? slugify(name)
|
|
350
354
|
|
|
351
|
-
// Materialize
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
// Materialize the starter (after we know the slug/name). Imports get it too — porting a
|
|
356
|
+
// downloaded game into a project that already builds beats rebuilding the project by hand.
|
|
357
|
+
const templateDir = resolveTemplateDir("minesweeper")
|
|
358
|
+
if (!fs.existsSync(templateDir)) {
|
|
359
|
+
p.log.error(`Bundled template not found at ${templateDir}`)
|
|
360
|
+
process.exit(1)
|
|
361
|
+
}
|
|
362
|
+
const replacements = {
|
|
363
|
+
__SLUG__: slug,
|
|
364
|
+
__DISPLAY_NAME__: name,
|
|
365
|
+
__TEAM_ID__: opts.teamID ?? "REPLACE_ME",
|
|
366
|
+
// Prettier rewrites __DISPLAY_NAME__ to bold syntax in markdown, so match that form too.
|
|
367
|
+
"**DISPLAY_NAME**": name,
|
|
359
368
|
}
|
|
369
|
+
const materialize = (from: string, to: string) => copyTemplate(from, to, replacements)
|
|
370
|
+
if (strategy === "import") seedImportedGame(tmpDir, templateDir, materialize)
|
|
371
|
+
else materialize(templateDir, tmpDir)
|
|
360
372
|
|
|
361
373
|
// Step 5: Login if token provided
|
|
362
374
|
if (opts.accessToken) {
|
|
@@ -410,24 +422,38 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
410
422
|
}
|
|
411
423
|
|
|
412
424
|
// Step 7: Strategy-specific agent work
|
|
425
|
+
const pm = packageManagerFrom(opts.pm, repo.packageManager)
|
|
426
|
+
const buildCmd = resolveBuildCommand(gameDir, pm)
|
|
427
|
+
// One context per run: the agent keeps the same conversation across every step.
|
|
428
|
+
const contextFor = (agent: string): PipelineContext => ({
|
|
429
|
+
agent,
|
|
430
|
+
gameDir,
|
|
431
|
+
repoContext: buildRepoContext(repo, repoType),
|
|
432
|
+
buildCmd,
|
|
433
|
+
session: newSession(),
|
|
434
|
+
})
|
|
435
|
+
|
|
413
436
|
if (strategy === "import") {
|
|
414
437
|
const selectedAgent = await pickAgent(opts.agent)
|
|
415
438
|
if (selectedAgent !== "none") {
|
|
416
439
|
p.log.step("Running Puzzmo migration pipeline...")
|
|
417
|
-
await
|
|
440
|
+
await runPipelineTUI(contextFor(selectedAgent), importPipeline)
|
|
441
|
+
} else {
|
|
442
|
+
p.log.info(`The downloaded game is in ${importedSourceDir}/, and a reference game is in ${referenceDir}/.`)
|
|
418
443
|
}
|
|
419
444
|
} else if (strategy === "prompt") {
|
|
420
445
|
const selectedAgent = await pickAgent(opts.agent)
|
|
421
|
-
const message = buildPromptStrategyMessage({ userPrompt: userPrompt!, displayName: name })
|
|
446
|
+
const message = buildPromptStrategyMessage({ userPrompt: userPrompt!, displayName: name, buildCmd })
|
|
422
447
|
if (selectedAgent === "none") {
|
|
423
448
|
p.log.warn("No agent selected; skipping LLM customization.")
|
|
424
449
|
p.note(message, "Paste this prompt into your LLM agent:")
|
|
425
450
|
} else {
|
|
426
451
|
// Ask which optional extras to apply up front, then run everything unattended
|
|
427
452
|
const extras = await pickOptionalSkills()
|
|
453
|
+
const ctx = contextFor(selectedAgent)
|
|
428
454
|
|
|
429
455
|
p.log.step("Running agent with your prompt...")
|
|
430
|
-
const result = await runAgentWithBuildLoop(
|
|
456
|
+
const result = await runAgentWithBuildLoop(ctx, message, "from-prompt")
|
|
431
457
|
if (!result.ok) {
|
|
432
458
|
p.log.warn(`Agent step did not complete cleanly: ${result.reason}. The Minesweeper starter is still in place.`)
|
|
433
459
|
if (result.buildError) p.note(result.buildError.trimEnd().split("\n").slice(-40).join("\n"), "Last build error")
|
|
@@ -436,7 +462,7 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
436
462
|
|
|
437
463
|
if (extras.length > 0) {
|
|
438
464
|
p.log.step(`Applying optional skills: ${extras.map((s) => s.name).join(", ")}`)
|
|
439
|
-
await runSelectedSkills(
|
|
465
|
+
await runSelectedSkills(ctx, extras)
|
|
440
466
|
}
|
|
441
467
|
}
|
|
442
468
|
}
|
|
@@ -446,7 +472,6 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
446
472
|
writeSchemaHint(gameDir, effectiveRepoRoot)
|
|
447
473
|
|
|
448
474
|
// Done
|
|
449
|
-
const pm = opts.pm || repo.packageManager
|
|
450
475
|
const runCmd = pm === "npm" ? "npx" : pm === "yarn" ? "yarn dlx" : "pnpm dlx"
|
|
451
476
|
const relativePath = path.relative(process.cwd(), gameDir)
|
|
452
477
|
|
|
@@ -457,3 +482,7 @@ export const gameCreate = async (opts: CreateOptions) => {
|
|
|
457
482
|
|
|
458
483
|
p.outro(`Done! Your game is in ./${relativePath}/`)
|
|
459
484
|
}
|
|
485
|
+
|
|
486
|
+
/** `--pm` arrives as a plain string; anything unexpected falls back to the repo's own manager */
|
|
487
|
+
const packageManagerFrom = (value: string | undefined, fallback: PackageManagerName): PackageManagerName =>
|
|
488
|
+
value === "npm" || value === "yarn" || value === "pnpm" ? value : fallback
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
|
|
4
|
+
/** Where the downloaded page is parked while the agent ports it */
|
|
5
|
+
export const importedSourceDir = "original"
|
|
6
|
+
|
|
7
|
+
/** Where an untouched copy of the starter lives, for the agent to read but not edit */
|
|
8
|
+
export const referenceDir = path.join(".puzzmo", "reference")
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Turns a freshly downloaded page into a working Puzzmo project.
|
|
12
|
+
*
|
|
13
|
+
* The download moves to `original/`, the starter is unpacked over the top as the shell to port
|
|
14
|
+
* into, and a pristine copy is left in `.puzzmo/reference/`. This means the migration begins
|
|
15
|
+
* from a project that already builds and is already wired to the SDK, instead of asking an
|
|
16
|
+
* agent to reconstruct the whole layout a step at a time.
|
|
17
|
+
*/
|
|
18
|
+
export const seedImportedGame = (
|
|
19
|
+
gameDir: string,
|
|
20
|
+
templateDir: string,
|
|
21
|
+
copyTemplate: (sourceDir: string, targetDir: string) => void,
|
|
22
|
+
): void => {
|
|
23
|
+
const downloaded = path.join(gameDir, "src")
|
|
24
|
+
const target = path.join(gameDir, importedSourceDir)
|
|
25
|
+
if (fs.existsSync(target)) fs.rmSync(target, { recursive: true })
|
|
26
|
+
if (fs.existsSync(downloaded)) fs.renameSync(downloaded, target)
|
|
27
|
+
|
|
28
|
+
copyTemplate(templateDir, gameDir)
|
|
29
|
+
copyTemplate(templateDir, path.join(gameDir, referenceDir))
|
|
30
|
+
}
|
|
@@ -126,10 +126,10 @@ export const downloadPage = async (url: string, outputDir: string): Promise<{ ti
|
|
|
126
126
|
// Find referenced assets (src, href, url())
|
|
127
127
|
const assetRefs = extractAssetRefs(html)
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
}
|
|
129
|
+
const fetched = await mapWithConcurrency(assetRefs, (ref) => downloadAsset(ref, baseURL, srcDir, downloaded, assetContent, false))
|
|
130
|
+
assetRefs.forEach((ref, i) => {
|
|
131
|
+
if (fetched[i]) html = html.replaceAll(ref, new URL(ref, baseURL).pathname.replace(/^\//, ""))
|
|
132
|
+
})
|
|
133
133
|
|
|
134
134
|
// Second pass: scan downloaded JS/CSS files for string literals referencing
|
|
135
135
|
// paths with known asset extensions (images, fonts, audio, video).
|
|
@@ -143,9 +143,7 @@ export const downloadPage = async (url: string, outputDir: string): Promise<{ ti
|
|
|
143
143
|
|
|
144
144
|
if (jsAssetRefs.size > 0) {
|
|
145
145
|
console.log(` Found ${jsAssetRefs.size} additional asset reference${jsAssetRefs.size === 1 ? "" : "s"} in JS/CSS files`)
|
|
146
|
-
|
|
147
|
-
await downloadAsset(ref, baseURL, srcDir, downloaded, assetContent, true)
|
|
148
|
-
}
|
|
146
|
+
await mapWithConcurrency([...jsAssetRefs], (ref) => downloadAsset(ref, baseURL, srcDir, downloaded, assetContent, true))
|
|
149
147
|
}
|
|
150
148
|
|
|
151
149
|
// Write the HTML file
|
|
@@ -156,6 +154,23 @@ export const downloadPage = async (url: string, outputDir: string): Promise<{ ti
|
|
|
156
154
|
return { title: extractTitle(html) }
|
|
157
155
|
}
|
|
158
156
|
|
|
157
|
+
/** How many assets to fetch at once — a page's assets are otherwise one round trip each */
|
|
158
|
+
const downloadConcurrency = 8
|
|
159
|
+
|
|
160
|
+
/** Runs `task` over every item with a bounded number in flight, preserving input order in the results */
|
|
161
|
+
const mapWithConcurrency = async <T, R>(items: T[], task: (item: T) => Promise<R>): Promise<R[]> => {
|
|
162
|
+
const results = new Array<R>(items.length)
|
|
163
|
+
let next = 0
|
|
164
|
+
const worker = async () => {
|
|
165
|
+
while (next < items.length) {
|
|
166
|
+
const index = next++
|
|
167
|
+
results[index] = await task(items[index])
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
await Promise.all(Array.from({ length: Math.min(downloadConcurrency, items.length) }, worker))
|
|
171
|
+
return results
|
|
172
|
+
}
|
|
173
|
+
|
|
159
174
|
/** Extracts asset references from HTML using regex */
|
|
160
175
|
const extractAssetRefs = (html: string): string[] => {
|
|
161
176
|
const refs: string[] = []
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
|
|
4
|
+
const ignoredDirs = new Set(["node_modules", "dist", ".git", ".puzzmo", ".yarn", ".DS_Store"])
|
|
5
|
+
const maxDepth = 3
|
|
6
|
+
const maxEntriesPerDir = 12
|
|
7
|
+
const maxLines = 90
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A short description of what's already on disk, handed to the agent with every step.
|
|
11
|
+
* Without it each step opens by globbing and reading its way back to the same picture,
|
|
12
|
+
* which is several tool round trips before any work starts.
|
|
13
|
+
*/
|
|
14
|
+
export const describeProject = (gameDir: string): string => {
|
|
15
|
+
const sections = [`Project layout (${path.basename(gameDir)}/):`, ...treeLines(gameDir, "", 0, { count: 0 })]
|
|
16
|
+
|
|
17
|
+
const puzzmoJSON = readIfPresent(path.join(gameDir, "puzzmo.json"))
|
|
18
|
+
if (puzzmoJSON) sections.push("", "puzzmo.json:", puzzmoJSON.trim())
|
|
19
|
+
|
|
20
|
+
const scripts = readScripts(path.join(gameDir, "package.json"))
|
|
21
|
+
if (scripts) sections.push("", `package.json scripts: ${scripts}`)
|
|
22
|
+
|
|
23
|
+
return sections.join("\n")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Renders an indented tree, skipping build output and collapsing large directories */
|
|
27
|
+
const treeLines = (dir: string, prefix: string, depth: number, budget: { count: number }): string[] => {
|
|
28
|
+
if (depth > maxDepth || budget.count >= maxLines) return []
|
|
29
|
+
|
|
30
|
+
let entries: fs.Dirent[]
|
|
31
|
+
try {
|
|
32
|
+
entries = fs.readdirSync(dir, { withFileTypes: true })
|
|
33
|
+
} catch {
|
|
34
|
+
return []
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const visible = entries.filter((e) => !ignoredDirs.has(e.name)).sort((a, b) => a.name.localeCompare(b.name))
|
|
38
|
+
const shown = visible.slice(0, maxEntriesPerDir)
|
|
39
|
+
const lines: string[] = []
|
|
40
|
+
|
|
41
|
+
for (const entry of shown) {
|
|
42
|
+
if (budget.count >= maxLines) break
|
|
43
|
+
budget.count++
|
|
44
|
+
if (entry.isDirectory()) {
|
|
45
|
+
lines.push(`${prefix} ${entry.name}/`)
|
|
46
|
+
lines.push(...treeLines(path.join(dir, entry.name), `${prefix} `, depth + 1, budget))
|
|
47
|
+
} else {
|
|
48
|
+
lines.push(`${prefix} ${entry.name}`)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (visible.length > shown.length) lines.push(`${prefix} ... ${visible.length - shown.length} more`)
|
|
53
|
+
return lines
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Reads a file, returning undefined when it's missing or unreadable */
|
|
57
|
+
const readIfPresent = (file: string): string | undefined => {
|
|
58
|
+
try {
|
|
59
|
+
return fs.readFileSync(file, "utf-8")
|
|
60
|
+
} catch {
|
|
61
|
+
return undefined
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Comma-separated script names from a package.json, or undefined when there isn't one */
|
|
66
|
+
const readScripts = (pkgPath: string): string | undefined => {
|
|
67
|
+
const raw = readIfPresent(pkgPath)
|
|
68
|
+
if (!raw) return undefined
|
|
69
|
+
try {
|
|
70
|
+
const names = Object.keys(JSON.parse(raw).scripts ?? {})
|
|
71
|
+
return names.length > 0 ? names.join(", ") : undefined
|
|
72
|
+
} catch {
|
|
73
|
+
return undefined
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/skills/mcp-client.ts
CHANGED
|
@@ -77,6 +77,17 @@ export const listMcpPrompts = async (gameDir: string): Promise<{ name: string; d
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/** Skill docs are immutable for the length of a run, so a retry never refetches one */
|
|
81
|
+
const promptCache = new Map<string, Promise<string>>()
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Warms the cache for every skill a pipeline will need, in parallel, so steps don't
|
|
85
|
+
* each pay a round trip mid-run. Failures are left for the step itself to report.
|
|
86
|
+
*/
|
|
87
|
+
export const prefetchSkillPrompts = async (stepNames: string[], gameDir: string): Promise<void> => {
|
|
88
|
+
await Promise.all([...new Set(stepNames)].map((name) => fetchSkillPrompt(name, gameDir).catch(() => undefined)))
|
|
89
|
+
}
|
|
90
|
+
|
|
80
91
|
/** Fetches a step's instructions from the MCP server configured in .mcp.json */
|
|
81
92
|
export const fetchSkillPrompt = async (stepName: string, gameDir: string): Promise<string> => {
|
|
82
93
|
const config = readMcpConfig(gameDir)
|
|
@@ -85,6 +96,19 @@ export const fetchSkillPrompt = async (stepName: string, gameDir: string): Promi
|
|
|
85
96
|
const server = Object.values(config.mcpServers)[0]
|
|
86
97
|
if (!server) throw new Error("No MCP server configured in .mcp.json")
|
|
87
98
|
|
|
99
|
+
const cacheKey = `${server.url}|${stepName}`
|
|
100
|
+
const cached = promptCache.get(cacheKey)
|
|
101
|
+
if (cached) return cached
|
|
102
|
+
|
|
103
|
+
const pending = requestSkillPrompt(server, stepName)
|
|
104
|
+
promptCache.set(cacheKey, pending)
|
|
105
|
+
// A failed fetch shouldn't be remembered — the next attempt should try the network again.
|
|
106
|
+
pending.catch(() => promptCache.delete(cacheKey))
|
|
107
|
+
return pending
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Performs the uncached prompts/get round trip and flattens the response to text */
|
|
111
|
+
const requestSkillPrompt = async (server: { url: string; headers?: Record<string, string> }, stepName: string): Promise<string> => {
|
|
88
112
|
const result = await mcpRequest(server.url, server.headers ?? {}, "prompts/get", { name: stepName })
|
|
89
113
|
if (!result?.messages?.length) throw new Error(`MCP server returned no instructions for "${stepName}"`)
|
|
90
114
|
|
package/src/skills/registry.ts
CHANGED
|
@@ -4,20 +4,75 @@ export type SkillDefinition = {
|
|
|
4
4
|
label?: string
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
/**
|
|
8
|
+
* One step of the migration. A step is a single agent invocation: its prompt is the local
|
|
9
|
+
* `preamble` followed by the skill docs fetched from the MCP server, so several related
|
|
10
|
+
* skills can be handled in one pass instead of one cold agent run each.
|
|
11
|
+
*/
|
|
12
|
+
export type PipelineStep = {
|
|
13
|
+
/** Short id — used for the sidebar label, the commit message and the log file name */
|
|
14
|
+
name: string
|
|
15
|
+
/** Skill docs to fetch from the MCP server and append to the prompt, in order */
|
|
16
|
+
skills: string[]
|
|
17
|
+
/** Local instructions leading the fetched docs */
|
|
18
|
+
preamble: string
|
|
19
|
+
/** Set for steps that can't affect the build, so the build check is skipped */
|
|
20
|
+
skipBuild?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const portSourcePreamble = `Port the imported game into this Puzzmo project.
|
|
24
|
+
|
|
25
|
+
\`original/\` holds the game exactly as it was downloaded from the web — its HTML entry point
|
|
26
|
+
plus the scripts, styles and assets it referenced. Everything else in this directory is the
|
|
27
|
+
Minesweeper starter: a complete, working Puzzmo game that already builds.
|
|
28
|
+
|
|
29
|
+
Replace the starter's gameplay with the game from \`original/\`:
|
|
30
|
+
- Move the game's logic into \`src/main.ts\`, adding modules under \`src/\` where that keeps things
|
|
31
|
+
readable. Keep the SDK lifecycle calls that are already there (gameReady, gameLoaded,
|
|
32
|
+
on("start"), on("retry"), updateGameState, gameCompleted) and point them at the ported game.
|
|
33
|
+
- Update \`index.html\` and \`src/style.css\` to match what the ported game renders.
|
|
34
|
+
- Replace the puzzles in \`fixtures/puzzles/\` with puzzles for this game, in whatever format the
|
|
35
|
+
ported code parses out of \`puzzleString\`. Two or three with different characteristics.
|
|
36
|
+
- Delete \`original/\` once its contents have been ported or deliberately dropped.
|
|
37
|
+
|
|
38
|
+
A pristine copy of the starter stays in \`.puzzmo/reference/\` — read it whenever you need to see
|
|
39
|
+
how a finished Puzzmo game is wired. Leave the \`game\` block in puzzmo.json alone, and keep the
|
|
40
|
+
build green.`
|
|
41
|
+
|
|
42
|
+
const lifecyclePreamble = `Audit and complete this game's Puzzmo integration.
|
|
43
|
+
|
|
44
|
+
The SDK is already installed and the starter already wired up the lifecycle, so most of what
|
|
45
|
+
follows may be done — check each point against the ported game and fill in what is missing or
|
|
46
|
+
still describes Minesweeper rather than re-scaffolding it. Deeds and the leaderboards built on
|
|
47
|
+
them are the part most likely to be absent.
|
|
48
|
+
|
|
49
|
+
Do all of it in this one pass, in the order the instructions appear.`
|
|
50
|
+
|
|
51
|
+
const thumbnailPreamble = `Give this game a real thumbnail.
|
|
52
|
+
|
|
53
|
+
\`vite.config.ts\` already registers \`appBundlePlugin()\` and \`src/appBundle.tsx\` already exists
|
|
54
|
+
from the starter, so skip the plugin wiring below — the work is rewriting \`renderThumbnail\` so
|
|
55
|
+
it renders this game rather than a Minesweeper board.`
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Steps for a game imported from a URL. The project is scaffolded from the bundled starter
|
|
59
|
+
* before any of this runs, so these steps only cover work that genuinely needs judgement.
|
|
60
|
+
*/
|
|
61
|
+
export const importPipeline: PipelineStep[] = [
|
|
62
|
+
{ name: "port-source", skills: [], preamble: portSourcePreamble },
|
|
63
|
+
{
|
|
64
|
+
name: "puzzmo-lifecycle",
|
|
65
|
+
skills: ["introduce-puzzmo-sdk", "game-completion", "add-deeds", "setup-augmentations"],
|
|
66
|
+
preamble: lifecyclePreamble,
|
|
67
|
+
},
|
|
68
|
+
{ name: "thumbnail", skills: ["create-app-bundle"], preamble: thumbnailPreamble },
|
|
16
69
|
]
|
|
17
70
|
|
|
18
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Recommended optional skills offered as pre-checked tick boxes after the "from a prompt" flow.
|
|
73
|
+
* Deploy setup isn't here because the starter ships it: deploy scripts, .gitignore and README.
|
|
74
|
+
*/
|
|
19
75
|
export const optionalPromptSkills: SkillDefinition[] = [
|
|
20
76
|
{ name: "add-deeds", label: "Add deeds (in-game achievements)" },
|
|
21
77
|
{ name: "setup-augmentations", label: "Set up augmentations" },
|
|
22
|
-
{ name: "setup-deploy", label: "Set up deployment" },
|
|
23
78
|
]
|