Files
fanlusky a7779d2b05 refactor(engine): 将 engine 从 submodule 内嵌为仓内一等组件
`vendor/MetasequoiaImeEngine` submodule 改为 `engine/` 目录,导入的是
product-lock.json 原本钉住的提交 c810d201,逐文件核对过 blob,因此这是一次
搬迁而不是引擎升级。引擎自己的嵌套 submodule(googlepinyinime-rev、utfcpp、
miniaudio)按各自 gitlink 一并展开,来源与提交见 engine/UPSTREAM.md。

Windows 专门化裁掉了不属于本产品的部分:whisper.cpp 与本地推理 provider、
macOS 示例宿主、整个 dictionary/ 建库流水线、上游 CI 与 release-please 配置。
词库仍按 product-lock.json 在构建时取发布产物。

引擎不再进 product-lock.json:没有 gitlink 就没有可比对的东西,锁里写一个上游
commit 等于宣称这棵树仍等于上游,而第一个 Windows 专门化改动落地时这句话就假了。
verify-contracts / verify-checkout 随之移除,verify-published 保留。

CI 与工具链:引擎源码并入根 scripts/format.sh(删掉引擎自己的那份,避免两套排除
列表分叉);引擎 voice.yml 里的 silero_vad.onnx 摘要校验移到本仓 lock job;
engine-bump-triage 工作流与其测试删除;gitsubmodule 的 dependabot 频率由 daily
改为 monthly。

README、README.en、AGENTS.md、CONTRIBUTING、docs/product-release.md 及各子目录
文档同步说明新的位置与边界。
2026-09-12 03:40:48 +08:00

61 lines
2.6 KiB
C++

#pragma once
#include "../../core/runtime_paths.h"
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
namespace metasequoia
{
enum class PersonalDictionaryKind
{
Pinyin,
Wubi,
QuickPhrase,
English
};
struct PersonalDictionaryEntry
{
PersonalDictionaryKind kind = PersonalDictionaryKind::Pinyin;
// Pinyin uses complete syllables separated by apostrophes (spaces and capitals are normalized).
// Wubi uses 1..4 letters; quick phrases use 1..32 letters/digits; English uses 1..64 letters.
std::string key;
std::string value;
std::int64_t weight = 100000;
};
struct PersonalDictionaryValidation
{
std::optional<PersonalDictionaryEntry> entry;
std::string error;
};
PersonalDictionaryValidation validate_personal_dictionary_entry(PersonalDictionaryEntry entry);
struct PersonalDictionaryEditResult
{
bool success = false;
std::string error;
};
// Add (previous=null), remove (replacement=null), or replace an entry and its replay journal in
// one attached-database transaction. Replacement may change kind. An expected previous entry
// must still be a user-inserted entry with the same weight; stale edits leave all entries intact.
// Quiesce/recreate sessions around writes to invalidate candidate/query caches. As with candidate
// edits, SQL/commit failures roll back; WAL mode does not guarantee cross-file power-loss atomicity.
// Hosts handing edits across processes can supply a durable request ID (1..128 ASCII letters,
// digits, hyphens/underscores). Retrying the same normalized edit is a no-op success; reusing an
// ID for different content fails. The receipt commits in the same transaction as the edit.
PersonalDictionaryEditResult edit_personal_dictionary(const RuntimePaths &paths,
const std::optional<PersonalDictionaryEntry> &previous,
const std::optional<PersonalDictionaryEntry> &replacement,
const std::string &request_id = {});
struct PersonalDictionaryPage
{
std::vector<PersonalDictionaryEntry> entries;
bool has_more = false;
std::string error;
};
// Lists user-inserted words (including automatically created words), excluding ranking-only
// operations and deleted entries. Stable kind/key/value ordering; limit 1..1000, offset <= 1000000.
PersonalDictionaryPage personal_dictionary_entries(const RuntimePaths &paths, std::size_t offset = 0,
std::size_t limit = 100);
} // namespace metasequoia