resolve-spill-command.mjs 980 B

123456789101112131415161718192021
  1. /** Resolve the exact query-spill verification command through this run's filesystem locator map. */
  2. export const name = 'query-spill-verification-path'
  3. export const inject = ['shell', 'fs']
  4. /** Translate the physical command only; tool logging and approval keep the model-visible locator. */
  5. export function apply(ctx) {
  6. const shell = ctx.shell
  7. const fs = ctx.fs
  8. const run = shell.run
  9. const suffix = "; grep -Fq request/header \"$file\" && grep -Fq session_event_search \"$file\" && printf 'SPILL_CANONICAL_OK\\n'"
  10. ctx.effect(() => {
  11. shell.run = async (spec) => {
  12. const match = /^file="([^"]+)"/.exec(spec.command)
  13. if (match === null || spec.command !== match[0] + suffix) return run.call(shell, spec)
  14. const target = await fs.resolve(match[1])
  15. const path = fs.processPath(target).replaceAll("'", "'\"'\"'")
  16. return run.call(shell, { ...spec, command: "file='" + path + "'" + suffix })
  17. }
  18. return () => { shell.run = run }
  19. })
  20. }