@hominis/fireforge 0.38.0 → 0.39.0

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 (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/commands/build.js +8 -3
  3. package/dist/src/commands/discard.js +75 -50
  4. package/dist/src/commands/export-flow.d.ts +1 -1
  5. package/dist/src/commands/export-flow.js +7 -4
  6. package/dist/src/commands/export-placement-gate.js +1 -1
  7. package/dist/src/commands/export-shared.js +17 -2
  8. package/dist/src/commands/import.js +5 -0
  9. package/dist/src/commands/lint-per-patch.js +15 -5
  10. package/dist/src/commands/lint.js +1 -1
  11. package/dist/src/commands/patch/lint-ignore.js +20 -1
  12. package/dist/src/commands/patch/move-files-into.d.ts +47 -0
  13. package/dist/src/commands/patch/move-files-into.js +245 -0
  14. package/dist/src/commands/patch/move-files.js +27 -13
  15. package/dist/src/commands/patch/rename.js +4 -1
  16. package/dist/src/commands/reset.js +5 -0
  17. package/dist/src/commands/status-output.d.ts +9 -0
  18. package/dist/src/commands/status-output.js +33 -1
  19. package/dist/src/commands/status.js +17 -3
  20. package/dist/src/commands/test-diagnose.d.ts +1 -1
  21. package/dist/src/commands/test-diagnose.js +9 -3
  22. package/dist/src/commands/test-modes.d.ts +21 -0
  23. package/dist/src/commands/test-modes.js +42 -0
  24. package/dist/src/commands/test-run.d.ts +2 -0
  25. package/dist/src/commands/test-run.js +8 -2
  26. package/dist/src/commands/test.js +38 -32
  27. package/dist/src/core/build-baseline-types.d.ts +7 -0
  28. package/dist/src/core/build-baseline.d.ts +1 -1
  29. package/dist/src/core/build-baseline.js +2 -1
  30. package/dist/src/core/build-prepare.d.ts +9 -0
  31. package/dist/src/core/build-prepare.js +24 -0
  32. package/dist/src/core/config-validate.js +8 -0
  33. package/dist/src/core/discard-baseline.d.ts +60 -0
  34. package/dist/src/core/discard-baseline.js +232 -0
  35. package/dist/src/core/license-headers.d.ts +12 -0
  36. package/dist/src/core/license-headers.js +27 -0
  37. package/dist/src/core/patch-export.d.ts +10 -1
  38. package/dist/src/core/patch-export.js +12 -2
  39. package/dist/src/core/patch-lint-checkjs.d.ts +6 -1
  40. package/dist/src/core/patch-lint-checkjs.js +30 -14
  41. package/dist/src/core/patch-lint-cross.d.ts +9 -1
  42. package/dist/src/core/patch-lint-cross.js +69 -9
  43. package/dist/src/core/patch-lint-mozbuild.d.ts +18 -0
  44. package/dist/src/core/patch-lint-mozbuild.js +104 -0
  45. package/dist/src/core/patch-lint.js +4 -1
  46. package/dist/src/core/patch-policy.d.ts +14 -1
  47. package/dist/src/core/patch-policy.js +13 -2
  48. package/dist/src/core/test-harness-crash.d.ts +10 -0
  49. package/dist/src/core/test-harness-crash.js +16 -0
  50. package/dist/src/core/test-stale-check.d.ts +15 -0
  51. package/dist/src/core/test-stale-check.js +37 -1
  52. package/dist/src/core/token-manager.js +39 -2
  53. package/dist/src/core/token-variant.d.ts +7 -0
  54. package/dist/src/core/token-variant.js +9 -0
  55. package/dist/src/core/typecheck-shim.d.ts +13 -0
  56. package/dist/src/core/typecheck-shim.js +17 -2
  57. package/dist/src/core/typecheck.js +14 -3
  58. package/dist/src/types/commands/options.d.ts +12 -0
  59. package/dist/src/types/config.d.ts +15 -0
  60. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.39.0
4
+
5
+ - **`fireforge discard` restores patch-claimed paths to their PATCH-APPLIED baseline instead of pristine upstream, and re-materializes patch-created files instead of deleting them** (FORGE F1, P0 data-loss bug — 15 `patch-backed`/`owned` engine files discarded with `--yes` came back as upstream Firefox artwork, `jar.mn` lost all 134 fork entries, and patch-created files like `hominis-start.html` were deleted outright, all under the message "File restored to original state"; recovery cost a full `reset` + 207-patch `import` + rebuild): discard now consults the manifest's ownership claims per status entry and restores claimed files by folding HEAD content through every affecting patch in order (`computePatchedContent`), leaving the post-`import` worktree convention intact (patch edits stay unstaged ` M`, patch creations stay untracked `??`); patch-deleted files are removed to match the baseline. The legacy semantics are an explicit opt-in via the new `--to-upstream` flag. Success messages name the baseline (`File restored to patch baseline (0001-ui-edit.patch)`, `File re-materialized from patch baseline (…)`, `File restored to pristine upstream (HEAD)`); directory mode applies the same rule per file and its outro buckets the outcomes (`3 file(s) restored: 1 to patch baseline, 1 re-materialized, 1 to upstream state`); dry-run lines annotate each path with its restore target. A corrupt manifest or an unreconstructible baseline REFUSES (naming `--to-upstream`) rather than silently reverting to HEAD; multi-owner (conflict) claims restore the cumulative baseline with a warning pointing at `status --ownership`. Pinned by `discard-patch-baseline.integration.test.ts` (the exact handoff shape: edit-patch + create-patch, dirty both, discard each, assert patch content and git state) and `discard-baseline.test.ts`.
6
+ - **New per-patch lint check `mozbuild-unsorted-list` catches unsorted `EXTRA_JS_MODULES` (and sibling strict-ordered moz.build lists) before any build is dispatched** (FORGE F2, feature — three friction-log occurrences where an unsorted insertion surfaced only as `mozbuild.util.UnsortedError … expected "X" but got "Y"` at configure time, each costing a full multi-minute build cycle): the check reads each patch-touched `moz.build` from the engine tree and reports the exact expected/got pair mozbuild would raise (`moz.build list EXTRA_JS_MODULES is not alphabetically sorted: expected "X" but got "Y" (mozbuild will fail at configure time with UnsortedError)`), using mozbuild's case-insensitive ordering. Covered variables: `EXTRA_COMPONENTS`, `EXTRA_JS_MODULES`, `EXTRA_PP_COMPONENTS`, `EXPORTS`, `PYTHON_UNITTEST_MANIFESTS`, `TESTING_JS_MODULES`, `XPIDL_SOURCES`, including dotted namespaces (`EXTRA_JS_MODULES.<subdir>`); `DIRS` is deliberately excluded (order-meaningful). Severity error; waivable per patch via `lintIgnore: ["mozbuild-unsorted-list"]`; participates in the per-patch lint cache like every other rule.
7
+ - **Forward-import detection now catches a bare getter-property line added to an existing `defineESModuleGetters` map, and every refusal names the exact `patch staged-dependency` invocation to paste** (FORGE F3, bug + message — a patch inserting `Foo: "resource://gre/modules/Foo.sys.mjs",` into a PRE-EXISTING getter object carried no `defineESModuleGetters(` opener in its added lines, so the export gate missed it and the refusal surfaced one consumer at a time downstream): added-lines-only content is additionally scanned for `Name: "resource://…"` property lines (resource/chrome/moz-src schemes, forward-importable extensions only; deduped against the existing extractors so a patch adding the whole call reports once; the `// fireforge-ignore: forward-import` marker and staged-dependency suppression apply unchanged). The `forward-import` message now embeds the exact per-owner remedy — `fireforge patch staged-dependency <patch> --add --file <site> --specifier "<url>" --creates <path> --owner <patch>` — with the fingerprint unchanged. The "reports only the first offender" half of the field report did NOT reproduce on 0.38.0 code: the rule already emits one issue per site and the export gate returns all details (pinned by a two-site test); the observed one-at-a-time behavior was an artifact of the getter shapes being missed.
8
+ - **`patch move-files <from> <to>` into an EXISTING patch is now a real transaction** (FORGE F4, feature — the preview-only flow printed two `re-export --files` commands in the WRONG order (grow first) and without the `--allow-shrink`/`--yes` flags the real execution then demanded, costing three refusals per move): the two-positional form now performs the shrink→grow as one operation under the patch-directory lock with rollback, mirroring `patch split`/`--create`: both bodies are regenerated from the worktree, per-patch linted with each patch's own `lintIgnore`/`tier`, cross-patch linted as a projection (only regressions the move itself introduces refuse; `--force-unsafe` overrides), staged-dependency owners re-point to the target, and forward edges the move introduces are auto-declared. `--dry-run` previews without writing; `-y/--yes` covers non-TTY. The equivalent manual `re-export` commands are still printed — now in EXECUTABLE order (shrink first, flags included) with a note that the shrink must land first.
9
+ - **`lint --per-patch --max-warnings 0` on the cache-hit path: claim REFUTED; two warm-run gaps hardened** (FORGE F5 — the reported 0-exit-despite-warnings was observed once on a 0.37-line host and does not reproduce on 0.38.0+: cached issues flow through the same `--max-warnings` comparison as fresh ones, pinned since 0.38.0 by the "cached warnings still fail per-patch lint" test; the cache key hashes every affected engine file plus the engine HEAD SHA, so an engine-side revert that would empty a patch's diff always misses the cache — now pinned explicitly). One REAL warm-run gap is fixed: an all-cache-hit run previously dropped run-level checkJs errors entirely (e.g. "typescript not installed", unreadable extra shim), letting a warm run report fewer errors than a cold one; global checkJs findings are now emitted whenever checkJs is configured, building the queue-wide program lazily on demand.
10
+ - **`patch lint-ignore --add` warns that the waiver is subject to the project's patch-policy review process** (FORGE F6, message-only — a size-only waiver turned per-patch lint green and then failed a downstream policy audit as `lint-ignore-unreviewed`, a discovery costing a full multi-minute gate run): every `--add` that lands a new check id (including `--dry-run`) prints: "This lint waiver is subject to the project's patch-policy review process. Downstream policy audits that mirror lintIgnore lists in a reviewed allow-map will refuse this patch until the map is updated to include the new ID(s)." No warning on `--remove`, `--clear`, or a no-op add. (Per the upstream adjudication, the audit demanding the patch's WHOLE lintIgnore list in the review map remains intentional; this is the write-time warning only.)
11
+ - **The mixed-harness refusal runs BEFORE the pre-test build** (FORGE F7, inefficiency — `fireforge test <xpcshell file> <browser file> --build` spent the full build before reporting "cannot run xpcshell and browser/mochitest paths in the same mach invocation"): harness classification is a pure path→manifest lookup and now runs immediately after path normalization, ahead of the `--build` dispatch and the stale/coverage gates; a mixed request refuses in milliseconds and `runProtectedMachBuild` is never invoked (pinned by test). Stale/coverage refusals still take precedence over missing-path errors.
12
+ - **`token add --mode override` also writes existing `:root[data-theme="dark"]` / `:root[data-theme="light"]` blocks** (FORGE F8, bug — an override add wrote `:root` and the `@media (prefers-color-scheme: dark)` block but not the explicit theme-attribute blocks, so on scaffolds requiring identical token sets across all themed lists every override add was a guaranteed half-finished edit failing the downstream invariants audit): when the tokens CSS carries top-level `:root[data-theme="dark"]`/`:root[data-theme="light"]` blocks, the dark value is mirrored into the dark block and the base value into the light block (idempotent per block; files without those blocks are unchanged), with an info line naming the blocks written. The report's claim that the FireForge-generated file header documents the CLI "cannot write" those blocks did not match this repo — no such text exists in FireForge's scaffold (it is consumer-authored); nothing to drop here.
13
+ - **A `.patch` extension on a patch-name argument no longer double-suffixes, and `patch rename` explains its no-ops** (FORGE F9, bug + partial refutation — `patch move-files <from> 348-ui-editor-panels.patch --create` produced `348-ui-editor-panels-patch.patch`, and the repair `rename --to 348-ui-editor-panels.patch` reported "Patch rename (no-op)"): `patchNameSlug` now strips one trailing `.patch` (case-insensitive) before sanitisation, converging `export --name`, `patch split --name`, `move-files --create`, and `rename --to` — so the double-suffix never forms and the repair rename is a REAL rename. A true no-op now says why (`nothing to change — filename already "…" (slug of "X" is "Y"), name already "…"`). The claimed positional `<from> <to>` usage string on `rename` was REFUTED: registration is `rename <name>` with a required `--to` flag on 0.38.0.
14
+ - **xpcshell-only runs skip the Marionette port preflight and the mochitest client flags** (FORGE F10, bug — `fireforge test` probed port 2828 even for xpcshell path sets, so a developer's interactive browser holding the port killed xpcshell runs, and `--marionette-port <n>` alone then failed the dispatch because the mochitest-only client flags were forwarded to mach; the only working incantation was the `--mach-arg --flavor=xpcshell` crutch): when manifest classification shows every requested path is xpcshell, the stale-port preflight is skipped (with an explanatory line when `--marionette-port`/`--kill-stale-marionette` were passed) and neither `--setpref=marionette.port` nor `--marionette=127.0.0.1:<n>` is forwarded — the crutch is unnecessary. Pathless runs and `--doctor` (whose probe launches a Marionette browser regardless) keep the preflight.
15
+ - **New read-only coverage reporter: `fireforge status --test-coverage`** (FORGE F11, feature — with concurrent sessions sharing one engine tree, the only way to learn the current recorded test-packaging coverage was to trip the out-of-coverage refusal on a real run): prints the last build baseline's coverage (`full`, or the scoped path list with the refusal implication), `builtAt`, `binaryName`, engine HEAD, and the new `recordedBy` field (`fireforge build`, `fireforge build --ui`, `fireforge test --build <paths>`) that 0.39.0 baselines now record — older baselines render `Recorded by: unknown` and `full (implicit — baseline predates coverage recording)`. Needs only the project root (no engine/git); mutually exclusive with the other status modes. Per the upstream adjudication, coverage REPLACES — no union model; this is strictly a reporter.
16
+ - **`typecheck` and the checkJs lint pass no longer silently suppress undefined free identifiers (TS2304/TS2552)** (FORGE F12, bug — a deployed module referencing `EditorState.create(...)` with no import typechecked as "0 errors across all three projects" because the codes were unconditionally suppressed as globals-shim noise; the failure surfaced as a runtime `ReferenceError` manifesting as a hung suite): both flows now report undefined identifiers at a configurable severity — default `warning` (visible without breaking gates; blocking under `--max-warnings 0`), `error` to make them hard failures, `off` to restore the historical suppression — via `typecheck.undefinedIdentifiers` and `patchLint.undefinedIdentifiers` in fireforge.json. Shim-covered Firefox globals stay clean; reported diagnostics append a hint naming the extra-shim and config remedies. The other module-resolution suppressions (TS2307/2306/2305/2792/2580/7016) are unchanged.
17
+ - **`reset` and `import` warn at completion when `components.conf` diverged from the last full build** (FORGE F13, message — after a `reset` + `import` revert train, the next gate run's unit sweep refused on the stale compiled StaticComponents table one full rebuild too late): both commands now run the existing static-components probe after a successful mutation and print: "components.conf changed relative to the last full \"fireforge build\": <paths>. The compiled StaticComponents table in obj-\* no longer matches the tree, so the next \"fireforge test\" will require a full \"fireforge build\" first — a scoped \"fireforge test --build\" cannot regenerate the compiled table." Advisory only (never throws, silent without a baseline); dry-run/cancelled/failed paths skip it.
18
+ - **The forward-import "Closest legal ordinal" hint is suppressed when no legal ordinal exists in the importing patch's category range** (FORGE F14, message bug — the hint suggested ordinal 388 for a dependency that no reorder could satisfy, sending the operator into a `patch reorder` the category-range policy then refused): when `patchPolicy` is configured and the computed ordinal falls outside the importing patch's category range, the sentence becomes "No legal ordinal in the <category> category range (<from-to>) lands after the creating patch(es); declaring the staged dependency is the recommended remedy." Fingerprints are unchanged across both variants; without a policy the hint prints as before.
19
+ - **`export` never offers to prepend the project license header onto a vendored third-party file** (FORGE F15, bug — the header auto-fix offered EUPL-1.2 headers for three byte-identity-pinned MIT xterm bundles; accepting (or `-y`) would have mislicensed upstream code): new-file candidates carrying a recognized third-party permissive banner (MIT, ISC, BSD-2/3-Clause, Apache-2.0 — by license text markers or a bare `SPDX-License-Identifier`) are excluded from the offer and the dry-run fix list and reported separately: "N new file(s) carry a third-party permissive license banner and were left untouched (vendored); if the missing-license-header lint check flags them, waive it with --lint-ignore missing-license-header". The lint check itself still fires — the reviewed waiver (expressible at creation since 0.38.0's `export --lint-ignore`) remains the sanctioned path.
20
+ - **Signal-shaped configure/build exits are labeled as external interruptions** (FORGE F16 — the reported `--headless`→configure exit-144 mechanism was REFUTED: `--headless` only ever lands in mach TEST args and `mach configure` receives no environment from the test path, so no plausible interaction exists): configure and build failures with exit codes in the 128+N signal convention now append e.g. "Exit 144 is signal-shaped (144 - 128 = 16, SIGURG on this host): the process was likely interrupted externally (OOM-killer, terminal disconnect, display/session teardown) rather than failing on its own, and the log may be truncated mid-step", using the host's real signal table — so the next occurrence is self-describing.
21
+ - **Headed macOS no-output timeouts hint at display sleep and `caffeinate`** (FORGE F17, message-only — a headed single-file run with no `caffeinate` wrapper timed out at 370 s before the first TEST-START; every subsequent `caffeinate -dimsu`-wrapped run passed): when a harness crash with the no-output-timeout shape came from a HEADED run on macOS, the failure message appends: "Hint: this was a HEADED run on macOS that died at the no-output timeout. A common cause is the display going to sleep mid-run, which freezes the headed browser before any test starts. Wrap headed runs in `caffeinate -dimsu <command>` to keep the display awake, or pass --headless." Auto-wrapping dispatches in `caffeinate` was evaluated and DEFERRED — the message half is the clearly-correct, cheap half.
22
+
3
23
  ## 0.38.0
4
24
 
5
25
  - **`status --ownership` reports a furnace-deployed file whose owning patch body went stale as drift** (friction-log item 1, bug — after `furnace deploy` refreshed 12 deployed widget copies, the pre-export "consult ownership" step read clean while the composed gate caught the staleness later on the re-export path): the classifier no longer short-circuits every furnace-prefixed path into the `furnace` bucket — a furnace path claimed by exactly ONE patch now runs the same expected-content comparison as any patch-owned file (`computePatchedContent` vs the deployed copy, deletion and error branches included), classifying as `patch-owned-drift` on divergence and staying `furnace` on a match. Multi-owner and unowned furnace paths keep the old bucket (cross-patch conflicts are already surfaced independently), so the only behavioral change is that stale widget patches now show as drift in the table and in `--json` (machine consumers see those paths move from `"furnace"` to `"patch-owned-drift"`). An integration test pins the exact observed sequence: deploy, export the patch, edit the component source, deploy again, and `status --ownership` reports the owning patch drifted.
@@ -3,7 +3,7 @@ import { Command, InvalidArgumentError as CommanderInvalidArgumentError } from '
3
3
  import { validateBrandOverride } from '../core/brand-validation.js';
4
4
  import { auditBuildArtifacts } from '../core/build-audit.js';
5
5
  import { readBuildBaseline, writeBuildBaseline } from '../core/build-baseline.js';
6
- import { prepareBuildEnvironment } from '../core/build-prepare.js';
6
+ import { describeSignalShapedExit, prepareBuildEnvironment } from '../core/build-prepare.js';
7
7
  import { getProjectPaths, loadConfig } from '../core/config.js';
8
8
  import { withEngineSessionLock } from '../core/engine-session-lock.js';
9
9
  import { attemptMozinfoRewrite, build, buildArtifactMismatchMessage, buildUI, hasBuildArtifacts, hasRunnableBundle, runMach, withBuildLock, } from '../core/mach.js';
@@ -147,6 +147,7 @@ function buildFailureDiagnostics(result, engineDir, objDir, machCommand) {
147
147
  : `cd ${engineDir} && ./mach build -v`;
148
148
  return [
149
149
  `Build failed with exit code ${result.exitCode}.`,
150
+ describeSignalShapedExit(result.exitCode),
150
151
  `Mach phase: ${machCommand}`,
151
152
  makeError ? `Last make error: ${makeError}` : undefined,
152
153
  makeContext ? `Recent make context:\n${makeContext}` : undefined,
@@ -326,13 +327,17 @@ export async function buildCommand(projectRoot, options) {
326
327
  // Record a fresh baseline only on clean success so the next run audits
327
328
  // against this build's HEAD. A failed build keeps the prior baseline so
328
329
  // the next attempt still catches long-standing packaging drops.
330
+ await recordFullBuildBaseline(projectRoot, paths.engine, config.binaryName, options.ui === true);
331
+ outro(`Build completed in ${timeStr}!`);
332
+ }
333
+ /** Persists the full-coverage baseline; a failed write never fails the build. */
334
+ async function recordFullBuildBaseline(projectRoot, engineDir, binaryName, ui) {
329
335
  try {
330
- await writeBuildBaseline(projectRoot, paths.engine, config.binaryName, 'full');
336
+ await writeBuildBaseline(projectRoot, engineDir, binaryName, 'full', undefined, ui ? 'fireforge build --ui' : 'fireforge build');
331
337
  }
332
338
  catch (baselineError) {
333
339
  verbose(`Could not persist build baseline: ${toError(baselineError).message}`);
334
340
  }
335
- outro(`Build completed in ${timeStr}!`);
336
341
  }
337
342
  /** Registers the build command on the CLI program. */
338
343
  export function registerBuild(program, { getProjectRoot, withErrorHandling }) {
@@ -2,9 +2,9 @@
2
2
  import { confirm } from '@clack/prompts';
3
3
  import { Command } from 'commander';
4
4
  import { getProjectPaths } from '../core/config.js';
5
+ import { applyDiscardBaseline, describeConflictWarning, describeDiscardBaseline, describeDiscardOutcome, planDiscardBaselines, planUpstreamDiscards, summarizeDiscardBaselines, } from '../core/discard-baseline.js';
5
6
  import { collectFurnaceManagedPrefixes } from '../core/furnace-config.js';
6
7
  import { getHead, isGitRepository, isMissingHeadError } from '../core/git.js';
7
- import { discardStatusEntry } from '../core/git-file-ops.js';
8
8
  import { expandUntrackedDirectoryEntries, getWorkingTreeStatus } from '../core/git-status.js';
9
9
  import { GeneralError, InvalidArgumentError } from '../errors/base.js';
10
10
  import { GitError } from '../errors/git.js';
@@ -12,6 +12,42 @@ import { toError } from '../utils/errors.js';
12
12
  import { pathExists } from '../utils/fs.js';
13
13
  import { info, intro, isCancel, outro, spinner, warn } from '../utils/logger.js';
14
14
  import { pickDefined } from '../utils/options.js';
15
+ /**
16
+ * Shared interactive confirmation for the single-file and directory paths.
17
+ * Returns false when the operator cancelled (the caller printed the outro).
18
+ */
19
+ async function confirmDiscard(message, hint, options) {
20
+ if (options.yes || options.dryRun)
21
+ return true;
22
+ const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
23
+ if (!isInteractive) {
24
+ throw new InvalidArgumentError('Interactive confirmation not available. Use --yes flag to discard without confirmation.', hint);
25
+ }
26
+ const confirmed = await confirm({ message, initialValue: false });
27
+ if (isCancel(confirmed) || !confirmed) {
28
+ outro('Discard cancelled');
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ /**
34
+ * Plans the restore baseline for `entries`: the patch-applied baseline for
35
+ * patch-claimed paths (FORGE F1), or pristine HEAD when `--to-upstream`
36
+ * explicitly requests the legacy semantics.
37
+ */
38
+ async function planDiscards(patchesDir, engineDir, entries, options) {
39
+ if (options.toUpstream)
40
+ return planUpstreamDiscards(entries);
41
+ return planDiscardBaselines(patchesDir, engineDir, entries);
42
+ }
43
+ /** Dry-run label including the rename pair and the restore-baseline suffix. */
44
+ function dryRunLabel(plan) {
45
+ const { entry } = plan;
46
+ const target = entry.originalPath && entry.originalPath !== entry.file
47
+ ? `${entry.originalPath} -> ${entry.file}`
48
+ : entry.file;
49
+ return `${target} (${describeDiscardBaseline(plan)})`;
50
+ }
15
51
  /**
16
52
  * Discards every status entry whose path lives under `dirPath`. Used by
17
53
  * `discardCommand` as a directory-recursion fallback when the operator
@@ -23,28 +59,15 @@ import { pickDefined } from '../utils/options.js';
23
59
  * discard runs sequentially under its own try/catch so a failure on one
24
60
  * file is reported but does not block the remaining files in the batch.
25
61
  */
26
- async function discardDirectoryEntries(projectRoot, engineDir, dirPath, entries, options) {
27
- if (!options.yes && !options.dryRun) {
28
- const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
29
- if (!isInteractive) {
30
- throw new InvalidArgumentError('Interactive confirmation not available. Use --yes flag to discard without confirmation.', 'Use: fireforge discard <directory> --yes');
31
- }
32
- const confirmed = await confirm({
33
- message: `Discard changes to ${entries.length} file${entries.length === 1 ? '' : 's'} under ${dirPath}/?`,
34
- initialValue: false,
35
- });
36
- if (isCancel(confirmed) || !confirmed) {
37
- outro('Discard cancelled');
38
- return;
39
- }
40
- }
62
+ async function discardDirectoryEntries(projectRoot, engineDir, patchesDir, dirPath, entries, options) {
63
+ const proceed = await confirmDiscard(`Discard changes to ${entries.length} file${entries.length === 1 ? '' : 's'} under ${dirPath}/?`, 'Use: fireforge discard <directory> --yes', options);
64
+ if (!proceed)
65
+ return;
66
+ const plans = await planDiscards(patchesDir, engineDir, entries, options);
41
67
  if (options.dryRun) {
42
68
  info(`Would discard changes to ${entries.length} file(s) under ${dirPath}/:`);
43
- for (const entry of entries) {
44
- const target = entry.originalPath && entry.originalPath !== entry.file
45
- ? `${entry.originalPath} -> ${entry.file}`
46
- : entry.file;
47
- info(` ${target}`);
69
+ for (const plan of plans) {
70
+ info(` ${dryRunLabel(plan)}`);
48
71
  }
49
72
  outro('Dry run complete — no changes made');
50
73
  return;
@@ -52,20 +75,26 @@ async function discardDirectoryEntries(projectRoot, engineDir, dirPath, entries,
52
75
  const s = spinner(`Discarding ${entries.length} file(s) under ${dirPath}/...`);
53
76
  let succeeded = 0;
54
77
  const failures = [];
78
+ const appliedPlans = [];
55
79
  try {
56
- for (const entry of entries) {
80
+ for (const plan of plans) {
57
81
  try {
58
- await discardStatusEntry(engineDir, entry);
82
+ await applyDiscardBaseline(engineDir, plan);
83
+ appliedPlans.push(plan);
59
84
  succeeded += 1;
60
85
  }
61
86
  catch (error) {
62
- failures.push(`${entry.file}: ${toError(error).message}`);
87
+ failures.push(`${plan.entry.file}: ${toError(error).message}`);
63
88
  }
64
89
  }
65
90
  s.stop(`Discarded ${succeeded} of ${entries.length} file(s) under ${dirPath}/${failures.length > 0 ? ` (${failures.length} failed)` : ''}`);
66
91
  for (const failure of failures) {
67
92
  warn(` ${failure}`);
68
93
  }
94
+ for (const plan of appliedPlans) {
95
+ if (plan.conflicted)
96
+ warn(describeConflictWarning(plan));
97
+ }
69
98
  try {
70
99
  const furnacePrefixes = await collectFurnaceManagedPrefixes(projectRoot);
71
100
  const dirIsFurnace = [...furnacePrefixes].some((prefix) => `${dirPath}/`.startsWith(prefix) || prefix.startsWith(`${dirPath}/`));
@@ -79,7 +108,7 @@ async function discardDirectoryEntries(projectRoot, engineDir, dirPath, entries,
79
108
  if (failures.length > 0) {
80
109
  throw new GeneralError(`Failed to discard ${failures.length} file(s) under ${dirPath}/. See warnings above.`);
81
110
  }
82
- outro(`${succeeded} file(s) restored to original state`);
111
+ outro(summarizeDiscardBaselines(appliedPlans, succeeded));
83
112
  }
84
113
  catch (error) {
85
114
  if (!(error instanceof GeneralError)) {
@@ -138,40 +167,33 @@ export async function discardCommand(projectRoot, file, options = {}) {
138
167
  const dirPrefix = `${dirPath}/`;
139
168
  const dirEntries = statusEntries.filter((entry) => entry.file.startsWith(dirPrefix) || entry.originalPath?.startsWith(dirPrefix));
140
169
  if (dirEntries.length > 0) {
141
- await discardDirectoryEntries(projectRoot, paths.engine, dirPath, dirEntries, options);
170
+ await discardDirectoryEntries(projectRoot, paths.engine, paths.patches, dirPath, dirEntries, options);
142
171
  return;
143
172
  }
144
173
  throw new GeneralError(`File "${file}" has no changes to discard.`);
145
174
  }
146
- if (!options.yes && !options.dryRun) {
147
- const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
148
- if (!isInteractive) {
149
- throw new InvalidArgumentError('Interactive confirmation not available. Use --yes flag to discard without confirmation.', 'Use: fireforge discard <file> --yes');
150
- }
151
- const confirmed = await confirm({
152
- message: `Discard all changes to ${statusEntry.file}?`,
153
- initialValue: false,
154
- });
155
- if (isCancel(confirmed) || !confirmed) {
156
- outro('Discard cancelled');
157
- return;
158
- }
175
+ const proceed = await confirmDiscard(`Discard all changes to ${statusEntry.file}?`, 'Use: fireforge discard <file> --yes', options);
176
+ if (!proceed)
177
+ return;
178
+ const [plan] = await planDiscards(paths.patches, paths.engine, [statusEntry], options);
179
+ if (!plan) {
180
+ throw new GeneralError(`File "${file}" has no changes to discard.`);
159
181
  }
160
182
  if (options.dryRun) {
161
183
  // Show the rename pair regardless of which side the operator passed —
162
184
  // passing the NEW path of a rename used to hide that discarding also
163
185
  // resurrects the old path, exactly when the full picture matters most.
164
- const target = statusEntry.originalPath
165
- ? `${statusEntry.originalPath} -> ${statusEntry.file}`
166
- : statusEntry.file;
167
- info(`Would discard changes to: ${target}`);
186
+ info(`Would discard changes to: ${dryRunLabel(plan)}`);
168
187
  outro('Dry run complete — no changes made');
169
188
  return;
170
189
  }
171
190
  const s = spinner(`Discarding changes to ${file}...`);
172
191
  try {
173
- await discardStatusEntry(paths.engine, statusEntry);
192
+ await applyDiscardBaseline(paths.engine, plan);
174
193
  s.stop(`Discarded changes to ${file}`);
194
+ if (plan.conflicted) {
195
+ warn(describeConflictWarning(plan));
196
+ }
175
197
  // Warn when the discarded file is managed by Furnace so the user knows
176
198
  // to re-apply if they want the component's deployed state back.
177
199
  try {
@@ -183,16 +205,18 @@ export async function discardCommand(projectRoot, file, options = {}) {
183
205
  catch {
184
206
  // Furnace config may not exist — skip silently
185
207
  }
186
- outro('File restored to original state');
208
+ outro(describeDiscardOutcome(plan, options.toUpstream === true));
187
209
  }
188
210
  catch (error) {
189
211
  s.error('Discard failed');
190
- if (error instanceof GitError) {
212
+ if (error instanceof GitError || error instanceof GeneralError) {
191
213
  throw error;
192
214
  }
193
- throw new GitError(`Failed to discard ${file}`, statusEntry.isUntracked
194
- ? `rm ${statusEntry.file}`
195
- : `restore --source HEAD --staged --worktree -- ${statusEntry.file}`,
215
+ throw new GitError(`Failed to discard ${file}`, plan.kind === 'unmanaged'
216
+ ? statusEntry.isUntracked
217
+ ? `rm ${statusEntry.file}`
218
+ : `restore --source HEAD --staged --worktree -- ${statusEntry.file}`
219
+ : `write patch baseline for ${statusEntry.file}`,
196
220
  // Always attach the cause via toError so thrown primitives (strings,
197
221
  // numbers) produced by poorly-behaved utilities still propagate as
198
222
  // an Error, preserving stack traces for verbose-mode triage.
@@ -203,8 +227,9 @@ export async function discardCommand(projectRoot, file, options = {}) {
203
227
  export function registerDiscard(program, { getProjectRoot, withErrorHandling }) {
204
228
  program
205
229
  .command('discard <file>')
206
- .description('Discard changes to a specific file (deletes untracked files). Pass a directory path to discard every modified or untracked file beneath it; the operation walks the status output and reverts each match individually.')
230
+ .description('Discard changes to a specific file, restoring patch-claimed paths to their patch-applied baseline (unmanaged untracked files are deleted). Pass a directory path to discard every modified or untracked file beneath it; the operation walks the status output and reverts each match individually.')
207
231
  .option('--dry-run', 'Show what would be discarded without doing it')
232
+ .option('--to-upstream', 'Restore to pristine upstream (HEAD) instead of the patch-applied baseline; deletes patch-created files')
208
233
  .option('-y, --yes', 'Skip confirmation prompt')
209
234
  .action(withErrorHandling(async (file, options) => {
210
235
  await discardCommand(getProjectRoot(), file, pickDefined(options));
@@ -51,7 +51,7 @@ export declare function resolvePlacementPlan(patchesDir: string, options: Export
51
51
  * introduce by landing earlier than one of its dependencies. Returns null
52
52
  * when the projection is clean.
53
53
  */
54
- export declare function projectPlacementForLint(patchesDir: string, plan: PlacementPlan, diff: string): Promise<ConflictReport | null>;
54
+ export declare function projectPlacementForLint(patchesDir: string, plan: PlacementPlan, diff: string, config?: FireForgeConfig): Promise<ConflictReport | null>;
55
55
  /**
56
56
  * Builds the change-summary lines printed by the placement confirmation.
57
57
  */
@@ -176,8 +176,8 @@ function buildNewFilesFromDiff(diff) {
176
176
  * introduce by landing earlier than one of its dependencies. Returns null
177
177
  * when the projection is clean.
178
178
  */
179
- export async function projectPlacementForLint(patchesDir, plan, diff) {
180
- const baseCtx = await buildPatchQueueContext(patchesDir);
179
+ export async function projectPlacementForLint(patchesDir, plan, diff, config) {
180
+ const baseCtx = await buildPatchQueueContext(patchesDir, config);
181
181
  const projectedEntries = baseCtx.entries.map((entry) => {
182
182
  const rename = plan.renameMap.get(entry.filename);
183
183
  if (!rename)
@@ -199,7 +199,10 @@ export async function projectPlacementForLint(patchesDir, plan, diff) {
199
199
  modifiedFileAdditions: buildModifiedFileAdditionsFromDiff(diff),
200
200
  });
201
201
  projectedEntries.sort((a, b) => a.order - b.order || a.filename.localeCompare(b.filename));
202
- const projectedIssues = lintPatchQueue({ entries: projectedEntries }).filter((i) => i.severity === 'error');
202
+ const projectedIssues = lintPatchQueue({
203
+ entries: projectedEntries,
204
+ ...(baseCtx.patchPolicy ? { patchPolicy: baseCtx.patchPolicy } : {}),
205
+ }).filter((i) => i.severity === 'error');
203
206
  if (projectedIssues.length === 0)
204
207
  return null;
205
208
  return {
@@ -235,7 +238,7 @@ export async function commitPlacementExport(input) {
235
238
  if (!placementPlansEqual(currentPlan, input.expectedPlan)) {
236
239
  throw new InvalidArgumentError('Patch queue changed while waiting for export confirmation. Re-run the command to recompute placement.', 'export placement');
237
240
  }
238
- const conflicts = await projectPlacementForLint(input.patchesDir, currentPlan, input.diff);
241
+ const conflicts = await projectPlacementForLint(input.patchesDir, currentPlan, input.diff, input.config);
239
242
  if (conflicts && input.unsafeOverride !== true) {
240
243
  throw new InvalidArgumentError(`Refusing to run export: ${conflicts.reason}. ` +
241
244
  'If the conflict names files owned by another patch (e.g. duplicate-new-file-creation), ' +
@@ -44,7 +44,7 @@ export async function gatePlacementPlan(args) {
44
44
  // is passed — one up-front error per run instead of per-patch findings.
45
45
  const placementPlan = await resolvePlacementPlan(patchesDir, options, selectedCategory, patchName, config);
46
46
  const currentManifest = await loadPatchesManifest(patchesDir);
47
- const conflicts = await projectPlacementForLint(patchesDir, placementPlan, diff);
47
+ const conflicts = await projectPlacementForLint(patchesDir, placementPlan, diff, config);
48
48
  const renamed = currentManifest !== null
49
49
  ? applyRenameMapToManifest(currentManifest, placementPlan.renameMap)
50
50
  : buildProjectedManifest(null, []);
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: EUPL-1.2
2
2
  import { join } from 'node:path';
3
3
  import { confirm, select, text } from '@clack/prompts';
4
- import { addLicenseHeaderToFile } from '../core/license-headers.js';
4
+ import { addLicenseHeaderToFile, hasThirdPartyPermissiveBanner } from '../core/license-headers.js';
5
5
  import { findAllPatchesForFiles } from '../core/patch-export.js';
6
6
  import { commentStyleForFile, detectNewFilesInDiff, isAcceptableNewFileHeader, lintExportedPatch, resolvePatchSizeTier, } from '../core/patch-lint.js';
7
7
  import { resolvePatchOwnedSysMjs } from '../core/patch-lint-ownership.js';
@@ -218,6 +218,7 @@ export async function autoFixLicenseHeaders(engineDir, diffContent, config, isIn
218
218
  if (newFiles.size === 0)
219
219
  return false;
220
220
  const filesToFix = [];
221
+ const vendoredFiles = [];
221
222
  for (const file of newFiles) {
222
223
  const style = commentStyleForFile(file);
223
224
  if (!style)
@@ -231,9 +232,23 @@ export async function autoFixLicenseHeaders(engineDir, diffContent, config, isIn
231
232
  // MPL block header on a derived JS/CSS file) would stack a second
232
233
  // header on top of a legitimate one.
233
234
  if (!isAcceptableNewFileHeader(file, content, style, license)) {
234
- filesToFix.push(file);
235
+ // A recognized third-party permissive banner marks the file as
236
+ // vendored: prepending the project's own license header would break
237
+ // byte-identity pins and mislicense upstream code (FORGE F15).
238
+ if (hasThirdPartyPermissiveBanner(content)) {
239
+ vendoredFiles.push(file);
240
+ }
241
+ else {
242
+ filesToFix.push(file);
243
+ }
235
244
  }
236
245
  }
246
+ if (vendoredFiles.length > 0) {
247
+ const vendoredList = vendoredFiles.map((f) => ` - ${f}`).join('\n');
248
+ info(`${vendoredFiles.length} new file(s) carry a third-party permissive license banner and ` +
249
+ 'were left untouched (vendored); if the missing-license-header lint check flags them, ' +
250
+ `waive it with --lint-ignore missing-license-header:\n${vendoredList}`);
251
+ }
237
252
  if (filesToFix.length === 0)
238
253
  return false;
239
254
  if (dryRun) {
@@ -8,6 +8,7 @@ import { getDirtyFiles } from '../core/git-status.js';
8
8
  import { applyPatchesWithContinue, countPatches, createPatchedContentComputer, discoverPatches, extractAffectedFiles, matchesUntilFilename, PatchError, } from '../core/patch-apply.js';
9
9
  import { checkVersionCompatibility, loadPatchesManifest, validatePatchesManifestConsistency, validatePatchIntegrity, } from '../core/patch-manifest.js';
10
10
  import { getPatchSourceVersion } from '../core/patch-source-metadata.js';
11
+ import { warnIfStaticComponentsStale } from '../core/test-stale-check.js';
11
12
  import { GeneralError } from '../errors/base.js';
12
13
  import { toError } from '../utils/errors.js';
13
14
  import { pathExists, readText } from '../utils/fs.js';
@@ -419,6 +420,10 @@ export async function importCommand(projectRoot, options = {}) {
419
420
  const suffix = result.autoResolved ? ' (auto-resolved)' : '';
420
421
  success(` ${result.patch.filename}${suffix}`);
421
422
  }
423
+ // The re-applied queue may have moved components.conf away from what
424
+ // the last full build compiled in — surface that now instead of at the
425
+ // next test refusal (FORGE F13).
426
+ await warnIfStaticComponentsStale(projectRoot, paths.engine);
422
427
  outro('All patches applied successfully!');
423
428
  }
424
429
  catch (error) {
@@ -56,6 +56,11 @@ async function lintQueuedPatch(patch, lintCtx) {
56
56
  });
57
57
  const cached = getCachedPerPatchLintIssues(cache, patch.filename, cacheKey);
58
58
  if (cached) {
59
+ // Returning before the empty-diff probe below is safe: the cache key
60
+ // hashes every affected engine file's content plus engineHeadSha, so
61
+ // an engine-side revert that would empty the diff always changes the
62
+ // key and misses the cache (pinned by the "engine-side content
63
+ // revert invalidates the per-patch cache" test — FORGE F5).
59
64
  return { status: 'cached', existingFiles: existing, rawIssues: cached, usedCheckJs: false };
60
65
  }
61
66
  }
@@ -115,9 +120,14 @@ async function applyPerPatchResults(subset, results, issues, checkJs, cache) {
115
120
  continue;
116
121
  }
117
122
  emitTierNotice(patch.filename, result.existingFiles, patch.tier);
118
- // Run-level checkJs errors are emitted once, before the first freshly
119
- // linted patch's own issues — matching the serial emit point.
120
- if (result.usedCheckJs && checkJs && !globalCheckJsEmitted) {
123
+ // Run-level checkJs errors are emitted once, before the first
124
+ // non-skipped patch's own issues — matching the serial emit point.
125
+ // Deliberately NOT gated on `result.usedCheckJs`: global findings are
126
+ // run-level, never cached, and an all-cache-hit run previously dropped
127
+ // them entirely, letting a warm run report fewer errors than a cold
128
+ // one (FORGE F5 hardening). PerRunCheckJs builds its program lazily,
129
+ // so the cost only materialises when checkJs is configured.
130
+ if (checkJs && !globalCheckJsEmitted) {
121
131
  globalCheckJsEmitted = true;
122
132
  issues.push(...(await checkJs.getGlobal()));
123
133
  }
@@ -276,7 +286,7 @@ function buildPerRunCheckJs(projectRoot, paths, config, ctx) {
276
286
  return {
277
287
  ownedByPatch,
278
288
  getGrouped: () => (groupedPromise ??= invokePatchLintCheckJsGrouped(paths.engine, resolvePatchOwnedSysMjs(new Set(), ctx), patchLint, projectRoot)),
279
- getGlobal: async () => (groupedPromise ? (await groupedPromise).global : []),
289
+ getGlobal: async () => (await (groupedPromise ??= invokePatchLintCheckJsGrouped(paths.engine, resolvePatchOwnedSysMjs(new Set(), ctx), patchLint, projectRoot))).global,
280
290
  };
281
291
  }
282
292
  /**
@@ -299,7 +309,7 @@ export async function lintPerPatch(projectRoot, paths, options = {}) {
299
309
  const subsetNames = new Set(subset.map((p) => p.filename));
300
310
  const isSubset = subset.length !== manifest.patches.length;
301
311
  const config = await loadConfig(projectRoot);
302
- const ctx = await buildPatchQueueContext(paths.patches);
312
+ const ctx = await buildPatchQueueContext(paths.patches, config);
303
313
  // Queue-level findings (policy, cross-patch) are scoped to the requested
304
314
  // subset: a 5-patch slice should not fail on a policy or forward-import
305
315
  // problem owned entirely by patches the operator did not target.
@@ -461,7 +461,7 @@ export async function lintCommand(projectRoot, files, options = {}) {
461
461
  // per-patch ownership resolver and the cross-patch rules.
462
462
  let ctx;
463
463
  if (await pathExists(paths.patches)) {
464
- ctx = await buildPatchQueueContext(paths.patches);
464
+ ctx = await buildPatchQueueContext(paths.patches, config);
465
465
  }
466
466
  // Ad-hoc explicit-file-list mode evaluates the patch-size rules per
467
467
  // owning patch (see `lintOwningPatchSizes`), so suppress the synthetic
@@ -26,6 +26,16 @@ import { GeneralError, InvalidArgumentError } from '../../errors/base.js';
26
26
  import { toError } from '../../utils/errors.js';
27
27
  import { info, intro, outro, warn } from '../../utils/logger.js';
28
28
  import { requirePatchQueue, requirePatchTarget } from './patch-context.js';
29
+ /**
30
+ * Printed whenever `--add` lands a new check id. The waiver this command
31
+ * writes turns per-patch lint green immediately, but consumer projects
32
+ * commonly audit lintIgnore lists against a reviewed allow-map — the
33
+ * discovery that the map also needs updating otherwise costs a full
34
+ * downstream gate run (FORGE F6).
35
+ */
36
+ const LINT_IGNORE_REVIEW_WARNING = "This lint waiver is subject to the project's patch-policy review process. " +
37
+ 'Downstream policy audits that mirror lintIgnore lists in a reviewed allow-map ' +
38
+ 'will refuse this patch until the map is updated to include the new ID(s).';
29
39
  /**
30
40
  * Computes the post-mutation `lintIgnore` list for a given mode.
31
41
  * Returns `undefined` when the result should drop the field from the
@@ -114,7 +124,10 @@ export async function patchLintIgnoreCommand(projectRoot, identifier, options =
114
124
  // the flag only appeared in the history record — and suppressing lint
115
125
  // findings is precisely the mutation an operator should consciously
116
126
  // approve.
117
- const projectedSummary = describeChange(target.lintIgnore ?? [], applyMode(target.lintIgnore ?? [], mode, values) ?? [], mode, values);
127
+ const currentList = target.lintIgnore ?? [];
128
+ const projectedList = applyMode(currentList, mode, values) ?? [];
129
+ const addsNewIds = mode === 'add' && projectedList.length > currentList.length;
130
+ const projectedSummary = describeChange(currentList, projectedList, mode, values);
118
131
  const decision = await confirmDestructive({
119
132
  operation: 'patch-lint-ignore',
120
133
  title: `Patch lint-ignore: ${target.filename}`,
@@ -123,6 +136,9 @@ export async function patchLintIgnoreCommand(projectRoot, identifier, options =
123
136
  dryRun: isDryRun,
124
137
  });
125
138
  if (decision === 'dry-run') {
139
+ if (addsNewIds) {
140
+ warn(LINT_IGNORE_REVIEW_WARNING);
141
+ }
126
142
  outro('Dry run complete — no changes made');
127
143
  return;
128
144
  }
@@ -148,6 +164,9 @@ export async function patchLintIgnoreCommand(projectRoot, identifier, options =
148
164
  const existing = result.before.lintIgnore ?? [];
149
165
  const projected = result.after.lintIgnore ?? [];
150
166
  info(`${target.filename}: ${describeChange(existing, projected, mode, values)}.`);
167
+ if (mode === 'add' && projected.length > existing.length) {
168
+ warn(LINT_IGNORE_REVIEW_WARNING);
169
+ }
151
170
  try {
152
171
  await appendHistory(paths.patches, {
153
172
  operation: 'patch-lint-ignore',
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Transactional file-ownership move into an EXISTING patch (FORGE F4).
3
+ *
4
+ * Before 0.39.0, `patch move-files <from> <to>` with an existing target was
5
+ * preview-only: it printed two `re-export --files` commands whose real
6
+ * execution cost three further refusals (`--allow-shrink`, `--yes`, and a
7
+ * projected `duplicate-new-file-creation` unless the SHRINK landed first —
8
+ * while the printed plan listed the grow first). This module performs the
9
+ * same shrink→grow as one transaction under the patch-directory lock with
10
+ * rollback, mirroring `patch split` / `move-files --create`.
11
+ *
12
+ * Preconditions match `re-export`: the engine worktree must currently
13
+ * reflect both patches' content, because both bodies are regenerated from
14
+ * the worktree.
15
+ */
16
+ import type { PatchMetadata, PatchMoveFilesOptions, PatchStagedForwardImport } from '../../types/commands/index.js';
17
+ import type { FireForgeConfig } from '../../types/config.js';
18
+ /** Everything the commit step needs, computed and confirmed up front. */
19
+ export interface MoveIntoPlan {
20
+ source: PatchMetadata;
21
+ target: PatchMetadata;
22
+ movedFiles: string[];
23
+ sourceAfter: string[];
24
+ targetAfter: string[];
25
+ sourceDiff: string;
26
+ targetDiff: string;
27
+ /** Patches (by filename) whose staged-dependency owners re-point to the target. */
28
+ ownerRewrites: string[];
29
+ /** Forward-import declarations the move introduces, keyed by importing patch. */
30
+ stagedDependencyAdditions: Map<string, PatchStagedForwardImport[]>;
31
+ }
32
+ /**
33
+ * Plans, lints, confirms, and commits a file-ownership move into an
34
+ * existing patch. Called by `patchMoveFilesCommand` after its ownership
35
+ * pre-checks resolved and validated both patches.
36
+ */
37
+ export declare function runMoveFilesInto(args: {
38
+ enginePath: string;
39
+ patchesDir: string;
40
+ source: PatchMetadata;
41
+ target: PatchMetadata;
42
+ files: string[];
43
+ sourceAfter: string[];
44
+ targetAfter: string[];
45
+ options: PatchMoveFilesOptions;
46
+ config: FireForgeConfig;
47
+ }): Promise<void>;