agentmesh-ai 0.1.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 +247 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +134 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/memory.d.ts +8 -0
- package/dist/cli/commands/memory.d.ts.map +1 -0
- package/dist/cli/commands/memory.js +40 -0
- package/dist/cli/commands/memory.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +8 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +90 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +117 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +66 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +50 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/conversation/client.d.ts +72 -0
- package/dist/conversation/client.d.ts.map +1 -0
- package/dist/conversation/client.js +245 -0
- package/dist/conversation/client.js.map +1 -0
- package/dist/conversation/index.d.ts +7 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +4 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/protocol.d.ts +217 -0
- package/dist/conversation/protocol.d.ts.map +1 -0
- package/dist/conversation/protocol.js +7 -0
- package/dist/conversation/protocol.js.map +1 -0
- package/dist/conversation/recorder.d.ts +4 -0
- package/dist/conversation/recorder.d.ts.map +1 -0
- package/dist/conversation/recorder.js +60 -0
- package/dist/conversation/recorder.js.map +1 -0
- package/dist/conversation/server.d.ts +59 -0
- package/dist/conversation/server.d.ts.map +1 -0
- package/dist/conversation/server.js +529 -0
- package/dist/conversation/server.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/claude-md.d.ts +2 -0
- package/dist/integrations/claude-md.d.ts.map +1 -0
- package/dist/integrations/claude-md.js +35 -0
- package/dist/integrations/claude-md.js.map +1 -0
- package/dist/integrations/copilot.d.ts +2 -0
- package/dist/integrations/copilot.d.ts.map +1 -0
- package/dist/integrations/copilot.js +39 -0
- package/dist/integrations/copilot.js.map +1 -0
- package/dist/integrations/detect.d.ts +9 -0
- package/dist/integrations/detect.d.ts.map +1 -0
- package/dist/integrations/detect.js +34 -0
- package/dist/integrations/detect.js.map +1 -0
- package/dist/mcp/conversation-tools.d.ts +4 -0
- package/dist/mcp/conversation-tools.d.ts.map +1 -0
- package/dist/mcp/conversation-tools.js +540 -0
- package/dist/mcp/conversation-tools.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +86 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/memory-tools.d.ts +4 -0
- package/dist/mcp/memory-tools.d.ts.map +1 -0
- package/dist/mcp/memory-tools.js +195 -0
- package/dist/mcp/memory-tools.js.map +1 -0
- package/dist/mcp/resources.d.ts +3 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +23 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +6 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/merge-view.d.ts +9 -0
- package/dist/memory/merge-view.d.ts.map +1 -0
- package/dist/memory/merge-view.js +88 -0
- package/dist/memory/merge-view.js.map +1 -0
- package/dist/memory/reader.d.ts +8 -0
- package/dist/memory/reader.d.ts.map +1 -0
- package/dist/memory/reader.js +53 -0
- package/dist/memory/reader.js.map +1 -0
- package/dist/memory/schema.d.ts +154 -0
- package/dist/memory/schema.d.ts.map +1 -0
- package/dist/memory/schema.js +34 -0
- package/dist/memory/schema.js.map +1 -0
- package/dist/memory/searcher.d.ts +7 -0
- package/dist/memory/searcher.d.ts.map +1 -0
- package/dist/memory/searcher.js +49 -0
- package/dist/memory/searcher.js.map +1 -0
- package/dist/memory/secret-scanner.d.ts +21 -0
- package/dist/memory/secret-scanner.d.ts.map +1 -0
- package/dist/memory/secret-scanner.js +54 -0
- package/dist/memory/secret-scanner.js.map +1 -0
- package/dist/memory/types.d.ts +71 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +5 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/writer.d.ts +4 -0
- package/dist/memory/writer.d.ts.map +1 -0
- package/dist/memory/writer.js +114 -0
- package/dist/memory/writer.js.map +1 -0
- package/dist/utils/git.d.ts +7 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +46 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/id.d.ts +6 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +20 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/yaml.d.ts +7 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +50 -0
- package/dist/utils/yaml.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for validating AgentHub data structures.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export declare const memoryEntrySchema: z.ZodObject<{
|
|
6
|
+
topic: z.ZodString;
|
|
7
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
content: z.ZodString;
|
|
9
|
+
date: z.ZodString;
|
|
10
|
+
decided_with: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
status: z.ZodOptional<z.ZodEnum<["auto", "proposal", "protected"]>>;
|
|
12
|
+
protected: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
topic: string;
|
|
16
|
+
tags: string[];
|
|
17
|
+
content: string;
|
|
18
|
+
date: string;
|
|
19
|
+
status?: "auto" | "proposal" | "protected" | undefined;
|
|
20
|
+
decided_with?: string[] | undefined;
|
|
21
|
+
protected?: boolean | undefined;
|
|
22
|
+
owner?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
topic: string;
|
|
25
|
+
content: string;
|
|
26
|
+
date: string;
|
|
27
|
+
status?: "auto" | "proposal" | "protected" | undefined;
|
|
28
|
+
tags?: string[] | undefined;
|
|
29
|
+
decided_with?: string[] | undefined;
|
|
30
|
+
protected?: boolean | undefined;
|
|
31
|
+
owner?: string | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const agentMemoryFileSchema: z.ZodObject<{
|
|
34
|
+
agent: z.ZodString;
|
|
35
|
+
role: z.ZodString;
|
|
36
|
+
tool: z.ZodString;
|
|
37
|
+
last_active: z.ZodString;
|
|
38
|
+
entries: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
39
|
+
topic: z.ZodString;
|
|
40
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
content: z.ZodString;
|
|
42
|
+
date: z.ZodString;
|
|
43
|
+
decided_with: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
44
|
+
status: z.ZodOptional<z.ZodEnum<["auto", "proposal", "protected"]>>;
|
|
45
|
+
protected: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
topic: string;
|
|
49
|
+
tags: string[];
|
|
50
|
+
content: string;
|
|
51
|
+
date: string;
|
|
52
|
+
status?: "auto" | "proposal" | "protected" | undefined;
|
|
53
|
+
decided_with?: string[] | undefined;
|
|
54
|
+
protected?: boolean | undefined;
|
|
55
|
+
owner?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
topic: string;
|
|
58
|
+
content: string;
|
|
59
|
+
date: string;
|
|
60
|
+
status?: "auto" | "proposal" | "protected" | undefined;
|
|
61
|
+
tags?: string[] | undefined;
|
|
62
|
+
decided_with?: string[] | undefined;
|
|
63
|
+
protected?: boolean | undefined;
|
|
64
|
+
owner?: string | undefined;
|
|
65
|
+
}>, "many">>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
entries: {
|
|
68
|
+
topic: string;
|
|
69
|
+
tags: string[];
|
|
70
|
+
content: string;
|
|
71
|
+
date: string;
|
|
72
|
+
status?: "auto" | "proposal" | "protected" | undefined;
|
|
73
|
+
decided_with?: string[] | undefined;
|
|
74
|
+
protected?: boolean | undefined;
|
|
75
|
+
owner?: string | undefined;
|
|
76
|
+
}[];
|
|
77
|
+
agent: string;
|
|
78
|
+
role: string;
|
|
79
|
+
tool: string;
|
|
80
|
+
last_active: string;
|
|
81
|
+
}, {
|
|
82
|
+
agent: string;
|
|
83
|
+
role: string;
|
|
84
|
+
tool: string;
|
|
85
|
+
last_active: string;
|
|
86
|
+
entries?: {
|
|
87
|
+
topic: string;
|
|
88
|
+
content: string;
|
|
89
|
+
date: string;
|
|
90
|
+
status?: "auto" | "proposal" | "protected" | undefined;
|
|
91
|
+
tags?: string[] | undefined;
|
|
92
|
+
decided_with?: string[] | undefined;
|
|
93
|
+
protected?: boolean | undefined;
|
|
94
|
+
owner?: string | undefined;
|
|
95
|
+
}[] | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
export declare const agentInfoSchema: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
display_name: z.ZodString;
|
|
100
|
+
role: z.ZodString;
|
|
101
|
+
tool: z.ZodString;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
role: string;
|
|
104
|
+
tool: string;
|
|
105
|
+
id: string;
|
|
106
|
+
display_name: string;
|
|
107
|
+
}, {
|
|
108
|
+
role: string;
|
|
109
|
+
tool: string;
|
|
110
|
+
id: string;
|
|
111
|
+
display_name: string;
|
|
112
|
+
}>;
|
|
113
|
+
export declare const hubConfigSchema: z.ZodObject<{
|
|
114
|
+
project: z.ZodString;
|
|
115
|
+
created: z.ZodString;
|
|
116
|
+
version: z.ZodDefault<z.ZodString>;
|
|
117
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
118
|
+
id: z.ZodString;
|
|
119
|
+
display_name: z.ZodString;
|
|
120
|
+
role: z.ZodString;
|
|
121
|
+
tool: z.ZodString;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
role: string;
|
|
124
|
+
tool: string;
|
|
125
|
+
id: string;
|
|
126
|
+
display_name: string;
|
|
127
|
+
}, {
|
|
128
|
+
role: string;
|
|
129
|
+
tool: string;
|
|
130
|
+
id: string;
|
|
131
|
+
display_name: string;
|
|
132
|
+
}>, "many">>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
project: string;
|
|
135
|
+
created: string;
|
|
136
|
+
version: string;
|
|
137
|
+
agents: {
|
|
138
|
+
role: string;
|
|
139
|
+
tool: string;
|
|
140
|
+
id: string;
|
|
141
|
+
display_name: string;
|
|
142
|
+
}[];
|
|
143
|
+
}, {
|
|
144
|
+
project: string;
|
|
145
|
+
created: string;
|
|
146
|
+
version?: string | undefined;
|
|
147
|
+
agents?: {
|
|
148
|
+
role: string;
|
|
149
|
+
tool: string;
|
|
150
|
+
id: string;
|
|
151
|
+
display_name: string;
|
|
152
|
+
}[] | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/memory/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAK1B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for validating AgentHub data structures.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export const memoryEntrySchema = z.object({
|
|
6
|
+
topic: z.string().min(1),
|
|
7
|
+
tags: z.array(z.string()).default([]),
|
|
8
|
+
content: z.string().min(1),
|
|
9
|
+
date: z.string(),
|
|
10
|
+
decided_with: z.array(z.string()).optional(),
|
|
11
|
+
status: z.enum(['auto', 'proposal', 'protected']).optional(),
|
|
12
|
+
protected: z.boolean().optional(), // backward compat
|
|
13
|
+
owner: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
export const agentMemoryFileSchema = z.object({
|
|
16
|
+
agent: z.string().min(1),
|
|
17
|
+
role: z.string().min(1),
|
|
18
|
+
tool: z.string().min(1),
|
|
19
|
+
last_active: z.string(),
|
|
20
|
+
entries: z.array(memoryEntrySchema).default([]),
|
|
21
|
+
});
|
|
22
|
+
export const agentInfoSchema = z.object({
|
|
23
|
+
id: z.string().min(1),
|
|
24
|
+
display_name: z.string().min(1),
|
|
25
|
+
role: z.string().min(1),
|
|
26
|
+
tool: z.string().min(1),
|
|
27
|
+
});
|
|
28
|
+
export const hubConfigSchema = z.object({
|
|
29
|
+
project: z.string().min(1),
|
|
30
|
+
created: z.string(),
|
|
31
|
+
version: z.string().default('1.0'),
|
|
32
|
+
agents: z.array(agentInfoSchema).default([]),
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/memory/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC5C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5D,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,kBAAkB;IACrD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC7C,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory searcher - search across all agent memories by keyword or tags.
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentMemoryFile, MergedMemoryEntry } from './types.js';
|
|
5
|
+
/** Search all memories for entries matching the query string. */
|
|
6
|
+
export declare function searchMemories(memories: AgentMemoryFile[], query: string): MergedMemoryEntry[];
|
|
7
|
+
//# sourceMappingURL=searcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searcher.d.ts","sourceRoot":"","sources":["../../src/memory/searcher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE,iEAAiE;AACjE,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,iBAAiB,EAAE,CAyBrB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Search all memories for entries matching the query string. */
|
|
2
|
+
export function searchMemories(memories, query) {
|
|
3
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
4
|
+
const results = [];
|
|
5
|
+
for (const memory of memories) {
|
|
6
|
+
for (const entry of memory.entries) {
|
|
7
|
+
const score = calculateRelevance(entry, memory, terms);
|
|
8
|
+
if (score > 0) {
|
|
9
|
+
results.push({
|
|
10
|
+
entry: {
|
|
11
|
+
...entry,
|
|
12
|
+
agent: memory.agent,
|
|
13
|
+
agent_role: memory.role,
|
|
14
|
+
},
|
|
15
|
+
score,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Sort by relevance score, highest first
|
|
21
|
+
results.sort((a, b) => b.score - a.score);
|
|
22
|
+
return results.map(r => r.entry);
|
|
23
|
+
}
|
|
24
|
+
function calculateRelevance(entry, memory, terms) {
|
|
25
|
+
let score = 0;
|
|
26
|
+
const topicLower = entry.topic.toLowerCase();
|
|
27
|
+
const contentLower = entry.content.toLowerCase();
|
|
28
|
+
const tagsLower = entry.tags.map(t => t.toLowerCase());
|
|
29
|
+
const agentLower = memory.agent.toLowerCase();
|
|
30
|
+
for (const term of terms) {
|
|
31
|
+
// Topic match (highest weight)
|
|
32
|
+
if (topicLower.includes(term))
|
|
33
|
+
score += 10;
|
|
34
|
+
// Tag exact match (high weight)
|
|
35
|
+
if (tagsLower.includes(term))
|
|
36
|
+
score += 8;
|
|
37
|
+
// Agent name match
|
|
38
|
+
if (agentLower.includes(term))
|
|
39
|
+
score += 3;
|
|
40
|
+
// Content match (lower weight, but still relevant)
|
|
41
|
+
if (contentLower.includes(term))
|
|
42
|
+
score += 2;
|
|
43
|
+
// Tag partial match
|
|
44
|
+
if (tagsLower.some(t => t.includes(term)))
|
|
45
|
+
score += 4;
|
|
46
|
+
}
|
|
47
|
+
return score;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=searcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searcher.js","sourceRoot":"","sources":["../../src/memory/searcher.ts"],"names":[],"mappings":"AAKA,iEAAiE;AACjE,MAAM,UAAU,cAAc,CAC5B,QAA2B,EAC3B,KAAa;IAEb,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE/D,MAAM,OAAO,GAAuD,EAAE,CAAC;IAEvE,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;YACvD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK,EAAE;wBACL,GAAG,KAAK;wBACR,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,UAAU,EAAE,MAAM,CAAC,IAAI;qBACxB;oBACD,KAAK;iBACN,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,yCAAyC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK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enters shared memory.
|
|
3
|
+
*
|
|
4
|
+
* Prevents API keys, passwords, private keys, and internal URLs from being
|
|
5
|
+
* accidentally shared across the team via .agenthub/ files.
|
|
6
|
+
*/
|
|
7
|
+
export interface ScanResult {
|
|
8
|
+
safe: boolean;
|
|
9
|
+
blocked: boolean;
|
|
10
|
+
warnings: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Scan text content for sensitive information.
|
|
14
|
+
*
|
|
15
|
+
* @returns ScanResult with:
|
|
16
|
+
* - safe: true if no issues found
|
|
17
|
+
* - blocked: true if high-severity secrets found (should prevent write)
|
|
18
|
+
* - warnings: list of human-readable warnings
|
|
19
|
+
*/
|
|
20
|
+
export declare function scanForSecrets(content: string): ScanResult;
|
|
21
|
+
//# sourceMappingURL=secret-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-scanner.d.ts","sourceRoot":"","sources":["../../src/memory/secret-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAiCD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAmB1D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret scanner — detects sensitive information before it enters shared memory.
|
|
3
|
+
*
|
|
4
|
+
* Prevents API keys, passwords, private keys, and internal URLs from being
|
|
5
|
+
* accidentally shared across the team via .agenthub/ files.
|
|
6
|
+
*/
|
|
7
|
+
const PATTERNS = [
|
|
8
|
+
// API keys — high severity (direct credential exposure)
|
|
9
|
+
{ name: 'OpenAI API key', regex: /sk-[a-zA-Z0-9]{20,}/, severity: 'high' },
|
|
10
|
+
{ name: 'Anthropic API key', regex: /sk-ant-[a-zA-Z0-9-]{20,}/, severity: 'high' },
|
|
11
|
+
{ name: 'AWS Access Key', regex: /AKIA[0-9A-Z]{16}/, severity: 'high' },
|
|
12
|
+
{ name: 'GitHub token', regex: /gh[ps]_[a-zA-Z0-9]{36,}/, severity: 'high' },
|
|
13
|
+
{ name: 'GitHub PAT', regex: /github_pat_[a-zA-Z0-9_]{20,}/, severity: 'high' },
|
|
14
|
+
{ name: 'Stripe key', regex: /sk_live_[a-zA-Z0-9]{20,}/, severity: 'high' },
|
|
15
|
+
{ name: 'Stripe key', regex: /sk_test_[a-zA-Z0-9]{20,}/, severity: 'high' },
|
|
16
|
+
{ name: 'Private key', regex: /-----BEGIN\s+(RSA\s+|EC\s+|DSA\s+|OPENSSH\s+)?PRIVATE KEY-----/, severity: 'high' },
|
|
17
|
+
{ name: 'Generic secret assignment', regex: /(?:password|passwd|secret|api_key|apikey|access_token|auth_token)\s*[=:]\s*['"][^'"]{8,}['"]/i, severity: 'high' },
|
|
18
|
+
// Internal URLs — medium severity (information leakage)
|
|
19
|
+
{ name: 'Localhost URL', regex: /https?:\/\/localhost[:/]/, severity: 'medium' },
|
|
20
|
+
{ name: 'Internal IP (127.x)', regex: /https?:\/\/127\.0\.0\.\d+[:/]/, severity: 'medium' },
|
|
21
|
+
{ name: 'Internal IP (192.168.x)', regex: /https?:\/\/192\.168\.\d+\.\d+[:/]/, severity: 'medium' },
|
|
22
|
+
{ name: 'Internal IP (10.x)', regex: /https?:\/\/10\.\d+\.\d+\.\d+[:/]/, severity: 'medium' },
|
|
23
|
+
// Connection strings — high severity
|
|
24
|
+
{ name: 'Database connection string', regex: /(?:mongodb|postgres|mysql|redis):\/\/[^\s]+:[^\s]+@/, severity: 'high' },
|
|
25
|
+
// Bearer tokens — high severity
|
|
26
|
+
{ name: 'Bearer token', regex: /Bearer\s+[a-zA-Z0-9._\-]{20,}/, severity: 'high' },
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Scan text content for sensitive information.
|
|
30
|
+
*
|
|
31
|
+
* @returns ScanResult with:
|
|
32
|
+
* - safe: true if no issues found
|
|
33
|
+
* - blocked: true if high-severity secrets found (should prevent write)
|
|
34
|
+
* - warnings: list of human-readable warnings
|
|
35
|
+
*/
|
|
36
|
+
export function scanForSecrets(content) {
|
|
37
|
+
const warnings = [];
|
|
38
|
+
let hasHighSeverity = false;
|
|
39
|
+
for (const pattern of PATTERNS) {
|
|
40
|
+
if (pattern.regex.test(content)) {
|
|
41
|
+
const severity = pattern.severity === 'high' ? '🔴' : '🟡';
|
|
42
|
+
warnings.push(`${severity} ${pattern.name} detected (${pattern.severity} risk)`);
|
|
43
|
+
if (pattern.severity === 'high') {
|
|
44
|
+
hasHighSeverity = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
safe: warnings.length === 0,
|
|
50
|
+
blocked: hasHighSeverity,
|
|
51
|
+
warnings,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=secret-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-scanner.js","sourceRoot":"","sources":["../../src/memory/secret-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,MAAM,QAAQ,GAAc;IAC1B,wDAAwD;IACxD,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,EAAE;IAC1E,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE;IAClF,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE;IACvE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,EAAE;IAC5E,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,8BAA8B,EAAE,QAAQ,EA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C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3D,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,IAAI,OAAO,CAAC,IAAI,cAAc,OAAO,CAAC,QAAQ,QAAQ,CAAC,CAAC;YACjF,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;gBAChC,eAAe,GAAG,IAAI,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;QAC3B,OAAO,EAAE,eAAe;QACxB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core data types for AgentHub shared memory.
|
|
3
|
+
*/
|
|
4
|
+
/** Memory entry status levels */
|
|
5
|
+
export type MemoryStatus = 'auto' | 'proposal' | 'protected';
|
|
6
|
+
/** A single knowledge entry recorded by an agent */
|
|
7
|
+
export interface MemoryEntry {
|
|
8
|
+
topic: string;
|
|
9
|
+
tags: string[];
|
|
10
|
+
content: string;
|
|
11
|
+
date: string;
|
|
12
|
+
decided_with?: string[];
|
|
13
|
+
status?: MemoryStatus;
|
|
14
|
+
protected?: boolean;
|
|
15
|
+
owner?: string;
|
|
16
|
+
}
|
|
17
|
+
/** An agent's complete memory file */
|
|
18
|
+
export interface AgentMemoryFile {
|
|
19
|
+
agent: string;
|
|
20
|
+
role: string;
|
|
21
|
+
tool: string;
|
|
22
|
+
last_active: string;
|
|
23
|
+
entries: MemoryEntry[];
|
|
24
|
+
}
|
|
25
|
+
/** An agent registered in hub.yaml */
|
|
26
|
+
export interface AgentInfo {
|
|
27
|
+
id: string;
|
|
28
|
+
display_name: string;
|
|
29
|
+
role: string;
|
|
30
|
+
tool: string;
|
|
31
|
+
}
|
|
32
|
+
/** The hub.yaml project metadata */
|
|
33
|
+
export interface HubConfig {
|
|
34
|
+
project: string;
|
|
35
|
+
created: string;
|
|
36
|
+
version: string;
|
|
37
|
+
agents: AgentInfo[];
|
|
38
|
+
}
|
|
39
|
+
/** A memory entry with its source agent attached (used in merged views) */
|
|
40
|
+
export interface MergedMemoryEntry extends MemoryEntry {
|
|
41
|
+
agent: string;
|
|
42
|
+
agent_role: string;
|
|
43
|
+
}
|
|
44
|
+
/** Options for reading memory */
|
|
45
|
+
export interface ReadMemoryOptions {
|
|
46
|
+
tags?: string[];
|
|
47
|
+
agent?: string;
|
|
48
|
+
limit?: number;
|
|
49
|
+
}
|
|
50
|
+
/** Options for writing memory */
|
|
51
|
+
export interface WriteMemoryOptions {
|
|
52
|
+
topic: string;
|
|
53
|
+
content: string;
|
|
54
|
+
tags: string[];
|
|
55
|
+
decided_with?: string[];
|
|
56
|
+
status?: MemoryStatus;
|
|
57
|
+
protected?: boolean;
|
|
58
|
+
owner?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Result of a write operation */
|
|
61
|
+
export interface WriteResult {
|
|
62
|
+
success: boolean;
|
|
63
|
+
blocked?: boolean;
|
|
64
|
+
reason?: string;
|
|
65
|
+
warnings?: string[];
|
|
66
|
+
}
|
|
67
|
+
/** Options for searching memory */
|
|
68
|
+
export interface SearchMemoryOptions {
|
|
69
|
+
query: string;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;AAE7D,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,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,EAAE,MAAM,CAAC;CAChB;AAED,kCAAkC;AAClC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WriteMemoryOptions, WriteResult } from './types.js';
|
|
2
|
+
/** Write a new memory entry to the current agent's file. */
|
|
3
|
+
export declare function writeMemoryEntry(agentHubDir: string, agentId: string, agentRole: string, agentTool: string, options: WriteMemoryOptions): Promise<WriteResult>;
|
|
4
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/memory/writer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAmB,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnF,4DAA4D;AAC5D,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAmHtB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory writer - appends knowledge entries to an agent's memory file.
|
|
3
|
+
*/
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { readYaml, writeYaml } from '../utils/yaml.js';
|
|
6
|
+
import { agentMemoryFileSchema } from './schema.js';
|
|
7
|
+
import { readAllAgentMemories } from './reader.js';
|
|
8
|
+
import { scanForSecrets } from './secret-scanner.js';
|
|
9
|
+
/** Write a new memory entry to the current agent's file. */
|
|
10
|
+
export async function writeMemoryEntry(agentHubDir, agentId, agentRole, agentTool, options) {
|
|
11
|
+
// Check if this topic is protected or proposed by another agent
|
|
12
|
+
const allMemories = await readAllAgentMemories(agentHubDir);
|
|
13
|
+
let proposalWarning;
|
|
14
|
+
for (const memory of allMemories) {
|
|
15
|
+
if (memory.agent === agentId)
|
|
16
|
+
continue;
|
|
17
|
+
const matchingEntry = memory.entries.find(e => e.topic.toLowerCase() === options.topic.toLowerCase());
|
|
18
|
+
if (!matchingEntry)
|
|
19
|
+
continue;
|
|
20
|
+
// Determine effective status (backward compat: protected=true → status 'protected')
|
|
21
|
+
const effectiveStatus = matchingEntry.status ?? (matchingEntry.protected ? 'protected' : 'auto');
|
|
22
|
+
if (effectiveStatus === 'protected') {
|
|
23
|
+
const owner = matchingEntry.owner ?? memory.agent;
|
|
24
|
+
if (owner !== agentId) {
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
blocked: true,
|
|
28
|
+
reason: `This topic is protected by ${memory.agent}${matchingEntry.owner ? ` (owner: ${matchingEntry.owner})` : ''}. Record your thoughts under a different topic name, e.g. "${options.topic} — ${agentId} notes".`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (effectiveStatus === 'proposal') {
|
|
33
|
+
proposalWarning = `Note: ${memory.agent} has a proposal on "${matchingEntry.topic}". Your entry will coexist, but consider discussing before overriding.`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Scan for sensitive information before writing
|
|
37
|
+
const scanResult = scanForSecrets(options.content);
|
|
38
|
+
if (scanResult.blocked) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
blocked: true,
|
|
42
|
+
reason: `Content contains sensitive information that must not be shared:\n${scanResult.warnings.join('\n')}\n\nRemove the sensitive data and try again.`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const filePath = join(agentHubDir, 'memory', `${agentId}.yaml`);
|
|
46
|
+
// Read existing file or create new one
|
|
47
|
+
let memoryFile;
|
|
48
|
+
const existing = await readYaml(filePath);
|
|
49
|
+
if (existing) {
|
|
50
|
+
const parsed = agentMemoryFileSchema.safeParse(existing);
|
|
51
|
+
if (parsed.success) {
|
|
52
|
+
memoryFile = parsed.data;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
memoryFile = {
|
|
56
|
+
agent: agentId,
|
|
57
|
+
role: agentRole,
|
|
58
|
+
tool: agentTool,
|
|
59
|
+
last_active: new Date().toISOString(),
|
|
60
|
+
entries: [],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
memoryFile = {
|
|
66
|
+
agent: agentId,
|
|
67
|
+
role: agentRole,
|
|
68
|
+
tool: agentTool,
|
|
69
|
+
last_active: new Date().toISOString(),
|
|
70
|
+
entries: [],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const now = new Date().toISOString();
|
|
74
|
+
// Check if there's an existing entry with the same topic - update it
|
|
75
|
+
const existingIndex = memoryFile.entries.findIndex(e => e.topic.toLowerCase() === options.topic.toLowerCase());
|
|
76
|
+
// Resolve status: explicit status > legacy protected flag > default 'auto'
|
|
77
|
+
const resolvedStatus = options.status ?? (options.protected ? 'protected' : 'auto');
|
|
78
|
+
const newEntry = {
|
|
79
|
+
topic: options.topic,
|
|
80
|
+
tags: options.tags,
|
|
81
|
+
content: options.content,
|
|
82
|
+
date: now,
|
|
83
|
+
status: resolvedStatus,
|
|
84
|
+
...(options.decided_with ? { decided_with: options.decided_with } : {}),
|
|
85
|
+
...(resolvedStatus === 'protected' ? { protected: true } : {}), // backward compat
|
|
86
|
+
...(options.owner ? { owner: options.owner } : {}),
|
|
87
|
+
};
|
|
88
|
+
if (existingIndex >= 0) {
|
|
89
|
+
// Preserve status/protected/owner from old entry if not explicitly set
|
|
90
|
+
const oldEntry = memoryFile.entries[existingIndex];
|
|
91
|
+
const oldStatus = oldEntry.status ?? (oldEntry.protected ? 'protected' : 'auto');
|
|
92
|
+
if (!options.status && !options.protected && (oldStatus === 'protected' || oldStatus === 'proposal')) {
|
|
93
|
+
newEntry.status = oldStatus;
|
|
94
|
+
if (oldStatus === 'protected')
|
|
95
|
+
newEntry.protected = true;
|
|
96
|
+
if (oldEntry.owner)
|
|
97
|
+
newEntry.owner = oldEntry.owner;
|
|
98
|
+
}
|
|
99
|
+
memoryFile.entries[existingIndex] = newEntry;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
memoryFile.entries.push(newEntry);
|
|
103
|
+
}
|
|
104
|
+
memoryFile.last_active = now;
|
|
105
|
+
await writeYaml(filePath, memoryFile);
|
|
106
|
+
const allWarnings = [...scanResult.warnings];
|
|
107
|
+
if (proposalWarning)
|
|
108
|
+
allWarnings.push(proposalWarning);
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
...(allWarnings.length > 0 ? { warnings: allWarnings } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../src/memory/writer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,OAAe,EACf,SAAiB,E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C;YAC5B,IAAI,SAAS,KAAK,WAAW;gBAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;YACzD,IAAI,QAAQ,CAAC,KAAK;gBAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QACtD,CAAC;QACD,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,UAAU,CAAC,WAAW,GAAG,GAAG,CAAC;IAE7B,MAAM,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEtC,MAAM,WAAW,GAAG,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,eAAe;QAAE,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAEvD,OAAO;QACL,OAAO,EAAE,IAAI;QACb,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Find the git root directory by walking up from startDir. */
|
|
2
|
+
export declare function findGitRoot(startDir: string): string | null;
|
|
3
|
+
/** Find the .agenthub directory by walking up from startDir. */
|
|
4
|
+
export declare function findAgentHubDir(startDir: string): string | null;
|
|
5
|
+
/** Check if the current directory is inside a git repository. */
|
|
6
|
+
export declare function isGitRepo(dir: string): boolean;
|
|
7
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAOA,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW3D;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqB/D;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE9C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git utilities - detect git root, check status.
|
|
3
|
+
*/
|
|
4
|
+
import { execSync } from 'node:child_process';
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { join, dirname, resolve } from 'node:path';
|
|
7
|
+
/** Find the git root directory by walking up from startDir. */
|
|
8
|
+
export function findGitRoot(startDir) {
|
|
9
|
+
try {
|
|
10
|
+
const result = execSync('git rev-parse --show-toplevel', {
|
|
11
|
+
cwd: startDir,
|
|
12
|
+
encoding: 'utf-8',
|
|
13
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
14
|
+
});
|
|
15
|
+
return result.trim();
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Find the .agenthub directory by walking up from startDir. */
|
|
22
|
+
export function findAgentHubDir(startDir) {
|
|
23
|
+
let dir = resolve(startDir);
|
|
24
|
+
const root = dirname(dir);
|
|
25
|
+
while (dir !== root) {
|
|
26
|
+
const candidate = join(dir, '.agenthub');
|
|
27
|
+
if (existsSync(candidate)) {
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
const parent = dirname(dir);
|
|
31
|
+
if (parent === dir)
|
|
32
|
+
break;
|
|
33
|
+
dir = parent;
|
|
34
|
+
}
|
|
35
|
+
// Check the final root directory
|
|
36
|
+
const candidate = join(dir, '.agenthub');
|
|
37
|
+
if (existsSync(candidate)) {
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/** Check if the current directory is inside a git repository. */
|
|
43
|
+
export function isGitRepo(dir) {
|
|
44
|
+
return findGitRoot(dir) !== null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,+DAA+D;AAC/D,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,+BAA+B,EAAE;YACvD,GAAG,EAAE,QAAQ;YACb,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1B,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAA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