initial real project snapshot
This commit is contained in:
commit
b49b9cf1e7
18 files changed
+53739
No files matched your search
@@ -0,0 +1 @@
|
||||
[{"name":"host-c","repo":"work/host-repo","task":"在 sample.py 里加一个函数 div2(a, b),返回 a/b,不要改其他函数,不要做其他改动。"},{"name":"host-d","repo":"work/host-repo","task":"在 sample.py 里加一个函数 pow2(a, b),返回 a**b,不要改其他函数,不要做其他改动。"},{"name":"host-e","repo":"work/host-repo","task":"在 sample.py 里加一个函数 mod2(a, b),返回 a%b,不要改其他函数,不要做其他改动。"}]
|
||||
@@ -0,0 +1 @@
|
||||
[{"name":"host-a","repo":"work/host-repo","task":"在 sample.py 里加一个函数 add2(a, b),返回 a+b,不要改 hello,不要做其他改动。"},{"name":"host-b","repo":"work/host-repo","task":"在 sample.py 里加一个函数 mul2(a, b),返回 a*b,不要改 hello,不要做其他改动。"}]
|
||||
@@ -0,0 +1 @@
|
||||
[{"cwd":"work/job-a","prompt":"只读审查 work/job-a 里的代码,列出最严重的 3 个问题,不要改任何文件。","sandbox":"read-only"},{"cwd":"work/job-b","prompt":"只读审查 work/job-b 里的代码,列出最严重的 3 个问题,不要改任何文件。","sandbox":"read-only"}]
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""最小 MCP stdio 服务器(宿主提供工具的对齐试验用)。
|
||||
|
||||
只给两个工具,不依赖任何第三方包:
|
||||
echo_fact:返回固定事实字符串 mcp-fact-42
|
||||
add:返回 a + b
|
||||
|
||||
协议:JSON-RPC over stdio,MCP initialize / tools/list / tools/call,
|
||||
以及 notifications/initialized、ping。codex 的 MCP 客户端就是按
|
||||
这个协议调它的,宿主只要在 config.toml 里写:
|
||||
|
||||
[mcp_servers.echo]
|
||||
command = "python3"
|
||||
args = ["<本文件绝对路径>"]
|
||||
startup_timeout_sec = 30
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def send(obj):
|
||||
sys.stdout.write(json.dumps(obj) + "\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def main():
|
||||
for line in sys.stdin:
|
||||
if not line.strip():
|
||||
continue
|
||||
try:
|
||||
req = json.loads(line)
|
||||
except Exception:
|
||||
continue
|
||||
method = req.get("method")
|
||||
rid = req.get("id")
|
||||
# 通知:没有 id,不回
|
||||
if method in ("notifications/initialized", "notifications/cancelled"):
|
||||
continue
|
||||
if method == "initialize":
|
||||
send({"jsonrpc": "2.0", "id": rid, "result": {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"capabilities": {"tools": {}},
|
||||
"serverInfo": {"name": "echo", "version": "0.1"}}})
|
||||
elif method == "tools/list":
|
||||
send({"jsonrpc": "2.0", "id": rid, "result": {"tools": [
|
||||
{"name": "echo_fact",
|
||||
"description": "返回一个固定事实字符串,用于验证宿主提供的 MCP 工具是否被 agent 调用",
|
||||
"inputSchema": {"type": "object", "properties": {}}},
|
||||
{"name": "add",
|
||||
"description": "返回 a + b",
|
||||
"inputSchema": {"type": "object",
|
||||
"properties": {"a": {"type": "number"},
|
||||
"b": {"type": "number"}},
|
||||
"required": ["a", "b"]}}]}})
|
||||
elif method == "tools/call":
|
||||
params = req.get("params") or {}
|
||||
name = params.get("name")
|
||||
args = params.get("arguments") or {}
|
||||
if name == "echo_fact":
|
||||
text = "mcp-fact-42"
|
||||
elif name == "add":
|
||||
text = str(args.get("a", 0) + args.get("b", 0))
|
||||
else:
|
||||
text = f"unknown tool: {name}"
|
||||
send({"jsonrpc": "2.0", "id": rid, "result": {
|
||||
"content": [{"type": "text", "text": text}]}})
|
||||
elif method == "ping":
|
||||
send({"jsonrpc": "2.0", "id": rid, "result": {}})
|
||||
elif rid is not None:
|
||||
send({"jsonrpc": "2.0", "id": rid, "result": {}})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1 @@
|
||||
[{"name":"prod-pow","repo":"work/prod-repo","task":"在 features/ 新建 pow_feature.py,实现 pow_calc(a, b) 返回 a**b;在 tests/ 新建 test_pow.py,用 unittest 覆盖正常值和 0 次幂;跑 python3 -m unittest discover -s tests -v,全部通过才算完成。不要改 core.py、tests/test_core.py 和其他功能文件。"},{"name":"prod-mod","repo":"work/prod-repo","task":"在 features/ 新建 mod_feature.py,实现 mod_calc(a, b) 返回 a%b,b 为 0 时抛出 ValueError;在 tests/ 新建 test_mod.py,用 unittest 覆盖正常值和 b=0 抛错;跑 python3 -m unittest discover -s tests -v,全部通过才算完成。不要改 core.py、tests/test_core.py 和其他功能文件。"}]
|
||||
@@ -0,0 +1,9 @@
|
||||
用 3 个子代理并行做代码评审,最后由你汇总成一份结论,不要直接改代码:
|
||||
|
||||
1. 安全子代理:只看鉴权、注入、敏感信息泄露。
|
||||
2. 质量子代理:只看可读性、重复代码、边界条件。
|
||||
3. 测试子代理:只看现有测试是否覆盖了本次改动,缺什么用例。
|
||||
|
||||
要求:每个子代理的结果先分开列出,再给一份合并结论;
|
||||
只列有证据的项(文件名+行号/函数名),猜测的标明是猜测;
|
||||
汇总时去掉重复项,按严重程度排序。
|
||||
Reference in new issue
Block a user