Skip to content

Commit e021d7c

Browse files
committed
refactor: ponytail audit — cut dead paths and legacy forms
- plugin: drop dead readBridgeIdentity/bridge-manifest identity (launcher is gone; nobody writes the manifest) — /version always reports protocol+source - core media-server: drop legacy single-handle commit + its guards; all callers commit image/video pairs or null - CLI: drop apply-video legacy <poster> <video> arg form - tray: drop 4 unreferenced labels - adapter-codex: move test-only MemoryHostApplier out of the production index into test/helpers (plain JS, no runtime type imports)
1 parent 63240b9 commit e021d7c

7 files changed

Lines changed: 21 additions & 118 deletions

File tree

apps/tray/start-tray.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,9 @@ $L = @{
916916
RunningTipDsh = (U "6258 76D8 5DF2 542F 52A8 3002 8BF7 5148 6253 5F00 0020 0044 0065 0065 0070 0053 0065 0065 006B 0020 0048 0061 0072 006E 0065 0073 0073 0020 7F51 9875 3002") # 托盘已启动。请先打开 DeepSeek Harness 网页。
917917
HostCodex = "Codex Desktop"
918918
HostDsh = "DeepSeek Harness"
919-
DshPhaseOne = (U "0044 0065 0065 0070 0053 0065 0065 006B 0020 0048 0061 0072 006E 0065 0073 0073 0020 7B2C 4E00 9636 6BB5 4EC5 652F 6301 56FE 7247 80CC 666F 3001 6E05 9664 548C 91CD 65B0 5E94 7528 3002") # DeepSeek Harness 第一阶段仅支持图片背景、清除和重新应用。
920-
FailedSuffix = (U "5931 8D25") # 失败
921919
MediaImage = (U "56FE 7247") # 图片
922920
MediaVideo = (U "89C6 9891") # 视频
923-
MediaClear = (U "65E0") #
924921
NoBackground = (U "6682 65E0 80CC 666F") # 暂无背景
925-
Sessions = (U "4F1A 8BDD") # 会话
926922
HotkeyFail = (U "5168 5C40 5FEB 6377 952E 6CE8 518C 5931 8D25 FF0C 4ECD 53EF 7528 6258 76D8 83DC 5355 5207 6362 6478 9C7C 6A21 5F0F 3002") # 全局快捷键注册失败,仍可用托盘菜单切换摸鱼模式。
927923
}
928924

integrations/deepseek-harness/index.mjs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,8 @@ export const bridgeProtocol = 4;
99

1010
const here = path.dirname(fileURLToPath(import.meta.url));
1111
const TOKEN_PATTERN = /^[a-f0-9]{64}$/;
12-
const REVISION_PATTERN = /^[a-f0-9]{64}$/;
1312
const MAX_BODY_BYTES = 64 * 1024;
1413

15-
async function readBridgeIdentity() {
16-
try {
17-
const manifest = JSON.parse(
18-
await fs.readFile(path.join(here, "bridge-manifest.json"), "utf8"),
19-
);
20-
if (
21-
manifest.schema === "beauticode.dsh-bridge/v1" &&
22-
manifest.protocol === bridgeProtocol &&
23-
REVISION_PATTERN.test(manifest.revision)
24-
) {
25-
return { protocol: bridgeProtocol, revision: manifest.revision };
26-
}
27-
} catch {}
28-
return { protocol: bridgeProtocol, revision: "source" };
29-
}
30-
3114
/**
3215
* Token file must be explicit too: plugin `config.tokenFile` or the shared
3316
* `BEAUTICODE_DATA_ROOT` environment variable. No LOCALAPPDATA guess — the
@@ -218,12 +201,15 @@ export function apply(ctx, config = {}) {
218201
res.writeHead(405).end();
219202
return;
220203
}
221-
const identity = await readBridgeIdentity();
222204
if (req.method === "HEAD") {
223205
res.writeHead(200, { "cache-control": "no-store" }).end();
224206
return;
225207
}
226-
sendJson(res, 200, { ok: true, ...identity });
208+
sendJson(res, 200, {
209+
ok: true,
210+
protocol: bridgeProtocol,
211+
revision: "source",
212+
});
227213
},
228214
}),
229215
ctx.webServer.register({

packages/adapter-codex/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ export {
3333
loadRendererSource,
3434
} from "./payload.js";
3535

36-
export {
37-
MemoryHostApplier,
38-
type MemoryHostOptions,
39-
} from "./memory-host.js";
40-
4136
export {
4237
CodexHostApplier,
4338
type CodexHostApplierOptions,

packages/adapter-codex/test/adapter.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
buildInjectionExpression,
1010
CodexHostApplier,
1111
isCandidatePageTarget,
12-
MemoryHostApplier,
1312
readBoundedJson,
1413
runApplyOnce,
1514
runWatch,
@@ -21,6 +20,7 @@ import {
2120
getCodexLaunchGuidance,
2221
BeautiSession,
2322
} from "../dist/index.js";
23+
import { MemoryHostApplier } from "./helpers/memory-host.js";
2424
import { startMockCdp } from "./mock-cdp.js";
2525
import http from "node:http";
2626

packages/adapter-codex/src/memory-host.ts renamed to packages/adapter-codex/test/helpers/memory-host.js

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
1-
import type {
2-
HostApplyPayload,
3-
HostApplier,
4-
VerifyExpectation,
5-
VerifyResult,
6-
} from "@beauticode/core";
7-
8-
export interface MemoryHostOptions {
9-
verifyStatus?: VerifyResult["status"];
10-
verifyReason?: string;
11-
}
12-
131
/**
142
* In-process host applier for unit tests — records payloads and exposes the
153
* last generation for assertions. Not used against a real Codex window.
164
*/
17-
export class MemoryHostApplier implements HostApplier {
18-
payloads: HostApplyPayload[] = [];
19-
verifyStatus: VerifyResult["status"];
20-
verifyReason: string;
21-
22-
constructor(opts: MemoryHostOptions = {}) {
5+
export class MemoryHostApplier {
6+
constructor(opts = {}) {
7+
this.payloads = [];
238
this.verifyStatus = opts.verifyStatus ?? "pass";
249
this.verifyReason = opts.verifyReason ?? "memory host";
2510
}
2611

27-
async apply(payload: HostApplyPayload): Promise<void> {
12+
async apply(payload) {
2813
this.payloads.push(payload);
2914
}
3015

31-
async verify(
32-
expected: VerifyExpectation,
33-
_opts: { deadlineMs: number },
34-
): Promise<VerifyResult> {
16+
async verify(expected, _opts) {
3517
const last = this.payloads[this.payloads.length - 1];
3618
if (!last) {
3719
return { status: "fail", reason: "no payload applied" };

packages/core/src/media-server.ts

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -551,29 +551,6 @@ export async function createMediaServer(
551551
};
552552
}
553553

554-
function isAssetHandle(value: unknown): value is MediaAssetHandle {
555-
if (!value || typeof value !== "object") return false;
556-
const v = value as Record<string, unknown>;
557-
return (
558-
(v.kind === "image" || v.kind === "video") &&
559-
typeof v.token === "string" &&
560-
typeof v.srcUrl === "string" &&
561-
!("image" in v && typeof v.image === "object") &&
562-
!("video" in v && typeof v.video === "object")
563-
);
564-
}
565-
566-
function isPairCommit(
567-
value: unknown,
568-
): value is {
569-
image?: MediaAssetHandle | null;
570-
video?: MediaAssetHandle | null;
571-
} {
572-
if (!value || typeof value !== "object") return false;
573-
// Pair shape is chosen when image/video keys are present (even if null).
574-
return "image" in value || "video" in value;
575-
}
576-
577554
/**
578555
* Controller that can hold poster image + video assets on one hub.
579556
*/
@@ -610,30 +587,13 @@ export class MediaServerController {
610587
* Promote staged image/video handles; close assets that are no longer needed.
611588
*/
612589
async commit(
613-
next:
614-
| {
615-
image?: MediaAssetHandle | null;
616-
video?: MediaAssetHandle | null;
617-
}
618-
| MediaAssetHandle
619-
| null,
590+
next: {
591+
image?: MediaAssetHandle | null;
592+
video?: MediaAssetHandle | null;
593+
} | null,
620594
): Promise<void> {
621-
let nextImage: MediaAssetHandle | null = null;
622-
let nextVideo: MediaAssetHandle | null = null;
623-
624-
if (next == null) {
625-
nextImage = null;
626-
nextVideo = null;
627-
} else if (isPairCommit(next)) {
628-
nextImage = next.image ?? null;
629-
nextVideo = next.video ?? null;
630-
} else if (isAssetHandle(next)) {
631-
// Legacy single-handle commit.
632-
if (next.kind === "image") nextImage = next;
633-
else nextVideo = next;
634-
} else {
635-
throw new Error("Invalid media commit payload.");
636-
}
595+
const nextImage = next?.image ?? null;
596+
const nextVideo = next?.video ?? null;
637597

638598
const prevImage = this.#image;
639599
const prevVideo = this.#video;

scripts/beauticode.mjs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -351,30 +351,14 @@ async function main() {
351351
finish(1);
352352
return;
353353
}
354-
// Dream-Skin style: video-only is enough. Optional poster as 2nd arg.
355-
// Legacy form `apply-video <image> <video.mp4>` still works when the first
356-
// arg is an image and the second is .mp4.
354+
// <video.mp4> [poster]; video-only is enough.
357355
const aPath = path.resolve(a);
358-
const bPath = b ? path.resolve(b) : null;
359356
const aIsMp4 = path.extname(aPath).toLowerCase() === ".mp4";
360-
const bIsMp4 = bPath
361-
? path.extname(bPath).toLowerCase() === ".mp4"
362-
: false;
363-
if (aIsMp4 && !bIsMp4) {
364-
input = { type: "video", videoPath: aPath };
365-
if (bPath) input.imagePath = bPath;
366-
} else if (bIsMp4) {
367-
input = {
368-
type: "video",
369-
imagePath: aPath,
370-
videoPath: bPath,
371-
};
372-
} else if (aIsMp4) {
357+
if (aIsMp4) {
373358
input = { type: "video", videoPath: aPath };
359+
if (b) input.imagePath = path.resolve(b);
374360
} else {
375-
console.error(
376-
"apply-video 需要 <video.mp4> [poster](或旧格式 <poster> <video.mp4>)。",
377-
);
361+
console.error("apply-video 需要 <video.mp4> [poster]。");
378362
finish(1);
379363
return;
380364
}

0 commit comments

Comments
 (0)