@ornexus/neocortex 4.0.1
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.
Potentially problematic release.
This version of @ornexus/neocortex might be problematic. Click here for more details.
- package/LICENSE +56 -0
- package/README.md +32 -0
- package/install.js +486 -0
- package/install.ps1 +1790 -0
- package/install.sh +1587 -0
- package/package.json +104 -0
- package/packages/client/dist/adapters/adapter-registry.d.ts +61 -0
- package/packages/client/dist/adapters/adapter-registry.js +106 -0
- package/packages/client/dist/adapters/antigravity-adapter.d.ts +18 -0
- package/packages/client/dist/adapters/antigravity-adapter.js +77 -0
- package/packages/client/dist/adapters/claude-code-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/claude-code-adapter.js +79 -0
- package/packages/client/dist/adapters/codex-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/codex-adapter.js +80 -0
- package/packages/client/dist/adapters/cursor-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/cursor-adapter.js +115 -0
- package/packages/client/dist/adapters/gemini-adapter.d.ts +18 -0
- package/packages/client/dist/adapters/gemini-adapter.js +71 -0
- package/packages/client/dist/adapters/index.d.ts +19 -0
- package/packages/client/dist/adapters/index.js +21 -0
- package/packages/client/dist/adapters/platform-detector.d.ts +46 -0
- package/packages/client/dist/adapters/platform-detector.js +106 -0
- package/packages/client/dist/adapters/target-adapter.d.ts +70 -0
- package/packages/client/dist/adapters/target-adapter.js +12 -0
- package/packages/client/dist/adapters/vscode-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/vscode-adapter.js +72 -0
- package/packages/client/dist/agent/refresh-stubs.d.ts +65 -0
- package/packages/client/dist/agent/refresh-stubs.js +234 -0
- package/packages/client/dist/agent/update-agent-yaml.d.ts +26 -0
- package/packages/client/dist/agent/update-agent-yaml.js +102 -0
- package/packages/client/dist/agent/update-description.d.ts +45 -0
- package/packages/client/dist/agent/update-description.js +251 -0
- package/packages/client/dist/cache/crypto-utils.d.ts +30 -0
- package/packages/client/dist/cache/crypto-utils.js +76 -0
- package/packages/client/dist/cache/encrypted-cache.d.ts +30 -0
- package/packages/client/dist/cache/encrypted-cache.js +94 -0
- package/packages/client/dist/cache/in-memory-asset-cache.d.ts +59 -0
- package/packages/client/dist/cache/in-memory-asset-cache.js +70 -0
- package/packages/client/dist/cache/index.d.ts +13 -0
- package/packages/client/dist/cache/index.js +13 -0
- package/packages/client/dist/cli.d.ts +14 -0
- package/packages/client/dist/cli.js +194 -0
- package/packages/client/dist/commands/activate.d.ts +55 -0
- package/packages/client/dist/commands/activate.js +390 -0
- package/packages/client/dist/commands/cache-status.d.ts +39 -0
- package/packages/client/dist/commands/cache-status.js +112 -0
- package/packages/client/dist/commands/invoke.d.ts +70 -0
- package/packages/client/dist/commands/invoke.js +490 -0
- package/packages/client/dist/config/resolver-selection.d.ts +40 -0
- package/packages/client/dist/config/resolver-selection.js +278 -0
- package/packages/client/dist/config/secure-config.d.ts +78 -0
- package/packages/client/dist/config/secure-config.js +269 -0
- package/packages/client/dist/constants.d.ts +25 -0
- package/packages/client/dist/constants.js +25 -0
- package/packages/client/dist/context/context-collector.d.ts +28 -0
- package/packages/client/dist/context/context-collector.js +222 -0
- package/packages/client/dist/context/context-sanitizer.d.ts +28 -0
- package/packages/client/dist/context/context-sanitizer.js +145 -0
- package/packages/client/dist/index.d.ts +55 -0
- package/packages/client/dist/index.js +38 -0
- package/packages/client/dist/license/index.d.ts +5 -0
- package/packages/client/dist/license/index.js +5 -0
- package/packages/client/dist/license/license-client.d.ts +79 -0
- package/packages/client/dist/license/license-client.js +257 -0
- package/packages/client/dist/machine/fingerprint.d.ts +34 -0
- package/packages/client/dist/machine/fingerprint.js +160 -0
- package/packages/client/dist/machine/index.d.ts +5 -0
- package/packages/client/dist/machine/index.js +5 -0
- package/packages/client/dist/resilience/circuit-breaker.d.ts +70 -0
- package/packages/client/dist/resilience/circuit-breaker.js +170 -0
- package/packages/client/dist/resilience/degradation-manager.d.ts +67 -0
- package/packages/client/dist/resilience/degradation-manager.js +164 -0
- package/packages/client/dist/resilience/freshness-indicator.d.ts +59 -0
- package/packages/client/dist/resilience/freshness-indicator.js +100 -0
- package/packages/client/dist/resilience/index.d.ts +8 -0
- package/packages/client/dist/resilience/index.js +8 -0
- package/packages/client/dist/resilience/recovery-detector.d.ts +59 -0
- package/packages/client/dist/resilience/recovery-detector.js +74 -0
- package/packages/client/dist/resolvers/asset-resolver.d.ts +79 -0
- package/packages/client/dist/resolvers/asset-resolver.js +13 -0
- package/packages/client/dist/resolvers/local-resolver.d.ts +26 -0
- package/packages/client/dist/resolvers/local-resolver.js +218 -0
- package/packages/client/dist/resolvers/remote-resolver.d.ts +91 -0
- package/packages/client/dist/resolvers/remote-resolver.js +282 -0
- package/packages/client/dist/telemetry/index.d.ts +5 -0
- package/packages/client/dist/telemetry/index.js +5 -0
- package/packages/client/dist/telemetry/offline-queue.d.ts +57 -0
- package/packages/client/dist/telemetry/offline-queue.js +131 -0
- package/packages/client/dist/tier/index.d.ts +5 -0
- package/packages/client/dist/tier/index.js +5 -0
- package/packages/client/dist/tier/tier-aware-client.d.ts +97 -0
- package/packages/client/dist/tier/tier-aware-client.js +260 -0
- package/packages/client/dist/types/index.d.ts +140 -0
- package/packages/client/dist/types/index.js +38 -0
- package/postinstall.js +272 -0
- package/targets-stubs/antigravity/README.md +36 -0
- package/targets-stubs/antigravity/gemini.md +22 -0
- package/targets-stubs/antigravity/install-antigravity.sh +44 -0
- package/targets-stubs/antigravity/mcp-config.json +9 -0
- package/targets-stubs/antigravity/skill/SKILL.md +67 -0
- package/targets-stubs/claude-code/README.md +20 -0
- package/targets-stubs/claude-code/neocortex.agent.yaml +24 -0
- package/targets-stubs/claude-code/neocortex.md +125 -0
- package/targets-stubs/codex/README.md +32 -0
- package/targets-stubs/codex/agents.md +61 -0
- package/targets-stubs/codex/config-mcp.toml +6 -0
- package/targets-stubs/codex/install-codex.sh +61 -0
- package/targets-stubs/cursor/README.md +33 -0
- package/targets-stubs/cursor/agent.md +94 -0
- package/targets-stubs/cursor/install-cursor.sh +35 -0
- package/targets-stubs/cursor/mcp.json +11 -0
- package/targets-stubs/gemini-cli/README.md +34 -0
- package/targets-stubs/gemini-cli/agent.md +101 -0
- package/targets-stubs/gemini-cli/gemini.md +16 -0
- package/targets-stubs/gemini-cli/install-gemini.sh +56 -0
- package/targets-stubs/gemini-cli/settings-mcp.json +11 -0
- package/targets-stubs/vscode/README.md +34 -0
- package/targets-stubs/vscode/agent.md +102 -0
- package/targets-stubs/vscode/copilot-instructions.md +16 -0
- package/targets-stubs/vscode/install-vscode.sh +42 -0
- package/targets-stubs/vscode/mcp.json +13 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @neocortex/client - Stub Refresh Module
|
|
15
|
+
*
|
|
16
|
+
* Detects version mismatch between installed stubs and CLI version.
|
|
17
|
+
* Re-copies full stub files from the package when outdated.
|
|
18
|
+
*
|
|
19
|
+
* Called by activate.ts BEFORE updateAgentDescription() to ensure
|
|
20
|
+
* the stub file has all current sections (Banner, Plugin Guard, etc.)
|
|
21
|
+
* before the regex patcher runs.
|
|
22
|
+
*
|
|
23
|
+
* Never throws -- stub refresh is non-critical.
|
|
24
|
+
*
|
|
25
|
+
* Story 55.1
|
|
26
|
+
*/
|
|
27
|
+
import { readFileSync, writeFileSync, copyFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
28
|
+
import { join, dirname } from 'node:path';
|
|
29
|
+
import { homedir } from 'node:os';
|
|
30
|
+
import { fileURLToPath } from 'node:url';
|
|
31
|
+
import { setSecureFilePermissions } from '../config/secure-config.js';
|
|
32
|
+
// -- Banner Frame Constants ---------------------------------------------------
|
|
33
|
+
const BANNER_INNER = 60;
|
|
34
|
+
const BANNER_PREFIX_INNER = 25;
|
|
35
|
+
// -- Version Patching ---------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Replace all version strings in a stub file with the given version.
|
|
38
|
+
* Handles 4 patterns:
|
|
39
|
+
* 1. Emoji description: 🧠 Neocortex vX.Y.Z
|
|
40
|
+
* 2. Plain markdown header: # Neocortex vX.Y.Z
|
|
41
|
+
* 3. Banner line: │ ### ######## vX.Y.Z ...│
|
|
42
|
+
* 4. YAML version field: version: 'X.Y.Z'
|
|
43
|
+
*
|
|
44
|
+
* Never throws -- version patching is best-effort.
|
|
45
|
+
* Story 71.2
|
|
46
|
+
*/
|
|
47
|
+
export function patchVersionInFile(filePath, version) {
|
|
48
|
+
try {
|
|
49
|
+
let content = readFileSync(filePath, 'utf-8');
|
|
50
|
+
const original = content;
|
|
51
|
+
// Pattern 1: Emoji description/header (🧠 Neocortex vX.Y.Z)
|
|
52
|
+
content = content.replace(/🧠 Neocortex v[\d.]+/g, `🧠 Neocortex v${version}`);
|
|
53
|
+
// Pattern 2: Plain markdown header (# Neocortex vX.Y.Z)
|
|
54
|
+
content = content.replace(/# Neocortex v[\d.]+/g, `# Neocortex v${version}`);
|
|
55
|
+
// Pattern 3: Banner version line (│ ### ######## vX.Y.Z ...│)
|
|
56
|
+
content = content.replace(/^(│ ### ######## v)[\d.]+(\s*│)$/gm, () => {
|
|
57
|
+
const ver = `v${version}`;
|
|
58
|
+
const pad = BANNER_INNER - BANNER_PREFIX_INNER - ver.length;
|
|
59
|
+
return `\u2502 ### ######## ${ver}${' '.repeat(Math.max(0, pad))}\u2502`;
|
|
60
|
+
});
|
|
61
|
+
// Pattern 4: YAML version field (version: 'X.Y.Z')
|
|
62
|
+
content = content.replace(/version: '[\d.]+'/g, `version: '${version}'`);
|
|
63
|
+
if (content !== original) {
|
|
64
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Non-critical -- version patching is best-effort
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const STUB_TARGETS = [
|
|
72
|
+
{
|
|
73
|
+
destDir: join(homedir(), '.claude', 'agents', 'neocortex'),
|
|
74
|
+
sourceDir: 'claude-code',
|
|
75
|
+
files: ['neocortex.md', 'neocortex.agent.yaml'],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
destDir: join(homedir(), '.gemini', 'agents'),
|
|
79
|
+
sourceDir: 'gemini-cli',
|
|
80
|
+
files: ['agent.md'],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
destDir: join(homedir(), '.cursor', 'agents'),
|
|
84
|
+
sourceDir: 'cursor',
|
|
85
|
+
files: ['agent.md'],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
destDir: join(homedir(), '.codex'),
|
|
89
|
+
sourceDir: 'codex',
|
|
90
|
+
files: ['agents.md'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
destDir: join(homedir(), '.vscode'),
|
|
94
|
+
sourceDir: 'vscode',
|
|
95
|
+
files: ['agent.md'],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
destDir: join(homedir(), '.agent', 'skills', 'neocortex'),
|
|
99
|
+
sourceDir: 'antigravity',
|
|
100
|
+
files: ['skill/SKILL.md'],
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
// -- Package Root Resolution --------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* Find the monorepo / npm package root by walking up from this file's location.
|
|
106
|
+
* Looks for a package.json with name '@ornexus/neocortex' (monorepo root) or
|
|
107
|
+
* '@neocortex/client' (client package root that contains targets-stubs after build).
|
|
108
|
+
*
|
|
109
|
+
* Returns null if not found within 10 levels.
|
|
110
|
+
*/
|
|
111
|
+
export function findPackageRoot() {
|
|
112
|
+
try {
|
|
113
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
114
|
+
let dir = dirname(thisFile);
|
|
115
|
+
for (let i = 0; i < 10; i++) {
|
|
116
|
+
try {
|
|
117
|
+
const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'));
|
|
118
|
+
if (pkg.name === '@ornexus/neocortex') {
|
|
119
|
+
return dir;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch { /* no package.json at this level */ }
|
|
123
|
+
dir = dirname(dir);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch { /* fallback */ }
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
// -- Version Comparison -------------------------------------------------------
|
|
130
|
+
/**
|
|
131
|
+
* Read the installed version from .version file in the dest directory.
|
|
132
|
+
* Returns null if file doesn't exist or is unreadable.
|
|
133
|
+
*/
|
|
134
|
+
function readInstalledVersion(destDir) {
|
|
135
|
+
try {
|
|
136
|
+
const versionFile = join(destDir, '.version');
|
|
137
|
+
if (existsSync(versionFile)) {
|
|
138
|
+
return readFileSync(versionFile, 'utf-8').trim() || null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch { /* unreadable */ }
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Refresh installed stubs if CLI version differs from installed version.
|
|
146
|
+
*
|
|
147
|
+
* For each stub target:
|
|
148
|
+
* 1. Read .version from install dir
|
|
149
|
+
* 2. Compare with cliVersion
|
|
150
|
+
* 3. If different (or .version missing): re-copy all stub files + write .version
|
|
151
|
+
* 4. If same: skip (no-op)
|
|
152
|
+
*
|
|
153
|
+
* When options.forceCreate is true, creates destDir if it doesn't exist.
|
|
154
|
+
* When options.targetFilter is set, only processes matching target.
|
|
155
|
+
*
|
|
156
|
+
* Never throws -- stub refresh is non-critical.
|
|
157
|
+
* Returns the number of targets that were refreshed.
|
|
158
|
+
*/
|
|
159
|
+
export function refreshStubs(cliVersion, options) {
|
|
160
|
+
try {
|
|
161
|
+
const forceCreate = options?.forceCreate ?? false;
|
|
162
|
+
const targetFilter = options?.targetFilter;
|
|
163
|
+
const packageRoot = findPackageRoot();
|
|
164
|
+
if (!packageRoot) {
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
// targets-stubs/ is at the package root level
|
|
168
|
+
const stubsRoot = join(packageRoot, 'targets-stubs');
|
|
169
|
+
if (!existsSync(stubsRoot)) {
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
let refreshed = 0;
|
|
173
|
+
for (const target of STUB_TARGETS) {
|
|
174
|
+
try {
|
|
175
|
+
// If targetFilter is set, skip non-matching targets
|
|
176
|
+
if (targetFilter && target.sourceDir !== targetFilter) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// Epic 67 - Story 67.3: If forceCreate, create destDir when it doesn't exist
|
|
180
|
+
if (!existsSync(target.destDir)) {
|
|
181
|
+
if (forceCreate) {
|
|
182
|
+
mkdirSync(target.destDir, { recursive: true });
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const installedVersion = readInstalledVersion(target.destDir);
|
|
189
|
+
if (installedVersion === cliVersion) {
|
|
190
|
+
continue; // Already up to date
|
|
191
|
+
}
|
|
192
|
+
// Source directory for this target
|
|
193
|
+
const sourceDir = join(stubsRoot, target.sourceDir);
|
|
194
|
+
if (!existsSync(sourceDir)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
// Copy each file
|
|
198
|
+
let copiedAny = false;
|
|
199
|
+
for (const file of target.files) {
|
|
200
|
+
const src = join(sourceDir, file);
|
|
201
|
+
const dest = join(target.destDir, file);
|
|
202
|
+
if (existsSync(src)) {
|
|
203
|
+
// Ensure parent directory exists (handles nested paths like skill/SKILL.md)
|
|
204
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
205
|
+
copyFileSync(src, dest);
|
|
206
|
+
// Story 71.2: Substitute version strings in copied stubs
|
|
207
|
+
if (file.endsWith('.md') || file.endsWith('.yaml') || file.endsWith('.yml')) {
|
|
208
|
+
patchVersionInFile(dest, cliVersion);
|
|
209
|
+
}
|
|
210
|
+
// Story 66.3 AC1: Apply ACL/chmod after copy (runs after patchVersionInFile rewrite)
|
|
211
|
+
setSecureFilePermissions(dest);
|
|
212
|
+
copiedAny = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Write .version file
|
|
216
|
+
if (copiedAny) {
|
|
217
|
+
const versionPath = join(target.destDir, '.version');
|
|
218
|
+
writeFileSync(versionPath, cliVersion + '\n', 'utf-8');
|
|
219
|
+
// Story 66.3 AC2: Apply ACL/chmod on .version file
|
|
220
|
+
setSecureFilePermissions(versionPath);
|
|
221
|
+
refreshed++;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
// Non-critical -- continue with next target
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return refreshed;
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// Non-critical -- entire function is best-effort
|
|
232
|
+
return 0;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Update agent.yaml files across all known locations.
|
|
15
|
+
* Returns count of files updated.
|
|
16
|
+
*
|
|
17
|
+
* Never throws.
|
|
18
|
+
*/
|
|
19
|
+
export declare function updateAgentYaml(version: string, tier?: string): number;
|
|
20
|
+
/**
|
|
21
|
+
* Update agent.yaml at a specific file path (used for testing).
|
|
22
|
+
* Returns true if the file was modified.
|
|
23
|
+
*
|
|
24
|
+
* Never throws.
|
|
25
|
+
*/
|
|
26
|
+
export declare function updateAgentYamlAt(filePath: string, version: string, tier?: string): boolean;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @neocortex/client - Agent YAML Updater
|
|
15
|
+
*
|
|
16
|
+
* Patches neocortex.agent.yaml with current version and tier-based title.
|
|
17
|
+
*
|
|
18
|
+
* Patches TWO fields:
|
|
19
|
+
* 1. version: 'X.X.X'
|
|
20
|
+
* 2. title: 'Development Orchestrator (Tier)'
|
|
21
|
+
*
|
|
22
|
+
* Called after:
|
|
23
|
+
* - refreshStubs() (ensures YAML exists with current structure)
|
|
24
|
+
* - updateAgentDescription() (ensures consistency across all surfaces)
|
|
25
|
+
*
|
|
26
|
+
* Never throws -- YAML update is non-critical.
|
|
27
|
+
*
|
|
28
|
+
* Story 55.2
|
|
29
|
+
*/
|
|
30
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
31
|
+
import { join } from 'node:path';
|
|
32
|
+
import { homedir } from 'node:os';
|
|
33
|
+
// -- Constants ----------------------------------------------------------------
|
|
34
|
+
const TIER_LABELS = {
|
|
35
|
+
free: 'Free',
|
|
36
|
+
pro: 'Pro',
|
|
37
|
+
enterprise: 'Enterprise',
|
|
38
|
+
};
|
|
39
|
+
// Regex patterns for YAML fields (simple key: 'value' format)
|
|
40
|
+
const VERSION_PATTERN = /^(\s*version:\s*)'[^']*'/m;
|
|
41
|
+
const TITLE_PATTERN = /^(\s*title:\s*)'[^']*'/m;
|
|
42
|
+
const HOME_YAML_FILES = [
|
|
43
|
+
join(homedir(), '.claude', 'agents', 'neocortex', 'neocortex.agent.yaml'),
|
|
44
|
+
];
|
|
45
|
+
// -- Internal -----------------------------------------------------------------
|
|
46
|
+
/**
|
|
47
|
+
* Patch a single agent.yaml file with version and tier.
|
|
48
|
+
* Returns true if file was modified.
|
|
49
|
+
*/
|
|
50
|
+
function patchYamlFile(filePath, version, tier) {
|
|
51
|
+
try {
|
|
52
|
+
if (!existsSync(filePath)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
let content = readFileSync(filePath, 'utf-8');
|
|
56
|
+
const original = content;
|
|
57
|
+
const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
|
|
58
|
+
// Patch version
|
|
59
|
+
if (VERSION_PATTERN.test(content)) {
|
|
60
|
+
content = content.replace(VERSION_PATTERN, `$1'${version}'`);
|
|
61
|
+
}
|
|
62
|
+
// Patch title
|
|
63
|
+
if (TITLE_PATTERN.test(content)) {
|
|
64
|
+
content = content.replace(TITLE_PATTERN, `$1'Development Orchestrator (${label})'`);
|
|
65
|
+
}
|
|
66
|
+
if (content === original) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// -- Public API ---------------------------------------------------------------
|
|
77
|
+
/**
|
|
78
|
+
* Update agent.yaml files across all known locations.
|
|
79
|
+
* Returns count of files updated.
|
|
80
|
+
*
|
|
81
|
+
* Never throws.
|
|
82
|
+
*/
|
|
83
|
+
export function updateAgentYaml(version, tier) {
|
|
84
|
+
const resolvedTier = tier ?? 'free';
|
|
85
|
+
let updated = 0;
|
|
86
|
+
// Home-level files
|
|
87
|
+
for (const filePath of HOME_YAML_FILES) {
|
|
88
|
+
if (patchYamlFile(filePath, version, resolvedTier)) {
|
|
89
|
+
updated++;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return updated;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Update agent.yaml at a specific file path (used for testing).
|
|
96
|
+
* Returns true if the file was modified.
|
|
97
|
+
*
|
|
98
|
+
* Never throws.
|
|
99
|
+
*/
|
|
100
|
+
export function updateAgentYamlAt(filePath, version, tier) {
|
|
101
|
+
return patchYamlFile(filePath, version, tier ?? 'free');
|
|
102
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Build the banner version line with correct padding.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildBannerVersionLine(version: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build the banner tier line with correct padding.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildBannerTierLine(tier: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Build the dynamic description string (without quotes/prefix).
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildDescription(version: string, tier: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Read the current tier from ~/.neocortex/config.json.
|
|
27
|
+
* Returns 'free' if config doesn't exist or tier is missing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function readTierFromConfig(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Update agent descriptions across ALL known platform files:
|
|
32
|
+
* 1. Home-level files (Claude Code, Gemini CLI)
|
|
33
|
+
* 2. Project-level files (Cursor, VSCode, Codex, Antigravity) -- discovered via git root
|
|
34
|
+
*
|
|
35
|
+
* Never throws -- description update is non-critical.
|
|
36
|
+
* Returns count of files updated.
|
|
37
|
+
*/
|
|
38
|
+
export declare function updateAgentDescription(version: string, tier?: string): number;
|
|
39
|
+
/**
|
|
40
|
+
* Update agent description for a specific file path (used by install scripts
|
|
41
|
+
* for project-level files where paths are dynamic).
|
|
42
|
+
*
|
|
43
|
+
* Never throws -- description update is non-critical.
|
|
44
|
+
*/
|
|
45
|
+
export declare function updateAgentDescriptionAt(filePath: string, type: 'yaml' | 'h1', version: string, tier?: string): boolean;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @neocortex/client - Agent Description Updater (Multi-Platform)
|
|
15
|
+
*
|
|
16
|
+
* Updates the installed agent description across ALL supported platforms
|
|
17
|
+
* with dynamic values: version, tier, and branding.
|
|
18
|
+
*
|
|
19
|
+
* Patches THREE surfaces per file (when present):
|
|
20
|
+
* 1. YAML frontmatter `description: "..."` or Markdown H1 `# ...`
|
|
21
|
+
* 2. ASCII banner version line: `│ ### ######## vX.X.X ...│`
|
|
22
|
+
* 3. ASCII banner tier line: `│ ## ### ###### ## OrNexus Team (Tier) ...│`
|
|
23
|
+
*
|
|
24
|
+
* Supported platforms (home-level):
|
|
25
|
+
* - Claude Code: ~/.claude/agents/neocortex/neocortex.md (YAML frontmatter)
|
|
26
|
+
* - Gemini CLI: ~/.gemini/agents/agent.md (YAML frontmatter)
|
|
27
|
+
*
|
|
28
|
+
* Supported platforms (project-level, discovered via git root):
|
|
29
|
+
* - Cursor: <root>/.cursor/agents/neocortex.md (YAML frontmatter)
|
|
30
|
+
* - VSCode: <root>/.github/agents/neocortex.md (YAML frontmatter)
|
|
31
|
+
* - Codex: <root>/AGENTS.md (Markdown H1)
|
|
32
|
+
* - Antigravity: <root>/.agent/skills/neocortex/SKILL.md (YAML frontmatter)
|
|
33
|
+
*
|
|
34
|
+
* Called after:
|
|
35
|
+
* - License activation (activate.ts)
|
|
36
|
+
* - Install (install.sh via sed fallback for all platforms)
|
|
37
|
+
*
|
|
38
|
+
* Format: 🧠 Neocortex vX.X.X (Tier) | OrNexus Team
|
|
39
|
+
*/
|
|
40
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
41
|
+
import { execSync } from 'node:child_process';
|
|
42
|
+
import { join } from 'node:path';
|
|
43
|
+
import { homedir } from 'node:os';
|
|
44
|
+
// ── Constants ─────────────────────────────────────────────────────────────
|
|
45
|
+
const CONFIG_FILE = join(homedir(), '.neocortex', 'config.json');
|
|
46
|
+
const TIER_LABELS = {
|
|
47
|
+
free: 'Free',
|
|
48
|
+
pro: 'Pro',
|
|
49
|
+
enterprise: 'Enterprise',
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Banner frame geometry.
|
|
53
|
+
* Frame is 62 chars wide: │ + 60 inner chars + │
|
|
54
|
+
* Both dynamic lines have a 25-char inner prefix (after the leading │).
|
|
55
|
+
*/
|
|
56
|
+
const BANNER_INNER_WIDTH = 60;
|
|
57
|
+
const BANNER_PREFIX_INNER = 25; // chars after leading │, before dynamic content
|
|
58
|
+
// YAML frontmatter: description: "..."
|
|
59
|
+
const YAML_DESCRIPTION_PATTERN = /^description:\s*".*"$/m;
|
|
60
|
+
// Markdown H1: # 🧠 Neocortex vX.X.X (Tier) | OrNexus Team
|
|
61
|
+
// Also matches legacy format: # 🧠 Neocortex vX.X.X - Development Orchestrator | OrNexus Team (Tier)
|
|
62
|
+
const H1_DESCRIPTION_PATTERN = /^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m;
|
|
63
|
+
// Banner version line: │ ### ######## vX.X.X<spaces>│
|
|
64
|
+
const BANNER_VERSION_PATTERN = /^│ ### ######## v[\d.]+\s*│$/m;
|
|
65
|
+
// Banner tier line: │ ## ### ###### ## OrNexus Team (<Tier>)<spaces>│
|
|
66
|
+
const BANNER_TIER_PATTERN = /^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m;
|
|
67
|
+
/**
|
|
68
|
+
* All known home-directory agent files, grouped by description format.
|
|
69
|
+
*/
|
|
70
|
+
const HOME_AGENT_FILES = [
|
|
71
|
+
// Claude Code (home-level)
|
|
72
|
+
{ path: join(homedir(), '.claude', 'agents', 'neocortex', 'neocortex.md'), type: 'yaml' },
|
|
73
|
+
// Gemini CLI (home-level)
|
|
74
|
+
{ path: join(homedir(), '.gemini', 'agents', 'agent.md'), type: 'yaml' },
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* Known project-level agent file paths (relative to project root).
|
|
78
|
+
* These are patched after license activation so the tier reflects reality.
|
|
79
|
+
*/
|
|
80
|
+
const PROJECT_AGENT_FILES = [
|
|
81
|
+
// Cursor
|
|
82
|
+
{ relativePath: join('.cursor', 'agents', 'neocortex.md'), type: 'yaml' },
|
|
83
|
+
// VSCode / GitHub Copilot
|
|
84
|
+
{ relativePath: join('.github', 'agents', 'neocortex.md'), type: 'yaml' },
|
|
85
|
+
// Codex
|
|
86
|
+
{ relativePath: 'AGENTS.md', type: 'h1' },
|
|
87
|
+
// Antigravity
|
|
88
|
+
{ relativePath: join('.agent', 'skills', 'neocortex', 'SKILL.md'), type: 'yaml' },
|
|
89
|
+
];
|
|
90
|
+
// ── Project Root Discovery ────────────────────────────────────────────────
|
|
91
|
+
/**
|
|
92
|
+
* Discover the git project root, or null if not in a git repo.
|
|
93
|
+
* Never throws -- returns null on any failure.
|
|
94
|
+
*/
|
|
95
|
+
function discoverProjectRoot() {
|
|
96
|
+
try {
|
|
97
|
+
const root = execSync('git rev-parse --show-toplevel', {
|
|
98
|
+
encoding: 'utf-8',
|
|
99
|
+
timeout: 5000,
|
|
100
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
101
|
+
}).trim();
|
|
102
|
+
return root || null;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// ── Banner Helpers ────────────────────────────────────────────────────────
|
|
109
|
+
/**
|
|
110
|
+
* Build a right-padded banner line.
|
|
111
|
+
* Prefix is the fixed art portion INCLUDING the leading │ (26 chars).
|
|
112
|
+
* Content is the dynamic text. Padding fills to inner width, then closing │.
|
|
113
|
+
*
|
|
114
|
+
* Total: │(1) + prefixInner(25) + content + pad + │(1) = 62 chars.
|
|
115
|
+
*/
|
|
116
|
+
function buildBannerLine(prefix, content) {
|
|
117
|
+
const padLen = BANNER_INNER_WIDTH - BANNER_PREFIX_INNER - content.length;
|
|
118
|
+
const padding = padLen > 0 ? ' '.repeat(padLen) : '';
|
|
119
|
+
return `${prefix}${content}${padding}\u2502`; // \u2502 = │
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Build the banner version line with correct padding.
|
|
123
|
+
*/
|
|
124
|
+
export function buildBannerVersionLine(version) {
|
|
125
|
+
return buildBannerLine('\u2502 ### ######## ', `v${version}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Build the banner tier line with correct padding.
|
|
129
|
+
*/
|
|
130
|
+
export function buildBannerTierLine(tier) {
|
|
131
|
+
const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
|
|
132
|
+
return buildBannerLine('\u2502 ## ### ###### ## ', `OrNexus Team (${label})`);
|
|
133
|
+
}
|
|
134
|
+
// ── Public API ────────────────────────────────────────────────────────────
|
|
135
|
+
/**
|
|
136
|
+
* Build the dynamic description string (without quotes/prefix).
|
|
137
|
+
*/
|
|
138
|
+
export function buildDescription(version, tier) {
|
|
139
|
+
const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
|
|
140
|
+
return `\u{1F9E0} Neocortex v${version} (${label}) | OrNexus Team`;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Read the current tier from ~/.neocortex/config.json.
|
|
144
|
+
* Returns 'free' if config doesn't exist or tier is missing.
|
|
145
|
+
*/
|
|
146
|
+
export function readTierFromConfig() {
|
|
147
|
+
try {
|
|
148
|
+
if (existsSync(CONFIG_FILE)) {
|
|
149
|
+
const raw = readFileSync(CONFIG_FILE, 'utf-8');
|
|
150
|
+
const config = JSON.parse(raw);
|
|
151
|
+
return config.tier ?? 'free';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// Config missing or corrupted
|
|
156
|
+
}
|
|
157
|
+
return 'free';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Patch ASCII banner lines (version + tier) in file content.
|
|
161
|
+
* Returns the patched content, or the original if no banner found.
|
|
162
|
+
*/
|
|
163
|
+
function patchBannerLines(content, version, tier) {
|
|
164
|
+
let patched = content;
|
|
165
|
+
// Patch version line
|
|
166
|
+
if (BANNER_VERSION_PATTERN.test(patched)) {
|
|
167
|
+
patched = patched.replace(BANNER_VERSION_PATTERN, buildBannerVersionLine(version));
|
|
168
|
+
}
|
|
169
|
+
// Patch tier line
|
|
170
|
+
if (BANNER_TIER_PATTERN.test(patched)) {
|
|
171
|
+
patched = patched.replace(BANNER_TIER_PATTERN, buildBannerTierLine(tier));
|
|
172
|
+
}
|
|
173
|
+
return patched;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Update a single file's description and banner.
|
|
177
|
+
* Supports YAML frontmatter, H1 header, and ASCII banner lines.
|
|
178
|
+
*
|
|
179
|
+
* Never throws -- description update is non-critical.
|
|
180
|
+
*/
|
|
181
|
+
function updateFile(filePath, type, description, version, tier) {
|
|
182
|
+
try {
|
|
183
|
+
if (!existsSync(filePath)) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
let content = readFileSync(filePath, 'utf-8');
|
|
187
|
+
const original = content;
|
|
188
|
+
// 1. Patch description (YAML frontmatter or H1 header)
|
|
189
|
+
if (type === 'yaml') {
|
|
190
|
+
if (YAML_DESCRIPTION_PATTERN.test(content)) {
|
|
191
|
+
content = content.replace(YAML_DESCRIPTION_PATTERN, `description: "${description}"`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (H1_DESCRIPTION_PATTERN.test(content)) {
|
|
196
|
+
content = content.replace(H1_DESCRIPTION_PATTERN, `# ${description}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// 2. Patch ASCII banner lines (version + tier) if present
|
|
200
|
+
content = patchBannerLines(content, version, tier);
|
|
201
|
+
if (content === original) {
|
|
202
|
+
return false; // Already up to date
|
|
203
|
+
}
|
|
204
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Update agent descriptions across ALL known platform files:
|
|
213
|
+
* 1. Home-level files (Claude Code, Gemini CLI)
|
|
214
|
+
* 2. Project-level files (Cursor, VSCode, Codex, Antigravity) -- discovered via git root
|
|
215
|
+
*
|
|
216
|
+
* Never throws -- description update is non-critical.
|
|
217
|
+
* Returns count of files updated.
|
|
218
|
+
*/
|
|
219
|
+
export function updateAgentDescription(version, tier) {
|
|
220
|
+
const resolvedTier = tier ?? readTierFromConfig();
|
|
221
|
+
const description = buildDescription(version, resolvedTier);
|
|
222
|
+
let updated = 0;
|
|
223
|
+
// 1. Home-level files (existing behavior)
|
|
224
|
+
for (const { path, type } of HOME_AGENT_FILES) {
|
|
225
|
+
if (updateFile(path, type, description, version, resolvedTier)) {
|
|
226
|
+
updated++;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// 2. Project-level files (discover git root, then check known paths)
|
|
230
|
+
const projectRoot = discoverProjectRoot();
|
|
231
|
+
if (projectRoot) {
|
|
232
|
+
for (const { relativePath, type } of PROJECT_AGENT_FILES) {
|
|
233
|
+
const fullPath = join(projectRoot, relativePath);
|
|
234
|
+
if (updateFile(fullPath, type, description, version, resolvedTier)) {
|
|
235
|
+
updated++;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return updated;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Update agent description for a specific file path (used by install scripts
|
|
243
|
+
* for project-level files where paths are dynamic).
|
|
244
|
+
*
|
|
245
|
+
* Never throws -- description update is non-critical.
|
|
246
|
+
*/
|
|
247
|
+
export function updateAgentDescriptionAt(filePath, type, version, tier) {
|
|
248
|
+
const resolvedTier = tier ?? readTierFromConfig();
|
|
249
|
+
const description = buildDescription(version, resolvedTier);
|
|
250
|
+
return updateFile(filePath, type, description, version, resolvedTier);
|
|
251
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
/** On-disk envelope format. expiresAt is inside the encrypted data payload. */
|
|
14
|
+
export interface EncryptedEnvelope {
|
|
15
|
+
/** Base64-encoded initialization vector (12 bytes) */
|
|
16
|
+
iv: string;
|
|
17
|
+
/** Base64-encoded PBKDF2 salt */
|
|
18
|
+
salt: string;
|
|
19
|
+
/** Base64-encoded GCM auth tag */
|
|
20
|
+
tag: string;
|
|
21
|
+
/** Base64-encoded encrypted data (contains plaintext + expiresAt) */
|
|
22
|
+
data: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function deriveKey(passphrase: string, salt: Buffer): Buffer;
|
|
25
|
+
export declare function encrypt(plaintext: string, passphrase: string, ttlMs?: number): string;
|
|
26
|
+
export interface DecryptResult {
|
|
27
|
+
plaintext: string;
|
|
28
|
+
expired: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function decrypt(envelopeJson: string, passphrase: string): DecryptResult;
|