From 4fc7b4b885cf0ebfc21221d77939597348bf368c Mon Sep 17 00:00:00 2001 From: Daylam Tayari Date: Thu, 12 Mar 2026 12:46:37 -0500 Subject: [PATCH 1/3] Implemented source subdir specification --- cmd/skillshare/init.go | 45 +++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/cmd/skillshare/init.go b/cmd/skillshare/init.go index 3c4bc47fc..9503a1365 100644 --- a/cmd/skillshare/init.go +++ b/cmd/skillshare/init.go @@ -12,7 +12,6 @@ import ( "strings" "time" - "golang.org/x/term" "skillshare/internal/config" gitops "skillshare/internal/git" "skillshare/internal/install" @@ -20,6 +19,8 @@ import ( ssync "skillshare/internal/sync" "skillshare/internal/ui" "skillshare/internal/utils" + + "golang.org/x/term" ) const skillshareSkillSource = "github.com/runkids/skillshare/skills/skillshare" @@ -402,18 +403,28 @@ func performFreshInit(opts *initOptions, home string) error { }, } - if opts.dryRun { - summarizeInitConfig(cfg) - } else if err := cfg.Save(); err != nil { - return err - } - // Initialize git in source directory for safety initGitIfNeeded(sourcePath, opts.dryRun, opts.initGit, opts.noGit) // Set up git remote for cross-machine sync setupGitRemote(sourcePath, opts.remoteURL, opts.dryRun) + // Prompt user for subdirectory + subDir := useSourceSubdir() + if subDir != "" { + sourcePath = filepath.Join(sourcePath, subDir) + if err := createSourceDir(sourcePath, opts.dryRun); err != nil { + return err + } + cfg.Source = sourcePath + } + + if opts.dryRun { + summarizeInitConfig(cfg) + } else if err := cfg.Save(); err != nil { + return err + } + // Install built-in skillshare skill (opt-in) installSkillIfNeeded(sourcePath, opts.dryRun, opts.initSkill, opts.noSkill) @@ -1219,6 +1230,26 @@ func tryPullAfterRemoteSetup(sourcePath, remoteURL string) bool { return true } +// Specify a subdirectory to be the source and store the skills +// This allows users to have skills stored in a subdirectory of their repo and not the root +// Returns a string representing the name of the subdirectory, empty if none was selected +func useSourceSubdir() string { + fmt.Println(" Specifying a subdirectory as the source will store skills in the subdirectory (e.g. skills/) instead of in the root") + fmt.Println() + fmt.Print(" Specify a subdirectory as the source (e.g. skills)? [y/N]: ") + var input string + fmt.Scanln(&input) + input = strings.ToLower(strings.TrimSpace(input)) + + if input == "y" || input == "yes" { + fmt.Print(" Enter subdirectory name: ") + var dirNameInput string + fmt.Scanln(&dirNameInput) + return strings.TrimSpace(dirNameInput) + } + return "" +} + const fallbackSkillContent = `--- name: skillshare description: Manage and sync skills across AI CLI tools From 06dae1c34fa9ebb4cb6ea710689d0a72cc4040aa Mon Sep 17 00:00:00 2001 From: Daylam Tayari Date: Thu, 12 Mar 2026 12:53:17 -0500 Subject: [PATCH 2/3] Added new line for spacing in prompts --- cmd/skillshare/init.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/skillshare/init.go b/cmd/skillshare/init.go index 9503a1365..96c5580f0 100644 --- a/cmd/skillshare/init.go +++ b/cmd/skillshare/init.go @@ -1234,6 +1234,7 @@ func tryPullAfterRemoteSetup(sourcePath, remoteURL string) bool { // This allows users to have skills stored in a subdirectory of their repo and not the root // Returns a string representing the name of the subdirectory, empty if none was selected func useSourceSubdir() string { + fmt.Println() fmt.Println(" Specifying a subdirectory as the source will store skills in the subdirectory (e.g. skills/) instead of in the root") fmt.Println() fmt.Print(" Specify a subdirectory as the source (e.g. skills)? [y/N]: ") From 4a8814ffcf36880abe55390d97fc140d893c9c77 Mon Sep 17 00:00:00 2001 From: Daylam Tayari Date: Thu, 12 Mar 2026 13:15:15 -0500 Subject: [PATCH 3/3] Switched dir name reading to bufio for space sup --- cmd/skillshare/init.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/skillshare/init.go b/cmd/skillshare/init.go index 96c5580f0..33288767d 100644 --- a/cmd/skillshare/init.go +++ b/cmd/skillshare/init.go @@ -1236,7 +1236,6 @@ func tryPullAfterRemoteSetup(sourcePath, remoteURL string) bool { func useSourceSubdir() string { fmt.Println() fmt.Println(" Specifying a subdirectory as the source will store skills in the subdirectory (e.g. skills/) instead of in the root") - fmt.Println() fmt.Print(" Specify a subdirectory as the source (e.g. skills)? [y/N]: ") var input string fmt.Scanln(&input) @@ -1244,8 +1243,7 @@ func useSourceSubdir() string { if input == "y" || input == "yes" { fmt.Print(" Enter subdirectory name: ") - var dirNameInput string - fmt.Scanln(&dirNameInput) + dirNameInput, _ := bufio.NewReader(os.Stdin).ReadString('\n') return strings.TrimSpace(dirNameInput) } return ""