@herjarsa/omo-meta-governor 0.24.1 → 0.24.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.
- package/dist/index.js +12 -5
- package/dist/index.js.map +3 -3
- package/dist/lib.js +12 -5
- package/dist/lib.js.map +3 -3
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import{createRequire as gO}from"node:module";var{defineProperty:A4,getOwnPropertyNames:zO,getOwnPropertyDescriptor:NO}=Object,_O=Object.prototype.hasOwnProperty;function IO(r){return this[r]}var OO=(r)=>{var v=(rN??=new WeakMap).get(r),b;if(v)return v;if(v=A4({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function"){for(var U of zO(r))if(!_O.call(v,U))A4(v,U,{get:IO.bind(r,U),enumerable:!(b=NO(r,U))||b.enumerable})}return rN.set(r,v),v},rN,kO=(r,v)=>()=>(v||r((v={exports:{}}).exports,v),v.exports);var wO=(r)=>r;function JO(r,v){this[r]=wO.bind(null,v)}var Wr=(r,v)=>{for(var b in v)A4(r,b,{get:v[b],enumerable:!0,configurable:!0,set:JO.bind(v,b)})};var $N=(r,v)=>()=>(r&&(v=r(r=0)),v);var fr=gO(import.meta.url);var E4={};Wr(E4,{logToFile:()=>x,logStructured:()=>GO,getRotatedLogCount:()=>EO,getLogFileSize:()=>SO,LOG_PATH:()=>br});import{appendFileSync as KO,mkdirSync as XO,statSync as NN,renameSync as WO,existsSync as vv,unlinkSync as QO}from"node:fs";import{resolve as YO,dirname as PO}from"node:path";import{homedir as VO}from"node:os";function _N(r){let v=r;for(let b of qO)v=v.replace(b,"[REDACTED]");return v}function G4(r,v=new WeakSet){if(typeof r==="string")return _N(r);if(Array.isArray(r)){if(v.has(r))return"[Circular]";return v.add(r),r.map((b)=>G4(b,v))}if(r&&typeof r==="object"){if(v.has(r))return"[Circular]";v.add(r);let b={};for(let[U,$]of Object.entries(r))if(HO.test(U))b[U]="[REDACTED]";else try{b[U]=G4($,v)}catch{b[U]="[unserializable]"}return b}return r}function AO(){try{XO(PO(br),{recursive:!0})}catch{}}function LO(){if(!vv(br))return;try{if(NN(br).size<BO)return}catch{return}for(let r=S4;r>=1;r--){let v=r===1?br:`${br}.${r-1}`,b=`${br}.${r}`;if(vv(v))try{if(r===S4)QO(v);else WO(v,b)}catch{}}}function IN(r,v,b,U,$){AO(),LO();let z=_N(v),N=b!==void 0?G4(b):void 0,_={timestamp:new Date().toISOString(),level:r,message:z,...U?{event:U}:{},...$?{sessionID:$}:{},...N!==void 0?{data:N}:{}},I;try{I=JSON.stringify(_)+`
|
|
2
2
|
`}catch{I=JSON.stringify({timestamp:_.timestamp,level:r,message:v,data:"[unserializable]"})+`
|
|
3
|
-
`}try{KO(br,I)}catch{}if(r==="error")console.error(`[meta-governor] ${v}`);else if(r==="warn")console.warn(`[meta-governor] ${v}`);else console.log(`[meta-governor] ${v}`)}function x(r,v,b){IN(r,v,b)}function GO(r){IN(r.level,r.message,r.data,r.event,r.sessionID)}function SO(){try{if(vv(br))return NN(br).size}catch{}return 0}function EO(){let r=0;for(let v=1;v<=S4;v++)if(vv(`${br}.${v}`))r=v;else break;return r}var qO,HO,br,BO=10485760,S4=5;var bv=$N(()=>{qO=[/eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+/g,/sk-(?:proj-|svc-|)[a-zA-Z0-9]{20,}/g,/pk-[a-zA-Z0-9]{20,}/g,/ghp_[a-zA-Z0-9]{36,}/g,/ghs_[a-zA-Z0-9]{36,}/g,/github_pat_[a-zA-Z0-9]{22,}/g,/Bearer\s+[a-zA-Z0-9_\-]{20,}/gi,/(?:key|secret|token|password|credential|private_key)\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}/gi],HO=/^(?:key|secret|token|password|credential|private_key|api[_-]?key|access[_-]?token|auth[_-]?token)$/i;br=YO(VO(),".config","opencode","meta-governor.log")});var F1=kO((AX,Wg)=>{Wg.exports={name:"@herjarsa/omo-meta-governor",version:"0.24.
|
|
3
|
+
`}try{KO(br,I)}catch{}if(r==="error")console.error(`[meta-governor] ${v}`);else if(r==="warn")console.warn(`[meta-governor] ${v}`);else console.log(`[meta-governor] ${v}`)}function x(r,v,b){IN(r,v,b)}function GO(r){IN(r.level,r.message,r.data,r.event,r.sessionID)}function SO(){try{if(vv(br))return NN(br).size}catch{}return 0}function EO(){let r=0;for(let v=1;v<=S4;v++)if(vv(`${br}.${v}`))r=v;else break;return r}var qO,HO,br,BO=10485760,S4=5;var bv=$N(()=>{qO=[/eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+/g,/sk-(?:proj-|svc-|)[a-zA-Z0-9]{20,}/g,/pk-[a-zA-Z0-9]{20,}/g,/ghp_[a-zA-Z0-9]{36,}/g,/ghs_[a-zA-Z0-9]{36,}/g,/github_pat_[a-zA-Z0-9]{22,}/g,/Bearer\s+[a-zA-Z0-9_\-]{20,}/gi,/(?:key|secret|token|password|credential|private_key)\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}/gi],HO=/^(?:key|secret|token|password|credential|private_key|api[_-]?key|access[_-]?token|auth[_-]?token)$/i;br=YO(VO(),".config","opencode","meta-governor.log")});var F1=kO((AX,Wg)=>{Wg.exports={name:"@herjarsa/omo-meta-governor",version:"0.24.2",type:"module",description:"Self-judging agent orchestration layer for OpenCode. Reads memory, scores sessions, dispatches decisions.",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./lib":{types:"./dist/lib.d.ts",import:"./dist/lib.js"}},types:"./dist/index.d.ts",main:"./dist/index.js",files:["dist","README.md"],scripts:{build:"bun build.ts",typecheck:"tsc --noEmit",test:"bun test"},peerDependencies:{"@opencode-ai/plugin":">=1.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},license:"MIT",repository:{type:"git",url:"https://github.com/herjarsa/omo-meta-governor.git"},devDependencies:{"@colbymchenry/codegraph":"^1.5.0","@opencode-ai/plugin":"^1.17.4","@types/node":"^25.9.3",typescript:"^7.0.2"}}});var iI={};Wr(iI,{stripJsoncComments:()=>CI,parseJsonc:()=>hI,loadMetaGovernorConfig:()=>T1,loadJsoncFile:()=>n1,getUserConfigPath:()=>fI,getProjectConfigPath:()=>yI,deepMerge:()=>p$});import{readFile as Vg,access as qg}from"node:fs/promises";import{resolve as Hg,join as Bg}from"node:path";import{homedir as Ag}from"node:os";function CI(r){let v=[],b=0;while(b<r.length){let $=r[b];if($==='"'||$==="'"){let z=$;v.push(z),b++;while(b<r.length){let N=r[b];if(v.push(N),N==="\\"){if(b++,b<r.length)v.push(r[b])}else if(N===z){b++;break}b++}continue}if($==="/"&&b+1<r.length&&r[b+1]==="/"){b+=2;while(b<r.length&&r[b]!==`
|
|
4
4
|
`)b++;continue}if($==="/"&&b+1<r.length&&r[b+1]==="*"){b+=2;while(b<r.length){if(r[b]==="*"&&b+1<r.length&&r[b+1]==="/"){b+=2;break}b++}continue}v.push($),b++}let U=v.join("");for(let $=0;$<10;$++){let z=U;if(U=U.replace(/,(\s*[\]}])/g,"$1"),U===z)break}return U}function hI(r){try{let v=CI(r);return JSON.parse(v)}catch{return}}function fI(){return Hg(Ag(),".config","opencode",TI)}function yI(r){let v=r??process.cwd();return Bg(v,".opencode",TI)}async function Lg(r){try{return await qg(r),!0}catch{return!1}}async function n1(r){if(!await Lg(r))return;try{let v=await Vg(r,"utf-8");return hI(v)}catch{return}}function p$(r,v){let b={...r};for(let U of Object.keys(v)){let $=v[U],z=b[U];if($===void 0)continue;if(nI($)&&nI(z))b[U]=p$(z,$);else b[U]=$}return b}function nI(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)}async function T1(r={}){let v=[],b="defaults",U={},$=fI(),z=await n1($);if(z)U=p$(U,z),v.push(`user:${$}`),b="user";let N=yI(r.projectDir),_=await n1(N);if(_)U=p$(U,_),v.push(`project:${N}`),b="project";if(r.cliOptions&&Object.keys(r.cliOptions).length>0)U=p$(U,r.cliOptions),v.push("cli:inline"),b="cli";return{config:U,sources:v,effectiveSource:b}}var TI="omo-meta-governor.jsonc";var C1=()=>{};import{execSync as xr,spawn as ON}from"node:child_process";import{access as I0,stat as YN}from"node:fs/promises";import{resolve as Nv}from"node:path";import{homedir as cO}from"node:os";import{spawn as jO,spawnSync as Dr}from"node:child_process";function vN(r){try{let v=Dr("pgrep",["-P",String(r)],{encoding:"utf8"});for(let b of v.stdout.trim().split(/\s+/)){let U=Number(b);if(!U)continue;vN(U);try{process.kill(U,"SIGKILL")}catch{}}}catch{}}function yr(r){if(!r||r<=0)return;try{if(process.platform==="win32")Dr("taskkill",["/pid",String(r),"/T","/F"],{stdio:"ignore"});else{try{process.kill(-r,"SIGKILL")}catch{}vN(r);try{process.kill(r,"SIGKILL")}catch{}}}catch{}}var bN=new Set;function L4(r){if(r&&r>0)bN.add(r)}function $v(r){bN.delete(r)}function UN(r,v,b){return new Promise((U)=>{let $;try{$=jO(r,v,{cwd:b.cwd,stdio:["ignore","pipe","pipe"],shell:process.platform==="win32",windowsHide:!0,env:{...process.env,OMO_MG_SPAWN:"1",...b.env}})}catch{U({stdout:"",stderr:"",code:null,timedOut:!1});return}L4($.pid);let z="",N="",_=!1,I=!1,O,J=(j)=>{if(I)return;if(I=!0,clearTimeout(P),O)clearTimeout(O);$v($.pid),U(j)},P=setTimeout(()=>{_=!0,yr($.pid),O=setTimeout(()=>{J({stdout:z,stderr:N,code:null,timedOut:!0})},2000)},b.timeoutMs);$.stdout?.on("data",(j)=>{z+=j.toString("utf8")}),$.stderr?.on("data",(j)=>{N+=j.toString("utf8")}),$.on("error",()=>{J({stdout:z,stderr:N,code:null,timedOut:_})}),$.on("close",(j)=>{if($.exitCode===null)yr($.pid);J({stdout:z,stderr:N,code:j,timedOut:_})})})}function h(r,v,b){let U=Date.now(),$;try{$=Dr(r,v,{cwd:b.cwd,stdio:["ignore","pipe","pipe"],shell:process.platform==="win32",windowsHide:!0,env:{...process.env,OMO_MG_SPAWN:"1",...b.env},timeout:b.timeoutMs})}catch{return{stdout:"",stderr:"",code:null,timedOut:!1}}let z=Date.now()-U,N=$.error!=null&&$.error.code==="ETIMEDOUT"||$.signal==="SIGTERM"||z>=b.timeoutMs-50;if(N&&$.pid)yr($.pid);return{stdout:($.stdout??"").toString("utf8"),stderr:($.stderr??"").toString("utf8"),code:$.status,timedOut:N}}function zN(){let r=0;try{if(process.platform==="win32"){for(let v of["graphify.exe","codegraph.exe"])try{Dr("taskkill",["/IM",v,"/F"],{stdio:"ignore"})}catch{}try{if(Dr("powershell",["-NoProfile","-Command","Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -match 'OMO_MG_WATCH|OMO_MG_SPAWN' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }"],{stdio:"ignore"}).status===0)r=1}catch{}}else{for(let v of["graphify","codegraph"])try{Dr("pkill",["-x",v],{stdio:"ignore"})}catch{}try{Dr("pkill",["-f","OMO_MG_WATCH|OMO_MG_SPAWN"],{stdio:"ignore"})}catch{}}}catch{}return r}async function kN(r,v=60000){return h("npm",["i","-D","@colbymchenry/codegraph"],{cwd:r,timeoutMs:v}).code===0?"codegraph-installed":"codegraph-install-failed"}async function wN(r=60000){if(h("pip",["install","graphifyy","--break-system-packages","--quiet"],{timeoutMs:r}).code===0)return"graphify-installed";return h("uv",["tool","install","graphifyy","--quiet"],{timeoutMs:r}).code===0?"graphify-installed":"graphify-install-failed"}var c4=new Set;function J0(){c4.clear()}var JN=!1;async function gN(r,v=xr){let b=!1,U=!1,$=await KN(Nv(r,".codegraph","codegraph.db")),z=await KN(Nv(r,"graphify-out","graph.json")),N=(_,I)=>{if(v!==xr)return v(_,{stdio:"ignore",...I});let O=_.split(" "),J=O[0],P=O.slice(1),j=h(J,P,{cwd:I?.cwd??r,timeoutMs:I?.timeout??1e4});if(j.code!==0)throw Error(`exit ${j.code}`)};try{N("npx --yes codegraph --version",{timeout:1e4}),b=!0}catch{try{N("node node_modules/.bin/codegraph --version",{cwd:r,timeout:5000}),b=!0}catch{}}try{N("graphify --version",{timeout:5000}),U=!0}catch{try{N("graphifyy --version",{timeout:5000}),U=!0}catch{try{N('python -c "import graphifyy"',{timeout:5000}),U=!0}catch{try{N('python3 -c "import graphifyy"',{timeout:5000}),U=!0}catch{}}}}return{codegraph:b,graphify:U,codegraphIndexExists:$,graphifyIndexExists:z}}async function uO(r,v=60000,b=xr){try{if(b!==xr)b("npx --yes codegraph init",{cwd:r,stdio:"ignore",timeout:v});else{let U=h("npx",["--yes","codegraph","init"],{cwd:r,timeoutMs:v});if(U.code!==0)throw Error(`exit ${U.code}`)}return!0}catch{return!1}}async function DO(r,v=120000,b=xr){let U=[{bin:"graphify",args:[".","--no-viz"]},{bin:"python",args:["-m","graphify",".","--no-viz"]},{bin:"python3",args:["-m","graphify",".","--no-viz"]}];for(let $ of U)try{if(b!==xr)b(`${$.bin} ${$.args.join(" ")}`,{cwd:r,stdio:"ignore",timeout:v});else{let z=h($.bin,$.args,{cwd:r,timeoutMs:v});if(z.code!==0)throw Error(`exit ${z.code}`)}return!0}catch{}return!1}var N$=new Map;function jN(r,v){let b=`${r}:${v}`;if(N$.has(b))return;try{let U;if(v==="codegraph")U=ON("node",["-e",`
|
|
5
5
|
const OMO_MG_WATCH = 1;
|
|
6
|
-
const {
|
|
6
|
+
const {spawn} = require("child_process");
|
|
7
7
|
const run = () => {
|
|
8
|
-
try {
|
|
9
|
-
|
|
8
|
+
try {
|
|
9
|
+
const c = spawn("npx", ["codegraph", "update"], {
|
|
10
|
+
cwd: ${JSON.stringify(r)},
|
|
11
|
+
stdio: "ignore",
|
|
12
|
+
windowsHide: true,
|
|
13
|
+
shell: false,
|
|
14
|
+
});
|
|
15
|
+
c.unref();
|
|
16
|
+
} catch(e) { /* best effort */ }
|
|
10
17
|
};
|
|
11
18
|
run();
|
|
12
19
|
setInterval(run, 30_000);
|
|
@@ -206,5 +213,5 @@ Current decision: ${l.message}`;c.recentInterventionTexts=[...M,`[${l.action}] $
|
|
|
206
213
|
`)}function tg(r,v,b=Fg){if(r==="own"||r==="third-party")return r;try{let U=b("gh repo view --json isFork,parent",{cwd:v,stdio:"pipe",timeout:1e4}),$=JSON.parse(String(U));if($.isFork===!0&&$.parent!==null&&$.parent!==void 0)return"third-party";return"own"}catch{try{let U=b("git remote -v",{cwd:v,stdio:"pipe",timeout:1e4});if(String(U).split(`
|
|
207
214
|
`).some((z)=>/^\s*upstream\s+/.test(z)))return"third-party"}catch{}return"own"}}var dg=$O();function V4(r,v){return dg(r,v)}V4.id="omo-meta-governor";V4.server=V4;var u9=V4;export{u9 as default};
|
|
208
215
|
|
|
209
|
-
//# debugId=
|
|
216
|
+
//# debugId=BD278FA10915A65564756E2164756E21
|
|
210
217
|
//# sourceMappingURL=index.js.map
|