-
Notifications
You must be signed in to change notification settings - Fork 4
Scopes and Project Discovery
Language: English · 简体中文
Scope determines which Wiki a command may read or mutate. Project discovery turns the current directory into an explicit filesystem authority boundary; it is not a convenience alias for arbitrary paths. This page covers normal discovery, intentional overrides, and the path-safety rules that keep one project from reaching another.
| Scope | Store | Intended use |
|---|---|---|
project |
nearest authorized ancestor <root>/.lwc/wiki.db
|
Repository knowledge and project operations |
global |
current user's ~/.lwc/wiki.db
|
Cross-project memory and defaults |
all |
bounded merge of initialized project and global stores | Read-oriented search, context, tag listing, and strong-tag loading |
Mutating domain commands accept only project or global. When a read-oriented command offers a recording option, choose one explicit writable scope before enabling recording.
Project and global results retain their scope field after a merged read. LWC does not merge their canonical databases.
Run lwc from the project or one of its subdirectories:
cd /path/to/project
lwc --scope project context --limit 20LWC walks ancestors from the current directory and selects the nearest real .lwc/wiki.db. It does not mistake the user's global ~/.lwc/wiki.db for a project Wiki and does not search above the user-home boundary.
lwc init reuses the nearest existing ancestor Wiki. If none exists, it initializes the current directory.
This behavior means routine commands need neither an exported project root nor an absolute binary variable.
Use LWC_PROJECT_ROOT only when one process intentionally targets a known project boundary while its current directory is inside that boundary:
LWC_PROJECT_ROOT=/path/to/project lwc --scope project context --limit 20LWC canonicalizes the root and current directory, then requires the current directory to remain inside the root. Resolution stops at that boundary.
If multiple project Wikis exist between the current directory and the explicit root, LWC returns project_scope_conflict instead of guessing which one owns the command.
Do not export this variable in shell startup files or Agent instructions. In the current project it adds noise and can make later commands target an unintended boundary.
LWC resolves the user home through platform-appropriate variables in this order:
-
HOME; -
USERPROFILE; -
HOMEDRIVEplusHOMEPATH.
An unavailable home returns home_not_set. Agent installations and global Wiki operations use the same user boundary but their host-specific paths remain owned by each AgentTarget adapter.
Store discovery validates the .lwc directory, wiki.db, WAL, and shared-memory sidecars as real paths. Symbolic links or non-regular files return a typed unsafe-path error.
When LWC_PROJECT_ROOT is explicit, every existing ancestor of a target path is canonicalized and must remain under the root. A symlink that resolves outside becomes project_root_escape.
Draft runtime, Work, graph sidecar, config, checkpoint, and materialization code repeat ownership checks at their own write boundaries. One early string-prefix check is not considered sufficient.
Source manifests and conversion inputs normally remain inside the selected project. External Source or conversion input requires an explicit command option and still undergoes file-type, size, UTF-8, and secret checks.
Conversion output must be project-contained, must end in .md, and uses create-new semantics. Adapter arguments cannot smuggle an alternate output or positional filesystem path.
CodeGraph arguments are normalized relative to the canonical project and reject paths that escape through .., an absolute external path, or a resolving symlink.
lwc serve --mcp accepts an absolute project path from the client for each exploration call. The path must exist, resolve to a project rather than filesystem root, and contain or discover the requested Wiki/CodeGraph state.
The server validates mode and path before invoking either backend. It never changes current process scope, initializes a missing capability, or accepts a relative path as ambient authority.
Agent --location global and --location local are integration locations, not Wiki scopes:
- global writes the host's official user configuration;
- local writes the current project's official host surfaces;
- neither enables the project Wiki, document graph, or CodeGraph automatically.
Receipts record exact paths and post-install hashes. Refresh and uninstall use that ownership, not broad deletion under a host directory.
Do not store secrets in:
- Source content unless the Wiki is explicitly authorized for that data;
- Page bodies or strong tags;
- command
--reasonfields or recorded query wording; - trans arguments;
- Agent instructions, Hook output, or MCP configuration.
LWC scans selected ingest and configuration inputs for likely credentials, but detection is a guardrail, not proof that content is safe. The user remains responsible for the selected project's data classification and filesystem permissions.
-
store_not_found: no Wiki exists in the selected scope. -
project_root_invalid: the explicit root is empty, missing, or not a directory. -
project_root_mismatch: current directory is outside the explicit root. -
project_root_escape: a selected path or ancestor resolves outside the root. -
project_scope_conflict: more than one Wiki exists inside the explicit boundary. -
store_path_invalid: Store or sidecar path is not a safe regular path. -
scope_not_supported: the command cannot use--scope all.
Do not work around these errors with symlinks or private absolute binary aliases. Move to the authorized project directory or correct the explicit boundary.
Before a mutation, confirm:
lwc --scope project context --limit 1
lwc --scope project config showCheck the returned database/config paths and scope. For a deliberately external project, also verify the canonical root and current directory relation before running the mutation.
LWC Wiki
- Home · 首页
- Project overview · 项目简介
- Basic concepts · 基本概念
- Use cases · 应用场景
- Installation and upgrades · 安装与升级
- Quick start · 快速开始
- Persistent memory · 持久记忆体系
- Agent workflow and memory policy · Agent 工作流与主动记忆策略
- Sources and ingestion · 来源与知识整合
- Wiki pages and provenance · Wiki 页面与来源证明
- Search and context · 搜索与上下文载入
- Document knowledge graph · 文档知识图(记忆图网)
- Code graph · 代码图
- Word graph · 词图
- Tags and strong context · 标签与强上下文
- Document conversion · 文档转换
-
MCP server and
lwc_explore· MCP 服务与lwc_explore - Skills, Hooks, and Instructions · Skills、Hooks 与 Instructions
- AgentTarget installation · AgentTarget 安装与集成
- Changesets · Changeset 原子变更
- Work system · Work 任务系统
- Checkpoints and rollback · Checkpoint、恢复与回滚
- Read-only Viewer · 只读可视化界面
- Architecture overview · 总体架构
- Storage and data model · 存储与数据模型
- Retrieval and indexing · 检索与索引设计
- Graph projection and performance · 图投影与性能设计
- MCP, Hooks, and AgentTarget design · MCP、Hook 与 AgentTarget 设计
- Safety and trust boundaries · 安全模型与信任边界
- Maintenance and diagnostics · 维护与诊断
- Troubleshooting and FAQ · 故障排查与常见问题
- Migration and compatibility · 迁移与版本兼容
- Support and issue reporting · 获取帮助与问题反馈
- CLI and configuration reference · CLI 与配置参考
- JSON output and error contract · JSON 输出与错误契约
- Limits and glossary · 系统限制与术语表
- Contributing and development · 贡献与开发指南
- Testing and release process · 测试与发布流程
- Wiki style guide · Wiki 编写规范