Skip to content

VS Code extension: ship portable, built-in custom agents (codeql-query-developer, codeql-workshop-author)#281

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/ship-portable-custom-agents
Draft

VS Code extension: ship portable, built-in custom agents (codeql-query-developer, codeql-workshop-author)#281
Copilot wants to merge 4 commits into
mainfrom
copilot/ship-portable-custom-agents

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

Bundles two query-author-facing custom agents — codeql-query-developer and codeql-workshop-author — directly inside the extensions/vscode/ VSIX, alongside curated prompts and skills. End users get a turnkey, named-agent experience on install (no .github/agents/*.md checkout required), with build-time (--customizations-dir) and runtime (codeql-mcp.additionalAgentDirs) extensibility hooks. The five repo-local .github/agents/*.md files are untouched.

⚠️ Template note: this PR ships a VS Code extension feature, not a server/src/ MCP primitive — the strict scope clauses below apply by analogy (no unrelated/temporary files), but the allowed paths are under extensions/vscode/ rather than server/src/.

📝 Primitive Information

Primitive Details

  • Type: VS Code extension feature (custom agents + contributions + runtime registrar)
  • Name: codeql-query-developer, codeql-workshop-author (custom agents)
  • Domain: VS Code Extension / Chat customizations

⚠️ CRITICAL: PR SCOPE VALIDATION

Scope is limited to VS Code extension files + a CHANGELOG entry. No server/src/ changes; the five .github/agents/*.md files are unchanged.

FILES TOUCHED:

  • extensions/vscode/customizations/** — new tracked source dir for shipped .agent.md files and the bundler whitelist
  • extensions/vscode/scripts/bundle-customizations.js — bundler with overlay support and manifest
  • extensions/vscode/src/customizations/agent-registrar.ts — runtime registrar
  • extensions/vscode/src/extension.ts — wires the registrar + showAgentsStatus command
  • extensions/vscode/package.jsonchatAgents/chatPromptFiles/chatSkills contributes, new settings + command, bundle:customizations script
  • extensions/vscode/test/customizations/*.test.ts — Vitest unit tests
  • extensions/vscode/test/suite/agents.integration.test.ts@vscode/test-electron integration suite
  • extensions/vscode/examples/team-customizations/** — sample overlay
  • extensions/vscode/.vscodeignore, .gitignore, esbuild.config.js, eslint.config.mjs, README.md
  • CHANGELOG.md — Unreleased entry

🚫 NOT TOUCHED: any .github/agents/*.md, server/src/prompts/*.prompt.md, or .github/skills/*/SKILL.md source files (read-only copy sources).


🛑 MANDATORY PR VALIDATION CHECKLIST

  • ONLY VS Code extension files are included (plus the cross-cutting CHANGELOG.md entry)
  • NO temporary or output files are included — generated agents/, prompts/, skills/, dist-customizations-manifest.json are gitignored
  • NO unrelated configuration files are included
  • ALL new functionality is properly tested

  • Category: Code Quality / Developer Experience

Primitive Metadata

  • MCP Type: N/A — this is VS Code chat customization wiring (custom agents + contribution points), not an MCP tool/resource
  • Input Schema: New settings — codeql-mcp.agents.enabled: boolean (default true), codeql-mcp.additionalAgentDirs: string[] (default [])
  • Output Format: dist-customizations-manifest.json (build artifact); codeql-mcp.showAgentsStatus prints { enabled, bundledDir, additionalDirs, effectiveLocations }

🎯 Functionality Description

What This Primitive Does

  • Bundles two .agent.md files into the VSIX so they appear as extension-contributed custom agents the moment the extension activates.
  • Programmatically appends the bundled agents/ directory (and any user-supplied additionalAgentDirs) to chat.agentFilesLocations, with idempotent dedupe and clean removal on deactivation.
  • Declaratively contributes a whitelisted subset of prompt files and skills via contributes.chatPromptFiles / contributes.chatSkills; speculatively contributes chatAgents (kept — vsce accepted it).
  • Exposes a build-time overlay (--customizations-dir=<path> or CODEQL_MCP_CUSTOMIZATIONS_DIR) that lets teams replace/extend the defaults before packaging.
  • Neither shipped .agent.md sets a model: key — user-controlled model selection is a non-negotiable design point.

Use Cases

  • Out-of-the-box @codeql-query-developer (TDD query authoring) and @codeql-workshop-author (workshop generation, one-way handoff to the developer agent) in any VS Code workspace with the extension installed.
  • Teams ship their own opinionated overlays via npm run package -- --customizations-dir=./examples/team-customizations.
  • End users append personal agent dirs via the codeql-mcp.additionalAgentDirs setting without rebuilding the VSIX.

Example Usage

// .vscode/settings.json — user/team extensibility
{
  "codeql-mcp.agents.enabled": true,
  "codeql-mcp.additionalAgentDirs": [
    "/Users/me/codeql-personal-agents"
  ]
}
# Build-time overlay
npm run package --workspace=extensions/vscode -- \
  --customizations-dir=./examples/team-customizations

Example Input/Output

// codeql-mcp.showAgentsStatus — output channel
{
  "enabled": true,
  "bundledDir": "/.../extensions/.../agents",
  "additionalDirs": ["/Users/me/codeql-personal-agents"],
  "effectiveLocations": [
    "/.../extensions/.../agents",
    "/Users/me/codeql-personal-agents"
  ]
}

🧪 Implementation Details

Files Added/Modified

  • New shipped agents: extensions/vscode/customizations/agents/{codeql-query-developer,codeql-workshop-author}.agent.md
  • Bundler + whitelist: extensions/vscode/scripts/bundle-customizations.js, extensions/vscode/customizations/bundle-customizations.config.js
  • Runtime registrar: extensions/vscode/src/customizations/agent-registrar.ts
  • Wiring: extensions/vscode/src/extension.ts, extensions/vscode/package.json (scripts, settings, command, contributes)
  • Packaging: extensions/vscode/.vscodeignore (excludes customizations/, examples/), extensions/vscode/.gitignore (excludes generated outputs)
  • Tests: extensions/vscode/test/customizations/{bundle-customizations,agent-registrar}.test.ts, extensions/vscode/test/suite/agents.integration.test.ts
  • Example overlay: extensions/vscode/examples/team-customizations/**
  • Docs: extensions/vscode/README.md new "Built-in Custom Agents" section, CHANGELOG.md Unreleased entry

Architecture Integration

  • Server Registration: registrar pushed to existing disposables[]; showAgentsStatus command registered alongside existing commands
  • Error Handling: registrar wraps in try/catch — warn log on failure, never blocks activation
  • Logging: uses the existing Logger
  • Type Safety: full TypeScript strict mode
  • Schema Validation: settings declared in contributes.configuration.properties
  • Session Tracking: N/A (no server changes)
  • Quality Assessment: N/A (no server changes)

Design Patterns

  • Follows Existing Patterns: bundler mirrors scripts/bundle-server.js; registrar mirrors McpProvider disposable pattern
  • Modular Design: build-time / declarative / runtime concerns split into three independent layers
  • Dependency Management: zero new runtime dependencies
  • Performance Considerations: registrar runs once per activation + on relevant config/folder change events

📋 Testing Coverage

Unit Tests

  • Input Validation: agent registrar — config defaults, target selection (Workspace vs Global), normalized dedupe
  • Core Functionality: bundler defaults, overlay collision, net-new overlay files, manifest emission
  • Error Conditions: missing whitelisted files warn and skip without failing
  • Integration: @vscode/test-electron suite asserts bundled agents/ exists, both .agent.md files load, toggle removes/restores entries, additionalAgentDirs appends, showAgentsStatus command runs

Test Scenarios

  1. Basic Functionality: bundler copies whitelisted agents/prompts/skills and emits a manifest
  2. Error Handling: missing skills (e.g. create-codeql-query-tdd-generic not yet on disk) warn-and-skip; registrar never throws past activation
  3. Edge Cases: overlay replacement preserves nested paths (e.g. skills/foo/SKILL.md, not skills/SKILL.md); registrar dedupes across normalized paths
  4. Integration: extension activation registers the bundled dir; deactivation removes only the registrar's own entries

Test Files

  • extensions/vscode/test/customizations/bundle-customizations.test.ts
  • extensions/vscode/test/customizations/agent-registrar.test.ts
  • extensions/vscode/test/suite/agents.integration.test.ts

🔗 References

Related Implementation

  • extensions/vscode/scripts/bundle-server.js — sibling bundler pattern
  • .github/agents/mcp-enabled-ql-query-developer.md, .github/agents/mcp-enabled-ql-workshop-developer.md — source agents the shipped versions are slimmed from (left unchanged)

External References

  • VS Code Custom Agents
  • VS Code Contribution PointschatPromptFiles, chatSkills documented; chatAgents speculative (kept — accepted by vsce)
  • Related: codeql-development-mcp-server#2 (--prompts-dir user extensibility for the MCP server)

Validation Materials

  • Test Queries: N/A
  • Expected Behaviors: covered by the integration suite + acceptance criteria in the linked issue

🚀 Server Integration

Registration Details

// extensions/vscode/src/extension.ts
const agentRegistrar = new AgentRegistrar(context, logger);
disposables.push(agentRegistrar);
agentRegistrar.register();

context.subscriptions.push(
  vscode.commands.registerCommand('codeql-mcp.showAgentsStatus', () => {
    const status = agentRegistrar.getStatus();
    logger.info(JSON.stringify(status, null, 2));
    logger.show();
  }),
);

Compatibility

  • MCP Protocol Version: unchanged (no server changes)
  • Node.js Version: matches existing extension target
  • Dependencies: no new runtime dependencies
  • TypeScript Version: matches extensions/vscode/tsconfig.json

Performance Considerations

  • Memory Usage: trivial — one path list per activation
  • Execution Time: registrar work is microseconds
  • Concurrency: no shared mutable state
  • Resource Cleanup: dispose() removes only this instance's entries; idempotent

🔍 Quality Assurance

Code Quality

  • TypeScript Compilation: passes
  • Linting: npm run lint --workspace=extensions/vscode clean
  • Formatting: Prettier-consistent
  • Documentation: README section added; JSDoc on registrar public API

Validation Testing

  • Manual Testing: bundler executed end-to-end; overlay verified with examples/team-customizations/
  • Automated Testing: 194/194 Vitest unit tests pass
  • Integration Testing: @vscode/test-electron suite added (driven by repo CI)
  • Error Path Testing: missing-file warn paths covered

Security Considerations

  • Input Sanitization: paths normalized; only filesystem reads of user-provided dirs
  • No Code Injection: no eval/dynamic require
  • Resource Limits: bundler copies whitelisted file lists only
  • Error Information: registrar logs warn-level diagnostics only

👥 Review Guidelines

For Reviewers

  • ⚠️ SCOPE COMPLIANCE: scope is the VS Code extension + CHANGELOG; no server/src/ or .github/agents/ edits
  • ⚠️ NO UNRELATED FILES: generated outputs are gitignored
  • Functionality: registrar + bundler behave as documented
  • Test Coverage: unit + integration suites cover the acceptance criteria
  • Code Quality: follows extension conventions
  • Documentation: README "Built-in Custom Agents" + CHANGELOG updated
  • Performance: negligible activation overhead
  • Integration: registrar disposed via existing disposables[]
  • Type Safety: full TS coverage
  • Error Handling: registrar never blocks activation

Testing Instructions

# From extensions/vscode/
npm run lint
npm run test:coverage
npm run bundle:customizations
npm run package
unzip -l codeql-development-mcp-server-v*.vsix | grep -E 'agents/|prompts/|skills/'
# (verify customizations/ is absent)

Manual Validation Steps

  1. Install the produced VSIX in a fresh VS Code profile.
  2. Open Chat: Open Customizations — both agents appear as extension-contributed.
  3. Run codeql-mcp.showAgentsStatus — bundled + extra paths printed.
  4. Toggle codeql-mcp.agents.enabled = false — agents disappear; re-enable to restore.
  5. Set codeql-mcp.additionalAgentDirs to a temp dir with an .agent.md and confirm surface.

📊 Impact Analysis

Server Impact

  • Startup Time: no MCP server changes
  • Memory Usage: no MCP server changes
  • API Surface: no MCP server changes
  • Dependencies: no new dependencies

AI Assistant Benefits

  • Enhanced Capabilities: turnkey curated agents in any workspace
  • Improved Accuracy: TDD + workshop workflows surfaced as first-class personas
  • Better Coverage: prompts and skills shipped alongside agents
  • Workflow Integration: one-way handoff codeql-workshop-author → codeql-query-developer
  • Quality Measurement: N/A (no server changes)

Monitoring & Reporting Integration

  • Session Tracking: N/A
  • Quality Metrics: N/A
  • Usage Analytics: N/A
  • Test-Driven Workflow: shipped codeql-query-developer agent encodes TDD as the default flow

Maintenance Considerations

  • Code Maintainability: three-layer split keeps each concern small
  • Test Maintainability: tests mirror the layered architecture
  • Documentation: README + CHANGELOG + inline JSDoc
  • Compatibility: forward-compatible — chatAgents removable if a future vsce rejects it

🔄 Deployment Considerations

Rollout Strategy

  • Safe Deployment: additive only — existing MCP wiring untouched
  • Feature Flag: codeql-mcp.agents.enabled acts as a kill-switch
  • Monitoring: registrar warnings flow through the existing CodeQL MCP output channel
  • Rollback: disabling the setting removes registered entries cleanly

Migration Notes

None. Existing repo-local .github/agents/*.md files are unchanged and continue to serve maintainers of this repo.


Implementation Methodology: This change follows best practices:

  1. ✅ Hybrid declarative (contributes.*) + programmatic (chat.agentFilesLocations) registration
  2. ✅ TypeScript strict mode + zero new runtime deps
  3. ✅ Defensive registrar — never blocks activation
  4. ✅ Unit + integration test coverage
  5. ✅ README + CHANGELOG documentation
  6. ✅ User-controlled model — no model: key shipped, no coercion in code

…le packaging

- Add codeql-query-developer and codeql-workshop-author .agent.md files
- Add bundle-customizations.js script with overlay support
- Add AgentRegistrar class managing chat.agentFilesLocations registration
- Add bundle:customizations npm script; update vscode:prepublish and clean
- Add codeql-mcp.agents.enabled and additionalAgentDirs settings
- Add codeql-mcp.showAgentsStatus command
- Add contributes.chatAgents, chatPromptFiles, chatSkills static declarations
- Add Vitest unit tests for bundler and AgentRegistrar
- Add Mocha integration test suite for agents
- Add team-customizations example overlay
- Update README.md with Built-in Custom Agents section
- Update CHANGELOG.md [Unreleased] with new VS Code Extension features

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 18, 2026 04:32
…ills/, manifest)

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 18, 2026 04:33
…n tests

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 18, 2026 04:35
Copilot AI changed the title [WIP] Add portable, built-in custom agents to VS Code extension VS Code extension: ship portable, built-in custom agents (codeql-query-developer, codeql-workshop-author) May 18, 2026
Copilot AI requested a review from data-douser May 18, 2026 04:37
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.

VS Code extension: ship portable, built-in custom agents (codeql-query-developer, codeql-workshop-author) with user-extensible packaging

2 participants