fm-delta
Use when the legacy Angular source for an already-migrated page changes (the staleness hook flags drift) — re-migrate only the changed surface via a delta plan, preserving accumulated fixes, then re-enter the gates.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- fm-delta
- description
- Use when the legacy Angular source for an already-migrated page changes (the staleness hook flags drift) — re-migrate only the changed surface via a delta plan, preserving accumulated fixes, then re-enter the gates.
- allowed-tools
- Read, Write, Edit, Glob, Grep, Bash, Agent
- argument-hint
- <page> [--app pc|mobile|hana]
- user-invocable
- true
03 SKILL.md 正文
Incremental Re-migration
Re-migrates only what changed when the legacy source drifts, instead of regenerating the whole
page — preserving the fixes accumulated through earlier gate loops. All user-facing output in
workingLanguage.
Instructions
Step 0: Config & state
Read config (absent → run fm-init; stop). Resolve app, targetDir, appDir, packagesDir,
legacyDir, workingLanguage, and the app's legacyPort / port / domain — Step 4 hands all
three to style-spec-extractor for provenance side-resolution, and an unresolved one makes every
capture unresolved. The page should already be at generated or beyond (else this is
a first migration → use fm-analyze/fm-style-spec/fm-plan/fm-gen).
Confirm apps[app] before using it (${CLAUDE_PLUGIN_ROOT}/CLAUDE.md → Configuration): the app entry must exist and carry the keys this stage reads. Config-file presence is not app presence — mobile/hana are scaffolded, and a --app naming an unconfigured one must stop here with a clear message rather than fail deep inside an agent on an unresolved path.
Refuse fixing and escalated too. A fix is in progress or awaiting manual intervention;
Step 5 resets the page to generated, which discards the accumulated repairs and the
previousStatus the fix loop needs. Send the user to fm-fix (after the manual step, for
escalated) and let the gate re-run first.
Refuse a flipped page, a done page, or one with a flip prepared and handed over. done is past
flipped — the legacy page has been deleted, so there is no legacy source left to diff a delta
against and no rollback target; refuse and require manual intervention — not --revert, which
refuses a done page too. A present flipPrOpenedAt means the flip artifact is prepared and PR2
handed over against the current code: refuse and point at fm-route --revert first.
If the status is flipped, stop and tell the user to run
/frontend-migration-plugin:fm-route {page} --revert first — --revert, not --flag-off:
flag-off keeps the current status (fm-route Step 4), so it would leave the page at flipped and
this refusal would repeat with no exit. --revert is the rollback that returns it to
parity-passed. Step 5 resets the status to
generated while the edge flag stays ON — nothing here touches routing — so the tracker would say
"not flipped" while the production domain serves v2. Provenance resolves a capture's side from
exactly that status (${CLAUDE_PLUGIN_ROOT}/templates/capture-provenance.md), so the next capture from the production
host would be labelled legacy and accepted as the legacy baseline. Beyond the provenance damage,
applying a delta to a page under live traffic is a change in production; taking it out of rotation
first is the correct order.
Stale staging is cleared in Step 2, under the lock — not here. Deleting it before the lock
would let a second session destroy the staged baseline of a delta that is currently running: that
run then reaches Step 5, finds its files gone, and aborts having already rewritten the code, leaving
a page whose tracker still says parity-passed over code the delta changed. Step 5's
integrity check is that they exist, so an abandoned pair from a previous run would sail through it
and promote a baseline describing a delta nobody applied — the same reason the Full branch deletes
them, which is the only abort path that was covered.
Step 1: Lock
Acquire docs/migration/{app}/{page}/.lock (stale only when its holder is gone — see ${CLAUDE_PLUGIN_ROOT}/CLAUDE.md → Lock file; JSON schema — holder/pid/ISO-8601 acquiredAt — in ${CLAUDE_PLUGIN_ROOT}/CLAUDE.md → Lock file). If it is held and fresh, report who holds it and stop — do not delete anything, and do not wait.
Step 2: Clear stale staging, then compute the delta (planner incremental mode)
Under the lock, first clear the page's gate authorization — gateEvidence, the legacy
verifiedAt/e2ePassedAt/parityPassedAt, routePrepared/flagKey (take .tracker.lock), plus
the cascade record and the page's cascade-diff*.json files — fm-route reads that file
directly, so a pre-drift cascade report left on disk would still bind the flip. Do it
now, before anything is computed or applied: from this point the page is known to be drifted, and
an abort at any later step must not leave it route-authorized over code the drift already
invalidated. Step 5 re-clears the same set; clearing twice is harmless, clearing late is not.
Then delete any migration-plan.next.json / analysis.next.json left by an earlier
run that aborted between Step 2 and Step 5. Holding the lock is what makes this safe: the only
staged files that can exist here are orphans, because any live delta holds this lock. Step 5's
integrity check is that the staged pair exists, so an abandoned pair would otherwise sail
through it and promote a baseline describing a delta nobody applied.
Then launch the planner:
Launch migration-planner (subagent_type: "frontend-migration-plugin:migration-planner") with only its params: mode: "incremental", app, page,
analysisPath, planPath (= migration-plan.json, the baseline), legacyDir,
outPath = docs/migration/{app}/{page}/delta-plan.json, workingLanguage. It diffs the current
legacy source against the analysis.json / migration-plan.json baseline and writes
delta-plan.json (added/modified/removed ops + cascade).
Step 3: Offer incremental vs full
Read delta-plan.json.summary. Present:
- the change counts (added/modified/removed);
- if the delta touches > 60% of the page's files (denominator =
tracker.jsonsourcePaths[], the listfm-genrecorded; absent → report the ratio as unavailable rather than guessing), recommend full regeneration instead (Step 4's Full branch names the chain); otherwise default to incremental. Let the user choose.
Step 4: Apply
Style-surface prerequisite — incremental branch only. If delta-plan.json.styleDrift is set (the planner
detected changed classes / structure / assets), first replace analysis.json.styleSurface
wholesale with delta-plan.json.styleDrift.styleSurface — the complete current surface (every
element + structure, not the drifted subset; a merge would leave removed elements behind). Whatever
re-extracts styles reads analysis.json.styleSurface, and the baseline still holds the old surface
until Step 5, so this patch must land before any re-extraction. It must not land before the
Step 3 choice: the Full branch stops without running Step 5, so a styleSurface already replaced
there leaves the canonical analysis.json describing post-drift structure while the tracker still
says parity-passed over pre-drift code and evidence. Patch it inside the incremental branch,
after the user has chosen it.
-
Incremental →
-
Refresh the answer key in-lock — do NOT nest the
fm-style-specskill (it acquires this same page.lock, which this skill holds from Step 1 → deadlock). Because the skill is bypassed, its Step 2b is bypassed too: ensure.claude/settings.local.json(per-machine, untracked — never the shared.claude/settings.json)permissions.allowincludes the Playwright command (e.g.Bash(npx playwright *)) here, or the sub-agent probe cannot launch and the refresh silently degrades tosource-derived— defeating the point of refreshing the answer key. WhenstyleDriftwas set, launchstyle-spec-extractor(subagent_type: "frontend-migration-plugin:style-spec-extractor") directly, resolvinglegacyUrlthe wayfm-style-specStep 2 does (configstagingConfig.baseUrl/ appdomain+analysis.target.routePath/legacyUrlCandidates, ornull→ source-cascade fallback), passing the extractor's own params (seeagents/style-spec-extractor.md):app,page,analysisPath(now holding the patched surface),outPath=docs/migration/{app}/{page}/style-spec.json,legacyUrl,legacyDir,targetDir,appDir, the app'slegacyPort/port/domainand the page's flip state (the extractor resolves each capture'sprovenance.sidefrom those —${CLAUDE_PLUGIN_ROOT}/templates/capture-provenance.md; bypassingfm-style-specbypasses its param list too, and an unresolved side counts as absent, so the refreshed baseline would be unusable byfm-parity),workingLanguage. It refreshesstyle-spec.jsonso the delta's style ops build to fresh values. (Skip whenstyleDriftis unset.) -
Launch
delta-modifier(subagent_type: "frontend-migration-plugin:delta-modifier") with only its params:app,page,deltaPlanPath=docs/migration/{app}/{page}/delta-plan.json,styleSpecPath=docs/migration/{app}/{page}/style-spec.json,targetDir,appDir,packagesDir,workingLanguage(create/style ops usetdd-cycle-runnersemantics — build to the style-spec, no eyeballing). It applies ops in cascade order and preserves fm-fix edits. -
Read the modifier's result before going on.
delta-modifierreports pass/fail rather than aborting. On failing tsc/Vitest, first merge itsfilesChanged[]intosourcePaths(under.tracker.lock) — the files it already created exist in the tree, and a retry that reuses them unchanged will not list them again — then release the page.lockand stop — Step 5's release is the only other one on this branch, so stopping without it strands the page under a lock whose holder has ended. Report the failure and leavemigration-plan.next.json/analysis.next.jsonstaged. Step 5 promotes the staged baseline and writesgenerated, and Step 5 itself states that a run which failed here "leaves the reference untouched" — continuing unconditionally is what breaks that, and a promoted baseline makes the un-applied ops unrecoverable throughfm-delta.
Then, only on success, continue to Step 5.
-
-
Full → the page needs re-planning, not just re-generation. Do all of this while still holding the page
.lock, in this order:- Clear the page's gate authorization —
gateEvidence, the legacyverifiedAt/e2ePassedAt/parityPassedAt, androutePrepared/flagKey(take.tracker.lockfor that write), plus thecascaderecord and the page'scascade-diff*.jsonfiles (fm-routereads that file directly). The drift that brought you here means the recorded passes describe legacy the page no longer matches, and legacy source is not a watch-path axis, so nothing else will notice. Until this write lands the page is still route-authorized over known-stale code. - Delete
migration-plan.next.jsonandanalysis.next.jsonso a later run cannot mistake an abandoned proposal for a current one. - Only then release the page
.lock— the skills you point the user to need it. Releasing first would leave both mutations unprotected: a secondfm-deltacould take the lock, clear what it correctly reads as stale staging, and start applying its own delta while this run is still deleting files and writing the tracker underneath it. - Tell the user to re-run the chain from the stage the drift invalidated:
/frontend-migration-plugin:fm-analyze {page}→fm-style-spec(ifstyleDrift) →fm-plan→fm-gen {page} --force. Do not send them straight tofm-gen: the canonical baseline is still the pre-drift one — the planner staged its proposal and only Step 5 promotes it — sofm-genwould regenerate against the plan the drift just invalidated.
The skill stops here; Step 5 does not run.
- Clear the page's gate authorization —
Step 5: Record (incremental path only)
Tracker lock. Take docs/migration/.tracker.lock around every tracker.json write below —
after the lock this step already holds, released right after the write (${CLAUDE_PLUGIN_ROOT}/CLAUDE.md → Lock file). Write it per ${CLAUDE_PLUGIN_ROOT}/CLAUDE.md → Serialization.
- Promote the staged baseline.
migration-planner(incremental mode) wrote its proposal tomigration-plan.next.jsonandanalysis.next.json; verify both parse and reflect the applied ops rather than re-deriving them here (thestyleSurfaceis already current from Step 4), then move them over the canonicalmigration-plan.json/analysis.jsonand delete the staged copies. This is the only step that advances the baseline, and it runs after the delta actually applied — so a user who chose full regeneration, or a run that failed in Step 4, leaves the reference untouched. If either staged file is missing, the delta is incomplete — re-run the planner before recording. Archive the delta asdelta-plan.{timestamp}.json. - Update
tracker.json(Read-Modify-Write): set status back togenerated(the page must re-pass the gates), recorddeltaAppliedAt, refresh the trackerstyleSpecsummary when Step 4 re-extracted the answer key (otherwise it keeps describing the pre-drift capture), refreshsourcePathsfrom the modifier'sfilesChanged[](repo-relative — add created/modified files, drop removed ones; a report without the list is incomplete evidence: re-collect before recording), and cleargateEvidencetogether with the legacyverifiedAt/e2ePassedAt/parityPassedAt— the page's code changed, so every prior gate PASS now rests on superseded code and must not read as fresh. ClearinggateEvidencealone leaves exactly the fieldsfm-routeStep 1 hard-gates on (verifiedAt+ both reports readingpass), which would re-authorize the flip. ClearroutePreparedandflagKeyon the same pass, or Step 1-pre still reads the page as code-PR-prepared and--flag-onskips the fresh--flag-off(${CLAUDE_PLUGIN_ROOT}/CLAUDE.md → "Gate Result Accounting"). Do not clearregenRequiredAt— it means a fullfm-genis owed, and the incremental branch runsdelta-modifier, not the foundation phase that produces the i18n key-coverage spec. - Release the lock.
Step 6: Report (incremental path)
In workingLanguage: ops applied, tests pass/fail with evidence, confirmation that prior fixes
were preserved, and the re-entry point — /frontend-migration-plugin:fm-verify {page} →
(fm-cascade when the page injects markup it does not author) → fm-e2e → fm-parity. (On the Full path the skill already ended in Step 4 after releasing the lock and
printing the fm-analyze → fm-style-spec → fm-plan → fm-gen --force next-steps — that
instruction is its report.)
04 同仓库更多 Skills
hp-shared
Shared conventions for every homepage-plugin agent and skill — stack, code conventions, state-file writes, check commands and how to report them. Preloaded into agents through their `skills:` frontmatter; not meant to be invoked by hand.
fe-shared
Shared conventions for every frontend-react-plugin agent and skill — code conventions, state files and locks, accepted deviations, design principles, build working directory, router-mode command matrix, TypeScript check. Preloaded into agents through their `skills:` frontmatter; not meant to be invoked by hand.
be-spring-shared
Shared conventions for every backend-springboot-plugin agent and skill — tech stack, CQRS architecture, naming, coding standards, TDD, commit and build rules, state files. Preloaded into agents through their `skills:` frontmatter; not meant to be invoked by hand.
pp-translate
Use after directly editing the working language spec to sync changes to other supported languages.
pp-sync-stitch
Use when wireframes were manually edited on the Stitch website and need to be re-fetched to the local project.
pp-sync-notion
Use when a specification needs to be published or re-synced to Notion after finalization or manual edits.