feat: add environment-backed output target - #18
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
.env loading currently occurs before validating the env:/index URI form, which can surface the wrong failure mode for malformed env: outputs.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces an explicit env:/<index> Elasticsearch output target that resolves connection settings from ELASTIC_ES_URL / ELASTIC_ES_API_KEY (process environment first, then .env), and returns es:/ / elasticsearch:/ to configured-host resolution to remove ambiguity and namespace conflicts.
Changes:
- Add
env:/<index>output dispatch and URL construction/validation using environment + optional.envloading. - Update CLI startup to conditionally load
.envand to apply environment API key fallback only forenv:/...outputs. - Add/adjust tests and documentation/specs, including making generated-ID integration tests independent of bulk operation ordering.
File summaries
| File | Description |
|---|---|
| tests/index_template.rs | Makes the generated-ID/upsert CLI test resilient to parallel file discovery/order changes. |
| tests/env_output.rs | Adds CLI integration tests covering env:/ behavior, .env precedence, and error cases. |
| src/output/mod.rs | Adds env scheme dispatch and environment-based URL construction/validation. |
| src/main.rs | Loads .env only for env:/ output and scopes environment API key fallback accordingly. |
| README.md | Documents the new env:/index-name output and migration guidance. |
| openspec/specs/elasticsearch-environment-output/spec.md | Adds a formal spec defining env:/ syntax, precedence rules, and validation requirements. |
| openspec/changes/archive/2026-08-26-add-elasticsearch-environment-output/tasks.md | Tracks implementation and verification tasks for the new capability. |
| openspec/changes/archive/2026-08-26-add-elasticsearch-environment-output/specs/elasticsearch-environment-output/spec.md | Archives the spec snapshot alongside the change proposal/design. |
| openspec/changes/archive/2026-08-26-add-elasticsearch-environment-output/proposal.md | Records rationale, scope, and breaking-change note for the scheme migration. |
| openspec/changes/archive/2026-08-26-add-elasticsearch-environment-output/design.md | Documents design decisions (scheme reservation, .env scoping, precedence). |
| openspec/changes/archive/2026-08-26-add-elasticsearch-environment-output/.openspec.yaml | Adds openspec metadata for the archived change bundle. |
| CHANGELOG.md | Notes the new .env fallback and the scheme migration in Unreleased. |
| Cargo.toml | Adds the dotenvy dependency. |
| Cargo.lock | Locks dotenvy in the dependency graph. |
| .agents/skills/espipe/SKILL.md | Updates skill documentation/examples to use env:/ instead of es:/ / elasticsearch:/. |
Review details
- Files reviewed: 14/15 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The changes consistently implement env:/ dispatch with scoped .env loading, preserve auth precedence, and add targeted tests/spec/docs without introducing obvious behavioral regressions.
Review details
- Files reviewed: 14/15 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
es:/andelasticsearch:/context targets withenv:/.env, with CLI authentication taking precedenceValidation
cargo test(195 passed, 5 ignored)cargo clippy --all-targets(0 errors; existing warnings remain)openspec validate --all --strict --json