neural-loom 0.2.43 → 0.2.45
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/cache/.previewinfo +1 -1
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/sessions/inject/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/input/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/launch/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/scope/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/start/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/stats/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/stop/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__01.zh3b._.js +6 -6
- package/.next/server/chunks/[root-of-the-server]__01.zh3b._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0656ruo._.js +6 -6
- package/.next/server/chunks/[root-of-the-server]__0656ruo._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__07zx04e._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__07zx04e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js +7 -7
- package/.next/server/chunks/[root-of-the-server]__0_o7_jj._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0d0pykb._.js +7 -7
- package/.next/server/chunks/[root-of-the-server]__0d0pykb._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0em6a~~._.js +5 -5
- package/.next/server/chunks/[root-of-the-server]__0em6a~~._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0gchnwb._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0gchnwb._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0i~01cv._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__0i~01cv._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0s0is_9._.js +6 -6
- package/.next/server/chunks/[root-of-the-server]__0s0is_9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0t713sv._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0t713sv._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0thsozo._.js +5 -5
- package/.next/server/chunks/[root-of-the-server]__0thsozo._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__10wwca8._.js +5 -5
- package/.next/server/chunks/[root-of-the-server]__10wwca8._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__11h_nxt._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__11h_nxt._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__11z12oe._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__11z12oe._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/package.json +1 -1
- package/src/lib/agents/ContextManager.ts +87 -63
- package/src/lib/agents/SessionPersister.ts +2 -5
- package/src/lib/config.ts +10 -1
- /package/.next/static/{xqFiJPAmHsNHappCgW2Ov → X96CB5X5ONpzNOxbXcD_F}/_buildManifest.js +0 -0
- /package/.next/static/{xqFiJPAmHsNHappCgW2Ov → X96CB5X5ONpzNOxbXcD_F}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{xqFiJPAmHsNHappCgW2Ov → X96CB5X5ONpzNOxbXcD_F}/_ssgManifest.js +0 -0
|
@@ -7,55 +7,75 @@ export class ContextManager {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
private static ensureDirs(root: string) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fs.
|
|
13
|
-
|
|
10
|
+
try {
|
|
11
|
+
const aiDir = path.join(root, ".ai", "neural-loom");
|
|
12
|
+
if (!fs.existsSync(aiDir)) {
|
|
13
|
+
fs.mkdirSync(aiDir, { recursive: true });
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const commandDir = path.join(root, ".claude", "commands");
|
|
17
|
+
if (!fs.existsSync(commandDir)) {
|
|
18
|
+
fs.mkdirSync(commandDir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.warn(`[ContextManager] Failed to ensure directories at ${root}:`, err);
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
public static initializeStaging(root: string = process.env.ORIGINAL_CWD || process.cwd()) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
fs.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
try {
|
|
27
|
+
this.ensureDirs(root);
|
|
28
|
+
|
|
29
|
+
// Create /ccp.md custom slash command file
|
|
30
|
+
const ccpPath = path.join(root, ".claude", "commands", "ccp.md");
|
|
31
|
+
if (!fs.existsSync(ccpPath)) {
|
|
32
|
+
fs.writeFileSync(
|
|
33
|
+
ccpPath,
|
|
34
|
+
"Read the prompt from .ai/neural-loom/cprompt.md and execute it. This is a staged prompt from the NeuralLoom UI. Treat the contents as user instructions.\n"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// Create /ccc.md custom slash command file
|
|
39
|
+
const cccPath = path.join(root, ".claude", "commands", "ccc.md");
|
|
40
|
+
if (!fs.existsSync(cccPath)) {
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
cccPath,
|
|
43
|
+
"Read the context from .ai/neural-loom/ccontext.md. This is persistent context from the NeuralLoom UI. Absorb it as background information for this session. Acknowledge briefly what you received.\n"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
} catch (err) {
|
|
47
|
+
console.warn(`[ContextManager] Failed to initialize staging at ${root}:`, err);
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
public static updatePrompt(promptText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
try {
|
|
53
|
+
this.ensureDirs(root);
|
|
54
|
+
const promptFile = path.join(root, ".ai", "neural-loom", "cprompt.md");
|
|
55
|
+
fs.writeFileSync(promptFile, promptText);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(`[ContextManager] Failed to write prompt file at ${root}:`, err);
|
|
58
|
+
}
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
public static updateContext(contextText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
try {
|
|
63
|
+
this.ensureDirs(root);
|
|
64
|
+
const contextFile = path.join(root, ".ai", "neural-loom", "ccontext.md");
|
|
65
|
+
fs.writeFileSync(contextFile, contextText);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.error(`[ContextManager] Failed to write context file at ${root}:`, err);
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
|
|
55
71
|
public static updateRules(rulesText: string, root: string = process.env.ORIGINAL_CWD || process.cwd()) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
try {
|
|
73
|
+
this.ensureDirs(root);
|
|
74
|
+
const agentsMdPath = path.join(root, "AGENTS.md");
|
|
75
|
+
fs.writeFileSync(agentsMdPath, rulesText, "utf8");
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error(`[ContextManager] Failed to write rules file at ${root}:`, err);
|
|
78
|
+
}
|
|
59
79
|
}
|
|
60
80
|
|
|
61
81
|
public static loadPrompt(root: string = process.env.ORIGINAL_CWD || process.cwd()): string {
|
|
@@ -73,41 +93,45 @@ export class ContextManager {
|
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
public static compileSessionContext(root: string = process.env.ORIGINAL_CWD || process.cwd(), scopedDirs?: string[]) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
try {
|
|
97
|
+
this.ensureDirs(root);
|
|
98
|
+
this.initializeStaging(root);
|
|
99
|
+
|
|
100
|
+
// Check if AGENTS.md rules template exists
|
|
101
|
+
const agentsMdPath = path.join(root, "AGENTS.md");
|
|
102
|
+
let agentsRules = "";
|
|
103
|
+
if (fs.existsSync(agentsMdPath)) {
|
|
104
|
+
agentsRules = fs.readFileSync(agentsMdPath, "utf8");
|
|
105
|
+
} else {
|
|
106
|
+
// Try fallback from global
|
|
107
|
+
const fallbackPath = path.join(this.workspaceRoot, "AGENTS.md");
|
|
108
|
+
if (fs.existsSync(fallbackPath)) {
|
|
109
|
+
agentsRules = fs.readFileSync(fallbackPath, "utf8");
|
|
110
|
+
}
|
|
89
111
|
}
|
|
90
|
-
}
|
|
91
112
|
|
|
92
|
-
|
|
93
|
-
|
|
113
|
+
// Generate maps
|
|
114
|
+
let maps = `## Workspace Root Map (${root}):\n${this.generateProjectMapFor(root)}`;
|
|
94
115
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
if (scopedDirs && Array.isArray(scopedDirs)) {
|
|
117
|
+
scopedDirs.forEach((dir) => {
|
|
118
|
+
if (fs.existsSync(dir)) {
|
|
119
|
+
maps += `\n\n## Scoped Directory Map (${dir}):\n${this.generateProjectMapFor(dir)}`;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
102
123
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
// Combine rules and folder map
|
|
125
|
+
const compiledContext = `# System Rules & Guidelines\n\n${agentsRules}\n\n# Project File Hierarchy Map\n\n${maps}`;
|
|
126
|
+
this.updateContext(compiledContext, root);
|
|
106
127
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
128
|
+
// Write a default empty prompt staging file if missing
|
|
129
|
+
const promptFile = path.join(root, ".ai", "neural-loom", "cprompt.md");
|
|
130
|
+
if (!fs.existsSync(promptFile)) {
|
|
131
|
+
fs.writeFileSync(promptFile, "Hello! Please review the project context (/ccc) and check for any tasks to execute.");
|
|
132
|
+
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.warn(`[ContextManager] Failed to compile session context at ${root}:`, err);
|
|
111
135
|
}
|
|
112
136
|
}
|
|
113
137
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { getConfigDir } from "../config";
|
|
3
4
|
|
|
4
5
|
export interface PersistedSession {
|
|
5
6
|
id: string;
|
|
@@ -17,12 +18,8 @@ export class SessionPersister {
|
|
|
17
18
|
private static pendingSaves = new Map<string, NodeJS.Timeout>();
|
|
18
19
|
private static pendingData = new Map<string, PersistedSession>();
|
|
19
20
|
|
|
20
|
-
private static get workspaceRoot(): string {
|
|
21
|
-
return process.env.ORIGINAL_CWD || process.cwd();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
21
|
private static getSessionsDir(): string {
|
|
25
|
-
const dir = path.join(
|
|
22
|
+
const dir = path.join(getConfigDir(), "sessions");
|
|
26
23
|
if (!fs.existsSync(dir)) {
|
|
27
24
|
fs.mkdirSync(dir, { recursive: true });
|
|
28
25
|
}
|
package/src/lib/config.ts
CHANGED
|
@@ -2,7 +2,13 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import os from "os";
|
|
4
4
|
|
|
5
|
+
let cachedConfigDir: string | null = null;
|
|
6
|
+
|
|
5
7
|
export function getConfigDir(): string {
|
|
8
|
+
if (cachedConfigDir) {
|
|
9
|
+
return cachedConfigDir;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
const primaryDir = path.join(process.env.ORIGINAL_CWD || process.cwd(), ".ai", "neural-loom");
|
|
7
13
|
|
|
8
14
|
try {
|
|
@@ -14,18 +20,21 @@ export function getConfigDir(): string {
|
|
|
14
20
|
const testFile = path.join(primaryDir, ".write-test-" + Math.random().toString(36).substring(7));
|
|
15
21
|
fs.writeFileSync(testFile, "test");
|
|
16
22
|
fs.unlinkSync(testFile);
|
|
23
|
+
cachedConfigDir = primaryDir;
|
|
17
24
|
return primaryDir;
|
|
18
25
|
} catch (err) {
|
|
19
26
|
// If EPERM or any other write error occurs, fall back to the user's home directory
|
|
20
|
-
console.warn(`[Config] Primary config dir is not writable (${primaryDir}). Falling back to home directory
|
|
27
|
+
console.warn(`[Config] Primary config dir is not writable (${primaryDir}). Falling back to home directory.`);
|
|
21
28
|
const fallbackDir = path.join(os.homedir(), ".ai", "neural-loom");
|
|
22
29
|
try {
|
|
23
30
|
if (!fs.existsSync(fallbackDir)) {
|
|
24
31
|
fs.mkdirSync(fallbackDir, { recursive: true });
|
|
25
32
|
}
|
|
33
|
+
cachedConfigDir = fallbackDir;
|
|
26
34
|
return fallbackDir;
|
|
27
35
|
} catch (fallbackErr) {
|
|
28
36
|
console.error("[Config] Fallback config dir is also not writable!", fallbackErr);
|
|
37
|
+
cachedConfigDir = primaryDir;
|
|
29
38
|
return primaryDir;
|
|
30
39
|
}
|
|
31
40
|
}
|
|
File without changes
|
/package/.next/static/{xqFiJPAmHsNHappCgW2Ov → X96CB5X5ONpzNOxbXcD_F}/_clientMiddlewareManifest.js
RENAMED
|
File without changes
|
|
File without changes
|