Spaces:
Sleeping
Sleeping
Download src/modules/skill/packs/code_review.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 3.09 kB
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/modules/skill/packs/code_review.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/src/modules/skill/packs/code_review.py
-
curl -L -o code_review.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/modules/skill/packs/code_review.py
3.09 kB
| """Version a built-in draft with one review; never edit published run snapshots.""" | |
| import copy | |
| from src.modules.skill.domain.models import Draft | |
| def with_code_review(body): | |
| result=copy.deepcopy(body) | |
| graph=result['graph'] | |
| if any((n.get('operation_ref') or '').startswith('AO13@') for n in graph['nodes']): | |
| for node in graph['nodes']: | |
| if (node.get('operation_ref') or '').startswith('AO13@'):node['operation_ref']='AO13@0.2.0' | |
| return Draft.model_validate(result) | |
| if not any(e=={'source':'code','target':'patch'} for e in graph['control_edges']): | |
| raise ValueError('BUILTIN_REVIEW_INSERTION_POINT_MISSING') | |
| graph['nodes'].insert(next(i for i,n in enumerate(graph['nodes']) if n['id']=='patch'), | |
| {'id':'code_review','kind':'operation','operation_ref':'AO13@0.2.0'}) | |
| graph['control_edges']=[e for e in graph['control_edges'] if e!={'source':'code','target':'patch'}] | |
| graph['control_edges'] += [{'source':'code','target':'code_review'},{'source':'code_review','target':'patch'}] | |
| for edge in graph['data_edges']: | |
| if edge['source']=='code' and edge['target']=='patch' and edge['target_port']=='patch': | |
| edge['source']='code_review' | |
| graph['data_edges'] += [dict(source='code',source_port='patch',target='code_review',target_port='patch'), | |
| dict(source='design',source_port='design',target='code_review',target_port='design')] | |
| return Draft.model_validate(result) | |
| def without_code_review(body): | |
| """Remove only the standard built-in review node, retaining all other graph data.""" | |
| result=copy.deepcopy(body) | |
| graph=result['graph'] | |
| nodes=[n for n in graph['nodes'] if (n.get('operation_ref') or '').startswith('AO13@')] | |
| if not nodes: | |
| return Draft.model_validate(result) | |
| if len(nodes)!=1 or nodes[0]['id']!='code_review': | |
| raise ValueError('BUILTIN_REVIEW_GRAPH_UNSUPPORTED') | |
| control=graph['control_edges']; data=graph['data_edges'] | |
| expected_control=[{'source':'code','target':'code_review'},{'source':'code_review','target':'patch'}] | |
| expected_data=[dict(source='code',source_port='patch',target='code_review',target_port='patch'), | |
| dict(source='design',source_port='design',target='code_review',target_port='design')] | |
| outgoing=dict(source='code_review',source_port='patch',target='patch',target_port='patch') | |
| if ([e for e in control if 'code_review' in (e['source'],e['target'])] != expected_control | |
| or any(e not in data for e in expected_data+[outgoing]) | |
| or len([e for e in data if 'code_review' in (e['source'],e['target'])])!=3): | |
| raise ValueError('BUILTIN_REVIEW_GRAPH_UNSUPPORTED') | |
| graph['nodes'].remove(nodes[0]) | |
| graph['control_edges']=[e for e in control if e not in expected_control]+[{'source':'code','target':'patch'}] | |
| graph['data_edges']=[e for e in data if e not in expected_data+[outgoing]] | |
| graph['data_edges'].append(dict(source='code',source_port='patch',target='patch',target_port='patch')) | |
| return Draft.model_validate(result) | |