erosolar-cli 1.7.261 → 1.7.263
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/dist/capabilities/securityTestingCapability.d.ts +13 -0
- package/dist/capabilities/securityTestingCapability.d.ts.map +1 -0
- package/dist/capabilities/securityTestingCapability.js +25 -0
- package/dist/capabilities/securityTestingCapability.js.map +1 -0
- package/dist/contracts/agent-schemas.json +15 -0
- package/dist/contracts/tools.schema.json +9 -0
- package/dist/core/hooksSystem.d.ts +65 -0
- package/dist/core/hooksSystem.d.ts.map +1 -0
- package/dist/core/hooksSystem.js +273 -0
- package/dist/core/hooksSystem.js.map +1 -0
- package/dist/core/memorySystem.d.ts +48 -0
- package/dist/core/memorySystem.d.ts.map +1 -0
- package/dist/core/memorySystem.js +271 -0
- package/dist/core/memorySystem.js.map +1 -0
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
- package/dist/plugins/tools/nodeDefaults.js +2 -0
- package/dist/plugins/tools/nodeDefaults.js.map +1 -1
- package/dist/plugins/tools/security/securityPlugin.d.ts +3 -0
- package/dist/plugins/tools/security/securityPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/security/securityPlugin.js +12 -0
- package/dist/plugins/tools/security/securityPlugin.js.map +1 -0
- package/dist/shell/interactiveShell.d.ts +5 -1
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +118 -9
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/metricsTracker.d.ts +60 -0
- package/dist/shell/metricsTracker.d.ts.map +1 -0
- package/dist/shell/metricsTracker.js +119 -0
- package/dist/shell/metricsTracker.js.map +1 -0
- package/dist/shell/shellApp.d.ts +0 -2
- package/dist/shell/shellApp.d.ts.map +1 -1
- package/dist/shell/shellApp.js +0 -16
- package/dist/shell/shellApp.js.map +1 -1
- package/dist/shell/systemPrompt.d.ts.map +1 -1
- package/dist/shell/systemPrompt.js +4 -1
- package/dist/shell/systemPrompt.js.map +1 -1
- package/dist/shell/terminalInput.d.ts +10 -3
- package/dist/shell/terminalInput.d.ts.map +1 -1
- package/dist/shell/terminalInput.js +33 -14
- package/dist/shell/terminalInput.js.map +1 -1
- package/dist/shell/terminalInputAdapter.d.ts +5 -0
- package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
- package/dist/shell/terminalInputAdapter.js +7 -0
- package/dist/shell/terminalInputAdapter.js.map +1 -1
- package/dist/tools/securityTools.d.ts +22 -0
- package/dist/tools/securityTools.d.ts.map +1 -0
- package/dist/tools/securityTools.js +448 -0
- package/dist/tools/securityTools.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CapabilityContribution, CapabilityContext, CapabilityModule } from '../runtime/agentHost.js';
|
|
2
|
+
export interface SecurityTestingCapabilityOptions {
|
|
3
|
+
workingDir?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class SecurityTestingCapabilityModule implements CapabilityModule {
|
|
8
|
+
readonly id = "capability.security-testing";
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(options?: SecurityTestingCapabilityOptions);
|
|
11
|
+
create(context: CapabilityContext): Promise<CapabilityContribution>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=securityTestingCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securityTestingCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/securityTestingCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3G,MAAM,WAAW,gCAAgC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,+BAAgC,YAAW,gBAAgB;IACtE,QAAQ,CAAC,EAAE,iCAAiC;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;gBAE/C,OAAO,GAAE,gCAAqC;IAIpD,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAiB1E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSecurityTools } from '../tools/securityTools.js';
|
|
2
|
+
export class SecurityTestingCapabilityModule {
|
|
3
|
+
id = 'capability.security-testing';
|
|
4
|
+
options;
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
async create(context) {
|
|
9
|
+
const workingDir = this.options.workingDir ?? context.workingDir;
|
|
10
|
+
return {
|
|
11
|
+
id: this.options.id ?? 'security.testing',
|
|
12
|
+
description: this.options.description ?? 'Ethical penetration testing and security analysis tools.',
|
|
13
|
+
toolSuite: {
|
|
14
|
+
id: 'security-testing',
|
|
15
|
+
description: 'Security scanning, vulnerability detection, and penetration testing (authorized targets only)',
|
|
16
|
+
tools: createSecurityTools(workingDir),
|
|
17
|
+
},
|
|
18
|
+
metadata: {
|
|
19
|
+
workingDir,
|
|
20
|
+
disclaimer: 'For authorized security testing only. Do not use on systems without permission.',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=securityTestingCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securityTestingCapability.js","sourceRoot":"","sources":["../../src/capabilities/securityTestingCapability.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAQhE,MAAM,OAAO,+BAA+B;IACjC,EAAE,GAAG,6BAA6B,CAAC;IAC3B,OAAO,CAAmC;IAE3D,YAAY,UAA4C,EAAE;QACxD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAA0B;QACrC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC;QACjE,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,kBAAkB;YACzC,WAAW,EACT,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,0DAA0D;YACxF,SAAS,EAAE;gBACT,EAAE,EAAE,kBAAkB;gBACtB,WAAW,EAAE,+FAA+F;gBAC5G,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC;aACvC;YACD,QAAQ,EAAE;gBACR,UAAU;gBACV,UAAU,EAAE,iFAAiF;aAC9F;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -372,6 +372,21 @@
|
|
|
372
372
|
"command": "/autocontinue",
|
|
373
373
|
"description": "Toggle auto-continue mode (prompts model when it expresses intent but doesn't act)",
|
|
374
374
|
"category": "configuration"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"command": "/memory",
|
|
378
|
+
"description": "View and manage persistent memory files (EROSOLAR.md)",
|
|
379
|
+
"category": "workspace"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"command": "/clear",
|
|
383
|
+
"description": "Clear conversation history",
|
|
384
|
+
"category": "workspace"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"command": "/help",
|
|
388
|
+
"description": "Show available commands and usage",
|
|
389
|
+
"category": "other"
|
|
375
390
|
}
|
|
376
391
|
],
|
|
377
392
|
|
|
@@ -203,6 +203,15 @@
|
|
|
203
203
|
"category": "integrations",
|
|
204
204
|
"scopes": ["integrations:mcp"],
|
|
205
205
|
"pluginIds": ["tool.mcp.bridge"]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"id": "security-testing",
|
|
209
|
+
"label": "Security testing",
|
|
210
|
+
"description": "Ethical penetration testing and security analysis tools. For authorized testing only.",
|
|
211
|
+
"defaultEnabled": false,
|
|
212
|
+
"category": "advanced",
|
|
213
|
+
"scopes": ["analysis:security"],
|
|
214
|
+
"pluginIds": ["tool.security.testing"]
|
|
206
215
|
}
|
|
207
216
|
]
|
|
208
217
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks System - Event-driven automation for tool execution
|
|
3
|
+
*
|
|
4
|
+
* Implements a Claude Code-style hooks system that runs shell commands
|
|
5
|
+
* in response to tool execution events:
|
|
6
|
+
*
|
|
7
|
+
* - beforeToolExecution: Runs before any tool starts
|
|
8
|
+
* - afterToolExecution: Runs after any tool completes
|
|
9
|
+
* - beforeFileEdit: Runs before a file is modified
|
|
10
|
+
* - afterFileEdit: Runs after a file is modified
|
|
11
|
+
* - beforeBashCommand: Runs before a bash command executes
|
|
12
|
+
* - afterBashCommand: Runs after a bash command completes
|
|
13
|
+
*
|
|
14
|
+
* Hooks are configured in EROSOLAR.md or settings.json
|
|
15
|
+
*/
|
|
16
|
+
export type HookTrigger = 'beforeToolExecution' | 'afterToolExecution' | 'beforeFileEdit' | 'afterFileEdit' | 'beforeBashCommand' | 'afterBashCommand';
|
|
17
|
+
export interface HookDefinition {
|
|
18
|
+
/** When to trigger the hook */
|
|
19
|
+
when: HookTrigger;
|
|
20
|
+
/** Condition to match (tool name, file pattern, or command pattern) */
|
|
21
|
+
if?: string;
|
|
22
|
+
/** Shell commands to execute */
|
|
23
|
+
then: string[];
|
|
24
|
+
/** Optional timeout in milliseconds */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface HookContext {
|
|
28
|
+
/** The tool or command being executed */
|
|
29
|
+
tool?: string;
|
|
30
|
+
/** File path if applicable */
|
|
31
|
+
file?: string;
|
|
32
|
+
/** Bash command if applicable */
|
|
33
|
+
command?: string;
|
|
34
|
+
/** Working directory */
|
|
35
|
+
workingDir: string;
|
|
36
|
+
/** Additional context data */
|
|
37
|
+
data?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export interface HookResult {
|
|
40
|
+
/** Whether the hook was triggered */
|
|
41
|
+
triggered: boolean;
|
|
42
|
+
/** Output from executed commands */
|
|
43
|
+
output: string[];
|
|
44
|
+
/** Any errors that occurred */
|
|
45
|
+
errors: string[];
|
|
46
|
+
/** Whether execution should be aborted */
|
|
47
|
+
abort: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Load hooks from EROSOLAR.md or settings.json
|
|
51
|
+
*/
|
|
52
|
+
export declare function loadHooks(workingDir: string): HookDefinition[];
|
|
53
|
+
/**
|
|
54
|
+
* Run hooks for a specific trigger
|
|
55
|
+
*/
|
|
56
|
+
export declare function runHooks(trigger: HookTrigger, context: HookContext, hooks?: HookDefinition[]): Promise<HookResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a hooks runner bound to a specific working directory
|
|
59
|
+
*/
|
|
60
|
+
export declare function createHooksRunner(workingDir: string): {
|
|
61
|
+
runBefore: (trigger: HookTrigger, context: Omit<HookContext, 'workingDir'>) => Promise<HookResult>;
|
|
62
|
+
runAfter: (trigger: HookTrigger, context: Omit<HookContext, 'workingDir'>) => Promise<HookResult>;
|
|
63
|
+
reload: () => void;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=hooksSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooksSystem.d.ts","sourceRoot":"","sources":["../../src/core/hooksSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,MAAM,MAAM,WAAW,GACnB,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,eAAe,GACf,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,WAAW,CAAC;IAClB,uEAAuE;IACvE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uCAAuC;IACvC,OAA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
+
* Hooks System - Event-driven automation for tool execution
|
|
3
|
+
*
|
|
4
|
+
* Implements a Claude Code-style hooks system that runs shell commands
|
|
5
|
+
* in response to tool execution events:
|
|
6
|
+
*
|
|
7
|
+
* - beforeToolExecution: Runs before any tool starts
|
|
8
|
+
* - afterToolExecution: Runs after any tool completes
|
|
9
|
+
* - beforeFileEdit: Runs before a file is modified
|
|
10
|
+
* - afterFileEdit: Runs after a file is modified
|
|
11
|
+
* - beforeBashCommand: Runs before a bash command executes
|
|
12
|
+
* - afterBashCommand: Runs after a bash command completes
|
|
13
|
+
*
|
|
14
|
+
* Hooks are configured in EROSOLAR.md or settings.json
|
|
15
|
+
*/
|
|
16
|
+
import { exec } from 'node:child_process';
|
|
17
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { homedir } from 'node:os';
|
|
20
|
+
import { promisify } from 'node:util';
|
|
21
|
+
const execAsync = promisify(exec);
|
|
22
|
+
const DEFAULT_HOOK_TIMEOUT = 30000; // 30 seconds
|
|
23
|
+
/**
|
|
24
|
+
* Load hooks from EROSOLAR.md or settings.json
|
|
25
|
+
*/
|
|
26
|
+
export function loadHooks(workingDir) {
|
|
27
|
+
const configs = loadHooksConfigs(workingDir);
|
|
28
|
+
return configs.flatMap((c) => c.hooks);
|
|
29
|
+
}
|
|
30
|
+
function loadHooksConfigs(workingDir) {
|
|
31
|
+
const configs = [];
|
|
32
|
+
// 1. User-level hooks from ~/.erosolar/hooks.json
|
|
33
|
+
const userHooksPath = join(homedir(), '.erosolar', 'hooks.json');
|
|
34
|
+
if (existsSync(userHooksPath)) {
|
|
35
|
+
const hooks = tryLoadHooksJson(userHooksPath);
|
|
36
|
+
if (hooks.length > 0) {
|
|
37
|
+
configs.push({ hooks, source: userHooksPath });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// 2. Project-level hooks from .erosolar/hooks.json
|
|
41
|
+
const projectHooksPath = join(workingDir, '.erosolar', 'hooks.json');
|
|
42
|
+
if (existsSync(projectHooksPath)) {
|
|
43
|
+
const hooks = tryLoadHooksJson(projectHooksPath);
|
|
44
|
+
if (hooks.length > 0) {
|
|
45
|
+
configs.push({ hooks, source: projectHooksPath });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// 3. Parse hooks from EROSOLAR.md YAML frontmatter
|
|
49
|
+
const memoryPaths = [
|
|
50
|
+
join(workingDir, 'EROSOLAR.md'),
|
|
51
|
+
join(workingDir, '.erosolar', 'EROSOLAR.md'),
|
|
52
|
+
];
|
|
53
|
+
for (const memoryPath of memoryPaths) {
|
|
54
|
+
if (existsSync(memoryPath)) {
|
|
55
|
+
const hooks = tryParseHooksFromMarkdown(memoryPath);
|
|
56
|
+
if (hooks.length > 0) {
|
|
57
|
+
configs.push({ hooks, source: memoryPath });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return configs;
|
|
62
|
+
}
|
|
63
|
+
function tryLoadHooksJson(filePath) {
|
|
64
|
+
try {
|
|
65
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
66
|
+
const parsed = JSON.parse(content);
|
|
67
|
+
if (Array.isArray(parsed)) {
|
|
68
|
+
return parsed.filter(isValidHook);
|
|
69
|
+
}
|
|
70
|
+
if (parsed.hooks && Array.isArray(parsed.hooks)) {
|
|
71
|
+
return parsed.hooks.filter(isValidHook);
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function tryParseHooksFromMarkdown(filePath) {
|
|
80
|
+
try {
|
|
81
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
82
|
+
// Look for hooks in YAML-like format within the markdown
|
|
83
|
+
const hooksMatch = content.match(/```(?:yaml|yml)?\nhooks:\s*\n([\s\S]*?)```/);
|
|
84
|
+
if (!hooksMatch) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
// Simple YAML-like parsing for hooks
|
|
88
|
+
const hooksYaml = hooksMatch[1] ?? '';
|
|
89
|
+
const hooks = [];
|
|
90
|
+
let currentHook = null;
|
|
91
|
+
let inThenBlock = false;
|
|
92
|
+
const thenCommands = [];
|
|
93
|
+
for (const line of hooksYaml.split('\n')) {
|
|
94
|
+
const trimmed = line.trim();
|
|
95
|
+
if (trimmed.startsWith('- when:')) {
|
|
96
|
+
// Save previous hook
|
|
97
|
+
if (currentHook && currentHook.when) {
|
|
98
|
+
if (thenCommands.length > 0) {
|
|
99
|
+
currentHook.then = [...thenCommands];
|
|
100
|
+
}
|
|
101
|
+
if (currentHook.then && currentHook.then.length > 0) {
|
|
102
|
+
hooks.push(currentHook);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Start new hook
|
|
106
|
+
const whenValue = trimmed.replace('- when:', '').trim().replace(/['"]/g, '');
|
|
107
|
+
currentHook = { when: whenValue };
|
|
108
|
+
thenCommands.length = 0;
|
|
109
|
+
inThenBlock = false;
|
|
110
|
+
}
|
|
111
|
+
else if (trimmed.startsWith('if:') && currentHook) {
|
|
112
|
+
currentHook.if = trimmed.replace('if:', '').trim().replace(/['"]/g, '');
|
|
113
|
+
}
|
|
114
|
+
else if (trimmed.startsWith('then:')) {
|
|
115
|
+
inThenBlock = true;
|
|
116
|
+
}
|
|
117
|
+
else if (inThenBlock && trimmed.startsWith('- ')) {
|
|
118
|
+
const cmd = trimmed.slice(2).replace(/['"]/g, '');
|
|
119
|
+
thenCommands.push(cmd);
|
|
120
|
+
}
|
|
121
|
+
else if (trimmed.startsWith('timeout:') && currentHook) {
|
|
122
|
+
const timeout = parseInt(trimmed.replace('timeout:', '').trim(), 10);
|
|
123
|
+
if (!isNaN(timeout)) {
|
|
124
|
+
currentHook.timeout = timeout;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Save last hook
|
|
129
|
+
if (currentHook && currentHook.when) {
|
|
130
|
+
if (thenCommands.length > 0) {
|
|
131
|
+
currentHook.then = [...thenCommands];
|
|
132
|
+
}
|
|
133
|
+
if (currentHook.then && currentHook.then.length > 0) {
|
|
134
|
+
hooks.push(currentHook);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return hooks;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function isValidHook(hook) {
|
|
144
|
+
if (!hook || typeof hook !== 'object') {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const h = hook;
|
|
148
|
+
const when = h['when'];
|
|
149
|
+
const then = h['then'];
|
|
150
|
+
return (typeof when === 'string' &&
|
|
151
|
+
Array.isArray(then) &&
|
|
152
|
+
then.length > 0 &&
|
|
153
|
+
then.every((cmd) => typeof cmd === 'string'));
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Match a condition against context
|
|
157
|
+
*/
|
|
158
|
+
function matchCondition(condition, context) {
|
|
159
|
+
if (!condition) {
|
|
160
|
+
return true; // No condition means always match
|
|
161
|
+
}
|
|
162
|
+
// Match tool name
|
|
163
|
+
if (context.tool && context.tool.toLowerCase().includes(condition.toLowerCase())) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
// Match file pattern (simple glob)
|
|
167
|
+
if (context.file) {
|
|
168
|
+
if (condition.includes('*')) {
|
|
169
|
+
const regex = new RegExp('^' + condition.replace(/\./g, '\\.').replace(/\*\*/g, '.*').replace(/\*/g, '[^/]*') + '$');
|
|
170
|
+
return regex.test(context.file);
|
|
171
|
+
}
|
|
172
|
+
return context.file.includes(condition);
|
|
173
|
+
}
|
|
174
|
+
// Match command pattern
|
|
175
|
+
if (context.command && context.command.includes(condition)) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Execute a hook's commands
|
|
182
|
+
*/
|
|
183
|
+
async function executeHookCommands(hook, context) {
|
|
184
|
+
const output = [];
|
|
185
|
+
const errors = [];
|
|
186
|
+
let abort = false;
|
|
187
|
+
const timeout = hook.timeout ?? DEFAULT_HOOK_TIMEOUT;
|
|
188
|
+
for (const command of hook.then) {
|
|
189
|
+
// Handle special commands
|
|
190
|
+
if (command.toLowerCase() === 'abort') {
|
|
191
|
+
abort = true;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (command.toLowerCase().startsWith('message:')) {
|
|
195
|
+
output.push(command.slice(8).trim());
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
// Execute shell command
|
|
199
|
+
try {
|
|
200
|
+
const controller = new AbortController();
|
|
201
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
202
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
203
|
+
cwd: context.workingDir,
|
|
204
|
+
timeout,
|
|
205
|
+
signal: controller.signal,
|
|
206
|
+
env: {
|
|
207
|
+
...process.env,
|
|
208
|
+
EROSOLAR_TOOL: context.tool ?? '',
|
|
209
|
+
EROSOLAR_FILE: context.file ?? '',
|
|
210
|
+
EROSOLAR_COMMAND: context.command ?? '',
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
clearTimeout(timeoutId);
|
|
214
|
+
if (stdout.trim()) {
|
|
215
|
+
output.push(stdout.trim());
|
|
216
|
+
}
|
|
217
|
+
if (stderr.trim()) {
|
|
218
|
+
errors.push(stderr.trim());
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
223
|
+
errors.push(`Hook command failed: ${command}\n${errMsg}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { output, errors, abort };
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Run hooks for a specific trigger
|
|
230
|
+
*/
|
|
231
|
+
export async function runHooks(trigger, context, hooks) {
|
|
232
|
+
const allHooks = hooks ?? loadHooks(context.workingDir);
|
|
233
|
+
const matchingHooks = allHooks.filter((hook) => hook.when === trigger && matchCondition(hook.if, context));
|
|
234
|
+
if (matchingHooks.length === 0) {
|
|
235
|
+
return { triggered: false, output: [], errors: [], abort: false };
|
|
236
|
+
}
|
|
237
|
+
const result = {
|
|
238
|
+
triggered: true,
|
|
239
|
+
output: [],
|
|
240
|
+
errors: [],
|
|
241
|
+
abort: false,
|
|
242
|
+
};
|
|
243
|
+
for (const hook of matchingHooks) {
|
|
244
|
+
const { output, errors, abort } = await executeHookCommands(hook, context);
|
|
245
|
+
result.output.push(...output);
|
|
246
|
+
result.errors.push(...errors);
|
|
247
|
+
if (abort) {
|
|
248
|
+
result.abort = true;
|
|
249
|
+
break; // Stop processing if abort is requested
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Create a hooks runner bound to a specific working directory
|
|
256
|
+
*/
|
|
257
|
+
export function createHooksRunner(workingDir) {
|
|
258
|
+
let cachedHooks = null;
|
|
259
|
+
const getHooks = () => {
|
|
260
|
+
if (cachedHooks === null) {
|
|
261
|
+
cachedHooks = loadHooks(workingDir);
|
|
262
|
+
}
|
|
263
|
+
return cachedHooks;
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
runBefore: (trigger, context) => runHooks(trigger, { ...context, workingDir }, getHooks()),
|
|
267
|
+
runAfter: (trigger, context) => runHooks(trigger, { ...context, workingDir }, getHooks()),
|
|
268
|
+
reload: () => {
|
|
269
|
+
cachedHooks = null;
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=hooksSystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooksSystem.js","sourceRoot":"","sources":["../../src/core/hooksSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAsB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O,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAC9B,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC3D,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAC7B,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC3D,MAAM,EAAE,GAAG,EAAE;YACX,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory System - Hierarchical persistent memory for AI context
|
|
3
|
+
*
|
|
4
|
+
* Implements a Claude Code-style memory system that loads persistent context
|
|
5
|
+
* from markdown files at multiple levels:
|
|
6
|
+
*
|
|
7
|
+
* 1. Enterprise Policy: /etc/erosolar/EROSOLAR.md (Linux), managed settings
|
|
8
|
+
* 2. User Memory: ~/.erosolar/EROSOLAR.md
|
|
9
|
+
* 3. Project Memory: ./EROSOLAR.md or ./.erosolar/EROSOLAR.md
|
|
10
|
+
*
|
|
11
|
+
* Supports @imports for including external files recursively (max 5 levels).
|
|
12
|
+
*/
|
|
13
|
+
interface MemorySource {
|
|
14
|
+
level: 'enterprise' | 'user' | 'project' | 'local';
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LoadedMemory {
|
|
19
|
+
sources: MemorySource[];
|
|
20
|
+
combinedContent: string;
|
|
21
|
+
importedPaths: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Load all memory from the hierarchy
|
|
25
|
+
*/
|
|
26
|
+
export declare function loadMemory(workingDir: string): LoadedMemory;
|
|
27
|
+
/**
|
|
28
|
+
* Get memory content formatted for system prompt injection
|
|
29
|
+
*/
|
|
30
|
+
export declare function getMemoryForPrompt(workingDir: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* List all memory file paths and their status
|
|
33
|
+
*/
|
|
34
|
+
export declare function listMemoryPaths(workingDir: string): Array<{
|
|
35
|
+
level: string;
|
|
36
|
+
path: string;
|
|
37
|
+
exists: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the default path for creating a new project memory file
|
|
41
|
+
*/
|
|
42
|
+
export declare function getDefaultProjectMemoryPath(workingDir: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get the user memory path for editing
|
|
45
|
+
*/
|
|
46
|
+
export declare function getUserMemoryEditPath(): string;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=memorySystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memorySystem.d.ts","sourceRoot":"","sources":["../../src/core/memorySystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,UAAU,YAAY;IACpB,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAmKD;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CA6D3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAc7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC,CAmCD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C"}
|