Skip to content

feat: add JSON schemas and Copilot prompts for filter/override configuration#183

Open
EMaher wants to merge 14 commits into
mainfrom
emaher-feat-filter-override-schemas-prompts
Open

feat: add JSON schemas and Copilot prompts for filter/override configuration#183
EMaher wants to merge 14 commits into
mainfrom
emaher-feat-filter-override-schemas-prompts

Conversation

@EMaher

@EMaher EMaher commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Motivation

When working with configuration.extractor.yaml (filter) and configuration.{env}.yaml (override) files, users have no IDE autocompletion or guided workflow for building these configs correctly. This makes onboarding harder and increases the chance of typos or structural mistakes.

Approach

This PR adds two complementary features:

  1. JSON Schema files (schemas/extractor-config.schema.json, schemas/override-config.schema.json) that provide IDE autocompletion via the yaml-language-server $schema directive. These are auto-generated from the TypeScript interfaces on every build by a new scripts/generate-schemas.mjs script, so they stay in sync with the code automatically.

  2. Copilot prompt files (apiops-configure-filter.prompt.md, apiops-configure-overrides.prompt.md) that conversationally guide users through creating filter/override files. The overrides prompt covers environment promotion (dev -> stage -> prod), Key Vault references, and {#[TOKEN_NAME]#} pipeline placeholder syntax per Enable pipeline token/placeholder substitution in publish pipeline (APIOps Toolkit parity) #117.

Both prompts are laid down by apiops init alongside the existing identity setup prompt.

Key changes

  • scripts/generate-schemas.mjs -- reads FilterConfig, ApiSubFilter, WorkspaceSubFilter, and OverrideConfig from src/models/config.ts and generates both schema files. Runs as part of prebuild/prelint/pretest.
  • src/templates/copilot/configure-filter-prompt.md and .ts -- prompt template for filter creation
  • src/templates/copilot/configure-overrides-prompt.md and .ts -- prompt template for override creation with token substitution guidance
  • src/services/init-service.ts -- new generateCopilotConfigurationPrompts() method + conflict detection for the new files
  • Documentation updated in docs/commands/init.md, docs/guides/filtering-resources.md, docs/guides/environment-overrides.md

Notes

  • Schema files are committed to the repo (users reference them via raw GitHub URLs for the $schema comment to work), but they are regenerated on every build from the canonical TypeScript types.
  • The filter schema was named extractor-config.schema.json for consistency with configuration.extractor.yaml.
  • The $comment JSON Schema keyword carries the MIT license notice since JSON doesn't support traditional comments.

…uration

- Add auto-generated JSON Schema files (schemas/extractor-config.schema.json,
  schemas/override-config.schema.json) for IDE autocompletion in YAML configs
- Add scripts/generate-schemas.mjs that derives schemas from TypeScript
  interfaces and runs on every build/lint/test
- Add Copilot prompt files (apiops-configure-filter, apiops-configure-overrides)
  that conversationally guide users through creating filter and override files
- Update apiops init to lay down the new prompt files alongside identity setup
- Include {#[TOKEN_NAME]#} placeholder syntax guidance and Key Vault patterns
  in the overrides prompt (per issue #117)
- Update docs for filtering-resources, environment-overrides, and init command

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread docs/commands/init.md Outdated
Comment thread docs/commands/init.md Outdated
Comment thread docs/commands/init.md Outdated
Comment thread docs/guides/environment-overrides.md Outdated
Comment thread docs/guides/environment-overrides.md Outdated
Comment thread src/templates/copilot/configure-overrides-prompt.md Outdated
Comment thread src/templates/copilot/configure-filter-prompt.md Outdated
Comment thread src/templates/copilot/configure-filter-prompt.md Outdated
Comment thread src/templates/copilot/configure-overrides-prompt.md Outdated
Comment thread src/templates/copilot/configure-overrides-prompt.ts Outdated
@EMaher

EMaher commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot, have the Squad handle all the comments in this PR.

@EMaher EMaher self-assigned this Jun 23, 2026
@EMaher EMaher marked this pull request as draft June 23, 2026 04:15
EMaher and others added 8 commits June 22, 2026 21:27
…tect instead

The overrides prompt now instructs Copilot to detect environments by scanning
for existing configuration.*.yaml files before falling back to asking the user.
This makes the prompt reusable outside of apiops init context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the shared renderTemplate function from src/templates/shared/template-utils.ts
to src/lib/render-template.ts and remove the duplicate private method from
identity-guide-service.ts. All template consumers now import from the single
canonical location.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@EMaher EMaher marked this pull request as ready for review June 25, 2026 20:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves authoring ergonomics for APIOps filter (configuration.extractor.yaml) and override (configuration.{env}.yaml) configs by adding IDE JSON Schemas (published under schemas/v1/) and adding new GitHub Copilot “prompt” templates that apiops init scaffolds into .github/prompts/.

Changes:

  • Add schema generation (scripts/generate-schemas.mjs) and commit the generated schemas under schemas/v1/ for editor autocomplete/validation.
  • Add Copilot prompt templates for configuring filters and environment overrides, and have apiops init generate them.
  • Update config templates to include yaml-language-server $schema headers, update packaging tests to include YAML templates, and refresh docs/devcontainer tooling.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/templates/copilot/configure-overrides-prompt.test.ts Adds unit coverage for the overrides Copilot prompt generator.
tests/unit/templates/copilot/configure-filter-prompt.test.ts Adds unit coverage for the filter Copilot prompt generator.
tests/unit/templates/configs/config-templates.test.ts Verifies generated config templates include schema URLs and no unrendered placeholders.
tests/unit/services/init-service.test.ts Extends init-service tests to cover prompt generation and conflict detection.
tests/integration/package-build/package-build.test.ts Updates packaging test to assert YAML templates are embedded/shipped, not only markdown.
src/templates/copilot/identity-setup-prompt.ts Refactors to reuse shared renderTemplate helper.
src/templates/copilot/configure-overrides-prompt.ts Adds generator for the overrides Copilot prompt template (static content).
src/templates/copilot/configure-overrides-prompt.md Adds the overrides Copilot prompt content to guide creating configuration.{environment}.yaml files.
src/templates/copilot/configure-filter-prompt.ts Adds generator for the filter Copilot prompt template (currently static).
src/templates/copilot/configure-filter-prompt.md Adds the filter Copilot prompt content to guide creating configuration.extractor.yaml.
src/templates/configs/schema-ref.ts Adds helper to build versioned raw GitHub schema URLs from package.json’s schemaVersion.
src/templates/configs/override-config.yaml Adds an override config template with a $schema placeholder for init-time rendering.
src/templates/configs/override-config.ts Switches override config generation to embedded template + token rendering + schema URL injection.
src/templates/configs/filter-config.yaml Adds a filter config template with a $schema placeholder for init-time rendering.
src/templates/configs/filter-config.ts Switches filter config generation to embedded template + token rendering + schema URL injection.
src/services/init-service.ts Adds generation + conflict detection for the two new Copilot prompt files during init.
src/services/identity-guide-service.ts Refactors to reuse shared renderTemplate helper.
src/lib/render-template.ts Introduces shared {{TOKEN}} template rendering utility.
scripts/generate-schemas.mjs Adds schema generator deriving schema structure from config model field names and emitting to schemas/v<N>/.
scripts/embed-markdown-templates.mjs Embeds the new Copilot prompts and the new YAML config templates into generated constants.
schemas/v1/override-config.schema.json Adds the published JSON Schema for override files.
schemas/v1/extractor-config.schema.json Adds the published JSON Schema for extractor filter files.
package.json Adds schemaVersion and runs schema generation in prelint/prebuild/pretest.
docs/guides/filtering-resources.md Documents $schema usage and points to the init-generated Copilot prompt.
docs/guides/environment-overrides.md Documents $schema usage and points to the init-generated Copilot prompt (contains a duplicated schema section).
docs/commands/init.md Documents new prompt files and updates “next steps” guidance to mention them.
.github/skills/update-config-schema-version/SKILL.md Adds internal skill documentation for safely bumping schema versions and updating references.
.github/skills/codespace-multi-repo/SKILL.md Adds internal skill documentation for multi-repo auth workflows in Codespaces/devcontainers.
.github/skills/codespace-clone-repo/SKILL.md Removes the old single-repo clone skill doc (replaced by the multi-repo skill).
.devcontainer/devcontainer.json Adds the Red Hat YAML extension to support schema-based autocomplete in the devcontainer.

Comment thread docs/guides/environment-overrides.md Outdated
Comment thread scripts/generate-schemas.mjs

@petehauge petehauge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking approve since I think all my suggestions can be done later if needed!


## Copilot-Assisted Configuration

If you ran `apiops init`, a Copilot prompt file was generated at `.github/prompts/apiops-configure-overrides.prompt.md`. Open it in VS Code and ask GitHub Copilot to help you configure environment overrides — it will guide you through setting up environment-specific values interactively.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the files are separated (better design), maybe we can link to them? IE: if the user didn't start with apiops init - go for the prompt to use?


## IDE Autocompletion with JSON Schema

A JSON Schema is available for `configuration.{env}.yaml` override files. Add yaml-language-server comment at the top of your override file. Requires yaml language extension in VSCode.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool, great idea!


These rules apply to **every** step below. Follow them strictly:

1. **Confirm before proceeding.** At the end of every step, summarize what you

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it matters, but the word wrapping here is a bit strange - like it was generated thinking that a window would be a certain width... It might be better if it was more naturally formatted and let the containing editor handle the wrapping

@@ -0,0 +1,299 @@
---

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought that occurred to me - I wonder if we should preface all the prompts with 'apiops', so it kind of matches the cli but it's also easier to find all of them, so /apiops-configure-overrides etc.


These rules apply to **every** step below. Follow them strictly:

1. **Confirm before proceeding.** At the end of every step, summarize what you

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, the formatting is a little strange to have artificial wrapping rather than letting the editor handle the word wrap...


Before filling in any value, **ask the user** which environment variables /
pipeline variables are available for this environment, and get the **exact,
case-sensitive** token names.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate what the user tells us? (only if gh cli is available)?


> Note: some repos use `AZURE_SUBSCRIPTION_ID` (global, no env suffix) as the
> default init-generated name. Others customize to `AZURE_SUBSCRIPTION_ID_<ENV>`.
> Ask the user which naming pattern exists in their pipeline.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're asking the user for a lot of things - can we just go look at the pipeline?

time** (for example one `resourceId` or one `value` field), not one whole
override object at a time. Do not batch multiple settings in a single prompt.

**Single-setting cadence for Step 4:**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be curious how this works in practice to get tokens first and then fill in overrides after... If it feels cumbersome to the user, we could consider an approach where copilot goes over the artifacts, find things that should be overriden and then prompts the user (want a token for any part, etc), then at the end just populate any missing tokens to github environment?

- Re-read each `configuration.{env}.yaml` file and confirm it is valid YAML
with no leftover blank values from the stubs.
- Confirm the schema comment is present as the first line of each file.
- Keep files easy to compare across environments and avoid duplicating

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also have copilot confirm that the yaml file contents matches the schema?

- Keep files easy to compare across environments and avoid duplicating
unchanged base configuration.

Show the finalized files and **STOP for confirmation** before treating them as

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of 'show' - I guess it's hard because user could be in vs code terminal, github copilot, or even agent tab in github or other places. I'm curious what copilot would do in this case - if it's enough instruction then sounds good - if not, we could consider another approach like telling the user to review the files that they're correct before checking them in and that's the end of the prompt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants