feat: override merge mode for generate-context#47
feat: override merge mode for generate-context#47joshbouncesecurity wants to merge 6 commits intoknostic:masterfrom
Conversation
Add a standalone `openant generate-context` command so users can generate application_context.json as a discrete pipeline step when running individual commands (parse → generate-context → analyze → verify). Also wire up auto-discovery of application_context.json in both the Go CLI (project scan dir) and Python CLI (output dir, repo path, input file dir) so `analyze` and `verify` pick it up automatically without requiring `--app-context` every time. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: update PIPELINE_MANUAL.md for generate-context CLI command Update Step 4 to document the new `openant generate-context` command as the primary way to generate application context. Add note about auto-discovery in analyze/verify. Update examples and quick reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: update remaining docs for generate-context CLI command Update CURRENT_IMPLEMENTATION.md, README.md, and DOCUMENTATION.md to reference `openant generate-context` as the primary command and note the auto-discovery behavior in analyze/verify. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover the `_find_app_context` helper used by `analyze` and `verify` to locate application_context.json automatically when --app-context is not provided. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When a manual override file (OPENANT.md) is detected, users can now choose how to handle it: use as-is, merge into LLM context, or ignore. An interactive prompt appears by default; --override-mode flag bypasses it. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds unit tests for the override-mode functionality of generate-context: - test_override_mode.py: covers find_override_file() (none/found/priority), gather_context_sources() merge behavior, and the dispatch logic of generate_application_context() across "use", "ignore", "merge", and legacy force_regenerate paths. Also covers the Python CLI's argparse validation of --override-mode choices. - test_go_cli.py: extends TestGenerateContext with parametrized tests for each --override-mode value, an invalid-value rejection test, and a no-TTY default test ensuring the interactive prompt is suppressed when stdin is piped. Also wires run_cli() to default stdin to a closed pipe so subprocess tests don't accidentally inherit pytest's TTY. All 128 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Round 1 PR review fixes for the override-mode feature: - Add 30s timeout on the interactive override-mode prompt (Go CLI). The previous bufio.ReadString call would block forever if a TTY was detected but no user was actually present (detached terminals, some CI runners). Now the prompt clearly advertises the timeout and falls back to "use". - find_override_file (Python) now requires a regular file via .is_file() rather than .exists(). This matches the Go CLI's IsDir() guard and prevents merge mode from crashing with IsADirectoryError when a directory happens to share an override filename. Updated the test that previously documented the unsafe behavior, and added a regression test. - Extract the 10000-char merge-mode truncation cap into a named constant MAX_OVERRIDE_MERGE_CHARS so the magic number isn't duplicated.
Manual verificationRequires API key. Drop an
|
Local test resultsBuilt and reinstalled openant-core from this branch. Created a tiny fixture ( Commands run: Outcome (per checklist):
Note for the maintainer (small UX nit): Reported cost: $0.00 (Sonnet, ~6.9s). |
Summary
When
generate-contextdetects a manual override file (OPENANT.md/OPENANT.json), it now prompts the user to choose:Adds
--override-mode <use|merge|ignore>to bypass the prompt for CI/automation.--forceis kept as a backward-compatible shortcut for--override-mode ignore. In non-interactive environments (no TTY) the prompt is skipped anduseis the default.Previously, override files were all-or-nothing — either they fully replaced LLM generation or were ignored entirely, with no way to combine developer-provided hints with LLM analysis.
Addresses item 18 from #16 (does not close the issue).
Test plan
use/merge/ignorewhen an override exists.--override-mode useskips the LLM and emits the override verbatim.--override-mode mergefeeds the override into the LLM (verify with--show-prompt).--override-mode ignoreignores the override.--forcestill works as a shortcut for--override-mode ignore.--forceand--override-modeare mutually exclusive (CLI rejects both).use.