Elinpf/dsh-ops-plugins--packages-ops-tool-kubectl ↗★ 1
@elinpf/dsh-ops-tool-kubectl
kubectl tool consumer of the ops-access seam — resolves k8s profiles into kubeconfig paths and runs kubectl via ctx.shell; list_access surfaces registered profiles without secret fields. 适合需要让 AI 代理安全执行 K8s 运维命令并自动注入凭据的场景。
インストール
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Elinpf/dsh-ops-plugins#64b1d76649bf24155173c74254d0fb61d12815d5&path:packages/ops-tool-kubectlドキュメント
README 全文を読む ↗@elinpf/dsh-ops-tool-kubectl
kubectl tool consumer of the ops-access capability seam — resolves k8s profiles into kubeconfig paths and runs kubectl via ctx.shell, plus a list_access tool that surfaces registered profiles without any secret fields.
What it does
Registers two model-facing tools:
kubectl— resolves a namedk8saccess profile per call and runs the given subcommand through the local shell with the profile's--kubeconfigpath injected. The executed command carries the real path; the model-visible result shows a `` credential reference, so secrets never reach the log or the model.list_access— groupsctx.opsAccess.listAll()by kind and shows envelope fields only (name, displayName, description, environment) plus per-tier readiness (ro/rw) and capability-probe annotations. Profilefields(paths, connection params) never cross into tool output.help: truereturns the registry management doc instead.
Design notes
- Thin consumer, shared machinery. This package supplies only four identity pieces — tool name, resolved kind (
k8s), profile-arg name (cluster), andbuildCommand. The standard result shape ({ exitCode, stdout, stderr, command, error? }), output schema, render, and the resolve-per-call execute template (30 s default timeout, signal deaths normalized to exitCode -1) all live in@elinpf/dsh-ops-shell-tool, so kubectl/ceph/ssh tools behave identically. - Resolve per call, never cached. The ops-access seam is reached through
ctx.get('opsAccess')insideexecute— no static inject, no caching — so registry edits take effect without restart and the loader never deadlocks on a sibling service. - No session state. The tool appends no session events and owns no projection; every call is independent. The
./invariantsubpath ships a "no runtime invariant" companion that only reserves package ownership on the invariants service. - One call = one kubectl subcommand. Shell composition (
;,&&,||, backticks,$(), newlines) is rejected with a teaching error before execution — everything after such an operator would run as a NEW local command without the kubectl prefix and credentials (a real session hitget: command not found8+ times this way, 2026-09-10). A single|pipe stays allowed (filters the output locally). Slow clusters can raise the per-call ceiling withtimeoutSec(1–600 s).
Config
- id: tool-ops-kubectl
name: '@elinpf/dsh-ops-tool-kubectl'
config:
timeoutMs: 30000 # per-call shell timeout for kubectl runs (ms); raise for slow clusters
Subpath exports
@elinpf/dsh-ops-tool-kubectl/types— pure types (ListedProfile,ListAccessResult); zero runtime code.@elinpf/dsh-ops-tool-kubectl/invariant— the invariant companion plugin.
Testing
npm run build # tsc → lib/
npx vitest run # unit tests drive the real plugin through a mock context:
# kubectl happy path + failure fallbacks, render purity,
# list_access grouping with the no-fields guarantee,
# export shape, and HMR unload (disposers empty the registry)