mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-10-30 19:32:39 +08:00
Introduce a primaryWorktree Effect that queries Git plumbing commands to locate the main checkout from any linked worktree. Integrate it into config loading so .kilo directory settings from the primary checkout act as local-scoped fallbacks beneath the active worktree and KILO_CONFIG_DIR overrides. Wire primaryPaths into skill discovery so project skills installed in the primary checkout appear as fallbacks unless overridden locally. Refactor session family matching to consider sandbox directories and filter out nested Git repositories when resolving worktree roots. Convert baselineDirectory in indexing to an Effect that delegates to primaryWorktree instead of reading Instance.project.worktree directly. Restore the content() signal usage in the TUI text part renderer. Provide Git.defaultLayer across all affected test layers and add coverage for linked worktrees, submodules, paths with spaces, sandbox project matching, and primary config directory precedence.
65 lines
2.6 KiB
TypeScript
65 lines
2.6 KiB
TypeScript
import { expect } from "bun:test"
|
|
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
|
import { Effect, Layer } from "effect"
|
|
import { FetchHttpClient } from "effect/unstable/http"
|
|
import path from "path"
|
|
import { pathToFileURL } from "url"
|
|
import { Agent } from "../../src/agent/agent"
|
|
import { Bus } from "../../src/bus"
|
|
import { Config } from "../../src/config/config"
|
|
import { Env } from "../../src/env"
|
|
import { Git } from "../../src/git" // kilocode_change
|
|
import { RuntimeFlags } from "../../src/effect/runtime-flags"
|
|
import { Plugin } from "../../src/plugin"
|
|
import { AccountTest } from "../fake/account"
|
|
import { AuthTest } from "../fake/auth"
|
|
import { NpmTest } from "../fake/npm"
|
|
import { ProviderTest } from "../fake/provider"
|
|
import { SkillTest } from "../fake/skill"
|
|
import { testEffect } from "../lib/effect"
|
|
import { PLUGIN_AGENT } from "../fixture/agent-plugin.constants"
|
|
|
|
// `it.instance` skips InstanceBootstrap so FileWatcher / LSP / MCP don't spin
|
|
// up — those services hang during scope teardown on Windows and aren't needed
|
|
// to verify plugin → config hook → Agent.list.
|
|
const pluginUrl = pathToFileURL(path.join(import.meta.dir, "..", "fixture", "agent-plugin.ts")).href
|
|
|
|
const provider = ProviderTest.fake()
|
|
const configLayer = Config.layer.pipe(
|
|
Layer.provide(Git.defaultLayer), // kilocode_change
|
|
Layer.provide(RuntimeFlags.layer({ disableDefaultPlugins: true })),
|
|
Layer.provide(AppFileSystem.defaultLayer),
|
|
Layer.provide(Env.defaultLayer),
|
|
Layer.provide(AuthTest.empty),
|
|
Layer.provide(AccountTest.empty),
|
|
Layer.provide(NpmTest.noop),
|
|
Layer.provide(FetchHttpClient.layer),
|
|
)
|
|
const pluginLayer = Plugin.layer.pipe(
|
|
Layer.provide(Bus.layer),
|
|
Layer.provide(RuntimeFlags.layer({ disableDefaultPlugins: true })),
|
|
)
|
|
const dependencies = Layer.mergeAll(configLayer, pluginLayer).pipe(Layer.provideMerge(configLayer))
|
|
const agentLayer = Agent.layer.pipe(
|
|
Layer.provide(AuthTest.empty),
|
|
Layer.provide(SkillTest.empty),
|
|
Layer.provide(provider.layer),
|
|
Layer.provide(RuntimeFlags.layer({ disableDefaultPlugins: true })),
|
|
)
|
|
const layer = Layer.mergeAll(agentLayer, dependencies).pipe(Layer.provideMerge(dependencies))
|
|
|
|
const it = testEffect(layer)
|
|
|
|
it.instance(
|
|
"plugin-registered agents appear in Agent.list",
|
|
() =>
|
|
Effect.gen(function* () {
|
|
yield* Plugin.Service.use((p) => p.init())
|
|
const agents = yield* Agent.use.list()
|
|
const added = agents.find((agent) => agent.name === PLUGIN_AGENT.name)
|
|
expect(added?.description).toBe(PLUGIN_AGENT.description)
|
|
expect(added?.mode).toBe(PLUGIN_AGENT.mode)
|
|
}),
|
|
{ config: { plugin: [pluginUrl] } },
|
|
)
|