@i4ctime/q-ring 0.4.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,13 +6,25 @@
6
6
 
7
7
  **The first quantum-inspired keyring built specifically for AI coding agents.**
8
8
 
9
- Stop pasting API keys into plain-text `.env` files or struggling with clunky secret managers. **q-ring** securely anchors your credentials to your OS's native vault (macOS Keychain, GNOME Keyring, Windows Credential Manager), then supercharges them with mechanics from quantum physics.
9
+ [![NPM Version](https://img.shields.io/npm/v/@i4ctime/q-ring?style=flat-square&color=0ea5e9)](https://www.npmjs.com/package/@i4ctime/q-ring)
10
+ [![Docs](https://img.shields.io/badge/docs-website-0ea5e9?style=flat-square)](https://i4ctime.github.io/quantum_ring/docs)
11
+ [![MCP Tools](https://img.shields.io/badge/MCP_tools-44-0ea5e9?style=flat-square)](https://glama.ai/mcp/servers/I4cTime/quantum_ring)
12
+ [![License](https://img.shields.io/npm/l/@i4ctime/q-ring?style=flat-square&color=0ea5e9)](https://github.com/I4cTime/quantum_ring/blob/main/LICENSE)
10
13
 
11
- Experience **superposition** (multi-environment keys), **entanglement** (linked rotations), **tunneling** (in-memory ephemerality), and **teleportation** (encrypted sharing).
14
+ <a href="https://glama.ai/mcp/servers/I4cTime/quantum_ring">
15
+ <img src="https://glama.ai/mcp/servers/I4cTime/quantum_ring/badges/card.svg" alt="quantum_ring MCP server" width="400" />
16
+ </a>
12
17
 
13
- Seamlessly integrated with **Cursor**, **Kiro**, **Claude Code**, and the entire **MCP** ecosystem.
18
+ Stop pasting API keys into plain-text `.env` files or wrestling with clunky secret managers. **q-ring** securely anchors your credentials to your OS's native vault (macOS Keychain, Linux Secret Service, Windows Credential Vault) and supercharges them with mechanics from quantum physics.
14
19
 
15
- [![qring-mcp MCP server](https://glama.ai/mcp/servers/I4cTime/quantum_ring/badges/card.svg)](https://glama.ai/mcp/servers/I4cTime/quantum_ring)
20
+ > 📖 **[View the Official Documentation](https://i4ctime.github.io/quantum_ring/docs)** for a complete CLI reference, MCP prompt cookbooks, and architecture details.
21
+
22
+ ### Why q-ring?
23
+ - **Superposition:** Store one key with multiple states (dev/staging/prod) that collapse based on context.
24
+ - **Entanglement:** Link keys across projects so rotating one automatically updates them all.
25
+ - **Tunneling:** Create ephemeral, in-memory secrets that self-destruct after a set time or read count.
26
+ - **Teleportation:** Securely pack and share AES-256-GCM encrypted secret bundles.
27
+ - **Seamless AI Integration:** 44 built-in MCP tools for native use in **Cursor**, **Kiro**, and **Claude Code**.
16
28
 
17
29
  ## 🚀 Installation
18
30
 
@@ -104,15 +116,22 @@ qring health
104
116
 
105
117
  ### Observer Effect — Audit Everything
106
118
 
107
- Every secret read, write, and delete is logged. Access patterns are tracked for anomaly detection.
119
+ Every secret read, write, and delete is logged with a tamper-evident hash chain. Access patterns are tracked for anomaly detection.
108
120
 
109
121
  ```bash
110
122
  # View audit log
111
123
  qring audit
112
124
  qring audit --key OPENAI_KEY --limit 50
113
125
 
114
- # Detect anomalies (burst access, unusual hours)
126
+ # Detect anomalies (burst access, unusual hours, chain tampering)
115
127
  qring audit --anomalies
128
+
129
+ # Verify audit chain integrity
130
+ qring audit:verify
131
+
132
+ # Export audit log
133
+ qring audit:export --format json --since 2026-03-01
134
+ qring audit:export --format csv --output audit-report.csv
116
135
  ```
117
136
 
118
137
  ### Quantum Noise — Secret Generation
@@ -313,6 +332,8 @@ qring hook test <id>
313
332
 
314
333
  Hooks are fire-and-forget: a failing hook never blocks secret operations. The hook registry is stored at `~/.config/q-ring/hooks.json`.
315
334
 
335
+ **SSRF protection:** HTTP hook URLs targeting private/loopback IP ranges (`127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `169.254.0.0/16`, `::1`, `fc00::/7`) are blocked by default. DNS resolution is checked before the request is sent. To allow hooks targeting local services (e.g. during development), set the environment variable `Q_RING_ALLOW_PRIVATE_HOOKS=1`.
336
+
316
337
  ### Configurable Rotation
317
338
 
318
339
  Set a rotation format per secret so the agent auto-rotates with the correct value shape.
@@ -325,6 +346,266 @@ qring set STRIPE_KEY "sk-..." --rotation-format api-key --rotation-prefix "sk-"
325
346
  qring set DB_PASS "..." --rotation-format password
326
347
  ```
327
348
 
349
+ ### Secure Execution & Auto-Redaction
350
+
351
+ Run commands with secrets securely injected into the environment. All known secret values are automatically redacted from stdout and stderr to prevent leaking into terminal logs or agent transcripts. Exec profiles restrict which commands may be run.
352
+
353
+ ```bash
354
+ # Execute a deployment script with secrets injected
355
+ qring exec -- npm run deploy
356
+
357
+ # Inject only specific tags
358
+ qring exec --tags backend -- node server.js
359
+
360
+ # Run with a restricted profile (blocks curl/wget/ssh, 30s timeout)
361
+ qring exec --profile restricted -- npm test
362
+ ```
363
+
364
+ ### Codebase Secret Scanner
365
+
366
+ Migrating a legacy codebase? Quickly scan directories for hardcoded credentials using regex heuristics and Shannon entropy analysis.
367
+
368
+ ```bash
369
+ # Scan current directory
370
+ qring scan .
371
+ ```
372
+
373
+ Output:
374
+ ```
375
+ ✗ src/db/connection.js:12
376
+ Key: DB_PASSWORD
377
+ Entropy: 4.23
378
+ Context: const DB_PASSWORD = "..."
379
+ ```
380
+
381
+ ### Composite / Templated Secrets
382
+
383
+ Store complex connection strings that dynamically resolve other secrets. If `DB_PASS` rotates, `DB_URL` is automatically correct without manual updates.
384
+
385
+ ```bash
386
+ qring set DB_USER "admin"
387
+ qring set DB_PASS "supersecret"
388
+ qring set DB_URL "postgres://{{DB_USER}}:{{DB_PASS}}@localhost/mydb"
389
+
390
+ # Resolves embedded templates automatically
391
+ qring get DB_URL
392
+ # Output: postgres://admin:supersecret@localhost/mydb
393
+ ```
394
+
395
+ ### User Approvals (Zero-Trust Agent)
396
+
397
+ Protect sensitive production secrets from being read autonomously by the MCP server without explicit user approval. Each approval token is HMAC-verified, scoped, reasoned, and time-limited.
398
+
399
+ ```bash
400
+ # Mark a secret as requiring approval
401
+ qring set PROD_DB_URL "..." --requires-approval
402
+
403
+ # Temporarily grant MCP access for 1 hour with a reason
404
+ qring approve PROD_DB_URL --for 3600 --reason "deploying v2.0"
405
+
406
+ # List all approvals with verification status
407
+ qring approvals
408
+
409
+ # Revoke an approval
410
+ qring approve PROD_DB_URL --revoke
411
+ ```
412
+
413
+ ### Just-In-Time (JIT) Provisioning
414
+
415
+ Instead of storing static credentials, configure `q-ring` to dynamically generate short-lived tokens on the fly when requested (e.g. AWS STS, generic HTTP endpoints).
416
+
417
+ ```bash
418
+ # Store the STS role configuration
419
+ qring set AWS_TEMP_KEYS '{"roleArn":"arn:aws:iam::123:role/AgentRole", "durationSeconds":3600}' --jit-provider aws-sts
420
+
421
+ # Resolving the secret automatically assumes the role and caches the temporary token
422
+ qring get AWS_TEMP_KEYS
423
+ ```
424
+
425
+ ### Project Context for AI Agents
426
+
427
+ A safe, redacted overview of the project's secrets, configuration, and state. Designed to be fed into an AI agent's system prompt without ever exposing secret values.
428
+
429
+ ```bash
430
+ # Human-readable summary
431
+ qring context
432
+
433
+ # JSON output (for MCP / programmatic use)
434
+ qring context --json
435
+ ```
436
+
437
+ ### Secret-Aware Linter
438
+
439
+ Scan specific files for hardcoded secrets with optional auto-fix. When `--fix` is used, detected secrets are replaced with `process.env.KEY` references and stored in q-ring.
440
+
441
+ ```bash
442
+ # Lint files for hardcoded secrets
443
+ qring lint src/config.ts src/db.ts
444
+
445
+ # Auto-fix: replace hardcoded values and store in q-ring
446
+ qring lint src/config.ts --fix
447
+
448
+ # Scan entire directory with auto-fix
449
+ qring scan . --fix
450
+ ```
451
+
452
+ ### Agent Memory
453
+
454
+ Encrypted, persistent key-value store that survives across AI agent sessions. Useful for remembering rotation history, project decisions, or context.
455
+
456
+ ```bash
457
+ # Store a memory
458
+ qring remember last_rotation "Rotated STRIPE_KEY on 2026-03-21"
459
+
460
+ # Retrieve it
461
+ qring recall last_rotation
462
+
463
+ # List all memories
464
+ qring recall
465
+
466
+ # Forget
467
+ qring forget last_rotation
468
+ ```
469
+
470
+ ### Pre-Commit Secret Scanning
471
+
472
+ Install a git pre-commit hook that automatically blocks commits containing hardcoded secrets.
473
+
474
+ ```bash
475
+ # Install the hook
476
+ qring hook:install
477
+
478
+ # Uninstall
479
+ qring hook:uninstall
480
+ ```
481
+
482
+ ### Secret Analytics
483
+
484
+ Analyze usage patterns and get optimization suggestions for your secrets.
485
+
486
+ ```bash
487
+ qring analyze
488
+ ```
489
+
490
+ Output includes most accessed secrets, unused/stale secrets, scope optimization suggestions, and rotation recommendations.
491
+
492
+ ### Service Setup Wizard
493
+
494
+ Quickly set up a new service integration with secrets, manifest entries, and hooks in one command.
495
+
496
+ ```bash
497
+ # Create secrets for a new Stripe integration
498
+ qring wizard stripe --keys STRIPE_KEY,STRIPE_SECRET --provider stripe --tags payment
499
+
500
+ # With a hook to restart the app on change
501
+ qring wizard myservice --hook-exec "pm2 restart app"
502
+ ```
503
+
504
+ ### Governance Policy
505
+
506
+ Define project-level governance rules in `.q-ring.json` to control which MCP tools can be used, which keys are accessible, and which commands can be executed. Policy is enforced at both the MCP server and keyring level.
507
+
508
+ ```bash
509
+ # View the active policy
510
+ qring policy
511
+
512
+ # JSON output
513
+ qring policy --json
514
+ ```
515
+
516
+ Example policy in `.q-ring.json`:
517
+
518
+ ```json
519
+ {
520
+ "policy": {
521
+ "mcp": {
522
+ "denyTools": ["delete_secret"],
523
+ "deniedKeys": ["PROD_DB_PASSWORD"],
524
+ "deniedTags": ["production"]
525
+ },
526
+ "exec": {
527
+ "denyCommands": ["curl", "wget", "ssh"],
528
+ "maxRuntimeSeconds": 30
529
+ },
530
+ "secrets": {
531
+ "requireApprovalForTags": ["production"],
532
+ "maxTtlSeconds": 86400
533
+ }
534
+ }
535
+ }
536
+ ```
537
+
538
+ ### Exec Profiles
539
+
540
+ Restrict command execution with named profiles that control allowed commands, network access, timeouts, and environment sanitization.
541
+
542
+ ```bash
543
+ # Run with the "restricted" profile (blocks curl, wget, ssh; 30s timeout)
544
+ qring exec --profile restricted -- npm test
545
+
546
+ # Run with the "ci" profile (5min timeout, allows network)
547
+ qring exec --profile ci -- npm run deploy
548
+
549
+ # Default: unrestricted
550
+ qring exec -- echo "hello"
551
+ ```
552
+
553
+ **Built-in profiles:** `unrestricted`, `restricted` (no network tools, 30s limit), `ci` (5min limit, blocks destructive commands).
554
+
555
+ ### Tamper-Evident Audit
556
+
557
+ Every audit event includes a SHA-256 hash of the previous event, creating a tamper-evident chain. Verify integrity and export logs in multiple formats.
558
+
559
+ ```bash
560
+ # Verify the entire audit chain
561
+ qring audit:verify
562
+
563
+ # Export as JSON
564
+ qring audit:export --format json --since 2026-03-01
565
+
566
+ # Export as CSV
567
+ qring audit:export --format csv --output audit-report.csv
568
+ ```
569
+
570
+ ### Team & Org Scopes
571
+
572
+ Extend beyond `global` and `project` scopes with `team` and `org` scopes for shared secrets across groups. Resolution order: project → team → org → global (most specific wins).
573
+
574
+ ```bash
575
+ # Store a secret in team scope
576
+ qring set SHARED_API_KEY "sk-..." --team my-team
577
+
578
+ # Store in org scope
579
+ qring set ORG_LICENSE "lic-..." --org acme-corp
580
+
581
+ # Resolution cascades: project > team > org > global
582
+ qring get API_KEY --team my-team --org acme-corp
583
+ ```
584
+
585
+ ### Issuer-Native Rotation
586
+
587
+ Attempt provider-native secret rotation (for providers that support it) or fall back to local generation.
588
+
589
+ ```bash
590
+ # Rotate via the detected provider
591
+ qring rotate STRIPE_KEY
592
+
593
+ # Force a specific provider
594
+ qring rotate API_KEY --provider openai
595
+ ```
596
+
597
+ ### CI Secret Validation
598
+
599
+ Batch-validate all secrets against their providers in a CI-friendly mode. Returns a structured pass/fail report with exit code 1 on failure.
600
+
601
+ ```bash
602
+ # Validate all secrets (CI mode)
603
+ qring ci:validate
604
+
605
+ # JSON output for pipeline parsing
606
+ qring ci:validate --json
607
+ ```
608
+
328
609
  ### Agent Mode — Autonomous Monitoring
329
610
 
330
611
  A background daemon that continuously monitors secret health, detects anomalies, and optionally auto-rotates expired secrets.
@@ -359,7 +640,7 @@ qring status --no-open
359
640
 
360
641
  ## MCP Server
361
642
 
362
- q-ring includes a full MCP server with 31 tools for AI agent integration.
643
+ q-ring includes a full MCP server with 44 tools for AI agent integration.
363
644
 
364
645
  ### Core Tools
365
646
 
@@ -416,15 +697,45 @@ q-ring includes a full MCP server with 31 tools for AI agent integration.
416
697
  | `list_hooks` | List all registered hooks with match criteria and status |
417
698
  | `remove_hook` | Remove a registered hook by ID |
418
699
 
700
+ ### Execution & Scanning Tools
701
+
702
+ | Tool | Description |
703
+ |------|-------------|
704
+ | `exec_with_secrets` | Run a shell command securely with secrets injected, auto-redacted output, and exec profile enforcement |
705
+ | `scan_codebase_for_secrets` | Scan a directory for hardcoded secrets using regex heuristics and entropy analysis |
706
+ | `lint_files` | Lint specific files for hardcoded secrets with optional auto-fix |
707
+
708
+ ### AI Agent Tools
709
+
710
+ | Tool | Description |
711
+ |------|-------------|
712
+ | `get_project_context` | Safe, redacted overview of project secrets, environment, manifest, and activity |
713
+ | `agent_remember` | Store a key-value pair in encrypted agent memory (persists across sessions) |
714
+ | `agent_recall` | Retrieve from agent memory, or list all stored keys |
715
+ | `agent_forget` | Delete a key from agent memory |
716
+ | `analyze_secrets` | Usage analytics: most accessed, stale, unused, and rotation recommendations |
717
+
419
718
  ### Observer & Health Tools
420
719
 
421
720
  | Tool | Description |
422
721
  |------|-------------|
423
722
  | `audit_log` | Query access history |
424
723
  | `detect_anomalies` | Scan for unusual access patterns |
724
+ | `verify_audit_chain` | Verify tamper-evident hash chain integrity |
725
+ | `export_audit` | Export audit events in jsonl, json, or csv format |
425
726
  | `health_check` | Full health report |
727
+ | `status_dashboard` | Launch the quantum status dashboard via MCP |
426
728
  | `agent_scan` | Run autonomous agent scan |
427
729
 
730
+ ### Governance & Policy Tools
731
+
732
+ | Tool | Description |
733
+ |------|-------------|
734
+ | `check_policy` | Check if an action (tool use, key read, exec) is allowed by project policy |
735
+ | `get_policy_summary` | Get a summary of the project's governance policy configuration |
736
+ | `rotate_secret` | Attempt issuer-native rotation via detected or specified provider |
737
+ | `ci_validate_secrets` | CI-oriented batch validation of all secrets with structured pass/fail report |
738
+
428
739
  ### Cursor / Kiro Configuration
429
740
 
430
741
  Add to `.cursor/mcp.json` or `.kiro/mcp.json`:
@@ -490,14 +801,22 @@ qring CLI ─────┐
490
801
  ├──▶ Core Engine ──▶ @napi-rs/keyring ──▶ OS Keyring
491
802
  MCP Server ────┘ │
492
803
  ├── Envelope (quantum metadata)
493
- ├── Scope Resolver (global / project)
804
+ ├── Scope Resolver (global / project / team / org)
494
805
  ├── Collapse (env detection + branchMap globs)
495
- ├── Observer (audit log)
806
+ ├── Observer (tamper-evident audit chain)
807
+ ├── Policy (governance-as-code engine)
496
808
  ├── Noise (secret generation)
497
809
  ├── Entanglement (cross-secret linking)
498
- ├── Validate (provider-based liveness checks)
810
+ ├── Validate (provider-based liveness + rotation)
499
811
  ├── Hooks (shell/HTTP/signal callbacks)
500
812
  ├── Import (.env file ingestion)
813
+ ├── Exec (profile-restricted injection + redaction)
814
+ ├── Scan (codebase entropy heuristics)
815
+ ├── Provision (JIT ephemeral credentials)
816
+ ├── Approval (HMAC-verified zero-trust tokens)
817
+ ├── Context (safe redacted project view)
818
+ ├── Linter (secret-aware code scanning)
819
+ ├── Memory (encrypted agent persistence)
501
820
  ├── Tunnel (ephemeral in-memory)
502
821
  ├── Teleport (encrypted sharing)
503
822
  ├── Agent (autonomous monitor + rotation)
@@ -523,6 +842,17 @@ Optional per-project configuration:
523
842
  "OPENAI_API_KEY": { "required": true, "description": "OpenAI API key", "format": "api-key", "prefix": "sk-", "provider": "openai" },
524
843
  "DATABASE_URL": { "required": true, "description": "Postgres connection string", "validationUrl": "https://api.example.com/health" },
525
844
  "SENTRY_DSN": { "required": false, "description": "Sentry error tracking" }
845
+ },
846
+ "policy": {
847
+ "mcp": {
848
+ "denyTools": ["delete_secret"],
849
+ "deniedKeys": ["PROD_DB_PASSWORD"],
850
+ "deniedTags": ["production"]
851
+ },
852
+ "exec": {
853
+ "denyCommands": ["curl", "wget"],
854
+ "maxRuntimeSeconds": 60
855
+ }
526
856
  }
527
857
  }
528
858
  ```
@@ -531,6 +861,7 @@ Optional per-project configuration:
531
861
  - **`secrets`** declares the project's required secrets — use `qring check` to validate, `qring env:generate` to produce a `.env` file
532
862
  - **`provider`** associates a liveness validation provider with a secret (e.g., `"openai"`, `"stripe"`, `"github"`) — use `qring validate` to test
533
863
  - **`validationUrl`** configures the generic HTTP provider's endpoint for custom validation
864
+ - **`policy`** defines governance rules for MCP tool gating, key access restrictions, exec allowlists, and secret lifecycle requirements
534
865
 
535
866
  ## 📜 License
536
867