@social-data/social-neuron-subscription 1.0.0-beta.29 → 1.0.0-beta.30
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 +6 -4
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -39,15 +39,17 @@ function resolveConfig() {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function emit(env) {
|
|
42
|
-
process.stdout.write(JSON.stringify(env) + "\n");
|
|
43
42
|
const dataExit = env.ok && env.data && env.data.meta && env.data.meta.exit_code;
|
|
44
43
|
const status = env.ok
|
|
45
44
|
? ([0, 1, 2].includes(dataExit) ? dataExit : 0)
|
|
46
45
|
: (EXIT[env.error && env.error.type] ?? 1);
|
|
47
|
-
|
|
46
|
+
// 管道输出为异步写入;自然退出让stdout缓冲排空,保留原有业务退出码。
|
|
47
|
+
process.exitCode = status;
|
|
48
|
+
process.stdout.write(JSON.stringify(env) + "\n");
|
|
48
49
|
}
|
|
49
50
|
function fail(type, code, message, extra) {
|
|
50
51
|
emit({ ok: false, error: { type, code, message, ...(extra || {}) } });
|
|
52
|
+
return true; // parseArgs用此标记短路,错误后不得继续请求接口。
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
// 网关统一 {code,msg,data}(code=0 成功)→ 归一化 {ok,data|error}。
|
|
@@ -180,7 +182,7 @@ function printHelp(action) {
|
|
|
180
182
|
if (action) {
|
|
181
183
|
const c = findCmd(action);
|
|
182
184
|
if (!c) return fail("validation", "UNKNOWN_COMMAND", "未知命令 " + action);
|
|
183
|
-
const u = usageOf(c); w(u._text); w(""); w("示例:" + u.example);
|
|
185
|
+
const u = usageOf(c); w(u._text); w(""); w("示例:" + u.example); process.exitCode = 0; return;
|
|
184
186
|
}
|
|
185
187
|
w(COMMAND + " v" + VERSION + " — Social Neuron 能力 CLI(能力:" + CAPABILITY + ";供 AI agent 调用)");
|
|
186
188
|
w("");
|
|
@@ -198,7 +200,7 @@ function printHelp(action) {
|
|
|
198
200
|
w(" " + COMMAND + " --version");
|
|
199
201
|
w("");
|
|
200
202
|
w("鉴权/网关:env NEURON_API_BASE_URL / NEURON_TOKEN 覆盖配置;令牌走头 X-Social-Neuron-CLI-Key。");
|
|
201
|
-
process.
|
|
203
|
+
process.exitCode = 0;
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
function parseArgs(cmd, argv) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@social-data/social-neuron-subscription",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.30",
|
|
4
4
|
"description": "Social Neuron subscription 能力 CLI —— 一能力一命令(social-neuron-subscription),薄客户端直达 /subscription/{op}。",
|
|
5
5
|
"bin": {
|
|
6
6
|
"social-neuron-subscription": "bin/cli.js"
|