cmd

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 37 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ExitOK          = 0
	ExitError       = 1
	ExitUsage       = 2
	ExitNotSignedIn = 3 // run treecli connect (or login)
	ExitSpending    = 4 // price cap, daily spending limit, or billing
	ExitNotFound    = 5
	ExitRateLimited = 6
)

Stable exit codes, so agents and scripts can branch without parsing text.

View Source
const BashCompletionPrelude = `` /* 1006-byte string literal not displayed */

Variables

View Source
var AccountCmd = newAccountCommand()
View Source
var ActionCmd = &cobra.Command{
	Use:   "action <ai-action-or-invocation> [prompt...]",
	Short: "Create an AI action post or reply and wait for generated media",
	Long:  "Create an AI action root thread or reply, then poll the submitted answer until media generation completes, fails, or times out.\n\nRun `treecli action actions` to see the current model-backed AI actions.\n\nUse --duration to request a specific audio or video length in seconds; the backend clamps it to the model's allowed range.",
	Example: "  treecli action flux \"a red kite over Bangkok\"\n" +
		"  treecli action !kling \"camera orbit around a bonsai tree\"\n" +
		"  treecli action \"!veo3 slow dolly through a neon alley\"\n" +
		"  treecli action eleven_tts \"read this in a crisp narration voice\"\n" +
		"  treecli action sfx \"rain, tires on wet asphalt, distant thunder\"\n" +
		"  treecli action !stableaudio \"ambient build, 120 BPM\" --duration 90\n" +
		"  treecli action --reply-to 7a5e85c9-9dca-4140-ba9a-f5db0030afca flux \"make this warmer\"\n" +
		"  treecli action --reply-to http://localhost:5173/quest/7a5e85c9-9dca-4140-ba9a-f5db0030afca flux \"make this warmer\"",
	Args:              cobra.MinimumNArgs(1),
	RunE:              runAction,
	ValidArgsFunction: completeActionArgs,
}
View Source
var AppHostOverride string
View Source
var BackendURLOverride string
View Source
var BillingCmd = &cobra.Command{
	Use:   "billing",
	Short: "Manage AI usage billing (USD via Stripe, or BSV via a local wallet)",
	Long: `Manage how Treechat charges you for AI usage.

Two lanes:
  USD  Stripe card on file, charged pay-as-you-go. Account-tied: requires
       ` + "`treecli login`" + `. See: billing checkout | status | mode | sync.
  BSV  A local treechat-style wallet pays directly from its balance. No login
       required. See: billing wallet new | import | address.`,
}

BillingCmd is the parent for both billing lanes:

  • USD (Stripe): account-tied, requires `treecli login`.
  • BSV: a local wallet pays directly, no login required (see `billing wallet`).
View Source
var BranchReplyCmd = newPostReplyCommand(true)
View Source
var ConnectCmd = &cobra.Command{
	Use:   "connect",
	Short: "Connect treecli to your Treechat account in the browser (sign up, sign in, card billing)",
	Long: "Connect treecli to a Treechat account without typing a password into the terminal.\n\n" +
		"treecli shows a short code and opens a Treechat page. There you sign in or create an account " +
		"(email, Google or X), check the code, allow access, and can add a card for pay-as-you-go AI " +
		"generation. treecli waits, then saves a connection that renews itself.",
	Example: "  treecli connect\n  treecli connect --no-browser\n  treecli --env staging --account bot connect",
	Args:    cobra.NoArgs,
	RunE:    runConnect,
}
View Source
var CurrentVersion = "dev"

CurrentVersion is replaced by the release workflow. Dev builds keep "dev".

View Source
var GenerateCmd = &cobra.Command{
	Use:   "generate <ai-action> [prompt...]",
	Short: "Generate AI media directly and download it locally (never creates a post)",
	Long: "Generate AI media through the direct generation API and save it to a local file.\n\n" +
		"Set --max-price-cents for each action. An idempotency key is generated when --id is omitted; reuse the printed key on retries. The shared backend enforces the action cap and connected application rolling 24-hour budget.\n" +
		"Use `treecli billing budget` to inspect the daily cap and next capacity release. --quote is an optional preview.\n\n" +
		"This charges your account (USD/BSV) and NEVER touches the posting infra — no Answer, " +
		"no Quest, no thread, nothing on your feed.\n\n" +
		"Pass arbitrary model inputs with repeatable --input key=value (values are parsed as JSON " +
		"when possible, else treated as a string). Use @path in --input values to upload local " +
		"images, video, or audio before generation. Chain generations or steer a model with " +
		"--reference (run:<id> reuses a prior generation's output as the model's reference; " +
		"@path uploads a local file; a public URL is passed through). Music models accept " +
		"--instrumental and --duration. Use --payment usd or --payment bsv to choose the " +
		"payment rail for this generation; omit it to use your account default.\n\n" +
		"Run `treecli generate actions --verbose` or `treecli generate describe <ai-action>` " +
		"to see available AI actions, descriptions, settings, and examples.",
	Example: "  treecli generate flux2 \"wide hero banner\" --out banner.webp --max-price-cents 100 --id banner-001\n" +
		"  treecli generate topazimg --reference @photo.jpg --out photo-4x.jpg --max-price-cents 100 --id upscale-001\n" +
		"  treecli generate suno \"ambient build\" --duration 20 --quote --max-price-cents 100\n" +
		"  treecli generate suno \"Song title\" --reference @song.mp3 --input replace_start_s=84 --input replace_end_s=96 \\\n" +
		"      --input lyrics=\"new lines\" --input full_lyrics=\"$(cat lyrics.txt)\" --duration 210 --out fixed.mp3 --max-price-cents 100\n" +
		"  treecli generate --quote-id REVIEWED_QUOTE_ID --id music-001 --out music.mp3\n" +
		"  treecli billing budget\n" +
		"  treecli generate describe flux2",
	Args: func(command *cobra.Command, args []string) error {
		if generateQuoteID != "" {
			return nil
		}
		return cobra.MinimumNArgs(1)(command, args)
	},
	RunE:              runGenerate,
	ValidArgsFunction: completeGenerateArgs,
}

GenerateCmd generates AI media via the direct (post-less) API and saves it locally.

View Source
var GetCmd = &cobra.Command{
	Use:   "get",
	Short: "Get information about various resources",
	Long:  `Fetch and display information about threads, answers, or other resources.`,
}
View Source
var LoginCmd = &cobra.Command{
	Use:   "login",
	Short: "Log in to your account",
	Long:  `Authenticate and log in to your tree account to access protected features.`,
	RunE:  runLogin,
}

LoginCmd represents the login command

View Source
var MCPCmd = newMCPCommand()
View Source
var NewCmd = &cobra.Command{
	Use:   "new",
	Short: "Create new resources",
	Long:  `Create new resources such as posts, clips or channels.`,
}
View Source
var OnboardCmd = &cobra.Command{
	Use:   "onboard",
	Short: "Check setup status and get next steps for humans and agents",
	Long: `Show treecli setup status and the next steps to finish onboarding.

The bare command prints a checklist: selected environment and account, login state, whether this
directory's agent instruction files (AGENTS.md / CLAUDE.md) carry the treecli
guidance block, and which packaged skills are installed.

Subcommands:
  agents  Print or install the AGENTS.md/CLAUDE.md guidance block
  guide   Print the full onboarding guide document`,
	Example: `  treecli onboard                      # setup checklist with next steps
  treecli onboard --json               # machine-readable status
  treecli onboard agents --write       # install/update the guidance block in AGENTS.md
  treecli onboard agents --check       # verify the guidance block is present and current
  treecli onboard guide                # full onboarding guide document`,
	Args: cobra.NoArgs,
	RunE: runOnboard,
}
View Source
var ProfileCmd = &cobra.Command{
	Use:   "profile",
	Short: "Deprecated: inspect legacy profiles; use account commands",
	Long:  `List, inspect, and switch the saved treecli profiles.`,
}
View Source
var QuoteReplyCmd = newPostReplyCommand(false)
View Source
var ReferenceManifestCmd = &cobra.Command{
	Use:    "export-reference-manifest",
	Hidden: true,
	Args:   cobra.NoArgs,
	RunE: func(command *cobra.Command, args []string) error {
		revision, _ := command.Flags().GetString("source-revision")
		if !regexp.MustCompile(`^[0-9a-f]{40}$`).MatchString(revision) {
			return usageErrorf("--source-revision must be a full source commit SHA")
		}
		skills, err := treeclicontent.ListPackagedSkills()
		if err != nil {
			return err
		}
		records := make([]map[string]string, 0, len(skills))
		for _, skill := range skills {
			records = append(records, map[string]string{"key": skill.Key, "name": skill.Name, "description": skill.Description, "skill_md": skill.SkillMD, "openai_yaml": skill.OpenAIYAML})
		}
		long, err := treeclicontent.OnboardLong()
		if err != nil {
			return err
		}
		short, err := treeclicontent.OnboardShort()
		if err != nil {
			return err
		}
		guideLong, err := treeclicontent.BuildOnboardContent("long")
		if err != nil {
			return err
		}
		guideShort, err := treeclicontent.BuildOnboardContent("short")
		if err != nil {
			return err
		}
		root := command.Root()
		root.InitDefaultCompletionCmd()
		completions := map[string]string{}
		plainCompletions := map[string]string{}
		for _, shell := range []string{"bash", "zsh", "fish", "powershell"} {
			for _, plain := range []bool{false, true} {
				var output bytes.Buffer
				err = RenderCompletion(root, shell, &output, plain)
				if err != nil {
					return err
				}
				if plain {
					plainCompletions[shell] = output.String()
				} else {
					completions[shell] = output.String()
				}
			}
		}

		manifest := map[string]interface{}{"schema_version": 1, "source_revision": revision, "skills": records, "onboard": map[string]interface{}{"agents": map[string]string{"short": short, "long": long}, "guide": map[string]string{"short": guideShort, "long": guideLong}}, "completion": completions, "completion_no_descriptions": plainCompletions, "commands": referenceCommandInventory(root)}
		encoder := json.NewEncoder(command.OutOrStdout())
		encoder.SetIndent("", "  ")
		return encoder.Encode(manifest)
	},
}

ReferenceManifestCmd exports generated MCP resources from the CLI's canonical embedded content and the fully registered command tree. No profiles are read.

View Source
var SelectedEnvironment, SelectedAccount string
View Source
var SelectedProfile string
View Source
var SignupCmd = &cobra.Command{
	Use:   "signup",
	Short: "Create an account",
	Long:  `Create a Treechat account interactively and save its authenticated profile.`,
	Args:  cobra.NoArgs,
	RunE:  runSignup,
}

SignupCmd represents the signup command.

View Source
var SkillsCmd = &cobra.Command{
	Use:   "skills",
	Short: "List, emit, and install packaged treecli skills",
}
View Source
var ToolsCmd = newToolsCommand()
View Source
var UpdateCmd = &cobra.Command{
	Use:   "update [version]",
	Short: "Update treecli to the latest release",
	Long: "Download a treecli GitHub Release archive, verify it against checksums.txt, " +
		"and replace the current CLI binary.\n\n" +
		"Without a version argument, treecli installs the latest published release. Pass a " +
		"specific tag such as v0.1.2 to install that release instead. Self-update currently " +
		"supports macOS and Linux release archives.",
	Example: "  treecli update\n" +
		"  treecli update --check\n" +
		"  treecli update v0.1.2\n" +
		"  treecli update --install-dir ~/.local/bin",
	Args: cobra.MaximumNArgs(1),
	RunE: runUpdate,
}
View Source
var WhoamiCmd = newWhoamiCommand()

Functions

func ConfigureAccountSelection added in v0.2.9

func ConfigureAccountSelection(command *cobra.Command, args []string) error

ConfigureAccountSelection keeps the legacy interface explicit. Old saved active_profile values never redirect a new invocation away from production.

func ExitCode added in v0.2.15

func ExitCode(err error) int

ExitCode maps an error to one of the stable exit codes.

func PrepareCommand added in v0.2.15

func PrepareCommand(command *cobra.Command, args []string) error

PrepareCommand runs before every command: it turns on --json for commands that have it when output is piped, then applies account selection.

func PrintError added in v0.2.10

func PrintError(writer io.Writer, err error)

PrintError reports err on stderr: JSON for agents (with the exit code), text for people. Structured write errors keep their write ID either way.

func RenderCompletion added in v0.2.13

func RenderCompletion(root *cobra.Command, shell string, out io.Writer, noDescriptions bool) error

RenderCompletion is shared by shell emission and generated hosted resources.

Types

This section is empty.

Jump to

Keyboard shortcuts

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