Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fuzzy-pigs-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Install npm-managed plugins and runtime packages under Kilo's cache directory.
26 changes: 23 additions & 3 deletions packages/opencode/src/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { definitions, flatten, nerfDarts, shorthands } from "@npmcli/config/lib/
import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect"
import { NodeFileSystem } from "@effect/platform-node"
import { AppFileSystem } from "@opencode-ai/shared/filesystem"
import { Global } from "@opencode-ai/shared/global"
import { Global as Shared } from "@opencode-ai/shared/global" // kilocode_change
import { EffectFlock } from "@opencode-ai/shared/util/effect-flock"
// kilocode_change start - keep npm-managed package caches in Kilo's XDG paths.
import { Global as Kilo } from "../global"
// kilocode_change end

import { makeRuntime } from "../effect/runtime"

Expand Down Expand Up @@ -103,7 +106,7 @@ export const layer = Layer.effect(
Service,
Effect.gen(function* () {
const afs = yield* AppFileSystem.Service
const global = yield* Global.Service
const global = yield* Shared.Service // kilocode_change
const fs = yield* FileSystem.FileSystem
const flock = yield* EffectFlock.Service
const directory = (pkg: string) => path.join(global.cache, "packages", sanitize(pkg))
Expand Down Expand Up @@ -299,10 +302,27 @@ export const layer = Layer.effect(
}),
)

// kilocode_change start - the shared global layer is still opencode-branded upstream.
const kilo = Layer.succeed(
Shared.Service,
Shared.Service.of({
home: Kilo.Path.home,
data: Kilo.Path.data,
cache: Kilo.Path.cache,
config: Kilo.Path.config,
state: Kilo.Path.state,
bin: Kilo.Path.bin,
log: Kilo.Path.log,
}),
)
// kilocode_change end

export const defaultLayer = layer.pipe(
Layer.provide(EffectFlock.layer),
Layer.provide(AppFileSystem.layer),
Layer.provide(Global.layer),
// kilocode_change start
Layer.provide(kilo),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Kilo-specific change is outside the annotation block

This line is the actual default-layer switch from the shared opencode global paths to Kilo paths, but it is not covered by a kilocode_change marker. The opencode annotation check scans added lines in shared packages/opencode files, so this and the related unmarked changed lines will fail CI unless they are covered by an inline marker or surrounding block.

// kilocode_change end
Layer.provide(NodeFileSystem.layer),
)

Expand Down
17 changes: 17 additions & 0 deletions packages/opencode/test/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import path from "path"
import { describe, expect, test } from "bun:test"
import { Npm } from "../src/npm"
import { tmpdir } from "./fixture/fixture"
// kilocode_change start
import { Global } from "../src/global"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Kilo-specific test changes need annotation coverage

packages/opencode/test/npm.test.ts is a shared opencode test file, and the added import plus regression test are Kilo-specific. The opencode annotation check will flag these added lines unless they are covered with kilocode_change markers.

// kilocode_change end

const win = process.platform === "win32"
const writePackage = (dir: string, pkg: Record<string, unknown>) =>
Expand Down Expand Up @@ -51,5 +54,19 @@ describe("Npm.install", () => {

await expect(fs.stat(path.join(tmp.path, "node_modules", "prod-pkg"))).resolves.toBeDefined()
await expect(fs.stat(path.join(tmp.path, "node_modules", "dev-pkg"))).rejects.toThrow()
}) // kilocode_change
}) // kilocode_change

// kilocode_change start - Kilo should not inherit opencode-branded npm cache paths.
describe("Npm.add", () => {
test("uses Kilo cache path", async () => {
const dir = path.join(Global.Path.cache, "packages", "acme", "node_modules", ".bin")
await fs.mkdir(dir, { recursive: true })
await Bun.write(path.join(dir, "acme"), "#!/usr/bin/env node\n")

const result = await Npm.which("acme")

expect(result).toBe(path.join(dir, "acme"))
})
})
// kilocode_change end
Loading