@warpgogol/forge 9.6.2 → 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.
- package/CHANGELOG.md +28 -0
- package/CONTRIBUTING.md +19 -25
- package/README.md +2 -2
- package/README.uk.md +2 -2
- package/dist/src/migration-adapters/ignored-files.d.ts +14 -0
- package/dist/src/migration-adapters/ignored-files.d.ts.map +1 -1
- package/dist/src/migration-adapters/ignored-files.js +62 -0
- package/dist/src/migration-adapters/ignored-files.js.map +1 -1
- package/dist/src/migration-adapters/index.d.ts +3 -3
- package/dist/src/migration-adapters/index.d.ts.map +1 -1
- package/dist/src/migration-adapters/index.js +2 -2
- package/dist/src/migration-adapters/index.js.map +1 -1
- package/dist/src/migration-adapters/node-typescript-pnpm/index.d.ts.map +1 -1
- package/dist/src/migration-adapters/node-typescript-pnpm/index.js +9 -7
- package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
- package/dist/src/migration-adapters/phaser-pnpm/index.d.ts.map +1 -1
- package/dist/src/migration-adapters/phaser-pnpm/index.js +9 -7
- package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
- package/dist/src/migration-adapters/types.d.ts +19 -1
- package/dist/src/migration-adapters/types.d.ts.map +1 -1
- package/dist/src/migration-adapters/types.js +19 -0
- package/dist/src/migration-adapters/types.js.map +1 -1
- package/docs/concepts/why-forge.md +1 -1
- package/docs/evidence/release-9.6.2.md +31 -0
- package/docs/grants/devin-startups.md +25 -0
- package/docs/guides/existing-project.md +5 -5
- package/docs/integrations/devin.md +14 -0
- package/docs/reference/cli.md +2 -2
- package/docs/reference/forge-yaml.md +1 -1
- package/package.json +3 -2
- package/skills/meta/forge-bootstrap/SKILL.md +18 -12
- package/src/migration-adapters/ignored-files.ts +64 -0
- package/src/migration-adapters/index.ts +19 -3
- package/src/migration-adapters/node-typescript-pnpm/index.ts +21 -5
- package/src/migration-adapters/phaser-pnpm/index.ts +21 -5
- package/src/migration-adapters/types.ts +36 -1
- package/src/tests/migration-adapters.test.ts +73 -5
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Forge × Devin for Startups — proposal brief
|
|
2
|
+
|
|
3
|
+
Working draft for the [Devin for Startups](https://devin.ai/startups) application. Public so the claims stay checkable against the repository.
|
|
4
|
+
|
|
5
|
+
| Section | Content |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| **Startup** | Warpgogol — operating engineering studio based in Germany. Forge is our open-source infrastructure product (Apache-2.0, [`@warpgogol/forge`](https://www.npmjs.com/package/@warpgogol/forge) on npm). |
|
|
8
|
+
| **Problem** | Autonomous agents lose project decisions and self-certify their output. There is no independent check between "the agent says done" and "the change is accepted." |
|
|
9
|
+
| **Solution** | Repository-native contracts — `forge.yaml`, generated `AGENTS.md`, portable skills — plus deterministic validators that run in CI outside the agent's reasoning. |
|
|
10
|
+
| **Traction** | Published npm package (v9.6.x) with provenance-signed releases, public CI on every release, documented use across our own production fleet of repositories ([fleet measurement](../reference/fleet-measurement.md)). Note: the fleet is internal usage — evidence of a working tool, not of independent market adoption. |
|
|
11
|
+
| **Devin use case** | Devin as the implementation agent on Forge-governed projects: Forge holds the contract and skills, Devin writes code, Forge validators gate acceptance independently of the agent's self-assessment. See [the integration guide](../integrations/devin.md). |
|
|
12
|
+
| **Milestones** | (1) Reference experiment published — reproducible scenario where a Forge validator catches a contract violation Devin's self-assessment accepted ([protocol](../integrations/devin.md#reference-experiment-planned)). (2) Comparative measurement — same task class, Devin with vs. without Forge. (3) Public results + case study. |
|
|
13
|
+
| **Success metrics** | Verified completion rate, contract violations caught pre-merge, cost per accepted task, manual review effort per PR. |
|
|
14
|
+
| **Limits** | No completed public Devin experiment yet — the integration is verified against Devin's published conventions, the end-to-end demonstration is a funded milestone, not a finished result. |
|
|
15
|
+
|
|
16
|
+
## What the grant pays for
|
|
17
|
+
|
|
18
|
+
- Devin seat/credits for the reference experiment and the comparative study above.
|
|
19
|
+
- CI compute for the validation matrix (Devin × task class × contract presence).
|
|
20
|
+
- Maintainer time writing the reproducible scenarios and publishing the evidence.
|
|
21
|
+
|
|
22
|
+
## What we are not asking the grant to fund
|
|
23
|
+
|
|
24
|
+
- Core Forge development — it is already shipping.
|
|
25
|
+
- Marketing claims — results get published as artifacts (tasks, diffs, validator logs, cost data) or not at all.
|
|
@@ -18,7 +18,7 @@ Transplanting an existing codebase into Forge is an interactive, AI-guided proce
|
|
|
18
18
|
The skill will:
|
|
19
19
|
- Ask for the path to your existing codebase
|
|
20
20
|
- Detect the stack automatically (Phaser, Godot, TypeScript, etc.)
|
|
21
|
-
- Migrate all files (
|
|
21
|
+
- Migrate all files, asking first which git-ignored categories to transfer — secrets (`.env`, `*.key`, `*.pem`) are opt-in only and never copied without explicit approval
|
|
22
22
|
- Optionally transfer git history
|
|
23
23
|
- Verify the build
|
|
24
24
|
|
|
@@ -30,8 +30,8 @@ Transplanting an existing codebase into Forge is an interactive, AI-guided proce
|
|
|
30
30
|
|
|
31
31
|
## What happens during transplant
|
|
32
32
|
|
|
33
|
-
- Your existing files are
|
|
34
|
-
- Hidden files (`.env`, `.gitignore`) are preserved
|
|
33
|
+
- Your existing files are copied into the Forge project structure (the source directory is not modified)
|
|
34
|
+
- Hidden files (`.env`, `.gitignore`) are preserved only when you approve them — git-ignored and secret-looking files transfer on explicit opt-in
|
|
35
35
|
- Git history is optionally transferred
|
|
36
36
|
- The matching stack profile is detected from marker files (`phaser.config.*`, `project.godot`, etc.) <!-- pkg-health-12: code/config path, not a command -->
|
|
37
37
|
- `AGENTS.md` is generated from `forge.yaml`
|
|
@@ -43,8 +43,8 @@ Before transplanting:
|
|
|
43
43
|
|
|
44
44
|
- **Commit or stash all work in the source project** — a clean source tree makes the post-transplant diff reviewable and recovery trivial.
|
|
45
45
|
- **Keep a backup of the source directory** until the transplanted project verifies green (`forge doctor` + your build). The transplant moves files; the backup is the rollback.
|
|
46
|
-
- **Audit secrets before migrating.**
|
|
46
|
+
- **Audit secrets before migrating.** The migration adapter blocks git-ignored and secret-looking files (`.env`, `*.key`, `*.pem`, certificates) unless you explicitly allow them during onboarding — confirm any secret you approve lands only in git-ignored paths of the target, and rotate any credential that had ever been committed to history.
|
|
47
47
|
- **Review the diff before your first commit** — `git status` and `git diff` show exactly what the skill added (`forge.yaml`, `AGENTS.md`, `.agents/skills/`, profile config) versus what it left untouched.
|
|
48
48
|
- **Prefer skipping git history** for projects with secrets in past commits — history transfer is optional, not required.
|
|
49
49
|
|
|
50
|
-
Recovery: if verification fails, restore from the backup and re-run the bootstrap
|
|
50
|
+
Recovery: if verification fails, restore from the backup and re-run the bootstrap. The skill does not modify anything outside the target project directory — optional global tooling (RTK token optimization) is offered only with your explicit consent and backs up any config it touches.
|
|
@@ -47,3 +47,17 @@ The important property: Forge's checks run outside the agent's reasoning. A PR p
|
|
|
47
47
|
- Does not guarantee semantic correctness — validators check declared conditions only.
|
|
48
48
|
- Does not enforce anything by itself. A validator that CI does not run is a report, not a gate — wire `forge` checks into CI or hooks for enforcement. See [the verification model](../concepts/verification-model.md).
|
|
49
49
|
- Does not require or provide a hosted service — everything is files in the repo.
|
|
50
|
+
|
|
51
|
+
## Reference experiment (planned)
|
|
52
|
+
|
|
53
|
+
The claim worth proving is not "Forge works" but "Forge's checks catch what the agent's self-assessment misses." The experiment we intend to publish:
|
|
54
|
+
|
|
55
|
+
1. **Setup** — a clean TypeScript repo with Forge installed; versions, commit SHA and environment pinned.
|
|
56
|
+
2. **Task** — Devin receives a change to an API module with explicit acceptance criteria and one architectural constraint.
|
|
57
|
+
3. **Violation** — one candidate change breaks the declared contract; a Forge validator must detect it independently of Devin's self-report.
|
|
58
|
+
4. **Correction** — Devin receives the validator output, fixes the code, and CI reruns green.
|
|
59
|
+
5. **Evidence** — task text, commits, diffs, validator logs, and run cost are published for independent reproduction.
|
|
60
|
+
|
|
61
|
+
Success criterion: a third party can repeat the scenario and see which contract prevented the incorrect change from being accepted. A follow-up comparison (same task class, Devin with vs. without Forge) measures accepted-change rate, contract violations, manual rework and cost per accepted task — not impressions.
|
|
62
|
+
|
|
63
|
+
Status: **planned, not yet run.** This section will link the published artifacts when the experiment lands; until then it describes the protocol, not a result. See also the [grant proposal](../grants/devin-startups.md) where this experiment is a funded milestone.
|
package/docs/reference/cli.md
CHANGED
|
@@ -282,6 +282,6 @@ forge note.orphan.detect
|
|
|
282
282
|
|
|
283
283
|
## Registered command surface
|
|
284
284
|
|
|
285
|
-
Canonical registry names (
|
|
285
|
+
Canonical registry names not covered in the usage sections above (the live list is generated from the command registry — run `forge --help` for what your installed build exposes):
|
|
286
286
|
|
|
287
|
-
`audit.archive`, `file.size.lint`, `flow.publication.retire`, `flow.status`, `flow.version`, `forge.assets.check`, `forge.assets.list`, `forge.build`, `forge.conformance.run`, `forge.conformance.validate`, `forge.create`, `forge.determinism.check`, `forge.dev`, `forge.doctor`, `forge.port.scaffold`, `forge.port.validate`, `forge.profile.validate`, `forge.public-surface.validate`, `forge.release.prepare`, `forge.release.publish`, `forge.scaffold`, `forge.skill.doc-sync`, `forge.skill.knowledge.compact`, `forge.skill.list`, `forge.skill.validate`, `forge.validate`, `memory.compact`, `mission.archive`, `outbox.validate`, `plan.archive`, `spec.live.rebuild`, `system.map.validate`, `system.outbox.scan`, `system.task.collect`, `system.task.create`, `system.task.dispatch`, `system.task.move`, `system.task.status`, `system.versionset.record`.
|
|
287
|
+
`audit.archive`, `file.size.lint`, `flow.publication.retire`, `flow.status`, `flow.version`, `forge.assets.check`, `forge.assets.list`, `forge.build`, `forge.conformance.run`, `forge.conformance.validate`, `forge.create`, `forge.determinism.check`, `forge.dev`, `forge.doctor`, `forge.port.scaffold`, `forge.port.validate`, `forge.profile.validate`, `forge.public-surface.validate`, `forge.release.prepare`, `forge.release.publish`, `forge.scaffold`, `forge.skill.doc-sync`, `forge.skill.knowledge.compact`, `forge.skill.list`, `forge.skill.validate`, `forge.validate`, `gate.run.status`, `memory.compact`, `mission.archive`, `outbox.validate`, `plan.archive`, `spec.live.rebuild`, `system.map.validate`, `system.outbox.scan`, `system.task.collect`, `system.task.create`, `system.task.dispatch`, `system.task.move`, `system.task.status`, `system.versionset.record`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warpgogol/forge",
|
|
3
|
-
"version": "9.6.
|
|
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",
|
|
@@ -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
|
|
52
|
-
- The skill always offers the operator an interactive selection of git-ignored files
|
|
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
|
|
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** —
|
|
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** —
|
|
173
|
-
-
|
|
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
|
-
|
|
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.
|
|
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,
|
|
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
|
-
|
|
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 {
|
|
16
|
+
export type {
|
|
17
|
+
MigrationAdapter,
|
|
18
|
+
AdapterAnalysis,
|
|
19
|
+
MigrationResult,
|
|
20
|
+
Conflict,
|
|
21
|
+
MigrateOptions,
|
|
22
|
+
} from "./types.ts";
|
|
17
23
|
|
|
18
|
-
export {
|
|
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 {
|
|
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 {
|
|
19
|
-
|
|
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(
|
|
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 {
|
|
19
|
-
|
|
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(
|
|
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(
|
|
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
|
+
}
|
|
@@ -237,7 +237,7 @@ test("migrate skips forge-protected files", async () => {
|
|
|
237
237
|
expect(existsSync(join(appDir, "docs", "rfcs", "rfc-0001.md"))).toBe(false);
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
test("migrate
|
|
240
|
+
test("migrate blocks secret-looking files by default (no git, no allowedPaths)", async () => {
|
|
241
241
|
const sourceDir = join(tempDir, "source");
|
|
242
242
|
const targetDir = join(tempDir, "target");
|
|
243
243
|
|
|
@@ -256,16 +256,84 @@ test("migrate copies untracked/git-ignored files like .env to apps/<appName>/",
|
|
|
256
256
|
const analysis = nodeTypescriptPnpmAdapter.analyze(sourceDir);
|
|
257
257
|
const result = nodeTypescriptPnpmAdapter.migrate(sourceDir, targetDir, analysis);
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
expect(result.
|
|
259
|
+
// Secrets are excluded by default — the operator did not opt in.
|
|
260
|
+
expect(result.filesSkipped).toContain(".env");
|
|
261
|
+
expect(result.filesSkipped).toContain(".env.local");
|
|
261
262
|
expect(result.filesCopied).toContain(".gitignore");
|
|
262
263
|
|
|
263
264
|
const appDir = join(targetDir, "apps", "test-app");
|
|
264
|
-
expect(existsSync(join(appDir, ".env"))).toBe(
|
|
265
|
-
expect(existsSync(join(appDir, ".env.local"))).toBe(
|
|
265
|
+
expect(existsSync(join(appDir, ".env"))).toBe(false);
|
|
266
|
+
expect(existsSync(join(appDir, ".env.local"))).toBe(false);
|
|
266
267
|
expect(existsSync(join(appDir, ".gitignore"))).toBe(true);
|
|
267
268
|
});
|
|
268
269
|
|
|
270
|
+
test("migrate copies secrets only when operator allows them via allowedPaths", async () => {
|
|
271
|
+
const sourceDir = join(tempDir, "source");
|
|
272
|
+
const targetDir = join(tempDir, "target");
|
|
273
|
+
|
|
274
|
+
await mkdir(sourceDir, { recursive: true });
|
|
275
|
+
await mkdir(targetDir, { recursive: true });
|
|
276
|
+
|
|
277
|
+
await writeFile(join(sourceDir, "package.json"), JSON.stringify({ name: "test-app" }));
|
|
278
|
+
await writeFile(join(sourceDir, "tsconfig.json"), "{}");
|
|
279
|
+
await writeFile(join(sourceDir, "pnpm-lock.yaml"), "");
|
|
280
|
+
await writeFile(join(sourceDir, ".env"), "SECRET=hello");
|
|
281
|
+
await writeFile(join(sourceDir, ".env.local"), "API_KEY=secret");
|
|
282
|
+
await writeFile(join(sourceDir, ".gitignore"), ".env\n.env.local\n");
|
|
283
|
+
|
|
284
|
+
const analysis = nodeTypescriptPnpmAdapter.analyze(sourceDir);
|
|
285
|
+
// Operator approved .env but declined .env.local.
|
|
286
|
+
const result = nodeTypescriptPnpmAdapter.migrate(sourceDir, targetDir, analysis, {
|
|
287
|
+
allowedPaths: [".env"],
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
expect(result.filesCopied).toContain(".env");
|
|
291
|
+
expect(result.filesSkipped).toContain(".env.local");
|
|
292
|
+
|
|
293
|
+
const appDir = join(targetDir, "apps", "test-app");
|
|
294
|
+
expect(existsSync(join(appDir, ".env"))).toBe(true);
|
|
295
|
+
expect(existsSync(join(appDir, ".env.local"))).toBe(false);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
test("migrate honors operator refusal for git-ignored categories (git source)", async () => {
|
|
299
|
+
const sourceDir = join(tempDir, "source");
|
|
300
|
+
const targetDir = join(tempDir, "target");
|
|
301
|
+
|
|
302
|
+
await mkdir(sourceDir, { recursive: true });
|
|
303
|
+
await mkdir(targetDir, { recursive: true });
|
|
304
|
+
await mkdir(join(sourceDir, "data"), { recursive: true });
|
|
305
|
+
|
|
306
|
+
await writeFile(join(sourceDir, "package.json"), JSON.stringify({ name: "test-app" }));
|
|
307
|
+
await writeFile(join(sourceDir, "tsconfig.json"), "{}");
|
|
308
|
+
await writeFile(join(sourceDir, "pnpm-lock.yaml"), "");
|
|
309
|
+
await writeFile(join(sourceDir, ".env"), "SECRET=hello");
|
|
310
|
+
await writeFile(join(sourceDir, "data", "dump.db"), "binary-db");
|
|
311
|
+
await writeFile(join(sourceDir, ".gitignore"), ".env\ndata/\n");
|
|
312
|
+
|
|
313
|
+
const { execSync } = await import("node:child_process");
|
|
314
|
+
execSync("git init", { cwd: sourceDir, stdio: "pipe" });
|
|
315
|
+
execSync('git config user.email "test@test.com"', { cwd: sourceDir, stdio: "pipe" });
|
|
316
|
+
execSync('git config user.name "Test"', { cwd: sourceDir, stdio: "pipe" });
|
|
317
|
+
execSync("git add .gitignore package.json tsconfig.json pnpm-lock.yaml", {
|
|
318
|
+
cwd: sourceDir,
|
|
319
|
+
stdio: "pipe",
|
|
320
|
+
});
|
|
321
|
+
execSync("git commit -m initial", { cwd: sourceDir, stdio: "pipe" });
|
|
322
|
+
|
|
323
|
+
// Operator declined the config/secrets category but approved the data dir.
|
|
324
|
+
const analysis = nodeTypescriptPnpmAdapter.analyze(sourceDir);
|
|
325
|
+
const result = nodeTypescriptPnpmAdapter.migrate(sourceDir, targetDir, analysis, {
|
|
326
|
+
allowedPaths: ["data"],
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
expect(result.filesSkipped).toContain(".env");
|
|
330
|
+
expect(result.filesCopied).toContain("data/dump.db");
|
|
331
|
+
|
|
332
|
+
const appDir = join(targetDir, "apps", "test-app");
|
|
333
|
+
expect(existsSync(join(appDir, ".env"))).toBe(false);
|
|
334
|
+
expect(existsSync(join(appDir, "data", "dump.db"))).toBe(true);
|
|
335
|
+
});
|
|
336
|
+
|
|
269
337
|
test("migrate excludes .git directory from copy", async () => {
|
|
270
338
|
const sourceDir = join(tempDir, "source");
|
|
271
339
|
const targetDir = join(tempDir, "target");
|