Skip to content

Commit dbe25a4

Browse files
authored
Merge pull request #57 from harumiWeb/feat/edit-mcp
Feat/edit mcp
2 parents a538962 + bbb2510 commit dbe25a4

42 files changed

Lines changed: 6226 additions & 1066 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: codacy-issues-fetcher
3+
description: Retrieve and format Codacy analysis issues by running `scripts/codacy_issues.py` in the ExStruct workspace. Use when users ask to inspect repository or pull-request Codacy findings, filter by severity, or produce structured issue output for review and fix planning.
4+
---
5+
6+
# Codacy Issues Fetcher
7+
8+
Run `scripts/codacy_issues.py` as the primary interface to Codacy issue retrieval.
9+
Avoid reimplementing API calls unless the script itself must be changed.
10+
11+
## Workflow
12+
13+
1. Confirm prerequisites.
14+
- Run from repository root so `scripts/codacy_issues.py` is reachable.
15+
- Ensure `CODACY_API_TOKEN` is set and valid.
16+
- Prefer explicit `org` and `repo` if user provides them; otherwise rely on Git `origin` auto-detection.
17+
18+
2. Choose scope and severity.
19+
- Repository scope: omit `--pr`.
20+
- Pull request scope: pass `--pr <number>`.
21+
- Severity filter (`--min-level`): `Error`, `High`, `Warning`, `Info`.
22+
- Provider (`--provider`): `gh`, `gl`, `bb` (default is effectively `gh`).
23+
24+
3. Run one of the command patterns.
25+
26+
```powershell
27+
# Repository issues (explicit target)
28+
python scripts/codacy_issues.py <org> <repo> --provider gh --min-level Warning
29+
30+
# Pull request issues (explicit target)
31+
python scripts/codacy_issues.py <org> <repo> --pr <number> --provider gh --min-level Warning
32+
33+
# Pull request issues (auto-detect org/repo from git origin)
34+
python scripts/codacy_issues.py --pr <number> --min-level Warning
35+
```
36+
37+
4. Parse output JSON and respond with actionable summary.
38+
- Trust payload fields: `scope`, `organization`, `repository`, `pullRequest`, `minLevel`, `total`, `issues`.
39+
- `issues` entries are formatted as:
40+
`<level> | <file_path>:<line_no> | <rule> | <category> | <message>`
41+
- Report high-severity findings first, then summarize counts.
42+
43+
## Error Handling
44+
45+
- `HTTP 401` / `Unauthorized`: token invalid or missing permissions. Ask user to set or refresh `CODACY_API_TOKEN`.
46+
- `CODACY_API_TOKEN is not set`: export the environment variable before retrying.
47+
- `Invalid --provider`: use only `gh`, `gl`, or `bb`.
48+
- Segment validation errors (`Invalid org/repo/pr`): sanitize input and rerun.
49+
50+
## Output Policy
51+
52+
- Return concise triage-ready results, not raw command logs.
53+
- Include the exact command you used when reproducibility matters.
54+
- If no issues match the selected `--min-level`, state that explicitly.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Codacy Issues Fetcher"
3+
short_description: "Run codacy_issues.py to fetch and triage Codacy findings"
4+
default_prompt: "Use $codacy-issues-fetcher to collect Codacy issues for this repository or PR and summarize the highest-priority fixes."

.bandit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bandit]
2+
exclude_dirs = tests,benchmark

.codacy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
exclude_paths:
22
- "benchmark/**"
3+
- "tests/**"

AGENTS.md

Lines changed: 13 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@ AI は必ず次のルールに従ってコードを生成してください。
4747

4848
### 2.4 import の順序
4949

50-
```
51-
5250
1. 標準ライブラリ
5351
2. サードパーティ
5452
3. exstruct 内のモジュール
5553

56-
```
57-
5854
### 2.5 Docstring(Google スタイル)
5955

6056
関数・クラスには必ず Docstring を付ける。
@@ -111,51 +107,7 @@ AI は必要であれば **禁止事項を回避するためにリファクタ
111107

112108
---
113109

114-
# 5. AI に依頼するときの標準プロンプト(Developer Prompt)
115-
116-
AI に実装依頼する際は、以下のフォーマットが推奨されます。
117-
118-
```
119-
120-
あなたは ExStruct のコア開発エンジニアです。
121-
mypy strict + Ruff check を完全に通過するコードのみ生成してください。
122-
123-
遵守事項:
124-
125-
- 型ヒント完全
126-
- 境界は BaseModel、内部は dataclass を返す
127-
- 1 関数 = 1 責務
128-
- import 順序厳守
129-
- Google スタイルの docstring
130-
- 外部ライブラリ(xlwings, pandas)は Any 扱い
131-
- 複雑度を抑えること
132-
- 必要に応じて補助関数を追加して良い
133-
134-
出力は Python コードのみ。
135-
136-
```
137-
138-
---
139-
140-
# 6. AI にエラー修正を依頼する際のルール
141-
142-
mypy / Ruff のエラーが出た場合、AI への指示は次のテンプレートを使用します:
143-
144-
```
145-
146-
以下は mypy / Ruff のエラーメッセージです。
147-
すべてのエラーが解消されるようにコードを修正してください。
148-
149-
<エラー全文>
150-
151-
```
152-
153-
AI は差分修正タスクが得意なため、
154-
この方式が最も効率的かつ正確です。
155-
156-
---
157-
158-
# 7. AI の責務外(人間が担当する領域)
110+
# 5. AI の責務外(人間が担当する領域)
159111

160112
AI は以下の領域は担当しません。人間が判断します。
161113

@@ -168,45 +120,17 @@ AI は以下の領域は担当しません。人間が判断します。
168120

169121
---
170122

171-
# 8. AI を開発パイプラインと組み合わせる例
172-
173-
推奨フロー:
174-
175-
1. 人間:仕様を記述
176-
2. AI:コード生成(テンプレート+ガイドラインに従う)
177-
3. 自動:`mypy strict` チェック
178-
4. 自動:`ruff check --fix`
179-
5. AI:エラー出たら修正
180-
6. 人間:レビューしてマージ
181-
182-
このサイクルにより **高速 & 高品質の開発が可能** になります。
183-
184-
---
185-
186-
# 9. 最終目標
187-
188-
AI エージェントが ExStruct のコードを書く場合でも:
189-
190-
- バグのない型安全なコード
191-
- 一貫したコーディングスタイル
192-
- 仕様の誤解を最小化した実装
193-
- 人間が安心してレビューできるコード
194-
195-
を常に提供できるようにする。
196-
197-
この AGENTS ガイドラインは
198-
**Codex / ChatGPT を“チームメンバー”として扱うための基盤** です。
199-
200-
---
201-
202-
# 10. 各種仕様の確認
203-
204-
AI エージェントは必要に応じて以下のドキュメントを参照して ExStruct の開発をする
123+
# 6. 遵守すべき作業手順
205124

206-
- 処理アーキテクチャ: `docs/architecture/pipeline.md`
207-
- プロジェクトアーキテクチャ: `docs/contributors/architecture.md`
208-
- コーディングガイドライン: `docs/agents/CODING_GUIDELINES.md`
209-
- データモデル: `docs/agents/DATA_MODEL.md`
210-
- タスク: `docs/agents/TASKS.md`
125+
AI はコード生成前に以下の手順を必ず踏んでください。
211126

212-
**以上。AI はこのガイドラインに従って ExStruct の開発に参加してください。**
127+
1. **要件の理解**:仕様書や設計資料を読み込み、要件を完全に理解する
128+
2. **設計の検討**:必要に応じて関数分割やモデル設計を検討する。
129+
3. **仕様の定義**: 要件に基づいて、関数の引数・戻り値の型を定義する。
130+
4. **タスクの割り当て**: 各タスクを明確に定義し、実装順序を決定する。
131+
5. **コード実装**: 上記の基準を守りながらコードを実装する。
132+
6. **コードレビュー**: 自動生成されたコードを自己レビューし、品質基準を満たしているか確認する。
133+
7. **テストコードの生成**: 必要に応じて、テストコードも生成する。
134+
8. **テストの実行**: 生成されたテストコードを実行し、期待通りの動作を確認する。
135+
9. **静的解析**: `uv run task precommit-run` を実行し、mypy / Ruff エラーがないことを確認する。
136+
10. **ドキュメントの更新**: 変更があれば、関連するドキュメントも更新する。

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ All notable changes to this project are documented in this file. This changelog
88

99
- _No unreleased changes yet._
1010

11+
## [0.4.4] - 2026-02-16
12+
13+
### Added
14+
15+
- Added an MVP of Excel editing for MCP via `exstruct_patch`, including atomic apply semantics and expanded operations: `set_range_values`, `fill_formula`, `set_value_if`, and `set_formula_if`.
16+
- Added direct A1-oriented MCP read tools for extracted JSON: `exstruct_read_range`, `exstruct_read_cells`, and `exstruct_read_formulas`.
17+
- Added patch safety/review options: `dry_run`, `return_inverse_ops`, `preflight_formula_check`, and `auto_formula`.
18+
19+
### Changed
20+
21+
- Improved `exstruct_patch` input compatibility: `ops` now accepts both object lists (recommended) and JSON object strings.
22+
- Enabled `alpha_col` support more broadly across extraction/read flows, and added `merged_ranges` output support for alpha-column mode.
23+
- Updated MCP documentation and chunking guidance, including clearer error messages and mode guidance.
24+
- Changed MCP default conflict policy to `overwrite` for output handling.
25+
1126
## [0.4.2] - 2026-01-23
1227

1328
### Changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ exstruct-mcp --root C:\data --log-file C:\logs\exstruct-mcp.log --on-conflict re
7373
Available tools:
7474

7575
- `exstruct_extract`
76+
- `exstruct_patch`
7677
- `exstruct_read_json_chunk`
7778
- `exstruct_validate_input`
7879

7980
Notes:
8081

82+
- In MCP, `exstruct_extract` defaults to `options.alpha_col=true` (column keys: `A`, `B`, ...). Set `options.alpha_col=false` for legacy 0-based numeric string keys.
8183
- Logs go to stderr (and optionally `--log-file`) to avoid contaminating stdio responses.
8284
- On Windows with Excel, standard/verbose can use COM for richer extraction. On non-Windows, COM is unavailable and extraction uses openpyxl-based fallbacks.
8385

docs/README.en.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ exstruct-mcp --root C:\data --log-file C:\logs\exstruct-mcp.log --on-conflict re
7373
Available tools:
7474

7575
- `exstruct_extract`
76+
- `exstruct_patch`
7677
- `exstruct_read_json_chunk`
7778
- `exstruct_validate_input`
7879

7980
Notes:
8081

82+
- In MCP, `exstruct_extract` defaults to `options.alpha_col=true` (column keys: `A`, `B`, ...). Set `options.alpha_col=false` for legacy 0-based numeric string keys.
8183
- Logs go to stderr (and optionally `--log-file`) to avoid contaminating stdio responses.
8284
- On Windows with Excel, standard/verbose can use COM for richer extraction. On non-Windows, COM is unavailable and extraction uses openpyxl-based fallbacks.
8385

docs/README.ja.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ exstruct-mcp --root C:\data --log-file C:\logs\exstruct-mcp.log --on-conflict re
7070
利用可能なツール:
7171

7272
- `exstruct_extract`
73+
- `exstruct_patch`
7374
- `exstruct_read_json_chunk`
75+
- `exstruct_read_range`
76+
- `exstruct_read_cells`
77+
- `exstruct_read_formulas`
7478
- `exstruct_validate_input`
7579

80+
- `exstruct_read_range` / `exstruct_read_cells` / `exstruct_read_formulas` は v0.4.4 で追加され、MCPサーバー実装とテストに登録済みです。
81+
- MCPでは `exstruct_extract``options.alpha_col=true` が既定です(列キーは `A`, `B`, ...)。従来の0始まり数値キーが必要な場合は `options.alpha_col=false` を指定してください。
82+
7683
注意点:
7784

7885
- 標準入出力の応答を汚染しないよう、ログは標準エラー出力(およびオプションで`--log-file`で指定したファイル)に出力されます。

docs/agents/API_DESIGN.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)