#!/usr/bin/env python3 import json from datetime import date from pathlib import Path ROOT = Path(__file__).resolve().parents[1] BACKLOG = ROOT / 'backlog' / 'features.json' def ask(prompt, default=''): value = input(f"{prompt}{' [' + default + ']' if default else ''}: ").strip() return value if value else default def next_id(features): nums = [] for f in features: fid = str(f.get('id', '')) if fid.startswith('F-') and fid[2:].isdigit(): nums.append(int(fid[2:])) return f"F-{(max(nums) + 1) if nums else 1:03d}" def main(): data = json.loads(BACKLOG.read_text(encoding='utf-8')) features = data.get('features', []) print('Create ticket (English caveman style).') ttype = ask('Type (feature/fix/bug/chore)', 'feature') title = ask('Title (short EN)', f'{ttype.capitalize()} TODO') problem = ask('Problem (short EN)', 'Need change') goal = ask('Goal (short EN)', 'Make flow better') scope_in = ask('Scope IN (comma list EN)', 'Core flow') scope_out = ask('Scope OUT (comma list EN)', 'No redesign') risk = ask('Risk (low/med/high)', 'low') priority = ask('Priority (low/med/high)', 'med') print('Acceptance bullets (EN caveman). Empty line to end.') acceptance = [] while True: line = input('- ').strip() if not line: break acceptance.append(line) if not acceptance: acceptance = [ 'Flow works end to end', 'No break old behavior', 'verify.sh is green' ] fid = next_id(features) desc = ( f"Problem: {problem}. " f"Goal: {goal}. " f"Scope IN: {scope_in}. " f"Scope OUT: {scope_out}. " f"Type: {ttype}. Priority: {priority}. Risk: {risk}." ) features.append({ 'id': fid, 'title': title, 'description': desc, 'acceptance': acceptance, 'status': 'pending', 'created_at': str(date.today()), 'gates': {'review': False, 'security': False, 'qa': False} }) data['features'] = features BACKLOG.write_text(json.dumps(data, indent=2, ensure_ascii=False) + '\n', encoding='utf-8') print(f'Created {fid}: {title}') if __name__ == '__main__': main()