@godv61/dsh-task-engine 0.11.0 → 0.14.0
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/lib/client.js +267 -92
- package/lib/client.js.map +2 -2
- package/lib/controller.d.ts +40 -7
- package/lib/controller.js +72 -9
- package/lib/controller.js.map +1 -1
- package/lib/engine.d.ts +7 -0
- package/lib/engine.js +33 -2
- package/lib/engine.js.map +1 -1
- package/package.json +1 -1
- package/skills/code-commit/SKILL.md +1 -1
- package/skills/code-implement/SKILL.md +3 -3
- package/skills/code-review/SKILL.md +1 -1
- package/skills/code-verify/SKILL.md +1 -1
- package/skills/eng-delivery/SKILL.md +5 -1
- package/skills/requirement-analysis/SKILL.md +1 -1
- package/skills/solution-design/SKILL.md +1 -1
package/lib/client.js
CHANGED
|
@@ -4146,7 +4146,7 @@ var writeResourceResultSchema = external_exports.object({
|
|
|
4146
4146
|
});
|
|
4147
4147
|
var readSkillRequestSchema = external_exports.object({
|
|
4148
4148
|
name: external_exports.string(),
|
|
4149
|
-
level: external_exports.enum(["project", "user"]),
|
|
4149
|
+
level: external_exports.enum(["project", "user", "bundled"]),
|
|
4150
4150
|
path: external_exports.string().optional()
|
|
4151
4151
|
});
|
|
4152
4152
|
var readSkillResultSchema = external_exports.object({
|
|
@@ -4159,7 +4159,7 @@ var readSkillResultSchema = external_exports.object({
|
|
|
4159
4159
|
});
|
|
4160
4160
|
var readRuleRequestSchema = external_exports.object({
|
|
4161
4161
|
name: external_exports.string(),
|
|
4162
|
-
level: external_exports.enum(["project", "user"]),
|
|
4162
|
+
level: external_exports.enum(["project", "user", "bundled"]),
|
|
4163
4163
|
path: external_exports.string().optional()
|
|
4164
4164
|
});
|
|
4165
4165
|
var readRuleResultSchema = external_exports.object({
|
|
@@ -4168,6 +4168,16 @@ var readRuleResultSchema = external_exports.object({
|
|
|
4168
4168
|
content: external_exports.string(),
|
|
4169
4169
|
error: external_exports.string().optional()
|
|
4170
4170
|
});
|
|
4171
|
+
var deleteSkillRequestSchema = external_exports.object({
|
|
4172
|
+
name: external_exports.string(),
|
|
4173
|
+
level: external_exports.enum(["project", "user"]),
|
|
4174
|
+
path: external_exports.string().optional()
|
|
4175
|
+
});
|
|
4176
|
+
var deleteRuleRequestSchema = external_exports.object({
|
|
4177
|
+
name: external_exports.string(),
|
|
4178
|
+
level: external_exports.enum(["project", "user"]),
|
|
4179
|
+
path: external_exports.string().optional()
|
|
4180
|
+
});
|
|
4171
4181
|
var taskLedgerItemSchema = external_exports.object({
|
|
4172
4182
|
id: external_exports.string(),
|
|
4173
4183
|
title: external_exports.string(),
|
|
@@ -4319,6 +4329,38 @@ var TYPERT_REMOTE = {
|
|
|
4319
4329
|
],
|
|
4320
4330
|
result: { mode: "strict", typeSymbol: `${PACKAGE}/types#ReadRuleResult`, schema: readRuleResultSchema }
|
|
4321
4331
|
},
|
|
4332
|
+
{
|
|
4333
|
+
id: `${PACKAGE}#task-engine/deleteSkill`,
|
|
4334
|
+
service: "taskEngineController",
|
|
4335
|
+
namespace: "task-engine",
|
|
4336
|
+
method: "deleteSkill",
|
|
4337
|
+
invocation: { kind: "direct" },
|
|
4338
|
+
parameters: [
|
|
4339
|
+
{
|
|
4340
|
+
name: "request",
|
|
4341
|
+
wire: "request",
|
|
4342
|
+
source: "json",
|
|
4343
|
+
codec: { mode: "strict", typeSymbol: `${PACKAGE}/types#DeleteSkillRequest`, schema: deleteSkillRequestSchema }
|
|
4344
|
+
}
|
|
4345
|
+
],
|
|
4346
|
+
result: { mode: "strict", typeSymbol: `${PACKAGE}/types#WriteResourceResult`, schema: writeResourceResultSchema }
|
|
4347
|
+
},
|
|
4348
|
+
{
|
|
4349
|
+
id: `${PACKAGE}#task-engine/deleteRule`,
|
|
4350
|
+
service: "taskEngineController",
|
|
4351
|
+
namespace: "task-engine",
|
|
4352
|
+
method: "deleteRule",
|
|
4353
|
+
invocation: { kind: "direct" },
|
|
4354
|
+
parameters: [
|
|
4355
|
+
{
|
|
4356
|
+
name: "request",
|
|
4357
|
+
wire: "request",
|
|
4358
|
+
source: "json",
|
|
4359
|
+
codec: { mode: "strict", typeSymbol: `${PACKAGE}/types#DeleteRuleRequest`, schema: deleteRuleRequestSchema }
|
|
4360
|
+
}
|
|
4361
|
+
],
|
|
4362
|
+
result: { mode: "strict", typeSymbol: `${PACKAGE}/types#WriteResourceResult`, schema: writeResourceResultSchema }
|
|
4363
|
+
},
|
|
4322
4364
|
{
|
|
4323
4365
|
id: `${PACKAGE}#task-engine/readTasks`,
|
|
4324
4366
|
service: "taskEngineController",
|
|
@@ -5385,6 +5427,7 @@ var card = {
|
|
|
5385
5427
|
padding: "10px 12px"
|
|
5386
5428
|
};
|
|
5387
5429
|
function levelOf(source) {
|
|
5430
|
+
if (source === "bundled") return "bundled";
|
|
5388
5431
|
return source.startsWith("user") ? "user" : "project";
|
|
5389
5432
|
}
|
|
5390
5433
|
function SkillManager({ workspace, remote }) {
|
|
@@ -5392,6 +5435,8 @@ function SkillManager({ workspace, remote }) {
|
|
|
5392
5435
|
const [level, setLevel] = (0, import_react3.useState)("project");
|
|
5393
5436
|
const [editing, setEditing] = (0, import_react3.useState)(null);
|
|
5394
5437
|
const [creating, setCreating] = (0, import_react3.useState)(false);
|
|
5438
|
+
const [viewing, setViewing] = (0, import_react3.useState)(false);
|
|
5439
|
+
const [confirming, setConfirming] = (0, import_react3.useState)(null);
|
|
5395
5440
|
const [name, setName] = (0, import_react3.useState)("");
|
|
5396
5441
|
const [description, setDescription] = (0, import_react3.useState)("");
|
|
5397
5442
|
const [whenToUse, setWhenToUse] = (0, import_react3.useState)("");
|
|
@@ -5406,9 +5451,20 @@ function SkillManager({ workspace, remote }) {
|
|
|
5406
5451
|
(0, import_react3.useEffect)(() => {
|
|
5407
5452
|
refresh();
|
|
5408
5453
|
}, [refresh]);
|
|
5454
|
+
const closeForm = () => {
|
|
5455
|
+
setEditing(null);
|
|
5456
|
+
setCreating(false);
|
|
5457
|
+
setViewing(false);
|
|
5458
|
+
setName("");
|
|
5459
|
+
setDescription("");
|
|
5460
|
+
setWhenToUse("");
|
|
5461
|
+
setBody("");
|
|
5462
|
+
setMsg("");
|
|
5463
|
+
};
|
|
5409
5464
|
const startCreate = () => {
|
|
5410
5465
|
setEditing(null);
|
|
5411
5466
|
setCreating(true);
|
|
5467
|
+
setViewing(false);
|
|
5412
5468
|
setLevel("project");
|
|
5413
5469
|
setName("");
|
|
5414
5470
|
setDescription("");
|
|
@@ -5416,13 +5472,9 @@ function SkillManager({ workspace, remote }) {
|
|
|
5416
5472
|
setBody("");
|
|
5417
5473
|
setMsg("");
|
|
5418
5474
|
};
|
|
5419
|
-
const
|
|
5420
|
-
const lvl = levelOf(sk.source);
|
|
5421
|
-
setEditing(sk.name);
|
|
5422
|
-
setCreating(false);
|
|
5423
|
-
setLevel(lvl);
|
|
5475
|
+
const loadSkill = (skillName, lvl) => {
|
|
5424
5476
|
setMsg("");
|
|
5425
|
-
void remote.readSkill({ name:
|
|
5477
|
+
void remote.readSkill({ name: skillName, level: lvl, path: workspace }).then((r) => {
|
|
5426
5478
|
if (r.ok && r.value.ok) {
|
|
5427
5479
|
setName(r.value.name);
|
|
5428
5480
|
setDescription(r.value.description);
|
|
@@ -5433,6 +5485,20 @@ function SkillManager({ workspace, remote }) {
|
|
|
5433
5485
|
}
|
|
5434
5486
|
});
|
|
5435
5487
|
};
|
|
5488
|
+
const startEdit = (sk) => {
|
|
5489
|
+
const lvl = levelOf(sk.source);
|
|
5490
|
+
setEditing(sk.name);
|
|
5491
|
+
setCreating(false);
|
|
5492
|
+
setViewing(false);
|
|
5493
|
+
setLevel(lvl === "user" ? "user" : "project");
|
|
5494
|
+
loadSkill(sk.name, lvl);
|
|
5495
|
+
};
|
|
5496
|
+
const startView = (sk) => {
|
|
5497
|
+
setEditing(sk.name);
|
|
5498
|
+
setCreating(false);
|
|
5499
|
+
setViewing(true);
|
|
5500
|
+
loadSkill(sk.name, "bundled");
|
|
5501
|
+
};
|
|
5436
5502
|
const submit = async () => {
|
|
5437
5503
|
setMsg("");
|
|
5438
5504
|
const target = editing ?? name;
|
|
@@ -5457,45 +5523,78 @@ function SkillManager({ workspace, remote }) {
|
|
|
5457
5523
|
setCreating(false);
|
|
5458
5524
|
refresh();
|
|
5459
5525
|
};
|
|
5526
|
+
const remove = async (sk) => {
|
|
5527
|
+
setMsg("");
|
|
5528
|
+
const lvl = levelOf(sk.source);
|
|
5529
|
+
if (lvl === "bundled") return;
|
|
5530
|
+
const result = await remote.deleteSkill({ name: sk.name, level: lvl, path: workspace });
|
|
5531
|
+
if (!result.ok) {
|
|
5532
|
+
setMsg("\u5220\u9664\u5931\u8D25\uFF1A" + describeError(result.error));
|
|
5533
|
+
setConfirming(null);
|
|
5534
|
+
return;
|
|
5535
|
+
}
|
|
5536
|
+
if (!result.value.ok) {
|
|
5537
|
+
setMsg("\u5220\u9664\u5931\u8D25\uFF1A" + (result.value.error ?? "\u672A\u77E5\u9519\u8BEF"));
|
|
5538
|
+
setConfirming(null);
|
|
5539
|
+
return;
|
|
5540
|
+
}
|
|
5541
|
+
setMsg(`\u5DF2\u5220\u9664 skill\u300C${result.value.name}\u300D`);
|
|
5542
|
+
if (editing === sk.name) setEditing(null);
|
|
5543
|
+
setConfirming(null);
|
|
5544
|
+
refresh();
|
|
5545
|
+
};
|
|
5460
5546
|
const formOpen = editing !== null || creating;
|
|
5461
|
-
|
|
5547
|
+
const renderRow = (sk) => (0, import_react3.createElement)(
|
|
5462
5548
|
"div",
|
|
5463
|
-
{
|
|
5549
|
+
{
|
|
5550
|
+
key: sk.name,
|
|
5551
|
+
style: { display: "flex", alignItems: "center", gap: 8, justifyContent: "space-between", padding: "6px 0", borderBottom: "1px solid var(--dsw-alias-border-l2)" }
|
|
5552
|
+
},
|
|
5464
5553
|
(0, import_react3.createElement)(
|
|
5465
5554
|
"div",
|
|
5466
|
-
{ style:
|
|
5555
|
+
{ style: { display: "flex", flexDirection: "column", gap: 2, minWidth: 0 } },
|
|
5467
5556
|
(0, import_react3.createElement)(
|
|
5557
|
+
"span",
|
|
5558
|
+
{ style: { fontSize: 13, color: "var(--dsw-alias-label-primary)" } },
|
|
5559
|
+
sk.name,
|
|
5560
|
+
sk.source !== "bundled" ? (0, import_react3.createElement)("span", { style: styles.sourceBadge }, `\uFF08${sourceLabel(sk.source)}\uFF09`) : null
|
|
5561
|
+
),
|
|
5562
|
+
(0, import_react3.createElement)("span", { style: styles.sourceBadge }, sk.description)
|
|
5563
|
+
),
|
|
5564
|
+
sk.source === "bundled" ? (0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
5565
|
+
startView(sk);
|
|
5566
|
+
} }, "\u67E5\u770B") : (0, import_react3.createElement)(
|
|
5567
|
+
"div",
|
|
5568
|
+
{ style: { display: "flex", gap: 6 } },
|
|
5569
|
+
(0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
5570
|
+
startEdit(sk);
|
|
5571
|
+
} }, "\u7F16\u8F91"),
|
|
5572
|
+
confirming === sk.name ? (0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "primary", size: "sm", onClick: () => {
|
|
5573
|
+
void remove(sk);
|
|
5574
|
+
} }, "\u786E\u8BA4\u5220\u9664") : (0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", onClick: () => {
|
|
5575
|
+
setConfirming(sk.name);
|
|
5576
|
+
} }, "\u5220\u9664")
|
|
5577
|
+
)
|
|
5578
|
+
);
|
|
5579
|
+
const renderForm = () => {
|
|
5580
|
+
if (viewing) {
|
|
5581
|
+
return (0, import_react3.createElement)(
|
|
5468
5582
|
"div",
|
|
5469
|
-
{ style:
|
|
5470
|
-
(0, import_react3.createElement)("span", { style: styles.bindingLabel }, "\
|
|
5471
|
-
|
|
5583
|
+
{ style: card },
|
|
5584
|
+
(0, import_react3.createElement)("span", { style: styles.bindingLabel }, `\u67E5\u770B skill\u300C${editing ?? ""}\u300D\uFF08\u5185\u7F6E \xB7 \u53EA\u8BFB\uFF09`),
|
|
5585
|
+
(0, import_react3.createElement)("input", { style: control2, value: name, disabled: true, readOnly: true }),
|
|
5586
|
+
(0, import_react3.createElement)("input", { style: control2, value: description, disabled: true, readOnly: true }),
|
|
5587
|
+
(0, import_react3.createElement)("input", { style: control2, value: whenToUse, disabled: true, readOnly: true }),
|
|
5588
|
+
(0, import_react3.createElement)("textarea", { style: { ...styles.textarea, minHeight: 220 }, value: body2, disabled: true, readOnly: true }),
|
|
5589
|
+
(0, import_react3.createElement)(
|
|
5472
5590
|
"div",
|
|
5473
|
-
{ style: styles.
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
(0, import_react3.createElement)(
|
|
5481
|
-
"div",
|
|
5482
|
-
{ style: { display: "flex", flexDirection: "column", gap: 2, minWidth: 0 } },
|
|
5483
|
-
(0, import_react3.createElement)(
|
|
5484
|
-
"span",
|
|
5485
|
-
{ style: { fontSize: 13, color: "var(--dsw-alias-label-primary)" } },
|
|
5486
|
-
sk.name,
|
|
5487
|
-
sk.source !== "bundled" ? (0, import_react3.createElement)("span", { style: styles.sourceBadge }, `\uFF08${sourceLabel(sk.source)}\uFF09`) : null
|
|
5488
|
-
),
|
|
5489
|
-
(0, import_react3.createElement)("span", { style: styles.sourceBadge }, sk.description)
|
|
5490
|
-
),
|
|
5491
|
-
sk.source === "bundled" ? (0, import_react3.createElement)("span", { style: styles.sourceBadge }, "\u5185\u7F6E \xB7 \u53EA\u8BFB") : (0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
5492
|
-
startEdit(sk);
|
|
5493
|
-
} }, "\u7F16\u8F91")
|
|
5494
|
-
))
|
|
5495
|
-
)
|
|
5496
|
-
)
|
|
5497
|
-
),
|
|
5498
|
-
formOpen ? (0, import_react3.createElement)(
|
|
5591
|
+
{ style: styles.row },
|
|
5592
|
+
(0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", onClick: closeForm }, "\u5173\u95ED")
|
|
5593
|
+
),
|
|
5594
|
+
msg !== "" ? (0, import_react3.createElement)("p", { style: styles.status }, msg) : null
|
|
5595
|
+
);
|
|
5596
|
+
}
|
|
5597
|
+
return (0, import_react3.createElement)(
|
|
5499
5598
|
"div",
|
|
5500
5599
|
{ style: card },
|
|
5501
5600
|
(0, import_react3.createElement)("span", { style: styles.bindingLabel }, editing === null ? "\u65B0\u5EFA skill" : `\u7F16\u8F91 skill\u300C${editing}\u300D`),
|
|
@@ -5532,18 +5631,29 @@ function SkillManager({ workspace, remote }) {
|
|
|
5532
5631
|
void submit();
|
|
5533
5632
|
}
|
|
5534
5633
|
}, "\u4FDD\u5B58"),
|
|
5535
|
-
(0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", onClick:
|
|
5536
|
-
setEditing(null);
|
|
5537
|
-
setCreating(false);
|
|
5538
|
-
setName("");
|
|
5539
|
-
setDescription("");
|
|
5540
|
-
setWhenToUse("");
|
|
5541
|
-
setBody("");
|
|
5542
|
-
setMsg("");
|
|
5543
|
-
} }, "\u53D6\u6D88")
|
|
5634
|
+
(0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", onClick: closeForm }, "\u53D6\u6D88")
|
|
5544
5635
|
),
|
|
5545
5636
|
msg !== "" ? (0, import_react3.createElement)("p", { style: styles.status }, msg) : null
|
|
5546
|
-
)
|
|
5637
|
+
);
|
|
5638
|
+
};
|
|
5639
|
+
return (0, import_react3.createElement)(
|
|
5640
|
+
"div",
|
|
5641
|
+
{ style: styles.section },
|
|
5642
|
+
(0, import_react3.createElement)(
|
|
5643
|
+
"div",
|
|
5644
|
+
{ style: card },
|
|
5645
|
+
(0, import_react3.createElement)(
|
|
5646
|
+
"div",
|
|
5647
|
+
{ style: styles.bindingStage },
|
|
5648
|
+
(0, import_react3.createElement)("span", { style: styles.bindingLabel }, "\u5DF2\u5B89\u88C5\u7684 skill"),
|
|
5649
|
+
skills.length === 0 ? (0, import_react3.createElement)("p", { style: styles.muted }, "\u6682\u65E0 skill\uFF0C\u70B9\u4E0B\u65B9\u300C\u65B0\u5EFA skill\u300D\u521B\u5EFA\u4E00\u4E2A\u3002") : (0, import_react3.createElement)(
|
|
5650
|
+
"div",
|
|
5651
|
+
{ style: styles.section },
|
|
5652
|
+
...skills.map(renderRow)
|
|
5653
|
+
)
|
|
5654
|
+
)
|
|
5655
|
+
),
|
|
5656
|
+
formOpen ? renderForm() : (0, import_react3.createElement)(
|
|
5547
5657
|
"div",
|
|
5548
5658
|
null,
|
|
5549
5659
|
(0, import_react3.createElement)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "md", onClick: startCreate }, "\u65B0\u5EFA skill")
|
|
@@ -5572,6 +5682,7 @@ var card2 = {
|
|
|
5572
5682
|
padding: "10px 12px"
|
|
5573
5683
|
};
|
|
5574
5684
|
function levelOf2(source) {
|
|
5685
|
+
if (source === "bundled") return "bundled";
|
|
5575
5686
|
return source.startsWith("user") ? "user" : "project";
|
|
5576
5687
|
}
|
|
5577
5688
|
function RuleManager({ workspace, remote }) {
|
|
@@ -5579,6 +5690,8 @@ function RuleManager({ workspace, remote }) {
|
|
|
5579
5690
|
const [level, setLevel] = (0, import_react4.useState)("project");
|
|
5580
5691
|
const [editing, setEditing] = (0, import_react4.useState)(null);
|
|
5581
5692
|
const [creating, setCreating] = (0, import_react4.useState)(false);
|
|
5693
|
+
const [viewing, setViewing] = (0, import_react4.useState)(false);
|
|
5694
|
+
const [confirming, setConfirming] = (0, import_react4.useState)(null);
|
|
5582
5695
|
const [name, setName] = (0, import_react4.useState)("");
|
|
5583
5696
|
const [body2, setBody] = (0, import_react4.useState)("");
|
|
5584
5697
|
const [msg, setMsg] = (0, import_react4.useState)("");
|
|
@@ -5591,21 +5704,26 @@ function RuleManager({ workspace, remote }) {
|
|
|
5591
5704
|
(0, import_react4.useEffect)(() => {
|
|
5592
5705
|
refresh();
|
|
5593
5706
|
}, [refresh]);
|
|
5707
|
+
const closeForm = () => {
|
|
5708
|
+
setEditing(null);
|
|
5709
|
+
setCreating(false);
|
|
5710
|
+
setViewing(false);
|
|
5711
|
+
setName("");
|
|
5712
|
+
setBody("");
|
|
5713
|
+
setMsg("");
|
|
5714
|
+
};
|
|
5594
5715
|
const startCreate = () => {
|
|
5595
5716
|
setEditing(null);
|
|
5596
5717
|
setCreating(true);
|
|
5718
|
+
setViewing(false);
|
|
5597
5719
|
setLevel("project");
|
|
5598
5720
|
setName("");
|
|
5599
5721
|
setBody("");
|
|
5600
5722
|
setMsg("");
|
|
5601
5723
|
};
|
|
5602
|
-
const
|
|
5603
|
-
const lvl = levelOf2(rule.source);
|
|
5604
|
-
setEditing(rule.name);
|
|
5605
|
-
setCreating(false);
|
|
5606
|
-
setLevel(lvl);
|
|
5724
|
+
const loadRule = (ruleName, lvl) => {
|
|
5607
5725
|
setMsg("");
|
|
5608
|
-
void remote.readRule({ name:
|
|
5726
|
+
void remote.readRule({ name: ruleName, level: lvl, path: workspace }).then((r) => {
|
|
5609
5727
|
if (r.ok && r.value.ok) {
|
|
5610
5728
|
setName(r.value.name);
|
|
5611
5729
|
setBody(r.value.content);
|
|
@@ -5614,6 +5732,20 @@ function RuleManager({ workspace, remote }) {
|
|
|
5614
5732
|
}
|
|
5615
5733
|
});
|
|
5616
5734
|
};
|
|
5735
|
+
const startEdit = (rule) => {
|
|
5736
|
+
const lvl = levelOf2(rule.source);
|
|
5737
|
+
setEditing(rule.name);
|
|
5738
|
+
setCreating(false);
|
|
5739
|
+
setViewing(false);
|
|
5740
|
+
setLevel(lvl === "user" ? "user" : "project");
|
|
5741
|
+
loadRule(rule.name, lvl);
|
|
5742
|
+
};
|
|
5743
|
+
const startView = (rule) => {
|
|
5744
|
+
setEditing(rule.name);
|
|
5745
|
+
setCreating(false);
|
|
5746
|
+
setViewing(true);
|
|
5747
|
+
loadRule(rule.name, "bundled");
|
|
5748
|
+
};
|
|
5617
5749
|
const submit = async () => {
|
|
5618
5750
|
setMsg("");
|
|
5619
5751
|
const result = await remote.writeRule({
|
|
@@ -5635,40 +5767,70 @@ function RuleManager({ workspace, remote }) {
|
|
|
5635
5767
|
setCreating(false);
|
|
5636
5768
|
refresh();
|
|
5637
5769
|
};
|
|
5770
|
+
const remove = async (rule) => {
|
|
5771
|
+
setMsg("");
|
|
5772
|
+
const lvl = levelOf2(rule.source);
|
|
5773
|
+
if (lvl === "bundled") return;
|
|
5774
|
+
const result = await remote.deleteRule({ name: rule.name, level: lvl, path: workspace });
|
|
5775
|
+
if (!result.ok) {
|
|
5776
|
+
setMsg("\u5220\u9664\u5931\u8D25\uFF1A" + describeError(result.error));
|
|
5777
|
+
setConfirming(null);
|
|
5778
|
+
return;
|
|
5779
|
+
}
|
|
5780
|
+
if (!result.value.ok) {
|
|
5781
|
+
setMsg("\u5220\u9664\u5931\u8D25\uFF1A" + (result.value.error ?? "\u672A\u77E5\u9519\u8BEF"));
|
|
5782
|
+
setConfirming(null);
|
|
5783
|
+
return;
|
|
5784
|
+
}
|
|
5785
|
+
setMsg(`\u5DF2\u5220\u9664 rule\u300C${result.value.name}\u300D`);
|
|
5786
|
+
if (editing === rule.name) setEditing(null);
|
|
5787
|
+
setConfirming(null);
|
|
5788
|
+
refresh();
|
|
5789
|
+
};
|
|
5638
5790
|
const formOpen = editing !== null || creating;
|
|
5639
|
-
|
|
5791
|
+
const renderRow = (rule) => (0, import_react4.createElement)(
|
|
5640
5792
|
"div",
|
|
5641
|
-
{
|
|
5793
|
+
{
|
|
5794
|
+
key: rule.name,
|
|
5795
|
+
style: { display: "flex", alignItems: "center", gap: 8, justifyContent: "space-between", padding: "6px 0", borderBottom: "1px solid var(--dsw-alias-border-l2)" }
|
|
5796
|
+
},
|
|
5642
5797
|
(0, import_react4.createElement)(
|
|
5798
|
+
"span",
|
|
5799
|
+
{ style: { fontSize: 13, color: "var(--dsw-alias-label-primary)" } },
|
|
5800
|
+
rule.name,
|
|
5801
|
+
rule.source !== "bundled" ? (0, import_react4.createElement)("span", { style: styles.sourceBadge }, `\uFF08${sourceLabel(rule.source)}\uFF09`) : null
|
|
5802
|
+
),
|
|
5803
|
+
rule.source === "bundled" ? (0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
5804
|
+
startView(rule);
|
|
5805
|
+
} }, "\u67E5\u770B") : (0, import_react4.createElement)(
|
|
5643
5806
|
"div",
|
|
5644
|
-
{ style:
|
|
5645
|
-
(0, import_react4.createElement)(
|
|
5807
|
+
{ style: { display: "flex", gap: 6 } },
|
|
5808
|
+
(0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
5809
|
+
startEdit(rule);
|
|
5810
|
+
} }, "\u7F16\u8F91"),
|
|
5811
|
+
confirming === rule.name ? (0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "primary", size: "sm", onClick: () => {
|
|
5812
|
+
void remove(rule);
|
|
5813
|
+
} }, "\u786E\u8BA4\u5220\u9664") : (0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "ghost", size: "sm", onClick: () => {
|
|
5814
|
+
setConfirming(rule.name);
|
|
5815
|
+
} }, "\u5220\u9664")
|
|
5816
|
+
)
|
|
5817
|
+
);
|
|
5818
|
+
const renderForm = () => {
|
|
5819
|
+
if (viewing) {
|
|
5820
|
+
return (0, import_react4.createElement)(
|
|
5646
5821
|
"div",
|
|
5647
|
-
{ style:
|
|
5648
|
-
(0, import_react4.createElement)("span", { style: styles.bindingLabel }, "\
|
|
5649
|
-
|
|
5822
|
+
{ style: card2 },
|
|
5823
|
+
(0, import_react4.createElement)("span", { style: styles.bindingLabel }, `\u67E5\u770B rule\u300C${editing ?? ""}\u300D\uFF08\u5185\u7F6E \xB7 \u53EA\u8BFB\uFF09`),
|
|
5824
|
+
(0, import_react4.createElement)("textarea", { style: { ...styles.textarea, minHeight: 240 }, value: body2, disabled: true, readOnly: true }),
|
|
5825
|
+
(0, import_react4.createElement)(
|
|
5650
5826
|
"div",
|
|
5651
|
-
{ style: styles.
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
(0, import_react4.createElement)(
|
|
5659
|
-
"span",
|
|
5660
|
-
{ style: { fontSize: 13, color: "var(--dsw-alias-label-primary)" } },
|
|
5661
|
-
rule.name,
|
|
5662
|
-
rule.source !== "bundled" ? (0, import_react4.createElement)("span", { style: styles.sourceBadge }, `\uFF08${sourceLabel(rule.source)}\uFF09`) : null
|
|
5663
|
-
),
|
|
5664
|
-
rule.source === "bundled" ? (0, import_react4.createElement)("span", { style: styles.sourceBadge }, "\u5185\u7F6E \xB7 \u53EA\u8BFB") : (0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
5665
|
-
startEdit(rule);
|
|
5666
|
-
} }, "\u7F16\u8F91")
|
|
5667
|
-
))
|
|
5668
|
-
)
|
|
5669
|
-
)
|
|
5670
|
-
),
|
|
5671
|
-
formOpen ? (0, import_react4.createElement)(
|
|
5827
|
+
{ style: styles.row },
|
|
5828
|
+
(0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "ghost", size: "sm", onClick: closeForm }, "\u5173\u95ED")
|
|
5829
|
+
),
|
|
5830
|
+
msg !== "" ? (0, import_react4.createElement)("p", { style: styles.status }, msg) : null
|
|
5831
|
+
);
|
|
5832
|
+
}
|
|
5833
|
+
return (0, import_react4.createElement)(
|
|
5672
5834
|
"div",
|
|
5673
5835
|
{ style: card2 },
|
|
5674
5836
|
(0, import_react4.createElement)("span", { style: styles.bindingLabel }, editing === null ? "\u65B0\u5EFA rule" : `\u7F16\u8F91 rule\u300C${editing}\u300D`),
|
|
@@ -5699,16 +5861,29 @@ function RuleManager({ workspace, remote }) {
|
|
|
5699
5861
|
void submit();
|
|
5700
5862
|
}
|
|
5701
5863
|
}, "\u4FDD\u5B58"),
|
|
5702
|
-
(0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "ghost", size: "sm", onClick:
|
|
5703
|
-
setEditing(null);
|
|
5704
|
-
setCreating(false);
|
|
5705
|
-
setName("");
|
|
5706
|
-
setBody("");
|
|
5707
|
-
setMsg("");
|
|
5708
|
-
} }, "\u53D6\u6D88")
|
|
5864
|
+
(0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "ghost", size: "sm", onClick: closeForm }, "\u53D6\u6D88")
|
|
5709
5865
|
),
|
|
5710
5866
|
msg !== "" ? (0, import_react4.createElement)("p", { style: styles.status }, msg) : null
|
|
5711
|
-
)
|
|
5867
|
+
);
|
|
5868
|
+
};
|
|
5869
|
+
return (0, import_react4.createElement)(
|
|
5870
|
+
"div",
|
|
5871
|
+
{ style: styles.section },
|
|
5872
|
+
(0, import_react4.createElement)(
|
|
5873
|
+
"div",
|
|
5874
|
+
{ style: card2 },
|
|
5875
|
+
(0, import_react4.createElement)(
|
|
5876
|
+
"div",
|
|
5877
|
+
{ style: styles.bindingStage },
|
|
5878
|
+
(0, import_react4.createElement)("span", { style: styles.bindingLabel }, "\u5DF2\u5B89\u88C5\u7684 rule"),
|
|
5879
|
+
rules.length === 0 ? (0, import_react4.createElement)("p", { style: styles.muted }, "\u6682\u65E0 rule\uFF0C\u70B9\u4E0B\u65B9\u300C\u65B0\u5EFA rule\u300D\u521B\u5EFA\u4E00\u4E2A\u3002") : (0, import_react4.createElement)(
|
|
5880
|
+
"div",
|
|
5881
|
+
{ style: styles.section },
|
|
5882
|
+
...rules.map(renderRow)
|
|
5883
|
+
)
|
|
5884
|
+
)
|
|
5885
|
+
),
|
|
5886
|
+
formOpen ? renderForm() : (0, import_react4.createElement)(
|
|
5712
5887
|
"div",
|
|
5713
5888
|
null,
|
|
5714
5889
|
(0, import_react4.createElement)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "md", onClick: startCreate }, "\u65B0\u5EFA rule")
|