@ornexus/neocortex 4.66.4 → 4.66.6
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/release-source.json +1 -1
- package/dist/sbom.cdx.json +1194 -1194
- package/install.js +2 -0
- package/install.ps1 +93 -35
- package/install.sh +68 -100
- package/package.json +2 -2
- package/packages/client/dist/agent/refresh-stubs.d.ts +9 -0
- package/packages/client/dist/agent/refresh-stubs.js +2 -2
- package/packages/client/dist/agent/update-agent-yaml.js +1 -1
- package/packages/client/dist/agent/update-description.d.ts +23 -0
- package/packages/client/dist/agent/update-description.js +1 -2
- package/packages/client/dist/cli.js +14 -6
- package/packages/client/dist/commands/activate.js +8 -8
- package/packages/client/dist/commands/auth-doctor.d.ts +24 -0
- package/packages/client/dist/commands/auth-doctor.js +7 -0
- package/packages/client/dist/commands/invoke.d.ts +3 -1
- package/packages/client/dist/commands/invoke.js +101 -95
- package/packages/client/dist/config/profile-directory.d.ts +24 -0
- package/packages/client/dist/config/profile-directory.js +1 -1
- package/packages/client/dist/config/project-root.d.ts +40 -0
- package/packages/client/dist/config/project-root.js +1 -0
- package/packages/client/dist/errors/error-messages.js +2 -2
- package/packages/client/dist/git/epic-operational-state.d.ts +18 -0
- package/packages/client/dist/git/epic-operational-state.js +2 -2
- package/packages/client/dist/license/license-client.d.ts +2 -1
- package/packages/client/dist/license/license-client.js +1 -1
- package/packages/client/dist/migrations/epic-lifecycle-backfill.d.ts +7 -0
- package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -3
- package/packages/shared/dist/executable-graph-catalog/contracts.js +6 -6
- package/packages/shared/dist/invocation/diagnose-degraded-continuation.d.ts +14 -0
- package/packages/shared/dist/invocation/diagnose-degraded-continuation.js +39 -0
- package/packages/shared/dist/invocation/diagnose-degraded-continuation.test.d.ts +1 -0
- package/packages/shared/dist/invocation/diagnose-degraded-continuation.test.js +26 -0
- package/packages/shared/dist/invocation/index.d.ts +1 -0
- package/packages/shared/dist/invocation/index.js +1 -0
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/neocortex.md +15 -1
- package/targets-stubs/antigravity/skill/SKILL.md +18 -4
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +13 -5
- package/targets-stubs/claude-code/neocortex-sentinel.md +1 -1
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +13 -5
- package/targets-stubs/codex/AGENTS.md +20 -21
- package/targets-stubs/codex/neocortex.toml +15 -1
- package/targets-stubs/cursor/agent.md +19 -5
- package/targets-stubs/deepseek-harness/SKILL.md +15 -1
- package/targets-stubs/gemini-cli/README.md +7 -5
- package/targets-stubs/gemini-cli/agent.md +19 -5
- package/targets-stubs/gemini-cli/agents/neocortex.md +19 -5
- package/targets-stubs/gemini-cli/gemini.md +8 -7
- package/targets-stubs/gemini-cli/install-gemini.sh +35 -11
- package/targets-stubs/grok/README.md +5 -0
- package/targets-stubs/grok/SKILL.md +16 -1
- package/targets-stubs/grok/install-grok.sh +19 -6
- package/targets-stubs/kimi/neocortex.md +15 -1
- package/targets-stubs/lib/managed-config-merge.js +276 -23
- package/targets-stubs/lib/managed-profile.sh +38 -0
- package/targets-stubs/openclaw/SKILL.md +20 -17
- package/targets-stubs/opencode/neocortex-root.md +20 -22
- package/targets-stubs/opencode/neocortex.md +20 -22
- package/targets-stubs/vscode/neocortex.agent.md +19 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as E,writeFileSync as M,existsSync as c,mkdirSync as q,renameSync as ae,unlinkSync as le,realpathSync as V}from"node:fs";import{join as t,dirname as z,relative as $,isAbsolute as Q}from"node:path";import{homedir as p}from"node:os";import{createRequire as de}from"node:module";import{fileURLToPath as ue}from"node:url";import{setSecureFilePermissions as G}from"../config/secure-config.js";const fe=60,pe=25,Z=de(import.meta.url),xe={"codex:AGENTS.md":"profile-codex-root","codex:neocortex-sentinel.toml":"profile-codex-neocortex-sentinel","codex:neocortex.toml":"profile-codex-neocortex","claude-code:neocortex-sentinel.md":"profile-claude-neocortex-sentinel-agent","claude-code:neocortex.md":"profile-claude-neocortex-agent","claude-code:neocortex-root.md":"profile-claude-neocortex-root-agent"},me={"codex:neocortex-sentinel.toml":"profile-codex-neocortex-sentinel","codex:neocortex.toml":"profile-codex-neocortex","claude-code:neocortex-sentinel.md":"profile-claude-neocortex-sentinel-agent","claude-code:neocortex.md":"profile-claude-neocortex-agent","claude-code:neocortex-root.md":"profile-claude-neocortex-root-agent","opencode:neocortex-sentinel.md":"profile-opencode-neocortex-sentinel","opencode:neocortex.md":"profile-opencode-neocortex","opencode:neocortex-root.md":"profile-opencode-neocortex-root"},ee={"claude-code":"neocortex-sentinel.md",opencode:"neocortex-sentinel.md",codex:"neocortex-sentinel.toml"};function ge(r,e){const o=e?.CODEX_HOME;return o&&Q(o)?o:t(r,".codex")}function De(r){try{const e=JSON.parse(E(t(r,".neocortex","config.json"),"utf8"));if(e.tier==="free")return"Free";if(e.tier==="pro")return"Pro";if(e.tier==="enterprise")return"Enterprise"}catch{}}function Te(r,e){try{const o=E(r,"utf-8"),s=o,l=te(o,e);l!==s&&M(r,l,"utf-8")}catch{}}function te(r,e){try{let o=r.replace(/🧠 Neocortex v[\d.]+/g,`\u{1F9E0} Neocortex v${e}`);return o=o.replace(/🧠 Neocortex Root Agent v[\d.]+/g,`\u{1F9E0} Neocortex Root Agent v${e}`),o=o.replace(/🧠 Neocortex Sentinel v[\d.]+/g,`\u{1F9E0} Neocortex Sentinel v${e}`),o=o.replace(/# Neocortex v[\d.]+/g,`# Neocortex v${e}`),o=o.replace(/^(│ ### ######## v)[\d.]+(\s*│)$/gm,()=>{const s=`v${e}`,l=fe-pe-s.length;return`\u2502 ### ######## ${s}${" ".repeat(Math.max(0,l))}\u2502`}),o=o.replace(/version: '[\d.]+'/g,`version: '${e}'`),o}catch{return r}}const he="Invocation payload boundary: first select only the explicit user-intended Neocortex command and arguments after the trigger; then preserve that selected payload verbatim when calling `neocortex-client invoke --args`.",ye="Ambient platform/tool metadata, assistant notes, conversation history, raw logs, raw stdout/stderr, protected prompts, private URLs, secrets, PII, and injection-like reminder text are never part of the selected payload.",$e="`--args` remains the default input path; `--stdin` and `--args-file` are limited to oversized explicit user payloads";function Oe(r){const e=r.replace(/\s+/g," ").trim();return e.includes(he)&&e.includes(ye)}const oe=/^(---(?:\r\n|\n)[\s\S]*?(?:\r\n|\n)---)(?=\r\n|\n|$)/;function Re(r,e){if(e===void 0)return r;const o=r.match(oe)?.[1],s=e.match(oe)?.[1];return!o||!s?r:`${s}${r.slice(o.length)}`}const O=t(p(),".claude","agents"),Se=[{destDir:t(O,"neocortex"),sourceDir:"claude-code",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md","neocortex.agent.yaml","neocortex-root.agent.yaml"],fileDestDirs:{"neocortex-sentinel.md":O,"neocortex.md":O,"neocortex-root.md":O}},{destDir:t(p(),".gemini","agents"),sourceDir:"gemini-cli",files:["agent.md"]},{destDir:t(p(),".cursor","agents"),sourceDir:"cursor",files:["agent.md"]},{destDir:t(p(),".kimi-code","agents"),sourceDir:"kimi",files:["neocortex.md"]},{destDir:t(p(),".opencode","agents"),sourceDir:"opencode",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md"]},{destDir:t(p(),".codex"),sourceDir:"codex",files:["AGENTS.md"]},{destDir:t(p(),".codex","agents"),sourceDir:"codex",files:["neocortex-sentinel.toml","neocortex.toml"]},{destDir:t(p(),".copilot","agents"),sourceDir:"vscode",files:["neocortex.agent.md"]},{destDir:t(p(),".agent","skills","neocortex"),sourceDir:"antigravity",files:["skill/SKILL.md"]},{destDir:t(p(),".gemini","config","agents"),sourceDir:"antigravity",files:["neocortex.md"]},{destDir:t(p(),".grok","skills","neocortex"),sourceDir:"grok",files:["SKILL.md"]}],ve=[{stubDir:"claude-code",agentsDir:t(".claude","agents"),roleFiles:[["neocortex-sentinel.md","project-claude-neocortex-sentinel-agent",!0],["neocortex.md","project-claude-neocortex-agent",!0]],legacyDir:t(".claude","agents","neocortex")},{stubDir:"opencode",agentsDir:t(".opencode","agents"),roleFiles:[["neocortex-sentinel.md","project-opencode-neocortex-sentinel",!0],["neocortex.md","project-opencode-neocortex",!0],["neocortex-root.md","project-opencode-neocortex-root",!1]]},{stubDir:"codex",agentsDir:t(".codex","agents"),roleFiles:[["neocortex-sentinel.toml","project-codex-neocortex-sentinel",!0],["neocortex.toml","project-codex-neocortex",!0]]}];function Ee(){try{const r=ue(import.meta.url);let e=z(r);for(let o=0;o<10;o++){try{if(JSON.parse(E(t(e,"package.json"),"utf-8")).name==="@ornexus/neocortex")return e}catch{}e=z(e)}}catch{}return null}function Ne(r){try{const e=t(r,".version");if(c(e))return E(e,"utf-8").trim()||null}catch{}return null}function Pe(r,e){const o=`${r}.tmp-${process.pid}`;try{M(o,e,"utf8"),G(o),ae(o,r),G(r)}catch(s){try{c(o)&&le(o)}catch{}throw s}}function we(r,e){return be(r,e).refreshed}function re(r,e,o,s,l,u=!0){let x=E(r,"utf8");if(e.endsWith(".md")&&u){const i=c(o)?o:s&&c(s)?s:null,y=i?E(i,"utf8"):void 0;x=Re(x,y)}return(e.endsWith(".md")||e.endsWith(".yaml")||e.endsWith(".yml"))&&(x=te(x,l)),x}function ne(r,e,o){return{id:r.id??e,scope:o,relativePath:r.relativePath??"",action:r.action,reasonCode:r.reasonCode,...r.nextStep?{nextStep:r.nextStep}:{}}}function Ae(r,e){try{return V.native(r)===V.native(e)}catch{return!1}}function Fe(r){const{projectRoot:e,home:o,stubsRoot:s,managed:l,cliVersion:u,dryRun:x,tierLabel:i,targetFilter:y,results:h}=r;if(!Q(e)||!c(e)||Ae(e,o))return;const N=t(e,".neocortex","managed-config-manifest.json");for(const d of ve)if(!(y&&d.stubDir!==y))try{const P=t(s,d.stubDir),A=t(e,d.agentsDir);if(!d.roleFiles.slice(0,2).some(([m])=>c(t(A,m))))continue;const S=ee[d.stubDir],j=!!(S&&c(t(P,S)));for(const[m,n,R]of d.roleFiles){const F=t(P,m),f=t(A,m);if(!c(F)||!R&&!c(f))continue;const g=d.legacyDir?t(e,d.legacyDir,m):null,I=j&&l.agentRoleMigrationPending?.({id:n,destination:f,manifestFile:N,baseDir:e})===!0,w=re(F,m,f,g,u,!I);try{const b=l.applyProfileBytes({id:n,content:w,destination:f,manifestFile:N,baseDir:e,dryRun:x,allowLegacyAdoption:!0,tierLabel:i,adoptExistingOwner:!0,agentRoles:j,legacyCopyPath:g&&c(g)?g:null});h.push(ne(b,n,"project"))}catch(b){const D=b?.reasonCode;h.push({id:n,scope:"project",relativePath:$(e,f).split("\\").join("/"),action:"failed",reasonCode:typeof D=="string"?D:"managed-operation-failed"})}}}catch{}}function be(r,e){const o=[];try{const s=e?.forceCreate??!1,l=e?.targetFilter,u=e?.dryRun??!1,x=p(),i=e?.homeDir??x,y=e?.packageRoot??Ee();if(!y)return{refreshed:0,results:o};const h=t(y,"targets-stubs");if(!c(h))return{refreshed:0,results:o};const N=t(h,"lib","managed-config-merge.js");if(!c(N))return{refreshed:0,results:o};const d=Z(N),P=t(i,".neocortex","managed-config-manifest.json"),A=De(i),U=e?.env??(e?.homeDir?void 0:process.env),S=ge(i,U),j=t(x,".codex");try{d.applyPolicy({configFile:t(i,".neocortex","config.json"),manifestFile:P,baseDir:i,dryRun:u})}catch{}if(e?.projectRoot&&Fe({projectRoot:e.projectRoot,home:i,stubsRoot:h,managed:d,cliVersion:r,dryRun:u,tierLabel:A,targetFilter:l,results:o}),!l||l==="claude-code")try{const n=t(h,"lib","claude-worktree-setting.js");c(n)&&Z(n).ensureClaudeWorktreeBaseRef(i,{dryRun:u})}catch{}let m=0;for(const n of Se)try{const R=n.sourceDir==="codex",F=a=>R?t(S,$(j,a)):e?.homeDir?t(i,$(x,a)):a,f=F(n.destDir);if(l&&n.sourceDir!==l)continue;if(!c(f)){if(s&&!u)q(f,{recursive:!0});else if(!(s&&u))continue}const g=t(h,n.sourceDir),I=a=>{const L=n.fileDestDirs?.[a];return L?t(F(L),a):t(f,a)},w=Ne(f),b=n.files.every(a=>!c(t(g,a))||c(I(a)));if(w===r&&b||!c(g))continue;let D=i;if(R){if(!c(S))continue;D=d.resolveManagedBase(S,i)}const H=D===i?P:t(D,".neocortex","managed-config-manifest.json"),W=ee[n.sourceDir],Y=!!(W&&c(t(g,W)));let B=!1;for(const a of n.files){const L=t(g,a),ce=n.fileDestDirs?.[a],k=I(a),C=ce?t(f,a):null;if(c(L)){const J=$(i,k).split("\\").join("/"),K=`${n.sourceDir}:${a}`,T=xe[K]??`profile-${n.sourceDir}-${J}`,v=me[K],ie=!!v&&Y&&d.agentRoleMigrationPending?.({id:T,agentRoleId:v,destination:k,manifestFile:H,baseDir:D})===!0,se=re(L,a,k,C,r,!ie);try{const _=d.applyProfileBytes({id:T,content:se,destination:k,manifestFile:H,baseDir:D,dryRun:u,allowLegacyAdoption:!0,tierLabel:A,adoptExistingOwner:!0,legacyBaseDir:D===i?null:i,...v?{agentRoles:Y,agentRoleId:v}:{},legacyCopyPath:C&&c(C)?C:null});v&&o.push(ne(_,T,"user")),_.action!=="failed"&&(B=!0)}catch(_){if(v){const X=_?.reasonCode;o.push({id:T,scope:"user",relativePath:J,action:"failed",reasonCode:typeof X=="string"?X:"managed-operation-failed"})}throw _}}}if(B&&!u){const a=t(f,".version");Pe(a,r+`
|
|
2
|
-
`),
|
|
1
|
+
import{readFileSync as F,writeFileSync as X,existsSync as a,mkdirSync as te,renameSync as ge,unlinkSync as xe,realpathSync as oe}from"node:fs";import{join as o,dirname as ne,relative as T,isAbsolute as re}from"node:path";import{homedir as x}from"node:os";import{createRequire as pe}from"node:module";import{fileURLToPath as De}from"node:url";import{setSecureFilePermissions as Y}from"../config/secure-config.js";const he=60,ye=25,ce=pe(import.meta.url),Se={"codex:AGENTS.md":"profile-codex-root","codex:neocortex-sentinel.toml":"profile-codex-neocortex-sentinel","codex:neocortex.toml":"profile-codex-neocortex","claude-code:neocortex-sentinel.md":"profile-claude-neocortex-sentinel-agent","claude-code:neocortex.md":"profile-claude-neocortex-agent","claude-code:neocortex-root.md":"profile-claude-neocortex-root-agent","gemini-cli:neocortex-sentinel.md":"profile-gemini-neocortex-sentinel","gemini-cli:neocortex.md":"profile-gemini-neocortex","gemini-cli:neocortex-root.md":"profile-gemini-neocortex-root","grok:neocortex-sentinel.md":"profile-grok-agent-neocortex-sentinel"},be={"codex:neocortex-sentinel.toml":"profile-codex-neocortex-sentinel","codex:neocortex.toml":"profile-codex-neocortex","claude-code:neocortex-sentinel.md":"profile-claude-neocortex-sentinel-agent","claude-code:neocortex.md":"profile-claude-neocortex-agent","claude-code:neocortex-root.md":"profile-claude-neocortex-root-agent","opencode:neocortex-sentinel.md":"profile-opencode-neocortex-sentinel","opencode:neocortex.md":"profile-opencode-neocortex","opencode:neocortex-root.md":"profile-opencode-neocortex-root"},ie={"claude-code":"neocortex-sentinel.md","gemini-cli":"agents/neocortex-sentinel.md",grok:"agents/neocortex-sentinel.md",opencode:"neocortex-sentinel.md",codex:"neocortex-sentinel.toml"},Ee=["b3efacd202482c4fe0ff18cd6c115dfb1ea7252b5bddcfc1401f84a13f0943af","79e3b721e9d330239ccc166b75b98f3dac2cad91958e850c9c6226dbb5d0f330","e5de92b4bbe73fec1abc8f027de9f5765b251bdd52846c6b6be8b9a8e6fa68c6"];function Re(t,e){return t?.installSentinel!==void 0?t.installSentinel:e?.NEOCORTEX_INSTALL_SENTINEL==="1"}function ve(t){return/^neocortex-sentinel\.(?:md|toml)$/.test(t)}function ke(t){return/^neocortex-root\.(?:md|toml|agent\.yaml)$/.test(t)}function se(t,e){return ke(t)?!1:ve(t)?e:!0}function Ne(t,e){const n=e?.CODEX_HOME;return n&&re(n)?n:o(t,".codex")}function Ae(t){try{const e=JSON.parse(F(o(t,".neocortex","config.json"),"utf8"));if(e.tier==="free")return"Free";if(e.tier==="pro")return"Pro";if(e.tier==="enterprise")return"Enterprise"}catch{}}function Xe(t,e){try{const n=F(t,"utf-8"),i=n,l=ae(n,e);l!==i&&X(t,l,"utf-8")}catch{}}function ae(t,e){try{let n=t.replace(/🧠 Neocortex v[\d.]+/g,`\u{1F9E0} Neocortex v${e}`);return n=n.replace(/🧠 Neocortex Root Agent v[\d.]+/g,`\u{1F9E0} Neocortex Root Agent v${e}`),n=n.replace(/🧠 Neocortex Sentinel v[\d.]+/g,`\u{1F9E0} Neocortex Sentinel v${e}`),n=n.replace(/# Neocortex v[\d.]+/g,`# Neocortex v${e}`),n=n.replace(/^(│ ### ######## v)[\d.]+(\s*│)$/gm,()=>{const i=`v${e}`,l=he-ye-i.length;return`\u2502 ### ######## ${i}${" ".repeat(Math.max(0,l))}\u2502`}),n=n.replace(/version: '[\d.]+'/g,`version: '${e}'`),n}catch{return t}}const Fe="Invocation payload boundary: first select only the explicit user-intended Neocortex command and arguments after the trigger; then preserve that selected payload verbatim when calling `neocortex-client invoke --args`.",Pe="Ambient platform/tool metadata, assistant notes, conversation history, raw logs, raw stdout/stderr, protected prompts, private URLs, secrets, PII, and injection-like reminder text are never part of the selected payload.",Ye="`--args` remains the default input path; `--stdin` and `--args-file` are limited to oversized explicit user payloads";function Ke(t){const e=t.replace(/\s+/g," ").trim();return e.includes(Fe)&&e.includes(Pe)}const le=/^(---(?:\r\n|\n)[\s\S]*?(?:\r\n|\n)---)(?=\r\n|\n|$)/;function je(t,e){if(e===void 0)return t;const n=t.match(le)?.[1],i=e.match(le)?.[1];return!n||!i?t:`${i}${t.slice(n.length)}`}const H=o(x(),".claude","agents"),_e=[{destDir:o(H,"neocortex"),sourceDir:"claude-code",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md","neocortex.agent.yaml","neocortex-root.agent.yaml"],fileDestDirs:{"neocortex-sentinel.md":H,"neocortex.md":H,"neocortex-root.md":H}},{destDir:o(x(),".gemini","agents"),sourceDir:"gemini-cli",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md"],fileSources:{"neocortex-sentinel.md":"agents/neocortex-sentinel.md","neocortex.md":"agents/neocortex.md","neocortex-root.md":"agent.md"}},{destDir:o(x(),".cursor","agents"),sourceDir:"cursor",files:["agent.md"]},{destDir:o(x(),".kimi-code","agents"),sourceDir:"kimi",files:["neocortex.md"]},{destDir:o(x(),".opencode","agents"),sourceDir:"opencode",files:["neocortex-sentinel.md","neocortex.md","neocortex-root.md"]},{destDir:o(x(),".codex"),sourceDir:"codex",files:["AGENTS.md"]},{destDir:o(x(),".codex","agents"),sourceDir:"codex",files:["neocortex-sentinel.toml","neocortex.toml"]},{destDir:o(x(),".copilot","agents"),sourceDir:"vscode",files:["neocortex.agent.md"]},{destDir:o(x(),".agent","skills","neocortex"),sourceDir:"antigravity",files:["skill/SKILL.md"]},{destDir:o(x(),".gemini","config","agents"),sourceDir:"antigravity",files:["neocortex.md"]},{destDir:o(x(),".grok","skills","neocortex"),sourceDir:"grok",files:["SKILL.md"]},{destDir:o(x(),".grok","agents"),sourceDir:"grok",files:["neocortex-sentinel.md"],fileSources:{"neocortex-sentinel.md":"agents/neocortex-sentinel.md"}}],Le=[{stubDir:"gemini-cli",agentsDir:o(".gemini","agents"),roleFiles:[["neocortex-sentinel.md","project-gemini-neocortex-sentinel",!0],["neocortex.md","project-gemini-neocortex",!0],["neocortex-root.md","project-gemini-neocortex-root",!1]],fileSources:{"neocortex-sentinel.md":"agents/neocortex-sentinel.md","neocortex.md":"agents/neocortex.md","neocortex-root.md":"agent.md"}},{stubDir:"grok",agentsDir:o(".grok","agents"),roleFiles:[["neocortex-sentinel.md","project-grok-agent-neocortex-sentinel",!0]],fileSources:{"neocortex-sentinel.md":"agents/neocortex-sentinel.md"}},{stubDir:"claude-code",agentsDir:o(".claude","agents"),roleFiles:[["neocortex-sentinel.md","project-claude-neocortex-sentinel-agent",!0],["neocortex.md","project-claude-neocortex-agent",!0]],legacyDir:o(".claude","agents","neocortex")},{stubDir:"opencode",agentsDir:o(".opencode","agents"),roleFiles:[["neocortex-sentinel.md","project-opencode-neocortex-sentinel",!0],["neocortex.md","project-opencode-neocortex",!0],["neocortex-root.md","project-opencode-neocortex-root",!1]]},{stubDir:"codex",agentsDir:o(".codex","agents"),roleFiles:[["neocortex-sentinel.toml","project-codex-neocortex-sentinel",!0],["neocortex.toml","project-codex-neocortex",!0]]}];function Ie(){try{const t=De(import.meta.url);let e=ne(t);for(let n=0;n<10;n++){try{if(JSON.parse(F(o(e,"package.json"),"utf-8")).name==="@ornexus/neocortex")return e}catch{}e=ne(e)}}catch{}return null}function Ce(t){try{const e=o(t,".version");if(a(e))return F(e,"utf-8").trim()||null}catch{}return null}function Te(t,e){const n=`${t}.tmp-${process.pid}`;try{X(n,e,"utf8"),Y(n),ge(n,t),Y(t)}catch(i){try{a(n)&&xe(n)}catch{}throw i}}function Je(t,e){return we(t,e).refreshed}function de(t,e,n,i,l,s=!0){let f=F(t,"utf8");if(e.endsWith(".md")&&s){const c=a(n)?n:i&&a(i)?i:null,S=c?F(c,"utf8"):void 0;f=je(f,S)}return(e.endsWith(".md")||e.endsWith(".yaml")||e.endsWith(".yml"))&&(f=ae(f,l)),f}function K(t,e,n){return{id:t.id??e,scope:n,relativePath:t.relativePath??"",action:t.action,reasonCode:t.reasonCode,...t.nextStep?{nextStep:t.nextStep}:{}}}function Oe(t,e){try{return oe.native(t)===oe.native(e)}catch{return!1}}function P(t){const{managed:e,destination:n,manifestFile:i,baseDir:l,id:s,scope:f,dryRun:c,results:S,knownHashes:h}=t;try{const p=e.retireLegacy({destination:n,manifestFile:i,baseDir:l,id:s,dryRun:c,...h?{knownHashes:h}:{}});p.action!=="none"&&S.push(K(p,s,f))}catch(p){const u=p?.reasonCode;S.push({id:s,scope:f,relativePath:T(l,n).split("\\").join("/"),action:"failed",reasonCode:typeof u=="string"?u:"managed-retirement-failed"})}}function $e(t){const{projectRoot:e,home:n,stubsRoot:i,managed:l,cliVersion:s,dryRun:f,tierLabel:c,targetFilter:S,installSentinel:h,results:p}=t;if(!re(e)||!a(e)||Oe(e,n))return;const u=o(e,".neocortex","managed-config-manifest.json");for(const g of Le)if(!(S&&g.stubDir!==S))try{const j=o(i,g.stubDir),k=o(e,g.agentsDir),R=g.stubDir==="gemini-cli"?o(k,"agent.md"):null;if(!(g.roleFiles.slice(0,2).some(([r])=>a(o(k,r)))||!!(R&&a(R))))continue;const $=ie[g.stubDir],N=h&&!!($&&a(o(j,$)));for(const[r,y,w]of g.roleFiles){const D=o(j,g.fileSources?.[r]??r),b=o(k,r);if(!se(r,h)){P({managed:l,destination:b,manifestFile:u,baseDir:e,id:y,scope:"project",dryRun:f,results:p});continue}if(!a(D)||!w&&!a(b))continue;const A=g.legacyDir?o(e,g.legacyDir,r):null,G=N&&l.agentRoleMigrationPending?.({id:y,destination:b,manifestFile:u,baseDir:e})===!0,U=de(D,r,b,A,s,!G);try{const m=l.applyProfileBytes({id:y,content:U,destination:b,manifestFile:u,baseDir:e,dryRun:f,allowLegacyAdoption:!0,tierLabel:c,adoptExistingOwner:!0,agentRoles:N,legacyCopyPath:A&&a(A)?A:null,contentVersion:s});p.push(K(m,y,"project"))}catch(m){const E=m?.reasonCode;p.push({id:y,scope:"project",relativePath:T(e,b).split("\\").join("/"),action:"failed",reasonCode:typeof E=="string"?E:"managed-operation-failed"})}}R&&a(o(k,"neocortex.md"))&&P({managed:l,destination:R,manifestFile:u,baseDir:e,id:"project-gemini-cli-.gemini-agents-agent.md",scope:"project",dryRun:f,results:p})}catch{}}function we(t,e){const n=[];try{const i=e?.forceCreate??!1,l=e?.targetFilter,s=e?.dryRun??!1,f=x(),c=e?.homeDir??f,S=e?.packageRoot??Ie();if(!S)return{refreshed:0,results:n};const h=o(S,"targets-stubs");if(!a(h))return{refreshed:0,results:n};const p=o(h,"lib","managed-config-merge.js");if(!a(p))return{refreshed:0,results:n};const u=ce(p),g=o(c,".neocortex","managed-config-manifest.json"),j=Ae(c),k=e?.env??(e?.homeDir?void 0:process.env),R=Re(e,k),O=Ne(c,k),$=o(f,".codex");try{u.applyPolicy({configFile:o(c,".neocortex","config.json"),manifestFile:g,baseDir:c,dryRun:s})}catch{}if(e?.projectRoot&&$e({projectRoot:e.projectRoot,home:c,stubsRoot:h,managed:u,cliVersion:t,dryRun:s,tierLabel:j,targetFilter:l,installSentinel:R,results:n}),!l||l==="claude-code")try{const r=o(h,"lib","claude-worktree-setting.js");a(r)&&ce(r).ensureClaudeWorktreeBaseRef(c,{dryRun:s})}catch{}let N=0;for(const r of _e)try{const y=r.sourceDir==="codex",w=d=>y?o(O,T($,d)):e?.homeDir?o(c,T(f,d)):d,D=w(r.destDir);if(l&&r.sourceDir!==l)continue;if(!a(D)){if(i&&!s)te(D,{recursive:!0});else if(!(i&&s))continue}const b=o(h,r.sourceDir),A=d=>o(b,r.fileSources?.[d]??d),G=d=>{const L=r.fileDestDirs?.[d];return L?o(w(L),d):o(D,d)},U=Ce(D);if(!a(b))continue;let m=c;if(y){if(!a(O))continue;m=u.resolveManagedBase(O,c)}const E=m===c?g:o(m,".neocortex","managed-config-manifest.json"),J=ie[r.sourceDir],V=R&&!!(J&&a(o(b,J)));r.sourceDir==="codex"&&r.files.includes("neocortex.toml")&&P({managed:u,destination:o(D,"neocortex-worker.toml"),manifestFile:E,baseDir:m,id:"profile-codex-neocortex-worker-retired",scope:"user",dryRun:s,results:n,knownHashes:Ee});let W=!1,q=!1,_=!1;for(const d of r.files){const L=A(d),ue=r.fileDestDirs?.[d],I=G(d),B=ue?o(D,d):null,Q=T(c,I).split("\\").join("/"),Z=`${r.sourceDir}:${d}`,C=Se[Z]??`profile-${r.sourceDir}-${Q}`;if(!se(d,R)){P({managed:u,destination:I,manifestFile:E,baseDir:m,id:C,scope:"user",dryRun:s,results:n});continue}if(a(L)){const M=be[Z],fe=!!M&&V&&u.agentRoleMigrationPending?.({id:C,agentRoleId:M,destination:I,manifestFile:E,baseDir:m})===!0,me=de(L,d,I,B,t,!fe);try{const v=u.applyProfileBytes({id:C,content:me,destination:I,manifestFile:E,baseDir:m,dryRun:s,allowLegacyAdoption:!0,tierLabel:j,adoptExistingOwner:!0,legacyBaseDir:m===c?null:c,...M?{agentRoles:V,agentRoleId:M}:{},legacyCopyPath:B&&a(B)?B:null,contentVersion:t});n.push(K(v,C,"user")),v.action==="skipped"||v.action==="failed"?_=!0:(W=!0,v.action!=="noop"&&v.action!=="planned-noop"&&(q=!0))}catch(v){const ee=v?.reasonCode;throw n.push({id:C,scope:"user",relativePath:Q,action:"failed",reasonCode:typeof ee=="string"?ee:"managed-operation-failed"}),_=!0,v}}}!_&&W&&r.sourceDir==="gemini-cli"&&P({managed:u,destination:o(D,"agent.md"),manifestFile:E,baseDir:m,id:"profile-gemini-cli-.gemini-agents-agent.md",scope:"user",dryRun:s,results:n}),!_&&r.sourceDir==="grok"&&r.files.includes("neocortex-sentinel.md")&&P({managed:u,destination:o(D,"neocortex.md"),manifestFile:E,baseDir:m,id:"profile-grok-agent-neocortex",scope:"user",dryRun:s,results:n});const z=W&&!_&&(q||U!==t);if(z&&!s){const d=o(D,".version");Te(d,t+`
|
|
2
|
+
`),N++}else z&&N++}catch{}if(N>0&&!s)try{const r=o(c,".neocortex");te(r,{recursive:!0});const y=o(r,".update-check");X(y,"",{flag:"w"}),Y(y)}catch{}return{refreshed:N,results:n}}catch{return{refreshed:0,results:n}}}export{be as AGENT_ROLE_IDS,Se as CANONICAL_MANAGED_IDS,Le as PROJECT_ROLE_TARGETS,Fe as SELECTED_PAYLOAD_BOUNDARY_SNIPPET,Pe as SELECTED_PAYLOAD_EXCLUSION_SNIPPET,Ye as SELECTED_PAYLOAD_LARGE_INPUT_SNIPPET,_e as STUB_TARGETS,Ke as containsSelectedPayloadBoundary,Ie as findPackageRoot,ae as patchVersionInContent,Xe as patchVersionInFile,je as preserveInstalledMarkdownFrontmatter,Je as refreshStubs,we as refreshStubsReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readFileSync as l,writeFileSync as u,existsSync as m}from"node:fs";import{join as p}from"node:path";import{homedir as i}from"node:os";import{decideManagedOwnership as d}from"./update-description.js";const E={free:"Free",pro:"Pro",enterprise:"Enterprise"},s=/^(\s*version:\s*)'[^']*'/m,f=/^(\s*title:\s*)'[^']*'/m,T=[p(i(),".claude","agents","neocortex","neocortex.agent.yaml")];function a(t,r,n){try{if(!m(t))return!1;let e=l(t,"utf-8");const o=e,c=E[n.toLowerCase()]??"Free";return s.test(e)&&(e=e.replace(s,`$1'${r}'`)),f.test(e)&&(e=e.replace(f,`$1'Development Orchestrator (${c})'`)),e===o||d(t,i(),Buffer.from(o,"utf-8")).kind!=="unmanaged"?!1:(u(t,e,"utf-8"),!0)}catch{return!1}}function S(t,r){const n=r??"free";let e=0;for(const o of T)a(o,t,n)&&e++;return e}function x(t,r,n){return a(t,r,n??"free")}export{S as updateAgentYaml,x as updateAgentYamlAt};
|
|
@@ -34,6 +34,28 @@ export interface DescriptionPatchOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
managedBaseDir?: string;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* P231.05 ownership decision for a post-process patch:
|
|
39
|
+
* - `unmanaged`: no manifest entry tracks the path; legacy patch is allowed.
|
|
40
|
+
* - `proven`: exactly one entry whose installed hash equals the pre-patch bytes.
|
|
41
|
+
* - `refused`: the path is (or may be) managed but ownership is not provable.
|
|
42
|
+
*/
|
|
43
|
+
type OwnershipDecision = {
|
|
44
|
+
readonly kind: 'unmanaged';
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'refused';
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'proven';
|
|
49
|
+
readonly manifestFile: string;
|
|
50
|
+
readonly entryId: string;
|
|
51
|
+
readonly baseDir: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Decide whether a post-process patch may touch this file. Any doubt about a
|
|
55
|
+
* managed path (invalid/unsupported manifest, ambiguous or mismatched entry,
|
|
56
|
+
* symlink) refuses the write instead of mutating managed bytes out of band.
|
|
57
|
+
*/
|
|
58
|
+
export declare function decideManagedOwnership(filePath: string, baseDir: string, beforeBytes: Buffer): OwnershipDecision;
|
|
37
59
|
/**
|
|
38
60
|
* Update agent descriptions across ALL known platform files:
|
|
39
61
|
* 1. Home-level files (Claude Code, Gemini CLI)
|
|
@@ -50,3 +72,4 @@ export declare function updateAgentDescription(version: string, tier?: string):
|
|
|
50
72
|
* Never throws -- description update is non-critical.
|
|
51
73
|
*/
|
|
52
74
|
export declare function updateAgentDescriptionAt(filePath: string, type: 'yaml' | 'h1', version: string, tier?: string, options?: DescriptionPatchOptions): boolean;
|
|
75
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{readFileSync as
|
|
2
|
-
`,"utf8")),!0}catch{return!1}}function N(e,r,t,n,i,a=p()){try{if(!m(e))return!1;const s=d(e);let o=s.toString("utf-8");const l=o;if(r==="yaml"?b.test(o)&&(o=o.replace(b,`description: "${t}"`)):_.test(o)&&(o=o.replace(_,`# ${t}`)),o=Z(o,n,i),o===l)return!1;const u=ne(e,a,s),f=Buffer.from(o,"utf-8");return E(e,f),u&&re(u,f),!0}catch{return!1}}function le(e,r){const t=r??L(),n=F(e,t);let i=0;for(const{path:s,type:o,fallbackPaths:l}of X){const u=m(s)?s:l?.find(f=>m(f))??s;N(u,o,n,e,t)&&i++}const a=z();if(a)for(const{relativePath:s,type:o}of Y){const l=c(a,s);N(l,o,n,e,t,a)&&i++}return i}function ue(e,r,t,n,i){const a=n??L(),s=F(t,a);return N(e,r,s,t,a,i?.managedBaseDir??p())}export{U as buildBannerTierLine,Q as buildBannerVersionLine,F as buildDescription,L as readTierFromConfig,le as updateAgentDescription,ue as updateAgentDescriptionAt};
|
|
1
|
+
import{readFileSync as h,writeFileSync as L,existsSync as d,lstatSync as y}from"node:fs";import{execSync as k}from"node:child_process";import{createHash as O}from"node:crypto";import{createRequire as B}from"node:module";import{dirname as E,isAbsolute as D,join as c,relative as $,resolve as N,sep as j}from"node:path";import{homedir as p}from"node:os";import{fileURLToPath as M}from"node:url";const T=c(p(),".neocortex","config.json"),A={free:"Free",pro:"Pro",enterprise:"Enterprise"},C=60,H=25,x=/^description:\s*".*"$/m,S=/^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m,I=/^│ ### ######## v[\d.]+\s*│$/m,R=/^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m,w=[{path:c(p(),".claude","agents","neocortex.md"),type:"yaml",fallbackPaths:[c(p(),".claude","agents","neocortex","neocortex.md")]},{path:c(p(),".gemini","agents","agent.md"),type:"yaml"}],G=[{relativePath:c(".cursor","agents","neocortex.md"),type:"yaml"},{relativePath:c(".github","agents","neocortex.md"),type:"yaml"},{relativePath:"AGENTS.md",type:"h1"},{relativePath:c(".agent","skills","neocortex","SKILL.md"),type:"yaml"}];function V(){try{return k("git rev-parse --show-toplevel",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function _(e,n){const t=C-H-n.length,r=t>0?" ".repeat(t):"";return`${e}${n}${r}\u2502`}function J(e){return _("\u2502 ### ######## ",`v${e}`)}function q(e){const n=A[e.toLowerCase()]??"Free";return _("\u2502 ## ### ###### ## ",`OrNexus Team (${n})`)}function b(e,n){const t=A[n.toLowerCase()]??"Free";return`\u{1F9E0} Neocortex v${e} (${t}) | OrNexus Team`}function P(){try{if(d(T)){const e=h(T,"utf-8");return JSON.parse(e).tier??"free"}}catch{}return"free"}function W(e,n,t){let r=e;return I.test(r)&&(r=r.replace(I,J(n))),R.test(r)&&(r=r.replace(R,q(t))),r}const K=[1,2],U="[P201-EV-INSTALLER]",X=B(import.meta.url);function Y(e){return O("sha256").update(e).digest("hex")}function z(){try{let e=E(M(import.meta.url));for(let n=0;n<10;n++){const t=c(e,"targets-stubs","lib","managed-config-merge.js");if(d(t))return t;e=E(e)}}catch{}return null}function Q(e,n,t){try{const r=N(n),s=$(r,N(e));if(!s||s.startsWith("..")||D(s))return{kind:"unmanaged"};const a=s.split(j).join("/"),i=c(r,".neocortex","managed-config-manifest.json");if(!d(i))return{kind:"unmanaged"};if(y(i).isSymbolicLink()||y(e).isSymbolicLink())return{kind:"refused"};const o=JSON.parse(h(i).toString("utf8").replace(/^\uFEFF/,""));if(!o||typeof o!="object"||Array.isArray(o))return{kind:"refused"};const u=o;if(!K.includes(u.schemaVersion)||u.evidence!==U)return{kind:"refused"};const f=u.entries;if(!f||typeof f!="object"||Array.isArray(f))return{kind:"refused"};const l=Object.entries(f).filter(([,m])=>!!m&&typeof m=="object"&&m.relativePath===a);if(l.length===0)return{kind:"unmanaged"};if(l.length!==1)return{kind:"refused"};const[F,v]=l[0];return v.installedHash!==Y(t)?{kind:"refused"}:{kind:"proven",manifestFile:i,entryId:F,baseDir:r}}catch{return{kind:"refused"}}}function Z(e,n,t){const r=z();if(!r)return!1;const a=X(r).applyProfileBytes({id:e.entryId,content:t,destination:n,manifestFile:e.manifestFile,baseDir:e.baseDir});return a.action==="updated"||a.action==="created"}function g(e,n,t,r,s,a=p()){try{if(!d(e))return!1;const i=h(e);let o=i.toString("utf-8");const u=o;if(n==="yaml"?x.test(o)&&(o=o.replace(x,`description: "${t}"`)):S.test(o)&&(o=o.replace(S,`# ${t}`)),o=W(o,r,s),o===u)return!1;const f=Buffer.from(o,"utf-8"),l=Q(e,a,i);return l.kind==="refused"?!1:l.kind==="proven"?Z(l,e,f):(L(e,f),!0)}catch{return!1}}function ae(e,n){const t=n??P(),r=b(e,t);let s=0;for(const{path:i,type:o,fallbackPaths:u}of w){const f=d(i)?i:u?.find(l=>d(l))??i;g(f,o,r,e,t)&&s++}const a=V();if(a)for(const{relativePath:i,type:o}of G){const u=c(a,i);g(u,o,r,e,t,a)&&s++}return s}function ce(e,n,t,r,s){const a=r??P(),i=b(t,a);return g(e,n,i,t,a,s?.managedBaseDir??p())}export{q as buildBannerTierLine,J as buildBannerVersionLine,b as buildDescription,Q as decideManagedOwnership,P as readTierFromConfig,ae as updateAgentDescription,ce as updateAgentDescriptionAt};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{getClientVersion as
|
|
2
|
+
import{getClientVersion as p}from"./version.js";import{spawnSync as b}from"node:child_process";import{COMMAND_REGISTRY_CHECKSUM as m,COMMAND_REGISTRY_VERSION as u}from"./generated/command-registry.generated.js";import{readProjectRegistryIdentity as k,reconcileRegistry as f,RegistryReconciliationError as h,REGISTRY_RECONCILIATION_REASON_CODES as y}from"./registry/registry-reconciliation.js";const g=`
|
|
3
3
|
neocortex-client - Neocortex Client CLI
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -32,6 +32,7 @@ Commands:
|
|
|
32
32
|
config Inspect or change managed subagent approval mode
|
|
33
33
|
cache-status Show cache and circuit breaker status
|
|
34
34
|
doctor Read-only compatibility and release diagnostics
|
|
35
|
+
auth-doctor Read-only local authentication cause/action diagnostics
|
|
35
36
|
reconcile-registry Reconcile the installed client with a trusted local/public registry
|
|
36
37
|
update Update to latest version (use 'neocortex update' instead)
|
|
37
38
|
|
|
@@ -43,7 +44,7 @@ Invoke Options:
|
|
|
43
44
|
--args <string> Selected Neocortex command payload (e.g., "*status")
|
|
44
45
|
--stdin Read an oversized explicit payload as UTF-8 text from stdin
|
|
45
46
|
--args-file <path> Read an oversized explicit payload as UTF-8 text from a local file
|
|
46
|
-
--project-root <path> Project root directory (default:
|
|
47
|
+
--project-root <path> Project root directory (default: Git toplevel, else cwd)
|
|
47
48
|
--format <type> Output format: json | plain (default: plain)
|
|
48
49
|
--watch Keep invoke open and poll local continuity summaries
|
|
49
50
|
--server-url <url> Server URL override
|
|
@@ -97,6 +98,11 @@ Doctor Options:
|
|
|
97
98
|
Exit 0: healthy or observationally degraded; exit 1: incompatible/malformed/required blocker;
|
|
98
99
|
exit 2: invalid usage. Doctor never repairs, updates, deploys, logs in, or rewrites state.
|
|
99
100
|
|
|
101
|
+
Auth Doctor Options:
|
|
102
|
+
--format <type> Output format: plain | json (default: plain)
|
|
103
|
+
Exit 0: public-safe local diagnosis; exit 1: unsafe/malformed inspection;
|
|
104
|
+
exit 2: invalid usage. Auth doctor never writes or contacts the server.
|
|
105
|
+
|
|
100
106
|
Registry Reconciliation Options:
|
|
101
107
|
--project-root <path> Trusted local Neocortex checkout (default: cwd)
|
|
102
108
|
--check-latest Upgrade only when npm latest is strictly newer; never downgrade
|
|
@@ -122,6 +128,7 @@ Examples:
|
|
|
122
128
|
neocortex-client doctor --json
|
|
123
129
|
neocortex-client doctor --offline
|
|
124
130
|
neocortex-client doctor --require release
|
|
131
|
+
neocortex-client auth-doctor --format json
|
|
125
132
|
neocortex-client config status
|
|
126
133
|
neocortex-client config standard --platform-target claude-code
|
|
127
134
|
neocortex-client story-checkpoint setup --story P174.03.913359 --format json
|
|
@@ -221,7 +228,8 @@ Invocation payload boundary:
|
|
|
221
228
|
|
|
222
229
|
License:
|
|
223
230
|
Licensed under BSL-1.1 (Business Source License 1.1)
|
|
224
|
-
`.trim(),
|
|
225
|
-
`);return}process.stderr.write(`[Neocortex] ${
|
|
226
|
-
`)}function
|
|
227
|
-
`)
|
|
231
|
+
`.trim(),C=new Set(["pm","install","postinstall","preinstall","prepublish","postpublish","preuninstall","postuninstall","preprepare","prepare","postprepare"]);function d(r,a){const o=r.indexOf(a);return o>=0?r[o+1]:void 0}function x(r){if(r instanceof h){process.stderr.write(`[Neocortex] ${r.reasonCode}: ${r.remediation}
|
|
232
|
+
`);return}process.stderr.write(`[Neocortex] ${y.ARTIFACT_UNAVAILABLE}: registry reconciliation could not be completed safely; no invoke request was sent.
|
|
233
|
+
`)}function v(){return{version:u,checksum:m}}function S(r){const a=k(r);return!a||a.version===u&&a.checksum===m}function A(r,a){const o=d(a,"--project-root")||process.cwd();try{if(process.env.NEOCORTEX_REGISTRY_REEXECUTED==="1"&&!S(o))throw new h(y.ARTIFACT_MISMATCH,"The reinstalled client still does not match the trusted local projection; no invoke request was sent.");if(f({projectRoot:o,installedVersion:p(),installedIdentity:v()}).status!=="updated")return;const t=b(process.execPath,[process.argv[1],...r],{stdio:"inherit",env:{...process.env,NEOCORTEX_REGISTRY_REEXECUTED:"1"},shell:!1});return t.error?1:t.status??1}catch(e){return x(e),1}}function R(r,a){const o=[...r],e=o.indexOf("--project-root");return e>=0?o[e+1]=a:o.push("--project-root",a),o}function P(r){const a=r instanceof Error&&/^project-root-[a-z-]+$/.test(r.message)?r.message:"project-root-resolution-failed";process.stderr.write(`[Neocortex] ${a}: project root could not be resolved safely; no invoke request was sent.
|
|
234
|
+
`)}async function q(){const r=process.argv.slice(2),a=r[0];a&&C.has(a.toLowerCase())&&process.exit(0),(!a||a==="--help"||a==="-h")&&(console.log(g),process.exit(0)),(a==="--version"||a==="-v")&&(console.log(p()),process.stderr.write(`Licensed under BSL-1.1 (Business Source License 1.1)
|
|
235
|
+
`),process.exit(0));const o=r.slice(1);switch(a){case"invoke":{const e=await import("./commands/invoke.js");let t;try{const l=typeof e.resolveInvokeCliProjectRoot=="function"?await e.resolveInvokeCliProjectRoot(d(o,"--project-root")):void 0;t=l?R(o,l):[...o]}catch(l){P(l),process.exitCode=1;break}const c=["invoke",...t],s=A(c,t);if(s!==void 0){process.exitCode=s;break}const{invokeCliHandler:n,flushInvokeCliOutput:i}=e,j=await n(t),w=await i();process.exitCode=w?j:1;break}case"reconcile-registry":{const e=d(o,"--project-root")||process.cwd();try{f({projectRoot:e,installedVersion:p(),installedIdentity:v(),checkLatest:o.includes("--check-latest")}),process.exitCode=0}catch(t){x(t),process.exitCode=1}break}case"activate":{const{activate:e}=await import("./commands/activate.js");let t,c,s=!1;for(let n=0;n<o.length;n++){const i=o[n];i==="--server-url"?c=o[++n]:i==="--non-interactive"?s=!0:i==="--help"||i==="-h"?(console.log(g),process.exit(0)):i.startsWith("-")||(t=i)}t||(console.error("Error: License key is required."),console.error("Usage: neocortex-client activate <license-key>"),console.error("Example: neocortex-client activate NX-PRO-ABC-123"),process.exit(1));try{const n=await e({licenseKey:t,serverUrl:c,nonInteractive:s});n.success?(console.log(n.message),process.exit(0)):(console.error(n.message),process.exit(1))}catch(n){const i=n instanceof Error?n.message:String(n);console.error(`Activation failed: ${i}`),process.exit(1)}break}case"cache-status":{console.log("Cache status requires an active client session."),console.log("Use this command within a running Neocortex client context."),process.exit(0);break}case"doctor":{const{doctorCliHandler:e}=await import("./commands/doctor.js"),t=await e(o);process.exit(t);break}case"auth-doctor":{const{authDoctorCliHandler:e}=await import("./commands/auth-doctor.js"),t=await e(o);process.exitCode=t;break}case"config":{const{configCliHandler:e}=await import("./commands/config.js"),t=await e(o);process.exit(t);break}case"refresh-memory":{const{refreshMemoryCliHandler:e}=await import("./commands/refresh-memory.js"),t=await e(o);process.exit(t);break}case"architecture-memory":{const{architectureMemoryTerminalCliHandler:e}=await import("./commands/architecture-memory-terminal.js"),t=await e(o);process.exit(t);break}case"planning-diagnosis":{const{planningDiagnosisCliHandler:e}=await import("./commands/planning-diagnosis.js"),t=await e(o);process.exit(t);break}case"planning-research":{const{planningResearchCliHandler:e}=await import("./commands/planning-research.js"),t=await e(o);process.exit(t);break}case"private-session":{const{privateSessionCliHandler:e}=await import("./commands/private-session.js"),t=await e(o);process.exit(t);break}case"planning-memory":{const{planningMemoryCliHandler:e}=await import("./commands/planning-memory.js"),t=await e(o);process.exit(t);break}case"planning-generation":{const{planningGenerationCliHandler:e}=await import("./commands/planning-generation.js"),t=await e(o);process.exit(t);break}case"planning-qa":{const{planningQaCliHandler:e}=await import("./commands/planning-qa.js"),t=await e(o);process.exit(t);break}case"story-checkpoint":{const{storyCheckpointCliHandler:e}=await import("./commands/story-checkpoint.js"),t=await e(o);process.exit(t);break}case"story-worktree":{const{storyWorktreeCliHandler:e}=await import("./commands/story-worktree.js"),t=await e(o);process.exit(t);break}case"legacy-story-branch":{const{legacyStoryBranchCliHandler:e}=await import("./commands/legacy-story-branch.js"),t=await e(o);process.exit(t);break}case"legacy-story-pr":{const{legacyStoryPrCliHandler:e}=await import("./commands/legacy-story-pr.js"),t=await e(o);process.exit(t);break}case"legacy-epic-terminal":{const{legacyEpicTerminalCliHandler:e}=await import("./commands/legacy-epic-terminal.js"),t=await e(o);process.exit(t);break}case"mutation-qa":{const{mutationQaCliHandler:e}=await import("./commands/mutation-qa.js"),t=await e(o);process.exit(t);break}case"property-qa":{const{propertyQaCliHandler:e}=await import("./commands/property-qa.js"),t=await e(o);process.exit(t);break}case"qa-synthetic-backend":{const{syntheticBackendCliHandler:e}=await import("./commands/qa-synthetic-backend.js");process.exitCode=await e(r.slice(1));break}case"qa-scan-review":{const{qaScanReviewCliHandler:e}=await import("./commands/qa-scan-review.js"),t=await e(o);process.exit(t);break}case"qa-root":{const{qaControlCliHandler:e}=await import("./commands/qa-control.js");process.exit(await e(o));break}case"refactor-root":{if(o[0]==="control"){const{refactorControlCliHandler:c}=await import("./commands/refactor-control.js");process.exit(await c(o))}if(o[0]==="characterize"){const{refactorCharacterizationCliHandler:c}=await import("./commands/refactor-characterization.js");process.exit(c(o))}if(o[0]==="review-accept"||o[0]==="review-status"){const{refactorReviewCliHandler:c}=await import("./commands/refactor-review.js");process.exit(await c(o))}if(o[0]?.startsWith("commit-")){const{refactorCommitCliHandler:c}=await import("./commands/refactor-commit.js");process.exit(c(o))}const{refactorRootCliHandler:e}=await import("./commands/refactor-root.js"),t=e(o);process.exit(t);break}case"native-agent":{const{nativeAgentCliHandler:e}=await import("./commands/native-agent.js"),t=await e(o);process.exit(t);break}case"architecture-answers":{const{architectureAnswersCliHandler:e}=await import("./commands/architecture-answers.js"),t=await e(o);process.exit(t);break}case"update":{console.log("To update Neocortex, run:"),console.log(" neocortex update"),console.log(""),console.log("Or manually:"),console.log(" npm install -g @ornexus/neocortex@latest"),process.exit(0);break}default:console.error(`Unknown command: ${a}`),console.error('Run "neocortex-client --help" for usage information.'),process.exit(1)}}q().catch(r=>{console.error(`Fatal error: ${r instanceof Error?r.message:String(r)}`),process.exit(1)});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`,"utf-8")}}async function
|
|
3
|
-
`)};const n=t.trim();if(n.startsWith("nxk_")){const
|
|
4
|
-
`)}}const
|
|
5
|
-
`),tier:
|
|
6
|
-
`)}}if(!
|
|
7
|
-
`)};const
|
|
8
|
-
`),tier:
|
|
1
|
+
import{existsSync as L,mkdirSync as x,writeFileSync as $,readFileSync as I}from"node:fs";import{join as i,dirname as C}from"node:path";import{homedir as M}from"node:os";import{fileURLToPath as V}from"node:url";import{LicenseClient as X}from"../license/license-client.js";import{EncryptedCache as P}from"../cache/encrypted-cache.js";import{getMachineFingerprint as S}from"../machine/fingerprint.js";import{refreshStubs as u}from"../agent/refresh-stubs.js";import{saveSecureConfig as Y,setSecureDirPermissions as E}from"../config/secure-config.js";import{DEFAULT_SERVER_URL as W}from"../constants.js";function b(){try{const e=V(import.meta.url);let t=C(e);for(let r=0;r<5;r++){try{const n=JSON.parse(I(i(t,"package.json"),"utf-8"));if(n.name==="@ornexus/neocortex"||n.name==="@neocortex/client")return n.version??"0.0.0"}catch{}t=C(t)}}catch{}return"0.0.0"}const o=i(M(),".neocortex"),c=i(o,"config.json"),J=/^NX-(F|P|E)-[a-f0-9]+-[a-f0-9]+$/i,B=/^nxk_(?:[a-z]+_)?[a-f0-9]+_[a-f0-9]+$/;function G(e){if(!e||e.trim().length===0)return{valid:!1,error:"License key cannot be empty"};const t=e.trim().toUpperCase();return t.startsWith("NX-")?J.test(t)?{valid:!0}:{valid:!1,error:"Invalid license key format. Expected: NX-{TIER}-{ID} (e.g., NX-PRO-ABC-123)"}:{valid:!1,error:'License key must start with "NX-"'}}function z(e){if(!e||e.trim().length===0)return{valid:!1,error:"API key cannot be empty"};const t=e.trim();return t.startsWith("nxk_")?t.length<20?{valid:!1,error:"API key is too short"}:B.test(t)?{valid:!0}:{valid:!1,error:"Invalid API key format. Expected: nxk_{id}_{check} (e.g., nxk_abc123def456...)"}:{valid:!1,error:'API key must start with "nxk_"'}}function ue(){try{if(L(c)){const e=I(c,"utf-8");return JSON.parse(e)}}catch{}return null}function N(e){x(o,{recursive:!0}),E(o);const t=i(o,"cache");if(x(t,{recursive:!0}),E(t),e.licenseKey||e.apiKey)Y({serverUrl:e.serverUrl,mode:e.mode,machineId:e.machineId,activatedAt:e.activatedAt,tier:e.tier,licenseKey:e.licenseKey??e.apiKey});else{const r={configVersion:1,...e};$(c,JSON.stringify(r,null,2)+`
|
|
2
|
+
`,"utf-8")}}async function fe(e){const{licenseKey:t,serverUrl:r=W}=e;if(!t)return{success:!1,message:["No key provided.","","Get your license key at https://neocortex.sh/portal/login","","Usage:"," neocortex activate YOUR-LICENSE-KEY"," neocortex activate YOUR-API-KEY"].join(`
|
|
3
|
+
`)};const n=t.trim();if(n.startsWith("nxk_")){const a=z(n);if(!a.valid)return{success:!1,message:`Invalid API key: ${a.error}`};const g=n.match(/^nxk_(free|pro|ent)_/),j={free:"free",pro:"pro",ent:"enterprise"},O=g?.[1]?j[g[1]]??"unknown":"unknown",k=S(),m=b();let d;try{const s=await fetch(`${r}/api/v1/license/activate-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:n,machine_id:k,client_version:m})});if(!s.ok)return{success:!1,message:`API key activation failed: ${(await s.json().catch(()=>({}))).message??`HTTP ${s.status}`}`};d=await s.json()}catch{return{success:!1,message:["Failed to connect to IP Protection Server.","","Possible causes:",` - Server at ${r} is unreachable`," - Network connectivity issue","","Workaround: Use --local flag to run in local mode"].join(`
|
|
4
|
+
`)}}const w=d.tier??O,T=i(o,"cache");try{await new P({cacheDir:T,passphrase:n}).set("neocortex:jwt:token",d.token,d.expires_in*1e3)}catch{}const D={serverUrl:r,mode:"remote",machineId:k,activatedAt:new Date().toISOString(),tier:w,apiKey:n};try{N(D)}catch(s){return{success:!1,message:`Failed to save configuration: ${s instanceof Error?s.message:"unknown error"}`}}return{success:!0,message:["Neocortex activated successfully.","","Open your preferred platform (Claude Code, Cursor, VS Code, etc.)","and reference the Neocortex agent.",...u(m,{forceCreate:!0,targetFilter:"claude-code"})+u(m)>0?["","Managed agent wrappers were refreshed while preserving existing Markdown frontmatter and unrelated platform files."]:[],"","Use *menu to see available commands or check the Docs in your Dashboard."].join(`
|
|
5
|
+
`),tier:w,serverUrl:r,configPath:c}}const p=G(n);if(!p.valid)return{success:!1,message:`Invalid license key: ${p.error}`};const l=n,h=l.match(/^NX-(F|P|E)-/i),_={F:"free",P:"pro",E:"enterprise"},A=h?.[1]?_[h[1].toUpperCase()]??"unknown":"unknown",F=i(o,"cache"),K=new P({cacheDir:F,passphrase:l}),R=new X({serverUrl:r,licenseKey:l,cacheProvider:K});let f;try{f=await R.activate()}catch{return{success:!1,message:["Failed to connect to IP Protection Server.","","Possible causes:",` - Server at ${r} is unreachable`," - Network connectivity issue"," - Server is still being deployed","","Workaround: Use --local flag to run in local mode"].join(`
|
|
6
|
+
`)}}if(!f)return{success:!1,message:["License activation failed.","","Possible causes:"," - Invalid or expired license key"," - License already activated on another machine"," - Server rejected the activation request","","Check your license key and try again.","Contact support if the problem persists."].join(`
|
|
7
|
+
`)};const y=f.tier??A,U={serverUrl:r,mode:"remote",machineId:S(),activatedAt:new Date().toISOString(),tier:y,licenseKey:l};try{N(U)}catch(a){return{success:!1,message:`Failed to save config to ${c}: ${a instanceof Error?a.message:String(a)}`}}const v=b();return{success:!0,message:["Neocortex activated successfully.","","Open your preferred platform (Claude Code, Cursor, VS Code, etc.)","and reference the Neocortex agent.",...u(v,{forceCreate:!0,targetFilter:"claude-code"})+u(v)>0?["","Managed agent wrappers were refreshed while preserving existing Markdown frontmatter and unrelated platform files."]:[],"","Use *menu to see available commands or check the Docs in your Dashboard."].join(`
|
|
8
|
+
`),tier:y,serverUrl:r,configPath:c}}export{fe as activate,z as validateApiKeyFormat,G as validateLicenseKeyFormat};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SecureConfig } from '../config/secure-config.js';
|
|
2
|
+
import { type CacheProvider } from '../types/index.js';
|
|
3
|
+
export type AuthDoctorCause = 'valid' | 'near-expiry' | 'expired' | 'store-unavailable' | 'not-configured';
|
|
4
|
+
export type AuthDoctorAction = 'none' | 'prepare' | 'retry-later' | 'activate';
|
|
5
|
+
export interface AuthDoctorReportV1 {
|
|
6
|
+
readonly schemaVersion: 'AuthDoctor/1.0';
|
|
7
|
+
readonly status: 'authenticated' | 'refresh-required' | 'not-configured';
|
|
8
|
+
readonly cause: AuthDoctorCause;
|
|
9
|
+
readonly action: AuthDoctorAction;
|
|
10
|
+
readonly profileSource: 'default-profile' | 'environment-override';
|
|
11
|
+
readonly credentialState: 'valid' | 'near-expiry' | 'expired' | 'unavailable' | 'absent';
|
|
12
|
+
readonly identityHash: string;
|
|
13
|
+
readonly publicSafe: true;
|
|
14
|
+
}
|
|
15
|
+
export interface AuthDoctorDependencies {
|
|
16
|
+
readonly config?: SecureConfig | null;
|
|
17
|
+
readonly cacheProvider?: CacheProvider;
|
|
18
|
+
readonly machineIdentity?: string;
|
|
19
|
+
readonly profileSource?: AuthDoctorReportV1['profileSource'];
|
|
20
|
+
}
|
|
21
|
+
/** Local-only, no-network and zero-write auth inspection. */
|
|
22
|
+
export declare function inspectAuthDoctor(dependencies?: AuthDoctorDependencies): Promise<AuthDoctorReportV1>;
|
|
23
|
+
export declare function renderAuthDoctorPlain(report: AuthDoctorReportV1): string;
|
|
24
|
+
export declare function authDoctorCliHandler(args: readonly string[]): Promise<number>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createHash as c}from"node:crypto";import{join as s}from"node:path";import{EncryptedCache as u}from"../cache/encrypted-cache.js";import{loadSecureConfig as l}from"../config/secure-config.js";import{neocortexProfileDirectory as f}from"../config/profile-directory.js";import{DEFAULT_SERVER_URL as d}from"../constants.js";import{getMachineFingerprint as h}from"../machine/fingerprint.js";import{LicenseClient as p}from"../license/license-client.js";import{NoOpCache as m}from"../types/index.js";function y(){const e=console.warn;console.warn=()=>{};try{return l({strictReadOnly:!0})}finally{console.warn=e}}function S(e){return c("sha256").update("neocortex-auth-doctor-v1\0").update(e.slice(0,1024)).digest("hex")}async function v(e={}){const r=e.config!==void 0?e.config:y(),t=e.profileSource??(process.env.NEOCORTEX_PROFILE_DIR===void 0?"default-profile":"environment-override"),o=e.machineIdentity??r?.machineId??h({strictReadOnly:!0}),i={schemaVersion:"AuthDoctor/1.0",profileSource:t,identityHash:S(o),publicSafe:!0};if(!r?.licenseKey)return{...i,status:"not-configured",cause:"not-configured",action:"activate",credentialState:"absent"};const a=e.cacheProvider??new u({cacheDir:s(f(),"cache"),passphrase:r.licenseKey,strictReadOnly:!0}),n=await new p({serverUrl:r.serverUrl??d,licenseKey:r.licenseKey,cacheProvider:a??new m,strictReadOnly:!0,causalAuthRecovery:!0}).inspectToken();return n.status==="authenticated"?{...i,status:"authenticated",cause:"valid",action:"none",credentialState:"valid"}:n.status==="not-configured"?{...i,status:"not-configured",cause:"not-configured",action:"activate",credentialState:"absent"}:n.reason==="expired"||n.reason==="near-expiry"?{...i,status:"refresh-required",cause:n.reason,action:"prepare",credentialState:n.reason}:{...i,status:"refresh-required",cause:"store-unavailable",action:"retry-later",credentialState:"unavailable"}}function g(e){return[`schemaVersion=${e.schemaVersion}`,`status=${e.status}`,`cause=${e.cause}`,`action=${e.action}`,`profileSource=${e.profileSource}`,`credentialState=${e.credentialState}`,`identityHash=${e.identityHash}`,"publicSafe=true"].join(`
|
|
2
|
+
`)}async function A(e){let r="plain";for(let t=0;t<e.length;t+=1){if(e[t]!=="--format"||t+1>=e.length)return process.stderr.write(`Usage: neocortex-client auth-doctor [--format plain|json]
|
|
3
|
+
`),2;const o=e[t+1];if(o!=="plain"&&o!=="json")return process.stderr.write(`Usage: neocortex-client auth-doctor [--format plain|json]
|
|
4
|
+
`),2;r=o,t+=1}try{const t=await v();return process.stdout.write(r==="json"?`${JSON.stringify(t)}
|
|
5
|
+
`:`${g(t)}
|
|
6
|
+
`),0}catch{return process.stderr.write(`AUTH_DOCTOR_INSPECTION_FAILED
|
|
7
|
+
`),1}}export{A as authDoctorCliHandler,v as inspectAuthDoctor,g as renderAuthDoctorPlain};
|
|
@@ -41,7 +41,7 @@ export declare function recordPendingEpicReservation(projectRoot: string, finger
|
|
|
41
41
|
export interface InvokeOptions {
|
|
42
42
|
/** Raw args from the user (e.g., "*yolo @docs/stories/1.1.story.md") */
|
|
43
43
|
readonly args: string;
|
|
44
|
-
/** Project root directory (default:
|
|
44
|
+
/** Project root directory (default: Git toplevel, falling back to cwd) */
|
|
45
45
|
readonly projectRoot?: string;
|
|
46
46
|
/** Output format: 'json' for full response, 'plain' for instructions only */
|
|
47
47
|
readonly format?: 'json' | 'plain';
|
|
@@ -157,6 +157,8 @@ export declare function classifyPrivateCreateEpicPlanningPhase(input: {
|
|
|
157
157
|
* Neocortex commands.
|
|
158
158
|
*/
|
|
159
159
|
export declare function resolveInvokeProjectRoot(projectRoot: string | undefined, fallbackRoot?: string): string;
|
|
160
|
+
/** Resolve the CLI root once so registry reconciliation and invoke share it. */
|
|
161
|
+
export declare function resolveInvokeCliProjectRoot(projectRoot?: string): Promise<string>;
|
|
160
162
|
export interface InvokeResult {
|
|
161
163
|
readonly success: boolean;
|
|
162
164
|
readonly instructions?: string;
|