ai-prompt-guide-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +271 -0
- package/dist/__tests__/config-loading.test.d.ts +5 -0
- package/dist/__tests__/config-loading.test.d.ts.map +1 -0
- package/dist/__tests__/config-loading.test.js +127 -0
- package/dist/__tests__/config-loading.test.js.map +1 -0
- package/dist/__tests__/config-logging.test.d.ts +5 -0
- package/dist/__tests__/config-logging.test.d.ts.map +1 -0
- package/dist/__tests__/config-logging.test.js +146 -0
- package/dist/__tests__/config-logging.test.js.map +1 -0
- package/dist/__tests__/config-path-resolution.test.d.ts +5 -0
- package/dist/__tests__/config-path-resolution.test.d.ts.map +1 -0
- package/dist/__tests__/config-path-resolution.test.js +88 -0
- package/dist/__tests__/config-path-resolution.test.js.map +1 -0
- package/dist/__tests__/config-path-validation.test.d.ts +6 -0
- package/dist/__tests__/config-path-validation.test.d.ts.map +1 -0
- package/dist/__tests__/config-path-validation.test.js +203 -0
- package/dist/__tests__/config-path-validation.test.js.map +1 -0
- package/dist/__tests__/config-precedence.test.d.ts +5 -0
- package/dist/__tests__/config-precedence.test.d.ts.map +1 -0
- package/dist/__tests__/config-precedence.test.js +200 -0
- package/dist/__tests__/config-precedence.test.js.map +1 -0
- package/dist/__tests__/config-types.test.d.ts +5 -0
- package/dist/__tests__/config-types.test.d.ts.map +1 -0
- package/dist/__tests__/config-types.test.js +189 -0
- package/dist/__tests__/config-types.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +5 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +229 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/config.d.ts +87 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +498 -0
- package/dist/config.js.map +1 -0
- package/dist/constants/defaults.d.ts +78 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +78 -0
- package/dist/constants/defaults.js.map +1 -0
- package/dist/document-cache.d.ts +485 -0
- package/dist/document-cache.d.ts.map +1 -0
- package/dist/document-cache.hierarchical.test.d.ts +2 -0
- package/dist/document-cache.hierarchical.test.d.ts.map +1 -0
- package/dist/document-cache.hierarchical.test.js +243 -0
- package/dist/document-cache.hierarchical.test.js.map +1 -0
- package/dist/document-cache.js +965 -0
- package/dist/document-cache.js.map +1 -0
- package/dist/document-cache.test.d.ts +8 -0
- package/dist/document-cache.test.d.ts.map +1 -0
- package/dist/document-cache.test.js +624 -0
- package/dist/document-cache.test.js.map +1 -0
- package/dist/document-manager.d.ts +252 -0
- package/dist/document-manager.d.ts.map +1 -0
- package/dist/document-manager.js +760 -0
- package/dist/document-manager.js.map +1 -0
- package/dist/document-manager.race-condition.test.d.ts +8 -0
- package/dist/document-manager.race-condition.test.d.ts.map +1 -0
- package/dist/document-manager.race-condition.test.js +139 -0
- package/dist/document-manager.race-condition.test.js.map +1 -0
- package/dist/fingerprint-index.d.ts +177 -0
- package/dist/fingerprint-index.d.ts.map +1 -0
- package/dist/fingerprint-index.js +374 -0
- package/dist/fingerprint-index.js.map +1 -0
- package/dist/fingerprint-index.test.d.ts +15 -0
- package/dist/fingerprint-index.test.d.ts.map +1 -0
- package/dist/fingerprint-index.test.js +482 -0
- package/dist/fingerprint-index.test.js.map +1 -0
- package/dist/fsio.d.ts +76 -0
- package/dist/fsio.d.ts.map +1 -0
- package/dist/fsio.js +506 -0
- package/dist/fsio.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown-tools.test.d.ts +5 -0
- package/dist/markdown-tools.test.d.ts.map +1 -0
- package/dist/markdown-tools.test.js +200 -0
- package/dist/markdown-tools.test.js.map +1 -0
- package/dist/parse.d.ts +19 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +144 -0
- package/dist/parse.js.map +1 -0
- package/dist/prompts/__tests__/prompt-loader.test.d.ts +5 -0
- package/dist/prompts/__tests__/prompt-loader.test.d.ts.map +1 -0
- package/dist/prompts/__tests__/prompt-loader.test.js +300 -0
- package/dist/prompts/__tests__/prompt-loader.test.js.map +1 -0
- package/dist/prompts/prompt-loader.d.ts +58 -0
- package/dist/prompts/prompt-loader.d.ts.map +1 -0
- package/dist/prompts/prompt-loader.js +215 -0
- package/dist/prompts/prompt-loader.js.map +1 -0
- package/dist/prompts/prompt-validator.d.ts +30 -0
- package/dist/prompts/prompt-validator.d.ts.map +1 -0
- package/dist/prompts/prompt-validator.js +65 -0
- package/dist/prompts/prompt-validator.js.map +1 -0
- package/dist/prompts/types.d.ts +46 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +14 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/prompts/workflow-prompts.d.ts +42 -0
- package/dist/prompts/workflow-prompts.d.ts.map +1 -0
- package/dist/prompts/workflow-prompts.js +61 -0
- package/dist/prompts/workflow-prompts.js.map +1 -0
- package/dist/sections.d.ts +67 -0
- package/dist/sections.d.ts.map +1 -0
- package/dist/sections.hierarchical.test.d.ts +8 -0
- package/dist/sections.hierarchical.test.d.ts.map +1 -0
- package/dist/sections.hierarchical.test.js +397 -0
- package/dist/sections.hierarchical.test.js.map +1 -0
- package/dist/sections.js +1229 -0
- package/dist/sections.js.map +1 -0
- package/dist/server/default-dependencies.d.ts +134 -0
- package/dist/server/default-dependencies.d.ts.map +1 -0
- package/dist/server/default-dependencies.js +176 -0
- package/dist/server/default-dependencies.js.map +1 -0
- package/dist/server/dependencies.d.ts +161 -0
- package/dist/server/dependencies.d.ts.map +1 -0
- package/dist/server/dependencies.js +50 -0
- package/dist/server/dependencies.js.map +1 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +9 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middleware/error-handling.d.ts +52 -0
- package/dist/server/middleware/error-handling.d.ts.map +1 -0
- package/dist/server/middleware/error-handling.js +76 -0
- package/dist/server/middleware/error-handling.js.map +1 -0
- package/dist/server/middleware/index.d.ts +7 -0
- package/dist/server/middleware/index.d.ts.map +1 -0
- package/dist/server/middleware/index.js +7 -0
- package/dist/server/middleware/index.js.map +1 -0
- package/dist/server/middleware/logging.d.ts +29 -0
- package/dist/server/middleware/logging.d.ts.map +1 -0
- package/dist/server/middleware/logging.js +49 -0
- package/dist/server/middleware/logging.js.map +1 -0
- package/dist/server/middleware/session-management.d.ts +38 -0
- package/dist/server/middleware/session-management.d.ts.map +1 -0
- package/dist/server/middleware/session-management.js +66 -0
- package/dist/server/middleware/session-management.js.map +1 -0
- package/dist/server/request-handlers/index.d.ts +5 -0
- package/dist/server/request-handlers/index.d.ts.map +1 -0
- package/dist/server/request-handlers/index.js +5 -0
- package/dist/server/request-handlers/index.js.map +1 -0
- package/dist/server/request-handlers/prompt-handlers.d.ts +13 -0
- package/dist/server/request-handlers/prompt-handlers.d.ts.map +1 -0
- package/dist/server/request-handlers/prompt-handlers.js +80 -0
- package/dist/server/request-handlers/prompt-handlers.js.map +1 -0
- package/dist/server/request-handlers/tool-handlers.d.ts +11 -0
- package/dist/server/request-handlers/tool-handlers.d.ts.map +1 -0
- package/dist/server/request-handlers/tool-handlers.js +85 -0
- package/dist/server/request-handlers/tool-handlers.js.map +1 -0
- package/dist/server/server-factory.d.ts +68 -0
- package/dist/server/server-factory.d.ts.map +1 -0
- package/dist/server/server-factory.js +135 -0
- package/dist/server/server-factory.js.map +1 -0
- package/dist/server/transport/stdio-transport.d.ts +9 -0
- package/dist/server/transport/stdio-transport.d.ts.map +1 -0
- package/dist/server/transport/stdio-transport.js +11 -0
- package/dist/server/transport/stdio-transport.js.map +1 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +7 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/session-store.d.ts +74 -0
- package/dist/session/session-store.d.ts.map +1 -0
- package/dist/session/session-store.js +150 -0
- package/dist/session/session-store.js.map +1 -0
- package/dist/session/types.d.ts +96 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +9 -0
- package/dist/session/types.js.map +1 -0
- package/dist/shared/__tests__/addressing-system.batch-cache.test.d.ts +12 -0
- package/dist/shared/__tests__/addressing-system.batch-cache.test.d.ts.map +1 -0
- package/dist/shared/__tests__/addressing-system.batch-cache.test.js +306 -0
- package/dist/shared/__tests__/addressing-system.batch-cache.test.js.map +1 -0
- package/dist/shared/__tests__/addressing-system.hierarchical.test.d.ts +6 -0
- package/dist/shared/__tests__/addressing-system.hierarchical.test.d.ts.map +1 -0
- package/dist/shared/__tests__/addressing-system.hierarchical.test.js +205 -0
- package/dist/shared/__tests__/addressing-system.hierarchical.test.js.map +1 -0
- package/dist/shared/__tests__/addressing-system.lru.test.d.ts +6 -0
- package/dist/shared/__tests__/addressing-system.lru.test.d.ts.map +1 -0
- package/dist/shared/__tests__/addressing-system.lru.test.js +159 -0
- package/dist/shared/__tests__/addressing-system.lru.test.js.map +1 -0
- package/dist/shared/__tests__/addressing-system.relative-paths.test.d.ts +14 -0
- package/dist/shared/__tests__/addressing-system.relative-paths.test.d.ts.map +1 -0
- package/dist/shared/__tests__/addressing-system.relative-paths.test.js +249 -0
- package/dist/shared/__tests__/addressing-system.relative-paths.test.js.map +1 -0
- package/dist/shared/__tests__/document-analysis-enhanced.test.d.ts +9 -0
- package/dist/shared/__tests__/document-analysis-enhanced.test.d.ts.map +1 -0
- package/dist/shared/__tests__/document-analysis-enhanced.test.js +419 -0
- package/dist/shared/__tests__/document-analysis-enhanced.test.js.map +1 -0
- package/dist/shared/__tests__/document-analysis.test.d.ts +8 -0
- package/dist/shared/__tests__/document-analysis.test.d.ts.map +1 -0
- package/dist/shared/__tests__/document-analysis.test.js +904 -0
- package/dist/shared/__tests__/document-analysis.test.js.map +1 -0
- package/dist/shared/__tests__/keyword-utils-integration.test.d.ts +9 -0
- package/dist/shared/__tests__/keyword-utils-integration.test.d.ts.map +1 -0
- package/dist/shared/__tests__/keyword-utils-integration.test.js +317 -0
- package/dist/shared/__tests__/keyword-utils-integration.test.js.map +1 -0
- package/dist/shared/__tests__/link-utils.test.d.ts +5 -0
- package/dist/shared/__tests__/link-utils.test.d.ts.map +1 -0
- package/dist/shared/__tests__/link-utils.test.js +560 -0
- package/dist/shared/__tests__/link-utils.test.js.map +1 -0
- package/dist/shared/__tests__/link-validation.test.d.ts +5 -0
- package/dist/shared/__tests__/link-validation.test.d.ts.map +1 -0
- package/dist/shared/__tests__/link-validation.test.js +473 -0
- package/dist/shared/__tests__/link-validation.test.js.map +1 -0
- package/dist/shared/__tests__/reference-extractor.test.d.ts +8 -0
- package/dist/shared/__tests__/reference-extractor.test.d.ts.map +1 -0
- package/dist/shared/__tests__/reference-extractor.test.js +260 -0
- package/dist/shared/__tests__/reference-extractor.test.js.map +1 -0
- package/dist/shared/__tests__/reference-loader.test.d.ts +8 -0
- package/dist/shared/__tests__/reference-loader.test.d.ts.map +1 -0
- package/dist/shared/__tests__/reference-loader.test.js +622 -0
- package/dist/shared/__tests__/reference-loader.test.js.map +1 -0
- package/dist/shared/__tests__/section-operations.append.test.d.ts +8 -0
- package/dist/shared/__tests__/section-operations.append.test.d.ts.map +1 -0
- package/dist/shared/__tests__/section-operations.append.test.js +150 -0
- package/dist/shared/__tests__/section-operations.append.test.js.map +1 -0
- package/dist/shared/__tests__/section-operations.test.d.ts +7 -0
- package/dist/shared/__tests__/section-operations.test.d.ts.map +1 -0
- package/dist/shared/__tests__/section-operations.test.js +118 -0
- package/dist/shared/__tests__/section-operations.test.js.map +1 -0
- package/dist/shared/__tests__/slug-utils.test.d.ts +5 -0
- package/dist/shared/__tests__/slug-utils.test.d.ts.map +1 -0
- package/dist/shared/__tests__/slug-utils.test.js +542 -0
- package/dist/shared/__tests__/slug-utils.test.js.map +1 -0
- package/dist/shared/__tests__/task-operations.test.d.ts +9 -0
- package/dist/shared/__tests__/task-operations.test.d.ts.map +1 -0
- package/dist/shared/__tests__/task-operations.test.js +257 -0
- package/dist/shared/__tests__/task-operations.test.js.map +1 -0
- package/dist/shared/__tests__/task-validation.test.d.ts +6 -0
- package/dist/shared/__tests__/task-validation.test.d.ts.map +1 -0
- package/dist/shared/__tests__/task-validation.test.js +129 -0
- package/dist/shared/__tests__/task-validation.test.js.map +1 -0
- package/dist/shared/__tests__/task-view-utilities.test.d.ts +5 -0
- package/dist/shared/__tests__/task-view-utilities.test.d.ts.map +1 -0
- package/dist/shared/__tests__/task-view-utilities.test.js +312 -0
- package/dist/shared/__tests__/task-view-utilities.test.js.map +1 -0
- package/dist/shared/__tests__/tool-integration.array-validation.test.d.ts +7 -0
- package/dist/shared/__tests__/tool-integration.array-validation.test.d.ts.map +1 -0
- package/dist/shared/__tests__/tool-integration.array-validation.test.js +169 -0
- package/dist/shared/__tests__/tool-integration.array-validation.test.js.map +1 -0
- package/dist/shared/__tests__/tool-integration.hierarchical.test.d.ts +7 -0
- package/dist/shared/__tests__/tool-integration.hierarchical.test.d.ts.map +1 -0
- package/dist/shared/__tests__/tool-integration.hierarchical.test.js +204 -0
- package/dist/shared/__tests__/tool-integration.hierarchical.test.js.map +1 -0
- package/dist/shared/__tests__/workflow-prompt-utilities.test.d.ts +8 -0
- package/dist/shared/__tests__/workflow-prompt-utilities.test.d.ts.map +1 -0
- package/dist/shared/__tests__/workflow-prompt-utilities.test.js +722 -0
- package/dist/shared/__tests__/workflow-prompt-utilities.test.js.map +1 -0
- package/dist/shared/addressing-system.d.ts +799 -0
- package/dist/shared/addressing-system.d.ts.map +1 -0
- package/dist/shared/addressing-system.js +1074 -0
- package/dist/shared/addressing-system.js.map +1 -0
- package/dist/shared/document-analysis/__tests__/keyword-utils.test.d.ts +8 -0
- package/dist/shared/document-analysis/__tests__/keyword-utils.test.d.ts.map +1 -0
- package/dist/shared/document-analysis/__tests__/keyword-utils.test.js +601 -0
- package/dist/shared/document-analysis/__tests__/keyword-utils.test.js.map +1 -0
- package/dist/shared/document-analysis/index.d.ts +67 -0
- package/dist/shared/document-analysis/index.d.ts.map +1 -0
- package/dist/shared/document-analysis/index.js +166 -0
- package/dist/shared/document-analysis/index.js.map +1 -0
- package/dist/shared/document-analysis/keyword-utils.d.ts +405 -0
- package/dist/shared/document-analysis/keyword-utils.d.ts.map +1 -0
- package/dist/shared/document-analysis/keyword-utils.js +1147 -0
- package/dist/shared/document-analysis/keyword-utils.js.map +1 -0
- package/dist/shared/document-analysis/reference-validation.d.ts +27 -0
- package/dist/shared/document-analysis/reference-validation.d.ts.map +1 -0
- package/dist/shared/document-analysis/reference-validation.js +173 -0
- package/dist/shared/document-analysis/reference-validation.js.map +1 -0
- package/dist/shared/document-analysis/related-docs.d.ts +27 -0
- package/dist/shared/document-analysis/related-docs.d.ts.map +1 -0
- package/dist/shared/document-analysis/related-docs.js +459 -0
- package/dist/shared/document-analysis/related-docs.js.map +1 -0
- package/dist/shared/document-analysis/types.d.ts +89 -0
- package/dist/shared/document-analysis/types.d.ts.map +1 -0
- package/dist/shared/document-analysis/types.js +41 -0
- package/dist/shared/document-analysis/types.js.map +1 -0
- package/dist/shared/document-analysis.d.ts +15 -0
- package/dist/shared/document-analysis.d.ts.map +1 -0
- package/dist/shared/document-analysis.js +16 -0
- package/dist/shared/document-analysis.js.map +1 -0
- package/dist/shared/document-manager-factory.d.ts +32 -0
- package/dist/shared/document-manager-factory.d.ts.map +1 -0
- package/dist/shared/document-manager-factory.js +75 -0
- package/dist/shared/document-manager-factory.js.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +7 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/link-analysis.d.ts +84 -0
- package/dist/shared/link-analysis.d.ts.map +1 -0
- package/dist/shared/link-analysis.js +213 -0
- package/dist/shared/link-analysis.js.map +1 -0
- package/dist/shared/link-context.d.ts +23 -0
- package/dist/shared/link-context.d.ts.map +1 -0
- package/dist/shared/link-context.js +172 -0
- package/dist/shared/link-context.js.map +1 -0
- package/dist/shared/link-utils.d.ts +33 -0
- package/dist/shared/link-utils.d.ts.map +1 -0
- package/dist/shared/link-utils.js +301 -0
- package/dist/shared/link-utils.js.map +1 -0
- package/dist/shared/link-validation.d.ts +79 -0
- package/dist/shared/link-validation.d.ts.map +1 -0
- package/dist/shared/link-validation.js +340 -0
- package/dist/shared/link-validation.js.map +1 -0
- package/dist/shared/namespace-analysis.d.ts +10 -0
- package/dist/shared/namespace-analysis.d.ts.map +1 -0
- package/dist/shared/namespace-analysis.js +100 -0
- package/dist/shared/namespace-analysis.js.map +1 -0
- package/dist/shared/namespace-constants.d.ts +69 -0
- package/dist/shared/namespace-constants.d.ts.map +1 -0
- package/dist/shared/namespace-constants.js +97 -0
- package/dist/shared/namespace-constants.js.map +1 -0
- package/dist/shared/path-utilities.d.ts +13 -0
- package/dist/shared/path-utilities.d.ts.map +1 -0
- package/dist/shared/path-utilities.js +39 -0
- package/dist/shared/path-utilities.js.map +1 -0
- package/dist/shared/reference-extractor.d.ts +121 -0
- package/dist/shared/reference-extractor.d.ts.map +1 -0
- package/dist/shared/reference-extractor.js +195 -0
- package/dist/shared/reference-extractor.js.map +1 -0
- package/dist/shared/reference-loader.d.ts +163 -0
- package/dist/shared/reference-loader.d.ts.map +1 -0
- package/dist/shared/reference-loader.js +265 -0
- package/dist/shared/reference-loader.js.map +1 -0
- package/dist/shared/section-operations.d.ts +14 -0
- package/dist/shared/section-operations.d.ts.map +1 -0
- package/dist/shared/section-operations.js +115 -0
- package/dist/shared/section-operations.js.map +1 -0
- package/dist/shared/slug-utils.d.ts +109 -0
- package/dist/shared/slug-utils.d.ts.map +1 -0
- package/dist/shared/slug-utils.js +302 -0
- package/dist/shared/slug-utils.js.map +1 -0
- package/dist/shared/task-operations.d.ts +152 -0
- package/dist/shared/task-operations.d.ts.map +1 -0
- package/dist/shared/task-operations.js +416 -0
- package/dist/shared/task-operations.js.map +1 -0
- package/dist/shared/task-utilities.d.ts +63 -0
- package/dist/shared/task-utilities.d.ts.map +1 -0
- package/dist/shared/task-utilities.js +86 -0
- package/dist/shared/task-utilities.js.map +1 -0
- package/dist/shared/task-validation.d.ts +50 -0
- package/dist/shared/task-validation.d.ts.map +1 -0
- package/dist/shared/task-validation.js +97 -0
- package/dist/shared/task-validation.js.map +1 -0
- package/dist/shared/task-view-utilities.d.ts +109 -0
- package/dist/shared/task-view-utilities.d.ts.map +1 -0
- package/dist/shared/task-view-utilities.js +255 -0
- package/dist/shared/task-view-utilities.js.map +1 -0
- package/dist/shared/utilities.d.ts +14 -0
- package/dist/shared/utilities.d.ts.map +1 -0
- package/dist/shared/utilities.js +23 -0
- package/dist/shared/utilities.js.map +1 -0
- package/dist/shared/utilities.test.d.ts +5 -0
- package/dist/shared/utilities.test.d.ts.map +1 -0
- package/dist/shared/utilities.test.js +422 -0
- package/dist/shared/utilities.test.js.map +1 -0
- package/dist/shared/validation-utils.d.ts +57 -0
- package/dist/shared/validation-utils.d.ts.map +1 -0
- package/dist/shared/validation-utils.js +63 -0
- package/dist/shared/validation-utils.js.map +1 -0
- package/dist/shared/workflow-prompt-utilities.d.ts +64 -0
- package/dist/shared/workflow-prompt-utilities.d.ts.map +1 -0
- package/dist/shared/workflow-prompt-utilities.js +163 -0
- package/dist/shared/workflow-prompt-utilities.js.map +1 -0
- package/dist/slug.d.ts +9 -0
- package/dist/slug.d.ts.map +1 -0
- package/dist/slug.js +40 -0
- package/dist/slug.js.map +1 -0
- package/dist/template-loader.d.ts +6 -0
- package/dist/template-loader.d.ts.map +1 -0
- package/dist/template-loader.js +8 -0
- package/dist/template-loader.js.map +1 -0
- package/dist/tools/__tests__/create-document-self-reference.test.d.ts +2 -0
- package/dist/tools/__tests__/create-document-self-reference.test.d.ts.map +1 -0
- package/dist/tools/__tests__/create-document-self-reference.test.js +124 -0
- package/dist/tools/__tests__/create-document-self-reference.test.js.map +1 -0
- package/dist/tools/__tests__/create-document-workflow-regression.test.d.ts +16 -0
- package/dist/tools/__tests__/create-document-workflow-regression.test.d.ts.map +1 -0
- package/dist/tools/__tests__/create-document-workflow-regression.test.js +655 -0
- package/dist/tools/__tests__/create-document-workflow-regression.test.js.map +1 -0
- package/dist/tools/__tests__/create-document.test.d.ts +2 -0
- package/dist/tools/__tests__/create-document.test.d.ts.map +1 -0
- package/dist/tools/__tests__/create-document.test.js +255 -0
- package/dist/tools/__tests__/create-document.test.js.map +1 -0
- package/dist/tools/__tests__/delete-document.test.d.ts +7 -0
- package/dist/tools/__tests__/delete-document.test.d.ts.map +1 -0
- package/dist/tools/__tests__/delete-document.test.js +311 -0
- package/dist/tools/__tests__/delete-document.test.js.map +1 -0
- package/dist/tools/__tests__/edit-document.test.d.ts +2 -0
- package/dist/tools/__tests__/edit-document.test.d.ts.map +1 -0
- package/dist/tools/__tests__/edit-document.test.js +644 -0
- package/dist/tools/__tests__/edit-document.test.js.map +1 -0
- package/dist/tools/__tests__/error-scenarios.test.d.ts +5 -0
- package/dist/tools/__tests__/error-scenarios.test.d.ts.map +1 -0
- package/dist/tools/__tests__/error-scenarios.test.js +105 -0
- package/dist/tools/__tests__/error-scenarios.test.js.map +1 -0
- package/dist/tools/__tests__/mocks/document-manager.mock.d.ts +99 -0
- package/dist/tools/__tests__/mocks/document-manager.mock.d.ts.map +1 -0
- package/dist/tools/__tests__/mocks/document-manager.mock.js +457 -0
- package/dist/tools/__tests__/mocks/document-manager.mock.js.map +1 -0
- package/dist/tools/__tests__/mocks/filesystem.mock.d.ts +103 -0
- package/dist/tools/__tests__/mocks/filesystem.mock.d.ts.map +1 -0
- package/dist/tools/__tests__/mocks/filesystem.mock.js +247 -0
- package/dist/tools/__tests__/mocks/filesystem.mock.js.map +1 -0
- package/dist/tools/__tests__/move-document.test.d.ts +12 -0
- package/dist/tools/__tests__/move-document.test.d.ts.map +1 -0
- package/dist/tools/__tests__/move-document.test.js +214 -0
- package/dist/tools/__tests__/move-document.test.js.map +1 -0
- package/dist/tools/__tests__/move.test.d.ts +13 -0
- package/dist/tools/__tests__/move.test.d.ts.map +1 -0
- package/dist/tools/__tests__/move.test.js +939 -0
- package/dist/tools/__tests__/move.test.js.map +1 -0
- package/dist/tools/__tests__/section.integration.improved.test.d.ts +5 -0
- package/dist/tools/__tests__/section.integration.improved.test.d.ts.map +1 -0
- package/dist/tools/__tests__/section.integration.improved.test.js +199 -0
- package/dist/tools/__tests__/section.integration.improved.test.js.map +1 -0
- package/dist/tools/__tests__/section.integration.test.d.ts +5 -0
- package/dist/tools/__tests__/section.integration.test.d.ts.map +1 -0
- package/dist/tools/__tests__/section.integration.test.js +637 -0
- package/dist/tools/__tests__/section.integration.test.js.map +1 -0
- package/dist/tools/__tests__/setup/test-environment.d.ts +111 -0
- package/dist/tools/__tests__/setup/test-environment.d.ts.map +1 -0
- package/dist/tools/__tests__/setup/test-environment.js +322 -0
- package/dist/tools/__tests__/setup/test-environment.js.map +1 -0
- package/dist/tools/__tests__/suggestion-generator.test.d.ts +8 -0
- package/dist/tools/__tests__/suggestion-generator.test.d.ts.map +1 -0
- package/dist/tools/__tests__/suggestion-generator.test.js +508 -0
- package/dist/tools/__tests__/suggestion-generator.test.js.map +1 -0
- package/dist/tools/__tests__/task-consistency.test.d.ts +11 -0
- package/dist/tools/__tests__/task-consistency.test.d.ts.map +1 -0
- package/dist/tools/__tests__/task-consistency.test.js +93 -0
- package/dist/tools/__tests__/task-consistency.test.js.map +1 -0
- package/dist/tools/__tests__/task-status-parsing.test.d.ts +15 -0
- package/dist/tools/__tests__/task-status-parsing.test.d.ts.map +1 -0
- package/dist/tools/__tests__/task-status-parsing.test.js +126 -0
- package/dist/tools/__tests__/task-status-parsing.test.js.map +1 -0
- package/dist/tools/__tests__/view-section-boundary.test.d.ts +2 -0
- package/dist/tools/__tests__/view-section-boundary.test.d.ts.map +1 -0
- package/dist/tools/__tests__/view-section-boundary.test.js +132 -0
- package/dist/tools/__tests__/view-section-boundary.test.js.map +1 -0
- package/dist/tools/__tests__/write-operations-integration.test.d.ts +8 -0
- package/dist/tools/__tests__/write-operations-integration.test.d.ts.map +1 -0
- package/dist/tools/__tests__/write-operations-integration.test.js +136 -0
- package/dist/tools/__tests__/write-operations-integration.test.js.map +1 -0
- package/dist/tools/browse/content-analyzer.d.ts +27 -0
- package/dist/tools/browse/content-analyzer.d.ts.map +1 -0
- package/dist/tools/browse/content-analyzer.js +150 -0
- package/dist/tools/browse/content-analyzer.js.map +1 -0
- package/dist/tools/browse/dependency-analyzer.d.ts +63 -0
- package/dist/tools/browse/dependency-analyzer.d.ts.map +1 -0
- package/dist/tools/browse/dependency-analyzer.js +261 -0
- package/dist/tools/browse/dependency-analyzer.js.map +1 -0
- package/dist/tools/browse/folder-navigator.d.ts +35 -0
- package/dist/tools/browse/folder-navigator.d.ts.map +1 -0
- package/dist/tools/browse/folder-navigator.js +154 -0
- package/dist/tools/browse/folder-navigator.js.map +1 -0
- package/dist/tools/browse/index.d.ts +10 -0
- package/dist/tools/browse/index.d.ts.map +1 -0
- package/dist/tools/browse/index.js +14 -0
- package/dist/tools/browse/index.js.map +1 -0
- package/dist/tools/browse/relationship-classifier.d.ts +9 -0
- package/dist/tools/browse/relationship-classifier.d.ts.map +1 -0
- package/dist/tools/browse/relationship-classifier.js +38 -0
- package/dist/tools/browse/relationship-classifier.js.map +1 -0
- package/dist/tools/browse/search-engine.d.ts +69 -0
- package/dist/tools/browse/search-engine.d.ts.map +1 -0
- package/dist/tools/browse/search-engine.js +197 -0
- package/dist/tools/browse/search-engine.js.map +1 -0
- package/dist/tools/create/__tests__/file-creator.test.d.ts +6 -0
- package/dist/tools/create/__tests__/file-creator.test.d.ts.map +1 -0
- package/dist/tools/create/__tests__/file-creator.test.js +138 -0
- package/dist/tools/create/__tests__/file-creator.test.js.map +1 -0
- package/dist/tools/create/__tests__/template-processor.test.d.ts +6 -0
- package/dist/tools/create/__tests__/template-processor.test.d.ts.map +1 -0
- package/dist/tools/create/__tests__/template-processor.test.js +130 -0
- package/dist/tools/create/__tests__/template-processor.test.js.map +1 -0
- package/dist/tools/create/file-creator.d.ts +35 -0
- package/dist/tools/create/file-creator.d.ts.map +1 -0
- package/dist/tools/create/file-creator.js +103 -0
- package/dist/tools/create/file-creator.js.map +1 -0
- package/dist/tools/create/index.d.ts +6 -0
- package/dist/tools/create/index.d.ts.map +1 -0
- package/dist/tools/create/index.js +7 -0
- package/dist/tools/create/index.js.map +1 -0
- package/dist/tools/create/pipeline.d.ts +39 -0
- package/dist/tools/create/pipeline.d.ts.map +1 -0
- package/dist/tools/create/pipeline.js +112 -0
- package/dist/tools/create/pipeline.js.map +1 -0
- package/dist/tools/create/suggestion-generator.d.ts +47 -0
- package/dist/tools/create/suggestion-generator.d.ts.map +1 -0
- package/dist/tools/create/suggestion-generator.js +51 -0
- package/dist/tools/create/suggestion-generator.js.map +1 -0
- package/dist/tools/create/template-processor.d.ts +27 -0
- package/dist/tools/create/template-processor.d.ts.map +1 -0
- package/dist/tools/create/template-processor.js +74 -0
- package/dist/tools/create/template-processor.js.map +1 -0
- package/dist/tools/create/validation-processor.d.ts +48 -0
- package/dist/tools/create/validation-processor.d.ts.map +1 -0
- package/dist/tools/create/validation-processor.js +107 -0
- package/dist/tools/create/validation-processor.js.map +1 -0
- package/dist/tools/executor.d.ts +19 -0
- package/dist/tools/executor.d.ts.map +1 -0
- package/dist/tools/executor.js +53 -0
- package/dist/tools/executor.js.map +1 -0
- package/dist/tools/implementations/__tests__/browse-documents.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/browse-documents.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/browse-documents.test.js +319 -0
- package/dist/tools/implementations/__tests__/browse-documents.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/complete-coordinator-task.test.d.ts +7 -0
- package/dist/tools/implementations/__tests__/complete-coordinator-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/complete-coordinator-task.test.js +440 -0
- package/dist/tools/implementations/__tests__/complete-coordinator-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/complete-subagent-task.test.d.ts +14 -0
- package/dist/tools/implementations/__tests__/complete-subagent-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/complete-subagent-task.test.js +851 -0
- package/dist/tools/implementations/__tests__/complete-subagent-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/complete-task-notes.test.d.ts +6 -0
- package/dist/tools/implementations/__tests__/complete-task-notes.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/complete-task-notes.test.js +157 -0
- package/dist/tools/implementations/__tests__/complete-task-notes.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/complete-task.test.d.ts +14 -0
- package/dist/tools/implementations/__tests__/complete-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/complete-task.test.js +867 -0
- package/dist/tools/implementations/__tests__/complete-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/continue-task.test.d.ts +11 -0
- package/dist/tools/implementations/__tests__/continue-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/continue-task.test.js +845 -0
- package/dist/tools/implementations/__tests__/continue-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/coordinator-task.test.d.ts +7 -0
- package/dist/tools/implementations/__tests__/coordinator-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/coordinator-task.test.js +495 -0
- package/dist/tools/implementations/__tests__/coordinator-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/get-guide.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/get-guide.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/get-guide.test.js +242 -0
- package/dist/tools/implementations/__tests__/get-guide.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/get-workflow.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/get-workflow.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/get-workflow.test.js +232 -0
- package/dist/tools/implementations/__tests__/get-workflow.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/search-documents.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/search-documents.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/search-documents.test.js +336 -0
- package/dist/tools/implementations/__tests__/search-documents.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/start-coordinator-task.test.d.ts +7 -0
- package/dist/tools/implementations/__tests__/start-coordinator-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/start-coordinator-task.test.js +177 -0
- package/dist/tools/implementations/__tests__/start-coordinator-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/start-subagent-task.test.d.ts +11 -0
- package/dist/tools/implementations/__tests__/start-subagent-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/start-subagent-task.test.js +846 -0
- package/dist/tools/implementations/__tests__/start-subagent-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/start-task.test.d.ts +11 -0
- package/dist/tools/implementations/__tests__/start-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/start-task.test.js +828 -0
- package/dist/tools/implementations/__tests__/start-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.js +199 -0
- package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/subagent-task.test.d.ts +7 -0
- package/dist/tools/implementations/__tests__/subagent-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/subagent-task.test.js +720 -0
- package/dist/tools/implementations/__tests__/subagent-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/task-batch-operations.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/task-batch-operations.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/task-batch-operations.test.js +200 -0
- package/dist/tools/implementations/__tests__/task-batch-operations.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/task.test.d.ts +7 -0
- package/dist/tools/implementations/__tests__/task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/task.test.js +578 -0
- package/dist/tools/implementations/__tests__/task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/view-coordinator-task.test.d.ts +13 -0
- package/dist/tools/implementations/__tests__/view-coordinator-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/view-coordinator-task.test.js +1404 -0
- package/dist/tools/implementations/__tests__/view-coordinator-task.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/view-document.linked-context.test.d.ts +8 -0
- package/dist/tools/implementations/__tests__/view-document.linked-context.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/view-document.linked-context.test.js +235 -0
- package/dist/tools/implementations/__tests__/view-document.linked-context.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/view-document.simplification.test.d.ts +9 -0
- package/dist/tools/implementations/__tests__/view-document.simplification.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/view-document.simplification.test.js +160 -0
- package/dist/tools/implementations/__tests__/view-document.simplification.test.js.map +1 -0
- package/dist/tools/implementations/__tests__/view-task.test.d.ts +12 -0
- package/dist/tools/implementations/__tests__/view-task.test.d.ts.map +1 -0
- package/dist/tools/implementations/__tests__/view-task.test.js +1158 -0
- package/dist/tools/implementations/__tests__/view-task.test.js.map +1 -0
- package/dist/tools/implementations/browse-documents.d.ts +36 -0
- package/dist/tools/implementations/browse-documents.d.ts.map +1 -0
- package/dist/tools/implementations/browse-documents.js +123 -0
- package/dist/tools/implementations/browse-documents.js.map +1 -0
- package/dist/tools/implementations/complete-coordinator-task.d.ts +53 -0
- package/dist/tools/implementations/complete-coordinator-task.d.ts.map +1 -0
- package/dist/tools/implementations/complete-coordinator-task.js +159 -0
- package/dist/tools/implementations/complete-coordinator-task.js.map +1 -0
- package/dist/tools/implementations/complete-subagent-task.d.ts +47 -0
- package/dist/tools/implementations/complete-subagent-task.d.ts.map +1 -0
- package/dist/tools/implementations/complete-subagent-task.js +141 -0
- package/dist/tools/implementations/complete-subagent-task.js.map +1 -0
- package/dist/tools/implementations/complete-task.d.ts +32 -0
- package/dist/tools/implementations/complete-task.d.ts.map +1 -0
- package/dist/tools/implementations/complete-task.hierarchical.test.d.ts +8 -0
- package/dist/tools/implementations/complete-task.hierarchical.test.d.ts.map +1 -0
- package/dist/tools/implementations/complete-task.hierarchical.test.js +363 -0
- package/dist/tools/implementations/complete-task.hierarchical.test.js.map +1 -0
- package/dist/tools/implementations/complete-task.js +122 -0
- package/dist/tools/implementations/complete-task.js.map +1 -0
- package/dist/tools/implementations/continue-task.d.ts +48 -0
- package/dist/tools/implementations/continue-task.d.ts.map +1 -0
- package/dist/tools/implementations/continue-task.js +167 -0
- package/dist/tools/implementations/continue-task.js.map +1 -0
- package/dist/tools/implementations/coordinator-task.d.ts +72 -0
- package/dist/tools/implementations/coordinator-task.d.ts.map +1 -0
- package/dist/tools/implementations/coordinator-task.js +169 -0
- package/dist/tools/implementations/coordinator-task.js.map +1 -0
- package/dist/tools/implementations/create-document.d.ts +12 -0
- package/dist/tools/implementations/create-document.d.ts.map +1 -0
- package/dist/tools/implementations/create-document.js +15 -0
- package/dist/tools/implementations/create-document.js.map +1 -0
- package/dist/tools/implementations/delete-document.d.ts +16 -0
- package/dist/tools/implementations/delete-document.d.ts.map +1 -0
- package/dist/tools/implementations/delete-document.js +70 -0
- package/dist/tools/implementations/delete-document.js.map +1 -0
- package/dist/tools/implementations/edit-document.d.ts +8 -0
- package/dist/tools/implementations/edit-document.d.ts.map +1 -0
- package/dist/tools/implementations/edit-document.js +118 -0
- package/dist/tools/implementations/edit-document.js.map +1 -0
- package/dist/tools/implementations/get-guide.d.ts +13 -0
- package/dist/tools/implementations/get-guide.d.ts.map +1 -0
- package/dist/tools/implementations/get-guide.js +64 -0
- package/dist/tools/implementations/get-guide.js.map +1 -0
- package/dist/tools/implementations/get-workflow.d.ts +12 -0
- package/dist/tools/implementations/get-workflow.d.ts.map +1 -0
- package/dist/tools/implementations/get-workflow.js +71 -0
- package/dist/tools/implementations/get-workflow.js.map +1 -0
- package/dist/tools/implementations/index.d.ts +24 -0
- package/dist/tools/implementations/index.d.ts.map +1 -0
- package/dist/tools/implementations/index.js +24 -0
- package/dist/tools/implementations/index.js.map +1 -0
- package/dist/tools/implementations/manage-document.d.ts +8 -0
- package/dist/tools/implementations/manage-document.d.ts.map +1 -0
- package/dist/tools/implementations/manage-document.js +180 -0
- package/dist/tools/implementations/manage-document.js.map +1 -0
- package/dist/tools/implementations/move-document.d.ts +12 -0
- package/dist/tools/implementations/move-document.d.ts.map +1 -0
- package/dist/tools/implementations/move-document.js +72 -0
- package/dist/tools/implementations/move-document.js.map +1 -0
- package/dist/tools/implementations/move.d.ts +24 -0
- package/dist/tools/implementations/move.d.ts.map +1 -0
- package/dist/tools/implementations/move.js +167 -0
- package/dist/tools/implementations/move.js.map +1 -0
- package/dist/tools/implementations/search-documents.d.ts +39 -0
- package/dist/tools/implementations/search-documents.d.ts.map +1 -0
- package/dist/tools/implementations/search-documents.js +246 -0
- package/dist/tools/implementations/search-documents.js.map +1 -0
- package/dist/tools/implementations/section.d.ts +42 -0
- package/dist/tools/implementations/section.d.ts.map +1 -0
- package/dist/tools/implementations/section.hierarchical.test.d.ts +8 -0
- package/dist/tools/implementations/section.hierarchical.test.d.ts.map +1 -0
- package/dist/tools/implementations/section.hierarchical.test.js +299 -0
- package/dist/tools/implementations/section.hierarchical.test.js.map +1 -0
- package/dist/tools/implementations/section.js +244 -0
- package/dist/tools/implementations/section.js.map +1 -0
- package/dist/tools/implementations/section.test.d.ts +5 -0
- package/dist/tools/implementations/section.test.d.ts.map +1 -0
- package/dist/tools/implementations/section.test.js +371 -0
- package/dist/tools/implementations/section.test.js.map +1 -0
- package/dist/tools/implementations/start-coordinator-task.d.ts +44 -0
- package/dist/tools/implementations/start-coordinator-task.d.ts.map +1 -0
- package/dist/tools/implementations/start-coordinator-task.js +125 -0
- package/dist/tools/implementations/start-coordinator-task.js.map +1 -0
- package/dist/tools/implementations/start-subagent-task.d.ts +53 -0
- package/dist/tools/implementations/start-subagent-task.d.ts.map +1 -0
- package/dist/tools/implementations/start-subagent-task.js +179 -0
- package/dist/tools/implementations/start-subagent-task.js.map +1 -0
- package/dist/tools/implementations/start-task.d.ts +48 -0
- package/dist/tools/implementations/start-task.d.ts.map +1 -0
- package/dist/tools/implementations/start-task.js +216 -0
- package/dist/tools/implementations/start-task.js.map +1 -0
- package/dist/tools/implementations/subagent-task.d.ts +98 -0
- package/dist/tools/implementations/subagent-task.d.ts.map +1 -0
- package/dist/tools/implementations/subagent-task.js +277 -0
- package/dist/tools/implementations/subagent-task.js.map +1 -0
- package/dist/tools/implementations/task.d.ts +97 -0
- package/dist/tools/implementations/task.d.ts.map +1 -0
- package/dist/tools/implementations/task.hierarchical.test.d.ts +8 -0
- package/dist/tools/implementations/task.hierarchical.test.d.ts.map +1 -0
- package/dist/tools/implementations/task.hierarchical.test.js +333 -0
- package/dist/tools/implementations/task.hierarchical.test.js.map +1 -0
- package/dist/tools/implementations/task.js +235 -0
- package/dist/tools/implementations/task.js.map +1 -0
- package/dist/tools/implementations/view-coordinator-task.d.ts +61 -0
- package/dist/tools/implementations/view-coordinator-task.d.ts.map +1 -0
- package/dist/tools/implementations/view-coordinator-task.js +295 -0
- package/dist/tools/implementations/view-coordinator-task.js.map +1 -0
- package/dist/tools/implementations/view-document.d.ts +84 -0
- package/dist/tools/implementations/view-document.d.ts.map +1 -0
- package/dist/tools/implementations/view-document.js +287 -0
- package/dist/tools/implementations/view-document.js.map +1 -0
- package/dist/tools/implementations/view-section.d.ts +28 -0
- package/dist/tools/implementations/view-section.d.ts.map +1 -0
- package/dist/tools/implementations/view-section.hierarchical.test.d.ts +8 -0
- package/dist/tools/implementations/view-section.hierarchical.test.d.ts.map +1 -0
- package/dist/tools/implementations/view-section.hierarchical.test.js +318 -0
- package/dist/tools/implementations/view-section.hierarchical.test.js.map +1 -0
- package/dist/tools/implementations/view-section.js +167 -0
- package/dist/tools/implementations/view-section.js.map +1 -0
- package/dist/tools/implementations/view-subagent-task.d.ts +46 -0
- package/dist/tools/implementations/view-subagent-task.d.ts.map +1 -0
- package/dist/tools/implementations/view-subagent-task.js +283 -0
- package/dist/tools/implementations/view-subagent-task.js.map +1 -0
- package/dist/tools/implementations/view-task.d.ts +43 -0
- package/dist/tools/implementations/view-task.d.ts.map +1 -0
- package/dist/tools/implementations/view-task.hierarchical.test.d.ts +8 -0
- package/dist/tools/implementations/view-task.hierarchical.test.d.ts.map +1 -0
- package/dist/tools/implementations/view-task.hierarchical.test.js +420 -0
- package/dist/tools/implementations/view-task.hierarchical.test.js.map +1 -0
- package/dist/tools/implementations/view-task.js +280 -0
- package/dist/tools/implementations/view-task.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +10 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +132 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/schemas/__tests__/get-guide-schemas.test.d.ts +8 -0
- package/dist/tools/schemas/__tests__/get-guide-schemas.test.d.ts.map +1 -0
- package/dist/tools/schemas/__tests__/get-guide-schemas.test.js +216 -0
- package/dist/tools/schemas/__tests__/get-guide-schemas.test.js.map +1 -0
- package/dist/tools/schemas/__tests__/get-workflow-schemas.test.d.ts +8 -0
- package/dist/tools/schemas/__tests__/get-workflow-schemas.test.d.ts.map +1 -0
- package/dist/tools/schemas/__tests__/get-workflow-schemas.test.js +229 -0
- package/dist/tools/schemas/__tests__/get-workflow-schemas.test.js.map +1 -0
- package/dist/tools/schemas/browse-documents-schemas.d.ts +47 -0
- package/dist/tools/schemas/browse-documents-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/browse-documents-schemas.js +48 -0
- package/dist/tools/schemas/browse-documents-schemas.js.map +1 -0
- package/dist/tools/schemas/complete-coordinator-task-schemas.d.ts +41 -0
- package/dist/tools/schemas/complete-coordinator-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/complete-coordinator-task-schemas.js +42 -0
- package/dist/tools/schemas/complete-coordinator-task-schemas.js.map +1 -0
- package/dist/tools/schemas/complete-subagent-task-schemas.d.ts +38 -0
- package/dist/tools/schemas/complete-subagent-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/complete-subagent-task-schemas.js +41 -0
- package/dist/tools/schemas/complete-subagent-task-schemas.js.map +1 -0
- package/dist/tools/schemas/complete-task-schemas.d.ts +33 -0
- package/dist/tools/schemas/complete-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/complete-task-schemas.js +36 -0
- package/dist/tools/schemas/complete-task-schemas.js.map +1 -0
- package/dist/tools/schemas/continue-task-schemas.d.ts +27 -0
- package/dist/tools/schemas/continue-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/continue-task-schemas.js +28 -0
- package/dist/tools/schemas/continue-task-schemas.js.map +1 -0
- package/dist/tools/schemas/coordinator-task-schemas.d.ts +87 -0
- package/dist/tools/schemas/coordinator-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/coordinator-task-schemas.js +80 -0
- package/dist/tools/schemas/coordinator-task-schemas.js.map +1 -0
- package/dist/tools/schemas/create-document-schemas.d.ts +61 -0
- package/dist/tools/schemas/create-document-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/create-document-schemas.js +143 -0
- package/dist/tools/schemas/create-document-schemas.js.map +1 -0
- package/dist/tools/schemas/delete-document-schemas.d.ts +24 -0
- package/dist/tools/schemas/delete-document-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/delete-document-schemas.js +25 -0
- package/dist/tools/schemas/delete-document-schemas.js.map +1 -0
- package/dist/tools/schemas/edit-document-schemas.d.ts +27 -0
- package/dist/tools/schemas/edit-document-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/edit-document-schemas.js +28 -0
- package/dist/tools/schemas/edit-document-schemas.js.map +1 -0
- package/dist/tools/schemas/get-guide-schemas.d.ts +35 -0
- package/dist/tools/schemas/get-guide-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/get-guide-schemas.js +66 -0
- package/dist/tools/schemas/get-guide-schemas.js.map +1 -0
- package/dist/tools/schemas/get-workflow-schemas.d.ts +35 -0
- package/dist/tools/schemas/get-workflow-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/get-workflow-schemas.js +67 -0
- package/dist/tools/schemas/get-workflow-schemas.js.map +1 -0
- package/dist/tools/schemas/manage-document-schemas.d.ts +59 -0
- package/dist/tools/schemas/manage-document-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/manage-document-schemas.js +83 -0
- package/dist/tools/schemas/manage-document-schemas.js.map +1 -0
- package/dist/tools/schemas/move-document-schemas.d.ts +25 -0
- package/dist/tools/schemas/move-document-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/move-document-schemas.js +26 -0
- package/dist/tools/schemas/move-document-schemas.js.map +1 -0
- package/dist/tools/schemas/move-schemas.d.ts +43 -0
- package/dist/tools/schemas/move-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/move-schemas.js +43 -0
- package/dist/tools/schemas/move-schemas.js.map +1 -0
- package/dist/tools/schemas/search-documents-schemas.d.ts +77 -0
- package/dist/tools/schemas/search-documents-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/search-documents-schemas.js +78 -0
- package/dist/tools/schemas/search-documents-schemas.js.map +1 -0
- package/dist/tools/schemas/section-schemas.d.ts +361 -0
- package/dist/tools/schemas/section-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/section-schemas.js +182 -0
- package/dist/tools/schemas/section-schemas.js.map +1 -0
- package/dist/tools/schemas/start-coordinator-task-schemas.d.ts +30 -0
- package/dist/tools/schemas/start-coordinator-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/start-coordinator-task-schemas.js +31 -0
- package/dist/tools/schemas/start-coordinator-task-schemas.js.map +1 -0
- package/dist/tools/schemas/start-subagent-task-schemas.d.ts +29 -0
- package/dist/tools/schemas/start-subagent-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/start-subagent-task-schemas.js +40 -0
- package/dist/tools/schemas/start-subagent-task-schemas.js.map +1 -0
- package/dist/tools/schemas/start-task-schemas.d.ts +23 -0
- package/dist/tools/schemas/start-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/start-task-schemas.js +39 -0
- package/dist/tools/schemas/start-task-schemas.js.map +1 -0
- package/dist/tools/schemas/subagent-task-schemas.d.ts +93 -0
- package/dist/tools/schemas/subagent-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/subagent-task-schemas.js +81 -0
- package/dist/tools/schemas/subagent-task-schemas.js.map +1 -0
- package/dist/tools/schemas/task-schemas.d.ts +88 -0
- package/dist/tools/schemas/task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/task-schemas.js +80 -0
- package/dist/tools/schemas/task-schemas.js.map +1 -0
- package/dist/tools/schemas/view-coordinator-task-schemas.d.ts +27 -0
- package/dist/tools/schemas/view-coordinator-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/view-coordinator-task-schemas.js +46 -0
- package/dist/tools/schemas/view-coordinator-task-schemas.js.map +1 -0
- package/dist/tools/schemas/view-document-schemas.d.ts +152 -0
- package/dist/tools/schemas/view-document-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/view-document-schemas.js +70 -0
- package/dist/tools/schemas/view-document-schemas.js.map +1 -0
- package/dist/tools/schemas/view-section-schemas.d.ts +31 -0
- package/dist/tools/schemas/view-section-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/view-section-schemas.js +56 -0
- package/dist/tools/schemas/view-section-schemas.js.map +1 -0
- package/dist/tools/schemas/view-subagent-task-schemas.d.ts +31 -0
- package/dist/tools/schemas/view-subagent-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/view-subagent-task-schemas.js +65 -0
- package/dist/tools/schemas/view-subagent-task-schemas.js.map +1 -0
- package/dist/tools/schemas/view-task-schemas.d.ts +31 -0
- package/dist/tools/schemas/view-task-schemas.d.ts.map +1 -0
- package/dist/tools/schemas/view-task-schemas.js +62 -0
- package/dist/tools/schemas/view-task-schemas.js.map +1 -0
- package/dist/tools/types.d.ts +98 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +9 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools-manager.d.ts +8 -0
- package/dist/tools-manager.d.ts.map +1 -0
- package/dist/tools-manager.js +9 -0
- package/dist/tools-manager.js.map +1 -0
- package/dist/types/core.d.ts +71 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +5 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/linking.d.ts +97 -0
- package/dist/types/linking.d.ts.map +1 -0
- package/dist/types/linking.js +5 -0
- package/dist/types/linking.js.map +1 -0
- package/dist/utils/__tests__/path-handler.archive.test.d.ts +8 -0
- package/dist/utils/__tests__/path-handler.archive.test.d.ts.map +1 -0
- package/dist/utils/__tests__/path-handler.archive.test.js +163 -0
- package/dist/utils/__tests__/path-handler.archive.test.js.map +1 -0
- package/dist/utils/error-formatter.d.ts +32 -0
- package/dist/utils/error-formatter.d.ts.map +1 -0
- package/dist/utils/error-formatter.js +79 -0
- package/dist/utils/error-formatter.js.map +1 -0
- package/dist/utils/logger.d.ts +21 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +154 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/path-handler.d.ts +52 -0
- package/dist/utils/path-handler.d.ts.map +1 -0
- package/dist/utils/path-handler.js +129 -0
- package/dist/utils/path-handler.js.map +1 -0
- package/dist/utils/security-audit-logger.d.ts +64 -0
- package/dist/utils/security-audit-logger.d.ts.map +1 -0
- package/dist/utils/security-audit-logger.js +56 -0
- package/dist/utils/security-audit-logger.js.map +1 -0
- package/dist/utils/virtual-path-resolver.d.ts +126 -0
- package/dist/utils/virtual-path-resolver.d.ts.map +1 -0
- package/dist/utils/virtual-path-resolver.js +171 -0
- package/dist/utils/virtual-path-resolver.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document management operations using cache system
|
|
3
|
+
*/
|
|
4
|
+
import { promises as fs } from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { AccessContext } from './document-cache.js';
|
|
7
|
+
import { replaceSectionBody, insertRelative, renameHeading, deleteSection } from './sections.js';
|
|
8
|
+
import { listHeadings, buildToc } from './parse.js';
|
|
9
|
+
import { ensureDirectoryExists, writeFileIfUnchanged, readFileSnapshot } from './fsio.js';
|
|
10
|
+
import { getGlobalLogger } from './utils/logger.js';
|
|
11
|
+
import { PathHandler } from './utils/path-handler.js';
|
|
12
|
+
import { VirtualPathResolver } from './utils/virtual-path-resolver.js';
|
|
13
|
+
import { validateHeadingDepth } from './shared/validation-utils.js';
|
|
14
|
+
const logger = getGlobalLogger();
|
|
15
|
+
/**
|
|
16
|
+
* Debounce delay in milliseconds for TOC updates.
|
|
17
|
+
* Prevents race conditions from multiple rapid document updates.
|
|
18
|
+
*/
|
|
19
|
+
const TOC_UPDATE_DEBOUNCE_MS = 100;
|
|
20
|
+
/**
|
|
21
|
+
* Document management facade using cache system
|
|
22
|
+
*/
|
|
23
|
+
export class DocumentManager {
|
|
24
|
+
docsRoot;
|
|
25
|
+
coordinatorRoot;
|
|
26
|
+
archivedRoot;
|
|
27
|
+
cache;
|
|
28
|
+
pathHandler;
|
|
29
|
+
pathResolver;
|
|
30
|
+
fingerprintIndex;
|
|
31
|
+
pendingTocUpdates = new Map();
|
|
32
|
+
constructor(docsRoot, cache, fingerprintIndex, archivedBasePath, coordinatorRoot) {
|
|
33
|
+
this.docsRoot = path.resolve(docsRoot);
|
|
34
|
+
// Coordinator root defaults to sibling of docs root if not provided
|
|
35
|
+
this.coordinatorRoot = coordinatorRoot != null
|
|
36
|
+
? path.resolve(coordinatorRoot)
|
|
37
|
+
: path.join(path.dirname(this.docsRoot), 'coordinator');
|
|
38
|
+
// Archived root defaults to sibling of docs root if not provided
|
|
39
|
+
this.archivedRoot = archivedBasePath != null
|
|
40
|
+
? path.resolve(archivedBasePath)
|
|
41
|
+
: path.join(path.dirname(this.docsRoot), 'archived');
|
|
42
|
+
this.cache = cache;
|
|
43
|
+
this.pathHandler = new PathHandler(this.docsRoot, archivedBasePath);
|
|
44
|
+
// Initialize virtual path resolver for centralized path routing
|
|
45
|
+
this.pathResolver = new VirtualPathResolver(this.docsRoot, this.coordinatorRoot, this.archivedRoot);
|
|
46
|
+
this.fingerprintIndex = fingerprintIndex;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generate table of contents markdown
|
|
50
|
+
*/
|
|
51
|
+
generateTocMarkdown(toc, level = 0) {
|
|
52
|
+
const lines = [];
|
|
53
|
+
const indent = ' '.repeat(level);
|
|
54
|
+
for (const node of toc) {
|
|
55
|
+
lines.push(`${indent}- [${node.title}](#${node.slug})`);
|
|
56
|
+
if (node.children.length > 0) {
|
|
57
|
+
lines.push(this.generateTocMarkdown(node.children, level + 1));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return lines.join('\n');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Load template content with fallback to default content
|
|
64
|
+
*
|
|
65
|
+
* Attempts to load template from ../templates/${template}.md.
|
|
66
|
+
* Returns default content on any error (file not found, permissions, etc).
|
|
67
|
+
*
|
|
68
|
+
* @param template - Template name (without .md extension)
|
|
69
|
+
* @param title - Document title for default content and template variable replacement
|
|
70
|
+
* @returns Promise resolving to template content or default content
|
|
71
|
+
*/
|
|
72
|
+
async loadTemplateWithFallback(template, title) {
|
|
73
|
+
const defaultContent = `# ${title}\n\n`;
|
|
74
|
+
if (template === '') {
|
|
75
|
+
return defaultContent;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const templatePath = path.join(this.docsRoot, '../templates', `${template}.md`);
|
|
79
|
+
const content = await fs.readFile(templatePath, 'utf8');
|
|
80
|
+
// Replace template variables
|
|
81
|
+
return content.replace(/\{\{title\}\}/g, title);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
logger.warn('Template load failed, using default content', {
|
|
85
|
+
template,
|
|
86
|
+
severity: 'OPTIONAL',
|
|
87
|
+
error
|
|
88
|
+
});
|
|
89
|
+
return defaultContent;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if a file exists at the given absolute path
|
|
94
|
+
*
|
|
95
|
+
* @param absolutePath - Absolute filesystem path to check
|
|
96
|
+
* @returns Promise resolving to true if file exists, false otherwise
|
|
97
|
+
*/
|
|
98
|
+
async fileExists(absolutePath) {
|
|
99
|
+
try {
|
|
100
|
+
await fs.access(absolutePath);
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Schedule a table of contents update with debouncing
|
|
109
|
+
*
|
|
110
|
+
* Cancels any pending TOC update for the same document and schedules a new one
|
|
111
|
+
* with configurable debounce delay. This prevents race conditions from multiple rapid updates.
|
|
112
|
+
*
|
|
113
|
+
* @param docPath - Relative path to the document
|
|
114
|
+
*/
|
|
115
|
+
scheduleTocUpdate(docPath) {
|
|
116
|
+
// Cancel any pending update for this document
|
|
117
|
+
const existingTimeout = this.pendingTocUpdates.get(docPath);
|
|
118
|
+
if (existingTimeout != null) {
|
|
119
|
+
clearTimeout(existingTimeout);
|
|
120
|
+
}
|
|
121
|
+
// Schedule new update with debounce
|
|
122
|
+
const timeoutId = setTimeout(() => {
|
|
123
|
+
this.pendingTocUpdates.delete(docPath);
|
|
124
|
+
void this.updateTableOfContents(docPath);
|
|
125
|
+
}, TOC_UPDATE_DEBOUNCE_MS);
|
|
126
|
+
// Store timeout ID
|
|
127
|
+
this.pendingTocUpdates.set(docPath, timeoutId);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new markdown document with specified content and metadata
|
|
131
|
+
*
|
|
132
|
+
* Validates document path, ensures parent directories exist, and builds initial content
|
|
133
|
+
* from template or provided data. Automatically generates table of contents if requested.
|
|
134
|
+
*
|
|
135
|
+
* @param docPath - Relative path for the new document (e.g., "api/new-feature.md")
|
|
136
|
+
* @param options - Configuration for document creation including title, content, and template
|
|
137
|
+
* @returns Promise that resolves when document is successfully created
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* await manager.createDocument("api/authentication.md", {
|
|
141
|
+
* title: "Authentication Guide",
|
|
142
|
+
* content: "Initial content here",
|
|
143
|
+
* generateToc: true
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* @throws {Error} When document already exists at the specified path
|
|
147
|
+
* @throws {Error} When filesystem operations fail (permissions, disk space, etc.)
|
|
148
|
+
*/
|
|
149
|
+
async createDocument(docPath, options) {
|
|
150
|
+
const absolutePath = this.getAbsolutePath(docPath);
|
|
151
|
+
// Ensure directory exists
|
|
152
|
+
await ensureDirectoryExists(path.dirname(absolutePath));
|
|
153
|
+
// Check if file already exists
|
|
154
|
+
try {
|
|
155
|
+
await fs.access(absolutePath);
|
|
156
|
+
throw new Error(`Document already exists: ${docPath}`);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
if (error instanceof Error && 'code' in error && error.code !== 'ENOENT') {
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
// File doesn't exist, continue
|
|
163
|
+
}
|
|
164
|
+
// Build initial content
|
|
165
|
+
let content = await this.loadTemplateWithFallback(options.template ?? '', options.title);
|
|
166
|
+
// Add table of contents if requested
|
|
167
|
+
if (options.features?.toc === true) {
|
|
168
|
+
const tocPlaceholder = '## Table of Contents\n\n<!-- TOC will be generated here -->\n\n';
|
|
169
|
+
// Use our markdown parsing tools to find the right insertion point
|
|
170
|
+
const headings = listHeadings(content);
|
|
171
|
+
if (headings.length > 0) {
|
|
172
|
+
// Insert TOC after the first heading (title) using our section tools
|
|
173
|
+
const firstHeading = headings[0];
|
|
174
|
+
if (firstHeading != null) {
|
|
175
|
+
content = insertRelative(content, firstHeading.slug, 'insert_after', 2, 'Table of Contents', '<!-- TOC will be generated here -->');
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
content = `${content}\n\n${tocPlaceholder}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// If no headings found, just append at the end
|
|
183
|
+
content = `${content}\n\n${tocPlaceholder}`;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Write file
|
|
187
|
+
await fs.writeFile(absolutePath, content, 'utf8');
|
|
188
|
+
// Generate TOC if requested and content has headings beyond title
|
|
189
|
+
if (options.features?.toc === true) {
|
|
190
|
+
await this.updateTableOfContents(docPath);
|
|
191
|
+
}
|
|
192
|
+
logger.info('Created document', {
|
|
193
|
+
path: docPath,
|
|
194
|
+
title: options.title,
|
|
195
|
+
features: options.features
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Update table of contents in document
|
|
200
|
+
*/
|
|
201
|
+
async updateTableOfContents(docPath) {
|
|
202
|
+
const document = await this.cache.getDocument(docPath);
|
|
203
|
+
if (!document) {
|
|
204
|
+
throw new Error(`Document not found: ${docPath}`);
|
|
205
|
+
}
|
|
206
|
+
// Filter out the title heading and TOC heading itself
|
|
207
|
+
const contentHeadings = document.headings.filter(h => h.depth > 1 && h.slug !== 'table-of-contents');
|
|
208
|
+
if (contentHeadings.length === 0) {
|
|
209
|
+
return; // No headings to create TOC for
|
|
210
|
+
}
|
|
211
|
+
// Build TOC from filtered headings using our buildToc tool
|
|
212
|
+
const absolutePath = this.getAbsolutePath(docPath);
|
|
213
|
+
const snapshot = await readFileSnapshot(absolutePath, { bypassValidation: true });
|
|
214
|
+
// Parse the current content to get the complete TOC structure
|
|
215
|
+
const currentToc = buildToc(snapshot.content);
|
|
216
|
+
const filteredToc = currentToc.filter(node => node.depth > 1 && node.slug !== 'table-of-contents');
|
|
217
|
+
const tocContent = this.generateTocMarkdown(filteredToc);
|
|
218
|
+
// Update TOC section using our section tools
|
|
219
|
+
try {
|
|
220
|
+
const updated = replaceSectionBody(snapshot.content, 'table-of-contents', tocContent);
|
|
221
|
+
await writeFileIfUnchanged(absolutePath, snapshot.mtimeMs, updated, { bypassValidation: true });
|
|
222
|
+
logger.debug('Updated table of contents', { path: docPath });
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
logger.warn('Failed to update TOC', { path: docPath, error });
|
|
226
|
+
// Don't throw - TOC update is not critical
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Update a document section
|
|
231
|
+
*/
|
|
232
|
+
async updateSection(docPath, slug, newContent, options = {}) {
|
|
233
|
+
const absolutePath = this.getAbsolutePath(docPath);
|
|
234
|
+
const snapshot = await readFileSnapshot(absolutePath, { bypassValidation: true });
|
|
235
|
+
const updated = replaceSectionBody(snapshot.content, slug, newContent);
|
|
236
|
+
await writeFileIfUnchanged(absolutePath, snapshot.mtimeMs, updated, { bypassValidation: true });
|
|
237
|
+
// Invalidate cache after write to ensure subsequent operations see fresh data
|
|
238
|
+
this.cache.invalidateDocument(docPath);
|
|
239
|
+
// Update TOC if requested
|
|
240
|
+
if (options.updateToc === true) {
|
|
241
|
+
this.scheduleTocUpdate(docPath);
|
|
242
|
+
}
|
|
243
|
+
logger.info('Updated document section', { path: docPath, slug });
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Rename a heading
|
|
247
|
+
*/
|
|
248
|
+
async renameSection(docPath, slug, newTitle, options = {}) {
|
|
249
|
+
const absolutePath = this.getAbsolutePath(docPath);
|
|
250
|
+
const snapshot = await readFileSnapshot(absolutePath, { bypassValidation: true });
|
|
251
|
+
const updated = renameHeading(snapshot.content, slug, newTitle);
|
|
252
|
+
await writeFileIfUnchanged(absolutePath, snapshot.mtimeMs, updated, { bypassValidation: true });
|
|
253
|
+
// Invalidate cache after write to ensure subsequent operations see fresh data
|
|
254
|
+
this.cache.invalidateDocument(docPath);
|
|
255
|
+
// Update TOC if requested
|
|
256
|
+
if (options.updateToc === true) {
|
|
257
|
+
this.scheduleTocUpdate(docPath);
|
|
258
|
+
}
|
|
259
|
+
logger.info('Renamed document section', { path: docPath, slug, newTitle });
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Delete a section
|
|
263
|
+
*/
|
|
264
|
+
async deleteSection(docPath, slug, options = {}) {
|
|
265
|
+
const absolutePath = this.getAbsolutePath(docPath);
|
|
266
|
+
const snapshot = await readFileSnapshot(absolutePath, { bypassValidation: true });
|
|
267
|
+
const updated = deleteSection(snapshot.content, slug);
|
|
268
|
+
await writeFileIfUnchanged(absolutePath, snapshot.mtimeMs, updated, { bypassValidation: true });
|
|
269
|
+
// Invalidate cache after write to ensure subsequent operations see fresh data
|
|
270
|
+
this.cache.invalidateDocument(docPath);
|
|
271
|
+
// Update TOC if requested
|
|
272
|
+
if (options.updateToc === true) {
|
|
273
|
+
this.scheduleTocUpdate(docPath);
|
|
274
|
+
}
|
|
275
|
+
logger.info('Deleted document section', { path: docPath, slug });
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Archives a document or folder by moving it to the archived directory with audit trail
|
|
279
|
+
*
|
|
280
|
+
* Creates timestamped archive directory, moves the document/folder, and generates
|
|
281
|
+
* an audit file with metadata about the archival operation.
|
|
282
|
+
*
|
|
283
|
+
* @param userPath - Path to document or folder to archive (relative to docs root)
|
|
284
|
+
* @returns Archive operation result with original path, archive path, and folder status
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* const result = await manager.archiveDocument("api/old-feature.md");
|
|
288
|
+
* console.log(`Archived to: ${result.archivePath}`);
|
|
289
|
+
* console.log(`Was folder: ${result.wasFolder}`);
|
|
290
|
+
*
|
|
291
|
+
* @throws {Error} When source path doesn't exist or archive operation fails
|
|
292
|
+
* @throws {Error} When filesystem operations fail (permissions, disk space, etc.)
|
|
293
|
+
*/
|
|
294
|
+
async archiveDocument(userPath) {
|
|
295
|
+
// Normalize and validate the path
|
|
296
|
+
const normalizedPath = this.pathHandler.processUserPath(userPath);
|
|
297
|
+
// Use VirtualPathResolver to get correct absolute path (handles docs vs coordinator routing)
|
|
298
|
+
const absolutePath = this.pathResolver.resolve(normalizedPath);
|
|
299
|
+
// Check if source exists (use fs.access directly since we already have validated absolute path)
|
|
300
|
+
try {
|
|
301
|
+
await fs.access(absolutePath);
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
throw new Error(`Path not found: ${normalizedPath}`);
|
|
305
|
+
}
|
|
306
|
+
// Determine if it's a folder or file
|
|
307
|
+
const stats = await fs.stat(absolutePath);
|
|
308
|
+
const isFolder = stats.isDirectory();
|
|
309
|
+
// Use VirtualPathResolver to get archive path with proper namespace routing
|
|
310
|
+
// This automatically handles docs vs coordinator paths correctly
|
|
311
|
+
let archivePath = this.pathResolver.getArchivePath(normalizedPath);
|
|
312
|
+
// Handle duplicates by appending counter if file already exists
|
|
313
|
+
let counter = 1;
|
|
314
|
+
const originalArchivePath = archivePath;
|
|
315
|
+
while (await this.fileExists(archivePath)) {
|
|
316
|
+
const ext = path.extname(originalArchivePath);
|
|
317
|
+
const nameWithoutExt = originalArchivePath.slice(0, -ext.length);
|
|
318
|
+
archivePath = `${nameWithoutExt}_${counter}${ext}`;
|
|
319
|
+
counter++;
|
|
320
|
+
}
|
|
321
|
+
const uniqueArchivePath = archivePath;
|
|
322
|
+
// Ensure archive directory structure exists
|
|
323
|
+
await ensureDirectoryExists(path.dirname(uniqueArchivePath));
|
|
324
|
+
// Move file/folder to archive
|
|
325
|
+
await fs.rename(absolutePath, uniqueArchivePath);
|
|
326
|
+
// Create audit trail file
|
|
327
|
+
const auditPath = `${uniqueArchivePath}.audit`;
|
|
328
|
+
const auditInfo = {
|
|
329
|
+
originalPath: normalizedPath,
|
|
330
|
+
archivedAt: new Date().toISOString(),
|
|
331
|
+
archivedBy: 'MCP Document Manager',
|
|
332
|
+
type: isFolder ? 'folder' : 'file',
|
|
333
|
+
reason: 'User requested archive',
|
|
334
|
+
note: 'Archived via MCP server'
|
|
335
|
+
};
|
|
336
|
+
await fs.writeFile(auditPath, JSON.stringify(auditInfo, null, 2), 'utf8');
|
|
337
|
+
// Invalidate cache for the archived item
|
|
338
|
+
this.cache.invalidateDocument(normalizedPath);
|
|
339
|
+
// If it was a folder, invalidate all documents within it
|
|
340
|
+
if (isFolder) {
|
|
341
|
+
// Invalidate all cached documents that were in this folder
|
|
342
|
+
const invalidatedCount = this.cache.invalidateDocumentsByPrefix(normalizedPath);
|
|
343
|
+
logger.info('Archived folder', {
|
|
344
|
+
originalPath: normalizedPath,
|
|
345
|
+
archivePath: uniqueArchivePath,
|
|
346
|
+
invalidatedDocuments: invalidatedCount
|
|
347
|
+
});
|
|
348
|
+
return {
|
|
349
|
+
originalPath: normalizedPath,
|
|
350
|
+
archivePath: uniqueArchivePath,
|
|
351
|
+
wasFolder: true
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
logger.info('Archived document', { originalPath: normalizedPath, archivePath: uniqueArchivePath });
|
|
356
|
+
return {
|
|
357
|
+
originalPath: normalizedPath,
|
|
358
|
+
archivePath: uniqueArchivePath,
|
|
359
|
+
wasFolder: false
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Insert section at specific location
|
|
365
|
+
*/
|
|
366
|
+
async insertSection(docPath, referenceSlug, insertMode, depth, title, content, options = {}) {
|
|
367
|
+
const absolutePath = this.getAbsolutePath(docPath);
|
|
368
|
+
const snapshot = await readFileSnapshot(absolutePath, { bypassValidation: true });
|
|
369
|
+
// Determine depth if not specified
|
|
370
|
+
let calculatedDepth;
|
|
371
|
+
if (depth != null) {
|
|
372
|
+
calculatedDepth = depth;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
// Auto-determine depth based on insertion mode
|
|
376
|
+
const document = await this.cache.getDocument(docPath);
|
|
377
|
+
if (!document) {
|
|
378
|
+
throw new Error(`Document not found: ${docPath}`);
|
|
379
|
+
}
|
|
380
|
+
const refHeading = document.headings.find(h => h.slug === referenceSlug);
|
|
381
|
+
if (!refHeading) {
|
|
382
|
+
throw new Error(`Reference section not found: ${referenceSlug}`);
|
|
383
|
+
}
|
|
384
|
+
calculatedDepth = insertMode === 'append_child'
|
|
385
|
+
? refHeading.depth + 1
|
|
386
|
+
: refHeading.depth;
|
|
387
|
+
}
|
|
388
|
+
// Validate and sanitize depth to ensure it's a valid HeadingDepth (1-6)
|
|
389
|
+
const finalDepth = validateHeadingDepth(calculatedDepth);
|
|
390
|
+
const updated = insertRelative(snapshot.content, referenceSlug, insertMode, finalDepth, title, content);
|
|
391
|
+
await writeFileIfUnchanged(absolutePath, snapshot.mtimeMs, updated, { bypassValidation: true });
|
|
392
|
+
// Invalidate cache after write to ensure subsequent operations see fresh data
|
|
393
|
+
this.cache.invalidateDocument(docPath);
|
|
394
|
+
// Update TOC if requested
|
|
395
|
+
if (options.updateToc === true) {
|
|
396
|
+
this.scheduleTocUpdate(docPath);
|
|
397
|
+
}
|
|
398
|
+
logger.info('Inserted section', { path: docPath, referenceSlug, title, mode: insertMode });
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Move section to different location (implementation needed)
|
|
402
|
+
*/
|
|
403
|
+
async moveSection(docPath, sectionSlug, targetSlug, position) {
|
|
404
|
+
// This would require implementing section extraction and re-insertion
|
|
405
|
+
// For now, throw a helpful error with all the context
|
|
406
|
+
throw new Error(`Move section operation not yet implemented. Document: ${docPath}, Section: ${sectionSlug}, Target: ${targetSlug}, Position: ${position}`);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* List all documents
|
|
410
|
+
*/
|
|
411
|
+
async listDocuments() {
|
|
412
|
+
const documents = [];
|
|
413
|
+
const errors = [];
|
|
414
|
+
const findMarkdownFiles = async (dir, basePath = '') => {
|
|
415
|
+
try {
|
|
416
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
417
|
+
for (const entry of entries) {
|
|
418
|
+
const fullPath = path.join(dir, entry.name);
|
|
419
|
+
const docPath = path.join(basePath, entry.name);
|
|
420
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
421
|
+
await findMarkdownFiles(fullPath, docPath);
|
|
422
|
+
}
|
|
423
|
+
else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
424
|
+
try {
|
|
425
|
+
const document = await this.cache.getDocument(`/${docPath}`);
|
|
426
|
+
if (document) {
|
|
427
|
+
documents.push({
|
|
428
|
+
path: `/${docPath}`,
|
|
429
|
+
title: document.metadata.title,
|
|
430
|
+
lastModified: document.metadata.lastModified,
|
|
431
|
+
headingCount: document.headings.length,
|
|
432
|
+
wordCount: document.metadata.wordCount
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
438
|
+
errors.push({ path: `/${docPath}`, error: errorMessage });
|
|
439
|
+
logger.warn('Failed to load document for listing', { path: docPath, error });
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
446
|
+
errors.push({ path: dir, error: errorMessage });
|
|
447
|
+
logger.warn('Failed to read directory', { dir, error });
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
await findMarkdownFiles(this.docsRoot);
|
|
451
|
+
// Sort by last modified descending
|
|
452
|
+
documents.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
|
|
453
|
+
return {
|
|
454
|
+
documents,
|
|
455
|
+
...(errors.length > 0 && { errors })
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* List document fingerprints for efficient discovery operations
|
|
460
|
+
*
|
|
461
|
+
* Returns lightweight fingerprint data for all documents without triggering
|
|
462
|
+
* full document parsing. Uses cached fingerprints when available and fresh.
|
|
463
|
+
*
|
|
464
|
+
* @param options - Configuration options
|
|
465
|
+
* @returns Promise resolving to array of valid fingerprint entries
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* // Get all document fingerprints
|
|
469
|
+
* const fingerprints = await manager.listDocumentFingerprints();
|
|
470
|
+
* console.log(`Found ${fingerprints.length} documents with fingerprints`);
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* // Get fingerprints for specific namespace with stale refresh
|
|
474
|
+
* const apiFingerprints = await manager.listDocumentFingerprints({
|
|
475
|
+
* namespace: 'api',
|
|
476
|
+
* refreshStale: true
|
|
477
|
+
* });
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* // Use for efficient discovery without full parsing
|
|
481
|
+
* const fingerprints = await manager.listDocumentFingerprints();
|
|
482
|
+
* const relevantDocs = fingerprints.filter(fp =>
|
|
483
|
+
* fp.keywords.some(keyword => targetKeywords.includes(keyword))
|
|
484
|
+
* );
|
|
485
|
+
*/
|
|
486
|
+
async listDocumentFingerprints(options) {
|
|
487
|
+
const startTime = performance.now();
|
|
488
|
+
const fingerprints = [];
|
|
489
|
+
const staleDocuments = [];
|
|
490
|
+
// Default options
|
|
491
|
+
const refreshStale = options?.refreshStale ?? false;
|
|
492
|
+
const namespaceFilter = options?.namespace;
|
|
493
|
+
const processMarkdownFiles = async (dir, basePath = '') => {
|
|
494
|
+
try {
|
|
495
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
496
|
+
for (const entry of entries) {
|
|
497
|
+
const fullPath = path.join(dir, entry.name);
|
|
498
|
+
const docPath = path.join(basePath, entry.name);
|
|
499
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
500
|
+
await processMarkdownFiles(fullPath, docPath);
|
|
501
|
+
}
|
|
502
|
+
else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
503
|
+
const normalizedDocPath = `/${docPath}`;
|
|
504
|
+
try {
|
|
505
|
+
// First check if we have a cached document with valid fingerprint
|
|
506
|
+
const cachedDocument = this.cache.getCachedPaths().includes(normalizedDocPath)
|
|
507
|
+
? await this.cache.getDocument(normalizedDocPath)
|
|
508
|
+
: null;
|
|
509
|
+
if (cachedDocument != null) {
|
|
510
|
+
// Check if fingerprint is stale
|
|
511
|
+
const isStale = await this.cache.isFingerprintStale(normalizedDocPath);
|
|
512
|
+
if (isStale) {
|
|
513
|
+
staleDocuments.push(normalizedDocPath);
|
|
514
|
+
if (refreshStale) {
|
|
515
|
+
// Invalidate and reload to get fresh fingerprint
|
|
516
|
+
this.cache.invalidateDocument(normalizedDocPath);
|
|
517
|
+
const freshDocument = await this.cache.getDocument(normalizedDocPath);
|
|
518
|
+
if (freshDocument != null) {
|
|
519
|
+
const fingerprint = this.cache.createFingerprintEntry(freshDocument.metadata);
|
|
520
|
+
// Apply namespace filter if specified
|
|
521
|
+
if (namespaceFilter == null || fingerprint.namespace === namespaceFilter) {
|
|
522
|
+
fingerprints.push(fingerprint);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
// If not refreshing stale, skip this document
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
// Use cached fingerprint
|
|
530
|
+
const fingerprint = this.cache.createFingerprintEntry(cachedDocument.metadata);
|
|
531
|
+
// Apply namespace filter if specified
|
|
532
|
+
if (namespaceFilter == null || fingerprint.namespace === namespaceFilter) {
|
|
533
|
+
fingerprints.push(fingerprint);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
// No cached version - need to load to get fingerprint
|
|
539
|
+
// This is efficient since we only load metadata, not sections
|
|
540
|
+
const document = await this.cache.getDocument(normalizedDocPath);
|
|
541
|
+
if (document != null) {
|
|
542
|
+
const fingerprint = this.cache.createFingerprintEntry(document.metadata);
|
|
543
|
+
// Apply namespace filter if specified
|
|
544
|
+
if (namespaceFilter == null || fingerprint.namespace === namespaceFilter) {
|
|
545
|
+
fingerprints.push(fingerprint);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
logger.warn('Failed to process document for fingerprint listing', {
|
|
552
|
+
path: normalizedDocPath,
|
|
553
|
+
error
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
catch (error) {
|
|
560
|
+
logger.warn('Failed to read directory for fingerprint listing', { dir, error });
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
await processMarkdownFiles(this.docsRoot);
|
|
564
|
+
const endTime = performance.now();
|
|
565
|
+
const durationMs = Math.round(endTime - startTime);
|
|
566
|
+
logger.debug('Listed document fingerprints', {
|
|
567
|
+
totalFingerprints: fingerprints.length,
|
|
568
|
+
staleDocuments: staleDocuments.length,
|
|
569
|
+
refreshStale,
|
|
570
|
+
namespaceFilter,
|
|
571
|
+
durationMs
|
|
572
|
+
});
|
|
573
|
+
// Sort by last modified descending for consistency with listDocuments
|
|
574
|
+
fingerprints.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
|
|
575
|
+
return fingerprints;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Search documents
|
|
579
|
+
*/
|
|
580
|
+
async searchDocuments(query, options = {}) {
|
|
581
|
+
const searchOptions = {
|
|
582
|
+
searchIn: ['title', 'headings', 'content'],
|
|
583
|
+
fuzzy: false,
|
|
584
|
+
boost: { title: 2.0, headings: 1.5, code: 1.2 },
|
|
585
|
+
highlight: true,
|
|
586
|
+
groupByDocument: true,
|
|
587
|
+
...options
|
|
588
|
+
};
|
|
589
|
+
const results = [];
|
|
590
|
+
const queryLower = query.toLowerCase();
|
|
591
|
+
// OPTIMIZATION: Use fingerprint index if available
|
|
592
|
+
let documentsToSearch;
|
|
593
|
+
if (this.fingerprintIndex?.isInitialized() === true) {
|
|
594
|
+
// Fast path: Filter candidates using fingerprint index
|
|
595
|
+
const candidates = this.fingerprintIndex.findCandidates(query);
|
|
596
|
+
documentsToSearch = candidates;
|
|
597
|
+
const { documents: allDocuments } = await this.listDocuments();
|
|
598
|
+
logger.debug('Search candidates filtered', {
|
|
599
|
+
query,
|
|
600
|
+
totalDocuments: allDocuments.length,
|
|
601
|
+
candidates: candidates.length,
|
|
602
|
+
reduction: allDocuments.length > 0
|
|
603
|
+
? `${Math.round((1 - candidates.length / allDocuments.length) * 100)}%`
|
|
604
|
+
: '0%'
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
// Slow path: Search all documents
|
|
609
|
+
const { documents: allDocs } = await this.listDocuments();
|
|
610
|
+
documentsToSearch = allDocs.map(d => d.path);
|
|
611
|
+
logger.debug('Search without fingerprint index', {
|
|
612
|
+
query,
|
|
613
|
+
totalDocuments: documentsToSearch.length
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
// Deep search only in candidates - use 'search' context for boost
|
|
617
|
+
for (const docPath of documentsToSearch) {
|
|
618
|
+
const document = await this.cache.getDocument(docPath, AccessContext.SEARCH);
|
|
619
|
+
if (!document)
|
|
620
|
+
continue;
|
|
621
|
+
const matches = [];
|
|
622
|
+
// Search in title
|
|
623
|
+
if (searchOptions.searchIn.includes('title')) {
|
|
624
|
+
const title = document.metadata.title.toLowerCase();
|
|
625
|
+
if (title.includes(queryLower)) {
|
|
626
|
+
matches.push({
|
|
627
|
+
type: 'title',
|
|
628
|
+
snippet: document.metadata.title,
|
|
629
|
+
score: (searchOptions.boost.title ?? 1.0) * 10
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
// Search in headings
|
|
634
|
+
if (searchOptions.searchIn.includes('headings')) {
|
|
635
|
+
for (const heading of document.headings) {
|
|
636
|
+
const headingText = heading.title.toLowerCase();
|
|
637
|
+
if (headingText.includes(queryLower)) {
|
|
638
|
+
matches.push({
|
|
639
|
+
type: 'heading',
|
|
640
|
+
slug: heading.slug,
|
|
641
|
+
snippet: heading.title,
|
|
642
|
+
score: (searchOptions.boost.headings ?? 1.0) * (7 - heading.depth)
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
// Search in content using our section tools
|
|
648
|
+
if (searchOptions.searchIn.includes('content')) {
|
|
649
|
+
try {
|
|
650
|
+
// Search within each section using our readSection tool
|
|
651
|
+
for (const heading of document.headings) {
|
|
652
|
+
const sectionContent = await this.cache.getSectionContent(docPath, heading.slug);
|
|
653
|
+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
654
|
+
if (sectionContent != null && sectionContent.toLowerCase().includes(queryLower)) {
|
|
655
|
+
// Extract a meaningful snippet from the section
|
|
656
|
+
const lines = sectionContent.split('\n').filter(line => line.trim() !== '' &&
|
|
657
|
+
!line.trim().startsWith('#') &&
|
|
658
|
+
line.toLowerCase().includes(queryLower));
|
|
659
|
+
if (lines.length > 0) {
|
|
660
|
+
const firstLine = lines[0];
|
|
661
|
+
if (firstLine != null) {
|
|
662
|
+
matches.push({
|
|
663
|
+
type: 'content',
|
|
664
|
+
slug: heading.slug,
|
|
665
|
+
snippet: firstLine.trim().substring(0, 200), // Limit snippet length
|
|
666
|
+
score: 1.0 * (heading.depth <= 3 ? 1.2 : 1.0) // Boost matches in higher-level sections
|
|
667
|
+
});
|
|
668
|
+
break; // Only one content match per document for now
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
catch (error) {
|
|
675
|
+
logger.warn('Failed to search content', { path: docPath, error });
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (matches.length > 0) {
|
|
679
|
+
results.push({
|
|
680
|
+
documentPath: docPath,
|
|
681
|
+
documentTitle: document.metadata.title,
|
|
682
|
+
matches: matches.sort((a, b) => b.score - a.score)
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
// Sort results by best match score
|
|
687
|
+
results.sort((a, b) => {
|
|
688
|
+
const maxScoreA = Math.max(...a.matches.map(m => m.score));
|
|
689
|
+
const maxScoreB = Math.max(...b.matches.map(m => m.score));
|
|
690
|
+
return maxScoreB - maxScoreA;
|
|
691
|
+
});
|
|
692
|
+
return results;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Get document by path
|
|
696
|
+
*/
|
|
697
|
+
async getDocument(docPath) {
|
|
698
|
+
return await this.cache.getDocument(docPath);
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Get section content
|
|
702
|
+
*/
|
|
703
|
+
async getSectionContent(docPath, slug) {
|
|
704
|
+
return await this.cache.getSectionContent(docPath, slug);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Get complete document content
|
|
708
|
+
*
|
|
709
|
+
* Retrieves the full content of a document from the filesystem.
|
|
710
|
+
* This method provides direct access to the entire document content
|
|
711
|
+
* without going through the section-based cache system, making it
|
|
712
|
+
* ideal for operations that need the complete document like relevance
|
|
713
|
+
* analysis and keyword extraction.
|
|
714
|
+
*
|
|
715
|
+
* @param docPath - Relative path to the document (e.g., "api/auth.md")
|
|
716
|
+
* @returns Promise resolving to full document content or null if file doesn't exist
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* const content = await manager.getDocumentContent("api/authentication.md");
|
|
720
|
+
* if (content) {
|
|
721
|
+
* const keywords = extractKeywords(content);
|
|
722
|
+
* console.log(`Found keywords: ${keywords.join(', ')}`);
|
|
723
|
+
* }
|
|
724
|
+
*
|
|
725
|
+
* @throws {Error} When file access fails due to permissions or other filesystem errors
|
|
726
|
+
*/
|
|
727
|
+
async getDocumentContent(docPath) {
|
|
728
|
+
return await this.cache.readDocumentContent(docPath);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Destroy the document manager and clean up resources
|
|
732
|
+
* Cancels all pending TOC updates and destroys the cache
|
|
733
|
+
*/
|
|
734
|
+
async destroy() {
|
|
735
|
+
// Cancel all pending TOC updates
|
|
736
|
+
for (const timeoutId of this.pendingTocUpdates.values()) {
|
|
737
|
+
clearTimeout(timeoutId);
|
|
738
|
+
}
|
|
739
|
+
this.pendingTocUpdates.clear();
|
|
740
|
+
// Destroy cache
|
|
741
|
+
await this.cache.destroy();
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Convert document path to absolute filesystem path
|
|
745
|
+
*/
|
|
746
|
+
getAbsolutePath(docPath) {
|
|
747
|
+
const relativePath = docPath.startsWith('/') ? docPath.slice(1) : docPath;
|
|
748
|
+
// Check if this is a coordinator path
|
|
749
|
+
if (relativePath.startsWith('coordinator/') || relativePath === 'coordinator') {
|
|
750
|
+
// Use coordinator root and remove the 'coordinator/' prefix
|
|
751
|
+
const coordPath = relativePath === 'coordinator'
|
|
752
|
+
? ''
|
|
753
|
+
: relativePath.slice('coordinator/'.length);
|
|
754
|
+
return path.join(this.coordinatorRoot, coordPath);
|
|
755
|
+
}
|
|
756
|
+
// Default to docs root
|
|
757
|
+
return path.join(this.docsRoot, relativePath);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
//# sourceMappingURL=document-manager.js.map
|