agent-resource-management 2.1.2 → 2.1.4
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/main.js +32 -4
- package/package.json +1 -1
- package/src/cmd/skill.ts +31 -4
- package/src/main.ts +10 -0
- package/dist/test.md +0 -3
- package/dist/test2.md +0 -3
package/dist/main.js
CHANGED
|
@@ -956,13 +956,33 @@ async function downloadSkill(name, outputDir) {
|
|
|
956
956
|
info(`正在下载 ${name}...`);
|
|
957
957
|
}
|
|
958
958
|
const buffer = await client.downloadSkill(name);
|
|
959
|
-
const
|
|
960
|
-
|
|
959
|
+
const tempDir = mkdtempSync2("/tmp/skill-download-");
|
|
960
|
+
const zipPath = join3(tempDir, `${name}.zip`);
|
|
961
|
+
writeFileSync2(zipPath, Buffer.from(buffer));
|
|
962
|
+
execSync2(`unzip -q "${zipPath}" -d "${tempDir}"`, { stdio: "pipe" });
|
|
963
|
+
const targetDir = join3(outputDir || ".", name);
|
|
964
|
+
execSync2(`mkdir -p "${targetDir}"`, { stdio: "pipe" });
|
|
965
|
+
const entries = execSync2(`ls -1 "${tempDir}"`, { encoding: "utf-8" }).split(`
|
|
966
|
+
`).filter((e) => e.trim());
|
|
967
|
+
const nonZipEntries = entries.filter((e) => e !== `${name}.zip`);
|
|
968
|
+
if (nonZipEntries.length === 1) {
|
|
969
|
+
const onlyEntry = join3(tempDir, nonZipEntries[0]);
|
|
970
|
+
if (statSync3(onlyEntry).isDirectory()) {
|
|
971
|
+
execSync2(`cp -r "${onlyEntry}"/* "${targetDir}/"`, { stdio: "pipe" });
|
|
972
|
+
} else {
|
|
973
|
+
execSync2(`cp -r "${onlyEntry}" "${targetDir}/"`, { stdio: "pipe" });
|
|
974
|
+
}
|
|
975
|
+
} else {
|
|
976
|
+
for (const entry of nonZipEntries) {
|
|
977
|
+
execSync2(`cp -r "${join3(tempDir, entry)}" "${targetDir}/"`, { stdio: "pipe" });
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
rmSync2(tempDir, { recursive: true, force: true });
|
|
961
981
|
if (shouldOutputJson()) {
|
|
962
|
-
outputJson({ success: true, data: { path:
|
|
982
|
+
outputJson({ success: true, data: { path: targetDir } });
|
|
963
983
|
return;
|
|
964
984
|
}
|
|
965
|
-
success(`已下载到 ${
|
|
985
|
+
success(`已下载到 ${targetDir}`);
|
|
966
986
|
} catch (err) {
|
|
967
987
|
if (shouldOutputJson()) {
|
|
968
988
|
outputJson({ success: false, error: { code: "DOWNLOAD_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
@@ -1956,10 +1976,18 @@ function setServer(url) {
|
|
|
1956
1976
|
}
|
|
1957
1977
|
|
|
1958
1978
|
// src/main.ts
|
|
1979
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
1980
|
+
import { join as join6 } from "path";
|
|
1981
|
+
var __dirname = "/Users/lk/Documents/Dev/aims/xuanwu/xuanwu-agents/agent-resource-management/cli/src";
|
|
1959
1982
|
var args = process.argv.slice(2);
|
|
1960
1983
|
var command = args[0];
|
|
1961
1984
|
var subCommand = args[1];
|
|
1985
|
+
var VERSION = JSON.parse(readFileSync4(join6(__dirname, "../package.json"), "utf-8")).version;
|
|
1962
1986
|
async function main() {
|
|
1987
|
+
if (command === "--version" || command === "-v") {
|
|
1988
|
+
console.log(`arm v${VERSION}`);
|
|
1989
|
+
return;
|
|
1990
|
+
}
|
|
1963
1991
|
switch (command) {
|
|
1964
1992
|
case "register":
|
|
1965
1993
|
if (args[1] && args[1].startsWith("--")) {
|
package/package.json
CHANGED
package/src/cmd/skill.ts
CHANGED
|
@@ -130,13 +130,40 @@ export async function downloadSkill(name: string, outputDir?: string): Promise<v
|
|
|
130
130
|
info(`正在下载 ${name}...`);
|
|
131
131
|
}
|
|
132
132
|
const buffer = await client.downloadSkill(name);
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
|
|
134
|
+
const tempDir = mkdtempSync('/tmp/skill-download-');
|
|
135
|
+
const zipPath = join(tempDir, `${name}.zip`);
|
|
136
|
+
writeFileSync(zipPath, Buffer.from(buffer));
|
|
137
|
+
|
|
138
|
+
execSync(`unzip -q "${zipPath}" -d "${tempDir}"`, { stdio: 'pipe' });
|
|
139
|
+
|
|
140
|
+
const targetDir = join(outputDir || '.', name);
|
|
141
|
+
execSync(`mkdir -p "${targetDir}"`, { stdio: 'pipe' });
|
|
142
|
+
|
|
143
|
+
const entries = execSync(`ls -1 "${tempDir}"`, { encoding: 'utf-8' }).split('\n').filter(e => e.trim());
|
|
144
|
+
|
|
145
|
+
const nonZipEntries = entries.filter(e => e !== `${name}.zip`);
|
|
146
|
+
|
|
147
|
+
if (nonZipEntries.length === 1) {
|
|
148
|
+
const onlyEntry = join(tempDir, nonZipEntries[0]);
|
|
149
|
+
if (statSync(onlyEntry).isDirectory()) {
|
|
150
|
+
execSync(`cp -r "${onlyEntry}"/* "${targetDir}/"`, { stdio: 'pipe' });
|
|
151
|
+
} else {
|
|
152
|
+
execSync(`cp -r "${onlyEntry}" "${targetDir}/"`, { stdio: 'pipe' });
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
for (const entry of nonZipEntries) {
|
|
156
|
+
execSync(`cp -r "${join(tempDir, entry)}" "${targetDir}/"`, { stdio: 'pipe' });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
161
|
+
|
|
135
162
|
if (shouldOutputJson()) {
|
|
136
|
-
outputJson({ success: true, data: { path:
|
|
163
|
+
outputJson({ success: true, data: { path: targetDir } });
|
|
137
164
|
return;
|
|
138
165
|
}
|
|
139
|
-
success(`已下载到 ${
|
|
166
|
+
success(`已下载到 ${targetDir}`);
|
|
140
167
|
} catch (err) {
|
|
141
168
|
if (shouldOutputJson()) {
|
|
142
169
|
outputJson({ success: false, error: { code: 'DOWNLOAD_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
|
package/src/main.ts
CHANGED
|
@@ -5,11 +5,21 @@ import { listKnowledge, searchKnowledge, infoKnowledge, downloadKnowledge, uploa
|
|
|
5
5
|
import { showServer, setServer } from './cmd/server';
|
|
6
6
|
import { getOutputMode, setOutputMode } from './lib/output';
|
|
7
7
|
|
|
8
|
+
import { readFileSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
8
11
|
const args = process.argv.slice(2);
|
|
9
12
|
const command = args[0];
|
|
10
13
|
const subCommand = args[1];
|
|
11
14
|
|
|
15
|
+
const VERSION = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8')).version;
|
|
16
|
+
|
|
12
17
|
async function main() {
|
|
18
|
+
if (command === '--version' || command === '-v') {
|
|
19
|
+
console.log(`arm v${VERSION}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
switch (command) {
|
|
14
24
|
case 'register':
|
|
15
25
|
if (args[1] && args[1].startsWith('--')) {
|
package/dist/test.md
DELETED
package/dist/test2.md
DELETED