@puzzmo/cli 1.0.71 → 1.0.73

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.
Files changed (83) hide show
  1. package/lib/agents/claude.d.ts +2 -2
  2. package/lib/agents/claude.js +67 -16
  3. package/lib/agents/claude.js.map +1 -1
  4. package/lib/agents/codex.js +12 -1
  5. package/lib/agents/codex.js.map +1 -1
  6. package/lib/agents/copilot.js +10 -1
  7. package/lib/agents/copilot.js.map +1 -1
  8. package/lib/agents/gemini.js +9 -1
  9. package/lib/agents/gemini.js.map +1 -1
  10. package/lib/agents/index.d.ts +1 -1
  11. package/lib/agents/stream-json-cli.d.ts +5 -4
  12. package/lib/agents/stream-json-cli.js +29 -4
  13. package/lib/agents/stream-json-cli.js.map +1 -1
  14. package/lib/agents/types.d.ts +15 -0
  15. package/lib/commands/game/create.js +46 -18
  16. package/lib/commands/game/create.js.map +1 -1
  17. package/lib/commands/game/seedImport.d.ts +13 -0
  18. package/lib/commands/game/seedImport.js +25 -0
  19. package/lib/commands/game/seedImport.js.map +1 -0
  20. package/lib/commands/upload.js +8 -19
  21. package/lib/commands/upload.js.map +1 -1
  22. package/lib/download/page-downloader.js +20 -7
  23. package/lib/download/page-downloader.js.map +1 -1
  24. package/lib/skills/context.d.ts +6 -0
  25. package/lib/skills/context.js +74 -0
  26. package/lib/skills/context.js.map +1 -0
  27. package/lib/skills/mcp-client.d.ts +5 -0
  28. package/lib/skills/mcp-client.js +21 -0
  29. package/lib/skills/mcp-client.js.map +1 -1
  30. package/lib/skills/registry.d.ts +24 -3
  31. package/lib/skills/registry.js +47 -11
  32. package/lib/skills/registry.js.map +1 -1
  33. package/lib/skills/runner.d.ts +3 -6
  34. package/lib/skills/runner.js +45 -94
  35. package/lib/skills/runner.js.map +1 -1
  36. package/lib/skills/step.d.ts +25 -0
  37. package/lib/skills/step.js +29 -0
  38. package/lib/skills/step.js.map +1 -0
  39. package/lib/tui/pipeline.d.ts +3 -1
  40. package/lib/tui/pipeline.js +195 -75
  41. package/lib/tui/pipeline.js.map +1 -1
  42. package/lib/util/collapseRepeats.d.ts +20 -0
  43. package/lib/util/collapseRepeats.js +80 -0
  44. package/lib/util/collapseRepeats.js.map +1 -0
  45. package/lib/util/duration.d.ts +7 -0
  46. package/lib/util/duration.js +25 -0
  47. package/lib/util/duration.js.map +1 -0
  48. package/lib/util/exec.d.ts +15 -3
  49. package/lib/util/exec.js +37 -7
  50. package/lib/util/exec.js.map +1 -1
  51. package/lib/util/mascot.d.ts +18 -0
  52. package/lib/util/mascot.js +42 -0
  53. package/lib/util/mascot.js.map +1 -0
  54. package/package.json +3 -2
  55. package/scripts/demo-tui.mjs +108 -0
  56. package/src/agents/__fixtures__/README.md +1 -0
  57. package/src/agents/__fixtures__/claude-bash.jsonl +114 -0
  58. package/src/agents/claude.ts +64 -16
  59. package/src/agents/codex.ts +12 -1
  60. package/src/agents/copilot.ts +10 -1
  61. package/src/agents/gemini.ts +9 -1
  62. package/src/agents/index.ts +1 -1
  63. package/src/agents/parse-line.test.ts +40 -6
  64. package/src/agents/stream-json-cli.ts +32 -8
  65. package/src/agents/types.ts +16 -0
  66. package/src/commands/game/create.ts +47 -18
  67. package/src/commands/game/seedImport.ts +30 -0
  68. package/src/commands/upload.ts +7 -21
  69. package/src/download/page-downloader.ts +22 -7
  70. package/src/skills/context.ts +75 -0
  71. package/src/skills/mcp-client.ts +24 -0
  72. package/src/skills/registry.ts +66 -11
  73. package/src/skills/runner.ts +52 -103
  74. package/src/skills/step.ts +47 -0
  75. package/src/tui/pipeline.ts +200 -72
  76. package/src/util/collapseRepeats.test.ts +78 -0
  77. package/src/util/collapseRepeats.ts +77 -0
  78. package/src/util/duration.test.ts +37 -0
  79. package/src/util/duration.ts +25 -0
  80. package/src/util/exec.ts +40 -7
  81. package/src/util/mascot.ts +55 -0
  82. package/templates/minesweeper/README.md +3 -1
  83. package/templates/minesweeper/package.json +3 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Coarser sibling of `formatDuration` for a counter that repaints while it runs, where
3
+ * sub-second precision only flickers: 0s / 12s / 6m02s.
4
+ */
5
+ export const formatElapsed = (ms: number): string => {
6
+ const secs = Math.floor(ms / 1000)
7
+ return secs < 60 ? `${secs}s` : formatDuration(secs * 1000)
8
+ }
9
+
10
+ /** Renders a span as 340ms / 12.4s / 6m02s — short enough to sit at the end of a log line */
11
+ export const formatDuration = (ms: number): string => {
12
+ if (ms < 1000) return `${Math.round(ms)}ms`
13
+
14
+ const totalSecs = ms / 1000
15
+ if (totalSecs < 60) return `${totalSecs.toFixed(1)}s`
16
+
17
+ let mins = Math.floor(totalSecs / 60)
18
+ let secs = Math.round(totalSecs % 60)
19
+ // Rounding can push seconds to a full minute (119.7s would read "1m60s")
20
+ if (secs === 60) {
21
+ mins += 1
22
+ secs = 0
23
+ }
24
+ return `${mins}m${String(secs).padStart(2, "0")}s`
25
+ }
package/src/util/exec.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { execSync } from "node:child_process"
1
+ import { execSync, spawn } from "node:child_process"
2
+ import fs from "node:fs"
3
+ import path from "node:path"
2
4
 
3
5
  type ExecOptions = { cwd?: string }
4
6
 
7
+ export type PackageManagerName = "npm" | "yarn" | "pnpm"
8
+
5
9
  /** Runs a shell command, printing output */
6
10
  export const runCommand = (cmd: string, opts: ExecOptions = {}) => {
7
11
  execSync(cmd, {
@@ -37,12 +41,41 @@ export const isGitInstalled = (): boolean => {
37
41
  }
38
42
  }
39
43
 
40
- /** Runs vite build and returns success/failure */
41
- export const verifyBuild = (cwd: string): { success: boolean; error?: string } => {
44
+ /** Runs a command without blocking the event loop, capturing stdout and stderr together */
45
+ export const runCapture = (cmd: string, opts: ExecOptions = {}): Promise<{ success: boolean; output: string }> =>
46
+ new Promise((resolve) => {
47
+ const child = spawn(cmd, { cwd: opts.cwd, shell: true })
48
+ let output = ""
49
+ child.stdout?.on("data", (chunk: Buffer) => (output += chunk.toString("utf-8")))
50
+ child.stderr?.on("data", (chunk: Buffer) => (output += chunk.toString("utf-8")))
51
+ child.on("error", (e) => resolve({ success: false, output: output + e.message }))
52
+ child.on("close", (code) => resolve({ success: code === 0, output }))
53
+ })
54
+
55
+ /** Runs the project's build and returns success/failure */
56
+ export const verifyBuild = async (cwd: string, buildCmd: string): Promise<{ success: boolean; error?: string }> => {
57
+ const { success, output } = await runCapture(buildCmd, { cwd })
58
+ return success ? { success: true } : { success: false, error: output }
59
+ }
60
+
61
+ /**
62
+ * The command that builds a game directory. Prefers the project's own `build` script so
63
+ * monorepo/PnP setups resolve the way they normally do, and only falls back to invoking
64
+ * vite directly for games that share a parent package.json.
65
+ */
66
+ export const resolveBuildCommand = (gameDir: string, pm: PackageManagerName): string => {
67
+ if (hasBuildScript(gameDir)) return pm === "yarn" ? "yarn build" : `${pm} run build`
68
+ if (pm === "yarn") return "yarn vite build"
69
+ if (pm === "pnpm") return "pnpm exec vite build"
70
+ return "npx vite build"
71
+ }
72
+
73
+ /** True when the directory has its own package.json declaring a build script */
74
+ const hasBuildScript = (dir: string): boolean => {
42
75
  try {
43
- execSync("npx vite build", { cwd, encoding: "utf-8", stdio: "pipe" })
44
- return { success: true }
45
- } catch (e: any) {
46
- return { success: false, error: e.stderr || e.stdout || e.message }
76
+ const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf-8"))
77
+ return Boolean(pkg.scripts?.build)
78
+ } catch {
79
+ return false
47
80
  }
48
81
  }
@@ -0,0 +1,55 @@
1
+ // The Puzzmo brand mark traced into braille: each cell holds 2x4 dots, and only the
2
+ // yellow body is dotted so the dark face reads as holes. Rows are exactly `width`
3
+ // columns, which callers rely on to pad around the art without measuring it.
4
+
5
+ /** The Puzzmo character rendered as terminal art, one string per row. */
6
+ export type Mascot = {
7
+ /** Rows of the art, each carrying its own ANSI escapes and ending in a reset. */
8
+ lines: string[]
9
+ /** Visible width in terminal columns, so callers can pad around it. */
10
+ width: number
11
+ /** Height in terminal rows. */
12
+ height: number
13
+ }
14
+
15
+ /** Braille art at 20x10 cells, for when there is room to spare. */
16
+ export const mascotLarge: Mascot = {
17
+ lines: [
18
+ "\x1b[38;2;255;192;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⠇\x1b[0m",
19
+ "\x1b[38;2;255;192;0m⠀⠀⠀⠀⢀⣠⣤⣴⣶⣶⣶⣦⣤⣀⠀⠀⠀⣾⣿⠀\x1b[0m",
20
+ "\x1b[38;2;255;192;0m⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣦⡀⠈⣿⣧\x1b[0m",
21
+ "\x1b[38;2;255;192;0m⠀⣾⣿⣿⣿⣿⣿⣿⣿⣧⣀⣽⣿⣿⣿⣿⣿⣾⡿⠁\x1b[0m",
22
+ "\x1b[38;2;255;192;0m⢸⣿⣿⣿⣿⣀⣹⣿⣿⡿⠟⠛⠉⢻⣿⣿⣿⣿⠀⠀\x1b[0m",
23
+ "\x1b[38;2;255;192;0m⢸⣿⣿⣿⣿⣿⠟⠋⠁⠀⠀⠀⠀⣸⣿⣿⣿⣿⠃⠀\x1b[0m",
24
+ "\x1b[38;2;255;192;0m⠘⣿⣿⣿⣿⣷⣄⠀⠀⠀⢀⣠⣴⣿⣿⣿⣿⡟⠀⠀\x1b[0m",
25
+ "\x1b[38;2;255;192;0m⠀⢘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀\x1b[0m",
26
+ "\x1b[38;2;255;192;0m⣰⣿⠟⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠁⠀⠀⠀⠀\x1b[0m",
27
+ "\x1b[38;2;255;192;0m⠻⣿⣶⣶⣶⠄⠀⠀⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀\x1b[0m",
28
+ ],
29
+ width: 20,
30
+ height: 10,
31
+ }
32
+
33
+ /** Braille art at 16x8 cells, for tight spots like the upload summary. */
34
+ export const mascotSmall: Mascot = {
35
+ lines: [
36
+ "\x1b[38;2;255;192;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⠇\x1b[0m",
37
+ "\x1b[38;2;255;192;0m⠀⠀⢀⣤⣶⣶⣿⣿⣿⣷⣶⣤⡀⠐⣿⣄\x1b[0m",
38
+ "\x1b[38;2;255;192;0m⠀⣴⣿⣿⣿⣿⣿⣟⠉⣿⣿⣿⣿⣦⣾⠟\x1b[0m",
39
+ "\x1b[38;2;255;192;0m⣸⣿⣿⣿⣉⣿⣿⡿⠿⠛⠻⣿⣿⣿⡇⠀\x1b[0m",
40
+ "\x1b[38;2;255;192;0m⢻⣿⣿⣿⡿⠋⠁⠀⠀⠀⣰⣿⣿⣿⡇⠀\x1b[0m",
41
+ "\x1b[38;2;255;192;0m⠘⣿⣿⣿⣿⣦⣄⣀⣤⣶⣿⣿⣿⡿⠁⠀\x1b[0m",
42
+ "\x1b[38;2;255;192;0m⢠⣾⠿⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀\x1b[0m",
43
+ "\x1b[38;2;255;192;0m⢿⣷⣶⣶⠈⠉⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀\x1b[0m",
44
+ ],
45
+ width: 16,
46
+ height: 8,
47
+ }
48
+
49
+ /**
50
+ * The art to draw, or null when colour is unavailable. There is no plain-text
51
+ * fallback on purpose: nobody wants eight rows of braille in a CI log.
52
+ */
53
+ export const pickMascot = (preferred: Mascot): Mascot | null => (supportsColor() ? preferred : null)
54
+
55
+ const supportsColor = (): boolean => Boolean(process.stdout.isTTY) && !process.env.NO_COLOR
@@ -15,5 +15,7 @@ Edit puzzles in `fixtures/puzzles/`. Game logic is in `src/main.ts`.
15
15
  ## Deployment
16
16
 
17
17
  ```
18
- yarn puzzmo games upload
18
+ puzzmo login <your-token> # token from dev.puzzmo.com
19
+ yarn deploy # builds, then uploads to Puzzmo
20
+ yarn deploy:only # uploads the current dist/
19
21
  ```
@@ -5,7 +5,9 @@
5
5
  "scripts": {
6
6
  "dev": "vite",
7
7
  "build": "vite build",
8
- "preview": "vite preview"
8
+ "preview": "vite preview",
9
+ "deploy": "vite build && puzzmo games upload",
10
+ "deploy:only": "puzzmo games upload"
9
11
  },
10
12
  "dependencies": {
11
13
  "@puzzmo/cli": "*",