Skip to content

Commit edf76d6

Browse files
committed
docs: update README and Chinese translation to clarify oc init usage and its idempotency
1 parent f77f299 commit edf76d6

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,21 @@ npm run tauri:build
6464

6565
If you want your IDE / agent platform to call OpenContext as tools (MCP) and use beginner slash commands, use the CLI.
6666

67-
#### 1) Initialize (once per machine)
67+
#### 1) Run `oc init` (do it in the repo you want to use)
68+
69+
`oc init` always does **both**:
70+
71+
- Prepares the **global** OpenContext environment (contexts + database)
72+
- Syncs **this repo’s** Cursor/agent artifacts (e.g. `AGENTS.md`, `.cursor/commands`, `.cursor/mcp.json`)
73+
74+
So you **don’t need a separate “global init” step**. Just run it **inside the repo** where you want Cursor slash commands / coding-agent integration.
75+
76+
Rule of thumb:
77+
78+
- For your **first time** on a machine, run `oc init` in any repo you care about — that single run also prepares the global store.
79+
- For **each additional repo** you want integrated, run `oc init` in that repo once.
80+
81+
It’s safe to run multiple times (idempotent). Re-run it whenever you want to refresh generated templates.
6882

6983
```bash
7084
oc init

README.zh-CN.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,19 @@ npm run tauri:build
6464

6565
如果你想让 IDE/Agent 平台通过 MCP 调用 OpenContext,并使用新手向 slash commands,建议使用 CLI。
6666

67-
#### 1) 初始化(只做一次 / 换机器再做一次)
67+
#### 1) 运行 `oc init`(在“你要用的仓库”里跑一次就行)
68+
69+
`oc init` 每次都会同时做两件事:
70+
71+
- 准备 **全局** OpenContext 环境(contexts + 数据库)
72+
- 同步 **当前仓库** 的集成产物(例如 `AGENTS.md``.cursor/commands``.cursor/mcp.json`
73+
74+
所以你**不需要先单独做一次“全局 init”**。对小白来说,最简单的规则是:
75+
76+
- 第一次使用:在你要用 Cursor/Coding Agent 的那个仓库里运行一次 `oc init`,这一次就会把全局环境也准备好
77+
- 之后如果你想在另一个仓库也用同样的 slash commands / MCP:就在那个仓库里再运行一次 `oc init`
78+
79+
重复执行是安全的(幂等)。当你更新了命令模板或想刷新项目产物时,也可以再跑一次。
6880

6981
```bash
7082
oc init

crates/opencontext-core/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ impl OpenContext {
266266
});
267267
}
268268
let ts = now_iso();
269-
let name = rel_path.split('/').next_back().unwrap_or(&rel_path).to_string();
269+
let name = rel_path
270+
.split('/')
271+
.next_back()
272+
.unwrap_or(&rel_path)
273+
.to_string();
270274
let abs_path = self.contexts_root.join(&rel_path);
271275
fs::create_dir_all(&abs_path)?;
272276
self.with_conn(|conn| {

0 commit comments

Comments
 (0)