feat(input,voice): instant first-word-after-focus PC layout fix and speech disfluency post-processing (INPUT-04, INPUT-19, AI-03, AI-05)

This commit is contained in:
Yun Chan 2026-10-29 19:05:01 +09:00
parent dbed97c348
commit 7a86afa7b0
22 changed files with 359 additions and 39 deletions

View file

@ -2,7 +2,9 @@
> Status: ACTIVE
> Last full audit: 2026-09-13
> Last update: 2026-10-29 — **v1.13.0 릴리스 + 그래프 관계성 기반 극한 개인화(`INPUT-06`, `INPUT-20`) + 한영 형태론·전방 구문 감지 및 단일-시스콜 초고속 인플레이스 수정(`INPUT-19`, `INPUT-22`) + 전 표면 디자인파카(`designpaca`) 순회 감사(`SHELL-11`, `SHELL-15`).** (1) **그래프 관계성 & 극한 개인화:** `@d3ro/core/personal-graph` 및 `PersonalGraphService`에 앱별 연속 단문 메시지 간 세션 `follows` 체이닝(`_lastIndexedByScope`), 엔터 전송 직후 비워진 채팅창 문맥 복원(`recentWrites`), 증분 `shares_terms` 엣지 연결, 조사 차이 무관 어간 연속 이어쓰기(`stemContinuationsFrom`), 2-홉 그래프 경로 랭킹(`rankTwoHopGraphTargets`), 개인 그래프·어투 일치 기반 LLM 후보 재정렬(`scoreCandidatePersonalization`), 어간 바이그램 폴백 및 빈도 가중 개인 n-gram(`PersonalNgramModel`)을 추가했다(제안 노출 빈도는 그대로 유지). (2) **영어 감지 강화 & 초고속 타이핑 중 무경합 교정:** `@d3ro/core/typo-correction`에 확장 영어 어간(`EXTENDED_ENGLISH_STEMS`, `kubernetes`/`microsoft` 등)과 생산적 접두·접미 파생 형태론(`matchesInflectedOrDerivedEnglish`), 전방 영어 구문 호응(`새 ㅠㄷ `→`to be `, `새 애 this `→`to do this `, `랙 솓 `→`for the ` vs `오늘 새 API를 만들었어` 보존), 영어 축약형·약어(`ㅊ무ㅅ`/`ㅊ무'ㅅ`/`ㅊ무ㅜ'ㅅ`→`can't`, `츤를`→`CMS를`, `눈를`→`SNS를` 등)를 추가하고, `sendWin32UnicodeReplacement`(`utils/win32-unicode-input.ts`)로 `(선택 Space) + N × VK_BACK + M × KEYEVENTF_UNICODE`를 **단일 `SendInput` 시스템콜(`< 0.5 ms`, 대기 `0 ms`)**로 원자적 주입하며, 타이핑 중 추가 입력된 꼬리 글자를 보존하는 델타 리베이싱(`rebaseTypoReplacementPlan`)을 구현했다. (3) `packages/ui`, `apps/web`, `apps/admin`, `apps/desktop/src/renderer`(메인·팝업 6종), `site/`, `apps/mobile-rn` 6개 표면을 전수 순회해 `design.md` 계약 위반을 모두 해소했다 (`npm run check:design` 0건).
> Last update: 2026-10-29 — **v1.14.0 릴리스 + 포커스 전환 직후 첫 단어(`pc`/`ㅔㅊ`/`ㅖㅊ`/`내ㅔㅊ`) 한영 자동 전환(`INPUT-04`, `INPUT-19`) + 받아쓰기 구어·추임새·중복·동음이의어 후처리 정리 고도화(`AI-03`, `AI-05`).** (1) **포커스 클릭 직후 첫 단어(`pc` 등) 자동 전환:** `InputTelemetryService`에서 마우스 클릭(`_rebaseFocusText`)·창 전환 직후 첫 스냅샷(40~680 ms)이 찍히기 전에 사용자가 곧바로 친 첫 단어(`ㅔㅊ`, `ㅖㅊ` 등)가 `_textAtFocus` 기준선에 삼켜져 `editedSinceFocus = false`가 되던 문제를 `_typedInCurrentFocus`·`_lastTypedHwnd` 추적 및 첫 글자 키 입력 시 포그라운드 창 즉시 샘플링으로 해결하고, `@d3ro/core/typo-correction`에 대소문자 2글자 영문 약어(`ㅔㅊ`/`ㅖㅊ`→`PC`, `ㅐㄴ`/`ㅒㄴ`→`OS`, `ㅔㄱ`/`ㅖㄱ`→`PR`, `ㅊㅑ`→`CI`, `ㅍㅡ`→`VM`, `ㅔㅡ`/`ㅖㅡ`→`PM`, `ㅔㅐ`/`ㅖㅐ`→`PO`, `ㅗㄱ`→`HR`, `ㅑㄱ`→`IR`, `ㅇㅡ`→`DM`, `ㅡㅇ`→`MD`, `ㅔㅇ`/`ㅖㅇ`→`PD`, `ㅍㅔ`/`ㅍㅖ`→`VP`, `ㅠㅡ`→`BM`, `ㅆㅍ`→`TV`, `ㅑㅖ`→`IP`) 및 한글 접두+낱자모 합성어(`내ㅔㅊ`→`내PC`, `회사ㅔㅊ에서`→`회사PC에서`, `한글로ㅔㅊ라고`→`한글로PC라고`, `윈도우ㅐㄴ`→`윈도우OS`, `새ㅁㅔㅑ를`→`새API를`)를 추가했다. (2) **받아쓰기 구어·추임새·말바꾸기·중복·STT 동음이의어 정리:** `@d3ro/core/dictation-cleaner`(`cleanDictatedText`)를 신설해 `VoiceModeService._transcribe` 직후 지연 0 ms로 단독 추임새(`어`, `음`, `그 쓸데없는` 등 — 단 인용된 `어라든가`, `아라든가` 보존), 발화 중 말바꾸기(`검색 아니 검색이 아니라 타이핑을`→`타이핑을`), 상투적 중복(`쓸데없는 의미없는`→`불필요한`, `정리해 가지고 해 주는 거`→`정리해 주는 기능`), 구어 잉여 어미(`예를 들자면은`→`예를 들어`, `보면은`→`보면`), 문맥상 명백한 STT 동음이의어(`스시가 영어로 변경되지`→`PC가 영어로 변경되지`, `그 길을 쓸 이유가`→`그 기능을 쓸 이유가`)를 즉시 정리하고, `BASE_SYSTEM_PROMPTS.refine`(`llm-prompts.ts`), `MeetingModeService.polishTranscript`, 신규 내장 프리셋 `builtin-clean-speech`(`구어·추임새·중복 정리`, `CustomInstructionService.ts`)가 화자의 원래 어투(반말/해요체/합쇼체)를 바꾸지 않고 추임새·말바꾸기·중복·비문만 자연스럽게 다듬도록 업그레이드했다.
>
> Previous update: 2026-10-29 — **v1.13.0 릴리스 + 그래프 관계성 기반 극한 개인화(`INPUT-06`, `INPUT-20`) + 한영 형태론·전방 구문 감지 및 단일-시스콜 초고속 인플레이스 수정(`INPUT-19`, `INPUT-22`) + 전 표면 디자인파카(`designpaca`) 순회 감사(`SHELL-11`, `SHELL-15`).** (1) **그래프 관계성 & 극한 개인화:** `@d3ro/core/personal-graph` 및 `PersonalGraphService`에 앱별 연속 단문 메시지 간 세션 `follows` 체이닝(`_lastIndexedByScope`), 엔터 전송 직후 비워진 채팅창 문맥 복원(`recentWrites`), 증분 `shares_terms` 엣지 연결, 조사 차이 무관 어간 연속 이어쓰기(`stemContinuationsFrom`), 2-홉 그래프 경로 랭킹(`rankTwoHopGraphTargets`), 개인 그래프·어투 일치 기반 LLM 후보 재정렬(`scoreCandidatePersonalization`), 어간 바이그램 폴백 및 빈도 가중 개인 n-gram(`PersonalNgramModel`)을 추가했다(제안 노출 빈도는 그대로 유지). (2) **영어 감지 강화 & 초고속 타이핑 중 무경합 교정:** `@d3ro/core/typo-correction`에 확장 영어 어간(`EXTENDED_ENGLISH_STEMS`, `kubernetes`/`microsoft` 등)과 생산적 접두·접미 파생 형태론(`matchesInflectedOrDerivedEnglish`), 전방 영어 구문 호응(`새 ㅠㄷ `→`to be `, `새 애 this `→`to do this `, `랙 솓 `→`for the ` vs `오늘 새 API를 만들었어` 보존), 영어 축약형·약어(`ㅊ무ㅅ`/`ㅊ무'ㅅ`/`ㅊ무ㅜ'ㅅ`→`can't`, `츤를`→`CMS를`, `눈를`→`SNS를` 등)를 추가하고, `sendWin32UnicodeReplacement`(`utils/win32-unicode-input.ts`)로 `(선택 Space) + N × VK_BACK + M × KEYEVENTF_UNICODE`를 **단일 `SendInput` 시스템콜(`< 0.5 ms`, 대기 `0 ms`)**로 원자적 주입하며, 타이핑 중 추가 입력된 꼬리 글자를 보존하는 델타 리베이싱(`rebaseTypoReplacementPlan`)을 구현했다. (3) `packages/ui`, `apps/web`, `apps/admin`, `apps/desktop/src/renderer`(메인·팝업 6종), `site/`, `apps/mobile-rn` 6개 표면을 전수 순회해 `design.md` 계약 위반을 모두 해소했다 (`npm run check:design` 0건).
>
> Previous update: 2026-10-27 — **v1.11.0 릴리스 + Araso 방식 한영 자동 변환·터미널/Vim/xterm.js 지원 완성 (`INPUT-19`, `GAP-INPUT-08`).** `nyttastudio/araso`를 분석해 `@d3ro/core/araso-layout` 및 `@d3ro/core/typo-correction`을 대폭 업그레이드하고 터미널·Vim·xterm.js(`Agent Switchboard`)까지 확장했다: 영어·약어·CamelCase+한국어 조사/단어 혼합어 분리(`githubdp`→`github에`, `PDFvkdlf`/`ㅖㅇㄹ파일`→`PDF파일`, `Reactzjavhsjsxm`→`React컴포넌트`, `dhsmfdmsgoogledptj`→`오늘은google에서`, `1:1ansdml`→`1:1문의`, 2글자 약어 받침 호응 `TMdms`→`TM은` vs `TMsms`→`쓰는`), 쌍자음 잔여 Shift 정규화(`djEJs`→`어떤`, `qkRNjTdj`→`바꿨어`), 한글 자판 상태 영어/혼합어 역변환(`ㅗ디ㅣㅐ 재깅`→`hello world`, `내ㅡㄷ샤ㅡㄷ`→`sometime`, `ㅎ샤ㅗㅕㅠ에`→`github에`, `ㅠㅕㅎ가`→`bug가`, 알파벳+조사 `ㄴ가`→`s가`, `ㄴ은`→`s은`), 문장 문맥 한영 전환(`Stay hungry, stay foolishsms wkqtmdml akfdlek.`), URL·경로·이메일 보호(`isUrlOrPathRun`), 터미널·Vim 명령(`:ㅈㅂ`→`:wq`, `:ㅂ!`→`:q!`, `퍄ㅡ `→`vim `, Vim 노멀 모드 교정 억제), `SendInput(KEYEVENTF_UNICODE)` 직접 유니코드 타이핑(클립보드 무접촉), 단어 경계(`25ms`)와 어절 내부(`650ms`) 유휴 분리 및 완성형 음절(`[가-힣]`) 한정 `commitComposition`으로 고속 타이핑 시 글자 삼킴·유령 공백·앞글자 중복을 완전히 해소했다. 통계 수집 동의(`inputTelemetryEnabled`)가 꺼져 있어도 기본 기능(`typoAutoCorrectEnabled: true`)으로 즉시 동작한다.
>
@ -13,7 +15,7 @@
> Previous update: 2026-09-22 — **Gemma/Ollama 폭주 방어 계약을 기록했다.** 19:14:12 부팅 워밍업이 `keep_alive: 30m`으로 `gemma4:e4b`를 19:44:12까지 VRAM 3,226,342,521 bytes / context 4096으로 강제 상주시킨 것이 관측됐으며, 같은 시점 Windows GPU Engine PID 표본에는 Ollama의 활성 compute가 없었다. 즉 당시 상태는 무한 추론이 아니라 강제 residency였다. 19:11:17~19:11:58의 자동 제안 연속 생성은 기존 900 ms·12/min·5 candidates·128 tokens·한 글자 재생성 정책이 허용한 burst였다. 현재 구현 계약은 부팅 warmup 제거, `keep_alive: 2m`, 제안 600 ms / 최소 5 s 간격 / 기본 6회·hard max 12회 per min / 3 candidates / 64 tokens / 12-char growth / 8 s timeout, 그리고 요청별 취소·상한·종료 정리다. 독립 표적 검증은 6 test files / 69 tests passed / 0 failed, 변경 코드·테스트 ESLint와 `git diff --check`도 exit 0이다. Raw Ollama에서는 cold bounded 요청이 client hard timeout 15.044 s에 취소된 뒤 `/api/ps`가 비었고 `/api/version`은 80 ms에 회복했다. 명시 warmup은 HTTP 200 / 16.639 s, 후속 warm 요청은 body `options.num_predict=1`, `keep_alive='2m'`로 553 ms HTTP 200 / `done:true` / `eval_count:1` / `done_reason:length`였고 `/api/ps` expiry는 약 119.9 s였다. **19:48:59 +09:00에는 새 generate/unload/kill/retry 없이 충분히 지난 뒤 한 번의 `/api/ps`가 HTTP 200 / 45.8 ms / `{models:[]}`였고 `/api/version`은 HTTP 200 / 7.3 ms / `0.32.13`이었다.** 이는 raw API 수준의 expiry 뒤 unload 확인일 뿐 앱 재시작·GUI·실제 타이핑 증거는 아니므로 상태는 `[~]`로 유지한다 (`11` GAP-LLM-04, GAP-INPUT-06).
>
> Previous update: 2026-09-21 — **Input intelligence (입력 레메트리 + 다음 문장 제안) 신규**. 데스크톱에 입력 수집기(`InputTelemetryService`), UIA 컨텍스트 브리지(사이드카 `GET /uia/focus`), 제안 서비스(`SuggestionService`), 어렛 커 오버레이, 설정 > 입력 탭(동의·정책·주간 인사이트·개인 문구)을 추가했다. 카탈로그에 `INPUT-01`~`INPUT-08`(전부 데스크톱 `[~]` — 유닛 48건은 GREEN 이지만 **실앱 타이핑 검증 전**), 백로그에 GAP-INPUT-01~05 + GAP-LLM-03, §7 에 CONSTRAINT-INPUT-01(키 내용 미저장 — ActivityWatch 정책 채택)을 기록. 설계 근거는 조사 기반이다: 어렛은 `GetGUIThreadInfo` 가 아니라 UIA `TextPattern.GetSelection`(Chromium 은 `TextPattern2` 미구현), 타이핑 스트는 키코드 복원이 아니라 UIA 스냅샷 diff(한/일 IME 대응), 디바운스/토큰 한도는 인라인 컴플리션 실측값(Continue 350 / Tabby 250 / twinny 300 ms, 출력 64~256 토큰). 의존성: `koffi` 3.3.1(포그라운드 창 FFI), 사이드카 `uiautomation` 2.0.29 + `comtypes`. 데스크톱 유닛 총계 1409(+49), Electron ABI 실행에서 신규 실패 0건. 당시의 24.7초/4.9초 지연 설명과 `keep_alive: 30m`·부팅 워밍업 처방은 **현재 상태가 아닌 과거 가설/완화 이력**이며, 최신 운영 결론은 위 2026-09-22 항목과 `11` GAP-LLM-04를 따른다. 직전: LLM instruction-prompt fix (`9c2b4d4`): the custom-instruction path inserted the instruction's own wording instead of the processed result and had **never worked in any shipped release** (`v0.1.0-alpha`..`v1.4.0`, introduced `fea923d` 2026-04-05, not a regression). `llm-prompts.ts` is now the SSOT for prompt resolution and placeholder substitution, shared by `VoiceModeService` / `ChainService` / `LLM.PROCESS`. AI-04/05/06/07 are demoted to `[~]` on desktop — fixed with unit tests, but **not verified in a running app** and the four related `tests/red/*.usecase.test.ts` could not execute (`better-sqlite3` ABI). New: GAP-LLM-01 (no target-language setting), GAP-LLM-02 (this fix unverified); GAP-INFRA-06 amended (the ABI masks verification, not just dev-env switching cost); GAP-I18N-01 amended (`popup.error.default` missing in 10 locales). Earlier the same day: CAP-16 (desktop key bindings rebuilt on one `@d3ro/core/keybinding` SSOT — multiple bindings per action, mouse buttons, `HOTKEY` → `KEYBINDING` IPC group), verified on Windows by a manual run, so CAP-16 and CAP-02 are `[x]` and GAP-KEY-01 is closed. Still open: GAP-KEY-02/03, GAP-QA-02, GAP-I18N-01/02, GAP-INFRA-06, GAP-LLM-01/02, GAP-INPUT-01~05; `11` §7 holds accepted design constraints (things deliberately kept, not gaps)
> Scope: entire monorepo `D:/workspace/D3ROVoice` at product version `1.13.0` (`release/product-version.json`, released 2026-10-29)
> Scope: entire monorepo `D:/workspace/D3ROVoice` at product version `1.14.0` (`release/product-version.json`, released 2026-10-29)
> Purpose: let any agent (or human) answer two questions in under a minute:
> 1. **What infrastructure exists?** (build, CI, services, APIs, data, packages, deploy)
> 2. **How far is each feature developed?** (per surface, with file anchors and status)

View file

@ -18,7 +18,8 @@ The canonical place for types and cross-surface logic. Both desktop and web/mobi
| IPC channels | `./ipc-channels` | `IPC_CHANNELS` object + `IPCChannel` union. **SSOT** for every desktop IPC channel (VOICE, AUDIO, STT, TTS, LLM, KEYBINDING, CONFIG, HISTORY, UNIFIED_SEARCH, DICTIONARY, WINDOW, SYSTEM, STATS, MEMO, VOICE_COMMAND, CONTEXT, CHAIN, CAPTION, FILE_TRANSCRIPTION, MEETING_SUMMARY, DICTATION_TEMPLATE, VOICE_CONVERSATION, RAG, VOICE_ACTION, MEETING_MODE, MEETING_DOC_TEMPLATE, MEETING_CHAT, LICENSE, CLOUD_SYNC, INSTRUCTION, SYSTEM_AUDIO, POPUP_RESULT, POPUP_HISTORY, POPUP_COMMAND, POPUP_CAPTION, VOICE_PARTIAL, CLIPBOARD, APP, ONLINE_AUTH, ADS, SUPPORT, INPUT_TELEMETRY, SUGGESTION, POPUP_SUGGESTION) |
| Key bindings | `./keybinding` | **SSOT** for every global shortcut in the app: `KeyBinding` (`device`/`code`/`ctrl`/`alt`/`shift`/`meta`), `KEY_CATALOG` (10 selectable groups incl. mouse), `KEYBINDING_ACTIONS` (9 rebindable actions incl. the three suggestion actions), `bindingKey`/`normalizeBinding`/`validateBinding`/`detectBindingConflicts`/`formatBindingSegments`/`searchKeyCatalog`/`parseBindingMap`. Persisted as `AppConfig.keyBindings`. i18n keys are exposed as plain `string` so core stays independent of `@d3ro/i18n`; consumers narrow at the boundary (`asTranslationKey`) and a contract test guards the keys — accepted constraint, `11` §7 CONSTRAINT-I18N-01. Tests: `__tests__/keybinding*.test.ts` via `vitest.config.ts` (`npm run test --workspace=@d3ro/core`), 117 cases as of 2026-09-21 |
| Input intelligence | `./input-intelligence` | **SSOT** for the input-telemetry and next-sentence-suggestion domain (added 2026-09-21): key classification (`classifyKeyStroke`), text metrics (`countWords`/`countSentences`/`endsSentence`/`textBeforeCaret`), `computeTypedDelta` (UIA snapshot diff — the IME-safe way to count typed text), `decideSuggestion` + `isAppExcluded` (when to request / skip / clear), `parseSuggestionCandidates`/`sanitizeSuggestionLine` (prompt-leak and prefix-echo defence), `anchorFloatingPanel` (caret-anchored overlay placement), `mergeActivityBucket`/`summarizeActivity`/`pixelsToMeters`, `extractPhrases`/`selectPhraseHints`, `INPUT_TELEMETRY_DEFAULTS`/`SUGGESTION_DEFAULTS` |
| Typo correction & Araso layout | `./typo-correction`, `./araso-layout` | **SSOT** for built-in automatic Han/Eng conversion and typo auto-correction (upgraded 2026-10-28): 2-set Korean/English layout conversion (`engToHangul`/`hangulToEng`), productive English derivational prefixes/suffixes (`matchesInflectedOrDerivedEnglish`, `EXTENDED_ENGLISH_STEMS`), phrase-level lookahead English detection (`TO_FOLLOWING_ENGLISH_WORDS`, `resolveTokenAsEnglishPreview`), lingering Shift normalization (`normalizeLingeringShift`/`lingersAfterKoreanShift`), mixed-word splitting with Korean particle batchim agreement (`splitMixedWord`/`particleAgrees`), reverse Hangul-to-English/mixed restoration, URL/path/email run protection (`isUrlOrPathRun`), deterministic spelling & jamo-noise rules (`detectTypos`/`detectJamoNoise`), delta-rebasing for in-flight typing (`rebaseTypoReplacementPlan`), and LLM typo validation (`validateModelCorrections`). |
| Typo correction & Araso layout | `./typo-correction`, `./araso-layout` | **SSOT** for built-in automatic Han/Eng conversion and typo auto-correction (upgraded 2026-10-29): 2-set Korean/English layout conversion (`engToHangul`/`hangulToEng`), shifted/unshifted 2-letter loose-jamo acronyms (`ㅔㅊ`/`ㅖㅊ`→`PC`, `ㅐㄴ`/`ㅒㄴ`→`OS`, `ㅔㄱ`/`ㅖㄱ`→`PR`, `ㅊㅑ`→`CI`, `ㅍㅡ`→`VM`, `ㅔㅡ`→`PM`, `ㅔㅐ`→`PO`, `ㅗㄱ`→`HR`, `ㅑㄱ`→`IR`, `ㅇㅡ`→`DM`, `ㅡㅇ`→`MD`, `ㅔㅇ`→`PD`, `ㅍㅔ`→`VP`, `ㅠㅡ`→`BM`, `ㅆㅍ`→`TV`, `ㅑㅖ`→`IP`) and Korean-prefix + loose-jamo compounds (`내ㅔㅊ`→`내PC`, `회사ㅔㅊ에서`→`회사PC에서`, `한글로ㅔㅊ라고`→`한글로PC라고`), productive English derivational prefixes/suffixes (`matchesInflectedOrDerivedEnglish`, `EXTENDED_ENGLISH_STEMS`), phrase-level lookahead English detection (`TO_FOLLOWING_ENGLISH_WORDS`, `resolveTokenAsEnglishPreview`), lingering Shift normalization (`normalizeLingeringShift`/`lingersAfterKoreanShift`), mixed-word splitting with Korean particle batchim agreement (`splitMixedWord`/`particleAgrees`), reverse Hangul-to-English/mixed restoration, URL/path/email run protection (`isUrlOrPathRun`), deterministic spelling & jamo-noise rules (`detectTypos`/`detectJamoNoise`), delta-rebasing for in-flight typing (`rebaseTypoReplacementPlan`), and LLM typo validation (`validateModelCorrections`). |
| Dictation cleaner | `./dictation-cleaner` | **SSOT** for deterministic zero-latency speech disfluency & dictation cleanup (`cleanDictatedText`, added 2026-10-29): strips standalone spoken fillers (`어`, `음`, `그 쓸데없는` while preserving quoted mentions like `어라든가`, `아라든가` and demonstratives), mid-sentence self-corrections (`X 아니 X이 아니라 Y` → `Y`), word stutters (`내가 내가` → `내가`), colloquial suffixes (`예를 들자면은` → `예를 들어`, `보면은` → `보면`), redundant expressions (`쓸데없는 의미없는` → `불필요한`), and clear contextual STT homophones (`스시가 영어로 변경되지` → `PC가 영어로 변경되지`, `그 길을 쓸 이유가` → `그 기능을 쓸 이유가`) while preserving speaker register. |
| Personal graph & n-gram | `./personal-graph`, `./personal-ngram` | **SSOT** for relational personalization and n-gram continuation (upgraded 2026-10-28): exact & particle-invariant stemmed continuations (`continuationsFrom`/`stemContinuationsFrom`), IDF-weighted related node scoring (`scoreRelatedNodes`), 2-hop graph path ranking (`rankTwoHopGraphTargets` across `shares_terms→follows` and `follows→follows`), personalized candidate reranking (`scoreCandidatePersonalization`), and frequency-weighted n-gram indexing with Korean stemmed-word bigram fallback (`PersonalNgramModel`). |
| Constants | `./constants` | Shared constants |
| Crypto license | `./utils/crypto-license` | Ed25519 license sign/verify (used by admin issuer + desktop verifier) |

View file

@ -83,7 +83,7 @@ Singleton + `EventEmitter` pattern (`getXService()` accessors).
### Input intelligence (2026-09-21; Local Flow Intelligence extension 2026-09-22)
| Service / file | Purpose |
|---|---|
| `InputTelemetryService` | Global input telemetry and context observer: keystroke/click/scroll counters, mouse travel (Manhattan sum of per-axis deltas), active time, per-hour-per-app buckets flushed every 5 s; typed-text learning via UIA snapshot diffs. **Since 2026-10-26**, the UIA context observer runs by default whenever `typoAutoCorrectEnabled !== false` (or `suggestionEnabled === true`), while SQLite `input_activity` persistence only runs when `inputTelemetryEnabled === true` (opt-in). **Since 2026-10-27**, includes `TerminalKeystrokeTracker` (`@d3ro/core/input-intelligence`) + `isForegroundKoreanIme` (`utils/win32-foreground.ts`) to reconstruct the active terminal/Vim line (`reconcileWithScreen` for UIA screen buffers like Windows Terminal/pwsh/cmd, `reconcileWithXtermValue` for `xterm.js` `<textarea class="xterm-helper-textarea">` controls in Agent Switchboard/VS Code/Cursor where `.value` stays populated until Enter/Ctrl+C, and `getSnapshot` for canvas/remote terminals with `len=0` like Kitedesk/WezTerm/Alacritty), preserving trailing spaces stripped by grid terminals and tracking Vim modes (`insert`, `normal`, `command`). Programmatic keys (`_programmaticKeys`) no longer advance `_lastKeyAt`, and `Enter`-triggered chat submissions that clear or shrink the input field rebase focus text immediately so cleared/toolbar text does not trigger post-send suggestions. It extends the telemetry store with Flow Radar (hourly activity density + chars + edit stability; a potential-focus score, **not** a real session), Edit Friction (chars/backspaces; edits per 100 chars), App Quality (per-app suggestion total/accepted/accept rate/average latency), Privacy Receipt (actual row counts and retention), and Smart Exclusion evidence. Raw key events, key codes and content streams are never retained; separately, opt-in learned text may be retained in `typing_samples` and `personal_phrases` under the stated receipt policy. |
| `InputTelemetryService` | Global input telemetry and context observer: keystroke/click/scroll counters, mouse travel (Manhattan sum of per-axis deltas), active time, per-hour-per-app buckets flushed every 5 s; typed-text learning via UIA snapshot diffs. **Since 2026-10-26**, the UIA context observer runs by default whenever `typoAutoCorrectEnabled !== false` (or `suggestionEnabled === true`), while SQLite `input_activity` persistence only runs when `inputTelemetryEnabled === true` (opt-in). **Since 2026-10-27**, includes `TerminalKeystrokeTracker` (`@d3ro/core/input-intelligence`) + `isForegroundKoreanIme` (`utils/win32-foreground.ts`) to reconstruct the active terminal/Vim line (`reconcileWithScreen` for UIA screen buffers like Windows Terminal/pwsh/cmd, `reconcileWithXtermValue` for `xterm.js` `<textarea class="xterm-helper-textarea">` controls in Agent Switchboard/VS Code/Cursor where `.value` stays populated until Enter/Ctrl+C, and `getSnapshot` for canvas/remote terminals with `len=0` like Kitedesk/WezTerm/Alacritty), preserving trailing spaces stripped by grid terminals and tracking Vim modes (`insert`, `normal`, `command`). Programmatic keys (`_programmaticKeys`) no longer advance `_lastKeyAt`, and `Enter`-triggered chat submissions that clear or shrink the input field rebase focus text immediately so cleared/toolbar text does not trigger post-send suggestions. **Since 2026-10-29**, tracks `_typedInCurrentFocus` and `_lastTypedHwnd` and forces immediate foreground sampling on the first keystroke after a mouse click (`_rebaseFocusText`) or window switch, so typing `pc` (`ㅔㅊ`) immediately after clicking into a search box or new field sets `editedSinceFocus = true` on the very first snapshot. It extends the telemetry store with Flow Radar (hourly activity density + chars + edit stability; a potential-focus score, **not** a real session), Edit Friction (chars/backspaces; edits per 100 chars), App Quality (per-app suggestion total/accepted/accept rate/average latency), Privacy Receipt (actual row counts and retention), and Smart Exclusion evidence. Raw key events, key codes and content streams are never retained; separately, opt-in learned text may be retained in `typing_samples` and `personal_phrases` under the stated receipt policy. |
| `TypoCorrectionService` | Built-in automatic Han/Eng layout conversion and typo auto-correction (`INPUT-19`). Runs on each `typed-context`: Araso-style layout conversions (`source: 'layout'`) fire after 25 ms on word boundaries (Space/punctuation, 40 ms quick snapshot) or 135 ms at token tail (150 ms quick snapshot, even when Chromium/Discord keeps `isComposing=true`, committing IME composition first only when the trailing character is Hangul/jamo), replacing 2-set Han/Eng layout errors, mixed English+Korean words (`githubdp`→`github에`, `PDFvkdlf`→`PDF파일`, `ㅖㅇㄹ파일`→`PDF파일`), lingering Shift on double consonants (`djEJs`→`어떤`), reverse Hangul-to-English (`ㅎ샤ㅗㅕㅠ에`→`github에`, `ㅑㄹ ㅑ 쇼ㅔㄷ ㅗ디ㅣㅐ 소두 ㅑㅅ 초뭏ㄷㄴ ㅑㅜ 10 ㄴㄷ채ㅜㅇㄴ`→`if I type hello then it changes in 10 seconds`), lookahead English clauses (`새 ㅠㄷ `→`to be `, `새 애 this `→`to do this `), and partially-converted tokens (`안녕gktpdy`→`안녕하세요`). **In terminals and Vim (`terminalMode: true`)**, layout-only conversion stays active while spelling/model checks are suppressed: converts CLI commands (`퍄ㅡ `→`vim `, `ㅜ퍄ㅡ `→`nvim `, `ㅎ샤 `→`git `, `ㅣㄴ `→`ls `, `채ㅜㄴㅅ `→`const `), Vim Insert-mode typing (stripping leading `i/a/o/I/A/O/s/S` mode-entry keys when present in raw keystroke buffers), and Vim Command-line ex-commands (`:ㅈㅂ`→`:wq`, `:ㅈㅂ!`→`:wq!`, `:ㅈ`→`:w`, `:ㅂ`→`:q`, `:ㅂ!`→`:q!`, `:ㅌ`→`:x`, `:ㅍ네`→`:vsp`, `:네`→`:sp`, `:ㅜㅐㅗ`→`:noh`, preserving `:`), while blocking all conversions in Vim Normal mode (`vimMode === 'normal'`). **Since 2026-10-28**, on Windows, `TextInsertService.replaceBeforeCaret` (`method === 'keyboard'`) executes an atomic single-syscall `sendWin32UnicodeReplacement` (`utils/win32-unicode-input.ts`) packing `(optional VK_SPACE) + N × VK_BACK + M × KEYEVENTF_UNICODE` into one `SendInput` call (`<0.5 ms`, zero JS sleep, zero clipboard access), and `TypoCorrectionService` delta-rebases replacement plans (`rebaseTypoReplacementPlan`) when the user appends characters while an async snapshot or LLM check is in flight. Both Stage 1 (deterministic layout/spelling) and Stage 2 (tail-anchored `trailingWordOnly: true` Gemma check) run seamlessly even when `SuggestionService` is enabled. |
| `UiaContextService` | Client for the sidecar UIA bridge (`GET /uia/focus`): focused text, caret rect/offset, `IsPassword`, IME composition state and `hasSelection`. The sidecar derives `hasSelection` only by comparing the TextPattern selection range Start/End endpoints: it does not call `GetText` on that range or add a separate selected-text payload (the existing focused-field text can still include a selection). Fail-closed on password/unavailable; transient failures back off for 1.5/3/6/12/30 s and permanent failures for 5 min. |
| `SuggestionService` | Next-sentence ghost text: 600 ms debounce, then `buildSuggestionPrompt` → `LocalLLMService.streamGenerate` with a caller-owned `AbortSignal` → candidate ranking and accept (via `TextInsertService`). Presentation-active includes candidates plus `generating`, `warmingUp` and `partialText`; clear/dismiss aborts the active request, invalidates its generation token, clears TTL state, then emits `cleared`/hide so a spinner-only popup closes. A successful final candidate payload resets `generating=false` and `partialText=null`. App DNA extends phrase ranking with `appName` context and a 1.75× same-app bonus; Memory Decay uses a 30-day half-life plus frequency. Why This Suggestion exposes only `local-model`/`local-memory` provenance and continuation/related/phrase/appPhrase **counts** to the overlay, never raw evidence text. Instant Recall uses local-memory provenance without another model-budget spend only when the model is unavailable, raises a non-cancellation error, truly times out, or returns empty; it never publishes after dismiss, new typing, token/context mismatch or staleness. Its runaway limits are a 5 s minimum interval, 6 requests/min default (hard-config maximum 12), 3 candidates, 64 output tokens, 12-character regeneration growth and an 8 s timeout; app startup does not warm the model and suggestion requests use `keep_alive: 2m`. |

File diff suppressed because one or more lines are too long