skilld 1.7.3 → 2.0.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/dist/_chunks/add.mjs +66 -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 +737 -619
- 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 +11 -8
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +77 -131
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +320 -54
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +7 -6
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/client.mjs +117 -0
- package/dist/_chunks/client.mjs.map +1 -0
- package/dist/_chunks/core.mjs +7 -4
- package/dist/_chunks/detect.mjs +54 -44
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/eject.mjs +69 -0
- package/dist/_chunks/eject.mjs.map +1 -0
- package/dist/_chunks/embedding-cache2.mjs +2 -2
- package/dist/_chunks/env.mjs +19 -0
- package/dist/_chunks/env.mjs.map +1 -0
- package/dist/_chunks/install-many.mjs +376 -0
- package/dist/_chunks/install-many.mjs.map +1 -0
- package/dist/_chunks/install.mjs +86 -371
- 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 +2 -2
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +31 -7
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/login.mjs +233 -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 +79 -54
- 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 +73 -0
- package/dist/_chunks/monorepo.mjs.map +1 -0
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/paths.mjs +47 -0
- package/dist/_chunks/paths.mjs.map +1 -0
- package/dist/_chunks/pipeline.mjs +985 -0
- package/dist/_chunks/pipeline.mjs.map +1 -0
- package/dist/_chunks/pool2.mjs +2 -2
- 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 +47 -3
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +9 -8
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +784 -26
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/pull.mjs +219 -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 +12 -9
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +9 -8
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +23 -20
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +3 -4
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/{sources.mjs → semver.mjs} +1128 -838
- package/dist/_chunks/semver.mjs.map +1 -0
- package/dist/_chunks/skill-installer.mjs +2 -0
- package/dist/_chunks/skill-installer2.mjs +154 -0
- package/dist/_chunks/skill-installer2.mjs.map +1 -0
- package/dist/_chunks/skills.mjs +12 -12
- 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 +761 -1349
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +2 -3
- package/dist/_chunks/telemetry.mjs +26 -0
- package/dist/_chunks/telemetry.mjs.map +1 -0
- package/dist/_chunks/uninstall.mjs +15 -13
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/update.mjs +171 -0
- package/dist/_chunks/update.mjs.map +1 -0
- package/dist/_chunks/upload.mjs +4 -4
- package/dist/_chunks/validate.mjs +1 -1
- package/dist/_chunks/version.mjs +16 -27
- 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/cli.mjs +77 -59
- package/dist/cli.mjs.map +1 -1
- package/dist/prepare.mjs +5 -4
- 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/package.json +20 -29
- 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/config.mjs +0 -122
- package/dist/_chunks/config.mjs.map +0 -1
- package/dist/_chunks/index.d.mts +0 -151
- package/dist/_chunks/index.d.mts.map +0 -1
- package/dist/_chunks/index2.d.mts +0 -44
- package/dist/_chunks/index2.d.mts.map +0 -1
- package/dist/_chunks/index3.d.mts +0 -589
- package/dist/_chunks/index3.d.mts.map +0 -1
- package/dist/_chunks/prefix.mjs +0 -108
- package/dist/_chunks/prefix.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/shared.mjs +0 -503
- package/dist/_chunks/shared.mjs.map +0 -1
- package/dist/_chunks/skill.mjs +0 -329
- package/dist/_chunks/skill.mjs.map +0 -1
- package/dist/_chunks/sources.mjs.map +0 -1
- package/dist/_chunks/sync-registry.mjs +0 -59
- package/dist/_chunks/sync-registry.mjs.map +0 -1
- package/dist/_chunks/sync-shared.mjs +0 -2
- package/dist/_chunks/sync-shared2.mjs +0 -1020
- package/dist/_chunks/sync-shared2.mjs.map +0 -1
- package/dist/_chunks/types.d.mts +0 -88
- package/dist/_chunks/types.d.mts.map +0 -1
- package/dist/_chunks/wizard.mjs.map +0 -1
- package/dist/agent/index.d.mts +0 -346
- package/dist/agent/index.d.mts.map +0 -1
- package/dist/agent/index.mjs +0 -5
- package/dist/cache/index.d.mts +0 -2
- package/dist/cache/index.mjs +0 -4
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -5
- package/dist/retriv/index.d.mts +0 -3
- package/dist/retriv/index.mjs +0 -2
- package/dist/sources/index.d.mts +0 -2
- package/dist/sources/index.mjs +0 -3
- package/dist/types.d.mts +0 -4
- package/dist/types.mjs +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { n as COMMA_OR_WHITESPACE_RE } from "./regex.mjs";
|
|
2
|
+
import { l as hasCompletedWizard } from "./cache.mjs";
|
|
3
|
+
import { t as autoResolveAgent } from "./agent-prompt.mjs";
|
|
4
|
+
import { t as sharedArgs } from "./args.mjs";
|
|
5
|
+
import { s as parseSkillInput } from "./semver.mjs";
|
|
6
|
+
import { t as runWizard } from "./wizard2.mjs";
|
|
7
|
+
import { t as installSkills } from "./install-many.mjs";
|
|
8
|
+
import { t as 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
|
+
await installSkills(rawInputs.map(parseSkillInput), {
|
|
52
|
+
agent,
|
|
53
|
+
surface: "cli:add",
|
|
54
|
+
global: args.global,
|
|
55
|
+
yes: args.yes,
|
|
56
|
+
force: args.force,
|
|
57
|
+
debug: args.debug,
|
|
58
|
+
model: args.model,
|
|
59
|
+
skillFilter: args.skill,
|
|
60
|
+
allowUnsafe: args["allow-unsafe"]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
export { addCommandDef };
|
|
65
|
+
|
|
66
|
+
//# 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;EAAyE;CAC3G,MAAM;EACJ,WAAW;GACT,MAAM;GACN,aAAa;GACb,UAAU;GACX;EACD,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,WAAW;GACZ;EACD,gBAAgB;GACd,MAAM;GACN,aAAa;GACd;EACD,GAAG;EACJ;CACD,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,YAAY,CAAC,GAAG,IAAI,IACxB,CAAC,KAAK,SAAS,GAAK,KAAa,KAAK,EAAE,CAAE,CACvC,KAAK,MAAc,EAAE,MAAM,CAAC,CAC5B,OAAO,QAAQ,CACnB,CAAC;EAGF,IAAI,KAAK,UAAU,QAAQ;GACzB,MAAM,WAAW,CAAC,GAAG,IAAI,IAAI,UAAU,SAAQ,MAAK,EAAE,MAAM,uBAAuB,CAAC,CAAC,KAAI,MAAK,EAAE,MAAM,CAAC,CAAC,OAAO,QAAQ,CAAC,CAAC;GACzH,KAAK,MAAM,OAAO,UAChB,MAAM,sBAAsB,KAAK;IAAE,OAAO,KAAK;IAAO,OAAO;IAAQ,CAAC;GACxE;;EAGF,MAAM,QAA0B,iBAAiB,KAAK,MAAM;EAC5D,IAAI,CAAC,OAAO;GACV,EAAE,IAAI,MAAM,qKAAqK;GACjL,QAAQ,WAAW;GACnB;;EAGF,IAAI,CAAC,oBAAoB,EACvB,MAAM,UAAU,EAAE,OAAO,CAAC;EAG5B,MAAM,cADQ,UAAU,IAAI,gBACH,EAAE;GACzB;GACA,SAAS;GACT,QAAQ,KAAK;GACb,KAAK,KAAK;GACV,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ,aAAa,KAAK;GAClB,aAAa,KAAK;GACnB,CAAC;;CAEL,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { a as targets, n as detectProjectAgents, r as detectTargetAgent, t as detectInstalledAgents } from "./detect.mjs";
|
|
2
|
+
import "./agent.mjs";
|
|
3
|
+
import { d as readConfig, m as updateConfig } from "./cache.mjs";
|
|
4
|
+
import { t as 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 { promptForAgent as n, resolveAgent as r, autoResolveAgent as t };
|
|
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,mBAAmB,IAClB,YAAY,CAAC,SACd;;;;;;;;;;;;;;CAgBP,IAAA,gBAAgB;CACd,iBAAiB;CACjB,EAAA,IAAI,KAAA,0IACK;;eAKH,iBAAiB;CACvB,MAAI,UAAA,CAAA,CAAA,QAAe,IAAW;CAG9B,MAAM,YAAY,UAAA,EAAA,GAAA,uBAAuB;CACzC,MAAI,iBAAU,UACZ,EAAO,GAAA,qBAAU;CAEnB,IAAA,CAAA,eAAO,EAAA;;GAOT,aAAI,EAAA,OAAiB,UAAA,IAAA,CAAA;GACrB,OAAS,UAAA;;EAGP,aAAA;EACA,OAAM;;CAGR,EAAA,IAAA,KAAA,sIAA2E;CACzE,MAAM,eAAY,eAAY,SAAA,IAAA,iBAAA,UAAA,SAAA,IAAA,YAAA,OAAA,KAAA,QAAA;CAC9B,MAAM,eAAY,IAAA,IAAU,OAAK,QAAA,QAAA,CAAA,QAAuB,GAAA,OAAA,EAAA,qBAAA,MAAA,MAAA,EAAA,SAAA,iBAAA,CAAA,CAAA,CAAA,KAAA,CAAA,QAAA,GAAA,CAAA;CACxD,MAAM,YAAA,aAAiB,QAAe,OAAA,OAAA,iBAAqB,aAAA,IAAA,GAAA,CAAA;CAE3D,MAAK,cAAe,aAAE,QAAA,OAAA,OAAA,iBAAA,CAAA,aAAA,IAAA,GAAA,CAAA;OAChB,UAAU,EAAA;KACZ,UAAA,SAAe,KAAO,YAAe,SAAA,GAAA,KAAA,MAAA,MAAA,WAAA;QACrC,IAAO,QAAU;;EAEnB,QAAA,KAAa;GACb,OAAO,EAAA;;GAGP;GAKF,CAAA;;CAYA,MAAM,mBAAY,IAAA,IAAa,OAAO,QAAM,QAAO,CAAA,QAAA,GAAA,OAAiB,EAAA,qBAAqB,WAAA,EAAA,CAAA,KAAA,CAAA,QAAA,GAAA,CAAA;CACzF,KAAA,MAAM,MAAA,UAAc,SAAa,KAAO,YAAM,SAAO,IAAA,cAAkB,cAAqB;EAE5F,IAAA,QAAM,MAAgF,MAAA,EAAA,UAAA,GAAA,EAAA;EAEtF,MAAI,IAAA,QAAU;EAEV,MAAM,OAAIA,aAAO,IAAA,GAAA,IAAA,OAAA,gBAAA,8CAAA,iBAAA,IAAA,GAAA,GAAA,sCAAA,KAAA;EACjB,QAAM,KAAO;GAGb,OAAQ,EAAA;GAAO,OAAO;GAAe;GAAwB,CAAA;;;EAIjE,OAAM;EAMN,OAAK;EACH,MAAI;EAEJ,CAAA;KACA,CAAA,gBAAa;EAKb,iBAAa;QAAE,OAAS,eAAA,SAAA,IAAA,qCAAA,eAAA,KAAA,MAAA,QAAA,GAAA,YAAA,CAAA,KAAA,KAAA,KAAA,UAAA,SAAA,IAAA,SAAA,UAAA,KAAA,MAAA,QAAA,GAAA,YAAA,CAAA,KAAA,KAAA,CAAA,wCAAA;QAAa,YAAO,UAAA,SAAA,IAAA,OAAA,UAAA,QAAA,+CAAA,UAAA,QAAA,OAAA,OAAA,cAAA,CAAA,KAAA,OAAA,QAAA,IAAA,YAAA,CAAA,KAAA,KAAA,CAAA,iBAAA,KAAA;IAAiB,IAAA,KAAA,GAAA,KAAA,4CAAA,YAAA;;;EAG/D,SAAQ;EAAO;EAAmB,CAAA;KAAe,EAAA,SAAM,OAAA,EAAA,OAAA;KAA0C,WAAA,QAAA,OAAA;CAEjG,aAAK,EAAA,OAAgB,QAAA,CAAA;GACnB,IAAA,QAAA,uBAAiB,QAAA,QAAA,cAAA;QACX"}
|