Extending Sylva
This guide covers how to add new providers, models, file extensions, and output sections to Sylva.
Adding a New Model
- Open
src/constants.ts - Add the model to
MODEL_CATALOG:
export const MODEL_CATALOG: Record<string, ModelMetadata> = {
// ... existing models
// Your new model
"provider/model-name": { provider: PROVIDER_OPENAI, tier: "primary" },
};
- If it's a new provider, add it to the defaults:
export const DEFAULT_MODELS: Record<string, string> = {
// ... existing defaults
[PROVIDER_NEW]: "provider/model-name",
};
- Rebuild:
npm run build
Adding a New Provider
- Add the provider constant to
src/constants.ts:
export const PROVIDER_NEWPROVIDER = "newprovider";
- Add the API key variable to
API_KEY_ENV_VARS:
export const API_KEY_ENV_VARS: Record<string, string[]> = {
// ... existing
[PROVIDER_NEWPROVIDER]: ["NEWPROVIDER_API_KEY"],
};
- Add default models for the provider to
DEFAULT_MODELSandDEFAULT_MINI_MODELS - Add models to
MODEL_CATALOG - Update the model resolution logic in
src/modelConfig.tsif the provider has special requirements - Rebuild:
npm run build
Adding File Extensions
To support a new file type in source tree scanning:
- Open
src/constants.ts - Add the extension to
ALLOWED_EXTENSIONS:
export const ALLOWED_EXTENSIONS = new Set([
// ... existing
".lua", // Lua scripts
".zig", // Zig language
]);
- Rebuild:
npm run build
Adding Ignored Directories
To ignore additional directories during scanning:
- Open
src/constants.ts - Add the directory name to
IGNORED_DIRS:
export const IGNORED_DIRS = new Set([
// ... existing
".cache",
".terraform",
]);
Adding Dependency Manifests
To hoist additional dependency files to the top of the serialized tree:
- Open
src/constants.ts - Add the filename to
DEPENDENCY_MANIFESTS:
export const DEPENDENCY_MANIFESTS = new Set([
// ... existing
"mix.exs", // Elixir
"pubspec.yaml", // Dart/Flutter
]);
Adding Output Sections
See Customizing Output for detailed instructions on adding, modifying, or removing AGENTS.md sections.