oricore 1.3.6 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +84 -137
  2. package/README.zh-CN.md +81 -134
  3. package/dist/core/context.d.ts +3 -0
  4. package/dist/core/globalData.d.ts +2 -0
  5. package/dist/core/loop.d.ts +1 -1
  6. package/dist/core/model/aliases.d.ts +2 -0
  7. package/dist/core/model/models.d.ts +2 -0
  8. package/dist/core/model/providers.d.ts +12 -0
  9. package/dist/core/model/proxy.d.ts +12 -0
  10. package/dist/core/model/resolution.d.ts +17 -0
  11. package/dist/core/model/types.d.ts +65 -0
  12. package/dist/core/model/utils.d.ts +11 -0
  13. package/dist/core/model.d.ts +13 -80
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.js +2569 -2319
  16. package/dist/tools/tools/bash.d.ts +4 -20
  17. package/dist/utils/background-detection.d.ts +1 -1
  18. package/dist/utils/bash/constants.d.ts +20 -0
  19. package/dist/utils/bash/output.d.ts +49 -0
  20. package/dist/utils/bash/security.d.ts +46 -0
  21. package/package.json +1 -1
  22. package/src/api/engine.ts +16 -2
  23. package/src/core/context.ts +6 -0
  24. package/src/core/globalData.ts +15 -0
  25. package/src/core/loop.ts +22 -5
  26. package/src/core/model/aliases.ts +12 -0
  27. package/src/core/model/models.ts +1014 -0
  28. package/src/core/model/providers.ts +919 -0
  29. package/src/core/model/proxy.ts +42 -0
  30. package/src/core/model/resolution.ts +422 -0
  31. package/src/core/model/types.ts +76 -0
  32. package/src/core/model/utils.ts +41 -0
  33. package/src/core/model.ts +32 -2255
  34. package/src/core/promptCache.ts +39 -16
  35. package/src/index.ts +17 -0
  36. package/src/tools/tools/bash.integration.test.ts +516 -0
  37. package/src/tools/tools/bash.test.ts +35 -323
  38. package/src/tools/tools/bash.ts +214 -507
  39. package/src/utils/background-detection.ts +3 -8
  40. package/src/utils/bash/constants.ts +52 -0
  41. package/src/utils/bash/output.test.ts +461 -0
  42. package/src/utils/bash/output.ts +145 -0
  43. package/src/utils/bash/security.test.ts +315 -0
  44. package/src/utils/bash/security.ts +234 -0
  45. package/src/core/thinking-config.ts +0 -98
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # OriCore
4
4
 
5
- **A powerful, standalone AI engine with multi-model support, tool calling, and extensible architecture**
5
+ **Powerful AI Engine Library - Build Smart Assistants in 5 Lines of Code**
6
6
 
7
7
  [![npm version](https://badge.fury.io/js/oricore.svg)](https://www.npmjs.com/package/oricore)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -11,202 +11,149 @@
11
11
 
12
12
  </div>
13
13
 
14
- ## About OriCore
14
+ ---
15
15
 
16
- OriCore is a comprehensive AI engine that provides the core functionality for building intelligent assistants. It offers a rich set of tools, multi-model support, and extensible architecture through MCP (Model Context Protocol) and Skills.
16
+ ## What is OriCore?
17
17
 
18
- ### Key Features
18
+ OriCore is a fully-featured **AI Engine Library** that lets you easily integrate powerful AI capabilities into any application.
19
19
 
20
- - **Multi-Model Support**: Compatible with 40+ AI providers including OpenAI, Anthropic, Google, DeepSeek, and more
21
- - **Rich Tool System**: Built-in tools for file operations (read, write, edit), code search (grep, glob), shell commands, and web requests
22
- - **Interaction Modes**: Specialized modes for different tasks - brainstorming, planning, code review, debugging, and default
23
- - **MCP Integration**: Extensible via Model Context Protocol for custom tools and capabilities
24
- - **Skill System**: Load and use custom skills from local or remote sources (GitHub, GitLab)
25
- - **Agent Framework**: Built-in agents for complex multi-step tasks (explore, general-purpose)
26
- - **Session Management**: Persistent conversation history with session resumption
27
- - **Streaming Support**: Real-time text delta streaming for responsive interactions
28
- - **Fully Typed**: Complete TypeScript support with comprehensive type definitions
29
- - **Zero Configuration**: Works out of the box with sensible defaults
20
+ - **Support for 40+ AI providers** (OpenAI, Claude, DeepSeek, Zhipu AI, etc.)
21
+ - **Complete built-in tool system** (file read/write, code search, shell commands, network requests)
22
+ - **Session management** + **Context compression**
23
+ - **MCP protocol** + **Skill system** for unlimited extensions
24
+ - **5 professional interaction modes** (brainstorm, plan, review, debug, default)
30
25
 
31
- ### Use Cases
26
+ Build AI-powered products with just **5 lines of code**:
32
27
 
33
- - Build custom AI assistants
34
- - Integrate AI capabilities into IDE extensions
35
- - Create automated code review systems
36
- - Develop intelligent debugging tools
37
- - Build educational platforms
38
- - Implement automated documentation generation
39
-
40
- ## Installation
41
-
42
- ```bash
43
- npm install oricore
44
- ```
28
+ ```typescript
29
+ import { createEngine } from 'oricore';
45
30
 
46
- ```bash
47
- # Using pnpm
48
- pnpm add oricore
31
+ const engine = createEngine({ productName: 'MyApp', version: '1.0.0' });
32
+ await engine.initialize({ model: 'deepseek/deepseek-chat', provider: { deepseek: { apiKey: 'your-key' } } });
49
33
 
50
- # Using bun
51
- bun add oricore
34
+ const result = await engine.sendMessage({ message: 'Analyze this project structure', write: true });
35
+ console.log(result.data.text);
52
36
  ```
53
37
 
54
- ### Optional Dependencies
38
+ ---
55
39
 
56
- OriCore has support for additional features through optional dependencies:
40
+ ## Quick Start
57
41
 
58
- **PDF Support**
59
42
  ```bash
60
- npm install pdf-parse
43
+ npm install oricore ai
61
44
  ```
62
- The `read` tool can parse PDF files when `pdf-parse` is installed. Without it, PDF reading will be disabled.
63
-
64
- ## Quick Start
65
45
 
66
46
  ```typescript
67
47
  import { createEngine } from 'oricore';
68
48
 
69
- // 1. Create the engine
70
- const engine = createEngine({
71
- productName: 'MyAIAssistant',
72
- version: '1.0.0',
73
- });
74
-
75
- // 2. Initialize with model and API key
49
+ const engine = createEngine({ productName: 'MyAIAssistant', version: '1.0.0' });
76
50
  await engine.initialize({
77
- model: 'openai/gpt-5.2-codex',
78
- provider: {
79
- openai: {
80
- apiKey: 'your-api-key',
81
- baseURL: 'https://api.openai.com/v1',
82
- },
83
- },
51
+ model: 'deepseek/deepseek-chat',
52
+ provider: { deepseek: { apiKey: 'your-api-key' } },
84
53
  });
85
54
 
86
- // 3. Send a message
87
55
  const result = await engine.sendMessage({
88
- message: 'Create a TypeScript function to calculate fibonacci',
56
+ message: 'Create a TypeScript function to calculate Fibonacci',
89
57
  write: true,
90
58
  });
91
59
 
92
60
  console.log(result.data.text);
93
-
94
- // 4. Cleanup
95
61
  await engine.shutdown();
96
62
  ```
97
63
 
98
- ## Interaction Modes
64
+ [📖 5-Minute Quick Start Guide](docs/QUICKSTART.md)
99
65
 
100
- OriCore provides specialized modes for different tasks:
66
+ ---
101
67
 
102
- ```typescript
103
- // Brainstorm mode - interactive design exploration
104
- engine.setMode('brainstorm');
105
- const design = await engine.sendMessageWithMode('I want to build a task management app');
68
+ ## Why OriCore?
106
69
 
107
- // Plan mode - create implementation plans
108
- engine.setMode('plan');
109
- const plan = await engine.sendMessageWithMode('Create a plan for adding user authentication');
70
+ | What You Need | OriCore | Others |
71
+ |---------------|---------|--------|
72
+ | **Build an AI assistant fast** | 5 lines of code | ❌ 100+ lines of setup |
73
+ | **Work with any AI provider** | ✅ 40+ providers unified | ⚠️ Provider-specific SDKs |
74
+ | **Ready-to-use tools** | ✅ File, shell, search, web | ❌ Build everything yourself |
75
+ | **Save on API costs** | ✅ Auto context compression | ❌ Pay for full context every time |
76
+ | **Extend with plugins** | ✅ MCP + Skills | ❌ Complex or impossible |
77
+ | **Switch AI providers** | ✅ Change 1 line of code | ❌ Rewrite integration code |
110
78
 
111
- // Review mode - code review and analysis
112
- engine.setMode('review');
113
- const review = await engine.sendMessageWithMode('Review this code: ...');
79
+ **Built for developers who need to ship AI features fast:**
114
80
 
115
- // Debug mode - troubleshooting
116
- engine.setMode('debug');
117
- const fix = await engine.sendMessageWithMode('Help debug this error: ...');
118
- ```
81
+ - **5-minute setup** - Get a working AI assistant with file access, code search, and shell commands
82
+ - **No vendor lock-in** - Switch between OpenAI, Claude, DeepSeek, etc. anytime
83
+ - **Production-ready** - Built-in session persistence, cost tracking, and error handling
84
+ - **Extensible** - Add custom tools via MCP servers or local skill files
85
+ - **AI-aware** - Context compression and specialized modes for different tasks
119
86
 
120
- ## Built-in Tools
87
+ ---
121
88
 
122
- OriCore includes a comprehensive set of tools:
89
+ ## Built-in Tools
123
90
 
124
- | Tool | Description |
125
- |------|-------------|
126
- | `read` | Read file contents (supports text, images, and PDF*) |
127
- | `write` | Write new files |
128
- | `edit` | Edit existing files with search/replace |
91
+ | Tool | Function |
92
+ |------|----------|
93
+ | `read` | Read files (text, images, PDF) |
94
+ | `write` | Write files |
95
+ | `edit` | Edit files (search & replace) |
129
96
  | `glob` | Find files by pattern |
130
97
  | `grep` | Search file contents |
131
98
  | `bash` | Execute shell commands |
132
99
  | `fetch` | Make HTTP requests |
133
- | `askUserQuestion` | Interactive Q&A with users |
134
- | `task` | Spawn specialized agents |
100
+ | `task` | Launch specialized agents |
135
101
  | `todo` | Track task progress |
102
+ | `askUserQuestion` | Interactive Q&A with users |
136
103
 
137
- *PDF support requires the optional `pdf-parse` package (see below)
104
+ [📖 Tools Documentation](docs/TOOLS.md)
138
105
 
139
- ## Configuration
106
+ ---
140
107
 
141
- ### Full Configuration Example
108
+ ## Use Cases
142
109
 
143
- ```typescript
144
- await engine.initialize({
145
- model: 'openai/gpt-5.2-codex',
146
- planModel: 'openai/gpt-5.2-codex',
147
- approvalMode: 'autoEdit',
148
- language: 'en',
149
- tools: {
150
- read: true,
151
- write: true,
152
- bash: true,
153
- },
154
- provider: {
155
- openai: {
156
- apiKey: 'your-api-key',
157
- baseURL: 'https://api.openai.com/v1',
158
- },
159
- },
160
- });
161
- ```
110
+ - **Build Custom AI Assistants** - Chatbots, customer service systems
111
+ - **IDE Integration** - Code assistants, smart autocomplete
112
+ - **Code Review** - Automated code review systems
113
+ - **Debugging Tools** - Intelligent error diagnosis
114
+ - **Education Platforms** - Programming teaching assistants
115
+ - **Documentation Generation** - Automated documentation generation
162
116
 
163
- ### Supported Providers
117
+ ---
164
118
 
165
- | Provider | Model Example | API Base URL |
166
- |----------|---------------|--------------|
167
- | OpenAI | `openai/gpt-5.2-codex` | `https://api.openai.com/v1` |
168
- | Anthropic | `anthropic/claude-opus-4-5` | `https://api.anthropic.com` |
169
- | Google | `google/gemini-3-flash-preview` | `https://generativelanguage.googleapis.com` |
170
- | DeepSeek | `deepseek/deepseek-chat` | `https://api.deepseek.com` |
171
- | Zhipu AI | `zhipuai/glm-4.7` | `https://open.bigmodel.cn/api/paas/v4` |
119
+ ## Documentation
172
120
 
173
- See [USAGE.md](./USAGE.md) for more configuration options.
121
+ ### Getting Started
122
+ - **[5-Minute Quick Start](docs/QUICKSTART.md)** - Get up to speed with OriCore
123
+ - **[Tutorials](docs/TUTORIALS.md)** - Practical examples
174
124
 
175
- **Tool Approval System:** See [APPROVAL.md](./APPROVAL.md) for detailed information about the approval system, including approval modes (`default`, `autoEdit`, `yolo`), custom approval handlers, and best practices.
125
+ ### Core Features
126
+ - **[API Reference](docs/API.md)** - Complete API documentation
127
+ - **[Configuration Guide](docs/CONFIG.md)** - All configuration options
128
+ - **[Tools System](docs/TOOLS.md)** - Built-in tools guide
129
+ - **[Interaction Modes](docs/MODES.md)** - 5 professional modes
176
130
 
177
- ## Project Structure
131
+ ### Advanced Features
132
+ - **[Session Management](docs/SESSIONS.md)** - Persistence & context compression
133
+ - **[Event System](docs/EVENTS.md)** - Message bus & events
134
+ - **[MCP Integration](docs/MCP.md)** - MCP protocol support
135
+ - **[Skill System](docs/SKILLS.md)** - Custom skill loading
136
+ - **[Approval System](docs/APPROVAL.md)** - Tool execution permission control
178
137
 
179
- ```
180
- oricore/
181
- ├── src/
182
- │ ├── api/ # Main Engine API
183
- │ ├── core/ # Core functionality (loop, context, config)
184
- │ ├── tools/ # Built-in tools
185
- │ ├── modes/ # Interaction modes
186
- │ ├── mcp/ # MCP integration
187
- │ ├── skill/ # Skill system
188
- │ ├── agent/ # Agent framework
189
- │ ├── session/ # Session management
190
- │ └── utils/ # Utilities
191
- ├── examples/ # Usage examples
192
- └── dist/ # Compiled output
193
- ```
138
+ ---
194
139
 
195
- ## Statement
140
+ ## Acknowledgments
196
141
 
197
142
  This project references the core architecture of the following excellent project:
198
- - **[neovate-code](https://github.com/neovateai/neovate-code)** - Core AI engine architecture
199
143
 
200
- OriCore has been refactored and streamlined on this foundation, removing UI, CLI, and other peripheral features to focus on providing a lightweight, standalone AI engine library that can be easily integrated into any project.
144
+ **[neovate-code](https://github.com/neovateai/neovate-code)** - Core AI engine architecture
145
+
146
+ OriCore has been refactored and streamlined on this foundation, removing UI, CLI, and other peripheral features to focus on providing a powerful and standalone AI engine library that can be easily integrated into any project.
147
+
148
+ ---
201
149
 
202
150
  ## License
203
151
 
204
152
  MIT © [lyw405](https://github.com/lyw405)
205
153
 
206
- ## Contributing
207
-
208
- Contributions are welcome! Please feel free to submit a Pull Request.
154
+ ---
209
155
 
210
156
  ## Support
211
157
 
212
- If you have any questions or issues, please [open an issue](https://github.com/lyw405/oricore/issues) on GitHub.
158
+ - **GitHub**: [lyw405/oricore](https://github.com/lyw405/oricore)
159
+ - **Issues**: [Report a problem](https://github.com/lyw405/oricore/issues)
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # OriCore
4
4
 
5
- **强大的独立 AI 引擎,支持多模型、工具调用和可扩展架构**
5
+ **强大的 AI 引擎库,5 行代码构建智能助手**
6
6
 
7
7
  [![npm version](https://badge.fury.io/js/oricore.svg)](https://www.npmjs.com/package/oricore)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -11,202 +11,149 @@
11
11
 
12
12
  </div>
13
13
 
14
- ## 关于 OriCore
14
+ ---
15
15
 
16
- OriCore 是一个全面的 AI 引擎,为构建智能助手提供核心功能。它拥有丰富的工具集、多模型支持,以及通过 MCP(模型上下文协议)和 Skills 实现的可扩展架构。
16
+ ## 什么是 OriCore?
17
17
 
18
- ### 核心特性
18
+ OriCore 是一个功能完整的 **AI 引擎库**,让你可以轻松地在任何应用中集成强大的 AI 能力。
19
19
 
20
- - **多模型支持**:兼容 40+ AI 提供商,包括 OpenAI、AnthropicGoogle、DeepSeek
21
- - **丰富的工具系统**:内置文件操作(读、写、编辑)、代码搜索(grep、glob)、Shell 命令和 Web 请求工具
22
- - **交互模式**:针对不同任务的专用模式 - 头脑风暴、规划、代码审查、调试和默认模式
23
- - **MCP 集成**:通过模型上下文协议扩展自定义工具和功能
24
- - **技能系统**:从本地或远程源(GitHub、GitLab)加载和使用自定义技能
25
- - **Agent 框架**:用于复杂多步骤任务的内置 Agent(探索、通用)
26
- - **会话管理**:持久的对话历史,支持会话恢复
27
- - **流式支持**:实时文本增量流式传输,提供响应式交互
28
- - **完整的类型支持**:全面的 TypeScript 支持和类型定义
29
- - **零配置**:使用合理的默认值即可开箱即用
20
+ - 支持 **40+ AI 厂商**(OpenAI、Claude、DeepSeek、智谱等)
21
+ - 内置 **完整工具系统**(文件读写、代码搜索、Shell 命令、网络请求)
22
+ - **会话管理** + **上下文压缩**
23
+ - **MCP 协议** + **Skill 系统** 无限扩展
24
+ - **5 种专业交互模式**(头脑风暴、规划、审查、调试、默认)
30
25
 
31
- ### 使用场景
26
+ 只需要 **5 行代码**,就能给你的产品加上 AI:
32
27
 
33
- - 构建自定义 AI 助手
34
- - AI 功能集成到 IDE 扩展中
35
- - 创建自动化代码审查系统
36
- - 开发智能调试工具
37
- - 构建教育平台
38
- - 实现自动化文档生成
39
-
40
- ## 安装
41
-
42
- ```bash
43
- npm install oricore
44
- ```
28
+ ```typescript
29
+ import { createEngine } from 'oricore';
45
30
 
46
- ```bash
47
- # 使用 pnpm
48
- pnpm add oricore
31
+ const engine = createEngine({ productName: 'MyApp', version: '1.0.0' });
32
+ await engine.initialize({ model: 'deepseek/deepseek-chat', provider: { deepseek: { apiKey: 'your-key' } } });
49
33
 
50
- # 使用 bun
51
- bun add oricore
34
+ const result = await engine.sendMessage({ message: '帮我分析这个项目的结构', write: true });
35
+ console.log(result.data.text);
52
36
  ```
53
37
 
54
- ### 可选依赖
38
+ ---
55
39
 
56
- OriCore 支持通过可选依赖来扩展功能:
40
+ ## 快速开始
57
41
 
58
- **PDF 支持**
59
42
  ```bash
60
- npm install pdf-parse
43
+ npm install oricore ai
61
44
  ```
62
- 安装 `pdf-parse` 后,`read` 工具可以解析 PDF 文件。未安装时,PDF 读取功能将被禁用。
63
-
64
- ## 快速开始
65
45
 
66
46
  ```typescript
67
47
  import { createEngine } from 'oricore';
68
48
 
69
- // 1. 创建引擎
70
- const engine = createEngine({
71
- productName: 'MyAIAssistant',
72
- version: '1.0.0',
73
- });
74
-
75
- // 2. 初始化模型和 API Key
49
+ const engine = createEngine({ productName: 'MyAIAssistant', version: '1.0.0' });
76
50
  await engine.initialize({
77
- model: 'openai/gpt-5.2-codex',
78
- provider: {
79
- openai: {
80
- apiKey: 'your-api-key',
81
- baseURL: 'https://api.openai.com/v1',
82
- },
83
- },
51
+ model: 'deepseek/deepseek-chat',
52
+ provider: { deepseek: { apiKey: 'your-api-key' } },
84
53
  });
85
54
 
86
- // 3. 发送消息
87
55
  const result = await engine.sendMessage({
88
56
  message: '创建一个 TypeScript 函数来计算斐波那契数列',
89
57
  write: true,
90
58
  });
91
59
 
92
60
  console.log(result.data.text);
93
-
94
- // 4. 清理
95
61
  await engine.shutdown();
96
62
  ```
97
63
 
98
- ## 交互模式
64
+ [📖 5分钟上手指南](docs/QUICKSTART.zh-CN.md)
99
65
 
100
- OriCore 提供针对不同任务的专用模式:
66
+ ---
101
67
 
102
- ```typescript
103
- // 头脑风暴模式 - 交互式设计探索
104
- engine.setMode('brainstorm');
105
- const design = await engine.sendMessageWithMode('我想构建一个任务管理应用');
68
+ ## 为什么选择 OriCore?
106
69
 
107
- // 计划模式 - 创建实施计划
108
- engine.setMode('plan');
109
- const plan = await engine.sendMessageWithMode('制定用户认证系统的实施计划');
70
+ | 你的需求 | OriCore | 其他方案 |
71
+ |---------|---------|----------|
72
+ | **快速构建 AI 助手** | ✅ 5 行代码 | ❌ 100+ 行配置 |
73
+ | **对接任意 AI 厂商** | ✅ 40+ 厂商统一接口 | ⚠️ 各自独立的 SDK |
74
+ | **开箱即用的工具** | ✅ 文件、Shell、搜索、网络 | ❌ 全部自己实现 |
75
+ | **节省 API 成本** | ✅ 自动上下文压缩 | ❌ 每次都传完整上下文 |
76
+ | **插件扩展能力** | ✅ MCP + Skills | ❌ 复杂或无法实现 |
77
+ | **切换 AI 厂商** | ✅ 改一行代码 | ❌ 重写集成代码 |
110
78
 
111
- // 审查模式 - 代码审查和分析
112
- engine.setMode('review');
113
- const review = await engine.sendMessageWithMode('审查这段代码的性能');
79
+ **为需要快速交付 AI 功能的开发者打造:**
114
80
 
115
- // 调试模式 - 故障排除
116
- engine.setMode('debug');
117
- const fix = await engine.sendMessageWithMode('帮我调试这个错误');
118
- ```
81
+ - **5 分钟上手** - 立即获得具备文件访问、代码搜索、Shell 命令的 AI 助手
82
+ - **无厂商锁定** - 随时在 OpenAI、Claude、DeepSeek 等之间切换
83
+ - **生产就绪** - 内置会话持久化、成本追踪、错误处理
84
+ - **易于扩展** - 通过 MCP 服务器或本地技能文件添加自定义工具
85
+ - **AI 智能优化** - 上下文压缩和针对不同任务的专业模式
119
86
 
120
- ## 内置工具
87
+ ---
121
88
 
122
- OriCore 包含一套完整的工具:
89
+ ## 内置工具
123
90
 
124
- | 工具 | 描述 |
91
+ | 工具 | 功能 |
125
92
  |------|------|
126
- | `read` | 读取文件内容(支持文本、图片和 PDF*) |
127
- | `write` | 写入新文件 |
128
- | `edit` | 编辑现有文件(搜索/替换) |
93
+ | `read` | 读取文件(支持文本、图片、PDF |
94
+ | `write` | 写入文件 |
95
+ | `edit` | 编辑文件(搜索替换) |
129
96
  | `glob` | 按模式查找文件 |
130
97
  | `grep` | 搜索文件内容 |
131
98
  | `bash` | 执行 Shell 命令 |
132
99
  | `fetch` | 发起 HTTP 请求 |
133
- | `askUserQuestion` | 与用户交互式问答 |
134
100
  | `task` | 启动专用 Agent |
135
101
  | `todo` | 跟踪任务进度 |
102
+ | `askUserQuestion` | 与用户交互问答 |
136
103
 
137
- *PDF 支持需要安装可选的 `pdf-parse` 包(见上文)
104
+ [📖 工具系统详解](docs/TOOLS.md)
138
105
 
139
- ## 配置
106
+ ---
140
107
 
141
- ### 完整配置示例
108
+ ## 使用场景
142
109
 
143
- ```typescript
144
- await engine.initialize({
145
- model: 'openai/gpt-5.2-codex',
146
- planModel: 'openai/gpt-5.2-codex',
147
- approvalMode: 'autoEdit',
148
- language: 'zh-CN',
149
- tools: {
150
- read: true,
151
- write: true,
152
- bash: true,
153
- },
154
- provider: {
155
- openai: {
156
- apiKey: 'your-api-key',
157
- baseURL: 'https://api.openai.com/v1',
158
- },
159
- },
160
- });
161
- ```
110
+ - **构建自定义 AI 助手** - 聊天机器人、客服系统
111
+ - **IDE 集成** - 代码助手、智能补全
112
+ - **代码审查** - 自动化代码审查系统
113
+ - **调试工具** - 智能错误诊断
114
+ - **教育平台** - 编程教学助手
115
+ - **文档生成** - 自动化文档生成
162
116
 
163
- ### 支持的提供商
117
+ ---
164
118
 
165
- | 提供商 | 模型示例 | API 地址 |
166
- |----------|---------------|--------------|
167
- | OpenAI | `openai/gpt-5.2-codex` | `https://api.openai.com/v1` |
168
- | Anthropic | `anthropic/claude-opus-4-5` | `https://api.anthropic.com` |
169
- | Google | `google/gemini-3-flash-preview` | `https://generativelanguage.googleapis.com` |
170
- | DeepSeek | `deepseek/deepseek-chat` | `https://api.deepseek.com` |
171
- | 智谱 AI | `zhipuai/glm-4.7` | `https://open.bigmodel.cn/api/paas/v4` |
119
+ ## 文档导航
172
120
 
173
- 更多配置选项请参阅 [USAGE.zh-CN.md](./USAGE.zh-CN.md)。
121
+ ### 新手入门
122
+ - **[5分钟上手](docs/QUICKSTART.md)** - 快速了解 OriCore
123
+ - **[场景教程](docs/TUTORIALS.md)** - 实战示例
174
124
 
175
- **工具审批系统:** 有关审批系统的详细信息,包括审批模式(`default`、`autoEdit`、`yolo`)、自定义审批处理程序和最佳实践,请参阅 [APPROVAL.zh-CN.md](./APPROVAL.zh-CN.md)。
125
+ ### 核心功能
126
+ - **[API 参考](docs/API.md)** - 完整的 API 文档
127
+ - **[配置详解](docs/CONFIG.md)** - 所有配置选项
128
+ - **[工具系统](docs/TOOLS.md)** - 内置工具详解
129
+ - **[交互模式](docs/MODES.md)** - 5 种专业模式
176
130
 
177
- ## 项目结构
131
+ ### 高级功能
132
+ - **[会话管理](docs/SESSIONS.md)** - 持久化与上下文压缩
133
+ - **[事件系统](docs/EVENTS.md)** - 消息总线与事件
134
+ - **[MCP 集成](docs/MCP.md)** - MCP 协议支持
135
+ - **[Skill 系统](docs/SKILLS.md)** - 自定义技能加载
136
+ - **[审批系统](docs/APPROVAL.md)** - 工具执行权限控制
178
137
 
179
- ```
180
- oricore/
181
- ├── src/
182
- │ ├── api/ # 核心 API
183
- │ ├── core/ # 核心功能(循环、上下文、配置)
184
- │ ├── tools/ # 内置工具
185
- │ ├── modes/ # 交互模式
186
- │ ├── mcp/ # MCP 集成
187
- │ ├── skill/ # 技能系统
188
- │ ├── agent/ # Agent 框架
189
- │ ├── session/ # 会话管理
190
- │ └── utils/ # 工具函数
191
- ├── examples/ # 使用示例
192
- └── dist/ # 编译输出
193
- ```
138
+ ---
194
139
 
195
- ## 声明
140
+ ## 致谢
196
141
 
197
142
  本项目参考了以下优秀项目的核心架构:
198
- - **[neovate-code](https://github.com/neovateai/neovate-code)** - 核心 AI 引擎架构
199
143
 
200
- OriCore 在此基础上进行了重新封装和精简,移除了 UI、CLI 等周边功能,专注于提供一个轻量、独立的 AI 引擎库,可轻松集成到任何项目中。
144
+ **[neovate-code](https://github.com/neovateai/neovate-code)** - 核心 AI 引擎架构
145
+
146
+ OriCore 在此基础上进行了重构和精简,移除了 UI、CLI 等外围功能,专注于提供一个功能强大且独立的 AI 引擎库,可以轻松集成到任何项目中。
147
+
148
+ ---
201
149
 
202
150
  ## 许可证
203
151
 
204
152
  MIT © [lyw405](https://github.com/lyw405)
205
153
 
206
- ## 贡献
207
-
208
- 欢迎提交 Issue 和 Pull Request!
154
+ ---
209
155
 
210
156
  ## 支持
211
157
 
212
- 如有问题或建议,请访问 [GitHub Issues](https://github.com/lyw405/oricore/issues)
158
+ - **GitHub**: [lyw405/oricore](https://github.com/lyw405/oricore)
159
+ - **问题反馈**: [Issues](https://github.com/lyw405/oricore/issues)
@@ -1,6 +1,7 @@
1
1
  import { AgentManager } from '../agent/agent/agentManager';
2
2
  import { BackgroundTaskManager } from './backgroundTaskManager';
3
3
  import { type Config } from '../core/config';
4
+ import { GlobalData } from './globalData';
4
5
  import { MCPManager } from '../mcp/mcp';
5
6
  import type { MessageBus } from '../communication/messageBus';
6
7
  import { Paths } from './paths';
@@ -22,6 +23,7 @@ type ContextOpts = {
22
23
  agentManager?: AgentManager;
23
24
  plugins: (string | Plugin)[];
24
25
  fetch?: typeof globalThis.fetch;
26
+ globalData: GlobalData;
25
27
  };
26
28
  export type ContextCreateOpts = {
27
29
  cwd: string;
@@ -49,6 +51,7 @@ export declare class Context {
49
51
  agentManager?: AgentManager;
50
52
  plugins: (string | Plugin)[];
51
53
  fetch?: typeof globalThis.fetch;
54
+ globalData: GlobalData;
52
55
  constructor(opts: ContextOpts);
53
56
  apply(applyOpts: Omit<PluginApplyOpts, 'pluginContext'>): Promise<any>;
54
57
  destroy(): Promise<void>;
@@ -18,4 +18,6 @@ export declare class GlobalData {
18
18
  updateProjectLastAccessed({ cwd }: {
19
19
  cwd: string;
20
20
  }): void;
21
+ getRecentModels(): string[];
22
+ addRecentModel(model: string): void;
21
23
  }
@@ -2,7 +2,6 @@ import type { LanguageModelV3FunctionTool, LanguageModelV3Prompt, SharedV3Header
2
2
  import { History, type OnMessage } from '../core/history';
3
3
  import { type NormalizedMessage } from '../core/message';
4
4
  import type { ModelInfo } from '../core/model';
5
- import { type ReasoningEffort } from './thinking-config';
6
5
  import type { ToolApprovalResult, ToolResult, Tools, ToolUse } from '../tools/tool';
7
6
  import { Usage } from '../core/usage';
8
7
  export type LoopResult = {
@@ -46,6 +45,7 @@ export type ResponseFormat = {
46
45
  name?: string;
47
46
  description?: string;
48
47
  };
48
+ export type ReasoningEffort = 'low' | 'medium' | 'high' | 'max';
49
49
  export type ThinkingConfig = {
50
50
  effort: ReasoningEffort;
51
51
  };
@@ -0,0 +1,2 @@
1
+ import type { ModelAlias } from './types';
2
+ export declare const modelAlias: ModelAlias;
@@ -0,0 +1,2 @@
1
+ import type { ModelMap } from './types';
2
+ export declare const models: ModelMap;
@@ -0,0 +1,12 @@
1
+ import type { LanguageModelV3, LanguageModelV3Middleware } from '@ai-sdk/provider';
2
+ import type { Provider, ProvidersMap } from './types';
3
+ export declare const defaultModelCreator: (name: string, provider: Provider) => LanguageModelV3;
4
+ export declare const defaultAnthropicModelCreator: (name: string, provider: Provider) => LanguageModelV3;
5
+ export declare const openaiModelCreator: (name: string, provider: Provider) => LanguageModelV3;
6
+ export declare const openaiModelResponseCreator: (name: string, provider: Provider) => LanguageModelV3;
7
+ export declare const createModelCreatorCompatible: (opts?: {
8
+ headers?: Record<string, string>;
9
+ fetch?: any;
10
+ middlewares?: LanguageModelV3Middleware[];
11
+ }) => (name: string, provider: Provider) => LanguageModelV3;
12
+ export declare const providers: ProvidersMap;