cmd

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Copyright © 2026 nmdra

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAndRun

func ParseAndRun(ctx context.Context, version, commit, date string) error

ParseAndRun parses CLI arguments and runs the selected subcommand.

Types

type BacklinksCmd

type BacklinksCmd struct {
	Note string `arg:"" help:"note slug, title, or file path (auto-resolved)"`
}

func (*BacklinksCmd) Run

func (c *BacklinksCmd) Run(globals *Globals) error

type BoostedCmd

type BoostedCmd struct {
	ChunkDisplayFlags
	Query string  `arg:"" help:"search query text"`
	Limit int     `help:"maximum number of results" default:"10"`
	Seed  string  `help:"seed note (slug, title, or path) whose graph neighbors get score boost" required:"true"`
	Boost float64 `help:"score multiplier for graph-connected results (e.g. 1.5 = 50% boost)" default:"1.5"`
}

func (*BoostedCmd) Run

func (c *BoostedCmd) Run(globals *Globals) error

type CLI

type CLI struct {
	Globals

	Ingest      IngestCmd      `cmd:"" help:"Ingest markdown files from a vault"`
	Search      SearchCmd      `cmd:"" help:"Semantic search across indexed notes"`
	Backlinks   BacklinksCmd   `cmd:"" help:"Find incoming links to a note"`
	Connections ConnectionsCmd `cmd:"" help:"Find notes connected via wikilinks (graph traversal)"`
	Hidden      HiddenCmd      `cmd:"" help:"Discover semantically related but unlinked notes"`
	Tags        TagsCmd        `cmd:"" help:"Find notes sharing common tags"`
	Boosted     BoostedCmd     `cmd:"" help:"Semantic search boosted by wikilink graph proximity"`
	Stats       StatsCmd       `cmd:"" help:"Show collection statistics"`
	Get         GetCmd         `cmd:"" help:"Retrieve the full text of an indexed note"`
	Reset       ResetCmd       `cmd:"" help:"Delete all indexed data and reset the database"`
	Version     VersionCmd     `cmd:"" help:"Show version information"`
}

CLI is the top-level Kong command tree.

type ChunkDisplayFlags added in v2.7.0

type ChunkDisplayFlags struct {
	IncludeText   bool    `help:"include the matched markdown text in each result"`
	ContextWindow int     `name:"context-window" help:"fetch ±N surrounding chunks around each match (0=off)" default:"0"`
	MinScore      float64 `help:"minimum similarity score to include in results (0.0–1.0)" default:"0"`
}

ChunkDisplayFlags holds options for semantic search commands that return text chunks.

type ConnectionsCmd

type ConnectionsCmd struct {
	Note string `arg:"" help:"note slug, title, or file path (auto-resolved)"`
	Hops int    `help:"graph traversal depth (keep 1-2 to avoid exponential blowup)" default:"2"`
}

func (*ConnectionsCmd) Run

func (c *ConnectionsCmd) Run(globals *Globals) error

type GetCmd

type GetCmd struct {
	Slug string `arg:"" help:"note slug, title, or file path (auto-resolved)"`
}

func (*GetCmd) Run

func (c *GetCmd) Run(globals *Globals) error

type Globals

type Globals struct {
	ChromaPath      string           `help:"path to ChromaDB persistent storage directory" default:"~/.notebrain/chroma"`
	VaultPath       string           `name:"vault-path" help:"path to the Obsidian vault directory"`
	VaultName       string           `name:"vault-name" help:"vault display name for Obsidian URI links (defaults to basename of --vault-path)"`
	Verbose         bool             `help:"show detailed output including all matched sections"`
	NoHyperlinks    bool             `help:"disable clickable terminal hyperlinks in output"`
	Format          string           `help:"output format: text, json, or tsv" enum:"text,json,tsv" default:"text"`
	JSONPath        string           `name:"jsonpath" help:"extract fields using JSONPath (e.g. '$.results[*].note_slug')"`
	LogFormat       string           `name:"log-format" help:"log output format (auto, json, text)" default:"auto"`
	LogLevel        string           `name:"log-level" help:"minimum log severity (info, debug, warn, error)" default:"info"`
	SkipAttachments bool             `name:"skip-attachments" help:"exclude image/attachment links from graph edges" default:"true"`
	SkipPhantom     bool             `name:"skip-phantom" help:"exclude phantom (uncreated) notes from results" default:"true"`
	HideTags        bool             `name:"hide-tags" help:"hide tag names from output (use --hide-tags=false to show)" default:"true"`
	ShowFilePath    bool             `name:"show-file-path" help:"include file_path in output (use --show-file-path=false to hide)" default:"true"`
	Version         kong.VersionFlag `name:"version" help:"show version information"`

	// Internal fields, not exposed as flags
	Ctx           context.Context `kong:"-"`
	VersionString string          `kong:"-"`
	Queries       []string        `kong:"-"`

	Config kong.ConfigFlag `help:"path to config file" default:"~/.notebrain/config/config.toml"`
}

Globals holds shared configuration available to all subcommands.

type HiddenCmd

type HiddenCmd struct {
	ChunkDisplayFlags
	Note          string `arg:"" help:"note slug, title, or file path (auto-resolved)"`
	Limit         int    `help:"maximum number of hidden connections to return" default:"10"`
	Deep          bool   `help:"analyze each chunk individually for granular section-level matches"`
	TopK          int    `name:"top-k" help:"chunks to evaluate per candidate note in --deep mode" default:"3"`
	IncludeLinked bool   `name:"include-linked" help:"include notes even if they are already linked directly or indirectly"`
}

func (*HiddenCmd) Run

func (c *HiddenCmd) Run(globals *Globals) error

type IngestCmd

type IngestCmd struct {
	Glob           string `arg:"" optional:"" help:"glob pattern to filter files (default: all .md files)"`
	Workers        int    `help:"number of concurrent ingestion workers" default:"4"`
	MinChunkWords  int    `name:"min-chunk-words" help:"skip chunks with fewer words (0=default of 10)" default:"0"`
	ChunkSize      int    `name:"chunk-size" help:"max runes per chunk (0=default of 800)" default:"0"`
	ChunkOverlap   int    `name:"chunk-overlap" help:"overlap runes between sub-chunks (0=default of 100)" default:"0"`
	RespectExclude bool   `help:"respect Obsidian userIgnoreFilters and attachmentFolderPath settings during ingest" default:"true"`
}

func (*IngestCmd) Run

func (c *IngestCmd) Run(globals *Globals) error

type ResetCmd

type ResetCmd struct {
	Yes bool `short:"y" help:"skip confirmation prompt (use in scripts and automation)"`
}

func (*ResetCmd) Run

func (c *ResetCmd) Run(globals *Globals) error

type SearchCmd

type SearchCmd struct {
	ChunkDisplayFlags
	Queries     []string `arg:"" optional:"" name:"query" help:"search query (multiple args for multi-hit boosting)"`
	Split       bool     `help:"split query by delimiters for independent sub-searches with multi-hit boosting"`
	SplitBy     string   `name:"split-by" help:"delimiter characters for --split" default:",|;"`
	Limit       int      `help:"maximum number of results" default:"10"`
	TopKPerNote int      `name:"top-k" help:"maximum chunks to retain per note (prevents one note dominating)" default:"3"`
	Section     string   `help:"filter results to chunks under this heading path (e.g. 'Architecture > Components')"`
	Tag         string   `help:"filter results to notes with this tag"`
	HasTasks    bool     `help:"only return chunks containing task lists (checkboxes)"`
	HasCode     bool     `help:"only return chunks containing fenced code blocks"`
}

func (*SearchCmd) Run

func (c *SearchCmd) Run(globals *Globals) error

type StatsCmd

type StatsCmd struct {
}

func (*StatsCmd) Run

func (c *StatsCmd) Run(globals *Globals) error

type TagsCmd

type TagsCmd struct {
	Query     string `arg:"" help:"Tag name to search for (e.g. 'kubernetes'), or note slug/title if --shared is used."`
	Shared    bool   `help:"Find notes sharing tags with the given note instead of searching by tag name." default:"false"`
	Children  bool   `help:"Include child tags in the hierarchy (e.g. 'kubernetes' also matches 'kubernetes/cka')." default:"false"`
	MinShared int    `help:"Minimum shared tags to include a result (only with --shared)." default:"1"`
}

func (*TagsCmd) Run

func (c *TagsCmd) Run(globals *Globals) error

type VersionCmd

type VersionCmd struct {
	// Writer allows overriding destination for testing (defaults to os.Stdout)
	Writer io.Writer `kong:"-"`
}

VersionCmd prints version information.

func (*VersionCmd) Run

func (c *VersionCmd) Run(globals *Globals) error

Run executes the version command.

Jump to

Keyboard shortcuts

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