@playcraft/cli 0.0.57 → 0.0.58

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 (225) hide show
  1. package/README.md +34 -16
  2. package/dist/cli-root-help.js +1 -0
  3. package/dist/commands/build-all.js +10 -9
  4. package/dist/commands/build.js +13 -12
  5. package/dist/commands/create.js +26 -33
  6. package/dist/commands/platform-skills.generated.js +19 -0
  7. package/dist/commands/skills.js +2 -0
  8. package/dist/commands/tools-generation.js +1 -1
  9. package/dist/commands/workspace-runtime.js +54 -0
  10. package/dist/index.js +3 -1
  11. package/dist/project-skills/commands.js +72 -0
  12. package/dist/project-skills/lifecycle.js +28 -0
  13. package/dist/project-skills/local-run.js +112 -0
  14. package/dist/project-skills/local-store.js +149 -0
  15. package/dist/project-skills/messages.js +72 -0
  16. package/dist/project-skills/reconcile.js +62 -0
  17. package/dist/project-skills/remote-cache.js +51 -0
  18. package/dist/project-skills/validation.js +19 -0
  19. package/dist/remix/clone.js +2 -0
  20. package/dist/remix/init-template.js +2 -0
  21. package/dist/remix/pull.js +2 -0
  22. package/dist/remix/push.js +21 -1
  23. package/dist/utils/agent-api-client.js +54 -17
  24. package/dist/utils/tool-operation-journal.js +54 -0
  25. package/dist/workspace-runtime/codex/app-server.js +395 -0
  26. package/dist/workspace-runtime/codex/config-toml.js +25 -0
  27. package/dist/workspace-runtime/codex/jsonrpc-stdio.js +106 -0
  28. package/dist/workspace-runtime/codex/loopback.js +59 -0
  29. package/dist/workspace-runtime/codex/native-adapter.js +3 -0
  30. package/dist/workspace-runtime/main.js +10 -0
  31. package/dist/workspace-runtime/persistence/journal.js +350 -0
  32. package/dist/workspace-runtime/processes/managed-writes.js +69 -0
  33. package/dist/workspace-runtime/serve.js +111 -0
  34. package/dist/workspace-runtime/server/auth.js +21 -0
  35. package/dist/workspace-runtime/server/dispatch.js +861 -0
  36. package/dist/workspace-runtime/server/execution-group.js +88 -0
  37. package/dist/workspace-runtime/server/http.js +561 -0
  38. package/dist/workspace-runtime/server/lock.js +53 -0
  39. package/dist/workspace-runtime/server/types.js +1 -0
  40. package/dist/workspace-runtime/workspaces/context-error.js +2 -0
  41. package/dist/workspace-runtime/workspaces/file-snapshot.js +213 -0
  42. package/dist/workspace-runtime/workspaces/files.js +143 -0
  43. package/dist/workspace-runtime/workspaces/git.js +242 -0
  44. package/dist/workspace-runtime/workspaces/json5-edit.js +170 -0
  45. package/dist/workspace-runtime/workspaces/parameters.js +272 -0
  46. package/dist/workspace-runtime/workspaces/prepare.js +364 -0
  47. package/dist/workspace-runtime/workspaces/registry.js +107 -0
  48. package/dist/workspace-runtime/workspaces/revisions.js +31 -0
  49. package/package.json +4 -1
  50. package/project-template-v2/.claude/agents/artist.md +82 -0
  51. package/project-template-v2/.claude/agents/developer.md +153 -0
  52. package/project-template-v2/.claude/agents/game-designer.md +264 -0
  53. package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
  54. package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
  55. package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
  56. package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
  57. package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
  58. package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
  59. package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
  60. package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
  61. package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
  62. package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
  63. package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
  64. package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  65. package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  66. package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
  67. package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  68. package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
  69. package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
  70. package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  71. package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
  72. package/project-template-v2/.claude/agents/reviewer.md +75 -0
  73. package/project-template-v2/.claude/agents/technical-artist.md +86 -0
  74. package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
  75. package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
  76. package/project-template-v2/.claude/settings.json +33 -0
  77. package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
  78. package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
  79. package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
  80. package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
  81. package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
  82. package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
  83. package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
  84. package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  85. package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
  86. package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  87. package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  88. package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
  89. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  90. package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  91. package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  92. package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +298 -0
  93. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  94. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  95. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +324 -0
  96. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  97. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  98. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  99. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  100. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  101. package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  102. package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +219 -0
  103. package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
  104. package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
  105. package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
  106. package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
  107. package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  108. package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
  109. package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
  110. package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  111. package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  112. package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  113. package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  114. package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
  115. package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  116. package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  117. package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  118. package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
  119. package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
  120. package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
  121. package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  122. package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
  123. package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
  124. package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
  125. package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
  126. package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
  127. package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
  128. package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
  129. package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
  130. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
  131. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
  132. package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
  133. package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
  134. package/project-template-v2/.claude/snapshot.mjs +263 -0
  135. package/project-template-v2/.playcraft/skills.lock.json +152 -0
  136. package/project-template-v2/CLAUDE.md +146 -0
  137. package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
  138. package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
  139. package/project-template-v2/assets/bundles/.gitkeep +0 -0
  140. package/project-template-v2/assets/images/bg/.gitkeep +0 -0
  141. package/project-template-v2/assets/images/reference/.gitkeep +0 -0
  142. package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
  143. package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
  144. package/project-template-v2/assets/images/ui/.gitkeep +0 -0
  145. package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
  146. package/project-template-v2/assets/models/.gitkeep +0 -0
  147. package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
  148. package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
  149. package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
  150. package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
  151. package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
  152. package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
  153. package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
  154. package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
  155. package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
  156. package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
  157. package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
  158. package/project-template-v2/docs/project-state.json +60 -0
  159. package/project-template-v2/docs/project-state.md +72 -0
  160. package/project-template-v2/docs/standards/README.md +225 -0
  161. package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
  162. package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
  163. package/project-template-v2/docs/standards/artifacts/design.md +22 -0
  164. package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
  165. package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
  166. package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
  167. package/project-template-v2/game/index.ts +18 -0
  168. package/project-template-v2/globals.d.ts +51 -0
  169. package/project-template-v2/index.css +34 -0
  170. package/project-template-v2/index.html +18 -0
  171. package/project-template-v2/main.ts +9 -0
  172. package/project-template-v2/package.json +46 -0
  173. package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
  174. package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
  175. package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
  176. package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
  177. package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
  178. package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
  179. package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
  180. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
  181. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
  182. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
  183. package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
  184. package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
  185. package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
  186. package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
  187. package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
  188. package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
  189. package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
  190. package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
  191. package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
  192. package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
  193. package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
  194. package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
  195. package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
  196. package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
  197. package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
  198. package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
  199. package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
  200. package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
  201. package/project-template-v2/skills/playable-record/SKILL.md +140 -0
  202. package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
  203. package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
  204. package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
  205. package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
  206. package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
  207. package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
  208. package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
  209. package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
  210. package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
  211. package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
  212. package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
  213. package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
  214. package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
  215. package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
  216. package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
  217. package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
  218. package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
  219. package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
  220. package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
  221. package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
  222. package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
  223. package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
  224. package/project-template-v2/tsconfig.json +20 -0
  225. package/project-template-v2/vite.config.ts +27 -0
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * snapshot.mjs — Archive current project state + all AI sessions as a git commit + tag
4
+ *
5
+ * Usage:
6
+ * node snapshot.mjs # snapshot cwd project
7
+ * node snapshot.mjs <project-path> # snapshot a specific project
8
+ * node snapshot.mjs --project <path> # same as above, explicit flag
9
+ * node snapshot.mjs --name <label> # custom label for the snapshot commit
10
+ * node snapshot.mjs --force # skip active-CLI check
11
+ *
12
+ * What gets archived:
13
+ * All tracked project files (git add -A)
14
+ * .playcraft/sessions/ — session JSONL files (main + subagents) from all three stores
15
+ * (Claude Code / Claude Internal / CodeBuddy) matching the project path
16
+ *
17
+ * Output: git commit snapshot: {label} ({MMDD_HHmm})
18
+ */
19
+
20
+ import { spawnSync } from 'child_process';
21
+ import { existsSync, readdirSync, statSync, mkdirSync, writeFileSync, rmSync, cpSync } from 'fs';
22
+ import { join, basename, resolve } from 'path';
23
+ import { homedir } from 'os';
24
+
25
+ // ── helpers ──────────────────────────────────────────────────────────────────
26
+
27
+ function parseArgs() {
28
+ const args = process.argv.slice(2);
29
+ const opts = { project: null, name: null, force: false };
30
+ for (let i = 0; i < args.length; i++) {
31
+ if (args[i] === '--project' && args[i + 1]) opts.project = args[++i];
32
+ else if (args[i] === '--name' && args[i + 1]) opts.name = args[++i];
33
+ else if (args[i] === '--force') opts.force = true;
34
+ else if (!args[i].startsWith('--') && !opts.project) opts.project = args[i];
35
+ }
36
+ return opts;
37
+ }
38
+
39
+ function timestamp() {
40
+ const d = new Date();
41
+ const pad = n => String(n).padStart(2, '0');
42
+ return `${pad(d.getMonth() + 1)}${pad(d.getDate())}_${pad(d.getHours())}${pad(d.getMinutes())}`;
43
+ }
44
+
45
+ function isoNow() {
46
+ return new Date().toISOString();
47
+ }
48
+
49
+ // ── active CLI detection ─────────────────────────────────────────────────────
50
+
51
+ // ── session collection ───────────────────────────────────────────────────────
52
+
53
+ function findSessions(projectCwd) {
54
+ const home = homedir();
55
+ const stores = [
56
+ { name: 'claude-code', path: join(home, '.claude', 'projects') },
57
+ { name: 'codebuddy', path: join(home, '.codebuddy', 'projects') },
58
+ ];
59
+
60
+ const normalizedCwd = resolve(projectCwd).replace(/\\/g, '/');
61
+ const slugVariants = [
62
+ normalizedCwd.replace(/[:/]/g, '-').replace(/\//g, '-'),
63
+ normalizedCwd.replace(/\\/g, '-').replace(/:/g, '-'),
64
+ ];
65
+ const projectName = basename(normalizedCwd);
66
+
67
+ const found = [];
68
+
69
+ for (const store of stores) {
70
+ if (!existsSync(store.path)) continue;
71
+ let projects;
72
+ try { projects = readdirSync(store.path); } catch { continue; }
73
+
74
+ for (const proj of projects) {
75
+ const projLower = proj.toLowerCase();
76
+ const matches =
77
+ projLower.includes(projectName.toLowerCase()) ||
78
+ slugVariants.some(s => projLower.includes(s.toLowerCase().slice(-30)));
79
+
80
+ if (!matches) continue;
81
+
82
+ const projPath = join(store.path, proj);
83
+ let stat;
84
+ try { stat = statSync(projPath); } catch { continue; }
85
+ if (!stat.isDirectory()) continue;
86
+
87
+ let files;
88
+ try { files = readdirSync(projPath).filter(f => f.endsWith('.jsonl')); } catch { continue; }
89
+
90
+ for (const f of files) {
91
+ const sessionId = f.replace('.jsonl', '');
92
+ const sessionFile = join(projPath, f);
93
+ const subagentsDir = join(projPath, sessionId, 'subagents');
94
+ found.push({
95
+ store: store.name,
96
+ project: proj,
97
+ sessionId,
98
+ sessionFile,
99
+ subagentsDir: existsSync(subagentsDir) ? subagentsDir : null,
100
+ });
101
+ }
102
+ }
103
+ }
104
+
105
+ return found;
106
+ }
107
+
108
+ function waitForStable(sessionFile, maxRetries = 3, intervalMs = 500) {
109
+ let lastSize;
110
+ try { lastSize = statSync(sessionFile).size; } catch { return false; }
111
+
112
+ for (let i = 0; i < maxRetries; i++) {
113
+ const waitUntil = Date.now() + intervalMs;
114
+ while (Date.now() < waitUntil) { /* spin */ }
115
+
116
+ let newSize;
117
+ try { newSize = statSync(sessionFile).size; } catch { return false; }
118
+
119
+ if (newSize === lastSize) return true;
120
+ lastSize = newSize;
121
+ }
122
+
123
+ return false;
124
+ }
125
+
126
+ // ── git operations ───────────────────────────────────────────────────────────
127
+
128
+ function gitExec(cwd, args, env = {}) {
129
+ const result = spawnSync('git', ['-C', cwd, ...args], {
130
+ encoding: 'utf8',
131
+ env: { ...process.env, ...env },
132
+ stdio: ['ignore', 'pipe', 'pipe'],
133
+ });
134
+ if (result.status !== 0) {
135
+ const errMsg = result.stderr?.trim() || result.stdout?.trim() || 'unknown error';
136
+ throw new Error(`git ${args[0]} failed: ${errMsg}`);
137
+ }
138
+ return result.stdout?.trim() || '';
139
+ }
140
+
141
+ function gitExecWithRetries(cwd, args, env = {}, maxRetries = 3) {
142
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
143
+ try {
144
+ return gitExec(cwd, args, env);
145
+ } catch (err) {
146
+ if (attempt < maxRetries && err.message.includes('.git/index.lock')) {
147
+ console.warn(` ⚠ git index locked, retrying (${attempt}/${maxRetries})...`);
148
+ const waitUntil = Date.now() + 1000;
149
+ while (Date.now() < waitUntil) { /* spin */ }
150
+ continue;
151
+ }
152
+ throw err;
153
+ }
154
+ }
155
+ }
156
+
157
+ // ── main ─────────────────────────────────────────────────────────────────────
158
+
159
+ const opts = parseArgs();
160
+
161
+ // ── snapshot creation ─────────────────────────────────────────────────────────
162
+
163
+ const executionCwd = process.cwd();
164
+ const projectDir = opts.project ? resolve(executionCwd, opts.project) : executionCwd;
165
+ const projectName = basename(projectDir);
166
+ const ts = timestamp();
167
+ const label = opts.name || `manual`;
168
+
169
+ console.log(`\n📦 Snapshotting project: ${projectName}`);
170
+ console.log(` Source: ${projectDir}\n`);
171
+
172
+ // 1. Verify .git/ exists
173
+ const gitDir = join(projectDir, '.git');
174
+ if (!existsSync(gitDir)) {
175
+ console.error(`❌ No .git directory found at ${projectDir}`);
176
+ console.error(' Snapshot requires a git repository. Use "git init" first.');
177
+ process.exit(1);
178
+ }
179
+
180
+ // 2. Active CLI check
181
+ if (!opts.force) {
182
+ console.warn(' ⚠ Use --force to skip active-CLI check.\n');
183
+ }
184
+
185
+ // 3. Collect sessions with write stability detection
186
+ console.log('🗂 Finding sessions...');
187
+ const sessions = findSessions(projectDir);
188
+
189
+ const sessionsDir = join(projectDir, '.playcraft', 'sessions');
190
+ if (existsSync(sessionsDir)) {
191
+ rmSync(sessionsDir, { recursive: true, force: true });
192
+ }
193
+ mkdirSync(sessionsDir, { recursive: true });
194
+
195
+ if (sessions.length === 0) {
196
+ console.log(' ⚠ No sessions found for this project path');
197
+ } else {
198
+ console.log(` Found ${sessions.length} session(s):`);
199
+ for (const s of sessions) {
200
+ const stable = waitForStable(s.sessionFile);
201
+ if (!stable) {
202
+ console.warn(` ⚠ Session file still being written: ${s.sessionId.slice(0, 8)}… — copying anyway`);
203
+ }
204
+
205
+ const sessionDestDir = join(sessionsDir, s.store, s.project);
206
+ mkdirSync(sessionDestDir, { recursive: true });
207
+ cpSync(s.sessionFile, join(sessionDestDir, `${s.sessionId}.jsonl`));
208
+
209
+ let subCount = 0;
210
+ if (s.subagentsDir) {
211
+ const subDest = join(sessionDestDir, s.sessionId, 'subagents');
212
+ mkdirSync(subDest, { recursive: true });
213
+ const subFiles = readdirSync(s.subagentsDir).filter(f => f.endsWith('.jsonl'));
214
+ for (const sf of subFiles) {
215
+ cpSync(join(s.subagentsDir, sf), join(subDest, sf));
216
+ subCount++;
217
+ }
218
+ }
219
+
220
+ const sizeMB = (statSync(s.sessionFile).size / 1024 / 1024).toFixed(2);
221
+ console.log(` ✓ [${s.store}] ${s.sessionId.slice(0, 8)}… (${sizeMB}MB, ${subCount} subagents)`);
222
+ }
223
+ }
224
+
225
+ // 4. Write manifest
226
+ const manifest = {
227
+ createdAt: isoNow(),
228
+ projectName,
229
+ projectPath: projectDir,
230
+ label: opts.name || 'manual',
231
+ sessionCount: sessions.length,
232
+ sessions: sessions.map(s => ({
233
+ store: s.store,
234
+ project: s.project,
235
+ sessionId: s.sessionId,
236
+ hasSubagents: !!s.subagentsDir,
237
+ })),
238
+ };
239
+ writeFileSync(join(sessionsDir, 'manifest.json'), JSON.stringify(manifest, null, 2));
240
+
241
+ // 5. Git add all changes (including sessions)
242
+ console.log('\n📝 Staging changes...');
243
+ const GIT_ENV = {
244
+ GIT_AUTHOR_NAME: 'PlayCraft Snapshot',
245
+ GIT_AUTHOR_EMAIL: 'snapshot@playcraft.local',
246
+ GIT_COMMITTER_NAME: 'PlayCraft Snapshot',
247
+ GIT_COMMITTER_EMAIL: 'snapshot@playcraft.local',
248
+ };
249
+
250
+ gitExecWithRetries(projectDir, ['add', '-A'], GIT_ENV);
251
+ console.log(' ✓ Staged');
252
+
253
+ // 6. Commit
254
+ console.log('\n💾 Committing snapshot...');
255
+ const commitMsg = `snapshot: ${label} (${ts})`;
256
+ gitExecWithRetries(projectDir, ['commit', '--allow-empty', '-m', commitMsg], GIT_ENV);
257
+ const commitHash = gitExec(projectDir, ['rev-parse', '--short', 'HEAD']);
258
+ console.log(` ✓ Commit: ${commitHash}`);
259
+
260
+ // 7. Summary
261
+ console.log(`\n✅ Snapshot complete!`);
262
+ console.log(` Hash: ${commitHash}`);
263
+ console.log(` Sessions archived: ${sessions.length}\n`);
@@ -0,0 +1,152 @@
1
+ {
2
+ "lockVersion": 2,
3
+ "entries": [
4
+ {
5
+ "skillRef": "platform/playcraft-3d-flip-sprite",
6
+ "version": "1.0.0",
7
+ "artifactHash": "bfea71413bf9f0b57eda4c79c1c9e5d73061becaf9c1ece066ffcc32890ad1ea",
8
+ "surface": "portal-agent",
9
+ "mountPath": ".playcraft/skills/platform__playcraft-3d-flip-sprite"
10
+ },
11
+ {
12
+ "skillRef": "platform/playcraft-asset-management",
13
+ "version": "1.0.0",
14
+ "artifactHash": "11ae4c6b1e9e9cb8639e22cfc9568f70cc7fc526bb9632e601e2886ba50fb0f3",
15
+ "surface": "portal-agent",
16
+ "mountPath": ".playcraft/skills/platform__playcraft-asset-management"
17
+ },
18
+ {
19
+ "skillRef": "platform/playcraft-build",
20
+ "version": "1.0.0",
21
+ "artifactHash": "7fbd4ba060efc9409e8da9aa7d4edfe2cdb2734de7a497b79299a7061cacf3ac",
22
+ "surface": "portal-agent",
23
+ "mountPath": ".playcraft/skills/platform__playcraft-build"
24
+ },
25
+ {
26
+ "skillRef": "platform/playcraft-code-editor",
27
+ "version": "1.0.0",
28
+ "artifactHash": "4db2b7e60762ba0ccc249ea4023dcb81701dac38d54af0e6757b5337ea489a32",
29
+ "surface": "portal-agent",
30
+ "mountPath": ".playcraft/skills/platform__playcraft-code-editor"
31
+ },
32
+ {
33
+ "skillRef": "platform/playcraft-create-remix",
34
+ "version": "1.0.0",
35
+ "artifactHash": "76f7cfd4b7441184805e07550f687651225a3baf27e306f0ee7c4347e58f3f19",
36
+ "surface": "portal-agent",
37
+ "mountPath": ".playcraft/skills/platform__playcraft-create-remix"
38
+ },
39
+ {
40
+ "skillRef": "platform/playcraft-deploy",
41
+ "version": "1.0.0",
42
+ "artifactHash": "e619cee8bea40b2a0c9b69a02d387369a3628a73c0a0504b3c92b1330bc12e86",
43
+ "surface": "portal-agent",
44
+ "mountPath": ".playcraft/skills/platform__playcraft-deploy"
45
+ },
46
+ {
47
+ "skillRef": "platform/playcraft-iteration-methodology",
48
+ "version": "1.0.0",
49
+ "artifactHash": "42c5219f6f8a8d63787efeef6da8522cf7400442dc75dc8dee6d0c49b0ed28b7",
50
+ "surface": "portal-agent",
51
+ "mountPath": ".playcraft/skills/platform__playcraft-iteration-methodology"
52
+ },
53
+ {
54
+ "skillRef": "platform/playcraft-platform-intro",
55
+ "version": "1.0.0",
56
+ "artifactHash": "d32001cff62516d343707fdbe4812ed9dde6651c749f2aadc848d06196f07c15",
57
+ "surface": "portal-agent",
58
+ "mountPath": ".playcraft/skills/platform__playcraft-platform-intro"
59
+ },
60
+ {
61
+ "skillRef": "platform/playcraft-prefab",
62
+ "version": "1.0.0",
63
+ "artifactHash": "7089e5b346ce99dbc25f61e2645e67fce057e6a108445975c99a03b062c84007",
64
+ "surface": "portal-agent",
65
+ "mountPath": ".playcraft/skills/platform__playcraft-prefab"
66
+ },
67
+ {
68
+ "skillRef": "platform/playcraft-project-management",
69
+ "version": "1.0.0",
70
+ "artifactHash": "32459786cdd17ece2df094be1f13387802325191531939c40c1ddfde3590a17b",
71
+ "surface": "portal-agent",
72
+ "mountPath": ".playcraft/skills/platform__playcraft-project-management"
73
+ },
74
+ {
75
+ "skillRef": "platform/playcraft-remix-workflow",
76
+ "version": "1.0.0",
77
+ "artifactHash": "07a25c34042dabbde9a166d4e49c977dd8b2459eff27c9c1bc9cafe0a56a08ef",
78
+ "surface": "portal-agent",
79
+ "mountPath": ".playcraft/skills/platform__playcraft-remix-workflow"
80
+ },
81
+ {
82
+ "skillRef": "platform/playcraft-save",
83
+ "version": "1.0.0",
84
+ "artifactHash": "100d6d66ac449bc8b7f183b8165587bcef6bb5d138d2ddfa07035f229275bc3d",
85
+ "surface": "portal-agent",
86
+ "mountPath": ".playcraft/skills/platform__playcraft-save"
87
+ },
88
+ {
89
+ "skillRef": "platform/playcraft-template-upgrade-merge",
90
+ "version": "1.0.0",
91
+ "artifactHash": "459e87e02c45b5a859d1c79daf0c53cd7ee9426d6d55ef8d1156a052e557a52f",
92
+ "surface": "portal-agent",
93
+ "mountPath": ".playcraft/skills/platform__playcraft-template-upgrade-merge"
94
+ },
95
+ {
96
+ "skillRef": "platform/sound-effects",
97
+ "version": "1.0.0",
98
+ "artifactHash": "3a2235197c23ca5b38c46fbb0ff1686f509c094ba206f199f78cdd5f1a07aa95",
99
+ "surface": "portal-agent",
100
+ "mountPath": ".playcraft/skills/platform__sound-effects"
101
+ },
102
+ {
103
+ "skillRef": "remix/playcraft-adsdk",
104
+ "version": "1.0.0",
105
+ "artifactHash": "9b2e784b167372c6d3e14a3636dac2af8cf64af46c1bef1e082b77c0db51a9c2",
106
+ "surface": "sandbox-agent",
107
+ "mountPath": ".playcraft/skills/remix__playcraft-adsdk"
108
+ },
109
+ {
110
+ "skillRef": "remix/playcraft-audio-generation",
111
+ "version": "1.0.0",
112
+ "artifactHash": "0f171e4e739d3b1a5b1f00a0b20cf13d0897c69c9d4e30dd3477acd6b982c8c8",
113
+ "surface": "sandbox-agent",
114
+ "mountPath": ".playcraft/skills/remix__playcraft-audio-generation"
115
+ },
116
+ {
117
+ "skillRef": "remix/playcraft-dist-publish",
118
+ "version": "1.0.0",
119
+ "artifactHash": "0c2396be7fed8b1a0fa2990eee2a23ed9b6abe02ead68c15648f45de7c11e254",
120
+ "surface": "sandbox-agent",
121
+ "mountPath": ".playcraft/skills/remix__playcraft-dist-publish"
122
+ },
123
+ {
124
+ "skillRef": "remix/playcraft-image-generation",
125
+ "version": "1.0.0",
126
+ "artifactHash": "a7bd5e50c62250f9c84c600239a57d71f197b88d4dedfa9eec6befc10cb4239a",
127
+ "surface": "sandbox-agent",
128
+ "mountPath": ".playcraft/skills/remix__playcraft-image-generation"
129
+ },
130
+ {
131
+ "skillRef": "remix/playcraft-image-processing",
132
+ "version": "1.0.0",
133
+ "artifactHash": "137ce0b8b76d591148dc0158b5e38abc2fc17f04471fc0d027b0a19d3dde709d",
134
+ "surface": "sandbox-agent",
135
+ "mountPath": ".playcraft/skills/remix__playcraft-image-processing"
136
+ },
137
+ {
138
+ "skillRef": "remix/playcraft-prefab",
139
+ "version": "1.0.0",
140
+ "artifactHash": "eb1de9851f842e475bb2ae8bb239d5f9b5ab6bd28fe0c83ae96d8570e1a8b814",
141
+ "surface": "sandbox-agent",
142
+ "mountPath": ".playcraft/skills/remix__playcraft-prefab"
143
+ },
144
+ {
145
+ "skillRef": "remix/playcraft-remix-workflow",
146
+ "version": "1.0.0",
147
+ "artifactHash": "cf5ed218579d49887d6bf2c5f4eb7512ea86684984f57546676df2d6378cd054",
148
+ "surface": "sandbox-agent",
149
+ "mountPath": ".playcraft/skills/remix__playcraft-remix-workflow"
150
+ }
151
+ ]
152
+ }
@@ -0,0 +1,146 @@
1
+ # PlayCraft Playable Ad Project
2
+
3
+ 这是一个正在制作中的 PlayCraft playable ad 工程,由模板 `project-template-v2` 生成。当前目录不是通用代码库,而是一个会随多 agent 制作流程逐步长出的 playable 项目。
4
+
5
+ 本文件是项目速览:帮助任何 agent 快速理解当前工程形态、入口文件、状态来源和安全边界。它不是调度剧本,也不是状态真源。
6
+
7
+ ## Current Snapshot
8
+
9
+ - Package: `playcraft-game`, template version `0.4.0-alpha.0`.
10
+ - Runtime stack: Vite + TypeScript.
11
+ - Current pipeline: iteration 1, stage `ideate`, status `pending`.
12
+ - Locked decisions: engine `unset`, coreAction `unset`.
13
+ - Runtime code: `game/index.ts` is still an engine placeholder. Engine scaffold has not been applied yet.
14
+ - Design artifacts are not created yet: `docs/design.md`, `docs/design-brief.md`, `docs/atom-tree.json`, and `docs/todo_list.md` will appear during iteration 1.
15
+ - Optimize verification currently includes `playable-record`, `playable-debug`, and `playable-validate`.
16
+
17
+ ## State Sources
18
+
19
+ - State command: `npm run state:get` is the normal read entry for current workflow state.
20
+ - Process backing file: `docs/project-state.json` (JSON, JavaScript Object Notation, JavaScript 对象表示法); do not read it directly unless debugging the state scripts.
21
+ - Human view: `docs/project-state.md`, generated from the process backing file.
22
+ - Pipeline specification: `skills/_shared/scripts/pipeline/`.
23
+ - Orchestrator flow: `docs/harness/orchestrator-flow.md`.
24
+ - Stage flow notes: `docs/harness/iteration-1/`.
25
+ - Do not hand-edit `docs/project-state.md`; update state through scripts.
26
+
27
+ State describes current work; it does not by itself prove which process you are. Use your entry context first, then state.
28
+
29
+ Main agent entry:
30
+
31
+ Read `docs/harness/orchestrator-flow.md`.
32
+
33
+ Named role subagent entry:
34
+
35
+ ```bash
36
+ npm run state:get -- --json dispatch
37
+ ```
38
+
39
+ If `dispatch.role` is not your role, stop and report that no workticket is assigned to you.
40
+
41
+ ## Project Map
42
+
43
+ ### Runtime
44
+
45
+ - `index.html` - browser document entry (HTML, HyperText Markup Language, 超文本标记语言).
46
+ - `main.ts` - TypeScript entry; imports styles and mounts `startGame("game-container")`.
47
+ - `game/index.ts` - current playable entry. At bootstrap it only displays the engine-not-scaffolded message.
48
+ - `index.css` - global page layout and styling (CSS, Cascading Style Sheets, 层叠样式表).
49
+ - `globals.d.ts` - asset module declarations and `__DEV__` global.
50
+ - `vite.config.ts` - dev/build configuration, asset alias, port preference.
51
+
52
+ ### Assets
53
+
54
+ - `assets/images/bg/` - background image candidates.
55
+ - `assets/images/ui/` - user interface image candidates.
56
+ - `assets/images/tiles/` - tile or board image candidates.
57
+ - `assets/images/vfx/` - visual effect images.
58
+ - `assets/images/storyboard/` and `assets/images/reference/` - ideation and reference images.
59
+ - `assets/audio/bgm/` and `assets/audio/sfx/` - music and sound effects.
60
+ - `assets/models/` - 3D (Three-Dimensional, 三维) model assets.
61
+ - `assets/bundles/` - generated or packaged asset bundles.
62
+
63
+ ### Project State And Design
64
+
65
+ - `docs/project-state.json` - process backing file for workflow state; normally read via `npm run state:get`.
66
+ - `docs/project-state.md` - generated state view.
67
+ - `docs/harness/pipeline-design.md` - pipeline v2 design and TODO backlog.
68
+ - `docs/harness/orchestrator-flow.md` - orchestrator runtime loop and dispatch rules.
69
+ - `docs/harness/iteration-1/ideate-flow.md` - design discovery and `docs/design.md` rules.
70
+ - `docs/harness/iteration-1/context-flow.md` - atom-tree and plan-equivalent todo task-card seeding rules.
71
+ - `docs/harness/iteration-1/generate-flow.md` - todo-driven implementation loop.
72
+ - `docs/harness/iteration-1/optimize-flow.md` - build/autoplay/record target and verification skill usage.
73
+ - `docs/harness/iteration-1/wrapup-flow.md` - cleanup and this file refresh rules.
74
+
75
+ Expected iteration-1 artifacts:
76
+
77
+ - `docs/design-brief.md` - discovery and brainstorming log.
78
+ - `docs/design.md` - core gameplay design.
79
+ - `docs/atom-tree.json` - selected atom and skills match source.
80
+ - `docs/todo_list.md` - human-readable todo index and cross-todo ref/gap overview.
81
+
82
+ ### Workflow Scripts
83
+
84
+ - `skills/_shared/scripts/state-get.mjs` - read orchestrator or dispatch state.
85
+ - `skills/_shared/scripts/state-set.mjs` - update state fields.
86
+ - `skills/_shared/scripts/state-advance-stage.mjs` - advance the pipeline stage.
87
+ - `skills/_shared/scripts/todo-add.mjs` / `todo-set.mjs` / `todo-remove.mjs` - manage todo pool.
88
+ - `skills/_shared/scripts/handoff-append.mjs` - append role handoff records.
89
+ - `skills/_shared/scripts/dod-check.mjs` - run DoD (Definition of Done, 完成定义) checks for the current stage.
90
+ - `skills/_shared/scripts/render-project-state.mjs` - render `docs/project-state.md` from JSON state.
91
+
92
+ ### Agent And Skill Context
93
+
94
+ - `.claude/agents/` - role cards for game-designer, developer, artist, technical-artist, and reviewer.
95
+ - `.claude/agents/refs/` - role reference material.
96
+ - `.claude/skills/` - local skills visible to agents.
97
+ - `.claude/hooks/` - Claude hook scripts.
98
+ - `.claude/settings.json` - hook registration and agent-team environment.
99
+
100
+ ## Common Commands
101
+
102
+ ```bash
103
+ npm run dev
104
+ npm run build
105
+ npm run typecheck
106
+ npm run state:get
107
+ npm run state:get -- --json dispatch
108
+ npm run dispatch:set -- id=<id> role=<role> goal="..."
109
+ npm run dispatch:clear
110
+ npm run todo:add -- id=<id> role=<role> title="..." goal="..." context="..." acceptance="..."
111
+ npm run todo:get -- id=<id>
112
+ npm run todo:set -- id=<id> status=<pending|in_progress|done|failed>
113
+ npm run handoff:append -- role=<role> summary="..." artifactRefs="<files>"
114
+ npm run dod:check
115
+ npm run verify:contract
116
+ npm run verify:firstwin
117
+ npm run verify:fusion
118
+ npm run record:mp4
119
+ npm run verify:vlm-video
120
+ ```
121
+
122
+ Notes:
123
+
124
+ - `npm run typecheck` requires dependencies to be installed first.
125
+ - `record:mp4` requires Playwright Chromium to be installed; run `npm run record:mp4:install` if the local browser binary is missing.
126
+
127
+ ## Agent Boundaries
128
+
129
+ - This file is injected into every agent, so keep it as project context only.
130
+ - Main agent reads `npm run state:get` and remains orchestrator.
131
+ - Subagents read `npm run state:get -- --json dispatch`, work within `allowedFiles`, satisfy `acceptance`, then append handoff.
132
+ - Todo status is updated by the orchestrator after reading handoff; subagents do not mark their own todo done.
133
+ - Do not put `stageExit`, `dispatchableRoles`, full todo pools, handoff history, or future-stage plans in this file.
134
+ - Do not infer workflow progress from file presence alone; use `npm run state:get` for workflow state.
135
+
136
+ ## Refresh Policy
137
+
138
+ Refresh this file during wrapup when the project shape changes. Update:
139
+
140
+ - current snapshot;
141
+ - runtime entry status;
142
+ - key artifact existence;
143
+ - directory map changes;
144
+ - high-impact known gaps.
145
+
146
+ Do not copy dynamic workflow history into this file. Detailed process rules belong in `docs/harness/` and `skills/_shared/scripts/pipeline/`.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes