fix(ui): show correct field docs for target names in config editor

- name: claude under targets was showing mode doc (targets.mode)
  instead of target name doc. Fixed by adding targets.name fieldDoc
  entry which scores higher in subsequence matching.
- Bare list values like "- agents" (short-form target name) were
  invisible: extractKey, parseYamlTree, and lookupFieldDoc now
  handle them.
This commit is contained in:
Willie
2026-03-25 21:14:16 +08:00
parent 2ce1544dd1
commit 7c913086d0
7 changed files with 24 additions and 7 deletions
+1
View File
@@ -34,6 +34,7 @@
- **Flatten checkbox** — the Extras page shows a flatten checkbox per target, both when creating extras and on existing targets. Disabled when mode is symlink
- **Config editor validation** — the YAML config editor warns when `flatten: true` is combined with `mode: symlink`
- **Target name field docs** — clicking a target name in the config editor (both `name: claude` and short-form `- agents`) now shows the correct "target name" documentation instead of unrelated field docs
## [0.17.10] - 2026-03-24
+4
View File
@@ -54,3 +54,7 @@ The `extras init` interactive wizard now includes a "Flatten files into target r
## Web UI
The Extras page now shows a flatten checkbox per target — both in the "Add Extra" modal and on existing targets. The checkbox is disabled when mode is `symlink`. The YAML config editor warns when `flatten: true` is combined with `mode: symlink`.
## Config Editor — Target Name Docs
Clicking a target name in the config editor now shows the correct "target name" field documentation. Previously, clicking `name: claude` under `targets` incorrectly showed the sync mode documentation. Short-form entries like `- agents` are also recognized and show the same target name docs.
+4 -3
View File
@@ -48,10 +48,11 @@ function lookupFieldDoc(fieldPath: string | null, docsMap: Record<string, FieldD
}
if (bestKey) doc = docsMap[bestKey];
// Fallback: just the root key (for dynamic child keys like target names)
// targets.universal → targets
// Fallback: dynamic value under a known section → treat as a name
// targets.agents → targets.name, extras.rules → extras.name
if (!doc && parts.length >= 2) {
doc = docsMap[parts[0]];
const nameKey = parts[0] + '.name';
doc = docsMap[nameKey] ?? docsMap[parts[0]];
}
}
+6 -4
View File
@@ -33,9 +33,6 @@ function parseYamlTree(source: string): TreeNode[] {
const trimmed = rawLine.trim();
// Skip blank lines and comment lines
if (!trimmed || trimmed.startsWith('#')) continue;
// Skip bare list values (- value without colon)
if ((trimmed.startsWith('- ') || trimmed === '-') && !trimmed.includes(':')) continue;
let key: string | null = null;
let rest = '';
let indent = rawLine.length - rawLine.trimStart().length;
@@ -45,13 +42,18 @@ function parseYamlTree(source: string): TreeNode[] {
if (listMatch) {
key = listMatch[1];
rest = listMatch[2].trim();
// For depth calc, use indent of the dash
} else {
// Plain key: "key: value"
const plainMatch = trimmed.match(/^([a-zA-Z_][\w.-]*)\s*:(.*)/);
if (plainMatch) {
key = plainMatch[1];
rest = plainMatch[2].trim();
} else {
// Bare list value: "- agents" (short-form target name, no colon)
const bareMatch = trimmed.match(/^-\s+([a-zA-Z_][\w.-]+)$/);
if (bareMatch) {
key = bareMatch[1];
}
}
}
+3
View File
@@ -14,6 +14,9 @@ function extractKey(line: string): string | null {
// Try list item key: " - key: value"
const listItem = line.match(/^\s*-\s+([a-zA-Z_][\w.-]*)\s*:/);
if (listItem) return listItem[1];
// Bare list value: " - agents" (no colon, e.g. short-form target name)
const bare = line.match(/^\s*-\s+([a-zA-Z_][\w.-]+)\s*$/);
if (bare) return bare[1];
return null;
}
+5
View File
@@ -51,6 +51,11 @@ export const fieldDocs: Record<string, FieldDoc> = {
type: 'object',
example: 'targets:\n claude:\n path: ~/.claude/skills\n mode: merge\n include: ["skill-a", "skill-b"]\n exclude: ["debug-only"]\n cursor:\n mode: symlink',
},
'targets.name': {
description: 'Target name in config. Use a built-in name (e.g., claude, cursor, codex) for automatic path resolution, or any custom name with an explicit path.',
type: 'string',
example: '- name: claude\n path: ~/.claude/skills',
},
'targets.include': {
description: 'List of skill names to include for this target. If set, only these skills are synced.',
type: 'string[]',
+1
View File
@@ -43,6 +43,7 @@ All notable changes to skillshare are documented here. For the full commit histo
- **Flatten checkbox** — the Extras page shows a flatten checkbox per target, both when creating extras and on existing targets. Disabled when mode is symlink
- **Config editor validation** — the YAML config editor warns when `flatten: true` is combined with `mode: symlink`
- **Target name field docs** — clicking a target name in the config editor (both `name: claude` and short-form `- agents`) now shows the correct "target name" documentation instead of unrelated field docs
## [0.17.10] - 2026-03-24