// Task-local staging: use a separate index so other sessions' staged work is not committed. import { spawnSync } from 'node:child_process' import { mkdtempSync, readFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' const paths=[ 'CONTEXT.md','public/cockpit/models/pipes/README.md', 'src/modules/cockpit/domain/pipeDiameter.js','src/modules/cockpit/domain/pipeModels.js','src/modules/cockpit/domain/pipeNetwork.js', 'src/modules/cockpit/services/cesiumPipeModels.js', '.scratch/cockpit-real-data-wayfinding/issues/32-32.md', '.scratch/cockpit-real-data-wayfinding/verify/t32-diameter-fill.mjs', '.scratch/cockpit-real-data-wayfinding/verify/t32-diameter-live.mjs', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/diameter-live-result.json', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/diameter-cockpit-status.png', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/diameter-implementation.md', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/implementation-and-acceptance.md', ] const ui='src/modules/cockpit/components/MapInfoPanel.vue' const all=[...paths,ui] function git(args,{input,env=process.env}={}) { const result=spawnSync('git',args,{input,env,encoding:'utf8'}) if(result.status!==0) throw new Error(result.stderr||result.stdout) return result.stdout } const stagedOther=git(['diff','--cached','--name-only']).trim().split('\n').filter(Boolean) if(stagedOther.some(path=>all.includes(path))) throw new Error('Another staged change overlaps this task') const head=git(['rev-parse','HEAD']).trim() const env={...process.env,GIT_INDEX_FILE:join(mkdtempSync(join(tmpdir(),'t32-diameter-index-')),'index')} git(['read-tree',head],{env}) git(['add','--',...paths],{env}) const old=' 折线/符号 {{ pipeModelState.fallback }} 对象\n' const source=readFileSync(ui,'utf8').replace(/\r\n/g,'\n') const beginning=source.indexOf(old) const end=source.indexOf('