context-management-context-restore
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContext Restoration: Advanced Semantic Memory Rehydration
上下文恢复:高级语义内存复现
Use this skill when
适用场景
- Working on context restoration: advanced semantic memory rehydration tasks or workflows
- Needing guidance, best practices, or checklists for context restoration: advanced semantic memory rehydration
- 处理上下文恢复:高级语义内存复现任务或工作流时
- 需要上下文恢复相关的指导、最佳实践或检查清单:高级语义内存复现
Do not use this skill when
不适用场景
- The task is unrelated to context restoration: advanced semantic memory rehydration
- You need a different domain or tool outside this scope
- 任务与上下文恢复:高级语义内存复现无关时
- 需要此范围之外的其他领域或工具时
Instructions
操作说明
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open .
resources/implementation-playbook.md
- 明确目标、约束条件和所需输入。
- 应用相关最佳实践并验证结果。
- 提供可执行步骤和验证方法。
- 如果需要详细示例,请打开。
resources/implementation-playbook.md
Role Statement
角色说明
Expert Context Restoration Specialist focused on intelligent, semantic-aware context retrieval and reconstruction across complex multi-agent AI workflows. Specializes in preserving and reconstructing project knowledge with high fidelity and minimal information loss.
专注于复杂多Agent AI工作流中智能、语义感知的上下文检索与重构的资深上下文恢复专家。擅长以高保真度、最小信息损失的方式保存和重构项目知识。
Context Overview
上下文概述
The Context Restoration tool is a sophisticated memory management system designed to:
- Recover and reconstruct project context across distributed AI workflows
- Enable seamless continuity in complex, long-running projects
- Provide intelligent, semantically-aware context rehydration
- Maintain historical knowledge integrity and decision traceability
Context Restoration工具是一套复杂的内存管理系统,旨在:
- 在分布式AI工作流中恢复和重构项目上下文
- 实现复杂、长期运行项目的无缝连续性
- 提供智能、语义感知的上下文复现
- 维护历史知识完整性和决策可追溯性
Core Requirements and Arguments
核心要求与参数
Input Parameters
输入参数
- : Primary context storage location (vector database, file system)
context_source - : Unique project namespace
project_identifier - :
restoration_mode- : Complete context restoration
full - : Partial context update
incremental - : Compare and merge context versions
diff
- : Maximum context tokens to restore (default: 8192)
token_budget - : Semantic similarity cutoff for context components (default: 0.75)
relevance_threshold
- :主要上下文存储位置(向量数据库、文件系统)
context_source - :唯一项目命名空间
project_identifier - :
restoration_mode- :完整上下文恢复
full - :部分上下文更新
incremental - :比较并合并上下文版本
diff
- :可恢复的最大上下文令牌数(默认值:8192)
token_budget - :上下文组件的语义相似度阈值(默认值:0.75)
relevance_threshold
Advanced Context Retrieval Strategies
高级上下文检索策略
1. Semantic Vector Search
1. 语义向量搜索
- Utilize multi-dimensional embedding models for context retrieval
- Employ cosine similarity and vector clustering techniques
- Support multi-modal embedding (text, code, architectural diagrams)
python
def semantic_context_retrieve(project_id, query_vector, top_k=5):
"""Semantically retrieve most relevant context vectors"""
vector_db = VectorDatabase(project_id)
matching_contexts = vector_db.search(
query_vector,
similarity_threshold=0.75,
max_results=top_k
)
return rank_and_filter_contexts(matching_contexts)- 利用多维度嵌入模型进行上下文检索
- 采用余弦相似度和向量聚类技术
- 支持多模态嵌入(文本、代码、架构图)
python
def semantic_context_retrieve(project_id, query_vector, top_k=5):
"""Semantically retrieve most relevant context vectors"""
vector_db = VectorDatabase(project_id)
matching_contexts = vector_db.search(
query_vector,
similarity_threshold=0.75,
max_results=top_k
)
return rank_and_filter_contexts(matching_contexts)2. Relevance Filtering and Ranking
2. 相关性过滤与排序
- Implement multi-stage relevance scoring
- Consider temporal decay, semantic similarity, and historical impact
- Dynamic weighting of context components
python
def rank_context_components(contexts, current_state):
"""Rank context components based on multiple relevance signals"""
ranked_contexts = []
for context in contexts:
relevance_score = calculate_composite_score(
semantic_similarity=context.semantic_score,
temporal_relevance=context.age_factor,
historical_impact=context.decision_weight
)
ranked_contexts.append((context, relevance_score))
return sorted(ranked_contexts, key=lambda x: x[1], reverse=True)- 实现多阶段相关性评分
- 考虑时间衰减、语义相似度和历史影响
- 动态加权上下文组件
python
def rank_context_components(contexts, current_state):
"""Rank context components based on multiple relevance signals"""
ranked_contexts = []
for context in contexts:
relevance_score = calculate_composite_score(
semantic_similarity=context.semantic_score,
temporal_relevance=context.age_factor,
historical_impact=context.decision_weight
)
ranked_contexts.append((context, relevance_score))
return sorted(ranked_contexts, key=lambda x: x[1], reverse=True)3. Context Rehydration Patterns
3. 上下文复现模式
- Implement incremental context loading
- Support partial and full context reconstruction
- Manage token budgets dynamically
python
def rehydrate_context(project_context, token_budget=8192):
"""Intelligent context rehydration with token budget management"""
context_components = [
'project_overview',
'architectural_decisions',
'technology_stack',
'recent_agent_work',
'known_issues'
]
prioritized_components = prioritize_components(context_components)
restored_context = {}
current_tokens = 0
for component in prioritized_components:
component_tokens = estimate_tokens(component)
if current_tokens + component_tokens <= token_budget:
restored_context[component] = load_component(component)
current_tokens += component_tokens
return restored_context- 实现增量式上下文加载
- 支持部分和完整上下文重构
- 动态管理令牌预算
python
def rehydrate_context(project_context, token_budget=8192):
"""Intelligent context rehydration with token budget management"""
context_components = [
'project_overview',
'architectural_decisions',
'technology_stack',
'recent_agent_work',
'known_issues'
]
prioritized_components = prioritize_components(context_components)
restored_context = {}
current_tokens = 0
for component in prioritized_components:
component_tokens = estimate_tokens(component)
if current_tokens + component_tokens <= token_budget:
restored_context[component] = load_component(component)
current_tokens += component_tokens
return restored_context4. Session State Reconstruction
4. 会话状态重构
- Reconstruct agent workflow state
- Preserve decision trails and reasoning contexts
- Support multi-agent collaboration history
- 重构Agent工作流状态
- 保留决策轨迹和推理上下文
- 支持多Agent协作历史
5. Context Merging and Conflict Resolution
5. 上下文合并与冲突解决
- Implement three-way merge strategies
- Detect and resolve semantic conflicts
- Maintain provenance and decision traceability
- 实现三方合并策略
- 检测并解决语义冲突
- 维护来源和决策可追溯性
6. Incremental Context Loading
6. 增量式上下文加载
- Support lazy loading of context components
- Implement context streaming for large projects
- Enable dynamic context expansion
- 支持上下文组件的懒加载
- 为大型项目实现上下文流式传输
- 启用动态上下文扩展
7. Context Validation and Integrity Checks
7. 上下文验证与完整性检查
- Cryptographic context signatures
- Semantic consistency verification
- Version compatibility checks
- 加密上下文签名
- 语义一致性验证
- 版本兼容性检查
8. Performance Optimization
8. 性能优化
- Implement efficient caching mechanisms
- Use probabilistic data structures for context indexing
- Optimize vector search algorithms
- 实现高效缓存机制
- 使用概率数据结构进行上下文索引
- 优化向量搜索算法
Reference Workflows
参考工作流
Workflow 1: Project Resumption
工作流1:项目恢复
- Retrieve most recent project context
- Validate context against current codebase
- Selectively restore relevant components
- Generate resumption summary
- 检索最新项目上下文
- 针对当前代码库验证上下文
- 选择性恢复相关组件
- 生成恢复摘要
Workflow 2: Cross-Project Knowledge Transfer
工作流2:跨项目知识迁移
- Extract semantic vectors from source project
- Map and transfer relevant knowledge
- Adapt context to target project's domain
- Validate knowledge transferability
- 从源项目提取语义向量
- 映射并迁移相关知识
- 调整上下文以适配目标项目领域
- 验证知识可迁移性
Usage Examples
使用示例
bash
undefinedbash
undefinedFull context restoration
完整上下文恢复
context-restore project:ai-assistant --mode full
context-restore project:ai-assistant --mode full
Incremental context update
增量式上下文更新
context-restore project:web-platform --mode incremental
context-restore project:web-platform --mode incremental
Semantic context query
语义上下文查询
context-restore project:ml-pipeline --query "model training strategy"
undefinedcontext-restore project:ml-pipeline --query "model training strategy"
undefinedIntegration Patterns
集成模式
- RAG (Retrieval Augmented Generation) pipelines
- Multi-agent workflow coordination
- Continuous learning systems
- Enterprise knowledge management
- RAG(检索增强生成)流水线
- 多Agent工作流协调
- 持续学习系统
- 企业知识管理
Future Roadmap
未来路线图
- Enhanced multi-modal embedding support
- Quantum-inspired vector search algorithms
- Self-healing context reconstruction
- Adaptive learning context strategies
- 增强多模态嵌入支持
- 类量子向量搜索算法
- 自修复上下文重构
- 自适应学习上下文策略