Commit graph

11 commits

Author SHA1 Message Date
wujunchen
ff1116d7f4 fix: pass --max-tokens to Claude Code CLI to prevent output truncation
The CLI path was not forwarding settings.apiMaxTokens, causing the
model to use its own default which is too small for long documents
with many CJK cards. This was the root cause of repeated "LLM 返回
非 JSON" errors — the JSON was being cut off mid-card.

Change-Id: Ia738418e2e6cf7f919752cb3128a82768d95cedf
2026-04-27 11:58:04 +08:00
wujunchen
abce923f14 fix: salvage truncated LLM JSON and make errors copyable
- Add repairTruncatedCardsJson to recover complete cards when output
  is cut off mid-card (e.g. token limit reached)
- Log raw LLM response to console on parse failure for debugging
- Make error panel text selectable and add "copy error" button

Change-Id: I4e76121138888234d42f84f3695cbbfd6beba886
2026-04-27 11:56:40 +08:00
wujunchen
6dd7ef15a4 test: cover cli edge cases
Change-Id: Ia6114ab7ba24e32f7f86ff76710a596b0c24682c
2026-04-26 18:16:38 +08:00
wujunchen
9ed36570b5 refactor: restore strict lint hygiene
Change-Id: I26917328ec55e529242dfd8e4c42af0b3fcd58b7
2026-04-26 17:41:28 +08:00
wujunchen
38ba0acdb2 fix: parse Claude Code JSON array output and drop --model flag
Claude Code `--output-format json` returns a JSON array of event
objects, not a single object. Parse the array and extract the
result event. Also stop passing --model to let Claude Code use
its own default model. Revert timeout to 120s.

Change-Id: I5b5d4aa589ff78c0a2806a3e700bac0676a9b354
2026-04-26 11:09:47 +08:00
wujunchen
c4b1543046 fix: cross-platform CLI path detection for Windows
Add Windows-specific candidate paths (AppData\Roaming\npm,
scoop\shims, etc.) and probe .cmd/.exe extensions. Unix paths
unchanged.

Change-Id: I8a431cfadc7143fa7d5db18817e2152e896e7243
2026-04-26 10:22:28 +08:00
wujunchen
58ab0fa77f refactor: enable full TypeScript strict mode
Switch from incremental strict flags to strict: true. Fix property
initializers with definite assignment assertions and inline defaults,
and annotate all catch clauses with unknown type.

Change-Id: I805047eebea7dc5414ff7001aca96eac5a099d02
2026-04-26 09:21:54 +08:00
wujunchen
31e57c8b19 refactor: enable noImplicitAny and add type annotations
Turn on noImplicitAny in tsconfig.json. Add explicit type annotations
to all 137 previously untyped parameters across main.ts, view.ts,
modal.ts, settings-tab.ts, providers.ts, cli.ts, anchor.ts, scroll.ts,
ui-helpers.ts, vault.ts, and settings.ts.

Change-Id: Icc5a69ab57113e9f6dc08dd97e3a8fa5e7e24937
2026-04-26 08:58:41 +08:00
wujunchen
83f35f8ccb feat: add Biome for lint and format
Install @biomejs/biome with lint and format config.
Add npm lint/lint:fix scripts. Auto-fix formatting across all source
files. Update tsconfig lib to ES2022 for Object.hasOwn support.

Change-Id: I13e3ba2f106f7e3d03349080b7ed515d427d24a1
2026-04-25 23:47:49 +08:00
wujunchen
f3afc4fbe0 refactor: add TypeScript interfaces for core types
Create src/types.ts with RawCard, ResolvedCard, CardPatch, CacheEntry,
PluginSettings, ApiProviderPreset, ApiFormat, GenerationPhase, ErrorKind,
and PromptPair. Update all source modules to use typed signatures,
replacing `any` with concrete interfaces.

Change-Id: I87b7dd6f3a240c95597d7a796b4d1885386aa632
2026-04-25 23:34:45 +08:00
wujunchen
5f6f18677b refactor: split CLI backend module
Change-Id: I7450dface429972b71b173973e6f71393d83303e
2026-04-25 19:58:29 +08:00