agent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package agent implements the "ctx agent" command for generating AI-ready context packets.

The agent command reads context files from .context/ and produces a concise, token-budgeted output optimized for AI consumption. Output can be in Markdown (default) or JSON format.

File Organization

  • agent.go: Command definition and flag registration
  • run.go: Main execution logic and context loading
  • extract.go: Functions for extracting content from context files
  • sort.go: Priority sorting for tasks and decisions
  • out.go: Output formatting (Markdown and JSON)
  • types.go: Data structures for context packets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd

func Cmd() *cobra.Command

Cmd returns the "ctx agent" command for generating AI-ready context packets.

The command reads context files from .context/ and outputs a concise packet optimized for AI consumption, including constitution rules, active tasks, conventions, and recent decisions.

Flags:

  • --budget: Token budget for the context packet (default 8000)
  • --format: Output format, "md" for Markdown or "json" (default "md")

Returns:

  • *cobra.Command: Configured agent command with flags registered

Types

type Packet

type Packet struct {
	Generated    string   `json:"generated"`
	Budget       int      `json:"budget"`
	TokensUsed   int      `json:"tokens_used"`
	ReadOrder    []string `json:"read_order"`
	Constitution []string `json:"constitution"`
	Tasks        []string `json:"tasks"`
	Conventions  []string `json:"conventions"`
	Decisions    []string `json:"decisions"`
}

Packet represents the JSON output format for the agent command.

This struct is serialized when using --format json and contains all extracted context information for AI consumption.

Fields:

  • Generated: RFC3339 timestamp of when the packet was created
  • Budget: Token budget specified by the user
  • TokensUsed: Actual token count of loaded context files
  • ReadOrder: File paths in recommended reading order
  • Constitution: Rules from CONSTITUTION.md
  • Tasks: Active (unchecked) tasks from TASKS.md
  • Conventions: Key conventions from CONVENTIONS.md
  • Decisions: Recent decision titles from DECISIONS.md

Jump to

Keyboard shortcuts

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