@tokmizer/plugin 0.9.59 → 0.9.61
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +45 -14
- package/command-templates/tkr-status.md +1 -1
- package/dist/bin/tkr-codex-hook.js +4 -4
- package/dist/bin/tkr-daemon.js +108 -106
- package/dist/bin/tkr-exec +57 -57
- package/dist/bin/tkr-exec.js +57 -57
- package/dist/bin/tkr-processor.js +85 -83
- package/dist/bin/tkr-shim.js +4 -4
- package/dist/bin/tkr.js +85 -85
- package/dist/hooks-host/command-expansion.js +3 -0
- package/dist/hooks-host/post-tool-use.js +79 -77
- package/dist/hooks-host/pre-tool-use.js +5 -5
- package/dist/hooks-host/reducer-stop.js +13 -13
- package/dist/hooks-host/session-recap.js +1 -1
- package/dist/index.js +4 -4
- package/dist/native/manifest.json +12 -12
- package/dist/native/single.json +12 -12
- package/dist/native/tkr-exec-darwin-arm64 +0 -0
- package/dist/native/tkr-exec-darwin-x64 +0 -0
- package/dist/native/tkr-exec-linux-arm64 +0 -0
- package/dist/native/tkr-exec-linux-x64 +0 -0
- package/dist/native/tkr-exec-win32-arm64.exe +0 -0
- package/dist/native/tkr-exec-win32-x64.exe +0 -0
- package/hooks/hooks.json +12 -0
- package/package.json +7 -7
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
|
|
3
|
+
import{spawnSync as S}from"node:child_process";import{dirname as w,join as O}from"node:path";import{fileURLToPath as E}from"node:url";import{realpathSync as u}from"node:fs";import{fileURLToPath as k,pathToFileURL as h}from"node:url";var a=null;function l(r,o,t){if(t!==void 0&&a===t)return!0;if(a!==null||!r)return!1;if(o===h(r).href)return!0;try{return u(r)===u(k(o))}catch{return!1}}import{basename as g}from"node:path";var x={exec:"tkr-exec",processor:"tkr-processor",daemon:"tkr-daemon","shim-run":"tkr-shim"},y={codex:"tkr-codex-hook",cursor:"tkr-cursor-hook",gemini:"tkr-gemini-hook",agent:"tkr-agent-hook",copilot:"tkr-copilot-hook",droid:"tkr-droid-hook",trae:"tkr-trae-hook",qwen:"tkr-qwen-hook",crush:"tkr-crush-hook",junie:"tkr-junie-hook",zcode:"tkr-zcode-hook",grok:"tkr-grok-hook",context:"tkr-context-hook","pre-tool-use":"pre-tool-use","post-tool-use":"post-tool-use","session-recap":"session-recap","session-start":"on-session-start","reducer-session-start":"reducer-session-start","reducer-prompt-submit":"reducer-prompt-submit","reducer-stop":"reducer-stop","command-expansion":"command-expansion"};function p(r){let o=g(r).replace(/\.(m?js|ts)$/,"");if(o==="tkr")return[];for(let[t,e]of Object.entries(x))if(e===o)return[t];for(let[t,e]of Object.entries(y))if(e===o)return["hook",t];return null}function b(){return!1}function m(r,o=process.execPath){let t=b()?p(r):null;return t?[process.execPath,...t]:[o,r]}function f(r=5e3){return new Promise(o=>{let t=[],e=process.stdin,n=!1,s=()=>{n||(n=!0,clearTimeout(d),e.off("data",c),e.pause(),e.unref?.(),o(Buffer.concat(t).toString("utf8")))},c=i=>{t.push(Buffer.isBuffer(i)?i:Buffer.from(i))},d=setTimeout(s,r);e.on("data",c).once("end",s).once("error",s),e.resume()})}var _=/^[A-Za-z0-9._~/:-]{1,64}$/,P={"tkr-gain":{base:["gain"],args:r=>r},"tkr-status":{base:["status"],args:r=>r.length?null:[]},"tkr-telemetry":{base:["telemetry"],args:r=>r.length===0?["status"]:r.length===1&&r[0]==="status"?r:null},"tkr-compression":{base:["compression"],args:r=>r.length?null:[]},"tkr-yolo":{base:["yolo"],args:r=>r.length===0?["status"]:r.length===1&&r[0]==="status"?r:null}};function v(r,o){if(typeof r!="string")return null;let t=P[r.replace(/^[^:]+:/,"")];if(!t)return null;let e=typeof o=="string"&&o.trim()?o.trim().split(/\s+/):[];if(!e.every(s=>_.test(s)))return null;let n=t.args(e);return n?[...t.base,...n]:null}function R(r){return JSON.stringify({decision:"block",reason:r.replace(/\s+$/,""),hookSpecificOutput:{hookEventName:"UserPromptExpansion",suppressOriginalPrompt:!0}})}async function j(){let r;try{r=JSON.parse(await f())}catch{return}if(r.hook_event_name!=="UserPromptExpansion")return;let o=v(r.command_name,r.command_args);if(!o)return;let[t,...e]=m(O(w(E(import.meta.url)),"..","bin","tkr.js")),n=S(t,[...e,...o],{encoding:"utf8",timeout:8e3,env:{...process.env,NO_COLOR:"1",FORCE_COLOR:"0"},stdio:["ignore","pipe","pipe"]});n.error||n.status!==0||!n.stdout.trim()||process.stdout.write(R(n.stdout))}var N=process.argv[1]??"";l(N,import.meta.url,"command-expansion")&&j().catch(()=>{process.exit(0)});export{R as blockWithOutput,v as commandFor};
|