@ornexus/neocortex 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.ps1 +92 -33
- package/install.sh +15 -1
- package/package.json +3 -3
- package/packages/client/dist/adapters/adapter-registry.js +1 -106
- package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
- package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
- package/packages/client/dist/adapters/codex-adapter.js +2 -80
- package/packages/client/dist/adapters/cursor-adapter.js +4 -115
- package/packages/client/dist/adapters/gemini-adapter.js +2 -71
- package/packages/client/dist/adapters/index.js +1 -21
- package/packages/client/dist/adapters/platform-detector.js +1 -106
- package/packages/client/dist/adapters/target-adapter.js +0 -12
- package/packages/client/dist/adapters/vscode-adapter.js +2 -72
- package/packages/client/dist/agent/refresh-stubs.js +2 -234
- package/packages/client/dist/agent/update-agent-yaml.js +1 -102
- package/packages/client/dist/agent/update-description.js +1 -251
- package/packages/client/dist/cache/crypto-utils.js +1 -76
- package/packages/client/dist/cache/encrypted-cache.js +1 -94
- package/packages/client/dist/cache/in-memory-asset-cache.js +1 -70
- package/packages/client/dist/cache/index.js +1 -13
- package/packages/client/dist/cli.js +2 -163
- package/packages/client/dist/commands/activate.js +8 -390
- package/packages/client/dist/commands/cache-status.js +2 -112
- package/packages/client/dist/commands/invoke.js +28 -490
- package/packages/client/dist/config/resolver-selection.js +1 -278
- package/packages/client/dist/config/secure-config.js +12 -269
- package/packages/client/dist/constants.js +1 -25
- package/packages/client/dist/context/context-collector.js +2 -222
- package/packages/client/dist/context/context-sanitizer.js +1 -145
- package/packages/client/dist/index.js +1 -38
- package/packages/client/dist/license/index.js +1 -5
- package/packages/client/dist/license/license-client.js +1 -257
- package/packages/client/dist/machine/fingerprint.js +2 -160
- package/packages/client/dist/machine/index.js +1 -5
- package/packages/client/dist/resilience/circuit-breaker.js +1 -170
- package/packages/client/dist/resilience/degradation-manager.js +1 -164
- package/packages/client/dist/resilience/freshness-indicator.js +1 -100
- package/packages/client/dist/resilience/index.js +1 -8
- package/packages/client/dist/resilience/recovery-detector.js +1 -74
- package/packages/client/dist/resolvers/asset-resolver.js +0 -13
- package/packages/client/dist/resolvers/local-resolver.js +8 -218
- package/packages/client/dist/resolvers/remote-resolver.js +1 -282
- package/packages/client/dist/telemetry/index.js +1 -5
- package/packages/client/dist/telemetry/offline-queue.js +1 -131
- package/packages/client/dist/tier/index.js +1 -5
- package/packages/client/dist/tier/tier-aware-client.js +1 -260
- package/packages/client/dist/types/index.js +1 -38
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/install-antigravity.sh +49 -3
- package/targets-stubs/antigravity/skill/SKILL.md +23 -4
- package/targets-stubs/claude-code/neocortex.agent.yaml +19 -1
- package/targets-stubs/claude-code/neocortex.md +64 -29
- package/targets-stubs/codex/agents.md +20 -3
- package/targets-stubs/codex/config-mcp.toml +5 -0
- package/targets-stubs/cursor/agent.md +23 -5
- package/targets-stubs/cursor/install-cursor.sh +51 -3
- package/targets-stubs/cursor/mcp.json +7 -0
- package/targets-stubs/gemini-cli/agent.md +37 -6
- package/targets-stubs/gemini-cli/install-gemini.sh +50 -17
- package/targets-stubs/vscode/agent.md +47 -10
- package/targets-stubs/vscode/install-vscode.sh +50 -3
- package/targets-stubs/vscode/mcp.json +8 -0
|
@@ -1,102 +1 @@
|
|
|
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
|
-
}
|
|
1
|
+
import{readFileSync as f,writeFileSync as l,existsSync as u}from"node:fs";import{join as p}from"node:path";import{homedir as m}from"node:os";const E={free:"Free",pro:"Pro",enterprise:"Enterprise"},s=/^(\s*version:\s*)'[^']*'/m,c=/^(\s*title:\s*)'[^']*'/m,d=[p(m(),".claude","agents","neocortex","neocortex.agent.yaml")];function i(t,r,n){try{if(!u(t))return!1;let e=f(t,"utf-8");const o=e,a=E[n.toLowerCase()]??"Free";return s.test(e)&&(e=e.replace(s,`$1'${r}'`)),c.test(e)&&(e=e.replace(c,`$1'Development Orchestrator (${a})'`)),e===o?!1:(l(t,e,"utf-8"),!0)}catch{return!1}}function L(t,r){const n=r??"free";let e=0;for(const o of d)i(o,t,n)&&e++;return e}function S(t,r,n){return i(t,r,n??"free")}export{L as updateAgentYaml,S as updateAgentYamlAt};
|
|
@@ -1,251 +1 @@
|
|
|
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
|
-
}
|
|
1
|
+
import{readFileSync as l,writeFileSync as _,existsSync as f}from"node:fs";import{execSync as A}from"node:child_process";import{join as c}from"node:path";import{homedir as p}from"node:os";const m=c(p(),".neocortex","config.json"),d={free:"Free",pro:"Pro",enterprise:"Enterprise"},I=60,L=25,N=/^description:\s*".*"$/m,E=/^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m,T=/^│ ### ######## v[\d.]+\s*│$/m,x=/^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m,P=[{path:c(p(),".claude","agents","neocortex","neocortex.md"),type:"yaml"},{path:c(p(),".gemini","agents","agent.md"),type:"yaml"}],F=[{relativePath:c(".cursor","agents","neocortex.md"),type:"yaml"},{relativePath:c(".github","agents","neocortex.md"),type:"yaml"},{relativePath:"AGENTS.md",type:"h1"},{relativePath:c(".agent","skills","neocortex","SKILL.md"),type:"yaml"}];function O(){try{return A("git rev-parse --show-toplevel",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function y(e,o){const t=I-L-o.length,r=t>0?" ".repeat(t):"";return`${e}${o}${r}\u2502`}function S(e){return y("\u2502 ### ######## ",`v${e}`)}function $(e){const o=d[e.toLowerCase()]??"Free";return y("\u2502 ## ### ###### ## ",`OrNexus Team (${o})`)}function g(e,o){const t=d[o.toLowerCase()]??"Free";return`\u{1F9E0} Neocortex v${e} (${t}) | OrNexus Team`}function R(){try{if(f(m)){const e=l(m,"utf-8");return JSON.parse(e).tier??"free"}}catch{}return"free"}function v(e,o,t){let r=e;return T.test(r)&&(r=r.replace(T,S(o))),x.test(r)&&(r=r.replace(x,$(t))),r}function u(e,o,t,r,i){try{if(!f(e))return!1;let n=l(e,"utf-8");const s=n;return o==="yaml"?N.test(n)&&(n=n.replace(N,`description: "${t}"`)):E.test(n)&&(n=n.replace(E,`# ${t}`)),n=v(n,r,i),n===s?!1:(_(e,n,"utf-8"),!0)}catch{return!1}}function w(e,o){const t=o??R(),r=g(e,t);let i=0;for(const{path:s,type:a}of P)u(s,a,r,e,t)&&i++;const n=O();if(n)for(const{relativePath:s,type:a}of F){const h=c(n,s);u(h,a,r,e,t)&&i++}return i}function j(e,o,t,r){const i=r??R(),n=g(t,i);return u(e,o,n,t,i)}export{$ as buildBannerTierLine,S as buildBannerVersionLine,g as buildDescription,R as readTierFromConfig,w as updateAgentDescription,j as updateAgentDescriptionAt};
|
|
@@ -1,76 +1 @@
|
|
|
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 - Crypto Utilities
|
|
15
|
-
*
|
|
16
|
-
* AES-256-GCM encryption/decryption with PBKDF2 key derivation.
|
|
17
|
-
* Used by EncryptedCache to protect cached assets at rest.
|
|
18
|
-
*
|
|
19
|
-
* Security design:
|
|
20
|
-
* - IV: 12 bytes (NIST SP 800-38D recommended for GCM)
|
|
21
|
-
* - Salt: 32 bytes random per entry
|
|
22
|
-
* - Key: PBKDF2 with 100k iterations, SHA-512
|
|
23
|
-
* - expiresAt is inside the encrypted payload (authenticated by GCM tag)
|
|
24
|
-
*/
|
|
25
|
-
import { randomBytes, pbkdf2Sync, createCipheriv, createDecipheriv } from 'node:crypto';
|
|
26
|
-
// ── Constants ────────────────────────────────────────────────────────────
|
|
27
|
-
const ALGORITHM = 'aes-256-gcm';
|
|
28
|
-
const IV_LENGTH = 12; // NIST SP 800-38D recommended for AES-GCM
|
|
29
|
-
const SALT_LENGTH = 32;
|
|
30
|
-
const KEY_LENGTH = 32;
|
|
31
|
-
const AUTH_TAG_LENGTH = 16;
|
|
32
|
-
const PBKDF2_ITERATIONS = 100_000;
|
|
33
|
-
const PBKDF2_DIGEST = 'sha512';
|
|
34
|
-
// ── Key Derivation ───────────────────────────────────────────────────────
|
|
35
|
-
export function deriveKey(passphrase, salt) {
|
|
36
|
-
return pbkdf2Sync(passphrase, salt, PBKDF2_ITERATIONS, KEY_LENGTH, PBKDF2_DIGEST);
|
|
37
|
-
}
|
|
38
|
-
// ── Encrypt ──────────────────────────────────────────────────────────────
|
|
39
|
-
export function encrypt(plaintext, passphrase, ttlMs) {
|
|
40
|
-
const iv = randomBytes(IV_LENGTH);
|
|
41
|
-
const salt = randomBytes(SALT_LENGTH);
|
|
42
|
-
const key = deriveKey(passphrase, salt);
|
|
43
|
-
const expiresAt = ttlMs != null ? Date.now() + ttlMs : null;
|
|
44
|
-
const payload = { plaintext, expiresAt };
|
|
45
|
-
const payloadJson = JSON.stringify(payload);
|
|
46
|
-
const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
47
|
-
const encrypted = Buffer.concat([cipher.update(payloadJson, 'utf8'), cipher.final()]);
|
|
48
|
-
const tag = cipher.getAuthTag();
|
|
49
|
-
const envelope = {
|
|
50
|
-
iv: iv.toString('base64'),
|
|
51
|
-
salt: salt.toString('base64'),
|
|
52
|
-
tag: tag.toString('base64'),
|
|
53
|
-
data: encrypted.toString('base64'),
|
|
54
|
-
};
|
|
55
|
-
return JSON.stringify(envelope);
|
|
56
|
-
}
|
|
57
|
-
export function decrypt(envelopeJson, passphrase) {
|
|
58
|
-
const raw = JSON.parse(envelopeJson);
|
|
59
|
-
if (!raw.iv || !raw.salt || !raw.tag || !raw.data) {
|
|
60
|
-
throw new Error('Invalid cache envelope: missing required fields');
|
|
61
|
-
}
|
|
62
|
-
const iv = Buffer.from(raw.iv, 'base64');
|
|
63
|
-
const salt = Buffer.from(raw.salt, 'base64');
|
|
64
|
-
const tag = Buffer.from(raw.tag, 'base64');
|
|
65
|
-
const data = Buffer.from(raw.data, 'base64');
|
|
66
|
-
const key = deriveKey(passphrase, salt);
|
|
67
|
-
const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
68
|
-
decipher.setAuthTag(tag);
|
|
69
|
-
const decrypted = Buffer.concat([decipher.update(data), decipher.final()]);
|
|
70
|
-
const payload = JSON.parse(decrypted.toString('utf8'));
|
|
71
|
-
const expired = payload.expiresAt != null && Date.now() > payload.expiresAt;
|
|
72
|
-
return {
|
|
73
|
-
plaintext: payload.plaintext,
|
|
74
|
-
expired,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
1
|
+
import{randomBytes as d,pbkdf2Sync as h,createCipheriv as S,createDecipheriv as v}from"node:crypto";const l="aes-256-gcm",A=12,b=32,m=32,g=16,x=1e5,B="sha512";function y(e,n){return h(e,n,x,m,B)}function E(e,n,t){const r=d(A),c=d(b),i=y(n,c),f=t!=null?Date.now()+t:null,a=JSON.stringify({plaintext:e,expiresAt:f}),o=S(l,i,r,{authTagLength:g}),s=Buffer.concat([o.update(a,"utf8"),o.final()]),p=o.getAuthTag(),T={iv:r.toString("base64"),salt:c.toString("base64"),tag:p.toString("base64"),data:s.toString("base64")};return JSON.stringify(T)}function L(e,n){const t=JSON.parse(e);if(!t.iv||!t.salt||!t.tag||!t.data)throw new Error("Invalid cache envelope: missing required fields");const r=Buffer.from(t.iv,"base64"),c=Buffer.from(t.salt,"base64"),i=Buffer.from(t.tag,"base64"),f=Buffer.from(t.data,"base64"),u=y(n,c),a=v(l,u,r,{authTagLength:g});a.setAuthTag(i);const o=Buffer.concat([a.update(f),a.final()]),s=JSON.parse(o.toString("utf8")),p=s.expiresAt!=null&&Date.now()>s.expiresAt;return{plaintext:s.plaintext,expired:p}}export{L as decrypt,y as deriveKey,E as encrypt};
|
|
@@ -1,94 +1 @@
|
|
|
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 - EncryptedCache
|
|
15
|
-
*
|
|
16
|
-
* Filesystem-backed encrypted cache implementing the CacheProvider interface.
|
|
17
|
-
* Stores assets as AES-256-GCM encrypted files with PBKDF2 key derivation.
|
|
18
|
-
* Cache keys are hashed with SHA-256 to produce safe filenames.
|
|
19
|
-
*
|
|
20
|
-
* All public methods are designed to never throw - cache failures are
|
|
21
|
-
* silently handled since caching is a non-critical optimization.
|
|
22
|
-
*/
|
|
23
|
-
import { mkdir, writeFile, readFile, rm, readdir } from 'node:fs/promises';
|
|
24
|
-
import { join } from 'node:path';
|
|
25
|
-
import { createHash } from 'node:crypto';
|
|
26
|
-
import { encrypt, decrypt } from './crypto-utils.js';
|
|
27
|
-
import { setSecureFilePermissions } from '../config/secure-config.js';
|
|
28
|
-
// ── Constants ────────────────────────────────────────────────────────────
|
|
29
|
-
const CACHE_FILE_EXTENSION = '.enc';
|
|
30
|
-
// ── EncryptedCache Implementation ────────────────────────────────────────
|
|
31
|
-
export class EncryptedCache {
|
|
32
|
-
cacheDir;
|
|
33
|
-
passphrase;
|
|
34
|
-
initPromise = null;
|
|
35
|
-
constructor(options) {
|
|
36
|
-
this.cacheDir = options.cacheDir;
|
|
37
|
-
this.passphrase = options.passphrase;
|
|
38
|
-
}
|
|
39
|
-
async get(key) {
|
|
40
|
-
try {
|
|
41
|
-
const filePath = this.keyToPath(key);
|
|
42
|
-
const raw = await readFile(filePath, 'utf8');
|
|
43
|
-
const result = decrypt(raw, this.passphrase);
|
|
44
|
-
if (result.expired) {
|
|
45
|
-
// Clean up expired entry (fire-and-forget)
|
|
46
|
-
rm(filePath, { force: true }).catch(() => { });
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return result.plaintext;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async set(key, value, ttlMs) {
|
|
56
|
-
try {
|
|
57
|
-
await this.ensureDir();
|
|
58
|
-
const filePath = this.keyToPath(key);
|
|
59
|
-
const encrypted = encrypt(value, this.passphrase, ttlMs);
|
|
60
|
-
await writeFile(filePath, encrypted, 'utf8');
|
|
61
|
-
// Story 66.1 AC6: Apply restrictive permissions on .enc files
|
|
62
|
-
setSecureFilePermissions(filePath);
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
// Cache write failures are non-critical
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async clear() {
|
|
69
|
-
try {
|
|
70
|
-
const entries = await readdir(this.cacheDir).catch(() => []);
|
|
71
|
-
const removals = entries
|
|
72
|
-
.filter((entry) => entry.endsWith(CACHE_FILE_EXTENSION))
|
|
73
|
-
.map((entry) => rm(join(this.cacheDir, entry), { force: true }).catch(() => { }));
|
|
74
|
-
await Promise.all(removals);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// Clear failures are non-critical
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// ── Private Methods ─────────────────────────────────────────────────
|
|
81
|
-
keyToPath(key) {
|
|
82
|
-
const hash = createHash('sha256').update(key).digest('hex');
|
|
83
|
-
return join(this.cacheDir, `${hash}${CACHE_FILE_EXTENSION}`);
|
|
84
|
-
}
|
|
85
|
-
ensureDir() {
|
|
86
|
-
if (!this.initPromise) {
|
|
87
|
-
this.initPromise = mkdir(this.cacheDir, { recursive: true }).then(() => undefined).catch((err) => {
|
|
88
|
-
this.initPromise = null; // allow retry on next call
|
|
89
|
-
throw err;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return this.initPromise;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
1
|
+
import{mkdir as n,writeFile as o,readFile as p,rm as s,readdir as u}from"node:fs/promises";import{join as a}from"node:path";import{createHash as l}from"node:crypto";import{encrypt as m,decrypt as f}from"./crypto-utils.js";import{setSecureFilePermissions as d}from"../config/secure-config.js";const c=".enc";class x{cacheDir;passphrase;initPromise=null;constructor(t){this.cacheDir=t.cacheDir,this.passphrase=t.passphrase}async get(t){try{const e=this.keyToPath(t),r=await p(e,"utf8"),i=f(r,this.passphrase);return i.expired?(s(e,{force:!0}).catch(()=>{}),null):i.plaintext}catch{return null}}async set(t,e,r){try{await this.ensureDir();const i=this.keyToPath(t),h=m(e,this.passphrase,r);await o(i,h,"utf8"),d(i)}catch{}}async clear(){try{const e=(await u(this.cacheDir).catch(()=>[])).filter(r=>r.endsWith(c)).map(r=>s(a(this.cacheDir,r),{force:!0}).catch(()=>{}));await Promise.all(e)}catch{}}keyToPath(t){const e=l("sha256").update(t).digest("hex");return a(this.cacheDir,`${e}${c}`)}ensureDir(){return this.initPromise||(this.initPromise=n(this.cacheDir,{recursive:!0}).then(()=>{}).catch(t=>{throw this.initPromise=null,t})),this.initPromise}}export{x as EncryptedCache};
|
|
@@ -1,70 +1 @@
|
|
|
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
|
-
const DEFAULT_MAX_SIZE = 50;
|
|
14
|
-
const DEFAULT_TTL_MS = 5 * 60 * 1000;
|
|
15
|
-
export class InMemoryAssetCache {
|
|
16
|
-
store = new Map();
|
|
17
|
-
maxSize;
|
|
18
|
-
ttlMs;
|
|
19
|
-
constructor(options = {}) {
|
|
20
|
-
this.maxSize = options.maxSize ?? DEFAULT_MAX_SIZE;
|
|
21
|
-
this.ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Retrieve a value by key. Returns null if missing or expired.
|
|
25
|
-
* Accessing a key moves it to the end of the LRU ordering.
|
|
26
|
-
*/
|
|
27
|
-
async get(key) {
|
|
28
|
-
const entry = this.store.get(key);
|
|
29
|
-
if (!entry)
|
|
30
|
-
return null;
|
|
31
|
-
if (Date.now() >= entry.expiresAt) {
|
|
32
|
-
this.store.delete(key);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
// LRU: move to end (most recently used)
|
|
36
|
-
this.store.delete(key);
|
|
37
|
-
this.store.set(key, entry);
|
|
38
|
-
return entry.value;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Store a value by key. Evicts the least-recently-used entry if the
|
|
42
|
-
* cache is at capacity.
|
|
43
|
-
*
|
|
44
|
-
* @param ttlMs - optional override of the default TTL
|
|
45
|
-
*/
|
|
46
|
-
async set(key, value, ttlMs) {
|
|
47
|
-
const ttl = ttlMs ?? this.ttlMs;
|
|
48
|
-
const expiresAt = Date.now() + ttl;
|
|
49
|
-
if (this.store.has(key)) {
|
|
50
|
-
// Overwrite keeps insertion order fresh -- delete then set.
|
|
51
|
-
this.store.delete(key);
|
|
52
|
-
}
|
|
53
|
-
else if (this.store.size >= this.maxSize) {
|
|
54
|
-
// LRU eviction: delete oldest entry (first in insertion order).
|
|
55
|
-
const oldestKey = this.store.keys().next().value;
|
|
56
|
-
if (oldestKey !== undefined) {
|
|
57
|
-
this.store.delete(oldestKey);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
this.store.set(key, { value, expiresAt });
|
|
61
|
-
}
|
|
62
|
-
/** Drop all entries. Safe to call at any time. */
|
|
63
|
-
async clear() {
|
|
64
|
-
this.store.clear();
|
|
65
|
-
}
|
|
66
|
-
/** Internal: number of live entries (for diagnostics / tests). */
|
|
67
|
-
size() {
|
|
68
|
-
return this.store.size;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
const l=50,h=3e5;class a{store=new Map;maxSize;ttlMs;constructor(t={}){this.maxSize=t.maxSize??50,this.ttlMs=t.ttlMs??3e5}async get(t){const e=this.store.get(t);return e?Date.now()>=e.expiresAt?(this.store.delete(t),null):(this.store.delete(t),this.store.set(t,e),e.value):null}async set(t,e,i){const r=i??this.ttlMs,o=Date.now()+r;if(this.store.has(t))this.store.delete(t);else if(this.store.size>=this.maxSize){const s=this.store.keys().next().value;s!==void 0&&this.store.delete(s)}this.store.set(t,{value:e,expiresAt:o})}async clear(){this.store.clear()}size(){return this.store.size}}export{a as InMemoryAssetCache};
|
|
@@ -1,13 +1 @@
|
|
|
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
|
-
export { EncryptedCache } from './encrypted-cache.js';
|
|
1
|
+
import{EncryptedCache as c}from"./encrypted-cache.js";export{c as EncryptedCache};
|