chore(prompts): host fallback build and minimal manifest parser (no PyYAML)
Some checks are pending
CI / checks (push) Waiting to run
Some checks are pending
CI / checks (push) Waiting to run
This commit is contained in:
@@ -1,9 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
import os, sys, yaml
|
||||
import os, sys
|
||||
|
||||
def load_manifest(path):
|
||||
# Minimal YAML parser for our simple manifests:
|
||||
# keys: name (ignored), include: [..], modules: [..]
|
||||
data = {"include": [], "modules": []}
|
||||
key = None
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
return yaml.safe_load(f)
|
||||
for raw in f:
|
||||
line = raw.rstrip('\n')
|
||||
s = line.strip()
|
||||
if not s or s.startswith('#'):
|
||||
continue
|
||||
if s.startswith('include:'):
|
||||
key = 'include'
|
||||
continue
|
||||
if s.startswith('modules:'):
|
||||
key = 'modules'
|
||||
continue
|
||||
if s.startswith('name:'):
|
||||
key = None
|
||||
continue
|
||||
# list item under current key
|
||||
if key in ('include', 'modules') and s.startswith('- '):
|
||||
item = s[2:].strip()
|
||||
data[key].append(item)
|
||||
return data
|
||||
|
||||
def resolve(path, seen):
|
||||
m = load_manifest(path)
|
||||
@@ -28,6 +50,7 @@ def main():
|
||||
if not mods:
|
||||
print(f"No modules resolved from {manifest}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if out_path != '-':
|
||||
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
||||
def read(p):
|
||||
with open(p, 'r', encoding='utf-8') as f:
|
||||
|
@@ -31,7 +31,11 @@ build_manifest() {
|
||||
# Write on host to avoid ownership issues; container prints to stdout.
|
||||
TMP_OUT=$(mktemp)
|
||||
trap '[[ -n "${TMP_OUT:-}" ]] && rm -f "$TMP_OUT"' EXIT
|
||||
ci_run "python3 scripts/prompt_build.py '$manifest' -" >"$TMP_OUT"
|
||||
ci_run "python3 scripts/prompt_build.py '$manifest' -" >"$TMP_OUT" || true
|
||||
# Fallback: if container produced no output, run on host
|
||||
if [[ ! -s "$TMP_OUT" ]]; then
|
||||
python3 scripts/prompt_build.py "$manifest" - >"$TMP_OUT"
|
||||
fi
|
||||
mkdir -p "$(dirname "$out")"
|
||||
mv "$TMP_OUT" "$out"
|
||||
}
|
||||
|
Reference in New Issue
Block a user