skilld 2.1.0 → 2.2.0

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 (40) hide show
  1. package/README.md +69 -0
  2. package/dist/_chunks/add.mjs +1 -1
  3. package/dist/_chunks/agent-prompt.mjs +1 -1
  4. package/dist/_chunks/agent.mjs +3 -8
  5. package/dist/_chunks/agent.mjs.map +1 -1
  6. package/dist/_chunks/author.mjs +2 -1
  7. package/dist/_chunks/author.mjs.map +1 -1
  8. package/dist/_chunks/cache.mjs +4 -129
  9. package/dist/_chunks/cache.mjs.map +1 -1
  10. package/dist/_chunks/core.mjs +1 -1
  11. package/dist/_chunks/eject.mjs +1 -1
  12. package/dist/_chunks/embedding-cache2.mjs +12 -11
  13. package/dist/_chunks/embedding-cache2.mjs.map +1 -1
  14. package/dist/_chunks/index-identity.mjs +365 -0
  15. package/dist/_chunks/index-identity.mjs.map +1 -0
  16. package/dist/_chunks/index-identity2.mjs +2 -0
  17. package/dist/_chunks/install-many.mjs +2 -1
  18. package/dist/_chunks/install-many.mjs.map +1 -1
  19. package/dist/_chunks/install.mjs +2 -1
  20. package/dist/_chunks/install.mjs.map +1 -1
  21. package/dist/_chunks/pipeline.mjs +6 -2
  22. package/dist/_chunks/pipeline.mjs.map +1 -1
  23. package/dist/_chunks/portable.mjs +2 -1
  24. package/dist/_chunks/portable.mjs.map +1 -1
  25. package/dist/_chunks/retriv.mjs +2 -2
  26. package/dist/_chunks/retriv2.mjs +21 -3
  27. package/dist/_chunks/retriv2.mjs.map +1 -1
  28. package/dist/_chunks/semver.mjs.map +1 -1
  29. package/dist/_chunks/skill-installer2.mjs +1 -1
  30. package/dist/_chunks/sync.mjs +2 -1
  31. package/dist/_chunks/sync.mjs.map +1 -1
  32. package/dist/_chunks/uninstall.mjs +2 -1
  33. package/dist/_chunks/uninstall.mjs.map +1 -1
  34. package/dist/_chunks/update.mjs +1 -1
  35. package/dist/_chunks/wizard2.mjs +1 -1
  36. package/dist/cli.mjs +73 -1
  37. package/dist/cli.mjs.map +1 -1
  38. package/dist/retriv/worker.mjs +11 -5
  39. package/dist/retriv/worker.mjs.map +1 -1
  40. package/package.json +14 -13
package/README.md CHANGED
@@ -239,6 +239,75 @@ Generation runs locally: free, offline, no API key. Unlike the CLI and API backe
239
239
 
240
240
  The large default context can exceed memory for big models on constrained hardware (Ollama returns a 500). Lower `OLLAMA_NUM_CTX` or pick a smaller model if generation fails to load.
241
241
 
242
+ ### Embedding Model
243
+
244
+ `skilld search` is powered by a local embedding model. It runs offline through transformers.js. It needs no API key or network traffic after the first download. Pick one under **Embedding model** in `skilld config`:
245
+
246
+ | Model | Dimensions | Notes |
247
+ |-------|-----------:|-------|
248
+ | `bge-small-en-v1.5` | 384 | Default. Fastest to index, smallest download. |
249
+ | `bge-base-en-v1.5` | 768 | Balanced accuracy and speed. |
250
+ | `Xenova/bge-large-en-v1.5` | 1024 | Most accurate English retrieval, slowest to index. |
251
+ | `bge-m3` | 1024 | Multilingual, 8192-token context. |
252
+
253
+ Larger models retrieve more accurately but cost more time and memory when indexing. Locally-pulled [Ollama](#ollama-embedding-models) models can be used too. Export `SKILLD_EMBED_MODEL` to override the saved setting for every index and search command in the current shell:
254
+
255
+ ```bash
256
+ export SKILLD_EMBED_MODEL=bge-m3
257
+ skilld update
258
+ ```
259
+
260
+ Search indexes must use one embedding model and device. Rebuild them after switching either setting:
261
+
262
+ ```bash
263
+ skilld update
264
+ ```
265
+
266
+ ### Ollama Embedding Models
267
+
268
+ If [Ollama](https://ollama.com) is running, locally-pulled embedding models appear in the **Embedding model** picker alongside the built-in ones. They are addressed as `ollama:<name>`, matching the `-m ollama:<name>` syntax used for enhancement models:
269
+
270
+ ```bash
271
+ ollama pull qwen3-embedding
272
+ SKILLD_EMBED_MODEL=ollama:qwen3-embedding skilld add npm:vue
273
+ ```
274
+
275
+ Only models that advertise the `embedding` capability are listed, so chat models cannot be selected by mistake. Dimensions and context length are read from Ollama. skilld validates each vector before indexing.
276
+
277
+ This talks to Ollama's HTTP API directly. It needs no additional dependency or API key. Set `OLLAMA_HOST` to point at a non-default daemon. If Ollama is not running, the picker simply shows the built-in models.
278
+
279
+ Ollama manages its own execution device, so **Embedding device** does not apply to `ollama:` models.
280
+
281
+ ### Embedding Device
282
+
283
+ The embedding model runs on the CPU by default. **Embedding device** in `skilld config` moves it onto a GPU backend, which can be substantially faster:
284
+
285
+ | Device | Notes |
286
+ |--------|-------|
287
+ | `auto` | Default. Lets transformers.js choose; CPU under Node. |
288
+ | `cpu` | Always available, predictable. |
289
+ | `webgpu` | Fastest on Apple Silicon in testing. |
290
+ | `coreml` | Apple Neural Engine. Measured slower than CPU for these models. |
291
+
292
+ Measured on an Apple M5 Max, 120 documents, best of 3 after warm-up (docs/sec):
293
+
294
+ | Model | `cpu` | `coreml` | `webgpu` |
295
+ |-------|------:|---------:|---------:|
296
+ | `bge-small-en-v1.5` | 664 | 198 | **1713** |
297
+ | `bge-base-en-v1.5` | 198 | 68 | **580** |
298
+ | `Xenova/bge-large-en-v1.5` | 71 | 9 | **201** |
299
+
300
+ WebGPU was 2.6 to 2.9 times faster than CPU at every size. On WebGPU, `bge-large` indexed faster than `bge-base` on CPU and improved retrieval. CoreML was consistently slower.
301
+
302
+ The ranking is hardware-specific, so benchmark before trusting a device on other machines. Export `SKILLD_EMBED_DEVICE` to override the saved setting in the current shell:
303
+
304
+ ```bash
305
+ export SKILLD_EMBED_DEVICE=cpu
306
+ skilld update
307
+ ```
308
+
309
+ If a backend is unavailable, indexing fails to start. Switch back to `auto`.
310
+
242
311
  ### Eject
243
312
 
244
313
  Export a skill as a portable, self-contained directory for sharing via git repos:
@@ -1,5 +1,5 @@
1
+ import { hasCompletedWizard } from "./index-identity.mjs";
1
2
  import { COMMA_OR_WHITESPACE_RE } from "./regex.mjs";
2
- import { hasCompletedWizard } from "./cache.mjs";
3
3
  import { autoResolveAgent } from "./agent-prompt.mjs";
4
4
  import { sharedArgs } from "./args.mjs";
5
5
  import { parseSkillInput } from "./semver.mjs";
@@ -1,6 +1,6 @@
1
1
  import { detectInstalledAgents, detectProjectAgents, detectTargetAgent, targets } from "./detect.mjs";
2
2
  import "./agent.mjs";
3
- import { readConfig, updateConfig } from "./cache.mjs";
3
+ import { readConfig, updateConfig } from "./index-identity.mjs";
4
4
  import { isInteractive } from "./env.mjs";
5
5
  import { styleText } from "node:util";
6
6
  import * as p from "@clack/prompts";
@@ -1,7 +1,8 @@
1
1
  import { detectInstalledAgents, targets } from "./detect.mjs";
2
2
  import { SECTION_MERGE_ORDER, SECTION_OUTPUT_FILES, buildAllSectionPrompts, getSectionValidator, resolveSkilldCommand, wrapSection } from "./prompts.mjs";
3
+ import { ollamaHost } from "./index-identity.mjs";
3
4
  import { CACHE_DIR, LLM_CACHE_DIR, PI_AI_AUTH_PATH, skillInternalDir, skillLogDir } from "./paths.mjs";
4
- import { API_CHANGE_BULLET_RE, SECTION_HEADING_RE, SOURCE_LINK_RE, TRAILING_SLASH_RE as TRAILING_SLASH_RE$1 } from "./regex.mjs";
5
+ import { API_CHANGE_BULLET_RE, SECTION_HEADING_RE, SOURCE_LINK_RE, TRAILING_SLASH_RE } from "./regex.mjs";
5
6
  import { sanitizeMarkdown } from "./sanitize.mjs";
6
7
  import { createReferenceCache, getSkillReferenceDirs } from "./cache.mjs";
7
8
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
@@ -393,12 +394,6 @@ function isOllamaModel(model) {
393
394
  function parseOllamaModelId(model) {
394
395
  return isOllamaModel(model) ? model.slice(7) : null;
395
396
  }
396
- const HAS_SCHEME_RE = /^https?:\/\//;
397
- const TRAILING_SLASH_RE = /\/$/;
398
- function ollamaHost() {
399
- const raw = process.env.OLLAMA_HOST || "http://localhost:11434";
400
- return (HAS_SCHEME_RE.test(raw) ? raw : `http://${raw}`).replace(TRAILING_SLASH_RE, "");
401
- }
402
397
  async function isCompletionModel(name) {
403
398
  const res = await fetch(`${ollamaHost()}/api/show`, {
404
399
  method: "POST",
@@ -812,7 +807,7 @@ function executeTool(toolCall, skilldDir) {
812
807
  else results.push(`./.skilld/${relPath}`);
813
808
  }
814
809
  };
815
- const baseDir = pattern.split("*")[0]?.replace(TRAILING_SLASH_RE$1, "") ?? "";
810
+ const baseDir = pattern.split("*")[0]?.replace(TRAILING_SLASH_RE, "") ?? "";
816
811
  walkDir(join(skilldDir, baseDir), baseDir);
817
812
  const matched = results.filter((r) => globMatch(r.replace(STATIC_REGEX_1$3, ""), pattern));
818
813
  return matched.length > 0 ? matched.join("\n") : `No files matching: ${args.pattern}`;