From 8b203fbdb5d0f45a7b3172f801cfd1281c993229 Mon Sep 17 00:00:00 2001 From: ReachableCEO Date: Thu, 11 Sep 2025 07:27:55 -0500 Subject: [PATCH] chore(prompts): host fallback build and minimal manifest parser (no PyYAML) --- scripts/prompt_build.py | 29 ++++++++++++++++++++++++++--- scripts/prompts | 6 +++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/scripts/prompt_build.py b/scripts/prompt_build.py index 60353c6..9c7e20d 100644 --- a/scripts/prompt_build.py +++ b/scripts/prompt_build.py @@ -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,7 +50,8 @@ def main(): if not mods: print(f"No modules resolved from {manifest}", file=sys.stderr) 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): with open(p, 'r', encoding='utf-8') as f: return f.read().strip() + "\n\n" diff --git a/scripts/prompts b/scripts/prompts index c5a3930..2a0b98f 100755 --- a/scripts/prompts +++ b/scripts/prompts @@ -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" }