Skip to content

Commit 9261501

Browse files
authored
Merge pull request KafClaw#27 from scalytics/sills
Add Skill management, hardening, security, keystore
2 parents 112d7e4 + 0550dcd commit 9261501

74 files changed

Lines changed: 9697 additions & 36 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ jobs:
7676
- name: Run tests
7777
run: go test ./...
7878

79+
- name: Security check gate
80+
run: go run ./cmd/kafclaw security check
81+
7982
- name: Run race detector
8083
run: go test -race ./...
8184

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ jobs:
136136
go-version: "1.24.13"
137137
cache-dependency-path: go.sum
138138

139+
- name: Validate bundled skills artifacts
140+
shell: bash
141+
run: bash scripts/check_bundled_skills.sh
142+
139143
- name: Build hardened binary
140144
shell: bash
141145
env:
@@ -174,9 +178,11 @@ jobs:
174178
set -euo pipefail
175179
BIN_NAME="kafclaw-${{ matrix.artifact_suffix }}${{ matrix.ext }}"
176180
BUNDLE_DIR="dist/kafclaw-${{ matrix.artifact_suffix }}-bundle"
177-
mkdir -p "$BUNDLE_DIR/bin" "$BUNDLE_DIR/systemd" "$BUNDLE_DIR/env"
181+
mkdir -p "$BUNDLE_DIR/bin" "$BUNDLE_DIR/systemd" "$BUNDLE_DIR/env" "$BUNDLE_DIR/skills" "$BUNDLE_DIR/docs/skills"
178182
179183
cp "dist/${BIN_NAME}" "$BUNDLE_DIR/bin/kafclaw"
184+
cp -R skills/. "$BUNDLE_DIR/skills/"
185+
cp -R docs/skills/. "$BUNDLE_DIR/docs/skills/"
180186
181187
cat > "$BUNDLE_DIR/systemd/kafclaw.service" <<'UNIT'
182188
[Unit]
@@ -227,6 +233,10 @@ jobs:
227233
228234
tar -C dist -czf "dist/kafclaw-${{ matrix.artifact_suffix }}-bundle.tar.gz" "kafclaw-${{ matrix.artifact_suffix }}-bundle"
229235
236+
if [[ "${{ matrix.goarch }}" == "amd64" ]]; then
237+
tar -czf "dist/kafclaw-skills-bundle.tar.gz" skills docs/skills
238+
fi
239+
230240
- name: Upload artifact
231241
uses: actions/upload-artifact@v4
232242
with:

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NPM_MIN_VERSION := 11
1010
HOST_GOMODCACHE := $(shell go env GOMODCACHE)
1111
HOST_GOCACHE := $(shell go env GOCACHE)
1212

13-
.PHONY: help check bootstrap build run rerun test vet race commit-check test-smoke test-critical test-fuzz code-ql test-classification test-subagents-e2e install \
13+
.PHONY: help check bootstrap build run rerun test vet race fmt-check commit-check test-smoke test-critical test-fuzz code-ql test-classification test-subagents-e2e check-bundled-skills install \
1414
release release-major release-minor release-patch dist-go \
1515
docker-build docker-up docker-down docker-logs \
1616
run-standalone run-full run-headless \
@@ -108,9 +108,20 @@ vet: ## Run go vet across all packages
108108
race: ## Run race-enabled tests across all packages
109109
go test -race ./...
110110

111+
fmt-check: ## Verify Go files are gofmt-formatted
112+
@unformatted="$$(gofmt -l .)"; \
113+
if [ -n "$$unformatted" ]; then \
114+
echo "The following files are not gofmt-formatted:"; \
115+
echo "$$unformatted"; \
116+
exit 1; \
117+
fi
118+
111119
test-smoke: ## Run fast critical-path smoke tests (bug-finding first)
112120
bash scripts/test_smoke.sh
113121

122+
check-bundled-skills: ## Validate that bundled skills/docs artifacts exist
123+
bash scripts/check_bundled_skills.sh
124+
114125
test-critical: ## Enforce 100% coverage on critical logic
115126
bash scripts/check_critical_coverage.sh
116127

@@ -120,7 +131,7 @@ test-fuzz: ## Run fuzz tests for critical guard logic
120131
code-ql: ## Run local CodeQL (Go + JS/TS + Actions) and emit SARIF under .tmp/codeql/
121132
bash scripts/codeql_local.sh
122133

123-
commit-check: check vet race test-fuzz code-ql ## Run pre-commit quality gates (vet, race, fuzz, CodeQL)
134+
commit-check: check fmt-check vet race test-fuzz code-ql ## Run pre-commit quality gates (fmt, vet, race, fuzz, CodeQL)
124135
@echo "commit-check completed."
125136

126137
test-classification: ## Run internal/external message classification E2E test (verbose)

docs/architecture-security/security-for-ops.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ Test restore regularly on a clean host.
9494
./kafclaw status
9595
./kafclaw doctor
9696
./kafclaw doctor --fix
97+
./kafclaw security check
98+
./kafclaw security audit --deep
99+
./kafclaw security fix --yes
97100
```
98101

99102
Use these as part of daily operations and after any security-relevant change.
103+
104+
## 9. Skills and OAuth Security Notes
105+
106+
- Prefer `skills.scope=selected` for least-privilege skill exposure.
107+
- Use `skills.runtimeIsolation=auto` (or `strict` when container runtime is guaranteed).
108+
- When using `strict`, `kafclaw security check` validates that `docker`/`podman` is actually usable by the current operator user.
109+
- OAuth skill tokens are encrypted at rest with local tomb-key management by default (`~/.config/kafclaw/tomb.rr`), with optional keyring/file backends.
110+
- `doctor --fix` moves sensitive env keys into tomb-managed encrypted storage and scrubs them from `~/.config/kafclaw/env`.
111+
- Security events and install decisions are chained into immutable-style audit logs under `~/.kafclaw/skills/audit/`.
112+
- For deployment-specific skill operations and remediations, refer to:
113+
- [Skills](../skills/index.md)
114+
- [KafClaw Management Guide](../operations-admin/manage-kafclaw.md)

docs/operations-admin/manage-kafclaw.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ Operator-focused guide for managing KafClaw from CLI and runtime endpoints.
1414
| `kafclaw onboard` | Initialize config and scaffold workspace identity files |
1515
| `kafclaw gateway` | Run full gateway (API, dashboard, channels, memory, group/orchestrator when enabled) |
1616
| `kafclaw status` | Quick operational status: config, providers, channels, pairing, policy diagnostics |
17-
| `kafclaw doctor` | Run setup and config diagnostics |
17+
| `kafclaw doctor` | Run setup/config diagnostics including skills readiness checks |
18+
| `kafclaw security` | Unified security checks/audit/fix (`check`, `audit --deep`, `fix --yes`) |
1819
| `kafclaw config` | Low-level dotted-path config read/write/unset |
19-
| `kafclaw configure` | Guided updates for selected settings (currently subagent allowlist) |
20+
| `kafclaw configure` | Guided/non-interactive config updates (subagents + skills toggles) |
21+
| `kafclaw skills` | Skills lifecycle (`enable/disable/list/status/verify/install/update/auth/prereq`) |
2022
| `kafclaw group` | Join/leave/status/members for Kafka collaboration group |
2123
| `kafclaw kshark` | Kafka connectivity and protocol diagnostics |
2224
| `kafclaw agent -m` | Single-shot direct CLI interaction with agent loop |
@@ -54,6 +56,7 @@ Then verify:
5456
./kafclaw onboard --non-interactive --profile local --llm skip
5557
./kafclaw onboard --non-interactive --profile local-kafka --kafka-brokers localhost:9092 --group-name kafclaw --agent-id agent-local --role worker --llm skip
5658
./kafclaw onboard --non-interactive --profile remote --llm openai-compatible --llm-api-base http://localhost:11434/v1 --llm-model llama3.1:8b
59+
./kafclaw onboard --non-interactive --accept-risk --skip-skills=false --install-clawhub --skills-node-major 20
5760
```
5861

5962
Mode effects applied by onboarding:
@@ -98,6 +101,8 @@ Highlights include:
98101
```
99102

100103
`doctor` returns non-zero when failing checks exist.
104+
When skills are enabled, doctor also checks `node`, `clawhub` (if external installs are enabled), runtime dir permissions, and channel-onboarding readiness.
105+
Use `kafclaw security` for consolidated security posture and deep skill audits.
101106

102107
## 5. Config Management
103108

@@ -115,8 +120,18 @@ Highlights include:
115120
./kafclaw configure
116121
./kafclaw configure --subagents-allow-agents agent-main,agent-research --non-interactive
117122
./kafclaw configure --clear-subagents-allow-agents --non-interactive
123+
./kafclaw configure --non-interactive --skills-enabled-set --skills-enabled=true --skills-node-manager npm
124+
./kafclaw configure --non-interactive --skills-scope selected
125+
./kafclaw configure --non-interactive --enable-skill github --disable-skill weather
118126
```
119127

128+
Skills policy defaults:
129+
130+
- `skills.scope=selected` (least-privilege, recommended)
131+
- `skills.runtimeIsolation=auto` (use strict if container runtime is mandatory in your environment)
132+
133+
See [Skills](../skills/index.md) for full skill policy details.
134+
120135
### LLM provider and token management
121136

122137
Interactive (recommended):
@@ -272,6 +287,30 @@ Core runtime files:
272287
This section applies to **direct HTTP clients** that call KafClaw API endpoints.
273288
For Slack/Teams/WhatsApp users, authentication is handled by provider bridge + pairing/allowlist controls, not by manually passing the gateway bearer token.
274289

290+
## 12. Security Command Runbook
291+
292+
```bash
293+
./kafclaw security check
294+
./kafclaw security audit --deep
295+
./kafclaw security fix --yes
296+
```
297+
298+
Recommended usage:
299+
300+
- `security check`: quick operational gate in CI/day-2 operations.
301+
- `security audit --deep`: include installed skill re-verification.
302+
- `security fix --yes`: apply safe remediations; re-run check after changes.
303+
- `doctor --fix`: merges env files, syncs sensitive env keys into tomb-managed encrypted storage, then scrubs those sensitive keys from `~/.config/kafclaw/env`.
304+
305+
For security posture details, see [Security for Operators](../architecture-security/security-for-ops.md).
306+
For skills policy, OAuth keying, and source pinning syntax, see [Skills](../skills/index.md).
307+
308+
Recommended CI gate:
309+
310+
```bash
311+
go run ./cmd/kafclaw security check
312+
```
313+
275314
When `KAFCLAW_GATEWAY_AUTH_TOKEN` (or `gateway.authToken`) is set, direct clients do not auto-receive tokens.
276315
Operators must distribute tokens out-of-band (secure chat, secret manager, deployment env injection, etc.).
277316

docs/skills/channel-onboarding.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: channel-onboarding
3+
parent: Skills
4+
nav_order: 1
5+
---
6+
7+
# channel-onboarding
8+
9+
Guides setup and verification for Slack, Teams, and WhatsApp channel integrations.
10+
11+
## Default State
12+
13+
- Bundled with KafClaw
14+
- Enabled by default
15+
16+
## What It Does
17+
18+
- Validates channel prerequisites and required config fields.
19+
- Guides first-time onboarding for Slack, Teams, and WhatsApp.
20+
- Produces concrete remediation steps when checks fail.
21+
22+
## Install / Enable
23+
24+
Already bundled and enabled by default. To ensure the skills system is active:
25+
26+
```bash
27+
kafclaw skills enable
28+
```
29+
30+
## Usage
31+
32+
- Run onboarding:
33+
34+
```bash
35+
kafclaw onboard
36+
```
37+
38+
- Run diagnostics:
39+
40+
```bash
41+
kafclaw doctor
42+
```
43+
44+
## Troubleshooting
45+
46+
- If channels do not respond, check channel `enabled` flags and required tokens in config.
47+
- If onboarding is skipped, rerun with `kafclaw onboard --skip-skills=false`.
48+
- If diagnostics report missing prerequisites, follow the command hints from `doctor`.

docs/skills/gh-issues.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: gh-issues
3+
parent: Skills
4+
nav_order: 5
5+
---
6+
7+
# gh-issues
8+
9+
Run issue-driven engineering loops with controlled PR lifecycle.
10+
11+
## Default State
12+
13+
- Bundled with KafClaw
14+
- Disabled by default
15+
16+
## What It Does
17+
18+
- Selects and executes issue work by priority/label.
19+
- Drives implementation, PR updates, and review follow-up.
20+
- Keeps explicit approval gates for merge and high-risk operations.
21+
22+
## Install / Enable
23+
24+
No external install needed (bundled skill). Enable it:
25+
26+
```bash
27+
kafclaw skills enable-skill gh-issues
28+
```
29+
30+
## Usage
31+
32+
- Use when running backlog-driven work and shipping issues end-to-end.
33+
- Works best with `github` skill enabled for full repository operations.
34+
35+
## Troubleshooting
36+
37+
- If issue selection is noisy, tighten labels/milestones before execution.
38+
- If PR actions fail, verify GitHub auth and repository permissions.
39+
- If merge actions are blocked, confirm approval workflow requirements.

docs/skills/github.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: github
3+
parent: Skills
4+
nav_order: 4
5+
---
6+
7+
# github
8+
9+
Operate GitHub issues, pull requests, and checks safely.
10+
11+
## Default State
12+
13+
- Bundled with KafClaw
14+
- Disabled by default
15+
16+
## What It Does
17+
18+
- Supports issue/PR/check/release workflows with controlled safety gates.
19+
- Encourages minimal, auditable changes with clear status reporting.
20+
- Applies approval expectations before merge/release/destructive actions.
21+
22+
## Install / Enable
23+
24+
No external install needed (bundled skill). Enable it:
25+
26+
```bash
27+
kafclaw skills enable-skill github
28+
```
29+
30+
## Usage
31+
32+
- Use for repo triage, PR follow-up, and CI signal interpretation.
33+
- Pair with `gh-issues` for issue-driven execution loops.
34+
35+
## Troubleshooting
36+
37+
- If GitHub actions fail, verify `gh auth status`.
38+
- If operations are blocked, check your policy/approval settings.
39+
- If API calls are rate-limited, retry with reduced query scope.

docs/skills/google-cli.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: google-cli
3+
parent: Skills
4+
nav_order: 7
5+
---
6+
7+
# google-cli
8+
9+
Install and validate the Google Cloud CLI (`gcloud`) for cloud/operator workflows.
10+
11+
## Default State
12+
13+
- Bundled with KafClaw
14+
- Disabled by default
15+
16+
## Check
17+
18+
```bash
19+
kafclaw skills prereq check google-cli
20+
```
21+
22+
## Install Plan
23+
24+
```bash
25+
kafclaw skills prereq install google-cli --dry-run
26+
```
27+
28+
## Install
29+
30+
```bash
31+
kafclaw skills prereq install google-cli --yes
32+
```
33+
34+
The installer uses Go-native OS routines (APT on Linux, Homebrew on macOS).
35+
36+
## Enable Skill
37+
38+
```bash
39+
kafclaw skills enable-skill google-cli
40+
```
41+
42+
## Usage
43+
44+
- Verify auth status:
45+
46+
```bash
47+
gcloud auth list
48+
```
49+
50+
- Verify active project:
51+
52+
```bash
53+
gcloud config get-value project
54+
```
55+
56+
## Troubleshooting
57+
58+
- If install fails on Linux, run package metadata update and retry.
59+
- If `gcloud` is not found after install, ensure your shell `PATH` includes the install location.
60+
- If auth fails in headless environments, use device/browser-based auth flow from Google CLI.

0 commit comments

Comments
 (0)