feat(core): add project reference guidance (#31601)

This commit is contained in:
Dax 2026-06-10 00:08:26 -04:00 committed by GitHub
commit 8a2cfc00c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 753 additions and 165 deletions

View file

@ -14,6 +14,7 @@ import { Plugin } from "../../src/plugin"
import { Provider } from "../../src/provider/provider"
import { Skill } from "../../src/skill"
import { Truncate } from "../../src/tool/truncate"
import { LocationServiceMap } from "@opencode-ai/core/location-layer"
const agentLayer = (flags: Partial<RuntimeFlags.Info> = {}) =>
Agent.layer.pipe(
@ -22,6 +23,7 @@ const agentLayer = (flags: Partial<RuntimeFlags.Info> = {}) =>
Layer.provide(Auth.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(Skill.defaultLayer),
Layer.provide(LocationServiceMap.layer),
Layer.provide(RuntimeFlags.layer(flags)),
)
@ -119,7 +121,7 @@ it.instance(
}),
{
config: {
reference: {
references: {
effect: "github.com/effect/effect-smol",
effectFull: {
repository: "Effect-TS/effect",
@ -601,6 +603,25 @@ description: Permission skill.
{ git: true },
)
it.instance(
"project reference directories are allowed for external_directory",
() =>
Effect.gen(function* () {
const test = yield* TestInstance
const build = yield* load((svc) => svc.get("build"))
const target = path.resolve(test.directory, "../docs/reference/notes.md")
expect(Permission.evaluate("external_directory", target, build!.permission).action).toBe("allow")
}),
{
git: true,
config: {
references: {
docs: "../docs",
},
},
},
)
it.instance("defaultAgent returns build when no default_agent config", () =>
Effect.gen(function* () {
const agent = yield* load((svc) => svc.defaultAgent())

View file

@ -1,5 +1,6 @@
import { expect } from "bun:test"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { LocationServiceMap } from "@opencode-ai/core/location-layer"
import { Effect, Layer } from "effect"
import { FetchHttpClient } from "effect/unstable/http"
import path from "path"
@ -43,6 +44,7 @@ const agentLayer = Agent.layer.pipe(
Layer.provide(SkillTest.empty),
Layer.provide(provider.layer),
Layer.provide(pluginLayer),
Layer.provide(LocationServiceMap.layer),
Layer.provide(RuntimeFlags.layer({ disableDefaultPlugins: true })),
)

View file

@ -16,7 +16,7 @@ describe("reference HttpApi", () => {
config: {
formatter: false,
lsp: false,
reference: {
references: {
docs: "./docs",
effect: { repository: "Effect-TS/effect", branch: "main" },
bad: "not-a-repo",
@ -35,18 +35,26 @@ describe("reference HttpApi", () => {
{
name: "docs",
path: path.join(tmp.path, "docs"),
description: null,
hidden: null,
source: {
type: "local",
path: path.join(tmp.path, "docs"),
description: null,
hidden: null,
},
},
{
name: "effect",
path: path.join(Global.Path.repos, "github.com", "Effect-TS", "effect"),
description: null,
hidden: null,
source: {
type: "git",
repository: "Effect-TS/effect",
branch: "main",
description: null,
hidden: null,
},
},
])

View file

@ -5,6 +5,7 @@ import { NamedError } from "@opencode-ai/core/util/error"
import { Skill } from "../../src/skill"
import { Permission } from "../../src/permission"
import { SystemPrompt } from "../../src/session/system"
import { LocationServiceMap } from "@opencode-ai/core/location-layer"
import { testEffect } from "../lib/effect"
const skills: Skill.Info[] = [
@ -42,6 +43,7 @@ const build: Agent.Info = {
const it = testEffect(
SystemPrompt.layer.pipe(
Layer.provide(LocationServiceMap.layer),
Layer.provide(
Layer.succeed(
Skill.Service,