@gitkraken/agent-tools 0.1.1 → 0.3.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.
@@ -1 +1 @@
1
- import{removeAtPointer as e,removeAtPointerAndEmptyParent as t}from"./jsonc-edit.js";import{assertValidToml as n,parseTomlSafe as r,tomlDottedPath as i,tomlLiteralKey as a}from"./toml-read.js";import{OPEN_CODE_JSON_PATHS as o,clientConfigPaths as s,clientJSONPath as c,isSupported as l}from"./clients.js";import{writeFileTracked as u}from"../file-change.js";import{tomlSemanticEqual as d,withoutCodexEntry as f}from"./toml-safety.js";import{removeBlock as p,trimTrailingBlankLines as m}from"./toml-splice.js";function h(e,t){return{file:{path:e,change:`unchanged`,removedLocations:[],reason:t}}}async function g(e,t){let{client:n}=e;if(!l(n))throw Error(`unsupported client: ${n}`);let r=e.configPath?[e.configPath]:await s(n,t),i=[];for(let e of r)i.push(await _(n,e,t));let a=[];for(let{file:e,text:n}of i)n!==void 0&&await u(t.fs,e.path,n,[]),a.push(e);return{client:n,removed:a.some(e=>e.removedLocations.length>0),files:a}}async function _(e,t,n){let r=await n.fs.readFile(t);if(r===null)return h(t,`file-missing`);if(r.trim()===``)return h(t,`file-empty`);let{text:i,removedLocations:a}=e===`codex`?y(r,t):v(r,e,t);return a.length===0?h(t,`no-entry`):{file:{path:t,change:`updated`,removedLocations:a},text:i}}function v(n,r,i){let a=r===`opencode`,s=a?o:[c(r)],l=n,u=[];for(let n of s){let r=a?t(l,n,i):e(l,n,i);r.removed&&(l=r.text,u.push(n))}return{text:l,removedLocations:u}}function y(e,t){n(e,t);let o=c(`codex`),s=r(e);if(a(s,o)===void 0&&i(s,o)===void 0)return{text:e,removedLocations:[]};let{text:l,removed:u}=p(e,o);if(!u){if(a(s,o)!==void 0||i(s,o)!==void 0)throw Error(`cannot safely remove Codex MCP entry in ${t}: unsupported TOML representation`);return{text:e,removedLocations:[]}}let h=m(l),g=r(h);if(a(g,o)!==void 0||i(g,o)!==void 0)throw Error(`cannot safely remove Codex MCP entry in ${t}: target remains after splice`);if(!g||!d(f(g),f(s)))throw Error(`cannot safely remove Codex MCP entry in ${t}: splice would change another TOML value`);return{text:h,removedLocations:[o]}}export{g as uninstallMcp};
1
+ import{writeFileTracked as e}from"../file-change.js";import{removeAtPointer as t,removeAtPointerAndEmptyParent as n}from"./jsonc-edit.js";import{assertValidToml as r,parseTomlSafe as i,tomlDottedPath as a,tomlLiteralKey as o}from"./toml-read.js";import{clientConfigPaths as s,clientJSONPath as c,isSupported as l,openCodeEntryPointers as u}from"./clients.js";import{tomlSemanticEqual as d,withoutCodexEntry as f}from"./toml-safety.js";import{removeBlock as p,trimTrailingBlankLines as m}from"./toml-splice.js";function h(e,t){return{file:{path:e,change:`unchanged`,removedLocations:[],reason:t}}}async function g(t,n){let{client:r}=t;if(!l(r))throw Error(`unsupported client: ${r}`);let i=t.configPath?[t.configPath]:await s(r,n),a=[];for(let e of i)a.push(await _(r,e,n));let o=[];for(let{file:t,text:r}of a)r!==void 0&&await e(n.fs,t.path,r,[]),o.push(t);return{client:r,removed:o.some(e=>e.removedLocations.length>0),files:o}}async function _(e,t,n){let r=await n.fs.readFile(t);if(r===null)return h(t,`file-missing`);if(r.trim()===``)return h(t,`file-empty`);let{text:i,removedLocations:a}=e===`codex`?y(r,t):v(r,e,t);return a.length===0?h(t,`no-entry`):{file:{path:t,change:`updated`,removedLocations:a},text:i}}function v(e,r,i){let a=r===`opencode`,o=a?u(e):[c(r)],s=e,l=[];for(let e of o){let r=a?n(s,e,i):t(s,e,i);r.removed&&(s=r.text,l.push(e))}return{text:s,removedLocations:l}}function y(e,t){r(e,t);let n=c(`codex`),s=i(e);if(o(s,n)===void 0&&a(s,n)===void 0)return{text:e,removedLocations:[]};let{text:l,removed:u}=p(e,n);if(!u){if(o(s,n)!==void 0||a(s,n)!==void 0)throw Error(`cannot safely remove Codex MCP entry in ${t}: unsupported TOML representation`);return{text:e,removedLocations:[]}}let h=m(l),g=i(h);if(o(g,n)!==void 0||a(g,n)!==void 0)throw Error(`cannot safely remove Codex MCP entry in ${t}: target remains after splice`);if(!g||!d(f(g),f(s)))throw Error(`cannot safely remove Codex MCP entry in ${t}: splice would change another TOML value`);return{text:h,removedLocations:[n]}}export{g as uninstallMcp};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/agent-tools",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Host configuration and path helpers for AI coding agent integrations, with an in-memory filesystem for testing.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Axosoft, LLC dba GitKraken",