mcard-studio 0.0.1 → 0.0.3
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/README.md +3 -0
- package/astro.config.mjs +46 -2
- package/bin/mcard-studio.mjs +1 -1
- package/cli/lib/runtimeContext.mjs +6 -3
- package/dist/client/_astro/{ChartAnalyticsViewlet.Cevj0EOs.js → ChartAnalyticsViewlet.CBW-JyA3.js} +1 -1
- package/dist/client/_astro/ClmPcardViewlet.cvKsR2ng.js +3 -0
- package/dist/client/_astro/D3GraphViewlet.8YEIrCGL.js +2 -0
- package/dist/client/_astro/DockviewSpatialWorkbench.BTd66LPl.js +12 -0
- package/dist/client/_astro/DocumentViewlets.KY1HcNka.js +2 -0
- package/dist/client/_astro/DxfViewlet.B3N5zpZR.js +1 -0
- package/dist/client/_astro/ExcalidrawWhiteboardViewlet.CMJGCQN4.js +1 -0
- package/dist/client/_astro/{FaroVCardSpanInstrumenter.BIk2NhJY.js → FaroVCardSpanInstrumenter.ClIqZujq.js} +1 -1
- package/dist/client/_astro/{FontSpecimenViewlet.CpONhJh0.js → FontSpecimenViewlet.ChIyr0B8.js} +1 -1
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.D3FSc061.js +1 -0
- package/dist/client/_astro/{ImageViewlet.CHeNvX6L.js → ImageViewlet.Cs-u7-wt.js} +1 -1
- package/dist/client/_astro/{KatexFormulaViewlet.Cy_InWOK.js → KatexFormulaViewlet.0nOzV_qD.js} +1 -1
- package/dist/client/_astro/KoishiChatViewlet.DLsMmwdb.js +16 -0
- package/dist/client/_astro/MCardLibraryHarness.WBT9W10S.js +2 -0
- package/dist/client/_astro/{MarkdownViewlet.qoPlM-TZ.js → MarkdownViewlet.BIolkNXf.js} +25 -25
- package/dist/client/_astro/{MermaidDiagramViewlet.RnwDfQl6.js → MermaidDiagramViewlet.CkRk7QsS.js} +1 -1
- package/dist/client/_astro/PCardRendererBridge.DhaRSprd.js +1 -0
- package/dist/client/_astro/RendererPCardRegistry.brM2KiQs.js +1 -0
- package/dist/client/_astro/{SchemaYamlViewlet.D6HVdmrq.js → SchemaYamlViewlet.Bc7nkK4M.js} +1 -1
- package/dist/client/_astro/{ShellContainer.astro_astro_type_script_index_0_lang.2oi8fhQo.js → ShellContainer.astro_astro_type_script_index_0_lang.5q1gCLvf.js} +1 -1
- package/dist/client/_astro/{Spatial3dViewlet.CCYBSSib.js → Spatial3dViewlet.C-jjhr0A.js} +1 -1
- package/dist/client/_astro/{StudioLayout.CBgiVbeb.css → StudioLayout.CX8XGtZV.css} +1 -1
- package/dist/client/_astro/StudioWorkbench.B1QwGHWM.js +7 -0
- package/dist/client/_astro/{SvgViewlet.BxlWQ-JX.js → SvgViewlet.uGxvb06H.js} +1 -1
- package/dist/client/_astro/{TerminalView.DWZR-hUa.js → TerminalView.DP7G7E1m.js} +4 -4
- package/dist/client/_astro/{ThemeSettingsViewlet.Cb1r8fWw.js → ThemeSettingsViewlet.UaTHcGnF.js} +1 -1
- package/dist/client/_astro/{TikzDiagramViewlet.CqY7VTeP.js → TikzDiagramViewlet.O8MJyXfT.js} +1 -1
- package/dist/client/_astro/VideoPlayerViewlet.-ycmo3kY.js +1 -0
- package/dist/client/_astro/WebappZenViewlet.PNce4u2T.js +1 -0
- package/dist/client/_astro/{WelcomeViewport.LwKTA6h7.js → WelcomeViewport.CZ6RxGSw.js} +1 -1
- package/dist/client/_astro/{agentIdentityCredentialService.BtKVsl2C.js → agentIdentityCredentialService.BEtZzBlO.js} +5 -5
- package/dist/client/_astro/cardTypeDetector.C2HH5RnU.js +1 -0
- package/dist/client/_astro/disposable.BmlxZrDf.js +1 -0
- package/dist/client/_astro/{markdownService.D-tM2RYx.js → markdownService.CpuKl0vp.js} +1 -1
- package/dist/client/_astro/{mcardStore.BiAvqM-D.js → mcardStore.nSWnzeLg.js} +2 -2
- package/dist/client/_astro/mcardVfs.BSdys1Y7.js +3 -0
- package/dist/client/_astro/pathsConfig.CSBBSzwH.js +2 -0
- package/dist/client/_astro/polyfills.Bi7kO8cu.js +1 -0
- package/dist/client/_astro/rendererEventBus.DirFDmGw.js +1 -0
- package/dist/client/_astro/themeStore.BajxvCga.js +1 -0
- package/dist/client/_astro/{tikzCompiler.DFojjdxR.js → tikzCompiler.-fXMNQpz.js} +1 -1
- package/dist/client/_astro/{useMCardHydration.Co47OH3D.js → useMCardHydration.Bjj_N5Gv.js} +1 -1
- package/dist/client/_astro/vendor-ai.D6NcJ6lu.js +69 -0
- package/dist/client/_astro/vendor-clm-kernel.B0kxq3g4.js +108 -0
- package/dist/client/_astro/vfsHandles.D4Pq18pW.js +1 -0
- package/dist/client/_astro/vfsPersistence.DVrd1BZj.js +1 -0
- package/dist/client/_astro/vfsTransactions.DBNtFuRz.js +1 -0
- package/dist/client/_astro/{workspaceStore.CXakha4Y.js → workspaceStore.DUHW2YBc.js} +1 -1
- package/dist/client/js/buffer-polyfill.js +14 -0
- package/dist/server/chunks/{StudioLayout_D163irJ0.mjs → StudioLayout_taayQJ5b.mjs} +2 -2
- package/dist/server/chunks/{_.._ZXsz792-.mjs → _.._CoQKwo62.mjs} +137 -91
- package/dist/server/chunks/{_handle__D_cIJYrU.mjs → _handle__D8dKQPUS.mjs} +3 -3
- package/dist/server/chunks/{cardTypeDetector_CyW1Xnmy.mjs → cardTypeDetector_C55M_HWS.mjs} +9 -0
- package/dist/server/chunks/{cards_B89BvF6W.mjs → cards_rVOc8K6H.mjs} +2 -2
- package/dist/server/chunks/cas_DTxlZ4Le.mjs +68 -0
- package/dist/server/chunks/{dispatch_DOwSKukU.mjs → dispatch_BTW4E_BJ.mjs} +8 -7
- package/dist/server/chunks/{dispatch_CxWKiHpn.mjs → dispatch_MbkljUxD.mjs} +8 -8
- package/dist/server/chunks/{export_DRouradA.mjs → export_DkEwDE2T.mjs} +3 -3
- package/dist/server/chunks/{health_Dfa5I0-X.mjs → health_cRt0M0yu.mjs} +1 -1
- package/dist/server/chunks/{mcard-library_DvPPUs9_.mjs → mcard-library_CLHvyslV.mjs} +1 -1
- package/dist/server/chunks/{mcardVfs_CeezzRvt.mjs → mcardVfs_DvNburKb.mjs} +5 -30
- package/dist/server/chunks/{move__RFvIDkq.mjs → move_DYcaXBLV.mjs} +6 -6
- package/dist/server/chunks/{pathsConfig_CgNYYLVm.mjs → pathsConfig_Dack-p2f.mjs} +13 -3
- package/dist/server/chunks/{proxy_CrWJQIBe.mjs → proxy_CMbbdBPW.mjs} +2 -2
- package/dist/server/chunks/{raw_DzNDaDVP.mjs → raw_C97sJWhg.mjs} +59 -26
- package/dist/server/chunks/{serverBootstrap_XKo2s6Ha.mjs → serverBootstrap_BDdSRIu5.mjs} +2 -2
- package/dist/server/chunks/tree_BwmO-pTe.mjs +186 -0
- package/dist/server/chunks/vfsCore_DIKpk-pk.mjs +98 -0
- package/dist/server/chunks/{vfsTreeScan_CKp7kMt9.mjs → vfsTreeScan_CRoCluPB.mjs} +18 -10
- package/dist/server/chunks/workspaceRoot_CRx3taID.mjs +157 -0
- package/dist/server/chunks/{write_popiFsO7.mjs → write_BLsmsTIx.mjs} +6 -5
- package/dist/server/chunks/{ws-server-init_CkcgcI5V.mjs → ws-server-init_Cfft7U5u.mjs} +343 -298
- package/dist/server/entry.mjs +8 -4
- package/dist/server/entry2.mjs +67 -28
- package/dist/server/virtual_astro_middleware.mjs +2 -2
- package/package.json +2 -2
- package/public/js/buffer-polyfill.js +14 -0
- package/src/components/studio/views/cardViewlets/ClmRegistryComponentViewlet.tsx +133 -0
- package/src/components/studio/views/cardViewlets/DxfViewlet.tsx +230 -0
- package/src/components/studio/views/cardViewlets/VideoPlayerViewlet.tsx +4 -4
- package/src/components/studio/views/cardViewlets/coreViewletDefs.ts +2 -2
- package/src/components/studio/views/cardViewlets/documents/AudioPlayerViewlet.tsx +15 -3
- package/src/components/studio/views/cardViewlets/documents/PdfViewlet.tsx +25 -7
- package/src/components/studio/views/cardViewlets/markdown/stages/wikilinkStage.ts +2 -1
- package/src/components/studio/views/cardViewlets/mediaViewletDefs.ts +21 -1
- package/src/components/studio/views/cardViewlets/webapp/WebappCanvas.tsx +40 -15
- package/src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx +108 -0
- package/src/components/studio/views/cardViewlets/webapp/WebappZenViewlet.tsx +23 -30
- package/src/components/studio/views/fileTree/MCardFileTree.tsx +71 -54
- package/src/components/studio/views/fileTree/hooks/useFileTreeSync.ts +0 -1
- package/src/components/studio/views/fileTree/hooks/usePartitionedTrees.ts +68 -23
- package/src/components/studio/views/fileTree/hooks/useSectionAccordion.ts +21 -11
- package/src/components/studio/views/functions/UnifiedFunctionExplorerViewlet.tsx +168 -0
- package/src/components/studio/views/history/HistoryPanel.tsx +110 -0
- package/src/components/studio/views/lineage/LineagePanel.tsx +152 -0
- package/src/components/studio/views/navigation/HandleLineageDrawer.tsx +89 -0
- package/src/components/studio/views/navigation/MultiCardCollectionBrowser.tsx +154 -0
- package/src/components/studio/views/pills/HashPill.tsx +101 -0
- package/src/components/studio/views/residency/ResidencyIndicator.tsx +82 -0
- package/src/config/app_config.json +3 -3
- package/src/core/projection/catalog.ts +105 -0
- package/src/core/projection/collection.ts +148 -0
- package/src/core/projection/handleSubscription.ts +132 -0
- package/src/core/projection/index.ts +4 -0
- package/src/core/projection/selectors.ts +29 -0
- package/src/core/projection/views.ts +242 -0
- package/src/core/refinement/designMetrics.ts +104 -0
- package/src/core/refinement/fibrationProjector.ts +142 -0
- package/src/core/refinement/lagrangianEngine.ts +137 -0
- package/src/core/refinement/refinementCommands.ts +82 -0
- package/src/core/viewport/deviceArchetypeRegistry.ts +177 -0
- package/src/core/viewport/viewportAudit.ts +150 -0
- package/src/edge/storeFilter.d.ts +4 -0
- package/src/edge/storeFilter.js +54 -0
- package/src/edge/storeFilter.ts +52 -0
- package/src/layouts/StudioLayout.astro +1 -0
- package/src/lib/cryptoPolyfill.js +77 -1
- package/src/lib/fsPolyfill.js +65 -0
- package/src/lib/urlPolyfill.js +21 -0
- package/src/lib/zlibPolyfill.js +35 -0
- package/src/packages/mcard-studio/package.json +2 -2
- package/src/packages/mcard-studio/type/legacyMapping.ts +5 -0
- package/src/packages/mcard-studio/viewlets/manifests.ts +2 -0
- package/src/packages/mcard-studio/viewlets/moduleMap.ts +12 -0
- package/src/packages/mcard-studio/viewlets/refinementManifests.ts +114 -0
- package/src/pages/api/dispatch.ts +3 -2
- package/src/pages/api/vfs/cas.ts +114 -0
- package/src/pages/api/vfs/move.ts +5 -5
- package/src/pages/api/vfs/raw.ts +72 -27
- package/src/pages/api/vfs/tree.ts +130 -11
- package/src/pages/api/vfs/write.ts +5 -4
- package/src/pages/index.astro +75 -0
- package/src/server/api/kernelDispatch.ts +8 -8
- package/src/server/artifactCollectionService.ts +4 -7
- package/src/server/artifactRepository.ts +4 -3
- package/src/server/clmRunner.mjs +1 -1
- package/src/server/collectionOwner.mjs +5 -5
- package/src/server/effects/executionPersistenceService.mjs +11 -11
- package/src/server/effects/resultSealingService.mjs +2 -2
- package/src/server/fileIngestService.mjs +21 -9
- package/src/server/fileWatcherService.mjs +4 -1
- package/src/server/handlers/fileChangeHandler.mjs +18 -10
- package/src/server/handlers/saveExecutionLogHandler.mjs +6 -6
- package/src/server/notificationService.mjs +14 -1
- package/src/server/scripts/buildSeedingMemory.mjs +3 -3
- package/src/server/serverMemoryRepository.ts +41 -59
- package/src/server/vfsTreeScan.ts +16 -10
- package/src/server/workspaceRoot.ts +143 -5
- package/src/services/cardTypeDetector.ts +4 -0
- package/src/services/databaseSyncService.ts +30 -46
- package/src/services/inBrowserLlm/engines/litertEngine.ts +1 -1
- package/src/services/namespaceProtocolClient.ts +221 -0
- package/src/services/renderers/pcard/RendererPCardRegistry.ts +4 -66
- package/src/services/renderers/pcard/modalitySpecs.ts +125 -0
- package/src/services/renderers/pcard/types.ts +7 -1
- package/src/services/renderers/rendererEventBus.ts +5 -3
- package/src/services/unifiedFunctionExecutionService.ts +145 -0
- package/src/services/vfs/vfsCore.ts +12 -1
- package/src/services/vfs/vfsMigration.ts +95 -0
- package/src/services/vfs/vfsMutations.ts +17 -35
- package/src/services/vfs/vfsPersistence.ts +19 -24
- package/src/services/vfs/vfsSync.ts +55 -17
- package/src/services/vfs/vfsVersions.ts +23 -34
- package/src/services/workbenchExecutionPolicy.ts +183 -0
- package/src/stores/mcardCollectionStore.ts +2 -0
- package/src/styles/dockview.css +34 -0
- package/src/ui/viewlets/FibrationRefinementViewlet.tsx +155 -0
- package/src/ui/viewlets/PetriConformanceViewlet.tsx +166 -0
- package/src/ui/viewlets/ResponsiveViewportLabViewlet.tsx +175 -0
- package/src/ui/viewlets/SprintGovernanceViewlet.tsx +176 -0
- package/src/ui/viewlets/viewletFocus.ts +35 -0
- package/src/ui/viewlets/viewportLabParts.tsx +190 -0
- package/dist/client/_astro/ClmPcardViewlet.DW5Yft0E.js +0 -3
- package/dist/client/_astro/D3GraphViewlet.DAjPz1DP.js +0 -2
- package/dist/client/_astro/DockviewSpatialWorkbench.DyQjSoHd.js +0 -12
- package/dist/client/_astro/DocumentViewlets.Dm_GL3AL.js +0 -2
- package/dist/client/_astro/ExcalidrawWhiteboardViewlet.DrlW7B6G.js +0 -1
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.DGXU-3Lu.js +0 -1
- package/dist/client/_astro/KoishiChatViewlet.B0eDEMnT.js +0 -16
- package/dist/client/_astro/MCardLibraryHarness.CUJLJFBt.js +0 -2
- package/dist/client/_astro/PCardRendererBridge.BnyaE05I.js +0 -1
- package/dist/client/_astro/RendererPCardRegistry.CLr4j1Ub.js +0 -1
- package/dist/client/_astro/StudioWorkbench.CF0SOYwy.js +0 -7
- package/dist/client/_astro/VideoPlayerViewlet.DoSYmmoQ.js +0 -1
- package/dist/client/_astro/WebappZenViewlet.CQW50OhX.js +0 -1
- package/dist/client/_astro/cardTypeDetector.C9kGObMh.js +0 -1
- package/dist/client/_astro/disposable.66apX1Q2.js +0 -1
- package/dist/client/_astro/empty.DOwCrGXH.js +0 -1
- package/dist/client/_astro/mcardVfs.Bj-RA0p7.js +0 -2
- package/dist/client/_astro/path.CR60mj9W.js +0 -1
- package/dist/client/_astro/pathsConfig.D0hV34p7.js +0 -2
- package/dist/client/_astro/polyfills.DcBkS56X.js +0 -1
- package/dist/client/_astro/rendererEventBus.CyFnSRLk.js +0 -1
- package/dist/client/_astro/themeStore.zUMFLo3Q.js +0 -1
- package/dist/client/_astro/vendor-ai.CZe7UVVK.js +0 -69
- package/dist/client/_astro/vfsHandles.B-nczBRy.js +0 -1
- package/dist/client/_astro/vfsPersistence.D6zRzVML.js +0 -1
- package/dist/client/_astro/vfsTransactions.04mkEHxD.js +0 -1
- package/dist/server/chunks/cryptoPolyfill_99rxUwYC.mjs +0 -180
- package/dist/server/chunks/kernelHash_DRaj51hY.mjs +0 -5
- package/dist/server/chunks/tree_CE2BhvyJ.mjs +0 -76
- package/dist/server/chunks/vfsCore_B6nCiBl5.mjs +0 -21
- package/dist/server/chunks/workspaceRoot_DVSUbYkd.mjs +0 -71
- package/src/server/kernelHash.ts +0 -22
- package/src/server/storage/cardCollection.ts +0 -94
- package/src/server/storage/index.ts +0 -3
- package/src/server/storage/mcard.ts +0 -99
- package/src/server/storage/sqliteNodeEngine.ts +0 -121
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
import { parseMcardUri } from "clm-kernel";
|
|
5
|
+
//#region src/server/workspaceRoot.ts
|
|
6
|
+
/**
|
|
7
|
+
* Installed-package root, when the CLI provides one (Program NP · INV-NP-05).
|
|
8
|
+
* An installed app must resolve its immutable assets from the package rather
|
|
9
|
+
* than guessing from the consumer's CWD. Returns null when unset or when the
|
|
10
|
+
* candidate does not carry the sentinel, so repo/tests keep prior behavior.
|
|
11
|
+
*/
|
|
12
|
+
function installedPackageRoot(config = PATHS) {
|
|
13
|
+
const envRoot = process.env.MCARD_PACKAGE_ROOT;
|
|
14
|
+
if (!envRoot) return null;
|
|
15
|
+
const resolved = resolve(envRoot);
|
|
16
|
+
const sentinelParts = config.paths.repo_root_sentinel.split("/").filter(Boolean);
|
|
17
|
+
return existsSync(join(resolved, ...sentinelParts)) ? resolved : null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Locate the mcard-studio repository root reliably.
|
|
21
|
+
* The sentinel directory is `paths.repo_root_sentinel` (default `assets/clm`),
|
|
22
|
+
* so relocating the layout is a config change, not a code change (INV-PC-06).
|
|
23
|
+
* An explicit `MCARD_PACKAGE_ROOT` wins; otherwise the historical upward search
|
|
24
|
+
* from CWD is used.
|
|
25
|
+
*/
|
|
26
|
+
function repoRoot(config = PATHS) {
|
|
27
|
+
const installed = installedPackageRoot(config);
|
|
28
|
+
if (installed) return installed;
|
|
29
|
+
const envRepo = process.env.MCARD_REPO_ROOT;
|
|
30
|
+
if (envRepo && existsSync(resolve(envRepo))) return resolve(envRepo);
|
|
31
|
+
const sentinelParts = config.paths.repo_root_sentinel.split("/").filter(Boolean);
|
|
32
|
+
let cur = process.cwd();
|
|
33
|
+
while (cur !== "/" && dirname(cur) !== cur) {
|
|
34
|
+
if (existsSync(join(cur, "package.json")) && existsSync(join(cur, ...sentinelParts))) return cur;
|
|
35
|
+
if (existsSync(join(cur, "mcard-studio", "package.json")) && existsSync(join(cur, "mcard-studio", ...sentinelParts))) return join(cur, "mcard-studio");
|
|
36
|
+
cur = dirname(cur);
|
|
37
|
+
}
|
|
38
|
+
if (existsSync(join(process.cwd(), "mcard-studio", ...sentinelParts))) return join(process.cwd(), "mcard-studio");
|
|
39
|
+
return process.cwd();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Locate the active workspace root.
|
|
43
|
+
* `MCARD_WORKSPACE_ROOT` (env) still wins (absolute override); otherwise the
|
|
44
|
+
* configured `paths.workspace_dirname` under the repo root is used.
|
|
45
|
+
*/
|
|
46
|
+
function workspaceRoot(config = PATHS) {
|
|
47
|
+
const envRoot = process.env.MCARD_WORKSPACE_ROOT;
|
|
48
|
+
if (envRoot) return resolve(envRoot);
|
|
49
|
+
const base = process.env.MCARD_PROJECT_ROOT ? resolve(process.env.MCARD_PROJECT_ROOT) : repoRoot(config);
|
|
50
|
+
return join(base, config.paths.workspace_dirname);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Locate the active data root (chosen directory, e.g. --data-root ./data/demo_vault).
|
|
54
|
+
* Returns null if unset or if the directory does not exist.
|
|
55
|
+
*/
|
|
56
|
+
function dataRoot() {
|
|
57
|
+
const envData = process.env.MCARD_DATA_ROOT || process.env.DATA_ROOT;
|
|
58
|
+
if (envData) {
|
|
59
|
+
const res = resolve(envData);
|
|
60
|
+
if (existsSync(res)) return res;
|
|
61
|
+
const base = process.env.MCARD_PROJECT_ROOT ? resolve(process.env.MCARD_PROJECT_ROOT) : repoRoot();
|
|
62
|
+
const relRes = resolve(base, envData);
|
|
63
|
+
if (existsSync(relRes)) return relRes;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolves a locator path (e.g. 'workspace/foo' or 'assets/clm') to an absolute
|
|
69
|
+
* path on disk. When running as an installed package, the workspace lives under
|
|
70
|
+
* the host project root rather than inside the immutable package directory.
|
|
71
|
+
*/
|
|
72
|
+
function resolveHostPath(targetPath, rootDir = repoRoot(), config = PATHS) {
|
|
73
|
+
const wsDir = config.paths.workspace_dirname;
|
|
74
|
+
const wsRoot = resolve(workspaceRoot(config));
|
|
75
|
+
const dRoot = dataRoot();
|
|
76
|
+
if (resolve(targetPath) === targetPath) return targetPath;
|
|
77
|
+
let cleanRel = targetPath.trim();
|
|
78
|
+
if (cleanRel.startsWith("mcard://")) try {
|
|
79
|
+
const parsed = parseMcardUri(cleanRel);
|
|
80
|
+
if (parsed.type === "handle") cleanRel = parsed.target.replace(/^mcard:/, "");
|
|
81
|
+
else cleanRel = parsed.target;
|
|
82
|
+
} catch {
|
|
83
|
+
cleanRel = cleanRel.replace(/^mcard:\/\//, "");
|
|
84
|
+
}
|
|
85
|
+
cleanRel = cleanRel.replace(/:/g, "/").replace(/^[/\\]+/, "");
|
|
86
|
+
if (cleanRel === wsDir || cleanRel.startsWith(wsDir + "/")) {
|
|
87
|
+
const sub = cleanRel === wsDir ? "" : cleanRel.slice(wsDir.length + 1);
|
|
88
|
+
return resolve(wsRoot, sub);
|
|
89
|
+
}
|
|
90
|
+
if (dRoot) {
|
|
91
|
+
const cand1 = resolve(dRoot, cleanRel);
|
|
92
|
+
if (existsSync(cand1)) return cand1;
|
|
93
|
+
const dBasename = basename(dRoot);
|
|
94
|
+
const prefix1 = `data/${dBasename}/`;
|
|
95
|
+
const prefix2 = `${dBasename}/`;
|
|
96
|
+
if (cleanRel.startsWith(prefix1)) {
|
|
97
|
+
const stripped = cleanRel.slice(prefix1.length);
|
|
98
|
+
const cand = resolve(dRoot, stripped);
|
|
99
|
+
if (existsSync(cand)) return cand;
|
|
100
|
+
} else if (cleanRel.startsWith(prefix2)) {
|
|
101
|
+
const stripped = cleanRel.slice(prefix2.length);
|
|
102
|
+
const cand = resolve(dRoot, stripped);
|
|
103
|
+
if (existsSync(cand)) return cand;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const candRoot = resolve(rootDir, cleanRel);
|
|
107
|
+
if (existsSync(candRoot)) return candRoot;
|
|
108
|
+
const candCwd = resolve(process.cwd(), cleanRel);
|
|
109
|
+
if (existsSync(candCwd)) return candCwd;
|
|
110
|
+
if (cleanRel.startsWith("assets/")) {
|
|
111
|
+
const candStudioAsset = resolve(rootDir, cleanRel);
|
|
112
|
+
if (existsSync(candStudioAsset)) return candStudioAsset;
|
|
113
|
+
const candCwdStudioAsset = resolve(process.cwd(), "mcard-studio", cleanRel);
|
|
114
|
+
if (existsSync(candCwdStudioAsset)) return candCwdStudioAsset;
|
|
115
|
+
}
|
|
116
|
+
if (dRoot) {
|
|
117
|
+
const dBasename = basename(dRoot);
|
|
118
|
+
if (cleanRel.startsWith(`data/${dBasename}/`)) return resolve(dRoot, cleanRel.slice(`data/${dBasename}/`.length));
|
|
119
|
+
if (cleanRel.startsWith(`${dBasename}/`)) return resolve(dRoot, cleanRel.slice(`${dBasename}/`.length));
|
|
120
|
+
if (cleanRel.startsWith("cards/") || cleanRel.startsWith("guest/")) return resolve(dRoot, cleanRel);
|
|
121
|
+
}
|
|
122
|
+
return resolve(rootDir, cleanRel);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Security containment check (INV-PC-09): ensures the target path is strictly
|
|
126
|
+
* within any configured `vfs.scan_roots` directory or the resolved workspace root.
|
|
127
|
+
* This is a containment guard for the filesystem adapter — never an algebra input
|
|
128
|
+
* (INV-PC-10).
|
|
129
|
+
*/
|
|
130
|
+
function isPathAllowed(targetPath, rootDir = repoRoot(), config = PATHS) {
|
|
131
|
+
const wsDir = config.paths.workspace_dirname;
|
|
132
|
+
const wsRoot = resolve(workspaceRoot(config));
|
|
133
|
+
const resolved = resolveHostPath(targetPath, rootDir, config);
|
|
134
|
+
const dRoot = dataRoot();
|
|
135
|
+
const allowedRoots = /* @__PURE__ */ new Set([wsRoot]);
|
|
136
|
+
if (dRoot) allowedRoots.add(dRoot);
|
|
137
|
+
for (const scanRoot of config.vfs.scan_roots) if (scanRoot === wsDir) allowedRoots.add(wsRoot);
|
|
138
|
+
else allowedRoots.add(resolve(rootDir, scanRoot));
|
|
139
|
+
if (config.workspaces?.directory_projections) for (const proj of config.workspaces.directory_projections) if (proj.path === wsDir) allowedRoots.add(wsRoot);
|
|
140
|
+
else allowedRoots.add(resolve(rootDir, proj.path));
|
|
141
|
+
for (const root of allowedRoots) if (resolved === root || resolved.startsWith(root + "/")) return true;
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Mutability containment check (Sprint EX-04, INV-EX-09):
|
|
146
|
+
* Ensures targetPath is strictly within the resolved workspaceRoot directory.
|
|
147
|
+
* Read-only projections (assets, computable_knowledge, public) reject writes with false.
|
|
148
|
+
*/
|
|
149
|
+
function isPathWritable(targetPath, rootDir = repoRoot(), config = PATHS) {
|
|
150
|
+
const resolved = resolveHostPath(targetPath, rootDir, config);
|
|
151
|
+
const wsRoot = resolve(workspaceRoot(config));
|
|
152
|
+
const dRoot = dataRoot();
|
|
153
|
+
if (dRoot && (resolved === dRoot || resolved.startsWith(dRoot + "/"))) return true;
|
|
154
|
+
return resolved === wsRoot || resolved.startsWith(wsRoot + "/");
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { resolveHostPath as a, repoRoot as i, isPathAllowed as n, workspaceRoot as o, isPathWritable as r, dataRoot as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as resolveHostPath, i as repoRoot, r as isPathWritable } from "./workspaceRoot_CRx3taID.mjs";
|
|
3
3
|
import { r as json, t as error } from "./apiUtils_B3BX89fM.mjs";
|
|
4
|
-
import { t as createHash } from "./cryptoPolyfill_99rxUwYC.mjs";
|
|
5
4
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { dirname
|
|
5
|
+
import { dirname } from "node:path";
|
|
6
|
+
import { createRecord, qualify } from "clm-kernel";
|
|
7
7
|
//#region src/pages/api/vfs/write.ts
|
|
8
8
|
var write_exports = /* @__PURE__ */ __exportAll({ POST: () => POST });
|
|
9
9
|
var POST = async ({ request }) => {
|
|
@@ -16,7 +16,7 @@ var POST = async ({ request }) => {
|
|
|
16
16
|
if (content === void 0 || content === null) return error("Missing required field: content", 400);
|
|
17
17
|
const root = repoRoot();
|
|
18
18
|
if (!isPathWritable(targetPath, root)) return error("Access denied: Target path is in a read-only projection", 403);
|
|
19
|
-
const absolutePath =
|
|
19
|
+
const absolutePath = resolveHostPath(targetPath, root);
|
|
20
20
|
mkdirSync(dirname(absolutePath), { recursive: true });
|
|
21
21
|
let bytes;
|
|
22
22
|
if (encoding === "base64" && typeof content === "string") bytes = Buffer.from(content, "base64");
|
|
@@ -24,7 +24,8 @@ var POST = async ({ request }) => {
|
|
|
24
24
|
else if (Array.isArray(content) || content instanceof Uint8Array) bytes = Buffer.from(content);
|
|
25
25
|
else bytes = Buffer.from(JSON.stringify(content), "utf8");
|
|
26
26
|
writeFileSync(absolutePath, bytes);
|
|
27
|
-
const
|
|
27
|
+
const record = createRecord(bytes);
|
|
28
|
+
const hash = qualify(record).asPrefixed();
|
|
28
29
|
return json({
|
|
29
30
|
success: true,
|
|
30
31
|
path: targetPath,
|