personal-bot 0.4.1 → 0.4.2
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +4 -1
- package/README.zh-CN.md +4 -1
- package/docs/README.md +2 -3
- package/docs/architecture/design.md +41 -2
- package/docs/architecture/model-context.md +4 -1
- package/docs/architecture/principles.md +2 -2
- package/docs/guides/cross-harness-workers.md +26 -1
- package/docs/guides/workspace-configuration.md +2 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +19 -3
- package/lib/antigravity-plugin/lib/extension/cli.js +136 -61
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +2 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +96 -17
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +20 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +2 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +12 -13
- package/lib/antigravity-plugin/lib/model/worker-template.d.ts +21 -0
- package/lib/antigravity-plugin/lib/model/worker-template.js +1 -0
- package/lib/antigravity-plugin/lib/services/workspace/worker-templates.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/worker-templates.js +88 -0
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +1 -1
- package/lib/extension/acp-worker.js +19 -3
- package/lib/extension/cli.js +136 -61
- package/lib/extension/hosts/dsh/workspace.js +2 -1
- package/lib/extension/hosts/plugin-runtime.js +2 -0
- package/lib/extension/mcp/tool-contract.d.ts +3 -3
- package/lib/extension/mcp/tool-contract.js +4 -4
- package/lib/extension/mcp/workers.d.ts +1 -1
- package/lib/extension/mcp/workers.js +15 -7
- package/lib/extension/mcp.js +96 -17
- package/lib/integrations/agent-resources.d.ts +2 -0
- package/lib/integrations/agent-resources.js +20 -2
- package/lib/integrations/hosts/dsh/resources.d.ts +2 -1
- package/lib/integrations/hosts/dsh/resources.js +12 -13
- package/lib/model/worker-template.d.ts +21 -0
- package/lib/model/worker-template.js +1 -0
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +1 -1
- package/lib/services/workspace/worker-templates.d.ts +17 -0
- package/lib/services/workspace/worker-templates.js +88 -0
- package/package.json +1 -1
- package/src/extension/hosts/dsh/workspace.ts +2 -1
- package/src/extension/hosts/pi/events.ts +2 -0
- package/src/extension/hosts/plugin-runtime.ts +2 -0
- package/src/extension/mcp/tool-contract.ts +4 -5
- package/src/extension/mcp/workers.ts +17 -8
- package/src/integrations/agent-resources.ts +22 -2
- package/src/integrations/hosts/dsh/resources.ts +13 -12
- package/src/model/worker-template.ts +24 -0
- package/src/services/workspace/worker-templates.ts +80 -0
- package/docs/architecture/model-instruction-guidelines.md +0 -34
package/lib/extension/cli.js
CHANGED
|
@@ -881,10 +881,10 @@ var require_truncate = __commonJS({
|
|
|
881
881
|
"node_modules/semver/functions/truncate.js"(exports, module) {
|
|
882
882
|
"use strict";
|
|
883
883
|
var parse = require_parse();
|
|
884
|
-
var
|
|
884
|
+
var constants5 = require_constants();
|
|
885
885
|
var SemVer = require_semver();
|
|
886
886
|
var truncate = (version, truncation, options) => {
|
|
887
|
-
if (!
|
|
887
|
+
if (!constants5.RELEASE_TYPES.includes(truncation)) {
|
|
888
888
|
return null;
|
|
889
889
|
}
|
|
890
890
|
const clonedVersion = cloneInputVersion(version, options);
|
|
@@ -1933,7 +1933,7 @@ var require_semver2 = __commonJS({
|
|
|
1933
1933
|
"node_modules/semver/index.js"(exports, module) {
|
|
1934
1934
|
"use strict";
|
|
1935
1935
|
var internalRe = require_re();
|
|
1936
|
-
var
|
|
1936
|
+
var constants5 = require_constants();
|
|
1937
1937
|
var SemVer = require_semver();
|
|
1938
1938
|
var identifiers = require_identifiers();
|
|
1939
1939
|
var parse = require_parse();
|
|
@@ -2017,8 +2017,8 @@ var require_semver2 = __commonJS({
|
|
|
2017
2017
|
re: internalRe.re,
|
|
2018
2018
|
src: internalRe.src,
|
|
2019
2019
|
tokens: internalRe.t,
|
|
2020
|
-
SEMVER_SPEC_VERSION:
|
|
2021
|
-
RELEASE_TYPES:
|
|
2020
|
+
SEMVER_SPEC_VERSION: constants5.SEMVER_SPEC_VERSION,
|
|
2021
|
+
RELEASE_TYPES: constants5.RELEASE_TYPES,
|
|
2022
2022
|
compareIdentifiers: identifiers.compareIdentifiers,
|
|
2023
2023
|
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
2024
2024
|
};
|
|
@@ -12456,11 +12456,11 @@ var require_codegen = __commonJS({
|
|
|
12456
12456
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
12457
12457
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
12458
12458
|
}
|
|
12459
|
-
optimizeNames(names,
|
|
12459
|
+
optimizeNames(names, constants5) {
|
|
12460
12460
|
if (!names[this.name.str])
|
|
12461
12461
|
return;
|
|
12462
12462
|
if (this.rhs)
|
|
12463
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
12463
|
+
this.rhs = optimizeExpr(this.rhs, names, constants5);
|
|
12464
12464
|
return this;
|
|
12465
12465
|
}
|
|
12466
12466
|
get names() {
|
|
@@ -12477,10 +12477,10 @@ var require_codegen = __commonJS({
|
|
|
12477
12477
|
render({ _n }) {
|
|
12478
12478
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
12479
12479
|
}
|
|
12480
|
-
optimizeNames(names,
|
|
12480
|
+
optimizeNames(names, constants5) {
|
|
12481
12481
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
12482
12482
|
return;
|
|
12483
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
12483
|
+
this.rhs = optimizeExpr(this.rhs, names, constants5);
|
|
12484
12484
|
return this;
|
|
12485
12485
|
}
|
|
12486
12486
|
get names() {
|
|
@@ -12541,8 +12541,8 @@ var require_codegen = __commonJS({
|
|
|
12541
12541
|
optimizeNodes() {
|
|
12542
12542
|
return `${this.code}` ? this : void 0;
|
|
12543
12543
|
}
|
|
12544
|
-
optimizeNames(names,
|
|
12545
|
-
this.code = optimizeExpr(this.code, names,
|
|
12544
|
+
optimizeNames(names, constants5) {
|
|
12545
|
+
this.code = optimizeExpr(this.code, names, constants5);
|
|
12546
12546
|
return this;
|
|
12547
12547
|
}
|
|
12548
12548
|
get names() {
|
|
@@ -12571,12 +12571,12 @@ var require_codegen = __commonJS({
|
|
|
12571
12571
|
}
|
|
12572
12572
|
return nodes.length > 0 ? this : void 0;
|
|
12573
12573
|
}
|
|
12574
|
-
optimizeNames(names,
|
|
12574
|
+
optimizeNames(names, constants5) {
|
|
12575
12575
|
const { nodes } = this;
|
|
12576
12576
|
let i = nodes.length;
|
|
12577
12577
|
while (i--) {
|
|
12578
12578
|
const n = nodes[i];
|
|
12579
|
-
if (n.optimizeNames(names,
|
|
12579
|
+
if (n.optimizeNames(names, constants5))
|
|
12580
12580
|
continue;
|
|
12581
12581
|
subtractNames(names, n.names);
|
|
12582
12582
|
nodes.splice(i, 1);
|
|
@@ -12629,12 +12629,12 @@ var require_codegen = __commonJS({
|
|
|
12629
12629
|
return void 0;
|
|
12630
12630
|
return this;
|
|
12631
12631
|
}
|
|
12632
|
-
optimizeNames(names,
|
|
12632
|
+
optimizeNames(names, constants5) {
|
|
12633
12633
|
var _a;
|
|
12634
|
-
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names,
|
|
12635
|
-
if (!(super.optimizeNames(names,
|
|
12634
|
+
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants5);
|
|
12635
|
+
if (!(super.optimizeNames(names, constants5) || this.else))
|
|
12636
12636
|
return;
|
|
12637
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
12637
|
+
this.condition = optimizeExpr(this.condition, names, constants5);
|
|
12638
12638
|
return this;
|
|
12639
12639
|
}
|
|
12640
12640
|
get names() {
|
|
@@ -12657,10 +12657,10 @@ var require_codegen = __commonJS({
|
|
|
12657
12657
|
render(opts) {
|
|
12658
12658
|
return `for(${this.iteration})` + super.render(opts);
|
|
12659
12659
|
}
|
|
12660
|
-
optimizeNames(names,
|
|
12661
|
-
if (!super.optimizeNames(names,
|
|
12660
|
+
optimizeNames(names, constants5) {
|
|
12661
|
+
if (!super.optimizeNames(names, constants5))
|
|
12662
12662
|
return;
|
|
12663
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
12663
|
+
this.iteration = optimizeExpr(this.iteration, names, constants5);
|
|
12664
12664
|
return this;
|
|
12665
12665
|
}
|
|
12666
12666
|
get names() {
|
|
@@ -12696,10 +12696,10 @@ var require_codegen = __commonJS({
|
|
|
12696
12696
|
render(opts) {
|
|
12697
12697
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
12698
12698
|
}
|
|
12699
|
-
optimizeNames(names,
|
|
12700
|
-
if (!super.optimizeNames(names,
|
|
12699
|
+
optimizeNames(names, constants5) {
|
|
12700
|
+
if (!super.optimizeNames(names, constants5))
|
|
12701
12701
|
return;
|
|
12702
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
12702
|
+
this.iterable = optimizeExpr(this.iterable, names, constants5);
|
|
12703
12703
|
return this;
|
|
12704
12704
|
}
|
|
12705
12705
|
get names() {
|
|
@@ -12741,11 +12741,11 @@ var require_codegen = __commonJS({
|
|
|
12741
12741
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
12742
12742
|
return this;
|
|
12743
12743
|
}
|
|
12744
|
-
optimizeNames(names,
|
|
12744
|
+
optimizeNames(names, constants5) {
|
|
12745
12745
|
var _a, _b;
|
|
12746
|
-
super.optimizeNames(names,
|
|
12747
|
-
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names,
|
|
12748
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names,
|
|
12746
|
+
super.optimizeNames(names, constants5);
|
|
12747
|
+
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants5);
|
|
12748
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants5);
|
|
12749
12749
|
return this;
|
|
12750
12750
|
}
|
|
12751
12751
|
get names() {
|
|
@@ -13046,7 +13046,7 @@ var require_codegen = __commonJS({
|
|
|
13046
13046
|
function addExprNames(names, from) {
|
|
13047
13047
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
13048
13048
|
}
|
|
13049
|
-
function optimizeExpr(expr, names,
|
|
13049
|
+
function optimizeExpr(expr, names, constants5) {
|
|
13050
13050
|
if (expr instanceof code_1.Name)
|
|
13051
13051
|
return replaceName(expr);
|
|
13052
13052
|
if (!canOptimize(expr))
|
|
@@ -13061,14 +13061,14 @@ var require_codegen = __commonJS({
|
|
|
13061
13061
|
return items;
|
|
13062
13062
|
}, []));
|
|
13063
13063
|
function replaceName(n) {
|
|
13064
|
-
const c =
|
|
13064
|
+
const c = constants5[n.str];
|
|
13065
13065
|
if (c === void 0 || names[n.str] !== 1)
|
|
13066
13066
|
return n;
|
|
13067
13067
|
delete names[n.str];
|
|
13068
13068
|
return c;
|
|
13069
13069
|
}
|
|
13070
13070
|
function canOptimize(e) {
|
|
13071
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
13071
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants5[c.str] !== void 0);
|
|
13072
13072
|
}
|
|
13073
13073
|
}
|
|
13074
13074
|
function subtractNames(names, from) {
|
|
@@ -15030,7 +15030,7 @@ var require_compile = __commonJS({
|
|
|
15030
15030
|
const schOrFunc = root.refs[ref];
|
|
15031
15031
|
if (schOrFunc)
|
|
15032
15032
|
return schOrFunc;
|
|
15033
|
-
let _sch =
|
|
15033
|
+
let _sch = resolve11.call(this, root, ref);
|
|
15034
15034
|
if (_sch === void 0) {
|
|
15035
15035
|
const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
15036
15036
|
const { schemaId } = this.opts;
|
|
@@ -15057,7 +15057,7 @@ var require_compile = __commonJS({
|
|
|
15057
15057
|
function sameSchemaEnv(s1, s2) {
|
|
15058
15058
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
15059
15059
|
}
|
|
15060
|
-
function
|
|
15060
|
+
function resolve11(root, ref) {
|
|
15061
15061
|
let sch;
|
|
15062
15062
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
15063
15063
|
ref = sch;
|
|
@@ -15921,7 +15921,7 @@ var require_fast_uri = __commonJS({
|
|
|
15921
15921
|
}
|
|
15922
15922
|
return uri;
|
|
15923
15923
|
}
|
|
15924
|
-
function
|
|
15924
|
+
function resolve11(baseURI, relativeURI, options) {
|
|
15925
15925
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
15926
15926
|
const {
|
|
15927
15927
|
parsed: baseParsed,
|
|
@@ -16312,7 +16312,7 @@ var require_fast_uri = __commonJS({
|
|
|
16312
16312
|
var fastUri = {
|
|
16313
16313
|
SCHEMES,
|
|
16314
16314
|
normalize,
|
|
16315
|
-
resolve:
|
|
16315
|
+
resolve: resolve11,
|
|
16316
16316
|
resolveComponent,
|
|
16317
16317
|
equal,
|
|
16318
16318
|
serialize,
|
|
@@ -21020,7 +21020,7 @@ init_validation();
|
|
|
21020
21020
|
|
|
21021
21021
|
// src/extension/hosts/plugin-runtime.ts
|
|
21022
21022
|
init_paths();
|
|
21023
|
-
import { join as
|
|
21023
|
+
import { join as join24 } from "node:path";
|
|
21024
21024
|
init_validation();
|
|
21025
21025
|
|
|
21026
21026
|
// src/integrations/agent-resources.ts
|
|
@@ -21056,6 +21056,20 @@ function formatWorkspaceSkills(skills) {
|
|
|
21056
21056
|
const lines = skills.map((skill) => `- **${skill.name}**\uFF08\`${skill.path}\`\uFF09\uFF1A${skill.description}`);
|
|
21057
21057
|
return "## \u6309\u9700\u8BFB\u53D6\u7684\u6280\u80FD\n\n" + lines.join("\n");
|
|
21058
21058
|
}
|
|
21059
|
+
function formatWorkerTemplates(templates) {
|
|
21060
|
+
if (!templates.length) return "";
|
|
21061
|
+
const lines = templates.map(({ id, name, description, create }) => {
|
|
21062
|
+
const label = name === id ? id : `${name}\uFF08${id}\uFF09`;
|
|
21063
|
+
const settings2 = [
|
|
21064
|
+
["\u52A9\u624B", create.backend],
|
|
21065
|
+
["\u6267\u884C\u5DE5\u4F5C\u533A", create.workspace],
|
|
21066
|
+
["\u6A21\u578B", create.model],
|
|
21067
|
+
["\u601D\u8003\u6DF1\u5EA6", create.thinking]
|
|
21068
|
+
].filter(([, value]) => value !== void 0).map(([field, value]) => `${field} ${JSON.stringify(value)}`).join("\uFF0C");
|
|
21069
|
+
return `- ${label}\u3000${description}\uFF08${settings2}\uFF09`;
|
|
21070
|
+
});
|
|
21071
|
+
return "## \u5DE5\u4F5C\u533A\u52A9\u624B\u6A21\u677F\n\n\u9009\u7528\u6A21\u677F\u65F6\uFF0C\u7528 worker_discover \u67E5\u8BE2\u6700\u65B0\u8BBE\u7F6E\uFF08target=templates\uFF09\u3002\n\n" + lines.join("\n");
|
|
21072
|
+
}
|
|
21059
21073
|
async function loadWorkspaceContext(options) {
|
|
21060
21074
|
const {
|
|
21061
21075
|
host,
|
|
@@ -21068,11 +21082,13 @@ async function loadWorkspaceContext(options) {
|
|
|
21068
21082
|
workspaceSkills = [],
|
|
21069
21083
|
notices = []
|
|
21070
21084
|
} = options;
|
|
21071
|
-
const [workspace,
|
|
21085
|
+
const [workspace, baseRole, rootAgents, catalog] = includePrompts ? await Promise.all([
|
|
21072
21086
|
readFile8(join20(resourceRoot, "prompts/workspace.md"), "utf8"),
|
|
21073
21087
|
localRoleOnly ? readLocalRole(role, root) : agentText(role, root, coordinatorPrompt),
|
|
21074
|
-
includeRootAgents ? readOptionalFile(join20(root, "AGENTS.md")) : Promise.resolve("")
|
|
21075
|
-
|
|
21088
|
+
includeRootAgents ? readOptionalFile(join20(root, "AGENTS.md")) : Promise.resolve(""),
|
|
21089
|
+
role === "coordinator" ? options.readWorkerTemplates?.(root) : void 0
|
|
21090
|
+
]) : ["", "", "", void 0];
|
|
21091
|
+
const roleText = [baseRole, formatWorkerTemplates(catalog?.templates ?? [])].filter(Boolean).join("\n\n");
|
|
21076
21092
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
21077
21093
|
const noticesSection = notices.length ? "## \u7EF4\u62A4\u63D0\u9192\n\n\u544A\u77E5\u7528\u6237\uFF0C\u6309\u7528\u6237\u8981\u6C42\u6267\u884C\u3002\n\n" + notices.map((item) => `- ${item}`).join("\n") : "";
|
|
21078
21094
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
@@ -21179,12 +21195,70 @@ function recordHistoryCapture(root, host, capture) {
|
|
|
21179
21195
|
init_summary_runner();
|
|
21180
21196
|
init_workspace_config2();
|
|
21181
21197
|
|
|
21198
|
+
// src/services/workspace/worker-templates.ts
|
|
21199
|
+
import { constants as constants4 } from "node:fs";
|
|
21200
|
+
import { open } from "node:fs/promises";
|
|
21201
|
+
init_json();
|
|
21202
|
+
import { join as join21, resolve as resolve10 } from "node:path";
|
|
21203
|
+
var templateIdPattern = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
21204
|
+
var templateFields = ["name", "description", "create"];
|
|
21205
|
+
var createFields = ["backend", "workspace", "model", "thinking"];
|
|
21206
|
+
function validString(value) {
|
|
21207
|
+
return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
|
|
21208
|
+
}
|
|
21209
|
+
function parseTemplate(id, entry) {
|
|
21210
|
+
if (!templateIdPattern.test(id)) return { id, message: "\u6A21\u677F\u6807\u8BC6\u65E0\u6548\u3002" };
|
|
21211
|
+
if (!object(entry) || Object.keys(entry).some((key) => !templateFields.includes(key))) {
|
|
21212
|
+
return { id, message: "\u6A21\u677F\u8BBE\u7F6E\u65E0\u6548\u3002" };
|
|
21213
|
+
}
|
|
21214
|
+
const { name = id, description, create } = entry;
|
|
21215
|
+
if (!validString(name)) return { id, message: "\u6A21\u677F\u540D\u79F0\u65E0\u6548\u3002" };
|
|
21216
|
+
if (!validString(description)) return { id, message: "\u6A21\u677F\u7F3A\u5C11\u6709\u6548\u7684\u804C\u8D23\u8BF4\u660E\u3002" };
|
|
21217
|
+
if (!object(create) || Object.keys(create).some((key) => !createFields.includes(key))) {
|
|
21218
|
+
return { id, message: "\u52A9\u624B\u7684\u542F\u52A8\u8BBE\u7F6E\u65E0\u6548\u3002" };
|
|
21219
|
+
}
|
|
21220
|
+
if (!validString(create.backend)) return { id, message: "\u6A21\u677F\u7F3A\u5C11\u6709\u6548\u7684\u52A9\u624B\u6807\u8BC6\u3002" };
|
|
21221
|
+
const options = { backend: create.backend, workspace: "." };
|
|
21222
|
+
for (const key of ["workspace", "model", "thinking"]) {
|
|
21223
|
+
const value = create[key];
|
|
21224
|
+
if (value === void 0) continue;
|
|
21225
|
+
if (!validString(value)) return { id, message: "\u52A9\u624B\u7684\u542F\u52A8\u8BBE\u7F6E\u65E0\u6548\u3002" };
|
|
21226
|
+
options[key] = value;
|
|
21227
|
+
}
|
|
21228
|
+
return { id, name, description, create: options };
|
|
21229
|
+
}
|
|
21230
|
+
async function readWorkerTemplates(root) {
|
|
21231
|
+
const path = join21(root, ".pbot", "worker", "templates.json");
|
|
21232
|
+
const catalog = { templates: [], errors: [] };
|
|
21233
|
+
const unavailable = { ...catalog, error: "\u5F53\u524D\u5DE5\u4F5C\u533A\u7684\u52A9\u624B\u6A21\u677F\u4E0D\u53EF\u7528\u3002" };
|
|
21234
|
+
let entries;
|
|
21235
|
+
try {
|
|
21236
|
+
const file = await open(path, constants4.O_RDONLY | constants4.O_NONBLOCK);
|
|
21237
|
+
try {
|
|
21238
|
+
if (!(await file.stat()).isFile()) return unavailable;
|
|
21239
|
+
entries = JSON.parse(await file.readFile("utf8"));
|
|
21240
|
+
} finally {
|
|
21241
|
+
await file.close();
|
|
21242
|
+
}
|
|
21243
|
+
} catch (error) {
|
|
21244
|
+
if (error.code === "ENOENT") return catalog;
|
|
21245
|
+
return unavailable;
|
|
21246
|
+
}
|
|
21247
|
+
if (!object(entries)) return unavailable;
|
|
21248
|
+
for (const id of Object.keys(entries).sort()) {
|
|
21249
|
+
const result = parseTemplate(id, entries[id]);
|
|
21250
|
+
if ("message" in result) catalog.errors.push(result);
|
|
21251
|
+
else catalog.templates.push(result);
|
|
21252
|
+
}
|
|
21253
|
+
return catalog;
|
|
21254
|
+
}
|
|
21255
|
+
|
|
21182
21256
|
// src/services/workspace/workspace-preparation.ts
|
|
21183
21257
|
init_validation();
|
|
21184
21258
|
init_paths();
|
|
21185
21259
|
init_workspace_config2();
|
|
21186
21260
|
import { lstat as lstat2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
21187
|
-
import { join as
|
|
21261
|
+
import { join as join22 } from "node:path";
|
|
21188
21262
|
async function initializeWorkspace(root) {
|
|
21189
21263
|
const configuration = await readWorkspaceConfig(root);
|
|
21190
21264
|
if (configuration.error) throw new Error(configuration.error);
|
|
@@ -21194,22 +21268,22 @@ async function initializeWorkspace(root) {
|
|
|
21194
21268
|
var directories = ["areas", "projects", "knowledge", "providers", "scratch", "agents"];
|
|
21195
21269
|
async function prepareWorkspace(root) {
|
|
21196
21270
|
for (const part of directories) {
|
|
21197
|
-
const path =
|
|
21271
|
+
const path = join22(root, part);
|
|
21198
21272
|
await mkdir4(path, { mode: 448 }).catch((error) => {
|
|
21199
21273
|
if (error.code !== "EEXIST") throw error;
|
|
21200
21274
|
});
|
|
21201
21275
|
const entry = await lstat2(path);
|
|
21202
21276
|
requireThat(entry.isDirectory() && !entry.isSymbolicLink(), "\u5DE5\u4F5C\u533A\u76EE\u5F55\u4E0D\u80FD\u4F7F\u7528\u7B26\u53F7\u94FE\u63A5\uFF1A" + path);
|
|
21203
21277
|
}
|
|
21204
|
-
const agents = await readFile9(
|
|
21205
|
-
await writeFile2(
|
|
21278
|
+
const agents = await readFile9(join22(resourceRoot, "templates/workspace-agents.md"), "utf8");
|
|
21279
|
+
await writeFile2(join22(root, "AGENTS.md"), agents, { flag: "wx" }).catch((error) => {
|
|
21206
21280
|
if (error.code !== "EEXIST") throw error;
|
|
21207
21281
|
});
|
|
21208
21282
|
}
|
|
21209
21283
|
|
|
21210
21284
|
// src/services/workspace/workspace-skills.ts
|
|
21211
21285
|
import { readdir, readFile as readFile10 } from "node:fs/promises";
|
|
21212
|
-
import { join as
|
|
21286
|
+
import { join as join23 } from "node:path";
|
|
21213
21287
|
function unquoteYaml(value) {
|
|
21214
21288
|
const trimmed = value.trim();
|
|
21215
21289
|
if (trimmed.length >= 2 && (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
@@ -21257,7 +21331,7 @@ function parseSkillFrontmatter(content) {
|
|
|
21257
21331
|
};
|
|
21258
21332
|
}
|
|
21259
21333
|
async function discoverWorkspaceSkills(root) {
|
|
21260
|
-
return discoverSkills(
|
|
21334
|
+
return discoverSkills(join23(root, ".agents", "skills"), ".agents/skills");
|
|
21261
21335
|
}
|
|
21262
21336
|
async function discoverSkills(skillsDir, indexPath) {
|
|
21263
21337
|
let entries;
|
|
@@ -21270,7 +21344,7 @@ async function discoverSkills(skillsDir, indexPath) {
|
|
|
21270
21344
|
const results = [];
|
|
21271
21345
|
for (const entry of entries) {
|
|
21272
21346
|
if (entry.name.startsWith(".") || !entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
21273
|
-
const filePath =
|
|
21347
|
+
const filePath = join23(skillsDir, entry.name, "SKILL.md");
|
|
21274
21348
|
let content;
|
|
21275
21349
|
try {
|
|
21276
21350
|
content = await readFile10(filePath, "utf8");
|
|
@@ -21282,7 +21356,7 @@ async function discoverSkills(skillsDir, indexPath) {
|
|
|
21282
21356
|
results.push({
|
|
21283
21357
|
name: meta.name,
|
|
21284
21358
|
description: meta.description,
|
|
21285
|
-
path:
|
|
21359
|
+
path: join23(indexPath, entry.name, "SKILL.md")
|
|
21286
21360
|
});
|
|
21287
21361
|
}
|
|
21288
21362
|
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -21344,7 +21418,7 @@ async function pluginHook(adapter, payload, replay) {
|
|
|
21344
21418
|
const includeSkills = features.skills && !event.noticesOnly;
|
|
21345
21419
|
const workspaceSkills = includeSkills && !adapter.nativeWorkspaceSkills ? await discoverWorkspaceSkills(root) : [];
|
|
21346
21420
|
if (includeSkills && adapter.indexBundledSkills) {
|
|
21347
|
-
const directory =
|
|
21421
|
+
const directory = join24(resourceRoot, "skills");
|
|
21348
21422
|
workspaceSkills.push(...await discoverSkills(directory, directory));
|
|
21349
21423
|
}
|
|
21350
21424
|
const notices = event.isSessionStart && features.history ? [...historyStartupNotices(root)] : [];
|
|
@@ -21353,6 +21427,7 @@ async function pluginHook(adapter, payload, replay) {
|
|
|
21353
21427
|
host: adapter.host,
|
|
21354
21428
|
root,
|
|
21355
21429
|
role: event.role,
|
|
21430
|
+
readWorkerTemplates,
|
|
21356
21431
|
coordinatorPrompt: adapter.coordinatorPrompt ?? (features.history ? "plugin-coordinator.md" : null),
|
|
21357
21432
|
includePrompts,
|
|
21358
21433
|
includeRootAgents: includePrompts && !adapter.nativeRootAgents,
|
|
@@ -21395,7 +21470,7 @@ var pluginCommand2 = {
|
|
|
21395
21470
|
};
|
|
21396
21471
|
|
|
21397
21472
|
// src/extension/cli/commands/upgrade.ts
|
|
21398
|
-
import { join as
|
|
21473
|
+
import { join as join29 } from "node:path";
|
|
21399
21474
|
|
|
21400
21475
|
// src/common/package-source.ts
|
|
21401
21476
|
var import_semver5 = __toESM(require_semver2(), 1);
|
|
@@ -21420,7 +21495,7 @@ init_validation();
|
|
|
21420
21495
|
var import_semver6 = __toESM(require_semver2(), 1);
|
|
21421
21496
|
init_json();
|
|
21422
21497
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
21423
|
-
import { join as
|
|
21498
|
+
import { join as join25 } from "node:path";
|
|
21424
21499
|
async function readManifestVersion4(path) {
|
|
21425
21500
|
try {
|
|
21426
21501
|
const data = JSON.parse(await readFile11(path, "utf8"));
|
|
@@ -21484,8 +21559,8 @@ var antigravityUpgrader = {
|
|
|
21484
21559
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21485
21560
|
};
|
|
21486
21561
|
}
|
|
21487
|
-
const pluginDir =
|
|
21488
|
-
const bundledVersion = await readManifestVersion4(
|
|
21562
|
+
const pluginDir = join25(context.packageRoot, "lib", "antigravity-plugin");
|
|
21563
|
+
const bundledVersion = await readManifestVersion4(join25(pluginDir, "plugin.json"));
|
|
21489
21564
|
if (!bundledVersion) {
|
|
21490
21565
|
return {
|
|
21491
21566
|
host: this.host,
|
|
@@ -21628,7 +21703,7 @@ var claudeUpgrader = {
|
|
|
21628
21703
|
var import_semver8 = __toESM(require_semver2(), 1);
|
|
21629
21704
|
init_json();
|
|
21630
21705
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
21631
|
-
import { join as
|
|
21706
|
+
import { join as join26 } from "node:path";
|
|
21632
21707
|
async function readManifestVersion5(path) {
|
|
21633
21708
|
try {
|
|
21634
21709
|
const data = JSON.parse(await readFile12(path, "utf8"));
|
|
@@ -21707,8 +21782,8 @@ var codexUpgrader = {
|
|
|
21707
21782
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21708
21783
|
};
|
|
21709
21784
|
}
|
|
21710
|
-
const marketplaceDir =
|
|
21711
|
-
const bundledVersion = await readManifestVersion5(
|
|
21785
|
+
const marketplaceDir = join26(context.packageRoot, "lib", "codex-marketplace");
|
|
21786
|
+
const bundledVersion = await readManifestVersion5(join26(marketplaceDir, "plugins", "personal-bot", ".codex-plugin", "plugin.json"));
|
|
21712
21787
|
if (!bundledVersion) {
|
|
21713
21788
|
return {
|
|
21714
21789
|
host: this.host,
|
|
@@ -21830,14 +21905,14 @@ var dshUpgrader = {
|
|
|
21830
21905
|
var import_semver10 = __toESM(require_semver2(), 1);
|
|
21831
21906
|
init_json();
|
|
21832
21907
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
21833
|
-
import { join as
|
|
21908
|
+
import { join as join27 } from "node:path";
|
|
21834
21909
|
function packageSource(entry) {
|
|
21835
21910
|
if (typeof entry === "string") return entry;
|
|
21836
21911
|
if (object(entry) && typeof entry.source === "string") return entry.source;
|
|
21837
21912
|
return void 0;
|
|
21838
21913
|
}
|
|
21839
21914
|
async function hasCustomOnlySource(workspace) {
|
|
21840
|
-
const settingsPath =
|
|
21915
|
+
const settingsPath = join27(workspace, ".pi", "settings.json");
|
|
21841
21916
|
try {
|
|
21842
21917
|
const data = JSON.parse(await readFile13(settingsPath, "utf8"));
|
|
21843
21918
|
if (!object(data) || !Array.isArray(data.packages)) return false;
|
|
@@ -21851,7 +21926,7 @@ async function hasCustomOnlySource(workspace) {
|
|
|
21851
21926
|
}
|
|
21852
21927
|
}
|
|
21853
21928
|
async function readLocalPiVersion(workspace) {
|
|
21854
|
-
const manifestPath =
|
|
21929
|
+
const manifestPath = join27(workspace, ".pi", "npm", "node_modules", "personal-bot", "package.json");
|
|
21855
21930
|
try {
|
|
21856
21931
|
const data = JSON.parse(await readFile13(manifestPath, "utf8"));
|
|
21857
21932
|
return object(data) && data.name === "personal-bot" && typeof data.version === "string" && (0, import_semver10.valid)(data.version) ? data.version : void 0;
|
|
@@ -21918,7 +21993,7 @@ var piUpgrader = {
|
|
|
21918
21993
|
var import_semver11 = __toESM(require_semver2(), 1);
|
|
21919
21994
|
init_json();
|
|
21920
21995
|
import { readFile as readFile14, realpath as realpath7 } from "node:fs/promises";
|
|
21921
|
-
import { join as
|
|
21996
|
+
import { join as join28 } from "node:path";
|
|
21922
21997
|
async function readManifestVersion6(path) {
|
|
21923
21998
|
try {
|
|
21924
21999
|
const data = JSON.parse(await readFile14(path, "utf8"));
|
|
@@ -22011,8 +22086,8 @@ var qoderUpgrader = {
|
|
|
22011
22086
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
22012
22087
|
};
|
|
22013
22088
|
}
|
|
22014
|
-
const pluginDir =
|
|
22015
|
-
const bundledVersion = await readManifestVersion6(
|
|
22089
|
+
const pluginDir = join28(context.packageRoot, "lib", "qoder-plugin");
|
|
22090
|
+
const bundledVersion = await readManifestVersion6(join28(pluginDir, ".qoder-plugin", "plugin.json"));
|
|
22016
22091
|
if (!bundledVersion) {
|
|
22017
22092
|
return {
|
|
22018
22093
|
host: this.host,
|
|
@@ -22247,7 +22322,7 @@ var upgradeCommand = {
|
|
|
22247
22322
|
PBOT_UPGRADING_CLI: targetVersion,
|
|
22248
22323
|
PBOT_UPGRADING_PREVIOUS_VERSION: packageVersion
|
|
22249
22324
|
};
|
|
22250
|
-
return execCliEntry(
|
|
22325
|
+
return execCliEntry(join29(cliResult.globalDirectory, "bin", "pbot.mjs"), ctx.rawArgs, nextEnv);
|
|
22251
22326
|
}
|
|
22252
22327
|
cli = {
|
|
22253
22328
|
state: cliResult.state,
|
|
@@ -9,6 +9,7 @@ import { requireThat } from "../../../common/validation.js";
|
|
|
9
9
|
import { toDshMcpConfig } from "../../../integrations/hosts/dsh/mcp.js";
|
|
10
10
|
import { registerDshSkills } from "../../../integrations/hosts/dsh/skills.js";
|
|
11
11
|
import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../../services/workspace/workspace-config.js";
|
|
12
|
+
import { readWorkerTemplates } from "../../../services/workspace/worker-templates.js";
|
|
12
13
|
import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
|
|
13
14
|
import { initializeWorkspace } from "../../../services/workspace/workspace-preparation.js";
|
|
14
15
|
import { historyStartupNotices } from "../../../services/history/summary-runner.js";
|
|
@@ -43,7 +44,7 @@ export class DshWorkspace {
|
|
|
43
44
|
registerDshSkills(ctx, this.agent, { workspaceRoot: this.root });
|
|
44
45
|
if (this.features.prompts) {
|
|
45
46
|
const historyPrompt = this.features.history ? "history-coordinator.md" : null;
|
|
46
|
-
await dshResources(ctx, this.agent, this.root, "coordinator", this.check, historyPrompt);
|
|
47
|
+
await dshResources(ctx, this.agent, this.root, "coordinator", this.check, historyPrompt, readWorkerTemplates);
|
|
47
48
|
}
|
|
48
49
|
registerDshFileEvents(ctx, this.agent, this.root, false, this.check);
|
|
49
50
|
if (this.features.history) {
|
|
@@ -6,6 +6,7 @@ import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
|
|
|
6
6
|
import { recordHistoryCapture } from "../../services/history/history-capture.js";
|
|
7
7
|
import { historyStartupNotices } from "../../services/history/summary-runner.js";
|
|
8
8
|
import { readWorkspaceConfig, workspaceFeatures } from "../../services/workspace/workspace-config.js";
|
|
9
|
+
import { readWorkerTemplates } from "../../services/workspace/worker-templates.js";
|
|
9
10
|
import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
|
|
10
11
|
import { discoverSkills, discoverWorkspaceSkills } from "../../services/workspace/workspace-skills.js";
|
|
11
12
|
function disabledMessage(adapter, configuration) {
|
|
@@ -86,6 +87,7 @@ export async function pluginHook(adapter, payload, replay) {
|
|
|
86
87
|
host: adapter.host,
|
|
87
88
|
root,
|
|
88
89
|
role: event.role,
|
|
90
|
+
readWorkerTemplates,
|
|
89
91
|
coordinatorPrompt: adapter.coordinatorPrompt ?? (features.history ? "plugin-coordinator.md" : null),
|
|
90
92
|
includePrompts,
|
|
91
93
|
includeRootAgents: includePrompts && !adapter.nativeRootAgents,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AcpCommands } from "../../model/acp.js";
|
|
2
2
|
export declare const defaultWaitMs = 50000;
|
|
3
3
|
export declare const maxWaitMs = 600000;
|
|
4
|
-
export declare const discoverTargets: readonly ["overview", "workers", "backends", "models"];
|
|
4
|
+
export declare const discoverTargets: readonly ["overview", "workers", "backends", "models", "templates"];
|
|
5
5
|
export declare function buildPbotWorkerTools(commands?: AcpCommands, defaultBackend?: string, workspaceBound?: boolean): ({
|
|
6
6
|
name: "worker_create";
|
|
7
7
|
description: string;
|
|
@@ -229,7 +229,7 @@ export declare function buildPbotWorkerTools(commands?: AcpCommands, defaultBack
|
|
|
229
229
|
properties: {
|
|
230
230
|
target: {
|
|
231
231
|
type: string;
|
|
232
|
-
enum: ("models" | "overview" | "workers" | "backends")[];
|
|
232
|
+
enum: ("templates" | "models" | "overview" | "workers" | "backends")[];
|
|
233
233
|
description: string;
|
|
234
234
|
};
|
|
235
235
|
workerId: {
|
|
@@ -657,7 +657,7 @@ export declare const pbotWorkerTools: ({
|
|
|
657
657
|
properties: {
|
|
658
658
|
target: {
|
|
659
659
|
type: string;
|
|
660
|
-
enum: ("models" | "overview" | "workers" | "backends")[];
|
|
660
|
+
enum: ("templates" | "models" | "overview" | "workers" | "backends")[];
|
|
661
661
|
description: string;
|
|
662
662
|
};
|
|
663
663
|
workerId: {
|
|
@@ -5,7 +5,7 @@ import { historyPageLimits } from "../../model/history.js";
|
|
|
5
5
|
import { acpElicitationActions } from "../../model/acp.js";
|
|
6
6
|
export const defaultWaitMs = 50_000;
|
|
7
7
|
export const maxWaitMs = 600_000;
|
|
8
|
-
export const discoverTargets = ["overview", "workers", "backends", "models"];
|
|
8
|
+
export const discoverTargets = ["overview", "workers", "backends", "models", "templates"];
|
|
9
9
|
function formatBackendItem(entry, defaultBackend) {
|
|
10
10
|
const tags = [];
|
|
11
11
|
if (entry.label)
|
|
@@ -176,9 +176,9 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
|
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
name: "worker_discover",
|
|
179
|
-
description: "
|
|
179
|
+
description: "查找可用助手、模板或已有会话。查询模型会临时启动所选助手。",
|
|
180
180
|
annotations: {
|
|
181
|
-
title: "Discover Workers, Backends & Models",
|
|
181
|
+
title: "Discover Workers, Templates, Backends & Models",
|
|
182
182
|
readOnlyHint: true,
|
|
183
183
|
destructiveHint: false,
|
|
184
184
|
idempotentHint: true,
|
|
@@ -192,7 +192,7 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
|
|
|
192
192
|
target: {
|
|
193
193
|
type: "string",
|
|
194
194
|
enum: [...discoverTargets],
|
|
195
|
-
description: "overview
|
|
195
|
+
description: "overview(默认)列助手和本会话的 worker,workers 查会话状态,backends 查可用助手,models 查模型与思考深度。templates 列出工作区的助手模板,选中模板的 create 可直接传给 worker_create。",
|
|
196
196
|
},
|
|
197
197
|
workerId: {
|
|
198
198
|
type: "string",
|
|
@@ -264,7 +264,7 @@ export declare class McpWorkerRuntime {
|
|
|
264
264
|
properties: {
|
|
265
265
|
target: {
|
|
266
266
|
type: string;
|
|
267
|
-
enum: ("models" | "overview" | "workers" | "backends")[];
|
|
267
|
+
enum: ("templates" | "models" | "overview" | "workers" | "backends")[];
|
|
268
268
|
description: string;
|
|
269
269
|
};
|
|
270
270
|
workerId: {
|