core

module
v0.1.158 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT

README

codefly.ai core

workflow Go Report Card Go Reference coverage

Fundamentals for the codefly.ai ecosystem.

dragonfly

What this is

core is the shared library that every codefly agent, the CLI, and user services depend on. It defines:

  • Resource modelWorkspace, Module, Service, Endpoint, Agent, Environment (resources/)
  • Architecture — DAG-based dependency resolution (architecture/, graph/)
  • Network model — port allocation, DNS, native/container/public access modes (network/)
  • Configuration flow — typed configs passed between services as env vars (configurations/)
  • Agent system — gRPC-based agent lifecycle: Builder, Runtime, Code (agents/)
  • Runners — Native, Docker, and Nix execution environments with consistent process supervision (runners/)
  • Companions — sidecar containers for proto, Go, Python, Node tooling (companions/)
  • Telemetry — structured logging via wool (wool/)

Install

go get github.com/codefly-dev/core

core is self-contained — no replace directives, no internal codefly imports beyond its own module.

Quick example

import (
    "context"
    "github.com/codefly-dev/core/resources"
    "github.com/codefly-dev/core/wool"
)

ctx := context.Background()
w := wool.Get(ctx).In("Example")

ws, err := resources.LoadWorkspaceFromDir(ctx, "/path/to/workspace")
if err != nil {
    return w.Wrapf(err, "load workspace")
}
w.Info("loaded", wool.Field("modules", len(ws.Modules)))

Develop

# All tests
go test ./...

# Single package
go test ./resources/ -v

# With race detector
go test -race ./...

Tests gracefully skip when external prerequisites (Docker, Nix flakes ≥ 2.18) are unavailable.

License

MIT — see LICENSE.

Directories

Path Synopsis
Package agents provides the framework for codefly service agents: gRPC servers that the CLI spawns as subprocesses to handle the service lifecycle (Load → Init → Start → Stop → Destroy) and the build / deploy / code-analysis flows.
Package agents provides the framework for codefly service agents: gRPC servers that the CLI spawns as subprocesses to handle the service lifecycle (Load → Init → Start → Stop → Destroy) and the build / deploy / code-analysis flows.
services/audit
Package audit runs language-specific dependency audits on behalf of codefly Builder agents.
Package audit runs language-specific dependency audits on behalf of codefly Builder agents.
services/upgrade
Package upgrade applies dependency bumps on behalf of codefly Builder agents.
Package upgrade applies dependency bumps on behalf of codefly Builder agents.
testing
Package testing provides helpers for agent composition + lifecycle tests.
Package testing provides helpers for agent composition + lifecycle tests.
Package architecture computes the dependency graph across services and modules and produces a topological execution order.
Package architecture computes the dependency graph across services and modules and produces a topological execution order.
Package builders provides file-level dependency tracking for incremental agent builds.
Package builders provides file-level dependency tracking for incremental agent builds.
Package code provides shared implementations for Code service RPCs.
Package code provides shared implementations for Code service RPCs.
companions
dap
treesitter
Package treesitter implements code analysis using tree-sitter parsers.
Package treesitter implements code analysis using tree-sitter parsers.
treesitter/golang
Package golang registers the Go tree-sitter grammar with the treesitter registry.
Package golang registers the Go tree-sitter grammar with the treesitter registry.
treesitter/python
Package python registers the Python tree-sitter grammar with the treesitter registry.
Package python registers the Python tree-sitter grammar with the treesitter registry.
Package configurations routes service configurations and DNS declarations between codefly services.
Package configurations routes service configurations and DNS declarations between codefly services.
generated
go/codefly/cli/v0
Package v0 is a reverse proxy.
Package v0 is a reverse proxy.
go/mind/debug/v1
Package debugv1 is a reverse proxy.
Package debugv1 is a reverse proxy.
go/mind/v1
Package mindv1 is a reverse proxy.
Package mindv1 is a reverse proxy.
Package generation provides the template-driven code generator that powers `codefly add` and agent scaffolding.
Package generation provides the template-driven code generator that powers `codefly add` and agent scaffolding.
Package graph implements the directed-graph primitives that architecture and other dependency-aware packages use.
Package graph implements the directed-graph primitives that architecture and other dependency-aware packages use.
Package languages defines the language and runtime constants codefly understands (GO, PYTHON, TYPESCRIPT, RUST, …) and the runtime kinds that agents declare as prerequisites.
Package languages defines the language and runtime constants codefly understands (GO, PYTHON, TYPESCRIPT, RUST, …) and the runtime kinds that agents declare as prerequisites.
Package network manages port allocation, DNS resolution, and kubernetes / container network instance creation for codefly services.
Package network manages port allocation, DNS resolution, and kubernetes / container network instance creation for codefly services.
Package policy is the codefly permission and capability layer.
Package policy is the codefly permission and capability layer.
Package resources defines the codefly resource model — the typed hierarchy that every other package operates on.
Package resources defines the codefly resource model — the typed hierarchy that every other package operates on.
runners
base
Package base is the runner foundation: it defines the RunnerEnvironment and Proc abstractions and provides three backends — Native, Docker, and Nix — plus the CompanionRunner wrapper that picks the best backend at runtime.
Package base is the runner foundation: it defines the RunnerEnvironment and Proc abstractions and provides three backends — Native, Docker, and Nix — plus the CompanionRunner wrapper that picks the best backend at runtime.
golang
Package golang is the Go-specific runner: build, test, and run Go programs in any of the supported execution environments (native, Docker, Nix) with consistent behavior.
Package golang is the Go-specific runner: build, test, and run Go programs in any of the supported execution environments (native, Docker, Nix) with consistent behavior.
javascript
Package javascript runs and parses test output for JS/TS test runners — vitest, jest, playwright.
Package javascript runs and parses test output for JS/TS test runners — vitest, jest, playwright.
python
Package python is the Python-specific runner: build, test, and run Python services across native, Docker, and Nix backends.
Package python is the Python-specific runner: build, test, and run Python services across native, Docker, and Nix backends.
sandbox
Package sandbox confines a child process's filesystem and network access using OS-level primitives.
Package sandbox confines a child process's filesystem and network access using OS-level primitives.
testmatrix
Package testmatrix provides a multi-environment test harness.
Package testmatrix provides a multi-environment test harness.
Package sdk provides helpers for codefly-managed services.
Package sdk provides helpers for codefly-managed services.
Package shared collects small, dependency-free utilities used across the codefly stack: case conversions, file & path helpers, the Must pattern, generics helpers, and concurrency-safe writers used in tests and runners.
Package shared collects small, dependency-free utilities used across the codefly stack: case conversions, file & path helpers, the Must pattern, generics helpers, and concurrency-safe writers used in tests and runners.
leakcheck
Package leakcheck provides test-time helpers for detecting resource leaks: file descriptors, docker containers, and (via go.uber.org/goleak wired at the TestMain level) goroutines.
Package leakcheck provides test-time helpers for detecting resource leaks: file descriptors, docker containers, and (via go.uber.org/goleak wired at the TestMain level) goroutines.
Package standards defines the small set of API-type constants used across the codefly stack: TCP, HTTP, REST, GRPC.
Package standards defines the small set of API-type constants used across the codefly stack: TCP, HTTP, REST, GRPC.
Package templates is the template engine that materializes agent scaffolding, service stubs, and configuration files from templates/factory/ and templates/builder/ trees.
Package templates is the template engine that materializes agent scaffolding, service stubs, and configuration files from templates/factory/ and templates/builder/ trees.
toolbox
bash
Package bash is the codefly Bash toolbox — the only sanctioned path for running shell commands across the codefly stack.
Package bash is the codefly Bash toolbox — the only sanctioned path for running shell commands across the codefly stack.
git
Package git is the codefly Git toolbox: every git operation an agent might want to perform, exposed as typed Tool RPCs through the codefly.services.toolbox.v0 contract.
Package git is the codefly Git toolbox: every git operation an agent might want to perform, exposed as typed Tool RPCs through the codefly.services.toolbox.v0 contract.
git/cmd/git-toolbox command
Command git-toolbox is the standalone binary form of the codefly git toolbox.
Command git-toolbox is the standalone binary form of the codefly git toolbox.
lang
Package lang defines the conventional language toolbox: the stable set of tool names every language plugin (python, go, rust, ...) exposes through the unified Toolbox contract.
Package lang defines the conventional language toolbox: the stable set of tool names every language plugin (python, go, rust, ...) exposes through the unified Toolbox contract.
lang/cmd/fake-lang-toolbox command
Command fake-lang-toolbox is a TEST-ONLY language plugin used by the round-trip integration test in core/toolbox/lang.
Command fake-lang-toolbox is a TEST-ONLY language plugin used by the round-trip integration test in core/toolbox/lang.
launch
Package launch bridges resources.Toolbox manifests to running host.Plugin processes.
Package launch bridges resources.Toolbox manifests to running host.Plugin processes.
launch/cmd/network-victim-toolbox command
Command network-victim-toolbox is a TEST-ONLY plugin used by the end-to-end sandbox-enforcement tests in core/toolbox/launch.
Command network-victim-toolbox is a TEST-ONLY plugin used by the end-to-end sandbox-enforcement tests in core/toolbox/launch.
mcp
Package mcp transcodes between the codefly toolbox v0 contract (Connect-RPC over gRPC) and the Model Context Protocol (JSON-RPC 2.0 over stdio).
Package mcp transcodes between the codefly toolbox v0 contract (Connect-RPC over gRPC) and the Model Context Protocol (JSON-RPC 2.0 over stdio).
mcprev
Package mcprev is the reverse-direction MCP transcoder: wraps an MCP server (speaking JSON-RPC over stdio) and exposes it as a codefly Toolbox gRPC server.
Package mcprev is the reverse-direction MCP transcoder: wraps an MCP server (speaking JSON-RPC over stdio) and exposes it as a codefly Toolbox gRPC server.
policyguard
Package policyguard wraps a toolboxv0.ToolboxServer with policy decision point (PDP) enforcement.
Package policyguard wraps a toolboxv0.ToolboxServer with policy decision point (PDP) enforcement.
registry
Package registry holds the shared "tool definition" type each codefly toolbox uses to declare its callable surface ONCE and project to whichever response shape the host requested:
Package registry holds the shared "tool definition" type each codefly toolbox uses to declare its callable surface ONCE and project to whichever response shape the host requested:
respond
Package respond holds the small set of response-shaping helpers that every toolbox.Toolbox implementation needs: extract arguments from a CallToolRequest, build error / structured / content responses, and bake JSON-Schema constants into the proto Struct shape.
Package respond holds the small set of response-shaping helpers that every toolbox.Toolbox implementation needs: extract arguments from a CallToolRequest, build error / structured / content responses, and bake JSON-Schema constants into the proto Struct shape.
Package tui provides the bubbletea-based terminal UI components used by `codefly run` and other interactive CLI commands.
Package tui provides the bubbletea-based terminal UI components used by `codefly run` and other interactive CLI commands.
Package version exposes the current codefly build version and is the single source of truth used by both the CLI (--version) and the embedded agents.
Package version exposes the current codefly build version and is the single source of truth used by both the CLI (--version) and the embedded agents.
Package wool is a lightweight, pluggable telemetry layer for codefly.
Package wool is a lightweight, pluggable telemetry layer for codefly.
log
otel
Package otel provides an OpenTelemetry backend for wool.
Package otel provides an OpenTelemetry backend for wool.

Jump to

Keyboard shortcuts

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