stevesolun/ctx

GitHub: stevesolun/ctx

ctx 是一个上下文推荐系统,解决 LLM 开发中技能发现、上下文管理和工具集成的问题。

Stars: 454 | Forks: 54

# ctx — 技能、代理、MCP与Harness推荐 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Python 3.11+](https://img.shields.io/badge/Python-3.11+-green.svg)](https://python.org) [![PyPI](https://img.shields.io/pypi/v/claude-ctx.svg)](https://pypi.org/project/claude-ctx/) [![Tests](https://img.shields.io/badge/Tests-3915_collected-brightgreen.svg)](#) [![Graph](https://img.shields.io/badge/Graph-102%2C928_nodes_/_2.9M_edges-red.svg)](graph/) [![Docs](https://img.shields.io/badge/docs-MkDocs_Material-blue.svg)](https://stevesolun.github.io/ctx/) [![Repo views](https://hits.sh/github.com/stevesolun/ctx.svg?label=repo%20views)](https://hits.sh/github.com/stevesolun/ctx/) ctx 监视你正在构建的内容,遍历一个 **102,928 节点** 的图,并为当前任务推荐一个小型、高评分的技能、代理和MCP服务器组合包。如果你使用自己的本地/API模型而非Claude Code,ctx 有一个单独的Harness设置流程:告知其模型和目标,审阅推荐的Harness,然后通过试运行/更新/卸载控件进行安装。 当前发布快照: - **91,464 个技能实体页面**,其中 **89,465** 个已填充可安装的 `SKILL.md` 主体。 - **467 个代理**,**10,790 个MCP服务器**,以及 **207 个Harness**。 - **290 万条图边**,涵盖语义相似性、标签、标识符令牌、源重叠、直接链接、质量、使用情况、类型关联和图结构。 - **28,612 个长技能主体**通过微技能关卡转换,而非直接发送原始长提示。 - 技能、代理、MCP和Harness的实体更新会打印收益/风险,除非你明确批准更新,否则跳过替换。 ## 存在原因 - **发现** — 面对9万多个技能页面、460多个代理、1万多MCP服务器和207个Harness,你不可能知道它们哪些存在或哪些适用于你当前的工作。 - **上下文预算** — 加载所有内容会浪费token并降低质量。你需要每个会话正确的10-15项。 - **技能腐化** — 你几个月前安装却从未使用的技能正污染上下文。陈旧的技能应被自动标记。 ## 安装 ``` pip install claude-ctx ctx-init # terminal wizard: hooks, graph, model, harness goal ctx-init --graph --hooks --model-mode skip # fast runtime graph + Claude Code hooks ctx-init --graph --graph-install-mode full # expand the full markdown wiki locally ctx-init --wizard # force the same wizard from scripts/tests ctx-init --model-mode custom --model openai/gpt-5.5 --goal "build a CAD agent" ``` 可选额外包:`pip install "claude-ctx[embeddings]"` 用于语义后端,`pip install "claude-ctx[harness]"` 用于本地/API模型Harness运行,`pip install "claude-ctx[dev]"` 用于测试工具链。 ### 预构建知识图 基于图的推荐需要预构建的图。默认情况下,`ctx-init --graph` 安装快速运行时构件:在源代码检出中为 `graph/wiki-graph-runtime.tar.gz`,或在pip安装中匹配相应的GitHub发布资产。 它包含 `graphify-out/*`,即推荐所需的已发布技能索引,以及 `ctx-harness-install` 所需的207个Harness页面: ``` ctx-init --graph ``` 完整的LLM-wiki构件仍可用于本地浏览、Obsidian和扩展的Markdown页面: ``` ctx-init --graph --graph-install-mode full ``` 完整的 `wiki-graph.tar.gz` 包含已发布的技能索引、位于 `entities/skills/` 下的91,464个技能实体页面、位于 `converted/` 下的89,465个已填充可安装的 `SKILL.md` 文件,以及位于 `entities/harnesses/` 下的207个Harness页面。 ## 使用 在运行 `ctx-init --hooks` 或向导钩子步骤后,ctx 会观察Claude Code的 `PostToolUse` 和 `Stop` 事件。典型流程: ``` ctx-scan-repo --repo . # scan current repo and stack signals ctx-scan-repo --repo . --recommend # include skill/agent/MCP recommendations ctx-agent-add --agent-path ./code-reviewer.md --name code-reviewer ctx-harness-add --repo https://github.com/earthtojake/text-to-cad --tag cad ctx-harness-install text-to-cad --dry-run # inspect before cloning/running anything ctx-harness-install text-to-cad # install after reviewing the plan ctx-harness-install text-to-cad --update --dry-run ctx-harness-install text-to-cad --uninstall --dry-run ctx-skill-quality list # four-signal quality score for every skill ctx-skill-quality explain python-patterns # drill into a single skill ctx-skill-health dashboard # structural health + drift detection ctx-toolbox run --event pre-commit # run a council on the current diff ctx-monitor serve # local dashboard: http://127.0.0.1:8765/ ``` 推送前,运行本地PR门禁: ``` python scripts/ci_preflight.py --profile pr ``` 它使用与GitHub Actions相同的更改文件分类器,然后运行匹配的本地检查:统计、ruff、mypy、pip check、单元测试覆盖率、金丝雀测试、包构建、twine、文档、图验证、浏览器以及按需相似性门禁。在发布工作前使用 `--profile full`,即使对于仅文档或仅图的更改,也强制执行源码/包门禁。 **`ctx-monitor`** 仪表板显示当前加载的技能、代理、MCP服务器、已安装的Harness记录以及通用Harness验证/升级状态。它在ctx拥有实时操作的地方提供加载/卸载按钮、图视图(`/graph?slug=...`)、LLM-wiki实体浏览器(`/wiki/`)、可过滤的技能网格、会话时间线、审计/运行时日志视图以及实时SSE事件流。已安装的Harness记录出现在 `/loaded`;Harness页面出现在 `/wiki` 和 `/graph`。Harness的安装/更新/卸载操作保留在 `ctx-harness-install` 中。 当 `ctx-skill-add`、`ctx-agent-add`、`ctx-mcp-add` 或 `ctx-harness-add` 发现实体已存在时,ctx 会打印收益/风险更新审阅,并默认跳过替换。使用 `--update-existing` 重新运行可在审阅后应用目录或本地资产更新。 逐步实体入门指南: **** 完整文档、架构及所有模块:**** ## 许可证 MIT — 参见 [LICENSE](LICENSE)。
标签:AI代理, Claude Code, harness设置, LLM, MCP服务器, PyPI, Python, Unmanaged PE, 上下文优化, 人工智能, 代理推荐, 图遍历, 安装控制, 技能推荐, 推荐系统, 无后门, 用户模式Hook绕过, 自定义LLM, 逆向工具