cmd

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 21 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"`
}

func (*BacklinksCmd) Run

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

type BoostedCmd

type BoostedCmd struct {
	Query string  `arg:"" help:"Search query"`
	Limit int     `help:"maximum number of results to return" default:"10"`
	Seed  string  `help:"seed note for graph-based score boosting" required:"true"`
	Boost float64 `help:"multiplier applied to graph-connected results" 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:"Traverse graph connections"`
	Hidden      HiddenCmd      `cmd:"" help:"Discover hidden semantic links between unlinked notes"`
	Tags        TagsCmd        `cmd:"" help:"Find notes sharing common tags"`
	Boosted     BoostedCmd     `cmd:"" help:"Graph-boosted semantic search"`
	Stats       StatsCmd       `cmd:"" help:"Show collection statistics"`
	Get         GetCmd         `cmd:"" help:"Fetch complete note content by slug or path"`
	Reset       ResetCmd       `cmd:"" help:"Reset the ChromaDB collections"`
	Version     VersionCmd     `cmd:"" help:"Show version information"`
}

CLI is the top-level Kong command tree.

type ConnectionsCmd

type ConnectionsCmd struct {
	Note string `arg:"" help:"Note slug"`
	Hops int    `help:"maximum number of graph hops to traverse" default:"2"`
}

func (*ConnectionsCmd) Run

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

type GetCmd

type GetCmd struct {
	Slug string `arg:"" help:"Note slug or file path to retrieve"`
}

func (*GetCmd) Run

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

type Globals

type Globals struct {
	ChromaPath      string           `help:"path to ChromaDB persistent storage" default:"~/.notebrain/chroma"`
	VaultPath       string           `name:"vault-path" help:"Obsidian vault path (also used as vault name fallback)"`
	VaultName       string           `name:"vault-name" help:"Obsidian vault name (for URI links, defaults to basename of vault-path)"`
	Verbose         bool             `help:"enable verbose output"`
	NoHyperlinks    bool             `help:"Disable OSC 8 terminal hyperlinks in output"`
	Format          string           `help:"output format" enum:"text,json,tsv,ndjson" default:"text"`
	JSONPath        string           `name:"jsonpath" help:"extract specific fields from JSON output using a JSONPath expression (e.g. '$.results[0].note_slug')"`
	IncludeText     bool             `help:"include matched chunk text in structured output"`
	ContextWindow   int              `name:"context-window" help:"fetch ±N adjacent chunks around each match for context" default:"0"`
	MinScore        float64          `help:"suppress results below this similarity score (0–1)" default:"0"`
	RespectExclude  bool             `help:"respect Obsidian userIgnoreFilters and attachmentFolderPath settings during ingest" default:"true"`
	UseEditor       bool             `help:"enable external editor ($EDITOR) integration as default open type" default:"false"`
	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 attachment and image links from graph edges" default:"true"`
	SkipPhantom     bool             `name:"skip-phantom" help:"Exclude uncreated notes (phantom links) from results" default:"true"`
	Version         kong.VersionFlag `name:"version" help:"Show version information"`

	// Internal fields, not exposed as flags
	Ctx           context.Context `kong:"-"`
	VersionString 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 {
	Note  string `arg:"" help:"Note slug"`
	Limit int    `help:"maximum number of hidden connections to return" default:"10"`
}

func (*HiddenCmd) Run

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

type IngestCmd

type IngestCmd struct {
	Glob          string `arg:"" optional:"" help:"glob pattern to ingest"`
	Workers       int    `help:"number of concurrent ingestion workers" default:"4"`
	MinChunkWords int    `name:"min-chunk-words" help:"skip chunks with fewer words than this (0 = use default of 10)" default:"0"`
	ChunkSize     int    `name:"chunk-size" help:"maximum runes per chunk for the parser (0 = use default of 800)" default:"0"`
	ChunkOverlap  int    `name:"chunk-overlap" help:"overlap runes between sub-chunks when a section is split (0 = use default of 100)" default:"0"`
}

func (*IngestCmd) Run

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

type ResetCmd

type ResetCmd struct {
}

func (*ResetCmd) Run

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

type SearchCmd

type SearchCmd struct {
	Query       string `arg:"" optional:"" help:"Search query (omit when using --interactive or --tag)"`
	Limit       int    `help:"maximum number of results to return" default:"10"`
	TopKPerNote int    `name:"top-k" help:"maximum number of chunks to return per note" default:"3"`
	Section     string `help:"filter by heading path"`
	Tag         string `help:"filter or search by tag name"`
	HasTasks    bool   `help:"only return chunks that contain task lists"`
	HasCode     bool   `help:"only return chunks that contain code blocks"`
	Interactive bool   `help:"launch live interactive search TUI"`
}

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 {
	Note      string `arg:"" help:"Note slug"`
	MinShared int    `help:"minimum number of shared tags to include a result" 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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