@jingyi0605/codingns 0.8.1 → 0.9.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/bin/codingns.mjs +187 -156
- package/dist/public/assets/AdaptiveButlerPage-B17QiMyT.js +2 -0
- package/dist/public/assets/App-CFBwDUNA.js +30 -0
- package/dist/public/assets/{BootstrapPage-jFfl7KNK.js → BootstrapPage-W5wU3BPh.js} +1 -1
- package/dist/public/assets/{ConversationPage-sj_rn4q0.js → ConversationPage-DQLX1bUh.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-C5c88SOX.js → DesktopDetachPreviewPage-DTPeuAW-.js} +1 -1
- package/dist/public/assets/DesktopModal-6ii53_Y9.js +1 -0
- package/dist/public/assets/DesktopWindowPage-D0blSuKd.js +2 -0
- package/dist/public/assets/FileContextPanel-BrKO8Xt6.js +1 -0
- package/dist/public/assets/GitSidebar-BdwiDtOr.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-Cx_dBiBb.js +1 -0
- package/dist/public/assets/MobileSheet-opTWyRe1.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-_I0t7cC_.js → MobileTopHeaderFrame-BbNON3Y4.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-BZEzPeMj.js +1 -0
- package/dist/public/assets/PluginAccessOverview-mQDmAljp.js +1 -0
- package/dist/public/assets/PluginContainerPage-CcxUJpM4.js +1 -0
- package/dist/public/assets/PluginDetailPage-D5--ACIt.js +1 -0
- package/dist/public/assets/PluginsListPage-D_oJxYXT.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-CMtDWyGS.js → RelayConnectEntryPage-DROxpnkv.js} +1 -1
- package/dist/public/assets/ServerSettingsModal-CUUOPqSe.js +1 -0
- package/dist/public/assets/SessionIndexPage-C2Jxh6Gp.js +1 -0
- package/dist/public/assets/SettingsPage-BlAZCHsy.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-CjzbiWjl.js +1 -0
- package/dist/public/assets/{TerminalPage-CBIKHI33.js → TerminalPage-CwWyFDj8.js} +3 -3
- package/dist/public/assets/TerminalRuntimeFallbackModal-CSVVbO8r.js +1 -0
- package/dist/public/assets/ToolFilesPage-QBEY8oCf.js +1 -0
- package/dist/public/assets/ToolGitPage-BKoZ2l9v.js +1 -0
- package/dist/public/assets/ToolProcessesPage-BOH0ib4G.js +1 -0
- package/dist/public/assets/ToolsHomePage-BcMZ3BCQ.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-B5zoppEl.js +1 -0
- package/dist/public/assets/WorkbenchLayout-BksVkkFF.css +1 -0
- package/dist/public/assets/WorkbenchLayout-CikJBS62.js +1019 -0
- package/dist/public/assets/WorkbenchModal-NGmPgqaE.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BbbSOiZw.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DT3VMjWD.css +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-CVivdPx5.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-DgOSjscR.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-HPa7M_Vh.js +1 -0
- package/dist/public/assets/{client-runtime-manager-CdJP7nUp.js → client-runtime-manager-DXbI9K1K.js} +1 -1
- package/dist/public/assets/index-BxJPQpFM.css +1 -0
- package/dist/public/assets/index-CeXGOT_T.js +50 -0
- package/dist/public/assets/{login-direct-candidate-resolver-C-mo698r.js → login-direct-candidate-resolver-DkKyFtQJ.js} +1 -1
- package/dist/public/assets/plugin-permission-copy-CzN269Bk.js +1 -0
- package/dist/public/assets/plugins-api-Bv9DHpLF.js +1 -0
- package/dist/public/assets/{preferences-service-CnaTvZq2.js → preferences-service-D2ISL2Zz.js} +1 -1
- package/dist/public/assets/{relay-entry-D7OgZZN-.js → relay-entry-Bg0OisQy.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BCtAYB0E.js → terminal-runtime-meta-C8t-CIDF.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-Bol3NVfN.js +1 -0
- package/dist/public/assets/workbench-navigation-B7IjRQd8.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +4 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -1
- package/dist/server/middlewares/auth-guard.js +10 -5
- package/dist/server/middlewares/auth-guard.js.map +1 -1
- package/dist/server/modules/affairs-indexer/contracts/src/errors/app-error.d.ts +11 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/app-error.js +22 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/app-error.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/error-codes.d.ts +23 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/error-codes.js +23 -0
- package/dist/server/modules/affairs-indexer/contracts/src/errors/error-codes.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/index.d.ts +4 -0
- package/dist/server/modules/affairs-indexer/contracts/src/index.js +5 -0
- package/dist/server/modules/affairs-indexer/contracts/src/index.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/cli-command-context.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/cli-command-context.js +2 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/cli-command-context.js.map +1 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/runtime-config.d.ts +16 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/runtime-config.js +2 -0
- package/dist/server/modules/affairs-indexer/contracts/src/types/runtime-config.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/config/load-runtime-config.d.ts +10 -0
- package/dist/server/modules/affairs-indexer/core/src/config/load-runtime-config.js +215 -0
- package/dist/server/modules/affairs-indexer/core/src/config/load-runtime-config.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/index.d.ts +31 -0
- package/dist/server/modules/affairs-indexer/core/src/index.js +32 -0
- package/dist/server/modules/affairs-indexer/core/src/index.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/logging/structured-logger.d.ts +20 -0
- package/dist/server/modules/affairs-indexer/core/src/logging/structured-logger.js +47 -0
- package/dist/server/modules/affairs-indexer/core/src/logging/structured-logger.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/base-complex-parser-adapter.d.ts +17 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/base-complex-parser-adapter.js +63 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/base-complex-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/complex-document-skip-adapter.d.ts +12 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/complex-document-skip-adapter.js +42 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/complex-document-skip-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/csv-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/csv-parser-adapter.js +107 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/csv-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/document-parser.d.ts +19 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/document-parser.js +37 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/document-parser.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/docx-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/docx-parser-adapter.js +123 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/docx-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/openxml-utils.d.ts +8 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/openxml-utils.js +111 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/openxml-utils.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-adapter.d.ts +42 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-adapter.js +2 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-capability-registry.d.ts +18 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-capability-registry.js +91 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-capability-registry.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-router.d.ts +18 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-router.js +59 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-router.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.d.ts +48 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.js +193 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/parser-skip-repository.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pdf-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pdf-parser-adapter.js +371 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pdf-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser-adapter.d.ts +10 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser-adapter.js +55 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser.d.ts +9 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser.js +2 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/plain-text-parser.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pptx-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pptx-parser-adapter.js +130 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/pptx-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/xlsx-parser-adapter.d.ts +7 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/xlsx-parser-adapter.js +228 -0
- package/dist/server/modules/affairs-indexer/core/src/parser/xlsx-parser-adapter.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.d.ts +205 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js +1471 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-repository.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.d.ts +161 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.js +1350 -0
- package/dist/server/modules/affairs-indexer/core/src/repositories/catalog-write-repository.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/scanner/file-scanner.d.ts +32 -0
- package/dist/server/modules/affairs-indexer/core/src/scanner/file-scanner.js +208 -0
- package/dist/server/modules/affairs-indexer/core/src/scanner/file-scanner.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.d.ts +30 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js +66 -0
- package/dist/server/modules/affairs-indexer/core/src/services/dirty/dirty-scope-resolver.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.d.ts +33 -0
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js +705 -0
- package/dist/server/modules/affairs-indexer/core/src/services/export/export-builder.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/allowed-extensions-diff-service.d.ts +80 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/allowed-extensions-diff-service.js +193 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/allowed-extensions-diff-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/text-indexer.d.ts +77 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/text-indexer.js +467 -0
- package/dist/server/modules/affairs-indexer/core/src/services/indexer/text-indexer.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/mcp/mcp-stdio-server.d.ts +17 -0
- package/dist/server/modules/affairs-indexer/core/src/services/mcp/mcp-stdio-server.js +264 -0
- package/dist/server/modules/affairs-indexer/core/src/services/mcp/mcp-stdio-server.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/offline-search-service.d.ts +11 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/offline-search-service.js +76 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/offline-search-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.d.ts +26 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js +305 -0
- package/dist/server/modules/affairs-indexer/core/src/services/search/search-index-builder.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/tagging/tag-recompute-service.d.ts +53 -0
- package/dist/server/modules/affairs-indexer/core/src/services/tagging/tag-recompute-service.js +566 -0
- package/dist/server/modules/affairs-indexer/core/src/services/tagging/tag-recompute-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/services/watch/watch-service.d.ts +47 -0
- package/dist/server/modules/affairs-indexer/core/src/services/watch/watch-service.js +227 -0
- package/dist/server/modules/affairs-indexer/core/src/services/watch/watch-service.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/catalog-schema.d.ts +5 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/catalog-schema.js +245 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/catalog-schema.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.d.ts +14 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js +87 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/detect-catalog-schema.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/init-catalog.d.ts +13 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/init-catalog.js +16 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/init-catalog.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/migration-runner.d.ts +22 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/migration-runner.js +430 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/migration-runner.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.d.ts +9 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js +19 -0
- package/dist/server/modules/affairs-indexer/core/src/sqlite/open-database.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/tagging/simple-tag-inference.d.ts +21 -0
- package/dist/server/modules/affairs-indexer/core/src/tagging/simple-tag-inference.js +94 -0
- package/dist/server/modules/affairs-indexer/core/src/tagging/simple-tag-inference.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/abort.d.ts +2 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/abort.js +13 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/abort.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/file-streaming.d.ts +9 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/file-streaming.js +64 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/file-streaming.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/root-command-lock.d.ts +10 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/root-command-lock.js +230 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/root-command-lock.js.map +1 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/rss-log.d.ts +2 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/rss-log.js +19 -0
- package/dist/server/modules/affairs-indexer/core/src/utils/rss-log.js.map +1 -0
- package/dist/server/modules/affairs-indexer/internal-command-runner.d.ts +31 -0
- package/dist/server/modules/affairs-indexer/internal-command-runner.js +643 -0
- package/dist/server/modules/affairs-indexer/internal-command-runner.js.map +1 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +0 -49
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +10 -56
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +2 -46
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +15 -158
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/browser-runtime/opencli-bridge-browser-executor.d.ts +4 -2
- package/dist/server/modules/browser-runtime/opencli-bridge-browser-executor.js +62 -21
- package/dist/server/modules/browser-runtime/opencli-bridge-browser-executor.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +3 -4
- package/dist/server/modules/butler/butler-control-session-service.js +39 -62
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-controller.d.ts +11 -3
- package/dist/server/modules/butler/butler-controller.js +19 -4
- package/dist/server/modules/butler/butler-controller.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
- package/dist/server/modules/butler/butler-profile-service.d.ts +1 -1
- package/dist/server/modules/butler/butler-profile-service.js +34 -63
- package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
- package/dist/server/modules/butler/butler-project-service.d.ts +1 -3
- package/dist/server/modules/butler/butler-project-service.js +1 -7
- package/dist/server/modules/butler/butler-project-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-service.d.ts +1 -0
- package/dist/server/modules/butler/butler-session-service.js +109 -0
- package/dist/server/modules/butler/butler-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-summary-service.js +0 -2
- package/dist/server/modules/butler/butler-session-summary-service.js.map +1 -1
- package/dist/server/modules/butler/butler-workspace-context.d.ts +5 -1
- package/dist/server/modules/butler/butler-workspace-context.js +21 -12
- package/dist/server/modules/butler/butler-workspace-context.js.map +1 -1
- package/dist/server/modules/file/file-access-guard.d.ts +2 -0
- package/dist/server/modules/file/file-access-guard.js +24 -2
- package/dist/server/modules/file/file-access-guard.js.map +1 -1
- package/dist/server/modules/file/file-content-service.d.ts +11 -0
- package/dist/server/modules/file/file-content-service.js +55 -0
- package/dist/server/modules/file/file-content-service.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +178 -1
- package/dist/server/modules/file/file-controller.js +273 -4
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +3 -0
- package/dist/server/modules/file/file-preview-link-service.js +30 -1
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/file-preview-service.js +15 -4
- package/dist/server/modules/file/file-preview-service.js.map +1 -1
- package/dist/server/modules/file/file-preview-types.d.ts +9 -1
- package/dist/server/modules/file/file-preview-types.js +8 -1
- package/dist/server/modules/file/file-preview-types.js.map +1 -1
- package/dist/server/modules/file/recent-modified-file-service.d.ts +15 -0
- package/dist/server/modules/file/recent-modified-file-service.js +102 -0
- package/dist/server/modules/file/recent-modified-file-service.js.map +1 -0
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +917 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +137 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +490 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +42 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +304 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -0
- package/dist/server/modules/file/workspace-index-apply-service.d.ts +25 -0
- package/dist/server/modules/file/workspace-index-apply-service.js +42 -0
- package/dist/server/modules/file/workspace-index-apply-service.js.map +1 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/office/office-controller.d.ts +15 -1
- package/dist/server/modules/office/office-controller.js +26 -1
- package/dist/server/modules/office/office-controller.js.map +1 -1
- package/dist/server/modules/office/onlyoffice-integration-service.d.ts +78 -0
- package/dist/server/modules/office/onlyoffice-integration-service.js +610 -0
- package/dist/server/modules/office/onlyoffice-integration-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-controller.d.ts +131 -0
- package/dist/server/modules/plugins/plugin-controller.js +277 -0
- package/dist/server/modules/plugins/plugin-controller.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +50 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +191 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-manifest.d.ts +8 -0
- package/dist/server/modules/plugins/plugin-manifest.js +420 -0
- package/dist/server/modules/plugins/plugin-manifest.js.map +1 -0
- package/dist/server/modules/plugins/plugin-permission-service.d.ts +49 -0
- package/dist/server/modules/plugins/plugin-permission-service.js +267 -0
- package/dist/server/modules/plugins/plugin-permission-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-process-runner.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-process-runner.js +127 -0
- package/dist/server/modules/plugins/plugin-process-runner.js.map +1 -0
- package/dist/server/modules/plugins/plugin-registry-service.d.ts +41 -0
- package/dist/server/modules/plugins/plugin-registry-service.js +238 -0
- package/dist/server/modules/plugins/plugin-registry-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-service.d.ts +55 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js +252 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js +83 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.d.ts +31 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js +232 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-static-service.d.ts +11 -0
- package/dist/server/modules/plugins/plugin-static-service.js +145 -0
- package/dist/server/modules/plugins/plugin-static-service.js.map +1 -0
- package/dist/server/modules/preferences/profile-service.d.ts +1 -0
- package/dist/server/modules/preferences/profile-service.js +27 -3
- package/dist/server/modules/preferences/profile-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-controller.d.ts +3 -0
- package/dist/server/modules/presentation/presentation-controller.js +11 -0
- package/dist/server/modules/presentation/presentation-controller.js.map +1 -1
- package/dist/server/modules/presentation/presentation-export-task-service.d.ts +6 -0
- package/dist/server/modules/presentation/presentation-export-task-service.js +52 -8
- package/dist/server/modules/presentation/presentation-export-task-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-pptx-export-service.js +200 -14
- package/dist/server/modules/presentation/presentation-pptx-export-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-renderer.d.ts +50 -0
- package/dist/server/modules/presentation/presentation-renderer.js +450 -37
- package/dist/server/modules/presentation/presentation-renderer.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +0 -8
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/session-controller.d.ts +1 -0
- package/dist/server/modules/sessions/session-controller.js +3 -0
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +2 -0
- package/dist/server/modules/sessions/session-history-service.js +78 -3
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +1 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +4 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-permission-request-service.js +0 -4
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/sessions/workspace-session-instruction-watch-service.d.ts +23 -0
- package/dist/server/modules/sessions/workspace-session-instruction-watch-service.js +122 -0
- package/dist/server/modules/sessions/workspace-session-instruction-watch-service.js.map +1 -0
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.d.ts +15 -0
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +93 -10
- package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/SKILL.md +6 -7
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/references/cli-workflow.md +2 -3
- package/dist/server/modules/system/host-resource-controller.d.ts +7 -0
- package/dist/server/modules/system/host-resource-controller.js +12 -0
- package/dist/server/modules/system/host-resource-controller.js.map +1 -0
- package/dist/server/modules/system/host-resource-service.d.ts +54 -0
- package/dist/server/modules/system/host-resource-service.js +162 -0
- package/dist/server/modules/system/host-resource-service.js.map +1 -0
- package/dist/server/modules/tasks/observability-service.d.ts +12 -2
- package/dist/server/modules/tasks/observability-service.js +13 -1
- package/dist/server/modules/tasks/observability-service.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-client.d.ts +36 -2
- package/dist/server/modules/tasks/task-helper-client.js +201 -19
- package/dist/server/modules/tasks/task-helper-client.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-pool.d.ts +37 -0
- package/dist/server/modules/tasks/task-helper-pool.js +173 -0
- package/dist/server/modules/tasks/task-helper-pool.js.map +1 -0
- package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +27 -0
- package/dist/server/modules/tasks/task-helper-process-handlers.js +25 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process.js +75 -26
- package/dist/server/modules/tasks/task-helper-process.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-scheduling.d.ts +11 -0
- package/dist/server/modules/tasks/task-helper-scheduling.js +43 -0
- package/dist/server/modules/tasks/task-helper-scheduling.js.map +1 -0
- package/dist/server/modules/tasks/task-lane-executors.js +19 -3
- package/dist/server/modules/tasks/task-lane-executors.js.map +1 -1
- package/dist/server/modules/tasks/task-manager.d.ts +1 -0
- package/dist/server/modules/tasks/task-manager.js +3 -0
- package/dist/server/modules/tasks/task-manager.js.map +1 -1
- package/dist/server/modules/tasks/task-registry.d.ts +1 -0
- package/dist/server/modules/tasks/task-registry.js +3 -0
- package/dist/server/modules/tasks/task-registry.js.map +1 -1
- package/dist/server/modules/tasks/task-scheduler.d.ts +6 -0
- package/dist/server/modules/tasks/task-scheduler.js +162 -7
- package/dist/server/modules/tasks/task-scheduler.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +30 -3
- package/dist/server/modules/tasks/task-types.js +16 -2
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.d.ts +68 -0
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js +286 -0
- package/dist/server/modules/workbench/affairs-assistant-session-snapshot-service.js.map +1 -0
- package/dist/server/modules/workbench/workbench-controller.js +11 -1
- package/dist/server/modules/workbench/workbench-controller.js.map +1 -1
- package/dist/server/modules/workbench/workbench-service.d.ts +9 -2
- package/dist/server/modules/workbench/workbench-service.js +58 -18
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workspace/affairs-library-controller.d.ts +117 -0
- package/dist/server/modules/workspace/affairs-library-controller.js +164 -0
- package/dist/server/modules/workspace/affairs-library-controller.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-debug-log.d.ts +23 -0
- package/dist/server/modules/workspace/affairs-library-debug-log.js +107 -0
- package/dist/server/modules/workspace/affairs-library-debug-log.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-dirty-watch-service.d.ts +52 -0
- package/dist/server/modules/workspace/affairs-library-dirty-watch-service.js +555 -0
- package/dist/server/modules/workspace/affairs-library-dirty-watch-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.d.ts +24 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.js +157 -0
- package/dist/server/modules/workspace/affairs-library-preview-link-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-refresh-contract.d.ts +56 -0
- package/dist/server/modules/workspace/affairs-library-refresh-contract.js +48 -0
- package/dist/server/modules/workspace/affairs-library-refresh-contract.js.map +1 -0
- package/dist/server/modules/workspace/affairs-library-service.d.ts +344 -0
- package/dist/server/modules/workspace/affairs-library-service.js +3755 -0
- package/dist/server/modules/workspace/affairs-library-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.d.ts +78 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.js +146 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-controller.js.map +1 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.d.ts +133 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js +1447 -0
- package/dist/server/modules/workspace/affairs-lightweight-session-service.js.map +1 -0
- package/dist/server/modules/workspace/affairs-tag-controller.d.ts +107 -0
- package/dist/server/modules/workspace/affairs-tag-controller.js +97 -0
- package/dist/server/modules/workspace/affairs-tag-controller.js.map +1 -0
- package/dist/server/modules/workspace/affairs-tag-service.d.ts +153 -0
- package/dist/server/modules/workspace/affairs-tag-service.js +680 -0
- package/dist/server/modules/workspace/affairs-tag-service.js.map +1 -0
- package/dist/server/modules/workspace/workspace-controller.d.ts +2 -1
- package/dist/server/modules/workspace/workspace-controller.js +8 -2
- package/dist/server/modules/workspace/workspace-controller.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.js +60 -9
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/routes/affairs.d.ts +3 -0
- package/dist/server/routes/affairs.js +7 -0
- package/dist/server/routes/affairs.js.map +1 -0
- package/dist/server/routes/assistant.js +0 -5
- package/dist/server/routes/assistant.js.map +1 -1
- package/dist/server/routes/files.js +45 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/office.js +4 -0
- package/dist/server/routes/office.js.map +1 -1
- package/dist/server/routes/plugins-public.d.ts +3 -0
- package/dist/server/routes/plugins-public.js +5 -0
- package/dist/server/routes/plugins-public.js.map +1 -0
- package/dist/server/routes/plugins.d.ts +3 -0
- package/dist/server/routes/plugins.js +19 -0
- package/dist/server/routes/plugins.js.map +1 -0
- package/dist/server/routes/presentation.js +1 -0
- package/dist/server/routes/presentation.js.map +1 -1
- package/dist/server/routes/system.d.ts +2 -1
- package/dist/server/routes/system.js +2 -1
- package/dist/server/routes/system.js.map +1 -1
- package/dist/server/routes/workspaces.d.ts +4 -1
- package/dist/server/routes/workspaces.js +46 -1
- package/dist/server/routes/workspaces.js.map +1 -1
- package/dist/server/server/create-server.d.ts +26 -2
- package/dist/server/server/create-server.js +159 -32
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +20 -6
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/shared/runtime/better-sqlite3.d.ts +5 -0
- package/dist/server/shared/runtime/better-sqlite3.js +6 -0
- package/dist/server/shared/runtime/better-sqlite3.js.map +1 -0
- package/dist/server/storage/repositories/affairs-assistant-session-snapshot-repository.d.ts +10 -0
- package/dist/server/storage/repositories/affairs-assistant-session-snapshot-repository.js +47 -0
- package/dist/server/storage/repositories/affairs-assistant-session-snapshot-repository.js.map +1 -0
- package/dist/server/storage/repositories/butler-profile-repository.js +7 -3
- package/dist/server/storage/repositories/butler-profile-repository.js.map +1 -1
- package/dist/server/storage/repositories/office-onlyoffice-setting-repository.d.ts +19 -0
- package/dist/server/storage/repositories/office-onlyoffice-setting-repository.js +55 -0
- package/dist/server/storage/repositories/office-onlyoffice-setting-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.d.ts +8 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js +49 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-definition-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js +84 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.d.ts +9 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js +74 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.d.ts +12 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js +142 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-run-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-run-repository.js +111 -0
- package/dist/server/storage/repositories/plugin-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js +86 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-index-repository.js +9 -2
- package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.d.ts +10 -0
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.js +69 -0
- package/dist/server/storage/repositories/user-affairs-library-setting-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-preference-profile-repository.js +6 -3
- package/dist/server/storage/repositories/user-preference-profile-repository.js.map +1 -1
- package/dist/server/storage/repositories/workspace-navigation-state-repository.d.ts +3 -0
- package/dist/server/storage/repositories/workspace-navigation-state-repository.js +47 -4
- package/dist/server/storage/repositories/workspace-navigation-state-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.d.ts +2 -2
- package/dist/server/storage/sqlite/client.js +480 -124
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +188 -25
- package/dist/server/types/domain.d.ts +149 -20
- package/dist/server/ws/workbench-ws-hub.js +2 -2
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +0 -2
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +0 -6
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/package.json +10 -3
- package/scripts/postinstall.mjs +248 -11
- package/vendor/better-sqlite3-win32-x64-node22/LICENSE +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.upstream.md +99 -0
- package/vendor/better-sqlite3-win32-x64-node22/binding.gyp +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/build/Release/better_sqlite3.node +0 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/common.gypi +68 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/copy.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/defines.gypi +41 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/download.sh +122 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/patches/1208.patch +15 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.c +265994 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.h +13968 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3ext.h +730 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3.gyp +80 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/test_extension.c +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/database.js +90 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/index.js +3 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/aggregate.js +43 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/backup.js +67 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/function.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/inspect.js +7 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/pragma.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/serialize.js +16 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/table.js +189 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/transaction.js +78 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/wrappers.js +54 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/sqlite-error.js +20 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/util.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/package.json +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/scripts/verify-runtime.cjs +42 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/addon.cpp +47 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/better_sqlite3.cpp +74 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.cpp +120 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.hpp +36 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.cpp +417 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.hpp +103 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.cpp +113 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.hpp +50 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.cpp +383 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.hpp +58 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/bind-map.cpp +73 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/binder.cpp +193 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/constants.cpp +172 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-aggregate.cpp +121 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-function.cpp +59 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-table.cpp +409 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data-converter.cpp +17 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data.cpp +194 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/helpers.cpp +109 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/macros.cpp +83 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/query-macros.cpp +71 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/row-builder.cpp +49 -0
- package/vendor/node-pty-fork/README.md +1 -0
- package/vendor/node-pty-fork/scripts/runtime-install-context.cjs +24 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.cjs +8 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +30 -0
- package/vendor-src/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/dist/public/assets/AdaptiveButlerPage-B153lk5H.css +0 -1
- package/dist/public/assets/AdaptiveButlerPage-b7s6F_sd.js +0 -3
- package/dist/public/assets/App-B0q8uDA-.js +0 -30
- package/dist/public/assets/DesktopWindowPage-BdKUZrKG.js +0 -2
- package/dist/public/assets/FileContextPanel-lM5mBcfn.js +0 -1
- package/dist/public/assets/GitSidebar-CmXAhyjo.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-CceV0-AH.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DhaM9fgx.js +0 -1
- package/dist/public/assets/ServerSettingsModal-Rkgn3jft.js +0 -1
- package/dist/public/assets/SessionIndexPage-BOumP3ij.js +0 -1
- package/dist/public/assets/SettingsPage-vx_c-00-.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-D9JHCS6d.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-W5NjqFEz.js +0 -1
- package/dist/public/assets/ToolFilesPage-DWtpaN_7.js +0 -1
- package/dist/public/assets/ToolGitPage-MpGXsw4_.js +0 -1
- package/dist/public/assets/ToolProcessesPage-B1jHQKhZ.js +0 -1
- package/dist/public/assets/ToolsHomePage-CJrn8ZFl.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CJQ1V5U-.js +0 -1
- package/dist/public/assets/WorkbenchLayout-D48i71PU.js +0 -244
- package/dist/public/assets/WorkbenchModal-BYNuMIoV.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-B4XB8SwG.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-CGKjy4J-.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-DCAYgays.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D5v-nUIi.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-I5G1p5SR.js +0 -1
- package/dist/public/assets/file-tree-icon-BFwaPxKs.js +0 -590
- package/dist/public/assets/index-CjewzOUG.js +0 -42
- package/dist/public/assets/index-VVxfF0s5.css +0 -1
- package/dist/public/assets/model-switch-api-Br0ivfe5.js +0 -1
- package/dist/public/assets/realtime-client-BlQRqVmm.js +0 -1
- package/dist/public/assets/useRegisteredDebugTemplates-CXmxu69X.js +0 -1
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.d.ts +0 -32
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js +0 -93
- package/dist/server/modules/butler/assistant-sandbox-cleanup-scheduler.js.map +0 -1
- package/dist/server/modules/butler/assistant-sandbox-service.d.ts +0 -69
- package/dist/server/modules/butler/assistant-sandbox-service.js +0 -399
- package/dist/server/modules/butler/assistant-sandbox-service.js.map +0 -1
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.d.ts +0 -18
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js +0 -191
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js.map +0 -1
|
@@ -0,0 +1,1471 @@
|
|
|
1
|
+
import { openDatabase, } from "../sqlite/open-database.js";
|
|
2
|
+
function compareTagPostingRows(left, right) {
|
|
3
|
+
return left.rootType.localeCompare(right.rootType, "zh-Hans-CN")
|
|
4
|
+
|| left.tagPath.localeCompare(right.tagPath, "zh-Hans-CN")
|
|
5
|
+
|| left.path.localeCompare(right.path, "zh-Hans-CN")
|
|
6
|
+
|| left.documentId.localeCompare(right.documentId, "zh-Hans-CN")
|
|
7
|
+
|| Number(left.derived) - Number(right.derived);
|
|
8
|
+
}
|
|
9
|
+
function attachTags(documentRows, directTagRows, derivedTagRows) {
|
|
10
|
+
const directTagsByDocument = new Map();
|
|
11
|
+
for (const row of directTagRows) {
|
|
12
|
+
const current = directTagsByDocument.get(row.document_id) ?? [];
|
|
13
|
+
current.push(row.tag_path);
|
|
14
|
+
directTagsByDocument.set(row.document_id, current);
|
|
15
|
+
}
|
|
16
|
+
const derivedTagsByDocument = new Map();
|
|
17
|
+
for (const row of derivedTagRows) {
|
|
18
|
+
const current = derivedTagsByDocument.get(row.document_id) ?? [];
|
|
19
|
+
current.push(row.tag_path);
|
|
20
|
+
derivedTagsByDocument.set(row.document_id, current);
|
|
21
|
+
}
|
|
22
|
+
return documentRows.map(row => {
|
|
23
|
+
const documentId = String(row.document_id);
|
|
24
|
+
return {
|
|
25
|
+
documentId,
|
|
26
|
+
path: String(row.path),
|
|
27
|
+
title: String(row.title),
|
|
28
|
+
summary: String(row.summary ?? ""),
|
|
29
|
+
tags: directTagsByDocument.get(documentId) ?? [],
|
|
30
|
+
derivedTags: derivedTagsByDocument.get(documentId) ?? [],
|
|
31
|
+
mtime: String(row.mtime),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function mapDocumentRows(rows) {
|
|
36
|
+
return rows.map(row => ({
|
|
37
|
+
documentId: String(row.document_id),
|
|
38
|
+
path: String(row.path),
|
|
39
|
+
title: String(row.title),
|
|
40
|
+
summary: String(row.summary ?? ""),
|
|
41
|
+
mtime: String(row.mtime),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function fetchDocumentTagsForIds(db, documentIds) {
|
|
45
|
+
if (documentIds.length === 0) {
|
|
46
|
+
return {
|
|
47
|
+
directTagRows: [],
|
|
48
|
+
derivedTagRows: [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const placeholders = documentIds.map(() => "?").join(", ");
|
|
52
|
+
const directTagRows = db.prepare(`
|
|
53
|
+
SELECT dt.document_id, t.path AS tag_path
|
|
54
|
+
FROM document_tags dt
|
|
55
|
+
JOIN tags t ON t.id = dt.tag_id
|
|
56
|
+
WHERE dt.document_id IN (${placeholders})
|
|
57
|
+
ORDER BY dt.document_id, t.path
|
|
58
|
+
`).all(...documentIds);
|
|
59
|
+
const derivedTagRows = db.prepare(`
|
|
60
|
+
SELECT ddt.document_id, t.path AS tag_path
|
|
61
|
+
FROM derived_document_tags ddt
|
|
62
|
+
JOIN tags t ON t.id = ddt.tag_id
|
|
63
|
+
WHERE ddt.document_id IN (${placeholders})
|
|
64
|
+
ORDER BY ddt.document_id, t.path
|
|
65
|
+
`).all(...documentIds);
|
|
66
|
+
return {
|
|
67
|
+
directTagRows,
|
|
68
|
+
derivedTagRows,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 最小 SQLite 查询仓库。
|
|
73
|
+
* 第二阶段继续承接只读查询,并补最小增量导出所需查询。
|
|
74
|
+
*/
|
|
75
|
+
export class CatalogRepository {
|
|
76
|
+
dbPath;
|
|
77
|
+
dbOptions;
|
|
78
|
+
constructor(dbPath, dbOptions = {}) {
|
|
79
|
+
this.dbPath = dbPath;
|
|
80
|
+
this.dbOptions = dbOptions;
|
|
81
|
+
}
|
|
82
|
+
listTagDefinitions(includeDisabled = false) {
|
|
83
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
84
|
+
try {
|
|
85
|
+
const rows = db.prepare(`
|
|
86
|
+
SELECT
|
|
87
|
+
id,
|
|
88
|
+
root_type,
|
|
89
|
+
path,
|
|
90
|
+
name,
|
|
91
|
+
parent_id,
|
|
92
|
+
canonical_name,
|
|
93
|
+
description,
|
|
94
|
+
status,
|
|
95
|
+
created_by,
|
|
96
|
+
created_at,
|
|
97
|
+
updated_at,
|
|
98
|
+
disabled_at
|
|
99
|
+
FROM tags
|
|
100
|
+
${includeDisabled ? "" : "WHERE status <> 'disabled'"}
|
|
101
|
+
ORDER BY path
|
|
102
|
+
`).all();
|
|
103
|
+
return rows.map(row => ({
|
|
104
|
+
id: String(row.id),
|
|
105
|
+
rootType: String(row.root_type),
|
|
106
|
+
path: String(row.path),
|
|
107
|
+
name: String(row.name),
|
|
108
|
+
parentId: row.parent_id ? String(row.parent_id) : null,
|
|
109
|
+
canonicalName: String(row.canonical_name),
|
|
110
|
+
description: typeof row.description === "string" ? row.description : null,
|
|
111
|
+
status: String(row.status),
|
|
112
|
+
createdBy: String(row.created_by),
|
|
113
|
+
createdAt: String(row.created_at),
|
|
114
|
+
updatedAt: String(row.updated_at ?? row.created_at),
|
|
115
|
+
disabledAt: typeof row.disabled_at === "string" ? row.disabled_at : null,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
db.close();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
getTagDefinitionById(tagId) {
|
|
123
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
124
|
+
try {
|
|
125
|
+
const row = db.prepare(`
|
|
126
|
+
SELECT
|
|
127
|
+
id,
|
|
128
|
+
root_type,
|
|
129
|
+
path,
|
|
130
|
+
name,
|
|
131
|
+
parent_id,
|
|
132
|
+
canonical_name,
|
|
133
|
+
description,
|
|
134
|
+
status,
|
|
135
|
+
created_by,
|
|
136
|
+
created_at,
|
|
137
|
+
updated_at,
|
|
138
|
+
disabled_at
|
|
139
|
+
FROM tags
|
|
140
|
+
WHERE id = ?
|
|
141
|
+
`).get(tagId);
|
|
142
|
+
if (!row) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
id: String(row.id),
|
|
147
|
+
rootType: String(row.root_type),
|
|
148
|
+
path: String(row.path),
|
|
149
|
+
name: String(row.name),
|
|
150
|
+
parentId: row.parent_id ? String(row.parent_id) : null,
|
|
151
|
+
canonicalName: String(row.canonical_name),
|
|
152
|
+
description: typeof row.description === "string" ? row.description : null,
|
|
153
|
+
status: String(row.status),
|
|
154
|
+
createdBy: String(row.created_by),
|
|
155
|
+
createdAt: String(row.created_at),
|
|
156
|
+
updatedAt: String(row.updated_at ?? row.created_at),
|
|
157
|
+
disabledAt: typeof row.disabled_at === "string" ? row.disabled_at : null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
db.close();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
listTagRulesByTagIds(tagIds) {
|
|
165
|
+
const normalizedIds = [...new Set(tagIds.map(item => item.trim()).filter(Boolean))];
|
|
166
|
+
if (normalizedIds.length === 0) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
170
|
+
try {
|
|
171
|
+
const placeholders = normalizedIds.map(() => "?").join(", ");
|
|
172
|
+
const rows = db.prepare(`
|
|
173
|
+
SELECT
|
|
174
|
+
r.id,
|
|
175
|
+
r.tag_id,
|
|
176
|
+
t.path AS tag_path,
|
|
177
|
+
r.enabled,
|
|
178
|
+
r.rule_type,
|
|
179
|
+
r.scope_json,
|
|
180
|
+
r.matcher_json,
|
|
181
|
+
r.min_score,
|
|
182
|
+
r.priority,
|
|
183
|
+
r.source,
|
|
184
|
+
r.created_at,
|
|
185
|
+
r.updated_at
|
|
186
|
+
FROM tag_rules r
|
|
187
|
+
JOIN tags t ON t.id = r.tag_id
|
|
188
|
+
WHERE r.tag_id IN (${placeholders})
|
|
189
|
+
ORDER BY t.path, r.priority, r.created_at
|
|
190
|
+
`).all(...normalizedIds);
|
|
191
|
+
return rows.map(mapTagRuleRow);
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
db.close();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
listAllEnabledTagRules() {
|
|
198
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
199
|
+
try {
|
|
200
|
+
const rows = db.prepare(`
|
|
201
|
+
SELECT
|
|
202
|
+
r.id,
|
|
203
|
+
r.tag_id,
|
|
204
|
+
t.path AS tag_path,
|
|
205
|
+
r.enabled,
|
|
206
|
+
r.rule_type,
|
|
207
|
+
r.scope_json,
|
|
208
|
+
r.matcher_json,
|
|
209
|
+
r.min_score,
|
|
210
|
+
r.priority,
|
|
211
|
+
r.source,
|
|
212
|
+
r.created_at,
|
|
213
|
+
r.updated_at
|
|
214
|
+
FROM tag_rules r
|
|
215
|
+
JOIN tags t ON t.id = r.tag_id
|
|
216
|
+
WHERE r.enabled = 1
|
|
217
|
+
AND t.status = 'active'
|
|
218
|
+
ORDER BY t.path, r.priority, r.created_at
|
|
219
|
+
`).all();
|
|
220
|
+
return rows.map(mapTagRuleRow);
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
db.close();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
listManualDocumentTagBindingsByDocumentIds(documentIds) {
|
|
227
|
+
const normalizedIds = [...new Set(documentIds.map(item => item.trim()).filter(Boolean))];
|
|
228
|
+
if (normalizedIds.length === 0) {
|
|
229
|
+
return [];
|
|
230
|
+
}
|
|
231
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
232
|
+
try {
|
|
233
|
+
const placeholders = normalizedIds.map(() => "?").join(", ");
|
|
234
|
+
const documentRows = db.prepare(`
|
|
235
|
+
SELECT
|
|
236
|
+
d.id AS document_id,
|
|
237
|
+
f.path,
|
|
238
|
+
f.inode_key,
|
|
239
|
+
f.content_hash,
|
|
240
|
+
f.size,
|
|
241
|
+
f.extension
|
|
242
|
+
FROM documents d
|
|
243
|
+
JOIN files f ON f.id = d.file_id
|
|
244
|
+
WHERE d.id IN (${placeholders})
|
|
245
|
+
AND f.status = 'active'
|
|
246
|
+
AND d.index_status = 'indexed'
|
|
247
|
+
`).all(...normalizedIds);
|
|
248
|
+
const currentDocuments = documentRows.map((row) => ({
|
|
249
|
+
documentId: String(row.document_id),
|
|
250
|
+
path: String(row.path),
|
|
251
|
+
inodeKey: typeof row.inode_key === "string" && row.inode_key.trim() ? String(row.inode_key) : null,
|
|
252
|
+
contentHash: typeof row.content_hash === "string" && row.content_hash.trim() ? String(row.content_hash) : null,
|
|
253
|
+
size: Number(row.size ?? 0),
|
|
254
|
+
extension: String(row.extension ?? ""),
|
|
255
|
+
}));
|
|
256
|
+
const resolvedRows = this.resolveManualFileTagBindingsForDocuments(db, currentDocuments);
|
|
257
|
+
const legacyRows = db.prepare(`
|
|
258
|
+
SELECT
|
|
259
|
+
b.id,
|
|
260
|
+
b.document_id,
|
|
261
|
+
b.tag_id,
|
|
262
|
+
t.path AS tag_path,
|
|
263
|
+
b.source,
|
|
264
|
+
b.created_at,
|
|
265
|
+
b.updated_at
|
|
266
|
+
FROM manual_document_tag_bindings b
|
|
267
|
+
JOIN tags t ON t.id = b.tag_id
|
|
268
|
+
WHERE b.document_id IN (${placeholders})
|
|
269
|
+
AND t.status = 'active'
|
|
270
|
+
ORDER BY b.document_id, t.path
|
|
271
|
+
`).all(...normalizedIds);
|
|
272
|
+
const identityRowsByDocument = new Map();
|
|
273
|
+
resolvedRows.forEach((row) => {
|
|
274
|
+
const current = identityRowsByDocument.get(row.documentId) ?? [];
|
|
275
|
+
current.push(row);
|
|
276
|
+
identityRowsByDocument.set(row.documentId, current);
|
|
277
|
+
});
|
|
278
|
+
const legacyRowsByDocument = new Map();
|
|
279
|
+
legacyRows.forEach((row) => {
|
|
280
|
+
const mapped = {
|
|
281
|
+
id: String(row.id),
|
|
282
|
+
documentId: String(row.document_id),
|
|
283
|
+
tagId: String(row.tag_id),
|
|
284
|
+
tagPath: String(row.tag_path),
|
|
285
|
+
source: String(row.source),
|
|
286
|
+
createdAt: String(row.created_at),
|
|
287
|
+
updatedAt: String(row.updated_at),
|
|
288
|
+
};
|
|
289
|
+
const current = legacyRowsByDocument.get(mapped.documentId) ?? [];
|
|
290
|
+
current.push(mapped);
|
|
291
|
+
legacyRowsByDocument.set(mapped.documentId, current);
|
|
292
|
+
});
|
|
293
|
+
return normalizedIds
|
|
294
|
+
.flatMap((documentId) => {
|
|
295
|
+
const identityRows = identityRowsByDocument.get(documentId);
|
|
296
|
+
if (identityRows && identityRows.length > 0) {
|
|
297
|
+
return identityRows;
|
|
298
|
+
}
|
|
299
|
+
return legacyRowsByDocument.get(documentId) ?? [];
|
|
300
|
+
})
|
|
301
|
+
.sort((left, right) => left.documentId.localeCompare(right.documentId, "zh-Hans-CN")
|
|
302
|
+
|| left.tagPath.localeCompare(right.tagPath, "zh-Hans-CN"));
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
db.close();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
getManualTagBindingStats() {
|
|
309
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
310
|
+
try {
|
|
311
|
+
const row = db.prepare(`
|
|
312
|
+
WITH legacy_active AS (
|
|
313
|
+
SELECT
|
|
314
|
+
mdtb.document_id,
|
|
315
|
+
mdtb.tag_id,
|
|
316
|
+
f.inode_key,
|
|
317
|
+
f.content_hash,
|
|
318
|
+
f.size,
|
|
319
|
+
f.extension
|
|
320
|
+
FROM manual_document_tag_bindings mdtb
|
|
321
|
+
JOIN documents d ON d.id = mdtb.document_id
|
|
322
|
+
JOIN files f ON f.id = d.file_id
|
|
323
|
+
WHERE f.status = 'active'
|
|
324
|
+
AND d.index_status IN ('indexed', 'failed', 'skipped')
|
|
325
|
+
),
|
|
326
|
+
legacy_only AS (
|
|
327
|
+
SELECT la.document_id, la.tag_id
|
|
328
|
+
FROM legacy_active la
|
|
329
|
+
WHERE NOT EXISTS (
|
|
330
|
+
SELECT 1
|
|
331
|
+
FROM manual_file_tag_bindings mftb
|
|
332
|
+
WHERE mftb.tag_id = la.tag_id
|
|
333
|
+
AND (
|
|
334
|
+
(la.inode_key IS NOT NULL AND mftb.inode_key = la.inode_key)
|
|
335
|
+
OR (
|
|
336
|
+
la.content_hash IS NOT NULL
|
|
337
|
+
AND mftb.content_hash = la.content_hash
|
|
338
|
+
AND mftb.file_size = la.size
|
|
339
|
+
AND mftb.extension = la.extension
|
|
340
|
+
)
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
)
|
|
344
|
+
SELECT
|
|
345
|
+
(SELECT COUNT(*) FROM manual_file_tag_bindings) AS identity_binding_count,
|
|
346
|
+
(SELECT COUNT(*) FROM manual_document_tag_bindings) AS legacy_binding_count,
|
|
347
|
+
(SELECT COUNT(*) FROM legacy_only) AS legacy_fallback_binding_count,
|
|
348
|
+
(SELECT COUNT(DISTINCT document_id) FROM legacy_only) AS legacy_fallback_document_count
|
|
349
|
+
`).get();
|
|
350
|
+
return {
|
|
351
|
+
identityBindingCount: Number(row?.identity_binding_count ?? 0),
|
|
352
|
+
legacyBindingCount: Number(row?.legacy_binding_count ?? 0),
|
|
353
|
+
legacyFallbackBindingCount: Number(row?.legacy_fallback_binding_count ?? 0),
|
|
354
|
+
legacyFallbackDocumentCount: Number(row?.legacy_fallback_document_count ?? 0),
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
finally {
|
|
358
|
+
db.close();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
resolveManualFileTagBindingsForDocuments(db, documents) {
|
|
362
|
+
if (documents.length === 0) {
|
|
363
|
+
return [];
|
|
364
|
+
}
|
|
365
|
+
const inodeKeys = [...new Set(documents.map((item) => item.inodeKey).filter((item) => Boolean(item)))];
|
|
366
|
+
const contentHashes = [...new Set(documents.map((item) => item.contentHash).filter((item) => Boolean(item)))];
|
|
367
|
+
if (inodeKeys.length === 0 && contentHashes.length === 0) {
|
|
368
|
+
return [];
|
|
369
|
+
}
|
|
370
|
+
const predicateParts = [];
|
|
371
|
+
const predicateParams = [];
|
|
372
|
+
if (inodeKeys.length > 0) {
|
|
373
|
+
predicateParts.push(`b.inode_key IN (${inodeKeys.map(() => "?").join(", ")})`);
|
|
374
|
+
predicateParams.push(...inodeKeys);
|
|
375
|
+
}
|
|
376
|
+
if (contentHashes.length > 0) {
|
|
377
|
+
predicateParts.push(`b.content_hash IN (${contentHashes.map(() => "?").join(", ")})`);
|
|
378
|
+
predicateParams.push(...contentHashes);
|
|
379
|
+
}
|
|
380
|
+
const candidateRows = db.prepare(`
|
|
381
|
+
SELECT
|
|
382
|
+
b.id,
|
|
383
|
+
b.inode_key,
|
|
384
|
+
b.content_hash,
|
|
385
|
+
b.file_size,
|
|
386
|
+
b.extension,
|
|
387
|
+
b.tag_id,
|
|
388
|
+
t.path AS tag_path,
|
|
389
|
+
b.source,
|
|
390
|
+
b.created_at,
|
|
391
|
+
b.updated_at
|
|
392
|
+
FROM manual_file_tag_bindings b
|
|
393
|
+
JOIN tags t ON t.id = b.tag_id
|
|
394
|
+
WHERE t.status = 'active'
|
|
395
|
+
AND (${predicateParts.join(" OR ")})
|
|
396
|
+
ORDER BY t.path, b.updated_at DESC, b.id
|
|
397
|
+
`).all(...predicateParams);
|
|
398
|
+
if (candidateRows.length === 0) {
|
|
399
|
+
return [];
|
|
400
|
+
}
|
|
401
|
+
const candidates = candidateRows.map((row) => ({
|
|
402
|
+
id: String(row.id),
|
|
403
|
+
inodeKey: typeof row.inode_key === "string" && row.inode_key.trim() ? String(row.inode_key) : null,
|
|
404
|
+
contentHash: typeof row.content_hash === "string" && row.content_hash.trim() ? String(row.content_hash) : null,
|
|
405
|
+
fileSize: Number(row.file_size ?? 0),
|
|
406
|
+
extension: String(row.extension ?? ""),
|
|
407
|
+
tagId: String(row.tag_id),
|
|
408
|
+
tagPath: String(row.tag_path),
|
|
409
|
+
source: String(row.source),
|
|
410
|
+
createdAt: String(row.created_at),
|
|
411
|
+
updatedAt: String(row.updated_at),
|
|
412
|
+
}));
|
|
413
|
+
const candidateInodeKeys = [...new Set(candidates.map((item) => item.inodeKey).filter((item) => Boolean(item)))];
|
|
414
|
+
const candidateContentHashes = [...new Set(candidates.map((item) => item.contentHash).filter((item) => Boolean(item)))];
|
|
415
|
+
const activeIdentityRows = this.listActiveDocumentIdentitiesByKeys(db, candidateInodeKeys, candidateContentHashes);
|
|
416
|
+
const activeDocIdsByInode = buildDocumentIdsByInode(activeIdentityRows);
|
|
417
|
+
const activeDocIdsByContent = buildDocumentIdsByContent(activeIdentityRows);
|
|
418
|
+
const resolved = new Map();
|
|
419
|
+
for (const document of documents) {
|
|
420
|
+
const documentContentKey = buildContentIdentityKey(document.contentHash, document.size, document.extension);
|
|
421
|
+
for (const candidate of candidates) {
|
|
422
|
+
const matchedByInode = Boolean(candidate.inodeKey && document.inodeKey && candidate.inodeKey === document.inodeKey);
|
|
423
|
+
const matchedByContent = !matchedByInode && matchesContentFallback(document, candidate, activeDocIdsByInode, activeDocIdsByContent, documentContentKey);
|
|
424
|
+
if (!matchedByInode && !matchedByContent) {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
resolved.set(`${document.documentId}:${candidate.tagId}`, {
|
|
428
|
+
id: candidate.id,
|
|
429
|
+
documentId: document.documentId,
|
|
430
|
+
tagId: candidate.tagId,
|
|
431
|
+
tagPath: candidate.tagPath,
|
|
432
|
+
source: candidate.source,
|
|
433
|
+
createdAt: candidate.createdAt,
|
|
434
|
+
updatedAt: candidate.updatedAt,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return [...resolved.values()];
|
|
439
|
+
}
|
|
440
|
+
listActiveDocumentIdentitiesByKeys(db, inodeKeys, contentHashes) {
|
|
441
|
+
if (inodeKeys.length === 0 && contentHashes.length === 0) {
|
|
442
|
+
return [];
|
|
443
|
+
}
|
|
444
|
+
const predicateParts = [];
|
|
445
|
+
const params = [];
|
|
446
|
+
if (inodeKeys.length > 0) {
|
|
447
|
+
predicateParts.push(`f.inode_key IN (${inodeKeys.map(() => "?").join(", ")})`);
|
|
448
|
+
params.push(...inodeKeys);
|
|
449
|
+
}
|
|
450
|
+
if (contentHashes.length > 0) {
|
|
451
|
+
predicateParts.push(`f.content_hash IN (${contentHashes.map(() => "?").join(", ")})`);
|
|
452
|
+
params.push(...contentHashes);
|
|
453
|
+
}
|
|
454
|
+
const rows = db.prepare(`
|
|
455
|
+
SELECT
|
|
456
|
+
d.id AS document_id,
|
|
457
|
+
f.path,
|
|
458
|
+
f.inode_key,
|
|
459
|
+
f.content_hash,
|
|
460
|
+
f.size,
|
|
461
|
+
f.extension
|
|
462
|
+
FROM documents d
|
|
463
|
+
JOIN files f ON f.id = d.file_id
|
|
464
|
+
WHERE f.status = 'active'
|
|
465
|
+
AND d.index_status = 'indexed'
|
|
466
|
+
AND (${predicateParts.join(" OR ")})
|
|
467
|
+
`).all(...params);
|
|
468
|
+
return rows.map((row) => ({
|
|
469
|
+
documentId: String(row.document_id),
|
|
470
|
+
path: String(row.path),
|
|
471
|
+
inodeKey: typeof row.inode_key === "string" && row.inode_key.trim() ? String(row.inode_key) : null,
|
|
472
|
+
contentHash: typeof row.content_hash === "string" && row.content_hash.trim() ? String(row.content_hash) : null,
|
|
473
|
+
size: Number(row.size ?? 0),
|
|
474
|
+
extension: String(row.extension ?? ""),
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
listFolderTagBindingsByPaths(paths) {
|
|
478
|
+
const normalizedPaths = [...new Set(paths.map(normalizeFolderBindingPath))];
|
|
479
|
+
if (normalizedPaths.length === 0) {
|
|
480
|
+
return [];
|
|
481
|
+
}
|
|
482
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
483
|
+
try {
|
|
484
|
+
const placeholders = normalizedPaths.map(() => "?").join(", ");
|
|
485
|
+
const rows = db.prepare(`
|
|
486
|
+
SELECT
|
|
487
|
+
b.id,
|
|
488
|
+
b.folder_path,
|
|
489
|
+
b.tag_id,
|
|
490
|
+
t.path AS tag_path,
|
|
491
|
+
b.apply_mode,
|
|
492
|
+
b.created_at,
|
|
493
|
+
b.updated_at
|
|
494
|
+
FROM folder_tag_bindings b
|
|
495
|
+
JOIN tags t ON t.id = b.tag_id
|
|
496
|
+
WHERE b.folder_path IN (${placeholders})
|
|
497
|
+
ORDER BY b.folder_path, t.path
|
|
498
|
+
`).all(...normalizedPaths);
|
|
499
|
+
return rows.map(row => ({
|
|
500
|
+
id: String(row.id),
|
|
501
|
+
folderPath: String(row.folder_path),
|
|
502
|
+
tagId: String(row.tag_id),
|
|
503
|
+
tagPath: String(row.tag_path),
|
|
504
|
+
applyMode: String(row.apply_mode),
|
|
505
|
+
createdAt: String(row.created_at),
|
|
506
|
+
updatedAt: String(row.updated_at),
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
finally {
|
|
510
|
+
db.close();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
listEffectiveFolderTagBindingsForDocumentPaths(paths) {
|
|
514
|
+
const normalizedPaths = [...new Set(paths.map(item => item.trim().replace(/^\.\/+/, "")).filter(Boolean))];
|
|
515
|
+
if (normalizedPaths.length === 0) {
|
|
516
|
+
return [];
|
|
517
|
+
}
|
|
518
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
519
|
+
try {
|
|
520
|
+
const valuePlaceholders = normalizedPaths.map(() => "(?)").join(", ");
|
|
521
|
+
const rows = db.prepare(`
|
|
522
|
+
WITH target_paths(path) AS (
|
|
523
|
+
VALUES ${valuePlaceholders}
|
|
524
|
+
)
|
|
525
|
+
SELECT
|
|
526
|
+
b.id,
|
|
527
|
+
b.folder_path,
|
|
528
|
+
b.tag_id,
|
|
529
|
+
t.path AS tag_path,
|
|
530
|
+
b.apply_mode,
|
|
531
|
+
b.created_at,
|
|
532
|
+
b.updated_at,
|
|
533
|
+
f.path AS document_path,
|
|
534
|
+
d.id AS document_id
|
|
535
|
+
FROM target_paths p
|
|
536
|
+
JOIN files f ON f.path = p.path
|
|
537
|
+
JOIN documents d ON d.file_id = f.id
|
|
538
|
+
JOIN folder_tag_bindings b ON (
|
|
539
|
+
b.folder_path = '.'
|
|
540
|
+
OR f.path = b.folder_path
|
|
541
|
+
OR f.path LIKE b.folder_path || '/%'
|
|
542
|
+
)
|
|
543
|
+
JOIN tags t ON t.id = b.tag_id
|
|
544
|
+
WHERE f.status = 'active'
|
|
545
|
+
AND d.index_status = 'indexed'
|
|
546
|
+
ORDER BY f.path, b.folder_path, t.path
|
|
547
|
+
`).all(...normalizedPaths);
|
|
548
|
+
return rows.map(row => ({
|
|
549
|
+
id: String(row.id),
|
|
550
|
+
folderPath: String(row.folder_path),
|
|
551
|
+
tagId: String(row.tag_id),
|
|
552
|
+
tagPath: String(row.tag_path),
|
|
553
|
+
applyMode: String(row.apply_mode),
|
|
554
|
+
createdAt: String(row.created_at),
|
|
555
|
+
updatedAt: String(row.updated_at),
|
|
556
|
+
documentPath: String(row.document_path),
|
|
557
|
+
documentId: String(row.document_id),
|
|
558
|
+
}));
|
|
559
|
+
}
|
|
560
|
+
finally {
|
|
561
|
+
db.close();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
listEffectiveFolderTagBindingsForFolderScope(folderPath) {
|
|
565
|
+
const normalizedFolderPath = normalizeScopedFolderPath(folderPath);
|
|
566
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
567
|
+
try {
|
|
568
|
+
const whereClause = normalizedFolderPath === "."
|
|
569
|
+
? ""
|
|
570
|
+
: "AND (f.path = ? OR f.path LIKE ?)";
|
|
571
|
+
const params = normalizedFolderPath === "."
|
|
572
|
+
? []
|
|
573
|
+
: [normalizedFolderPath, `${normalizedFolderPath}/%`];
|
|
574
|
+
const rows = db.prepare(`
|
|
575
|
+
SELECT
|
|
576
|
+
b.id,
|
|
577
|
+
b.folder_path,
|
|
578
|
+
b.tag_id,
|
|
579
|
+
t.path AS tag_path,
|
|
580
|
+
b.apply_mode,
|
|
581
|
+
b.created_at,
|
|
582
|
+
b.updated_at,
|
|
583
|
+
f.path AS document_path,
|
|
584
|
+
d.id AS document_id
|
|
585
|
+
FROM files f
|
|
586
|
+
JOIN documents d ON d.file_id = f.id
|
|
587
|
+
JOIN folder_tag_bindings b ON (
|
|
588
|
+
b.folder_path = '.'
|
|
589
|
+
OR f.path = b.folder_path
|
|
590
|
+
OR f.path LIKE b.folder_path || '/%'
|
|
591
|
+
)
|
|
592
|
+
JOIN tags t ON t.id = b.tag_id
|
|
593
|
+
WHERE f.status = 'active'
|
|
594
|
+
AND d.index_status = 'indexed'
|
|
595
|
+
${whereClause}
|
|
596
|
+
ORDER BY f.path, b.folder_path, t.path
|
|
597
|
+
`).all(...params);
|
|
598
|
+
return rows.map(row => ({
|
|
599
|
+
id: String(row.id),
|
|
600
|
+
folderPath: String(row.folder_path),
|
|
601
|
+
tagId: String(row.tag_id),
|
|
602
|
+
tagPath: String(row.tag_path),
|
|
603
|
+
applyMode: String(row.apply_mode),
|
|
604
|
+
createdAt: String(row.created_at),
|
|
605
|
+
updatedAt: String(row.updated_at),
|
|
606
|
+
documentPath: String(row.document_path),
|
|
607
|
+
documentId: String(row.document_id),
|
|
608
|
+
}));
|
|
609
|
+
}
|
|
610
|
+
finally {
|
|
611
|
+
db.close();
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
listResolvedDocumentTagsByDocumentIds(documentIds) {
|
|
615
|
+
const normalizedIds = [...new Set(documentIds.map(item => item.trim()).filter(Boolean))];
|
|
616
|
+
if (normalizedIds.length === 0) {
|
|
617
|
+
return [];
|
|
618
|
+
}
|
|
619
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
620
|
+
try {
|
|
621
|
+
const placeholders = normalizedIds.map(() => "?").join(", ");
|
|
622
|
+
const directRows = db.prepare(`
|
|
623
|
+
SELECT
|
|
624
|
+
dt.document_id,
|
|
625
|
+
t.path,
|
|
626
|
+
dt.tag_id,
|
|
627
|
+
dt.source AS source_type,
|
|
628
|
+
dt.source_ref,
|
|
629
|
+
dt.evidence,
|
|
630
|
+
dt.confidence,
|
|
631
|
+
dt.updated_at
|
|
632
|
+
FROM document_tags dt
|
|
633
|
+
JOIN tags t ON t.id = dt.tag_id
|
|
634
|
+
WHERE dt.document_id IN (${placeholders})
|
|
635
|
+
`).all(...normalizedIds);
|
|
636
|
+
const derivedRows = db.prepare(`
|
|
637
|
+
SELECT
|
|
638
|
+
ddt.document_id,
|
|
639
|
+
t.path,
|
|
640
|
+
ddt.tag_id,
|
|
641
|
+
ddt.source AS source_type,
|
|
642
|
+
ddt.source_ref,
|
|
643
|
+
ddt.evidence,
|
|
644
|
+
1 AS confidence,
|
|
645
|
+
ddt.updated_at
|
|
646
|
+
FROM derived_document_tags ddt
|
|
647
|
+
JOIN tags t ON t.id = ddt.tag_id
|
|
648
|
+
WHERE ddt.document_id IN (${placeholders})
|
|
649
|
+
`).all(...normalizedIds);
|
|
650
|
+
return [...directRows, ...derivedRows]
|
|
651
|
+
.map(row => ({
|
|
652
|
+
documentId: String(row.document_id),
|
|
653
|
+
path: String(row.path),
|
|
654
|
+
tagId: String(row.tag_id),
|
|
655
|
+
sourceType: String(row.source_type),
|
|
656
|
+
sourceRef: typeof row.source_ref === "string" ? row.source_ref : null,
|
|
657
|
+
evidence: typeof row.evidence === "string" ? row.evidence : null,
|
|
658
|
+
confidence: Number(row.confidence ?? 0),
|
|
659
|
+
updatedAt: String(row.updated_at),
|
|
660
|
+
}))
|
|
661
|
+
.sort((left, right) => left.path.localeCompare(right.path, "zh-Hans-CN"));
|
|
662
|
+
}
|
|
663
|
+
finally {
|
|
664
|
+
db.close();
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
listRecomputeCandidateDocuments(scope) {
|
|
668
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
669
|
+
try {
|
|
670
|
+
if (scope.kind === "document" && scope.documentId) {
|
|
671
|
+
const rows = db.prepare(`
|
|
672
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
673
|
+
COALESCE(d.summary, '') AS summary,
|
|
674
|
+
COALESCE(group_concat(c.content, char(10)), '') AS content_text,
|
|
675
|
+
f.mtime, f.ctime, f.extension
|
|
676
|
+
FROM documents d
|
|
677
|
+
JOIN files f ON f.id = d.file_id
|
|
678
|
+
LEFT JOIN chunks c ON c.document_id = d.id
|
|
679
|
+
WHERE d.id = ?
|
|
680
|
+
AND f.status = 'active'
|
|
681
|
+
AND d.index_status = 'indexed'
|
|
682
|
+
GROUP BY d.id, f.path, d.title, f.name, d.summary, f.mtime, f.ctime, f.extension
|
|
683
|
+
`).all(scope.documentId);
|
|
684
|
+
return rows.map(mapTagRecomputeRow);
|
|
685
|
+
}
|
|
686
|
+
if (scope.kind === "folder" && scope.folderPath) {
|
|
687
|
+
const normalizedPath = normalizeScopedFolderPath(scope.folderPath);
|
|
688
|
+
const includeContentText = scope.mode !== "folder_bindings_only";
|
|
689
|
+
const contentJoinClause = includeContentText
|
|
690
|
+
? "LEFT JOIN chunks c ON c.document_id = d.id"
|
|
691
|
+
: "";
|
|
692
|
+
const contentSelectClause = includeContentText
|
|
693
|
+
? "COALESCE(group_concat(c.content, char(10)), '') AS content_text,"
|
|
694
|
+
: "'' AS content_text,";
|
|
695
|
+
const whereClause = normalizedPath === "."
|
|
696
|
+
? ""
|
|
697
|
+
: "AND (f.path = ? OR f.path LIKE ?)";
|
|
698
|
+
const groupByClause = includeContentText
|
|
699
|
+
? "GROUP BY d.id, f.path, d.title, f.name, d.summary, f.mtime, f.ctime, f.extension"
|
|
700
|
+
: "";
|
|
701
|
+
const params = normalizedPath === "."
|
|
702
|
+
? []
|
|
703
|
+
: [normalizedPath, `${normalizedPath}/%`];
|
|
704
|
+
const rows = db.prepare(`
|
|
705
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
706
|
+
COALESCE(d.summary, '') AS summary,
|
|
707
|
+
${contentSelectClause}
|
|
708
|
+
f.mtime, f.ctime, f.extension
|
|
709
|
+
FROM documents d
|
|
710
|
+
JOIN files f ON f.id = d.file_id
|
|
711
|
+
${contentJoinClause}
|
|
712
|
+
WHERE f.status = 'active'
|
|
713
|
+
AND d.index_status = 'indexed'
|
|
714
|
+
${whereClause}
|
|
715
|
+
${groupByClause}
|
|
716
|
+
ORDER BY f.path
|
|
717
|
+
`).all(...params);
|
|
718
|
+
return rows.map(mapTagRecomputeRow);
|
|
719
|
+
}
|
|
720
|
+
if (scope.kind === "tag" && scope.tagId) {
|
|
721
|
+
const rows = db.prepare(`
|
|
722
|
+
SELECT DISTINCT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
723
|
+
COALESCE(d.summary, '') AS summary,
|
|
724
|
+
COALESCE(group_concat(c.content, char(10)), '') AS content_text,
|
|
725
|
+
f.mtime, f.ctime, f.extension
|
|
726
|
+
FROM tag_rules r
|
|
727
|
+
JOIN tags t ON t.id = r.tag_id
|
|
728
|
+
JOIN documents d
|
|
729
|
+
LEFT JOIN chunks c ON c.document_id = d.id
|
|
730
|
+
JOIN files f ON f.id = d.file_id
|
|
731
|
+
WHERE r.tag_id = ?
|
|
732
|
+
AND f.status = 'active'
|
|
733
|
+
AND d.index_status = 'indexed'
|
|
734
|
+
GROUP BY d.id, f.path, d.title, f.name, d.summary, f.mtime, f.ctime, f.extension
|
|
735
|
+
ORDER BY f.path
|
|
736
|
+
`).all(scope.tagId);
|
|
737
|
+
return rows.map(mapTagRecomputeRow);
|
|
738
|
+
}
|
|
739
|
+
return this.listAllRecomputeCandidateDocuments(db);
|
|
740
|
+
}
|
|
741
|
+
finally {
|
|
742
|
+
db.close();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
getDocumentContext(documentId, filePath) {
|
|
746
|
+
if (!documentId && !filePath) {
|
|
747
|
+
throw new Error("documentId 或 filePath 至少提供一个");
|
|
748
|
+
}
|
|
749
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
750
|
+
try {
|
|
751
|
+
let row;
|
|
752
|
+
if (documentId) {
|
|
753
|
+
row = db.prepare(`
|
|
754
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
755
|
+
COALESCE(d.summary, '') AS summary, f.mtime, f.inode_key, f.content_hash, f.size, f.extension
|
|
756
|
+
FROM documents d
|
|
757
|
+
JOIN files f ON f.id = d.file_id
|
|
758
|
+
WHERE d.id = ?
|
|
759
|
+
AND f.status = 'active'
|
|
760
|
+
AND d.index_status = 'indexed'
|
|
761
|
+
`).get(documentId);
|
|
762
|
+
}
|
|
763
|
+
else if (filePath) {
|
|
764
|
+
row = db.prepare(`
|
|
765
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
766
|
+
COALESCE(d.summary, '') AS summary, f.mtime, f.inode_key, f.content_hash, f.size, f.extension
|
|
767
|
+
FROM documents d
|
|
768
|
+
JOIN files f ON f.id = d.file_id
|
|
769
|
+
WHERE f.path = ?
|
|
770
|
+
AND f.status = 'active'
|
|
771
|
+
AND d.index_status = 'indexed'
|
|
772
|
+
`).get(filePath);
|
|
773
|
+
}
|
|
774
|
+
if (!row) {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
const resolvedDocumentId = String(row.document_id);
|
|
778
|
+
const tags = db.prepare(`
|
|
779
|
+
SELECT t.path AS tag_path
|
|
780
|
+
FROM tags t
|
|
781
|
+
JOIN document_tags dt ON dt.tag_id = t.id
|
|
782
|
+
WHERE dt.document_id = ?
|
|
783
|
+
UNION ALL
|
|
784
|
+
SELECT t.path AS tag_path
|
|
785
|
+
FROM tags t
|
|
786
|
+
JOIN derived_document_tags ddt ON ddt.tag_id = t.id
|
|
787
|
+
WHERE ddt.document_id = ?
|
|
788
|
+
ORDER BY tag_path
|
|
789
|
+
`).all(resolvedDocumentId, resolvedDocumentId);
|
|
790
|
+
return {
|
|
791
|
+
documentId: resolvedDocumentId,
|
|
792
|
+
path: String(row.path),
|
|
793
|
+
title: String(row.title),
|
|
794
|
+
summary: String(row.summary ?? ""),
|
|
795
|
+
modifiedAt: String(row.mtime),
|
|
796
|
+
inodeKey: typeof row.inode_key === "string" && row.inode_key.trim() ? String(row.inode_key) : null,
|
|
797
|
+
contentHash: typeof row.content_hash === "string" && row.content_hash.trim() ? String(row.content_hash) : null,
|
|
798
|
+
size: Number(row.size ?? 0),
|
|
799
|
+
extension: String(row.extension ?? ""),
|
|
800
|
+
tags: tags.map(item => item.tag_path),
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
finally {
|
|
804
|
+
db.close();
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
browseTags(rootType, parentPath) {
|
|
808
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
809
|
+
try {
|
|
810
|
+
let sql = `
|
|
811
|
+
SELECT id, path, name, root_type, parent_id
|
|
812
|
+
FROM tags
|
|
813
|
+
WHERE status = 'active'
|
|
814
|
+
AND (
|
|
815
|
+
EXISTS (SELECT 1 FROM document_tags dt WHERE dt.tag_id = tags.id)
|
|
816
|
+
OR EXISTS (SELECT 1 FROM derived_document_tags ddt WHERE ddt.tag_id = tags.id)
|
|
817
|
+
OR EXISTS (SELECT 1 FROM tags child WHERE child.parent_id = tags.id AND child.status = 'active')
|
|
818
|
+
)
|
|
819
|
+
`;
|
|
820
|
+
const params = [];
|
|
821
|
+
if (rootType) {
|
|
822
|
+
sql += ` AND root_type = ?`;
|
|
823
|
+
params.push(rootType);
|
|
824
|
+
}
|
|
825
|
+
if (parentPath) {
|
|
826
|
+
const parentRow = db.prepare(`SELECT id FROM tags WHERE path = ?`).get(parentPath);
|
|
827
|
+
if (!parentRow?.id) {
|
|
828
|
+
return [];
|
|
829
|
+
}
|
|
830
|
+
sql += ` AND parent_id = ?`;
|
|
831
|
+
params.push(String(parentRow.id));
|
|
832
|
+
}
|
|
833
|
+
sql += ` ORDER BY path`;
|
|
834
|
+
const rows = db.prepare(sql).all(...params);
|
|
835
|
+
return rows.map(row => {
|
|
836
|
+
let parentPathValue = null;
|
|
837
|
+
if (row.parent_id) {
|
|
838
|
+
const parent = db.prepare(`SELECT path FROM tags WHERE id = ?`).get(row.parent_id);
|
|
839
|
+
parentPathValue = parent?.path ?? null;
|
|
840
|
+
}
|
|
841
|
+
return {
|
|
842
|
+
path: row.path,
|
|
843
|
+
name: row.name,
|
|
844
|
+
rootType: row.root_type,
|
|
845
|
+
parentPath: parentPathValue,
|
|
846
|
+
depth: row.path.split("/").length - 1,
|
|
847
|
+
};
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
finally {
|
|
851
|
+
db.close();
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
searchDocuments(query, limit = 20) {
|
|
855
|
+
const normalizedQuery = query.trim();
|
|
856
|
+
if (!normalizedQuery) {
|
|
857
|
+
return [];
|
|
858
|
+
}
|
|
859
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
860
|
+
try {
|
|
861
|
+
const keyword = `%${normalizedQuery}%`;
|
|
862
|
+
const rows = db.prepare(`
|
|
863
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
864
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
865
|
+
FROM documents d
|
|
866
|
+
JOIN files f ON f.id = d.file_id
|
|
867
|
+
WHERE f.status = 'active'
|
|
868
|
+
AND d.index_status = 'indexed'
|
|
869
|
+
AND (
|
|
870
|
+
f.path LIKE ?
|
|
871
|
+
OR COALESCE(d.title, '') LIKE ?
|
|
872
|
+
OR COALESCE(d.summary, '') LIKE ?
|
|
873
|
+
)
|
|
874
|
+
ORDER BY f.mtime DESC, f.path ASC
|
|
875
|
+
LIMIT ?
|
|
876
|
+
`).all(keyword, keyword, keyword, limit);
|
|
877
|
+
return rows.map(row => ({
|
|
878
|
+
documentId: String(row.document_id),
|
|
879
|
+
path: String(row.path),
|
|
880
|
+
title: String(row.title),
|
|
881
|
+
summary: String(row.summary ?? ""),
|
|
882
|
+
modifiedAt: String(row.mtime),
|
|
883
|
+
}));
|
|
884
|
+
}
|
|
885
|
+
finally {
|
|
886
|
+
db.close();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
listExportDocumentsByDocumentIds(documentIds) {
|
|
890
|
+
const normalizedIds = [...new Set(documentIds.map(item => item.trim()).filter(Boolean))];
|
|
891
|
+
if (normalizedIds.length === 0) {
|
|
892
|
+
return [];
|
|
893
|
+
}
|
|
894
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
895
|
+
try {
|
|
896
|
+
const placeholders = normalizedIds.map(() => "?").join(", ");
|
|
897
|
+
const documentRows = db.prepare(`
|
|
898
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
899
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
900
|
+
FROM documents d
|
|
901
|
+
JOIN files f ON f.id = d.file_id
|
|
902
|
+
WHERE f.status = 'active'
|
|
903
|
+
AND d.index_status = 'indexed'
|
|
904
|
+
AND d.id IN (${placeholders})
|
|
905
|
+
ORDER BY f.path
|
|
906
|
+
`).all(...normalizedIds);
|
|
907
|
+
if (documentRows.length === 0) {
|
|
908
|
+
return [];
|
|
909
|
+
}
|
|
910
|
+
const ids = documentRows.map(row => String(row.document_id));
|
|
911
|
+
const { directTagRows, derivedTagRows, } = fetchDocumentTagsForIds(db, ids);
|
|
912
|
+
return attachTags(documentRows, directTagRows, derivedTagRows);
|
|
913
|
+
}
|
|
914
|
+
finally {
|
|
915
|
+
db.close();
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
listExportDocuments() {
|
|
919
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
920
|
+
try {
|
|
921
|
+
const documentRows = db.prepare(`
|
|
922
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
923
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
924
|
+
FROM documents d
|
|
925
|
+
JOIN files f ON f.id = d.file_id
|
|
926
|
+
WHERE f.status = 'active'
|
|
927
|
+
AND d.index_status = 'indexed'
|
|
928
|
+
ORDER BY f.path
|
|
929
|
+
`).all();
|
|
930
|
+
const directTagRows = db.prepare(`
|
|
931
|
+
SELECT dt.document_id, t.path AS tag_path
|
|
932
|
+
FROM document_tags dt
|
|
933
|
+
JOIN tags t ON t.id = dt.tag_id
|
|
934
|
+
ORDER BY dt.document_id, t.path
|
|
935
|
+
`).all();
|
|
936
|
+
const derivedTagRows = db.prepare(`
|
|
937
|
+
SELECT ddt.document_id, t.path AS tag_path
|
|
938
|
+
FROM derived_document_tags ddt
|
|
939
|
+
JOIN tags t ON t.id = ddt.tag_id
|
|
940
|
+
ORDER BY ddt.document_id, t.path
|
|
941
|
+
`).all();
|
|
942
|
+
return attachTags(documentRows, directTagRows, derivedTagRows);
|
|
943
|
+
}
|
|
944
|
+
finally {
|
|
945
|
+
db.close();
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
listActiveFileExtensions() {
|
|
949
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
950
|
+
try {
|
|
951
|
+
const rows = db.prepare(`
|
|
952
|
+
SELECT DISTINCT extension
|
|
953
|
+
FROM files
|
|
954
|
+
WHERE status = 'active'
|
|
955
|
+
AND extension IS NOT NULL
|
|
956
|
+
AND extension <> ''
|
|
957
|
+
ORDER BY extension
|
|
958
|
+
`).all();
|
|
959
|
+
return rows.map(row => String(row.extension));
|
|
960
|
+
}
|
|
961
|
+
finally {
|
|
962
|
+
db.close();
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
listExportDocumentsByPaths(paths) {
|
|
966
|
+
const normalizedPaths = [...new Set(paths.map(item => item.trim()).filter(Boolean))];
|
|
967
|
+
if (normalizedPaths.length === 0) {
|
|
968
|
+
return [];
|
|
969
|
+
}
|
|
970
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
971
|
+
try {
|
|
972
|
+
const placeholders = normalizedPaths.map(() => "?").join(", ");
|
|
973
|
+
const documentRows = db.prepare(`
|
|
974
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
975
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
976
|
+
FROM documents d
|
|
977
|
+
JOIN files f ON f.id = d.file_id
|
|
978
|
+
WHERE f.status = 'active'
|
|
979
|
+
AND d.index_status = 'indexed'
|
|
980
|
+
AND f.path IN (${placeholders})
|
|
981
|
+
ORDER BY f.path
|
|
982
|
+
`).all(...normalizedPaths);
|
|
983
|
+
if (documentRows.length === 0) {
|
|
984
|
+
return [];
|
|
985
|
+
}
|
|
986
|
+
const documentIds = documentRows.map(row => String(row.document_id));
|
|
987
|
+
const tagPlaceholders = documentIds.map(() => "?").join(", ");
|
|
988
|
+
const directTagRows = db.prepare(`
|
|
989
|
+
SELECT dt.document_id, t.path AS tag_path
|
|
990
|
+
FROM document_tags dt
|
|
991
|
+
JOIN tags t ON t.id = dt.tag_id
|
|
992
|
+
WHERE dt.document_id IN (${tagPlaceholders})
|
|
993
|
+
ORDER BY dt.document_id, t.path
|
|
994
|
+
`).all(...documentIds);
|
|
995
|
+
const derivedTagRows = db.prepare(`
|
|
996
|
+
SELECT ddt.document_id, t.path AS tag_path
|
|
997
|
+
FROM derived_document_tags ddt
|
|
998
|
+
JOIN tags t ON t.id = ddt.tag_id
|
|
999
|
+
WHERE ddt.document_id IN (${tagPlaceholders})
|
|
1000
|
+
ORDER BY ddt.document_id, t.path
|
|
1001
|
+
`).all(...documentIds);
|
|
1002
|
+
return attachTags(documentRows, directTagRows, derivedTagRows);
|
|
1003
|
+
}
|
|
1004
|
+
finally {
|
|
1005
|
+
db.close();
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
listExportDocumentsByExtensions(extensions) {
|
|
1009
|
+
const normalizedExtensions = [...new Set(extensions
|
|
1010
|
+
.map(item => item.trim().toLowerCase())
|
|
1011
|
+
.filter(Boolean)
|
|
1012
|
+
.map(item => item.startsWith(".") ? item : `.${item}`))];
|
|
1013
|
+
if (normalizedExtensions.length === 0) {
|
|
1014
|
+
return [];
|
|
1015
|
+
}
|
|
1016
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
1017
|
+
try {
|
|
1018
|
+
const placeholders = normalizedExtensions.map(() => "?").join(", ");
|
|
1019
|
+
const documentRows = db.prepare(`
|
|
1020
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
1021
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
1022
|
+
FROM documents d
|
|
1023
|
+
JOIN files f ON f.id = d.file_id
|
|
1024
|
+
WHERE f.status = 'active'
|
|
1025
|
+
AND d.index_status = 'indexed'
|
|
1026
|
+
AND f.extension IN (${placeholders})
|
|
1027
|
+
ORDER BY f.path
|
|
1028
|
+
`).all(...normalizedExtensions);
|
|
1029
|
+
if (documentRows.length === 0) {
|
|
1030
|
+
return [];
|
|
1031
|
+
}
|
|
1032
|
+
const documentIds = documentRows.map(row => String(row.document_id));
|
|
1033
|
+
const { directTagRows, derivedTagRows, } = fetchDocumentTagsForIds(db, documentIds);
|
|
1034
|
+
return attachTags(documentRows, directTagRows, derivedTagRows);
|
|
1035
|
+
}
|
|
1036
|
+
finally {
|
|
1037
|
+
db.close();
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
listExportTags() {
|
|
1041
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
1042
|
+
try {
|
|
1043
|
+
const rows = db.prepare(`
|
|
1044
|
+
SELECT t.path, t.name, t.root_type, parent.path AS parent_path
|
|
1045
|
+
FROM tags t
|
|
1046
|
+
LEFT JOIN tags parent ON parent.id = t.parent_id
|
|
1047
|
+
WHERE t.status = 'active'
|
|
1048
|
+
AND (
|
|
1049
|
+
EXISTS (SELECT 1 FROM document_tags dt WHERE dt.tag_id = t.id)
|
|
1050
|
+
OR EXISTS (SELECT 1 FROM derived_document_tags ddt WHERE ddt.tag_id = t.id)
|
|
1051
|
+
OR EXISTS (SELECT 1 FROM tags child WHERE child.parent_id = t.id AND child.status = 'active')
|
|
1052
|
+
)
|
|
1053
|
+
ORDER BY t.path
|
|
1054
|
+
`).all();
|
|
1055
|
+
return rows.map(row => ({
|
|
1056
|
+
path: String(row.path),
|
|
1057
|
+
name: String(row.name),
|
|
1058
|
+
rootType: String(row.root_type),
|
|
1059
|
+
parentPath: row.parent_path ? String(row.parent_path) : null,
|
|
1060
|
+
depth: String(row.path).split("/").length - 1,
|
|
1061
|
+
}));
|
|
1062
|
+
}
|
|
1063
|
+
finally {
|
|
1064
|
+
db.close();
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
*iterateExportDocuments(batchSize = 1000) {
|
|
1068
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
1069
|
+
try {
|
|
1070
|
+
let lastPath = "";
|
|
1071
|
+
while (true) {
|
|
1072
|
+
const rows = db.prepare(`
|
|
1073
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
1074
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
1075
|
+
FROM documents d
|
|
1076
|
+
JOIN files f ON f.id = d.file_id
|
|
1077
|
+
WHERE f.status = 'active'
|
|
1078
|
+
AND d.index_status = 'indexed'
|
|
1079
|
+
AND f.path > ?
|
|
1080
|
+
ORDER BY f.path
|
|
1081
|
+
LIMIT ?
|
|
1082
|
+
`).all(lastPath, batchSize);
|
|
1083
|
+
if (rows.length === 0) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
yield mapDocumentRows(rows);
|
|
1087
|
+
lastPath = String(rows[rows.length - 1]?.path ?? lastPath);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
finally {
|
|
1091
|
+
db.close();
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
*iterateExportDocumentRecords(batchSize = 1000) {
|
|
1095
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
1096
|
+
try {
|
|
1097
|
+
let lastPath = "";
|
|
1098
|
+
while (true) {
|
|
1099
|
+
const documentRows = db.prepare(`
|
|
1100
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
1101
|
+
COALESCE(d.summary, '') AS summary, f.mtime
|
|
1102
|
+
FROM documents d
|
|
1103
|
+
JOIN files f ON f.id = d.file_id
|
|
1104
|
+
WHERE f.status = 'active'
|
|
1105
|
+
AND d.index_status = 'indexed'
|
|
1106
|
+
AND f.path > ?
|
|
1107
|
+
ORDER BY f.path
|
|
1108
|
+
LIMIT ?
|
|
1109
|
+
`).all(lastPath, batchSize);
|
|
1110
|
+
if (documentRows.length === 0) {
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
const documentIds = documentRows.map(row => String(row.document_id));
|
|
1114
|
+
const { directTagRows, derivedTagRows, } = fetchDocumentTagsForIds(db, documentIds);
|
|
1115
|
+
yield attachTags(documentRows, directTagRows, derivedTagRows);
|
|
1116
|
+
lastPath = String(documentRows[documentRows.length - 1]?.path ?? lastPath);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
finally {
|
|
1120
|
+
db.close();
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
*iterateDocumentTagRows(batchSize = 5000) {
|
|
1124
|
+
const db = openDatabase(this.dbPath, this.dbOptions);
|
|
1125
|
+
try {
|
|
1126
|
+
let offset = 0;
|
|
1127
|
+
while (true) {
|
|
1128
|
+
const rows = db.prepare(`
|
|
1129
|
+
SELECT dt.document_id, t.path AS tag_path, 0 AS derived
|
|
1130
|
+
FROM document_tags dt
|
|
1131
|
+
JOIN tags t ON t.id = dt.tag_id
|
|
1132
|
+
ORDER BY dt.document_id, t.path
|
|
1133
|
+
LIMIT ? OFFSET ?
|
|
1134
|
+
`).all(batchSize, offset);
|
|
1135
|
+
if (rows.length === 0) {
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
yield rows.map(row => ({
|
|
1139
|
+
documentId: String(row.document_id),
|
|
1140
|
+
tagPath: String(row.tag_path),
|
|
1141
|
+
derived: Number(row.derived) === 1,
|
|
1142
|
+
}));
|
|
1143
|
+
offset += rows.length;
|
|
1144
|
+
}
|
|
1145
|
+
offset = 0;
|
|
1146
|
+
while (true) {
|
|
1147
|
+
const rows = db.prepare(`
|
|
1148
|
+
SELECT ddt.document_id, t.path AS tag_path, 1 AS derived
|
|
1149
|
+
FROM derived_document_tags ddt
|
|
1150
|
+
JOIN tags t ON t.id = ddt.tag_id
|
|
1151
|
+
ORDER BY ddt.document_id, t.path
|
|
1152
|
+
LIMIT ? OFFSET ?
|
|
1153
|
+
`).all(batchSize, offset);
|
|
1154
|
+
if (rows.length === 0) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
yield rows.map(row => ({
|
|
1158
|
+
documentId: String(row.document_id),
|
|
1159
|
+
tagPath: String(row.tag_path),
|
|
1160
|
+
derived: Number(row.derived) === 1,
|
|
1161
|
+
}));
|
|
1162
|
+
offset += rows.length;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
finally {
|
|
1166
|
+
db.close();
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
*iterateTagPostingRows(batchSize = 5000) {
|
|
1170
|
+
const directIterator = this.iterateDirectTagPostingRows(batchSize);
|
|
1171
|
+
const derivedIterator = this.iterateDerivedTagPostingRows(batchSize);
|
|
1172
|
+
let directState = directIterator.next();
|
|
1173
|
+
let derivedState = derivedIterator.next();
|
|
1174
|
+
let directIndex = 0;
|
|
1175
|
+
let derivedIndex = 0;
|
|
1176
|
+
while (!directState.done || !derivedState.done) {
|
|
1177
|
+
const mergedBatch = [];
|
|
1178
|
+
while (mergedBatch.length < batchSize && (!directState.done || !derivedState.done)) {
|
|
1179
|
+
if (directState.done) {
|
|
1180
|
+
mergedBatch.push(derivedState.value[derivedIndex]);
|
|
1181
|
+
derivedIndex += 1;
|
|
1182
|
+
}
|
|
1183
|
+
else if (derivedState.done) {
|
|
1184
|
+
mergedBatch.push(directState.value[directIndex]);
|
|
1185
|
+
directIndex += 1;
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
const directRow = directState.value[directIndex];
|
|
1189
|
+
const derivedRow = derivedState.value[derivedIndex];
|
|
1190
|
+
if (compareTagPostingRows(directRow, derivedRow) <= 0) {
|
|
1191
|
+
mergedBatch.push(directRow);
|
|
1192
|
+
directIndex += 1;
|
|
1193
|
+
}
|
|
1194
|
+
else {
|
|
1195
|
+
mergedBatch.push(derivedRow);
|
|
1196
|
+
derivedIndex += 1;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
if (!directState.done && directIndex >= directState.value.length) {
|
|
1200
|
+
directState = directIterator.next();
|
|
1201
|
+
directIndex = 0;
|
|
1202
|
+
}
|
|
1203
|
+
if (!derivedState.done && derivedIndex >= derivedState.value.length) {
|
|
1204
|
+
derivedState = derivedIterator.next();
|
|
1205
|
+
derivedIndex = 0;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (mergedBatch.length === 0) {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
yield mergedBatch;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
*iterateDirectTagPostingRows(batchSize = 5000) {
|
|
1215
|
+
const db = openDatabase(this.dbPath);
|
|
1216
|
+
try {
|
|
1217
|
+
let lastRootType = "";
|
|
1218
|
+
let lastTagPath = "";
|
|
1219
|
+
let lastPath = "";
|
|
1220
|
+
let lastDocumentId = "";
|
|
1221
|
+
while (true) {
|
|
1222
|
+
const rows = db.prepare(`
|
|
1223
|
+
SELECT t.root_type, t.path AS tag_path, dt.document_id, f.path, COALESCE(d.title, f.name) AS title, 0 AS derived
|
|
1224
|
+
FROM document_tags dt
|
|
1225
|
+
JOIN tags t ON t.id = dt.tag_id
|
|
1226
|
+
JOIN documents d ON d.id = dt.document_id
|
|
1227
|
+
JOIN files f ON f.id = d.file_id
|
|
1228
|
+
WHERE f.status = 'active'
|
|
1229
|
+
AND d.index_status = 'indexed'
|
|
1230
|
+
AND (
|
|
1231
|
+
t.root_type > ?
|
|
1232
|
+
OR (t.root_type = ? AND t.path > ?)
|
|
1233
|
+
OR (t.root_type = ? AND t.path = ? AND f.path > ?)
|
|
1234
|
+
OR (t.root_type = ? AND t.path = ? AND f.path = ? AND dt.document_id > ?)
|
|
1235
|
+
)
|
|
1236
|
+
ORDER BY t.root_type, t.path, f.path, dt.document_id
|
|
1237
|
+
LIMIT ?
|
|
1238
|
+
`).all(lastRootType, lastRootType, lastTagPath, lastRootType, lastTagPath, lastPath, lastRootType, lastTagPath, lastPath, lastDocumentId, batchSize);
|
|
1239
|
+
if (rows.length === 0) {
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
const mapped = rows.map(row => ({
|
|
1243
|
+
rootType: String(row.root_type),
|
|
1244
|
+
tagPath: String(row.tag_path),
|
|
1245
|
+
documentId: String(row.document_id),
|
|
1246
|
+
path: String(row.path),
|
|
1247
|
+
title: String(row.title),
|
|
1248
|
+
derived: false,
|
|
1249
|
+
}));
|
|
1250
|
+
yield mapped;
|
|
1251
|
+
const lastRow = mapped[mapped.length - 1];
|
|
1252
|
+
lastRootType = lastRow?.rootType ?? lastRootType;
|
|
1253
|
+
lastTagPath = lastRow?.tagPath ?? lastTagPath;
|
|
1254
|
+
lastPath = lastRow?.path ?? lastPath;
|
|
1255
|
+
lastDocumentId = lastRow?.documentId ?? lastDocumentId;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
finally {
|
|
1259
|
+
db.close();
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
*iterateDerivedTagPostingRows(batchSize = 5000) {
|
|
1263
|
+
const db = openDatabase(this.dbPath);
|
|
1264
|
+
try {
|
|
1265
|
+
let lastRootType = "";
|
|
1266
|
+
let lastTagPath = "";
|
|
1267
|
+
let lastPath = "";
|
|
1268
|
+
let lastDocumentId = "";
|
|
1269
|
+
while (true) {
|
|
1270
|
+
const rows = db.prepare(`
|
|
1271
|
+
SELECT t.root_type, t.path AS tag_path, ddt.document_id, f.path, COALESCE(d.title, f.name) AS title, 1 AS derived
|
|
1272
|
+
FROM derived_document_tags ddt
|
|
1273
|
+
JOIN tags t ON t.id = ddt.tag_id
|
|
1274
|
+
JOIN documents d ON d.id = ddt.document_id
|
|
1275
|
+
JOIN files f ON f.id = d.file_id
|
|
1276
|
+
WHERE f.status = 'active'
|
|
1277
|
+
AND d.index_status = 'indexed'
|
|
1278
|
+
AND (
|
|
1279
|
+
t.root_type > ?
|
|
1280
|
+
OR (t.root_type = ? AND t.path > ?)
|
|
1281
|
+
OR (t.root_type = ? AND t.path = ? AND f.path > ?)
|
|
1282
|
+
OR (t.root_type = ? AND t.path = ? AND f.path = ? AND ddt.document_id > ?)
|
|
1283
|
+
)
|
|
1284
|
+
ORDER BY t.root_type, t.path, f.path, ddt.document_id
|
|
1285
|
+
LIMIT ?
|
|
1286
|
+
`).all(lastRootType, lastRootType, lastTagPath, lastRootType, lastTagPath, lastPath, lastRootType, lastTagPath, lastPath, lastDocumentId, batchSize);
|
|
1287
|
+
if (rows.length === 0) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
const mapped = rows.map(row => ({
|
|
1291
|
+
rootType: String(row.root_type),
|
|
1292
|
+
tagPath: String(row.tag_path),
|
|
1293
|
+
documentId: String(row.document_id),
|
|
1294
|
+
path: String(row.path),
|
|
1295
|
+
title: String(row.title),
|
|
1296
|
+
derived: true,
|
|
1297
|
+
}));
|
|
1298
|
+
yield mapped;
|
|
1299
|
+
const lastRow = mapped[mapped.length - 1];
|
|
1300
|
+
lastRootType = lastRow?.rootType ?? lastRootType;
|
|
1301
|
+
lastTagPath = lastRow?.tagPath ?? lastTagPath;
|
|
1302
|
+
lastPath = lastRow?.path ?? lastPath;
|
|
1303
|
+
lastDocumentId = lastRow?.documentId ?? lastDocumentId;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
finally {
|
|
1307
|
+
db.close();
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
*iterateTagRecomputeDocuments(batchSize = 1000) {
|
|
1311
|
+
const db = openDatabase(this.dbPath);
|
|
1312
|
+
try {
|
|
1313
|
+
let lastPath = "";
|
|
1314
|
+
while (true) {
|
|
1315
|
+
const rows = db.prepare(`
|
|
1316
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
1317
|
+
COALESCE(d.summary, '') AS summary,
|
|
1318
|
+
COALESCE(group_concat(c.content, char(10)), '') AS content_text,
|
|
1319
|
+
f.mtime, f.ctime, f.extension
|
|
1320
|
+
FROM documents d
|
|
1321
|
+
JOIN files f ON f.id = d.file_id
|
|
1322
|
+
LEFT JOIN chunks c ON c.document_id = d.id
|
|
1323
|
+
WHERE f.status = 'active'
|
|
1324
|
+
AND d.index_status = 'indexed'
|
|
1325
|
+
AND f.path > ?
|
|
1326
|
+
GROUP BY d.id, f.path, d.title, f.name, d.summary, f.mtime, f.ctime, f.extension
|
|
1327
|
+
ORDER BY f.path
|
|
1328
|
+
LIMIT ?
|
|
1329
|
+
`).all(lastPath, batchSize);
|
|
1330
|
+
if (rows.length === 0) {
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
yield rows.map(row => ({
|
|
1334
|
+
documentId: String(row.document_id),
|
|
1335
|
+
path: String(row.path),
|
|
1336
|
+
title: String(row.title),
|
|
1337
|
+
summary: String(row.summary ?? ""),
|
|
1338
|
+
contentText: String(row.content_text ?? ""),
|
|
1339
|
+
mtime: String(row.mtime),
|
|
1340
|
+
ctime: String(row.ctime),
|
|
1341
|
+
extension: String(row.extension),
|
|
1342
|
+
}));
|
|
1343
|
+
lastPath = String(rows[rows.length - 1]?.path ?? lastPath);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
finally {
|
|
1347
|
+
db.close();
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
listAllRecomputeCandidateDocuments(db) {
|
|
1351
|
+
const rows = db.prepare(`
|
|
1352
|
+
SELECT d.id AS document_id, f.path, COALESCE(d.title, f.name) AS title,
|
|
1353
|
+
COALESCE(d.summary, '') AS summary,
|
|
1354
|
+
COALESCE(group_concat(c.content, char(10)), '') AS content_text,
|
|
1355
|
+
f.mtime, f.ctime, f.extension
|
|
1356
|
+
FROM documents d
|
|
1357
|
+
JOIN files f ON f.id = d.file_id
|
|
1358
|
+
LEFT JOIN chunks c ON c.document_id = d.id
|
|
1359
|
+
WHERE f.status = 'active'
|
|
1360
|
+
AND d.index_status = 'indexed'
|
|
1361
|
+
GROUP BY d.id, f.path, d.title, f.name, d.summary, f.mtime, f.ctime, f.extension
|
|
1362
|
+
ORDER BY f.path
|
|
1363
|
+
`).all();
|
|
1364
|
+
return rows.map(mapTagRecomputeRow);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
function buildDocumentIdsByInode(rows) {
|
|
1368
|
+
const byInode = new Map();
|
|
1369
|
+
rows.forEach((row) => {
|
|
1370
|
+
if (!row.inodeKey) {
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
const current = byInode.get(row.inodeKey) ?? new Set();
|
|
1374
|
+
current.add(row.documentId);
|
|
1375
|
+
byInode.set(row.inodeKey, current);
|
|
1376
|
+
});
|
|
1377
|
+
return byInode;
|
|
1378
|
+
}
|
|
1379
|
+
function buildDocumentIdsByContent(rows) {
|
|
1380
|
+
const byContent = new Map();
|
|
1381
|
+
rows.forEach((row) => {
|
|
1382
|
+
const key = buildContentIdentityKey(row.contentHash, row.size, row.extension);
|
|
1383
|
+
if (!key) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
const current = byContent.get(key) ?? new Set();
|
|
1387
|
+
current.add(row.documentId);
|
|
1388
|
+
byContent.set(key, current);
|
|
1389
|
+
});
|
|
1390
|
+
return byContent;
|
|
1391
|
+
}
|
|
1392
|
+
function buildContentIdentityKey(contentHash, size, extension) {
|
|
1393
|
+
if (!contentHash) {
|
|
1394
|
+
return null;
|
|
1395
|
+
}
|
|
1396
|
+
return `${contentHash}::${size}::${extension}`;
|
|
1397
|
+
}
|
|
1398
|
+
function matchesContentFallback(document, candidate, activeDocIdsByInode, activeDocIdsByContent, documentContentKey) {
|
|
1399
|
+
const candidateContentKey = buildContentIdentityKey(candidate.contentHash, candidate.fileSize, candidate.extension);
|
|
1400
|
+
if (!documentContentKey || !candidateContentKey || documentContentKey !== candidateContentKey) {
|
|
1401
|
+
return false;
|
|
1402
|
+
}
|
|
1403
|
+
const contentMatches = activeDocIdsByContent.get(candidateContentKey);
|
|
1404
|
+
if (!contentMatches || contentMatches.size !== 1 || !contentMatches.has(document.documentId)) {
|
|
1405
|
+
return false;
|
|
1406
|
+
}
|
|
1407
|
+
if (!candidate.inodeKey) {
|
|
1408
|
+
return true;
|
|
1409
|
+
}
|
|
1410
|
+
const inodeMatches = activeDocIdsByInode.get(candidate.inodeKey);
|
|
1411
|
+
return !inodeMatches || (inodeMatches.size === 1 && inodeMatches.has(document.documentId));
|
|
1412
|
+
}
|
|
1413
|
+
function mapTagRecomputeRow(row) {
|
|
1414
|
+
return {
|
|
1415
|
+
documentId: String(row.document_id),
|
|
1416
|
+
path: String(row.path),
|
|
1417
|
+
title: String(row.title),
|
|
1418
|
+
summary: String(row.summary ?? ""),
|
|
1419
|
+
contentText: String(row.content_text ?? ""),
|
|
1420
|
+
mtime: String(row.mtime),
|
|
1421
|
+
ctime: String(row.ctime),
|
|
1422
|
+
extension: String(row.extension),
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
function normalizeScopedFolderPath(value) {
|
|
1426
|
+
const normalized = value.trim().replace(/^\.\/+/, "").replace(/\/+$/g, "");
|
|
1427
|
+
if (!normalized || normalized === ".") {
|
|
1428
|
+
return ".";
|
|
1429
|
+
}
|
|
1430
|
+
return normalized;
|
|
1431
|
+
}
|
|
1432
|
+
function parseJsonRecord(value) {
|
|
1433
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
1434
|
+
return {};
|
|
1435
|
+
}
|
|
1436
|
+
try {
|
|
1437
|
+
const parsed = JSON.parse(value);
|
|
1438
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
1439
|
+
return parsed;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
catch {
|
|
1443
|
+
return {};
|
|
1444
|
+
}
|
|
1445
|
+
return {};
|
|
1446
|
+
}
|
|
1447
|
+
function mapTagRuleRow(row) {
|
|
1448
|
+
const scope = parseJsonRecord(row.scope_json);
|
|
1449
|
+
const matcher = parseJsonRecord(row.matcher_json);
|
|
1450
|
+
const relationValue = typeof scope.relation === "string" ? scope.relation.toLowerCase() : "and";
|
|
1451
|
+
const relation = relationValue === "or" || relationValue === "not" ? relationValue : "and";
|
|
1452
|
+
return {
|
|
1453
|
+
id: String(row.id),
|
|
1454
|
+
tagId: String(row.tag_id),
|
|
1455
|
+
tagPath: String(row.tag_path),
|
|
1456
|
+
enabled: Number(row.enabled ?? 0) === 1,
|
|
1457
|
+
relation,
|
|
1458
|
+
ruleType: String(row.rule_type),
|
|
1459
|
+
matcher,
|
|
1460
|
+
minScore: row.min_score === null || row.min_score === undefined ? null : Number(row.min_score),
|
|
1461
|
+
priority: Number(row.priority ?? 0),
|
|
1462
|
+
source: String(row.source ?? "smart_rule"),
|
|
1463
|
+
createdAt: String(row.created_at),
|
|
1464
|
+
updatedAt: String(row.updated_at),
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
function normalizeFolderBindingPath(value) {
|
|
1468
|
+
const normalized = value.trim().replace(/^\.\/+/, "").replace(/\/+$/g, "");
|
|
1469
|
+
return normalized || ".";
|
|
1470
|
+
}
|
|
1471
|
+
//# sourceMappingURL=catalog-repository.js.map
|