#!/usr/bin/env node
import*as i from'fs';import*as c from'path';import*as a from'js-yaml';var v={architect:{tier:"high",description:"Complex planning needs best reasoning"},security:{tier:"high",description:"Deep security analysis"},reviewer:{tier:"medium",description:"Balanced critique"},builder:{tier:"low",description:"Fast implementation, lower cost"},tester:{tier:"low",description:"Quick validation"}},p={architect:{role:`You design system architecture, write specifications, and plan features.
You do NOT write implementation code - that's the Builder's job.
When your spec is ready, hand off to Builder with 'paradigm team handoff --to builder'.`,focus:{reads:["@features","$flows","specs/*.md","health.yaml"],writes:["specs/*.md",".purpose"]},triggers:[{type:"keyword",match:["design","architect","plan","spec"]},{type:"symbol",match:["@*","$*"]}],handoff_to:["builder","reviewer"],defaultModel:"opus",context:{include:["specs/*.md",".purpose","**/.purpose","portal.yaml"],exclude:["src/**","tests/**","node_modules/**"]}},builder:{role:`You implement code based on specifications from the Architect.
Follow the spec exactly. If spec is unclear, hand back to Architect.
When implementation is ready, hand off to Reviewer with 'paradigm team handoff --to reviewer'.`,focus:{reads:["#components","specs/*.md","src/**","tests/**"],writes:["src/**","tests/**"]},triggers:[{type:"keyword",match:["implement","build","code","fix"]},{type:"handoff",from:"architect"}],handoff_to:["reviewer","architect"],defaultModel:"haiku",context:{include:["src/**","tests/**","{feature}.purpose"],exclude:["specs/*.md","node_modules/**"]}},reviewer:{role:`You review code for correctness, security, and adherence to specs.
Check all ^gate requirements are met.
Approve or request changes. Do NOT implement fixes yourself.
Hand back to Builder for fixes, or to Tester when approved.`,focus:{reads:["^gates","!signals","portal.yaml","src/**","specs/*.md"],writes:["reviews/*.md"]},triggers:[{type:"keyword",match:["review","check","audit","approve"]},{type:"handoff",from:"builder"}],handoff_to:["builder","tester"],defaultModel:"sonnet",context:{include:["src/**","specs/*.md","portal.yaml",".purpose"],exclude:["tests/**","node_modules/**"]}},tester:{role:`You verify implementations work correctly.
Run tests, check portal validations, verify health status.
Report issues back to Builder. Update health.yaml when verified.`,focus:{reads:["tests/**","portal.yaml","health.yaml","#components"],writes:["tests/**","health.yaml"]},triggers:[{type:"keyword",match:["test","verify","qa","validate"]},{type:"handoff",from:"reviewer"}],handoff_to:["builder","architect"],defaultModel:"haiku",context:{include:["tests/**","health.yaml","{feature}.purpose"],exclude:["src/**","specs/**","node_modules/**"]}},security:{role:`You audit for security issues, especially around ^gates.
Review auth flows, check for vulnerabilities.
Flag issues but do NOT implement fixes - hand to Builder for that.`,focus:{reads:["^gates","!signals","portal.yaml","src/**"],writes:["security/*.md"]},triggers:[{type:"keyword",match:["security","audit","vulnerability","auth"]}],handoff_to:["builder","architect"],defaultModel:"opus",context:{include:["portal.yaml","src/middleware/**","src/auth/**"],exclude:["src/routes/**","tests/**","node_modules/**"]}}};function l(e){return c.join(e,".paradigm")}function d(e){return c.join(l(e),"agents.yaml")}function h(e){return c.join(l(e),"team-state.yaml")}function f(e){return c.join(l(e),"handoffs")}function _(e){return i.existsSync(d(e))}function D(e){let t=d(e);if(!i.existsSync(t))return null;try{let n=i.readFileSync(t,"utf8");return a.load(n)}catch{return null}}function F(e,t){let n=d(e),r=l(e);i.existsSync(r)||i.mkdirSync(r,{recursive:true});let o=a.dump(t,{lineWidth:-1,noRefs:true,quotingType:'"'});i.writeFileSync(n,o);}function u(e){let t=h(e);if(!i.existsSync(t))return {current:null,queue:[],recent:[],blocked:[]};try{let n=i.readFileSync(t,"utf8");return a.load(n)}catch{return {current:null,queue:[],recent:[],blocked:[]}}}function g(e,t){let n=h(e),r=l(e);i.existsSync(r)||i.mkdirSync(r,{recursive:true});let o=a.dump(t,{lineWidth:-1,noRefs:true,quotingType:'"'});i.writeFileSync(n,o);}function y(e,t){let n=c.join(f(e),`${t}.yaml`);if(!i.existsSync(n))return null;try{let r=i.readFileSync(n,"utf8");return a.load(r)}catch{return null}}function H(e,t){let n=f(e);i.existsSync(n)||i.mkdirSync(n,{recursive:true});let r=c.join(n,`${t.id}.yaml`),o=a.dump(t,{lineWidth:-1,noRefs:true,quotingType:'"'});i.writeFileSync(r,o);}function x(e){let t=f(e);if(!i.existsSync(t))return [];let n=i.readdirSync(t).filter(o=>o.endsWith(".yaml")),r=[];for(let o of n){let s=o.replace(".yaml",""),m=y(e,s);m&&r.push(m);}return r.sort((o,s)=>new Date(s.timestamp).getTime()-new Date(o.timestamp).getTime())}function R(e){return x(e).filter(t=>t.status==="pending")}function C(e="project",t){let n={};for(let[r,o]of Object.entries(p))if(n[r]={name:r,...o},t&&t[r]){let s=t[r].id.toLowerCase();s.includes("opus")||s.includes("gpt-4")&&!s.includes("mini")||s.includes("o1")&&!s.includes("mini")||s.includes("pro")&&!s.includes("mini")||s.includes("large")?n[r].defaultModel="opus":s.includes("haiku")||s.includes("mini")||s.includes("flash")||s.includes("small")?n[r].defaultModel="haiku":n[r].defaultModel="sonnet";}return {version:"1.0.0",team:{name:`${e}-team`,default_agent:"architect",require_handoff:false},agents:n}}function q(e,t){let n=u(e);n.recent.unshift({...t,timestamp:new Date().toISOString()}),n.recent=n.recent.slice(0,20),g(e,n);}function I(e,t,n){let r=u(e);r.current={agent:t,task:n,started:new Date().toISOString(),symbols_touched:[]},g(e,r);}function P(e){let t=u(e);t.current=null,g(e,t);}export{v as a,l as b,d as c,_ as d,D as e,F as f,u as g,g as h,H as i,x as j,R as k,C as l,q as m,I as n,P as o};