superlab 0.1.7 → 0.1.9

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 (71) hide show
  1. package/README.md +65 -17
  2. package/README.zh-CN.md +64 -15
  3. package/bin/superlab.cjs +232 -1
  4. package/lib/context.cjs +337 -0
  5. package/lib/i18n.cjs +693 -41
  6. package/lib/install.cjs +253 -53
  7. package/package-assets/claude/commands/lab/framing.md +11 -0
  8. package/package-assets/claude/commands/lab/idea.md +2 -1
  9. package/package-assets/claude/commands/lab/iterate.md +2 -1
  10. package/package-assets/claude/commands/lab/report.md +2 -1
  11. package/package-assets/claude/commands/lab/review.md +2 -1
  12. package/package-assets/claude/commands/lab/run.md +2 -1
  13. package/package-assets/claude/commands/lab/spec.md +2 -1
  14. package/package-assets/claude/commands/lab/write.md +2 -1
  15. package/package-assets/claude/commands/lab.md +48 -0
  16. package/package-assets/codex/prompts/lab-framing.md +9 -0
  17. package/package-assets/codex/prompts/lab-idea.md +2 -1
  18. package/package-assets/codex/prompts/lab-iterate.md +2 -1
  19. package/package-assets/codex/prompts/lab-report.md +2 -1
  20. package/package-assets/codex/prompts/lab-review.md +2 -1
  21. package/package-assets/codex/prompts/lab-run.md +2 -1
  22. package/package-assets/codex/prompts/lab-spec.md +2 -1
  23. package/package-assets/codex/prompts/lab-write.md +2 -1
  24. package/package-assets/codex/prompts/lab.md +46 -0
  25. package/package-assets/shared/{templates → lab/.managed/templates}/design.md +3 -3
  26. package/package-assets/shared/lab/.managed/templates/framing.md +68 -0
  27. package/package-assets/shared/{templates → lab/.managed/templates}/paper-plan.md +1 -0
  28. package/package-assets/shared/{templates → lab/.managed/templates}/proposal.md +1 -1
  29. package/package-assets/shared/{templates → lab/.managed/templates}/spec.md +2 -2
  30. package/package-assets/shared/{templates → lab/.managed/templates}/tasks.md +2 -2
  31. package/package-assets/shared/{templates → lab/.managed/templates}/write-iteration.md +1 -0
  32. package/package-assets/shared/lab/changes/README.md +10 -0
  33. package/package-assets/shared/lab/config/workflow.json +6 -0
  34. package/package-assets/shared/lab/context/next-action.md +19 -0
  35. package/package-assets/shared/lab/context/session-brief.md +30 -0
  36. package/package-assets/shared/lab/context/summary.md +21 -0
  37. package/package-assets/shared/lab/context/terminology-lock.md +28 -0
  38. package/package-assets/shared/lab/system/core.md +41 -0
  39. package/package-assets/shared/skills/lab/SKILL.md +54 -37
  40. package/package-assets/shared/skills/lab/references/paper-writing/abstract.md +2 -17
  41. package/package-assets/shared/skills/lab/references/paper-writing/introduction.md +3 -63
  42. package/package-assets/shared/skills/lab/references/paper-writing/method.md +4 -34
  43. package/package-assets/shared/skills/lab/references/workflow.md +4 -4
  44. package/package-assets/shared/skills/lab/stages/framing.md +72 -0
  45. package/package-assets/shared/skills/lab/stages/idea.md +5 -5
  46. package/package-assets/shared/skills/lab/stages/iterate.md +8 -8
  47. package/package-assets/shared/skills/lab/stages/report.md +7 -6
  48. package/package-assets/shared/skills/lab/stages/review.md +6 -5
  49. package/package-assets/shared/skills/lab/stages/run.md +4 -4
  50. package/package-assets/shared/skills/lab/stages/spec.md +11 -11
  51. package/package-assets/shared/skills/lab/stages/write.md +14 -10
  52. package/package.json +1 -1
  53. package/package-assets/shared/changes/README.md +0 -10
  54. package/package-assets/shared/config/workflow.json +0 -5
  55. package/package-assets/shared/examples/minimal-uplift-workflow.md +0 -73
  56. /package/package-assets/shared/{scripts → lab/.managed/scripts}/eval_report.py +0 -0
  57. /package/package-assets/shared/{scripts → lab/.managed/scripts}/register_run.py +0 -0
  58. /package/package-assets/shared/{scripts → lab/.managed/scripts}/summarize_iterations.py +0 -0
  59. /package/package-assets/shared/{scripts → lab/.managed/scripts}/validate_results.py +0 -0
  60. /package/package-assets/shared/{templates → lab/.managed/templates}/final-report.md +0 -0
  61. /package/package-assets/shared/{templates → lab/.managed/templates}/idea.md +0 -0
  62. /package/package-assets/shared/{templates → lab/.managed/templates}/iteration-report.md +0 -0
  63. /package/package-assets/shared/{templates → lab/.managed/templates}/paper-section.md +0 -0
  64. /package/package-assets/shared/{templates → lab/.managed/templates}/paper-section.tex +0 -0
  65. /package/package-assets/shared/{templates → lab/.managed/templates}/paper.tex +0 -0
  66. /package/package-assets/shared/{templates → lab/.managed/templates}/review-checklist.md +0 -0
  67. /package/package-assets/shared/{context → lab/context}/decisions.md +0 -0
  68. /package/package-assets/shared/{context → lab/context}/evidence-index.md +0 -0
  69. /package/package-assets/shared/{context → lab/context}/mission.md +0 -0
  70. /package/package-assets/shared/{context → lab/context}/open-questions.md +0 -0
  71. /package/package-assets/shared/{context → lab/context}/state.md +0 -0
package/lib/install.cjs CHANGED
@@ -5,6 +5,9 @@ const { getLocalizedContent } = require("./i18n.cjs");
5
5
 
6
6
  const REPO_ROOT = path.resolve(__dirname, "..");
7
7
  const PACKAGE_VERSION = require(path.join(REPO_ROOT, "package.json")).version;
8
+ const LAYOUT_VERSION = 1;
9
+ const SUPERLAB_START = "<!-- superlab:start -->";
10
+ const SUPERLAB_END = "<!-- superlab:end -->";
8
11
 
9
12
  const ASSET_GROUPS = {
10
13
  codex: [
@@ -19,41 +22,28 @@ const ASSET_GROUPS = {
19
22
  ],
20
23
  claude: [
21
24
  {
22
- from: path.join(REPO_ROOT, "package-assets", "claude", "commands", "lab"),
23
- to: path.join(".claude", "commands", "lab"),
25
+ from: path.join(REPO_ROOT, "package-assets", "claude", "commands"),
26
+ to: path.join(".claude", "commands"),
24
27
  },
25
28
  {
26
29
  from: path.join(REPO_ROOT, "package-assets", "shared", "skills", "lab"),
27
30
  to: path.join(".claude", "skills", "lab"),
28
31
  },
29
32
  ],
30
- shared: [
31
- {
32
- from: path.join(REPO_ROOT, "package-assets", "shared", "templates"),
33
- to: path.join(".superlab", "templates"),
34
- },
35
- {
36
- from: path.join(REPO_ROOT, "package-assets", "shared", "config"),
37
- to: path.join(".superlab", "config"),
38
- },
39
- {
40
- from: path.join(REPO_ROOT, "package-assets", "shared", "changes"),
41
- to: path.join(".superlab", "changes"),
42
- },
43
- {
44
- from: path.join(REPO_ROOT, "package-assets", "shared", "scripts"),
45
- to: path.join(".superlab", "scripts"),
46
- },
47
- {
48
- from: path.join(REPO_ROOT, "package-assets", "shared", "examples"),
49
- to: path.join(".superlab", "examples"),
50
- },
51
- {
52
- from: path.join(REPO_ROOT, "package-assets", "shared", "context"),
53
- to: path.join(".superlab", "context"),
54
- },
55
- ],
56
33
  };
34
+ const LAB_SOURCE_ROOT = path.join(REPO_ROOT, "package-assets", "shared", "lab");
35
+ const PROJECT_OWNED_LOCALIZED_PATHS = [
36
+ path.join(".lab", "config", "workflow.json"),
37
+ path.join(".lab", "context", "mission.md"),
38
+ path.join(".lab", "context", "state.md"),
39
+ path.join(".lab", "context", "decisions.md"),
40
+ path.join(".lab", "context", "evidence-index.md"),
41
+ path.join(".lab", "context", "open-questions.md"),
42
+ path.join(".lab", "context", "terminology-lock.md"),
43
+ path.join(".lab", "context", "summary.md"),
44
+ path.join(".lab", "context", "next-action.md"),
45
+ path.join(".lab", "context", "session-brief.md"),
46
+ ];
57
47
 
58
48
  function listFiles(dir) {
59
49
  const entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -92,8 +82,90 @@ function copyDirectory(sourceDir, targetDir, force) {
92
82
  fs.cpSync(sourceDir, targetDir, { recursive: true, force });
93
83
  }
94
84
 
85
+ function copyMissingTree(sourceDir, targetDir) {
86
+ if (!fs.existsSync(sourceDir)) {
87
+ return;
88
+ }
89
+ fs.mkdirSync(targetDir, { recursive: true });
90
+ for (const entry of fs.readdirSync(sourceDir, { withFileTypes: true })) {
91
+ const sourcePath = path.join(sourceDir, entry.name);
92
+ const targetPath = path.join(targetDir, entry.name);
93
+ if (entry.isDirectory()) {
94
+ copyMissingTree(sourcePath, targetPath);
95
+ continue;
96
+ }
97
+ if (!fs.existsSync(targetPath)) {
98
+ fs.copyFileSync(sourcePath, targetPath);
99
+ }
100
+ }
101
+ }
102
+
103
+ function mergeJsonFile(defaultPath, targetPath) {
104
+ const defaults = JSON.parse(fs.readFileSync(defaultPath, "utf8"));
105
+ let existing = {};
106
+ if (fs.existsSync(targetPath)) {
107
+ existing = JSON.parse(fs.readFileSync(targetPath, "utf8"));
108
+ }
109
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });
110
+ fs.writeFileSync(targetPath, JSON.stringify({ ...defaults, ...existing }, null, 2) + "\n");
111
+ }
112
+
113
+ function installLabAssets(targetDir, force) {
114
+ copyMissingTree(path.join(LAB_SOURCE_ROOT, "system"), path.join(targetDir, ".lab", "system"));
115
+ copyMissingTree(path.join(LAB_SOURCE_ROOT, "context"), path.join(targetDir, ".lab", "context"));
116
+ copyMissingTree(path.join(LAB_SOURCE_ROOT, "changes"), path.join(targetDir, ".lab", "changes"));
117
+ mergeJsonFile(
118
+ path.join(LAB_SOURCE_ROOT, "config", "workflow.json"),
119
+ path.join(targetDir, ".lab", "config", "workflow.json")
120
+ );
121
+ copyDirectory(
122
+ path.join(LAB_SOURCE_ROOT, ".managed"),
123
+ path.join(targetDir, ".lab", ".managed"),
124
+ force
125
+ );
126
+ }
127
+
128
+ function coreTemplateContent(lang) {
129
+ return (
130
+ getLocalizedContent(path.join(".lab", "system", "core.md"), lang) ||
131
+ fs.readFileSync(path.join(LAB_SOURCE_ROOT, "system", "core.md"), "utf8")
132
+ );
133
+ }
134
+
135
+ function writeManagedCoreFile(targetDir, lang, { force = false } = {}) {
136
+ const filePath = path.join(targetDir, ".lab", "system", "core.md");
137
+ const managedBody = coreTemplateContent(lang);
138
+
139
+ ensureParentDir(filePath);
140
+ if (!fs.existsSync(filePath)) {
141
+ fs.writeFileSync(filePath, managedShimBlock(managedBody));
142
+ return;
143
+ }
144
+
145
+ const existing = fs.readFileSync(filePath, "utf8");
146
+ const start = existing.indexOf(SUPERLAB_START);
147
+ const end = existing.indexOf(SUPERLAB_END);
148
+ if (start >= 0 && end >= 0 && end >= start) {
149
+ upsertManagedBlock(filePath, managedBody, { force });
150
+ return;
151
+ }
152
+
153
+ const canonicalVariants = ["en", "zh"].map((candidateLang) => coreTemplateContent(candidateLang).trim());
154
+ if (!existing.trim() || canonicalVariants.includes(existing.trim())) {
155
+ fs.writeFileSync(filePath, managedShimBlock(managedBody));
156
+ return;
157
+ }
158
+
159
+ if (force) {
160
+ fs.writeFileSync(filePath, `${existing.trimEnd()}\n\n${managedShimBlock(managedBody)}`);
161
+ return;
162
+ }
163
+
164
+ throw new Error(`${filePath} already exists. Re-run with --force to overwrite.`);
165
+ }
166
+
95
167
  function chmodScripts(targetDir) {
96
- const scriptsDir = path.join(targetDir, ".superlab", "scripts");
168
+ const scriptsDir = path.join(targetDir, ".lab", ".managed", "scripts");
97
169
  if (!fs.existsSync(scriptsDir)) {
98
170
  return;
99
171
  }
@@ -116,7 +188,7 @@ function registryFilePath({ env = process.env } = {}) {
116
188
  }
117
189
 
118
190
  function installMetadataPath(targetDir) {
119
- return path.join(targetDir, ".superlab", "install.json");
191
+ return path.join(targetDir, ".lab", ".managed", "install.json");
120
192
  }
121
193
 
122
194
  function ensureParentDir(filePath) {
@@ -137,6 +209,93 @@ function readProjectInstallMetadata(targetDir) {
137
209
  return JSON.parse(fs.readFileSync(filePath, "utf8"));
138
210
  }
139
211
 
212
+ function managedShimBlock(content) {
213
+ return `${SUPERLAB_START}\n${content.trimEnd()}\n${SUPERLAB_END}\n`;
214
+ }
215
+
216
+ function upsertManagedBlock(filePath, body, { force = false } = {}) {
217
+ const block = managedShimBlock(body);
218
+ if (!fs.existsSync(filePath)) {
219
+ fs.writeFileSync(filePath, block);
220
+ return;
221
+ }
222
+
223
+ const existing = fs.readFileSync(filePath, "utf8");
224
+ const start = existing.indexOf(SUPERLAB_START);
225
+ const end = existing.indexOf(SUPERLAB_END);
226
+
227
+ if (start >= 0 && end >= 0 && end >= start) {
228
+ const updated =
229
+ existing.slice(0, start) +
230
+ block +
231
+ existing.slice(end + SUPERLAB_END.length).replace(/^\n/, "");
232
+ fs.writeFileSync(filePath, updated);
233
+ return;
234
+ }
235
+
236
+ if (force) {
237
+ fs.writeFileSync(filePath, `${existing.trimEnd()}\n\n${block}`);
238
+ return;
239
+ }
240
+
241
+ throw new Error(`${filePath} already exists. Re-run with --force to overwrite.`);
242
+ }
243
+
244
+ function agentsShim(lang) {
245
+ if (lang === "zh") {
246
+ return `# Project Agent Notes
247
+
248
+ 本仓库使用项目级 \`.lab/\` 研究工作流。
249
+
250
+ 如果任务属于 research、experiment、report 或 paper-writing:
251
+ 1. 先读 \`.lab/system/core.md\`
252
+ 2. 再读 \`.lab/context/session-brief.md\`
253
+
254
+ 不要静默覆盖 \`.lab/context/*\`。
255
+ 非研究类工程任务不要强行进入 \`/lab:*\`。`;
256
+ }
257
+
258
+ return `# Project Agent Notes
259
+
260
+ This repository uses a project-level \`.lab/\` research workflow.
261
+
262
+ For research, experiment, reporting, or paper-writing tasks:
263
+ 1. Read \`.lab/system/core.md\`
264
+ 2. Then read \`.lab/context/session-brief.md\`
265
+
266
+ Do not silently overwrite \`.lab/context/*\`.
267
+ For non-research engineering tasks, do not force \`/lab:*\`.`;
268
+ }
269
+
270
+ function claudeShim(lang) {
271
+ if (lang === "zh") {
272
+ return `# Claude Project Notes
273
+
274
+ 本仓库使用项目级 \`.lab/\` 研究工作流。
275
+
276
+ @.lab/system/core.md
277
+ @.lab/context/session-brief.md
278
+
279
+ 不要静默覆盖 \`.lab/context/*\`。
280
+ 非研究类工程任务不要强行进入 \`/lab:*\`。`;
281
+ }
282
+
283
+ return `# Claude Project Notes
284
+
285
+ This repository uses a project-level \`.lab/\` research workflow.
286
+
287
+ @.lab/system/core.md
288
+ @.lab/context/session-brief.md
289
+
290
+ Do not silently overwrite \`.lab/context/*\`.
291
+ For non-research engineering tasks, do not force \`/lab:*\`.`;
292
+ }
293
+
294
+ function writePlatformShims(targetDir, lang, force) {
295
+ upsertManagedBlock(path.join(targetDir, "AGENTS.md"), agentsShim(lang), { force });
296
+ upsertManagedBlock(path.join(targetDir, "CLAUDE.md"), claudeShim(lang), { force });
297
+ }
298
+
140
299
  function detectLegacyPlatform(targetDir) {
141
300
  const hasCodex =
142
301
  fs.existsSync(path.join(targetDir, ".codex", "prompts")) ||
@@ -162,8 +321,14 @@ function looksChinese(text) {
162
321
  }
163
322
 
164
323
  function detectLegacyLanguage(targetDir) {
165
- const workflowConfigPath = path.join(targetDir, ".superlab", "config", "workflow.json");
166
- if (fs.existsSync(workflowConfigPath)) {
324
+ const workflowConfigPaths = [
325
+ path.join(targetDir, ".lab", "config", "workflow.json"),
326
+ path.join(targetDir, ".superlab", "config", "workflow.json"),
327
+ ];
328
+ for (const workflowConfigPath of workflowConfigPaths) {
329
+ if (!fs.existsSync(workflowConfigPath)) {
330
+ continue;
331
+ }
167
332
  try {
168
333
  const config = JSON.parse(fs.readFileSync(workflowConfigPath, "utf8"));
169
334
  if (config.workflow_language === "zh" || config.workflow_language === "en") {
@@ -177,6 +342,7 @@ function detectLegacyLanguage(targetDir) {
177
342
  const probeFiles = [
178
343
  path.join(targetDir, ".codex", "prompts", "lab-idea.md"),
179
344
  path.join(targetDir, ".claude", "commands", "lab", "idea.md"),
345
+ path.join(targetDir, ".lab", ".managed", "templates", "idea.md"),
180
346
  path.join(targetDir, ".superlab", "templates", "idea.md"),
181
347
  ];
182
348
 
@@ -203,6 +369,7 @@ function detectLegacyInstallMetadata(targetDir) {
203
369
  lang: detectLegacyLanguage(targetDir),
204
370
  package_version: "legacy",
205
371
  updated_at: null,
372
+ layout_version: 0,
206
373
  legacy: true,
207
374
  };
208
375
  }
@@ -266,20 +433,24 @@ function detectLanguage({ explicitLang, env = process.env } = {}) {
266
433
  return locale.includes("zh") ? "zh" : "en";
267
434
  }
268
435
 
269
- function localizeInstalledAssets(targetDir, lang) {
436
+ function localizeInstalledAssets(targetDir, lang, { newlyCreatedProjectOwnedPaths = new Set() } = {}) {
270
437
  if (lang !== "zh") {
271
438
  return;
272
439
  }
273
440
 
274
441
  const relativePaths = [
442
+ path.join(".codex", "prompts", "lab.md"),
275
443
  path.join(".codex", "prompts", "lab-idea.md"),
444
+ path.join(".codex", "prompts", "lab-framing.md"),
276
445
  path.join(".codex", "prompts", "lab-spec.md"),
277
446
  path.join(".codex", "prompts", "lab-run.md"),
278
447
  path.join(".codex", "prompts", "lab-iterate.md"),
279
448
  path.join(".codex", "prompts", "lab-review.md"),
280
449
  path.join(".codex", "prompts", "lab-report.md"),
281
450
  path.join(".codex", "prompts", "lab-write.md"),
451
+ path.join(".claude", "commands", "lab.md"),
282
452
  path.join(".claude", "commands", "lab", "idea.md"),
453
+ path.join(".claude", "commands", "lab", "framing.md"),
283
454
  path.join(".claude", "commands", "lab", "spec.md"),
284
455
  path.join(".claude", "commands", "lab", "run.md"),
285
456
  path.join(".claude", "commands", "lab", "iterate.md"),
@@ -288,27 +459,36 @@ function localizeInstalledAssets(targetDir, lang) {
288
459
  path.join(".claude", "commands", "lab", "write.md"),
289
460
  path.join(".codex", "skills", "lab", "SKILL.md"),
290
461
  path.join(".codex", "skills", "lab", "stages", "idea.md"),
462
+ path.join(".codex", "skills", "lab", "stages", "framing.md"),
463
+ path.join(".codex", "skills", "lab", "stages", "spec.md"),
464
+ path.join(".codex", "skills", "lab", "stages", "run.md"),
465
+ path.join(".codex", "skills", "lab", "stages", "iterate.md"),
466
+ path.join(".codex", "skills", "lab", "stages", "review.md"),
467
+ path.join(".codex", "skills", "lab", "stages", "report.md"),
291
468
  path.join(".codex", "skills", "lab", "stages", "write.md"),
469
+ path.join(".codex", "skills", "lab", "references", "workflow.md"),
292
470
  path.join(".claude", "skills", "lab", "SKILL.md"),
293
471
  path.join(".claude", "skills", "lab", "stages", "idea.md"),
472
+ path.join(".claude", "skills", "lab", "stages", "framing.md"),
473
+ path.join(".claude", "skills", "lab", "stages", "spec.md"),
474
+ path.join(".claude", "skills", "lab", "stages", "run.md"),
475
+ path.join(".claude", "skills", "lab", "stages", "iterate.md"),
476
+ path.join(".claude", "skills", "lab", "stages", "review.md"),
477
+ path.join(".claude", "skills", "lab", "stages", "report.md"),
294
478
  path.join(".claude", "skills", "lab", "stages", "write.md"),
295
- path.join(".superlab", "templates", "idea.md"),
296
- path.join(".superlab", "templates", "proposal.md"),
297
- path.join(".superlab", "templates", "design.md"),
298
- path.join(".superlab", "templates", "spec.md"),
299
- path.join(".superlab", "templates", "tasks.md"),
300
- path.join(".superlab", "templates", "iteration-report.md"),
301
- path.join(".superlab", "templates", "review-checklist.md"),
302
- path.join(".superlab", "templates", "final-report.md"),
303
- path.join(".superlab", "templates", "paper-plan.md"),
304
- path.join(".superlab", "templates", "paper-section.md"),
305
- path.join(".superlab", "templates", "write-iteration.md"),
306
- path.join(".superlab", "config", "workflow.json"),
307
- path.join(".superlab", "context", "mission.md"),
308
- path.join(".superlab", "context", "state.md"),
309
- path.join(".superlab", "context", "decisions.md"),
310
- path.join(".superlab", "context", "evidence-index.md"),
311
- path.join(".superlab", "context", "open-questions.md"),
479
+ path.join(".claude", "skills", "lab", "references", "workflow.md"),
480
+ path.join(".lab", ".managed", "templates", "idea.md"),
481
+ path.join(".lab", ".managed", "templates", "framing.md"),
482
+ path.join(".lab", ".managed", "templates", "proposal.md"),
483
+ path.join(".lab", ".managed", "templates", "design.md"),
484
+ path.join(".lab", ".managed", "templates", "spec.md"),
485
+ path.join(".lab", ".managed", "templates", "tasks.md"),
486
+ path.join(".lab", ".managed", "templates", "iteration-report.md"),
487
+ path.join(".lab", ".managed", "templates", "review-checklist.md"),
488
+ path.join(".lab", ".managed", "templates", "final-report.md"),
489
+ path.join(".lab", ".managed", "templates", "paper-plan.md"),
490
+ path.join(".lab", ".managed", "templates", "paper-section.md"),
491
+ path.join(".lab", ".managed", "templates", "write-iteration.md"),
312
492
  ];
313
493
 
314
494
  for (const relativePath of relativePaths) {
@@ -321,6 +501,20 @@ function localizeInstalledAssets(targetDir, lang) {
321
501
  fs.writeFileSync(absolutePath, localized);
322
502
  }
323
503
  }
504
+
505
+ for (const relativePath of PROJECT_OWNED_LOCALIZED_PATHS) {
506
+ if (!newlyCreatedProjectOwnedPaths.has(relativePath)) {
507
+ continue;
508
+ }
509
+ const localized = getLocalizedContent(relativePath, lang);
510
+ if (!localized) {
511
+ continue;
512
+ }
513
+ const absolutePath = path.join(targetDir, relativePath);
514
+ if (fs.existsSync(absolutePath)) {
515
+ fs.writeFileSync(absolutePath, localized);
516
+ }
517
+ }
324
518
  }
325
519
 
326
520
  function installSuperlab({
@@ -338,19 +532,25 @@ function installSuperlab({
338
532
  if (platform === "claude" || platform === "both") {
339
533
  groups.push(...ASSET_GROUPS.claude);
340
534
  }
341
- groups.push(...ASSET_GROUPS.shared);
342
535
 
536
+ const resolvedLang = detectLanguage({ explicitLang: lang, env });
537
+ const newlyCreatedProjectOwnedPaths = new Set(
538
+ PROJECT_OWNED_LOCALIZED_PATHS.filter((relativePath) => !fs.existsSync(path.join(targetDir, relativePath)))
539
+ );
343
540
  for (const asset of groups) {
344
541
  copyDirectory(asset.from, path.join(targetDir, asset.to), force);
345
542
  }
346
- const resolvedLang = detectLanguage({ explicitLang: lang, env });
347
- localizeInstalledAssets(targetDir, resolvedLang);
543
+ installLabAssets(targetDir, force);
544
+ writePlatformShims(targetDir, resolvedLang, force);
545
+ writeManagedCoreFile(targetDir, resolvedLang, { force });
546
+ localizeInstalledAssets(targetDir, resolvedLang, { newlyCreatedProjectOwnedPaths });
348
547
  chmodScripts(targetDir);
349
548
  const metadata = {
350
549
  target_dir: path.resolve(targetDir),
351
550
  platform,
352
551
  lang: resolvedLang,
353
552
  package_version: PACKAGE_VERSION,
553
+ layout_version: LAYOUT_VERSION,
354
554
  updated_at: new Date().toISOString(),
355
555
  };
356
556
  writeProjectInstallMetadata(targetDir, metadata);
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: "LAB: Framing"
3
+ description: Lock paper-facing naming, title, and contribution framing before drafting
4
+ category: Workflow
5
+ tags: [workflow, research, framing]
6
+ ---
7
+
8
+ Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
+
10
+ Execute the requested `/lab:framing` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:framing` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, idea]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:idea` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
10
+ Execute the requested `/lab:idea` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:idea` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, iterate]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:iterate` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
10
+ Execute the requested `/lab:iterate` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:iterate` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, report]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:report` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
10
+ Execute the requested `/lab:report` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:report` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, review]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:review` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
10
+ Execute the requested `/lab:review` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:review` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, run]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:run` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
10
+ Execute the requested `/lab:run` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:run` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, spec]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:spec` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
10
+ Execute the requested `/lab:spec` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:spec` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -7,4 +7,5 @@ tags: [workflow, research, writing]
7
7
 
8
8
  Use the installed `lab` skill at `.claude/skills/lab/SKILL.md`.
9
9
 
10
- This command runs the `/lab:write` stage. It must read the matching section reference from `.claude/skills/lab/references/paper-writing/`, plus `paper-review.md` and `does-my-writing-flow-source.md`, build a mini-outline, and then revise only one section.
10
+ Execute the requested `/lab:write` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
11
+ This command runs the `/lab:write` stage. It requires an approved framing artifact from `/lab:framing`, must read the matching section reference from `.claude/skills/lab/references/paper-writing/`, plus `paper-review.md` and `does-my-writing-flow-source.md`, build a mini-outline, and then revise only one section.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: "LAB"
3
+ description: Overview of the /lab research workflow and stage selection
4
+ category: Workflow
5
+ tags: [workflow, research, overview]
6
+ ---
7
+
8
+ # `/lab` for Claude
9
+
10
+ `/lab` is a strict research workflow command family. Use the same repository artifacts and stage boundaries every time.
11
+
12
+ ## Subcommands
13
+
14
+ - `/lab:idea`
15
+ Research the idea, define the problem and failure case, classify the contribution and breakthrough level, compare against existing methods, end with three meaningful points, and keep an explicit approval gate before any implementation.
16
+
17
+ - `/lab:framing`
18
+ Lock paper-facing method name, module names, paper title, and contribution bullets by auditing current-field and adjacent-field terminology, then keep an approval gate before any section drafting.
19
+
20
+ - `/lab:spec`
21
+ Convert the approved idea into one lab change directory under `.lab/changes/<change-id>/`, then draft `proposal`, `design`, `spec`, and `tasks` inside that directory.
22
+
23
+ - `/lab:run`
24
+ Execute the smallest useful validation run, register it, and produce the first normalized evaluation summary.
25
+
26
+ - `/lab:iterate`
27
+ Run bounded Ralph Wiggum style experiment loops with a frozen mission, explicit thresholds, deterministic verification commands, `completion_promise`, and per-round reports.
28
+
29
+ - `/lab:review`
30
+ Audit documents or results in reviewer mode. Start with a short summary, then output findings, fatal flaws, fix priority, and residual risks.
31
+
32
+ - `/lab:report`
33
+ Generate the final research report from accumulated runs and iteration artifacts.
34
+
35
+ - `/lab:write`
36
+ Turn stable report artifacts into paper sections through small, evidence-bound writing rounds using the vendored paper-writing references under the installed `lab` skill.
37
+
38
+ ## Dispatch Rules
39
+
40
+ - Always use `skills/lab/SKILL.md` as the workflow contract.
41
+ - When the user explicitly invokes `/lab:<stage>`, execute that stage now against the provided argument instead of only recommending another `/lab` stage.
42
+ - Start by giving the user a concise summary, then decide whether to write artifacts, then report the output path and next step.
43
+ - When ambiguity matters, ask one clarifying question at a time; when multiple paths are viable, present 2-3 approaches before converging.
44
+ - `/lab:spec` is not complete until the approved change is frozen under `.lab/changes/<change-id>/`.
45
+ - Never skip directly from `/lab:idea` to code.
46
+ - `/lab:iterate` requires a normalized summary from `scripts/eval_report.py`.
47
+ - `/lab:write` requires an approved framing artifact from `/lab:framing`.
48
+ - `/lab:write` requires stable report artifacts, a mini-outline, the active section guide, `paper-review.md`, and `does-my-writing-flow-source.md`, and should only change one section per round.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Lock paper-facing naming, title, and contribution framing before drafting
3
+ argument-hint: naming, title, or contribution framing target
4
+ ---
5
+
6
+ Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
+
8
+ Execute the requested `/lab:framing` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:framing` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: idea or research problem
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:idea` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
8
+ Execute the requested `/lab:idea` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:idea` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: iteration mission
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:iterate` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
8
+ Execute the requested `/lab:iterate` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:iterate` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: report context
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:report` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
8
+ Execute the requested `/lab:report` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:report` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: artifact or result to review
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:review` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
8
+ Execute the requested `/lab:review` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:review` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: run context
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:run` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
8
+ Execute the requested `/lab:run` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:run` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: approved idea context
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:spec` stage. Follow the installed skill, stage guide, templates, and scripts under `.superlab/`.
8
+ Execute the requested `/lab:spec` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:spec` stage. Follow the installed skill, stage guide, and the project assets under `.lab/`.
@@ -5,4 +5,5 @@ argument-hint: section or writing target
5
5
 
6
6
  Use the installed `lab` skill at `.codex/skills/lab/SKILL.md`.
7
7
 
8
- This command runs the `/lab:write` stage. It must read the matching section reference from `.codex/skills/lab/references/paper-writing/`, plus `paper-review.md` and `does-my-writing-flow-source.md`, build a mini-outline, and then revise only one section.
8
+ Execute the requested `/lab:write` stage against the user's argument now. Do not only recommend another lab stage. If a blocking prerequisite is missing, say exactly what is missing and ask at most one clarifying question.
9
+ This command runs the `/lab:write` stage. It requires an approved framing artifact from `/lab:framing`, must read the matching section reference from `.codex/skills/lab/references/paper-writing/`, plus `paper-review.md` and `does-my-writing-flow-source.md`, build a mini-outline, and then revise only one section.