inscope 0.8.0 → 0.8.1
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/bin/index.mjs +36 -36
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +11 -11
- package/package.json +1 -1
package/dist/bin/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
`)},x=/^[A-Za-z0-9._-]+$/,S=e=>e?x.test(e)?null:`use only letters, digits, dot (.), dash (-), or underscore (_)`:`must not be empty`,C=/["`$\n]/,w=e=>C.test(e)?'must not contain a quote ("), backtick (`), $, or newline':null,ee=e=>e?w(e):`must not be empty`,te=e=>e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-.]+|[-.]+$/g,``),
|
|
4
|
-
`)},
|
|
5
|
-
`)},A=(e,t,n)=>{let r=i(e,t,{encoding:`utf8`,input:n?.input});return{status:r.status??(r.error?127:1),stdout:r.stdout??``,stderr:r.stderr??``}},
|
|
2
|
+
import e from"node:fs";import{parseArgs as t}from"node:util";import n from"node:path";import r from"node:os";import{spawnSync as i}from"node:child_process";import a from"node:readline";const o=()=>r.homedir(),s=()=>process.env.XDG_CONFIG_HOME?.trim()||n.join(o(),`.config`),c=e=>e===`~`?o():e.startsWith(`~/`)?n.join(o(),e.slice(2)):e,l=e=>{let t=c(e),r=o();return t===r?`~`:t.startsWith(r+n.sep)?`~/`+t.slice(r.length+1):t},u=e=>n.resolve(c(e)),d=()=>n.join(s(),`inscope`),f=()=>n.join(d(),`inscope.json`),p=()=>n.join(d(),`inscope.zsh`),m=()=>n.join(d(),`git`),h=()=>n.join(o(),`.gitconfig`),g=()=>n.join(o(),`.zshrc`),_=()=>({version:1,workspaces:[]}),v=()=>e.existsSync(f()),y=()=>{let t=f(),n=e.readFileSync(t,`utf8`),r=JSON.parse(n),i=ne(r);if(i)throw Error(i);try{ie(r)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`${n}\nFix it in ${l(t)}, then re-run.`)}return r},b=t=>{ie(t);let r=f();e.mkdirSync(n.dirname(r),{recursive:!0}),e.writeFileSync(r,JSON.stringify(t,null,2)+`
|
|
3
|
+
`)},x=/^[A-Za-z0-9._-]+$/,S=e=>e?x.test(e)?null:`use only letters, digits, dot (.), dash (-), or underscore (_)`:`must not be empty`,C=/["`$\n]/,w=e=>C.test(e)?'must not contain a quote ("), backtick (`), $, or newline':null,ee=e=>e?w(e):`must not be empty`,te=e=>/[\n\r]/.test(e)?`must not contain a newline`:null,ne=e=>typeof e.version==`number`&&e.version>1?`config version ${e.version} is newer than this inscope supports (max 1); upgrade inscope`:null,re=e=>e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-.]+|[-.]+$/g,``),ie=e=>{if(!e||typeof e!=`object`)throw Error(`config is not an object`);let t=ne(e);if(t)throw Error(t);if(!Array.isArray(e.workspaces))throw Error(`config.workspaces must be an array`);let n=new Set;for(let t of e.workspaces){if(!t.name)throw Error(`a workspace is missing a name`);let e=S(t.name);if(e)throw Error(`workspace name "${t.name}" is invalid: ${e}`);if(!t.path)throw Error(`workspace "${t.name}" is missing a path`);let r=ee(t.path);if(r)throw Error(`workspace "${t.name}" path "${t.path}" is invalid: ${r}`);if(t.gh){let e=w(t.gh);if(e)throw Error(`workspace "${t.name}" gh account "${t.gh}" is invalid: ${e}`)}if(t.git?.email){let e=te(t.git.email);if(e)throw Error(`workspace "${t.name}" git email "${t.git.email}" is invalid: ${e}`)}if(t.git?.name){let e=te(t.git.name);if(e)throw Error(`workspace "${t.name}" git name "${t.git.name}" is invalid: ${e}`)}let i=t.servers?.slack;if(i&&i.keychain){let e=w(i.keychain);if(e)throw Error(`workspace "${t.name}" Slack keychain "${i.keychain}" is invalid: ${e}`)}if(n.has(t.name))throw Error(`duplicate workspace name "${t.name}"`);n.add(t.name)}},ae=e=>re(n.basename(u(e)))||`workspace`,T=(e,t)=>{let n=e.workspaces.find(e=>e.name===t);if(n)return n;let r=u(t);return e.workspaces.find(e=>u(e.path)===r)},oe=(e,t)=>{let n=e.workspaces.filter(e=>e.name!==t.name);return n.push({...t,path:l(t.path)}),n.sort((e,t)=>e.name.localeCompare(t.name)),{...e,workspaces:n}},se=(e,t)=>{let n=T(e,t);return n?{cfg:{...e,workspaces:e.workspaces.filter(e=>e.name!==n.name)},removed:n}:{cfg:e}},E={atlassian:`https://mcp.atlassian.com/v1/mcp`,canva:`https://mcp.canva.com/mcp`,clickup:`https://mcp.clickup.com/mcp`,hubspot:`https://mcp.hubspot.com`,intercom:`https://mcp.intercom.com/mcp`,linear:`https://mcp.linear.app/mcp`,monday:`https://mcp.monday.com/mcp`,notion:`https://mcp.notion.com/mcp`,plane:`https://mcp.plane.so/http/mcp`,sentry:`https://mcp.sentry.dev/mcp`,stripe:`https://mcp.stripe.com`,vercel:`https://mcp.vercel.com`,webflow:`https://mcp.webflow.com/`},D=[`github`,`atlassian`,`canva`,`clickup`,`hubspot`,`intercom`,`linear`,`monday`,`notion`,`plane`,`sentry`,`slack`,`stripe`,`vercel`,`webflow`],O=e=>D.map(t=>`${t}-${e}`),k=e=>n.join(u(e.path),`.mcp.json`),ce=(e,t)=>e&&typeof e==`object`&&e.url?e.url:t,le=e=>{let t=e.servers,n={};for(let r of D){let i=t[r];if(!i)continue;let a=`${r}-${e.name}`;if(r===`github`)n[a]={type:`http`,url:`https://api.githubcopilot.com/mcp/`,headers:{Authorization:"Bearer ${GITHUB_TOKEN}"}};else if(r===`slack`){let e=i,t={SLACK_MCP_XOXP_TOKEN:"${SLACK_MCP_XOXP_TOKEN}"};e.addMessageTool&&(t.SLACK_MCP_ADD_MESSAGE_TOOL=`true`),n[a]={type:`stdio`,command:`npx`,args:[`-y`,`slack-mcp-server@1.3.0`,`--transport`,`stdio`],env:t}}else n[a]={type:`http`,url:ce(i,E[r])}}return n},ue=t=>{if(!e.existsSync(t))return{};try{return JSON.parse(e.readFileSync(t,`utf8`))}catch{return{}}},de=t=>{if(!e.existsSync(t))return{};try{return JSON.parse(e.readFileSync(t,`utf8`))}catch{throw Error(`${t} is not valid JSON; fix or remove it, then re-run inscope (left it untouched)`)}},fe=t=>{let n=k(t);return e.existsSync(n)?ue(n):null},pe=t=>{let r=k(t);e.mkdirSync(n.dirname(r),{recursive:!0});let i=de(r),a=i.mcpServers&&typeof i.mcpServers==`object`?{...i.mcpServers}:{};for(let e of O(t.name))delete a[e];Object.assign(a,le(t)),i.mcpServers=a,e.writeFileSync(r,JSON.stringify(i,null,2)+`
|
|
4
|
+
`)},me=t=>{let n=k(t);if(!e.existsSync(n))return;let r=de(n);if(r.mcpServers&&typeof r.mcpServers==`object`)for(let e of O(t.name))delete r.mcpServers[e];e.writeFileSync(n,JSON.stringify(r,null,2)+`
|
|
5
|
+
`)},A=(e,t,n)=>{let r=i(e,t,{encoding:`utf8`,input:n?.input});return{status:r.status??(r.error?127:1),stdout:r.stdout??``,stderr:r.stderr??``}},he=()=>process.platform===`darwin`,j=()=>process.env.USER||``,ge=(e,t=A)=>{let n=t(`gh`,[`auth`,`token`,`-u`,e]),r=n.stdout.trim();return n.status===0&&r?r:null},_e=(e=A)=>{let t=e(`gh`,[`auth`,`status`]);return(t.stdout+t.stderr).trim()},ve=(e=A)=>{let t=[];for(let n of _e(e).matchAll(/account (\S+) \(/g))t.includes(n[1])||t.push(n[1]);return t},ye=(e,t=A)=>{let n=t(`git`,[`config`,`--global`,e]),r=n.stdout.trim();return n.status===0&&r?r:null},M=(e,t=A)=>{let n=t(`security`,[`find-generic-password`,`-a`,j(),`-s`,e,`-w`]);return n.status===0&&n.stdout.trim().length>0},be=(e,t,n=A)=>{let r=n(`security`,[`add-generic-password`,`-U`,`-a`,j(),`-s`,e,`-w`,t]);if(r.status!==0)throw Error(`security add-generic-password failed: ${r.stderr.trim()||`unknown error`}`)},xe=e=>`security add-generic-password -U -a "${j()||`$USER`}" -s ${e} -w 'xoxp-...'`,Se=(e,t=A)=>{let n=t(`git`,[`config`,`--file`,e,`user.email`]);return n.status===0?n.stdout.trim():null},N=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),Ce=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,P=e=>t=>process.stdout.isTTY?`\x1b[${e}m${t}\x1b[0m`:t,F=P(`38;5;208`),we=P(`38;2;63;185;80`),Te=P(`38;2;210;153;34`),I=P(`38;2;248;81;73`),L=e=>{let t=process.stdin;t.isTTY&&typeof t.setRawMode==`function`&&t.setRawMode(e)};let R=``;const Ee=e=>new Promise(t=>{process.stdout.write(e);let n=()=>{let e=R.indexOf(`
|
|
6
6
|
`);if(e<0)return!1;let n=R.slice(0,e).replace(/\r$/,``);return R=R.slice(e+1),t(n),!0};if(n())return;let r=e=>{R+=e.toString(`utf8`),R.includes(`
|
|
7
|
-
`)&&(process.stdin.off(`data`,r),process.stdin.off(`end`,i),process.stdin.pause(),n())},i=()=>{process.stdin.off(`data`,r),process.stdin.off(`end`,i);let e=R.replace(/\r$/,``);R=``,t(e)};process.stdin.on(`data`,r),process.stdin.on(`end`,i),process.stdin.resume()}),z=async(e,t=``)=>(await
|
|
8
|
-
`),n.close(),t(e.trim())})}),
|
|
9
|
-
`);let s=e=>{e||o.write(`\x1b[${t.length}A`);for(let e=0;e<t.length;e++){let n=e===i,r=`${n?`❯`:` `} ${t[e].label}`;o.write(`\x1b[2K ${n?
|
|
10
|
-
`),process.exit(130))};process.stdin.on(`keypress`,l)}),
|
|
11
|
-
`);let c=e=>{e||s.write(`\x1b[${t.length}A`);for(let e=0;e<t.length;e++){let n=e===o,i=`${n?`❯`:` `} ${r[e]?`◉`:`◯`} ${t[e].label}`;s.write(`\x1b[2K ${n?
|
|
12
|
-
`),process.exit(130))};process.stdin.on(`keypress`,u)}),H=e=>`# >>> inscope:${e} >>>`,U=e=>`# <<< inscope:${e} <<<`,W=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),
|
|
13
|
-
|
|
14
|
-
`).replace(/^\n+/,``);
|
|
15
|
-
`),
|
|
7
|
+
`)&&(process.stdin.off(`data`,r),process.stdin.off(`end`,i),process.stdin.pause(),n())},i=()=>{process.stdin.off(`data`,r),process.stdin.off(`end`,i);let e=R.replace(/\r$/,``);R=``,t(e)};process.stdin.on(`data`,r),process.stdin.on(`end`,i),process.stdin.resume()}),z=async(e,t=``)=>(await Ee(`${e}${t?` [${t}]`:``}: `)).trim()||t,B=async(e,t=!1)=>{if(!N()){let n=(await Ee(`${e} [${t?`Y/n`:`y/N`}]: `)).trim().toLowerCase();return n?n===`y`||n===`yes`:t}return V(e,[{label:`Yes`,value:!0},{label:`No`,value:!1}],t?0:1)},De=e=>new Promise(t=>{let n=a.createInterface({input:process.stdin,output:process.stdout}),r=n.output,i=!1;n._writeToOutput=t=>{if(!i){r.write(t),t.includes(e)&&(i=!0);return}},n.question(e,e=>{r.write(`
|
|
8
|
+
`),n.close(),t(e.trim())})}),Oe=`\x1B[36m`,ke=`\x1B[0m`,V=(e,t,n=0)=>new Promise(r=>{if(!N()||t.length===0){r(t[Math.min(n,t.length-1)]?.value);return}let i=Math.max(0,Math.min(n,t.length-1)),o=process.stdout;o.write(e+`
|
|
9
|
+
`);let s=e=>{e||o.write(`\x1b[${t.length}A`);for(let e=0;e<t.length;e++){let n=e===i,r=`${n?`❯`:` `} ${t[e].label}`;o.write(`\x1b[2K ${n?Oe+r+ke:r}\n`)}};s(!0),a.emitKeypressEvents(process.stdin),L(!0),process.stdin.resume();let c=()=>{process.stdin.off(`keypress`,l),L(!1),process.stdin.pause()},l=(e,n)=>{n.name===`up`||n.name===`k`?(i=(i-1+t.length)%t.length,s(!1)):n.name===`down`||n.name===`j`?(i=(i+1)%t.length,s(!1)):n.name===`return`||n.name===`enter`?(c(),r(t[i].value)):n.ctrl&&n.name===`c`&&(c(),o.write(`
|
|
10
|
+
`),process.exit(130))};process.stdin.on(`keypress`,l)}),Ae=(e,t)=>new Promise(n=>{let r=t.map(e=>!!e.checked),i=()=>t.filter((e,t)=>r[t]).map(e=>e.value);if(!N()||t.length===0){n(i());return}let o=0,s=process.stdout;s.write(e+`
|
|
11
|
+
`);let c=e=>{e||s.write(`\x1b[${t.length}A`);for(let e=0;e<t.length;e++){let n=e===o,i=`${n?`❯`:` `} ${r[e]?`◉`:`◯`} ${t[e].label}`;s.write(`\x1b[2K ${n?Oe+i+ke:i}\n`)}};c(!0),a.emitKeypressEvents(process.stdin),L(!0),process.stdin.resume();let l=()=>{process.stdin.off(`keypress`,u),L(!1),process.stdin.pause()},u=(e,a)=>{a.name===`up`||a.name===`k`?(o=(o-1+t.length)%t.length,c(!1)):a.name===`down`||a.name===`j`?(o=(o+1)%t.length,c(!1)):a.name===`space`||e===` `?(r[o]=!r[o],c(!1)):a.name===`return`||a.name===`enter`?(l(),n(i())):a.ctrl&&a.name===`c`&&(l(),s.write(`
|
|
12
|
+
`),process.exit(130))};process.stdin.on(`keypress`,u)}),H=e=>`# >>> inscope:${e} >>>`,U=e=>`# <<< inscope:${e} <<<`,W=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),je=e=>RegExp(`${W(H(e))}\\n[\\s\\S]*?\\n${W(U(e))}\\n?`),Me=(e,t)=>{let n=t.replace(/\n+$/,``);return`${H(e)}\n${n}\n${U(e)}\n`},G=t=>{try{return e.readFileSync(t,`utf8`)}catch{return``}},Ne=(t,r,i)=>{e.mkdirSync(n.dirname(t),{recursive:!0});let a=G(t),o=Me(r,i),s=je(r),c;if(s.test(a))c=a.replace(s,o);else{let e=a.replace(/\n*$/,``);c=e.length?`${e}\n\n${o}`:o}e.writeFileSync(t,c)},Pe=(t,n)=>{let r=G(t);if(!r)return;let i=r.replace(je(n),``).replace(/\n{3,}/g,`
|
|
13
|
+
|
|
14
|
+
`).replace(/^\n+/,``);e.writeFileSync(t,i)},Fe=(e,t)=>{let n=G(e).match(RegExp(`${W(H(t))}\\n([\\s\\S]*?)\\n${W(U(t))}`));return n?n[1]:null},K=`gitconfig`,q=e=>!!(e.git&&(e.git.email||e.git.name)),J=e=>n.join(m(),`${e}.gitconfig`),Ie=e=>l(e).replace(/\/+$/,``)+`/`,Le=e=>e.workspaces.filter(q).map(e=>`[includeIf "gitdir:${Ie(e.path)}"]\n\tpath = ${l(J(e.name))}`).join(`
|
|
15
|
+
`),Re=e=>{let t=[`# Managed by inscope. Do not edit by hand.`,`[user]`];return e.git?.email&&t.push(`\temail = ${e.git.email}`),e.git?.name&&t.push(`\tname = ${e.git.name}`),t.join(`
|
|
16
16
|
`)+`
|
|
17
|
-
`},
|
|
17
|
+
`},ze=t=>{e.mkdirSync(m(),{recursive:!0});for(let n of t.workspaces)q(n)&&e.writeFileSync(J(n.name),Re(n));let n=Le(t);n?Ne(h(),K,n):Pe(h(),K)},Be=t=>{let n=J(t);e.existsSync(n)&&e.rmSync(n)},Ve=e=>{let t=l(e);return t===`~`?`"$HOME/"*`:t.startsWith(`~/`)?`"$HOME/${t.slice(2)}/"*`:`"${t}/"*`},He=e=>e.servers.slack?e.servers.slack.keychain:``,Y=e=>{let t=[...e.workspaces].sort((e,t)=>e.name.localeCompare(t.name));return`# Managed by inscope. Do not edit by hand.
|
|
18
18
|
# Source of truth: ~/.config/inscope/inscope.json
|
|
19
19
|
# Edit there, then run \`inscope apply\` to regenerate this file.
|
|
20
20
|
#
|
|
@@ -25,7 +25,7 @@ import{parseArgs as e}from"node:util";import t from"node:fs";import n from"node:
|
|
|
25
25
|
__inscope_resolve_identity() {
|
|
26
26
|
local ws
|
|
27
27
|
case "\${PWD}/" in
|
|
28
|
-
${t.map(e=>` ${
|
|
28
|
+
${[...t].sort((e,t)=>l(t.path).length-l(e.path).length).map(e=>` ${Ve(e.path)}) ws="${e.name}" ;;`).join(`
|
|
29
29
|
`)||` # no workspaces configured`}
|
|
30
30
|
*) ws="" ;;
|
|
31
31
|
esac
|
|
@@ -35,7 +35,7 @@ ${t.map(e=>` ${ze(e.path)}) ws="${e.name}" ;;`).join(`
|
|
|
35
35
|
|
|
36
36
|
local gh_user="" slack_svc=""
|
|
37
37
|
case "$ws" in
|
|
38
|
-
${t.map(e=>{let t=[];e.gh&&t.push(`gh_user="${e.gh}"`);let n=
|
|
38
|
+
${t.map(e=>{let t=[];e.gh&&t.push(`gh_user="${e.gh}"`);let n=He(e);return n&&t.push(`slack_svc="${n}"`),` ${e.name}) ${t.length?t.join(`; `):`:`} ;;`}).join(`
|
|
39
39
|
`)||` # no workspaces configured`}
|
|
40
40
|
*) return ;; # outside a mapped workspace: nothing set
|
|
41
41
|
esac
|
|
@@ -61,8 +61,8 @@ autoload -Uz add-zsh-hook
|
|
|
61
61
|
add-zsh-hook chpwd __inscope_resolve_identity
|
|
62
62
|
__inscope_ws="__init__" # force the first resolve, clearing any inherited token
|
|
63
63
|
__inscope_resolve_identity
|
|
64
|
-
`},
|
|
65
|
-
No token entered; skipped keychain write.`)}else M(n)||console.log(`\nSlack token not in the keychain yet. Store it once with:\n${F(
|
|
64
|
+
`},Ue=e=>{let t=o();return e===t?`$HOME`:e.startsWith(t+n.sep)?`$HOME/${e.slice(t.length+1)}`:e},We=()=>{let e=Ue(p());return`[ -r "${e}" ] && source "${e}"`},Ge=e=>{let t=We();if(e.includes(t))return e;let n=e.replace(/\n*$/,``),r=`# inscope: load each workspace's tokens (GitHub, Slack) from \$PWD on every cd\n${t}`;return n.length?`${n}\n\n${r}\n`:`${r}\n`},Ke=()=>{let t=g(),n=``;try{n=e.readFileSync(t,`utf8`)}catch{}let r=Ge(n);r!==n&&e.writeFileSync(t,r)},qe=()=>{try{return e.readFileSync(g(),`utf8`).includes(We())}catch{return!1}},X=t=>{let r=p();e.mkdirSync(n.dirname(r),{recursive:!0}),e.writeFileSync(r,Y(t)),ze(t),Ke();let i=[];for(let e of t.workspaces)pe(e),i.push(k(e));return{hook:r,gitconfig:t.workspaces.some(e=>e.git?.email||e.git?.name),mcp:i}},Je=D,Ye=e=>`SLACK_MCP_XOXP_TOKEN_${e.toUpperCase().replace(/[^A-Z0-9]+/g,`_`)}`,Xe=e=>D.filter(t=>!!e[t]),Ze=(e,t)=>{let n={};for(let r of D)n[r]=r===`slack`?t?{keychain:t.keychain,addMessageTool:t.addMessageTool}:!1:e.includes(r);return n},Qe=e=>{let t=oe(v()?y():_(),e);b(t),X(t)},$e=async(e,t)=>{if(!e.servers.slack)return;let n=e.servers.slack.keychain;if(t){let e=await De(`Paste the Slack xoxp token for ${n}: `);e?(be(n,e),console.log(`\n✓ stored ${n} in the macOS keychain`)):console.error(`
|
|
65
|
+
No token entered; skipped keychain write.`)}else M(n)||console.log(`\nSlack token not in the keychain yet. Store it once with:\n${F(xe(n))}\n\nSetup guide: ${F(Ce(`https://github.com/korotovsky/slack-mcp-server/blob/HEAD/docs/01-authentication-setup.md#option-2-using-slack_mcp_xoxp_token-user-oauth`))}`)};var Z=`inscope`,et=`0.8.1`,Q={name:`Neeraj Dalal`,email:`admin@nrjdalal.com`,url:`https://nrjdalal.com`};const tt=`Map a directory to a GitHub account, git email, and MCP servers.
|
|
66
66
|
Runs interactively in a terminal; pass flags or -y to skip the prompts. Re-running
|
|
67
67
|
with the same path or label updates that workspace.
|
|
68
68
|
|
|
@@ -83,22 +83,22 @@ Options:
|
|
|
83
83
|
--slack-message allow the Slack MCP server to post messages
|
|
84
84
|
--seed-slack prompt for the Slack token and store it in the keychain
|
|
85
85
|
-y, --yes accept defaults, skip all prompts (non-interactive)
|
|
86
|
-
-h, --help Display help message`,
|
|
87
|
-
GitHub account for this workspace`,[...
|
|
88
|
-
Slack uses a user OAuth (xoxp) token.`),
|
|
86
|
+
-h, --help Display help message`,nt=D.map(e=>({label:e,value:e,checked:e===`github`})),rt=async n=>{let{positionals:r,values:i}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`},yes:{type:`boolean`,short:`y`},gh:{type:`string`},email:{type:`string`},"git-name":{type:`string`},label:{type:`string`},servers:{type:`string`},"slack-keychain":{type:`string`},"slack-message":{type:`boolean`},"seed-slack":{type:`boolean`}},args:n});i.help&&(console.log(tt),process.exit(0));let a=N()&&!i.yes;a&&console.log();let o=r[0];if(!o)if(a)o=await z(`Workspace directory`,process.cwd());else throw Error(tt);let s=ee(o);s&&(console.error(`\nInvalid workspace path "${o}": ${s}`),process.exit(1)),e.existsSync(u(o))||console.error(Te(`\nWarning: ${l(o)} does not exist yet; it will be created.`));let c=i.label||ae(o);a&&!i.label&&(c=await z(`Label`,c));let d=S(c);d&&(console.error(`\nInvalid label "${c}": ${d}`),process.exit(1));let f=i.gh;f===void 0&&a&&(f=await V(`
|
|
87
|
+
GitHub account for this workspace`,[...ve().map(e=>({label:e,value:e})),{label:`(none)`,value:``}])||void 0);let p=i.email,m=i[`git-name`];if(a){if(p===void 0){let e=ye(`user.email`);p=await z(`Git email${e?` [${e} · global]`:``} (enter to inherit global)`)||void 0}if(m===void 0){let e=ye(`user.name`);m=await z(`Git name${e?` [${e} · global]`:``} (enter to inherit global)`)||void 0}}let h;h=i.servers===void 0?a?await Ae(`MCP servers (space toggles, enter confirms)`,nt):[`github`]:i.servers.split(`,`).map(e=>e.trim()).filter(Boolean);let g=h.includes(`slack`)||!!i[`slack-keychain`]||!!i[`seed-slack`],_=i[`slack-keychain`]||Ye(c),v=!!i[`slack-message`],y=!!i[`seed-slack`];g&&a&&(console.log(`
|
|
88
|
+
Slack uses a user OAuth (xoxp) token.`),i[`slack-keychain`]||(_=await z(`Slack keychain service`,_)),i[`slack-message`]||(v=await B(`Allow Slack to post messages?`,!0)),i[`seed-slack`]||(y=await B(`Store the Slack token now?`,!0)));let b=f?w(f):null;if(b&&(console.error(`\nInvalid gh account "${f}": ${b}`),process.exit(1)),g){let e=w(_);e&&(console.error(`\nInvalid Slack keychain service "${_}": ${e}`),process.exit(1))}let x={name:c,path:l(o),gh:f,git:p||m?{email:p,name:m}:void 0,servers:Ze(h,g?{keychain:_,addMessageTool:v}:null)};Qe(x),console.log(`\n✓ workspace "${c}" -> ${x.path}`),console.log(`✓ regenerated the hook, git includes, and ${x.path}/.mcp.json`),await $e(x,y),console.log(`\nLaunch \`claude\` from ${x.path} (or relaunch) to pick up the new identity.`),process.exit(0)},it=`Regenerate the chpwd hook, git includes, and every .mcp.json
|
|
89
89
|
from your config. Idempotent: run it any time the config changes.
|
|
90
90
|
|
|
91
91
|
Usage:
|
|
92
92
|
$ ${Z} apply
|
|
93
93
|
|
|
94
94
|
Options:
|
|
95
|
-
-h, --help Display help message`,
|
|
96
|
-
`},
|
|
95
|
+
-h, --help Display help message`,at=e=>{let{values:n}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`}},args:e});n.help&&(console.log(it),process.exit(0)),v()||(console.error(`No config found. Run \`${Z} init\` first.`),process.exit(1));let r=y(),i=X(r);console.log(`\n✓ hook ${i.hook}`),i.gitconfig&&console.log(`✓ gitconfig ~/.gitconfig (includeIf block)`);for(let e of i.mcp)console.log(`✓ mcp ${e}`);console.log(`\nApplied ${r.workspaces.length} workspace(s).`),process.exit(0)},$=t=>{try{return e.readFileSync(t,`utf8`)}catch{return``}},ot=e=>{let t=$(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},st=e=>{let t=ot(k(e))??{},n=t.mcpServers&&typeof t.mcpServers==`object`?{...t.mcpServers}:{};for(let t of O(e.name))delete n[t];return Object.assign(n,le(e)),t.mcpServers=n,JSON.stringify(t,null,2)+`
|
|
96
|
+
`},ct=t=>{let n=k(t);if(!e.existsSync(n))return null;try{return JSON.parse(e.readFileSync(n,`utf8`)),null}catch{return"invalid JSON; `apply` will not touch it until you fix it"}},lt=e=>{let t=[],n=p();t.push({label:`hook`,path:n,current:$(n),next:Y(e)}),t.push({label:`gitconfig`,path:h(),current:Fe(h(),K)??``,next:Le(e)});for(let n of e.workspaces){if(!q(n))continue;let e=J(n.name);t.push({label:`gitconfig:${n.name}`,path:e,current:$(e),next:Re(n)})}for(let n of e.workspaces){let e=k(n),r=ct(n);if(r){t.push({label:`mcp:${n.name}`,path:e,current:``,next:``,error:r});continue}t.push({label:`mcp:${n.name}`,path:e,current:$(e),next:st(n)})}return t.filter(e=>e.error!=null||e.current!==e.next)},ut=(e,t)=>{let n=e.length?e.split(`
|
|
97
97
|
`):[],r=t.length?t.split(`
|
|
98
98
|
`):[],i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array.from({length:a+1},()=>0));for(let e=i-1;e>=0;e--)for(let t=a-1;t>=0;t--)o[e][t]=n[e]===r[t]?o[e+1][t+1]+1:Math.max(o[e+1][t],o[e][t+1]);let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push(` ${n[c]}`),c++,l++):o[c+1][l]>=o[c][l+1]?(s.push(`- ${n[c]}`),c++):(s.push(`+ ${r[l]}`),l++);for(;c<i;)s.push(`- ${n[c++]}`);for(;l<a;)s.push(`+ ${r[l++]}`);return s.join(`
|
|
99
|
-
`)},
|
|
99
|
+
`)},dt=e=>{let t=[],n=e.workspaces.map(e=>{let n=ot(k(e))?.mcpServers;if(!n||typeof n!=`object`)return e;let r=e.servers,i=e.servers.slack;i&&!i.addMessageTool&&n[`slack-${e.name}`]?.env?.SLACK_MCP_ADD_MESSAGE_TOOL===`true`&&(r={...r,slack:{...i,addMessageTool:!0}},t.push(`${e.name}: slack.addMessageTool = true`));for(let i of D){if(i===`github`||i===`slack`)continue;let a=n[`${i}-${e.name}`]?.url;if(typeof a!=`string`)continue;let o=e.servers[i];if(!o){r={...r,[i]:a===E[i]?!0:{url:a}},t.push(`${e.name}: ${i} = ${a===E[i]?`enabled`:a}`);continue}a!==((typeof o==`object`?o.url:void 0)??E[i])&&(r={...r,[i]:{url:a}},t.push(`${e.name}: ${i}.url = ${a}`))}return r===e.servers?e:{...e,servers:r}});return{cfg:{...e,workspaces:n},changes:t}},ft=e=>{if(!process.stdout.isTTY)return e;let t=process.stdout.columns||80;return e.split(`
|
|
100
100
|
`).map(e=>{if(!e.startsWith(`- `)&&!e.startsWith(`+ `))return e;let n=` `.repeat(Math.max(0,t-e.length));return`\x1b[${e.startsWith(`- `)?`48;2;48;27;31;38;2;248;81;73`:`48;2;18;38;30;38;2;63;185;80`}m${e}${n}\x1b[0m`}).join(`
|
|
101
|
-
`)},
|
|
101
|
+
`)},pt=`Show what \`${Z} apply\` would change: a diff of each managed
|
|
102
102
|
artifact (the zsh hook, git includes, and .mcp.json files) against what your
|
|
103
103
|
config would generate. Read-only.
|
|
104
104
|
|
|
@@ -111,7 +111,7 @@ Usage:
|
|
|
111
111
|
|
|
112
112
|
Options:
|
|
113
113
|
--adopt Write config-expressible on-disk settings back into the config
|
|
114
|
-
-h, --help Display help message`,
|
|
114
|
+
-h, --help Display help message`,mt=e=>{let{values:n}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`},adopt:{type:`boolean`}},args:e});n.help&&(console.log(pt),process.exit(0)),v()||(console.error(`No config found. Run \`${Z} init\` first.`),process.exit(1));let r=y();if(n.adopt){let{cfg:e,changes:t}=dt(r);t.length||(console.log(`Nothing to adopt: the config already covers your .mcp.json settings.`),process.exit(0)),ie(e),b(e),console.log(`Adopted into config:`);for(let e of t)console.log(` ${e}`);console.log(`\nRun ${F(`${Z} apply`)} to regenerate from the updated config.`),process.exit(0)}let i=lt(r);i.length||(console.log("In sync. `apply` would change nothing."),process.exit(0));for(let e of i)console.log(`\n${F(`${l(e.path)} (${e.label})`)}`),e.error?console.log(I(` ${e.error}`)):console.log(ft(ut(e.current,e.next)));let{changes:a}=dt(r);if(a.length){console.log("\nThese .mcp.json settings aren't in your config, so `apply` would drop them:");for(let e of a)console.log(` ${e}`);console.log(`\nRun ${F(`${Z} diff --adopt`)} to keep them by writing them into the config.`)}process.exit(0)},ht=t=>{try{return e.readFileSync(t,`utf8`)}catch{return null}},gt=e=>{let t=[],n=e?.mcpServers;if(!n||typeof n!=`object`)return t;for(let[e,r]of Object.entries(n)){let n=Array.isArray(r?.args)?r.args:[];if(n.some(e=>typeof e==`string`&&e.endsWith(`@latest`)))t.push(e);else if(r?.command===`npx`){let r=n.find(e=>typeof e==`string`&&!e.startsWith(`-`));r&&!r.includes(`@`)&&t.push(e)}}return t},_t=(e,t=process.cwd())=>{let r=n.resolve(t),i,a=-1;for(let t of e.workspaces){let e=u(t.path);(r===e||r.startsWith(e+n.sep))&&e.length>a&&(i=t,a=e.length)}return i},vt=(e=A)=>{let t=e(`gh`,[`api`,`user`,`--jq`,`.login`]),n=e(`git`,[`config`,`user.email`]);return{pwd:process.cwd(),gh:t.status===0&&t.stdout.trim()?t.stdout.trim():`none`,gitEmail:n.status===0?n.stdout.trim():`none`,tokenSet:!!process.env.GITHUB_TOKEN}},yt=(t,n=A)=>{let r=[];he()||r.push({status:`warn`,label:`platform`,detail:`inscope's secret resolution targets macOS (gh keyring + Keychain)`});let i=p(),a=ht(i);a===null?r.push({status:`fail`,label:`hook`,detail:`missing ${i}; run \`inscope init\``}):a===Y(t)?r.push({status:`ok`,label:`hook`,detail:i}):r.push({status:`warn`,label:`hook`,detail:"out of date; run `inscope apply`"}),r.push(qe()?{status:`ok`,label:`zshrc`,detail:`sources the hook`}:{status:`warn`,label:`zshrc`,detail:"does not source the hook; run `inscope init`"}),t.workspaces.some(q)&&r.push(Fe(h(),K)===null?{status:`fail`,label:`gitconfig`,detail:"missing includeIf block; run `inscope apply`"}:{status:`ok`,label:`gitconfig`,detail:`includeIf block present`});for(let i of t.workspaces){let t=`[${i.name}]`;if(i.gh&&r.push(ge(i.gh,n)?{status:`ok`,label:`${t} gh`,detail:`token for ${i.gh}`}:{status:`fail`,label:`${t} gh`,detail:`no token for ${i.gh}; run \`gh auth login\``}),i.servers.slack){let e=i.servers.slack.keychain;r.push(M(e,n)?{status:`ok`,label:`${t} slack`,detail:e}:{status:`fail`,label:`${t} slack`,detail:`${e} not in keychain; run \`${xe(e)}\``})}if(q(i)){let a=J(i.name);if(!e.existsSync(a))r.push({status:`fail`,label:`${t} git`,detail:`missing ${a}; run \`inscope apply\``});else if(i.git?.email){let e=Se(a,n);r.push(e===i.git.email?{status:`ok`,label:`${t} git`,detail:i.git.email}:{status:`fail`,label:`${t} git`,detail:`email is ${e??`unset`}, expected ${i.git.email}`})}}let a=ct(i);if(a)r.push({status:`fail`,label:`${t} mcp`,detail:a});else{let e=fe(i);if(e===null)r.push({status:`warn`,label:`${t} mcp`,detail:"no .mcp.json; run `inscope apply`"});else{let n=O(i.name).filter(t=>e.mcpServers?.[t]);r.push({status:`ok`,label:`${t} mcp`,detail:`${n.length} server(s)`}),ht(k(i))!==st(i)&&r.push({status:`warn`,label:`${t} mcp`,detail:"out of date; run `inscope diff`"});let a=gt(e);a.length&&r.push({status:`warn`,label:`${t} mcp`,detail:`unpinned: ${a.join(`, `)}`})}}}return r},bt=`Verify the setup: gh tokens resolve, keychain entries exist,
|
|
115
115
|
git emails match per path, the hook is current, and no MCP server is unpinned.
|
|
116
116
|
Exits non-zero if any check fails.
|
|
117
117
|
|
|
@@ -119,8 +119,8 @@ Usage:
|
|
|
119
119
|
$ ${Z} doctor
|
|
120
120
|
|
|
121
121
|
Options:
|
|
122
|
-
-h, --help Display help message`,
|
|
123
|
-
`);console.log(`\n${a}`);let o=
|
|
122
|
+
-h, --help Display help message`,xt={ok:`✓`,warn:`!`,fail:`✗`},St={ok:we,warn:Te,fail:I},Ct=e=>{let{values:n}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`}},args:e});n.help&&(console.log(bt),process.exit(0)),v()||(console.error(`No config found. Run \`${Z} init\` first.`),process.exit(1));let r=y(),i=yt(r),a=i.map(e=>`${St[e.status](xt[e.status])} ${e.label}${e.detail?` ${e.detail}`:``}`).join(`
|
|
123
|
+
`);console.log(`\n${a}`);let o=_t(r);if(o){let e=vt();console.log(`\nThis shell (${o.name}):`),console.log(` pwd ${e.pwd}`),console.log(` gh ${e.gh}`),console.log(` git ${e.gitEmail}`),console.log(` token ${e.tokenSet?`set`:`unset`}`)}let s=i.filter(e=>e.status===`fail`).length;s&&(console.log(`\n${I(`${s} check(s) failed.`)}`),process.exit(1)),console.log(`\n${we(`All checks passed.`)}`),process.exit(0)},wt=`Edit a configured workspace interactively, then re-apply.
|
|
124
124
|
Pick a workspace (or pass its path/label), step through the prompts pre-filled
|
|
125
125
|
with its current values, and inscope regenerates everything on save.
|
|
126
126
|
|
|
@@ -128,25 +128,25 @@ Usage:
|
|
|
128
128
|
$ ${Z} edit [path|label]
|
|
129
129
|
|
|
130
130
|
Options:
|
|
131
|
-
-h, --help Display help message`,
|
|
132
|
-
Slack uses a user OAuth (xoxp) token.`),b=await z(`Slack keychain service`,b),x=await B(`Allow Slack to post messages?`,x),M(b)||(S=await B(`Store the Slack token now?`,!0))),_){let e=w(b);e&&(console.error(`\nInvalid Slack keychain service "${b}": ${e}`),process.exit(1))}let C={name:o.name,path:o.path,gh:c,git:d||m?{email:d,name:m}:void 0,servers:
|
|
131
|
+
-h, --help Display help message`,Tt=async e=>{let{positionals:n,values:r}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`}},args:e});r.help&&(console.log(wt),process.exit(0)),v()||(console.error(`No config found. Run \`${Z} init\` first.`),process.exit(1));let i=y();i.workspaces.length||(console.error(`No workspaces yet. Add one with \`${Z} add <path>\`.`),process.exit(1));let a=n[0],o=await(async()=>{if(a){let e=T(i,a);return e||(console.error(`No workspace matching "${a}".`),process.exit(1)),e}if(i.workspaces.length===1)return i.workspaces[0];if(N())return V(`Edit which workspace?`,i.workspaces.map(e=>({label:`${e.name} (${e.path})`,value:e})));console.error(`Specify a workspace, e.g. \`${Z} edit <label>\`.`),process.exit(1)})();console.log(`\nEditing "${o.name}" (${o.path})\n`);let s=[...ve().map(e=>({label:e,value:e})),{label:`(none)`,value:``}],c=await V(`GitHub account`,s,Math.max(0,s.findIndex(e=>e.value===(o.gh??``))))||void 0,l=o.git?.email,u=await z(l?`Git email (enter keeps ${l}, "-" to inherit global)`:`Git email (enter to inherit global)`,l??``),d=u===`-`?void 0:u||void 0,f=o.git?.name,p=await z(f?`Git name (enter keeps ${f}, "-" to inherit global)`:`Git name (enter to inherit global)`,f??``),m=p===`-`?void 0:p||void 0,h=Xe(o.servers),g=await Ae(`MCP servers (space toggles, enter confirms)`,Je.map(e=>({label:e,value:e,checked:h.includes(e)}))),_=g.includes(`slack`),b=o.servers.slack?o.servers.slack.keychain:Ye(o.name),x=o.servers.slack?!!o.servers.slack.addMessageTool:!1,S=!1;if(_&&(console.log(`
|
|
132
|
+
Slack uses a user OAuth (xoxp) token.`),b=await z(`Slack keychain service`,b),x=await B(`Allow Slack to post messages?`,x),M(b)||(S=await B(`Store the Slack token now?`,!0))),_){let e=w(b);e&&(console.error(`\nInvalid Slack keychain service "${b}": ${e}`),process.exit(1))}let C={name:o.name,path:o.path,gh:c,git:d||m?{email:d,name:m}:void 0,servers:Ze(g,_?{keychain:b,addMessageTool:x}:null)};Qe(C),console.log(`\n✓ updated "${C.name}" -> ${C.path}`),await $e(C,S),console.log(`\nRelaunch \`claude\` from ${C.path} to pick up the changes.`),process.exit(0)},Et=`Set up inscope: create the config, generate the chpwd hook, and
|
|
133
133
|
source it from ~/.zshrc. Safe to run again; it never overwrites your config.
|
|
134
134
|
|
|
135
135
|
Usage:
|
|
136
136
|
$ ${Z} init
|
|
137
137
|
|
|
138
138
|
Options:
|
|
139
|
-
-h, --help Display help message`,
|
|
139
|
+
-h, --help Display help message`,Dt=e=>{let{values:n}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`}},args:e});n.help&&(console.log(Et),process.exit(0));let r;v()?(r=y(),console.log(`\nUsing existing config at ${f()}`)):(r=_(),b(r),console.log(`\nCreated ${f()}`)),X(r),console.log(`Generated the chpwd hook and added a source line to ~/.zshrc.`),console.log(`
|
|
140
140
|
Next steps:
|
|
141
141
|
1. Reload your shell: source ~/.zshrc (or open a new terminal)
|
|
142
|
-
2. Map a workspace: ${Z} add ~/acme`),process.exit(0)},
|
|
142
|
+
2. Map a workspace: ${Z} add ~/acme`),process.exit(0)},Ot=`List the configured workspaces. Run \`${Z} doctor\` to verify
|
|
143
143
|
that their tokens and identities actually resolve.
|
|
144
144
|
|
|
145
145
|
Usage:
|
|
146
146
|
$ ${Z} list
|
|
147
147
|
|
|
148
148
|
Options:
|
|
149
|
-
-h, --help Display help message`,
|
|
149
|
+
-h, --help Display help message`,kt=e=>D.filter(t=>!!e[t]).join(`, `)||`none`,At=e=>{let{values:n}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`}},args:e});n.help&&(console.log(Ot),process.exit(0)),v()||(console.error(`No config found. Run \`${Z} init\` first.`),process.exit(1));let r=y();r.workspaces.length||(console.log(`No workspaces yet. Add one with \`${Z} add <path> --gh <account>\`.`),process.exit(0));for(let e of r.workspaces)console.log(`\n${e.name}`),console.log(` path ${e.path}`),console.log(` gh ${e.gh??`(none)`}`),console.log(` git ${e.git?.email??`(default)`}`),console.log(` servers ${kt(e.servers)}`),e.servers.slack&&console.log(` slack keychain: ${e.servers.slack.keychain}`);process.exit(0)},jt=`Remove a workspace mapping. Drops its git include and the MCP
|
|
150
150
|
servers inscope manages; leaves your keychain and gh accounts untouched. Pick a
|
|
151
151
|
workspace, or pass its path/label.
|
|
152
152
|
|
|
@@ -155,8 +155,8 @@ Usage:
|
|
|
155
155
|
|
|
156
156
|
Options:
|
|
157
157
|
-y, --yes Skip the type-the-label confirmation
|
|
158
|
-
-h, --help Display help message`,
|
|
159
|
-
${Z}@${
|
|
158
|
+
-h, --help Display help message`,Mt=async e=>{let{positionals:n,values:r}=t({allowPositionals:!0,options:{help:{type:`boolean`,short:`h`},yes:{type:`boolean`,short:`y`}},args:e});r.help&&(console.log(jt),process.exit(0)),v()||(console.error(`No config found. Run \`${Z} init\` first.`),process.exit(1));let i=y();i.workspaces.length||(console.error(`No workspaces to remove.`),process.exit(1));let a=n[0],o;if(a){let e=T(i,a);e||(console.error(`No workspace matching "${a}".`),process.exit(1)),o=e}else N()?o=await V(`Remove which workspace?`,i.workspaces.map(e=>({label:`${e.name} (${e.path})`,value:e}))):(console.error(`Specify a workspace, e.g. \`${Z} rm <label>\`.`),process.exit(1));if(!r.yes){console.log(`\n⚠ Removing "${o.name}" (${o.path}) unmaps it from inscope.`);let e=await z(`Type "${o.name}" to confirm`);e!==o.name&&(console.error(`Aborted: "${e}" does not match "${o.name}".`),process.exit(1))}let{cfg:s}=se(i,o.name);me(o),Be(o.name),b(s),X(s),console.log(`\n✓ removed workspace "${o.name}"`),o.servers.slack&&console.log(`\nNote: the keychain entry ${o.servers.slack.keychain} was left in place.\nDelete it with: ${F(`security delete-generic-password -s ${o.servers.slack.keychain}`)}`),process.exit(0)},Nt=`Version:
|
|
159
|
+
${Z}@${et}
|
|
160
160
|
|
|
161
161
|
Per-workspace identity for Claude Code: scope MCP servers, GitHub auth, and git
|
|
162
162
|
commit identity to the directory you are in, so concurrent sessions never clash.
|
|
@@ -179,4 +179,4 @@ Options:
|
|
|
179
179
|
-h, --help Display help
|
|
180
180
|
|
|
181
181
|
Author:
|
|
182
|
-
${Q.name} <${Q.email}> (${Q.url})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return
|
|
182
|
+
${Q.name} <${Q.email}> (${Q.url})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return Dt(n);case`add`:return await rt(n);case`edit`:return Tt(n);case`rm`:case`remove`:return await Mt(n);case`ls`:case`list`:return At(n);case`diff`:return mt(n);case`apply`:case`sync`:return at(n);case`doctor`:return Ct(n)}(t===`-v`||t===`--version`)&&(console.log(`${Z}@${et}`),process.exit(0)),(!t||t===`-h`||t===`--help`)&&(console.log(Nt),process.exit(0)),console.error(`unknown command: ${e.join(` `)}\n`),console.error(Nt),process.exit(1)}catch(e){console.error(e.message),process.exit(1)}})();export{};
|
package/dist/index.d.mts
CHANGED
|
@@ -46,6 +46,8 @@ declare const WORKSPACE_NAME_RE: RegExp;
|
|
|
46
46
|
declare const workspaceNameError: (name: string) => string | null;
|
|
47
47
|
declare const hookValueError: (value: string) => string | null;
|
|
48
48
|
declare const workspacePathError: (p: string) => string | null;
|
|
49
|
+
declare const gitValueError: (value: string) => string | null;
|
|
50
|
+
declare const configVersionError: (cfg: Config) => string | null;
|
|
49
51
|
declare const slugify: (s: string) => string;
|
|
50
52
|
declare const validateConfig: (cfg: Config) => void;
|
|
51
53
|
declare const labelFromPath: (p: string) => string;
|
|
@@ -140,4 +142,4 @@ declare const readMcp: (ws: Workspace) => Record<string, any> | null;
|
|
|
140
142
|
declare const applyMcp: (ws: Workspace) => void;
|
|
141
143
|
declare const removeMcp: (ws: Workspace) => void;
|
|
142
144
|
//#endregion
|
|
143
|
-
export { ApplyResult, CONFIG_VERSION, Check, CheckStatus, Config, Drift, HttpServer, RunResult, Runner, SLACK_MCP_VERSION, Servers, SlackServer, WORKSPACE_NAME_RE, Workspace, adoptable, applyAll, applyGitconfig, applyMcp, computeDrift, configExists, currentWorkspace, defaultConfig, defaultRunner, diffLines, ensureZshrcSource, findWorkspace, ghAccounts, ghStatus, ghToken, gitEmailForFile, gitGlobal, hookValueError, isMacOS, keychainHas, keychainSet, keychainSetCommand, labelFromPath, liveSnapshot, loadConfig, managedKeys, mcpError, mcpFilePath, mcpTarget, readMcp, removeMcp, removeWorkspace, renderGitInclude, renderHook, renderMcp, renderPerWorkspaceGitconfig, renderServers, renderZshrcSource, runDoctor, saveConfig, slugify, upsertWorkspace, validateConfig, workspaceNameError, workspacePathError, zshrcSourcesHook };
|
|
145
|
+
export { ApplyResult, CONFIG_VERSION, Check, CheckStatus, Config, Drift, HttpServer, RunResult, Runner, SLACK_MCP_VERSION, Servers, SlackServer, WORKSPACE_NAME_RE, Workspace, adoptable, applyAll, applyGitconfig, applyMcp, computeDrift, configExists, configVersionError, currentWorkspace, defaultConfig, defaultRunner, diffLines, ensureZshrcSource, findWorkspace, ghAccounts, ghStatus, ghToken, gitEmailForFile, gitGlobal, gitValueError, hookValueError, isMacOS, keychainHas, keychainSet, keychainSetCommand, labelFromPath, liveSnapshot, loadConfig, managedKeys, mcpError, mcpFilePath, mcpTarget, readMcp, removeMcp, removeWorkspace, renderGitInclude, renderHook, renderMcp, renderPerWorkspaceGitconfig, renderServers, renderZshrcSource, runDoctor, saveConfig, slugify, upsertWorkspace, validateConfig, workspaceNameError, workspacePathError, zshrcSourcesHook };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import n from"node:os";import{spawnSync as r}from"node:child_process";const i=()=>n.homedir(),a=()=>process.env.XDG_CONFIG_HOME?.trim()||t.join(i(),`.config`),o=e=>e===`~`?i():e.startsWith(`~/`)?t.join(i(),e.slice(2)):e,s=e=>{let n=o(e),r=i();return n===r?`~`:n.startsWith(r+t.sep)?`~/`+n.slice(r.length+1):n},c=e=>t.resolve(o(e)),l=()=>t.join(a(),`inscope`),u=()=>t.join(l(),`inscope.json`),d=()=>t.join(l(),`inscope.zsh`),f=()=>t.join(l(),`git`),p=()=>t.join(i(),`.gitconfig`),m=()=>t.join(i(),`.zshrc`),ee=1,te=()=>({version:1,workspaces:[]}),ne=()=>e.existsSync(u()),re=()=>{let t=u(),n=e.readFileSync(t,`utf8`),r=JSON.parse(n);try{
|
|
2
|
-
`)},h=/^[A-Za-z0-9._-]+$/,g=e=>e?h.test(e)?null:`use only letters, digits, dot (.), dash (-), or underscore (_)`:`must not be empty`,ae=/["`$\n]/,_=e=>ae.test(e)?'must not contain a quote ("), backtick (`), $, or newline':null,v=e=>e?_(e):`must not be empty`,y=e=>e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-.]+|[-.]+$/g,``),
|
|
1
|
+
import e from"node:fs";import t from"node:path";import n from"node:os";import{spawnSync as r}from"node:child_process";const i=()=>n.homedir(),a=()=>process.env.XDG_CONFIG_HOME?.trim()||t.join(i(),`.config`),o=e=>e===`~`?i():e.startsWith(`~/`)?t.join(i(),e.slice(2)):e,s=e=>{let n=o(e),r=i();return n===r?`~`:n.startsWith(r+t.sep)?`~/`+n.slice(r.length+1):n},c=e=>t.resolve(o(e)),l=()=>t.join(a(),`inscope`),u=()=>t.join(l(),`inscope.json`),d=()=>t.join(l(),`inscope.zsh`),f=()=>t.join(l(),`git`),p=()=>t.join(i(),`.gitconfig`),m=()=>t.join(i(),`.zshrc`),ee=1,te=()=>({version:1,workspaces:[]}),ne=()=>e.existsSync(u()),re=()=>{let t=u(),n=e.readFileSync(t,`utf8`),r=JSON.parse(n),i=b(r);if(i)throw Error(i);try{S(r)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`${n}\nFix it in ${s(t)}, then re-run.`)}return r},ie=n=>{S(n);let r=u();e.mkdirSync(t.dirname(r),{recursive:!0}),e.writeFileSync(r,JSON.stringify(n,null,2)+`
|
|
2
|
+
`)},h=/^[A-Za-z0-9._-]+$/,g=e=>e?h.test(e)?null:`use only letters, digits, dot (.), dash (-), or underscore (_)`:`must not be empty`,ae=/["`$\n]/,_=e=>ae.test(e)?'must not contain a quote ("), backtick (`), $, or newline':null,v=e=>e?_(e):`must not be empty`,y=e=>/[\n\r]/.test(e)?`must not contain a newline`:null,b=e=>typeof e.version==`number`&&e.version>1?`config version ${e.version} is newer than this inscope supports (max 1); upgrade inscope`:null,x=e=>e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-.]+|[-.]+$/g,``),S=e=>{if(!e||typeof e!=`object`)throw Error(`config is not an object`);let t=b(e);if(t)throw Error(t);if(!Array.isArray(e.workspaces))throw Error(`config.workspaces must be an array`);let n=new Set;for(let t of e.workspaces){if(!t.name)throw Error(`a workspace is missing a name`);let e=g(t.name);if(e)throw Error(`workspace name "${t.name}" is invalid: ${e}`);if(!t.path)throw Error(`workspace "${t.name}" is missing a path`);let r=v(t.path);if(r)throw Error(`workspace "${t.name}" path "${t.path}" is invalid: ${r}`);if(t.gh){let e=_(t.gh);if(e)throw Error(`workspace "${t.name}" gh account "${t.gh}" is invalid: ${e}`)}if(t.git?.email){let e=y(t.git.email);if(e)throw Error(`workspace "${t.name}" git email "${t.git.email}" is invalid: ${e}`)}if(t.git?.name){let e=y(t.git.name);if(e)throw Error(`workspace "${t.name}" git name "${t.git.name}" is invalid: ${e}`)}let i=t.servers?.slack;if(i&&i.keychain){let e=_(i.keychain);if(e)throw Error(`workspace "${t.name}" Slack keychain "${i.keychain}" is invalid: ${e}`)}if(n.has(t.name))throw Error(`duplicate workspace name "${t.name}"`);n.add(t.name)}},oe=e=>x(t.basename(c(e)))||`workspace`,C=(e,t)=>{let n=e.workspaces.find(e=>e.name===t);if(n)return n;let r=c(t);return e.workspaces.find(e=>c(e.path)===r)},se=(e,t)=>{let n=e.workspaces.filter(e=>e.name!==t.name);return n.push({...t,path:s(t.path)}),n.sort((e,t)=>e.name.localeCompare(t.name)),{...e,workspaces:n}},ce=(e,t)=>{let n=C(e,t);return n?{cfg:{...e,workspaces:e.workspaces.filter(e=>e.name!==n.name)},removed:n}:{cfg:e}},w=e=>`# >>> inscope:${e} >>>`,T=e=>`# <<< inscope:${e} <<<`,E=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),le=e=>RegExp(`${E(w(e))}\\n[\\s\\S]*?\\n${E(T(e))}\\n?`),ue=(e,t)=>{let n=t.replace(/\n+$/,``);return`${w(e)}\n${n}\n${T(e)}\n`},D=t=>{try{return e.readFileSync(t,`utf8`)}catch{return``}},de=(n,r,i)=>{e.mkdirSync(t.dirname(n),{recursive:!0});let a=D(n),o=ue(r,i),s=le(r),c;if(s.test(a))c=a.replace(s,o);else{let e=a.replace(/\n*$/,``);c=e.length?`${e}\n\n${o}`:o}e.writeFileSync(n,c)},fe=(t,n)=>{let r=D(t);if(!r)return;let i=r.replace(le(n),``).replace(/\n{3,}/g,`
|
|
3
3
|
|
|
4
|
-
`).replace(/^\n+/,``);e.writeFileSync(t,i)},
|
|
5
|
-
`),
|
|
4
|
+
`).replace(/^\n+/,``);e.writeFileSync(t,i)},O=(e,t)=>{let n=D(e).match(RegExp(`${E(w(t))}\\n([\\s\\S]*?)\\n${E(T(t))}`));return n?n[1]:null},k=`gitconfig`,A=e=>!!(e.git&&(e.git.email||e.git.name)),j=e=>t.join(f(),`${e}.gitconfig`),pe=e=>s(e).replace(/\/+$/,``)+`/`,M=e=>e.workspaces.filter(A).map(e=>`[includeIf "gitdir:${pe(e.path)}"]\n\tpath = ${s(j(e.name))}`).join(`
|
|
5
|
+
`),N=e=>{let t=[`# Managed by inscope. Do not edit by hand.`,`[user]`];return e.git?.email&&t.push(`\temail = ${e.git.email}`),e.git?.name&&t.push(`\tname = ${e.git.name}`),t.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`},
|
|
7
|
+
`},P=t=>{e.mkdirSync(f(),{recursive:!0});for(let n of t.workspaces)A(n)&&e.writeFileSync(j(n.name),N(n));let n=M(t);n?de(p(),k,n):fe(p(),k)},me=e=>{let t=s(e);return t===`~`?`"$HOME/"*`:t.startsWith(`~/`)?`"$HOME/${t.slice(2)}/"*`:`"${t}/"*`},he=e=>e.servers.slack?e.servers.slack.keychain:``,F=e=>{let t=[...e.workspaces].sort((e,t)=>e.name.localeCompare(t.name));return`# Managed by inscope. Do not edit by hand.
|
|
8
8
|
# Source of truth: ~/.config/inscope/inscope.json
|
|
9
9
|
# Edit there, then run \`inscope apply\` to regenerate this file.
|
|
10
10
|
#
|
|
@@ -15,7 +15,7 @@ import e from"node:fs";import t from"node:path";import n from"node:os";import{sp
|
|
|
15
15
|
__inscope_resolve_identity() {
|
|
16
16
|
local ws
|
|
17
17
|
case "\${PWD}/" in
|
|
18
|
-
${t.map(e=>` ${me(e.path)}) ws="${e.name}" ;;`).join(`
|
|
18
|
+
${[...t].sort((e,t)=>s(t.path).length-s(e.path).length).map(e=>` ${me(e.path)}) ws="${e.name}" ;;`).join(`
|
|
19
19
|
`)||` # no workspaces configured`}
|
|
20
20
|
*) ws="" ;;
|
|
21
21
|
esac
|
|
@@ -51,10 +51,10 @@ autoload -Uz add-zsh-hook
|
|
|
51
51
|
add-zsh-hook chpwd __inscope_resolve_identity
|
|
52
52
|
__inscope_ws="__init__" # force the first resolve, clearing any inherited token
|
|
53
53
|
__inscope_resolve_identity
|
|
54
|
-
`},
|
|
55
|
-
`)},ye=t=>{let n=
|
|
56
|
-
`)},be=e=>{let n=i();return e===n?`$HOME`:e.startsWith(n+t.sep)?`$HOME/${e.slice(n.length+1)}`:e},
|
|
57
|
-
`},X=t=>{let n=
|
|
54
|
+
`},I=`1.3.0`,L={atlassian:`https://mcp.atlassian.com/v1/mcp`,canva:`https://mcp.canva.com/mcp`,clickup:`https://mcp.clickup.com/mcp`,hubspot:`https://mcp.hubspot.com`,intercom:`https://mcp.intercom.com/mcp`,linear:`https://mcp.linear.app/mcp`,monday:`https://mcp.monday.com/mcp`,notion:`https://mcp.notion.com/mcp`,plane:`https://mcp.plane.so/http/mcp`,sentry:`https://mcp.sentry.dev/mcp`,stripe:`https://mcp.stripe.com`,vercel:`https://mcp.vercel.com`,webflow:`https://mcp.webflow.com/`},R=[`github`,`atlassian`,`canva`,`clickup`,`hubspot`,`intercom`,`linear`,`monday`,`notion`,`plane`,`sentry`,`slack`,`stripe`,`vercel`,`webflow`],z=e=>R.map(t=>`${t}-${e}`),B=e=>t.join(c(e.path),`.mcp.json`),ge=(e,t)=>e&&typeof e==`object`&&e.url?e.url:t,V=e=>{let t=e.servers,n={};for(let r of R){let i=t[r];if(!i)continue;let a=`${r}-${e.name}`;if(r===`github`)n[a]={type:`http`,url:`https://api.githubcopilot.com/mcp/`,headers:{Authorization:"Bearer ${GITHUB_TOKEN}"}};else if(r===`slack`){let e=i,t={SLACK_MCP_XOXP_TOKEN:"${SLACK_MCP_XOXP_TOKEN}"};e.addMessageTool&&(t.SLACK_MCP_ADD_MESSAGE_TOOL=`true`),n[a]={type:`stdio`,command:`npx`,args:[`-y`,`slack-mcp-server@${I}`,`--transport`,`stdio`],env:t}}else n[a]={type:`http`,url:ge(i,L[r])}}return n},_e=e=>({mcpServers:V(e)}),ve=t=>{if(!e.existsSync(t))return{};try{return JSON.parse(e.readFileSync(t,`utf8`))}catch{return{}}},H=t=>{if(!e.existsSync(t))return{};try{return JSON.parse(e.readFileSync(t,`utf8`))}catch{throw Error(`${t} is not valid JSON; fix or remove it, then re-run inscope (left it untouched)`)}},U=t=>{let n=B(t);return e.existsSync(n)?ve(n):null},W=n=>{let r=B(n);e.mkdirSync(t.dirname(r),{recursive:!0});let i=H(r),a=i.mcpServers&&typeof i.mcpServers==`object`?{...i.mcpServers}:{};for(let e of z(n.name))delete a[e];Object.assign(a,V(n)),i.mcpServers=a,e.writeFileSync(r,JSON.stringify(i,null,2)+`
|
|
55
|
+
`)},ye=t=>{let n=B(t);if(!e.existsSync(n))return;let r=H(n);if(r.mcpServers&&typeof r.mcpServers==`object`)for(let e of z(t.name))delete r.mcpServers[e];e.writeFileSync(n,JSON.stringify(r,null,2)+`
|
|
56
|
+
`)},be=e=>{let n=i();return e===n?`$HOME`:e.startsWith(n+t.sep)?`$HOME/${e.slice(n.length+1)}`:e},xe=()=>{let e=be(d());return`[ -r "${e}" ] && source "${e}"`},G=e=>{let t=xe();if(e.includes(t))return e;let n=e.replace(/\n*$/,``),r=`# inscope: load each workspace's tokens (GitHub, Slack) from \$PWD on every cd\n${t}`;return n.length?`${n}\n\n${r}\n`:`${r}\n`},K=()=>{let t=m(),n=``;try{n=e.readFileSync(t,`utf8`)}catch{}let r=G(n);r!==n&&e.writeFileSync(t,r)},q=()=>{try{return e.readFileSync(m(),`utf8`).includes(xe())}catch{return!1}},Se=n=>{let r=d();e.mkdirSync(t.dirname(r),{recursive:!0}),e.writeFileSync(r,F(n)),P(n),K();let i=[];for(let e of n.workspaces)W(e),i.push(B(e));return{hook:r,gitconfig:n.workspaces.some(e=>e.git?.email||e.git?.name),mcp:i}},J=t=>{try{return e.readFileSync(t,`utf8`)}catch{return``}},Ce=e=>{let t=J(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},Y=e=>{let t=Ce(B(e))??{},n=t.mcpServers&&typeof t.mcpServers==`object`?{...t.mcpServers}:{};for(let t of z(e.name))delete n[t];return Object.assign(n,V(e)),t.mcpServers=n,JSON.stringify(t,null,2)+`
|
|
57
|
+
`},X=t=>{let n=B(t);if(!e.existsSync(n))return null;try{return JSON.parse(e.readFileSync(n,`utf8`)),null}catch{return"invalid JSON; `apply` will not touch it until you fix it"}},we=e=>{let t=[],n=d();t.push({label:`hook`,path:n,current:J(n),next:F(e)}),t.push({label:`gitconfig`,path:p(),current:O(p(),k)??``,next:M(e)});for(let n of e.workspaces){if(!A(n))continue;let e=j(n.name);t.push({label:`gitconfig:${n.name}`,path:e,current:J(e),next:N(n)})}for(let n of e.workspaces){let e=B(n),r=X(n);if(r){t.push({label:`mcp:${n.name}`,path:e,current:``,next:``,error:r});continue}t.push({label:`mcp:${n.name}`,path:e,current:J(e),next:Y(n)})}return t.filter(e=>e.error!=null||e.current!==e.next)},Te=(e,t)=>{let n=e.length?e.split(`
|
|
58
58
|
`):[],r=t.length?t.split(`
|
|
59
59
|
`):[],i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array.from({length:a+1},()=>0));for(let e=i-1;e>=0;e--)for(let t=a-1;t>=0;t--)o[e][t]=n[e]===r[t]?o[e+1][t+1]+1:Math.max(o[e+1][t],o[e][t+1]);let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push(` ${n[c]}`),c++,l++):o[c+1][l]>=o[c][l+1]?(s.push(`- ${n[c]}`),c++):(s.push(`+ ${r[l]}`),l++);for(;c<i;)s.push(`- ${n[c++]}`);for(;l<a;)s.push(`+ ${r[l++]}`);return s.join(`
|
|
60
|
-
`)},
|
|
60
|
+
`)},Ee=e=>{let t=[],n=e.workspaces.map(e=>{let n=Ce(B(e))?.mcpServers;if(!n||typeof n!=`object`)return e;let r=e.servers,i=e.servers.slack;i&&!i.addMessageTool&&n[`slack-${e.name}`]?.env?.SLACK_MCP_ADD_MESSAGE_TOOL===`true`&&(r={...r,slack:{...i,addMessageTool:!0}},t.push(`${e.name}: slack.addMessageTool = true`));for(let i of R){if(i===`github`||i===`slack`)continue;let a=n[`${i}-${e.name}`]?.url;if(typeof a!=`string`)continue;let o=e.servers[i];if(!o){r={...r,[i]:a===L[i]?!0:{url:a}},t.push(`${e.name}: ${i} = ${a===L[i]?`enabled`:a}`);continue}a!==((typeof o==`object`?o.url:void 0)??L[i])&&(r={...r,[i]:{url:a}},t.push(`${e.name}: ${i}.url = ${a}`))}return r===e.servers?e:{...e,servers:r}});return{cfg:{...e,workspaces:n},changes:t}},Z=(e,t,n)=>{let i=r(e,t,{encoding:`utf8`,input:n?.input});return{status:i.status??(i.error?127:1),stdout:i.stdout??``,stderr:i.stderr??``}},De=()=>process.platform===`darwin`,Q=()=>process.env.USER||``,Oe=(e,t=Z)=>{let n=t(`gh`,[`auth`,`token`,`-u`,e]),r=n.stdout.trim();return n.status===0&&r?r:null},ke=(e=Z)=>{let t=e(`gh`,[`auth`,`status`]);return(t.stdout+t.stderr).trim()},Ae=(e=Z)=>{let t=[];for(let n of ke(e).matchAll(/account (\S+) \(/g))t.includes(n[1])||t.push(n[1]);return t},je=(e,t=Z)=>{let n=t(`git`,[`config`,`--global`,e]),r=n.stdout.trim();return n.status===0&&r?r:null},Me=(e,t=Z)=>{let n=t(`security`,[`find-generic-password`,`-a`,Q(),`-s`,e,`-w`]);return n.status===0&&n.stdout.trim().length>0},Ne=(e,t,n=Z)=>{let r=n(`security`,[`add-generic-password`,`-U`,`-a`,Q(),`-s`,e,`-w`,t]);if(r.status!==0)throw Error(`security add-generic-password failed: ${r.stderr.trim()||`unknown error`}`)},Pe=e=>`security add-generic-password -U -a "${Q()||`$USER`}" -s ${e} -w 'xoxp-...'`,Fe=(e,t=Z)=>{let n=t(`git`,[`config`,`--file`,e,`user.email`]);return n.status===0?n.stdout.trim():null},$=t=>{try{return e.readFileSync(t,`utf8`)}catch{return null}},Ie=e=>{let t=[],n=e?.mcpServers;if(!n||typeof n!=`object`)return t;for(let[e,r]of Object.entries(n)){let n=Array.isArray(r?.args)?r.args:[];if(n.some(e=>typeof e==`string`&&e.endsWith(`@latest`)))t.push(e);else if(r?.command===`npx`){let r=n.find(e=>typeof e==`string`&&!e.startsWith(`-`));r&&!r.includes(`@`)&&t.push(e)}}return t},Le=(e,n=process.cwd())=>{let r=t.resolve(n),i,a=-1;for(let n of e.workspaces){let e=c(n.path);(r===e||r.startsWith(e+t.sep))&&e.length>a&&(i=n,a=e.length)}return i},Re=(e=Z)=>{let t=e(`gh`,[`api`,`user`,`--jq`,`.login`]),n=e(`git`,[`config`,`user.email`]);return{pwd:process.cwd(),gh:t.status===0&&t.stdout.trim()?t.stdout.trim():`none`,gitEmail:n.status===0?n.stdout.trim():`none`,tokenSet:!!process.env.GITHUB_TOKEN}},ze=(t,n=Z)=>{let r=[];De()||r.push({status:`warn`,label:`platform`,detail:`inscope's secret resolution targets macOS (gh keyring + Keychain)`});let i=d(),a=$(i);a===null?r.push({status:`fail`,label:`hook`,detail:`missing ${i}; run \`inscope init\``}):a===F(t)?r.push({status:`ok`,label:`hook`,detail:i}):r.push({status:`warn`,label:`hook`,detail:"out of date; run `inscope apply`"}),r.push(q()?{status:`ok`,label:`zshrc`,detail:`sources the hook`}:{status:`warn`,label:`zshrc`,detail:"does not source the hook; run `inscope init`"}),t.workspaces.some(A)&&r.push(O(p(),k)===null?{status:`fail`,label:`gitconfig`,detail:"missing includeIf block; run `inscope apply`"}:{status:`ok`,label:`gitconfig`,detail:`includeIf block present`});for(let i of t.workspaces){let t=`[${i.name}]`;if(i.gh&&r.push(Oe(i.gh,n)?{status:`ok`,label:`${t} gh`,detail:`token for ${i.gh}`}:{status:`fail`,label:`${t} gh`,detail:`no token for ${i.gh}; run \`gh auth login\``}),i.servers.slack){let e=i.servers.slack.keychain;r.push(Me(e,n)?{status:`ok`,label:`${t} slack`,detail:e}:{status:`fail`,label:`${t} slack`,detail:`${e} not in keychain; run \`${Pe(e)}\``})}if(A(i)){let a=j(i.name);if(!e.existsSync(a))r.push({status:`fail`,label:`${t} git`,detail:`missing ${a}; run \`inscope apply\``});else if(i.git?.email){let e=Fe(a,n);r.push(e===i.git.email?{status:`ok`,label:`${t} git`,detail:i.git.email}:{status:`fail`,label:`${t} git`,detail:`email is ${e??`unset`}, expected ${i.git.email}`})}}let a=X(i);if(a)r.push({status:`fail`,label:`${t} mcp`,detail:a});else{let e=U(i);if(e===null)r.push({status:`warn`,label:`${t} mcp`,detail:"no .mcp.json; run `inscope apply`"});else{let n=z(i.name).filter(t=>e.mcpServers?.[t]);r.push({status:`ok`,label:`${t} mcp`,detail:`${n.length} server(s)`}),$(B(i))!==Y(i)&&r.push({status:`warn`,label:`${t} mcp`,detail:"out of date; run `inscope diff`"});let a=Ie(e);a.length&&r.push({status:`warn`,label:`${t} mcp`,detail:`unpinned: ${a.join(`, `)}`})}}}return r};export{ee as CONFIG_VERSION,I as SLACK_MCP_VERSION,h as WORKSPACE_NAME_RE,Ee as adoptable,Se as applyAll,P as applyGitconfig,W as applyMcp,we as computeDrift,ne as configExists,b as configVersionError,Le as currentWorkspace,te as defaultConfig,Z as defaultRunner,Te as diffLines,K as ensureZshrcSource,C as findWorkspace,Ae as ghAccounts,ke as ghStatus,Oe as ghToken,Fe as gitEmailForFile,je as gitGlobal,y as gitValueError,_ as hookValueError,De as isMacOS,Me as keychainHas,Ne as keychainSet,Pe as keychainSetCommand,oe as labelFromPath,Re as liveSnapshot,re as loadConfig,z as managedKeys,X as mcpError,B as mcpFilePath,Y as mcpTarget,U as readMcp,ye as removeMcp,ce as removeWorkspace,M as renderGitInclude,F as renderHook,_e as renderMcp,N as renderPerWorkspaceGitconfig,V as renderServers,G as renderZshrcSource,ze as runDoctor,ie as saveConfig,x as slugify,se as upsertWorkspace,S as validateConfig,g as workspaceNameError,v as workspacePathError,q as zshrcSourcesHook};
|