@aaac/runtime 0.2.9 → 0.2.10
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/adapters/adk-sdk.d.ts +1 -1
- package/dist/adapters/adk-sdk.js +1 -1
- package/dist/adapters/claude-agent-sdk.d.ts +1 -1
- package/dist/adapters/claude-agent-sdk.js +5 -4
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.js +1 -1
- package/dist/{chunk-D2UXESPT.js → chunk-2SG3TBI3.js} +4 -51
- package/dist/chunk-2SG3TBI3.js.map +1 -0
- package/dist/{chunk-Y7NORFFM.js → chunk-5ZDW4RP7.js} +2 -2
- package/dist/{chunk-GWNXNSGL.js → chunk-BHTHXGA3.js} +12 -9
- package/dist/chunk-BHTHXGA3.js.map +1 -0
- package/dist/{chunk-HR2Q64AO.js → chunk-EA4V5DVD.js} +29 -4
- package/dist/chunk-EA4V5DVD.js.map +1 -0
- package/dist/chunk-EBMQHLXY.js +61 -0
- package/dist/chunk-EBMQHLXY.js.map +1 -0
- package/dist/{chunk-QVMLALPF.js → chunk-GGBNVCPV.js} +5 -3
- package/dist/{chunk-QVMLALPF.js.map → chunk-GGBNVCPV.js.map} +1 -1
- package/dist/{chunk-CJLKKDKN.js → chunk-N2EA3TGS.js} +12 -12
- package/dist/{chunk-CJLKKDKN.js.map → chunk-N2EA3TGS.js.map} +1 -1
- package/dist/{chunk-MG7WSWJU.js → chunk-RTYJNZGT.js} +1 -1
- package/dist/chunk-RTYJNZGT.js.map +1 -0
- package/dist/claude-bundles/full.js +148 -148
- package/dist/claude-bundles/lean.js +5 -5
- package/dist/claude-bundles/prompt.js +2 -2
- package/dist/generator/index.d.ts +2 -2
- package/dist/generator/index.js +2 -2
- package/dist/{guardrail-hooks-B-qe4ebW.d.ts → guardrail-hooks-BgHe8PrP.d.ts} +6 -3
- package/dist/{hooks-lite-DvZu9Jhx.d.ts → hooks-lite-BtOGc2F_.d.ts} +12 -1
- package/dist/{index-C2DHitGz.d.ts → index-BHlvPqIp.d.ts} +3 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.js +108 -42
- package/dist/index.js.map +1 -1
- package/dist/lib/claude-native/hooks-lite.d.ts +2 -2
- package/dist/lib/claude-native/hooks-lite.js +6 -4
- package/dist/lib/claude-native/hooks-prompt.d.ts +3 -3
- package/dist/lib/claude-native/hooks-prompt.js +4 -3
- package/dist/lib/claude-native/index.d.ts +5 -5
- package/dist/lib/claude-native/index.js +11 -9
- package/dist/lib/claude-native/index.js.map +1 -1
- package/dist/{navigation-context-D1NbiipT.d.ts → navigation-context-DJjCkrcj.d.ts} +1 -1
- package/dist/{workspace-user-prompt-submit-aErGPoX4.d.ts → workspace-user-prompt-submit-GZwUKUHi.d.ts} +1 -1
- package/package.json +4 -4
- package/dist/chunk-D2UXESPT.js.map +0 -1
- package/dist/chunk-GWNXNSGL.js.map +0 -1
- package/dist/chunk-HR2Q64AO.js.map +0 -1
- package/dist/chunk-MG7WSWJU.js.map +0 -1
- /package/dist/{chunk-Y7NORFFM.js.map → chunk-5ZDW4RP7.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __aaacCreateRequire } from 'node:module';
|
|
2
2
|
const require = __aaacCreateRequire(import.meta.url);
|
|
3
|
-
import{readFileSync as
|
|
4
|
-
`)}var
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}function
|
|
3
|
+
import{realpathSync as J}from"fs";import{basename as Y,dirname as z,isAbsolute as X,join as Q,relative as Z,resolve as ee,sep as O}from"path";import{readFileSync as te,statSync as re}from"fs";import{resolve as ne}from"path";var oe=/(?:^|\s)(?:--body-file|--notes-file|--file|-F)(?:=|\s+)(?:'([^']*)'|"([^"]*)"|([^\s;|&]+))/g;function ie(e,t){let r=[];for(let n of e.matchAll(oe)){let s=n[1]??n[2]??n[3];if(!s||s==="-")continue;let o=ne(t??process.cwd(),s);try{if(!re(o).isFile())continue;r.push(te(o,"utf8"))}catch{continue}}return r.length===0?e:[e,...r].join(`
|
|
4
|
+
`)}var se=["block","warn","shadow","info","unresolved"],ae="unresolved";function w(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.guardrail_id=="string"&&typeof t.pattern=="string"&&se.includes(t.action)&&typeof t.message=="string"&&(t.file_glob===void 0||typeof t.file_glob=="string")&&(t.exclude_glob===void 0||typeof t.exclude_glob=="string")}function $(e){if(typeof e!="object"||e===null)return!1;let t=e;return Array.isArray(t.commandRules)&&t.commandRules.every(w)&&Array.isArray(t.fileRules)&&t.fileRules.every(w)&&Array.isArray(t.contentRules)&&t.contentRules.every(w)}function ce(e){let t="";for(let r of e)r==="*"?t+="[^/]*":r==="?"?t+="[^/]":".+^$|()[]\\".includes(r)?t+="\\"+r:t+=r;return t}function ue(e){return e.endsWith("/")?`${e}**`:e}function h(e,t){let r=ue(e),n="",s=0;for(;s<r.length;)if(r[s]==="*"&&r[s+1]==="*"&&r[s+2]==="/")n+="(?:.+/)?",s+=3;else if(r[s]==="*"&&r[s+1]==="*")n+=".*",s+=2;else if(r[s]==="*")n+="[^/]*",s+=1;else if(r[s]==="?")n+="[^/]",s+=1;else if(r[s]==="{"){let o=r.indexOf("}",s);if(o!==-1){let c=r.slice(s+1,o).split(",").map(ce);n+="(?:"+c.join("|")+")",s=o+1}else n+="\\{",s+=1}else".+^$|()[]\\".includes(r[s])?(n+="\\"+r[s],s+=1):(n+=r[s],s+=1);return new RegExp("^"+n+"$").test(t)}function le(e){return e==="path"||e==="file"||e==="filename"||e.endsWith("_path")}function fe(e){return e==="content"||e.startsWith("new_")}function U(e,t){if(!e)return"";for(let r of Object.keys(e).sort()){if(!t(r))continue;let n=e[r];if(typeof n=="string"&&n)return n}return""}function de(e){return U(e,le)}var me=new Set(["Read","Glob","Grep","LSP","Task","Agent","Skill","WebFetch","WebSearch","TodoWrite","AskUserQuestion","ToolSearch","EnterPlanMode","ExitPlanMode"]);function D(e){let t=[],r=e;for(;;)try{return Q(J(r),...t)}catch{let n=z(r);if(n===r)return e;t.unshift(Y(r)),r=n}}function pe(e,t){let r=ee(t,e),n=Z(D(t),D(r));return n===""||X(n)||n.split(O)[0]===".."?r:n.split(O).join("/")}function k(e,t,r){if(me.has(e??""))return"";let n=de(t);return n&&pe(n,r??process.cwd())}function v(e){return U(e,fe)}function he(e){return e==="block"||e===ae}function N(e){return e.filter(t=>!t.passed&&he(t.action))}function ge(e){return e.filter(t=>!t.passed&&t.action==="warn")}function H(e){return e.map(t=>`[${t.guardrail_id}] ${t.message}`).join(`
|
|
5
|
+
`)}function I(e){let t=H(e);return{permission:"deny",user_message:t,agent_message:t}}function ye(...e){function t(i){let a=[];if(i.command)for(let u of e)a.push(...u.checkCommand(i.command));if(i.filePath)for(let u of e)a.push(...u.checkFilePath(i.filePath));if(i.filePath&&i.content)for(let u of e)a.push(...u.checkContent(i.filePath,i.content));return a}function r(i){let a=i.command??"";return a?t({command:ie(a,i.cwd)}):[]}function n(i){let a=r(i);if(a.length===0)return{};let u=N(a),f=ge(a);return u.length>0?I(u):f.length>0?{additionalContext:H(f)}:{}}function s(i,a){if(!i)return{};let u=N(t({filePath:i,content:a}));return u.length>0?I(u):{}}function o(i){return s(k(i.tool_name,i.tool_input,i.root),v(i.tool_input))}function c(i){return s(i.file_path??"",i.content??"")}return{beforeShellExecution:n,checkShellCommand:r,preToolUse:o,afterFileEdit:c,runChecks:t}}function j(e){return e.startsWith("(?i)")?new RegExp(e.slice(4),"i"):new RegExp(e)}function A(e,...t){let r=e.commandRules.map(o=>({guardrail_id:o.guardrail_id,pattern:j(o.pattern),action:o.action,message:o.message})),n=e.fileRules,s=e.contentRules.map(o=>({guardrail_id:o.guardrail_id,pattern:j(o.pattern),action:o.action,message:o.message,file_glob:o.file_glob,exclude_glob:o.exclude_glob}));return ye({checkCommand(o){let c=[];for(let i of r){let a=!i.pattern.test(o);c.push({guardrail_id:i.guardrail_id,passed:a,action:i.action,message:a?"":i.message})}return c},checkFilePath(o){let c=[];for(let i of n){if(i.exclude_glob&&h(i.exclude_glob,o))continue;let a=h(i.pattern,o);c.push({guardrail_id:i.guardrail_id,passed:!a,action:i.action,message:a?i.message:""})}return c},checkContent(o,c){let i=[];for(let a of s){if(a.file_glob&&!h(a.file_glob,o)||a.exclude_glob&&h(a.exclude_glob,o))continue;let u=a.pattern.test(c);i.push({guardrail_id:a.guardrail_id,passed:!u,action:a.action,message:u?a.message:""})}return i}},...t)}import{readFile as Se,writeFile as W,rename as Re,stat as Ce,mkdir as xe}from"fs/promises";import{join as Ee}from"path";import{randomBytes as Te}from"crypto";import{stat as De}from"fs/promises";var _e=["SessionStart","UserPromptSubmit","PreToolUse"],P=e=>new Error(`Not a hook payload: ${e.slice(0,100)}`),p=e=>e===void 0||typeof e=="string";function be(e){if(e===void 0)return!0;if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return p(t.file_path)&&p(t.path)&&p(t.command)&&p(t.content)}function we(e){if(!p(e.session_id))return!1;switch(e.hookEventName){case"SessionStart":return e.type===void 0||typeof e.type=="string"&&["new","resume","clear","compact"].includes(e.type);case"UserPromptSubmit":return p(e.prompt);case"PreToolUse":return p(e.tool_name)&&be(e.tool_input);default:return!1}}function ke(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw P(e);let r=t;if(typeof r.hook_event_name=="string"&&r.hookEventName===void 0&&(r.hookEventName=r.hook_event_name),!_e.includes(r.hookEventName)){if(typeof r.hookEventName=="string")return;throw P(e)}if(!we(r))throw P(e);return r}async function ve(){let e=[];for await(let r of process.stdin)e.push(Buffer.isBuffer(r)?r:Buffer.from(r));let t=Buffer.concat(e).toString("utf-8").trim();if(!t)throw new Error("Empty stdin \u2014 no hook input received");return ke(t)}function Ae(e){process.stdout.write(JSON.stringify(e)+`
|
|
6
|
+
`)}function Pe(e,t){return{hookSpecificOutput:{hookEventName:e,additionalContext:t}}}function m(e){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:e}}}function g(){return{}}var y=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Fe(e,t){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=e;return typeof r.writtenAt=="string"&&typeof r.sourceHash=="string"&&(r.sourceFiles===void 0||Array.isArray(r.sourceFiles)&&r.sourceFiles.every(n=>typeof n=="string"))&&t(r.data)}function _(e){let{cacheDir:t}=e;function r(o){return Ee(t,`${o}.json`)}async function n(){await xe(t,{recursive:!0})}return{async read(o,c){let i;try{i=JSON.parse(await Se(r(o),"utf-8"))}catch{return null}return Fe(i,c)?i:null},async write(o,c,i,a){await n();let u={data:c,writtenAt:new Date().toISOString(),sourceHash:i,...a?{sourceFiles:a}:{}},f=JSON.stringify(u,null,2),d=r(o),l=`${d}.${Te(4).toString("hex")}.tmp`;await W(l,f,"utf-8");try{await Re(l,d)}catch{await W(d,f,"utf-8")}},async getFileMtime(o){try{return(await Ce(o)).mtimeMs}catch{return null}}}}function Oe(e){return e.map(String).join(":")}var Ne=".guardrails";function Ie(e){return`${e}${Ne}`}var L="navigation-index";async function je(e){let t=[];for(let r of e)try{let n=await De(r);t.push(n.mtimeMs)}catch{t.push(`missing:${r}`)}return Oe(t)}async function S(e){let t=e.cacheKey??L,r=_({cacheDir:e.cacheDir}),n=await r.read(t,y);if(!n?.sourceFiles||await je(n.sourceFiles)!==n.sourceHash)return;let o=await r.read(Ie(t),$);if(o?.sourceHash===n.sourceHash)return{navigationIndex:n.data,guardrailRules:o.data}}import{isAbsolute as $e}from"path";function R(e,t){if($e(e))return[];let r=t.artifacts??{},n=[];for(let[s,o]of Object.entries(r)){let c=o?.files?.path_patterns;if(Array.isArray(c)){for(let i of c)if(typeof i=="string"&&h(i,e)){n.push({artifactId:s,artifact:o,matchedPattern:i});break}}}return n}function Ue(e){if(e.authority==="generated")return"generated";if(e.manual_edit==="forbidden")return"forbidden"}function C(e){let t=Ue(e.artifact.properties??{});if(t==="generated"){let r=e.artifact.routes?.regenerate,n=r?` Run '${r}' to regenerate.`:" Edit the source artifact and regenerate instead.";return{protected:!0,reason:`File belongs to generated artifact '${e.artifactId}'. Direct editing is not allowed.${n}`}}return t==="forbidden"?{protected:!0,reason:`File belongs to artifact '${e.artifactId}' which has manual_edit: forbidden. This artifact must not be edited directly.`}:{protected:!1,reason:""}}function x(e){let t=e.artifacts??{};return Object.entries(t).map(([r,n])=>({id:r,artifact:n}))}import{resolve as K}from"path";function E(e){return e.tool_input?.command!==void 0}function M(e,t){return k(e.tool_name,e.tool_input,t)}var He={"navigation-index":"the artifact edit guard","guardrail-rules":"the DSL guardrails"};function b(e,t){let r=t?` for ${t}`:"";return`[guard-unavailable] ${He[e]} cannot run: the \`${e}\` cache entry${r} is absent or was built from sources that have since changed, so this operation gets no verdict and is refused rather than judged by superseded rules or silently allowed. Run \`.claude/bin/ensure-navigation-index\` (SessionStart and every prompt submission do this automatically \u2014 if it keeps failing, that failure is the bug).`}function We(e){let t=e.guardrailRules?A(e.guardrailRules):null;return async function(n){let s=M(n,e.projectRoot);if(!t&&(E(n)||s))return m(b("guardrail-rules"));if(t){if(E(n)){let c=t.beforeShellExecution({command:n.tool_input?.command,cwd:n.cwd});if(c.permission==="deny")return m(c.user_message)}let o=t.preToolUse({tool_name:n.tool_name,tool_input:n.tool_input,root:e.projectRoot});if(o.permission==="deny")return m(o.user_message)}if(s){if(!e.navigationIndex)return m(b("navigation-index"));for(let o of R(s,e.navigationIndex)){let c=C(o);if(c.protected)return m(c.reason)}}return g()}}var B=100;function q(e,t){let{navigationIndex:r,maxCandidates:n=B}=t,s=x(r),o=[],c=e.toLowerCase(),i=a=>Le(t.pathPrefix,a);for(let{id:a,artifact:u}of s){let f=u.properties??{},d=u.files?.path_patterns??[];(!e||a.toLowerCase().includes(c))&&o.push({label:a,path:i(d.length>0?String(d[0]):a),kind:"artifact",authority:f.authority,manual_edit:f.manual_edit,score:Ge(a,u,e)});for(let l of d)typeof l=="string"&&(l.includes("*")||l.includes("?")||(!e||l.toLowerCase().includes(c))&&o.push({label:l,path:i(l),kind:"file",artifact:a,authority:f.authority,manual_edit:f.manual_edit,score:Me(l,e)}))}return o.sort((a,u)=>u.score!==a.score?u.score-a.score:a.label.localeCompare(u.label)),o.slice(0,n)}function Le(e,t){if(!e)return t;let r=e.replace(/^\.\//,"").replace(/\/+$/,"");return r?`${r}/${t}`:t}function V(e){return e.map(t=>JSON.stringify(t)).join(`
|
|
7
|
+
`)}function Ge(e,t,r){let n=50,s=t.properties??{};return s.authority==="canonical"&&(n+=20),s.manual_edit==="allowed"&&(n+=10),s.type==="source"&&(n+=15),s.authority==="generated"&&(n-=20),s.manual_edit==="forbidden"&&(n-=10),r&&e.toLowerCase().startsWith(r.toLowerCase())&&(n+=20),n}function Me(e,t){let r=40;return t&&e.toLowerCase().startsWith(t.toLowerCase())&&(r+=30),r+=Math.max(0,20-e.split("/").length*2),r}async function Be(e,t){let r=t.trim(),n=q(r,{navigationIndex:e});return V(n)}async function qe(e,t,r,n=B){let s=r.trim(),o=_({cacheDir:e}),c=[];for(let i of t){let a=await o.read(i.cacheKey,y);a&&c.push(...q(s,{navigationIndex:a.data,pathPrefix:i.memberPath,maxCandidates:Number.POSITIVE_INFINITY}))}return c.sort((i,a)=>a.score!==i.score?a.score-i.score:i.label.localeCompare(a.label)),V(c.slice(0,n))}function G(e,t,r){if(!e)return null;let n=e.startsWith("/")?e:K(r,e),s=null,o=0;for(let c of t){let i=c.root,a=i.endsWith("/")?i:i+"/";n.startsWith(a)&&a.length>o&&(s=c,o=a.length)}return s}function Ve(e,t,r){let n=e.startsWith("/")?e:K(r,e),s=t.endsWith("/")?t:t+"/";return n.startsWith(s)?n.slice(s.length):e}function Ke(e){let t=[];for(let r of e.split(/\s+/)){let n=r.replace(/^['"]+|['"]+$/g,"");n&&(n.includes("/")||n.includes("\\"))&&t.push(n)}return t}function Je(e){let t=new Map;async function r(s){if(t.has(s.name))return t.get(s.name);let o=await S({cacheDir:e.cacheDir,cacheKey:s.cacheKey}),c=o?{...o,hooks:A(o.guardrailRules)}:void 0;return t.set(s.name,c),c}function n(s){for(let o of Ke(s)){let c=G(o,e.members,e.workspaceRoot);if(c)return[c]}return e.members}return async function(o){if(E(o)){let d=o.tool_input?.command??"";for(let l of n(d)){let T=await r(l);if(!T)return m(b("guardrail-rules",`member "${l.name}"`));let F=T.hooks.beforeShellExecution({command:d,cwd:o.cwd});if(F.permission==="deny")return m(F.user_message)}}let c=M(o,e.workspaceRoot);if(!c)return g();let i=G(c,e.members,e.workspaceRoot);if(!i)return g();let a=await r(i);if(!a)return m(b("navigation-index",`member "${i.name}"`));let u=Ve(c,i.root,e.workspaceRoot),f=a.hooks.afterFileEdit({file_path:u,content:v(o.tool_input)});if(f.permission==="deny")return m(f.user_message);for(let d of R(u,a.navigationIndex)){let l=C(d);if(l.protected)return m(l.reason)}return g()}}export{L as DEFAULT_CACHE_KEY,Pe as buildContextResponse,_ as createCacheStore,We as createPreToolUseHandler,Je as createWorkspacePreToolUseHandler,Ae as emitHookOutput,Be as handleFileSuggestion,qe as handleWorkspaceFileSuggestion,y as isCachedRecord,x as listArtifacts,S as readFreshNavigationBuild,ve as readHookInput};
|
|
@@ -4,7 +4,7 @@ function N(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.s
|
|
|
4
4
|
Artifacts: ${i.length}`),i.length>0){let n=[];for(let c of i){let s=a[c]??{},d=s.properties??{},u=[d.type,d.authority].filter(v=>typeof v=="string"&&v.length>0).join(", "),x=typeof d.manual_edit=="string"?`, edit:${d.manual_edit}`:"";n.push(`- ${c}${u||x?` [${u}${x}]`:""}`);let p=s.files?.path_patterns;Array.isArray(p)&&p.length>0&&n.push(` files: ${p.join(", ")}`);let m=s.relations?.derived_artifacts;Array.isArray(m)&&m.length>0&&n.push(` derived \u2192 ${m.join(", ")}`);let l=s.agents?.owners;Array.isArray(l)&&l.length>0&&n.push(` owners: ${l.join(", ")}`)}r.push(n.join(`
|
|
5
5
|
`))}return r.join(`
|
|
6
6
|
|
|
7
|
-
`)}import{DEFAULT_CACHE_KEY as C,buildContextResponse as w,
|
|
7
|
+
`)}import{DEFAULT_CACHE_KEY as C,buildContextResponse as w,readFreshNavigationBuild as $}from"./_aaac-runtime-lean.mjs";import{listArtifacts as E}from"./_aaac-runtime-lean.mjs";import{spawn as P}from"child_process";var S=20;function h(t,e="navigation-index"){if(!t||t.length===0)return;let a=t.slice(0,S).map(r=>` - [${r.severity}] ${r.path}: ${r.message}`),i=t.length-a.length;return i>0&&a.push(` - \u2026 ${i} more`),[`${e} diagnostics (${t.length}):`,...a].join(`
|
|
8
8
|
`)}var U=3e4;function _(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.path=="string"&&typeof e.message=="string"&&typeof e.severity=="string"}function I(t){return t.diagnostics===void 0||Array.isArray(t.diagnostics)&&t.diagnostics.every(_)}function D(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.member=="string"&&typeof e.status=="string"&&I(e)}function M(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.component!="string"?!1:e.results!==void 0?Array.isArray(e.results)&&e.results.every(D):typeof e.status=="string"&&Array.isArray(e.sources)&&e.sources.every(a=>typeof a=="string")&&I(e)}async function y(t){return new Promise((e,a)=>{let i=P(process.execPath,[t],{stdio:["ignore","pipe","pipe"],timeout:U}),r="",o="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",n=>r+=n),i.stderr.on("data",n=>o+=n),i.on("error",n=>a(n)),i.on("close",n=>{if(n!==0){a(new Error(`ensure-navigation-index exited ${n}: ${o.trim()}`));return}let c;try{c=JSON.parse(r.trim())}catch{}e(M(c)?c:void 0)})})}function A(t){return new Error(`navigation-index cache \`${t}\` is still unreadable after ensure-navigation-index reported success \u2014 the rebuild did not write it, or wrote it against a different source list. Run \`.claude/bin/ensure-navigation-index\` directly to see why.`)}function k(t){return async function(a){let i=a.prompt??"",r=async()=>(await $({cacheDir:t.cacheDir}))?.navigationIndex,o=await r(),n;if(!o){let d=await y(t.ensureBin);d&&"diagnostics"in d&&(n=h(d.diagnostics)),o=await r()}if(!o)throw A(C);let c=[f(o),"","> Use `analyzer.getContextMap` with candidate paths/artifacts from the index","> when you need structured dependency and read-target guidance."],s=b(i,o);return s&&c.push(s),n&&c.push("",n),w("UserPromptSubmit",c.join(`
|
|
9
9
|
`))}}function b(t,e,a="## Candidate Artifacts (from prompt keywords)"){let i=B(t,e);if(i.length===0)return;let r=i.map(o=>{let n=o.artifact.properties??{},c=[n.type,n.authority,n.manual_edit?`edit:${n.manual_edit}`:""].filter(Boolean).join(", ");return`- ${o.artifactId} [${c}]`});return`${a}
|
|
10
10
|
${r.join(`
|
|
@@ -14,4 +14,4 @@ ${a}`+(r?`
|
|
|
14
14
|
${r}`:"")}async function g(t,e){return Promise.all(e.map(async a=>({member:a,navigationIndex:(await $({cacheDir:t,cacheKey:a.cacheKey}))?.navigationIndex})))}function H(t){return async function(a){let i=a.prompt??"",r=await g(t.cacheDir,t.members),o=new Map;if(r.some(s=>!s.navigationIndex)){let s=await y(t.ensureBin);if(s&&"results"in s)for(let d of s.results)d.diagnostics&&o.set(d.member,d.diagnostics);r=await g(t.cacheDir,t.members)}let n=[];for(let s of r){if(!s.navigationIndex)throw A(s.member.cacheKey);n.push(j({member:s.member,result:{navigationIndex:s.navigationIndex,fromCache:!0,...o.has(s.member.name)?{diagnostics:o.get(s.member.name)}:{}}}));let d=b(i,s.navigationIndex,`#### Candidate Artifacts in ${s.member.name} (from prompt keywords)`);d&&n.push(d)}if(n.length===0)return{};let c=[n.join(`
|
|
15
15
|
|
|
16
16
|
`),"","> Use `analyzer.getContextMap` with candidate paths/artifacts from a member's index","> when you need structured dependency and read-target guidance."].join(`
|
|
17
|
-
`);return w("UserPromptSubmit",c)}}import{emitHookOutput as
|
|
17
|
+
`);return w("UserPromptSubmit",c)}}import{emitHookOutput as J,readHookInput as X}from"./_aaac-runtime-lean.mjs";import"./_aaac-runtime-lean.mjs";import"./_aaac-runtime-lean.mjs";import"./_aaac-runtime-lean.mjs";export{k as createUserPromptSubmitHandler,H as createWorkspaceUserPromptSubmitHandler,J as emitHookOutput,N as isNavigationIndex,g as readFreshMemberIndices,X as readHookInput,b as renderCandidateArtifacts,j as renderMemberSection,h as renderNavigationDiagnostics,f as renderNavigationIndexPrompt,y as runEnsureNavigationIndexBin};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as GuardrailCheckEntry, G as GuardrailContext, a as GuardrailDiagnostic, d as ProjectConfig, e as ProjectConfigSchema, R as ResolvedConfig, f as buildGuardrailContext, l as loadProjectConfig, p as parseProjectManifest, r as readProjectManifest } from '../index-
|
|
1
|
+
export { c as GuardrailCheckEntry, G as GuardrailContext, a as GuardrailDiagnostic, d as ProjectConfig, e as ProjectConfigSchema, R as ResolvedConfig, f as buildGuardrailContext, l as loadProjectConfig, p as parseProjectManifest, r as readProjectManifest } from '../index-BHlvPqIp.js';
|
|
2
2
|
import 'zod';
|
|
3
|
-
import '../guardrail-hooks-
|
|
3
|
+
import '../guardrail-hooks-BgHe8PrP.js';
|
package/dist/generator/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
loadProjectConfig,
|
|
5
5
|
parseProjectManifest,
|
|
6
6
|
readProjectManifest
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-5ZDW4RP7.js";
|
|
8
|
+
import "../chunk-EA4V5DVD.js";
|
|
9
9
|
import "../chunk-BJ7B4R26.js";
|
|
10
10
|
export {
|
|
11
11
|
ProjectConfigSchema,
|
|
@@ -153,13 +153,16 @@ interface GuardrailHooks {
|
|
|
153
153
|
*/
|
|
154
154
|
checkShellCommand: (input: ShellCommandInput) => GuardrailCheckResult[];
|
|
155
155
|
/**
|
|
156
|
-
* A TOOL INPUT, verbatim: `
|
|
157
|
-
* `
|
|
158
|
-
*
|
|
156
|
+
* A TOOL INPUT, verbatim: `toolWriteTarget` reads the file out of it, relative
|
|
157
|
+
* to `root` — the directory the rules' patterns are written against, the
|
|
158
|
+
* working directory when absent — and `toolPendingContent` the text about to
|
|
159
|
+
* go in. The single-component Claude Code PreToolUse route, `guard evaluate`
|
|
160
|
+
* and the Claude SDK adapter.
|
|
159
161
|
*/
|
|
160
162
|
preToolUse: (input: {
|
|
161
163
|
tool_name?: string;
|
|
162
164
|
tool_input?: Record<string, unknown>;
|
|
165
|
+
root?: string;
|
|
163
166
|
}) => HookResponse;
|
|
164
167
|
/**
|
|
165
168
|
* A file write whose path and content the caller has ALREADY extracted —
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as PreToolUseInput, H as HookOutput } from './hook-protocol-BH86kCQB.js';
|
|
2
|
-
import { a as GuardrailRuleData } from './guardrail-hooks-
|
|
2
|
+
import { a as GuardrailRuleData } from './guardrail-hooks-BgHe8PrP.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Cache Store — read/write `.claude/cache/` directory.
|
|
@@ -176,6 +176,11 @@ interface ArtifactMatch {
|
|
|
176
176
|
/**
|
|
177
177
|
* Resolve a file path to its artifact(s) in the navigation index.
|
|
178
178
|
* Returns all matching artifacts (a file may belong to multiple artifacts).
|
|
179
|
+
*
|
|
180
|
+
* `filePath` is relative to the project root, the space `path_patterns` are
|
|
181
|
+
* written in (`toolWriteTarget` reads a call's target that way). An absolute
|
|
182
|
+
* path is one outside that root and belongs to no artifact, even where a
|
|
183
|
+
* `**`-prefixed pattern would match its text.
|
|
179
184
|
*/
|
|
180
185
|
declare function resolvePathToArtifacts(filePath: string, navigationIndex: Record<string, unknown>): ArtifactMatch[];
|
|
181
186
|
/**
|
|
@@ -230,6 +235,12 @@ interface PreToolUseHandlerConfig {
|
|
|
230
235
|
* has no rules to consult, never that there are none.
|
|
231
236
|
*/
|
|
232
237
|
guardrailRules?: GuardrailRuleData;
|
|
238
|
+
/**
|
|
239
|
+
* The project root — the directory `path_patterns` and the file guardrails
|
|
240
|
+
* are written against, and so the one a call's target is read relative to
|
|
241
|
+
* (`toolWriteTarget`). The working directory when absent.
|
|
242
|
+
*/
|
|
243
|
+
projectRoot?: string;
|
|
233
244
|
}
|
|
234
245
|
/**
|
|
235
246
|
* Create a PreToolUse hook handler.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { d as GuardrailAction } from './guardrail-hooks-
|
|
2
|
+
import { d as GuardrailAction } from './guardrail-hooks-BgHe8PrP.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Generator configuration — loads and validates the project manifest
|
|
@@ -112,6 +112,8 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
112
112
|
agents: z.ZodOptional<z.ZodBoolean>;
|
|
113
113
|
harness: z.ZodOptional<z.ZodBoolean>;
|
|
114
114
|
}, z.core.$strict>>;
|
|
115
|
+
sync_command: z.ZodOptional<z.ZodString>;
|
|
116
|
+
check_command: z.ZodOptional<z.ZodString>;
|
|
115
117
|
}, z.core.$strict>>;
|
|
116
118
|
}, z.core.$strict>>;
|
|
117
119
|
active_guardrail_policy: z.ZodOptional<z.ZodString>;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ export { j as AdapterError, k as AdapterErrorKind, A as AdapterSendOptions, a as
|
|
|
3
3
|
import { ProjectModelMapping, ModelClass, ComponentIR, OperationIR } from '@aaac/contracts';
|
|
4
4
|
export { ModelClass } from '@aaac/contracts';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { b as GuardrailCheckFunctions, a as GuardrailRuleData, G as GuardrailHooks, H as HookResponse, c as GuardrailCheckResult } from './guardrail-hooks-
|
|
7
|
-
export { d as GuardrailAction, e as GuardrailRule, f as HookContext, U as UNRESOLVED_GUARDRAIL_ACTION, g as createGuardrailHooks, h as createGuardrailHooksFromRules, i as getBlockingViolations, j as getWarnings, k as hasBlockingViolation } from './guardrail-hooks-
|
|
8
|
-
import { G as GuardrailContext, P as ProgressLogConfig, R as ResolvedConfig, a as GuardrailDiagnostic } from './index-
|
|
9
|
-
export { b as PROJECT_CONFIG_FILENAME } from './index-
|
|
6
|
+
import { b as GuardrailCheckFunctions, a as GuardrailRuleData, G as GuardrailHooks, H as HookResponse, c as GuardrailCheckResult } from './guardrail-hooks-BgHe8PrP.js';
|
|
7
|
+
export { d as GuardrailAction, e as GuardrailRule, f as HookContext, U as UNRESOLVED_GUARDRAIL_ACTION, g as createGuardrailHooks, h as createGuardrailHooksFromRules, i as getBlockingViolations, j as getWarnings, k as hasBlockingViolation } from './guardrail-hooks-BgHe8PrP.js';
|
|
8
|
+
import { G as GuardrailContext, P as ProgressLogConfig, R as ResolvedConfig, a as GuardrailDiagnostic } from './index-BHlvPqIp.js';
|
|
9
|
+
export { b as PROJECT_CONFIG_FILENAME } from './index-BHlvPqIp.js';
|
|
10
10
|
import { OtelEmitter } from '@aaac/observability';
|
|
11
11
|
export { ExecutionEnvelope } from '@aaac/observability';
|
|
12
|
-
export { a as NavigationContext, N as NavigationContextOptions, b as buildNavigationContext } from './navigation-context-
|
|
12
|
+
export { a as NavigationContext, N as NavigationContextOptions, b as buildNavigationContext } from './navigation-context-DJjCkrcj.js';
|
|
13
13
|
export { i as isNavigationIndex, r as renderNavigationIndexPrompt } from './navigation-index-prompt-CbrS5laO.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -1460,6 +1460,12 @@ interface EvaluateGuardrailOptions {
|
|
|
1460
1460
|
bindingPaths: string[];
|
|
1461
1461
|
/** Active guardrail policy name (from project.yaml active_guardrail_policy). */
|
|
1462
1462
|
activeGuardrailPolicy?: string;
|
|
1463
|
+
/**
|
|
1464
|
+
* The project root — the directory the file guardrails' patterns are written
|
|
1465
|
+
* against, and so the one a tool call's target is read relative to. The
|
|
1466
|
+
* working directory when absent.
|
|
1467
|
+
*/
|
|
1468
|
+
projectRoot?: string;
|
|
1463
1469
|
}
|
|
1464
1470
|
interface EvaluateGuardrailResult {
|
|
1465
1471
|
/** HookResponse to write to stdout. */
|
|
@@ -1558,6 +1564,8 @@ declare const ClaudeConfigSchema: z.ZodObject<{
|
|
|
1558
1564
|
harness: z.ZodDefault<z.ZodBoolean>;
|
|
1559
1565
|
}, z.core.$strip>>;
|
|
1560
1566
|
guard_command: z.ZodOptional<z.ZodString>;
|
|
1567
|
+
sync_command: z.ZodOptional<z.ZodString>;
|
|
1568
|
+
check_command: z.ZodOptional<z.ZodString>;
|
|
1561
1569
|
component_id: z.ZodOptional<z.ZodString>;
|
|
1562
1570
|
}, z.core.$strip>;
|
|
1563
1571
|
type ClaudeConfig = z.infer<typeof ClaudeConfigSchema>;
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
resolveHandoffSchemas,
|
|
16
16
|
resolveNavigationDsl,
|
|
17
17
|
resolveNavigationSources
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-N2EA3TGS.js";
|
|
19
19
|
import {
|
|
20
20
|
jsonSchemaToZod
|
|
21
21
|
} from "./chunk-ET6TGQRT.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
AdapterError,
|
|
24
24
|
adapterErrorKind,
|
|
25
25
|
toolGrantForAgent
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RTYJNZGT.js";
|
|
27
27
|
import {
|
|
28
28
|
OBSERVABILITY_ENV_VARS,
|
|
29
29
|
buildObservabilityEnv,
|
|
@@ -52,11 +52,14 @@ import {
|
|
|
52
52
|
loadProjectConfig,
|
|
53
53
|
loadWorkspaceMembers,
|
|
54
54
|
readProjectManifest
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-5ZDW4RP7.js";
|
|
56
56
|
import {
|
|
57
57
|
isNavigationIndex,
|
|
58
58
|
renderNavigationIndexPrompt
|
|
59
59
|
} from "./chunk-3CLWG72V.js";
|
|
60
|
+
import {
|
|
61
|
+
editProtection
|
|
62
|
+
} from "./chunk-EBMQHLXY.js";
|
|
60
63
|
import {
|
|
61
64
|
UNRESOLVED_GUARDRAIL_ACTION,
|
|
62
65
|
createGuardrailHooks,
|
|
@@ -64,8 +67,9 @@ import {
|
|
|
64
67
|
getBlockingViolations,
|
|
65
68
|
getWarnings,
|
|
66
69
|
hasBlockingViolation,
|
|
67
|
-
toolTargetPath
|
|
68
|
-
|
|
70
|
+
toolTargetPath,
|
|
71
|
+
toolWriteTarget
|
|
72
|
+
} from "./chunk-EA4V5DVD.js";
|
|
69
73
|
import {
|
|
70
74
|
__commonJS,
|
|
71
75
|
__require,
|
|
@@ -9276,8 +9280,12 @@ async function evaluateGuardrail(opts) {
|
|
|
9276
9280
|
response = hooks.beforeShellExecution(shell);
|
|
9277
9281
|
checks = hooks.checkShellCommand(shell);
|
|
9278
9282
|
} else if (toolName !== void 0 || toolInput !== void 0) {
|
|
9279
|
-
response = hooks.preToolUse({
|
|
9280
|
-
|
|
9283
|
+
response = hooks.preToolUse({
|
|
9284
|
+
tool_name: toolName,
|
|
9285
|
+
tool_input: toolInput,
|
|
9286
|
+
root: opts.projectRoot
|
|
9287
|
+
});
|
|
9288
|
+
const checkFilePath = toolWriteTarget(toolName, toolInput, opts.projectRoot);
|
|
9281
9289
|
if (checkFilePath) {
|
|
9282
9290
|
checks = hooks.runChecks({ filePath: checkFilePath });
|
|
9283
9291
|
}
|
|
@@ -9437,27 +9445,56 @@ var ClaudeConfigSchema = z3.object({
|
|
|
9437
9445
|
* Reserved for future hook integration; validated for config parity.
|
|
9438
9446
|
*/
|
|
9439
9447
|
guard_command: z3.string().optional(),
|
|
9448
|
+
/**
|
|
9449
|
+
* The command that runs `syncClaude` for this project (e.g.
|
|
9450
|
+
* "npx dev-team claude sync"). The CLAUDE.md block and the banner on every
|
|
9451
|
+
* generated subagent and workflow file name it as the way to regenerate
|
|
9452
|
+
* them. Without it they name `syncClaude` itself: the component id is not a
|
|
9453
|
+
* command, so nothing else here says which executable runs the sync. The
|
|
9454
|
+
* project manifest's `bindings.claude.sync_command` wins over it
|
|
9455
|
+
* (`applyProjectBinding`).
|
|
9456
|
+
*/
|
|
9457
|
+
sync_command: z3.string().optional(),
|
|
9458
|
+
/**
|
|
9459
|
+
* The command that runs `checkClaude` for this project (e.g.
|
|
9460
|
+
* "npx dev-team claude check"), named in the CLAUDE.md block as the drift
|
|
9461
|
+
* check. Without it the block names `checkClaude` itself. The project
|
|
9462
|
+
* manifest's `bindings.claude.check_command` wins over it.
|
|
9463
|
+
*/
|
|
9464
|
+
check_command: z3.string().optional(),
|
|
9440
9465
|
/** Override component id; defaults to `dsl.system.id`. */
|
|
9441
9466
|
component_id: z3.string().optional()
|
|
9442
9467
|
}).strip();
|
|
9443
9468
|
function parseClaudeConfig(raw) {
|
|
9444
9469
|
return ClaudeConfigSchema.parse(raw ?? {});
|
|
9445
9470
|
}
|
|
9446
|
-
function
|
|
9471
|
+
function harnessCommandsFor(config) {
|
|
9472
|
+
return { sync: config.sync_command, check: config.check_command };
|
|
9473
|
+
}
|
|
9474
|
+
function applyProjectBinding(config, project) {
|
|
9447
9475
|
if (!project) return config;
|
|
9448
9476
|
const emit = { ...config.emit };
|
|
9449
|
-
if (project.workflows !== void 0) emit.workflows = project.workflows;
|
|
9450
|
-
if (project.agents !== void 0) emit.agents = project.agents;
|
|
9451
|
-
if (project.harness !== void 0) emit.harness = project.harness;
|
|
9452
|
-
if (project.commands !== void 0) {
|
|
9453
|
-
emit.commands = project.commands ? config.emit.commands ?? {} : void 0;
|
|
9477
|
+
if (project.emit?.workflows !== void 0) emit.workflows = project.emit.workflows;
|
|
9478
|
+
if (project.emit?.agents !== void 0) emit.agents = project.emit.agents;
|
|
9479
|
+
if (project.emit?.harness !== void 0) emit.harness = project.emit.harness;
|
|
9480
|
+
if (project.emit?.commands !== void 0) {
|
|
9481
|
+
emit.commands = project.emit.commands ? config.emit.commands ?? {} : void 0;
|
|
9454
9482
|
}
|
|
9455
|
-
return {
|
|
9483
|
+
return {
|
|
9484
|
+
...config,
|
|
9485
|
+
emit,
|
|
9486
|
+
sync_command: project.sync_command ?? config.sync_command,
|
|
9487
|
+
check_command: project.check_command ?? config.check_command
|
|
9488
|
+
};
|
|
9456
9489
|
}
|
|
9457
9490
|
|
|
9458
9491
|
// src/lib/claude-materialize/workflow-render.ts
|
|
9459
9492
|
import { resolveSchemaRefs } from "agent-contracts";
|
|
9460
|
-
import {
|
|
9493
|
+
import {
|
|
9494
|
+
claudeSyncReference,
|
|
9495
|
+
pathSegmentForId as pathSegmentForId4,
|
|
9496
|
+
readDslExtension
|
|
9497
|
+
} from "@aaac/contracts";
|
|
9461
9498
|
|
|
9462
9499
|
// src/lib/claude-materialize/dsl-sources.ts
|
|
9463
9500
|
import { existsSync as existsSync4 } from "fs";
|
|
@@ -9485,7 +9522,7 @@ async function resolveDslSources(root, embeddedDsl, config) {
|
|
|
9485
9522
|
embeddedDsl,
|
|
9486
9523
|
dslPath: config.config_path
|
|
9487
9524
|
});
|
|
9488
|
-
const dsl = await resolveNavigationDsl(navigationOptions);
|
|
9525
|
+
const { dsl } = await resolveNavigationDsl(navigationOptions);
|
|
9489
9526
|
return member === void 0 ? { dsl } : { member, dsl };
|
|
9490
9527
|
})
|
|
9491
9528
|
);
|
|
@@ -9510,7 +9547,9 @@ function mergeSourceFiles(rendered, conflict) {
|
|
|
9510
9547
|
}
|
|
9511
9548
|
|
|
9512
9549
|
// src/lib/claude-materialize/workflow-render.ts
|
|
9513
|
-
|
|
9550
|
+
function generatedMarker(commands) {
|
|
9551
|
+
return `// Auto-generated by @aaac/runtime claude-materialize (#235). Do not edit; regenerate with ${claudeSyncReference(commands)} instead.`;
|
|
9552
|
+
}
|
|
9514
9553
|
var CLAUDE_CODE_ADAPTER = "claude";
|
|
9515
9554
|
var WorkflowCodegenError = class extends Error {
|
|
9516
9555
|
constructor(message) {
|
|
@@ -9989,7 +10028,7 @@ function assertInScope(step) {
|
|
|
9989
10028
|
throw new WorkflowCodegenError(`Unknown workflow step type "${step.type}"`);
|
|
9990
10029
|
}
|
|
9991
10030
|
}
|
|
9992
|
-
function renderWorkflowScript(id, wf, dsl, modelMapping) {
|
|
10031
|
+
function renderWorkflowScript(id, wf, dsl, modelMapping, commands) {
|
|
9993
10032
|
const reg = buildRegistries(dsl, modelMapping);
|
|
9994
10033
|
const steps = wf.steps ?? [];
|
|
9995
10034
|
for (const step of steps) assertInScope(step);
|
|
@@ -10066,14 +10105,14 @@ function renderWorkflowScript(id, wf, dsl, modelMapping) {
|
|
|
10066
10105
|
body.push(" return { completed: true, workflow: " + jsString(id) + " }");
|
|
10067
10106
|
const metaLiteral = jsLiteral(meta, 0);
|
|
10068
10107
|
const topLevelBody = body.map((line) => line.startsWith(" ") ? line.slice(2) : line).join("\n");
|
|
10069
|
-
return `${
|
|
10108
|
+
return `${generatedMarker(commands)}
|
|
10070
10109
|
|
|
10071
10110
|
export const meta = ${metaLiteral}
|
|
10072
10111
|
|
|
10073
10112
|
${topLevelBody}
|
|
10074
10113
|
`;
|
|
10075
10114
|
}
|
|
10076
|
-
function renderWorkflowFiles(sources, outputDir, modelMapping) {
|
|
10115
|
+
function renderWorkflowFiles(sources, outputDir, modelMapping, commands) {
|
|
10077
10116
|
const dir = workflowsDirFor(outputDir);
|
|
10078
10117
|
return mergeSourceFiles(
|
|
10079
10118
|
sources.map((source) => ({
|
|
@@ -10082,7 +10121,7 @@ function renderWorkflowFiles(sources, outputDir, modelMapping) {
|
|
|
10082
10121
|
source.dsl.workflow ?? {}
|
|
10083
10122
|
).map(([id, wf]) => ({
|
|
10084
10123
|
path: `${dir}/${pathSegmentForId4("workflow id", id)}${WORKFLOW_FILE_EXT}`,
|
|
10085
|
-
content: renderWorkflowScript(id, wf, source.dsl, modelMapping)
|
|
10124
|
+
content: renderWorkflowScript(id, wf, source.dsl, modelMapping, commands)
|
|
10086
10125
|
}))
|
|
10087
10126
|
})),
|
|
10088
10127
|
(message) => new WorkflowCodegenError(message)
|
|
@@ -10178,7 +10217,7 @@ function renderCommandFiles(sources, outputTemplate, templateSource) {
|
|
|
10178
10217
|
}
|
|
10179
10218
|
|
|
10180
10219
|
// src/lib/claude-materialize/agent-render.ts
|
|
10181
|
-
import { pathSegmentForId as pathSegmentForId6 } from "@aaac/contracts";
|
|
10220
|
+
import { claudeSyncReference as claudeSyncReference2, pathSegmentForId as pathSegmentForId6 } from "@aaac/contracts";
|
|
10182
10221
|
var AgentCodegenError = class extends Error {
|
|
10183
10222
|
constructor(message) {
|
|
10184
10223
|
super(message);
|
|
@@ -10188,7 +10227,9 @@ var AgentCodegenError = class extends Error {
|
|
|
10188
10227
|
var AGENTS_SUBDIR = "agents";
|
|
10189
10228
|
var AGENT_FILE_EXT = ".md";
|
|
10190
10229
|
var AGENT_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
10191
|
-
|
|
10230
|
+
function generatedMarker2(commands) {
|
|
10231
|
+
return `<!-- Auto-generated from the agent-contracts DSL. Do not edit; regenerate with ${claudeSyncReference2(commands)}. -->`;
|
|
10232
|
+
}
|
|
10192
10233
|
function agentsDirFor(outputDir) {
|
|
10193
10234
|
return `${outputDir.replace(/\/+$/, "")}/${AGENTS_SUBDIR}`;
|
|
10194
10235
|
}
|
|
@@ -10233,7 +10274,7 @@ function agentDescription(agent) {
|
|
|
10233
10274
|
function renderAgentBody(agent) {
|
|
10234
10275
|
return [renderAgentSystemPrompt(agent), ...permissionSections(agent)].join("\n\n").replace(/\s+$/, "");
|
|
10235
10276
|
}
|
|
10236
|
-
function renderAgentFile(name, agent) {
|
|
10277
|
+
function renderAgentFile(name, agent, commands) {
|
|
10237
10278
|
const frontmatter = renderFrontmatter([
|
|
10238
10279
|
// `name` is validated against AGENT_NAME_PATTERN, so it is always a plain
|
|
10239
10280
|
// YAML scalar and needs no quoting. `description` is arbitrary DSL prose.
|
|
@@ -10242,7 +10283,7 @@ function renderAgentFile(name, agent) {
|
|
|
10242
10283
|
// The Claude Code tool grant follows the contract, never the DSL tool ids.
|
|
10243
10284
|
["tools", toolGrantForAgent(agent).join(", ")]
|
|
10244
10285
|
]);
|
|
10245
|
-
const body = [
|
|
10286
|
+
const body = [generatedMarker2(commands), renderAgentBody(agent)].join("\n\n");
|
|
10246
10287
|
return `${frontmatter}
|
|
10247
10288
|
${body}
|
|
10248
10289
|
`;
|
|
@@ -10270,7 +10311,7 @@ function mergeAgents(sources, dir) {
|
|
|
10270
10311
|
}
|
|
10271
10312
|
return merged;
|
|
10272
10313
|
}
|
|
10273
|
-
function renderAgentFiles(sources, outputDir) {
|
|
10314
|
+
function renderAgentFiles(sources, outputDir, commands) {
|
|
10274
10315
|
const dir = agentsDirFor(outputDir);
|
|
10275
10316
|
const files = [];
|
|
10276
10317
|
for (const [name, { agent, origin }] of mergeAgents(sources, dir)) {
|
|
@@ -10282,7 +10323,7 @@ function renderAgentFiles(sources, outputDir) {
|
|
|
10282
10323
|
}
|
|
10283
10324
|
files.push({
|
|
10284
10325
|
path: `${dir}/${pathSegmentForId6("agent id", name)}${AGENT_FILE_EXT}`,
|
|
10285
|
-
content: renderAgentFile(name, agent)
|
|
10326
|
+
content: renderAgentFile(name, agent, commands)
|
|
10286
10327
|
});
|
|
10287
10328
|
}
|
|
10288
10329
|
return files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
@@ -10306,6 +10347,7 @@ import {
|
|
|
10306
10347
|
|
|
10307
10348
|
// src/lib/claude-materialize/bundle-bins.ts
|
|
10308
10349
|
import {
|
|
10350
|
+
claudeSyncReference as claudeSyncReference3,
|
|
10309
10351
|
isHookBinChunk
|
|
10310
10352
|
} from "@aaac/contracts";
|
|
10311
10353
|
import { createHash } from "crypto";
|
|
@@ -10407,7 +10449,7 @@ function withMarker(bodyWithoutMarker) {
|
|
|
10407
10449
|
const firstNl = bodyWithoutMarker.indexOf("\n");
|
|
10408
10450
|
return bodyWithoutMarker.slice(0, firstNl + 1) + markerFor(bodyWithoutMarker) + "\n" + bodyWithoutMarker.slice(firstNl + 1);
|
|
10409
10451
|
}
|
|
10410
|
-
function assembleHookBin(source, kind) {
|
|
10452
|
+
function assembleHookBin(source, kind, commands) {
|
|
10411
10453
|
const withoutShebang = source.replace(/^#![^\n]*\n/, "");
|
|
10412
10454
|
const match = requireRuntimeImport(withoutShebang);
|
|
10413
10455
|
const binBody = withoutShebang.replace(
|
|
@@ -10417,21 +10459,21 @@ function assembleHookBin(source, kind) {
|
|
|
10417
10459
|
return withMarker(
|
|
10418
10460
|
[
|
|
10419
10461
|
"#!/usr/bin/env node",
|
|
10420
|
-
|
|
10462
|
+
`// Auto-generated by @aaac/runtime. Do not edit \u2014 self-contained bundle; regenerate with ${claudeSyncReference3(commands)}.`,
|
|
10421
10463
|
binBody.trimStart()
|
|
10422
10464
|
].join("\n")
|
|
10423
10465
|
);
|
|
10424
10466
|
}
|
|
10425
|
-
function assembleRuntimeChunk(kind) {
|
|
10467
|
+
function assembleRuntimeChunk(kind, commands) {
|
|
10426
10468
|
return withMarker(
|
|
10427
10469
|
[
|
|
10428
|
-
`// Auto-generated by @aaac/runtime
|
|
10470
|
+
`// Auto-generated by @aaac/runtime. Do not edit \u2014 shared ${kind} runtime chunk; regenerate with ${claudeSyncReference3(commands)}.`,
|
|
10429
10471
|
readPrebuiltBundle(kind).trimEnd(),
|
|
10430
10472
|
""
|
|
10431
10473
|
].join("\n")
|
|
10432
10474
|
);
|
|
10433
10475
|
}
|
|
10434
|
-
function withAssembledHookBins(files) {
|
|
10476
|
+
function withAssembledHookBins(files, commands) {
|
|
10435
10477
|
const out = [];
|
|
10436
10478
|
const needed = /* @__PURE__ */ new Set();
|
|
10437
10479
|
for (const file of files) {
|
|
@@ -10445,13 +10487,13 @@ function withAssembledHookBins(files) {
|
|
|
10445
10487
|
}
|
|
10446
10488
|
const kind = bundleKindFor(file.content);
|
|
10447
10489
|
needed.add(kind);
|
|
10448
|
-
out.push({ ...file, content: assembleHookBin(file.content, kind) });
|
|
10490
|
+
out.push({ ...file, content: assembleHookBin(file.content, kind, commands) });
|
|
10449
10491
|
}
|
|
10450
10492
|
for (const kind of BUNDLE_KINDS) {
|
|
10451
10493
|
if (!needed.has(kind)) continue;
|
|
10452
10494
|
out.push({
|
|
10453
10495
|
path: chunkFileName(kind),
|
|
10454
|
-
content: assembleRuntimeChunk(kind),
|
|
10496
|
+
content: assembleRuntimeChunk(kind, commands),
|
|
10455
10497
|
overwrite: true,
|
|
10456
10498
|
targetDir: HOOK_BIN_DIR
|
|
10457
10499
|
});
|
|
@@ -10617,11 +10659,12 @@ async function readIfExists(path) {
|
|
|
10617
10659
|
if (!existsSync5(path)) return void 0;
|
|
10618
10660
|
return readFile5(path, "utf8");
|
|
10619
10661
|
}
|
|
10620
|
-
async function renderFiles(root, dsl, config, entryAgentPrompt) {
|
|
10662
|
+
async function renderFiles(root, dsl, config, entryAgentPrompt, protectsArtifacts) {
|
|
10621
10663
|
if (!config.emit.harness) return [];
|
|
10622
10664
|
const ir = buildComponentIR(dsl, config);
|
|
10623
10665
|
const members = await workspaceMembersForProject(root);
|
|
10624
10666
|
const workspaceOptions = members.length > 0 ? { members } : void 0;
|
|
10667
|
+
const harnessCommands = harnessCommandsFor(config);
|
|
10625
10668
|
return withAssembledHookBins(
|
|
10626
10669
|
claudeGenerator.generate(ir, {
|
|
10627
10670
|
outputDir: "",
|
|
@@ -10634,8 +10677,12 @@ async function renderFiles(root, dsl, config, entryAgentPrompt) {
|
|
|
10634
10677
|
// subagent file, so the CLAUDE.md block is where its prompt reaches
|
|
10635
10678
|
// Claude (#345). Resolved by the caller from the SAME merge that produced
|
|
10636
10679
|
// the subagent files.
|
|
10637
|
-
entryAgentPrompt
|
|
10638
|
-
|
|
10680
|
+
entryAgentPrompt,
|
|
10681
|
+
harnessCommands,
|
|
10682
|
+
// Whether the block may say the edit guard protects anything.
|
|
10683
|
+
protectsArtifacts
|
|
10684
|
+
}),
|
|
10685
|
+
harnessCommands
|
|
10639
10686
|
);
|
|
10640
10687
|
}
|
|
10641
10688
|
function mergeClaudeMdBlock(existing, block) {
|
|
@@ -10712,7 +10759,7 @@ function checkContent(file, existing) {
|
|
|
10712
10759
|
}
|
|
10713
10760
|
function workflowFiles(sources, config, modelMapping) {
|
|
10714
10761
|
if (!config.emit.workflows) return [];
|
|
10715
|
-
return renderWorkflowFiles(sources, config.output_dir, modelMapping);
|
|
10762
|
+
return renderWorkflowFiles(sources, config.output_dir, modelMapping, harnessCommandsFor(config));
|
|
10716
10763
|
}
|
|
10717
10764
|
function commandOutputTemplate(config) {
|
|
10718
10765
|
const commands = config.emit.commands;
|
|
@@ -10732,12 +10779,19 @@ async function commandFiles(sources, config, root) {
|
|
|
10732
10779
|
}
|
|
10733
10780
|
function agentFiles(sources, config) {
|
|
10734
10781
|
if (!config.emit.agents) return [];
|
|
10735
|
-
return renderAgentFiles(sources, config.output_dir);
|
|
10782
|
+
return renderAgentFiles(sources, config.output_dir, harnessCommandsFor(config));
|
|
10736
10783
|
}
|
|
10737
10784
|
function entryAgentPromptFor(sources, config) {
|
|
10738
10785
|
if (!config.emit.agents) return void 0;
|
|
10739
10786
|
return renderEntryAgentPrompt(sources, config.output_dir);
|
|
10740
10787
|
}
|
|
10788
|
+
function protectsAnyArtifact(sources) {
|
|
10789
|
+
return sources.some(
|
|
10790
|
+
(source) => Object.values(source.dsl.artifacts ?? {}).some(
|
|
10791
|
+
(artifact) => typeof artifact === "object" && artifact !== null && editProtection(artifact) !== void 0
|
|
10792
|
+
)
|
|
10793
|
+
);
|
|
10794
|
+
}
|
|
10741
10795
|
async function isOwnedHookBinFile(_name, absPath2) {
|
|
10742
10796
|
const content = await readIfExists(absPath2).catch(() => void 0);
|
|
10743
10797
|
return content !== void 0 && readBundleMarker(content) !== void 0;
|
|
@@ -10829,7 +10883,7 @@ function effectiveClaudeInputs(root, raw) {
|
|
|
10829
10883
|
if (!existsSync5(manifestPath)) return { config, modelMapping: {} };
|
|
10830
10884
|
const manifest = readProjectManifest(manifestPath);
|
|
10831
10885
|
return {
|
|
10832
|
-
config:
|
|
10886
|
+
config: applyProjectBinding(config, manifest.bindings?.claude),
|
|
10833
10887
|
modelMapping: manifest.model_mapping
|
|
10834
10888
|
};
|
|
10835
10889
|
}
|
|
@@ -10838,7 +10892,13 @@ async function syncClaude(opts) {
|
|
|
10838
10892
|
const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
|
|
10839
10893
|
const result = { files: [] };
|
|
10840
10894
|
const sources = await resolveDslSources(root, opts.dsl, config);
|
|
10841
|
-
const rendered = await renderFiles(
|
|
10895
|
+
const rendered = await renderFiles(
|
|
10896
|
+
root,
|
|
10897
|
+
opts.dsl,
|
|
10898
|
+
config,
|
|
10899
|
+
entryAgentPromptFor(sources, config),
|
|
10900
|
+
protectsAnyArtifact(sources)
|
|
10901
|
+
);
|
|
10842
10902
|
for (const file of rendered) {
|
|
10843
10903
|
const rel = generatedFileRelPath(file);
|
|
10844
10904
|
const abs = absPath(root, file);
|
|
@@ -10903,7 +10963,13 @@ async function checkClaude(opts) {
|
|
|
10903
10963
|
const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
|
|
10904
10964
|
const drift = [];
|
|
10905
10965
|
const sources = await resolveDslSources(root, opts.dsl, config);
|
|
10906
|
-
const rendered = await renderFiles(
|
|
10966
|
+
const rendered = await renderFiles(
|
|
10967
|
+
root,
|
|
10968
|
+
opts.dsl,
|
|
10969
|
+
config,
|
|
10970
|
+
entryAgentPromptFor(sources, config),
|
|
10971
|
+
protectsAnyArtifact(sources)
|
|
10972
|
+
);
|
|
10907
10973
|
for (const file of rendered) {
|
|
10908
10974
|
const rel = generatedFileRelPath(file);
|
|
10909
10975
|
const abs = absPath(root, file);
|