context-manager

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Context Manager Skill

Context Manager Skill

Purpose: Comprehensive context management operations with clear guidance, lazy loading, and safe operations for discovering, organizing, and maintaining project context.

用途:提供全面的上下文管理操作,包含清晰引导、懒加载和安全操作,用于发现、整理和维护项目上下文。

What I Do

我能做什么

I provide 8 powerful operations for managing context:
  1. DISCOVER - Find context files by topic or path
  2. FETCH - Get external documentation from libraries
  3. HARVEST - Extract context from summary files
  4. EXTRACT - Pull specific information from context
  5. COMPRESS - Reduce large file sizes
  6. ORGANIZE - Restructure context by concern
  7. CLEANUP - Remove stale or temporary files
  8. PROCESS - Guided workflow for context operations

我提供8种强大的上下文管理操作:
  1. DISCOVER - 按主题或路径查找上下文文件
  2. FETCH - 从外部库获取文档
  3. HARVEST - 从摘要文件中提取上下文
  4. EXTRACT - 从上下文中提取特定信息
  5. COMPRESS - 减小大文件体积
  6. ORGANIZE - 按关注点重组上下文
  7. CLEANUP - 删除过期或临时文件
  8. PROCESS - 上下文操作的引导式工作流

Quick Start

快速开始

1. Discover Context

1. 发现上下文

bash
bash .opencode/skills/context-manager/router.sh discover authentication
Finds all context files related to authentication patterns.
bash
bash .opencode/skills/context-manager/router.sh discover authentication
查找所有与认证模式相关的上下文文件。

2. Fetch External Documentation

2. 获取外部文档

bash
bash .opencode/skills/context-manager/router.sh fetch "Drizzle ORM" "modular schemas"
Retrieves live documentation from external libraries.
bash
bash .opencode/skills/context-manager/router.sh fetch "Drizzle ORM" "modular schemas"
从外部库获取实时文档。

3. Harvest Context

3. 采集上下文

bash
bash .opencode/skills/context-manager/router.sh harvest ANALYSIS.md
Extracts key concepts from summary files into permanent context.
bash
bash .opencode/skills/context-manager/router.sh harvest ANALYSIS.md
从摘要文件中提取关键概念并转化为永久上下文。

4. Extract Information

4. 提取信息

bash
bash .opencode/skills/context-manager/router.sh extract code-quality.md "naming conventions"
Pulls specific information from context files.
bash
bash .opencode/skills/context-manager/router.sh extract code-quality.md "naming conventions"
从上下文文件中提取特定信息。

5. Compress Files

5. 压缩文件

bash
bash .opencode/skills/context-manager/router.sh compress .opencode/context/ 100KB
Reduces large context files to save space.
bash
bash .opencode/skills/context-manager/router.sh compress .opencode/context/ 100KB
压缩大体积上下文文件以节省空间。

6. Organize Context

6. 整理上下文

bash
bash .opencode/skills/context-manager/router.sh organize .opencode/context/
Restructures context by concern for better organization.
bash
bash .opencode/skills/context-manager/router.sh organize .opencode/context/
按关注点重组上下文,提升组织性。

7. Cleanup Stale Files

7. 清理过期文件

bash
bash .opencode/skills/context-manager/router.sh cleanup .tmp/ 7
Removes temporary or old files (older than 7 days).
bash
bash .opencode/skills/context-manager/router.sh cleanup .tmp/ 7
删除临时文件或旧文件(超过7天)。

8. Guided Workflow

8. 引导式工作流

bash
bash .opencode/skills/context-manager/router.sh process "organize authentication context" .opencode/context/
Step-by-step guidance for complex context operations.

bash
bash .opencode/skills/context-manager/router.sh process "organize authentication context" .opencode/context/
为复杂的上下文操作提供分步引导。

Operations Reference

操作参考

Operation 1: DISCOVER

操作1:DISCOVER

Purpose: Find context files using intelligent discovery or direct search
When to Use:
  • Need to find all context files in repository
  • Looking for specific context by topic
  • Mapping context structure
  • Understanding what context exists
Syntax:
discover [target]
Examples:
bash
undefined
用途:通过智能发现或直接搜索查找上下文文件
适用场景:
  • 需要查找仓库中的所有上下文文件
  • 按主题查找特定上下文
  • 映射上下文结构
  • 了解现有上下文情况
语法:
discover [target]
示例:
bash
undefined

Discover by topic

按主题查找

./router.sh discover "authentication patterns"
./router.sh discover "authentication patterns"

Discover all context

查找所有上下文

./router.sh discover "all context files"
./router.sh discover "all context files"

Discover in specific directory

在指定目录中查找

./router.sh discover ".opencode/context/core/"

**Output**:
- List of discovered files with paths and sizes
- File statistics (count, total size, last updated)
- Categorization by type
- Suggestions for next steps

---
./router.sh discover ".opencode/context/core/"

**输出**:
- 包含路径和大小的已发现文件列表
- 文件统计信息(数量、总大小、最后更新时间)
- 按类型分类
- 下一步操作建议

---

Operation 2: FETCH

操作2:FETCH

Purpose: Fetch external documentation using ExternalScout
When to Use:
  • Need live documentation from external libraries
  • Setting up new external library integration
  • Need version-specific documentation
  • Want to cache external docs for team
Syntax:
fetch [libraries] [topics]
Examples:
bash
undefined
用途:使用ExternalScout获取外部文档
适用场景:
  • 需要外部库的实时文档
  • 搭建新的外部库集成
  • 需要特定版本的文档
  • 为团队缓存外部文档
语法:
fetch [libraries] [topics]
示例:
bash
undefined

Fetch single library

获取单个库的文档

./router.sh fetch "Drizzle ORM" "modular schemas"
./router.sh fetch "Drizzle ORM" "modular schemas"

Fetch multiple libraries

获取多个库的文档

./router.sh fetch "Drizzle ORM" "Better Auth" "Next.js" "modular schemas" "integration" "app router"
./router.sh fetch "Drizzle ORM" "Better Auth" "Next.js" "modular schemas" "integration" "app router"

Fetch with specific query

按特定查询获取

./router.sh fetch "Better Auth" "Next.js App Router integration with Drizzle adapter"

**Output**:
- Fetched files with paths
- File sizes and statistics
- Source URLs
- How to reference in context
- Manifest updates

---
./router.sh fetch "Better Auth" "Next.js App Router integration with Drizzle adapter"

**输出**:
- 已获取文件的路径
- 文件大小和统计信息
- 源URL
- 如何在上下文中引用
- 清单更新

---

Operation 3: HARVEST

操作3:HARVEST

Purpose: Extract context from summary files and create permanent context
When to Use:
  • Have summary documents that should become context
  • Need to convert temporary notes to permanent context
  • Want to extract key concepts from larger documents
  • Need to organize scattered information
Syntax:
harvest [source-file]
Examples:
bash
undefined
用途:从摘要文件中提取上下文并创建永久上下文
适用场景:
  • 有需要转化为上下文的摘要文档
  • 需要将临时笔记转为永久上下文
  • 希望从大型文档中提取关键概念
  • 需要整理分散的信息
语法:
harvest [source-file]
示例:
bash
undefined

Harvest from analysis

从分析文档中采集

./router.sh harvest DEVELOPER_PROFILE_ANALYSIS.md
./router.sh harvest DEVELOPER_PROFILE_ANALYSIS.md

Harvest from brainstorm

从头脑风暴文档中采集

./router.sh harvest AGENT_NAMING_BRAINSTORM.md
./router.sh harvest AGENT_NAMING_BRAINSTORM.md

Harvest from UX analysis

从UX分析文档中采集

./router.sh harvest UX_ANALYSIS_THREE_MAIN_AGENTS.md

**Output**:
- Created context file path
- Space saved (original vs. harvested)
- Content structure
- Updated navigation files
- How to use the new context

---
./router.sh harvest UX_ANALYSIS_THREE_MAIN_AGENTS.md

**输出**:
- 创建的上下文文件路径
- 节省的空间(原文件 vs 采集后文件)
- 内容结构
- 更新的导航文件
- 如何使用新上下文

---

Operation 4: EXTRACT

操作4:EXTRACT

Purpose: Extract specific information from context files
When to Use:
  • Need specific information from context
  • Creating summaries or reports
  • Building context bundles for subagents
  • Validating context completeness
Syntax:
extract [file] [what-to-extract]
Examples:
bash
undefined
用途:从上下文文件中提取特定信息
适用场景:
  • 需要从上下文中获取特定信息
  • 创建摘要或报告
  • 为子Agent构建上下文包
  • 验证上下文完整性
语法:
extract [file] [what-to-extract]
示例:
bash
undefined

Extract naming conventions

提取命名规范

./router.sh extract code-quality.md "naming conventions"
./router.sh extract code-quality.md "naming conventions"

Extract test patterns

提取测试模式

./router.sh extract test-coverage.md "test patterns"
./router.sh extract test-coverage.md "test patterns"

Extract all standards

提取所有标准

./router.sh extract ".opencode/context/core/" "all standards"

**Output**:
- Extracted information organized by topic
- Source file citations
- Relevance scores
- Usage suggestions
- Next steps

---
./router.sh extract ".opencode/context/core/" "all standards"

**输出**:
- 按主题组织的提取信息
- 源文件引用
- 相关性评分
- 使用建议
- 下一步操作

---

Operation 5: COMPRESS

操作5:COMPRESS

Purpose: Compress large context files to save space
When to Use:
  • Context files are very large (>100 KB)
  • Need to reduce disk space usage
  • Archiving old context
  • Preparing context for distribution
Syntax:
compress [target] [size-threshold]
Examples:
bash
undefined
用途:压缩大体积上下文文件以节省空间
适用场景:
  • 上下文文件体积过大(>100 KB)
  • 需要减少磁盘空间占用
  • 归档旧上下文
  • 准备待分发的上下文
语法:
compress [target] [size-threshold]
示例:
bash
undefined

Compress large files

压缩大文件

./router.sh compress ".opencode/context/" "100 KB"
./router.sh compress ".opencode/context/" "100 KB"

Compress all context

压缩所有上下文

./router.sh compress ".opencode/context/"
./router.sh compress ".opencode/context/"

Compress and archive

压缩并归档

./router.sh compress ".opencode/context/development/" "50 KB"

**Output**:
- Compressed files with paths
- Space savings (before/after)
- Compression ratio
- Decompression instructions
- Manifest updates

---
./router.sh compress ".opencode/context/development/" "50 KB"

**输出**:
- 已压缩文件的路径
- 节省的空间(压缩前 vs 压缩后)
- 压缩比
- 解压说明
- 清单更新

---

Operation 6: ORGANIZE

操作6:ORGANIZE

Purpose: Reorganize context files by concern (what you're doing) rather than function
When to Use:
  • Context is scattered across multiple locations
  • Need to reorganize by concern/topic
  • Creating new context structure
  • Consolidating related context
Syntax:
organize [target]
Examples:
bash
undefined
用途:按关注点(当前执行的任务)而非功能重组上下文文件
适用场景:
  • 上下文分散在多个位置
  • 需要按关注点/主题重组
  • 创建新的上下文结构
  • 整合相关上下文
语法:
organize [target]
示例:
bash
undefined

Organize by concern

按关注点整理

./router.sh organize ".opencode/context/"
./router.sh organize ".opencode/context/"

Organize specific topic

整理特定主题

./router.sh organize ".opencode/context/development/"

**Output**:
- Current structure analysis
- Proposed new structure
- Files moved and reorganized
- Updated references
- Navigation updates
- New structure overview

---
./router.sh organize ".opencode/context/development/"

**输出**:
- 当前结构分析
- 建议的新结构
- 已移动和重组的文件
- 更新的引用
- 导航更新
- 新结构概览

---

Operation 7: CLEANUP

操作7:CLEANUP

Purpose: Clean up stale, temporary, or unused context files
When to Use:
  • Removing temporary files (.tmp/)
  • Deleting old external context (>7 days)
  • Removing duplicate context
  • Archiving unused context
Syntax:
cleanup [target] [older-than-days]
Examples:
bash
undefined
用途:清理过期、临时或未使用的上下文文件
适用场景:
  • 删除临时文件(.tmp/)
  • 删除旧的外部上下文(>7天)
  • 删除重复上下文
  • 归档未使用的上下文
语法:
cleanup [target] [older-than-days]
示例:
bash
undefined

Cleanup .tmp directory

清理.tmp目录

./router.sh cleanup ".tmp/"
./router.sh cleanup ".tmp/"

Cleanup old external context

清理旧的外部上下文

./router.sh cleanup ".tmp/external-context/" "7"
./router.sh cleanup ".tmp/external-context/" "7"

Cleanup stale sessions

清理过期会话

./router.sh cleanup ".tmp/sessions/" "3"

**Output**:
- Files to be deleted
- Space to be freed
- Impact analysis
- Recovery instructions
- Manifest updates

---
./router.sh cleanup ".tmp/sessions/" "3"

**输出**:
- 待删除文件列表
- 可释放的空间
- 影响分析
- 恢复说明
- 清单更新

---

Operation 8: PROCESS

操作8:PROCESS

Purpose: Provide guided workflow for processing context
When to Use:
  • Need step-by-step guidance on context operations
  • Processing multiple context files
  • Learning context management workflow
  • Automating context processing
Syntax:
process [goal] [scope]
Examples:
bash
undefined
用途:为上下文处理提供引导式工作流
适用场景:
  • 需要上下文操作的分步引导
  • 处理多个上下文文件
  • 学习上下文管理工作流
  • 自动化上下文处理
语法:
process [goal] [scope]
示例:
bash
undefined

Process authentication context

处理认证上下文

./router.sh process "organize authentication context" ".opencode/context/development/"
./router.sh process "organize authentication context" ".opencode/context/development/"

Process all development context

处理所有开发上下文

./router.sh process "organize all development context" ".opencode/context/development/"
./router.sh process "organize all development context" ".opencode/context/development/"

Process external context

处理外部上下文

./router.sh process "fetch, persist, and reference external context" ".tmp/external-context/"

**Output**:
- Step-by-step workflow
- Progress indicators
- Discovered context
- Processing plan
- Execution results
- Validation results
- Summary and next steps

---
./router.sh process "fetch, persist, and reference external context" ".tmp/external-context/"

**输出**:
- 分步工作流
- 进度指示器
- 已发现的上下文
- 处理计划
- 执行结果
- 验证结果
- 总结和下一步操作

---

Common Workflows

常见工作流

Workflow 1: Discover & Extract

工作流1:发现与提取

1. discover context for: "authentication"
   → Find all auth-related context

2. extract from: "security-patterns.md" what: "auth patterns"
   → Get specific patterns

3. Show results
   → Ready to use in session
1. discover context for: "authentication"
   → 查找所有与认证相关的上下文

2. extract from: "security-patterns.md" what: "auth patterns"
   → 获取特定模式

3. 展示结果
   → 可在会话中直接使用

Workflow 2: Fetch & Reference

工作流2:获取与引用

1. fetch external docs for: "Drizzle ORM"
   → Get live documentation

2. Show file paths
   → .tmp/external-context/drizzle-orm/...

3. Reference in session context
   → Add to "## External Context Fetched"

4. Pass to subagents
   → Include in subtask JSONs
1. fetch external docs for: "Drizzle ORM"
   → 获取实时文档

2. 展示文件路径
   → .tmp/external-context/drizzle-orm/...

3. 在会话上下文中引用
   → 添加至"## External Context Fetched"

4. 传递给子Agent
   → 包含在子任务JSON中

Workflow 3: Harvest & Organize

工作流3:采集与整理

1. harvest context from: "ANALYSIS.md"
   → Extract key concepts

2. organize context by: "concern"
   → Restructure for clarity

3. Update documentation
   → Show new structure

4. Delete original summary
   → Clean up temporary files
1. harvest context from: "ANALYSIS.md"
   → 提取关键概念

2. organize context by: "concern"
   → 重组以提升清晰度

3. 更新文档
   → 展示新结构

4. 删除原始摘要
   → 清理临时文件

Workflow 4: Cleanup & Maintain

工作流4:清理与维护

1. cleanup .tmp/ directory
   → Remove temporary files

2. cleanup external context older than: "7 days"
   → Remove stale external docs

3. Show space freed
   → Provide statistics

4. Update manifest
   → Keep tracking accurate

1. cleanup .tmp/ directory
   → 删除临时文件

2. cleanup external context older than: "7 days"
   → 删除过期外部文档

3. 展示释放的空间
   → 提供统计信息

4. 更新清单
   → 保持追踪准确性

Key Principles

核心原则

1. Lazy Loading

1. 懒加载

  • Discover files first (glob, grep)
  • Load only what's needed (read specific files)
  • Process incrementally (don't load entire repo)
  • Reference context files, don't duplicate
  • 先发现文件(glob、grep)
  • 仅加载所需内容(读取特定文件)
  • 增量处理(不加载整个仓库)
  • 引用上下文文件,不重复复制

2. Clear Guidance

2. 清晰引导

  • Explain what you're doing at each step
  • Show file paths and sizes
  • Provide before/after metrics
  • Suggest next steps
  • Ask for confirmation before destructive operations
  • 每一步都说明正在执行的操作
  • 展示文件路径和大小
  • 提供操作前后的指标
  • 建议下一步操作
  • 执行破坏性操作前请求确认

3. Context Reference

3. 上下文引用

  • When discovering: cite which files found
  • When processing: reference standards applied
  • When organizing: show which patterns used
  • When cleaning: explain what's being removed
  • 发现时:注明找到的文件
  • 处理时:引用所应用的标准
  • 整理时:展示所使用的模式
  • 清理时:说明要删除的内容

4. Safe Operations

4. 安全操作

  • Ask for confirmation before destructive ops
  • Create backups when needed
  • Verify integrity after operations
  • Provide recovery instructions

  • 执行破坏性操作前请求确认
  • 必要时创建备份
  • 操作后验证完整性
  • 提供恢复说明

File Structure

文件结构

.opencode/skills/context-manager/
├── SKILL.md                          # This file
├── router.sh                         # CLI router (entry point)
├── CONTEXT_SKILL_QUICK_START.md      # Quick start guide
├── context-manager.md                # Detailed operation guide
└── navigation.md                     # Navigation index

.opencode/skills/context-manager/
├── SKILL.md                          # 本文档
├── router.sh                         # CLI 路由(入口点)
├── CONTEXT_SKILL_QUICK_START.md      # 快速入门指南
├── context-manager.md                # 详细操作指南
└── navigation.md                     # 导航索引

Integration Points

集成点

With ContextScout

与ContextScout集成

  • ContextScout discovers context files
  • This skill helps organize what ContextScout finds
  • Can harvest context from ContextScout results
  • ContextScout 发现上下文文件
  • 本Skill帮助整理ContextScout发现的内容
  • 可从ContextScout的结果中采集上下文

With ExternalScout

与ExternalScout集成

  • ExternalScout fetches external documentation
  • This skill persists and organizes fetched docs
  • Can reference external context in operations
  • ExternalScout 获取外部文档
  • 本Skill持久化并整理已获取的文档
  • 可在操作中引用外部上下文

With TaskManager

与TaskManager集成

  • TaskManager references context in task definitions
  • This skill ensures context files exist and are valid
  • Can catalog which tasks use which context
  • TaskManager 在任务定义中引用上下文
  • 本Skill确保上下文文件存在且有效
  • 可记录哪些任务使用了哪些上下文

With Other Subagents

与其他子Agent集成

  • All subagents depend on context structure
  • This skill maintains and validates context
  • Can identify context gaps that subagents need

  • 所有子Agent都依赖上下文结构
  • 本Skill维护并验证上下文
  • 可识别子Agent所需的上下文缺口

Success Criteria

成功标准

You succeed when: ✅ Context files are discovered efficiently ✅ External documentation is fetched and persisted ✅ Context is harvested from summaries ✅ Key information is extracted clearly ✅ Large files are compressed safely ✅ Context is organized by concern ✅ Stale files are cleaned up safely ✅ User has clear guidance at each step ✅ All operations are reversible ✅ Documentation is updated

当满足以下条件时,操作成功: ✅ 上下文文件被高效发现 ✅ 外部文档被获取并持久化 ✅ 从摘要中采集到上下文 ✅ 关键信息被清晰提取 ✅ 大文件被安全压缩 ✅ 上下文按关注点整理完成 ✅ 过期文件被安全清理 ✅ 用户在每一步都获得清晰引导 ✅ 所有操作均可逆转 ✅ 文档已更新

Tips & Best Practices

技巧与最佳实践

1. Regular Discovery

1. 定期发现

Run discover operations regularly to understand your context structure and identify gaps.
定期执行discover操作,了解上下文结构并识别缺口。

2. Organize by Concern

2. 按关注点整理

Organize context by what you're doing (authentication, testing, etc.) not by function (standards, guides).
按当前执行的任务(认证、测试等)而非功能(标准、指南)来组织上下文。

3. Lazy Load External Docs

3. 懒加载外部文档

Fetch external documentation only when needed, not preemptively.
仅在需要时获取外部文档,而非预先获取。

4. Harvest Summaries

4. 采集摘要文档

Convert temporary analysis documents into permanent context using harvest.
使用harvest将临时分析文档转化为永久上下文。

5. Regular Cleanup

5. 定期清理

Schedule regular cleanup operations to remove stale temporary files.
定期执行cleanup操作,删除过期临时文件。

6. Validate After Changes

6. 变更后验证

Always validate context integrity after making changes.
在做出变更后,始终验证上下文的完整性。

7. Document Organization

7. 维护导航文档

Keep navigation.md files up-to-date as you organize context.
整理上下文时,保持navigation.md文件的更新。

8. Reference Standards

8. 引用标准

When extracting context, always cite the source files.

提取上下文时,始终注明源文件。

Troubleshooting

故障排除

"Context files not found"

"未找到上下文文件"

Run
discover all context files
to see what exists and where.
执行
discover all context files
查看现有内容及其位置。

"External docs failed to fetch"

"获取外部文档失败"

Check that the library name is correct and ExternalScout is available.
检查库名称是否正确,以及ExternalScout是否可用。

"Harvest created empty file"

"采集后创建了空文件"

The source file may not have enough high-signal content. Review and add manually.
源文件可能缺少足够的高价值内容,请检查并手动补充。

"Organization failed"

"整理操作失败"

Check that all referenced files exist and navigation.md is valid.
检查所有引用的文件是否存在,以及navigation.md是否有效。

"Cleanup removed too much"

"清理操作删除了过多内容"

Check the backup at
.backup/cleanup-{date}.tar.gz
for recovery.

Context Manager Skill - Discover, organize, and maintain your project context!
查看
.backup/cleanup-{date}.tar.gz
备份文件进行恢复。

Context Manager Skill - 发现、整理并维护你的项目上下文!