Token导航 LogoToken导航TokenDH.com
LLM-context.py logo
AI代理未说明官方级别未说明来源级核验

LLM-context.py

MCP Server

为LLM开发工作流提供智能上下文管理,通过规则化筛选和智能选择共享相关项目文件。

工具数

4

提示词数

0

GitHub Stars

300

资源数

0
代码管理PythonClaude工作流自动化Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

cyberchitta

提供方

cyberchitta

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

LLM背景

![License](https://opensource.org/licenses/Apache-2.0) ](https://pypi.org/project/llm-context/) ](https://pepy.tech/project/llm-context)

LLM开发工作流的智能上下文管理。 通过智能选择和基于规则的过滤,即时共享相关项目文件。

问题

在LLM对话中获得正确的背景是充满摩擦的:

  • 手动查找和复制相关文件浪费时间
  • 太多的上下文触及了令牌的极限,太少的上下文遗漏了重要的细节
  • 对其他文件的AI请求需要手动获取
  • 很难跟踪开发会议期间发生了什么变化

解决方案

llm上下文通过可组合规则提供专注的、特定于任务的项目上下文。

对于使用聊天界面的人:

lc-select   # Smart file selection
lc-context  # Copy formatted context to clipboard
# Paste and work - AI can access additional files via MCP

对于具有CLI访问权限的AI代理:

lc-preview tmp-prm-auth    # Validate rule selects right files
lc-context tmp-prm-auth    # Get focused context for sub-agent

对于聊天中的AI代理(MCP工具):

  • lc_outlines -从当前规则生成摘录上下文
  • lc_preview -使用前验证规则的有效性
  • lc_missing -按需获取特定文件/实现
备注:这个项目是与几个Claude十四行诗(3.5、3.6、3.7、4.0)和Groks(3、4)合作开发的,在开发过程中使用LLM Context本身共享代码。所有代码都是由@restlessronin精心策划的。

安装

uv tool install "llm-context>=0.6.0"

快速开始

人工工作流(剪贴板)

# One-time setup
cd your-project
lc-init

# Daily usage
lc-select
lc-context
# Paste into your LLM chat

MCP集成(推荐)

添加到Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "llm-context": {
      "command": "uvx",
      "args": ["--from", "llm-context", "lc-mcp"]
    }
  }
}

重新启动克劳德桌面。现在,AI可以在对话过程中访问其他文件,而无需手动复制。

代理工作流(CLI)

具有shell访问权限的AI代理使用llm上下文创建聚焦上下文:

# Agent explores codebase
lc-outlines

# Agent creates focused rule for specific task
# (via Skill or lc-rule-instructions)

# Agent validates rule
lc-preview tmp-prm-oauth-task

# Agent uses context for sub-task
lc-context tmp-prm-oauth-task

代理工作流(MCP)

聊天环境中的AI代理使用MCP工具:

# Explore codebase structure
lc_outlines(root_path, rule_name)

# Validate rule effectiveness  
lc_preview(root_path, rule_name)

# Fetch specific files/implementations
lc_missing(root_path, param_type, data, timestamp)

核心概念

规则:任务特定上下文描述符

规则是描述为任务提供什么上下文的YAML+Markdown文件:

---
description: "Debug API authentication"
compose:
  filters: [lc/flt-no-files]
  excerpters: [lc/exc-base]
also-include:
  full-files: ["/src/auth/**", "/tests/auth/**"]
---
Focus on authentication system and related tests.

五个规则类别

  • 提示规则(prm-):生成项目上下文(例如。, lc/prm-developer)
  • 筛选规则(flt-):控制文件包含(例如。, lc/flt-base, lc/flt-no-files)
  • 指令规则(ins-):提供指导方针(例如。, lc/ins-developer)
  • 风格规则(sty-):执行编码标准(例如。, lc/sty-python)
  • 摘录规则(exc-):配置内容提取(例如。, lc/exc-base)

规则组成

从简单规则构建复杂规则:

---
instructions: [lc/ins-developer, lc/sty-python]
compose:
  filters: [lc/flt-base, project-filters]
  excerpters: [lc/exc-base]
---

基本命令

命令目的
lc-init初始化项目配置
lc-select根据当前规则选择文件
lc-context生成并复制上下文
lc-context -p包括提示说明
lc-context -m格式化为单独的消息
lc-context -nt无工具(手动工作流程)
lc-set-rule 切换活动规则
lc-preview 验证规则选择和大小
lc-outlines获取代码结构摘录
lc-missing获取文件/实现(手动MCP)

人工智能辅助规则创建

让人工智能帮助创建专注的、特定任务的规则。根据您的环境,有两种方法:

克劳德技能(互动,克劳德桌面/代码)

运作原理:全局技能指导您以交互方式创建规则。根据需要使用MCP工具检查您的代码库。

设置:

lc-init  # Installs skill to ~/.claude/skills/
# Restart Claude Desktop or Claude Code

用法:

# 1. Share project context
lc-context  # Any rule - overview included

# 2. Paste into Claude, then ask:
# "Create a rule for refactoring authentication to JWT"
# "I need a rule to debug the payment processing"

克劳德将:

  1. 在上下文中使用项目概述
  2. 通过以下方式检查特定文件 lc-missing 根据需要
  3. 提出关于范围的澄清问题
  4. 生成优化规则(tmp-prm-.md)
  5. 提供验证说明

技能文档 (逐步披露):

  • Skill.md -快速的工作流程、决策模式
  • PATTERNS.md -常见规则模式
  • SYNTAX.md -详细参考
  • EXAMPLES.md -完整演练
  • TROUBLESHOOTING.md -解决问题

指令规则(适用于任何地方)

运作原理:将全面的规则创建文档加载到上下文中,使用任何LLM。

用法:

# 1. Load framework
lc-set-rule lc/prm-rule-create
lc-select
lc-context -nt

# 2. Paste into any LLM
# "I need a rule for adding OAuth integration"

# 3. LLM generates focused rule using framework

# 4. Use the new rule
lc-set-rule tmp-prm-oauth
lc-select
lc-context

包括文件:

  • lc/ins-rule-intro -引言与概述
  • lc/ins-rule-framework -完整的决策框架

比较

方面技能指导规则
设置自动带 lc-init已经可用
交互交互式,使用 lc-missing静态文档
档案检查通过MCP自动手动或通过AI
最适合克劳德桌面/代码任何LLM,任何环境
更新自动进行版本升级内置规则

两者都需要首先共享项目上下文。两者都产生了相同的结果。

项目定制

创建基本筛选器

cat > .llm-context/rules/flt-repo-base.md  .llm-context/rules/prm-code.md  /tmp/context.md
# Sub-agent reads context and executes task

代理上下文配置(MCP)

# Agent validates rule
preview = lc_preview(root_path="/path/to/project", rule_name="tmp-prm-task")

# Agent generates context
context = lc_outlines(root_path="/path/to/project")

# Agent fetches additional files as needed
files = lc_missing(root_path, "f", "['/proj/src/auth.py']", timestamp)

路径格式

所有路径都使用带有项目名称前缀的项目相对格式:

/{project-name}/src/module/file.py
/{project-name}/tests/test_module.py

这使得多项目上下文组合没有路径冲突。

在规则中,模式是相对于项目的,没有前缀:

also-include:
  full-files:
    - "/src/auth/**"      # ✓ Correct
    - "/myproject/src/**" # ✗ Wrong - don't include project name

了解更多

许可证

Apache许可证,版本2.0。看 许可证 了解详情。

目录标签

目录标签

代码管理PythonClaude工作流自动化LLM开发本地部署上下文管理AI工具自动化工作流

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

oauth

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明oauth部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP