Spot it. Save it. Free, local-first Chrome extension for images, videos and prompts. Explore 2,000+ curated cases and connect your library to AI Agents via MCP. 提示词导演
JavaScript ai-artai-videochrome-extensionclaude-codecodexhiggsfieldjimenglocal-firstmcpmidjourneymoodboardprompt-engineeringprompt-libraryprompt-managerreference-libraryseedancevisual-bookmarksweb-clipper
fix(release): let installed updaters accept the hash runtime in 1.20.4
MigenAI0b93c3fa37cd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7154c2b..bcf9b4c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,11 @@# Changelog+## 1.20.4++- 修复本地版升级因哈希依赖文件被旧更新器拒绝的问题;保持插件身份和原安装目录,案例与媒体无需导出或重新导入。+- 发布包使用旧更新器支持的程序布局,保留流式文件校验和完整依赖许可。+- 发布验收加入历史更新器对最终 ZIP 的实际原位安装,以及同一浏览器资料库的案例、媒体、项目、标签和回收站保留验证。+## 1.20.3- 采集侧栏统一选图、选区、剪贴板、截图和网页补充入口,同一案例可连续追加、去重、移除和撤销。diff --git a/manifest.json b/manifest.jsonindex 4b11238..963ec3b 100644--- a/manifest.json+++ b/manifest.json@@ -1,7 +1,7 @@{"manifest_version": 3,"name": "__MSG_extensionName__",- "version": "1.20.3",+ "version": "1.20.4","key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq2m8W9ACXJTkJqPAd36sPrtzonmHhOYU34uS7c+D7DXX6ggWNMwB4xZapGFJ4ScBQJv71PeG9KfsEnhcXFZ9RoX/X3wY+57evL19hf6woNX1xxhKOe1rtx5QmzWCEYIr99TzW50k/N9U6tS9Ri+2DHKYA85ssXTC8B2yRQ5zUXhsAWZe/HDU18UFuvUKXYt3ZdIUi31c2vIlgFFBfsyKbIUMny9LlxL/smb4vJzU/+A3LwJDjjvOtS/lmQ2vHoQGjHJItO18bYI6h67fIEvmWk+HJKtO08Ca+5RLS8TYhI+K7l7S0RyDVNujyVWtvhAULot1H0BvteYL87fKu3SNywIDAQAB","homepage_url": "https://github.com/wchao6891/PromptDirector","default_locale": "zh_CN",diff --git a/package-lock.json b/package-lock.jsonindex 829effe..3ed04f9 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "prompt-case-collector",- "version": "1.20.3",+ "version": "1.20.4","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "prompt-case-collector",- "version": "1.20.3",+ "version": "1.20.4","license": "Apache-2.0","dependencies": {"@jonahschulte/rtf-toolkit": "0.5.0",diff --git a/package.json b/package.jsonindex 1fed6c6..0614ba2 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "prompt-case-collector",- "version": "1.20.3",+ "version": "1.20.4","private": false,"license": "Apache-2.0","repository": "https://github.com/wchao6891/PromptDirector",diff --git a/store/CHROME_WEB_STORE_SUBMISSION.md b/store/CHROME_WEB_STORE_SUBMISSION.mdindex a3a2be5..1aa1a0d 100644--- a/store/CHROME_WEB_STORE_SUBMISSION.md+++ b/store/CHROME_WEB_STORE_SUBMISSION.md@@ -6,7 +6,7 @@ This file is the source-of-truth worksheet for the current PromptDirector manife- Chrome Web Store item public key: stored in the source `manifest.json` for local identity verification only; `package:release` removes `key` from the upload manifest.- Expected extension ID: `iahakaahijddcjjldidbclicedibgpjm`.-- Current upload artifact: `dist/PromptDirector-1.20.3.zip`. The GitHub `FIXED-ID-DEV` artifact is for local installations only.+- Current upload artifact: `dist/PromptDirector-1.20.4.zip`. The GitHub `FIXED-ID-DEV` artifact is for local installations only.- Generate a candidate only with `npm run package:release`; the command verifies the source public key against the expected identity, then removes `key` from the Web Store upload manifest and excludes the local program installer. Record the generated ZIP size and SHA-256 from the final release assets.## Store listingdiff --git a/test/extension-package-variants.test.js b/test/extension-package-variants.test.jsindex 9e14ec2..8e93c5e 100644--- a/test/extension-package-variants.test.js+++ b/test/extension-package-variants.test.js@@ -22,3 +22,31 @@ test("store packages contain no program downloader or writer and preserve sharedassert.match(ui, /商店版由 Chrome 自动更新/);assert.equal(files[2].data, "local update controls");});++// Exercise the shipped dependency graph, not a stub with no vendor files.+test("hash runtime packages remain acceptable to installed updaters and hash streamed files correctly", async t => {+ const { readFile, readdir, mkdtemp, writeFile, rm } = await import("node:fs/promises");+ const { tmpdir } = await import("node:os");+ const { join } = await import("node:path");+ const { pathToFileURL } = await import("node:url");+ const { createHash } = await import("node:crypto");+ const { isExtensionProgramPath } = await import("../local-extension-upgrade.js");+ const names = ["blob-digest.js", "THIRD_PARTY_NOTICES.md", ...(await readdir(new URL("../vendor/noble-hashes/", import.meta.url))).map(name => `vendor/noble-hashes/${name}`)];+ const input = await Promise.all(names.map(async name => ({ name, data: await readFile(new URL(`../${name}`, import.meta.url)) })));+ for (const release of [false, true]) {+ const packaged = packageRuntimeFiles(input, { release });+ for (const file of packaged) assert.ok(isExtensionProgramPath(file.name), `Old updater rejects ${file.name}`);+ const license = input.find(file => file.name.endsWith("/LICENSE")).data.toString();+ assert.ok(packaged.find(file => file.name === "THIRD_PARTY_NOTICES.md").data.toString().includes(license));+ const dir = await mkdtemp(join(tmpdir(), "pd-packaged-hash-"));+ t.after(() => rm(dir, { recursive: true, force: true }));+ await writeFile(join(dir, "package.json"), '{"type":"module"}');+ for (const file of packaged) await writeFile(join(dir, file.name), file.data);+ const { sha256Blob } = await import(pathToFileURL(join(dir, "blob-digest.js")));+ const data = Buffer.from("案例原件 integrity ".repeat(10000));+ const blob = new Blob([data]);+ blob.arrayBuffer = () => { throw new Error("must hash through the stream"); };+ assert.equal(await sha256Blob(blob), createHash("sha256").update(data).digest("hex"));+ assert.equal(await sha256Blob(new Blob()), createHash("sha256").digest("hex"));+ }+});diff --git a/test/helpers/local-upgrade-directory.mjs b/test/helpers/local-upgrade-directory.mjsnew file mode 100644index 0000000..85d4adc--- /dev/null+++ b/test/helpers/local-upgrade-directory.mjs@@ -0,0 +1,45 @@+import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";+import { join } from "node:path";++// Real temporary disk adapter for the File System Access interface. Chrome permissions+// and native picker behavior require separate browser verification.+function missing(error) { if (error.code === "ENOENT") error.name = "NotFoundError"; return error; }+export function directory(path, fault = () => false) {+ return {+ kind: "directory", name: path.split("/").at(-1), path,+ async getDirectoryHandle(name, { create = false } = {}) {+ const next = join(path, name);+ try { if (create) await mkdir(next, { recursive: true }); await readdir(next); }+ catch (error) { throw missing(error); }+ return directory(next, fault);+ },+ async getFileHandle(name, { create = false } = {}) {+ const next = join(path, name);+ try { await readFile(next); } catch (error) { if (create && error.code === "ENOENT") await writeFile(next, ""); else throw missing(error); }+ return {+ kind: "file", name,+ async getFile() { return new Blob([await readFile(next)]); },+ async createWritable() {+ let content;+ return {+ async write(blob) { content = new Uint8Array(await blob.arrayBuffer()); },+ async close() { if (fault(next)) throw new Error("simulated disk write failure"); await writeFile(next, content); },+ async abort() {}+ };+ }+ };+ },+ async removeEntry(name, { recursive = false } = {}) { try { await rm(join(path, name), { recursive }); } catch (error) { throw missing(error); } },+ async *entries() {+ for (const entry of await readdir(path, { withFileTypes: true })) {+ yield [entry.name, entry.isDirectory() ? directory(join(path, entry.name), fault) : await this.getFileHandle(entry.name)];+ }+ }+ };+}+export function served(path) {+ return async url => {+ try { return new Response(await readFile(join(path, new URL(url).pathname))); }+ catch { return new Response("", { status: 404 }); }+ };+}diff --git a/test/local-extension-upgrade.test.js b/test/local-extension-upgrade.test.jsindex 6ce06cb..0ce06a8 100644--- a/test/local-extension-upgrade.test.js+++ b/test/local-extension-upgrade.test.js@@ -10,48 +10,8 @@ const id = await extensionIdForKey(manifest.key);const nextVersion = [...manifest.version.split(".").slice(0, -1), Number(manifest.version.split(".").at(-1)) + 1].join(".");const runtime = { id, getManifest: () => manifest, getURL: path => `chrome-extension://${id}/${path}` };-// Real temporary disk adapter for the File System Access interface. Chrome permissions-// and native picker behavior require separate browser verification.-function missing(error) { if (error.code === "ENOENT") error.name = "NotFoundError"; return error; }-function directory(path, fault = () => false) {- return {- kind: "directory", name: path.split("/").at(-1), path,- async getDirectoryHandle(name, { create = false } = {}) {- const next = join(path, name);- try { if (create) await mkdir(next, { recursive: true }); await readdir(next); }- catch (error) { throw missing(error); }- return directory(next, fault);- },- async getFileHandle(name, { create = false } = {}) {- const next = join(path, name);- try { await readFile(next); } catch (error) { if (create && error.code === "ENOENT") await writeFile(next, ""); else throw missing(error); }- return {- kind: "file", name,- async getFile() { return new Blob([await readFile(next)]); },- async createWritable() {- let content;- return {- async write(blob) { content = new Uint8Array(await blob.arrayBuffer()); },- async close() { if (fault(next)) throw new Error("simulated disk write failure"); await writeFile(next, content); },- async abort() {}- };- }- };- },- async removeEntry(name, { recursive = false } = {}) { try { await rm(join(path, name), { recursive }); } catch (error) { throw missing(error); } },- async *entries() {- for (const entry of await readdir(path, { withFileTypes: true })) {- yield [entry.name, entry.isDirectory() ? directory(join(path, entry.name), fault) : await this.getFileHandle(entry.name)];- }- }- };-}-function served(path) {- return async url => {- try { return new Response(await readFile(join(path, new URL(url).pathname))); }- catch { return new Response("", { status: 404 }); }- };-}+import { directory, served } from "./helpers/local-upgrade-directory.mjs";+async function fixture(t, fault) {const path = await mkdtemp(join(tmpdir(), "pd-upgrade-test-"));t.after(() => rm(path, { recursive: true, force: true }));diff --git a/test/release_upgrade_e2e.py b/test/release_upgrade_e2e.pyindex fc9984c..d54dccc 100644--- a/test/release_upgrade_e2e.py+++ b/test/release_upgrade_e2e.py@@ -1,6 +1,8 @@from __future__ import annotations+import jsonimport os+import subprocessimport tempfilefrom pathlib import Path@@ -114,7 +116,7 @@ def seed_previous_release(playwright: Playwright, profile: str) -> tuple[str, stdef verify_current_package(playwright: Playwright, profile: str, previous_version: str, expected_id: str, expected_media: list[dict]) -> None:- context, extension_id = open_extension(playwright, profile, CURRENT_EXTENSION_DIR)+ context, extension_id = open_extension(playwright, profile, PREVIOUS_EXTENSION_DIR)errors: list[str] = []try:assert extension_id == expected_id, (extension_id, expected_id)@@ -151,7 +153,9 @@ def verify_current_package(playwright: Playwright, profile: str, previous_versio}""")assert result["mediaProof"] == expected_media, result["mediaProof"]- assert version_tuple(result["version"]) >= version_tuple(previous_version), result+ assert version_tuple(result["version"]) > version_tuple(previous_version), result+ expected_version = json.loads(CURRENT_EXTENSION_DIR.joinpath("manifest.json").read_text())["version"]+ assert result["version"] == expected_version, resultassert result["active"] == [{"id": "upgrade:active", "title": "升级保留的案例","text": "用户正文必须跨版本保留", "customLabels": ["用户标签"]@@ -179,6 +183,12 @@ def main() -> None:with tempfile.TemporaryDirectory(prefix="promptdirector-release-profile-") as profile:with sync_playwright() as playwright:previous_version, extension_id, media = seed_previous_release(playwright, profile)+ subprocess.run([+ os.environ.get("PROMPTDIRECTOR_NODE", "node"),+ str(Path(__file__).resolve().parents[1] / "tools" / "apply-release-upgrade-fixture.mjs"),+ str(PREVIOUS_EXTENSION_DIR),+ os.environ["PROMPTDIRECTOR_CURRENT_ARCHIVE"],+ ], check=True)verify_current_package(playwright, profile, previous_version, extension_id, media)print(f"升级资料保持通过:{PREVIOUS_RELEASE_TAG} → 当前最终包")diff --git a/tools/apply-release-upgrade-fixture.mjs b/tools/apply-release-upgrade-fixture.mjsnew file mode 100644index 0000000..1a620e2--- /dev/null+++ b/tools/apply-release-upgrade-fixture.mjs@@ -0,0 +1,27 @@+import assert from "node:assert/strict";+import { readFile, writeFile, mkdir } from "node:fs/promises";+import { join } from "node:path";+import { pathToFileURL } from "node:url";+import { directory, served } from "../test/helpers/local-upgrade-directory.mjs";++// Called between launches of one disposable Chromium profile. This invokes the+// historical installer on its actual disk directory; native permission UI is separate.+const [installation, archive] = process.argv.slice(2);+if (!installation || !archive) throw new Error("Expected disposable installation directory and final ZIP");+const previous = JSON.parse(await readFile(join(installation, "manifest.json"), "utf8"));+const updater = await import(pathToFileURL(join(installation, "local-extension-upgrade.js")));+const id = await updater.extensionIdForKey(previous.key);+const runtime = { id, getManifest: () => previous, getURL: path => `chrome-extension://${id}/${path}` };+const prepared = await updater.prepareLocalUpgrade(new Blob([await readFile(archive)]), runtime);+const sentinel = "user media must stay byte-identical";+await mkdir(join(installation, "media"), { recursive: true });+await writeFile(join(installation, "media", "upgrade-fixture.bin"), sentinel);+let record;+await updater.installLocalUpgrade(directory(installation), prepared, {+ runtime, fetchFn: served(installation), saveRecord: async value => { record = value; }+});+assert.equal(record.phase, "written");+assert.equal(await readFile(join(installation, "media", "upgrade-fixture.bin"), "utf8"), sentinel);+assert.equal(await updater.verifyRunningUpgrade(record, { ...runtime, getManifest: () => prepared.manifest }, served(installation)), true);+assert.equal(await updater.verifyRecoveredUpgrade(record, runtime, served(join(installation, updater.RECOVERY_DIRECTORY))), true);+console.log(`历史更新器原位安装通过:${previous.version} → ${prepared.manifest.version}(${prepared.files.size} 个文件;恢复副本完整)`);diff --git a/tools/extension-package-variants.mjs b/tools/extension-package-variants.mjsindex 748bbf0..815e68e 100644--- a/tools/extension-package-variants.mjs+++ b/tools/extension-package-variants.mjs@@ -1,3 +1,5 @@+import { posix } from "node:path";+const storeUpdateUi = `import { t } from "./i18n.js";export async function openLocalUpgrade() {@@ -14,6 +16,7 @@ export async function finishLocalUpgrade() {`;export function packageRuntimeFiles(files, { release = false } = {}) {+ files = packageHashRuntime(files);if (!release) return files;return files.filter(file => file.name !== "local-extension-upgrade.js")@@ -21,3 +24,32 @@ export function packageRuntimeFiles(files, { release = false } = {}) {? { ...file, data: storeUpdateUi }: file);}++// Installed updaters accept root program modules, but predate this vendor directory.+// Rebase only the distribution paths; keep the audited upstream source intact.+function packageHashRuntime(files) {+ const prefix = "vendor/noble-hashes/";+ const modules = files.filter(file => file.name.startsWith(prefix) && file.name.endsWith(".js"));+ if (!modules.length) return files;+ const paths = new Map(modules.map(file => [file.name, `noble-hashes-${posix.basename(file.name)}`]));+ const license = files.find(file => file.name === `${prefix}LICENSE`);+ if (!license || !files.some(file => file.name === "THIRD_PARTY_NOTICES.md")) throw new Error("Hash runtime license is missing");+ for (const target of paths.values()) {+ if (files.some(file => file.name === target)) throw new Error(`Duplicate packaged module: ${target}`);+ }+ return files.filter(file => file !== license).map(file => {+ if (file.name === "THIRD_PARTY_NOTICES.md") {+ return { ...file, data: `${file.data.toString().replaceAll("vendor/noble-hashes/LICENSE", "the @noble/hashes license below")}\n\n### @noble/hashes license\n\n${license.data.toString()}` };+ }+ if (!file.name.endsWith(".js")) return file;+ const name = paths.get(file.name) || file.name;+ const data = file.data.toString().replace(/(\bfrom\s+["'])(\.[^"']+)(["'])/gu, (match, before, specifier, after) => {+ const dependency = posix.normalize(posix.join(posix.dirname(file.name), specifier));+ const destination = paths.get(dependency);+ if (!destination) return match;+ const relative = posix.relative(posix.dirname(name), destination);+ return `${before}${relative.startsWith(".") ? relative : `./${relative}`}${after}`;+ });+ return name === file.name && data === file.data.toString() ? file : { ...file, name, data };+ });+}diff --git a/tools/package-extension.mjs b/tools/package-extension.mjsindex 91393db..3edb68d 100644--- a/tools/package-extension.mjs+++ b/tools/package-extension.mjs@@ -6,6 +6,7 @@ import { validateChromeStoreManifest } from "./chrome-store-manifest.mjs";import { verifyPdfjsRuntime } from "./pdfjs-runtime.mjs";import { chromeStoreUploadManifest, extensionArchiveName } from "./release-identity.mjs";import { packageRuntimeFiles } from "./extension-package-variants.mjs";+import { isExtensionProgramPath } from "../local-extension-upgrade.js";const projectRoot = fileURLToPath(new URL("../", import.meta.url));const sourceManifest = JSON.parse(await readFile(join(projectRoot, "manifest.json"), "utf8"));@@ -64,6 +65,9 @@ validateChromeStoreManifest({ manifest, locales });validateManifest(manifest, files.map((file) => file.name));await mkdir(join(projectRoot, "dist"), { recursive: true });const runtimeFilesForDistribution = packageRuntimeFiles(files, { release });+for (const file of runtimeFilesForDistribution) {+ if (!isExtensionProgramPath(file.name)) throw new Error(`更新器无法接收发布文件:${file.name}`);+}const archive = await createZipBlob(runtimeFilesForDistribution);const outputPath = join(projectRoot, "dist", extensionArchiveName(sourceManifest, { release }));await writeFile(outputPath, new Uint8Array(await archive.arrayBuffer()));diff --git a/tools/run-release-upgrade-e2e.mjs b/tools/run-release-upgrade-e2e.mjsindex b9e2419..6399662 100644--- a/tools/run-release-upgrade-e2e.mjs+++ b/tools/run-release-upgrade-e2e.mjs@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";import { extensionArchiveName } from "./release-identity.mjs";import { verifyDataCompatibility } from "./check-data-compatibility.mjs";+import { compareExtensionVersions } from "../extension-update.js";const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));const python = process.env.PYTHON || "python3";@@ -14,6 +15,12 @@ const temporaryRoot = await mkdtemp(join(tmpdir(), "promptdirector-release-upgratry {const report = await verifyDataCompatibility();const manifest = JSON.parse(await readFile(join(projectRoot, "manifest.json"), "utf8"));+ let baselineTag = report.releaseBaseline.tag;+ if (compareExtensionVersions(baselineTag.replace(/^v/u, ""), manifest.version) >= 0) {+ baselineTag = execFileSync("git", ["tag", "--merged", "HEAD", "--sort=-version:refname", "--list", "v[0-9]*"], { cwd: projectRoot, encoding: "utf8" })+ .trim().split("\n").find(tag => compareExtensionVersions(tag.slice(1), manifest.version) < 0);+ if (!baselineTag) throw new Error("找不到早于当前版本的已发布升级基线");+ }const currentArchive = join(projectRoot, "dist", extensionArchiveName(manifest));const previousDirectory = join(temporaryRoot, "previous-release");const currentDirectory = join(temporaryRoot, "current-package");@@ -21,7 +28,7 @@ try {await mkdir(previousDirectory);await mkdir(currentDirectory);- execFileSync("git", ["archive", "--format=tar", report.releaseBaseline.tag, "-o", previousArchive], {+ execFileSync("git", ["archive", "--format=tar", baselineTag, "-o", previousArchive], {cwd: projectRoot,stdio: "inherit"});@@ -43,12 +50,14 @@ try {stdio: "inherit",env: {...process.env,+ PROMPTDIRECTOR_NODE: process.execPath,+ PROMPTDIRECTOR_CURRENT_ARCHIVE: currentArchive,PROMPTDIRECTOR_PREVIOUS_EXTENSION_DIR: previousDirectory,PROMPTDIRECTOR_CURRENT_EXTENSION_DIR: currentDirectory,- PROMPTDIRECTOR_PREVIOUS_RELEASE_TAG: report.releaseBaseline.tag+ PROMPTDIRECTOR_PREVIOUS_RELEASE_TAG: baselineTag}});- process.stdout.write(`升级演练通过:${report.releaseBaseline.tag} 资料 → ${manifest.version} 最终固定 ID 包\n`);+ process.stdout.write(`升级演练通过:${baselineTag} 资料 → ${manifest.version} 最终固定 ID 包\n`);} catch (error) {process.stderr.write(`升级演练失败:${error.message}\n`);process.exitCode = 1;