skilld 1.7.4 → 2.1.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.
- package/README.md +25 -0
- package/dist/_chunks/add.mjs +67 -0
- package/dist/_chunks/add.mjs.map +1 -0
- package/dist/_chunks/agent-prompt.mjs +88 -0
- package/dist/_chunks/agent-prompt.mjs.map +1 -0
- package/dist/_chunks/agent.mjs +359 -157
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/args.mjs +42 -0
- package/dist/_chunks/args.mjs.map +1 -0
- package/dist/_chunks/assemble.mjs +12 -9
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +35 -19
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +153 -185
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +9 -8
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/client.mjs +118 -0
- package/dist/_chunks/client.mjs.map +1 -0
- package/dist/_chunks/core.mjs +5 -5
- package/dist/_chunks/detect.mjs +54 -44
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/detect2.mjs +1 -1
- package/dist/_chunks/eject.mjs +69 -0
- package/dist/_chunks/eject.mjs.map +1 -0
- package/dist/_chunks/embedding-cache.mjs +1 -1
- package/dist/_chunks/embedding-cache2.mjs +2 -2
- package/dist/_chunks/embedding-cache2.mjs.map +1 -1
- package/dist/_chunks/env.mjs +19 -0
- package/dist/_chunks/env.mjs.map +1 -0
- package/dist/_chunks/install-many.mjs +377 -0
- package/dist/_chunks/install-many.mjs.map +1 -0
- package/dist/_chunks/install.mjs +93 -334
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/intro.mjs +63 -0
- package/dist/_chunks/intro.mjs.map +1 -0
- package/dist/_chunks/list.mjs +5 -4
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +10 -7
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/login.mjs +234 -0
- package/dist/_chunks/login.mjs.map +1 -0
- package/dist/_chunks/logout.mjs +27 -0
- package/dist/_chunks/logout.mjs.map +1 -0
- package/dist/_chunks/map.mjs +11 -0
- package/dist/_chunks/map.mjs.map +1 -0
- package/dist/_chunks/markdown.mjs +81 -56
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/menu.mjs +33 -0
- package/dist/_chunks/menu.mjs.map +1 -0
- package/dist/_chunks/model-picker.mjs +61 -0
- package/dist/_chunks/model-picker.mjs.map +1 -0
- package/dist/_chunks/monorepo.mjs +7 -4
- package/dist/_chunks/monorepo.mjs.map +1 -1
- package/dist/_chunks/package-json.mjs +7 -5
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/paths.mjs +3 -5
- package/dist/_chunks/paths.mjs.map +1 -1
- package/dist/_chunks/{sync-pipeline.mjs → pipeline.mjs} +360 -323
- package/dist/_chunks/pipeline.mjs.map +1 -0
- package/dist/_chunks/pool.mjs +1 -1
- package/dist/_chunks/pool2.mjs +2 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/portable.mjs +151 -0
- package/dist/_chunks/portable.mjs.map +1 -0
- package/dist/_chunks/prepare-hook.mjs +2 -0
- package/dist/_chunks/prepare-hook2.mjs +61 -0
- package/dist/_chunks/prepare-hook2.mjs.map +1 -0
- package/dist/_chunks/prepare.mjs +58 -8
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +14 -11
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +488 -76
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/pull.mjs +220 -0
- package/dist/_chunks/pull.mjs.map +1 -0
- package/dist/_chunks/regex.mjs +19 -0
- package/dist/_chunks/regex.mjs.map +1 -0
- package/dist/_chunks/retriv.mjs +2 -171
- package/dist/_chunks/retriv2.mjs +159 -0
- package/dist/_chunks/retriv2.mjs.map +1 -0
- package/dist/_chunks/sanitize.mjs +13 -10
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +11 -9
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +25 -22
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +6 -6
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/semver.mjs +2793 -5
- package/dist/_chunks/semver.mjs.map +1 -1
- package/dist/_chunks/skill-installer.mjs +1 -1
- package/dist/_chunks/skill-installer2.mjs +31 -23
- package/dist/_chunks/skill-installer2.mjs.map +1 -1
- package/dist/_chunks/skills.mjs +9 -10
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/store.mjs +107 -0
- package/dist/_chunks/store.mjs.map +1 -0
- package/dist/_chunks/sync.mjs +422 -915
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +2 -5
- package/dist/_chunks/telemetry.mjs +26 -0
- package/dist/_chunks/telemetry.mjs.map +1 -0
- package/dist/_chunks/uninstall.mjs +38 -32
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/update.mjs +172 -0
- package/dist/_chunks/update.mjs.map +1 -0
- package/dist/_chunks/upload.mjs +16 -13
- package/dist/_chunks/upload.mjs.map +1 -1
- package/dist/_chunks/validate.mjs +1 -1
- package/dist/_chunks/validate.mjs.map +1 -1
- package/dist/_chunks/version.mjs +16 -17
- package/dist/_chunks/version.mjs.map +1 -1
- package/dist/_chunks/whoami.mjs +21 -0
- package/dist/_chunks/whoami.mjs.map +1 -0
- package/dist/_chunks/wizard.mjs +2 -190
- package/dist/_chunks/wizard2.mjs +200 -0
- package/dist/_chunks/wizard2.mjs.map +1 -0
- package/dist/_chunks/yaml.mjs +1 -1
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/cli-entry.d.mts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +94 -71
- package/dist/cli.mjs.map +1 -1
- package/dist/prepare.d.mts +1 -1
- package/dist/prepare.mjs +9 -6
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/worker.d.mts +5 -1
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +1 -1
- package/dist/retriv/worker.mjs.map +1 -1
- package/package.json +27 -37
- package/dist/_chunks/author-group.mjs +0 -17
- package/dist/_chunks/author-group.mjs.map +0 -1
- package/dist/_chunks/cli-helpers.mjs +0 -335
- package/dist/_chunks/cli-helpers.mjs.map +0 -1
- package/dist/_chunks/cli-helpers2.mjs +0 -2
- package/dist/_chunks/index.d.mts +0 -344
- package/dist/_chunks/index.d.mts.map +0 -1
- package/dist/_chunks/index2.d.mts +0 -279
- package/dist/_chunks/index2.d.mts.map +0 -1
- package/dist/_chunks/index3.d.mts +0 -44
- package/dist/_chunks/index3.d.mts.map +0 -1
- package/dist/_chunks/index4.d.mts +0 -553
- package/dist/_chunks/index4.d.mts.map +0 -1
- package/dist/_chunks/package-registry.mjs +0 -465
- package/dist/_chunks/package-registry.mjs.map +0 -1
- package/dist/_chunks/retriv.mjs.map +0 -1
- package/dist/_chunks/setup.mjs +0 -17
- package/dist/_chunks/setup.mjs.map +0 -1
- package/dist/_chunks/sources.mjs +0 -2654
- package/dist/_chunks/sources.mjs.map +0 -1
- package/dist/_chunks/sync-pipeline.mjs.map +0 -1
- package/dist/_chunks/sync-registry.mjs +0 -65
- package/dist/_chunks/sync-registry.mjs.map +0 -1
- package/dist/_chunks/types.d.mts +0 -76
- package/dist/_chunks/types.d.mts.map +0 -1
- package/dist/_chunks/types2.d.mts +0 -88
- package/dist/_chunks/types2.d.mts.map +0 -1
- package/dist/_chunks/wizard.mjs.map +0 -1
- package/dist/agent/index.d.mts +0 -2
- package/dist/agent/index.mjs +0 -4
- package/dist/cache/index.d.mts +0 -2
- package/dist/cache/index.mjs +0 -5
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -6
- package/dist/retriv/index.d.mts +0 -3
- package/dist/retriv/index.mjs +0 -2
- package/dist/sources/index.d.mts +0 -3
- package/dist/sources/index.mjs +0 -3
- package/dist/types.d.mts +0 -4
- package/dist/types.mjs +0 -1
package/README.md
CHANGED
|
@@ -222,6 +222,23 @@ skilld author assemble
|
|
|
222
222
|
|
|
223
223
|
`skilld author assemble` auto-discovers skills with pending output files. `skilld update` re-exports prompts for outdated packages.
|
|
224
224
|
|
|
225
|
+
### Local Models (Ollama)
|
|
226
|
+
|
|
227
|
+
If [Ollama](https://ollama.com) is running, skilld auto-detects your locally-pulled text models and lists them in `skilld config` (and `-m ollama:<name>`):
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
skilld add npm:vue -m ollama:qwen2.5:14b-instruct
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Generation runs locally: free, offline, no API key. Unlike the CLI and API backends, the Ollama path is one-shot (it does not explore reference files with tools), so all source material is inlined into a single prompt. Best paired with a capable instruct model.
|
|
234
|
+
|
|
235
|
+
| Env var | Default | Purpose |
|
|
236
|
+
|---------|---------|---------|
|
|
237
|
+
| `OLLAMA_HOST` | `http://localhost:11434` | Ollama daemon address |
|
|
238
|
+
| `OLLAMA_NUM_CTX` | `32768` | Context window; sized to fit the full prompt + output |
|
|
239
|
+
|
|
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
|
+
|
|
225
242
|
### Eject
|
|
226
243
|
|
|
227
244
|
Export a skill as a portable, self-contained directory for sharing via git repos:
|
|
@@ -253,6 +270,14 @@ Share via `skilld add gh:owner/repo` - consumers get fully functional skills wit
|
|
|
253
270
|
|
|
254
271
|
Ship skills with your npm package so consumers get them automatically. No LLM needed on their end.
|
|
255
272
|
|
|
273
|
+
Install the official publication workflow for authoring, validation, packaging, and postpublish verification:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npx skilld add gh:skilld-dev/skills --skill publish-skill --yes
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The skill orchestrates publication. `skilld author package` remains the deterministic package documentation generator it invokes.
|
|
280
|
+
|
|
256
281
|
### Generate a skill
|
|
257
282
|
|
|
258
283
|
From your package root (or monorepo root):
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { COMMA_OR_WHITESPACE_RE } from "./regex.mjs";
|
|
2
|
+
import { hasCompletedWizard } from "./cache.mjs";
|
|
3
|
+
import { autoResolveAgent } from "./agent-prompt.mjs";
|
|
4
|
+
import { sharedArgs } from "./args.mjs";
|
|
5
|
+
import { parseSkillInput } from "./semver.mjs";
|
|
6
|
+
import { runWizard } from "./wizard2.mjs";
|
|
7
|
+
import { installSkills } from "./install-many.mjs";
|
|
8
|
+
import { exportPortablePrompts } from "./portable.mjs";
|
|
9
|
+
import * as p from "@clack/prompts";
|
|
10
|
+
import { defineCommand } from "citty";
|
|
11
|
+
const addCommandDef = defineCommand({
|
|
12
|
+
meta: {
|
|
13
|
+
name: "add",
|
|
14
|
+
description: "Install skills (npm:<pkg>, crate:<name>, gh:<owner/repo>, @<curator>)"
|
|
15
|
+
},
|
|
16
|
+
args: {
|
|
17
|
+
"package": {
|
|
18
|
+
type: "positional",
|
|
19
|
+
description: "Package(s) to sync (space/comma-separated; npm:<pkg>, crate:<name>, or owner/repo)",
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
"skill": {
|
|
23
|
+
type: "string",
|
|
24
|
+
alias: "s",
|
|
25
|
+
description: "Select specific skills from a git repo (comma-separated)",
|
|
26
|
+
valueHint: "name"
|
|
27
|
+
},
|
|
28
|
+
"allow-unsafe": {
|
|
29
|
+
type: "boolean",
|
|
30
|
+
description: "Install skills that fail the upstream audit gate"
|
|
31
|
+
},
|
|
32
|
+
...sharedArgs
|
|
33
|
+
},
|
|
34
|
+
async run({ args }) {
|
|
35
|
+
const rawInputs = [...new Set([args.package, ...args._ || []].map((s) => s.trim()).filter(Boolean))];
|
|
36
|
+
if (args.agent === "none") {
|
|
37
|
+
const packages = [...new Set(rawInputs.flatMap((s) => s.split(COMMA_OR_WHITESPACE_RE)).map((s) => s.trim()).filter(Boolean))];
|
|
38
|
+
for (const pkg of packages) await exportPortablePrompts(pkg, {
|
|
39
|
+
force: args.force,
|
|
40
|
+
agent: "none"
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const agent = autoResolveAgent(args.agent);
|
|
45
|
+
if (!agent) {
|
|
46
|
+
p.log.error("No target agent detected.\n Pass --agent <name> (claude-code, cursor, codex, …) or run `skilld config` to set a default.\n Use --agent none for portable export.");
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!hasCompletedWizard()) await runWizard({ agent });
|
|
51
|
+
const items = rawInputs.map(parseSkillInput);
|
|
52
|
+
await installSkills(items, {
|
|
53
|
+
agent,
|
|
54
|
+
surface: "cli:add",
|
|
55
|
+
global: args.global,
|
|
56
|
+
yes: args.yes,
|
|
57
|
+
force: args.force,
|
|
58
|
+
debug: args.debug,
|
|
59
|
+
model: args.model,
|
|
60
|
+
skillFilter: args.skill,
|
|
61
|
+
allowUnsafe: args["allow-unsafe"]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
export { addCommandDef };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=add.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.mjs","names":[],"sources":["../../src/commands/sync/add.ts"],"sourcesContent":["import type { AgentType, OptimizeModel } from '../../agent/index.ts'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { autoResolveAgent } from '../../cli/agent-prompt.ts'\nimport { sharedArgs } from '../../cli/args.ts'\nimport { hasCompletedWizard } from '../../core/config.ts'\nimport { parseSkillInput } from '../../core/prefix.ts'\nimport { COMMA_OR_WHITESPACE_RE } from '../../core/regex.ts'\nimport { runWizard } from '../wizard.ts'\nimport { installSkills } from './install-many.ts'\nimport { exportPortablePrompts } from './portable.ts'\n\nexport const addCommandDef = defineCommand({\n meta: { name: 'add', description: 'Install skills (npm:<pkg>, crate:<name>, gh:<owner/repo>, @<curator>)' },\n args: {\n 'package': {\n type: 'positional',\n description: 'Package(s) to sync (space/comma-separated; npm:<pkg>, crate:<name>, or owner/repo)',\n required: true,\n },\n 'skill': {\n type: 'string',\n alias: 's',\n description: 'Select specific skills from a git repo (comma-separated)',\n valueHint: 'name',\n },\n 'allow-unsafe': {\n type: 'boolean',\n description: 'Install skills that fail the upstream audit gate',\n },\n ...sharedArgs,\n },\n async run({ args }) {\n const rawInputs = [...new Set(\n [args.package, ...((args as any)._ || [])]\n .map((s: string) => s.trim())\n .filter(Boolean),\n )]\n\n // --agent none → portable export (no installed-agent target needed).\n if (args.agent === 'none') {\n const packages = [...new Set(rawInputs.flatMap(s => s.split(COMMA_OR_WHITESPACE_RE)).map(s => s.trim()).filter(Boolean))]\n for (const pkg of packages)\n await exportPortablePrompts(pkg, { force: args.force, agent: 'none' })\n return\n }\n\n const agent: AgentType | null = autoResolveAgent(args.agent)\n if (!agent) {\n p.log.error('No target agent detected.\\n Pass --agent <name> (claude-code, cursor, codex, …) or run `skilld config` to set a default.\\n Use --agent none for portable export.')\n process.exitCode = 1\n return\n }\n\n if (!hasCompletedWizard())\n await runWizard({ agent })\n\n const items = rawInputs.map(parseSkillInput)\n await installSkills(items, {\n agent,\n surface: 'cli:add',\n global: args.global,\n yes: args.yes,\n force: args.force,\n debug: args.debug,\n model: args.model as OptimizeModel | undefined,\n skillFilter: args.skill,\n allowUnsafe: args['allow-unsafe'],\n })\n },\n})\n"],"mappings":";;;;;;;;;;AAYA,MAAa,gBAAgB,cAAc;CACzC,MAAM;EAAE,MAAM;EAAO,aAAa;CAAwE;CAC1G,MAAM;EACJ,WAAW;GACT,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,WAAW;EACb;EACA,gBAAgB;GACd,MAAM;GACN,aAAa;EACf;EACA,GAAG;CACL;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,YAAY,CAAC,GAAG,IAAI,IACxB,CAAC,KAAK,SAAS,GAAK,KAAa,KAAK,CAAC,CAAE,CAAC,CACvC,KAAK,MAAc,EAAE,KAAK,CAAC,CAAC,CAC5B,OAAO,OAAO,CACnB,CAAC;EAGD,IAAI,KAAK,UAAU,QAAQ;GACzB,MAAM,WAAW,CAAC,GAAG,IAAI,IAAI,UAAU,SAAQ,MAAK,EAAE,MAAM,sBAAsB,CAAC,CAAC,CAAC,KAAI,MAAK,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC;GACxH,KAAK,MAAM,OAAO,UAChB,MAAM,sBAAsB,KAAK;IAAE,OAAO,KAAK;IAAO,OAAO;GAAO,CAAC;GACvE;EACF;EAEA,MAAM,QAA0B,iBAAiB,KAAK,KAAK;EAC3D,IAAI,CAAC,OAAO;GACV,EAAE,IAAI,MAAM,oKAAoK;GAChL,QAAQ,WAAW;GACnB;EACF;EAEA,IAAI,CAAC,mBAAmB,GACtB,MAAM,UAAU,EAAE,MAAM,CAAC;EAE3B,MAAM,QAAQ,UAAU,IAAI,eAAe;EAC3C,MAAM,cAAc,OAAO;GACzB;GACA,SAAS;GACT,QAAQ,KAAK;GACb,KAAK,KAAK;GACV,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ,aAAa,KAAK;GAClB,aAAa,KAAK;EACpB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { detectInstalledAgents, detectProjectAgents, detectTargetAgent, targets } from "./detect.mjs";
|
|
2
|
+
import "./agent.mjs";
|
|
3
|
+
import { readConfig, updateConfig } from "./cache.mjs";
|
|
4
|
+
import { isInteractive } from "./env.mjs";
|
|
5
|
+
import { styleText } from "node:util";
|
|
6
|
+
import * as p from "@clack/prompts";
|
|
7
|
+
function resolveAgent(agentFlag) {
|
|
8
|
+
if (process.env.SKILLD_NO_AGENT) return null;
|
|
9
|
+
return agentFlag ?? detectTargetAgent() ?? readConfig().agent ?? null;
|
|
10
|
+
}
|
|
11
|
+
function autoResolveAgent(agentFlag) {
|
|
12
|
+
const resolved = resolveAgent(agentFlag);
|
|
13
|
+
if (resolved && resolved !== "none") return resolved;
|
|
14
|
+
if (process.env.SKILLD_NO_AGENT) return null;
|
|
15
|
+
const projectMatches = detectProjectAgents();
|
|
16
|
+
if (projectMatches.length === 1) return projectMatches[0];
|
|
17
|
+
const installed = detectInstalledAgents();
|
|
18
|
+
if (installed.length === 1) return installed[0];
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
let _warnedNoAgent = false;
|
|
22
|
+
function warnNoAgent() {
|
|
23
|
+
if (_warnedNoAgent) return;
|
|
24
|
+
_warnedNoAgent = true;
|
|
25
|
+
p.log.warn("No target agent detected — falling back to prompt-only mode.\n Use --agent <name> to specify, or run `skilld config` to set a default.");
|
|
26
|
+
}
|
|
27
|
+
async function promptForAgent() {
|
|
28
|
+
const noAgent = !!process.env.SKILLD_NO_AGENT;
|
|
29
|
+
const installed = noAgent ? [] : detectInstalledAgents();
|
|
30
|
+
const projectMatches = noAgent ? [] : detectProjectAgents();
|
|
31
|
+
if (!isInteractive()) {
|
|
32
|
+
if (installed.length === 1) {
|
|
33
|
+
updateConfig({ agent: installed[0] });
|
|
34
|
+
return installed[0];
|
|
35
|
+
}
|
|
36
|
+
warnNoAgent();
|
|
37
|
+
return "none";
|
|
38
|
+
}
|
|
39
|
+
p.log.info("Skilld generates reference cards from package docs so your AI agent\n always has accurate APIs for your exact dependency versions.");
|
|
40
|
+
const candidateIds = projectMatches.length > 0 ? projectMatches : installed.length > 0 ? installed : Object.keys(targets);
|
|
41
|
+
const sharedAgents = new Set(Object.entries(targets).filter(([, a]) => a.additionalSkillsDirs.some((d) => d.includes(".claude/skills"))).map(([id]) => id));
|
|
42
|
+
const sharedIds = candidateIds.filter((id) => id === "claude-code" || sharedAgents.has(id));
|
|
43
|
+
const isolatedIds = candidateIds.filter((id) => id !== "claude-code" && !sharedAgents.has(id));
|
|
44
|
+
const options = [];
|
|
45
|
+
if (sharedIds.length > 0 && isolatedIds.length > 0) for (const id of sharedIds) {
|
|
46
|
+
const a = targets[id];
|
|
47
|
+
const hint = id === "claude-code" ? `skills shared with ${sharedIds.length - 1} other agents` : `skills shared with Claude Code and others`;
|
|
48
|
+
options.push({
|
|
49
|
+
label: a.displayName,
|
|
50
|
+
value: id,
|
|
51
|
+
hint
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const isolatedAgentIds = new Set(Object.entries(targets).filter(([, a]) => a.additionalSkillsDirs.length === 0).map(([id]) => id));
|
|
55
|
+
for (const id of sharedIds.length > 0 && isolatedIds.length > 0 ? isolatedIds : candidateIds) {
|
|
56
|
+
if (options.some((o) => o.value === id)) continue;
|
|
57
|
+
const a = targets[id];
|
|
58
|
+
const hint = sharedAgents.has(id) && id !== "claude-code" ? "skills shared with Claude Code and others" : isolatedAgentIds.has(id) ? "skills only visible to this agent" : void 0;
|
|
59
|
+
options.push({
|
|
60
|
+
label: a.displayName,
|
|
61
|
+
value: id,
|
|
62
|
+
hint
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
options.push({
|
|
66
|
+
label: "No agent",
|
|
67
|
+
value: "none",
|
|
68
|
+
hint: "export as standalone files for any AI"
|
|
69
|
+
});
|
|
70
|
+
if (!_warnedNoAgent) {
|
|
71
|
+
_warnedNoAgent = true;
|
|
72
|
+
const hint = projectMatches.length > 1 ? `Multiple agent directories found: ${projectMatches.map((t) => targets[t].displayName).join(", ")}` : installed.length > 0 ? `Found ${installed.map((t) => targets[t].displayName).join(", ")} but couldn't determine which to use` : "No agents auto-detected";
|
|
73
|
+
const crossNote = sharedIds.length > 1 ? `\n ${styleText("gray", `Tip: Picking Claude Code shares skills with ${sharedIds.filter((id) => id !== "claude-code").map((id) => targets[id].displayName).join(", ")} automatically.`)}` : "";
|
|
74
|
+
p.log.warn(`${hint}\n Pick the agent you actively code with.${crossNote}`);
|
|
75
|
+
}
|
|
76
|
+
const choice = await p.select({
|
|
77
|
+
message: "Which AI coding agent do you use?",
|
|
78
|
+
options
|
|
79
|
+
});
|
|
80
|
+
if (p.isCancel(choice)) return null;
|
|
81
|
+
if (choice === "none") return "none";
|
|
82
|
+
updateConfig({ agent: choice });
|
|
83
|
+
p.log.success(`Target agent set to ${targets[choice].displayName}`);
|
|
84
|
+
return choice;
|
|
85
|
+
}
|
|
86
|
+
export { autoResolveAgent, promptForAgent, resolveAgent };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=agent-prompt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-prompt.mjs","names":["agents"],"sources":["../../src/cli/agent-prompt.ts"],"sourcesContent":["import type { AgentType } from '../agent/index.ts'\nimport { styleText } from 'node:util'\nimport * as p from '@clack/prompts'\nimport { agents, detectInstalledAgents, detectProjectAgents, detectTargetAgent } from '../agent/index.ts'\nimport { readConfig, updateConfig } from '../core/config.ts'\nimport { isInteractive } from './env.ts'\n\nexport function resolveAgent(agentFlag?: string): AgentType | 'none' | null {\n if (process.env.SKILLD_NO_AGENT)\n return null\n return (agentFlag as AgentType | undefined)\n ?? detectTargetAgent()\n ?? (readConfig().agent as AgentType | undefined)\n ?? null\n}\n\n/**\n * Auto-resolve target agent without prompting. Consults, in order:\n * 1. Explicit `--agent` flag.\n * 2. Env-detected target (`CLAUDE_CODE`, `CURSOR_SESSION`, etc).\n * 3. Saved config default.\n * 4. Project marker dirs (`.claude/skills`, `.cursor/`, …) when exactly one\n * agent matches the cwd.\n * 5. Installed agents on the machine when exactly one is found.\n *\n * Returns `null` when nothing is determined. Callers should error with a clear\n * \"pass --agent <name>\" hint rather than prompting — keeps commands\n * scriptable.\n */\nexport function autoResolveAgent(agentFlag?: string): AgentType | null {\n const resolved = resolveAgent(agentFlag)\n if (resolved && resolved !== 'none')\n return resolved\n\n if (process.env.SKILLD_NO_AGENT)\n return null\n\n const projectMatches = detectProjectAgents()\n if (projectMatches.length === 1)\n return projectMatches[0]!\n\n const installed = detectInstalledAgents()\n if (installed.length === 1)\n return installed[0]!\n\n return null\n}\n\nexport function listKnownAgents(): AgentType[] {\n return Object.keys(agents) as AgentType[]\n}\n\nlet _warnedNoAgent = false\nfunction warnNoAgent(): void {\n if (_warnedNoAgent)\n return\n _warnedNoAgent = true\n p.log.warn('No target agent detected — falling back to prompt-only mode.\\n Use --agent <name> to specify, or run `skilld config` to set a default.')\n}\n\nexport async function promptForAgent(): Promise<AgentType | 'none' | null> {\n const noAgent = !!process.env.SKILLD_NO_AGENT\n const installed = noAgent ? [] : detectInstalledAgents()\n const projectMatches = noAgent ? [] : detectProjectAgents()\n\n if (!isInteractive()) {\n if (installed.length === 1) {\n updateConfig({ agent: installed[0] })\n return installed[0]!\n }\n warnNoAgent()\n return 'none'\n }\n\n p.log.info(\n `Skilld generates reference cards from package docs so your AI agent\\n`\n + ` always has accurate APIs for your exact dependency versions.`,\n )\n\n const candidateIds = projectMatches.length > 0\n ? projectMatches\n : installed.length > 0\n ? installed\n : Object.keys(agents) as AgentType[]\n\n const sharedAgents = new Set(\n Object.entries(agents)\n .filter(([, a]) => a.additionalSkillsDirs.some(d => d.includes('.claude/skills')))\n .map(([id]) => id),\n )\n\n const sharedIds = candidateIds.filter(id => id === 'claude-code' || sharedAgents.has(id))\n const isolatedIds = candidateIds.filter(id => id !== 'claude-code' && !sharedAgents.has(id))\n\n const options: Array<{ label: string, value: AgentType | 'none', hint?: string }> = []\n\n if (sharedIds.length > 0 && isolatedIds.length > 0) {\n for (const id of sharedIds) {\n const a = agents[id]\n const hint = id === 'claude-code'\n ? `skills shared with ${sharedIds.length - 1} other agents`\n : `skills shared with Claude Code and others`\n options.push({ label: a.displayName, value: id as AgentType, hint })\n }\n }\n\n const isolatedAgentIds = new Set(\n Object.entries(agents)\n .filter(([, a]) => a.additionalSkillsDirs.length === 0)\n .map(([id]) => id),\n )\n\n for (const id of (sharedIds.length > 0 && isolatedIds.length > 0 ? isolatedIds : candidateIds)) {\n if (options.some(o => o.value === id))\n continue\n const a = agents[id]\n const hint = sharedAgents.has(id) && id !== 'claude-code'\n ? 'skills shared with Claude Code and others'\n : isolatedAgentIds.has(id)\n ? 'skills only visible to this agent'\n : undefined\n options.push({ label: a.displayName, value: id as AgentType, hint })\n }\n\n options.push({ label: 'No agent', value: 'none', hint: 'export as standalone files for any AI' })\n\n if (!_warnedNoAgent) {\n _warnedNoAgent = true\n const hint = projectMatches.length > 1\n ? `Multiple agent directories found: ${projectMatches.map(t => agents[t].displayName).join(', ')}`\n : installed.length > 0\n ? `Found ${installed.map(t => agents[t].displayName).join(', ')} but couldn't determine which to use`\n : 'No agents auto-detected'\n const crossNote = sharedIds.length > 1\n ? `\\n ${styleText('gray', `Tip: Picking Claude Code shares skills with ${sharedIds.filter(id => id !== 'claude-code').map(id => agents[id].displayName).join(', ')} automatically.`)}`\n : ''\n p.log.warn(`${hint}\\n Pick the agent you actively code with.${crossNote}`)\n }\n\n const choice = await p.select({\n message: 'Which AI coding agent do you use?',\n options,\n })\n\n if (p.isCancel(choice))\n return null\n\n if (choice === 'none')\n return 'none'\n\n updateConfig({ agent: choice })\n p.log.success(`Target agent set to ${agents[choice].displayName}`)\n return choice\n}\n"],"mappings":";;;;;;AAOA,SAAgB,aAAa,WAA+C;CAC1E,IAAI,QAAQ,IAAI,iBACd,OAAO;CACT,OAAQ,aACH,kBAAkB,KACjB,WAAW,CAAC,CAAC,SACd;AACP;;;;;;;;;;;;;CAeA,IAAA,gBAAgB;CACd,iBAAiB;CACjB,EAAA,IAAI,KAAA,yIACK;AAET;AAGA,eAAM,iBAAiB;CACvB,MAAI,UAAA,CAAA,CAAA,QAAe,IAAW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