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
53 changes: 26 additions & 27 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,77 @@
name: Bug Report
description: Report a confirmed defect or regression
title: "bug: "
name: 问题反馈
description: 报告已确认的缺陷或回归问题
title: "问题:"
labels:
- bug
body:
- type: markdown
attributes:
value: |
Provide a reproducible report. Include exact commands, config, and observed behavior.
请尽量提供可复现的信息,包括命令、配置、实际表现和预期结果。
- type: input
id: summary
attributes:
label: Summary
description: One-sentence description of the bug
placeholder: codex_workdir is ignored by /home and the directory browser Home action
label: 问题概述
description: 用一句话描述你遇到的问题
placeholder: codex_workdir /home 和目录浏览器的 Home 按钮中没有生效
validations:
required: true

- type: textarea
id: environment
attributes:
label: Environment
description: Python, PDM, NoneBot, adapter, OS, and any relevant Codex setup details
label: 运行环境
description: 填写 Python、PDMNoneBot、适配器、操作系统以及相关 Codex 环境信息
placeholder: |
Python:
PDM:
NoneBot:
Adapter:
OS:
Codex CLI:
Python 版本:
PDM 版本:
NoneBot 版本:
Adapter 版本:
操作系统:
Codex CLI
validations:
required: true

- type: textarea
id: reproduce
attributes:
label: Steps To Reproduce
description: Provide exact steps or commands
label: 复现步骤
description: 提供可以稳定复现问题的步骤或命令
placeholder: |
1. Configure codex_workdir = "/tmp/work"
2. Start the bot
3. Run /home
4. Observe the reported workdir
1. 配置 codex_workdir = "/tmp/work"
2. 启动机器人
3. 执行 /home
4. 观察返回的工作目录
validations:
required: true

- type: textarea
id: expected
attributes:
label: Expected Behavior
label: 预期行为
validations:
required: true

- type: textarea
id: actual
attributes:
label: Actual Behavior
label: 实际行为
validations:
required: true

- type: textarea
id: evidence
attributes:
label: Verification Evidence
description: Include failing tests, logs, screenshots, or command output summaries
label: 补充信息
description: 可填写失败测试、日志、截图或命令输出摘要

- type: textarea
id: affected
attributes:
label: Affected Files Or Commands
label: 相关文件或命令
placeholder: |
src/nonebot_plugin_codex/service.py
src/nonebot_plugin_codex/telegram.py
/home
/cd
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Repository Plans
- name: 仓库规划文档
url: https://github.com/ttiee/nonebot-plugin-codex/tree/main/docs/plans
about: Review existing design and implementation planning documents before opening broad-scoped requests.

about: 在提交范围较大的请求前,请先查看现有设计文档和实现计划。
29 changes: 14 additions & 15 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
name: Feature Request
description: Propose an improvement or new capability
title: "feat: "
name: 功能请求
description: 提议一个改进或新能力
title: "功能:"
labels:
- enhancement
body:
- type: markdown
attributes:
value: |
Describe the user problem first, then the proposed solution.
请先描述用户问题,再说明你希望的解决方案。

- type: input
id: summary
attributes:
label: Summary
placeholder: Add button panels for mode/model/effort/permission commands
label: 功能概述
placeholder: 为 /mode/model/effort/permission 增加按钮面板
validations:
required: true

- type: textarea
id: problem
attributes:
label: Problem Statement
description: What is hard, missing, or error-prone today?
label: 问题背景
description: 当前使用上有什么困难、缺失或容易出错的地方?
validations:
required: true

- type: textarea
id: proposal
attributes:
label: Proposed Solution
label: 建议方案
validations:
required: true

- type: textarea
id: alternatives
attributes:
label: Alternatives Considered
label: 备选方案

- type: textarea
id: scope
attributes:
label: Scope And Constraints
description: Compatibility, migration, UX, or testing constraints that matter
label: 范围与约束
description: 这里填写兼容性、迁移、交互或测试方面的约束

- type: textarea
id: verification
attributes:
label: Verification Plan
description: Tests, manual checks, or rollout validation you expect

label: 验证计划
description: 希望如何验证这个功能,例如测试、手工检查或上线确认
11 changes: 5 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
## Summary
## 变更摘要

-

## Linked Issue
## 关联 Issue

Closes #

## What Changed
## 具体改动

-

## Verification
## 验证

- [ ] `pdm run pytest -q`
- [ ] `pdm run ruff check .`

## Risks / Follow-Ups
## 风险 / 后续项

-

99 changes: 99 additions & 0 deletions docs/plans/2026-03-12-model-cache-and-cn-templates-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Model Cache Fallback And Chinese Templates Design

## Background

The repository still has one confirmed runtime defect: if the configured model cache file is missing, `get_preferences()` currently tries to build default preferences via `load_models()`, which makes non-model commands fail early. At the same time, the repository's new GitHub issue templates and PR template are still written in English, while the project's user-facing language and maintainer preference are Chinese.

## Goals

- Fix the remaining bug where non-model commands fail when the model cache file is missing.
- Keep model-specific commands honest: they may still require model metadata, but generic commands should not.
- Localize the GitHub issue templates into Chinese.
- Localize the PR template into Chinese as well for consistency.

## Non-Goals

- Do not redesign the Telegram command flow again.
- Do not add external configuration discovery beyond the current Codex config and existing settings.
- Do not change issue labels or broader repo governance.

## Root Cause

`CodexBridgeService.get_preferences()` lazily creates default preferences through `_default_preferences()`. That method currently loads the model cache first, even though many call sites only need a summary of current settings or the current workdir. As a result, commands like `/pwd`, `/codex` without a prompt, and `/new` can fail with `FileNotFoundError` before the user reaches any model-specific operation.

## Approach Options

### Option 1: Catch FileNotFoundError in handlers

Wrap more handlers in `FileNotFoundError` handling and keep the service logic unchanged.

- Pros: very small code diff
- Cons: symptom fix only; the service still couples generic preference creation to model metadata

### Option 2: Decouple default preferences from model cache

Make `_default_preferences()` prefer `~/.codex/config.toml` values first, then safe fallback defaults, and only consult the model cache when available for normalization.

- Pros: fixes the root cause at the service layer, keeps generic commands usable, preserves existing behavior when metadata exists
- Cons: needs careful tests so model-specific commands still behave intentionally

### Option 3: Allow missing model in preferences

Let preferences hold `model=None` and push the requirement down to execution-time paths only.

- Pros: semantically explicit
- Cons: much wider type and formatting churn than necessary

## Recommended Design

Use Option 2.

### Service Behavior

- `_default_preferences()` should stop hard-requiring `load_models()`.
- It should:
- read `codex_config_path` first
- if the model cache is available, preserve the current normalization behavior
- if the model cache is missing or invalid, fall back to the configured model/effort from `config.toml`
- if even that is missing, use a small internal default such as `gpt-5` and `high`

This keeps generic preference creation stable while avoiding a large `None`-propagation refactor.

### Command Expectations

- These should work even if the model cache file is absent:
- `/pwd`
- `/codex` without prompt
- `/new`
- These may still require model metadata and can continue to error clearly if it is missing:
- `/models`
- `/model`
- `/effort`
- model and effort selector panels

### Template Localization

Translate the current GitHub-facing templates to Chinese:

- `.github/ISSUE_TEMPLATE/bug_report.yml`
- `.github/ISSUE_TEMPLATE/feature_request.yml`
- `.github/ISSUE_TEMPLATE/config.yml`
- `.github/pull_request_template.md`

The structure should remain the same; only the repository-facing language and helper copy need localization.

### Testing

Add failing tests first for:

- service default preferences without a model cache
- handler paths that should stay usable without a model cache
- presence of Chinese wording in the issue and PR templates

## Risks And Mitigations

- Risk: fallback defaults may diverge from an individual user's actual Codex defaults.
Mitigation: prefer `codex_config_path` values before any hardcoded fallback.

- Risk: a broad fallback could accidentally hide model-metadata errors everywhere.
Mitigation: keep `load_models()`-dependent commands unchanged; only decouple generic preference creation.
Loading
Loading