diff --git a/v3/@claude-flow/cli/README.md b/v3/@claude-flow/cli/README.md index d4136492ec..c207cd7ff4 100644 --- a/v3/@claude-flow/cli/README.md +++ b/v3/@claude-flow/cli/README.md @@ -500,12 +500,9 @@ npm install -g claude-flow@alpha --omit=optional ### Basic Usage ```bash -# Initialize project (standard template) +# Initialize project npx claude-flow@alpha init -# Initialize with wizard (interactive template selection) -npx claude-flow@alpha init --wizard - # Start MCP server for Claude Code integration npx claude-flow@alpha mcp start @@ -516,41 +513,6 @@ npx claude-flow@alpha --agent coder --task "Implement user authentication" npx claude-flow@alpha --list ``` -
-CLAUDE.md Init Templates - -The `init` command generates a CLAUDE.md file that configures Claude Code behavior. Choose a template based on your use case: - -| Template | Score | Lines | Use Case | -|----------|-------|-------|----------| -| `minimal` | 93/100 (A) | ~140 | Quick start — behavioral rules, anti-drift, CLI reference | -| `standard` | 93/100 (A) | ~190 | **Recommended** — swarm orchestration, agents, memory commands | -| `full` | 91/100 (A) | ~295 | Everything — hooks, learning protocol, intelligence system | -| `security` | 93/100 (A) | ~205 | Security-focused — scanning, audit protocols, CVE checks | -| `performance` | 95/100 (A) | ~225 | Performance-focused — benchmarking, profiling, optimization | -| `solo` | 93/100 (A) | ~145 | Solo developer — no swarm overhead, simple agent usage | - -All templates are analyzer-validated with **100% enforceability** and **A-grade** governance scores. - -**Template selection:** -- Interactive: `npx claude-flow@alpha init --wizard` (prompts for template choice) -- Programmatic: Set `runtime.claudeMdTemplate` in your init options -- Default: `standard` template when components include agents/commands, `minimal` otherwise - -**Governance validation:** -```bash -# Analyze your CLAUDE.md quality and enforceability -npx claude-flow@alpha guidance analyze - -# Optimize for higher score -npx claude-flow@alpha guidance optimize --apply - -# Run A/B comparison test -npx claude-flow@alpha guidance ab-test --config-a original.md --config-b optimized.md -``` - -
- ### Upgrading ```bash @@ -1224,6 +1186,102 @@ echo "ANTHROPIC_API_KEY=sk-ant-..." >> .env --- +
+🛡️ @claude-flow/guidance — Long-horizon governance control plane for Claude Code agents + +### Overview + +`@claude-flow/guidance` turns `CLAUDE.md` into a runtime governance system with enforcement gates, cryptographic proofs, and feedback loops. Agents that normally drift after 30 minutes can now operate for days — rules are enforced mechanically at every step, not remembered by the model. + +**7-phase pipeline:** Compile → Retrieve → Enforce → Trust → Prove → Defend → Evolve + +| Capability | Description | +|-----------|-------------| +| **Compile** | Parses `CLAUDE.md` into typed policy bundles (constitution + task-scoped shards) | +| **Retrieve** | Intent-classified shard retrieval with semantic similarity and risk filters | +| **Enforce** | 4 gates the model cannot bypass (destructive ops, tool allowlist, diff size, secrets) | +| **Trust** | Per-agent trust accumulation with privilege tiers and coherence-driven throttling | +| **Prove** | HMAC-SHA256 hash-chained proof envelopes for cryptographic run auditing | +| **Defend** | Prompt injection, memory poisoning, and inter-agent collusion detection | +| **Evolve** | Optimizer loop that ranks violations, simulates rule changes, and promotes winners | + +### Install + +```bash +npm install @claude-flow/guidance@alpha +``` + +### Quick Usage + +```typescript +import { + createCompiler, + createRetriever, + createGates, + createLedger, + createProofChain, +} from '@claude-flow/guidance'; + +// Compile CLAUDE.md into a policy bundle +const compiler = createCompiler(); +const bundle = await compiler.compile(claudeMdText); + +// Retrieve task-relevant rules +const retriever = createRetriever(); +await retriever.loadBundle(bundle); +const { shards, policyText } = await retriever.retrieve({ + taskDescription: 'Fix authentication bug in login flow', +}); + +// Enforce gates on tool calls +const gates = createGates(bundle); +const result = gates.evaluate({ tool: 'bash', args: { command: 'rm -rf /' } }); +// result.blocked === true + +// Audit with proof chain +const chain = createProofChain({ signingKey: process.env.PROOF_KEY! }); +const envelope = chain.seal(runEvent); +chain.verify(envelope); // true — tamper-evident +``` + +### Key Modules + +| Import Path | Purpose | +|-------------|---------| +| `@claude-flow/guidance` | Main entry — GuidanceControlPlane | +| `@claude-flow/guidance/compiler` | CLAUDE.md → PolicyBundle compiler | +| `@claude-flow/guidance/retriever` | Intent classification + shard retrieval | +| `@claude-flow/guidance/gates` | 4 enforcement gates | +| `@claude-flow/guidance/ledger` | Run event logging + evaluators | +| `@claude-flow/guidance/proof` | HMAC-SHA256 proof chain | +| `@claude-flow/guidance/adversarial` | Threat, collusion, memory quorum | +| `@claude-flow/guidance/trust` | Trust accumulation + privilege tiers | +| `@claude-flow/guidance/authority` | Human authority + irreversibility classification | +| `@claude-flow/guidance/wasm-kernel` | WASM-accelerated security-critical paths | +| `@claude-flow/guidance/analyzer` | CLAUDE.md quality analysis + A/B benchmarking | +| `@claude-flow/guidance/conformance-kit` | Headless conformance test runner | + +### Stats + +- **1,331 tests** across 26 test files +- **27 subpath exports** for tree-shaking +- **WASM kernel** for security-critical hot paths (gates, proof, scoring) +- **25 ADRs** documenting every architectural decision + +### Documentation + +- [Architecture Overview](v3/@claude-flow/guidance/docs/guides/architecture-overview.md) +- [Getting Started](v3/@claude-flow/guidance/docs/guides/getting-started.md) +- [Enforcement Gates Tutorial](v3/@claude-flow/guidance/docs/tutorials/enforcement-gates.md) +- [Proof Audit Trail](v3/@claude-flow/guidance/docs/tutorials/proof-audit-trail.md) +- [Multi-Agent Security](v3/@claude-flow/guidance/docs/guides/multi-agent-security.md) +- [API Quick Reference](v3/@claude-flow/guidance/docs/reference/api-quick-reference.md) +- [Full README](v3/@claude-flow/guidance/README.md) + +
+ +--- + ## 📦 Core Features Comprehensive capabilities for enterprise-grade AI agent orchestration. diff --git a/v3/pnpm-lock.yaml b/v3/pnpm-lock.yaml index 12e67e61c9..ee5d7a43a3 100644 --- a/v3/pnpm-lock.yaml +++ b/v3/pnpm-lock.yaml @@ -45,7 +45,7 @@ importers: dependencies: '@claude-flow/cli': specifier: ^3.0.0-alpha.140 - version: link:../cli + version: 3.0.0-alpha.190(agentic-flow@2.0.3) agent-browser: specifier: ^0.6.0 version: 0.6.0 @@ -96,15 +96,34 @@ importers: '@claude-flow/aidefence': specifier: ^3.0.2 version: link:../aidefence - '@claude-flow/embeddings': - specifier: ^3.0.0-alpha.12 - version: link:../embeddings + '@claude-flow/guidance': + specifier: ^3.0.0-alpha.1 + version: link:../guidance '@claude-flow/mcp': specifier: ^3.0.0-alpha.8 version: link:../mcp '@claude-flow/shared': specifier: ^3.0.0-alpha.1 version: link:../shared + '@noble/ed25519': + specifier: ^2.1.0 + version: 2.3.0 + optionalDependencies: + '@claude-flow/embeddings': + specifier: ^3.0.0-alpha.12 + version: link:../embeddings + '@claude-flow/plugin-gastown-bridge': + specifier: ^0.1.0 + version: 0.1.1 + '@ruvector/attention': + specifier: ^0.1.4 + version: 0.1.4 + '@ruvector/learning-wasm': + specifier: ^0.1.29 + version: 0.1.29 + '@ruvector/sona': + specifier: ^0.1.5 + version: 0.1.5 devDependencies: typescript: specifier: ^5.3.0 @@ -151,6 +170,28 @@ importers: specifier: ^4.0.16 version: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@20.19.27) + '@claude-flow/guidance': + dependencies: + '@claude-flow/hooks': + specifier: ^3.0.0-alpha.7 + version: link:../hooks + '@claude-flow/memory': + specifier: ^3.0.0-alpha.2 + version: link:../memory + '@claude-flow/shared': + specifier: ^3.0.0-alpha.1 + version: link:../shared + devDependencies: + '@types/node': + specifier: ^20.10.0 + version: 20.19.27 + typescript: + specifier: ^5.3.0 + version: 5.9.3 + vitest: + specifier: ^4.0.16 + version: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@20.19.27) + '@claude-flow/hooks': dependencies: '@claude-flow/memory': @@ -497,6 +538,100 @@ packages: resolution: {integrity: sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw==} dev: false + /@claude-flow/aidefence@3.0.2: + resolution: {integrity: sha512-jyZa1axjjqtYyS1AbnW0fPuzKBUqRH4SnTOTJZLm5Q6E7qX7A/IG7JcZVEeyipHSl9rFfc6Tj91bC1EoV4GMQg==} + engines: {node: '>=18.0.0'} + peerDependencies: + agentdb: '>=2.0.0-alpha.1' + peerDependenciesMeta: + agentdb: + optional: true + dev: false + + /@claude-flow/cli@3.0.0-alpha.190(agentic-flow@2.0.3): + resolution: {integrity: sha512-/DS7a53D9nZvF9S44i4BoPhdO7guSz0rLdEYW9MhHVhtElS5fo0ZIyt41QUZQgJ9FpT9ITNXUIy7zejkK2vrSA==} + hasBin: true + dependencies: + '@claude-flow/aidefence': 3.0.2 + '@claude-flow/mcp': 3.0.0-alpha.8 + '@claude-flow/shared': 3.0.0-alpha.1 + '@noble/ed25519': 2.3.0 + optionalDependencies: + '@claude-flow/embeddings': 3.0.0-alpha.12(@claude-flow/shared@3.0.0-alpha.1)(agentic-flow@2.0.3) + '@claude-flow/plugin-gastown-bridge': 0.1.1 + '@ruvector/attention': 0.1.4 + '@ruvector/learning-wasm': 0.1.29 + '@ruvector/sona': 0.1.5 + transitivePeerDependencies: + - '@claude-flow/memory' + - agentdb + - agentic-flow + - bare-abort-controller + - bare-buffer + - bufferutil + - react-native-b4a + - supports-color + - utf-8-validate + dev: false + + /@claude-flow/embeddings@3.0.0-alpha.12(@claude-flow/shared@3.0.0-alpha.1)(agentic-flow@2.0.3): + resolution: {integrity: sha512-k7oyPp3QofaVZvI+ZIuNy4IC8+L60cjFDtftwmnY2/flZSE5yWDNucMuzyIumb5E5SaXgrEyh/NQbfFKPRLTXA==} + engines: {node: '>=20.0.0'} + requiresBuild: true + peerDependencies: + '@claude-flow/shared': ^3.0.0-alpha.1 + agentic-flow: ^2.0.0 + peerDependenciesMeta: + agentic-flow: + optional: true + dependencies: + '@claude-flow/shared': 3.0.0-alpha.1 + '@xenova/transformers': 2.17.2 + agentic-flow: 2.0.3(@types/node@20.19.27)(hono@4.11.3)(marked@11.2.0) + sql.js: 1.13.0 + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + dev: false + optional: true + + /@claude-flow/mcp@3.0.0-alpha.8: + resolution: {integrity: sha512-lP1t8GMWDl9RxnwMZrjMukZkyglhge7Znhj1PbUiUQ94kHcN+dAxUkA75HM1n7BONbIDcE/CS8qN2ril5KgzNg==} + dependencies: + ajv: 8.17.1 + cors: 2.8.5 + express: 4.22.1 + helmet: 7.2.0 + ws: 8.19.0 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + + /@claude-flow/plugin-gastown-bridge@0.1.1: + resolution: {integrity: sha512-Wv/UO4RLiiKa9i8NMxDsex0zXJvD1QyBTIk8XH9nB72Qr91GzkXH8w4z3xPgr1koWx1CwZyim4Q6+MD2l52y9g==} + engines: {node: '>=20.0.0'} + requiresBuild: true + peerDependencies: + '@claude-flow/memory': '>=3.0.0' + peerDependenciesMeta: + '@claude-flow/memory': + optional: true + dependencies: + '@iarna/toml': 2.2.5 + uuid: 9.0.1 + zod: 3.25.76 + dev: false + optional: true + + /@claude-flow/shared@3.0.0-alpha.1: + resolution: {integrity: sha512-NIYfDd4OKeMnCe5xmEJe8aQtQCxJVo8Syf0+hGJua9exYPA9wSo0Yu1OIo1zlIOy/0upOm8mFHuDiYFL6Prqig==} + dependencies: + sql.js: 1.13.0 + dev: false + /@colors/colors@1.5.0: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} @@ -989,6 +1124,12 @@ packages: engines: {node: '>=18'} dev: false + /@iarna/toml@2.2.5: + resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} + requiresBuild: true + dev: false + optional: true + /@img/sharp-darwin-arm64@0.33.5: resolution: {integrity: sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -4204,7 +4345,7 @@ packages: http-proxy-middleware: 3.0.5 tiktoken: 1.0.22 ulid: 3.0.2 - ws: 8.18.3 + ws: 8.19.0 yaml: 2.8.2 zod: 3.25.76 transitivePeerDependencies: @@ -4629,6 +4770,7 @@ packages: /bare-events@2.8.2: resolution: {integrity: sha512-riJjyv1/mHLIPX4RwiK+oW9/4c3TEUeORHKefKAKnZ5kyslbN+HXowtbaVEqt4IMUB7OXlfixcs6gsFeo/jhiQ==} + requiresBuild: true peerDependencies: bare-abort-controller: '*' peerDependenciesMeta: @@ -5712,6 +5854,7 @@ packages: /events-universal@1.0.1: resolution: {integrity: sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==} + requiresBuild: true dependencies: bare-events: 2.8.2 transitivePeerDependencies: @@ -9475,6 +9618,7 @@ packages: /text-decoder@1.2.3: resolution: {integrity: sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==} + requiresBuild: true dependencies: b4a: 1.7.3 transitivePeerDependencies: