@fellowhumans/pathmx 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/pathmx.js +400 -63
  2. package/package.json +7 -2
package/dist/pathmx.js CHANGED
@@ -100758,7 +100758,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
100758
100758
  this._exitCallback = (err) => {
100759
100759
  if (err.code !== "commander.executeSubCommandAsync") {
100760
100760
  throw err;
100761
- } else {}
100761
+ }
100762
100762
  };
100763
100763
  }
100764
100764
  return this;
@@ -139319,23 +139319,17 @@ class BuildGraph {
139319
139319
  removeNode(nodeId) {
139320
139320
  this.nodes.delete(nodeId);
139321
139321
  this.replaceEdgesFrom(nodeId, []);
139322
- const incoming = this.edgesByTarget.get(nodeId) ?? [];
139322
+ const incoming = [...this.edgesByTarget.get(nodeId) ?? []];
139323
139323
  for (const edge of incoming) {
139324
139324
  this.removeEdge(edge);
139325
139325
  }
139326
139326
  }
139327
139327
  addEdge(edge) {
139328
- this.edgesBySource.set(edge.from, [
139329
- ...this.edgesBySource.get(edge.from) ?? [],
139330
- edge
139331
- ]);
139332
- this.edgesByTarget.set(edge.to, [
139333
- ...this.edgesByTarget.get(edge.to) ?? [],
139334
- edge
139335
- ]);
139328
+ this.getOrCreateEdgeBucket(this.edgesBySource, edge.from).push(edge);
139329
+ this.getOrCreateEdgeBucket(this.edgesByTarget, edge.to).push(edge);
139336
139330
  }
139337
139331
  replaceEdgesFrom(nodeId, edges) {
139338
- const current = this.edgesBySource.get(nodeId) ?? [];
139332
+ const current = [...this.edgesBySource.get(nodeId) ?? []];
139339
139333
  for (const edge of current) {
139340
139334
  this.removeEdge(edge);
139341
139335
  }
@@ -139360,9 +139354,27 @@ class BuildGraph {
139360
139354
  this.edgesBySource.clear();
139361
139355
  this.edgesByTarget.clear();
139362
139356
  }
139357
+ diagnostics() {
139358
+ return {
139359
+ nodes: this.nodes.size,
139360
+ edges: countEdges(this.edgesBySource),
139361
+ edgesBySourceBuckets: this.edgesBySource.size,
139362
+ edgesByTargetBuckets: this.edgesByTarget.size,
139363
+ emptyEdgesBySourceBuckets: countEmptyBuckets(this.edgesBySource),
139364
+ emptyEdgesByTargetBuckets: countEmptyBuckets(this.edgesByTarget)
139365
+ };
139366
+ }
139367
+ getOrCreateEdgeBucket(index2, nodeId) {
139368
+ let edges = index2.get(nodeId);
139369
+ if (!edges) {
139370
+ edges = [];
139371
+ index2.set(nodeId, edges);
139372
+ }
139373
+ return edges;
139374
+ }
139363
139375
  removeEdge(edge) {
139364
- this.edgesBySource.set(edge.from, (this.edgesBySource.get(edge.from) ?? []).filter((current) => current !== edge));
139365
- this.edgesByTarget.set(edge.to, (this.edgesByTarget.get(edge.to) ?? []).filter((current) => current !== edge));
139376
+ removeEdgeFromIndex(this.edgesBySource, edge.from, edge);
139377
+ removeEdgeFromIndex(this.edgesByTarget, edge.to, edge);
139366
139378
  }
139367
139379
  walk(start, next) {
139368
139380
  const queue = Array.isArray(start) ? [...start] : [start];
@@ -139384,6 +139396,30 @@ class BuildGraph {
139384
139396
  return [...visited];
139385
139397
  }
139386
139398
  }
139399
+ function removeEdgeFromIndex(index2, nodeId, edge) {
139400
+ const edges = index2.get(nodeId);
139401
+ if (!edges)
139402
+ return;
139403
+ const edgeIndex = edges.indexOf(edge);
139404
+ if (edgeIndex >= 0)
139405
+ edges.splice(edgeIndex, 1);
139406
+ if (edges.length === 0)
139407
+ index2.delete(nodeId);
139408
+ }
139409
+ function countEdges(index2) {
139410
+ let count = 0;
139411
+ for (const edges of index2.values())
139412
+ count += edges.length;
139413
+ return count;
139414
+ }
139415
+ function countEmptyBuckets(index2) {
139416
+ let count = 0;
139417
+ for (const edges of index2.values()) {
139418
+ if (edges.length === 0)
139419
+ count += 1;
139420
+ }
139421
+ return count;
139422
+ }
139387
139423
  // packages/build/src/repository/node-ids.ts
139388
139424
  var sourceNodeId = (id) => `source:${id}`;
139389
139425
  var sourceDataNodeId = (id) => `source-data:${id}`;
@@ -143175,6 +143211,19 @@ function createMetadataRecordDelta(previous, current) {
143175
143211
  }
143176
143212
  return Object.keys(delta).length > 0 ? delta : undefined;
143177
143213
  }
143214
+ function createMetadataRecordDeltaForKeys(previous, current, keys2) {
143215
+ const delta = {};
143216
+ for (const key2 of keys2) {
143217
+ if (key2 in current) {
143218
+ if (!stableJsonEqual(previous[key2], current[key2])) {
143219
+ delta[key2] = current[key2];
143220
+ }
143221
+ } else if (key2 in previous) {
143222
+ delta[key2] = null;
143223
+ }
143224
+ }
143225
+ return Object.keys(delta).length > 0 ? delta : undefined;
143226
+ }
143178
143227
  function buildOutputStateToDelta(state) {
143179
143228
  return {
143180
143229
  sources: state.sources,
@@ -143185,11 +143234,11 @@ function buildOutputStateToDelta(state) {
143185
143234
  runtime: state.runtime
143186
143235
  };
143187
143236
  }
143188
- function createBuildOutputMetadataDelta(previous, current) {
143237
+ function createBuildOutputMetadataDelta(previous, current, hints) {
143189
143238
  if (!previous)
143190
143239
  return buildOutputStateToDelta(current);
143191
143240
  const delta = {};
143192
- const sources = createMetadataRecordDelta(previous.sources, current.sources);
143241
+ const sources = hints?.sourceIds ? createMetadataRecordDeltaForKeys(previous.sources, current.sources, hints.sourceIds) : createMetadataRecordDelta(previous.sources, current.sources);
143193
143242
  if (sources)
143194
143243
  delta.sources = sources;
143195
143244
  const sourceFiles = createMetadataRecordDelta(previous.sourceFiles, current.sourceFiles);
@@ -143198,17 +143247,20 @@ function createBuildOutputMetadataDelta(previous, current) {
143198
143247
  if (!stableJsonEqual(previous.missingSourceFilePaths, current.missingSourceFilePaths)) {
143199
143248
  delta.missingSourceFilePaths = current.missingSourceFilePaths;
143200
143249
  }
143201
- const renderedBlocks = createMetadataRecordDelta(previous.renderedBlocks, current.renderedBlocks);
143250
+ const renderedBlocks = hints?.blockIds ? createMetadataRecordDeltaForKeys(previous.renderedBlocks, current.renderedBlocks, hints.blockIds) : createMetadataRecordDelta(previous.renderedBlocks, current.renderedBlocks);
143202
143251
  if (renderedBlocks)
143203
143252
  delta.renderedBlocks = renderedBlocks;
143204
- const artifacts = createMetadataRecordDelta(previous.artifacts, current.artifacts);
143253
+ const artifacts = hints?.artifactPaths ? createMetadataRecordDeltaForKeys(previous.artifacts, current.artifacts, hints.artifactPaths) : createMetadataRecordDelta(previous.artifacts, current.artifacts);
143205
143254
  if (artifacts)
143206
143255
  delta.artifacts = artifacts;
143207
- if (!stableJsonEqual(previous.runtime, current.runtime)) {
143256
+ if (hints?.runtimeChanged === true || hints?.runtimeChanged === undefined && !stableJsonEqual(previous.runtime, current.runtime)) {
143208
143257
  delta.runtime = current.runtime;
143209
143258
  }
143210
143259
  return delta;
143211
143260
  }
143261
+ function isBuildOutputMetadataDeltaEmpty(delta) {
143262
+ return delta.sources === undefined && delta.sourceFiles === undefined && delta.missingSourceFilePaths === undefined && delta.renderedBlocks === undefined && delta.artifacts === undefined && delta.runtime === undefined;
143263
+ }
143212
143264
  function applyMetadataRecordDelta(target, delta) {
143213
143265
  if (!delta)
143214
143266
  return;
@@ -143750,6 +143802,46 @@ function getChangedRenderedBlockIds(changes) {
143750
143802
  }
143751
143803
  return blockIds;
143752
143804
  }
143805
+ function getChangedSourceIds2(changes) {
143806
+ const sourceIds = new Set;
143807
+ if (!changes)
143808
+ return sourceIds;
143809
+ for (const change of changes) {
143810
+ for (const nodeId of [
143811
+ ...change.dirtyNodes,
143812
+ ...change.affectedNodes,
143813
+ ...change.addedNodes,
143814
+ ...change.removedNodes
143815
+ ]) {
143816
+ const sourceId = sourceIdFromNodeId(nodeId);
143817
+ if (sourceId)
143818
+ sourceIds.add(sourceId);
143819
+ }
143820
+ }
143821
+ return sourceIds;
143822
+ }
143823
+ function getChangedArtifactPaths(artifactChanges) {
143824
+ if (!artifactChanges)
143825
+ return new Set;
143826
+ return new Set([
143827
+ ...artifactChanges.written.map((artifact) => artifact.path),
143828
+ ...artifactChanges.deleted.map((deletion) => deletion.path)
143829
+ ]);
143830
+ }
143831
+ function createBuildOutputMetadataDeltaHints(options) {
143832
+ const hasRepositoryChanges = (options.changes?.length ?? 0) > 0;
143833
+ const hasArtifactChanges = (options.artifactChanges?.written.length ?? 0) > 0 || (options.artifactChanges?.deleted.length ?? 0) > 0;
143834
+ if (!hasRepositoryChanges && !hasArtifactChanges)
143835
+ return;
143836
+ return {
143837
+ ...hasRepositoryChanges ? {
143838
+ sourceIds: getChangedSourceIds2(options.changes),
143839
+ blockIds: getChangedRenderedBlockIds(options.changes)
143840
+ } : {},
143841
+ ...hasArtifactChanges ? { artifactPaths: getChangedArtifactPaths(options.artifactChanges) } : {},
143842
+ ...options.runtimeChanged === undefined ? {} : { runtimeChanged: options.runtimeChanged }
143843
+ };
143844
+ }
143753
143845
  function createSourceEntries(ctx) {
143754
143846
  return Object.fromEntries(ctx.repository.getSources().map((source3) => [
143755
143847
  source3.id,
@@ -144292,7 +144384,12 @@ async function writeBuildOutputCache(options) {
144292
144384
  artifacts,
144293
144385
  runtime: runtime3
144294
144386
  };
144295
- if (previousState && stableJson(previousState) === stableJson(state)) {
144387
+ const delta = createBuildOutputMetadataDelta(previousState, state, createBuildOutputMetadataDeltaHints({
144388
+ changes,
144389
+ artifactChanges,
144390
+ runtimeChanged
144391
+ }));
144392
+ if (previousState && isBuildOutputMetadataDeltaEmpty(delta)) {
144296
144393
  setCachedBuildOutputState(ctx, root, state);
144297
144394
  trustedBuildCacheBlobPaths.set(ctx, collectCacheBlobPaths(state));
144298
144395
  for (const [rendered, ref] of renderedBlockRefs) {
@@ -144308,7 +144405,7 @@ async function writeBuildOutputCache(options) {
144308
144405
  await Promise.all([...blobs.values()].map((write) => writeCacheBlob(cacheStorage, write, trustedBlobPaths)));
144309
144406
  });
144310
144407
  await metadataStore.writeDelta(root, {
144311
- buildOutput: createBuildOutputMetadataDelta(previousState, state)
144408
+ buildOutput: delta
144312
144409
  });
144313
144410
  await ctx.performance.measure({
144314
144411
  kind: "cache",
@@ -145979,6 +146076,61 @@ async function createBuildSession(options) {
145979
146076
  }
145980
146077
  return finish(roots);
145981
146078
  }
146079
+ async function readMetadataJournalEntries(state) {
146080
+ if (!state.ctx.env.cache || !state.entrySourceId || !state.outputPath) {
146081
+ return;
146082
+ }
146083
+ const root = {
146084
+ entry: state.entry,
146085
+ sourceId: state.entrySourceId,
146086
+ outputPath: state.outputPath
146087
+ };
146088
+ const manifest5 = await readStorageJson(state.ctx.env.cache, getBuildMetadataManifestPath(root));
146089
+ if (!manifest5)
146090
+ return;
146091
+ const signature = createBuildMetadataStoreSignature(createBuildCacheSignature(state.ctx.plugins));
146092
+ if (manifest5.signature !== signature || manifest5.root.entry !== root.entry || manifest5.root.sourceId !== root.sourceId || manifest5.root.outputPath !== root.outputPath) {
146093
+ return;
146094
+ }
146095
+ return manifest5.journal.length;
146096
+ }
146097
+ async function rootDiagnostics(state) {
146098
+ const pendingCache = state.pendingCache;
146099
+ const metadataJournalEntries = await readMetadataJournalEntries(state);
146100
+ const diagnostics = {
146101
+ entry: state.entry,
146102
+ ...state.pathId ? { pathId: state.pathId } : {},
146103
+ ...state.entrySourceId ? { entrySourceId: state.entrySourceId } : {},
146104
+ ...state.outputPath ? { outputPath: state.outputPath } : {},
146105
+ sources: state.ctx.repository.getSources().length,
146106
+ reachableSources: state.reachableSourcePaths.size,
146107
+ missingSources: state.missingSourcePaths.size,
146108
+ graph: state.ctx.repository.graph.diagnostics(),
146109
+ renderCache: {
146110
+ entries: state.ctx.renderCache.size
146111
+ },
146112
+ artifacts: {
146113
+ entries: state.ctx.artifacts.list().length
146114
+ },
146115
+ deferredTasks: state.ctx.deferredTasks?.summary() ?? createUnavailableDeferredTaskSummary(),
146116
+ pending: {
146117
+ settle: settledPending.has(state.entry),
146118
+ cache: !!pendingCache,
146119
+ cacheChanges: pendingCache?.changes.length ?? 0,
146120
+ cacheArtifacts: pendingCache?.artifacts.size ?? 0
146121
+ },
146122
+ ...metadataJournalEntries === undefined ? {} : { metadataJournal: { entries: metadataJournalEntries } }
146123
+ };
146124
+ return diagnostics;
146125
+ }
146126
+ async function collectDiagnostics() {
146127
+ const roots = await Promise.all(states.map(rootDiagnostics));
146128
+ return {
146129
+ roots,
146130
+ pendingSettleRoots: settledPending.size,
146131
+ pendingCacheRoots: roots.filter((root) => root.pending.cache).length
146132
+ };
146133
+ }
145982
146134
  async function drainDeferredTasksSession(options2 = {}) {
145983
146135
  let latest = await runDeferredTasksSession(options2);
145984
146136
  while (findStatesWithRunnableDeferredTasks(options2).length > 0) {
@@ -146048,6 +146200,9 @@ async function createBuildSession(options) {
146048
146200
  hasPendingSettle() {
146049
146201
  return settledPending.size > 0;
146050
146202
  },
146203
+ diagnostics() {
146204
+ return runExclusive(collectDiagnostics);
146205
+ },
146051
146206
  flushCache() {
146052
146207
  return runExclusive(flushPendingCache);
146053
146208
  }
@@ -157565,7 +157720,7 @@ function finalize(ctx, schema2) {
157565
157720
  result.$schema = "http://json-schema.org/draft-07/schema#";
157566
157721
  } else if (ctx.target === "draft-04") {
157567
157722
  result.$schema = "http://json-schema.org/draft-04/schema#";
157568
- } else if (ctx.target === "openapi-3.0") {} else {}
157723
+ } else if (ctx.target === "openapi-3.0") {}
157569
157724
  if (ctx.external?.uri) {
157570
157725
  const id = ctx.external.registry.get(schema2)?.id;
157571
157726
  if (!id)
@@ -157809,7 +157964,7 @@ var literalProcessor = (schema2, ctx, json2, _params) => {
157809
157964
  if (val === undefined) {
157810
157965
  if (ctx.unrepresentable === "throw") {
157811
157966
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
157812
- } else {}
157967
+ }
157813
157968
  } else if (typeof val === "bigint") {
157814
157969
  if (ctx.unrepresentable === "throw") {
157815
157970
  throw new Error("BigInt literals cannot be represented in JSON Schema");
@@ -188717,7 +188872,7 @@ var RuleFactory = class _RuleFactory {
188717
188872
  let localIncludedRule = repository2[reference.ruleName];
188718
188873
  if (localIncludedRule) {
188719
188874
  ruleId = _RuleFactory.getCompiledRuleId(localIncludedRule, helper, repository2);
188720
- } else {}
188875
+ }
188721
188876
  break;
188722
188877
  case 3:
188723
188878
  case 4:
@@ -188729,11 +188884,11 @@ var RuleFactory = class _RuleFactory {
188729
188884
  let externalIncludedRule = externalGrammar.repository[externalGrammarInclude];
188730
188885
  if (externalIncludedRule) {
188731
188886
  ruleId = _RuleFactory.getCompiledRuleId(externalIncludedRule, helper, externalGrammar.repository);
188732
- } else {}
188887
+ }
188733
188888
  } else {
188734
188889
  ruleId = _RuleFactory.getCompiledRuleId(externalGrammar.repository.$self, helper, externalGrammar.repository);
188735
188890
  }
188736
- } else {}
188891
+ }
188737
188892
  break;
188738
188893
  }
188739
188894
  } else {
@@ -206266,7 +206421,7 @@ var EXCLUDED_DIRS = new Set([
206266
206421
  ".git",
206267
206422
  ".obsidian",
206268
206423
  ".pathmx",
206269
- ".pathmx2",
206424
+ ".pathmx",
206270
206425
  ".trash",
206271
206426
  "build",
206272
206427
  "dist",
@@ -206374,7 +206529,12 @@ async function createObsidianIndexSource(options) {
206374
206529
  }
206375
206530
  const managed = parseManagedIndexContent(existingContent);
206376
206531
  if (!managed || managed.hash !== hashString(managed.body)) {
206377
- return { status: "conflict", reason: "user-edited", indexPath, sourcePaths };
206532
+ return {
206533
+ status: "conflict",
206534
+ reason: "user-edited",
206535
+ indexPath,
206536
+ sourcePaths
206537
+ };
206378
206538
  }
206379
206539
  }
206380
206540
  await options.env.sourceStorage.write(indexPath, {
@@ -206436,7 +206596,10 @@ function resultFromMatches(matches3) {
206436
206596
  }
206437
206597
  function obsidianWikilinkResolver() {
206438
206598
  return ({ source: source3, sources, targetPath }) => {
206439
- const sourceByPath = new Map(sources.map((candidate) => [normalizeSourcePath(candidate.path), candidate]));
206599
+ const sourceByPath = new Map(sources.map((candidate) => [
206600
+ normalizeSourcePath(candidate.path),
206601
+ candidate
206602
+ ]));
206440
206603
  const exactPaths = [
206441
206604
  resolveSourcePath(targetPath, source3),
206442
206605
  targetPath.startsWith("/") ? normalizeSourcePath(targetPath.slice(1)) : undefined,
@@ -206484,6 +206647,26 @@ var defaultMarkdownOptions = {
206484
206647
  autolinks: true,
206485
206648
  hardSoftBreaks: true
206486
206649
  };
206650
+ var ensuredBunWriteDirs = new Set;
206651
+ async function ensureBunWriteDir(dir) {
206652
+ if (ensuredBunWriteDirs.has(dir))
206653
+ return;
206654
+ await mkdir(dir, { recursive: true });
206655
+ ensuredBunWriteDirs.add(dir);
206656
+ }
206657
+ async function writeBunFile(filePath, body3) {
206658
+ const dir = dirname2(filePath);
206659
+ await ensureBunWriteDir(dir);
206660
+ try {
206661
+ await Bun.write(filePath, body3);
206662
+ } catch (error52) {
206663
+ if (!isMissingFileError(error52))
206664
+ throw error52;
206665
+ ensuredBunWriteDirs.delete(dir);
206666
+ await ensureBunWriteDir(dir);
206667
+ await Bun.write(filePath, body3);
206668
+ }
206669
+ }
206487
206670
  var textExtensions = new Set([
206488
206671
  ".css",
206489
206672
  ".html",
@@ -206558,8 +206741,7 @@ function createBunFileStorage(rootDir) {
206558
206741
  },
206559
206742
  async write(storagePath, entry) {
206560
206743
  const filePath = join2(rootDir, storagePath);
206561
- await mkdir(dirname2(filePath), { recursive: true });
206562
- await Bun.write(filePath, storageContentToBody(entry.content));
206744
+ await writeBunFile(filePath, storageContentToBody(entry.content));
206563
206745
  },
206564
206746
  async delete(storagePath) {
206565
206747
  await rm(join2(rootDir, storagePath), { force: true });
@@ -206609,13 +206791,12 @@ function createBunArtifactWriter(rootDir, options = {}) {
206609
206791
  return {
206610
206792
  async write(artifact) {
206611
206793
  const filePath = join2(rootDir, artifact.path);
206612
- await mkdir(dirname2(filePath), { recursive: true });
206613
206794
  const body3 = artifact.content === undefined ? await readSourceAsset(artifact, options.env) : artifactContentToBody(artifact);
206614
206795
  if (body3 === undefined) {
206615
206796
  await rm(filePath, { force: true });
206616
206797
  return;
206617
206798
  }
206618
- await Bun.write(filePath, body3);
206799
+ await writeBunFile(filePath, body3);
206619
206800
  },
206620
206801
  async delete(deletion) {
206621
206802
  await rm(join2(rootDir, deletion.path), { force: true });
@@ -207391,6 +207572,60 @@ var {
207391
207572
  Option,
207392
207573
  Help
207393
207574
  } = import__.default;
207575
+ // packages/pathmx/package.json
207576
+ var package_default = {
207577
+ name: "pathmx",
207578
+ version: "0.1.1",
207579
+ private: true,
207580
+ type: "module",
207581
+ types: "./src/index.ts",
207582
+ bin: {
207583
+ pathmx: "./src/bin.ts"
207584
+ },
207585
+ exports: {
207586
+ ".": {
207587
+ types: "./src/index.ts",
207588
+ default: "./src/index.ts"
207589
+ },
207590
+ "./runtime": {
207591
+ types: "./src/runtime.ts",
207592
+ default: "./src/runtime.ts"
207593
+ },
207594
+ "./runtime/react": {
207595
+ types: "./src/runtime-react.ts",
207596
+ default: "./src/runtime-react.ts"
207597
+ },
207598
+ "./runtime/bridge": {
207599
+ types: "./src/runtime-bridge.ts",
207600
+ default: "./src/runtime-bridge.ts"
207601
+ },
207602
+ "./protocol": {
207603
+ types: "./src/protocol.ts",
207604
+ default: "./src/protocol.ts"
207605
+ },
207606
+ "./plugin": {
207607
+ types: "./src/plugin.ts",
207608
+ default: "./src/plugin.ts"
207609
+ },
207610
+ "./mcp": {
207611
+ types: "./src/mcp.ts",
207612
+ default: "./src/mcp.ts"
207613
+ }
207614
+ },
207615
+ scripts: {
207616
+ test: "bun test",
207617
+ typecheck: "tsc --noEmit"
207618
+ },
207619
+ dependencies: {
207620
+ "@pathmx/build": "workspace:*",
207621
+ "@pathmx/cli": "workspace:*",
207622
+ "@pathmx/host": "workspace:*",
207623
+ "@pathmx/mcp": "workspace:*",
207624
+ "@pathmx/protocol": "workspace:*",
207625
+ "@pathmx/runtime": "workspace:*",
207626
+ "@pathmx/server": "workspace:*"
207627
+ }
207628
+ };
207394
207629
  // packages/mcp/src/index.ts
207395
207630
  import { randomUUID } from "crypto";
207396
207631
  import { mkdir as mkdir3, rm as rm4 } from "fs/promises";
@@ -217949,7 +218184,7 @@ function createPathMXHost(options) {
217949
218184
  }
217950
218185
 
217951
218186
  // packages/mcp/src/index.ts
217952
- var DEFAULT_MCP_OUT_DIR = ".pathmx2-mcp";
218187
+ var DEFAULT_MCP_OUT_DIR = ".pathmx-mcp";
217953
218188
  var DEFAULT_LIVE_MCP_HOST = "127.0.0.1";
217954
218189
  var DEFAULT_LIVE_MCP_PORT = 3002;
217955
218190
  var DEFAULT_LIVE_MCP_PATH = "/mcp";
@@ -218050,10 +218285,12 @@ async function spaceSnapshot(ctx) {
218050
218285
  }
218051
218286
  function contentResult(structuredContent) {
218052
218287
  return {
218053
- content: [{
218054
- type: "text",
218055
- text: JSON.stringify(structuredContent, null, 2)
218056
- }],
218288
+ content: [
218289
+ {
218290
+ type: "text",
218291
+ text: JSON.stringify(structuredContent, null, 2)
218292
+ }
218293
+ ],
218057
218294
  structuredContent
218058
218295
  };
218059
218296
  }
@@ -218357,11 +218594,13 @@ function createPathMXMcpServer(ctx) {
218357
218594
  description: "Current PathMX workspace, host, and refresh status.",
218358
218595
  mimeType: "application/json"
218359
218596
  }, async (uri) => ({
218360
- contents: [{
218361
- uri: uri.href,
218362
- mimeType: "application/json",
218363
- text: JSON.stringify(await spaceSnapshot(ctx), null, 2)
218364
- }]
218597
+ contents: [
218598
+ {
218599
+ uri: uri.href,
218600
+ mimeType: "application/json",
218601
+ text: JSON.stringify(await spaceSnapshot(ctx), null, 2)
218602
+ }
218603
+ ]
218365
218604
  }));
218366
218605
  server.registerResource("pathmx-source", new ResourceTemplate("pathmx://source/{path}", { list: undefined }), {
218367
218606
  title: "PathMX Source",
@@ -218372,11 +218611,13 @@ function createPathMXMcpServer(ctx) {
218372
218611
  const sourcePath = normalizeToolSourcePath(decodeURIComponent(String(rawPath ?? "")));
218373
218612
  const source3 = await readSource(ctx, sourcePath);
218374
218613
  return {
218375
- contents: [{
218376
- uri: uri.href,
218377
- mimeType: source3.contentType ?? "text/plain",
218378
- text: source3.content
218379
- }]
218614
+ contents: [
218615
+ {
218616
+ uri: uri.href,
218617
+ mimeType: source3.contentType ?? "text/plain",
218618
+ text: source3.content
218619
+ }
218620
+ ]
218380
218621
  };
218381
218622
  });
218382
218623
  server.registerTool("pathmx_status", {
@@ -218645,7 +218886,7 @@ async function runPathMXMcpServer(options = {}) {
218645
218886
  }
218646
218887
 
218647
218888
  // packages/cli/src/constants.ts
218648
- var CLI_VERSION = "0.0.3";
218889
+ var CLI_VERSION = package_default.version;
218649
218890
  var PATHMX_PUBLIC_CLI_PACKAGE_NAME = "@fellowhumans/pathmx";
218650
218891
  var DEFAULT_SERVE_HOST = "127.0.0.1";
218651
218892
  var DEFAULT_SERVE_PORT = 3000;
@@ -219596,7 +219837,7 @@ var IGNORED_SOURCE_PARTS = new Set([
219596
219837
  ".git",
219597
219838
  "node_modules",
219598
219839
  ".pathmx",
219599
- ".pathmx2"
219840
+ ".pathmx"
219600
219841
  ]);
219601
219842
  function isIgnoredSourceFileName(fileName) {
219602
219843
  return fileName === ".DS_Store" || fileName.endsWith(".swp") || fileName.endsWith(".swo") || fileName.endsWith(".tmp") || fileName.endsWith("~");
@@ -247440,7 +247681,7 @@ async function loadLocal(value$, syncOptions, syncState$, localState) {
247440
247681
  } catch (err) {
247441
247682
  if (true) {
247442
247683
  console.error("[legend-state] Error loading local cache. This would be a crashing error in production.", err);
247443
- } else {}
247684
+ }
247444
247685
  }
247445
247686
  }
247446
247687
  const prevValue = getNodeValue2(node);
@@ -251383,7 +251624,9 @@ class PlayerRouterStore {
251383
251624
  this.$.ready.set(false);
251384
251625
  }
251385
251626
  navigate(route, options = {}) {
251386
- this.setPrimaryRoute(this.resolvePrimaryRoute(route), {
251627
+ this.setPrimaryRoute(this.resolvePrimaryRoute(route, {
251628
+ unknownRouteFallback: options.unknownRouteFallback ?? "preserve"
251629
+ }), {
251387
251630
  history: options.history ?? "push"
251388
251631
  });
251389
251632
  }
@@ -251391,7 +251634,9 @@ class PlayerRouterStore {
251391
251634
  this.navigate(route, { history: "replace" });
251392
251635
  }
251393
251636
  syncFromLocation(options = {}) {
251394
- const route = this.resolvePrimaryRoute(this.routeFromLocation());
251637
+ const route = this.resolvePrimaryRoute(this.routeFromLocation(), {
251638
+ unknownRouteFallback: "entry"
251639
+ });
251395
251640
  this.setPrimaryRoute(route, {
251396
251641
  history: options.canonicalize ? "replace" : false
251397
251642
  });
@@ -251447,10 +251692,17 @@ class PlayerRouterStore {
251447
251692
  }
251448
251693
  return \`\${url.pathname}\${url.hash}\`;
251449
251694
  }
251450
- resolvePrimaryRoute(route) {
251695
+ resolvePrimaryRoute(route, options = {}) {
251451
251696
  const parsed = this.parseRoute(route);
251452
- const source = this.findSource(parsed.pathname) ?? this.entrySource();
251697
+ const source = this.findSource(parsed.pathname);
251453
251698
  if (!source) {
251699
+ const entrySource = this.entrySource();
251700
+ if (entrySource && (parsed.pathname === "/" || options.unknownRouteFallback !== "preserve")) {
251701
+ return {
251702
+ route: \`\${entrySource.route}\${parsed.hash}\`,
251703
+ sourceId: entrySource.id
251704
+ };
251705
+ }
251454
251706
  return {
251455
251707
  route: \`\${parsed.pathname}\${parsed.hash}\`,
251456
251708
  sourceId: undefined
@@ -252171,6 +252423,21 @@ function RuntimeSurface({
252171
252423
  const preferences2 = import_react17.useMemo(() => ({ colorScheme }), [colorScheme]);
252172
252424
  const live = import_react17.useMemo(() => liveOptions(config), [config.liveSocketPath, config.primaryDocument]);
252173
252425
  const fetchDocument = import_react17.useCallback((route, options) => fetchPathMXDocumentHtml(route, graph.graph, options.signal), [graph]);
252426
+ const navigateDocumentRoute = import_react17.useCallback((path, history) => {
252427
+ const navigate = () => {
252428
+ router.navigate(path, { history });
252429
+ };
252430
+ if (findSourceForRoute(graph.graph, path)) {
252431
+ navigate();
252432
+ return;
252433
+ }
252434
+ graph.revalidate({ force: true }).catch((error) => {
252435
+ app.reportRuntimeError(error);
252436
+ return;
252437
+ }).then(() => {
252438
+ navigate();
252439
+ });
252440
+ }, [app, graph, router]);
252174
252441
  return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(PathMXRuntimeProvider, {
252175
252442
  live,
252176
252443
  fetchDocument,
@@ -252193,9 +252460,7 @@ function RuntimeSurface({
252193
252460
  if (!event.defaultNavigation)
252194
252461
  return;
252195
252462
  event.preventDefault();
252196
- router.navigate(event.path, {
252197
- history: event.defaultNavigation.history === "replace" ? "replace" : "push"
252198
- });
252463
+ navigateDocumentRoute(event.path, event.defaultNavigation.history === "replace" ? "replace" : "push");
252199
252464
  },
252200
252465
  onError: (event) => {
252201
252466
  app.reportRuntimeError(event.error);
@@ -263841,14 +264106,14 @@ function PlayComposer({
263841
264106
  }, undefined, false, undefined, this),
263842
264107
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(IconButton, {
263843
264108
  icon: "send",
263844
- label: "Add",
264109
+ label: "Add annotation",
263845
264110
  onClick: onSubmit,
263846
264111
  variant: "default",
263847
264112
  className: "absolute bottom-2 right-2 bg-primary-background text-accent-foreground"
263848
264113
  }, undefined, false, undefined, this),
263849
264114
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(IconButton, {
263850
264115
  icon: "close",
263851
- label: "Close",
264116
+ label: "Close composer",
263852
264117
  onClick: onClose,
263853
264118
  className: "absolute top-1 right-2 text-muted-foreground"
263854
264119
  }, undefined, false, undefined, this)
@@ -263887,6 +264152,14 @@ function PlayComposerButton({
263887
264152
  if (!activeBeatView && composerOpen)
263888
264153
  play.composer.close();
263889
264154
  }, [activeBeatView, composerOpen, play]);
264155
+ function handleShowComposer() {
264156
+ if (!activeBeatView)
264157
+ return;
264158
+ play.composer.open({
264159
+ beatId: activeBeatView.beatId,
264160
+ rect: activeBeatView.rect
264161
+ });
264162
+ }
263890
264163
  if (composerOpen && composerRect) {
263891
264164
  return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(PlayComposer, {
263892
264165
  draft,
@@ -263903,7 +264176,7 @@ function PlayComposerButton({
263903
264176
  label: "Compose",
263904
264177
  className,
263905
264178
  iconClassName,
263906
- onClick: () => play.composer.open()
264179
+ onClick: handleShowComposer
263907
264180
  }, undefined, false, undefined, this);
263908
264181
  }
263909
264182
 
@@ -273058,12 +273331,22 @@ var ROOT_SCROLLBAR_STYLE_PROPERTIES = [
273058
273331
  "scrollbar-width",
273059
273332
  "-ms-overflow-style"
273060
273333
  ];
273334
+ function isElement5(value) {
273335
+ return typeof value === "object" && value !== null && value.nodeType === 1;
273336
+ }
273337
+ function getEventElementTarget2(target) {
273338
+ if (isElement5(target))
273339
+ return target;
273340
+ const parentElement = target?.parentElement;
273341
+ return isElement5(parentElement) ? parentElement : undefined;
273342
+ }
273061
273343
  function rootScrollbarTargets(root2) {
273062
273344
  return [root2.documentElement, root2.body].filter((element) => Boolean(element));
273063
273345
  }
273064
273346
  function createBrowserPlayRootEffects(root2 = document, view2 = window) {
273065
273347
  let snapRestoreFrame;
273066
273348
  let restoreScrollbarStyles;
273349
+ let removeExternalLinkHandler;
273067
273350
  const cancelSnapRestore = () => {
273068
273351
  if (snapRestoreFrame === undefined)
273069
273352
  return;
@@ -273097,14 +273380,69 @@ function createBrowserPlayRootEffects(root2 = document, view2 = window) {
273097
273380
  restoreScrollbarStyles?.();
273098
273381
  restoreScrollbarStyles = undefined;
273099
273382
  };
273383
+ const externalHttpUrlForClick = (event) => {
273384
+ if (event.defaultPrevented || event.button !== 0 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
273385
+ return;
273386
+ }
273387
+ const eventTarget = getEventElementTarget2(event.target);
273388
+ const anchor = eventTarget?.closest("a[href]");
273389
+ if (!anchor || anchor.hasAttribute("download"))
273390
+ return;
273391
+ if (anchor.hasAttribute("target"))
273392
+ return;
273393
+ const href = anchor.getAttribute("href")?.trim();
273394
+ if (!href || href.startsWith("#"))
273395
+ return;
273396
+ let url;
273397
+ try {
273398
+ url = new URL(href, view2.location.href);
273399
+ } catch {
273400
+ return;
273401
+ }
273402
+ if (url.origin === view2.location.origin)
273403
+ return;
273404
+ if (url.protocol !== "http:" && url.protocol !== "https:")
273405
+ return;
273406
+ return url;
273407
+ };
273408
+ const openExternalLinksInNewContext = () => {
273409
+ if (removeExternalLinkHandler)
273410
+ return;
273411
+ const handleClick = (event) => {
273412
+ const url = externalHttpUrlForClick(event);
273413
+ if (!url)
273414
+ return;
273415
+ let opened;
273416
+ try {
273417
+ opened = view2.open(url.href, "_blank", "noopener,noreferrer");
273418
+ } catch {
273419
+ return;
273420
+ }
273421
+ event.preventDefault();
273422
+ try {
273423
+ if (opened)
273424
+ opened.opener = null;
273425
+ } catch {}
273426
+ };
273427
+ root2.addEventListener("click", handleClick);
273428
+ removeExternalLinkHandler = () => {
273429
+ root2.removeEventListener("click", handleClick);
273430
+ removeExternalLinkHandler = undefined;
273431
+ };
273432
+ };
273433
+ const restoreExternalLinkBehavior = () => {
273434
+ removeExternalLinkHandler?.();
273435
+ };
273100
273436
  return {
273101
273437
  setPlaying(on) {
273102
273438
  if (on) {
273103
273439
  root2.documentElement.setAttribute("data-pathmx-play", "playing");
273104
273440
  hideRootScrollbars();
273441
+ openExternalLinksInNewContext();
273105
273442
  } else {
273106
273443
  root2.documentElement.removeAttribute("data-pathmx-play");
273107
273444
  restoreRootScrollbars();
273445
+ restoreExternalLinkBehavior();
273108
273446
  }
273109
273447
  },
273110
273448
  setViewportHeight(px2) {
@@ -273805,15 +274143,14 @@ function PlayerAugmentations() {
273805
274143
  className: "pmx-player-control-surface pointer-events-none fixed inset-0 z-50",
273806
274144
  children: [
273807
274145
  /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(PlayAugmentations, {}, undefined, false, undefined, this),
273808
- !playActive && /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(jsx_dev_runtime17.Fragment, {
274146
+ !playActive && !exploreActive && /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(jsx_dev_runtime17.Fragment, {
273809
274147
  children: [
273810
274148
  /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(PlayerBreadcrumbBar, {}, undefined, false, undefined, this),
273811
274149
  /* @__PURE__ */ jsx_dev_runtime17.jsxDEV("div", {
273812
274150
  className: "absolute bottom-[max(0.75rem,env(safe-area-inset-bottom))] left-3",
273813
274151
  children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(ActionButton, {
273814
- "aria-pressed": exploreActive,
273815
274152
  icon: "map",
273816
- label: exploreActive ? "Close explore" : "Explore",
274153
+ label: "Explore",
273817
274154
  onClick: () => view2.toggleExplore()
273818
274155
  }, undefined, false, undefined, this)
273819
274156
  }, undefined, false, undefined, this),
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@fellowhumans/pathmx",
3
- "version": "0.0.3",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/pathmx/pathmx.git"
9
+ },
6
10
  "bin": {
7
11
  "pathmx": "dist/pathmx.js",
8
12
  "pmx": "dist/pathmx.js"
@@ -15,6 +19,7 @@
15
19
  "bun": ">=1.3.0"
16
20
  },
17
21
  "publishConfig": {
18
- "access": "public"
22
+ "access": "public",
23
+ "registry": "https://registry.npmjs.org/"
19
24
  }
20
25
  }