skill-flow 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.gstack/browse-network.log +1 -0
  2. package/.gstack/browse.json +7 -0
  3. package/.gstack/qa-reports/qa-report-skill-manager-2026-03-22.md +60 -0
  4. package/README.md +20 -3
  5. package/README.zh.md +20 -3
  6. package/dist/cli.js +19 -7
  7. package/dist/cli.js.map +1 -1
  8. package/dist/domain/types.d.ts +9 -2
  9. package/dist/services/deployment-planner.js +8 -16
  10. package/dist/services/deployment-planner.js.map +1 -1
  11. package/dist/services/doctor-service.js +13 -0
  12. package/dist/services/doctor-service.js.map +1 -1
  13. package/dist/services/inventory-service.d.ts +1 -1
  14. package/dist/services/inventory-service.js +4 -2
  15. package/dist/services/inventory-service.js.map +1 -1
  16. package/dist/services/skill-flow.d.ts +7 -1
  17. package/dist/services/skill-flow.js +8 -4
  18. package/dist/services/skill-flow.js.map +1 -1
  19. package/dist/services/source-service.d.ts +10 -1
  20. package/dist/services/source-service.js +200 -39
  21. package/dist/services/source-service.js.map +1 -1
  22. package/dist/state/store.d.ts +3 -1
  23. package/dist/state/store.js +9 -2
  24. package/dist/state/store.js.map +1 -1
  25. package/dist/tests/skill-flow.test.js.map +1 -1
  26. package/dist/tui/config-app.d.ts +2 -2
  27. package/dist/tui/config-app.js +26 -7
  28. package/dist/tui/config-app.js.map +1 -1
  29. package/dist/utils/clawhub.d.ts +38 -0
  30. package/dist/utils/clawhub.js +65 -0
  31. package/dist/utils/clawhub.js.map +1 -0
  32. package/dist/utils/format.js +9 -4
  33. package/dist/utils/format.js.map +1 -1
  34. package/dist/utils/naming.d.ts +20 -0
  35. package/dist/utils/naming.js +82 -0
  36. package/dist/utils/naming.js.map +1 -0
  37. package/dist/utils/source-id.js +29 -0
  38. package/dist/utils/source-id.js.map +1 -1
  39. package/docs/DESIGN.md +407 -0
  40. package/docs/PRD/PRD-1.0.0.md +1862 -0
  41. package/docs/PRD/renew/PRD-0.0.0.md +26 -0
  42. package/docs/PRD/renew/PRD-0.0.1.md +408 -0
  43. package/docs/PRD/renew/PRD-0.0.2.md +705 -0
  44. package/docs/PRD/renew/PRD-0.0.3.md +740 -0
  45. package/docs/PRD/renew/PRD-0.0.4.md +1494 -0
  46. package/docs/README.md +242 -0
  47. package/docs/plan/PLAN_v1.0.0.md +663 -0
  48. package/docs/plan/PLAN_v1.0.1.md +814 -0
  49. package/docs/refrences/README.md +7 -0
  50. package/docs/refrences/agent-skill-paths.md +252 -0
  51. package/docs/refrences/naming-dedupe-warning-rules.md +482 -0
  52. package/img/img-1.jpg +0 -0
  53. package/package.json +18 -7
  54. package/dist/tests/skill-flow.test.js +0 -926
  55. package/src/adapters/channel-adapters.ts +0 -75
  56. package/src/cli.tsx +0 -147
  57. package/src/domain/types.ts +0 -175
  58. package/src/services/deployment-applier.ts +0 -81
  59. package/src/services/deployment-planner.ts +0 -259
  60. package/src/services/doctor-service.ts +0 -156
  61. package/src/services/inventory-service.ts +0 -251
  62. package/src/services/skill-flow.ts +0 -381
  63. package/src/services/source-service.ts +0 -427
  64. package/src/services/workflow-service.ts +0 -56
  65. package/src/state/store.ts +0 -68
  66. package/src/tests/skill-flow.test.ts +0 -1184
  67. package/src/tui/config-app.tsx +0 -1094
  68. package/src/tui/selection-state.ts +0 -45
  69. package/src/utils/constants.ts +0 -201
  70. package/src/utils/format.ts +0 -59
  71. package/src/utils/fs.ts +0 -102
  72. package/src/utils/git.ts +0 -16
  73. package/src/utils/result.ts +0 -23
  74. package/src/utils/source-id.ts +0 -19
  75. package/tsconfig.json +0 -22
  76. package/vitest.config.ts +0 -8
@@ -0,0 +1,814 @@
1
+ # Skill Flow Implementation Plan
2
+
3
+ Version: v1.0.1
4
+ Status: ENGINEERING REVIEWED
5
+ Date: 2026-03-22
6
+ Product mode: Source Expansion + Discovery Entry
7
+ Platform: macOS
8
+ CLI entry: `skill-flow`
9
+ State root: `~/.skillflow/`
10
+
11
+ ## 1. Executive Summary
12
+
13
+ `v1.0.1` adds two product capabilities:
14
+ - expanded `add` beyond plain Git clone
15
+ - a first `find` / `search` discovery flow
16
+
17
+ This release does not try to become a full ecosystem registry.
18
+ It stays narrow:
19
+ - Git sources still matter
20
+ - ClawHub becomes the only new remote structured source
21
+ - `find` only merges local inventory and ClawHub search
22
+
23
+ The engineering goal is not "support every source."
24
+ The engineering goal is:
25
+
26
+ ```text
27
+ take the existing Git-only workflow manager
28
+ ->
29
+ make source ingestion multi-kind without breaking state
30
+ ->
31
+ add a small discovery entrypoint that always leads back to `add`
32
+ ```
33
+
34
+ This plan explicitly avoids:
35
+ - broad Git host search
36
+ - persistent discovery cache
37
+ - a plugin SDK
38
+ - importing `.clawhub` local state
39
+ - a new `install <candidate>` command
40
+
41
+ ## 2. Why This Release Exists
42
+
43
+ `v1.0.0` shipped a narrow but real baseline:
44
+ - Git source add / update / uninstall
45
+ - grouped workflow management
46
+ - config / apply / doctor
47
+ - explicit `manifest.json + lock.json`
48
+
49
+ That baseline is useful, but two gaps are now visible:
50
+ - users still need to know a source before they can do anything
51
+ - `add` still behaves like a Git clone wrapper instead of a source-ingestion command
52
+
53
+ `v1.0.1` closes those gaps without changing the product's core identity.
54
+
55
+ ## 3. Research Summary
56
+
57
+ Research date: 2026-03-22
58
+
59
+ Primary references:
60
+ - Vercel skills repo: <https://github.com/vercel-labs/skills>
61
+ - Vercel `find-skills` skill: <https://github.com/vercel-labs/skills/tree/main/skills/find-skills>
62
+ - OpenAI `skill-installer` skill: <https://github.com/openai/skills/blob/main/skills/.system/skill-installer/SKILL.md>
63
+ - OpenClaw ClawHub docs: <https://docs.openclaw.ai/tools/clawhub>
64
+
65
+ ### 3.1 Vercel `skills`
66
+
67
+ Observed behavior:
68
+ - installation is still repo-centric
69
+ - accepted inputs include `owner/repo`, full URL, repo tree URL, and local path
70
+ - discovery is a workflow that helps users choose a source, then route into installation
71
+
72
+ Takeaways:
73
+ - `find` and `add` should be one journey
74
+ - repo subpath install is a real need
75
+ - discovery can start with explicit rules and curated sources
76
+
77
+ ### 3.2 OpenAI `skill-installer`
78
+
79
+ Observed behavior:
80
+ - supports repo, URL, local path, and repo subpath installation
81
+ - prefers direct download for public content
82
+ - falls back to sparse checkout when needed
83
+
84
+ Takeaways:
85
+ - path-scoped install is worth doing
86
+ - source identity should still remain repo-first
87
+ - direct path input does not require inventing a separate package model
88
+
89
+ ### 3.3 ClawHub
90
+
91
+ Observed behavior:
92
+ - `clawhub search` is a structured discovery surface
93
+ - `clawhub install` installs named skills with optional version selection
94
+ - installation lands in the current workspace `./skills`
95
+ - state is tracked under `.clawhub/`
96
+
97
+ Takeaways:
98
+ - ClawHub is a real source kind, not just another Git locator
99
+ - its identity model is `slug + version`, not `remote + commit`
100
+ - its install UX is useful reference
101
+ - its on-disk state model should not be reused inside `skill-flow`
102
+
103
+ Engineering conclusion:
104
+ - do not shell out to `clawhub install` and absorb `.clawhub/lock.json`
105
+ - do implement ClawHub fetch/search against `skill-flow`'s own state and cache model
106
+
107
+ ## 4. What Already Exists
108
+
109
+ Existing code and flows this plan must reuse:
110
+
111
+ - [src/services/source-service.ts](/Users/Vint/仓库/03%20Project/skill-manager/src/services/source-service.ts)
112
+ Reuse:
113
+ - source add/update/remove orchestration
114
+ - leaf scan + manifest/lock write flow
115
+ - source-level update semantics
116
+
117
+ - [src/services/skill-flow.ts](/Users/Vint/仓库/03%20Project/skill-manager/src/services/skill-flow.ts)
118
+ Reuse:
119
+ - application service entrypoints
120
+ - existing orchestration pattern for CLI commands
121
+
122
+ - [src/state/store.ts](/Users/Vint/仓库/03%20Project/skill-manager/src/state/store.ts)
123
+ Reuse:
124
+ - manifest / lock path ownership
125
+ - state root initialization
126
+ Change:
127
+ - source cache path resolution must become source-kind aware
128
+
129
+ - [src/tests/skill-flow.test.ts](/Users/Vint/仓库/03%20Project/skill-manager/src/tests/skill-flow.test.ts)
130
+ Reuse:
131
+ - temp repo + temp state test harness
132
+ - integration-heavy testing style
133
+ - existing backward-compat lock read pattern
134
+
135
+ - [src/cli.tsx](/Users/Vint/仓库/03%20Project/skill-manager/src/cli.tsx)
136
+ Reuse:
137
+ - existing command registration shell
138
+ Change:
139
+ - add `find`
140
+ - add `search` alias
141
+ - widen `add` argument semantics
142
+
143
+ Existing things this plan must not rebuild:
144
+ - a second state layer for discovery
145
+ - a second service layer parallel to `SkillFlowApp`
146
+ - a generalized source plugin system
147
+
148
+ ## 5. NOT In Scope
149
+
150
+ - Broad GitHub / GitLab keyword search
151
+ Reason: low-signal results and unclear trust model
152
+
153
+ - Persistent discovery cache files
154
+ Reason: no demonstrated performance need yet
155
+
156
+ - `install <candidate>` top-level command
157
+ Reason: `find -> add` is sufficient for this release
158
+
159
+ - Importing `.clawhub` local state
160
+ Reason: it would couple two source-of-truth systems
161
+
162
+ - Stars / install counts / leaderboard aggregation from arbitrary public hosts
163
+ Reason: data quality and trust are not stable enough
164
+
165
+ - Registry / source plugin SDK
166
+ Reason: two concrete source kinds do not justify a framework
167
+
168
+ ## 6. Step 0 Scope Challenge
169
+
170
+ This plan is intentionally split into two bounded delivery tracks:
171
+
172
+ ```text
173
+ Track A: Source expansion
174
+ - naming alignment
175
+ - multi-kind storage
176
+ - ClawHub add/update/uninstall
177
+ - Git repo-subpath add
178
+
179
+ Track B: Discovery
180
+ - find/search
181
+ - local + ClawHub result merge
182
+ - ranking
183
+ - candidate -> add command bridge
184
+ ```
185
+
186
+ This is not a scope reduction in product value.
187
+ It is a scope reduction in simultaneous moving parts.
188
+
189
+ Without this split, one release would change:
190
+ - naming and state paths
191
+ - source fetch/update semantics
192
+ - CLI surface
193
+ - result ranking
194
+ - follow-up action generation
195
+
196
+ That is too much blast radius for one undifferentiated implementation batch.
197
+
198
+ ## 7. Architecture Decisions
199
+
200
+ ### 7.1 Phase 0: Naming And State-Root Alignment
201
+
202
+ Before new behavior is added, `v1.0.1` must align plan and code on one product identity.
203
+
204
+ Lock for this release:
205
+ - CLI name: `skill-flow`
206
+ - state root: `~/.skillflow/`
207
+ - env var prefix: `SKILL_FLOW_`
208
+
209
+ Do not mix:
210
+ - `skill-manager`
211
+ - `.skillmanager`
212
+ - future rename ideas
213
+
214
+ If product rename work is desired later, it must be a separate plan.
215
+
216
+ ### 7.2 Keep The Existing Source Of Truth
217
+
218
+ Keep:
219
+ - `manifest.json`
220
+ - `lock.json`
221
+
222
+ Do not add:
223
+ - `inventory-index.json`
224
+ - `discovery-cache.json`
225
+ - `channels.json`
226
+
227
+ Discovery results are ephemeral.
228
+ Only actual installed sources modify persistent state.
229
+
230
+ ### 7.3 Multi-Kind Source Storage Is Explicit
231
+
232
+ Current code assumes one cache root: Git.
233
+ That is no longer enough.
234
+
235
+ New required cache layout:
236
+
237
+ ```text
238
+ ~/.skillflow/
239
+ ├── source/
240
+ │ ├── git/
241
+ │ │ └── <source-id>/
242
+ │ └── clawhub/
243
+ │ └── <source-id>/
244
+ ├── manifest.json
245
+ └── lock.json
246
+ ```
247
+
248
+ `StateStore` owns this path resolution.
249
+ Adapters must not construct cache paths themselves.
250
+
251
+ Required API direction:
252
+ - `getSourceRoot(kind)`
253
+ - `getSourceCheckoutPath(kind, sourceId)`
254
+
255
+ ### 7.4 Source Identity Stays Source-First
256
+
257
+ Direct path installs do not create a new source identity.
258
+
259
+ Rules:
260
+ - source identity is based on normalized source locator
261
+ - `--path` is not part of source identity
262
+ - the same repo cannot be registered twice just because the requested path differs
263
+ - `--path` is an add-time selection filter and optional persisted preference only
264
+
265
+ This preserves update and uninstall semantics at source granularity.
266
+
267
+ ### 7.5 Minimal Source Adapter Seam
268
+
269
+ Do not build a plugin system.
270
+ Do not let adapters own state writes or scanning.
271
+
272
+ Only extract source-specific IO:
273
+ - `resolve(locator)`
274
+ - `fetch(resolved, destination)`
275
+ - `update(existingSnapshot, checkoutPath)`
276
+
277
+ Keep in `SourceService`:
278
+ - manifest/lock writes
279
+ - inventory scan
280
+ - source diffing
281
+ - duplicate detection
282
+ - source lifecycle orchestration
283
+
284
+ This is the smallest seam that cleanly supports:
285
+ - Git
286
+ - ClawHub
287
+
288
+ ### 7.6 `find` Is A Read-Time Aggregation Service
289
+
290
+ `find` aggregates:
291
+ - local installed inventory
292
+ - ClawHub search metadata
293
+
294
+ It does not:
295
+ - download bundles during search
296
+ - mutate manifest/lock
297
+ - create background cache state
298
+
299
+ Search fetch policy:
300
+ - `find` requests metadata only
301
+ - `add` downloads source content
302
+
303
+ ### 7.7 Candidate-To-Command Bridge Is A First-Class Boundary
304
+
305
+ `find` output must not hand-build `add` command strings in CLI formatting code.
306
+
307
+ Instead:
308
+ - candidate assembly produces normalized `SkillCandidate`
309
+ - a single command-builder maps candidate -> follow-up `add` command
310
+ - text output and JSON output both consume the same mapping source
311
+
312
+ This avoids formatter drift between:
313
+ - Git candidates
314
+ - Git + path candidates
315
+ - ClawHub floating candidates
316
+ - ClawHub pinned candidates
317
+
318
+ ## 8. Data Flow Diagrams
319
+
320
+ ### 8.1 Expanded `add`
321
+
322
+ ```text
323
+ user input
324
+ |
325
+ v
326
+ parse locator + optional --path
327
+ |
328
+ v
329
+ resolve source kind
330
+ |
331
+ +--> git resolver
332
+ |
333
+ +--> clawhub resolver
334
+ |
335
+ v
336
+ fetch source checkout into source/<kind>/<source-id>
337
+ |
338
+ v
339
+ scan checkout for valid leafs
340
+ |
341
+ v
342
+ apply optional path filter / preference
343
+ |
344
+ v
345
+ write manifest + lock
346
+ |
347
+ v
348
+ optional follow-up apply/config
349
+ ```
350
+
351
+ ### 8.2 `find`
352
+
353
+ ```text
354
+ query
355
+ |
356
+ +--> local inventory matcher
357
+ |
358
+ +--> clawhub search metadata
359
+ |
360
+ v
361
+ merge candidates
362
+ |
363
+ v
364
+ rank with explicit rule table
365
+ |
366
+ v
367
+ candidate -> add command builder
368
+ |
369
+ +--> text output
370
+ |
371
+ +--> json output
372
+ ```
373
+
374
+ ## 9. Command Design
375
+
376
+ ### 9.1 `skill-flow add`
377
+
378
+ ```bash
379
+ skill-flow add <locator>
380
+ [--path <repoSubpath>]
381
+ [--channel <channel...>]
382
+ [--yes]
383
+ [--json]
384
+ ```
385
+
386
+ Supported locators:
387
+ - GitHub shorthand: `owner/repo`
388
+ - full Git URL
389
+ - SSH Git URL
390
+ - local path
391
+ - GitHub tree URL
392
+ - `clawhub:<slug>`
393
+ - `clawhub:<slug>@<version>`
394
+
395
+ Behavior:
396
+ - detect source kind before fetch
397
+ - normalize source identity
398
+ - for GitHub tree URL:
399
+ - resolve repo locator
400
+ - extract subpath as `--path` intent
401
+ - for `--path`:
402
+ - narrow the initial result to matching leafs
403
+ - do not create a distinct source identity
404
+ - for `--channel`:
405
+ - reuse existing apply flow after add
406
+
407
+ ### 9.2 `skill-flow find`
408
+
409
+ ```bash
410
+ skill-flow find <query>
411
+ [--source local|clawhub|all]
412
+ [--limit <n>]
413
+ [--json]
414
+ ```
415
+
416
+ Behavior:
417
+ - default source is `all`
418
+ - search local inventory and ClawHub metadata
419
+ - return structured candidates
420
+ - annotate installed matches
421
+ - show exact follow-up `add` command for each result
422
+
423
+ ### 9.3 `skill-flow search`
424
+
425
+ ```bash
426
+ skill-flow search <query>
427
+ ```
428
+
429
+ Behavior:
430
+ - exact alias of `find`
431
+ - same output shape
432
+ - same options
433
+
434
+ ## 10. Data Model Changes
435
+
436
+ ### 10.1 Source kinds
437
+
438
+ ```ts
439
+ type SourceKind = "git" | "clawhub";
440
+ ```
441
+
442
+ ### 10.2 Source manifest
443
+
444
+ Keep current manifest structure.
445
+ Extend only enough to allow:
446
+ - `kind = "git" | "clawhub"`
447
+ - normalized locators for ClawHub
448
+
449
+ ### 10.3 Source lock
450
+
451
+ Keep one `sources[]` array.
452
+ Do not split by kind.
453
+
454
+ Required fields:
455
+ - shared:
456
+ - `id`
457
+ - `locator`
458
+ - `kind`
459
+ - `displayName`
460
+ - `checkoutPath`
461
+ - `updatedAt`
462
+ - `leafIds`
463
+ - `invalidLeafs`
464
+
465
+ - Git-specific:
466
+ - `commitSha`
467
+
468
+ - ClawHub-specific:
469
+ - `packageSlug`
470
+ - `resolvedVersion`
471
+ - `contentHash`
472
+ - `versionMode`
473
+
474
+ `versionMode` is:
475
+ - `pinned`
476
+ - `floating`
477
+
478
+ ### 10.4 `SkillCandidate`
479
+
480
+ `SkillCandidate` is an internal result object for `find`.
481
+
482
+ Group fields by responsibility.
483
+
484
+ Identity:
485
+ - `candidateId`
486
+ - `sourceKind`
487
+ - `locator`
488
+ - `skillPath?`
489
+ - `version?`
490
+
491
+ Display:
492
+ - `title`
493
+ - `summary`
494
+ - `official`
495
+ - `alreadyInstalled`
496
+ - `installedSourceId?`
497
+
498
+ Action:
499
+ - `installCommand`
500
+
501
+ Internal-only:
502
+ - `score`
503
+
504
+ Rules:
505
+ - `score` is not a stable public contract
506
+ - do not add leaderboard or popularity fields in this release
507
+
508
+ ## 11. Ranking Rules For `find`
509
+
510
+ Do not implement free-form numeric tuning first.
511
+ Implement a rule table.
512
+
513
+ Ordering rules:
514
+
515
+ ```text
516
+ Step 1: group by trust tier
517
+ Tier 0 = local installed inventory
518
+ Tier 1 = ClawHub registry results
519
+
520
+ Step 2: within a tier, exact token overlap beats partial overlap
521
+
522
+ Step 3: installed exact match beats installed partial match
523
+
524
+ Step 4: remote result with exact title/path match beats remote partial text match
525
+
526
+ Step 5: stable tie-break by:
527
+ sourceKind
528
+ title
529
+ locator
530
+ ```
531
+
532
+ Notes:
533
+ - no broad Git host search in `v1.0.1`
534
+ - `score` may exist internally, but implementation must preserve the rule table above
535
+
536
+ ## 12. Implementation Plan
537
+
538
+ ### Phase 0: Naming And Path Alignment
539
+
540
+ Goal:
541
+ - remove naming drift before new behavior lands
542
+
543
+ Tasks:
544
+ - align plan, README, and implementation on `skill-flow`
545
+ - align state root references on `~/.skillflow/`
546
+ - align env var references on `SKILL_FLOW_*`
547
+ - document that any future rename is out of scope
548
+
549
+ Exit criteria:
550
+ - no mixed `skill-manager` / `skill-flow` references remain in the active implementation plan
551
+
552
+ ### Phase 1: Source Storage And Resolver Refactor
553
+
554
+ Goal:
555
+ - make source ingestion multi-kind without broad refactor
556
+
557
+ Tasks:
558
+ - make `StateStore` source-kind aware
559
+ - add a source-kind resolver
560
+ - keep orchestration in `SourceService`
561
+ - extract only source-specific IO seam
562
+ - preserve existing Git behavior
563
+
564
+ Exit criteria:
565
+ - current Git add/update/uninstall tests still pass
566
+ - source cache path is resolved by store, not by callers
567
+
568
+ ### Phase 2: ClawHub Source Support
569
+
570
+ Goal:
571
+ - support ClawHub as a real source kind in local state
572
+
573
+ Tasks:
574
+ - parse `clawhub:<slug>`
575
+ - parse `clawhub:<slug>@<version>`
576
+ - fetch source bundle into `source/clawhub/<source-id>`
577
+ - persist ClawHub lock metadata
578
+ - support update semantics:
579
+ - floating source resolves latest only on `update`
580
+ - pinned source remains pinned
581
+ - support uninstall through the existing source lifecycle path
582
+
583
+ Exit criteria:
584
+ - add works for floating and pinned ClawHub locators
585
+ - update differentiates pinned and floating behavior
586
+ - uninstall removes ClawHub cache and deployments cleanly
587
+
588
+ ### Phase 3: Git Path-Scoped Add
589
+
590
+ Goal:
591
+ - support Git installs that begin from a repo subpath
592
+
593
+ Tasks:
594
+ - support `--path`
595
+ - parse GitHub tree URLs into repo + path intent
596
+ - validate whether requested path maps to:
597
+ - a valid leaf
598
+ - or a valid source subtree
599
+ - reject existing-but-invalid paths clearly
600
+ - preserve source identity without duplicating the repo
601
+
602
+ Exit criteria:
603
+ - repo path installs work without duplicating source identity
604
+ - same repo cannot be registered twice by changing only `--path`
605
+
606
+ ### Phase 4: Discovery
607
+
608
+ Goal:
609
+ - provide a small, reliable discovery entrypoint
610
+
611
+ Tasks:
612
+ - add `find`
613
+ - add `search` alias
614
+ - build local inventory matcher
615
+ - build ClawHub metadata search integration
616
+ - merge candidates
617
+ - rank by the explicit rule table
618
+ - annotate installed state
619
+ - use the shared candidate-to-command builder for all outputs
620
+
621
+ Exit criteria:
622
+ - local-only results work
623
+ - remote-only results work
624
+ - mixed local+remote results are stable
625
+ - every actionable result produces a correct `add` command
626
+
627
+ ### Phase 5: Docs And Verification
628
+
629
+ Goal:
630
+ - make the release verifiable and understandable
631
+
632
+ Tasks:
633
+ - update README command examples
634
+ - update help text
635
+ - add diagrams to the plan
636
+ - add any inline ASCII diagrams needed in touched implementation files
637
+ - expand tests for new branches and failure modes
638
+
639
+ Exit criteria:
640
+ - command surface and docs match implementation
641
+ - new codepaths are covered by tests, not just happy paths
642
+
643
+ ## 13. Test Plan
644
+
645
+ ### 13.1 New flow diagram
646
+
647
+ ```text
648
+ A. Expanded add
649
+ git shorthand/url/local path/tree url
650
+ clawhub slug / slug@version
651
+ optional --path filter
652
+
653
+ B. Discovery
654
+ local inventory
655
+ remote clawhub metadata
656
+ merge
657
+ rank
658
+ command build
659
+
660
+ C. Mixed state
661
+ git-only old state
662
+ git + clawhub new state
663
+ update / uninstall / reconcile
664
+ ```
665
+
666
+ ### 13.2 Required unit tests
667
+
668
+ - locator parsing
669
+ - Git shorthand
670
+ - Git URL
671
+ - local path
672
+ - GitHub tree URL
673
+ - ClawHub floating
674
+ - ClawHub pinned
675
+
676
+ - ranking rule table
677
+ - local exact > local partial
678
+ - local > remote
679
+ - remote exact > remote partial
680
+ - stable tie-break order
681
+
682
+ - candidate-to-command builder
683
+ - Git candidate
684
+ - Git candidate with path
685
+ - ClawHub floating candidate
686
+ - ClawHub pinned candidate
687
+
688
+ ### 13.3 Required integration tests
689
+
690
+ - add Git source by shorthand / URL / local path
691
+ - add GitHub tree URL
692
+ - add Git source with `--path`
693
+ - reject `--path` when it exists but is not a valid skill root
694
+ - reject duplicate repo registration when only `--path` differs
695
+
696
+ - add ClawHub floating source
697
+ - add ClawHub pinned source
698
+ - reject missing ClawHub package
699
+ - reject ClawHub bundle with zero valid skills
700
+
701
+ - update floating ClawHub source to newer version
702
+ - keep pinned ClawHub source fixed on update
703
+ - uninstall ClawHub source cleanly
704
+
705
+ - `find` local-only hit
706
+ - `find` remote-only hit
707
+ - `find` mixed local+remote hit
708
+ - `search` alias parity with `find`
709
+ - `find --json` output shape
710
+
711
+ ### 13.4 Required failure-path tests
712
+
713
+ - local inventory success + remote ClawHub failure -> return local results with warning
714
+ - local empty + remote ClawHub failure -> clear error
715
+ - malformed remote candidate payload -> clear drop/error behavior
716
+ - failed ClawHub fetch must not dirty manifest/lock
717
+ - mixed git + clawhub state survives:
718
+ - list
719
+ - update
720
+ - uninstall
721
+ - reconcile
722
+
723
+ ### 13.5 Backward compatibility tests
724
+
725
+ - old git-only lock remains readable
726
+ - optional ClawHub lock fields do not break Git-only reads
727
+ - mixed git/clawhub sources coexist in one lock file
728
+
729
+ ## 14. Failure Modes
730
+
731
+ | Codepath | Realistic failure | Test required | Error handling required | User-visible outcome |
732
+ |---|---|---:|---:|---|
733
+ | Git `add --path` | path exists but is not a valid skill root | yes | yes | clear validation error |
734
+ | ClawHub `add` | package found but bundle has no valid skills | yes | yes | clear add failure |
735
+ | ClawHub `update` | resolved version changes but lock/inventory diverge | yes | yes | clear update failure, no partial state |
736
+ | `find` | remote search fails | yes | yes | warning + partial results, or clear error |
737
+ | command builder | wrong follow-up `add` command | yes | yes | no silent mismatch |
738
+ | mixed-state reconcile | Git-only assumptions break ClawHub records | yes | yes | no silent corruption |
739
+
740
+ Critical rule:
741
+ - if a failure mode has no test and no clear user-visible error, implementation is not done
742
+
743
+ ## 15. Open Questions And Locked Recommendations
744
+
745
+ ### 15.1 ClawHub fetch method
746
+
747
+ Question:
748
+ - use documented HTTP contract directly, or shell out to CLI?
749
+
750
+ Locked recommendation:
751
+ - prefer documented HTTP / bundle fetch directly
752
+ - CLI bridge is fallback only if HTTP contract is incomplete
753
+
754
+ ### 15.2 Path-scoped add semantics
755
+
756
+ Question:
757
+ - should `--path` auto-select and auto-bind the leaf?
758
+
759
+ Locked recommendation:
760
+ - no hidden auto-apply
761
+ - use `--path` only to narrow the add result / optional persisted preference
762
+ - let `config` remain the binding surface
763
+
764
+ ### 15.3 Floating ClawHub version policy
765
+
766
+ Question:
767
+ - when should a floating source advance?
768
+
769
+ Locked recommendation:
770
+ - resolve version on add
771
+ - persist resolved version in lock
772
+ - only advance on explicit `update`
773
+
774
+ ## 16. Inline Diagram Targets In Code
775
+
776
+ When implementing this plan, add or update inline ASCII diagrams in:
777
+
778
+ - [src/services/source-service.ts](/Users/Vint/仓库/03%20Project/skill-manager/src/services/source-service.ts)
779
+ For:
780
+ - source resolve -> fetch -> scan -> persist pipeline
781
+
782
+ - [src/services/skill-flow.ts](/Users/Vint/仓库/03%20Project/skill-manager/src/services/skill-flow.ts)
783
+ For:
784
+ - `find` orchestration
785
+ - candidate -> command output flow
786
+
787
+ - new ranking / command-builder files
788
+ For:
789
+ - ranking rule table
790
+ - candidate-to-command decision tree
791
+
792
+ ## 17. Definition Of Done
793
+
794
+ `v1.0.1` is done when all of the following are true:
795
+
796
+ - naming and state-root references are aligned on `skill-flow`
797
+ - source cache layout is `source/<kind>/<source-id>`
798
+ - `add` supports Git and ClawHub locators
799
+ - `add` supports repo subpath intent without duplicating source identity
800
+ - `find` exists
801
+ - `search` aliases to `find`
802
+ - `find` merges local inventory and ClawHub metadata
803
+ - ranking follows the explicit rule table
804
+ - all `find` outputs use the shared candidate-to-command builder
805
+ - partial remote failure behavior is implemented and tested
806
+ - mixed git/clawhub lock state is implemented and tested
807
+ - docs match the shipped command surface
808
+
809
+ ## 18. References
810
+
811
+ - <https://github.com/vercel-labs/skills>
812
+ - <https://github.com/vercel-labs/skills/tree/main/skills/find-skills>
813
+ - <https://github.com/openai/skills/blob/main/skills/.system/skill-installer/SKILL.md>
814
+ - <https://docs.openclaw.ai/tools/clawhub>