Skip to content
Draft
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
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3
github.com/hexops/gotextdiff v1.0.3
github.com/manifoldco/promptui v0.9.0
github.com/mark3labs/mcp-go v0.46.0
github.com/mergestat/timediff v0.0.4
github.com/pkg/errors v0.9.1
github.com/schollz/progressbar/v3 v3.19.0
Expand All @@ -20,6 +21,7 @@ require (
github.com/stretchr/testify v1.11.1
github.com/urfave/cli/v2 v2.3.0
golang.org/x/crypto v0.46.0
golang.org/x/term v0.38.0
google.golang.org/grpc v1.74.2
google.golang.org/protobuf v1.36.11
)
Expand All @@ -34,24 +36,24 @@ require (
github.com/go-fed/httpsig v1.1.0 // indirect
github.com/google/go-github/v74 v74.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
github.com/hashicorp/go-version v1.8.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
gitlab.com/gitlab-org/api/client-go v1.9.1 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect
Expand Down
19 changes: 12 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creativeprojects/go-selfupdate v1.5.2 h1:3KR3JLrq70oplb9yZzbmJ89qRP78D1AN/9u+l3k0LJ4=
github.com/creativeprojects/go-selfupdate v1.5.2/go.mod h1:BCOuwIl1dRRCmPNRPH0amULeZqayhKyY2mH/h4va7Dk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -28,6 +27,8 @@ github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454Wv
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
Expand All @@ -43,6 +44,8 @@ github.com/google/go-github/v74 v74.0.0 h1:yZcddTUn8DPbj11GxnMrNiAnXH14gNs559AsU
github.com/google/go-github/v74 v74.0.0/go.mod h1:ubn/YdyftV80VPSI26nSJvaEsTOnsjrxG3o9kJhcyak=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 h1:B+8ClL/kCQkRiU82d9xajRPKYMrB7E0MbtzWVi1K4ns=
Expand All @@ -58,16 +61,17 @@ github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
github.com/mark3labs/mcp-go v0.46.0 h1:8KRibF4wcKejbLsHxCA/QBVUr5fQ9nwz/n8lGqmaALo=
github.com/mark3labs/mcp-go v0.46.0/go.mod h1:JKTC7R2LLVagkEWK7Kwu7DbmA6iIvnNAod6yrHiQMag=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand All @@ -87,7 +91,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
Expand All @@ -100,6 +103,8 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -109,6 +114,8 @@ github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
gitlab.com/gitlab-org/api/client-go v1.9.1 h1:tZm+URa36sVy8UCEHQyGGJ8COngV4YqMHpM6k9O5tK8=
gitlab.com/gitlab-org/api/client-go v1.9.1/go.mod h1:71yTJk1lnHCWcZLvM5kPAXzeJ2fn5GjaoV8gTOPd4ME=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
Expand Down Expand Up @@ -162,10 +169,8 @@ google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeB
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
10 changes: 9 additions & 1 deletion tdl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ var app = &cli.App{
Aliases: []string{"d"},
Usage: "running in non-interactive mode",
},
&cli.IntFlag{
Name: "mcp-port",
Usage: "port for MCP server on 127.0.0.1 (0 to disable)",
Value: 39131,
EnvVars: []string{"TDL_MCP_PORT"},
},
},
Action: func(c *cli.Context) error {
err := newHandlers(c).Run(c.Context, c.Bool("detached"))
Expand Down Expand Up @@ -416,6 +422,8 @@ func newHandlers(c *cli.Context) *trainings.Handlers {
cmd = c.Command.FullName()
}

mcpPort := c.Int("mcp-port")

return trainings.NewHandlers(trainings.CliMetadata{
Version: version,
Commit: commit,
Expand All @@ -426,7 +434,7 @@ func newHandlers(c *cli.Context) *trainings.Handlers {
GitVersion: gitVersionString(),
ExecutedCommand: cmd,
Interactive: internal.IsStdinTerminal(),
})
}, mcpPort)
}

func osVersion() string {
Expand Down
10 changes: 6 additions & 4 deletions trainings/config/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
)

type GlobalConfig struct {
Token string `toml:"token"`
ServerAddr string `toml:"server_addr"`
Region string `toml:"region"`
Insecure bool `toml:"insecure"`
Token string `toml:"token"`
ServerAddr string `toml:"server_addr"`
Region string `toml:"region"`
Insecure bool `toml:"insecure"`
MCPConfigured bool `toml:"mcp_configured,omitempty"`
MCPEnabled bool `toml:"mcp_enabled,omitempty"`
}

func globalConfigPath() string {
Expand Down
30 changes: 23 additions & 7 deletions trainings/config/training.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@ import (
const trainingConfigFile = ".tdl-training"

type TrainingConfig struct {
TrainingName string `toml:"training_name"`
GitConfigured bool `toml:"git_configured,omitempty"`
GitEnabled bool `toml:"git_enabled,omitempty"`
GitAutoCommit bool `toml:"git_auto_commit,omitempty"`
GitAutoGolden bool `toml:"git_auto_sync,omitempty"`
GitGoldenMode string `toml:"git_sync_mode,omitempty"` // "compare" | "merge" | "override"
GitUnavailable bool `toml:"git_unavailable,omitempty"` // git was missing/too old at init
TrainingName string `toml:"training_name"`
GitConfigured bool `toml:"git_configured,omitempty"`
GitEnabled bool `toml:"git_enabled,omitempty"`
GitAutoCommit bool `toml:"git_auto_commit,omitempty"`
GitAutoGolden bool `toml:"git_auto_sync,omitempty"`
GitGoldenMode string `toml:"git_sync_mode,omitempty"` // "compare" | "merge" | "override"
GitUnavailable bool `toml:"git_unavailable,omitempty"` // git was missing/too old at init
ClaudeMdHash string `toml:"claude_md_hash,omitempty"` // deprecated: migrated to FileHashes
FileHashes map[string]string `toml:"file_hashes,omitempty"`
}

// MigrateHashes moves the deprecated ClaudeMdHash into the FileHashes map
// and ensures the map is initialized.
func (c *TrainingConfig) MigrateHashes() {
if c.FileHashes == nil {
c.FileHashes = make(map[string]string)
}
if c.ClaudeMdHash != "" && c.FileHashes["CLAUDE.md"] == "" {
c.FileHashes["CLAUDE.md"] = c.ClaudeMdHash
c.ClaudeMdHash = ""
}
}

func (c Config) WriteTrainingConfig(config TrainingConfig, trainingRootFs afero.Fs) error {
Expand All @@ -39,6 +53,8 @@ func (c Config) TrainingConfig(trainingRootFs afero.Fs) TrainingConfig {
panic(errors.Wrapf(err, "can't decode training config: %s", string(b)))
}

config.MigrateHashes()

logrus.WithField("training_config", config).Debug("Training config")

return config
Expand Down
17 changes: 11 additions & 6 deletions trainings/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ func (h *Handlers) ConfigureGlobally(ctx context.Context, token, serverAddr, reg
region = resp.Region
}

return h.config.WriteGlobalConfig(config.GlobalConfig{
Token: token,
ServerAddr: serverAddr,
Region: region,
Insecure: insecure,
})
// Read existing config to preserve MCP settings (and any future fields).
// ConfiguredGlobally() check: on first-ever configure, there's no file yet.
var globalCfg config.GlobalConfig
if h.config.ConfiguredGlobally() {
globalCfg = h.config.GlobalConfig()
}
globalCfg.Token = token
globalCfg.ServerAddr = serverAddr
globalCfg.Region = region
globalCfg.Insecure = insecure
return h.config.WriteGlobalConfig(globalCfg)
}
6 changes: 3 additions & 3 deletions trainings/files/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (f Files) shouldWriteAllFiles(fs afero.Fs, exerciseDir string, filesToCreat

edits := myers.ComputeEdits(span.URIFromPath("local "+filePath), string(localContent), externalContent)
diff := fmt.Sprint(gotextdiff.ToUnified("local "+relPath, "remote "+relPath, string(localContent), edits))
_, _ = fmt.Fprintln(f.stdout, colorDiff(diff))
_, _ = fmt.Fprintln(f.stdout, ColorDiff(diff))
}
}

Expand Down Expand Up @@ -339,7 +339,7 @@ func (f Files) shouldWriteFile(fs afero.Fs, filePath string, file *genproto.File

edits := myers.ComputeEdits(span.URIFromPath("local "+filepath.Base(file.Path)), string(actualContent), file.Content)
diff := fmt.Sprint(gotextdiff.ToUnified("local "+filepath.Base(file.Path), "remote "+filepath.Base(file.Path), string(actualContent), edits))
_, _ = fmt.Fprintln(f.stdout, colorDiff(diff))
_, _ = fmt.Fprintln(f.stdout, ColorDiff(diff))

if !internal.FConfirmPrompt("Should it be overridden?", f.stdin, f.stdout) {
_, _ = fmt.Fprintln(f.stdout, "Skipping file")
Expand All @@ -366,7 +366,7 @@ func DirOrFileExists(fs afero.Fs, path string) bool {
panic(err)
}

func colorDiff(diffText string) string {
func ColorDiff(diffText string) string {
red := color.New(color.FgRed)
green := color.New(color.FgGreen)
yellow := color.New(color.FgYellow)
Expand Down
46 changes: 36 additions & 10 deletions trainings/git_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package trainings

import (
"fmt"
"os"

"github.com/fatih/color"
"github.com/pkg/errors"

"github.com/ThreeDotsLabs/cli/internal"
)

// ConfigureGit lets users change git integration settings for the current training.
// ConfigureGit lets users change git and MCP settings for the current training.
func (h *Handlers) ConfigureGit() error {
trainingRoot, err := h.config.FindTrainingRoot()
if err != nil {
Expand All @@ -22,22 +25,45 @@ func (h *Handlers) ConfigureGit() error {
if !cfg.GitConfigured || !cfg.GitEnabled {
fmt.Println("Git integration is not enabled for this training.")
fmt.Println("To enable it, reinitialize with: " + color.CyanString("tdl training init"))
return nil
}
} else {
fmt.Printf("Current settings for %s:\n", color.CyanString(cfg.TrainingName))
fmt.Printf(" Auto-commit: %s\n", formatBool(cfg.GitAutoCommit))
fmt.Printf(" Auto-sync: %s\n\n", formatBool(cfg.GitAutoGolden))

fmt.Printf("Current settings for %s:\n", color.CyanString(cfg.TrainingName))
fmt.Printf(" Auto-commit: %s\n", formatBool(cfg.GitAutoCommit))
fmt.Printf(" Auto-sync: %s\n\n", formatBool(cfg.GitAutoGolden))
autoCommit, autoGolden := promptGitPreferences()

autoCommit, autoGolden := promptGitPreferences()

cfg.GitAutoCommit = autoCommit
cfg.GitAutoGolden = autoGolden
cfg.GitAutoCommit = autoCommit
cfg.GitAutoGolden = autoGolden
}

if err := h.config.WriteTrainingConfig(cfg, trainingRootFs); err != nil {
return errors.Wrap(err, "can't update training config")
}

// MCP settings (stored in global config)
globalCfg := h.config.GlobalConfig()

fmt.Println()
fmt.Printf("Current MCP server setting: %s\n", formatBool(globalCfg.MCPEnabled))
fmt.Println("MCP server lets AI coding tools (Claude Code, Cursor, etc.) run exercises for you.")
fmt.Println()

mcpPrompt := internal.Prompt(
internal.Actions{
{Shortcut: '\n', Action: "enable MCP server", ShortcutAliases: []rune{'\r'}},
{Shortcut: 'n', Action: "disable MCP server"},
},
os.Stdin,
os.Stdout,
)
globalCfg.MCPConfigured = true
globalCfg.MCPEnabled = mcpPrompt == '\n'
fmt.Println()

if err := h.config.WriteGlobalConfig(globalCfg); err != nil {
return errors.Wrap(err, "can't update global config")
}

fmt.Println(color.GreenString("Settings updated."))
return nil
}
Expand Down
Loading