config.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #!/usr/bin/env bun
  2. /**
  3. * Configuration for upstream merge automation
  4. */
  5. export interface PackageMapping {
  6. from: string
  7. to: string
  8. }
  9. export interface MergeConfig {
  10. /** Package name mappings from opencode to kilo */
  11. packageMappings: PackageMapping[]
  12. /** Files to always keep Kilo's version (never take upstream changes) */
  13. keepOurs: string[]
  14. /** Files to skip entirely (don't add from upstream, remove if added) */
  15. skipFiles: string[]
  16. /** Files that should take upstream version and apply Kilo branding transforms */
  17. takeTheirsAndTransform: string[]
  18. /** Tauri/Desktop config files with predictable branding patterns */
  19. tauriFiles: string[]
  20. /** Script files with GitHub API references */
  21. scriptFiles: string[]
  22. /** Extension files (Zed, etc.) */
  23. extensionFiles: string[]
  24. /** Web/docs files */
  25. webFiles: string[]
  26. /** Lock files to accept ours and regenerate after merge */
  27. lockFiles: string[]
  28. /** Directories that are Kilo-specific and should be preserved */
  29. kiloDirectories: string[]
  30. /** File patterns to exclude from codemods */
  31. excludePatterns: string[]
  32. /** Default branch to merge into */
  33. baseBranch: string
  34. /** Branch prefix for merge branches */
  35. branchPrefix: string
  36. /** Remote name for upstream */
  37. upstreamRemote: string
  38. /** Remote name for origin */
  39. originRemote: string
  40. /** i18n file patterns that need string transformation */
  41. i18nPatterns: string[]
  42. }
  43. export const defaultConfig: MergeConfig = {
  44. packageMappings: [
  45. { from: "opencode-ai", to: "@kilocode/cli" },
  46. { from: "@opencode-ai/cli", to: "@kilocode/cli" },
  47. { from: "@opencode-ai/sdk", to: "@kilocode/sdk" },
  48. { from: "@opencode-ai/plugin", to: "@kilocode/plugin" },
  49. ],
  50. keepOurs: [
  51. "README.md",
  52. "CONTRIBUTING.md",
  53. "CODE_OF_CONDUCT.md",
  54. "PRIVACY.md",
  55. "SECURITY.md",
  56. "AGENTS.md",
  57. // GitHub workflows - MANUAL REVIEW (can break CI/CD)
  58. ".github/workflows/publish.yml",
  59. ".github/workflows/close-stale-prs.yml",
  60. ".github/pull_request_template.md",
  61. // Kilo-specific command files
  62. ".opencode/command/commit.md",
  63. // Kilo-specific publish scripts
  64. "packages/opencode/script/publish-registries.ts",
  65. // Generated OpenAPI spec - kept ours and regenerated post-merge via script/generate.ts
  66. "packages/sdk/openapi.json",
  67. // GitHub Action - Kilo version is fully ported and complete
  68. "github/action.yml",
  69. "github/README.md",
  70. "github/.gitignore",
  71. "github/script/release",
  72. "github/script/publish",
  73. ],
  74. // Files that only exist in upstream and should NOT be added to Kilo
  75. // These are removed during merge if they appear
  76. skipFiles: [
  77. // Translated README files (Kilo doesn't have these)
  78. "README.ar.md",
  79. "README.bn.md",
  80. "README.br.md",
  81. "README.bs.md",
  82. "README.da.md",
  83. "README.de.md",
  84. "README.es.md",
  85. "README.fr.md",
  86. "README.gr.md",
  87. "README.it.md",
  88. "README.ja.md",
  89. "README.ko.md",
  90. "README.no.md",
  91. "README.pl.md",
  92. "README.ru.md",
  93. "README.th.md",
  94. "README.tr.md",
  95. "README.uk.md",
  96. "README.vi.md",
  97. "README.zh.md",
  98. "README.zht.md",
  99. // Stats file
  100. "STATS.md",
  101. // Workflows that don't exist in Kilo
  102. ".github/workflows/update-nix-hashes.yml",
  103. ".github/workflows/deploy.yml",
  104. ".github/workflows/docs-update.yml",
  105. ".github/workflows/docs-locale-sync.yml",
  106. // Vouch files (Kilo doesn't use Vouch)
  107. ".github/VOUCHED.md",
  108. ".github/workflows/vouch-check-issue.yml",
  109. ".github/workflows/vouch-check-pr.yml",
  110. ".github/workflows/vouch-manage-by-issue.yml",
  111. // SST infrastructure files (Kilo is CLI-only, no hosted platform)
  112. "sst.config.ts",
  113. "sst-env.d.ts",
  114. // Hosted platform packages (not needed for CLI)
  115. "infra/**",
  116. "packages/console/**",
  117. "packages/enterprise/**",
  118. "packages/web/**",
  119. "packages/slack/**",
  120. "packages/function/**",
  121. "packages/docs/**",
  122. "packages/identity/**",
  123. // GitHub Action - Kilo version is fully ported and complete
  124. "github/index.ts",
  125. "github/package.json",
  126. "github/tsconfig.json",
  127. "github/bun.lock",
  128. "github/sst-env.d.ts",
  129. ],
  130. // Files that should take upstream version and apply Kilo branding transforms
  131. // These are files with only branding differences, no logic changes
  132. takeTheirsAndTransform: [
  133. // App components with branding only
  134. "packages/app/src/components/**/*.tsx",
  135. "packages/app/src/context/**/*.tsx",
  136. "packages/app/src/pages/**/*.tsx",
  137. // UI components
  138. "packages/ui/src/components/**/*.tsx",
  139. "packages/ui/src/context/**/*.tsx",
  140. // Desktop TypeScript files (not Rust)
  141. "packages/desktop/src/**/*.ts",
  142. // E2E and test fixtures
  143. "packages/app/e2e/**/*.ts",
  144. "packages/app/script/**/*.ts",
  145. ],
  146. // Tauri/Desktop config files with predictable branding patterns
  147. tauriFiles: [
  148. "packages/desktop/src-tauri/tauri.conf.json",
  149. "packages/desktop/src-tauri/tauri.prod.conf.json",
  150. "packages/desktop/src-tauri/Cargo.toml",
  151. "packages/desktop/src-tauri/Cargo.lock",
  152. "packages/desktop/src-tauri/src/*.rs",
  153. ],
  154. // Script files with GitHub API references
  155. scriptFiles: ["script/*.ts", "packages/opencode/script/*.ts"],
  156. // Extension files
  157. extensionFiles: ["packages/extensions/**/*"],
  158. // Web/docs files
  159. webFiles: [],
  160. // Lock files and generated files to accept ours and regenerate after merge
  161. // Note: nix/hashes.json is regenerated by CI (update-nix-hashes.yml), not locally
  162. lockFiles: [
  163. "bun.lock",
  164. "**/bun.lock",
  165. "package-lock.json",
  166. "**/package-lock.json",
  167. "yarn.lock",
  168. "**/yarn.lock",
  169. "pnpm-lock.yaml",
  170. "**/pnpm-lock.yaml",
  171. "Cargo.lock",
  172. "**/Cargo.lock",
  173. "nix/hashes.json",
  174. ],
  175. kiloDirectories: [
  176. "packages/opencode/src/kilocode",
  177. "packages/opencode/test/kilocode",
  178. "packages/kilo-gateway",
  179. "packages/kilo-telemetry",
  180. "packages/kilo-vscode",
  181. "packages/kilo-ui",
  182. "packages/kilo-docs",
  183. "packages/kilo-i18n",
  184. "script/upstream",
  185. ],
  186. excludePatterns: [
  187. "**/node_modules/**",
  188. "**/dist/**",
  189. "**/.git/**",
  190. "**/bun.lock",
  191. "**/package-lock.json",
  192. "**/yarn.lock",
  193. ],
  194. baseBranch: "main",
  195. branchPrefix: "upstream-merge",
  196. upstreamRemote: "upstream",
  197. originRemote: "origin",
  198. // i18n translation files that need Kilo branding transforms
  199. i18nPatterns: ["packages/*/src/i18n/*.ts", "packages/desktop/src/i18n/*.ts"],
  200. }
  201. export function loadConfig(overrides?: Partial<MergeConfig>): MergeConfig {
  202. return { ...defaultConfig, ...overrides }
  203. }