krew

package module
v0.3.0-nightly.20261119 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Krew — Platform-Agnostic Autonomous AI Agent

Go Reference

Krew is an autonomous, platform-agnostic AI agent engine designed to be embedded literally anywhere:

  • In-process inside Krewire Boost or custom Go microservices.
  • As a local/remote headless runner in CI/CD pipelines or cron jobs.
  • As a background daemon via HTTP REST + Server-Sent Events (SSE) in Docker or Kubernetes.
  • Inside IDEs (Cursor, Windsurf, Claude Desktop, Antigravity) via Model Context Protocol (MCP).
  • Directly in your terminal via an interactive CLI (krew chat).

Architecture Overview

                      ┌────────────────────────────────────────┐
                      │            Target Application          │
                      │  (Krewire Boost, Go App, Server, IDE)  │
                      └───────────────────┬────────────────────┘
                                          │
                   ┌──────────────────────┴──────────────────────┐
                   │                 Transports                  │
                   │   Embed API  │  CLI  │  HTTP/SSE  │   MCP   │
                   └──────────────────────┬──────────────────────┘
                                          │
                               ┌──────────┴──────────┐
                               │     Krew Agent      │
                               │  (Autonomous ReAct) │
                               └──────────┬──────────┘
                                          │
             ┌────────────────────────────┼────────────────────────────┐
             │                            │                            │
   ┌─────────┴─────────┐        ┌─────────┴─────────┐        ┌─────────┴─────────┐
   │    Tool Suite     │        │   Memory Buffer   │        │   LLM Providers   │
   │  read/write/edit  │        │   Sliding Window  │        │  Gemini, OpenAI,  │
   │  exec, fetch_url  │        │     Compaction    │        │ Anthropic, Ollama │
   └───────────────────┘        └───────────────────┘        └───────────────────┘

1. Embed in Go (3 Lines)

You can embed Krew into any Go service or toolchain:

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/krewire/krew/pkg/embed"
	"github.com/krewire/krew/pkg/persona"
)

func main() {
	// 1. Initialize embedded agent (auto-detects GEMINI_API_KEY, OPENAI_API_KEY, etc.)
	ag, err := embed.New(embed.Options{
		Workspace: ".",
		Persona:   &persona.CodingAssistant,
	})
	if err != nil {
		log.Fatal(err)
	}

	// 2. Execute an autonomous task
	res, err := ag.Run(context.Background(), "Inspect the codebase and add tests for pkg/utils")
	if err != nil {
		log.Fatal(err)
	}

	// 3. Print result
	fmt.Println(res.Content)
}

2. CLI Usage

Interactive Terminal Session
# Launch interactive coding session
krew chat --persona=coding --workspace=.
Headless Single-Shot Execution
# Run headless automation (ideal for CI/CD or background scripts)
krew run "Check all Go tests and fix any failing assertions"
Remote Server Daemon
# Start HTTP/REST + Server-Sent Events daemon
krew serve --port=8080 --host=0.0.0.0

Available HTTP endpoints:

  • GET /health: Health check status.
  • POST /api/agent/run: Single-turn autonomous execution (supports {"stream": true} for SSE).
  • POST /api/agent/chat: Multi-turn conversational execution.
Model Context Protocol (MCP)

Run Krew as a stdio MCP server for Cursor, Windsurf, or Claude Desktop:

krew mcp --workspace=/path/to/project
Claude Desktop Configuration (claude_desktop_config.json):
{
  "mcpServers": {
    "krew": {
      "command": "krew",
      "args": ["mcp", "--workspace", "/path/to/workspace"],
      "env": {
        "GEMINI_API_KEY": "your-key-here"
      }
    }
  }
}

3. Built-In Personas

Krew provides battle-tested system personas tailored for specific operational environments:

Persona Role Key Capabilities
persona.CodingAssistant Senior software engineer Code exploration, refactoring, atomic diffs, test execution.
persona.DevOpsRunner Site reliability & DevOps Server diagnostics, Docker/systemd automation, network debugging.
persona.AutonomousWorker Headless worker Step-by-step task queue resolution with structured summaries.
persona.GeneralAssistant General companion Explanations, Q&A, and workflow assistance.

4. Built-In Sandboxed Tool Suite

All workspace tools respect path sandboxing to protect against directory traversal attacks (SafePath):

  • read_file(path): Inspect file contents up to size limits.
  • write_file(path, content, overwrite): Atomically create or overwrite files.
  • edit_file(path, target, replacement): Precise exact-match string replacement.
  • list_dir(path, recursive): File tree inventory.
  • run_command(command, timeout_seconds): Execute commands with timeout enforcement.
  • fetch_url(url, method, timeout_seconds): Query external APIs or scrape documentation.

5. Integrating with Krewire Boost

Krewire Boost leverages krew as its default coding assistant runtime:

import (
	"github.com/krewire/krew/pkg/embed"
	"github.com/krewire/krew/pkg/persona"
)

func RegisterBoostAssistant(workspace string) (*embed.Instance, error) {
	return embed.New(embed.Options{
		Workspace: workspace,
		Persona:   &persona.CodingAssistant,
		MaxSteps:  30,
	})
}

6. Supported LLM Providers

Krew uses github.com/krewire/krewire/pkg/ai as its unified inference provider abstraction:

  • Google Gemini: set GEMINI_API_KEY (defaults to Gemini 2.5 Flash / Pro).
  • OpenAI: set OPENAI_API_KEY (GPT-4o, o3-mini).
  • Anthropic: set ANTHROPIC_API_KEY (Claude 3.7 Sonnet).
  • Ollama: set OLLAMA_HOST (e.g. http://localhost:11434) for 100% offline local inference.

7. Strategic Roadmap

Krew follows a multi-year engineering roadmap (2026–2028):

  • 2026: Core ReAct Engine, Multi-Protocol Transports (Embed, CLI, SSE Daemon, MCP), Sandboxed Tools, and standalone CLI (krew). (Delivered)
  • 2027: 3-Tier Hierarchical Memory (Working, Episodic, Semantic Vector RAG), OpenTelemetry step tracing, cloud-hosted autonomous runners, and cryptographic agent identity (A-Identity) with RBAC.
  • 2028: Agent-to-Agent (A2A) peer-to-peer swarm mesh protocol, autonomous SRE remediation, sovereign air-gapped local inference engine (Ollama/GGUF/Metal/CUDA), and v1.0.0 LTS.

For quarterly ecosystem milestones, see Quarterly Roadmaps.


License

Krew is open source software licensed under the MIT License. Part of the Krewire ecosystem.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EcosystemRequires = map[string]version.Version{
	"krewire": version.MustParseVersion("0.2.0"),
}

EcosystemRequires declares the minimum version of each ecosystem module this one was built against.

View Source
var Version = version.MustParseVersion("0.2.0")

Version is the semantic release version of the Krew AI Agent engine.

Functions

func VersionString

func VersionString() string

VersionString returns the formatted version identifier.

Types

This section is empty.

Directories

Path Synopsis
cmd
krew command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL