feat(init): add interactive source path prompt during init -g

Previously, `init` silently defaulted source to ~/.config/skillshare/skills/
with no way for users to discover customization without reading docs. Now
interactive mode asks whether to customize the source path (Y/N gate + text
input), with tilde expansion and filepath.Abs normalization. The success
message also hints at --source and config path for future changes.

- promptSourcePath() follows same Y/N pattern as useSourceSubdir()
- TTY guard ensures non-interactive (piped stdin, --source flag) is unaffected
- Integration test verifies success message contains source hint
- Updated init.md flowchart, --source option note, and first-sync.md steps
This commit is contained in:
Willie
2026-03-17 04:48:42 +08:00
parent 0c2d700fb9
commit 41e3f6ae2b
7 changed files with 115 additions and 12 deletions
+8
View File
@@ -19,6 +19,14 @@
```
- **Smart shared repo detection** — when a teammate clones a shared skills repo and runs `skillshare init -p`, skillshare auto-detects the shared repo pattern (config.yaml in .gitignore) and creates an empty config with guided next steps. No `--config local` flag needed for cloners
#### Init Source Path Prompt
- **Interactive source path customization** — `skillshare init` now asks whether you want to customize the source directory path instead of silently using the default (`~/.config/skillshare/skills/`). Use `--source` to skip the prompt in scripts:
```bash
skillshare init # Prompts for source path
skillshare init --source ~/my-skills # Skips prompt
```
#### Target List Interactive TUI
- **Interactive target browser** — `skillshare target list` now launches a full-screen TUI with a split panel layout (target list on the left, detail panel on the right). Includes fuzzy filtering via `/` and keyboard navigation:
+46 -1
View File
@@ -359,7 +359,8 @@ func performFreshInit(opts *initOptions, home string) error {
// Default source path (same location as config)
sourcePath := opts.sourcePath
if sourcePath == "" {
sourcePath = filepath.Join(config.BaseDir(), "skills")
defaultPath := filepath.Join(config.BaseDir(), "skills")
sourcePath = promptSourcePath(defaultPath, home)
}
// Find directories with skills to potentially copy from
@@ -494,6 +495,8 @@ func printInitSuccess(sourcePath string, dryRun bool, skillInstalled bool) {
fmt.Println(" \"Pull my new skill from Claude and sync to all targets\"")
fmt.Println(" \"Show me skillshare status\"")
}
fmt.Println()
fmt.Printf(" %sTip: edit %s or re-run with --source to change source path%s\n", ui.Dim, config.ConfigPath(), ui.Reset)
}
// hasGlobalOnlyInitFlags returns true if args contain flags only valid for global init
@@ -1241,6 +1244,48 @@ func tryPullAfterRemoteSetup(sourcePath, remoteURL string) bool {
return true
}
// promptSourcePath asks the user whether they want to customize the source directory path.
// Returns defaultPath if non-interactive, user declines, or input is empty.
func promptSourcePath(defaultPath, home string) string {
if !runningInInteractiveTTY() {
return defaultPath
}
fmt.Println()
ui.Info("Source directory stores your skills (single source of truth)")
fmt.Printf(" Default: %s\n", defaultPath)
fmt.Print(" Customize source path? [y/N]: ")
reader := bufio.NewReader(os.Stdin)
input, _ := reader.ReadString('\n')
input = strings.ToLower(strings.TrimSpace(input))
if input != "y" && input != "yes" {
return defaultPath
}
fmt.Print(" Enter source path: ")
path, _ := reader.ReadString('\n')
path = strings.TrimSpace(path)
if path == "" {
return defaultPath
}
// Expand ~ prefix
if utils.HasTildePrefix(path) {
path = filepath.Join(home, path[1:])
}
absPath, err := filepath.Abs(path)
if err != nil {
ui.Warning("Invalid path, using default")
return defaultPath
}
ui.Success("Source path: %s", absPath)
return absPath
}
// useSourceSubdir specifies 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 the name of the subdirectory, or "" if skipped or non-interactive.
+32 -5
View File
@@ -7,11 +7,12 @@ Release date: 2026-03-16
v0.17.3 brings the **target list** command into the interactive TUI family, adds **centralized skills repo** support, and fixes a couple of paper cuts:
1. **Centralized skills repo** — `init -p --config local` enables one repo for skills, each developer manages own targets
2. **Target list TUI** — full-screen interactive browser with split layout, fuzzy filter, and inline editing
3. **Mode picker** — change a target's sync mode (`M` key) without leaving the TUI
4. **Include/Exclude editor** — add/remove filter patterns (`I`/`E` keys) directly from the TUI
5. **Web UI error guidance** — network failures now show actionable "restart `skillshare ui`" message
6. **`init --help` fix** — `--subdir` flag now visible, flag ordering matches documentation
2. **Init source path prompt** — `init` now asks whether to customize source directory path instead of silently defaulting
3. **Target list TUI** — full-screen interactive browser with split layout, fuzzy filter, and inline editing
4. **Mode picker** — change a target's sync mode (`M` key) without leaving the TUI
5. **Include/Exclude editor** — add/remove filter patterns (`I`/`E` keys) directly from the TUI
6. **Web UI error guidance** — network failures now show actionable "restart `skillshare ui`" message
7. **`init --help` fix** — `--subdir` flag now visible, flag ordering matches documentation
---
@@ -65,6 +66,32 @@ TUI keybindings:
---
## Init Source Path Prompt
### The problem
`skillshare init` silently set the source directory to `~/.config/skillshare/skills/` without telling the user this was customizable. Only users who read the docs or knew about `--source` could change it. First-time users had no opportunity to choose a different location.
### Solution
In interactive mode, `init` now displays the default source path and asks whether to customize it:
```
ℹ Source directory stores your skills (single source of truth)
Default: /home/user/.config/skillshare/skills
Customize source path? [y/N]:
```
If the user says yes, they enter a custom path (with `~` expansion). The success message also now includes a hint about `--source` and the config file location.
### Design decisions
- **TTY guard** — `runningInInteractiveTTY()` ensures the prompt only appears in real terminal sessions. Piped stdin (tests, scripts) skips automatically
- **`--source` priority** — when `--source` is provided on the CLI, `promptSourcePath()` is never called. Zero behavior change for non-interactive workflows
- **Same Y/N pattern** — reuses the `bufio.NewReader` + `ReadString('\n')` gate pattern from `useSourceSubdir()`, keeping the UX consistent
---
## Centralized Skills Repo (`--config local`)
### The problem
+13
View File
@@ -1005,6 +1005,19 @@ func TestInit_Fresh_ConfigHasSchemaComment(t *testing.T) {
}
}
func TestInit_SuccessMessage_ContainsSourceHint(t *testing.T) {
sb := testutil.NewSandbox(t)
defer sb.Cleanup()
os.Remove(sb.ConfigPath)
result := sb.RunCLI("init", "--no-copy", "--no-targets", "--no-git", "--no-skill")
result.AssertSuccess(t)
result.AssertOutputContains(t, "Tip:")
result.AssertOutputContains(t, "--source")
}
func TestInit_MutualExclusion_SkillFlags(t *testing.T) {
sb := testutil.NewSandbox(t)
defer sb.Cleanup()
+5 -4
View File
@@ -55,10 +55,11 @@ skillshare init
</p>
This:
1. Creates your source directory (`~/.config/skillshare/skills/`)
2. Auto-detects installed AI CLIs
3. Sets up configuration
4. Optionally installs the built-in skillshare skill (adds `/skillshare` command to AI CLIs)
1. Lets you customize the source directory path (default: `~/.config/skillshare/skills/`)
2. Creates your source directory
3. Auto-detects installed AI CLIs
4. Sets up configuration
5. Optionally installs the built-in skillshare skill (adds `/skillshare` command to AI CLIs)
### Init mode tip
+3 -2
View File
@@ -23,6 +23,7 @@ skillshare init --dry-run # Preview without changes
```mermaid
flowchart TD
TITLE["skillshare init"]
S0["0. Source path prompt"]
S1["1. Create source directory"]
S2["2. Auto-detect AI CLIs"]
S3["3. Initialize git"]
@@ -30,7 +31,7 @@ flowchart TD
S4b["5. Subdirectory prompt"]
S5["6. Create config.yaml"]
S6["7. Built-in skill"]
TITLE --> S1 --> S2 --> S3 --> S4 --> S4b --> S5 --> S6
TITLE --> S0 --> S1 --> S2 --> S3 --> S4 --> S4b --> S5 --> S6
```
:::info Universal target
@@ -103,7 +104,7 @@ If you run `skillshare init` on an already-initialized setup without `--discover
| Flag | Description |
|------|-------------|
| `--source, -s <path>` | Custom source directory |
| `--source, -s <path>` | Custom source directory (interactive mode prompts if not set) |
| `--remote <url>` | Set git remote (implies `--git`; auto-pulls if remote has skills) |
| `--project, -p` | Initialize project-level skills in current directory |
| `--copy-from, -c <name\|path>` | Copy skills from a specific CLI or path |
+8
View File
@@ -28,6 +28,14 @@ All notable changes to skillshare are documented here. For the full commit histo
```
- **Smart shared repo detection** — when a teammate clones a shared skills repo and runs `skillshare init -p`, skillshare auto-detects the shared repo pattern (config.yaml in .gitignore) and creates an empty config with guided next steps. No `--config local` flag needed for cloners
#### Init Source Path Prompt
- **Interactive source path customization** — `skillshare init` now asks whether you want to customize the source directory path instead of silently using the default (`~/.config/skillshare/skills/`). Use `--source` to skip the prompt in scripts:
```bash
skillshare init # Prompts for source path
skillshare init --source ~/my-skills # Skips prompt
```
#### Target List Interactive TUI
- **Interactive target browser** — `skillshare target list` now launches a full-screen TUI with a split panel layout (target list on the left, detail panel on the right). Includes fuzzy filtering via `/` and keyboard navigation: