workspai 0.70.0 → 0.72.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/README.md +43 -80
- package/contracts/artifact-remediation-plan.v1.json +49 -0
- package/contracts/workspace-intelligence/goal-lifecycle-result.v1.json +19 -0
- package/contracts/workspace-repair-capabilities.v1.json +7 -1
- package/dist/analyze-5ENZTHOT.js +1 -0
- package/dist/{artifact-remediation-plan-URQL5MBN.js → artifact-remediation-plan-WDK5ISRU.js} +1 -1
- package/dist/autopilot-release-PNSWAVZG.js +1 -0
- package/dist/{chunk-EP6Q2QBU.js → chunk-2RF75G5T.js} +1 -1
- package/dist/{chunk-4R7STECB.js → chunk-5OLNT6YD.js} +63 -63
- package/dist/{chunk-GED7JURY.js → chunk-5PFFR5S7.js} +1 -1
- package/dist/{chunk-QZODGRAI.js → chunk-5TKRCE6F.js} +1 -1
- package/dist/{chunk-IGJA6GBQ.js → chunk-62YBFWHY.js} +1 -1
- package/dist/chunk-6WOFOOM7.js +7 -0
- package/dist/{chunk-ZLCLGIM6.js → chunk-7LKCWDX6.js} +1 -1
- package/dist/chunk-7Q7X4X5I.js +1 -0
- package/dist/chunk-BVWDG66W.js +1 -0
- package/dist/{chunk-DNZHKBQ3.js → chunk-COBU44T5.js} +1 -1
- package/dist/chunk-CQBM6BBP.js +2 -0
- package/dist/chunk-CY4QZ3PE.js +3 -0
- package/dist/{chunk-LE2I2E6R.js → chunk-D5RUGSBC.js} +2 -2
- package/dist/chunk-EDPUQXP6.js +5 -0
- package/dist/{chunk-IBJEQHJR.js → chunk-HV6EQMUJ.js} +24 -7
- package/dist/{chunk-V52R2W2Q.js → chunk-IX5Z6EK6.js} +1 -1
- package/dist/{chunk-N6FJZ62B.js → chunk-JQINCVK5.js} +1 -1
- package/dist/{chunk-GL3KLNIG.js → chunk-KVPTZMEV.js} +1 -1
- package/dist/{chunk-UT57IFS4.js → chunk-LDNX2R6V.js} +6 -6
- package/dist/{chunk-WUXJCSYO.js → chunk-LLEKVSMX.js} +1 -1
- package/dist/{chunk-ZPOZ6MDX.js → chunk-N2PAAQKI.js} +1 -1
- package/dist/{chunk-S2TOSHQW.js → chunk-ONV6WW7A.js} +1 -1
- package/dist/{chunk-TEMFNVO2.js → chunk-QVUVJU56.js} +1 -1
- package/dist/{chunk-AGZWDYMF.js → chunk-QYXX6G5O.js} +8 -8
- package/dist/{chunk-S42KDOGG.js → chunk-S66NO5BX.js} +1 -1
- package/dist/{chunk-KFTJVVJR.js → chunk-SATPH22S.js} +1 -1
- package/dist/{chunk-IFHM2SI6.js → chunk-SG3QRCMM.js} +1 -1
- package/dist/{chunk-Z7JIUA6I.js → chunk-SS7X2YF5.js} +1 -1
- package/dist/{chunk-IET57ZKN.js → chunk-T6KHOIEY.js} +1 -1
- package/dist/{chunk-TLMP2MGH.js → chunk-T6LCDLJ7.js} +1 -1
- package/dist/{chunk-QNHKUSBH.js → chunk-TDQ2PRHV.js} +1 -1
- package/dist/{chunk-3S2U7WRM.js → chunk-TQQEZQLC.js} +1 -1
- package/dist/{chunk-LU6CYDLN.js → chunk-UHAPXPGW.js} +1 -1
- package/dist/chunk-V4LCPLV6.js +1 -0
- package/dist/{chunk-GYN6RPNU.js → chunk-WMC2H7MJ.js} +1 -1
- package/dist/{chunk-PTSEDZIV.js → chunk-WPZUKU2B.js} +1 -1
- package/dist/chunk-X5ZNFXFI.js +1 -0
- package/dist/{create-BBALBC3U.js → create-7CWWGDXQ.js} +1 -1
- package/dist/{doctor-WWVY7NB6.js → doctor-WYBSI3GC.js} +1 -1
- package/dist/{dotnet-webapi-clean-XL4IBUQV.js → dotnet-webapi-clean-VJX6SGGP.js} +39 -33
- package/dist/{goal-lifecycle-CEUTKUNV.js → goal-lifecycle-PSPYQ4TR.js} +1 -1
- package/dist/{goal-pack-JQL3YOKT.js → goal-pack-G7SAYDIC.js} +1 -1
- package/dist/{gofiber-standard-OHHMCNMJ.js → gofiber-standard-I6ASLOEE.js} +77 -66
- package/dist/{gogin-standard-BAZXPOKL.js → gogin-standard-U2LSRLIP.js} +78 -67
- package/dist/index.js +121 -121
- package/dist/{pipeline-V46WWMP4.js → pipeline-NDV7DBB7.js} +1 -1
- package/dist/{project-agent-entry-MRAYG7QD.js → project-agent-entry-HEBGPLMX.js} +1 -1
- package/dist/{project-intelligence-lens-4BKPN4PE.js → project-intelligence-lens-QTQEZXUY.js} +1 -1
- package/dist/{project-test-coverage-4RRCHY5W.js → project-test-coverage-4BGDDBBL.js} +1 -1
- package/dist/{proof-carrying-change-B7ONTBYO.js → proof-carrying-change-SHO2E3DX.js} +1 -1
- package/dist/{rust-axum-CCJ6UCBW.js → rust-axum-JMV7UPO7.js} +25 -20
- package/dist/{springboot-standard-M5JQEJML.js → springboot-standard-OC2RS3KC.js} +41 -39
- package/dist/verified-goal-BSREU6R7.js +1 -0
- package/dist/{workspace-FJ6JRYWA.js → workspace-E3MM3AIE.js} +1 -1
- package/dist/{workspace-agent-sync-V33UGII3.js → workspace-agent-sync-NBIOSXCG.js} +1 -1
- package/dist/{workspace-context-O6UBCBEA.js → workspace-context-ZDXF6S7S.js} +1 -1
- package/dist/{workspace-contract-S2JYDA4K.js → workspace-contract-E7GVWM7W.js} +1 -1
- package/dist/{workspace-explain-RP6VJ6QM.js → workspace-explain-YB66UFAS.js} +1 -1
- package/dist/{workspace-foundation-7QXEJJKZ.js → workspace-foundation-LRLYPR36.js} +1 -1
- package/dist/{workspace-graph-stream-YY65R5EC.js → workspace-graph-stream-SJUCBPS4.js} +1 -1
- package/dist/workspace-graph-token-efficiency-BTIS6JXL.js +1 -0
- package/dist/{workspace-intelligence-LMR42ICR.js → workspace-intelligence-3IAAM3H3.js} +1 -1
- package/dist/{workspace-intelligence-benchmark-S5OXVNLC.js → workspace-intelligence-benchmark-UCGDKMDF.js} +1 -1
- package/dist/{workspace-intelligence-runner-FXFSTCHC.js → workspace-intelligence-runner-FPPKTSNK.js} +1 -1
- package/dist/{workspace-knowledge-graph-3564KQXT.js → workspace-knowledge-graph-WNQMNAVL.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-WHCGPBGS.js → workspace-knowledge-graph-query-3GPXGWYN.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-MTFTCVFF.js +1 -0
- package/dist/{workspace-mcp-serve-ZK46EZUD.js → workspace-mcp-serve-KSZ2O66S.js} +1 -1
- package/dist/{workspace-model-6UMQAGUK.js → workspace-model-5FA2636K.js} +1 -1
- package/dist/{workspace-onboarding-C57OQ7XZ.js → workspace-onboarding-RJMTHN7Z.js} +1 -1
- package/dist/{workspace-registry-summary-GLQO4ZUF.js → workspace-registry-summary-WKENOFEA.js} +1 -1
- package/dist/workspace-repair-engine-4JTNNDZL.js +3 -0
- package/dist/workspace-run-HFOY2UYT.js +1 -0
- package/dist/{workspace-verify-LQHXBH2D.js → workspace-verify-37QL2JYE.js} +1 -1
- package/dist/{workspace-watch-Z32443UP.js → workspace-watch-P5X6TAFK.js} +1 -1
- package/docs/README.md +5 -2
- package/docs/README_CONTENT_CONTRACT.md +14 -9
- package/docs/ci-workflows.md +1 -1
- package/docs/commands-reference.md +53 -34
- package/docs/contracts/ARTIFACT_CATALOG.md +4 -1
- package/docs/doctor-command.md +13 -0
- package/docs/native-kit-baselines.md +82 -0
- package/docs/workspace-knowledge-graph.md +17 -2
- package/docs/workspace-repair-engine.md +9 -1
- package/docs/workspace-run.md +29 -0
- package/package.json +1 -1
- package/dist/analyze-OGWDSPXQ.js +0 -1
- package/dist/autopilot-release-QQDFEPT7.js +0 -1
- package/dist/chunk-DWL3PPLA.js +0 -1
- package/dist/chunk-EZPLMAW2.js +0 -1
- package/dist/chunk-IHKG5C6G.js +0 -1
- package/dist/chunk-IRLKWRLP.js +0 -3
- package/dist/chunk-TKXRP2B4.js +0 -1
- package/dist/chunk-U5ENEDJA.js +0 -7
- package/dist/chunk-WCJU3CFG.js +0 -1
- package/dist/chunk-XSSNM4F5.js +0 -5
- package/dist/verified-goal-YNSBL7L3.js +0 -1
- package/dist/workspace-graph-token-efficiency-WNAFAN2F.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-P27RPMV5.js +0 -1
- package/dist/workspace-repair-engine-5ZSSF3T5.js +0 -3
- package/dist/workspace-run-UGWGT3K2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import {c as c$3}from'./chunk-GL3KLNIG.js';import {c}from'./chunk-ZLCLGIM6.js';import {j,i,d as d$1,f as f$1,c as c$2,e,h}from'./chunk-LU6CYDLN.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-LU6CYDLN.js';import {f as f$2}from'./chunk-EZPLMAW2.js';import {a as a$1}from'./chunk-QNHKUSBH.js';import {b}from'./chunk-EBQS5T7Q.js';import {b as b$1}from'./chunk-AGZWDYMF.js';import {f,i as i$1}from'./chunk-FE5R6EUV.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import C from'path';import _ from'fs-extra';var ve=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ye=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,Pe=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,je=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Ge(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(ve.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ye.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(Pe.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function Ce(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var re=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ae(e){return re.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=Ge(e),n=je.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=Ce(r),d=Ae(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>re.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function oe(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var ae="contracts/workspace-intelligence/goal-pack.v1.json",se="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Re="contracts/workspace-intelligence/goal-plan-result.v1.json",pe="contracts/workspace-intelligence/goal-index.v1.json",ue=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Se(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ie(e){return e.split(C.sep).join("/")}function V(e,t){return C.resolve(t.absolutePath??C.join(e,t.path))}function ce(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=C.isAbsolute(t)?C.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ie(a.path)===ie(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Ee(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function le(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>ce({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[ce({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Ie(e){if(e.explicitScope?.trim())return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=C.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Te(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function xe(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function _e(e){let t=C.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(ue.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(A=>({project:c.project.name,...A}))).filter((c,A,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===A).sort((c,A)=>c.project.localeCompare(A.project)||c.path.localeCompare(A.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=oe(e.intent),m=[...Se(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>f$2(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),de=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),U=[...S,...de];return U.filter((G,me)=>U.findIndex(ge=>ge.id===G.id)===me)}),c=[],A=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||A.has(S.id)||(A.add(S.id),c.push(S));}return xe(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g=I?b[0]??[]:[];for(let o of g.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function Le(e$1){let t=C.join(e$1,f$1);if(!await _.pathExists(t))return {schemaVersion:e,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,pe,"Goal index");try{i(r);}catch(n){let a=h(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function Ne(e$1,t,r){let n=e$1.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e$1.activeGoalId===t.id?null:e$1.activeGoalId,goals:[...e$1.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function et(e){let t=b({startPath:C.resolve(e.startPath),explicitWorkspacePath:e.workspacePath,strict:true,requireProjectMembership:true});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=C.resolve(t.workspacePath);e.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Ee(r),s=await Ie({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e.scope,selectScope:e.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>ue.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$2=K(e.intent,{availableCoverageRuntimes:v,...e.runtime?{selectedCoverageRuntime:e.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e.runtime&&!v.includes(e.runtime)){let i=e.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e.runtime&&f$2.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e.runtime&&f$2.requestedTarget?.runtime&&f$2.requestedTarget.runtime!==e.runtime)throw new Error(`--runtime ${e.runtime} conflicts with the ${f$2.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$2.category==="test-coverage"&&f$2.requestedTarget&&!f$2.requestedTarget.runtime&&v.length>1&&!e.runtime&&e.selectCoverageRuntime){let i=await e.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$2=K(e.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$2.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$2={...f$2,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$2.ambiguities]}),s.selectionRequired&&(f$2={...f$2,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$2.ambiguities]});let M=await _e({workspacePath:r,projects:d$2,graph:a$1,intent:f$2,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$2,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Te(a$1,l)},maxAttempts:p$1,consumer:e.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,ae,"Goal Pack"),a(T,se,"Goal agent handoff");let L=false,o=async()=>{let i=C.join(r,g.artifacts.goalPack),h=C.join(r,g.artifacts.agentHandoff),[c,A]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==A)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,ae,"Persisted Goal Pack"),a(k,se,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e.dryRun)await o();else {let i$2=`.workspai/goals/${g.id}/publication`;await f(r,i$2,async()=>{await o();let h=Ne(await Le(r),g,new Date().toISOString());a(h,pe,"Goal index"),i(h),await i$1(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$1],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e.dryRun?[]:L?[d$1,f$1]:y,dryRun:e.dryRun===true,resumed:L};return a(P,Re,"Goal plan result"),P}export{et as planGoalPack};
|
|
1
|
+
import {c as c$3}from'./chunk-KVPTZMEV.js';import {c}from'./chunk-7LKCWDX6.js';import {j,i,d as d$1,f as f$1,c as c$2,e,h}from'./chunk-UHAPXPGW.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-UHAPXPGW.js';import {f as f$2}from'./chunk-X5ZNFXFI.js';import {a as a$1}from'./chunk-TDQ2PRHV.js';import {b}from'./chunk-EBQS5T7Q.js';import {b as b$1}from'./chunk-QYXX6G5O.js';import {f,i as i$1}from'./chunk-FE5R6EUV.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import C from'path';import _ from'fs-extra';var ve=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ye=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,Pe=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,je=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Ge(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(ve.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ye.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(Pe.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function Ce(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var re=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ae(e){return re.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=Ge(e),n=je.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=Ce(r),d=Ae(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>re.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function oe(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var ae="contracts/workspace-intelligence/goal-pack.v1.json",se="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Re="contracts/workspace-intelligence/goal-plan-result.v1.json",pe="contracts/workspace-intelligence/goal-index.v1.json",ue=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Se(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ie(e){return e.split(C.sep).join("/")}function V(e,t){return C.resolve(t.absolutePath??C.join(e,t.path))}function ce(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=C.isAbsolute(t)?C.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ie(a.path)===ie(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Ee(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function le(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>ce({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[ce({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Ie(e){if(e.explicitScope?.trim())return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=C.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Te(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function xe(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function _e(e){let t=C.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(ue.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(A=>({project:c.project.name,...A}))).filter((c,A,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===A).sort((c,A)=>c.project.localeCompare(A.project)||c.path.localeCompare(A.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=oe(e.intent),m=[...Se(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>f$2(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),de=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),U=[...S,...de];return U.filter((G,me)=>U.findIndex(ge=>ge.id===G.id)===me)}),c=[],A=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||A.has(S.id)||(A.add(S.id),c.push(S));}return xe(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g=I?b[0]??[]:[];for(let o of g.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function Le(e$1){let t=C.join(e$1,f$1);if(!await _.pathExists(t))return {schemaVersion:e,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,pe,"Goal index");try{i(r);}catch(n){let a=h(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function Ne(e$1,t,r){let n=e$1.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e$1.activeGoalId===t.id?null:e$1.activeGoalId,goals:[...e$1.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function et(e){let t=b({startPath:C.resolve(e.startPath),explicitWorkspacePath:e.workspacePath,strict:true,requireProjectMembership:true});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=C.resolve(t.workspacePath);e.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Ee(r),s=await Ie({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e.scope,selectScope:e.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>ue.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$2=K(e.intent,{availableCoverageRuntimes:v,...e.runtime?{selectedCoverageRuntime:e.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e.runtime&&!v.includes(e.runtime)){let i=e.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e.runtime&&f$2.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e.runtime&&f$2.requestedTarget?.runtime&&f$2.requestedTarget.runtime!==e.runtime)throw new Error(`--runtime ${e.runtime} conflicts with the ${f$2.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$2.category==="test-coverage"&&f$2.requestedTarget&&!f$2.requestedTarget.runtime&&v.length>1&&!e.runtime&&e.selectCoverageRuntime){let i=await e.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$2=K(e.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$2.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$2={...f$2,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$2.ambiguities]}),s.selectionRequired&&(f$2={...f$2,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$2.ambiguities]});let M=await _e({workspacePath:r,projects:d$2,graph:a$1,intent:f$2,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$2,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Te(a$1,l)},maxAttempts:p$1,consumer:e.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,ae,"Goal Pack"),a(T,se,"Goal agent handoff");let L=false,o=async()=>{let i=C.join(r,g.artifacts.goalPack),h=C.join(r,g.artifacts.agentHandoff),[c,A]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==A)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,ae,"Persisted Goal Pack"),a(k,se,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e.dryRun)await o();else {let i$2=`.workspai/goals/${g.id}/publication`;await f(r,i$2,async()=>{await o();let h=Ne(await Le(r),g,new Date().toISOString());a(h,pe,"Goal index"),i(h),await i$1(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$1],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e.dryRun?[]:L?[d$1,f$1]:y,dryRun:e.dryRun===true,resumed:L};return a(P,Re,"Goal plan result"),P}export{et as planGoalPack};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c,b as
|
|
1
|
+
import {c,b,e,d,f,g,h as h$1,a as a$1}from'./chunk-HV6EQMUJ.js';import {h}from'./chunk-PKKSRXUS.js';import {b as b$1,a}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import u from'path';import o from'chalk';import O from'ora';import {execa}from'execa';function y(e){return `package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
@@ -52,16 +52,16 @@ func main() {
|
|
|
52
52
|
}
|
|
53
53
|
slog.Info("server stopped")
|
|
54
54
|
}
|
|
55
|
-
`}function
|
|
55
|
+
`}function C(e){return `module ${e.module_path}
|
|
56
56
|
|
|
57
57
|
go ${e.go_version}
|
|
58
58
|
|
|
59
59
|
require (
|
|
60
|
-
github.com/gofiber/fiber/v2
|
|
61
|
-
github.com/swaggo/fiber-swagger
|
|
62
|
-
github.com/swaggo/swag
|
|
60
|
+
github.com/gofiber/fiber/v2 ${a$1.go.fiber}
|
|
61
|
+
github.com/swaggo/fiber-swagger ${a$1.go.fiberSwagger}
|
|
62
|
+
github.com/swaggo/swag ${a$1.go.swag}
|
|
63
63
|
)
|
|
64
|
-
`}function
|
|
64
|
+
`}function N(e){return `package config
|
|
65
65
|
|
|
66
66
|
import (
|
|
67
67
|
"log/slog"
|
|
@@ -114,7 +114,7 @@ func getEnv(key, fallback string) string {
|
|
|
114
114
|
}
|
|
115
115
|
return fallback
|
|
116
116
|
}
|
|
117
|
-
`}function
|
|
117
|
+
`}function E(e){return `package server
|
|
118
118
|
|
|
119
119
|
import (
|
|
120
120
|
"net/http"
|
|
@@ -180,7 +180,7 @@ func NewApp(cfg *config.Config) *fiber.App {
|
|
|
180
180
|
|
|
181
181
|
return app
|
|
182
182
|
}
|
|
183
|
-
`}function
|
|
183
|
+
`}function L(){return `package handlers
|
|
184
184
|
|
|
185
185
|
import (
|
|
186
186
|
"time"
|
|
@@ -218,7 +218,7 @@ func Readiness(c *fiber.Ctx) error {
|
|
|
218
218
|
"time": time.Now().UTC().Format(time.RFC3339),
|
|
219
219
|
})
|
|
220
220
|
}
|
|
221
|
-
`}function
|
|
221
|
+
`}function G(e){return `package handlers_test
|
|
222
222
|
|
|
223
223
|
import (
|
|
224
224
|
"encoding/json"
|
|
@@ -267,8 +267,8 @@ func TestReadiness(t *testing.T) {
|
|
|
267
267
|
t.Fatalf("expected 200, got %d: %s", resp.StatusCode, resp.Status)
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
`}function
|
|
271
|
-
FROM golang
|
|
270
|
+
`}function A(){return `# \u2500\u2500 Build stage \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
271
|
+
FROM golang:${a$1.go.version}-alpine AS builder
|
|
272
272
|
|
|
273
273
|
# Build-time version injection
|
|
274
274
|
ARG VERSION=dev
|
|
@@ -286,7 +286,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build \\
|
|
|
286
286
|
|
|
287
287
|
# \u2500\u2500 Runtime stage \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\u2500\u2500\u2500\u2500\u2500\u2500
|
|
288
288
|
# alpine includes busybox wget required for the HEALTHCHECK below.
|
|
289
|
-
FROM alpine
|
|
289
|
+
FROM alpine:${a$1.go.alpine}
|
|
290
290
|
|
|
291
291
|
RUN addgroup -S app && adduser -S -G app app
|
|
292
292
|
COPY --from=builder /app/server /server
|
|
@@ -296,7 +296,7 @@ EXPOSE 3000
|
|
|
296
296
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
|
|
297
297
|
CMD wget -qO- http://localhost:3000/api/v1/health/live || exit 1
|
|
298
298
|
ENTRYPOINT ["/server"]
|
|
299
|
-
`}function
|
|
299
|
+
`}function I(e){return `version: "3.9"
|
|
300
300
|
|
|
301
301
|
services:
|
|
302
302
|
api:
|
|
@@ -311,7 +311,7 @@ services:
|
|
|
311
311
|
CORS_ALLOW_ORIGINS: "*"
|
|
312
312
|
RATE_LIMIT_RPS: "100"
|
|
313
313
|
restart: unless-stopped
|
|
314
|
-
`}function
|
|
314
|
+
`}function k(e){return f({projectName:e.project_name,devCommand:"$(GOBIN)/air",runCommand:"go run $(LDFLAGS) ./cmd/server",testCommand:"go test ./... -v -race",includeLintAndFmt:true})}function F(e){return `# Application
|
|
315
315
|
PORT=${e.port}
|
|
316
316
|
APP_ENV=development
|
|
317
317
|
LOG_LEVEL=debug
|
|
@@ -321,7 +321,7 @@ CORS_ALLOW_ORIGINS=*
|
|
|
321
321
|
|
|
322
322
|
# Rate limiting \u2014 max requests per IP per second
|
|
323
323
|
RATE_LIMIT_RPS=100
|
|
324
|
-
`}function
|
|
324
|
+
`}function x(){return `# Binaries
|
|
325
325
|
bin/
|
|
326
326
|
*.exe
|
|
327
327
|
*.exe~
|
|
@@ -361,7 +361,7 @@ docs/docs.go
|
|
|
361
361
|
# OS
|
|
362
362
|
.DS_Store
|
|
363
363
|
Thumbs.db
|
|
364
|
-
`}function
|
|
364
|
+
`}function D(e){return `name: CI
|
|
365
365
|
|
|
366
366
|
on:
|
|
367
367
|
push:
|
|
@@ -369,16 +369,19 @@ on:
|
|
|
369
369
|
pull_request:
|
|
370
370
|
branches: [main]
|
|
371
371
|
|
|
372
|
+
permissions:
|
|
373
|
+
contents: read
|
|
374
|
+
|
|
372
375
|
jobs:
|
|
373
376
|
test:
|
|
374
377
|
name: Test
|
|
375
378
|
runs-on: ubuntu-latest
|
|
376
379
|
|
|
377
380
|
steps:
|
|
378
|
-
- uses: actions/checkout
|
|
381
|
+
- uses: actions/checkout@${a$1.actions.checkout}
|
|
379
382
|
|
|
380
383
|
- name: Set up Go
|
|
381
|
-
uses: actions/setup-go
|
|
384
|
+
uses: actions/setup-go@${a$1.actions.setupGo}
|
|
382
385
|
with:
|
|
383
386
|
go-version: "${e.go_version}"
|
|
384
387
|
cache: true
|
|
@@ -393,7 +396,7 @@ jobs:
|
|
|
393
396
|
run: go test ./... -race -coverprofile=coverage.out
|
|
394
397
|
|
|
395
398
|
- name: Upload coverage
|
|
396
|
-
uses: actions/upload-artifact
|
|
399
|
+
uses: actions/upload-artifact@${a$1.actions.uploadArtifact}
|
|
397
400
|
with:
|
|
398
401
|
name: coverage
|
|
399
402
|
path: coverage.out
|
|
@@ -403,19 +406,19 @@ jobs:
|
|
|
403
406
|
runs-on: ubuntu-latest
|
|
404
407
|
|
|
405
408
|
steps:
|
|
406
|
-
- uses: actions/checkout
|
|
409
|
+
- uses: actions/checkout@${a$1.actions.checkout}
|
|
407
410
|
|
|
408
411
|
- name: Set up Go
|
|
409
|
-
uses: actions/setup-go
|
|
412
|
+
uses: actions/setup-go@${a$1.actions.setupGo}
|
|
410
413
|
with:
|
|
411
414
|
go-version: "${e.go_version}"
|
|
412
415
|
cache: true
|
|
413
416
|
|
|
414
417
|
- name: golangci-lint
|
|
415
|
-
uses: golangci/golangci-lint-action
|
|
418
|
+
uses: golangci/golangci-lint-action@${a$1.actions.golangciLint}
|
|
416
419
|
with:
|
|
417
|
-
version:
|
|
418
|
-
`}function
|
|
420
|
+
version: ${a$1.go.golangciLint}
|
|
421
|
+
`}function P(e){return `# ${d(e.project_name)}
|
|
419
422
|
|
|
420
423
|
> ${e.description}
|
|
421
424
|
|
|
@@ -530,7 +533,7 @@ ${e.project_name}/
|
|
|
530
533
|
## License
|
|
531
534
|
|
|
532
535
|
${e.app_version} \xB7 ${e.author}
|
|
533
|
-
`}function
|
|
536
|
+
`}function M(){return `package middleware
|
|
534
537
|
|
|
535
538
|
import (
|
|
536
539
|
"crypto/rand"
|
|
@@ -583,7 +586,7 @@ func newID() string {
|
|
|
583
586
|
}
|
|
584
587
|
return hex.EncodeToString(b)
|
|
585
588
|
}
|
|
586
|
-
`}function
|
|
589
|
+
`}function $(e){return `package middleware_test
|
|
587
590
|
|
|
588
591
|
import (
|
|
589
592
|
"net/http"
|
|
@@ -636,7 +639,7 @@ func TestRequestID_IsReused(t *testing.T) {
|
|
|
636
639
|
t.Fatalf("expected X-Request-ID to be reused, got %q", id)
|
|
637
640
|
}
|
|
638
641
|
}
|
|
639
|
-
`}function
|
|
642
|
+
`}function B(){return `// Package apierr provides a consistent JSON error envelope for all API responses.
|
|
640
643
|
//
|
|
641
644
|
// Every error response looks like:
|
|
642
645
|
//
|
|
@@ -700,7 +703,7 @@ func InternalError(c *fiber.Ctx, _ error) error {
|
|
|
700
703
|
func TooManyRequests(c *fiber.Ctx, msg string) error {
|
|
701
704
|
return reply(c, http.StatusTooManyRequests, msg, "TOO_MANY_REQUESTS")
|
|
702
705
|
}
|
|
703
|
-
`}function
|
|
706
|
+
`}function j(e){return `package apierr_test
|
|
704
707
|
|
|
705
708
|
import (
|
|
706
709
|
"encoding/json"
|
|
@@ -832,11 +835,11 @@ func TestTooManyRequests(t *testing.T) {
|
|
|
832
835
|
t.Fatalf("expected TOO_MANY_REQUESTS, got %q", body.Code)
|
|
833
836
|
}
|
|
834
837
|
}
|
|
835
|
-
`}function
|
|
838
|
+
`}function H(e){return `// Package docs provides the swaggo-generated OpenAPI specification.
|
|
836
839
|
//
|
|
837
840
|
// Run \`make docs\` to regenerate after changing handler annotations.
|
|
838
841
|
//
|
|
839
|
-
// @title ${
|
|
842
|
+
// @title ${d(e.project_name)} API
|
|
840
843
|
// @version ${e.app_version}
|
|
841
844
|
// @description ${e.description}
|
|
842
845
|
// @host localhost:${e.port}
|
|
@@ -846,7 +849,7 @@ func TestTooManyRequests(t *testing.T) {
|
|
|
846
849
|
// @contact.name ${e.author}
|
|
847
850
|
// @license.name MIT
|
|
848
851
|
package docs
|
|
849
|
-
`}function
|
|
852
|
+
`}function U(e){return `package handlers
|
|
850
853
|
|
|
851
854
|
import (
|
|
852
855
|
"net/http"
|
|
@@ -888,7 +891,7 @@ func EchoParams(c *fiber.Ctx) error {
|
|
|
888
891
|
RequestID: rid,
|
|
889
892
|
})
|
|
890
893
|
}
|
|
891
|
-
`}function
|
|
894
|
+
`}function V(e){return `package handlers_test
|
|
892
895
|
|
|
893
896
|
import (
|
|
894
897
|
"encoding/json"
|
|
@@ -956,7 +959,7 @@ func TestEchoParams_EmptyName(t *testing.T) {
|
|
|
956
959
|
t.Fatalf("expected code=BAD_REQUEST, got %v", body["code"])
|
|
957
960
|
}
|
|
958
961
|
}
|
|
959
|
-
`}function
|
|
962
|
+
`}function J(e){return `package config_test
|
|
960
963
|
|
|
961
964
|
import (
|
|
962
965
|
"log/slog"
|
|
@@ -1024,7 +1027,7 @@ func TestLoad_Defaults(t *testing.T) {
|
|
|
1024
1027
|
t.Errorf("expected default LogLevel=debug (development env), got %q", cfg.LogLevel)
|
|
1025
1028
|
}
|
|
1026
1029
|
}
|
|
1027
|
-
`}function
|
|
1030
|
+
`}function W(){return `package middleware
|
|
1028
1031
|
|
|
1029
1032
|
import (
|
|
1030
1033
|
"os"
|
|
@@ -1052,7 +1055,7 @@ func CORS() fiber.Handler {
|
|
|
1052
1055
|
MaxAge: 600,
|
|
1053
1056
|
})
|
|
1054
1057
|
}
|
|
1055
|
-
`}function
|
|
1058
|
+
`}function K(e){return `package middleware_test
|
|
1056
1059
|
|
|
1057
1060
|
import (
|
|
1058
1061
|
"net/http"
|
|
@@ -1124,7 +1127,7 @@ func TestCORS_Default_Origin(t *testing.T) {
|
|
|
1124
1127
|
t.Fatal("expected CORS header when origins defaulting to *")
|
|
1125
1128
|
}
|
|
1126
1129
|
}
|
|
1127
|
-
`}function
|
|
1130
|
+
`}function X(e){return `package server_test
|
|
1128
1131
|
|
|
1129
1132
|
import (
|
|
1130
1133
|
"encoding/json"
|
|
@@ -1213,7 +1216,7 @@ func TestServer_Docs_Redirect(t *testing.T) {
|
|
|
1213
1216
|
t.Fatalf("expected Location=/docs/index.html, got %q", loc)
|
|
1214
1217
|
}
|
|
1215
1218
|
}
|
|
1216
|
-
`}function
|
|
1219
|
+
`}function Q(e){return `package middleware
|
|
1217
1220
|
|
|
1218
1221
|
import (
|
|
1219
1222
|
"os"
|
|
@@ -1246,7 +1249,7 @@ func RateLimit() fiber.Handler {
|
|
|
1246
1249
|
},
|
|
1247
1250
|
})
|
|
1248
1251
|
}
|
|
1249
|
-
`}function
|
|
1252
|
+
`}function Y(e){return `package middleware_test
|
|
1250
1253
|
|
|
1251
1254
|
import (
|
|
1252
1255
|
"net/http"
|
|
@@ -1322,7 +1325,7 @@ func TestRateLimit_InvalidRPS(t *testing.T) {
|
|
|
1322
1325
|
t.Fatalf("expected 200 with invalid RPS env, got %d", resp.StatusCode)
|
|
1323
1326
|
}
|
|
1324
1327
|
}
|
|
1325
|
-
`}function
|
|
1328
|
+
`}function z(e){return `# Air \u2014 live reload for Go projects
|
|
1326
1329
|
# https://github.com/air-verse/air
|
|
1327
1330
|
root = "."
|
|
1328
1331
|
tmp_dir = "tmp"
|
|
@@ -1346,19 +1349,19 @@ tmp_dir = "tmp"
|
|
|
1346
1349
|
|
|
1347
1350
|
[log]
|
|
1348
1351
|
time = false
|
|
1349
|
-
`}function
|
|
1352
|
+
`}function Z(e){return `version: "2"
|
|
1353
|
+
|
|
1354
|
+
run:
|
|
1350
1355
|
timeout: 5m
|
|
1351
1356
|
|
|
1352
1357
|
linters:
|
|
1358
|
+
default: standard
|
|
1353
1359
|
enable:
|
|
1354
1360
|
- bodyclose
|
|
1355
1361
|
- durationcheck
|
|
1356
1362
|
- errcheck
|
|
1357
1363
|
- errname
|
|
1358
1364
|
- errorlint
|
|
1359
|
-
- gci
|
|
1360
|
-
- goimports
|
|
1361
|
-
- gosimple
|
|
1362
1365
|
- govet
|
|
1363
1366
|
- ineffassign
|
|
1364
1367
|
- misspell
|
|
@@ -1369,29 +1372,37 @@ linters:
|
|
|
1369
1372
|
- unconvert
|
|
1370
1373
|
- unused
|
|
1371
1374
|
- wrapcheck
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1375
|
+
settings:
|
|
1376
|
+
govet:
|
|
1377
|
+
enable:
|
|
1378
|
+
- shadow
|
|
1379
|
+
wrapcheck:
|
|
1380
|
+
ignore-package-globs:
|
|
1381
|
+
- "${e}/*"
|
|
1382
|
+
exclusions:
|
|
1383
|
+
rules:
|
|
1384
|
+
- path: _test\\.go
|
|
1385
|
+
linters:
|
|
1386
|
+
- errcheck
|
|
1387
|
+
- wrapcheck
|
|
1388
|
+
|
|
1389
|
+
formatters:
|
|
1390
|
+
enable:
|
|
1391
|
+
- gci
|
|
1392
|
+
- goimports
|
|
1393
|
+
settings:
|
|
1394
|
+
gci:
|
|
1395
|
+
sections:
|
|
1396
|
+
- standard
|
|
1397
|
+
- default
|
|
1398
|
+
- prefix(${e})
|
|
1399
|
+
goimports:
|
|
1400
|
+
local-prefixes:
|
|
1401
|
+
- "${e}"
|
|
1387
1402
|
|
|
1388
1403
|
issues:
|
|
1389
1404
|
max-same-issues: 5
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
- wrapcheck
|
|
1395
|
-
`}function z(){return JSON.stringify({engine:"npm",runtime:"go"},null,2)}function Z(e$1){return e({runtimeLabel:"Go/Fiber",projectName:e$1.project_name,fallbackDevCommand:'exec go run ./cmd/server "$@"'})}function ee(e){return f({runtimeLabel:"Go/Fiber",projectName:e.project_name})}function te(e,i){return JSON.stringify({kit_name:"gofiber.standard",runtime:"go",module_support:false,project_name:e.project_name,module_path:e.module_path,app_version:e.app_version,created_by:"workspai",workspai_version:i,rapidkit_version:i,created_at:new Date().toISOString()},null,2)}async function ce(e,i){let r={project_name:i.project_name,module_path:i.module_path||i.project_name,author:i.author||"Workspai User",description:i.description||`Go/Fiber REST API \u2014 ${i.project_name}`,go_version:i.go_version||a$1,app_version:i.app_version||"0.1.0",port:i.port||"3000",skipGit:i.skipGit??false,skipInstall:i.skipInstall??false},v=h();if(!r.skipInstall)try{await execa("go",["version"],{timeout:3e3});}catch{console.log(o.yellow("\n\u26A0 Go not found in PATH \u2014 project will be scaffolded, but `go mod tidy` requires Go 1.21+")),console.log(o.gray(` Install: https://go.dev/dl/
|
|
1396
|
-
`));}let n=T(`Generating Go/Fiber project: ${r.project_name}\u2026`).start();try{let t=(S,_)=>c(p.join(e,S),_),w=p.join(e,"rapidkit"),R=p.join(e,"rapidkit.cmd");if(await Promise.all([t("cmd/server/main.go",q(r)),t("go.mod",O(r)),t("internal/config/config.go",y(r)),t("internal/server/server.go",C(r)),t("internal/middleware/requestid.go",P()),t("internal/middleware/requestid_test.go",D(r)),t("internal/apierr/apierr.go",M()),t("internal/apierr/apierr_test.go",B(r)),t("internal/handlers/health.go",N()),t("internal/handlers/health_test.go",E(r)),t("internal/handlers/example.go",j(r)),t("internal/handlers/example_test.go",H(r)),t("internal/config/config_test.go",U(r)),t("internal/middleware/cors.go",V()),t("internal/middleware/cors_test.go",J(r)),t("internal/middleware/ratelimit.go",K(r)),t("internal/middleware/ratelimit_test.go",X(r)),t("internal/server/server_test.go",W(r)),t("docs/doc.go",$(r)),t(".air.toml",Q(r)),t("Dockerfile",L()),t("docker-compose.yml",G(r)),t("Makefile",A(r)),t(".golangci.yml",Y(r.module_path)),t(".env.example",I(r)),t(".gitignore",k()),t(".github/workflows/ci.yml",F(r)),t("README.md",x(r)),t(".workspai/project.json",te(r,v)),t(".workspai/context.json",z()),t("rapidkit",Z(r)),t("rapidkit.cmd",ee(r))]),await promises.chmod(w,493),await promises.chmod(R,493),n.succeed(o.green(`Project created at ${e}`)),r.skipInstall)n.info(o.gray("Skipped Go dependency warm-up (--skip-install)."));else try{n.start("Fetching Go dependencies\u2026"),await execa("go",["mod","tidy"],{cwd:e,timeout:12e4}),n.succeed(o.gray("\u2713 go mod tidy completed"));}catch{n.warn(o.yellow("\u26A0 go mod tidy failed \u2014 run manually: go mod tidy"));}if(!r.skipGit)try{await b(e)?console.log(o.gray("\u26A0 git init skipped (target is inside an existing git worktree)")):(await execa("git",["init"],{cwd:e,env:a()}),await execa("git",["add","-A"],{cwd:e,env:a()}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit gofiber.standard)"],{cwd:e,env:a()}),console.log(o.gray("\u2713 git repository initialized")));}catch{console.log(o.gray("\u26A0 git init skipped (git not found or error)"));}console.log(""),console.log(o.bold("\u2705 Go/Fiber project ready!")),console.log(""),console.log(o.cyan("Next steps:")),console.log(o.white(` cd ${r.project_name}`)),console.log(o.white(" make run # start dev server")),console.log(o.white(" make test # run tests")),console.log(""),console.log(o.gray("Server will listen on port "+r.port)),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/live")),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/ready")),console.log(""),console.log(o.yellow("\u2139 RapidKit Core modules are not available for Go projects (module system uses Python/pip).")),console.log("");}catch(t){throw n.fail(o.red("Failed to generate Go/Fiber project")),t}}
|
|
1397
|
-
export{ce as generateGoFiberKit};
|
|
1405
|
+
`}function ee(){return JSON.stringify({engine:"npm",runtime:"go"},null,2)}function te(e){return g({runtimeLabel:"Go/Fiber",projectName:e.project_name,fallbackDevCommand:'exec go run ./cmd/server "$@"'})}function re(e){return h$1({runtimeLabel:"Go/Fiber",projectName:e.project_name})}function oe(e,i){return JSON.stringify({kit_name:"gofiber.standard",runtime:"go",module_support:false,project_name:e.project_name,module_path:e.module_path,app_version:e.app_version,created_by:"workspai",workspai_version:i,rapidkit_version:i,created_at:new Date().toISOString()},null,2)}async function me(e$1,i){let r={project_name:i.project_name,module_path:i.module_path||i.project_name,author:i.author||"Workspai User",description:i.description||`Go/Fiber REST API \u2014 ${i.project_name}`,go_version:i.go_version||c,app_version:i.app_version||"0.1.0",port:i.port||"3000",skipGit:i.skipGit??false,skipInstall:i.skipInstall??false},R=h();if(!r.skipInstall)try{await execa("go",["version"],{timeout:3e3});}catch{console.log(o.yellow(`
|
|
1406
|
+
\u26A0 Go not found in PATH \u2014 project will be scaffolded, but this baseline requires Go ${c}+`)),console.log(o.gray(` Install: https://go.dev/dl/
|
|
1407
|
+
`));}let s=O(`Generating Go/Fiber project: ${r.project_name}\u2026`).start();try{let t=(T,q)=>e(u.join(e$1,T),q),S=u.join(e$1,"rapidkit"),_=u.join(e$1,"rapidkit.cmd");if(await Promise.all([t("cmd/server/main.go",y(r)),t("go.mod",C(r)),t("internal/config/config.go",N(r)),t("internal/server/server.go",E(r)),t("internal/middleware/requestid.go",M()),t("internal/middleware/requestid_test.go",$(r)),t("internal/apierr/apierr.go",B()),t("internal/apierr/apierr_test.go",j(r)),t("internal/handlers/health.go",L()),t("internal/handlers/health_test.go",G(r)),t("internal/handlers/example.go",U(r)),t("internal/handlers/example_test.go",V(r)),t("internal/config/config_test.go",J(r)),t("internal/middleware/cors.go",W()),t("internal/middleware/cors_test.go",K(r)),t("internal/middleware/ratelimit.go",Q(r)),t("internal/middleware/ratelimit_test.go",Y(r)),t("internal/server/server_test.go",X(r)),t("docs/doc.go",H(r)),t(".air.toml",z(r)),t("Dockerfile",A()),t("docker-compose.yml",I(r)),t("Makefile",k(r)),t(".golangci.yml",Z(r.module_path)),t(".env.example",F(r)),t(".gitignore",x()),t(".github/workflows/ci.yml",D(r)),t(".github/dependabot.yml",b("gomod")),t("README.md",P(r)),t(".workspai/project.json",oe(r,R)),t(".workspai/context.json",ee()),t("rapidkit",te(r)),t("rapidkit.cmd",re(r))]),await promises.chmod(S,493),await promises.chmod(_,493),s.succeed(o.green(`Project created at ${e$1}`)),r.skipInstall)s.info(o.gray("Skipped Go dependency warm-up (--skip-install)."));else try{s.start("Fetching Go dependencies\u2026"),await execa("go",["mod","tidy"],{cwd:e$1,timeout:12e4}),s.succeed(o.gray("\u2713 go mod tidy completed"));}catch{s.warn(o.yellow("\u26A0 go mod tidy failed \u2014 run manually: go mod tidy"));}if(!r.skipGit)try{await b$1(e$1)?console.log(o.gray("\u26A0 git init skipped (target is inside an existing git worktree)")):(await execa("git",["init"],{cwd:e$1,env:a()}),await execa("git",["add","-A"],{cwd:e$1,env:a()}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit gofiber.standard)"],{cwd:e$1,env:a()}),console.log(o.gray("\u2713 git repository initialized")));}catch{console.log(o.gray("\u26A0 git init skipped (git not found or error)"));}console.log(""),console.log(o.bold("\u2705 Go/Fiber project ready!")),console.log(""),console.log(o.cyan("Next steps:")),console.log(o.white(` cd ${r.project_name}`)),console.log(o.white(" make run # start dev server")),console.log(o.white(" make test # run tests")),console.log(""),console.log(o.gray("Server will listen on port "+r.port)),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/live")),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/ready")),console.log(""),console.log(o.yellow("\u2139 RapidKit Core modules are not available for Go projects (module system uses Python/pip).")),console.log("");}catch(t){throw s.fail(o.red("Failed to generate Go/Fiber project")),t}}
|
|
1408
|
+
export{me as generateGoFiberKit};
|