maoda-commander-tt 0.0.75 → 0.0.76
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 +25 -6
- package/dist/{chunk-HC46BQKK.js → chunk-LRYUVB4W.js} +96 -108
- package/dist/chunk-LRYUVB4W.js.map +1 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.js +1 -3
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HC46BQKK.js.map +0 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ tt-cli/
|
|
|
56
56
|
│ │ └── command-meta.ts # ICommandMeta: name/description/aliases/hidden/output
|
|
57
57
|
│ ├── commands/ # CLI 表现层,每个命令组一个目录
|
|
58
58
|
│ │ ├── index.ts # 顶层注册表 createRootCommands()
|
|
59
|
-
│ │ ├── ai/ deploy/ git/ hello/ pippit/
|
|
59
|
+
│ │ ├── ai/ deploy/ git/ hello/ pippit/ tool/
|
|
60
60
|
│ ├── modules/ # 领域逻辑:不依赖 commander,返回 Result<T>
|
|
61
61
|
│ │ ├── ark/ git/ pippit/ static-deploy/ video-generation/ xyq/ xyq-tasks/
|
|
62
62
|
│ ├── bedrock/ # 与业务无关的基础设施
|
|
@@ -92,6 +92,22 @@ pnpm test
|
|
|
92
92
|
pnpm build && pnpm test:dist
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
## 拉取仓库及子模块
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
tt g l
|
|
99
|
+
tt g l --help
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
从当前 Git 仓库的任意子目录运行均可:先在仓库根目录执行 `git pull
|
|
103
|
+
--no-recurse-submodules`,成功后执行 `git submodule update --init --recursive
|
|
104
|
+
--checkout`。pull 沿用 Git 的上游分支及合并/rebase 配置;未初始化及嵌套子模块
|
|
105
|
+
一并同步到仓库记录的 commit,无子模块时也能正常完成,不追随子模块远端分支最新版本。
|
|
106
|
+
|
|
107
|
+
子模块通常切为 detached HEAD;不强制覆盖本地修改,本命令不额外执行 stash。任一步失败立即
|
|
108
|
+
停止并返回退出码 1,保留 Git 原始输出;若子模块同步失败,主仓库及已经完成的子模块
|
|
109
|
+
更新会保留,修复报错后可再次运行。此命令透传 Git 输出,不返回 JSON envelope。
|
|
110
|
+
|
|
95
111
|
## 读写配置
|
|
96
112
|
|
|
97
113
|
```bash
|
|
@@ -334,8 +350,9 @@ writer 写入。它的 `value` 是包含以下五个字段的 JSON 字符串,
|
|
|
334
350
|
Nginx 将 `/assets/<编码后的key>` 302 到固定 COS 桶的 `/tt/<编码后的key>`,配置见
|
|
335
351
|
[资源入口路由](ops/nginx/tt-assets-location.conf)。302 保留原始 URL 编码,避免中文、
|
|
336
352
|
空格及保留字符被二次解释。入口省略 `tt/`,但跳转的 Location 和浏览器网络记录仍能
|
|
337
|
-
看到 COS
|
|
338
|
-
|
|
353
|
+
看到 COS 对象路径。白名单 GET/HEAD 302 的 Nginx 响应缓存 30 天,其余跳转与
|
|
354
|
+
错误、OPTIONS 响应为 `no-store`;最终 COS 对象的缓存头按上述 key 后缀规则设置。
|
|
355
|
+
统一规则见 [静态缓存配置](ops/nginx/static-cache.conf) 与
|
|
339
356
|
[普通静态文件路由](ops/nginx/static-files-location.conf)。更新内容或资源入口映射时,
|
|
340
357
|
要考虑已经缓存的响应,使用新 key 发布新内容。
|
|
341
358
|
|
|
@@ -425,9 +442,11 @@ loopback HTTP 除外),客户端不跟随重定向,以免将 token 发送
|
|
|
425
442
|
这个根目录下的项目;需要更换时同时更新服务器和跨应用设置。
|
|
426
443
|
|
|
427
444
|
服务器需要预先配置 API 和 nginx 路由,参见 [部署运维说明](ops/static-deploy/README.md)。
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
445
|
+
当前服务器在静态入口上保留既有跨域响应头、OPTIONS 预检及 HSTS。白名单静态资源的
|
|
446
|
+
GET/HEAD 响应使用 `Cache-Control: max-age=2592000`(30 天);HTML、JSON、播放列表、
|
|
447
|
+
无扩展名和未知后缀使用 `no-cache`,允许浏览器缓存,但再次使用前向服务器确认内容
|
|
448
|
+
是否更新。目录清单和部署 API 使用 `no-store`。覆盖白名单静态资源不会刷新客户端
|
|
449
|
+
已有的 30 天缓存,新内容应使用版本文件名。
|
|
431
450
|
|
|
432
451
|
### 目录页与 AI 返回值
|
|
433
452
|
|
|
@@ -8792,6 +8792,39 @@ function buildMergeRequestUrl(repoUrl, sourceBranch) {
|
|
|
8792
8792
|
return `${repoUrl}/merge_requests/new?merge_request=&source_branch=${encodeURIComponent(sourceBranch)}`;
|
|
8793
8793
|
}
|
|
8794
8794
|
|
|
8795
|
+
// src/modules/git/git-pull.ts
|
|
8796
|
+
import { err as err32 } from "rockbed/error";
|
|
8797
|
+
async function gitPullWithSubmodules() {
|
|
8798
|
+
const rootResult = await captureGit(["rev-parse", "--show-toplevel"]);
|
|
8799
|
+
if (!rootResult.ok) {
|
|
8800
|
+
return rootResult;
|
|
8801
|
+
}
|
|
8802
|
+
const atRoot = ["-C", rootResult.value];
|
|
8803
|
+
const pullResult = await runGit([
|
|
8804
|
+
...atRoot,
|
|
8805
|
+
"pull",
|
|
8806
|
+
"--no-recurse-submodules"
|
|
8807
|
+
]);
|
|
8808
|
+
if (!pullResult.ok) {
|
|
8809
|
+
return err32(pullResult.code, `\u62C9\u53D6\u5931\u8D25\uFF0C\u672A\u6267\u884C\u5B50\u6A21\u5757\u540C\u6B65\u3002${pullResult.msg}`);
|
|
8810
|
+
}
|
|
8811
|
+
const updateResult = await runGit([
|
|
8812
|
+
...atRoot,
|
|
8813
|
+
"submodule",
|
|
8814
|
+
"update",
|
|
8815
|
+
"--init",
|
|
8816
|
+
"--recursive",
|
|
8817
|
+
"--checkout"
|
|
8818
|
+
]);
|
|
8819
|
+
if (!updateResult.ok) {
|
|
8820
|
+
return err32(
|
|
8821
|
+
updateResult.code,
|
|
8822
|
+
`\u4E3B\u4ED3\u5E93\u5DF2\u62C9\u53D6\uFF0C\u5B50\u6A21\u5757\u540C\u6B65\u672A\u5B8C\u6210\uFF0C\u90E8\u5206\u5B50\u6A21\u5757\u53EF\u80FD\u5DF2\u66F4\u65B0\u3002${updateResult.msg}`
|
|
8823
|
+
);
|
|
8824
|
+
}
|
|
8825
|
+
return updateResult;
|
|
8826
|
+
}
|
|
8827
|
+
|
|
8795
8828
|
// src/commands/git/git-base-command.ts
|
|
8796
8829
|
var GitBaseCommand = class extends BaseCommand {
|
|
8797
8830
|
_defaultOutputMode() {
|
|
@@ -8919,6 +8952,33 @@ var GitPpCommand = class extends GitBaseCommand {
|
|
|
8919
8952
|
}
|
|
8920
8953
|
};
|
|
8921
8954
|
|
|
8955
|
+
// src/commands/git/git-pull-command.ts
|
|
8956
|
+
var GitPullCommand = class extends BaseCommand {
|
|
8957
|
+
constructor(_pull = gitPullWithSubmodules) {
|
|
8958
|
+
super();
|
|
8959
|
+
this._pull = _pull;
|
|
8960
|
+
}
|
|
8961
|
+
_meta() {
|
|
8962
|
+
return {
|
|
8963
|
+
name: "l",
|
|
8964
|
+
description: "\u62C9\u53D6\u5F53\u524D\u4ED3\u5E93\uFF0C\u518D\u6309\u4ED3\u5E93\u6307\u9488\u9012\u5F52\u540C\u6B65\u5B50\u6A21\u5757",
|
|
8965
|
+
output: "passthrough"
|
|
8966
|
+
};
|
|
8967
|
+
}
|
|
8968
|
+
_agentContract() {
|
|
8969
|
+
return [
|
|
8970
|
+
"\u5728\u5F53\u524D Git \u4ED3\u5E93\u6839\u76EE\u5F55\u6267\u884C pull\uFF0C\u6CBF\u7528 Git \u7684\u4E0A\u6E38\u5206\u652F\u53CA\u5408\u5E76/rebase \u914D\u7F6E\u3002",
|
|
8971
|
+
"pull \u6210\u529F\u540E\u521D\u59CB\u5316\u5E76\u9012\u5F52 checkout \u5B50\u6A21\u5757\u5230\u4ED3\u5E93\u8BB0\u5F55\u7684 commit\uFF0C\u4E0D\u8FFD\u968F\u8FDC\u7AEF\u5206\u652F\u6700\u65B0\u7248\u672C\uFF1B\u65E0\u5B50\u6A21\u5757\u4E5F\u53EF\u4F7F\u7528\u3002",
|
|
8972
|
+
"\u5B50\u6A21\u5757\u901A\u5E38\u5207\u4E3A detached HEAD\uFF1B\u4E0D\u5F3A\u5236\u8986\u76D6\u4FEE\u6539\uFF0C\u672C\u547D\u4EE4\u4E0D\u989D\u5916\u6267\u884C stash\u3002",
|
|
8973
|
+
"\u4EFB\u4E00\u6B65\u5931\u8D25\u5373\u505C\u6B62\uFF0C\u5DF2\u5B8C\u6210\u7684\u66F4\u65B0\u4FDD\u7559\uFF1B\u4FEE\u590D Git \u62A5\u9519\u540E\u53EF\u518D\u6B21\u8FD0\u884C\u3002",
|
|
8974
|
+
"stdout \u4E3A Git \u539F\u59CB\u8F93\u51FA\uFF0C\u4E0D\u4F7F\u7528 JSON envelope\uFF1B\u5931\u8D25\u9000\u51FA\u7801\u4E3A 1\u3002"
|
|
8975
|
+
];
|
|
8976
|
+
}
|
|
8977
|
+
async _execute() {
|
|
8978
|
+
return this._pull();
|
|
8979
|
+
}
|
|
8980
|
+
};
|
|
8981
|
+
|
|
8922
8982
|
// src/commands/git/git-command.ts
|
|
8923
8983
|
var GitCommand = class extends BaseCommandGroup {
|
|
8924
8984
|
_meta() {
|
|
@@ -8930,6 +8990,7 @@ var GitCommand = class extends BaseCommandGroup {
|
|
|
8930
8990
|
};
|
|
8931
8991
|
}
|
|
8932
8992
|
_registerSubcommands() {
|
|
8993
|
+
this._addSubcommand(new GitPullCommand());
|
|
8933
8994
|
this._addSubcommand(new GitMmCommand());
|
|
8934
8995
|
this._addSubcommand(new GitPpCommand());
|
|
8935
8996
|
this._addSubcommand(new GitCheckoutCommand());
|
|
@@ -8995,13 +9056,13 @@ var HelloCommand = class extends BaseCommandGroup {
|
|
|
8995
9056
|
|
|
8996
9057
|
// src/modules/kv/kv-service.ts
|
|
8997
9058
|
import { Disposable as Disposable18 } from "rockbed/dispose";
|
|
8998
|
-
import { err as
|
|
9059
|
+
import { err as err34, ok as ok56 } from "rockbed/error";
|
|
8999
9060
|
|
|
9000
9061
|
// src/modules/kv/kv-value.ts
|
|
9001
|
-
import { err as
|
|
9062
|
+
import { err as err33, ok as ok55 } from "rockbed/error";
|
|
9002
9063
|
function validateKvAddress(scope, key) {
|
|
9003
9064
|
if (typeof scope !== "string" || scope.length === 0 || typeof key !== "string" || key.length === 0) {
|
|
9004
|
-
return
|
|
9065
|
+
return err33(1, "scope \u548C key \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32", {
|
|
9005
9066
|
stage: "input",
|
|
9006
9067
|
...typeof scope === "string" ? { scope } : {},
|
|
9007
9068
|
...typeof key === "string" ? { key } : {}
|
|
@@ -9014,16 +9075,16 @@ function parseKvValue(text) {
|
|
|
9014
9075
|
try {
|
|
9015
9076
|
value = JSON.parse(text);
|
|
9016
9077
|
} catch (caught) {
|
|
9017
|
-
return
|
|
9078
|
+
return err33(1, `value \u5FC5\u987B\u662F\u5408\u6CD5 JSON\uFF1A${caught instanceof Error ? caught.message : String(caught)}`, { stage: "input" });
|
|
9018
9079
|
}
|
|
9019
9080
|
return validateKvValue(value);
|
|
9020
9081
|
}
|
|
9021
9082
|
function validateKvValue(value) {
|
|
9022
9083
|
if (value === null || value === void 0) {
|
|
9023
|
-
return
|
|
9084
|
+
return err33(1, "set \u4E0D\u63A5\u53D7\u9876\u5C42 null \u6216\u7F3A\u5931\u7684 value\uFF1B\u5220\u9664\u8BF7\u4F7F\u7528 tt kv delete", { stage: "input" });
|
|
9024
9085
|
}
|
|
9025
9086
|
if (!isJsonValue(value)) {
|
|
9026
|
-
return
|
|
9087
|
+
return err33(1, "value \u5FC5\u987B\u662F\u53EF\u5B8C\u6574\u5E8F\u5217\u5316\u7684 JSON\uFF0C\u6240\u6709\u6570\u5B57\u5FC5\u987B\u6709\u9650", { stage: "input" });
|
|
9027
9088
|
}
|
|
9028
9089
|
return ok55(value);
|
|
9029
9090
|
}
|
|
@@ -9095,7 +9156,7 @@ var KvService = class extends Disposable18 {
|
|
|
9095
9156
|
const address = validateKvAddress(scope, key);
|
|
9096
9157
|
if (!address.ok) return address;
|
|
9097
9158
|
const parsed = validateKvValue(value);
|
|
9098
|
-
if (!parsed.ok) return
|
|
9159
|
+
if (!parsed.ok) return err34(parsed.code, parsed.msg, { stage: "input", ...address.value });
|
|
9099
9160
|
return this._write(address.value, parsed.value, "write");
|
|
9100
9161
|
}
|
|
9101
9162
|
async delete(scope, key) {
|
|
@@ -9108,7 +9169,7 @@ var KvService = class extends Disposable18 {
|
|
|
9108
9169
|
try {
|
|
9109
9170
|
body = JSON.stringify({ ...address, value });
|
|
9110
9171
|
} catch (caught) {
|
|
9111
|
-
return
|
|
9172
|
+
return err34(1, `value \u65E0\u6CD5\u5E8F\u5217\u5316\u4E3A JSON\uFF1A${describeError(caught)}`, { stage: "input", ...address });
|
|
9112
9173
|
}
|
|
9113
9174
|
const details = { stage, ...address };
|
|
9114
9175
|
const result = await this._request(KV_URL, {
|
|
@@ -9171,9 +9232,9 @@ function isEnvelope(value) {
|
|
|
9171
9232
|
function failure2(code, message, details, explicitlyRejected = false) {
|
|
9172
9233
|
if ((details.stage === "write" || details.stage === "delete") && !explicitlyRejected) {
|
|
9173
9234
|
const effect = details.stage === "delete" ? "\u5220\u9664" : "\u5199\u5165";
|
|
9174
|
-
return
|
|
9235
|
+
return err34(code, `${message}\uFF1B\u672C\u6B21${effect}\u7ED3\u679C\u672A\u786E\u8BA4\uFF0C\u53EF\u80FD\u5DF2${effect}\uFF0C\u672A\u81EA\u52A8\u91CD\u8BD5`, { ...details, outcome: "unconfirmed" });
|
|
9175
9236
|
}
|
|
9176
|
-
return
|
|
9237
|
+
return err34(code, message, details);
|
|
9177
9238
|
}
|
|
9178
9239
|
function describeError(caught) {
|
|
9179
9240
|
return caught instanceof Error ? caught.message : String(caught);
|
|
@@ -9388,7 +9449,7 @@ var KvCommand = class extends BaseCommandGroup {
|
|
|
9388
9449
|
};
|
|
9389
9450
|
|
|
9390
9451
|
// src/modules/pippit/douyin-video/cn-douyin-video.ts
|
|
9391
|
-
import { err as
|
|
9452
|
+
import { err as err35, ok as ok59 } from "rockbed/error";
|
|
9392
9453
|
|
|
9393
9454
|
// src/modules/pippit/request-json.ts
|
|
9394
9455
|
import { ok as ok58 } from "rockbed/error";
|
|
@@ -9513,7 +9574,7 @@ async function fetchDouyinVideoCn(options, dependencies = {}) {
|
|
|
9513
9574
|
return ok59({ video_url: videoUrl });
|
|
9514
9575
|
}
|
|
9515
9576
|
if (response.ret !== void 0 && String(response.ret) !== "0") {
|
|
9516
|
-
return
|
|
9577
|
+
return err35(
|
|
9517
9578
|
parseErrorCode(response.ret),
|
|
9518
9579
|
response.errmsg?.trim() || "\u6296\u97F3\u89C6\u9891\u89E3\u6790\u63A5\u53E3\u8FD4\u56DE\u9519\u8BEF\u3002"
|
|
9519
9580
|
);
|
|
@@ -9567,79 +9628,8 @@ var PippitCommand = class extends BaseCommandGroup {
|
|
|
9567
9628
|
}
|
|
9568
9629
|
};
|
|
9569
9630
|
|
|
9570
|
-
// src/commands/shortcut/shortcut-definitions.ts
|
|
9571
|
-
var SHORTCUT_DEFINITIONS = [
|
|
9572
|
-
{
|
|
9573
|
-
name: "pippit",
|
|
9574
|
-
aliases: ["pp"],
|
|
9575
|
-
description: "\u542F\u52A8 pippit \u9879\u76EE",
|
|
9576
|
-
cwd: "~/work/pippit",
|
|
9577
|
-
commandLine: "w2 start && emo start platform-business"
|
|
9578
|
-
},
|
|
9579
|
-
{
|
|
9580
|
-
name: "pippit-cn",
|
|
9581
|
-
aliases: ["ppc"],
|
|
9582
|
-
description: "\u5728 pippit \u9879\u76EE\u542F\u52A8 platform-xyq",
|
|
9583
|
-
cwd: "~/work/pippit",
|
|
9584
|
-
commandLine: "w2 start && emo start platform-xyq"
|
|
9585
|
-
}
|
|
9586
|
-
];
|
|
9587
|
-
|
|
9588
|
-
// src/commands/shortcut/shortcut-run-command.ts
|
|
9589
|
-
import { homedir as homedir4 } from "node:os";
|
|
9590
|
-
import { join as join9 } from "node:path";
|
|
9591
|
-
var ShortcutRunCommand = class extends BaseCommand {
|
|
9592
|
-
constructor(_definition) {
|
|
9593
|
-
super();
|
|
9594
|
-
this._definition = _definition;
|
|
9595
|
-
}
|
|
9596
|
-
_meta() {
|
|
9597
|
-
return {
|
|
9598
|
-
name: this._definition.name,
|
|
9599
|
-
description: this._definition.description,
|
|
9600
|
-
aliases: this._definition.aliases,
|
|
9601
|
-
output: "passthrough"
|
|
9602
|
-
};
|
|
9603
|
-
}
|
|
9604
|
-
_agentContract() {
|
|
9605
|
-
return ["stdout/stderr \u539F\u6837\u900F\u4F20\u5B50\u8FDB\u7A0B\u8F93\u51FA\uFF0C\u4E0D\u4F7F\u7528 JSON envelope\uFF1B\u5931\u8D25\u9000\u51FA\u7801\u4E3A 1\u3002"];
|
|
9606
|
-
}
|
|
9607
|
-
_execute(_ctx) {
|
|
9608
|
-
return runProcess(this._definition.commandLine, [], {
|
|
9609
|
-
cwd: expandHomeDir(this._definition.cwd),
|
|
9610
|
-
shell: true
|
|
9611
|
-
});
|
|
9612
|
-
}
|
|
9613
|
-
};
|
|
9614
|
-
function expandHomeDir(path15) {
|
|
9615
|
-
if (path15 === "~") {
|
|
9616
|
-
return homedir4();
|
|
9617
|
-
}
|
|
9618
|
-
if (path15.startsWith("~/")) {
|
|
9619
|
-
return join9(homedir4(), path15.slice(2));
|
|
9620
|
-
}
|
|
9621
|
-
return path15;
|
|
9622
|
-
}
|
|
9623
|
-
|
|
9624
|
-
// src/commands/shortcut/shortcut-command.ts
|
|
9625
|
-
var ShortcutCommand = class extends BaseCommandGroup {
|
|
9626
|
-
_meta() {
|
|
9627
|
-
return {
|
|
9628
|
-
name: "shortcut",
|
|
9629
|
-
description: "\u5E38\u7528 shell \u547D\u4EE4\u5FEB\u6377\u65B9\u5F0F",
|
|
9630
|
-
aliases: ["sc"],
|
|
9631
|
-
hidden: true
|
|
9632
|
-
};
|
|
9633
|
-
}
|
|
9634
|
-
_registerSubcommands() {
|
|
9635
|
-
for (const definition of SHORTCUT_DEFINITIONS) {
|
|
9636
|
-
this._addSubcommand(new ShortcutRunCommand(definition));
|
|
9637
|
-
}
|
|
9638
|
-
}
|
|
9639
|
-
};
|
|
9640
|
-
|
|
9641
9631
|
// src/commands/tool/tool-draw-command.ts
|
|
9642
|
-
import { err as
|
|
9632
|
+
import { err as err36, ok as ok60 } from "rockbed/error";
|
|
9643
9633
|
var ToolDrawCommand = class extends BaseCommand {
|
|
9644
9634
|
_meta() {
|
|
9645
9635
|
return {
|
|
@@ -9670,7 +9660,7 @@ var ToolDrawCommand = class extends BaseCommand {
|
|
|
9670
9660
|
}
|
|
9671
9661
|
const distributionText = stringifyDistributionArg(ctx.args[1]);
|
|
9672
9662
|
if (!distributionText) {
|
|
9673
|
-
return
|
|
9663
|
+
return err36(1, "\u6982\u7387\u5206\u5E03\u4E0D\u80FD\u4E3A\u7A7A");
|
|
9674
9664
|
}
|
|
9675
9665
|
const distributionResult = parseDistribution(distributionText);
|
|
9676
9666
|
if (!distributionResult.ok) {
|
|
@@ -9684,7 +9674,7 @@ var ToolDrawCommand = class extends BaseCommand {
|
|
|
9684
9674
|
function parseCount(value) {
|
|
9685
9675
|
const count = Number(String(value ?? "").trim());
|
|
9686
9676
|
if (!Number.isInteger(count) || count <= 0) {
|
|
9687
|
-
return
|
|
9677
|
+
return err36(1, "\u62BD\u53D6\u4E2A\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570");
|
|
9688
9678
|
}
|
|
9689
9679
|
return ok60(count);
|
|
9690
9680
|
}
|
|
@@ -9706,10 +9696,10 @@ function parseJsonDistribution(value) {
|
|
|
9706
9696
|
parsed = JSON.parse(value);
|
|
9707
9697
|
} catch (caughtError) {
|
|
9708
9698
|
const msg = caughtError instanceof Error ? caughtError.message : String(caughtError);
|
|
9709
|
-
return
|
|
9699
|
+
return err36(1, `JSON \u6982\u7387\u5206\u5E03\u89E3\u6790\u5931\u8D25: ${msg}`);
|
|
9710
9700
|
}
|
|
9711
9701
|
if (!Array.isArray(parsed)) {
|
|
9712
|
-
return
|
|
9702
|
+
return err36(1, "JSON \u6982\u7387\u5206\u5E03\u5FC5\u987B\u662F\u6570\u7EC4");
|
|
9713
9703
|
}
|
|
9714
9704
|
const entries = [];
|
|
9715
9705
|
for (let index = 0; index < parsed.length; index += 1) {
|
|
@@ -9724,7 +9714,7 @@ function parseJsonDistribution(value) {
|
|
|
9724
9714
|
function parseJsonDistributionEntry(value, index) {
|
|
9725
9715
|
const record = asRecord(value);
|
|
9726
9716
|
if (!record) {
|
|
9727
|
-
return
|
|
9717
|
+
return err36(1, `\u7B2C ${index + 1} \u9879\u5FC5\u987B\u662F\u5BF9\u8C61`);
|
|
9728
9718
|
}
|
|
9729
9719
|
const nameResult = parseEntryName(record.name, `\u7B2C ${index + 1} \u9879`);
|
|
9730
9720
|
if (!nameResult.ok) {
|
|
@@ -9754,11 +9744,11 @@ function parseShorthandDistribution(value) {
|
|
|
9754
9744
|
for (let index = 0; index < parts.length; index += 1) {
|
|
9755
9745
|
const part = parts[index].trim();
|
|
9756
9746
|
if (!part) {
|
|
9757
|
-
return
|
|
9747
|
+
return err36(1, `\u7B2C ${index + 1} \u9879\u4E3A\u7A7A`);
|
|
9758
9748
|
}
|
|
9759
9749
|
const separatorIndex = findLastWeightSeparator(part);
|
|
9760
9750
|
if (separatorIndex < 0) {
|
|
9761
|
-
return
|
|
9751
|
+
return err36(1, `\u7B2C ${index + 1} \u9879\u7F3A\u5C11\u6982\u7387\u5206\u9694\u7B26 ":"`);
|
|
9762
9752
|
}
|
|
9763
9753
|
const nameResult = parseEntryName(part.slice(0, separatorIndex), `\u7B2C ${index + 1} \u9879`);
|
|
9764
9754
|
if (!nameResult.ok) {
|
|
@@ -9777,11 +9767,11 @@ function findLastWeightSeparator(value) {
|
|
|
9777
9767
|
}
|
|
9778
9768
|
function parseEntryName(value, label) {
|
|
9779
9769
|
if (typeof value !== "string") {
|
|
9780
|
-
return
|
|
9770
|
+
return err36(1, `${label}\u7684\u540D\u79F0\u5FC5\u987B\u662F\u5B57\u7B26\u4E32`);
|
|
9781
9771
|
}
|
|
9782
9772
|
const name = value.trim();
|
|
9783
9773
|
if (!name) {
|
|
9784
|
-
return
|
|
9774
|
+
return err36(1, `${label}\u7684\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A`);
|
|
9785
9775
|
}
|
|
9786
9776
|
return ok60(name);
|
|
9787
9777
|
}
|
|
@@ -9789,13 +9779,13 @@ function parseWeight(value, label) {
|
|
|
9789
9779
|
const rawValue = typeof value === "string" ? value.trim().replace(/[%%]$/, "") : value;
|
|
9790
9780
|
const weight = Number(rawValue);
|
|
9791
9781
|
if (!Number.isFinite(weight) || weight <= 0) {
|
|
9792
|
-
return
|
|
9782
|
+
return err36(1, `${label}\u7684\u6982\u7387\u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6570\u5B57`);
|
|
9793
9783
|
}
|
|
9794
9784
|
return ok60(weight);
|
|
9795
9785
|
}
|
|
9796
9786
|
function validateDistribution(entries) {
|
|
9797
9787
|
if (entries.length === 0) {
|
|
9798
|
-
return
|
|
9788
|
+
return err36(1, "\u6982\u7387\u5206\u5E03\u81F3\u5C11\u9700\u8981 1 \u9879");
|
|
9799
9789
|
}
|
|
9800
9790
|
return ok60(entries);
|
|
9801
9791
|
}
|
|
@@ -9825,7 +9815,7 @@ function asRecord(value) {
|
|
|
9825
9815
|
}
|
|
9826
9816
|
|
|
9827
9817
|
// src/commands/tool/tool-get-config-command.ts
|
|
9828
|
-
import { err as
|
|
9818
|
+
import { err as err37, ok as ok61 } from "rockbed/error";
|
|
9829
9819
|
var ToolGetConfigCommand = class extends BaseCommand {
|
|
9830
9820
|
constructor(_settingsReader = new FileCrossAppSettingsReader()) {
|
|
9831
9821
|
super();
|
|
@@ -9877,14 +9867,14 @@ function toConfigCommandResponse(value) {
|
|
|
9877
9867
|
}
|
|
9878
9868
|
async function readConfigValue(settingsReader, key) {
|
|
9879
9869
|
if (!isValidCrossAppSettingKey(key)) {
|
|
9880
|
-
return
|
|
9870
|
+
return err37(
|
|
9881
9871
|
16002 /* InvalidDocument */,
|
|
9882
9872
|
`\u914D\u7F6E key \u65E0\u6548: ${key || "<empty>"}`
|
|
9883
9873
|
);
|
|
9884
9874
|
}
|
|
9885
9875
|
const snapshotResult = await settingsReader.read();
|
|
9886
9876
|
if (!snapshotResult.ok) {
|
|
9887
|
-
return
|
|
9877
|
+
return err37(snapshotResult.code, snapshotResult.msg);
|
|
9888
9878
|
}
|
|
9889
9879
|
const entry = snapshotResult.value.document.settings[key];
|
|
9890
9880
|
if (!entry) {
|
|
@@ -9957,22 +9947,22 @@ var ToolCommand = class extends BaseCommandGroup {
|
|
|
9957
9947
|
import { stat as stat5 } from "node:fs/promises";
|
|
9958
9948
|
import { resolve as resolve15 } from "node:path";
|
|
9959
9949
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
9960
|
-
import { err as
|
|
9950
|
+
import { err as err38, ok as ok63 } from "rockbed/error";
|
|
9961
9951
|
var DEFAULT_TRAEX_CWD = "/Users/bytedance/work/autogen";
|
|
9962
9952
|
var DEFAULT_TRAEX_MODEL = "gpt-5.6-sol";
|
|
9963
9953
|
var DEFAULT_TRAEX_REASONING = "xhigh";
|
|
9964
9954
|
var TRAEX_MODELS = ["gpt-5.6-sol", "gpt-6-astra"];
|
|
9965
9955
|
var TRAEX_REASONING_LEVELS = ["low", "medium", "high", "xhigh"];
|
|
9966
9956
|
async function launchTraex(input, launch = launchDefaultTraexWorker) {
|
|
9967
|
-
if (!input.prompt.trim()) return
|
|
9968
|
-
if (!TRAEX_MODELS.some((model) => model === input.model)) return
|
|
9969
|
-
if (!TRAEX_REASONING_LEVELS.some((level) => level === input.reasoning)) return
|
|
9970
|
-
if (!input.cwd.trim()) return
|
|
9957
|
+
if (!input.prompt.trim()) return err38(1, "\u8BF7\u8F93\u5165\u975E\u7A7A prompt");
|
|
9958
|
+
if (!TRAEX_MODELS.some((model) => model === input.model)) return err38(1, "\u4E0D\u652F\u6301\u7684\u6A21\u578B");
|
|
9959
|
+
if (!TRAEX_REASONING_LEVELS.some((level) => level === input.reasoning)) return err38(1, "\u4E0D\u652F\u6301\u7684\u63A8\u7406\u5F3A\u5EA6");
|
|
9960
|
+
if (!input.cwd.trim()) return err38(1, "\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");
|
|
9971
9961
|
const cwd = resolve15(input.cwd);
|
|
9972
9962
|
try {
|
|
9973
|
-
if (!(await stat5(cwd)).isDirectory()) return
|
|
9963
|
+
if (!(await stat5(cwd)).isDirectory()) return err38(1, `\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u662F\u76EE\u5F55: ${cwd}`);
|
|
9974
9964
|
} catch {
|
|
9975
|
-
return
|
|
9965
|
+
return err38(1, `\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BBF\u95EE: ${cwd}`);
|
|
9976
9966
|
}
|
|
9977
9967
|
const result = await launch({ ...input, cwd });
|
|
9978
9968
|
if (!result.ok) return result;
|
|
@@ -10038,7 +10028,6 @@ function createRootCommands() {
|
|
|
10038
10028
|
new CodexCommand(),
|
|
10039
10029
|
new CodexExecCommand(),
|
|
10040
10030
|
new GitCommand(),
|
|
10041
|
-
new ShortcutCommand(),
|
|
10042
10031
|
new ToolCommand(),
|
|
10043
10032
|
new HelloCommand()
|
|
10044
10033
|
];
|
|
@@ -10079,9 +10068,8 @@ export {
|
|
|
10079
10068
|
KvSetCommand,
|
|
10080
10069
|
KvCommand,
|
|
10081
10070
|
PippitCommand,
|
|
10082
|
-
ShortcutCommand,
|
|
10083
10071
|
ToolCommand,
|
|
10084
10072
|
TraexCommand,
|
|
10085
10073
|
createRootCommands
|
|
10086
10074
|
};
|
|
10087
|
-
//# sourceMappingURL=chunk-
|
|
10075
|
+
//# sourceMappingURL=chunk-LRYUVB4W.js.map
|