{"id":50556102,"url":"https://github.com/jianghe12/opskit-core","last_synced_at":"2026-06-26T05:00:25.983Z","repository":{"id":362277528,"uuid":"1257935138","full_name":"JiangHe12/opskit-core","owner":"JiangHe12","description":"Shared governance engine for the opskit family of CLIs for AI agents — R0–R3 risk tiers, change-ticket \u0026 allow-flag authorization, RBAC, tamper-evident audit, credstore \u0026 redaction. Go library.","archived":false,"fork":false,"pushed_at":"2026-06-25T08:44:48.000Z","size":111,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-25T10:08:01.574Z","etag":null,"topics":["ai","audit","cli","credentials","go","golang","governance","library","rbac","security"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/JiangHe12/opskit-core","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JiangHe12.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audit/audit.go","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-03T06:10:31.000Z","updated_at":"2026-06-25T08:44:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/JiangHe12/opskit-core","commit_stats":null,"previous_names":["jianghe12/opskit-core"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/JiangHe12/opskit-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiangHe12%2Fopskit-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiangHe12%2Fopskit-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiangHe12%2Fopskit-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiangHe12%2Fopskit-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JiangHe12","download_url":"https://codeload.github.com/JiangHe12/opskit-core/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiangHe12%2Fopskit-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34803678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","audit","cli","credentials","go","golang","governance","library","rbac","security"],"created_at":"2026-06-04T07:03:08.013Z","updated_at":"2026-06-26T05:00:25.820Z","avatar_url":"https://github.com/JiangHe12.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# opskit-core\n\n**The governance engine behind the `opskit` family of CLIs for humans _and_ AI agents.**\n\nOne shared Go library so every governed operations CLI — databases, remote servers, config centers, message brokers — speaks the **same** safety model: risk tiers, change tickets, allow-flags, RBAC, and a tamper-evident audit trail. Write the dangerous parts once, correctly; never copy-paste them again.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/JiangHe12/opskit-core.svg)](https://pkg.go.dev/github.com/JiangHe12/opskit-core)\n[![CI](https://github.com/JiangHe12/opskit-core/actions/workflows/ci.yml/badge.svg)](https://github.com/JiangHe12/opskit-core/actions/workflows/ci.yml)\n[![release](https://img.shields.io/github/v/tag/JiangHe12/opskit-core.svg?label=release\u0026sort=semver)](https://github.com/JiangHe12/opskit-core/releases)\n[![Go](https://img.shields.io/badge/go-1.25%2B-00ADD8.svg)](go.mod)\n[![license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n\n[English](README.md) · [简体中文](README_zh.md)\n\n\u003c/div\u003e\n\n---\n\n## 🧭 What is this? (read me first)\n\nBuilding a CLI that lets humans **— or AI agents —** operate production systems is mostly about the *guardrails*, not the operations. Who's allowed to do this? Is it reversible? Does it need a human's explicit sign-off? Was it recorded? Get that wrong once and you've handed an agent a loaded gun.\n\n`opskit-core` is the **engine that gets those guardrails right, once.** Every CLI in the family plugs into it instead of re-implementing risk classification, authorization, credential storage, redaction, and audit:\n\n- 🔐 **One risk model (R0–R3)** — reads are free, ordinary writes need confirmation, sensitive writes need a change ticket, destructive ones need an explicit per-operation allow-flag. Protected contexts raise every tier.\n- 🎫 **Human-only authorization walls** — `--ticket` and `--allow-*` are inputs an autonomous agent *cannot* fabricate, forcing a single, traceable, intentional human approval for anything dangerous.\n- 📜 **Append-only, tamper-evident audit** — every action is a hash-chained JSONL record; `Verify` detects any gap or edit. Bodies and secrets never land in the log.\n- 🔑 **Pluggable credential storage** — plaintext is never required; secrets resolve through keychain, encrypted-file, or vault backends.\n- 🧩 **Domain-agnostic by design** — each CLI injects its own command vocabulary, audit record shape, prompts, and error text through `Configure(...)`; the engine never hard-codes a domain.\n\nIt's the foundation under [`dbgov-cli`](https://github.com/JiangHe12/dbgov-cli) (databases), [`srvgov-cli`](https://github.com/JiangHe12/srvgov-cli) (remote servers), [`cfgov-cli`](https://github.com/JiangHe12/cfgov-cli) (config centers), and [`mqgov-cli`](https://github.com/JiangHe12/mqgov-cli) (message brokers).\n\n---\n\n## ✨ What's in the box\n\n| | |\n|---|---|\n| 🔐 **`safety`** | The risk model: `R0`–`R3`, `Authorize`, `EffectiveRisk` (protected contexts raise a tier), allow-flags (every required flag must be granted), opt-in RBAC, ticket validation, backup policy. |\n| 📜 **`audit`** | Append-only JSONL audit engine: `AppendRecord` (works with each CLI's own event type), `Query`/`QueryRaw`, `Verify`, size-based rotation, optional age encryption. |\n| 🔑 **`credstore`** | Pluggable credential backends — `plain-yaml`, `encrypted-file`, OS `keychain`, and `vault` — plus credential-reference encoding. |\n| 🗂️ **`ctx`** | Context configuration store: per-context settings, per-operator roles, and literal or credstore-referenced secret resolution. |\n| 🖨️ **`printer`** | `table` / `json` / `plain` output behind a configurable, versioned API envelope. |\n| 🧹 **`redact`** | Context-free secret redaction for both caller output and audit records. |\n| 📈 **`telemetry`** | OpenTelemetry tracing and metrics with per-CLI service / attribute / metric prefixes. |\n| ⚠️ **`apperrors`** | Typed error codes and the shared process exit-code contract. |\n| 🔒 **`lockfile`** | Advisory lock file that serializes mutating operations. |\n| 📌 **`trust`** | Transport-neutral trust-on-first-use (TOFU) pin store: pin SSH host keys or TLS certificate SPKI on first use, hard-fail on any later change. |\n\n---\n\n## 📦 Install\n\n```sh\ngo get github.com/JiangHe12/opskit-core\n```\n\nRequires **Go 1.25+**. The library follows Go semantic import versioning — the `v1` module path is stable and carries no version suffix, so patch and minor releases never break your build.\n\n---\n\n## 🚀 Quick start\n\nConfigure the shared packages once at startup with your CLI's identity, then use them with your own domain types.\n\n```go\nimport (\n\t\"github.com/JiangHe12/opskit-core/audit\"\n\t\"github.com/JiangHe12/opskit-core/credstore\"\n\t\"github.com/JiangHe12/opskit-core/safety\"\n)\n\n// 1. Wire the engine to your CLI's identity (once, at startup)\nsafety.Configure(safety.Config{ /* prompt text, operator env var, RBAC hints */ })\naudit.Configure(audit.Config{APIVersion: \"dbgov.io/audit/v1\", ConfigDirName: \".dbgov\"})\ncredstore.Configure(credstore.Options{KeychainService: \"dbgov\", EncryptedFileMagic: []byte(\"DBGOV001\")})\n\n// 2. Classify an operation, then gate it behind the right human approvals\nrisk := safety.EffectiveRisk(safety.R3, meta) // a protected context raises the tier\nif err := safety.Authorize(risk, safety.Options{\n\tYes:                flags.Yes,                              // --yes\n\tTicket:             flags.Ticket,                           // --ticket   (required at R2+)\n\tRequiredAllowFlags: []safety.AllowFlag{\"allow-drop-table\"}, // --allow-*  (required at R3)\n\tGrantedAllowFlags:  flags.Allows,\n\tOperator:           operator,\n}); err != nil {\n\treturn err // carries the shared apperrors exit-code contract\n}\n\n// 3. Record it — your own event struct, the engine's tamper-evident storage\n_ = audit.AppendRecord(auditPath, myEvent, audit.Options{})\n```\n\nYour CLI owns its vocabulary and audit fields; the engine owns risk, authorization, storage, and verification.\n\n---\n\n## 🔐 The governance model\n\nEach consumer assigns every operation one of four **risk tiers**. The higher the tier, the more explicit human sign-off `safety.Authorize` demands:\n\n| Tier | What it covers | What the caller must provide |\n|:---:|---|---|\n| **R0** | Reads \u0026 previews | Nothing — but it's still audited |\n| **R1** | Ordinary writes | `--yes` (or an interactive confirmation) |\n| **R2** | Sensitive writes / protected-context R1 | `--yes` **and** a non-empty `--ticket` |\n| **R3** | Destructive / irreversible / protected-context R2 | The above **plus** the matching `--allow-*` flag(s) |\n\nTwo properties make this safe for automation:\n\n1. **Authorization is fail-closed.** Missing confirmation, an empty/invalid ticket, or an ungranted allow-flag all reject the operation — callers classify uncertain operations at the **highest** tier, never the lowest.\n2. **🤖 `--ticket` and `--allow-*` are walls a non-human cannot fill.** They force a single, traceable, intentional human approval. An AI agent should surface *\"this needs approval X\"* to its operator and stop — it must never invent these values. Protected contexts raise every operation one tier automatically (`EffectiveRisk`).\n\n---\n\n## 🧩 The injection model\n\n`opskit-core` is the engine; it never hard-codes a domain. Each consumer configures the shared packages once and then uses them with its own types:\n\n- The CLI defines its **own audit `Event` struct** and writes it through `audit.AppendRecord` as a *foreign record* — `audit` stays the storage / query / verify engine while each tool keeps full fidelity over its own fields.\n- `safety.Configure`, `audit.Configure`, and `credstore.Configure` inject prompt text, the operator env var, RBAC hints, the audit API version and config directory, and the keychain service / encrypted-file magic — so one engine serves four different domains without forking.\n\nNew CLI? The full contract for building one that behaves like the rest of the family lives in **[ONBOARDING.md](ONBOARDING.md)**.\n\n---\n\n## 🏗️ Build \u0026 contribute\n\n```sh\ngit clone https://github.com/JiangHe12/opskit-core \u0026\u0026 cd opskit-core\ngo build ./...\ngo test -count=1 ./...\ngofmt -l .                 # must print nothing\ngo vet ./...\n```\n\n`opskit-core` ships as a Go module only — releases are git tags (no npm, no binaries). The public contract was frozen at `v1.0.0`; everything since is backward-compatible. See [CHANGELOG.md](CHANGELOG.md) for the per-release history.\n\n---\n\n## 📄 License\n\n[MIT](LICENSE) © 2026 JiangHe12\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjianghe12%2Fopskit-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjianghe12%2Fopskit-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjianghe12%2Fopskit-core/lists"}