@a-company/paradigm 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accept-orchestration-WMGFGYDK.js → accept-orchestration-XW44LF5Y.js} +1 -1
- package/dist/add-CBDU23S2.js +12 -0
- package/dist/{aggregate-KZICPVT3.js → aggregate-H7SB2UYT.js} +1 -1
- package/dist/{ambient-HAXPDIWK.js → ambient-TFLZFV5Y.js} +1 -1
- package/dist/ambient-VCTUHHIG.js +2 -0
- package/dist/arch-loader-YVOS3QRY.js +2 -0
- package/dist/{beacon-52EWNZPK.js → beacon-WVN264OT.js} +1 -1
- package/dist/captain-CAXGHC2V.js +2 -0
- package/dist/captain-CWCLFOXV.js +2 -0
- package/dist/{chunk-QDP4G53M.js → chunk-27EK3OQZ.js} +4 -4
- package/dist/chunk-2KK4JQ55.js +17 -0
- package/dist/chunk-3I3TITBA.js +25 -0
- package/dist/chunk-3YM5ABNX.js +2 -0
- package/dist/{chunk-RDWWSQGH.js → chunk-6HYRS3PH.js} +14 -14
- package/dist/{chunk-S3UVQ5RV.js → chunk-6VZSOQ7Y.js} +1 -1
- package/dist/chunk-727PXENG.js +2 -0
- package/dist/chunk-A5EEY6NO.js +3 -0
- package/dist/{chunk-DLMDHS2X.js → chunk-ASBK55FU.js} +1 -1
- package/dist/{chunk-4GC35IFF.js → chunk-D6BSCELB.js} +1 -1
- package/dist/{chunk-G6DK3ND3.js → chunk-DH7QVZDI.js} +9 -0
- package/dist/chunk-FG3M6VVO.js +30 -0
- package/dist/chunk-FNYYQNJY.js +2 -0
- package/dist/chunk-K6TLYNRQ.js +7 -0
- package/dist/chunk-K7KT6FL3.js +25 -0
- package/dist/chunk-M7JHVVDW.js +6 -0
- package/dist/chunk-NFN5UUJB.js +2 -0
- package/dist/{chunk-EG22HDXI.js → chunk-NRP2KJ6I.js} +12 -12
- package/dist/{chunk-VPNJL4LS.js → chunk-QPQBXRXX.js} +1 -1
- package/dist/chunk-RZRFYGND.js +504 -0
- package/dist/chunk-UNSI6DVD.js +93 -0
- package/dist/{chunk-W4BW7GXA.js → chunk-USYV5QYU.js} +1 -1
- package/dist/chunk-VOPJ47QY.js +2 -0
- package/dist/{chunk-KP5VOYAH.js → chunk-W3VWORQZ.js} +1 -1
- package/dist/chunk-WMTES556.js +2 -0
- package/dist/chunk-XBK244QR.js +6 -0
- package/dist/{chunk-YQK3XU63.js → chunk-XSKIXXFW.js} +12 -12
- package/dist/{chunk-MBSY57RN.js → chunk-Y76OIMDO.js} +1 -1
- package/dist/chunk-YYRP7FLC.js +2 -0
- package/dist/{compliance-4P3EE5OA.js → compliance-3M6COUCO.js} +3 -3
- package/dist/{constellation-RHZAEFV7.js → constellation-TIKNCZWR.js} +1 -1
- package/dist/{cost-24UZSS2P.js → cost-VTHZQKO4.js} +2 -2
- package/dist/{diff-VBVIUNL5.js → diff-Z2YSIRC4.js} +1 -1
- package/dist/{dist-TNE4GFT7.js → dist-PW5YPGFF.js} +1 -1
- package/dist/{docs-NTP6UENF.js → docs-OWJ7EPD7.js} +1 -1
- package/dist/github-4X4MYINS.js +4 -0
- package/dist/{habits-BX2IRSUI.js → habits-UA7YT3CG.js} +3 -3
- package/dist/{hooks-AXBWYJ5V.js → hooks-XXJ7CSGJ.js} +1 -1
- package/dist/index.js +9 -9
- package/dist/{init-F4MSKZIW.js → init-QPMLEQWQ.js} +1 -1
- package/dist/{integrity-7TKX3DZ4.js → integrity-FRGF5BFS.js} +1 -1
- package/dist/lint-Y4P3MHBV.js +26 -0
- package/dist/list-5XRLWD7K.js +12 -0
- package/dist/mcp.js +1 -1
- package/dist/{migrate-5M4KUQ2L.js → migrate-LIVXILOO.js} +1 -1
- package/dist/nomination-engine-EFXDEPZN.js +2 -0
- package/dist/{orchestrate-MLUGQOEJ.js → orchestrate-C5NM5MFN.js} +1 -1
- package/dist/orchestration-EVWQWTOV.js +2 -0
- package/dist/orchestration-UP3KFUJT.js +2 -0
- package/dist/{platform-server-Y6TLEXR2.js → platform-server-FXF3XFHM.js} +1 -1
- package/dist/{probe-27ARJKRO.js → probe-G3TKOJYW.js} +1 -1
- package/dist/quiz-QKIKAVL7.js +10 -0
- package/dist/registry-NEW4OJ44.js +2 -0
- package/dist/reindex-QZYOD5K4.js +2 -0
- package/dist/{reindex-ZLDQBFUR.js → reindex-W67B2LQP.js} +1 -1
- package/dist/remember-KZYAY77S.js +14 -0
- package/dist/{review-BRO2UP4M.js → review-WHRNLW2W.js} +1 -1
- package/dist/{ripple-KCVDS3WE.js → ripple-B6U7263T.js} +1 -1
- package/dist/{serve-2PKJP65E.js → serve-6RNZYK2I.js} +2 -2
- package/dist/{serve-XZ6GBUS3.js → serve-ZT2Z54NK.js} +1 -1
- package/dist/{setup-5V2AGLQ6.js → setup-L5OP24US.js} +3 -3
- package/dist/{shift-PM4GI736.js → shift-UDKXCIW7.js} +3 -3
- package/dist/{show-N5LGB5B2.js → show-VXNGIJE4.js} +3 -3
- package/dist/{snapshot-YMX5QRBM.js → snapshot-MT5L6XE4.js} +1 -1
- package/dist/{spawn-PHA2SVQ3.js → spawn-I6XG57S2.js} +1 -1
- package/dist/status-45KIG32R.js +6 -0
- package/dist/{status-3GJXI4IK.js → status-4QGKLOP6.js} +4 -4
- package/dist/{summary-RPU2BS3Q.js → summary-6QNVQZJV.js} +1 -1
- package/dist/symphony-KQJ6HIXB.js +53 -0
- package/dist/symphony-VDNDFK7H.js +2 -0
- package/dist/symphony-relay-ASMKPDEE.js +3 -0
- package/dist/task-KFND4HLF.js +3 -0
- package/dist/task-loader-HBZ3KRH2.js +2 -0
- package/dist/task-loader-IO4UVFUD.js +2 -0
- package/dist/task-settlement-NF7PFSNE.js +3 -0
- package/dist/task-settlement-TATNPY6L.js +3 -0
- package/dist/team-6WNNLBAO.js +2 -0
- package/dist/thread-2A7QKU72.js +41 -0
- package/dist/tools-GDWT74O6.js +2 -0
- package/dist/tools-SDWAFQMQ.js +142 -0
- package/dist/validate-OZTX3FYX.js +13 -0
- package/dist/validate-RIMSY3RP.js +9 -0
- package/dist/{workspace-6POCBPDY.js → workspace-4D4TQ637.js} +1 -1
- package/package.json +1 -1
- package/dist/add-V6XR7DU5.js +0 -12
- package/dist/agent-loader-Z753DQWH.js +0 -2
- package/dist/ambient-QB7V4TBR.js +0 -6
- package/dist/captain-3COP6YTD.js +0 -2
- package/dist/chunk-4CGPLLWQ.js +0 -30
- package/dist/chunk-7SWEOPWF.js +0 -2
- package/dist/chunk-CHSU6LTR.js +0 -2
- package/dist/chunk-EKNLG73M.js +0 -6
- package/dist/chunk-H55W26AR.js +0 -3
- package/dist/chunk-HE2NA5QF.js +0 -8
- package/dist/chunk-JIXHEBGK.js +0 -7
- package/dist/chunk-MBPLJKE5.js +0 -3
- package/dist/chunk-OIYJUU6T.js +0 -25
- package/dist/chunk-QO7YPQXC.js +0 -2
- package/dist/chunk-XPPFILCM.js +0 -2
- package/dist/chunk-YCDOA5IQ.js +0 -18
- package/dist/lint-IGKE6UPS.js +0 -26
- package/dist/list-NC3QGT75.js +0 -12
- package/dist/lore-loader-HAZ5FRLP.js +0 -2
- package/dist/nomination-engine-ORHH4L2W.js +0 -2
- package/dist/orchestration-O2OVPTIZ.js +0 -2
- package/dist/quiz-TNV6APBM.js +0 -10
- package/dist/remember-MJRNTXYS.js +0 -14
- package/dist/session-work-log-FF7CKMWP.js +0 -2
- package/dist/status-ENAI35NL.js +0 -6
- package/dist/symphony-CFAYJGLF.js +0 -2
- package/dist/symphony-L56O5ZG3.js +0 -53
- package/dist/symphony-relay-Y2UR3YNR.js +0 -3
- package/dist/task-loader-H7HQAYGL.js +0 -2
- package/dist/task-loader-YZME4RKE.js +0 -2
- package/dist/task-settlement-HINBVZBE.js +0 -3
- package/dist/task-settlement-XC6E6JNT.js +0 -3
- package/dist/team-25LK6CWM.js +0 -2
- package/dist/thread-HFXK65D4.js +0 -41
- package/dist/tools-GAU5WOEI.js +0 -2
- package/dist/validate-IQG7DBFC.js +0 -9
- package/dist/validate-LSCDOLBO.js +0 -13
- package/dist/work-log-loader-CRVTOMVB.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {D}from'./chunk-
|
|
2
|
+
import {D as D$1}from'./chunk-K7KT6FL3.js';import {O}from'./chunk-W3VWORQZ.js';import {z as z$1,b as b$1,c}from'./chunk-KAFQA7HV.js';import {b,a}from'./chunk-EK4ZRIFJ.js';import*as D from'fs';import*as ne from'os';import*as Y from'path';import*as G from'js-yaml';z$1();b();var le=/[@#$%^!?&~][a-zA-Z0-9_-]+/g;var B={architect:"tier-1",ftux:"tier-1",scholar:"tier-1",security:"tier-1",advocate:"tier-1",product:"tier-1",operations:"tier-1",sales:"tier-1",legal:"tier-1",ethicist:"tier-1",futurist:"tier-1",cartographer:"tier-1",cid:"tier-1","agent-evaluator":"tier-1","data-model":"tier-1",domain:"tier-1",regulatory:"tier-1",compliance:"tier-2",reviewer:"tier-2",designer:"tier-2",copywriter:"tier-2",researcher:"tier-2",analyst:"tier-2",dx:"tier-2",qa:"tier-2",debugger:"tier-2",performance:"tier-2",creative:"tier-2",pm:"tier-2",narrator:"tier-2",e2e:"tier-2",educator:"tier-2",community:"tier-2","content-intel":"tier-2",ai:"tier-2",mediator:"tier-2",presenter:"tier-2",mentor:"tier-2",trainer:"tier-2",a11y:"tier-2",seo:"tier-2",swift:"tier-2",forms:"tier-2",geo:"tier-2",builder:"tier-3",tester:"tier-3",documentor:"tier-3",sysadmin:"tier-3",archivist:"tier-3",release:"tier-3",devops:"tier-3",dba:"tier-3",dataeng:"tier-3",integrator:"tier-3",network:"tier-3",streaming:"tier-3",mobile:"tier-3",gamedev:"tier-3","3d":"tier-3",i18n:"tier-3",translator:"tier-3",forge:"tier-3",secretary:"tier-3",reverser:"tier-3",audio:"tier-3",finance:"tier-3",offline:"tier-3","report-gen":"tier-3"},z={"tier-1":"opus","tier-2":"sonnet","tier-3":"haiku"};function se(a,e,t){try{let k=Y.join(e,".paradigm","config.yaml");if(D.existsSync(k)){let n=G.load(D.readFileSync(k,"utf8"))?.["model-resolution"];if(n){let d=t?.modelTier||B[a]||"tier-2";if(n[d])return n[d]}}}catch{}if(t?.defaultModel)return t.defaultModel;let c=B[a]||"tier-2";return z[c]||"sonnet"}var de={architect:{min:5e3,max:2e4},ftux:{min:4e3,max:18e3},security:{min:3e3,max:15e3},reviewer:{min:2e3,max:1e4},builder:{min:1e4,max:5e4},tester:{min:5e3,max:2e4},cartographer:{min:1e3,max:5e3}};function ue(a$1){try{let e=Y.join(a$1,".paradigm","learned","token-estimates.json");if(!D.existsSync(e))return {};let t=JSON.parse(D.readFileSync(e,"utf8"));return !t||typeof t!="object"||Array.isArray(t)?{}:t}catch(e){return a.component("#calibration").warn("learned token table load failed; using constant prior",{error:e instanceof Error?e.message:String(e)}),{}}}function pe(a,e,t){if(t){let c=a[e]?.[t];if(c&&typeof c.min=="number"&&typeof c.max=="number")return {min:c.min,max:c.max}}return de[e]||{min:5e3,max:2e4}}var U={architect:`You are the ARCHITECT agent.
|
|
3
3
|
|
|
4
4
|
## Your Role
|
|
5
5
|
You design system architecture, write specifications, and plan features.
|
|
@@ -450,7 +450,7 @@ code, and never modify .purpose files or portal.yaml.
|
|
|
450
450
|
- Produce lengthy analysis \u2014 be sharp, summarize, and hand off`};function We(){return [{name:"paradigm_orchestrate_inline",description:`REQUIRED before implementing features. Start with mode="quick" for fast pre-check, or mode="plan" for full orchestration planning.
|
|
451
451
|
|
|
452
452
|
Plans and coordinates multi-agent task execution within the same session.
|
|
453
|
-
- mode: "quick" - Lightweight pre-implementation check (~3-4k tokens). Jinx (advocate) stress-tests assumptions, reviewer checks feasibility. Returns greenlight or escalates to full orchestration.
|
|
453
|
+
- mode: "quick" - Lightweight pre-implementation check (~3-4k tokens). Jinx (advocate) stress-tests assumptions, reviewer checks feasibility. Returns greenlight or escalates to full orchestration. NOTE: quick is a pre-check only \u2014 it does NOT satisfy orchestration-required enforcement. Enforcement is satisfied by a COMPLETED run (verdicts > 0 \u2014 a settled task DAG or a debrief with real agent verdicts) or by declaring \`paradigm solo\`.
|
|
454
454
|
- mode: "plan" - See suggested agents, estimated tokens, and get orchestration plan
|
|
455
455
|
- mode: "execute" - Get full prompts and execution strategy for any IDE
|
|
456
456
|
|
|
@@ -462,7 +462,7 @@ After getting prompts, launch agents using the Task tool. Stages marked canRunPa
|
|
|
462
462
|
The active mode is set via \`orchestration.default_mode\` in agents.yaml (defaults to "faceted").
|
|
463
463
|
|
|
464
464
|
When to use this tool:
|
|
465
|
-
- mode="quick": Before any implementation \u2014 fast sanity check
|
|
465
|
+
- mode="quick": Before any implementation \u2014 fast sanity check (does NOT satisfy enforcement; a completed run with verdicts>0 or \`paradigm solo\` does)
|
|
466
466
|
- mode="plan": Task affects 3+ files, involves security, or mentions multiple symbols
|
|
467
467
|
- mode="execute": Ready to implement, need full agent prompts
|
|
468
468
|
|
|
@@ -470,17 +470,17 @@ Examples:
|
|
|
470
470
|
- "Fix the login bug" \u2192 quick (greenlight or escalate)
|
|
471
471
|
- "Add user authentication with JWT" \u2192 plan \u2192 architect + security + builder + tester
|
|
472
472
|
- "Should I use soft delete or hard delete?" \u2192 plan \u2192 architect only (analysis)
|
|
473
|
-
- "Refactor the payment module" \u2192 plan \u2192 architect + builder`,inputSchema:{type:"object",properties:{task:{type:"string",description:'The task to orchestrate (e.g., "Build @payment-system with Stripe integration")'},mode:{type:"string",enum:["quick","plan","execute"],description:'Mode: "quick" for lightweight pre-check (advocate + reviewer), "plan" returns suggested agents and plan, "execute" returns prompts ready for Task tool'},agents:{type:"array",items:{type:"string"},description:'Optional: Override which agents to use (e.g., ["architect", "builder"])'}},required:["task"]},annotations:{readOnlyHint:true,destructiveHint:false},aliases:["plan","coordinate","team","multi-agent","orchestrate","agents","spawn agents"]},{name:"paradigm_agent_prompt",description:"Get the complete prompt for a specific agent to execute a task. Use this when you need to spawn an agent via the Task tool with full context.",inputSchema:{type:"object",properties:{agent:{type:"string",enum:["advocate","architect","builder","cartographer","compliance","ftux","scholar","swift","tester","reviewer","security","documentor"],description:"The agent role to get prompt for"},task:{type:"string",description:"The specific task for this agent"},handoffContext:{type:"string",description:"Optional: Context passed from a previous agent"},previousAgent:{type:"string",description:"Optional: Name of the agent that handed off"}},required:["agent","task"]},annotations:{readOnlyHint:true,destructiveHint:false}}]}async function Fe(a,e,t){return a==="paradigm_orchestrate_inline"?ge(e,t):a==="paradigm_agent_prompt"?he(e,t):{handled:false,text:""}}async function ge(a,e){let t=a.task,c$1=a.mode||"execute",k=a.agents;try{let
|
|
474
|
-
`,"utf8");}catch{}let g=re(e.rootDir);if(!g){let
|
|
475
|
-
## Permission Constraints`];P.permissions.paths?.deny?.length&&
|
|
476
|
-
`+
|
|
477
|
-
`);}y.set(
|
|
473
|
+
- "Refactor the payment module" \u2192 plan \u2192 architect + builder`,inputSchema:{type:"object",properties:{task:{type:"string",description:'The task to orchestrate (e.g., "Build @payment-system with Stripe integration")'},mode:{type:"string",enum:["quick","plan","execute"],description:'Mode: "quick" for lightweight pre-check (advocate + reviewer), "plan" returns suggested agents and plan, "execute" returns prompts ready for Task tool'},agents:{type:"array",items:{type:"string"},description:'Optional: Override which agents to use (e.g., ["architect", "builder"])'}},required:["task"]},annotations:{readOnlyHint:true,destructiveHint:false},aliases:["plan","coordinate","team","multi-agent","orchestrate","agents","spawn agents"]},{name:"paradigm_agent_prompt",description:"Get the complete prompt for a specific agent to execute a task. Use this when you need to spawn an agent via the Task tool with full context.",inputSchema:{type:"object",properties:{agent:{type:"string",enum:["advocate","architect","builder","cartographer","compliance","ftux","scholar","swift","tester","reviewer","security","documentor"],description:"The agent role to get prompt for"},task:{type:"string",description:"The specific task for this agent"},handoffContext:{type:"string",description:"Optional: Context passed from a previous agent"},previousAgent:{type:"string",description:"Optional: Name of the agent that handed off"}},required:["agent","task"]},annotations:{readOnlyHint:true,destructiveHint:false}}]}async function Fe(a,e,t){return a==="paradigm_orchestrate_inline"?ge(e,t):a==="paradigm_agent_prompt"?he(e,t):{handled:false,text:""}}async function ge(a,e){let t=a.task,c$1=a.mode||"execute",k=a.agents;try{let h=Y.join(e.rootDir,".paradigm","events");D.existsSync(h)||D.mkdirSync(h,{recursive:!0}),D.appendFileSync(Y.join(h,"team-funnel.jsonl"),JSON.stringify({timestamp:new Date().toISOString(),type:"orchestrated",source:"orchestrate_inline",mode:c$1})+`
|
|
474
|
+
`,"utf8");}catch{}let g=re(e.rootDir);if(!g){let h=JSON.stringify({error:"No agents.yaml found",suggestion:"Run `paradigm team init` to set up multi-agent orchestration"},null,2);return O(h.length,"paradigm_orchestrate_inline"),{handled:true,text:h}}let n=b$1(e.rootDir);if(n&&g.agents){let h={};for(let[m,u]of Object.entries(g.agents))n.includes(m)&&(h[m]=u);g.agents=h;}let d=H(t),o=[];try{let{processPendingEvents:h,loadNominations:m}=await import('./nomination-engine-YRHZZZUN.js');h(e.rootDir),o=m(e.rootDir,{pending_only:!0,limit:10}).filter(l=>l.urgency==="high"||l.urgency==="critical").map(l=>({agent:l.agent,urgency:l.urgency,brief:l.brief}));}catch{}let s=De(t);if(c$1==="quick")return me(t,d,s,o,g,e);let i=ye(t,g.agents,k,s,g.orchestration,e.rootDir);if(c$1==="plan"){let h=Ce(t,g.agents),m=Oe(i,s),u;try{let{loadNotebookEntries:S}=await import('./notebook-loader-TZVIMNDJ.js'),v=d.map(E=>E.replace(/^[#$^!~@&%?]/,"").toLowerCase()),N={},x=new Set;for(let E of i.stages)for(let P of E.agents){if(x.has(P.name))continue;x.add(P.name);let j=S(P.name,e.rootDir),I=v.length>0?S(P.name,e.rootDir,{concepts:v}):j;j.length>0&&(N[P.name]={totalEntries:j.length,relevantEntries:I.length});}Object.keys(N).length>0&&(u=N);}catch{}let l=i.stages.flatMap(S=>S.agents.map(v=>v.name)),w=ie(l,g.agents),T=w.length>0?{edges:w,note:"Shows which agents hand off to which based on agents.yaml handoff_to. Stage ordering was derived from this graph."}:void 0,_=JSON.stringify({task:t,mode:"plan",classification:{type:s.type,confidence:s.confidence,...s.alternativeType?{alternativeType:s.alternativeType}:{},overrideHint:s.overrideHint,complexity:s.complexity,securityRequired:s.securityRequired,costMultiplier:s.costMultiplier},plan:i,suggestedAgents:h,costPreview:m,...T?{collaborationGraph:T}:{},...u?{notebookKnowledge:u,notebookNote:"Agents with relevant notebook entries will have curated knowledge injected into their prompts during execute mode."}:{},...o.length>0?{activeNominations:o,nominationNote:`${o.length} high-urgency agent nomination(s) pending. These agents have been flagged by the system for attention on this project.`}:{},instructions:["Review task classification and cost preview above","Review suggested agents based on task triggers",...T?["Review collaboration graph \u2014 stage ordering was derived from agent handoff_to edges"]:[],...u?["Review notebook knowledge \u2014 agents with relevant entries will receive curated snippets in execute mode"]:[],...o.length>0?["Review active nominations \u2014 agents flagged by the system may need to be included"]:[],'Call again with mode="execute" to get full prompts and execution strategy',"Stages marked canRunParallel: true can be launched simultaneously","After each agent completes, pass handoff context to the next stage"]},null,2);return O(_.length,"paradigm_orchestrate_inline"),{handled:true,text:_}}let y=new Map;try{let{loadAgentProfile:h,buildProfileEnrichment:m}=await import('./agent-loader-W3RQJVW7.js'),{loadDecisions:u}=await import('./decision-loader-HELL2AMX.js'),{loadJournalEntries:l}=await import('./journal-loader-CNNA4EAU.js'),{loadNominations:w}=await import('./nomination-engine-YRHZZZUN.js'),{loadAgentState:T}=await import('./agent-state-KSQ3S7OB.js'),{loadNotebookEntries:_}=await import('./notebook-loader-TZVIMNDJ.js'),S=u(e.rootDir,{status:"active",limit:5}).map(x=>({title:x.title,decision:x.decision.slice(0,150)})),v=w(e.rootDir,{pending_only:!0,limit:10}).map(x=>({urgency:x.urgency,brief:x.brief})),N=d.map(x=>x.replace(/^[#$^!~@&%?]/,"").toLowerCase());for(let x of i.stages)for(let E of x.agents)if(!y.has(E.name)){let P=h(e.rootDir,E.name);if(P){if(!c(E.name,e.rootDir))continue;let j=l(E.name,{transferable:!0,limit:5}).map(M=>({trigger:M.trigger,insight:M.insight.slice(0,150)})),I=T(E.name,e.rootDir),K;try{let M=_(E.name,e.rootDir,N.length>0?{concepts:N}:void 0);if(M.length>0){let J=M.sort(($,W)=>W.confidence-$.confidence||new Date(W.updated).getTime()-new Date($.updated).getTime()).slice(0,5);K=J.map($=>({context:$.context,snippet:$.snippet,concepts:$.concepts}));try{let{recordNotebookReference:$}=await import('./session-work-log-T2IE4Y4T.js');$(e.rootDir,E.name,J.map(W=>W.id));}catch{}try{let{incrementApplied:$}=await import('./notebook-loader-TZVIMNDJ.js');for(let W of J)$(E.name,W.id,e.rootDir);}catch{}}}catch{}let L=m(P,d,K,{recentDecisions:S,journalInsights:j,pendingNominations:v},I?{lastSession:I.lastSession,pendingWork:I.pendingWork,recentPatterns:I.recentPatterns,sessionsOnProject:I.sessionsOnProject}:void 0);if(P.permissions){let M=[`
|
|
475
|
+
## Permission Constraints`];P.permissions.paths?.deny?.length&&M.push(`**Denied paths:** ${P.permissions.paths.deny.join(", ")}`),P.permissions.paths?.write?.length&&M.push(`**Writable paths:** ${P.permissions.paths.write.join(", ")}`),P.permissions.tools?.deny?.length&&M.push(`**Denied tools:** ${P.permissions.tools.deny.join(", ")}`),P.permissions.dangerous_actions?.length&&M.push(`**Requires approval for:** ${P.permissions.dangerous_actions.join(", ")}`),L+=`
|
|
476
|
+
`+M.join(`
|
|
477
|
+
`);}y.set(E.name,{enrichment:L.trim()?L:"",nickname:P.nickname,description:P.description});}}}catch{}let r;try{let h=await D$1("paradigm_captain_brief",{taskDescription:t,symbols:d,depth:"standard"},e);h.handled&&(r=JSON.parse(h.text).renderedBrief);}catch{}let p=[];for(let h of i.stages){let m=[];for(let u of h.agents){let l=g.agents[u.name],w=y.get(u.name),T={name:l?.name||u.name,role:l?.role||U[u.name]||`${u.name} agent`,description:w?.description,focus:l?.focus||{reads:["**/*"],writes:["**/*"]},defaultModel:se(u.name,e.rootDir,l),triggers:l?.triggers,handoff_to:l?.handoff_to,context:l?.context,protocol:l?.protocol},_=oe({agent:T,task:u.task,symbols:d,dependsOn:u.dependsOn,profileEnrichment:w?.enrichment,nickname:w?.nickname,captainBrief:r});m.push(_);}p.push({stage:h.stage,canRunParallel:h.canRunParallel,agents:m});}let f=`orch-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,6)}`;Ie(e.rootDir,f,t,i);let{epicTaskId:A,agentTaskIds:R}=await Ne(e.rootDir,f,t,i);for(let h of p)for(let m of h.agents){let u=R.get(m.agent);u&&(m.taskId=u,m.prompt+=`
|
|
478
478
|
|
|
479
479
|
## Task tracking (v7 DAG)
|
|
480
|
-
Your DAG task-id is \`${u}\`. On start, call \`paradigm_task_update({ id: "${u}", status: "in-progress" })\`; when finished, call \`paradigm_task_done({ id: "${u}" })\` (or \`paradigm_task_update\` \u2192 done) so the orchestration loop can settle.`);}try{let{appendSessionWorkEntry:m}=await import('./session-work-log-T2IE4Y4T.js');for(let h of p)for(let u of h.agents)m(e.rootDir,{timestamp:new Date().toISOString(),type:"agent-contribution",agent:u.agent,contribution:u.taskDescription?.slice(0,200)||t.slice(0,200),attribution:u.attribution,symbols:d});}catch{}try{let{recordAgentSession:m}=await import('./agent-state-KSQ3S7OB.js'),u=(await import('./session-tracker-BZ7FU4AT.js')).default?.session?.sessionId||f;for(let l of p)for(let w of l.agents)m(w.agent,e.rootDir,{sessionId:u,summary:`${w.attribution||w.agent}: ${(w.taskDescription||t).slice(0,200)}`,symbolsTouched:d});}catch{}let b=`thr-orch-${f}`;try{let m=await import('./symphony-loader-VA4UREOM.js'),h=M.basename(e.rootDir),u=`${h}/maestro`;try{m.getMyIdentity(e.rootDir)||m.registerAgent(e.rootDir,"maestro","Maestro (orchestrator)");}catch{}m.createThread(`Orchestration: ${t.slice(0,80)}`,{id:u,name:"Maestro",type:"agent",project:h,role:"orchestrator"});let l=M.join(ne.homedir(),".paradigm","score","threads"),w=E.readdirSync(l).filter(_=>_.endsWith(".json")).sort(),T=w[w.length-1];if(T){let _=M.join(l,T),S=M.join(l,`${b}.json`),v=JSON.parse(E.readFileSync(_,"utf8"));v.id=b,E.writeFileSync(S,JSON.stringify(v,null,2),"utf8"),_!==S&&E.unlinkSync(_);}for(let _ of p)for(let S of _.agents){let v=m.buildMessage({threadRoot:b,sender:{id:u,name:"Maestro",type:"agent",project:h,role:"orchestrator"},intent:"task",text:`[Maestro] Stage ${_.stage}: Assigned to ${S.attribution||S.agent} \u2014 ${S.taskDescription||t}`,symbols:d,metadata:{task:{stage:_.stage,canRunParallel:_.canRunParallel,...S.taskId?{taskId:S.taskId}:{}}}});m.routeMessage(v);}}catch{}let O$1={orchestrationId:f,task:t,mode:"execute",classification:{type:s.type,confidence:s.confidence,...s.alternativeType?{alternativeType:s.alternativeType}:{},overrideHint:s.overrideHint},symbols:d,totalAgents:i.estimatedAgents,...o.length>0?{activeNominations:o}:{},...A?{emittedTasks:{epicTaskId:A,stageTasks:p.flatMap(m=>m.agents.filter(h=>h.taskId).map(h=>({stage:m.stage,agent:h.agent,taskId:h.taskId})))}}:{},stages:p,executionInstructions:["Execute stages in order (stage 0, then stage 1, etc.)","Agents within a stage can be run in parallel if your environment supports it","Pass handoff context between stages",'Present each agent response as an attributed message using the attribution prefix (e.g., "[architect] Rate limiter should go before ^authenticated")',"Do NOT synthesize agent responses \u2014 show them as distinct contributions from each agent","After all agents in a stage complete, reconcile their outputs before proceeding to the next stage"],finalStep:{mandatory:true,description:"FINAL STEPS (mandatory, in order):",steps:[{order:1,action:"Call paradigm_captain_debrief",args:{orchestrationId:`${f} (use the orchestrationId from this response)`,sessionSummary:"(summarize what was accomplished)",touchedFiles:"(list all files modified during this session)",newSymbols:"(optional: list any new symbols registered)"}},{order:2,action:"Take the sessionInsights from the debrief result and call paradigm_ambient_learn_postflight",args:{sessionId:`${f} (use the orchestrationId from this response)`,context:"(pass the sessionInsights object from the debrief result here)"},note:"This is Loid's learning pass \u2014 she processes what the crew learned and ensures it compounds."},{order:3,action:"Session is complete."}],note:"Step 1 closes the session, updates .purpose coverage, records lore, and clears the stop hook. Step 2 runs Loid's learning pass on the session insights. Both steps are required \u2014 the session is NOT complete until both run."},claudeCode:{method:"Task tool",example:{description:p[0]?.agents[0]?.taskDescription||"Agent task",prompt:"(see agent prompts above)",subagent_type:"general-purpose"},parallel:"Launch multiple Task calls in one message for parallel stages"},sequential:{method:"Execute each role in sequence within this session",steps:i.stages.map((m,h)=>({stage:h,rolePrompt:`Adopt the ${m.agents[0]?.name} role. Focus ONLY on: ${m.agents.map(u=>u.task).join(", ")}`,constraint:h===0?"Design/plan only \u2014 do NOT write implementation code":h===i.stages.length-1?"Verify and test \u2014 do NOT change implementation":"Implement following the design from the previous stage"}))},cli:{method:"paradigm team orchestrate",command:`paradigm team orchestrate "${t}"`,note:"Spawns independent agent processes \u2014 works from any terminal"},symphony:{enabled:true,orchestrationThread:b,instructions:["After each agent completes, call paradigm_symphony_send to report progress. This makes the work visible in Conductor.",'Use intent "context" for analysis, "proposal" for recommendations, "decision" for decisions made',`Set threadRoot to "${b}" so all contributions are in one thread`,"Include the symbols array from the agent relay output"],perAgentInstruction:`When each agent finishes, run: paradigm_symphony_send threadId="${b}" intent="task-complete" text="[agentName] Summary of completed work" symbols=[touched symbols]`,exampleCall:{intent:"context",text:"[architect] Rate limiter should be placed before ^authenticated gate to prevent unauthenticated flood",threadRoot:b,symbols:["#rate-limiter","^authenticated"]}}},C=JSON.stringify(O$1,null,2);return O(C.length,"paradigm_orchestrate_inline"),{handled:true,text:C}}async function me(a,e,t,c,k,g){let n=a.toLowerCase(),d;try{let b=await D("paradigm_captain_brief",{taskDescription:a,symbols:e,depth:"quick"},g);if(b.handled){let O=JSON.parse(b.text);d={coverage:`${O.coverage?.label||"unknown"} (${Math.round((O.coverage?.score||0)*100)}%)`,warnings:O.warnings||[]};}}catch{}let o=[];t.securityRequired&&o.push("security-adjacent task (auth, gates, permissions detected)"),t.complexity==="high"&&o.push(`high complexity task (type: ${t.type})`),e.length>=4&&o.push(`${e.length} symbols in scope \u2014 cross-cutting change`);let s=c.filter(b=>b.urgency==="critical");s.length>0&&o.push(`${s.length} critical agent nomination(s) pending`);let i={assumptions:[],risks:[],edgeCases:[],questions:[]};(n.includes("simple")||n.includes("just")||n.includes("only"))&&i.assumptions.push("Task framed as simple \u2014 verify no hidden complexity"),(n.includes("always")||n.includes("never"))&&i.assumptions.push("Absolute language detected \u2014 edge cases likely exist"),!n.includes("error")&&!n.includes("fail")&&!n.includes("invalid")&&i.assumptions.push("No error/failure handling mentioned \u2014 what happens when it fails?"),e.some(b=>b.startsWith("$"))&&i.risks.push("Flow symbols detected \u2014 multi-step changes have ordering/rollback risk"),e.some(b=>b.startsWith("^"))&&(i.risks.push("Gate symbols detected \u2014 authorization changes require security review"),o.some(b=>b.includes("security"))||o.push("gate symbols in scope \u2014 security review recommended")),t.matchedKeywords.some(b=>["migration","database","schema"].includes(b))&&i.risks.push("Data migration risk \u2014 irreversible changes need rollback plan"),t.matchedKeywords.some(b=>["delete","remove","drop"].includes(b))&&i.risks.push("Destructive operation \u2014 verify nothing depends on removed items"),(n.includes("add")||n.includes("new"))&&i.edgeCases.push("New feature \u2014 how does it interact with existing features?"),(n.includes("refactor")||n.includes("rename"))&&i.edgeCases.push("Refactor \u2014 all callers updated? Integration tests cover the change?"),(n.includes("fix")||n.includes("bug"))&&i.edgeCases.push("Bug fix \u2014 does the fix address the root cause or just the symptom?"),n.includes("test")||i.questions.push("How will this be tested?"),e.length===0&&i.questions.push("No symbols referenced \u2014 which components are actually affected?");let y={concerns:[],suggestions:[]};for(let b of e){let O=b.replace(/^[#$^!~@&%?]/,"");!k.agents[O]&&b.startsWith("#");}t.costMultiplier.max>1&&y.concerns.push(`Higher-than-average complexity (${t.costMultiplier.min}x-${t.costMultiplier.max}x baseline) \u2014 consider breaking into smaller tasks`);let r=[];try{let{loadNotebookEntries:b}=await import('./notebook-loader-TZVIMNDJ.js'),O=e.map(m=>m.replace(/^[#$^!~@&%?]/,"").toLowerCase()),C=b("advocate",g.rootDir,O.length>0?{concepts:O}:void 0);C.length>0&&(r=C.sort((m,h)=>h.confidence-m.confidence).slice(0,3).map(m=>m.snippet));}catch{}let f=o.length>=2||o.some(b=>b.includes("security")||b.includes("critical"))?"escalate":"greenlight",A={mode:"quick",task:a,verdict:f,classification:{type:t.type,confidence:t.confidence,...t.alternativeType?{alternativeType:t.alternativeType}:{},overrideHint:t.overrideHint,complexity:t.complexity,securityRequired:t.securityRequired},advocate:{agent:"Jinx (advocate)",...i.assumptions.length>0?{assumptions:i.assumptions}:{},...i.risks.length>0?{risks:i.risks}:{},...i.edgeCases.length>0?{edgeCases:i.edgeCases}:{},...i.questions.length>0?{questions:i.questions}:{},...r.length>0?{notebookInsights:r}:{}},reviewer:{agent:"reviewer",...y.concerns.length>0?{concerns:y.concerns}:{},...y.suggestions.length>0?{suggestions:y.suggestions}:{}},...o.length>0?{escalationSignals:o}:{},...c.length>0?{activeNominations:c}:{},...d?{captainBrief:d}:{},symbols:e,instructions:f==="greenlight"?["Quick check passed \u2014 proceed with implementation.","Orchestration enforcement is satisfied.",i.questions.length>0?`Address Jinx's questions during implementation: ${i.questions.join("; ")}`:"No open questions from advocate."]:["Quick check recommends full orchestration.",`Escalation reasons: ${o.join("; ")}`,'Call paradigm_orchestrate_inline mode="plan" for full agent planning.',"Orchestration enforcement is satisfied regardless of verdict."]},R=JSON.stringify(A,null,2);return O(R.length,"paradigm_orchestrate_inline"),{handled:true,text:R}}async function he(a,e){let t=a.agent,c=a.task,k=a.handoffContext,g=a.previousAgent,n=re(e.rootDir),d=b$1(e.rootDir);if(d&&!d.includes(t)){let R=JSON.stringify({warning:`Agent "${t}" is not on this project's roster`,suggestion:`Run paradigm_agent_activate id="${t}" to add it, or check .paradigm/roster.yaml`,activeRoster:d},null,2);return O(R.length,"paradigm_agent_prompt"),{handled:true,text:R}}let o=n?.agents[t],s={name:o?.name||t,role:o?.role||U[t]||U.builder,focus:o?.focus||{reads:["**/*"],writes:["**/*"]},defaultModel:se(t,e.rootDir,o),triggers:o?.triggers,handoff_to:o?.handoff_to,context:o?.context,protocol:o?.protocol},i=H(c),y,r;try{let{loadAgentProfile:R,buildProfileEnrichment:b}=await import('./agent-loader-W3RQJVW7.js'),{loadDecisions:O}=await import('./decision-loader-HELL2AMX.js'),{loadJournalEntries:C}=await import('./journal-loader-CNNA4EAU.js'),{loadNominations:m}=await import('./nomination-engine-YRHZZZUN.js'),{loadNotebookEntries:h}=await import('./notebook-loader-TZVIMNDJ.js'),u=R(e.rootDir,t);if(u){r=u.nickname,s.description=u.description;let l=O(e.rootDir,{status:"active",limit:5}).map(v=>({title:v.title,decision:v.decision.slice(0,150)})),w=C(t,{transferable:!0,limit:5}).map(v=>({trigger:v.trigger,insight:v.insight.slice(0,150)})),T=m(e.rootDir,{pending_only:!0,limit:10}).map(v=>({urgency:v.urgency,brief:v.brief})),_;try{let v=i.map(x=>x.replace(/^[#$^!~@&%?]/,"").toLowerCase()),I=h(t,e.rootDir,v.length>0?{concepts:v}:void 0);if(I.length>0){let x=I.sort((D,P)=>P.confidence-D.confidence||new Date(P.updated).getTime()-new Date(D.updated).getTime()).slice(0,5);_=x.map(D=>({context:D.context,snippet:D.snippet,concepts:D.concepts}));try{let{recordNotebookReference:D}=await import('./session-work-log-T2IE4Y4T.js');D(e.rootDir,t,x.map(P=>P.id));}catch{}}}catch{}let S=b(u,i,_,{recentDecisions:l,journalInsights:w,pendingNominations:T});if(u.permissions){let v=[`
|
|
480
|
+
Your DAG task-id is \`${u}\`. On start, call \`paradigm_task_update({ id: "${u}", status: "in-progress" })\`; when finished, call \`paradigm_task_done({ id: "${u}" })\` (or \`paradigm_task_update\` \u2192 done) so the orchestration loop can settle.`);}try{let{appendSessionWorkEntry:h}=await import('./session-work-log-T2IE4Y4T.js');for(let m of p)for(let u of m.agents)h(e.rootDir,{timestamp:new Date().toISOString(),type:"agent-contribution",agent:u.agent,contribution:u.taskDescription?.slice(0,200)||t.slice(0,200),attribution:u.attribution,symbols:d});}catch{}try{let{recordAgentSession:h}=await import('./agent-state-KSQ3S7OB.js'),u=(await import('./session-tracker-BZ7FU4AT.js')).default?.session?.sessionId||f;for(let l of p)for(let w of l.agents)h(w.agent,e.rootDir,{sessionId:u,summary:`${w.attribution||w.agent}: ${(w.taskDescription||t).slice(0,200)}`,symbolsTouched:d});}catch{}let b=`thr-orch-${f}`;try{let h=await import('./symphony-loader-VA4UREOM.js'),m=Y.basename(e.rootDir),u=`${m}/maestro`;try{h.getMyIdentity(e.rootDir)||h.registerAgent(e.rootDir,"maestro","Maestro (orchestrator)");}catch{}h.createThread(`Orchestration: ${t.slice(0,80)}`,{id:u,name:"Maestro",type:"agent",project:m,role:"orchestrator"});let l=Y.join(ne.homedir(),".paradigm","score","threads"),w=D.readdirSync(l).filter(_=>_.endsWith(".json")).sort(),T=w[w.length-1];if(T){let _=Y.join(l,T),S=Y.join(l,`${b}.json`),v=JSON.parse(D.readFileSync(_,"utf8"));v.id=b,D.writeFileSync(S,JSON.stringify(v,null,2),"utf8"),_!==S&&D.unlinkSync(_);}for(let _ of p)for(let S of _.agents){let v=h.buildMessage({threadRoot:b,sender:{id:u,name:"Maestro",type:"agent",project:m,role:"orchestrator"},intent:"task",text:`[Maestro] Stage ${_.stage}: Assigned to ${S.attribution||S.agent} \u2014 ${S.taskDescription||t}`,symbols:d,metadata:{task:{stage:_.stage,canRunParallel:_.canRunParallel,...S.taskId?{taskId:S.taskId}:{}}}});h.routeMessage(v);}}catch{}let O$1={orchestrationId:f,task:t,mode:"execute",classification:{type:s.type,confidence:s.confidence,...s.alternativeType?{alternativeType:s.alternativeType}:{},overrideHint:s.overrideHint},symbols:d,totalAgents:i.estimatedAgents,...o.length>0?{activeNominations:o}:{},...A?{emittedTasks:{epicTaskId:A,stageTasks:p.flatMap(h=>h.agents.filter(m=>m.taskId).map(m=>({stage:h.stage,agent:m.agent,taskId:m.taskId})))}}:{},stages:p,executionInstructions:["Execute stages in order (stage 0, then stage 1, etc.)","Agents within a stage can be run in parallel if your environment supports it","Pass handoff context between stages",'Present each agent response as an attributed message using the attribution prefix (e.g., "[architect] Rate limiter should go before ^authenticated")',"Do NOT synthesize agent responses \u2014 show them as distinct contributions from each agent","After all agents in a stage complete, reconcile their outputs before proceeding to the next stage"],finalStep:{mandatory:true,description:"FINAL STEPS (mandatory, in order):",steps:[{order:1,action:"Call paradigm_captain_debrief",args:{orchestrationId:`${f} (use the orchestrationId from this response)`,sessionSummary:"(summarize what was accomplished)",touchedFiles:"(list all files modified during this session)",newSymbols:"(optional: list any new symbols registered)"}},{order:2,action:"Take the sessionInsights from the debrief result and call paradigm_ambient_learn_postflight",args:{sessionId:`${f} (use the orchestrationId from this response)`,context:"(pass the sessionInsights object from the debrief result here)"},note:"This is Loid's learning pass \u2014 she processes what the crew learned and ensures it compounds."},{order:3,action:"Session is complete."}],note:"Step 1 closes the session, updates .purpose coverage, records lore, and clears the stop hook. Step 2 runs Loid's learning pass on the session insights. Both steps are required \u2014 the session is NOT complete until both run."},claudeCode:{method:"Task tool",example:{description:p[0]?.agents[0]?.taskDescription||"Agent task",prompt:"(see agent prompts above)",subagent_type:"general-purpose"},parallel:"Launch multiple Task calls in one message for parallel stages"},sequential:{method:"Execute each role in sequence within this session",steps:i.stages.map((h,m)=>({stage:m,rolePrompt:`Adopt the ${h.agents[0]?.name} role. Focus ONLY on: ${h.agents.map(u=>u.task).join(", ")}`,constraint:m===0?"Design/plan only \u2014 do NOT write implementation code":m===i.stages.length-1?"Verify and test \u2014 do NOT change implementation":"Implement following the design from the previous stage"}))},cli:{method:"paradigm team orchestrate",command:`paradigm team orchestrate "${t}"`,note:"Spawns independent agent processes \u2014 works from any terminal"},symphony:{enabled:true,orchestrationThread:b,instructions:["After each agent completes, call paradigm_symphony_send to report progress. This makes the work visible in Conductor.",'Use intent "context" for analysis, "proposal" for recommendations, "decision" for decisions made',`Set threadRoot to "${b}" so all contributions are in one thread`,"Include the symbols array from the agent relay output"],perAgentInstruction:`When each agent finishes, run: paradigm_symphony_send threadId="${b}" intent="task-complete" text="[agentName] Summary of completed work" symbols=[touched symbols]`,exampleCall:{intent:"context",text:"[architect] Rate limiter should be placed before ^authenticated gate to prevent unauthenticated flood",threadRoot:b,symbols:["#rate-limiter","^authenticated"]}}},C=JSON.stringify(O$1,null,2);return O(C.length,"paradigm_orchestrate_inline"),{handled:true,text:C}}async function me(a,e,t,c,k,g){let n=a.toLowerCase(),d;try{let b=await D$1("paradigm_captain_brief",{taskDescription:a,symbols:e,depth:"quick"},g);if(b.handled){let O=JSON.parse(b.text);d={coverage:`${O.coverage?.label||"unknown"} (${Math.round((O.coverage?.score||0)*100)}%)`,warnings:O.warnings||[]};}}catch{}let o=[];t.securityRequired&&o.push("security-adjacent task (auth, gates, permissions detected)"),t.complexity==="high"&&o.push(`high complexity task (type: ${t.type})`),e.length>=4&&o.push(`${e.length} symbols in scope \u2014 cross-cutting change`);let s=c.filter(b=>b.urgency==="critical");s.length>0&&o.push(`${s.length} critical agent nomination(s) pending`);let i={assumptions:[],risks:[],edgeCases:[],questions:[]};(n.includes("simple")||n.includes("just")||n.includes("only"))&&i.assumptions.push("Task framed as simple \u2014 verify no hidden complexity"),(n.includes("always")||n.includes("never"))&&i.assumptions.push("Absolute language detected \u2014 edge cases likely exist"),!n.includes("error")&&!n.includes("fail")&&!n.includes("invalid")&&i.assumptions.push("No error/failure handling mentioned \u2014 what happens when it fails?"),e.some(b=>b.startsWith("$"))&&i.risks.push("Flow symbols detected \u2014 multi-step changes have ordering/rollback risk"),e.some(b=>b.startsWith("^"))&&(i.risks.push("Gate symbols detected \u2014 authorization changes require security review"),o.some(b=>b.includes("security"))||o.push("gate symbols in scope \u2014 security review recommended")),t.matchedKeywords.some(b=>["migration","database","schema"].includes(b))&&i.risks.push("Data migration risk \u2014 irreversible changes need rollback plan"),t.matchedKeywords.some(b=>["delete","remove","drop"].includes(b))&&i.risks.push("Destructive operation \u2014 verify nothing depends on removed items"),(n.includes("add")||n.includes("new"))&&i.edgeCases.push("New feature \u2014 how does it interact with existing features?"),(n.includes("refactor")||n.includes("rename"))&&i.edgeCases.push("Refactor \u2014 all callers updated? Integration tests cover the change?"),(n.includes("fix")||n.includes("bug"))&&i.edgeCases.push("Bug fix \u2014 does the fix address the root cause or just the symptom?"),n.includes("test")||i.questions.push("How will this be tested?"),e.length===0&&i.questions.push("No symbols referenced \u2014 which components are actually affected?");let y={concerns:[],suggestions:[]};for(let b of e){let O=b.replace(/^[#$^!~@&%?]/,"");!k.agents[O]&&b.startsWith("#");}t.costMultiplier.max>1&&y.concerns.push(`Higher-than-average complexity (${t.costMultiplier.min}x-${t.costMultiplier.max}x baseline) \u2014 consider breaking into smaller tasks`);let r=[];try{let{loadNotebookEntries:b}=await import('./notebook-loader-TZVIMNDJ.js'),O=e.map(h=>h.replace(/^[#$^!~@&%?]/,"").toLowerCase()),C=b("advocate",g.rootDir,O.length>0?{concepts:O}:void 0);C.length>0&&(r=C.sort((h,m)=>m.confidence-h.confidence).slice(0,3).map(h=>h.snippet));}catch{}let f=o.length>=2||o.some(b=>b.includes("security")||b.includes("critical"))?"escalate":"greenlight",A={mode:"quick",task:a,verdict:f,classification:{type:t.type,confidence:t.confidence,...t.alternativeType?{alternativeType:t.alternativeType}:{},overrideHint:t.overrideHint,complexity:t.complexity,securityRequired:t.securityRequired},advocate:{agent:"Jinx (advocate)",...i.assumptions.length>0?{assumptions:i.assumptions}:{},...i.risks.length>0?{risks:i.risks}:{},...i.edgeCases.length>0?{edgeCases:i.edgeCases}:{},...i.questions.length>0?{questions:i.questions}:{},...r.length>0?{notebookInsights:r}:{}},reviewer:{agent:"reviewer",...y.concerns.length>0?{concerns:y.concerns}:{},...y.suggestions.length>0?{suggestions:y.suggestions}:{}},...o.length>0?{escalationSignals:o}:{},...c.length>0?{activeNominations:c}:{},...d?{captainBrief:d}:{},symbols:e,instructions:f==="greenlight"?["Quick check passed \u2014 proceed with implementation.","Orchestration enforcement is satisfied.",i.questions.length>0?`Address Jinx's questions during implementation: ${i.questions.join("; ")}`:"No open questions from advocate."]:["Quick check recommends full orchestration.",`Escalation reasons: ${o.join("; ")}`,'Call paradigm_orchestrate_inline mode="plan" for full agent planning.',"Orchestration enforcement is satisfied regardless of verdict."]},R=JSON.stringify(A,null,2);return O(R.length,"paradigm_orchestrate_inline"),{handled:true,text:R}}async function he(a,e){let t=a.agent,c=a.task,k=a.handoffContext,g=a.previousAgent,n=re(e.rootDir),d=b$1(e.rootDir);if(d&&!d.includes(t)){let R=JSON.stringify({warning:`Agent "${t}" is not on this project's roster`,suggestion:`Run paradigm_agent_activate id="${t}" to add it, or check .paradigm/roster.yaml`,activeRoster:d},null,2);return O(R.length,"paradigm_agent_prompt"),{handled:true,text:R}}let o=n?.agents[t],s={name:o?.name||t,role:o?.role||U[t]||U.builder,focus:o?.focus||{reads:["**/*"],writes:["**/*"]},defaultModel:se(t,e.rootDir,o),triggers:o?.triggers,handoff_to:o?.handoff_to,context:o?.context,protocol:o?.protocol},i=H(c),y,r;try{let{loadAgentProfile:R,buildProfileEnrichment:b}=await import('./agent-loader-W3RQJVW7.js'),{loadDecisions:O}=await import('./decision-loader-HELL2AMX.js'),{loadJournalEntries:C}=await import('./journal-loader-CNNA4EAU.js'),{loadNominations:h}=await import('./nomination-engine-YRHZZZUN.js'),{loadNotebookEntries:m}=await import('./notebook-loader-TZVIMNDJ.js'),u=R(e.rootDir,t);if(u){r=u.nickname,s.description=u.description;let l=O(e.rootDir,{status:"active",limit:5}).map(v=>({title:v.title,decision:v.decision.slice(0,150)})),w=C(t,{transferable:!0,limit:5}).map(v=>({trigger:v.trigger,insight:v.insight.slice(0,150)})),T=h(e.rootDir,{pending_only:!0,limit:10}).map(v=>({urgency:v.urgency,brief:v.brief})),_;try{let v=i.map(x=>x.replace(/^[#$^!~@&%?]/,"").toLowerCase()),N=m(t,e.rootDir,v.length>0?{concepts:v}:void 0);if(N.length>0){let x=N.sort((E,P)=>P.confidence-E.confidence||new Date(P.updated).getTime()-new Date(E.updated).getTime()).slice(0,5);_=x.map(E=>({context:E.context,snippet:E.snippet,concepts:E.concepts}));try{let{recordNotebookReference:E}=await import('./session-work-log-T2IE4Y4T.js');E(e.rootDir,t,x.map(P=>P.id));}catch{}}}catch{}let S=b(u,i,_,{recentDecisions:l,journalInsights:w,pendingNominations:T});if(u.permissions){let v=[`
|
|
481
481
|
## Permission Constraints`];u.permissions.paths?.deny?.length&&v.push(`**Denied paths:** ${u.permissions.paths.deny.join(", ")}`),u.permissions.paths?.write?.length&&v.push(`**Writable paths:** ${u.permissions.paths.write.join(", ")}`),u.permissions.tools?.deny?.length&&v.push(`**Denied tools:** ${u.permissions.tools.deny.join(", ")}`),u.permissions.dangerous_actions?.length&&v.push(`**Requires approval for:** ${u.permissions.dangerous_actions.join(", ")}`),S+=`
|
|
482
482
|
`+v.join(`
|
|
483
|
-
`);}S.trim()&&(y=S);}}catch{}let p=oe({agent:s,task:c,symbols:i,handoffContext:k,previousAgent:g,profileEnrichment:y,nickname:r}),f={agent:t,model:p.model,prompt:p.prompt,attribution:p.attribution,taskToolParams:{description:p.taskDescription,prompt:p.prompt,subagent_type:p.subagentType,model:p.model},focusAreas:p.focusAreas,usage:"Use the Task tool with the taskToolParams to spawn this agent. Present the response with the attribution prefix."},A=JSON.stringify(f,null,2);return O(A.length,"paradigm_agent_prompt"),{handled:true,text:A}}function ie(a,e){let t=new Set(a),c=[];for(let k of a){let g=e[k];if(g?.handoff_to)for(let n of g.handoff_to)t.has(n)&&c.push({from:k,to:n});}return c}function fe(a,e){let t=ie(a,e);if(t.length===0)return null;let c=new Set,k=new Set(t.map(r=>`${r.from}->${r.to}`));for(let r of t)if(k.has(`${r.to}->${r.from}`)){let p=[r.from,r.to].sort().join(",");c.add(p);}let g=new Map;for(let r of c){let[p,f]=r.split(","),A=g.get(p)||p,R=g.get(f)||f,b=A<R?A:R;for(let[O,C]of g)(C===A||C===R)&&g.set(O,b);g.set(p,b),g.set(f,b);}for(let r of a)g.has(r)||g.set(r,r);let n=[...new Set(g.values())],d=new Map,o=new Map;for(let r of n)d.set(r,0),o.set(r,new Set);for(let r of t){let p=g.get(r.from),f=g.get(r.to);p!==f&&(o.get(p).has(f)||(o.get(p).add(f),d.set(f,(d.get(f)||0)+1)));}let s=new Map,i=[];for(let r of n)(d.get(r)||0)===0&&(i.push(r),s.set(r,0));for(;i.length>0;){let r=i.shift(),p=s.get(r)||0;for(let f of o.get(r)||[]){let A=(d.get(f)||1)-1;d.set(f,A);let R=p+1;s.set(f,Math.max(s.get(f)||0,R)),A===0&&i.push(f);}}if(s.size<n.length)return null;let y=new Map;for(let r of a){let p=g.get(r);y.set(r,s.get(p)||0);}return y}function ye(a,e,t,c,k,g){let n=H(a),d=a.toLowerCase(),o=[],s=[];if(t&&t.length>0)for(let l=0;l<t.length;l++){let w=t[l];e[w]&&s.push({name:w,task:`${w==="architect"?"Design":w==="builder"?"Implement":w==="tester"?"Test":"Process"}: ${a}`,dependsOn:l>0?[t[l-1]]:[],required:true,stage:l});}else if(c&&c.type!=="feature"&&c.type!=="unknown"){let l=c.recommendedAgents.length>0?c.recommendedAgents:["architect"],w={architect:Q(c.type)?"Analyze":"Design",security:Q(c.type)?"Assess security of":"Review security of",builder:"Implement",tester:"Test",reviewer:"Review"},T=0,_=null;for(let S of l){if(!e[S])continue;let v=_?[_]:[],
|
|
483
|
+
`);}S.trim()&&(y=S);}}catch{}let p=oe({agent:s,task:c,symbols:i,handoffContext:k,previousAgent:g,profileEnrichment:y,nickname:r}),f={agent:t,model:p.model,prompt:p.prompt,attribution:p.attribution,taskToolParams:{description:p.taskDescription,prompt:p.prompt,subagent_type:p.subagentType,model:p.model},focusAreas:p.focusAreas,usage:"Use the Task tool with the taskToolParams to spawn this agent. Present the response with the attribution prefix."},A=JSON.stringify(f,null,2);return O(A.length,"paradigm_agent_prompt"),{handled:true,text:A}}function ie(a,e){let t=new Set(a),c=[];for(let k of a){let g=e[k];if(g?.handoff_to)for(let n of g.handoff_to)t.has(n)&&c.push({from:k,to:n});}return c}function fe(a,e){let t=ie(a,e);if(t.length===0)return null;let c=new Set,k=new Set(t.map(r=>`${r.from}->${r.to}`));for(let r of t)if(k.has(`${r.to}->${r.from}`)){let p=[r.from,r.to].sort().join(",");c.add(p);}let g=new Map;for(let r of c){let[p,f]=r.split(","),A=g.get(p)||p,R=g.get(f)||f,b=A<R?A:R;for(let[O,C]of g)(C===A||C===R)&&g.set(O,b);g.set(p,b),g.set(f,b);}for(let r of a)g.has(r)||g.set(r,r);let n=[...new Set(g.values())],d=new Map,o=new Map;for(let r of n)d.set(r,0),o.set(r,new Set);for(let r of t){let p=g.get(r.from),f=g.get(r.to);p!==f&&(o.get(p).has(f)||(o.get(p).add(f),d.set(f,(d.get(f)||0)+1)));}let s=new Map,i=[];for(let r of n)(d.get(r)||0)===0&&(i.push(r),s.set(r,0));for(;i.length>0;){let r=i.shift(),p=s.get(r)||0;for(let f of o.get(r)||[]){let A=(d.get(f)||1)-1;d.set(f,A);let R=p+1;s.set(f,Math.max(s.get(f)||0,R)),A===0&&i.push(f);}}if(s.size<n.length)return null;let y=new Map;for(let r of a){let p=g.get(r);y.set(r,s.get(p)||0);}return y}function ye(a,e,t,c,k,g){let n=H(a),d=a.toLowerCase(),o=[],s=[];if(t&&t.length>0)for(let l=0;l<t.length;l++){let w=t[l];e[w]&&s.push({name:w,task:`${w==="architect"?"Design":w==="builder"?"Implement":w==="tester"?"Test":"Process"}: ${a}`,dependsOn:l>0?[t[l-1]]:[],required:true,stage:l});}else if(c&&c.type!=="feature"&&c.type!=="unknown"){let l=c.recommendedAgents.length>0?c.recommendedAgents:["architect"],w={architect:Q(c.type)?"Analyze":"Design",security:Q(c.type)?"Assess security of":"Review security of",builder:"Implement",tester:"Test",reviewer:"Review"},T=0,_=null;for(let S of l){if(!e[S])continue;let v=_?[_]:[],N=w[S]||"Process",x=S==="architect"||S==="builder";s.push({name:S,task:`${N}: ${a}`,required:x,stage:T,dependsOn:v}),_=S,T++;}}else {let l=d.includes("design")||d.includes("architect")||d.includes("plan")||d.includes("spec"),w=d.includes("auth")||d.includes("security")||d.includes("gate")||n.some(x=>x.startsWith("^")),T=d.includes("build")||d.includes("implement")||d.includes("create")||d.includes("add")||d.includes("fix"),_=d.includes("review")||d.includes("check"),S=d.includes("test")||d.includes("verify")||d.includes("validate");if(l&&e.architect&&s.push({name:"architect",task:`Design and specify: ${a}`,dependsOn:[],required:true,stage:0}),w&&e.security&&s.push({name:"security",task:`Review security aspects of: ${a}`,dependsOn:[],required:false,stage:0}),T&&e.builder){let x=l&&e.architect?["architect"]:[];s.push({name:"builder",task:`Implement: ${a}`,dependsOn:x,required:true,stage:x.length>0?1:0});}let v=s.some(x=>x.name==="builder"),N=v?2:l?1:0;if(_&&e.reviewer&&s.push({name:"reviewer",task:`Review: ${a}`,dependsOn:v?["builder"]:[],required:false,stage:N}),S&&e.tester&&s.push({name:"tester",task:`Test and validate: ${a}`,dependsOn:v?["builder"]:[],required:false,stage:N}),s.length===0){let x=c?.recommendedAgents||["architect","builder","tester"],E={architect:"Design",security:"Review security of",builder:"Implement",tester:"Test",reviewer:"Review"},P=0,j=null;for(let I of x){if(!e[I])continue;let K=j?[j]:[],L=E[I]||"Process",M=I==="architect"||I==="builder";s.push({name:I,task:`${L}: ${a}`,required:M,stage:P,dependsOn:K}),j=I,P++;}}}let i=s.map(l=>l.name),y=fe(i,e);if(y)for(let l of s){l.stage=y.get(l.name)||0;let w=[];for(let T of i){if(T===l.name)continue;e[T]?.handoff_to?.includes(l.name)&&(y.get(T)||0)<l.stage&&w.push(T);}w.length>0&&(l.dependsOn=w);}let r=new Map;for(let l of s){let w=r.get(l.stage)||[];w.push(l),r.set(l.stage,w);}let p=Array.from(r.keys()).sort((l,w)=>l-w);for(let l of p){let w=r.get(l)||[];o.push({stage:l,agents:w.map(T=>({name:T.name,task:T.task,dependsOn:T.dependsOn,required:T.required})),canRunParallel:w.length>1});}let f=s.some(l=>l.name==="builder"||l.name==="tester"),R=(c?Q(c.type):false)||!f,b=false;if(!R){let l=p.length>0?p[p.length-1]+1:0;o.push({stage:l,agents:[{name:"documentor",task:"Review all changes made by previous agents. Update .purpose files, portal.yaml, and symbol registrations using only paradigm_purpose_* and paradigm_portal_* MCP tools. Run paradigm_reindex when done. Do NOT modify source code.",dependsOn:s.map(w=>w.name),required:true}],canRunParallel:false}),b=true;}let O=ue(g||"."),C=c?.type,h=0,m=0;for(let l of s){let w=pe(O,l.name,C);h+=w.min,m+=w.max;}b&&(h+=2e3,m+=8e3);let u=k?.default_mode||"faceted";return {task:a,mode:u,stages:o,symbols:n,estimatedAgents:s.length+(b?1:0),estimatedTokens:{min:h,max:m}}}function oe(a){let{agent:e,task:t,symbols:c,handoffContext:k,previousAgent:g}=a,n=[];a.profileEnrichment&&(n.push(a.profileEnrichment),n.push("---"),n.push("")),a.captainBrief&&(n.push(a.captainBrief),n.push(""));let d=U[e.name]||e.description||e.role||U.builder;if(n.push(d),n.push(""),n.push("---"),n.push(""),n.push("## Your Task"),n.push(""),n.push(t),n.push(""),c.length>0){n.push("## Symbols in Scope"),n.push("");for(let y of c){let r=be(y);n.push(`- \`${y}\` (${r})`);}n.push("");}k&&(n.push("## Context from Previous Agent"),g&&n.push(`*Handed off from ${g}:*`),n.push(""),n.push(k),n.push("")),(e.focus?.reads||e.focus?.writes)&&(n.push("## Focus Areas"),n.push(""),n.push(`**Read from:** ${e.focus?.reads?.join(", ")||"**/*"}`),n.push(`**Write to:** ${e.focus?.writes?.join(", ")||"**/*"}`),n.push("")),n.push(`## Output Format
|
|
484
484
|
|
|
485
485
|
When you complete your task, end with a structured summary block:
|
|
486
486
|
|
|
@@ -499,6 +499,6 @@ handoff_context: |
|
|
|
499
499
|
\`\`\`
|
|
500
500
|
|
|
501
501
|
This structured output helps track progress and pass context between agents.`);let o=n.join(`
|
|
502
|
-
`),s=e.defaultModel||z[B[e.name]||"tier-2"]||"sonnet",i=a.nickname?`[${a.nickname} (${e.name})]`:`[${e.name}]`;return {agent:e.name,model:s,prompt:o,taskDescription:`${e.name}: ${t.slice(0,50)}${t.length>50?"...":""}`,subagentType:"general-purpose",attribution:i,focusAreas:e.focus||{reads:["**/*"],writes:["**/*"]}}}function H(a){let e=a.match(le)||[];return [...new Set(e)]}function be(a){let e=a.charAt(0);return {"@":"feature","#":"component",$:"flow","%":"state","^":"gate","!":"signal","?":"idea","&":"integration","~":"deprecated"}[e]||"unknown"}var we=["should","what","how","why","recommend","analyze","compare","evaluate","assess","review","explain","describe","investigate","which","best practice","trade-off","pros and cons"],ke=["document","write docs","readme",".purpose","purpose file","jsdoc","tsdoc","comments","docstring","api docs"],ve=["bug","fix","broken","not working","issue","error","crash","fails","failing","wrong","incorrect","regression","patch"],Se=["rename","refactor","migrate","restructure","move","reorganize","clean up","cleanup","consolidate","extract","inline","simplify"],Ae=["auth","permission","admin","delete","purge","password","credential","token","secret","key","encrypt","decrypt","ownership","transfer","privilege","escalation","impersonation","takeover","rbac","acl","role","guard","middleware","session","cookie","csrf","xss","injection","sanitize"],_e=["audit","self-audit","inspect","examine","survey","inventory","find issues","identify problems","identify gaps","gap analysis","health check","sanity check","post-mortem","postmortem"],xe=["design","architect","architecture","spec","specify","specification","blueprint","plan","propose","proposal","rfc","schema design","api design","data model"],Re=["research","investigate","explore","study","discover","spike","prototype","feasibility","survey the","literature","prior art","options for","approaches to"],Te=new Set(["analysis","audit","design","research","documentation"]),Pe=[{pattern:/^(please\s+)?(audit|self-audit)\b/,family:"audit"},{pattern:/^(please\s+)?(analy[sz]e|assess|evaluate|examine|inspect|review)\b/,family:"analysis"},{pattern:/^(please\s+)?(design|architect|spec|specify|plan|propose)\b/,family:"design"},{pattern:/^(please\s+)?(research|investigate|explore|study)\b/,family:"research"},{pattern:/^(please\s+)?(document|write\s+docs)\b/,family:"documentation"}],
|
|
502
|
+
`),s=e.defaultModel||z[B[e.name]||"tier-2"]||"sonnet",i=a.nickname?`[${a.nickname} (${e.name})]`:`[${e.name}]`;return {agent:e.name,model:s,prompt:o,taskDescription:`${e.name}: ${t.slice(0,50)}${t.length>50?"...":""}`,subagentType:"general-purpose",attribution:i,focusAreas:e.focus||{reads:["**/*"],writes:["**/*"]}}}function H(a){let e=a.match(le)||[];return [...new Set(e)]}function be(a){let e=a.charAt(0);return {"@":"feature","#":"component",$:"flow","%":"state","^":"gate","!":"signal","?":"idea","&":"integration","~":"deprecated"}[e]||"unknown"}var we=["should","what","how","why","recommend","analyze","compare","evaluate","assess","review","explain","describe","investigate","which","best practice","trade-off","pros and cons"],ke=["document","write docs","readme",".purpose","purpose file","jsdoc","tsdoc","comments","docstring","api docs"],ve=["bug","fix","broken","not working","issue","error","crash","fails","failing","wrong","incorrect","regression","patch"],Se=["rename","refactor","migrate","restructure","move","reorganize","clean up","cleanup","consolidate","extract","inline","simplify"],Ae=["auth","permission","admin","delete","purge","password","credential","token","secret","key","encrypt","decrypt","ownership","transfer","privilege","escalation","impersonation","takeover","rbac","acl","role","guard","middleware","session","cookie","csrf","xss","injection","sanitize"],_e=["audit","self-audit","inspect","examine","survey","inventory","find issues","identify problems","identify gaps","gap analysis","health check","sanity check","post-mortem","postmortem"],xe=["design","architect","architecture","spec","specify","specification","blueprint","plan","propose","proposal","rfc","schema design","api design","data model"],Re=["research","investigate","explore","study","discover","spike","prototype","feasibility","survey the","literature","prior art","options for","approaches to"],Te=new Set(["analysis","audit","design","research","documentation"]),Pe=[{pattern:/^(please\s+)?(audit|self-audit)\b/,family:"audit"},{pattern:/^(please\s+)?(analy[sz]e|assess|evaluate|examine|inspect|review)\b/,family:"analysis"},{pattern:/^(please\s+)?(design|architect|spec|specify|plan|propose)\b/,family:"design"},{pattern:/^(please\s+)?(research|investigate|explore|study)\b/,family:"research"},{pattern:/^(please\s+)?(document|write\s+docs)\b/,family:"documentation"}],Ee={audit:1.3,analysis:1.1,design:1.2,research:1.2,documentation:1.1,bugfix:1,refactor:1};function De(a){let e=a.toLowerCase(),t=H(a),c=m=>m.filter(u=>e.includes(u.toLowerCase())),k={audit:c(_e),analysis:c(we),design:c(xe),research:c(Re),documentation:c(ke),bugfix:c(ve),refactor:c(Se)},g=c(Ae),n={};for(let[m,u]of Object.entries(k))n[m]=u.length*(Ee[m]??1);let d;for(let{pattern:m,family:u}of Pe)if(m.test(e)){d=u,n[u]=(n[u]??0)+5;break}let o=Object.entries(n).filter(([,m])=>m>0).sort((m,u)=>u[1]-m[1]),s,i,y=0,r=0;o.length===0?s="feature":(s=o[0][0],y=o[0][1],i=o[1]?.[0],r=o.reduce((m,[,u])=>m+u,0));let p=r>0?y/r:.4;d&&(p=Math.max(p,.7)),p=Math.round(p*100)/100;let f=k[s]||[],A="medium",R=a.split(/\s+/).length;t.length>=5||R>=100?A="high":t.length<=1&&R<30&&(A="low");let b=g.length>0||t.some(m=>m.startsWith("^")),O={audit:["architect"],analysis:["architect"],design:["architect"],research:["architect"],documentation:["architect"],bugfix:["security","builder"],refactor:["architect","builder"],feature:["architect","security","builder","tester"]},C={audit:{min:.3,max:.5},analysis:{min:.3,max:.5},design:{min:.4,max:.7},research:{min:.3,max:.6},documentation:{min:.25,max:.45},bugfix:{min:.5,max:.8},refactor:{min:.6,max:.85},feature:{min:.8,max:1.2}},h=`classified ${s} (${p.toFixed(2)})`+(i?`; alt ${i}`:"")+"; override with agents:[...] if misrouted";return {type:s,confidence:p,...i?{alternativeType:i}:{},overrideHint:h,complexity:A,recommendedAgents:O[s]||["architect","builder"],securityRequired:b,costMultiplier:C[s]||{min:.8,max:1},matchedKeywords:f,symbols:t}}function Q(a){return Te.has(a)}var ee={opus:{input:15,output:75},sonnet:{input:3,output:15},haiku:{input:.25,output:1.25}},te={architect:{input:8e3,output:4e3},security:{input:6e3,output:3e3},reviewer:{input:5e3,output:2e3},builder:{input:15e3,output:1e4},tester:{input:8e3,output:5e3}};function Oe(a,e){let t=[],c=0,k=e.complexity==="high"?1.5:e.complexity==="low"?.6:1;for(let d of a.stages)for(let o of d.agents){let s=te[o.name]||{input:5e3,output:3e3},i=z[B[o.name]||"tier-2"]||"sonnet",y=ee[i],r=Math.round(s.input*k),p=Math.round(s.output*k),f=r+p,A=r/1e6*y.input+p/1e6*y.output;t.push({name:o.name,model:i,estimatedTokens:f,estimatedCost:Math.round(A*1e4)/1e4}),c+=A;}let g=0;for(let[d,o]of Object.entries(te)){let s=z[B[d]||"tier-2"]||"sonnet",i=ee[s];g+=o.input/1e6*i.input+o.output/1e6*i.output;}let n=g>0?c/g:1;return {agents:t,totalEstimatedCost:Math.round(c*1e4)/1e4,comparisonToBaseline:`${n.toFixed(2)}x`}}function Ce(a,e){let t=[],c=a.toLowerCase(),k=H(a);for(let[o,s]of Object.entries(e)){let i=[];for(let y of s.triggers||[]){if(y.type==="keyword"&&y.match)for(let r of y.match)c.includes(r.toLowerCase())&&i.push(`keyword:${r}`);if(y.type==="symbol"&&y.match)for(let r of y.match){let p=k.filter(f=>r.endsWith("*")?f.startsWith(r.slice(0,-1)):f===r);for(let f of p)i.push(`symbol:${f}`);}}if(i.length>0){let y=i.filter(b=>b.startsWith("keyword:")).length,r=i.filter(b=>b.startsWith("symbol:")).length,p=y>0&&r>0,f=i.length>=3||p?"high":i.length>=2?"medium":"low",A=s.role.split(`
|
|
503
503
|
`)[0].trim(),R=A.length>50?A.slice(0,47)+"...":A;t.push({name:o,reason:R,confidence:f,triggers_matched:i});}}let g=new Set(t.map(o=>o.name)),n=[];for(let o of t){let s=e[o.name];if(s?.handoff_to)for(let i of s.handoff_to){if(g.has(i)||!e[i])continue;let y=e[i],r=[];for(let p of y.triggers||[]){if(p.type==="keyword"&&p.match)for(let f of p.match)c.includes(f.toLowerCase())&&r.push(`keyword:${f}`);if(p.type==="symbol"&&p.match)for(let f of p.match){let A=k.filter(R=>f.endsWith("*")?R.startsWith(f.slice(0,-1)):R===f);for(let R of A)r.push(`symbol:${R}`);}}if(r.length>0){g.add(i);let p=y.role.split(`
|
|
504
|
-
`)[0].trim(),f=p.length>50?p.slice(0,47)+"...":p;n.push({name:i,reason:f,confidence:r.length>=2?"high":"medium",triggers_matched:[...r,`collaboration:handoff_from:${o.name}`]});}}}t.push(...n);let d={high:3,medium:2,low:1};return t.sort((o,s)=>d[s.confidence]-d[o.confidence])}function re(a){let e=
|
|
504
|
+
`)[0].trim(),f=p.length>50?p.slice(0,47)+"...":p;n.push({name:i,reason:f,confidence:r.length>=2?"high":"medium",triggers_matched:[...r,`collaboration:handoff_from:${o.name}`]});}}}t.push(...n);let d={high:3,medium:2,low:1};return t.sort((o,s)=>d[s.confidence]-d[o.confidence])}function re(a){let e=Y.join(a,".paradigm","agents.yaml");if(!D.existsSync(e))return null;try{let t=D.readFileSync(e,"utf-8");return G.load(t)}catch{return null}}async function Ne(a$1,e,t,c){let k=new Map,g;try{let{createTask:n,updateTask:d}=await import('./task-loader-IO4UVFUD.js');g=await n(a$1,{blurb:t,priority:"medium",tags:["orchestration","epic"],claimant:{kind:"archetype",ref:"orchestrator"},external_ref:{provider:"orchestration",ref:e}});try{await d(a$1,g,{status:"in-progress"});}catch(o){a.flow("$dag-emission").warn("Epic promote to in-progress failed",{orchestrationId:e,epicTaskId:g,error:o instanceof Error?o.message:String(o)});}for(let o of c.stages)for(let s of o.agents)try{let i=(s.dependsOn||[]).map(r=>k.get(r)).filter(r=>typeof r=="string"),y=await n(a$1,{blurb:s.task,priority:"medium",tags:["orchestration"],claimant:{kind:"archetype",ref:s.name},parentTaskId:g,stage:o.stage,...i.length>0?{dependsOn:i}:{},external_ref:{provider:"orchestration",ref:e}});k.set(s.name,y);}catch(i){a.flow("$dag-emission").warn("Stage-agent task emission failed",{orchestrationId:e,agent:s.name,stage:o.stage,error:i instanceof Error?i.message:String(i)});}a.flow("$dag-emission").info("Emitted orchestration task DAG",{orchestrationId:e,epicTaskId:g,stageAgents:k.size});}catch(n){a.flow("$dag-emission").warn("Task DAG emission failed; orchestration continues",{orchestrationId:e,error:n instanceof Error?n.message:String(n)});}return {epicTaskId:g,agentTaskIds:k}}function Ie(a,e,t,c){let k=Y.join(a,".paradigm","orchestrations");D.existsSync(k)||D.mkdirSync(k,{recursive:true});let g=Y.join(k,`${e}.yaml`),n={id:e,task:t,created:new Date().toISOString(),status:"pending",mode:c.mode,symbols:c.symbols,estimatedAgents:c.estimatedAgents,estimatedTokens:c.estimatedTokens,stages:c.stages};try{D.writeFileSync(g,G.dump(n));}catch{}}function Me(a){let e=a?.filePlan;if(!(!e||e.length===0))return [{group:"all",subPhase:0,files:e.map(t=>({path:t,description:""}))}]}function Le(a){let e=Me(a);if(!e||e.length===0)return {hasFilePlan:false,stages:[{subPhase:0,builders:[{agent:"builder",group:"all",files:[],availableFiles:[]}]}],totalFiles:0,totalBuilders:1};let t=new Map;for(let o of e){let s=t.get(o.subPhase)||[];s.push(o),t.set(o.subPhase,s);}let c=[],k=[...t.keys()].sort((o,s)=>o-s),g=[],n=0,d=0;for(let o of k){let s=t.get(o),i=[];for(let y=0;y<s.length;y++){let r=s[y];d+=r.files.length,n++,i.push({agent:`builder-${o}-${y}`,group:r.group,files:r.files,availableFiles:[...g]});}c.push({subPhase:o,builders:i});for(let y of s)for(let r of y.files)g.push(r.path);}return {hasFilePlan:true,stages:c,totalFiles:d,totalBuilders:n}}export{ue as a,We as b,Fe as c,De as d,Ce as e,re as f,Ne as g,Le as h};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a,b}from'./chunk-4TXOVRWD.js';import {b as b$1}from'./chunk-VCKKJDLP.js';import {m}from'./chunk-
|
|
2
|
+
import {a,b}from'./chunk-4TXOVRWD.js';import {b as b$1}from'./chunk-VCKKJDLP.js';import {m}from'./chunk-D6BSCELB.js';import*as u from'fs';import*as p from'path';import*as $ from'js-yaml';import g from'chalk';import q from'ora';var _={"@":{category:"features",prefix:"@"},"#":{category:"components",prefix:"#"},"^":{category:"gates",prefix:"^"},$:{category:"flows",prefix:"$"},"&":{category:"integrations",prefix:"&"},"!":{category:"signals",prefix:"!"},"%":{category:"state",prefix:"%"}},N={features:["src/features/","features/","app/","src/app/","src/modules/","modules/"],components:["src/components/","components/","src/lib/","lib/","src/ui/","ui/"],gates:["middleware/","src/middleware/","auth/","src/auth/","guards/","src/guards/"],flows:["flows/","src/flows/","workflows/","src/workflows/","sagas/","src/sagas/"],integrations:["integrations/","src/integrations/","external/","src/external/","vendors/"],signals:["events/","src/events/","handlers/","src/handlers/"],state:["stores/","src/stores/","state/","src/state/","reducers/","src/reducers/"]},z={config:[".paradigm/config.yaml","package.json","tsconfig.json",".env.example"],entry:["src/index.ts","src/index.tsx","src/main.ts","src/main.tsx","index.ts","main.ts","src/app.ts","src/app.tsx"],types:["src/types/","types/","src/types.ts","types.ts"]},G={always:["node_modules/","dist/","build/",".git/",".next/",".nuxt/",".cache/","*.lock","*.log"],unless_testing:["**/*.test.ts","**/*.test.tsx","**/*.spec.ts","**/*.spec.tsx","__tests__/","test/","tests/"],unless_docs:["docs/","*.md","README*","CHANGELOG*"]};async function A(o,t,n={}){let r=n.quiet?null:q();r?.start("Generating navigator.yaml...");let s=M(o),e=L(o),c=H(o),i=U(t.symbols,t.purposeFiles),f={version:"1.0",generated:new Date().toISOString(),structure:s,key_files:e,skip_patterns:c,symbols:i},a=p.join(o,".paradigm"),l=p.join(a,"navigator.yaml");u.existsSync(a)||u.mkdirSync(a,{recursive:true}),u.writeFileSync(l,$.dump(f,{indent:2,lineWidth:120,noRefs:true,sortKeys:false}),"utf8"),r?.succeed(g.green("Navigator generated")),n.quiet||(console.log(g.gray(` Output: ${l}`)),console.log(g.gray(` Structure categories: ${Object.keys(s).length}`)),console.log(g.gray(` Symbol mappings: ${Object.keys(i).length}`)),console.log());}function M(o){let t={};for(let[n,r]of Object.entries(N)){let s=r.filter(e=>{let c=p.join(o,e);return u.existsSync(c)});if(s.length>0){let e=Object.values(_).find(c=>c.category===n);t[n]={paths:s,symbol:e?.prefix||"@"};}}return t}function L(o){let t={};for(let[n,r]of Object.entries(z)){let s=r.filter(e=>{let c=p.join(o,e);return u.existsSync(c)});s.length>0&&(t[n]=s);}return t.config||(t.config=[]),t.entry||(t.entry=[]),t.types||(t.types=[]),t}function H(o){let t={...G},n=p.join(o,".gitignore");if(u.existsSync(n))try{let s=u.readFileSync(n,"utf8").split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).filter(e=>e.endsWith("/")||e.includes("*")||["node_modules","dist","build",".cache"].some(c=>e.includes(c))).slice(0,20);for(let e of s)t.always.includes(e)||t.always.push(e);}catch{}return t}function U(o,t,n){let r={},s=new Map;for(let e of t){let c=p.dirname(e);s.set(e,c);}for(let e of o){let i=`${W(e.type)}${e.id}`;if(e.path)r[i]=e.path;else if(e.directory)r[i]=e.directory;else {let f=t.find(a=>{let l=p.dirname(a),y=e.id.toLowerCase();return l.toLowerCase().includes(y)});f&&(r[i]=p.dirname(f)+"/");}}return r}function W(o){switch(o){case "feature":return "@";case "component":return "#";case "gate":return "^";case "flow":return "$";case "integration":return "&";case "signal":return "!";case "state":return "%";case "idea":return "?";case "deprecated":return "~";default:return "@"}}function P(o){return $.load(o)}async function ce(o,t){let n=o?p.resolve(o):process.cwd(),r=p.basename(n),s=q(),e=p.join(n,".paradigm"),c=u.existsSync(e)&&u.statSync(e).isFile(),i;t.output?i=p.resolve(t.output):c?i=p.join(n,".paradigm-scan-index.json"):(i=p.join(n,".paradigm","scan-index.json"),u.existsSync(p.dirname(i))||u.mkdirSync(p.dirname(i),{recursive:true})),t.quiet||console.log(g.blue(`
|
|
4
4
|
\u{1F52D} Generating Paradigm Scan Index
|
|
5
5
|
`));let f,a$1,l,y=[p.join(n,".paradigm"),p.join(n,".paradigm","config.yaml")];for(let h of y)if(u.existsSync(h)&&u.statSync(h).isFile())try{let m=u.readFileSync(h,"utf8"),F=P(m);f=F.scan,a$1=F.graph,l=F.context?.tiers;break}catch{}s.start("Aggregating symbols from purpose and portal files...");let d;try{d=await m(n);}catch(h){s.fail(g.red("Failed to aggregate symbols")),console.error(g.gray(h.message)),process.exit(1);}if(s.succeed(`Found ${d.symbols.length} symbols`),!t.quiet){let h={components:d.symbols.filter(m=>m.type==="component").length,flows:d.symbols.filter(m=>m.type==="flow").length,gates:d.symbols.filter(m=>m.type==="gate").length,signals:d.symbols.filter(m=>m.type==="signal").length,aspects:d.symbols.filter(m=>m.type==="aspect").length};console.log(g.gray(" Breakdown:"));for(let[m,S]of Object.entries(h))S>0&&console.log(g.gray(` ${m}: ${S}`));console.log();}s.start("Generating scan index...");let b$2=a({symbols:d.symbols,purposeFiles:d.purposeFiles,portalFiles:d.portalFiles},{projectName:r,visualTagMappings:f?.visualTagMappings,screenDefinitions:f?.screens});K(b$2,{hot:l?.["hot-threshold"],warm:l?.["warm-threshold"]});try{u.writeFileSync(i,b(b$2),"utf8"),s.succeed(g.green("Scan index generated"));}catch(h){s.fail(g.red("Failed to write scan index")),console.error(g.gray(h.message)),process.exit(1);}await A(n,d,{quiet:t.quiet});let j=await Y(n,d.purposeFiles,{quiet:t.quiet});if(j&&Object.keys(j.flows).length>0){let h=p.join(n,".paradigm","flow-index.json");u.writeFileSync(h,JSON.stringify(j,null,2),"utf8"),t.quiet||s.succeed(g.green(`Flow index generated (${Object.keys(j.flows).length} flows)`));}if(a$1?.["auto-generate"]!==false)try{let h=b$1(n),m=p.join(n,".paradigm","graphs");u.existsSync(m)||u.mkdirSync(m,{recursive:!0});let S=p.join(m,"auto.graph.json");u.writeFileSync(S,JSON.stringify(h,null,2),"utf8"),t.quiet||s.succeed(g.green(`Symbol graph updated (${h.nodes.length} nodes)`));}catch{t.quiet||s.warn(g.yellow("Could not auto-generate symbol graph"));}return t.quiet||(console.log(g.gray(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {s,r as r$1,u,i,k,c as c$1}from'./chunk-M7JHVVDW.js';import*as c from'fs';import*as r from'path';import*as x from'js-yaml';var f=".paradigm/university",j="pack.yaml";function B(n){let e=l(n);if(!e||!Array.isArray(e.sections))return [];let a=[];for(let t of e.sections)t&&typeof t.id=="string"&&t.id.length>0&&a.push({id:t.id,name:typeof t.name=="string"?t.name:void 0});return a}function l(n){let e=r.join(n,j);if(!c.existsSync(e))return null;try{let a=c.readFileSync(e,"utf8");return x.load(a)??null}catch{return null}}function b(n){let e=[],a=r.join(n,"node_modules","@a-company","university"),t=l(a);t&&t.id&&t.tenant_kind&&e.push({id:t.id,name:t.name,tenantKind:t.tenant_kind,packRoot:a,disciplines:t.disciplines,entryCount:s(a)});let i=r.join(n,f);if(c.existsSync(i)){let s$1=l(i),o=s$1?.id??r.basename(n),P=s$1?.tenant_kind??"project";e.push({id:o,name:s$1?.name,tenantKind:P,packRoot:i,disciplines:s$1?.disciplines,entryCount:s(i)});try{let R=c.readdirSync(i,{withFileTypes:!0});for(let u of R){if(!u.isDirectory()||u.name.startsWith("."))continue;let m=r.join(i,u.name),d=l(m);!d||!d.id||e.push({id:d.id,name:d.name,tenantKind:d.tenant_kind??"project",packRoot:m,disciplines:d.disciplines,entryCount:s(m)});}}catch{}}return e}function D(n,e){let a=b(n),t;if(e.pack){let i=a.find(s=>s.id===e.pack);if(i)t={packId:i.id,packRoot:i.packRoot,tenantKind:i.tenantKind,hasManifest:true};else {let s=r.join(n,f);t={packId:e.pack,packRoot:s,hasManifest:false};}}else if(e.project){let i=a.find(o=>o.tenantKind==="project"&&!o.disciplines),s=r.join(n,f);i?t={packId:i.id,packRoot:i.packRoot,tenantKind:i.tenantKind,hasManifest:true}:t={packId:r.basename(n),packRoot:s,hasManifest:false};}else {let i=a.find(s=>s.tenantKind==="project");if(i)t={packId:i.id,packRoot:i.packRoot,tenantKind:i.tenantKind,hasManifest:true};else {let s=a.find(o=>o.tenantKind==="first-party");if(s)t={packId:s.id,packRoot:s.packRoot,tenantKind:s.tenantKind,hasManifest:true};else {let o=r.join(n,f);t={packId:r.basename(n),packRoot:o,hasManifest:false};}}}if(e.discipline){let i=r.join(t.packRoot,e.discipline),s=l(i);s&&s.id?(t.subPackRoot=i,t.subPackId=s.id):c.existsSync(i)&&(t.subPackRoot=i,t.subPackId=`${t.packId}-${e.discipline}`);}return t}function w(n){return !!(n.pack||n.project||n.discipline)}function N(n){let e=r$1(n);return e&&s(n)>0?e:null}function F(n){return u(n,n)}function E(n,e,a,t){let i$1=I(e,t);return i(n,i$1,a,{packRoot:t,stampPackId:false,resolveDefaultPack:false})}function T(n,e,a){let t=I(e,a);return k(n,t,{packRoot:a,stampPackId:false,resolveDefaultPack:false})}function I(n,e){if(!e)return n;let a=c$1(e);return a&&!n.pack_id?{...n,pack_id:a}:n}export{B as a,b,D as c,w as d,N as e,F as f,E as g,T as h};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a,
|
|
3
|
-
`).filter(Boolean);}catch{}let l;try{l=execSync("git status --porcelain",{cwd:s,encoding:"utf8",timeout:5e3}).trim()==="";}catch{}let c=m.join(s,"portal.yaml"),f=!1;if(u.existsSync(c))try{let t=u.readFileSync(c,"utf8"),e=w.load(t);f=e?.routes!=null&&Object.keys(e.routes).length>0;}catch{}let i=
|
|
4
|
-
`),"utf8");}else a$1==="on-stop"&&u.existsSync(h)&&u.unlinkSync(h);}catch{}return {trigger:a$1,evaluation:{total:o.summary.total,followed:o.summary.followed,skipped:o.summary.skipped,partial:o.summary.partial,blockingViolations:o.summary.blockingViolations,blocksCompletion:o.blocksCompletion},habits:o.evaluations.map(t=>({id:t.habit.id,name:t.habit.name,category:t.habit.category,severity:t.habit.severity,result:t.result,reason:t.reason,evidence:t.evidence})),recorded:g}}catch{return null}}async function P(s,a){let r=m.join(s,".paradigm","aspect-graph.db");if(!u.existsSync(r))return {driftedCount:0,healedCount:0,cleanCount:0,missingCount:0,details:[]};try{let{driftCheckCommand:d}=await import('./drift-ILZE5BFJ.js'),l="",c=console.log;console.log=f=>{l=f;};try{await d({json:!0,autoHeal:a});}finally{console.log=c;}return l?JSON.parse(l):null}catch{return null}}async function B(s){if(!u.existsSync(m.join(s,"portal.yaml")))return null;try{let{checkPortalCompliance:a}=await import('./portal-compliance-JONQ4SOP.js'),r=await a(s);return {status:r.status,declaredButUnusedCount:r.declaredButUnused.length,usedButUndeclaredCount:r.usedButUndeclared.length,properlyDeclaredCount:r.properlyDeclared.length,declaredButUnused:r.declaredButUnused,usedButUndeclared:r.usedButUndeclared,properlyDeclared:r.properlyDeclared,portalError:r.portalError,...r.nearMatches&&r.nearMatches.length>0?{suggestions:r.nearMatches.map(d=>({gate:d.gate,didYouMean:d.didYouMean,distance:d.distance}))}:{}}}catch{return null}}async function j(s){try{let{runPostflightLearning:a}=await import('./ambient-
|
|
2
|
+
import {a}from'./chunk-FNYYQNJY.js';import {n as n$1,m as m$1}from'./chunk-WMTES556.js';import'./chunk-5TAVYPOV.js';import*as u from'fs';import*as m from'path';import {execSync}from'child_process';import n from'chalk';import*as w from'js-yaml';function $(s){return s.match(/(?:^|\s)((?:\/|\.\/|[a-zA-Z0-9_-]+\/)[^\s,;:'"]+\.[a-zA-Z]{1,10})\b/)?.[1]}async function R(s,a$1){try{let r=a(s),d=[];try{d=execSync("git diff --name-only HEAD",{cwd:s,encoding:"utf8",timeout:5e3}).trim().split(`
|
|
3
|
+
`).filter(Boolean);}catch{}let l;try{l=execSync("git status --porcelain",{cwd:s,encoding:"utf8",timeout:5e3}).trim()==="";}catch{}let c=m.join(s,"portal.yaml"),f=!1;if(u.existsSync(c))try{let t=u.readFileSync(c,"utf8"),e=w.load(t);f=e?.routes!=null&&Object.keys(e.routes).length>0;}catch{}let i=n$1({toolsCalled:[],filesModified:d,symbolsTouched:[],loreRecorded:!1,hasPortalRoutes:f,taskAddsRoutes:!1,gitClean:l}),o=m$1(r,a$1,i),g=0;if(o.evaluations.length>0)try{let t=m.join(s,".paradigm","sentinel");if(u.existsSync(t)){let{SentinelStorage:e}=await import('./dist-VGFSP3XM.js'),p=new e(t);for(let b of o.evaluations)p.recordPracticeEvent({habitId:b.habit.id,habitCategory:b.habit.category,result:b.result,engineer:"agent",sessionId:`cli-${Date.now().toString(36)}`,symbolsTouched:[],filesModified:d,notes:b.reason}),g++;}}catch{}let h=m.join(s,".paradigm",".habits-blocking");try{if(a$1==="on-stop"&&o.blocksCompletion){let t=o.evaluations.filter(e=>e.result==="skipped"&&e.habit.severity==="block").map(e=>`${e.habit.name}: ${e.reason}`);u.writeFileSync(h,t.join(`
|
|
4
|
+
`),"utf8");}else a$1==="on-stop"&&u.existsSync(h)&&u.unlinkSync(h);}catch{}return {trigger:a$1,evaluation:{total:o.summary.total,followed:o.summary.followed,skipped:o.summary.skipped,partial:o.summary.partial,blockingViolations:o.summary.blockingViolations,blocksCompletion:o.blocksCompletion},habits:o.evaluations.map(t=>({id:t.habit.id,name:t.habit.name,category:t.habit.category,severity:t.habit.severity,result:t.result,reason:t.reason,evidence:t.evidence})),recorded:g}}catch{return null}}async function P(s,a){let r=m.join(s,".paradigm","aspect-graph.db");if(!u.existsSync(r))return {driftedCount:0,healedCount:0,cleanCount:0,missingCount:0,details:[]};try{let{driftCheckCommand:d}=await import('./drift-ILZE5BFJ.js'),l="",c=console.log;console.log=f=>{l=f;};try{await d({json:!0,autoHeal:a});}finally{console.log=c;}return l?JSON.parse(l):null}catch{return null}}async function B(s){if(!u.existsSync(m.join(s,"portal.yaml")))return null;try{let{checkPortalCompliance:a}=await import('./portal-compliance-JONQ4SOP.js'),r=await a(s);return {status:r.status,declaredButUnusedCount:r.declaredButUnused.length,usedButUndeclaredCount:r.usedButUndeclared.length,properlyDeclaredCount:r.properlyDeclared.length,declaredButUnused:r.declaredButUnused,usedButUndeclared:r.usedButUndeclared,properlyDeclared:r.properlyDeclared,portalError:r.portalError,...r.nearMatches&&r.nearMatches.length>0?{suggestions:r.nearMatches.map(d=>({gate:d.gate,didYouMean:d.didYouMean,distance:d.distance}))}:{}}}catch{return null}}async function j(s){try{let{runPostflightLearning:a}=await import('./ambient-VCTUHHIG.js');return await a(s)}catch{return null}}async function A(s){let a=process.cwd(),r=s.trigger||"on-stop",d=s.autoHeal!==false,l=[],c=[],f=await R(a,r),i=await P(a,d),o=await B(a);if(f?.evaluation.blocksCompletion){let t=f.habits.filter(e=>e.result==="skipped"&&e.severity==="block");for(let e of t){let p=`Blocking habit not satisfied: ${e.name} \u2014 ${e.reason}`;l.push(p),c.push({message:p,source:"habits",file:$(e.reason),severity:"blocking"});}}if(i&&i.driftedCount>0){let t=`${i.driftedCount} aspect anchor(s) have drifted (content genuinely changed). Run paradigm_aspect_check to review.`;l.push(t);for(let e of i.details.filter(p=>p.status==="drifted"))c.push({message:`Aspect ~${e.aspectId} drifted at lines ${e.startLine}-${e.endLine}`,source:"drift",file:e.path,severity:"advisory"});c.filter(e=>e.source==="drift").length===0&&c.push({message:t,source:"drift",severity:"advisory"});}if(o&&o.portalError?.kind==="unparseable"){let e=`portal.yaml unparseable: ${o.portalError.errorClass} \u2014 run 'paradigm doctor' for details`;l.push(e),c.push({message:e,source:"portal",file:"portal.yaml",severity:"blocking"});}else if(o&&o.usedButUndeclaredCount>0){let t=o.usedButUndeclared.filter(e=>e!=="__portal_unparseable__");if(t.length>0){let e=`${t.length} gate(s) used in code but not declared in portal.yaml: ${t.join(", ")}`;l.push(e);for(let p of t)c.push({message:`Gate ^${p} used in code but not declared in portal.yaml`,source:"portal",file:"portal.yaml",severity:"blocking"});}}let g=null;s.learn&&(g=await j(a));let h={habits:f,drift:i,portal:o,violations:l,structuredViolations:c,postflight:s.learn?g:void 0};if(s.json)console.log(JSON.stringify(h));else {if(console.log(n.magenta(`
|
|
5
5
|
Paradigm Compliance Check
|
|
6
6
|
`)),f){let{evaluation:t}=f,e=t.blocksCompletion?n.red:n.green;console.log(n.white(" Habits:")),console.log(` ${e(`${t.followed} followed, ${t.skipped} skipped, ${t.partial} partial`)}`),t.blockingViolations>0&&console.log(n.red(` ${t.blockingViolations} blocking violation(s)`)),console.log();}if(i&&(console.log(n.white(" Drift:")),i.healedCount>0&&console.log(n.green(` Auto-healed: ${i.healedCount} shifted anchor(s)`)),i.cleanCount>0&&console.log(n.green(` Clean: ${i.cleanCount} anchor(s)`)),i.driftedCount>0&&console.log(n.red(` Drifted: ${i.driftedCount} anchor(s)`)),i.missingCount>0&&console.log(n.yellow(` Missing: ${i.missingCount} anchor file(s)`)),console.log()),o){console.log(n.white(" Portal:"));let t=o.status==="compliant"?n.green:o.status==="warnings"?n.yellow:n.red;console.log(` Status: ${t(o.status)}`),o.usedButUndeclaredCount>0&&console.log(n.red(` ${o.usedButUndeclaredCount} undeclared gate(s)`)),console.log();}if(g){if(console.log(n.white(" Postflight Learning:")),g.journalsWritten>0){console.log(n.green(` Journals written: ${g.journalsWritten}`));for(let[t,e]of Object.entries(g.journalsByAgent))e>0&&console.log(n.gray(` ${t}: ${e} entries`));}else console.log(n.gray(" No verdicts to learn from"));g.promoted>0&&console.log(n.green(` Promoted to notebooks: ${g.promoted}`)),console.log();}if(l.length>0){console.log(n.red(` ${l.length} violation(s):`));for(let t of l)console.log(n.red(` - ${t}`));}else console.log(n.green(" All checks passed."));console.log();}l.length>0&&(process.exitCode=1);}export{A as complianceCheckCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {m as m$1,o,C,B,r}from'./chunk-
|
|
2
|
+
import {m as m$1,o,C,B,r}from'./chunk-D6BSCELB.js';import'./chunk-K6TLYNRQ.js';import'./chunk-ZJQY5PPP.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as u from'fs';import*as m from'path';import e from'chalk';import F from'ora';function I(t){let o={gates:[],signals:[],components:[],flows:[],aspects:[]};for(let r of t){if(!r||r.length<2)continue;switch(r[0]){case "^":o.gates.push(r);break;case "!":o.signals.push(r);break;case "#":o.components.push(r);break;case "$":o.flows.push(r);break;case "~":o.aspects.push(r);break}}return o}function T(t,o){let r$1={},g={},l=B(t),a=C(t);for(let s of a){let n=I(s.references),i={type:s.type,path:s.filePath,references:s.references,referencedBy:s.referencedBy};s.description&&(i.description=s.description),s.tags&&s.tags.length>0&&(i.tags=s.tags),n.gates.length>0&&(i.gates=n.gates),n.signals.length>0&&(i.signals=n.signals),n.components.length>0&&(i.components=n.components),n.flows.length>0&&(i.flows=n.flows),n.aspects.length>0&&(i.aspects=n.aspects),r$1[s.symbol]=i;}let y=r(t,"flow");for(let s of y){let n=s.data,i=n?.sequence||n?.gates||s.references;g[s.symbol]={description:s.description,sequence:i};}return {version:"1.0",generated:new Date().toISOString(),project:o,stats:{components:l.component,flows:l.flow,gates:l.gate,signals:l.signal,aspects:l.aspect,total:Object.values(l).reduce((s,n)=>s+n,0)},stars:r$1,orbits:g}}async function z(t,o$1={}){let r=process.cwd(),g=t?m.resolve(r,t):r,l=m.basename(g),a$1=o$1.format||"json";o$1.quiet||console.log(e.blue(`
|
|
3
3
|
\u2728 Building Constellation...
|
|
4
4
|
`));let y=F("Aggregating symbols...").start(),s=a.command("constellation").start("Building constellation",{project:l});try{let n=await m$1(g),i=o(n);a.operation("aggregate").debug("Symbols aggregated",{count:C(i).length}),y.text="Building constellation...";let p=T(i,l),$=m.join(g,".paradigm");u.existsSync($)||u.mkdirSync($,{recursive:!0});let h=o$1.output||m.join($,`constellation.${a$1}`),S;if(a$1==="yaml"?S=d(p):S=JSON.stringify(p,null,2),u.writeFileSync(h,S,"utf8"),a.component("constellation-file").success("Constellation written",{path:h,format:a$1}),y.succeed("Constellation built"),s.success("Constellation built",{path:h,stars:Object.keys(p.stars).length}),!o$1.quiet){console.log(e.white(`
|
|
5
5
|
Constellation Stats`)),console.log(e.gray("\u2500".repeat(40)));let f=p.stats,q=[{symbol:"#",name:"Components",count:f.components,color:e.green},{symbol:"$",name:"Flows",count:f.flows,color:e.yellow},{symbol:"^",name:"Gates",count:f.gates,color:e.red},{symbol:"!",name:"Signals",count:f.signals,color:e.cyan},{symbol:"~",name:"Aspects",count:f.aspects,color:e.magenta}];for(let{symbol:c,name:R,count:O,color:E}of q)O>0&&console.log(` ${E(c)} ${R.padEnd(12)} ${e.cyan(O.toString())}`);console.log(e.gray("\u2500".repeat(40))),console.log(` Total stars: ${e.cyan(f.total.toString())}`),console.log(` Total orbits: ${e.cyan(Object.keys(p.orbits).length.toString())}`),console.log(e.gray(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import {f as f$1}from'./chunk-K6TLYNRQ.js';import {e}from'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as v from'fs';import*as l from'path';import o from'chalk';import D from'ora';function Q(t){let a=t.length;return Math.ceil(a/3.5)}function f(t,a){try{let s=v.readFileSync(t,"utf8"),m=Buffer.byteLength(s,"utf8"),C=Q(s),r=l.relative(a,t);return {path:t,relativePath:r,tokens:C,bytes:m}}catch{return null}}function i(t){return t<1e3?t.toString():`${(t/1e3).toFixed(1)}k`}async function L(t,a){let s=t?l.resolve(t):process.cwd(),m=D();a.json||console.log(o.blue(`
|
|
3
3
|
\u{1F4B0} Paradigm Cost Analysis
|
|
4
|
-
`)),m.start("Analyzing context files...");let C=await
|
|
4
|
+
`)),m.start("Analyzing context files...");let C=await f$1(s),r=[];for(let e of C){let n=f(e,s);n&&r.push(n);}let A=await e(s),y=[];for(let e of A){let n=f(e,s);n&&y.push(n);}let R=l.join(s,".paradigm","scan-index.json"),h=f(R,s),I=l.join(s,".cursorrules"),q=l.join(s,".cursor","rules","paradigm.mdc"),g=f(I,s);g||(g=f(q,s)),m.stop();let x=r.reduce((e,n)=>e+n.tokens,0),F=y.reduce((e,n)=>e+n.tokens,0),b=h?.tokens||0,P=g?.tokens||0,w=x+F+b,u=w+P,T=150,k=T*7,c=u>0?Math.round((1-k/u)*100):0,d=[],M=r.filter(e=>e.tokens>500);M.length>0&&d.push(`${M.length} .purpose file(s) exceed 500 tokens. Consider splitting large features.`);let N=l.join(s,".cursor","mcp.json"),$=v.existsSync(N);$||d.push("MCP not configured. Run `paradigm mcp setup` to enable dynamic context (80%+ savings)."),h||d.push("No scan-index.json found. Run `paradigm index` for visual discovery support."),r.length<3&&d.push("Few .purpose files found. Add more context for better AI understanding.");let O={static:{purposeFiles:r,portalFiles:y,scanIndex:h,cursorrules:g,total:u},dynamic:{avgQueryTokens:T,typicalConversation:k},savings:{percentage:Math.max(0,c),description:c>0?`${c}% fewer tokens with MCP vs static context`:"MCP provides on-demand context loading"},recommendations:d};if(a.json){console.log(JSON.stringify(O,null,2));return}if(console.log(o.white("Context Token Analysis")),console.log(o.gray("\u2500".repeat(50))),console.log(o.cyan(`
|
|
5
5
|
Static Context (loaded every conversation):`)),console.log(` .purpose files (${r.length}):`.padEnd(35)+o.yellow(i(x)+" tokens")),console.log(` portal.yaml (${y.length}):`.padEnd(35)+o.yellow(i(F)+" tokens")),h&&console.log(" scan-index.json:".padEnd(35)+o.yellow(i(b)+" tokens")),g&&console.log(" .cursorrules:".padEnd(35)+o.yellow(i(P)+" tokens")),console.log(o.gray("\u2500".repeat(50))),console.log(" Static Total:".padEnd(35)+o.yellow.bold(i(u)+" tokens")),console.log(o.cyan(`
|
|
6
6
|
Dynamic Context (MCP on-demand):`)),console.log(" Avg query response:".padEnd(35)+o.green(i(T)+" tokens")),console.log(" Typical conversation (~7 queries):".padEnd(35)+o.green(i(k)+" tokens")),console.log(o.cyan(`
|
|
7
7
|
Potential Savings:`)),c>0){let e=c>70?o.green:c>40?o.yellow:o.white;console.log(" MCP vs Static:".padEnd(35)+e.bold(`${c}% reduction`));let n=u/1e3*.01,p=k/1e3*.01,j=n-p;j>.001&&console.log(" Est. savings per conversation:".padEnd(35)+o.green(`~$${j.toFixed(4)}`));}if(a.detailed&&r.length>0){console.log(o.cyan(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-NRP2KJ6I.js';import'./chunk-TYWB5IQJ.js';import'./chunk-ASBK55FU.js';import'./chunk-ECLUYHAR.js';import'./chunk-YXLGVOZO.js';import'./chunk-FYDRENK7.js';import'./chunk-3YM5ABNX.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-EKZDFEJW.js';import'./chunk-LPBCQM5Y.js';import'./chunk-D6BSCELB.js';import'./chunk-K6TLYNRQ.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as i from'fs';import*as a from'path';import o from'chalk';async function D(l,f,t){let d=f?a.resolve(f):process.cwd();if(!l){t.json?console.log(JSON.stringify({error:"Orchestration ID required"})):(console.log(o.red(`
|
|
3
3
|
Orchestration ID required.`)),console.log(o.gray(`Usage: paradigm team diff <orchestration-id>
|
|
4
4
|
`)));return}let e=new b(d).getOrchestration(l);if(!e){t.json?console.log(JSON.stringify({error:"Orchestration not found",id:l})):console.log(o.red(`
|
|
5
5
|
Orchestration not found: ${l}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{b as PREFIX_TO_TYPE,a as SYMBOL_PREFIXES,j as addConnection,h as addPremiseNode,m as aggregateFromDirectory,l as aggregateFromPremise,o as buildSymbolIndex,J as checkAspectAnchors,e as createEmptyPremiseFile,k as createSnapshot,n as createSymbolIndex,E as createSymbolString,I as detectAnchorBaseMismatch,v as getAllComponentTypes,C as getAllSymbols,A as getAllTags,G as getAutocompleteSuggestions,w as getChildComponents,u as getComponentsByType,g as getDefaultPremiseContent,y as getReferencesFrom,x as getReferencesTo,p as getSymbol,q as getSymbolById,B as getSymbolCounts,s as getSymbolsBySource,z as getSymbolsByTag,r as getSymbolsByType,F as isValidSymbol,d as parsePremiseContent,c as parsePremiseFile,D as parseSymbol,H as resolveAnchorPath,t as searchSymbols,f as serializePremiseFile,i as updateNodePosition}from'./chunk-
|
|
2
|
+
export{b as PREFIX_TO_TYPE,a as SYMBOL_PREFIXES,j as addConnection,h as addPremiseNode,m as aggregateFromDirectory,l as aggregateFromPremise,o as buildSymbolIndex,J as checkAspectAnchors,e as createEmptyPremiseFile,k as createSnapshot,n as createSymbolIndex,E as createSymbolString,I as detectAnchorBaseMismatch,v as getAllComponentTypes,C as getAllSymbols,A as getAllTags,G as getAutocompleteSuggestions,w as getChildComponents,u as getComponentsByType,g as getDefaultPremiseContent,y as getReferencesFrom,x as getReferencesTo,p as getSymbol,q as getSymbolById,B as getSymbolCounts,s as getSymbolsBySource,z as getSymbolsByTag,r as getSymbolsByType,F as isValidSymbol,d as parsePremiseContent,c as parsePremiseFile,D as parseSymbol,H as resolveAnchorPath,t as searchSymbols,f as serializePremiseFile,i as updateNodePosition}from'./chunk-D6BSCELB.js';import'./chunk-K6TLYNRQ.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {a,d,e,f,g,b}from'./chunk-BFD3GFRK.js';import'./chunk-5TAVYPOV.js';import n from'chalk';import*as t from'fs';import*as o from'path';import {fileURLToPath}from'url';async function C(c){let s=process.cwd(),e=parseInt(c.port||"3850",10),p=c.open!==false;console.log(n.cyan(`
|
|
3
3
|
Starting Paradigm Docs...
|
|
4
|
-
`));try{let{startPlatformServer:i}=await import('./platform-server-
|
|
4
|
+
`));try{let{startPlatformServer:i}=await import('./platform-server-FXF3XFHM.js');await i({projectDir:s,port:e,open:p,sections:["overview","docs"]}),console.log(n.green(` Docs running at ${n.bold(`http://localhost:${e}`)}`)),console.log(n.gray(` Press Ctrl+C to stop
|
|
5
5
|
`)),await new Promise(()=>{});}catch(i){i.code==="EADDRINUSE"?(console.error(n.red(`
|
|
6
6
|
Error: Port ${e} is already in use.`)),console.log(n.gray(` Try: paradigm docs serve --port ${e+1}
|
|
7
7
|
`))):console.error(n.red(`
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a}from'./chunk-NFN5UUJB.js';import {b as b$1,a as a$1}from'./chunk-EK4ZRIFJ.js';import'./chunk-5TAVYPOV.js';import {execFileSync}from'child_process';b$1();function f(t){if(!t)return {labels:[]};switch(t.kind){case "human":return {assignee:t.ref,labels:[]};case "archetype":return {labels:[`paradigm:agent/${t.ref}`]};case "peer":return {labels:[`paradigm:peer/${t.ref}`]};default:return {labels:[]}}}var b="gh";function l(t){let e=t.match(/^([^/\s]+\/[^/#\s]+)#\d+$/);if(e)return e[1];let r=t.match(/github\.com\/([^/]+\/[^/]+)\/issues\/\d+/);if(r)return r[1]}function y(t){let e=t.match(/github\.com\/([^/]+\/[^/]+)\/issues\/(\d+)/);return e?`${e[1]}#${e[2]}`:void 0}var d=class{id="github";repo;run;constructor(e={}){this.repo=e.repo,this.run=e.run??(r=>execFileSync(b,r,{encoding:"utf8",timeout:2e4}));}capabilities(){return {push:true,comment:true,pull:false,close:true}}async isAvailable(){try{return this.run(["auth","status"]),!0}catch{return false}}async push(e){let r=this.resolveRepo(e),i=this.renderBody(e),n=f(e.claimant),o=["issue","create","--title",e.blurb,"--body",i];r&&o.push("--repo",r),n.assignee&&o.push("--assignee","@me");let u=this.run(o).trim(),a=u.split(`
|
|
3
|
+
`).map(c=>c.trim()).find(c=>/github\.com\//.test(c)),p=a?y(a):void 0;if(!p)throw a$1.component("#github-provider").warn("Could not parse issue ref from gh output",{stdout:u}),new Error(`gh issue create did not return a parseable issue URL: ${u||"(empty)"}`);return a$1.component("#github-provider").info("Pushed task to GitHub",{taskId:e.id,ref:p}),{ref:p,url:a}}async comment(e,r){let i=l(e.ref)??this.repo,n=["issue","comment",e.ref,"--body",r];i&&n.push("--repo",i),this.run(n),a$1.component("#github-provider").info("Commented on GitHub issue",{ref:e.ref});}async close(e){let r=l(e.ref)??this.repo,i=["issue","close",e.ref];r&&i.push("--repo",r),this.run(i),a$1.component("#github-provider").info("Closed GitHub issue",{ref:e.ref});}resolveRepo(e){if(e.external_ref?.ref){let r=l(e.external_ref.ref);if(r)return r}return this.repo}renderBody(e){let r=[];return r.push(`Synced from Paradigm task \`${e.id}\`.`),r.push(""),e.claimant&&r.push(`Claimant: \`${e.claimant.kind}:${e.claimant.ref}\``),r.push(`Priority: ${e.priority}`),e.tags.length>0&&r.push(`Tags: ${e.tags.join(", ")}`),r.push(""),r.push("\u2014 Pushed one-way by Paradigm sync (Phase 2a). Edits here do not flow back."),r.join(`
|
|
4
|
+
`)}};a("github",()=>new d);export{d as GithubProvider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a,b,c,
|
|
2
|
+
import {a,b,c}from'./chunk-FNYYQNJY.js';import {n,m}from'./chunk-WMTES556.js';import'./chunk-5TAVYPOV.js';import*as g from'fs';import*as u from'path';import {execSync}from'child_process';import o from'chalk';import*as C from'js-yaml';var $=".paradigm/habits.yaml",G=new Set(["explore-before-implement","ripple-before-modify","check-fragility","wisdom-before-implement","verify-before-done","postflight-compliance","test-new-components","purpose-coverage","record-lore-for-significant","gates-for-routes"]),x=["discovery","verification","testing","documentation","collaboration","security"],E=["preflight","postflight","on-stop","on-commit"],I=["advisory","warn","block"],P=["tool-called","file-exists","file-modified","lore-recorded","symbols-registered","gates-declared","tests-exist","git-clean"];function T(e,t){let r=u.join(e,$),i=F(r,t);if(i)return {source:"project",...i};let n=process.env.HOME||process.env.USERPROFILE||"~",l=u.join(n,".paradigm","habits.yaml"),c=F(l,t);return c?{source:"global",...c}:G.has(t)?{source:"seed",filePath:"",index:-1}:null}function F(e,t){if(!g.existsSync(e))return null;try{let r=g.readFileSync(e,"utf8"),i=C.load(r);if(!i?.habits)return null;let n=i.habits.findIndex(l=>l.id===t);return n===-1?null:{filePath:e,index:n}}catch{return null}}function D(e){let t=g.readFileSync(e,"utf8"),r=C.load(t);return r.habits||(r.habits=[]),r.overrides||(r.overrides={}),r}function w(e,t){g.writeFileSync(e,C.dump(t,{lineWidth:80,noRefs:true}),"utf8");}function L(e){let t=u.join(e,$);if(!g.existsSync(t)){let r=u.dirname(t);g.existsSync(r)||g.mkdirSync(r,{recursive:true}),w(t,{version:"1.0",habits:[],overrides:{}});}return t}async function J(e){let t=process.cwd(),r;try{r=a(t);}catch(s){console.log(o.red("Failed to load habits:"),s.message);return}if(e.trigger&&(r=r.filter(s=>s.trigger===e.trigger)),e.category&&(r=r.filter(s=>s.category===e.category)),e.json){console.log(JSON.stringify(r,null,2));return}let i=r.filter(s=>s.enabled),n=r.filter(s=>!s.enabled);console.log(o.magenta(`
|
|
3
3
|
Habits (${i.length} active, ${n.length} disabled)
|
|
4
4
|
`));let l=["preflight","postflight","on-stop","on-commit"];for(let s of l){let y=r.filter(d=>d.trigger===s);if(y.length!==0){console.log(o.cyan(` ${s}:`));for(let d of y){let a=d.enabled?o.green("ON"):o.gray("OFF"),m=d.severity==="block"?o.red(d.severity):d.severity==="warn"?o.yellow(d.severity):o.gray(d.severity);console.log(` ${a} ${o.white(d.id)} [${m}] - ${d.name}`),console.log(o.gray(` ${d.description}`));}console.log();}}let c=u.join(t,$);g.existsSync(c)?console.log(o.gray(` Config: ${$}`)):console.log(o.gray(" Config: using seed habits only (run 'paradigm habits init' to customize)")),console.log();}async function W(e){let t=process.cwd(),r;try{r=a(t);}catch(c){console.log(o.red("Failed to load habits:"),c.message);return}let i=b(r),n=null;try{let{SentinelStorage:c}=await import('./dist-VGFSP3XM.js'),s=u.join(t,".paradigm","sentinel");if(g.existsSync(s)){let y=new c(s),d=e.period||"30d",a=parseInt(d.replace("d",""),10)||30,m=d==="all"?void 0:new Date(Date.now()-a*24*60*60*1e3).toISOString(),v=y.getComplianceRate({dateFrom:m}),f=y.getPracticeEvents({dateFrom:m,limit:500}),b=new Map;for(let h of f){let p=h.habitCategory,S=b.get(p)||{followed:0,skipped:0,partial:0};S[h.result]++,b.set(p,S);}let j=Array.from(b.entries()).map(([h,p])=>{let S=p.followed+p.skipped+p.partial,O=S>0?Math.round((p.followed+p.partial*.5)/S*100):100;return {category:h,rate:O,total:S}}).sort((h,p)=>h.rate-p.rate);n={total:v.total,followed:v.followed,skipped:v.skipped,partial:v.partial,rate:v.rate,byCategory:j};}}catch{}if(e.json){console.log(JSON.stringify({habits:{total:r.length,enabled:i.length},practice:n},null,2));return}console.log(o.magenta(`
|
|
5
5
|
Habits Practice Profile
|
|
@@ -35,8 +35,8 @@ ${C.dump({version:"1.0",habits:[],overrides:{"verify-before-done":{severity:"war
|
|
|
35
35
|
# enabled: false # Disable this habit
|
|
36
36
|
`;g.writeFileSync(r,l,"utf8"),c(t),console.log(o.green(`Created ${$}`)),console.log(o.gray(" 10 seed habits are active by default.")),console.log(o.gray(" Use overrides section to tune severity or disable habits.")),console.log(o.gray(" Run `paradigm habits list` to see all habits.\n"));}async function q(e){let t=process.cwd(),r=u.join(t,$);if(!g.existsSync(r)){console.log(o.yellow(`No ${$} found. Run 'paradigm habits init' first.`));return}if(!x.includes(e.category)){console.log(o.red(`Invalid category: ${e.category}. Valid: ${x.join(", ")}`));return}if(!E.includes(e.trigger)){console.log(o.red(`Invalid trigger: ${e.trigger}. Valid: ${E.join(", ")}`));return}if(e.severity&&!I.includes(e.severity)){console.log(o.red(`Invalid severity: ${e.severity}. Valid: ${I.join(", ")}`));return}let i=e.checkType||"tool-called";if(!P.includes(i)){console.log(o.red(`Invalid check-type: ${i}. Valid: ${P.join(", ")}`));return}let n;try{let a=g.readFileSync(r,"utf8");n=C.load(a),n.habits||(n.habits=[]);}catch(a){console.log(o.red("Failed to parse habits.yaml:"),a.message);return}if(new Set([...n.habits.map(a=>a.id),...a(t).map(a=>a.id)]).has(e.id)){console.log(o.yellow(`Habit "${e.id}" already exists.`));return}let c$1=e.tools?e.tools.split(",").map(a=>a.trim()):[],s=e.patterns?e.patterns.split(",").map(a=>a.trim()):[],y={};i==="tool-called"&&c$1.length>0&&(y.tools=c$1),(i==="file-exists"||i==="file-modified"||i==="tests-exist")&&s.length>0&&(y.patterns=s);let d={id:e.id,name:e.name,description:e.description,category:e.category,trigger:e.trigger,severity:e.severity||"advisory",check:{type:i,params:y},enabled:true};n.habits.push(d),w(r,n),c(t),console.log(o.green(`Added habit: ${e.id}`)),console.log(o.gray(` Name: ${e.name}`)),console.log(o.gray(` Category: ${e.category} | Trigger: ${e.trigger} | Severity: ${e.severity||"advisory"}`)),console.log(o.gray(` Check: ${i}`)),c$1.length>0&&console.log(o.gray(` Tools: ${c$1.join(", ")}`)),s.length>0&&console.log(o.gray(` Patterns: ${s.join(", ")}`)),console.log();}async function z(e,t){let r=process.cwd();if(t.category&&!x.includes(t.category)){console.log(o.red(`Invalid category: ${t.category}. Valid: ${x.join(", ")}`));return}if(t.trigger&&!E.includes(t.trigger)){console.log(o.red(`Invalid trigger: ${t.trigger}. Valid: ${E.join(", ")}`));return}if(t.severity&&!I.includes(t.severity)){console.log(o.red(`Invalid severity: ${t.severity}. Valid: ${I.join(", ")}`));return}if(t.checkType&&!P.includes(t.checkType)){console.log(o.red(`Invalid check-type: ${t.checkType}. Valid: ${P.join(", ")}`));return}let i=T(r,e);if(!i){console.log(o.red(`Habit not found: ${e}`));return}if(i.source==="seed"){if(["name","description","category","trigger","checkType","patterns","tools"].some(m=>t[m]!==void 0)){console.log(o.yellow(`"${e}" is a seed habit. Only --severity and --enabled can be changed.`)),console.log(o.gray(" Other fields require creating a custom habit with the same functionality."));return}if(!t.severity&&t.enabled===void 0){console.log(o.yellow("No changes specified. Use --severity or --enabled for seed habits."));return}let d=L(r),a=D(d);a.overrides||(a.overrides={}),a.overrides[e]||(a.overrides[e]={}),t.severity&&(a.overrides[e].severity=t.severity),t.enabled!==void 0&&(a.overrides[e].enabled=t.enabled==="true"),w(d,a),c(r),console.log(o.green(`Updated seed habit override: ${e}`)),t.severity&&console.log(o.gray(` Severity: ${t.severity}`)),t.enabled!==void 0&&console.log(o.gray(` Enabled: ${t.enabled}`)),console.log();return}let n=D(i.filePath),l=n.habits[i.index];t.name&&(l.name=t.name),t.description&&(l.description=t.description),t.category&&(l.category=t.category),t.trigger&&(l.trigger=t.trigger),t.severity&&(l.severity=t.severity),t.enabled!==void 0&&(l.enabled=t.enabled==="true"),t.checkType&&(l.check.type=t.checkType),t.tools&&(l.check.params.tools=t.tools.split(",").map(s=>s.trim())),t.patterns&&(l.check.params.patterns=t.patterns.split(",").map(s=>s.trim())),n.habits[i.index]=l,w(i.filePath,n),c(r);let c$1=i.source==="global"?"(global)":"(project)";console.log(o.green(`Updated habit: ${e} ${o.gray(c$1)}`)),console.log();}async function Q(e,t){let r=process.cwd(),i=T(r,e);if(!i){console.log(o.red(`Habit not found: ${e}`));return}if(i.source==="seed"){console.log(o.yellow(`"${e}" is a seed habit and cannot be removed.`)),console.log(o.gray(` Use: paradigm habits edit ${e} --enabled false`));return}let n=D(i.filePath),l=n.habits[i.index];if(!t.yes){console.log(o.yellow(`
|
|
37
37
|
Will remove habit: ${l.name} (${e})`)),console.log(o.gray(` Source: ${i.source} (${i.filePath})`)),console.log(o.gray(` Use --yes to confirm.
|
|
38
|
-
`));return}n.habits.splice(i.index,1),w(i.filePath,n),c(r),console.log(o.green(`Removed habit: ${e}`)),console.log();}async function X(e,t){let r=process.cwd(),i=t==="enable",n=T(r,e);if(!n){console.log(o.red(`Habit not found: ${e}`));return}if(n.source==="seed"){let c$1=L(r),s=D(c$1);s.overrides||(s.overrides={}),s.overrides[e]||(s.overrides[e]={}),s.overrides[e].enabled=i,w(c$1,s),c(r),console.log(o.green(`${i?"Enabled":"Disabled"} seed habit: ${e}`)),console.log();return}let l=D(n.filePath);l.habits[n.index].enabled=i,w(n.filePath,l),c(r),console.log(o.green(`${i?"Enabled":"Disabled"} habit: ${e}`)),console.log();}async function Z(e
|
|
39
|
-
`),"utf8");}else r==="on-stop"&&g.existsSync(v)&&g.unlinkSync(v);}catch{}e
|
|
38
|
+
`));return}n.habits.splice(i.index,1),w(i.filePath,n),c(r),console.log(o.green(`Removed habit: ${e}`)),console.log();}async function X(e,t){let r=process.cwd(),i=t==="enable",n=T(r,e);if(!n){console.log(o.red(`Habit not found: ${e}`));return}if(n.source==="seed"){let c$1=L(r),s=D(c$1);s.overrides||(s.overrides={}),s.overrides[e]||(s.overrides[e]={}),s.overrides[e].enabled=i,w(c$1,s),c(r),console.log(o.green(`${i?"Enabled":"Disabled"} seed habit: ${e}`)),console.log();return}let l=D(n.filePath);l.habits[n.index].enabled=i,w(n.filePath,l),c(r),console.log(o.green(`${i?"Enabled":"Disabled"} habit: ${e}`)),console.log();}async function Z(e){let t=process.cwd(),r=e.trigger,i;try{i=a(t);}catch(f){console.log(o.red("Failed to load habits:"),f.message),process.exitCode=1;return}let n$1=e.files?e.files.split(",").map(f=>f.trim()).filter(Boolean):N(t),l=e.symbols?e.symbols.split(",").map(f=>f.trim()).filter(Boolean):[],c;try{c=execSync("git status --porcelain",{cwd:t,encoding:"utf8",timeout:5e3}).trim()==="";}catch{}let s=u.join(t,"portal.yaml"),y=false;if(g.existsSync(s))try{let f=g.readFileSync(s,"utf8"),b=C.load(f);y=b?.routes!=null&&Object.keys(b.routes).length>0;}catch{}let d=n({toolsCalled:[],filesModified:n$1,symbolsTouched:l,loreRecorded:false,hasPortalRoutes:y,taskAddsRoutes:false,gitClean:c}),a$1=m(i,r,d),m$1=0;if(e.record&&a$1.evaluations.length>0)try{let f=u.join(t,".paradigm","sentinel");if(g.existsSync(f)){let{SentinelStorage:b}=await import('./dist-VGFSP3XM.js'),j=new b(f);for(let h of a$1.evaluations)j.recordPracticeEvent({habitId:h.habit.id,habitCategory:h.habit.category,result:h.result,engineer:"agent",sessionId:`cli-${Date.now().toString(36)}`,symbolsTouched:l,filesModified:n$1,notes:h.reason}),m$1++;}}catch{}let v=u.join(t,".paradigm",".habits-blocking");try{if(r==="on-stop"&&a$1.blocksCompletion){let f=a$1.evaluations.filter(b=>b.result==="skipped"&&b.habit.severity==="block").map(b=>`${b.habit.name}: ${b.reason}`);g.writeFileSync(v,f.join(`
|
|
39
|
+
`),"utf8");}else r==="on-stop"&&g.existsSync(v)&&g.unlinkSync(v);}catch{}e.json?console.log(JSON.stringify({trigger:r,evaluation:{total:a$1.summary.total,followed:a$1.summary.followed,skipped:a$1.summary.skipped,partial:a$1.summary.partial,blockingViolations:a$1.summary.blockingViolations,blocksCompletion:a$1.blocksCompletion},habits:a$1.evaluations.map(f=>({id:f.habit.id,name:f.habit.name,category:f.habit.category,severity:f.habit.severity,result:f.result,reason:f.reason,evidence:f.evidence})),recorded:m$1},null,2)):U(a$1,m$1),a$1.blocksCompletion&&(process.exitCode=1);}function N(e){try{return execSync("git diff --name-only HEAD",{cwd:e,encoding:"utf8",timeout:5e3}).trim().split(`
|
|
40
40
|
`).filter(Boolean)}catch{return []}}function U(e,t){let{summary:r}=e;console.log(o.magenta(`
|
|
41
41
|
Habits Check (${e.trigger})
|
|
42
42
|
`));for(let i of e.evaluations){let n=i.result==="followed"?o.green("PASS"):i.result==="skipped"?i.habit.severity==="block"?o.red("BLOCK"):o.yellow("SKIP"):o.gray("PART"),l=i.habit.severity==="block"?o.red(i.habit.severity):i.habit.severity==="warn"?o.yellow(i.habit.severity):o.gray(i.habit.severity);console.log(` ${n} ${o.white(i.habit.id)} [${l}]`),console.log(o.gray(` ${i.reason}`));}console.log(),console.log(o.white(` Summary: ${r.followed} followed, ${r.skipped} skipped, ${r.partial} partial`)),r.blockingViolations>0&&console.log(o.red(` ${r.blockingViolations} blocking violation(s) \u2014 exit code 1`)),t>0&&console.log(o.gray(` Recorded ${t} practice event(s) to Sentinel`)),console.log();}export{q as habitsAddCommand,Z as habitsCheckCommand,z as habitsEditCommand,Y as habitsInitCommand,J as habitsListCommand,Q as habitsRemoveCommand,W as habitsStatusCommand,X as habitsToggleCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{a as hooksInstallCommand,c as hooksStatusCommand,b as hooksUninstallCommand}from'./chunk-
|
|
2
|
+
export{a as hooksInstallCommand,c as hooksStatusCommand,b as hooksUninstallCommand}from'./chunk-DH7QVZDI.js';import'./chunk-5TAVYPOV.js';
|