diff --git a/README.en.md b/README.en.md index eaf606d..1796e6a 100644 --- a/README.en.md +++ b/README.en.md @@ -73,17 +73,10 @@ Start the Dashboard with `node /.loci/dashboard/server.js`, then ope ## One entry, one manual, shared data -```mermaid -flowchart TD - A[LOCI.md: short entry] --> B[Native instructions in each agent] - B --> C[Startup: short preferences] - H[Optional hook / same fallback reader] --> C - B --> D[First memory use: read LOCI-RULES.md once] - D --> E[Read relevant indexes and records] - E --> F[Existing scripts / Dashboard API] - F --> G[Local Markdown, JSON and attachments] - UI[Dashboard] <--> G -``` + + + Loci architecture: install an entry, load preferences at startup, read rules at first memory use, and share local data + - **`LOCI.md`** provides the brain path, startup preference reader and triggers to read the manual. - **`LOCI-RULES.md`** contains the complete operating rules. Read it at first Loci use, reuse while valid, reload after changes or lost context. diff --git a/README.md b/README.md index d0f6123..ca28b0d 100644 --- a/README.md +++ b/README.md @@ -71,17 +71,10 @@ node loci/scripts/loci-install.js --connect auto --lang zh ## 架构:一个入口,一本手册,一套数据 -```mermaid -flowchart TD - A[LOCI.md:短入口] --> B[安装到各 Agent 原生指令文件] - B --> C[启动:短偏好与大脑位置] - H[可选 Hook / 同一个后备读取器] --> C - B --> D[首次涉及记忆:完整读取 LOCI-RULES.md] - D --> E[按需查询索引和相关记录] - E --> F[现有脚本 / Dashboard API] - F --> G[本地 Markdown、JSON、附件] - UI[Dashboard] <--> G -``` + + + Loci 架构:安装短入口,启动获取偏好,首次使用读手册,Agent 与 Dashboard 共用本地数据 + - **`LOCI.md` 是短入口**:告诉 Agent 大脑在哪、如何获取偏好、何时读取完整手册。 - **`LOCI-RULES.md` 是完整手册**:任务、碎片、人物、项目等规则集中分块维护;首次涉及 Loci 操作时读一次,未变且仍在上下文则复用。 diff --git a/docs/architecture.md b/docs/architecture.md index caa8906..bd5dcc8 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -4,23 +4,12 @@ Loci 的核心是让不同 Agent 通过自己的原生指令入口,使用同一份本地记忆。规则告诉模型何时读取和调用工具,脚本/API 完成实际读写。Markdown 指令能够引导模型,不能从机制上强制它执行;安装验证与真实客户端验收是两件事。 -```mermaid -flowchart TD - Source[LOCI.md:唯一短入口源文件] --> Install[同一个 Node 安装器:替换大脑路径并合并标记区] - Install --> Native[各 Agent 原生指令入口] - Native --> Prefs[启动:短偏好与大脑位置] - Hook[可选 SessionStart Hook] --> Context[scripts/loci-context.js] - Fallback[入口指令的后备调用] --> Context - Context --> Prefs - Native --> Trigger{首次涉及 Loci 记忆操作?} - Trigger -->|是| Rules[完整读取 LOCI-RULES.md 一次] - Trigger -->|否| Chat[继续普通请求] - Rules --> Index[按需查索引、读取最小相关数据] - Index --> Tools[现有脚本或 Dashboard API] - Tools --> Data[本地 Markdown、JSON 和附件] - Dashboard[Dashboard 界面] <--> Data - Data --> Project[项目正文留在对应仓库,大脑只保存索引] -``` + + + Loci 架构:安装短入口,启动获取偏好,首次使用读手册,Agent 与 Dashboard 共用本地数据 + + +图分为三个阶段:安装入口、启动获取短偏好、首次使用记忆。Dashboard 与 Agent 最终读写同一套本地数据。图片随 GitHub 的深浅主题切换;文字与流程源文件在 [`scripts/render-architecture.js`](../scripts/render-architecture.js),运行 `node scripts/render-architecture.js` 可重新生成中英文 SVG。 ## 哪些文件需要维护 diff --git a/docs/assets/architecture-en-dark.svg b/docs/assets/architecture-en-dark.svg new file mode 100644 index 0000000..461ee62 --- /dev/null +++ b/docs/assets/architecture-en-dark.svg @@ -0,0 +1,55 @@ + +One entry. One manual. Shared local data.The installer copies LOCI.md into native agent instructions. An optional hook or instruction fallback calls the same preference reader at startup. At first memory use, the agent reads LOCI-RULES.md, retrieves relevant data and uses scripts or local APIs. Dashboard and agents share local files. + + + +LOCI / ARCHITECTURE +One entry. One manual. Shared local data. +Instructions guide the agent. Tools execute. Files keep the memory. +01 +Install once + +LOCI.md +Brain path + when to load rules + + +Install into native agent instructions +Claude Code · Codex · WorkBuddy +CLAUDE.md / AGENTS.md / MEMORY.md +02 +At session start: compact preferences + +With a hook: automatic context +Without one: the agent calls it +Both paths use the same reader + + +loci-context.js +Reads me/preferences.md +Returns preferences + file pointers +03 +At first memory use: read the manual, then act + +LOCI-RULES.md +Read in full once +Reuse while valid + + +Read on demand +Look up an index +Open relevant records + + +Scripts / local API +Validate, write, link +Log the operation + +Dashboard +People view and edit the same data + + + +Local Markdown · JSON · attachments +Project details stay in their repository; the brain keeps an index. +Hooks improve delivery, not compliance. Actual data stays on demand. + diff --git a/docs/assets/architecture-en-light.svg b/docs/assets/architecture-en-light.svg new file mode 100644 index 0000000..118232a --- /dev/null +++ b/docs/assets/architecture-en-light.svg @@ -0,0 +1,55 @@ + +One entry. One manual. Shared local data.The installer copies LOCI.md into native agent instructions. An optional hook or instruction fallback calls the same preference reader at startup. At first memory use, the agent reads LOCI-RULES.md, retrieves relevant data and uses scripts or local APIs. Dashboard and agents share local files. + + + +LOCI / ARCHITECTURE +One entry. One manual. Shared local data. +Instructions guide the agent. Tools execute. Files keep the memory. +01 +Install once + +LOCI.md +Brain path + when to load rules + + +Install into native agent instructions +Claude Code · Codex · WorkBuddy +CLAUDE.md / AGENTS.md / MEMORY.md +02 +At session start: compact preferences + +With a hook: automatic context +Without one: the agent calls it +Both paths use the same reader + + +loci-context.js +Reads me/preferences.md +Returns preferences + file pointers +03 +At first memory use: read the manual, then act + +LOCI-RULES.md +Read in full once +Reuse while valid + + +Read on demand +Look up an index +Open relevant records + + +Scripts / local API +Validate, write, link +Log the operation + +Dashboard +People view and edit the same data + + + +Local Markdown · JSON · attachments +Project details stay in their repository; the brain keeps an index. +Hooks improve delivery, not compliance. Actual data stays on demand. + diff --git a/docs/assets/architecture-zh-dark.svg b/docs/assets/architecture-zh-dark.svg new file mode 100644 index 0000000..4107471 --- /dev/null +++ b/docs/assets/architecture-zh-dark.svg @@ -0,0 +1,55 @@ + +一个入口,一本手册,一套本地数据安装器将 LOCI.md 写入 Agent 指令入口。启动由可选 Hook 或入口调用同一偏好读取器。首次使用记忆时完整读取 LOCI-RULES.md,再按需读数据并调用脚本或本地 API。Dashboard 与 Agent 共用本地文件。 + + + +LOCI / ARCHITECTURE +一个入口,一本手册,一套本地数据 +规则让 Agent 知道怎么用;工具负责执行;文件保存记忆。 +01 +安装一次 + +LOCI.md +短入口 · 大脑路径与触发条件 + + +安装到各 Agent 原生指令入口 +Claude Code · Codex · WorkBuddy +CLAUDE.md / AGENTS.md / MEMORY.md +02 +每次启动:只取短偏好 + +有 Hook:自动提供 +无 Hook:Agent 按入口调用 +两条路径共用同一个读取器 + + +loci-context.js +读取 me/preferences.md +输出短偏好、路径和手册指针 +03 +首次需要记忆:读手册,再操作 + +LOCI-RULES.md +完整读一次 +有效且未变时复用 + + +按需读取数据 +先查索引 +再打开相关记录 + + +脚本 / 本地 API +校验、写入、关联 +按操作记录活动 + +Dashboard +人查看、修改同一份数据 + + + +本地 Markdown · JSON · 附件 +项目正文留在项目仓库,大脑保存索引。 +Hook 增强送达,不保证模型遵守;实际数据始终按需读取。 + diff --git a/docs/assets/architecture-zh-light.svg b/docs/assets/architecture-zh-light.svg new file mode 100644 index 0000000..329985d --- /dev/null +++ b/docs/assets/architecture-zh-light.svg @@ -0,0 +1,55 @@ + +一个入口,一本手册,一套本地数据安装器将 LOCI.md 写入 Agent 指令入口。启动由可选 Hook 或入口调用同一偏好读取器。首次使用记忆时完整读取 LOCI-RULES.md,再按需读数据并调用脚本或本地 API。Dashboard 与 Agent 共用本地文件。 + + + +LOCI / ARCHITECTURE +一个入口,一本手册,一套本地数据 +规则让 Agent 知道怎么用;工具负责执行;文件保存记忆。 +01 +安装一次 + +LOCI.md +短入口 · 大脑路径与触发条件 + + +安装到各 Agent 原生指令入口 +Claude Code · Codex · WorkBuddy +CLAUDE.md / AGENTS.md / MEMORY.md +02 +每次启动:只取短偏好 + +有 Hook:自动提供 +无 Hook:Agent 按入口调用 +两条路径共用同一个读取器 + + +loci-context.js +读取 me/preferences.md +输出短偏好、路径和手册指针 +03 +首次需要记忆:读手册,再操作 + +LOCI-RULES.md +完整读一次 +有效且未变时复用 + + +按需读取数据 +先查索引 +再打开相关记录 + + +脚本 / 本地 API +校验、写入、关联 +按操作记录活动 + +Dashboard +人查看、修改同一份数据 + + + +本地 Markdown · JSON · 附件 +项目正文留在项目仓库,大脑保存索引。 +Hook 增强送达,不保证模型遵守;实际数据始终按需读取。 + diff --git a/scripts/render-architecture.js b/scripts/render-architecture.js new file mode 100644 index 0000000..b971690 --- /dev/null +++ b/scripts/render-architecture.js @@ -0,0 +1,94 @@ +#!/usr/bin/env node +'use strict'; + +// GitHub-safe SVG: native text only, no foreignObject, remote fonts or scripts. +const fs = require('node:fs'); +const path = require('node:path'); +const out = path.resolve(__dirname, '../docs/assets'); +const copy = { + zh: { + title: '一个入口,一本手册,一套本地数据', + subtitle: '规则让 Agent 知道怎么用;工具负责执行;文件保存记忆。', + install: '安装一次', entry: ['LOCI.md', '短入口 · 大脑路径与触发条件'], + native: ['安装到各 Agent 原生指令入口', 'Claude Code · Codex · WorkBuddy', 'CLAUDE.md / AGENTS.md / MEMORY.md'], + start: '每次启动:只取短偏好', hook: ['有 Hook:自动提供', '无 Hook:Agent 按入口调用', '两条路径共用同一个读取器'], + prefs: ['loci-context.js', '读取 me/preferences.md', '输出短偏好、路径和手册指针'], + use: '首次需要记忆:读手册,再操作', + manual: ['LOCI-RULES.md', '完整读一次', '有效且未变时复用'], + read: ['按需读取数据', '先查索引', '再打开相关记录'], + write: ['脚本 / 本地 API', '校验、写入、关联', '按操作记录活动'], + dashboard: ['Dashboard', '人查看、修改同一份数据'], + data: ['本地 Markdown · JSON · 附件', '任务 / 日程 / 偏好 / 人脉 / 笔记 / 碎片', '项目正文留在项目仓库,大脑保存索引。'], + foot: 'Hook 增强送达,不保证模型遵守;实际数据始终按需读取。', + desc: '安装器将 LOCI.md 写入 Agent 指令入口。启动由可选 Hook 或入口调用同一偏好读取器。首次使用记忆时完整读取 LOCI-RULES.md,再按需读数据并调用脚本或本地 API。Dashboard 与 Agent 共用本地文件。' + }, + en: { + title: 'One entry. One manual. Shared local data.', + subtitle: 'Instructions guide the agent. Tools execute. Files keep the memory.', + install: 'Install once', entry: ['LOCI.md', 'Brain path + when to load rules'], + native: ['Install into native agent instructions', 'Claude Code · Codex · WorkBuddy', 'CLAUDE.md / AGENTS.md / MEMORY.md'], + start: 'At session start: compact preferences', hook: ['With a hook: automatic context', 'Without one: the agent calls it', 'Both paths use the same reader'], + prefs: ['loci-context.js', 'Reads me/preferences.md', 'Returns preferences + file pointers'], + use: 'At first memory use: read the manual, then act', + manual: ['LOCI-RULES.md', 'Read in full once', 'Reuse while valid'], + read: ['Read on demand', 'Look up an index', 'Open relevant records'], + write: ['Scripts / local API', 'Validate, write, link', 'Log the operation'], + dashboard: ['Dashboard', 'People view and edit the same data'], + data: ['Local Markdown · JSON · attachments', 'Tasks / calendar / preferences / people / notes / scraps', 'Project details stay in their repository; the brain keeps an index.'], + foot: 'Hooks improve delivery, not compliance. Actual data stays on demand.', + desc: 'The installer copies LOCI.md into native agent instructions. An optional hook or instruction fallback calls the same preference reader at startup. At first memory use, the agent reads LOCI-RULES.md, retrieves relevant data and uses scripts or local APIs. Dashboard and agents share local files.' + } +}; +const esc = s => String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); + +function render(lang, dark) { + const c = copy[lang]; + const p = dark + ? {bg:'#101915',panel:'#1a2820',line:'#3d5647',ink:'#edf4ee',muted:'#b3c8ba',accent:'#9cdbb6',soft:'#203c2c',arrow:'#87b79b'} + : {bg:'#f6f8f4',panel:'#ffffff',line:'#d2dfd5',ink:'#243b2d',muted:'#52685a',accent:'#236941',soft:'#e7f1e6',arrow:'#67967b'}; + const parts = [``, + `${esc(c.title)}${esc(c.desc)}`, + ``, + ``, + ``]; + const text = (x,y,value,size=21,color=p.ink,weight=400) => parts.push(`${esc(value)}`); + const rect = (x,y,w,h,fill=p.panel) => parts.push(``); + const arrow = (x1,y1,x2,y2,both=false) => parts.push(``); + const stage = (n,y,label) => { text(40,y,n,18,p.accent,700); text(83,y,label,22,p.ink,650); }; + const card = (x,y,w,h,lines,fill) => { rect(x,y,w,h,fill); lines.forEach((s,i)=>text(x+22,y+33+i*28,s,i===0?22:19,i===0?p.ink:p.muted,i===0?650:400)); }; + text(40,38,'LOCI / ARCHITECTURE',14,p.accent,700); + text(40,83,c.title,lang==='zh'?34:32,p.ink,700); + text(40,117,c.subtitle,20,p.muted); + + stage('01',169,c.install); + card(40,189,314,116,c.entry); + arrow(369,247,407,247); + card(423,189,497,116,c.native); + + stage('02',354,c.start); + card(40,374,411,117,c.hook); + arrow(465,432,495,432); + card(511,374,409,117,c.prefs); + + stage('03',545,c.use); + card(40,565,260,118,c.manual,p.soft); + arrow(310,624,339,624); + card(351,565,260,118,c.read); + arrow(621,624,650,624); + card(662,565,258,118,c.write); + card(40,704,382,78,c.dashboard); + arrow(231,790,231,819,true); + arrow(791,696,791,818,true); + rect(40,831,880,65,p.soft); + text(61,858,c.data[0],23,p.ink,650); + text(61,882,c.data[2],17,p.muted); + text(40,930,c.foot,17,p.muted); + parts.push(''); + return parts.join('\n')+'\n'; +} +fs.mkdirSync(out,{recursive:true}); +for (const lang of ['zh','en']) for (const theme of ['light','dark']) { + const name = `architecture-${lang}-${theme}.svg`; + fs.writeFileSync(path.join(out,name),render(lang,theme==='dark')); + console.log(name); +}