Documentation
¶
Overview ¶
Package setup wires stacklit into AI coding assistants. Every step is idempotent, supports dry-run, and can be reversed with uninstall.
Index ¶
- Constants
- Variables
- func BodyFor(idx *schema.Index, variant string) string
- func CrawlGuardHook(stdin io.Reader, installed string) (out string)
- func CrawlMode(root, installed string) string
- func CrawlModes() []string
- func GuideJSON() string
- func GuideText() string
- func MCPSchemaTokens(exe, dir string) int
- func MarkdownBody(idx *schema.Index) string
- func PreToolHook(stdin io.Reader) string
- func Run(r *Runner, o Options) error
- func SessionHook(stdin io.Reader) string
- func SteeringFor(root string) string
- func SteeringVariants() []string
- func SubagentHook(stdin io.Reader) string
- func Tokens(s string) int
- type ClaudeOptions
- type Crawl
- type GuideCommand
- type MCP
- type MCPStyle
- type Options
- type ReportRow
- type Rule
- type Runner
- type Tool
Constants ¶
const ( StyleMarkdown = "md" StyleHash = "hash" )
Marker styles. Markdown files use HTML comments, config files use hashes.
const ( CrawlOff = "off" CrawlNudge = "nudge" CrawlRedirect = "redirect" )
Crawl guard modes.
const DefaultSteering = "a"
DefaultSteering is the variant used when none is configured.
const StructureTag = "map "
StructureTag prefixes the hash in the digest so a reader (or the session hook) can tell which structure a CLAUDE.md block was written from.
Variables ¶
var SkillMD string
SkillMD is the /stacklit skill installed for Claude Code.
Functions ¶
func BodyFor ¶ added in v0.5.0
BodyFor is MarkdownBody with a chosen steering variant. Nothing in it depends on line counts, timestamps or churn, only on structure.
func CrawlGuardHook ¶ added in v0.5.0
CrawlGuardHook answers a PreToolUse payload. Any failure, a missing index or a narrow call produces no output, which Claude Code reads as allow.
func CrawlMode ¶ added in v0.5.0
CrawlMode resolves the mode: STACKLIT_CRAWL_GUARD, then the crawl_guard config key, then the mode the installed hook carries. Unknown means off.
func GuideJSON ¶ added in v0.5.0
func GuideJSON() string
GuideJSON is the same guide as JSON for tools that want structured input.
func GuideText ¶ added in v0.5.0
func GuideText() string
GuideText is the full agent usage guide, plain text, byte stable.
func MCPSchemaTokens ¶ added in v0.5.0
MCPSchemaTokens starts `exe serve` and measures the tools/list payload an agent loads into context. It returns -1 when the server cannot be queried.
func MarkdownBody ¶ added in v0.5.0
MarkdownBody builds the always-on orientation digest. It is deterministic (sorted, no timestamps, no churn counters) so reruns are byte-identical and do not invalidate prompt caches, and it is capped to the token budget.
func PreToolHook ¶ added in v0.5.0
PreToolHook answers a PreToolUse payload. For a Grep on a single identifier it points at the definition and top callers from the symbol graph; it never blocks or approves, and stays silent without a graph or for non-identifiers.
func SessionHook ¶ added in v0.5.0
SessionHook answers a SessionStart payload for every source (startup, resume, clear, compact, fork). When the project's CLAUDE.md already holds a digest of the current structure it adds only the status line, because Claude Code re-reads that file itself, including after compaction. Otherwise it injects the digest. Any failure or a missing index yields no output.
func SteeringFor ¶ added in v0.5.0
SteeringFor resolves the variant: STACKLIT_STEERING wins, then the config key.
func SteeringVariants ¶ added in v0.5.0
func SteeringVariants() []string
SteeringVariants lists the valid variant names.
func SubagentHook ¶ added in v0.5.0
SubagentHook answers a SubagentStart payload. Explore and Plan skip CLAUDE.md, so they get the digest; other agents already load it and get nothing, which avoids paying for the same text twice.
Types ¶
type ClaudeOptions ¶ added in v0.5.0
type ClaudeOptions struct {
PreToolHook bool
SessionHook bool
RefreshHook bool
// CrawlGuard is "", "off" (remove), "nudge" or "redirect".
CrawlGuard string
Skill bool
GlobalScope bool
UninstallAll bool
}
ClaudeOptions selects the optional Claude Code extras.
type Crawl ¶ added in v0.5.0
type Crawl struct {
Kind string // find, ls, tree, grep, glob, read-dir, subagent
Ident string // identifier searched for, when the pattern is one
Query string // words to put in a stacklit query, may be empty
Command string // suggested stacklit command
}
Crawl describes one recognised repo-wide crawl and the stacklit command that answers the same need.
func DetectBash ¶ added in v0.5.0
DetectBash judges a shell command line. A cd into a subdirectory ends the scan, since later relative paths no longer mean the repo root.
func DetectCrawl ¶ added in v0.5.0
DetectCrawl classifies one PreToolUse payload.
func DetectGlob ¶ added in v0.5.0
DetectGlob flags a Glob that lists every file or every file of an extension from the repo root. Patterns naming a file or a subdirectory pass.
func DetectRead ¶ added in v0.5.0
DetectRead flags a Read whose target is a directory.
func DetectSubagent ¶ added in v0.5.0
DetectSubagent flags a subagent prompt that asks to explore the whole repo with no identifier, path or file named.
type GuideCommand ¶ added in v0.5.0
GuideCommand is one row of the command list in the guide.
func GuideCommands ¶ added in v0.5.0
func GuideCommands() []GuideCommand
GuideCommands lists the commands an agent should reach for, in order.
type MCP ¶ added in v0.5.0
type MCP struct {
Path string
Style MCPStyle
// Global paths are relative to the home directory and need --global.
Global bool
}
MCP describes where and how a tool registers the stacklit server.
type MCPStyle ¶ added in v0.5.0
type MCPStyle string
MCPStyle selects the config file format a tool expects.
type Options ¶ added in v0.5.0
type Options struct {
Root string
Tools []Tool
Index *schema.Index
Uninstall bool
NoMCP bool
NoGitHook bool
// Global lets setup write outside the repo (home directory configs).
Global bool
Claude ClaudeOptions
}
Options controls one setup run.
type ReportRow ¶ added in v0.5.0
ReportRow is the always-on context one integration adds, in tokens (bytes/4).
type Rule ¶ added in v0.5.0
Rule is one instruction file a tool reads. Owned files are ours alone and are deleted on uninstall once the block is gone; shared files only lose the block.
type Runner ¶ added in v0.5.0
type Runner struct {
Root string
DryRun bool
Out io.Writer
// Changed counts files that were (or would be) created, updated or removed.
Changed int
}
Runner applies file changes, or only reports them in dry-run mode.
func (*Runner) ApplyClaudeExtras ¶ added in v0.5.0
func (r *Runner) ApplyClaudeExtras(o ClaudeOptions, uninstall bool) error
ApplyClaudeExtras installs or removes the optional hooks and skill. Settings are only written under .claude/ unless GlobalScope is set.
type Tool ¶
type Tool struct {
ID string
Name string
Rules []Rule
MCP []MCP
// Paths and Bins drive auto-detection.
Paths []string
Bins []string
}
Tool is one supported AI coding assistant.