|
1 | 1 | import { expect } from "bun:test" |
2 | 2 | import { Agent } from "@opencode/core/agent" |
3 | 3 | import { Plugin } from "@opencode/core/plugin" |
| 4 | +import { InstructionDiscovery } from "@opencode/core/instruction-discovery" |
| 5 | +import { Instructions } from "@opencode/core/instructions/index" |
4 | 6 | import { CustomAutoLoadSkillsPlugin } from "@opencode/core/plugin/custom/auto-load-skills" |
| 7 | +import { CustomInstructionsPlugin } from "@opencode/core/plugin/custom/instructions" |
5 | 8 | import { CustomTaskResumePlugin } from "@opencode/core/plugin/custom/task-resume" |
6 | 9 | import { CustomTimeoutsPlugin } from "@opencode/core/plugin/custom/timeouts" |
7 | 10 | import { PluginHooks } from "@opencode/core/plugin/hooks" |
8 | 11 | import { PluginHost } from "@opencode/core/plugin/host" |
| 12 | +import { AbsolutePath } from "@opencode/core/schema" |
9 | 13 | import { Session } from "@opencode/core/session" |
10 | 14 | import { Tool } from "@opencode/schema/tool" |
11 | 15 | import { SessionMessage } from "@opencode/schema/session-message" |
12 | | -import { Effect } from "effect" |
| 16 | +import { DateTime, Effect } from "effect" |
13 | 17 | import { testEffect } from "../lib/effect" |
14 | 18 | import { PluginTestLayer } from "./fixture" |
15 | 19 |
|
@@ -60,6 +64,31 @@ it.effect("disables the default shell timeout until a session opts in", () => |
60 | 64 | }), |
61 | 65 | ) |
62 | 66 |
|
| 67 | +it.effect("collects instruction files without duplicates and flags unavailable discovery", () => |
| 68 | + Effect.sync(() => { |
| 69 | + const project = AbsolutePath.make("/repo") |
| 70 | + const history = [ |
| 71 | + SessionMessage.Synthetic.make({ |
| 72 | + id: SessionMessage.ID.make("msg_nested"), |
| 73 | + type: "synthetic", |
| 74 | + text: "nested", |
| 75 | + metadata: { instruction: { paths: [`${project}/AGENTS.md`, `${project}/packages/web/AGENTS.md`] } }, |
| 76 | + time: { created: DateTime.makeUnsafe(0) }, |
| 77 | + }), |
| 78 | + ] |
| 79 | + const ambient = [new InstructionDiscovery.File({ path: AbsolutePath.make(`${project}/AGENTS.md`), content: "root" })] |
| 80 | + expect(CustomInstructionsPlugin.instructionFiles(project, ambient, history)).toEqual({ |
| 81 | + unavailable: false, |
| 82 | + files: ["AGENTS.md", "packages/web/AGENTS.md"], |
| 83 | + }) |
| 84 | + expect(CustomInstructionsPlugin.instructionFiles(project, Instructions.unavailable, history)).toEqual({ |
| 85 | + unavailable: true, |
| 86 | + files: ["AGENTS.md", "packages/web/AGENTS.md"], |
| 87 | + }) |
| 88 | + expect(CustomInstructionsPlugin.instructionFiles(project, [], [])).toEqual({ unavailable: false, files: [] }) |
| 89 | + }), |
| 90 | +) |
| 91 | + |
63 | 92 | it.effect("parses the auto-load skill list", () => |
64 | 93 | Effect.sync(() => { |
65 | 94 | expect(CustomAutoLoadSkillsPlugin.parse(" Foo, bar ,,")).toEqual(["foo", "bar"]) |
|
0 commit comments