zzh799 / dsh-opencode-usage

목록에 있음

업스트림 저장소에 설명이 없습니다.

main기타 소스 보기

설치

npm run watch # hot-swap rebuilds into a running `dsh web` host

이 명령은 GitHub 저장소 주소에서 생성됩니다. 실행 전에 업스트림 README와 소스를 검토하고 재현성이 필요하면 release 또는 commit을 고정하세요.

README

유지 관리자가 작성한 문서 스냅샷입니다.

GitHub에서 보기 ↗
커밋 3550507동기화 2026. 8. 18.

최근 디렉터리 동기화에서 이 README 스냅샷을 새로 고치지 못했습니다.

dsh-opencode-usage

A dsh web GUI plugin that shows your OpenCode Zen balance and Go usage windows right in the composer tool row: a concentric-ring button (rolling 5h / weekly / monthly) that opens a usage panel.

  • Host half (src/index.tslib/index.js): resolves config from env vars and $DSH_HOME/ocgo-usage.json, fetches the opencode.ai SSR pages, and serves same-origin JSON endpoints with caching + failure cooldown.
  • Browser half (src/client.tsxlib/client.js): renders the concentric-ring composer button and usage panel, and the config editor (cookie values are only ever shown masked — the full cookie never leaves the host).

button panel

Features

  • Rolling 5-hour / weekly / monthly usage rings on a single composer button
  • Usage panel with window details and a manual refresh
  • Built-in config editor in the panel (masked cookie tails only)
  • Smart cookie normalization: paste the raw auth token, a full header, or anything in between
  • Server-side cache (default 5 min) + 60 s failure cooldown so the poller never spams opencode.ai
  • Optional peak-clock display (showPeakClock)

Install

# From a local checkout (or a tarball), add into the dsh web profile:
dsh plugin --profile web add /path/to/dsh-opencode-usage

cordis.patch.yml inserts the plugin as opencode-usage; it requires the webServer service.

Configuration

Priority: env vars > config file ($DSH_HOME/ocgo-usage.json) > defaults.

Env varConfig file keyDefaultDescription
OPENCODE_GO_COOKIEcookieOpenCode Go session cookie (auto-normalized)
OPENCODE_GO_WORKSPACE_IDworkspaceIDOpenCode workspace id
OPENCODE_GO_BASE_URLbaseUrlhttps://opencode.aiProvider base URL
OPENCODE_GO_CACHE_TTLcacheTTL300Cache TTL in seconds, clamped to [60, 3600]
OPENCODE_GO_TIMEOUT_MStimeoutMs15000Fetch timeout in ms
showPeakClockfalseShow the peak-clock readout

The cookie is never logged. You can also edit cookie / workspaceID / showPeakClock from the panel's config editor; a successful write invalidates the cache so the next poll uses the fresh values immediately.

Config file is written with chmod 600.

API

The browser half talks to the host over plain same-origin JSON:

MethodPathDescription
GET/api/opencode-usageCached usage view
GET/api/opencode-usage/refreshForce a fresh provider query
GET/api/opencode-usage/configMasked config view
POST/api/opencode-usage/configWrite cookie / workspace / showPeakClock

Development

npm install      # dev deps (esbuild) — prepack build runs automatically
npm run build    # emit lib/client.js + lib/index.js
npm run watch    # hot-swap rebuilds into a running `dsh web` host

The build mirrors the dsh plugin loader contract: the browser bundle rides in the closure-factory module format with react/platform modules externalized, and CSS is inlined idempotently (data-plugin-css).

License

MIT

저장소 정보

언어
TypeScript
라이선스
MIT
마지막 업데이트
2026. 8. 18. 오전 12:31

신중하게 설치하기

소스 코드, 권한, 수명 주기 스크립트, 의존성 및 네트워크 접근을 검토하고 신뢰하지 않는 플러그인은 격리 환경에서 테스트하세요.