elastic / elastic/ai-github-actions
[framework-best-practices] Fix prompt extractor to parse current lockfile prompt blocks
- Dominant language
- Python
- Stars
- 11
- Forks
- 16
- Avg merge
- 22h 9m
- Merged PRs (30d)
- 31
Description
## Framework / Library Best Practices Findings
### 1. Prompt-audit extraction relies on brittle text parsing instead of YAML parsing
**Library:** PyYAML (`pyyaml>=6.0`, declared in `pyproject.toml` optional dependencies)
**Library feature:** `yaml.safe_load` for structured YAML parsing instead of regex/awk state machines over raw YAML text.
**Current code:**
- `scripts/extract-lockfile-prompts.sh:53` matches only runtime includes at `/opt/gh-aw/prompts/...`
- `scripts/extract-lockfile-prompts.sh:66` and `scripts/extract-lockfile-prompts.sh:72` assume a fixed heredoc marker `GH_AW_PROMPT_EOF`
- Current lockfiles use different generated text:
- `.github/workflows/gh-aw-framework-best-practices.lock.yml:224-227` includes `cat "\$\{RUNNER_TEMP}/gh-aw/prompts/..."`
- `.github/workflows/gh-aw-framework-best-practices.lock.yml:221` and `:228` use hashed markers like `GH_AW_PROMPT_adf247ff0e47d28f_EOF`
- Workflow impact path:
- `.github/workflows/trigger-prompt-audit.yml:20` runs `scripts/extract-lockfile-prompts.sh`
- The script currently reports `Extracted prompts from 0 lockfiles` when run against `.github/workflows`
**Simplification:**
Replace the brittle awk parser with a small Python extractor that reads lockfiles as YAML and inspects the `jobs.*.steps[*].run` block for the "Create prompt" step. Parse heredoc segments and runtime includes from that run script in a way that accepts `\$\{RUNNER_TEMP}` and hashed `GH_AW_PROMPT_*_EOF` markers.
This uses a stable parser API already present in the project dependencies and removes path/sentinel assumptions that are now stale.
**Documentation:**
- (pyyaml.org/redacted)
## Suggested Actions
- [ ] Replace `scripts/extract-lockfile-prompts.sh` with a YAML-based extractor (or keep shell wrapper that calls Python) using `yaml.safe_load`.
- [ ] Match dynamic prompt includes (`\$\{RUNNER_TEMP}/gh-aw/prompts/...`) and dynamic heredoc delimiters (`GH_AW_PROMPT_*_EOF`) instead of fixed literals.
- [ ] Add a regression test fixture for at least one current `.lock.yml` prompt block to ensure extraction never regresses to zero files.
> [!NOTE]
>
> 🔒 Integrity filter blocked 5 items
>
> The following items were blocked because they don't meet the GitHub integrity level.
>
> - [#694](https://github.com/elastic/ai-github-actions/issues/694) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#875](https://github.com/elastic/ai-github-actions/issues/875) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#238](https://github.com/elastic/ai-github-actions/issues/238) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#466](https://github.com/elastic/ai-github-actions/issues/466) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#336](https://github.com/elastic/ai-github-actions/issues/336) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
>
> To allow these resources, lower `min-integrity` in your GitHub frontmatter:
>
> ```yaml
> tools:
> github:
> min-integrity: approved # merged | approved | unapproved | none
> ```
>
>
---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Trigger Framework Best Practices](https://github.com/elastic/ai-github-actions/actions/runs/26826412863)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
Contributor guide
Assessment
This issue has not been assessed yet.