Skip to content

Commit 84be322

Browse files
committed
fix: plugin spinner TTY check and skill file resolution
- Add isTTY check to plugin install spinner to avoid garbage output in non-interactive environments (fixes anomalyco#27908) - Resolve @file references in skill commands relative to skill directory instead of worktree (fixes anomalyco#24831)
1 parent ab45f3c commit 84be322

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎packages/opencode/src/cli/cmd/plug.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ export type PlugCtx = {
4545
}
4646

4747
const defaultPlugDeps: PlugDeps = {
48-
spinner: () => spinner(),
48+
spinner: () => {
49+
if (!process.stdout.isTTY) {
50+
return {
51+
start: (msg: string) => log.info(`${msg}...`),
52+
stop: (msg: string) => log.info(msg),
53+
}
54+
}
55+
return spinner()
56+
},
4957
log: {
5058
error: (msg) => log.error(msg),
5159
info: (msg) => log.info(msg),

‎packages/opencode/src/command/index.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
2+
import path from "path"
23
import { InstanceState } from "@/effect/instance-state"
34
import { EffectBridge } from "@/effect/bridge"
45
import type { InstanceContext } from "@/project/instance-context"
@@ -39,7 +40,10 @@ export const Info = Schema.Struct({
3940
hints: Schema.Array(Schema.String),
4041
}).annotate({ identifier: "Command" })
4142

42-
export type Info = Omit<Schema.Schema.Type<typeof Info>, "template"> & { template: Promise<string> | string }
43+
export type Info = Omit<Schema.Schema.Type<typeof Info>, "template"> & {
44+
template: Promise<string> | string
45+
baseDir?: string
46+
}
4347

4448
export function hints(template: string) {
4549
const result: string[] = []
@@ -149,6 +153,7 @@ export const layer = Layer.effect(
149153
return item.content
150154
},
151155
hints: [],
156+
baseDir: path.dirname(item.location),
152157
}
153158
}
154159

‎packages/opencode/src/session/prompt.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export const layer = Layer.effect(
138138
yield* state.cancel(sessionID)
139139
})
140140

141-
const resolvePromptParts = Effect.fn("SessionPrompt.resolvePromptParts")(function* (template: string) {
141+
const resolvePromptParts = Effect.fn("SessionPrompt.resolvePromptParts")(function* (template: string, baseDir?: string) {
142142
const ctx = yield* InstanceState.context
143143
const parts: Types.DeepMutable<PromptInput["parts"]> = [{ type: "text", text: template }]
144144
const files = ConfigMarkdown.files(template)
@@ -153,7 +153,11 @@ export const layer = Layer.effect(
153153

154154
const filepath = name.startsWith("~/")
155155
? path.join(os.homedir(), name.slice(2))
156-
: path.resolve(ctx.worktree, name)
156+
: path.isAbsolute(name)
157+
? name
158+
: baseDir
159+
? path.resolve(baseDir, name)
160+
: path.resolve(ctx.worktree, name)
157161

158162
const info = yield* fsys.stat(filepath).pipe(Effect.option)
159163
if (Option.isNone(info)) {
@@ -1490,7 +1494,7 @@ export const layer = Layer.effect(
14901494
throw error
14911495
}
14921496

1493-
const templateParts = yield* resolvePromptParts(template)
1497+
const templateParts = yield* resolvePromptParts(template, cmd.baseDir)
14941498
const inputFiles = new Set(
14951499
input.parts?.filter((part) => new URL(part.url).protocol === "file:").map((part) => fileURLToPath(part.url)),
14961500
)

0 commit comments

Comments
 (0)