scream-code 0.6.3 → 0.6.4
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/dist/{app-Uko4bajP.mjs → app-DHT_tWRH.mjs} +878 -289
- package/dist/main.mjs +1 -1
- package/package.json +2 -2
|
@@ -38493,7 +38493,7 @@ function normalizeScreamToolSchema(schema) {
|
|
|
38493
38493
|
}
|
|
38494
38494
|
function ensureScreamPropertyTypes(schema) {
|
|
38495
38495
|
const normalized = cloneJsonValue(schema);
|
|
38496
|
-
if (!isRecord$
|
|
38496
|
+
if (!isRecord$7(normalized)) throw new Error("JSON Schema root must normalize to an object.");
|
|
38497
38497
|
recurseSchema(normalized);
|
|
38498
38498
|
return normalized;
|
|
38499
38499
|
}
|
|
@@ -38554,7 +38554,7 @@ function resolveLocalJsonPointer(root, ref) {
|
|
|
38554
38554
|
let current = root;
|
|
38555
38555
|
for (const rawPart of ref.slice(2).split("/")) {
|
|
38556
38556
|
const part = unescapeJsonPointerPart(rawPart);
|
|
38557
|
-
if (isRecord$
|
|
38557
|
+
if (isRecord$7(current)) {
|
|
38558
38558
|
if (!hasOwn$1(current, part)) return { found: false };
|
|
38559
38559
|
current = current[part];
|
|
38560
38560
|
} else if (Array.isArray(current)) {
|
|
@@ -38576,20 +38576,20 @@ function parseJsonPointerArrayIndex(part) {
|
|
|
38576
38576
|
return Number(part);
|
|
38577
38577
|
}
|
|
38578
38578
|
function recurseSchema(node) {
|
|
38579
|
-
if (!isRecord$
|
|
38579
|
+
if (!isRecord$7(node)) return;
|
|
38580
38580
|
visitChildSchemas(node, normalizeProperty);
|
|
38581
38581
|
}
|
|
38582
38582
|
function visitChildSchemas(node, visit) {
|
|
38583
38583
|
for (const { key, kind } of CHILD_SCHEMA_SLOTS) {
|
|
38584
38584
|
const value = node[key];
|
|
38585
38585
|
if (kind === "single") {
|
|
38586
|
-
if (isRecord$
|
|
38586
|
+
if (isRecord$7(value)) visit(value);
|
|
38587
38587
|
} else if (kind === "array") {
|
|
38588
38588
|
if (Array.isArray(value)) for (const item of value) visit(item);
|
|
38589
38589
|
} else if (kind === "map") {
|
|
38590
|
-
if (isRecord$
|
|
38590
|
+
if (isRecord$7(value)) for (const item of Object.values(value)) visit(item);
|
|
38591
38591
|
} else if (kind === "schema-or-array") {
|
|
38592
|
-
if (isRecord$
|
|
38592
|
+
if (isRecord$7(value)) visit(value);
|
|
38593
38593
|
else if (Array.isArray(value)) for (const item of value) visit(item);
|
|
38594
38594
|
}
|
|
38595
38595
|
}
|
|
@@ -38601,7 +38601,7 @@ function childSchemaKeysForParentType(parentType) {
|
|
|
38601
38601
|
});
|
|
38602
38602
|
}
|
|
38603
38603
|
function normalizeProperty(node) {
|
|
38604
|
-
if (!isRecord$
|
|
38604
|
+
if (!isRecord$7(node)) return;
|
|
38605
38605
|
if (!hasOwn$1(node, "type") && !hasAnyKey(node, TYPE_COMPLETION_SKIP_KEYS)) {
|
|
38606
38606
|
const enumValues = node["enum"];
|
|
38607
38607
|
if (Array.isArray(enumValues) && enumValues.length > 0) node["type"] = inferTypeFromValues(enumValues);
|
|
@@ -38665,14 +38665,14 @@ function hasAnyKey(obj, keys) {
|
|
|
38665
38665
|
}
|
|
38666
38666
|
function cloneJsonValue(value) {
|
|
38667
38667
|
if (Array.isArray(value)) return value.map((item) => cloneJsonValue(item));
|
|
38668
|
-
if (isRecord$
|
|
38668
|
+
if (isRecord$7(value)) {
|
|
38669
38669
|
const cloned = {};
|
|
38670
38670
|
for (const [key, child] of Object.entries(value)) cloned[key] = cloneJsonValue(child);
|
|
38671
38671
|
return cloned;
|
|
38672
38672
|
}
|
|
38673
38673
|
return value;
|
|
38674
38674
|
}
|
|
38675
|
-
function isRecord$
|
|
38675
|
+
function isRecord$7(value) {
|
|
38676
38676
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
38677
38677
|
}
|
|
38678
38678
|
function hasOwn$1(obj, key) {
|
|
@@ -53912,7 +53912,7 @@ function canonicalizePath(path, cwd, pathClass = DEFAULT_PATH_CLASS) {
|
|
|
53912
53912
|
* True iff `candidate` is `base` itself or a descendant of it, compared
|
|
53913
53913
|
* on path-component boundaries. Both arguments must already be canonical.
|
|
53914
53914
|
*/
|
|
53915
|
-
function isWithinDirectory(candidate, base, pathClass = DEFAULT_PATH_CLASS) {
|
|
53915
|
+
function isWithinDirectory$1(candidate, base, pathClass = DEFAULT_PATH_CLASS) {
|
|
53916
53916
|
const nc = normalize(candidate);
|
|
53917
53917
|
const nb = normalize(base);
|
|
53918
53918
|
const comparableCandidate = pathClass === "win32" ? nc.toLowerCase() : nc;
|
|
@@ -53926,8 +53926,8 @@ function isWithinDirectory(candidate, base, pathClass = DEFAULT_PATH_CLASS) {
|
|
|
53926
53926
|
* roots listed in `config` (primary `workspaceDir` or any `additionalDirs`).
|
|
53927
53927
|
*/
|
|
53928
53928
|
function isWithinWorkspace(candidate, config, pathClass = DEFAULT_PATH_CLASS) {
|
|
53929
|
-
if (isWithinDirectory(candidate, config.workspaceDir, pathClass)) return true;
|
|
53930
|
-
for (const dir of config.additionalDirs) if (isWithinDirectory(candidate, dir, pathClass)) return true;
|
|
53929
|
+
if (isWithinDirectory$1(candidate, config.workspaceDir, pathClass)) return true;
|
|
53930
|
+
for (const dir of config.additionalDirs) if (isWithinDirectory$1(candidate, dir, pathClass)) return true;
|
|
53931
53931
|
return false;
|
|
53932
53932
|
}
|
|
53933
53933
|
function outsideWorkspaceMessage(path, canonical, config, operation) {
|
|
@@ -55014,14 +55014,14 @@ function fileOperationWrites(operation) {
|
|
|
55014
55014
|
}
|
|
55015
55015
|
}
|
|
55016
55016
|
function fileAccessesOverlap(left, right) {
|
|
55017
|
-
const leftPath = normalizePath(left.path);
|
|
55018
|
-
const rightPath = normalizePath(right.path);
|
|
55017
|
+
const leftPath = normalizePath$1(left.path);
|
|
55018
|
+
const rightPath = normalizePath$1(right.path);
|
|
55019
55019
|
if (leftPath === rightPath) return true;
|
|
55020
55020
|
const leftPrefix = leftPath.endsWith("/") ? leftPath : `${leftPath}/`;
|
|
55021
55021
|
const rightPrefix = rightPath.endsWith("/") ? rightPath : `${rightPath}/`;
|
|
55022
55022
|
return left.recursive === true && rightPath.startsWith(leftPrefix) || right.recursive === true && leftPath.startsWith(rightPrefix);
|
|
55023
55023
|
}
|
|
55024
|
-
function normalizePath(path) {
|
|
55024
|
+
function normalizePath$1(path) {
|
|
55025
55025
|
const folded = path.replaceAll("\\", "/").replaceAll(/\/+/g, "/").toLowerCase();
|
|
55026
55026
|
if (folded.length > 1 && folded.endsWith("/")) return folded.slice(0, -1);
|
|
55027
55027
|
return folded;
|
|
@@ -56573,20 +56573,33 @@ var MemoryMemoStore = class MemoryMemoStore {
|
|
|
56573
56573
|
embeddingQueue = /* @__PURE__ */ new Set();
|
|
56574
56574
|
embeddingTimer;
|
|
56575
56575
|
embeddingFlushing = false;
|
|
56576
|
-
|
|
56576
|
+
embeddingDegraded = false;
|
|
56577
|
+
embeddingConsecutiveFailures = 0;
|
|
56578
|
+
lastEmbeddingError;
|
|
56579
|
+
log;
|
|
56580
|
+
constructor(projectDir, log) {
|
|
56577
56581
|
this.projectDir = projectDir;
|
|
56578
56582
|
this.jsonlPath = join$1(projectDir, "memory", FILE_NAME);
|
|
56579
56583
|
this.dbPath = join$1(projectDir, "memory", "memos.sqlite");
|
|
56584
|
+
this.log = log ?? {};
|
|
56580
56585
|
}
|
|
56581
56586
|
/**
|
|
56582
56587
|
* Open the SQLite database and run schema migrations. Call this once after
|
|
56583
56588
|
* construction before relying on reads/writes.
|
|
56589
|
+
*
|
|
56590
|
+
* Note on async SQLite: Node.js added the asynchronous `Database` class to
|
|
56591
|
+
* `node:sqlite` in v23.4.0 (experimental). This package currently supports
|
|
56592
|
+
* Node >=22.0.0 and uses `DatabaseSync` because the v22 type definitions do
|
|
56593
|
+
* not yet include `Database`. Once the project baseline moves to Node 23+ and
|
|
56594
|
+
* the types catch up, the synchronous calls here should be migrated to the
|
|
56595
|
+
* async API to avoid blocking the event loop on large operations.
|
|
56584
56596
|
*/
|
|
56585
56597
|
async init() {
|
|
56586
56598
|
if (this.initialized) return;
|
|
56587
56599
|
await this.ensureDir();
|
|
56588
56600
|
this.db = new DatabaseSync(this.dbPath);
|
|
56589
56601
|
this.db.exec("PRAGMA journal_mode = WAL;");
|
|
56602
|
+
this.db.exec("PRAGMA foreign_keys = ON;");
|
|
56590
56603
|
this.createSchema();
|
|
56591
56604
|
await this.migrateFromJsonl();
|
|
56592
56605
|
this.initialized = true;
|
|
@@ -57040,15 +57053,19 @@ var MemoryMemoStore = class MemoryMemoStore {
|
|
|
57040
57053
|
this.flushEmbeddings();
|
|
57041
57054
|
}, 2e3);
|
|
57042
57055
|
}
|
|
57056
|
+
/**
|
|
57057
|
+
* Flush queued embedding generation. Retries once on failure to tolerate
|
|
57058
|
+
* transient model-load contention, then marks embeddings as degraded and
|
|
57059
|
+
* logs the problem. Callers can still retrieve memos through keyword search.
|
|
57060
|
+
*/
|
|
57043
57061
|
async flushEmbeddings() {
|
|
57044
57062
|
if (this.embeddingFlushing || this.embeddingEngine === void 0 || !this.embeddingEngine.available) return;
|
|
57045
|
-
const ids = [...this.embeddingQueue];
|
|
57046
|
-
this.embeddingQueue.clear();
|
|
57047
|
-
if (ids.length === 0) return;
|
|
57048
57063
|
this.embeddingFlushing = true;
|
|
57049
57064
|
try {
|
|
57050
57065
|
await this.init();
|
|
57051
57066
|
if (this.db === void 0) return;
|
|
57067
|
+
const ids = [...this.embeddingQueue];
|
|
57068
|
+
this.embeddingQueue.clear();
|
|
57052
57069
|
const pending = [];
|
|
57053
57070
|
for (const id of ids) {
|
|
57054
57071
|
if (this.db.prepare("SELECT id FROM memory_embeddings WHERE memory_id = ?").get(id) !== void 0) continue;
|
|
@@ -57059,21 +57076,66 @@ var MemoryMemoStore = class MemoryMemoStore {
|
|
|
57059
57076
|
});
|
|
57060
57077
|
}
|
|
57061
57078
|
if (pending.length === 0) return;
|
|
57062
|
-
const vectors = await this.
|
|
57063
|
-
if (vectors === null || vectors.length !== pending.length)
|
|
57079
|
+
const vectors = await this.tryEmbedBatch(pending.map((p) => p.text));
|
|
57080
|
+
if (vectors === null || vectors.length !== pending.length) {
|
|
57081
|
+
this.markEmbeddingFailure(/* @__PURE__ */ new Error(vectors === null ? "embedBatch returned null" : "embedding count mismatch"));
|
|
57082
|
+
return;
|
|
57083
|
+
}
|
|
57084
|
+
this.clearEmbeddingFailure();
|
|
57064
57085
|
const insert = this.db.prepare("INSERT OR REPLACE INTO memory_embeddings (memory_id, embedding_json, model, created_at) VALUES (?, ?, ?, ?)");
|
|
57065
57086
|
const now = Date.now();
|
|
57066
57087
|
this.db.exec("BEGIN TRANSACTION");
|
|
57067
57088
|
try {
|
|
57068
57089
|
for (let i = 0; i < pending.length; i++) insert.run(pending[i].id, JSON.stringify([...vectors[i]]), "bge-small-zh-v1.5", now);
|
|
57069
57090
|
this.db.exec("COMMIT");
|
|
57070
|
-
} catch {
|
|
57091
|
+
} catch (err) {
|
|
57071
57092
|
this.db.exec("ROLLBACK");
|
|
57093
|
+
this.markEmbeddingFailure(err instanceof Error ? err : new Error(String(err)));
|
|
57072
57094
|
}
|
|
57073
|
-
} catch
|
|
57095
|
+
} catch (err) {
|
|
57096
|
+
this.markEmbeddingFailure(err instanceof Error ? err : new Error(String(err)));
|
|
57097
|
+
} finally {
|
|
57074
57098
|
this.embeddingFlushing = false;
|
|
57075
57099
|
}
|
|
57076
57100
|
}
|
|
57101
|
+
async tryEmbedBatch(texts) {
|
|
57102
|
+
if (this.embeddingEngine === void 0) return null;
|
|
57103
|
+
try {
|
|
57104
|
+
const first = await this.embeddingEngine.embedBatch(texts);
|
|
57105
|
+
if (first !== null) return first;
|
|
57106
|
+
} catch {}
|
|
57107
|
+
try {
|
|
57108
|
+
return await this.embeddingEngine.embedBatch(texts);
|
|
57109
|
+
} catch {
|
|
57110
|
+
return null;
|
|
57111
|
+
}
|
|
57112
|
+
}
|
|
57113
|
+
markEmbeddingFailure(error) {
|
|
57114
|
+
this.embeddingDegraded = true;
|
|
57115
|
+
this.embeddingConsecutiveFailures += 1;
|
|
57116
|
+
this.lastEmbeddingError = error;
|
|
57117
|
+
this.log.warn?.("embedding flush failed", {
|
|
57118
|
+
error: error.message,
|
|
57119
|
+
consecutiveFailures: this.embeddingConsecutiveFailures
|
|
57120
|
+
});
|
|
57121
|
+
}
|
|
57122
|
+
clearEmbeddingFailure() {
|
|
57123
|
+
this.embeddingDegraded = false;
|
|
57124
|
+
this.embeddingConsecutiveFailures = 0;
|
|
57125
|
+
this.lastEmbeddingError = void 0;
|
|
57126
|
+
}
|
|
57127
|
+
/**
|
|
57128
|
+
* Runtime health of the embedding subsystem. When `degraded` is true, the
|
|
57129
|
+
* store still serves keyword search; only vector similarity is unavailable.
|
|
57130
|
+
*/
|
|
57131
|
+
embeddingStatus() {
|
|
57132
|
+
return {
|
|
57133
|
+
available: this.embeddingEngine !== void 0 && this.embeddingEngine.available,
|
|
57134
|
+
degraded: this.embeddingDegraded,
|
|
57135
|
+
consecutiveFailures: this.embeddingConsecutiveFailures,
|
|
57136
|
+
lastError: this.lastEmbeddingError?.message
|
|
57137
|
+
};
|
|
57138
|
+
}
|
|
57077
57139
|
listAll(limit, offset, projectDir) {
|
|
57078
57140
|
if (this.db === void 0) return {
|
|
57079
57141
|
rows: [],
|
|
@@ -61738,7 +61800,8 @@ function summarizeSkill(skill) {
|
|
|
61738
61800
|
path: skill.path,
|
|
61739
61801
|
source: skill.source,
|
|
61740
61802
|
type: skill.metadata.type,
|
|
61741
|
-
disableModelInvocation: skill.metadata.disableModelInvocation
|
|
61803
|
+
disableModelInvocation: skill.metadata.disableModelInvocation,
|
|
61804
|
+
pluginId: skill.plugin?.id
|
|
61742
61805
|
};
|
|
61743
61806
|
}
|
|
61744
61807
|
//#endregion
|
|
@@ -61822,7 +61885,7 @@ function parseSkillText(options) {
|
|
|
61822
61885
|
throw error;
|
|
61823
61886
|
}
|
|
61824
61887
|
const frontmatter = parsed.data ?? {};
|
|
61825
|
-
if (!isRecord$
|
|
61888
|
+
if (!isRecord$6(frontmatter)) throw new SkillParseError(`Frontmatter in ${options.skillMdPath} must be a mapping at the top level`);
|
|
61826
61889
|
const metadata = normalizeMetadata(frontmatter);
|
|
61827
61890
|
if (!isSupportedSkillType(metadata.type)) throw new UnsupportedSkillTypeError(metadata.type ?? String(frontmatter["type"]));
|
|
61828
61891
|
const name = nonEmptyString$2(metadata.name);
|
|
@@ -61935,7 +61998,7 @@ function tokenizeArgs(raw) {
|
|
|
61935
61998
|
function nonEmptyString$2(value) {
|
|
61936
61999
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
61937
62000
|
}
|
|
61938
|
-
function isRecord$
|
|
62001
|
+
function isRecord$6(value) {
|
|
61939
62002
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61940
62003
|
}
|
|
61941
62004
|
//#endregion
|
|
@@ -62215,6 +62278,31 @@ function isWithin$2(child, parent) {
|
|
|
62215
62278
|
return rel === "" || !rel.startsWith("..") && !isAbsolute$1(rel);
|
|
62216
62279
|
}
|
|
62217
62280
|
//#endregion
|
|
62281
|
+
//#region ../../packages/agent-core/src/skill/install-paths.ts
|
|
62282
|
+
const MANAGED_SKILL_ROOT_NAMES = new Set([".scream-code", ".agents"]);
|
|
62283
|
+
/**
|
|
62284
|
+
* Given a skill path, return the filesystem entry that represents the whole
|
|
62285
|
+
* skill installation unit. For directory-based skills this is the skill's root
|
|
62286
|
+
* directory (so bundled sub-skills are removed together); for flat `.md`
|
|
62287
|
+
* skills this is the `.md` file itself.
|
|
62288
|
+
*
|
|
62289
|
+
* The install unit is the first ancestor of `skillPath` whose parent is a
|
|
62290
|
+
* managed skill root such as `<...>/.scream-code/skills` or
|
|
62291
|
+
* `<...>/.agents/skills`.
|
|
62292
|
+
*/
|
|
62293
|
+
function resolveSkillInstallUnit(skillPath) {
|
|
62294
|
+
let current = normalize(skillPath).replaceAll("\\", "/");
|
|
62295
|
+
while (true) {
|
|
62296
|
+
const parent = dirname$2(current).replaceAll("\\", "/");
|
|
62297
|
+
if (parent === current || parent === ".") throw new Error(`Skill path "${skillPath}" is not under a managed skill root`);
|
|
62298
|
+
const parentBase = basename$1(parent);
|
|
62299
|
+
const grandparent = dirname$2(parent).replaceAll("\\", "/");
|
|
62300
|
+
const grandparentBase = grandparent === "." ? "" : basename$1(grandparent);
|
|
62301
|
+
if (parentBase === "skills" && MANAGED_SKILL_ROOT_NAMES.has(grandparentBase)) return current;
|
|
62302
|
+
current = parent;
|
|
62303
|
+
}
|
|
62304
|
+
}
|
|
62305
|
+
//#endregion
|
|
62218
62306
|
//#region ../../packages/agent-core/src/skill/registry.ts
|
|
62219
62307
|
const LISTING_DESC_MAX = 250;
|
|
62220
62308
|
var SkillRegistry = class {
|
|
@@ -62275,6 +62363,40 @@ var SkillRegistry = class {
|
|
|
62275
62363
|
const key = pluginSkillKey(skill.plugin.id, skill.name);
|
|
62276
62364
|
if (options.replace === true || !this.byPluginAndName.has(key)) this.byPluginAndName.set(key, skill);
|
|
62277
62365
|
}
|
|
62366
|
+
/**
|
|
62367
|
+
* Remove every skill and root contributed by a plugin that is being
|
|
62368
|
+
* uninstalled, so the running session no longer offers those skills.
|
|
62369
|
+
*/
|
|
62370
|
+
ejectPlugin(pluginId) {
|
|
62371
|
+
const rootsToRemove = /* @__PURE__ */ new Set();
|
|
62372
|
+
for (const skill of this.byName.values()) {
|
|
62373
|
+
if (skill.plugin?.id !== pluginId) continue;
|
|
62374
|
+
for (const rootPath of this.roots) if (isPathUnderOrEqual(skill.path, rootPath)) rootsToRemove.add(rootPath);
|
|
62375
|
+
}
|
|
62376
|
+
for (const [name, skill] of this.byName) if (skill.plugin?.id === pluginId) this.byName.delete(name);
|
|
62377
|
+
for (const [key, skill] of this.byPluginAndName) if (skill.plugin?.id === pluginId) this.byPluginAndName.delete(key);
|
|
62378
|
+
const keptRoots = this.roots.filter((rootPath) => !rootsToRemove.has(rootPath));
|
|
62379
|
+
this.roots.length = 0;
|
|
62380
|
+
this.roots.push(...keptRoots);
|
|
62381
|
+
}
|
|
62382
|
+
/**
|
|
62383
|
+
* Remove every skill whose path lives under `skillPath` (inclusive), and any
|
|
62384
|
+
* skill root that is contained by `skillPath`. Used when a manual skill
|
|
62385
|
+
* installation unit has been deleted from disk.
|
|
62386
|
+
*/
|
|
62387
|
+
removeSkillPath(skillPath) {
|
|
62388
|
+
const normalizedPrefix = normalizePath(skillPath);
|
|
62389
|
+
let removed = 0;
|
|
62390
|
+
for (const [name, skill] of this.byName) if (isPathUnderOrEqual(skill.path, normalizedPrefix)) {
|
|
62391
|
+
this.byName.delete(name);
|
|
62392
|
+
removed++;
|
|
62393
|
+
}
|
|
62394
|
+
for (const [key, skill] of this.byPluginAndName) if (isPathUnderOrEqual(skill.path, normalizedPrefix)) this.byPluginAndName.delete(key);
|
|
62395
|
+
const keptRoots = this.roots.filter((rootPath) => !isPathUnderOrEqual(rootPath, normalizedPrefix));
|
|
62396
|
+
this.roots.length = 0;
|
|
62397
|
+
this.roots.push(...keptRoots);
|
|
62398
|
+
return removed;
|
|
62399
|
+
}
|
|
62278
62400
|
renderSkillPrompt(skill, rawArgs) {
|
|
62279
62401
|
const argumentNames = skillArgumentNames(skill.metadata);
|
|
62280
62402
|
const content = expandSkillParameters(skill.content, rawArgs, {
|
|
@@ -62311,6 +62433,16 @@ var SkillRegistry = class {
|
|
|
62311
62433
|
return lines.length === 1 ? "" : lines.join("\n");
|
|
62312
62434
|
}
|
|
62313
62435
|
};
|
|
62436
|
+
function normalizePath(value) {
|
|
62437
|
+
return value.replaceAll("\\", "/").replace(/\/$/, "");
|
|
62438
|
+
}
|
|
62439
|
+
function isPathUnderOrEqual(skillPath, rootPath) {
|
|
62440
|
+
const normalizedSkill = normalizePath(skillPath);
|
|
62441
|
+
const normalizedRoot = normalizePath(rootPath);
|
|
62442
|
+
if (normalizedSkill === normalizedRoot) return true;
|
|
62443
|
+
const separator = normalizedRoot.endsWith("/") ? "" : "/";
|
|
62444
|
+
return normalizedSkill.startsWith(`${normalizedRoot}${separator}`);
|
|
62445
|
+
}
|
|
62314
62446
|
function pluginSkillKey(pluginId, skillName) {
|
|
62315
62447
|
return `${pluginId}\0${normalizeSkillName(skillName)}`;
|
|
62316
62448
|
}
|
|
@@ -68836,7 +68968,8 @@ const LoopControlSchema = z.object({
|
|
|
68836
68968
|
maxRetriesPerStep: z.number().int().min(0).optional(),
|
|
68837
68969
|
maxRalphIterations: z.number().int().min(-1).optional(),
|
|
68838
68970
|
reservedContextSize: z.number().int().min(0).optional(),
|
|
68839
|
-
compactionTriggerRatio: z.number().min(.5).max(.99).optional()
|
|
68971
|
+
compactionTriggerRatio: z.number().min(.5).max(.99).optional(),
|
|
68972
|
+
maxGoalTurns: z.number().int().min(0).optional()
|
|
68840
68973
|
});
|
|
68841
68974
|
const BackgroundConfigSchema = z.object({
|
|
68842
68975
|
maxRunningTasks: z.number().int().min(1).optional(),
|
|
@@ -69099,11 +69232,11 @@ async function parseManifest(pluginRoot) {
|
|
|
69099
69232
|
return {
|
|
69100
69233
|
manifest: {
|
|
69101
69234
|
name,
|
|
69102
|
-
version: stringField$
|
|
69103
|
-
description: stringField$
|
|
69104
|
-
keywords: stringArrayField(raw, "keywords"),
|
|
69105
|
-
homepage: stringField$
|
|
69106
|
-
license: stringField$
|
|
69235
|
+
version: stringField$2(raw, "version"),
|
|
69236
|
+
description: stringField$2(raw, "description"),
|
|
69237
|
+
keywords: stringArrayField$1(raw, "keywords"),
|
|
69238
|
+
homepage: stringField$2(raw, "homepage"),
|
|
69239
|
+
license: stringField$2(raw, "license"),
|
|
69107
69240
|
author: readAuthor(raw["author"]),
|
|
69108
69241
|
skills,
|
|
69109
69242
|
sessionStart: readSessionStart(raw["sessionStart"], diagnostics),
|
|
@@ -69294,8 +69427,8 @@ async function normalizePluginMcpServer(input) {
|
|
|
69294
69427
|
function readAuthor(raw) {
|
|
69295
69428
|
if (typeof raw === "string") return { name: raw };
|
|
69296
69429
|
if (!isObject(raw)) return void 0;
|
|
69297
|
-
const name = stringField$
|
|
69298
|
-
const email = stringField$
|
|
69430
|
+
const name = stringField$2(raw, "name");
|
|
69431
|
+
const email = stringField$2(raw, "email");
|
|
69299
69432
|
if (name === void 0 && email === void 0) return void 0;
|
|
69300
69433
|
return {
|
|
69301
69434
|
name,
|
|
@@ -69305,21 +69438,21 @@ function readAuthor(raw) {
|
|
|
69305
69438
|
function readInterface(raw) {
|
|
69306
69439
|
if (!isObject(raw)) return void 0;
|
|
69307
69440
|
const out = {
|
|
69308
|
-
displayName: stringField$
|
|
69309
|
-
shortDescription: stringField$
|
|
69310
|
-
longDescription: stringField$
|
|
69311
|
-
developerName: stringField$
|
|
69312
|
-
websiteURL: stringField$
|
|
69441
|
+
displayName: stringField$2(raw, "displayName"),
|
|
69442
|
+
shortDescription: stringField$2(raw, "shortDescription"),
|
|
69443
|
+
longDescription: stringField$2(raw, "longDescription"),
|
|
69444
|
+
developerName: stringField$2(raw, "developerName"),
|
|
69445
|
+
websiteURL: stringField$2(raw, "websiteURL")
|
|
69313
69446
|
};
|
|
69314
69447
|
return Object.values(out).some((value) => value !== void 0) ? out : void 0;
|
|
69315
69448
|
}
|
|
69316
|
-
function stringField$
|
|
69449
|
+
function stringField$2(raw, key) {
|
|
69317
69450
|
const value = raw[key];
|
|
69318
69451
|
if (typeof value !== "string") return void 0;
|
|
69319
69452
|
const trimmed = value.trim();
|
|
69320
69453
|
return trimmed.length === 0 ? void 0 : trimmed;
|
|
69321
69454
|
}
|
|
69322
|
-
function stringArrayField(raw, key) {
|
|
69455
|
+
function stringArrayField$1(raw, key) {
|
|
69323
69456
|
const value = raw[key];
|
|
69324
69457
|
if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string")) return;
|
|
69325
69458
|
return value;
|
|
@@ -76160,17 +76293,13 @@ var BashTool = class {
|
|
|
76160
76293
|
"-c",
|
|
76161
76294
|
`cd ${shellQuote$1(shellCwd)} && ${preamble}\n${command}`
|
|
76162
76295
|
];
|
|
76163
|
-
const
|
|
76296
|
+
const mergedEnv = {
|
|
76164
76297
|
NO_COLOR: "1",
|
|
76165
76298
|
TERM: "dumb",
|
|
76166
76299
|
GIT_TERMINAL_PROMPT: process.env["GIT_TERMINAL_PROMPT"] ?? "0",
|
|
76167
76300
|
SHELL: this.jian.osEnv.shellPath,
|
|
76168
76301
|
SCREAM_PID: String(process.pid)
|
|
76169
76302
|
};
|
|
76170
|
-
const mergedEnv = {
|
|
76171
|
-
...process.env,
|
|
76172
|
-
...noninteractiveEnv
|
|
76173
|
-
};
|
|
76174
76303
|
return this.jian.execWithEnv(shellArgs, mergedEnv);
|
|
76175
76304
|
}
|
|
76176
76305
|
async execution(args, signal) {
|
|
@@ -78987,7 +79116,7 @@ const OptionalStringSchema = z.preprocess((value) => {
|
|
|
78987
79116
|
if (typeof value === "string") return value;
|
|
78988
79117
|
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
|
|
78989
79118
|
}, z.string().optional());
|
|
78990
|
-
const HookSpecificOutputSchema = z.preprocess((value) => isRecord$
|
|
79119
|
+
const HookSpecificOutputSchema = z.preprocess((value) => isRecord$5(value) ? value : void 0, z.looseObject({
|
|
78991
79120
|
message: OptionalStringSchema,
|
|
78992
79121
|
permissionDecision: z.unknown().optional(),
|
|
78993
79122
|
permissionDecisionReason: OptionalStringSchema
|
|
@@ -79147,7 +79276,7 @@ function tryKillProcess(child, signal) {
|
|
|
79147
79276
|
} catch {}
|
|
79148
79277
|
}
|
|
79149
79278
|
}
|
|
79150
|
-
function isRecord$
|
|
79279
|
+
function isRecord$5(value) {
|
|
79151
79280
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
79152
79281
|
}
|
|
79153
79282
|
function errorMessage$2(error) {
|
|
@@ -80105,7 +80234,7 @@ var CwdOutsideFileWriteAskPermissionPolicy = class {
|
|
|
80105
80234
|
if (cwd.length === 0) return;
|
|
80106
80235
|
const pathClass = this.agent.jian.pathClass();
|
|
80107
80236
|
const access = writeFileAccesses(context).find((fileAccess) => {
|
|
80108
|
-
return !isWithinDirectory(fileAccess.path, cwd, pathClass);
|
|
80237
|
+
return !isWithinDirectory$1(fileAccess.path, cwd, pathClass);
|
|
80109
80238
|
});
|
|
80110
80239
|
if (access === void 0) return;
|
|
80111
80240
|
return {
|
|
@@ -80131,7 +80260,7 @@ function hasGitPathComponent(targetPath, cwd, pathClass) {
|
|
|
80131
80260
|
return relativePathParts(targetPath, cwd, pathClass).some((part) => part.toLowerCase() === ".git");
|
|
80132
80261
|
}
|
|
80133
80262
|
function isGitControlPath(targetPath, marker, pathClass) {
|
|
80134
|
-
return isWithinDirectory(targetPath, marker.dotGitPath, pathClass) || isWithinDirectory(targetPath, marker.controlDirPath, pathClass);
|
|
80263
|
+
return isWithinDirectory$1(targetPath, marker.dotGitPath, pathClass) || isWithinDirectory$1(targetPath, marker.controlDirPath, pathClass);
|
|
80135
80264
|
}
|
|
80136
80265
|
function relativePathParts(targetPath, cwd, pathClass) {
|
|
80137
80266
|
return pathMod(pathClass).relative(cwd, targetPath).split(/[\\/]+/).filter((part) => part.length > 0);
|
|
@@ -80155,7 +80284,7 @@ var GitCwdWriteApprovePermissionPolicy = class {
|
|
|
80155
80284
|
if (cwd.length === 0) return;
|
|
80156
80285
|
const writeAccesses = writeFileAccesses(context);
|
|
80157
80286
|
if (writeAccesses.length === 0) return;
|
|
80158
|
-
if (!writeAccesses.every((access) => isWithinDirectory(access.path, cwd, "posix"))) return;
|
|
80287
|
+
if (!writeAccesses.every((access) => isWithinDirectory$1(access.path, cwd, "posix"))) return;
|
|
80159
80288
|
if (await findGitWorkTreeMarker(this.agent.jian, cwd) === null) return;
|
|
80160
80289
|
return { kind: "approve" };
|
|
80161
80290
|
}
|
|
@@ -95403,14 +95532,21 @@ var TurnFlow = class {
|
|
|
95403
95532
|
* one full turn, then reads the goal status the model set via UpdateGoal.
|
|
95404
95533
|
*/
|
|
95405
95534
|
async driveGoal(firstTurnId, input, origin, signal) {
|
|
95535
|
+
const effectiveMaxGoalTurns = this.agent.screamConfig?.loopControl?.maxGoalTurns ?? 50;
|
|
95406
95536
|
let turnId = firstTurnId;
|
|
95407
95537
|
let turnInput = input;
|
|
95408
95538
|
let turnOrigin = origin;
|
|
95409
95539
|
while (true) {
|
|
95410
95540
|
const goalBeforeTurn = this.agent.goal.getGoal().goal;
|
|
95411
|
-
if (goalBeforeTurn?.status === "active"
|
|
95412
|
-
|
|
95413
|
-
|
|
95541
|
+
if (goalBeforeTurn?.status === "active") {
|
|
95542
|
+
if (effectiveMaxGoalTurns > 0 && goalBeforeTurn.budget.turnBudget === null && goalBeforeTurn.turnsUsed >= effectiveMaxGoalTurns) {
|
|
95543
|
+
await this.agent.goal.markBlocked({ reason: `Reached the goal turn limit (${effectiveMaxGoalTurns})` });
|
|
95544
|
+
return { event: await this.endGoalTurnWithoutModel(turnId, turnInput, turnOrigin) };
|
|
95545
|
+
}
|
|
95546
|
+
if (goalBeforeTurn.budget.overBudget) {
|
|
95547
|
+
await this.agent.goal.markBlocked({ reason: "A configured budget was reached" });
|
|
95548
|
+
return { event: await this.endGoalTurnWithoutModel(turnId, turnInput, turnOrigin) };
|
|
95549
|
+
}
|
|
95414
95550
|
}
|
|
95415
95551
|
await this.agent.goal.incrementTurn();
|
|
95416
95552
|
const end = await this.runOneTurn(turnId, turnInput, turnOrigin, signal, false);
|
|
@@ -96375,19 +96511,39 @@ var Agent = class {
|
|
|
96375
96511
|
this.cron = this.type === "sub" ? null : new CronManager(this);
|
|
96376
96512
|
this.goal = new GoalMode(this);
|
|
96377
96513
|
const screamHomeDir = options.screamHomeDir;
|
|
96378
|
-
this.memoStore = screamHomeDir ? new MemoryMemoStore(screamHomeDir) : void 0;
|
|
96379
|
-
|
|
96380
|
-
this.memoStore.init();
|
|
96381
|
-
MemoryMemoStore.migrateLegacyStores(screamHomeDir);
|
|
96382
|
-
try {
|
|
96383
|
-
this.memoStore.setEmbeddingEngine(createFastEmbedEngine());
|
|
96384
|
-
} catch {}
|
|
96385
|
-
}
|
|
96514
|
+
this.memoStore = screamHomeDir ? new MemoryMemoStore(screamHomeDir, this.log) : void 0;
|
|
96515
|
+
this.memoStoreReady = this.initMemoStore(screamHomeDir);
|
|
96386
96516
|
this.sessionMemory = new SessionMemory(this);
|
|
96387
96517
|
this.workingSet = new WorkingSet();
|
|
96388
96518
|
this.dreamTracker = new DreamTracker(screamHomeDir ?? "");
|
|
96389
96519
|
this.replayBuilder = new ReplayBuilder(this);
|
|
96390
96520
|
}
|
|
96521
|
+
/**
|
|
96522
|
+
* Promise that resolves once the shared memory store (and any legacy migration)
|
|
96523
|
+
* has been initialized. Session startup awaits this so memory tools are ready
|
|
96524
|
+
* before the first turn runs.
|
|
96525
|
+
*/
|
|
96526
|
+
memoStoreReady;
|
|
96527
|
+
initMemoStore(screamHomeDir) {
|
|
96528
|
+
if (screamHomeDir === void 0 || this.memoStore === void 0) return Promise.resolve();
|
|
96529
|
+
return (async () => {
|
|
96530
|
+
try {
|
|
96531
|
+
await this.memoStore.init();
|
|
96532
|
+
} catch (error) {
|
|
96533
|
+
this.log.error("memory store init failed", error);
|
|
96534
|
+
}
|
|
96535
|
+
try {
|
|
96536
|
+
await MemoryMemoStore.migrateLegacyStores(screamHomeDir);
|
|
96537
|
+
} catch (error) {
|
|
96538
|
+
this.log.error("memory legacy migration failed", error);
|
|
96539
|
+
}
|
|
96540
|
+
try {
|
|
96541
|
+
this.memoStore.setEmbeddingEngine(createFastEmbedEngine());
|
|
96542
|
+
} catch (error) {
|
|
96543
|
+
this.log.warn("embedding engine init failed; falling back to keyword search", error);
|
|
96544
|
+
}
|
|
96545
|
+
})();
|
|
96546
|
+
}
|
|
96391
96547
|
get generate() {
|
|
96392
96548
|
return async (provider, systemPrompt, tools, history, callbacks, options) => {
|
|
96393
96549
|
if (options?.auth !== void 0) {
|
|
@@ -101245,6 +101401,7 @@ var Session$1 = class {
|
|
|
101245
101401
|
hookEngine;
|
|
101246
101402
|
agentIdCounter = 0;
|
|
101247
101403
|
skillsReady;
|
|
101404
|
+
mcpReady;
|
|
101248
101405
|
metadata = {
|
|
101249
101406
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
101250
101407
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -101279,12 +101436,13 @@ var Session$1 = class {
|
|
|
101279
101436
|
}).then(() => {
|
|
101280
101437
|
this.refreshAgentBuiltinTools();
|
|
101281
101438
|
});
|
|
101282
|
-
this.loadMcpServers().catch((error) => {
|
|
101439
|
+
this.mcpReady = this.loadMcpServers().catch((error) => {
|
|
101283
101440
|
this.emitInitialMcpLoadError(error);
|
|
101284
101441
|
});
|
|
101285
101442
|
}
|
|
101286
101443
|
async createMain() {
|
|
101287
101444
|
const { agent } = await this.createAgent({ type: "main" }, DEFAULT_AGENT_PROFILES["agent"]);
|
|
101445
|
+
await agent.memoStoreReady;
|
|
101288
101446
|
await this.triggerSessionStart("startup");
|
|
101289
101447
|
return agent;
|
|
101290
101448
|
}
|
|
@@ -101294,7 +101452,9 @@ var Session$1 = class {
|
|
|
101294
101452
|
this.agents.clear();
|
|
101295
101453
|
let warning;
|
|
101296
101454
|
const resumeTasks = Object.keys(agents).map(async (id) => {
|
|
101297
|
-
const
|
|
101455
|
+
const agent = this.ensureResumeAgentInstantiated(id, agents);
|
|
101456
|
+
await agent.memoStoreReady;
|
|
101457
|
+
const result = await agent.resume();
|
|
101298
101458
|
if (result.warning !== void 0 && warning === void 0) warning = result.warning;
|
|
101299
101459
|
});
|
|
101300
101460
|
await Promise.all(resumeTasks);
|
|
@@ -101431,6 +101591,42 @@ var Session$1 = class {
|
|
|
101431
101591
|
await this.skillsReady;
|
|
101432
101592
|
return this.skills.listSkills().map(summarizeSkill);
|
|
101433
101593
|
}
|
|
101594
|
+
/**
|
|
101595
|
+
* Dynamically load additional skill roots into the running session.
|
|
101596
|
+
* Used after a plugin is installed so its skills become available
|
|
101597
|
+
* without requiring the user to create a new session.
|
|
101598
|
+
*/
|
|
101599
|
+
async injectSkillRoots(roots) {
|
|
101600
|
+
await this.skillsReady;
|
|
101601
|
+
await this.skills.loadRoots(roots);
|
|
101602
|
+
this.refreshAgentBuiltinTools();
|
|
101603
|
+
}
|
|
101604
|
+
/**
|
|
101605
|
+
* Remove skills contributed by a plugin from the running session.
|
|
101606
|
+
* Called automatically when a plugin is uninstalled while the session is active.
|
|
101607
|
+
*/
|
|
101608
|
+
ejectPlugin(pluginId) {
|
|
101609
|
+
this.skills.ejectPlugin(pluginId);
|
|
101610
|
+
this.refreshAgentBuiltinTools();
|
|
101611
|
+
}
|
|
101612
|
+
/**
|
|
101613
|
+
* Delete a manually installed skill from disk and remove it (and any bundled
|
|
101614
|
+
* sub-skills) from the running session. Plugin-provided skills must be
|
|
101615
|
+
* uninstalled via removePlugin instead.
|
|
101616
|
+
*/
|
|
101617
|
+
async removeSkill(skillName) {
|
|
101618
|
+
await this.skillsReady;
|
|
101619
|
+
const skill = this.skills.getSkill(skillName);
|
|
101620
|
+
if (skill === void 0) throw new ScreamError(ErrorCodes.SKILL_NOT_FOUND, `Skill "${skillName}" was not found`);
|
|
101621
|
+
if (skill.source === "builtin" || skill.plugin !== void 0) throw new ScreamError(ErrorCodes.REQUEST_INVALID, `Skill "${skillName}" cannot be removed this way; use removePlugin for plugin skills`);
|
|
101622
|
+
const installUnit = resolveSkillInstallUnit(skill.path);
|
|
101623
|
+
await rm(installUnit, {
|
|
101624
|
+
recursive: true,
|
|
101625
|
+
force: true
|
|
101626
|
+
});
|
|
101627
|
+
this.skills.removeSkillPath(installUnit);
|
|
101628
|
+
this.refreshAgentBuiltinTools();
|
|
101629
|
+
}
|
|
101434
101630
|
async loadSkills() {
|
|
101435
101631
|
const roots = await resolveSkillRoots({
|
|
101436
101632
|
paths: {
|
|
@@ -116164,6 +116360,9 @@ var SessionAPIImpl = class {
|
|
|
116164
116360
|
listSkills(_payload) {
|
|
116165
116361
|
return this.session.listSkills();
|
|
116166
116362
|
}
|
|
116363
|
+
async removeSkill(payload) {
|
|
116364
|
+
return this.session.removeSkill(payload.skillName);
|
|
116365
|
+
}
|
|
116167
116366
|
listMcpServers(_payload) {
|
|
116168
116367
|
return this.session.mcp.list();
|
|
116169
116368
|
}
|
|
@@ -116335,6 +116534,9 @@ var SessionAPIImpl = class {
|
|
|
116335
116534
|
}
|
|
116336
116535
|
});
|
|
116337
116536
|
}
|
|
116537
|
+
async injectPlugin(_payload) {
|
|
116538
|
+
throw new ScreamError(ErrorCodes.NOT_IMPLEMENTED, "injectPlugin is implemented at the core level");
|
|
116539
|
+
}
|
|
116338
116540
|
};
|
|
116339
116541
|
function isUntitled(title) {
|
|
116340
116542
|
return typeof title !== "string" || title.trim().length === 0 || title === "New Session";
|
|
@@ -116660,7 +116862,7 @@ var SessionStore = class {
|
|
|
116660
116862
|
} catch (error) {
|
|
116661
116863
|
throw new ScreamError(ErrorCodes.SESSION_STATE_NOT_FOUND, `Session "${input.sourceId}" state.json was not found`, { cause: error });
|
|
116662
116864
|
}
|
|
116663
|
-
if (!isRecord$
|
|
116865
|
+
if (!isRecord$4(parsed)) throw new ScreamError(ErrorCodes.SESSION_STATE_INVALID, `Session "${input.sourceId}" state.json is invalid`);
|
|
116664
116866
|
const title = normalizeForkTitle(input.title, parsed["title"]);
|
|
116665
116867
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
116666
116868
|
const next = {
|
|
@@ -116671,7 +116873,7 @@ var SessionStore = class {
|
|
|
116671
116873
|
isCustomTitle: input.title === void 0 ? parsed["isCustomTitle"] === true : true,
|
|
116672
116874
|
forkedFrom: input.sourceId,
|
|
116673
116875
|
agents: rewriteAgentHomedirs(parsed["agents"], sourceDir, targetDir),
|
|
116674
|
-
custom: Object.assign({}, isRecord$
|
|
116876
|
+
custom: Object.assign({}, isRecord$4(parsed["custom"]) ? parsed["custom"] : {}, input.metadata)
|
|
116675
116877
|
};
|
|
116676
116878
|
await writeFile(statePath, `${JSON.stringify(next, null, 2)}\n`, "utf-8");
|
|
116677
116879
|
}
|
|
@@ -116746,10 +116948,10 @@ function normalizeForkTitle(title, fallback) {
|
|
|
116746
116948
|
return typeof fallback === "string" && fallback.trim().length > 0 ? fallback : "New Session";
|
|
116747
116949
|
}
|
|
116748
116950
|
function rewriteAgentHomedirs(value, sourceDir, targetDir) {
|
|
116749
|
-
if (!isRecord$
|
|
116951
|
+
if (!isRecord$4(value)) return {};
|
|
116750
116952
|
const agents = {};
|
|
116751
116953
|
for (const [agentId, agentMeta] of Object.entries(value)) {
|
|
116752
|
-
if (!isRecord$
|
|
116954
|
+
if (!isRecord$4(agentMeta)) {
|
|
116753
116955
|
agents[agentId] = agentMeta;
|
|
116754
116956
|
continue;
|
|
116755
116957
|
}
|
|
@@ -116767,7 +116969,7 @@ function remapSessionPath(value, sourceDir, targetDir) {
|
|
|
116767
116969
|
if (rel.startsWith("..") || isAbsolute$1(rel)) return value;
|
|
116768
116970
|
return join$1(targetDir, rel);
|
|
116769
116971
|
}
|
|
116770
|
-
function isRecord$
|
|
116972
|
+
function isRecord$4(value) {
|
|
116771
116973
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
116772
116974
|
}
|
|
116773
116975
|
async function statIfExists(path) {
|
|
@@ -116916,6 +117118,21 @@ var JianShellNotFoundError = class extends JianError {
|
|
|
116916
117118
|
this.name = "JianShellNotFoundError";
|
|
116917
117119
|
}
|
|
116918
117120
|
};
|
|
117121
|
+
/**
|
|
117122
|
+
* Thrown by `LocalJian` when a file operation would resolve outside the
|
|
117123
|
+
* instance's configured root directory. This is a last-line-of-defense guard;
|
|
117124
|
+
* higher-level path policies should still validate user-supplied paths first.
|
|
117125
|
+
*/
|
|
117126
|
+
var JianPathOutsideRootError = class extends JianError {
|
|
117127
|
+
path;
|
|
117128
|
+
rootDir;
|
|
117129
|
+
constructor(message, path, rootDir) {
|
|
117130
|
+
super(message);
|
|
117131
|
+
this.path = path;
|
|
117132
|
+
this.rootDir = rootDir;
|
|
117133
|
+
this.name = "JianPathOutsideRootError";
|
|
117134
|
+
}
|
|
117135
|
+
};
|
|
116919
117136
|
//#endregion
|
|
116920
117137
|
//#region ../../packages/jian/src/environment.ts
|
|
116921
117138
|
/**
|
|
@@ -117277,8 +117494,73 @@ var BufferedReadable = class extends Readable {
|
|
|
117277
117494
|
};
|
|
117278
117495
|
//#endregion
|
|
117279
117496
|
//#region ../../packages/jian/src/local.ts
|
|
117497
|
+
/**
|
|
117498
|
+
* Environment variables that spawned processes are allowed to inherit from the
|
|
117499
|
+
* parent process. All other variables are stripped to prevent accidental secret
|
|
117500
|
+
* leakage (e.g. cloud tokens, API keys, SSH agent sockets) into agent-executed
|
|
117501
|
+
* commands. Explicit env values passed by callers can still add or override keys.
|
|
117502
|
+
*/
|
|
117503
|
+
const ALLOWED_INHERITED_ENV_KEYS = [
|
|
117504
|
+
"PATH",
|
|
117505
|
+
"PATHEXT",
|
|
117506
|
+
"SHELL",
|
|
117507
|
+
"ComSpec",
|
|
117508
|
+
"HOME",
|
|
117509
|
+
"USER",
|
|
117510
|
+
"USERNAME",
|
|
117511
|
+
"LOGNAME",
|
|
117512
|
+
"USERPROFILE",
|
|
117513
|
+
"HOMEDRIVE",
|
|
117514
|
+
"HOMEPATH",
|
|
117515
|
+
"LANG",
|
|
117516
|
+
"LC_ALL",
|
|
117517
|
+
"LC_CTYPE",
|
|
117518
|
+
"LC_MESSAGES",
|
|
117519
|
+
"TERM",
|
|
117520
|
+
"TERM_PROGRAM",
|
|
117521
|
+
"TERM_PROGRAM_VERSION",
|
|
117522
|
+
"COLORTERM",
|
|
117523
|
+
"NO_COLOR",
|
|
117524
|
+
"FORCE_COLOR",
|
|
117525
|
+
"TMPDIR",
|
|
117526
|
+
"TEMP",
|
|
117527
|
+
"TMP",
|
|
117528
|
+
"APPDATA",
|
|
117529
|
+
"LOCALAPPDATA",
|
|
117530
|
+
"XDG_CONFIG_HOME",
|
|
117531
|
+
"XDG_CACHE_HOME",
|
|
117532
|
+
"XDG_DATA_HOME",
|
|
117533
|
+
"XDG_RUNTIME_DIR",
|
|
117534
|
+
"GIT_TERMINAL_PROMPT",
|
|
117535
|
+
"GIT_ASKPASS",
|
|
117536
|
+
"SSH_ASKPASS",
|
|
117537
|
+
"SCREAM_PID"
|
|
117538
|
+
];
|
|
117280
117539
|
const isWindows = process.platform === "win32";
|
|
117281
117540
|
/**
|
|
117541
|
+
* True if `candidate` is `base` itself or a descendant of `base`, compared on
|
|
117542
|
+
* path-component boundaries. Both paths must already be normalized. This is a
|
|
117543
|
+
* lexical check only; it does not resolve symlinks.
|
|
117544
|
+
*/
|
|
117545
|
+
function isWithinDirectory(candidate, base) {
|
|
117546
|
+
if (candidate === base) return true;
|
|
117547
|
+
const prefix = base.endsWith("/") ? base : `${base}/`;
|
|
117548
|
+
return candidate.startsWith(prefix);
|
|
117549
|
+
}
|
|
117550
|
+
/**
|
|
117551
|
+
* Build a sanitized environment for child processes. Inherits only an explicit
|
|
117552
|
+
* allowlist of ambient variables, then applies caller-supplied overrides.
|
|
117553
|
+
*/
|
|
117554
|
+
function buildSafeEnv(explicit) {
|
|
117555
|
+
const env = {};
|
|
117556
|
+
for (const key of ALLOWED_INHERITED_ENV_KEYS) {
|
|
117557
|
+
const value = process.env[key];
|
|
117558
|
+
if (value !== void 0) env[key] = value;
|
|
117559
|
+
}
|
|
117560
|
+
if (explicit !== void 0) for (const [key, value] of Object.entries(explicit)) env[key] = value;
|
|
117561
|
+
return env;
|
|
117562
|
+
}
|
|
117563
|
+
/**
|
|
117282
117564
|
* Build the `(dev, ino)` cycle-detection key used by `_globWalk`'s
|
|
117283
117565
|
* visited set. Returns `null` when `ino` is 0, which Node returns on
|
|
117284
117566
|
* filesystems that don't carry inodes (Windows FAT/exFAT, some SMB/NFS
|
|
@@ -117375,8 +117657,10 @@ var LocalJian = class LocalJian {
|
|
|
117375
117657
|
name = "local";
|
|
117376
117658
|
osEnv;
|
|
117377
117659
|
_cwd;
|
|
117378
|
-
|
|
117660
|
+
_rootDir;
|
|
117661
|
+
constructor(osEnv, cwd, rootDir) {
|
|
117379
117662
|
this._cwd = normalize(cwd ?? process.cwd());
|
|
117663
|
+
this._rootDir = rootDir === void 0 ? void 0 : normalize(rootDir);
|
|
117380
117664
|
this.osEnv = osEnv;
|
|
117381
117665
|
}
|
|
117382
117666
|
/**
|
|
@@ -117386,15 +117670,21 @@ var LocalJian = class LocalJian {
|
|
|
117386
117670
|
* callers can therefore operate on independent working directories
|
|
117387
117671
|
* without polluting one another.
|
|
117388
117672
|
*/
|
|
117389
|
-
static async create() {
|
|
117390
|
-
return new LocalJian(await detectEnvironmentFromNode());
|
|
117673
|
+
static async create(cwd, rootDir) {
|
|
117674
|
+
return new LocalJian(await detectEnvironmentFromNode(), cwd, rootDir);
|
|
117391
117675
|
}
|
|
117392
117676
|
withCwd(cwd) {
|
|
117393
|
-
return new LocalJian(this.osEnv, cwd);
|
|
117677
|
+
return new LocalJian(this.osEnv, cwd, this._rootDir);
|
|
117394
117678
|
}
|
|
117395
117679
|
_resolvePath(path) {
|
|
117396
|
-
|
|
117397
|
-
|
|
117680
|
+
const resolved = isAbsolute$1(path) ? normalize(path) : join$1(this._cwd, path);
|
|
117681
|
+
this._assertWithinRoot(resolved);
|
|
117682
|
+
return resolved;
|
|
117683
|
+
}
|
|
117684
|
+
_assertWithinRoot(resolvedPath) {
|
|
117685
|
+
if (this._rootDir === void 0) return;
|
|
117686
|
+
if (isWithinDirectory(resolvedPath, this._rootDir)) return;
|
|
117687
|
+
throw new JianPathOutsideRootError(`Path outside allowed root directory: ${resolvedPath}`, resolvedPath, this._rootDir);
|
|
117398
117688
|
}
|
|
117399
117689
|
pathClass() {
|
|
117400
117690
|
return isWindows ? "win32" : "posix";
|
|
@@ -117574,19 +117864,7 @@ var LocalJian = class LocalJian {
|
|
|
117574
117864
|
}
|
|
117575
117865
|
}
|
|
117576
117866
|
async exec(...args) {
|
|
117577
|
-
|
|
117578
|
-
if (command === void 0) throw new Error("LocalJian.exec(): at least one argument (the command to run) is required.");
|
|
117579
|
-
const child = spawn(command, args.slice(1), {
|
|
117580
|
-
cwd: this._cwd,
|
|
117581
|
-
stdio: [
|
|
117582
|
-
"pipe",
|
|
117583
|
-
"pipe",
|
|
117584
|
-
"pipe"
|
|
117585
|
-
],
|
|
117586
|
-
detached: !isWindows
|
|
117587
|
-
});
|
|
117588
|
-
await waitForSpawn(child);
|
|
117589
|
-
return new LocalProcess(child);
|
|
117867
|
+
return this.execWithEnv(args, void 0);
|
|
117590
117868
|
}
|
|
117591
117869
|
async execWithEnv(args, env) {
|
|
117592
117870
|
const command = args[0];
|
|
@@ -117599,7 +117877,7 @@ var LocalJian = class LocalJian {
|
|
|
117599
117877
|
"pipe"
|
|
117600
117878
|
],
|
|
117601
117879
|
detached: !isWindows,
|
|
117602
|
-
env
|
|
117880
|
+
env: buildSafeEnv(env)
|
|
117603
117881
|
});
|
|
117604
117882
|
await waitForSpawn(child);
|
|
117605
117883
|
return new LocalProcess(child);
|
|
@@ -117984,6 +118262,29 @@ var ScreamCore = class {
|
|
|
117984
118262
|
listSkills({ sessionId, ...payload }) {
|
|
117985
118263
|
return this.sessionApi(sessionId).listSkills(payload);
|
|
117986
118264
|
}
|
|
118265
|
+
async removeSkill({ sessionId, ...payload }) {
|
|
118266
|
+
return this.sessionApi(sessionId).removeSkill(payload);
|
|
118267
|
+
}
|
|
118268
|
+
async injectPlugin({ sessionId, id }) {
|
|
118269
|
+
await this.pluginsReady;
|
|
118270
|
+
this.assertPluginsLoaded();
|
|
118271
|
+
const session = this.sessions.get(sessionId);
|
|
118272
|
+
if (session === void 0) throw new ScreamError(ErrorCodes.SESSION_NOT_FOUND, `Session "${sessionId}" was not found`, { details: { sessionId } });
|
|
118273
|
+
const record = this.plugins.get(id);
|
|
118274
|
+
if (record === void 0) throw new ScreamError(ErrorCodes.PLUGIN_NOT_FOUND, `Plugin "${id}" is not installed`, { details: { id } });
|
|
118275
|
+
if (record.state !== "ok" || record.manifest === void 0) throw new ScreamError(ErrorCodes.PLUGIN_LOAD_FAILED, `Plugin "${id}" is in an error state and cannot be injected`, { details: { id } });
|
|
118276
|
+
const skillDirs = record.manifest.skills ?? [];
|
|
118277
|
+
if (skillDirs.length === 0) return;
|
|
118278
|
+
const roots = skillDirs.map((dir) => ({
|
|
118279
|
+
path: dir,
|
|
118280
|
+
source: "extra",
|
|
118281
|
+
plugin: {
|
|
118282
|
+
id: record.id,
|
|
118283
|
+
instructions: record.skillInstructions
|
|
118284
|
+
}
|
|
118285
|
+
}));
|
|
118286
|
+
await session.injectSkillRoots(roots);
|
|
118287
|
+
}
|
|
117987
118288
|
listMcpServers({ sessionId, ...payload }) {
|
|
117988
118289
|
return this.sessionApi(sessionId).listMcpServers(payload);
|
|
117989
118290
|
}
|
|
@@ -118002,6 +118303,14 @@ var ScreamCore = class {
|
|
|
118002
118303
|
removeMcpServer({ sessionId, ...payload }) {
|
|
118003
118304
|
return this.sessionApi(sessionId).removeMcpServer(payload);
|
|
118004
118305
|
}
|
|
118306
|
+
async removePlugin({ id }) {
|
|
118307
|
+
await this.pluginsReady;
|
|
118308
|
+
this.assertPluginsLoaded();
|
|
118309
|
+
await this.plugins.remove(id);
|
|
118310
|
+
for (const session of this.sessions.values()) try {
|
|
118311
|
+
session.ejectPlugin(id);
|
|
118312
|
+
} catch {}
|
|
118313
|
+
}
|
|
118005
118314
|
generateAgentsMd({ sessionId, ...payload }) {
|
|
118006
118315
|
return this.sessionApi(sessionId).generateAgentsMd(payload);
|
|
118007
118316
|
}
|
|
@@ -118026,11 +118335,6 @@ var ScreamCore = class {
|
|
|
118026
118335
|
this.assertPluginsLoaded();
|
|
118027
118336
|
await this.plugins.setMcpServerEnabled(id, server, enabled);
|
|
118028
118337
|
}
|
|
118029
|
-
async removePlugin({ id }) {
|
|
118030
|
-
await this.pluginsReady;
|
|
118031
|
-
this.assertPluginsLoaded();
|
|
118032
|
-
await this.plugins.remove(id);
|
|
118033
|
-
}
|
|
118034
118338
|
async reloadPlugins(_) {
|
|
118035
118339
|
try {
|
|
118036
118340
|
const summary = await this.plugins.reload();
|
|
@@ -118623,6 +118927,18 @@ var SDKRpcClient = class {
|
|
|
118623
118927
|
async listSkills(input) {
|
|
118624
118928
|
return (await this.getRpc()).listSkills({ sessionId: input.sessionId });
|
|
118625
118929
|
}
|
|
118930
|
+
async injectPlugin(input) {
|
|
118931
|
+
return (await this.getRpc()).injectPlugin({
|
|
118932
|
+
sessionId: input.sessionId,
|
|
118933
|
+
id: input.id
|
|
118934
|
+
});
|
|
118935
|
+
}
|
|
118936
|
+
async removeSkill(input) {
|
|
118937
|
+
return (await this.getRpc()).removeSkill({
|
|
118938
|
+
sessionId: input.sessionId,
|
|
118939
|
+
skillName: input.skillName
|
|
118940
|
+
});
|
|
118941
|
+
}
|
|
118626
118942
|
async listBackgroundTasks(input) {
|
|
118627
118943
|
return (await this.getRpc()).getBackground({
|
|
118628
118944
|
sessionId: input.sessionId,
|
|
@@ -118977,6 +119293,30 @@ var Session = class {
|
|
|
118977
119293
|
return this.rpc.listSkills({ sessionId: this.id });
|
|
118978
119294
|
}
|
|
118979
119295
|
/**
|
|
119296
|
+
* Inject a newly installed plugin's skills into the running session
|
|
119297
|
+
* without requiring a session restart.
|
|
119298
|
+
*/
|
|
119299
|
+
async injectPlugin(id) {
|
|
119300
|
+
this.ensureOpen();
|
|
119301
|
+
const normalized = normalizeRequiredString(id, "Plugin id cannot be empty", ErrorCodes.REQUEST_INVALID);
|
|
119302
|
+
await this.rpc.injectPlugin({
|
|
119303
|
+
sessionId: this.id,
|
|
119304
|
+
id: normalized
|
|
119305
|
+
});
|
|
119306
|
+
}
|
|
119307
|
+
/**
|
|
119308
|
+
* Delete a manually installed skill from disk and remove it from the
|
|
119309
|
+
* running session, including any bundled sub-skills.
|
|
119310
|
+
*/
|
|
119311
|
+
async removeSkill(skillName) {
|
|
119312
|
+
this.ensureOpen();
|
|
119313
|
+
const normalized = normalizeRequiredString(skillName, "Skill name cannot be empty", ErrorCodes.REQUEST_INVALID);
|
|
119314
|
+
await this.rpc.removeSkill({
|
|
119315
|
+
sessionId: this.id,
|
|
119316
|
+
skillName: normalized
|
|
119317
|
+
});
|
|
119318
|
+
}
|
|
119319
|
+
/**
|
|
118980
119320
|
* List background tasks for this session's interactive agent.
|
|
118981
119321
|
*
|
|
118982
119322
|
* Defaults to all tasks (including terminal/lost). Pass
|
|
@@ -119522,6 +119862,7 @@ const SCREAM_CODE_INPUT_HISTORY_DIR_NAME = "user-history";
|
|
|
119522
119862
|
const DEFAULT_OAUTH_PROVIDER_NAME = "managed:scream-code";
|
|
119523
119863
|
ErrorCodes.AUTH_LOGIN_REQUIRED;
|
|
119524
119864
|
const SCREAM_CODE_CDN_LATEST_URL = "https://api.github.com/repos/LIUTod/scream-code/releases/latest";
|
|
119865
|
+
const SCREAM_CODE_PLUGIN_MARKETPLACE_URL_ENV = "SCREAM_CODE_PLUGIN_MARKETPLACE_URL";
|
|
119525
119866
|
//#endregion
|
|
119526
119867
|
//#region src/migration/command.ts
|
|
119527
119868
|
function registerMigrateCommand(parent, _onMigrate) {
|
|
@@ -120620,17 +120961,21 @@ const BUILTIN_SLASH_COMMANDS = [
|
|
|
120620
120961
|
availability: "always"
|
|
120621
120962
|
},
|
|
120622
120963
|
{
|
|
120623
|
-
name: "
|
|
120624
|
-
aliases: [
|
|
120625
|
-
|
|
120626
|
-
|
|
120964
|
+
name: "skill",
|
|
120965
|
+
aliases: [
|
|
120966
|
+
"skills",
|
|
120967
|
+
"plugin",
|
|
120968
|
+
"plugins"
|
|
120969
|
+
],
|
|
120970
|
+
description: "技能中心,管理 Skill 技能,含激活、安装、卸载等",
|
|
120971
|
+
priority: 110,
|
|
120627
120972
|
availability: "always"
|
|
120628
120973
|
},
|
|
120629
120974
|
{
|
|
120630
120975
|
name: "cc",
|
|
120631
120976
|
aliases: [],
|
|
120632
120977
|
description: "操控你的cc(启动/关闭/重启)",
|
|
120633
|
-
priority:
|
|
120978
|
+
priority: 109,
|
|
120634
120979
|
availability: "always"
|
|
120635
120980
|
},
|
|
120636
120981
|
{
|
|
@@ -120805,9 +121150,10 @@ function slashBusyMessage(commandName, reason) {
|
|
|
120805
121150
|
function isUserActivatableSkill(skill) {
|
|
120806
121151
|
return skill.type === void 0 || skill.type === "prompt" || skill.type === "inline" || skill.type === "flow";
|
|
120807
121152
|
}
|
|
120808
|
-
function buildSkillSlashCommands(skills) {
|
|
121153
|
+
function buildSkillSlashCommands(skills, builtinCommandNames) {
|
|
120809
121154
|
const commandMap = /* @__PURE__ */ new Map();
|
|
120810
121155
|
const commands = [];
|
|
121156
|
+
const reservedNames = builtinCommandNames ?? /* @__PURE__ */ new Set();
|
|
120811
121157
|
for (const skill of skills) {
|
|
120812
121158
|
if (!isUserActivatableSkill(skill)) continue;
|
|
120813
121159
|
const commandName = `skill:${skill.name}`;
|
|
@@ -120817,7 +121163,7 @@ function buildSkillSlashCommands(skills) {
|
|
|
120817
121163
|
aliases: [],
|
|
120818
121164
|
description: skill.description ?? ""
|
|
120819
121165
|
});
|
|
120820
|
-
if (skill.source === "builtin") {
|
|
121166
|
+
if (skill.source === "builtin" && !reservedNames.has(skill.name)) {
|
|
120821
121167
|
commandMap.set(skill.name, skill.name);
|
|
120822
121168
|
commands.push({
|
|
120823
121169
|
name: skill.name,
|
|
@@ -121249,6 +121595,14 @@ var ChoicePickerComponent = class extends Container {
|
|
|
121249
121595
|
if (chosen !== void 0) this.opts.onSelect(chosen.value);
|
|
121250
121596
|
return;
|
|
121251
121597
|
}
|
|
121598
|
+
const chosen = this.list.selected();
|
|
121599
|
+
if (chosen?.actionKeys !== void 0 && this.list.view().query.length === 0) {
|
|
121600
|
+
const ch = printableChar(data);
|
|
121601
|
+
if (ch !== void 0 && chosen.actionKeys[ch] !== void 0) {
|
|
121602
|
+
chosen.actionKeys[ch]();
|
|
121603
|
+
return;
|
|
121604
|
+
}
|
|
121605
|
+
}
|
|
121252
121606
|
this.list.handleKey(data);
|
|
121253
121607
|
}
|
|
121254
121608
|
render(width) {
|
|
@@ -123665,6 +124019,7 @@ const BREATHE_INTERVAL_MS$1 = 40;
|
|
|
123665
124019
|
const WELCOME_TIPS = [
|
|
123666
124020
|
"/config 配置模型",
|
|
123667
124021
|
"/sessions 恢复历史会话",
|
|
124022
|
+
"/skill 打开 Skill 中心",
|
|
123668
124023
|
"/ 输入后打开快捷菜单"
|
|
123669
124024
|
];
|
|
123670
124025
|
const WELCOME_SESSION_SLOTS = 3;
|
|
@@ -127888,8 +128243,163 @@ async function activateMakeSkill(host, session, initialRequest) {
|
|
|
127888
128243
|
}
|
|
127889
128244
|
}
|
|
127890
128245
|
//#endregion
|
|
127891
|
-
//#region src/
|
|
127892
|
-
const
|
|
128246
|
+
//#region src/utils/plugin-marketplace.ts
|
|
128247
|
+
const PLUGIN_MARKETPLACE_TIERS = ["official", "curated"];
|
|
128248
|
+
async function loadPluginMarketplace(options) {
|
|
128249
|
+
const location = resolveMarketplaceLocation(options.source ?? process.env["SCREAM_CODE_PLUGIN_MARKETPLACE_URL"] ?? "https://raw.githubusercontent.com/LIUTod/scream-code/main/plugins/marketplace.json", options.workDir);
|
|
128250
|
+
return parsePluginMarketplace(await readMarketplaceText(location, options.fetchImpl ?? fetch), location);
|
|
128251
|
+
}
|
|
128252
|
+
function parsePluginMarketplace(raw, location) {
|
|
128253
|
+
let parsed;
|
|
128254
|
+
try {
|
|
128255
|
+
parsed = JSON.parse(raw);
|
|
128256
|
+
} catch (error) {
|
|
128257
|
+
throw new Error(`插件市场不是有效的 JSON: ${formatParseError(error)}`, { cause: error });
|
|
128258
|
+
}
|
|
128259
|
+
if (!isRecord$3(parsed)) throw new TypeError("插件市场必须是一个对象.");
|
|
128260
|
+
const rawPlugins = parsed["plugins"];
|
|
128261
|
+
if (!Array.isArray(rawPlugins)) throw new TypeError("插件市场必须包含 \"plugins\" 数组.");
|
|
128262
|
+
return {
|
|
128263
|
+
source: location.resolved,
|
|
128264
|
+
version: stringField$1(parsed, "version"),
|
|
128265
|
+
plugins: rawPlugins.map((entry, index) => parseMarketplaceEntry(entry, index, location))
|
|
128266
|
+
};
|
|
128267
|
+
}
|
|
128268
|
+
function resolveMarketplaceLocation(source, workDir) {
|
|
128269
|
+
const trimmed = source.trim();
|
|
128270
|
+
if (trimmed.length === 0) throw new Error(`${SCREAM_CODE_PLUGIN_MARKETPLACE_URL_ENV} 不能为空.`);
|
|
128271
|
+
if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) return {
|
|
128272
|
+
raw: trimmed,
|
|
128273
|
+
kind: "remote",
|
|
128274
|
+
resolved: trimmed
|
|
128275
|
+
};
|
|
128276
|
+
if (trimmed.startsWith("file://")) return {
|
|
128277
|
+
raw: trimmed,
|
|
128278
|
+
kind: "local",
|
|
128279
|
+
resolved: fileURLToPath(trimmed)
|
|
128280
|
+
};
|
|
128281
|
+
return {
|
|
128282
|
+
raw: trimmed,
|
|
128283
|
+
kind: "local",
|
|
128284
|
+
resolved: resolveLocalPath(trimmed, workDir)
|
|
128285
|
+
};
|
|
128286
|
+
}
|
|
128287
|
+
async function readMarketplaceText(location, fetchImpl) {
|
|
128288
|
+
if (location.kind === "local") return readFile(location.resolved, "utf8");
|
|
128289
|
+
const response = await fetchImpl(location.resolved);
|
|
128290
|
+
if (!response.ok) throw new Error(`插件市场返回 HTTP ${response.status}`);
|
|
128291
|
+
return response.text();
|
|
128292
|
+
}
|
|
128293
|
+
function parseMarketplaceEntry(value, index, location) {
|
|
128294
|
+
if (!isRecord$3(value)) throw new TypeError(`插件市场条目 ${index + 1} 必须是一个对象.`);
|
|
128295
|
+
const id = requiredString(value, "id", index);
|
|
128296
|
+
const source = stringField$1(value, "source") ?? stringField$1(value, "url") ?? stringField$1(value, "downloadUrl");
|
|
128297
|
+
if (source === void 0) throw new Error(`插件市场条目 ${id} 必须定义 "source".`);
|
|
128298
|
+
return {
|
|
128299
|
+
id,
|
|
128300
|
+
displayName: stringField$1(value, "displayName") ?? stringField$1(value, "name") ?? id,
|
|
128301
|
+
source: resolveEntrySource(source, location),
|
|
128302
|
+
tier: parseMarketplaceTier(value, id),
|
|
128303
|
+
version: stringField$1(value, "version"),
|
|
128304
|
+
description: stringField$1(value, "description") ?? stringField$1(value, "shortDescription"),
|
|
128305
|
+
homepage: stringField$1(value, "homepage") ?? stringField$1(value, "websiteURL"),
|
|
128306
|
+
keywords: stringArrayField(value, "keywords")
|
|
128307
|
+
};
|
|
128308
|
+
}
|
|
128309
|
+
function parseMarketplaceTier(value, id) {
|
|
128310
|
+
const raw = value["tier"];
|
|
128311
|
+
if (raw === void 0) return void 0;
|
|
128312
|
+
if (typeof raw !== "string") throw new TypeError(`插件市场条目 ${id} "tier" 必须是字符串.`);
|
|
128313
|
+
const tier = raw.trim();
|
|
128314
|
+
if (tier.length === 0) return void 0;
|
|
128315
|
+
if (PLUGIN_MARKETPLACE_TIERS.includes(tier)) return tier;
|
|
128316
|
+
throw new Error(`插件市场条目 ${id} "tier" 必须是以下之一: ${PLUGIN_MARKETPLACE_TIERS.join(", ")}.`);
|
|
128317
|
+
}
|
|
128318
|
+
function resolveEntrySource(source, location) {
|
|
128319
|
+
const trimmed = source.trim();
|
|
128320
|
+
if (trimmed.startsWith("http://") || trimmed.startsWith("https://") || trimmed.startsWith("~/") || trimmed === "~" || isAbsolute(trimmed)) return trimmed;
|
|
128321
|
+
if (trimmed.startsWith("file://")) return fileURLToPath(trimmed);
|
|
128322
|
+
if (location.kind === "remote") return new URL(trimmed, location.resolved).toString();
|
|
128323
|
+
return resolve(dirname$1(location.resolved), trimmed);
|
|
128324
|
+
}
|
|
128325
|
+
function resolveLocalPath(input, workDir) {
|
|
128326
|
+
if (input === "~") return homedir();
|
|
128327
|
+
if (input.startsWith("~/")) return join(homedir(), input.slice(2));
|
|
128328
|
+
return isAbsolute(input) ? input : resolve(workDir, input);
|
|
128329
|
+
}
|
|
128330
|
+
function requiredString(value, field, index) {
|
|
128331
|
+
const result = stringField$1(value, field);
|
|
128332
|
+
if (result === void 0) throw new Error(`插件市场条目 ${index + 1} 必须定义 "${field}".`);
|
|
128333
|
+
return result;
|
|
128334
|
+
}
|
|
128335
|
+
function stringField$1(value, field) {
|
|
128336
|
+
const raw = value[field];
|
|
128337
|
+
if (typeof raw !== "string") return void 0;
|
|
128338
|
+
const trimmed = raw.trim();
|
|
128339
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
128340
|
+
}
|
|
128341
|
+
function stringArrayField(value, field) {
|
|
128342
|
+
const raw = value[field];
|
|
128343
|
+
if (!Array.isArray(raw)) return void 0;
|
|
128344
|
+
const out = raw.filter((item) => typeof item === "string").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
128345
|
+
return out.length > 0 ? out : void 0;
|
|
128346
|
+
}
|
|
128347
|
+
function isRecord$3(value) {
|
|
128348
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
128349
|
+
}
|
|
128350
|
+
function formatParseError(error) {
|
|
128351
|
+
return error instanceof Error ? error.message : String(error);
|
|
128352
|
+
}
|
|
128353
|
+
//#endregion
|
|
128354
|
+
//#region src/tui/components/chrome/moon-loader.ts
|
|
128355
|
+
var MoonLoader = class extends Text {
|
|
128356
|
+
currentFrame = 0;
|
|
128357
|
+
intervalId = null;
|
|
128358
|
+
ui;
|
|
128359
|
+
frames;
|
|
128360
|
+
interval;
|
|
128361
|
+
colorFn;
|
|
128362
|
+
label;
|
|
128363
|
+
constructor(ui, style = "moon", colorFn, label = "") {
|
|
128364
|
+
super("", 1, 0);
|
|
128365
|
+
this.ui = ui;
|
|
128366
|
+
this.frames = style === "moon" ? [...MOON_SPINNER_FRAMES] : [...BRAILLE_SPINNER_FRAMES];
|
|
128367
|
+
this.interval = style === "moon" ? 120 : 80;
|
|
128368
|
+
this.colorFn = colorFn;
|
|
128369
|
+
this.label = label;
|
|
128370
|
+
this.start();
|
|
128371
|
+
}
|
|
128372
|
+
start() {
|
|
128373
|
+
this.updateDisplay();
|
|
128374
|
+
this.intervalId = setInterval(() => {
|
|
128375
|
+
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
|
128376
|
+
this.updateDisplay();
|
|
128377
|
+
}, this.interval);
|
|
128378
|
+
}
|
|
128379
|
+
stop() {
|
|
128380
|
+
if (this.intervalId) {
|
|
128381
|
+
clearInterval(this.intervalId);
|
|
128382
|
+
this.intervalId = null;
|
|
128383
|
+
}
|
|
128384
|
+
}
|
|
128385
|
+
setLabel(label) {
|
|
128386
|
+
this.label = label;
|
|
128387
|
+
this.updateDisplay();
|
|
128388
|
+
}
|
|
128389
|
+
setColorFn(colorFn) {
|
|
128390
|
+
this.colorFn = colorFn;
|
|
128391
|
+
this.updateDisplay();
|
|
128392
|
+
}
|
|
128393
|
+
updateDisplay() {
|
|
128394
|
+
const frame = this.frames[this.currentFrame];
|
|
128395
|
+
const coloredFrame = this.colorFn ? this.colorFn(frame) : frame;
|
|
128396
|
+
this.setText(this.label ? `${coloredFrame} ${this.label}` : coloredFrame);
|
|
128397
|
+
this.ui.requestRender();
|
|
128398
|
+
}
|
|
128399
|
+
};
|
|
128400
|
+
//#endregion
|
|
128401
|
+
//#region src/tui/commands/skill-marketplace.ts
|
|
128402
|
+
const FALLBACK_SKILL_MARKETPLACE = [
|
|
127893
128403
|
{
|
|
127894
128404
|
id: "gsap-skills",
|
|
127895
128405
|
displayName: "GSAP 动画技能包",
|
|
@@ -128017,89 +128527,230 @@ const BUILTIN_REGISTRY = [
|
|
|
128017
128527
|
source: "https://github.com/op7418/guizang-social-card-skill"
|
|
128018
128528
|
}
|
|
128019
128529
|
];
|
|
128020
|
-
|
|
128530
|
+
//#endregion
|
|
128531
|
+
//#region src/tui/commands/skill-center.ts
|
|
128532
|
+
const SKILL_DESC_MAX = 60;
|
|
128533
|
+
async function handleSkillCommand(host, _args) {
|
|
128021
128534
|
if (!host.session) {
|
|
128022
|
-
host.showError("
|
|
128535
|
+
host.showError("请先创建或恢复一个会话,再使用 Skill 中心。");
|
|
128023
128536
|
return;
|
|
128024
128537
|
}
|
|
128025
|
-
await
|
|
128538
|
+
await openSkillCenter(host);
|
|
128026
128539
|
}
|
|
128027
|
-
async function
|
|
128028
|
-
const
|
|
128029
|
-
|
|
128030
|
-
|
|
128540
|
+
async function openSkillCenter(host) {
|
|
128541
|
+
const loading = new SkillCenterLoadingComponent(host, "正在加载 Skill 中心…");
|
|
128542
|
+
host.mountEditorReplacement(loading);
|
|
128543
|
+
const [skillsResult, pluginsResult, marketplaceResult] = await Promise.allSettled([
|
|
128544
|
+
loadActivatableSkills(host),
|
|
128545
|
+
loadInstalledPlugins(host),
|
|
128546
|
+
loadMarketplace(host)
|
|
128547
|
+
]);
|
|
128548
|
+
loading.stop();
|
|
128549
|
+
const skills = skillsResult.status === "fulfilled" ? skillsResult.value : [];
|
|
128550
|
+
const plugins = pluginsResult.status === "fulfilled" ? pluginsResult.value : [];
|
|
128551
|
+
const marketplace = marketplaceResult.status === "fulfilled" ? marketplaceResult.value : [];
|
|
128552
|
+
if (loading.isCancelled()) return;
|
|
128553
|
+
const options = buildOptions(host, skills, plugins, marketplace);
|
|
128554
|
+
if (options.length === 0) {
|
|
128555
|
+
host.restoreEditor();
|
|
128556
|
+
host.showNotice("Skill 中心", "当前没有已安装 Skill 也没有可安装 Skill 包。");
|
|
128031
128557
|
return;
|
|
128032
128558
|
}
|
|
128033
|
-
const
|
|
128034
|
-
|
|
128035
|
-
|
|
128036
|
-
|
|
128037
|
-
|
|
128559
|
+
const picker = new ChoicePickerComponent({
|
|
128560
|
+
title: "Skill 中心",
|
|
128561
|
+
hint: "Enter 激活/安装 · d 卸载 · i 安装并注入 · Esc 返回",
|
|
128562
|
+
options,
|
|
128563
|
+
colors: host.state.theme.colors,
|
|
128564
|
+
searchable: true,
|
|
128565
|
+
pageSize: 10,
|
|
128566
|
+
onSelect: (value) => {
|
|
128567
|
+
host.restoreEditor();
|
|
128568
|
+
handleSelect(host, value, skills, plugins, marketplace);
|
|
128569
|
+
},
|
|
128570
|
+
onCancel: () => {
|
|
128571
|
+
host.restoreEditor();
|
|
128572
|
+
}
|
|
128573
|
+
});
|
|
128574
|
+
host.mountEditorReplacement(picker);
|
|
128575
|
+
}
|
|
128576
|
+
var SkillCenterLoadingComponent = class extends Container {
|
|
128577
|
+
label;
|
|
128578
|
+
focused = false;
|
|
128579
|
+
loader;
|
|
128580
|
+
host;
|
|
128581
|
+
cancelled = false;
|
|
128582
|
+
constructor(host, label) {
|
|
128583
|
+
super();
|
|
128584
|
+
this.label = label;
|
|
128585
|
+
this.host = host;
|
|
128586
|
+
const tint = (s) => chalk.hex(host.state.theme.colors.primary)(s);
|
|
128587
|
+
this.loader = new MoonLoader(host.state.ui, "braille", tint, this.label);
|
|
128588
|
+
this.addChild(new Spacer(1));
|
|
128589
|
+
this.addChild(this.loader);
|
|
128590
|
+
}
|
|
128591
|
+
handleInput(data) {
|
|
128592
|
+
if (matchesKey(data, Key.escape)) {
|
|
128593
|
+
this.cancelled = true;
|
|
128594
|
+
this.stop();
|
|
128595
|
+
this.host.restoreEditor();
|
|
128596
|
+
}
|
|
128597
|
+
}
|
|
128598
|
+
isCancelled() {
|
|
128599
|
+
return this.cancelled;
|
|
128600
|
+
}
|
|
128601
|
+
stop() {
|
|
128602
|
+
this.loader.stop();
|
|
128603
|
+
}
|
|
128604
|
+
};
|
|
128605
|
+
async function loadActivatableSkills(host) {
|
|
128606
|
+
const session = host.session;
|
|
128607
|
+
if (!session) return [];
|
|
128038
128608
|
try {
|
|
128039
|
-
|
|
128040
|
-
|
|
128041
|
-
|
|
128042
|
-
|
|
128609
|
+
return (await session.listSkills()).filter((skill) => isUserActivatableSkill(skill) && skill.source !== "builtin");
|
|
128610
|
+
} catch {
|
|
128611
|
+
return [];
|
|
128612
|
+
}
|
|
128613
|
+
}
|
|
128614
|
+
async function loadInstalledPlugins(host) {
|
|
128615
|
+
const session = host.session;
|
|
128616
|
+
if (!session) return [];
|
|
128617
|
+
try {
|
|
128618
|
+
await session.reloadPlugins().catch(() => {});
|
|
128619
|
+
return await session.listPlugins();
|
|
128620
|
+
} catch {
|
|
128621
|
+
return [];
|
|
128622
|
+
}
|
|
128623
|
+
}
|
|
128624
|
+
async function loadMarketplace(host) {
|
|
128625
|
+
try {
|
|
128626
|
+
const { plugins } = await loadPluginMarketplace({ workDir: host.state.appState.workDir });
|
|
128627
|
+
return plugins;
|
|
128628
|
+
} catch {
|
|
128629
|
+
return [...FALLBACK_SKILL_MARKETPLACE];
|
|
128630
|
+
}
|
|
128631
|
+
}
|
|
128632
|
+
function buildOptions(host, skills, plugins, marketplace) {
|
|
128633
|
+
const options = [];
|
|
128634
|
+
if (skills.length > 0) {
|
|
128635
|
+
options.push({
|
|
128636
|
+
value: "__section__installed",
|
|
128637
|
+
label: "── 已安装的 Skill ──"
|
|
128043
128638
|
});
|
|
128044
|
-
|
|
128045
|
-
|
|
128046
|
-
|
|
128047
|
-
|
|
128048
|
-
|
|
128049
|
-
|
|
128050
|
-
|
|
128051
|
-
|
|
128052
|
-
|
|
128053
|
-
|
|
128639
|
+
for (const skill of skills) {
|
|
128640
|
+
const actionKeys = {};
|
|
128641
|
+
if (skill.pluginId !== void 0) actionKeys["d"] = () => {
|
|
128642
|
+
host.restoreEditor();
|
|
128643
|
+
uninstallByPluginId(host, skill.pluginId);
|
|
128644
|
+
};
|
|
128645
|
+
else actionKeys["d"] = () => {
|
|
128646
|
+
host.restoreEditor();
|
|
128647
|
+
uninstallManualSkill(host, skill);
|
|
128648
|
+
};
|
|
128649
|
+
options.push({
|
|
128650
|
+
value: `activate:${skill.name}`,
|
|
128651
|
+
label: skill.name,
|
|
128652
|
+
description: formatSkillDescription(skill),
|
|
128653
|
+
actionKeys
|
|
128654
|
+
});
|
|
128655
|
+
}
|
|
128656
|
+
}
|
|
128657
|
+
const installedIds = new Set(plugins.map((p) => p.id));
|
|
128658
|
+
const installable = marketplace.filter((entry) => !installedIds.has(entry.id));
|
|
128659
|
+
if (installable.length > 0) {
|
|
128660
|
+
options.push({
|
|
128661
|
+
value: "__section__installable",
|
|
128662
|
+
label: "── 可安装的 Skill 包 ──"
|
|
128663
|
+
});
|
|
128664
|
+
for (const entry of installable) options.push({
|
|
128665
|
+
value: `install:${entry.source}`,
|
|
128666
|
+
label: entry.displayName,
|
|
128667
|
+
description: entry.description ? `${truncate$1(entry.description, SKILL_DESC_MAX)} [未安装]` : "[未安装]",
|
|
128668
|
+
actionKeys: { i: () => {
|
|
128669
|
+
host.restoreEditor();
|
|
128670
|
+
installInjectActivate(host, entry.source);
|
|
128671
|
+
} }
|
|
128054
128672
|
});
|
|
128055
|
-
host.showError(`安装失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
128056
|
-
} finally {
|
|
128057
|
-
for (const timer of stageTimers) clearTimeout(timer);
|
|
128058
128673
|
}
|
|
128674
|
+
return options;
|
|
128675
|
+
}
|
|
128676
|
+
async function handleSelect(host, value, skills, _plugins, _marketplace) {
|
|
128677
|
+
if (value.startsWith("__section")) {
|
|
128678
|
+
await openSkillCenter(host);
|
|
128679
|
+
return;
|
|
128680
|
+
}
|
|
128681
|
+
if (value.startsWith("activate:")) {
|
|
128682
|
+
await activateSkillByName(host, value.slice(9), skills);
|
|
128683
|
+
return;
|
|
128684
|
+
}
|
|
128685
|
+
if (value.startsWith("install:")) {
|
|
128686
|
+
await installInjectActivate(host, value.slice(8));
|
|
128687
|
+
return;
|
|
128688
|
+
}
|
|
128689
|
+
await openSkillCenter(host);
|
|
128690
|
+
}
|
|
128691
|
+
async function activateSkillByName(host, name, skills) {
|
|
128692
|
+
const session = host.session;
|
|
128693
|
+
if (!session) {
|
|
128694
|
+
host.showError("未连接到会话。请先创建或恢复一个会话。");
|
|
128695
|
+
return;
|
|
128696
|
+
}
|
|
128697
|
+
const skill = skills.find((s) => s.name === name);
|
|
128698
|
+
if (!skill) {
|
|
128699
|
+
host.showError(`未找到 Skill "${name}"。`);
|
|
128700
|
+
return;
|
|
128701
|
+
}
|
|
128702
|
+
host.sendSkillActivation(session, skill.name, "");
|
|
128059
128703
|
}
|
|
128060
|
-
async function
|
|
128704
|
+
async function installInjectActivate(host, source) {
|
|
128061
128705
|
const session = host.session;
|
|
128062
128706
|
if (!session) {
|
|
128063
128707
|
host.showError("未连接到会话。请先创建或恢复一个会话。");
|
|
128064
128708
|
return;
|
|
128065
128709
|
}
|
|
128066
|
-
const spinner = host.showProgressSpinner(
|
|
128710
|
+
const spinner = host.showProgressSpinner("正在安装 Skill 包…");
|
|
128067
128711
|
try {
|
|
128068
|
-
await session.
|
|
128712
|
+
const summary = await session.installPlugin(source);
|
|
128713
|
+
await session.injectPlugin(summary.id);
|
|
128069
128714
|
spinner.stop({
|
|
128070
128715
|
ok: true,
|
|
128071
|
-
label:
|
|
128716
|
+
label: `"${summary.displayName}" 已安装并注入当前会话。`
|
|
128072
128717
|
});
|
|
128073
|
-
|
|
128718
|
+
const pluginSkills = (await session.listSkills()).filter((s) => s.pluginId === summary.id && isUserActivatableSkill(s));
|
|
128719
|
+
if (pluginSkills.length === 0) {
|
|
128720
|
+
host.showNotice("插件已安装", `${summary.displayName} 已成功安装,但该包没有可手动激活的 Skill。`);
|
|
128721
|
+
return;
|
|
128722
|
+
}
|
|
128723
|
+
if (pluginSkills.length === 1) {
|
|
128724
|
+
const first = pluginSkills[0];
|
|
128725
|
+
host.sendSkillActivation(session, first.name, "");
|
|
128726
|
+
return;
|
|
128727
|
+
}
|
|
128728
|
+
await pickAndActivateSkill(host, pluginSkills);
|
|
128074
128729
|
} catch (error) {
|
|
128075
128730
|
spinner.stop({
|
|
128076
128731
|
ok: false,
|
|
128077
|
-
label: "
|
|
128732
|
+
label: "安装失败。"
|
|
128078
128733
|
});
|
|
128079
|
-
host.showError(
|
|
128734
|
+
host.showError(`安装失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
128080
128735
|
}
|
|
128081
128736
|
}
|
|
128082
|
-
async function
|
|
128083
|
-
const
|
|
128084
|
-
|
|
128085
|
-
const options = buildOptions(marketplace, installed);
|
|
128086
|
-
if (options.length === 0) {
|
|
128087
|
-
host.showNotice("ScreamCode 插件中心", "暂无可用插件。请检查网络或稍后重试。");
|
|
128088
|
-
return;
|
|
128089
|
-
}
|
|
128737
|
+
async function pickAndActivateSkill(host, skills) {
|
|
128738
|
+
const session = host.session;
|
|
128739
|
+
if (!session) return;
|
|
128090
128740
|
const picker = new ChoicePickerComponent({
|
|
128091
|
-
title: "
|
|
128092
|
-
hint: "Enter
|
|
128093
|
-
options
|
|
128741
|
+
title: "选择一个 Skill 激活",
|
|
128742
|
+
hint: "Enter 激活 · Esc 返回",
|
|
128743
|
+
options: skills.map((skill) => ({
|
|
128744
|
+
value: skill.name,
|
|
128745
|
+
label: skill.name,
|
|
128746
|
+
description: formatSkillDescription(skill)
|
|
128747
|
+
})),
|
|
128094
128748
|
colors: host.state.theme.colors,
|
|
128095
|
-
searchable:
|
|
128096
|
-
pageSize:
|
|
128749
|
+
searchable: true,
|
|
128750
|
+
pageSize: 8,
|
|
128097
128751
|
onSelect: (value) => {
|
|
128098
|
-
if (value.startsWith("__section")) return;
|
|
128099
128752
|
host.restoreEditor();
|
|
128100
|
-
|
|
128101
|
-
openPluginPanel(host).catch(() => {});
|
|
128102
|
-
});
|
|
128753
|
+
host.sendSkillActivation(session, value, "");
|
|
128103
128754
|
},
|
|
128104
128755
|
onCancel: () => {
|
|
128105
128756
|
host.restoreEditor();
|
|
@@ -128107,98 +128758,85 @@ async function openPluginPanel(host) {
|
|
|
128107
128758
|
});
|
|
128108
128759
|
host.mountEditorReplacement(picker);
|
|
128109
128760
|
}
|
|
128110
|
-
async function
|
|
128111
|
-
|
|
128112
|
-
|
|
128113
|
-
|
|
128114
|
-
|
|
128115
|
-
return await session.listPlugins();
|
|
128116
|
-
} catch {
|
|
128117
|
-
return [];
|
|
128761
|
+
async function uninstallByPluginId(host, pluginId) {
|
|
128762
|
+
const session = host.session;
|
|
128763
|
+
if (!session) {
|
|
128764
|
+
host.showError("未连接到会话。请先创建或恢复一个会话。");
|
|
128765
|
+
return;
|
|
128118
128766
|
}
|
|
128119
|
-
|
|
128120
|
-
/**
|
|
128121
|
-
* Normalize a GitHub URL to `{owner}/{repo}` for fuzzy matching.
|
|
128122
|
-
* Returns `null` for non-GitHub URLs (caller falls back to exact match).
|
|
128123
|
-
*/
|
|
128124
|
-
function normalizeGithubSource(url) {
|
|
128767
|
+
let plugins = [];
|
|
128125
128768
|
try {
|
|
128126
|
-
|
|
128127
|
-
|
|
128128
|
-
|
|
128129
|
-
|
|
128130
|
-
|
|
128131
|
-
|
|
128132
|
-
return null;
|
|
128769
|
+
plugins = await session.listPlugins();
|
|
128770
|
+
} catch {}
|
|
128771
|
+
const label = plugins.find((p) => p.id === pluginId)?.displayName ?? pluginId;
|
|
128772
|
+
if (!await confirmUninstall(host, label)) {
|
|
128773
|
+
await openSkillCenter(host);
|
|
128774
|
+
return;
|
|
128133
128775
|
}
|
|
128134
|
-
}
|
|
128135
|
-
|
|
128136
|
-
|
|
128137
|
-
|
|
128138
|
-
|
|
128139
|
-
|
|
128140
|
-
const norm = normalizeGithubSource(p.originalSource ?? "");
|
|
128141
|
-
return norm !== null && norm === normalizedSource;
|
|
128142
|
-
});
|
|
128143
|
-
}
|
|
128144
|
-
function buildOptions(marketplace, installed) {
|
|
128145
|
-
const options = [];
|
|
128146
|
-
const newPlugins = marketplace.filter((p) => !isInstalled(p.id, p.source, installed));
|
|
128147
|
-
if (newPlugins.length > 0) {
|
|
128148
|
-
options.push({
|
|
128149
|
-
value: "__section__marketplace",
|
|
128150
|
-
label: "── 插件市场(可安装)──",
|
|
128151
|
-
description: void 0
|
|
128776
|
+
const spinner = host.showProgressSpinner(`正在卸载 "${label}"…`);
|
|
128777
|
+
try {
|
|
128778
|
+
await session.removePlugin(pluginId);
|
|
128779
|
+
spinner.stop({
|
|
128780
|
+
ok: true,
|
|
128781
|
+
label: `"${label}" 已卸载。`
|
|
128152
128782
|
});
|
|
128153
|
-
|
|
128154
|
-
|
|
128155
|
-
|
|
128156
|
-
|
|
128783
|
+
host.showNotice("插件已卸载", "该插件的 Skill 已从当前会话中移除,无需重启会话。");
|
|
128784
|
+
} catch (error) {
|
|
128785
|
+
spinner.stop({
|
|
128786
|
+
ok: false,
|
|
128787
|
+
label: "卸载失败。"
|
|
128157
128788
|
});
|
|
128789
|
+
host.showError(`卸载失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
128790
|
+
} finally {
|
|
128791
|
+
await openSkillCenter(host);
|
|
128158
128792
|
}
|
|
128159
|
-
|
|
128160
|
-
|
|
128161
|
-
|
|
128162
|
-
|
|
128163
|
-
|
|
128793
|
+
}
|
|
128794
|
+
async function uninstallManualSkill(host, skill) {
|
|
128795
|
+
const session = host.session;
|
|
128796
|
+
if (!session) {
|
|
128797
|
+
host.showError("未连接到会话。请先创建或恢复一个会话。");
|
|
128798
|
+
return;
|
|
128799
|
+
}
|
|
128800
|
+
if (!await confirmUninstall(host, skill.name, "将删除该 Skill 的安装目录及子 Skill")) {
|
|
128801
|
+
await openSkillCenter(host);
|
|
128802
|
+
return;
|
|
128803
|
+
}
|
|
128804
|
+
const spinner = host.showProgressSpinner(`正在删除 "${skill.name}"…`);
|
|
128805
|
+
try {
|
|
128806
|
+
await session.removeSkill(skill.name);
|
|
128807
|
+
spinner.stop({
|
|
128808
|
+
ok: true,
|
|
128809
|
+
label: `"${skill.name}" 已删除。`
|
|
128164
128810
|
});
|
|
128165
|
-
|
|
128166
|
-
|
|
128167
|
-
|
|
128168
|
-
|
|
128811
|
+
host.showNotice("Skill 已删除", "该 Skill 及其子 Skill 已从当前会话中移除。");
|
|
128812
|
+
} catch (error) {
|
|
128813
|
+
spinner.stop({
|
|
128814
|
+
ok: false,
|
|
128815
|
+
label: "删除失败。"
|
|
128169
128816
|
});
|
|
128170
|
-
|
|
128171
|
-
|
|
128172
|
-
|
|
128173
|
-
label: "暂无可用插件",
|
|
128174
|
-
description: "请检查网络连接或稍后重试"
|
|
128175
|
-
});
|
|
128176
|
-
return options;
|
|
128177
|
-
}
|
|
128178
|
-
async function handlePanelAction(host, value, _marketplace, installed) {
|
|
128179
|
-
if (value.startsWith("install:")) await installAndReport(host, value.slice(8));
|
|
128180
|
-
else if (value.startsWith("uninstall:")) {
|
|
128181
|
-
const id = value.slice(10);
|
|
128182
|
-
if (await confirmUninstall(host, installed.find((p) => p.id === id)?.displayName ?? id)) await uninstallAndReport(host, id);
|
|
128817
|
+
host.showError(`删除失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
128818
|
+
} finally {
|
|
128819
|
+
await openSkillCenter(host);
|
|
128183
128820
|
}
|
|
128184
128821
|
}
|
|
128185
|
-
async function confirmUninstall(host, label) {
|
|
128822
|
+
async function confirmUninstall(host, label, description) {
|
|
128186
128823
|
return new Promise((resolve) => {
|
|
128187
128824
|
const picker = new ChoicePickerComponent({
|
|
128188
128825
|
title: `确认卸载 "${label}"?`,
|
|
128189
|
-
hint: "
|
|
128826
|
+
hint: "卸载后可在 Skill 中心重新安装",
|
|
128190
128827
|
options: [{
|
|
128191
128828
|
value: "no",
|
|
128192
128829
|
label: "取消"
|
|
128193
128830
|
}, {
|
|
128194
128831
|
value: "yes",
|
|
128195
128832
|
label: "是,卸载",
|
|
128196
|
-
tone: "danger"
|
|
128833
|
+
tone: "danger",
|
|
128834
|
+
description
|
|
128197
128835
|
}],
|
|
128198
128836
|
colors: host.state.theme.colors,
|
|
128199
|
-
onSelect: (
|
|
128837
|
+
onSelect: (value) => {
|
|
128200
128838
|
host.restoreEditor();
|
|
128201
|
-
resolve(
|
|
128839
|
+
resolve(value === "yes");
|
|
128202
128840
|
},
|
|
128203
128841
|
onCancel: () => {
|
|
128204
128842
|
host.restoreEditor();
|
|
@@ -128208,16 +128846,12 @@ async function confirmUninstall(host, label) {
|
|
|
128208
128846
|
host.mountEditorReplacement(picker);
|
|
128209
128847
|
});
|
|
128210
128848
|
}
|
|
128211
|
-
|
|
128212
|
-
const
|
|
128213
|
-
|
|
128214
|
-
|
|
128215
|
-
|
|
128216
|
-
|
|
128217
|
-
const remaining = p.skillCount - SKILLS_PREVIEW_COUNT;
|
|
128218
|
-
const descriptionParts = [`${meta} [${p.skillCount} skills]`, ...skillDescriptions];
|
|
128219
|
-
if (remaining > 0) descriptionParts.push(`…等 ${remaining} 个 skill`);
|
|
128220
|
-
return descriptionParts.join(" · ");
|
|
128849
|
+
function formatSkillDescription(skill) {
|
|
128850
|
+
const parts = [];
|
|
128851
|
+
if (skill.source) parts.push(`来源: ${skill.source}`);
|
|
128852
|
+
if (skill.pluginId !== void 0) parts.push(`插件: ${skill.pluginId}`);
|
|
128853
|
+
if (skill.description) parts.push(truncate$1(skill.description, SKILL_DESC_MAX));
|
|
128854
|
+
return parts.join(" · ");
|
|
128221
128855
|
}
|
|
128222
128856
|
function truncate$1(value, max) {
|
|
128223
128857
|
return value.length > max ? `${value.slice(0, max)}…` : value;
|
|
@@ -128508,8 +129142,8 @@ async function handleBuiltInSlashCommand(host, name, args) {
|
|
|
128508
129142
|
case "make-skill":
|
|
128509
129143
|
await handleMakeSkillCommand(host, args);
|
|
128510
129144
|
return;
|
|
128511
|
-
case "
|
|
128512
|
-
await
|
|
129145
|
+
case "skill":
|
|
129146
|
+
await handleSkillCommand(host, args);
|
|
128513
129147
|
return;
|
|
128514
129148
|
default:
|
|
128515
129149
|
host.showError(`Unknown slash command: /${String(name)}`);
|
|
@@ -129447,53 +130081,6 @@ var EditorKeyboardController = class {
|
|
|
129447
130081
|
}
|
|
129448
130082
|
};
|
|
129449
130083
|
//#endregion
|
|
129450
|
-
//#region src/tui/components/chrome/moon-loader.ts
|
|
129451
|
-
var MoonLoader = class extends Text {
|
|
129452
|
-
currentFrame = 0;
|
|
129453
|
-
intervalId = null;
|
|
129454
|
-
ui;
|
|
129455
|
-
frames;
|
|
129456
|
-
interval;
|
|
129457
|
-
colorFn;
|
|
129458
|
-
label;
|
|
129459
|
-
constructor(ui, style = "moon", colorFn, label = "") {
|
|
129460
|
-
super("", 1, 0);
|
|
129461
|
-
this.ui = ui;
|
|
129462
|
-
this.frames = style === "moon" ? [...MOON_SPINNER_FRAMES] : [...BRAILLE_SPINNER_FRAMES];
|
|
129463
|
-
this.interval = style === "moon" ? 120 : 80;
|
|
129464
|
-
this.colorFn = colorFn;
|
|
129465
|
-
this.label = label;
|
|
129466
|
-
this.start();
|
|
129467
|
-
}
|
|
129468
|
-
start() {
|
|
129469
|
-
this.updateDisplay();
|
|
129470
|
-
this.intervalId = setInterval(() => {
|
|
129471
|
-
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
|
129472
|
-
this.updateDisplay();
|
|
129473
|
-
}, this.interval);
|
|
129474
|
-
}
|
|
129475
|
-
stop() {
|
|
129476
|
-
if (this.intervalId) {
|
|
129477
|
-
clearInterval(this.intervalId);
|
|
129478
|
-
this.intervalId = null;
|
|
129479
|
-
}
|
|
129480
|
-
}
|
|
129481
|
-
setLabel(label) {
|
|
129482
|
-
this.label = label;
|
|
129483
|
-
this.updateDisplay();
|
|
129484
|
-
}
|
|
129485
|
-
setColorFn(colorFn) {
|
|
129486
|
-
this.colorFn = colorFn;
|
|
129487
|
-
this.updateDisplay();
|
|
129488
|
-
}
|
|
129489
|
-
updateDisplay() {
|
|
129490
|
-
const frame = this.frames[this.currentFrame];
|
|
129491
|
-
const coloredFrame = this.colorFn ? this.colorFn(frame) : frame;
|
|
129492
|
-
this.setText(this.label ? `${coloredFrame} ${this.label}` : coloredFrame);
|
|
129493
|
-
this.ui.requestRender();
|
|
129494
|
-
}
|
|
129495
|
-
};
|
|
129496
|
-
//#endregion
|
|
129497
130084
|
//#region src/tui/components/messages/status-message.ts
|
|
129498
130085
|
var StatusMessageComponent = class extends Container {
|
|
129499
130086
|
constructor(content, colors, color) {
|
|
@@ -135242,9 +135829,10 @@ const TOOLBAR_TIPS = [
|
|
|
135242
135829
|
},
|
|
135243
135830
|
{ text: "@: 提及文件" },
|
|
135244
135831
|
{ text: "ctrl+c: 取消" },
|
|
135245
|
-
{
|
|
135246
|
-
|
|
135247
|
-
|
|
135832
|
+
{
|
|
135833
|
+
text: "/skill: 打开 Skill 中心",
|
|
135834
|
+
priority: 2
|
|
135835
|
+
},
|
|
135248
135836
|
{ text: "/help: 显示命令" },
|
|
135249
135837
|
{
|
|
135250
135838
|
text: "/config: 选择并配置你常用的模型商",
|
|
@@ -138834,7 +139422,8 @@ var ScreamTUI = class {
|
|
|
138834
139422
|
} catch {
|
|
138835
139423
|
return;
|
|
138836
139424
|
}
|
|
138837
|
-
const
|
|
139425
|
+
const builtinNames = new Set(BUILTIN_SLASH_COMMANDS.flatMap((cmd) => [cmd.name, ...cmd.aliases]));
|
|
139426
|
+
const skillCommands = buildSkillSlashCommands(skills, builtinNames);
|
|
138838
139427
|
this.skillCommands = skillCommands.commands;
|
|
138839
139428
|
this.skillCommandMap.clear();
|
|
138840
139429
|
for (const [commandName, skillName] of skillCommands.commandMap) this.skillCommandMap.set(commandName, skillName);
|