MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / startAutoUpdate

Function startAutoUpdate

lib/update.ts:19–40  ·  view source on GitHub ↗
(ctx: PluginInput, enabled: boolean)

Source from the content-addressed store, hash-verified

17const PACKAGE_NAME = "@tarquinen/opencode-dcp"
18
19export function startAutoUpdate(ctx: PluginInput, enabled: boolean): void {
20 if (!enabled) return
21
22 const controller = new AbortController()
23 const timeout = setTimeout(() => controller.abort(), 10_000)
24 void checkAutoUpdate(controller.signal)
25 .then((result) => {
26 if (!result.updated) return
27 setTimeout(() => {
28 ctx.client.tui.showToast({
29 body: {
30 title: "DCP update ready",
31 message: `Updated ${result.name} from ${result.current} to ${result.latest}. Restart OpenCode to finish.`,
32 variant: "info",
33 duration: 7000,
34 },
35 })
36 }, 5000)
37 })
38 .catch(() => {})
39 .finally(() => clearTimeout(timeout))
40}
41
42export async function checkAutoUpdate(signal: AbortSignal): Promise<UpdateResult> {
43 const packageDir = await findPackageDir(PACKAGE_NAME)

Callers 1

index.tsFile · 0.90

Calls 1

checkAutoUpdateFunction · 0.85

Tested by

no test coverage detected