Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Analysiere **jede Datei, jedes Feature und jedes Repo individuell und ganzheitli

---

## StoryCraft-Studio (dieses Repo) — Kurzkontext
## WorldScript-Studio (dieses Repo, ehem. StoryCraft-Studio) — Kurzkontext

Offline-first, **Privacy**, Redux Toolkit + IndexedDB + Zustand (transient UI), Hybrid-KI (Gemini, Vercel AI SDK, Ollama/WebLLM), pnpm-Workspace (`packages/*`), PWA, 5-Locale-i18n. Fokus: **Erzählung**, Schreibflow, KI als Co-Pilot — nicht als Ghostwriter. Vollständiger Stack und Regelkatalog: **`.cursor/index.mdc`**.
Offline-first, **Privacy**, Redux Toolkit + IndexedDB + Zustand (transient UI), Multi-Provider-KI (Gemini, Vercel AI SDK, OpenAI/Claude/Grok/OpenRouter, Ollama/WebLLM/ONNX/Transformers.js), pnpm-Workspace (`packages/*`), PWA + Tauri 2, 19-Locale-i18n. Fokus: **Erzählung**, Schreibflow, KI als Co-Pilot — nicht als Ghostwriter. Vollständiger Stack und Regelkatalog: **`.cursor/index.mdc`**.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

---

Expand All @@ -46,7 +46,7 @@ Inhalt des Kommentars: **warum** die Änderung, **was** sie verbessert, optional

Bei jeder offenen PR **alle** Inline-Review-Kommentare (CodeRabbit + jeder andere Bot/Mensch) **proaktiv, ungefragt** abarbeiten. Pro Finding: gegen den **aktuellen** Code validieren (Anker oft veraltet), dann **Root-Cause-Fix** vollständig umsetzen (Code **+ Tests + i18n + Doku**) oder mit Begründung als False-Positive ablehnen. Jeden Thread mit Commit-Referenz beantworten, **resolven**, **0 unresolved** hinterlassen, committen + pushen.

**Iron Rule — Loop bis Ruhe:** Nach jedem Push **Review erneut triggern** (`gh pr comment <N> --body "@coderabbitai review"`) und die komplette Review-Historie prüfen, nicht nur den letzten Status (ein „rate limited"-Status kann eine frühere echte Review verdecken); eine frische Review bringt regelmäßig **neue** Findings (eine „Welle"). Zyklus wiederholen, bis **BEIDES** gilt: frische Review = **0 neue Kommentare** UND **0 offene Threads**. Niemals aufhören, solange noch Kommentare kommen. **Niemals ein neues `biome-ignore`/Suppression** einbauen, um ein Finding stummzuschalten — der Suppression-Ratchet-Gate lässt die CI scheitern; stattdessen sauber refaktorieren. CodeAnt AI erscheint nur als 5 CI-Status-Checks (Quality Gates/SAST/SCA/SCR/Test Coverage) zur Grün-Prüfung, kein Kommentar-Thread — dort nicht erneut triggern in Erwartung eines Kommentars. Vollständige Prozedur: **`docs/CODEANT-REVIEW-LOOP.md`**.
**Iron Rule — Loop bis Ruhe:** Nach jedem Push **Review erneut triggern** (`gh pr comment <N> --body "@coderabbitai review"`) und die komplette Review-Historie prüfen, nicht nur den letzten Status (ein „rate limited"-Status kann eine frühere echte Review verdecken); eine frische Review bringt regelmäßig **neue** Findings (eine „Welle"). Zyklus wiederholen, bis **BEIDES** gilt: frische Review = **0 neue Kommentare** UND **0 offene Threads**. Niemals aufhören, solange noch Kommentare kommen. **Niemals ein neues `biome-ignore`/Suppression** einbauen, um ein Finding stummzuschalten — der Suppression-Ratchet-Gate lässt die CI scheitern; stattdessen sauber refaktorieren. CodeAnt AI erscheint nur als 5 CI-Status-Checks (Quality Gates/SAST/SCA/SCR/Test Coverage) zur Grün-Prüfung, kein Kommentar-Thread — dort nicht erneut triggern in Erwartung eines Kommentars. Vollständige Prozedur (inkl. des komplementären, token-freien DeepSource-Loops): **`docs/CODEANT-REVIEW-LOOP.md`** + **`docs/DEEPSOURCE-REVIEW-LOOP.md`**.

---

Expand Down
8 changes: 7 additions & 1 deletion KIMI-INSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Dieses Projekt läuft auf Low-End-Hardware. Beachte strikt:

Dieser Workflow ist die Standardvorgehensweise, wenn der Nutzer um Behebung von CodeAnt-Kommentaren bittet.

> **Kanonische Quelle:** Die vollständige, agenten-unabhängige Prozedur (inkl. GraphQL-Snippets, PR-Split
> bei >100 Dateien, Merge-Regeln) lebt in **`docs/CODEANT-REVIEW-LOOP.md`**; der komplementäre,
> token-freie statische-Analyse-Loop in **`docs/DEEPSOURCE-REVIEW-LOOP.md`**. Der Abschnitt unten ist
> eine Kimi-spezifische Kurzfassung — bei Abweichungen gelten die beiden kanonischen Dateien.

> **In der Praxis (Beobachtung 2026-07-30):** Der Bot, der tatsächlich Inline-Kommentare postet, ist
> **CodeRabbit** (`@coderabbitai review` zum erneuten Triggern) — nicht CodeAnt AI. CodeAnt AI
> erscheint als 5 CI-Status-Checks (`CodeAnt - Quality Gates/SAST/SCA/SCR/Test Coverage`), die auf
Expand Down Expand Up @@ -102,7 +107,8 @@ pnpm exec vitest run <betroffene-testdateien>

- Lint/Format-Fehler vor dem Commit beheben (`biome check --write ...`).
- TypeScript-Fehler sofort beheben.
- i18n-Keys bei neuem UI-Text zu **allen 11 Locales** hinzufügen und Bundles neu bauen.
- i18n-Keys bei neuem UI-Text zu **allen 19 Locales** hinzufügen (`node scripts/check-i18n-keys.mjs --fix`) und Bundles neu bauen (`pnpm run i18n:bundle`).
- Commit-Nachrichten mit der Zuordnung des tatsächlich arbeitenden Agenten/Modells abschließen, z. B. `Co-Authored-By: Kimi K2 <noreply@moonshot.ai>` — niemals eine generische oder falsche Modellangabe übernehmen.

### 3.4 Commit & Push

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ The Settings → AI panel shows a live GPU status badge with adapter details and
| **PDF Export** | jsPDF | Client-side, configurable PDF document generation |
| **Document Export** | docx + jszip | Word-compatible `.docx` generation (lazy-loaded) |
| **PWA** | Service Worker + Web App Manifest v3 | Offline support, installability, Workbox chunking |
| **i18n** | Custom React Context (`I18nContext.tsx`) | 2861 keys × 19 locales (de/en/es/fr/it + ar/he/fa RTL Beta + ja/zh/pt/el/fi/sv/hu/is/eu Beta); EN fallback; `localStorage` persistence |
| **i18n** | Custom React Context (`I18nContext.tsx`) | 2861 keys × 19 locales (de/en/es/fr/it + ar/he/fa RTL Beta + ja/zh/pt/el/fi/sv/hu/is/eu/ru/ko Beta); EN fallback; `localStorage` persistence |
| **Testing** | Vitest 4.x (6477+ tests / 532 files) + Playwright E2E | Unit/integration + cross-browser E2E; Stryker mutation (manual workflow) |
| **Code Quality** | Biome (lint + format) + TypeScript 7 (tsgo) strict | `--error-on-warnings` in CI; zero `any` policy |
| **Visualization** | Force-directed graph | Interactive character relationship network |
Expand Down Expand Up @@ -748,7 +748,7 @@ Shared Playwright helpers (`waitForSpaReady`, `ensureBlankProject`, `clickNavIte

- **🐛 Report Bugs** — Open a GitHub Issue with details and reproduction steps
- **💡 Suggest Features** — Open a Discussion or Issue
- **🌍 Improve Translations** — Five locale trees (`en` is the reference); native polish for FR/ES/IT especially welcome in PRs
- **🌍 Improve Translations** — Five core locale trees (`en` is the reference); native polish for FR/ES/IT especially welcome in PRs
- **🧪 Write Tests** — Coverage thresholds: branches ≥ 60 %, functions ≥ 67 %, lines ≥ 74 %; contributions to large components (collaboration, AI streaming paths, OpenRouter provider) are particularly valuable

See **[`CONTRIBUTING.md`](CONTRIBUTING.md)** for the full dev setup, Biome / Vitest / Playwright guide, and architecture notes.
Expand All @@ -767,6 +767,7 @@ See **[`CONTRIBUTING.md`](CONTRIBUTING.md)** for the full dev setup, Biome / Vit
| [`AUDIT.md`](AUDIT.md) | Security & quality audit trail + scorecard |
| [`docs/AUDIT-PERFECTION-PLAN-v1.23.md`](docs/AUDIT-PERFECTION-PLAN-v1.23.md) | Living master plan for the v1.23 audit/perfection engagement (phase status + batch log) |
| [`docs/CI.md`](docs/CI.md) | GitHub Actions jobs, Node/pnpm parity, Act examples |
| [`docs/CODEANT-REVIEW-LOOP.md`](docs/CODEANT-REVIEW-LOOP.md) | Canonical, agent-agnostic PR review correction loop (CodeRabbit/CodeAnt/any bot) — GraphQL fetch/reply/resolve, PR-size split, merge rules |
| [`docs/DEEPSOURCE-REVIEW-LOOP.md`](docs/DEEPSOURCE-REVIEW-LOOP.md) | DeepSource static-analysis correction loop (living runbook; complements the CodeAnt loop) |
| [`docs/DEEPSOURCE-REMEDIATION-PLAN.md`](docs/DEEPSOURCE-REMEDIATION-PLAN.md) | Prioritised DeepSource backlog tracker (P0-security→P5-docs) with triage decisions |
| [`docs/adr/`](docs/adr/README.md) | Architecture Decision Records — state-management boundaries, local-AI stack layering, WorkerBus v2 hybrid routing |
Expand Down
8 changes: 4 additions & 4 deletions docs/CODEANT-REVIEW-LOOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Each wave is handled exactly like the first.
> Until both are true, **keep iterating**. Never declare the PR done while new comments are still
> arriving or any thread is open.

```
```text
┌─────────────────────────────────────────────┐
│ 1. Fetch unresolved threads (GraphQL) │
│ 2. Validate each against CURRENT code │
Expand Down Expand Up @@ -167,10 +167,10 @@ git commit -m "refactor(scope): address CodeAnt wave N review feedback"
git push origin <feature-branch>
```

End commit messages with:
End commit messages with the attribution matching whichever agent/model actually made the change, e.g.:

```
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
```text
Co-Authored-By: GitHub Copilot (Claude Sonnet 5) <noreply@github.com>
```

## 6. Reply to every thread, then resolve it → 0 unresolved
Expand Down
4 changes: 4 additions & 0 deletions docs/DEEPSOURCE-REMEDIATION-PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Fix in this order — highest user/security impact first; cosmetic last. Within
|---|---|---|---|---|---|---|
| **JS-0323** | Detected usage of `any` (Critical) | 34 / 20 files | **100% test files** (browser-API mocks: MediaRecorder/AudioContext …), all already `biome-ignore noExplicitAny`'d; **0 production** | **rule-ignore, test scope** — redundant with Biome `noExplicitAny` + the suppression ratchet (baseline 52). Do NOT add 34 inline `skipcq`. Long-term: opportunistic typed-mock cleanup (§4c). | maintainer-click (rule-ignore) | — |
| **JS-0415** | JSX tree too deeply nested (5–6 levels) | 2 | `components/HelpView.tsx` | pre-existing structural; genuine refactor candidate (extract sub-components to cut nesting). Minor severity → schedule as a low-priority hygiene PR; **not** a false positive. | todo (future refactor) | — |
| **JS-0067** | Unexpected function declaration in the global scope | 2+ (repo-wide pattern) | `services/ai/localAiDeviceProfiler.ts`, `services/workerBusManager.ts` (representative — every top-level `services/*.ts` function hits this) | **rule-ignore, repo-wide** — idiomatic top-level ES-module functions, not `<script>`-tag globals; fixing per-occurrence would touch dozens of pre-existing files for no behavioral gain. | todo (maintainer dashboard click) | #305 |
| **JS-R1005** | Cyclomatic complexity (medium risk) | 5 | `packages/worker-bus/src/workerBus.ts` (`enqueue`=11), `services/ai/localAiDeviceProfiler.ts` (`detectWebnn`=10, `detectMemoryTier`=9, `recommendBackend`=9, `detectDirectML`=6) | **pre-existing, out of scope for #305** — confirmed via diff that none of these 5 functions were touched by the PR (only `runOnPool`/`waitForIdle` in `workerBus.ts` and an `export` keyword add on `detectMemoryTier`); DeepSource's PR view widens "introduced" to every issue in a touched file, not just changed lines. Genuine refactor candidates (extract sub-checks to cut branching) — schedule as a dedicated low-priority hygiene PR, not bundled into feature work. | todo (future refactor) | #305 |
| **JS-C1002** | Variable name is too small | 2 | `packages/worker-bus/src/workerBus.ts` (`toError`'s `e`), `packages/worker-bus/tests/workerBus.test.ts` (`t` in a telemetry assertion) | **pre-existing, out of scope for #305** — same "introduced" widening as JS-R1005 above; neither line is in this PR's diff. Trivial rename (`e`→`err`, `t`→`telemetry`) whenever either file is next touched for an unrelated reason. | todo (opportunistic) | #305 |

### P4 — Hygiene / Style
| Issue code | Title | Occ. | Files / modules | Decision | Status | PR |
Expand Down Expand Up @@ -148,6 +151,7 @@ config level (`.deepsource.toml`) instead of scattering inline `skipcq`. Log eac
|---|---|---|---|
| **JS-0323** (`any`) | dashboard rule-ignore, **test-file scope** | 34 occ all in test mocks, already governed by Biome `noExplicitAny` + the suppression ratchet (baseline 52); double-suppressing is noise. 0 production `any`. Long-term cleanup → §4c. | 2026-06-24 |
| **JS-0440** (`dangerouslySetInnerHTML`) | dashboard "Ignore" (single occurrence) | reviewed-safe — `__html` is DOMPurify-sanitized (repo policy). In-code skipcq can't attach to a JSX attribute (§4b). | 2026-06-24 |
| **JS-0067** ("unexpected function declaration in the global scope") | recommend dashboard rule-ignore (not yet actioned — maintainer click) | flagged on PR #305 for ordinary top-level `function`/`async function` declarations in `services/ai/localAiDeviceProfiler.ts` + `services/workerBusManager.ts` — idiomatic Biome-approved ES-module code, not `<script>`-tag global pollution; repo-wide pattern, not a per-file fix. Informational-only check (not in required-status list). See `DEEPSOURCE-REVIEW-LOOP.md` §11, 2026-08-01 entry. | 2026-08-01 |

## 6. Definition of done

Expand Down
20 changes: 18 additions & 2 deletions docs/DEEPSOURCE-REVIEW-LOOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ List + resolve via the GraphQL snippet in §3a.
A push that fixes findings triggers a **fresh** DeepSource run, which can surface **new** findings
caused by the fix (a "wave"). Handle each wave like the first.

```
```text
┌─────────────────────────────────────────────┐
│ 1. Fetch DeepSource findings (check-runs + │
│ annotations) for the PR head SHA │
Expand Down Expand Up @@ -215,7 +215,8 @@ git commit -m "refactor(scope): address DeepSource wave N (<issue codes>)"
git push origin <feature-branch>
```

End commit messages with `Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>`.
End commit messages with the attribution matching whichever agent/model actually made the change, e.g.
`Co-Authored-By: GitHub Copilot (Claude Sonnet 5) <noreply@github.com>`.
**No manual re-trigger** — DeepSource analyses the new head SHA on its own. Wait for the fresh run,
then go back to §3.

Expand Down Expand Up @@ -270,6 +271,21 @@ GitHub App resumes auto-reviewing, run **both** loops: CodeAnt for narrative/AI
new service/hook needs its branches tested or patch coverage dips below the ~72% target and the
`codecov/patch` check fails. #236's hook+panel needed a dedicated hook test (offline/error/disabled/
stale-apply/dictionary/clear branches) to clear it — same posture as #232's binderDepth test.
- **2026-08-01** — On PR #305, `DeepSource: JavaScript` surfaced **JS-0067** ("unexpected function
declaration in the global scope") on top-level `function`/`async function` declarations in
`services/ai/localAiDeviceProfiler.ts` and `services/workerBusManager.ts` — a pattern used
throughout this repo's ES modules (every service file declares top-level functions; this is
idiomatic, Biome-approved module code, not `<script>`-tag global-scope pollution). Confirmed via
`gh api .../branches/main/protection`: only the `CI Success` aggregator is a **required** status
check — `DeepSource: JavaScript` is informational-only and does not block merge. Per §4a.3, do not
scatter `# skipcq: JS-0067` across dozens of pre-existing functions repo-wide to chase this; the
correct fix is a **dashboard rule-level ignore** for JS-0067 (maintainer action, not toml-expressible
— DeepSource rule toggles live under Settings → Issue Types on app.deepsource.com, not
`.deepsource.toml`). Real, valuable findings from the same wave (real bugs, not style noise) were
fixed instead: a stale-`MessagePort`-reuse bug (late PROGRESS/RESULT from a cancelled task could
reset/resolve a new task sharing the same released port — fixed by filtering on `msg.taskId` in
`workerBus.ts`), and a missing `port.start()` call in `workerPool.ts::spawnWorker()` (an
`addEventListener`-based `MessagePort` never dispatches without it per the WHATWG spec).

---

Expand Down
7 changes: 4 additions & 3 deletions docs/SESSION-HANDOFF-MAIN-CI-COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The diagnostic narrative below is retained for the record.
**Symptom:** On `main`, the **`CI / CD` → `🔍 Quality Gate`** job (both Node 22 and Node 24) fails on the
**coverage threshold**:

```
```text
ERROR: Coverage for lines (5.16%) does not meet global threshold (74%)
ERROR: Coverage for functions (4.91%) ... (67%)
ERROR: Coverage for statements (5.02%) ... (72%)
Expand Down Expand Up @@ -113,7 +113,7 @@ the coverage-threshold path (i.e. not as a hard test failure). Candidates, in pr
**⚠️ BLOCKER on #180 — real typecheck failure (must fix before commit):**
`pnpm run typecheck` fails with **3× TS2352** at `features/proForge/machine/proForgeMachine.ts` lines
**68, 71, 75** (the pre-existing `setPreSnapshot`/`setResult`/`setDecision` actions):
```
```text
Conversion of type 'ProForgeMachineEvent' to type '{ output: ... }' may be a mistake ...
Property 'output' is missing in type '{ type: "ABORT"; }' ...
```
Expand Down Expand Up @@ -158,5 +158,6 @@ Flow-Mode fullscreen + docs). Each = one PR off main, CodeAnt deferred.
## Environment reminders
- **ONE Bash call per turn** (low-end hardware ~3.7 GB RAM); no concurrent heavy shells. A full local
coverage run ≈ 1 hour — prefer single-file runs for diagnosis.
- Co-Author commits with `Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>`.
- Co-Author commits with the attribution matching whichever agent/model actually made the change, e.g.
`Co-Authored-By: GitHub Copilot (Claude Sonnet 5) <noreply@github.com>`.
- Never lower coverage thresholds or `it.skip` to go green — fix the root cause.
Loading
Loading