Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
71cbb36
feat: 添加统一内容轨导航
taekchef Jul 9, 2026
45f509e
fix: 让内容轨悬浮于原边界
taekchef Jul 9, 2026
2710990
feat: add sourced empty workspace launcher
taekchef Jul 9, 2026
8a172fe
fix: 保持分栏切换连续
taekchef Jul 10, 2026
735c69a
merge: integrate empty workspace launcher
taekchef Jul 10, 2026
513a761
feat: add empty workspace to stable pane host
taekchef Jul 10, 2026
27db8b1
feat: polish empty workspace and compact content rail
taekchef Jul 10, 2026
0151b1c
fix: anchor content rail ticks from the left
taekchef Jul 10, 2026
b210527
fix: make content rail hover precise
taekchef Jul 10, 2026
77f802e
fix: match content rail distance wave
taekchef Jul 10, 2026
dd66f64
fix: keep content rail off pane dividers
taekchef Jul 10, 2026
2dc6255
fix: keep divider drags out of window movement
taekchef Jul 10, 2026
8273266
feat: expand offline inspiration catalog
taekchef Jul 10, 2026
24e58ee
feat: embed PI as WeiBei study agent
taekchef Jul 10, 2026
e54d972
fix: keep workspace entries fixed during inspiration changes
taekchef Jul 10, 2026
3e7325b
fix: center empty workspace when inspiration is hidden
taekchef Jul 10, 2026
3728839
feat: add course-aware study memory
taekchef Jul 10, 2026
006c541
fix: keep empty workspace hover active in preview windows
taekchef Jul 10, 2026
1399ef6
fix: unify content rail collapse and preview states
taekchef Jul 11, 2026
244d58b
feat: add persistent course agent index
taekchef Jul 11, 2026
df86c88
fix: make dormant content rails useful
taekchef Jul 11, 2026
408c1d0
fix: tighten dormant rail restoration
taekchef Jul 11, 2026
a5720fd
merge: integrate latest agent and workspace checkpoints
taekchef Jul 11, 2026
5b4fd5a
feat: unify note sources and restore pure writing
taekchef Jul 11, 2026
366892c
feat: add course workspace management
taekchef Jul 12, 2026
1fbc755
feat: refine course home navigation
taekchef Jul 14, 2026
aaf13e5
fix: preserve Pi startup cancellation
taekchef Jul 14, 2026
d032fea
fix: extend Pi startup readiness window
taekchef Jul 14, 2026
ea81cd7
fix: refine empty workspace composition
taekchef Jul 14, 2026
fbf2ec8
Merge pull request #2 from taekchef/codex/pi-reliability
taekchef Jul 14, 2026
d905ac5
Merge pull request #3 from taekchef/codex/empty-workspace-followup
taekchef Jul 14, 2026
2e1d26e
恢复空工作区灵感内容的视觉层级 (#4)
taekchef Jul 14, 2026
385d290
chore: add release guardrails
taekchef Jul 15, 2026
09520e5
ci: use current macOS toolchain
taekchef Jul 15, 2026
80ffbe2
ci: verify Pi terminal semantics when available
taekchef Jul 15, 2026
8828b71
Merge pull request #10 from taekchef/codex/release-guardrails
taekchef Jul 15, 2026
6f79c14
fix: preserve Pi terminal errors and cancellation
taekchef Jul 15, 2026
aaff7c5
Merge pull request #11 from taekchef/codex/pi-terminal-correctness
taekchef Jul 15, 2026
7b63ee3
ci: make release checks unambiguous
taekchef Jul 15, 2026
99701d6
Merge pull request #12 from taekchef/codex/release-guardrails-finalize
taekchef Jul 15, 2026
7ee57a7
feat: preserve imported file identity across moves
taekchef Jul 15, 2026
fdba7ed
fix: make imported identity recovery lossless
taekchef Jul 15, 2026
7716410
Merge pull request #13 from taekchef/codex/stable-imported-item-identity
taekchef Jul 15, 2026
598d8f0
fix: keep rapid note switches visible
taekchef Jul 15, 2026
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
37 changes: 37 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## 这次解决什么

关联任务:#

<!-- 用产品语言说明用户会得到什么。 -->

## 实际改动

-

## 明确没做

-

## 分支与共享文件

- [ ] 本分支从当时最新的 `origin/codex/course-workspace` 创建
- [ ] 开工当天已推送并建立草稿合并请求
- [ ] 未整体合入、变基或批量挑取旧功能分支 / 救援分支
- 共享核心文件占用:无 / 请列出文件、对应任务和释放条件

## 验证证据

<!-- 写真实命令和结果;不要只写“已测试”。不适用的项目说明原因。 -->

- [ ] `swift build`
- [ ] `swift run WeiBeiSelfCheck`
- [ ] `swift run WeiBeiWebEditorCheck`
- [ ] 界面改动已完成真实窗口验收
- [ ] 发布链路改动已运行 `./script/build_and_run.sh package`
- [ ] 发布链路改动已运行 `./script/verify_release_metadata.sh --require-clean`

## 交给整合任务

- [ ] 改动范围单一,工作树干净,分支已推送
- [ ] 风险、依赖和后续动作已写清
- [ ] 我没有自行合并、创建标签或发布正式安装包
56 changes: 56 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 魏碑合并请求检查

on:
pull_request:
branches:
- codex/course-workspace
- main
push:
branches:
- main
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build-check-package:
name: 编译、自检与安装包追溯
runs-on: macos-26
timeout-minutes: 45

steps:
- name: 取出完整源码历史
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: 记录构建工具链
run: |
swift --version
xcodebuild -version

- name: 编译
run: swift build

- name: 运行应用自检
run: swift run WeiBeiSelfCheck

- name: 运行 Pi 终止语义自检
run: WEIBEI_PI_TERMINAL_SELF_CHECK_ONLY=1 swift run WeiBeiSelfCheck

- name: 运行编辑器自检
run: swift run WeiBeiWebEditorCheck

- name: 生成可追溯安装包
run: ./script/build_and_run.sh package

- name: 校验版本、构建号与提交来源
run: ./script/verify_release_metadata.sh --require-clean

- name: 校验安装包签名
run: /usr/bin/codesign --verify --deep --strict "dist/魏碑.app"
42 changes: 42 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 魏碑 Agent 开发与发布规则

本文件适用于整个仓库。用户已授权把这些规则作为长期流程约束;所有 Agent 和新任务都必须遵守。

## 分支与合并请求

1. `codex/course-workspace` 是唯一开发整合线,`main` 只接收整合线验收通过的版本。
2. 每个新任务先拉取远端,再从最新 `origin/codex/course-workspace` 创建一个短分支 `codex/<任务名>`。普通功能任务不得直接在整合线或 `main` 上开发。
3. 一个任务只对应一个分支、一个工作目录和一个合并请求。开始工作的当天必须推送分支,并建立目标为 `codex/course-workspace` 的草稿合并请求;不能把未推送的本地工作目录当作长期成果保存处。
4. 旧功能分支和救援分支只可用于取证。禁止把旧分支整体 merge、rebase 或批量 cherry-pick 到当前开发线。需要复用旧成果时,必须从最新整合线开新分支,只迁移经过审查的最小改动,并重新完成验证。

## 共享核心文件占用

以下位置默认属于共享核心面:

- `Sources/WeiBei/Stores/WorkspaceStore.swift`
- `Sources/WeiBei/App/WeiBeiApp.swift`
- `Sources/WeiBei/Views/ContentView.swift`
- `Sources/WeiBei/Views/StableDocumentWorkspace.swift`
- `Sources/WeiBeiSelfCheck/main.swift`
- `Package.swift`
- `script/`
- `.github/`
- `VERSION`

修改共享核心面之前,必须在任务对应的 issue 或草稿合并请求中写明“占用文件、负责人任务、预计释放条件”。同一文件同一时间只能由一个活跃任务占用;发现已有占用时,停止修改并交由整合任务协调,不得在另一条分支上并行改出第二套实现。

## 权限边界

- 只有明确标记为“整合”或“发布”的任务可以合并合并请求、更新 `codex/course-workspace`、把整合线合入 `main`、创建标签、发布版本或上传正式安装包。
- 功能任务可以生成本地安装包做验收,但不得把它当作正式发布物,也不得自行合并自己的合并请求。
- 不绕过自动检查,不用回退实现伪造通过结果;检查失败必须修复或明确记录真实阻塞。

## 完成定义

任务只有同时满足下列条件才算完成:

1. 需求范围内的实现和必要文档已经完成,没有混入无关改动。
2. 已运行与风险相称的构建、自检和真实体验验收;界面改动必须有真实窗口证据,发布链路改动必须验证安装包元数据和签名。
3. 草稿合并请求已更新,写清实际改动、未做内容、共享文件占用、验证命令和结果。
4. 分支已推送,工作树干净,成果不只存在于本地或临时目录。
5. 已把合并风险和后续动作交给整合任务;只有整合任务可以宣布已合并或已发布。
11 changes: 11 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Domain Context

- **Course workspace**: The current collection of materials, notes, relations, study sessions, and learning memory. It is the Agent's durable scope; it is not the currently open file.
- **Material**: A source document used as course evidence, such as a PDF, HTML page, text file, or non-notebook Markdown file.
- **Notebook**: A user-editable course note. A notebook can be linked to many materials, and a material can be linked to many notebooks.
- **Note-source link**: A durable relation saying that a notebook uses or discusses a material. Opening a file does not create this relation.
- **Study location**: Observed navigation state for a material, including its last PDF page or stable HTML section id, section title, and visit time. It is recorded by the app rather than inferred by the model.
- **Learning memory**: Durable user learning state such as goals, understood concepts, confusions, next steps, and preferences. Every entry keeps its origin and evidence; it is not course-source evidence. An active memory can be resolved only from an explicit current-turn user statement or demonstrated performance in the current conversation.
- **Study session**: A recoverable conversation around a learning goal. Sessions persist across material navigation and own all messages, a rolling summary, bounded earlier-turn excerpts, focus items, and the suggested study phase. PI runs are clean; WeiBei injects this durable continuity every turn.
- **Study flow**: A flexible phase suggestion for orienting, exploring, close reading, note-making, recall, consolidation, or planning. The user can move between phases at any time.
- **Course search index**: A local persistent full-text index. PDF text layers are extracted in a separately monitored helper with CPU, resident-memory, output, and timeout limits; scanned pages are then OCRed incrementally. Truncated or failed pages are terminal partial evidence until the source file changes, so incomplete indexing is exposed instead of retried on every question or treated as a complete search.
20 changes: 18 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ let package = Package(
products: [
.executable(name: "WeiBei", targets: ["WeiBei"]),
.executable(name: "WeiBeiSelfCheck", targets: ["WeiBeiSelfCheck"]),
.executable(name: "WeiBeiWebEditorCheck", targets: ["WeiBeiWebEditorCheck"])
.executable(name: "WeiBeiWebEditorCheck", targets: ["WeiBeiWebEditorCheck"]),
.executable(name: "WeiBeiPiCheck", targets: ["WeiBeiPiCheck"]),
.executable(name: "WeiBeiPDFTextWorker", targets: ["WeiBeiPDFTextWorker"])
],
targets: [
.target(
name: "WeiBeiCore",
resources: [
.copy("AgentResources")
],
linkerSettings: [
.linkedFramework("AppKit"),
.linkedFramework("PDFKit"),
.linkedFramework("Security"),
.linkedFramework("Vision")
.linkedFramework("Vision"),
.linkedLibrary("sqlite3")
]
),
.executableTarget(
Expand Down Expand Up @@ -49,6 +55,16 @@ let package = Package(
.linkedFramework("AppKit"),
.linkedFramework("WebKit")
]
),
.executableTarget(
name: "WeiBeiPiCheck",
dependencies: ["WeiBeiCore"]
),
.executableTarget(
name: "WeiBeiPDFTextWorker",
linkerSettings: [
.linkedFramework("PDFKit")
]
)
]
)
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

| | |
| --- | --- |
| 资料 | 导入 HTML、PDF、Markdown、纯文本 |
| 资料 | 导入单个文件或整个课程目录;支持 HTML、PDF、Markdown、纯文本 |
| 阅读 | HTML(WebKit)、PDF(PDFKit,连续或单页,`⌘[` / `⌘]`)、Markdown 渲染 |
| 笔记 | 绑当前资料,存本机;Milkdown 原地编辑,可切源码 / 对照 |
| 划线 | 选区浮层带摘录,可写入或替换笔记 |
| 对话 | 上下文固定为当前材料与笔记;无 Key 时离线预览,不编造 |
| 对话 | PI 可检索整个课程的材料、笔记与关联,说明关系并给出可点击的文件、PDF 页或 HTML 章节 |
| 学习 | 记录上次位置、目标、已掌握、困惑和下一步;旧困惑只能凭用户原话或可验证的回忆表现提出结案,用户确认后才落盘且可撤销 |
| 布局 | 三栏可调;文档笔记对半;沉浸阅读 / 对话 / 写作 |
| Agent | 固定列、抽屉、小窗、划线浮层、静默洞察、隐藏 |
| 键位 | `⌘1`–`⌘4` 聚焦,`⌘B` 资料库,`⌘K` 命令面板 |
Expand All @@ -28,6 +29,7 @@
- macOS 14+
- `swift`(Xcode Command Line Tools)
- 改 Web 编辑器源码时需要 Node.js
- 首次构建需要联网下载并校验固定版本的 PI 独立运行体;用户不需要安装 PI、Node.js 或 Bun

## 运行

Expand All @@ -40,17 +42,35 @@ cd weibei
```bash
./script/build_and_run.sh check
./script/build_and_run.sh package
./script/verify_release_metadata.sh --require-clean
./script/build_and_run.sh --verify
```

## Agent

自备 API Key(设置页或环境变量),应用不托管账号。
魏碑把 PI 当内部学习 Agent,不给它文件、终端或网络工具。魏碑先索引当前课程里的材料与笔记,再把有界课程目录、关联、相关摘录、学习进度和当前会话交给 PI。PI 只能读取这份受限快照;笔记整理只能返回待确认建议,最终写回仍由魏碑和用户决定。

单个课程目录最多导入 500 个支持文件。PI 通过分页课程地图认识完整文件清单;每轮按用户问题选出最多 80 份相关知识片段,不把整个课程全文一次塞进模型。课程全文索引持久化在本机 SQLite:后台先快速扫完所有文字层和普通文本,再用独立低优先级队列逐页补齐纯扫描页 OCR,包括第 12 页之后的页面。PDF 原生文字层由应用包内单独的受限进程批量提取,每次打开同一份 PDF 处理最多 8 页,并设置内存监测、CPU、输出和超时边界,异常页面不会拖垮主应用;界面线程只读缓存,前台索引每份 PDF 最多尝试 32 页且单份预算 2 秒,整轮同步补索引最多 4 秒,剩余文字页分批在后台续跑。只有已经完成文字层尝试且确认无文字的页才进入 OCR,不会把长教材中尚未扫描到的后续文字页误当成图片页。确认无文字的空白页会记为已检查,截断页和 OCR 失败页会记为终态不完整,只有文件内容变化后才重建,不会在每次提问时永久重试。未完成的索引和只返回局部命中的摘录都会明确标记为不完整;每次提问先轻量核对文件签名,前台最多同步补齐 24 个缺失或真正改过的来源。单个可全文索引的 HTML、Markdown 或纯文本文件上限为 32MB,单页 PDF 最多索引 128K 字;更大的内容仍出现在课程目录,但内容索引明确保持不完整。跨文件检索先保证每份命中材料都有自己的候选片段,避免一本大书挤掉其他关联来源。索引目录使用私有权限;SQLite 主库按连接限制为 768MB,整个索引目录以 1GB 为停止新增写入的预算并为 WAL 留出余量,但不是操作系统磁盘配额。全文与可索引元数据分表保存,写入使用可回滚事务。达到预算时保持“未完成”标记。索引只保存文件标识的哈希,已移出课程的材料会清理并增量回收物理页;导入文件的本机绝对路径进入 PI 上下文前还会再次替换成临时匿名 ID。

应用内建固定到 `0.80.2` 的 PI macOS 独立运行体,只从自身资源目录启动,不扫描用户的 `PATH`、NVM、Node.js、Bun 或全局 PI。构建脚本按架构下载官方开源产物,先核对 SHA-256,再把最小运行文件、MIT 许可证和来源清单装进应用包。PI 内核以后可替换成我们的源码分支,Swift/RPC 契约无需跟着重写。

正式学习对话始终由 PI 处理。PI 启动、提供方或工具失败时,魏碑会明确报错并保留原问题,不会静默降级成不认识课程、记忆和工具的普通对话。静默洞察不属于用户学习会话,仍可在 PI 启动前失败时使用原有有界在线/离线路径。

魏碑为 PI 建立独立配置目录,只迁入本机已有 PI 的认证信息和默认提供方;全局扩展、技能、提示模板、主题和会话都不会加载。PI 子进程使用环境白名单,不继承宿主里的其他密钥。PI 自己的原始会话轨迹不落盘;魏碑持久化完整的用户学习会话,每轮向干净的 PI 运行会话注入最近 20 条消息、受限的更早对话摘录、会话摘要、上次位置和经过证据约束的学习记忆,因此切换材料或重启应用不会把学习连续性交给 PI 的隐藏状态。

五个内置学习技能:学习陪伴、课程关联导航、细读与证据核对、Markdown 笔记整理、主动回忆与自测。六个魏碑专用工具负责读取当前上下文、浏览课程地图、检索课程知识、读取学习记忆、提交学习更新和生成笔记建议。上下文先读、目录不等于读过来源、记忆先读、工具白名单、修订号失效和写回边界由 PI 扩展钩子与 Swift 宿主双重校验。可点击来源也由宿主按完整位置验真:重复文件的条目序号、PDF 页码、HTML 章节序号和章节名必须与本轮工具返回值一致。

| 变量 | 说明 | 默认 |
| --- | --- | --- |
| `OPENAI_API_KEY` | API Key | 无 |
| `WEIBEI_OPENAI_MODEL` | 模型 | `gpt-5.1` |
| `WEIBEI_PI_PROVIDER` | 指定 PI 提供方 | PI 当前配置;有应用 Key 时为 `openai` |
| `WEIBEI_PI_MODEL` | 指定 PI 模型 | PI 当前配置;有应用 Key 时沿用应用模型 |
| `WEIBEI_PI_THINKING` | PI 思考强度 | `medium` |
| `WEIBEI_PI_DISABLED` | 设为 `1` 跳过 PI;正式学习对话将明确报不可用 | 未设置 |
| `WEIBEI_PI_LIVE_CHECK` | `1` 强制、`0` 跳过真实笔记技能冒烟 | 有可用认证时自动运行 |
| `WEIBEI_PI_EVAL` | 运行学习陪伴、课程导航、细读、笔记、回忆五项真实评测 | 未设置 |
| `WEIBEI_PI_EXECUTABLE` | 仅供 `WeiBeiPiCheck` 指向准备好的内建运行体 | 未设置 |

Key 只在本机。

Expand All @@ -59,16 +79,25 @@ Key 只在本机。
```text
Sources/WeiBei/ App、界面、编辑器资源
Sources/WeiBeiCore/ 工作区、Agent、密钥、PDF OCR
AgentResources/ PI 扩展、系统契约与五个学习技能
Sources/WeiBeiSelfCheck/
Sources/WeiBeiPiCheck/ PI 启动检查与可选真模型冒烟
Sources/WeiBeiPDFTextWorker/ 受限的 PDF 原生文字提取进程
Sources/WeiBei/WebEditor/ 编辑器源码 → Resources/Editor
Vendor/PiRuntime/ PI 固定版本、哈希、许可证与维护边界
DesignReferences/ 纸 / 墨 / 石 / 朱砂参考
script/build_and_run.sh
script/prepare_pi_runtime.sh
```

```bash
swift build
swift run WeiBeiSelfCheck
swift run WeiBeiWebEditorCheck
PI_RUNTIME="$(./script/prepare_pi_runtime.sh)"
WEIBEI_PI_EXECUTABLE="$PI_RUNTIME/bin/pi" swift run WeiBeiPiCheck
WEIBEI_PI_EXECUTABLE="$PI_RUNTIME/bin/pi" WEIBEI_PI_LIVE_CHECK=1 swift run WeiBeiPiCheck
WEIBEI_PI_EXECUTABLE="$PI_RUNTIME/bin/pi" WEIBEI_PI_EVAL=1 swift run WeiBeiPiCheck
```

动布局或对话结构时,把 SelfCheck 里的断言一并改掉。
Expand Down
Loading