@a-company/paradigm 6.6.2 → 6.6.3
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-TIXUQQGR.js → accept-orchestration-JHDCVHB2.js} +1 -1
- package/dist/{aggregate-A5S5MTCC.js → aggregate-KZICPVT3.js} +1 -1
- package/dist/arch-loader-G3AAM4E2.js +2 -0
- package/dist/{beacon-QVUD3MGP.js → beacon-52EWNZPK.js} +1 -1
- package/dist/chunk-4GC35IFF.js +2 -0
- package/dist/{chunk-AXQBUD3Q.js → chunk-FI66YM6G.js} +43 -43
- package/dist/{chunk-Y4P4SGZV.js → chunk-MBSY57RN.js} +1 -1
- package/dist/{chunk-IOVHF4SR.js → chunk-MU5YWTNE.js} +1 -1
- package/dist/{chunk-5NAF6CKU.js → chunk-QALPEMCU.js} +26 -26
- package/dist/{chunk-4PSD5R7N.js → chunk-QDP4G53M.js} +1 -1
- package/dist/{chunk-ARLB6YYW.js → chunk-RGSFU2YW.js} +1 -1
- package/dist/{chunk-TOYQ2QCB.js → chunk-S3UVQ5RV.js} +1 -1
- package/dist/chunk-TMDPDIWA.js +3 -0
- package/dist/{chunk-2AU5L333.js → chunk-XKNJSPB5.js} +1 -1
- package/dist/{commands-ANRJNG2W.js → commands-4ENQMHFO.js} +1 -1
- package/dist/{constellation-NWLXYATA.js → constellation-RHZAEFV7.js} +1 -1
- package/dist/{diff-75MABOSL.js → diff-ANKTFDRA.js} +1 -1
- package/dist/dist-RXYJK7AZ.js +2 -0
- package/dist/dist-TNE4GFT7.js +2 -0
- package/dist/index.js +5 -5
- package/dist/{init-V4KSEKPK.js → init-F4MSKZIW.js} +1 -1
- package/dist/{integrity-ROO3G43N.js → integrity-7TKX3DZ4.js} +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{orchestrate-K4KBTBYK.js → orchestrate-UG5QXNAU.js} +1 -1
- package/dist/{probe-5HAXULAD.js → probe-27ARJKRO.js} +1 -1
- package/dist/reindex-F7BZCG4W.js +2 -0
- package/dist/review-BRO2UP4M.js +11 -0
- package/dist/{ripple-FNZI47SH.js → ripple-KCVDS3WE.js} +1 -1
- package/dist/sentinel.js +1 -1
- package/dist/{setup-ZSEC72BS.js → setup-5V2AGLQ6.js} +1 -1
- package/dist/{shift-QY3EXVF4.js → shift-TNA2E5O7.js} +2 -2
- package/dist/{snapshot-3IYB67D4.js → snapshot-YMX5QRBM.js} +1 -1
- package/dist/{status-DB3KNLW3.js → status-3GJXI4IK.js} +1 -1
- package/dist/{summary-WLI3NF4G.js → summary-RPU2BS3Q.js} +1 -1
- package/dist/{team-2LGZQRP4.js → team-PEGP6F7S.js} +1 -1
- package/dist/{tools-W5WRPSJF.js → tools-HQKF4Q3P.js} +1 -1
- package/dist/{workspace-VMSPYIBV.js → workspace-6POCBPDY.js} +1 -1
- package/package.json +1 -1
- package/dist/arch-loader-T3TARMSO.js +0 -2
- package/dist/chunk-LWAIVOSF.js +0 -2
- package/dist/chunk-SU5F5D4I.js +0 -3
- package/dist/dist-JZZJLVMR.js +0 -2
- package/dist/dist-OG6MM4VY.js +0 -2
- package/dist/reindex-2YTQP2EO.js +0 -2
- package/dist/review-VMSX2PKI.js +0 -11
package/dist/mcp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d,g,h,e,a as a$1,b as b$2,f,c}from'./chunk-AXQBUD3Q.js';import {b as b$1,ga}from'./chunk-5NAF6CKU.js';import'./chunk-4UJ4NIEQ.js';import'./chunk-4N56FRNE.js';import'./chunk-Q527BPUF.js';import'./chunk-KLBH26PA.js';import'./chunk-ARLB6YYW.js';import {p,q as q$1,k,l as l$1}from'./chunk-SU5F5D4I.js';import'./chunk-JNSJVCTU.js';import'./chunk-XROULIQN.js';import'./chunk-ZUAUFZRJ.js';import'./chunk-3KVVC4WV.js';import'./chunk-M4UMM6DC.js';import'./chunk-GRZQIKST.js';import'./chunk-KAFQA7HV.js';import {j as j$1}from'./chunk-6QXBXZF6.js';import {b,a}from'./chunk-EK4ZRIFJ.js';import'./chunk-LAYBUKMB.js';import'./chunk-DVZWCXB6.js';import'./chunk-QGZRM6ZB.js';import'./chunk-K7X3Z3GL.js';import'./chunk-5TAVYPOV.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {ListResourcesRequestSchema,ReadResourceRequestSchema}from'@modelcontextprotocol/sdk/types.js';import*as l from'fs';import*as m from'path';function se(e){return {id:e.id,symbol:`^${e.id}`,description:e.description,locks:e.locks?.map(s=>({id:s.id,description:s.description,keys:s.keys?.map(n=>n.expression||n),mode:s.mode||"all"})),prizes:e.prizes?.map(s=>({id:s.id,oneTime:s.oneTime}))}}function L(e){let s=e.gateConfig?.gates||[],n=l$1(e.index,"gate"),t=new Map;for(let o of n){let i=o.symbol.replace(/^\^/,"");t.set(i,{id:i,symbol:o.symbol,description:o.description,source:"purpose",filePath:o.filePath,data:o.data});}for(let o of s)t.set(o.id,{...se(o),source:"portal.yaml"});return Array.from(t.values())}function F(e){let s=e.gateConfig?.flows||[],n=l$1(e.index,"flow"),t=new Map;for(let o of n){let i=o.symbol.replace(/^\$/,"");t.set(i,{id:i,symbol:o.symbol,description:o.description,source:"purpose",filePath:o.filePath,data:o.data});}for(let o of s)t.set(o.id,{id:o.id,symbol:`$${o.id}`,description:o.description,gates:o.gates,source:"portal.yaml"});return Array.from(t.values())}function z(){return [{uri:"paradigm://wisdom/preferences",name:"Wisdom - Preferences",description:"Team preferences for patterns, testing, and code style",mimeType:"application/json"},{uri:"paradigm://wisdom/antipatterns",name:"Wisdom - Antipatterns",description:"What NOT to do, with reasons and alternatives",mimeType:"application/json"},{uri:"paradigm://wisdom/decisions",name:"Wisdom - Decisions",description:"Architectural Decision Records (ADRs) index",mimeType:"application/json"}]}async function U(e$1,s){if(e$1==="wisdom/preferences"){let n=await e(s);return {handled:true,text:JSON.stringify({version:n.preferences?.version||"1.0",global:n.preferences?.global||{},by_symbol:n.preferences?.by_symbol||{},symbol_count:Object.keys(n.preferences?.by_symbol||{}).length},null,2)}}if(e$1.startsWith("wisdom/preferences/")){let n=decodeURIComponent(e$1.replace("wisdom/preferences/","")),t=await e(s),o=a$1(t,n);return {handled:true,text:JSON.stringify({symbol:n,preferences:o.preferences,global:t.preferences?.global||{}},null,2)}}if(e$1==="wisdom/antipatterns"){let n=await e(s);return {handled:true,text:JSON.stringify({count:n.antipatterns.length,antipatterns:n.antipatterns},null,2)}}if(e$1.startsWith("wisdom/antipatterns/")){let n=decodeURIComponent(e$1.replace("wisdom/antipatterns/","")),t=await e(s),o=a$1(t,n);return {handled:true,text:JSON.stringify({symbol:n,count:o.antipatterns.length,antipatterns:o.antipatterns},null,2)}}if(e$1==="wisdom/decisions"){let n=await e(s);return {handled:true,text:JSON.stringify({count:n.decisions.length,decisions:n.decisions.map(t=>({id:t.id,title:t.title,status:t.status,date:t.date,symbols:t.symbols}))},null,2)}}if(e$1.startsWith("wisdom/decision/")){let n=e$1.replace("wisdom/decision/",""),t=await e(s),o=t.decisions.find(i=>i.id===n);return o?{handled:true,text:JSON.stringify(o,null,2)}:{handled:true,text:JSON.stringify({error:"Decision not found",id:n,available:t.decisions.map(i=>i.id)},null,2)}}if(e$1.startsWith("wisdom/expertise/")){let n=decodeURIComponent(e$1.replace("wisdom/expertise/","")),t=await e(s),o=b$2(t,{symbol:n});return {handled:true,text:JSON.stringify({symbol:n,count:o.length,experts:o.map(i=>({name:i.name,symbols:i.symbols,areas:i.areas,contact:i.contact}))},null,2)}}return {handled:false,text:""}}function $(){return [{uri:"paradigm://history/fragile",name:"History - Fragile Symbols",description:"Symbols with high fragility that need extra care when modifying",mimeType:"application/json"},{uri:"paradigm://history/validation/summary",name:"History - Validation Summary",description:"Overall validation statistics and pass rates",mimeType:"application/json"}]}async function G(e,s){if(e.startsWith("history/symbol/")&&!e.endsWith("/recent")){let n=decodeURIComponent(e.replace("history/symbol/","")),t=await f(s),o=c(t,n);return {handled:true,text:JSON.stringify({symbol:n,summary:o.summary?{total_changes:o.summary.total_changes,last_modified:o.summary.last_modified,stability_score:o.summary.stability_score,fragility:o.summary.fragility,contributors:o.summary.contributors}:null,recent:o.recent,co_changes:o.co_changes,validation:o.validation},null,2)}}if(e.startsWith("history/symbol/")&&e.endsWith("/recent")){let n=decodeURIComponent(e.replace("history/symbol/","").replace("/recent","")),t=await f(s),o=c(t,n);return {handled:true,text:JSON.stringify({symbol:n,fragility:o.summary?.fragility||"unknown",stability_score:o.summary?.stability_score,recent:o.recent.slice(0,5)},null,2)}}if(e==="history/fragile"){let n=await f(s);return {handled:true,text:JSON.stringify({count:n.index?.fragile_symbols?.length||0,fragile_symbols:n.index?.fragile_symbols||[],recommendation:"Consider adding extra test coverage and reviewing recent changes before modifying these symbols"},null,2)}}if(e.startsWith("history/cochanges/")){let n=decodeURIComponent(e.replace("history/cochanges/","")),o=(await f(s)).index?.co_changes?.filter(i=>i.symbols.includes(n))||[];return {handled:true,text:JSON.stringify({symbol:n,count:o.length,co_changes:o.map(i=>({with:i.symbols.filter(a=>a!==n),frequency:i.frequency,correlation:i.correlation})),recommendation:o.length>0?"These symbols often change together - consider if they need updates too":"No strong co-change patterns detected"},null,2)}}if(e==="history/validation/summary"){let n=await f(s);return {handled:true,text:JSON.stringify({last_run:n.validation?.last_run,total_validations:n.validation?.total_validations||0,pass_rate:n.validation?.pass_rate||0,by_symbol:n.validation?.by_symbol||{}},null,2)}}return {handled:false,text:""}}function q(){return [{uri:"paradigm://context/agent-protocol",name:"Agent Protocol",description:"IMPORTANT: Read this first. Workflow instructions for using Paradigm MCP tools effectively.",mimeType:"text/markdown"},{uri:"paradigm://context/session",name:"Session Info",description:"Current MCP session statistics and context usage estimate",mimeType:"application/json"},{uri:"paradigm://context/handoff-guide",name:"Handoff Guide",description:"When and how to perform context handoffs",mimeType:"text/markdown"}]}async function H(e,s){if(e==="context/agent-protocol")return {handled:true,text:'# Agent Protocol for Paradigm MCP Tools\n\n## What Paradigm Is\n\nParadigm adds a metadata layer (`.purpose` files + `portal.yaml`) to any codebase so AI agents can query architecture context via MCP instead of reading source files directly.\n\n**What it does**\n- Tracks codebase symbols: `#components`, `$flows`, `^gates`, `!signals`, `~aspects`\n- Answers queries about structure, dependencies, authorization, and history without file reads\n- Enforces coverage: hooks block sessions that modify code without updating `.purpose` files\n\n**Tool surface (50+ tools)**\n- Navigation: `paradigm_status`, `paradigm_search`, `paradigm_navigate`, `paradigm_related`\n- Impact: `paradigm_ripple`, `paradigm_flows_affected`\n- Authorization: `paradigm_gates_for_route`, `paradigm_portal_add_gate`\n- History: `paradigm_history_context`, `paradigm_lore_record`, `paradigm_lore_search`\n- Agents: `paradigm_agent_list`, `paradigm_orchestrate_inline`, `paradigm_ambient_events`\n- Compliance: `paradigm_aspect_check`, `paradigm_protocol_search`\n- Session: `paradigm_session_health`, `paradigm_handoff_prepare`\n\n**Setup** (if not already initialized)\nRun `paradigm shift` \u2014 auto-detects language/framework, creates `.paradigm/` config, scaffolds `.purpose` and `portal.yaml`, installs hooks.\n\n---\n\n## Query Before Modify\n\n**Always query before making changes** - this ensures you understand impact and dependencies.\n\n| Before doing this... | Call this MCP tool |\n|---------------------|-------------------|\n| Modifying a symbol | `paradigm_ripple` with the symbol |\n| Starting a session | `paradigm_status` for project overview |\n| Understanding code | `paradigm_navigate` with explore intent |\n| Checking dependencies | `paradigm_related` for connections |\n\n## Example Workflow\n\n1. **Get oriented**: Call `paradigm_status` to see project symbols and health\n2. **Find relevant code**: Call `paradigm_navigate` with intent "find" or "explore"\n3. **Before editing**: Call `paradigm_ripple` on symbols you\'ll modify\n4. **Check context**: Call `paradigm_session_health` every 10-15 tool calls\n\n## Benefits\n\n- **Fresh data**: Always current from live project index\n- **Precise**: Only get the data you need\n- **Token-efficient**: ~100 tokens per query vs ~2000 for reading files\n\n## Context Monitoring\n\nCall `paradigm_session_health` periodically to monitor session health:\n- **<50%**: Continue working\n- **50-70%**: Plan a stopping point\n- **70-85%**: Prepare handoff soon\n- **>85%**: Handoff after current task\n\n## Tool Surface by Category\n\n| Category | Tools |\n|----------|-------|\n| Navigation | `paradigm_status`, `paradigm_search`, `paradigm_navigate`, `paradigm_related` |\n| Impact analysis | `paradigm_ripple`, `paradigm_flows_affected` |\n| Authorization | `paradigm_gates_for_route`, `paradigm_portal_add_gate` |\n| History & lore | `paradigm_history_context`, `paradigm_lore_record`, `paradigm_lore_search` |\n| Agent team | `paradigm_agent_list`, `paradigm_orchestrate_inline`, `paradigm_captain_brief` |\n| Compliance | `paradigm_aspect_check`, `paradigm_protocol_search`, `paradigm_aspect_drift` |\n| Session | `paradigm_session_health`, `paradigm_handoff_prepare`, `paradigm_session_recover` |\n| Architecture | `paradigm_arch_status`, `paradigm_arch_diagram` |\n\n---\n\n*This protocol ensures efficient, safe modifications to the codebase.*\n'};if(e==="context/session"){let n=j$1(),t=n.getStats(),o=n.getDurationMinutes();return {handled:true,text:JSON.stringify({session:{durationMinutes:o,startTime:new Date(t.startTime).toISOString(),lastActivity:new Date(t.lastActivity).toISOString()},interactions:{toolCalls:t.totals.toolCallCount,resourceReads:t.totals.resourceReadCount,totalInteractions:t.totals.toolCallCount+t.totals.resourceReadCount},tokens:{estimatedMcpContribution:t.totals.totalTokens,note:"Use paradigm_session_health tool for full analysis with handoff recommendations"}},null,2)}}return e==="context/handoff-guide"?{handled:true,text:`# Context Handoff Guide
|
|
2
|
+
import {d,g,h,e,a as a$1,b as b$2,f,c}from'./chunk-FI66YM6G.js';import {b as b$1,ea}from'./chunk-QALPEMCU.js';import'./chunk-4UJ4NIEQ.js';import'./chunk-4N56FRNE.js';import'./chunk-Q527BPUF.js';import'./chunk-KLBH26PA.js';import'./chunk-RGSFU2YW.js';import {p,q as q$1,k,l as l$1}from'./chunk-TMDPDIWA.js';import'./chunk-JNSJVCTU.js';import'./chunk-XROULIQN.js';import'./chunk-ZUAUFZRJ.js';import'./chunk-3KVVC4WV.js';import'./chunk-M4UMM6DC.js';import'./chunk-GRZQIKST.js';import'./chunk-KAFQA7HV.js';import {j as j$1}from'./chunk-6QXBXZF6.js';import {b,a}from'./chunk-EK4ZRIFJ.js';import'./chunk-LAYBUKMB.js';import'./chunk-DVZWCXB6.js';import'./chunk-QGZRM6ZB.js';import'./chunk-K7X3Z3GL.js';import'./chunk-5TAVYPOV.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {ListResourcesRequestSchema,ReadResourceRequestSchema}from'@modelcontextprotocol/sdk/types.js';import*as l from'fs';import*as m from'path';function se(e){return {id:e.id,symbol:`^${e.id}`,description:e.description,locks:e.locks?.map(s=>({id:s.id,description:s.description,keys:s.keys?.map(n=>n.expression||n),mode:s.mode||"all"})),prizes:e.prizes?.map(s=>({id:s.id,oneTime:s.oneTime}))}}function L(e){let s=e.gateConfig?.gates||[],n=l$1(e.index,"gate"),t=new Map;for(let o of n){let i=o.symbol.replace(/^\^/,"");t.set(i,{id:i,symbol:o.symbol,description:o.description,source:"purpose",filePath:o.filePath,data:o.data});}for(let o of s)t.set(o.id,{...se(o),source:"portal.yaml"});return Array.from(t.values())}function F(e){let s=e.gateConfig?.flows||[],n=l$1(e.index,"flow"),t=new Map;for(let o of n){let i=o.symbol.replace(/^\$/,"");t.set(i,{id:i,symbol:o.symbol,description:o.description,source:"purpose",filePath:o.filePath,data:o.data});}for(let o of s)t.set(o.id,{id:o.id,symbol:`$${o.id}`,description:o.description,gates:o.gates,source:"portal.yaml"});return Array.from(t.values())}function z(){return [{uri:"paradigm://wisdom/preferences",name:"Wisdom - Preferences",description:"Team preferences for patterns, testing, and code style",mimeType:"application/json"},{uri:"paradigm://wisdom/antipatterns",name:"Wisdom - Antipatterns",description:"What NOT to do, with reasons and alternatives",mimeType:"application/json"},{uri:"paradigm://wisdom/decisions",name:"Wisdom - Decisions",description:"Architectural Decision Records (ADRs) index",mimeType:"application/json"}]}async function U(e$1,s){if(e$1==="wisdom/preferences"){let n=await e(s);return {handled:true,text:JSON.stringify({version:n.preferences?.version||"1.0",global:n.preferences?.global||{},by_symbol:n.preferences?.by_symbol||{},symbol_count:Object.keys(n.preferences?.by_symbol||{}).length},null,2)}}if(e$1.startsWith("wisdom/preferences/")){let n=decodeURIComponent(e$1.replace("wisdom/preferences/","")),t=await e(s),o=a$1(t,n);return {handled:true,text:JSON.stringify({symbol:n,preferences:o.preferences,global:t.preferences?.global||{}},null,2)}}if(e$1==="wisdom/antipatterns"){let n=await e(s);return {handled:true,text:JSON.stringify({count:n.antipatterns.length,antipatterns:n.antipatterns},null,2)}}if(e$1.startsWith("wisdom/antipatterns/")){let n=decodeURIComponent(e$1.replace("wisdom/antipatterns/","")),t=await e(s),o=a$1(t,n);return {handled:true,text:JSON.stringify({symbol:n,count:o.antipatterns.length,antipatterns:o.antipatterns},null,2)}}if(e$1==="wisdom/decisions"){let n=await e(s);return {handled:true,text:JSON.stringify({count:n.decisions.length,decisions:n.decisions.map(t=>({id:t.id,title:t.title,status:t.status,date:t.date,symbols:t.symbols}))},null,2)}}if(e$1.startsWith("wisdom/decision/")){let n=e$1.replace("wisdom/decision/",""),t=await e(s),o=t.decisions.find(i=>i.id===n);return o?{handled:true,text:JSON.stringify(o,null,2)}:{handled:true,text:JSON.stringify({error:"Decision not found",id:n,available:t.decisions.map(i=>i.id)},null,2)}}if(e$1.startsWith("wisdom/expertise/")){let n=decodeURIComponent(e$1.replace("wisdom/expertise/","")),t=await e(s),o=b$2(t,{symbol:n});return {handled:true,text:JSON.stringify({symbol:n,count:o.length,experts:o.map(i=>({name:i.name,symbols:i.symbols,areas:i.areas,contact:i.contact}))},null,2)}}return {handled:false,text:""}}function $(){return [{uri:"paradigm://history/fragile",name:"History - Fragile Symbols",description:"Symbols with high fragility that need extra care when modifying",mimeType:"application/json"},{uri:"paradigm://history/validation/summary",name:"History - Validation Summary",description:"Overall validation statistics and pass rates",mimeType:"application/json"}]}async function G(e,s){if(e.startsWith("history/symbol/")&&!e.endsWith("/recent")){let n=decodeURIComponent(e.replace("history/symbol/","")),t=await f(s),o=c(t,n);return {handled:true,text:JSON.stringify({symbol:n,summary:o.summary?{total_changes:o.summary.total_changes,last_modified:o.summary.last_modified,stability_score:o.summary.stability_score,fragility:o.summary.fragility,contributors:o.summary.contributors}:null,recent:o.recent,co_changes:o.co_changes,validation:o.validation},null,2)}}if(e.startsWith("history/symbol/")&&e.endsWith("/recent")){let n=decodeURIComponent(e.replace("history/symbol/","").replace("/recent","")),t=await f(s),o=c(t,n);return {handled:true,text:JSON.stringify({symbol:n,fragility:o.summary?.fragility||"unknown",stability_score:o.summary?.stability_score,recent:o.recent.slice(0,5)},null,2)}}if(e==="history/fragile"){let n=await f(s);return {handled:true,text:JSON.stringify({count:n.index?.fragile_symbols?.length||0,fragile_symbols:n.index?.fragile_symbols||[],recommendation:"Consider adding extra test coverage and reviewing recent changes before modifying these symbols"},null,2)}}if(e.startsWith("history/cochanges/")){let n=decodeURIComponent(e.replace("history/cochanges/","")),o=(await f(s)).index?.co_changes?.filter(i=>i.symbols.includes(n))||[];return {handled:true,text:JSON.stringify({symbol:n,count:o.length,co_changes:o.map(i=>({with:i.symbols.filter(a=>a!==n),frequency:i.frequency,correlation:i.correlation})),recommendation:o.length>0?"These symbols often change together - consider if they need updates too":"No strong co-change patterns detected"},null,2)}}if(e==="history/validation/summary"){let n=await f(s);return {handled:true,text:JSON.stringify({last_run:n.validation?.last_run,total_validations:n.validation?.total_validations||0,pass_rate:n.validation?.pass_rate||0,by_symbol:n.validation?.by_symbol||{}},null,2)}}return {handled:false,text:""}}function q(){return [{uri:"paradigm://context/agent-protocol",name:"Agent Protocol",description:"IMPORTANT: Read this first. Workflow instructions for using Paradigm MCP tools effectively.",mimeType:"text/markdown"},{uri:"paradigm://context/session",name:"Session Info",description:"Current MCP session statistics and context usage estimate",mimeType:"application/json"},{uri:"paradigm://context/handoff-guide",name:"Handoff Guide",description:"When and how to perform context handoffs",mimeType:"text/markdown"}]}async function H(e,s){if(e==="context/agent-protocol")return {handled:true,text:'# Agent Protocol for Paradigm MCP Tools\n\n## What Paradigm Is\n\nParadigm adds a metadata layer (`.purpose` files + `portal.yaml`) to any codebase so AI agents can query architecture context via MCP instead of reading source files directly.\n\n**What it does**\n- Tracks codebase symbols: `#components`, `$flows`, `^gates`, `!signals`, `~aspects`\n- Answers queries about structure, dependencies, authorization, and history without file reads\n- Enforces coverage: hooks block sessions that modify code without updating `.purpose` files\n\n**Tool surface (50+ tools)**\n- Navigation: `paradigm_status`, `paradigm_search`, `paradigm_navigate`, `paradigm_related`\n- Impact: `paradigm_ripple`, `paradigm_flows_affected`\n- Authorization: `paradigm_gates_for_route`, `paradigm_portal_add_gate`\n- History: `paradigm_history_context`, `paradigm_lore_record`, `paradigm_lore_search`\n- Agents: `paradigm_agent_list`, `paradigm_orchestrate_inline`, `paradigm_ambient_events`\n- Compliance: `paradigm_aspect_check`, `paradigm_protocol_search`\n- Session: `paradigm_session_health`, `paradigm_handoff_prepare`\n\n**Setup** (if not already initialized)\nRun `paradigm shift` \u2014 auto-detects language/framework, creates `.paradigm/` config, scaffolds `.purpose` and `portal.yaml`, installs hooks.\n\n---\n\n## Query Before Modify\n\n**Always query before making changes** - this ensures you understand impact and dependencies.\n\n| Before doing this... | Call this MCP tool |\n|---------------------|-------------------|\n| Modifying a symbol | `paradigm_ripple` with the symbol |\n| Starting a session | `paradigm_status` for project overview |\n| Understanding code | `paradigm_navigate` with explore intent |\n| Checking dependencies | `paradigm_related` for connections |\n\n## Example Workflow\n\n1. **Get oriented**: Call `paradigm_status` to see project symbols and health\n2. **Find relevant code**: Call `paradigm_navigate` with intent "find" or "explore"\n3. **Before editing**: Call `paradigm_ripple` on symbols you\'ll modify\n4. **Check context**: Call `paradigm_session_health` every 10-15 tool calls\n\n## Benefits\n\n- **Fresh data**: Always current from live project index\n- **Precise**: Only get the data you need\n- **Token-efficient**: ~100 tokens per query vs ~2000 for reading files\n\n## Context Monitoring\n\nCall `paradigm_session_health` periodically to monitor session health:\n- **<50%**: Continue working\n- **50-70%**: Plan a stopping point\n- **70-85%**: Prepare handoff soon\n- **>85%**: Handoff after current task\n\n## Tool Surface by Category\n\n| Category | Tools |\n|----------|-------|\n| Navigation | `paradigm_status`, `paradigm_search`, `paradigm_navigate`, `paradigm_related` |\n| Impact analysis | `paradigm_ripple`, `paradigm_flows_affected` |\n| Authorization | `paradigm_gates_for_route`, `paradigm_portal_add_gate` |\n| History & lore | `paradigm_history_context`, `paradigm_lore_record`, `paradigm_lore_search` |\n| Agent team | `paradigm_agent_list`, `paradigm_orchestrate_inline`, `paradigm_captain_brief` |\n| Compliance | `paradigm_aspect_check`, `paradigm_protocol_search`, `paradigm_aspect_drift` |\n| Session | `paradigm_session_health`, `paradigm_handoff_prepare`, `paradigm_session_recover` |\n| Architecture | `paradigm_arch_status`, `paradigm_arch_diagram` |\n\n---\n\n*This protocol ensures efficient, safe modifications to the codebase.*\n'};if(e==="context/session"){let n=j$1(),t=n.getStats(),o=n.getDurationMinutes();return {handled:true,text:JSON.stringify({session:{durationMinutes:o,startTime:new Date(t.startTime).toISOString(),lastActivity:new Date(t.lastActivity).toISOString()},interactions:{toolCalls:t.totals.toolCallCount,resourceReads:t.totals.resourceReadCount,totalInteractions:t.totals.toolCallCount+t.totals.resourceReadCount},tokens:{estimatedMcpContribution:t.totals.totalTokens,note:"Use paradigm_session_health tool for full analysis with handoff recommendations"}},null,2)}}return e==="context/handoff-guide"?{handled:true,text:`# Context Handoff Guide
|
|
3
3
|
|
|
4
4
|
## When to Handoff
|
|
5
5
|
|
|
@@ -414,4 +414,4 @@ components:
|
|
|
414
414
|
| When | Tool | Purpose |
|
|
415
415
|
|------|------|---------|
|
|
416
416
|
| Starting any task | \`paradigm_pm_preflight\` | Get compliance plan |
|
|
417
|
-
| Finishing any task | _(handled by stop hook)_ | Auto-checks compliance |`}};function we(e){return Math.ceil(e.length/3.5)}function oe(){return [{uri:"paradigm://guidance",name:"Guidance Topics",description:"List all available on-demand guidance topics (logging, portal, flows, orchestration, etc.)",mimeType:"application/json"},{uri:"paradigm://guidance/{topic}",name:"Guidance Content",description:`Get guidance for a topic. Available: ${Object.keys(j).join(", ")}`,mimeType:"text/markdown"}]}async function ne(e,s){let n=`paradigm://${e}`;if(e==="guidance"){let t=Object.entries(j).map(([i,a])=>{let r=a.generate();return {name:i,description:a.description,tokens:we(r)}}),o=JSON.stringify({count:t.length,totalTokens:t.reduce((i,a)=>i+a.tokens,0),note:"These guidance topics were previously baked into CLAUDE.md. Load on-demand to save context.",topics:t.map(i=>({...i,uri:`paradigm://guidance/${i.name}`}))},null,2);return b$1(o.length,n),{handled:true,text:o,mimeType:"application/json"}}if(e.startsWith("guidance/")&&e!=="guidance/"){let t=decodeURIComponent(e.replace("guidance/","")),o=j[t];if(!o){let a=Object.keys(j),r=JSON.stringify({error:`Unknown guidance topic: "${t}"`,available:a},null,2);return b$1(r.length,n),{handled:true,text:r,mimeType:"application/json"}}let i=o.generate();return b$1(i.length,n),{handled:true,text:i,mimeType:"text/markdown"}}return {handled:false,text:"",mimeType:"application/json"}}function ie(e,s){e.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:[{uri:"paradigm://symbols",name:"All Symbols",description:"Overview of all Paradigm symbols in the project",mimeType:"application/json"},{uri:"paradigm://symbols/type/feature",name:"Features",description:"All @feature symbols",mimeType:"application/json"},{uri:"paradigm://symbols/type/component",name:"Components",description:"All #component symbols",mimeType:"application/json"},{uri:"paradigm://symbols/type/gate",name:"Gates",description:"All ^gate symbols (authorization)",mimeType:"application/json"},{uri:"paradigm://symbols/type/flow",name:"Flows",description:"All $flow symbols (processes)",mimeType:"application/json"},{uri:"paradigm://symbols/type/signal",name:"Signals",description:"All !signal symbols (events)",mimeType:"application/json"},{uri:"paradigm://symbols/type/state",name:"States",description:"All %state symbols",mimeType:"application/json"},{uri:"paradigm://gates",name:"Gates (Detailed)",description:"All gates with locks, keys, and prizes from portal.yaml",mimeType:"application/json"},{uri:"paradigm://flows",name:"Flows (Detailed)",description:"All flows with gate sequences",mimeType:"application/json"},...z(),...$(),...q(),...V(),...K(),...ee(),...oe()]})),e.setRequestHandler(ReadResourceRequestSchema,async n=>{let t=n.params.uri;if(!t?.startsWith("paradigm://"))throw new Error(`Unknown URI scheme: ${t}`);let o=s(),i=t.replace("paradigm://","");if(i==="symbols"){let a=p(o.index),r=q$1(o.index),d=JSON.stringify({project:o.projectName,counts:a,total:Object.values(a).reduce((p,k)=>p+k,0),symbols:r.map(p=>({symbol:p.symbol,type:p.type,description:p.description}))},null,2);return b$1(d.length,t),{contents:[{uri:t,mimeType:"application/json",text:d}]}}if(i.startsWith("symbol/")){let a=decodeURIComponent(i.replace("symbol/","")),r=k(o.index,a);if(!r){let p=JSON.stringify({error:"Symbol not found",symbol:a,available:q$1(o.index).filter(k=>k.symbol.includes(a.slice(1))).slice(0,5).map(k=>k.symbol)},null,2);return b$1(p.length,t),{contents:[{uri:t,mimeType:"application/json",text:p}]}}let d=JSON.stringify({symbol:r.symbol,type:r.type,description:r.description,filePath:r.filePath,references:r.references,referencedBy:r.referencedBy,tags:r.tags,data:r.data},null,2);return b$1(d.length,t),{contents:[{uri:t,mimeType:"application/json",text:d}]}}if(i.startsWith("symbols/type/")){let a=i.replace("symbols/type/",""),r=l$1(o.index,a),d=JSON.stringify({type:a,count:r.length,symbols:r.map(p=>({symbol:p.symbol,description:p.description,filePath:p.filePath,referencesCount:p.references.length,referencedByCount:p.referencedBy.length}))},null,2);return b$1(d.length,t),{contents:[{uri:t,mimeType:"application/json",text:d}]}}if(i==="gates"){let a=L(o),r=JSON.stringify({count:a.length,gates:a},null,2);return b$1(r.length,t),{contents:[{uri:t,mimeType:"application/json",text:r}]}}if(i==="flows"){let a=F(o),r=JSON.stringify({count:a.length,flows:a},null,2);return b$1(r.length,t),{contents:[{uri:t,mimeType:"application/json",text:r}]}}if(i.startsWith("wisdom/")){let a=await U(i,o);if(a.handled)return b$1(a.text.length),{contents:[{uri:t,mimeType:"application/json",text:a.text}]}}if(i.startsWith("history/")){let a=await G(i,o);if(a.handled)return b$1(a.text.length),{contents:[{uri:t,mimeType:"application/json",text:a.text}]}}if(i.startsWith("context/")){let a=await H(i);if(a.handled)return b$1(a.text.length),{contents:[{uri:t,mimeType:a.text.startsWith("#")?"text/markdown":"application/json",text:a.text}]}}if(i==="prompts"||i.startsWith("prompts/")){let a=await Y(i,o);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}if(i==="specs"||i.startsWith("specs/")){let a=await X(i,o);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}if(i==="docs"||i.startsWith("docs/")){let a=await te(i,o);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}if(i==="guidance"||i.startsWith("guidance/")){let a=await ne(i);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}throw new Error(`Unknown resource: ${i}`)});}b();var v=process.argv[2]||process.cwd(),_=null;function ae(){if(!_)throw new Error("Project context not loaded");return _}async function je(){_=await d(v),
|
|
417
|
+
| Finishing any task | _(handled by stop hook)_ | Auto-checks compliance |`}};function we(e){return Math.ceil(e.length/3.5)}function oe(){return [{uri:"paradigm://guidance",name:"Guidance Topics",description:"List all available on-demand guidance topics (logging, portal, flows, orchestration, etc.)",mimeType:"application/json"},{uri:"paradigm://guidance/{topic}",name:"Guidance Content",description:`Get guidance for a topic. Available: ${Object.keys(j).join(", ")}`,mimeType:"text/markdown"}]}async function ne(e,s){let n=`paradigm://${e}`;if(e==="guidance"){let t=Object.entries(j).map(([i,a])=>{let r=a.generate();return {name:i,description:a.description,tokens:we(r)}}),o=JSON.stringify({count:t.length,totalTokens:t.reduce((i,a)=>i+a.tokens,0),note:"These guidance topics were previously baked into CLAUDE.md. Load on-demand to save context.",topics:t.map(i=>({...i,uri:`paradigm://guidance/${i.name}`}))},null,2);return b$1(o.length,n),{handled:true,text:o,mimeType:"application/json"}}if(e.startsWith("guidance/")&&e!=="guidance/"){let t=decodeURIComponent(e.replace("guidance/","")),o=j[t];if(!o){let a=Object.keys(j),r=JSON.stringify({error:`Unknown guidance topic: "${t}"`,available:a},null,2);return b$1(r.length,n),{handled:true,text:r,mimeType:"application/json"}}let i=o.generate();return b$1(i.length,n),{handled:true,text:i,mimeType:"text/markdown"}}return {handled:false,text:"",mimeType:"application/json"}}function ie(e,s){e.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:[{uri:"paradigm://symbols",name:"All Symbols",description:"Overview of all Paradigm symbols in the project",mimeType:"application/json"},{uri:"paradigm://symbols/type/feature",name:"Features",description:"All @feature symbols",mimeType:"application/json"},{uri:"paradigm://symbols/type/component",name:"Components",description:"All #component symbols",mimeType:"application/json"},{uri:"paradigm://symbols/type/gate",name:"Gates",description:"All ^gate symbols (authorization)",mimeType:"application/json"},{uri:"paradigm://symbols/type/flow",name:"Flows",description:"All $flow symbols (processes)",mimeType:"application/json"},{uri:"paradigm://symbols/type/signal",name:"Signals",description:"All !signal symbols (events)",mimeType:"application/json"},{uri:"paradigm://symbols/type/state",name:"States",description:"All %state symbols",mimeType:"application/json"},{uri:"paradigm://gates",name:"Gates (Detailed)",description:"All gates with locks, keys, and prizes from portal.yaml",mimeType:"application/json"},{uri:"paradigm://flows",name:"Flows (Detailed)",description:"All flows with gate sequences",mimeType:"application/json"},...z(),...$(),...q(),...V(),...K(),...ee(),...oe()]})),e.setRequestHandler(ReadResourceRequestSchema,async n=>{let t=n.params.uri;if(!t?.startsWith("paradigm://"))throw new Error(`Unknown URI scheme: ${t}`);let o=s(),i=t.replace("paradigm://","");if(i==="symbols"){let a=p(o.index),r=q$1(o.index),d=JSON.stringify({project:o.projectName,counts:a,total:Object.values(a).reduce((p,k)=>p+k,0),symbols:r.map(p=>({symbol:p.symbol,type:p.type,description:p.description}))},null,2);return b$1(d.length,t),{contents:[{uri:t,mimeType:"application/json",text:d}]}}if(i.startsWith("symbol/")){let a=decodeURIComponent(i.replace("symbol/","")),r=k(o.index,a);if(!r){let p=JSON.stringify({error:"Symbol not found",symbol:a,available:q$1(o.index).filter(k=>k.symbol.includes(a.slice(1))).slice(0,5).map(k=>k.symbol)},null,2);return b$1(p.length,t),{contents:[{uri:t,mimeType:"application/json",text:p}]}}let d=JSON.stringify({symbol:r.symbol,type:r.type,description:r.description,filePath:r.filePath,references:r.references,referencedBy:r.referencedBy,tags:r.tags,data:r.data},null,2);return b$1(d.length,t),{contents:[{uri:t,mimeType:"application/json",text:d}]}}if(i.startsWith("symbols/type/")){let a=i.replace("symbols/type/",""),r=l$1(o.index,a),d=JSON.stringify({type:a,count:r.length,symbols:r.map(p=>({symbol:p.symbol,description:p.description,filePath:p.filePath,referencesCount:p.references.length,referencedByCount:p.referencedBy.length}))},null,2);return b$1(d.length,t),{contents:[{uri:t,mimeType:"application/json",text:d}]}}if(i==="gates"){let a=L(o),r=JSON.stringify({count:a.length,gates:a},null,2);return b$1(r.length,t),{contents:[{uri:t,mimeType:"application/json",text:r}]}}if(i==="flows"){let a=F(o),r=JSON.stringify({count:a.length,flows:a},null,2);return b$1(r.length,t),{contents:[{uri:t,mimeType:"application/json",text:r}]}}if(i.startsWith("wisdom/")){let a=await U(i,o);if(a.handled)return b$1(a.text.length),{contents:[{uri:t,mimeType:"application/json",text:a.text}]}}if(i.startsWith("history/")){let a=await G(i,o);if(a.handled)return b$1(a.text.length),{contents:[{uri:t,mimeType:"application/json",text:a.text}]}}if(i.startsWith("context/")){let a=await H(i);if(a.handled)return b$1(a.text.length),{contents:[{uri:t,mimeType:a.text.startsWith("#")?"text/markdown":"application/json",text:a.text}]}}if(i==="prompts"||i.startsWith("prompts/")){let a=await Y(i,o);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}if(i==="specs"||i.startsWith("specs/")){let a=await X(i,o);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}if(i==="docs"||i.startsWith("docs/")){let a=await te(i,o);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}if(i==="guidance"||i.startsWith("guidance/")){let a=await ne(i);if(a.handled)return {contents:[{uri:t,mimeType:a.mimeType,text:a.text}]}}throw new Error(`Unknown resource: ${i}`)});}b();var v=process.argv[2]||process.cwd(),_=null;function ae(){if(!_)throw new Error("Project context not loaded");return _}async function je(){_=await d(v),ea(v,_).catch(e=>{a.component("#paradigm-mcp").warn("Background reindex failed",{error:e.message});});}async function Te(){a.component("#paradigm-mcp").info("Loading project",{projectDir:v});try{_=await d(v),j$1().setRootDir(_.rootDir),a.component("#paradigm-mcp").info("Project loaded",{symbols:_.aggregation.symbols.length,project:_.projectName});}catch(n){a.component("#paradigm-mcp").error("Error loading project",{error:n.message}),process.exit(1);}g(v);let e=new Server({name:"paradigm",version:"0.1.0"},{capabilities:{resources:{},tools:{}}});ie(e,ae),h(e,ae,je),e.onerror=n=>{a.component("#paradigm-mcp").error("Server error",{error:String(n)});};let s=new StdioServerTransport;await e.connect(s),a.component("#paradigm-mcp").info("Server running on stdio");}Te().catch(e=>{a.component("#paradigm-mcp").error("Fatal error",{error:e.message}),process.exit(1);});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a,b}from'./chunk-
|
|
2
|
+
import {a,b}from'./chunk-MU5YWTNE.js';import'./chunk-TYWB5IQJ.js';import'./chunk-AMLD7IYC.js';import'./chunk-FYDRENK7.js';import'./chunk-HXGYVS2N.js';import {e as e$1}from'./chunk-TQOT2LBO.js';import {d,c}from'./chunk-EKZDFEJW.js';import'./chunk-LPBCQM5Y.js';import'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as S from'path';import e from'chalk';import O from'ora';async function I(o,n,t){let i=n?S.resolve(n):process.cwd();if(!o){t.json?console.log(JSON.stringify({error:"Task is required"})):(console.log(e.red(`
|
|
3
3
|
Task is required.`)),console.log(e.gray(`Example: paradigm team orchestrate "Build @payment-system with Stripe"
|
|
4
4
|
`)));return}if(!e$1(i)){t.json?console.log(JSON.stringify({error:"Team not configured"})):console.log(e.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));return}let f="faceted";t.solo&&(f="solo"),t.faceted&&(f="faceted");let g;if(t.budget){let s=t.budget.split(",");g={};for(let l of s){let[a,r]=l.split("=");a==="tokens"&&(g.maxTokens=parseInt(r)),a==="cost"&&(g.maxCostUsd=parseFloat(r)),a==="warn"&&(g.warnAtPercent=parseInt(r));}}let c=O({text:"Initializing orchestrator...",isSilent:t.quiet||t.json}).start(),y=new a(i);try{await y.initialize();}catch(s){c.fail("Failed to initialize orchestrator"),t.json?console.log(JSON.stringify({error:s instanceof Error?s.message:String(s)})):console.log(e.red(`
|
|
5
5
|
Error: ${s instanceof Error?s.message:s}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a as a$1,c}from'./chunk-
|
|
2
|
+
import {a as a$1,c}from'./chunk-MBSY57RN.js';import {a,b}from'./chunk-4TXOVRWD.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import {m}from'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import {e as e$1}from'./chunk-VIG5LSGZ.js';import'./chunk-5TAVYPOV.js';import*as n from'fs';import*as e from'path';import s from'chalk';import I from'ora';async function T(i,o){let a$2=i?e.resolve(i):process.cwd(),m$1=e.basename(a$2),g=I(),f=e.join(a$2,".paradigm"),F=n.existsSync(f)&&n.statSync(f).isFile(),p;o.output?p=e.resolve(o.output):F?p=e.join(a$2,".paradigm-scan-index.json"):(p=e.join(a$2,".paradigm","scan-index.json"),n.existsSync(e.dirname(p))||n.mkdirSync(e.dirname(p),{recursive:true})),o.quiet||console.log(s.blue(`
|
|
3
3
|
\u{1F52D} Generating Paradigm Scan Index
|
|
4
4
|
`));let y,k=[e.join(a$2,".paradigm"),e.join(a$2,".paradigm","config.yaml")];for(let c of k)if(n.existsSync(c)&&n.statSync(c).isFile())try{let t=n.readFileSync(c,"utf8");y=e$1(t).scan;break}catch{}g.start("Aggregating symbols from purpose and gate files...");let r;try{r=await m(a$2);}catch(c){g.fail(s.red("Failed to aggregate symbols")),console.error(s.gray(c.message)),process.exit(1);}if(g.succeed(`Found ${r.symbols.length} symbols`),!o.quiet){let c={components:r.symbols.filter(t=>t.type==="component").length,flows:r.symbols.filter(t=>t.type==="flow").length,gates:r.symbols.filter(t=>t.type==="gate").length,signals:r.symbols.filter(t=>t.type==="signal").length,aspects:r.symbols.filter(t=>t.type==="aspect").length};console.log(s.gray(" Breakdown:"));for(let[t,u]of Object.entries(c))u>0&&console.log(s.gray(` ${t}: ${u}`));console.log();}g.start("Generating scan index...");let l=a({symbols:r.symbols,purposeFiles:r.purposeFiles,portalFiles:r.portalFiles},{projectName:m$1,visualTagMappings:y?.visualTagMappings,screenDefinitions:y?.screens});try{n.writeFileSync(p,b(l),"utf8"),g.succeed(s.green("Scan index generated"));}catch(c){g.fail(s.red("Failed to write scan index")),console.error(s.gray(c.message)),process.exit(1);}await a$1(a$2,r,{quiet:o.quiet});let d=await c(a$2,r.purposeFiles,{quiet:o.quiet});if(d&&Object.keys(d.flows).length>0){let c=e.join(a$2,".paradigm","flow-index.json");if(n.writeFileSync(c,JSON.stringify(d,null,2),"utf8"),!o.quiet){let t=Object.keys(d.symbolToFlows).length;g.succeed(s.green(`Flow index generated (${Object.keys(d.flows).length} flows, ${t} symbol mappings)`));}}return o.quiet||(console.log(s.gray(`
|
|
5
5
|
Output: ${p}`)),console.log(s.gray(` Components: ${Object.keys(l.components).length}`)),console.log(s.gray(` Features: ${Object.keys(l.features).length}`)),console.log(s.gray(` Flows: ${Object.keys(l.flows).length}`)),console.log(s.gray(` State: ${Object.keys(l.state).length}`)),console.log(s.gray(` Gates: ${Object.keys(l.gates).length}`)),console.log(s.gray(` Signals: ${Object.keys(l.signals).length}`)),console.log(s.gray(` Aspects: ${Object.keys(l.aspects).length}`)),console.log(),console.log(s.blue('\u2728 Scan index ready for "paradigm scan" queries')),console.log(s.gray(` Attach an image and say "paradigm scan" to map UI to code
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export{ca as getReindexToolsList,da as handleReindexTool,ea as rebuildStaticFiles}from'./chunk-QALPEMCU.js';import'./chunk-TMDPDIWA.js';import'./chunk-M4UMM6DC.js';import'./chunk-GRZQIKST.js';import'./chunk-6QXBXZF6.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-LAYBUKMB.js';import'./chunk-5TAVYPOV.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {n,m,o,t as t$1,J}from'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as i from'fs';import*as l from'path';import t from'chalk';import {execSync}from'child_process';import*as j from'js-yaml';var O=/[@#$%^!?&~][a-zA-Z][a-zA-Z0-9_-]*/g,W=[/\.(get|post|put|patch|delete)\s*\(\s*['"`]([^'"`]+)['"`]/gi,/export\s+(async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)/gi];async function z(r={}){let s=process.cwd(),$=a.command("review").start("Running review pipeline",{cwd:s}),f=[],c=[];try{if(r.pr)f=execSync(`gh pr diff ${r.pr} --name-only`,{cwd:s,encoding:"utf8",timeout:15e3}).trim().split(`
|
|
3
|
+
`).filter(Boolean);else {let e=execSync("git diff --cached --name-only",{cwd:s,encoding:"utf8",timeout:5e3}).trim(),o=execSync("git diff --name-only",{cwd:s,encoding:"utf8",timeout:5e3}).trim();f=[...new Set([...e.split(`
|
|
4
|
+
`).filter(Boolean),...o.split(`
|
|
5
|
+
`).filter(Boolean)])];}}catch(e){let o=e.message;r.json||a.command("review").error(`Failed to get changed files: ${o}`),$.error("Failed to get changed files"),r.ci&&process.exit(1);return}if(f.length===0){r.json?console.log(JSON.stringify({findings:[],summary:{total:0,blocking:0,improvements:0,notes:0}})):console.log(t.green(`
|
|
6
|
+
No modified files to review.
|
|
7
|
+
`)),$.success("No files to review");return}try{for(let e of f)if(e.endsWith(".purpose")){let o=l.join(s,e);if(i.existsSync(o)){let m=i.readFileSync(o,"utf-8").match(O)||[];c.push(...m);}}c=[...new Set(c)];}catch{}let n$1=[],h=n();try{let e=await m(s);h=o(e);}catch{}let R=l.join(s,"portal.yaml"),d=null;if(i.existsSync(R))try{d=j.load(i.readFileSync(R,"utf-8"));}catch{}for(let e of c)t$1(h,e).length===0&&n$1.push({type:"blocking",category:"purpose-coverage",message:`Symbol "${e}" is not registered in any .purpose file`,suggestion:"Add to nearest .purpose file using paradigm_purpose_add_component."});let F=d?.routes?Object.keys(d.routes):[];for(let e of f){let o=l.isAbsolute(e)?e:l.join(s,e);if(!i.existsSync(o))continue;let a;try{a=i.readFileSync(o,"utf-8");}catch{continue}for(let m of W){m.lastIndex=0;let y;for(;(y=m.exec(a))!==null;){let g=y[2]||y[0];g&&g.startsWith("/")&&(F.some(b=>b.replace(/\s+(GET|POST|PUT|PATCH|DELETE)\s*$/,"").trim()===g)||n$1.push({type:d?"blocking":"improvement",category:"route-coverage",message:`Route "${g}" in ${e} not in portal.yaml`,file:e,suggestion:"Add route to portal.yaml with ^gates."}));}}}let N=d?Object.keys(d.gates||{}).map(e=>e.startsWith("^")?e.slice(1):e):[];for(let e of c)if(e.startsWith("^")){let o=e.slice(1);N.includes(o)||n$1.push({type:"blocking",category:"portal-compliance",message:`Gate "${e}" referenced but not declared in portal.yaml`,suggestion:`Add ${e} to portal.yaml with description and check expression.`});}try{for(let e of J(h,c,s))n$1.push({type:"improvement",category:"aspect-anchors",message:e.kind==="no-anchors"?`Aspect "${e.aspectSymbol}" has no code anchors`:`Aspect "${e.aspectSymbol}" anchor "${e.anchorRaw}" points to missing file`,suggestion:`Update anchors for ${e.aspectSymbol} in .purpose file.`});}catch{}for(let e of c){let o=t$1(h,e);if(o.length===0)continue;let a=o[0];a.parentSymbol&&t$1(h,a.parentSymbol).length===0&&n$1.push({type:"improvement",category:"broken-reference",message:`Symbol "${e}" references parent "${a.parentSymbol}" which does not exist`,suggestion:"Create the parent symbol or update the parent reference."});}if(r.deep)for(let e of f){let o=l.isAbsolute(e)?e:l.join(s,e);if(!i.existsSync(o))continue;let a=l.extname(e);if(![".ts",".tsx",".js",".jsx",".py",".rs"].includes(a))continue;let m;try{m=i.readFileSync(o,"utf-8");}catch{continue}let y=m.split(`
|
|
8
|
+
`);for(let g=0;g<y.length;g++){let p=y[g],b=g+1;/\beval\s*\(/.test(p)&&!p.trimStart().startsWith("//")&&n$1.push({type:"blocking",category:"security",message:"eval() detected \u2014 potential code injection risk",file:e,line:b,suggestion:"Replace eval() with a safer alternative."}),/(?:password|secret|api_key|apikey|token)\s*[:=]\s*['"][^'"]{8,}['"]/i.test(p)&&!p.trimStart().startsWith("//")&&!p.trimStart().startsWith("#")&&n$1.push({type:"blocking",category:"security",message:"Possible hardcoded secret detected",file:e,line:b,suggestion:"Move secrets to environment variables or a secrets manager."}),/\bconsole\.(log|debug|info|warn)\b/.test(p)&&!e.includes("test")&&!e.includes("spec")&&(p.trimStart().startsWith("//")||n$1.push({type:"note",category:"convention",message:"console.log detected \u2014 use Paradigm logger instead",file:e,line:b,suggestion:"Use log.component(), log.gate(), etc. from the Paradigm logger."}));}}let u=n$1.filter(e=>e.type==="blocking"),w=n$1.filter(e=>e.type==="improvement"),S=n$1.filter(e=>e.type==="note");if(r.json)console.log(JSON.stringify({findings:n$1,summary:{total:n$1.length,blocking:u.length,improvements:w.length,notes:S.length,filesReviewed:f.length,symbolsChecked:c.length}},null,2));else if(console.log(t.blue(`
|
|
9
|
+
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`)),console.log(t.blue("\u2502")+t.white.bold(" paradigm review ")+t.blue("\u2502")),console.log(t.blue("\u2502")+t.gray(` ${f.length} files, ${c.length} symbols${r.deep?", deep mode":""}`.padEnd(50))+t.blue("\u2502")),console.log(t.blue(`\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
10
|
+
`)),n$1.length===0)console.log(t.green(` All checks passed \u2014 no findings.
|
|
11
|
+
`));else {if(u.length>0){console.log(t.red.bold(` Blocking (${u.length})`));for(let e of u)console.log(` ${t.red("x")} ${e.message}`),e.file&&console.log(` ${t.gray(e.file)}${e.line?`:${e.line}`:""}`),e.suggestion&&console.log(` ${t.yellow("->")} ${e.suggestion}`);console.log("");}if(w.length>0){console.log(t.yellow(` Improvements (${w.length})`));for(let e of w)console.log(` ${t.yellow("*")} ${e.message}`),e.file&&console.log(` ${t.gray(e.file)}${e.line?`:${e.line}`:""}`),e.suggestion&&console.log(` ${t.yellow("->")} ${e.suggestion}`);console.log("");}if(S.length>0){console.log(t.gray(` Notes (${S.length})`));for(let e of S)console.log(` ${t.gray("o")} ${e.message}`),e.file&&console.log(` ${t.gray(e.file)}${e.line?`:${e.line}`:""}`);console.log("");}}r.ci&&u.length>0&&($.error(`${u.length} blocking findings`),process.exit(1)),$.success(`Review complete: ${n$1.length} findings`);}export{z as reviewCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {D as D$1,m,o,r,p,x,y}from'./chunk-
|
|
2
|
+
import {D as D$1,m,o,r,p,x,y}from'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as u from'path';import e from'chalk';import F from'ora';function I(s,t){let r$1=r(t,"flow"),a=[];for(let p of r$1){let l=p.data,i=l?.sequence||l?.gates||p.references,g=i.indexOf(s);g!==-1&&a.push({flow:p.symbol,position:g+1,total:i.length});}return a}function O(s){let t=u.dirname(s),r=`${t}/**/*.test.{ts,tsx}`,a=`npm test -- --testPathPattern="${t}"`;return {testPath:r,testCommand:a}}function C(s){return {components:s.filter(t=>t.type==="component").map(t=>t.symbol),gates:s.filter(t=>t.type==="gate").map(t=>t.symbol),signals:s.filter(t=>t.type==="signal").map(t=>t.symbol),flows:s.filter(t=>t.type==="flow").map(t=>t.symbol),aspects:s.filter(t=>t.type==="aspect").map(t=>t.symbol)}}function B(s,t){let r=p(t,s);if(!r)return null;let a=x(t,s),p$1=y(t,s),l=C(a),i=C(p$1),g=I(s,t),{testPath:m,testCommand:y$1}=O(r.filePath);return {symbol:r.symbol,type:r.type,path:r.filePath,description:r.description,requires:r.references,requiredBy:r.referencedBy,downstream:{components:l.components,signals:l.signals,aspects:l.aspects},upstream:{gates:i.gates,flows:i.flows},partOfFlows:g,testPath:m,testCommand:y$1}}async function D(s,t,r$1={}){let a$1=process.cwd(),p=t?u.resolve(a$1,t):a$1,l=D$1(s);l||(console.log(e.red(`
|
|
3
3
|
\u274C Invalid symbol format: ${s}`)),console.log(e.gray(" Symbols must start with @, #, ^, !, $, %, ~, or ?")),console.log(e.gray(` Example: paradigm ripple @checkout
|
|
4
4
|
`)),process.exit(1)),!r$1.quiet&&!r$1.json&&console.log(e.blue(`
|
|
5
5
|
\u{1F30A} Ripple Analysis for ${e.cyan(s)}
|
package/dist/sentinel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {Command}from'commander';import {createRequire}from'module';var r=createRequire(import.meta.url),{version:c}=r("../package.json"),o=new Command;o.name("sentinel").description("Semantic error monitoring \u2014 errors that speak your language").version(c);o.command("defend",{isDefault:true}).description("Launch the Sentinel dashboard").option("-p, --port <port>","Port number","3838").option("--no-open","Don't open browser").action(async t=>{let{launchDashboard:i}=await import('./commands-
|
|
2
|
+
import {Command}from'commander';import {createRequire}from'module';var r=createRequire(import.meta.url),{version:c}=r("../package.json"),o=new Command;o.name("sentinel").description("Semantic error monitoring \u2014 errors that speak your language").version(c);o.command("defend",{isDefault:true}).description("Launch the Sentinel dashboard").option("-p, --port <port>","Port number","3838").option("--no-open","Don't open browser").action(async t=>{let{launchDashboard:i}=await import('./commands-4ENQMHFO.js');await i(t);});o.command("init").description("Initialize Sentinel in current project").option("--detect","Auto-detect symbols from codebase").action(async t=>{let{initProject:i}=await import('./commands-4ENQMHFO.js');await i(t);});var n=o.command("triage").description("Incident triage");n.command("list").description("List incidents").option("-s, --status <status>","Filter by status (open, investigating, resolved, wont-fix)").option("-e, --env <env>","Filter by environment").option("--symbol <symbol>","Filter by symbol").option("-n, --limit <n>","Max results","10").action(async t=>{let{triageList:i}=await import('./commands-4ENQMHFO.js');await i(t);});n.command("show <id>").description("Show incident details").option("--timeline","Include flow timeline").action(async(t,i)=>{let{triageShow:e}=await import('./commands-4ENQMHFO.js');await e(t,i);});n.command("resolve <id>").description("Resolve an incident").option("--pattern <id>","Pattern that resolved it").option("--commit <hash>","Fix commit").option("--notes <text>","Resolution notes").action(async(t,i)=>{let{triageResolve:e}=await import('./commands-4ENQMHFO.js');await e(t,i);});n.command("stats").description("Show incident statistics").option("-p, --period <period>","Period (7d, 30d, 90d)","7d").action(async t=>{let{triageStats:i}=await import('./commands-4ENQMHFO.js');await i(t);});o.parse();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b,c as c$2}from'./chunk-W7C6FFMO.js';import'./chunk-4TXOVRWD.js';import {g}from'./chunk-
|
|
2
|
+
import {b,c as c$2}from'./chunk-W7C6FFMO.js';import'./chunk-4TXOVRWD.js';import {g}from'./chunk-4GC35IFF.js';import {c as c$1}from'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import {d as d$1,b as b$1,a}from'./chunk-VIG5LSGZ.js';import'./chunk-5TAVYPOV.js';import*as n from'fs';import*as c from'path';import*as D from'readline';import e from'chalk';function x(){return D.createInterface({input:process.stdin,output:process.stdout})}async function d(s,r){return new Promise(t=>{s.question(r,o=>{t(o.trim());});})}async function p(s,r,t){console.log(`
|
|
3
3
|
${e.cyan(r)}`),t.forEach((i,u)=>{console.log(e.gray(` ${u+1}) `)+i.name);});let o=await d(s,e.white(`Enter number (1-${t.length}): `)),a=parseInt(o,10)-1;return a>=0&&a<t.length?t[a].value:t[0].value}async function k(s,r,t){return console.log(`
|
|
4
4
|
${e.cyan(r)}`),t.forEach((i,u)=>{console.log(e.gray(` ${u+1}) `)+i.name);}),(await d(s,e.white("Enter numbers separated by commas (e.g., 1,2,3): "))).split(",").map(i=>parseInt(i.trim(),10)-1).filter(i=>i>=0&&i<t.length).map(i=>t[i].value)}function A(s){let r={};for(let t of ["src","app","lib","packages"])if(n.existsSync(c.join(s,t))){r.sourceDir=t;break}if(r.sourceDir){let t=c.join(s,r.sourceDir);try{let o=n.readdirSync(t,{withFileTypes:!0});r.directories=o.filter(a=>a.isDirectory()).map(a=>a.name).filter(a=>!a.startsWith(".")&&!a.startsWith("_"));}catch{}}return r}function I(s,r){let t={version:"1.0","agent-guidelines":{overview:`${r} uses Paradigm for structured AI context management.`,"how-to-use":["Check .purpose files in directories before making changes","Run `paradigm status` to see all symbols in the project","Run `paradigm visualize` to explore the Dreamscape","Reference symbols using @ # $ % ~ ^ ! ? prefixes"],"update-rules":["When adding a feature, create/update the nearest .purpose file","When adding authorization, update portal.yaml","When exploring ideas, add to .premise with ? prefix","Run `paradigm cursorrules` after updating .paradigm"]},"symbol-system":a,states:{},"purpose-required":[],conventions:b$1};if(t.states||(t.states={}),s.hasAuth&&s.hasAuth!=="none"&&(t.states.user={authenticated:{type:"boolean",default:false,description:"User is logged in"},role:{type:"enum",values:["guest","user","admin"],description:"User access level"}},s.hasAuth==="session"&&(t.states.user.sessionExpiry={type:"string",description:"Session expiration time"})),s.hasSubscription&&s.hasSubscription!=="none"&&(t.states.user||(t.states.user={}),s.hasSubscription==="tiers"?t.states.user.subscription={type:"enum",values:["free","trial","pro","enterprise"],description:"Subscription tier"}:t.states.user.isPremium={type:"boolean",default:false,description:"Has premium access"}),s.hasGates==="yes"&&t["agent-guidelines"]["how-to-use"].push("Check portal.yaml for authorization rules before modifying access control"),s.directories&&s.directories.length>0&&s.sourceDir&&(t["purpose-required"]=s.directories.map(o=>({pattern:`${s.sourceDir}/${o}/*`,depth:1}))),s.customStates){let o=s.customStates.split(",").map(a=>a.trim()).filter(Boolean);for(let a of o){let i=a.split(".");if(i.length>=2){let u=i[0],g=i.slice(1).join(".");t.states[u]||(t.states[u]={}),t.states[u][g]={type:"boolean",description:`Custom state: ${a}`};}}}return t}async function j(s){let r=x(),t={};console.log(e.blue(`
|
|
5
5
|
\u{1F305} Paradigm Setup Wizard
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a as a$5,d as d$3,b as b$2,e as e$1,f}from'./chunk-Z72SDTBJ.js';import {b}from'./chunk-
|
|
2
|
+
import {a as a$5,d as d$3,b as b$2,e as e$1,f}from'./chunk-Z72SDTBJ.js';import {b}from'./chunk-XKNJSPB5.js';import'./chunk-MU5YWTNE.js';import'./chunk-TYWB5IQJ.js';import'./chunk-AMLD7IYC.js';import'./chunk-FYDRENK7.js';import'./chunk-HXGYVS2N.js';import {d as d$2}from'./chunk-TQOT2LBO.js';import'./chunk-Y4XFVDZC.js';import {a as a$7}from'./chunk-5RFISGUW.js';import {d as d$1}from'./chunk-S3UVQ5RV.js';import {a as a$4,b as b$1}from'./chunk-GE3GQALR.js';import {a as a$8}from'./chunk-XQLO5URP.js';import'./chunk-EKZDFEJW.js';import {a as a$2}from'./chunk-QDP4G53M.js';import {b as b$3}from'./chunk-MBSY57RN.js';import'./chunk-4TXOVRWD.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import {a as a$3}from'./chunk-UIKLE3WD.js';import {a as a$6}from'./chunk-UZ5H7K6Q.js';import'./chunk-LPBCQM5Y.js';import'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-YNDPSWOE.js';import'./chunk-VIG5LSGZ.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as a from'fs';import*as ne from'os';import*as d from'path';import e from'chalk';import Se from'ora';import*as h from'js-yaml';import*as C from'fs/promises';var ae=[{path:".paradigm/config.yaml",defaultContent:['version: "2.0"','project: ""','description: ""','initialized: ""'].join(`
|
|
3
3
|
`)+`
|
|
4
4
|
`},{path:".paradigm/agents.yaml",defaultContent:['version: "1.0"',"agents: []"].join(`
|
|
5
5
|
`)+`
|
|
@@ -57,4 +57,4 @@ workspace: "${u}"
|
|
|
57
57
|
workspace: "${j}"
|
|
58
58
|
`;a.writeFileSync(t,re,"utf8"),console.log(e.green(` \u2713 Found workspace: ${e.cyan(j)} (added to config.yaml)`));break}let y=d.dirname(p);if(y===p)break;p=y;}}}catch(s){a$1.operation("shift").debug("Workspace auto-detect failed",{error:s.message});}}if(!d$2(n)||o.force){console.log(e.cyan(" Step 2/6: Initializing team configuration..."));try{await b(n,{force:o.force,json:!1,configureModels:o.configureModels||!1,noConfigureModels:!o.configureModels}),console.log(e.green(` \u2713 Team configuration initialized
|
|
59
59
|
`));}catch(t){console.log(e.yellow(` \u26A0 Team init warning: ${t.message}
|
|
60
|
-
`));}}else i.succeed(e.gray("Step 2/6: Team already configured (use --force to reinit)"));if(o.force){let t=d.join(n,".paradigm",".compliance-nomination-skipped");if(a.existsSync(t))try{a.unlinkSync(t);}catch{}}let S=d.join(n,".paradigm","roster.yaml");if(!a.existsSync(S)||o.force)try{let t=a$4(n),s=b$1[t]||b$1.generic,c={version:"1.0",project:l,type:t,active:s.sort()};a.writeFileSync(S,h.dump(c,{lineWidth:-1,noRefs:!0}),"utf8"),console.log(e.green(` \u2713 Agent roster set: ${e.cyan(s.length)} agents for ${e.cyan(t)}`));}catch(t){a$1.operation("shift").debug("Roster setup failed",{error:t.message});}else try{let s=h.load(a.readFileSync(S,"utf8"))?.active?.length??0;console.log(e.gray(` \u2713 Agent roster exists (${s} agents active)`));}catch{console.log(e.gray(" \u2713 Agent roster exists"));}await be(n,S,o);{let t=d.join(n,".paradigm","adoptions.yaml"),s=a.existsSync(t);try{let c=a$4(n),p=s?await a$5(n):null,u=p&&Object.keys(p.agents).length>0;if(!u&&a.existsSync(S))p=await d$3(n),await b$2(n,p),a$1.operation("shift").debug("Migrated roster to adoptions",{count:Object.keys(p.agents).length});else if(!u){p=e$1(c);let g=a.existsSync(S)?h.load(a.readFileSync(S,"utf8")):{active:[]},y=new Date().toISOString();for(let j of g.active||[])p.agents[j]={adopted:y,source:oe.has(j)?"core":"ecosystem",defaultsAccepted:!0};Object.keys(p.agents).length>0&&await b$2(n,p);}if(p&&Object.keys(p.agents).length>0){let g=ke(p),y=f(g,c);console.log(y),console.log(e.green(` \u2713 ${Object.keys(p.agents).length} agents adopted`));}if(p&&p.agents.compliance){let g=d.join(n,".paradigm","authority.yaml");if(!a.existsSync(g))try{let{writeArchetypeDefaults:y}=await import('./authority-GCMPX7RW.js');await y(n,"archetype-default"),a$1.operation("shift").debug("Wrote archetype-default authority.yaml",{source:"default-adoption"});}catch(y){a$1.operation("shift").debug("Authority defaults write failed",{error:y.message});}}}catch(c){a$1.operation("shift").debug("Adoption ceremony failed",{error:c.message});}}{let t=d.join(r,"config.yaml");if(a.existsSync(t))try{let s=a.readFileSync(t,"utf8"),c=h.load(s);if(!c["model-resolution"]||o.force){let{ModelDiscovery:p}=await import('./model-discovery-HMB3YI4L.js'),g=new p(n).detectEnvironment(),y;g==="claude-code"?y={"tier-1":"opus","tier-2":"sonnet","tier-3":"haiku"}:g==="cursor"?y={"tier-1":"sonnet","tier-2":"sonnet","tier-3":"haiku"}:y={"tier-1":"sonnet","tier-2":"sonnet","tier-3":"sonnet"},c["model-resolution"]=y,a.writeFileSync(t,h.dump(c,{lineWidth:-1,noRefs:!0}),"utf8"),console.log(e.green(` \u2713 Model tiers configured for ${e.cyan(g)}: tier-1=${y["tier-1"]}, tier-2=${y["tier-2"]}, tier-3=${y["tier-3"]}`));}}catch(s){a$1.operation("shift").debug("Model tier config failed",{error:s.message});}}try{let{ensureEnforcementDefaults:t}=await import('./enforcement-VRE3WZOI.js');t(n)&&(console.log(e.green(` \u2713 Enforcement config initialized (${e.cyan("none")} preset)`)),console.log(e.dim(" Enforcement: none \u2014 symbol tracking available when you're ready. Rune will guide you.")));}catch(t){a$1.operation("shift").debug("Enforcement config setup failed",{error:t.message});}{i.start("Ensuring core files...");try{let{created:t,existed:s}=await Q(n);i.succeed(e.green(`Core files ensured: ${e.cyan(String(t.length))} created, ${e.cyan(String(s.length))} already existed`));}catch(t){i.warn(e.yellow(`Guaranteed files warning: ${t.message}`));}}if(o.quick)i.succeed(e.gray("Step 3/6: Skipped scan (--quick mode)"));else {i.start("Step 3/6: Scanning and indexing symbols...");try{await b$3(n,{quiet:!0}),i.succeed(e.green("Symbols indexed"));}catch(t){i.warn(e.yellow(`Scan warning: ${t.message}`));}}{let t=d.join(r,"config.yaml");if(a.existsSync(t))try{if(h.load(a.readFileSync(t,"utf8")).workspace){i.start("Step 3b/6: Reindexing workspace members...");try{let{workspaceReindexCommand:c}=await import('./workspace-
|
|
60
|
+
`));}}else i.succeed(e.gray("Step 2/6: Team already configured (use --force to reinit)"));if(o.force){let t=d.join(n,".paradigm",".compliance-nomination-skipped");if(a.existsSync(t))try{a.unlinkSync(t);}catch{}}let S=d.join(n,".paradigm","roster.yaml");if(!a.existsSync(S)||o.force)try{let t=a$4(n),s=b$1[t]||b$1.generic,c={version:"1.0",project:l,type:t,active:s.sort()};a.writeFileSync(S,h.dump(c,{lineWidth:-1,noRefs:!0}),"utf8"),console.log(e.green(` \u2713 Agent roster set: ${e.cyan(s.length)} agents for ${e.cyan(t)}`));}catch(t){a$1.operation("shift").debug("Roster setup failed",{error:t.message});}else try{let s=h.load(a.readFileSync(S,"utf8"))?.active?.length??0;console.log(e.gray(` \u2713 Agent roster exists (${s} agents active)`));}catch{console.log(e.gray(" \u2713 Agent roster exists"));}await be(n,S,o);{let t=d.join(n,".paradigm","adoptions.yaml"),s=a.existsSync(t);try{let c=a$4(n),p=s?await a$5(n):null,u=p&&Object.keys(p.agents).length>0;if(!u&&a.existsSync(S))p=await d$3(n),await b$2(n,p),a$1.operation("shift").debug("Migrated roster to adoptions",{count:Object.keys(p.agents).length});else if(!u){p=e$1(c);let g=a.existsSync(S)?h.load(a.readFileSync(S,"utf8")):{active:[]},y=new Date().toISOString();for(let j of g.active||[])p.agents[j]={adopted:y,source:oe.has(j)?"core":"ecosystem",defaultsAccepted:!0};Object.keys(p.agents).length>0&&await b$2(n,p);}if(p&&Object.keys(p.agents).length>0){let g=ke(p),y=f(g,c);console.log(y),console.log(e.green(` \u2713 ${Object.keys(p.agents).length} agents adopted`));}if(p&&p.agents.compliance){let g=d.join(n,".paradigm","authority.yaml");if(!a.existsSync(g))try{let{writeArchetypeDefaults:y}=await import('./authority-GCMPX7RW.js');await y(n,"archetype-default"),a$1.operation("shift").debug("Wrote archetype-default authority.yaml",{source:"default-adoption"});}catch(y){a$1.operation("shift").debug("Authority defaults write failed",{error:y.message});}}}catch(c){a$1.operation("shift").debug("Adoption ceremony failed",{error:c.message});}}{let t=d.join(r,"config.yaml");if(a.existsSync(t))try{let s=a.readFileSync(t,"utf8"),c=h.load(s);if(!c["model-resolution"]||o.force){let{ModelDiscovery:p}=await import('./model-discovery-HMB3YI4L.js'),g=new p(n).detectEnvironment(),y;g==="claude-code"?y={"tier-1":"opus","tier-2":"sonnet","tier-3":"haiku"}:g==="cursor"?y={"tier-1":"sonnet","tier-2":"sonnet","tier-3":"haiku"}:y={"tier-1":"sonnet","tier-2":"sonnet","tier-3":"sonnet"},c["model-resolution"]=y,a.writeFileSync(t,h.dump(c,{lineWidth:-1,noRefs:!0}),"utf8"),console.log(e.green(` \u2713 Model tiers configured for ${e.cyan(g)}: tier-1=${y["tier-1"]}, tier-2=${y["tier-2"]}, tier-3=${y["tier-3"]}`));}}catch(s){a$1.operation("shift").debug("Model tier config failed",{error:s.message});}}try{let{ensureEnforcementDefaults:t}=await import('./enforcement-VRE3WZOI.js');t(n)&&(console.log(e.green(` \u2713 Enforcement config initialized (${e.cyan("none")} preset)`)),console.log(e.dim(" Enforcement: none \u2014 symbol tracking available when you're ready. Rune will guide you.")));}catch(t){a$1.operation("shift").debug("Enforcement config setup failed",{error:t.message});}{i.start("Ensuring core files...");try{let{created:t,existed:s}=await Q(n);i.succeed(e.green(`Core files ensured: ${e.cyan(String(t.length))} created, ${e.cyan(String(s.length))} already existed`));}catch(t){i.warn(e.yellow(`Guaranteed files warning: ${t.message}`));}}if(o.quick)i.succeed(e.gray("Step 3/6: Skipped scan (--quick mode)"));else {i.start("Step 3/6: Scanning and indexing symbols...");try{await b$3(n,{quiet:!0}),i.succeed(e.green("Symbols indexed"));}catch(t){i.warn(e.yellow(`Scan warning: ${t.message}`));}}{let t=d.join(r,"config.yaml");if(a.existsSync(t))try{if(h.load(a.readFileSync(t,"utf8")).workspace){i.start("Step 3b/6: Reindexing workspace members...");try{let{workspaceReindexCommand:c}=await import('./workspace-6POCBPDY.js');await c({quiet:!0}),i.succeed(e.green("Workspace members reindexed"));}catch(c){i.warn(e.yellow(`Workspace reindex: ${c.message}`));}}}catch(s){a$1.operation("shift").debug("Workspace config read failed",{error:s.message});}}let v=d.join(n,"portal.yaml");a.existsSync(v)||a.writeFileSync(v,h.dump({version:"1.0.0",gates:{},routes:{}},{lineWidth:-1,noRefs:true}),"utf8");let E=d.join(n,".paradigm","lore");a.existsSync(E)||a.mkdirSync(E,{recursive:true});let R=d.join(n,".paradigm","university");for(let t of ["content/notes","content/policies","content/quizzes","content/paths","diplomas"]){let s=d.join(R,t);a.existsSync(s)||a.mkdirSync(s,{recursive:true});}let N=d.join(R,"config.yaml");if(!a.existsSync(N)){let t="Project";try{let c=d.join(n,".paradigm","config.yaml");if(a.existsSync(c)){let p=h.load(a.readFileSync(c,"utf8"));p.project&&typeof p.project=="string"&&(t=p.project);}}catch{}let s={branding:{name:`${t} University`,tagline:`Learn the ${t} codebase`,institution:t},theme:{primary:"#6366f1",secondary:"#8b5cf6",accent:"#f59e0b",background:"#0f172a",surface:"#1e293b",text:"#f8fafc",textMuted:"#94a3b8",success:"#22c55e",error:"#ef4444",font:"Inter, system-ui, sans-serif"},content:{categories:[],defaultDifficulty:"beginner",requireApproval:false},diplomas:{includeGlobalPLSAT:true}};a.writeFileSync(N,h.dump(s,{lineWidth:-1,noRefs:true}),"utf8");}i.start("Step 4/6: Syncing IDE configurations...");try{let t=o.ide?[o.ide]:["claude","cursor","copilot","windsurf","agents"],s=[];for(let c of t)try{await a$6(c,{quiet:!0,force:!0}),s.push(c);}catch{}s.length>0?i.succeed(e.green(`IDE configs synced: ${s.join(", ")}`)):i.warn(e.yellow("No IDE configs to sync"));}catch(t){i.warn(e.yellow(`Sync warning: ${t.message}`));}i.start("Step 5/6: Installing hooks...");try{await a$7({force:o.force}),i.succeed(e.green("Hooks installed (git + Claude Code + Cursor)"));}catch(t){i.warn(e.yellow(`Hooks warning: ${t.message}`));}if(o.verify){i.start("Step 6/6: Running health checks...");try{await a$8({quiet:!0})?i.succeed(e.green("All health checks passed")):i.warn(e.yellow("Some health checks need attention"));}catch(t){i.warn(e.yellow(`Doctor warning: ${t.message}`));}}else i.succeed(e.gray("Step 6/6: Skipped verify (use --verify to check health)"));console.log(""),console.log(e.blue("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510")),console.log(e.blue("\u2502")+e.white.bold(" \u2728 Paradigm shift complete! ")+e.blue("\u2502")),console.log(e.blue("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")),console.log(""),console.log(e.white(" Created/Updated:")),console.log(e.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));let O=[{path:".paradigm/config.yaml",desc:"Project configuration"},{path:".paradigm/navigator.yaml",desc:"Symbol navigation map"},{path:".paradigm/agents.yaml",desc:"Team agent configuration"},{path:".paradigm/adoptions.yaml",desc:"Agent adoption records"},{path:".purpose",desc:"Root feature definitions"},{path:".paradigm/lore/",desc:"Project lore timeline",isDir:true},{path:"portal.yaml",desc:"Authorization gates"},{path:".paradigm/roster.yaml",desc:"Agent roster for this project"},{path:"CLAUDE.md",desc:"Claude Code AI instructions"},{path:"AGENTS.md",desc:"Universal AI agent instructions"},{path:".cursor/rules/",desc:"Cursor AI instructions",isDir:true},{path:".claude/hooks/",desc:"Claude Code enforcement hooks",isDir:true,optional:true},{path:".cursor/hooks/",desc:"Cursor enforcement hooks",isDir:true,optional:true}],W=d.join(r,"config.yaml");if(a.existsSync(W))try{let t=h.load(a.readFileSync(W,"utf8"));if(typeof t.workspace=="string"){let s=d.resolve(n,t.workspace),c=d.relative(n,s);O.push({path:c,desc:"Multi-project workspace",optional:!0});}}catch(t){a$1.operation("shift").debug("Summary config read failed",{error:t.message});}for(let t of O){let s=d.join(n,t.path);a.existsSync(s)?console.log(e.green(" \u2713 ")+e.white(t.path.padEnd(28))+e.gray(t.desc)):t.optional||console.log(e.yellow(" \u25CB ")+e.gray(t.path.padEnd(28))+e.gray(`(${t.desc})`));}try{let t=await Z(n),s=ee(t);s&&console.log(s);}catch(t){a$1.operation("shift").debug("Recommendations engine failed",{error:t.message}),console.log(""),console.log(e.white(" Next steps:")),console.log(e.gray(" "+"\u2500".repeat(49))),console.log(e.white(" 1. ")+e.gray("Edit ")+e.cyan(".purpose")+e.gray(" to define your features")),console.log(e.white(" 2. ")+e.gray("Run ")+e.cyan("paradigm shift --verify")+e.gray(" to check health")),console.log("");}try{let{captureSnapshot:t,seedMetricsConsent:s}=await import('./metrics-UESGUHTA.js');s(n),t(n);}catch(t){a$1.operation("shift").debug("metrics snapshot failed",{error:t.message});}m.success("Paradigm shift complete",{project:l});}export{be as runComplianceNominationStep,Le as shiftCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,k,f as f$1}from'./chunk-
|
|
2
|
+
import {c,k,f as f$1}from'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as n from'fs';import*as f from'path';import o from'chalk';import y from'ora';async function w(t,r){let m=process.cwd(),i=f.join(m,".premise");console.log(o.blue(`
|
|
3
3
|
\u{1F4F8} Creating Snapshot...
|
|
4
4
|
`));let e=y("Loading .premise file...").start();try{n.existsSync(i)||(e.fail(".premise file not found"),console.log(o.yellow(`
|
|
5
5
|
Run "paradigm init" first to create a .premise file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {m,o as o$1,B}from'./chunk-
|
|
2
|
+
import {m,o as o$1,B}from'./chunk-4GC35IFF.js';import {e}from'./chunk-JIXHEBGK.js';import {e as e$1}from'./chunk-ZJQY5PPP.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as l from'fs';import*as a from'path';import o from'chalk';import G from'ora';async function D(){let t=process.cwd();console.log(o.blue(`
|
|
3
3
|
\u{1F4CA} Paradigm Status
|
|
4
4
|
`)),console.log(o.gray("\u2500".repeat(40)));let i=a$1.command("status").start("Getting project status"),r=G("Scanning project...").start(),p=l.existsSync(a.join(t,".premise")),m$1=l.existsSync(a.join(t,".purpose")),f=l.existsSync(a.join(t,"portal.yaml"));r.stop(),console.log(o.white(`
|
|
5
5
|
Configuration Files`)),console.log(o.gray("\u2500".repeat(40))),console.log(` .premise: ${p?o.green("\u2713 Found"):o.yellow("\u25CB Not found")}`),console.log(` .purpose: ${m$1?o.green("\u2713 Found"):o.yellow("\u25CB Not found")}`),console.log(` portal.yaml: ${f?o.green("\u2713 Found"):o.yellow("\u25CB Not found")}`),r.start("Counting files...");let u=await e(t),y=await e$1(t);if(r.stop(),console.log(o.white(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {m}from'./chunk-
|
|
2
|
+
import {m}from'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import {c as c$1,a}from'./chunk-YNDPSWOE.js';import'./chunk-VIG5LSGZ.js';import'./chunk-5TAVYPOV.js';import*as n from'fs';import*as c from'path';import o from'chalk';import S from'ora';async function F(){let p=process.cwd(),x=c.basename(p),l=S();console.log(o.blue(`
|
|
3
3
|
\u{1F4CA} Paradigm Summary
|
|
4
4
|
`));let r=c.join(p,".paradigm");(!n.existsSync(r)||!n.statSync(r).isDirectory())&&(console.log(o.red("\u274C No .paradigm/ directory found.")),console.log(o.gray(" Run `paradigm init` first.\n")),process.exit(1)),l.start("Aggregating symbols...");let m$1;try{m$1=await m(p),l.succeed(`Found ${m$1.symbols.length} symbols`);}catch(e){l.fail(o.red("Failed to aggregate symbols")),console.error(o.gray(e.message)),process.exit(1);}let u={components:{count:0,examples:[]},flows:{count:0,examples:[]},gates:{count:0,examples:[]},signals:{count:0,examples:[]},aspects:{count:0,examples:[]}};for(let e of m$1.symbols){let t=e.type,i=t==="component"?"components":t==="flow"?"flows":t==="gate"?"gates":t==="signal"?"signals":t==="aspect"?"aspects":null;i&&u[i]&&(u[i].count++,u[i].examples.length<3&&u[i].examples.push(e.symbol));}let a$1=[];n.existsSync(c.join(r,"config.yaml"))?a$1.push({check:"Config",status:"ok"}):a$1.push({check:"Config",status:"missing"});let k=["logger.md","probe.md","symbols.md"].every(e=>n.existsSync(c.join(r,"specs",e)));a$1.push({check:"Specs",status:k?"ok":"warn"});let j=n.existsSync(c.join(r,"docs"));a$1.push({check:"Docs",status:j?"ok":"warn"});let g=c$1(p);if(g.detected){let e=a(g.detected);e&&n.existsSync(c.join(p,e.outputPath))?a$1.push({check:`IDE (${g.detected})`,status:"ok"}):a$1.push({check:`IDE (${g.detected})`,status:"warn"});}let w=n.existsSync(c.join(r,"scan-index.json"))||n.existsSync(c.join(p,".paradigm-scan-index.json"));a$1.push({check:"Scan index",status:w?"ok":"missing"});let s=[];s.push(`# Project: ${x}`),s.push(""),s.push(`**Generated:** ${new Date().toISOString()}`),s.push("**Paradigm Version:** 0.2.0"),s.push(""),s.push("## Symbol Counts"),s.push(""),s.push("| Type | Count | Examples |"),s.push("|------|-------|----------|");for(let[e,t]of Object.entries(u))if(t.count>0){let i=t.examples.join(", ");s.push(`| ${e} | ${t.count} | ${i} |`);}s.push(""),s.push("## Source Files"),s.push(""),s.push(`- Purpose files: ${m$1.purposeFiles.length}`),s.push(`- Gate files: ${m$1.portalFiles.length}`),s.push(""),s.push("## Health Status"),s.push("");for(let e of a$1){let t=e.status==="ok"?"\u2713":e.status==="warn"?"\u26A0":"\u25CB";s.push(`- ${t} ${e.check}`);}s.push(""),s.push("---"),s.push("*Generated by `paradigm summary`*");let h=c.join(r,"project.md");l.start("Writing project.md...");try{n.writeFileSync(h,s.join(`
|
|
5
5
|
`),"utf8"),l.succeed(o.green("project.md generated"));}catch(e){l.fail(o.red("Failed to write project.md")),console.error(o.gray(e.message)),process.exit(1);}console.log(o.gray(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{e as teamAcceptCommand,f as teamCheckCommand,d as teamHandoffCommand,g as teamHistoryCommand,b as teamInitCommand,a as teamModelsCommand,h as teamResetCommand,c as teamStatusCommand}from'./chunk-
|
|
2
|
+
export{e as teamAcceptCommand,f as teamCheckCommand,d as teamHandoffCommand,g as teamHistoryCommand,b as teamInitCommand,a as teamModelsCommand,h as teamResetCommand,c as teamStatusCommand}from'./chunk-XKNJSPB5.js';import'./chunk-MU5YWTNE.js';import'./chunk-TYWB5IQJ.js';import'./chunk-AMLD7IYC.js';import'./chunk-FYDRENK7.js';import'./chunk-HXGYVS2N.js';import'./chunk-TQOT2LBO.js';import'./chunk-Y4XFVDZC.js';import'./chunk-EKZDFEJW.js';import'./chunk-LPBCQM5Y.js';import'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{h as registerTools}from'./chunk-
|
|
2
|
+
export{h as registerTools}from'./chunk-FI66YM6G.js';import'./chunk-QALPEMCU.js';import'./chunk-4UJ4NIEQ.js';import'./chunk-4N56FRNE.js';import'./chunk-Q527BPUF.js';import'./chunk-KLBH26PA.js';import'./chunk-RGSFU2YW.js';import'./chunk-TMDPDIWA.js';import'./chunk-JNSJVCTU.js';import'./chunk-XROULIQN.js';import'./chunk-ZUAUFZRJ.js';import'./chunk-3KVVC4WV.js';import'./chunk-M4UMM6DC.js';import'./chunk-GRZQIKST.js';import'./chunk-KAFQA7HV.js';import'./chunk-6QXBXZF6.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-LAYBUKMB.js';import'./chunk-DVZWCXB6.js';import'./chunk-QGZRM6ZB.js';import'./chunk-K7X3Z3GL.js';import'./chunk-5TAVYPOV.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{d as detectProjectRole,a as workspaceInitCommand,c as workspaceReindexCommand,b as workspaceStatusCommand}from'./chunk-
|
|
2
|
+
export{d as detectProjectRole,a as workspaceInitCommand,c as workspaceReindexCommand,b as workspaceStatusCommand}from'./chunk-S3UVQ5RV.js';import'./chunk-MBSY57RN.js';import'./chunk-4TXOVRWD.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';
|
package/package.json
CHANGED
package/dist/chunk-LWAIVOSF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {f,g,h,i,j,k,l,m,n}from'./chunk-JIXHEBGK.js';import {a,e}from'./chunk-ZJQY5PPP.js';import*as N from'fs';import*as v from'js-yaml';import {z as z$1}from'zod';import*as S from'path';var U={component:"#",flow:"$",gate:"^",signal:"!",aspect:"~"},Z={"#":"component",$:"flow","^":"gate","!":"signal","~":"aspect"},q=["#","$","^","!","~"];function H(e){return q.includes(e)}var ee=z$1.object({x:z$1.number(),y:z$1.number()}),te=z$1.object({x:z$1.number(),y:z$1.number(),zoom:z$1.number()}),z=z$1.object({path:z$1.string(),include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),G=z$1.object({id:z$1.string(),symbol:z$1.string(),type:z$1.enum(["feature","component","flow","state","aspect","gate","signal","idea"]),content:z$1.string().optional(),position:ee,tags:z$1.array(z$1.string()).optional(),created:z$1.string(),modified:z$1.string().optional()}),_=z$1.object({from:z$1.string(),to:z$1.string(),label:z$1.string().optional(),type:z$1.string().optional()}),oe=z$1.object({id:z$1.string(),name:z$1.string(),nodes:z$1.array(z$1.string()),color:z$1.string().optional()}),F=z$1.object({viewport:te,groups:z$1.array(oe).optional()}),ne=z$1.object({nodes:z$1.array(G),connections:z$1.array(_),layout:F}),se=z$1.object({id:z$1.string(),name:z$1.string(),timestamp:z$1.string(),description:z$1.string().optional(),state:ne}),re=z$1.object({version:z$1.string(),metadata:z$1.object({name:z$1.string(),created:z$1.string(),modified:z$1.string()}),sources:z$1.object({purpose:z$1.array(z).optional(),portal:z$1.array(z).optional()}),nodes:z$1.array(G),connections:z$1.array(_),layout:F,snapshots:z$1.array(se).optional()});function ge(e){let o=[],t;try{t=N.readFileSync(e,"utf8");}catch(n){return o.push(`Cannot read file: ${n.message}`),{data:null,errors:o,rawContent:void 0}}return ae(t)}function ae(e){let o=[],t=null;try{t=v.load(e);}catch(i){let l=i,f=l.mark?.line?l.mark.line+1:void 0;return o.push(`YAML syntax error: ${l.reason||i.message}${f?` (line ${f})`:""}`),{data:null,errors:o,rawContent:e}}if(t==null)return {data:V(),errors:[],rawContent:e};let n=re.safeParse(t);if(!n.success){for(let i of n.error.issues){let l=i.path.join(".");o.push(`Schema error at ${l||"/"}: ${i.message}`);}return {data:t,errors:o,rawContent:e}}return {data:n.data,errors:[],rawContent:e}}function V(e="Untitled"){let o=new Date().toISOString();return {version:"1.0.0",metadata:{name:e,created:o,modified:o},sources:{purpose:[{path:"./"}],portal:[{path:"./portal.yaml"}]},nodes:[],connections:[],layout:{viewport:{x:0,y:0,zoom:1}}}}function ie(e){return e.metadata.modified=new Date().toISOString(),v.dump(e,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function he(e="My Project"){return ie(V(e))}function be(e,o){return {...e,nodes:[...e.nodes,o],metadata:{...e.metadata,modified:new Date().toISOString()}}}function Se(e,o,t){return {...e,nodes:e.nodes.map(n=>n.id===o?{...n,position:t,modified:new Date().toISOString()}:n),metadata:{...e.metadata,modified:new Date().toISOString()}}}function $e(e,o){return e.connections.some(n=>n.from===o.from&&n.to===o.to)?e:{...e,connections:[...e.connections,o],metadata:{...e.metadata,modified:new Date().toISOString()}}}function we(e,o,t){let n={id:`snap-${Date.now()}`,name:o,timestamp:new Date().toISOString(),description:t,state:{nodes:[...e.nodes],connections:[...e.connections],layout:{...e.layout}}};return {...e,snapshots:[...e.snapshots||[],n],metadata:{...e.metadata,modified:new Date().toISOString()}}}async function ce(e$1,o){let t=[],n$1=[],i$1=[],l$1=[];if(e$1.sources.purpose)for(let c of e$1.sources.purpose){let u=S.resolve(o,c.path);try{let p=await f(u);i$1.push(...p.map(r=>r.filePath));let m$1=g(p);for(let[r,{item:a,filePath:d}]of m$1){let b=["feature",...a.tags||[]];t.push(y({id:`purpose-feature-${r}`,symbol:`#${r}`,type:"component",source:"purpose",filePath:d,data:a,description:a.description,tags:b,componentType:a.type,parentSymbol:a.parent,anchors:a.anchors?.map(Q=>T(Q))}));}let g$1=h(p);for(let[r,{item:a,filePath:d}]of g$1)t.push(y({id:`purpose-component-${r}`,symbol:`#${r}`,type:"component",source:"purpose",filePath:d,data:a,description:a.description,tags:a.tags,componentType:a.type,parentSymbol:a.parent,anchors:a.anchors?.map(b=>T(b))}));let $=i(p);for(let[r,{item:a,filePath:d}]of $)t.push(y({id:`purpose-gate-${r}`,symbol:`^${r}`,type:"gate",source:"purpose",filePath:d,data:a,description:a.description}));let Y=j(p);for(let[r,{item:a,filePath:d}]of Y)t.push(y({id:`purpose-state-${r}`,symbol:`#${r}`,type:"component",source:"purpose",filePath:d,data:a,description:a.description,tags:["state"]}));let k$1=k(p);for(let[r,{item:a,filePath:d}]of k$1)t.push(y({id:`purpose-flow-${r}`,symbol:`$${r}`,type:"flow",source:"purpose",filePath:d,data:a,description:a.description}));let X=l(p);for(let[r,{item:a,filePath:d}]of X)t.push(y({id:`purpose-signal-${r}`,symbol:`!${r}`,type:"signal",source:"purpose",filePath:d,data:a,description:a.description}));let K=m(p);for(let[r,{item:a,filePath:d}]of K)t.push(y({id:`purpose-aspect-${r}`,symbol:`~${r}`,type:"aspect",source:"purpose",filePath:d,data:a,description:a.description,anchors:a.anchors?.map(b=>T(b)),appliesTo:a["applies-to"],tags:a.tags,enforcement:a.enforcement}));let J=n(p),x=new Set(t.map(r=>r.symbol));for(let r of J)x.has(r.symbol)||(x.add(r.symbol),t.push(y({id:`purpose-ref-${r.type}-${r.symbol.slice(1)}`,symbol:r.symbol,type:r.type,source:"purpose",filePath:r.filePath,data:{referencedFrom:r.sourceSymbol},description:`Referenced from ${r.sourceSymbol}`})));}catch(p){n$1.push({source:"purpose",filePath:u,message:p.message});}}if(e$1.sources.portal)for(let c of e$1.sources.portal){let u=S.resolve(o,c.path);try{let p;if(u.endsWith(".yaml")||u.endsWith(".yml"))p=await a(u),l$1.push(u);else {let m=await e(u);if(l$1.push(...m),m.length>0){p=await a(m[0]);for(let g=1;g<m.length;g++){let $=await a(m[g]);p.gates.push(...$.gates),p.flows.push(...$.flows);}}else continue}for(let m of p.gates){t.push(pe(m,u));for(let g of m.prizes)t.push(y({id:`gate-signal-${m.id}-${g.id}`,symbol:`!${g.id}`,type:"signal",source:"portal",filePath:u,data:g,description:`Signal from gate ${m.id}`}));}for(let m of p.flows)t.push(ue(m,u));}catch(p){n$1.push({source:"portal",filePath:u,message:p.message});}}for(let c of e$1.nodes){let u=c.tags?.includes("idea");if(!c.content&&!u){let p=t.find(m=>m.symbol===c.symbol);if(p){p.position=c.position,p.tags=c.tags;continue}}t.push(y({id:c.id,symbol:c.symbol,type:c.type,source:"premise",filePath:".premise",data:c,description:c.content,position:c.position,tags:c.tags,created:c.created,modified:c.modified}));}fe(t);let f$1=new Map;for(let c of t){let u=f$1.get(c.symbol)||[];u.includes(c.filePath)||u.push(c.filePath),f$1.set(c.symbol,u);}let h$1=[];for(let[c,u]of f$1)u.length>1&&h$1.push({symbol:c,files:u});return {symbols:t,purposeFiles:i$1,portalFiles:l$1,errors:n$1,timestamp:Date.now(),...h$1.length>0?{duplicateSymbols:h$1}:{}}}function y(e){return {...e,data:e.data??null,references:e.references??[],referencedBy:e.referencedBy??[]}}function pe(e,o){let t=e.id.startsWith("^")?e.id.slice(1):e.id;return y({id:`gate-${t}`,symbol:`^${t}`,type:"gate",source:"portal",filePath:o,data:e,description:e.description,position:e.position})}function ue(e,o){return y({id:`gate-flow-${e.id}`,symbol:`$${e.id}`,type:"flow",source:"portal",filePath:o,data:e,description:e.description})}function T(e){let o=e.lastIndexOf(":");if(o===-1||o===e.length-1)return {path:e,lines:0,raw:e};let t=e.slice(o+1),n=e.slice(0,o);if(!/^[\d,\- ]+$/.test(t))return {path:e,lines:0,raw:e};if(t.includes("-")){let[i,l]=t.split("-").map(Number);return {path:n,lines:[i,l],raw:e}}else if(t.includes(",")){let i=t.split(",").map(Number);return {path:n,lines:i,raw:e}}else return {path:n,lines:Number(t),raw:e}}var le=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function fe(e){let o=new Map(e.map(t=>[t.symbol,t]));for(let t of e){let n=JSON.stringify(t.data),i=/(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g,l=(n.match(i)||[]).filter(f=>!le.has(f));for(let f of l)if(f!==t.symbol&&o.has(f)){t.references.includes(f)||t.references.push(f);let h=o.get(f);h&&!h.referencedBy.includes(t.symbol)&&h.referencedBy.push(t.symbol);}}}async function Ce(e){let o={metadata:{name:S.basename(e),created:new Date().toISOString(),modified:new Date().toISOString()},sources:{purpose:[{path:"./"}],portal:[{path:"./"}]},nodes:[]};return ce(o,e)}function me(){return {entries:new Map,byType:new Map,bySource:new Map,timestamp:0}}function Te(e){let o=me();o.timestamp=e.timestamp;for(let t of e.symbols)o.entries.set(t.id,t),o.byType.has(t.type)||o.byType.set(t.type,[]),o.byType.get(t.type).push(t),o.bySource.has(t.source)||o.bySource.set(t.source,[]),o.bySource.get(t.source).push(t);return o}function P(e,o){for(let t of e.entries.values())if(t.symbol===o)return t}function xe(e,o){return e.entries.get(o)}function C(e,o){return e.byType.get(o)||[]}function Ie(e,o){return e.bySource.get(o)||[]}function de(e,o){let t=o.toLowerCase(),n=[];for(let i of e.entries.values()){if(i.symbol.toLowerCase().includes(t)){n.push(i);continue}if(i.description?.toLowerCase().includes(t)){n.push(i);continue}if(i.tags?.some(l=>l.toLowerCase().includes(t))){n.push(i);continue}if(i.componentType?.toLowerCase().includes(t)){n.push(i);continue}}return n}function Oe(e,o){return C(e,"component").filter(n=>n.componentType===o)}function je(e){let o=new Set,t=C(e,"component");for(let n of t)n.componentType&&o.add(n.componentType);return Array.from(o).sort()}function Le(e,o){return C(e,"component").filter(n=>n.parentSymbol===o)}function Ae(e,o){let t=P(e,o);return t?t.referencedBy.map(n=>P(e,n)).filter(n=>n!==void 0):[]}function Be(e,o){let t=P(e,o);return t?t.references.map(n=>P(e,n)).filter(n=>n!==void 0):[]}function De(e,o){let t=[];for(let n of e.entries.values())n.tags?.includes(o)&&t.push(n);return t}function Me(e){let o=new Set;for(let t of e.entries.values())for(let n of t.tags||[])o.add(n);return Array.from(o).sort()}function Re(e){let o={component:0,flow:0,gate:0,signal:0,aspect:0};for(let[t,n]of e.byType)t in o&&(o[t]=n.length);return o}function Ee(e){return Array.from(e.entries.values())}function W(e){if(e.length<2)return null;let o=e[0],t=e.slice(1);return H(o)?{type:Z[o],name:t}:null}function ze(e,o){return `${U[e]}${o}`}function Ne(e){return W(e)!==null}function Ge(e,o,t=10){let n=o.toLowerCase(),i=W(o);return i?C(e,i.type).filter(f=>f.symbol.toLowerCase().includes(n)).slice(0,t):de(e,o).slice(0,t)}export{Me as A,Re as B,Ee as C,W as D,ze as E,Ne as F,Ge as G,U as a,Z as b,ge as c,ae as d,V as e,ie as f,he as g,be as h,Se as i,$e as j,we as k,ce as l,Ce as m,me as n,Te as o,P as p,xe as q,C as r,Ie as s,de as t,Oe as u,je as v,Le as w,Ae as x,Be as y,De as z};
|
package/dist/chunk-SU5F5D4I.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import*as k from'fs';import*as I from'js-yaml';import {z as z$1}from'zod';import*as S from'path';import {glob}from'glob';var E=z$1.object({description:z$1.string(),type:z$1.string().optional(),parent:z$1.string().optional(),anchors:z$1.array(z$1.string()).optional(),tags:z$1.array(z$1.string()).optional(),endpoints:z$1.array(z$1.string()).optional(),tests:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),aspects:z$1.array(z$1.string()).optional(),flows:z$1.array(z$1.string()).optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),states:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),location:z$1.string().optional(),locations:z$1.array(z$1.string()).optional(),uses:z$1.array(z$1.string()).optional(),"used-by":z$1.array(z$1.string()).optional(),"used-for":z$1.array(z$1.string()).optional(),exports:z$1.array(z$1.string()).optional(),status:z$1.string().optional(),properties:z$1.record(z$1.unknown()).optional(),handles:z$1.array(z$1.string()).optional()}).passthrough(),L=E.extend({id:z$1.string()}),fe=z$1.object({description:z$1.string().optional(),category:z$1.string().optional(),severity:z$1.enum(["info","warn","error"]).optional(),emitters:z$1.array(z$1.string()).optional(),related:z$1.array(z$1.string()).optional(),data:z$1.record(z$1.unknown()).optional()}),le=z$1.union([fe,z$1.string().transform(o=>({description:o}))]),ue=z$1.object({from:z$1.string(),to:z$1.string(),type:z$1.string(),description:z$1.string().optional()}),de=z$1.union([ue,z$1.string()]),me=z$1.object({component:z$1.string(),action:z$1.string(),description:z$1.string().optional()}),Y=z$1.union([me,z$1.string()]),ge=z$1.object({name:z$1.string(),description:z$1.string().optional(),steps:z$1.array(Y)}),he=z$1.object({description:z$1.string().optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),steps:z$1.array(Y).optional()}),ye=z$1.object({description:z$1.string().optional(),requires:z$1.array(z$1.string()).optional(),keys:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional()}),$e=z$1.object({description:z$1.string().optional(),default:z$1.unknown().optional(),type:z$1.string().optional()}),we=z$1.object({description:z$1.string().optional(),tags:z$1.array(z$1.string()).optional(),anchors:z$1.array(z$1.string()).optional(),"applies-to":z$1.array(z$1.string()).optional(),enforcement:z$1.string().optional()}),be=z$1.object({target:z$1.string(),type:z$1.string(),path:z$1.string()}),Se=z$1.object({version:z$1.string().optional(),description:z$1.string().optional(),apiSpec:z$1.string().optional(),context:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),features:z$1.union([z$1.array(L),z$1.record(E)]).optional(),components:z$1.union([z$1.array(L),z$1.record(E)]).optional(),gates:z$1.record(ye).optional(),states:z$1.record($e).optional(),signals:z$1.record(le).optional(),aspects:z$1.record(we).optional(),relationships:z$1.array(de).optional(),flows:z$1.union([z$1.array(ge),z$1.record(he)]).optional(),references:z$1.array(be).optional()});function ve(o){let t=xe(o);return {data:t.data,errors:t.errors}}function xe(o){let t=[],e=[],n;try{n=k.readFileSync(o,"utf8");}catch(c){let p=`Cannot read file: ${c.message}`;return t.push(p),e.push({message:p,type:"file"}),{data:null,errors:t,detailedErrors:e,rawContent:void 0,isYamlValid:false}}let a=n.replace(/^([#~!$^][\w-]+):/gm,'"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm,'$1"$2"'),i=null;try{i=I.load(a);}catch(c){let p=c,f=p.mark?.line?p.mark.line+1:void 0,u=`YAML syntax error: ${p.reason||c.message}`;return t.push(`${u}${f?` (line ${f})`:""}`),e.push({message:u,line:f,type:"yaml"}),{data:null,errors:t,detailedErrors:e,rawContent:n,isYamlValid:false}}if(i==null)return {data:{},errors:[],detailedErrors:[],rawContent:n,isYamlValid:true};if(typeof i=="object"&&i!==null){let c=i,p={"#":"components",$:"flows","^":"gates","!":"signals","~":"aspects"};for(let f of Object.keys(c)){let u=f[0],g=p[u];if(!g||f.length<2)continue;let h=f.slice(1),$=c[f];if(typeof $!="object"||$===null)continue;let x=c[g]||{};g in c||(c[g]=x),h in x||(x[h]=$),delete c[f];}}let r=Se.safeParse(i);if(!r.success){for(let c of r.error.issues){let p=c.path.join("."),f=c.message;t.push(`Schema error at ${p||"/"}: ${f}`),e.push({message:f,path:p||"/",type:"schema"});}return {data:i,errors:t,detailedErrors:e,rawContent:n,isYamlValid:true}}return {data:r.data,errors:[],detailedErrors:[],rawContent:n,isYamlValid:true}}function Ne(o){return I.dump(o,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function j(o){return o?Array.isArray(o)?o.map(t=>[t.id,t]):Object.entries(o):[]}async function ke(o){let t=S.resolve(o);return (await glob("**/.purpose",{cwd:t,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})).sort((n,a)=>{let i=n.split(S.sep).length,r=a.split(S.sep).length;return i-r})}async function B(o){let t=await ke(o),e=[];for(let n of t){let{data:a,errors:i}=ve(n);a&&(e.push({filePath:n,data:a}),i.length>0&&console.warn(`Warnings parsing ${n}:`,i));}return e}function V(o){let t=new Map;for(let{filePath:e,data:n}of o){let a=j(n.features);for(let[i,r]of a)t.set(i,{item:r,filePath:e});}return t}function _(o){let t=new Map;for(let{filePath:e,data:n}of o){let a=j(n.components);for(let[i,r]of a)t.set(i,{item:r,filePath:e});}return t}function N(o){let t=new Map;for(let{filePath:e,data:n}of o)if(n.gates)for(let[a,i]of Object.entries(n.gates))t.set(a,{item:i,filePath:e});return t}function K(o){let t=new Map;for(let{filePath:e,data:n}of o)if(n.states)for(let[a,i]of Object.entries(n.states))t.set(a,{item:i,filePath:e});return t}function q(o){let t=new Map;for(let{filePath:e,data:n}of o)if(n.flows)if(Array.isArray(n.flows))for(let a of n.flows)t.set(a.name,{item:{id:a.name,description:a.description,steps:a.steps},filePath:e});else for(let[a,i]of Object.entries(n.flows))t.set(a,{item:{id:a,description:i.description,gates:i.gates,signals:i.signals,components:i.components,steps:i.steps},filePath:e});return t}function Z(o){let t=new Map;for(let{filePath:e,data:n}of o)if(n.signals)for(let[a,i]of Object.entries(n.signals))t.set(a,{item:i,filePath:e});return t}function U(o){let t=new Map;for(let{filePath:e,data:n}of o)if(n.aspects)for(let[a,i]of Object.entries(n.aspects))t.set(a,{item:i,filePath:e});return t}function X(o){let t=[],e=new Set;for(let{filePath:n,data:a}of o){let i=j(a.features);for(let[c,p]of i)M(`#${c}`,p,n,t,e);let r=j(a.components);for(let[c,p]of r)M(`#${c}`,p,n,t,e);}return t}function M(o,t,e,n,a){if(t.flows)for(let i of t.flows){let r=i.startsWith("$")?i:`$${i}`;a.has(r)||(a.add(r),n.push({symbol:r,type:"flow",sourceSymbol:o,filePath:e}));}if(t.gates)for(let i of t.gates){let r=i.startsWith("^")?i:`^${i}`;a.has(r)||(a.add(r),n.push({symbol:r,type:"gate",sourceSymbol:o,filePath:e}));}if(t.signals)for(let i of t.signals){let r=i.startsWith("!")?i:`!${i}`;a.has(r)||(a.add(r),n.push({symbol:r,type:"signal",sourceSymbol:o,filePath:e}));}if(t.states)for(let i of t.states){let r=i.startsWith("#")?i:i.startsWith("%")?`#${i.slice(1)}`:`#${i}`;a.has(r)||(a.add(r),n.push({symbol:r,type:"component",sourceSymbol:o,filePath:e}));}if(t.components)for(let i of t.components){let r=i.startsWith("#")?i:`#${i}`;a.has(r)||(a.add(r),n.push({symbol:r,type:"component",sourceSymbol:o,filePath:e}));}if(t.aspects)for(let i of t.aspects){let r=i.startsWith("~")?i:`~${i}`;a.has(r)||(a.add(r),n.push({symbol:r,type:"aspect",sourceSymbol:o,filePath:e}));}if(t.description){let i=je(t.description);for(let{symbol:r,type:c}of i)a.has(r)||(a.add(r),n.push({symbol:r,type:c,sourceSymbol:o,filePath:e}));}}var Ce=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function je(o){let t=[],e=/([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g,n;for(;(n=e.exec(o))!==null;){let a=n[1],i=n[2],r,c;switch(a){case "#":c="component",r=`#${i}`;break;case "$":c="flow",r=`$${i}`;break;case "^":c="gate",r=`^${i}`;break;case "!":c="signal",r=`!${i}`;break;case "~":c="aspect",r=`~${i}`;break;case "%":c="component",r=`#${i}`;break;default:continue}Ce.has(r)||t.push({symbol:r,type:c});}return t}function v(o){return o?Array.isArray(o)?o.map(t=>[t.id,t]):Object.entries(o):[]}function O(o){return o?Array.isArray(o)?o.map(t=>t.id):Object.keys(o):[]}function qe(o,t){let e=[],n=t?`${t}: `:"",a=v(o.features);for(let[r,c]of a)G(r,c,"feature",n,e);let i=v(o.components);for(let[r,c]of i)G(r,c,"component",n,e);if(o.relationships){let r=new Set([...O(o.features),...O(o.components)]);for(let c of o.relationships){if(typeof c=="string"||!c||!c.from||!c.to)continue;let p=c.from.replace(/^[@#$%~^!?]/,"");!r.has(p)&&!c.from.includes(".")&&e.push({type:"warning",message:`${n}Relationship references unknown source: "${c.from}"`,path:"relationships"});let f=c.to.replace(/^[@#$%~^!?]/,"");!r.has(f)&&!c.to.includes(".")&&e.push({type:"warning",message:`${n}Relationship references unknown target: "${c.to}"`,path:"relationships"});}}if(o.flows){let r=new Set(O(o.components));if(Array.isArray(o.flows)){for(let c of o.flows)if(!(!c||typeof c!="object")&&(c.name||e.push({type:"error",message:`${n}Flow missing required "name" field`,path:"flows"}),c.steps&&Array.isArray(c.steps)))for(let p of c.steps){if(typeof p=="string"||!p||!p.component)continue;let f=p.component.replace(/^#/,"");r.has(f)||e.push({type:"warning",message:`${n}Flow "${c.name}" references unknown component: "${p.component}"`,path:`flows.${c.name}`});}}else for(let[c,p]of Object.entries(o.flows))if(!(!p||typeof p!="object")&&p.steps&&Array.isArray(p.steps))for(let f of p.steps){if(typeof f=="string"||!f||!f.component)continue;let u=f.component.replace(/^#/,"");r.has(u)||e.push({type:"warning",message:`${n}Flow "${c}" references unknown component: "${f.component}"`,path:`flows.${c}`});}}return {valid:e.filter(r=>r.type==="error").length===0,issues:e}}function G(o,t,e,n,a){let i=`${e}s.${o}`;if(/^[a-zA-Z][a-zA-Z0-9-]*$/.test(o)||a.push({type:"warning",message:`${n}${e} ID "${o}" should use alphanumeric characters and hyphens`,path:i}),(!t.description||t.description.trim()==="")&&a.push({type:"warning",message:`${n}${e} "${o}" has no description`,path:i}),t.endpoints)for(let r of t.endpoints)/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+\//.test(r)||a.push({type:"warning",message:`${n}Endpoint "${r}" in ${e} "${o}" may not be in standard format (e.g., "GET /api/users")`,path:`${i}.endpoints`});}function Ze(o){let t=[],e=new Set;for(let{data:n}of o){let a=v(n.components);for(let[r]of a)e.add(`#${r}`),e.add(r);let i=v(n.features);for(let[r]of i)e.add(`#${r}`),e.add(r);if(n.gates)for(let r of Object.keys(n.gates))e.add(`^${r}`),e.add(r);if(n.signals)for(let r of Object.keys(n.signals))e.add(`!${r}`),e.add(r);if(n.flows)if(Array.isArray(n.flows))for(let r of n.flows)r?.name&&(e.add(`$${r.name}`),e.add(r.name));else for(let r of Object.keys(n.flows))e.add(`$${r}`),e.add(r);if(n.aspects)for(let r of Object.keys(n.aspects))e.add(`~${r}`),e.add(r);if(n.states)for(let r of Object.keys(n.states))e.add(`#${r}`),e.add(r);}for(let{filePath:n,data:a}of o){let i=n?`${n}: `:"",r=[...v(a.components),...v(a.features)];for(let[c,p]of r){if(p.parent){let u=p.parent.replace(/^["']|["']$/g,""),g=u.replace(/^[#$^!~@%?&]/,"");!e.has(u)&&!e.has(g)&&t.push({type:"warning",message:`${i}Component "${c}" references parent "${u}" which is not defined in any .purpose file`,path:`components.${c}.parent`});}let f=[{field:"gates",refs:p.gates},{field:"signals",refs:p.signals},{field:"flows",refs:p.flows},{field:"components",refs:p.components},{field:"aspects",refs:p.aspects}];for(let{field:u,refs:g}of f)if(g)for(let h of g){let $=h.replace(/^[#$^!~@%?&]/,"");!e.has(h)&&!e.has($)&&t.push({type:"warning",message:`${i}Symbol "${c}" references ${u} "${h}" which is not defined`,path:`components.${c}.${u}`});}}if(a.flows){if(Array.isArray(a.flows)){for(let c of a.flows)if(c?.steps)for(let p of c.steps){if(typeof p=="string"||!p?.component)continue;let f=p.component.replace(/^#/,"");!e.has(p.component)&&!e.has(f)&&t.push({type:"warning",message:`${i}Flow "${c.name}" step references "${p.component}" which is not defined`,path:`flows.${c.name}.steps`});}}else for(let[c,p]of Object.entries(a.flows))if(p?.steps)for(let f of p.steps){if(typeof f=="string"||!f?.component)continue;let u=f.component.replace(/^#/,"");!e.has(f.component)&&!e.has(u)&&t.push({type:"warning",message:`${i}Flow "${c}" step references "${f.component}" which is not defined`,path:`flows.${c}.steps`});}}}return {valid:t.filter(n=>n.type==="error").length===0,issues:t}}var Ie={visualizerPort:42195,watcherPort:42196,autoConnect:true};async function D(o){let t=S.resolve(o),e=S.dirname(t);if(!k.existsSync(t))throw new Error(`Gate config not found: ${t}`);let n=k.readFileSync(t,"utf8"),a=I.load(n);if(!a.version)throw new Error('Gate config missing required "version" field');let i=[],r=a,c=a.gates||r.portals;if(c)for(let[f,u]of Object.entries(c)){let g=f.startsWith("^")?f.slice(1):f;i.push(F(g,u));}if(a.include)for(let f of a.include){let u=S.join(e,f),g=await glob(u.replace(/\\/g,"/"));for(let h of g){let $=await Ae(h);i.push(...$);}}let p=[];if(a.flows)for(let[f,u]of Object.entries(a.flows))p.push(Oe(f,u));return {version:a.version,gates:i,flows:p,settings:{dev:{...Ie,...a.settings?.dev}}}}async function Ae(o){let t=k.readFileSync(o,"utf8"),e=I.load(t);if(e.id){let n=e.id,a=n.startsWith("^")?n.slice(1):n;return [F(a,e)]}if(e.gates){let n=[];for(let[a,i]of Object.entries(e.gates)){let r=a.startsWith("^")?a.slice(1):a;n.push(F(r,i));}return n}return []}function F(o,t){let e=[];if(t.locks)for(let a of t.locks)e.push(De(a));let n=[];if(t.prizes)for(let a of t.prizes)n.push(ze(a));return {id:o,description:t.description,locks:e,prizes:n,position:t.position}}function De(o){let t=o,e=[];if(t.keys){for(let n of t.keys)if(typeof n=="string")e.push({expression:n});else if(n.expression){let a=n;e.push({expression:a.expression,description:a.description});}}return {id:t.id,description:t.description,keys:e,mode:t.mode||"all"}}function ze(o){let t=o;return {id:t.id,oneTime:t.oneTime??false,metadata:t.metadata}}function Oe(o,t){return {id:o,description:t.description,gates:t.gates||[],forkable:t.forkable}}async function J(o){let t=S.resolve(o);return await glob("**/portal.yaml",{cwd:t,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})}function He(o){if(o instanceof I.YAMLException){let t=(o.reason||"").toLowerCase();return t.includes("duplicated mapping key")||t.includes("duplicate mapping key")?{errorClass:"duplicate-key",detail:"duplicate mapping key"}:["unexpected","expected","bad indentation","mapping values","cannot read a block mapping entry","end of the stream","while scanning","while parsing"].some(n=>t.includes(n))?{errorClass:"syntax",detail:"yaml syntax error"}:{errorClass:"other",detail:"yaml parse error"}}return {errorClass:"other",detail:"yaml parse error"}}var Ee=z$1.object({x:z$1.number(),y:z$1.number()}),Fe=z$1.object({x:z$1.number(),y:z$1.number(),zoom:z$1.number()}),ee=z$1.object({path:z$1.string(),include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),oe=z$1.object({id:z$1.string(),symbol:z$1.string(),type:z$1.enum(["feature","component","flow","state","aspect","gate","signal","idea"]),content:z$1.string().optional(),position:Ee,tags:z$1.array(z$1.string()).optional(),created:z$1.string(),modified:z$1.string().optional()}),se=z$1.object({from:z$1.string(),to:z$1.string(),label:z$1.string().optional(),type:z$1.string().optional()}),Te=z$1.object({id:z$1.string(),name:z$1.string(),nodes:z$1.array(z$1.string()),color:z$1.string().optional()}),ne=z$1.object({viewport:Fe,groups:z$1.array(Te).optional()}),Re=z$1.object({nodes:z$1.array(oe),connections:z$1.array(se),layout:ne}),Le=z$1.object({id:z$1.string(),name:z$1.string(),timestamp:z$1.string(),description:z$1.string().optional(),state:Re});z$1.object({version:z$1.string(),metadata:z$1.object({name:z$1.string(),created:z$1.string(),modified:z$1.string()}),sources:z$1.object({purpose:z$1.array(ee).optional(),portal:z$1.array(ee).optional()}),nodes:z$1.array(oe),connections:z$1.array(se),layout:ne,snapshots:z$1.array(Le).optional()});async function Me(o,t){let e=[],n=[],a=[],i=[];if(o.sources.purpose)for(let p of o.sources.purpose){let f=S.resolve(t,p.path);try{let u=await B(f);a.push(...u.map(d=>d.filePath));let g=V(u);for(let[d,{item:m,filePath:y}]of g){let P=["feature",...m.tags||[]];e.push(w({id:`purpose-feature-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:P,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(pe=>T(pe))}));}let h=_(u);for(let[d,{item:m,filePath:y}]of h)e.push(w({id:`purpose-component-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:m.tags,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(P=>T(P))}));let $=N(u);for(let[d,{item:m,filePath:y}]of $)e.push(w({id:`purpose-gate-${d}`,symbol:`^${d}`,type:"gate",source:"purpose",filePath:y,data:m,description:m.description}));let x=K(u);for(let[d,{item:m,filePath:y}]of x)e.push(w({id:`purpose-state-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:["state"]}));let re=q(u);for(let[d,{item:m,filePath:y}]of re)e.push(w({id:`purpose-flow-${d}`,symbol:`$${d}`,type:"flow",source:"purpose",filePath:y,data:m,description:m.description}));let ae=Z(u);for(let[d,{item:m,filePath:y}]of ae)e.push(w({id:`purpose-signal-${d}`,symbol:`!${d}`,type:"signal",source:"purpose",filePath:y,data:m,description:m.description}));let ie=U(u);for(let[d,{item:m,filePath:y}]of ie)e.push(w({id:`purpose-aspect-${d}`,symbol:`~${d}`,type:"aspect",source:"purpose",filePath:y,data:m,description:m.description,anchors:m.anchors?.map(P=>T(P)),appliesTo:m["applies-to"],tags:m.tags,enforcement:m.enforcement}));let ce=X(u),R=new Set(e.map(d=>d.symbol));for(let d of ce)R.has(d.symbol)||(R.add(d.symbol),e.push(w({id:`purpose-ref-${d.type}-${d.symbol.slice(1)}`,symbol:d.symbol,type:d.type,source:"purpose",filePath:d.filePath,data:{referencedFrom:d.sourceSymbol},description:`Referenced from ${d.sourceSymbol}`})));}catch(u){n.push({source:"purpose",filePath:f,message:u.message});}}if(o.sources.portal)for(let p of o.sources.portal){let f=S.resolve(t,p.path);try{let u;if(f.endsWith(".yaml")||f.endsWith(".yml"))u=await D(f),i.push(f);else {let g=await J(f);if(i.push(...g),g.length>0){u=await D(g[0]);for(let h=1;h<g.length;h++){let $=await D(g[h]);u.gates.push(...$.gates),u.flows.push(...$.flows);}}else continue}for(let g of u.gates){e.push(Ge(g,f));for(let h of g.prizes)e.push(w({id:`gate-signal-${g.id}-${h.id}`,symbol:`!${h.id}`,type:"signal",source:"portal",filePath:f,data:h,description:`Signal from gate ${g.id}`}));}for(let g of u.flows)e.push(We(g,f));}catch(u){n.push({source:"portal",filePath:f,message:u.message});}}for(let p of o.nodes){let f=p.tags?.includes("idea");if(!p.content&&!f){let u=e.find(g=>g.symbol===p.symbol);if(u){u.position=p.position,u.tags=p.tags;continue}}e.push(w({id:p.id,symbol:p.symbol,type:p.type,source:"premise",filePath:".premise",data:p,description:p.content,position:p.position,tags:p.tags,created:p.created,modified:p.modified}));}Be(e);let r=new Map;for(let p of e){let f=r.get(p.symbol)||[];f.includes(p.filePath)||f.push(p.filePath),r.set(p.symbol,f);}let c=[];for(let[p,f]of r)f.length>1&&c.push({symbol:p,files:f});return {symbols:e,purposeFiles:a,portalFiles:i,errors:n,timestamp:Date.now(),...c.length>0?{duplicateSymbols:c}:{}}}function w(o){return {...o,data:o.data??null,references:o.references??[],referencedBy:o.referencedBy??[]}}function Ge(o,t){let e=o.id.startsWith("^")?o.id.slice(1):o.id;return w({id:`gate-${e}`,symbol:`^${e}`,type:"gate",source:"portal",filePath:t,data:o,description:o.description,position:o.position})}function We(o,t){return w({id:`gate-flow-${o.id}`,symbol:`$${o.id}`,type:"flow",source:"portal",filePath:t,data:o,description:o.description})}function T(o){let t=o.lastIndexOf(":");if(t===-1||t===o.length-1)return {path:o,lines:0,raw:o};let e=o.slice(t+1),n=o.slice(0,t);if(!/^[\d,\- ]+$/.test(e))return {path:o,lines:0,raw:o};if(e.includes("-")){let[a,i]=e.split("-").map(Number);return {path:n,lines:[a,i],raw:o}}else if(e.includes(",")){let a=e.split(",").map(Number);return {path:n,lines:a,raw:o}}else return {path:n,lines:Number(e),raw:o}}var Ye=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function Be(o){let t=new Map(o.map(e=>[e.symbol,e]));for(let e of o){let n=JSON.stringify(e.data),a=/(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g,i=(n.match(a)||[]).filter(r=>!Ye.has(r));for(let r of i)if(r!==e.symbol&&t.has(r)){e.references.includes(r)||e.references.push(r);let c=t.get(r);c&&!c.referencedBy.includes(e.symbol)&&c.referencedBy.push(e.symbol);}}}async function st(o){let t={metadata:{name:S.basename(o),created:new Date().toISOString(),modified:new Date().toISOString()},sources:{purpose:[{path:"./"}],portal:[{path:"./"}]},nodes:[]};return Me(t,o)}function Ve(){return {entries:new Map,byType:new Map,bySource:new Map,timestamp:0}}function nt(o){let t=Ve();t.timestamp=o.timestamp;for(let e of o.symbols)t.entries.set(e.id,e),t.byType.has(e.type)||t.byType.set(e.type,[]),t.byType.get(e.type).push(e),t.bySource.has(e.source)||t.bySource.set(e.source,[]),t.bySource.get(e.source).push(e);return t}function z(o,t){for(let e of o.entries.values())if(e.symbol===t)return e}function rt(o,t){return o.byType.get(t)||[]}function at(o,t){let e=t.toLowerCase(),n=[];for(let a of o.entries.values()){if(a.symbol.toLowerCase().includes(e)){n.push(a);continue}if(a.description?.toLowerCase().includes(e)){n.push(a);continue}if(a.tags?.some(i=>i.toLowerCase().includes(e))){n.push(a);continue}if(a.componentType?.toLowerCase().includes(e)){n.push(a);continue}}return n}function it(o,t){let e=z(o,t);return e?e.referencedBy.map(n=>z(o,n)).filter(n=>n!==void 0):[]}function ct(o,t){let e=z(o,t);return e?e.references.map(n=>z(o,n)).filter(n=>n!==void 0):[]}function pt(o){let t={component:0,flow:0,gate:0,signal:0,aspect:0};for(let[e,n]of o.byType)e in t&&(t[e]=n.length);return t}function ft(o){return Array.from(o.entries.values())}
|
|
3
|
-
export{ve as a,xe as b,Ne as c,ke as d,qe as e,Ze as f,D as g,He as h,st as i,nt as j,z as k,rt as l,at as m,it as n,ct as o,pt as p,ft as q};
|
package/dist/dist-JZZJLVMR.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import*as P from'fs';import*as j from'js-yaml';import {z as z$1}from'zod';import*as S from'path';import {glob}from'glob';var O=z$1.object({description:z$1.string(),type:z$1.string().optional(),parent:z$1.string().optional(),anchors:z$1.array(z$1.string()).optional(),tags:z$1.array(z$1.string()).optional(),endpoints:z$1.array(z$1.string()).optional(),tests:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),aspects:z$1.array(z$1.string()).optional(),flows:z$1.array(z$1.string()).optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),states:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),location:z$1.string().optional(),locations:z$1.array(z$1.string()).optional(),uses:z$1.array(z$1.string()).optional(),"used-by":z$1.array(z$1.string()).optional(),"used-for":z$1.array(z$1.string()).optional(),exports:z$1.array(z$1.string()).optional(),status:z$1.string().optional(),properties:z$1.record(z$1.unknown()).optional(),handles:z$1.array(z$1.string()).optional()}).passthrough(),L=O.extend({id:z$1.string()}),fe=z$1.object({description:z$1.string().optional(),category:z$1.string().optional(),severity:z$1.enum(["info","warn","error"]).optional(),emitters:z$1.array(z$1.string()).optional(),related:z$1.array(z$1.string()).optional(),data:z$1.record(z$1.unknown()).optional()}),le=z$1.union([fe,z$1.string().transform(e=>({description:e}))]),ue=z$1.object({from:z$1.string(),to:z$1.string(),type:z$1.string(),description:z$1.string().optional()}),de=z$1.union([ue,z$1.string()]),me=z$1.object({component:z$1.string(),action:z$1.string(),description:z$1.string().optional()}),W=z$1.union([me,z$1.string()]),ge=z$1.object({name:z$1.string(),description:z$1.string().optional(),steps:z$1.array(W)}),he=z$1.object({description:z$1.string().optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),steps:z$1.array(W).optional()}),ye=z$1.object({description:z$1.string().optional(),requires:z$1.array(z$1.string()).optional(),keys:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional()}),$e=z$1.object({description:z$1.string().optional(),default:z$1.unknown().optional(),type:z$1.string().optional()}),we=z$1.object({description:z$1.string().optional(),tags:z$1.array(z$1.string()).optional(),anchors:z$1.array(z$1.string()).optional(),"applies-to":z$1.array(z$1.string()).optional(),enforcement:z$1.string().optional()}),be=z$1.object({target:z$1.string(),type:z$1.string(),path:z$1.string()}),Se=z$1.object({version:z$1.string().optional(),description:z$1.string().optional(),apiSpec:z$1.string().optional(),context:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),features:z$1.union([z$1.array(L),z$1.record(O)]).optional(),components:z$1.union([z$1.array(L),z$1.record(O)]).optional(),gates:z$1.record(ye).optional(),states:z$1.record($e).optional(),signals:z$1.record(le).optional(),aspects:z$1.record(we).optional(),relationships:z$1.array(de).optional(),flows:z$1.union([z$1.array(ge),z$1.record(he)]).optional(),references:z$1.array(be).optional()});function ve(e){let t=xe(e);return {data:t.data,errors:t.errors}}function xe(e){let t=[],o=[],n;try{n=P.readFileSync(e,"utf8");}catch(l){let p=`Cannot read file: ${l.message}`;return t.push(p),o.push({message:p,type:"file"}),{data:null,errors:t,detailedErrors:o,rawContent:void 0,isYamlValid:false}}let r=n.replace(/^([#~!$^][\w-]+):/gm,'"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm,'$1"$2"'),a=null;try{a=j.load(r);}catch(l){let p=l,f=p.mark?.line?p.mark.line+1:void 0,u=`YAML syntax error: ${p.reason||l.message}`;return t.push(`${u}${f?` (line ${f})`:""}`),o.push({message:u,line:f,type:"yaml"}),{data:null,errors:t,detailedErrors:o,rawContent:n,isYamlValid:false}}if(a==null)return {data:{},errors:[],detailedErrors:[],rawContent:n,isYamlValid:true};if(typeof a=="object"&&a!==null){let l=a,p={"#":"components",$:"flows","^":"gates","!":"signals","~":"aspects"};for(let f of Object.keys(l)){let u=f[0],g=p[u];if(!g||f.length<2)continue;let h=f.slice(1),w=l[f];if(typeof w!="object"||w===null)continue;let v=l[g]||{};g in l||(l[g]=v),h in v||(v[h]=w),delete l[f];}}let i=Se.safeParse(a);if(!i.success){for(let l of i.error.issues){let p=l.path.join("."),f=l.message;t.push(`Schema error at ${p||"/"}: ${f}`),o.push({message:f,path:p||"/",type:"schema"});}return {data:a,errors:t,detailedErrors:o,rawContent:n,isYamlValid:true}}return {data:i.data,errors:[],detailedErrors:[],rawContent:n,isYamlValid:true}}function C(e){return e?Array.isArray(e)?e.map(t=>[t.id,t]):Object.entries(e):[]}async function ke(e){let t=S.resolve(e);return (await glob("**/.purpose",{cwd:t,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})).sort((n,r)=>{let a=n.split(S.sep).length,i=r.split(S.sep).length;return a-i})}async function Y(e){let t=await ke(e),o=[];for(let n of t){let{data:r,errors:a}=ve(n);r&&(o.push({filePath:n,data:r}),a.length>0&&console.warn(`Warnings parsing ${n}:`,a));}return o}function B(e){let t=new Map;for(let{filePath:o,data:n}of e){let r=C(n.features);for(let[a,i]of r)t.set(a,{item:i,filePath:o});}return t}function V(e){let t=new Map;for(let{filePath:o,data:n}of e){let r=C(n.components);for(let[a,i]of r)t.set(a,{item:i,filePath:o});}return t}function _(e){let t=new Map;for(let{filePath:o,data:n}of e)if(n.gates)for(let[r,a]of Object.entries(n.gates))t.set(r,{item:a,filePath:o});return t}function N(e){let t=new Map;for(let{filePath:o,data:n}of e)if(n.states)for(let[r,a]of Object.entries(n.states))t.set(r,{item:a,filePath:o});return t}function K(e){let t=new Map;for(let{filePath:o,data:n}of e)if(n.flows)if(Array.isArray(n.flows))for(let r of n.flows)t.set(r.name,{item:{id:r.name,description:r.description,steps:r.steps},filePath:o});else for(let[r,a]of Object.entries(n.flows))t.set(r,{item:{id:r,description:a.description,gates:a.gates,signals:a.signals,components:a.components,steps:a.steps},filePath:o});return t}function q(e){let t=new Map;for(let{filePath:o,data:n}of e)if(n.signals)for(let[r,a]of Object.entries(n.signals))t.set(r,{item:a,filePath:o});return t}function Z(e){let t=new Map;for(let{filePath:o,data:n}of e)if(n.aspects)for(let[r,a]of Object.entries(n.aspects))t.set(r,{item:a,filePath:o});return t}function U(e){let t=[],o=new Set;for(let{filePath:n,data:r}of e){let a=C(r.features);for(let[l,p]of a)M(`#${l}`,p,n,t,o);let i=C(r.components);for(let[l,p]of i)M(`#${l}`,p,n,t,o);}return t}function M(e,t,o,n,r){if(t.flows)for(let a of t.flows){let i=a.startsWith("$")?a:`$${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"flow",sourceSymbol:e,filePath:o}));}if(t.gates)for(let a of t.gates){let i=a.startsWith("^")?a:`^${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"gate",sourceSymbol:e,filePath:o}));}if(t.signals)for(let a of t.signals){let i=a.startsWith("!")?a:`!${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"signal",sourceSymbol:e,filePath:o}));}if(t.states)for(let a of t.states){let i=a.startsWith("#")?a:a.startsWith("%")?`#${a.slice(1)}`:`#${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"component",sourceSymbol:e,filePath:o}));}if(t.components)for(let a of t.components){let i=a.startsWith("#")?a:`#${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"component",sourceSymbol:e,filePath:o}));}if(t.aspects)for(let a of t.aspects){let i=a.startsWith("~")?a:`~${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"aspect",sourceSymbol:e,filePath:o}));}if(t.description){let a=je(t.description);for(let{symbol:i,type:l}of a)r.has(i)||(r.add(i),n.push({symbol:i,type:l,sourceSymbol:e,filePath:o}));}}var Ce=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function je(e){let t=[],o=/([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g,n;for(;(n=o.exec(e))!==null;){let r=n[1],a=n[2],i,l;switch(r){case "#":l="component",i=`#${a}`;break;case "$":l="flow",i=`$${a}`;break;case "^":l="gate",i=`^${a}`;break;case "!":l="signal",i=`!${a}`;break;case "~":l="aspect",i=`~${a}`;break;case "%":l="component",i=`#${a}`;break;default:continue}Ce.has(i)||t.push({symbol:i,type:l});}return t}var Ie={visualizerPort:42195,watcherPort:42196,autoConnect:true};async function I(e){let t=S.resolve(e),o=S.dirname(t);if(!P.existsSync(t))throw new Error(`Gate config not found: ${t}`);let n=P.readFileSync(t,"utf8"),r=j.load(n);if(!r.version)throw new Error('Gate config missing required "version" field');let a=[],i=r,l=r.gates||i.portals;if(l)for(let[f,u]of Object.entries(l)){let g=f.startsWith("^")?f.slice(1):f;a.push(F(g,u));}if(r.include)for(let f of r.include){let u=S.join(o,f),g=await glob(u.replace(/\\/g,"/"));for(let h of g){let w=await Ae(h);a.push(...w);}}let p=[];if(r.flows)for(let[f,u]of Object.entries(r.flows))p.push(Oe(f,u));return {version:r.version,gates:a,flows:p,settings:{dev:{...Ie,...r.settings?.dev}}}}async function Ae(e){let t=P.readFileSync(e,"utf8"),o=j.load(t);if(o.id){let n=o.id,r=n.startsWith("^")?n.slice(1):n;return [F(r,o)]}if(o.gates){let n=[];for(let[r,a]of Object.entries(o.gates)){let i=r.startsWith("^")?r.slice(1):r;n.push(F(i,a));}return n}return []}function F(e,t){let o=[];if(t.locks)for(let r of t.locks)o.push(De(r));let n=[];if(t.prizes)for(let r of t.prizes)n.push(ze(r));return {id:e,description:t.description,locks:o,prizes:n,position:t.position}}function De(e){let t=e,o=[];if(t.keys){for(let n of t.keys)if(typeof n=="string")o.push({expression:n});else if(n.expression){let r=n;o.push({expression:r.expression,description:r.description});}}return {id:t.id,description:t.description,keys:o,mode:t.mode||"all"}}function ze(e){let t=e;return {id:t.id,oneTime:t.oneTime??false,metadata:t.metadata}}function Oe(e,t){return {id:e,description:t.description,gates:t.gates||[],forkable:t.forkable}}async function H(e){let t=S.resolve(e);return await glob("**/portal.yaml",{cwd:t,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})}var Fe={component:"#",flow:"$",gate:"^",signal:"!",aspect:"~"},Te={"#":"component",$:"flow","^":"gate","!":"signal","~":"aspect"},Re=["#","$","^","!","~"];function Le(e){return Re.includes(e)}var Me=z$1.object({x:z$1.number(),y:z$1.number()}),Ge=z$1.object({x:z$1.number(),y:z$1.number(),zoom:z$1.number()}),J=z$1.object({path:z$1.string(),include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),ee=z$1.object({id:z$1.string(),symbol:z$1.string(),type:z$1.enum(["feature","component","flow","state","aspect","gate","signal","idea"]),content:z$1.string().optional(),position:Me,tags:z$1.array(z$1.string()).optional(),created:z$1.string(),modified:z$1.string().optional()}),te=z$1.object({from:z$1.string(),to:z$1.string(),label:z$1.string().optional(),type:z$1.string().optional()}),We=z$1.object({id:z$1.string(),name:z$1.string(),nodes:z$1.array(z$1.string()),color:z$1.string().optional()}),oe=z$1.object({viewport:Ge,groups:z$1.array(We).optional()}),Ye=z$1.object({nodes:z$1.array(ee),connections:z$1.array(te),layout:oe}),Be=z$1.object({id:z$1.string(),name:z$1.string(),timestamp:z$1.string(),description:z$1.string().optional(),state:Ye}),Ve=z$1.object({version:z$1.string(),metadata:z$1.object({name:z$1.string(),created:z$1.string(),modified:z$1.string()}),sources:z$1.object({purpose:z$1.array(J).optional(),portal:z$1.array(J).optional()}),nodes:z$1.array(ee),connections:z$1.array(te),layout:oe,snapshots:z$1.array(Be).optional()});function rt(e){let t=[],o;try{o=P.readFileSync(e,"utf8");}catch(n){return t.push(`Cannot read file: ${n.message}`),{data:null,errors:t,rawContent:void 0}}return _e(o)}function _e(e){let t=[],o=null;try{o=j.load(e);}catch(r){let a=r,i=a.mark?.line?a.mark.line+1:void 0;return t.push(`YAML syntax error: ${a.reason||r.message}${i?` (line ${i})`:""}`),{data:null,errors:t,rawContent:e}}if(o==null)return {data:se(),errors:[],rawContent:e};let n=Ve.safeParse(o);if(!n.success){for(let r of n.error.issues){let a=r.path.join(".");t.push(`Schema error at ${a||"/"}: ${r.message}`);}return {data:o,errors:t,rawContent:e}}return {data:n.data,errors:[],rawContent:e}}function se(e="Untitled"){let t=new Date().toISOString();return {version:"1.0.0",metadata:{name:e,created:t,modified:t},sources:{purpose:[{path:"./"}],portal:[{path:"./portal.yaml"}]},nodes:[],connections:[],layout:{viewport:{x:0,y:0,zoom:1}}}}function Ne(e){return e.metadata.modified=new Date().toISOString(),j.dump(e,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function at(e="My Project"){return Ne(se(e))}function it(e,t){return {...e,nodes:[...e.nodes,t],metadata:{...e.metadata,modified:new Date().toISOString()}}}function ct(e,t,o){return {...e,nodes:e.nodes.map(n=>n.id===t?{...n,position:o,modified:new Date().toISOString()}:n),metadata:{...e.metadata,modified:new Date().toISOString()}}}function pt(e,t){return e.connections.some(n=>n.from===t.from&&n.to===t.to)?e:{...e,connections:[...e.connections,t],metadata:{...e.metadata,modified:new Date().toISOString()}}}function ft(e,t,o){let n={id:`snap-${Date.now()}`,name:t,timestamp:new Date().toISOString(),description:o,state:{nodes:[...e.nodes],connections:[...e.connections],layout:{...e.layout}}};return {...e,snapshots:[...e.snapshots||[],n],metadata:{...e.metadata,modified:new Date().toISOString()}}}async function Ke(e,t){let o=[],n=[],r=[],a=[];if(e.sources.purpose)for(let p of e.sources.purpose){let f=S.resolve(t,p.path);try{let u=await Y(f);r.push(...u.map(d=>d.filePath));let g=B(u);for(let[d,{item:m,filePath:y}]of g){let x=["feature",...m.tags||[]];o.push($({id:`purpose-feature-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:x,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(pe=>T(pe))}));}let h=V(u);for(let[d,{item:m,filePath:y}]of h)o.push($({id:`purpose-component-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:m.tags,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(x=>T(x))}));let w=_(u);for(let[d,{item:m,filePath:y}]of w)o.push($({id:`purpose-gate-${d}`,symbol:`^${d}`,type:"gate",source:"purpose",filePath:y,data:m,description:m.description}));let v=N(u);for(let[d,{item:m,filePath:y}]of v)o.push($({id:`purpose-state-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:["state"]}));let re=K(u);for(let[d,{item:m,filePath:y}]of re)o.push($({id:`purpose-flow-${d}`,symbol:`$${d}`,type:"flow",source:"purpose",filePath:y,data:m,description:m.description}));let ae=q(u);for(let[d,{item:m,filePath:y}]of ae)o.push($({id:`purpose-signal-${d}`,symbol:`!${d}`,type:"signal",source:"purpose",filePath:y,data:m,description:m.description}));let ie=Z(u);for(let[d,{item:m,filePath:y}]of ie)o.push($({id:`purpose-aspect-${d}`,symbol:`~${d}`,type:"aspect",source:"purpose",filePath:y,data:m,description:m.description,anchors:m.anchors?.map(x=>T(x)),appliesTo:m["applies-to"],tags:m.tags,enforcement:m.enforcement}));let ce=U(u),R=new Set(o.map(d=>d.symbol));for(let d of ce)R.has(d.symbol)||(R.add(d.symbol),o.push($({id:`purpose-ref-${d.type}-${d.symbol.slice(1)}`,symbol:d.symbol,type:d.type,source:"purpose",filePath:d.filePath,data:{referencedFrom:d.sourceSymbol},description:`Referenced from ${d.sourceSymbol}`})));}catch(u){n.push({source:"purpose",filePath:f,message:u.message});}}if(e.sources.portal)for(let p of e.sources.portal){let f=S.resolve(t,p.path);try{let u;if(f.endsWith(".yaml")||f.endsWith(".yml"))u=await I(f),a.push(f);else {let g=await H(f);if(a.push(...g),g.length>0){u=await I(g[0]);for(let h=1;h<g.length;h++){let w=await I(g[h]);u.gates.push(...w.gates),u.flows.push(...w.flows);}}else continue}for(let g of u.gates){o.push(qe(g,f));for(let h of g.prizes)o.push($({id:`gate-signal-${g.id}-${h.id}`,symbol:`!${h.id}`,type:"signal",source:"portal",filePath:f,data:h,description:`Signal from gate ${g.id}`}));}for(let g of u.flows)o.push(Ze(g,f));}catch(u){n.push({source:"portal",filePath:f,message:u.message});}}for(let p of e.nodes){let f=p.tags?.includes("idea");if(!p.content&&!f){let u=o.find(g=>g.symbol===p.symbol);if(u){u.position=p.position,u.tags=p.tags;continue}}o.push($({id:p.id,symbol:p.symbol,type:p.type,source:"premise",filePath:".premise",data:p,description:p.content,position:p.position,tags:p.tags,created:p.created,modified:p.modified}));}Xe(o);let i=new Map;for(let p of o){let f=i.get(p.symbol)||[];f.includes(p.filePath)||f.push(p.filePath),i.set(p.symbol,f);}let l=[];for(let[p,f]of i)f.length>1&&l.push({symbol:p,files:f});return {symbols:o,purposeFiles:r,portalFiles:a,errors:n,timestamp:Date.now(),...l.length>0?{duplicateSymbols:l}:{}}}function $(e){return {...e,data:e.data??null,references:e.references??[],referencedBy:e.referencedBy??[]}}function qe(e,t){let o=e.id.startsWith("^")?e.id.slice(1):e.id;return $({id:`gate-${o}`,symbol:`^${o}`,type:"gate",source:"portal",filePath:t,data:e,description:e.description,position:e.position})}function Ze(e,t){return $({id:`gate-flow-${e.id}`,symbol:`$${e.id}`,type:"flow",source:"portal",filePath:t,data:e,description:e.description})}function T(e){let t=e.lastIndexOf(":");if(t===-1||t===e.length-1)return {path:e,lines:0,raw:e};let o=e.slice(t+1),n=e.slice(0,t);if(!/^[\d,\- ]+$/.test(o))return {path:e,lines:0,raw:e};if(o.includes("-")){let[r,a]=o.split("-").map(Number);return {path:n,lines:[r,a],raw:e}}else if(o.includes(",")){let r=o.split(",").map(Number);return {path:n,lines:r,raw:e}}else return {path:n,lines:Number(o),raw:e}}var Ue=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function Xe(e){let t=new Map(e.map(o=>[o.symbol,o]));for(let o of e){let n=JSON.stringify(o.data),r=/(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g,a=(n.match(r)||[]).filter(i=>!Ue.has(i));for(let i of a)if(i!==o.symbol&&t.has(i)){o.references.includes(i)||o.references.push(i);let l=t.get(i);l&&!l.referencedBy.includes(o.symbol)&&l.referencedBy.push(o.symbol);}}}async function dt(e){let t={metadata:{name:S.basename(e),created:new Date().toISOString(),modified:new Date().toISOString()},sources:{purpose:[{path:"./"}],portal:[{path:"./"}]},nodes:[]};return Ke(t,e)}function He(){return {entries:new Map,byType:new Map,bySource:new Map,timestamp:0}}function mt(e){let t=He();t.timestamp=e.timestamp;for(let o of e.symbols)t.entries.set(o.id,o),t.byType.has(o.type)||t.byType.set(o.type,[]),t.byType.get(o.type).push(o),t.bySource.has(o.source)||t.bySource.set(o.source,[]),t.bySource.get(o.source).push(o);return t}function A(e,t){for(let o of e.entries.values())if(o.symbol===t)return o}function gt(e,t){return e.entries.get(t)}function z(e,t){return e.byType.get(t)||[]}function ht(e,t){return e.bySource.get(t)||[]}function Je(e,t){let o=t.toLowerCase(),n=[];for(let r of e.entries.values()){if(r.symbol.toLowerCase().includes(o)){n.push(r);continue}if(r.description?.toLowerCase().includes(o)){n.push(r);continue}if(r.tags?.some(a=>a.toLowerCase().includes(o))){n.push(r);continue}if(r.componentType?.toLowerCase().includes(o)){n.push(r);continue}}return n}function yt(e,t){return z(e,"component").filter(n=>n.componentType===t)}function $t(e){let t=new Set,o=z(e,"component");for(let n of o)n.componentType&&t.add(n.componentType);return Array.from(t).sort()}function wt(e,t){return z(e,"component").filter(n=>n.parentSymbol===t)}function bt(e,t){let o=A(e,t);return o?o.referencedBy.map(n=>A(e,n)).filter(n=>n!==void 0):[]}function St(e,t){let o=A(e,t);return o?o.references.map(n=>A(e,n)).filter(n=>n!==void 0):[]}function vt(e,t){let o=[];for(let n of e.entries.values())n.tags?.includes(t)&&o.push(n);return o}function xt(e){let t=new Set;for(let o of e.entries.values())for(let n of o.tags||[])t.add(n);return Array.from(t).sort()}function Pt(e){let t={component:0,flow:0,gate:0,signal:0,aspect:0};for(let[o,n]of e.byType)o in t&&(t[o]=n.length);return t}function kt(e){return Array.from(e.entries.values())}function ne(e){if(e.length<2)return null;let t=e[0],o=e.slice(1);return Le(t)?{type:Te[t],name:o}:null}function Ct(e,t){return `${Fe[e]}${t}`}function jt(e){return ne(e)!==null}function It(e,t,o=10){let n=t.toLowerCase(),r=ne(t);return r?z(e,r.type).filter(i=>i.symbol.toLowerCase().includes(n)).slice(0,o):Je(e,t).slice(0,o)}export{Te as PREFIX_TO_TYPE,Fe as SYMBOL_PREFIXES,pt as addConnection,it as addPremiseNode,dt as aggregateFromDirectory,Ke as aggregateFromPremise,mt as buildSymbolIndex,se as createEmptyPremiseFile,ft as createSnapshot,He as createSymbolIndex,Ct as createSymbolString,$t as getAllComponentTypes,kt as getAllSymbols,xt as getAllTags,It as getAutocompleteSuggestions,wt as getChildComponents,yt as getComponentsByType,at as getDefaultPremiseContent,St as getReferencesFrom,bt as getReferencesTo,A as getSymbol,gt as getSymbolById,Pt as getSymbolCounts,ht as getSymbolsBySource,vt as getSymbolsByTag,z as getSymbolsByType,jt as isValidSymbol,_e as parsePremiseContent,rt as parsePremiseFile,ne as parseSymbol,Je as searchSymbols,Ne as serializePremiseFile,ct as updateNodePosition};
|
package/dist/dist-OG6MM4VY.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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,e as createEmptyPremiseFile,k as createSnapshot,n as createSymbolIndex,E as createSymbolString,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,t as searchSymbols,f as serializePremiseFile,i as updateNodePosition}from'./chunk-LWAIVOSF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';
|
package/dist/reindex-2YTQP2EO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
export{ea as getReindexToolsList,fa as handleReindexTool,ga as rebuildStaticFiles}from'./chunk-5NAF6CKU.js';import'./chunk-SU5F5D4I.js';import'./chunk-M4UMM6DC.js';import'./chunk-GRZQIKST.js';import'./chunk-6QXBXZF6.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-LAYBUKMB.js';import'./chunk-5TAVYPOV.js';
|
package/dist/review-VMSX2PKI.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {n,m,o as o$1,t,r as r$1}from'./chunk-LWAIVOSF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as a from'fs';import*as r from'path';import o from'chalk';import {execSync}from'child_process';import*as F from'js-yaml';var W=/[@#$%^!?&~][a-zA-Z][a-zA-Z0-9_-]*/g,_=[/\.(get|post|put|patch|delete)\s*\(\s*['"`]([^'"`]+)['"`]/gi,/export\s+(async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)/gi];async function G(n$1={}){let i=process.cwd(),b=a$1.command("review").start("Running review pipeline",{cwd:i}),u=[],m$1=[];try{if(n$1.pr)u=execSync(`gh pr diff ${n$1.pr} --name-only`,{cwd:i,encoding:"utf8",timeout:15e3}).trim().split(`
|
|
3
|
-
`).filter(Boolean);else {let e=execSync("git diff --cached --name-only",{cwd:i,encoding:"utf8",timeout:5e3}).trim(),t=execSync("git diff --name-only",{cwd:i,encoding:"utf8",timeout:5e3}).trim();u=[...new Set([...e.split(`
|
|
4
|
-
`).filter(Boolean),...t.split(`
|
|
5
|
-
`).filter(Boolean)])];}}catch(e){let t=e.message;n$1.json||a$1.command("review").error(`Failed to get changed files: ${t}`),b.error("Failed to get changed files"),n$1.ci&&process.exit(1);return}if(u.length===0){n$1.json?console.log(JSON.stringify({findings:[],summary:{total:0,blocking:0,improvements:0,notes:0}})):console.log(o.green(`
|
|
6
|
-
No modified files to review.
|
|
7
|
-
`)),b.success("No files to review");return}try{for(let e of u)if(e.endsWith(".purpose")){let t=r.join(i,e);if(a.existsSync(t)){let g=a.readFileSync(t,"utf-8").match(W)||[];m$1.push(...g);}}m$1=[...new Set(m$1)];}catch{}let s=[],$=n();try{let e=await m(i);$=o$1(e);}catch{}let R=r.join(i,"portal.yaml"),h=null;if(a.existsSync(R))try{h=F.load(a.readFileSync(R,"utf-8"));}catch{}for(let e of m$1)t($,e).length===0&&s.push({type:"blocking",category:"purpose-coverage",message:`Symbol "${e}" is not registered in any .purpose file`,suggestion:"Add to nearest .purpose file using paradigm_purpose_add_component."});let N=h?.routes?Object.keys(h.routes):[];for(let e of u){let t=r.isAbsolute(e)?e:r.join(i,e);if(!a.existsSync(t))continue;let l;try{l=a.readFileSync(t,"utf-8");}catch{continue}for(let g of _){g.lastIndex=0;let d;for(;(d=g.exec(l))!==null;){let f=d[2]||d[0];f&&f.startsWith("/")&&(N.some(p=>p.replace(/\s+(GET|POST|PUT|PATCH|DELETE)\s*$/,"").trim()===f)||s.push({type:h?"blocking":"improvement",category:"route-coverage",message:`Route "${f}" in ${e} not in portal.yaml`,file:e,suggestion:"Add route to portal.yaml with ^gates."}));}}}let O=h?Object.keys(h.gates||{}).map(e=>e.startsWith("^")?e.slice(1):e):[];for(let e of m$1)if(e.startsWith("^")){let t=e.slice(1);O.includes(t)||s.push({type:"blocking",category:"portal-compliance",message:`Gate "${e}" referenced but not declared in portal.yaml`,suggestion:`Add ${e} to portal.yaml with description and check expression.`});}try{let e=r$1($,"aspect");for(let t of e){let l=t.appliesTo||[];if(l.length!==0){for(let g of l)for(let d of m$1)if(I(g,d)){let c=t.anchors||[];if(c.length===0)s.push({type:"improvement",category:"aspect-anchors",message:`Aspect "${t.symbol}" applies to "${d}" but has no code anchors`,suggestion:`Add anchors to ${t.symbol} in .purpose file.`});else for(let p of c){let T=r.isAbsolute(p.path)?p.path:r.join(i,p.path);a.existsSync(T)||s.push({type:"improvement",category:"aspect-anchors",message:`Aspect "${t.symbol}" anchor "${p.raw}" points to missing file`,suggestion:`Update anchors for ${t.symbol} in .purpose file.`});}}}}}catch{}for(let e of m$1){let t$1=t($,e);if(t$1.length===0)continue;let l=t$1[0];l.parentSymbol&&t($,l.parentSymbol).length===0&&s.push({type:"improvement",category:"broken-reference",message:`Symbol "${e}" references parent "${l.parentSymbol}" which does not exist`,suggestion:"Create the parent symbol or update the parent reference."});}if(n$1.deep)for(let e of u){let t=r.isAbsolute(e)?e:r.join(i,e);if(!a.existsSync(t))continue;let l=r.extname(e);if(![".ts",".tsx",".js",".jsx",".py",".rs"].includes(l))continue;let g;try{g=a.readFileSync(t,"utf-8");}catch{continue}let d=g.split(`
|
|
8
|
-
`);for(let f=0;f<d.length;f++){let c=d[f],p=f+1;/\beval\s*\(/.test(c)&&!c.trimStart().startsWith("//")&&s.push({type:"blocking",category:"security",message:"eval() detected \u2014 potential code injection risk",file:e,line:p,suggestion:"Replace eval() with a safer alternative."}),/(?:password|secret|api_key|apikey|token)\s*[:=]\s*['"][^'"]{8,}['"]/i.test(c)&&!c.trimStart().startsWith("//")&&!c.trimStart().startsWith("#")&&s.push({type:"blocking",category:"security",message:"Possible hardcoded secret detected",file:e,line:p,suggestion:"Move secrets to environment variables or a secrets manager."}),/\bconsole\.(log|debug|info|warn)\b/.test(c)&&!e.includes("test")&&!e.includes("spec")&&(c.trimStart().startsWith("//")||s.push({type:"note",category:"convention",message:"console.log detected \u2014 use Paradigm logger instead",file:e,line:p,suggestion:"Use log.component(), log.gate(), etc. from the Paradigm logger."}));}}let y=s.filter(e=>e.type==="blocking"),w=s.filter(e=>e.type==="improvement"),S=s.filter(e=>e.type==="note");if(n$1.json)console.log(JSON.stringify({findings:s,summary:{total:s.length,blocking:y.length,improvements:w.length,notes:S.length,filesReviewed:u.length,symbolsChecked:m$1.length}},null,2));else if(console.log(o.blue(`
|
|
9
|
-
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`)),console.log(o.blue("\u2502")+o.white.bold(" paradigm review ")+o.blue("\u2502")),console.log(o.blue("\u2502")+o.gray(` ${u.length} files, ${m$1.length} symbols${n$1.deep?", deep mode":""}`.padEnd(50))+o.blue("\u2502")),console.log(o.blue(`\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
10
|
-
`)),s.length===0)console.log(o.green(` All checks passed \u2014 no findings.
|
|
11
|
-
`));else {if(y.length>0){console.log(o.red.bold(` Blocking (${y.length})`));for(let e of y)console.log(` ${o.red("x")} ${e.message}`),e.file&&console.log(` ${o.gray(e.file)}${e.line?`:${e.line}`:""}`),e.suggestion&&console.log(` ${o.yellow("->")} ${e.suggestion}`);console.log("");}if(w.length>0){console.log(o.yellow(` Improvements (${w.length})`));for(let e of w)console.log(` ${o.yellow("*")} ${e.message}`),e.file&&console.log(` ${o.gray(e.file)}${e.line?`:${e.line}`:""}`),e.suggestion&&console.log(` ${o.yellow("->")} ${e.suggestion}`);console.log("");}if(S.length>0){console.log(o.gray(` Notes (${S.length})`));for(let e of S)console.log(` ${o.gray("o")} ${e.message}`),e.file&&console.log(` ${o.gray(e.file)}${e.line?`:${e.line}`:""}`);console.log("");}}n$1.ci&&y.length>0&&(b.error(`${y.length} blocking findings`),process.exit(1)),b.success(`Review complete: ${s.length} findings`);}function I(n,i){return n.includes("*")?new RegExp("^"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$").test(i):n===i}export{G as reviewCommand};
|