code

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package code implements `sf code` — a compact structural summary of source files, without function bodies, so the agent needn't cat a whole file just to see its shape/API (where read tokens go in practice).

This package is a thin ROUTER: it dispatches each file by extension to a per-language backend library (gocode, phpcode, tscode), runs multiple files in parallel, and aggregates the results. Each backend is small and tested in isolation. The router owns the cross-cutting concerns: the compact-or-raw token-saver invariant (internal/emit — emit the summary only when it is actually cheaper than the raw file, else hand back the raw bytes), the below-threshold raw passthrough ("never worse than cat" — see rawBelow), call-log accounting, and symbol-slice mode (one file, one or more symbols).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the `code` Cobra command (`sf code`).

func Run

func Run(opts Options, w io.Writer) error

Run dispatches the requested files to their backends and writes the result. Multiple files are summarised in parallel and aggregated in input order.

Types

type Options

type Options struct {
	Inputs       []string // one or more source files, directories, or glob patterns
	Format       string   // toon | md | json
	ExportedOnly bool
	API          bool     // PHP only: effective public surface (own + traits + inherited)
	Brief        bool     // names + signatures only — drop field/member/value detail
	Symbols      []string // optional: slice these func/method/type/etc. from Inputs[0] (single file)
	Force        bool     // bypass the dedup stub for a repeated call (still records itself, see internal/dedup)
}

Directories

Path Synopsis
Package gocode is the Go backend for `sf code`: a structural summary of a Go source file (package, imports, types, func/method signatures, consts, vars) and single-symbol slicing — via the stdlib go/parser (syntax only, no type-checking), so it works on any file regardless of whether it compiles.
Package gocode is the Go backend for `sf code`: a structural summary of a Go source file (package, imports, types, func/method signatures, consts, vars) and single-symbol slicing — via the stdlib go/parser (syntax only, no type-checking), so it works on any file regardless of whether it compiles.
Package phpcode is the PHP backend for `sf code`: a structural summary of a PHP file (namespace, class/interface/trait/enum, extends/implements, attributes, enum cases, constructor deps, properties, method signatures) and single-method slicing.
Package phpcode is the PHP backend for `sf code`: a structural summary of a PHP file (namespace, class/interface/trait/enum, extends/implements, attributes, enum cases, constructor deps, properties, method signatures) and single-method slicing.
Package tscode is the TypeScript/Vue backend for `sf code`.
Package tscode is the TypeScript/Vue backend for `sf code`.

Jump to

Keyboard shortcuts

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