Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ The CLI reads config from multiple sources with this priority:

`FIZZY_ACCOUNT` is accepted as a deprecated alias for `FIZZY_PROFILE`.

**Local config trust.** A `.fizzy.yaml` is found by walking up from the working
directory, so a cloned repo can supply one. Its `account` and `board` apply without
trust. Its `api_url` and `token` decide where a credential is sent and which one, so
`config.LoadLocal` (`internal/config/trust.go`) drops them and lists them in `Ignored`,
and `config.Load` prints the warning, unless `fizzy config trust` recorded a digest of
those two values that still matches. Anything that reads the local file for its settings
goes through `LoadLocal`, never around it, and a new key that can redirect or replace a
credential joins `trustDigest`.

**`--board` is command-scoped, not global.** `fizzy --board X ...` fails with
`unknown flag`; it is declared per-command, by nineteen of them across the activity,
board, card, column and webhook groups. So `fizzy card list --board X` works while
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ Configuration priority (highest to lowest):

`FIZZY_ACCOUNT` is accepted as a deprecated alias for `FIZZY_PROFILE`.

A local `.fizzy.yaml` sets the account and the board. Its `api_url` and `token` decide
where your credentials are sent, so they are ignored, with a warning, until you trust the
file: read it, then run `fizzy config trust` in that directory. Trust covers those two
settings as they are: if either changes, as a pull can change them, the file needs trusting
again. `fizzy setup` trusts the local file it writes, and `fizzy config untrust` removes
the trust.

Profiles created by `fizzy setup` use the account slug as their name and continue to work without changes. A profile can also use a distinct name by storing its account in the profile's `extra` settings. This supports separate credentials for multiple users of the same account:

```bash
Expand Down
34 changes: 34 additions & 0 deletions SURFACE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ARG fizzy comment attachments help 00 [command]
ARG fizzy comment help 00 [command]
ARG fizzy completion 00 [bash|zsh|fish|powershell]
ARG fizzy config help 00 [command]
ARG fizzy config trust 00 [path]
ARG fizzy config untrust 00 [path]
ARG fizzy help 00 [command]
ARG fizzy identity help 00 [command]
ARG fizzy migrate help 00 [command]
Expand Down Expand Up @@ -138,6 +140,8 @@ CMD fizzy config
CMD fizzy config explain
CMD fizzy config help
CMD fizzy config show
CMD fizzy config trust
CMD fizzy config untrust
CMD fizzy config view
CMD fizzy doctor
CMD fizzy help
Expand Down Expand Up @@ -1897,6 +1901,34 @@ FLAG fizzy config show --quiet type=bool
FLAG fizzy config show --styled type=bool
FLAG fizzy config show --token type=string
FLAG fizzy config show --verbose type=bool
FLAG fizzy config trust --agent type=bool
FLAG fizzy config trust --api-url type=string
FLAG fizzy config trust --count type=bool
FLAG fizzy config trust --help type=bool
FLAG fizzy config trust --ids-only type=bool
FLAG fizzy config trust --jq type=string
FLAG fizzy config trust --json type=bool
FLAG fizzy config trust --limit type=int
FLAG fizzy config trust --markdown type=bool
FLAG fizzy config trust --profile type=string
FLAG fizzy config trust --quiet type=bool
FLAG fizzy config trust --styled type=bool
FLAG fizzy config trust --token type=string
FLAG fizzy config trust --verbose type=bool
FLAG fizzy config untrust --agent type=bool
FLAG fizzy config untrust --api-url type=string
FLAG fizzy config untrust --count type=bool
FLAG fizzy config untrust --help type=bool
FLAG fizzy config untrust --ids-only type=bool
FLAG fizzy config untrust --jq type=string
FLAG fizzy config untrust --json type=bool
FLAG fizzy config untrust --limit type=int
FLAG fizzy config untrust --markdown type=bool
FLAG fizzy config untrust --profile type=string
FLAG fizzy config untrust --quiet type=bool
FLAG fizzy config untrust --styled type=bool
FLAG fizzy config untrust --token type=string
FLAG fizzy config untrust --verbose type=bool
FLAG fizzy config view --agent type=bool
FLAG fizzy config view --api-url type=string
FLAG fizzy config view --count type=bool
Expand Down Expand Up @@ -3463,6 +3495,8 @@ SUB fizzy config
SUB fizzy config explain
SUB fizzy config help
SUB fizzy config show
SUB fizzy config trust
SUB fizzy config untrust
SUB fizzy config view
SUB fizzy doctor
SUB fizzy help
Expand Down
103 changes: 99 additions & 4 deletions internal/commands/config_cmd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package commands

import (
"errors"
"fmt"
"os"
"sort"
Expand Down Expand Up @@ -93,10 +94,88 @@ from flags, environment variables, profile settings, local config, and global co
},
}

var configTrustCmd = &cobra.Command{
Use: "trust [path]",
Short: "Trust a local config's api_url and token",
Long: `Trust the api_url and token in a local config (.fizzy.yaml), so they apply.

A local config sets the account and the board without trust. Its api_url and
token decide where your credentials are sent, so they are ignored until you
trust the file. Trust covers those two settings as they are now: if either
changes, as a pull or a checkout can change them, the file is untrusted again.

Without a path, trusts the nearest .fizzy.yaml, in this directory or a parent.
Read the file first.`,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
entry, err := cfgpkg.TrustLocal(firstArg(args))
if err != nil {
return localTrustError(err)
}
printDetail(map[string]any{"path": entry.Path, "trusted": true}, "Trusted "+cfgpkg.DisplayPath(entry.Path), []Breadcrumb{
breadcrumb("show", "fizzy config show", "Show the effective config"),
breadcrumb("untrust", "fizzy config untrust", "Remove the trust"),
})
return nil
},
}

var configUntrustCmd = &cobra.Command{
Use: "untrust [path]",
Short: "Remove trust from a local config",
Long: `Remove trust from a local config (.fizzy.yaml), so its api_url and token are ignored again.

Without a path, untrusts the nearest .fizzy.yaml, in this directory or a parent.`,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
path, removed, err := cfgpkg.UntrustLocal(firstArg(args))
Comment thread
robzolkos marked this conversation as resolved.
Resolved
if err != nil {
return localTrustError(err)
}
summary := "Removed trust from " + cfgpkg.DisplayPath(path)
if !removed {
summary = cfgpkg.DisplayPath(path) + " was not trusted"
}
printDetail(map[string]any{"path": path, "trusted": false}, summary, []Breadcrumb{
breadcrumb("trust", "fizzy config trust", "Trust it again"),
})
return nil
},
}

// localTrustError tells a request that names no usable file, which is the
// caller's to fix, from a failure to read or write, which is not.
func localTrustError(err error) error {
switch {
case errors.Is(err, cfgpkg.ErrNoLocalConfig):
return &output.Error{Code: output.CodeUsage, Message: err.Error()}
case errors.Is(err, os.ErrNotExist):
return &output.Error{Code: output.CodeNotFound, Message: err.Error()}
default:
return &output.Error{Code: output.CodeAPI, Message: err.Error()}
}
}

// isLocalTrustCommand reports whether cmd only changes local trust records,
// so it runs whatever the profile, account and token settings are.
func isLocalTrustCommand(cmd *cobra.Command) bool {
return cmd.Name() != "" && cmd.Parent() != nil && cmd.Parent().Name() == "config" &&
(cmd.Name() == "trust" || cmd.Name() == "untrust")
}

func firstArg(args []string) string {
if len(args) == 0 {
return ""
}
return args[0]
}

func init() {
rootCmd.AddCommand(configCmd)
configCmd.AddCommand(configShowCmd)
configCmd.AddCommand(configExplainCmd)
configCmd.AddCommand(configTrustCmd)
configCmd.AddCommand(configUntrustCmd)
}

func configShowData(verbose bool) map[string]any {
Expand Down Expand Up @@ -150,7 +229,23 @@ func configShowData(verbose bool) map[string]any {
func configExplainData() map[string]any {
eff := resolveDoctorEffectiveConfig()
globalCfg, _ := loadDoctorConfigFile(globalConfigPathForDoctor())
localCfg, _ := loadDoctorConfigFile(cfgpkg.LocalConfigPath())
localCfg := appliedLocalConfig()
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
localAPIURL := unsetString(fieldValue(localCfg, func(c *cfgpkg.Config) string { return c.APIURL }))
localToken := configuredString(localCfg != nil && localCfg.Token != "", "configured in local config")
if local := cfgpkg.LoadLocal(); local != nil {
// What an untrusted file sets is shown, as ignored, so the reader sees
// why another source applies.
if raw, err := loadDoctorConfigFile(local.Path); err == nil {
for _, key := range local.Ignored {
switch key {
case "api_url":
localAPIURL = cfgpkg.DisplayPath(raw.APIURL) + " (ignored: the file is not trusted)"
case "token":
localToken = "ignored: the file is not trusted"
}
}
}
}
resolvedProfile, profileCfg := resolveDoctorProfileContext()
_, defaultProfile := profileStoreInfo()
binding, _ := resolveProfileAccountBinding(resolvedProfile, profileCfg)
Expand Down Expand Up @@ -192,8 +287,8 @@ func configExplainData() map[string]any {
Candidates: []configExplainCandidate{
{Source: "flag --api-url", Value: unsetString(cfgAPIURL), Selected: eff.APIURLSource == "flag --api-url"},
{Source: "env FIZZY_API_URL", Value: unsetString(strings.TrimSpace(getEnv("FIZZY_API_URL"))), Selected: eff.APIURLSource == "env FIZZY_API_URL"},
{Source: profileSourceLabel(resolvedProfile, eff.ProfileName), Value: unsetString(profileBaseURL(profileCfg)), Selected: eff.APIURLSource == "profile store"},
{Source: "local config", Value: unsetString(fieldValue(localCfg, func(c *cfgpkg.Config) string { return c.APIURL })), Selected: eff.APIURLSource == "local config"},
{Source: profileSourceLabel(resolvedProfile, eff.ProfileName), Value: unsetString(firstNonEmpty(profileBaseURL(profileCfg), accountProfileBaseURL(allProfilesForDoctor()))), Selected: eff.APIURLSource == "profile store"},
{Source: "local config", Value: localAPIURL, Selected: eff.APIURLSource == "local config"},
{Source: "global config", Value: unsetString(fieldValue(globalCfg, func(c *cfgpkg.Config) string { return c.APIURL })), Selected: eff.APIURLSource == "global config"},
{Source: "default", Value: cfgpkg.DefaultAPIURL, Selected: eff.APIURLSource == "default"},
},
Expand All @@ -218,7 +313,7 @@ func configExplainData() map[string]any {
{Source: "flag --token", Value: configuredString(cfgToken != "", "configured via flag"), Selected: eff.TokenSourceRaw == "flag"},
{Source: "env FIZZY_TOKEN", Value: configuredString(strings.TrimSpace(getEnv("FIZZY_TOKEN")) != "", "configured in environment"), Selected: eff.TokenSourceRaw == "env"},
{Source: profileTokenSourceLabel(resolvedProfile, eff.ProfileName), Value: configuredString(profileToken != "", profileCredentialValue(eff.TokenSourceRaw, profileToken != "")), Selected: eff.TokenSourceRaw == "keyring" || eff.TokenSourceRaw == "fallback-file" || eff.TokenSourceRaw == "legacy-keyring" || eff.TokenSourceRaw == "legacy-fallback"},
{Source: "local config", Value: configuredString(localCfg != nil && localCfg.Token != "", "configured in local config"), Selected: eff.TokenSourceRaw == "local-config"},
{Source: "local config", Value: localToken, Selected: eff.TokenSourceRaw == "local-config"},
{Source: "global config", Value: configuredString(globalCfg != nil && globalCfg.Token != "", "configured in global config"), Selected: eff.TokenSourceRaw == "global-config"},
},
}
Expand Down
Loading
Loading