@chief-clancy/terminal 0.1.1 → 0.1.2

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
- "use strict";var E=require("node:fs");function r(){return{decision:"approve"}}function u(t){return{decision:"block",reason:t}}function p(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var l={};var k=0;function g(t){try{let e=JSON.parse(t);return p(e)?e:l}catch{return l}}function f(t){let e=t.argv[2];if(e)return g(e);try{let n=t.readFileSync(k,"utf8");return g(n)}catch{return l}}var i=["main","master","develop"],A=/\bgit\s+push\b/,R=/\s--force\b/,S=/\s-f\b/,b=/--force-with-lease/,T=/\bgit\s+reset\s+--hard\b/,O=/\bgit\s+clean\s+(.*)/,y=/(?:^|\s)-[a-zA-Z]*f/,P=/(?:^|\s)-[a-zA-Z]*n/,D=/\bgit\s+checkout\s+--\s+\./,F=/\bgit\s+restore\s+\.(?:\s*$|\s*[;&|])/,N=/\bgit\s+branch\s+.*-D\b/,x="Blocked: git push --force destroys remote history. Use --force-with-lease instead.",B=t=>`Blocked: direct push to protected branch '${t}'. Create a PR instead.`,L="Blocked: git reset --hard discards all uncommitted changes.",I="Blocked: git clean -f deletes untracked files. Use -n for a dry run first.",H="Blocked: git checkout -- . discards all unstaged changes.",U="Blocked: git restore . discards all unstaged changes.",M="Blocked: git branch -D force-deletes without merge check. Use -d for safe deletion.";function _(t){return t?i.includes(t)?[...i]:[...i,t]:[...i]}function G(t){let e=/\bgit\s+push\b[^&|;]*/.exec(t);return e?e[0]:null}function v(t){let e=G(t);if(!e)return null;let n=R.test(e)||S.test(e),o=b.test(e);return n&&!o?x:null}function J(t,e){if(!A.test(t))return null;let n=t.split(/\s+/),o=n.indexOf("push");if(o<0)return null;let c=(n.slice(o+1).filter(a=>!a.startsWith("-"))[1]??"").split(":")[0],h=e.find(a=>c===a);return h?B(h):null}function w(t){return T.test(t)?L:null}function Y(t){let e=O.exec(t);if(!e)return null;let n=e[1],o=y.test(n),s=P.test(n);return o&&!s?I:null}function j(t){return D.test(t)?H:null}function z(t){return F.test(t)?U:null}function K(t){return N.test(t)?M:null}function m(t,e){return t?[()=>v(t),()=>J(t,e),()=>w(t),()=>Y(t),()=>j(t),()=>z(t),()=>K(t)].map(s=>s()).find(Boolean)??null:null}try{process.env.CLANCY_BRANCH_GUARD==="false"&&(console.log(JSON.stringify(r())),process.exit(0));let e=f({argv:process.argv,readFileSync:E.readFileSync}),n=e.tool_name??"",o=e.tool_input??{},s=typeof o.command=="string"?o.command:"";n==="Bash"||(console.log(JSON.stringify(r())),process.exit(0));let d=_(process.env.CLANCY_BASE_BRANCH),c=m(s,d);console.log(JSON.stringify(c?u(c):r()))}catch{console.log(JSON.stringify(r()))}
1
+ "use strict";var _=require("node:fs");function r(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow"}}}function u(t){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:t}}}function p(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var l={};var C=0;function m(t){try{let e=JSON.parse(t);return p(e)?e:l}catch{return l}}function f(t){let e=t.argv[2];if(e)return m(e);try{let o=t.readFileSync(C,"utf8");return m(o)}catch{return l}}var i=["main","master","develop"],R=/\bgit\s+push\b/,S=/\s--force\b/,A=/\s-f\b/,T=/--force-with-lease/,b=/\bgit\s+reset\s+--hard\b/,O=/\bgit\s+clean\s+(.*)/,D=/(?:^|\s)-[a-zA-Z]*f/,P=/(?:^|\s)-[a-zA-Z]*n/,y=/\bgit\s+checkout\s+--\s+\./,N=/\bgit\s+restore\s+\.(?:\s*$|\s*[;&|])/,F=/\bgit\s+branch\s+.*-D\b/,x="Blocked: git push --force destroys remote history. Use --force-with-lease instead.",B=t=>`Blocked: direct push to protected branch '${t}'. Create a PR instead.`,L="Blocked: git reset --hard discards all uncommitted changes.",U="Blocked: git clean -f deletes untracked files. Use -n for a dry run first.",I="Blocked: git checkout -- . discards all unstaged changes.",H="Blocked: git restore . discards all unstaged changes.",M="Blocked: git branch -D force-deletes without merge check. Use -d for safe deletion.";function g(t){return t?i.includes(t)?[...i]:[...i,t]:[...i]}function G(t){let e=/\bgit\s+push\b[^&|;]*/.exec(t);return e?e[0]:null}function v(t){let e=G(t);if(!e)return null;let o=S.test(e)||A.test(e),n=T.test(e);return o&&!n?x:null}function w(t,e){if(!R.test(t))return null;let o=t.split(/\s+/),n=o.indexOf("push");if(n<0)return null;let c=(o.slice(n+1).filter(a=>!a.startsWith("-"))[1]??"").split(":")[0],d=e.find(a=>c===a);return d?B(d):null}function J(t){return b.test(t)?L:null}function Y(t){let e=O.exec(t);if(!e)return null;let o=e[1],n=D.test(o),s=P.test(o);return n&&!s?U:null}function j(t){return y.test(t)?I:null}function z(t){return N.test(t)?H:null}function K(t){return F.test(t)?M:null}function E(t,e){return t?[()=>v(t),()=>w(t,e),()=>J(t),()=>Y(t),()=>j(t),()=>z(t),()=>K(t)].map(s=>s()).find(Boolean)??null:null}try{process.env.CLANCY_BRANCH_GUARD==="false"&&(console.log(JSON.stringify(r())),process.exit(0));let e=f({argv:process.argv,readFileSync:_.readFileSync}),o=e.tool_name??"",n=e.tool_input??{},s=typeof n.command=="string"?n.command:"";o==="Bash"||(console.log(JSON.stringify(r())),process.exit(0));let h=g(process.env.CLANCY_BASE_BRANCH),c=E(s,h);console.log(JSON.stringify(c?u(c):r()))}catch{console.log(JSON.stringify(r()))}
@@ -1,9 +1,9 @@
1
- "use strict";var g=require("node:fs"),k=require("node:os");function x(e,t){return{hookSpecificOutput:{hookEventName:e,additionalContext:t}}}var P=require("node:path");function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function y(e,t){let n=(0,P.join)(e,".clancy","lock.json");try{let r=JSON.parse(t.readFileSync(n,"utf8"));return l(r)?r:null}catch{return null}}var M=require("node:stream/consumers");var w={},G=3e3;function Y(e){try{let t=JSON.parse(e);return l(t)?t:w}catch{return w}}function H(e){return new Promise(t=>{setTimeout(()=>t(w),e)})}function S(e){let t=e.timeoutMs??G,n=(0,M.text)(e.stdin).then(Y);return Promise.race([n,H(t)])}var L=require("node:path");function b(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"")}function C(e,t){return(0,L.join)(t.tmpdir(),`clancy-ctx-${b(e)}.json`)}function I(e,t){return(0,L.join)(t.tmpdir(),`clancy-ctx-${b(e)}-warned.json`)}var J=35,B=25,q=60,K=5,V=80,X=100,N=30;function A(e,t,n){return e||t>=K||n}function D(e,t,n){let r={message:null,debounce:t};if(!e||e.timestamp!==void 0&&n-e.timestamp>q)return r;let o=e.remaining_percentage;if(!(o<=J))return r;let m=t.callsSinceWarn+1,a=o<=B,d=a?"critical":"warning",p=t.lastLevel===null,c=t.lastLevel==="warning";return A(p,m,a&&c)?{message:a?Z(e.used_pct,o):z(e.used_pct,o),debounce:{callsSinceWarn:0,lastLevel:d}}:{message:null,debounce:{callsSinceWarn:m,lastLevel:t.lastLevel}}}function O(e,t){let n={message:null,debounce:t},{startedAt:r,timeLimitMinutes:i,nowMs:o}=e;if(!r||i<=0)return n;let s=new Date(r).getTime();if(isNaN(s))return n;let a=o-s,d=Math.floor(a/6e4),p=i*6e4,c=Math.floor(a/p*100);if(c<V)return n;let f=t.callsSinceWarn+1,u=c>=X,E=u?"critical":"warning",$=t.lastLevel===null,j=t.lastLevel==="warning";return A($,f,u&&j)?{message:u?tt(d,i):Q(d,i,c),debounce:{callsSinceWarn:0,lastLevel:E}}:{message:null,debounce:{callsSinceWarn:f,lastLevel:t.lastLevel}}}var v={callsSinceWarn:0,lastLevel:null},h={context:v,time:v};function F(e){try{let t=JSON.parse(e);return l(t)?{context:_(t.context),time:_(t.time)}:h}catch{return h}}function W(e){try{let t=JSON.parse(e);if(!l(t))return null;let n=t.remaining_percentage,r=t.used_pct;if(!(typeof n=="number"&&typeof r=="number"&&Number.isFinite(n)&&Number.isFinite(r)))return null;let o={remaining_percentage:n,used_pct:r},s=t.timestamp;return typeof s=="number"&&Number.isFinite(s)?{...o,timestamp:s}:o}catch{return null}}function R(e){if(e===void 0)return N;let t=Number(e);return Number.isFinite(t)?t:N}function _(e){if(!l(e))return v;let t=e.callsSinceWarn,n=typeof t=="number"?t:0,r=e.lastLevel;return{callsSinceWarn:n,lastLevel:r==="warning"||r==="critical"?r:null}}function z(e,t){return`CONTEXT WARNING: Usage at ${e}%. Remaining: ${t}%. Context is getting limited. Stop exploring and move to implementation. Avoid reading additional files unless strictly necessary. Commit completed work as soon as it is ready.`}function Z(e,t){return`CONTEXT CRITICAL: Usage at ${e}%. Remaining: ${t}%. Context is nearly exhausted. Stop reading files and wrap up immediately:
1
+ "use strict";var g=require("node:fs"),k=require("node:os");function x(e,t){return{hookSpecificOutput:{hookEventName:e,additionalContext:t}}}var P=require("node:path");function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function y(e,t){let n=(0,P.join)(e,".clancy","lock.json");try{let r=JSON.parse(t.readFileSync(n,"utf8"));return l(r)?r:null}catch{return null}}var N=require("node:stream/consumers");var w={},G=3e3;function Y(e){try{let t=JSON.parse(e);return l(t)?t:w}catch{return w}}function H(e){return new Promise(t=>{setTimeout(()=>t(w),e)})}function S(e){let t=e.timeoutMs??G,n=(0,N.text)(e.stdin).then(Y);return Promise.race([n,H(t)])}var L=require("node:path");function C(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"")}function b(e,t){return(0,L.join)(t.tmpdir(),`clancy-ctx-${C(e)}.json`)}function v(e,t){return(0,L.join)(t.tmpdir(),`clancy-ctx-${C(e)}-warned.json`)}var J=35,B=25,q=60,K=5,V=80,X=100,M=30;function D(e,t,n){return e||t>=K||n}function O(e,t,n){let r={message:null,debounce:t};if(!e||e.timestamp!==void 0&&n-e.timestamp>q)return r;let i=e.remaining_percentage;if(!(i<=J))return r;let m=t.callsSinceWarn+1,a=i<=B,d=a?"critical":"warning",p=t.lastLevel===null,c=t.lastLevel==="warning";return D(p,m,a&&c)?{message:a?Z(e.used_pct,i):z(e.used_pct,i),debounce:{callsSinceWarn:0,lastLevel:d}}:{message:null,debounce:{callsSinceWarn:m,lastLevel:t.lastLevel}}}function A(e,t){let n={message:null,debounce:t},{startedAt:r,timeLimitMinutes:o,nowMs:i}=e;if(!r||o<=0)return n;let s=new Date(r).getTime();if(isNaN(s))return n;let a=i-s,d=Math.floor(a/6e4),p=o*6e4,c=Math.floor(a/p*100);if(c<V)return n;let f=t.callsSinceWarn+1,u=c>=X,E=u?"critical":"warning",$=t.lastLevel===null,j=t.lastLevel==="warning";return D($,f,u&&j)?{message:u?tt(d,o):Q(d,o,c),debounce:{callsSinceWarn:0,lastLevel:E}}:{message:null,debounce:{callsSinceWarn:f,lastLevel:t.lastLevel}}}var I={callsSinceWarn:0,lastLevel:null},h={context:I,time:I};function F(e){try{let t=JSON.parse(e);return l(t)?{context:_(t.context),time:_(t.time)}:h}catch{return h}}function W(e){try{let t=JSON.parse(e);if(!l(t))return null;let n=t.remaining_percentage,r=t.used_pct;if(!(typeof n=="number"&&typeof r=="number"&&Number.isFinite(n)&&Number.isFinite(r)))return null;let i={remaining_percentage:n,used_pct:r},s=t.timestamp;return typeof s=="number"&&Number.isFinite(s)?{...i,timestamp:s}:i}catch{return null}}function R(e){if(e===void 0)return M;let t=Number(e);return Number.isFinite(t)?t:M}function _(e){if(!l(e))return I;let t=e.callsSinceWarn,n=typeof t=="number"?t:0,r=e.lastLevel;return{callsSinceWarn:n,lastLevel:r==="warning"||r==="critical"?r:null}}function z(e,t){return`CONTEXT WARNING: Usage at ${e}%. Remaining: ${t}%. Context is getting limited. Stop exploring and move to implementation. Avoid reading additional files unless strictly necessary. Commit completed work as soon as it is ready.`}function Z(e,t){return`CONTEXT CRITICAL: Usage at ${e}%. Remaining: ${t}%. Context is nearly exhausted. Stop reading files and wrap up immediately:
2
2
  1. Commit whatever work is staged on the current feature branch
3
3
  2. Append a WIP entry to .clancy/progress.txt: YYYY-MM-DD HH:MM | TICKET-KEY | Summary | WIP \u2014 context exhausted
4
4
  3. Inform the user what was completed and what remains.
5
5
  Do NOT start any new work.`}function Q(e,t,n){return`TIME WARNING: Ticket implementation at ${e}min of ${t}min limit (${n}%).
6
6
  Wrap up implementation and prepare for delivery. Avoid starting new approaches.`}function tt(e,t){return`TIME CRITICAL: Time limit reached (${e}min of ${t}min).
7
7
  STOP implementation immediately. Commit current work, push the branch,
8
- and create the PR with whatever is ready. Log a WIP entry if incomplete.`}S({stdin:process.stdin}).then(et).catch(()=>{});function et(e){let t=e.session_id??"";if(!t)return;let n=e.cwd??process.cwd(),r={readFileSync:g.readFileSync},i={tmpdir:k.tmpdir},o=I(t,i),s=nt(o,r),m=C(t,i),a=U(m,r),d=a?W(a):null,p=Math.floor(Date.now()/1e3),c=D(d,s.context,p),T=y(n,r),f=R(process.env.CLANCY_TIME_LIMIT),u=O({startedAt:T?.startedAt,timeLimitMinutes:f,nowMs:Date.now()},s.time);rt(o,s,{context:c,time:u}),it(c,u)}function U(e,t){try{return t.readFileSync(e,"utf8")}catch{return null}}function nt(e,t){let n=U(e,t);return n?F(n):h}function rt(e,t,n){if(!(n.context.debounce!==t.context||n.time.debounce!==t.time))return;let i={context:n.context.debounce,time:n.time.debounce};try{(0,g.writeFileSync)(e,JSON.stringify(i))}catch{}}function it(e,t){let n=[e.message,t.message].filter(i=>i!==null);if(n.length===0)return;let r=x("PostToolUse",n.join(`
8
+ and create the PR with whatever is ready. Log a WIP entry if incomplete.`}S({stdin:process.stdin}).then(et).catch(()=>{});function et(e){let t=e.session_id??"";if(!t)return;let n=e.cwd??process.cwd(),r={readFileSync:g.readFileSync},o={tmpdir:k.tmpdir},i=v(t,o),s=nt(i,r),m=b(t,o),a=U(m,r),d=a?W(a):null,p=Math.floor(Date.now()/1e3),c=O(d,s.context,p),T=y(n,r),f=R(process.env.CLANCY_TIME_LIMIT),u=A({startedAt:T?.startedAt,timeLimitMinutes:f,nowMs:Date.now()},s.time);rt(i,s,{context:c,time:u}),ot(c,u)}function U(e,t){try{return t.readFileSync(e,"utf8")}catch{return null}}function nt(e,t){let n=U(e,t);return n?F(n):h}function rt(e,t,n){if(!(n.context.debounce!==t.context||n.time.debounce!==t.time))return;let o={context:n.context.debounce,time:n.time.debounce};try{(0,g.writeFileSync)(e,JSON.stringify(o))}catch{}}function ot(e,t){let n=[e.message,t.message].filter(o=>o!==null);if(n.length===0)return;let r=x("PostToolUse",n.join(`
9
9
  `));process.stdout.write(JSON.stringify(r))}
@@ -1,2 +1,2 @@
1
- "use strict";var x=require("node:fs");function o(){return{decision:"approve"}}function i(e){return{decision:"block",reason:e}}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var a={};var P=0;function g(e){try{let t=JSON.parse(e);return f(t)?t:a}catch{return a}}function c(e){let t=e.argv[2];if(t)return g(t);try{let n=e.readFileSync(P,"utf8");return g(n)}catch{return a}}function r(e,t,n){return new RegExp(`(?:${e})\\s*[:=]\\s*["']?${t}{${n},}["']?`,"i")}var l="[A-Za-z0-9\\-_.]",h="[A-Za-z0-9+/=]",v="[A-Za-z0-9/+=]",b=[{name:"Generic API key",regex:r("api[_-]?key|apikey",l,20)},{name:"Generic secret",regex:r("secret|private[_-]?key",l,20)},{name:"Generic token",regex:r("auth[_-]?token|access[_-]?token|bearer",l,20)},{name:"Generic password",regex:r("password|passwd|pwd",`[^\\s"']`,8)},{name:"AWS Secret Key",regex:r("aws_secret_access_key|aws_secret",v,40)},{name:"Atlassian API token",regex:r("jira_api_token|atlassian[_-]?token",h,24)},{name:"AWS Access Key",regex:/AKIA[0-9A-Z]{16}/},{name:"GitHub PAT (classic)",regex:/ghp_[A-Za-z0-9]{36}/},{name:"GitHub PAT (fine-grained)",regex:/github_pat_[A-Za-z0-9_]{82}/},{name:"GitHub OAuth token",regex:/gho_[A-Za-z0-9]{36}/},{name:"Slack token",regex:/xox[bpors]-[0-9]{10,}-[A-Za-z0-9-]+/},{name:"Stripe key",regex:/(?:sk|pk)_(?:live|test)_[A-Za-z0-9]{24,}/},{name:"Linear API key",regex:/lin_api_[A-Za-z0-9]{40,}/},{name:"Private key",regex:/-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/},{name:"Database connection string",regex:/(?:mongodb|postgres|mysql|redis):\/\/[^\s"']+:[^\s"']+@/i}],w=[".clancy/.env",".env.local",".env.example",".env.development",".env.test"];function m(e){return w.some(t=>e.endsWith(t))}function A(e){return e?b.filter(({regex:t})=>t.test(e)).map(({name:t})=>t):[]}function T(e){if(!(typeof e=="object"&&e!==null))return;let n=e.new_string;return typeof n=="string"?n:void 0}function d(e,t){if(e==="Write"){let n=t.content;return typeof n=="string"?n:null}if(e==="Edit"){let n=t.new_string;return typeof n=="string"?n:null}if(e==="MultiEdit"){let n=t.edits;return Array.isArray(n)?n.map(T).filter(Boolean).join(`
2
- `):null}return null}try{let e=c({argv:process.argv,readFileSync:x.readFileSync}),t=e.tool_name??"",n=e.tool_input??{},s=typeof n.file_path=="string"?n.file_path:"",u=d(t,n),_=u!==null,y=s!==""&&m(s);(!_||y)&&(console.log(JSON.stringify(o())),process.exit(0));let p=A(u);if(p.length>0){let k=p.join(", "),S=`Credential guard: blocked writing to ${s}. Detected: ${k}. Move credentials to .clancy/.env instead.`;console.log(JSON.stringify(i(S)))}else console.log(JSON.stringify(o()))}catch{console.log(JSON.stringify(o()))}
1
+ "use strict";var x=require("node:fs");function r(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow"}}}function i(e){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:e}}}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var a={};var P=0;function m(e){try{let t=JSON.parse(e);return f(t)?t:a}catch{return a}}function c(e){let t=e.argv[2];if(t)return m(t);try{let n=e.readFileSync(P,"utf8");return m(n)}catch{return a}}function o(e,t,n){return new RegExp(`(?:${e})\\s*[:=]\\s*["']?${t}{${n},}["']?`,"i")}var l="[A-Za-z0-9\\-_.]",h="[A-Za-z0-9+/=]",v="[A-Za-z0-9/+=]",T=[{name:"Generic API key",regex:o("api[_-]?key|apikey",l,20)},{name:"Generic secret",regex:o("secret|private[_-]?key",l,20)},{name:"Generic token",regex:o("auth[_-]?token|access[_-]?token|bearer",l,20)},{name:"Generic password",regex:o("password|passwd|pwd",`[^\\s"']`,8)},{name:"AWS Secret Key",regex:o("aws_secret_access_key|aws_secret",v,40)},{name:"Atlassian API token",regex:o("jira_api_token|atlassian[_-]?token",h,24)},{name:"AWS Access Key",regex:/AKIA[0-9A-Z]{16}/},{name:"GitHub PAT (classic)",regex:/ghp_[A-Za-z0-9]{36}/},{name:"GitHub PAT (fine-grained)",regex:/github_pat_[A-Za-z0-9_]{82}/},{name:"GitHub OAuth token",regex:/gho_[A-Za-z0-9]{36}/},{name:"Slack token",regex:/xox[bpors]-[0-9]{10,}-[A-Za-z0-9-]+/},{name:"Stripe key",regex:/(?:sk|pk)_(?:live|test)_[A-Za-z0-9]{24,}/},{name:"Linear API key",regex:/lin_api_[A-Za-z0-9]{40,}/},{name:"Private key",regex:/-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/},{name:"Database connection string",regex:/(?:mongodb|postgres|mysql|redis):\/\/[^\s"']+:[^\s"']+@/i}],b=[".clancy/.env",".env.local",".env.example",".env.development",".env.test"];function g(e){return b.some(t=>e.endsWith(t))}function A(e){return e?T.filter(({regex:t})=>t.test(e)).map(({name:t})=>t):[]}function w(e){if(!(typeof e=="object"&&e!==null))return;let n=e.new_string;return typeof n=="string"?n:void 0}function d(e,t){if(e==="Write"){let n=t.content;return typeof n=="string"?n:null}if(e==="Edit"){let n=t.new_string;return typeof n=="string"?n:null}if(e==="MultiEdit"){let n=t.edits;return Array.isArray(n)?n.map(w).filter(Boolean).join(`
2
+ `):null}return null}try{let e=c({argv:process.argv,readFileSync:x.readFileSync}),t=e.tool_name??"",n=e.tool_input??{},s=typeof n.file_path=="string"?n.file_path:"",u=d(t,n),y=u!==null,_=s!==""&&g(s);(!y||_)&&(console.log(JSON.stringify(r())),process.exit(0));let p=A(u);if(p.length>0){let k=p.join(", "),S=`Credential guard: blocked writing to ${s}. Detected: ${k}. Move credentials to .clancy/.env instead.`;console.log(JSON.stringify(i(S)))}else console.log(JSON.stringify(r()))}catch{console.log(JSON.stringify(r()))}
@@ -1 +1 @@
1
- "use strict";var u=require("node:fs"),f=require("node:os");function l(t,r){return{hookSpecificOutput:{hookEventName:t,additionalContext:r}}}var x=require("node:stream/consumers");function a(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var p={},D=3e3;function F(t){try{let r=JSON.parse(t);return a(r)?r:p}catch{return p}}function T(t){return new Promise(r=>{setTimeout(()=>r(p),t)})}function d(t){let r=t.timeoutMs??D,n=(0,x.text)(t.stdin).then(F);return Promise.race([n,T(r)])}var P=require("node:path");function h(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"")}function m(t,r){return(0,P.join)(r.tmpdir(),`clancy-drift-${h(t)}`)}var s=require("node:path");var j=(0,s.join)(".clancy","version.json"),g=(0,s.join)(".claude","commands","clancy","VERSION");function S(t,r){return!t||!r?!1:t.trim()!==r.trim()}function y(t,r){try{return r.readFileSync(t,"utf8")}catch{return null}}function I(t,r){let n=y((0,s.join)(t,j),r);if(!n)return null;try{let o=JSON.parse(n);if(!a(o))return null;let e=o.version;return typeof e=="string"?e:null}catch{return null}}function O(t,r,n){let o=(0,s.join)(t,g),e=(0,s.join)(r,g),i=y(o,n);if(i)return i.trim();let c=y(e,n);return c?c.trim():null}function b(t,r){return`DRIFT WARNING: Clancy runtime files are outdated (runtime: ${t}, commands: ${r}). Run /clancy:update to sync your installation.`}d({stdin:process.stdin}).then(t=>{let r=t.session_id??"";if(!r)return;let n=m(r,{tmpdir:f.tmpdir});try{(0,u.writeFileSync)(n,"1",{flag:"wx"})}catch{return}let o=t.cwd??process.cwd(),e={readFileSync:u.readFileSync},i=I(o,e),c=O(o,(0,f.homedir)(),e);if(!i||!c||!S(i,c))return;let N=b(i,c),w=l("PostToolUse",N);process.stdout.write(JSON.stringify(w))}).catch(()=>{});
1
+ "use strict";var u=require("node:fs"),f=require("node:os");function l(t,r){return{hookSpecificOutput:{hookEventName:t,additionalContext:r}}}var h=require("node:stream/consumers");function a(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var p={},w=3e3;function T(t){try{let r=JSON.parse(t);return a(r)?r:p}catch{return p}}function k(t){return new Promise(r=>{setTimeout(()=>r(p),t)})}function m(t){let r=t.timeoutMs??w,n=(0,h.text)(t.stdin).then(T);return Promise.race([n,k(r)])}var P=require("node:path");function x(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"")}function d(t,r){return(0,P.join)(r.tmpdir(),`clancy-drift-${x(t)}`)}var s=require("node:path");var F=(0,s.join)(".clancy","version.json"),g=(0,s.join)(".claude","commands","clancy","VERSION");function S(t,r){return!t||!r?!1:t.trim()!==r.trim()}function y(t,r){try{return r.readFileSync(t,"utf8")}catch{return null}}function O(t,r){let n=y((0,s.join)(t,F),r);if(!n)return null;try{let o=JSON.parse(n);if(!a(o))return null;let e=o.version;return typeof e=="string"?e:null}catch{return null}}function I(t,r,n){let o=(0,s.join)(t,g),e=(0,s.join)(r,g),i=y(o,n);if(i)return i.trim();let c=y(e,n);return c?c.trim():null}function D(t,r){return`DRIFT WARNING: Clancy runtime files are outdated (runtime: ${t}, commands: ${r}). Run /clancy:update to sync your installation.`}m({stdin:process.stdin}).then(t=>{let r=t.session_id??"";if(!r)return;let n=d(r,{tmpdir:f.tmpdir});try{(0,u.writeFileSync)(n,"1",{flag:"wx"})}catch{return}let o=t.cwd??process.cwd(),e={readFileSync:u.readFileSync},i=O(o,e),c=I(o,(0,f.homedir)(),e);if(!i||!c||!S(i,c))return;let N=D(i,c),b=l("PostToolUse",N);process.stdout.write(JSON.stringify(b))}).catch(()=>{});
@@ -1,2 +1,2 @@
1
- "use strict";var d=require("node:fs");function c(t,n){return{hookSpecificOutput:{hookEventName:t,additionalContext:n}}}var p=require("node:path");function o(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function s(t,n){let e=(0,p.join)(t,".clancy","lock.json");try{let r=JSON.parse(n.readFileSync(e,"utf8"));return o(r)?r:null}catch{return null}}var m=require("node:stream/consumers");var a={},x=3e3;function P(t){try{let n=JSON.parse(t);return o(n)?n:a}catch{return a}}function T(t){return new Promise(n=>{setTimeout(()=>n(a),t)})}function u(t){let n=t.timeoutMs??x,e=(0,m.text)(t.stdin).then(P);return Promise.race([e,T(n)])}function f(t){let{ticketKey:n,ticketBranch:e}=t;if(!n||!e)return null;let r=t.ticketTitle||"Unknown",i=t.targetBranch??"main",l=t.parentKey!==void 0&&t.parentKey!=="none"&&t.parentKey!==""?`Parent: ${t.parentKey}.`:void 0,y=t.description?`Requirements: ${t.description.slice(0,2e3)}`:void 0;return[`CONTEXT RESTORED: You are implementing ticket [${n}] ${r}.`,`Branch: ${e} targeting ${i}.`,l,y,"Continue your implementation. Do not start over."].filter(Boolean).join(`
2
- `)}u({stdin:process.stdin}).then(t=>{let n=t.cwd??process.cwd(),e=s(n,{readFileSync:d.readFileSync});if(!e)return;let r=f(e);if(!r)return;let i=c("PostCompact",r);process.stdout.write(JSON.stringify(i))}).catch(()=>{});
1
+ "use strict";var d=require("node:fs");function c(t,e){return{hookSpecificOutput:{hookEventName:t,additionalContext:e}}}var p=require("node:path");function r(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function s(t,e){let n=(0,p.join)(t,".clancy","lock.json");try{let o=JSON.parse(e.readFileSync(n,"utf8"));return r(o)?o:null}catch{return null}}var m=require("node:stream/consumers");var a={},P=3e3;function x(t){try{let e=JSON.parse(t);return r(e)?e:a}catch{return a}}function h(t){return new Promise(e=>{setTimeout(()=>e(a),t)})}function u(t){let e=t.timeoutMs??P,n=(0,m.text)(t.stdin).then(x);return Promise.race([n,h(e)])}function f(t){let{ticketKey:e,ticketBranch:n}=t;if(!e||!n)return null;let o=t.ticketTitle||"Unknown",i=t.targetBranch??"main",l=t.parentKey!==void 0&&t.parentKey!=="none"&&t.parentKey!==""?`Parent: ${t.parentKey}.`:void 0,y=t.description?`Requirements: ${t.description.slice(0,2e3)}`:void 0;return[`CONTEXT RESTORED: You are implementing ticket [${e}] ${o}.`,`Branch: ${n} targeting ${i}.`,l,y,"Continue your implementation. Do not start over."].filter(Boolean).join(`
2
+ `)}u({stdin:process.stdin}).then(t=>{let e=t.cwd??process.cwd(),n=s(e,{readFileSync:d.readFileSync});if(!n)return;let o=f(n);if(!o)return;let i=c("PostCompact",o);process.stdout.write(JSON.stringify(i))}).catch(()=>{});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chief-clancy/terminal",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Installer, slash commands, hooks, AFK runner, agents, Claude CLI bridge",
5
5
  "author": "Alex Clapperton",
6
6
  "license": "MIT",