Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
- **🏗️ Workqueue & Background Tasks**: Enhanced the internal workqueue system for more robust background task management.
- **🧠 AI-Native Logic Flow**: Refined the agent's decision-making logic to be more efficient and better suited for complex multi-step coding tasks.

### Recent Improvements (v0.2.x)

- **🔍 Precise Code Reading (Read Tool)**: Introduced advanced navigation and positioning. Supports direct jumping to functions, classes, or line numbers via `symbol`, with 1-based line support and file structure previews, significantly boosting AI context retrieval efficiency.
- **📝 Enhanced Code Editing (Edit/MultiEdit)**:
- **Advanced Matching Strategies**: Supports `exact`, `fuzzy`, `block`, and `regex` matching, drastically improving the success rate of complex code modifications.
- **Range Constraints & Validation**: Added `anchorLines` to restrict search ranges, alongside `dryRun` and `validateOnly` modes for safer, more predictable edits.
- **Intelligent Error Feedback**: Provides smart suggestions on match failures (e.g., "Did you mean line X?"), enabling faster agent self-correction.
- **⚙️ Robust Task Scheduling (Work Queue)**:
- **Optimized Task Identification**: Improved task ID generation using hashing to prevent collisions in large-scale workflows.
- **Enhanced State Management**: Introduced granular failure handling (`isFailed`) to increase reliability during parallel execution.
- **💎 Code Quality & Standards**: Fully aligned with strict coding standards, adding comprehensive documentation and thread-safety annotations (`@VertxThreadSafety`) across core components.

---

[![OpenCode Terminal UI](packages/web/src/assets/lander/screenshot.png)](https://opencode.ai)
Expand Down
12 changes: 12 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
- **🏗️ 工作队列与后台任务**: 增强了内部工作队列系统,使后台任务管理更加健壮。
- **🧠 AI 原生逻辑流**: 优化了 Agent 的决策逻辑,使其更高效且更适合处理复杂的多步编码任务。

### 最近更新 (v0.2.x)

- **🔍 精准代码读取 (Read Tool)**: 引入了全新的导航与定位功能。支持通过 `symbol` 直接定位函数、类或行号,提供 1-based 行号支持和文件结构预览(Preview 模式),极大提升了 AI 获取代码上下文的效率。
- **📝 增强型代码编辑 (Edit/MultiEdit)**:
- **多种匹配策略**: 支持 `exact`(精确)、`fuzzy`(模糊)、`block`(块匹配)和 `regex`(正则)匹配,大幅提高复杂代码修改的成功率。
- **范围限制与验证**: 引入 `anchorLines` 限制修改范围,并增加 `dryRun` 和 `validateOnly` 模式,确保修改的安全性和准确性。
- **智能错误反馈**: 当匹配失败时,工具会提供智能建议(如“您是否是指第 X 行?”),帮助 Agent 快速自我纠错。
- **⚙️ 健壮的任务调度 (Work Queue)**:
- **任务标识优化**: 改进了任务 ID 生成算法(基于 Hash),避免了在大规模任务流中的 ID 碰撞。
- **状态管理增强**: 引入了更细致的任务失败处理逻辑 (`isFailed`),提升了并行执行时的可靠性。
- **💎 代码质量与标准**: 全面遵循严格的编码规范,并在核心组件中增加了详细的文档注释和线程安全说明 (`@VertxThreadSafety`)。

---

[![OpenCode Terminal UI](packages/web/src/assets/lander/screenshot.png)](https://opencode.ai)
Expand Down
65 changes: 37 additions & 28 deletions packages/opencode/src/global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,42 @@ export namespace Global {
config,
state,
}
}

await Promise.all([
fs.mkdir(Global.Path.data, { recursive: true }),
fs.mkdir(Global.Path.config, { recursive: true }),
fs.mkdir(Global.Path.state, { recursive: true }),
fs.mkdir(Global.Path.log, { recursive: true }),
fs.mkdir(Global.Path.bin, { recursive: true }),
])

const CACHE_VERSION = "21"

const version = await Bun.file(path.join(Global.Path.cache, "version"))
.text()
.catch(() => "0")

if (version !== CACHE_VERSION) {
try {
const contents = await fs.readdir(Global.Path.cache)
await Promise.all(
contents.map((item) =>
fs.rm(path.join(Global.Path.cache, item), {
recursive: true,
force: true,
}),
),
)
} catch (e) {}
await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
let initialized = false
export async function init() {
if (initialized) return
await Promise.all([
fs.mkdir(Global.Path.data, { recursive: true }),
fs.mkdir(Global.Path.config, { recursive: true }),
fs.mkdir(Global.Path.state, { recursive: true }),
fs.mkdir(Global.Path.log, { recursive: true }),
fs.mkdir(Global.Path.bin, { recursive: true }),
fs.mkdir(Global.Path.cache, { recursive: true }),
])

const CACHE_VERSION = "21"

const version = await Bun.file(path.join(Global.Path.cache, "version"))
.text()
.catch(() => "0")

if (version !== CACHE_VERSION) {
try {
const contents = await fs.readdir(Global.Path.cache)
await Promise.all(
contents.map((item) =>
fs.rm(path.join(Global.Path.cache, item), {
recursive: true,
force: true,
}),
),
)
} catch (e) {}
await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
}
initialized = true
}
}

// We still want to trigger initialization but not as a top-level await that blocks CJS require
Global.init().catch(console.error)
2 changes: 2 additions & 0 deletions packages/opencode/src/project/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Plugin } from "../plugin"
import { Global } from "../global"
import { Share } from "../share/share"
import { Format } from "../format"
import { LSP } from "../lsp"
Expand All @@ -16,6 +17,7 @@ import { Truncate } from "../tool/truncation"

export async function InstanceBootstrap() {
Log.Default.info("bootstrapping", { directory: Instance.directory })
await Global.init()
await Plugin.init()
Share.init()
ShareNext.init()
Expand Down
Loading