@a-company/paradigm 5.37.8 → 5.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accept-orchestration-SBZVK3H4.js → accept-orchestration-OATWIRHP.js} +1 -1
- package/dist/{aggregate-W66DM3GA.js → aggregate-A5S5MTCC.js} +1 -1
- package/dist/{beacon-5QVYV5DF.js → beacon-QVUD3MGP.js} +1 -1
- package/dist/{chunk-SI6SV76D.js → chunk-3DZK54RU.js} +72 -19
- package/dist/{chunk-KFNHCQ4R.js → chunk-4L7665QV.js} +1 -1
- package/dist/chunk-4VKSEOXZ.js +6 -0
- package/dist/{chunk-CHVQNRRT.js → chunk-5QOCKWK5.js} +1 -1
- package/dist/chunk-HOBHJPTL.js +24 -0
- package/dist/{chunk-T6IDXUUA.js → chunk-LWAIVOSF.js} +1 -1
- package/dist/chunk-NQ47TA6C.js +111 -0
- package/dist/{chunk-G7XFK2GI.js → chunk-RBLK34IA.js} +1 -1
- package/dist/chunk-RN4VE6P3.js +521 -0
- package/dist/{chunk-SUU6M4JH.js → chunk-TOYQ2QCB.js} +1 -1
- package/dist/{chunk-LBQBWIEX.js → chunk-Y4P4SGZV.js} +1 -1
- package/dist/chunk-ZJQY5PPP.js +7 -0
- package/dist/{commands-LMUD5L6R.js → commands-ANRJNG2W.js} +1 -1
- package/dist/compliance-D7GD6ZYC.js +6 -0
- package/dist/{constellation-CG7C4WFE.js → constellation-NWLXYATA.js} +1 -1
- package/dist/{cost-IDNVMAEV.js → cost-24UZSS2P.js} +1 -1
- package/dist/{diff-JVEYCXUC.js → diff-YGHBIJY5.js} +1 -1
- package/dist/dist-JZZJLVMR.js +2 -0
- package/dist/{dist-3ZCH25SG.js → dist-OG6MM4VY.js} +1 -1
- package/dist/dist-SE67SOXB.js +2 -0
- package/dist/doctor-WMVULMQD.js +2 -0
- package/dist/{flow-POQP27WA.js → flow-FVZR3YJ4.js} +1 -1
- package/dist/{hooks-IG2GOAHP.js → hooks-TFMMMB2H.js} +1 -1
- package/dist/index.js +5 -5
- package/dist/init-XYB62Q3X.js +2 -0
- package/dist/{integrity-UYDOOJDP.js → integrity-ROO3G43N.js} +1 -1
- package/dist/mcp.js +18 -10
- package/dist/{migrate-IBDE7VK4.js → migrate-Z5UQN57G.js} +1 -1
- package/dist/{orchestrate-RCAMBOIB.js → orchestrate-M5PBZBJQ.js} +1 -1
- package/dist/portal-check-ZMLVBIGW.js +8 -0
- package/dist/portal-compliance-6YR27IQU.js +2 -0
- package/dist/{probe-B22G2JKF.js → probe-3FTG6LYO.js} +1 -1
- package/dist/{reindex-FO5VMZVQ.js → reindex-I6LPAKCC.js} +1 -1
- package/dist/{review-6UAH6V3R.js → review-VMSX2PKI.js} +1 -1
- package/dist/{ripple-ZGDITCGB.js → ripple-FNZI47SH.js} +1 -1
- package/dist/sentinel.js +1 -1
- package/dist/{setup-3F5IK7MO.js → setup-FEWSYS3Y.js} +2 -2
- package/dist/{shift-CZMQWZWP.js → shift-PC6C7NUX.js} +4 -4
- package/dist/{snapshot-L2G56RPL.js → snapshot-3IYB67D4.js} +1 -1
- package/dist/{status-77M3SDIF.js → status-DB3KNLW3.js} +1 -1
- package/dist/{summary-LXLHFRN7.js → summary-PYTEIJ4U.js} +1 -1
- package/dist/{team-NSP6PMPS.js → team-PDK64JXI.js} +1 -1
- package/dist/{test-BQJMS4Y2.js → test-WLEPZQFC.js} +1 -1
- package/dist/{tools-BZUAEUSQ.js → tools-5ITPEPSV.js} +1 -1
- package/dist/{validate-VZXTJHGO.js → validate-BB6LRWIY.js} +1 -1
- package/dist/workspace-VMSPYIBV.js +2 -0
- package/package.json +2 -1
- package/templates/paradigm/specs/symbols.md +4 -2
- package/dist/chunk-3TR6LLXP.js +0 -111
- package/dist/chunk-3VF3CMCF.js +0 -521
- package/dist/chunk-J6KWGCHN.js +0 -24
- package/dist/chunk-QT2LKB3P.js +0 -7
- package/dist/chunk-SHD27BQX.js +0 -6
- package/dist/compliance-WJINB5DM.js +0 -6
- package/dist/dist-R3RWD35F.js +0 -2
- package/dist/dist-VXCZWVVJ.js +0 -2
- package/dist/doctor-QJ47XAUP.js +0 -2
- package/dist/init-HIBRSVUB.js +0 -2
- package/dist/portal-check-Z3OCQEQR.js +0 -8
- package/dist/portal-compliance-4MG5F2GI.js +0 -2
- package/dist/workspace-MKSQN7B2.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-HOBHJPTL.js';import'./chunk-TYWB5IQJ.js';import'./chunk-ORDKEGII.js';import'./chunk-BV5PRPLB.js';import'./chunk-AO7ZSRME.js';import'./chunk-FYDRENK7.js';import'./chunk-EKZDFEJW.js';import'./chunk-4VKSEOXZ.js';import'./chunk-LWAIVOSF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as g from'path';import e from'chalk';async function u(n,s,r){let a=s?g.resolve(s):process.cwd();if(!n){r.json?console.log(JSON.stringify({error:"Orchestration ID required"})):(console.log(e.red(`
|
|
3
3
|
Orchestration ID required.`)),console.log(e.gray(`Usage: paradigm team accept <orchestration-id>
|
|
4
4
|
`)));return}let l=new b(a),o=l.getOrchestration(n);if(!o){r.json?console.log(JSON.stringify({error:"Orchestration not found",id:n})):console.log(e.red(`
|
|
5
5
|
Orchestration not found: ${n}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,l as l$1,m,o as o$1,B}from'./chunk-
|
|
2
|
+
import {c,l as l$1,m,o as o$1,B}from'./chunk-LWAIVOSF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as u from'fs';import*as l from'path';import o from'chalk';import S from'ora';async function A(d){let h=process.cwd(),a=l.resolve(h,d);console.log(o.blue(`
|
|
3
3
|
\u{1F52E} Aggregating Premise...
|
|
4
4
|
`));let c$1=S("Loading sources...").start();try{let e,g=l.join(a,".premise");if(u.existsSync(g)){let{data:r,errors:s}=c(g);if(s.length>0){c$1.warn("Warnings parsing .premise file");for(let n of s)console.log(o.yellow(` \u26A0 ${n}`));console.log(o.gray(` Falling back to directory aggregation...
|
|
5
5
|
`));}if(r&&!s.some(n=>n.includes("Required")))try{e=await l$1(r,a);}catch(n){console.log(o.yellow(` \u26A0 Error using .premise file: ${n.message}`)),console.log(o.gray(` Falling back to directory aggregation...
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {m,o,C,B}from'./chunk-
|
|
2
|
+
import {m,o,C,B}from'./chunk-LWAIVOSF.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 c from'path';import n from'chalk';import O from'ora';function G(u){let o=[],g=[{pattern:"portal.yaml",desc:"Authorization topology"},{pattern:"src/lib/api.ts",desc:"API utilities"},{pattern:"src/lib/api.js",desc:"API utilities"},{pattern:"src/utils/api.ts",desc:"API utilities"},{pattern:"src/hooks/useAuth.ts",desc:"Auth hook"},{pattern:"src/hooks/useAuth.tsx",desc:"Auth hook"},{pattern:"src/context/AuthContext.tsx",desc:"Auth context"},{pattern:"src/store/index.ts",desc:"State store"},{pattern:"src/types/index.ts",desc:"Type definitions"},{pattern:"src/types.ts",desc:"Type definitions"},{pattern:".paradigm/config.yaml",desc:"Paradigm config"},{pattern:"tsconfig.json",desc:"TypeScript config"},{pattern:"package.json",desc:"Package manifest"}];for(let{pattern:r,desc:l}of g){let t=c.join(u,r);i.existsSync(t)&&o.push({path:r,description:l});}return o.slice(0,8)}function E(u){let o=c.join(u,".paradigm","prompts"),g=[];if(i.existsSync(o)){let r=i.readdirSync(o).filter(l=>l.endsWith(".md"));for(let l of r){let t=l.replace(".md","").replace(/-/g," ");g.push({name:t.charAt(0).toUpperCase()+t.slice(1),path:`.paradigm/prompts/${l}`});}}return g.slice(0,6)}function I(u,o,g,r,l){let t=[];t.push(`# Beacon - ${u}`),t.push(""),t.push("> Quick-start orientation for AI agents. Generated by Paradigm."),t.push(""),t.push("## Constellation (Symbol Map)"),t.push(""),t.push("```");let a=o.filter(e=>e.type==="component"),m=o.filter(e=>e.type==="gate");for(let e of a.slice(0,15)){let p=e.references.filter(d=>d.startsWith("^")),b=`${e.symbol.padEnd(20)} \u2192 ${c.dirname(e.filePath).padEnd(25)}`;p.length>0&&(b+=` \u2192 ${p.join(", ")}`),t.push(b);}if(a.length>15&&t.push(`... and ${a.length-15} more components`),t.push("```"),t.push(""),m.length>0){t.push("## Gates (Authorization)"),t.push("");for(let e of m.slice(0,6)){let p=e.description?` - ${e.description}`:"";t.push(`- \`${e.symbol}\`${p}`);}m.length>6&&t.push(`- ... and ${m.length-6} more gates`),t.push("");}if(g.length>0){t.push("## Landmarks (Key Files)"),t.push("");for(let e of g)t.push(`- \`${e.path}\` - ${e.description}`);t.push("");}if(r.length>0){t.push("## Pathways (Common Tasks)"),t.push("");for(let e of r)t.push(`- "${e.name}" \u2192 \`${e.path}\``);t.push("");}return t.push("## Symbol Quick Reference"),t.push(""),t.push("| Symbol | Type | Meaning |"),t.push("|--------|------|---------|"),t.push("| `#` | Component | Any documented code unit |"),t.push("| `$` | Flow | Multi-step process |"),t.push("| `^` | Gate | Authorization checkpoint |"),t.push("| `!` | Signal | Event for side effects |"),t.push("| `~` | Aspect | Rule with code anchor |"),t.push(""),t.push("## For More Context"),t.push(""),t.push("- Full symbol graph: `.paradigm/constellation.json`"),t.push("- Detailed context: `.paradigm/specs/` for detailed specifications"),t.push("- Session history: `.paradigm/thread.md` (if available)"),t.push("- Error mapping: `.paradigm/echoes.yaml` (if available)"),t.push(""),t.push("---"),t.push(`*Generated: ${new Date().toISOString().split("T")[0]}*`),t.push("*Run `paradigm beacon --refresh` to update*"),t.join(`
|
|
3
3
|
`)}async function q(u,o$1={}){let g=process.cwd(),r=u?c.resolve(g,u):g,l=c.basename(r),t=!o$1.json&&!o$1.quiet;t&&console.log(n.blue(`
|
|
4
4
|
\u{1F526} Generating Beacon...
|
|
5
5
|
`));let a$1=o$1.json?null:O("Scanning project...").start(),m$1=a.command("beacon").start("Generating beacon",{project:l});try{let e=c.join(r,".paradigm"),p=o$1.output||c.join(e,"beacon.md");if(!o$1.json&&i.existsSync(p)&&!o$1.refresh){if(a$1?.info("Beacon already exists"),t){console.log(n.gray(` Use --refresh to regenerate
|
|
@@ -511,11 +511,40 @@ fi
|
|
|
511
511
|
# --- Checks 8, 10, 11: Unified compliance check (single Node.js process) ---
|
|
512
512
|
# Replaces 3 separate subprocess calls (habits check, drift check, portal check)
|
|
513
513
|
# with a single \`paradigm compliance-check\` invocation.
|
|
514
|
+
#
|
|
515
|
+
# v5.37.12 fail-closed fix (security audit 2026-04-22, Scenario D):
|
|
516
|
+
# the prior \`|| true\` swallowed non-zero exits, which masked every upstream
|
|
517
|
+
# failure mode (missing binary, corrupt index, uncaught exception on malformed
|
|
518
|
+
# portal.yaml). On non-zero exit we now record the exit code and block with
|
|
519
|
+
# an explicit "compliance check failed to run" violation \u2014 never silently
|
|
520
|
+
# fall through to the habits-only branch.
|
|
514
521
|
COMPLIANCE_RESULT=""
|
|
522
|
+
COMPLIANCE_EXIT=0
|
|
515
523
|
if command -v paradigm >/dev/null 2>&1; then
|
|
516
|
-
COMPLIANCE_RESULT=$(paradigm compliance-check --json --auto-heal --learn --trigger on-stop 2>/dev/null)
|
|
524
|
+
COMPLIANCE_RESULT=$(paradigm compliance-check --json --auto-heal --learn --trigger on-stop 2>/dev/null)
|
|
525
|
+
COMPLIANCE_EXIT=$?
|
|
517
526
|
elif command -v npx >/dev/null 2>&1; then
|
|
518
|
-
COMPLIANCE_RESULT=$(npx paradigm compliance-check --json --auto-heal --learn --trigger on-stop 2>/dev/null)
|
|
527
|
+
COMPLIANCE_RESULT=$(npx paradigm compliance-check --json --auto-heal --learn --trigger on-stop 2>/dev/null)
|
|
528
|
+
COMPLIANCE_EXIT=$?
|
|
529
|
+
else
|
|
530
|
+
# No binary available at all \u2014 mark as unavailable, not as silent success.
|
|
531
|
+
COMPLIANCE_EXIT=127
|
|
532
|
+
fi
|
|
533
|
+
|
|
534
|
+
# Fail-closed: non-zero exit MUST block the stop hook. The prior behavior
|
|
535
|
+
# silently dropped this signal via \`|| true\`.
|
|
536
|
+
_SEV_COMPLIANCE_RUN=$(_check_severity "portal-compliance" "block")
|
|
537
|
+
if [ "$COMPLIANCE_EXIT" -ne 0 ] && [ "$_SEV_COMPLIANCE_RUN" != "off" ]; then
|
|
538
|
+
if [ "$_SEV_COMPLIANCE_RUN" = "block" ]; then
|
|
539
|
+
VIOLATIONS="$VIOLATIONS
|
|
540
|
+
- paradigm compliance-check failed to run (exit $COMPLIANCE_EXIT).
|
|
541
|
+
Refusing to complete session. Run 'paradigm compliance-check' manually
|
|
542
|
+
to see the error. If portal.yaml is malformed, run 'paradigm doctor'."
|
|
543
|
+
VIOLATION_COUNT=$((VIOLATION_COUNT + 1))
|
|
544
|
+
else
|
|
545
|
+
ADVISORY="$ADVISORY
|
|
546
|
+
- (warn) paradigm compliance-check failed to run (exit $COMPLIANCE_EXIT)."
|
|
547
|
+
fi
|
|
519
548
|
fi
|
|
520
549
|
|
|
521
550
|
if [ -n "$COMPLIANCE_RESULT" ]; then
|
|
@@ -560,17 +589,41 @@ if [ -n "$COMPLIANCE_RESULT" ]; then
|
|
|
560
589
|
_SEV=$(_check_severity "portal-compliance" "block")
|
|
561
590
|
UNDECLARED=$(echo "$COMPLIANCE_RESULT" | grep -o '"usedButUndeclaredCount":[0-9]*' | sed 's/.*://')
|
|
562
591
|
|
|
592
|
+
# v5.37.12: detect unparseable-portal sentinel (classifier, not a gate name).
|
|
593
|
+
# checkPortalCompliance emits \`__portal_unparseable__\` in usedButUndeclared
|
|
594
|
+
# to force a block when portal.yaml fails to parse. We never render the
|
|
595
|
+
# sentinel or the raw YAMLException to the user \u2014 only a redacted class.
|
|
596
|
+
PORTAL_ERR_CLASS=$(echo "$COMPLIANCE_RESULT" | grep -o '"errorClass":"[^"]*"' | head -1 | sed 's/.*"errorClass":"\\([^"]*\\)".*/\\1/')
|
|
597
|
+
|
|
563
598
|
if [ "$_SEV" != "off" ] && [ -n "$UNDECLARED" ] && [ "$UNDECLARED" -gt 0 ] 2>/dev/null; then
|
|
564
599
|
UNDECLARED_LIST=$(echo "$COMPLIANCE_RESULT" | grep -o '"usedButUndeclared":\\[[^]]*\\]' | sed 's/.*\\[//;s/\\].*//;s/"//g')
|
|
565
|
-
|
|
566
|
-
|
|
600
|
+
# Strip the unparseable-portal sentinel from the user-visible list.
|
|
601
|
+
CLEAN_LIST=$(echo "$UNDECLARED_LIST" | sed 's/__portal_unparseable__,//g; s/,__portal_unparseable__//g; s/__portal_unparseable__//g')
|
|
602
|
+
|
|
603
|
+
if echo "$UNDECLARED_LIST" | grep -q '__portal_unparseable__'; then
|
|
604
|
+
# Portal unparseable path \u2014 redacted message, classifier only.
|
|
605
|
+
if [ "$_SEV" = "block" ]; then
|
|
606
|
+
VIOLATIONS="$VIOLATIONS
|
|
607
|
+
- portal.yaml unparseable\${PORTAL_ERR_CLASS:+ ($PORTAL_ERR_CLASS)}.
|
|
608
|
+
Run 'paradigm doctor' locally for line-specific details.
|
|
609
|
+
Fix the YAML error or run 'paradigm portal check'."
|
|
610
|
+
VIOLATION_COUNT=$((VIOLATION_COUNT + 1))
|
|
611
|
+
else
|
|
612
|
+
ADVISORY="$ADVISORY
|
|
613
|
+
- (warn) portal.yaml unparseable\${PORTAL_ERR_CLASS:+ ($PORTAL_ERR_CLASS)} \u2014 run 'paradigm doctor'."
|
|
614
|
+
fi
|
|
615
|
+
elif [ -n "$CLEAN_LIST" ]; then
|
|
616
|
+
# Real undeclared gates \u2014 existing behavior.
|
|
617
|
+
if [ "$_SEV" = "block" ]; then
|
|
618
|
+
VIOLATIONS="$VIOLATIONS
|
|
567
619
|
- $UNDECLARED gate(s) used in code but not declared in portal.yaml:
|
|
568
|
-
$
|
|
620
|
+
$CLEAN_LIST
|
|
569
621
|
Add them to portal.yaml or use paradigm_portal_add_gate."
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
- (warn) $UNDECLARED gate(s) used in code but not declared in portal.yaml: $
|
|
622
|
+
VIOLATION_COUNT=$((VIOLATION_COUNT + 1))
|
|
623
|
+
else
|
|
624
|
+
ADVISORY="$ADVISORY
|
|
625
|
+
- (warn) $UNDECLARED gate(s) used in code but not declared in portal.yaml: $CLEAN_LIST"
|
|
626
|
+
fi
|
|
574
627
|
fi
|
|
575
628
|
fi
|
|
576
629
|
else
|
|
@@ -1503,7 +1556,7 @@ else
|
|
|
1503
1556
|
echo " Then retry your edit." >&2
|
|
1504
1557
|
exit 2
|
|
1505
1558
|
fi
|
|
1506
|
-
`,
|
|
1559
|
+
`,V=`#!/bin/sh
|
|
1507
1560
|
# Paradigm Cursor PostToolUse Hook \u2014 Advisory Feedback
|
|
1508
1561
|
# Fires AFTER the agent calls Edit or Write.
|
|
1509
1562
|
# Tracks modified source files and outputs advisory the agent can see.
|
|
@@ -1627,7 +1680,7 @@ if [ "$PENDING_COUNT" -ge 30 ]; then
|
|
|
1627
1680
|
fi
|
|
1628
1681
|
|
|
1629
1682
|
exit 0
|
|
1630
|
-
`;function
|
|
1683
|
+
`;function F(){try{let i=r.join(S.homedir(),".claude","settings.json");if(!e.existsSync(i))return {active:!1};if(!JSON.parse(e.readFileSync(i,"utf8")).enabledPlugins?.["paradigm@a-paradigm"])return {active:!1};let d=r.join(S.homedir(),".claude","plugins","cache","a-paradigm","paradigm");if(!e.existsSync(d))return {active:!1};let a=e.readdirSync(d).filter(t=>e.statSync(r.join(d,t)).isDirectory()).sort().reverse();if(a.length===0)return {active:!1};let p=r.join(d,a[0]),l=r.join(p,"hooks","hooks.json");return e.existsSync(l)?{active:!0,cacheVersion:a[0]}:{active:!1}}catch{return {active:false}}}function W(){try{let i=F();if(!i.active||!i.cacheVersion)return {compatible:!0};let h=r.join(S.homedir(),".claude","plugins","cache","a-paradigm","paradigm",i.cacheVersion,"hooks.json");if(!e.existsSync(h))return {compatible:!0};let d=JSON.parse(e.readFileSync(h,"utf8")).compatibleVersions;if(!d)return {compatible:!0};let a=q();if(!a)return {compatible:!0};let p=d.split(/\s+/);for(let l of p){let t=l.match(/^(>=?|<=?)\s*(\d+\.\d+\.\d+)/);if(!t)continue;let[,s,n]=t,f=J(a,n);if(s===">="&&f<0)return {compatible:!1,message:`Plugin requires paradigm ${d}, current: ${a}`};if(s===">"&&f<=0)return {compatible:!1,message:`Plugin requires paradigm ${d}, current: ${a}`};if(s==="<="&&f>0)return {compatible:!1,message:`Plugin requires paradigm ${d}, current: ${a}`};if(s==="<"&&f>=0)return {compatible:!1,message:`Plugin requires paradigm ${d}, current: ${a}`}}return {compatible:!0}}catch{return {compatible:true}}}function q(){try{let i=r.join(r.dirname(new URL(import.meta.url).pathname),"..","..","package.json");return JSON.parse(e.readFileSync(i,"utf8")).version||null}catch{return null}}function J(i,h){let c=i.split(".").map(Number),d=h.split(".").map(Number);for(let a=0;a<3;a++){if((c[a]||0)<(d[a]||0))return -1;if((c[a]||0)>(d[a]||0))return 1}return 0}function B(i){let h=[],c=r.join(i,".claude","hooks");if(e.existsSync(c)){for(let a of ["paradigm-common.sh","paradigm-stop.sh","paradigm-precommit.sh","paradigm-postwrite.sh","paradigm-navigate-remind.sh"]){let p=r.join(c,a);e.existsSync(p)&&(e.unlinkSync(p),h.push(a));}try{e.readdirSync(c).length===0&&e.rmdirSync(c);}catch{}}let d=r.join(i,".claude","settings.json");if(e.existsSync(d))try{let a=JSON.parse(e.readFileSync(d,"utf8")),p=a.hooks;if(p){let l=!1;for(let[t,s]of Object.entries(p)){if(!Array.isArray(s))continue;let n=s.filter(f=>!JSON.stringify(f).includes("paradigm-"));n.length!==s.length&&(l=!0,n.length===0?delete p[t]:p[t]=n);}l&&(Object.keys(p).length===0?delete a.hooks:a.hooks=p,e.writeFileSync(d,JSON.stringify(a,null,2)+`
|
|
1631
1684
|
`,"utf8"),h.push("settings.json hooks"));}}catch{}return {cleaned:h.length>0,removed:h}}function K(i,h){try{let c=r.join(S.tmpdir(),`paradigm-hook-validate-${Date.now()}.sh`);e.writeFileSync(c,i,"utf8");try{return execSync(`bash -n "${c}" 2>&1`,{encoding:"utf-8"}),null}catch(d){return `${h}: bash syntax error \u2014 ${d.message?.split(`
|
|
1632
1685
|
`)[0]||"unknown error"}`}finally{try{e.unlinkSync(c);}catch{}}}catch{return null}}var G=`#!/bin/sh
|
|
1633
1686
|
# Paradigm post-commit hook - captures history from commits
|
|
@@ -1723,23 +1776,23 @@ if [ -d ".paradigm/history" ] && [ -f ".paradigm/history/log.jsonl" ]; then
|
|
|
1723
1776
|
fi
|
|
1724
1777
|
`;async function re(i={}){let h=process.cwd(),c=i.dryRun||false;c&&console.log(o.cyan(`
|
|
1725
1778
|
[dry-run] Showing what would be installed:
|
|
1726
|
-
`));let d=i.claudeCode&&!i.postCommit&&!i.prePush&&!i.cursor,a=i.cursor&&!i.postCommit&&!i.prePush&&!i.claudeCode;if(!c){let
|
|
1779
|
+
`));let d=i.claudeCode&&!i.postCommit&&!i.prePush&&!i.cursor,a=i.cursor&&!i.postCommit&&!i.prePush&&!i.claudeCode;if(!c){let t=[{name:"post-commit",content:G},{name:"pre-push",content:Y},{name:"paradigm-common",content:y},{name:"claude-code-stop",content:U},{name:"claude-code-precommit",content:v},{name:"claude-code-postwrite",content:D},{name:"claude-code-navigate-remind",content:P},{name:"cursor-session-start",content:b},{name:"cursor-stop",content:L},{name:"cursor-precommit",content:x},{name:"cursor-postwrite",content:w},{name:"cursor-pretooluse",content:M},{name:"cursor-posttooluse",content:V}];for(let s of t){let n=K(s.content,s.name);if(n){console.log(o.red(`Hook syntax error: ${n}`)),console.log(o.gray("Aborting installation. Fix the hook script and try again."));return}}}let p=W();if(p.compatible||(console.log(o.yellow(`
|
|
1727
1780
|
\u26A0 ${p.message}`)),console.log(o.gray(` Hook installation will continue, but behavior may differ from plugin expectations.
|
|
1728
|
-
`))),!d&&!a){let
|
|
1781
|
+
`))),!d&&!a){let t=r.join(h,".git");if(!e.existsSync(t)){console.log(o.red("Not a git repository."));return}let s=r.join(t,"hooks"),n=!i.postCommit&&!i.prePush&&!i.claudeCode,f=[];if(n||i.postCommit){let u=r.join(s,"post-commit");if(c){let _=e.existsSync(u)&&!i.force?"skip (exists)":"install";console.log(o.gray(` post-commit: ${_} \u2192 ${u}`));}else e.existsSync(u)&&!i.force?e.readFileSync(u,"utf8").includes("paradigm")?console.log(o.gray("post-commit hook already installed by paradigm")):console.log(o.yellow("post-commit hook exists. Use --force to overwrite.")):(e.mkdirSync(s,{recursive:true}),e.writeFileSync(u,G),e.chmodSync(u,"755"),f.push("post-commit"));}if(n||i.prePush){let u=r.join(s,"pre-push");if(c){let _=e.existsSync(u)&&!i.force?"skip (exists)":"install";console.log(o.gray(` pre-push: ${_} \u2192 ${u}`));}else e.existsSync(u)&&!i.force?e.readFileSync(u,"utf8").includes("paradigm")?console.log(o.gray("pre-push hook already installed by paradigm")):console.log(o.yellow("pre-push hook exists. Use --force to overwrite.")):(e.mkdirSync(s,{recursive:true}),e.writeFileSync(u,Y),e.chmodSync(u,"755"),f.push("pre-push"));}!c&&f.length>0&&console.log(o.green(`Git hooks installed: ${f.join(", ")}`));let O=r.join(h,".paradigm/history");!e.existsSync(O)&&!c&&console.log(o.gray("Tip: Run `paradigm history init` to initialize history tracking"));}let l=!i.postCommit&&!i.prePush&&!i.claudeCode&&!i.cursor;(l||i.claudeCode)&&(c?(console.log(o.gray(" Claude Code hooks: would install paradigm-stop.sh, paradigm-precommit.sh, paradigm-postwrite.sh, paradigm-navigate-remind.sh")),console.log(o.gray(` \u2192 ${r.join(h,".claude","hooks")}/`)),console.log(o.gray(" \u2192 Update .claude/settings.json with hook configuration"))):await z(h,i.force)),(l||i.cursor)&&(c?(console.log(o.gray(" Cursor hooks: would install paradigm-session-start.sh, paradigm-stop.sh, paradigm-precommit.sh, paradigm-postwrite.sh, paradigm-pretooluse.sh, paradigm-posttooluse.sh")),console.log(o.gray(` \u2192 ${r.join(h,".cursor","hooks")}/`)),console.log(o.gray(" \u2192 Update .cursor/hooks.json"))):await Q(h,i.force)),c&&console.log(o.cyan(`
|
|
1729
1782
|
[dry-run] No changes made.
|
|
1730
|
-
`));}async function z(i,h){let c=
|
|
1731
|
-
`,"utf8"),a.length>0&&console.log(o.green(`Claude Code hooks installed: ${a.join(", ")}`)),console.log(o.green("Claude Code settings.json updated with hook configuration"));}async function Q(i,h){let c=r.join(i,".cursor","hooks");e.mkdirSync(c,{recursive:true});let d=[],a=r.join(c,"paradigm-common.sh");e.writeFileSync(a,y,"utf8"),e.chmodSync(a,"755");let p=[{name:"paradigm-session-start.sh",content:b},{name:"paradigm-stop.sh",content:L},{name:"paradigm-precommit.sh",content:x},{name:"paradigm-postwrite.sh",content:w},{name:"paradigm-pretooluse.sh",content:M},{name:"paradigm-posttooluse.sh",content:
|
|
1783
|
+
`));}async function z(i,h){let c=F();if(c.active){console.log(o.cyan(` Paradigm plugin v${c.cacheVersion} is active \u2014 hooks are managed by the plugin.`));let{cleaned:g,removed:E}=B(i);console.log(g?o.green(` Cleaned up stale project hooks: ${E.join(", ")}`):o.gray(" No stale project hooks to clean up.")),console.log(o.gray(" Plugin hooks auto-update with each session \u2014 no manual install needed."));return}let d=r.join(i,".claude","hooks");e.mkdirSync(d,{recursive:true});let a=[],p=r.join(d,"paradigm-common.sh");e.writeFileSync(p,y,"utf8"),e.chmodSync(p,"755");let l=[{name:"paradigm-stop.sh",content:U},{name:"paradigm-precommit.sh",content:v},{name:"paradigm-postwrite.sh",content:D},{name:"paradigm-navigate-remind.sh",content:P}];for(let g of l){let E=r.join(d,g.name);if(e.existsSync(E)&&!h){console.log(o.gray(` ${g.name}: already installed`));continue}e.writeFileSync(E,g.content,"utf8"),e.chmodSync(E,"755"),a.push(g.name);}let t=r.join(i,".claude","settings.json"),s={};if(e.existsSync(t))try{s=JSON.parse(e.readFileSync(t,"utf8"));}catch{}let n=s.hooks||{},f={hooks:[{type:"command",command:'bash "$CLAUDE_PROJECT_DIR/.claude/hooks/paradigm-stop.sh"',timeout:10}]},O={matcher:"Bash",hooks:[{type:"command",command:'bash "$CLAUDE_PROJECT_DIR/.claude/hooks/paradigm-precommit.sh"',timeout:30}]},u=n.Stop||[];u.some(g=>JSON.stringify(g).includes("paradigm-stop.sh"))||u.push(f),n.Stop=u;let $=n.PreToolUse||[];$.some(g=>JSON.stringify(g).includes("paradigm-precommit.sh"))||$.push(O),n.PreToolUse=$;let H={matcher:"Glob|Grep",hooks:[{type:"command",command:'bash "$CLAUDE_PROJECT_DIR/.claude/hooks/paradigm-navigate-remind.sh"',timeout:5}]};$.some(g=>JSON.stringify(g).includes("paradigm-navigate-remind.sh"))||$.push(H),n.PreToolUse=$;let j={matcher:"Edit,Write",hooks:[{type:"command",command:'bash "$CLAUDE_PROJECT_DIR/.claude/hooks/paradigm-postwrite.sh"',timeout:5}]},T=n.PostToolUse||[];T.some(g=>JSON.stringify(g).includes("paradigm-postwrite.sh"))||T.push(j),n.PostToolUse=T,s.hooks=n,e.writeFileSync(t,JSON.stringify(s,null,2)+`
|
|
1784
|
+
`,"utf8"),a.length>0&&console.log(o.green(`Claude Code hooks installed: ${a.join(", ")}`)),console.log(o.green("Claude Code settings.json updated with hook configuration"));}async function Q(i,h){let c=r.join(i,".cursor","hooks");e.mkdirSync(c,{recursive:true});let d=[],a=r.join(c,"paradigm-common.sh");e.writeFileSync(a,y,"utf8"),e.chmodSync(a,"755");let p=[{name:"paradigm-session-start.sh",content:b},{name:"paradigm-stop.sh",content:L},{name:"paradigm-precommit.sh",content:x},{name:"paradigm-postwrite.sh",content:w},{name:"paradigm-pretooluse.sh",content:M},{name:"paradigm-posttooluse.sh",content:V}];for(let m of p){let R=r.join(c,m.name);if(e.existsSync(R)&&!h){console.log(o.gray(` ${m.name}: already installed (Cursor)`));continue}e.writeFileSync(R,m.content,"utf8"),e.chmodSync(R,"755"),d.push(m.name);}let l=r.join(i,".cursor","hooks.json"),t={};if(e.existsSync(l))try{t=JSON.parse(e.readFileSync(l,"utf8"));}catch{}t.version=1;let s=t.hooks||{},n={command:".cursor/hooks/paradigm-session-start.sh",timeout:5},f={command:".cursor/hooks/paradigm-stop.sh",timeout:10,loop_limit:3},O={command:".cursor/hooks/paradigm-postwrite.sh",timeout:5},u={command:".cursor/hooks/paradigm-precommit.sh",matcher:"git commit",timeout:30},_=s.sessionStart||[];_.some(m=>JSON.stringify(m).includes("paradigm-session-start.sh"))||_.push(n),s.sessionStart=_;let I=s.stop||[];I.some(m=>JSON.stringify(m).includes("paradigm-stop.sh"))||I.push(f),s.stop=I;let N=s.afterFileEdit||[];N.some(m=>JSON.stringify(m).includes("paradigm-postwrite.sh"))||N.push(O),s.afterFileEdit=N;let T={command:".cursor/hooks/paradigm-pretooluse.sh",matcher:"Edit|Write",timeout:5},C=s.preToolUse||[];C.some(m=>JSON.stringify(m).includes("paradigm-pretooluse.sh"))||C.push(T),s.preToolUse=C;let E={command:".cursor/hooks/paradigm-posttooluse.sh",matcher:"Edit|Write",timeout:5},k=s.postToolUse||[];k.some(m=>JSON.stringify(m).includes("paradigm-posttooluse.sh"))||k.push(E),s.postToolUse=k;let A=s.beforeShellExecution||[];A.some(m=>JSON.stringify(m).includes("paradigm-precommit.sh"))||A.push(u),s.beforeShellExecution=A,t.hooks=s,e.writeFileSync(l,JSON.stringify(t,null,2)+`
|
|
1732
1785
|
`,"utf8"),d.length>0&&console.log(o.green(`Cursor hooks installed: ${d.join(", ")}`)),console.log(o.green("Cursor hooks.json updated with hook configuration"));}async function ae(i={}){let h=process.cwd(),c=i.dryRun||false;if(c&&console.log(o.cyan(`
|
|
1733
1786
|
[dry-run] Showing what would be removed:
|
|
1734
|
-
`)),!i.cursor){let d=r.join(h,".git");if(!e.existsSync(d)){console.log(o.red("Not a git repository."));return}let a=r.join(d,"hooks"),p=[];for(let l of ["post-commit","pre-push"]){let
|
|
1787
|
+
`)),!i.cursor){let d=r.join(h,".git");if(!e.existsSync(d)){console.log(o.red("Not a git repository."));return}let a=r.join(d,"hooks"),p=[];for(let l of ["post-commit","pre-push"]){let t=r.join(a,l);e.existsSync(t)&&e.readFileSync(t,"utf8").includes("paradigm")&&(c?console.log(o.gray(` Would remove: ${t}`)):e.unlinkSync(t),p.push(l));}c?p.length===0&&console.log(o.gray(" No paradigm git hooks to remove")):p.length>0?console.log(o.green(`Git hooks removed: ${p.join(", ")}`)):console.log(o.gray("No paradigm git hooks found to remove"));}if(i.cursor){let d=r.join(h,".cursor","hooks"),a=[];for(let l of ["paradigm-session-start.sh","paradigm-stop.sh","paradigm-precommit.sh","paradigm-postwrite.sh","paradigm-pretooluse.sh","paradigm-posttooluse.sh"]){let t=r.join(d,l);e.existsSync(t)&&(c?console.log(o.gray(` Would remove: ${t}`)):e.unlinkSync(t),a.push(l));}let p=r.join(h,".cursor","hooks.json");if(e.existsSync(p))if(c)console.log(o.gray(` Would clean paradigm entries from: ${p}`));else try{let l=JSON.parse(e.readFileSync(p,"utf8")),t=l.hooks||{};for(let s of ["sessionStart","stop","afterFileEdit","beforeShellExecution","preToolUse","postToolUse"])Array.isArray(t[s])&&(t[s]=t[s].filter(n=>!JSON.stringify(n).includes("paradigm-")),t[s].length===0&&delete t[s]);l.hooks=t,e.writeFileSync(p,JSON.stringify(l,null,2)+`
|
|
1735
1788
|
`,"utf8");}catch{}c?a.length===0&&console.log(o.gray(" No paradigm Cursor hooks to remove")):a.length>0?console.log(o.green(`Cursor hooks removed: ${a.join(", ")}`)):console.log(o.gray("No paradigm Cursor hooks found to remove"));}c&&console.log(o.cyan(`
|
|
1736
1789
|
[dry-run] No changes made.
|
|
1737
1790
|
`));}async function ne(){let i=process.cwd(),h=r.join(i,".git");if(e.existsSync(h)){console.log(o.magenta(`
|
|
1738
1791
|
Git Hooks Status
|
|
1739
|
-
`));let l=r.join(h,"hooks"),
|
|
1792
|
+
`));let l=r.join(h,"hooks"),t=["post-commit","pre-push"];for(let n of t){let f=r.join(l,n);e.existsSync(f)?e.readFileSync(f,"utf8").includes("paradigm")?console.log(o.green(` ${n}: installed (paradigm)`)):console.log(o.yellow(` ${n}: exists (other)`)):console.log(o.gray(` ${n}: not installed`));}console.log();let s=r.join(i,".paradigm/history");if(e.existsSync(s)){let n=r.join(s,"log.jsonl");if(e.existsSync(n)){let O=e.readFileSync(n,"utf8").split(`
|
|
1740
1793
|
`).filter(u=>u.trim()).length;console.log(o.white(` History entries: ${O}`));}}else console.log(o.gray(" History: not initialized")),console.log(o.gray(" Run `paradigm history init` to enable"));}else console.log(o.gray(`
|
|
1741
1794
|
Not a git repository (git hooks N/A)
|
|
1742
1795
|
`));console.log(o.magenta(` Claude Code Hooks Status
|
|
1743
|
-
`));let c=
|
|
1796
|
+
`));let c=F();if(c.active){console.log(o.cyan(` Plugin: paradigm v${c.cacheVersion} (active)`)),console.log(o.green(" Hooks are managed by the plugin \u2014 auto-updates with each session."));let l=r.join(i,".claude","hooks"),t=[];for(let f of ["paradigm-common.sh","paradigm-stop.sh","paradigm-precommit.sh","paradigm-postwrite.sh","paradigm-navigate-remind.sh"])e.existsSync(r.join(l,f))&&t.push(f);let s=r.join(i,".claude","settings.json"),n=false;if(e.existsSync(s))try{let f=JSON.parse(e.readFileSync(s,"utf8"));n=JSON.stringify(f.hooks||{}).includes("paradigm-");}catch{}(t.length>0||n)&&(console.log(o.yellow(` WARNING: Stale project hooks detected (${t.join(", ")}${n?", settings.json entries":""})`)),console.log(o.yellow(" These shadow the plugin hooks and may run outdated logic.")),console.log(o.gray(" Run `paradigm hooks install --claude-code` to clean them up.")));}else {console.log(o.gray(" Plugin: not active (using project-level hooks)"));let l=r.join(i,".claude","hooks"),t=["paradigm-stop.sh","paradigm-precommit.sh","paradigm-postwrite.sh","paradigm-navigate-remind.sh"];for(let n of t){let f=r.join(l,n);e.existsSync(f)?console.log(o.green(` ${n}: installed`)):console.log(o.gray(` ${n}: not installed`));}let s=r.join(i,".claude","settings.json");if(e.existsSync(s))try{let f=JSON.parse(e.readFileSync(s,"utf8")).hooks||{},O=JSON.stringify(f.Stop||[]).includes("paradigm-stop.sh"),u=JSON.stringify(f.PreToolUse||[]).includes("paradigm-precommit.sh"),_=JSON.stringify(f.PostToolUse||[]).includes("paradigm-postwrite.sh");console.log(o.gray(` settings.json Stop hook: ${O?"configured":"missing"}`)),console.log(o.gray(` settings.json PreToolUse hook: ${u?"configured":"missing"}`)),console.log(o.gray(` settings.json PostToolUse hook: ${_?"configured":"missing"}`));}catch{console.log(o.yellow(" settings.json: parse error"));}else console.log(o.gray(" settings.json: not found"));}console.log(o.magenta(`
|
|
1744
1797
|
Cursor Hooks Status
|
|
1745
|
-
`));let d=r.join(i,".cursor","hooks"),a=["paradigm-session-start.sh","paradigm-stop.sh","paradigm-precommit.sh","paradigm-postwrite.sh","paradigm-pretooluse.sh","paradigm-posttooluse.sh"];for(let l of a){let
|
|
1798
|
+
`));let d=r.join(i,".cursor","hooks"),a=["paradigm-session-start.sh","paradigm-stop.sh","paradigm-precommit.sh","paradigm-postwrite.sh","paradigm-pretooluse.sh","paradigm-posttooluse.sh"];for(let l of a){let t=r.join(d,l);e.existsSync(t)?console.log(o.green(` ${l}: installed`)):console.log(o.gray(` ${l}: not installed`));}let p=r.join(i,".cursor","hooks.json");if(e.existsSync(p))try{let t=JSON.parse(e.readFileSync(p,"utf8")).hooks||{},s=JSON.stringify(t.sessionStart||[]).includes("paradigm-session-start.sh"),n=JSON.stringify(t.stop||[]).includes("paradigm-stop.sh"),f=JSON.stringify(t.afterFileEdit||[]).includes("paradigm-postwrite.sh"),O=JSON.stringify(t.beforeShellExecution||[]).includes("paradigm-precommit.sh"),u=JSON.stringify(t.preToolUse||[]).includes("paradigm-pretooluse.sh"),_=JSON.stringify(t.postToolUse||[]).includes("paradigm-posttooluse.sh");console.log(o.gray(` hooks.json sessionStart: ${s?"configured":"missing"}`)),console.log(o.gray(` hooks.json stop: ${n?"configured":"missing"}`)),console.log(o.gray(` hooks.json afterFileEdit: ${f?"configured":"missing"}`)),console.log(o.gray(` hooks.json preToolUse: ${u?"configured":"missing"}`)),console.log(o.gray(` hooks.json postToolUse: ${_?"configured":"missing"}`)),console.log(o.gray(` hooks.json beforeShellExecution: ${O?"configured":"missing"}`));}catch{console.log(o.yellow(" hooks.json: parse error"));}else console.log(o.gray(" hooks.json: not found"));console.log();}export{re as a,ae as b,ne as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-HOBHJPTL.js';import {e,f,c,d,l,h,g,k,i,m as m$1,o,n,j,b as b$1,a as a$1}from'./chunk-AO7ZSRME.js';import {a}from'./chunk-Y4XFVDZC.js';import*as $ from'fs';import*as m from'path';import e$1 from'chalk';import E from'prompts';function F(){return process.env.CLAUDE_CODE==="1"||process.env.TERM_PROGRAM==="claude"?false:!!(process.env.TERM_PROGRAM==="cursor"||process.env.CURSOR_SESSION||process.env.CURSOR_TRACE_ID||process.env.VSCODE_CWD&&process.env.VSCODE_CWD.toLowerCase().includes("cursor")||process.env.VSCODE_NLS_CONFIG&&process.env.VSCODE_NLS_CONFIG.toLowerCase().includes("cursor")||process.env.TERM_PROGRAM==="vscode"&&process.env.VSCODE_GIT_ASKPASS_NODE?.toLowerCase().includes("cursor")||process.stdin.isTTY)}async function T(g){let n=new a(g),c=await n.discover();console.log(e$1.cyan(`
|
|
3
3
|
Configure Agent Models
|
|
4
4
|
`)),console.log(e$1.gray(` Environment: ${c.source}`)),console.log(e$1.gray(` Available: ${c.models.length} models
|
|
5
5
|
`));let i={},o=n.groupByTier(c.models),a$2=t=>{let r=a$1[t],s=r.tier==="high"?o.high:r.tier==="medium"?o.medium:o.low,l=[];for(let f of s){let P=l.length===0;l.push({title:P?`${f.name} (recommended)`:f.name,value:f.id,description:`${f.provider} - ${r.tier} tier`});}let u=o.high.filter(f=>!s.includes(f)),y=o.medium.filter(f=>!s.includes(f)),v=o.low.filter(f=>!s.includes(f));for(let f of u)l.push({title:f.name,value:f.id,description:`${f.provider} - high tier`});for(let f of y)l.push({title:f.name,value:f.id,description:`${f.provider} - medium tier`});for(let f of v)l.push({title:f.name,value:f.id,description:`${f.provider} - low tier`});return l};for(let t of ["architect","builder","tester","reviewer","security"]){let r=a$1[t],s=t.charAt(0).toUpperCase()+t.slice(1),l=a$2(t),u=await E({type:"select",name:"model",message:`${s} (${r.description})`,choices:l,initial:0},{onCancel:()=>{console.log(e$1.yellow(`
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {h as h$1}from'./chunk-ZJQY5PPP.js';import*as y from'fs';import*as h from'path';import*as E from'js-yaml';import {execFileSync}from'child_process';function w(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;let a=new Array(e.length+1),r=new Array(e.length+1);for(let s=0;s<=e.length;s++)a[s]=s;for(let s=1;s<=t.length;s++){r[0]=s;for(let n=1;n<=e.length;n++){let c=t.charCodeAt(s-1)===e.charCodeAt(n-1)?0:1;r[n]=Math.min(r[n-1]+1,a[n]+1,a[n-1]+c);}let o=a;a=r,r=o;}return a[e.length]}function S(t,e){if(!t||e.length===0)return;let a;for(let r of e){if(r===t)continue;let s=w(t,r),o=Math.max(t.length,r.length);if(o===0)continue;let n=s/o;(s<=2||n<=.3)&&(!a||s<a.distance)&&(a={didYouMean:r,distance:s});}return a}function M(t,e){let a=[];for(let r of t){let s=S(r,e);s&&a.push({gate:r,didYouMean:s.didYouMean,distance:s.distance});}return a}function $(t,e){let a=[];for(let r of t){let s=S(r,e);s&&a.push({gate:r,didYouMean:s.didYouMean,distance:s.distance});}return a}var R=["node_modules",".git","dist","build","coverage",".paradigm","vendor","__pycache__",".next","target"];function B(t){let e=h.join(t,"portal.yaml");if(!y.existsSync(e))return {status:"missing"};let a;try{a=y.readFileSync(e,"utf-8");}catch{return {status:"unparseable",errorClass:"other",detail:"file read error"}}try{return {status:"ok",data:E.load(a)}}catch(r){let{errorClass:s,detail:o}=h$1(r);return {status:"unparseable",errorClass:s,detail:o}}}function O(t){let e=B(t);return e.status==="ok"?e.data:null}function Y(t){let e=new Set;if(t.gates)for(let a of Object.keys(t.gates)){let r=a.startsWith("^")?a.slice(1):a;e.add(r);}if(t.routes)for(let a of Object.values(t.routes)){let r=Array.isArray(a)?a:a.gates||[];for(let s of r){let o=s.startsWith("^")?s.slice(1):s;e.add(o);}}return Array.from(e)}function v(t){let e=new Set;if(t.routes)for(let a of Object.values(t.routes)){let r=Array.isArray(a)?a:a.gates||[];for(let s of r){let o=s.startsWith("^")?s.slice(1):s;e.add(o);}}return e}function N(t,e){let a={encoding:"utf-8",maxBuffer:10485760,stdio:["ignore","pipe","pipe"]};try{let n=["-n","--no-ignore-vcs",...R.flatMap(c=>["--glob",`!${c}/**`]),"--engine","auto",e,t];return execFileSync("rg",n,a)}catch{}let s=["-rn",...R.map(o=>`--exclude-dir=${o}`),"-E",e,"--",t];try{return execFileSync("grep",s,a)}catch(o){return o?.code===1||o?.status===1,""}}var D=["**/.purpose","**/portal.yaml","**/.paradigm/**/*.yaml","**/.paradigm/**/*.yml"];function _(t){let e=[];for(let s of D){h.join(t,s);let n;try{n=execFileSync("find",[t,"-path","*/node_modules","-prune","-o","-path","*/.git","-prune","-o","(","-name",".purpose","-o","-name","portal.yaml",")","-print"],{encoding:"utf-8",maxBuffer:5242880}).split(`
|
|
3
|
+
`).filter(Boolean);}catch{n=[];}for(let c of n)try{let u=y.readFileSync(c,"utf-8").split(`
|
|
4
|
+
`);for(let d=0;d<u.length;d++){let p=u[d],l=p.matchAll(/\^([a-z][a-z0-9-]+)/g);for(let m of l)e.push({gate:m[1],file:h.relative(t,c),line:d+1,context:p.trim().slice(0,100),matchType:"symbol"});}}catch{}}let r=[{pattern:`checkGate\\s*\\(['"]([^'"]+)['"]`,type:"function"},{pattern:`requireGate\\s*\\(['"]([^'"]+)['"]`,type:"function"},{pattern:`@Gate\\s*\\(['"]?([^'"\\)]+)['"]?\\)`,type:"function"}];for(let{pattern:s,type:o}of r){let n=N(t,s);for(let c of n.split(`
|
|
5
|
+
`).filter(Boolean)){let f=c.match(/^(.+?):(\d+):(.*)$/);if(f){let[,u,d,p]=f,l=p.match(new RegExp(s));if(l&&l[1]){let m=l[1].startsWith("^")?l[1].slice(1):l[1];e.push({gate:m,file:h.relative(t,u),line:parseInt(d,10),context:p.trim().slice(0,100),matchType:o});}}}}return e}function P(t){return [...new Set(t.map(e=>e.gate))]}async function I(t){let e=B(t);if(e.status==="unparseable"){let i=e.errorClass==="duplicate-key"?"duplicate mapping key detected":e.errorClass==="syntax"?"YAML syntax error":"YAML parse error";return {status:"violations",declaredButUnused:[],routeAttachedUnused:[],orphanUnused:[],usedButUndeclared:["__portal_unparseable__"],properlyDeclared:[],suggestions:[`portal.yaml unparseable: ${i} \u2014 run 'paradigm doctor' for details`],references:[],portalError:{kind:"unparseable",errorClass:e.errorClass,detail:e.detail}}}if(e.status==="missing"){let i=_(t),A=P(i);return A.length===0?{status:"compliant",declaredButUnused:[],routeAttachedUnused:[],orphanUnused:[],usedButUndeclared:[],properlyDeclared:[],suggestions:["No portal.yaml found, and no gate references detected in code."],references:[]}:{status:"violations",declaredButUnused:[],routeAttachedUnused:[],orphanUnused:[],usedButUndeclared:A,properlyDeclared:[],suggestions:["Gate references found in code but no portal.yaml exists.","Create a portal.yaml file to declare these gates:",...A.map(k=>` - ^${k}`),"","Run: paradigm portal init"],references:i}}let a=e.data,r=Y(a),s=v(a),o=_(t),n=P(o),c=new Set(r),f=new Set(n),u=r.filter(i=>!f.has(i)),d=u.filter(i=>s.has(i)),p=u.filter(i=>!s.has(i)),l=n.filter(i=>!c.has(i)),m=r.filter(i=>f.has(i)),g=[];if(d.length>0){g.push("Gates documented on routes but no checkGate/requireGate in code:");for(let i of d)g.push(` - ^${i} (documented on routes; if enforced by middleware, this may be intentional)`);g.push("");}if(p.length>0){g.push("Orphan gates (declared but never on a route or in code):");for(let i of p)g.push(` - ^${i} (add to a route or remove from portal.yaml)`);g.push("");}if(l.length>0){g.push("Gates used in code but not declared in portal.yaml:");for(let i of l)g.push(` - ^${i} (add to portal.yaml with proper definition)`);g.push("");}let x="compliant";l.length>0?x="violations":u.length>0&&(x="warnings");let U=[],C=l.filter(i=>i!=="__portal_unparseable__");return C.length>0&&U.push(...M(C,r)),u.length>0&&C.length>0&&U.push(...$(u,C)),{status:x,declaredButUnused:u,routeAttachedUnused:d,orphanUnused:p,usedButUndeclared:l,properlyDeclared:m,suggestions:g,references:o,...U.length>0?{nearMatches:U}:{}}}function z(t){let e=[],a=t.status==="compliant"?"\u2713":t.status==="warnings"?"\u26A0":"\u2717";if(e.push(`Portal Compliance: ${a} ${t.status.toUpperCase()}`),e.push(""),e.push(`Properly Declared: ${t.properlyDeclared.length}`),t.routeAttachedUnused.length>0&&e.push(`Route-Attached, No Code: ${t.routeAttachedUnused.length}`),t.orphanUnused.length>0&&e.push(`Orphan Gates: ${t.orphanUnused.length}`),t.usedButUndeclared.length>0&&e.push(`Used but Undeclared: ${t.usedButUndeclared.length}`),e.push(""),t.properlyDeclared.length>0){e.push("Gates in Use:");for(let n of t.properlyDeclared)e.push(` \u2713 ^${n}`);e.push("");}if(t.routeAttachedUnused.length>0){e.push("Route-Attached (no checkGate/requireGate in code):");for(let n of t.routeAttachedUnused)e.push(` \u26A0 ^${n}`);e.push("");}if(t.orphanUnused.length>0){e.push("Orphan Gates (declared but never on route or in code):");for(let n of t.orphanUnused)e.push(` \u26A0 ^${n}`);e.push("");}t.portalError&&(e.push("Portal Unparseable:"),e.push(` \u2717 ${t.portalError.detail} \u2014 run 'paradigm doctor' for details`),e.push(""));let r=t.usedButUndeclared.filter(n=>n!=="__portal_unparseable__"),s=new Map,o=new Map;if(t.nearMatches)for(let n of t.nearMatches)r.includes(n.gate)&&!s.has(n.gate)?s.set(n.gate,{didYouMean:n.didYouMean,distance:n.distance}):t.declaredButUnused.includes(n.gate)&&!o.has(n.gate)&&o.set(n.gate,{didYouMean:n.didYouMean,distance:n.distance});if(r.length>0){e.push("Undeclared Gates (used but not in portal.yaml):");for(let n of r){e.push(` \u2717 ^${n}`);let c=s.get(n);c&&e.push(` Did you mean: ^${c.didYouMean}? (declared in portal.yaml)`);let f=t.references.filter(u=>u.gate===n).slice(0,3);for(let u of f)e.push(` at ${u.file}:${u.line}`);}e.push("");}if(o.size>0){e.push("Possible Typos (declared gates may be misspelled references):");for(let[n,c]of o)e.push(` ? ^${n} \u2014 did you mean to reference as ^${c.didYouMean}?`);e.push("");}if(t.suggestions.length>0&&t.status!=="compliant"){e.push("Suggestions:");for(let n of t.suggestions)n&&e.push(` ${n}`);}return e.join(`
|
|
6
|
+
`)}function W(t){if(t.status==="compliant")return {status:"ok",message:`${t.properlyDeclared.length} gates properly declared`};if(t.status==="warnings"){let e=[];return t.routeAttachedUnused.length>0&&e.push(`${t.routeAttachedUnused.length} route-attached`),t.orphanUnused.length>0&&e.push(`${t.orphanUnused.length} orphan`),{status:"warn",message:e.length>0?e.join(", ")+" gate(s)":`${t.declaredButUnused.length} unused gates`}}return {status:"error",message:`${t.usedButUndeclared.length} gates used but not declared`}}export{B as a,O as b,Y as c,_ as d,I as e,z as f,W as g};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b as b$1}from'./chunk-
|
|
2
|
+
import {b as b$1}from'./chunk-Y4P4SGZV.js';import {a as a$2,g as g$1,h,d as d$1,f}from'./chunk-UIKLE3WD.js';import {g}from'./chunk-LWAIVOSF.js';import {c}from'./chunk-JIXHEBGK.js';import {c as c$1,d,e}from'./chunk-DOCDDDTD.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import*as i from'fs';import*as a from'path';import {fileURLToPath}from'url';import t from'chalk';import q from'ora';function b(s){try{return i.readFileSync(s,"utf8").split(`
|
|
3
3
|
`).length}catch{return 0}}function _(s){let o=g$1(s);if(o&&f[o])return f[o].name;let e=a$2(s);if(e!=="backend")return e.charAt(0).toUpperCase()+e.slice(1)}function U(s){let o=[],e=0,n={name:"cursor",displayName:"Cursor"},g=a.join(s,".cursorrules"),r=a.join(s,".cursor","rules");if(i.existsSync(g)){let l=b(g);n.legacy={path:".cursorrules",lines:l,type:"legacy"},e+=l;}if(i.existsSync(r)){let l=i.readdirSync(r).filter(m=>m.endsWith(".mdc"));l.length>0&&(n.modern=l.map(m=>{let x=a.join(r,m),j=b(x);return e+=j,{path:`.cursor/rules/${m}`,lines:j,type:"modern"}}));}(n.legacy||n.modern)&&o.push(n);let u={name:"copilot",displayName:"GitHub Copilot"},c=a.join(s,".github","copilot-instructions.md"),f=a.join(s,".github","instructions");if(i.existsSync(c)){let l=b(c);u.legacy={path:".github/copilot-instructions.md",lines:l,type:"legacy"},e+=l;}if(i.existsSync(f)){let l=i.readdirSync(f).filter(m=>m.endsWith(".md"));l.length>0&&(u.modern=l.map(m=>{let x=a.join(f,m),j=b(x);return e+=j,{path:`.github/instructions/${m}`,lines:j,type:"modern"}}));}(u.legacy||u.modern)&&o.push(u);let h=a.join(s,".windsurfrules");if(i.existsSync(h)){let l=b(h);o.push({name:"windsurf",displayName:"Windsurf",legacy:{path:".windsurfrules",lines:l,type:"legacy"}}),e+=l;}let w=a.join(s,"CLAUDE.md");if(i.existsSync(w)){let l=b(w);o.push({name:"claude",displayName:"Claude",legacy:{path:"CLAUDE.md",lines:l,type:"legacy"}}),e+=l;}let p=a.join(s,"AGENTS.md");if(i.existsSync(p)){let l=b(p);o.push({name:"agents",displayName:"AGENTS.md",legacy:{path:"AGENTS.md",lines:l,type:"legacy"}}),e+=l;}let y=a$2(s),d=g$1(s);return {ides:o,hasExisting:o.length>0,totalLines:e,projectType:_(s),discipline:y!=="backend"?y:void 0,stack:d||void 0}}function O(s,o){let e=[];e.push("# Migrate IDE Instructions to Paradigm Format"),e.push(""),e.push("## Overview"),e.push(""),e.push(`Migrate existing IDE instruction files for **${o}** to Paradigm's managed, scoped format.`),e.push(""),e.push("## Source Files Found"),e.push("");for(let n of s.ides)if(n.legacy&&e.push(`- \`${n.legacy.path}\` (${n.legacy.lines} lines) - ${n.displayName} ${n.legacy.type} format`),n.modern)for(let g of n.modern)e.push(`- \`${g.path}\` (${g.lines} lines) - ${n.displayName} modern format`);return e.push(""),s.ides.some(n=>n.name==="cursor")&&(e.push("## Cursor Migration \u2192 `.cursor/rules/*.mdc`"),e.push(""),e.push("Split the existing `.cursorrules` into scoped `.mdc` files with YAML frontmatter:"),e.push(""),e.push("### File Structure"),e.push(""),e.push("```"),e.push(".cursor/rules/"),e.push("\u251C\u2500\u2500 project-core.mdc # Always applies - project overview, architecture"),e.push("\u251C\u2500\u2500 code-style.mdc # globs: **/*.{ts,tsx,js,jsx} - naming, formatting"),e.push("\u251C\u2500\u2500 components.mdc # globs: **/components/**/* - component patterns"),e.push("\u251C\u2500\u2500 api-patterns.mdc # globs: **/api/**/* - API conventions"),e.push("\u251C\u2500\u2500 testing.mdc # globs: **/*.test.* - testing guidelines"),e.push("\u2514\u2500\u2500 custom.mdc # Any project-specific rules"),e.push("```"),e.push(""),e.push("### Frontmatter Format"),e.push(""),e.push("```yaml"),e.push("---"),e.push("description: Brief description of what these rules cover"),e.push('globs: "**/*.ts" # File pattern (OR use alwaysApply)'),e.push("alwaysApply: true # Apply to all files (OR use globs)"),e.push("---"),e.push("```"),e.push("")),s.ides.some(n=>n.name==="copilot")&&(e.push("## Copilot Migration \u2192 `.github/instructions/*.instructions.md`"),e.push(""),e.push("Split into scoped instruction files with `applyTo` frontmatter:"),e.push(""),e.push("### File Structure"),e.push(""),e.push("```"),e.push(".github/"),e.push("\u251C\u2500\u2500 copilot-instructions.md # Always applies - core rules"),e.push("\u2514\u2500\u2500 instructions/"),e.push(" \u251C\u2500\u2500 typescript.instructions.md # applyTo: **/*.ts"),e.push(" \u251C\u2500\u2500 react.instructions.md # applyTo: **/*.tsx"),e.push(" \u251C\u2500\u2500 api.instructions.md # applyTo: **/api/**"),e.push(" \u2514\u2500\u2500 testing.instructions.md # applyTo: **/*.test.*"),e.push("```"),e.push(""),e.push("### Frontmatter Format"),e.push(""),e.push("```yaml"),e.push("---"),e.push('applyTo: "**/*.ts"'),e.push("---"),e.push("```"),e.push("")),e.push("## Migration Steps"),e.push(""),e.push("1. **Read each source file** and identify logical sections:"),e.push(" - Project overview / architecture"),e.push(" - Code style / naming conventions"),e.push(" - Language-specific patterns"),e.push(" - Framework-specific rules"),e.push(" - Testing guidelines"),e.push(" - API patterns"),e.push(""),e.push("2. **Create scoped target files** with appropriate frontmatter"),e.push(""),e.push("3. **Backup originals** by renaming to `.bak`:"),e.push(" - `.cursorrules` \u2192 `.cursorrules.bak`"),e.push(" - `.github/copilot-instructions.md` \u2192 `.github/copilot-instructions.md.bak`"),e.push(""),e.push("4. **Verify** the migration by checking that rules apply correctly"),e.push(""),e.push("## Tips"),e.push(""),e.push("- **Prefer specific globs** over `alwaysApply` when possible"),e.push("- **Keep files focused** - one concern per file"),e.push("- **Use descriptive names** that indicate the scope"),e.push("- **Paradigm will generate its own rules** - keep custom rules separate"),e.push("- After migration, run `paradigm sync` to add Paradigm-managed rules"),e.push(""),e.push("---"),e.push(""),e.push("*Generated by `paradigm init --migrate`*"),e.join(`
|
|
4
4
|
`)}function G(){let s=fileURLToPath(import.meta.url),o=a.dirname(s),e=[a.join(o,"..","..","templates","paradigm"),a.join(o,"..","templates","paradigm"),a.join(o,"..","..","src","templates","paradigm")];for(let n of e)if(i.existsSync(n))return n;return a.join(o,"..","templates","paradigm")}var A={directories:["prompts"],files:["echoes.yaml","docs/commands.md","docs/queries.md","specs/disciplines.md","specs/scan.md","specs/context-tracking.md"]};function z(s){for(let o of A.directories)if(s===o||s.startsWith(o+"/"))return true;return !!A.files.includes(s)}function N(s,o,e,n=""){i.existsSync(o)||i.mkdirSync(o,{recursive:true});let g=i.readdirSync(s,{withFileTypes:true});for(let r of g){let u=a.join(s,r.name),c=a.join(o,r.name),f=n?`${n}/${r.name}`:r.name;if(!z(f))if(r.isDirectory())N(u,c,e,f);else {let h=i.readFileSync(u,"utf8");h=h.replace(/\{\{PROJECT_NAME\}\}/g,e),i.writeFileSync(c,h,"utf8");}}}function M(s,o){if(console.log(t.blue(`
|
|
5
5
|
\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(" Welcome to Paradigm ")+t.blue("\u2502")),console.log(t.blue("\u2502")+t.gray(" Let's set up your project ")+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
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a as a$3}from'./chunk-TYWB5IQJ.js';import {b,a as a$1}from'./chunk-ORDKEGII.js';import {e}from'./chunk-AO7ZSRME.js';import {a}from'./chunk-FYDRENK7.js';import {b as b$1}from'./chunk-EKZDFEJW.js';import {a as a$2,c}from'./chunk-4VKSEOXZ.js';import {o,t,x}from'./chunk-LWAIVOSF.js';import'minimatch';import*as w from'fs';import*as A from'path';import*as F from'js-yaml';import {spawn}from'child_process';var ee=["should","what","how","why","recommend","analyze","compare","evaluate","assess","review","explain","describe","investigate","which","best practice","trade-off","tradeoff","pros and cons","decision"],te=["document","write docs","readme",".purpose","purpose file","jsdoc","tsdoc","comments","docstring","api docs","changelog","architecture doc"],se=["bug","fix","broken","not working","issue","error","crash","fails","failing","wrong","incorrect","doesn't work","doesn't","cant","can't","regression","patch"],re=["rename","refactor","migrate","restructure","move","reorganize","clean up","cleanup","consolidate","extract","inline","simplify","modularize","decouple","split","merge"],ne=["auth","authentication","authorization","permission","admin","delete","purge","password","credential","token","secret","key","encrypt","decrypt","hash","session","oauth","jwt","api key","role","access","gate","portal","sensitive","private","security","vulnerability","xss","sql injection","csrf"],oe=/[@#$%^!?&~][a-zA-Z0-9_-]+/g,Y={analysis:{agents:["architect"],models:{architect:"opus"},costMultiplier:{min:.3,max:.5}},documentation:{agents:["architect"],models:{architect:"sonnet"},costMultiplier:{min:.25,max:.45}},bugfix:{agents:["security","builder"],models:{security:"opus",builder:"haiku"},costMultiplier:{min:.5,max:.8}},refactor:{agents:["architect","builder"],models:{architect:"opus",builder:"haiku"},costMultiplier:{min:.6,max:.85}},feature:{agents:["architect","security","builder","tester"],models:{architect:"opus",security:"opus",builder:"haiku",tester:"haiku"},costMultiplier:{min:.8,max:1.2}}};function ie(p){let s=p.match(oe)||[];return [...new Set(s)]}function $(p,s){let e=p.toLowerCase();return s.filter(t=>e.includes(t.toLowerCase()))}function ae(p,s,e,t){let n=0;e.length>=5?n+=2:e.length>=2&&(n+=1);let o=p.split(/\s+/).length;o>=100?n+=2:o>=50&&(n+=1);let r=new Set(e.map(a=>a[0]));return r.size>=4?n+=2:r.size>=2&&(n+=1),e.some(a=>a.startsWith("^"))&&(n+=1),e.some(a=>a.startsWith("$"))&&(n+=1),s==="feature"&&(n+=1),s==="refactor"&&(n+=1),n>=5?"high":n>=2?"medium":"low"}function le(p,s,e){if($(p,ne).length>0||s.some(n=>n.startsWith("^")))return true;return false}function K(p,s){let e=ie(p),t=$(p,ee),n=$(p,te),o=$(p,se),r=$(p,re),a,i;t.length>0&&o.length===0&&r.length===0?(a="analysis",i=t):n.length>0&&o.length===0?(a="documentation",i=n):o.length>0?(a="bugfix",i=o):r.length>0?(a="refactor",i=r):(a="feature",i=[]);let c=Y[a],d=le(p,e),u=[...c.agents];d&&!u.includes("security")&&(u=["security",...u]);let m=ae(p,a,e),g={...c.costMultiplier};return m==="high"?(g.min*=1.2,g.max*=1.3):m==="low"&&(g.min*=.8,g.max*=.9),d&&!c.agents.includes("security")&&(g.min+=.15,g.max+=.2),{type:a,complexity:m,recommendedAgents:u,securityRequired:d,costMultiplier:g,matchedKeywords:i,symbols:e}}function B(p,s){let e=Y[s.type];return p==="security"&&s.securityRequired?"opus":e.models[p]||"sonnet"}var ce=/[@#$%^!?&~][a-zA-Z][a-zA-Z0-9_-]*/g,ue=[/\.(get|post|put|patch|delete)\s*\(\s*['"`]([^'"`]+)['"`]/gi,/export\s+(async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)/gi,/export\s+(async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)/gi,/\.(get|post|put|patch|delete)\s*\(\s*['"`]([^'"`]+)['"`]/gi],de=["endpoint","route","api","handler","get","post","put","patch","delete","rest","crud","controller"];function V(p,s,e$1){let t$1=p.toLowerCase(),n=p.match(ce)||[],o=[...new Set(n)],r=o.map(l=>{let y=t(e$1,l),k=y.length>0?y[0]:null;return {symbol:l,exists:!!k,type:k?.type,description:k?.description}}),a=r.filter(l=>l.exists).map(l=>{let y=x(e$1,l.symbol),k=new Set;for(let S of y){let x$1=x(e$1,S.symbol);for(let P of x$1)P.symbol!==l.symbol&&!y.find(O=>O.symbol===P.symbol)&&k.add(P.symbol);}let f=y.length+k.size,b="low";return f>10?b="high":f>3&&(b="medium"),{symbol:l.symbol,directDependents:y.length,indirectDependents:k.size,impact:b}}),i=a$2(s),c$1=i.status==="ok"?i.data:null,d={exists:i.status!=="missing",gateCount:c$1?c(c$1).length:0,gates:c$1?c(c$1).map(l=>`^${l}`):[],routeCount:c$1?.routes?Object.keys(c$1.routes).length:0},u=de.some(l=>t$1.includes(l)),m=e(s),g=m?a$3(p,m.agents).map(l=>({name:l.name,confidence:l.confidence,reason:l.reason})):[],h=[];return r.some(l=>l.exists)&&h.push("ripple-analysis"),u&&h.push("portal-compliance"),o.some(l=>l.startsWith("^"))&&h.push("gate-validation"),o.some(l=>l.startsWith("!"))&&h.push("signal-registration"),h.push("purpose-coverage"),{affectedSymbols:r,rippleAnalysis:a,portalStatus:d,taskAddsRoutes:u,suggestedAgents:g,requiredChecks:h}}function H(p,s,e,t$1){let n=[],o=a$2(e),r=o.status==="ok"?o.data:null,a=r?c(r):[],i=r?.routes?Object.keys(r.routes):[];for(let g of p){let h=A.isAbsolute(g)?g:A.join(e,g);if(!w.existsSync(h))continue;let l;try{l=w.readFileSync(h,"utf-8");}catch{continue}for(let y of ue){y.lastIndex=0;let k;for(;(k=y.exec(l))!==null;){let f=k[2]||k[0];f&&f.startsWith("/")&&(!i.some(S=>S.replace(/\s+(GET|POST|PUT|PATCH|DELETE)\s*$/,"").trim()===f)&&r?n.push({type:"missing-portal-gate",severity:"warning",message:`Route "${f}" found in ${A.relative(e,h)} but not declared in portal.yaml`,file:A.relative(e,h),suggestion:"Add this route to portal.yaml with appropriate ^gates. Run paradigm_gates_for_route to get suggestions."}):!r&&f.startsWith("/api/")&&n.push({type:"missing-portal-gate",severity:"warning",message:`API route "${f}" found but no portal.yaml exists`,file:A.relative(e,h),suggestion:"Create portal.yaml to declare gates for API routes. Run: paradigm portal init"}));}}}for(let g of s)t(t$1,g).length===0&&n.push({type:"unregistered-symbol",severity:"error",message:`Symbol "${g}" was touched but is not registered in any .purpose file`,suggestion:`Add "${g}" to the nearest .purpose file. Use paradigm_purpose_add_component or paradigm_purpose_add_signal.`});for(let g of s)if(g.startsWith("^")){let h=g.slice(1);a.includes(h)||n.push({type:"missing-portal-gate",severity:"error",message:`Gate "${g}" is referenced but not declared in portal.yaml`,suggestion:`Add ${g} to portal.yaml with description and check expression.`});}p.length>=5&&s.length>=3&&n.push({type:"uncaptured-wisdom",severity:"warning",message:`Large change (${p.length} files, ${s.length} symbols) \u2014 consider recording architectural decisions`,suggestion:"Use paradigm_wisdom_record to capture any decisions or antipatterns discovered during this task."});let c$1=n.filter(g=>g.severity==="error").length,d=n.filter(g=>g.severity==="warning").length,u=4,m="pass";return c$1>0?m="violations":d>0&&(m="warnings"),{status:m,violations:n,summary:{totalChecks:u,passed:u-(c$1>0?1:0)-(d>0?1:0),warnings:d,errors:c$1},blocksCompletion:c$1>0}}var pe={architect:"opus",security:"opus",reviewer:"sonnet",builder:"haiku",tester:"haiku"},he=["auth","permission","admin","delete","purge","password","credential","token","secret","key","encrypt","decrypt","hash","session","oauth","jwt","role","access control","vulnerability","injection","xss","csrf"];function me(p,s){let e=p.toLowerCase(),t=he.some(r=>e.includes(r.toLowerCase())),n=p.includes("^"),o=false;return t||n||o}var ye=["rename","refactor","migrate","restructure","move","reorganize"];function be(p){let s=p.toLowerCase();return ye.some(e=>s.includes(e))}var E=class{spawner;auditLogger;rootDir;constructor(s){this.rootDir=s,this.spawner=new b(s),this.auditLogger=new a(s);}async initialize(){await this.spawner.initialize();}async orchestrate(s,e={}){let t=e.mode||"faceted",n=Date.now(),o$1=this.generateOrchestrationId(),r={success:false,mode:t,orchestrationId:o$1,task:s,agentsSpawned:0,totalTokens:{input:0,output:0,total:0},totalCost:0,duration_ms:0,agentResults:[]};try{let a;if(e.pmGovernance?.enabled)try{let{aggregateFromDirectory:c}=await import('./dist-OG6MM4VY.js'),d=await c(this.rootDir),u=o(d);a=V(s,this.rootDir,u);}catch{}if(t==="solo"){let c=await this.runSoloMode(s,e);r.agentsSpawned=1,r.agentResults=[c],r.success=c.success,c.relay&&(r.totalTokens=c.relay.metrics.tokens_used,r.totalCost=b$1(r.totalTokens,e.orchestratorModel||"opus"));}else {let c=await this.runFacetedMode(s,e);r.agentsSpawned=c.results.length,r.agentResults=c.results,r.totalTokens=c.totalTokens,r.totalCost=c.totalCost,r.success=c.success,r.parallelBuilderStats=c.parallelBuilderStats;}if(e.pmGovernance?.enabled&&a)try{let{aggregateFromDirectory:c}=await import('./dist-OG6MM4VY.js'),d=await c(this.rootDir),u=o(d),m=[],g=[];for(let l of r.agentResults)l.relay?.outputs?.artifacts&&m.push(...l.relay.outputs.artifacts.map(y=>y.path));for(let l of a.affectedSymbols)g.push(l.symbol);let h=H(m,g,this.rootDir,u);r.complianceReport={preflight:a,postflight:h},e.pmGovernance.blockOnViolations&&h.blocksCompletion&&(r.success=!1);}catch{r.complianceReport={preflight:a};}r.duration_ms=Date.now()-n;let i=this.auditLogger.startOrchestration(o$1,s,t);return i.completed=new Date().toISOString(),i.status=r.success?"success":"failed",i.totals={duration_ms:r.duration_ms,tokens:r.totalTokens.total,cost_usd:r.totalCost,agents_spawned:r.agentsSpawned,files_created:0,files_modified:0},this.auditLogger.saveOrchestration(i),r.log=i,r}catch(a){return r.error=a instanceof Error?a.message:String(a),r.duration_ms=Date.now()-n,r}}async compare(s,e={}){let t=await this.orchestrate(s,{...e,mode:"solo"}),n=await this.orchestrate(s,{...e,mode:"faceted"}),o=t.totalTokens.total-n.totalTokens.total,r=t.totalCost-n.totalCost,a=t.duration_ms-n.duration_ms,i="tie";return n.success&&!t.success?i="faceted":t.success&&!n.success?i="solo":n.totalCost<t.totalCost*.8?i="faceted":t.totalCost<n.totalCost*.8&&(i="solo"),{solo:t,faceted:n,comparison:{winner:i,tokensSaved:o,costDiff:r,timeDiff:a,soloSucceeded:t.success,facetedSucceeded:n.success}}}async runSoloMode(s,e$1){let n=e(this.rootDir)?.team.default_agent||"architect",o=e$1.orchestratorModel||"opus",r={model:o,workingDirectory:e$1.workingDirectory||this.rootDir,mcpServerPath:e$1.mcpServerPath,budget:e$1.budget,onMessage:e$1.onMessage?i=>e$1.onMessage("solo",i):void 0,onCheckpoint:e$1.onCheckpoint};e$1.onAgentStart&&e$1.onAgentStart("solo",s,o);let a=await this.spawner.spawn(n,s,r);return e$1.onAgentComplete&&e$1.onAgentComplete("solo",a,o),a}async runFacetedMode(s,e$1){let t=e(this.rootDir);if(!t)return {success:false,results:[],totalTokens:{input:0,output:0,total:0},totalCost:0};let n="";if(be(s)){let h=a$1(s);if(h.length>0){let l=[];l.push(`## Auto-Ripple Analysis
|
|
3
|
+
`),l.push("The following symbols are affected by this refactoring:"),l.push("");for(let y of h.slice(0,5))l.push(`- **${y}**: Check dependencies before renaming/moving`);l.push(""),l.push("**Recommendation:** Run `paradigm_ripple` for each symbol before making changes."),n=l.join(`
|
|
4
|
+
`);}}let o=this.planAgentSequence(s,t.agents),r=this.groupByStage(o),a=[],i={input:0,output:0,total:0},c=0,d=new Map,u=true,m,g=Array.from(r.keys()).sort((h,l)=>h-l);for(let h of g){let l=r.get(h)||[];if(l.length===0)continue;if(e$1.checkpoints?.beforeAgentSpawn&&e$1.onCheckpoint){let f=l.map(S=>S.agent).join(", ");if(!await e$1.onCheckpoint(`Stage ${h}: Spawn ${f}${l.length>1?" (parallel)":""}`)){u=false;break}}let y=l.map(async f=>{let b=e$1.agentBudgets?.[f.agent]?.maxTokens?"haiku":f.model||pe[f.agent]||"sonnet",S="";if(f.dependsOn.length>0){let R=f.dependsOn.map(I=>d.get(I)).filter(Boolean);R.length>0&&(S=R.join(`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`));}let x=S;f.agent==="architect"&&n&&(x=n+(S?`
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
`+S:""));let P=x?`${f.subtask}
|
|
13
|
+
|
|
14
|
+
## Context from previous agents:
|
|
15
|
+
${x}`:f.subtask,O={model:b,workingDirectory:e$1.workingDirectory||this.rootDir,mcpServerPath:e$1.mcpServerPath,budget:e$1.agentBudgets?.[f.agent]||e$1.budget,onMessage:e$1.onMessage?R=>e$1.onMessage(f.agent,R):void 0,onCheckpoint:e$1.onCheckpoint};e$1.onAgentStart&&e$1.onAgentStart(f.agent,f.subtask,b);let C=await this.spawner.spawn(f.agent,P,O);return e$1.onAgentComplete&&e$1.onAgentComplete(f.agent,C,b),{step:f,result:C,model:b}}),k=await Promise.all(y);for(let{step:f,result:b,model:S}of k){if(a.push(b),b.relay){i.input+=b.relay.metrics.tokens_used.input,i.output+=b.relay.metrics.tokens_used.output,i.total+=b.relay.metrics.tokens_used.total,c+=b$1(b.relay.metrics.tokens_used,S);let x=b.relay.handoff?.context||`${f.agent} completed: ${b.relay.outputs.decisions.join(", ")||"task done"}`;if(d.set(f.agent,x),f.agent==="architect"&&b.relay){let P=this.extractFilePlanFromRelay(b);if(P&&P.length>0){let O=this.planBuilderStages(P);if(O.hasFilePlan&&O.totalBuilders>1){let C=await this.runParallelBuilders(O,d.get("architect")||"",e$1);a.push(...C.results),i.input+=C.totalTokens.input,i.output+=C.totalTokens.output,i.total+=C.totalTokens.total,c+=C.totalCost,C.success||(u=false),m={usedFilePlan:true,totalSubPhases:O.stages.length,totalParallelBuilders:O.totalBuilders,filesCreated:O.totalFiles};for(let[R,I]of r){let X=I.filter(Q=>Q.agent!=="builder");r.set(R,X);}}}}}!b.success&&f.required&&(u=false);}if(!u||e$1.checkpoints?.afterAgentComplete&&e$1.onCheckpoint&&!await e$1.onCheckpoint(`Stage ${h} completed. Continue to next stage?`))break}return {success:u,results:a,totalTokens:i,totalCost:c,parallelBuilderStats:m}}extractFilePlanFromRelay(s){if(!s.relay)return;let e=s.relay.handoff?.context||"";if(e.includes("filePlan:"))return this.parseFilePlanFromText(e)}parseFilePlanFromText(s){let e=[],t=s.match(/filePlan:\s*\n([\s\S]*?)(?=\n[a-z_]+:|$)/);if(!t)return;let o=t[1].split(`
|
|
16
|
+
`),r=null,a=false,i={};for(let c of o){let d=c.trim();if(!(!d||d.startsWith("#"))){if(d.startsWith("- group:")){r&&(i.path&&(r.files.push({path:i.path,description:i.description||""}),i={}),e.push(r)),r={group:d.split(":")[1].trim(),subPhase:0,files:[]},a=false;continue}if(r){if(d.startsWith("subPhase:")){r.subPhase=parseInt(d.split(":")[1].trim(),10)||0;continue}if(d==="files:"){a=true;continue}if(a){if(d.startsWith("- path:")){i.path&&r.files.push({path:i.path,description:i.description||""}),i={path:d.split(":").slice(1).join(":").trim().replace(/^["']|["']$/g,"")};continue}if(d.startsWith("description:")){i.description=d.split(":").slice(1).join(":").trim().replace(/^["']|["']$/g,"");continue}}}}}return i.path&&r&&r.files.push({path:i.path,description:i.description||""}),r&&e.push(r),e.length>0?e:void 0}planAgentSequence(s,e){let t=a$1(s),n=s.toLowerCase(),o=K(s),r=[],a=me(s);if(o.type==="analysis")return e.architect&&r.push({agent:"architect",subtask:`Analyze and recommend: ${s}`,required:true,stage:0,dependsOn:[],model:"opus"}),r;if(o.type==="documentation")return e.architect&&r.push({agent:"architect",subtask:`Document: ${s}`,required:true,stage:0,dependsOn:[],model:"sonnet"}),r;let i=n.includes("design")||n.includes("architect")||n.includes("plan")||n.includes("spec"),c=a||n.includes("auth")||n.includes("security")||n.includes("gate")||t.some(l=>l.startsWith("^"));if(i&&e.architect&&r.push({agent:"architect",subtask:`Design and specify: ${s}`,required:true,stage:0,dependsOn:[],model:"opus"}),c&&e.security&&r.push({agent:"security",subtask:`Review security aspects of: ${s}`,required:a,stage:0,dependsOn:[],model:"opus"}),(n.includes("build")||n.includes("implement")||n.includes("create")||n.includes("add")||n.includes("fix"))&&e.builder){let l=i&&e.architect?["architect"]:[];r.push({agent:"builder",subtask:`Implement: ${s}`,required:true,stage:l.length>0?1:0,dependsOn:l,model:"haiku"});}let u=n.includes("review")||n.includes("check"),m=n.includes("test")||n.includes("verify")||n.includes("validate"),g=r.some(l=>l.agent==="builder"),h=g?2:i?1:0;if(u&&e.reviewer&&r.push({agent:"reviewer",subtask:`Review: ${s}`,required:false,stage:h,dependsOn:g?["builder"]:[],model:"sonnet"}),m&&e.tester&&r.push({agent:"tester",subtask:`Test and validate: ${s}`,required:false,stage:h,dependsOn:g?["builder"]:[],model:"haiku"}),r.length===0){let l=o.recommendedAgents;if(l.includes("architect")&&e.architect&&r.push({agent:"architect",subtask:`Design: ${s}`,required:true,stage:0,dependsOn:[],model:B("architect",o)}),(l.includes("security")||a)&&e.security&&r.push({agent:"security",subtask:`Security review: ${s}`,required:a,stage:0,dependsOn:[],model:"opus"}),l.includes("builder")&&e.builder){let y=r.length>0;r.push({agent:"builder",subtask:`Implement: ${s}`,required:true,stage:y?1:0,dependsOn:r.filter(k=>k.stage===0).map(k=>k.agent),model:B("builder",o)});}if(l.includes("tester")&&e.tester){let y=r.find(k=>k.agent==="builder")?.stage??0;r.push({agent:"tester",subtask:`Test: ${s}`,required:false,stage:y+1,dependsOn:e.builder?["builder"]:[],model:B("tester",o)});}}return r.sort((l,y)=>l.stage-y.stage)}groupByStage(s){let e=new Map;for(let t of s){let n=e.get(t.stage)||[];n.push({agent:t.agent,subtask:t.subtask,required:t.required,dependsOn:t.dependsOn}),e.set(t.stage,n);}return e}generateOrchestrationId(){let s=new Date().toISOString().slice(0,10),e=Math.random().toString(36).substring(2,8);return `orch-${s}-${e}`}planBuilderStages(s){if(!s||s.length===0)return {hasFilePlan:false,stages:[{subPhase:0,builders:[{agent:"builder",group:"all",files:[],availableFiles:[]}]}],totalFiles:0,totalBuilders:1};let e=new Map;for(let i of s){let c=e.get(i.subPhase)||[];c.push(i),e.set(i.subPhase,c);}let t=[],n=[...e.keys()].sort((i,c)=>i-c),o=[],r=0,a=0;for(let i of n){let c=e.get(i),d=[];for(let u=0;u<c.length;u++){let m=c[u];a+=m.files.length,r++,d.push({agent:`builder-${i}-${u}`,group:m.group,files:m.files,availableFiles:[...o]});}t.push({subPhase:i,builders:d});for(let u of c)for(let m of u.files)o.push(m.path);}return {hasFilePlan:true,stages:t,totalFiles:a,totalBuilders:r}}buildParallelBuilderPrompt(s,e,t,n){let o=[];o.push(`You are a BUILDER agent responsible for implementing the **${n}** group.`),o.push(""),o.push("## Your Assignment"),o.push(""),o.push("### Files to Create:");for(let r of s)o.push(`- \`${r.path}\`: ${r.description}`);if(o.push(""),e.length>0){o.push("### Available Files (already created):"),o.push("These files exist and you can import from them:");for(let r of e)o.push(`- \`${r}\``);o.push("");}return t&&(o.push("### Context from Architect:"),o.push(t),o.push("")),o.push("### Instructions:"),o.push("1. Create ONLY the files assigned to you"),o.push("2. You can import from available files (already created)"),o.push("3. Follow existing patterns in the codebase"),o.push("4. Use the Paradigm logger (not console.log)"),o.push("5. End with the standard Agent Relay block"),o.join(`
|
|
17
|
+
`)}async runParallelBuilders(s,e,t){let n=[],o={input:0,output:0,total:0},r=0,a=true;for(let i of s.stages){if(t.checkpoints?.beforeAgentSpawn&&t.onCheckpoint){let u=i.builders.map(g=>g.group).join(", ");if(!await t.onCheckpoint(`Builder Sub-phase ${i.subPhase}: ${u}${i.builders.length>1?" (parallel)":""}`)){a=false;break}}let c=i.builders.map(async u=>{let m=this.buildParallelBuilderPrompt(u.files,u.availableFiles,e,u.group),g={model:"haiku",workingDirectory:t.workingDirectory||this.rootDir,mcpServerPath:t.mcpServerPath,budget:t.budget,onMessage:t.onMessage?l=>t.onMessage(u.agent,l):void 0,onCheckpoint:t.onCheckpoint};t.onAgentStart&&t.onAgentStart(u.agent,`Implement ${u.group}`,"haiku");let h=await this.spawner.spawn("builder",m,g);return t.onAgentComplete&&t.onAgentComplete(u.agent,h,"haiku"),{builder:u,result:h}}),d=await Promise.all(c);for(let{result:u}of d)n.push(u),u.relay&&(o.input+=u.relay.metrics.tokens_used.input,o.output+=u.relay.metrics.tokens_used.output,o.total+=u.relay.metrics.tokens_used.total,r+=b$1(u.relay.metrics.tokens_used,"haiku")),u.success||(a=false);if(!a||t.checkpoints?.afterAgentComplete&&t.onCheckpoint&&!await t.onCheckpoint(`Sub-phase ${i.subPhase} complete. Continue to next sub-phase?`))break}return {success:a,results:n,totalTokens:o,totalCost:r}}};var J=class{rootDir;orchestrationsDir;constructor(s){this.rootDir=s,this.orchestrationsDir=A.join(s,".paradigm","orchestrations"),this.ensureOrchestrationDir();}async startBackground(s,e={}){let t=this.generateId(),n=A.join(this.orchestrationsDir,`${t}.output`),o=A.join(this.orchestrationsDir,`${t}.log`),r={id:t,task:s,status:"pending",mode:e.mode||"faceted",created:new Date().toISOString(),outputFile:n,logFile:o,artifacts:[]};return this.saveOrchestration(r),this.spawnOrchestration(t,s,e),r}getOrchestration(s){let e=A.join(this.orchestrationsDir,`${s}.yaml`);if(!w.existsSync(e))return null;try{let t=w.readFileSync(e,"utf-8");return F.load(t)}catch{return null}}listOrchestrations(s={}){let e=w.readdirSync(this.orchestrationsDir).filter(n=>n.endsWith(".yaml")&&!n.includes("output")&&!n.includes("log")).sort().reverse(),t=[];for(let n of e){if(s.limit&&t.length>=s.limit)break;let o=A.join(this.orchestrationsDir,n);try{let r=w.readFileSync(o,"utf-8"),a=F.load(r);if(s.status&&!(Array.isArray(s.status)?s.status:[s.status]).includes(a.status))continue;t.push(a);}catch{}}return t}getRunning(){return this.listOrchestrations({status:"running"})}getOutput(s,e={}){let t=this.getOrchestration(s);if(!t||!w.existsSync(t.outputFile))return "";let n=w.readFileSync(t.outputFile,"utf-8");return e.lines?n.split(`
|
|
18
|
+
`).slice(-e.lines).join(`
|
|
19
|
+
`):n}async accept(s,e={}){let t=this.getOrchestration(s);if(!t)return false;if(t.status!=="completed")throw new Error(`Cannot accept orchestration in '${t.status}' status`);return t.status="accepted",this.saveOrchestration(t),true}async reject(s,e={}){let t=this.getOrchestration(s);if(!t)return false;if(t.status!=="completed")throw new Error(`Cannot reject orchestration in '${t.status}' status`);if(t.status="rejected",t.error=e.reason,this.saveOrchestration(t),e.cleanup&&t.artifacts.length>0){for(let n of t.artifacts)if(n.action==="created"){let o=A.join(this.rootDir,n.path);w.existsSync(o)&&w.unlinkSync(o);}}return true}async getDiff(s){let e=this.getOrchestration(s);if(!e)return "";if(e.artifacts.length===0)return "No file changes in this orchestration.";let t=[];t.push(`Orchestration: ${s}`),t.push(`Task: ${e.task}`),t.push(`Status: ${e.status}`),t.push(""),t.push("Files:");for(let n of e.artifacts){let o=n.action==="created"?"+":n.action==="modified"?"~":"-";t.push(` ${o} ${n.path}`);}return t.join(`
|
|
20
|
+
`)}markComplete(s,e){let t=this.getOrchestration(s);if(t){t.status=e.success?"completed":"failed",t.completed=new Date().toISOString(),t.result=e,t.parallelBuilderStats=e.parallelBuilderStats;for(let n of e.agentResults)if(n.relay?.outputs.artifacts)for(let o of n.relay.outputs.artifacts)t.artifacts.push(o);this.saveOrchestration(t);}}async notify(s,e=["bell"]){let t=this.getOrchestration(s);if(t)for(let n of e)switch(n){case "bell":process.stdout.write("\x07");break;case "desktop":try{process.platform==="darwin"?spawn("osascript",["-e",`display notification "Orchestration ${t.status}: ${t.task.slice(0,50)}" with title "Paradigm"`]):spawn("notify-send",["Paradigm",`Orchestration ${t.status}: ${t.task.slice(0,50)}`]);}catch{}break;case "file":let o=A.join(this.orchestrationsDir,`${s}.status`);w.writeFileSync(o,JSON.stringify({id:s,status:t.status,completed:t.completed,task:t.task}));break;}}ensureOrchestrationDir(){w.existsSync(this.orchestrationsDir)||w.mkdirSync(this.orchestrationsDir,{recursive:true});}generateId(){let s=new Date().toISOString().slice(0,10),e=Date.now().toString(36),t=Math.random().toString(36).substring(2,6);return `orch-${s}-${e}-${t}`}saveOrchestration(s){let e=A.join(this.orchestrationsDir,`${s.id}.yaml`);w.writeFileSync(e,F.dump(s));}spawnOrchestration(s,e,t){let n=this.getOrchestration(s);n&&(n.status="running",n.started=new Date().toISOString(),this.saveOrchestration(n)),(async()=>{try{let o=new E(this.rootDir);await o.initialize();let r=w.createWriteStream(n.outputFile,{flags:"a"}),a=await o.orchestrate(e,{...t,onMessage:(i,c)=>{c.type==="text"&&r.write(`[${i}] ${c.content}
|
|
21
|
+
`),t.onMessage?.(i,c);},onAgentStart:(i,c,d)=>{r.write(`
|
|
22
|
+
\u25B6 ${i}: ${c}
|
|
23
|
+
`),t.onAgentStart?.(i,c,d);},onAgentComplete:(i,c,d)=>{let u=c.success?"\u2713":"\u2717";r.write(`${u} ${i} completed
|
|
24
|
+
`),t.onAgentComplete?.(i,c,d);}});r.end(),this.markComplete(s,a),t.notify&&await this.notify(s,t.notifyMethods||["bell"]);}catch(o){let r=this.getOrchestration(s);r&&(r.status="failed",r.error=o instanceof Error?o.message:String(o),r.completed=new Date().toISOString(),this.saveOrchestration(r));}})();}};export{E as a,J as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-QT2LKB3P.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 k$1=j(p);for(let[r,{item:a,filePath:d}]of k$1)t.push(y({id:`purpose-state-${r}`,symbol:`#${r}`,type:"component",source:"purpose",filePath:d,data:a,description:a.description,tags:["state"]}));let W=k(p);for(let[r,{item:a,filePath:d}]of W)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){return y({id:`gate-${e.id}`,symbol:`^${e.id}`,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 Y(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 Y(e)!==null}function Ge(e,o,t=10){let n=o.toLowerCase(),i=Y(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,Y 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};
|
|
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};
|