This website requires JavaScript.
0
Issues
Pull Requests
Milestones
Explore
0
Create…
New Repository
New Migration
New Organization
public
Signed in as
public
Profile
Starred
Subscriptions
Settings
Help
Sign Out
yws
/
lc-mcp
Watch
1
Star
0
Fork
0
Code
Issues
Pull Requests
Actions
Packages
Projects
Releases
Wiki
Activity
Files
lc-mcp
/
lc_mcp
/
or
Cancel
Edit File
Preview
Preview Changes
Spaces
Tabs
2
4
8
Wrap
No wrap
# -*- coding: utf-8 -*- """决策审计日志(BACKLOG P2-8)。 任务子进程把选队/寻路/卡包/饰品/事件/商店的每个决策追加成一行 JSON, 写到 TaskRunner 给的路径 (和任务日志同名, 后缀 .decisions.jsonl)。每行至少有 time / stage / choice / reason: reason 是用来计数的短类别(例如 gift 的 keyword / no_keyword), 细节放在其余字段。 写失败只丢这一行, 不影响任务。 """ import json import os import threading import time from collections import Counter DECISIONS_ENV = 'LCP_DECISIONS' SUFFIX = '.decisions.jsonl' class DecisionLog: def __init__(self, path=None): self.path = path self._lock = threading.Lock() def open(self, env=None): """按环境变量决定写到哪; 没设置时 record 什么也不做。""" env = os.environ if env is None else env self.path = env.get(DECISIONS_ENV) or None return self.path def record(self, stage, choice, reason, **detail): if not self.path: return entry = {'time': time.strftime('%Y-%m-%dT%H:%M:%S'), 'stage': stage, 'choice': choice, 'reason': reason} entry.update(detail) line = json.dumps(entry, ensure_ascii=False, default=str) + '\n' try: with self._lock, open(self.path, 'a', encoding='utf-8') as f: f.write(line) except OSError: pass decisions = DecisionLog() def summarize(path): """{stage: {reason: 次数}}; 文件不存在返回 None, 坏行跳过。""" try: with open(path, encoding='utf-8') as f: lines = f.readlines() except OSError: return None counts = {} for line in lines: try: entry = json.loads(line) stage, reason = str(entry['stage']), str(entry['reason']) except (ValueError, KeyError, TypeError): continue counts.setdefault(stage, Counter())[reason] += 1 return {stage: dict(counter) for stage, counter in sorted(counts.items())}
Commit Changes
Add a Signed-off-by trailer by the committer at the end of the commit log message.
Commit directly to the
codex/feedback-unattended-setup-20261004
branch.
Create a
new branch
for this commit and start a pull request.
Commit Changes
Cancel