@warpgogol/forge 9.6.1 → 9.6.3

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 (74) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/CONTRIBUTING.md +19 -25
  3. package/README.md +42 -18
  4. package/README.uk.md +60 -36
  5. package/dist/os/core/core.module.d.ts.map +1 -1
  6. package/dist/os/core/core.module.js +58 -5
  7. package/dist/os/core/core.module.js.map +1 -1
  8. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  9. package/dist/os/core/handlers/package-health.js +95 -8
  10. package/dist/os/core/handlers/package-health.js.map +1 -1
  11. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  12. package/dist/os/flow/handlers/flow-cut.js +27 -6
  13. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  14. package/dist/src/migration-adapters/ignored-files.d.ts +14 -0
  15. package/dist/src/migration-adapters/ignored-files.d.ts.map +1 -1
  16. package/dist/src/migration-adapters/ignored-files.js +62 -0
  17. package/dist/src/migration-adapters/ignored-files.js.map +1 -1
  18. package/dist/src/migration-adapters/index.d.ts +3 -3
  19. package/dist/src/migration-adapters/index.d.ts.map +1 -1
  20. package/dist/src/migration-adapters/index.js +2 -2
  21. package/dist/src/migration-adapters/index.js.map +1 -1
  22. package/dist/src/migration-adapters/node-typescript-pnpm/index.d.ts.map +1 -1
  23. package/dist/src/migration-adapters/node-typescript-pnpm/index.js +9 -7
  24. package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
  25. package/dist/src/migration-adapters/phaser-pnpm/index.d.ts.map +1 -1
  26. package/dist/src/migration-adapters/phaser-pnpm/index.js +9 -7
  27. package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
  28. package/dist/src/migration-adapters/types.d.ts +19 -1
  29. package/dist/src/migration-adapters/types.d.ts.map +1 -1
  30. package/dist/src/migration-adapters/types.js +19 -0
  31. package/dist/src/migration-adapters/types.js.map +1 -1
  32. package/dist/src/onboarding/scaffold-project.d.ts.map +1 -1
  33. package/dist/src/onboarding/scaffold-project.js +21 -2
  34. package/dist/src/onboarding/scaffold-project.js.map +1 -1
  35. package/dist/src/validators/skill-doc-sync.d.ts +76 -0
  36. package/dist/src/validators/skill-doc-sync.d.ts.map +1 -0
  37. package/dist/src/validators/skill-doc-sync.js +333 -0
  38. package/dist/src/validators/skill-doc-sync.js.map +1 -0
  39. package/docs/concepts/governance-model.md +9 -1
  40. package/docs/concepts/verification-model.md +31 -0
  41. package/docs/concepts/why-forge.md +1 -1
  42. package/docs/evidence/release-9.6.2.md +31 -0
  43. package/docs/grants/devin-startups.md +25 -0
  44. package/docs/guides/existing-project.md +15 -3
  45. package/docs/guides/skills.md +27 -8
  46. package/docs/guides/upgrading.md +6 -2
  47. package/docs/guides/verification-and-evidence.md +45 -0
  48. package/docs/integrations/devin.md +63 -0
  49. package/docs/reference/cli.md +13 -2
  50. package/docs/reference/fleet-measurement.md +52 -0
  51. package/docs/reference/forge-yaml.md +1 -1
  52. package/docs/reference/programmatic-api.md +62 -33
  53. package/os/core/core.module.ts +70 -11
  54. package/os/core/handlers/package-health.test.ts +104 -23
  55. package/os/core/handlers/package-health.ts +133 -19
  56. package/os/flow/handlers/flow-cut.ts +27 -6
  57. package/os/flow/tests/flow-cut.rerun.test.ts +54 -4
  58. package/package.json +3 -2
  59. package/profiles/forge-shell.yaml +1 -0
  60. package/profiles/godot-game.yaml +1 -0
  61. package/profiles/phaser-game.yaml +1 -0
  62. package/profiles/site-workshop.yaml +1 -0
  63. package/profiles/system.yaml +1 -0
  64. package/profiles/typescript.yaml +1 -0
  65. package/skills/meta/forge-bootstrap/SKILL.md +18 -12
  66. package/src/migration-adapters/ignored-files.ts +64 -0
  67. package/src/migration-adapters/index.ts +19 -3
  68. package/src/migration-adapters/node-typescript-pnpm/index.ts +21 -5
  69. package/src/migration-adapters/phaser-pnpm/index.ts +21 -5
  70. package/src/migration-adapters/types.ts +36 -1
  71. package/src/onboarding/scaffold-project.ts +19 -2
  72. package/src/tests/migration-adapters.test.ts +73 -5
  73. package/src/tests/skill-doc-sync.test.ts +233 -0
  74. package/src/validators/skill-doc-sync.ts +449 -0
@@ -20,11 +20,20 @@ released with no mutation.</purpose>
20
20
  <item>RFC-1502: `git add -u` folds the release-prepare hook's tracked edits in; its untracked leftovers are listed as FLOW-CUT-14 then removed via io.rm (the integrate gate demands a clean tree, and `git clean -f` is blocked in agent sessions). Pre-tag verification extracts every named line at the release commit — a failure deletes worktree+branch before any ref or tag moves (FLOW-CUT-13).</item>
21
21
  </KEY_DECISIONS>
22
22
  <CHANGE_SUMMARY>
23
- <item>RFC-1502: review r1 — fix-cut rollback on FLOW-CUT-12/13, populated steps[], hook validation, GIT_* env scrub</item>
24
23
  <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
25
24
  <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
26
25
  <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
27
26
  <item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
27
+ <item>RFC-1546: flow.cut resume keys on nearest chore(release): subject, not tip only (F-0269)
28
+
29
+ A concurrent session landing on develop between a cut's own integrate and
30
+ its tail buried the release commit — every re-run fell through to the
31
+ fresh-cut path and refused FLOW-CUT-01 on already-bumped version files
32
+ (the documented recovery could never fire). planOrdinaryCut now back-walks
33
+ git log (-20) to the nearest chore(release): declaration; resume fires only
34
+ for an incomplete release (missing tags) or a tip-resident one — a buried
35
+ completed release never re-runs its main CAS. Regression tests cover the
36
+ buried-pending and buried-completed cases.</item>
28
37
  <history>RFC-1490, RFC-1491, RFC-1494, RFC-1502</history>
29
38
  </CHANGE_SUMMARY>
30
39
  */
@@ -271,9 +280,17 @@ async function planOrdinaryCut(
271
280
  // still runs but the tail completes exactly the subject's tags (and tags
272
281
  // the subject names cannot block as FLOW-CUT-06).
273
282
  const tipSubject = (await git(repoRoot, io, ["log", "-1", "--format=%s", ref])).stdout.trim();
283
+ // The tip may sit past the release commit: a concurrent session can land
284
+ // on develop between this cut's own integrate and its tail — the release
285
+ // declaration is still the nearest `chore(release):` subject behind tip.
286
+ const recentSubjects = (await git(repoRoot, io, ["log", "-20", "--format=%s", ref])).stdout
287
+ .split("\n")
288
+ .map((s) => s.trim());
289
+ const releaseIdx = recentSubjects.findIndex((s) => s.startsWith("chore(release): "));
290
+ const releaseSubject = releaseIdx >= 0 ? recentSubjects[releaseIdx]! : tipSubject;
274
291
  let resumeTags: string[] | null = null;
275
- if (tipSubject.startsWith("chore(release): ")) {
276
- const named = tipSubject
292
+ if (releaseSubject.startsWith("chore(release): ")) {
293
+ const named = releaseSubject
277
294
  .slice("chore(release): ".length)
278
295
  .split(",")
279
296
  .map((t) => t.trim())
@@ -297,14 +314,18 @@ async function planOrdinaryCut(
297
314
  const existence = await Promise.all(
298
315
  named.map(
299
316
  async (t) =>
300
- (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/tags/${t}`])).exitCode ===
301
- 0,
317
+ (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/tags/${t}`]))
318
+ .exitCode === 0,
302
319
  ),
303
320
  );
304
321
  if (named.length > 0 && existence.every((e) => e) && mainTip === ref) {
305
322
  return { kind: "completed", ref, tags: named, allLines: lines, mainTip };
306
323
  }
307
- if (named.length > 0) resumeTags = named;
324
+ // A buried release whose tags all exist already ran its tail — do not
325
+ // resume it to redo the main CAS. Only an incomplete release (missing
326
+ // tags) or the tip-resident one may resume.
327
+ const allNamedExist = named.length > 0 && existence.every((e) => e);
328
+ if (named.length > 0 && (releaseIdx === 0 || !allNamedExist)) resumeTags = named;
308
329
  }
309
330
  }
310
331
 
@@ -14,6 +14,16 @@ tagged tail completes exactly the named tags (fingerprints → main → tags).</
14
14
  <CHANGE_SUMMARY>
15
15
  <item>RFC-1490: step 4 — resume-path tests split out per the RFC file table</item>
16
16
  <item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
17
+ <item>RFC-1546: flow.cut resume keys on nearest chore(release): subject, not tip only (F-0269)
18
+
19
+ A concurrent session landing on develop between a cut's own integrate and
20
+ its tail buried the release commit — every re-run fell through to the
21
+ fresh-cut path and refused FLOW-CUT-01 on already-bumped version files
22
+ (the documented recovery could never fire). planOrdinaryCut now back-walks
23
+ git log (-20) to the nearest chore(release): declaration; resume fires only
24
+ for an incomplete release (missing tags) or a tip-resident one — a buried
25
+ completed release never re-runs its main CAS. Regression tests cover the
26
+ buried-pending and buried-completed cases.</item>
17
27
  </CHANGE_SUMMARY>
18
28
  */
19
29
 
@@ -42,10 +52,7 @@ async function adoptedRepo(): Promise<string> {
42
52
  const repo = await initRepo({ prefix: "flow-cut-rerun-" });
43
53
  dirs.push(repo);
44
54
  await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
45
- await writeFile(
46
- join(repo, "package.json"),
47
- '{\n "name": "fixture",\n "version": "0.1.0"\n}\n',
48
- );
55
+ await writeFile(join(repo, "package.json"), '{\n "name": "fixture",\n "version": "0.1.0"\n}\n');
49
56
  await gitExec(repo, ["add", "-A"]);
50
57
  await gitExec(repo, ["commit", "-m", "config"]);
51
58
  await gitExec(repo, ["switch", "-c", "develop"]);
@@ -92,4 +99,47 @@ describe("flow.cut — rerun/resume (AC-5)", () => {
92
99
  expect(await sha(repo, "v0.1.1^{}")).toBe(await sha(repo, "develop"));
93
100
  expect(await sha(repo, "main")).toBe(await sha(repo, "develop"));
94
101
  }, 30_000);
102
+
103
+ it("resumes the tail when a later commit buried the release commit on develop", async () => {
104
+ const repo = await adoptedRepo();
105
+ const first = await runOrdinaryCut(repo, ambientIo, { lines: [], dryRun: false });
106
+ expect(first.released).toBe(true);
107
+ // Break the tail as a refused fingerprints step would have, then let an
108
+ // unrelated session land on develop past the release commit.
109
+ await gitExec(repo, ["tag", "-d", "v0.1.1"]);
110
+ await gitExec(repo, ["update-ref", "refs/heads/main", "v0.1.0"]);
111
+ await writeFile(join(repo, "housekeeping.txt"), "retro");
112
+ await gitExec(repo, ["add", "housekeeping.txt"]);
113
+ const bury = await gitExec(repo, ["commit", "-m", "chore: session-end housekeeping"], {
114
+ FORGE_FLOW_OP: "install",
115
+ });
116
+ if (bury.exitCode !== 0) throw new Error(`bury commit failed: ${bury.stderr}`);
117
+
118
+ const data = await runOrdinaryCut(repo, ambientIo, { lines: [], dryRun: false });
119
+
120
+ expect(data.diagnostics).toEqual([]);
121
+ expect(data.released).toBe(true);
122
+ expect(data.resumed).toBe(true);
123
+ expect(await sha(repo, "v0.1.1^{}")).toBe(await sha(repo, "develop"));
124
+ expect(await sha(repo, "main")).toBe(await sha(repo, "develop"));
125
+ }, 30_000);
126
+
127
+ it("does not resume a buried release whose tags already exist", async () => {
128
+ const repo = await adoptedRepo();
129
+ const first = await runOrdinaryCut(repo, ambientIo, { lines: [], dryRun: false });
130
+ expect(first.released).toBe(true);
131
+ // Fully landed release, then a later commit — the buried declaration
132
+ // must not trigger a resume (main lagging develop is unrelated state).
133
+ await writeFile(join(repo, "later.txt"), "later");
134
+ await gitExec(repo, ["add", "later.txt"]);
135
+ const bury = await gitExec(repo, ["commit", "-m", "docs: later work"], {
136
+ FORGE_FLOW_OP: "install",
137
+ });
138
+ if (bury.exitCode !== 0) throw new Error(`bury commit failed: ${bury.stderr}`);
139
+
140
+ const data = await runOrdinaryCut(repo, ambientIo, { lines: [], dryRun: false });
141
+
142
+ // Falls through to the fresh-cut path — the prior release is complete.
143
+ expect(data.resumed).toBe(false);
144
+ }, 30_000);
95
145
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpgogol/forge",
3
- "version": "9.6.1",
3
+ "version": "9.6.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -358,7 +358,8 @@
358
358
  "test": "vitest run --passWithNoTests",
359
359
  "test:coverage": "vitest run --coverage --passWithNoTests",
360
360
  "test:watch": "vitest",
361
- "test:tarball:node24": "node test-fixtures/node24-consumer/smoke.mjs"
361
+ "test:tarball:node24": "node test-fixtures/node24-consumer/smoke.mjs",
362
+ "prepublishOnly": "pnpm run test:tarball:node24"
362
363
  },
363
364
  "dependencies": {
364
365
  "@aws-sdk/client-s3": "^3.1131.0",
@@ -599,6 +599,7 @@ workspace:
599
599
 
600
600
  - Engine: @warpgogol/forge
601
601
  - Stack profile: forge-shell
602
+ - Skills: <!-- forge:skills-count --><!-- /forge:skills-count --> (rendered by `forge skill.doc-sync`)
602
603
  - path: hooks/worktree-setup.sh
603
604
  content: |
604
605
  #!/bin/sh
@@ -1108,6 +1108,7 @@ workspace:
1108
1108
  - Engine: @warpgogol/werkstatt-engine
1109
1109
  - Plugin: @warpgogol/werkstatt-godot-game
1110
1110
  - Stack profile: godot-game
1111
+ - Skills: <!-- forge:skills-count --><!-- /forge:skills-count --> (rendered by `forge skill.doc-sync`)
1111
1112
  - path: hooks/worktree-setup.sh
1112
1113
  content: |
1113
1114
  #!/bin/sh
@@ -677,6 +677,7 @@ workspace:
677
677
  - Engine: @warpgogol/werkstatt-engine
678
678
  - Plugin: @warpgogol/werkstatt-phaser-game
679
679
  - Stack profile: phaser-game
680
+ - Skills: <!-- forge:skills-count --><!-- /forge:skills-count --> (rendered by `forge skill.doc-sync`)
680
681
  - path: hooks/worktree-setup.sh
681
682
  content: |
682
683
  #!/bin/sh
@@ -596,6 +596,7 @@ workspace:
596
596
  - Engine: @warpgogol/werkstatt-engine + @warpgogol/werkstatt-site
597
597
  - Governance: @warpgogol/forge
598
598
  - Stack profile: site-workshop
599
+ - Skills: <!-- forge:skills-count --><!-- /forge:skills-count --> (rendered by `forge skill.doc-sync`)
599
600
 
600
601
  ## Platform updates
601
602
 
@@ -627,6 +627,7 @@ workspace:
627
627
 
628
628
  - Engine: @warpgogol/forge
629
629
  - Stack profile: system
630
+ - Skills: <!-- forge:skills-count --><!-- /forge:skills-count --> (rendered by `forge skill.doc-sync`)
630
631
  - path: hooks/worktree-setup.sh
631
632
  content: |
632
633
  #!/bin/sh
@@ -540,6 +540,7 @@ workspace:
540
540
  - Engine: @warpgogol/forge
541
541
  - Plugin: @warpgogol/werkstatt-typescript
542
542
  - Stack profile: typescript
543
+ - Skills: <!-- forge:skills-count --><!-- /forge:skills-count --> (rendered by `forge skill.doc-sync`)
543
544
  - path: docs/correctness.yaml
544
545
  content: |
545
546
  # Product correctness manifest (RFC-1578, forge/correctness-manifest@1).
@@ -48,15 +48,15 @@ Interactive skill for configuring a freshly created forge project. Runs after `f
48
48
  - The skill never skips the auto-doctor step — it runs internally, not as a suggested operator action.
49
49
  - The skill never skips the silent auto-ADR step — the ADR is created, not suggested, for both greenfield and transplant.
50
50
  - The skill never copies the `.git` directory directly — git history transfer uses `git format-patch` + `git am` only.
51
- - The skill always transfers untracked and git-ignored files (e.g. `.env`, `.env.local`, secret config files, local certificates, input data, runtime state) from the source project — these are necessary for the project to work immediately after onboarding. The `migrate()` adapter copies all files on disk, not just git-tracked files. Only build artifacts (`node_modules/`, `dist/`, `.next/`, `.cache/`, `.turbo/`), `.git/`, and forge-protected files are excluded.
52
- - The skill always offers the operator an interactive selection of git-ignored files before copying them — the operator chooses which categories to transfer (config, data, runtime-state, cache, other). Config files (`.env`, secrets, certificates) are selected by default and the operator must explicitly opt out. The operator never loses files from their previous project without being asked.
51
+ - The skill transfers the operator's files needed for the project to work immediately after onboarding, but secrets are opt-in: git-ignored files and secret-looking files (`.env*`, `*.key`, `*.pem`, certificates) are NEVER copied by `migrate()` unless the operator explicitly approves them. The adapter enforces this in code — `migrate()` blocks every ignored or sensitive path not on the operator's `allowedPaths` list. Only build artifacts (`node_modules/`, `dist/`, `.next/`, `.cache/`, `.turbo/`), `.git/`, and forge-protected files are excluded unconditionally.
52
+ - The skill always offers the operator an interactive selection of git-ignored files BEFORE calling `migrate()` — discovery runs first, the operator's decision is passed into `migrate()` via its `allowedPaths` option. Config/secret files are NOT selected by default — the operator must explicitly opt in to transfer secrets. Other categories (data, runtime-state, cache, other) are selected by default and the operator may opt out. The operator never loses files from their previous project without being asked, and a refusal to copy secrets is honored by the adapter itself, not just by convention.
53
53
  - The skill never collects personal data as a separate interview before the first creation moment — personal data emerges naturally from the creative dialogue.
54
54
  - `operator-profile.md` is local and private — it is in `.gitignore` and is not committed to the repository. The operator can delete it at any time.
55
55
  - Gender is optional — the operator may decline to provide it. If declined, the skill uses gender-neutral addressing and notes the absence in `operator-profile.md`.
56
56
  - Form of address defaults to formal if the operator skips the question.
57
57
  - The skill never informs the operator about migration, version numbers, or upgrade mechanics — the silent version check in step 0 is invisible to the operator.
58
58
  - The skill never asks the operator for permission to migrate — if versions differ, migration runs automatically.
59
- - The skill always attempts to install RTK (Rust Token Killer) during onboarding — it is a mandatory setup step. If installation fails (network error, no Rust toolchain, permission denied), the skill continues with a note in the welcoming report. The operator can install RTK manually later.
59
+ - The skill offers RTK (Rust Token Killer) as an OPTIONAL optimization after the core setup is complete — it requires explicit operator consent because `rtk init` modifies global AI-assistant settings outside the project directory. If the operator declines, the skill skips RTK entirely without further prompting.
60
60
  - The skill never enables aggressive RTK modes (`--ultra-compact`, aggressive `read`) during onboarding — default settings only. The operator can enable aggressive modes later via `~/.config/rtk/config.toml`.
61
61
  - The skill always creates `.bak` backups of any config files modified by `rtk init` (e.g. `~/.claude/settings.json.bak`, `~/.windsurf/settings.json.bak`).
62
62
 
@@ -167,22 +167,22 @@ The transplant mode performs real code migration via a migration-adapter registr
167
167
  1. **Source directory** — ask for an absolute or relative path to the external codebase. Resolve and validate. The source must be outside the current forge project.
168
168
  2. **Detect adapter** — iterate the migration-adapter registry, call `detect()` on each adapter against the source directory. If multiple adapters match, ask the operator to choose. If none match, report "no migration adapter detected for this project type" and fall back to the greenfield interview for bindings (no code migration).
169
169
  3. **Analyze** — call `analyze()` on the matched adapter. Present: detected stack, proposed bindings (`typecheck`, `test`, `scopedBuild`), placement (`apps/<appName>/`), exclude patterns. The operator confirms or edits.
170
- 4. **Migrate** — call `migrate()` on the matched adapter. Show any file conflicts before copying. The operator confirms. The adapter copies ALL files from the source directory into `apps/<appName>/`, including untracked and git-ignored files (e.g. `.env`, `.env.local`, secret configuration, local certificates, input data, runtime state). Only `node_modules/`, `dist/`, `.next/`, `.cache/`, `.turbo/`, `.git/`, and other build artifacts are excluded. Forge-protected files (`forge.yaml`, `.agents/`, `docs/rfcs/`, `docs/adrs/`, `PREFERENCES.md`) are never overwritten. Untracked files are essential — the project must work immediately after onboarding with minimal manual fixes.
170
+ 4. **Migrate** — discovery and the operator's decision come BEFORE copying; the adapter enforces the decision in code.
171
171
 
172
- 4.1. **Discover git-ignored files** — before copying, scan the source project for git-ignored and untracked files using `discoverIgnoredFiles()`. This function runs `git status --ignored --porcelain` in the source directory, categorizes each ignored path, and returns sized categories:
173
- - **Configuration & secrets** (`.env`, `.env.local`, `*.key`, `*.pem`, certificates, `.envrc`) — selected by default, operator must explicitly opt out.
172
+ 4.1. **Discover git-ignored and sensitive files** — scan the source project BEFORE calling `migrate()`:
173
+ - `discoverIgnoredFiles()` runs `git status --ignored --porcelain` in the source directory, categorizes each ignored path, and returns sized categories:
174
+ - **Configuration & secrets** (`.env`, `.env.local`, `*.key`, `*.pem`, certificates, `.envrc`) — NOT selected by default; the operator must explicitly opt in. Secrets never transfer silently.
174
175
  - **Data & inputs** (`.input/`, `input/`, `data/`, `batches/`, `*.db`, `*.ndjson`) — selected by default if total size < 1 GB, otherwise ask the operator.
175
176
  - **Runtime state** (`storage/`, `.state/`, `*.log`) — not selected by default, operator must opt in.
176
177
  - **Caches** (`.cache/`, `cache/`, `.playwright`, `browser-profile`, `*.tmp`) — not selected by default, operator must opt in.
177
178
  - **Other** — any git-ignored file not matching the above categories — not selected by default, operator must opt in.
179
+ - `discoverSensitiveFiles()` walks the tree and finds secret-looking files (`.env*`, `*.key`, `*.pem`, certificates) even without git metadata — run it when the source has no `.git` (where `discoverIgnoredFiles()` returns nothing). Present any hits as a "Secrets" category with the same opt-in rule.
178
180
 
179
181
  For each category, present: label, description, file count, total size (formatted), and a few example paths. The operator selects which categories to transfer.
180
182
 
181
- If `discoverIgnoredFiles()` returns no categories (no `.git` in source, or no ignored files), skip this step entirely — `migrate()` already copies all files on disk.
183
+ 4.2. **Migrate with the operator's decision** — collect `allowedPaths` as the union of `paths` from every category the operator selected (plus individually approved secret paths), then call `migrate(sourceDir, targetDir, analysis, { allowedPaths })`. Show any file conflicts before copying; the operator confirms. The adapter copies all files EXCEPT: build artifacts (`node_modules/`, `dist/`, `.next/`, `.cache/`, `.turbo/`), `.git/`, forge-protected files (`forge.yaml`, `.agents/`, `docs/rfcs/`, `docs/adrs/`, `PREFERENCES.md`), and every ignored or secret-looking path not in `allowedPaths`. Unapproved secrets never reach the target — `collectMigrationBlockedPaths()` enforces this inside the adapter, not by agent discipline. Approved paths are copied by `migrate()` itself — no separate copy step is needed. Blocked paths land in `result.filesSkipped`.
182
184
 
183
- 4.2. **Copy selected ignored files** — after `migrate()` completes, copy the operator-selected git-ignored file categories from the source to `apps/<appName>/`. For each selected category, copy every path in that category from the source to the corresponding location under `apps/<appName>/`. Use `fs.cpSync(src, dest, { recursive: true })` for directories and `fs.copyFileSync` for individual files. Report what was copied (category, file count, total size) in human language.
184
-
185
- 4.3. **Verify untracked files** — after all copies complete, verify that essential untracked files (`.env`, `.env.local`, and other dotfiles present in the source) were copied to `apps/<appName>/`. If any are missing, copy them manually from the source. Do not skip this step — missing `.env` files are the most common cause of a non-functional project after onboarding.
185
+ 4.3. **Verify untracked files** — inspect `result.filesSkipped` and the target tree. If files the operator approved are missing, re-run `migrate()` with those paths added to `allowedPaths` — the adapter is idempotent and skips identical existing files. If `filesSkipped` contains sensitive paths the operator never saw, list them and ask whether to transfer any — never copy skipped secrets without explicit opt-in.
186
186
 
187
187
  5. **Git history transfer** — if the source project has a `.git` directory, ask the operator:
188
188
 
@@ -229,11 +229,17 @@ rtk git commit -m "chore: sync Forge skills"
229
229
 
230
230
  This ensures skills are tracked in version control from the start. The commit includes only `.agents/skills/` — no other files.
231
231
 
232
- ### 6.10. RTK setup (token optimization, mandatory)
232
+ ### 6.10. RTK setup (token optimization, optional)
233
233
 
234
234
  RTK (Rust Token Killer) is a CLI proxy that filters and compresses terminal command output before it reaches the LLM context, cutting up to 90% of bash output on common operations. It is installed once per machine and shared across all forge projects.
235
235
 
236
- The skill installs and configures RTK with **default settings only** — no `--ultra-compact`, no aggressive `read` modes. The operator can enable aggressive modes later via `~/.config/rtk/config.toml`.
236
+ RTK is **optional** — it modifies the machine outside the project directory (installs a global binary, runs `rtk init -g` against the operator's AI-assistant settings). The skill MUST ask for explicit consent before doing anything in this step:
237
+
238
+ > Optional: Forge can set up RTK, a token-optimization proxy for AI-assistant shell commands. This installs a tool on your machine and adjusts your assistant's global settings (a backup is created first). Set it up? (yes/no)
239
+
240
+ If the operator declines, skip the rest of this step entirely — note "RTK: declined by operator" in the welcoming report and do not prompt again this run.
241
+
242
+ If the operator consents, the skill installs and configures RTK with **default settings only** — no `--ultra-compact`, no aggressive `read` modes. The operator can enable aggressive modes later via `~/.config/rtk/config.toml`.
237
243
 
238
244
  #### 6.10.1. Check if RTK is installed
239
245
 
@@ -19,6 +19,7 @@ Sweep batch 4: 73 Compass headers on headerless engine files (certification, com
19
19
  import * as fs from "../utils/sync-fs.ts";
20
20
  import path from "node:path";
21
21
  import { execFileSync } from "../utils/sync-fs.ts";
22
+ import { DEFAULT_EXCLUDE_PATTERNS, normalizeRelPath, isPathExcluded } from "./types.ts";
22
23
 
23
24
  export type IgnoredFileCategoryId = "config" | "data" | "runtime-state" | "cache" | "other";
24
25
 
@@ -224,3 +225,66 @@ export function formatSize(bytes: number): string {
224
225
  if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
225
226
  return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
226
227
  }
228
+
229
+ /**
230
+ * Walk the source tree and return repo-relative file paths matching the
231
+ * configuration/secrets matchers — `.env*`, `*.key`, `*.pem`, certificates,
232
+ * `.envrc`. Works without git metadata, so it is the safety net for sources
233
+ * where `discoverIgnoredFiles()` returns nothing (no `.git`). Build-artifact
234
+ * directories (`excludePatterns`) and forge-protected paths are not scanned.
235
+ */
236
+ export function discoverSensitiveFiles(
237
+ sourceDir: string,
238
+ excludePatterns: readonly string[],
239
+ ): string[] {
240
+ const hits: string[] = [];
241
+ const walk = (dir: string): void => {
242
+ let entries;
243
+ try {
244
+ entries = fs.readdirSync(dir, { withFileTypes: true });
245
+ } catch {
246
+ return;
247
+ }
248
+ for (const entry of entries) {
249
+ const fullPath = path.join(dir, entry.name);
250
+ const relPath = normalizeRelPath(path.relative(sourceDir, fullPath));
251
+ if (entry.isDirectory()) {
252
+ if (excludePatterns.some((p) => entry.name === p)) continue;
253
+ if (isForgeProtectedDir(relPath)) continue;
254
+ walk(fullPath);
255
+ } else if (entry.isFile()) {
256
+ if (CONFIG_MATCHERS.some((m) => m(relPath))) hits.push(relPath);
257
+ }
258
+ }
259
+ };
260
+ walk(sourceDir);
261
+ return hits;
262
+ }
263
+
264
+ function isForgeProtectedDir(relPath: string): boolean {
265
+ return relPath === ".agents" || relPath === "docs/rfcs" || relPath === "docs/adrs";
266
+ }
267
+
268
+ /**
269
+ * The paths `migrate()` must skip: every git-ignored path plus every
270
+ * secret-looking file, minus the operator's explicit allowlist. Secrets are
271
+ * therefore excluded by default — they transfer only when the operator opts in.
272
+ */
273
+ export function collectMigrationBlockedPaths(
274
+ sourceDir: string,
275
+ allowedPaths?: readonly string[],
276
+ ): Set<string> {
277
+ const allowed = new Set((allowedPaths ?? []).map(normalizeRelPath));
278
+ const blocked = new Set<string>();
279
+ const consider = (relPath: string): void => {
280
+ const normalized = normalizeRelPath(relPath);
281
+ if (!isPathExcluded(normalized, allowed)) blocked.add(normalized);
282
+ };
283
+ for (const cat of discoverIgnoredFiles(sourceDir)) {
284
+ for (const p of cat.paths) consider(p);
285
+ }
286
+ for (const p of discoverSensitiveFiles(sourceDir, DEFAULT_EXCLUDE_PATTERNS)) {
287
+ consider(p);
288
+ }
289
+ return blocked;
290
+ }
@@ -13,12 +13,28 @@ Sweep batch 2: real KEY_DECISIONS on 10 files, expanded purposes (CONTRACT-02/PU
13
13
  </CHANGE_SUMMARY>
14
14
  */
15
15
 
16
- export type { MigrationAdapter, AdapterAnalysis, MigrationResult, Conflict } from "./types.ts";
16
+ export type {
17
+ MigrationAdapter,
18
+ AdapterAnalysis,
19
+ MigrationResult,
20
+ Conflict,
21
+ MigrateOptions,
22
+ } from "./types.ts";
17
23
 
18
- export { FORGE_PROTECTED_PATHS, DEFAULT_EXCLUDE_PATTERNS } from "./types.ts";
24
+ export {
25
+ FORGE_PROTECTED_PATHS,
26
+ DEFAULT_EXCLUDE_PATTERNS,
27
+ normalizeRelPath,
28
+ isPathExcluded,
29
+ } from "./types.ts";
19
30
 
20
31
  export { nodeTypescriptPnpmAdapter } from "./node-typescript-pnpm/index.ts";
21
32
  export { phaserPnpmAdapter } from "./phaser-pnpm/index.ts";
22
33
  export { getAdapters, detectAdapter, detectAdapters } from "./registry.ts";
23
- export { discoverIgnoredFiles, formatSize } from "./ignored-files.ts";
34
+ export {
35
+ discoverIgnoredFiles,
36
+ discoverSensitiveFiles,
37
+ collectMigrationBlockedPaths,
38
+ formatSize,
39
+ } from "./ignored-files.ts";
24
40
  export type { IgnoredFileCategory, IgnoredFileCategoryId } from "./ignored-files.ts";
@@ -15,8 +15,15 @@
15
15
 
16
16
  import * as fs from "../../utils/sync-fs.ts";
17
17
  import path from "node:path";
18
- import type { MigrationAdapter, AdapterAnalysis, MigrationResult, Conflict } from "../types.ts";
19
- import { FORGE_PROTECTED_PATHS, DEFAULT_EXCLUDE_PATTERNS } from "../types.ts";
18
+ import type {
19
+ MigrationAdapter,
20
+ AdapterAnalysis,
21
+ MigrationResult,
22
+ Conflict,
23
+ MigrateOptions,
24
+ } from "../types.ts";
25
+ import { FORGE_PROTECTED_PATHS, DEFAULT_EXCLUDE_PATTERNS, isPathExcluded } from "../types.ts";
26
+ import { collectMigrationBlockedPaths } from "../ignored-files.ts";
20
27
  import { runPostSetup } from "../git-utils.ts";
21
28
 
22
29
  interface PackageJson {
@@ -76,17 +83,24 @@ export const nodeTypescriptPnpmAdapter: MigrationAdapter = {
76
83
  };
77
84
  },
78
85
 
79
- migrate(sourceDir: string, targetDir: string, analysis: AdapterAnalysis): MigrationResult {
86
+ migrate(
87
+ sourceDir: string,
88
+ targetDir: string,
89
+ analysis: AdapterAnalysis,
90
+ options?: MigrateOptions,
91
+ ): MigrationResult {
80
92
  const destDir = path.join(targetDir, analysis.placement, analysis.appName);
81
93
  const filesCopied: string[] = [];
82
94
  const filesSkipped: string[] = [];
83
95
  const conflicts: Conflict[] = [];
96
+ const blockedPaths = collectMigrationBlockedPaths(sourceDir, options?.allowedPaths);
84
97
 
85
98
  copyDirectory(
86
99
  sourceDir,
87
100
  destDir,
88
101
  sourceDir,
89
102
  analysis.excludePatterns,
103
+ blockedPaths,
90
104
  filesCopied,
91
105
  filesSkipped,
92
106
  conflicts,
@@ -140,6 +154,7 @@ function copyDirectory(
140
154
  dest: string,
141
155
  rootSrc: string,
142
156
  excludePatterns: string[],
157
+ blockedPaths: ReadonlySet<string>,
143
158
  filesCopied: string[],
144
159
  filesSkipped: string[],
145
160
  conflicts: Conflict[],
@@ -157,12 +172,13 @@ function copyDirectory(
157
172
  const relPath = path.relative(rootSrc, srcPath).replace(/\\/g, "/");
158
173
 
159
174
  if (entry.isDirectory()) {
160
- if (isExcluded(relPath, excludePatterns)) continue;
175
+ if (isExcluded(relPath, excludePatterns) || isPathExcluded(relPath, blockedPaths)) continue;
161
176
  copyDirectory(
162
177
  srcPath,
163
178
  destPath,
164
179
  rootSrc,
165
180
  excludePatterns,
181
+ blockedPaths,
166
182
  filesCopied,
167
183
  filesSkipped,
168
184
  conflicts,
@@ -170,7 +186,7 @@ function copyDirectory(
170
186
  } else if (entry.isFile()) {
171
187
  if (isExcluded(relPath, excludePatterns)) continue;
172
188
 
173
- if (isForgeProtected(relPath)) {
189
+ if (isForgeProtected(relPath) || isPathExcluded(relPath, blockedPaths)) {
174
190
  filesSkipped.push(relPath);
175
191
  continue;
176
192
  }
@@ -15,8 +15,15 @@
15
15
 
16
16
  import * as fs from "../../utils/sync-fs.ts";
17
17
  import path from "node:path";
18
- import type { MigrationAdapter, AdapterAnalysis, MigrationResult, Conflict } from "../types.ts";
19
- import { FORGE_PROTECTED_PATHS, DEFAULT_EXCLUDE_PATTERNS } from "../types.ts";
18
+ import type {
19
+ MigrationAdapter,
20
+ AdapterAnalysis,
21
+ MigrationResult,
22
+ Conflict,
23
+ MigrateOptions,
24
+ } from "../types.ts";
25
+ import { FORGE_PROTECTED_PATHS, DEFAULT_EXCLUDE_PATTERNS, isPathExcluded } from "../types.ts";
26
+ import { collectMigrationBlockedPaths } from "../ignored-files.ts";
20
27
  import { runPostSetup } from "../git-utils.ts";
21
28
 
22
29
  interface PackageJson {
@@ -76,17 +83,24 @@ export const phaserPnpmAdapter: MigrationAdapter = {
76
83
  };
77
84
  },
78
85
 
79
- migrate(sourceDir: string, targetDir: string, analysis: AdapterAnalysis): MigrationResult {
86
+ migrate(
87
+ sourceDir: string,
88
+ targetDir: string,
89
+ analysis: AdapterAnalysis,
90
+ options?: MigrateOptions,
91
+ ): MigrationResult {
80
92
  const destDir = path.join(targetDir, analysis.placement, analysis.appName);
81
93
  const filesCopied: string[] = [];
82
94
  const filesSkipped: string[] = [];
83
95
  const conflicts: Conflict[] = [];
96
+ const blockedPaths = collectMigrationBlockedPaths(sourceDir, options?.allowedPaths);
84
97
 
85
98
  copyDirectory(
86
99
  sourceDir,
87
100
  destDir,
88
101
  sourceDir,
89
102
  analysis.excludePatterns,
103
+ blockedPaths,
90
104
  filesCopied,
91
105
  filesSkipped,
92
106
  conflicts,
@@ -140,6 +154,7 @@ function copyDirectory(
140
154
  dest: string,
141
155
  rootSrc: string,
142
156
  excludePatterns: string[],
157
+ blockedPaths: ReadonlySet<string>,
143
158
  filesCopied: string[],
144
159
  filesSkipped: string[],
145
160
  conflicts: Conflict[],
@@ -157,12 +172,13 @@ function copyDirectory(
157
172
  const relPath = path.relative(rootSrc, srcPath).replace(/\\/g, "/");
158
173
 
159
174
  if (entry.isDirectory()) {
160
- if (isExcluded(relPath, excludePatterns)) continue;
175
+ if (isExcluded(relPath, excludePatterns) || isPathExcluded(relPath, blockedPaths)) continue;
161
176
  copyDirectory(
162
177
  srcPath,
163
178
  destPath,
164
179
  rootSrc,
165
180
  excludePatterns,
181
+ blockedPaths,
166
182
  filesCopied,
167
183
  filesSkipped,
168
184
  conflicts,
@@ -170,7 +186,7 @@ function copyDirectory(
170
186
  } else if (entry.isFile()) {
171
187
  if (isExcluded(relPath, excludePatterns)) continue;
172
188
 
173
- if (isForgeProtected(relPath)) {
189
+ if (isForgeProtected(relPath) || isPathExcluded(relPath, blockedPaths)) {
174
190
  filesSkipped.push(relPath);
175
191
  continue;
176
192
  }
@@ -22,10 +22,26 @@ export interface MigrationAdapter {
22
22
  id: string;
23
23
  detect(sourceDir: string): boolean;
24
24
  analyze(sourceDir: string): AdapterAnalysis;
25
- migrate(sourceDir: string, targetDir: string, analysis: AdapterAnalysis): MigrationResult;
25
+ migrate(
26
+ sourceDir: string,
27
+ targetDir: string,
28
+ analysis: AdapterAnalysis,
29
+ options?: MigrateOptions,
30
+ ): MigrationResult;
26
31
  postSetup(sourceDir: string, targetDir: string, analysis: AdapterAnalysis): void;
27
32
  }
28
33
 
34
+ export interface MigrateOptions {
35
+ /**
36
+ * Repo-relative paths the operator explicitly approved for transfer —
37
+ * the union of `paths` from the `discoverIgnoredFiles()` categories the
38
+ * operator selected (plus `discoverSensitiveFiles()` hits they opted into).
39
+ * Every git-ignored or secret-looking path NOT on this list is skipped:
40
+ * secrets are excluded by default unless the operator explicitly allows them.
41
+ */
42
+ allowedPaths?: readonly string[];
43
+ }
44
+
29
45
  export interface AdapterAnalysis {
30
46
  stack: string[];
31
47
  packageManager: string;
@@ -70,3 +86,22 @@ export const DEFAULT_EXCLUDE_PATTERNS = [
70
86
  ".turbo",
71
87
  ".git",
72
88
  ] as const;
89
+
90
+ /** Canonical logical repo-relative path: forward slashes, no `./`, no trailing `/`. */
91
+ export function normalizeRelPath(p: string): string {
92
+ return p.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
93
+ }
94
+
95
+ /**
96
+ * Repo-relative paths are logical (forward slashes, no leading `./`, no
97
+ * trailing `/`). An entry `dir` excludes `dir` itself and everything under
98
+ * `dir/`.
99
+ */
100
+ export function isPathExcluded(relPath: string, excluded: ReadonlySet<string>): boolean {
101
+ if (excluded.size === 0) return false;
102
+ const normalized = normalizeRelPath(relPath);
103
+ for (const entry of excluded) {
104
+ if (normalized === entry || normalized.startsWith(entry + "/")) return true;
105
+ }
106
+ return false;
107
+ }