GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(permission): wire permission.ask plugin hook by yohi · Pull Request #30509 · anomalyco/opencode

feat(permission): wire permission.ask plugin hook #30509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yohi wants to merge 10 commits into anomalyco:dev from yohi:feat/permission-ask-hook
+131 −2
Closed

feat(permission): wire permission.ask plugin hook #30509

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit Hold shift + click to select a range
a60ce94
feat(permission): wire permission.ask plugin hook
yohi Jun 3, 2026
d7203b8
fix: address review comments for feat/permission-ask-hook
yohi Jun 3, 2026
3b35211
fix(permission): prevent plugin mutation of permission request data b…
yohi Jun 3, 2026
934f17d
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 3, 2026
ce447d3
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 3, 2026
9808d8c
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 8, 2026
f1cfe37
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 9, 2026
fb76051
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 10, 2026
bd5d4b4
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 10, 2026
80b8f62
Merge branch 'dev' into feat/permission-ask-hook
yohi Jun 16, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Next Next commit
feat(permission): wire permission.ask plugin hook
Closes #7006
Closes #22311
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@yohi
yohi committed Jun 3, 2026
commit a60ce94e496cb88a61959ad09898dee7a05e79f2

There are no files selected for viewing

19 changes: 18 additions & 1 deletion 19 packages/opencode/src/permission/index.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import os from "os"
import { PermissionV1 } from "@opencode-ai/core/v1/permission"
import { EventV2Bridge } from "@/event-v2-bridge"
import { EventV2 } from "@opencode-ai/core/event"
import { Plugin } from "@/plugin"

const log = Log.create({ service: "permission" })

Expand Down Expand Up @@ -56,6 +57,7 @@ export const layer = Layer.effect(
Service,
Effect.gen(function* () {
const events = yield* EventV2Bridge.Service
const plugin = yield* Plugin.Service
const state = yield* InstanceState.make<State>(
Effect.fn("Permission.state")(function* (ctx) {
void ctx
Expand Down Expand Up @@ -108,6 +110,18 @@ export const layer = Layer.effect(
}
log.info("asking", { id, permission: info.permission, patterns: info.patterns })

const output: { status: "ask" | "allow" | "deny" } = { status: "ask" }
yield* plugin.trigger("permission.ask", info, output)

if (output.status === "allow") {
return
}
if (output.status === "deny") {
return yield* new PermissionV1.DeniedError({
ruleset: [],
})
}

const deferred = yield* Deferred.make<void, PermissionV1.RejectedError | PermissionV1.CorrectedError>()
pending.set(id, { info, deferred })
yield* events.publish(Event.Asked, info)
Expand Down Expand Up @@ -225,6 +239,9 @@ export function disabled(tools: string[], ruleset: PermissionV1.Ruleset): Set<st
)
}

export const defaultLayer = layer.pipe(Layer.provide(EventV2Bridge.defaultLayer))
export const defaultLayer = layer.pipe(
Layer.provide(EventV2Bridge.defaultLayer),
Layer.provide(Plugin.defaultLayer)
)

export * as Permission from "."
16 changes: 15 additions & 1 deletion 16 packages/opencode/test/permission/next.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ import { InstanceStore } from "../../src/project/instance-store"
import { TestInstance, tmpdirScoped } from "../fixture/fixture"
import { testEffect } from "../lib/effect"
import { MessageID, SessionID } from "../../src/session/schema"
import { Plugin } from "../../src/plugin"

const mockPluginLayer = Layer.succeed(
Plugin.Service,
Plugin.Service.of({
trigger: Effect.fn("Plugin.trigger")(function* (name, input, output) {
return output as any
}),
list: Effect.fn("Plugin.list")(function* () {
return []
}),
init: Effect.fn("Plugin.init")(function* () {}),
}),
)

const events = EventV2Bridge.defaultLayer
const noopBootstrap = Layer.succeed(InstanceBootstrap.Service, InstanceBootstrap.Service.of({ run: Effect.void }))
const env = Layer.mergeAll(
Permission.layer.pipe(Layer.provide(Database.defaultLayer), Layer.provide(events)),
Permission.layer.pipe(Layer.provide(Database.defaultLayer), Layer.provide(events), Layer.provide(mockPluginLayer)),
events,
CrossSpawnSpawner.defaultLayer,
InstanceStore.defaultLayer.pipe(Layer.provide(noopBootstrap)),
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.