| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- #!/usr/bin/env bun
- /**
- * Configuration for upstream merge automation
- */
- export interface PackageMapping {
- from: string
- to: string
- }
- export interface MergeConfig {
- /** Package name mappings from opencode to kilo */
- packageMappings: PackageMapping[]
- /** Files to always keep Kilo's version (never take upstream changes) */
- keepOurs: string[]
- /** Files to skip entirely (don't add from upstream, remove if added) */
- skipFiles: string[]
- /** Files that should take upstream version and apply Kilo branding transforms */
- takeTheirsAndTransform: string[]
- /** Tauri/Desktop config files with predictable branding patterns */
- tauriFiles: string[]
- /** Script files with GitHub API references */
- scriptFiles: string[]
- /** Extension files (Zed, etc.) */
- extensionFiles: string[]
- /** Web/docs files */
- webFiles: string[]
- /** Lock files to accept ours and regenerate after merge */
- lockFiles: string[]
- /** Directories that are Kilo-specific and should be preserved */
- kiloDirectories: string[]
- /** File patterns to exclude from codemods */
- excludePatterns: string[]
- /** Default branch to merge into */
- baseBranch: string
- /** Branch prefix for merge branches */
- branchPrefix: string
- /** Remote name for upstream */
- upstreamRemote: string
- /** Remote name for origin */
- originRemote: string
- /** i18n file patterns that need string transformation */
- i18nPatterns: string[]
- }
- export const defaultConfig: MergeConfig = {
- packageMappings: [
- { from: "opencode-ai", to: "@kilocode/cli" },
- { from: "@opencode-ai/cli", to: "@kilocode/cli" },
- { from: "@opencode-ai/sdk", to: "@kilocode/sdk" },
- { from: "@opencode-ai/plugin", to: "@kilocode/plugin" },
- ],
- keepOurs: [
- "README.md",
- "CONTRIBUTING.md",
- "CODE_OF_CONDUCT.md",
- "PRIVACY.md",
- "SECURITY.md",
- "AGENTS.md",
- // GitHub workflows - MANUAL REVIEW (can break CI/CD)
- ".github/workflows/publish.yml",
- ".github/workflows/close-stale-prs.yml",
- ".github/pull_request_template.md",
- // Kilo-specific command files
- ".opencode/command/commit.md",
- // Kilo-specific publish scripts
- "packages/opencode/script/publish-registries.ts",
- // Generated OpenAPI spec - kept ours and regenerated post-merge via script/generate.ts
- "packages/sdk/openapi.json",
- // GitHub Action - Kilo version is fully ported and complete
- "github/action.yml",
- "github/README.md",
- "github/.gitignore",
- "github/script/release",
- "github/script/publish",
- ],
- // Files that only exist in upstream and should NOT be added to Kilo
- // These are removed during merge if they appear
- skipFiles: [
- // Translated README files (Kilo doesn't have these)
- "README.ar.md",
- "README.bn.md",
- "README.br.md",
- "README.bs.md",
- "README.da.md",
- "README.de.md",
- "README.es.md",
- "README.fr.md",
- "README.gr.md",
- "README.it.md",
- "README.ja.md",
- "README.ko.md",
- "README.no.md",
- "README.pl.md",
- "README.ru.md",
- "README.th.md",
- "README.tr.md",
- "README.uk.md",
- "README.vi.md",
- "README.zh.md",
- "README.zht.md",
- // Stats file
- "STATS.md",
- // Workflows that don't exist in Kilo
- ".github/workflows/update-nix-hashes.yml",
- ".github/workflows/deploy.yml",
- ".github/workflows/docs-update.yml",
- ".github/workflows/docs-locale-sync.yml",
- // Vouch files (Kilo doesn't use Vouch)
- ".github/VOUCHED.md",
- ".github/workflows/vouch-check-issue.yml",
- ".github/workflows/vouch-check-pr.yml",
- ".github/workflows/vouch-manage-by-issue.yml",
- // SST infrastructure files (Kilo is CLI-only, no hosted platform)
- "sst.config.ts",
- "sst-env.d.ts",
- // Hosted platform packages (not needed for CLI)
- "infra/**",
- "packages/console/**",
- "packages/enterprise/**",
- "packages/web/**",
- "packages/slack/**",
- "packages/function/**",
- "packages/docs/**",
- "packages/identity/**",
- // GitHub Action - Kilo version is fully ported and complete
- "github/index.ts",
- "github/package.json",
- "github/tsconfig.json",
- "github/bun.lock",
- "github/sst-env.d.ts",
- ],
- // Files that should take upstream version and apply Kilo branding transforms
- // These are files with only branding differences, no logic changes
- takeTheirsAndTransform: [
- // App components with branding only
- "packages/app/src/components/**/*.tsx",
- "packages/app/src/context/**/*.tsx",
- "packages/app/src/pages/**/*.tsx",
- // UI components
- "packages/ui/src/components/**/*.tsx",
- "packages/ui/src/context/**/*.tsx",
- // Desktop TypeScript files (not Rust)
- "packages/desktop/src/**/*.ts",
- // E2E and test fixtures
- "packages/app/e2e/**/*.ts",
- "packages/app/script/**/*.ts",
- ],
- // Tauri/Desktop config files with predictable branding patterns
- tauriFiles: [
- "packages/desktop/src-tauri/tauri.conf.json",
- "packages/desktop/src-tauri/tauri.prod.conf.json",
- "packages/desktop/src-tauri/Cargo.toml",
- "packages/desktop/src-tauri/Cargo.lock",
- "packages/desktop/src-tauri/src/*.rs",
- ],
- // Script files with GitHub API references
- scriptFiles: ["script/*.ts", "packages/opencode/script/*.ts"],
- // Extension files
- extensionFiles: ["packages/extensions/**/*"],
- // Web/docs files
- webFiles: [],
- // Lock files and generated files to accept ours and regenerate after merge
- // Note: nix/hashes.json is regenerated by CI (update-nix-hashes.yml), not locally
- lockFiles: [
- "bun.lock",
- "**/bun.lock",
- "package-lock.json",
- "**/package-lock.json",
- "yarn.lock",
- "**/yarn.lock",
- "pnpm-lock.yaml",
- "**/pnpm-lock.yaml",
- "Cargo.lock",
- "**/Cargo.lock",
- "nix/hashes.json",
- ],
- kiloDirectories: [
- "packages/opencode/src/kilocode",
- "packages/opencode/test/kilocode",
- "packages/kilo-gateway",
- "packages/kilo-telemetry",
- "packages/kilo-vscode",
- "packages/kilo-ui",
- "packages/kilo-docs",
- "packages/kilo-i18n",
- "script/upstream",
- ],
- excludePatterns: [
- "**/node_modules/**",
- "**/dist/**",
- "**/.git/**",
- "**/bun.lock",
- "**/package-lock.json",
- "**/yarn.lock",
- ],
- baseBranch: "main",
- branchPrefix: "upstream-merge",
- upstreamRemote: "upstream",
- originRemote: "origin",
- // i18n translation files that need Kilo branding transforms
- i18nPatterns: ["packages/*/src/i18n/*.ts", "packages/desktop/src/i18n/*.ts"],
- }
- export function loadConfig(overrides?: Partial<MergeConfig>): MergeConfig {
- return { ...defaultConfig, ...overrides }
- }
|