focus

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package focus implements the `supermodel focus` command.

Given a file or function, it extracts a compact, token-efficient representation of the relevant graph slice: direct imports, functions defined in the file, callers, and callees. The output is formatted as structured markdown for direct injection into LLM context windows.

This addresses two issues:

  • #11 Token Efficiency Feature — minimal graph slice instead of full dump
  • #13 Slicing and Typing — type-aware slice extraction

This is a vertical slice. It must not import any other slice package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, cfg *config.Config, dir, target string, opts Options) error

Run extracts a focused graph slice for target and prints it.

Types

type Call

type Call struct {
	Caller string `json:"caller"`
	File   string `json:"file"`
}

Call is a reference to this file from an external caller.

type Function

type Function struct {
	Name    string   `json:"name"`
	Callees []string `json:"calls,omitempty"` // functions this fn calls
}

Function is a function defined in the focused file.

type Options

type Options struct {
	Force        bool   // bypass cache
	Output       string // "markdown" | "json"
	Depth        int    // import traversal depth (default 1)
	IncludeTypes bool   // include type/class nodes
}

Options configures the focus command.

type Slice

type Slice struct {
	File      string     `json:"file"`
	Imports   []string   `json:"imports"`
	Functions []Function `json:"functions"`
	CalledBy  []Call     `json:"called_by"`
	Types     []Type     `json:"types,omitempty"`
	TokenHint int        `json:"approx_tokens"` // rough estimate
}

Slice is the token-efficient graph slice for a single file.

type Type

type Type struct {
	Name string `json:"name"`
	Kind string `json:"kind"` // "class" | "interface" | "type"
	File string `json:"file"`
}

Type is a type/class declared in or used by the focused file.

Jump to

Keyboard shortcuts

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