@theihtisham/agent-shadow-brain 1.0.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 -0
- package/README.md +166 -0
- package/dist/adapters/base-adapter.d.ts +18 -0
- package/dist/adapters/base-adapter.d.ts.map +1 -0
- package/dist/adapters/base-adapter.js +110 -0
- package/dist/adapters/base-adapter.js.map +1 -0
- package/dist/adapters/claude-code.d.ts +14 -0
- package/dist/adapters/claude-code.d.ts.map +1 -0
- package/dist/adapters/claude-code.js +125 -0
- package/dist/adapters/claude-code.js.map +1 -0
- package/dist/adapters/cline.d.ts +13 -0
- package/dist/adapters/cline.d.ts.map +1 -0
- package/dist/adapters/cline.js +119 -0
- package/dist/adapters/cline.js.map +1 -0
- package/dist/adapters/codex.d.ts +12 -0
- package/dist/adapters/codex.d.ts.map +1 -0
- package/dist/adapters/codex.js +65 -0
- package/dist/adapters/codex.js.map +1 -0
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +38 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/kilo-code.d.ts +12 -0
- package/dist/adapters/kilo-code.d.ts.map +1 -0
- package/dist/adapters/kilo-code.js +94 -0
- package/dist/adapters/kilo-code.js.map +1 -0
- package/dist/adapters/opencode.d.ts +12 -0
- package/dist/adapters/opencode.d.ts.map +1 -0
- package/dist/adapters/opencode.js +100 -0
- package/dist/adapters/opencode.js.map +1 -0
- package/dist/brain/analyzer.d.ts +23 -0
- package/dist/brain/analyzer.d.ts.map +1 -0
- package/dist/brain/analyzer.js +218 -0
- package/dist/brain/analyzer.js.map +1 -0
- package/dist/brain/llm-client.d.ts +30 -0
- package/dist/brain/llm-client.d.ts.map +1 -0
- package/dist/brain/llm-client.js +240 -0
- package/dist/brain/llm-client.js.map +1 -0
- package/dist/brain/orchestrator.d.ts +41 -0
- package/dist/brain/orchestrator.d.ts.map +1 -0
- package/dist/brain/orchestrator.js +289 -0
- package/dist/brain/orchestrator.js.map +1 -0
- package/dist/brain/project-context.d.ts +15 -0
- package/dist/brain/project-context.d.ts.map +1 -0
- package/dist/brain/project-context.js +225 -0
- package/dist/brain/project-context.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +254 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/dashboard.d.ts +3 -0
- package/dist/ui/dashboard.d.ts.map +1 -0
- package/dist/ui/dashboard.js +110 -0
- package/dist/ui/dashboard.js.map +1 -0
- package/dist/watchers/file-watcher.d.ts +18 -0
- package/dist/watchers/file-watcher.d.ts.map +1 -0
- package/dist/watchers/file-watcher.js +132 -0
- package/dist/watchers/file-watcher.js.map +1 -0
- package/dist/watchers/git-watcher.d.ts +31 -0
- package/dist/watchers/git-watcher.d.ts.map +1 -0
- package/dist/watchers/git-watcher.js +93 -0
- package/dist/watchers/git-watcher.js.map +1 -0
- package/package.json +77 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type AgentTool = 'claude-code' | 'kilo-code' | 'cline' | 'opencode' | 'codex' | 'roo-code' | 'aider' | 'cursor';
|
|
2
|
+
export interface AgentAdapter {
|
|
3
|
+
name: AgentTool;
|
|
4
|
+
displayName: string;
|
|
5
|
+
/** Detect if this agent tool is running */
|
|
6
|
+
detect(): Promise<boolean>;
|
|
7
|
+
/** Get the project directory the agent is working on */
|
|
8
|
+
getProjectDir(): Promise<string | null>;
|
|
9
|
+
/** Read the agent's memory/context files */
|
|
10
|
+
readMemory(): Promise<AgentMemory>;
|
|
11
|
+
/** Inject context/instructions into the agent's memory */
|
|
12
|
+
injectContext(ctx: BrainInsight): Promise<boolean>;
|
|
13
|
+
/** Read recent conversation/activity logs */
|
|
14
|
+
readActivity(): Promise<AgentActivity[]>;
|
|
15
|
+
/** Get agent-specific config paths */
|
|
16
|
+
getConfigPaths(): AgentPaths;
|
|
17
|
+
}
|
|
18
|
+
export interface AgentPaths {
|
|
19
|
+
memoryDir: string;
|
|
20
|
+
rulesDir: string;
|
|
21
|
+
conversationDir?: string;
|
|
22
|
+
configFile?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentMemory {
|
|
25
|
+
rules: string[];
|
|
26
|
+
context: string[];
|
|
27
|
+
recentFiles: string[];
|
|
28
|
+
projectKnowledge: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export interface AgentActivity {
|
|
31
|
+
timestamp: Date;
|
|
32
|
+
type: 'file_edit' | 'file_read' | 'command' | 'conversation' | 'error' | 'search';
|
|
33
|
+
detail: string;
|
|
34
|
+
file?: string;
|
|
35
|
+
diff?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface BrainInsight {
|
|
38
|
+
type: 'review' | 'suggestion' | 'warning' | 'context' | 'pattern' | 'instruction';
|
|
39
|
+
priority: 'critical' | 'high' | 'medium' | 'low';
|
|
40
|
+
title: string;
|
|
41
|
+
content: string;
|
|
42
|
+
files?: string[];
|
|
43
|
+
timestamp: Date;
|
|
44
|
+
sourceAgent?: AgentTool;
|
|
45
|
+
targetAgent?: AgentTool;
|
|
46
|
+
}
|
|
47
|
+
export interface BrainConfig {
|
|
48
|
+
provider: LLMProvider;
|
|
49
|
+
apiKey?: string;
|
|
50
|
+
model?: string;
|
|
51
|
+
agents: AgentTool[];
|
|
52
|
+
projectDir: string;
|
|
53
|
+
watchMode: boolean;
|
|
54
|
+
autoInject: boolean;
|
|
55
|
+
reviewDepth: 'quick' | 'standard' | 'deep';
|
|
56
|
+
brainPersonality: BrainPersonality;
|
|
57
|
+
}
|
|
58
|
+
export type LLMProvider = 'anthropic' | 'openai' | 'ollama' | 'openrouter';
|
|
59
|
+
export type BrainPersonality = 'mentor' | 'critic' | 'architect' | 'security' | 'performance' | 'balanced';
|
|
60
|
+
export interface FileChange {
|
|
61
|
+
path: string;
|
|
62
|
+
type: 'add' | 'modify' | 'delete' | 'rename';
|
|
63
|
+
diff?: string;
|
|
64
|
+
content?: string;
|
|
65
|
+
oldPath?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ProjectContext {
|
|
68
|
+
name: string;
|
|
69
|
+
rootDir: string;
|
|
70
|
+
language: string[];
|
|
71
|
+
framework?: string;
|
|
72
|
+
packageManager?: string;
|
|
73
|
+
structure: string[];
|
|
74
|
+
recentChanges: FileChange[];
|
|
75
|
+
gitBranch?: string;
|
|
76
|
+
gitStatus?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface BrainSession {
|
|
79
|
+
id: string;
|
|
80
|
+
startedAt: Date;
|
|
81
|
+
agent: AgentTool;
|
|
82
|
+
projectDir: string;
|
|
83
|
+
insights: BrainInsight[];
|
|
84
|
+
filesReviewed: number;
|
|
85
|
+
suggestionsInjected: number;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,WAAW,GACX,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,OAAO,GACP,QAAQ,CAAC;AAEb,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IAEpB,2CAA2C;IAC3C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3B,wDAAwD;IACxD,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAExC,4CAA4C;IAC5C,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnC,0DAA0D;IAC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AAQ,EAAE,YAAY,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8DAA8D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/ui/dashboard.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAgOxD,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CASzE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// src/ui/dashboard.tsx — Ink/React terminal UI for Shadow Brain
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { render, Box, Text, useInput, useApp } from 'ink';
|
|
5
|
+
const PRIORITY_COLORS = {
|
|
6
|
+
critical: 'red',
|
|
7
|
+
high: 'yellow',
|
|
8
|
+
medium: 'blue',
|
|
9
|
+
low: 'gray',
|
|
10
|
+
};
|
|
11
|
+
const TYPE_COLORS = {
|
|
12
|
+
add: 'green',
|
|
13
|
+
modify: 'yellow',
|
|
14
|
+
delete: 'red',
|
|
15
|
+
rename: 'cyan',
|
|
16
|
+
};
|
|
17
|
+
function formatUptime(ms) {
|
|
18
|
+
const s = Math.floor(ms / 1000);
|
|
19
|
+
const m = Math.floor(s / 60);
|
|
20
|
+
const h = Math.floor(m / 60);
|
|
21
|
+
if (h > 0)
|
|
22
|
+
return `${h}h ${m % 60}m`;
|
|
23
|
+
if (m > 0)
|
|
24
|
+
return `${m}m ${s % 60}s`;
|
|
25
|
+
return `${s}s`;
|
|
26
|
+
}
|
|
27
|
+
// Header component
|
|
28
|
+
const Header = ({ personality }) => (_jsxs(Box, { borderStyle: "double", borderColor: "magenta", paddingX: 1, children: [_jsx(Text, { bold: true, color: "magenta", children: " SHADOW BRAIN " }), _jsx(Text, { children: " | " }), _jsx(Text, { color: "cyan", children: "v1.0.0" }), _jsx(Text, { children: " | " }), _jsxs(Text, { color: "green", children: ["[", personality, "]"] }), _jsx(Text, { children: " | " }), _jsx(Text, { dimColor: true, children: "Press q to quit, p to pause" })] }));
|
|
29
|
+
// Status bar
|
|
30
|
+
const StatusBar = ({ running, uptime, agentCount, insightCount, personality }) => (_jsxs(Box, { paddingX: 1, children: [_jsx(Text, { bold: true, children: "Status: " }), _jsx(Text, { color: running ? 'green' : 'red', children: running ? 'ACTIVE' : 'STOPPED' }), _jsx(Text, { children: " | " }), _jsxs(Text, { children: ["Uptime: ", _jsx(Text, { color: "cyan", children: formatUptime(uptime) })] }), _jsx(Text, { children: " | " }), _jsxs(Text, { children: ["Agents: ", _jsx(Text, { color: "green", children: agentCount })] }), _jsx(Text, { children: " | " }), _jsxs(Text, { children: ["Insights: ", _jsx(Text, { color: "yellow", children: insightCount })] }), _jsx(Text, { children: " | " }), _jsxs(Text, { children: ["Mode: ", _jsx(Text, { color: "magenta", children: personality })] })] }));
|
|
31
|
+
// Agent panel
|
|
32
|
+
const AgentPanel = ({ agents }) => (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "AGENTS" }), _jsx(Box, { flexDirection: "column", children: agents.length > 0 ? agents.map((agent, i) => (_jsxs(Box, { children: [_jsx(Text, { color: "green", children: " [ACTIVE] " }), _jsx(Text, { children: agent })] }, i))) : (_jsx(Text, { dimColor: true, children: " No agents detected" })) })] }));
|
|
33
|
+
// Changes panel
|
|
34
|
+
const ChangesPanel = ({ changes }) => (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { bold: true, color: "cyan", children: ["FILE CHANGES (", changes.length, ")"] }), _jsxs(Box, { flexDirection: "column", children: [changes.slice(-8).map((change, i) => (_jsxs(Box, { children: [_jsx(Text, { color: TYPE_COLORS[change.type] || 'white', children: ` ${change.type.toUpperCase().padEnd(8)}` }), _jsx(Text, { children: change.path })] }, i))), changes.length > 8 && _jsxs(Text, { dimColor: true, children: [" ... and ", changes.length - 8, " more"] })] })] }));
|
|
35
|
+
// Insights panel
|
|
36
|
+
const InsightsPanel = ({ insights }) => (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { bold: true, color: "cyan", children: ["INSIGHTS (", insights.length, ")"] }), _jsxs(Box, { flexDirection: "column", children: [insights.slice(-5).map((insight, i) => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: PRIORITY_COLORS[insight.priority] || 'white', bold: true, children: ` [${insight.priority.toUpperCase()}] ` }), _jsx(Text, { bold: true, children: insight.title })] }), insight.files && insight.files.length > 0 && (_jsx(Text, { dimColor: true, children: ` Files: ${insight.files.join(', ')}` })), _jsx(Text, { dimColor: true, children: ` ${insight.type} | ${insight.priority}` })] }, i))), insights.length > 5 && (_jsxs(Text, { dimColor: true, children: [" ... and ", insights.length - 5, " more"] }))] })] }));
|
|
37
|
+
// Log panel
|
|
38
|
+
const LogPanel = ({ logs }) => (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "LOG" }), _jsx(Box, { flexDirection: "column", children: logs.slice(-6).map((log, i) => (_jsx(Text, { dimColor: true, children: ` ${log}` }, i))) })] }));
|
|
39
|
+
// Main Dashboard
|
|
40
|
+
const Dashboard = ({ orchestrator, onQuit }) => {
|
|
41
|
+
const { exit } = useApp();
|
|
42
|
+
const [running, setRunning] = useState(true);
|
|
43
|
+
const [paused, setPaused] = useState(false);
|
|
44
|
+
const [agents, setAgents] = useState([]);
|
|
45
|
+
const [changes, setChanges] = useState([]);
|
|
46
|
+
const [insights, setInsights] = useState([]);
|
|
47
|
+
const [logs, setLogs] = useState([]);
|
|
48
|
+
const [uptime, setUptime] = useState(0);
|
|
49
|
+
const [personality, setPersonality] = useState('balanced');
|
|
50
|
+
// Subscribe to orchestrator events
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const addLog = (msg) => {
|
|
53
|
+
const time = new Date().toLocaleTimeString();
|
|
54
|
+
setLogs(prev => [...prev.slice(-20), `${time} ${msg}`]);
|
|
55
|
+
};
|
|
56
|
+
orchestrator.on('started', () => { setRunning(true); addLog('Shadow Brain started'); });
|
|
57
|
+
orchestrator.on('stopped', () => { setRunning(false); addLog('Shadow Brain stopped'); });
|
|
58
|
+
orchestrator.on('agents-detected', ({ adapters }) => {
|
|
59
|
+
setAgents(adapters.map((a) => `${a.displayName} (${a.name})`));
|
|
60
|
+
addLog(`Detected ${adapters.length} agent(s)`);
|
|
61
|
+
});
|
|
62
|
+
orchestrator.on('analysis-start', ({ changeCount }) => {
|
|
63
|
+
addLog(`Analyzing ${changeCount} change(s)...`);
|
|
64
|
+
});
|
|
65
|
+
orchestrator.on('insights', ({ insights: newInsights }) => {
|
|
66
|
+
setInsights(prev => [...prev, ...newInsights].slice(-50));
|
|
67
|
+
addLog(`Generated ${newInsights.length} insight(s)`);
|
|
68
|
+
});
|
|
69
|
+
orchestrator.on('injection', ({ adapter, success }) => {
|
|
70
|
+
addLog(`${success ? 'Injected' : 'Failed to inject'} into ${adapter}`);
|
|
71
|
+
});
|
|
72
|
+
orchestrator.on('info', ({ message }) => {
|
|
73
|
+
addLog(message);
|
|
74
|
+
});
|
|
75
|
+
orchestrator.on('error', ({ error }) => {
|
|
76
|
+
addLog(`Error: ${error.message}`);
|
|
77
|
+
});
|
|
78
|
+
// Get initial status
|
|
79
|
+
const status = orchestrator.getStatus();
|
|
80
|
+
setPersonality(status.personality);
|
|
81
|
+
setUptime(status.uptime);
|
|
82
|
+
// Update uptime every second
|
|
83
|
+
const interval = setInterval(() => {
|
|
84
|
+
const s = orchestrator.getStatus();
|
|
85
|
+
setUptime(s.uptime);
|
|
86
|
+
}, 1000);
|
|
87
|
+
return () => clearInterval(interval);
|
|
88
|
+
}, [orchestrator]);
|
|
89
|
+
// Key handling
|
|
90
|
+
useInput((input) => {
|
|
91
|
+
if (input === 'q') {
|
|
92
|
+
orchestrator.stop();
|
|
93
|
+
setRunning(false);
|
|
94
|
+
setTimeout(() => { exit(); onQuit(); }, 100);
|
|
95
|
+
}
|
|
96
|
+
if (input === 'p') {
|
|
97
|
+
setPaused(prev => !prev);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Header, { personality: personality }), _jsx(StatusBar, { running: running && !paused, uptime: uptime, agentCount: agents.length, insightCount: insights.length, personality: personality }), paused && _jsx(Text, { color: "yellow", bold: true, children: " [PAUSED]" }), _jsx(AgentPanel, { agents: agents }), _jsx(ChangesPanel, { changes: changes }), _jsx(InsightsPanel, { insights: insights }), _jsx(LogPanel, { logs: logs })] }));
|
|
101
|
+
};
|
|
102
|
+
export function renderDashboard(orchestrator) {
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
const { unmount } = render(_jsx(Dashboard, { orchestrator: orchestrator, onQuit: () => {
|
|
105
|
+
unmount();
|
|
106
|
+
resolve();
|
|
107
|
+
} }));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/ui/dashboard.tsx"],"names":[],"mappings":";AAAA,gEAAgE;AAEhE,OAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI1D,MAAM,eAAe,GAA2B;IAC9C,QAAQ,EAAE,KAAK;IACf,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,M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,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,KAAC,MAAM,IAAC,WAAW,EAAE,WAAW,GAAI,EACpC,KAAC,SAAS,IACR,OAAO,EAAE,OAAO,IAAI,CAAC,MAAM,EAC3B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,CAAC,MAAM,EACzB,YAAY,EAAE,QAAQ,CAAC,MAAM,EAC7B,WAAW,EAAE,WAAW,GACxB,EACD,MAAM,IAAI,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,iCAAkB,EACtD,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,GAAI,EAC9B,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,GAAI,EAClC,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,GAAI,EACrC,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,GAAI,IACpB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,YAA0B;IACxD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CACxB,KAAC,SAAS,IAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE;gBAClD,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC;YACZ,CAAC,GAAI,CACN,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export declare class FileWatcher extends EventEmitter {
|
|
3
|
+
private watcher;
|
|
4
|
+
private projectDir;
|
|
5
|
+
private fileCache;
|
|
6
|
+
private changeQueue;
|
|
7
|
+
private debounceTimer;
|
|
8
|
+
private ignorePatterns;
|
|
9
|
+
constructor(projectDir: string);
|
|
10
|
+
start(): Promise<void>;
|
|
11
|
+
stop(): void;
|
|
12
|
+
private cacheExistingFiles;
|
|
13
|
+
private shouldIgnore;
|
|
14
|
+
private handleChange;
|
|
15
|
+
private debouncedEmit;
|
|
16
|
+
getFileContent(filePath: string): string | undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=file-watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-watcher.d.ts","sourceRoot":"","sources":["../../src/watchers/file-watcher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAMtC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,cAAc,CAAW;gBAErB,UAAU,EAAE,MAAM;IAmBxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB5B,IAAI,IAAI,IAAI;YAWE,kBAAkB;IA2BhC,OAAO,CAAC,YAAY;YAQN,YAAY;IA6B1B,OAAO,CAAC,aAAa;IAWrB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAIrD"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// src/watchers/file-watcher.ts — Watches project files for changes in real-time
|
|
2
|
+
import chokidar from 'chokidar';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import { diffLines } from 'diff';
|
|
7
|
+
export class FileWatcher extends EventEmitter {
|
|
8
|
+
constructor(projectDir) {
|
|
9
|
+
super();
|
|
10
|
+
this.watcher = null;
|
|
11
|
+
this.fileCache = new Map();
|
|
12
|
+
this.changeQueue = [];
|
|
13
|
+
this.debounceTimer = null;
|
|
14
|
+
this.projectDir = projectDir;
|
|
15
|
+
this.ignorePatterns = [
|
|
16
|
+
'**/node_modules/**',
|
|
17
|
+
'**/.git/**',
|
|
18
|
+
'**/dist/**',
|
|
19
|
+
'**/build/**',
|
|
20
|
+
'**/__pycache__/**',
|
|
21
|
+
'**/*.pyc',
|
|
22
|
+
'**/package-lock.json',
|
|
23
|
+
'**/yarn.lock',
|
|
24
|
+
'**/.next/**',
|
|
25
|
+
'**/.nuxt/**',
|
|
26
|
+
'**/coverage/**',
|
|
27
|
+
'**/.shadow-brain/**',
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
async start() {
|
|
31
|
+
// Pre-cache existing files
|
|
32
|
+
await this.cacheExistingFiles();
|
|
33
|
+
this.watcher = chokidar.watch(this.projectDir, {
|
|
34
|
+
ignored: this.ignorePatterns,
|
|
35
|
+
persistent: true,
|
|
36
|
+
ignoreInitial: true,
|
|
37
|
+
awaitWriteFinish: { stabilityThreshold: 300, pollInterval: 100 },
|
|
38
|
+
});
|
|
39
|
+
this.watcher
|
|
40
|
+
.on('add', (filePath) => this.handleChange(filePath, 'add'))
|
|
41
|
+
.on('change', (filePath) => this.handleChange(filePath, 'modify'))
|
|
42
|
+
.on('unlink', (filePath) => this.handleChange(filePath, 'delete'));
|
|
43
|
+
this.emit('started', this.projectDir);
|
|
44
|
+
}
|
|
45
|
+
stop() {
|
|
46
|
+
if (this.watcher) {
|
|
47
|
+
this.watcher.close();
|
|
48
|
+
this.watcher = null;
|
|
49
|
+
}
|
|
50
|
+
if (this.debounceTimer) {
|
|
51
|
+
clearTimeout(this.debounceTimer);
|
|
52
|
+
}
|
|
53
|
+
this.emit('stopped');
|
|
54
|
+
}
|
|
55
|
+
async cacheExistingFiles() {
|
|
56
|
+
const walkDir = (dir) => {
|
|
57
|
+
const results = [];
|
|
58
|
+
try {
|
|
59
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
const fullPath = path.join(dir, entry.name);
|
|
62
|
+
if (this.shouldIgnore(fullPath))
|
|
63
|
+
continue;
|
|
64
|
+
if (entry.isDirectory()) {
|
|
65
|
+
results.push(...walkDir(fullPath));
|
|
66
|
+
}
|
|
67
|
+
else if (entry.isFile()) {
|
|
68
|
+
results.push(fullPath);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch { /* skip unreadable dirs */ }
|
|
73
|
+
return results;
|
|
74
|
+
};
|
|
75
|
+
const files = walkDir(this.projectDir);
|
|
76
|
+
for (const file of files.slice(0, 500)) { // cap at 500 files
|
|
77
|
+
try {
|
|
78
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
79
|
+
this.fileCache.set(file, content);
|
|
80
|
+
}
|
|
81
|
+
catch { /* skip binary/unreadable files */ }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
shouldIgnore(filePath) {
|
|
85
|
+
const rel = path.relative(this.projectDir, filePath);
|
|
86
|
+
return this.ignorePatterns.some(pattern => {
|
|
87
|
+
const clean = pattern.replace(/\*\*/g, '').replace(/\*/g, '');
|
|
88
|
+
return rel.includes(clean.replace(/\//g, path.sep));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async handleChange(filePath, type) {
|
|
92
|
+
const relPath = path.relative(this.projectDir, filePath);
|
|
93
|
+
const change = { path: relPath, type };
|
|
94
|
+
if (type === 'modify' || type === 'add') {
|
|
95
|
+
try {
|
|
96
|
+
const newContent = fs.readFileSync(filePath, 'utf-8');
|
|
97
|
+
const oldContent = this.fileCache.get(filePath) || '';
|
|
98
|
+
if (type === 'modify' && oldContent) {
|
|
99
|
+
const changes = diffLines(oldContent, newContent);
|
|
100
|
+
const diffStr = changes
|
|
101
|
+
.filter(c => c.added || c.removed)
|
|
102
|
+
.map(c => (c.added ? `+${c.value}` : `-${c.value}`))
|
|
103
|
+
.join('');
|
|
104
|
+
change.diff = diffStr;
|
|
105
|
+
}
|
|
106
|
+
change.content = newContent;
|
|
107
|
+
this.fileCache.set(filePath, newContent);
|
|
108
|
+
}
|
|
109
|
+
catch { /* binary file */ }
|
|
110
|
+
}
|
|
111
|
+
else if (type === 'delete') {
|
|
112
|
+
this.fileCache.delete(filePath);
|
|
113
|
+
}
|
|
114
|
+
this.changeQueue.push(change);
|
|
115
|
+
this.debouncedEmit();
|
|
116
|
+
}
|
|
117
|
+
debouncedEmit() {
|
|
118
|
+
if (this.debounceTimer) {
|
|
119
|
+
clearTimeout(this.debounceTimer);
|
|
120
|
+
}
|
|
121
|
+
this.debounceTimer = setTimeout(() => {
|
|
122
|
+
const changes = [...this.changeQueue];
|
|
123
|
+
this.changeQueue = [];
|
|
124
|
+
this.emit('changes', changes);
|
|
125
|
+
}, 500);
|
|
126
|
+
}
|
|
127
|
+
getFileContent(filePath) {
|
|
128
|
+
const fullPath = path.resolve(this.projectDir, filePath);
|
|
129
|
+
return this.fileCache.get(fullPath);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=file-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../src/watchers/file-watcher.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,QAAuB,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,OAAO,WAAY,SAAQ,YAAY;IAQ3C,YAAY,UAAkB;QAC5B,KAAK,EAAE,CAAC;QARF,YAAO,GAAqB,IAAI,CAAC;QAEjC,cAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;QAC3C,gBAAW,GAAiB,EAAE,CAAC;QAC/B,kBAAa,GAA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CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StatusResult } from 'simple-git';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export interface GitState {
|
|
4
|
+
branch: string;
|
|
5
|
+
status: StatusResult;
|
|
6
|
+
recentCommits: GitCommit[];
|
|
7
|
+
stagedDiff: string;
|
|
8
|
+
unstagedDiff: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GitCommit {
|
|
11
|
+
hash: string;
|
|
12
|
+
message: string;
|
|
13
|
+
author: string;
|
|
14
|
+
date: string;
|
|
15
|
+
files: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare class GitWatcher extends EventEmitter {
|
|
18
|
+
private git;
|
|
19
|
+
private projectDir;
|
|
20
|
+
private pollInterval;
|
|
21
|
+
private lastCommitHash;
|
|
22
|
+
private lastBranch;
|
|
23
|
+
constructor(projectDir: string);
|
|
24
|
+
start(intervalMs?: number): Promise<void>;
|
|
25
|
+
stop(): void;
|
|
26
|
+
private poll;
|
|
27
|
+
getFullState(): Promise<GitState>;
|
|
28
|
+
getDiffForCommit(hash: string): Promise<string>;
|
|
29
|
+
getFileHistory(filePath: string, count?: number): Promise<GitCommit[]>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=git-watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-watcher.d.ts","sourceRoot":"","sources":["../../src/watchers/git-watcher.ts"],"names":[],"mappings":"AAEA,OAAkB,EAAa,YAAY,EAAc,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;IACrB,aAAa,EAAE,SAAS,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,UAAU,CAAc;gBAEpB,UAAU,EAAE,MAAM;IAMxB,KAAK,CAAC,UAAU,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD,IAAI,IAAI,IAAI;YAQE,IAAI;IAyBZ,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC;IA0BjC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAUhF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/watchers/git-watcher.ts — Watches git activity (commits, branches, diffs)
|
|
2
|
+
import simpleGit from 'simple-git';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export class GitWatcher extends EventEmitter {
|
|
5
|
+
constructor(projectDir) {
|
|
6
|
+
super();
|
|
7
|
+
this.pollInterval = null;
|
|
8
|
+
this.lastCommitHash = '';
|
|
9
|
+
this.lastBranch = '';
|
|
10
|
+
this.projectDir = projectDir;
|
|
11
|
+
this.git = simpleGit(projectDir);
|
|
12
|
+
}
|
|
13
|
+
async start(intervalMs = 3000) {
|
|
14
|
+
// Get initial state
|
|
15
|
+
try {
|
|
16
|
+
const log = await this.git.log({ maxCount: 1 });
|
|
17
|
+
this.lastCommitHash = log.latest?.hash || '';
|
|
18
|
+
const branch = await this.git.branch();
|
|
19
|
+
this.lastBranch = branch.current;
|
|
20
|
+
}
|
|
21
|
+
catch { /* not a git repo */ }
|
|
22
|
+
this.pollInterval = setInterval(() => this.poll(), intervalMs);
|
|
23
|
+
this.emit('started');
|
|
24
|
+
}
|
|
25
|
+
stop() {
|
|
26
|
+
if (this.pollInterval) {
|
|
27
|
+
clearInterval(this.pollInterval);
|
|
28
|
+
this.pollInterval = null;
|
|
29
|
+
}
|
|
30
|
+
this.emit('stopped');
|
|
31
|
+
}
|
|
32
|
+
async poll() {
|
|
33
|
+
try {
|
|
34
|
+
// Check for new commits
|
|
35
|
+
const log = await this.git.log({ maxCount: 1 });
|
|
36
|
+
const currentHash = log.latest?.hash || '';
|
|
37
|
+
if (currentHash && currentHash !== this.lastCommitHash) {
|
|
38
|
+
this.lastCommitHash = currentHash;
|
|
39
|
+
this.emit('new-commit', {
|
|
40
|
+
hash: log.latest?.hash,
|
|
41
|
+
message: log.latest?.message,
|
|
42
|
+
author: log.latest?.author_name,
|
|
43
|
+
date: log.latest?.date,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Check for branch change
|
|
47
|
+
const branch = await this.git.branch();
|
|
48
|
+
if (branch.current !== this.lastBranch) {
|
|
49
|
+
const oldBranch = this.lastBranch;
|
|
50
|
+
this.lastBranch = branch.current;
|
|
51
|
+
this.emit('branch-change', { from: oldBranch, to: branch.current });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch { /* ignore git errors during polling */ }
|
|
55
|
+
}
|
|
56
|
+
async getFullState() {
|
|
57
|
+
const [status, log, stagedDiff, unstagedDiff, branch] = await Promise.all([
|
|
58
|
+
this.git.status(),
|
|
59
|
+
this.git.log({ maxCount: 10 }),
|
|
60
|
+
this.git.diff(['--cached']),
|
|
61
|
+
this.git.diff(),
|
|
62
|
+
this.git.branch(),
|
|
63
|
+
]);
|
|
64
|
+
const recentCommits = (log.all || []).slice(0, 10).map(c => ({
|
|
65
|
+
hash: c.hash,
|
|
66
|
+
message: c.message,
|
|
67
|
+
author: c.author_name,
|
|
68
|
+
date: c.date,
|
|
69
|
+
files: [], // populated on demand
|
|
70
|
+
}));
|
|
71
|
+
return {
|
|
72
|
+
branch: branch.current,
|
|
73
|
+
status,
|
|
74
|
+
recentCommits,
|
|
75
|
+
stagedDiff,
|
|
76
|
+
unstagedDiff,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async getDiffForCommit(hash) {
|
|
80
|
+
return this.git.diff([`${hash}~1`, hash]);
|
|
81
|
+
}
|
|
82
|
+
async getFileHistory(filePath, count = 5) {
|
|
83
|
+
const log = await this.git.log({ file: filePath, maxCount: count });
|
|
84
|
+
return (log.all || []).map(c => ({
|
|
85
|
+
hash: c.hash,
|
|
86
|
+
message: c.message,
|
|
87
|
+
author: c.author_name,
|
|
88
|
+
date: c.date,
|
|
89
|
+
files: [filePath],
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=git-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-watcher.js","sourceRoot":"","sources":["../../src/watchers/git-watcher.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,SAAkD,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAkBtC,MAAM,OAAO,UAAW,SAAQ,YAAY;IAO1C,YAAY,UAAkB;QAC5B,KAAK,EAAE,CAAC;QALF,iBAAY,GAA0B,IAAI,CAAC;QAC3C,mBAAc,GAAW,EAAE,CAAC;QAC5B,eAAU,GAAW,EAAE,CAAC;QAI9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,UAAU,C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CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACxE,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,MAAM,EAAE,CAAC,CAAC,WAAW;YACrB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,EAAE,EAAE,sBAAsB;SAClC,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,OAAO;YACtB,MAAM;YACN,aAAa;YACb,UAAU;YACV,YAAY;SACb,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAAY;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAAgB,EAAE,QAAgB,CAAC;QACtD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC/B,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,MAAM,EAAE,CAAC,CAAC,WAAW;YACrB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theihtisham/agent-shadow-brain",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A shadow AI brain that runs alongside Claude Code, Kilo Code, Cline, OpenCode, and Codex — watching, reviewing, and injecting intelligence in real-time.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"shadow-brain": "dist/cli.js",
|
|
11
|
+
"asb": "dist/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "ts-node src/cli.ts",
|
|
16
|
+
"watch": "tsc --watch",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"lint": "tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"ai",
|
|
23
|
+
"agent",
|
|
24
|
+
"brain",
|
|
25
|
+
"shadow",
|
|
26
|
+
"claude-code",
|
|
27
|
+
"kilo-code",
|
|
28
|
+
"cline",
|
|
29
|
+
"opencode",
|
|
30
|
+
"codex",
|
|
31
|
+
"review",
|
|
32
|
+
"intelligence",
|
|
33
|
+
"mcp",
|
|
34
|
+
"llm"
|
|
35
|
+
],
|
|
36
|
+
"author": "theihtisham",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@anthropic-ai/sdk": "^0.39.0",
|
|
40
|
+
"chalk": "^4.1.2",
|
|
41
|
+
"chokidar": "^4.0.3",
|
|
42
|
+
"commander": "^12.1.0",
|
|
43
|
+
"conf": "^13.0.0",
|
|
44
|
+
"diff": "^5.2.0",
|
|
45
|
+
"execa": "^5.1.1",
|
|
46
|
+
"ink": "^4.4.1",
|
|
47
|
+
"inquirer": "^8.2.6",
|
|
48
|
+
"marked": "^12.0.0",
|
|
49
|
+
"ora": "^5.4.1",
|
|
50
|
+
"react": "^18.3.1",
|
|
51
|
+
"simple-git": "^3.27.0",
|
|
52
|
+
"ws": "^8.18.0",
|
|
53
|
+
"zod": "^3.23.8"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/diff": "^5.2.3",
|
|
57
|
+
"@types/inquirer": "^9.0.7",
|
|
58
|
+
"@types/node": "^20.14.0",
|
|
59
|
+
"@types/react": "^18.3.0",
|
|
60
|
+
"@types/ws": "^8.5.13",
|
|
61
|
+
"ts-node": "^10.9.2",
|
|
62
|
+
"typescript": "^5.5.0",
|
|
63
|
+
"vitest": "^1.6.0"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18.0.0"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"dist/**/*",
|
|
70
|
+
"README.md",
|
|
71
|
+
"LICENSE"
|
|
72
|
+
],
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
},
|
|
76
|
+
"type": "module"
|
|
77
|
+
}
|