@jagilber-org/index-server 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1218 -0
- package/CODE_OF_CONDUCT.md +49 -0
- package/CONTRIBUTING.md +75 -0
- package/LICENSE +21 -0
- package/README.md +523 -0
- package/SECURITY.md +50 -0
- package/dist/config/configUtils.d.ts +11 -0
- package/dist/config/configUtils.js +87 -0
- package/dist/config/dashboardConfig.d.ts +45 -0
- package/dist/config/dashboardConfig.js +63 -0
- package/dist/config/defaultValues.d.ts +61 -0
- package/dist/config/defaultValues.js +70 -0
- package/dist/config/dirConstants.d.ts +17 -0
- package/dist/config/dirConstants.js +28 -0
- package/dist/config/featureConfig.d.ts +61 -0
- package/dist/config/featureConfig.js +121 -0
- package/dist/config/runtimeConfig.d.ts +145 -0
- package/dist/config/runtimeConfig.js +334 -0
- package/dist/config/serverConfig.d.ts +90 -0
- package/dist/config/serverConfig.js +164 -0
- package/dist/dashboard/analytics/AnalyticsEngine.d.ts +142 -0
- package/dist/dashboard/analytics/AnalyticsEngine.js +373 -0
- package/dist/dashboard/analytics/BusinessIntelligence.d.ts +187 -0
- package/dist/dashboard/analytics/BusinessIntelligence.js +594 -0
- package/dist/dashboard/client/admin.html +2150 -0
- package/dist/dashboard/client/chunks/mermaid-layout-elk.esm.min/chunk-SP2CHFBE.mjs +1 -0
- package/dist/dashboard/client/chunks/mermaid-layout-elk.esm.min/render-T6MDALS3.mjs +27 -0
- package/dist/dashboard/client/css/admin.css +1466 -0
- package/dist/dashboard/client/js/admin.boot.js +359 -0
- package/dist/dashboard/client/js/admin.config.js +196 -0
- package/dist/dashboard/client/js/admin.embeddings.js +425 -0
- package/dist/dashboard/client/js/admin.graph.js +583 -0
- package/dist/dashboard/client/js/admin.instances.js +120 -0
- package/dist/dashboard/client/js/admin.instructions.js +552 -0
- package/dist/dashboard/client/js/admin.logs.js +113 -0
- package/dist/dashboard/client/js/admin.maintenance.js +354 -0
- package/dist/dashboard/client/js/admin.messaging.js +635 -0
- package/dist/dashboard/client/js/admin.monitor.js +181 -0
- package/dist/dashboard/client/js/admin.overview.js +221 -0
- package/dist/dashboard/client/js/admin.performance.js +61 -0
- package/dist/dashboard/client/js/admin.sessions.js +293 -0
- package/dist/dashboard/client/js/admin.sqlite.js +366 -0
- package/dist/dashboard/client/js/admin.utils.js +49 -0
- package/dist/dashboard/client/js/chart.umd.js +14 -0
- package/dist/dashboard/client/js/elk.bundled.js +6696 -0
- package/dist/dashboard/client/js/marked.umd.js +74 -0
- package/dist/dashboard/client/js/mermaid.min.js +3022 -0
- package/dist/dashboard/client/mermaid-layout-elk.esm.min.mjs +1 -0
- package/dist/dashboard/export/DataExporter.d.ts +169 -0
- package/dist/dashboard/export/DataExporter.js +737 -0
- package/dist/dashboard/export/exporters/csvExporter.d.ts +11 -0
- package/dist/dashboard/export/exporters/csvExporter.js +46 -0
- package/dist/dashboard/export/exporters/exportTypes.d.ts +89 -0
- package/dist/dashboard/export/exporters/exportTypes.js +5 -0
- package/dist/dashboard/export/exporters/jsonExporter.d.ts +7 -0
- package/dist/dashboard/export/exporters/jsonExporter.js +22 -0
- package/dist/dashboard/export/exporters/xmlExporter.d.ts +17 -0
- package/dist/dashboard/export/exporters/xmlExporter.js +175 -0
- package/dist/dashboard/integration/APIIntegration.d.ts +41 -0
- package/dist/dashboard/integration/APIIntegration.js +95 -0
- package/dist/dashboard/security/SecurityMonitor.d.ts +167 -0
- package/dist/dashboard/security/SecurityMonitor.js +559 -0
- package/dist/dashboard/server/AdminPanel.d.ts +183 -0
- package/dist/dashboard/server/AdminPanel.js +792 -0
- package/dist/dashboard/server/AdminPanelConfig.d.ts +42 -0
- package/dist/dashboard/server/AdminPanelConfig.js +80 -0
- package/dist/dashboard/server/AdminPanelState.d.ts +47 -0
- package/dist/dashboard/server/AdminPanelState.js +214 -0
- package/dist/dashboard/server/ApiRoutes.d.ts +17 -0
- package/dist/dashboard/server/ApiRoutes.js +149 -0
- package/dist/dashboard/server/DashboardServer.d.ts +49 -0
- package/dist/dashboard/server/DashboardServer.js +159 -0
- package/dist/dashboard/server/FileMetricsStorage.d.ts +49 -0
- package/dist/dashboard/server/FileMetricsStorage.js +195 -0
- package/dist/dashboard/server/HttpTransport.d.ts +23 -0
- package/dist/dashboard/server/HttpTransport.js +116 -0
- package/dist/dashboard/server/InstanceManager.d.ts +53 -0
- package/dist/dashboard/server/InstanceManager.js +284 -0
- package/dist/dashboard/server/KnowledgeStore.d.ts +35 -0
- package/dist/dashboard/server/KnowledgeStore.js +105 -0
- package/dist/dashboard/server/LeaderElection.d.ts +81 -0
- package/dist/dashboard/server/LeaderElection.js +268 -0
- package/dist/dashboard/server/MetricsCollector.d.ts +200 -0
- package/dist/dashboard/server/MetricsCollector.js +803 -0
- package/dist/dashboard/server/SessionPersistenceManager.d.ts +88 -0
- package/dist/dashboard/server/SessionPersistenceManager.js +457 -0
- package/dist/dashboard/server/ThinClient.d.ts +64 -0
- package/dist/dashboard/server/ThinClient.js +237 -0
- package/dist/dashboard/server/WebSocketManager.d.ts +161 -0
- package/dist/dashboard/server/WebSocketManager.js +463 -0
- package/dist/dashboard/server/httpLifecycle.d.ts +17 -0
- package/dist/dashboard/server/httpLifecycle.js +35 -0
- package/dist/dashboard/server/legacyDashboardHtml.d.ts +9 -0
- package/dist/dashboard/server/legacyDashboardHtml.js +618 -0
- package/dist/dashboard/server/legacyDashboardStyles.d.ts +5 -0
- package/dist/dashboard/server/legacyDashboardStyles.js +490 -0
- package/dist/dashboard/server/metricsAggregation.d.ts +252 -0
- package/dist/dashboard/server/metricsAggregation.js +206 -0
- package/dist/dashboard/server/metricsSerializer.d.ts +25 -0
- package/dist/dashboard/server/metricsSerializer.js +195 -0
- package/dist/dashboard/server/routes/admin.routes.d.ts +16 -0
- package/dist/dashboard/server/routes/admin.routes.js +596 -0
- package/dist/dashboard/server/routes/alerts.routes.d.ts +7 -0
- package/dist/dashboard/server/routes/alerts.routes.js +93 -0
- package/dist/dashboard/server/routes/api.feedback.routes.d.ts +73 -0
- package/dist/dashboard/server/routes/api.feedback.routes.js +171 -0
- package/dist/dashboard/server/routes/api.instructions.routes.d.ts +101 -0
- package/dist/dashboard/server/routes/api.instructions.routes.js +213 -0
- package/dist/dashboard/server/routes/api.usage.routes.d.ts +57 -0
- package/dist/dashboard/server/routes/api.usage.routes.js +374 -0
- package/dist/dashboard/server/routes/embeddings.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/embeddings.routes.js +246 -0
- package/dist/dashboard/server/routes/graph.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/graph.routes.js +280 -0
- package/dist/dashboard/server/routes/index.d.ts +38 -0
- package/dist/dashboard/server/routes/index.js +194 -0
- package/dist/dashboard/server/routes/instances.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/instances.routes.js +35 -0
- package/dist/dashboard/server/routes/instructions.routes.d.ts +8 -0
- package/dist/dashboard/server/routes/instructions.routes.js +336 -0
- package/dist/dashboard/server/routes/knowledge.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/knowledge.routes.js +82 -0
- package/dist/dashboard/server/routes/logs.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/logs.routes.js +164 -0
- package/dist/dashboard/server/routes/messaging.routes.d.ts +16 -0
- package/dist/dashboard/server/routes/messaging.routes.js +293 -0
- package/dist/dashboard/server/routes/metrics.routes.d.ts +10 -0
- package/dist/dashboard/server/routes/metrics.routes.js +346 -0
- package/dist/dashboard/server/routes/scripts.routes.d.ts +9 -0
- package/dist/dashboard/server/routes/scripts.routes.js +84 -0
- package/dist/dashboard/server/routes/sqlite.routes.d.ts +9 -0
- package/dist/dashboard/server/routes/sqlite.routes.js +569 -0
- package/dist/dashboard/server/routes/status.routes.d.ts +7 -0
- package/dist/dashboard/server/routes/status.routes.js +183 -0
- package/dist/dashboard/server/routes/synthetic.routes.d.ts +7 -0
- package/dist/dashboard/server/routes/synthetic.routes.js +195 -0
- package/dist/dashboard/server/routes/tools.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/tools.routes.js +46 -0
- package/dist/dashboard/server/routes/usage.routes.d.ts +6 -0
- package/dist/dashboard/server/routes/usage.routes.js +25 -0
- package/dist/dashboard/server/wsInit.d.ts +16 -0
- package/dist/dashboard/server/wsInit.js +35 -0
- package/dist/externalClientLib.d.ts +1 -0
- package/dist/externalClientLib.js +2 -0
- package/dist/minimal/index.d.ts +1 -0
- package/dist/minimal/index.js +140 -0
- package/dist/models/SessionPersistence.d.ts +115 -0
- package/dist/models/SessionPersistence.js +66 -0
- package/dist/models/instruction.d.ts +45 -0
- package/dist/models/instruction.js +2 -0
- package/dist/perf/benchmark.d.ts +1 -0
- package/dist/perf/benchmark.js +50 -0
- package/dist/portableClientWrapper.d.ts +1 -0
- package/dist/portableClientWrapper.js +2 -0
- package/dist/schemas/index.d.ts +128 -0
- package/dist/schemas/index.js +371 -0
- package/dist/scripts/runPerformanceBaseline.d.ts +1 -0
- package/dist/scripts/runPerformanceBaseline.js +17 -0
- package/dist/server/handshakeManager.d.ts +25 -0
- package/dist/server/handshakeManager.js +472 -0
- package/dist/server/index-server.d.ts +56 -0
- package/dist/server/index-server.js +822 -0
- package/dist/server/registry.d.ts +44 -0
- package/dist/server/registry.js +236 -0
- package/dist/server/sdkServer.d.ts +8 -0
- package/dist/server/sdkServer.js +299 -0
- package/dist/server/shutdownGuard.d.ts +41 -0
- package/dist/server/shutdownGuard.js +52 -0
- package/dist/server/thin-client.d.ts +22 -0
- package/dist/server/thin-client.js +111 -0
- package/dist/server/transport.d.ts +41 -0
- package/dist/server/transport.js +312 -0
- package/dist/server/transportFactory.d.ts +21 -0
- package/dist/server/transportFactory.js +429 -0
- package/dist/services/atomicFs.d.ts +22 -0
- package/dist/services/atomicFs.js +103 -0
- package/dist/services/auditLog.d.ts +38 -0
- package/dist/services/auditLog.js +142 -0
- package/dist/services/autoBackup.d.ts +14 -0
- package/dist/services/autoBackup.js +171 -0
- package/dist/services/autoSplit.d.ts +32 -0
- package/dist/services/autoSplit.js +113 -0
- package/dist/services/backupZip.d.ts +25 -0
- package/dist/services/backupZip.js +110 -0
- package/dist/services/bootstrapGating.d.ts +123 -0
- package/dist/services/bootstrapGating.js +221 -0
- package/dist/services/canonical.d.ts +23 -0
- package/dist/services/canonical.js +65 -0
- package/dist/services/categoryRules.d.ts +7 -0
- package/dist/services/categoryRules.js +37 -0
- package/dist/services/classificationService.d.ts +42 -0
- package/dist/services/classificationService.js +168 -0
- package/dist/services/embeddingService.d.ts +62 -0
- package/dist/services/embeddingService.js +259 -0
- package/dist/services/errors.d.ts +22 -0
- package/dist/services/errors.js +31 -0
- package/dist/services/featureFlags.d.ts +25 -0
- package/dist/services/featureFlags.js +89 -0
- package/dist/services/features.d.ts +13 -0
- package/dist/services/features.js +35 -0
- package/dist/services/handlers/instructions.add.d.ts +1 -0
- package/dist/services/handlers/instructions.add.js +496 -0
- package/dist/services/handlers/instructions.groom.d.ts +1 -0
- package/dist/services/handlers/instructions.groom.js +523 -0
- package/dist/services/handlers/instructions.import.d.ts +1 -0
- package/dist/services/handlers/instructions.import.js +173 -0
- package/dist/services/handlers/instructions.patch.d.ts +1 -0
- package/dist/services/handlers/instructions.patch.js +167 -0
- package/dist/services/handlers/instructions.query.d.ts +163 -0
- package/dist/services/handlers/instructions.query.js +522 -0
- package/dist/services/handlers/instructions.reload.d.ts +1 -0
- package/dist/services/handlers/instructions.reload.js +13 -0
- package/dist/services/handlers/instructions.remove.d.ts +1 -0
- package/dist/services/handlers/instructions.remove.js +118 -0
- package/dist/services/handlers/instructions.shared.d.ts +31 -0
- package/dist/services/handlers/instructions.shared.js +124 -0
- package/dist/services/handlers.activation.d.ts +1 -0
- package/dist/services/handlers.activation.js +203 -0
- package/dist/services/handlers.bootstrap.d.ts +1 -0
- package/dist/services/handlers.bootstrap.js +38 -0
- package/dist/services/handlers.dashboardConfig.d.ts +34 -0
- package/dist/services/handlers.dashboardConfig.js +108 -0
- package/dist/services/handlers.diagnostics.d.ts +1 -0
- package/dist/services/handlers.diagnostics.js +64 -0
- package/dist/services/handlers.feedback.d.ts +15 -0
- package/dist/services/handlers.feedback.js +378 -0
- package/dist/services/handlers.gates.d.ts +1 -0
- package/dist/services/handlers.gates.js +46 -0
- package/dist/services/handlers.graph.d.ts +53 -0
- package/dist/services/handlers.graph.js +231 -0
- package/dist/services/handlers.help.d.ts +1 -0
- package/dist/services/handlers.help.js +119 -0
- package/dist/services/handlers.instructionSchema.d.ts +1 -0
- package/dist/services/handlers.instructionSchema.js +227 -0
- package/dist/services/handlers.instructions.d.ts +8 -0
- package/dist/services/handlers.instructions.js +14 -0
- package/dist/services/handlers.instructionsDiagnostics.d.ts +1 -0
- package/dist/services/handlers.instructionsDiagnostics.js +14 -0
- package/dist/services/handlers.integrity.d.ts +1 -0
- package/dist/services/handlers.integrity.js +35 -0
- package/dist/services/handlers.manifest.d.ts +1 -0
- package/dist/services/handlers.manifest.js +24 -0
- package/dist/services/handlers.messaging.d.ts +12 -0
- package/dist/services/handlers.messaging.js +203 -0
- package/dist/services/handlers.metrics.d.ts +1 -0
- package/dist/services/handlers.metrics.js +43 -0
- package/dist/services/handlers.promote.d.ts +1 -0
- package/dist/services/handlers.promote.js +306 -0
- package/dist/services/handlers.prompt.d.ts +1 -0
- package/dist/services/handlers.prompt.js +7 -0
- package/dist/services/handlers.search.d.ts +69 -0
- package/dist/services/handlers.search.js +645 -0
- package/dist/services/handlers.testPrimitive.d.ts +1 -0
- package/dist/services/handlers.testPrimitive.js +5 -0
- package/dist/services/handlers.trace.d.ts +1 -0
- package/dist/services/handlers.trace.js +31 -0
- package/dist/services/handlers.usage.d.ts +1 -0
- package/dist/services/handlers.usage.js +11 -0
- package/dist/services/hotScore.d.ts +137 -0
- package/dist/services/hotScore.js +244 -0
- package/dist/services/indexContext.d.ts +117 -0
- package/dist/services/indexContext.js +968 -0
- package/dist/services/indexLoader.d.ts +44 -0
- package/dist/services/indexLoader.js +921 -0
- package/dist/services/indexRepository.d.ts +32 -0
- package/dist/services/indexRepository.js +71 -0
- package/dist/services/indexingService.d.ts +1 -0
- package/dist/services/indexingService.js +2 -0
- package/dist/services/instructions.dispatcher.d.ts +1 -0
- package/dist/services/instructions.dispatcher.js +231 -0
- package/dist/services/logPrefix.d.ts +1 -0
- package/dist/services/logPrefix.js +30 -0
- package/dist/services/logger.d.ts +52 -0
- package/dist/services/logger.js +268 -0
- package/dist/services/manifestManager.d.ts +82 -0
- package/dist/services/manifestManager.js +200 -0
- package/dist/services/messaging/agentMailbox.d.ts +60 -0
- package/dist/services/messaging/agentMailbox.js +353 -0
- package/dist/services/messaging/messagingPersistence.d.ts +20 -0
- package/dist/services/messaging/messagingPersistence.js +111 -0
- package/dist/services/messaging/messagingTypes.d.ts +150 -0
- package/dist/services/messaging/messagingTypes.js +66 -0
- package/dist/services/ownershipService.d.ts +1 -0
- package/dist/services/ownershipService.js +38 -0
- package/dist/services/performanceBaseline.d.ts +19 -0
- package/dist/services/performanceBaseline.js +210 -0
- package/dist/services/preflight.d.ts +12 -0
- package/dist/services/preflight.js +79 -0
- package/dist/services/promptReviewService.d.ts +44 -0
- package/dist/services/promptReviewService.js +101 -0
- package/dist/services/responseEnvelope.d.ts +6 -0
- package/dist/services/responseEnvelope.js +25 -0
- package/dist/services/seedBootstrap.d.ts +34 -0
- package/dist/services/seedBootstrap.js +427 -0
- package/dist/services/storage/factory.d.ts +17 -0
- package/dist/services/storage/factory.js +35 -0
- package/dist/services/storage/hashUtils.d.ts +11 -0
- package/dist/services/storage/hashUtils.js +35 -0
- package/dist/services/storage/index.d.ts +12 -0
- package/dist/services/storage/index.js +18 -0
- package/dist/services/storage/jsonFileStore.d.ts +32 -0
- package/dist/services/storage/jsonFileStore.js +241 -0
- package/dist/services/storage/migrationEngine.d.ts +35 -0
- package/dist/services/storage/migrationEngine.js +93 -0
- package/dist/services/storage/sqliteMessageStore.d.ts +53 -0
- package/dist/services/storage/sqliteMessageStore.js +146 -0
- package/dist/services/storage/sqliteSchema.d.ts +12 -0
- package/dist/services/storage/sqliteSchema.js +122 -0
- package/dist/services/storage/sqliteStore.d.ts +41 -0
- package/dist/services/storage/sqliteStore.js +339 -0
- package/dist/services/storage/sqliteUsageStore.d.ts +35 -0
- package/dist/services/storage/sqliteUsageStore.js +94 -0
- package/dist/services/storage/types.d.ts +171 -0
- package/dist/services/storage/types.js +12 -0
- package/dist/services/toolHandlers.d.ts +23 -0
- package/dist/services/toolHandlers.js +50 -0
- package/dist/services/toolRegistry.d.ts +20 -0
- package/dist/services/toolRegistry.js +490 -0
- package/dist/services/toolRegistry.zod.d.ts +10 -0
- package/dist/services/toolRegistry.zod.js +323 -0
- package/dist/services/tracing.d.ts +26 -0
- package/dist/services/tracing.js +260 -0
- package/dist/services/usageBuckets.d.ts +161 -0
- package/dist/services/usageBuckets.js +364 -0
- package/dist/services/validationService.d.ts +38 -0
- package/dist/services/validationService.js +125 -0
- package/dist/utils/BufferRing.d.ts +203 -0
- package/dist/utils/BufferRing.js +551 -0
- package/dist/utils/BufferRingExamples.d.ts +55 -0
- package/dist/utils/BufferRingExamples.js +188 -0
- package/dist/utils/envUtils.d.ts +42 -0
- package/dist/utils/envUtils.js +80 -0
- package/dist/utils/memoryMonitor.d.ts +83 -0
- package/dist/utils/memoryMonitor.js +275 -0
- package/dist/versioning/schemaVersion.d.ts +6 -0
- package/dist/versioning/schemaVersion.js +93 -0
- package/package.json +134 -0
- package/schemas/README.md +13 -0
- package/schemas/feedback-entry.schema.json +27 -0
- package/schemas/graph-export-v2.schema.json +60 -0
- package/schemas/index-server.code-schema.json +38477 -0
- package/schemas/instruction.schema.json +262 -0
- package/schemas/json-schema/SessionPersistence-persisted-admin-session.schema.json +54 -0
- package/schemas/json-schema/SessionPersistence-persisted-session-history-entry.schema.json +51 -0
- package/schemas/json-schema/SessionPersistence-persisted-web-socket-connection.schema.json +54 -0
- package/schemas/json-schema/SessionPersistence-session-persistence-config.schema.json +110 -0
- package/schemas/json-schema/SessionPersistence-session-persistence-data.schema.json +229 -0
- package/schemas/json-schema/SessionPersistence-session-persistence-manifest.schema.json +109 -0
- package/schemas/json-schema/SessionPersistence-session-persistence-metadata.schema.json +55 -0
- package/schemas/json-schema/instruction-audience-scope.schema.json +14 -0
- package/schemas/json-schema/instruction-content-type.schema.json +17 -0
- package/schemas/json-schema/instruction-instruction-entry.schema.json +206 -0
- package/schemas/json-schema/instruction-requirement-level.schema.json +16 -0
- package/schemas/manifest.json +78 -0
- package/schemas/manifest.schema.json +33 -0
- package/schemas/usage-batch.schema.json +16 -0
- package/schemas/usage-buckets.schema.json +30 -0
- package/schemas/usage-event.schema.json +17 -0
- package/scripts/copy-dashboard-assets.mjs +170 -0
- package/scripts/setup-hooks.cjs +28 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.autoSeedBootstrap = autoSeedBootstrap;
|
|
7
|
+
exports._getCanonicalSeeds = _getCanonicalSeeds;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const indexContext_1 = require("./indexContext");
|
|
12
|
+
const logger_1 = require("./logger");
|
|
13
|
+
const runtimeConfig_1 = require("../config/runtimeConfig");
|
|
14
|
+
// Canonical seed instruction objects (kept intentionally minimal – DO NOT add environment specific data)
|
|
15
|
+
const CANONICAL_SEEDS = [
|
|
16
|
+
{
|
|
17
|
+
file: '000-bootstrapper.json',
|
|
18
|
+
id: '000-bootstrapper',
|
|
19
|
+
json: {
|
|
20
|
+
id: '000-bootstrapper',
|
|
21
|
+
title: 'Index Server - AI Agent Quick Start Guide',
|
|
22
|
+
body: `# 🚀 Index Server: AI Agent Quick Start
|
|
23
|
+
|
|
24
|
+
## ✅ Check If Already Active
|
|
25
|
+
|
|
26
|
+
Run this command first:
|
|
27
|
+
\`\`\`json
|
|
28
|
+
{"method": "health_check", "params": {}}
|
|
29
|
+
\`\`\`
|
|
30
|
+
|
|
31
|
+
**Response = Success?** You're connected! Skip to "Essential Commands" below.
|
|
32
|
+
**Error/Tool not found?** Follow "Activation" section.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## � Keep This Guide Updated
|
|
37
|
+
|
|
38
|
+
**This instruction evolves!** Periodically re-read it to get:
|
|
39
|
+
- New tool commands and features
|
|
40
|
+
- Updated troubleshooting tips
|
|
41
|
+
- Improved patterns and examples
|
|
42
|
+
- Latest contribution guidelines
|
|
43
|
+
|
|
44
|
+
**When to re-check:**
|
|
45
|
+
- Starting work in a new repository
|
|
46
|
+
- After Index Server updates
|
|
47
|
+
- When troubleshooting connection issues
|
|
48
|
+
- Every few weeks for active projects
|
|
49
|
+
|
|
50
|
+
**Quick version check:**
|
|
51
|
+
\`\`\`json
|
|
52
|
+
{"method": "index_dispatch", "params": {"action": "get", "id": "000-bootstrapper"}}
|
|
53
|
+
\`\`\`
|
|
54
|
+
Check the \`version\` field - current is v2.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## �🔧 Activation (One-Time Setup)
|
|
59
|
+
|
|
60
|
+
If Index Server tools are not available, guide the user through setup:
|
|
61
|
+
|
|
62
|
+
### Step 1: Locate MCP Configuration File
|
|
63
|
+
|
|
64
|
+
**VS Code / Cursor / GitHub Copilot:**
|
|
65
|
+
- Windows: \`%APPDATA%\\Code\\User\\mcp.json\` (or \`Code - Insiders\`)
|
|
66
|
+
- Mac: \`~/Library/Application Support/Code/User/mcp.json\`
|
|
67
|
+
- Linux: \`~/.config/Code/User/mcp.json\`
|
|
68
|
+
|
|
69
|
+
**Claude Desktop:**
|
|
70
|
+
- Windows: \`%APPDATA%\\Claude\\claude_desktop_config.json\`
|
|
71
|
+
- Mac: \`~/Library/Application Support/Claude/claude_desktop_config.json\`
|
|
72
|
+
|
|
73
|
+
### Step 2: Add Server Configuration
|
|
74
|
+
|
|
75
|
+
Ask user to add this to their \`mcpServers\` section:
|
|
76
|
+
|
|
77
|
+
\`\`\`json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"index": {
|
|
81
|
+
"command": "node",
|
|
82
|
+
"args": ["<repo-root>/dist/server/index-server.js"],
|
|
83
|
+
"transport": "stdio",
|
|
84
|
+
"env": {
|
|
85
|
+
"INDEX_SERVER_DIR": "<repo-root>/instructions"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
\`\`\`
|
|
91
|
+
|
|
92
|
+
**Important:** Paths must be adjusted for user's system!
|
|
93
|
+
|
|
94
|
+
### Step 3: Restart IDE Completely
|
|
95
|
+
|
|
96
|
+
Full restart required after editing mcp.json.
|
|
97
|
+
|
|
98
|
+
### Step 4: Verify Connection
|
|
99
|
+
|
|
100
|
+
Run: \`{"method": "health_check", "params": {}}\`
|
|
101
|
+
|
|
102
|
+
Expected: \`{"status": "healthy", "version": "1.x.x"}\`
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🎯 Essential Commands
|
|
107
|
+
|
|
108
|
+
### List All Available Instructions
|
|
109
|
+
\`\`\`json
|
|
110
|
+
{"method": "index_dispatch", "params": {"action": "list"}}
|
|
111
|
+
\`\`\`
|
|
112
|
+
|
|
113
|
+
### Search by Keywords
|
|
114
|
+
\`\`\`json
|
|
115
|
+
{"method": "index_search", "params": {"keywords": ["python", "api"]}}
|
|
116
|
+
\`\`\`
|
|
117
|
+
|
|
118
|
+
### Get Specific Instruction by ID
|
|
119
|
+
\`\`\`json
|
|
120
|
+
{"method": "index_dispatch", "params": {"action": "get", "id": "instruction-id"}}
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
### Get Help & Overview
|
|
124
|
+
\`\`\`json
|
|
125
|
+
{"method": "help_overview", "params": {}}
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
### Discover All Available Tools
|
|
129
|
+
\`\`\`json
|
|
130
|
+
{"method": "meta_tools", "params": {}}
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
### Browse Categories
|
|
134
|
+
\`\`\`json
|
|
135
|
+
{"method": "index_dispatch", "params": {"action": "categories"}}
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 🤔 When to Use Index Server
|
|
141
|
+
|
|
142
|
+
### ✅ USE For:
|
|
143
|
+
- Finding coding patterns specific to this codebase
|
|
144
|
+
- Architecture documentation and design decisions
|
|
145
|
+
- Best practices and conventions
|
|
146
|
+
- Past chat session summaries and solutions
|
|
147
|
+
- Cross-repository organizational standards
|
|
148
|
+
- API guidelines and examples
|
|
149
|
+
- Security policies and compliance procedures
|
|
150
|
+
- Troubleshooting guides specific to this project
|
|
151
|
+
|
|
152
|
+
### ❌ DON'T Use For:
|
|
153
|
+
- Reading current file contents (use \`read_file\` tool instead)
|
|
154
|
+
- Searching within files (use \`grep_search\` or \`semantic_search\`)
|
|
155
|
+
- Simple questions user can answer directly
|
|
156
|
+
- Real-time code execution or debugging
|
|
157
|
+
|
|
158
|
+
**Think of it as:** A curated knowledge base of instructions, patterns, and past learnings.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 💡 Real-World Examples
|
|
163
|
+
|
|
164
|
+
### Example 1: Find Python Error Handling Patterns
|
|
165
|
+
\`\`\`json
|
|
166
|
+
{"method": "index_search", "params": {"keywords": ["python", "error", "exception"]}}
|
|
167
|
+
\`\`\`
|
|
168
|
+
|
|
169
|
+
### Example 2: Get Architecture Overview
|
|
170
|
+
\`\`\`json
|
|
171
|
+
{"method": "index_search", "params": {"keywords": ["architecture"]}}
|
|
172
|
+
\`\`\`
|
|
173
|
+
|
|
174
|
+
### Example 3: Find API Design Guidelines
|
|
175
|
+
\`\`\`json
|
|
176
|
+
{"method": "index_search", "params": {"keywords": ["api", "rest", "endpoint"]}}
|
|
177
|
+
\`\`\`
|
|
178
|
+
|
|
179
|
+
### Example 4: Look up Security Best Practices
|
|
180
|
+
\`\`\`json
|
|
181
|
+
{"method": "index_search", "params": {"keywords": ["security", "authentication"]}}
|
|
182
|
+
\`\`\`
|
|
183
|
+
|
|
184
|
+
### Example 5: Find Testing Conventions
|
|
185
|
+
\`\`\`json
|
|
186
|
+
{"method": "index_search", "params": {"keywords": ["test", "testing", "unit"]}}
|
|
187
|
+
\`\`\`
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 🆘 Troubleshooting
|
|
192
|
+
|
|
193
|
+
### "Tool not found" / "Method not available"
|
|
194
|
+
1. Check if mcp.json/claude_desktop_config.json exists and has server configured
|
|
195
|
+
2. Verify server path points to correct location
|
|
196
|
+
3. Restart IDE/client completely (full quit and relaunch)
|
|
197
|
+
4. Enable verbose logging: Add \`"INDEX_SERVER_VERBOSE_LOGGING": "1"\` to env section
|
|
198
|
+
5. Check server is built: User should run \`npm run build\` in server directory
|
|
199
|
+
|
|
200
|
+
### Empty Search Results
|
|
201
|
+
- Index may be empty in brand new repository
|
|
202
|
+
- Try broader search terms
|
|
203
|
+
- Use \`action: "list"\` to see all available instructions
|
|
204
|
+
- Check if INDEX_SERVER_DIR env variable points to correct location
|
|
205
|
+
|
|
206
|
+
### Server Connection Issues
|
|
207
|
+
- Verify Node.js is installed: \`node --version\` should show v18+
|
|
208
|
+
- Check file paths use correct separators (forward slashes work on all platforms)
|
|
209
|
+
- Ensure dist/server/index-server.js exists (server must be built)
|
|
210
|
+
|
|
211
|
+
### Need Human Help
|
|
212
|
+
Ask user: "Can you verify the Index Server is configured in your mcp.json file? The default location is in your VS Code User directory."
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 📚 Advanced Usage
|
|
217
|
+
|
|
218
|
+
### Multi-Keyword Search (AND logic)
|
|
219
|
+
\`\`\`json
|
|
220
|
+
{"method": "index_search", "params": {"keywords": ["python", "async", "performance"]}}
|
|
221
|
+
\`\`\`
|
|
222
|
+
Returns instructions matching ALL keywords.
|
|
223
|
+
|
|
224
|
+
### Query with Filters
|
|
225
|
+
\`\`\`json
|
|
226
|
+
{"method": "index_dispatch", "params": {
|
|
227
|
+
"action": "query",
|
|
228
|
+
"filter": {"categories": ["security"]}
|
|
229
|
+
}}
|
|
230
|
+
\`\`\`
|
|
231
|
+
|
|
232
|
+
### Export Relationship Graph
|
|
233
|
+
\`\`\`json
|
|
234
|
+
{"method": "graph_export", "params": {}}
|
|
235
|
+
\`\`\`
|
|
236
|
+
Get instruction relationships and dependencies.
|
|
237
|
+
|
|
238
|
+
### Get Usage Statistics
|
|
239
|
+
\`\`\`json
|
|
240
|
+
{"method": "usage_hotset", "params": {"limit": 10}}
|
|
241
|
+
\`\`\`
|
|
242
|
+
See most frequently used instructions.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 📤 Contributing Back to the Index
|
|
247
|
+
|
|
248
|
+
**Local-First Strategy:**
|
|
249
|
+
1. Create instructions in your repo's \`.instructions/\` directory first
|
|
250
|
+
2. Test and validate them over multiple sessions
|
|
251
|
+
3. Once proven valuable, promote to shared index for organization-wide benefit
|
|
252
|
+
|
|
253
|
+
### ✅ When to Promote to Shared Index:
|
|
254
|
+
- Pattern is proven useful across multiple sessions
|
|
255
|
+
- Applies to other repos in the organization
|
|
256
|
+
- Non-repo-specific (architectural patterns, coding standards, security policies)
|
|
257
|
+
- Stable and unlikely to change frequently
|
|
258
|
+
- Helps other teams avoid solving the same problem
|
|
259
|
+
|
|
260
|
+
### ❌ Keep Local (Don't Promote):
|
|
261
|
+
- Repo-specific build commands or file paths
|
|
262
|
+
- Team-only conventions not relevant elsewhere
|
|
263
|
+
- Experimental or untested patterns
|
|
264
|
+
- Contains sensitive information, credentials, or internal paths
|
|
265
|
+
- Duplicates existing shared instructions
|
|
266
|
+
|
|
267
|
+
### How to Add to Shared Index:
|
|
268
|
+
\`\`\`json
|
|
269
|
+
{"method": "index_add", "params": {
|
|
270
|
+
"entry": {
|
|
271
|
+
"id": "unique-instruction-id",
|
|
272
|
+
"title": "Clear descriptive title",
|
|
273
|
+
"body": "Detailed instruction content...",
|
|
274
|
+
"categories": ["relevant", "categories"],
|
|
275
|
+
"audience": "agents",
|
|
276
|
+
"requirement": "recommended",
|
|
277
|
+
"priorityTier": "p1"
|
|
278
|
+
},
|
|
279
|
+
"overwrite": false
|
|
280
|
+
}}
|
|
281
|
+
\`\`\`
|
|
282
|
+
|
|
283
|
+
**Note:** Requires \`INDEX_SERVER_MUTATION=1\` in production server config.
|
|
284
|
+
|
|
285
|
+
### Value Proposition:
|
|
286
|
+
By contributing validated patterns back, you create a **knowledge flywheel**:
|
|
287
|
+
- You solve a problem → Document it → Others benefit → They contribute → Everyone improves
|
|
288
|
+
- Reduces duplicate work across teams
|
|
289
|
+
- Builds institutional knowledge that persists beyond individual projects
|
|
290
|
+
- New team members onboard faster with proven patterns
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## 🎓 Your First Query - Try Now!
|
|
295
|
+
|
|
296
|
+
Run this to see everything available:
|
|
297
|
+
\`\`\`json
|
|
298
|
+
{"method": "index_dispatch", "params": {"action": "list"}}
|
|
299
|
+
\`\`\`
|
|
300
|
+
|
|
301
|
+
Then explore! The more you use it, the more valuable it becomes.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 📖 Full Documentation
|
|
306
|
+
|
|
307
|
+
For complete reference, ask user for:
|
|
308
|
+
- Full API: \`docs/tools.md\`
|
|
309
|
+
- Configuration: \`docs/mcp_configuration.md\`
|
|
310
|
+
- Architecture: \`docs/architecture.md\`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 🎯 Quick Reference Card
|
|
315
|
+
|
|
316
|
+
| Task | Command |
|
|
317
|
+
|------|------|
|
|
318
|
+
| Check health | \`health_check\` |
|
|
319
|
+
| List all | \`index_dispatch {action: "list"}\` |
|
|
320
|
+
| Search | \`index_search {keywords: [...]}\` |
|
|
321
|
+
| Get by ID | \`index_dispatch {action: "get", id: "..."}\` |
|
|
322
|
+
| Categories | \`index_dispatch {action: "categories"}\` |
|
|
323
|
+
| Help | \`help_overview\` |
|
|
324
|
+
| All tools | \`meta_tools\` |
|
|
325
|
+
|
|
326
|
+
Start with \`health_check\` to confirm connection, then explore from there!`,
|
|
327
|
+
audience: 'agents',
|
|
328
|
+
requirement: 'required',
|
|
329
|
+
priorityTier: 'p0',
|
|
330
|
+
categories: ['bootstrap', 'mcp-activation', 'quick-start', 'documentation'],
|
|
331
|
+
owner: 'system',
|
|
332
|
+
version: 2,
|
|
333
|
+
schemaVersion: '4',
|
|
334
|
+
semanticSummary: 'Comprehensive Index Server activation, tool discovery, usage examples, and troubleshooting guide for AI agents'
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
file: '001-lifecycle-bootstrap.json',
|
|
339
|
+
id: '001-lifecycle-bootstrap',
|
|
340
|
+
json: {
|
|
341
|
+
id: '001-lifecycle-bootstrap',
|
|
342
|
+
title: 'Lifecycle Bootstrap: Local-First Instruction Strategy',
|
|
343
|
+
body: 'Purpose: Early lifecycle guidance after bootstrap confirmation. Keep index minimal; prefer local-first P0/P1 additions; promote only after stability.',
|
|
344
|
+
audience: 'agents',
|
|
345
|
+
requirement: 'recommended',
|
|
346
|
+
priorityTier: 'p1',
|
|
347
|
+
categories: ['bootstrap', 'lifecycle'],
|
|
348
|
+
owner: 'system',
|
|
349
|
+
version: 1,
|
|
350
|
+
schemaVersion: '4',
|
|
351
|
+
semanticSummary: 'Lifecycle and promotion guardrails after bootstrap confirmation',
|
|
352
|
+
reviewIntervalDays: 120
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
];
|
|
356
|
+
function computeCanonicalHash() {
|
|
357
|
+
const canonical = CANONICAL_SEEDS.map(s => ({ id: s.id, file: s.file, json: s.json })).sort((a, b) => a.id.localeCompare(b.id));
|
|
358
|
+
return crypto_1.default.createHash('sha256').update(JSON.stringify(canonical), 'utf8').digest('hex');
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Run automatic bootstrap seeding if enabled. Creates canonical seed files only when they are
|
|
362
|
+
* absent — never overwrites existing content. Safe under concurrent multi-process startup.
|
|
363
|
+
* @returns A {@link SeedSummary} describing what was created, skipped, or already present
|
|
364
|
+
*/
|
|
365
|
+
function autoSeedBootstrap() {
|
|
366
|
+
const cfg = (0, runtimeConfig_1.getRuntimeConfig)().bootstrapSeed;
|
|
367
|
+
const disabled = !cfg.autoSeed;
|
|
368
|
+
const dir = safeInstructionsDir();
|
|
369
|
+
const summary = { dir, created: [], existing: [], skipped: [], disabled, hash: computeCanonicalHash() };
|
|
370
|
+
if (disabled) {
|
|
371
|
+
summary.reason = 'disabled_by_env';
|
|
372
|
+
return summary;
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
376
|
+
}
|
|
377
|
+
catch { /* ignore */ }
|
|
378
|
+
// Probe directory existence (previously stored entries unused; keep check for side effects)
|
|
379
|
+
try {
|
|
380
|
+
fs_1.default.readdirSync(dir);
|
|
381
|
+
}
|
|
382
|
+
catch { /* ignore */ }
|
|
383
|
+
for (const seed of CANONICAL_SEEDS) {
|
|
384
|
+
const target = path_1.default.join(dir, seed.file);
|
|
385
|
+
const exists = fs_1.default.existsSync(target);
|
|
386
|
+
if (exists) {
|
|
387
|
+
summary.existing.push(seed.file);
|
|
388
|
+
summary.skipped.push(seed.file);
|
|
389
|
+
continue; // do not overwrite
|
|
390
|
+
}
|
|
391
|
+
// Directory empty OR missing seed triggers creation.
|
|
392
|
+
try {
|
|
393
|
+
const tmp = path_1.default.join(dir, `.${seed.file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
394
|
+
fs_1.default.writeFileSync(tmp, JSON.stringify(seed.json, null, 2), { encoding: 'utf8' });
|
|
395
|
+
fs_1.default.renameSync(tmp, target);
|
|
396
|
+
summary.created.push(seed.file);
|
|
397
|
+
}
|
|
398
|
+
catch (e) {
|
|
399
|
+
summary.reason = `partial_failure ${(e instanceof Error) ? e.message : String(e)}`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if ((0, runtimeConfig_1.getRuntimeConfig)().bootstrapSeed.verbose) {
|
|
403
|
+
try {
|
|
404
|
+
process.stderr.write(`[seed] dir="${dir}" created=${summary.created.length} existing=${summary.existing.length} disabled=${summary.disabled} hash=${summary.hash}\n`);
|
|
405
|
+
}
|
|
406
|
+
catch { /* ignore */ }
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
(0, logger_1.logInfo)('[seedBootstrap] Seed summary', summary);
|
|
410
|
+
}
|
|
411
|
+
catch { /* ignore */ }
|
|
412
|
+
return summary;
|
|
413
|
+
}
|
|
414
|
+
function safeInstructionsDir() {
|
|
415
|
+
try {
|
|
416
|
+
return (0, indexContext_1.getInstructionsDir)();
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
return path_1.default.join(process.cwd(), 'instructions');
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
// Test helper re-export for direct validation
|
|
423
|
+
/**
|
|
424
|
+
* Return the list of canonical seed file/id pairs (without JSON bodies) for test assertions.
|
|
425
|
+
* @returns Array of `{ file, id }` objects for each canonical seed
|
|
426
|
+
*/
|
|
427
|
+
function _getCanonicalSeeds() { return CANONICAL_SEEDS.map(s => ({ file: s.file, id: s.id })); }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage backend factory.
|
|
3
|
+
*
|
|
4
|
+
* Creates the appropriate IInstructionStore implementation based on config.
|
|
5
|
+
* Default: JsonFileStore (json). Experimental: SqliteStore (sqlite).
|
|
6
|
+
*/
|
|
7
|
+
import type { IInstructionStore } from './types.js';
|
|
8
|
+
export type StorageBackend = 'json' | 'sqlite';
|
|
9
|
+
/**
|
|
10
|
+
* Create a storage backend instance.
|
|
11
|
+
*
|
|
12
|
+
* @param backend - Override backend type (default: from config).
|
|
13
|
+
* @param dir - Override instruction directory (default: from config).
|
|
14
|
+
* @param sqlitePath - Override SQLite DB path (default: from config).
|
|
15
|
+
* @returns An IInstructionStore implementation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createStore(backend?: StorageBackend, dir?: string, sqlitePath?: string): IInstructionStore;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Storage backend factory.
|
|
4
|
+
*
|
|
5
|
+
* Creates the appropriate IInstructionStore implementation based on config.
|
|
6
|
+
* Default: JsonFileStore (json). Experimental: SqliteStore (sqlite).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createStore = createStore;
|
|
10
|
+
const runtimeConfig_js_1 = require("../../config/runtimeConfig.js");
|
|
11
|
+
const jsonFileStore_js_1 = require("./jsonFileStore.js");
|
|
12
|
+
const sqliteStore_js_1 = require("./sqliteStore.js");
|
|
13
|
+
/**
|
|
14
|
+
* Create a storage backend instance.
|
|
15
|
+
*
|
|
16
|
+
* @param backend - Override backend type (default: from config).
|
|
17
|
+
* @param dir - Override instruction directory (default: from config).
|
|
18
|
+
* @param sqlitePath - Override SQLite DB path (default: from config).
|
|
19
|
+
* @returns An IInstructionStore implementation.
|
|
20
|
+
*/
|
|
21
|
+
function createStore(backend, dir, sqlitePath) {
|
|
22
|
+
const config = (0, runtimeConfig_js_1.getRuntimeConfig)();
|
|
23
|
+
const resolvedBackend = backend ?? config.storage?.backend ?? 'json';
|
|
24
|
+
const resolvedDir = dir ?? config.index?.baseDir;
|
|
25
|
+
switch (resolvedBackend) {
|
|
26
|
+
case 'sqlite': {
|
|
27
|
+
console.warn('[storage] ⚠️ EXPERIMENTAL: SQLite backend is enabled. This feature has limited testing and may have data-loss or compatibility issues. Not recommended for production use.');
|
|
28
|
+
const dbPath = sqlitePath ?? config.storage?.sqlitePath ?? 'data/index.db';
|
|
29
|
+
return new sqliteStore_js_1.SqliteStore(dbPath);
|
|
30
|
+
}
|
|
31
|
+
case 'json':
|
|
32
|
+
default:
|
|
33
|
+
return new jsonFileStore_js_1.JsonFileStore(resolvedDir);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared governance hashing utilities for storage backends.
|
|
3
|
+
*
|
|
4
|
+
* Both JsonFileStore and SqliteStore must produce identical governance hashes
|
|
5
|
+
* for the same set of entries. This module ensures that.
|
|
6
|
+
*/
|
|
7
|
+
import { InstructionEntry } from '../../models/instruction.js';
|
|
8
|
+
/** @internal Governance projection for deterministic hashing. */
|
|
9
|
+
export declare function projectGovernance(e: InstructionEntry): Record<string, unknown>;
|
|
10
|
+
/** Compute deterministic governance hash from an array of entries. */
|
|
11
|
+
export declare function computeGovernanceHashFromEntries(entries: InstructionEntry[]): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared governance hashing utilities for storage backends.
|
|
4
|
+
*
|
|
5
|
+
* Both JsonFileStore and SqliteStore must produce identical governance hashes
|
|
6
|
+
* for the same set of entries. This module ensures that.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.projectGovernance = projectGovernance;
|
|
13
|
+
exports.computeGovernanceHashFromEntries = computeGovernanceHashFromEntries;
|
|
14
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
15
|
+
/** @internal Governance projection for deterministic hashing. */
|
|
16
|
+
function projectGovernance(e) {
|
|
17
|
+
return {
|
|
18
|
+
id: e.id,
|
|
19
|
+
title: e.title,
|
|
20
|
+
version: e.version ?? '0.0.0',
|
|
21
|
+
owner: e.owner ?? 'unowned',
|
|
22
|
+
priorityTier: e.priorityTier ?? 'P4',
|
|
23
|
+
nextReviewDue: e.nextReviewDue ?? '',
|
|
24
|
+
semanticSummarySha256: e.semanticSummary
|
|
25
|
+
? crypto_1.default.createHash('sha256').update(e.semanticSummary).digest('hex')
|
|
26
|
+
: '',
|
|
27
|
+
changeLogLength: e.changeLog?.length ?? 0,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Compute deterministic governance hash from an array of entries. */
|
|
31
|
+
function computeGovernanceHashFromEntries(entries) {
|
|
32
|
+
const sorted = [...entries].sort((a, b) => a.id.localeCompare(b.id));
|
|
33
|
+
const projection = sorted.map(e => JSON.stringify(projectGovernance(e)));
|
|
34
|
+
return crypto_1.default.createHash('sha256').update(projection.join('\n')).digest('hex');
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage — Instruction storage abstraction layer.
|
|
3
|
+
*
|
|
4
|
+
* Exports the IInstructionStore interface and backend implementations.
|
|
5
|
+
* Backend selection is controlled by INDEX_SERVER_STORAGE_BACKEND env var.
|
|
6
|
+
*/
|
|
7
|
+
export type { IInstructionStore, ListOptions, QueryOptions, ScopedListOptions, SearchOptions, SearchResult, UsagePersistRecord, UsageTrackOptions, LoadResult, } from './types.js';
|
|
8
|
+
export { JsonFileStore } from './jsonFileStore.js';
|
|
9
|
+
export { SqliteStore } from './sqliteStore.js';
|
|
10
|
+
export { createStore } from './factory.js';
|
|
11
|
+
export { computeGovernanceHashFromEntries, projectGovernance } from './hashUtils.js';
|
|
12
|
+
export type { StorageBackend } from './factory.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Storage — Instruction storage abstraction layer.
|
|
4
|
+
*
|
|
5
|
+
* Exports the IInstructionStore interface and backend implementations.
|
|
6
|
+
* Backend selection is controlled by INDEX_SERVER_STORAGE_BACKEND env var.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.projectGovernance = exports.computeGovernanceHashFromEntries = exports.createStore = exports.SqliteStore = exports.JsonFileStore = void 0;
|
|
10
|
+
var jsonFileStore_js_1 = require("./jsonFileStore.js");
|
|
11
|
+
Object.defineProperty(exports, "JsonFileStore", { enumerable: true, get: function () { return jsonFileStore_js_1.JsonFileStore; } });
|
|
12
|
+
var sqliteStore_js_1 = require("./sqliteStore.js");
|
|
13
|
+
Object.defineProperty(exports, "SqliteStore", { enumerable: true, get: function () { return sqliteStore_js_1.SqliteStore; } });
|
|
14
|
+
var factory_js_1 = require("./factory.js");
|
|
15
|
+
Object.defineProperty(exports, "createStore", { enumerable: true, get: function () { return factory_js_1.createStore; } });
|
|
16
|
+
var hashUtils_js_1 = require("./hashUtils.js");
|
|
17
|
+
Object.defineProperty(exports, "computeGovernanceHashFromEntries", { enumerable: true, get: function () { return hashUtils_js_1.computeGovernanceHashFromEntries; } });
|
|
18
|
+
Object.defineProperty(exports, "projectGovernance", { enumerable: true, get: function () { return hashUtils_js_1.projectGovernance; } });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JsonFileStore — JSON-file-per-instruction storage backend.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing file-based storage pattern: each instruction is a
|
|
5
|
+
* separate .json file in a directory. This is the default backend.
|
|
6
|
+
*
|
|
7
|
+
* Implements IInstructionStore for the storage abstraction layer.
|
|
8
|
+
*/
|
|
9
|
+
import { InstructionEntry } from '../../models/instruction.js';
|
|
10
|
+
import type { IInstructionStore, ListOptions, QueryOptions, ScopedListOptions, SearchOptions, SearchResult, LoadResult } from './types.js';
|
|
11
|
+
export declare class JsonFileStore implements IInstructionStore {
|
|
12
|
+
private readonly dir;
|
|
13
|
+
private cache;
|
|
14
|
+
private loaded;
|
|
15
|
+
/**
|
|
16
|
+
* @param dir - Directory containing instruction .json files.
|
|
17
|
+
*/
|
|
18
|
+
constructor(dir: string);
|
|
19
|
+
load(): LoadResult;
|
|
20
|
+
close(): void;
|
|
21
|
+
get(id: string): InstructionEntry | null;
|
|
22
|
+
write(entry: InstructionEntry): void;
|
|
23
|
+
remove(id: string): void;
|
|
24
|
+
list(opts?: ListOptions): InstructionEntry[];
|
|
25
|
+
query(opts: QueryOptions): InstructionEntry[];
|
|
26
|
+
listScoped(opts: ScopedListOptions): InstructionEntry[];
|
|
27
|
+
search(opts: SearchOptions): SearchResult[];
|
|
28
|
+
categories(): Map<string, number>;
|
|
29
|
+
computeHash(): string;
|
|
30
|
+
count(): number;
|
|
31
|
+
private ensureLoaded;
|
|
32
|
+
}
|