dsh-play-store-shots-wan 1.0.2 → 1.0.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/lib/index.mjs +43 -15
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { appendFile, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
1
3
|
import { isAbsolute, join, resolve } from "node:path";
|
|
2
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
4
|
import sharp from "sharp";
|
|
4
5
|
import z from "@deepseek-ai/schemastery";
|
|
5
6
|
// src/images.ts
|
|
@@ -385,6 +386,18 @@ async function generateStoreShots(options) {
|
|
|
385
386
|
}
|
|
386
387
|
// src/command.ts
|
|
387
388
|
const IMAGE_COUNT = 3;
|
|
389
|
+
/**
|
|
390
|
+
* Append one diagnostic line. Runs are long and the failing side is not always
|
|
391
|
+
* visible from the chat, so every invocation leaves a trace under `~/.dsh/logs`.
|
|
392
|
+
* Diagnostics must never break a run: any failure here is ignored.
|
|
393
|
+
*/
|
|
394
|
+
async function trace(line) {
|
|
395
|
+
try {
|
|
396
|
+
const dir = join(homedir(), ".dsh", "logs");
|
|
397
|
+
await mkdir(dir, { recursive: true });
|
|
398
|
+
await appendFile(join(dir, "play-store-shots.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${line}\n`);
|
|
399
|
+
} catch {}
|
|
400
|
+
}
|
|
388
401
|
function workspaceCwd(agent) {
|
|
389
402
|
const session = agent?.session;
|
|
390
403
|
return session?.header?.cwd ?? session?.meta?.cwd ?? process.cwd();
|
|
@@ -401,20 +414,32 @@ function createHandler(deps) {
|
|
|
401
414
|
return async function handler(invocation) {
|
|
402
415
|
const appName = invocation.rawInput.trim();
|
|
403
416
|
const images = invocation.attachments.filter((block) => block.type === "image");
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
417
|
+
await trace(`invoke app=${JSON.stringify(appName)} attachments=${invocation.attachments.length} images=${images.length}`);
|
|
418
|
+
if (invocation.attachments.length !== IMAGE_COUNT || images.length !== IMAGE_COUNT) {
|
|
419
|
+
await trace(`reject: expected ${IMAGE_COUNT} images`);
|
|
420
|
+
return {
|
|
421
|
+
kind: "error",
|
|
422
|
+
text: `需要恰好 3 张图片(${countMessage(invocation.attachments.length, images.length)})。\n请按顺序附上:1) App logo 2) 商店竖图参考 3) 商店横图参考,然后重新提交 /playstoreshots。`
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
if (!appName) {
|
|
426
|
+
await trace("reject: missing app name");
|
|
427
|
+
return {
|
|
428
|
+
kind: "error",
|
|
429
|
+
text: "缺少应用名称。用法:/playstoreshots <应用名称>,并附上 3 张图片。"
|
|
430
|
+
};
|
|
431
|
+
}
|
|
412
432
|
const settings = deps.settings();
|
|
413
|
-
if (!settings.apiKey)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
433
|
+
if (!settings.apiKey) {
|
|
434
|
+
await trace("reject: missing api key");
|
|
435
|
+
return {
|
|
436
|
+
kind: "error",
|
|
437
|
+
text: "未配置百炼 API Key。请在「插件 → Google Play 商店图」里填写,或设置环境变量 WAN_API_KEY。"
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
const started = Date.now();
|
|
417
441
|
try {
|
|
442
|
+
await trace(`start model=${settings.model} baseUrl=${settings.baseUrl}`);
|
|
418
443
|
const [logo, portrait, banner] = await Promise.all(images.map((block) => deps.readImage(block.attachment, invocation.signal)));
|
|
419
444
|
const result = await generateStoreShots({
|
|
420
445
|
appName,
|
|
@@ -427,6 +452,7 @@ function createHandler(deps) {
|
|
|
427
452
|
bannerReference: Buffer.from(banner.data),
|
|
428
453
|
signal: invocation.signal
|
|
429
454
|
});
|
|
455
|
+
await trace(`done in ${Date.now() - started}ms files=${result.files.length} dir=${result.directory}`);
|
|
430
456
|
const lines = result.files.map((file) => `- ${file.name} ${file.width}×${file.height} · ${file.headline}`);
|
|
431
457
|
return {
|
|
432
458
|
kind: "success",
|
|
@@ -438,9 +464,11 @@ function createHandler(deps) {
|
|
|
438
464
|
].join("\n")
|
|
439
465
|
};
|
|
440
466
|
} catch (caught) {
|
|
467
|
+
const message = caught instanceof WanError ? caught.message : caught.message;
|
|
468
|
+
await trace(`error after ${Date.now() - started}ms: ${message}`);
|
|
441
469
|
return {
|
|
442
470
|
kind: "error",
|
|
443
|
-
text: `生成失败:${
|
|
471
|
+
text: `生成失败:${message}`
|
|
444
472
|
};
|
|
445
473
|
}
|
|
446
474
|
};
|
|
@@ -470,7 +498,7 @@ function readSettings(config) {
|
|
|
470
498
|
}
|
|
471
499
|
// src/index.ts
|
|
472
500
|
const name = "play-store-shots";
|
|
473
|
-
const inject = ["commands"];
|
|
501
|
+
const inject = ["commands", "attachments"];
|
|
474
502
|
function apply(ctx, config) {
|
|
475
503
|
const host = ctx;
|
|
476
504
|
const handler = createHandler({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-play-store-shots-wan",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Google Play store screenshot generator for DeepSeek Harness — /playstoreshots turns an app logo plus two reference sheets into four 1080x1920 screenshots and one 1024x500 feature graphic via Bailian wan2.7-image-pro.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|