@ornexus/neocortex 4.60.76 → 4.60.78
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/docs/install/installer-diagnostics.md +6 -5
- package/docs/install/linux-global-install.md +5 -3
- package/install.ps1 +80 -66
- package/install.sh +63 -57
- package/package.json +3 -3
- package/packages/client/dist/agent/refresh-stubs.d.ts +7 -0
- package/packages/client/dist/agent/refresh-stubs.js +2 -2
- package/packages/client/dist/agent/update-description.js +1 -1
- package/packages/client/dist/commands/invoke.d.ts +6 -0
- package/packages/client/dist/commands/invoke.js +57 -57
- package/packages/client/dist/commands/refresh-memory.js +3 -3
- package/packages/client/dist/memory/project-memory-writer.d.ts +2 -0
- package/packages/client/dist/memory/project-memory-writer.js +17 -16
- package/packages/client/dist/memory/shared-project-memory-types.js +1 -1
- package/packages/client/dist/runner/headless/managed-profile.js +1 -1
- package/packages/client/dist/runner/host-capacity.d.ts +27 -0
- package/packages/client/dist/runner/host-capacity.js +1 -0
- package/packages/shared/dist/project-memory-targets.js +9 -3
- package/packages/shared/dist/yoloop/host-capacity.js +76 -0
- package/postinstall.js +1 -1
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/install-antigravity.sh +6 -5
- package/targets-stubs/antigravity/neocortex.md +37 -7
- package/targets-stubs/antigravity/skill/SKILL.md +30 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +2 -1
- package/targets-stubs/claude-code/neocortex-root.md +45 -19
- package/targets-stubs/claude-code/neocortex.agent.yaml +2 -1
- package/targets-stubs/claude-code/neocortex.md +64 -69
- package/targets-stubs/codex/AGENTS.md +36 -31
- package/targets-stubs/codex/README.md +7 -3
- package/targets-stubs/codex/install-codex.sh +22 -11
- package/targets-stubs/codex/neocortex.toml +14 -8
- package/targets-stubs/cursor/agent.md +39 -8
- package/targets-stubs/cursor/install-cursor.sh +1 -1
- package/targets-stubs/deepseek-harness/SKILL.md +8 -3
- package/targets-stubs/gemini-cli/agent.md +48 -16
- package/targets-stubs/gemini-cli/agents/neocortex.md +6 -0
- package/targets-stubs/gemini-cli/install-gemini.sh +20 -10
- package/targets-stubs/grok/SKILL.md +29 -0
- package/targets-stubs/grok/install-grok.sh +12 -3
- package/targets-stubs/kimi/neocortex.md +34 -2
- package/targets-stubs/lib/managed-config-merge.js +28 -1
- package/targets-stubs/lib/managed-profile.sh +81 -7
- package/targets-stubs/openclaw/SKILL.md +29 -0
- package/targets-stubs/opencode/neocortex-root.md +62 -28
- package/targets-stubs/opencode/neocortex.md +36 -4
- package/targets-stubs/vscode/install-vscode.sh +3 -3
- package/targets-stubs/vscode/neocortex.agent.md +55 -22
- package/docs/install/coderabbit-manual-setup.md +0 -86
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createHash as
|
|
2
|
-
`).length>
|
|
3
|
-
`)).digest("hex"),fileCount:
|
|
1
|
+
import{createHash as h}from"node:crypto";import{lstatSync as R,readFileSync as f}from"node:fs";import{join as u,resolve as b}from"node:path";import{getProjectMemoryTarget as E,isProjectMemoryTargetId as v,listProjectMemoryTargets as p}from"../memory/shared-project-memory-types.js";import{writeProjectMemoryTargetFiles as M}from"../memory/project-memory-writer.js";function d(r){return(r??"").split(",").map(t=>t.trim()).filter(Boolean)}function P(r){let t=process.cwd(),l=!1,s=!1;const c=[],o=[];for(let i=0;i<r.length;i++){const e=r[i];if(e==="--dry-run"||e==="--preview")l=!0;else if(e==="--verify")s=!0,l=!0;else if(e==="--project-root")t=r[++i]??t;else if(e.startsWith("--project-root="))t=e.slice(15);else if(e==="--target"||e==="--targets")c.push(...d(r[++i]));else if(e.startsWith("--target="))c.push(...d(e.slice(9)));else if(e.startsWith("--targets="))c.push(...d(e.slice(10)));else if(e==="--note"||e==="--memory-note"||e==="--change"){const m=r[++i];m&&o.push(m)}else e.startsWith("--note=")?o.push(e.slice(7)):e.startsWith("--memory-note=")?o.push(e.slice(14)):e.startsWith("--change=")&&o.push(e.slice(9))}if(s&&(c.length>0||o.length>0))throw new Error("Project memory verification requires all targets and no update notes.");const a=c.length>0?c.map(i=>{if(!v(i))throw new Error(`Unknown project-memory target: ${i}`);return i}):["canonical",...p().map(i=>i.targetId)];return{projectRoot:b(t),targetIds:Array.from(new Set(a)),dryRun:l,verify:s,memoryNotes:o}}function g(r){return r.targetIds.map(t=>M({projectRoot:r.projectRoot,targetId:t,dryRun:r.dryRun,memoryNotes:r.memoryNotes??[],backupDirectory:r.backupDirectory}))}function $(r){if(!r.verify||!r.dryRun||r.memoryNotes?.length||r.targetIds.join(",")!==["canonical",...p().map(n=>n.targetId)].join(","))throw new Error("Project memory verification requires the complete read-only target set.");const t=u(r.projectRoot,"NEOCORTEX.md");let l;try{l=R(t)}catch{throw new Error("Canonical project memory is missing or unsafe.")}if(!l.isFile()||l.isSymbolicLink())throw new Error("Canonical project memory must be a regular file.");const s=f(t,"utf8"),c="<!-- NEOCORTEX-MEMORY-START -->",o="<!-- NEOCORTEX-MEMORY-END -->",a=E("canonical").budget;if(s.split(c).length!==2||s.split(o).length!==2||s.indexOf(c)>=s.indexOf(o)||Buffer.byteLength(s,"utf8")>a.maxBytes||s.split(`
|
|
2
|
+
`).length>a.maxLines)throw new Error("Canonical project memory markers or budget are invalid.");const i=g(r),e=i.flatMap(n=>n.files);if(i.some(n=>(n.retiredFiles?.length??0)>0)||e.some(n=>n.changed||n.mode==="compatibility-materialized-fallback"||n.fallbackReason||n.remediationDebt))throw new Error("Project memory verification found stale or fallback targets.");let m;try{if(m=[...new Set(e.map(n=>n.relativeFile))].sort().map(n=>{const y=f(u(r.projectRoot,n)),j=e.find(w=>w.relativeFile===n).mode;return`${n}:${j}:${h("sha256").update(y).digest("hex")}`}),f(t,"utf8")!==s||g(r).some(n=>n.changed))throw new Error("project-memory-verification-race")}catch{throw new Error("Project memory changed during verification.")}return{schemaVersion:"ProjectMemoryVerification/1",canonicalSha256:h("sha256").update(s).digest("hex"),projectionSha256:h("sha256").update(m.join(`
|
|
3
|
+
`)).digest("hex"),fileCount:m.length,publicSafe:!0}}async function O(r){try{const t=P(r);if(t.verify){const o=$(t);return console.log(`Project memory verified: files=${o.fileCount} canonical_sha256=${o.canonicalSha256} projection_sha256=${o.projectionSha256}`),0}const l=g(t),s=l.flatMap(o=>o.files.map(a=>[a.changed?t.dryRun?"would-change":"changed":"unchanged",a.mode,a.relativeFile,a.fallbackReason?`warning=${a.fallbackReason}`:void 0,a.remediationDebt?`debt=${a.remediationDebt}`:void 0,a.reasonCodes&&a.reasonCodes.length>0?`reasons=${a.reasonCodes.join(",")}`:void 0].filter(Boolean).join(" "))),c=[...new Set(l.flatMap(o=>o.retiredFiles??[]))].map(o=>`${t.dryRun?"would-retire":"retired"} legacy-agent-path-wrapper ${o}`);console.log(`${t.dryRun?"Project memory preview":"Project memory refreshed"}: ${t.projectRoot}`);for(const o of[...s,...c])console.log(o);return 0}catch(t){return console.error(t instanceof Error?t.message:String(t)),1}}export{P as parseRefreshMemoryArgs,O as refreshMemoryCliHandler,g as refreshProjectMemoryTargets,$ as verifyProjectMemoryTargets};
|
|
@@ -55,6 +55,8 @@ export interface WriteProjectMemoryTargetFilesResult {
|
|
|
55
55
|
readonly canonicalFilePath: string;
|
|
56
56
|
readonly files: readonly WriteProjectMemoryFileResult[];
|
|
57
57
|
readonly changed: boolean;
|
|
58
|
+
/** Legacy wrappers removed from (or stripped out of) agent discovery paths. */
|
|
59
|
+
readonly retiredFiles?: readonly string[];
|
|
58
60
|
}
|
|
59
61
|
export declare function createNodeProjectMemoryFs(backupDirectory?: string): ProjectMemoryWriterFs;
|
|
60
62
|
export declare const PROJECT_MEMORY_LAYER_CATEGORIES: readonly ["skills-agents", "frontend", "backend", "api", "db", "schemas", "envs", "devops", "cyber-security", "testing-qa", "observability", "product-business", "docs-architecture", "platform-memory", "command-behavior", "generic"];
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{randomUUID as
|
|
2
|
-
`).length>e.budget.maxLines||Buffer.byteLength(t,"utf8")>e.budget.maxBytes)throw new Error("Canonical project memory update exceeds its context budget; refusing to truncate existing content.")}function
|
|
1
|
+
import{randomUUID as W}from"node:crypto";import{constants as ee,existsSync as g,lstatSync as P,mkdirSync as j,copyFileSync as M,readdirSync as te,readFileSync as w,readlinkSync as re,realpathSync as q,renameSync as ne,rmSync as v,statSync as we,symlinkSync as F,unlinkSync as X,writeFileSync as G}from"node:fs";import{platform as I}from"node:os";import{basename as Re,dirname as _,join as y,relative as Pe,resolve as Ce}from"node:path";import{CANONICAL_PROJECT_MEMORY_SOURCE as h,getProjectMemoryTarget as z,renderArchitectureReferenceTable as Se}from"./shared-project-memory-types.js";import{assertProjectMemoryPaths as L,invalidProjectMemoryPath as $e,isValidScopedRelativePath as Te}from"./project-memory-path-scope.js";function oe(e){return(e.memoryNotes?.length??0)>0||(e.architectureReferences?.length??0)>0||e.bootstrapArchitecture!==void 0}const H="<!-- NEOCORTEX-REFRESH-UPDATES-START -->",Y="<!-- NEOCORTEX-REFRESH-UPDATES-END -->";function D(e,t){return e.split(t).length-1}function xe(e){ue(e.memoryNotes??[],e.architectureReferences??[],e.bootstrapArchitecture);const t=K(e.memoryNotes??[]).map(r=>`- [${r.reasonCode}] ${r.summary} (layer: ${r.layer})`),n=(e.architectureReferences??[]).map(r=>`- [architecture-reference] \`${r.path}\`: ${r.title}; ${r.purpose}; use: ${r.suggestedUsage}`),s=e.bootstrapArchitecture,o=s===void 0?[]:[...(s.universalLaws??[]).map(r=>`- [bootstrap-law] ${r}`),...(s.businessContext??[]).map(r=>`- [bootstrap-business] ${r}`),...(s.activeContext??[]).map(r=>`- [bootstrap-context] ${r}`),...(s.repositoryMap??[]).map(r=>`- [bootstrap-repository] ${r}`),...(s.environmentPractices??[]).map(r=>`- [bootstrap-environment] ${r}`),...(s.platformMemoryContract??[]).map(r=>`- [bootstrap-platform] ${r}`),...(s.maintenanceRules??[]).map(r=>`- [bootstrap-maintenance] ${r}`),...(s.heuristics??[]).map(r=>`- [bootstrap-heuristic] ${r}`)];return k([...t,...n,...o])}function ve(e,t){if(t.split(`
|
|
2
|
+
`).length>e.budget.maxLines||Buffer.byteLength(t,"utf8")>e.budget.maxBytes)throw new Error("Canonical project memory update exceeds its context budget; refusing to truncate existing content.")}function se(e,t,n){const s=xe(n);if(s.length===0)return t;const o=t.includes(`\r
|
|
3
3
|
`)?`\r
|
|
4
4
|
`:`
|
|
5
|
-
`,r=$(e),a=
|
|
5
|
+
`,r=$(e),a=T(e),u=D(t,r),c=D(t,a);if(u!==1||c!==1||t.indexOf(a)<t.indexOf(r))throw new Error("Canonical project memory has ambiguous managed-block markers; refusing refresh.");const l=D(t,H),i=D(t,Y);if(l!==i||l>1)throw new Error("Canonical project memory has ambiguous refresh-update markers; refusing refresh.");let m;if(l===0){const d=t.indexOf(a),p=t.slice(0,d),E=[H,"## Durable Refresh Updates",...s,Y,""].join(o);m=`${p}${p.endsWith(o)?"":o}${E}${t.slice(d)}`}else{const d=t.indexOf(H),p=t.indexOf(Y),E=t.indexOf(r),R=t.indexOf(a);if(d<E||p>R||p<d)throw new Error("Canonical refresh-update block is outside the managed block; refusing refresh.");const C=t.slice(d,p),B=new Set(C.split(/\r?\n/).map(S=>S.trim().toLowerCase())),f=s.filter(S=>!B.has(S.trim().toLowerCase()));if(f.length===0)return t;const N=t.slice(0,p);m=`${N}${N.endsWith(o)?"":o}${f.join(o)}${o}${t.slice(p)}`}return ve(e,m),m}function Oe(e){return{readFile(t){try{return w(t,"utf8")}catch{return}},writeFileAtomic(t,n){j(_(t),{recursive:!0});const s=W(),o=`${t}.tmp-${s}`,r=g(t)?pe(t,s,e):void 0;try{return G(o,n,{encoding:"utf8",flag:"wx",mode:384}),r!==void 0&&M(t,r,ee.COPYFILE_EXCL),ne(o,t),{backupPath:r}}catch(a){if(v(o,{force:!0}),r!==void 0&&g(r))try{M(r,t)}catch{}throw a}},join(...t){return y(...t)}}}function $(e){return`<!-- ${e.ownedBlockName}-START -->`}function T(e){return`<!-- ${e.ownedBlockName}-END -->`}function k(e){const t=new Set,n=[];for(const s of e){const o=s.trim().replace(/\s+/g," ");o.length===0||t.has(o.toLowerCase())||(t.add(o.toLowerCase()),n.push(o))}return n}function Ae(e){const t=new Set,n=[];for(const s of e)t.has(s.path)||(t.add(s.path),n.push(s));return n}function Ne(e){switch(e.templateKind){case"neocortex-md":return"# NEOCORTEX.md Project Memory";case"claude-md":return"# CLAUDE.md Project Memory";case"agents-md":return"# AGENTS.md Project Instructions";case"gemini-md":return"# GEMINI.md Project Memory";case"copilot-instructions":return"# GitHub Copilot Repository Instructions";case"cursor-rule":return`---
|
|
6
6
|
description: Neocortex project memory
|
|
7
7
|
alwaysApply: true
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
# Cursor Project Memory`}}const
|
|
11
|
-
`),
|
|
12
|
-
`),
|
|
13
|
-
`);return
|
|
14
|
-
`)}function
|
|
15
|
-
`)}const
|
|
16
|
-
${t.slice(0,2e3)}`),
|
|
10
|
+
# Cursor Project Memory`}}const je=["Keep always-loaded memory compact: laws, active context, and references only.","Preserve human-authored instructions outside this owned block.","Prefer repository SSoT docs over duplicating architecture details here."],Me=["Consult `docs/architecture/` before changes that affect architecture, contracts, data, security, performance, UX, or infrastructure.","Reference architecture documents by repository path, such as `docs/architecture/architecture.md`, before changing related implementation.","Summarize decisions and trade-offs in NEOCORTEX.md; do not paste complete architecture documents into memory.","Update memory for durable cross-layer changes across skills/agents, frontend, backend, API, DB, schemas, envs, DevOps, cyber security, testing/QA, observability, product, docs, and platform contracts.","Prioritize compact summaries of durable decisions, public contracts, operational risks, debts, command behavior, and repository paths; skip transient logs, raw payloads, secrets, private prompts, long documents, and duplicated canonical sources.","Keep platform memory files symlink-backed or include-backed to NEOCORTEX.md when supported."],dt=["skills-agents","frontend","backend","api","db","schemas","envs","devops","cyber-security","testing-qa","observability","product-business","docs-architecture","platform-memory","command-behavior","generic"],Ie=360,ae={feature:"Features",rule:"Rules/Policies",flag:"Flags",route:"Routes",api:"APIs/Contracts","db-schema":"DB/Schema",architecture:"Architecture",debt:"Debts",decision:"Decisions",generic:"General Updates"},_e=/\b(private|proprietary|server[- ]only|system)\s+prompt\b|\b(api[-_ ]?key|license[-_ ]?key|password|authorization|bearer|token|secret)\s*[:=]|\b(ghp_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|xox[baprs]-[A-Za-z0-9-]+)\b|\b(customer|cliente)\s+(payload|record|email|phone)\b|\b(customer|cliente)\s+(data|dados)\s+(payload|record|email|phone)\b|\b(customer|cliente)\s+(data|dados)\s*[:=]|\braw\s+payload\b/i;function Le(e){const t=e.toLowerCase();return/\b(project memory|canonical memory|memory heuristic|neocortex\.md|\*update-memory)\b/.test(t)?"decision":/\b(feature|capability|funcionalidade|release)\b/.test(t)?"feature":/\b(rule|policy|guardrail|regra|lei|must|never)\b/.test(t)?"rule":/\b(flag|feature[- ]?flag|toggle|env var|environment variable)\b/.test(t)?"flag":/\b(api|contract|schema contract|graphql|rest|rpc|webhook)\b/.test(t)?"api":/\b(db|database|schema|migration|table|column|prisma|sql)\b/.test(t)?"db-schema":/\b(decision|decisão|decisao|accepted|rejected|trade[- ]?off)\b/.test(t)?"decision":/\b(route|endpoint route|url path|pathname)\b|\/(api|admin|portal|v\d+)\//.test(t)?"route":/\b(architecture|arquitetura|adr|topology|infra|boundary)\b/.test(t)?"architecture":/\b(debt|follow[- ]?up|todo|tech[- ]?debt|dívida|divida)\b/.test(t)?"debt":"generic"}function De(e){const t=e.toLowerCase();return/\b(neocortex\.md|project memory|canonical memory|memory wrapper|symlink|owned block|memory heuristic)\b/.test(t)?"platform-memory":/\b(command|cli|\*update-memory|\*create-epic|\*arch-plan|workflow behavior)\b/.test(t)?"command-behavior":/\b(skill|agent|subagent|orchestrator|opencode|codex|claude|gemini|cursor)\b/.test(t)?"skills-agents":/\b(frontend|ui|ux|react|component|design[- ]?system|css|accessibility|a11y)\b/.test(t)?"frontend":/\b(backend|server|service|worker|job|queue)\b/.test(t)?"backend":/\b(api|endpoint|rest|graphql|rpc|webhook|contract)\b/.test(t)?"api":/\b(db|database|table|column|migration|sql|prisma)\b/.test(t)?"db":/\b(schema|schemas|zod|json schema|protobuf|openapi)\b/.test(t)?"schemas":/\b(env|environment|\.env\.example|config|configuration|feature[- ]?flag)\b/.test(t)?"envs":/\b(devops|deploy|deployment|ci|cd|docker|container|kubernetes|infra|terraform|rollback)\b/.test(t)?"devops":/\b(security|cyber|auth|authorization|permission|compliance|vulnerability|secret|token redaction)\b/.test(t)?"cyber-security":/\b(test|testing|qa|e2e|unit|integration|snapshot|property[- ]?based|flaky)\b/.test(t)?"testing-qa":/\b(observability|metric|metrics|log|logging|trace|tracing|alert|monitoring|slo)\b/.test(t)?"observability":/\b(product|business|user journey|onboarding|pricing|tenant|customer-facing)\b/.test(t)?"product-business":/\b(docs|documentation|architecture|arquitetura|adr|runbook|decision record)\b/.test(t)?"docs-architecture":"generic"}function ie(e){const t=e.trim().replace(/\s+/g," ");if(Buffer.byteLength(t,"utf8")<=Ie)return t;const n=t.match(/(?:^|\s)([\w.-]+(?:\/[\w.@-]+)+(?:\.[A-Za-z0-9]+)?)/)?.[1],s=t.slice(0,220).replace(/\s+\S*$/,"").trim();return n?`${s}\u2026 See ${n} for details.`:`${s}\u2026 Details omitted from always-loaded memory; keep source content in repository docs.`}function Ue(e){b(e);const t=Le(e),n=De(e);return{kind:t,layer:n,sectionTitle:ae[t],summary:ie(e),reasonCode:`memory_update_${t.replace("-","_")}`}}function K(e){const t=new Set,n=[];for(const s of e){const o=Ue(s),r=`${o.kind}:${o.summary.toLowerCase()}`;t.has(r)||(t.add(r),n.push(o))}return n}function b(e){if(_e.test(e))throw new Error("Project memory input violates IP boundary guardrails.")}function ce(e,t){const n=(e??"").split(`
|
|
11
|
+
`),s=t.split(`
|
|
12
|
+
`),o=[],r=Math.max(n.length,s.length);for(let u=0;u<r;u++){const c=n[u],l=s[u];if(c!==l&&(c!==void 0&&o.push(`- ${c}`),l!==void 0&&o.push(`+ ${l}`),o.length>=80)){o.push("\u2026 diff truncated; inspect repository diff for full context.");break}}const a=o.join(`
|
|
13
|
+
`);return b(a),a}function J(e){b(e.path),b(e.title),b(e.purpose),b(e.suggestedUsage)}function ue(e,t,n){e.forEach(b),t.forEach(J),n?.universalLaws?.forEach(b),n?.businessContext?.forEach(b),n?.activeContext?.forEach(b),n?.repositoryMap?.forEach(b),n?.environmentPractices?.forEach(b),n?.platformMemoryContract?.forEach(b),n?.maintenanceRules?.forEach(b),n?.heuristics?.forEach(b),n?.importantReferences?.forEach(J),n?.architectureReferences?.forEach(J)}function de(e){return[Ne(e),"","This file contains compact, always-loaded project memory. Keep detailed architecture in referenced docs.",""].join(`
|
|
14
|
+
`)}function le(e,t,n,s){ue(t,n,s);const o=k([...je,...s?.universalLaws??[]]),r=k([...s?.activeContext??[],...t.map(ie)]),a=K(t),u=k(s?.businessContext??["Product/business context was not explicitly documented during bootstrap; treat conclusions as repository-inferred until a human updates this section."]),c=k(s?.repositoryMap??["Source, tests, package/build files, docs, CI, and runtime manifests are the permitted bootstrap sources for repository orientation."]),l=k(s?.environmentPractices??["Use `.env.example` for configuration shape only; do not read real environment files or credential-bearing files into always-loaded memory."]),i=k(s?.platformMemoryContract??["Semantic platform memory file must resolve to NEOCORTEX.md through a symlink; do not replace it with an unrelated wrapper or copied frontmatter.","Platform wrapper/frontmatter must be preserved via split/include/managed block while the semantic memory payload remains symlink-backed by NEOCORTEX.md."]),m=k(s?.maintenanceRules??["Keep NEOCORTEX.md deterministic, compact, objective, and direct; store only summaries, indexes, and links to detailed docs.","Do not copy protected prompt bodies, proprietary wrappers, server-side internals, customer data, license keys, or long document bodies into always-loaded memory."]),d=Ae([...s?.importantReferences??[],...s?.architectureReferences??[],...n]),p=k([...Me,...s?.heuristics??[]]),E=o.map(f=>`- ${f}`),R=r.length>0?r.map(f=>`- ${f}`):["- No active project notes recorded."],C=d.length>0?Se(d):"No architecture references discovered.",B=a.length>0?Object.entries(ae).flatMap(([f,N])=>{const S=a.filter(x=>x.kind===f);return S.length>0?[`### ${N}`,...S.map(x=>`- [${x.reasonCode}] ${x.summary} (layer: ${x.layer})`)]:[]}):["- No durable change feedback recorded."];return[$(e),"## Universal Project Laws",...E,"","## Business/Product Context",...u.map(f=>`- ${f}`),"","## Active Context",...R,"","## Durable Change Feedback",...B,"","## Architecture References",C,"","## Repository Map",...c.map(f=>`- ${f}`),"","## Environment/Container/Production/Security/Dev Practices",...l.map(f=>`- ${f}`),"","## Platform Memory Contract",...i.map(f=>`- ${f}`),`- NEOCORTEX.md is the canonical project memory source for every platform target; run \`${e.bidirectionalReference.feedbackTrigger}\` when durable context discovered in a platform wrapper should be fed back into canonical memory.`,"","## Maintenance Rules",...m.map(f=>`- ${f}`),"","## Architecture Heuristics",...p.map(f=>`- ${f}`),T(e)].join(`
|
|
15
|
+
`)}const me=["docs/architecture","docs/arquitetura-software"],Be=["README.md","readme.md","architecture.md","docs/architecture.md"],We=["package.json","pnpm-lock.yaml","package-lock.json","yarn.lock","tsconfig.json","vite.config.ts","turbo.json"],qe=["Dockerfile","docker-compose.yml","compose.yml",".env.example","fly.toml"],Fe=["AGENTS.md","CLAUDE.md","GEMINI.md",".opencode/AGENTS.md",".cursor/rules/neocortex.mdc"];function fe(e,t,n=24e3){const s=y(e,t);try{if(!g(s)||P(s).isDirectory())return;const o=w(s,"utf8");return o.length<=n?o:o.slice(0,n)}catch{return}}function pe(e,t,n){if(!n)return`${e}.bak-${t}`;const s=Ce(n),o=P(s);if(!o.isDirectory()||o.isSymbolicLink()||o.uid!==process.getuid?.()||(o.mode&63)!==0||q(s)!==s)throw new Error("project-memory-backup-directory-unsafe");return y(s,`${Re(e)}.bak-${t}`)}function U(e,t,n){j(_(e),{recursive:!0});const s=W(),o=`${e}.tmp-${s}`,r=g(e)?pe(e,s,n):void 0;try{return G(o,t,{encoding:"utf8",flag:"wx",mode:384}),r!==void 0&&M(e,r,ee.COPYFILE_EXCL),ne(o,e),r}catch(a){if(v(o,{force:!0}),r!==void 0&&g(r))try{M(r,e)}catch{}throw a}}function Z(e){return Array.from(new Set(K(e).map(t=>t.reasonCode)))}function O(e,t){try{return g(y(e,t))}catch{return!1}}function Xe(e,t){try{return te(y(e,t),{withFileTypes:!0}).filter(n=>!n.name.startsWith(".")&&!n.name.toLowerCase().includes("secret")).sort((n,s)=>n.name.localeCompare(s.name)).slice(0,8).map(n=>`${t}/${n.name}${n.isDirectory()?"/":""}`)}catch{return[]}}function ye(e,t,n=16){try{const s=te(y(e,t),{withFileTypes:!0}).filter(r=>!r.name.startsWith(".")&&!r.name.startsWith("_")).sort((r,a)=>r.name.localeCompare(a.name)),o=[];for(const r of s){const a=`${t}/${r.name}`;if(r.isDirectory()?o.push(...ye(e,a,n-o.length)):/\.(md|markdown)$/i.test(r.name)&&o.push(a),o.length>=n)break}return o}catch{return[]}}function Ge(e,t){const n=t.match(/^#\s+(.+?)\s*$/m)?.[1]?.trim();return n?n.replace(/[`*_#]/g,""):e.split("/").pop()?.replace(/\.(md|markdown)$/i,"").replace(/[-_]+/g," ")??e}function ze(e,t){const n=/\b(stale|deprecated|outdated|incerto|uncertain)\b/i.test(`${e}
|
|
16
|
+
${t.slice(0,2e3)}`),s=t.replace(/^---[\s\S]*?---\s*/,"").split(/\n{2,}/).map(r=>r.replace(/^#+\s+.+$/gm,"").replace(/[`*_>#]/g,"").replace(/\s+/g," ").trim()).find(r=>r.length>0&&!r.startsWith("|"));return`${n?"[stale/uncertain evidence] ":""}${(s??"Architecture reference for this project.").slice(0,180)}`}function He(e){const t=e.toLowerCase();return/deploy|infra|docker|production|runbook/.test(t)?"Use before changing deployment, runtime, containers, or production operations.":/security|auth|compliance/.test(t)?"Use before changing auth, compliance, or security-sensitive behavior.":/api|contract|state|schema/.test(t)?"Use before changing contracts, APIs, schemas, or persisted state.":"Use before implementation in this area; verify freshness when marked stale or uncertain."}function he(e){const t=We.filter(i=>O(e,i)),n=qe.filter(i=>O(e,i)),s=Fe.filter(i=>O(e,i)),o=["packages","src","apps","tests","__tests__"].filter(i=>O(e,i)),a=[...me.flatMap(i=>ye(e,i)),...Be.filter(i=>O(e,i))].slice(0,24).flatMap(i=>{const m=fe(e,i,48e3);return m?[{path:i,title:Ge(i,m),purpose:ze(i,m),suggestedUsage:He(i),source:me.some(d=>i.startsWith(`${d}/`))?"architecture-root":"fallback-file"}]:[]}),u=fe(e,"package.json"),c=u?.match(/"name"\s*:\s*"([^"]+)"/)?.[1],l=[...u?.matchAll(/"(test|build|lint|typecheck|dev)"\s*:/g)??[]].map(i=>i[1]);return{universalLaws:["Bootstrap canonical memory before creating or repairing platform memory wrappers when NEOCORTEX.md is absent.","Use only permitted repository sources for bootstrap: package/build files, architecture docs, README/deploy docs, .env.example, runtime manifests, CI, source/test layout, and platform memory wrappers."],businessContext:[c?`Repository package name: ${c}.`:"Repository product name was not declared in package metadata.","Business/product conclusions are bootstrap-inferred and must be refined from canonical docs or human input."],activeContext:[`Bootstrap scanned ${t.length} package/build files, ${a.length} architecture/readme docs, ${n.length} runtime/config templates, and ${s.length} platform memory wrappers.`,l.length>0?`Detected quality scripts: ${l.sort().join(", ")}.`:"No standard quality scripts were detected in package metadata."],repositoryMap:[t.length>0?`Package/build files: ${t.join(", ")}.`:"No package/build files detected in permitted bootstrap set.",o.length>0?`Source/test roots: ${o.flatMap(i=>Xe(e,i)).slice(0,16).join(", ")}.`:"Source/test roots were not detected in standard locations.",s.length>0?`Platform memory/wrappers: ${s.join(", ")}.`:"No platform memory wrappers detected before bootstrap."],environmentPractices:[n.length>0?`Runtime/config templates: ${n.join(", ")}.`:"No Docker/compose/.env.example/runtime manifest detected in permitted bootstrap set.","Read `.env.example` only for configuration shape; never ingest real .env files, credentials, customer data, or license keys into memory.","Run repository quality scripts before commit and keep CI/deploy evidence referenced by path or URL rather than copied verbatim."],platformMemoryContract:["Semantic platform memory file must resolve to NEOCORTEX.md through a symlink; do not replace it with an unrelated wrapper or copied frontmatter.","Preserve wrappers/frontmatter via split/include/managed block while the semantic memory payload remains symlink-backed by NEOCORTEX.md."],maintenanceRules:["Generated memory must be deterministic, objective, direct, compact, and inside the target always-loaded context budget.","Cite long architecture docs by path with usage guidance; mark stale or uncertain docs when repository evidence indicates that status.","Do not copy protected prompt bodies, proprietary wrappers, server internals, secrets, customer data, license keys, or complete long documents."],architectureReferences:a,heuristics:["Before processing a story, consult the cited Architecture References whose path or suggested usage intersects the change.","When a referenced doc is marked stale/uncertain, validate against current package/runtime/source evidence before relying on it."]}}function V(e,t,n){const s=$(t),o=T(t),r=e.indexOf(s),a=e.indexOf(o);if(r>=0&&a>=r){const c=a+o.length;return`${e.slice(0,r)}${n}${e.slice(c)}`}const u=e.endsWith(`
|
|
17
17
|
`)?`
|
|
18
18
|
`:`
|
|
19
19
|
|
|
20
|
-
`;return`${e}${
|
|
20
|
+
`;return`${e}${u}${n}
|
|
21
21
|
`}function Ye(e){return e.endsWith(".mdc")?`---
|
|
22
22
|
description: Neocortex project memory
|
|
23
23
|
alwaysApply: true
|
|
@@ -32,9 +32,10 @@ name: neocortex
|
|
|
32
32
|
description: Neocortex project memory wrapper
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
`:""}function be(e,t){const n=
|
|
35
|
+
`:""}function be(e,t){const n=_(y(e,t)),s=y(e,h),o=Pe(n,s);return o.length>0?o:h}function A(e,t){return!!(e.targetId==="canonical"||e.requiresWrapperPreservation||e.linkRequirement.requiresWrapperPreservation||e.linkRequirement.wrapperAllowed||t==="AGENTS.md"||t.includes("/agents/")||t.includes("/skills/")||t.endsWith(".toml")||t.endsWith(".mdc")||t.endsWith(".agent.md")||t.endsWith(".instructions.md"))}function Ke(e){return e.linkRequirement.symlinkBacked&&e.linkRequirement.semanticFileRequired}function Q(e){return/EPERM|EACCES|operation not permitted|permission/i.test(e)?"EPERM: symlink permission denied":/ENOSYS|ENOTSUP|EOPNOTSUPP|not supported/i.test(e)?"symlink filesystem unsupported":"symlink capability unavailable"}function ge(e,t,n,s,o=!1){if(s!==void 0)return s;const r=Ke(t);if(!r)return{os:I(),supported:!1,permission:"unknown",filesystem:"unknown",targetPolicy:t.linkRequirement.policy,targetPolicyAllowsSymlink:r,requiresWrapperPreservation:A(t,n),reason:`target policy ${t.linkRequirement.policy} does not allow semantic symlink orchestration`};if(o)return{os:I(),supported:!0,permission:"unknown",filesystem:"unknown",targetPolicy:t.linkRequirement.policy,targetPolicyAllowsSymlink:r,requiresWrapperPreservation:A(t,n),reason:"dry-run does not probe filesystem symlink support"};const a=y(e,".neocortex","tmp"),u=W(),c=y(a,`symlink-capability-source-${u}`),l=y(a,`symlink-capability-link-${u}`);try{j(a,{recursive:!0}),G(c,"probe",{encoding:"utf8",flag:"wx",mode:384}),F(c,l);const i=P(l).isSymbolicLink()&&we(l).isFile();return{os:I(),supported:i,permission:i?"ok":"unknown",filesystem:i?"supports-symlink":"no-symlink-support",targetPolicy:t.linkRequirement.policy,targetPolicyAllowsSymlink:r,requiresWrapperPreservation:A(t,n),reason:i?void 0:"filesystem probe did not create a resolvable symbolic link"}}catch(i){const m=i instanceof Error?i.message:String(i),d=/EPERM|EACCES|operation not permitted|permission/i.test(m);return{os:I(),supported:!1,permission:d?"denied":"unknown",filesystem:"no-symlink-support",targetPolicy:t.linkRequirement.policy,targetPolicyAllowsSymlink:r,requiresWrapperPreservation:A(t,n),reason:Q(m)}}finally{v(l,{force:!0}),v(c,{force:!0})}}function Je(e,t,n,s){const o=be(s,t),r=n??`${Ye(t)}# ${e.platformName} Neocortex Memory Wrapper
|
|
36
36
|
|
|
37
|
-
`,a=[$(e),"## Canonical Project Memory Source","",`This platform wrapper preserves host-specific frontmatter/instructions while resolving project memory to \`${
|
|
38
|
-
`);return
|
|
39
|
-
`)}${n}`,
|
|
40
|
-
`).length<=e.budget.maxLines&&Buffer.byteLength(
|
|
37
|
+
`,a=[$(e),"## Canonical Project Memory Source","",`This platform wrapper preserves host-specific frontmatter/instructions while resolving project memory to \`${o}\`.`,"",`- Canonical source: \`${h}\``,`- Symlink-backed/source-of-truth file: \`${o}\``,`- Feedback loop: read \`${o}\` for shared context and run \`${e.bidirectionalReference.feedbackTrigger}\` when durable platform findings should update \`${h}\`.`,"- Human-authored content outside this managed block is preserved byte-for-byte.",T(e)].join(`
|
|
38
|
+
`);return V(r,e,a)}function ke(e,t,n,s,o,r=!1){const a=y(e,t),u=Q(o),l=`${["[NEOCORTEX COMPATIBILITY REMEDIATION]","Materialized project memory fallback because semantic symlink orchestration failed.","This is not product mode; repair host permissions/filesystem support and restore the symlink to NEOCORTEX.md.","WARNING: materialized fallback is remediation debt, not a silent mode; run *update-memory for durable context and repair this file back to canonical NEOCORTEX.md resolution.",`Fallback reason: ${u}`,""].join(`
|
|
39
|
+
`)}${n}`,m=(g(a)?w(a,"utf8"):void 0)!==l;return m&&!r&&(g(a)&&P(a).isSymbolicLink()&&X(a),U(a,l)),{filePath:a,relativeFile:t,changed:m,content:l,mode:"compatibility-materialized-fallback",canonicalSource:h,symlinkCapability:s,fallbackReason:u,remediationDebt:`Repair ${t} so it is a symlink to ${h}; fallback is compatibility remediation only.`}}function Ze(e,t,n,s,o,r=!1){const a=y(e,t),u=be(e,t);r||j(_(a),{recursive:!0});const c=ge(e,n,t,o,r);if(!c.supported)return ke(e,t,s,c,c.reason??"symlink capability detection reported unsupported host",r);if(r){let i=!0;try{i=!(g(a)&&P(a).isSymbolicLink()&&re(a)===u)}catch{i=!0}return{filePath:a,relativeFile:t,changed:i,content:s,mode:"semantic-symlink",canonicalSource:h,symlinkCapability:c}}let l=!1;try{return g(a)?P(a).isSymbolicLink()&&re(a)===u?l=!1:(X(a),F(u,a),l=!0):(F(u,a),l=!0),{filePath:a,relativeFile:t,changed:l,content:w(a,"utf8"),mode:"semantic-symlink",canonicalSource:h,symlinkCapability:c}}catch(i){const m=i instanceof Error?i.message:String(i),d=Q(m);return ke(e,t,s,{...c,supported:!1,permission:/EPERM|EACCES|operation not permitted|permission/i.test(m)?"denied":c.permission,filesystem:"no-symlink-support",reason:d},d,r)}}function Ve(e,t,n,s,o){const r=c=>c.split(`
|
|
40
|
+
`).length<=e.budget.maxLines&&Buffer.byteLength(c,"utf8")<=e.budget.maxBytes;if(r(t))return t;const a=le(e,n.slice(0,8),s.slice(0,12),o),u=V(t.includes($(e))?t:de(e),e,a);return r(u)?u:u.slice(0,e.budget.maxBytes)}function Ee(e,t,n=[],s=[],o){const r=t??de(e),a=le(e,n,s,o),u=V(r,e,a);return Ve(e,u,n,s,o)}function Qe(e){const t=z(e.targetId),n=e.fs??Oe(e.backupDirectory),s=n.join(e.projectRoot,t.primaryFile);if(e.fs===void 0&&t.targetId==="canonical"&&L(e.projectRoot,[h]),t.targetId!=="canonical"&&e.fs===void 0){const c=nt(e).files.find(l=>l.relativeFile===t.primaryFile);if(c===void 0)throw new Error(`Primary project memory file was not written for ${t.targetId}.`);return{filePath:c.filePath,changed:c.changed,content:c.content}}const o=n.readFile(s),r=e.bootstrapArchitecture??(e.fs===void 0&&t.targetId==="canonical"&&o===void 0?he(e.projectRoot):void 0),a=t.targetId==="canonical"&&o!==void 0?oe(e)?se(t,o,e):o:Ee(t,o,e.memoryNotes,e.architectureReferences,r);if(o===a)return{filePath:s,changed:!1,content:a};const u=e.dryRun?void 0:n.writeFileAtomic(s,a);return{filePath:s,changed:!0,content:a,safeDiff:ce(o,a),backupPath:u?.backupPath,reasonCodes:Z(e.memoryNotes??[])}}function lt(e){return Qe({...e,targetId:"canonical"})}const et={"claude-code":[".claude/agents/neocortex.md"],"gemini-cli":[".gemini/agents/neocortex.md"],antigravity:[".gemini/agents/neocortex.md"]},tt=/^# [^\n]* Neocortex Memory Wrapper\s*$/;function rt(e,t,n,s){const o=[];for(const r of et[t.targetId]??[]){L(e,[r]);const a=y(e,r);let u;try{u=P(a)}catch{continue}if(u.isSymbolicLink()){let p=!1;try{p=q(a)===q(y(e,h))}catch{p=!1}p&&(n||X(a),o.push(r));continue}if(!u.isFile())continue;const c=w(a,"utf8"),l=c.indexOf($(t)),i=c.indexOf(T(t));if(l<0||i<l)continue;const m=c.slice(0,l)+c.slice(i+T(t).length),d=m.trim();d.length===0||tt.test(d)?n||v(a,{force:!0}):n||U(a,`${m.replace(/\s+$/,"")}
|
|
41
|
+
`,s),o.push(r)}return o}function nt(e){if(e.fs!==void 0)throw new Error("writeProjectMemoryTargetFiles requires the node filesystem to manage symlinks safely.");const t=z(e.targetId),n=z("canonical");t.secondaryFiles.some(d=>d===null||d.scope!=="project"&&d.scope!=="user"||!Te(d.path))&&$e("invalid");const s=Array.from(new Set([t.primaryFile,...t.targetId==="canonical"?[]:t.secondaryFiles.filter(d=>d.scope==="project").map(d=>d.path)]));L(e.projectRoot,[h,...s,".neocortex/tmp"]);const o=y(e.projectRoot,h),r=g(o)?w(o,"utf8"):void 0,a=e.bootstrapArchitecture??(r===void 0?he(e.projectRoot):void 0),u=r!==void 0?oe(e)?se(n,r,e):r:Ee(n,r,e.memoryNotes,e.architectureReferences,a),c=!g(o)||w(o,"utf8")!==u;let l;if(c&&!e.dryRun&&(l=U(o,u,e.backupDirectory)),t.targetId==="canonical")return{targetId:t.targetId,canonicalFilePath:o,changed:c,files:[{filePath:o,relativeFile:h,changed:c,content:u,mode:"canonical",canonicalSource:h,safeDiff:ce(r,u),backupPath:l,reasonCodes:Z(e.memoryNotes??[])}]};const i=s.map(d=>{if(L(e.projectRoot,[d,".neocortex/tmp"]),!A(t,d))return Ze(e.projectRoot,d,t,u,e.symlinkCapability,e.dryRun);const p=y(e.projectRoot,d),E=g(p)?w(p,"utf8"):void 0,R=Je(t,d,E,e.projectRoot),C=E!==R;return C&&!e.dryRun&&U(p,R,e.backupDirectory),{filePath:p,relativeFile:d,changed:C,content:R,mode:"managed-wrapper",canonicalSource:h,symlinkCapability:ge(e.projectRoot,t,d,e.symlinkCapability,e.dryRun),reasonCodes:Z(e.memoryNotes??[])}}),m=rt(e.projectRoot,t,e.dryRun,e.backupDirectory);return{targetId:t.targetId,canonicalFilePath:o,files:i,changed:c||i.some(d=>d.changed)||m.length>0,...m.length>0?{retiredFiles:m}:{}}}export{dt as PROJECT_MEMORY_LAYER_CATEGORIES,he as bootstrapArchitectureMemory,Ee as buildProjectMemoryContent,Ue as classifyProjectMemoryUpdate,Oe as createNodeProjectMemoryFs,ce as createSafeProjectMemoryDiff,A as shouldUseManagedWrapper,lt as writeCanonicalProjectMemory,Qe as writeProjectMemory,nt as writeProjectMemoryTargetFiles};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function i(...t){return t.map(a=>({scope:"project",path:a}))}const e="NEOCORTEX.md",r={canonicalSource:e,semanticFileRequired:!0,symlinkBacked:!0,wrapperAllowed:!1,includeFallbackAllowed:!1,requiresWrapperPreservation:!1,fallbackIsCompatibilityRemediation:!0,policy:"mandatory-semantic-symlink",notes:"Semantic platform memory file must resolve to NEOCORTEX.md through a symlink; do not replace it with an unrelated wrapper or copied frontmatter."},l={canonicalSource:e,semanticFileRequired:!0,symlinkBacked:!0,wrapperAllowed:!0,includeFallbackAllowed:!1,requiresWrapperPreservation:!0,fallbackIsCompatibilityRemediation:!0,policy:"symlink-backed-wrapper",notes:"Platform wrapper/frontmatter is allowed only when the semantic memory payload remains symlink-backed by NEOCORTEX.md."},c={canonicalSource:e,semanticFileRequired:!0,symlinkBacked:!0,wrapperAllowed:!0,includeFallbackAllowed:!0,requiresWrapperPreservation:!0,fallbackIsCompatibilityRemediation:!0,policy:"safe-include-fallback",notes:"Use a safe include/import only for platforms that cannot consume symlinks directly; the include must resolve back to NEOCORTEX.md."};function o(t){return{canonicalSource:e,resolvesVia:t.policy,feedbackTrigger:"*update-memory",guidance:"Treat NEOCORTEX.md as canonical project memory; consult it before platform-specific memory, and run *update-memory when durable project context changes should flow back to the canonical source."}}const s=["claude-code","codex","grok","gemini-cli","antigravity","vscode","cursor","opencode","openclaw","kimi","github-copilot-cli"],m={canonical:{targetId:"canonical",platformName:"Neocortex Canonical Memory",canonicalSource:e,primaryFile:e,secondaryFiles:i("AGENTS.md","CLAUDE.md","GEMINI.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"neocortex-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!1,notes:"Canonical compact project memory source for platform symlinks and wrappers. Store only summaries, indexes, and links to architecture docs here."},"claude-code":{targetId:"claude-code",platformName:"Claude Code",canonicalSource:e,primaryFile:"CLAUDE.md",secondaryFiles:i(
|
|
1
|
+
function i(...t){return t.map(a=>({scope:"project",path:a}))}const e="NEOCORTEX.md",r={canonicalSource:e,semanticFileRequired:!0,symlinkBacked:!0,wrapperAllowed:!1,includeFallbackAllowed:!1,requiresWrapperPreservation:!1,fallbackIsCompatibilityRemediation:!0,policy:"mandatory-semantic-symlink",notes:"Semantic platform memory file must resolve to NEOCORTEX.md through a symlink; do not replace it with an unrelated wrapper or copied frontmatter."},l={canonicalSource:e,semanticFileRequired:!0,symlinkBacked:!0,wrapperAllowed:!0,includeFallbackAllowed:!1,requiresWrapperPreservation:!0,fallbackIsCompatibilityRemediation:!0,policy:"symlink-backed-wrapper",notes:"Platform wrapper/frontmatter is allowed only when the semantic memory payload remains symlink-backed by NEOCORTEX.md."},c={canonicalSource:e,semanticFileRequired:!0,symlinkBacked:!0,wrapperAllowed:!0,includeFallbackAllowed:!0,requiresWrapperPreservation:!0,fallbackIsCompatibilityRemediation:!0,policy:"safe-include-fallback",notes:"Use a safe include/import only for platforms that cannot consume symlinks directly; the include must resolve back to NEOCORTEX.md."};function o(t){return{canonicalSource:e,resolvesVia:t.policy,feedbackTrigger:"*update-memory",guidance:"Treat NEOCORTEX.md as canonical project memory; consult it before platform-specific memory, and run *update-memory when durable project context changes should flow back to the canonical source."}}const s=["claude-code","codex","grok","gemini-cli","antigravity","vscode","cursor","opencode","openclaw","kimi","github-copilot-cli"],m={canonical:{targetId:"canonical",platformName:"Neocortex Canonical Memory",canonicalSource:e,primaryFile:e,secondaryFiles:i("AGENTS.md","CLAUDE.md","GEMINI.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"neocortex-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!1,notes:"Canonical compact project memory source for platform symlinks and wrappers. Store only summaries, indexes, and links to architecture docs here."},"claude-code":{targetId:"claude-code",platformName:"Claude Code",canonicalSource:e,primaryFile:"CLAUDE.md",secondaryFiles:i(),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"claude-md",budget:{maxLines:320,maxBytes:28e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!1,notes:"Claude Code project memory. Resolve to NEOCORTEX.md; keep root content concise and link deeper docs with @path references."},codex:{targetId:"codex",platformName:"Codex CLI",canonicalSource:e,primaryFile:"AGENTS.md",secondaryFiles:i(".codex/agents/neocortex.toml"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"agents-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!0,notes:"Codex root instructions. Uppercase AGENTS.md is required on case-sensitive filesystems."},grok:{targetId:"grok",platformName:"Grok Build",canonicalSource:e,primaryFile:"AGENTS.md",secondaryFiles:i(".grok/skills/neocortex/SKILL.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"agents-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!0,notes:"Grok Build reads AGENTS.md and the project-local Neocortex Skill; both resolve to canonical NEOCORTEX.md context."},"gemini-cli":{targetId:"gemini-cli",platformName:"Gemini CLI",canonicalSource:e,primaryFile:"GEMINI.md",secondaryFiles:i(),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"gemini-md",budget:{maxLines:260,maxBytes:22e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!1,notes:"Gemini CLI context file. Prefer shallow @file.md imports for detailed architecture docs."},antigravity:{targetId:"antigravity",platformName:"Antigravity",canonicalSource:e,primaryFile:"GEMINI.md",secondaryFiles:i(),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"gemini-md",budget:{maxLines:260,maxBytes:22e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!1,notes:"Antigravity currently shares GEMINI.md behavior with the Gemini target stubs."},vscode:{targetId:"vscode",platformName:"VS Code / GitHub Copilot",canonicalSource:e,primaryFile:".github/copilot-instructions.md",secondaryFiles:i(".github/instructions/neocortex.instructions.md",".github/agents/neocortex.agent.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"copilot-instructions",budget:{maxLines:180,maxBytes:14e3},linkRequirement:l,bidirectionalReference:o(l),requiresWrapperPreservation:!0,notes:"VS Code and GitHub Copilot always-on repository instructions."},cursor:{targetId:"cursor",platformName:"Cursor",canonicalSource:e,primaryFile:".cursor/rules/neocortex.mdc",secondaryFiles:i("AGENTS.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"cursor-rule",budget:{maxLines:180,maxBytes:14e3},linkRequirement:l,bidirectionalReference:o(l),requiresWrapperPreservation:!0,notes:"Cursor rule memory. Use AGENTS.md as compatibility fallback when Cursor rules are absent."},opencode:{targetId:"opencode",platformName:"OpenCode",canonicalSource:e,primaryFile:"AGENTS.md",secondaryFiles:i(".opencode/AGENTS.md",".opencode/agents/neocortex-root.md",".opencode/agents/neocortex.md",".agent/skills/neocortex/SKILL.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"agents-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:r,bidirectionalReference:o(r),requiresWrapperPreservation:!0,notes:"OpenCode agent memory. It consumes AGENTS.md-compatible instructions and must resolve to canonical NEOCORTEX.md."},openclaw:{targetId:"openclaw",platformName:"OpenClaw",canonicalSource:e,primaryFile:".openclaw/skills/neocortex/SKILL.md",secondaryFiles:[{scope:"user",path:".openclaw/skills/neocortex/SKILL.md"}],ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"agents-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:c,bidirectionalReference:o(c),requiresWrapperPreservation:!0,notes:"OpenClaw Skill thin-client memory entrypoint. Use the project Skill path when --create-project is requested; do not mutate ~/.openclaw/openclaw.json, and keep memory content public-safe."},kimi:{targetId:"kimi",platformName:"Kimi",canonicalSource:e,primaryFile:"KIMI.md",secondaryFiles:i("AGENTS.md",".kimi/skills/neocortex/SKILL.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"agents-md",budget:{maxLines:220,maxBytes:18e3},linkRequirement:c,bidirectionalReference:o(c),requiresWrapperPreservation:!0,notes:"Kimi memory entrypoint. Prefer a symlink to NEOCORTEX.md; use a compact include only if the host cannot follow symlinks."},"github-copilot-cli":{targetId:"github-copilot-cli",platformName:"GitHub Copilot CLI / gh alias",canonicalSource:e,primaryFile:".github/copilot-instructions.md",secondaryFiles:i("AGENTS.md"),ownedBlockName:"NEOCORTEX-MEMORY",templateKind:"copilot-instructions",budget:{maxLines:180,maxBytes:14e3},linkRequirement:c,bidirectionalReference:o(c),requiresWrapperPreservation:!0,notes:"GitHub Copilot CLI or gh alias instructions. Resolve compact memory back to NEOCORTEX.md without copying private prompt bodies."}};function p(t){return m[t]}function u(t){return t==="canonical"||s.includes(t)}function y(){return s.map(t=>m[t])}function E(t){const a=n=>n.replace(/\|/g,"\\|").replace(/\n/g," ");return["| Path | Title | Purpose | Suggested Usage |","| --- | --- | --- | --- |",...t.map(n=>`| ${a(n.path)} | ${a(n.title)} | ${a(n.purpose)} | ${a(n.suggestedUsage)} |`)].join(`
|
|
2
2
|
`)}export{e as CANONICAL_PROJECT_MEMORY_SOURCE,m as PROJECT_MEMORY_TARGETS,s as PROJECT_MEMORY_TARGET_IDS,p as getProjectMemoryTarget,u as isProjectMemoryTargetId,y as listProjectMemoryTargets,E as renderArchitectureReferenceTable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lstatSync as
|
|
1
|
+
import{lstatSync as g,readFileSync as p}from"node:fs";import{homedir as P}from"node:os";import{join as s}from"node:path";import{getSubagentApprovalPolicy as S}from"../../config.js";import{HEADLESS_REASON_CODES as i,boundPublicSummary as l,hashPublicValue as f,redaction as h}from"./types.js";const c="[P201-EV-HEADLESS]",m=96*1024,v="## Parallel Delegation Contract";function M(r,e){const o=y(r,e);for(const t of o){let n;try{n=g(t)}catch(a){if(a.code==="ENOENT")continue;return u()}if(n.isSymbolicLink()||!n.isFile()||n.size<=0||n.size>m)return u();try{const a=p(t,"utf8");return A(r,a)?b(r,e):u()}catch{return u()}}return d(i.MANAGED_PROFILE_MISSING,"Managed neocortex profile was not found in a trusted host location.")}function D(r,e,o){return{status:"failed",adapterId:r,runtimeId:e.runtimeId,...e.modelId?{modelId:e.modelId}:{},...e.runtimeSource?{runtimeSource:e.runtimeSource}:{},reasonCode:o.reasonCode,reasonCodes:[o.reasonCode,i.RECEIPT_REDACTED],durationMs:0,counts:{governedPreflightDenials:1},hashes:{governanceEvidence:f(c)},publicSummary:o.publicSummary,redactionSummary:[h("managedProfile","managed_profile","value-denied")],relativePaths:[e.targetRef],...e.receipt?{receipt:e.receipt}:{},publicSafe:!0}}function C(r){return{...r,counts:{...r.counts,governedPreflightPasses:1},hashes:{...r.hashes,governanceEvidence:f(c)},publicSummary:l(`${r.publicSummary} ${c}`)}}function y(r,e){const o=[],t=E(e.env);if(r==="claude-code"){const n=[e.cwd,t].filter(a=>!!a);for(const a of n)o.push(s(a,".claude","agents","neocortex.md"));for(const a of n)o.push(s(a,".claude","agents","neocortex","neocortex.md"));return Array.from(new Set(o))}if(e.cwd&&o.push(s(e.cwd,".opencode","agents","neocortex.md")),!t)return o;{const n=e.env?.OPENCODE_HOME||s(e.env?.XDG_CONFIG_HOME||s(t,".config"),"opencode");o.push(s(n,"agents","neocortex.md")),o.push(s(t,".opencode","agents","neocortex.md"))}return Array.from(new Set(o))}function E(r){const e=r?r.HOME||r.USERPROFILE:P();return e&&!/[\r\n\0]/.test(e)?e:void 0}function A(r,e){if(Buffer.byteLength(e)>m)return!1;const o=/^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e)?.[1];return o===void 0||!e.includes("Never pass the original root invocation")||!e.includes(v)?!1:r==="claude-code"?/^name:\s*neocortex\s*$/m.test(o)&&/^permissionMode:\s*bypassPermissions\s*$/m.test(o)&&!/^disallowedTools:.*\b(?:Agent|Task)\b/m.test(o)&&/^\s*-\s*Agent\s*$/m.test(o):/^name:\s*neocortex\s*$/m.test(o)&&/^mode:\s*subagent\s*$/m.test(o)&&/^\s+"\*":\s*allow\s*$/m.test(o)&&!/^\s+task:\s*deny\s*$/m.test(o)&&e.includes("root OpenCode agent remains the yoloop owner")}function b(r,e){try{const o=E(e.env),t=S({...o?{configFilePath:s(o,".neocortex","config.json")}:{},platformTarget:r,hostPolicy:e.approvalHostPolicy}).resolution;return t.requestedMode!=="max"||t.effectiveMode!=="max"?d(i.APPROVAL_POLICY_MISMATCH,"Managed max profile did not match the effective subagent approval policy."):{ok:!0,publicSafe:!0}}catch{return d(i.APPROVAL_POLICY_INVALID,"Managed subagent approval policy could not be validated safely.")}}function d(r,e){return{ok:!1,reasonCode:r,publicSummary:l(`${e} ${c}`),publicSafe:!0}}function u(){return d(i.MANAGED_PROFILE_INVALID,"Managed neocortex profile failed bounded identity, approval, or isolation validation.")}export{c as GOVERNED_HEADLESS_EVIDENCE,D as governedPreflightFailureResult,M as preflightManagedHeadlessProfile,C as withGovernedHeadlessEvidence};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, public-safe host capacity probe for yoloop dispatch sizing.
|
|
3
|
+
*
|
|
4
|
+
* Reports numbers only (CPU count, memory in MiB, 1-minute load and an
|
|
5
|
+
* optional harness subagent limit). Never reads or emits hostnames, user
|
|
6
|
+
* names, paths, CPU model strings or any other environment value. The server
|
|
7
|
+
* owns the concurrency decision; this is untrusted advisory evidence.
|
|
8
|
+
*/
|
|
9
|
+
import { type YoloopHostCapacityV1 } from '../../../shared/dist/yoloop/host-capacity.js';
|
|
10
|
+
export interface HostCapacityOsSource {
|
|
11
|
+
readonly availableParallelism?: () => number;
|
|
12
|
+
readonly cpus: () => readonly unknown[];
|
|
13
|
+
readonly totalmem: () => number;
|
|
14
|
+
readonly freemem: () => number;
|
|
15
|
+
readonly loadavg: () => readonly number[];
|
|
16
|
+
}
|
|
17
|
+
export interface ProbeYoloopHostCapacityInput {
|
|
18
|
+
readonly platformTarget?: string;
|
|
19
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
20
|
+
readonly os?: HostCapacityOsSource;
|
|
21
|
+
readonly platform?: NodeJS.Platform;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Probe the host. Any failure or out-of-bounds value omits the observation
|
|
25
|
+
* (returns undefined) so the server falls back to its conservative default.
|
|
26
|
+
*/
|
|
27
|
+
export declare function probeYoloopHostCapacity(input?: ProbeYoloopHostCapacityInput): YoloopHostCapacityV1 | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as p from"node:os";import{parseYoloopHostCapacity as f}from"../../../shared/dist/yoloop/host-capacity.js";const u=1024*1024,d="CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS";function E(o){if(typeof o!="string"||!/^[1-9][0-9]{0,3}$/.test(o.trim()))return null;const t=Number.parseInt(o.trim(),10);return t<=1024?t:null}function a(o){return Number.isFinite(o)&&o>0?Math.floor(o/u):0}function _(o={}){try{const t=o.os??p,l=o.platform??process.platform,s=o.env??process.env,i=typeof t.availableParallelism=="function"?t.availableParallelism():t.cpus().length,r=a(t.totalmem()),c=Math.min(r,a(t.freemem()));let n=null;if(l!=="win32"){const e=t.loadavg()[0];n=typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e*100)/100:null}const m=o.platformTarget==="claude-code"?E(s[d]):null;return f({schemaVersion:1,logicalCpus:i,totalMemoryMiB:r,freeMemoryMiB:c,loadAverage1m:n,platformConcurrencyLimit:m,source:"client-probe"})}catch{return}}export{_ as probeYoloopHostCapacity};
|
|
@@ -82,7 +82,9 @@ export const PROJECT_MEMORY_TARGETS = {
|
|
|
82
82
|
platformName: 'Claude Code',
|
|
83
83
|
canonicalSource: CANONICAL_PROJECT_MEMORY_SOURCE,
|
|
84
84
|
primaryFile: 'CLAUDE.md',
|
|
85
|
-
|
|
85
|
+
// .claude/agents/ is the subagent discovery directory; a memory wrapper there
|
|
86
|
+
// shadows the real `neocortex` agent, so CLAUDE.md is the only wrapper.
|
|
87
|
+
secondaryFiles: projectFileRefs(),
|
|
86
88
|
ownedBlockName: 'NEOCORTEX-MEMORY',
|
|
87
89
|
templateKind: 'claude-md',
|
|
88
90
|
budget: { maxLines: 320, maxBytes: 28_000 },
|
|
@@ -124,7 +126,9 @@ export const PROJECT_MEMORY_TARGETS = {
|
|
|
124
126
|
platformName: 'Gemini CLI',
|
|
125
127
|
canonicalSource: CANONICAL_PROJECT_MEMORY_SOURCE,
|
|
126
128
|
primaryFile: 'GEMINI.md',
|
|
127
|
-
|
|
129
|
+
// .gemini/agents/neocortex.md is the native subagent written by the installer;
|
|
130
|
+
// GEMINI.md is the only memory wrapper.
|
|
131
|
+
secondaryFiles: projectFileRefs(),
|
|
128
132
|
ownedBlockName: 'NEOCORTEX-MEMORY',
|
|
129
133
|
templateKind: 'gemini-md',
|
|
130
134
|
budget: { maxLines: 260, maxBytes: 22_000 },
|
|
@@ -138,7 +142,9 @@ export const PROJECT_MEMORY_TARGETS = {
|
|
|
138
142
|
platformName: 'Antigravity',
|
|
139
143
|
canonicalSource: CANONICAL_PROJECT_MEMORY_SOURCE,
|
|
140
144
|
primaryFile: 'GEMINI.md',
|
|
141
|
-
|
|
145
|
+
// .gemini/agents/neocortex.md is the native subagent written by the installer;
|
|
146
|
+
// GEMINI.md is the only memory wrapper.
|
|
147
|
+
secondaryFiles: projectFileRefs(),
|
|
142
148
|
ownedBlockName: 'NEOCORTEX-MEMORY',
|
|
143
149
|
templateKind: 'gemini-md',
|
|
144
150
|
budget: { maxLines: 260, maxBytes: 22_000 },
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-reported yoloop host capacity observation (wire format + strict
|
|
3
|
+
* parser). Kept separate from the server-owned dispatcher so thin clients can
|
|
4
|
+
* build/validate the observation without bundling dispatch decisions.
|
|
5
|
+
*
|
|
6
|
+
* Numbers only: never paths, hostnames, usernames, environment values or PII.
|
|
7
|
+
*/
|
|
8
|
+
export const YOLOOP_HOST_CAPACITY_SCHEMA_VERSION = 1;
|
|
9
|
+
export const YOLOOP_HOST_CAPACITY_BOUNDS = Object.freeze({
|
|
10
|
+
logicalCpus: Object.freeze({ min: 1, max: 1_024 }),
|
|
11
|
+
memoryMiB: Object.freeze({ min: 0, max: 16_777_216 }),
|
|
12
|
+
loadAverage1m: Object.freeze({ min: 0, max: 4_096 }),
|
|
13
|
+
platformConcurrencyLimit: Object.freeze({ min: 1, max: 1_024 }),
|
|
14
|
+
});
|
|
15
|
+
const HOST_CAPACITY_KEYS = Object.freeze([
|
|
16
|
+
'freeMemoryMiB',
|
|
17
|
+
'loadAverage1m',
|
|
18
|
+
'logicalCpus',
|
|
19
|
+
'platformConcurrencyLimit',
|
|
20
|
+
'schemaVersion',
|
|
21
|
+
'source',
|
|
22
|
+
'totalMemoryMiB',
|
|
23
|
+
]);
|
|
24
|
+
function isIntegerInRange(value, min, max) {
|
|
25
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= min && value <= max;
|
|
26
|
+
}
|
|
27
|
+
function isFiniteInRange(value, min, max) {
|
|
28
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= min && value <= max;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Strict boundary parser for the client-reported host capacity. Exact keys,
|
|
32
|
+
* bounded finite non-negative numbers; anything else returns `undefined`.
|
|
33
|
+
*/
|
|
34
|
+
export function parseYoloopHostCapacity(value) {
|
|
35
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
36
|
+
return undefined;
|
|
37
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const record = value;
|
|
41
|
+
const keys = Object.keys(record).sort();
|
|
42
|
+
if (keys.length !== HOST_CAPACITY_KEYS.length
|
|
43
|
+
|| !keys.every((key, index) => key === HOST_CAPACITY_KEYS[index])) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const bounds = YOLOOP_HOST_CAPACITY_BOUNDS;
|
|
47
|
+
if (record.schemaVersion !== YOLOOP_HOST_CAPACITY_SCHEMA_VERSION)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (record.source !== 'client-probe')
|
|
50
|
+
return undefined;
|
|
51
|
+
if (!isIntegerInRange(record.logicalCpus, bounds.logicalCpus.min, bounds.logicalCpus.max))
|
|
52
|
+
return undefined;
|
|
53
|
+
if (!isIntegerInRange(record.totalMemoryMiB, bounds.memoryMiB.min, bounds.memoryMiB.max))
|
|
54
|
+
return undefined;
|
|
55
|
+
if (!isIntegerInRange(record.freeMemoryMiB, bounds.memoryMiB.min, bounds.memoryMiB.max))
|
|
56
|
+
return undefined;
|
|
57
|
+
if (record.freeMemoryMiB > record.totalMemoryMiB)
|
|
58
|
+
return undefined;
|
|
59
|
+
const load = record.loadAverage1m;
|
|
60
|
+
if (load !== null && !isFiniteInRange(load, bounds.loadAverage1m.min, bounds.loadAverage1m.max)) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const platformLimit = record.platformConcurrencyLimit;
|
|
64
|
+
if (platformLimit !== null && !isIntegerInRange(platformLimit, bounds.platformConcurrencyLimit.min, bounds.platformConcurrencyLimit.max)) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return Object.freeze({
|
|
68
|
+
schemaVersion: YOLOOP_HOST_CAPACITY_SCHEMA_VERSION,
|
|
69
|
+
logicalCpus: record.logicalCpus,
|
|
70
|
+
totalMemoryMiB: record.totalMemoryMiB,
|
|
71
|
+
freeMemoryMiB: record.freeMemoryMiB,
|
|
72
|
+
loadAverage1m: load,
|
|
73
|
+
platformConcurrencyLimit: platformLimit,
|
|
74
|
+
source: 'client-probe',
|
|
75
|
+
});
|
|
76
|
+
}
|
package/postinstall.js
CHANGED
|
@@ -23,7 +23,7 @@ const DEFAULT_KILL_SIGNAL = 'SIGTERM';
|
|
|
23
23
|
|
|
24
24
|
const liveChildren = new Set();
|
|
25
25
|
const PUBLIC_DIAGNOSTIC_PREFIX = '[neocortex-installer]';
|
|
26
|
-
const DEFAULT_OPTIONAL_TOOL_DOC = 'docs/install/
|
|
26
|
+
const DEFAULT_OPTIONAL_TOOL_DOC = 'docs/install/installer-diagnostics.md';
|
|
27
27
|
const RAW_DIAGNOSTIC_FIELDS = [
|
|
28
28
|
'stdout',
|
|
29
29
|
'stderr',
|
|
@@ -41,7 +41,7 @@ install_antigravity() {
|
|
|
41
41
|
# 1. Copy SKILL.md stub
|
|
42
42
|
if [ -f "$ag_target/skill/SKILL.md" ]; then
|
|
43
43
|
neocortex_managed_profile "$source_dir" "$ag_target/skill/SKILL.md" "$dest_dir/.agent/skills/neocortex/SKILL.md" "$dest_dir" "project-antigravity-skill"
|
|
44
|
-
|
|
44
|
+
neocortex_managed_report "[ANTIGRAVITY]" ".agent/skills/neocortex/SKILL.md (skill stub)"
|
|
45
45
|
fi
|
|
46
46
|
|
|
47
47
|
# 2. Install the documented global custom-child candidate. Project installs
|
|
@@ -53,7 +53,7 @@ install_antigravity() {
|
|
|
53
53
|
else
|
|
54
54
|
echo "[ANTIGRAVITY] WARN: child candidate not installed; fallback Skill remains active" >&2
|
|
55
55
|
fi
|
|
56
|
-
if
|
|
56
|
+
if ! neocortex_is_user_home "$dest_dir"; then
|
|
57
57
|
mkdir -p "$dest_dir/.agents/agents"
|
|
58
58
|
local project_child_installed=false
|
|
59
59
|
if neocortex_managed_profile "$source_dir" "$ag_target/neocortex.md" "$dest_dir/.agents/agents/neocortex.md" "$dest_dir" "project-antigravity-neocortex"; then
|
|
@@ -78,10 +78,11 @@ install_antigravity() {
|
|
|
78
78
|
}
|
|
79
79
|
fi
|
|
80
80
|
|
|
81
|
-
# 4. Copy GEMINI.md stub to project root
|
|
82
|
-
|
|
81
|
+
# 4. Copy GEMINI.md stub to project root. A global install passes $HOME as
|
|
82
|
+
# the destination; never drop a project GEMINI.md into the home directory.
|
|
83
|
+
if [ -f "$ag_target/gemini.md" ] && ! neocortex_is_user_home "$dest_dir"; then
|
|
83
84
|
neocortex_managed_profile "$source_dir" "$ag_target/gemini.md" "$dest_dir/GEMINI.md" "$dest_dir" "project-antigravity-root"
|
|
84
|
-
|
|
85
|
+
neocortex_managed_report "[ANTIGRAVITY]" "GEMINI.md (project root)"
|
|
85
86
|
fi
|
|
86
87
|
|
|
87
88
|
echo "[ANTIGRAVITY] Thin-client installation complete!"
|
|
@@ -24,8 +24,8 @@ Ambient platform/tool metadata, assistant notes, conversation history, raw logs,
|
|
|
24
24
|
This is a public thin delegated-task wrapper installed at project
|
|
25
25
|
`.agents/agents/neocortex.md` and global
|
|
26
26
|
`~/.gemini/config/agents/neocortex.md`. Installer presence does not prove a
|
|
27
|
-
versioned runtime smoke
|
|
28
|
-
fallback
|
|
27
|
+
versioned runtime smoke; the root always retains yoloop ownership and uses the
|
|
28
|
+
shell-loop fallback only when the host offers no subagent primitive.
|
|
29
29
|
All orchestration logic comes from the remote Neocortex server; never invent
|
|
30
30
|
local workflow steps in this profile.
|
|
31
31
|
|
|
@@ -42,16 +42,46 @@ Then follow stdout exactly.
|
|
|
42
42
|
|
|
43
43
|
## P127 Subagent Isolation Contract
|
|
44
44
|
|
|
45
|
-
The root agent intercepts the user trigger and calls `neocortex-client`.
|
|
46
|
-
|
|
47
|
-
`subagentType: 'neocortex'
|
|
48
|
-
returned delegated task prompt.
|
|
45
|
+
The root agent intercepts the user trigger and calls `neocortex-client`. When
|
|
46
|
+
stdout includes `metadata.skillDirectives[]` with `kind: 'task'` and
|
|
47
|
+
`subagentType: 'neocortex'`, or an execution plan with per-story prompts, the
|
|
48
|
+
runtime invokes this profile with the returned delegated task prompt.
|
|
49
49
|
|
|
50
50
|
Never pass the original root invocation, root yoloop command, full conversation
|
|
51
51
|
history, ambient metadata, raw logs, or raw stdout/stderr into this profile. Do
|
|
52
52
|
not pass unmanaged user-owned content. Do not embed, reveal, summarize, or reconstruct proprietary prompts, server-side
|
|
53
53
|
implementation details, orchestration logic, secrets, license keys, or customer
|
|
54
|
-
data.
|
|
54
|
+
data. Children may delegate further to `neocortex` sub-agents when their
|
|
55
|
+
server output authorizes it, passing only server-authored prompts.
|
|
56
|
+
|
|
57
|
+
## Parallel Delegation Contract
|
|
58
|
+
|
|
59
|
+
Parallel subagent delegation is the default on every harness and OS, including
|
|
60
|
+
Antigravity. When the server authorizes delegation
|
|
61
|
+
(`taskDelegationCapability: 'native_safe'`) and returns a root-owned execution
|
|
62
|
+
plan, the root agent dispatches independent stories in parallel with
|
|
63
|
+
Antigravity subagents (`.agents/agents/neocortex.md`):
|
|
64
|
+
|
|
65
|
+
- `mode: parallel_wave`: for the current entry of `parallelWaves[]`, take its
|
|
66
|
+
`storyIds` (and matching `promptTemplates`, when present).
|
|
67
|
+
- `mode: continuous_dag`: take the plan's ready `storyIds` (and matching
|
|
68
|
+
`promptTemplates`, when present).
|
|
69
|
+
- Spawn ONE `neocortex` child per story **in a single turn with multiple subagent calls**, so the children truly run
|
|
70
|
+
in parallel. When the plan gives `maxConcurrency`, launch at most that many at
|
|
71
|
+
once and start the remainder as earlier children return.
|
|
72
|
+
- Each child receives only its server-authored per-story prompt, for example
|
|
73
|
+
`*yolo @docs/stories/<id>.story.md` or the `... branchless-preparation`
|
|
74
|
+
variant returned by the server. Never pass the outer `@neocortex *yoloop ...`
|
|
75
|
+
or any root invocation to a child.
|
|
76
|
+
- Serial plans (`mode: serial`, a single story, or no plan) keep one child at a
|
|
77
|
+
time.
|
|
78
|
+
- Children may delegate further when the server output they receive authorizes
|
|
79
|
+
it.
|
|
80
|
+
- The root agent keeps yoloop ownership: it waits for all children of the wave,
|
|
81
|
+
then re-invokes `*yoloop`; server output decides integration and the next
|
|
82
|
+
wave. Follow stdout and server output; never invent workflow steps.
|
|
83
|
+
|
|
84
|
+
If the Antigravity host offers no subagent primitive in the current session, the root keeps the documented shell-loop fallback, but parallel delegation is used whenever the host offers it.
|
|
55
85
|
|
|
56
86
|
At the root only, `epicTerminalGitDirective` uses the recorded origin and
|
|
57
87
|
forbids worktree management, force-push and ambiguous/unintegrated cleanup.
|