agentix-cli 0.16.0 → 0.18.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/agent-RDVGL2TW.js +2 -0
- package/dist/audit-Z47AQFFD.js +3 -0
- package/dist/audit-Z47AQFFD.js.map +1 -0
- package/dist/board-dashboard-KX2CNOSY.js +7282 -0
- package/dist/board-dashboard-KX2CNOSY.js.map +1 -0
- package/dist/chunk-34NG7UDX.js +11 -0
- package/dist/chunk-34NG7UDX.js.map +1 -0
- package/dist/{chunk-6MKAXEE5.js → chunk-4ITQP3XL.js} +2 -2
- package/dist/{chunk-6MKAXEE5.js.map → chunk-4ITQP3XL.js.map} +1 -1
- package/dist/chunk-53NRX2NA.js +2 -0
- package/dist/chunk-53NRX2NA.js.map +1 -0
- package/dist/chunk-6PPIFDOQ.js +1742 -0
- package/dist/chunk-6PPIFDOQ.js.map +1 -0
- package/dist/chunk-AFRHKA7B.js +2 -0
- package/dist/chunk-AFRHKA7B.js.map +1 -0
- package/dist/chunk-ASSJ4Z6Z.js +164 -0
- package/dist/chunk-ASSJ4Z6Z.js.map +1 -0
- package/dist/chunk-BLUXL6HR.js +854 -0
- package/dist/chunk-BLUXL6HR.js.map +1 -0
- package/dist/chunk-BTAEYL3P.js +72 -0
- package/dist/chunk-BTAEYL3P.js.map +1 -0
- package/dist/chunk-CDNWCYF7.js +2 -0
- package/dist/chunk-CDNWCYF7.js.map +1 -0
- package/dist/chunk-DJEZ2HVU.js +5 -0
- package/dist/chunk-DJEZ2HVU.js.map +1 -0
- package/dist/{chunk-FLOGK2U7.js → chunk-DSCMCVTV.js} +3 -3
- package/dist/chunk-DSCMCVTV.js.map +1 -0
- package/dist/chunk-EW27SCCC.js +2 -0
- package/dist/chunk-EW27SCCC.js.map +1 -0
- package/dist/chunk-HPDHNIA3.js +2 -0
- package/dist/chunk-IM376SD6.js +13 -0
- package/dist/chunk-IM376SD6.js.map +1 -0
- package/dist/chunk-J4WKMKTP.js +5 -0
- package/dist/{chunk-YI2T5QYB.js.map → chunk-J4WKMKTP.js.map} +1 -1
- package/dist/chunk-JGXE2YNV.js +46 -0
- package/dist/chunk-JGXE2YNV.js.map +1 -0
- package/dist/chunk-JXEPJ3YD.js +118 -0
- package/dist/chunk-JXEPJ3YD.js.map +1 -0
- package/dist/chunk-LY7JGDV7.js +6 -0
- package/dist/chunk-LY7JGDV7.js.map +1 -0
- package/dist/chunk-N67JZAXU.js +2 -0
- package/dist/chunk-N67JZAXU.js.map +1 -0
- package/dist/chunk-SR3X25TN.js +3 -0
- package/dist/chunk-SR3X25TN.js.map +1 -0
- package/dist/{chunk-7MBTMCKY.js → chunk-TRQSP67X.js} +2 -2
- package/dist/chunk-U364GNQX.js +719 -0
- package/dist/chunk-U364GNQX.js.map +1 -0
- package/dist/chunk-VJUTQAPJ.js +2 -0
- package/dist/chunk-VJUTQAPJ.js.map +1 -0
- package/dist/{chunk-HI24KAEY.js → chunk-WJXU5F4Z.js} +3 -4
- package/dist/{chunk-HI24KAEY.js.map → chunk-WJXU5F4Z.js.map} +1 -1
- package/dist/{chunk-QZP65I2H.js → chunk-ZE2YFX4K.js} +2 -2
- package/dist/cli.js +1 -320
- package/dist/cli.js.map +1 -1
- package/dist/{compaction-JBZZ7I7Y.js → compaction-S5H6DTOR.js} +6 -6
- package/dist/compaction-S5H6DTOR.js.map +1 -0
- package/dist/config-UOHEG4BW.js +2 -0
- package/dist/config-mutator-KSEBWKJH.js +2 -0
- package/dist/context-planner-2RGHJHSO.js +17 -0
- package/dist/context-planner-2RGHJHSO.js.map +1 -0
- package/dist/debug-TGAP7E7W.js +2 -0
- package/dist/discover-OATU7SHI.js +4 -0
- package/dist/discover-OATU7SHI.js.map +1 -0
- package/dist/editor-chat-FUBQLMAQ.js +137 -0
- package/dist/editor-chat-FUBQLMAQ.js.map +1 -0
- package/dist/heal-YP7QI7D3.js +2 -0
- package/dist/inbox-O5UB3YQN.js +315 -0
- package/dist/inbox-O5UB3YQN.js.map +1 -0
- package/dist/index.d.ts +3390 -1814
- package/dist/index.js +23 -53
- package/dist/index.js.map +1 -1
- package/dist/ingest-whatsapp-C3O5UPBX.js +6 -0
- package/dist/ingest-whatsapp-C3O5UPBX.js.map +1 -0
- package/dist/loader-BGWA7IRY.js +2 -0
- package/dist/loader-LBHKSXBK.js +2 -0
- package/dist/memory-extract-KKPKAOPH.js +2 -0
- package/dist/processes-7W27G3J3.js +256 -0
- package/dist/processes-7W27G3J3.js.map +1 -0
- package/dist/program-2MDELQLX.js +2 -0
- package/dist/providers-WCQSKTNP.js +2 -0
- package/dist/query-FZAL7AQD.js +2 -0
- package/dist/recipes-LZ56TA3X.js +2 -0
- package/dist/registry-ONJSILH4.js +2 -0
- package/dist/scheduler-XRM2RJIV.js +2 -0
- package/dist/slack-D27BE37Q.js +3 -0
- package/dist/slack-D27BE37Q.js.map +1 -0
- package/dist/store-4UCO56K2.js +2 -0
- package/dist/store-4UCO56K2.js.map +1 -0
- package/dist/{subagent-2SJHSSJS.js → subagent-EPOT3QDM.js} +2 -2
- package/dist/task-store-3NUWLYRY.js +2 -0
- package/dist/task-store-3NUWLYRY.js.map +1 -0
- package/dist/telegram-UWV67KWG.js +3 -0
- package/dist/telegram-UWV67KWG.js.map +1 -0
- package/dist/timers-QB4KYNAE.js +2 -0
- package/dist/timers-QB4KYNAE.js.map +1 -0
- package/dist/types-ECMEC5BZ.js +2 -0
- package/dist/types-ECMEC5BZ.js.map +1 -0
- package/dist/types-TTB6DJUE.js +2 -0
- package/dist/types-TTB6DJUE.js.map +1 -0
- package/dist/usage-dashboard-FQGPPABD.js +803 -0
- package/dist/usage-dashboard-FQGPPABD.js.map +1 -0
- package/dist/web/workflow-editor.global.js +1450 -0
- package/dist/web/workflow-editor.global.js.map +1 -0
- package/dist/whatsapp-KJ2NRKKQ.js +3 -0
- package/dist/whatsapp-KJ2NRKKQ.js.map +1 -0
- package/dist/{whatsapp-state-6D6FHHD2.js → whatsapp-state-3ZVQ6MQD.js} +2 -2
- package/dist/{wiki-UDPYFJBL.js → wiki-OUYKM7MB.js} +2 -2
- package/dist/wiki-OUYKM7MB.js.map +1 -0
- package/dist/workspace-setup-6GDBEORT.js +2 -0
- package/dist/workspace-setup-6GDBEORT.js.map +1 -0
- package/package.json +19 -2
- package/dist/agent-BCDPSPKU.js +0 -2
- package/dist/board-dashboard-LA7WW56M.js +0 -5668
- package/dist/board-dashboard-LA7WW56M.js.map +0 -1
- package/dist/chunk-6U2XOQHU.js +0 -7
- package/dist/chunk-6U2XOQHU.js.map +0 -1
- package/dist/chunk-7FJQGD6U.js +0 -6
- package/dist/chunk-7FJQGD6U.js.map +0 -1
- package/dist/chunk-ABDP7TDL.js +0 -71
- package/dist/chunk-ABDP7TDL.js.map +0 -1
- package/dist/chunk-CXY2RYNI.js +0 -11
- package/dist/chunk-CXY2RYNI.js.map +0 -1
- package/dist/chunk-FIOB3MEX.js +0 -2
- package/dist/chunk-FLOGK2U7.js.map +0 -1
- package/dist/chunk-HVC6FJNP.js +0 -108
- package/dist/chunk-HVC6FJNP.js.map +0 -1
- package/dist/chunk-K7BE4E35.js +0 -138
- package/dist/chunk-K7BE4E35.js.map +0 -1
- package/dist/chunk-KXJSLLSQ.js +0 -199
- package/dist/chunk-KXJSLLSQ.js.map +0 -1
- package/dist/chunk-KXZMYLHQ.js +0 -46
- package/dist/chunk-KXZMYLHQ.js.map +0 -1
- package/dist/chunk-M7HKBG3V.js +0 -2
- package/dist/chunk-M7HKBG3V.js.map +0 -1
- package/dist/chunk-MCJUAE6V.js +0 -6
- package/dist/chunk-MCJUAE6V.js.map +0 -1
- package/dist/chunk-RB7265LO.js +0 -12
- package/dist/chunk-RB7265LO.js.map +0 -1
- package/dist/chunk-YI2T5QYB.js +0 -5
- package/dist/compaction-JBZZ7I7Y.js.map +0 -1
- package/dist/config-LN6JEHMF.js +0 -2
- package/dist/config-mutator-24TH7PHM.js +0 -2
- package/dist/debug-3MEUO2P2.js +0 -2
- package/dist/heal-WKY5I4KB.js +0 -2
- package/dist/loader-PTCXLJEX.js +0 -2
- package/dist/memory-extract-AD7KMRPC.js +0 -2
- package/dist/providers-VUIWO3ZK.js +0 -2
- package/dist/query-PKGYE5HR.js +0 -2
- package/dist/registry-ASC2QS5K.js +0 -2
- package/dist/scheduler-A3TQOCKT.js +0 -2
- package/dist/types-OIFU3KSQ.js +0 -2
- package/dist/usage-dashboard-QX3CF6KK.js +0 -404
- package/dist/usage-dashboard-QX3CF6KK.js.map +0 -1
- package/dist/workspace-setup-ZWTT42XT.js +0 -2
- /package/dist/{agent-BCDPSPKU.js.map → agent-RDVGL2TW.js.map} +0 -0
- /package/dist/{chunk-FIOB3MEX.js.map → chunk-HPDHNIA3.js.map} +0 -0
- /package/dist/{chunk-7MBTMCKY.js.map → chunk-TRQSP67X.js.map} +0 -0
- /package/dist/{chunk-QZP65I2H.js.map → chunk-ZE2YFX4K.js.map} +0 -0
- /package/dist/{config-LN6JEHMF.js.map → config-UOHEG4BW.js.map} +0 -0
- /package/dist/{config-mutator-24TH7PHM.js.map → config-mutator-KSEBWKJH.js.map} +0 -0
- /package/dist/{debug-3MEUO2P2.js.map → debug-TGAP7E7W.js.map} +0 -0
- /package/dist/{heal-WKY5I4KB.js.map → heal-YP7QI7D3.js.map} +0 -0
- /package/dist/{loader-PTCXLJEX.js.map → loader-BGWA7IRY.js.map} +0 -0
- /package/dist/{memory-extract-AD7KMRPC.js.map → loader-LBHKSXBK.js.map} +0 -0
- /package/dist/{providers-VUIWO3ZK.js.map → memory-extract-KKPKAOPH.js.map} +0 -0
- /package/dist/{query-PKGYE5HR.js.map → program-2MDELQLX.js.map} +0 -0
- /package/dist/{registry-ASC2QS5K.js.map → providers-WCQSKTNP.js.map} +0 -0
- /package/dist/{scheduler-A3TQOCKT.js.map → query-FZAL7AQD.js.map} +0 -0
- /package/dist/{types-OIFU3KSQ.js.map → recipes-LZ56TA3X.js.map} +0 -0
- /package/dist/{wiki-UDPYFJBL.js.map → registry-ONJSILH4.js.map} +0 -0
- /package/dist/{workspace-setup-ZWTT42XT.js.map → scheduler-XRM2RJIV.js.map} +0 -0
- /package/dist/{subagent-2SJHSSJS.js.map → subagent-EPOT3QDM.js.map} +0 -0
- /package/dist/{whatsapp-state-6D6FHHD2.js.map → whatsapp-state-3ZVQ6MQD.js.map} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import{a as Oe,b as Ee,c as be}from"./chunk-SFQUP3BP.js";import{a as Y,c as Ae,e as ge,f as he,h as ye,l as ke}from"./chunk-JGXE2YNV.js";import{a as P}from"./chunk-VJUTQAPJ.js";import{a as He,d as we}from"./chunk-DJEZ2HVU.js";import{e as x}from"./chunk-DSYKYZMT.js";import{b as xe,c as ve}from"./chunk-QOYAX2FT.js";import{z as $}from"zod";var je=$.object({provider:$.enum(["claude-code","claude","openai","ollama","custom"]).default("claude-code"),model:$.string().optional(),apiKey:$.string().optional(),skills:$.array($.string()).default([]),output:$.object({dir:$.string().default("./generated")}).default({}),context7:$.object({enabled:$.boolean().default(!0),apiKey:$.string().optional()}).default({}),agentic:$.object({maxIterations:$.number().default(20),enabledTools:$.array($.string()).default(["create_files","ask_user","read_file","search_files","list_directory","run_command","edit_file"]),disabledTools:$.array($.string()).default([])}).default({})}),$t=["component","page","api","website","document","script","config","skill","media","report","test","workflow","schema","email","diagram","auto"],Mt={component:"UI component (any framework)",page:"Full page or screen",api:"API endpoint, route handler, or service",website:"Multi-page website or app",document:"Markdown, documentation, or specification",script:"Standalone script or utility",config:"Configuration file or setup",skill:"Agent skill (SKILL.md format for skills.sh)",media:"Media generation prompt (image/audio/video description)",report:"Analysis report or audit",test:"Test suite, test fixtures, or test data",workflow:"CI/CD pipeline, GitHub Actions, or automation",schema:"Database schema, Zod validators, or GraphQL types",email:"Email template (React Email, MJML, HTML)",diagram:"Mermaid, D2, or PlantUML diagram",auto:"Auto-detect the best output type"};import{existsSync as rt,promises as st}from"fs";import W from"path";import it from"fast-glob";var Ie={"prisma/schema.prisma":{type:"prisma",category:"database"},"drizzle/schema.ts":{type:"drizzle",category:"database"},"schema.graphql":{type:"graphql",category:"api"},"schema.gql":{type:"graphql",category:"api"},"openapi.yaml":{type:"openapi",category:"api"},"openapi.json":{type:"openapi",category:"api"},"swagger.yaml":{type:"openapi",category:"api"},"swagger.json":{type:"openapi",category:"api"}};async function Ue(r){let e={},t=await it.glob("**/*",{cwd:r,deep:4,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**","**/target/**","**/__pycache__/**","**/vendor/**","**/.git/**"],onlyFiles:!0});for(let[s,i]of Object.entries(Ie)){let l=t.find(a=>a.endsWith(s)||a===s);if(l&&i.category==="database"){let a=await J(W.resolve(r,l));if(a){e.database={type:i.type,content:ne(a,3e3),tables:at(a,i.type)};break}}}for(let[s,i]of Object.entries(Ie)){let l=t.find(a=>a.endsWith(s)||a===s);if(l&&i.category==="api"){let a=await J(W.resolve(r,l));if(a){e.api={type:i.type,content:ne(a,3e3)};break}}}if(!e.api){let s=t.find(i=>i.includes("trpc")&&(i.endsWith("router.ts")||i.endsWith("router.js")));if(s){let i=await J(W.resolve(r,s));i&&(e.api={type:"trpc",content:ne(i,3e3)})}}let o=t.find(s=>s===".env.example"||s===".env.local.example"||s===".env.template");if(o){let s=await J(W.resolve(r,o));s&&(e.env=lt(s))}let n=t.filter(s=>(s.includes("models")||s.includes("types")||s.includes("schemas"))&&(s.endsWith(".ts")||s.endsWith(".py")||s.endsWith(".rs")||s.endsWith(".go")));if(n.length){e.models=[];for(let s of n.slice(0,5)){let i=await J(W.resolve(r,s));i&&e.models.push({path:s,content:ne(i,2e3),type:W.extname(s).slice(1)})}}return e}function at(r,e){if(e==="prisma"){let t=r.match(/model\s+(\w+)\s*\{/g);return t?t.map(o=>o.replace(/model\s+/,"").replace(/\s*\{/,"")):[]}return[]}function lt(r){return{variables:r.split(`
|
|
2
|
+
`).filter(o=>o.trim()&&!o.trim().startsWith("#")).map(o=>{let[n]=o.split("="),s=n.trim(),i=o.includes("=")&&o.split("=")[1]?.trim().length>0;return{key:s,required:!i}})}}async function J(r){try{return rt(r)?await st.readFile(r,"utf8"):null}catch{return null}}function ne(r,e){return r.length<=e?r:r.slice(0,e)+`
|
|
3
|
+
... (truncated)`}function De(r){let e=[];if(r.database&&e.push(`## Database Schema (${r.database.type})
|
|
4
|
+
`+(r.database.tables?.length?`Tables: ${r.database.tables.join(", ")}
|
|
5
|
+
`:"")+"```\n"+r.database.content+"\n```"),r.api&&e.push(`## API Schema (${r.api.type})
|
|
6
|
+
\`\`\`
|
|
7
|
+
`+r.api.content+"\n```"),r.env&&e.push(`## Environment Variables
|
|
8
|
+
`+r.env.variables.map(t=>`- ${t.key}${t.required?" (required)":""}`).join(`
|
|
9
|
+
`)),r.models?.length)for(let t of r.models)e.push(`## Model: ${t.path}
|
|
10
|
+
\`\`\``+t.type+`
|
|
11
|
+
`+t.content+"\n```");return e.join(`
|
|
12
|
+
|
|
13
|
+
`)}import Ge from"node-fetch";var Fe="https://api.context7.com/v1";async function ct(r,e){try{let t={"Content-Type":"application/json"};e&&(t.Authorization=`Bearer ${e}`);let o=await Ge(`${Fe}/libraries/resolve`,{method:"POST",headers:t,body:JSON.stringify({name:r})});if(!o.ok)return null;let n=await o.json();return n?.libraries?.length?n.libraries[0]:null}catch{return null}}async function pt(r,e,t=5e3,o){try{let n={"Content-Type":"application/json"};o&&(n.Authorization=`Bearer ${o}`);let s=await Ge(`${Fe}/libraries/${encodeURIComponent(r)}/docs`,{method:"POST",headers:n,body:JSON.stringify({topic:e,maxTokens:t})});return s.ok&&(await s.json())?.content||null}catch{return null}}async function Ne(r,e,t){let o=[];for(let i of r.frameworks.slice(0,3))o.push(i.name);let n=["react","vue","svelte","angular","next","nuxt","express","fastify","hono","prisma","drizzle-orm","tailwindcss","shadcn","@tanstack/react-query","zod","trpc"];for(let i of n)(r.dependencies[i]||r.devDependencies[i])&&(o.includes(i)||o.push(i));let s=[];for(let i of o.slice(0,5)){let l=await ct(i,t);if(l){let a=await pt(l.id,e,3e3,t);a&&s.push(`## ${l.name} Documentation
|
|
14
|
+
${a}`)}}return s.length?`# Relevant Library Documentation (via Context7)
|
|
15
|
+
|
|
16
|
+
${s.join(`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
`)}`:""}var Le={component:{type:"component",baseDir:"src/components",filePatterns:["*.tsx","*.vue","*.svelte","*.jsx","*.ts"],description:"UI component"},page:{type:"page",baseDir:"src/app",filePatterns:["*.tsx","*.vue","*.svelte","*.jsx","*.astro"],description:"Page or screen"},api:{type:"api",baseDir:"src/api",filePatterns:["*.ts","*.js","*.py","*.go","*.rs"],description:"API route or endpoint"},website:{type:"website",baseDir:".",filePatterns:["*"],description:"Multi-file website"},document:{type:"document",baseDir:"docs",filePatterns:["*.md","*.mdx","*.txt","*.rst"],description:"Documentation"},script:{type:"script",baseDir:"scripts",filePatterns:["*.ts","*.js","*.py","*.sh","*.go"],description:"Standalone script"},config:{type:"config",baseDir:".",filePatterns:["*.json","*.yaml","*.yml","*.toml","*.env"],description:"Configuration file"},skill:{type:"skill",baseDir:".skills",filePatterns:["SKILL.md"],description:"Agent skill (SKILL.md)"},media:{type:"media",baseDir:"media",filePatterns:["*.md","*.json","*.txt"],description:"Media generation prompt/description"},report:{type:"report",baseDir:"reports",filePatterns:["*.md","*.html","*.json"],description:"Analysis report"},test:{type:"test",baseDir:"src",filePatterns:["*.test.ts","*.test.tsx","*.spec.ts","*.test.js","*.test.py","*.test.go"],description:"Test suite or fixture"},workflow:{type:"workflow",baseDir:".github/workflows",filePatterns:["*.yml","*.yaml"],description:"CI/CD pipeline or automation"},schema:{type:"schema",baseDir:"src",filePatterns:["*.ts","*.prisma","*.graphql","*.gql","*.py"],description:"Database schema, validators, or types"},email:{type:"email",baseDir:"src/emails",filePatterns:["*.tsx","*.jsx","*.html","*.mjml"],description:"Email template"},diagram:{type:"diagram",baseDir:"docs",filePatterns:["*.md","*.mmd","*.d2","*.puml"],description:"Architecture or data diagram"}};function _e(r,e){if(r&&r!=="auto")return r;let t=e.toLowerCase(),o=[[/\b(component|button|card|modal|dialog|form|input|dropdown|nav|sidebar|header|footer|widget|ui)\b/i,"component"],[/\b(page|screen|view|route|layout|dashboard|landing)\b/i,"page"],[/\b(api|endpoint|route handler|rest|graphql|webhook|middleware|server)\b/i,"api"],[/\b(website|site|web app|landing page|portfolio|blog)\b/i,"website"],[/\b(document|doc|readme|guide|tutorial|specification|spec|changelog)\b/i,"document"],[/\b(script|cli|command|tool|utility|migration|seed|cron)\b/i,"script"],[/\b(config|configuration|setup|env|settings)\b/i,"config"],[/\b(skill|agent skill|skill\.md)\b/i,"skill"],[/\b(video|audio|image|media|animation|thumbnail|podcast)\b/i,"media"],[/\b(report|audit|analysis|review|assessment|benchmark)\b/i,"report"],[/\b(test|spec|unit test|integration test|e2e|coverage|fixture|mock)\b/i,"test"],[/\b(workflow|ci|cd|pipeline|github action|deploy|automation|ci\/cd)\b/i,"workflow"],[/\b(schema|model|migration|prisma|drizzle|zod|validator|graphql type)\b/i,"schema"],[/\b(email|newsletter|transactional|invite|welcome email|notification email)\b/i,"email"],[/\b(diagram|erd|flowchart|architecture diagram|sequence diagram|mermaid|plantuml|d2)\b/i,"diagram"]];for(let[n,s]of o)if(n.test(t))return s;return"component"}import{existsSync as vt,promises as Ye}from"fs";import ae from"path";import{execa as mt}from"execa";import{z as j}from"zod";var V=["pre:generate","post:generate","pre:file-write","post:file-write","pre:prompt","post:response","pre:command","on:error","pre:tool-call","post:tool-call","pre:channel-message","post:channel-message","pre:a2a-task","pre:cron-run","post:cron-run","on:gitlab-pipeline","on:gitlab-issue"],Se=["pre:generate","pre:file-write","pre:prompt","post:response","pre:command","pre:tool-call","pre:channel-message","post:channel-message","pre:a2a-task","pre:cron-run"],Be=j.object({name:j.string(),type:j.enum(["command","prompt","script"]),command:j.string().optional(),prompt:j.string().optional(),provider:j.enum(["claude-code","claude","openai","ollama","custom"]).optional(),model:j.string().optional(),script:j.string().optional(),priority:j.number().default(100),enabled:j.boolean().default(!0)});var We={"claude-sonnet":{input:3,output:15},"claude-opus":{input:15,output:75},"claude-haiku":{input:.25,output:1.25}};function dt(r){let e=r.toLowerCase();return e.includes("opus")?"claude-opus":e.includes("haiku")?"claude-haiku":"claude-sonnet"}var re=class{steps=[];models=new Map;recordStep(e,t,o,n){let s=dt(t),i=We[s]||We["claude-sonnet"],l=o/1e6*i.input+n/1e6*i.output;this.steps.push({step:e,model:t,inputTokens:o,outputTokens:n,cost:l,timestamp:Date.now()});let a=this.models.get(t)||{inputTokens:0,outputTokens:0,cost:0,steps:0};a.inputTokens+=o,a.outputTokens+=n,a.cost+=l,a.steps++,this.models.set(t,a)}getSummary(){let e=0,t=0,o=0;for(let s of this.steps)e+=s.inputTokens,t+=s.outputTokens,o+=s.cost;let n={};for(let[s,i]of this.models)n[s]={...i};return{totalInputTokens:e,totalOutputTokens:t,totalTokens:e+t,totalCost:o,steps:[...this.steps],models:n}}reset(){this.steps=[],this.models.clear()}},Q=new re;function ut(r,e){let t=[];if(t.push(`# Session: ${r.id}`),t.push(""),t.push(`- **Created**: ${r.createdAt}`),t.push(`- **Updated**: ${r.updatedAt}`),t.push(`- **CWD**: ${r.cwd}`),t.push(`- **Messages**: ${r.messages.length}`),t.push(`- **Tokens**: ${r.tokensUsed.toLocaleString()}`),t.push(""),r.filesGenerated.length){t.push("## Files Generated"),t.push("");for(let o of r.filesGenerated)t.push(`- \`${o}\``);t.push("")}if(r.messages.length){t.push("## Conversation"),t.push("");for(let o of r.messages){if(o.role==="system")continue;let n=o.role==="user"?"**User**":"**Assistant**";t.push(`### ${n}`),t.push(""),o.role,t.push(o.content),t.push("")}}if(e){if(t.push("## Cost Summary"),t.push(""),t.push(`- **Total tokens**: ${e.totalTokens.toLocaleString()}`),t.push(` - Input: ${e.totalInputTokens.toLocaleString()}`),t.push(` - Output: ${e.totalOutputTokens.toLocaleString()}`),t.push(`- **Total cost**: $${e.totalCost.toFixed(4)}`),t.push(""),Object.keys(e.models).length){t.push("### Per Model"),t.push(""),t.push("| Model | Input | Output | Cost | Steps |"),t.push("|-------|-------|--------|------|-------|");for(let[o,n]of Object.entries(e.models))t.push(`| ${o} | ${n.inputTokens.toLocaleString()} | ${n.outputTokens.toLocaleString()} | $${n.cost.toFixed(4)} | ${n.steps} |`);t.push("")}if(e.steps.length){t.push("### Per Step"),t.push(""),t.push("| Step | Model | Input | Output | Cost |"),t.push("|------|-------|-------|--------|------|");for(let o of e.steps)t.push(`| ${o.step} | ${o.model} | ${o.inputTokens.toLocaleString()} | ${o.outputTokens.toLocaleString()} | $${o.cost.toFixed(4)} |`);t.push("")}}return t.join(`
|
|
21
|
+
`)}var X=class{hooks=new Map;register(e,t){if(!t.enabled)return;let o=this.createHandler(t),n={event:e,definition:t,handler:o},s=this.hooks.get(e)||[];s.push(n),s.sort((i,l)=>i.definition.priority-l.definition.priority),this.hooks.set(e,s)}async execute(e,t){let o=this.hooks.get(e);if(!o?.length)return{};let n=Se.includes(e),s={};for(let i of o){let l=Date.now();try{let a=await i.handler({...t,...s}),p=Date.now()-l;if(a.modified&&(s={...s,...a.modified}),n&&a.blocked)return x.hook(i.definition.name,p,"blocked"),{blocked:!0,message:a.message||`Blocked by hook: ${i.definition.name}`,modified:s};x.hook(i.definition.name,p,"ok")}catch(a){let p=Date.now()-l;if(x.hook(i.definition.name,p,`error: ${a.message}`),P.warn(`Hook "${i.definition.name}" failed: ${a.message}`),n)return{blocked:!0,message:`Hook "${i.definition.name}" errored: ${a.message}`}}}return{modified:Object.keys(s).length?s:void 0}}registerHandler(e,t,o,n=100){let i={event:e,definition:{name:t,type:"script",priority:n,enabled:!0},handler:o},l=this.hooks.get(e)||[];l.push(i),l.sort((a,p)=>a.definition.priority-p.definition.priority),this.hooks.set(e,l)}has(e){return!!this.hooks.get(e)?.length}clear(){this.hooks.clear()}size(){let e=0;for(let t of this.hooks.values())e+=t.length;return e}createHandler(e){switch(e.type){case"command":return this.createCommandHandler(e);case"script":return this.createScriptHandler(e);case"prompt":return this.createPromptHandler(e);default:throw new Error(`Unknown hook type: ${e.type}`)}}createCommandHandler(e){return async t=>{if(!e.command)return{};let o=e.command;o=o.replace(/\{\{(\w+)\}\}/g,(s,i)=>String(t[i]??""));let n=await mt("sh",["-c",o],{cwd:t.cwd||process.cwd(),reject:!1,timeout:6e4,env:process.env});return n.exitCode!==0?{blocked:!0,message:n.stderr||n.stdout||`Command hook "${e.name}" failed`}:{}}}createScriptHandler(e){return async t=>{if(!e.script)return{};let n=await import(e.script.startsWith("/")?e.script:`${t.cwd||process.cwd()}/${e.script}`),s=n.default||n.handler||n;return typeof s=="function"?await s(t):{}}}createPromptHandler(e){return async t=>{if(!e.prompt)return{};let o=e.provider||Y()?.provider||"claude-code",n=Ae();if(!n&&o!=="claude-code")return P.warn(`Prompt hook "${e.name}" skipped: no credentials available for provider "${o}"`),{};try{let{createProvider:s}=await import("./providers-WCQSKTNP.js"),i=s(o,n?.token),l=e.prompt;l=l.replace(/\{\{(\w+)\}\}/g,(k,A)=>String(t[A]??""));let a=`You are a hook validator for agentx. Analyze the following context and respond with ONLY a JSON object (no markdown, no code fences).
|
|
22
|
+
|
|
23
|
+
Response format:
|
|
24
|
+
{"action": "allow", "message": "optional explanation"}
|
|
25
|
+
OR
|
|
26
|
+
{"action": "block", "message": "reason for blocking"}
|
|
27
|
+
OR
|
|
28
|
+
{"action": "allow", "message": "optional", "modified": {"key": "new value"}}
|
|
29
|
+
|
|
30
|
+
The "modified" field is optional and can contain updated values to pass forward.`,u=(await i.generate([{role:"system",content:a},{role:"user",content:l}],{model:e.model,maxTokens:1024})).content.trim().match(/\{[\s\S]*\}/);if(!u)return P.warn(`Prompt hook "${e.name}": LLM response was not valid JSON, allowing`),{};let y=JSON.parse(u[0]);return y.action==="block"?{blocked:!0,message:y.message||`Blocked by prompt hook: ${e.name}`}:y.modified?{modified:y.modified}:{}}catch(s){return P.warn(`Prompt hook "${e.name}" failed: ${s.message}`),{}}}}};import{existsSync as qe,readFileSync as ft,readdirSync as gt}from"fs";import se from"path";function ht(r,e){yt(r,e),kt(r,e)}function yt(r,e){let t=se.join(r,"agentx.config.json");if(qe(t))try{let o=JSON.parse(ft(t,"utf8"));if(!o.hooks)return;for(let[n,s]of Object.entries(o.hooks)){if(!V.includes(n)){P.warn(`Unknown hook event in config: ${n}`);continue}let i=n;if(Array.isArray(s))for(let l of s)try{let a=Be.parse(l);e.register(i,a)}catch(a){P.warn(`Invalid hook definition for ${i}: ${a.message}`)}}}catch(o){P.warn(`Failed to load hooks from config: ${o.message}`)}}function kt(r,e){let t=se.join(r,".agentx","hooks");if(qe(t))try{let o=gt(t).filter(n=>n.endsWith(".ts")||n.endsWith(".js")||n.endsWith(".mjs"));for(let n of o){let s=n.replace(/\.(ts|js|mjs)$/,"").split(".");if(s.length<2){P.warn(`Hook file "${n}" should be named <event>.<name>.<ext>`);continue}let i=s[0],l=s.slice(1).join("."),a=i.replace(/-/g,":");if(!V.includes(a)){let p=i.replace("-",":");if(!V.includes(p)){P.warn(`Unknown hook event in filename: ${n}`);continue}e.register(p,{name:l,type:"script",script:se.join(t,n),priority:100,enabled:!0});continue}e.register(a,{name:l,type:"script",script:se.join(t,n),priority:100,enabled:!0})}}catch(o){P.warn(`Failed to load hooks from directory: ${o.message}`)}}var d=new X;import wt from"prompts";import bt from"chalk";import{z as G}from"zod";var ze=["default","acceptEdits","plan","yolo"],Ke=G.enum(ze),Pe=G.object({mode:Ke.default("default"),allow:G.array(G.string()).default([]),deny:G.array(G.string()).default([]),confirm:G.array(G.string()).default([])});function xt(r,e){let t=e.replace(/\./g,"\\.").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{GLOBSTAR\}\}/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${t}$`).test(r)}var ie=class{mode;allowPatterns;denyPatterns;confirmPatterns;autoAllowAll=!1;constructor(e){let t=Pe.parse(e||{});this.mode=t.mode,this.allowPatterns=t.allow,this.denyPatterns=t.deny,this.confirmPatterns=t.confirm}getMode(){return this.mode}setMode(e){this.mode=e,this.autoAllowAll=!1,x.context("permissions",`mode set to ${e}`)}async checkFileWrite(e){if(x.context("permissions",`checking write: ${e} (mode: ${this.mode})`),this.matchesAny(e,this.denyPatterns))return x.context("permissions",`denied by pattern: ${e}`),"deny";switch(this.mode){case"yolo":return"allow";case"plan":return"skip";case"acceptEdits":return"allow";case"default":return this.autoAllowAll||this.matchesAny(e,this.allowPatterns)?"allow":this.promptUser(e);default:return"allow"}}async checkCommand(e){return this.mode==="yolo"?"allow":this.mode==="plan"?"deny":"allow"}matchesAny(e,t){return t.some(o=>xt(e,o))}async promptUser(e){let{action:t}=await wt({type:"select",name:"action",message:`Write file ${bt.cyan(e)}?`,choices:[{title:"Yes",value:"allow"},{title:"No",value:"deny"},{title:"All (allow remaining)",value:"all"},{title:"Skip",value:"skip"}],initial:0});return t==="all"?(this.autoAllowAll=!0,"allow"):t||"deny"}},N=new ie;async function le(r,e){let t={written:[],skipped:[],errors:[]};for(let o of r){let n=ae.isAbsolute(o.path)?o.path:ae.resolve(e.cwd,e.outputDir||"",o.path);try{let s=o.content;if(d.has("pre:file-write")){let p=await d.execute("pre:file-write",{event:"pre:file-write",file:n,fileContent:s,cwd:e.cwd});if(p.blocked){t.skipped.push(n);continue}p.modified?.fileContent&&(s=String(p.modified.fileContent))}let i=ae.relative(e.cwd,n),l=await N.checkFileWrite(i);if(l==="deny"){t.skipped.push(n);continue}if(l==="skip"){t.written.push(n);continue}if(vt(n)&&!e.overwrite){t.skipped.push(n);continue}if(e.dryRun){t.written.push(n);continue}let a=ae.dirname(n);await Ye.mkdir(a,{recursive:!0}),await Ye.writeFile(n,s,"utf8"),t.written.push(n),d.has("post:file-write")&&await d.execute("post:file-write",{event:"post:file-write",file:n,fileContent:s,cwd:e.cwd})}catch(s){t.errors.push(`${n}: ${s.message}`)}}return t}function ce(r,e,t){if(t)return t;let o=Le[r];if(!o)return"generated";let n=o.baseDir;return r==="component"&&(e.srcDir?n=`${e.srcDir}/components`:n="components"),r==="page"&&e.frameworks.find(i=>i.name==="nextjs")&&e.srcDir&&(n=`${e.srcDir}/app`),r==="api"&&e.frameworks.find(i=>i.name==="nextjs")&&(n=e.srcDir?`${e.srcDir}/app/api`:"app/api"),r==="test"&&(e.testing.includes("vitest")||e.testing.includes("jest"))&&(n=e.srcDir||"src"),r==="workflow"&&(n=".github/workflows"),r==="schema"&&(e.databases.includes("prisma")?n="prisma":e.srcDir&&(n=`${e.srcDir}/schemas`)),r==="email"&&(n=e.srcDir?`${e.srcDir}/emails`:"emails"),n}import _t from"os";var St=_t.homedir(),Z=class{constructor(e){this.cwd=e;this.userMemory=new be(St),this.projectMemory=new be(e)}userMemory;projectMemory;async load(){await Promise.all([this.userMemory.load(),this.projectMemory.load()])}async save(){await Promise.all([this.userMemory.save(),this.projectMemory.save()])}buildMemoryContext(e){let t=this.userMemory.buildMemoryContext(e),o=this.projectMemory.buildMemoryContext(e);if(!t&&!o)return"";let n=[];return o&&n.push(o),t&&n.push(t.replace("# Memory (learned from past interactions)","# Global Memory (cross-project patterns)")),n.join(`
|
|
31
|
+
|
|
32
|
+
`)}async learnPreference(e,t,o){await this.userMemory.learnPreference(e,t,o)}async recordGeneration(e){return this.projectMemory.recordGeneration(e)}getPreferences(){let e=this.userMemory.getPreferences(),t=this.projectMemory.getPreferences(),o=new Map;for(let n of e)o.set(n.key,n);for(let n of t)o.set(n.key,n);return Array.from(o.values())}getPatterns(){let e=this.userMemory.getPatterns();return[...this.projectMemory.getPatterns(),...e]}getStats(){return{user:this.userMemory.getStats(),project:this.projectMemory.getStats()}}getRecentGenerations(e=10){return this.projectMemory.getRecentGenerations(e)}};import{existsSync as Je,readFileSync as Ve}from"fs";import Qe from"path";function Xe(r,e){return r.replace(/@([\w./-]+)/g,(t,o)=>{let n=Qe.resolve(e,o);if(Je(n))try{return Ve(n,"utf8")}catch{return t}return t})}function Te(r){let e=["SHADXN.md","CLAUDE.md"];for(let t of e){let o=Qe.join(r,t);if(Je(o))try{let n=Ve(o,"utf8");return n=Xe(n,r),n}catch{}}return""}function Pt(r){return Math.ceil(r.length/4)}var Ce=class{sections=[];addSection(e,t,o=50){t.trim()&&this.sections.push({label:e,content:t,priority:o})}buildContext(e,t=12e3){if(this.sections.length===0)return"";let o=this.sections.map(c=>c.content),n=xe(o),s=ve(e,n),i=new Map(s.map(c=>[c.docIndex,c.score])),l=this.sections.map((c,u)=>({...c,relevance:i.get(u)??0,tokens:Pt(c.content)}));l.sort((c,u)=>u.priority+u.relevance*100-(c.priority+c.relevance*100));let a=[],p=0;for(let c of l)p+c.tokens>t&&a.length>0||(a.push(c),p+=c.tokens);return a.map(c=>c.content).join(`
|
|
33
|
+
|
|
34
|
+
`)}};import{promises as ee}from"fs";import pe from"path";import{execa as Ct}from"execa";import Ze from"fast-glob";var te=class{cwd;options;constructor(e,t={}){this.cwd=e,this.options=t}async execute(e){if(x.context("tool-executor",`executing: ${e.name}`),d.has("pre:tool-call")){let o=await d.execute("pre:tool-call",{event:"pre:tool-call",toolName:e.name,toolInput:e.input,cwd:this.cwd});if(o.blocked)return{tool_use_id:e.id,content:o.message||`Tool ${e.name} blocked by pre:tool-call hook`,is_error:!0}}let t;try{switch(e.name){case"read_file":t=await this.readFile(e);break;case"search_files":t=await this.searchFiles(e);break;case"list_directory":t=await this.listDirectory(e);break;case"run_command":t=await this.runCommand(e);break;case"edit_file":t=await this.editFile(e);break;case"create_files":t=await this.createFiles(e);break;case"ask_user":t=await this.askUser(e);break;case"spawn_agent":t=await this.spawnAgent(e);break;default:t={tool_use_id:e.id,content:`Unknown tool: ${e.name}`,is_error:!0}}}catch(o){t={tool_use_id:e.id,content:`Error executing ${e.name}: ${o.message}`,is_error:!0}}return d.has("post:tool-call")&&await d.execute("post:tool-call",{event:"post:tool-call",toolName:e.name,toolInput:e.input,toolResult:t.content,cwd:this.cwd}),t}async readFile(e){let t=String(e.input.path||""),o=Number(e.input.max_lines)||500,n=pe.resolve(this.cwd,t),s=await ee.readFile(n,"utf8"),i=s.split(`
|
|
35
|
+
`),a=i.length>o?i.slice(0,o).join(`
|
|
36
|
+
`)+`
|
|
37
|
+
|
|
38
|
+
... (truncated, ${i.length-o} more lines)`:s;return{tool_use_id:e.id,content:a}}async searchFiles(e){let t=String(e.input.pattern||"**/*"),o=e.input.content_regex?String(e.input.content_regex):void 0,n=Number(e.input.max_results)||50,s=await Ze(t,{cwd:this.cwd,ignore:["node_modules/**",".git/**","dist/**",".next/**"],dot:!1});if(!o){let a=s.slice(0,n);return{tool_use_id:e.id,content:a.length?a.join(`
|
|
39
|
+
`)+(s.length>n?`
|
|
40
|
+
|
|
41
|
+
... (${s.length-n} more files)`:""):"No files matched the pattern."}}let i=new RegExp(o,"gm"),l=[];for(let a of s){if(l.length>=n)break;try{let c=(await ee.readFile(pe.resolve(this.cwd,a),"utf8")).split(`
|
|
42
|
+
`);for(let u=0;u<c.length&&!(l.length>=n);u++)i.test(c[u])&&l.push(`${a}:${u+1}: ${c[u]}`),i.lastIndex=0}catch{}}return{tool_use_id:e.id,content:l.length?l.join(`
|
|
43
|
+
`):"No matches found."}}async listDirectory(e){let t=String(e.input.path||"."),o=!!e.input.recursive,n=Number(e.input.max_depth)||3,s=pe.resolve(this.cwd,t);if(o){let p=await Ze("**/*",{cwd:s,onlyFiles:!1,markDirectories:!0,deep:n,ignore:["node_modules/**",".git/**","dist/**",".next/**"]});return{tool_use_id:e.id,content:p.length?p.join(`
|
|
44
|
+
`):"Empty directory."}}let l=(await ee.readdir(s,{withFileTypes:!0})).map(a=>a.isDirectory()?`${a.name}/`:a.name);return{tool_use_id:e.id,content:l.length?l.join(`
|
|
45
|
+
`):"Empty directory."}}async runCommand(e){let t=String(e.input.command||""),o=Number(e.input.timeout)||3e4;if(await N.checkCommand(t)==="deny")return{tool_use_id:e.id,content:`Command blocked by permissions (mode: ${N.getMode()}): ${t}`,is_error:!0};if(d.has("pre:command")){let a=await d.execute("pre:command",{event:"pre:command",command:t,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`Command blocked by pre:command hook: ${t}`,is_error:!0}}let s=await Ct("sh",["-c",t],{cwd:this.cwd,timeout:o,reject:!1,stdin:"ignore"}),i=[s.stdout,s.stderr].filter(Boolean).join(`
|
|
46
|
+
`),l=i.length>1e4?i.slice(0,1e4)+`
|
|
47
|
+
|
|
48
|
+
... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
|
|
49
|
+
${l}`,is_error:!0}:{tool_use_id:e.id,content:l||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,n=pe.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await N.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(d.has("pre:file-write")){let a=await d.execute("pre:file-write",{event:"pre:file-write",file:n,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await ee.readFile(n,"utf8"),l=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),l.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):l.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await ee.writeFile(n,i,"utf8"),d.has("post:file-write")&&await d.execute("post:file-write",{event:"post:file-write",file:n,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
|
|
50
|
+
${l.join(`
|
|
51
|
+
`)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-EPOT3QDM.js"),{getGlobalRegistry:i}=await import("./registry-ONJSILH4.js"),l=i();if(!l)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(l).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
|
|
52
|
+
|
|
53
|
+
${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,n=t;return o?.length&&(n+=`
|
|
54
|
+
Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:n}}};async function Re(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,cwd:s,maxIterations:i=20,enabledTools:l,interactive:a=!0,overwrite:p=!1,dryRun:c=!1,onProgress:u}=r;if(!e.generateRaw)return et(r);let y=new te(s,{interactive:a,overwrite:p,dryRun:c}),k=he(l),A=o.filter(v=>v.role!=="system").map(v=>({role:v.role,content:v.content})),F=[],C=0,T="",I,O=0;for(;O<i;){O++,u?.({type:"iteration_start",iteration:O}),x.step(O,`Agentic loop iteration (${k.length} tools available)`);let v;try{v=await e.generateRaw(A,t,k,n)}catch(w){if(w.message?.includes("not available"))return et(r);throw w}C+=v.usage.input_tokens+v.usage.output_tokens;for(let w of v.content)w.type==="text"&&(T+=w.text,u?.({type:"text_delta",text:w.text}));if(v.stop_reason==="end_turn"||v.stop_reason==="max_tokens")break;if(v.stop_reason==="tool_use"){let w=v.content.filter(_=>_.type==="tool_use");if(w.length===0)break;A.push({role:"assistant",content:v.content});let E=[];for(let _ of w){u?.({type:"tool_call",name:_.name,id:_.id,input:_.input}),x.step(O,`Tool call: ${_.name}`);let b=await y.execute({name:_.name,id:_.id,input:_.input});u?.({type:"tool_result",name:_.name,id:_.id,content:b.content.slice(0,200),is_error:b.is_error}),b.files?.length&&(F.push(...b.files),u?.({type:"files_created",files:b.files})),b.followUp&&(I=b.followUp),E.push({type:"tool_result",tool_use_id:b.tool_use_id,content:b.content,is_error:b.is_error})}if(A.push({role:"user",content:E}),I)break;continue}break}return u?.({type:"complete",iterations:O,totalTokens:C}),{files:F,content:T,followUp:I,tokensUsed:C,iterations:O}}async function et(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,maxIterations:s=5}=r,l=[{role:"system",content:t+`
|
|
55
|
+
|
|
56
|
+
`+ye()},...o.filter(k=>k.role!=="system")],a=[],p=0,c="",u,y=0;for(;y<s;){y++,x.step(y,`Legacy loop step (model: ${n.model||"default"})`);let k=await e.generate(l,n);if(p+=k.tokensUsed||0,c=k.content,k.files.length&&a.push(...k.files),k.followUp){u=k.followUp;break}if(k.files.length===0&&y>1||!(k.content.includes("[CONTINUE]")||k.content.includes("Next, I'll")||k.content.includes("Now let me")||k.content.includes("I'll also generate")))break;let F=k.files.map(C=>`Created: ${C.path}${C.description?` \u2014 ${C.description}`:""}`).join(`
|
|
57
|
+
`);l.push({role:"assistant",content:k.content+(F?`
|
|
58
|
+
|
|
59
|
+
Files created:
|
|
60
|
+
${F}`:"")}),l.push({role:"user",content:"Continue generating the remaining files. Build on what you've already created. When finished, do not include [CONTINUE] in your response."})}return{files:a,content:c,followUp:u,tokensUsed:p,iterations:y}}function $e(r){return typeof r.generateRaw=="function"}var de=class{queue=[];resolvers=[];closed=!1;push(e){if(this.closed)return;let t=this.resolvers.shift();if(t){t({value:e,done:!1});return}this.queue.push(e)}close(){if(!this.closed){this.closed=!0;for(let e of this.resolvers.splice(0))e({value:void 0,done:!0})}}async next(){return this.queue.length?{value:this.queue.shift(),done:!1}:this.closed?{value:void 0,done:!0}:new Promise(e=>{this.resolvers.push(e)})}async*[Symbol.asyncIterator](){for(;;){let{value:e,done:t}=await this.next();if(t)return;yield e}}};async function tt(r,e,t){let o=je.parse(t||{}),n=new Z(r);await n.load();let[s,i,l]=await Promise.all([Oe(r),Ue(r),He(r)]),a="";if(o.context7.enabled)try{a=await Ne(s,e,o.context7.apiKey)}catch{}let p=n.buildMemoryContext(e),c=Te(r);return x.context("memory",p?"loaded":"empty"),x.context("instructions",c?"loaded from project":"none"),{techStack:s,schemas:i,skills:l,docs:a,config:o,memoryContext:p,projectInstructions:c}}async function Cn(r){let{task:e,cwd:t,overwrite:o=!1,dryRun:n=!1,provider:s="claude-code",model:i,apiKey:l,context7:a=!0,interactive:p=!0}=r,c=e;if(d.has("pre:prompt")){let f=await d.execute("pre:prompt",{event:"pre:prompt",task:e,cwd:t});if(f.blocked)throw new Error(f.message||"Blocked by pre:prompt hook");f.modified?.task&&(c=String(f.modified.task))}if(d.has("pre:generate")){let f=await d.execute("pre:generate",{event:"pre:generate",task:c,cwd:t});if(f.blocked)throw new Error(f.message||"Blocked by pre:generate hook")}P.info("Analyzing project...");let u=await tt(t,c,{provider:s,context7:{enabled:a,apiKey:l}}),y=_e(r.outputType,c);P.info(`Output type: ${y}`);let k=we(u.skills,c,y);k.length&&P.info(`Loaded ${k.length} relevant skill(s): ${k.map(f=>f.skill.frontmatter.name).join(", ")}`);let A=ot(u,y,k.map(f=>f.skill));if(!await ge(l))throw new Error("No credentials configured. Run `agentx model` to set up.");let C=ke(s,l),T=i||Y()?.model,I=[...r.sessionMessages||[],{role:"user",content:c}];P.info("Generating...");let O=$e(C),v=r.maxSteps??(O?20:5),w=await Re({provider:C,systemPrompt:A,messages:[{role:"system",content:A},...I],providerOptions:{model:T,maxTokens:8192},cwd:t,maxIterations:v,enabledTools:u.config.agentic.enabledTools.filter(f=>!u.config.agentic.disabledTools.includes(f)),interactive:p,overwrite:o,dryRun:n,onProgress:f=>{f.type==="iteration_start"&&f.iteration>1&&P.info(`Step ${f.iteration}/${v}...`),f.type==="tool_call"&&x.step(0,`Tool: ${f.name}`)}});if(w.tokensUsed){let f=T||"claude-sonnet-4-20250514",L=Math.round(w.tokensUsed*.3),ue=w.tokensUsed-L;Q.recordStep(1,f,L,ue)}let{content:E}=w,{followUp:_,tokensUsed:b}=w;if(w.iterations>1&&P.info(`Completed in ${w.iterations} step(s)`),d.has("post:response")){let f=await d.execute("post:response",{event:"post:response",content:E,task:c,cwd:t});if(f.blocked)throw new Error(f.message||"Blocked by post:response hook");f.modified?.content&&(E=String(f.modified.content))}if(_&&p)return{files:{written:[],skipped:[],errors:[]},content:E,outputType:y,followUp:_,tokensUsed:b};let U=new Map;for(let f of w.files)U.set(f.path,f);let M=ce(y,u.techStack,r.outputDir),R=await le(Array.from(U.values()),{cwd:t,overwrite:o,dryRun:n,outputDir:M}),H;if(r.heal!==!1&&!n&&R.written.length>0){let{HealEngine:f}=await import("./heal-YP7QI7D3.js");H=await new f(t,{enabled:!0,testCommand:r.healConfig?.testCommand,buildCommand:r.healConfig?.buildCommand,lintCommand:r.healConfig?.lintCommand,maxAttempts:r.healConfig?.maxAttempts??3,provider:s,model:T,apiKey:l}).detectAndHeal(R.written,c),!H.healed&&H.error&&await d.execute("on:error",{event:"on:error",error:new Error(H.error),task:c,cwd:t})}return d.has("post:generate")&&await d.execute("post:generate",{event:"post:generate",task:c,content:E,cwd:t}),{files:R,content:E,outputType:y,tokensUsed:b,healResult:H}}async function*Tn(r){let{task:e,cwd:t,overwrite:o=!1,dryRun:n=!1,provider:s="claude-code",model:i,apiKey:l,context7:a=!0,interactive:p=!0}=r,c=e;if(d.has("pre:prompt")){let m=await d.execute("pre:prompt",{event:"pre:prompt",task:e,cwd:t});if(m.blocked){yield{type:"error",error:m.message||"Blocked by pre:prompt hook"};return}m.modified?.task&&(c=String(m.modified.task))}if(d.has("pre:generate")){let m=await d.execute("pre:generate",{event:"pre:generate",task:c,cwd:t});if(m.blocked){yield{type:"error",error:m.message||"Blocked by pre:generate hook"};return}}let u=await tt(t,c,{provider:s,context7:{enabled:a,apiKey:l}}),y=_e(r.outputType,c);yield{type:"context_ready",outputType:y};let k=we(u.skills,c,y),A=ot(u,y,k.map(m=>m.skill));if(!await ge(l)){yield{type:"error",error:"No credentials configured. Run `agentx model` to set up."};return}let C=ke(s,l),T=i||Y()?.model,I=$e(C),O=r.maxSteps??(I?20:5),v=[...r.sessionMessages||[],{role:"user",content:c}];if(I){let m=new de,S,h,B=(async()=>{try{S=await Re({provider:C,systemPrompt:A,messages:[{role:"system",content:A},...v],providerOptions:{model:T,maxTokens:8192},cwd:t,maxIterations:O,enabledTools:u.config.agentic.enabledTools.filter(g=>!u.config.agentic.disabledTools.includes(g)),interactive:p,overwrite:o,dryRun:n,onProgress:g=>{g.type==="text_delta"&&m.push({type:"text_delta",text:g.text}),g.type==="iteration_start"&&m.push({type:"iteration",iteration:g.iteration}),g.type==="tool_call"&&m.push({type:"tool_call",name:g.name,id:g.id}),g.type==="tool_result"&&m.push({type:"tool_result",name:g.name,id:g.id,is_error:g.is_error}),g.type==="files_created"&&m.push({type:"step_complete",step:0,filesCount:g.files.length})}})}catch(g){h=g}finally{m.close()}})();for await(let g of m)yield g;if(await B,h){yield{type:"error",error:h instanceof Error?h.message:String(h)};return}if(!S){yield{type:"error",error:"Agentic loop failed without a result"};return}yield{type:"done",result:{content:S.content,files:S.files,tokensUsed:S.tokensUsed,followUp:S.followUp}};let{content:D}=S;if(d.has("post:response")){let g=await d.execute("post:response",{event:"post:response",content:D,task:c,cwd:t});if(g.blocked){yield{type:"error",error:g.message||"Blocked by post:response hook"};return}g.modified?.content&&(D=String(g.modified.content))}if(S.followUp&&p){yield{type:"generate_result",result:{files:{written:[],skipped:[],errors:[]},content:D,outputType:y,followUp:S.followUp,tokensUsed:S.tokensUsed}};return}let z=new Map;for(let g of S.files)z.set(g.path,g);let fe=ce(y,u.techStack,r.outputDir),oe=await le(Array.from(z.values()),{cwd:t,overwrite:o,dryRun:n,outputDir:fe}),K;if(r.heal!==!1&&!n&&oe.written.length>0){let{HealEngine:g}=await import("./heal-YP7QI7D3.js");K=await new g(t,{enabled:!0,testCommand:r.healConfig?.testCommand,buildCommand:r.healConfig?.buildCommand,lintCommand:r.healConfig?.lintCommand,maxAttempts:r.healConfig?.maxAttempts??3,provider:s,model:T,apiKey:l}).detectAndHeal(oe.written,c)}d.has("post:generate")&&await d.execute("post:generate",{event:"post:generate",task:c,content:D,cwd:t}),yield{type:"generate_result",result:{files:oe,content:D,outputType:y,tokensUsed:S.tokensUsed,healResult:K}};return}let w=[{role:"system",content:A},...v],E=[],_=0,b="",U,M=0;M++,x.step(M,`Starting generation (model: ${T||"default"})`);let R;if(C.stream){let m="",S;for await(let h of C.stream(w,{model:T,maxTokens:8192}))yield h,h.type==="text_delta"&&(m+=h.text),h.type==="done"&&(S=h.result);R=S||{content:m,files:[],tokensUsed:0}}else{let m=await C.generate(w,{model:T,maxTokens:8192});m.content&&(yield{type:"text_delta",text:m.content}),yield{type:"done",result:m},R=m}_+=R.tokensUsed||0,b=R.content;let H=R.tokensUsed||0,f=T||"claude-sonnet-4-20250514",L=Math.round(H*.3),ue=H-L;if(Q.recordStep(M,f,L,ue),x.api("generate",f,H),x.step(M,`Generated ${R.files.length} file(s), ${H} tokens`),R.files.length&&E.push(...R.files),R.followUp&&(U=R.followUp),yield{type:"step_complete",step:M,filesCount:R.files.length},!U&&(b.includes("[CONTINUE]")||b.includes("Next, I'll")||b.includes("Now let me")||b.includes("I'll also generate"))&&R.files.length>0){let S=R.files.map(h=>`Created: ${h.path}${h.description?` \u2014 ${h.description}`:""}`).join(`
|
|
61
|
+
`);for(w.push({role:"assistant",content:b+(S?`
|
|
62
|
+
|
|
63
|
+
Files created:
|
|
64
|
+
${S}`:"")}),w.push({role:"user",content:"Continue generating the remaining files. Build on what you've already created. When finished, do not include [CONTINUE] in your response."});M<O;){M++,x.step(M,`Starting generation (model: ${T||"default"})`);let h=await C.generate(w,{model:T,maxTokens:8192});_+=h.tokensUsed||0,b=h.content;let B=h.tokensUsed||0,D=T||"claude-sonnet-4-20250514",z=Math.round(B*.3),fe=B-z;if(Q.recordStep(M,D,z,fe),x.api("generate",D,B),x.step(M,`Generated ${h.files.length} file(s), ${B} tokens`),h.files.length&&E.push(...h.files),yield{type:"step_complete",step:M,filesCount:h.files.length},h.followUp){U=h.followUp;break}if(h.files.length===0&&M>1||!(h.content.includes("[CONTINUE]")||h.content.includes("Next, I'll")||h.content.includes("Now let me")||h.content.includes("I'll also generate")))break;let K=h.files.map(g=>`Created: ${g.path}${g.description?` \u2014 ${g.description}`:""}`).join(`
|
|
65
|
+
`);w.push({role:"assistant",content:h.content+(K?`
|
|
66
|
+
|
|
67
|
+
Files created:
|
|
68
|
+
${K}`:"")}),w.push({role:"user",content:"Continue generating the remaining files. Build on what you've already created. When finished, do not include [CONTINUE] in your response."})}}if(d.has("post:response")){let m=await d.execute("post:response",{event:"post:response",content:b,task:c,cwd:t});if(m.blocked){yield{type:"error",error:m.message||"Blocked by post:response hook"};return}m.modified?.content&&(b=String(m.modified.content))}if(U&&p){yield{type:"generate_result",result:{files:{written:[],skipped:[],errors:[]},content:b,outputType:y,followUp:U,tokensUsed:_}};return}let Me=new Map;for(let m of E)Me.set(m.path,m);let nt=ce(y,u.techStack,r.outputDir),me=await le(Array.from(Me.values()),{cwd:t,overwrite:o,dryRun:n,outputDir:nt}),q;if(r.heal!==!1&&!n&&me.written.length>0){let{HealEngine:m}=await import("./heal-YP7QI7D3.js");q=await new m(t,{enabled:!0,testCommand:r.healConfig?.testCommand,buildCommand:r.healConfig?.buildCommand,lintCommand:r.healConfig?.lintCommand,maxAttempts:r.healConfig?.maxAttempts??3,provider:s,model:T,apiKey:l}).detectAndHeal(me.written,c),!q.healed&&q.error&&await d.execute("on:error",{event:"on:error",error:new Error(q.error),task:c,cwd:t})}d.has("post:generate")&&await d.execute("post:generate",{event:"post:generate",task:c,content:b,cwd:t}),yield{type:"generate_result",result:{files:me,content:b,outputType:y,tokensUsed:_,healResult:q}}}function ot(r,e,t){let o=[];o.push(`You are agentx, an agentic code generation tool. You generate high-quality, production-ready output for any tech stack.
|
|
69
|
+
|
|
70
|
+
Your primary tool is \`create_files\` \u2014 use it to output all generated code, documents, and configs as files.
|
|
71
|
+
If the request is ambiguous or you need critical information to proceed correctly, use \`ask_user\` to ask a clarifying question.
|
|
72
|
+
|
|
73
|
+
You also have tools to inspect the codebase before generating code:
|
|
74
|
+
- \`read_file\` \u2014 read existing files to understand patterns, styles, and implementations
|
|
75
|
+
- \`search_files\` \u2014 search for files by glob pattern, optionally grep content with regex
|
|
76
|
+
- \`list_directory\` \u2014 explore the project structure
|
|
77
|
+
- \`run_command\` \u2014 run shell commands (build, test, lint, etc.)
|
|
78
|
+
- \`edit_file\` \u2014 apply targeted search/replace edits to existing files
|
|
79
|
+
|
|
80
|
+
AGENTIC WORKFLOW:
|
|
81
|
+
- Before generating code, use \`read_file\` and \`search_files\` to understand the existing codebase
|
|
82
|
+
- Match the project's existing patterns, naming conventions, and code style
|
|
83
|
+
- After creating files, consider running tests or build commands to verify correctness
|
|
84
|
+
- Use \`edit_file\` for small, targeted changes instead of rewriting entire files
|
|
85
|
+
|
|
86
|
+
IMPORTANT RULES:
|
|
87
|
+
- Generate complete, working code \u2014 not stubs or placeholders
|
|
88
|
+
- Follow the project's existing patterns and conventions
|
|
89
|
+
- Use the detected tech stack to choose the right language, framework, and patterns
|
|
90
|
+
- File paths should be relative to the project root
|
|
91
|
+
- Include all necessary imports
|
|
92
|
+
- Do NOT add unnecessary dependencies
|
|
93
|
+
|
|
94
|
+
MULTI-STEP GENERATION:
|
|
95
|
+
For complex tasks that require multiple related files (e.g., schema + API + UI + tests), you can chain steps:
|
|
96
|
+
- Generate the foundational files first (schemas, types, configs)
|
|
97
|
+
- Include "[CONTINUE]" in your response text when there are more files to generate
|
|
98
|
+
- In subsequent steps, you'll see what was already created \u2014 build on it
|
|
99
|
+
- When all files are generated, do NOT include "[CONTINUE]"
|
|
100
|
+
- This enables you to generate a schema first, then an API that references it, then a UI that calls the API`),o.push(`# Project Tech Stack
|
|
101
|
+
${Ee(r.techStack)}`);let n=Object.keys(r.techStack.dependencies).slice(0,30);n.length&&o.push(`# Key Dependencies
|
|
102
|
+
${n.join(", ")}`);let s=De(r.schemas);return s&&o.push(`# Project Schemas
|
|
103
|
+
${s}`),t.length&&o.push(`# Active Skills
|
|
104
|
+
Follow these skill instructions when applicable:
|
|
105
|
+
|
|
106
|
+
`+t.map(i=>`## Skill: ${i.frontmatter.name}
|
|
107
|
+
${i.frontmatter.description}
|
|
108
|
+
|
|
109
|
+
${i.instructions}`).join(`
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
`)),r.docs&&o.push(r.docs),r.projectInstructions&&o.push(`# Project Instructions
|
|
114
|
+
${r.projectInstructions}`),r.memoryContext&&o.push(r.memoryContext),o.push(`# Output Type: ${e}
|
|
115
|
+
Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
|
|
116
|
+
|
|
117
|
+
`)}export{je as a,$t as b,Mt as c,Ue as d,De as e,Ne as f,Le as g,_e as h,V as i,Se as j,re as k,Q as l,ut as m,X as n,ht as o,d as p,ze as q,Ke as r,Pe as s,ie as t,N as u,Z as v,Xe as w,Te as x,Ce as y,te as z,tt as A,Cn as B,Tn as C};
|
|
118
|
+
//# sourceMappingURL=chunk-JXEPJ3YD.js.map
|