The full scope across this batch: POST /sessions key→token exchange, SessionStore dual-index with revoke_by_id, CLI Bearer injection (ONTOREF_TOKEN), ontoref setup --gen-keys, install scripts, daemon config form roundtrip, ADR-004/005, on+re self-description update (fully-self-described), and landing page refresh.
45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
#!/usr/bin/env nu
|
|
# install/hooks/post-merge — ontoref attribution hook.
|
|
#
|
|
# Installed by: ontoref init (copies to .git/hooks/post-merge and chmod +x)
|
|
# Triggered by: git merge, git pull --merge
|
|
#
|
|
# Purpose: notify the running daemon which NCL files changed and who caused it,
|
|
# so multi-actor coordination UIs can show attribution instead of "unknown source".
|
|
# Silently exits when the daemon is not running or ONTOREF_TOKEN is not set.
|
|
|
|
let token = ($env.ONTOREF_TOKEN? | default "")
|
|
if ($token | is-empty) { exit 0 }
|
|
|
|
let daemon_url = ($env.ONTOREF_DAEMON_URL? | default "http://127.0.0.1:7891")
|
|
|
|
# Collect NCL files that changed in this merge relative to ORIG_HEAD.
|
|
let changed = (
|
|
do { ^git diff-tree --no-commit-id -r --name-only HEAD } | complete
|
|
| if $in.exit_code == 0 { $in.stdout | lines } else { [] }
|
|
| where { |f| ($f | str ends-with ".ncl") or ($f | str ends-with ".jsonl") }
|
|
| where { |f|
|
|
($f | str starts-with ".ontology/")
|
|
or ($f | str starts-with "adrs/")
|
|
or ($f | str starts-with "reflection/")
|
|
}
|
|
)
|
|
|
|
if ($changed | is-empty) { exit 0 }
|
|
|
|
let body = { token: $token, files: $changed } | to json
|
|
|
|
let result = (
|
|
do {
|
|
^curl -sf -X POST
|
|
-H "Content-Type: application/json"
|
|
-d $body
|
|
$"($daemon_url)/ontology/changed"
|
|
} | complete
|
|
)
|
|
|
|
if $result.exit_code == 0 {
|
|
print $" ontoref: attributed ($changed | length) NCL file(s) to actor ($token)"
|
|
}
|
|
# Silent on failure — daemon may not be running, which is fine.
|