feat(extras): let several single-file extras share one source folder

A single-file extra added from the dashboard with the shared source got
<extras dir>/<name> as its folder, so a second file in the same folder
needed the same name and was refused as a duplicate. Project mode had no
source setting at all, so it could never share a folder.

The add dialog now has a source folder field that defaults to the name,
and project extras accept a source relative to the project root, from the
dashboard and from `extras init -p --source`. Paths shown for single-file
extras also keep the folder's own separator, so Windows paths no longer
mix backslashes with a slash before the file name.

Refs #300
This commit is contained in:
Willie
2026-09-29 09:43:29 +08:00
parent d9c55a5d4b
commit d757afbb61
41 changed files with 410 additions and 63 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ func cmdDiffProject(root, targetName string, kind resourceKindFilter, opts diffR
var extrasResults []extraDiffResult
if len(runtime.config.Extras) > 0 {
extrasResults = collectExtrasDiff(runtime.config.Extras, func(extra config.ExtraConfig) string {
return config.ExtrasSourceDirProject(runtime.config.EffectiveExtrasSource(root), extra.Name)
return config.ResolveExtrasSourceDirProject(extra, runtime.config.EffectiveExtrasSource(root), root)
})
}
+1 -1
View File
@@ -1116,7 +1116,7 @@ func checkExtras(extras []config.ExtraConfig, result *doctorResult, isProject bo
for _, extra := range extras {
var sourceDir string
if isProject {
sourceDir = config.ExtrasSourceDirProject(projectExtrasParent, extra.Name)
sourceDir = config.ResolveExtrasSourceDirProject(extra, projectExtrasParent, projectRoot)
} else {
sourceDir = config.ResolveExtrasSourceDir(extra, extrasSource, source)
}
+1 -1
View File
@@ -114,7 +114,7 @@ func extrasCollectProject(cwd, name, fromPath string, dryRun, force bool, start
return nil
}
sourceDir := config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), extra.Name)
sourceDir := config.ResolveExtrasSourceDirProject(*extra, projCfg.EffectiveExtrasSource(cwd), cwd)
return runCollect(sourceDir, expandedPath, extra.Name, target.Mode, dryRun, force, target.Flatten, "project", config.ProjectConfigPath(cwd), start, cwd)
}
+8 -5
View File
@@ -115,8 +115,8 @@ func cmdExtrasInit(args []string) error {
}
if mode == modeProject {
if sourceOverride != "" {
return fmt.Errorf("--source is not supported in project mode (source is always .skillshare/extras/<name>/)")
if err := config.ValidateProjectExtraSource(sourceOverride); err != nil {
return err
}
return extrasInitProject(cwd, opts, start)
}
@@ -127,7 +127,7 @@ func cmdExtrasInit(args []string) error {
// makes it a single-file extra.
type extrasInitOptions struct {
name string
source string // global mode only
source string // relative to the project root in project mode
file string
targets []extrasInitTarget
force bool
@@ -244,7 +244,7 @@ func extrasInitProject(cwd string, o extrasInitOptions, start time.Time) error {
}
extra := o.extra()
sourceDir := config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), o.name)
sourceDir := config.ResolveExtrasSourceDirProject(extra, projCfg.EffectiveExtrasSource(cwd), cwd)
if err := checkExtraSourceFile(sourceDir, o.file); err != nil {
return err
}
@@ -338,7 +338,8 @@ Arguments:
Options:
--target <path> Target directory (repeatable)
--source <path> Custom source directory (overrides extras_source and default; global mode only)
--source <path> Custom source directory (overrides extras_source and default;
relative to the project root in project mode)
--file <filename> Sync only this file from the source directory (single-file extra)
--as <filename> Target filename for every --target (requires --file; default: the --file name)
--mode <mode> Sync mode: merge (default), copy, symlink; import for single-file extras
@@ -356,6 +357,8 @@ Examples:
skillshare extras init rules --target ~/.claude/rules --force
skillshare extras init agents --target ~/.claude/agents --flatten
skillshare extras init prompts --target .claude/prompts -p
skillshare extras init review -p --source .skillshare/extras/prompts \
--file review.md --target .claude/commands
skillshare extras init pi-prompt --source ~/dotfiles/prompts --file system.md \
--target ~/.pi/agent --as APPEND_SYSTEM.md`)
}
+3 -1
View File
@@ -588,7 +588,9 @@ func cmdExtrasInitTUI(mode runMode, cwd string) error {
}
if mode == modeProject {
opts.source = ""
if err := config.ValidateProjectExtraSource(opts.source); err != nil {
return err
}
return extrasInitProject(cwd, opts, start)
}
return extrasInitGlobal(opts, start)
+1 -1
View File
@@ -151,7 +151,7 @@ func cmdExtrasList(args []string) error {
}
extras = projCfg.Extras
sourceFunc = func(extra config.ExtraConfig) string {
return config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), extra.Name)
return config.ResolveExtrasSourceDirProject(extra, projCfg.EffectiveExtrasSource(cwd), cwd)
}
configPath = config.ProjectConfigPath(cwd)
} else {
+2 -2
View File
@@ -101,7 +101,7 @@ func removeExtraFromProjectConfig(projCfg *config.ProjectConfig, cwd, name strin
return "", fmt.Errorf("extra %q not found in project config", name)
}
sourceDir := config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), name)
sourceDir := config.ResolveExtrasSourceDirProject(removed, projCfg.EffectiveExtrasSource(cwd), cwd)
restored, restoreErr := restoreExtraFileTargets(removed, sourceDir, modeProject, cwd)
if restoreErr == nil {
projCfg.Extras = append(projCfg.Extras[:idx], projCfg.Extras[idx+1:]...)
@@ -186,7 +186,7 @@ func extrasRemoveProject(cwd, name string, force bool, start time.Time) error {
_, found := findExtraByName(projCfg.Extras, name)
if !force {
sourceDir := config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), name)
sourceDir := config.ResolveExtrasSourceDirProject(found, projCfg.EffectiveExtrasSource(cwd), cwd)
ui.Warning("This will remove %q from project config.", name)
ui.Info("Source files in %s will NOT be deleted.", shortenPath(sourceDir))
ui.Info("%s", extraRemoveTargetNote(found))
+1 -1
View File
@@ -79,7 +79,7 @@ func cmdExtrasRemoveTarget(args []string) error {
saveFn = func() error { return projCfg.Save(cwd) }
projectExtrasSource := projCfg.EffectiveExtrasSource(cwd)
sourceDirForExtra = func(extra config.ExtraConfig) string {
return config.ExtrasSourceDirProject(projectExtrasSource, extra.Name)
return config.ResolveExtrasSourceDirProject(extra, projectExtrasSource, cwd)
}
extensionsDir = projectExtensionsDir(cwd)
} else {
+1 -1
View File
@@ -43,7 +43,7 @@ func cmdStatusProject(root string) error {
if len(runtime.config.Extras) > 0 {
ui.Header("Extras")
printExtrasStatus(runtime.config.Extras, func(extra config.ExtraConfig) string {
return config.ExtrasSourceDirProject(runtime.config.EffectiveExtrasSource(root), extra.Name)
return config.ResolveExtrasSourceDirProject(extra, runtime.config.EffectiveExtrasSource(root), root)
})
}
+1 -1
View File
@@ -240,7 +240,7 @@ func cmdSync(args []string) error {
if loadErr == nil && len(projCfg.Extras) > 0 {
agentPaths := collectAgentTargetPathsProject(cwd)
extrasEntries := runExtrasSyncEntries(projCfg.Extras, func(extra config.ExtraConfig) string {
return config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), extra.Name)
return config.ResolveExtrasSourceDirProject(extra, projCfg.EffectiveExtrasSource(cwd), cwd)
}, dryRun, force, cwd, agentPaths)
return syncOutputJSON(results, dryRun, start, projIgnoreStats, err, projCtxCost, mcpResult, extrasEntries)
}
+1 -1
View File
@@ -340,7 +340,7 @@ func cmdSyncExtrasProject(cwd string, dryRun, force, jsonOutput bool, start time
}
for _, extra := range projCfg.Extras {
extraSource := config.ExtrasSourceDirProject(projCfg.EffectiveExtrasSource(cwd), extra.Name)
extraSource := config.ResolveExtrasSourceDirProject(extra, projCfg.EffectiveExtrasSource(cwd), cwd)
if _, statErr := os.Stat(extraSource); os.IsNotExist(statErr) {
if !jsonOutput {
+8 -1
View File
@@ -98,7 +98,14 @@ func (c *Config) ValidateExtras(focus ...string) error {
// ValidateExtras checks file ownership and import support in project mode.
func (c *ProjectConfig) ValidateExtras(root string, focus ...string) error {
source := func(e ExtraConfig) string { return ExtrasSourceDirProject(c.EffectiveExtrasSource(root), e.Name) }
for _, e := range c.Extras {
if err := ValidateProjectExtraSource(e.Source); err != nil {
return fmt.Errorf("extra %q: %w", e.Name, err)
}
}
source := func(e ExtraConfig) string {
return ResolveExtrasSourceDirProject(e, c.EffectiveExtrasSource(root), root)
}
target := func(p string) string {
if filepath.IsAbs(p) {
return p
+31 -1
View File
@@ -1,6 +1,10 @@
package config
import "path/filepath"
import (
"fmt"
"path/filepath"
"strings"
)
// ResolveExtrasSourceDir resolves the source directory for an extra using
// three-level priority: per-extra source > extras_source > default.
@@ -21,6 +25,32 @@ func ExtrasSourceDirProject(extrasParent, name string) string {
return filepath.Join(extrasParent, name)
}
// ResolveExtrasSourceDirProject resolves the source directory for an extra in
// project mode: its source (relative to the project root) when set, else
// <extrasParent>/<name>.
func ResolveExtrasSourceDirProject(extra ExtraConfig, extrasParent, root string) string {
if extra.Source != "" {
return filepath.Join(root, filepath.FromSlash(extra.Source))
}
return ExtrasSourceDirProject(extrasParent, extra.Name)
}
// ValidateProjectExtraSource checks a project extra's source: a path relative
// to the project root that stays inside it. Empty means the default folder.
func ValidateProjectExtraSource(source string) error {
if source == "" {
return nil
}
if filepath.IsAbs(source) || filepath.VolumeName(source) != "" || strings.HasPrefix(source, "~") || strings.ContainsAny(source[:1], `/\`) {
return fmt.Errorf("extra source %q must be relative to the project root", source)
}
clean := filepath.Clean(filepath.FromSlash(source))
if clean == ".." || strings.HasPrefix(clean, ".."+string(filepath.Separator)) {
return fmt.Errorf("extra source %q must stay inside the project root", source)
}
return nil
}
// ExtrasParentDir returns the extras parent directory (for migration/init).
func ExtrasParentDir(skillsSource string) string {
return filepath.Join(filepath.Dir(skillsSource), "extras")
+47
View File
@@ -93,3 +93,50 @@ func TestExtrasParentDir(t *testing.T) {
t.Errorf("ExtrasParentDir() = %q, want %q", got, want)
}
}
func TestResolveExtrasSourceDirProject(t *testing.T) {
root := filepath.FromSlash("/projects/myapp")
parent := filepath.Join(root, ".skillshare", "extras")
got := ResolveExtrasSourceDirProject(ExtraConfig{Name: "a", Source: ".skillshare/extras/prompts"}, parent, root)
if want := filepath.Join(parent, "prompts"); got != want {
t.Errorf("with source = %q, want %q", got, want)
}
got = ResolveExtrasSourceDirProject(ExtraConfig{Name: "a"}, parent, root)
if want := filepath.Join(parent, "a"); got != want {
t.Errorf("without source = %q, want %q", got, want)
}
}
func TestValidateProjectExtraSource(t *testing.T) {
for _, source := range []string{"", ".skillshare/extras/prompts", "docs/prompts"} {
if err := ValidateProjectExtraSource(source); err != nil {
t.Errorf("%q: unexpected error %v", source, err)
}
}
for _, source := range []string{"/abs/prompts", "~/prompts", "..", "../prompts", "a/../../prompts"} {
if err := ValidateProjectExtraSource(source); err == nil {
t.Errorf("%q: expected an error", source)
}
}
}
// Two single-file extras may share one project folder, as in global mode.
func TestProjectValidateExtras_SharedSourceFolder(t *testing.T) {
root := t.TempDir()
cfg := &ProjectConfig{Extras: []ExtraConfig{
{Name: "a", Source: ".skillshare/extras/prompts", File: "a.md", Targets: []ExtraTargetConfig{{Path: ".claude/commands"}}},
{Name: "b", Source: ".skillshare/extras/prompts", File: "b.md", Targets: []ExtraTargetConfig{{Path: ".claude/commands"}}},
}}
if err := cfg.ValidateExtras(root); err != nil {
t.Fatalf("ValidateExtras() = %v, want nil", err)
}
}
func TestProjectValidateExtras_RejectsEscapingSource(t *testing.T) {
cfg := &ProjectConfig{Extras: []ExtraConfig{
{Name: "a", Source: "../prompts", File: "a.md", Targets: []ExtraTargetConfig{{Path: ".claude/commands"}}},
}}
if err := cfg.ValidateExtras(t.TempDir()); err == nil {
t.Fatal("ValidateExtras() = nil, want an error for a source outside the project")
}
}
+30 -5
View File
@@ -58,7 +58,7 @@ type extrasTargetInfo struct {
// current mode.
func (s *Server) extrasSourceDir(extra config.ExtraConfig) string {
if s.IsProjectMode() {
return config.ExtrasSourceDirProject(s.projectCfg.EffectiveExtrasSource(s.projectRoot), extra.Name)
return config.ResolveExtrasSourceDirProject(extra, s.projectCfg.EffectiveExtrasSource(s.projectRoot), s.projectRoot)
}
return config.ResolveExtrasSourceDir(extra, s.cfg.EffectiveExtrasSource(), s.cfg.EffectiveSkillsSource())
}
@@ -113,7 +113,7 @@ func (s *Server) handleExtras(w http.ResponseWriter, r *http.Request) {
for _, extra := range extras {
var sourceDir string
if isProjectMode {
sourceDir = config.ExtrasSourceDirProject(projectExtrasParent, extra.Name)
sourceDir = config.ResolveExtrasSourceDirProject(extra, projectExtrasParent, projectRoot)
} else {
sourceDir = config.ResolveExtrasSourceDir(extra, extrasSource, source)
}
@@ -255,7 +255,7 @@ func (s *Server) handleExtrasDiff(w http.ResponseWriter, r *http.Request) {
var sourceDir string
if isProjectMode {
sourceDir = config.ExtrasSourceDirProject(projectExtrasParent, extra.Name)
sourceDir = config.ResolveExtrasSourceDirProject(extra, projectExtrasParent, projectRoot)
} else {
sourceDir = config.ResolveExtrasSourceDir(extra, extrasSource, source)
}
@@ -424,7 +424,8 @@ func (s *Server) handleExtrasCreate(w http.ResponseWriter, r *http.Request) {
var body struct {
Name string `json:"name"`
Source string `json:"source,omitempty"`
File string `json:"file,omitempty"` // single-file extra: the file in the source dir
Folder string `json:"folder,omitempty"` // a folder in the extras directory, shared by several single-file extras
File string `json:"file,omitempty"` // single-file extra: the file in the source dir
Targets []struct {
Path string `json:"path"`
Mode string `json:"mode"`
@@ -447,6 +448,14 @@ func (s *Server) handleExtrasCreate(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, "at least one target is required")
return
}
if body.Folder != "" && body.Source != "" {
writeError(w, http.StatusBadRequest, "source and folder cannot both be set")
return
}
if body.Folder == "." || body.Folder == ".." || strings.ContainsAny(body.Folder, `/\`) {
writeError(w, http.StatusBadRequest, fmt.Sprintf("folder %q must be a plain folder name", body.Folder))
return
}
// Validate mode and flatten values
for _, t := range body.Targets {
@@ -471,6 +480,22 @@ func (s *Server) handleExtrasCreate(w http.ResponseWriter, r *http.Request) {
return
}
// A folder other than the name becomes the source: absolute in global
// mode, relative to the project root in project mode.
if body.Folder != "" && body.Folder != body.Name {
if s.IsProjectMode() {
dir := filepath.Join(s.projectCfg.EffectiveExtrasSource(s.projectRoot), body.Folder)
rel, err := filepath.Rel(s.projectRoot, dir)
if err != nil {
writeError(w, http.StatusBadRequest, err.Error())
return
}
body.Source = filepath.ToSlash(rel)
} else {
body.Source = filepath.Join(s.cfg.EffectiveExtrasSource(), body.Folder)
}
}
// Build ExtraConfig
extra := config.ExtraConfig{Name: body.Name, Source: body.Source, File: body.File}
for _, t := range body.Targets {
@@ -625,7 +650,7 @@ func (s *Server) syncExtras(name string, dryRun, force bool) []extraSyncResult {
}
var sourceDir string
if projectRoot != "" {
sourceDir = config.ExtrasSourceDirProject(projectExtrasParent, extra.Name)
sourceDir = config.ResolveExtrasSourceDirProject(extra, projectExtrasParent, projectRoot)
} else {
sourceDir = config.ResolveExtrasSourceDir(extra, extrasSource, source)
}
+46
View File
@@ -924,6 +924,52 @@ func TestHandleExtrasCreate_SingleFile(t *testing.T) {
}
}
// Two project single-file extras can share one folder: the folder is stored
// as a source relative to the project root and listed resolved.
func TestHandleExtrasCreate_ProjectFolderSharedBySingleFiles(t *testing.T) {
s, projectRoot := newTestProjectServerWithExtras(t, nil)
for _, name := range []string{"a", "b"} {
body := `{"name":"` + name + `","folder":"prompts","file":"` + name + `.md","targets":[{"path":".claude/commands"}]}`
rr := httptest.NewRecorder()
s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodPost, "/api/extras", strings.NewReader(body)))
if rr.Code != http.StatusOK {
t.Fatalf("create %s: expected 200, got %d: %s", name, rr.Code, rr.Body.String())
}
}
s.mu.RLock()
extras := s.projectCfg.Extras
s.mu.RUnlock()
for _, e := range extras {
if e.Source != ".skillshare/extras/prompts" {
t.Errorf("extra %s source = %q, want .skillshare/extras/prompts", e.Name, e.Source)
}
}
rr := httptest.NewRecorder()
s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodGet, "/api/extras", nil))
var resp struct {
Extras []extrasListEntry `json:"extras"`
}
if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil {
t.Fatal(err)
}
want := filepath.Join(projectRoot, ".skillshare", "extras", "prompts")
if len(resp.Extras) != 2 || resp.Extras[0].SourceDir != want || resp.Extras[1].SourceDir != want {
t.Errorf("extras = %+v, want both with source_dir %s", resp.Extras, want)
}
}
func TestHandleExtrasCreate_ProjectRejectsAbsoluteSource(t *testing.T) {
s, _ := newTestProjectServerWithExtras(t, nil)
body := `{"name":"a","source":"` + filepath.ToSlash(t.TempDir()) + `","file":"a.md","targets":[{"path":".claude/commands"}]}`
rr := httptest.NewRecorder()
s.handler.ServeHTTP(rr, httptest.NewRequest(http.MethodPost, "/api/extras", strings.NewReader(body)))
if rr.Code != http.StatusBadRequest {
t.Errorf("expected 400, got %d: %s", rr.Code, rr.Body.String())
}
}
func TestHandleExtrasCreate_SingleFileRejectsInvalidSettings(t *testing.T) {
targetDir := t.TempDir()
cases := map[string]string{
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"skillshare/internal/git"
"skillshare/internal/install"
"skillshare/internal/projectdir"
"skillshare/internal/resource"
"skillshare/internal/sync"
"skillshare/internal/utils"
@@ -28,7 +27,7 @@ func (s *Server) handleOverview(w http.ResponseWriter, r *http.Request) {
agentsSource := s.agentsSource()
extrasSource := s.cfg.EffectiveExtrasSource()
if s.IsProjectMode() {
extrasSource = filepath.Join(projectdir.Resolve(s.projectRoot), "extras")
extrasSource = s.projectCfg.EffectiveExtrasSource(s.projectRoot)
}
cfgMode := s.cfg.Mode
targetCount := len(s.cfg.Targets)
+5
View File
@@ -402,6 +402,11 @@
"description": "Name of the extra resource (matches a subdirectory under the source extras directory).",
"examples": ["rules", "commands"]
},
"source": {
"type": "string",
"description": "Custom source directory for this extra (overrides extras_source and the default). Several single-file extras can share one directory. Supports ~ for home directory.",
"examples": ["~/dotfiles/prompts"]
},
"file": {
"type": "string",
"description": "Sync one file instead of the whole source directory: a plain filename inside the extra's source directory. Each target receives <path>/<as or file>.",
+5
View File
@@ -365,6 +365,11 @@
"description": "Name of the extra resource (matches a subdirectory under the source extras directory).",
"examples": ["rules", "commands"]
},
"source": {
"type": "string",
"description": "Custom source directory for this extra, relative to the project root (absolute paths and paths outside the project are rejected). Several single-file extras can share one directory. Default: <extras source>/<name>.",
"examples": [".skillshare/extras/prompts"]
},
"file": {
"type": "string",
"description": "Sync one file instead of the whole source directory: a plain filename inside the extra's source directory. Each target receives <path>/<as or file>.",
+4 -3
View File
@@ -31,7 +31,7 @@ skillshare extras init rules --no-tui ... # Skip wizard
| Flag | Description |
|------|-------------|
| `--target <path>` | Target directory (repeatable, at least one required) |
| `--source <path>` | Custom source directory for this extra (global mode only) |
| `--source <path>` | Custom source directory for this extra (relative to the project root in project mode) |
| `--file <filename>` | Single-file extra: sync only this file from the source directory |
| `--as <filename>` | File name at every target (default: `--file` name); requires `--file` |
| `--mode <mode>` | Sync mode: `merge` (default), `copy`, `symlink`; `import` only with `--file` |
@@ -184,8 +184,9 @@ When replacing a user junction for a single-file extra, the warning includes its
`--remove-target` without `--prune` leaves the single-file target in place and unmanaged, and forgets its restore point. Later syncs do not clean it up; attaching it again records a new restore point.
`flatten` and `extension` are rejected on a single-file extra; `extras collect`
does not apply. `extras list` shows full file paths for its source and targets.
To sync several files from one folder (global mode only), create one single-file
extra per file with the same `--source`; files no extra names are not synced.
To sync several files from one folder, create one single-file extra per file with
the same `--source` (in project mode, relative to the project root, e.g.
`.skillshare/extras/prompts`); files no extra names are not synced.
The web dashboard lists single-file extras whose `file` is `AGENTS.md` under
Extras -> AGENTS.md as shared AGENTS.md files, and all others under Extras ->
Folders & files; its rename conversion (project mode) is blocked while the file
+37
View File
@@ -346,3 +346,40 @@ func TestExtrasFile_InitRejectsFlattenAndDirectorySource(t *testing.T) {
t.Errorf("config changed after rejected init:\n%s", got)
}
}
// Issue #300: several project single-file extras share one source folder.
func TestExtrasFile_ProjectSharedSourceFolder(t *testing.T) {
sb := testutil.NewSandbox(t)
defer sb.Cleanup()
projectRoot := sb.SetupProjectDir("claude")
prompts := filepath.Join(projectRoot, ".skillshare", "extras", "prompts")
if err := os.MkdirAll(prompts, 0755); err != nil {
t.Fatal(err)
}
sb.WriteFile(filepath.Join(prompts, "a.md"), "# a")
sb.WriteFile(filepath.Join(prompts, "b.md"), "# b")
for _, name := range []string{"a", "b"} {
sb.RunCLIInDir(projectRoot, "extras", "init", name, "-p",
"--source", ".skillshare/extras/prompts", "--file", name+".md",
"--target", ".claude/commands", "--mode", "copy").AssertSuccess(t)
}
if got := sb.ReadFile(filepath.Join(projectRoot, ".skillshare", "config.yaml")); !strings.Contains(got, "source: .skillshare/extras/prompts") {
t.Errorf("project config does not keep the relative source:\n%s", got)
}
sb.RunCLIInDir(projectRoot, "sync", "extras", "-p").AssertSuccess(t)
out := filepath.Join(projectRoot, ".claude", "commands")
for _, name := range []string{"a", "b"} {
if got := sb.ReadFile(filepath.Join(out, name+".md")); got != "# "+name {
t.Errorf("%s.md = %q, want %q", name, got, "# "+name)
}
}
// Removing one extra keeps the folder and the other extra's file.
sb.RunCLIInDir(projectRoot, "extras", "remove", "a", "-p", "--force").AssertSuccess(t)
if got := sb.ReadFile(filepath.Join(prompts, "b.md")); got != "# b" {
t.Errorf("b.md after removing a = %q, want %q", got, "# b")
}
}
+2 -2
View File
@@ -327,7 +327,7 @@ extras:
// TestExtras_Init_SourceNotSupportedInProjectMode verifies that --source is
// rejected in project mode with a clear error message.
func TestExtras_Init_SourceNotSupportedInProjectMode(t *testing.T) {
func TestExtras_Init_ProjectSourceMustBeRelative(t *testing.T) {
sb := testutil.NewSandbox(t)
defer sb.Cleanup()
@@ -342,7 +342,7 @@ func TestExtras_Init_SourceNotSupportedInProjectMode(t *testing.T) {
"-p")
result.AssertFailure(t)
result.AssertAnyOutputContains(t, "--source is not supported in project mode")
result.AssertAnyOutputContains(t, "must be relative to the project root")
}
// TestExtras_Source_Show verifies that "extras source" shows the current extras_source.
+1
View File
@@ -712,6 +712,7 @@ export const api = {
createExtra: (data: {
name: string;
source?: string;
folder?: string; // a folder in the shared extras folder; the server stores it as the source
file?: string; // single-file extra: the file in the source folder
targets: Array<{ path: string; mode: string; flatten?: boolean; extension?: string; as?: string }>;
}) =>
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "Dateiname",
"extras.modal.fileNameInvalid": "Gib einen Dateinamen ein, keinen Pfad.",
"extras.modal.fileSyncs": "Synchronisiert {path}. Andere Dateien in diesem Ordner bleiben unberührt.",
"extras.modal.sourceFolder": "Quellordner",
"extras.modal.sourceFolderHint": "Extras im selben Ordner synchronisieren jeweils ihre eigene Datei.",
"extras.modal.sourceFolderInvalid": "Gib einen Ordnernamen ein, keinen Pfad.",
"extras.modal.agentsNote": "Ein Extra mit der Datei AGENTS.md erscheint im Tab AGENTS.md.",
"extras.hint.fileAs": "Lass den Dateinamen leer, um {file} zu behalten.",
"extras.hint.fileModes": "merge verlinkt die Datei · copy schreibt eine Kopie · import fügt eine @-Zeile hinzu, nur für Tools, die @-Importe lesen.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "File name",
"extras.modal.fileNameInvalid": "Enter a file name, not a path.",
"extras.modal.fileSyncs": "Syncs {path}. Other files in that folder are left alone.",
"extras.modal.sourceFolder": "Source folder",
"extras.modal.sourceFolderHint": "Extras in the same folder each sync their own file.",
"extras.modal.sourceFolderInvalid": "Enter a folder name, not a path.",
"extras.modal.agentsNote": "An extra whose file is AGENTS.md appears on the AGENTS.md tab.",
"extras.hint.fileAs": "Leave File name empty to keep {file}.",
"extras.hint.fileModes": "merge links the file · copy writes a copy · import adds an @ line, only for tools that read @ imports.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "Nombre de archivo",
"extras.modal.fileNameInvalid": "Escribe un nombre de archivo, no una ruta.",
"extras.modal.fileSyncs": "Sincroniza {path}. Los demás archivos de esa carpeta no se tocan.",
"extras.modal.sourceFolder": "Carpeta de origen",
"extras.modal.sourceFolderHint": "Los extras de la misma carpeta sincronizan cada uno su propio archivo.",
"extras.modal.sourceFolderInvalid": "Escribe un nombre de carpeta, no una ruta.",
"extras.modal.agentsNote": "Un extra cuyo archivo es AGENTS.md aparece en la pestaña AGENTS.md.",
"extras.hint.fileAs": "Deja vacío el nombre de archivo para conservar {file}.",
"extras.hint.fileModes": "merge enlaza el archivo · copy escribe una copia · import añade una línea @, solo para herramientas que leen importaciones @.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "نام فایل",
"extras.modal.fileNameInvalid": "نام فایل را وارد کنید، نه مسیر.",
"extras.modal.fileSyncs": "{path} را همگام می‌کند. فایل‌های دیگر آن پوشه دست نمی‌خورند.",
"extras.modal.sourceFolder": "پوشه منبع",
"extras.modal.sourceFolderHint": "extraهایی که در یک پوشه‌اند هر کدام فایل خودشان را همگام می‌کنند.",
"extras.modal.sourceFolderInvalid": "نام پوشه را وارد کنید، نه مسیر.",
"extras.modal.agentsNote": "extraای که فایلش AGENTS.md است در زبانه AGENTS.md نمایش داده می‌شود.",
"extras.hint.fileAs": "برای نگه داشتن {file}، نام فایل را خالی بگذارید.",
"extras.hint.fileModes": "merge فایل را پیوند می‌دهد · copy یک نسخه می‌نویسد · import یک خط @ اضافه می‌کند، فقط برای ابزارهایی که importهای @ را می‌خوانند.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "Nom du fichier",
"extras.modal.fileNameInvalid": "Saisissez un nom de fichier, pas un chemin.",
"extras.modal.fileSyncs": "Synchronise {path}. Les autres fichiers de ce dossier ne sont pas modifiés.",
"extras.modal.sourceFolder": "Dossier source",
"extras.modal.sourceFolderHint": "Les extras d'un même dossier synchronisent chacun leur propre fichier.",
"extras.modal.sourceFolderInvalid": "Saisissez un nom de dossier, pas un chemin.",
"extras.modal.agentsNote": "Un extra dont le fichier est AGENTS.md apparaît dans l'onglet AGENTS.md.",
"extras.hint.fileAs": "Laissez le nom du fichier vide pour garder {file}.",
"extras.hint.fileModes": "merge crée un lien vers le fichier · copy écrit une copie · import ajoute une ligne @, uniquement pour les outils qui lisent les imports @.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "Nama file",
"extras.modal.fileNameInvalid": "Masukkan nama file, bukan path.",
"extras.modal.fileSyncs": "Menyinkronkan {path}. File lain di folder itu tidak diubah.",
"extras.modal.sourceFolder": "Folder sumber",
"extras.modal.sourceFolderHint": "Extra dalam folder yang sama masing-masing menyinkronkan filenya sendiri.",
"extras.modal.sourceFolderInvalid": "Masukkan nama folder, bukan path.",
"extras.modal.agentsNote": "Extra dengan file AGENTS.md muncul di tab AGENTS.md.",
"extras.hint.fileAs": "Kosongkan Nama file untuk tetap memakai {file}.",
"extras.hint.fileModes": "merge menautkan file · copy menulis salinan · import menambahkan baris @, hanya untuk alat yang membaca impor @.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "ファイル名",
"extras.modal.fileNameInvalid": "パスではなくファイル名を入力してください。",
"extras.modal.fileSyncs": "{path} を同期します。そのフォルダー内のほかのファイルはそのままです。",
"extras.modal.sourceFolder": "ソースフォルダー",
"extras.modal.sourceFolderHint": "同じフォルダーの extra は、それぞれ自分のファイルを同期します。",
"extras.modal.sourceFolderInvalid": "パスではなくフォルダー名を入力してください。",
"extras.modal.agentsNote": "ファイルが AGENTS.md の extra は「AGENTS.md」タブに表示されます。",
"extras.hint.fileAs": "ファイル名を空にすると {file} のままになります。",
"extras.hint.fileModes": "merge はファイルをリンク · copy はコピーを書き込み · import は @ 行を追加(@ インポートを読むツールのみ)。",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "파일 이름",
"extras.modal.fileNameInvalid": "경로가 아닌 파일 이름을 입력하세요.",
"extras.modal.fileSyncs": "{path}을(를) 동기화합니다. 해당 폴더의 다른 파일은 그대로 둡니다.",
"extras.modal.sourceFolder": "소스 폴더",
"extras.modal.sourceFolderHint": "같은 폴더의 extra는 각자 자기 파일을 동기화합니다.",
"extras.modal.sourceFolderInvalid": "경로가 아닌 폴더 이름을 입력하세요.",
"extras.modal.agentsNote": "파일이 AGENTS.md인 extra는 AGENTS.md 탭에 표시됩니다.",
"extras.hint.fileAs": "파일 이름을 비워 두면 {file}을(를) 그대로 사용합니다.",
"extras.hint.fileModes": "merge는 파일을 링크 · copy는 사본을 작성 · import는 @ 줄을 추가하며, @ import를 읽는 도구에서만 동작합니다.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "Nome do arquivo",
"extras.modal.fileNameInvalid": "Digite um nome de arquivo, não um caminho.",
"extras.modal.fileSyncs": "Sincroniza {path}. Os outros arquivos dessa pasta não são alterados.",
"extras.modal.sourceFolder": "Pasta de origem",
"extras.modal.sourceFolderHint": "Extras na mesma pasta sincronizam cada um o seu próprio arquivo.",
"extras.modal.sourceFolderInvalid": "Digite um nome de pasta, não um caminho.",
"extras.modal.agentsNote": "Um extra cujo arquivo é AGENTS.md aparece na aba AGENTS.md.",
"extras.hint.fileAs": "Deixe o nome do arquivo vazio para manter {file}.",
"extras.hint.fileModes": "merge cria um link para o arquivo · copy grava uma cópia · import adiciona uma linha @, só para ferramentas que leem imports @.",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "文件名",
"extras.modal.fileNameInvalid": "请输入文件名,而不是路径。",
"extras.modal.fileSyncs": "同步 {path}。该文件夹中的其他文件不受影响。",
"extras.modal.sourceFolder": "源文件夹",
"extras.modal.sourceFolderHint": "同一文件夹中的 extra 各自同步自己的文件。",
"extras.modal.sourceFolderInvalid": "请输入文件夹名称,而不是路径。",
"extras.modal.agentsNote": "文件为 AGENTS.md 的 extra 会显示在“AGENTS.md”标签页。",
"extras.hint.fileAs": "文件名留空则保留 {file}。",
"extras.hint.fileModes": "merge 链接文件 · copy 写入副本 · import 添加一行 @,仅适用于读取 @ import 的工具。",
+3
View File
@@ -1073,6 +1073,9 @@
"extras.modal.fileName": "檔名",
"extras.modal.fileNameInvalid": "請輸入檔名,不是路徑。",
"extras.modal.fileSyncs": "同步 {path}。那個資料夾裡的其他檔案不會被動到。",
"extras.modal.sourceFolder": "來源資料夾",
"extras.modal.sourceFolderHint": "同一個資料夾裡的 extra 各自同步自己的檔案。",
"extras.modal.sourceFolderInvalid": "請輸入資料夾名稱,不是路徑。",
"extras.modal.agentsNote": "檔案是 AGENTS.md 的 extra 會顯示在「AGENTS.md」分頁。",
"extras.hint.fileAs": "檔名留空就沿用 {file}。",
"extras.hint.fileModes": "merge 連結檔案 · copy 寫入副本 · import 加一行 @,只適用於會讀 @ import 的工具。",
+33
View File
@@ -23,6 +23,8 @@ vi.mock('../api/client', async (load) => {
targets: [{ path: '.claude/rules', mode: 'merge', flatten: false, status: 'synced' }] },
{ name: 'conventions', file: 'CONVENTIONS.md', source_dir: '/p/.skillshare/extras/conventions', source_type: 'per-extra', file_count: 1, source_exists: true,
targets: [{ path: '.cursor', mode: 'copy', flatten: false, as: 'rules.md', status: 'synced' }] },
{ name: 'pi-prompt', file: 'system.md', source_dir: String.raw`C:\Users\me\prompts`, source_type: 'custom', file_count: 1, source_exists: true,
targets: [{ path: String.raw`C:\Users\me\.pi\agent`, mode: 'copy', flatten: false, as: 'APPEND_SYSTEM.md', status: 'synced' }] },
],
}),
createExtra: vi.fn().mockResolvedValue({ success: true }),
@@ -58,6 +60,14 @@ describe('Extras page in a project', () => {
expect(screen.getByText('.cursor/rules.md')).toBeInTheDocument();
});
// A Windows folder keeps its backslashes up to the file name.
it('joins a Windows target folder and file name with a backslash', async () => {
renderPage();
expect(await screen.findByText(String.raw`~\.pi\agent\APPEND_SYSTEM.md`)).toBeInTheDocument();
// The full path is the row's tooltip.
expect(screen.getByTitle(String.raw`C:\Users\me\.pi\agent\APPEND_SYSTEM.md`)).toBeInTheDocument();
});
it('creates a single-file extra with its file and target file name', async () => {
const user = userEvent.setup();
renderPage();
@@ -77,4 +87,27 @@ describe('Extras page in a project', () => {
targets: [{ path: '.claude', mode: 'merge', as: 'CLAUDE-notes.md' }],
});
});
// Issue #300: several single files can share one folder of the shared extras folder.
it('creates a single-file extra in a source folder named differently from the extra', async () => {
const user = userEvent.setup();
renderPage();
await user.click(await screen.findByRole('button', { name: 'Add extra' }));
const dialog = screen.getByRole('dialog');
await user.type(within(dialog).getByLabelText('Name'), 'review');
await user.click(within(dialog).getByRole('radio', { name: 'Single file' }));
const [fileInput] = within(dialog).getAllByRole('textbox', { name: 'File name' });
await user.type(fileInput, 'review.md');
await user.type(within(dialog).getByRole('combobox', { name: 'Source folder' }), 'prompts');
await user.type(within(dialog).getByRole('textbox', { name: 'Folder' }), '.claude/commands');
expect(within(dialog).getByText(/\/extras\/prompts\/review\.md/)).toBeInTheDocument();
await user.click(within(dialog).getByRole('button', { name: 'Create' }));
expect(api.createExtra).toHaveBeenCalledWith({
name: 'review',
folder: 'prompts',
file: 'review.md',
targets: [{ path: '.claude/commands', mode: 'merge' }],
});
});
});
+33 -8
View File
@@ -30,8 +30,11 @@ const FILE_MODES = ['merge', 'copy', 'import'] as const;
/** A file name typed where a path would be wrong. */
const isPathLike = (name: string) => /[\\/]/.test(name);
/** <folder>/<file>, for a single-file extra's source or target file. */
const joinFile = (dir: string, file: string) => `${dir.replace(/[\\/]+$/, '')}/${file}`;
/** <folder>/<file>, for a single-file extra's source or target file, with the separator the folder already uses (a backslash on Windows). */
const joinFile = (dir: string, file: string) => {
const sep = dir.lastIndexOf('\\') > dir.lastIndexOf('/') ? '\\' : '/';
return `${dir.replace(/[\\/]+$/, '')}${sep}${file}`;
};
const STATUS: Record<string, { tone: string; labelKey: string }> = {
synced: { tone: 'ok', labelKey: 'extras.status.synced' },
@@ -190,12 +193,13 @@ function FileDraftHints({ fileName }: { fileName: string }) {
);
}
function AddExtraDialog({ onClose, onCreated, extensions, known, sharedDir }: {
function AddExtraDialog({ onClose, onCreated, extensions, known, sharedDir, folders }: {
onClose: () => void;
onCreated: (agents: boolean) => void;
extensions: string[];
known: AvailableTarget[];
sharedDir: string;
folders: string[]; // folders in sharedDir that single-file extras already use
}) {
const { toast } = useToast();
const t = useT();
@@ -204,15 +208,18 @@ function AddExtraDialog({ onClose, onCreated, extensions, known, sharedDir }: {
const [file, setFile] = useState('');
const [custom, setCustom] = useState(false);
const [source, setSource] = useState('');
const [folder, setFolder] = useState('');
const [drafts, setDrafts] = useState<Draft[]>(() => [newDraft()]);
const [saving, setSaving] = useState(false);
const title = t('extras.addExtraTitle');
const valid = drafts.filter((d) => d.path.trim());
const fileName = file.trim();
const fileOk = !single || (fileName !== '' && !isPathLike(fileName) && valid.every((d) => !isPathLike(d.as.trim())));
// A single file in the shared folder can use another extra's folder; empty means the extra's name.
const folderName = single && !custom ? folder.trim() : '';
const fileOk = !single || (fileName !== '' && !isPathLike(fileName) && !isPathLike(folderName) && valid.every((d) => !isPathLike(d.as.trim())));
const canCreate = name.trim() !== '' && valid.length > 0 && (!custom || source.trim() !== '') && fileOk && !saving;
const agents = single && isAgentsExtra({ file: fileName });
const sourceFile = joinFile(custom ? source.trim() || '…' : `${shortenHome(sharedDir)}/${name.trim() || '…'}`, fileName || '…');
const sourceFile = joinFile(custom ? source.trim() || '…' : joinFile(shortenHome(sharedDir), folderName || name.trim() || '…'), fileName || '…');
// Keep each target's mode valid for the chosen kind.
const switchKind = (toSingle: boolean) => {
@@ -228,6 +235,7 @@ function AddExtraDialog({ onClose, onCreated, extensions, known, sharedDir }: {
await api.createExtra({
name: name.trim(),
...(custom && { source: source.trim() }),
...(folderName && folderName !== name.trim() && { folder: folderName }),
...(single && { file: fileName }),
targets: valid.map((d) => (single
? { path: d.path.trim(), mode: d.mode, ...(d.as.trim() && { as: d.as.trim() }) }
@@ -285,8 +293,18 @@ function AddExtraDialog({ onClose, onCreated, extensions, known, sharedDir }: {
<span className="ss-inp">
<input value={source} onChange={(e) => setSource(e.target.value)} placeholder={t('extras.modal.sourcePathPlaceholder')} aria-label={t('extras.sourceType.custom')} disabled={saving} />
</span>
) : !single && (
<span className="hp truncate font-mono">{`${shortenHome(sharedDir)}/${name.trim() || '…'}`}</span>
) : single ? (
<>
<span className={`ss-inp ${isPathLike(folderName) ? 'err' : ''}`}>
<input value={folder} onChange={(e) => setFolder(e.target.value)} list="extra-folders" placeholder={name.trim() || t('extras.modal.namePlaceholder')} aria-label={t('extras.modal.sourceFolder')} aria-invalid={isPathLike(folderName)} disabled={saving} />
</span>
<datalist id="extra-folders">
{folders.map((f) => <option key={f} value={f} />)}
</datalist>
<span className={`hp ${isPathLike(folderName) ? 'text-bad' : ''}`}>{t(isPathLike(folderName) ? 'extras.modal.sourceFolderInvalid' : 'extras.modal.sourceFolderHint')}</span>
</>
) : (
<span className="hp truncate font-mono">{joinFile(shortenHome(sharedDir), name.trim() || '…')}</span>
)}
</div>
{single && (
@@ -402,7 +420,13 @@ export default function ExtrasPage() {
const extensions = extData?.extensions ?? [];
const known = useMemo(() => availData?.targets ?? [], [availData]);
// Mirrors config.ResolveExtrasSourceDir: extras_source, else "extras" next to the skills source
const sharedDir = overview?.extrasSource ?? `${(overview?.source ?? '').replace(/\/[^/]*\/?$/, '')}/extras`;
const sharedDir = overview?.extrasSource ?? joinFile((overview?.source ?? '').replace(/[\\/][^\\/]*[\\/]?$/, ''), 'extras');
// Folders of single-file extras directly inside sharedDir, offered when adding another file
const sharedFolders = useMemo(() => {
const parent = sharedDir.replace(/[\\/]+$/, '');
const dirs = (data?.extras ?? []).filter((e) => e.file).map((e) => e.source_dir.replace(/[\\/]+$/, ''));
return [...new Set(dirs.filter((d) => d.replace(/[\\/][^\\/]*$/, '') === parent).map((d) => d.slice(parent.length + 1)))];
}, [data, sharedDir]);
const [showAdd, setShowAdd] = useState(false);
const [creatingShared, setCreatingShared] = useState(false);
@@ -649,6 +673,7 @@ export default function ExtrasPage() {
extensions={extensions}
known={known}
sharedDir={sharedDir}
folders={sharedFolders}
/>
)}
<SkillContextMenu open={!!menu} anchorPoint={menu ?? undefined} items={menu?.items ?? []} onClose={() => setMenu(null)} />
+17 -6
View File
@@ -47,7 +47,7 @@ The wizard asks **What do you want to sync?** after the name: **Folder** or **Si
| `--as <filename>` | File name to write at every target (default: the `--file` name). Requires `--file` |
| `--mode <mode>` | Sync mode: `merge` (default), `copy`, or `symlink`; `import` only with `--file` |
| `--flatten` | Sync files from subdirectories directly into the target root (cannot be used with `symlink` mode or `--file`) |
| `--source <path>` | Custom source directory for this extra (overrides `extras_source` and default; **global mode only**) |
| `--source <path>` | Custom source directory for this extra (overrides `extras_source` and default; relative to the project root in project mode) |
| `--force` | Overwrite if extra already exists |
| `--no-tui` | Skip interactive wizard, use CLI flags only |
| `--project, -p` | Create in project config (`.skillshare/`) |
@@ -474,7 +474,7 @@ appends `~/.pi/agent/APPEND_SYSTEM.md` to its system prompt; keep that text as
```yaml
extras:
- name: pi-prompt
source: ~/dotfiles/prompts # global mode only
source: ~/dotfiles/prompts # project mode: relative to the project root
file: system.md # ~/dotfiles/prompts/system.md
targets:
- path: ~/.pi/agent
@@ -556,8 +556,8 @@ the file's content; edit the source file directly.
### One folder, several files
In global mode, several single-file extras can share one `source` directory. Create
one extra per file; files in the folder that no extra names are not synced:
Several single-file extras can share one `source` directory. Create one extra per
file; files in the folder that no extra names are not synced:
```yaml
extras:
@@ -582,8 +582,19 @@ skillshare extras init pi-agents --source ~/dotfiles/pi --file agents.md \
--as AGENTS.md --target ~/.pi/agent
```
This does not apply in project mode, where each extra's source is always
`.skillshare/extras/<name>/`.
In project mode, `source` is relative to the project root and must stay inside it;
absolute paths are rejected:
```bash
skillshare extras init review -p --source .skillshare/extras/prompts \
--file review.md --target .claude/commands
skillshare extras init plan -p --source .skillshare/extras/prompts \
--file plan.md --target .claude/commands
```
In the dashboard, a single file in the shared extras folder has a **Source folder**
field. It defaults to the extra's name; enter another extra's folder to keep both
files in one folder.
Backups are kept in skillshare's state directory
(`~/.local/state/skillshare/extras/backups/` on macOS and Linux), the last 10 per
@@ -47,7 +47,7 @@ skillshare extras init <name> --file <filename> [--as <filename>] --target <path
| `--as <filename>` | すべての Target で書き出すファイル名(デフォルト: `--file` の名前)。`--file` が必要 |
| `--mode <mode>` | sync モード: `merge`(デフォルト)、`copy`、または `symlink`。`import` は `--file` 指定時のみ |
| `--flatten` | サブディレクトリ内のファイルを Target のルート直下に sync する(`symlink` モードや `--file` とは併用不可) |
| `--source <path>` | この Extras 用のカスタム Source ディレクトリ(`extras_source` とデフォルトを上書き。**グローバルモードのみ**) |
| `--source <path>` | この Extras 用のカスタム Source ディレクトリ(`extras_source` とデフォルトを上書き。Project モードではプロジェクトルートからの相対パス) |
| `--force` | すでに存在する Extras を上書き |
| `--no-tui` | インタラクティブウィザードをスキップし、CLI フラグのみを使用 |
| `--project, -p` | Project 設定(`.skillshare/`)内に作成 |
@@ -453,7 +453,7 @@ Target はディレクトリであるため、各 Target はそれぞれの Sour
```yaml
extras:
- name: pi-prompt
source: ~/dotfiles/prompts # global モードのみ
source: ~/dotfiles/prompts # project モード: プロジェクトルートからの相対パス
file: system.md # ~/dotfiles/prompts/system.md
targets:
- path: ~/.pi/agent
@@ -530,7 +530,7 @@ Claude Code のように `@` import に従うツールでのみ使ってくだ
### 1 つのフォルダーに複数のファイル
グローバルモードでは、複数の単一ファイルの Extras が 1 つの `source` ディレクトリを共有できます。
複数の単一ファイルの Extras が 1 つの `source` ディレクトリを共有できます。
ファイルごとに Extras を 1 つ作成してください。どの Extras にも指定されていないフォルダー内のファイルは sync されません。
```yaml
@@ -556,7 +556,16 @@ skillshare extras init pi-agents --source ~/dotfiles/pi --file agents.md \
--as AGENTS.md --target ~/.pi/agent
```
Project モードでは各 Extras の Source が常に `.skillshare/extras/<name>/` であるため、これは適用されません。
Project モードでは、`source` はプロジェクトルートからの相対パスで、プロジェクト内に収まる必要があります。絶対パスは拒否されます:
```bash
skillshare extras init review -p --source .skillshare/extras/prompts \
--file review.md --target .claude/commands
skillshare extras init plan -p --source .skillshare/extras/prompts \
--file plan.md --target .claude/commands
```
ダッシュボードでは、共有 Extras フォルダー内の単一ファイルに **Source folder** 欄があります。デフォルトは Extras の名前です。別の Extras のフォルダーを入力すると、両方のファイルを 1 つのフォルダーにまとめられます。
バックアップは skillshare の state ディレクトリ(macOS と Linux では
`~/.local/state/skillshare/extras/backups/`)に、ファイルごとに最新 10 件まで保存されます。
@@ -47,7 +47,7 @@ wizard는 이름 다음에 **What do you want to sync?**를 묻습니다: **Fold
| `--as <filename>` | 모든 target에 쓸 파일 이름 (기본값: `--file` 이름). `--file` 필요 |
| `--mode <mode>` | 동기화 mode: `merge` (기본값), `copy`, 또는 `symlink`. `import`는 `--file`과 함께만 사용 가능 |
| `--flatten` | 하위 디렉터리의 파일을 target 루트에 바로 동기화 (`symlink` mode 또는 `--file`과 함께 사용 불가) |
| `--source <path>` | 이 extra에 대한 사용자 지정 source 디렉터리 (`extras_source` 및 기본값을 재정의; **전역 모드 전용**) |
| `--source <path>` | 이 extra에 대한 사용자 지정 source 디렉터리 (`extras_source` 및 기본값을 재정의; 프로젝트 모드에서는 프로젝트 루트 기준 상대 경로) |
| `--force` | extra가 이미 존재하면 덮어쓰기 |
| `--no-tui` | interactive wizard 생략, CLI 플래그만 사용 |
| `--project, -p` | 프로젝트 config(`.skillshare/`)에 생성 |
@@ -472,7 +472,7 @@ system prompt에 덧붙입니다. 그 내용을 dotfiles에 `system.md`로 두
```yaml
extras:
- name: pi-prompt
source: ~/dotfiles/prompts # global mode only
source: ~/dotfiles/prompts # 프로젝트 모드: 프로젝트 루트 기준 상대 경로
file: system.md # ~/dotfiles/prompts/system.md
targets:
- path: ~/.pi/agent
@@ -549,7 +549,7 @@ single-file extra는 **Folders & files**에 표시됩니다. 그곳의 **Add ext
### 폴더 하나, 여러 파일
전역 모드에서는 여러 single-file extra가 하나의 `source` 디렉터리를 공유할 수 있습니다. 파일마다
여러 single-file extra가 하나의 `source` 디렉터리를 공유할 수 있습니다. 파일마다
extra를 하나씩 만드세요. 어떤 extra에도 지정되지 않은 폴더 안의 파일은 동기화되지 않습니다:
```yaml
@@ -575,8 +575,18 @@ skillshare extras init pi-agents --source ~/dotfiles/pi --file agents.md \
--as AGENTS.md --target ~/.pi/agent
```
프로젝트 모드에서는 적용되지 않습니다. 프로젝트 모드에서 각 extra의 source는 항상
`.skillshare/extras/<name>/`입니다.
프로젝트 모드에서 `source`는 프로젝트 루트 기준 상대 경로이며 프로젝트 안에 있어야 합니다.
절대 경로는 거부됩니다:
```bash
skillshare extras init review -p --source .skillshare/extras/prompts \
--file review.md --target .claude/commands
skillshare extras init plan -p --source .skillshare/extras/prompts \
--file plan.md --target .claude/commands
```
대시보드에서는 공유 extras 폴더의 single file에 **Source folder** 필드가 있습니다. 기본값은
extra 이름이며, 다른 extra의 폴더를 입력하면 두 파일을 한 폴더에 둘 수 있습니다.
백업은 skillshare의 state 디렉터리(macOS와 Linux에서는
`~/.local/state/skillshare/extras/backups/`)에 파일당 최근 10개까지 보관됩니다.
@@ -47,7 +47,7 @@ skillshare extras init <name> --file <filename> [--as <filename>] --target <path
| `--as <filename>` | 写入每个 target 的文件名(默认为 `--file` 的名称)。需要搭配 `--file` |
| `--mode <mode>` | Sync mode:`merge`(默认)、`copy` 或 `symlink`;`import` 仅可搭配 `--file` |
| `--flatten` | 将子目录中的文件直接同步到 target 根目录(不能与 `symlink` mode 或 `--file` 一起使用) |
| `--source <path>` | 该 extra 的自定义 source 目录(覆盖 `extras_source` 和默认值;**仅 global mode**) |
| `--source <path>` | 该 extra 的自定义 source 目录(覆盖 `extras_source` 和默认值;project mode 下为相对于项目根目录的路径) |
| `--force` | 如果 extra 已存在则覆盖 |
| `--no-tui` | 跳过交互式向导,仅使用 CLI flags |
| `--project, -p` | 在 project 配置(`.skillshare/`)中创建 |
@@ -456,7 +456,7 @@ target 会得到 `<path>/<as>`,其中 `as` 默认为 `file` 的名称。任何
```yaml
extras:
- name: pi-prompt
source: ~/dotfiles/prompts # 仅限 global mode
source: ~/dotfiles/prompts # project mode:相对于项目根目录
file: system.md # ~/dotfiles/prompts/system.md
targets:
- path: ~/.pi/agent
@@ -529,7 +529,7 @@ extras 则显示在 **Folders & files**。在那里,**添加 Extra** 提供 **
### 一个文件夹,多个文件
在 global mode 中,多个单文件 extras 可以共用同一个 `source` 目录。每个文件创建
多个单文件 extras 可以共用同一个 `source` 目录。每个文件创建
一个 extra;文件夹中没有被任何 extra 指定的文件不会被同步:
```yaml
@@ -555,8 +555,17 @@ skillshare extras init pi-agents --source ~/dotfiles/pi --file agents.md \
--as AGENTS.md --target ~/.pi/agent
```
这不适用于 project mode,因为在 project mode 中每个 extra 的 source 始终是
`.skillshare/extras/<name>/`。
在 project mode 中,`source` 是相对于项目根目录的路径,且必须位于项目内;绝对路径会被拒绝:
```bash
skillshare extras init review -p --source .skillshare/extras/prompts \
--file review.md --target .claude/commands
skillshare extras init plan -p --source .skillshare/extras/prompts \
--file plan.md --target .claude/commands
```
在 Dashboard 中,共享 extras 文件夹里的单文件有一个 **Source folder** 字段。默认是 extra 的名称;
填入另一个 extra 的文件夹,即可把两个文件放在同一个文件夹中。
备份保存在 skillshare 的 state 目录中(macOS 和 Linux 上为
`~/.local/state/skillshare/extras/backups/`),每个文件保留最近 10 份。drift 备份位于该处的
@@ -47,7 +47,7 @@ skillshare extras init <name> --file <filename> [--as <filename>] --target <path
| `--as <filename>` | 寫入每個 target 時使用的檔名(預設為 `--file` 的名稱)。需要搭配 `--file` |
| `--mode <mode>` | Sync 模式:`merge`(預設)、`copy`,或 `symlink`;`import` 僅限搭配 `--file` |
| `--flatten` | 將子目錄中的檔案直接同步到 target 根目錄(無法與 `symlink` 模式或 `--file` 一起使用) |
| `--source <path>` | 此 extra 的自訂 source 目錄(會覆寫 `extras_source` 與預設值;**僅限 global mode**) |
| `--source <path>` | 此 extra 的自訂 source 目錄(會覆寫 `extras_source` 與預設值;project mode 中為相對於專案根目錄的路徑) |
| `--force` | 若 extra 已存在則覆寫 |
| `--no-tui` | 略過互動式精靈,只使用 CLI 旗標 |
| `--project, -p` | 在 project 設定中建立(`.skillshare/`) |
@@ -455,7 +455,7 @@ Claude Code 讀取的是 `CLAUDE.md` 而不是 `AGENTS.md`,而匯入正是它
```yaml
extras:
- name: pi-prompt
source: ~/dotfiles/prompts # 僅限 global mode
source: ~/dotfiles/prompts # project mode:相對於專案根目錄
file: system.md # ~/dotfiles/prompts/system.md
targets:
- path: ~/.pi/agent
@@ -525,7 +525,7 @@ extras:
### 一個資料夾、多個檔案
在 global mode 中,多個單一檔案 extra 可以共用同一個 `source` 目錄。每個檔案各建立一個 extra;
多個單一檔案 extra 可以共用同一個 `source` 目錄。每個檔案各建立一個 extra;
資料夾中沒有被任何 extra 指定的檔案不會同步:
```yaml
@@ -551,8 +551,17 @@ skillshare extras init pi-agents --source ~/dotfiles/pi --file agents.md \
--as AGENTS.md --target ~/.pi/agent
```
這不適用於 project mode,因為在 project mode 中每個 extra 的 source 一律是
`.skillshare/extras/<name>/`。
在 project mode 中,`source` 是相對於專案根目錄的路徑,而且必須在專案內;絕對路徑會被拒絕:
```bash
skillshare extras init review -p --source .skillshare/extras/prompts \
--file review.md --target .claude/commands
skillshare extras init plan -p --source .skillshare/extras/prompts \
--file plan.md --target .claude/commands
```
在 Dashboard 中,共用 extras 資料夾裡的單一檔案有一個 **Source folder** 欄位。預設是 extra 的名稱;
填入另一個 extra 的資料夾,就能把兩個檔案放在同一個資料夾。
備份保存在 skillshare 的 state 目錄中(macOS 與 Linux 上為 `~/.local/state/skillshare/extras/backups/`),
每個檔案保留最近 10 份。Drift backup 放在其中的 `extras/backups/<id>/drift/`,`<id>` 由 target 檔案的