release: ship v1.5.0 with on-device writing suggestions
Some checks failed
deploy-site / deploy (push) Failing after 33s
portable-unsigned / portable-windows (push) Failing after 4m7s
release / release-windows (push) Failing after 3m16s

Adds next-sentence suggestions while typing, weekly input insights and a
personal phrase memory to the desktop app, and fixes custom instructions so
they process the text instead of inserting the instruction's own wording.
Local model requests are now bounded and individually cancellable.

Bumps the product version to 1.5.0 (Android/iOS build 1050000), refreshes the
landing and web download links, and records the new INPUT feature rows and the
open verification gaps in the infrastructure map.
This commit is contained in:
Yun Chan 2026-09-23 16:04:27 +09:00
parent 99f06c253c
commit 5c11ee2fde
104 changed files with 14410 additions and 174 deletions

View file

@ -0,0 +1,222 @@
// packages/core — 개인 그래프(관계형 개인화) 정본.
//
// 왜 그래프인가:
// n-gram 문자열 조회(1단계)는 "같은 꼬리 뒤에 이어 쓴 문장" 만 찾는다. 하지만 사용자의
// 글은 관계로 이어진다 — 어떤 문장은 늘 다른 문장 뒤에 오고("follows"), 어떤 문장들은
// 같은 용어를 공유한다("shares_terms"). 그 관계를 저장해 두면 접두가 조금 달라도
// 관련 문맥을 끌어올 수 있다.
//
// 전부 순수 함수로 두어 LLM/DB 없이 검증 가능하게 한다.
import { countWords } from './input-intelligence'
import type { PhraseSource } from './input-intelligence'
// 렌더러/프리로드도 같은 계약을 쓴다 (main 모듈을 import 할 수 없다).
export type { PhraseSource }
/** 그래프 노드 = 사용자의 문장 하나. */
export interface GraphNode {
text: string
terms: string[]
source: PhraseSource
appName: string | null
count: number
lastUsedAt: number | null
}
export type GraphEdgeKind = 'follows' | 'shares_terms'
/** 그래프 엣지 = 두 문장의 관계. */
export interface GraphEdge {
from: string
to: string
kind: GraphEdgeKind
weight: number
}
/** 그래프 통계 (지식베이스 그래프 탭). */
export interface PersonalGraphStats {
nodes: number
followsEdges: number
sharesTermsEdges: number
/** 가장 강한 follows 엣지 (A → B) */
topEdges: Array<{ from: string; to: string; kind: string; weight: number }>
/** 최근 노드 */
recentNodes: Array<{ text: string; terms: string[]; count: number; appName: string | null }>
}
/** 특정 텍스트 주변 그래프 조회 결과. */
export interface PersonalGraphQuery {
anchors: Array<{ text: string; terms: string[]; count: number }>
neighbors: Array<{ text: string; kind: string; weight: number }>
}
export interface GraphContext {
/** 접두 꼬리 뒤에 실제로 이어 쓴 텍스트 (가장 강한 신호) */
continuations: string[]
/** 관계로 끌어온 관련 문장 (follows 우선, 그다음 용어 공유) */
related: string[]
}
/** 용어 추출에서 제외할 불용어 (한/영 최소 집합). */
const STOPWORDS: ReadonlySet<string> = new Set([
'그리고',
'그러나',
'하지만',
'그래서',
'저는',
'제가',
'이거',
'그거',
'저거',
'있습니다',
'합니다',
'입니다',
'the',
'and',
'for',
'with',
'that',
'this',
'from',
'have',
'will',
'your',
'you',
'are',
'was',
'were',
'not',
'but'
])
/** 최소 길이 (1~2자 토큰은 노이즈가 많다). */
const MIN_TERM_CHARS = 2
/**
* 문장에서 비교용 용어를 뽑는다.
*
* 소문자화 → 문자/숫자 경계로 분리 → 불용어/짧은 토큰 제거 → 빈도 순.
*/
export function extractTerms(text: string, limit = 8): string[] {
const tokens = text
.toLowerCase()
.split(/[^0-9a-z\uac00-\ud7a3\u3040-\u30ff\u4e00-\u9fff]+/u)
.filter((token) => token.length >= MIN_TERM_CHARS)
.filter((token) => !STOPWORDS.has(token))
const frequency = new Map<string, number>()
for (const token of tokens) {
frequency.set(token, (frequency.get(token) ?? 0) + 1)
}
return [...frequency.entries()]
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
.slice(0, limit)
.map(([token]) => token)
}
/** 문장 단위로 쪼갠다 (종결 부호 + 개행). 2단어 이상만 남긴다. */
export function splitSentences(text: string): string[] {
return text
.split(/[.!?。!?…\n]+/u)
.map((segment) => segment.replace(/\s+/gu, ' ').trim())
.filter((segment) => segment.length >= 4 && countWords(segment) >= 2)
}
/** 한 텍스트 안에서 인접한 문장 쌍 (follows 엣지의 근거). */
export function buildSequenceEdges(sentences: readonly string[]): Array<{ from: string; to: string }> {
const edges: Array<{ from: string; to: string }> = []
for (let index = 0; index + 1 < sentences.length; index += 1) {
const from = sentences[index]
const to = sentences[index + 1]
if (from === to) continue
edges.push({ from, to })
}
return edges
}
/** 자카드 유사도 — 두 용어 집합이 얼마나 겹치는가 (0~1). */
export function jaccard(a: readonly string[], b: readonly string[]): number {
if (a.length === 0 || b.length === 0) return 0
const setA = new Set(a)
const setB = new Set(b)
let intersection = 0
for (const term of setA) {
if (setB.has(term)) intersection += 1
}
const union = setA.size + setB.size - intersection
return union === 0 ? 0 : intersection / union
}
/** 용어 공유 엣지로 볼 최소 자카드. */
export const SHARES_TERMS_MIN_SIMILARITY = 0.34
/**
* 접두 꼬리 뒤에 실제로 이어 쓴 텍스트를 뽑는다.
*
* `texts` 는 꼬리를 포함하는 후보 문장들(최신순)이다.
*/
export function continuationsFrom(
texts: readonly string[],
tail: string,
limit = 3,
maxChars = 60
): string[] {
const needle = tail.trim()
if (needle.length < 4) return []
const out: string[] = []
for (const text of texts) {
const index = text.indexOf(needle)
if (index < 0) continue
const continuation = text
.slice(index + needle.length)
.replace(/\s+/gu, ' ')
.trim()
if (continuation.length < 3) continue
const clipped = continuation.slice(0, maxChars)
if (out.includes(clipped)) continue
out.push(clipped)
if (out.length >= limit) break
}
return out
}
export interface RelatedCandidate {
text: string
terms: readonly string[]
/** 엣지 가중치 합 (follows 가중치가 더 크게 반영된다) */
weight: number
lastUsedAt: number | null
}
/**
* 관련 문장 순위를 매긴다.
*
* 점수 = 엣지 가중치 + 용어 유사도 + 최근성 보너스.
* 이미 접두에 포함된 문장(후보 자신)은 제외한다.
*/
export function rankRelated(
anchorTerms: readonly string[],
candidates: readonly RelatedCandidate[],
limit = 4
): string[] {
const scored = candidates
.map((candidate) => {
const similarity = jaccard(anchorTerms, candidate.terms)
const recency = candidate.lastUsedAt
? Math.max(0, 1 - (Date.now() - candidate.lastUsedAt) / (7 * 86400000))
: 0
return { text: candidate.text, score: candidate.weight * 1.0 + similarity * 2.0 + recency * 0.5 }
})
.sort((a, b) => b.score - a.score)
const out: string[] = []
for (const item of scored) {
if (out.includes(item.text)) continue
out.push(item.text)
if (out.length >= limit) break
}
return out
}