import io, re

p = r'C:\Users\decid\Documents\projects\spt-claude-code\tools\claude-spt\src\hook.rs'
s = io.open(p, encoding='utf-8').read()
NL = chr(10)


def cut_between(a, b, repl=''):
    global s
    ia = s.index(a)
    ib = s.index(b, ia)
    s = s[:ia] + repl + s[ib:]


# ---- Stop leg: the whole confirm block, from the doc paragraph through the closing brace ---------
a = '    // [impl->REQ-HAZARD-TAG-STOP-SCAN-EARLY] The byte cursor still dedups vs the mid-turn scan.'
b = '    // ACROSS-CLEAR QUIET WINDOW: the turn that armed the wake ends HERE'
new_stop = '''    // [impl->REQ-HAZARD-TAG-STOP-SCAN-EARLY] The byte cursor still dedups vs the mid-turn scan, and
    // the settle is now load-bearing for the PAYLOAD rather than for a dispatch: it is what makes the
    // turn's closing text present in the batch this scan returns, which `batch_payload` then reports.
    //
    // THE CONFIRM SURFACE THAT USED TO LIVE HERE IS GONE. A turn-end tag confirm parked in adapter
    // state for the author's next hook, and a confirm carrying a FAILURE was self-sent as a normal
    // message so it could wake an idle author. Both were ours, and both are retired with the local
    // parser: spt-core reports per-target outcomes through the now-signal's DISPATCH_RESULTS
    // category, which it documents as "the only channel, by design - a dispatch does not echo into
    // your output, does not reply to you, and does not print a confirmation line, because a second
    // channel is how an author ends up trusting whichever one they happened to notice." Keeping our
    // richer surface beside it would have been exactly that second channel.
    // [impl->REQ-IO-COMPLIANCE-DECLARED]
    let scan = scan_and_dispatch(env, &id, &sid, &field(v, "transcript_path"), true);
'''
cut_between(a, b, new_stop)

# ---- PreToolUse leg: tag_confirm binding + its surfacing ----------------------------------------
s = s.replace('    let tag_confirm = scan.confirm;' + NL, '')

io.open(p, 'w', encoding='utf-8', newline=NL).write(s)
print('stop confirm block removed; tag_confirm binding removed')
