chore(prompts): host fallback build and minimal manifest parser (no PyYAML)
Some checks are pending
CI / checks (push) Waiting to run

This commit is contained in:
2025-09-11 07:27:55 -05:00
parent 817a397522
commit 8b203fbdb5
2 changed files with 31 additions and 4 deletions

View File

@@ -1,9 +1,31 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os, sys, yaml import os, sys
def load_manifest(path): 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: 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): def resolve(path, seen):
m = load_manifest(path) m = load_manifest(path)
@@ -28,7 +50,8 @@ def main():
if not mods: if not mods:
print(f"No modules resolved from {manifest}", file=sys.stderr) print(f"No modules resolved from {manifest}", file=sys.stderr)
sys.exit(1) sys.exit(1)
os.makedirs(os.path.dirname(out_path), exist_ok=True) if out_path != '-':
os.makedirs(os.path.dirname(out_path), exist_ok=True)
def read(p): def read(p):
with open(p, 'r', encoding='utf-8') as f: with open(p, 'r', encoding='utf-8') as f:
return f.read().strip() + "\n\n" return f.read().strip() + "\n\n"

View File

@@ -31,7 +31,11 @@ build_manifest() {
# Write on host to avoid ownership issues; container prints to stdout. # Write on host to avoid ownership issues; container prints to stdout.
TMP_OUT=$(mktemp) TMP_OUT=$(mktemp)
trap '[[ -n "${TMP_OUT:-}" ]] && rm -f "$TMP_OUT"' EXIT 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")" mkdir -p "$(dirname "$out")"
mv "$TMP_OUT" "$out" mv "$TMP_OUT" "$out"
} }