universal-agent-memory 0.4.1 → 0.5.1
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/README.md +106 -289
- package/dist/bin/cli.js +0 -0
- package/dist/cli/generate.d.ts +7 -0
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +89 -2
- package/dist/cli/generate.js.map +1 -1
- package/dist/coordination/capability-router.d.ts +79 -0
- package/dist/coordination/capability-router.d.ts.map +1 -0
- package/dist/coordination/capability-router.js +324 -0
- package/dist/coordination/capability-router.js.map +1 -0
- package/dist/coordination/deploy-batcher.d.ts +64 -1
- package/dist/coordination/deploy-batcher.d.ts.map +1 -1
- package/dist/coordination/deploy-batcher.js +203 -39
- package/dist/coordination/deploy-batcher.js.map +1 -1
- package/dist/coordination/index.d.ts +1 -0
- package/dist/coordination/index.d.ts.map +1 -1
- package/dist/coordination/index.js +1 -0
- package/dist/coordination/index.js.map +1 -1
- package/dist/generators/claude-md.js +18 -5
- package/dist/generators/claude-md.js.map +1 -1
- package/dist/generators/template-loader.d.ts +105 -0
- package/dist/generators/template-loader.d.ts.map +1 -0
- package/dist/generators/template-loader.js +291 -0
- package/dist/generators/template-loader.js.map +1 -0
- package/dist/memory/serverless-qdrant.d.ts +102 -0
- package/dist/memory/serverless-qdrant.d.ts.map +1 -0
- package/dist/memory/serverless-qdrant.js +369 -0
- package/dist/memory/serverless-qdrant.js.map +1 -0
- package/dist/types/config.d.ts +1220 -15
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +92 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/coordination.d.ts +4 -4
- package/dist/utils/merge-claude-md.d.ts +20 -7
- package/dist/utils/merge-claude-md.d.ts.map +1 -1
- package/dist/utils/merge-claude-md.js +252 -59
- package/dist/utils/merge-claude-md.js.map +1 -1
- package/package.json +1 -1
- package/templates/CLAUDE.template.md +286 -837
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;EAEzB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAShC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;EAMpC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AAEH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;EAEzB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAShC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;EAMpC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BjC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY/B,CAAC;AAEH,e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BAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AACrG,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAChD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
package/dist/types/config.js
CHANGED
|
@@ -25,16 +25,54 @@ export const QdrantCloudBackendSchema = z.object({
|
|
|
25
25
|
apiKey: z.string().optional(), // Can also use QDRANT_API_KEY env var
|
|
26
26
|
collection: z.string().default('agent_memory'),
|
|
27
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* NEW: Serverless Qdrant configuration for cost optimization.
|
|
30
|
+
* Supports lazy-start local instance or cloud serverless.
|
|
31
|
+
*/
|
|
32
|
+
export const QdrantServerlessSchema = z.object({
|
|
33
|
+
enabled: z.boolean().default(false),
|
|
34
|
+
mode: z.enum(['lazy-local', 'cloud-serverless', 'hybrid']).default('lazy-local'),
|
|
35
|
+
// Lazy-local settings
|
|
36
|
+
lazyLocal: z.object({
|
|
37
|
+
dockerImage: z.string().default('qdrant/qdrant:latest'),
|
|
38
|
+
port: z.number().default(6333),
|
|
39
|
+
dataDir: z.string().default('./agents/data/qdrant'),
|
|
40
|
+
autoStart: z.boolean().default(true),
|
|
41
|
+
autoStop: z.boolean().default(true),
|
|
42
|
+
idleTimeoutMs: z.number().default(300000), // 5 minutes
|
|
43
|
+
healthCheckIntervalMs: z.number().default(30000), // 30 seconds
|
|
44
|
+
}).optional(),
|
|
45
|
+
// Cloud serverless settings
|
|
46
|
+
cloudServerless: z.object({
|
|
47
|
+
provider: z.enum(['qdrant-cloud', 'aws-lambda', 'cloudflare-workers']).default('qdrant-cloud'),
|
|
48
|
+
url: z.string().optional(),
|
|
49
|
+
apiKey: z.string().optional(),
|
|
50
|
+
region: z.string().default('us-east-1'),
|
|
51
|
+
// Cold start optimization
|
|
52
|
+
keepWarm: z.boolean().default(false),
|
|
53
|
+
warmIntervalMs: z.number().default(240000), // 4 minutes
|
|
54
|
+
}).optional(),
|
|
55
|
+
// Hybrid mode: use local for dev, cloud for prod
|
|
56
|
+
hybrid: z.object({
|
|
57
|
+
useLocalInDev: z.boolean().default(true),
|
|
58
|
+
useCloudInProd: z.boolean().default(true),
|
|
59
|
+
envDetection: z.enum(['NODE_ENV', 'UAM_ENV', 'auto']).default('auto'),
|
|
60
|
+
}).optional(),
|
|
61
|
+
// Fallback to in-memory if all backends fail
|
|
62
|
+
fallbackToMemory: z.boolean().default(true),
|
|
63
|
+
});
|
|
28
64
|
export const LongTermMemorySchema = z.object({
|
|
29
65
|
enabled: z.boolean().default(true),
|
|
30
66
|
// Legacy local provider (keep for backward compatibility)
|
|
31
|
-
provider: z.enum(['qdrant', 'chroma', 'pinecone', 'github', 'qdrant-cloud', 'none']).default('qdrant'),
|
|
67
|
+
provider: z.enum(['qdrant', 'chroma', 'pinecone', 'github', 'qdrant-cloud', 'serverless', 'none']).default('qdrant'),
|
|
32
68
|
endpoint: z.string().optional(),
|
|
33
69
|
collection: z.string().default('agent_memory'),
|
|
34
70
|
embeddingModel: z.string().default('all-MiniLM-L6-v2'),
|
|
35
71
|
// New backend-specific configs
|
|
36
72
|
github: GitHubMemoryBackendSchema.optional(),
|
|
37
73
|
qdrantCloud: QdrantCloudBackendSchema.optional(),
|
|
74
|
+
// NEW: Serverless config
|
|
75
|
+
serverless: QdrantServerlessSchema.optional(),
|
|
38
76
|
});
|
|
39
77
|
export const MemorySchema = z.object({
|
|
40
78
|
shortTerm: ShortTermMemorySchema.optional(),
|
|
@@ -76,6 +114,56 @@ export const ProjectSchema = z.object({
|
|
|
76
114
|
description: z.string().optional(),
|
|
77
115
|
defaultBranch: z.string().default('main'),
|
|
78
116
|
});
|
|
117
|
+
/**
|
|
118
|
+
* NEW: Cost optimization settings.
|
|
119
|
+
*/
|
|
120
|
+
export const CostOptimizationSchema = z.object({
|
|
121
|
+
enabled: z.boolean().default(true),
|
|
122
|
+
// Token budget management
|
|
123
|
+
tokenBudget: z.object({
|
|
124
|
+
maxTemplateTokens: z.number().default(8000),
|
|
125
|
+
maxMemoryQueryTokens: z.number().default(2000),
|
|
126
|
+
maxContextTokens: z.number().default(12000),
|
|
127
|
+
warningThreshold: z.number().default(0.8), // Warn at 80% usage
|
|
128
|
+
}).optional(),
|
|
129
|
+
// Embedding batch optimization
|
|
130
|
+
embeddingBatching: z.object({
|
|
131
|
+
enabled: z.boolean().default(true),
|
|
132
|
+
batchSize: z.number().default(10),
|
|
133
|
+
maxDelayMs: z.number().default(5000),
|
|
134
|
+
}).optional(),
|
|
135
|
+
// LLM call reduction
|
|
136
|
+
llmCallReduction: z.object({
|
|
137
|
+
cacheResponses: z.boolean().default(true),
|
|
138
|
+
cacheTtlMs: z.number().default(3600000), // 1 hour
|
|
139
|
+
deduplicateQueries: z.boolean().default(true),
|
|
140
|
+
}).optional(),
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* NEW: Time optimization settings for deployments.
|
|
144
|
+
*/
|
|
145
|
+
export const TimeOptimizationSchema = z.object({
|
|
146
|
+
enabled: z.boolean().default(true),
|
|
147
|
+
// Dynamic batch windows
|
|
148
|
+
batchWindows: z.object({
|
|
149
|
+
commit: z.number().default(30000),
|
|
150
|
+
push: z.number().default(5000),
|
|
151
|
+
merge: z.number().default(10000),
|
|
152
|
+
workflow: z.number().default(5000),
|
|
153
|
+
deploy: z.number().default(60000),
|
|
154
|
+
}).optional(),
|
|
155
|
+
// Parallel execution
|
|
156
|
+
parallelExecution: z.object({
|
|
157
|
+
enabled: z.boolean().default(true),
|
|
158
|
+
maxParallelDroids: z.number().default(4),
|
|
159
|
+
maxParallelWorkflows: z.number().default(3),
|
|
160
|
+
}).optional(),
|
|
161
|
+
// Pre-warming
|
|
162
|
+
prewarming: z.object({
|
|
163
|
+
enabled: z.boolean().default(false),
|
|
164
|
+
prewarmServices: z.array(z.string()).default(['qdrant']),
|
|
165
|
+
}).optional(),
|
|
166
|
+
});
|
|
79
167
|
export const AgentContextConfigSchema = z.object({
|
|
80
168
|
$schema: z.string().optional(),
|
|
81
169
|
version: z.string().default('1.0.0'),
|
|
@@ -93,5 +181,8 @@ export const AgentContextConfigSchema = z.object({
|
|
|
93
181
|
droids: z.array(DroidSchema).optional(),
|
|
94
182
|
commands: z.array(CommandSchema).optional(),
|
|
95
183
|
template: TemplateSchema.optional(),
|
|
184
|
+
// NEW: Optimization settings
|
|
185
|
+
costOptimization: CostOptimizationSchema.optional(),
|
|
186
|
+
timeOptimization: TimeOptimizationSchema.optional(),
|
|
96
187
|
});
|
|
97
188
|
//# sourceMappingURL=config.js.map
|
package/dist/types/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACnC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,uBAAuB;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,E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,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE;IAC3C,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;IACnC,6BAA6B;IAC7B,gBAAgB,EAAE,sBAAsB,CAAC,QAAQ,EAAE;IACnD,gBAAgB,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAC"}
|
|
@@ -172,7 +172,7 @@ export declare const AgentMessageSchema: z.ZodObject<{
|
|
|
172
172
|
}, "strip", z.ZodTypeAny, {
|
|
173
173
|
type: "request" | "response" | "notification" | "claim" | "release";
|
|
174
174
|
id: number;
|
|
175
|
-
channel: "
|
|
175
|
+
channel: "deploy" | "broadcast" | "review" | "direct" | "coordination";
|
|
176
176
|
payload: {
|
|
177
177
|
action: string;
|
|
178
178
|
resource?: string | undefined;
|
|
@@ -187,7 +187,7 @@ export declare const AgentMessageSchema: z.ZodObject<{
|
|
|
187
187
|
}, {
|
|
188
188
|
type: "request" | "response" | "notification" | "claim" | "release";
|
|
189
189
|
id: number;
|
|
190
|
-
channel: "
|
|
190
|
+
channel: "deploy" | "broadcast" | "review" | "direct" | "coordination";
|
|
191
191
|
payload: {
|
|
192
192
|
action: string;
|
|
193
193
|
resource?: string | undefined;
|
|
@@ -217,7 +217,7 @@ export declare const DeployActionSchema: z.ZodObject<{
|
|
|
217
217
|
id: number;
|
|
218
218
|
priority: number;
|
|
219
219
|
agentId: string;
|
|
220
|
-
actionType: "push" | "
|
|
220
|
+
actionType: "push" | "commit" | "merge" | "workflow" | "deploy";
|
|
221
221
|
target: string;
|
|
222
222
|
queuedAt: string;
|
|
223
223
|
payload?: Record<string, unknown> | undefined;
|
|
@@ -228,7 +228,7 @@ export declare const DeployActionSchema: z.ZodObject<{
|
|
|
228
228
|
status: "completed" | "failed" | "pending" | "batched" | "executing";
|
|
229
229
|
id: number;
|
|
230
230
|
agentId: string;
|
|
231
|
-
actionType: "push" | "
|
|
231
|
+
actionType: "push" | "commit" | "merge" | "workflow" | "deploy";
|
|
232
232
|
target: string;
|
|
233
233
|
queuedAt: string;
|
|
234
234
|
payload?: Record<string, unknown> | undefined;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Intelligent merge of existing CLAUDE.md with newly generated content
|
|
3
|
+
*
|
|
4
|
+
* Strategy:
|
|
5
|
+
* - Preserves user customizations in standard sections
|
|
6
|
+
* - Extracts valuable content from existing file
|
|
7
|
+
* - Places extracted content in appropriate new sections
|
|
8
|
+
* - Never loses information
|
|
4
9
|
*/
|
|
5
10
|
/**
|
|
6
11
|
* Merge existing CLAUDE.md content with newly generated content
|
|
7
12
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* Intelligent merge strategy:
|
|
14
|
+
* 1. Use new template structure and preamble
|
|
15
|
+
* 2. Replace standard sections with new versions
|
|
16
|
+
* 3. Extract valuable content from existing file
|
|
17
|
+
* 4. Inject extracted content into appropriate new sections
|
|
18
|
+
* 5. Append completely custom sections at the end
|
|
13
19
|
*/
|
|
14
20
|
export declare function mergeClaudeMd(existingContent: string, newContent: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Validate merge result - ensure no significant content was lost
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateMerge(original: string, merged: string): {
|
|
25
|
+
valid: boolean;
|
|
26
|
+
warnings: string[];
|
|
27
|
+
};
|
|
15
28
|
//# sourceMappingURL=merge-claude-md.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-claude-md.d.ts","sourceRoot":"","sources":["../../src/utils/merge-claude-md.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"merge-claude-md.d.ts","sourceRoot":"","sources":["../../src/utils/merge-claude-md.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkTH;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAkDjF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAoCtG"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Intelligent merge of existing CLAUDE.md with newly generated content
|
|
3
|
+
*
|
|
4
|
+
* Strategy:
|
|
5
|
+
* - Preserves user customizations in standard sections
|
|
6
|
+
* - Extracts valuable content from existing file
|
|
7
|
+
* - Places extracted content in appropriate new sections
|
|
8
|
+
* - Never loses information
|
|
4
9
|
*/
|
|
5
10
|
/**
|
|
6
11
|
* Parse markdown content into sections
|
|
@@ -12,17 +17,17 @@ function parseSections(content) {
|
|
|
12
17
|
let currentContent = [];
|
|
13
18
|
for (let i = 0; i < lines.length; i++) {
|
|
14
19
|
const line = lines[i];
|
|
15
|
-
|
|
20
|
+
// Match ## headings, capturing optional emoji
|
|
21
|
+
const heading = line.match(/^##\s+([🔴⚡🤖📋🧠🌳🚀📁🏗️🔧🗄️🔐✅🔄📊⚙️🧪🏭⛔]\s*)?(.+)$/);
|
|
16
22
|
if (heading) {
|
|
17
|
-
// Save previous section
|
|
18
23
|
if (currentSection) {
|
|
19
24
|
currentSection.content = currentContent.join('\n').trim();
|
|
20
25
|
currentSection.endLine = i - 1;
|
|
21
26
|
sections.push(currentSection);
|
|
22
27
|
}
|
|
23
|
-
// Start new section
|
|
24
28
|
currentSection = {
|
|
25
|
-
title: heading[
|
|
29
|
+
title: heading[2].trim(),
|
|
30
|
+
emoji: heading[1]?.trim(),
|
|
26
31
|
content: '',
|
|
27
32
|
startLine: i,
|
|
28
33
|
endLine: i,
|
|
@@ -33,7 +38,6 @@ function parseSections(content) {
|
|
|
33
38
|
currentContent.push(line);
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
|
-
// Save last section
|
|
37
41
|
if (currentSection) {
|
|
38
42
|
currentSection.content = currentContent.join('\n').trim();
|
|
39
43
|
currentSection.endLine = lines.length - 1;
|
|
@@ -56,94 +60,283 @@ function extractPreamble(content) {
|
|
|
56
60
|
return preamble.join('\n').trim();
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
|
-
* Standard sections
|
|
63
|
+
* Standard sections managed by the template (will be replaced)
|
|
60
64
|
*/
|
|
61
65
|
const STANDARD_SECTIONS = new Set([
|
|
62
|
-
'
|
|
66
|
+
'DIRECTIVE HIERARCHY',
|
|
67
|
+
'SESSION START PROTOCOL',
|
|
68
|
+
'MULTI-AGENT COORDINATION PROTOCOL',
|
|
69
|
+
'MANDATORY DECISION LOOP',
|
|
63
70
|
'MEMORY SYSTEM',
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'Essential Commands',
|
|
72
|
-
'Core Components',
|
|
73
|
-
'Architecture',
|
|
74
|
-
'Data Layer',
|
|
75
|
-
'Databases',
|
|
76
|
-
'Authentication',
|
|
77
|
-
'CI/CD',
|
|
78
|
-
'Troubleshooting',
|
|
79
|
-
'Required Workflow',
|
|
80
|
-
'Augmented Agent Capabilities',
|
|
81
|
-
'Completion Checklist',
|
|
71
|
+
'FOUR-LAYER MEMORY SYSTEM',
|
|
72
|
+
'WORKTREE WORKFLOW',
|
|
73
|
+
'PARALLEL REVIEW PROTOCOL',
|
|
74
|
+
'AUTOMATIC TRIGGERS',
|
|
75
|
+
'REPOSITORY STRUCTURE',
|
|
76
|
+
'COMPLETION PROTOCOL',
|
|
77
|
+
'COMPLETION CHECKLIST',
|
|
82
78
|
]);
|
|
83
79
|
/**
|
|
84
|
-
*
|
|
80
|
+
* Sections that contain extractable content (we'll merge content intelligently)
|
|
85
81
|
*/
|
|
82
|
+
const EXTRACTABLE_SECTIONS = new Set([
|
|
83
|
+
'TROUBLESHOOTING',
|
|
84
|
+
'QUICK REFERENCE',
|
|
85
|
+
'CONFIG FILES',
|
|
86
|
+
'ARCHITECTURE',
|
|
87
|
+
'COMPONENTS',
|
|
88
|
+
'DATABASE',
|
|
89
|
+
'AUTHENTICATION',
|
|
90
|
+
'PROJECT KNOWLEDGE',
|
|
91
|
+
'INFRASTRUCTURE',
|
|
92
|
+
]);
|
|
93
|
+
function normalizeTitle(title) {
|
|
94
|
+
return title.toUpperCase()
|
|
95
|
+
.replace(/[🔴⚡🤖📋🧠🌳🚀📁🏗️🔧🗄️🔐✅🔄📊⚙️🧪🏭⛔]/g, '')
|
|
96
|
+
.trim();
|
|
97
|
+
}
|
|
86
98
|
function isStandardSection(title) {
|
|
87
|
-
const
|
|
88
|
-
for (const
|
|
89
|
-
if (
|
|
99
|
+
const normalized = normalizeTitle(title);
|
|
100
|
+
for (const std of STANDARD_SECTIONS) {
|
|
101
|
+
if (normalized.includes(std) || std.includes(normalized)) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
function isExtractableSection(title) {
|
|
108
|
+
const normalized = normalizeTitle(title);
|
|
109
|
+
for (const ext of EXTRACTABLE_SECTIONS) {
|
|
110
|
+
if (normalized.includes(ext) || ext.includes(normalized)) {
|
|
90
111
|
return true;
|
|
91
112
|
}
|
|
92
113
|
}
|
|
93
114
|
return false;
|
|
94
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Extract valuable content from existing sections
|
|
118
|
+
*/
|
|
119
|
+
function extractContent(sections) {
|
|
120
|
+
const result = {
|
|
121
|
+
customSections: [],
|
|
122
|
+
troubleshooting: [],
|
|
123
|
+
urls: [],
|
|
124
|
+
commands: [],
|
|
125
|
+
configFiles: [],
|
|
126
|
+
workflows: [],
|
|
127
|
+
clusters: [],
|
|
128
|
+
gotchas: [],
|
|
129
|
+
lessons: [],
|
|
130
|
+
};
|
|
131
|
+
for (const section of sections) {
|
|
132
|
+
const normalized = normalizeTitle(section.title);
|
|
133
|
+
const content = section.content;
|
|
134
|
+
// Completely custom sections - preserve entirely
|
|
135
|
+
if (!isStandardSection(section.title) && !isExtractableSection(section.title)) {
|
|
136
|
+
result.customSections.push(section);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
// Extract troubleshooting entries (table rows)
|
|
140
|
+
if (normalized.includes('TROUBLESHOOTING')) {
|
|
141
|
+
const tableRows = content.match(/^\|[^|]+\|[^|]+\|$/gm) || [];
|
|
142
|
+
for (const row of tableRows) {
|
|
143
|
+
if (!row.includes('---') && !row.toLowerCase().includes('symptom') && !row.toLowerCase().includes('solution')) {
|
|
144
|
+
result.troubleshooting.push(row);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Extract URLs
|
|
149
|
+
if (normalized.includes('QUICK REFERENCE') || normalized.includes('URL')) {
|
|
150
|
+
const urls = content.match(/https?:\/\/[^\s)>]+/g) || [];
|
|
151
|
+
result.urls.push(...urls.filter(u => !u.includes('img.shields.io')));
|
|
152
|
+
}
|
|
153
|
+
// Extract kubectl contexts/clusters
|
|
154
|
+
if (content.includes('kubectl config use-context')) {
|
|
155
|
+
const contexts = content.match(/kubectl config use-context\s+\S+.*$/gm) || [];
|
|
156
|
+
result.clusters.push(...contexts);
|
|
157
|
+
}
|
|
158
|
+
// Extract workflow files
|
|
159
|
+
if (content.includes('.yml') || content.includes('.yaml')) {
|
|
160
|
+
const workflows = content.match(/├──\s+[\w-]+\.ya?ml.*$/gm) || [];
|
|
161
|
+
result.workflows.push(...workflows);
|
|
162
|
+
}
|
|
163
|
+
// Extract config file entries
|
|
164
|
+
if (normalized.includes('CONFIG')) {
|
|
165
|
+
const configRows = content.match(/^\|\s*`[^`]+`\s*\|[^|]+\|$/gm) || [];
|
|
166
|
+
result.configFiles.push(...configRows);
|
|
167
|
+
}
|
|
168
|
+
// Extract gotchas
|
|
169
|
+
if (normalized.includes('GOTCHA') || content.includes('⚠️')) {
|
|
170
|
+
const gotchas = content.match(/^-?\s*⚠️.*$/gm) || [];
|
|
171
|
+
result.gotchas.push(...gotchas);
|
|
172
|
+
}
|
|
173
|
+
// Extract lessons
|
|
174
|
+
if (normalized.includes('LESSON') || normalized.includes('KNOWLEDGE')) {
|
|
175
|
+
const lessons = content.match(/^-\s+\*\*[^*]+\*\*:.*$/gm) || [];
|
|
176
|
+
result.lessons.push(...lessons);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Inject extracted content into appropriate sections of new content
|
|
183
|
+
*/
|
|
184
|
+
function injectExtractedContent(newSections, extracted) {
|
|
185
|
+
const result = [...newSections];
|
|
186
|
+
for (const section of result) {
|
|
187
|
+
const normalized = normalizeTitle(section.title);
|
|
188
|
+
// Inject troubleshooting entries
|
|
189
|
+
if (normalized.includes('TROUBLESHOOTING') && extracted.troubleshooting.length > 0) {
|
|
190
|
+
const existingRows = section.content.match(/^\|[^|]+\|[^|]+\|$/gm) || [];
|
|
191
|
+
const existingSet = new Set(existingRows.map(r => r.toLowerCase()));
|
|
192
|
+
const newRows = extracted.troubleshooting.filter(r => !existingSet.has(r.toLowerCase()));
|
|
193
|
+
if (newRows.length > 0) {
|
|
194
|
+
// Find table end and append
|
|
195
|
+
const tableMatch = section.content.match(/(^\|.*\|$\n?)+/m);
|
|
196
|
+
if (tableMatch) {
|
|
197
|
+
const tableEnd = tableMatch.index + tableMatch[0].length;
|
|
198
|
+
section.content =
|
|
199
|
+
section.content.slice(0, tableEnd) +
|
|
200
|
+
newRows.join('\n') + '\n' +
|
|
201
|
+
section.content.slice(tableEnd);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Inject URLs
|
|
206
|
+
if (normalized.includes('QUICK REFERENCE') && extracted.urls.length > 0) {
|
|
207
|
+
const existingUrls = new Set((section.content.match(/https?:\/\/[^\s)>]+/g) || []).map(u => u.toLowerCase()));
|
|
208
|
+
const newUrls = extracted.urls.filter(u => !existingUrls.has(u.toLowerCase()));
|
|
209
|
+
if (newUrls.length > 0 && !section.content.includes('### URLs')) {
|
|
210
|
+
section.content += '\n\n### URLs\n' + newUrls.map(u => `- ${u}`).join('\n');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Inject clusters
|
|
214
|
+
if (normalized.includes('QUICK REFERENCE') && extracted.clusters.length > 0) {
|
|
215
|
+
if (!section.content.includes('kubectl config use-context')) {
|
|
216
|
+
section.content += '\n\n### Clusters\n```bash\n' + extracted.clusters.join('\n') + '\n```';
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Inject workflows
|
|
220
|
+
if (normalized.includes('QUICK REFERENCE') && extracted.workflows.length > 0) {
|
|
221
|
+
const existingWorkflows = new Set((section.content.match(/[\w-]+\.ya?ml/g) || []).map(w => w.toLowerCase()));
|
|
222
|
+
const newWorkflows = extracted.workflows.filter(w => {
|
|
223
|
+
const match = w.match(/[\w-]+\.ya?ml/);
|
|
224
|
+
return match && !existingWorkflows.has(match[0].toLowerCase());
|
|
225
|
+
});
|
|
226
|
+
if (newWorkflows.length > 0 && !section.content.includes('### Workflows')) {
|
|
227
|
+
section.content += '\n\n### Workflows\n```\n' + newWorkflows.join('\n') + '\n```';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Inject config files
|
|
231
|
+
if (normalized.includes('CONFIG') && extracted.configFiles.length > 0) {
|
|
232
|
+
const existingFiles = new Set((section.content.match(/`[^`]+`/g) || []).map(f => f.toLowerCase()));
|
|
233
|
+
const newFiles = extracted.configFiles.filter(f => {
|
|
234
|
+
const match = f.match(/`([^`]+)`/);
|
|
235
|
+
return match && !existingFiles.has(match[0].toLowerCase());
|
|
236
|
+
});
|
|
237
|
+
if (newFiles.length > 0) {
|
|
238
|
+
section.content += '\n' + newFiles.join('\n');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Inject gotchas into Project Knowledge
|
|
242
|
+
if (normalized.includes('PROJECT KNOWLEDGE') || normalized.includes('GOTCHA')) {
|
|
243
|
+
if (extracted.gotchas.length > 0 && !section.content.includes('### Gotchas')) {
|
|
244
|
+
section.content += '\n\n### Gotchas\n' + extracted.gotchas.join('\n');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Inject lessons into Project Knowledge
|
|
248
|
+
if (normalized.includes('PROJECT KNOWLEDGE') || normalized.includes('LESSON')) {
|
|
249
|
+
if (extracted.lessons.length > 0 && !section.content.includes('### Lessons')) {
|
|
250
|
+
section.content += '\n\n### Lessons\n' + extracted.lessons.join('\n');
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
95
256
|
/**
|
|
96
257
|
* Merge existing CLAUDE.md content with newly generated content
|
|
97
258
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
259
|
+
* Intelligent merge strategy:
|
|
260
|
+
* 1. Use new template structure and preamble
|
|
261
|
+
* 2. Replace standard sections with new versions
|
|
262
|
+
* 3. Extract valuable content from existing file
|
|
263
|
+
* 4. Inject extracted content into appropriate new sections
|
|
264
|
+
* 5. Append completely custom sections at the end
|
|
103
265
|
*/
|
|
104
266
|
export function mergeClaudeMd(existingContent, newContent) {
|
|
105
267
|
const existingSections = parseSections(existingContent);
|
|
106
268
|
const newSections = parseSections(newContent);
|
|
107
269
|
const newPreamble = extractPreamble(newContent);
|
|
108
|
-
//
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// Build merged content
|
|
270
|
+
// Extract valuable content from existing file
|
|
271
|
+
const extracted = extractContent(existingSections);
|
|
272
|
+
// Inject extracted content into new sections
|
|
273
|
+
const mergedSections = injectExtractedContent(newSections, extracted);
|
|
274
|
+
// Build final content
|
|
116
275
|
const merged = [];
|
|
117
|
-
// Use new preamble
|
|
118
276
|
merged.push(newPreamble);
|
|
119
277
|
merged.push('');
|
|
120
|
-
//
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
merged.push(`## ${newSection.title}`);
|
|
278
|
+
// Add all sections from new content (with injected data)
|
|
279
|
+
for (const section of mergedSections) {
|
|
280
|
+
const emoji = section.emoji ? `${section.emoji} ` : '';
|
|
281
|
+
merged.push(`## ${emoji}${section.title}`);
|
|
125
282
|
merged.push('');
|
|
126
|
-
merged.push(
|
|
283
|
+
merged.push(section.content);
|
|
127
284
|
merged.push('');
|
|
128
285
|
merged.push('---');
|
|
129
286
|
merged.push('');
|
|
130
287
|
}
|
|
131
|
-
// Append
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
288
|
+
// Append custom sections that weren't in the template
|
|
289
|
+
if (extracted.customSections.length > 0) {
|
|
290
|
+
merged.push('<!-- Custom Sections (preserved from existing file) -->');
|
|
291
|
+
merged.push('');
|
|
292
|
+
for (const section of extracted.customSections) {
|
|
293
|
+
const emoji = section.emoji ? `${section.emoji} ` : '';
|
|
294
|
+
merged.push(`## ${emoji}${section.title}`);
|
|
135
295
|
merged.push('');
|
|
136
|
-
merged.push(
|
|
296
|
+
merged.push(section.content);
|
|
137
297
|
merged.push('');
|
|
138
298
|
merged.push('---');
|
|
139
299
|
merged.push('');
|
|
140
300
|
}
|
|
141
301
|
}
|
|
142
|
-
// Clean up
|
|
302
|
+
// Clean up
|
|
143
303
|
let result = merged.join('\n');
|
|
144
|
-
result = result.replace(/\n{3,}/g, '\n\n');
|
|
145
|
-
result = result.replace(/---\n*$/, '');
|
|
304
|
+
result = result.replace(/\n{3,}/g, '\n\n');
|
|
305
|
+
result = result.replace(/---\n*$/, '');
|
|
146
306
|
result = result.trim();
|
|
147
307
|
return result;
|
|
148
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Validate merge result - ensure no significant content was lost
|
|
311
|
+
*/
|
|
312
|
+
export function validateMerge(original, merged) {
|
|
313
|
+
const warnings = [];
|
|
314
|
+
// Check for URLs that might have been lost
|
|
315
|
+
const originalUrls = new Set((original.match(/https?:\/\/[^\s)>]+/g) || []).filter(u => !u.includes('img.shields.io')));
|
|
316
|
+
const mergedUrls = new Set((merged.match(/https?:\/\/[^\s)>]+/g) || []));
|
|
317
|
+
for (const url of originalUrls) {
|
|
318
|
+
if (!mergedUrls.has(url)) {
|
|
319
|
+
warnings.push(`URL may be missing: ${url.slice(0, 50)}...`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// Check for kubectl contexts that might have been lost
|
|
323
|
+
const originalContexts = original.match(/kubectl config use-context\s+\S+/g) || [];
|
|
324
|
+
const mergedContexts = merged.match(/kubectl config use-context\s+\S+/g) || [];
|
|
325
|
+
if (originalContexts.length > mergedContexts.length) {
|
|
326
|
+
warnings.push(`Some kubectl contexts may be missing (had ${originalContexts.length}, now ${mergedContexts.length})`);
|
|
327
|
+
}
|
|
328
|
+
// Check for custom section headers
|
|
329
|
+
const originalSections = parseSections(original);
|
|
330
|
+
const mergedSections = parseSections(merged);
|
|
331
|
+
const mergedTitles = new Set(mergedSections.map(s => normalizeTitle(s.title)));
|
|
332
|
+
for (const section of originalSections) {
|
|
333
|
+
if (!isStandardSection(section.title) && !mergedTitles.has(normalizeTitle(section.title))) {
|
|
334
|
+
warnings.push(`Custom section may be missing: ${section.title}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
valid: warnings.length === 0,
|
|
339
|
+
warnings,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
149
342
|
//# sourceMappingURL=merge-claude-md.js.map
|