agentic-knowledge-mcp 0.0.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.
Files changed (77) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +530 -0
  3. package/package.json +94 -0
  4. package/packages/cli/dist/cli.d.ts +5 -0
  5. package/packages/cli/dist/cli.js +21 -0
  6. package/packages/cli/dist/commands/create.d.ts +5 -0
  7. package/packages/cli/dist/commands/create.js +90 -0
  8. package/packages/cli/dist/commands/init.d.ts +5 -0
  9. package/packages/cli/dist/commands/init.js +182 -0
  10. package/packages/cli/dist/commands/refresh.d.ts +5 -0
  11. package/packages/cli/dist/commands/refresh.js +322 -0
  12. package/packages/cli/dist/commands/status.d.ts +5 -0
  13. package/packages/cli/dist/commands/status.js +268 -0
  14. package/packages/cli/dist/index.d.ts +6 -0
  15. package/packages/cli/dist/index.js +6 -0
  16. package/packages/cli/package.json +57 -0
  17. package/packages/content-loader/dist/__tests__/debug-filtering.d.ts +1 -0
  18. package/packages/content-loader/dist/__tests__/debug-filtering.js +17 -0
  19. package/packages/content-loader/dist/__tests__/test-filtering.d.ts +1 -0
  20. package/packages/content-loader/dist/__tests__/test-filtering.js +19 -0
  21. package/packages/content-loader/dist/content/api-documentation-loader.d.ts +26 -0
  22. package/packages/content-loader/dist/content/api-documentation-loader.js +45 -0
  23. package/packages/content-loader/dist/content/content-processor.d.ts +44 -0
  24. package/packages/content-loader/dist/content/content-processor.js +86 -0
  25. package/packages/content-loader/dist/content/documentation-site-loader.d.ts +26 -0
  26. package/packages/content-loader/dist/content/documentation-site-loader.js +45 -0
  27. package/packages/content-loader/dist/content/git-repo-loader.d.ts +79 -0
  28. package/packages/content-loader/dist/content/git-repo-loader.js +368 -0
  29. package/packages/content-loader/dist/content/index.d.ts +9 -0
  30. package/packages/content-loader/dist/content/index.js +9 -0
  31. package/packages/content-loader/dist/content/loader.d.ts +47 -0
  32. package/packages/content-loader/dist/content/loader.js +8 -0
  33. package/packages/content-loader/dist/content/metadata-manager.d.ts +65 -0
  34. package/packages/content-loader/dist/content/metadata-manager.js +160 -0
  35. package/packages/content-loader/dist/index.d.ts +5 -0
  36. package/packages/content-loader/dist/index.js +5 -0
  37. package/packages/content-loader/dist/types.d.ts +127 -0
  38. package/packages/content-loader/dist/types.js +48 -0
  39. package/packages/content-loader/package.json +50 -0
  40. package/packages/core/dist/config/discovery.d.ts +15 -0
  41. package/packages/core/dist/config/discovery.js +65 -0
  42. package/packages/core/dist/config/loader.d.ts +22 -0
  43. package/packages/core/dist/config/loader.js +236 -0
  44. package/packages/core/dist/config/manager.d.ts +55 -0
  45. package/packages/core/dist/config/manager.js +180 -0
  46. package/packages/core/dist/content/api-documentation-loader.d.ts +26 -0
  47. package/packages/core/dist/content/api-documentation-loader.js +45 -0
  48. package/packages/core/dist/content/content-processor.d.ts +44 -0
  49. package/packages/core/dist/content/content-processor.js +81 -0
  50. package/packages/core/dist/content/documentation-site-loader.d.ts +26 -0
  51. package/packages/core/dist/content/documentation-site-loader.js +45 -0
  52. package/packages/core/dist/content/git-repo-loader.d.ts +54 -0
  53. package/packages/core/dist/content/git-repo-loader.js +264 -0
  54. package/packages/core/dist/content/index.d.ts +9 -0
  55. package/packages/core/dist/content/index.js +9 -0
  56. package/packages/core/dist/content/loader.d.ts +50 -0
  57. package/packages/core/dist/content/loader.js +7 -0
  58. package/packages/core/dist/content/metadata-manager.d.ts +65 -0
  59. package/packages/core/dist/content/metadata-manager.js +160 -0
  60. package/packages/core/dist/index.d.ts +12 -0
  61. package/packages/core/dist/index.js +30 -0
  62. package/packages/core/dist/paths/calculator.d.ts +46 -0
  63. package/packages/core/dist/paths/calculator.js +166 -0
  64. package/packages/core/dist/templates/processor.d.ts +40 -0
  65. package/packages/core/dist/templates/processor.js +111 -0
  66. package/packages/core/dist/types.d.ts +129 -0
  67. package/packages/core/dist/types.js +79 -0
  68. package/packages/core/package.json +50 -0
  69. package/packages/mcp-server/dist/bin.d.ts +5 -0
  70. package/packages/mcp-server/dist/bin.js +10 -0
  71. package/packages/mcp-server/dist/cli.d.ts +7 -0
  72. package/packages/mcp-server/dist/cli.js +17 -0
  73. package/packages/mcp-server/dist/index.d.ts +8 -0
  74. package/packages/mcp-server/dist/index.js +9 -0
  75. package/packages/mcp-server/dist/server.d.ts +35 -0
  76. package/packages/mcp-server/dist/server.js +244 -0
  77. package/packages/mcp-server/package.json +54 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @codemcp/knowledge-core
3
+ *
4
+ * Core functionality for the agentic knowledge guidance system.
5
+ * Provides configuration discovery, path calculation, and template processing.
6
+ */
7
+ // Export all types and interfaces
8
+ export * from "./types.js";
9
+ // Export configuration functionality
10
+ export { findConfigPath, findConfigPathSync } from "./config/discovery.js";
11
+ export { loadConfig, loadConfigSync, validateConfig } from "./config/loader.js";
12
+ export { ConfigManager } from "./config/manager.js";
13
+ // Export path calculation utilities
14
+ export {
15
+ calculateLocalPath,
16
+ formatPath,
17
+ validatePath,
18
+ validatePathSync,
19
+ getRelativePath,
20
+ ensureKnowledgeGitignore,
21
+ ensureKnowledgeGitignoreSync,
22
+ } from "./paths/calculator.js";
23
+ // Export template processing
24
+ export {
25
+ processTemplate,
26
+ getEffectiveTemplate,
27
+ validateTemplate,
28
+ extractVariables,
29
+ createTemplateContext,
30
+ } from "./templates/processor.js";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Path calculation utilities
3
+ */
4
+ import type { DocsetConfig } from "../types.js";
5
+ /**
6
+ * Calculate the local path for a docset
7
+ * @param docset - Docset configuration
8
+ * @param configPath - Path to the configuration file
9
+ * @returns Calculated local path
10
+ */
11
+ export declare function calculateLocalPath(docset: DocsetConfig, configPath: string): string;
12
+ /**
13
+ * Ensure .knowledge/.gitignore exists with docsets/ ignored
14
+ * @param configPath - Path to the configuration file
15
+ */
16
+ export declare function ensureKnowledgeGitignore(configPath: string): Promise<void>;
17
+ /**
18
+ * Synchronous version of ensureKnowledgeGitignore
19
+ * @param configPath - Path to the configuration file
20
+ */
21
+ export declare function ensureKnowledgeGitignoreSync(configPath: string): void;
22
+ /**
23
+ * Format a path for use in instructions (normalize separators, etc.)
24
+ * @param path - Path to format
25
+ * @returns Formatted path
26
+ */
27
+ export declare function formatPath(path: string): string;
28
+ /**
29
+ * Validate that a path is accessible and exists
30
+ * @param path - Path to validate
31
+ * @returns True if path exists and is accessible
32
+ */
33
+ export declare function validatePath(path: string): Promise<boolean>;
34
+ /**
35
+ * Synchronous version of validatePath
36
+ * @param path - Path to validate
37
+ * @returns True if path exists and is accessible
38
+ */
39
+ export declare function validatePathSync(path: string): boolean;
40
+ /**
41
+ * Get relative path from one location to another (useful for instructions)
42
+ * @param from - Starting path
43
+ * @param to - Target path
44
+ * @returns Relative path from 'from' to 'to'
45
+ */
46
+ export declare function getRelativePath(from: string, to: string): string;
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Path calculation utilities
3
+ */
4
+ import { resolve, dirname, isAbsolute, join, normalize } from "node:path";
5
+ import { promises as fs } from "node:fs";
6
+ import * as fsSync from "node:fs";
7
+ import * as pathModule from "node:path";
8
+ import { KnowledgeError, ErrorType } from "../types.js";
9
+ /**
10
+ * Calculate the local path for a docset
11
+ * @param docset - Docset configuration
12
+ * @param configPath - Path to the configuration file
13
+ * @returns Calculated local path
14
+ */
15
+ export function calculateLocalPath(docset, configPath) {
16
+ try {
17
+ const configDir = dirname(configPath); // This is the .knowledge directory
18
+ // For docsets with web sources, use standardized path: .knowledge/docsets/{id}
19
+ if (docset.web_sources && docset.web_sources.length > 0) {
20
+ return join(configDir, "docsets", docset.id);
21
+ }
22
+ // For traditional local docsets, use the configured local_path
23
+ if (!docset.local_path) {
24
+ throw new Error(
25
+ "Docset must have either web_sources or local_path configured",
26
+ );
27
+ }
28
+ const projectRoot = dirname(configDir); // This is the project root
29
+ // If the path is absolute, use it as-is
30
+ if (isAbsolute(docset.local_path)) {
31
+ return normalize(docset.local_path);
32
+ }
33
+ // If relative, resolve relative to project root directory
34
+ const resolvedPath = resolve(projectRoot, docset.local_path);
35
+ return normalize(resolvedPath);
36
+ } catch (error) {
37
+ throw new KnowledgeError(
38
+ ErrorType.PATH_INVALID,
39
+ `Failed to calculate local path for docset '${docset.id}': ${error.message}`,
40
+ { docset, configPath, error },
41
+ );
42
+ }
43
+ }
44
+ /**
45
+ * Ensure .knowledge/.gitignore exists with docsets/ ignored
46
+ * @param configPath - Path to the configuration file
47
+ */
48
+ export async function ensureKnowledgeGitignore(configPath) {
49
+ try {
50
+ const configDir = dirname(configPath);
51
+ const gitignorePath = join(configDir, ".gitignore");
52
+ // Check if .gitignore already exists
53
+ try {
54
+ const content = await fs.readFile(gitignorePath, "utf-8");
55
+ // Check if it already contains docsets/ ignore rule
56
+ if (content.includes("docsets/")) {
57
+ return; // Already configured
58
+ }
59
+ // Append to existing file
60
+ await fs.appendFile(
61
+ gitignorePath,
62
+ "\n# Agentic Knowledge - Downloaded docsets\ndocsets/\n",
63
+ );
64
+ } catch (error) {
65
+ // File doesn't exist, create it
66
+ if (error.code === "ENOENT") {
67
+ await fs.writeFile(
68
+ gitignorePath,
69
+ "# Agentic Knowledge - Downloaded docsets\ndocsets/\n",
70
+ );
71
+ } else {
72
+ throw error;
73
+ }
74
+ }
75
+ } catch (error) {
76
+ // Don't fail the entire operation if gitignore creation fails
77
+ console.warn(
78
+ `Warning: Could not create .knowledge/.gitignore: ${error.message}`,
79
+ );
80
+ }
81
+ }
82
+ /**
83
+ * Synchronous version of ensureKnowledgeGitignore
84
+ * @param configPath - Path to the configuration file
85
+ */
86
+ export function ensureKnowledgeGitignoreSync(configPath) {
87
+ try {
88
+ const configDir = dirname(configPath);
89
+ const gitignorePath = join(configDir, ".gitignore");
90
+ // Check if .gitignore already exists
91
+ try {
92
+ const content = fsSync.readFileSync(gitignorePath, "utf-8");
93
+ // Check if it already contains docsets/ ignore rule
94
+ if (content.includes("docsets/")) {
95
+ return; // Already configured
96
+ }
97
+ // Append to existing file
98
+ fsSync.appendFileSync(
99
+ gitignorePath,
100
+ "\n# Agentic Knowledge - Downloaded docsets\ndocsets/\n",
101
+ );
102
+ } catch (error) {
103
+ // File doesn't exist, create it
104
+ if (error.code === "ENOENT") {
105
+ fsSync.writeFileSync(
106
+ gitignorePath,
107
+ "# Agentic Knowledge - Downloaded docsets\ndocsets/\n",
108
+ );
109
+ } else {
110
+ throw error;
111
+ }
112
+ }
113
+ } catch (error) {
114
+ // Don't fail the entire operation if gitignore creation fails
115
+ console.warn(
116
+ `Warning: Could not create .knowledge/.gitignore: ${error.message}`,
117
+ );
118
+ }
119
+ }
120
+ /**
121
+ * Format a path for use in instructions (normalize separators, etc.)
122
+ * @param path - Path to format
123
+ * @returns Formatted path
124
+ */
125
+ export function formatPath(path) {
126
+ // Normalize path separators and remove redundant separators
127
+ const normalized = normalize(path);
128
+ // Ensure path ends with separator for directory paths (if it looks like a directory)
129
+ // This helps with search instructions that need to specify directories
130
+ return normalized;
131
+ }
132
+ /**
133
+ * Validate that a path is accessible and exists
134
+ * @param path - Path to validate
135
+ * @returns True if path exists and is accessible
136
+ */
137
+ export async function validatePath(path) {
138
+ try {
139
+ await fs.access(path);
140
+ return true;
141
+ } catch {
142
+ return false;
143
+ }
144
+ }
145
+ /**
146
+ * Synchronous version of validatePath
147
+ * @param path - Path to validate
148
+ * @returns True if path exists and is accessible
149
+ */
150
+ export function validatePathSync(path) {
151
+ try {
152
+ fsSync.accessSync(path);
153
+ return true;
154
+ } catch {
155
+ return false;
156
+ }
157
+ }
158
+ /**
159
+ * Get relative path from one location to another (useful for instructions)
160
+ * @param from - Starting path
161
+ * @param to - Target path
162
+ * @returns Relative path from 'from' to 'to'
163
+ */
164
+ export function getRelativePath(from, to) {
165
+ return pathModule.relative(from, to);
166
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Template processing functionality
3
+ */
4
+ import type { TemplateContext, DocsetConfig } from "../types.js";
5
+ /**
6
+ * Process a template with variable substitution
7
+ * @param template - Template string with variables
8
+ * @param context - Context data for substitution
9
+ * @returns Processed template string
10
+ */
11
+ export declare function processTemplate(template: string, context: TemplateContext): string;
12
+ /**
13
+ * Get the effective template for a docset (docset template or global template or default)
14
+ * @param docset - Docset configuration
15
+ * @param globalTemplate - Global template from config (optional)
16
+ * @returns Template string to use
17
+ */
18
+ export declare function getEffectiveTemplate(docset: DocsetConfig, globalTemplate?: string): string;
19
+ /**
20
+ * Validate that a template contains only allowed variables and has required variables
21
+ * This is called during configuration loading to fail fast on invalid templates
22
+ * @param template - Template string to validate
23
+ * @returns True if template is valid, throws KnowledgeError if invalid
24
+ */
25
+ export declare function validateTemplate(template: string): boolean;
26
+ /**
27
+ * Extract variable names from a template
28
+ * @param template - Template string
29
+ * @returns Array of variable names found in the template
30
+ */
31
+ export declare function extractVariables(template: string): string[];
32
+ /**
33
+ * Create template context from search parameters
34
+ * @param localPath - Calculated local path
35
+ * @param keywords - Search keywords
36
+ * @param generalizedKeywords - Generalized keywords
37
+ * @param docset - Docset configuration
38
+ * @returns Template context object
39
+ */
40
+ export declare function createTemplateContext(localPath: string, keywords: string, generalizedKeywords: string, docset: DocsetConfig): TemplateContext;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Template processing functionality
3
+ */
4
+ import { KnowledgeError, ErrorType, DEFAULT_TEMPLATE, ALLOWED_TEMPLATE_VARIABLES, REQUIRED_TEMPLATE_VARIABLES, } from "../types.js";
5
+ /**
6
+ * Process a template with variable substitution
7
+ * @param template - Template string with variables
8
+ * @param context - Context data for substitution
9
+ * @returns Processed template string
10
+ */
11
+ export function processTemplate(template, context) {
12
+ try {
13
+ let processed = template;
14
+ // Replace template variables using double curly brace syntax
15
+ const variables = {
16
+ local_path: context.local_path,
17
+ keywords: context.keywords,
18
+ generalized_keywords: context.generalized_keywords,
19
+ docset_id: context.docset.id,
20
+ docset_name: context.docset.name,
21
+ docset_description: context.docset.description || "",
22
+ };
23
+ // Replace each variable
24
+ for (const [key, value] of Object.entries(variables)) {
25
+ const regex = new RegExp(`\\{\\{\\s*${key}\\s*\\}\\}`, "g");
26
+ processed = processed.replace(regex, value);
27
+ }
28
+ // Check for unreplaced variables - this should never happen in production
29
+ // because templates are validated at startup
30
+ const unreplacedMatches = processed.match(/\{\{[^}]+\}\}/g);
31
+ if (unreplacedMatches) {
32
+ throw new KnowledgeError(ErrorType.TEMPLATE_ERROR, `Template contains invalid variables: ${unreplacedMatches.join(", ")}`, { template, unreplacedMatches });
33
+ }
34
+ return processed.trim();
35
+ }
36
+ catch (error) {
37
+ if (error instanceof KnowledgeError) {
38
+ throw error;
39
+ }
40
+ throw new KnowledgeError(ErrorType.TEMPLATE_ERROR, `Failed to process template: ${error.message}`, { template, context, error });
41
+ }
42
+ }
43
+ /**
44
+ * Get the effective template for a docset (docset template or global template or default)
45
+ * @param docset - Docset configuration
46
+ * @param globalTemplate - Global template from config (optional)
47
+ * @returns Template string to use
48
+ */
49
+ export function getEffectiveTemplate(docset, globalTemplate) {
50
+ // Priority: docset template > global template > default template
51
+ return docset.template || globalTemplate || DEFAULT_TEMPLATE;
52
+ }
53
+ /**
54
+ * Validate that a template contains only allowed variables and has required variables
55
+ * This is called during configuration loading to fail fast on invalid templates
56
+ * @param template - Template string to validate
57
+ * @returns True if template is valid, throws KnowledgeError if invalid
58
+ */
59
+ export function validateTemplate(template) {
60
+ // Extract all variables from template
61
+ const variables = extractVariables(template);
62
+ // Check for invalid variables
63
+ const invalidVariables = variables.filter((variable) => !ALLOWED_TEMPLATE_VARIABLES.includes(variable));
64
+ if (invalidVariables.length > 0) {
65
+ throw new KnowledgeError(ErrorType.TEMPLATE_ERROR, `Template contains invalid variables: ${invalidVariables.join(", ")}. Allowed variables: ${ALLOWED_TEMPLATE_VARIABLES.join(", ")}`, {
66
+ template,
67
+ invalidVariables,
68
+ allowedVariables: ALLOWED_TEMPLATE_VARIABLES,
69
+ });
70
+ }
71
+ // Check for required variables
72
+ const missingRequired = REQUIRED_TEMPLATE_VARIABLES.filter((required) => !variables.includes(required));
73
+ if (missingRequired.length > 0) {
74
+ throw new KnowledgeError(ErrorType.TEMPLATE_ERROR, `Template missing required variables: ${missingRequired.join(", ")}. Required variables: ${REQUIRED_TEMPLATE_VARIABLES.join(", ")}`, {
75
+ template,
76
+ missingRequired,
77
+ requiredVariables: REQUIRED_TEMPLATE_VARIABLES,
78
+ });
79
+ }
80
+ return true;
81
+ }
82
+ /**
83
+ * Extract variable names from a template
84
+ * @param template - Template string
85
+ * @returns Array of variable names found in the template
86
+ */
87
+ export function extractVariables(template) {
88
+ const matches = template.match(/\{\{\s*([^}]+)\s*\}\}/g);
89
+ if (!matches)
90
+ return [];
91
+ return matches.map((match) => {
92
+ const varName = match.replace(/\{\{\s*/, "").replace(/\s*\}\}/, "");
93
+ return varName.trim();
94
+ });
95
+ }
96
+ /**
97
+ * Create template context from search parameters
98
+ * @param localPath - Calculated local path
99
+ * @param keywords - Search keywords
100
+ * @param generalizedKeywords - Generalized keywords
101
+ * @param docset - Docset configuration
102
+ * @returns Template context object
103
+ */
104
+ export function createTemplateContext(localPath, keywords, generalizedKeywords, docset) {
105
+ return {
106
+ local_path: localPath,
107
+ keywords,
108
+ generalized_keywords: generalizedKeywords,
109
+ docset,
110
+ };
111
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Core types and interfaces for the agentic knowledge guidance system
3
+ */
4
+ /**
5
+ * Configuration for a single docset
6
+ */
7
+ export interface DocsetConfig {
8
+ /** Unique identifier for the docset */
9
+ id: string;
10
+ /** Human-readable name of the docset */
11
+ name: string;
12
+ /** Description of what this docset contains */
13
+ description?: string;
14
+ /** Path to the documentation (relative to .knowledge folder or absolute) - optional for web sources */
15
+ local_path?: string;
16
+ /** Optional custom instruction template for this docset */
17
+ template?: string;
18
+ /** Optional web sources to load content from */
19
+ web_sources?: WebSourceConfig[];
20
+ }
21
+ /**
22
+ * Basic web source configuration (for core package validation)
23
+ */
24
+ export interface WebSourceConfig {
25
+ /** URL of the web source */
26
+ url: string;
27
+ /** Type of web source */
28
+ type: string;
29
+ /** Type-specific options */
30
+ options?: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * Main configuration structure for the knowledge system
34
+ */
35
+ export interface KnowledgeConfig {
36
+ /** Version of the configuration format */
37
+ version: string;
38
+ /** List of docsets available for search */
39
+ docsets: DocsetConfig[];
40
+ /** Global instruction template (optional) */
41
+ template?: string;
42
+ }
43
+ /**
44
+ * Parameters for the search_docs tool
45
+ */
46
+ export interface SearchDocsParams {
47
+ /** ID of the docset to search */
48
+ docset: string;
49
+ /** Specific keywords to search for */
50
+ keywords: string;
51
+ /** Generalized keywords for broader search context */
52
+ generalized_keywords: string;
53
+ }
54
+ /**
55
+ * Response from the search_docs tool
56
+ */
57
+ export interface SearchDocsResponse {
58
+ /** Instructions for the agent on how to search */
59
+ instructions: string;
60
+ /** The docset that was searched */
61
+ docset: string;
62
+ /** The calculated local path for searching */
63
+ local_path: string;
64
+ /** Keywords that were processed */
65
+ keywords: string;
66
+ /** Generalized keywords that were processed */
67
+ generalized_keywords: string;
68
+ }
69
+ /**
70
+ * Response from the list_docsets tool
71
+ */
72
+ export interface ListDocsetsResponse {
73
+ /** List of available docsets */
74
+ docsets: DocsetConfig[];
75
+ /** Total number of docsets */
76
+ count: number;
77
+ }
78
+ /**
79
+ * Template context for instruction generation
80
+ */
81
+ export interface TemplateContext {
82
+ /** Path to search in */
83
+ local_path: string;
84
+ /** Keywords to search for */
85
+ keywords: string;
86
+ /** Generalized keywords */
87
+ generalized_keywords: string;
88
+ /** Docset information */
89
+ docset: DocsetConfig;
90
+ }
91
+ /**
92
+ * Error types that can occur in the core system
93
+ */
94
+ export declare enum ErrorType {
95
+ CONFIG_NOT_FOUND = "CONFIG_NOT_FOUND",
96
+ CONFIG_INVALID = "CONFIG_INVALID",
97
+ DOCSET_NOT_FOUND = "DOCSET_NOT_FOUND",
98
+ PATH_INVALID = "PATH_INVALID",
99
+ TEMPLATE_ERROR = "TEMPLATE_ERROR",
100
+ YAML_PARSE_ERROR = "YAML_PARSE_ERROR"
101
+ }
102
+ /**
103
+ * Custom error class for knowledge system errors
104
+ */
105
+ export declare class KnowledgeError extends Error {
106
+ type: ErrorType;
107
+ context?: Record<string, unknown> | undefined;
108
+ constructor(type: ErrorType, message: string, context?: Record<string, unknown> | undefined);
109
+ }
110
+ /**
111
+ * Default instruction template
112
+ */
113
+ export declare const DEFAULT_TEMPLATE = "# \uD83D\uDCDA Search {{docset_name}} Documentation\n\n**Primary terms:** {{keywords}} \n**Related terms:** {{generalized_keywords}} \n**Location:** {{local_path}}\n\n## \uD83D\uDD0D Search Strategy\n\n### 1. **Start with Specific Terms**\nUse your text search tools (grep, rg, ripgrep) to search for: `{{keywords}}`\n\n### 2. **Expand to Related Terms**\nIf initial search doesn't yield results, try: `{{generalized_keywords}}`\n\n### 3. **What to Avoid**\nSkip these directories to save time:\n- `node_modules/`, `.git/`, `.knowledge/`\n- `build/`, `dist/`, `target/`, `vendor/`\n\n## \uD83D\uDCA1 Search Tips\n- Use **case-insensitive** search when possible\n- Look for **exact matches first**, then partial matches\n- Check **cross-references** and `See also` sections\n- If stuck, try **broader terms** or ask the user to clarify\n";
114
+ /**
115
+ * Allowed template variables that can be used in instruction templates
116
+ */
117
+ export declare const ALLOWED_TEMPLATE_VARIABLES: readonly ["local_path", "keywords", "generalized_keywords", "docset_id", "docset_name", "docset_description"];
118
+ /**
119
+ * Required template variables that must be present in every template
120
+ */
121
+ export declare const REQUIRED_TEMPLATE_VARIABLES: readonly ["local_path", "keywords"];
122
+ /**
123
+ * Configuration file name pattern
124
+ */
125
+ export declare const CONFIG_FILENAME = "config.yaml";
126
+ /**
127
+ * Configuration directory name
128
+ */
129
+ export declare const CONFIG_DIR = ".knowledge";
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Core types and interfaces for the agentic knowledge guidance system
3
+ */
4
+ /**
5
+ * Error types that can occur in the core system
6
+ */
7
+ export var ErrorType;
8
+ (function (ErrorType) {
9
+ ErrorType["CONFIG_NOT_FOUND"] = "CONFIG_NOT_FOUND";
10
+ ErrorType["CONFIG_INVALID"] = "CONFIG_INVALID";
11
+ ErrorType["DOCSET_NOT_FOUND"] = "DOCSET_NOT_FOUND";
12
+ ErrorType["PATH_INVALID"] = "PATH_INVALID";
13
+ ErrorType["TEMPLATE_ERROR"] = "TEMPLATE_ERROR";
14
+ ErrorType["YAML_PARSE_ERROR"] = "YAML_PARSE_ERROR";
15
+ })(ErrorType || (ErrorType = {}));
16
+ /**
17
+ * Custom error class for knowledge system errors
18
+ */
19
+ export class KnowledgeError extends Error {
20
+ type;
21
+ context;
22
+ constructor(type, message, context) {
23
+ super(message);
24
+ this.type = type;
25
+ this.context = context;
26
+ this.name = "KnowledgeError";
27
+ }
28
+ }
29
+ /**
30
+ * Default instruction template
31
+ */
32
+ export const DEFAULT_TEMPLATE = `# 📚 Search {{docset_name}} Documentation
33
+
34
+ **Primary terms:** {{keywords}}
35
+ **Related terms:** {{generalized_keywords}}
36
+ **Location:** {{local_path}}
37
+
38
+ ## 🔍 Search Strategy
39
+
40
+ ### 1. **Start with Specific Terms**
41
+ Use your text search tools (grep, rg, ripgrep) to search for: \`{{keywords}}\`
42
+
43
+ ### 2. **Expand to Related Terms**
44
+ If initial search doesn't yield results, try: \`{{generalized_keywords}}\`
45
+
46
+ ### 3. **What to Avoid**
47
+ Skip these directories to save time:
48
+ - \`node_modules/\`, \`.git/\`, \`.knowledge/\`
49
+ - \`build/\`, \`dist/\`, \`target/\`, \`vendor/\`
50
+
51
+ ## 💡 Search Tips
52
+ - Use **case-insensitive** search when possible
53
+ - Look for **exact matches first**, then partial matches
54
+ - Check **cross-references** and \`See also\` sections
55
+ - If stuck, try **broader terms** or ask the user to clarify
56
+ `;
57
+ /**
58
+ * Allowed template variables that can be used in instruction templates
59
+ */
60
+ export const ALLOWED_TEMPLATE_VARIABLES = [
61
+ "local_path",
62
+ "keywords",
63
+ "generalized_keywords",
64
+ "docset_id",
65
+ "docset_name",
66
+ "docset_description",
67
+ ];
68
+ /**
69
+ * Required template variables that must be present in every template
70
+ */
71
+ export const REQUIRED_TEMPLATE_VARIABLES = ["local_path", "keywords"];
72
+ /**
73
+ * Configuration file name pattern
74
+ */
75
+ export const CONFIG_FILENAME = "config.yaml";
76
+ /**
77
+ * Configuration directory name
78
+ */
79
+ export const CONFIG_DIR = ".knowledge";
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@codemcp/knowledge-core",
3
+ "version": "0.0.1",
4
+ "description": "Core functionality for agentic knowledge guidance system",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.build.json",
19
+ "build:watch": "tsc -p tsconfig.build.json --watch",
20
+ "clean": "rimraf dist",
21
+ "dev": "tsc -p tsconfig.build.json --watch",
22
+ "lint": "oxlint && eslint .",
23
+ "lint:fix": "oxlint --fix && eslint . --fix",
24
+ "format:check": "prettier --check .",
25
+ "format:fix": "prettier --write .",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "test:coverage": "vitest run --coverage",
29
+ "typecheck": "tsc --noEmit"
30
+ },
31
+ "dependencies": {
32
+ "js-yaml": "^4.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/js-yaml": "^4.0.9",
36
+ "@types/node": "^24.3.0",
37
+ "rimraf": "^6.0.1",
38
+ "typescript": "^5.9.2",
39
+ "vitest": "^3.2.4"
40
+ },
41
+ "keywords": [
42
+ "agentic",
43
+ "knowledge",
44
+ "configuration",
45
+ "path-calculation",
46
+ "templates"
47
+ ],
48
+ "author": "Oliver Jägle <github@beimir.net>",
49
+ "license": "MIT"
50
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Binary entry point for the agentic-knowledge MCP server
4
+ */
5
+ export {};
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Binary entry point for the agentic-knowledge MCP server
4
+ */
5
+ import { startServer } from "./cli.js";
6
+ // Start the server
7
+ startServer().catch((error) => {
8
+ console.error("Failed to start agentic-knowledge server:", error);
9
+ process.exit(1);
10
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * CLI functionality for the MCP server
3
+ */
4
+ /**
5
+ * Start the agentic knowledge MCP server from CLI
6
+ */
7
+ export declare function startServer(): Promise<void>;