VibeCoding / src /apps /workbench /development.py
dellweb3's picture
sol6.1 ERP稳定版本
115b94d verified
Raw History Blame Contribute Delete
5.85 kB
"""User-visible factual execution events and frozen demonstration requirements."""
from pathlib import Path
from datetime import datetime, timezone
ROOT=Path(__file__).resolve().parents[3]
TITLES={'start':'接收开发需求','requirements':'整理需求与验收目标','knowledge':'检索相关知识','context':'冻结权限与上下文',
'design':'模型生成技术设计','design_confirm':'设计检查','execution_confirm':'执行授权检查','code':'模型编写Java源码',
'patch':'形成候选文件','policy':'Harness源码约束检查','build':'隔离沙箱编译与独立测试','test':'核验独立系统测试回执',
'preview':'核验Java服务运行回执','acceptance':'技术交付,等待用户验收','evidence':'保存制品证据','end':'完成交付',
'review':'独立续作与修复来源','repair':'模型依据失败诊断修复','execution':'执行状态',
'routing':'按任务选择模型','model_recovery':'恢复已知输出问题'}
TITLES['recovery']='自动恢复任务'
TITLES['diagnosis']='定位失败代码与最小复现'
TITLES['code_review']='检视需求、接口和代码'
def progress(run, state, events, now):
"""Project only recorded facts and elapsed time; no estimated completion percentage."""
live = state in {'queued', 'working'}
records = [e for e in events if e['status'] != 'active']
starts = [e for e in records if e['status'] == 'started']
latest = records[-1] if records else None
stage = starts[-1]['stage'] if starts else None
stage_start = starts[-1]['timestamp'] if starts else run['created_at']
# A routing receipt is nested within the code/design step, not a completed task.
title = ('模型生成网页源码' if stage=='code' and run['project_id']=='webapp-demo' else TITLES.get(stage, stage or '等待调度'))
ended = events[-1]['timestamp'] if events else run['created_at']
end = now if live else ended
labels = {'verified': '开发完成 · 技术通过', 'failed': '本次开发失败',
'unknown': '本次结果尚未确认', 'cancelled': '任务已取消','waiting_approval':'等待下一步确认'}
headline = ('任务排队中' if state == 'queued' else '正在'+title) if live else labels.get(state, state)
detail = {'build': '隔离虚拟机正在完成启动、Java编译和独立HTTP测试;收到回执后才显示通过。',
'code': '模型正在生成完整Java候选,返回后检查源码并进入沙箱验证。',
'design': '模型正在整理技术方案,返回后展示实施方案。',
'code_review': '模型正在核对需求覆盖、前后端契约和代码问题;检视建议及修改仍须通过隔离编译与实际测试。',
'repair': '模型正在依据实际失败诊断修复,随后重新编译和测试。'}.get(stage, '执行状态和结果以服务端记录为准。')
if stage=='code' and run['project_id']=='webapp-demo':detail='模型正在根据本次需求生成完整交互页面,返回后检查源码并进入沙箱验证。'
if state == 'queued': detail = '等待本机执行器和可用沙箱,不需要重复发送。'
if state == 'verified': detail = '独立测试和运行验证均已通过。代码、文档、制品和网站预览已可查看;等待人工验收。'
if state == 'failed': detail = '本轮未达到验收条件,错误和诊断已保存。'
if state == 'unknown': detail = '尚无可信完成结果,费用预留与现场记录保留,不自动重放模型请求。'
if state == 'cancelled': detail = '任务已停止,历史调用与已生成的文件仍保留。'
if state == 'waiting_approval':detail='当前阶段结果已保存,等待下一步执行授权;尚未开始后续编译或测试。'
if state == 'waiting_budget':
headline='等待预算批准'
detail='任务已暂停,预算申请区分阶段上限和任务总额;确认前不调用,未知结果不能重放。'
if state=='waiting_limit':
headline='已安全暂停'
detail='本轮资源、修复或环境边界已触发;后台不再启动新工作。原需求、源码、诊断和账本保留,请在对话最下方查看原因与可批准的本次调整。环境错误不能靠加模型预算解决。'
heartbeats = [e for e in events if e['status'] == 'active']
from src.modules.orchestrator.feedback import CHECKPOINT_SECONDS, short_message
elapsed = max(0, end-stage_start)
return {'headline': headline, 'detail': detail, 'stage': stage, 'active': live,
'short_message': short_message('queued' if state=='queued' else stage) if live and end-run['created_at']>=CHECKPOINT_SECONDS else '',
'checkpoint_after_seconds': CHECKPOINT_SECONDS,
'server_time': now, 'elapsed_seconds': max(0, end-run['created_at']),
'stage_elapsed_seconds': max(0, end-stage_start),
'last_event_at': events[-1]['timestamp'] if events else run['created_at'],
'last_heartbeat_at': heartbeats[-1]['timestamp'] if heartbeats else None,
'event_count': len(events), 'latest_record': latest['detail'] if latest else ''}
def brief(scenario, fallback=''):
path=ROOT/'docs/demo-briefs'/f'{scenario}.md'
return path.read_text(encoding='utf-8') if path.is_file() else fallback
def timeline(store,run,events=None):
if events is None: events=store.stages(run['id'])
return [{'id':e['id'],'at':datetime.fromtimestamp(e['timestamp'],timezone.utc).isoformat(),
'stage':e['stage'],'status':e['status'],
'title':'模型生成网页源码' if e['stage']=='code' and run['project_id']=='webapp-demo' else TITLES.get(e['stage'],e['stage']),
'detail':e['detail']} for e in events]