neuroplex 0.0.1 → 0.2.0
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/LICENSE +21 -21
- package/README.md +11 -11
- package/dist/brain/build.d.ts +21 -0
- package/dist/brain/build.js +172 -0
- package/dist/brain/build.js.map +1 -0
- package/dist/brain/local.d.ts +12 -0
- package/dist/brain/local.js +23 -0
- package/dist/brain/local.js.map +1 -0
- package/dist/brain/stats.d.ts +23 -0
- package/dist/brain/stats.js +37 -0
- package/dist/brain/stats.js.map +1 -0
- package/dist/brain/status.d.ts +24 -0
- package/dist/brain/status.js +30 -0
- package/dist/brain/status.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +269 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/config.d.ts +64 -0
- package/dist/config/config.js +147 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/edit.d.ts +9 -0
- package/dist/config/edit.js +45 -0
- package/dist/config/edit.js.map +1 -0
- package/dist/enrich/index.d.ts +8 -0
- package/dist/enrich/index.js +13 -0
- package/dist/enrich/index.js.map +1 -0
- package/dist/enrich/tasks.d.ts +52 -0
- package/dist/enrich/tasks.js +339 -0
- package/dist/enrich/tasks.js.map +1 -0
- package/dist/enrich/write.d.ts +45 -0
- package/dist/enrich/write.js +228 -0
- package/dist/enrich/write.js.map +1 -0
- package/dist/graph/graph.d.ts +42 -0
- package/dist/graph/graph.js +174 -0
- package/dist/graph/graph.js.map +1 -0
- package/dist/graph/ids.d.ts +42 -0
- package/dist/graph/ids.js +104 -0
- package/dist/graph/ids.js.map +1 -0
- package/dist/graph/jsonl.d.ts +31 -0
- package/dist/graph/jsonl.js +121 -0
- package/dist/graph/jsonl.js.map +1 -0
- package/dist/graph/schema.d.ts +89 -0
- package/dist/graph/schema.js +73 -0
- package/dist/graph/schema.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/install/claude.d.ts +37 -0
- package/dist/install/claude.js +104 -0
- package/dist/install/claude.js.map +1 -0
- package/dist/mcp/config.d.ts +20 -0
- package/dist/mcp/config.js +51 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/serve.d.ts +6 -0
- package/dist/mcp/serve.js +29 -0
- package/dist/mcp/serve.js.map +1 -0
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.js +248 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/query/brain.d.ts +21 -0
- package/dist/query/brain.js +51 -0
- package/dist/query/brain.js.map +1 -0
- package/dist/query/queries.d.ts +116 -0
- package/dist/query/queries.js +224 -0
- package/dist/query/queries.js.map +1 -0
- package/dist/query/search.d.ts +43 -0
- package/dist/query/search.js +329 -0
- package/dist/query/search.js.map +1 -0
- package/dist/scan/assemble.d.ts +20 -0
- package/dist/scan/assemble.js +255 -0
- package/dist/scan/assemble.js.map +1 -0
- package/dist/scan/discover.d.ts +21 -0
- package/dist/scan/discover.js +119 -0
- package/dist/scan/discover.js.map +1 -0
- package/dist/scan/extract.d.ts +3 -0
- package/dist/scan/extract.js +11 -0
- package/dist/scan/extract.js.map +1 -0
- package/dist/scan/extractors/python.d.ts +4 -0
- package/dist/scan/extractors/python.js +303 -0
- package/dist/scan/extractors/python.js.map +1 -0
- package/dist/scan/extractors/typescript.d.ts +6 -0
- package/dist/scan/extractors/typescript.js +509 -0
- package/dist/scan/extractors/typescript.js.map +1 -0
- package/dist/scan/git.d.ts +17 -0
- package/dist/scan/git.js +45 -0
- package/dist/scan/git.js.map +1 -0
- package/dist/scan/merge.d.ts +14 -0
- package/dist/scan/merge.js +57 -0
- package/dist/scan/merge.js.map +1 -0
- package/dist/scan/parser.d.ts +23 -0
- package/dist/scan/parser.js +57 -0
- package/dist/scan/parser.js.map +1 -0
- package/dist/scan/resolve.d.ts +23 -0
- package/dist/scan/resolve.js +131 -0
- package/dist/scan/resolve.js.map +1 -0
- package/dist/scan/scan.d.ts +41 -0
- package/dist/scan/scan.js +104 -0
- package/dist/scan/scan.js.map +1 -0
- package/dist/scan/types.d.ts +86 -0
- package/dist/scan/types.js +20 -0
- package/dist/scan/types.js.map +1 -0
- package/dist/sync/sync.d.ts +57 -0
- package/dist/sync/sync.js +192 -0
- package/dist/sync/sync.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +40 -6
- package/skills/neuroplex/SKILL.md +95 -0
- package/skills/neuroplex-update/SKILL.md +37 -0
- package/bin/neuroplex.js +0 -8
- package/index.js +0 -7
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Murillo Yamamoto
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Murillo Yamamoto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# 🧠 Neuroplex
|
|
2
|
-
|
|
3
|
-
> **A plug-and-play brain for your AI.** Turn any codebase into a living knowledge graph, served to your AI through a built-in MCP server. Free and open source.
|
|
4
|
-
|
|
5
|
-
**⚠️ Work in progress.** This package is a placeholder and does nothing useful yet. It will ship with the first usable release.
|
|
6
|
-
|
|
7
|
-
Follow the project on GitHub: https://github.com/MurilloY/Neuroplex
|
|
8
|
-
|
|
9
|
-
## License
|
|
10
|
-
|
|
11
|
-
MIT © Murillo Yamamoto
|
|
1
|
+
# 🧠 Neuroplex
|
|
2
|
+
|
|
3
|
+
> **A plug-and-play brain for your AI.** Turn any codebase into a living knowledge graph, served to your AI through a built-in MCP server. Free and open source.
|
|
4
|
+
|
|
5
|
+
**⚠️ Work in progress.** This package is a placeholder and does nothing useful yet. It will ship with the first usable release.
|
|
6
|
+
|
|
7
|
+
Follow the project on GitHub: https://github.com/MurilloY/Neuroplex
|
|
8
|
+
|
|
9
|
+
## License
|
|
10
|
+
|
|
11
|
+
MIT © Murillo Yamamoto
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface BuildOptions {
|
|
2
|
+
brainDir: string;
|
|
3
|
+
/** Initialize the brain as a git repository (if needed) and commit the result. */
|
|
4
|
+
git?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface BuildResult {
|
|
7
|
+
written: string[];
|
|
8
|
+
/** `claude mcp add …` command that plugs this brain into Claude Code on this machine. */
|
|
9
|
+
mcpCommand: string;
|
|
10
|
+
/** Commit created in the brain repository, if any. */
|
|
11
|
+
commit?: string;
|
|
12
|
+
/** Why committing was skipped or failed, if `git` was requested. */
|
|
13
|
+
gitNote?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const OVERVIEW_PATH = "notes/overview.md";
|
|
16
|
+
/**
|
|
17
|
+
* Generates the brain repository files around the graph (docs/ARCHITECTURE.md §4.4):
|
|
18
|
+
* README, .gitignore and the structural overview note. Content outside the
|
|
19
|
+
* generated markers in the overview is preserved, so AI-written notes survive rebuilds.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildBrain(options: BuildOptions): Promise<BuildResult>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { loadConfig } from '../config/config.js';
|
|
4
|
+
import { readGraph } from '../graph/jsonl.js';
|
|
5
|
+
import { git } from '../scan/git.js';
|
|
6
|
+
import { claudeAddCommand, mcpJson } from '../mcp/config.js';
|
|
7
|
+
import { VERSION } from '../version.js';
|
|
8
|
+
import { LOCAL_DIR } from './local.js';
|
|
9
|
+
import { graphStats } from './stats.js';
|
|
10
|
+
export const OVERVIEW_PATH = 'notes/overview.md';
|
|
11
|
+
const START = '<!-- neuroplex:structure:start -->';
|
|
12
|
+
const END = '<!-- neuroplex:structure:end -->';
|
|
13
|
+
/**
|
|
14
|
+
* Generates the brain repository files around the graph (docs/ARCHITECTURE.md §4.4):
|
|
15
|
+
* README, .gitignore and the structural overview note. Content outside the
|
|
16
|
+
* generated markers in the overview is preserved, so AI-written notes survive rebuilds.
|
|
17
|
+
*/
|
|
18
|
+
export async function buildBrain(options) {
|
|
19
|
+
const brainDir = resolve(options.brainDir);
|
|
20
|
+
const config = await loadConfig(brainDir);
|
|
21
|
+
const graph = await readGraph(brainDir);
|
|
22
|
+
if (graph.nodeCount === 0) {
|
|
23
|
+
throw new Error(`The brain at ${brainDir} has no graph yet. Run \`neuroplex scan\` first.`);
|
|
24
|
+
}
|
|
25
|
+
const stats = graphStats(graph);
|
|
26
|
+
const written = [];
|
|
27
|
+
if (await writeIfMissing(join(brainDir, 'README.md'), renderReadme(config)))
|
|
28
|
+
written.push('README.md');
|
|
29
|
+
if (await ensureGitignore(brainDir))
|
|
30
|
+
written.push('.gitignore');
|
|
31
|
+
if (await writeIfMissing(join(brainDir, '.mcp.json'), mcpJson()))
|
|
32
|
+
written.push('.mcp.json');
|
|
33
|
+
await mkdir(join(brainDir, 'notes'), { recursive: true });
|
|
34
|
+
const overviewPath = join(brainDir, OVERVIEW_PATH);
|
|
35
|
+
const existing = await readFile(overviewPath, 'utf8').catch(() => undefined);
|
|
36
|
+
await writeFile(overviewPath, renderOverview(existing, config, graph, stats), 'utf8');
|
|
37
|
+
written.push(OVERVIEW_PATH);
|
|
38
|
+
const result = { written, mcpCommand: claudeAddCommand(brainDir, config.source.name) };
|
|
39
|
+
if (options.git)
|
|
40
|
+
Object.assign(result, await commitBrain(brainDir, config));
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
async function writeIfMissing(path, content) {
|
|
44
|
+
try {
|
|
45
|
+
await writeFile(path, content, { encoding: 'utf8', flag: 'wx' });
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err.code === 'EEXIST')
|
|
50
|
+
return false;
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function ensureGitignore(brainDir) {
|
|
55
|
+
const path = join(brainDir, '.gitignore');
|
|
56
|
+
const current = await readFile(path, 'utf8').catch(() => '');
|
|
57
|
+
const entry = `${LOCAL_DIR}/`;
|
|
58
|
+
if (current.split(/\r?\n/).some((l) => l.trim() === entry))
|
|
59
|
+
return false;
|
|
60
|
+
const prefix = current && !current.endsWith('\n') ? '\n' : '';
|
|
61
|
+
await writeFile(path, `${current}${prefix}# Local Neuroplex state (machine-specific)\n${entry}\n`, 'utf8');
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
async function commitBrain(brainDir, config) {
|
|
65
|
+
const isRepo = (await git(brainDir, 'rev-parse', '--is-inside-work-tree')) === 'true';
|
|
66
|
+
const root = isRepo ? await git(brainDir, 'rev-parse', '--show-toplevel') : undefined;
|
|
67
|
+
if (isRepo && root && resolve(root) !== brainDir) {
|
|
68
|
+
return { gitNote: `the brain is inside another repository (${root}); not committing` };
|
|
69
|
+
}
|
|
70
|
+
if (!isRepo && (await git(brainDir, 'init', '-b', 'main')) === undefined) {
|
|
71
|
+
return { gitNote: 'git init failed' };
|
|
72
|
+
}
|
|
73
|
+
await git(brainDir, 'add', '-A');
|
|
74
|
+
if (!(await git(brainDir, 'status', '--porcelain')))
|
|
75
|
+
return { gitNote: 'nothing to commit' };
|
|
76
|
+
const sha = config.source.indexedCommit?.slice(0, 7) ?? 'worktree';
|
|
77
|
+
const message = `neuroplex: update brain for ${config.source.name}@${sha}`;
|
|
78
|
+
if ((await git(brainDir, 'commit', '-m', message)) === undefined) {
|
|
79
|
+
return { gitNote: 'git commit failed (is user.name/user.email configured?)' };
|
|
80
|
+
}
|
|
81
|
+
const commit = await git(brainDir, 'rev-parse', 'HEAD');
|
|
82
|
+
return commit ? { commit } : {};
|
|
83
|
+
}
|
|
84
|
+
// ── Rendering ──────────────────────────────────────────────────────────
|
|
85
|
+
function renderReadme(config) {
|
|
86
|
+
return `# ${config.source.name} brain
|
|
87
|
+
|
|
88
|
+
This repository is a **Neuroplex brain**: a knowledge graph of [${config.source.name}](${config.source.remote ?? '#'}) for AI assistants.
|
|
89
|
+
|
|
90
|
+
- \`graph/\`: nodes and edges (JSONL), regenerated by \`neuroplex scan\`
|
|
91
|
+
- \`notes/\`: human-readable notes; start with [notes/overview.md](notes/overview.md)
|
|
92
|
+
- \`neuroplex.json\`: brain configuration
|
|
93
|
+
|
|
94
|
+
Generated by [Neuroplex](https://github.com/MurilloY/Neuroplex). Refresh it with:
|
|
95
|
+
|
|
96
|
+
\`\`\`bash
|
|
97
|
+
npx neuroplex scan <path-to-${config.source.name}> --brain .
|
|
98
|
+
npx neuroplex build --brain .
|
|
99
|
+
\`\`\`
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
function renderOverview(existing, config, graph, stats) {
|
|
103
|
+
const generated = `${START}\n${renderStructure(config, graph, stats)}\n${END}`;
|
|
104
|
+
if (existing?.includes(START) && existing.includes(END)) {
|
|
105
|
+
const before = existing.slice(0, existing.indexOf(START));
|
|
106
|
+
const after = existing.slice(existing.indexOf(END) + END.length);
|
|
107
|
+
return `${before}${generated}${after}`;
|
|
108
|
+
}
|
|
109
|
+
return `# ${config.source.name}\n\n${generated}\n`;
|
|
110
|
+
}
|
|
111
|
+
function renderStructure(config, graph, s) {
|
|
112
|
+
const project = graph.getNode('project');
|
|
113
|
+
const lines = [
|
|
114
|
+
`> Generated by Neuroplex ${VERSION} from \`${config.source.branch}\`` +
|
|
115
|
+
(config.source.indexedCommit ? ` at \`${config.source.indexedCommit.slice(0, 7)}\`` : '') +
|
|
116
|
+
'. Do not edit between the markers; it is rewritten on every build.',
|
|
117
|
+
'',
|
|
118
|
+
];
|
|
119
|
+
if (project?.summary)
|
|
120
|
+
lines.push(project.summary, '');
|
|
121
|
+
lines.push('## At a glance', '', '| | Count |', '|---|---|');
|
|
122
|
+
const label = [
|
|
123
|
+
['module', 'Modules'],
|
|
124
|
+
['file', 'Files'],
|
|
125
|
+
['symbol', 'Symbols'],
|
|
126
|
+
['package', 'External packages'],
|
|
127
|
+
['concept', 'Concepts'],
|
|
128
|
+
['flow', 'Flows'],
|
|
129
|
+
];
|
|
130
|
+
for (const [type, name] of label) {
|
|
131
|
+
if (s.nodes[type])
|
|
132
|
+
lines.push(`| ${name} | ${s.nodes[type]} |`);
|
|
133
|
+
}
|
|
134
|
+
lines.push(`| Relationships | ${s.totalEdges} |`);
|
|
135
|
+
const langs = Object.entries(s.languages).sort((a, b) => b[1] - a[1]);
|
|
136
|
+
if (langs.length)
|
|
137
|
+
lines.push(`| Languages | ${langs.map(([l, n]) => `${l} (${n})`).join(', ')} |`);
|
|
138
|
+
if (s.stale)
|
|
139
|
+
lines.push(`| Stale nodes | ${s.stale} |`);
|
|
140
|
+
const section = (title, ranked, unit, show) => {
|
|
141
|
+
if (!ranked.length)
|
|
142
|
+
return;
|
|
143
|
+
lines.push('', `## ${title}`, '', `| | ${unit} |`, '|---|---|');
|
|
144
|
+
for (const r of ranked)
|
|
145
|
+
lines.push(`| ${show(r.node)} | ${r.count} |`);
|
|
146
|
+
};
|
|
147
|
+
section('Core modules', s.coreModules, 'Modules depending on it', (n) => `\`${n.path ?? n.name}\``);
|
|
148
|
+
section('Most used symbols', s.hotSymbols, 'Callers', (n) => `\`${n.name}\` in \`${n.path}\``);
|
|
149
|
+
section('External packages', s.topPackages, 'Files importing it', (n) => `\`${n.name}\``);
|
|
150
|
+
const listSemantic = (title, type) => {
|
|
151
|
+
const nodes = [...graph.nodes()].filter((n) => n.type === type).sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
152
|
+
if (!nodes.length)
|
|
153
|
+
return;
|
|
154
|
+
lines.push('', `## ${title}`, '');
|
|
155
|
+
for (const n of nodes) {
|
|
156
|
+
const name = n.note ? `[${n.name}](${n.note.replace(/^notes\//, '')})` : n.name;
|
|
157
|
+
lines.push(`- **${name}**${n.summary ? `: ${n.summary}` : ''}`);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
listSemantic('Concepts', 'concept');
|
|
161
|
+
listSemantic('Flows', 'flow');
|
|
162
|
+
const modules = [...graph.nodes()].filter((n) => n.type === 'module' && n.summary);
|
|
163
|
+
if (modules.length) {
|
|
164
|
+
lines.push('', '## Modules', '');
|
|
165
|
+
for (const m of modules.sort((a, b) => (a.id < b.id ? -1 : 1))) {
|
|
166
|
+
const name = m.note ? `[\`${m.path}\`](${m.note.replace(/^notes\//, '')})` : `\`${m.path}\``;
|
|
167
|
+
lines.push(`- ${name}: ${m.summary}${m.stale ? ' *(may be outdated)*' : ''}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return lines.join('\n');
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/brain/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAA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BAAsB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-specific state in `<brain>/.neuroplex/local.json` (git-ignored), so the
|
|
3
|
+
* committed `neuroplex.json` stays portable across machines and teammates.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LOCAL_DIR = ".neuroplex";
|
|
6
|
+
export declare const LOCAL_FILE = "local.json";
|
|
7
|
+
export interface LocalState {
|
|
8
|
+
/** Absolute path of the source project on this machine. */
|
|
9
|
+
sourcePath?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function readLocalState(brainDir: string): Promise<LocalState>;
|
|
12
|
+
export declare function writeLocalState(brainDir: string, patch: LocalState): Promise<LocalState>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Machine-specific state in `<brain>/.neuroplex/local.json` (git-ignored), so the
|
|
5
|
+
* committed `neuroplex.json` stays portable across machines and teammates.
|
|
6
|
+
*/
|
|
7
|
+
export const LOCAL_DIR = '.neuroplex';
|
|
8
|
+
export const LOCAL_FILE = 'local.json';
|
|
9
|
+
export async function readLocalState(brainDir) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(await readFile(join(brainDir, LOCAL_DIR, LOCAL_FILE), 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function writeLocalState(brainDir, patch) {
|
|
18
|
+
const next = { ...(await readLocalState(brainDir)), ...patch };
|
|
19
|
+
await mkdir(join(brainDir, LOCAL_DIR), { recursive: true });
|
|
20
|
+
await writeFile(join(brainDir, LOCAL_DIR, LOCAL_FILE), JSON.stringify(next, null, 2) + '\n', 'utf8');
|
|
21
|
+
return next;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/brain/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;GAGG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAOvC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAe,CAAC;IACjG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,KAAiB;IACvE,MAAM,IAAI,GAAG,EAAE,GAAG,CAAC,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAC/D,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IACrG,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Graph } from '../graph/graph.js';
|
|
2
|
+
import type { EdgeType, GraphNode, NodeType } from '../graph/schema.js';
|
|
3
|
+
export interface Ranked {
|
|
4
|
+
node: GraphNode;
|
|
5
|
+
count: number;
|
|
6
|
+
}
|
|
7
|
+
export interface GraphStats {
|
|
8
|
+
nodes: Partial<Record<NodeType, number>>;
|
|
9
|
+
edges: Partial<Record<EdgeType, number>>;
|
|
10
|
+
totalNodes: number;
|
|
11
|
+
totalEdges: number;
|
|
12
|
+
stale: number;
|
|
13
|
+
/** Nodes with an AI-written summary. */
|
|
14
|
+
summarized: number;
|
|
15
|
+
languages: Record<string, number>;
|
|
16
|
+
/** Modules most depended on by other modules. */
|
|
17
|
+
coreModules: Ranked[];
|
|
18
|
+
/** External packages imported by the most files. */
|
|
19
|
+
topPackages: Ranked[];
|
|
20
|
+
/** Symbols called from the most places. */
|
|
21
|
+
hotSymbols: Ranked[];
|
|
22
|
+
}
|
|
23
|
+
export declare function graphStats(graph: Graph, top?: number): GraphStats;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function graphStats(graph, top = 10) {
|
|
2
|
+
const nodes = {};
|
|
3
|
+
const edges = {};
|
|
4
|
+
const languages = {};
|
|
5
|
+
let stale = 0;
|
|
6
|
+
let summarized = 0;
|
|
7
|
+
for (const n of graph.nodes()) {
|
|
8
|
+
nodes[n.type] = (nodes[n.type] ?? 0) + 1;
|
|
9
|
+
if (n.stale)
|
|
10
|
+
stale++;
|
|
11
|
+
if (n.summary)
|
|
12
|
+
summarized++;
|
|
13
|
+
if (n.type === 'file' && n.language)
|
|
14
|
+
languages[n.language] = (languages[n.language] ?? 0) + 1;
|
|
15
|
+
}
|
|
16
|
+
for (const e of graph.edges())
|
|
17
|
+
edges[e.type] = (edges[e.type] ?? 0) + 1;
|
|
18
|
+
const rank = (type, edge) => [...graph.nodes()]
|
|
19
|
+
.filter((n) => n.type === type)
|
|
20
|
+
.map((node) => ({ node, count: graph.incoming(node.id, [edge]).length }))
|
|
21
|
+
.filter((r) => r.count > 0)
|
|
22
|
+
.sort((a, b) => b.count - a.count || (a.node.id < b.node.id ? -1 : 1))
|
|
23
|
+
.slice(0, top);
|
|
24
|
+
return {
|
|
25
|
+
nodes,
|
|
26
|
+
edges,
|
|
27
|
+
totalNodes: graph.nodeCount,
|
|
28
|
+
totalEdges: graph.edgeCount,
|
|
29
|
+
stale,
|
|
30
|
+
summarized,
|
|
31
|
+
languages,
|
|
32
|
+
coreModules: rank('module', 'depends_on'),
|
|
33
|
+
topPackages: rank('package', 'imports'),
|
|
34
|
+
hotSymbols: rank('symbol', 'calls'),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/brain/stats.ts"],"names":[],"mappings":"AAyBA,MAAM,UAAU,UAAU,CAAC,KAAY,EAAE,GAAG,GAAG,EAAE;IAC/C,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,SAAS,GAA2B,EAAE,CAAC;IAC7C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAC9B,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,CAAC,KAAK;YAAE,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,CAAC,OAAO;YAAE,UAAU,EAAE,CAAC;QAC5B,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,QAAQ;YAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,C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WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC;QACvC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type NeuroplexConfig } from '../config/config.js';
|
|
2
|
+
import { type Phase } from '../enrich/tasks.js';
|
|
3
|
+
import { type SyncState } from '../sync/sync.js';
|
|
4
|
+
import { type GraphStats } from './stats.js';
|
|
5
|
+
export interface BrainStatus {
|
|
6
|
+
brainDir: string;
|
|
7
|
+
config: NeuroplexConfig;
|
|
8
|
+
stats: GraphStats;
|
|
9
|
+
/** Last auto-sync activity on this machine. */
|
|
10
|
+
sync: SyncState;
|
|
11
|
+
/** Pending AI enrichment tasks per phase. */
|
|
12
|
+
pendingTasks: Record<Phase, number>;
|
|
13
|
+
source: {
|
|
14
|
+
/** Local checkout of the source project, if known on this machine. */
|
|
15
|
+
path?: string;
|
|
16
|
+
/** Current HEAD of the local checkout. */
|
|
17
|
+
head?: string;
|
|
18
|
+
/** Commits in the local checkout that the brain has not indexed yet. */
|
|
19
|
+
behind?: number;
|
|
20
|
+
/** The local checkout has uncommitted changes. */
|
|
21
|
+
dirty?: true;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function brainStatus(brainDir: string): Promise<BrainStatus>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { loadConfig } from '../config/config.js';
|
|
3
|
+
import { listTasks } from '../enrich/tasks.js';
|
|
4
|
+
import { readGraph } from '../graph/jsonl.js';
|
|
5
|
+
import { readSyncState } from '../sync/sync.js';
|
|
6
|
+
import { countCommits, gitInfo } from '../scan/git.js';
|
|
7
|
+
import { readLocalState } from './local.js';
|
|
8
|
+
import { graphStats } from './stats.js';
|
|
9
|
+
export async function brainStatus(brainDir) {
|
|
10
|
+
const dir = resolve(brainDir);
|
|
11
|
+
const [config, graph, local] = await Promise.all([loadConfig(dir), readGraph(dir), readLocalState(dir)]);
|
|
12
|
+
const source = {};
|
|
13
|
+
if (local.sourcePath) {
|
|
14
|
+
source.path = local.sourcePath;
|
|
15
|
+
const git = await gitInfo(local.sourcePath);
|
|
16
|
+
if (git?.dirty)
|
|
17
|
+
source.dirty = true;
|
|
18
|
+
if (git?.head) {
|
|
19
|
+
source.head = git.head;
|
|
20
|
+
const indexed = config.source.indexedCommit;
|
|
21
|
+
const behind = indexed ? await countCommits(local.sourcePath, indexed, git.head) : undefined;
|
|
22
|
+
if (behind !== undefined)
|
|
23
|
+
source.behind = behind;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const pendingTasks = listTasks(graph, { limit: 0 }).pending;
|
|
27
|
+
const sync = await readSyncState(dir);
|
|
28
|
+
return { brainDir: dir, config, stats: graphStats(graph), pendingTasks, source, sync };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/brain/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAkB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAmB,MAAM,YAAY,CAAC;AAsBzD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,CAAC,MA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