@massa-ai/core 1.16.0 → 1.18.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/dist/data/audit/operation-log-pg.js +1 -1
- package/dist/data/audit/operation-log-pg.js.map +1 -1
- package/dist/data/graph-generation/graph-generation-repository-pg.js +1 -1
- package/dist/data/graph-generation/graph-generation-repository-pg.js.map +1 -1
- package/dist/data/handoff/handoff-repository-pg.js +3 -3
- package/dist/data/handoff/handoff-repository-pg.js.map +1 -1
- package/dist/data/keyword/keyword-search-pg.js +3 -3
- package/dist/data/keyword/keyword-search-pg.js.map +1 -1
- package/dist/data/managed-runs/managed-run-repository-pg.js +1 -1
- package/dist/data/managed-runs/managed-run-repository-pg.js.map +1 -1
- package/dist/data/memory/memory-repository-pg.js +2 -2
- package/dist/data/memory/memory-repository-pg.js.map +1 -1
- package/dist/data/memory/observation-repository-pg.js +2 -2
- package/dist/data/memory/observation-repository-pg.js.map +1 -1
- package/dist/data/proposal/proposal-repository-pg.js +3 -3
- package/dist/data/proposal/proposal-repository-pg.js.map +1 -1
- package/dist/data/symbol/symbol-repo-generation.d.ts +1 -1
- package/dist/data/symbol/symbol-repo-generation.d.ts.map +1 -1
- package/dist/data/symbol/symbol-repo-generation.js +2 -2
- package/dist/data/symbol/symbol-repo-generation.js.map +1 -1
- package/dist/data/symbol/symbol-repo-graph.js +2 -2
- package/dist/data/symbol/symbol-repo-graph.js.map +1 -1
- package/dist/data/symbol/symbol-repo-identity.d.ts +1 -1
- package/dist/data/symbol/symbol-repo-identity.d.ts.map +1 -1
- package/dist/data/symbol/symbol-repo-identity.js +1 -1
- package/dist/data/symbol/symbol-repo-identity.js.map +1 -1
- package/dist/data/symbol/symbol-repo-queries.js +1 -1
- package/dist/data/symbol/symbol-repo-queries.js.map +1 -1
- package/dist/data/symbol/symbol-repo-types.d.ts +1 -1
- package/dist/data/symbol/symbol-repo-types.d.ts.map +1 -1
- package/dist/data/symbol/symbol-repo-workspace.js +1 -1
- package/dist/data/symbol/symbol-repo-workspace.js.map +1 -1
- package/dist/data/vector/base-vector-store.d.ts +29 -3
- package/dist/data/vector/base-vector-store.d.ts.map +1 -1
- package/dist/data/vector/base-vector-store.js +33 -2
- package/dist/data/vector/base-vector-store.js.map +1 -1
- package/dist/data/vector/postgres-vector-store.d.ts +10 -1
- package/dist/data/vector/postgres-vector-store.d.ts.map +1 -1
- package/dist/data/vector/postgres-vector-store.js +4 -2
- package/dist/data/vector/postgres-vector-store.js.map +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/kernel/alias-resolver.d.ts.map +1 -0
- package/dist/{services/project-identity → kernel}/alias-resolver.js +1 -1
- package/dist/kernel/alias-resolver.js.map +1 -0
- package/dist/kernel/db-connection.d.ts.map +1 -0
- package/dist/kernel/db-connection.js.map +1 -0
- package/dist/{tools → kernel}/enum-validation.d.ts +17 -1
- package/dist/kernel/enum-validation.d.ts.map +1 -0
- package/dist/{tools → kernel}/enum-validation.js +17 -1
- package/dist/kernel/enum-validation.js.map +1 -0
- package/dist/kernel/fqn-codec.d.ts.map +1 -0
- package/dist/kernel/fqn-codec.js.map +1 -0
- package/dist/kernel/identity-guard-installer.d.ts.map +1 -0
- package/dist/{services/project-identity → kernel}/identity-guard-installer.js +1 -1
- package/dist/kernel/identity-guard-installer.js.map +1 -0
- package/dist/kernel/lexical-search.d.ts.map +1 -0
- package/dist/kernel/lexical-search.js.map +1 -0
- package/dist/{services/query → kernel}/prisma-client.d.ts +1 -1
- package/dist/kernel/prisma-client.d.ts.map +1 -0
- package/dist/{services/query → kernel}/prisma-client.js +1 -1
- package/dist/kernel/prisma-client.js.map +1 -0
- package/dist/kernel/registry.d.ts.map +1 -0
- package/dist/kernel/registry.js.map +1 -0
- package/dist/kernel/schema-version.d.ts.map +1 -0
- package/dist/kernel/schema-version.js.map +1 -0
- package/dist/kernel/search-diagnostics.d.ts.map +1 -0
- package/dist/kernel/search-diagnostics.js.map +1 -0
- package/dist/kernel/types.d.ts.map +1 -0
- package/dist/kernel/types.js.map +1 -0
- package/dist/services/cache/embedding-cache-pg.js +1 -1
- package/dist/services/cache/embedding-cache-pg.js.map +1 -1
- package/dist/services/cache/lru-evict.d.ts +63 -0
- package/dist/services/cache/lru-evict.d.ts.map +1 -0
- package/dist/services/cache/lru-evict.js +76 -0
- package/dist/services/cache/lru-evict.js.map +1 -0
- package/dist/services/checkpoint/checkpoint-store-pg.js +3 -3
- package/dist/services/checkpoint/checkpoint-store-pg.js.map +1 -1
- package/dist/services/compression/compress-with-metrics.d.ts +22 -0
- package/dist/services/compression/compress-with-metrics.d.ts.map +1 -0
- package/dist/services/compression/compress-with-metrics.js +62 -0
- package/dist/services/compression/compress-with-metrics.js.map +1 -0
- package/dist/services/compression/index.d.ts +2 -0
- package/dist/services/compression/index.d.ts.map +1 -1
- package/dist/services/compression/index.js +1 -0
- package/dist/services/compression/index.js.map +1 -1
- package/dist/{controllers → services/context}/context-controller.d.ts +1 -1
- package/dist/services/context/context-controller.d.ts.map +1 -0
- package/dist/{controllers → services/context}/context-controller.js +22 -17
- package/dist/services/context/context-controller.js.map +1 -0
- package/dist/services/etl/pipeline.js +2 -2
- package/dist/services/etl/pipeline.js.map +1 -1
- package/dist/services/etl/stage-context.d.ts +1 -1
- package/dist/services/etl/stage-context.d.ts.map +1 -1
- package/dist/services/etl/stages/load.js +1 -1
- package/dist/services/etl/stages/load.js.map +1 -1
- package/dist/services/etl/stages/parse.d.ts +1 -1
- package/dist/services/etl/stages/parse.d.ts.map +1 -1
- package/dist/services/etl/stages/resolve.js +2 -2
- package/dist/services/etl/stages/resolve.js.map +1 -1
- package/dist/{controllers → services/executor}/executor-controller.d.ts +2 -5
- package/dist/services/executor/executor-controller.d.ts.map +1 -0
- package/dist/{controllers → services/executor}/executor-controller.js +2 -2
- package/dist/services/executor/executor-controller.js.map +1 -0
- package/dist/services/executor/index.d.ts +2 -0
- package/dist/services/executor/index.d.ts.map +1 -1
- package/dist/services/executor/index.js +0 -10
- package/dist/services/executor/index.js.map +1 -1
- package/dist/services/executor/params.d.ts +39 -0
- package/dist/services/executor/params.d.ts.map +1 -0
- package/dist/services/executor/params.js +2 -0
- package/dist/services/executor/params.js.map +1 -0
- package/dist/services/file-read/file-content-cache.d.ts +41 -0
- package/dist/services/file-read/file-content-cache.d.ts.map +1 -0
- package/dist/services/file-read/file-content-cache.js +109 -0
- package/dist/services/file-read/file-content-cache.js.map +1 -0
- package/dist/services/file-read/file-metadata.d.ts +23 -0
- package/dist/services/file-read/file-metadata.d.ts.map +1 -0
- package/dist/services/file-read/file-metadata.js +127 -0
- package/dist/services/file-read/file-metadata.js.map +1 -0
- package/dist/services/file-read/line-range.d.ts +91 -0
- package/dist/services/file-read/line-range.d.ts.map +1 -0
- package/dist/services/file-read/line-range.js +146 -0
- package/dist/services/file-read/line-range.js.map +1 -0
- package/dist/services/file-read/path-containment.d.ts +49 -0
- package/dist/services/file-read/path-containment.d.ts.map +1 -0
- package/dist/services/file-read/path-containment.js +128 -0
- package/dist/services/file-read/path-containment.js.map +1 -0
- package/dist/services/file-read/project-root-cache.d.ts +21 -0
- package/dist/services/file-read/project-root-cache.d.ts.map +1 -0
- package/dist/services/file-read/project-root-cache.js +78 -0
- package/dist/services/file-read/project-root-cache.js.map +1 -0
- package/dist/services/file-read/read-file.service.d.ts +68 -0
- package/dist/services/file-read/read-file.service.d.ts.map +1 -0
- package/dist/services/file-read/read-file.service.js +222 -0
- package/dist/services/file-read/read-file.service.js.map +1 -0
- package/dist/services/health/local-health-checker.d.ts +1 -1
- package/dist/services/health/local-health-checker.d.ts.map +1 -1
- package/dist/services/health/local-health-checker.js +2 -2
- package/dist/services/health/local-health-checker.js.map +1 -1
- package/dist/services/hooks/attribution-resolver.js +2 -2
- package/dist/services/hooks/attribution-resolver.js.map +1 -1
- package/dist/services/hooks/co-retrieval-hook.js +1 -1
- package/dist/services/hooks/co-retrieval-hook.js.map +1 -1
- package/dist/services/hooks/search-session-hook.js +1 -1
- package/dist/services/hooks/search-session-hook.js.map +1 -1
- package/dist/services/index.d.ts +21 -11
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +24 -7
- package/dist/services/index.js.map +1 -1
- package/dist/services/indexing/acquire-indexing-lease.d.ts +34 -0
- package/dist/services/indexing/acquire-indexing-lease.d.ts.map +1 -0
- package/dist/services/indexing/acquire-indexing-lease.js +101 -0
- package/dist/services/indexing/acquire-indexing-lease.js.map +1 -0
- package/dist/services/indexing/execute-indexing.d.ts +33 -0
- package/dist/services/indexing/execute-indexing.d.ts.map +1 -0
- package/dist/services/indexing/execute-indexing.js +136 -0
- package/dist/services/indexing/execute-indexing.js.map +1 -0
- package/dist/services/jobs/auto-improve-ops.js +1 -1
- package/dist/services/jobs/auto-improve-ops.js.map +1 -1
- package/dist/services/jobs/index-job-store-pg.js +2 -2
- package/dist/services/jobs/index-job-store-pg.js.map +1 -1
- package/dist/services/jobs/memory-consolidation-job.js +2 -2
- package/dist/services/jobs/memory-consolidation-job.js.map +1 -1
- package/dist/services/memory/memory-clustering.js +1 -1
- package/dist/services/memory/memory-clustering.js.map +1 -1
- package/dist/{controllers → services/memory}/memory-controller.d.ts +2 -2
- package/dist/services/memory/memory-controller.d.ts.map +1 -0
- package/dist/{controllers → services/memory}/memory-controller.js +6 -6
- package/dist/services/memory/memory-controller.js.map +1 -0
- package/dist/services/memory/redundancy-filter.js +1 -1
- package/dist/services/memory/redundancy-filter.js.map +1 -1
- package/dist/services/memory-graph/graph-queries.d.ts.map +1 -0
- package/dist/services/{graph → memory-graph}/graph-queries.js +1 -1
- package/dist/services/memory-graph/graph-queries.js.map +1 -0
- package/dist/services/memory-graph/graph-store-factory.d.ts.map +1 -0
- package/dist/services/memory-graph/graph-store-factory.js.map +1 -0
- package/dist/services/memory-graph/graph-store-pg.d.ts.map +1 -0
- package/dist/services/{graph → memory-graph}/graph-store-pg.js +1 -1
- package/dist/services/memory-graph/graph-store-pg.js.map +1 -0
- package/dist/services/memory-graph/index.d.ts.map +1 -0
- package/dist/services/memory-graph/index.js.map +1 -0
- package/dist/services/memory-graph/memory-graph.service.d.ts.map +1 -0
- package/dist/services/memory-graph/memory-graph.service.js.map +1 -0
- package/dist/services/memory-graph/relation-extractor.d.ts.map +1 -0
- package/dist/services/memory-graph/relation-extractor.js.map +1 -0
- package/dist/services/memory-graph/types.d.ts.map +1 -0
- package/dist/services/memory-graph/types.js.map +1 -0
- package/dist/services/project-identity/discovery.d.ts +1 -1
- package/dist/services/project-identity/discovery.d.ts.map +1 -1
- package/dist/services/project-identity/discovery.js +1 -1
- package/dist/services/project-identity/discovery.js.map +1 -1
- package/dist/services/project-identity/index.d.ts +6 -6
- package/dist/services/project-identity/index.d.ts.map +1 -1
- package/dist/services/project-identity/index.js +3 -3
- package/dist/services/project-identity/index.js.map +1 -1
- package/dist/services/project-identity/invalidator-registry.d.ts +9 -3
- package/dist/services/project-identity/invalidator-registry.d.ts.map +1 -1
- package/dist/services/project-identity/invalidator-registry.js +9 -3
- package/dist/services/project-identity/invalidator-registry.js.map +1 -1
- package/dist/services/project-identity/production-wiring.d.ts +11 -2
- package/dist/services/project-identity/production-wiring.d.ts.map +1 -1
- package/dist/services/project-identity/production-wiring.js +13 -4
- package/dist/services/project-identity/production-wiring.js.map +1 -1
- package/dist/services/project-identity/project-root-identity.d.ts +11 -0
- package/dist/services/project-identity/project-root-identity.d.ts.map +1 -0
- package/dist/services/project-identity/project-root-identity.js +51 -0
- package/dist/services/project-identity/project-root-identity.js.map +1 -0
- package/dist/services/project-identity/service.js +1 -1
- package/dist/services/project-identity/service.js.map +1 -1
- package/dist/services/scheduler/scheduler-store-pg.js +2 -2
- package/dist/services/scheduler/scheduler-store-pg.js.map +1 -1
- package/dist/services/search/contextual-search-rlm.d.ts +2 -2
- package/dist/services/search/contextual-search-rlm.d.ts.map +1 -1
- package/dist/services/search/contextual-search-rlm.js +2 -2
- package/dist/services/search/contextual-search-rlm.js.map +1 -1
- package/dist/services/search/file-filter-cache.d.ts +30 -1
- package/dist/services/search/file-filter-cache.d.ts.map +1 -1
- package/dist/services/search/file-filter-cache.js +32 -13
- package/dist/services/search/file-filter-cache.js.map +1 -1
- package/dist/services/search/filter-validation.js +1 -1
- package/dist/services/search/filter-validation.js.map +1 -1
- package/dist/services/search/graph-stream.d.ts +1 -1
- package/dist/services/search/graph-stream.d.ts.map +1 -1
- package/dist/services/search/graph-stream.js +1 -1
- package/dist/services/search/graph-stream.js.map +1 -1
- package/dist/services/search/hybrid-search.d.ts +2 -2
- package/dist/services/search/hybrid-search.d.ts.map +1 -1
- package/dist/services/search/hybrid-search.js +2 -2
- package/dist/services/search/hybrid-search.js.map +1 -1
- package/dist/services/search/index-admin.d.ts +1 -1
- package/dist/services/search/index-admin.d.ts.map +1 -1
- package/dist/services/search/index-manager.js +1 -1
- package/dist/services/search/index-manager.js.map +1 -1
- package/dist/services/search/project-indexer.d.ts +1 -1
- package/dist/services/search/project-indexer.d.ts.map +1 -1
- package/dist/services/search/project-indexer.js +1 -1
- package/dist/services/search/project-indexer.js.map +1 -1
- package/dist/services/search/search-analytics-pg.js +2 -2
- package/dist/services/search/search-analytics-pg.js.map +1 -1
- package/dist/services/search/search-cache-pg.js +2 -2
- package/dist/services/search/search-cache-pg.js.map +1 -1
- package/dist/{controllers → services/search}/search-controller.d.ts +3 -3
- package/dist/services/search/search-controller.d.ts.map +1 -0
- package/dist/{controllers → services/search}/search-controller.js +4 -4
- package/dist/services/search/search-controller.js.map +1 -0
- package/dist/services/search/session-bias.d.ts +1 -1
- package/dist/services/search/session-bias.d.ts.map +1 -1
- package/dist/services/structural/diagnostics.d.ts +1 -1
- package/dist/services/structural/diagnostics.d.ts.map +1 -1
- package/dist/services/structural/grammar-loaders.d.ts +1 -1
- package/dist/services/structural/grammar-loaders.d.ts.map +1 -1
- package/dist/services/structural/language-manifest.d.ts +3 -3
- package/dist/services/structural/language-manifest.d.ts.map +1 -1
- package/dist/services/structural/language-manifest.js +1 -1
- package/dist/services/structural/language-manifest.js.map +1 -1
- package/dist/services/structural/native-node-helpers.d.ts +2 -2
- package/dist/services/structural/parser-readiness.d.ts +1 -1
- package/dist/services/structural/parser-readiness.d.ts.map +1 -1
- package/dist/services/structural/query-pack-edges.d.ts +1 -1
- package/dist/services/structural/query-pack-edges.d.ts.map +1 -1
- package/dist/services/structural/query-pack-registry.d.ts +1 -1
- package/dist/services/structural/query-pack-registry.d.ts.map +1 -1
- package/dist/services/structural/query-pack.d.ts +1 -1
- package/dist/services/structural/query-pack.d.ts.map +1 -1
- package/dist/services/structural/resolver.d.ts +2 -2
- package/dist/services/structural/resolver.d.ts.map +1 -1
- package/dist/services/structural/resolver.js +1 -1
- package/dist/services/structural/resolver.js.map +1 -1
- package/dist/services/structural/resolvers/typescript.js +1 -1
- package/dist/services/structural/resolvers/typescript.js.map +1 -1
- package/dist/services/structural/source-span.d.ts +1 -1
- package/dist/services/structural/source-span.d.ts.map +1 -1
- package/dist/services/structural/structural-runtime.d.ts +1 -1
- package/dist/services/structural/structural-runtime.d.ts.map +1 -1
- package/dist/services/structural/structural-runtime.js.map +1 -1
- package/dist/services/structural/symbol-signature.d.ts +1 -1
- package/dist/services/structural/symbol-signature.d.ts.map +1 -1
- package/dist/services/symbol/active-generation.js +1 -1
- package/dist/services/symbol/active-generation.js.map +1 -1
- package/dist/services/symbol/architecture.js +1 -1
- package/dist/services/symbol/architecture.js.map +1 -1
- package/dist/services/symbol/definition-lookup.js +1 -1
- package/dist/services/symbol/definition-lookup.js.map +1 -1
- package/dist/services/symbol/git-ref-validation.js +1 -1
- package/dist/services/symbol/git-ref-validation.js.map +1 -1
- package/dist/{controllers → services/symbol}/graph-controller.d.ts +4 -4
- package/dist/services/symbol/graph-controller.d.ts.map +1 -0
- package/dist/{controllers → services/symbol}/graph-controller.js +3 -3
- package/dist/services/symbol/graph-controller.js.map +1 -0
- package/dist/services/symbol/symbol-graph.service.d.ts +12 -1
- package/dist/services/symbol/symbol-graph.service.d.ts.map +1 -1
- package/dist/services/symbol/symbol-graph.service.js +14 -7
- package/dist/services/symbol/symbol-graph.service.js.map +1 -1
- package/dist/services/synapse/session/session-store-pg.js +2 -2
- package/dist/services/synapse/session/session-store-pg.js.map +1 -1
- package/dist/services/synapse/task-envelope.d.ts +1 -1
- package/dist/services/synapse/task-envelope.d.ts.map +1 -1
- package/dist/services/synapse/task-envelope.js +1 -1
- package/dist/services/synapse/task-envelope.js.map +1 -1
- package/dist/services/vector/vector-store-factory.d.ts +30 -0
- package/dist/services/vector/vector-store-factory.d.ts.map +1 -0
- package/dist/{data → services}/vector/vector-store-factory.js +29 -2
- package/dist/services/vector/vector-store-factory.js.map +1 -0
- package/dist/services/web/web-controller.d.ts.map +1 -1
- package/dist/services/web/web-controller.js +6 -7
- package/dist/services/web/web-controller.js.map +1 -1
- package/dist/tools/batch_execute.d.ts +2 -11
- package/dist/tools/batch_execute.d.ts.map +1 -1
- package/dist/tools/batch_execute.js.map +1 -1
- package/dist/tools/compress_context.d.ts.map +1 -1
- package/dist/tools/compress_context.js +9 -26
- package/dist/tools/compress_context.js.map +1 -1
- package/dist/tools/create_checkpoint.js +1 -1
- package/dist/tools/create_checkpoint.js.map +1 -1
- package/dist/tools/delete_memory.js +1 -1
- package/dist/tools/delete_memory.js.map +1 -1
- package/dist/tools/execute.d.ts +2 -9
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/execute.js.map +1 -1
- package/dist/tools/execute_file.d.ts +2 -8
- package/dist/tools/execute_file.d.ts.map +1 -1
- package/dist/tools/execute_file.js.map +1 -1
- package/dist/tools/get_analytics.js +1 -1
- package/dist/tools/get_analytics.js.map +1 -1
- package/dist/tools/get_architecture.js +1 -1
- package/dist/tools/get_architecture.js.map +1 -1
- package/dist/tools/get_optimized_context.d.ts +1 -1
- package/dist/tools/get_optimized_context.js +2 -2
- package/dist/tools/get_optimized_context.js.map +1 -1
- package/dist/tools/get_references.js +1 -1
- package/dist/tools/get_references.js.map +1 -1
- package/dist/tools/impact_analysis.js +1 -1
- package/dist/tools/impact_analysis.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index_project.d.ts +0 -19
- package/dist/tools/index_project.d.ts.map +1 -1
- package/dist/tools/index_project.js +38 -142
- package/dist/tools/index_project.js.map +1 -1
- package/dist/tools/list_projects.js +1 -1
- package/dist/tools/list_projects.js.map +1 -1
- package/dist/tools/read_file.d.ts +9 -72
- package/dist/tools/read_file.d.ts.map +1 -1
- package/dist/tools/read_file.js +22 -487
- package/dist/tools/read_file.js.map +1 -1
- package/dist/tools/search_definitions.js +1 -1
- package/dist/tools/search_definitions.js.map +1 -1
- package/dist/tools/search_memories.d.ts +1 -1
- package/dist/tools/search_memories.js +2 -2
- package/dist/tools/search_memories.js.map +1 -1
- package/dist/tools/search_project.d.ts +1 -1
- package/dist/tools/search_project.js +3 -3
- package/dist/tools/search_project.js.map +1 -1
- package/dist/tools/store_memory.d.ts +1 -1
- package/dist/tools/store_memory.js +2 -2
- package/dist/tools/store_memory.js.map +1 -1
- package/dist/tools/trace_path.js +1 -1
- package/dist/tools/trace_path.js.map +1 -1
- package/dist/tools/update_memory.d.ts +1 -1
- package/dist/tools/update_memory.js +2 -2
- package/dist/tools/update_memory.js.map +1 -1
- package/package.json +2 -6
- package/dist/controllers/context-controller.d.ts.map +0 -1
- package/dist/controllers/context-controller.js.map +0 -1
- package/dist/controllers/executor-controller.d.ts.map +0 -1
- package/dist/controllers/executor-controller.js.map +0 -1
- package/dist/controllers/graph-controller.d.ts.map +0 -1
- package/dist/controllers/graph-controller.js.map +0 -1
- package/dist/controllers/index.d.ts +0 -17
- package/dist/controllers/index.d.ts.map +0 -1
- package/dist/controllers/index.js +0 -12
- package/dist/controllers/index.js.map +0 -1
- package/dist/controllers/memory-controller.d.ts.map +0 -1
- package/dist/controllers/memory-controller.js.map +0 -1
- package/dist/controllers/search-controller.d.ts.map +0 -1
- package/dist/controllers/search-controller.js.map +0 -1
- package/dist/data/db-connection.d.ts.map +0 -1
- package/dist/data/db-connection.js.map +0 -1
- package/dist/data/vector/hybrid-search.d.ts +0 -64
- package/dist/data/vector/hybrid-search.d.ts.map +0 -1
- package/dist/data/vector/hybrid-search.js +0 -238
- package/dist/data/vector/hybrid-search.js.map +0 -1
- package/dist/data/vector/index.d.ts +0 -9
- package/dist/data/vector/index.d.ts.map +0 -1
- package/dist/data/vector/index.js +0 -7
- package/dist/data/vector/index.js.map +0 -1
- package/dist/data/vector/vector-store-factory.d.ts +0 -9
- package/dist/data/vector/vector-store-factory.d.ts.map +0 -1
- package/dist/data/vector/vector-store-factory.js.map +0 -1
- package/dist/services/graph/graph-queries.d.ts.map +0 -1
- package/dist/services/graph/graph-queries.js.map +0 -1
- package/dist/services/graph/graph-store-factory.d.ts.map +0 -1
- package/dist/services/graph/graph-store-factory.js.map +0 -1
- package/dist/services/graph/graph-store-pg.d.ts.map +0 -1
- package/dist/services/graph/graph-store-pg.js.map +0 -1
- package/dist/services/graph/index.d.ts.map +0 -1
- package/dist/services/graph/index.js.map +0 -1
- package/dist/services/graph/memory-graph.service.d.ts.map +0 -1
- package/dist/services/graph/memory-graph.service.js.map +0 -1
- package/dist/services/graph/relation-extractor.d.ts.map +0 -1
- package/dist/services/graph/relation-extractor.js.map +0 -1
- package/dist/services/graph/types.d.ts.map +0 -1
- package/dist/services/graph/types.js.map +0 -1
- package/dist/services/project-identity/alias-resolver.d.ts.map +0 -1
- package/dist/services/project-identity/alias-resolver.js.map +0 -1
- package/dist/services/project-identity/identity-guard-installer.d.ts.map +0 -1
- package/dist/services/project-identity/identity-guard-installer.js.map +0 -1
- package/dist/services/project-identity/registry.d.ts.map +0 -1
- package/dist/services/project-identity/registry.js.map +0 -1
- package/dist/services/query/prisma-client.d.ts.map +0 -1
- package/dist/services/query/prisma-client.js.map +0 -1
- package/dist/services/search/lexical-search.d.ts.map +0 -1
- package/dist/services/search/lexical-search.js.map +0 -1
- package/dist/services/search/search-diagnostics.d.ts.map +0 -1
- package/dist/services/search/search-diagnostics.js.map +0 -1
- package/dist/services/structural/fqn-codec.d.ts.map +0 -1
- package/dist/services/structural/fqn-codec.js.map +0 -1
- package/dist/services/structural/schema-version.d.ts.map +0 -1
- package/dist/services/structural/schema-version.js.map +0 -1
- package/dist/services/structural/types.d.ts.map +0 -1
- package/dist/services/structural/types.js.map +0 -1
- package/dist/tools/enum-validation.d.ts.map +0 -1
- package/dist/tools/enum-validation.js.map +0 -1
- /package/dist/{services/project-identity → kernel}/alias-resolver.d.ts +0 -0
- /package/dist/{data → kernel}/db-connection.d.ts +0 -0
- /package/dist/{data → kernel}/db-connection.js +0 -0
- /package/dist/{services/structural → kernel}/fqn-codec.d.ts +0 -0
- /package/dist/{services/structural → kernel}/fqn-codec.js +0 -0
- /package/dist/{services/project-identity → kernel}/identity-guard-installer.d.ts +0 -0
- /package/dist/{services/search → kernel}/lexical-search.d.ts +0 -0
- /package/dist/{services/search → kernel}/lexical-search.js +0 -0
- /package/dist/{services/project-identity → kernel}/registry.d.ts +0 -0
- /package/dist/{services/project-identity → kernel}/registry.js +0 -0
- /package/dist/{services/structural → kernel}/schema-version.d.ts +0 -0
- /package/dist/{services/structural → kernel}/schema-version.js +0 -0
- /package/dist/{services/search → kernel}/search-diagnostics.d.ts +0 -0
- /package/dist/{services/search → kernel}/search-diagnostics.js +0 -0
- /package/dist/{services/structural → kernel}/types.d.ts +0 -0
- /package/dist/{services/structural → kernel}/types.js +0 -0
- /package/dist/services/{graph → memory-graph}/graph-queries.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/graph-store-factory.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/graph-store-factory.js +0 -0
- /package/dist/services/{graph → memory-graph}/graph-store-pg.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/index.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/index.js +0 -0
- /package/dist/services/{graph → memory-graph}/memory-graph.service.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/memory-graph.service.js +0 -0
- /package/dist/services/{graph → memory-graph}/relation-extractor.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/relation-extractor.js +0 -0
- /package/dist/services/{graph → memory-graph}/types.d.ts +0 -0
- /package/dist/services/{graph → memory-graph}/types.js +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @massa-ai/core - Line range selection
|
|
3
|
+
*
|
|
4
|
+
* Module 6 of the `tools/read_file.ts` extraction (PR-D, T11). Owns everything
|
|
5
|
+
* that turns a request into the slice of a file the caller actually receives:
|
|
6
|
+
* `calculateRange` (request → range), `adjustRange` (range → range clamped to
|
|
7
|
+
* the file), `extractLines` (range → line-numbered text), the `ReadRange` shape
|
|
8
|
+
* they pass around, and the N9 output cap — the `MASSA_AI_READ_FILE_MAX_LINES`
|
|
9
|
+
* ceiling together with the clipping block that used to sit inside `handle()`.
|
|
10
|
+
*
|
|
11
|
+
* FREE FUNCTIONS, NOT A CLASS, and that is a decision rather than a default.
|
|
12
|
+
* Modules 2-5 are classes because each owns per-tool state — a Map, a
|
|
13
|
+
* subscription, an injected collaborator. This module owns none: every function
|
|
14
|
+
* here is pure, and the one piece of state is a process-wide constant read from
|
|
15
|
+
* the environment. `services/cache/lru-evict.ts` (module 1) is a bare function
|
|
16
|
+
* for exactly this reason (`design.md` §5.2). A class would also have to be
|
|
17
|
+
* constructed in `ReadFileTool`'s constructor, which is the one surface C64 is
|
|
18
|
+
* about, and would falsely imply per-instance state.
|
|
19
|
+
*
|
|
20
|
+
* IT IMPORTS NOTHING AT ALL, which is `lru-evict.ts`'s property and is asserted
|
|
21
|
+
* by this module's own unit test rather than by any tier rule.
|
|
22
|
+
*
|
|
23
|
+
* `LineRangeRequest` EXISTS BECAUSE `ReadFileParams` IS MODULE 7's. `design.md`
|
|
24
|
+
* §5.1 assigns `interface ReadFileParams` to `read-file.service.ts`, which T12
|
|
25
|
+
* built and which COMPOSES this module — so importing it here would be a 6 → 7
|
|
26
|
+
* edge against the composition direction. It exists now and the rule is
|
|
27
|
+
* unchanged. `calculateRange` reads exactly four fields off its argument, so
|
|
28
|
+
* this module declares those four and `ReadFileParams` satisfies it
|
|
29
|
+
* structurally. The alternative Design's module table hides is that module 6
|
|
30
|
+
* silently depends on module 7's type; naming the subset is what keeps 6
|
|
31
|
+
* standalone. Same shape as the 4 → 5 edge §4.1 decided, which Design handed to
|
|
32
|
+
* Tasks explicitly — this one it handed to nobody.
|
|
33
|
+
*
|
|
34
|
+
* THE CLIPPED PATH RETURNS UNNUMBERED TEXT, AND THAT IS PRESERVED DELIBERATELY.
|
|
35
|
+
* `extractLines` prefixes every line with a padded line number; the cap does NOT
|
|
36
|
+
* slice that string — it re-slices the RAW `lines` array and joins it, so a
|
|
37
|
+
* clipped response loses the prefixes an unclipped one carries. Found by the
|
|
38
|
+
* Plan Challenge gate's red-team lens before this file was written, and
|
|
39
|
+
* confirmed by the evidence audit: no test anywhere asserts content on the
|
|
40
|
+
* clipped path, so composing this as "extract, then slice the extracted text"
|
|
41
|
+
* would have been a silent behavior change inside a behavior-preserving PR.
|
|
42
|
+
* `__tests__/line-range.test.ts` pins both branches' exact format. Whether the
|
|
43
|
+
* asymmetry is intentional is not PR-D's question — it is logged, not fixed
|
|
44
|
+
* (`spec.md` §6, R-07's precedent).
|
|
45
|
+
*/
|
|
46
|
+
/** An inclusive, 1-indexed line range. `end` may be `Infinity` before adjustment. */
|
|
47
|
+
export interface ReadRange {
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The four fields `calculateRange` reads. `ReadFileParams` (module 7, T12)
|
|
53
|
+
* satisfies this structurally; declaring the subset is what stops module 6
|
|
54
|
+
* depending on the module that composes it.
|
|
55
|
+
*/
|
|
56
|
+
export interface LineRangeRequest {
|
|
57
|
+
offset?: number;
|
|
58
|
+
limit?: number;
|
|
59
|
+
lineStart?: number;
|
|
60
|
+
lineEnd?: number;
|
|
61
|
+
}
|
|
62
|
+
/** The result of selecting lines, after the N9 cap has been applied. */
|
|
63
|
+
export interface LineSelection {
|
|
64
|
+
/** The text served to the caller. Line-numbered unless `clipped`. */
|
|
65
|
+
content: string;
|
|
66
|
+
/** `content.split("\n").length` — recomputed after any clipping. */
|
|
67
|
+
lineCount: number;
|
|
68
|
+
/** True when the N9 cap trimmed the selection. Surfaces as `source_clipped`. */
|
|
69
|
+
clipped: boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare function calculateRange(params: LineRangeRequest): ReadRange;
|
|
72
|
+
export declare function adjustRange(range: ReadRange, totalLines: number): ReadRange;
|
|
73
|
+
export declare function extractLines(lines: string[], range: ReadRange): string;
|
|
74
|
+
/**
|
|
75
|
+
* Extract the requested lines and apply the N9 cap, returning the clipped flag
|
|
76
|
+
* rather than mutating the caller's locals.
|
|
77
|
+
*
|
|
78
|
+
* The two steps ship as one function because they were never separable at the
|
|
79
|
+
* call site: before this task the cap read and reassigned the very
|
|
80
|
+
* `selectedContent` and `selectedLineCount` that the `extractLines` call one
|
|
81
|
+
* line above it had produced, inside `handle()`. Deliberately unnumbered — a
|
|
82
|
+
* line citation into `read_file.ts` written here would name a revision that no
|
|
83
|
+
* longer exists the moment this commit lands, and T12 moves that whole region
|
|
84
|
+
* again (T8b's de-numbering precedent). Splitting them would mean passing
|
|
85
|
+
* the already-extracted string and its line count back in as parameters, which
|
|
86
|
+
* duplicates the `.split("\n")` at the call site and adds an argument derivable
|
|
87
|
+
* from another. `extractLines` stays exported so its own contract is pinnable
|
|
88
|
+
* independently.
|
|
89
|
+
*/
|
|
90
|
+
export declare function selectLines(lines: string[], range: ReadRange): LineSelection;
|
|
91
|
+
//# sourceMappingURL=line-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-range.d.ts","sourceRoot":"","sources":["../../../src/services/file-read/line-range.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AA2BH,qFAAqF;AACrF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAsBlE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAK3E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAatE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,GAAG,aAAa,CA0B5E"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @massa-ai/core - Line range selection
|
|
3
|
+
*
|
|
4
|
+
* Module 6 of the `tools/read_file.ts` extraction (PR-D, T11). Owns everything
|
|
5
|
+
* that turns a request into the slice of a file the caller actually receives:
|
|
6
|
+
* `calculateRange` (request → range), `adjustRange` (range → range clamped to
|
|
7
|
+
* the file), `extractLines` (range → line-numbered text), the `ReadRange` shape
|
|
8
|
+
* they pass around, and the N9 output cap — the `MASSA_AI_READ_FILE_MAX_LINES`
|
|
9
|
+
* ceiling together with the clipping block that used to sit inside `handle()`.
|
|
10
|
+
*
|
|
11
|
+
* FREE FUNCTIONS, NOT A CLASS, and that is a decision rather than a default.
|
|
12
|
+
* Modules 2-5 are classes because each owns per-tool state — a Map, a
|
|
13
|
+
* subscription, an injected collaborator. This module owns none: every function
|
|
14
|
+
* here is pure, and the one piece of state is a process-wide constant read from
|
|
15
|
+
* the environment. `services/cache/lru-evict.ts` (module 1) is a bare function
|
|
16
|
+
* for exactly this reason (`design.md` §5.2). A class would also have to be
|
|
17
|
+
* constructed in `ReadFileTool`'s constructor, which is the one surface C64 is
|
|
18
|
+
* about, and would falsely imply per-instance state.
|
|
19
|
+
*
|
|
20
|
+
* IT IMPORTS NOTHING AT ALL, which is `lru-evict.ts`'s property and is asserted
|
|
21
|
+
* by this module's own unit test rather than by any tier rule.
|
|
22
|
+
*
|
|
23
|
+
* `LineRangeRequest` EXISTS BECAUSE `ReadFileParams` IS MODULE 7's. `design.md`
|
|
24
|
+
* §5.1 assigns `interface ReadFileParams` to `read-file.service.ts`, which T12
|
|
25
|
+
* built and which COMPOSES this module — so importing it here would be a 6 → 7
|
|
26
|
+
* edge against the composition direction. It exists now and the rule is
|
|
27
|
+
* unchanged. `calculateRange` reads exactly four fields off its argument, so
|
|
28
|
+
* this module declares those four and `ReadFileParams` satisfies it
|
|
29
|
+
* structurally. The alternative Design's module table hides is that module 6
|
|
30
|
+
* silently depends on module 7's type; naming the subset is what keeps 6
|
|
31
|
+
* standalone. Same shape as the 4 → 5 edge §4.1 decided, which Design handed to
|
|
32
|
+
* Tasks explicitly — this one it handed to nobody.
|
|
33
|
+
*
|
|
34
|
+
* THE CLIPPED PATH RETURNS UNNUMBERED TEXT, AND THAT IS PRESERVED DELIBERATELY.
|
|
35
|
+
* `extractLines` prefixes every line with a padded line number; the cap does NOT
|
|
36
|
+
* slice that string — it re-slices the RAW `lines` array and joins it, so a
|
|
37
|
+
* clipped response loses the prefixes an unclipped one carries. Found by the
|
|
38
|
+
* Plan Challenge gate's red-team lens before this file was written, and
|
|
39
|
+
* confirmed by the evidence audit: no test anywhere asserts content on the
|
|
40
|
+
* clipped path, so composing this as "extract, then slice the extracted text"
|
|
41
|
+
* would have been a silent behavior change inside a behavior-preserving PR.
|
|
42
|
+
* `__tests__/line-range.test.ts` pins both branches' exact format. Whether the
|
|
43
|
+
* asymmetry is intentional is not PR-D's question — it is logged, not fixed
|
|
44
|
+
* (`spec.md` §6, R-07's precedent).
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* N9: per-read line ceiling on user-facing read_file output. Default 500;
|
|
48
|
+
* override via `MASSA_AI_READ_FILE_MAX_LINES`. Invalid/negative/zero
|
|
49
|
+
* values fall back to 500 (treat invalid as unset). When the requested
|
|
50
|
+
* range exceeds the cap, `selectedContent` is sliced and `source_clipped:
|
|
51
|
+
* true` is emitted in the same response. The true total line count is
|
|
52
|
+
* always surfaced as `lineRange.actual.total` so `omitted = total - shown`
|
|
53
|
+
* is derivable. Internal enrichment paths (SymbolGraphService.readSnippet
|
|
54
|
+
* /readContext used by go_to_definition) are NOT capped — see
|
|
55
|
+
* symbol-graph.service.ts for the exclusion comment.
|
|
56
|
+
*
|
|
57
|
+
* STILL EVALUATED ONCE AT MODULE LOAD, which is what keeps the move
|
|
58
|
+
* behavior-preserving. This module is a dependency of `tools/read_file.ts`, so
|
|
59
|
+
* it now evaluates strictly EARLIER in the graph — but both happen on the first
|
|
60
|
+
* import of `read_file.ts`, and a module-level const was never re-readable at
|
|
61
|
+
* call time in either arrangement. Measured: no test can reach this branch.
|
|
62
|
+
* `apps/tools-api/src/routes/workspace.test.ts:422` does set this variable, but
|
|
63
|
+
* it drives `workspace.ts`'s own PER-REQUEST copy of the same IIFE for
|
|
64
|
+
* `symbol_snippet` (a third, separate read of the same name), never this one.
|
|
65
|
+
*/
|
|
66
|
+
const MASSA_AI_READ_FILE_MAX_LINES = (() => {
|
|
67
|
+
const v = Number(process.env.MASSA_AI_READ_FILE_MAX_LINES);
|
|
68
|
+
return Number.isFinite(v) && v > 0 ? Math.floor(v) : 500;
|
|
69
|
+
})();
|
|
70
|
+
export function calculateRange(params) {
|
|
71
|
+
// Priority: lineStart/lineEnd > offset/limit > entire file
|
|
72
|
+
if (params.lineStart !== undefined && params.lineEnd !== undefined) {
|
|
73
|
+
return {
|
|
74
|
+
start: Math.max(1, params.lineStart),
|
|
75
|
+
end: params.lineEnd,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (params.offset !== undefined) {
|
|
79
|
+
const offset = Math.max(1, params.offset);
|
|
80
|
+
const limit = params.limit || 1000;
|
|
81
|
+
return {
|
|
82
|
+
start: offset,
|
|
83
|
+
end: offset + limit - 1,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
start: 1,
|
|
88
|
+
end: Infinity,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function adjustRange(range, totalLines) {
|
|
92
|
+
const start = Math.max(1, Math.min(range.start, totalLines));
|
|
93
|
+
const end = range.end === Infinity ? totalLines : Math.min(range.end, totalLines);
|
|
94
|
+
return { start, end };
|
|
95
|
+
}
|
|
96
|
+
export function extractLines(lines, range) {
|
|
97
|
+
const start = range.start - 1; // Convert to 0-indexed
|
|
98
|
+
const end = range.end;
|
|
99
|
+
const selectedLines = lines.slice(start, end);
|
|
100
|
+
// Add line numbers for context
|
|
101
|
+
return selectedLines
|
|
102
|
+
.map((line, index) => {
|
|
103
|
+
const lineNum = start + index + 1;
|
|
104
|
+
return `${lineNum.toString().padStart(6, " ")}: ${line}`;
|
|
105
|
+
})
|
|
106
|
+
.join("\n");
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Extract the requested lines and apply the N9 cap, returning the clipped flag
|
|
110
|
+
* rather than mutating the caller's locals.
|
|
111
|
+
*
|
|
112
|
+
* The two steps ship as one function because they were never separable at the
|
|
113
|
+
* call site: before this task the cap read and reassigned the very
|
|
114
|
+
* `selectedContent` and `selectedLineCount` that the `extractLines` call one
|
|
115
|
+
* line above it had produced, inside `handle()`. Deliberately unnumbered — a
|
|
116
|
+
* line citation into `read_file.ts` written here would name a revision that no
|
|
117
|
+
* longer exists the moment this commit lands, and T12 moves that whole region
|
|
118
|
+
* again (T8b's de-numbering precedent). Splitting them would mean passing
|
|
119
|
+
* the already-extracted string and its line count back in as parameters, which
|
|
120
|
+
* duplicates the `.split("\n")` at the call site and adds an argument derivable
|
|
121
|
+
* from another. `extractLines` stays exported so its own contract is pinnable
|
|
122
|
+
* independently.
|
|
123
|
+
*/
|
|
124
|
+
export function selectLines(lines, range) {
|
|
125
|
+
let content = extractLines(lines, range);
|
|
126
|
+
let lineCount = content.split("\n").length;
|
|
127
|
+
// N9: cap user-facing read_file output at MASSA_AI_READ_FILE_MAX_LINES
|
|
128
|
+
// (default 500). When the adjusted range exceeds the cap, slice the
|
|
129
|
+
// content and emit `source_clipped: true` in the same response so the
|
|
130
|
+
// caller knows lines were omitted. `lineRange.actual.total` keeps the
|
|
131
|
+
// true total line count so `omitted = total - shown` is derivable.
|
|
132
|
+
//
|
|
133
|
+
// NOTE the slice is over `lines`, the RAW array — not over `content`, which
|
|
134
|
+
// `extractLines` has already numbered. That is the pre-existing shape, moved
|
|
135
|
+
// verbatim: a clipped response is unnumbered where an unclipped one is
|
|
136
|
+
// numbered. See this file's header.
|
|
137
|
+
let clipped = false;
|
|
138
|
+
if (lineCount > MASSA_AI_READ_FILE_MAX_LINES) {
|
|
139
|
+
const cappedLines = lines.slice(range.start - 1, range.start - 1 + MASSA_AI_READ_FILE_MAX_LINES);
|
|
140
|
+
content = cappedLines.join("\n");
|
|
141
|
+
lineCount = content.split("\n").length;
|
|
142
|
+
clipped = true;
|
|
143
|
+
}
|
|
144
|
+
return { content, lineCount, clipped };
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=line-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-range.js","sourceRoot":"","sources":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uEAAuE;IACvE,oCAAoC;IACpC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,SAAS,GAAG,4BAA4B,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAC7B,KAAK,CAAC,KAAK,GAAG,CAAC,EACf,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,4BAA4B,CAC/C,CAAC;QACF,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACvC,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ProjectRootCache } from "./project-root-cache.js";
|
|
2
|
+
export declare class PathContainment {
|
|
3
|
+
private readonly projectRoots;
|
|
4
|
+
constructor(projectRoots: ProjectRootCache);
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a filePath to an absolute path.
|
|
7
|
+
*
|
|
8
|
+
* Resolution rules:
|
|
9
|
+
* - Absolute path → returned verbatim (still normalized via path.resolve, but base-independent).
|
|
10
|
+
* - `projectId` present → resolved against the workspace `project_path`. If the
|
|
11
|
+
* workspace lookup fails (no root), this returns null (ambiguous).
|
|
12
|
+
* - No `projectId` AND relative `filePath` → returns null. We deliberately do NOT
|
|
13
|
+
* fall back to `path.resolve(filePath)` against process.cwd(), because a
|
|
14
|
+
* relative path arriving without a projectId is ambiguous and historically
|
|
15
|
+
* read from the server's cwd (COVERAGE finding #3). Callers must provide an
|
|
16
|
+
* absolute path or a projectId.
|
|
17
|
+
*
|
|
18
|
+
* Returns null to signal an ambiguous/unsatisfiable path so `handle()` can map it
|
|
19
|
+
* to a distinct, clear error instead of the generic "Failed to read file" catch.
|
|
20
|
+
*/
|
|
21
|
+
resolveFilePath(filePath: string, projectId?: string): Promise<string | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Wave 5 FR-12 / AD-W5-006: filesystem-side path containment.
|
|
24
|
+
*
|
|
25
|
+
* An absolute path is allowed iff it resolves under one of:
|
|
26
|
+
* 1. the project root (workspace lookup for projectId, when provided)
|
|
27
|
+
* 2. process.cwd()
|
|
28
|
+
* 3. an entry in MASSA_AI_READ_FILE_ROOTS (colon-separated env)
|
|
29
|
+
*
|
|
30
|
+
* Project root + cwd are ALWAYS allowed. Outside → teaching error listing
|
|
31
|
+
* valid roots only (no host path enumeration). The check uses path.relative
|
|
32
|
+
* to detect traversal out of a root (a result starting with ".." or an
|
|
33
|
+
* absolute path on another drive means outside).
|
|
34
|
+
*
|
|
35
|
+
* The env allowlist is read at CALL TIME (not config-load time) so test
|
|
36
|
+
* suites and runtime operators can set it without restarting the process.
|
|
37
|
+
* config.readFile.extraRoots mirrors the same env for introspection.
|
|
38
|
+
*
|
|
39
|
+
* Returns { allowed: true } on success, or { allowed: false, error } with a
|
|
40
|
+
* Wave-4-N6-style teaching error listing the valid roots.
|
|
41
|
+
*/
|
|
42
|
+
checkPathContainment(absoluteFilePath: string, projectId?: string): Promise<{
|
|
43
|
+
allowed: true;
|
|
44
|
+
} | {
|
|
45
|
+
allowed: false;
|
|
46
|
+
error: string;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=path-containment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-containment.d.ts","sourceRoot":"","sources":["../../../src/services/file-read/path-containment.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,gBAAgB;IAE3D;;;;;;;;;;;;;;;OAeG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAmBnF;;;;;;;;;;;;;;;;;;;OAmBG;IACG,oBAAoB,CACxB,gBAAgB,EAAE,MAAM,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAuClE"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @massa-ai/core - Path resolution and filesystem containment
|
|
3
|
+
*
|
|
4
|
+
* Module 2 of the `tools/read_file.ts` extraction (PR-D, T9). Holds the two
|
|
5
|
+
* security-sensitive path functions `ReadFileTool` used to carry as private
|
|
6
|
+
* methods: `resolveFilePath` (absolute / projectId / ambiguous) and
|
|
7
|
+
* `checkPathContainment` (Wave 5 FR-12 / AD-W5-006).
|
|
8
|
+
*
|
|
9
|
+
* BOTH BODIES ARE MOVED VERBATIM. RFS-01's gate is structural and cannot tell a
|
|
10
|
+
* correct delegate from a widened one (RFS-01 AC-6), and `check-core-layering`
|
|
11
|
+
* cannot either, so this module's only real sensor is its tests —
|
|
12
|
+
* `__tests__/read-file-containment-shapes.test.ts` (RFS-06, the three mutation
|
|
13
|
+
* shapes all seven pre-existing containment tests fail to kill) plus
|
|
14
|
+
* `__tests__/path-containment.test.ts`. Neither the containment predicate nor
|
|
15
|
+
* the teaching-error text may drift here; RFS-06 AC-2 pins the latter.
|
|
16
|
+
*
|
|
17
|
+
* It takes the project-root cache as a constructor dependency. `design.md` §5.1
|
|
18
|
+
* names the 2 → 3 edge as real and one-directional — "module 2 cannot be
|
|
19
|
+
* constructed without module 3" — but chooses no mechanism, unlike the 4 → 5
|
|
20
|
+
* edge it hands to Tasks explicitly (`tasks.md` §4.1). Constructor injection is
|
|
21
|
+
* chosen over a `getProjectRoot` callback because the two are behaviorally
|
|
22
|
+
* indistinguishable here (module 3 caches, so neither adds a lookup) and the
|
|
23
|
+
* direct edge is the one §5.1 describes; the callback shape exists in §4.1/§4.2
|
|
24
|
+
* to stop a module NAMING a heavy collaborator, and module 3 is neither heavy
|
|
25
|
+
* nor a type this module would otherwise avoid.
|
|
26
|
+
*/
|
|
27
|
+
import { sanitizeFilePath } from "@massa-ai/shared";
|
|
28
|
+
import path from "path";
|
|
29
|
+
export class PathContainment {
|
|
30
|
+
projectRoots;
|
|
31
|
+
constructor(projectRoots) {
|
|
32
|
+
this.projectRoots = projectRoots;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a filePath to an absolute path.
|
|
36
|
+
*
|
|
37
|
+
* Resolution rules:
|
|
38
|
+
* - Absolute path → returned verbatim (still normalized via path.resolve, but base-independent).
|
|
39
|
+
* - `projectId` present → resolved against the workspace `project_path`. If the
|
|
40
|
+
* workspace lookup fails (no root), this returns null (ambiguous).
|
|
41
|
+
* - No `projectId` AND relative `filePath` → returns null. We deliberately do NOT
|
|
42
|
+
* fall back to `path.resolve(filePath)` against process.cwd(), because a
|
|
43
|
+
* relative path arriving without a projectId is ambiguous and historically
|
|
44
|
+
* read from the server's cwd (COVERAGE finding #3). Callers must provide an
|
|
45
|
+
* absolute path or a projectId.
|
|
46
|
+
*
|
|
47
|
+
* Returns null to signal an ambiguous/unsatisfiable path so `handle()` can map it
|
|
48
|
+
* to a distinct, clear error instead of the generic "Failed to read file" catch.
|
|
49
|
+
*/
|
|
50
|
+
async resolveFilePath(filePath, projectId) {
|
|
51
|
+
if (path.isAbsolute(filePath)) {
|
|
52
|
+
return path.resolve(filePath);
|
|
53
|
+
}
|
|
54
|
+
if (projectId) {
|
|
55
|
+
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
56
|
+
if (root) {
|
|
57
|
+
// Wave 5 FR-12: strip ../ traversal tokens from relative paths before
|
|
58
|
+
// resolving under the project root. sanitizeFilePath removes ../ and
|
|
59
|
+
// ..\ segments so a crafted relative path can't escape the root.
|
|
60
|
+
const cleaned = sanitizeFilePath(filePath);
|
|
61
|
+
return path.resolve(root, cleaned);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
// Relative path with no projectId — do not guess against cwd.
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Wave 5 FR-12 / AD-W5-006: filesystem-side path containment.
|
|
70
|
+
*
|
|
71
|
+
* An absolute path is allowed iff it resolves under one of:
|
|
72
|
+
* 1. the project root (workspace lookup for projectId, when provided)
|
|
73
|
+
* 2. process.cwd()
|
|
74
|
+
* 3. an entry in MASSA_AI_READ_FILE_ROOTS (colon-separated env)
|
|
75
|
+
*
|
|
76
|
+
* Project root + cwd are ALWAYS allowed. Outside → teaching error listing
|
|
77
|
+
* valid roots only (no host path enumeration). The check uses path.relative
|
|
78
|
+
* to detect traversal out of a root (a result starting with ".." or an
|
|
79
|
+
* absolute path on another drive means outside).
|
|
80
|
+
*
|
|
81
|
+
* The env allowlist is read at CALL TIME (not config-load time) so test
|
|
82
|
+
* suites and runtime operators can set it without restarting the process.
|
|
83
|
+
* config.readFile.extraRoots mirrors the same env for introspection.
|
|
84
|
+
*
|
|
85
|
+
* Returns { allowed: true } on success, or { allowed: false, error } with a
|
|
86
|
+
* Wave-4-N6-style teaching error listing the valid roots.
|
|
87
|
+
*/
|
|
88
|
+
async checkPathContainment(absoluteFilePath, projectId) {
|
|
89
|
+
// Collect valid roots. Project root is included only when actually
|
|
90
|
+
// resolvable (workspace lookup succeeds); cwd is always available.
|
|
91
|
+
const roots = [];
|
|
92
|
+
if (projectId) {
|
|
93
|
+
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
94
|
+
if (root)
|
|
95
|
+
roots.push(path.resolve(root));
|
|
96
|
+
}
|
|
97
|
+
roots.push(path.resolve(process.cwd()));
|
|
98
|
+
// Read the env allowlist at call time so tests/operators can set it
|
|
99
|
+
// without restarting the process. Colon-separated (POSIX-style).
|
|
100
|
+
const envRoots = (process.env.MASSA_AI_READ_FILE_ROOTS ?? "")
|
|
101
|
+
.split(":")
|
|
102
|
+
.map((s) => s.trim())
|
|
103
|
+
.filter((s) => s.length > 0);
|
|
104
|
+
for (const extra of envRoots) {
|
|
105
|
+
roots.push(path.resolve(extra));
|
|
106
|
+
}
|
|
107
|
+
const target = path.resolve(absoluteFilePath);
|
|
108
|
+
for (const root of roots) {
|
|
109
|
+
const rel = path.relative(root, target);
|
|
110
|
+
// Inside iff rel does not start with ".." and is not absolute (cross-drive).
|
|
111
|
+
if (rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel)) {
|
|
112
|
+
return { allowed: true };
|
|
113
|
+
}
|
|
114
|
+
// Exact root match (rel === "") is also inside.
|
|
115
|
+
if (rel === "")
|
|
116
|
+
return { allowed: true };
|
|
117
|
+
}
|
|
118
|
+
// Outside all roots → teaching error listing valid roots only.
|
|
119
|
+
const validRootsList = roots.map((r) => ` - ${r}`).join("\n");
|
|
120
|
+
return {
|
|
121
|
+
allowed: false,
|
|
122
|
+
error: `read_file path containment: "${target}" is outside the allowed roots.\n` +
|
|
123
|
+
`Valid roots (project root + cwd + MASSA_AI_READ_FILE_ROOTS):\n${validRootsList}\n` +
|
|
124
|
+
`Provide a filePath that resolves under one of these roots.`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=path-containment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-containment.js","sourceRoot":"","sources":["../../../src/services/file-read/path-containment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,YAA8B;QAA9B,iBAAY,GAAZ,YAAY,CAAkB;IAAG,CAAC;IAE/D;;;;;;;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
|
|
4
|
+
/**
|
|
5
|
+
* Maximum entries retained in the cache. Without a cap, an adversarial caller
|
|
6
|
+
* cycling distinct projectIds grows the map for the process lifetime. Map
|
|
7
|
+
* preserves INSERTION order in JS; we promote a key to most-recently-used on
|
|
8
|
+
* GET via delete+set, and evict the oldest key on SET while over the cap.
|
|
9
|
+
*
|
|
10
|
+
* Before the extraction this bound was read from `ReadFileTool`'s own
|
|
11
|
+
* FILE_CACHE_MAX_ENTRIES, which belongs to the file CONTENT cache and which
|
|
12
|
+
* T10 moved to `file-content-cache.ts`. Both were 512 and neither ever read
|
|
13
|
+
* the other's value, so naming the bound here retains the same number at the
|
|
14
|
+
* same call positions.
|
|
15
|
+
* Mirrors SymbolGraphService.PROJECT_ROOT_CACHE_MAX_ENTRIES.
|
|
16
|
+
*/
|
|
17
|
+
private readonly PROJECT_ROOT_CACHE_MAX_ENTRIES;
|
|
18
|
+
constructor();
|
|
19
|
+
getProjectRoot(projectId: string): Promise<string | null>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=project-root-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-root-cache.d.ts","sourceRoot":"","sources":["../../../src/services/file-read/project-root-cache.ts"],"names":[],"mappings":"AA2BA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IACzC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAO;;IAehD,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAqBhE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @massa-ai/core - Project root cache
|
|
3
|
+
*
|
|
4
|
+
* Module 3 of the `tools/read_file.ts` extraction (PR-D, T9). Owns the
|
|
5
|
+
* projectId → canonical project-root path cache that `ReadFileTool` used to
|
|
6
|
+
* carry as a private field, together with the `indexing:started` subscription
|
|
7
|
+
* that refreshes it and the LRU cap that bounds it.
|
|
8
|
+
*
|
|
9
|
+
* INSTANTIATED PER ReadFileTool, never as a module singleton. Each tool
|
|
10
|
+
* instance owned its own Map before the move — measured 41 construction sites
|
|
11
|
+
* across 9 files, 39 of them in tests — so a shared instance would leak cached
|
|
12
|
+
* roots between independently-constructed tools. That is a behavior change, and
|
|
13
|
+
* this extraction is behavior-preserving by contract (RFS-02 AC-1).
|
|
14
|
+
*
|
|
15
|
+
* ROOT_CACHE_TTL IS DECLARED AND READ NOWHERE, and that is carried across
|
|
16
|
+
* deliberately rather than repaired. It is the pre-existing state, measured by
|
|
17
|
+
* `__tests__/read-file-project-root-rename-pin.test.ts` (RFS-02 AC-4): past
|
|
18
|
+
* 300 s the project root still does not re-resolve, so this cache is
|
|
19
|
+
* LRU-bounded only and a committed rename leaves it serving the pre-rename
|
|
20
|
+
* root. PR-D logs that defect and does not fix it — enforcing the TTL here
|
|
21
|
+
* would be a behavior change inside a behavior-preserving PR.
|
|
22
|
+
*/
|
|
23
|
+
import { logger } from "@massa-ai/shared";
|
|
24
|
+
import { evictOldest } from "../cache/lru-evict.js";
|
|
25
|
+
import { eventBus } from "../events/event-bus.js";
|
|
26
|
+
import { workspaceManager } from "../workspace/workspace-manager.js";
|
|
27
|
+
export class ProjectRootCache {
|
|
28
|
+
projectRootCache = new Map();
|
|
29
|
+
ROOT_CACHE_TTL = 300000; // 5 minutes
|
|
30
|
+
/**
|
|
31
|
+
* Maximum entries retained in the cache. Without a cap, an adversarial caller
|
|
32
|
+
* cycling distinct projectIds grows the map for the process lifetime. Map
|
|
33
|
+
* preserves INSERTION order in JS; we promote a key to most-recently-used on
|
|
34
|
+
* GET via delete+set, and evict the oldest key on SET while over the cap.
|
|
35
|
+
*
|
|
36
|
+
* Before the extraction this bound was read from `ReadFileTool`'s own
|
|
37
|
+
* FILE_CACHE_MAX_ENTRIES, which belongs to the file CONTENT cache and which
|
|
38
|
+
* T10 moved to `file-content-cache.ts`. Both were 512 and neither ever read
|
|
39
|
+
* the other's value, so naming the bound here retains the same number at the
|
|
40
|
+
* same call positions.
|
|
41
|
+
* Mirrors SymbolGraphService.PROJECT_ROOT_CACHE_MAX_ENTRIES.
|
|
42
|
+
*/
|
|
43
|
+
PROJECT_ROOT_CACHE_MAX_ENTRIES = 512;
|
|
44
|
+
constructor() {
|
|
45
|
+
// The API keeps one ReadFileTool instance for the process lifetime. A
|
|
46
|
+
// guarded reset/reindex may legitimately move the same projectId to a new
|
|
47
|
+
// canonical root, so refresh the cached root as soon as ETL announces the
|
|
48
|
+
// new run. Without this, relative reads keep resolving against the prior
|
|
49
|
+
// workspace path until the API restarts.
|
|
50
|
+
eventBus.subscribe("indexing:started", ({ projectId, projectPath }) => {
|
|
51
|
+
this.projectRootCache.delete(projectId);
|
|
52
|
+
evictOldest(this.projectRootCache, this.PROJECT_ROOT_CACHE_MAX_ENTRIES - 1);
|
|
53
|
+
this.projectRootCache.set(projectId, projectPath);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async getProjectRoot(projectId) {
|
|
57
|
+
const cached = this.projectRootCache.get(projectId);
|
|
58
|
+
if (cached !== undefined) {
|
|
59
|
+
// LRU touch: promote this key to most-recently-used.
|
|
60
|
+
this.projectRootCache.delete(projectId);
|
|
61
|
+
this.projectRootCache.set(projectId, cached);
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const workspace = await workspaceManager.getWorkspace(projectId);
|
|
66
|
+
if (workspace?.project_path) {
|
|
67
|
+
evictOldest(this.projectRootCache, this.PROJECT_ROOT_CACHE_MAX_ENTRIES - 1);
|
|
68
|
+
this.projectRootCache.set(projectId, workspace.project_path);
|
|
69
|
+
return workspace.project_path;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
logger.warn("Failed to look up project root", { projectId, error: error.message });
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=project-root-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-root-cache.js","sourceRoot":"","sources":["../../../src/services/file-read/project-root-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,MAAM,OAAO,gBAAgB;IACnB,gBAAgB,GAAwB,IAAI,GAAG,EAAE,CAAC;IACzC,cAAc,GAAG,MAAM,CAAC,CAAC,YAAY;IACtD;;;;;;;;;;;;OAYG;IACc,8BAA8B,GAAG,GAAG,CAAC;IAEtD;QACE,sEAAsE;QACtE,0EAA0E;QAC1E,0EAA0E;QAC1E,yEAAyE;QACzE,yCAAyC;QACzC,QAAQ,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE;YACpE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACxC,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,8BAA8B,GAAG,CAAC,CAAC,CAAC;YAC5E,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,SAAiB;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,qDAAqD;YACrD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACxC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC7C,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YACjE,IAAI,SAAS,EAAE,YAAY,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,8BAA8B,GAAG,CAAC,CAAC,CAAC;gBAC5E,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;gBAC7D,OAAO,SAAS,CAAC,YAAY,CAAC;YAChC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QAChG,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { SymbolGraphService } from "../symbol/symbol-graph.service.js";
|
|
2
|
+
/**
|
|
3
|
+
* The `read_file` request. Moved verbatim from `tools/read_file.ts`, which
|
|
4
|
+
* exported exactly one symbol (`ReadFileTool`), so this interface was
|
|
5
|
+
* module-local before the move and `services/file-read/` is not re-exported from
|
|
6
|
+
* `services/index.ts` — the move adds **0** names to `@massa-ai/core`'s published
|
|
7
|
+
* surface.
|
|
8
|
+
*
|
|
9
|
+
* `line-range.ts` declares its own four-field `LineRangeRequest` rather than
|
|
10
|
+
* importing this, and the two MUST NOT be unified (C66): module 6 is composed by
|
|
11
|
+
* module 7, so importing this there is a 6 -> 7 edge against the composition
|
|
12
|
+
* direction. `ReadFileParams` satisfies `LineRangeRequest` structurally, so
|
|
13
|
+
* `calculateRange(p)` below needs no adapter and no call-site change.
|
|
14
|
+
*/
|
|
15
|
+
export interface ReadFileParams {
|
|
16
|
+
filePath: string;
|
|
17
|
+
projectId?: string;
|
|
18
|
+
offset?: number;
|
|
19
|
+
limit?: number;
|
|
20
|
+
lineStart?: number;
|
|
21
|
+
lineEnd?: number;
|
|
22
|
+
compress?: boolean;
|
|
23
|
+
targetRatio?: number;
|
|
24
|
+
format?: "json" | "toon";
|
|
25
|
+
includeSymbols?: boolean;
|
|
26
|
+
includeImports?: boolean;
|
|
27
|
+
fields?: string[];
|
|
28
|
+
}
|
|
29
|
+
/** The six values `handle()`'s prelude used to derive above its own `try`. */
|
|
30
|
+
export interface ReadFileOptions {
|
|
31
|
+
shouldCompress: boolean;
|
|
32
|
+
targetRatio: number;
|
|
33
|
+
format: "json" | "toon";
|
|
34
|
+
fields?: string[];
|
|
35
|
+
includeSymbols: boolean;
|
|
36
|
+
includeImports: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A denial carries the exact error string the handler used to return inline; a
|
|
40
|
+
* success carries the assembled result the handler used to pass straight to
|
|
41
|
+
* `serializeToolResponse`. `data` is `unknown` because that value is built with
|
|
42
|
+
* `any` below — see `read()`.
|
|
43
|
+
*/
|
|
44
|
+
export type ReadFileOutcome = {
|
|
45
|
+
ok: false;
|
|
46
|
+
error: string;
|
|
47
|
+
} | {
|
|
48
|
+
ok: true;
|
|
49
|
+
data: unknown;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Read the six option fields, in the order and at the call position `handle()`
|
|
53
|
+
* used. Order is load-bearing only for a `params` whose property getters throw
|
|
54
|
+
* selectively; position is load-bearing for `null`/`undefined`, which must keep
|
|
55
|
+
* throwing out of `handle()` rather than being caught. See this file's header.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readFileOptions(p: ReadFileParams): ReadFileOptions;
|
|
58
|
+
export declare class ReadFileService {
|
|
59
|
+
private compressor;
|
|
60
|
+
private symbolGraph?;
|
|
61
|
+
private projectRoots;
|
|
62
|
+
private pathContainment;
|
|
63
|
+
private fileMetadata;
|
|
64
|
+
private fileContent;
|
|
65
|
+
constructor(symbolGraph?: SymbolGraphService);
|
|
66
|
+
read(p: ReadFileParams, options: ReadFileOptions): Promise<ReadFileOutcome>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=read-file.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.service.d.ts","sourceRoot":"","sources":["../../../src/services/file-read/read-file.service.ts"],"names":[],"mappings":"AAqDA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,EA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