@code2rich/jpage 1.5.1 → 1.5.2
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/commands/ls.js +4 -3
- package/mcp/tools-files.js +5 -1
- package/package.json +1 -1
package/bin/commands/ls.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// ls 命令:列出文件。
|
|
2
2
|
// 后端:GET /api/files(支持 page/limit/sort/order/keyword/category/tag)。
|
|
3
3
|
|
|
4
|
-
const { formatSize, formatTime, out } = require('./_shared');
|
|
4
|
+
const { formatSize, formatTime, shareUrl, out } = require('./_shared');
|
|
5
5
|
|
|
6
|
-
async function run(client, args) {
|
|
6
|
+
async function run(client, args, { base }) {
|
|
7
7
|
const o = args.opts;
|
|
8
8
|
const params = new URLSearchParams();
|
|
9
9
|
if (o.page) params.set('page', o.page);
|
|
@@ -29,7 +29,8 @@ async function run(client, args) {
|
|
|
29
29
|
const pub = f.is_public ? 'pub' : 'pri';
|
|
30
30
|
const tags = (f.tags || []).map((t) => t.name).join(',');
|
|
31
31
|
const bundle = f.is_bundle ? ' 📦' : '';
|
|
32
|
-
const
|
|
32
|
+
const url = shareUrl(base, f);
|
|
33
|
+
const short = url ? ` ${url}` : '';
|
|
33
34
|
out(
|
|
34
35
|
`#${f.id} [${f.file_type || '?'} ${pub}] ${formatSize(f.size).padEnd(7)} ` +
|
|
35
36
|
`${formatTime(f.updated_at)} ${f.original_name}${bundle}` +
|
package/mcp/tools-files.js
CHANGED
|
@@ -37,7 +37,11 @@ function registerFileTools(server, { api, port, mcpIp, protocol }) {
|
|
|
37
37
|
if (tag) params.set('tag', tag);
|
|
38
38
|
const qs = params.toString();
|
|
39
39
|
const data = await api.get('/api/files' + (qs ? '?' + qs : ''));
|
|
40
|
-
|
|
40
|
+
const files = (data.files || []).map((f) => ({
|
|
41
|
+
...f,
|
|
42
|
+
url: f.share_key ? `${protocol}://${mcpIp}:${port}/s/${f.share_key}` : null,
|
|
43
|
+
}));
|
|
44
|
+
return textResult({ files, pagination: data.pagination });
|
|
41
45
|
}
|
|
42
46
|
);
|
|
43
47
|
|