diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index 0c0fc491061..4fcef9bc7c8 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -331,6 +331,8 @@ for (const item of targets) { version: Script.version, os: [item.os], cpu: [item.arch], + keywords: pkg.keywords, // kilocode_change + private: pkg.private, // kilocode_change // kilocode_change start repository: { type: "git", diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts index 32fc84028bf..126f43a34ca 100755 --- a/packages/opencode/script/publish.ts +++ b/packages/opencode/script/publish.ts @@ -54,6 +54,8 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( }, version: version, license: pkg.license, + keywords: pkg.keywords, // kilocode_change + private: pkg.private, // kilocode_change optionalDependencies: binaries, // kilocode_change start repository: { diff --git a/script/upstream/transforms/transform-package-json.test.ts b/script/upstream/transforms/transform-package-json.test.ts index 227ff2e4964..60e6d46e09f 100644 --- a/script/upstream/transforms/transform-package-json.test.ts +++ b/script/upstream/transforms/transform-package-json.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test" -import { fixCatalog, fixScripts, mergeWithNewestVersions } from "./transform-package-json" +import { fixCatalog, fixMetadata, fixScripts, mergeWithNewestVersions } from "./transform-package-json" test("fixScripts preserves Kilo-only root scripts from base", () => { const ours = { @@ -85,6 +85,17 @@ test("fixCatalog is a no-op when catalog is absent", () => { expect(changes.length).toBe(0) }) +test("fixMetadata preserves opencode publish metadata from base", () => { + const ours = { keywords: ["cli", "kilo", "opencode"], private: false } + const pkg: Record = { keywords: ["opencode"], private: true } + const changes: string[] = [] + fixMetadata(pkg, "packages/opencode/package.json", ours, changes) + expect(pkg.keywords).toEqual(ours.keywords) + expect(pkg.private).toBe(false) + expect(changes).toContain("keywords: preserved from base") + expect(changes).toContain("private: preserved from base") +}) + test("mergeWithNewestVersions preserves ours' key order so kilo-only deps don't relocate", () => { // Regression: when ours has a kilo-only dep in the middle (e.g. rotating-file-stream // alphabetically between npm-package-arg and semver) and theirs lacks it, the merge diff --git a/script/upstream/transforms/transform-package-json.ts b/script/upstream/transforms/transform-package-json.ts index e65432cd219..20fa0b280a3 100644 --- a/script/upstream/transforms/transform-package-json.ts +++ b/script/upstream/transforms/transform-package-json.ts @@ -289,6 +289,24 @@ export function fixCatalog(pkg: Record, path: string, changes: } } +export function fixMetadata( + pkg: Record, + path: string, + ours: Record | null, + changes: string[], +): void { + if (path !== "packages/opencode/package.json") return + if (!ours) return + if (Array.isArray(ours.keywords) && JSON.stringify(pkg.keywords) !== JSON.stringify(ours.keywords)) { + pkg.keywords = ours.keywords + changes.push("keywords: preserved from base") + } + if (typeof ours.private === "boolean" && pkg.private !== ours.private) { + pkg.private = ours.private + changes.push("private: preserved from base") + } +} + /** * Check if file is a package.json */ @@ -431,6 +449,8 @@ export async function transformPackageJson(file: string, options: PackageJsonOpt changes.push(`repository: preserved Kilo's repository configuration`) } + fixMetadata(pkg, relativePath, ourPkg, changes) + // 7. Handle workspaces for root package.json // Kilo has removed hosted platform packages (console/*, slack, etc.) // so we need to preserve Kilo's workspace configuration instead of taking upstream's @@ -649,6 +669,8 @@ export async function transformAllPackageJson(options: PackageJsonOptions = {}): changes.push(`repository: preserved Kilo's repository configuration`) } + fixMetadata(pkg, path, kiloPkg, changes) + // 7. Handle workspaces for root package.json // Kilo has removed hosted platform packages (console/*, slack, etc.) // so we need to preserve Kilo's workspace configuration instead of taking upstream's @@ -793,6 +815,7 @@ export async function reconcilePackageJsonFromRefs( if (!ourPkg) return { file, action: "skipped", changes: [], dryRun } pkg = JSON.parse(JSON.stringify(ourPkg)) } + if (!pkg) return { file, action: "skipped", changes: [], dryRun } const relativePath = file.replace(process.cwd() + "/", "") const newName = TRANSFORM_PACKAGE_NAMES[relativePath] @@ -857,6 +880,8 @@ export async function reconcilePackageJsonFromRefs( changes.push(`repository: preserved Kilo's repository configuration`) } + fixMetadata(pkg, relativePath, ourPkg, changes) + const ourWs = ourPkg.workspaces as { packages?: string[]; catalog?: Record } | undefined const theirWs = pkg.workspaces as { packages?: string[]; catalog?: Record } | undefined