dsh-desktop-enhance 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -362,7 +362,24 @@ interface SkillRetentionRecord {
362
362
  }
363
363
  declare function buildSkillRetentionPrompt(candidates: readonly SkillRetentionCandidate[]): string;
364
364
  declare function parseSkillRetention(text: string, candidates: readonly SkillRetentionCandidate[]): readonly string[] | null;
365
- declare function renderSkillRetentionRecord(record: SkillRetentionRecord): string;
365
+ declare function createSkillRetentionMessage(record: SkillRetentionRecord, id: string): {
366
+ id: string;
367
+ role: "user";
368
+ source: {
369
+ kind: string;
370
+ retention: {
371
+ schemaVersion: 1;
372
+ compactionId: string;
373
+ summarySeq: number;
374
+ candidates: {
375
+ name: string;
376
+ seq: number;
377
+ }[];
378
+ keep: string[];
379
+ };
380
+ };
381
+ content: readonly [];
382
+ };
366
383
  declare function readSkillRetentionRecord(message: unknown): SkillRetentionRecord | null;
367
384
  //#endregion
368
385
  //#region src/index.d.ts
@@ -491,7 +508,7 @@ export declare const __test: {
491
508
  SKILL_RETENTION_SOURCE: string;
492
509
  buildSkillRetentionPrompt: typeof buildSkillRetentionPrompt;
493
510
  parseSkillRetention: typeof parseSkillRetention;
494
- renderSkillRetentionRecord: typeof renderSkillRetentionRecord;
511
+ createSkillRetentionMessage: typeof createSkillRetentionMessage;
495
512
  readSkillRetentionRecord: typeof readSkillRetentionRecord;
496
513
  SUGGEST_PATH: string;
497
514
  SUGGEST_MODELS_PATH: string;
package/lib/index.js CHANGED
@@ -3239,21 +3239,30 @@ function parseSkillRetention(text, candidates) {
3239
3239
  const selected = new Set(names);
3240
3240
  return candidates.filter((candidate) => selected.has(candidate.name)).map((candidate) => candidate.name);
3241
3241
  }
3242
- function renderSkillRetentionRecord(record) {
3243
- const payload = JSON.stringify({
3244
- schemaVersion: 1,
3245
- compactionId: record.compactionId,
3246
- summarySeq: record.summarySeq,
3247
- candidates: record.candidates.map((candidate) => ({
3248
- name: candidate.name,
3249
- seq: candidate.seq
3250
- })),
3251
- keep: record.keep
3252
- }).replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("&", "\\u0026");
3253
- return `<${RECORD_TAG}>${payload}</${RECORD_TAG}>`;
3242
+ function createSkillRetentionMessage(record, id) {
3243
+ return {
3244
+ id,
3245
+ role: "user",
3246
+ source: {
3247
+ kind: SKILL_RETENTION_SOURCE,
3248
+ retention: {
3249
+ schemaVersion: 1,
3250
+ compactionId: record.compactionId,
3251
+ summarySeq: record.summarySeq,
3252
+ candidates: record.candidates.map((candidate) => ({
3253
+ name: candidate.name,
3254
+ seq: candidate.seq
3255
+ })),
3256
+ keep: [...record.keep]
3257
+ }
3258
+ },
3259
+ content: []
3260
+ };
3254
3261
  }
3255
3262
  function readSkillRetentionRecord(message) {
3256
- if (!isObject(message) || message.role !== "user" || !isObject(message.source) || message.source.kind !== "desktop-enhance-skill-retention" || !Array.isArray(message.content) || message.content.length !== 1) return null;
3263
+ if (!isObject(message) || message.role !== "user" || !isObject(message.source) || message.source.kind !== "desktop-enhance-skill-retention" || !Array.isArray(message.content)) return null;
3264
+ if (Object.hasOwn(message.source, "retention")) return message.content.length === 0 ? readRetentionPayload(message.source.retention) : null;
3265
+ if (message.content.length !== 1) return null;
3257
3266
  const block = message.content[0];
3258
3267
  if (!isObject(block) || !hasExactKeys(block, ["type", "text"]) || block.type !== "text" || typeof block.text !== "string") return null;
3259
3268
  const start = `<${RECORD_TAG}>`;
@@ -3265,6 +3274,9 @@ function readSkillRetentionRecord(message) {
3265
3274
  } catch {
3266
3275
  return null;
3267
3276
  }
3277
+ return readRetentionPayload(payload);
3278
+ }
3279
+ function readRetentionPayload(payload) {
3268
3280
  if (!isObject(payload) || !hasExactKeys(payload, [
3269
3281
  "schemaVersion",
3270
3282
  "compactionId",
@@ -3544,15 +3556,7 @@ function installSkillRecovery(ctx, options) {
3544
3556
  candidates,
3545
3557
  keep
3546
3558
  };
3547
- messages.push({
3548
- id: randomUUID(),
3549
- role: "user",
3550
- source: { kind: SKILL_RETENTION_SOURCE },
3551
- content: [{
3552
- type: "text",
3553
- text: renderSkillRetentionRecord(record)
3554
- }]
3555
- });
3559
+ messages.push(createSkillRetentionMessage(record, randomUUID()));
3556
3560
  projected.loads = applyRetention(projected.loads, record);
3557
3561
  }
3558
3562
  const decision = decideRecovery({
@@ -3761,7 +3765,7 @@ const __test = {
3761
3765
  SKILL_RETENTION_SOURCE,
3762
3766
  buildSkillRetentionPrompt,
3763
3767
  parseSkillRetention,
3764
- renderSkillRetentionRecord,
3768
+ createSkillRetentionMessage,
3765
3769
  readSkillRetentionRecord,
3766
3770
  SUGGEST_PATH,
3767
3771
  SUGGEST_MODELS_PATH,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-desktop-enhance",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "DSH Desktop 界面增强:页内查找(Cmd+F)、轮次编号、上下文压缩行常显、建议、每步耗时、折叠文件夹状态计数、会话信息(含上下文注入 C1 视图)、工具管理、Skill 管理、独立远程接入与手机体验。",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",