@thinkingai/ae-cli 1.0.22 → 1.0.27
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 +39 -1
- package/README.zh.md +40 -1
- package/dist/{auth-YM7OI23X.js → auth-TXFJHPXU.js} +3 -2
- package/dist/{auth-5S7SPPEJ.js → auth-W2JZ3DKA.js} +11 -4
- package/dist/{chunk-MPFTXJFG.js → chunk-2NGWYMLB.js} +14 -2
- package/dist/chunk-6T7245YE.js +478 -0
- package/dist/{chunk-KM57HI5B.js → chunk-B4UL2VIJ.js} +7 -1
- package/dist/{chunk-TMMUBSKW.js → chunk-BI5ZVD6T.js} +8 -1
- package/dist/chunk-MNHE6SSI.js +79 -0
- package/dist/chunk-MWWYGZ76.js +130 -0
- package/dist/{chunk-24ZKQWG2.js → chunk-SRRUNQIM.js} +51 -4
- package/dist/chunk-TG64AQV4.js +262 -0
- package/dist/{chunk-NBFTPIAH.js → chunk-VT6VC4PA.js} +15 -4
- package/dist/{client-7S23DVHH.js → client-IU2E5IOL.js} +6 -3
- package/dist/{config-RVUESJRF.js → config-WH3R3IRY.js} +3 -2
- package/dist/index.js +195 -20
- package/dist/model-CC7U5XOJ.js +131 -0
- package/dist/{raw-5SYAUCJQ.js → raw-TUHZQ4UB.js} +5 -4
- package/dist/sync-EVEDS7YE.js +383 -0
- package/dist/te-agent-FLTDYV3L.js +522 -0
- package/dist/{te-analysis-RQST6AT3.js → te-analysis-CMXADIJM.js} +101 -12
- package/dist/{te-audience-TJ74UJI3.js → te-audience-LPZFFSXM.js} +4 -3
- package/dist/{te-common-W5URM2SH.js → te-common-BXQFKTB3.js} +4 -3
- package/dist/{te-community-YRV2VAD4.js → te-community-K5S3VOZY.js} +4 -3
- package/dist/{te-dataops-ZPH72BCK.js → te-dataops-567IMCQG.js} +4 -3
- package/dist/{te-engage-57UKFV74.js → te-engage-TBUTGW5F.js} +105 -49
- package/dist/{te-kb-GD7SJRYB.js → te-kb-XHVBWP5E.js} +227 -38
- package/dist/{te-meta-25SLZFXJ.js → te-meta-NQ4U3VJW.js} +25 -4
- package/dist/te-team-556APRIU.js +529 -0
- package/package.json +6 -1
- package/skills/ae-agent/SKILL.md +133 -0
- package/skills/ae-analysis/references/create_entity.md +39 -0
- package/skills/ae-analysis/references/create_space.md +34 -0
- package/skills/ae-analysis/references/drilldown_user_events.md +1 -1
- package/skills/ae-analysis/references/drilldown_users.md +2 -2
- package/skills/ae-analysis/references/query_adhoc.md +3 -2
- package/skills/ae-analysis/references/query_entity_details.md +1 -1
- package/skills/ae-engage/SKILL.md +25 -2
- package/skills/ae-engage/references/build-task-save-guide.md +283 -0
- package/skills/ae-engage/references/save-task.md +304 -0
- package/skills/ae-kb/SKILL.md +283 -0
- package/skills/ae-team/SKILL.md +164 -0
- package/skills/ae-team/references/ai-generate.md +39 -0
- package/skills/ae-team/references/create.md +94 -0
- package/skills/ae-team/references/delete.md +39 -0
- package/skills/ae-team/references/list-projects.md +45 -0
- package/skills/ae-team/references/list-templates.md +38 -0
- package/skills/ae-team/references/list.md +39 -0
- package/skills/ae-team/references/run-artifacts.md +51 -0
- package/skills/ae-team/references/run-cancel.md +38 -0
- package/skills/ae-team/references/run-chat.md +57 -0
- package/skills/ae-team/references/run-reply.md +41 -0
- package/skills/ae-team/references/run-result.md +75 -0
- package/skills/ae-team/references/run-start.md +73 -0
- package/skills/ae-team/references/run-watch.md +82 -0
- package/skills/ae-team/references/update.md +47 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MultiselectCancelled,
|
|
3
|
+
SKILL_MANIFEST_FILE,
|
|
4
|
+
describeSource,
|
|
5
|
+
getCurrentWorkspace,
|
|
6
|
+
promptMultiselect,
|
|
7
|
+
promptSingleSelect,
|
|
8
|
+
readSkillManifestEntries,
|
|
9
|
+
scanMcps,
|
|
10
|
+
scanSkills,
|
|
11
|
+
writeSkillManifestEntries
|
|
12
|
+
} from "./chunk-6T7245YE.js";
|
|
13
|
+
import {
|
|
14
|
+
TeAgentApiError,
|
|
15
|
+
TeAgentCredentialsError,
|
|
16
|
+
getSandboxSyncPullCandidates,
|
|
17
|
+
postSandboxSyncPull,
|
|
18
|
+
postToMainApp
|
|
19
|
+
} from "./chunk-TG64AQV4.js";
|
|
20
|
+
import {
|
|
21
|
+
printError
|
|
22
|
+
} from "./chunk-B4UL2VIJ.js";
|
|
23
|
+
import "./chunk-MNHE6SSI.js";
|
|
24
|
+
|
|
25
|
+
// src/commands/sync/index.ts
|
|
26
|
+
import Table from "cli-table3";
|
|
27
|
+
|
|
28
|
+
// src/commands/sync/local-copy.ts
|
|
29
|
+
import {
|
|
30
|
+
cpSync,
|
|
31
|
+
existsSync,
|
|
32
|
+
mkdirSync,
|
|
33
|
+
realpathSync,
|
|
34
|
+
rmSync,
|
|
35
|
+
statSync
|
|
36
|
+
} from "fs";
|
|
37
|
+
import path from "path";
|
|
38
|
+
var SKILL_SLUG_RE = /^[a-z0-9-]+$/;
|
|
39
|
+
function updateSkillManifestForSource(sourceDir, slug) {
|
|
40
|
+
if (!SKILL_SLUG_RE.test(slug)) {
|
|
41
|
+
throw new Error(`\u975E\u6CD5 Skill slug: ${slug}`);
|
|
42
|
+
}
|
|
43
|
+
const sourceAbs = path.resolve(sourceDir);
|
|
44
|
+
if (!statSync(sourceAbs).isDirectory()) {
|
|
45
|
+
throw new Error(`Skill \u6E90\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55: ${sourceDir}`);
|
|
46
|
+
}
|
|
47
|
+
const manifestPath = path.join(path.dirname(sourceAbs), SKILL_MANIFEST_FILE);
|
|
48
|
+
const manifest = readSkillManifestEntries(manifestPath);
|
|
49
|
+
const nextEntry = { dirName: slug, scope: "personal" };
|
|
50
|
+
const existingIndex = manifest.findIndex((entry) => entry.dirName === slug);
|
|
51
|
+
if (existingIndex >= 0 && manifest[existingIndex].scope === nextEntry.scope) {
|
|
52
|
+
return { manifestPath, changed: false };
|
|
53
|
+
}
|
|
54
|
+
const nextManifest = manifest.slice();
|
|
55
|
+
if (existingIndex >= 0) {
|
|
56
|
+
nextManifest[existingIndex] = nextEntry;
|
|
57
|
+
} else {
|
|
58
|
+
nextManifest.push(nextEntry);
|
|
59
|
+
}
|
|
60
|
+
writeSkillManifestEntries(manifestPath, nextManifest);
|
|
61
|
+
return { manifestPath, changed: true };
|
|
62
|
+
}
|
|
63
|
+
function copySkillPackageToTarget(args) {
|
|
64
|
+
if (!SKILL_SLUG_RE.test(args.slug)) {
|
|
65
|
+
throw new Error(`\u975E\u6CD5 Skill slug: ${args.slug}`);
|
|
66
|
+
}
|
|
67
|
+
if (!path.isAbsolute(args.targetRoot)) {
|
|
68
|
+
throw new Error(`skillTargetRoot \u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84: ${args.targetRoot}`);
|
|
69
|
+
}
|
|
70
|
+
const sourceReal = realpathSync(args.sourceDir);
|
|
71
|
+
if (!statSync(sourceReal).isDirectory()) {
|
|
72
|
+
throw new Error(`Skill \u6E90\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55: ${args.sourceDir}`);
|
|
73
|
+
}
|
|
74
|
+
const targetDir = path.join(args.targetRoot, args.slug);
|
|
75
|
+
const targetAbs = path.resolve(targetDir);
|
|
76
|
+
if (targetAbs === sourceReal || targetAbs.startsWith(`${sourceReal}${path.sep}`)) {
|
|
77
|
+
return { targetDir, skipped: true };
|
|
78
|
+
}
|
|
79
|
+
if (existsSync(targetDir)) {
|
|
80
|
+
const targetReal = realpathSync(targetDir);
|
|
81
|
+
if (targetReal === sourceReal) {
|
|
82
|
+
return { targetDir, skipped: true };
|
|
83
|
+
}
|
|
84
|
+
rmSync(targetDir, { recursive: true, force: true });
|
|
85
|
+
}
|
|
86
|
+
mkdirSync(args.targetRoot, { recursive: true });
|
|
87
|
+
cpSync(sourceReal, targetDir, { recursive: true, dereference: true });
|
|
88
|
+
return { targetDir, skipped: false };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/commands/sync/index.ts
|
|
92
|
+
function redactEnv(env) {
|
|
93
|
+
if (!env) return void 0;
|
|
94
|
+
const out = {};
|
|
95
|
+
for (const [k, v] of Object.entries(env)) {
|
|
96
|
+
if (/TOKEN|SECRET|KEY|PASSWORD/i.test(k)) {
|
|
97
|
+
out[k] = "***";
|
|
98
|
+
} else {
|
|
99
|
+
out[k] = v;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
function skillToItem(s) {
|
|
105
|
+
return {
|
|
106
|
+
kind: "skill",
|
|
107
|
+
slug: s.slug,
|
|
108
|
+
scope: "personal",
|
|
109
|
+
source: s.source,
|
|
110
|
+
workspacePath: s.workspacePath,
|
|
111
|
+
event: "upsert",
|
|
112
|
+
dirPath: s.dirPath,
|
|
113
|
+
content: s.content,
|
|
114
|
+
checksum: s.checksum,
|
|
115
|
+
mtime: s.mtime
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function mcpToItem(m, includeSecrets) {
|
|
119
|
+
return {
|
|
120
|
+
kind: "mcp",
|
|
121
|
+
slug: m.slug,
|
|
122
|
+
scope: "personal",
|
|
123
|
+
source: m.source,
|
|
124
|
+
workspacePath: m.workspacePath,
|
|
125
|
+
event: "upsert",
|
|
126
|
+
transport: m.transport,
|
|
127
|
+
url: m.url,
|
|
128
|
+
command: m.command,
|
|
129
|
+
args: m.args,
|
|
130
|
+
env: includeSecrets ? m.env : redactEnv(m.env),
|
|
131
|
+
headers: m.headers
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async function selectSkills() {
|
|
135
|
+
const all = scanSkills();
|
|
136
|
+
if (all.length === 0) {
|
|
137
|
+
process.stderr.write("\u672A\u627E\u5230\u4EFB\u4F55 Skill\uFF08\u626B\u63CF\u4E86\u5F53\u524D\u5DE5\u4F5C\u7A7A\u95F4 .claude/skills\uFF09\n");
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
all.sort((a, b) => {
|
|
141
|
+
if (a.source !== b.source) return a.source === "global" ? -1 : 1;
|
|
142
|
+
return a.slug.localeCompare(b.slug);
|
|
143
|
+
});
|
|
144
|
+
const items = all.map((s) => ({
|
|
145
|
+
value: s,
|
|
146
|
+
label: s.slug,
|
|
147
|
+
group: describeSource(s),
|
|
148
|
+
hint: s.isSymlink ? "(symlink)" : void 0
|
|
149
|
+
}));
|
|
150
|
+
const picked = await promptMultiselect({ title: "\u9009\u62E9\u8981\u63A8\u9001\u5230\u4E3B\u5E94\u7528\u7684 Skill", items });
|
|
151
|
+
return picked.map(skillToItem);
|
|
152
|
+
}
|
|
153
|
+
async function selectMcps(includeSecrets) {
|
|
154
|
+
const all = scanMcps();
|
|
155
|
+
if (all.length === 0) {
|
|
156
|
+
process.stderr.write("\u672A\u627E\u5230\u4EFB\u4F55 MCP\uFF08\u626B\u63CF\u4E86\u5F53\u524D\u5DE5\u4F5C\u7A7A\u95F4 .mcp.json / .claude/.claude.json \u4E0E\u5168\u5C40 ~/.claude.json\uFF09\n");
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
all.sort((a, b) => {
|
|
160
|
+
if (a.source !== b.source) return a.source === "global" ? -1 : 1;
|
|
161
|
+
return a.slug.localeCompare(b.slug);
|
|
162
|
+
});
|
|
163
|
+
const items = all.map((m) => ({
|
|
164
|
+
value: m,
|
|
165
|
+
label: m.slug,
|
|
166
|
+
group: describeSource(m),
|
|
167
|
+
hint: m.hasSecrets && !includeSecrets ? "(env \u5DF2\u8131\u654F)" : void 0
|
|
168
|
+
}));
|
|
169
|
+
const picked = await promptMultiselect({ title: "\u9009\u62E9\u8981\u63A8\u9001\u5230\u4E3B\u5E94\u7528\u7684 MCP", items });
|
|
170
|
+
return picked.map((m) => mcpToItem(m, includeSecrets));
|
|
171
|
+
}
|
|
172
|
+
function renderResults(results) {
|
|
173
|
+
const table = new Table({ head: ["kind", "slug", "status", "message"], wordWrap: true });
|
|
174
|
+
for (const r of results) {
|
|
175
|
+
table.push([r.kind, r.slug, r.status, r.message ?? ""]);
|
|
176
|
+
}
|
|
177
|
+
process.stdout.write(table.toString() + "\n");
|
|
178
|
+
const failed = results.filter((r) => r.status === "failed").length;
|
|
179
|
+
if (failed > 0) {
|
|
180
|
+
process.stderr.write(`
|
|
181
|
+
\u2717 \u6709 ${failed} \u9879\u5931\u8D25
|
|
182
|
+
`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function selectPullResources(args) {
|
|
186
|
+
const all = args.candidates.filter((candidate) => candidate.selected).sort((a, b) => {
|
|
187
|
+
const scopeOrder = {
|
|
188
|
+
system: 0,
|
|
189
|
+
company: 1,
|
|
190
|
+
personal: 2
|
|
191
|
+
};
|
|
192
|
+
const scopeDiff = scopeOrder[a.scope] - scopeOrder[b.scope];
|
|
193
|
+
return scopeDiff !== 0 ? scopeDiff : a.name.localeCompare(b.name);
|
|
194
|
+
});
|
|
195
|
+
if (all.length === 0) {
|
|
196
|
+
process.stderr.write(`${args.title} \u65E0\u53EF\u540C\u6B65\u5019\u9009
|
|
197
|
+
`);
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
const items = all.map((candidate) => ({
|
|
201
|
+
value: candidate,
|
|
202
|
+
label: `${candidate.name} ${candidate.scope}`,
|
|
203
|
+
preselected: true
|
|
204
|
+
}));
|
|
205
|
+
return promptMultiselect({ title: args.title, items });
|
|
206
|
+
}
|
|
207
|
+
function toHttpItems(items) {
|
|
208
|
+
return items.map((item) => {
|
|
209
|
+
if (item.kind === "skill") {
|
|
210
|
+
const { kind: _kind2, dirPath: _dirPath, ...rest2 } = item;
|
|
211
|
+
return rest2;
|
|
212
|
+
}
|
|
213
|
+
const { kind: _kind, ...rest } = item;
|
|
214
|
+
return rest;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
async function pushItems(kind, items) {
|
|
218
|
+
if (items.length === 0) return { results: [] };
|
|
219
|
+
try {
|
|
220
|
+
const resp = await postToMainApp("/api/sandbox/sync/push", {
|
|
221
|
+
kind,
|
|
222
|
+
items: toHttpItems(items)
|
|
223
|
+
});
|
|
224
|
+
return { skillTargetRoot: resp.skillTargetRoot, results: resp.results ?? [] };
|
|
225
|
+
} catch (err) {
|
|
226
|
+
if (err instanceof TeAgentApiError) {
|
|
227
|
+
return {
|
|
228
|
+
results: items.map((it) => ({
|
|
229
|
+
kind: it.kind,
|
|
230
|
+
slug: it.slug,
|
|
231
|
+
status: "failed",
|
|
232
|
+
message: `${err.code ?? err.status} ${err.message}`
|
|
233
|
+
}))
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
throw err;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function copySyncedSkillPackages(skillItems, resp) {
|
|
240
|
+
if (skillItems.length === 0) return;
|
|
241
|
+
const bySlug = new Map(skillItems.map((item) => [item.slug, item]));
|
|
242
|
+
for (const result of resp.results) {
|
|
243
|
+
if (result.kind !== "skill" || result.status !== "synced") continue;
|
|
244
|
+
const item = bySlug.get(result.slug);
|
|
245
|
+
if (!item) continue;
|
|
246
|
+
if (!resp.skillTargetRoot) {
|
|
247
|
+
result.status = "failed";
|
|
248
|
+
result.message = "\u4E3B\u5E94\u7528\u54CD\u5E94\u7F3A\u5C11 skillTargetRoot\uFF0C\u65E0\u6CD5\u590D\u5236 Skill package";
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const copied = copySkillPackageToTarget({
|
|
253
|
+
sourceDir: item.dirPath,
|
|
254
|
+
targetRoot: resp.skillTargetRoot,
|
|
255
|
+
slug: item.slug
|
|
256
|
+
});
|
|
257
|
+
updateSkillManifestForSource(item.dirPath, item.slug);
|
|
258
|
+
if (copied.skipped) {
|
|
259
|
+
result.message = "\u6E90\u76EE\u5F55\u5DF2\u662F\u76EE\u6807\u76EE\u5F55\uFF0C\u8DF3\u8FC7\u672C\u5730\u590D\u5236";
|
|
260
|
+
}
|
|
261
|
+
} catch (err) {
|
|
262
|
+
result.status = "failed";
|
|
263
|
+
result.message = `\u672C\u5730\u590D\u5236\u5931\u8D25\uFF1A${err?.message ?? String(err)}`;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async function selectDirection(optsDirection) {
|
|
268
|
+
if (optsDirection === "push" || optsDirection === "pull") return optsDirection;
|
|
269
|
+
if (optsDirection) {
|
|
270
|
+
throw new Error("--direction \u4EC5\u652F\u6301 push \u6216 pull");
|
|
271
|
+
}
|
|
272
|
+
return promptSingleSelect({
|
|
273
|
+
title: "\u540C\u6B65\u65B9\u5411\uFF1F",
|
|
274
|
+
items: [
|
|
275
|
+
{ value: "push", label: "\u5DE5\u4F5C\u7A7A\u95F4 -> \u4E3B\u5E94\u7528" },
|
|
276
|
+
{ value: "pull", label: "\u4E3B\u5E94\u7528 -> \u5DE5\u4F5C\u7A7A\u95F4" }
|
|
277
|
+
]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
async function selectKind(optsKind) {
|
|
281
|
+
if (optsKind === "skill" || optsKind === "mcp" || optsKind === "both") return optsKind;
|
|
282
|
+
if (optsKind) {
|
|
283
|
+
throw new Error("--kind \u4EC5\u652F\u6301 skill\u3001mcp \u6216 both");
|
|
284
|
+
}
|
|
285
|
+
return promptSingleSelect({
|
|
286
|
+
title: "\u540C\u6B65\u54EA\u7C7B\u8D44\u6E90\uFF1F",
|
|
287
|
+
items: [
|
|
288
|
+
{ value: "skill", label: "Skills" },
|
|
289
|
+
{ value: "mcp", label: "MCPs" },
|
|
290
|
+
{ value: "both", label: "Skills + MCPs" }
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async function runPush(kind, includeSecrets) {
|
|
295
|
+
const skillItems = kind !== "mcp" ? await selectSkills() : [];
|
|
296
|
+
const mcpItems = kind !== "skill" ? await selectMcps(includeSecrets) : [];
|
|
297
|
+
if (skillItems.length === 0 && mcpItems.length === 0) {
|
|
298
|
+
process.stderr.write("\u672A\u9009\u62E9\u4EFB\u4F55\u9879\uFF0C\u5DF2\u9000\u51FA\n");
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
process.stderr.write(`\u63A8\u9001 ${skillItems.length} \u4E2A Skill / ${mcpItems.length} \u4E2A MCP ...
|
|
302
|
+
`);
|
|
303
|
+
const allResults = [];
|
|
304
|
+
if (skillItems.length > 0) {
|
|
305
|
+
const skillResp = await pushItems("skill", skillItems);
|
|
306
|
+
copySyncedSkillPackages(skillItems, skillResp);
|
|
307
|
+
allResults.push(...skillResp.results);
|
|
308
|
+
}
|
|
309
|
+
if (mcpItems.length > 0) {
|
|
310
|
+
const mcpResp = await pushItems("mcp", mcpItems);
|
|
311
|
+
allResults.push(...mcpResp.results);
|
|
312
|
+
}
|
|
313
|
+
renderResults(allResults);
|
|
314
|
+
}
|
|
315
|
+
function pullResultRows(resp) {
|
|
316
|
+
return (resp.results ?? []).map((result) => ({
|
|
317
|
+
kind: result.kind,
|
|
318
|
+
slug: result.name,
|
|
319
|
+
status: result.status,
|
|
320
|
+
message: result.message
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
async function runPull(kind) {
|
|
324
|
+
const workspace = getCurrentWorkspace();
|
|
325
|
+
if (!workspace) {
|
|
326
|
+
throw new Error("\u672A\u8BC6\u522B\u5F53\u524D\u5DE5\u4F5C\u7A7A\u95F4\uFF0C\u8BF7\u5728 /home/ta/workspaces/<workspace> \u4E0B\u6267\u884C");
|
|
327
|
+
}
|
|
328
|
+
const candidates = await getSandboxSyncPullCandidates({
|
|
329
|
+
workspacePath: workspace.name,
|
|
330
|
+
kind
|
|
331
|
+
});
|
|
332
|
+
const skillItems = kind !== "mcp" ? await selectPullResources({
|
|
333
|
+
title: "\u9009\u62E9\u8981\u540C\u6B65\u5230\u5DE5\u4F5C\u7A7A\u95F4\u7684 Skill",
|
|
334
|
+
candidates: candidates.skills ?? []
|
|
335
|
+
}) : [];
|
|
336
|
+
const mcpItems = kind !== "skill" ? await selectPullResources({
|
|
337
|
+
title: "\u9009\u62E9\u8981\u540C\u6B65\u5230\u5DE5\u4F5C\u7A7A\u95F4\u7684 MCP",
|
|
338
|
+
candidates: candidates.mcp ?? []
|
|
339
|
+
}) : [];
|
|
340
|
+
if (skillItems.length === 0 && mcpItems.length === 0) {
|
|
341
|
+
process.stderr.write("\u672A\u9009\u62E9\u4EFB\u4F55\u9879\uFF0C\u5DF2\u9000\u51FA\n");
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
process.stderr.write(`\u540C\u6B65\u5230\u5DE5\u4F5C\u7A7A\u95F4 ${skillItems.length} \u4E2A Skill / ${mcpItems.length} \u4E2A MCP ...
|
|
345
|
+
`);
|
|
346
|
+
const resp = await postSandboxSyncPull({
|
|
347
|
+
workspacePath: workspace.name,
|
|
348
|
+
kind,
|
|
349
|
+
skills: skillItems.map((item) => item.id),
|
|
350
|
+
mcp: mcpItems.map((item) => item.id),
|
|
351
|
+
ifUnmodifiedSince: candidates.mtime
|
|
352
|
+
});
|
|
353
|
+
renderResults(pullResultRows(resp));
|
|
354
|
+
}
|
|
355
|
+
function registerSync(program) {
|
|
356
|
+
program.command("sync").description("Sync Skills / MCPs between current workspace and te-claude main app").option("--direction <direction>", "push | pull (skip interactive direction picker)").option("--include-secrets", "Include MCP env secrets (TOKEN/SECRET/KEY) in push", false).option("--kind <kind>", "skill | mcp | both (skip interactive picker)").action(async (opts) => {
|
|
357
|
+
try {
|
|
358
|
+
const direction = await selectDirection(opts.direction);
|
|
359
|
+
const kind = await selectKind(opts.kind);
|
|
360
|
+
if (direction === "push") await runPush(kind, !!opts.includeSecrets);
|
|
361
|
+
else await runPull(kind);
|
|
362
|
+
} catch (err) {
|
|
363
|
+
if (err instanceof MultiselectCancelled) {
|
|
364
|
+
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (err instanceof TeAgentCredentialsError) {
|
|
368
|
+
printError("config", err.message, err.hint);
|
|
369
|
+
process.exit(1);
|
|
370
|
+
}
|
|
371
|
+
if (err instanceof TeAgentApiError) {
|
|
372
|
+
printError("api", err.message, err.code);
|
|
373
|
+
process.exit(1);
|
|
374
|
+
}
|
|
375
|
+
const e = err;
|
|
376
|
+
printError("api", e?.message ?? String(err));
|
|
377
|
+
process.exit(1);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
export {
|
|
382
|
+
registerSync
|
|
383
|
+
};
|