Keep declare→ResolveSchemaBuild as the ToolSpec authority, but materialize map[cli_path]CommandMeta during deliverySchemaCatalog sync.Once so leaf --help / ResolveMeta are O(1) after the first Schema touch. Defer wire Catalog/Tools maps, stamp Source as runtime-assembled, drop committed catalog/gob fixtures, and cover steady-state reuse with app/cli tests. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.2 KiB
Bash
Executable File
36 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# Assemble a fresh Schema Catalog via ResolveSchemaBuild (cmd_schema_catalog)
|
|
# into a temp directory, then emit the single-document JSON shape
|
|
# (version + surface_hash + source_hash + catalog + tools) that policy jq
|
|
# queries consume.
|
|
#
|
|
# Production reads runtime assembly only; this helper creates an ephemeral
|
|
# Catalog dump exclusively for CI/policy queries.
|
|
set -eu
|
|
|
|
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)"
|
|
cd "$ROOT"
|
|
. "$ROOT/scripts/policy/policy-runtime.sh"
|
|
policy_prepare_runtime "$ROOT"
|
|
|
|
tmp="$(mktemp -d)"
|
|
exec_tmp="$(policy_runtime_mktemp_dir dws-with-catalog)"
|
|
catalog_generator="$exec_tmp/schema-catalog"
|
|
trap 'rm -rf "$tmp" "$exec_tmp"' EXIT HUP INT TERM
|
|
|
|
go build -a -o "$catalog_generator" ./internal/generator/cmd_schema_catalog
|
|
dir="$tmp/schema_catalog"
|
|
"$catalog_generator" -root . -output "$dir" -meta-index "$tmp/schema_meta_index.gob" >/dev/null
|
|
|
|
jq -s '
|
|
.[0] as $envelope |
|
|
($envelope.surface_hash // null) as $surface |
|
|
{
|
|
version: $envelope.version,
|
|
source_hash: $envelope.source_hash,
|
|
catalog: $envelope.catalog,
|
|
tools: (reduce .[1:][] as $shard ({}; . + ($shard.tools // {})))
|
|
} +
|
|
(if $surface then {surface_hash: $surface} else {} end)
|
|
' "$dir/catalog.json" "$dir"/tools/*.json
|