progressive-loading

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Table of Contents

目录

Progressive Loading Patterns

渐进式加载模式

Overview

概述

Progressive loading provides standardized patterns for building skills that load modules dynamically based on context, user intent, and available token budget. This prevents loading unnecessary content while ensuring required functionality is available when needed.
The core principle: Start minimal, expand intelligently, monitor continuously.
渐进式加载提供了标准化模式,用于构建可根据上下文、用户意图和可用token预算动态加载模块的skill。该方案可避免加载不必要的内容,同时确保需要时可用到所需功能。
核心理念:最小启动、智能扩展、持续监控

When To Use

适用场景

Use progressive loading when building skills that:
  • Cover multiple distinct workflows or domains
  • Need to manage context window efficiently
  • Have modules that are mutually exclusive based on context
  • Require MECW compliance for long-running sessions
  • Want to optimize for common paths while supporting edge cases
当构建的skill符合以下特征时可使用渐进式加载:
  • 覆盖多个不同的工作流或领域
  • 需要高效管理上下文窗口
  • 存在根据上下文互斥使用的模块
  • 长时间运行的会话需要符合MECW规范
  • 希望针对常用路径做优化,同时支持边缘场景

When NOT To Use

不适用场景

  • Project doesn't use the leyline infrastructure patterns
  • Simple scripts without service architecture needs
  • 项目未使用leyline基础设施模式
  • 没有服务架构需求的简单脚本

Quick Start

快速开始

Basic Hub Pattern

基础中心模式

markdown
undefined
markdown
undefined

Progressive Loading

Progressive Loading

Context A: Load
modules/loading-patterns.md
for scenario A Context B: Load
modules/selection-strategies.md
for scenario B
Always Available: Core utilities, exit criteria, integration points
**Verification:** Run the command with `--help` flag to verify availability.
Context A: Load
modules/loading-patterns.md
for scenario A Context B: Load
modules/selection-strategies.md
for scenario B
Always Available: Core utilities, exit criteria, integration points
**验证方式:** 执行带`--help`参数的命令验证可用性。

Context-Based Selection

基于上下文的选择

python
from leyline import ModuleSelector, MECWMonitor

selector = ModuleSelector(skill_path="my-skill/")
modules = selector.select_modules(
    context={"intent": "git-catchup", "artifacts": ["git", "python"]},
    max_tokens=MECWMonitor().get_safe_budget()
)
Verification: Run the command with
--help
flag to verify availability.
python
from leyline import ModuleSelector, MECWMonitor

selector = ModuleSelector(skill_path="my-skill/")
modules = selector.select_modules(
    context={"intent": "git-catchup", "artifacts": ["git", "python"]},
    max_tokens=MECWMonitor().get_safe_budget()
)
验证方式: 执行带
--help
参数的命令验证可用性。

Hub-and-Spoke Architecture

Hub-and-Spoke架构

Hub Responsibilities

中心职责

  1. Context Detection: Identify user intent, artifacts, workflow type
  2. Module Selection: Choose which modules to load based on context
  3. Budget Management: Verify MECW compliance before loading
  4. Integration Coordination: Provide integration points with other skills
  5. Exit Criteria: Define completion criteria across all paths
  1. 上下文检测:识别用户意图、产物、工作流类型
  2. 模块选择:根据上下文选择要加载的模块
  3. 预算管理:加载前校验是否符合MECW规范
  4. 集成协调:提供与其他skill的集成点
  5. 退出标准:定义所有路径的完成标准

Spoke Characteristics

辐射节点特性

  1. Single Responsibility: Each module serves one workflow or domain
  2. Self-Contained: Modules don't depend on other modules
  3. Context-Tagged: Clear indicators of when module applies
  4. Token-Budgeted: Known token cost for selection decisions
  5. Independently Testable: Can be evaluated in isolation
  1. 单一职责:每个模块仅服务一个工作流或领域
  2. 自包含:模块不依赖其他模块
  3. 上下文标记:清晰标注模块的适用场景
  4. token预算明确:已知模块的token消耗,用于选择决策
  5. 可独立测试:可单独进行评估验证

Selection Strategies

选择策略

See
modules/selection-strategies.md
for detailed strategies:
  • Intent-based: Load based on detected user goals
  • Artifact-based: Load based on detected files/systems
  • Budget-aware: Load within available token budget
  • Progressive: Load core first, expand as needed
  • Mutually-exclusive: Load one path from multiple options
查看
modules/selection-strategies.md
了解详细策略:
  • 基于意图:根据检测到的用户目标加载
  • 基于产物:根据检测到的文件/系统加载
  • 预算感知:在可用token预算范围内加载
  • 渐进式:先加载核心模块,按需扩展
  • 互斥选择:从多个选项中加载一条路径

Loading Patterns

加载模式

See
modules/loading-patterns.md
for implementation patterns:
  • Conditional includes: Dynamic module references
  • Lazy loading: Load on first use
  • Tiered disclosure: Core → common → edge cases
  • Context switching: Change loaded modules mid-session
  • Preemptive unloading: Remove unused modules under pressure
查看
modules/loading-patterns.md
了解实现模式:
  • 条件引入:动态模块引用
  • Lazy loading:首次使用时加载
  • 分层披露:核心→通用→边缘场景
  • 上下文切换:会话中更换已加载模块
  • 预卸载:资源压力下移除未使用的模块

Common Use Cases

常见用例

  • Multi-Domain Skills:
    imbue:catchup
    loads git/docs/logs modules by context
  • Context-Heavy Analysis: Load relevant modules only, defer deep-dives, unload completed
  • Plugin Infrastructure: Mix-and-match infrastructure modules with version checks
  • 多领域Skill
    imbue:catchup
    根据上下文加载git/docs/logs模块
  • 重上下文分析:仅加载相关模块,推迟深度分析,卸载已完成任务的模块
  • 插件基础设施:可组合基础设施模块,附带版本校验

Best Practices

最佳实践

  1. Design Hub First: Define all possible contexts and module boundaries
  2. Tag Modules Clearly: Use YAML frontmatter to indicate context triggers
  3. Measure Token Cost: Know the cost of each module for selection
  4. Monitor Loading: Track which modules are actually used
  5. Validate Paths: Verify all context paths have required modules
  6. Document Triggers: Make context detection logic transparent
  1. 优先设计中心层:定义所有可能的上下文和模块边界
  2. 清晰标记模块:使用YAML frontmatter标注上下文触发条件
  3. 测量token消耗:明确每个模块的成本,用于选择决策
  4. 监控加载情况:跟踪实际被使用的模块
  5. 路径校验:验证所有上下文路径都有对应的必需模块
  6. 文档化触发规则:上下文检测逻辑透明可查

Module References

模块参考

  • Selection Strategies: See
    modules/selection-strategies.md
    for choosing modules
  • Loading Patterns: See
    modules/loading-patterns.md
    for implementation techniques
  • Performance Budgeting: See
    modules/performance-budgeting.md
    for token budget model and optimization workflow
  • 选择策略:查看
    modules/selection-strategies.md
    了解模块选择方法
  • 加载模式:查看
    modules/loading-patterns.md
    了解实现技术
  • 性能预算:查看
    modules/performance-budgeting.md
    了解token预算模型和优化工作流

Integration with Other Skills

与其他Skill的集成

This skill provides foundational patterns referenced by:
  • abstract:modular-skills
    - Uses progressive loading for skill design
  • conserve:context-optimization
    - Uses for MECW-compliant loading
  • imbue:catchup
    - Uses for context-based module selection
  • Plugin authors building multi-workflow skills
Reference in your skill's frontmatter:
yaml
dependencies: [leyline:progressive-loading, leyline:mecw-patterns]
progressive_loading: true
Verification: Run the command with
--help
flag to verify availability.
本skill提供的基础模式被以下能力引用:
  • abstract:modular-skills
    - 采用渐进式加载做skill设计
  • conserve:context-optimization
    - 用于符合MECW规范的加载
  • imbue:catchup
    - 用于基于上下文的模块选择
  • 构建多工作流skill的插件开发者
在你的skill的frontmatter中引用:
yaml
dependencies: [leyline:progressive-loading, leyline:mecw-patterns]
progressive_loading: true
验证方式: 执行带
--help
参数的命令验证可用性。

Exit Criteria

退出标准

  • Hub clearly defines all module loading contexts
  • Each module is tagged with activation context
  • Module selection respects MECW constraints
  • Token costs measured for all modules
  • Context detection logic documented
  • Loading paths validated for completeness
  • 中心层明确定义所有模块加载上下文
  • 每个模块都标注了激活上下文
  • 模块选择符合MECW约束
  • 所有模块的token成本已测量
  • 上下文检测逻辑已文档化
  • 加载路径完整性已验证

Troubleshooting

故障排查

Common Issues

常见问题

Command not found Ensure all dependencies are installed and in PATH
Permission errors Check file permissions and run with appropriate privileges
Unexpected behavior Enable verbose logging with
--verbose
flag
命令未找到 确保所有依赖已安装且在PATH中
权限错误 检查文件权限,使用合适的权限执行
异常行为 添加
--verbose
参数开启详细日志排查