ht32-code-mcp 0.4.2__tar.gz → 0.4.3__tar.gz
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.
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/PKG-INFO +1 -1
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/pyproject.toml +1 -1
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/server.py +8 -2
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/usage.py +5 -2
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/tests/test_tools.py +15 -1
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/uv.lock +1 -1
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/.gitignore +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/.gitkeep +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/.pytest_base_final_run.log +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/DEPLOY.md +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/README.md +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/e2e_scenario_a.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/e2e_scenario_b.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/smoke_http.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/smoke_stdio.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/__init__.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/__main__.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/exporter.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/index.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/knowledge.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/materializer.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/src/ht32_code_mcp/release.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/tests/conftest.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/tests/test_export_cloud_mode.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/tests/test_knowledge_grounding.py +0 -0
- {ht32_code_mcp-0.4.2 → ht32_code_mcp-0.4.3}/tests/test_recipe_claims.py +0 -0
|
@@ -98,7 +98,8 @@ M0+(HT32F5 / L5)、M3(HT32F1 / F175x-275x)、M4(F490x1 / F491x3 / F493
|
|
|
98
98
|
- 知识库缺了用户需要的内容,你只能用推测回答
|
|
99
99
|
- 导出工程有缺陷(编译失败、型号参数错、缺文件)
|
|
100
100
|
- **ht32-skills(编排层:流程/脚本/模板/环境检测)本身有缺陷**,用 issue_type=skill_defect
|
|
101
|
-
上报(本渠道是 skill
|
|
101
|
+
上报(本渠道是 skill 问题的统一入口),`skill_version` 传本机 `ht32.py version` 的版本号,
|
|
102
|
+
details 里附现象与日志路径
|
|
102
103
|
务必附 model_id;submit_feedback 之外的调用已由服务端自动记入用量日志,无需你重复上报。
|
|
103
104
|
"""
|
|
104
105
|
|
|
@@ -561,6 +562,7 @@ def submit_feedback(
|
|
|
561
562
|
details: str = "",
|
|
562
563
|
model_id: str = "",
|
|
563
564
|
tools_called: list[str] | None = None,
|
|
565
|
+
skill_version: str = "",
|
|
564
566
|
) -> str:
|
|
565
567
|
"""提交纠正反馈,改进 HT32 代码知识库 / ht32-skills 编排层。
|
|
566
568
|
|
|
@@ -576,9 +578,12 @@ def submit_feedback(
|
|
|
576
578
|
issue_type: 问题类型,枚举上述其一(skill_defect = ht32-skills 编排层缺陷)
|
|
577
579
|
answer: 你给出的回答原文
|
|
578
580
|
correction: 你认为正确的信息或用户指出的正确内容
|
|
579
|
-
details:
|
|
581
|
+
details: 补充上下文(如编译报错原文、复现步骤、日志路径)
|
|
580
582
|
model_id: 你的模型标识,如 deepseek-v4-flash
|
|
581
583
|
tools_called: 本次调过的查询工具列表(不含 submit_feedback 自身)
|
|
584
|
+
skill_version: 本机 ht32-skills 版本,取 `ht32.py version` 的 skill_version
|
|
585
|
+
(如 "v0.1.19")。服务端跨进程拿不到客户端 skill 版本,**skill_defect 必填**,
|
|
586
|
+
否则无从判断缺陷属于哪个版本
|
|
582
587
|
"""
|
|
583
588
|
if not question or not question.strip():
|
|
584
589
|
return "错误:question 参数不能为空,请提供用户原始需求。"
|
|
@@ -595,6 +600,7 @@ def submit_feedback(
|
|
|
595
600
|
tools_called=tools_called,
|
|
596
601
|
mcp_version=_MCP_VERSION,
|
|
597
602
|
kb_version=index.data.get("code_version", ""),
|
|
603
|
+
skill_version=skill_version,
|
|
598
604
|
)
|
|
599
605
|
if path is None:
|
|
600
606
|
return ("错误:反馈未能写入。服务端可能未配置 FEEDBACK_ROOT,"
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
- **tool_call**(`UsageMiddleware`,服务端自动):拦截所有工具调用,
|
|
10
10
|
记录工具名、参数原文、耗时、成败。不依赖 Agent 配合,数据完整。
|
|
11
11
|
- **feedback**(`record_feedback`,由各 server 的 `submit_feedback` 工具调用):
|
|
12
|
-
记录 Agent 主动上报的语义性问题,middleware
|
|
12
|
+
记录 Agent 主动上报的语义性问题,middleware 无法判断这些。其中 `skill_version`
|
|
13
|
+
由 Agent 自报(服务端跨进程拿不到客户端 skill 版本),用于定位 ht32-skills 缺陷版本。
|
|
13
14
|
|
|
14
15
|
目录布局(同根 + 服务子目录):
|
|
15
16
|
|
|
@@ -38,7 +39,7 @@ from typing import Any
|
|
|
38
39
|
from fastmcp.server.middleware import Middleware, MiddlewareContext
|
|
39
40
|
|
|
40
41
|
# 实现版本号:两仓库副本必须一致(各仓测试会校验,防止只改一边造成漂移)
|
|
41
|
-
_IMPL_VERSION = "1.
|
|
42
|
+
_IMPL_VERSION = "1.2.0"
|
|
42
43
|
|
|
43
44
|
# 服务名 → 子目录名。新增服务在此登记。
|
|
44
45
|
SERVICE_WIKI = "wiki"
|
|
@@ -203,6 +204,7 @@ def record_feedback(
|
|
|
203
204
|
tools_called: list[str] | None = None,
|
|
204
205
|
mcp_version: str = "",
|
|
205
206
|
kb_version: str = "",
|
|
207
|
+
skill_version: str = "",
|
|
206
208
|
) -> Path | None:
|
|
207
209
|
"""记录一条 Agent 主动提交的反馈。"""
|
|
208
210
|
record = {
|
|
@@ -219,5 +221,6 @@ def record_feedback(
|
|
|
219
221
|
"tools_called": [t for t in (tools_called or []) if t and t != "submit_feedback"],
|
|
220
222
|
"mcp_version": mcp_version,
|
|
221
223
|
"kb_version": kb_version,
|
|
224
|
+
"skill_version": skill_version.strip(),
|
|
222
225
|
}
|
|
223
226
|
return write_record(log_dir, FEEDBACK_PREFIX, record)
|
|
@@ -677,7 +677,7 @@ def test_version_reports_skill_latest(monkeypatch):
|
|
|
677
677
|
def test_usage_impl_version_pinned():
|
|
678
678
|
"""两仓库的 usage.py 是逐字节相同副本,实现版本号用于防止只改一边。"""
|
|
679
679
|
from ht32_code_mcp import usage
|
|
680
|
-
assert usage._IMPL_VERSION == "1.
|
|
680
|
+
assert usage._IMPL_VERSION == "1.2.0"
|
|
681
681
|
assert usage.SERVICE_CODE == "code"
|
|
682
682
|
assert usage.SERVICE_WIKI == "wiki"
|
|
683
683
|
# 噪声参数含 out_dir(code 特有:可能含用户本地路径)
|
|
@@ -735,6 +735,7 @@ def test_submit_feedback_writes_jsonl(tmp_path, monkeypatch):
|
|
|
735
735
|
details="编译报错 too few arguments",
|
|
736
736
|
model_id="deepseek-v4-flash",
|
|
737
737
|
tools_called=["search_code_knowledge", "submit_feedback", "get_file"],
|
|
738
|
+
skill_version="v0.1.19",
|
|
738
739
|
)
|
|
739
740
|
assert "反馈已记录" in out
|
|
740
741
|
f = next((tmp_path / "logs").glob("feedback_*.jsonl"))
|
|
@@ -747,6 +748,8 @@ def test_submit_feedback_writes_jsonl(tmp_path, monkeypatch):
|
|
|
747
748
|
# submit_feedback 自身被过滤,只留查询类工具
|
|
748
749
|
assert rec["tools_called"] == ["search_code_knowledge", "get_file"]
|
|
749
750
|
assert rec["mcp_version"] and rec["kb_version"]
|
|
751
|
+
# 客户端 skill 版本是结构化字段(不再靠 details 散文),未传时为空串而非缺键
|
|
752
|
+
assert rec["skill_version"] == "v0.1.19"
|
|
750
753
|
|
|
751
754
|
|
|
752
755
|
def test_submit_feedback_accepts_skill_defect(tmp_path, monkeypatch):
|
|
@@ -757,11 +760,22 @@ def test_submit_feedback_accepts_skill_defect(tmp_path, monkeypatch):
|
|
|
757
760
|
issue_type="skill_defect",
|
|
758
761
|
details="ht32-skills v0.1.0;导出后 uvprojx 未按工程名重命名",
|
|
759
762
|
model_id="deepseek-v4-flash",
|
|
763
|
+
skill_version="v0.1.0",
|
|
760
764
|
)
|
|
761
765
|
assert "skill_defect" in out
|
|
762
766
|
f = next((tmp_path / "logs").glob("feedback_*.jsonl"))
|
|
763
767
|
rec = json.loads(f.read_text(encoding="utf-8").splitlines()[0])
|
|
764
768
|
assert rec["issue_type"] == "skill_defect"
|
|
769
|
+
assert rec["skill_version"] == "v0.1.0"
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
def test_feedback_skill_version_key_always_present(tmp_path, monkeypatch):
|
|
773
|
+
"""没传 skill_version 时字段仍存在(空串),日志消费方不必分支判键。"""
|
|
774
|
+
monkeypatch.setattr(srv, "LOG_DIR", str(tmp_path / "logs"))
|
|
775
|
+
srv.submit_feedback(question="x", issue_type="other")
|
|
776
|
+
f = next((tmp_path / "logs").glob("feedback_*.jsonl"))
|
|
777
|
+
rec = json.loads(f.read_text(encoding="utf-8").splitlines()[0])
|
|
778
|
+
assert rec["skill_version"] == ""
|
|
765
779
|
|
|
766
780
|
|
|
767
781
|
def test_submit_feedback_empty_question(tmp_path, monkeypatch):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|