scip-query 0.17.2 → 0.18.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 (121) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +2 -1
  3. package/dist/{chunk-KSD6IWF4.js → chunk-2GX3TNOW.js} +2 -2
  4. package/dist/{chunk-Q4GKL4CC.js → chunk-35TZERMO.js} +2 -2
  5. package/dist/{chunk-P6FOIU7O.js → chunk-43QUXX3E.js} +2 -2
  6. package/dist/{chunk-U4G4UYLB.js → chunk-45XOH33S.js} +2 -2
  7. package/dist/{chunk-LEKXKHIQ.js → chunk-4MFMTEJ4.js} +5 -5
  8. package/dist/{chunk-FVLZB54V.js → chunk-ABDXTPCT.js} +2 -2
  9. package/dist/{chunk-N3JH45WR.js → chunk-AV54WZUK.js} +2 -2
  10. package/dist/{chunk-S22ICAWV.js → chunk-BAMVG4WQ.js} +2 -2
  11. package/dist/{chunk-7VR5TNOI.js → chunk-BECOMXAL.js} +2 -2
  12. package/dist/{chunk-K53GNKY3.js → chunk-BJJHBKEC.js} +2 -2
  13. package/dist/{chunk-ROMKXEUM.js → chunk-D5F3IQYP.js} +2 -2
  14. package/dist/{chunk-LFPQFRCX.js → chunk-DDGO34I2.js} +2 -2
  15. package/dist/{chunk-IS7DZ7TB.js → chunk-DUKRAHV2.js} +2 -2
  16. package/dist/{chunk-W7FNZKX5.js → chunk-EJ65IVPV.js} +2 -2
  17. package/dist/{chunk-SON6DQNK.js → chunk-EMEXMHOP.js} +2 -2
  18. package/dist/{chunk-BPMBOZAN.js → chunk-FMD46HAG.js} +2 -2
  19. package/dist/{chunk-4H7T7FIM.js → chunk-GTANVH72.js} +2 -2
  20. package/dist/{chunk-O7NA5FCA.js → chunk-GWCW25ON.js} +2 -2
  21. package/dist/chunk-GWNE2WJN.js +3 -0
  22. package/dist/{chunk-ELLPMCWA.js → chunk-H4JNB7RT.js} +2 -2
  23. package/dist/{chunk-G6DDSHMD.js → chunk-HOZ3IXZ5.js} +2 -2
  24. package/dist/{chunk-RUV4KHWA.js → chunk-L2RE5P3X.js} +2 -2
  25. package/dist/{chunk-7LERNHDG.js → chunk-L2TSLMPT.js} +2 -2
  26. package/dist/{chunk-KA7RMBVU.js → chunk-LADYDOS5.js} +2 -2
  27. package/dist/{chunk-AY44MGWS.js → chunk-MN54AGZ3.js} +2 -2
  28. package/dist/{chunk-DJI446FQ.js → chunk-MNRKD3WP.js} +2 -2
  29. package/dist/{chunk-SXDXR5FH.js → chunk-MPBN5DO4.js} +2 -2
  30. package/dist/{chunk-KJOKTZUE.js → chunk-NQBMGFFD.js} +2 -2
  31. package/dist/{chunk-K4XL4HOK.js → chunk-O5Y3ISO3.js} +2 -2
  32. package/dist/{chunk-BEGHYHOQ.js → chunk-ODH4FT3P.js} +2 -2
  33. package/dist/{chunk-MBVHEPHQ.js → chunk-OM6JHEW3.js} +2 -2
  34. package/dist/{chunk-C7MBQSIC.js → chunk-OSBLECSI.js} +2 -2
  35. package/dist/{chunk-ATC4MEVA.js → chunk-OTTHMUMV.js} +2 -2
  36. package/dist/{chunk-SSGACGAD.js → chunk-OUXPJ4H5.js} +2 -2
  37. package/dist/{chunk-CVWX24IY.js → chunk-OWXNDSG3.js} +2 -2
  38. package/dist/{chunk-OQFA2SUQ.js → chunk-P4L5QQT5.js} +2 -2
  39. package/dist/{chunk-APCXCRED.js → chunk-POGZSZPX.js} +2 -2
  40. package/dist/{chunk-4QBRVI7D.js → chunk-PV3GKBO5.js} +2 -2
  41. package/dist/{chunk-NJD4C5G5.js → chunk-PZV2PGBR.js} +2 -2
  42. package/dist/{chunk-CHJ3QROR.js → chunk-Q4UM4JJP.js} +2 -2
  43. package/dist/{chunk-PQD7P6WB.js → chunk-QPF7CS5W.js} +2 -2
  44. package/dist/{chunk-WD3PAQJT.js → chunk-R4VPIS4D.js} +2 -2
  45. package/dist/{chunk-XLJORP6N.js → chunk-RDX6WWHN.js} +2 -2
  46. package/dist/{chunk-YYYERNQL.js → chunk-S43DIBME.js} +2 -2
  47. package/dist/{chunk-MFIA6EIT.js → chunk-SW7LKHRU.js} +2 -2
  48. package/dist/{chunk-2A7LUMZP.js → chunk-SWJEREML.js} +2 -2
  49. package/dist/{chunk-6AITNECC.js → chunk-VQWDZ34M.js} +127 -127
  50. package/dist/{chunk-A2GX3PYV.js → chunk-VXDMXZKC.js} +2 -2
  51. package/dist/{chunk-XTF6ELXT.js → chunk-W3557RPL.js} +2 -2
  52. package/dist/chunk-W3SKYOTF.js +2 -0
  53. package/dist/{chunk-NJTIAQY7.js → chunk-XEEQX5X3.js} +2 -2
  54. package/dist/cli.js +1 -1
  55. package/dist/{command-descriptors-7UUURHWT.js → command-descriptors-AQWWJNTT.js} +143 -143
  56. package/dist/direct-navigation-K3CTVVBU.js +3 -0
  57. package/dist/index.js +1 -1
  58. package/dist/postinstall.js +1 -1
  59. package/dist/queries/affected.js +1 -1
  60. package/dist/queries/bottlenecks.js +1 -1
  61. package/dist/queries/call-graph.js +1 -1
  62. package/dist/queries/change-surface.js +1 -1
  63. package/dist/queries/cleanup-plan.js +1 -1
  64. package/dist/queries/complexity-hotspots.js +1 -1
  65. package/dist/queries/complexity.js +1 -1
  66. package/dist/queries/convergence.js +1 -1
  67. package/dist/queries/dataflow.js +1 -1
  68. package/dist/queries/dead.js +1 -1
  69. package/dist/queries/decorative-checkers.js +1 -1
  70. package/dist/queries/diff-gate.js +1 -1
  71. package/dist/queries/diff-impact.js +1 -1
  72. package/dist/queries/drift.js +1 -1
  73. package/dist/queries/extract-candidates.js +1 -1
  74. package/dist/queries/health.js +1 -1
  75. package/dist/queries/hotspots.js +1 -1
  76. package/dist/queries/imports.js +1 -1
  77. package/dist/queries/incomplete-migration.js +1 -1
  78. package/dist/queries/index.js +1 -1
  79. package/dist/queries/isolated.js +1 -1
  80. package/dist/queries/locality-candidates.js +1 -1
  81. package/dist/queries/members.js +1 -1
  82. package/dist/queries/methods.js +1 -1
  83. package/dist/queries/not-implemented.js +1 -1
  84. package/dist/queries/passthrough-candidates.js +1 -1
  85. package/dist/queries/plan-context.js +1 -1
  86. package/dist/queries/recent-duplicates.js +1 -1
  87. package/dist/queries/redundant-reexports.js +1 -1
  88. package/dist/queries/refs.js +1 -1
  89. package/dist/queries/self-audit.js +1 -1
  90. package/dist/queries/similar-signatures.js +1 -1
  91. package/dist/queries/similar.js +1 -1
  92. package/dist/queries/slice.js +1 -1
  93. package/dist/queries/stale-abstractions.js +1 -1
  94. package/dist/queries/surface.js +1 -1
  95. package/dist/queries/trace.js +1 -1
  96. package/dist/queries/twin-ab.js +1 -1
  97. package/dist/queries/unused-imports.js +1 -1
  98. package/dist/queries/unused-params.js +1 -1
  99. package/dist/queries/wrapper-candidates.js +1 -1
  100. package/dist/reindex-worker.js +24 -24
  101. package/dist/reindex.js +36 -36
  102. package/dist/runtime.js +1 -1
  103. package/docs/COMMAND_REFERENCE.md +1 -1
  104. package/package.json +1 -1
  105. package/skills/_shared/SKILL.md +1 -1
  106. package/skills/scip-api-impact/SKILL.md +5 -1
  107. package/skills/scip-claim-audit/SKILL.md +1 -0
  108. package/skills/scip-cleanup-audit/SKILL.md +4 -0
  109. package/skills/scip-concrete-plan/SKILL.md +129 -48
  110. package/skills/scip-debug/SKILL.md +6 -1
  111. package/skills/scip-explore/SKILL.md +2 -1
  112. package/skills/scip-integrity-audit/SKILL.md +17 -0
  113. package/skills/scip-maintainability/SKILL.md +6 -1
  114. package/skills/scip-query/SKILL.md +3 -0
  115. package/skills/scip-root-cause/SKILL.md +150 -0
  116. package/skills/scip-root-cause/agents/openai.yaml +4 -0
  117. package/skills/scip-tla-model-system/SKILL.md +7 -9
  118. package/skills/scip-verify/SKILL.md +19 -2
  119. package/dist/chunk-TFWDJDGO.js +0 -2
  120. package/dist/chunk-Z4MCFCGX.js +0 -3
  121. package/dist/direct-navigation-CVCFER5G.js +0 -3
package/dist/runtime.js CHANGED
@@ -1,2 +1,2 @@
1
- import{b as j,c as b,d as D,f,g as T,k as m,l as W}from"./chunk-SON6DQNK.js";import{a as k}from"./chunk-YZXV3CU3.js";import{c as g,d as y}from"./chunk-Z4MCFCGX.js";import{fork as $}from"child_process";import{statSync as _}from"fs";import{isAbsolute as F,join as G,relative as M}from"path";import{watch as N}from"chokidar";import A from"ignore";var S=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=T(t.config),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onError=t.onError??(e=>console.error(e.message)),this.gitignoreFilter=k(t.projectRoot),this.extraIgnore=A(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let t=N(this.projectRoot,{ignoreInitial:!0,ignored:(e,i)=>this.isIgnoredWatchPath(e,i?.isDirectory()??!1)});t.on("all",(e,i)=>{this.stopped||this.handleFileChange(i)}),t.on("error",e=>{this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}),this.fsWatchers.push(t)}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){this.stopped=!0;for(let t of this.fsWatchers)t.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}requestRefresh(t,e={}){if(!e.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(t);return}this.pendingTrigger=P(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}isIgnoredWatchPath(t,e){let i=this.relativeWatchPath(t);if(!i)return!1;let r=e?`${i}/`:i;return r===".git/"||r.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)}handleFileChange(t){let e=this.relativeWatchPath(t);!e||e===".."||e.startsWith("../")||e===".git"||e.startsWith(".git/")||this.gitignoreFilter.isIgnored(e)||this.extraIgnore.ignores(e)||e.endsWith("index.db")||e.endsWith("index.scip")||e.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:e})}relativeWatchPath(t){let e=F(t)?t:G(this.projectRoot,t);return M(this.projectRoot,e).replaceAll("\\","/")}scheduleReindex(t){if(this.pendingTrigger=P(this.pendingTrigger,t),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let e=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:e}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&t<this.watchConfig.cooldownMs){let r=this.watchConfig.cooldownMs-t;this.dirty=!0;let o=Date.now()+r;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},r);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let e=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=Date.now();this.setStatus({state:"indexing",startedAt:i}),this.runReindex(e).then(r=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(r),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(r=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(r instanceof Error?r:new Error(String(r))),this.setStatus({state:"idle"})})}runReindex(t){return new Promise((e,i)=>{let r=Date.now(),o=f(this.projectRoot),n=Object.keys(o).length>0?o:this.config,c=m(this.projectRoot,n),a=n.indexer?.typescript,l=n.indexer?.clojure,h=$(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:c.indexPath,SCIP_REINDEX_OUTPUT_DB:c.dbPath,SCIP_REINDEX_LANGUAGES:(n.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(n.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:a?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:a?.projectMode??this.typescriptProjectMode,projects:a?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:t.kind,SCIP_REINDEX_TRIGGER_DETAIL:t.detail??""},stdio:"pipe"});h.on("exit",d=>{d===0?e(Date.now()-r):i(new Error(`Reindex worker exited with code ${d}`))}),h.on("error",i)})}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let t=this.lastGitState,e=this.readGitState();if(!t||!e||this.stopped){this.lastGitState=e;return}this.lastGitState=e;let i=t.head!==e.head,r=t.indexPath!==e.indexPath||t.indexMtimeMs!==e.indexMtimeMs||t.indexSize!==e.indexSize;i&&r?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):i?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):r&&this.scheduleReindex({kind:"watch-git-index",detail:e.indexPath??"index changed"})}readGitState(){let t=g(this.projectRoot,["rev-parse","--git-path","index"]);if(!t)return null;let e=y(this.projectRoot,t),i={head:g(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:e};try{let r=_(e);i.indexMtimeMs=r.mtimeMs,i.indexSize=r.size}catch{i.indexMtimeMs=void 0,i.indexSize=void 0}return i}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function P(s,t){return s?s.kind===t.kind?s.detail===t.detail?s:{kind:s.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${s.kind}, ${t.kind}`}:t}import{existsSync as x,mkdirSync as O,symlinkSync as L,readlinkSync as I,unlinkSync as w,readdirSync as U}from"fs";import{join as p,dirname as R,resolve as u,relative as X,isAbsolute as q}from"path";import{homedir as v,platform as H}from"os";import{fileURLToPath as z}from"url";var J=H()==="win32",C=["_shared","scip-query","scip-setup","scip-calibrate","scip-cleanup-audit","scip-cleanup-improve","scip-integrity-audit","scip-twin-drift","scip-claim-audit","scip-probe-reachability","scip-hyper-optimization","scip-api-impact","scip-concrete-plan","scip-conductor","scip-debug","scip-explore","scip-triage-issue","scip-diagram","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook","scip-tla-model-system"];function K(s={}){let t=s.quiet?()=>{}:console.log,e=z(import.meta.url),i=u(R(e),"..","skills"),r=[p(v(),".claude","skills"),p(v(),".codex","skills"),p(v(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let n of r){let c=R(n);if(!x(c))continue;O(n,{recursive:!0});let a=Y(n);B(n,i,a,o,t);for(let l of C){let h=p(i,l),d=p(n,l);if(!x(h)){o.skipped.push(`${a}/${l}`);continue}if(x(d)){try{let E=I(d);if(u(E)===u(h)){o.alreadyLinked.push(`${a}/${l}`),t(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{o.skipped.push(`${a}/${l}`),t(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}w(d)}L(h,d,J?"junction":"dir"),o.installed.push(`${a}/${l}`),t(` done: ${l} \u2192 ${a}`)}}return o}function B(s,t,e,i,r){let o=new Set(C);for(let n of U(s)){if(o.has(n))continue;let c=p(s,n),a;try{a=u(R(c),I(c))}catch{continue}V(a,t)&&(w(c),i.pruned.push(`${e}/${n}`),r(` prune: ${n} \u2192 ${e} (removed stale scip-query skill link)`))}}function V(s,t){let e=X(u(t),u(s));return e===""||!e.startsWith("..")&&!q(e)}function Y(s){return s.includes(".codex")?"Codex":s.includes(".agents")?"Agents":"Claude"}export{S as Watcher,b as getScipVersion,W as initProjectConfig,K as installSkills,j as isScipInstalled,f as loadProjectConfig,D as printScipInstallInstructions,m as resolveIndexStoragePaths};
1
+ import{b as j,c as b,d as D,f,g as T,k as m,l as W}from"./chunk-EMEXMHOP.js";import{a as k}from"./chunk-YZXV3CU3.js";import{e as g,f as y}from"./chunk-GWNE2WJN.js";import{fork as $}from"child_process";import{statSync as _}from"fs";import{isAbsolute as F,join as G,relative as M}from"path";import{watch as N}from"chokidar";import A from"ignore";var S=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=T(t.config),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onError=t.onError??(e=>console.error(e.message)),this.gitignoreFilter=k(t.projectRoot),this.extraIgnore=A(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{let t=N(this.projectRoot,{ignoreInitial:!0,ignored:(e,i)=>this.isIgnoredWatchPath(e,i?.isDirectory()??!1)});t.on("all",(e,i)=>{this.stopped||this.handleFileChange(i)}),t.on("error",e=>{this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}),this.fsWatchers.push(t)}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){this.stopped=!0;for(let t of this.fsWatchers)t.close();this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer(),this.setStatus({state:"idle"})}requestRefresh(t,e={}){if(!e.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(t);return}this.pendingTrigger=P(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}isIgnoredWatchPath(t,e){let i=this.relativeWatchPath(t);if(!i)return!1;let r=e?`${i}/`:i;return r===".git/"||r.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)}handleFileChange(t){let e=this.relativeWatchPath(t);!e||e===".."||e.startsWith("../")||e===".git"||e.startsWith(".git/")||this.gitignoreFilter.isIgnored(e)||this.extraIgnore.ignores(e)||e.endsWith("index.db")||e.endsWith("index.scip")||e.endsWith("index.db.tmp")||this.scheduleReindex({kind:"watch-source",detail:e})}relativeWatchPath(t){let e=F(t)?t:G(this.projectRoot,t);return M(this.projectRoot,e).replaceAll("\\","/")}scheduleReindex(t){if(this.pendingTrigger=P(this.pendingTrigger,t),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let e=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:e}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&t<this.watchConfig.cooldownMs){let r=this.watchConfig.cooldownMs-t;this.dirty=!0;let o=Date.now()+r;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},r);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let e=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=Date.now();this.setStatus({state:"indexing",startedAt:i}),this.runReindex(e).then(r=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(r),this.dirty&&!this.stopped){let o=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(r=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(r instanceof Error?r:new Error(String(r))),this.setStatus({state:"idle"})})}runReindex(t){return new Promise((e,i)=>{let r=Date.now(),o=f(this.projectRoot),n=Object.keys(o).length>0?o:this.config,c=m(this.projectRoot,n),a=n.indexer?.typescript,l=n.indexer?.clojure,h=$(new URL("./reindex-worker.js",import.meta.url).pathname,[],{detached:!0,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:c.indexPath,SCIP_REINDEX_OUTPUT_DB:c.dbPath,SCIP_REINDEX_LANGUAGES:(n.languages??this.languages)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(n.indexerConcurrency??this.indexerConcurrency??""),SCIP_REINDEX_PNPM_WORKSPACES:a?.pnpmWorkspaces??this.pnpmWorkspaces?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:a?.projectMode??this.typescriptProjectMode,projects:a?.projects??this.typescriptProjects??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:l?.configPath??this.clojureConfigPath??"",SCIP_REINDEX_TRIGGER_KIND:t.kind,SCIP_REINDEX_TRIGGER_DETAIL:t.detail??""},stdio:"pipe"});h.on("exit",d=>{d===0?e(Date.now()-r):i(new Error(`Reindex worker exited with code ${d}`))}),h.on("error",i)})}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let t=this.lastGitState,e=this.readGitState();if(!t||!e||this.stopped){this.lastGitState=e;return}this.lastGitState=e;let i=t.head!==e.head,r=t.indexPath!==e.indexPath||t.indexMtimeMs!==e.indexMtimeMs||t.indexSize!==e.indexSize;i&&r?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):i?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):r&&this.scheduleReindex({kind:"watch-git-index",detail:e.indexPath??"index changed"})}readGitState(){let t=g(this.projectRoot,["rev-parse","--git-path","index"]);if(!t)return null;let e=y(this.projectRoot,t),i={head:g(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:e};try{let r=_(e);i.indexMtimeMs=r.mtimeMs,i.indexSize=r.size}catch{i.indexMtimeMs=void 0,i.indexSize=void 0}return i}clearGitPollTimer(){this.gitPollTimer&&(clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function P(s,t){return s?s.kind===t.kind?s.detail===t.detail?s:{kind:s.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${s.kind}, ${t.kind}`}:t}import{existsSync as x,mkdirSync as O,symlinkSync as L,readlinkSync as I,unlinkSync as w,readdirSync as U}from"fs";import{join as p,dirname as R,resolve as u,relative as X,isAbsolute as q}from"path";import{homedir as v,platform as H}from"os";import{fileURLToPath as z}from"url";var J=H()==="win32",C=["_shared","scip-query","scip-setup","scip-calibrate","scip-cleanup-audit","scip-cleanup-improve","scip-integrity-audit","scip-twin-drift","scip-claim-audit","scip-probe-reachability","scip-hyper-optimization","scip-api-impact","scip-concrete-plan","scip-conductor","scip-debug","scip-explore","scip-root-cause","scip-triage-issue","scip-diagram","scip-doc-reconcile","scip-directory-architecture","scip-maintainability","scip-react-maintainability","scip-vue-maintainability","scip-verify","scip-language-playbook","scip-tla-model-system"];function K(s={}){let t=s.quiet?()=>{}:console.log,e=z(import.meta.url),i=u(R(e),"..","skills"),r=[p(v(),".claude","skills"),p(v(),".codex","skills"),p(v(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let n of r){let c=R(n);if(!x(c))continue;O(n,{recursive:!0});let a=Y(n);B(n,i,a,o,t);for(let l of C){let h=p(i,l),d=p(n,l);if(!x(h)){o.skipped.push(`${a}/${l}`);continue}if(x(d)){try{let E=I(d);if(u(E)===u(h)){o.alreadyLinked.push(`${a}/${l}`),t(` ok: ${l} \u2192 ${a} (already linked)`);continue}}catch{o.skipped.push(`${a}/${l}`),t(` skip: ${l} \u2192 ${a} (exists, not a symlink)`);continue}w(d)}L(h,d,J?"junction":"dir"),o.installed.push(`${a}/${l}`),t(` done: ${l} \u2192 ${a}`)}}return o}function B(s,t,e,i,r){let o=new Set(C);for(let n of U(s)){if(o.has(n))continue;let c=p(s,n),a;try{a=u(R(c),I(c))}catch{continue}V(a,t)&&(w(c),i.pruned.push(`${e}/${n}`),r(` prune: ${n} \u2192 ${e} (removed stale scip-query skill link)`))}}function V(s,t){let e=X(u(t),u(s));return e===""||!e.startsWith("..")&&!q(e)}function Y(s){return s.includes(".codex")?"Codex":s.includes(".agents")?"Agents":"Claude"}export{S as Watcher,b as getScipVersion,W as initProjectConfig,K as installSkills,j as isScipInstalled,f as loadProjectConfig,D as printScipInstallInstructions,m as resolveIndexStoragePaths};
2
2
  //# sourceMappingURL=runtime.js.map
@@ -129,7 +129,7 @@ This syntax summary is generated from the CLI command descriptors. Keep workflow
129
129
  |---|---|---|
130
130
  | `bench` | Benchmark indexing and command runtimes for this repository | `--json`<br>`--cold-index`<br>`--include-heavy`<br>`--command <cmd>`<br>`--timeout-ms <n>`<br>`--progress`<br>`--profile`<br>`--profile-out <path>` |
131
131
  | `work-audit <profile>` | Rank exact repeated computations in a profiling JSONL file by measured avoidable time | `--top <n>`<br>`--json` |
132
- | `install-skills` | Install skills (_shared, scip-query, scip-setup, scip-calibrate, scip-cleanup-audit, scip-cleanup-improve, scip-integrity-audit, scip-twin-drift, scip-claim-audit, scip-probe-reachability, scip-hyper-optimization, scip-api-impact, scip-concrete-plan, scip-conductor, scip-debug, scip-explore, scip-triage-issue, scip-diagram, scip-doc-reconcile, scip-directory-architecture, scip-maintainability, scip-react-maintainability, scip-vue-maintainability, scip-verify, scip-language-playbook, scip-tla-model-system) into Claude Code, Codex, and shared agent roots | - |
132
+ | `install-skills` | Install skills (_shared, scip-query, scip-setup, scip-calibrate, scip-cleanup-audit, scip-cleanup-improve, scip-integrity-audit, scip-twin-drift, scip-claim-audit, scip-probe-reachability, scip-hyper-optimization, scip-api-impact, scip-concrete-plan, scip-conductor, scip-debug, scip-explore, scip-root-cause, scip-triage-issue, scip-diagram, scip-doc-reconcile, scip-directory-architecture, scip-maintainability, scip-react-maintainability, scip-vue-maintainability, scip-verify, scip-language-playbook, scip-tla-model-system) into Claude Code, Codex, and shared agent roots | - |
133
133
  | `setup-hooks` | Install or refresh project-local Codex and Claude Code lifecycle hooks | `--shared`<br>`--remove`<br>`--force`<br>`--json` |
134
134
  | `check-deps` | Check whether scip-query and the detected language indexers are actually runnable | - |
135
135
  | `capabilities` | Report which evidence and verification capabilities are available in this project | `--matrix`<br>`--json` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.17.2",
3
+ "version": "0.18.0",
4
4
  "description": "Evidence and verification for AI coding agents: map code, reuse concepts, finish migrations, and gate diffs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -175,7 +175,7 @@ scip-query complexity <symbol> # Per-symbol complexity: branches, cyclomatic est
175
175
  ```bash
176
176
  scip-query bench # Benchmark indexing and command runtimes for this repository
177
177
  scip-query work-audit <profile> # Rank exact repeated computations in a profiling JSONL file by measured avoidable time
178
- scip-query install-skills # Install skills (_shared, scip-query, scip-setup, scip-calibrate, scip-cleanup-audit, scip-cleanup-improve, scip-integrity-audit, scip-twin-drift, scip-claim-audit, scip-probe-reachability, scip-hyper-optimization, scip-api-impact, scip-concrete-plan, scip-conductor, scip-debug, scip-explore, scip-triage-issue, scip-diagram, scip-doc-reconcile, scip-directory-architecture, scip-maintainability, scip-react-maintainability, scip-vue-maintainability, scip-verify, scip-language-playbook, scip-tla-model-system) into Claude Code, Codex, and shared agent roots
178
+ scip-query install-skills # Install skills (_shared, scip-query, scip-setup, scip-calibrate, scip-cleanup-audit, scip-cleanup-improve, scip-integrity-audit, scip-twin-drift, scip-claim-audit, scip-probe-reachability, scip-hyper-optimization, scip-api-impact, scip-concrete-plan, scip-conductor, scip-debug, scip-explore, scip-root-cause, scip-triage-issue, scip-diagram, scip-doc-reconcile, scip-directory-architecture, scip-maintainability, scip-react-maintainability, scip-vue-maintainability, scip-verify, scip-language-playbook, scip-tla-model-system) into Claude Code, Codex, and shared agent roots
179
179
  scip-query setup-hooks # Install or refresh project-local Codex and Claude Code lifecycle hooks
180
180
  scip-query check-deps # Check whether scip-query and the detected language indexers are actually runnable
181
181
  scip-query capabilities # Report which evidence and verification capabilities are available in this project
@@ -107,7 +107,9 @@ This step is complete only when the migration shape explains deploy order, rollb
107
107
 
108
108
  ```markdown
109
109
  Surface:
110
- Consumers:
110
+ Consumer dispositions:
111
+ | Consumer | Kind (direct/transitive/doc/config/test) | Disposition (unchanged-safe/update/shim/defer) |
112
+ | --- | --- | --- |
111
113
  Required co-changes:
112
114
  Migration:
113
115
  Verification:
@@ -118,6 +120,8 @@ Verification:
118
120
  - `scip-query config-validate` when config changed
119
121
  ```
120
122
 
123
+ Every consumer from `refs`/`affected` appears as a row — a blank disposition is unfinished analysis, and the plan is not complete while one exists. Non-indexed consumers (SQL, fixtures, dynamic strings, external callers) are checked with `rg` and rowed the same way.
124
+
121
125
  After editing, run routed checks from the shared reference and invoke `scip-verify`.
122
126
 
123
127
  The work is complete only when direct consumers, docs/config partners, and `scip-verify` have been checked.
@@ -93,6 +93,7 @@ Write the report under `docs/scip-query/` unless the user asked only for a conve
93
93
  ```markdown
94
94
  Scope:
95
95
  Status words inventoried: N
96
+ Classified: <d> derived / <h> hedged / <a> asserted — must sum to N; a gap is an unfinished audit
96
97
 
97
98
  Claim table:
98
99
  | Claim | Producer | Classification | Fix |
@@ -101,11 +101,15 @@ scip-query co-change <file> --json --full
101
101
 
102
102
  Classify every candidate as `confirmed fix target`, `intentional design`, `false positive`, or `blocked`.
103
103
 
104
+ A deletion is this skill's scrutiny-ending verdict, so a `confirmed fix target` that deletes code must survive refutation first. Run the known blind-spot checks and record them on the entry: `rg` for the symbol name as a string (dynamic dispatch, config keys, serialized references, CLI/doc text), and the cross-package barrel re-export gap (the one shape `dead` self-labels `unconfirmed`). Record `refutation: survived — <checks run>` on the entry, or reclassify it; the note stays either way.
105
+
104
106
  ### 4. Report
105
107
 
106
108
  ```markdown
107
109
  Health score: N/100
108
110
 
111
+ Classification counts: <n> confirmed / <i> intentional / <fp> false positive / <b> blocked (must cover every collected signal)
112
+
109
113
  Confirmed items:
110
114
  - [priority] finding - evidence - first safe action
111
115
 
@@ -1,22 +1,24 @@
1
1
  ---
2
2
  name: scip-concrete-plan
3
- description: Plan code changes with scip-query evidence and testable design. Use for non-trivial implementation, refactor, migration, API, or bug-fix plans before editing code; require source citations, reuse audit, test seams, side-effect boundaries, contracts, and verification.
3
+ description: Plan code changes with scip-query evidence and testable design. Use for non-trivial implementation, refactor, migration, API, or bug-fix plans before editing code; require contextual definitions, cited premises, reuse audit, test seams, counterexample attacks, and a derived verdict.
4
4
  commands:
5
5
  - template: "scip-query status --capabilities"
6
6
  when: "Discover: confirm the index is fresh before citing graph facts."
7
7
  - template: "scip-query plan-context <target>"
8
8
  when: "Discover: anchor the plan with pre-edit context for the target."
9
9
  - template: "scip-query refs <symbol>"
10
- when: "Reuse audit: find existing consumers before proposing a new unit."
10
+ when: "Premises: enumerate every writer and reader of a touched state surface; reuse audit: find existing consumers."
11
+ - template: "scip-query dataflow <symbol-or-variable>"
12
+ when: "Premises: producers and consumers backing a state-authority premise."
11
13
  - template: "scip-query code <symbol>"
12
- when: "Reuse audit: read source before citing a behavior claim."
14
+ when: "Premises: read source before citing a behavior claim."
13
15
  - template: "scip-query trace <symbol>"
14
16
  when: "Verify the plan: rerun source-producing context for cited targets."
15
17
  ---
16
18
 
17
19
  # Concrete Plan
18
20
 
19
- Use this skill to write an implementation plan that another agent can execute without guessing. A concrete plan is a dated Markdown checklist whose code claims come from scip-query evidence and whose design makes the intended behavior easy to test before it is easy to ship.
21
+ Use this skill to write an implementation plan that another agent can execute without guessing and a reviewer can check without re-deriving. A concrete plan is a certificate: a dated Markdown document whose conclusion ready to implement — is derived from numbered, source-cited premises, defended against constructed counterexamples, and shaped so the intended behavior is easy to test before it is easy to ship.
20
22
 
21
23
  Load shared mechanics from [`../_shared/SKILL.md`](../_shared/SKILL.md) when you need lookup tips, command families, postchecks, or subagent rules.
22
24
 
@@ -27,8 +29,9 @@ Load shared mechanics from [`../_shared/SKILL.md`](../_shared/SKILL.md) when you
27
29
  | --- | --- | --- |
28
30
  | `scip-query status --capabilities` | Show index status for this project | Discover: confirm the index is fresh before citing graph facts. |
29
31
  | `scip-query plan-context <target>` | Pre-edit planning context for a symbol, file, or module | Discover: anchor the plan with pre-edit context for the target. |
30
- | `scip-query refs <symbol>` | Find all files referencing a symbol | Reuse audit: find existing consumers before proposing a new unit. |
31
- | `scip-query code <symbol>` | Read the source code for a symbol (bounded to its definition range) | Reuse audit: read source before citing a behavior claim. |
32
+ | `scip-query refs <symbol>` | Find all files referencing a symbol | Premises: enumerate every writer and reader of a touched state surface; reuse audit: find existing consumers. |
33
+ | `scip-query dataflow <symbol-or-variable>` | Reference-level dataflow: definition sites, usage sites, producers, consumers | Premises: producers and consumers backing a state-authority premise. |
34
+ | `scip-query code <symbol>` | Read the source code for a symbol (bounded to its definition range) | Premises: read source before citing a behavior claim. |
32
35
  | `scip-query trace <symbol>` | Trace a symbol: definition + all references | Verify the plan: rerun source-producing context for cited targets. |
33
36
 
34
37
  Use this shortlist first. Open [`../_shared/SKILL.md`](../_shared/SKILL.md) only when it is insufficient.
@@ -39,9 +42,14 @@ Use this shortlist first. Open [`../_shared/SKILL.md`](../_shared/SKILL.md) only
39
42
  1. Start with `scip-query status --capabilities`; reindex only when freshness is `stale`, `missing`, or `unknown`.
40
43
  2. Anchor the plan with `scip-query plan-context <target>`. If the target is not indexed, record that fact and use scip-query for every code-adjacent claim it can answer.
41
44
  3. Put the plan in `docs/plans/YYYY-MM-DD-<short-name>.md`.
42
- 4. Every code step includes a `Source` field naming the scip-query command that produced the path, line range, and behavior claim.
43
- 5. Every behavior-changing step includes a testability design: test seam, injected dependencies, pure core, side-effect boundary, and validation.
44
- 6. Do not propose a new helper, wrapper, type, parameter, config flag, component, hook, or module until the reuse audit proves reuse or extension is not the better move.
45
+ 4. Define every load-bearing concept contextually and state every invariant in `iff` or `must always` form. A definition without referents (a `Source:` line) is a guess.
46
+ 5. Evidence lives in numbered premises (`P1`, `P2`, ...), each with a `Source` naming the scip-query command that produced it. Every shared-state surface the plan touches gets a state-authority premise enumerating its complete writer and reader sets.
47
+ 6. Steps and defenses cite the premises they depend on. A claim no premise supports is either new evidence to gather or an explicit `ASSUMPTION` never silent.
48
+ 7. Do not propose a new helper, wrapper, type, parameter, config flag, component, hook, or module until the reuse audit proves reuse or extension is not the better move.
49
+ 8. Every behavior-changing step includes a testability design: test seam, injected dependencies, pure core, side-effect boundary, and validation.
50
+ 9. Attack entries must be constructed scenarios — actor, starting state, sequence — and each ends in a recorded outcome: `HELD` citing the defending step and premises, or `HOLE` with its repair step or accepted reason. An assertion of absence ("no new shared mutable state") is not a defense; it cannot fail, so it cannot catch anything.
51
+ 10. Installing an enforcer — trigger, constraint, guard, gate — opens an enforcement window: every existing writer in the relevant state-authority premise must be brought into compliance in the same or an earlier step, or the window recorded as an accepted hole. Every step declares `Deployable`.
52
+ 11. The verdict is derived, not asserted: `PLANNED-COMPLETE` only when the coverage matrix has no blank rows and every attack ends in `HELD` with citations or an accepted hole. An attack record where nothing ever broke is a red flag — attacks run against a draft should find holes; if none did, rerun the pass as falsification, preferably in a fresh subagent context.
45
53
 
46
54
  ## Planning Terms
47
55
 
@@ -53,6 +61,16 @@ A side-effect boundary is the edge where deterministic program decisions meet fi
53
61
 
54
62
  A contract is the stable promise one code unit exposes to another, including accepted inputs, returned outputs, errors, timing expectations, and side effects that callers may rely on.
55
63
 
64
+ An invariant is a property of the changed system that must hold at every observable moment; what makes it load-bearing is that attacks are judged against it and the final verdict is derived from whether it survives them all.
65
+
66
+ A premise is a numbered, source-cited statement of fact about the current code; what makes it a premise rather than a note is that steps and defenses cite it by ID, so a false premise is traceable to everything built on it.
67
+
68
+ A state-authority premise is a premise that enumerates the complete writer and reader sets of one shared state surface; what makes it powerful is that "complete" is falsifiable with `refs` and `dataflow`, turning a forgotten write path from an unknowable into a checkable omission.
69
+
70
+ A counterexample attack is a concrete actor, starting state, and action sequence constructed to violate an invariant; what makes it evidence is that its defense cites premises and steps, so "we considered failure" becomes "this specific failure is blocked here."
71
+
72
+ An enforcement window is the interval between the step that installs an invariant enforcer and the step that brings the last existing writer into compliance; what makes it dangerous is that during it, every unupdated writer fails the new check in production, so the plan that adds safety is itself the outage.
73
+
56
74
  ## Workflow
57
75
 
58
76
  ### 1. Discover
@@ -64,22 +82,50 @@ scip-query status --capabilities
64
82
  scip-query plan-context <target>
65
83
  ```
66
84
 
67
- Use the shared reference for follow-up commands. Fill three gates before designing:
85
+ Use the shared reference for follow-up commands. Fill four gates before designing:
68
86
 
69
87
  ```markdown
70
88
  ## Goal
71
89
  What the user is trying to accomplish and what done looks like for them.
72
90
 
91
+ ## Definitions & Invariants
92
+ For each load-bearing concept: its wider class, then the one trait that causally
93
+ explains its other traits in this codebase — with the referents. Then the
94
+ invariants the change must preserve, in iff / must-always form.
95
+
73
96
  ## Current State
74
- The affected end-to-end flow, with scip-query citations for entry points, callers, data flow, dependencies, downstream impact, and non-obvious invariants.
97
+ A short narrative of the affected end-to-end flow. Every factual sentence
98
+ cites a premise by ID.
75
99
 
76
100
  ## Reuse Audit
77
- For every new symbol or file being considered: reuse target, extension target, or evidence-backed reason new code is justified.
101
+ For every new symbol or file being considered: reuse target, extension target,
102
+ or evidence-backed reason new code is justified.
78
103
  ```
79
104
 
80
- This step is complete only when the plan can explain the current flow, its consumers, and every proposed new unit's reuse decision with citations.
105
+ Definition discipline: place the concept in its wider class, then name the essential trait the one that makes the concept's other traits in this codebase possible and explains them. Do not label genus or differentia; write it as prose. Ban circular and synonym definitions ("the refresh coordinator coordinates refreshes" defines nothing). Any new term the plan introduces gets defined the same way. Good definitions condense: they imply the concept's other traits instead of listing them, and derived requirements fall out of them — if restore is defined as the inverse of cancel, then the privilege to restore must not be weaker than the privilege to cancel, and a plan that gates them asymmetrically must defend that asymmetry.
106
+
107
+ This step is complete only when the concepts are defined with referents, the invariants are stated formally, and every proposed new unit has a reuse decision with citations.
108
+
109
+ ### 2. Establish Premises
81
110
 
82
- ### 2. Shape for Tests
111
+ Number every fact the plan depends on:
112
+
113
+ ```markdown
114
+ ## Premises
115
+
116
+ - P1. <current behavior fact> — Source: `scip-query code <symbol>`
117
+ - P2. Writers of `<state surface>`: <complete list>. Readers: <complete list>.
118
+ — Source: `scip-query refs <symbol>` + `scip-query dataflow <symbol>`
119
+ - P3. ASSUMPTION: <belief the evidence cannot yet confirm, and what would confirm it>
120
+ ```
121
+
122
+ State-authority rule: for every state surface the plan touches — database column, store field, event topic, endpoint, cache entry — write one premise enumerating its complete writer and reader sets. Completeness comes from `refs` and `dataflow`, not memory.
123
+
124
+ Why this premise class exists: a sprint-restore plan hardened `restore()` and the cancellation path but never enumerated the writers of sprint status. Review found `PATCH /sprints/:id` could set `status: 'active'` around every restore invariant, and transition automations wrote `sprintId` straight past the new membership guard — two of that review's five ship-blockers, both sitting in the writer list one `refs` call would have produced. With a state-authority premise, each writer in the list must be visited by an attack; without it, the side doors are invisible until review.
125
+
126
+ This step is complete only when every state surface named in any phase has a state-authority premise and every remaining unknown is an explicit `ASSUMPTION`.
127
+
128
+ ### 3. Shape for Tests
83
129
 
84
130
  Before writing implementation phases, add:
85
131
 
@@ -101,7 +147,7 @@ Plan the code so tests can call the pure core directly and exercise the side-eff
101
147
 
102
148
  This step is complete only when every changed behavior has a named test seam and the plan makes clear which logic can be tested without real external services.
103
149
 
104
- ### 3. Design the Checklist
150
+ ### 4. Design the Checklist
105
151
 
106
152
  Write phases in execution order. Keep each phase deployable or explicitly mark why it is not. Use this step format:
107
153
 
@@ -109,7 +155,8 @@ Write phases in execution order. Keep each phase deployable or explicitly mark w
109
155
  ### N.M - Imperative title
110
156
 
111
157
  - [ ] **File**: `path/to/file.ts:LINE-LINE`
112
- - **Source**: `scip-query <command>`
158
+ - **Premises**: P<n>, P<m>
159
+ - **Deployable**: yes | no — <reason> | part of single-deploy group <name>
113
160
  - **What**: Current behavior verified from source.
114
161
  - **Change**: Exact edit to make.
115
162
  - **Testability**:
@@ -119,41 +166,59 @@ Write phases in execution order. Keep each phase deployable or explicitly mark w
119
166
  - Side-effect shell:
120
167
  - Contract:
121
168
  - **Validation**: Targeted test, smoke command, or manual check that proves the behavior.
122
- - **Why**: Why this step is needed and why this order is safe.
169
+ - **Why**: Why this step is needed and why this order is safe, citing the premises it rests on.
123
170
  ```
124
171
 
125
- This step is complete only when no checklist item says "update this file" without exact current behavior, target behavior, and validation.
172
+ If a step installs an enforcer trigger, constraint, guard, gate check its enforcement window here: every existing writer in the relevant state-authority premise is brought into compliance in the same or an earlier step, or the window is carried into the attack record as a hole to accept or repair.
173
+
174
+ This step is complete only when no checklist item says "update this file" without exact current behavior, target behavior, cited premises, a deployability declaration, and validation.
126
175
 
127
- ### 4. Stress-Test
176
+ ### 5. Attack the Plan
128
177
 
129
- Apply these lenses to every phase. Add or change steps until each answer is concrete:
178
+ Construct counterexamples against every invariant. This pass is falsification, not defense: it succeeds by finding holes, and against a draft it should find some. Prefer delegating it to a fresh subagent when the environment can spawn one — give the adversary only the Definitions & Invariants, Premises, state-authority maps, and the checklist, not your design rationale, and brief it that it wins by producing holes; fold its findings back as HOLE entries and repair steps. Solo fallback: enumerate the full attack list from the coverage-matrix rows below before writing any Outcome line, so attacks cannot be shaped around defenses you already have.
130
179
 
131
- | Lens | Plan must answer |
180
+ Use the lenses as attack prompts — purpose, blast radius, valid intermediate state, reversibility, failure, concurrency, boundaries, data integrity, observability, human experience, efficiency, reuse, testability — and record each attack in this form:
181
+
182
+ ```markdown
183
+ ### A<n>. <invariant> via <lens>
184
+ - Attack: <actor> + <starting state> + <action sequence>
185
+ - Outcome: HELD — defended by step <N.M> (P<i>, P<j>)
186
+ | HOLE — repaired by new step <N.M>
187
+ | HOLE — accepted: <reason>
188
+ ```
189
+
190
+ A `HELD` that cannot name its defending step and premises is not `HELD`; it is a hole wearing confidence. A repaired hole keeps its `HOLE — repaired by step N.M` label permanently — do not rewrite it to `HELD` after the repair, because the repair history is the evidence that the pass falsified. The verdict's repaired count must equal the number of `HOLE — repaired` entries in the record. Close the record with a coverage matrix — one row per writer in every state-authority premise and per applicable lens (valid intermediate state is always applicable when any step installs an enforcer or migration):
191
+
192
+ ```markdown
193
+ | Surface or lens | Attacks |
132
194
  | --- | --- |
133
- | Purpose | Why does the current code exist, and what invariant must survive? |
134
- | Blast radius | Which direct and transitive consumers move with this change? |
135
- | Valid intermediate state | Would the project still work after only this phase? |
136
- | Reversibility | Is this a one-way or two-way door, and what rollback exists? |
137
- | Failure | What happens when I/O, external APIs, malformed data, retries, or crashes occur? |
138
- | Concurrency | What shared state can be touched twice or out of order? |
139
- | Boundaries | Who can call this entry point, and where is input validated? |
140
- | Data integrity | What existing data, generated artifacts, or persisted contracts are affected? |
141
- | Observability | Can a maintainer diagnose failures from logs/errors without rereading the source? |
142
- | Human experience | What would surprise, confuse, or block a real user? |
143
- | Reuse | Does existing code already solve this problem or most of it? |
144
- | Testability | Are dependencies injectable, logic pure where practical, concerns separated, and contracts small? |
145
-
146
- This step is complete only when every discovered gap has either a new plan step or a written reason it is accepted.
147
-
148
- ### 5. Verify the Plan
195
+ | <writer, reader, or lens> | A2, A7 |
196
+ ```
197
+
198
+ A blank row is an unattacked writer. The record is incomplete until every row names an attack or carries an accepted reason. Spread attacks across rows before deepening one: depth on the axis you already anticipated does not protect the axes you did not — the leaks come from blank rows, not from the tenth variation of the race you already modeled.
199
+
200
+ Invalid entry this exact shape preceded three post-review remediation rounds on a real plan:
201
+
202
+ > **Concurrency**: Validation happens before database writes; no new shared mutable state or retry behavior is introduced.
203
+
204
+ It names no actor, no interleaving, and cites nothing. It is an assertion of absence: it cannot fail, so it caught nothing review later found exactly the race it waved away. A valid entry for the same phase:
205
+
206
+ > ### A3. "Every stored value is a member of its field's option set" via concurrency
207
+ > - Attack: admin removes option O in transaction A while a user writes value O in transaction B; interleaving B-validates → A-commits → B-commits persists an orphaned value.
208
+ > - Outcome: HOLE — repaired by new step 2.2: validation reads the option definition outside B's lock (P4), so serialize definition changes with every value writer via FOR UPDATE on the definition row; regression proves both interleavings against PostgreSQL.
209
+
210
+ This step is complete only when the coverage matrix has no blank rows and every attack entry ends in a cited `HELD` or a recorded `HOLE`.
211
+
212
+ ### 6. Verify the Plan and Derive the Verdict
149
213
 
150
214
  Run or delegate phase-by-phase reference checks. Each verifier confirms:
151
215
 
152
216
  - every path exists;
153
217
  - every line range is still within about five lines;
218
+ - every premise reproduces when its `Source` command is rerun — a premise that no longer reproduces is false, and everything citing it is suspect until fixed;
154
219
  - every behavior claim matches source;
155
220
  - every new unit has reuse evidence;
156
- - every behavior-changing step has a validation command and testability design.
221
+ - every behavior-changing step has cited premises, a validation command, and a testability design.
157
222
 
158
223
  Then rerun the source-producing context for the cited targets:
159
224
 
@@ -161,9 +226,22 @@ Then rerun the source-producing context for the cited targets:
161
226
  scip-query plan-context <target>
162
227
  ```
163
228
 
164
- Use the shared reference for subagent briefing text when delegating.
229
+ Use the shared reference for subagent briefing text when delegating. Close the plan by applying the definitions to the record — do not summarize feelings:
230
+
231
+ ```markdown
232
+ ## Verdict
233
+
234
+ A plan is PLANNED-COMPLETE iff the coverage matrix has no blank rows, every
235
+ attack ends in HELD with cited steps and premises or an accepted hole with a
236
+ written reason, and no premise failed reverification.
237
+
238
+ Result: PLANNED-COMPLETE | INCOMPLETE — <n> attacks, <x> holes repaired,
239
+ <y> holes accepted; <unresolved items>
240
+ ```
241
+
242
+ The counts are part of the verdict. "16 attacks, 0 holes repaired" against a fresh draft is not a strong plan; it is an attack pass that defended instead of falsified — rerun it before shipping the plan.
165
243
 
166
- This step is complete only when stale references are fixed and every phase has a validation path.
244
+ This step is complete only when stale references are fixed, every premise reverified, and the verdict line is derived from the attack record.
167
245
 
168
246
  ## Output Shape
169
247
 
@@ -171,11 +249,14 @@ The plan file contains:
171
249
 
172
250
  1. Title and date.
173
251
  2. Goal.
174
- 3. Current State.
175
- 4. Reuse Audit.
176
- 5. Testability Design.
177
- 6. Design Phases.
178
- 7. Stress-Test Findings.
179
- 8. Execution Order and deployable phase notes.
180
- 9. Ship Order with one-way doors flagged.
181
- 10. Summary of files to create, edit, delete, and verify.
252
+ 3. Definitions & Invariants.
253
+ 4. Premises (including state-authority premises and explicit assumptions).
254
+ 5. Current State (narrative citing premise IDs).
255
+ 6. Reuse Audit.
256
+ 7. Testability Design.
257
+ 8. Design Phases (steps citing premises, each with a deployability declaration).
258
+ 9. Attack Record (attacks with outcomes, holes repaired or accepted, coverage matrix).
259
+ 10. Execution Order and deployable phase notes.
260
+ 11. Ship Order with one-way doors flagged.
261
+ 12. Verdict with attack and hole counts.
262
+ 13. Summary of files to create, edit, delete, and verify.
@@ -43,6 +43,7 @@ Use this shortlist first. Open [`../_shared/SKILL.md`](../_shared/SKILL.md) only
43
43
  2. Use scip-query to find entry points, call paths, data flow, and blast radius.
44
44
  3. Prefer one narrow fix over broad cleanup.
45
45
  4. Verify with the narrowest repo test or smoke command, then invoke `scip-verify`.
46
+ 5. A root-cause claim whose fix crosses a file boundary requires a rival: state the next-most-plausible explanation for the same symptom and run the observation that separates them. A root cause with no rival considered is a guess with confidence.
46
47
 
47
48
  ## Workflow
48
49
 
@@ -82,6 +83,8 @@ scip-query slice <symbol-or-variable> --forward
82
83
 
83
84
  Stop expanding when the first code fact that can cause the symptom is found.
84
85
 
86
+ When a candidate cause emerges, state it as a hypothesis alongside one rival — the next-most-plausible explanation for the same symptom. Name the observation that distinguishes them (a log line, a probe, a narrower test) and execute it. Choose the discriminator that is cheapest to run, not the one most likely to confirm.
87
+
85
88
  This step is complete only when the path explains the symptom or the missing evidence is explicit.
86
89
 
87
90
  ### 4. Compare nearby implementations
@@ -117,9 +120,11 @@ Run the reproduction, narrow test or smoke command, and invoke `scip-verify`.
117
120
  Bug:
118
121
  Entry point:
119
122
  Root cause:
123
+ Rival considered:
124
+ Discriminator: <the executed observation that separated them>
120
125
  Fix:
121
126
  Verification:
122
127
  Remaining risk:
123
128
  ```
124
129
 
125
- Do not present a guess as a root cause. If no root cause is proven, report the missing evidence.
130
+ Do not present a guess as a root cause. A root cause with no rival considered and no executed discriminator is a guess. If no root cause is proven, report the missing evidence.
@@ -44,6 +44,7 @@ Use this shortlist first. Open [`../_shared/SKILL.md`](../_shared/SKILL.md) only
44
44
  3. Read source with `scip-query code`; do not describe what a function probably does.
45
45
  4. Follow the graph before trusting folder structure.
46
46
  5. Start wide, then narrow.
47
+ 6. Descriptions need citations; conclusions need discriminators. A conclusion — why something happens, what a unit is for, which intent explains a shape — states one rival explanation and the trace evidence that rules it out.
47
48
 
48
49
  ## Workflow
49
50
 
@@ -117,4 +118,4 @@ This step is complete only when the explanation includes the risky symbols or st
117
118
 
118
119
  ## Report
119
120
 
120
- Report overview, entry points, call flow, data flow, dependencies, consumers, risk areas, and the command citations that prove each claim. Exploration is complete only when the user can see what was proven and what remains unverified.
121
+ Report overview, entry points, call flow, data flow, dependencies, consumers, risk areas, and the command citations that prove each claim. For each conclusion-bearing claim, name the rival explanation considered and the evidence that ruled it out. Exploration is complete only when the user can see what was proven, what remains unverified, and which conclusions rest on a discriminator rather than a single story.
@@ -43,6 +43,12 @@ validates (checkers, gates, verifiers, validators — find producers with
43
43
  an input that MUST fail — a wrong binding, a corrupt file, an impossible
44
44
  value — and run it. A checker that passes its should-fail input is
45
45
  decorative: file it as a defect, not a note.
46
+ Before filing, attempt the defense: an accusation triggers a rewrite, so
47
+ search for the failure exit the drill may have missed — a config-gated
48
+ branch, an async rejection, one-hop delegation (the calibration's known
49
+ noise archetypes). File the defect with the executed should-fail input
50
+ attached and the defense attempt noted; a defense that succeeds clears the
51
+ checker and stays in the record as its witness.
46
52
  Complete only when every checker in scope has been witnessed rejecting a
47
53
  constructed should-fail input, or is listed with a reason it cannot be.
48
54
 
@@ -121,6 +127,17 @@ the fix. The audit is complete only when every drill's exit criterion is
121
127
  met for the scope, and every defect found has a regression artifact — a
122
128
  test, fixture, or model that fails on the pre-fix behavior.
123
129
 
130
+ End with a derived verdict, not an impression:
131
+
132
+ ```markdown
133
+ Integrity: <scope> — <c> checkers witnessed failing, <a> adapters diffed
134
+ against reality, <f> fallback primaries witnessed live, <m> metrics
135
+ recomputed, <t> twins compared; <d> defects filed, <u> unverifiable (reasons)
136
+ ```
137
+
138
+ A suspect scope that produces zero defects is itself a claim: state what
139
+ made the suspicion wrong, or rerun the drill that should have caught it.
140
+
124
141
  A regression artifact that doesn't actually assert anything, or asserts the
125
142
  same literal it stubbed into its own mock, is a fake witness — the same
126
143
  "reports success without doing the work" failure mode this skill hunts in
@@ -53,6 +53,8 @@ Essential variation is difference that must remain because the real units differ
53
53
 
54
54
  System compression is replacing several mechanisms that perform the same role, policy, lifecycle, or surface job with fewer named mechanisms that preserve behavior.
55
55
 
56
+ A unifying definition is the single essential trait that makes several code sites one concept; what makes it a test is that failing to state it proves the sites are not one concept, and consolidating them anyway would package-deal essential variation into a false abstraction.
57
+
56
58
  ## Rules
57
59
 
58
60
  1. Ground claims in files, symbols, references, call graphs, dependencies, surfaces, and blast radius.
@@ -61,6 +63,7 @@ System compression is replacing several mechanisms that perform the same role, p
61
63
  4. Preserve essential variation.
62
64
  5. Add an abstraction only when it removes hidden policy, names a lifecycle, enforces a rule, or reduces concept count.
63
65
  6. Prefer deletion, inlining, merging, generation, or enforcement before broad frameworks.
66
+ 7. A scattered-concept or consolidation claim ships its unifying definition. If no single essential trait covers every cited site, the variation is essential: record it and do not consolidate.
64
67
 
65
68
  ## Workflow
66
69
 
@@ -100,7 +103,7 @@ This step is complete only when concrete units, consumers, tests, fallbacks, ada
100
103
 
101
104
  For each cluster, ask:
102
105
 
103
- - What one concept appears in several places?
106
+ - What one concept appears in several places — and what single essential trait makes them one concept? If the trait cannot be stated, they are not one concept.
104
107
  - What policy is hidden?
105
108
  - What lifecycle is unnamed?
106
109
  - Which differences are essential?
@@ -144,6 +147,8 @@ For broad review, write a register under `docs/plans/` unless the user asks not
144
147
 
145
148
  Use dispositions: `merge`, `delete`, `inline`, `extract`, `generate`, `enforce`, `supersede`, `defer`, `skip`.
146
149
 
150
+ Every `merge`, `extract`, or `generate` entry carries its unifying definition and its strongest dissenter — the cited site most likely to differ essentially — with the evidence that it does not. A dissenter that survives moves the entry to `skip` with reason `essential variation`; the dissenter stays in the register either way.
151
+
147
152
  This step is complete only when each opportunity has evidence, disposition, dependency order, touch map, and validation plan.
148
153
 
149
154
  ### 7. Implement and verify when asked
@@ -44,6 +44,7 @@ The loop is complete only when `scip-verify` passes or each remaining finding ha
44
44
  | --- | --- | --- |
45
45
  | Understand a system before answering or editing | `scip-explore` | `system`, `trace`, `call-graph`, `dataflow` |
46
46
  | Root-cause a bug or regression | `scip-debug` | `trace`, `dataflow`, `change-surface` |
47
+ | Diagnose the design flaw behind a family of recurring bugs | `scip-root-cause` | `co-change`, `similar`, `refs` |
47
48
  | Turn a report into a fix packet | `scip-triage-issue` | `files`, `trace`, `affected` |
48
49
  | Create a code flow, dependency, or blast-radius diagram | `scip-diagram` | `call-graph`, `dataflow`, `affected` |
49
50
  | Plan a feature, fix, or refactor | `scip-concrete-plan` | `plan-context` |
@@ -72,6 +73,7 @@ Routing is complete only when one owning skill is selected or the task is small
72
73
 
73
74
  - "Is this implementation real / does it actually work" → `scip-integrity-audit`; "is this well-organized" → `scip-maintainability`; same-name drifted twins specifically → `scip-twin-drift`.
74
75
  - One change → `scip-concrete-plan`; a program of changes with delegation → `scip-conductor`.
76
+ - One failing behavior → `scip-debug`; a family of similar bugs whose fixes keep recurring, or "what is really wrong with this system" backed by bug history → `scip-root-cause`; structure smells with no bug evidence → `scip-maintainability`.
75
77
 
76
78
  - Use `scip-cleanup-audit` for reports, ranking, confirmation, or recent AI-residue triage without edits.
77
79
  - Use `scip-cleanup-improve` when the user asks to fix, improve, continue cleaning, or raise health autonomously.
@@ -105,6 +107,7 @@ Top commands per routed skill, generated from each skill's own `commands:` front
105
107
  | `scip-maintainability` | `scip-query stats`, `scip-query system <scope>`, `scip-query surface <scope>` |
106
108
  | `scip-probe-reachability` | `scip-query outline <file> --signatures`, `scip-query code <symbol>`, `scip-query trace <symbol>` |
107
109
  | `scip-react-maintainability` | `scip-query react-component-duplicates --scope <scope> --full --json`, `scip-query react-hook-candidates --scope <scope> --full --json`, `scip-query react-large-component-pressure --scope <scope> --full --json` |
110
+ | `scip-root-cause` | `scip-query trace <mechanism-symbol>`, `scip-query co-change <fix-site-file>`, `scip-query system <system-scope>` |
108
111
  | `scip-setup` | `scip-query setup --json`, `scip-query doctor`, `scip-query status --json` |
109
112
  | `scip-tla-model-system` | `scip-query tla scaffold <file>`, `scip-query tla verify <spec>`, `scip-query tla instrument <spec>` |
110
113
  | `scip-triage-issue` | `scip-query files <issue-term>`, `scip-query trace <entry-or-error-symbol>`, `scip-query code <entry-or-error-symbol>` |