Compare commits

..

12 commits
1.0.21 ... main

Author SHA1 Message Date
wujunchen
6519633459 chore: bump version to 1.0.24
Change-Id: I6ada16f42f4f76781e25783493fbf6da88a640c1
2026-06-16 10:08:56 +08:00
wujunchen
2278129f03 Merge branch 'feat/robustness-onboarding-ci'
Provider/lifecycle robustness, first-run onboarding nudge, CI coverage gate, and
codex-review fixes. All gates green (typecheck, lint, obsidian strict review, 28
test files, branch coverage 100%, e2e gate).

Change-Id: Id47ba4d2bb8b6c847eb7563459d416ddfa1935f0
2026-06-16 10:08:09 +08:00
wujunchen
7986f1c308 fix: address codex review — drop false-positive fallback keywords, tighten stream-error detection
Two valid findings from an opposite-model (Codex) review of this branch:

- provider-request: drop bare `unknown`/`unrecognized` from the structured-output
  rejection keywords. They false-positive on model-name errors ("unknown model",
  "unrecognized model ID" from Ollama/Bedrock), triggering a wasted fallback
  retry. The specific feature tokens + bare `schema` still cover real structured-
  output rejections, so true-positive detection is unaffected.
- streaming: streamErrorMessage's OpenAI-style `{error:{...}}` branch now only
  treats the payload as an error when it carries a message/type, so a stray empty
  `error: {}` (or code-only object) in a normal chunk no longer aborts the stream.
  The Anthropic `{type:'error'}` branch still always signals an error.

Declined: Codex's suggestion to convert streaming's HTTP>=400 to ProviderApiError
+ add fallback — the streaming path always sends `structured:false`, so there is
no structured request to fall back from.

Tests updated/added: model-name 400s do not retry; empty/code-only error objects
do not throw.

Change-Id: I413d633c8ce7036365f97e2d8e1287c111e0902f
2026-06-16 10:05:04 +08:00
wujunchen
5f36b1218b feat: provider/lifecycle robustness, onboarding nudge, CI coverage gate
Assessment-driven batch of 10 verified, low-risk improvements. All gates green
(typecheck, biome, obsidian lint + strict review, 28 test files, branch
coverage 100%, e2e gate).

Correctness:
- provider-request: decide structured-output fallback on HTTP status via a new
  ProviderApiError (status+body) instead of pattern-matching the i18n-translated
  message — previously only en/zh matched, so fr/de/es/ja/ko users hit silent
  permanent failures when a provider rejected json_schema.
- streaming: surface in-stream provider error payloads ({type:'error'} /
  {error:{}}) by throwing, instead of swallowing them and later misreporting a
  transient overload/quota error as "non-JSON LLM output". Note: detection runs
  outside the JSON.parse try/catch so the throw is not swallowed.
- main: throwIfCancelled before cacheManager.put so a cancelled job cannot
  poison the cache.
- generation-job-manager: add cancelAll(); onunload now cancels in-flight jobs
  (aborting streaming HTTP + SIGKILL-ing CLI children), not just queued waiters.

Onboarding / UX:
- settings: DEFAULT_SETTINGS.promptLanguage 'zh' -> 'auto' so new non-Chinese
  users get source-language summaries by default (existing users unaffected).
- view/main/types: first-run "Set up AI provider" CTA in the empty state when no
  credential is configured (PluginHost.openSettings + isCredentialConfigured).
- error-ui/generation-job-manager/types: new 'network' ErrorKind with an
  actionable notice + Retry for offline/connection failures.
- i18n-strings: 4 new keys across all 7 locales (parity test enforced).

CI / docs:
- .c8rc.json + package.json: branch-coverage gate (check-coverage, branches=100,
  degenerate metrics disabled) and preserve c8's exit code in the coverage script.
- ci.yml: run coverage gate and strict obsidian review in CI.
- README: fix Obsidian version badge 1.4.0 -> 1.8.7 (matches manifest).
- e2e product-shell DOM shim: add createSpan (was missing; real Obsidian has it).

Tests: cover the status-based fallback (incl. non-English locale), in-stream
error throwing, cancelAll, and network classification.

Change-Id: Ic619098aa7cdf3dc1c444be4bb8a445550eadf55
2026-06-16 09:37:59 +08:00
wujunchen
c45f7987e3 fix: avoid stringifying locale objects
Change-Id: Ic9557acc384d5a23b3cbaaae9fea2678e9afd661
2026-05-20 13:23:56 +08:00
wujunchen
2faf1729f2 Expand i18n language support
Change-Id: I31bf34852ea46947dab186a46942839db7eaaaca
2026-05-19 13:12:11 +08:00
wujunchen
68bfed7f56 perf: eliminate per-card document rescans and redundant hashing
- anchor.ts: precompute line-offset index once; O(log n) binary-search
  offsetToLine replaces two O(n) newline-count loops. findLineForAnchor
  takes an optional lineOffsets param (backward compatible).
- cards.ts / generation.ts: build the line-offset index once per document
  and thread it through all card anchor resolutions (was N cards x ~9
  full-document O(n) passes -> 1 O(n) pass + N x O(log n)).
- anchor.ts: ASCII-whitespace charCode fast path in normalizeWithMap,
  deferring to /\s/ only for non-ASCII (exact semantics preserved).
- settings.ts: memoize generationFingerprint by settings object identity
  (WeakMap) — collapses SHA-1 + stableStringify done on every file-open.
- view.ts: remove keydown listener in onClose (lifecycle leak fix).

Verified: tsc, build, biome, all 28 tests, e2e smoke, branch coverage
100% (new anchor regression tests added). Deferred (higher risk /
test-breaking): view full-render->surgical DOM, scroll rebind guard,
cache scheduleSave timing — see notes/perf-report.md.

Change-Id: I17eef347471bb8233d48164e4453d492f301eac2
2026-05-16 00:33:51 +08:00
wujunchen
052aa13547 test: cover remaining branch gaps in cache.ts and markdown.ts
Branch coverage 27/27 -> 32/32 (100%):
- touchCacheEntry(null) and default-now path
- serializeCacheFile(falsy) -> {}
- shouldConfirmRegenerate all guard branches
- cardToPlain with undefined bullets

Change-Id: I4971f8808727c63f303ebd8c23ca599673928e84
2026-05-16 00:24:33 +08:00
wujunchen
606593e39b test: add c8 coverage harness with source-map remapping
- npm run coverage runs the full suite under c8
- Wire inline source maps into the esbuild test bundles
- Redirect bundles into repo (.test-bundles) under coverage so c8
  processes them; cleaned automatically after the run
- Fix esbuild->v8-to-istanbul source path remap (tests/coverage-sourcemap.js)
- .c8rc.json, .gitignore, dev-dep c8

Note: statement/function totals are degenerate under esbuild bundling;
branch coverage + HTML report are the reliable signals.

Change-Id: I880f5ee1e9a8e5368e27a8e274825f917d972269
2026-05-16 00:22:31 +08:00
wujunchen
de66de5b5c refactor: remove dead code and over-broad exports
- Delete unused CacheFile interface (src/types.ts)
- Demote internal-only symbols from export to module scope:
  PROMPT_VERSION, DEFAULT_CLI_TIMEOUT_MS, MIN_STREAMING_TIMEOUT_MS,
  MIN_CLI_TIMEOUT_MS (settings.ts), CliFailureReason (cli.ts),
  GenerationErrorContext (error-ui.ts), AnthropicMessagesBody/
  OpenAiChatBody/OpenAiResponsesBody/GeminiBody (provider-bodies.ts),
  BackendTestDeps (backend-test.ts)

Verified: tsc, esbuild prod build, biome, all 28 test files pass.
Change-Id: I0fc597ee51ec67d509a7f33db39fabcbdb301797
2026-05-16 00:15:10 +08:00
wujunchen
955a86e2c5 chore: bump version to 1.0.22
Change-Id: Ic89af734cc2d560485f1a2b116ac763b7765c927
2026-05-14 10:22:16 +08:00
wujunchen
9473ff8434 style: apply biome formatter to cli.test.js
Change-Id: I52932009843be1d12872066bf462e01f119ab028
2026-05-14 10:19:46 +08:00
43 changed files with 2739 additions and 93 deletions

21
.c8rc.json Normal file
View file

@ -0,0 +1,21 @@
{
"all": false,
"src": ["src"],
"include": ["src/**/*.ts", "main.ts"],
"exclude": [
"src/test-exports.ts",
"tests/**",
"scripts/**",
".e2e/**",
"**/node_modules/**"
],
"excludeAfterRemap": true,
"reporter": ["text-summary", "text", "html", "json-summary"],
"reportsDirectory": "coverage",
"tempDirectory": "coverage/.tmp",
"check-coverage": true,
"branches": 100,
"statements": 0,
"lines": 0,
"functions": 0
}

View file

@ -98,6 +98,10 @@ class FakeElement {
return this.createEl('div', options);
}
createSpan(options = {}) {
return this.createEl('span', options);
}
addEventListener(type, handler) {
if (typeof handler !== 'function') return;
if (!this._listeners.has(type)) this._listeners.set(type, []);

View file

@ -27,6 +27,12 @@ jobs:
- name: Lint (Obsidian review rules)
run: npm run lint:obsidian
- name: Lint (Obsidian strict review)
run: npm run lint:obsidian:review:all
- name: Coverage (branch threshold)
run: npm run coverage
- name: E2E gate
run: timeout 600 npm run e2e

4
.gitignore vendored
View file

@ -18,6 +18,10 @@ dist/
main.js
main.js.map
# Coverage
coverage/
.test-bundles/
# Agent state
.agent/
.claude/

View file

@ -9,7 +9,7 @@
<a href="https://github.com/fancive/obsidian-parallel-reader/releases"><img src="https://img.shields.io/github/downloads/fancive/obsidian-parallel-reader/total?style=flat-square&color=4c1" alt="Total downloads"></a>
<a href="https://github.com/fancive/obsidian-parallel-reader/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/fancive/obsidian-parallel-reader/ci.yml?style=flat-square&label=CI" alt="CI status"></a>
<a href="./LICENSE"><img src="https://img.shields.io/github/license/fancive/obsidian-parallel-reader?style=flat-square" alt="License"></a>
<img src="https://img.shields.io/badge/Obsidian-%E2%89%A5%201.4.0-7c3aed?style=flat-square&logo=obsidian&logoColor=white" alt="Obsidian 1.4+">
<img src="https://img.shields.io/badge/Obsidian-%E2%89%A5%201.8.7-7c3aed?style=flat-square&logo=obsidian&logoColor=white" alt="Obsidian 1.8.7+">
</p>
<p align="center">
@ -39,7 +39,7 @@ Inspired by [this reading workflow demo](https://www.bilibili.com/video/BV1FxoGB
- **Rich rendering** — cards render through Obsidian's `MarkdownRenderer`, so tables, bold, code, and wikilinks all work natively.
- **Card editing** — right-click any card to copy, edit, delete, or jump to source.
- **Export** — save cards as a Markdown note in your vault, or copy to clipboard.
- **Bilingual UI** — full Chinese and English support for commands, settings, and notices.
- **Multi-language UI and output** — UI supports Auto, Chinese, English, Japanese, Korean, French, German, and Spanish; generated titles, gists, and bullets can use the same fixed languages or follow the source document.
## Quick Start

View file

@ -9,7 +9,7 @@
<a href="https://github.com/fancive/obsidian-parallel-reader/releases"><img src="https://img.shields.io/github/downloads/fancive/obsidian-parallel-reader/total?style=flat-square&color=4c1" alt="累计下载"></a>
<a href="https://github.com/fancive/obsidian-parallel-reader/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/fancive/obsidian-parallel-reader/ci.yml?style=flat-square&label=CI" alt="CI 状态"></a>
<a href="./LICENSE"><img src="https://img.shields.io/github/license/fancive/obsidian-parallel-reader?style=flat-square" alt="开源协议"></a>
<img src="https://img.shields.io/badge/Obsidian-%E2%89%A5%201.4.0-7c3aed?style=flat-square&logo=obsidian&logoColor=white" alt="Obsidian 1.4+">
<img src="https://img.shields.io/badge/Obsidian-%E2%89%A5%201.8.7-7c3aed?style=flat-square&logo=obsidian&logoColor=white" alt="Obsidian 1.8.7+">
</p>
<p align="center">
@ -39,7 +39,7 @@
- **Markdown 渲染** — 通过 Obsidian 的 `MarkdownRenderer` 渲染表格、加粗、代码、wikilink 均正常显示。
- **卡片编辑** — 右键任意卡片:复制、编辑、删除、跳转原文。
- **导出** — 保存为 Vault 中的 Markdown 文件,或复制到剪贴板。
- **中英双语 UI** — 命令、设置、面板文案全部支持中文和英文
- **多语言 UI 与输出** — UI 支持 Auto、中文、英文、日文、韩文、法文、德文、西班牙文生成的 title/gist/bullets 也可选择这些固定语言,或跟随原文语言
## 快速开始

40
main.ts
View file

@ -30,7 +30,14 @@ import { translate } from './src/i18n';
import { cardsToMarkdown } from './src/markdown';
import { confirmRegenerateEditedCards } from './src/modal';
import { createRafThrottledHandler, visibleTopProbeY } from './src/scroll';
import { cacheEntryMatches, DEFAULT_SETTINGS, normalizeSettings } from './src/settings';
import {
cacheEntryMatches,
DEFAULT_SETTINGS,
getApiAuthType,
getApiKey,
isApiBackend,
normalizeSettings,
} from './src/settings';
import { ParallelReaderSettingTab } from './src/settings-tab';
import type { StreamProgress } from './src/streaming';
import type {
@ -177,7 +184,7 @@ class ParallelReaderPlugin extends Plugin {
}
onunload() {
if (this.jobs) this.jobs.cancelAllWaiters();
if (this.jobs) this.jobs.cancelAll();
this.flushSettingsSave().catch((e: unknown) => console.error('[parallel-reader] flush settings on unload', e));
this.flushCacheSave().catch((e: unknown) => console.error('[parallel-reader] flush cache on unload', e));
}
@ -555,6 +562,9 @@ class ParallelReaderPlugin extends Plugin {
}
const rawCards = sections.map((s) => ({ title: s.title, anchor: s.anchor, gist: s.gist, bullets: s.bullets }));
job.setPhase('saving');
// Check BEFORE persisting: a job cancelled during the generate→disk window must not
// poison the cache (a later force=false run would otherwise serve the cancelled output).
job.throwIfCancelled();
await this.cacheManager.put(file.path, content, rawCards, this.settings);
job.throwIfCancelled();
if (view && shouldRender) view.loadFor(file, sections, false);
@ -568,7 +578,7 @@ class ParallelReaderPlugin extends Plugin {
outcome = 'generated';
})
.catch((e: unknown) => {
this.handleGenerationError(e, file, view);
this.handleGenerationError(e, file, view, force);
if (e instanceof GenerationJobAlreadyRunningError) outcome = 'already-running';
else if (e instanceof GenerationJobCancelledError) outcome = 'cancelled';
else outcome = 'error';
@ -590,7 +600,7 @@ class ParallelReaderPlugin extends Plugin {
};
}
private handleGenerationError(e: unknown, file: TFile, view: ParallelReaderView | null) {
private handleGenerationError(e: unknown, file: TFile, view: ParallelReaderView | null, force = false) {
if (e instanceof GenerationJobAlreadyRunningError) {
new Notice(this.t('generationAlreadyRunning'));
return;
@ -608,7 +618,8 @@ class ParallelReaderPlugin extends Plugin {
{
app: this.app,
settings: this.settings,
openSettings: () => this.openPluginSettings(),
openSettings: () => this.openSettings(),
onRetry: () => void this.runForFile(file, force),
},
kind,
e,
@ -616,7 +627,7 @@ class ParallelReaderPlugin extends Plugin {
);
}
private openPluginSettings(): void {
openSettings(): void {
// Obsidian doesn't expose a typed API for opening a specific plugin tab; use the documented
// (but technically internal) setting/openTabById path with safe fallbacks.
const setting = (this.app as unknown as { setting?: { open: () => void; openTabById: (id: string) => void } })
@ -630,6 +641,23 @@ class ParallelReaderPlugin extends Plugin {
}
}
/**
* True when the active backend has a usable credential: an API key (direct or via
* env var) for API backends, or any keyless/local provider (auth type 'none').
* CLI backends authenticate out-of-band (claude/codex login), so they are treated
* as configured. Used to show a first-run setup nudge instead of a dead-end.
*/
isCredentialConfigured(): boolean {
if (!isApiBackend(this.settings.backend)) return true;
try {
if (getApiAuthType(this.settings) === 'none') return true;
return !!getApiKey(this.settings);
} catch {
// Settings resolution can throw for half-configured custom providers — treat as not configured.
return false;
}
}
async runBatchForFolder() {
if (this.activeBatch) {
new Notice(this.t('batchAlreadyRunning'));

View file

@ -1,7 +1,7 @@
{
"id": "parallel-reader",
"name": "Parallel Reader",
"version": "1.0.21",
"version": "1.0.24",
"minAppVersion": "1.8.7",
"description": "AI-powered split-view reading: source note on the left, LLM-generated summary cards on the right with scroll-sync highlighting.",
"author": "lancivez",

788
package-lock.json generated
View file

@ -11,6 +11,7 @@
"@biomejs/biome": "^2.4.13",
"@types/node": "^22.10.2",
"@typescript-eslint/parser": "^8.59.1",
"c8": "^10.1.3",
"esbuild": "^0.24.2",
"eslint": "^9.39.4",
"eslint-plugin-obsidianmd": "^0.2.9",
@ -18,6 +19,16 @@
"typescript": "^5.7.2"
}
},
"node_modules/@bcoe/v8-coverage": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz",
"integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/@biomejs/biome": {
"version": "2.4.13",
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.4.13.tgz",
@ -929,6 +940,62 @@
"url": "https://github.com/sponsors/nzakas"
}
},
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
"integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^5.1.2",
"string-width-cjs": "npm:string-width@^4.2.0",
"strip-ansi": "^7.0.1",
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
"wrap-ansi": "^8.1.0",
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@istanbuljs/schema": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz",
"integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"dev": true,
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@marijn/find-cluster-break": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
@ -975,6 +1042,17 @@
"ret": "~0.1.10"
}
},
"node_modules/@pkgjs/parseargs": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
"integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
"node": ">=14"
}
},
"node_modules/@pkgr/core": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.2.tgz",
@ -1023,6 +1101,13 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/istanbul-lib-coverage": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
"integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/json-schema": {
"version": "7.0.15",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
@ -1327,6 +1412,19 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/ansi-regex": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
"integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
@ -1559,6 +1657,40 @@
"node": "18 || 20 || >=22"
}
},
"node_modules/c8": {
"version": "10.1.3",
"resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz",
"integrity": "sha512-LvcyrOAaOnrrlMpW22n690PUvxiq4Uf9WMhQwNJ9vgagkL/ph1+D4uvjvDA5XCbykrc0sx+ay6pVi9YZ1GnhyA==",
"dev": true,
"license": "ISC",
"dependencies": {
"@bcoe/v8-coverage": "^1.0.1",
"@istanbuljs/schema": "^0.1.3",
"find-up": "^5.0.0",
"foreground-child": "^3.1.1",
"istanbul-lib-coverage": "^3.2.0",
"istanbul-lib-report": "^3.0.1",
"istanbul-reports": "^3.1.6",
"test-exclude": "^7.0.1",
"v8-to-istanbul": "^9.0.0",
"yargs": "^17.7.2",
"yargs-parser": "^21.1.1"
},
"bin": {
"c8": "bin/c8.js"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"monocart-coverage-reports": "^2"
},
"peerDependenciesMeta": {
"monocart-coverage-reports": {
"optional": true
}
}
},
"node_modules/call-bind": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz",
@ -1636,6 +1768,84 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/cliui": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.1",
"wrap-ansi": "^7.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/cliui/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/cliui/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/cliui/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cliui/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cliui/node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
@ -1663,6 +1873,13 @@
"dev": true,
"license": "MIT"
},
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"dev": true,
"license": "MIT"
},
"node_modules/crelt": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
@ -1829,6 +2046,20 @@
"node": ">= 0.4"
}
},
"node_modules/eastasianwidth": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",
"dev": true,
"license": "MIT"
},
"node_modules/emoji-regex": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
"dev": true,
"license": "MIT"
},
"node_modules/empathic": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/empathic/-/empathic-2.0.0.tgz",
@ -2071,6 +2302,16 @@
"@esbuild/win32-x64": "0.24.2"
}
},
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
@ -2927,6 +3168,23 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/foreground-child": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz",
"integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
"dev": true,
"license": "ISC",
"dependencies": {
"cross-spawn": "^7.0.6",
"signal-exit": "^4.0.1"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
@ -2978,6 +3236,16 @@
"node": ">= 0.4"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
@ -3048,6 +3316,28 @@
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
}
},
"node_modules/glob": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz",
"integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==",
"deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
"dev": true,
"license": "ISC",
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^3.1.2",
"minimatch": "^9.0.4",
"minipass": "^7.1.2",
"package-json-from-dist": "^1.0.0",
"path-scurry": "^1.11.1"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob-parent": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
@ -3061,6 +3351,39 @@
"node": ">=10.13.0"
}
},
"node_modules/glob/node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true,
"license": "MIT"
},
"node_modules/glob/node_modules/brace-expansion": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz",
"integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/glob/node_modules/minimatch": {
"version": "9.0.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.2"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/globals": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
@ -3205,6 +3528,13 @@
"node": ">= 0.4"
}
},
"node_modules/html-escaper": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
"dev": true,
"license": "MIT"
},
"node_modules/ignore": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
@ -3418,6 +3748,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/is-generator-function": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz",
@ -3653,6 +3993,45 @@
"dev": true,
"license": "ISC"
},
"node_modules/istanbul-lib-coverage": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz",
"integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=8"
}
},
"node_modules/istanbul-lib-report": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz",
"integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"istanbul-lib-coverage": "^3.0.0",
"make-dir": "^4.0.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/istanbul-reports": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz",
"integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"html-escaper": "^2.0.0",
"istanbul-lib-report": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/iterator.prototype": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.5.tgz",
@ -3671,6 +4050,22 @@
"node": ">= 0.4"
}
},
"node_modules/jackspeak": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz",
"integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/cliui": "^8.0.2"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
},
"optionalDependencies": {
"@pkgjs/parseargs": "^0.11.0"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -3885,6 +4280,29 @@
"loose-envify": "cli.js"
}
},
"node_modules/lru-cache": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
"dev": true,
"license": "ISC"
},
"node_modules/make-dir": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz",
"integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==",
"dev": true,
"license": "MIT",
"dependencies": {
"semver": "^7.5.3"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@ -3921,6 +4339,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/minipass": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
"dev": true,
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=16 || 14 >=14.17"
}
},
"node_modules/module-replacements": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/module-replacements/-/module-replacements-2.11.0.tgz",
@ -4187,6 +4615,13 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
"dev": true,
"license": "BlueOak-1.0.0"
},
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@ -4227,6 +4662,23 @@
"dev": true,
"license": "MIT"
},
"node_modules/path-scurry": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"lru-cache": "^10.2.0",
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
},
"engines": {
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/picomatch": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
@ -4343,6 +4795,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
@ -4654,6 +5116,19 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/stop-iteration-iterator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz",
@ -4668,6 +5143,70 @@
"node": ">= 0.4"
}
},
"node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
"dev": true,
"license": "MIT",
"dependencies": {
"eastasianwidth": "^0.2.0",
"emoji-regex": "^9.2.2",
"strip-ansi": "^7.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/string-width-cjs": {
"name": "string-width",
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/string-width-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/string-width-cjs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/string-width-cjs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/string.prototype.matchall": {
"version": "4.0.12",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.12.tgz",
@ -4766,6 +5305,46 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/strip-ansi": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^6.2.2"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
"node_modules/strip-ansi-cjs": {
"name": "strip-ansi",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
@ -4854,6 +5433,21 @@
"url": "https://opencollective.com/webpack"
}
},
"node_modules/test-exclude": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.2.tgz",
"integrity": "sha512-u9E6A+ZDYdp7a4WnarkXPZOx8Ilz46+kby6p1yZ8zsGTz9gYa6FIS7lj2oezzNKmtdyyJNNmmXDppga5GB7kSw==",
"dev": true,
"license": "ISC",
"dependencies": {
"@istanbuljs/schema": "^0.1.2",
"glob": "^10.4.1",
"minimatch": "^10.2.2"
},
"engines": {
"node": ">=18"
}
},
"node_modules/tinyglobby": {
"version": "0.2.16",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz",
@ -5111,6 +5705,21 @@
"punycode": "^2.1.0"
}
},
"node_modules/v8-to-istanbul": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
"integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==",
"dev": true,
"license": "ISC",
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.12",
"@types/istanbul-lib-coverage": "^2.0.1",
"convert-source-map": "^2.0.0"
},
"engines": {
"node": ">=10.12.0"
}
},
"node_modules/w3c-keyname": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
@ -5234,6 +5843,111 @@
"node": ">=0.10.0"
}
},
"node_modules/wrap-ansi": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
"integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^6.1.0",
"string-width": "^5.0.1",
"strip-ansi": "^7.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrap-ansi-cjs": {
"name": "wrap-ansi",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrap-ansi-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi-cjs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/wrap-ansi-cjs/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi-cjs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi/node_modules/ansi-styles": {
"version": "6.2.3",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
}
},
"node_modules/yaml": {
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.4.tgz",
@ -5280,6 +5994,80 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/yargs": {
"version": "17.7.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^8.0.1",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.3",
"y18n": "^5.0.5",
"yargs-parser": "^21.1.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/yargs-parser": {
"version": "21.1.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/yargs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/yargs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/yargs/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

View file

@ -7,6 +7,7 @@
"build": "node esbuild.config.mjs production",
"dev": "node esbuild.config.mjs watch",
"typecheck": "tsc --noEmit",
"coverage": "c8 node scripts/run-tests.mjs --all; status=$?; rm -rf .test-bundles; exit $status",
"lint": "biome check main.ts src/ tests/ scripts/ .e2e/scripts/",
"lint:fix": "biome check --write main.ts src/ tests/ scripts/ .e2e/scripts/",
"lint:obsidian": "eslint main.ts src/",
@ -26,6 +27,7 @@
"@biomejs/biome": "^2.4.13",
"@types/node": "^22.10.2",
"@typescript-eslint/parser": "^8.59.1",
"c8": "^10.1.3",
"esbuild": "^0.24.2",
"eslint": "^9.39.4",
"eslint-plugin-obsidianmd": "^0.2.9",

View file

@ -1,7 +1,33 @@
'use strict';
export function findLineForAnchor(content: string, anchor: string): number {
// Precompute the byte offset where each line starts (offsets[k] = start of
// line k). Built once per document so callers resolving many anchors over the
// same content avoid an O(n) newline rescan per anchor.
export function buildLineOffsets(content: string): number[] {
const offsets = [0];
for (let i = 0; i < content.length; i++) {
if (content.charCodeAt(i) === 10) offsets.push(i + 1);
}
return offsets;
}
// Largest line index whose start offset is <= charOffset, i.e. the 0-based
// line containing charOffset. Equivalent to counting '\n' before charOffset
// but O(log n) instead of O(n).
function offsetToLine(offsets: number[], charOffset: number): number {
let lo = 0;
let hi = offsets.length - 1;
while (lo < hi) {
const mid = (lo + hi + 1) >> 1;
if (offsets[mid] <= charOffset) lo = mid;
else hi = mid - 1;
}
return lo;
}
export function findLineForAnchor(content: string, anchor: string, lineOffsets?: number[]): number {
if (!anchor) return -1;
const offsets = lineOffsets ?? buildLineOffsets(content);
const normalize = (s: string) => s.replace(/\s+/g, ' ').trim();
const normalizeWithMap = (s: string) => {
const chars: string[] = [];
@ -9,7 +35,18 @@ export function findLineForAnchor(content: string, anchor: string): number {
let pendingWhitespace = false;
for (let i = 0; i < s.length; i++) {
const c = s[i];
if (/\s/.test(c)) {
const code = s.charCodeAt(i);
// ASCII whitespace fast path; defer to /\s/ only for rare non-ASCII
// code points so the exact RegExp semantics are preserved.
const isWhitespace =
code === 32 ||
code === 9 ||
code === 10 ||
code === 13 ||
code === 12 ||
code === 11 ||
(code > 127 && /\s/.test(c));
if (isWhitespace) {
pendingWhitespace = chars.length > 0;
continue;
}
@ -27,9 +64,7 @@ export function findLineForAnchor(content: string, anchor: string): number {
if (!needle) return -1;
const idx = content.indexOf(needle);
if (idx === -1) return -1;
let line = 0;
for (let i = 0; i < idx; i++) if (content[i] === '\n') line++;
return line;
return offsetToLine(offsets, idx);
};
let line = tryAt(anchor);
@ -51,7 +86,5 @@ export function findLineForAnchor(content: string, anchor: string): number {
if (normIdx === -1) return -1;
const originalIdx = normDoc.map[normIdx];
if (originalIdx == null) return -1;
let l = 0;
for (let j = 0; j < originalIdx; j++) if (content[j] === '\n') l++;
return l;
return offsetToLine(offsets, originalIdx);
}

View file

@ -14,7 +14,7 @@ const CLI_TEST_TIMEOUT_MS = 60000;
type SpawnImpl = Parameters<typeof runCli>[5];
export interface BackendTestDeps {
interface BackendTestDeps {
requestUrlImpl?: RequestUrlFunction;
spawnImpl?: SpawnImpl;
}

View file

@ -1,6 +1,6 @@
'use strict';
import { findLineForAnchor } from './anchor';
import { buildLineOffsets, findLineForAnchor } from './anchor';
import type { CardPatch, RawCard, ResolvedCard } from './types';
export function removeCardAt<T extends RawCard>(cards: T[], index: number): T[] {
@ -29,12 +29,15 @@ export function updateCardAt<T extends RawCard>(cards: T[], index: number, patch
}
export function resolveCardAnchors(content: string, rawCards: RawCard[]): ResolvedCard[] {
// Build the line-offset index once and reuse it for every card instead of
// rescanning the whole document per anchor.
const lineOffsets = buildLineOffsets(content);
const resolved: ResolvedCard[] = (rawCards || []).map((c: RawCard) => ({
title: c.title,
level: 2,
anchor: c.anchor,
gist: c.gist,
startLine: findLineForAnchor(content, c.anchor),
startLine: findLineForAnchor(content, c.anchor, lineOffsets),
bullets: c.bullets || [],
}));
resolved.sort((a, b) => {

View file

@ -52,12 +52,7 @@ export function resolveCliPath(name: string, override: string): string {
return name;
}
export type CliFailureReason =
| 'wall-timeout'
| 'exit-nonzero'
| 'streams-unavailable'
| 'spawn-failure'
| 'startup-error';
type CliFailureReason = 'wall-timeout' | 'exit-nonzero' | 'streams-unavailable' | 'spawn-failure' | 'startup-error';
export interface CliErrorDetails {
reason: CliFailureReason;

View file

@ -6,11 +6,13 @@ import { translate } from './i18n';
import type { ErrorKind, PluginSettings } from './types';
import { copyToClipboard } from './ui-helpers';
export interface GenerationErrorContext {
interface GenerationErrorContext {
app: App;
settings: PluginSettings;
/** Open the plugin settings tab (best-effort; falls back to no-op if unavailable). */
openSettings: () => void;
/** Re-run the generation that failed (used by retryable error kinds such as network). */
onRetry?: () => void;
}
interface ActionableNoticeAction {
@ -205,6 +207,17 @@ export function showGenerationError(
return;
}
if (kind === 'network') {
const actions: ActionableNoticeAction[] = [];
if (ctx.onRetry) actions.push({ label: tr('errorActionRetry'), primary: true, onClick: ctx.onRetry });
actions.push({
label: tr('errorActionCopyDetails'),
onClick: () => void copyToClipboard(message, tr('errorModalCopySuccess')),
});
showActionableNotice(tr('errorNoticeNetwork'), actions);
return;
}
if (kind === 'schema') {
showActionableNotice(tr('errorNoticeSchema'), [
{

View file

@ -189,6 +189,20 @@ export class GenerationJobManager {
if (!job) return false;
return job.cancel();
}
/**
* Cancel every in-flight job firing each job's cancel handlers, which abort the
* streaming HTTP request and SIGKILL any CLI child process and reject all queued
* waiters. Used on plugin unload so nothing keeps running after teardown. Returns
* the total number of jobs and waiters cancelled.
*/
cancelAll(): number {
let cancelled = 0;
for (const job of this.jobs.values()) {
if (job.cancel()) cancelled++;
}
return cancelled + this.cancelAllWaiters();
}
}
export function classifyGenerationError(error: unknown): ErrorKind {
@ -216,6 +230,12 @@ export function classifyGenerationError(error: unknown): ErrorKind {
if (/api key|unauthorized|401|403|认证|权限/i.test(message)) return 'auth';
if (/timeout|超时|timed out/i.test(message)) return 'timeout';
if (/429|rate limit|too many requests/i.test(message)) return 'rate-limit';
if (
/ECONNREFUSED|ENOTFOUND|ENETUNREACH|EAI_AGAIN|ECONNRESET|EHOSTUNREACH|Failed to fetch|NetworkError|net::ERR_|fetch failed/i.test(
message,
)
)
return 'network';
if (
/非 JSON|非预期输出|没有返回结果|non-JSON|unexpected output|no result|json_schema|schema|structured/i.test(message)
)

View file

@ -1,7 +1,7 @@
'use strict';
import { requestUrl } from 'obsidian';
import { findLineForAnchor } from './anchor';
import { buildLineOffsets, findLineForAnchor } from './anchor';
import { summarizeViaClaudeCode, summarizeViaCodex } from './cli';
import type { GenerationJob } from './generation-job-manager';
import { buildPrompts } from './prompt';
@ -44,12 +44,13 @@ export async function summarizeDocument(
break;
}
}
const lineOffsets = buildLineOffsets(content);
const resolved: ResolvedCard[] = cards.map((c) => ({
title: c.title,
level: 2,
anchor: c.anchor,
gist: c.gist,
startLine: findLineForAnchor(content, c.anchor),
startLine: findLineForAnchor(content, c.anchor, lineOffsets),
bullets: c.bullets,
}));
resolved.sort((a, b) => {

File diff suppressed because it is too large Load diff

View file

@ -3,14 +3,23 @@
import { STRINGS } from './i18n-strings';
import type { PluginSettings } from './types';
export { STRINGS } from './i18n-strings';
export { LOCALE_OVERRIDES, STRINGS } from './i18n-strings';
function supportedBaseLanguage(value: unknown): string | null {
if (typeof value !== 'string') {
return null;
}
const base = value.trim().toLowerCase().split(/[-_]/)[0];
return base && STRINGS[base] ? base : null;
}
export function resolveUiLanguage(settings: Pick<PluginSettings, 'uiLanguage'> | null): string {
const configured = settings?.uiLanguage;
if (configured === 'zh' || configured === 'en') return configured;
if (configured && configured !== 'auto') {
return supportedBaseLanguage(configured) || 'en';
}
const nav = typeof navigator !== 'undefined' ? navigator : null;
const language = String(nav?.language || '').toLowerCase();
return language.startsWith('zh') ? 'zh' : 'en';
return supportedBaseLanguage(nav?.language) || 'en';
}
export function translate(

View file

@ -3,21 +3,51 @@
import { DEFAULT_SETTINGS, MAX_DOC_CHARS, normalizeCardCount, PROMPT_LANGUAGES } from './settings';
import type { PluginSettings, PromptPair } from './types';
const PROMPT_LANGUAGE_INSTRUCTIONS: Record<string, string> = {
auto: 'Write title, gist, and bullets in the main language of the source document.',
zh: '用中文输出 title、gist 和 bullets。',
en: 'Write title, gist, and bullets in English.',
ja: 'Write title, gist, and bullets in Japanese.',
ko: 'Write title, gist, and bullets in Korean.',
fr: 'Write title, gist, and bullets in French.',
de: 'Write title, gist, and bullets in German.',
es: 'Write title, gist, and bullets in Spanish.',
};
const PROMPT_SCHEMA_EXAMPLES: Record<string, string> = {
zh: `{"cards":[
{"title":"U 型收益曲线","anchor":"那谁又会被 AI 所受益?整体来看,它把整个分数变成了一分到七分","gist":"AI 生产力收益呈 U 型,两端受益最大、中间层塌陷","bullets":["最高薪岗位(软件管理)通过加速既有工作受益最大","最低薪岗位(外卖员、园艺工)用 AI 开副业创造新收入","中间层科学家、律师收益最少,部分因对 prompt 精度信任不足","全体均分 5.1/742% 报告收益模糊"]}
]}`,
en: `{"cards":[
{"title":"U-shaped gains","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"AI productivity gains form a U shape, with both ends benefiting most","bullets":["Top-paid software managers benefit by accelerating existing work","Low-paid workers use AI to create new side income","Middle-layer specialists gain less because prompt precision is hard to trust","Average reported benefit is 5.1/7, with 42% describing gains as unclear"]}
]}`,
ja: `{"cards":[
{"title":"U字型の利益","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"AIによる生産性向上はU字型になり、両端の層がもっとも大きな恩恵を受ける","bullets":["高所得のソフトウェア管理職は既存業務を加速できるため大きく恩恵を受ける","低所得の労働者はAIを使って新しい副収入を作り出せる","中間層の専門職は、プロンプト精度への信頼が難しいため利益が小さい","平均利益は5.1/7で、42%が効果は不明確だと報告している"]}
]}`,
ko: `{"cards":[
{"title":"U자형 이득","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"AI 생산성 향상은 U자형을 보이며 양끝 집단이 가장 큰 혜택을 얻는다","bullets":["고소득 소프트웨어 관리자는 기존 업무를 더 빠르게 처리해 큰 이득을 얻는다","저소득 노동자는 AI로 새로운 부수입 기회를 만들 수 있다","중간층 전문가는 프롬프트 정확도를 신뢰하기 어려워 상대적으로 이득이 작다","평균 체감 이득은 5.1/7이며 42%는 효과가 불명확하다고 답했다"]}
]}`,
fr: `{"cards":[
{"title":"Gains en U","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"Les gains de productivité liés à l'AI forment une courbe en U, les deux extrémités en profitant le plus","bullets":["Les managers logiciels très rémunérés gagnent surtout en accélérant leur travail existant","Les travailleurs peu rémunérés utilisent l'AI pour créer de nouveaux revenus complémentaires","Les spécialistes intermédiaires gagnent moins, car la précision des prompts reste difficile à fiabiliser","Le bénéfice moyen déclaré est de 5,1/7, avec 42% de gains jugés peu clairs"]}
]}`,
de: `{"cards":[
{"title":"U-förmige Gewinne","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"AI-Produktivitätsgewinne bilden eine U-Form, bei der beide Enden am stärksten profitieren","bullets":["Hochbezahlte Softwaremanager profitieren, weil sie bestehende Arbeit beschleunigen","Geringverdienende nutzen AI, um neue Nebeneinnahmen zu schaffen","Spezialisten in der Mitte gewinnen weniger, weil präzise Prompts schwer zu vertrauen sind","Der gemeldete Durchschnittsnutzen liegt bei 5,1/7; 42% beschreiben die Gewinne als unklar"]}
]}`,
es: `{"cards":[
{"title":"Ganancias en forma de U","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"Las mejoras de productividad con AI forman una U: los extremos son quienes más se benefician","bullets":["Los gerentes de software mejor pagados se benefician al acelerar su trabajo existente","Los trabajadores con menores ingresos usan AI para crear nuevas fuentes de ingreso","Los especialistas intermedios ganan menos porque es difícil confiar en la precisión del prompt","El beneficio medio reportado es 5,1/7, con un 42% que describe las ganancias como poco claras"]}
]}`,
};
function usesEnglishPromptShell(language: string): boolean {
return language !== 'zh' && language !== 'auto';
}
export function promptLanguageInstruction(language: string): string {
if (language === 'en') return 'Write title, gist, and bullets in English.';
if (language === 'auto') return 'Write title, gist, and bullets in the main language of the source document.';
return '用中文输出 title、gist 和 bullets。';
return PROMPT_LANGUAGE_INSTRUCTIONS[language] || PROMPT_LANGUAGE_INSTRUCTIONS.zh;
}
export function promptSchemaExample(language: string): string {
if (language === 'en') {
return `{"cards":[
{"title":"U-shaped gains","anchor":"Who benefits from AI? Overall, it shifts the score from one to seven","gist":"AI productivity gains form a U shape, with both ends benefiting most","bullets":["Top-paid software managers benefit by accelerating existing work","Low-paid workers use AI to create new side income","Middle-layer specialists gain less because prompt precision is hard to trust","Average reported benefit is 5.1/7, with 42% describing gains as unclear"]}
]}`;
}
return `{"cards":[
{"title":"U 型收益曲线","anchor":"那谁又会被 AI 所受益?整体来看,它把整个分数变成了一分到七分","gist":"AI 生产力收益呈 U 型,两端受益最大、中间层塌陷","bullets":["最高薪岗位(软件管理)通过加速既有工作受益最大","最低薪岗位(外卖员、园艺工)用 AI 开副业创造新收入","中间层科学家、律师收益最少,部分因对 prompt 精度信任不足","全体均分 5.1/742% 报告收益模糊"]}
]}`;
return PROMPT_SCHEMA_EXAMPLES[language] || PROMPT_SCHEMA_EXAMPLES.zh;
}
export function renderPromptTemplate(template: string, vars: Record<string, string | number>): string {
@ -34,7 +64,7 @@ function defaultSystemPrompt(
schema: string,
example: string,
): string {
if (language === 'en') {
if (usesEnglishPromptShell(language)) {
return `You are a long-form reading summary assistant. After reading the full document, split it into ${minCards}-${maxCards} natural topic units. They do not need to match markdown headings; use a complete argument or topic as the unit, merging short sections and splitting long ones when needed.
Each card has one guiding sentence plus several bullets. Bullets carry details; gist is the lead-in.
@ -98,7 +128,7 @@ function systemPromptContract(
languageInstruction: string,
schema: string,
): string {
if (language === 'en') {
if (usesEnglishPromptShell(language)) {
return `Non-overridable output contract:
- Must output ${minCards}-${maxCards} cards.
- ${languageInstruction}
@ -125,7 +155,7 @@ export function buildPrompts(content: string, settings: PluginSettings): PromptP
const doc =
content.length > maxDocChars
? content.slice(0, maxDocChars) +
(promptLanguage === 'en' ? '\n\n[Document truncated]' : '\n\n[文档过长,已截断]')
(usesEnglishPromptShell(promptLanguage) ? '\n\n[Document truncated]' : '\n\n[文档过长,已截断]')
: content;
const schema = '{"cards":[{"title":"...","anchor":"...","gist":"...","bullets":["...","..."]}]}';
@ -141,6 +171,8 @@ export function buildPrompts(content: string, settings: PluginSettings): PromptP
${contract}`
: defaultSystem;
const user = promptLanguage === 'en' ? `Source document:\n\n${doc}` : `以下是需要处理的文档全文:\n\n${doc}`;
const user = usesEnglishPromptShell(promptLanguage)
? `Source document:\n\n${doc}`
: `以下是需要处理的文档全文:\n\n${doc}`;
return { system, user };
}

View file

@ -12,7 +12,7 @@ import type { PluginSettings } from './types';
/* ---------- Body type interfaces ---------- */
export interface AnthropicMessagesBody {
interface AnthropicMessagesBody {
model: string;
max_tokens: number;
system: string;
@ -22,7 +22,7 @@ export interface AnthropicMessagesBody {
stream?: boolean;
}
export interface OpenAiChatBody {
interface OpenAiChatBody {
model: string;
messages: Array<{ role: string; content: string }>;
response_format?: unknown;
@ -30,7 +30,7 @@ export interface OpenAiChatBody {
[tokenField: string]: unknown;
}
export interface OpenAiResponsesBody {
interface OpenAiResponsesBody {
model: string;
instructions: string;
input: string;
@ -46,7 +46,7 @@ interface GeminiGenerationConfig {
responseJsonSchema?: unknown;
}
export interface GeminiBody {
interface GeminiBody {
systemInstruction: { parts: Array<{ text: string }> };
contents: Array<{ role: string; parts: Array<{ text: string }> }>;
generationConfig: GeminiGenerationConfig;

View file

@ -11,6 +11,22 @@ export type RequestUrlFunction = (params: {
throw?: boolean;
}) => Promise<{ status: number; json: unknown; text: string }>;
/**
* Thrown when a provider responds with HTTP >= 400. Carries the raw status code
* and response body so callers can make locale-independent decisions (e.g. the
* structured-output fallback) instead of pattern-matching a translated message.
*/
export class ProviderApiError extends Error {
readonly status: number;
readonly body: string;
constructor(message: string, status: number, body: string) {
super(message);
this.name = 'ProviderApiError';
this.status = status;
this.body = body;
}
}
export function endpointUrl(baseUrl: string, suffixes: string[]) {
const base = baseUrl.replace(/\/+$/, '');
for (const suffix of suffixes) {
@ -65,24 +81,43 @@ export async function requestJsonBody(
}
if (resp.status >= 400) {
throw new Error(
throw new ProviderApiError(
translate(settings || null, 'errorProviderApiStatus', {
label,
status: resp.status,
excerpt: (resp.text || '').slice(0, 500),
}),
resp.status,
resp.text || '',
);
}
return responseJson(resp, label, settings);
}
// Bare `unknown`/`unrecognized` were intentionally dropped: they false-positive on
// model-name errors ("unknown model", "unrecognized model ID") and trigger a wasted
// fallback retry. The specific feature tokens + bare `schema` cover real structured-
// output rejections (e.g. "Unknown field: responseSchema" still matches `schema`).
const STRUCTURED_OUTPUT_REJECTION_KEYWORDS =
/response_format|json_schema|responseJsonSchema|responseMimeType|tools?|tool_choice|unsupported|schema/i;
const STRUCTURED_OUTPUT_FALLBACK_STATUSES = new Set([400, 404, 422]);
export function shouldRetryWithoutStructuredOutput(error: unknown): boolean {
// Preferred path: decide on the locale-independent HTTP status + raw provider body.
// The error message is i18n-translated, so matching it would only work for the two
// languages whose templates happen to contain the English/Chinese status phrasing.
if (error instanceof ProviderApiError) {
if (!STRUCTURED_OUTPUT_FALLBACK_STATUSES.has(error.status)) return false;
return (
STRUCTURED_OUTPUT_REJECTION_KEYWORDS.test(error.body) || STRUCTURED_OUTPUT_REJECTION_KEYWORDS.test(error.message)
);
}
// Fallback for errors without a status (e.g. wrapped transport failures): keep the
// legacy English/Chinese template match so existing behavior is preserved.
const message = error instanceof Error ? error.message : String(error);
if (!/(?:API (?:400|404|422):|API returned HTTP (?:400|404|422)|API 返回 HTTP (?:400|404|422))/.test(message))
return false;
return /response_format|json_schema|responseJsonSchema|responseMimeType|tools?|tool_choice|unsupported|unrecognized|unknown|schema/i.test(
message,
);
return STRUCTURED_OUTPUT_REJECTION_KEYWORDS.test(message);
}
export async function requestJsonBodyWithStructuredFallback(

View file

@ -8,21 +8,31 @@ import type { ApiFormat, ApiProviderPreset, CacheEntry, PluginSettings } from '.
export { API_PROVIDER_PRESETS } from './provider-presets';
export const MAX_DOC_CHARS = 100000;
export const PROMPT_VERSION = 2;
const PROMPT_VERSION = 2;
export const CACHE_SCHEMA_VERSION = 2;
export const DEFAULT_MAX_CACHE_ENTRIES = 100;
export const DEFAULT_CLI_TIMEOUT_MS = 300000;
export const MIN_STREAMING_TIMEOUT_MS = 1000;
export const MIN_CLI_TIMEOUT_MS = 1000;
const DEFAULT_CLI_TIMEOUT_MS = 300000;
const MIN_STREAMING_TIMEOUT_MS = 1000;
const MIN_CLI_TIMEOUT_MS = 1000;
export const PROMPT_LANGUAGES = {
auto: 'Auto-detect',
zh: '中文',
en: 'English',
auto: 'Auto-detect',
ja: '日本語',
ko: '한국어',
fr: 'Français',
de: 'Deutsch',
es: 'Español',
};
export const UI_LANGUAGES = {
auto: 'Auto',
zh: '中文',
en: 'English',
ja: '日本語',
ko: '한국어',
fr: 'Français',
de: 'Deutsch',
es: 'Español',
};
export const DEFAULT_SETTINGS: PluginSettings = {
@ -39,7 +49,10 @@ export const DEFAULT_SETTINGS: PluginSettings = {
apiMaxTokens: 4096,
maxDocChars: MAX_DOC_CHARS,
maxCacheEntries: DEFAULT_MAX_CACHE_ENTRIES,
promptLanguage: 'zh',
// 'auto' = match the source document's main language, so a new user reading an
// English (or any non-Chinese) note gets summaries in that language by default
// instead of forced Chinese. Existing users keep whatever they have persisted.
promptLanguage: 'auto',
minCards: 5,
maxCards: 15,
customSystemPrompt: '',
@ -268,7 +281,24 @@ export function pruneCacheEntries(cache: Record<string, CacheEntry>, maxEntries:
return removed;
}
// Memoize by settings object identity. The plugin replaces this.settings with
// a fresh object only on load/save, so the same reference always yields the
// same fingerprint — this collapses the SHA-1 + stableStringify work done on
// every file-open / cache check down to once per settings change.
const fingerprintCache = new WeakMap<object, string>();
export function generationFingerprint(settings: PluginSettings): string {
const cacheKey = settings as unknown as object;
if (cacheKey) {
const cached = fingerprintCache.get(cacheKey);
if (cached !== undefined) return cached;
}
const result = computeGenerationFingerprint(settings);
if (cacheKey) fingerprintCache.set(cacheKey, result);
return result;
}
function computeGenerationFingerprint(settings: PluginSettings): string {
const normalized = normalizeSettings(Object.assign({}, DEFAULT_SETTINGS, settings || {}));
const apiBackend = isApiBackend(normalized.backend);
const preset = getApiPreset(normalized);

View file

@ -26,6 +26,32 @@ function anthropicDelta(json: Record<string, unknown>): string {
return '';
}
/**
* Detect a provider error delivered as an SSE payload inside an HTTP 200 stream.
* These bypass the `response.status >= 400` guard, so without this they would be
* extracted as empty deltas and later misreported as "non-JSON LLM output".
* Anthropic: { type: 'error', error: { type, message } }
* OpenAI-compatible: { error: { message, type, code } }
* Returns a human-readable error message for an error payload, or null otherwise.
*/
export function streamErrorMessage(json: Record<string, unknown>): string | null {
const messageFromError = (value: unknown): string | null => {
if (!value || typeof value !== 'object') return null;
const err = value as { message?: unknown; type?: unknown };
if (typeof err.message === 'string' && err.message) return err.message;
if (typeof err.type === 'string' && err.type) return err.type;
return null;
};
// Anthropic: an explicit error event is an error even if its details are sparse.
if (json.type === 'error') {
return messageFromError(json.error) ?? 'Provider returned a streaming error';
}
// OpenAI-compatible: { error: { message, type, code } }. Only treat it as an error
// when it actually carries a message/type, so a stray empty `error: {}` (or a
// code-only object) in an otherwise-normal chunk does not abort the stream.
return messageFromError(json.error);
}
export type DeltaExtractor = (json: Record<string, unknown>) => string;
export function deltaExtractorForFormat(format: string): DeltaExtractor | null {
@ -61,13 +87,18 @@ export function parseSseBuffer(buffer: string, extractDelta: DeltaExtractor): {
const data = dataLines.join('\n');
if (data.trim() === '[DONE]') continue;
let json: Record<string, unknown>;
try {
const json = JSON.parse(data) as Record<string, unknown>;
const delta = extractDelta(json);
if (delta) deltas.push(delta);
json = JSON.parse(data) as Record<string, unknown>;
} catch {
// skip non-JSON SSE lines
continue; // skip non-JSON SSE lines (keep-alives, partial frames)
}
// Provider errors arrive as a 200-status SSE payload — surface them instead of
// swallowing them, so a transient overload/quota error is not misreported downstream.
const errorMessage = streamErrorMessage(json);
if (errorMessage) throw new Error(errorMessage);
const delta = extractDelta(json);
if (delta) deltas.push(delta);
}
return { deltas, rest };
}

View file

@ -1,7 +1,7 @@
'use strict';
export { default as ParallelReaderPlugin } from '../main';
export { findLineForAnchor } from './anchor';
export { buildLineOffsets, findLineForAnchor } from './anchor';
export { testBackend } from './backend-test';
export {
batchProgressVars,
@ -33,6 +33,14 @@ export { translate } from './i18n';
export { cardsToMarkdown } from './markdown';
export { activeSectionLine, nextCardIndex } from './navigation';
export { buildPrompts } from './prompt';
export {
endpointUrl,
ProviderApiError,
requestJsonBody,
requestJsonBodyWithStructuredFallback,
responseJson,
shouldRetryWithoutStructuredOutput,
} from './provider-request';
export {
buildAnthropicMessagesBody,
buildGeminiBody,
@ -58,7 +66,7 @@ export {
normalizeStreamingTimeoutMs,
pruneCacheEntries,
} from './settings';
export { deltaExtractorForFormat, parseSseBuffer } from './streaming';
export { deltaExtractorForFormat, parseSseBuffer, streamErrorMessage } from './streaming';
export { addIconButton, addTextButton, copyToClipboard } from './ui-helpers';
export { folderPathsForTarget } from './vault';
export { ParallelReaderView } from './view';

View file

@ -37,11 +37,6 @@ export interface CacheEntry {
updatedAt?: string;
}
export interface CacheFile {
version: number;
entries: Record<string, CacheEntry>;
}
/* ---------- Settings types ---------- */
export interface PluginSettings {
@ -101,7 +96,7 @@ export type GenerationPhase =
| 'done'
| 'cancelled';
export type ErrorKind = 'auth' | 'timeout' | 'rate-limit' | 'schema' | 'config' | 'cancelled' | 'unknown';
export type ErrorKind = 'auth' | 'timeout' | 'rate-limit' | 'network' | 'schema' | 'config' | 'cancelled' | 'unknown';
export interface RunForFileOptions {
rethrowErrors?: boolean;
@ -164,6 +159,10 @@ export interface PluginHost {
cache: Record<string, CacheEntry>;
manifest: PluginManifest;
t(key: string, vars?: Record<string, string | number>): string;
/** Open the plugin's settings tab (best-effort; no-op if the API is unavailable). */
openSettings(): void;
/** True if a usable credential is configured for the current backend (API key, env var, or keyless local provider). */
isCredentialConfigured(): boolean;
isGeneratingFile(file: TFile | null): boolean;
cancelGenerationForFile(file: TFile | null): boolean;
runForFile(

View file

@ -20,6 +20,8 @@ export class ParallelReaderView extends ItemView {
stale = false;
loadingMessage = '';
errorMessage = '';
private keydownHandler: ((e: KeyboardEvent) => void) | null = null;
private keydownTarget: Element | null = null;
constructor(leaf: WorkspaceLeaf, plugin: PluginHost) {
super(leaf);
@ -45,13 +47,20 @@ export class ParallelReaderView extends ItemView {
container.empty();
container.addClass('parallel-reader-container');
container.setAttr('tabindex', '0');
container.addEventListener('keydown', (e) => this.handleKeydown(e as KeyboardEvent));
this.keydownHandler = (e) => this.handleKeydown(e);
this.keydownTarget = container;
container.addEventListener('keydown', this.keydownHandler as EventListener);
this.renderEmpty();
this.focusSummaryPane();
return Promise.resolve();
}
onClose() {
if (this.keydownHandler && this.keydownTarget) {
this.keydownTarget.removeEventListener('keydown', this.keydownHandler as EventListener);
}
this.keydownHandler = null;
this.keydownTarget = null;
return Promise.resolve();
}
@ -67,6 +76,18 @@ export class ParallelReaderView extends ItemView {
hint.createEl('h3', { text: this.plugin.t('appTitle') });
hint.createEl('p', { text: this.plugin.t('emptyOpenNote') });
hint.createEl('code', { text: this.plugin.t('commandGenerate') });
this.appendSetupNudge(hint);
}
/**
* When no credential is configured, append a "set up your AI provider" call-to-action
* so a first-run user does not hit a dead-end (Generate immediate API-key error).
*/
private appendSetupNudge(parent: HTMLElement): boolean {
if (this.plugin.isCredentialConfigured()) return false;
parent.createEl('p', { cls: 'parallel-reader-setup-hint', text: this.plugin.t('emptyNeedsSetup') });
addTextButton(parent, 'settings', this.plugin.t('actionSetupProvider'), () => this.plugin.openSettings());
return true;
}
focusSummaryPane() {
@ -148,6 +169,7 @@ export class ParallelReaderView extends ItemView {
hint.createEl('h3', { text: file.basename });
hint.createEl('p', { text: this.plugin.t('emptyNoCache') });
hint.createEl('code', { text: this.plugin.t('commandGenerate') });
this.appendSetupNudge(hint);
addTextButton(hint, null, this.plugin.t('actionGenerate'), () => {
if (this.plugin.isGeneratingFile(file)) return;
void this.plugin.runForFile(file, false);

View file

@ -22,4 +22,22 @@ assert.strictEqual(
'unicode anchor match',
);
// ── perf: precomputed line-offset index must yield identical results ──
const doc = 'l0\nl1\nl2 needle here\nl3\n\nl5 tail';
const offsets = t.buildLineOffsets(doc);
assert.deepStrictEqual(offsets, [0, 3, 6, 21, 24, 25], 'buildLineOffsets marks each line start');
assert.strictEqual(
t.findLineForAnchor(doc, 'needle here', offsets),
t.findLineForAnchor(doc, 'needle here'),
'threaded offsets match self-computed result (exact path)',
);
assert.strictEqual(t.findLineForAnchor(doc, 'tail', offsets), 5, 'threaded offsets resolve trailing line');
// Non-ASCII whitespace (NBSP  ) must still normalize like /\s/ did.
assert.strictEqual(
t.findLineForAnchor('x\ny\nAlpha  beta gamma\nz', 'Alpha beta gamma'),
2,
'NBSP collapses to single space in normalized fallback match',
);
assert.strictEqual(t.buildLineOffsets('')[0], 0, 'empty content still has line 0');
console.log('anchor tests passed');

View file

@ -263,10 +263,7 @@ async function testClaudeCodeArgs() {
'stream-json',
'claude output should stream JSON events',
);
assert.ok(
capturedArgs.includes('--verbose'),
'stream-json requires --verbose in Claude CLI 2.1.131+',
);
assert.ok(capturedArgs.includes('--verbose'), 'stream-json requires --verbose in Claude CLI 2.1.131+');
assert.ok(capturedArgs.includes('--append-system-prompt'), 'should include --append-system-prompt');
assert.ok(capturedArgs.includes('--tools'), 'should explicitly restrict Claude tools');
assert.strictEqual(capturedArgs[capturedArgs.indexOf('--tools') + 1], '', 'Claude tools should be disabled');

View file

@ -0,0 +1,42 @@
'use strict';
// esbuild emits inline source maps whose `sources` are relative to the bundle
// file (deep under .test-bundles/) with a `sourceRoot`. v8-to-istanbul / the
// source-map library resolve those inconsistently and produce wrong paths like
// `/Users/.../github.com/src/batch.ts`, so c8 finds nothing to report.
//
// This rewrites the inline map in-place so every `source` is an absolute path
// to the real repo file and `sourceRoot` is cleared — making the remap exact.
// No-op when coverage is not active.
const fs = require('fs');
const path = require('path');
const MARKER = '//# sourceMappingURL=data:application/json;base64,';
function fixInlineSourceMap(outfile, repoRoot) {
if (!process.env.NODE_V8_COVERAGE) return;
const code = fs.readFileSync(outfile, 'utf8');
const idx = code.lastIndexOf(MARKER);
if (idx === -1) return;
const b64 = code.slice(idx + MARKER.length).trim();
const map = JSON.parse(Buffer.from(b64, 'base64').toString('utf8'));
// esbuild keeps `sources` relative to the bundle file's directory regardless
// of `sourceRoot`; resolving against sourceRoot double-counts and corrupts
// the path. Always resolve against the bundle directory.
const base = path.dirname(outfile);
map.sources = map.sources.map((src) => {
if (src.startsWith('stub:') || src.includes('obsidian-stub')) return src;
const abs = path.resolve(base, src);
// Strip any leftover climbing artifacts; keep the real repo path.
const i = abs.indexOf(repoRoot);
return i === -1 ? abs : abs.slice(i);
});
delete map.sourceRoot;
const fixed = Buffer.from(JSON.stringify(map), 'utf8').toString('base64');
fs.writeFileSync(outfile, code.slice(0, idx) + MARKER + fixed);
}
module.exports = { fixInlineSourceMap };

View file

@ -35,6 +35,31 @@ function createFakeAdapter() {
assert.strictEqual(cacheEntry.lastAccessedAt, undefined, 'direct cache import keeps cache entries immutable');
assert.strictEqual(JSON.parse(cache.serializeCacheFile({ 'a.md': { cards: [] } })).version, 1);
// touchCacheEntry: null entry short-circuits to null
assert.strictEqual(cache.touchCacheEntry(null), null, 'touchCacheEntry returns null for null entry');
// touchCacheEntry: omitted `now` falls back to a generated ISO timestamp
const touchedDefault = cache.touchCacheEntry({ generatedAt: '2024-01-01T00:00:00.000Z' });
assert.ok(
/^\d{4}-\d{2}-\d{2}T/.test(touchedDefault.lastAccessedAt),
'touchCacheEntry defaults lastAccessedAt to current ISO time',
);
// serializeCacheFile: falsy entries map serializes to an empty object
assert.deepStrictEqual(
JSON.parse(cache.serializeCacheFile(null)).entries,
{},
'serializeCacheFile coerces falsy entries to {}',
);
// shouldConfirmRegenerate: every guard branch
assert.strictEqual(cache.shouldConfirmRegenerate(null, true), false, 'no entry → false');
assert.strictEqual(cache.shouldConfirmRegenerate({ updatedAt: 'x' }, false), false, 'force=false → false');
assert.strictEqual(cache.shouldConfirmRegenerate({}, true), false, 'missing updatedAt → false');
assert.strictEqual(cache.shouldConfirmRegenerate({ updatedAt: ' ' }, true), false, 'blank updatedAt → false');
assert.strictEqual(
cache.shouldConfirmRegenerate({ updatedAt: '2024-01-01' }, true),
true,
'force + non-blank updatedAt → true',
);
// ── CacheManager: load + prune ──
const adapter = createFakeAdapter();
const manager = new cacheManagerModule.CacheManager(adapter, '.obsidian', 'parallel-reader', () => ({

View file

@ -28,16 +28,65 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'en' }), 'en');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'zh' }), 'zh');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'ja' }), 'ja');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'ko' }), 'ko');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'fr' }), 'fr');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'de' }), 'de');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'es' }), 'es');
assert.strictEqual(i18n.resolveUiLanguage(null), 'en');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'en');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: { toString: () => 'ja' } }), 'en');
const originalNavigator = Object.getOwnPropertyDescriptor(globalThis, 'navigator');
const setNavigatorLanguage = (language) => {
Object.defineProperty(globalThis, 'navigator', {
value: { language },
configurable: true,
});
};
try {
setNavigatorLanguage('ja-JP');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'ja');
setNavigatorLanguage('ko-KR');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'ko');
setNavigatorLanguage('fr-CA');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'fr');
setNavigatorLanguage('de_DE');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'de');
setNavigatorLanguage('es-MX');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'es');
setNavigatorLanguage('it-IT');
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'en');
} finally {
if (originalNavigator) {
Object.defineProperty(globalThis, 'navigator', originalNavigator);
} else {
delete globalThis.navigator;
}
}
assert.ok(i18n.STRINGS.zh);
assert.ok(i18n.STRINGS.en);
const zhKeys = Object.keys(i18n.STRINGS.zh);
const enKeys = Object.keys(i18n.STRINGS.en);
assert.strictEqual(zhKeys.length, enKeys.length);
for (const key of zhKeys) {
assert.ok(i18n.STRINGS.en[key], `en missing key: ${key}`);
assert.ok(i18n.STRINGS.ja);
assert.ok(i18n.STRINGS.ko);
assert.ok(i18n.STRINGS.fr);
assert.ok(i18n.STRINGS.de);
assert.ok(i18n.STRINGS.es);
const supportedLocales = ['zh', 'en', 'ja', 'ko', 'fr', 'de', 'es'];
const enKeys = Object.keys(i18n.STRINGS.en).sort();
for (const locale of supportedLocales) {
const keys = Object.keys(i18n.STRINGS[locale]).sort();
assert.deepStrictEqual(keys, enKeys, `${locale} keys must match en`);
for (const key of enKeys) {
assert.ok(i18n.STRINGS[locale][key], `${locale} empty key: ${key}`);
}
}
for (const locale of ['ja', 'ko', 'fr', 'de', 'es']) {
const overrideKeys = Object.keys(i18n.LOCALE_OVERRIDES[locale]).sort();
assert.deepStrictEqual(overrideKeys, enKeys, `${locale} raw override keys must match en`);
for (const key of enKeys) {
assert.ok(i18n.LOCALE_OVERRIDES[locale][key], `${locale} empty raw override: ${key}`);
}
}
console.log('direct i18n tests passed');

View file

@ -60,6 +60,9 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
const plainMinimal = md.cardToPlain({ title: 'T', anchor: '', gist: '', bullets: [] });
assert.strictEqual(plainMinimal, 'T', 'title only when gist and bullets empty');
const plainNullBullets = md.cardToPlain({ title: 'T', anchor: '', gist: 'G' });
assert.strictEqual(plainNullBullets, 'T\nG', 'undefined bullets coerced to [] (no crash)');
// ── cardsToMarkdown ──
const multi = md.cardsToMarkdown('My Title', [
{ title: 'A', anchor: 'q', gist: 'g', bullets: ['b'] },

View file

@ -13,8 +13,13 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
prompt.promptLanguageInstruction('auto'),
'Write title, gist, and bullets in the main language of the source document.',
);
assert.strictEqual(prompt.promptLanguageInstruction('ja'), 'Write title, gist, and bullets in Japanese.');
assert.strictEqual(prompt.promptLanguageInstruction('ko'), 'Write title, gist, and bullets in Korean.');
assert.strictEqual(prompt.promptLanguageInstruction('fr'), 'Write title, gist, and bullets in French.');
assert.strictEqual(prompt.promptLanguageInstruction('de'), 'Write title, gist, and bullets in German.');
assert.strictEqual(prompt.promptLanguageInstruction('es'), 'Write title, gist, and bullets in Spanish.');
assert.strictEqual(
prompt.promptLanguageInstruction('fr'),
prompt.promptLanguageInstruction('xx'),
'用中文输出 title、gist 和 bullets。',
'unknown language falls to zh',
);
@ -29,6 +34,11 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
assert.ok(zhExample.includes('"cards"'), 'zh example is JSON-like');
assert.ok(prompt.promptSchemaExample('auto').includes('U 型收益曲线'), 'auto falls to zh example');
assert.ok(prompt.promptSchemaExample('ja').includes('U字型の利益'), 'ja example has expected title');
assert.ok(prompt.promptSchemaExample('ko').includes('U자형 이득'), 'ko example has expected title');
assert.ok(prompt.promptSchemaExample('fr').includes('Gains en U'), 'fr example has expected title');
assert.ok(prompt.promptSchemaExample('de').includes('U-förmige Gewinne'), 'de example has expected title');
assert.ok(prompt.promptSchemaExample('es').includes('Ganancias en forma de U'), 'es example has expected title');
// ── renderPromptTemplate ──
assert.strictEqual(prompt.renderPromptTemplate('Hello {name}!', { name: 'World' }), 'Hello World!');
@ -55,6 +65,19 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
const autoResult = prompt.buildPrompts('content', { ...base, promptLanguage: 'auto' });
assert.ok(autoResult.system.includes('main language'), 'auto language instruction');
// ── buildPrompts: expanded output languages ──
for (const [language, expected] of [
['ja', 'Japanese'],
['ko', 'Korean'],
['fr', 'French'],
['de', 'German'],
['es', 'Spanish'],
]) {
const result = prompt.buildPrompts('content', { ...base, promptLanguage: language });
assert.ok(result.system.includes(expected), `${language} language instruction`);
assert.ok(result.user.includes('Source document:'), `${language} uses provider-facing source prefix`);
}
// ── buildPrompts: truncation ──
const longDoc = 'x'.repeat(25000);
const truncResult = prompt.buildPrompts(longDoc, { ...base, maxDocChars: 20000 });
@ -81,9 +104,11 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
const wsCustom = prompt.buildPrompts('doc', { ...base, customSystemPrompt: ' ' });
assert.ok(wsCustom.system.includes('long-form reading'), 'default prompt used when custom is whitespace-only');
// ── buildPrompts: invalid promptLanguage falls back ──
// ── buildPrompts: invalid promptLanguage falls back to the default ('auto') ──
const badLang = prompt.buildPrompts('doc', { ...base, promptLanguage: 'xyz' });
assert.ok(badLang.system.includes('中文'), 'invalid promptLanguage falls back to zh default');
const autoFallback = prompt.buildPrompts('doc', { ...base, promptLanguage: 'auto' });
assert.strictEqual(badLang.system, autoFallback.system, 'invalid promptLanguage falls back to the default (auto)');
assert.ok(badLang.system.includes('main language'), 'fallback uses the auto language instruction');
// ── buildPrompts: card count normalization ──
// 0 is falsy so || picks DEFAULT (5), then Math.max(1, 5) = 5

View file

@ -4,6 +4,7 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
try {
const generation = await requireBundledModule('src/generation.ts');
const providerParsers = await requireBundledModule('src/provider-parsers.ts');
const providerRequest = await requireBundledModule('src/provider-request.ts');
// ── generation.ts ──
assert.strictEqual(
@ -88,6 +89,76 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
);
assert.strictEqual(providerParsers.cardsFromAnthropicToolUse({}), null);
// ── provider-request: structured-output fallback keyed on HTTP status, not localized text ──
const { ProviderApiError, shouldRetryWithoutStructuredOutput, requestJsonBodyWithStructuredFallback } =
providerRequest;
// 400 + body keyword ⇒ retry, regardless of the (i18n-translated) message language.
assert.strictEqual(
shouldRetryWithoutStructuredOutput(
new ProviderApiError('英語以外のエラーメッセージ', 400, 'response_format is not supported'),
),
true,
'status-400 + body keyword ⇒ retry even when message is non-English/Chinese',
);
assert.strictEqual(
shouldRetryWithoutStructuredOutput(
new ProviderApiError("L'API a renvoyé une erreur", 422, 'json_schema unsupported'),
),
true,
'status-422 + body keyword ⇒ retry for a French-localized message',
);
// 5xx is a server error, never a structured-output problem ⇒ do not retry.
assert.strictEqual(
shouldRetryWithoutStructuredOutput(new ProviderApiError('server error', 500, 'response_format')),
false,
);
// 400 without any schema-related keyword ⇒ do not retry.
assert.strictEqual(
shouldRetryWithoutStructuredOutput(new ProviderApiError('bad request', 400, 'missing required field: model')),
false,
);
// Model-name errors ("unknown model" / "unrecognized model ID") must NOT trigger a
// wasted fallback retry — bare unknown/unrecognized keywords were dropped for this.
assert.strictEqual(
shouldRetryWithoutStructuredOutput(new ProviderApiError('bad request', 400, 'unknown model: gpt-5')),
false,
);
assert.strictEqual(
shouldRetryWithoutStructuredOutput(new ProviderApiError('bad request', 400, 'unrecognized model ID: x')),
false,
);
// Legacy path: a plain Error carrying the English template still works (back-compat).
assert.strictEqual(
shouldRetryWithoutStructuredOutput(new Error('OpenAI API returned HTTP 400: response_format not supported')),
true,
);
assert.strictEqual(shouldRetryWithoutStructuredOutput(new Error('some unrelated error')), false);
// End-to-end: a 400 returned alongside a NON-English locale still triggers the fallback body.
{
const calls = [];
const fakeRequestUrl = async ({ body }) => {
calls.push(JSON.parse(body));
if (calls.length === 1) {
return { status: 400, json: null, text: 'response_format is not supported by this model' };
}
return { status: 200, json: { ok: true }, text: '' };
};
const result = await requestJsonBodyWithStructuredFallback(
fakeRequestUrl,
'OpenAI-compatible Chat',
'https://example.test',
{},
{ model: 'x', response_format: { type: 'json_schema' } },
{ model: 'x' },
{ uiLanguage: 'fr' }, // localized error message must NOT block the fallback
);
assert.deepStrictEqual(result, { ok: true });
assert.strictEqual(calls.length, 2, 'should retry exactly once without structured output');
assert.ok(!('response_format' in calls[1]), 'fallback body omits response_format');
}
console.log('direct providers tests passed');
} finally {
cleanup();

View file

@ -4,6 +4,10 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
try {
const settings = await requireBundledModule('src/settings.ts');
const base = settings.DEFAULT_SETTINGS;
const supportedLanguageIds = ['auto', 'zh', 'en', 'ja', 'ko', 'fr', 'de', 'es'];
assert.deepStrictEqual(Object.keys(settings.PROMPT_LANGUAGES), supportedLanguageIds, 'prompt language order');
assert.deepStrictEqual(Object.keys(settings.UI_LANGUAGES), supportedLanguageIds, 'ui language order');
// ── stableStringify ──
assert.strictEqual(settings.stableStringify(42), '42', 'number');
@ -99,6 +103,19 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
assert.strictEqual(normed.maxDocChars, base.maxDocChars, 'maxDocChars <1000 → default');
assert.strictEqual(normed.customSystemPrompt, '', 'non-string customSystemPrompt → empty string');
for (const language of supportedLanguageIds) {
assert.strictEqual(
settings.normalizeSettings({ ...base, uiLanguage: language }).uiLanguage,
language,
`normalizeSettings preserves uiLanguage ${language}`,
);
assert.strictEqual(
settings.normalizeSettings({ ...base, promptLanguage: language }).promptLanguage,
language,
`normalizeSettings preserves promptLanguage ${language}`,
);
}
// ── pruneCacheEntries edge cases ──
assert.deepStrictEqual(settings.pruneCacheEntries(null, 10), [], 'null cache');
assert.deepStrictEqual(settings.pruneCacheEntries({}, 10), [], 'empty cache');

View file

@ -74,6 +74,47 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
const empty = streaming.parseSseBuffer('', openAiExtractor);
assert.deepStrictEqual(empty.deltas, []);
// ── streamErrorMessage: provider errors delivered as a 200-status SSE payload ──
assert.strictEqual(
streaming.streamErrorMessage({ type: 'error', error: { type: 'overloaded_error', message: 'Overloaded' } }),
'Overloaded',
);
assert.strictEqual(
streaming.streamErrorMessage({ type: 'error', error: { type: 'overloaded_error' } }),
'overloaded_error',
);
assert.strictEqual(streaming.streamErrorMessage({ type: 'error' }), 'Provider returned a streaming error');
assert.strictEqual(streaming.streamErrorMessage({ error: { message: 'Quota exceeded' } }), 'Quota exceeded');
// OpenAI-style error object without a message/type is NOT treated as an error
// (avoids aborting a normal chunk that carries a stray empty/code-only `error`).
assert.strictEqual(streaming.streamErrorMessage({ error: { code: 'insufficient_quota' } }), null);
assert.strictEqual(streaming.streamErrorMessage({ error: {} }), null);
assert.strictEqual(streaming.streamErrorMessage({ choices: [{ delta: { content: 'hi' } }] }), null);
assert.strictEqual(streaming.streamErrorMessage({ type: 'content_block_delta', delta: { text: 'x' } }), null);
assert.strictEqual(streaming.streamErrorMessage({ error: null }), null);
// ── parseSseBuffer: surface in-stream provider errors instead of swallowing them ──
assert.throws(
() =>
streaming.parseSseBuffer(
'data: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}\n\n',
anthropicExtractor,
),
/Overloaded/,
'anthropic in-stream error must throw, not be swallowed as a non-JSON line',
);
assert.throws(
() => streaming.parseSseBuffer('data: {"error":{"message":"Rate limit reached"}}\n\n', openAiExtractor),
/Rate limit reached/,
'openai-compatible in-stream error must throw',
);
// Normal deltas through the same parse path still work.
const okAfterError = streaming.parseSseBuffer(
'data: {"choices":[{"delta":{"content":"fine"}}]}\n\n',
openAiExtractor,
);
assert.deepStrictEqual(okAfterError.deltas, ['fine']);
// ── streamingRequestUrl ──
function trackedSignal() {
const controller = new AbortController();

View file

@ -10,7 +10,12 @@ if (typeof globalThis.activeWindow === 'undefined') {
}
const repoRoot = path.join(__dirname, '..');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'parallel-reader-tests-'));
// Under c8, bundles must live inside the repo so c8 processes their coverage
// (it ignores scripts outside cwd before source-map remap). Otherwise /tmp.
const bundleParent = process.env.NODE_V8_COVERAGE
? fs.mkdirSync(path.join(repoRoot, '.test-bundles'), { recursive: true }) || path.join(repoRoot, '.test-bundles')
: os.tmpdir();
const tempDir = fs.mkdtempSync(path.join(bundleParent, 'parallel-reader-tests-'));
async function requireBundledModule(relativePath) {
const entry = path.join(repoRoot, relativePath);
@ -21,6 +26,9 @@ async function requireBundledModule(relativePath) {
platform: 'node',
format: 'cjs',
outfile,
sourcemap: 'inline',
sourcesContent: true,
sourceRoot: repoRoot,
plugins: [
{
name: 'obsidian-stub',
@ -35,10 +43,14 @@ async function requireBundledModule(relativePath) {
},
],
});
require('./coverage-sourcemap').fixInlineSourceMap(outfile, repoRoot);
return require(outfile);
}
function cleanup() {
// Skipped under c8 coverage: c8 reads V8 coverage at exit and needs the
// bundled file (with its inline source map) still on disk to remap to src/.
if (process.env.NODE_V8_COVERAGE) return;
fs.rmSync(tempDir, { recursive: true, force: true });
}

View file

@ -166,6 +166,38 @@ async function testCancelAllWaiters() {
assert.strictEqual(manager.waitingCount(), 0);
}
async function testCancelAll() {
const manager = new GenerationJobManager(1);
let release;
const blocker = new Promise((r) => {
release = r;
});
let runningCancelHook = false;
const running = manager.start('run.md', async (job) => {
job.onCancel(() => {
runningCancelHook = true;
});
await blocker;
job.throwIfCancelled();
return 'run';
});
const queued = manager.start('q.md', async () => 'q');
await new Promise((r) => setTimeout(r, 5));
assert.strictEqual(manager.isRunning('run.md'), true, 'one running');
assert.strictEqual(manager.waitingCount(), 1, 'one queued');
const cancelled = manager.cancelAll();
assert.strictEqual(cancelled, 2, 'cancelAll cancels the running job and drains the queued waiter');
assert.strictEqual(runningCancelHook, true, 'running job cancel handler fired (aborts in-flight HTTP/CLI)');
release();
await assert.rejects(running, GenerationJobCancelledError, 'cancelled running job rejects');
await assert.rejects(queued, GenerationJobCancelledError, 'queued job rejects');
assert.strictEqual(manager.waitingCount(), 0);
}
async function testCancelSignalsRunnerAndCleansUp() {
const manager = new GenerationJobManager();
let cancelHookCalled = false;
@ -190,6 +222,12 @@ function testErrorClassification() {
assert.strictEqual(classifyGenerationError(new Error('API key 未设置')), 'auth');
assert.strictEqual(classifyGenerationError(new Error('CLI 超时 (120000ms)')), 'timeout');
assert.strictEqual(classifyGenerationError(new Error('OpenAI API 429: rate limit')), 'rate-limit');
assert.strictEqual(
classifyGenerationError(new Error('request to https://api failed, reason: ECONNREFUSED')),
'network',
);
assert.strictEqual(classifyGenerationError(new Error('Failed to fetch')), 'network');
assert.strictEqual(classifyGenerationError(new Error('getaddrinfo ENOTFOUND api.openai.com')), 'network');
assert.strictEqual(classifyGenerationError(new Error('LLM 返回非 JSON')), 'schema');
assert.strictEqual(classifyGenerationError(new Error('Model 未设置')), 'config');
assert.strictEqual(classifyGenerationError(new Error('something else')), 'unknown');
@ -200,6 +238,7 @@ function testErrorClassification() {
await testGlobalConcurrencyLimit();
await testNoOverbookingDuringRelease();
await testCancelAllWaiters();
await testCancelAll();
await testCancelSignalsRunnerAndCleansUp();
testErrorClassification();
console.log('generation job manager tests passed');

View file

@ -2,12 +2,22 @@ const { assert, t } = require('./test-setup');
assert.strictEqual(t.translate({ uiLanguage: 'zh' }, 'appTitle'), '对照阅读笔记', 'zh translation');
assert.strictEqual(t.translate({ uiLanguage: 'en' }, 'appTitle'), 'Parallel Reader', 'en translation');
assert.strictEqual(t.translate({ uiLanguage: 'ja' }, 'settingTestBackendButton'), 'テスト');
assert.strictEqual(t.translate({ uiLanguage: 'ko' }, 'settingTestBackendButton'), '테스트');
assert.strictEqual(t.translate({ uiLanguage: 'fr' }, 'settingTestBackendButton'), 'Tester');
assert.strictEqual(t.translate({ uiLanguage: 'de' }, 'settingTestBackendButton'), 'Testen');
assert.strictEqual(t.translate({ uiLanguage: 'es' }, 'settingTestBackendButton'), 'Probar');
assert.strictEqual(t.translate({ uiLanguage: 'en' }, 'nonexistent_key'), 'nonexistent_key', 'missing key returns key');
assert.strictEqual(
t.translate({ uiLanguage: 'en' }, 'cacheClearedAll', { count: 5 }),
'Cleared 5 cache entries',
'variable interpolation',
);
assert.strictEqual(
t.translate({ uiLanguage: 'fr' }, 'cacheClearedAll', { count: 5 }),
'5 entrées de cache effacées',
'new locale interpolation',
);
assert.strictEqual(
t.translate({ uiLanguage: 'en' }, 'exported', { path: 'foo/bar.md' }),
'Exported → foo/bar.md',

View file

@ -11,6 +11,7 @@ const expectedExports = [
'runCli',
'buildPrompts',
'buildOpenAiChatBody',
'buildLineOffsets',
'extractJson',
'findLineForAnchor',
'folderPathsForTarget',

View file

@ -17,7 +17,12 @@ const { getRequestUrlMock, setRequestUrlMock } = require('./obsidian-mock');
// Bundle test-exports.ts synchronously with obsidian marked as external.
// The bundled code will require('obsidian') at runtime, hitting our mock.
const repoRoot = path.join(__dirname, '..');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'parallel-reader-test-setup-'));
// Under c8, bundles must live inside the repo so c8 processes their coverage
// (it ignores scripts outside cwd before source-map remap). Otherwise /tmp.
const bundleParent = process.env.NODE_V8_COVERAGE
? fs.mkdirSync(path.join(repoRoot, '.test-bundles'), { recursive: true }) || path.join(repoRoot, '.test-bundles')
: os.tmpdir();
const tempDir = fs.mkdtempSync(path.join(bundleParent, 'parallel-reader-test-setup-'));
const outfile = path.join(tempDir, 'test-exports.cjs');
esbuild.buildSync({
@ -27,12 +32,20 @@ esbuild.buildSync({
format: 'cjs',
outfile,
external: ['obsidian'],
sourcemap: 'inline',
sourcesContent: true,
sourceRoot: repoRoot,
});
require('./coverage-sourcemap').fixInlineSourceMap(outfile, repoRoot);
const t = require(outfile);
// Clean up temp bundle on process exit.
// Clean up temp bundle on process exit. Skipped under c8 coverage:
// c8 reads V8 coverage at exit and needs the bundled file (with its
// inline source map) still on disk to remap back to src/*.ts.
process.on('exit', () => {
if (process.env.NODE_V8_COVERAGE) return;
try {
fs.rmSync(tempDir, { recursive: true, force: true });
} catch (_) {

View file

@ -20,5 +20,8 @@
"1.0.18": "1.8.7",
"1.0.19": "1.8.7",
"1.0.20": "1.8.7",
"1.0.21": "1.8.7"
"1.0.21": "1.8.7",
"1.0.22": "1.8.7",
"1.0.23": "1.8.7",
"1.0.24": "1.8.7"
}