Workspace Local Retrieval
Package retrieval as architecture, not ad-hoc glue.
This skill exists for a common failure mode in local RAG systems: indexing grows faster than boundary discipline. The result is usually a system that can sometimes retrieve relevant text, but cannot clearly answer:
- - what should be searchable
- which agent should see which corpus
- what belongs in personal memory versus workspace knowledge
- how freshness should be maintained over time
Prefer this skill when the goal is workspace knowledge retrieval, not personal memory recall. Keep those layers separate.
Single-command npm install
This skill also ships as an npm-friendly CLI. Install it with one line (npm install -g workspace-local-retrieval) or run it on-demand via npx workspace-local-retrieval install. The CLI wraps the existing Python helpers (scripts/check_retrieval_prereqs.py + scripts/bootstrap_workspace_retrieval.py), so the install command performs a safety check, writes the retrieval/config templates, and hints at the next refresh/index steps. Run workspace-local-retrieval check anytime for a standalone prerequisite report.
Core workflow
- 0. Run a preflight gate before any retrieval work
- Run
scripts/check_retrieval_prereqs.py before bootstrap, indexing, embedding refresh, or search.
- Classify findings into:
-
required: must exist before execution
-
recommended: may proceed with warning
-
optional: capability upgrade only
- Treat missing required prerequisites as a hard stop.
- Do not continue into retrieval execution when the environment is not ready.
- Read
references/dependencies-and-platforms.md when deciding what is required on the current OS.
- 1. Decide the boundary model first
- Use built-in memory tools for personal continuity (
MEMORY.md,
memory/*.md).
- Use this skill's retrieval pattern for workspace knowledge, docs, skills, plans, schemas, and agent-specific materials.
- Do not merge personal notes into a general retrieval corpus unless the user explicitly wants that and understands the privacy tradeoff.
- 2. Design corpora before indexing
- Split knowledge into small allowlisted corpora.
- Prefer domain or workspace boundaries over one giant corpus.
- Exclude runtime state, secrets, private notes, vector DB artifacts, build outputs, and caches.
- Read
references/privacy-and-boundaries.md before writing config.
- 3. Define agent access explicitly
- Use deny-by-default agent retrieval policy.
- Allow each agent to see only the corpora it needs.
- Use separate memory-boundary rules for personal memory vs domain memory.
- Read
references/agent-scoping.md when creating agent rules.
- 4. Bootstrap templates safely
- Run
scripts/bootstrap_workspace_retrieval.py --dest <dir> to generate sanitized starter templates.
- The script creates template config files only. It does not read external services, call the network, or ingest private data.
- Read
references/runtime-layout.md and
references/dependencies-and-platforms.md before claiming the setup is runnable.
- Run
scripts/check_retrieval_prereqs.py before wiring indexing or embedding backends.
- 5. Implement retrieval entrypoints
- Keep one stable wrapper for agent-facing search.
- Make the wrapper responsible for corpus allowlist checks.
- Keep indexing / embeddings / scoring internals behind the wrapper.
- Read
references/interface-contract.md for a recommended contract.
- 6. Add freshness + maintenance
- Track corpus fingerprints or file signatures.
- Prefer selective refresh when only a small set of files changed.
- Fall back to full rebuild only when needed.
- Read
references/maintenance-patterns.md for a production-friendly approach.
- 7. Validate with smoke tests
- Test at least:
- one broad query
- one corpus-specific query
- one agent allowlist denial
- one changed-file refresh path
- Do not claim retrieval is ready because indexing succeeded once.
- 8. Handle missing prerequisites explicitly
- If a required prerequisite is missing and the user has
not authorized installation or environment changes:
- stop
- say the skill is currently unavailable
- list the missing prerequisites
- tell the user what must be installed or configured first
- If a required prerequisite is missing and the user
does want the environment prepared:
- create a task plan first
- make the plan OS-specific when needed
- install or configure dependencies
- update config and documentation to reflect the chosen backend and runtime
- rerun
scripts/check_retrieval_prereqs.py
- continue only after the required checks pass
- Use this rule consistently for macOS, Linux, and Windows. Do not pretend portability removes the need for explicit checks.
Recommended file layout
Use this skill as a pattern, not a rigid requirement.
CODEBLOCK0
If the workspace already has a retrieval system, adapt the layout instead of forcing a rewrite.
Defaults worth keeping
- - local-first storage
- allowlisted corpora
- deny-by-default agent access
- personal memory separate from workspace retrieval
- minimal indexed file extensions
- explicit exclude globs
- incremental refresh before full rebuild
- one stable wrapper for agent-facing search
When to read references
- - Read
references/privacy-and-boundaries.md for safe corpus design and exclusions. - Read
references/agent-scoping.md when mapping corpora and memory roots to agents. - Read
references/interface-contract.md when building or reviewing the agent-facing search wrapper. - Read
references/maintenance-patterns.md when adding status checks, selective refresh, and smoke tests. - Read
references/example-templates.md when you need sanitized starter JSON examples. - Read
references/dependencies-and-platforms.md when the user wants concrete runtime dependencies, embedding backend choices, or cross-platform guidance. - Read
references/preflight-and-install-policy.md when deciding whether the skill is runnable now, blocked, or should first produce an installation task plan. - Read
references/runtime-layout.md when the user wants a more runnable implementation footprint. - Read
references/design-rationale.md when the user needs the architectural thesis, tradeoffs, or public-facing positioning. - Read
references/sanitized-demo.md when the user wants a safe walkthrough or publishable example. - Read
references/publish-readiness-checklist.md before packaging or publicly promoting the skill.
Practical guidance
- - Prefer fewer, clearer corpora over many overlapping ones.
- Avoid indexing secrets, credentials, private journals, logs, and generated artifacts.
- If two agents need different trust levels, separate their corpora even if the docs overlap.
- If retrieval results look noisy, improve corpus design before tuning ranking weights.
- If privacy matters, treat boundary design as a first-class feature, not cleanup later.
- Treat prerequisite checks as part of the runtime contract, not as optional setup advice.
- The npm-friendly CLI is the simplest user entry point:
workspace-local-retrieval install bootstraps the templates, workspace-local-retrieval check reports missing requirements, and both commands accept --dest, --workspace-root, and --force switches for customization. - No required prerequisites, no execution.
- If installation is needed, prefer a short task plan over ad-hoc shell improvisation.
- After installation or config changes, rerun preflight checks before claiming the skill is ready.
Output expectations
When using this skill for a user request, produce some or all of the following depending on scope:
- - sanitized corpus config
- agent allowlist config
- memory-boundary config
- search wrapper contract
- maintenance workflow
- smoke-test checklist
- packaging-ready skill contents when the user wants distribution
工作区本地检索
将包检索作为架构,而非临时拼凑。
此技能针对本地RAG系统中的常见失败模式:索引增长速度快于边界规范。结果通常是系统有时能检索到相关文本,但无法清晰回答:
- - 哪些内容应可搜索
- 哪个智能体应看到哪个语料库
- 哪些属于个人记忆而非工作区知识
- 如何随时间保持数据新鲜度
当目标是工作区知识检索而非个人记忆回忆时,优先使用此技能。请保持这些层级的分离。
单命令npm安装
此技能也以npm友好的CLI形式提供。通过一行命令(npm install -g workspace-local-retrieval)安装,或通过npx workspace-local-retrieval install按需运行。该CLI封装了现有的Python辅助脚本(scripts/checkretrievalprereqs.py + scripts/bootstrapworkspaceretrieval.py),因此install命令会执行安全检查,写入retrieval/config模板,并提示下一步的刷新/索引步骤。随时运行workspace-local-retrieval check获取独立的先决条件报告。
核心工作流程
- 0. 在任何检索工作前运行预检门控
- 在引导、索引、嵌入刷新或搜索之前运行scripts/check
retrievalprereqs.py。
- 将发现结果分类为:
-
必需:执行前必须存在
-
推荐:可继续但需警告
-
可选:仅能力升级
- 将缺失的必需先决条件视为硬性停止。
- 环境未就绪时不要继续执行检索。
- 在决定当前操作系统上需要什么时,阅读references/dependencies-and-platforms.md。
- 1. 首先确定边界模型
- 使用内置记忆工具处理个人连续性(MEMORY.md、memory/*.md)。
- 使用此技能的检索模式处理工作区知识、文档、技能、计划、架构和智能体特定材料。
- 除非用户明确要求并理解隐私权衡,否则不要将个人笔记合并到通用检索语料库中。
- 2. 在索引前设计语料库
- 将知识拆分为小型允许列表语料库。
- 优先使用领域或工作区边界,而非单一大型语料库。
- 排除运行时状态、密钥、私人笔记、向量数据库产物、构建输出和缓存。
- 在编写配置前阅读references/privacy-and-boundaries.md。
- 3. 明确定义智能体访问权限
- 使用默认拒绝的智能体检索策略。
- 允许每个智能体仅看到其所需的语料库。
- 对个人记忆与领域记忆使用独立的记忆边界规则。
- 在创建智能体规则时阅读references/agent-scoping.md。
- 4. 安全引导模板
- 运行scripts/bootstrap
workspaceretrieval.py --dest
生成经过净化的起始模板。
- 该脚本仅创建模板配置文件。不会读取外部服务、调用网络或摄取私人数据。
- 在声称设置可运行前阅读references/runtime-layout.md和references/dependencies-and-platforms.md。
- 在连接索引或嵌入后端前运行scripts/checkretrievalprereqs.py。
- 5. 实现检索入口点
- 为面向智能体的搜索保持一个稳定的包装器。
- 让包装器负责语料库允许列表检查。
- 将索引/嵌入/评分内部逻辑保持在包装器后面。
- 阅读references/interface-contract.md获取推荐的契约。
- 6. 添加新鲜度与维护
- 跟踪语料库指纹或文件签名。
- 当只有少量文件更改时优先选择选择性刷新。
- 仅在需要时回退到完全重建。
- 阅读references/maintenance-patterns.md获取生产友好型方法。
- 7. 通过冒烟测试验证
- 至少测试:
- 一个广泛查询
- 一个特定语料库查询
- 一个智能体允许列表拒绝
- 一个更改文件刷新路径
- 不要因为索引成功一次就声称检索已就绪。
- 8. 明确处理缺失的先决条件
- 如果缺少必需的先决条件且用户未授权安装或环境更改:
- 停止
- 说明该技能当前不可用
- 列出缺失的先决条件
- 告知用户必须先安装或配置什么
- 如果缺少必需的先决条件且用户确实希望准备环境:
- 首先创建任务计划
- 必要时使计划特定于操作系统
- 安装或配置依赖项
- 更新配置和文档以反映所选后端和运行时
- 重新运行scripts/checkretrievalprereqs.py
- 仅在必需检查通过后继续
- 在macOS、Linux和Windows上一致使用此规则。不要假装可移植性消除了显式检查的需要。
推荐文件布局
将此技能作为模式使用,而非刚性要求。
text
retrieval/
config/
corpora.json
agent_corpora.json
agent_memory.json
backend.json
scripts/
workspace_search.mjs
build_index.py
build_embeddings.mjs
retrieval_status.py
refresh_incremental.py
indexes/
workspace_retrieval.sqlite
如果工作区已有检索系统,则调整布局而非强制重写。
值得保留的默认设置
- - 本地优先存储
- 允许列表语料库
- 默认拒绝智能体访问
- 个人记忆与工作区检索分离
- 最小化索引文件扩展名
- 显式排除通配符
- 完全重建前先增量刷新
- 面向智能体搜索的一个稳定包装器
何时阅读参考资料
- - 阅读references/privacy-and-boundaries.md了解安全的语料库设计和排除项。
- 阅读references/agent-scoping.md了解如何将语料库和记忆根映射到智能体。
- 阅读references/interface-contract.md了解构建或审查面向智能体的搜索包装器。
- 阅读references/maintenance-patterns.md了解添加状态检查、选择性刷新和冒烟测试。
- 阅读references/example-templates.md了解需要经过净化的起始JSON示例。
- 阅读references/dependencies-and-platforms.md了解用户需要具体的运行时依赖项、嵌入后端选择或跨平台指导。
- 阅读references/preflight-and-install-policy.md了解判断技能当前是否可运行、被阻止或应首先生成安装任务计划。
- 阅读references/runtime-layout.md了解用户需要更可运行的实现足迹。
- 阅读references/design-rationale.md了解用户需要架构论点、权衡或面向公众的定位。
- 阅读references/sanitized-demo.md了解用户需要安全的演练或可发布的示例。
- 阅读references/publish-readiness-checklist.md了解打包或公开推广技能前。
实用指导
- - 优先选择更少、更清晰的语料库,而非多个重叠的语料库。
- 避免索引密钥、凭据、私人日志、日志和生成的产物。
- 如果两个智能体需要不同的信任级别,即使文档重叠也要分离它们的语料库。
- 如果检索结果看起来嘈杂,在调整排名权重前先改进语料库设计。
- 如果隐私很重要,将边界设计视为一等功能,而非后续清理。
- 将先决条件检查视为运行时契约的一部分,而非可选的设置建议。
- npm友好的CLI是最简单的用户入口点:workspace-local-retrieval install引导模板,workspace-local-retrieval check报告缺失的需求,两个命令都接受--dest、--workspace-root和--force开关进行自定义。
- 没有必需的先决条件,就不执行。
- 如果需要安装,优先选择简短的任务计划而非临时shell即兴操作。
- 安装或配置更改后,在声称技能就绪前重新运行预检检查。
输出期望
当为用户请求使用此技能时,根据范围生成以下部分或全部内容:
- - 经过净化的语料库配置
- 智能体允许列表配置
- 记忆边界配置
- 搜索包装器契约
- 维护工作流程
- 冒烟测试检查清单
- 当用户希望分发时,提供可打包的技能内容