// Isolate ticket32 visibility changes; preserve concurrent worktree and staged files. 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','tools/pipe-models/README.md', 'tools/pipe-models/visibility.html','tools/pipe-models/cockpitAcceptance.js', 'src/modules/cockpit/domain/pipeVisual.js','src/modules/cockpit/domain/pipeModels.js','src/modules/cockpit/domain/pipeNetwork.js','src/modules/cockpit/domain/viewModes.js', 'src/modules/cockpit/services/pipeModelShader.js','src/modules/cockpit/services/cesiumPipeModels.js', '.scratch/cockpit-real-data-wayfinding/issues/32-32.md', '.scratch/cockpit-real-data-wayfinding/verify/t32-visibility-style.mjs','.scratch/cockpit-real-data-wayfinding/verify/t32-color-layer.mjs','.scratch/cockpit-real-data-wayfinding/verify/t32-adapter-behavior.mjs', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/visibility-fix-and-evidence.md', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/visibility-performance.json', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/visibility-4k-real-pipes.jpg', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/visibility-shared-cockpit-near.jpg', '.scratch/cockpit-real-data-wayfinding/verify/artifacts/t32/visibility-shared-manhole-purple.jpg', ] const shared=['src/modules/cockpit/components/MapInfoPanel.vue','src/modules/cockpit/services/cesiumEngine.js','src/modules/cockpit/services/cesiumPipeLayer.js'] function git(args,{input,env=process.env}={}) {const r=spawnSync('git',args,{input,env,encoding:'utf8'});if(r.status!==0)throw new Error(r.stderr||r.stdout);return r.stdout} function once(s,a,b){if(s.split(a).length!==2)throw new Error('Stage anchor ambiguous: '+a.slice(0,60));return s.replace(a,b)} const head=git(['rev-parse','HEAD']).trim() const other=git(['diff','--cached','--name-only']).trim().split('\n').filter(Boolean) if(other.some(p=>paths.includes(p)||shared.includes(p)))throw new Error('Concurrent staged path overlap; inspect before committing') const env={...process.env,GIT_INDEX_FILE:join(mkdtempSync(join(tmpdir(),'t32-visibility-index-')),'index')} git(['read-tree',head],{env});git(['add','--',...paths],{env}) for(const p of shared){ let s=git(['show',head+':'+p]).replace(/\r\n/g,'\n') const current=readFileSync(p,'utf8').replace(/\r\n/g,'\n') if(p.endsWith('MapInfoPanel.vue')){ const marker='
' const start=current.indexOf('