generic-copilot
AGENTS.md41 starsChanged 12 months agoMITArchived repositoryView on GitHub
Purpose: This file provides context, instructions, and rules for AI coding agents working on the generic-copilot project. Agents MUST read and follow these guidelines. generic-copilot is a Visual Studio Code extension that integrates any Vercel AI SDK-compatible LLM provider into GitHub Copilot Chat. It leverages the VS Code Language Model API to act as a chat provider. Key Features: * Acts as a languageModelChatProvider. * Supports multiple providers (OpenAI, OpenRouter, Google, etc.) via Vercel AI SDK. * Includes a React-based…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
18 rules. About 0 are common, 2 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
Root (Extension): Run npm install in the project root.
- Very specific: line 30
Webview (UI): Run npm install in webview-ui/.
- Distinctive: line 39
Do not run terminal commands to verify files - use built in tools where possible.
- Very specific: line 48
NEVER: use console.log, console.info, console.error or print.
- Very specific: line 49
ALWAYS: use the OutputLogger singleton from src/outputLogger.ts.
- Very specific: line 50
Import: import { logger } from "./outputLogger".
- Very specific: line 64
Use vscode.workspace.getConfiguration("generic-copilot") to access settings.
- Very specific: line 65
Use vscode.secrets for storing sensitive data like API keys.
- Very specific: line 78
Use named caches per concern (e.g., toolCallMetadata, yourFeatureName) to avoid cross-contamination.
- Distinctive: line 80
If you add a new metadata type, define or import a small interface for it near the usage site and cast explicitly when reading/writing the …
- Very specific: line 83
Create a new client in src/ai/providers/ implementing ProviderClient.
- Very specific: line 84
Update src/ai/providerClientFactory.ts to handle the new vercelType.
- Very specific: line 85
Update package.json configuration schema to allow the new type.
- Very specific: line 86
Update webview-ui components if specific UI handling is needed.
- Very specific: line 89
When adding new properties to ModelItem or ProviderConfig in src/types.ts:
- Very specific: line 90
Update Type Definitions: Add the property to the interface in src/types.ts.
- Very specific: line 91
Update Configuration Schema: Add the property to package.json under contributes.configuration.
- Very specific: line 94
Update UI Components: Update the relevant React components (e.g., webview-ui/src/components/Models.tsx or Providers.tsx) to display and …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Purpose: This file provides context, instructions, and rules for AI coding agents working on the
generic-copilotproject. Agents MUST read and follow these guidelines.
1. Project Overview
generic-copilot is a Visual Studio Code extension that integrates any Vercel AI SDK-compatible LLM provider into GitHub Copilot Chat. It leverages the VS Code Language Model API to act as a chat provider.
Key Features:
- Acts as a
languageModelChatProvider. - Supports multiple providers (OpenAI, OpenRouter, Google, etc.) via Vercel AI SDK.
- Includes a React-based Webview for configuration and monitoring (
webview-ui). - Uses VS Code Secret Storage for API keys.
2. Tech Stack & Dependencies
- Runtime: Node.js (VS Code Extension Host).
- Language: TypeScript (Strict mode).
- Frameworks:
- VS Code Extension API: Uses proposed APIs (
chatProvider,languageModel*). - Vercel AI SDK: Core AI logic (
@ai-sdk/openai,@ai-sdk/google,ai). - React: Used in
webview-uifor the configuration panel.
- VS Code Extension API: Uses proposed APIs (
- Package Manager:
npm.
3. Development Workflow
Installation
The project has two distinct parts that need dependency installation:
- Root (Extension): Run
npm installin the project root. - Webview (UI): Run
npm installinwebview-ui/.
Helper Task: The shell: Prepare Env task in VS Code automates this.
Build Scripts (package.json)
npm run compile:all: Compiles both the extension and the webview.npm run watch:extension: Watchessrc/for changes and recompiles.npm run watch:webview: Watcheswebview-ui/for changes.npm run package: Packages the extension into a.vsixfile.- Do not run terminal commands to verify files - use built in tools where possible.
Debugging
- Reloading: The extension implements a dev-time auto-restart watcher in
src/extension.tsthat reloads the window whenout/changes.
4. Coding Conventions & Rules
🛑 Logging (CRITICAL)
- NEVER use
console.log,console.info,console.errororprint. - ALWAYS use the
OutputLoggersingleton fromsrc/outputLogger.ts.- Import:
import { logger } from "./outputLogger";(or relative path). - Usage:
logger.info("Message")logger.debug("Debug info")logger.warn("Warning")logger.error("Error message", errorObj)
- Import:
Error Handling
- Catch errors explicitly.
- Log errors using
logger.error(), passing the error object to capture the stack trace. - Show user-facing errors using
vscode.window.showErrorMessageONLY if immediate user action is required.
VS Code API Usage
- This extension relies on Proposed APIs. Ensure
enabledApiProposalsinpackage.jsonmatches the APIs used. - Use
vscode.workspace.getConfiguration("generic-copilot")to access settings. - Use
vscode.secretsfor storing sensitive data like API keys.
Architecture
src/extension.ts: Entry point. Registers providers and commands.src/ai/: Contains Vercel AI SDK integration.providerClientFactory.ts: Instantiates the correct client based on config.providers/: specific implementations (e.g.,google.ts,openai.ts).
src/configurationPanel.ts: Handles the Webview panel creation and message passing.webview-ui/: Standalone React application. Builds toout/webview-ui/.
Metadata Cache (important)
- The cache lives in
src/ai/utils/metadataCache.tsand is accessed viaCacheRegistry.getCache(name). - The cache stores
unknown; always cast on get/set to the shape you expect (e.g.,as ToolCallMetadata). Do not widen the cache type globally. - Use named caches per concern (e.g.,
toolCallMetadata,yourFeatureName) to avoid cross-contamination. Avoid reusing names across unrelated features. - The cache has a size limit (FIFO eviction). Do not store large payloads or secrets; it is meant for transient provider metadata (e.g., Google
thoughtSignature). - If you add a new metadata type, define or import a small interface for it near the usage site and cast explicitly when reading/writing the cache.
5. Adding New Providers
- Create a new client in
src/ai/providers/implementingProviderClient. - Update
src/ai/providerClientFactory.tsto handle the newvercelType. - Update
package.jsonconfiguration schema to allow the new type. - Update
webview-uicomponents if specific UI handling is needed.
6. Modifying Data Models (Configuration)
When adding new properties to ModelItem or ProviderConfig in src/types.ts:
- Update Type Definitions: Add the property to the interface in
src/types.ts. - Update Configuration Schema: Add the property to
package.jsonundercontributes.configuration. - Update Webview Data Mapping:
- CRITICAL: You MUST update the
toGroupedfunction inwebview-ui/src/App.tsxto include the new property. The Webview does not automatically ingest new fields; they must be explicitly mapped.
- CRITICAL: You MUST update the
- Update UI Components: Update the relevant React components (e.g.,
webview-ui/src/components/Models.tsxorProviders.tsx) to display and edit the new field.
Failure to follow these rules, especially regarding logging and build processes, will result in rejected code.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

