- DAG architecture: `dag show/validate/export` (nulib/main_provisioning/dag.nu),
config loader (lib_provisioning/config/loader/dag.nu), taskserv dag-executor.
Backed by schemas/lib/dag/*.ncl; orchestrator emits NATS events via
WorkspaceComposition::into_workflow. See ADR-020, ADR-021.
- Unified Component Architecture: components/mod.nu, main_provisioning/
{components,workflow,extensions,ontoref-queries}.nu. Full workflow engine with
topological sort and NATS subject emission. Blocks A-H complete (libre-daoshi).
- Commands-registry: nulib/commands-registry.ncl (Nickel source, 314 lines) +
JSON cache at ~/.cache/provisioning/commands-registry.json rebuilt on source
change. cli/provisioning fast-path alias expansion avoids cold Nu startup.
ADDING_COMMANDS.md documents new-command workflow.
- Platform service manager: service-manager.nu (+573), startup.nu (+611),
service-check.nu (+255); autostart/bootstrap/health/target refactored.
- Nushell 0.112.2 migration: removed all try/catch and bash redirections;
external commands prefixed with ^; type signatures enforced. Driven by
scripts/refactor-try-catch{,-simplified}.nu.
- TTY stack: removed shlib/*-tty.sh; replaced by cli/tty-dispatch.sh,
tty-filter.sh, tty-commands.conf.
- New domain modules: images/ (golden image lifecycle), workspace/{state,sync}.nu,
main_provisioning/{bootstrap,cluster-deploy,fip,state}.nu, commands/{state,
build,integrations/auth,utilities/alias}.nu, platform.nu expanded (+874).
- Config loader overhaul: loader/core.nu slimmed (-759), cache/core.nu
refactored (-454), removed legacy loaders/file_loader.nu (-330).
- Thirteen new provisioning-<domain>.nu top-level modules for bash dispatcher.
- Tests: test_workspace_state.nu (+351); updates to test_oci_registry,
test_services.
- README + CHANGELOG updated.
53 lines
1.8 KiB
Text
Executable file
53 lines
1.8 KiB
Text
Executable file
#!/usr/bin/env nu
|
|
# Validate if a command exists in commands-registry.ncl
|
|
# Returns: FOUND|true/false or NOT_FOUND
|
|
#
|
|
# Cache: exports registry to ~/.cache/provisioning/commands-registry.json
|
|
# and reuses it until commands-registry.ncl changes (mtime check).
|
|
# Typical cold start: ~2s (nickel export). Warm: <50ms (JSON read).
|
|
|
|
def main [
|
|
command_name: string
|
|
]: nothing -> nothing {
|
|
let registry_file = ($env.PROVISIONING | path join "core/nulib/commands-registry.ncl")
|
|
let cache_dir = ($env.HOME | path join ".cache" | path join "provisioning")
|
|
let cache_file = ($cache_dir | path join "commands-registry.json")
|
|
|
|
# Determine if cache is valid (exists and newer than source)
|
|
let registry_mtime = (ls $registry_file | get 0.modified)
|
|
let use_cache = if ($cache_file | path exists) {
|
|
let cache_mtime = (ls $cache_file | get 0.modified)
|
|
$cache_mtime > $registry_mtime
|
|
} else { false }
|
|
|
|
# Load or rebuild
|
|
let registry_json = if $use_cache {
|
|
open --raw $cache_file
|
|
} else {
|
|
let prov = ($env.PROVISIONING? | default "/usr/local/provisioning")
|
|
let result = (do {
|
|
^nickel export --format json --import-path $prov $registry_file
|
|
} | complete)
|
|
if $result.exit_code != 0 {
|
|
print "ERROR: Failed to export commands-registry.ncl" >&2
|
|
exit 1
|
|
}
|
|
^mkdir -p $cache_dir
|
|
$result.stdout | save --force $cache_file
|
|
$result.stdout
|
|
}
|
|
|
|
let commands = ($registry_json | from json | get -o commands | default [])
|
|
|
|
let matches = ($commands | where {|cmd|
|
|
let all = ([$cmd.command] | append ($cmd | get -o aliases | default []))
|
|
$command_name in $all
|
|
})
|
|
|
|
if ($matches | is-empty) {
|
|
print "NOT_FOUND"
|
|
} else {
|
|
let m = ($matches | first)
|
|
print $"FOUND|($m | get -o requires_daemon | default false)"
|
|
}
|
|
}
|