cc-safety-net 2.7.5 → 2.7.7

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.
@@ -1,2 +1,2 @@
1
- import{re,c,S,bt,d,w}from"./index-dm4v8s9a.js";import{Q,Ne,ve,Le}from"./index-a1hayde0.js";import{existsSync as x,lstatSync as H,readFileSync as C}from"node:fs";import{join as P}from"node:path";function b(e,t=(s)=>s){if(!x(e))return{kind:"missing"};try{return{kind:"ok",value:JSON.parse(t(C(e,"utf-8")))}}catch{return{kind:"unreadable"}}}function B(e,t){if(e==="~")return t;if(e.startsWith("~/")||e.startsWith("~\\"))return P(t,e.slice(2));return e}function u(e){try{return H(e)}catch{return}}function We(e,t){let s=u(t);if(!s)return{platform:e,status:"n/a",configPath:t};if(!s.isSymbolicLink()&&s.isDirectory())return;return{platform:e,status:"n/a",configPath:t,errors:[`${t} is a symlink or not a directory; move or remove it before installing`]}}function n(e,t){return typeof e==="object"&&e!==null?e[t]:void 0}import{readdirSync as T}from"node:fs";import{join as k,resolve as E}from"node:path";var h="cc-safety-net";function De(e){let t=e.env.get("DSH_HOME");return k(t?.trim()?E(B(t,e.home)):k(e.home,".dsh"),"profiles")}function D(e){let t=De(e),s=u(t)?.isDirectory()?T(t,{withFileTypes:!0}).filter((o)=>o.isDirectory()&&o.name!=="node_modules").map((o)=>{let r=k(t,o.name,"package.json");return{name:o.name,configPath:r,manifest:b(r)}}):[];return{installed:s.flatMap((o)=>{if(o.manifest.kind!=="ok")return[];let r=o.manifest.value;if(n(n(r,"dependencies"),h)===void 0)return[];let i=n(n(n(r,"dsh"),"profile"),"bundles");return[{name:o.name,configPath:o.configPath,enabled:Array.isArray(i)&&i.includes(h)}]}),unreadable:s.some((o)=>o.manifest.kind==="unreadable")}}function lt(e){return D(e).installed}function Rt(e){let t=D(e.environment),s=t.installed.filter((r)=>r.enabled),a=t.installed.filter((r)=>!r.enabled),o=a.map((r)=>`${h} is installed in the ${r.name} profile but its bundle is disabled`);if(s.length>0)return{platform:"deepseek-harness",status:"configured",method:"dsh bundle",configPaths:s.map((r)=>r.configPath),...o.length>0?{errors:o}:{}};if(a.length>0)return{platform:"deepseek-harness",status:"disabled",method:"dsh bundle",configPaths:a.map((r)=>r.configPath),errors:o};return t.unreadable?{platform:"deepseek-harness",status:"not-inspected"}:{platform:"deepseek-harness",status:"n/a"}}import{randomUUID as v}from"node:crypto";import{resolve as O}from"node:path";var ze=new Map([["bash","posix"],["pwsh","powershell"]]),j={agent:"deepseek-harness",debugLabel:"deepseek-harness tool guard",extract:(e,t,s)=>A(e,t,s),getSessionId:(e)=>e?.agent?.session.header.id,allow:void 0,block:(e)=>re(e),includeEvidenceOnError:(e)=>e.route.kind==="command"};function Tt(e){let t=_();e.tools.guard((a)=>t(a,process.cwd()));let s=new Set;e.on("tools/post-execute",async(a,o,r)=>{let i=await r(),l=I(a,s);if(!l)return i;return{...i,additionalContexts:[l,...i.additionalContexts??[]]}})}function I(e,t){try{let s=e,a=s?.agent?.session.header,o=s?.name,i=s?.arguments?.command;if(!a||typeof o!=="string"||ze.has(o)||S(o)!=="unknown"||typeof i!=="string"||i.trim()==="")return;let l=JSON.stringify([a.id,o]);if(t.has(l))return;let p=c();if(w(p,{cwd:a.cwd??process.cwd()}).policy.commandTools.some((m)=>m.name===o))return;t.add(l);let f=De(p);return Object.freeze({id:v(),role:"user",content:Object.freeze([Object.freeze({type:"text",text:`CC Safety Net did not check the command \`${o}\` just ran. It checks a plugin's shell tool only after the tool is declared. First find out where \`${o}\` runs its commands: check its tool description, and if that doesn't say, read its plugin's source under \`${f}/<profile>/node_modules\`. If it runs them on this machine, declare it with \`npx -y cc-safety-net rule tool add ${o}\`, and add \`--cwd-arg <name>\` if it takes its working directory in an argument other than \`workdir\`, \`cwd\` or \`working_directory\`. If it runs them somewhere else, such as a remote host, or you can't tell, declare it with \`npx -y cc-safety-net rule tool add ${o} --no-cwd-arg\`: its commands are then checked as if they ran in this session's directory. Don't test the declaration by running a destructive command; \`npx -y cc-safety-net rule tool list\` confirms it. Either way, tell the user what you found and what you did.`})]),source:Object.freeze({kind:"cc-safety-net",form:"notice",summary:`${o} commands are not checked`})})}catch{return}}function _(e={}){return Le(j,e)}function A(e,t,s){if(!e||typeof e!=="object")return Ne(null);let a=e,o=a.agent?.session.header.cwd??t,r=bt([o],s),i=a.name;if(typeof i!=="string"||i.trim()==="")return Q(r??null);if(!r)return ve({directory:"session",problem:"unusable",cwd:o},{toolName:i});let l=a.arguments,p=ze.get(i);if(!p)return d(i,l,{kind:S(i)},{configCwd:r,executionCwd:r},null);if(!l||typeof l!=="object"||Array.isArray(l))return Q(r,{toolName:i});let g=l,f=g.command;if(typeof f!=="string"||f.trim()==="")return Q(r,{toolName:i});let m=g.workdir;if(m!==void 0&&(typeof m!=="string"||m.trim()===""))return Q(r,{command:f,toolName:i});let y=m===void 0?r:bt([O(r,m)],s);if(!y)return ve({directory:"requested",problem:"unusable",cwd:m},{command:f,toolName:i});return d(i,l,{kind:"command",shell:p},{configCwd:r,executionCwd:y},f)}
1
+ import{re,c,S,bt,d,w}from"./index-769a735t.js";import{Q,Ne,ve,Le}from"./index-ssmnsasm.js";import{existsSync as x,lstatSync as H,readFileSync as C}from"node:fs";import{join as P}from"node:path";function b(e,t=(s)=>s){if(!x(e))return{kind:"missing"};try{return{kind:"ok",value:JSON.parse(t(C(e,"utf-8")))}}catch{return{kind:"unreadable"}}}function B(e,t){if(e==="~")return t;if(e.startsWith("~/")||e.startsWith("~\\"))return P(t,e.slice(2));return e}function u(e){try{return H(e)}catch{return}}function We(e,t){let s=u(t);if(!s)return{platform:e,status:"n/a",configPath:t};if(!s.isSymbolicLink()&&s.isDirectory())return;return{platform:e,status:"n/a",configPath:t,errors:[`${t} is a symlink or not a directory; move or remove it before installing`]}}function n(e,t){return typeof e==="object"&&e!==null?e[t]:void 0}import{readdirSync as T}from"node:fs";import{join as k,resolve as E}from"node:path";var h="cc-safety-net";function De(e){let t=e.env.get("DSH_HOME");return k(t?.trim()?E(B(t,e.home)):k(e.home,".dsh"),"profiles")}function D(e){let t=De(e),s=u(t)?.isDirectory()?T(t,{withFileTypes:!0}).filter((o)=>o.isDirectory()&&o.name!=="node_modules").map((o)=>{let r=k(t,o.name,"package.json");return{name:o.name,configPath:r,manifest:b(r)}}):[];return{installed:s.flatMap((o)=>{if(o.manifest.kind!=="ok")return[];let r=o.manifest.value;if(n(n(r,"dependencies"),h)===void 0)return[];let i=n(n(n(r,"dsh"),"profile"),"bundles");return[{name:o.name,configPath:o.configPath,enabled:Array.isArray(i)&&i.includes(h)}]}),unreadable:s.some((o)=>o.manifest.kind==="unreadable")}}function lt(e){return D(e).installed}function Rt(e){let t=D(e.environment),s=t.installed.filter((r)=>r.enabled),a=t.installed.filter((r)=>!r.enabled),o=a.map((r)=>`${h} is installed in the ${r.name} profile but its bundle is disabled`);if(s.length>0)return{platform:"deepseek-harness",status:"configured",method:"dsh bundle",configPaths:s.map((r)=>r.configPath),...o.length>0?{errors:o}:{}};if(a.length>0)return{platform:"deepseek-harness",status:"disabled",method:"dsh bundle",configPaths:a.map((r)=>r.configPath),errors:o};return t.unreadable?{platform:"deepseek-harness",status:"not-inspected"}:{platform:"deepseek-harness",status:"n/a"}}import{randomUUID as v}from"node:crypto";import{resolve as O}from"node:path";var ze=new Map([["bash","posix"],["pwsh","powershell"]]),j={agent:"deepseek-harness",debugLabel:"deepseek-harness tool guard",extract:(e,t,s)=>A(e,t,s),getSessionId:(e)=>e?.agent?.session.header.id,allow:void 0,block:(e)=>re(e),includeEvidenceOnError:(e)=>e.route.kind==="command"};function Tt(e){let t=_();e.tools.guard((a)=>t(a,process.cwd()));let s=new Set;e.on("tools/post-execute",async(a,o,r)=>{let i=await r(),l=I(a,s);if(!l)return i;return{...i,additionalContexts:[l,...i.additionalContexts??[]]}})}function I(e,t){try{let s=e,a=s?.agent?.session.header,o=s?.name,i=s?.arguments?.command;if(!a||typeof o!=="string"||ze.has(o)||S(o)!=="unknown"||typeof i!=="string"||i.trim()==="")return;let l=JSON.stringify([a.id,o]);if(t.has(l))return;let p=c();if(w(p,{cwd:a.cwd??process.cwd()}).policy.commandTools.some((m)=>m.name===o))return;t.add(l);let f=De(p);return Object.freeze({id:v(),role:"user",content:Object.freeze([Object.freeze({type:"text",text:`CC Safety Net did not check the command \`${o}\` just ran. It checks a plugin's shell tool only after the tool is declared. First find out where \`${o}\` runs its commands: check its tool description, and if that doesn't say, read its plugin's source under \`${f}/<profile>/node_modules\`. If it runs them on this machine, declare it with \`npx -y cc-safety-net rule tool add ${o}\`, and add \`--cwd-arg <name>\` if it takes its working directory in an argument other than \`workdir\`, \`cwd\` or \`working_directory\`. If it runs them somewhere else, such as a remote host, or you can't tell, declare it with \`npx -y cc-safety-net rule tool add ${o} --no-cwd-arg\`: its commands are then checked as if they ran in this session's directory. Don't test the declaration by running a destructive command; \`npx -y cc-safety-net rule tool list\` confirms it. Either way, tell the user what you found and what you did.`})]),source:Object.freeze({kind:"cc-safety-net",form:"notice",summary:`${o} commands are not checked`})})}catch{return}}function _(e={}){return Le(j,e)}function A(e,t,s){if(!e||typeof e!=="object")return Ne(null);let a=e,o=a.agent?.session.header.cwd??t,r=bt([o],s),i=a.name;if(typeof i!=="string"||i.trim()==="")return Q(r??null);if(!r)return ve({directory:"session",problem:"unusable",cwd:o},{toolName:i});let l=a.arguments,p=ze.get(i);if(!p)return d(i,l,{kind:S(i)},{configCwd:r,executionCwd:r},null);if(!l||typeof l!=="object"||Array.isArray(l))return Q(r,{toolName:i});let g=l,f=g.command;if(typeof f!=="string"||f.trim()==="")return Q(r,{toolName:i});let m=g.workdir;if(m!==void 0&&(typeof m!=="string"||m.trim()===""))return Q(r,{command:f,toolName:i});let y=m===void 0?r:bt([O(r,m)],s);if(!y)return ve({directory:"requested",problem:"unusable",cwd:m},{command:f,toolName:i});return d(i,l,{kind:"command",shell:p},{configCwd:r,executionCwd:y},f)}
2
2
  export{b,B,u,We,n,De,lt,Rt,ze,Tt};