gencode-ai 0.1.1 → 0.1.3
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/.gencode/settings.local.json +7 -0
- package/CLAUDE.md +86 -0
- package/README.md +13 -16
- package/dist/agent/agent.d.ts +50 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +96 -16
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/types.d.ts +14 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/cli/components/App.d.ts +8 -1
- package/dist/cli/components/App.d.ts.map +1 -1
- package/dist/cli/components/App.js +266 -29
- package/dist/cli/components/App.js.map +1 -1
- package/dist/cli/components/CommandSuggestions.d.ts.map +1 -1
- package/dist/cli/components/CommandSuggestions.js +2 -0
- package/dist/cli/components/CommandSuggestions.js.map +1 -1
- package/dist/cli/components/Header.d.ts +1 -1
- package/dist/cli/components/Header.d.ts.map +1 -1
- package/dist/cli/components/Header.js +4 -6
- package/dist/cli/components/Header.js.map +1 -1
- package/dist/cli/components/Logo.d.ts +1 -0
- package/dist/cli/components/Logo.d.ts.map +1 -1
- package/dist/cli/components/Logo.js +16 -3
- package/dist/cli/components/Logo.js.map +1 -1
- package/dist/cli/components/Messages.d.ts +4 -4
- package/dist/cli/components/Messages.d.ts.map +1 -1
- package/dist/cli/components/Messages.js +66 -23
- package/dist/cli/components/Messages.js.map +1 -1
- package/dist/cli/components/PermissionPrompt.d.ts +60 -0
- package/dist/cli/components/PermissionPrompt.d.ts.map +1 -0
- package/dist/cli/components/PermissionPrompt.js +192 -0
- package/dist/cli/components/PermissionPrompt.js.map +1 -0
- package/dist/cli/components/ProviderManager.js +3 -3
- package/dist/cli/components/ProviderManager.js.map +1 -1
- package/dist/cli/components/QuestionPrompt.d.ts +23 -0
- package/dist/cli/components/QuestionPrompt.d.ts.map +1 -0
- package/dist/cli/components/QuestionPrompt.js +231 -0
- package/dist/cli/components/QuestionPrompt.js.map +1 -0
- package/dist/cli/components/Spinner.d.ts +7 -2
- package/dist/cli/components/Spinner.d.ts.map +1 -1
- package/dist/cli/components/Spinner.js +116 -25
- package/dist/cli/components/Spinner.js.map +1 -1
- package/dist/cli/components/TodoList.d.ts +7 -0
- package/dist/cli/components/TodoList.d.ts.map +1 -0
- package/dist/cli/components/TodoList.js +34 -0
- package/dist/cli/components/TodoList.js.map +1 -0
- package/dist/cli/components/index.d.ts +2 -0
- package/dist/cli/components/index.d.ts.map +1 -1
- package/dist/cli/components/index.js +2 -0
- package/dist/cli/components/index.js.map +1 -1
- package/dist/cli/components/theme.d.ts +7 -0
- package/dist/cli/components/theme.d.ts.map +1 -1
- package/dist/cli/components/theme.js +11 -1
- package/dist/cli/components/theme.js.map +1 -1
- package/dist/cli/index.js +47 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +13 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +18 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/levels.d.ts +49 -0
- package/dist/config/levels.d.ts.map +1 -0
- package/dist/config/levels.js +222 -0
- package/dist/config/levels.js.map +1 -0
- package/dist/config/loader.d.ts +46 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +153 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/manager.d.ts +115 -15
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/config/manager.js +260 -34
- package/dist/config/manager.js.map +1 -1
- package/dist/config/manager.test.d.ts +5 -0
- package/dist/config/manager.test.d.ts.map +1 -0
- package/dist/config/manager.test.js +192 -0
- package/dist/config/manager.test.js.map +1 -0
- package/dist/config/merger.d.ts +56 -0
- package/dist/config/merger.d.ts.map +1 -0
- package/dist/config/merger.js +177 -0
- package/dist/config/merger.js.map +1 -0
- package/dist/config/test-utils.d.ts +24 -0
- package/dist/config/test-utils.d.ts.map +1 -0
- package/dist/config/test-utils.js +55 -0
- package/dist/config/test-utils.js.map +1 -0
- package/dist/config/types.d.ts +78 -9
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +52 -2
- package/dist/config/types.js.map +1 -1
- package/dist/memory/import-resolver.d.ts +46 -0
- package/dist/memory/import-resolver.d.ts.map +1 -0
- package/dist/memory/import-resolver.js +117 -0
- package/dist/memory/import-resolver.js.map +1 -0
- package/dist/memory/index.d.ts +7 -6
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +7 -5
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/init-prompt.d.ts +22 -0
- package/dist/memory/init-prompt.d.ts.map +1 -0
- package/dist/memory/init-prompt.js +103 -0
- package/dist/memory/init-prompt.js.map +1 -0
- package/dist/memory/memory-manager.d.ts +119 -0
- package/dist/memory/memory-manager.d.ts.map +1 -0
- package/dist/memory/memory-manager.js +587 -0
- package/dist/memory/memory-manager.js.map +1 -0
- package/dist/memory/rules-parser.d.ts +38 -0
- package/dist/memory/rules-parser.d.ts.map +1 -0
- package/dist/memory/rules-parser.js +69 -0
- package/dist/memory/rules-parser.js.map +1 -0
- package/dist/memory/test-utils.d.ts +20 -0
- package/dist/memory/test-utils.d.ts.map +1 -0
- package/dist/memory/test-utils.js +44 -0
- package/dist/memory/test-utils.js.map +1 -0
- package/dist/memory/types.d.ts +70 -63
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/types.js +42 -2
- package/dist/memory/types.js.map +1 -1
- package/dist/permissions/audit.d.ts +82 -0
- package/dist/permissions/audit.d.ts.map +1 -0
- package/dist/permissions/audit.js +229 -0
- package/dist/permissions/audit.js.map +1 -0
- package/dist/permissions/index.d.ts +11 -1
- package/dist/permissions/index.d.ts.map +1 -1
- package/dist/permissions/index.js +15 -0
- package/dist/permissions/index.js.map +1 -1
- package/dist/permissions/manager.d.ts +149 -13
- package/dist/permissions/manager.d.ts.map +1 -1
- package/dist/permissions/manager.js +480 -35
- package/dist/permissions/manager.js.map +1 -1
- package/dist/permissions/manager.test.d.ts +5 -0
- package/dist/permissions/manager.test.d.ts.map +1 -0
- package/dist/permissions/manager.test.js +213 -0
- package/dist/permissions/manager.test.js.map +1 -0
- package/dist/permissions/persistence.d.ts +74 -0
- package/dist/permissions/persistence.d.ts.map +1 -0
- package/dist/permissions/persistence.js +248 -0
- package/dist/permissions/persistence.js.map +1 -0
- package/dist/permissions/persistence.test.d.ts +5 -0
- package/dist/permissions/persistence.test.d.ts.map +1 -0
- package/dist/permissions/persistence.test.js +171 -0
- package/dist/permissions/persistence.test.js.map +1 -0
- package/dist/permissions/prompt-matcher.d.ts +64 -0
- package/dist/permissions/prompt-matcher.d.ts.map +1 -0
- package/dist/permissions/prompt-matcher.js +415 -0
- package/dist/permissions/prompt-matcher.js.map +1 -0
- package/dist/permissions/prompt-matcher.test.d.ts +5 -0
- package/dist/permissions/prompt-matcher.test.d.ts.map +1 -0
- package/dist/permissions/prompt-matcher.test.js +107 -0
- package/dist/permissions/prompt-matcher.test.js.map +1 -0
- package/dist/permissions/types.d.ts +157 -0
- package/dist/permissions/types.d.ts.map +1 -1
- package/dist/permissions/types.js +45 -8
- package/dist/permissions/types.js.map +1 -1
- package/dist/prompts/index.d.ts +92 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +241 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/tools/builtin/ask-user.d.ts +64 -0
- package/dist/tools/builtin/ask-user.d.ts.map +1 -0
- package/dist/tools/builtin/ask-user.js +148 -0
- package/dist/tools/builtin/ask-user.js.map +1 -0
- package/dist/tools/builtin/bash.d.ts.map +1 -1
- package/dist/tools/builtin/bash.js +2 -1
- package/dist/tools/builtin/bash.js.map +1 -1
- package/dist/tools/builtin/edit.d.ts.map +1 -1
- package/dist/tools/builtin/edit.js +2 -1
- package/dist/tools/builtin/edit.js.map +1 -1
- package/dist/tools/builtin/glob.d.ts.map +1 -1
- package/dist/tools/builtin/glob.js +2 -1
- package/dist/tools/builtin/glob.js.map +1 -1
- package/dist/tools/builtin/grep.d.ts.map +1 -1
- package/dist/tools/builtin/grep.js +2 -1
- package/dist/tools/builtin/grep.js.map +1 -1
- package/dist/tools/builtin/read.d.ts.map +1 -1
- package/dist/tools/builtin/read.js +2 -1
- package/dist/tools/builtin/read.js.map +1 -1
- package/dist/tools/builtin/todowrite.d.ts +15 -0
- package/dist/tools/builtin/todowrite.d.ts.map +1 -0
- package/dist/tools/builtin/todowrite.js +88 -0
- package/dist/tools/builtin/todowrite.js.map +1 -0
- package/dist/tools/builtin/webfetch.d.ts.map +1 -1
- package/dist/tools/builtin/webfetch.js +2 -5
- package/dist/tools/builtin/webfetch.js.map +1 -1
- package/dist/tools/builtin/websearch.d.ts.map +1 -1
- package/dist/tools/builtin/websearch.js +2 -16
- package/dist/tools/builtin/websearch.js.map +1 -1
- package/dist/tools/builtin/write.d.ts.map +1 -1
- package/dist/tools/builtin/write.js +2 -1
- package/dist/tools/builtin/write.js.map +1 -1
- package/dist/tools/index.d.ts +19 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.d.ts +39 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +8 -0
- package/dist/tools/types.js.map +1 -1
- package/docs/config-system-comparison.md +707 -0
- package/docs/memory-system.md +238 -0
- package/docs/permissions.md +368 -0
- package/docs/proposals/0005-todo-system.md +350 -85
- package/docs/proposals/0006-memory-system.md +11 -10
- package/docs/proposals/0012-ask-user-question.md +1007 -207
- package/docs/proposals/0023-permission-enhancements.md +61 -2
- package/docs/proposals/0041-configuration-system.md +33 -2
- package/docs/proposals/0042-prompt-optimization.md +866 -0
- package/docs/proposals/README.md +7 -6
- package/examples/test-ask-user.ts +167 -0
- package/jest.config.js +26 -0
- package/package.json +8 -2
- package/src/agent/agent.ts +130 -16
- package/src/agent/index.ts +1 -0
- package/src/agent/types.ts +13 -1
- package/src/cli/components/App.tsx +362 -37
- package/src/cli/components/CommandSuggestions.tsx +2 -0
- package/src/cli/components/Header.tsx +11 -17
- package/src/cli/components/Logo.tsx +76 -9
- package/src/cli/components/Messages.tsx +104 -41
- package/src/cli/components/PermissionPrompt.tsx +388 -0
- package/src/cli/components/ProviderManager.tsx +5 -5
- package/src/cli/components/QuestionPrompt.tsx +462 -0
- package/src/cli/components/Spinner.tsx +138 -25
- package/src/cli/components/TodoList.tsx +54 -0
- package/src/cli/components/index.ts +7 -0
- package/src/cli/components/theme.ts +11 -1
- package/src/cli/index.tsx +54 -6
- package/src/config/index.ts +78 -4
- package/src/config/levels.test.ts +163 -0
- package/src/config/levels.ts +285 -0
- package/src/config/loader.test.ts +120 -0
- package/src/config/loader.ts +178 -0
- package/src/config/manager.test.ts +215 -0
- package/src/config/manager.ts +328 -40
- package/src/config/merger.test.ts +360 -0
- package/src/config/merger.ts +221 -0
- package/src/config/test-utils.ts +79 -0
- package/src/config/types.ts +152 -9
- package/src/memory/import-resolver.test.ts +117 -0
- package/src/memory/import-resolver.ts +149 -0
- package/src/memory/index.ts +11 -0
- package/src/memory/init-prompt.ts +113 -0
- package/src/memory/memory-manager.test.ts +198 -0
- package/src/memory/memory-manager.ts +716 -0
- package/src/memory/rules-parser.test.ts +182 -0
- package/src/memory/rules-parser.ts +82 -0
- package/src/memory/test-utils.ts +60 -0
- package/src/memory/types.ts +119 -0
- package/src/permissions/audit.ts +284 -0
- package/src/permissions/index.ts +20 -1
- package/src/permissions/manager.test.ts +260 -0
- package/src/permissions/manager.ts +592 -40
- package/src/permissions/persistence.test.ts +220 -0
- package/src/permissions/persistence.ts +301 -0
- package/src/permissions/prompt-matcher.test.ts +213 -0
- package/src/permissions/prompt-matcher.ts +472 -0
- package/src/permissions/types.ts +238 -8
- package/src/prompts/index.test.ts +279 -0
- package/src/prompts/index.ts +306 -0
- package/src/prompts/system/anthropic.txt +29 -0
- package/src/prompts/system/base.txt +166 -0
- package/src/prompts/system/gemini.txt +35 -0
- package/src/prompts/system/generic.txt +128 -0
- package/src/prompts/system/openai.txt +29 -0
- package/src/prompts/tools/ask-user.txt +110 -0
- package/src/prompts/tools/bash.txt +60 -0
- package/src/prompts/tools/edit.txt +29 -0
- package/src/prompts/tools/glob.txt +35 -0
- package/src/prompts/tools/grep.txt +43 -0
- package/src/prompts/tools/read.txt +22 -0
- package/src/prompts/tools/todowrite.txt +71 -0
- package/src/prompts/tools/webfetch.txt +34 -0
- package/src/prompts/tools/websearch.txt +41 -0
- package/src/prompts/tools/write.txt +23 -0
- package/src/tools/builtin/ask-user.ts +185 -0
- package/src/tools/builtin/bash.ts +2 -1
- package/src/tools/builtin/edit.ts +2 -1
- package/src/tools/builtin/glob.ts +2 -1
- package/src/tools/builtin/grep.ts +2 -1
- package/src/tools/builtin/read.ts +2 -1
- package/src/tools/builtin/todowrite.ts +102 -0
- package/src/tools/builtin/webfetch.ts +2 -5
- package/src/tools/builtin/websearch.ts +2 -16
- package/src/tools/builtin/write.ts +2 -1
- package/src/tools/index.ts +19 -0
- package/src/tools/types.ts +30 -0
- package/tsconfig.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAM3E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IAEvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,YAAY,CAAC;I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
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Configuration Types - Multi-level configuration system (Claude Code compatible)
|
|
3
|
+
*
|
|
4
|
+
* Configuration hierarchy (priority from low to high):
|
|
5
|
+
* 1. User Level: ~/.gencode/ + ~/.claude/ (merged, gencode wins)
|
|
6
|
+
* 2. Extra Dirs: GENCODE_CONFIG_DIRS environment variable
|
|
7
|
+
* 3. Project Level: .gencode/ + .claude/ (merged, gencode wins)
|
|
8
|
+
* 4. Local Level: .gencode/*.local.* + .claude/*.local.* (merged, gencode wins)
|
|
9
|
+
* 5. CLI Arguments: Command line overrides
|
|
10
|
+
* 6. Managed Level: System-wide enforced settings (cannot be overridden)
|
|
3
11
|
*/
|
|
4
|
-
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Constants
|
|
16
|
+
// =============================================================================
|
|
17
|
+
export const GENCODE_CONFIG_DIRS_ENV = 'GENCODE_CONFIG_DIRS';
|
|
18
|
+
// File names
|
|
5
19
|
export const SETTINGS_FILE_NAME = 'settings.json';
|
|
20
|
+
export const SETTINGS_LOCAL_FILE_NAME = 'settings.local.json';
|
|
21
|
+
export const MANAGED_SETTINGS_FILE_NAME = 'managed-settings.json';
|
|
6
22
|
export const PROVIDERS_FILE_NAME = 'providers.json';
|
|
23
|
+
// Directory names
|
|
24
|
+
export const GENCODE_DIR = '.gencode';
|
|
25
|
+
export const CLAUDE_DIR = '.claude';
|
|
26
|
+
// User directory paths
|
|
27
|
+
export const USER_GENCODE_DIR = path.join(os.homedir(), GENCODE_DIR);
|
|
28
|
+
export const USER_CLAUDE_DIR = path.join(os.homedir(), CLAUDE_DIR);
|
|
29
|
+
// Managed settings locations by platform
|
|
30
|
+
export function getManagedPaths() {
|
|
31
|
+
const platform = os.platform();
|
|
32
|
+
if (platform === 'darwin') {
|
|
33
|
+
return {
|
|
34
|
+
gencode: '/Library/Application Support/GenCode',
|
|
35
|
+
claude: '/Library/Application Support/ClaudeCode',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else if (platform === 'win32') {
|
|
39
|
+
return {
|
|
40
|
+
gencode: 'C:\\Program Files\\GenCode',
|
|
41
|
+
claude: 'C:\\Program Files\\ClaudeCode',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Linux and other Unix-like systems
|
|
46
|
+
return {
|
|
47
|
+
gencode: '/etc/gencode',
|
|
48
|
+
claude: '/etc/claude-code',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Legacy exports
|
|
53
|
+
export const DEFAULT_SETTINGS_DIR = '~/.claude';
|
|
54
|
+
export const PROJECT_SETTINGS_DIR = '.claude';
|
|
55
|
+
export const FALLBACK_SETTINGS_DIR = '~/.gencode';
|
|
56
|
+
export const FALLBACK_PROJECT_DIR = '.gencode';
|
|
7
57
|
//# sourceMappingURL=types.js.map
|
package/dist/config/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAgG7B,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,aAAa;AACb,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEpD,kBAAkB;AAClB,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AAEpC,uBAAuB;AACvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;AAEnE,yCAAyC;AACzC,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAE/B,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO;YACL,OAAO,EAAE,sCAAsC;YAC/C,MAAM,EAAE,yCAAyC;SAClD,CAAC;IACJ,CAAC;SAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO;YACL,OAAO,EAAE,4BAA4B;YACrC,MAAM,EAAE,+BAA+B;SACxC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,oCAAoC;QACpC,OAAO;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,kBAAkB;SAC3B,CAAC;IACJ,CAAC;AACH,CAAC;AAUD,iBAAiB;AACjB,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import Resolver - Handle @import syntax in memory files
|
|
3
|
+
*
|
|
4
|
+
* Supports:
|
|
5
|
+
* - @path/to/file.md - Relative imports
|
|
6
|
+
* - @./file.md - Current directory imports
|
|
7
|
+
* - @../parent/file.md - Parent directory imports
|
|
8
|
+
*
|
|
9
|
+
* Security:
|
|
10
|
+
* - Circular import detection
|
|
11
|
+
* - Max depth limit (5 levels)
|
|
12
|
+
* - Path traversal protection
|
|
13
|
+
*/
|
|
14
|
+
import type { MemoryConfig } from './types.js';
|
|
15
|
+
export interface ImportResult {
|
|
16
|
+
content: string;
|
|
17
|
+
importedPaths: string[];
|
|
18
|
+
errors: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare class ImportResolver {
|
|
21
|
+
private config;
|
|
22
|
+
private resolvedPaths;
|
|
23
|
+
private projectRoot;
|
|
24
|
+
constructor(config: MemoryConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Set the project root for path traversal protection
|
|
27
|
+
*/
|
|
28
|
+
setProjectRoot(root: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve all @imports in content
|
|
31
|
+
*/
|
|
32
|
+
resolve(content: string, basePath: string, depth?: number): Promise<ImportResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve import path to absolute path
|
|
35
|
+
*/
|
|
36
|
+
private resolvePath;
|
|
37
|
+
/**
|
|
38
|
+
* Check if path is safe (within project or home directory)
|
|
39
|
+
*/
|
|
40
|
+
private isPathSafe;
|
|
41
|
+
/**
|
|
42
|
+
* Reset resolver state for new file
|
|
43
|
+
*/
|
|
44
|
+
reset(): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../src/memory/import-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,WAAW,CAAc;gBAErB,MAAM,EAAE,YAAY;IAIhC;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACG,OAAO,CACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC,YAAY,CAAC;IAiExB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import Resolver - Handle @import syntax in memory files
|
|
3
|
+
*
|
|
4
|
+
* Supports:
|
|
5
|
+
* - @path/to/file.md - Relative imports
|
|
6
|
+
* - @./file.md - Current directory imports
|
|
7
|
+
* - @../parent/file.md - Parent directory imports
|
|
8
|
+
*
|
|
9
|
+
* Security:
|
|
10
|
+
* - Circular import detection
|
|
11
|
+
* - Max depth limit (5 levels)
|
|
12
|
+
* - Path traversal protection
|
|
13
|
+
*/
|
|
14
|
+
import * as fs from 'fs/promises';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
export class ImportResolver {
|
|
17
|
+
config;
|
|
18
|
+
resolvedPaths = new Set();
|
|
19
|
+
projectRoot = '';
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Set the project root for path traversal protection
|
|
25
|
+
*/
|
|
26
|
+
setProjectRoot(root) {
|
|
27
|
+
this.projectRoot = root;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve all @imports in content
|
|
31
|
+
*/
|
|
32
|
+
async resolve(content, basePath, depth = 0) {
|
|
33
|
+
const importedPaths = [];
|
|
34
|
+
const errors = [];
|
|
35
|
+
if (depth >= this.config.maxImportDepth) {
|
|
36
|
+
errors.push(`Max import depth (${this.config.maxImportDepth}) exceeded`);
|
|
37
|
+
return { content, importedPaths, errors };
|
|
38
|
+
}
|
|
39
|
+
// Match @import lines: lines starting with @ followed by a path
|
|
40
|
+
// Pattern: @path/to/file or @./file or @../file
|
|
41
|
+
const importRegex = /^@([^\s]+\.md)$/gm;
|
|
42
|
+
let resolvedContent = content;
|
|
43
|
+
const matches = [...content.matchAll(importRegex)];
|
|
44
|
+
for (const match of matches) {
|
|
45
|
+
const importPath = match[1].trim();
|
|
46
|
+
const absolutePath = this.resolvePath(importPath, basePath);
|
|
47
|
+
// Circular import detection
|
|
48
|
+
if (this.resolvedPaths.has(absolutePath)) {
|
|
49
|
+
errors.push(`Circular import detected: ${importPath}`);
|
|
50
|
+
resolvedContent = resolvedContent.replace(match[0], `<!-- Circular import: ${importPath} -->`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
// Path traversal security check
|
|
54
|
+
if (!this.isPathSafe(absolutePath)) {
|
|
55
|
+
errors.push(`Import path outside allowed scope: ${importPath}`);
|
|
56
|
+
resolvedContent = resolvedContent.replace(match[0], `<!-- Blocked import: ${importPath} -->`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const stat = await fs.stat(absolutePath);
|
|
61
|
+
// Size limit check
|
|
62
|
+
if (stat.size > this.config.maxFileSize) {
|
|
63
|
+
errors.push(`Import too large (${Math.round(stat.size / 1024)}KB): ${importPath}`);
|
|
64
|
+
resolvedContent = resolvedContent.replace(match[0], `<!-- Import too large: ${importPath} -->`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
this.resolvedPaths.add(absolutePath);
|
|
68
|
+
let importedContent = await fs.readFile(absolutePath, 'utf-8');
|
|
69
|
+
importedPaths.push(absolutePath);
|
|
70
|
+
// Recursively resolve imports in the imported file
|
|
71
|
+
const nested = await this.resolve(importedContent, path.dirname(absolutePath), depth + 1);
|
|
72
|
+
importedContent = nested.content;
|
|
73
|
+
importedPaths.push(...nested.importedPaths);
|
|
74
|
+
errors.push(...nested.errors);
|
|
75
|
+
// Replace @import with content
|
|
76
|
+
resolvedContent = resolvedContent.replace(match[0], importedContent);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
errors.push(`Failed to import: ${importPath}`);
|
|
80
|
+
resolvedContent = resolvedContent.replace(match[0], `<!-- Failed to import: ${importPath} -->`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { content: resolvedContent, importedPaths, errors };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolve import path to absolute path
|
|
87
|
+
*/
|
|
88
|
+
resolvePath(importPath, basePath) {
|
|
89
|
+
if (path.isAbsolute(importPath)) {
|
|
90
|
+
return importPath;
|
|
91
|
+
}
|
|
92
|
+
return path.resolve(basePath, importPath);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check if path is safe (within project or home directory)
|
|
96
|
+
*/
|
|
97
|
+
isPathSafe(targetPath) {
|
|
98
|
+
const home = process.env.HOME || '';
|
|
99
|
+
const normalized = path.normalize(targetPath);
|
|
100
|
+
// Allow imports within project root
|
|
101
|
+
if (this.projectRoot && normalized.startsWith(this.projectRoot)) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
// Allow imports from home directory (for user-level imports)
|
|
105
|
+
if (home && normalized.startsWith(home)) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Reset resolver state for new file
|
|
112
|
+
*/
|
|
113
|
+
reset() {
|
|
114
|
+
this.resolvedPaths.clear();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=import-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resolver.js","sourceRoot":"","sources":["../../src/memory/import-resol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;QAC7D,IAAI,IAAI,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Memory System
|
|
2
|
+
* Memory System - Claude Code compatible memory management
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
5
|
-
* hierarchical memory files (CLAUDE.md, AGENT.md, etc.)
|
|
4
|
+
* Provides hierarchical memory loading with AGENT.md (primary) and CLAUDE.md (fallback)
|
|
6
5
|
*/
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export { MemoryManager } from './memory-manager.js';
|
|
8
|
+
export { ImportResolver } from './import-resolver.js';
|
|
9
|
+
export { parseRuleFrontmatter, matchesPatterns, activateRules, getActiveRules } from './rules-parser.js';
|
|
10
|
+
export { gatherContextFiles, buildInitPrompt, getContextSummary } from './init-prompt.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/memory/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Memory System
|
|
2
|
+
* Memory System - Claude Code compatible memory management
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
5
|
-
* hierarchical memory files (CLAUDE.md, AGENT.md, etc.)
|
|
4
|
+
* Provides hierarchical memory loading with AGENT.md (primary) and CLAUDE.md (fallback)
|
|
6
5
|
*/
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export { MemoryManager } from './memory-manager.js';
|
|
8
|
+
export { ImportResolver } from './import-resolver.js';
|
|
9
|
+
export { parseRuleFrontmatter, matchesPatterns, activateRules, getActiveRules } from './rules-parser.js';
|
|
10
|
+
export { gatherContextFiles, buildInitPrompt, getContextSummary } from './init-prompt.js';
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/dist/memory/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init Prompt Builder - Generate prompts for /init command
|
|
3
|
+
*
|
|
4
|
+
* Gathers context files (package.json, README.md, etc.) and builds
|
|
5
|
+
* a prompt for the AI to generate AGENT.md
|
|
6
|
+
*/
|
|
7
|
+
export interface ContextFiles {
|
|
8
|
+
[path: string]: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Gather context files for project analysis
|
|
12
|
+
*/
|
|
13
|
+
export declare function gatherContextFiles(cwd: string): Promise<ContextFiles>;
|
|
14
|
+
/**
|
|
15
|
+
* Build the init prompt for generating AGENT.md
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildInitPrompt(contextFiles: ContextFiles, existingAgentMd?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get a summary of files found for user feedback
|
|
20
|
+
*/
|
|
21
|
+
export declare function getContextSummary(contextFiles: ContextFiles): string;
|
|
22
|
+
//# sourceMappingURL=init-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-prompt.d.ts","sourceRoot":"","sources":["../../src/memory/init-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,YAAY;IAC3B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAyC3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAqC5F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAMpE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init Prompt Builder - Generate prompts for /init command
|
|
3
|
+
*
|
|
4
|
+
* Gathers context files (package.json, README.md, etc.) and builds
|
|
5
|
+
* a prompt for the AI to generate AGENT.md
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs/promises';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import { glob } from 'glob';
|
|
10
|
+
/**
|
|
11
|
+
* Gather context files for project analysis
|
|
12
|
+
*/
|
|
13
|
+
export async function gatherContextFiles(cwd) {
|
|
14
|
+
const patterns = [
|
|
15
|
+
'package.json',
|
|
16
|
+
'README.md',
|
|
17
|
+
'CONTRIBUTING.md',
|
|
18
|
+
'.cursor/rules/**/*.md',
|
|
19
|
+
'.cursorrules',
|
|
20
|
+
'.github/copilot-instructions.md',
|
|
21
|
+
'Cargo.toml',
|
|
22
|
+
'go.mod',
|
|
23
|
+
'pyproject.toml',
|
|
24
|
+
'tsconfig.json',
|
|
25
|
+
'Makefile',
|
|
26
|
+
'docker-compose.yml',
|
|
27
|
+
'docker-compose.yaml',
|
|
28
|
+
];
|
|
29
|
+
const files = {};
|
|
30
|
+
for (const pattern of patterns) {
|
|
31
|
+
try {
|
|
32
|
+
const matches = await glob(pattern, { cwd, absolute: false });
|
|
33
|
+
for (const match of matches.slice(0, 3)) {
|
|
34
|
+
// Limit per pattern
|
|
35
|
+
try {
|
|
36
|
+
const filePath = path.join(cwd, match);
|
|
37
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
38
|
+
if (content.length < 50000) {
|
|
39
|
+
// 50KB limit per file
|
|
40
|
+
files[match] = content;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Skip files that can't be read
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Skip patterns that fail
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return files;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the init prompt for generating AGENT.md
|
|
56
|
+
*/
|
|
57
|
+
export function buildInitPrompt(contextFiles, existingAgentMd) {
|
|
58
|
+
const contextParts = Object.entries(contextFiles)
|
|
59
|
+
.map(([filePath, content]) => `### ${filePath}\n\`\`\`\n${content}\n\`\`\``)
|
|
60
|
+
.join('\n\n');
|
|
61
|
+
const existingSection = existingAgentMd
|
|
62
|
+
? `\n\n## Existing AGENT.md\n\`\`\`markdown\n${existingAgentMd}\n\`\`\`\n`
|
|
63
|
+
: '';
|
|
64
|
+
return `Please analyze this codebase and create an AGENT.md file, which will be given to future AI assistants to operate in this repository.
|
|
65
|
+
|
|
66
|
+
## Context Files
|
|
67
|
+
|
|
68
|
+
${contextParts}
|
|
69
|
+
${existingSection}
|
|
70
|
+
## Instructions
|
|
71
|
+
|
|
72
|
+
What to add:
|
|
73
|
+
1. Commands that will be commonly used, such as how to build, lint, and run tests.
|
|
74
|
+
Include the necessary commands to develop in this codebase, such as how to run a single test.
|
|
75
|
+
2. High-level code architecture and structure so that future instances can be productive more quickly.
|
|
76
|
+
Focus on the "big picture" architecture that requires reading multiple files to understand.
|
|
77
|
+
|
|
78
|
+
Usage notes:
|
|
79
|
+
- ${existingAgentMd ? 'Suggest improvements to the existing AGENT.md.' : 'Create a new AGENT.md.'}
|
|
80
|
+
- Do not repeat yourself and do not include obvious instructions like "Provide helpful error messages" or "Write tests for new code".
|
|
81
|
+
- Avoid listing every component or file structure that can be easily discovered.
|
|
82
|
+
- Don't include generic development practices.
|
|
83
|
+
- Do not make up information unless it's expressly included in the files above.
|
|
84
|
+
- Keep it concise - aim for ~20-40 lines.
|
|
85
|
+
- Start the file with:
|
|
86
|
+
|
|
87
|
+
# AGENT.md
|
|
88
|
+
|
|
89
|
+
This file provides guidance to AI assistants when working with code in this repository.
|
|
90
|
+
|
|
91
|
+
After generating the content, use the Write tool to save it to ./AGENT.md`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get a summary of files found for user feedback
|
|
95
|
+
*/
|
|
96
|
+
export function getContextSummary(contextFiles) {
|
|
97
|
+
const fileNames = Object.keys(contextFiles);
|
|
98
|
+
if (fileNames.length === 0) {
|
|
99
|
+
return 'No context files found';
|
|
100
|
+
}
|
|
101
|
+
return `Found ${fileNames.length} context file(s): ${fileNames.join(', ')}`;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=init-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-prompt.js","sourceRoot":"","sources":["../../src/memory/init-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAM5B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,MAAM,QAAQ,GAAG;QACf,cAAc;QACd,WAAW;QACX,iBAAiB;QACjB,uBAAuB;QACvB,cAAc;QACd,iCAAiC;QACjC,YAAY;QACZ,QAAQ;QACR,gBAAgB;QAChB,eAAe;QACf,UAAU;QACV,oBAAoB;QACpB,qBAAqB;KACtB,CAAC;IAEF,MAAM,KAAK,GAAiB,EAAE,CAAC;IAE/B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9D,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACxC,oBAAoB;gBACpB,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;oBACvC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;oBACrD,IAAI,OAAO,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;wBAC3B,sBAAsB;wBACtB,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;oBACzB,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,gCAAgC;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,0BAA0B;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,YAA0B,EAAE,eAAwB;IAClF,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;SAC9C,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,QAAQ,aAAa,OAAO,UAAU,CAAC;SAC3E,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,MAAM,eAAe,GAAG,eAAe;QACrC,CAAC,CAAC,6CAA6C,eAAe,YAAY;QAC1E,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;;;;EAIP,YAAY;EACZ,eAAe;;;;;;;;;;IAUb,eAAe,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAC,wBAAwB;;;;;;;;;;;;0EAYvB,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAA0B;IAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,wBAAwB,CAAC;IAClC,CAAC;IACD,OAAO,SAAS,SAAS,CAAC,MAAM,qBAAqB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Manager - Core memory system implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements Claude Code compatible memory loading with merge semantics:
|
|
5
|
+
* At each level, both .gencode and .claude directories are loaded.
|
|
6
|
+
* Content from .gencode appears later in the context (higher priority for LLM).
|
|
7
|
+
*
|
|
8
|
+
* Loading order within each level:
|
|
9
|
+
* 1. .claude files first (lower priority - LLM sees earlier)
|
|
10
|
+
* 2. .gencode files second (higher priority - LLM sees later)
|
|
11
|
+
*
|
|
12
|
+
* Level loading order:
|
|
13
|
+
* 1. Enterprise (system-wide managed, enforced)
|
|
14
|
+
* 2. User (~/.gencode/ + ~/.claude/)
|
|
15
|
+
* 3. User Rules
|
|
16
|
+
* 4. Extra (GENCODE_CONFIG_DIRS)
|
|
17
|
+
* 5. Project (recursive upward search)
|
|
18
|
+
* 6. Project Rules
|
|
19
|
+
* 7. Local (*.local.md files)
|
|
20
|
+
*/
|
|
21
|
+
import type { MemoryConfig, LoadedMemory, MemoryLoadOptions } from './types.js';
|
|
22
|
+
export declare class MemoryManager {
|
|
23
|
+
private config;
|
|
24
|
+
private importResolver;
|
|
25
|
+
private loadedMemory;
|
|
26
|
+
constructor(config?: Partial<MemoryConfig>);
|
|
27
|
+
/**
|
|
28
|
+
* Load all memory files for the given working directory
|
|
29
|
+
*/
|
|
30
|
+
load(options: MemoryLoadOptions): Promise<LoadedMemory>;
|
|
31
|
+
/**
|
|
32
|
+
* Get the current loaded memory
|
|
33
|
+
*/
|
|
34
|
+
getLoaded(): LoadedMemory | null;
|
|
35
|
+
/**
|
|
36
|
+
* Check if any memory is loaded
|
|
37
|
+
*/
|
|
38
|
+
hasMemory(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Build combined context string for system prompt injection
|
|
41
|
+
*/
|
|
42
|
+
private buildContext;
|
|
43
|
+
private getLevelLabel;
|
|
44
|
+
/**
|
|
45
|
+
* Load enterprise-level memory files
|
|
46
|
+
*/
|
|
47
|
+
private loadEnterpriseMemory;
|
|
48
|
+
/**
|
|
49
|
+
* Load user-level memory files (both claude and gencode)
|
|
50
|
+
*/
|
|
51
|
+
private loadUserMemory;
|
|
52
|
+
/**
|
|
53
|
+
* Load user-level rules (both claude and gencode)
|
|
54
|
+
*/
|
|
55
|
+
private loadUserRules;
|
|
56
|
+
/**
|
|
57
|
+
* Load extra config dirs memory
|
|
58
|
+
*/
|
|
59
|
+
private loadExtraMemory;
|
|
60
|
+
/**
|
|
61
|
+
* Parse GENCODE_CONFIG_DIRS environment variable
|
|
62
|
+
*/
|
|
63
|
+
private parseExtraConfigDirs;
|
|
64
|
+
/**
|
|
65
|
+
* Load project-level memory files (both claude and gencode)
|
|
66
|
+
*/
|
|
67
|
+
private loadProjectMemory;
|
|
68
|
+
/**
|
|
69
|
+
* Load project-level rules (both claude and gencode)
|
|
70
|
+
*/
|
|
71
|
+
private loadProjectRules;
|
|
72
|
+
/**
|
|
73
|
+
* Load local memory files (both claude and gencode)
|
|
74
|
+
*/
|
|
75
|
+
private loadLocalMemory;
|
|
76
|
+
/**
|
|
77
|
+
* Load rules from a directory
|
|
78
|
+
*/
|
|
79
|
+
private loadRulesFromDir;
|
|
80
|
+
/**
|
|
81
|
+
* Load a single file with import resolution
|
|
82
|
+
*/
|
|
83
|
+
private loadFile;
|
|
84
|
+
/**
|
|
85
|
+
* Find project root (git root or cwd)
|
|
86
|
+
*/
|
|
87
|
+
private findProjectRoot;
|
|
88
|
+
/**
|
|
89
|
+
* Quick add content to memory file
|
|
90
|
+
*/
|
|
91
|
+
quickAdd(content: string, level: 'user' | 'project', cwd: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Get list of loaded files for /memory command
|
|
94
|
+
*/
|
|
95
|
+
getLoadedFileList(): Array<{
|
|
96
|
+
path: string;
|
|
97
|
+
level: string;
|
|
98
|
+
namespace: string;
|
|
99
|
+
size: number;
|
|
100
|
+
type: 'file' | 'rule';
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Get the path where /init would create a file
|
|
104
|
+
*/
|
|
105
|
+
getInitFilePath(cwd: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Check if project memory already exists
|
|
108
|
+
*/
|
|
109
|
+
hasProjectMemory(cwd: string): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* Get the path of existing project memory file
|
|
112
|
+
*/
|
|
113
|
+
getExistingProjectMemoryPath(cwd: string): Promise<string | null>;
|
|
114
|
+
/**
|
|
115
|
+
* Get debug summary of loaded memory
|
|
116
|
+
*/
|
|
117
|
+
getDebugSummary(): string;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=memory-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-manager.d.ts","sourceRoot":"","sources":["../../src/memory/memory-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,OAAO,KAAK,EACV,YAAY,EAGZ,YAAY,EACZ,iBAAiB,EAIlB,MAAM,YAAY,CAAC;AAIpB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAA6B;gBAErC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IAM1C;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IA8I7D;;OAEG;IACH,SAAS,IAAI,YAAY,GAAG,IAAI;IAIhC;;OAEG;IACH,SAAS,IAAI,OAAO;IAOpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAyBpB,OAAO,CAAC,aAAa;IAcrB;;OAEG;YACW,oBAAoB;IA6BlC;;OAEG;YACW,cAAc;IAuB5B;;OAEG;YACW,aAAa;IAiB3B;;OAEG;YACW,eAAe;IAyB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;OAEG;YACW,iBAAiB;IAkC/B;;OAEG;YACW,gBAAgB;IAgB9B;;OAEG;YACW,eAAe;IAkC7B;;OAEG;YACW,gBAAgB;IAuC9B;;OAEG;YACW,QAAQ;IA6BtB;;OAEG;YACW,eAAe;IAiB7B;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,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