
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
create-context-template
Advanced tools
CLI tool to scaffold LLM projects with context engineering architecture
快速创建基于上下文工程的 LLM 应用开发项目 | CLI tool to scaffold LLM projects with context engineering architecture
📚 相关资源:上下文工程实践指南 -深入学习上下文工程的设计理念和最佳实践
npm create context-template
pnpm create context-template
yarn create context-template
bun create context-template
npx create-context-template
npm install -g create-context-template
create-context-template
运行命令后,按照提示操作:
cd my-ai-app
cp .env.example .env
# 编辑 .env 文件,添加你的 DEEPSEEK_API_KEY
npm run dev # 简单对话示例
npm run dev:tool # 工具调用示例
cat docs/架构设计\ -\ 上下文工程.md
# 或在编辑器中打开
强烈建议先阅读架构文档,理解上下文工程的设计理念!
生成的项目包含以下模块:
my-ai-app/
├── core/ # 核心系统模块
│ ├── llm/ # LLM 服务层
│ │ ├── services/ # LLM 提供商实现(DeepSeek)
│ │ ├── utils/ # 工具函数(executeToolLoop)
│ │ └── factory.ts # LLM 服务工厂
│ ├── context/ # 上下文管理系统
│ │ ├── modules/ # 6 种上下文模块
│ │ └── ContextManager.ts # 统一管理器
│ ├── tool/ # 工具管理系统
│ │ ├── ReadFile/ # 文件读取工具
│ │ ├── ListFiles/ # 文件列表工具
│ │ └── ToolManager.ts # 工具管理器
│ ├── agent/ # Agent 编排
│ │ ├── SimpleAgent.ts # 简单 Agent 实现
│ │ └── MultiAgent.ts # 多 Agent 编排
│ └── promptManager/ # 提示词管理
├── evaluation/ # 测试评估系统
│ ├── EventBus.ts # 事件总线
│ ├── evaluate.ts # 评估器
│ └── example.ts # 评估示例
├── utils/ # 工具函数
│ └── logger.ts # 日志工具
├── config/ # 配置管理
│ └── env.ts # 环境变量加载
├── examples/ # 使用示例
│ ├── simple-chat.ts # 简单对话
│ └── multi-chat.ts # 多轮对话
└── docs/ # 项目文档
└── 架构设计 - 上下文工程.md # 核心架构文档 ⭐
基于 OpenAI SDK 实现的多模型支持:
核心方法:
complete(messages, tools) - 完整的 LLM 调用,支持工具simpleChat(userMessage, systemPrompt) - 简单对话generate(prompt) - 生成式调用基于上下文工程理念的 6 种上下文类型:
| 上下文类型 | 说明 | 用途 |
|---|---|---|
| ConversationContext | 会话历史记录 | 维护对话连续性 |
| ToolMessageSequenceContext | 工具调用序列 | 追踪工具使用历史 |
| MemoryContext | 用户记忆 | 长期记忆存储 |
| SystemPromptContext | 系统提示词 | 定义 AI 行为 |
| StructuredOutputContext | 结构化输出 | JSON 格式化输出 |
| RelevantContext | 相关上下文 | 动态相关信息 |
可扩展的工具调用框架:
内置工具:
工具定义规范:
SimpleAgent: 单一 Agent 实现 MultiAgent: 多 Agent 协作编排(预留扩展)
基于 EventBus 的测试评估框架:
本项目基于上下文工程的设计理念:
核心: LLM 模型是应用的关键核心 重心: 开发重心在上下文的获取和编排 优势: 随着模型能力提升,应用效果自动提升;同时充分发挥开发者的创造力
核心思想:
详细的架构设计请参考生成项目中的 docs/架构设计 - 上下文工程.md
import { createLLMService } from "./core/llm/index.js";
import { loadEnv } from "./config/env.js";
loadEnv();
const service = await createLLMService({
provider: "deepseek",
model: "deepseek-chat",
apiKey: process.env.DEEPSEEK_API_KEY,
});
const response = await service.simpleChat(
"Hello! Can you introduce yourself?",
"You are a helpful AI assistant."
);
console.log("Assistant:", response);
import { createLLMService } from "./core/llm/index.js";
import { ContextManager } from "./core/context/index.js";
import { ToolManager } from "./core/tool/index.js";
// 初始化上下文和工具
const contextManager = new ContextManager();
await contextManager.init();
const toolManager = new ToolManager();
// 创建 LLM 服务
const service = await createLLMService(
{
provider: "deepseek",
model: "deepseek-chat",
apiKey: process.env.DEEPSEEK_API_KEY,
},
toolManager
);
// 使用 generate 方法自动处理工具调用
const answer = await service.generate(
"请帮我读取 package.json 文件,并告诉我项目名称是什么"
);
console.log(answer);
git clone https://github.com/WakeUp-Jin/context-cli-template.git
cd context-cli-template
npm install
# 开发模式运行
npm run dev
# 构建
npm run build
# 本地测试
npm link
create-context-template
# 更新版本号
npm version patch # 1.0.0 -> 1.0.1
npm version minor # 1.0.0 -> 1.1.0
npm version major # 1.0.0 -> 2.0.0
# 发布到 npm
npm publish
欢迎贡献!如果你有任何建议或发现问题,请:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)感谢所有为这个项目做出贡献的开发者!
Made with ❤️ by WakeUp-Jin
如果这个项目对你有帮助,请给个 ⭐️ 吧!
FAQs
CLI tool to scaffold LLM projects with context engineering architecture
The npm package create-context-template receives a total of 0 weekly downloads. As such, create-context-template popularity was classified as not popular.
We found that create-context-template demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.