noteconnection 1.7.0 → 1.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.
Files changed (328) hide show
  1. package/LICENSE +674 -21
  2. package/README.md +260 -1626
  3. package/dist/src/agent_workspace.contract.parity.test.js +159 -0
  4. package/dist/src/agent_workspace.frontend.test.js +10388 -0
  5. package/dist/src/agent_workspace.locale.contract.test.js +95 -0
  6. package/dist/src/agent_workspace.runtime.behavior.test.js +5072 -0
  7. package/dist/src/android.knowledgebase.picker.contract.test.js +102 -0
  8. package/dist/src/appimage.patchelf.test.js +113 -0
  9. package/dist/src/appimage.portability.test.js +156 -0
  10. package/dist/src/backend/FileLoader.js +18 -4
  11. package/dist/src/backend/FileLoader.test.js +125 -0
  12. package/dist/src/backend/GraphBuilder.identity.test.js +86 -0
  13. package/dist/src/backend/GraphBuilder.js +66 -18
  14. package/dist/src/backend/GraphBuilder.matching.test.js +127 -0
  15. package/dist/src/backend/GraphMetrics.js +0 -3
  16. package/dist/src/backend/ResourceIdentity.js +155 -0
  17. package/dist/src/backend/ResourceIdentity.test.js +113 -0
  18. package/dist/src/backend/algorithms/CycleDetection.js +0 -1
  19. package/dist/src/backend/algorithms/HybridEngine.js +0 -3
  20. package/dist/src/backend/algorithms/LayoutEngine.js +0 -1
  21. package/dist/src/backend/algorithms/StatisticalAnalyzer.js +0 -4
  22. package/dist/src/backend/algorithms/TopologicalSort.js +0 -2
  23. package/dist/src/backend/build_dag.js +0 -1
  24. package/dist/src/capacitor.bridge.serialization.contract.test.js +3 -0
  25. package/dist/src/capacitor.runtime.contract.test.js +11 -2
  26. package/dist/src/copy.assets.contract.test.js +130 -0
  27. package/dist/src/core/Graph.js +138 -42
  28. package/dist/src/core/Graph.test.js +74 -0
  29. package/dist/src/core/NoteConnection.js +2 -2
  30. package/dist/src/core/PathBridge.js +293 -5
  31. package/dist/src/core/ResourceReference.js +17 -0
  32. package/dist/src/desktop.godot.pack.test.js +142 -0
  33. package/dist/src/desktop.runtime.graph.test.js +66 -0
  34. package/dist/src/export/WorkspaceExportBundle.js +1174 -0
  35. package/dist/src/export/WorkspaceExportBundle.test.js +1541 -0
  36. package/dist/src/export/index.js +18 -0
  37. package/dist/src/export/types.js +2 -0
  38. package/dist/src/fixrisk.issue.verifier.contract.test.js +3 -1
  39. package/dist/src/foundation.ann.runtime.contract.test.js +81 -0
  40. package/dist/src/foundation.release.evidence.contract.test.js +524 -0
  41. package/dist/src/foundation.sqlite.runtime.contract.test.js +88 -0
  42. package/dist/src/frontend/README.md +260 -1626
  43. package/dist/src/frontend/agent_workspace.js +6011 -0
  44. package/dist/src/frontend/agent_workspace_runtime.js +4434 -0
  45. package/dist/src/frontend/analysis.js +31 -4
  46. package/dist/src/frontend/app.js +2178 -62
  47. package/dist/src/frontend/focus_mode_interactions.js +33 -0
  48. package/dist/src/frontend/godot_future_path_renderer.js +540 -0
  49. package/dist/src/frontend/godot_tree_interactions.js +178 -0
  50. package/dist/src/frontend/graph_state.mjs +105 -0
  51. package/dist/src/frontend/hosted_future_path_runtime.js +157 -0
  52. package/dist/src/frontend/i18n.mjs +186 -0
  53. package/dist/src/frontend/index.html +672 -268
  54. package/dist/src/frontend/knowledge_projection_contract.js +230 -0
  55. package/dist/src/frontend/knowledge_projection_store.js +214 -0
  56. package/dist/src/frontend/layout_gpu.js +12 -4
  57. package/dist/src/frontend/libs/path_core.js +158 -42
  58. package/dist/src/frontend/locales/en.json +753 -5
  59. package/dist/src/frontend/locales/zh.json +753 -5
  60. package/dist/src/frontend/main.mjs +60 -0
  61. package/dist/src/frontend/markdown_runtime.js +827 -0
  62. package/dist/src/frontend/mobile_budget_runtime.js +33 -0
  63. package/dist/src/frontend/mobile_exact_analyzer.js +393 -0
  64. package/dist/src/frontend/mobile_identity_contract.js +221 -0
  65. package/dist/src/frontend/mobile_semantic_comparator.js +264 -0
  66. package/dist/src/frontend/notemd.css +49 -0
  67. package/dist/src/frontend/notemd.html +7 -1
  68. package/dist/src/frontend/notemd.js +64 -0
  69. package/dist/src/frontend/path.html +113 -2
  70. package/dist/src/frontend/path_app.js +2108 -130
  71. package/dist/src/frontend/path_layout.mjs +143 -0
  72. package/dist/src/frontend/path_mermaid_utils.mjs +108 -0
  73. package/dist/src/frontend/path_modules_bridge.js +486 -0
  74. package/dist/src/frontend/path_state.mjs +118 -0
  75. package/dist/src/frontend/path_styles.css +146 -0
  76. package/dist/src/frontend/path_worker_bridge.mjs +85 -0
  77. package/dist/src/frontend/reader.js +393 -33
  78. package/dist/src/frontend/runtime_bridge.js +67 -54
  79. package/dist/src/frontend/runtime_bridge.mjs +279 -0
  80. package/dist/src/frontend/settings.js +130 -12
  81. package/dist/src/frontend/simulationWorker.js +1 -1
  82. package/dist/src/frontend/source_manager.js +297 -22
  83. package/dist/src/frontend/storage_provider.js +661 -71
  84. package/dist/src/frontend/styles.css +2814 -72
  85. package/dist/src/frontend/workbench_state.mjs +101 -0
  86. package/dist/src/frontend/workspace_panes.js +10272 -0
  87. package/dist/src/frontend.locale.contract.test.js +62 -0
  88. package/dist/src/frontend.runtime.assets.contract.test.js +81 -0
  89. package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
  90. package/dist/src/graph.answer.operator.contract.test.js +72 -0
  91. package/dist/src/index.js +6 -2
  92. package/dist/src/index.knowledge-root.test.js +118 -0
  93. package/dist/src/indexing/IndexLifecycle.js +217 -0
  94. package/dist/src/indexing/IndexLifecycle.test.js +73 -0
  95. package/dist/src/indexing/SegmentBuilder.js +64 -0
  96. package/dist/src/indexing/UnitBuilder.js +48 -0
  97. package/dist/src/indexing/types.js +2 -0
  98. package/dist/src/knowledge.api.contract.test.js +172 -0
  99. package/dist/src/knowledge_projection.contract.test.js +134 -0
  100. package/dist/src/knowledge_projection_store.test.js +200 -0
  101. package/dist/src/learning/AnswerQualityEvaluation.js +153 -0
  102. package/dist/src/learning/AnswerQualityEvaluation.test.js +118 -0
  103. package/dist/src/learning/KnowledgeLearningPlatform.js +11181 -0
  104. package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +745 -0
  105. package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
  106. package/dist/src/learning/KnowledgeLearningPlatform.test.js +3208 -0
  107. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2998 -0
  108. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3936 -0
  109. package/dist/src/learning/MeasurementEvidenceConflicts.test.js +78 -0
  110. package/dist/src/learning/PublicAnswerContract.test.js +85 -0
  111. package/dist/src/learning/PublicEvidenceSelection.test.js +94 -0
  112. package/dist/src/learning/PublicMeasurementDisclosure.test.js +54 -0
  113. package/dist/src/learning/agentConversationExecution.js +211 -0
  114. package/dist/src/learning/agentConversationExecution.test.js +209 -0
  115. package/dist/src/learning/agentConversationSerialization.js +266 -0
  116. package/dist/src/learning/agentConversationSerialization.test.js +165 -0
  117. package/dist/src/learning/agentResponseBudget.js +179 -0
  118. package/dist/src/learning/agentResponseBudget.test.js +97 -0
  119. package/dist/src/learning/agentWorkspaceCapabilityContracts.js +65 -0
  120. package/dist/src/learning/answerReleaseReview.js +5260 -0
  121. package/dist/src/learning/answerReleaseReview.test.js +4174 -0
  122. package/dist/src/learning/answerTaskPlan.js +473 -0
  123. package/dist/src/learning/api.js +2 -0
  124. package/dist/src/learning/conversationComposer.js +1721 -0
  125. package/dist/src/learning/conversationComposer.test.js +3220 -0
  126. package/dist/src/learning/domains/ConversationManager.js +53 -0
  127. package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
  128. package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
  129. package/dist/src/learning/domains/MasteryEngine.js +387 -0
  130. package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
  131. package/dist/src/learning/domains/QualityEvaluator.js +307 -0
  132. package/dist/src/learning/domains/TutorRouter.js +313 -0
  133. package/dist/src/learning/domains/index.js +33 -0
  134. package/dist/src/learning/domains/types.js +7 -0
  135. package/dist/src/learning/errors.js +29 -0
  136. package/dist/src/learning/evidenceContextAssembler.js +1368 -0
  137. package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
  138. package/dist/src/learning/graphAnswerCoverage.js +37 -0
  139. package/dist/src/learning/graphAnswerCoverage.test.js +93 -0
  140. package/dist/src/learning/graphAnswerCoverageCalibration.js +59 -0
  141. package/dist/src/learning/graphAnswerCoverageCalibration.test.js +46 -0
  142. package/dist/src/learning/graphAnswerFacts.js +94 -0
  143. package/dist/src/learning/graphAnswerFacts.test.js +39 -0
  144. package/dist/src/learning/graphAnswerPlan.js +908 -0
  145. package/dist/src/learning/graphAnswerPlan.test.js +907 -0
  146. package/dist/src/learning/graphAnswerQualityCalibration.js +255 -0
  147. package/dist/src/learning/graphAnswerQualityCalibration.test.js +72 -0
  148. package/dist/src/learning/graphAnswerQualityPolicy.js +30 -0
  149. package/dist/src/learning/graphClaimMatcher.js +104 -0
  150. package/dist/src/learning/graphConditionedContext.js +109 -0
  151. package/dist/src/learning/graphConditionedContext.test.js +99 -0
  152. package/dist/src/learning/graphContextAssembler.js +860 -0
  153. package/dist/src/learning/graphContextAssembler.test.js +1033 -0
  154. package/dist/src/learning/graphExpansionPolicy.js +22 -0
  155. package/dist/src/learning/graphExpansionPolicy.test.js +33 -0
  156. package/dist/src/learning/identityMetadata.test.js +26 -0
  157. package/dist/src/learning/index.js +29 -0
  158. package/dist/src/learning/mobileAnswerProjection.js +104 -0
  159. package/dist/src/learning/mobileAnswerProjection.test.js +102 -0
  160. package/dist/src/learning/queryBackend.js +1922 -0
  161. package/dist/src/learning/queryBackend.test.js +976 -0
  162. package/dist/src/learning/ragContextPack.js +356 -0
  163. package/dist/src/learning/ragContextPack.test.js +311 -0
  164. package/dist/src/learning/ragEvidenceQuality.js +96 -0
  165. package/dist/src/learning/ragEvidenceQuality.test.js +29 -0
  166. package/dist/src/learning/ragPublicText.js +101 -0
  167. package/dist/src/learning/ragPublicText.test.js +57 -0
  168. package/dist/src/learning/ragSufficiencyJudge.js +171 -0
  169. package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
  170. package/dist/src/learning/ragSufficiencyProviderJudge.js +217 -0
  171. package/dist/src/learning/ragSufficiencyProviderJudge.test.js +207 -0
  172. package/dist/src/learning/requestNormalization.js +304 -0
  173. package/dist/src/learning/requestNormalization.test.js +101 -0
  174. package/dist/src/learning/runtimeCapability.js +4677 -0
  175. package/dist/src/learning/runtimeCapability.test.js +3635 -0
  176. package/dist/src/learning/store.js +1344 -0
  177. package/dist/src/learning/store.test.js +1425 -0
  178. package/dist/src/learning/tutorAdapter.js +2 -0
  179. package/dist/src/learning/types.js +2 -0
  180. package/dist/src/learning/vectorAccelerationAdapter.js +958 -0
  181. package/dist/src/learning/vectorAccelerationAdapter.test.js +412 -0
  182. package/dist/src/learning/workspaceHydration.js +168 -0
  183. package/dist/src/learning/workspaceHydration.test.js +30 -0
  184. package/dist/src/lfs.asset.policy.contract.test.js +153 -0
  185. package/dist/src/license.policy.contract.test.js +71 -0
  186. package/dist/src/markdown/MarkdownGateway.js +4 -0
  187. package/dist/src/markdown/MarkdownGateway.test.js +59 -0
  188. package/dist/src/memory/MemoryGovernance.js +74 -0
  189. package/dist/src/memory/MemoryGovernance.test.js +46 -0
  190. package/dist/src/memory/types.js +2 -0
  191. package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
  192. package/dist/src/middleware/SseResponseWriter.js +122 -0
  193. package/dist/src/middleware/SseResponseWriter.test.js +54 -0
  194. package/dist/src/middleware/auth.js +38 -0
  195. package/dist/src/middleware/auth.test.js +33 -0
  196. package/dist/src/middleware/body-parser.js +45 -0
  197. package/dist/src/middleware/cors.js +44 -0
  198. package/dist/src/middleware/index.js +22 -0
  199. package/dist/src/middleware/request-trace.js +96 -0
  200. package/dist/src/mobile.android.evidence.contract.test.js +146 -0
  201. package/dist/src/mobile.android.signing.contract.test.js +66 -0
  202. package/dist/src/mobile.artifact.contract.test.js +144 -0
  203. package/dist/src/mobile.budget.contract.test.js +90 -0
  204. package/dist/src/mobile.canonical-id.readiness.test.js +54 -0
  205. package/dist/src/mobile.graph.parity.contract.test.js +207 -0
  206. package/dist/src/mobile.identity.contract.test.js +66 -0
  207. package/dist/src/mobile.identity.corpus.manifest.test.js +72 -0
  208. package/dist/src/mobile.identity.corpus.test.js +40 -0
  209. package/dist/src/mobile.native.recovery.contract.test.js +64 -0
  210. package/dist/src/mobile.pipeline.test.js +11 -1
  211. package/dist/src/mobile.profile.contract.test.js +225 -0
  212. package/dist/src/mobile.semantic.parity.test.js +92 -0
  213. package/dist/src/mobile_exact_analyzer.test.js +113 -0
  214. package/dist/src/notemd/AppConfigToml.js +6 -4
  215. package/dist/src/notemd/ContentGenerator.js +4 -9
  216. package/dist/src/notemd/FileProcessor.js +4 -9
  217. package/dist/src/notemd/MermaidProcessor.js +400 -50
  218. package/dist/src/notemd/NotemdService.js +506 -26
  219. package/dist/src/notemd/PromptManager.js +15 -0
  220. package/dist/src/notemd/Translator.js +4 -9
  221. package/dist/src/notemd/cli/commands.js +357 -0
  222. package/dist/src/notemd/cli/dispatcher.js +225 -0
  223. package/dist/src/notemd/cli/index.js +169 -0
  224. package/dist/src/notemd/cli/parser.js +68 -0
  225. package/dist/src/notemd/cli/types.js +2 -0
  226. package/dist/src/notemd/constants.js +43 -0
  227. package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
  228. package/dist/src/notemd/diagram/diagramSpec.js +79 -0
  229. package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
  230. package/dist/src/notemd/diagram/intent.js +95 -0
  231. package/dist/src/notemd/diagram/planner.js +71 -0
  232. package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
  233. package/dist/src/notemd/diagram/types.js +18 -0
  234. package/dist/src/notemd/index.js +26 -0
  235. package/dist/src/notemd/operations/capabilityManifest.js +23 -0
  236. package/dist/src/notemd/operations/cliContracts.js +17 -0
  237. package/dist/src/notemd/operations/configProfileCommands.js +85 -0
  238. package/dist/src/notemd/operations/registry.contract.test.js +95 -0
  239. package/dist/src/notemd/operations/registry.js +991 -0
  240. package/dist/src/notemd/operations/types.js +2 -0
  241. package/dist/src/notemd/progressReporter.js +9 -0
  242. package/dist/src/notemd/providerDiagnostics.js +220 -0
  243. package/dist/src/notemd/providerProfiles.js +42 -0
  244. package/dist/src/notemd/providerTemplates.js +231 -0
  245. package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
  246. package/dist/src/notemd/search/SearchManager.js +13 -0
  247. package/dist/src/notemd/search/SearchProvider.js +2 -0
  248. package/dist/src/notemd/search/TavilyProvider.js +44 -0
  249. package/dist/src/notemd.agent.manifest.test.js +85 -0
  250. package/dist/src/notemd.api.contract.test.js +14 -1
  251. package/dist/src/notemd.app_config_toml.test.js +2 -1
  252. package/dist/src/notemd.batch.workflow.test.js +117 -0
  253. package/dist/src/notemd.cli.e2e.test.js +136 -0
  254. package/dist/src/notemd.core.test.js +51 -0
  255. package/dist/src/notemd.diagram.pipeline.test.js +233 -0
  256. package/dist/src/notemd.providerTemplates.test.js +34 -0
  257. package/dist/src/notemd.server.integration.test.js +262 -39
  258. package/dist/src/notemd.workflow.pipeline.test.js +162 -0
  259. package/dist/src/pathbridge.handshake.contract.test.js +45 -2
  260. package/dist/src/pathbridge.host-adapter.contract.test.js +133 -0
  261. package/dist/src/pathcore.bundle.contract.test.js +8 -0
  262. package/dist/src/pathmode.background.contract.test.js +69 -0
  263. package/dist/src/pathmode.settings.api.contract.test.js +9 -0
  264. package/dist/src/pkg.sidecar.contract.test.js +9 -3
  265. package/dist/src/platform/ExportProfile.js +86 -0
  266. package/dist/src/platform/MobileBudget.js +11 -0
  267. package/dist/src/platform/PlatformCapabilities.js +59 -0
  268. package/dist/src/platform/PlatformCapabilities.test.js +36 -0
  269. package/dist/src/platform/RenderMaterializer.js +33 -0
  270. package/dist/src/platform/RenderMaterializer.test.js +32 -0
  271. package/dist/src/query_backend.external_http.integration.test.js +410 -0
  272. package/dist/src/reader_renderer.js +404 -3
  273. package/dist/src/reader_renderer.test.js +87 -0
  274. package/dist/src/release.godot.mirror.contract.test.js +97 -0
  275. package/dist/src/resources/ResourceRegistry.js +263 -0
  276. package/dist/src/resources/ResourceRegistry.test.js +97 -0
  277. package/dist/src/resources/types.js +2 -0
  278. package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
  279. package/dist/src/routes/index.js +19 -0
  280. package/dist/src/routes/knowledge.js +981 -0
  281. package/dist/src/routes/knowledgePayload.js +185 -0
  282. package/dist/src/routes/knowledgePayload.test.js +53 -0
  283. package/dist/src/routes/markdown.js +295 -0
  284. package/dist/src/routes/notemd.js +1321 -0
  285. package/dist/src/routes/registry.contract.test.js +133 -0
  286. package/dist/src/routes/registry.shadow.contract.test.js +22 -0
  287. package/dist/src/routes/render.js +248 -0
  288. package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
  289. package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
  290. package/dist/src/routes/settings.js +6 -0
  291. package/dist/src/routes/staticFiles.js +94 -0
  292. package/dist/src/routes/types.js +2 -0
  293. package/dist/src/runtime.capabilities.test.js +18 -2
  294. package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
  295. package/dist/src/server.js +10342 -1325
  296. package/dist/src/server.migration.test.js +584 -10
  297. package/dist/src/server.port.fallback.contract.test.js +63 -0
  298. package/dist/src/session/SessionStateStore.js +81 -0
  299. package/dist/src/session/SessionStateStore.test.js +58 -0
  300. package/dist/src/session/types.js +2 -0
  301. package/dist/src/settings.runtime.contract.test.js +50 -0
  302. package/dist/src/shared/types.contract.test.js +107 -0
  303. package/dist/src/shared/types.js +22 -0
  304. package/dist/src/sidecar.build.lock.contract.test.js +201 -0
  305. package/dist/src/sidecar.freshness.contract.test.js +184 -0
  306. package/dist/src/sidecar.replacement.boundary.contract.test.js +131 -0
  307. package/dist/src/sidecar.supply.readiness.contract.test.js +155 -0
  308. package/dist/src/simulation.worker.offline.test.js +104 -0
  309. package/dist/src/source_manager.loadflow.test.js +46 -0
  310. package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
  311. package/dist/src/storage.provider.capacitor.content.contract.test.js +4 -1
  312. package/dist/src/storage.provider.contract.test.js +152 -1
  313. package/dist/src/tauri.frontend.build.contract.test.js +68 -0
  314. package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
  315. package/dist/src/tauri.window.evidence.execution.test.js +68 -0
  316. package/dist/src/utils/RuntimePaths.js +10 -13
  317. package/dist/src/utils/RuntimePaths.test.js +27 -0
  318. package/dist/src/utils/platform.js +153 -0
  319. package/dist/src/windows.installer.build.test.js +109 -0
  320. package/dist/src/windows.installer.payload.test.js +76 -0
  321. package/dist/src/windows.installer.runtime.test.js +69 -0
  322. package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
  323. package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
  324. package/dist/src/workflows/types.js +2 -0
  325. package/dist/src/workspace/WorkspaceRegistry.js +135 -0
  326. package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
  327. package/dist/src/workspace/types.js +2 -0
  328. package/package.json +80 -15
@@ -0,0 +1,264 @@
1
+ (function attachMobileSemanticComparator(root, factory) {
2
+ const api = factory();
3
+ if (typeof module === 'object' && module.exports) {
4
+ module.exports = api;
5
+ }
6
+ if (root) {
7
+ root.NoteConnectionMobileSemanticComparator = api;
8
+ }
9
+ }(typeof globalThis !== 'undefined' ? globalThis : this, function createMobileSemanticComparator() {
10
+ 'use strict';
11
+
12
+ const SOURCE_URI_PREFIX = 'note://workspace/v1/';
13
+ const MAX_DIAGNOSTICS = 64;
14
+
15
+ function normalizeText(value) {
16
+ const text = String(value || '').trim();
17
+ return typeof text.normalize === 'function' ? text.normalize('NFC') : text;
18
+ }
19
+
20
+ function normalizePath(value) {
21
+ const text = normalizeText(value)
22
+ .replace(/\\/g, '/')
23
+ .replace(/^\/+/, '')
24
+ .replace(/^knowledge_base\//i, '');
25
+ const segments = [];
26
+ for (const segment of text.split('/')) {
27
+ if (!segment || segment === '.') {
28
+ continue;
29
+ }
30
+ if (segment === '..') {
31
+ if (segments.length === 0) {
32
+ return '';
33
+ }
34
+ segments.pop();
35
+ continue;
36
+ }
37
+ segments.push(segment);
38
+ }
39
+ return segments.join('/').replace(/\.(?:md|markdown)$/i, '').toLowerCase();
40
+ }
41
+
42
+ function canonicalIdFromSourceUri(sourceUri) {
43
+ const normalized = normalizeText(sourceUri);
44
+ if (!normalized.startsWith(SOURCE_URI_PREFIX)) {
45
+ return '';
46
+ }
47
+ try {
48
+ const decoded = normalized.slice(SOURCE_URI_PREFIX.length)
49
+ .split('/')
50
+ .map((segment) => decodeURIComponent(segment))
51
+ .join('/');
52
+ return normalizePath(decoded);
53
+ } catch (_error) {
54
+ return '';
55
+ }
56
+ }
57
+
58
+ function normalizeSourceUri(sourceUri) {
59
+ const normalized = normalizeText(sourceUri);
60
+ if (!normalized) {
61
+ return '';
62
+ }
63
+ const canonicalId = canonicalIdFromSourceUri(normalized);
64
+ return canonicalId ? `${SOURCE_URI_PREFIX}${canonicalId.split('/').map(encodeURIComponent).join('/')}.md` : normalized;
65
+ }
66
+
67
+ function nodeCanonicalId(node) {
68
+ return normalizePath(node && node.canonicalId)
69
+ || canonicalIdFromSourceUri(node && node.sourceUri)
70
+ || normalizePath(node && node.id);
71
+ }
72
+
73
+ function nodeIdentity(node) {
74
+ const canonicalId = nodeCanonicalId(node);
75
+ if (canonicalId) {
76
+ return `canonical:${canonicalId}`;
77
+ }
78
+ const sourceUri = normalizeSourceUri(node && node.sourceUri);
79
+ if (sourceUri) {
80
+ return `uri:${sourceUri}`;
81
+ }
82
+ const legacyId = normalizeText(node && node.id).toLowerCase();
83
+ if (legacyId) {
84
+ return `legacy:${legacyId}`;
85
+ }
86
+ throw new Error('Semantic parity requires every node to expose an identity.');
87
+ }
88
+
89
+ function nodeSignature(node) {
90
+ return {
91
+ canonicalId: nodeCanonicalId(node),
92
+ sourceUri: normalizeSourceUri(node && node.sourceUri),
93
+ };
94
+ }
95
+
96
+ function endpointIdentity(rawEndpoint, rawUri, nodeById) {
97
+ const endpointId = rawEndpoint && typeof rawEndpoint === 'object'
98
+ ? normalizeText(rawEndpoint.id)
99
+ : normalizeText(rawEndpoint);
100
+ const node = nodeById.get(endpointId) || nodeById.get(endpointId.toLowerCase());
101
+ const endpointUri = normalizeSourceUri(rawUri) || normalizeSourceUri(node && node.sourceUri);
102
+ const canonicalId = nodeCanonicalId(node) || canonicalIdFromSourceUri(rawUri);
103
+ if (canonicalId) {
104
+ return {
105
+ identity: `canonical:${canonicalId}`,
106
+ sourceUri: endpointUri,
107
+ };
108
+ }
109
+ if (endpointUri) {
110
+ return {
111
+ identity: `uri:${endpointUri}`,
112
+ sourceUri: endpointUri,
113
+ };
114
+ }
115
+ if (endpointId) {
116
+ return {
117
+ identity: `legacy:${endpointId.toLowerCase()}`,
118
+ sourceUri: '',
119
+ };
120
+ }
121
+ throw new Error('Semantic parity requires every edge endpoint to resolve.');
122
+ }
123
+
124
+ function semanticEdge(rawEdge, nodeById) {
125
+ if (!rawEdge || typeof rawEdge !== 'object') {
126
+ throw new Error('Semantic parity requires every edge to be an object.');
127
+ }
128
+ const source = endpointIdentity(rawEdge.source || rawEdge.from, rawEdge.sourceUri, nodeById);
129
+ const target = endpointIdentity(rawEdge.target || rawEdge.to, rawEdge.targetUri, nodeById);
130
+ const type = normalizeText(rawEdge.type) || 'association';
131
+ const kind = normalizeText(rawEdge.kind).toLowerCase() || 'explicit';
132
+ const provenance = normalizeText(rawEdge.provenance) || type;
133
+ return {
134
+ source: source.identity,
135
+ target: target.identity,
136
+ sourceUri: source.sourceUri,
137
+ targetUri: target.sourceUri,
138
+ type,
139
+ kind,
140
+ provenance,
141
+ };
142
+ }
143
+
144
+ function edgeKey(edge) {
145
+ return [
146
+ edge.source,
147
+ edge.target,
148
+ edge.sourceUri,
149
+ edge.targetUri,
150
+ edge.type,
151
+ edge.kind,
152
+ edge.provenance,
153
+ ].join('|');
154
+ }
155
+
156
+ function buildIndex(projection, side) {
157
+ if (!projection || typeof projection !== 'object') {
158
+ throw new Error(`${side} projection must be an object.`);
159
+ }
160
+ const nodes = Array.isArray(projection.nodes) ? projection.nodes : [];
161
+ const edges = Array.isArray(projection.edges) ? projection.edges : [];
162
+ const nodeByIdentity = new Map();
163
+ const nodeById = new Map();
164
+ nodes.forEach((node) => {
165
+ const identity = nodeIdentity(node);
166
+ if (nodeByIdentity.has(identity)) {
167
+ throw new Error(`${side} projection contains duplicate semantic node identity: ${identity}.`);
168
+ }
169
+ const id = normalizeText(node && node.id);
170
+ if (!id) {
171
+ throw new Error(`${side} projection contains a node without an id.`);
172
+ }
173
+ nodeByIdentity.set(identity, {
174
+ identity,
175
+ signature: nodeSignature(node),
176
+ });
177
+ nodeById.set(id, node);
178
+ nodeById.set(id.toLowerCase(), node);
179
+ });
180
+
181
+ const edgeByKey = new Map();
182
+ edges.forEach((edge) => {
183
+ const semantic = semanticEdge(edge, nodeById);
184
+ const key = edgeKey(semantic);
185
+ if (edgeByKey.has(key)) {
186
+ throw new Error(`${side} projection contains duplicate semantic edge: ${key}.`);
187
+ }
188
+ edgeByKey.set(key, semantic);
189
+ });
190
+ return { nodeByIdentity, edgeByKey };
191
+ }
192
+
193
+ function boundedDiagnostics(values) {
194
+ return values.sort().slice(0, MAX_DIAGNOSTICS);
195
+ }
196
+
197
+ function compareSemanticProjections(leftProjection, rightProjection) {
198
+ const left = buildIndex(leftProjection, 'left');
199
+ const right = buildIndex(rightProjection, 'right');
200
+ const missingNodes = [];
201
+ const extraNodes = [];
202
+ const nodeMismatches = [];
203
+ left.nodeByIdentity.forEach((leftNode, identity) => {
204
+ const rightNode = right.nodeByIdentity.get(identity);
205
+ if (!rightNode) {
206
+ missingNodes.push(identity);
207
+ return;
208
+ }
209
+ if (JSON.stringify(leftNode.signature) !== JSON.stringify(rightNode.signature)) {
210
+ nodeMismatches.push({ identity, left: leftNode.signature, right: rightNode.signature });
211
+ }
212
+ });
213
+ right.nodeByIdentity.forEach((_rightNode, identity) => {
214
+ if (!left.nodeByIdentity.has(identity)) {
215
+ extraNodes.push(identity);
216
+ }
217
+ });
218
+
219
+ const missingEdges = [];
220
+ const extraEdges = [];
221
+ left.edgeByKey.forEach((_edge, key) => {
222
+ if (!right.edgeByKey.has(key)) {
223
+ missingEdges.push(key);
224
+ }
225
+ });
226
+ right.edgeByKey.forEach((_edge, key) => {
227
+ if (!left.edgeByKey.has(key)) {
228
+ extraEdges.push(key);
229
+ }
230
+ });
231
+
232
+ return {
233
+ equal: missingNodes.length === 0
234
+ && extraNodes.length === 0
235
+ && nodeMismatches.length === 0
236
+ && missingEdges.length === 0
237
+ && extraEdges.length === 0,
238
+ left: { nodeCount: left.nodeByIdentity.size, edgeCount: left.edgeByKey.size },
239
+ right: { nodeCount: right.nodeByIdentity.size, edgeCount: right.edgeByKey.size },
240
+ missingNodes: boundedDiagnostics(missingNodes),
241
+ extraNodes: boundedDiagnostics(extraNodes),
242
+ nodeMismatches: nodeMismatches.slice(0, MAX_DIAGNOSTICS),
243
+ missingEdges: boundedDiagnostics(missingEdges),
244
+ extraEdges: boundedDiagnostics(extraEdges),
245
+ };
246
+ }
247
+
248
+ function assertSemanticParity(leftProjection, rightProjection, label) {
249
+ const comparison = compareSemanticProjections(leftProjection, rightProjection);
250
+ if (!comparison.equal) {
251
+ const prefix = label ? `${label}: ` : '';
252
+ const error = new Error(`${prefix}semantic projection parity failed: ${JSON.stringify(comparison)}`);
253
+ error.comparison = comparison;
254
+ throw error;
255
+ }
256
+ return comparison;
257
+ }
258
+
259
+ return Object.freeze({
260
+ canonicalIdFromSourceUri,
261
+ compareSemanticProjections,
262
+ assertSemanticParity,
263
+ });
264
+ }));
@@ -249,3 +249,52 @@ input[type="checkbox"] {
249
249
  align-items: flex-start;
250
250
  }
251
251
  }
252
+
253
+ /* ── Agent Tools ── */
254
+ .badge {
255
+ background: var(--accent);
256
+ color: var(--bg-0);
257
+ font-size: 0.75rem;
258
+ padding: 0.15em 0.5em;
259
+ border-radius: 8px;
260
+ margin-left: 0.5em;
261
+ vertical-align: middle;
262
+ }
263
+ .agent-tool-card {
264
+ background: var(--card);
265
+ border: 1px solid var(--border);
266
+ border-radius: 8px;
267
+ padding: 0.6em 0.9em;
268
+ margin: 0.3em 0;
269
+ display: flex;
270
+ flex-direction: column;
271
+ gap: 0.25em;
272
+ }
273
+ .agent-tool-card.auto-exec {
274
+ border-left: 3px solid #4caf50;
275
+ }
276
+ .agent-tool-header {
277
+ display: flex;
278
+ justify-content: space-between;
279
+ align-items: center;
280
+ }
281
+ .agent-tool-name {
282
+ font-weight: 600;
283
+ font-size: 0.85rem;
284
+ }
285
+ .agent-tool-level {
286
+ font-size: 0.65rem;
287
+ padding: 0.1em 0.4em;
288
+ border-radius: 4px;
289
+ text-transform: uppercase;
290
+ opacity: 0.85;
291
+ }
292
+ .level-safe { background: #1b5e20; color: #a5d6a7; }
293
+ .level-requires-active-file { background: #0d47a1; color: #90caf9; }
294
+ .level-requires-selection { background: #e65100; color: #ffcc80; }
295
+ .level-interactive-ui { background: #4a148c; color: #ce93d8; }
296
+ .agent-tool-params {
297
+ font-size: 0.7rem;
298
+ opacity: 0.6;
299
+ font-family: monospace;
300
+ }
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta
7
7
  http-equiv="Content-Security-Policy"
8
- content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' http://127.0.0.1:* http://localhost:* tauri://localhost http://tauri.localhost; object-src 'none'; base-uri 'self'; frame-ancestors 'self'; form-action 'self';"
8
+ content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' ipc: http://127.0.0.1:* http://localhost:* http://ipc.localhost https://ipc.localhost tauri://localhost http://tauri.localhost https://tauri.localhost; object-src 'none'; base-uri 'self'; form-action 'self';"
9
9
  />
10
10
  <title>NoteMD Workspace</title>
11
11
  <link rel="stylesheet" href="notemd.css" />
@@ -146,6 +146,12 @@
146
146
  </div>
147
147
  </section>
148
148
 
149
+ <section class="panel" id="agent-tools-panel">
150
+ <h2>Agent Tools <span class="badge" id="agent-op-count"></span></h2>
151
+ <p class="subtitle">Auto-discovered operations from the Notemd CLI registry. Safe operations can be auto-executed by the Agent Workspace.</p>
152
+ <div class="grid two" id="agent-tools-grid"></div>
153
+ </section>
154
+
149
155
  <section class="panel">
150
156
  <h2>Logs</h2>
151
157
  <pre id="log-output" class="log-output"></pre>
@@ -801,4 +801,68 @@
801
801
  );
802
802
  }
803
803
  });
804
+
805
+ // ── Agent Tools: fetch & render CLI capability manifest ──
806
+ async function loadAgentTools() {
807
+ const grid = document.getElementById('agent-tools-grid');
808
+ const badge = document.getElementById('agent-op-count');
809
+ if (!grid || !badge) return;
810
+
811
+ try {
812
+ const res = await fetch('/api/notemd/agent-manifest');
813
+ if (!res.ok) throw new Error('agent-manifest fetch failed: ' + res.status);
814
+ const data = await res.json();
815
+ const manifest = data.manifest;
816
+ if (!manifest || !Array.isArray(manifest.operations)) return;
817
+
818
+ badge.textContent = manifest.agentExecutableCount + ' auto / ' + manifest.totalOperations + ' total';
819
+
820
+ const safeLabel = function (level) {
821
+ switch (level) {
822
+ case 'safe': return 'auto';
823
+ case 'requires-active-file': return 'file';
824
+ case 'requires-selection': return 'select';
825
+ case 'interactive-ui': return 'ui';
826
+ default: return level;
827
+ }
828
+ };
829
+
830
+ manifest.operations.forEach(function (op) {
831
+ var card = document.createElement('div');
832
+ card.className = 'agent-tool-card' + (op.agentAutoExecutable ? ' auto-exec' : '');
833
+ card.title = op.operationId + '\nContext: ' + op.requiredContext + '\nSide Effects: ' + op.sideEffectClass;
834
+
835
+ var header = document.createElement('div');
836
+ header.className = 'agent-tool-header';
837
+
838
+ var name = document.createElement('span');
839
+ name.className = 'agent-tool-name';
840
+ name.textContent = op.description;
841
+
842
+ var level = document.createElement('span');
843
+ level.className = 'agent-tool-level level-' + op.automationLevel;
844
+ level.textContent = safeLabel(op.automationLevel);
845
+
846
+ var params = document.createElement('div');
847
+ params.className = 'agent-tool-params';
848
+ if (op.requiredParams.length > 0) {
849
+ params.textContent = 'params: ' + op.requiredParams.join(', ');
850
+ } else {
851
+ params.textContent = 'no required params';
852
+ }
853
+
854
+ header.appendChild(name);
855
+ header.appendChild(level);
856
+ card.appendChild(header);
857
+ card.appendChild(params);
858
+ grid.appendChild(card);
859
+ });
860
+
861
+ appendLog('Agent Tools: loaded ' + manifest.totalOperations + ' operations (' + manifest.agentExecutableCount + ' auto-executable)', 'info');
862
+ } catch (error) {
863
+ appendLog('Agent Tools failed: ' + (error instanceof Error ? error.message : String(error)), 'warn');
864
+ }
865
+ }
866
+
867
+ loadAgentTools();
804
868
  })();
@@ -40,6 +40,12 @@
40
40
  </select>
41
41
  </div>
42
42
 
43
+ <div class="toolbar-group">
44
+ <button id="btn-toggle-learning-workbench" class="icon-btn" title="Toggle Learning Workbench">
45
+ Workbench
46
+ </button>
47
+ </div>
48
+
43
49
  <div class="toolbar-group right">
44
50
  <button id="btn-exit-path" class="icon-btn" title="Exit Path Mode">
45
51
  ❌ Exit
@@ -59,14 +65,118 @@
59
65
  </div>
60
66
  </div>
61
67
 
68
+ <!-- Learning Workbench Sidebar -->
69
+ <div
70
+ id="learning-workbench-sidebar"
71
+ class="path-sidebar workbench-sidebar"
72
+ style="display: none"
73
+ >
74
+ <div class="sidebar-header">
75
+ <h3>Learning Workbench</h3>
76
+ <button id="btn-close-learning-workbench" class="close-btn">&times;</button>
77
+ </div>
78
+ <div class="sidebar-content workbench-content">
79
+ <div class="workbench-field">
80
+ <label for="learning-user-id">Learner ID</label>
81
+ <input
82
+ id="learning-user-id"
83
+ type="text"
84
+ placeholder="path_user_default"
85
+ />
86
+ </div>
87
+ <div class="workbench-row">
88
+ <button id="btn-refresh-learning-workbench" class="btn-small">Refresh</button>
89
+ <button id="btn-ingest-focus-node" class="btn-small">Ingest Focus</button>
90
+ <button id="btn-run-learning-session" class="btn-small">Run Session</button>
91
+ <button id="btn-run-retest-session" class="btn-small">Run Retest</button>
92
+ </div>
93
+ <div id="learning-workbench-status" class="workbench-status">Ready.</div>
94
+ <div id="learning-workbench-updated-at" class="workbench-updated-at">Last updated: -</div>
95
+
96
+ <div class="workbench-section">
97
+ <h4>Quality Snapshot</h4>
98
+ <div class="workbench-row">
99
+ <button id="btn-set-quality-baseline" class="btn-small" type="button">Set Baseline</button>
100
+ <button id="btn-evaluate-quality-gates" class="btn-small" type="button">Evaluate Gates</button>
101
+ </div>
102
+ <ul id="learning-quality-summary" class="workbench-list">
103
+ <li class="muted">No quality snapshot yet.</li>
104
+ </ul>
105
+ <pre id="learning-quality-gates" class="workbench-feedback">No quality gate evaluation yet.</pre>
106
+ </div>
107
+
108
+ <div class="workbench-section">
109
+ <h4>Top Misconceptions</h4>
110
+ <ul id="learning-misconception-list" class="workbench-list">
111
+ <li class="muted">No recurring misconceptions detected.</li>
112
+ </ul>
113
+ </div>
114
+
115
+ <div class="workbench-section">
116
+ <h4>Session Actions</h4>
117
+ <ul id="learning-session-actions" class="workbench-list">
118
+ <li class="muted">No session actions yet.</li>
119
+ </ul>
120
+ </div>
121
+
122
+ <div class="workbench-section">
123
+ <h4>Tutor Feedback</h4>
124
+ <pre id="learning-tutor-feedback" class="workbench-feedback">No tutor feedback yet.</pre>
125
+ </div>
126
+
127
+ <div class="workbench-section">
128
+ <h4>Session Execution</h4>
129
+ <pre id="learning-session-execution" class="workbench-feedback">No session execution yet.</pre>
130
+ </div>
131
+
132
+ <div class="workbench-section">
133
+ <h4>Session History</h4>
134
+ <div class="workbench-row">
135
+ <label for="learning-history-kind-filter">Kind</label>
136
+ <select id="learning-history-kind-filter" class="control-select">
137
+ <option value="all">All</option>
138
+ <option value="session">Session</option>
139
+ <option value="retest">Retest</option>
140
+ <option value="custom">Custom</option>
141
+ </select>
142
+ <button id="btn-learning-history-prev" class="btn-small" type="button">Prev</button>
143
+ <button id="btn-learning-history-next" class="btn-small" type="button">Next</button>
144
+ <span id="learning-history-page" class="muted">Page 1/1</span>
145
+ </div>
146
+ <div class="workbench-row">
147
+ <label for="learning-history-from-date">From</label>
148
+ <input id="learning-history-from-date" type="date" class="control-input" />
149
+ <label for="learning-history-to-date">To</label>
150
+ <input id="learning-history-to-date" type="date" class="control-input" />
151
+ <button id="btn-learning-history-apply-range" class="btn-small" type="button">Apply</button>
152
+ <button id="btn-learning-history-clear-range" class="btn-small" type="button">Clear</button>
153
+ </div>
154
+ <div id="learning-session-history-summary" class="workbench-runtime">
155
+ History summary: unavailable
156
+ </div>
157
+ <ul id="learning-session-history" class="workbench-list">
158
+ <li class="muted">No session history yet.</li>
159
+ </ul>
160
+ </div>
161
+
162
+ <div id="learning-runtime-summary" class="workbench-runtime">
163
+ Runtime: unavailable
164
+ </div>
165
+ </div>
166
+ </div>
167
+
62
168
  <!-- Reading Mode Dependencies -->
63
169
  <script src="libs/marked.min.js"></script>
64
170
  <link rel="stylesheet" href="libs/katex/katex.min.css" />
65
171
  <script src="libs/katex/katex.min.js"></script>
66
172
  <script src="libs/katex/contrib/auto-render.min.js"></script>
67
173
  <script src="libs/mermaid.min.js"></script>
68
- <script src="runtime_bridge.js"></script>
69
- <script src="storage_provider.js"></script>
174
+ <script src="runtime_bridge.js"></script>
175
+ <script src="knowledge_projection_contract.js"></script>
176
+ <script src="knowledge_projection_store.js"></script>
177
+ <script src="mobile_exact_analyzer.js"></script>
178
+ <script src="mobile_identity_contract.js"></script>
179
+ <script src="storage_provider.js"></script>
70
180
  <script src="reader.js"></script>
71
181
 
72
182
  <!-- Reading Window -->
@@ -97,6 +207,7 @@
97
207
 
98
208
  <!-- Scripts -->
99
209
  <script src="i18n.js"></script>
210
+ <script src="path_modules_bridge.js"></script>
100
211
  <script src="path_app.js"></script>
101
212
  </body>
102
213
  </html>