
Security News
/Research
Fake Corepack Site Distributes Infostealer and Proxyware to Developers
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.
@deepracticex/context-manager
Advanced tools
Simple and powerful AI context formatter with layered XML structure
简单而强大的AI上下文格式化器,专注于文本组装,职责单一
职责单一,专注格式化
npm install @deepracticex/context-manager
import { ContextManager } from '@deepracticex/context-manager';
// 基础使用
const context = ContextManager.format({
role: "You are a helpful assistant",
current: "Hello world"
});
console.log(context);
// 输出:
// <context>
// <role>You are a helpful assistant</role>
//
// <current>Hello world</current>
// </context>
| 层级 | 标签 | 说明 | 可选 |
|---|---|---|---|
| 第一层 | <role> | AI角色定义 | ✅ |
| 第二层 | <tools> | MCP工具列表 | ✅ |
| 第三层 | <conversation> | 历史对话 | ✅ |
| 第四层 | <current> | 当前消息 | ✅ |
const context = ContextManager.format({
role: "You are a frontend developer with expertise in React",
tools: [
"code_analyzer: 分析代码质量和性能",
"debugger: 帮助调试问题",
"optimizer: 提供优化建议"
],
conversation: [
"User: 你好,我需要帮助优化我的React应用",
"Assistant: 你好!我很乐意帮助你优化React应用。请告诉我具体遇到了什么问题?",
"User: 我的组件渲染很慢,特别是列表组件"
],
current: "这是我的列表组件代码,请帮我看看性能问题"
});
输出:
<context>
<role>You are a frontend developer with expertise in React</role>
<tools>
- code_analyzer: 分析代码质量和性能
- debugger: 帮助调试问题
- optimizer: 提供优化建议
</tools>
<conversation>
User: 你好,我需要帮助优化我的React应用
Assistant: 你好!我很乐意帮助你优化React应用。请告诉我具体遇到了什么问题?
User: 我的组件渲染很慢,特别是列表组件
</conversation>
<current>这是我的列表组件代码,请帮我看看性能问题</current>
</context>
// 只要角色和当前消息
const simple = ContextManager.format({
role: "You are a coding assistant",
current: "Help me write a function"
});
// 只要工具和当前消息
const withTools = ContextManager.format({
tools: ["generator: 代码生成", "reviewer: 代码审查"],
current: "Generate a React component"
});
// 只要对话历史
const historyOnly = ContextManager.format({
conversation: ["User: Hello", "Assistant: Hi!"],
current: "How are you?"
});
// 工具:数组格式(自动添加 "- " 前缀)
ContextManager.format({
tools: ["analyzer: 分析", "debugger: 调试"]
});
// 工具:字符串格式(直接使用)
ContextManager.format({
tools: "analyzer: 分析工具\ndebugger: 调试工具"
});
// 对话:数组格式(换行拼接)
ContextManager.format({
conversation: ["User: Hello", "Assistant: Hi"]
});
// 对话:字符串格式(直接使用)
ContextManager.format({
conversation: "User: Hello\nAssistant: Hi"
});
// 禁用根标签
const withoutRoot = ContextManager.format(data, {
includeRootTag: false
});
// 自定义空行间距
const customSpacing = ContextManager.format(data, {
spacingLines: 2
});
ContextManager.format(data, options?)唯一核心方法,负责所有上下文格式化
参数:
data: ContextData - 上下文数据,所有层都是可选的options?: FormatOptions - 格式化选项返回: string - 格式化后的XML字符串
ContextData 接口interface ContextData {
role?: string; // 角色层
tools?: string | string[]; // 工具层
conversation?: string | string[]; // 对话层
current?: string; // 当前消息层
}
FormatOptions 接口interface FormatOptions {
includeRootTag?: boolean; // 是否包含 <context> 根标签,默认 true
spacingLines?: number; // 层级间空行数量,默认 1
}
MIT
欢迎提交 Issue 和 Pull Request!
简单而强大,专注于做好一件事 🎯
FAQs
Simple and powerful AI context formatter with layered XML structure
The npm package @deepracticex/context-manager receives a total of 1 weekly downloads. As such, @deepracticex/context-manager popularity was classified as not popular.
We found that @deepracticex/context-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
/Research
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.

Research
/Security News
A large-scale campaign abused GitHub Actions in compromised repositories to exploit CVE-2026-41940 in cPanel and WHM and steal server credentials.

Security News
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.