@smartkomm/plexus-cli 0.1.150 → 0.1.152

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/cli.mjs CHANGED
@@ -11031,11 +11031,11 @@ You can check the current status at any time here:
11031
11031
 
11032
11032
  {{taskLink}}`,en:`Go straight to the task:
11033
11033
 
11034
- {{taskLink}}`}}]},s1=m.object({tenantSlug:m.string(),recipientUserId:m.id("users"),workItemId:m.id("work_items"),teamId:m.id("permission_groups"),taskTitle:m.string(),teamLabel:m.string()}),a1={key:"teamLabel",label:"Team",subjectSafe:!0},l1={id:"staff.teamTaskQueued",category:"staffTasks",label:"Aufgabe f\xFCr ein Team",occasion:{de:"Sobald eine Aufgabe ohne Bearbeiter in der Queue eines Teams landet \u2014 an jedes Mitglied",en:"When a task lands in a team's queue with nobody holding it \u2014 to every member"},audience:"internal",frame:"notice",timeline:"hidden",paramsValidator:s1,channels:["email"],portalVisible:!1,placeholders:[Xy,a1,y_],slots:[_e({de:"Neue Aufgabe f\xFCr {{teamLabel}}: {{taskTitle}}",en:"New task for {{teamLabel}}: {{taskTitle}}"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"Diese Aufgabe liegt jetzt in der Queue Ihres Teams {{teamLabel}}:",en:"This task is now in the queue of your team {{teamLabel}}:"}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`Direkt zur Aufgabe:
11034
+ {{taskLink}}`}}]},s1=m.object({tenantSlug:m.string(),recipientUserId:m.id("users"),workItemId:m.id("work_items"),teamId:m.id("permission_groups"),taskTitle:m.string(),teamLabel:m.string()}),a1={key:"teamLabel",label:"Team",subjectSafe:!0},l1={id:"staff.teamTaskQueued",category:"staffTasks",label:"Aufgabe f\xFCr ein Team",occasion:{de:"Sobald eine Aufgabe ohne Bearbeiter in der Queue eines Teams landet \u2014 an jedes Mitglied",en:"When a task lands in a team's queue with nobody holding it \u2014 to every member"},audience:"internal",deputyCopy:!1,frame:"notice",timeline:"hidden",paramsValidator:s1,channels:["email"],portalVisible:!1,placeholders:[Xy,a1,y_],slots:[_e({de:"Neue Aufgabe f\xFCr {{teamLabel}}: {{taskTitle}}",en:"New task for {{teamLabel}}: {{taskTitle}}"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"Diese Aufgabe liegt jetzt in der Queue Ihres Teams {{teamLabel}}:",en:"This task is now in the queue of your team {{teamLabel}}:"}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`Direkt zur Aufgabe:
11035
11035
 
11036
11036
  {{taskLink}}`,en:`Go straight to the task:
11037
11037
 
11038
- {{taskLink}}`}}]},d1={...Xy,previewValue:{de:"Feedback der Lehrkraft",en:"Teacher feedback"}},c1={key:"feedbackLink",label:"Link zum Feedback",required:!0,link:!0,actionLabel:{de:"Feedback abgeben",en:"Give feedback"},previewValue:{de:"https://beispiel.plexus.schule/schule/respond?token=BEISPIEL",en:"https://beispiel.plexus.schule/schule/respond?token=BEISPIEL"}},u1={id:"staff.feedbackRequested",category:"staffFeedback",label:"Bitte um Feedback",occasion:{de:"Sobald eine Feedback-Aufgabe beantwortet werden kann \u2014 an die Person, die sie hat, oder an jedes Mitglied ihres Teams",en:"When a feedback task can be answered \u2014 to the person who has it, or to every member of its team"},audience:"internal",frame:"notice",timeline:"hidden",paramsValidator:g_,channels:["email"],portalVisible:!1,placeholders:[d1,c1],slots:[_e({de:"Bitte um Feedback: {{taskTitle}}",en:"Feedback requested: {{taskTitle}}"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"Ihre Schule hat eine Aufgabe f\xFCr Sie: {{taskTitle}}.",en:"Your school has a task for you: {{taskTitle}}."}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`{{feedbackLink}}
11038
+ {{taskLink}}`}}]},d1={...Xy,previewValue:{de:"Feedback der Lehrkraft",en:"Teacher feedback"}},c1={key:"feedbackLink",label:"Link zum Feedback",required:!0,link:!0,actionLabel:{de:"Feedback abgeben",en:"Give feedback"},previewValue:{de:"https://beispiel.plexus.schule/schule/respond?token=BEISPIEL",en:"https://beispiel.plexus.schule/schule/respond?token=BEISPIEL"}},u1={id:"staff.feedbackRequested",category:"staffFeedback",label:"Bitte um Feedback",occasion:{de:"Sobald eine Feedback-Aufgabe beantwortet werden kann \u2014 an die Person, die sie hat, oder an jedes Mitglied ihres Teams",en:"When a feedback task can be answered \u2014 to the person who has it, or to every member of its team"},audience:"internal",deputyCopy:!1,frame:"notice",timeline:"hidden",paramsValidator:g_,channels:["email"],portalVisible:!1,placeholders:[d1,c1],slots:[_e({de:"Bitte um Feedback: {{taskTitle}}",en:"Feedback requested: {{taskTitle}}"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"Ihre Schule hat eine Aufgabe f\xFCr Sie: {{taskTitle}}.",en:"Your school has a task for you: {{taskTitle}}."}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`{{feedbackLink}}
11039
11039
 
11040
11040
  Der Link gilt 30 Tage und antwortet in Ihrem Namen. Bitte leiten Sie diese E-Mail nicht weiter.`,en:`{{feedbackLink}}
11041
11041
 
@@ -11465,6 +11465,6 @@ ${n.length} unusable ${o}:
11465
11465
  `),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
11466
11466
  `),i.length>0&&this.context.stdout.write(` ${i.length} without any login account \u2014 plexus-cli platform users provision --tenant <slug> --email <email> --name <name>
11467
11467
  `)}else this.context.stdout.write(`No unusable identities.
11468
- `);return n.length>0?1:0}},GE=class extends cr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=T.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let n=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function bV(e,t){if(e===t)throw new Error("Pass exactly one of --on or --off.");return e}s(bV,"requireOnOff");var vV=[RE,IE,OE,_E,NE,CE,PE,DE,FE,LE,ru,ME,qE,KE,jE,VE,BE,UE,GE];function xV(e){return e.de??e.en??Object.values(e)[0]??""}s(xV,"titleDe");function JZ(e){return{id:e._id,kind:e.kind,status:e.status,title:xV(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(JZ,"row");var QZ=["id","kind","status","title","assignee","group","outcome"],YE=class extends D{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=T.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(x.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(JZ),QZ),0}},HE=class extends D{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=T.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(x.workItems.get,{client:n,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:xV(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},JE=class extends D{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=T.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(x.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},QE=class extends D{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=T.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(x.workItems.complete,{client:n,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},ZE=class extends D{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=T.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(x.workItems.assign,{client:n,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},SV=[YE,HE,JE,QE,ZE];var iu=[...NR,...OP,...jP,...BD,...VD,...hF,...xF,...vF,...wV,...vV,...yV,...rj,...dj,...mP,...uF,...sV,...OR,...iI,...XC,...EF,...AF,...RF,...IF,...dF,...HD,...SV,...ZM,...jq,...tj,...Vq,...Bj,...Qj,...cj,...kj,...xj,...Tj,...Rj,...eV,...cV,...YR];for(let e of iu){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:XT(e.usage.category,t.join(" "))})}var AV="0.1.150";function EV(){return iu.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=HT[so(n)];return{path:n,effect:ao(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(EV,"plexusCommandCatalog");import rs from"node:path";function ZZ(e){let t=at()?.workspaceRoot??process.cwd(),n=rs.resolve(t,e),r=rs.relative(t,n);if(rs.isAbsolute(e)||r===".."||r.startsWith(`..${rs.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(ZZ,"workspacePath");function XZ(e){let{absolute:t,relative:n}=ZZ(e.path??".");if(e.operation==="list"){if(!Ae(t))return{files:[]};let r=[],i=s(o=>{for(let a of Rr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=rs.join(o,a.name);if(a.isDirectory()?i(l):r.push(rs.relative(t,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(t);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return Ge(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Dt(rs.dirname(t),{recursive:!0}),Ge(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return as(t),{path:n,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(XZ,"plexusWorkspace");function TV(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=pl[n];if(!o||!Object.hasOwn(pl,n))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Gg,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Gg[i.path],skillHash:Zu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return XZ(i)},"executePlexusAgentTool")}s(TV,"createPlexusAgentToolExecutor");var Oh=TV({inspectCommand:RV,executeCommand:IV});function _h(){let e=new us({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:AV});e.register(Ja.HelpCommand),e.register(Ja.VersionCommand);for(let n of iu)e.register(n);async function t(n,r){let i;try{i=e.process(n,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return n9(i,r.stderr??process.stderr),e.run(i,r)}return s(t,"run"),{process(n,r){return e.process(n,r)},run:t,async runExit(n,r){process.exitCode=await t(n,r)}}}s(_h,"createPlexusCli");function n9(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&tl[n]===r&&ot(t,n,r),n in tl&&ao(n)==="confirm"&&!nl(e)&&t.write(`plexus-cli: \`${tl[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
11468
+ `);return n.length>0?1:0}},GE=class extends cr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=T.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let n=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function bV(e,t){if(e===t)throw new Error("Pass exactly one of --on or --off.");return e}s(bV,"requireOnOff");var vV=[RE,IE,OE,_E,NE,CE,PE,DE,FE,LE,ru,ME,qE,KE,jE,VE,BE,UE,GE];function xV(e){return e.de??e.en??Object.values(e)[0]??""}s(xV,"titleDe");function JZ(e){return{id:e._id,kind:e.kind,status:e.status,title:xV(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(JZ,"row");var QZ=["id","kind","status","title","assignee","group","outcome"],YE=class extends D{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=T.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(x.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(JZ),QZ),0}},HE=class extends D{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=T.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(x.workItems.get,{client:n,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:xV(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},JE=class extends D{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=T.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(x.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},QE=class extends D{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=T.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(x.workItems.complete,{client:n,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},ZE=class extends D{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=T.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(x.workItems.assign,{client:n,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},SV=[YE,HE,JE,QE,ZE];var iu=[...NR,...OP,...jP,...BD,...VD,...hF,...xF,...vF,...wV,...vV,...yV,...rj,...dj,...mP,...uF,...sV,...OR,...iI,...XC,...EF,...AF,...RF,...IF,...dF,...HD,...SV,...ZM,...jq,...tj,...Vq,...Bj,...Qj,...cj,...kj,...xj,...Tj,...Rj,...eV,...cV,...YR];for(let e of iu){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:XT(e.usage.category,t.join(" "))})}var AV="0.1.152";function EV(){return iu.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=HT[so(n)];return{path:n,effect:ao(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(EV,"plexusCommandCatalog");import rs from"node:path";function ZZ(e){let t=at()?.workspaceRoot??process.cwd(),n=rs.resolve(t,e),r=rs.relative(t,n);if(rs.isAbsolute(e)||r===".."||r.startsWith(`..${rs.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(ZZ,"workspacePath");function XZ(e){let{absolute:t,relative:n}=ZZ(e.path??".");if(e.operation==="list"){if(!Ae(t))return{files:[]};let r=[],i=s(o=>{for(let a of Rr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=rs.join(o,a.name);if(a.isDirectory()?i(l):r.push(rs.relative(t,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(t);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return Ge(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Dt(rs.dirname(t),{recursive:!0}),Ge(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return as(t),{path:n,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(XZ,"plexusWorkspace");function TV(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=pl[n];if(!o||!Object.hasOwn(pl,n))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Gg,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Gg[i.path],skillHash:Zu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return XZ(i)},"executePlexusAgentTool")}s(TV,"createPlexusAgentToolExecutor");var Oh=TV({inspectCommand:RV,executeCommand:IV});function _h(){let e=new us({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:AV});e.register(Ja.HelpCommand),e.register(Ja.VersionCommand);for(let n of iu)e.register(n);async function t(n,r){let i;try{i=e.process(n,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return n9(i,r.stderr??process.stderr),e.run(i,r)}return s(t,"run"),{process(n,r){return e.process(n,r)},run:t,async runExit(n,r){process.exitCode=await t(n,r)}}}s(_h,"createPlexusCli");function n9(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&tl[n]===r&&ot(t,n,r),n in tl&&ao(n)==="confirm"&&!nl(e)&&t.write(`plexus-cli: \`${tl[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
11469
11469
  `)}s(n9,"noteRetiredPath");function RV(e){let t=_h().process(ja(e),{executePlexusAgentTool:Oh}),n=t.path.join(" ");if(n.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=EV().find(l=>l.path===n);if(!r){if(n===""||n==="--help"||n==="--version")return{path:n,writes:!1,host:"shared"};throw new Error(`plexus: command ${n} has no host classification.`)}let i=t,o=r.effect==="callKind"?tm(ba(va),i.fn??"",i.kind):void 0,a=qu(n,{confirm:nl(t),callKind:o});return{...r,writes:a}}s(RV,"inspectPlexusCommand");async function IV(e,t){if(t)return tT(t,()=>IV(e));if(!Array.isArray(e.argv)||e.argv.length===0||e.argv.length>128||e.argv.some(l=>typeof l!="string"||l.length>128e3)||(e.stdin?.length??0)>1e6)throw new Error("plexus: invalid command invocation.");let n="",r="",i=_h();if(at()){let l=RV(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(ja(e.argv),{executePlexusAgentTool:Oh,stdin:t9.from(e.stdin===void 0?[]:[e.stdin]),stdout:new $V({write(l,d,c){n+=String(l),c()}}),stderr:new $V({write(l,d,c){r+=String(l),c()}})}),stdout:n,stderr:r}}s(IV,"executePlexusCommand");sT({source:r9.join(import.meta.dirname,"skill")});_h().runExit(ja(process.argv.slice(2)),{executePlexusAgentTool:Oh});
11470
11470
  //# sourceMappingURL=cli.mjs.map