agentskillsdk 0.5.3 → 0.6.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.
- package/bin/cli.js +49 -1
- package/package.json +5 -2
- package/src/commands/add.js +273 -173
- package/src/commands/list.js +18 -16
- package/src/index.js +91 -19
- package/src/lib/api.js +14 -11
- package/src/lib/detect-agent.js +45 -44
- package/src/lib/detect-runtime.js +63 -0
- package/src/lib/download.js +165 -48
- package/src/lib/errors.js +58 -0
- package/src/lib/messages/da.js +96 -0
- package/src/lib/messages/en.js +96 -0
- package/src/lib/messages/index.js +49 -0
- package/src/lib/output.js +139 -0
- package/src/lib/parse-source.js +115 -5
- package/src/lib/prompt.js +14 -20
- package/src/lib/resolve-github-path.js +55 -0
- package/src/lib/ui.js +27 -116
package/src/lib/ui.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
+
import { t } from './messages/index.js';
|
|
3
4
|
|
|
4
5
|
const require = createRequire(import.meta.url);
|
|
5
6
|
const pkg = require('../../package.json');
|
|
6
7
|
|
|
7
|
-
// --- strip ANSI for width calculation ---
|
|
8
|
-
|
|
9
8
|
const ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
10
9
|
function stripAnsi(str) {
|
|
11
10
|
return str.replace(ANSI_RE, '');
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
// --- box drawing ---
|
|
15
|
-
|
|
16
13
|
export function box(lines, { borderColor, padding = 2 } = {}) {
|
|
17
14
|
const maxWidth = Math.max(...lines.map(l => stripAnsi(l).length));
|
|
18
15
|
const pad = ' '.repeat(padding);
|
|
@@ -20,145 +17,59 @@ export function box(lines, { borderColor, padding = 2 } = {}) {
|
|
|
20
17
|
|
|
21
18
|
const colorize = borderColor ? chalk[borderColor].bind(chalk) : (s) => s;
|
|
22
19
|
|
|
23
|
-
const top = colorize(`
|
|
24
|
-
const bottom = colorize(`
|
|
20
|
+
const top = colorize(` ┌${'─'.repeat(inner)}┐`);
|
|
21
|
+
const bottom = colorize(` └${'─'.repeat(inner)}┘`);
|
|
25
22
|
const rowLines = lines.map(l => {
|
|
26
23
|
const visible = stripAnsi(l).length;
|
|
27
24
|
const rightPad = ' '.repeat(maxWidth - visible);
|
|
28
|
-
return ` ${colorize('
|
|
25
|
+
return ` ${colorize('│')}${pad}${l}${rightPad}${pad}${colorize('│')}`;
|
|
29
26
|
});
|
|
30
27
|
|
|
31
28
|
return [top, ...rowLines, bottom].join('\n');
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export function printBanner() {
|
|
31
|
+
export function formatBanner() {
|
|
37
32
|
const lines = [
|
|
38
33
|
`${chalk.hex('#FF8C00')('■')} ${chalk.bold('agentskillsdk')} ${chalk.dim(`v${pkg.version}`)}`,
|
|
39
|
-
chalk.dim('
|
|
34
|
+
chalk.dim(t('banner.subtitle')),
|
|
40
35
|
];
|
|
41
|
-
|
|
42
|
-
console.log(box(lines));
|
|
43
|
-
console.log('');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// --- install plan ---
|
|
47
|
-
|
|
48
|
-
export function printInstallPlan({ skillName, source, scope, universalAgents, symlinkAgents }) {
|
|
49
|
-
const scopeLabel = scope === 'global'
|
|
50
|
-
? 'globalt (alle projekter)'
|
|
51
|
-
: 'projekt (lokalt)';
|
|
52
|
-
|
|
53
|
-
const lines = [
|
|
54
|
-
chalk.bold('installationsplan:'),
|
|
55
|
-
'',
|
|
56
|
-
` ${chalk.dim('skill:')} ${skillName}`,
|
|
57
|
-
` ${chalk.dim('kilde:')} ${source}`,
|
|
58
|
-
` ${chalk.dim('omfang:')} ${scopeLabel}`,
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
if (universalAgents.length > 0) {
|
|
62
|
-
lines.push('');
|
|
63
|
-
lines.push(chalk.dim(' ── Universal (.agents/skills/) ──'));
|
|
64
|
-
for (const a of universalAgents) {
|
|
65
|
-
lines.push(` ${chalk.green('\u2713')} ${a.name}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (symlinkAgents.length > 0) {
|
|
70
|
-
lines.push('');
|
|
71
|
-
lines.push(chalk.dim(' ── Symlink \u2192 .agents/skills/ ──'));
|
|
72
|
-
for (const a of symlinkAgents) {
|
|
73
|
-
lines.push(` ${chalk.green('\u2713')} ${a.name} ${chalk.dim(a.displayPath(skillName, scope))}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
console.log('');
|
|
78
|
-
console.log(box(lines));
|
|
79
|
-
console.log('');
|
|
36
|
+
return box(lines);
|
|
80
37
|
}
|
|
81
38
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
: 'projekt (lokalt)';
|
|
39
|
+
export function formatCompletionSummary({ skillName, scope, agents, isGithub, namespace }) {
|
|
40
|
+
const scopeLabel = scope === 'global' ? t('summary.scope_global') : t('summary.scope_project');
|
|
41
|
+
const isSingle = agents.length === 1;
|
|
42
|
+
const agentNames = agents.map(a => a.name).join(', ');
|
|
43
|
+
const paths = agents.map(a => a.displayPath(skillName, scope));
|
|
88
44
|
|
|
89
45
|
const lines = [
|
|
90
|
-
chalk.bold.green('
|
|
46
|
+
chalk.bold.green(t('summary.title')),
|
|
91
47
|
'',
|
|
92
|
-
` ${chalk.dim('skill
|
|
93
|
-
` ${chalk.dim('
|
|
48
|
+
` ${chalk.dim(t('summary.skill'))} ${skillName}`,
|
|
49
|
+
` ${chalk.dim(t('summary.scope'))} ${scopeLabel}`,
|
|
94
50
|
];
|
|
95
51
|
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (canonical.length > 0) {
|
|
101
|
-
lines.push('');
|
|
102
|
-
lines.push(chalk.dim(' canonical (.agents/skills/):'));
|
|
103
|
-
for (const a of canonical) {
|
|
104
|
-
lines.push(` ${chalk.green('\u2713')} ${a.name}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (symlinked.length > 0) {
|
|
109
|
-
lines.push('');
|
|
110
|
-
lines.push(chalk.dim(' symlink:'));
|
|
111
|
-
for (const a of symlinked) {
|
|
112
|
-
lines.push(` ${chalk.green('\u2713')} ${a.name} ${chalk.dim(a.displayPath(skillName, scope) + ' \u2192 .agents/skills/')}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (copied.length > 0) {
|
|
117
|
-
lines.push('');
|
|
118
|
-
lines.push(chalk.dim(' kopi (symlink fejlede):'));
|
|
119
|
-
for (const a of copied) {
|
|
120
|
-
lines.push(` ${chalk.green('\u2713')} ${a.name} ${chalk.dim(a.displayPath(skillName, scope))}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
52
|
+
if (isSingle) {
|
|
53
|
+
lines.push(` ${chalk.dim(t('summary.agent'))} ${agentNames}`);
|
|
54
|
+
lines.push(` ${chalk.dim(t('summary.path'))} ${paths[0]}`);
|
|
123
55
|
} else {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (agents.length === 1) {
|
|
129
|
-
lines.push(` ${chalk.dim('agent:')} ${agentNames}`);
|
|
130
|
-
lines.push(` ${chalk.dim('sti:')} ${paths[0]}`);
|
|
131
|
-
} else {
|
|
132
|
-
lines.push(` ${chalk.dim('agenter:')} ${agentNames}`);
|
|
133
|
-
lines.push(` ${chalk.dim('stier:')} ${paths[0]}`);
|
|
134
|
-
for (let i = 1; i < paths.length; i++) {
|
|
135
|
-
lines.push(` ${paths[i]}`);
|
|
136
|
-
}
|
|
56
|
+
lines.push(` ${chalk.dim(t('summary.agents'))} ${agentNames}`);
|
|
57
|
+
lines.push(` ${chalk.dim(t('summary.paths'))} ${paths[0]}`);
|
|
58
|
+
for (let i = 1; i < paths.length; i++) {
|
|
59
|
+
lines.push(` ${paths[i]}`);
|
|
137
60
|
}
|
|
138
61
|
}
|
|
139
62
|
|
|
140
63
|
lines.push('');
|
|
141
|
-
if (
|
|
142
|
-
lines.push(
|
|
64
|
+
if (isSingle) {
|
|
65
|
+
lines.push(t('summary.session_single', { agent: agents[0].name }));
|
|
143
66
|
} else {
|
|
144
|
-
lines.push('
|
|
67
|
+
lines.push(t('summary.session_multi'));
|
|
145
68
|
}
|
|
146
69
|
|
|
147
70
|
if (!isGithub && namespace) {
|
|
148
|
-
lines.push(
|
|
71
|
+
lines.push(`${t('summary.learn_more')} ${chalk.underline(`https://agentskills.dk/skills/${namespace}`)}`);
|
|
149
72
|
}
|
|
150
73
|
|
|
151
|
-
|
|
152
|
-
console.log(box(lines, { borderColor: 'green' }));
|
|
153
|
-
console.log('');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// --- step / error output ---
|
|
157
|
-
|
|
158
|
-
export function step(text) {
|
|
159
|
-
console.log(chalk.green(' \u2713') + ` ${text}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function error(text) {
|
|
163
|
-
console.error(chalk.red(` ${text}`));
|
|
74
|
+
return box(lines, { borderColor: 'green' });
|
|
164
75
|
}
|