harn-hostlib 0.10.199

Opt-in code-intelligence and deterministic-tool host builtins for the Harn VM
import { with_llm_script } from "std/testing"

fn main(harness: Harness) {
  if argv[1] != "skip" {
    const rebuilt = harness.code_index.rebuild({root: argv[0]})
    require rebuilt.files_indexed == 1, "Rebuild must index the fixture file"
  }
  const found = harness.code_index.query({needle: "replay_index_sentinel"})
  require len(found.results) == 1, "Index query must return one fixture match"
  const hit = found.results[0]
  if hit == nil {
    throw "Index query must retain its fixture match"
  }
  require hit.path == "indexed.rs", "Index query must return the recorded fixture path"
  with_llm_script(
    harness.llm,
    [{text: "recorded", model: "mock"}],
    { ->
      const reply = harness.llm.call(
        json_stringify(found.results),
        nil,
        {provider: "mock", model: "mock"},
      )
      require reply.text == "recorded", "Replay must retain the recorded model reply"
    },
  )
  harness.stdio.println(json_stringify({matches: len(found.results), path: hit.path}))
}