Skip to content

Commit dd423db

Browse files
committed
refactor(core): rename guidance modules
1 parent 0a5530d commit dd423db

9 files changed

Lines changed: 103 additions & 97 deletions

File tree

packages/core/src/location-services.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import { Pty } from "./pty"
2727
import { QuestionV2 } from "./question"
2828
import { Shell } from "./shell"
2929
import { Reference } from "./reference"
30-
import { ReferenceGuidance } from "./reference/guidance"
30+
import { ReferenceInstructions } from "./reference/instructions"
3131
import { SessionRunnerLLM } from "./session/runner/llm"
3232
import { SessionRunnerModel } from "./session/runner/model"
3333
import { SessionCompaction } from "./session/compaction"
3434
import { SessionTitle } from "./session/title"
3535
import { SkillV2 } from "./skill"
36-
import { SkillGuidance } from "./skill/guidance"
36+
import { SkillInstructions } from "./skill/instructions"
3737
import { Snapshot } from "./snapshot"
3838
import { InstructionDiscovery } from "./instruction-discovery"
3939
import { InstructionBuiltIns } from "./instructions/builtins"
@@ -75,8 +75,8 @@ const locationServiceNodes = [
7575
ToolRegistry.node,
7676
ToolRegistry.toolsNode,
7777
Image.node,
78-
SkillGuidance.node,
79-
ReferenceGuidance.node,
78+
SkillInstructions.node,
79+
ReferenceInstructions.node,
8080
InstructionEntry.node,
8181
Form.node,
8282
QuestionV2.node,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * as McpGuidance from "./guidance"
1+
export * as McpInstructions from "./instructions"
22

33
import { makeLocationNode } from "../effect/app-node"
44
import { Context, Effect, Layer, Schema } from "effect"
@@ -54,15 +54,15 @@ export interface Interface {
5454
readonly load: (agent: AgentV2.Selection) => Effect.Effect<Instructions.Instructions>
5555
}
5656

57-
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/McpGuidance") {}
57+
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/McpInstructions") {}
5858

5959
export const layer = Layer.effect(
6060
Service,
6161
Effect.gen(function* () {
6262
const mcp = yield* MCP.Service
6363

6464
return Service.of({
65-
load: Effect.fn("McpGuidance.load")(function* (selection) {
65+
load: Effect.fn("McpInstructions.load")(function* (selection) {
6666
const agent = selection.info
6767
if (!agent) return Instructions.empty
6868
const source = (value: ReadonlyArray<Summary> | Instructions.Removed) =>

packages/core/src/reference/guidance.ts renamed to packages/core/src/reference/instructions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * as ReferenceGuidance from "./guidance"
1+
export * as ReferenceInstructions from "./instructions"
22

33
import { makeLocationNode } from "../effect/app-node"
44
import { Context, Effect, Layer, Schema } from "effect"
@@ -57,15 +57,15 @@ export interface Interface {
5757
readonly load: () => Effect.Effect<Instructions.Instructions>
5858
}
5959

60-
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/ReferenceGuidance") {}
60+
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/ReferenceInstructions") {}
6161

6262
const layer = Layer.effect(
6363
Service,
6464
Effect.gen(function* () {
6565
const references = yield* Reference.Service
6666

6767
return Service.of({
68-
load: Effect.fn("ReferenceGuidance.load")(function* () {
68+
load: Effect.fn("ReferenceInstructions.load")(function* () {
6969
const available = (yield* references.list())
7070
.filter((reference) => reference.description !== undefined)
7171
.map((reference) => ({

packages/core/src/session/context.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { InstructionDiscovery } from "../instruction-discovery"
88
import { Instructions } from "../instructions/index"
99
import { InstructionBuiltIns } from "../instructions/builtins"
1010
import { Location } from "../location"
11-
import { McpGuidance } from "../mcp/guidance"
11+
import { McpInstructions } from "../mcp/instructions"
1212
import { PluginSupervisor } from "../plugin/supervisor"
13-
import { ReferenceGuidance } from "../reference/guidance"
14-
import { SkillGuidance } from "../skill/guidance"
13+
import { ReferenceInstructions } from "../reference/instructions"
14+
import { SkillInstructions } from "../skill/instructions"
1515
import { AgentNotFoundError } from "./error"
1616
import { SessionHistory } from "./history"
1717
import { InstructionEntry } from "./instruction-entry"
@@ -52,11 +52,11 @@ const layer = Layer.effect(
5252
const discovery = yield* InstructionDiscovery.Service
5353
const entries = yield* InstructionEntry.Service
5454
const location = yield* Location.Service
55-
const mcpGuidance = yield* McpGuidance.Service
55+
const mcpInstructions = yield* McpInstructions.Service
5656
const models = yield* SessionRunnerModel.Service
5757
const plugins = yield* PluginSupervisor.Service
58-
const referenceGuidance = yield* ReferenceGuidance.Service
59-
const skillGuidance = yield* SkillGuidance.Service
58+
const referenceInstructions = yield* ReferenceInstructions.Service
59+
const skillInstructions = yield* SkillInstructions.Service
6060
const store = yield* SessionStore.Service
6161

6262
const select = Effect.fn("SessionContext.select")(function* (sessionID: SessionSchema.ID) {
@@ -72,9 +72,9 @@ const layer = Layer.effect(
7272
[
7373
builtins.load(sessionID),
7474
discovery.load(),
75-
skillGuidance.load(agent),
76-
referenceGuidance.load(),
77-
mcpGuidance.load(agent),
75+
skillInstructions.load(agent),
76+
referenceInstructions.load(),
77+
mcpInstructions.load(agent),
7878
entries.load(sessionID),
7979
],
8080
{ concurrency: "unbounded" },
@@ -108,11 +108,11 @@ export const node = makeLocationNode({
108108
InstructionDiscovery.node,
109109
InstructionEntry.node,
110110
Location.node,
111-
McpGuidance.node,
111+
McpInstructions.node,
112112
PluginSupervisor.node,
113-
ReferenceGuidance.node,
113+
ReferenceInstructions.node,
114114
SessionRunnerModel.node,
115115
SessionStore.node,
116-
SkillGuidance.node,
116+
SkillInstructions.node,
117117
],
118118
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * as SkillGuidance from "./guidance"
1+
export * as SkillInstructions from "./instructions"
22

33
import { makeLocationNode } from "../effect/app-node"
44
import { Context, Effect, Layer, Schema } from "effect"
@@ -60,15 +60,15 @@ export interface Interface {
6060
readonly load: (agent: AgentV2.Selection) => Effect.Effect<Instructions.Instructions>
6161
}
6262

63-
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/SkillGuidance") {}
63+
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/SkillInstructions") {}
6464

6565
const layer = Layer.effect(
6666
Service,
6767
Effect.gen(function* () {
6868
const skills = yield* SkillV2.Service
6969

7070
return Service.of({
71-
load: Effect.fn("SkillGuidance.load")(function* (selection) {
71+
load: Effect.fn("SkillInstructions.load")(function* (selection) {
7272
const agent = selection.info
7373
if (!agent) return Instructions.empty
7474
const permitted = SkillV2.available(yield* skills.list(), agent)

packages/core/test/reference-guidance.test.ts renamed to packages/core/test/reference-instructions.test.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ import { Effect, Layer } from "effect"
33
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
44
import { AbsolutePath } from "@opencode-ai/core/schema"
55
import { Reference } from "@opencode-ai/core/reference"
6-
import { ReferenceGuidance } from "@opencode-ai/core/reference/guidance"
6+
import { ReferenceInstructions } from "@opencode-ai/core/reference/instructions"
77
import { it } from "./lib/effect"
88
import { readInitial, readUpdate } from "./lib/instructions"
99

10-
const guidanceLayer = (referenceLayer: Layer.Layer<Reference.Service>) =>
11-
AppNodeBuilder.build(ReferenceGuidance.node, [[Reference.node, referenceLayer]])
10+
const instructionsLayer = (referenceLayer: Layer.Layer<Reference.Service>) =>
11+
AppNodeBuilder.build(ReferenceInstructions.node, [[Reference.node, referenceLayer]])
1212

13-
describe("ReferenceGuidance", () => {
13+
describe("ReferenceInstructions", () => {
1414
it.effect("lists available references in the instructions", () =>
1515
Effect.gen(function* () {
16-
const guidance = yield* ReferenceGuidance.Service
17-
const generation = yield* readInitial(yield* guidance.load())
16+
const instructions = yield* ReferenceInstructions.Service
17+
const generation = yield* readInitial(yield* instructions.load())
1818

1919
expect(generation.text).toContain("<available_references>")
2020
expect(generation.text).toContain("<name>docs</name>")
2121
expect(generation.text).toContain("<path>/docs</path>")
2222
expect(generation.text).toContain("<description>Use for product documentation</description>")
2323
}).pipe(
2424
Effect.provide(
25-
guidanceLayer(
25+
instructionsLayer(
2626
Layer.mock(Reference.Service, {
2727
list: () =>
2828
Effect.succeed([
@@ -43,22 +43,22 @@ describe("ReferenceGuidance", () => {
4343
),
4444
)
4545

46-
it.effect("omits guidance when no references are available", () =>
46+
it.effect("omits instructions when no references are available", () =>
4747
Effect.gen(function* () {
48-
const guidance = yield* ReferenceGuidance.Service
49-
const generation = yield* readInitial(yield* guidance.load())
48+
const instructions = yield* ReferenceInstructions.Service
49+
const generation = yield* readInitial(yield* instructions.load())
5050
expect(generation.text).toBe("")
51-
}).pipe(Effect.provide(guidanceLayer(Layer.mock(Reference.Service, { list: () => Effect.succeed([]) })))),
51+
}).pipe(Effect.provide(instructionsLayer(Layer.mock(Reference.Service, { list: () => Effect.succeed([]) })))),
5252
)
5353

5454
it.effect("omits references without descriptions", () =>
5555
Effect.gen(function* () {
56-
const guidance = yield* ReferenceGuidance.Service
57-
const generation = yield* readInitial(yield* guidance.load())
56+
const instructions = yield* ReferenceInstructions.Service
57+
const generation = yield* readInitial(yield* instructions.load())
5858
expect(generation.text).toBe("")
5959
}).pipe(
6060
Effect.provide(
61-
guidanceLayer(
61+
instructionsLayer(
6262
Layer.mock(Reference.Service, {
6363
list: () =>
6464
Effect.succeed([
@@ -84,11 +84,11 @@ describe("ReferenceGuidance", () => {
8484
})
8585
let references = [reference("docs", "Use for product documentation")]
8686
return Effect.gen(function* () {
87-
const guidance = yield* ReferenceGuidance.Service
88-
const initialized = yield* readInitial(yield* guidance.load())
87+
const instructions = yield* ReferenceInstructions.Service
88+
const initialized = yield* readInitial(yield* instructions.load())
8989

9090
references = [reference("docs", "Use for product documentation"), reference("examples", "Use for examples")]
91-
const added = yield* readUpdate(yield* guidance.load(), initialized)
91+
const added = yield* readUpdate(yield* instructions.load(), initialized)
9292
expect(added.text).toBe(
9393
[
9494
"New project references are available in addition to those previously listed:",
@@ -101,9 +101,11 @@ describe("ReferenceGuidance", () => {
101101
)
102102

103103
references = [reference("examples", "Use for examples")]
104-
expect((yield* readUpdate(yield* guidance.load(), added)).text).toBe(
104+
expect((yield* readUpdate(yield* instructions.load(), added)).text).toBe(
105105
"The following project references are no longer available and must not be used: docs.",
106106
)
107-
}).pipe(Effect.provide(guidanceLayer(Layer.mock(Reference.Service, { list: () => Effect.succeed(references) }))))
107+
}).pipe(
108+
Effect.provide(instructionsLayer(Layer.mock(Reference.Service, { list: () => Effect.succeed(references) }))),
109+
)
108110
})
109111
})

packages/core/test/session-runner-recorded.test.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import { Location } from "@opencode-ai/core/location"
3333
import { InstructionBuiltIns } from "@opencode-ai/core/instructions/builtins"
3434
import { InstructionDiscovery } from "@opencode-ai/core/instruction-discovery"
3535
import { Instructions } from "@opencode-ai/core/instructions"
36-
import { SkillGuidance } from "@opencode-ai/core/skill/guidance"
37-
import { ReferenceGuidance } from "@opencode-ai/core/reference/guidance"
38-
import { McpGuidance } from "@opencode-ai/core/mcp/guidance"
36+
import { SkillInstructions } from "@opencode-ai/core/skill/instructions"
37+
import { ReferenceInstructions } from "@opencode-ai/core/reference/instructions"
38+
import { McpInstructions } from "@opencode-ai/core/mcp/instructions"
3939
import { PluginSupervisor } from "@opencode-ai/core/plugin/supervisor"
4040
import { PluginHooks } from "@opencode-ai/core/plugin/hooks"
4141
import { SystemPromptPlugin } from "@opencode-ai/core/plugin/system-prompt"
@@ -76,9 +76,11 @@ const model = OpenAIChat.route
7676
const models = SessionRunnerModel.layerWith(() => Effect.succeed(SessionRunnerModel.resolved(model)))
7777
const systemContext = Layer.mock(InstructionBuiltIns.Service, { load: () => Effect.succeed(Instructions.empty) })
7878
const instructionContext = Layer.mock(InstructionDiscovery.Service, { load: () => Effect.succeed(Instructions.empty) })
79-
const skillGuidance = Layer.mock(SkillGuidance.Service, { load: () => Effect.succeed(Instructions.empty) })
80-
const referenceGuidance = Layer.mock(ReferenceGuidance.Service, { load: () => Effect.succeed(Instructions.empty) })
81-
const mcpGuidance = Layer.mock(McpGuidance.Service, { load: () => Effect.succeed(Instructions.empty) })
79+
const skillInstructions = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
80+
const referenceInstructions = Layer.mock(ReferenceInstructions.Service, {
81+
load: () => Effect.succeed(Instructions.empty),
82+
})
83+
const mcpInstructions = Layer.mock(McpInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
8284
const config = Layer.succeed(Config.Service, Config.Service.of({ entries: () => Effect.succeed([]) }))
8385
const pluginSupervisor = Layer.succeed(PluginSupervisor.Service, PluginSupervisor.Service.of({ flush: Effect.void }))
8486
const promptCatalog = Layer.mock(Catalog.Service, {
@@ -102,9 +104,9 @@ const runnerLayer = AppNodeBuilder.build(SessionRunnerLLM.node, [
102104
[InstructionBuiltIns.node, systemContext],
103105
[InstructionDiscovery.node, instructionContext],
104106
[Location.node, Location.boundNode({ directory: AbsolutePath.make("/project") })],
105-
[SkillGuidance.node, skillGuidance],
106-
[ReferenceGuidance.node, referenceGuidance],
107-
[McpGuidance.node, mcpGuidance],
107+
[SkillInstructions.node, skillInstructions],
108+
[ReferenceInstructions.node, referenceInstructions],
109+
[McpInstructions.node, mcpInstructions],
108110
[Config.node, config],
109111
[PermissionV2.node, permission],
110112
[ToolOutputStore.node, ToolOutputStore.nodeWithoutConfig],
@@ -140,8 +142,8 @@ const it = testEffect(
140142
SessionRunnerModel.node,
141143
InstructionBuiltIns.node,
142144
InstructionDiscovery.node,
143-
SkillGuidance.node,
144-
ReferenceGuidance.node,
145+
SkillInstructions.node,
146+
ReferenceInstructions.node,
145147
Config.node,
146148
Snapshot.node,
147149
SessionRunnerLLM.node,
@@ -156,8 +158,8 @@ const it = testEffect(
156158
[InstructionBuiltIns.node, systemContext],
157159
[InstructionDiscovery.node, instructionContext],
158160
[Location.node, Location.boundNode({ directory: AbsolutePath.make("/project") })],
159-
[SkillGuidance.node, skillGuidance],
160-
[ReferenceGuidance.node, referenceGuidance],
161+
[SkillInstructions.node, skillInstructions],
162+
[ReferenceInstructions.node, referenceInstructions],
161163
[Config.node, config],
162164
[Snapshot.node, Snapshot.noopLayer],
163165
[PluginSupervisor.node, pluginSupervisor],

packages/core/test/session-runner.test.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ import { SessionStore } from "@opencode-ai/core/session/store"
6363
import { Instructions } from "@opencode-ai/core/instructions"
6464
import { InstructionBuiltIns } from "@opencode-ai/core/instructions/builtins"
6565
import { InstructionDiscovery } from "@opencode-ai/core/instruction-discovery"
66-
import { SkillGuidance } from "@opencode-ai/core/skill/guidance"
67-
import { ReferenceGuidance } from "@opencode-ai/core/reference/guidance"
68-
import { McpGuidance } from "@opencode-ai/core/mcp/guidance"
66+
import { SkillInstructions } from "@opencode-ai/core/skill/instructions"
67+
import { ReferenceInstructions } from "@opencode-ai/core/reference/instructions"
68+
import { McpInstructions } from "@opencode-ai/core/mcp/instructions"
6969
import { ModelV2 } from "@opencode-ai/core/model"
7070
import { Location } from "@opencode-ai/core/location"
7171
import { ProviderV2 } from "@opencode-ai/core/provider"
@@ -318,7 +318,7 @@ const systemContext = Layer.mock(InstructionBuiltIns.Service, {
318318
),
319319
})
320320
const instructionContext = Layer.mock(InstructionDiscovery.Service, { load: () => Effect.succeed(Instructions.empty) })
321-
const skillGuidance = Layer.mock(SkillGuidance.Service, {
321+
const skillInstructions = Layer.mock(SkillInstructions.Service, {
322322
load: (agent) =>
323323
Effect.succeed(
324324
skillBaselines.has(agent.id)
@@ -335,8 +335,10 @@ const skillGuidance = Layer.mock(SkillGuidance.Service, {
335335
: Instructions.empty,
336336
),
337337
})
338-
const referenceGuidance = Layer.mock(ReferenceGuidance.Service, { load: () => Effect.succeed(Instructions.empty) })
339-
const mcpGuidance = Layer.mock(McpGuidance.Service, { load: () => Effect.succeed(Instructions.empty) })
338+
const referenceInstructions = Layer.mock(ReferenceInstructions.Service, {
339+
load: () => Effect.succeed(Instructions.empty),
340+
})
341+
const mcpInstructions = Layer.mock(McpInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
340342
const config = Layer.succeed(
341343
Config.Service,
342344
Config.Service.of({
@@ -382,11 +384,11 @@ const runnerLayer = AppNodeBuilder.build(SessionRunnerLLM.node, [
382384
[InstructionBuiltIns.node, systemContext],
383385
[InstructionDiscovery.node, instructionContext],
384386
[Location.node, Location.boundNode({ directory: AbsolutePath.make("/project") })],
385-
[SkillGuidance.node, skillGuidance],
386-
[ReferenceGuidance.node, referenceGuidance],
387+
[SkillInstructions.node, skillInstructions],
388+
[ReferenceInstructions.node, referenceInstructions],
387389
[PermissionV2.node, permission],
388390
[Config.node, config],
389-
[McpGuidance.node, mcpGuidance],
391+
[McpInstructions.node, mcpInstructions],
390392
[ToolOutputStore.node, ToolOutputStore.nodeWithoutConfig],
391393
[PluginSupervisor.node, pluginSupervisor],
392394
])
@@ -424,8 +426,8 @@ const it = testEffect(
424426
InstructionBuiltIns.node,
425427
InstructionDiscovery.node,
426428
InstructionEntry.node,
427-
SkillGuidance.node,
428-
ReferenceGuidance.node,
429+
SkillInstructions.node,
430+
ReferenceInstructions.node,
429431
Config.node,
430432
Snapshot.node,
431433
SessionRunnerLLM.node,
@@ -440,8 +442,8 @@ const it = testEffect(
440442
[InstructionBuiltIns.node, systemContext],
441443
[InstructionDiscovery.node, instructionContext],
442444
[Location.node, Location.boundNode({ directory: AbsolutePath.make("/project") })],
443-
[SkillGuidance.node, skillGuidance],
444-
[ReferenceGuidance.node, referenceGuidance],
445+
[SkillInstructions.node, skillInstructions],
446+
[ReferenceInstructions.node, referenceInstructions],
445447
[Snapshot.node, Snapshot.noopLayer],
446448
[SessionExecution.node, execution],
447449
[Config.node, config],
@@ -1424,7 +1426,7 @@ describe("SessionRunnerLLM", () => {
14241426
}),
14251427
)
14261428

1427-
it.effect("updates selected-agent skill guidance after an agent switch", () =>
1429+
it.effect("updates selected-agent skill instructions after an agent switch", () =>
14281430
Effect.gen(function* () {
14291431
const session = yield* setup
14301432
const events = yield* EventV2.Service

0 commit comments

Comments
 (0)