nudge-ui 0.2.0 → 0.2.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 (201) hide show
  1. package/bin/nudge-ui.mjs +3 -1
  2. package/dist/cli/agentCommand.d.ts +8 -0
  3. package/dist/cli/agentCommand.js +59 -0
  4. package/dist/client.mjs +872 -12
  5. package/dist/hosts/astro/astroRuntimeConfig.js +1 -1
  6. package/dist/hosts/astro/clientTransport.js +60 -11
  7. package/dist/hosts/next/sidecar.d.ts +4 -0
  8. package/dist/hosts/next/sidecar.js +49 -6
  9. package/dist/hosts/next/wrapper.js +30 -2
  10. package/dist/hosts/projectBridge.d.ts +20 -0
  11. package/dist/hosts/projectBridge.js +97 -0
  12. package/dist/hosts/static/cli.d.ts +1 -1
  13. package/dist/hosts/static/cli.js +6 -1
  14. package/dist/hosts/static/manifest.d.ts +1 -1
  15. package/dist/hosts/static/manifest.js +1 -1
  16. package/dist/hosts/static/server.js +44 -3
  17. package/dist/hosts/vite/vite.d.ts +5 -1
  18. package/dist/hosts/vite/vite.js +78 -14
  19. package/dist/inspector/agent/McpConnectionDialog.d.ts +2 -2
  20. package/dist/inspector/agent/McpConnectionDialog.js +11 -35
  21. package/dist/inspector/agent/client.d.ts +10 -3
  22. package/dist/inspector/agent/client.js +80 -9
  23. package/dist/inspector/agent/connectionStatus.js +3 -3
  24. package/dist/inspector/agent/httpTransport.d.ts +2 -0
  25. package/dist/inspector/agent/httpTransport.js +37 -17
  26. package/dist/inspector/agent/protocol.d.ts +8 -3
  27. package/dist/inspector/agent/protocol.js +1 -1
  28. package/dist/inspector/agent/verification.d.ts +1 -1
  29. package/dist/inspector/agent/verification.js +69 -12
  30. package/dist/inspector/canvas/CanvasCard.d.ts +5 -3
  31. package/dist/inspector/canvas/CanvasCard.js +181 -91
  32. package/dist/inspector/canvas/CanvasElementOverlay.js +246 -52
  33. package/dist/inspector/canvas/CanvasToolbar.d.ts +12 -0
  34. package/dist/inspector/canvas/CanvasToolbar.js +24 -0
  35. package/dist/inspector/canvas/CanvasWorkspace.d.ts +4 -1
  36. package/dist/inspector/canvas/CanvasWorkspace.js +392 -73
  37. package/dist/inspector/canvas/activeCanvasDocument.d.ts +5 -0
  38. package/dist/inspector/canvas/activeCanvasDocument.js +23 -0
  39. package/dist/inspector/canvas/canvasResize.d.ts +30 -0
  40. package/dist/inspector/canvas/canvasResize.js +52 -0
  41. package/dist/inspector/canvas/canvasStore.d.ts +30 -6
  42. package/dist/inspector/canvas/canvasStore.js +128 -61
  43. package/dist/inspector/canvas/frameProtocol.d.ts +69 -5
  44. package/dist/inspector/canvas/frameProtocol.js +56 -2
  45. package/dist/inspector/canvas/keyboardShortcuts.d.ts +3 -0
  46. package/dist/inspector/canvas/keyboardShortcuts.js +14 -0
  47. package/dist/inspector/canvas/projection.d.ts +7 -0
  48. package/dist/inspector/canvas/projection.js +118 -25
  49. package/dist/inspector/canvas/rendererBootstrap.js +29 -29
  50. package/dist/inspector/canvas/rendererElementSelector.js +341 -30
  51. package/dist/inspector/canvas/rendererMessageRouter.d.ts +11 -0
  52. package/dist/inspector/canvas/rendererMessageRouter.js +43 -0
  53. package/dist/inspector/canvas/rendererSelectionProxy.js +6 -2
  54. package/dist/inspector/canvas/sessionStore.d.ts +1 -0
  55. package/dist/inspector/canvas/sessionStore.js +12 -4
  56. package/dist/inspector/canvas/staleChangeDetector.js +16 -14
  57. package/dist/inspector/changes/changesLog.js +31 -1
  58. package/dist/inspector/changes/managedStyleProjection.d.ts +1 -1
  59. package/dist/inspector/changes/managedStyleProjection.js +3 -3
  60. package/dist/inspector/changes/structuralTypes.d.ts +4 -0
  61. package/dist/inspector/clientManifest.d.ts +5 -0
  62. package/dist/inspector/clientManifest.js +11 -0
  63. package/dist/inspector/componentSemantics/adapterRegistry.js +4 -3
  64. package/dist/inspector/componentSemantics/runtimeBridge.d.ts +2 -2
  65. package/dist/inspector/componentSemantics/runtimeBridge.js +16 -3
  66. package/dist/inspector/index.d.ts +2 -0
  67. package/dist/inspector/index.js +74 -24
  68. package/dist/inspector/inline-text/inlineTextDiagnostics.d.ts +10 -0
  69. package/dist/inspector/inline-text/inlineTextDiagnostics.js +65 -0
  70. package/dist/inspector/inline-text/inlineTextEditor.d.ts +3 -5
  71. package/dist/inspector/inline-text/inlineTextEditor.js +74 -206
  72. package/dist/inspector/inline-text/inlineTextFeedback.d.ts +5 -0
  73. package/dist/inspector/inline-text/inlineTextFeedback.js +27 -0
  74. package/dist/inspector/inline-text/inlineTextLifecycle.js +2 -0
  75. package/dist/inspector/inline-text/textEditChange.d.ts +14 -0
  76. package/dist/inspector/inline-text/textEditChange.js +165 -0
  77. package/dist/inspector/inspection/selectionProperty.d.ts +1 -0
  78. package/dist/inspector/inspection/selectionProperty.js +1 -0
  79. package/dist/inspector/overlay/selectedGeometry.js +21 -2
  80. package/dist/inspector/overlay/spacingGestures.d.ts +45 -0
  81. package/dist/inspector/overlay/spacingGestures.js +353 -0
  82. package/dist/inspector/overlay/structuralGestures.d.ts +2 -2
  83. package/dist/inspector/overlay/structuralGestures.js +12 -10
  84. package/dist/inspector/projection/managedStylesheet.js +4 -1
  85. package/dist/inspector/projection/renderedInstance.d.ts +2 -0
  86. package/dist/inspector/projection/renderedInstance.js +5 -1
  87. package/dist/inspector/projection/structuralProjection.d.ts +2 -0
  88. package/dist/inspector/projection/structuralProjection.js +85 -1
  89. package/dist/inspector/projection/structuralProjectionBoundary.js +17 -1
  90. package/dist/inspector/projection/textProjection.d.ts +2 -0
  91. package/dist/inspector/projection/textProjection.js +10 -4
  92. package/dist/inspector/prompt/clipboardHandoff.d.ts +1 -1
  93. package/dist/inspector/prompt/clipboardHandoff.js +3 -3
  94. package/dist/inspector/prompt/generatePrompt.d.ts +2 -1
  95. package/dist/inspector/prompt/generatePrompt.js +19 -2
  96. package/dist/inspector/runtime/editorShell.d.ts +2 -0
  97. package/dist/inspector/runtime/editorShell.js +4 -0
  98. package/dist/inspector/runtime/runtimeConfig.d.ts +4 -0
  99. package/dist/inspector/runtime/runtimeConfig.js +4 -0
  100. package/dist/inspector/selection/selectionStore.js +2 -0
  101. package/dist/inspector/settings/SettingsDialog.js +10 -0
  102. package/dist/inspector/shell/AppShell.js +5 -1
  103. package/dist/inspector/shell/ChangesLog.js +8 -4
  104. package/dist/inspector/shell/CopyPromptButton.js +95 -19
  105. package/dist/inspector/shell/EmptyState.js +1 -1
  106. package/dist/inspector/shell/InspectorShell.d.ts +0 -1
  107. package/dist/inspector/shell/InspectorShell.js +37 -38
  108. package/dist/inspector/shell/PeekOriginalButton.d.ts +7 -0
  109. package/dist/inspector/shell/PeekOriginalButton.js +57 -0
  110. package/dist/inspector/shell/PeekOriginalIcon.d.ts +7 -0
  111. package/dist/inspector/shell/PeekOriginalIcon.js +9 -0
  112. package/dist/inspector/shell/originalPreview.d.ts +9 -0
  113. package/dist/inspector/shell/originalPreview.js +61 -0
  114. package/dist/inspector/shell/shortcuts.d.ts +3 -0
  115. package/dist/inspector/shell/shortcuts.js +15 -0
  116. package/dist/inspector/sketch/SketchChanges.d.ts +2 -0
  117. package/dist/inspector/sketch/SketchChanges.js +72 -0
  118. package/dist/inspector/sketch/SketchEditor.d.ts +21 -0
  119. package/dist/inspector/sketch/SketchEditor.js +402 -0
  120. package/dist/inspector/sketch/SketchEntryButton.d.ts +4 -0
  121. package/dist/inspector/sketch/SketchEntryButton.js +11 -0
  122. package/dist/inspector/sketch/SketchFrameOverlay.d.ts +11 -0
  123. package/dist/inspector/sketch/SketchFrameOverlay.js +119 -0
  124. package/dist/inspector/sketch/SketchLayersPanel.d.ts +2 -0
  125. package/dist/inspector/sketch/SketchLayersPanel.js +63 -0
  126. package/dist/inspector/sketch/SketchOverlay.d.ts +19 -0
  127. package/dist/inspector/sketch/SketchOverlay.js +420 -0
  128. package/dist/inspector/sketch/SketchPromptPanel.d.ts +15 -0
  129. package/dist/inspector/sketch/SketchPromptPanel.js +18 -0
  130. package/dist/inspector/sketch/SketchWorkspace.d.ts +13 -0
  131. package/dist/inspector/sketch/SketchWorkspace.js +152 -0
  132. package/dist/inspector/sketch/capture.d.ts +55 -0
  133. package/dist/inspector/sketch/capture.js +350 -0
  134. package/dist/inspector/sketch/freehand.d.ts +13 -0
  135. package/dist/inspector/sketch/freehand.js +64 -0
  136. package/dist/inspector/sketch/geometry.d.ts +17 -0
  137. package/dist/inspector/sketch/geometry.js +98 -0
  138. package/dist/inspector/sketch/handoff.d.ts +21 -0
  139. package/dist/inspector/sketch/handoff.js +72 -0
  140. package/dist/inspector/sketch/interaction.d.ts +21 -0
  141. package/dist/inspector/sketch/interaction.js +98 -0
  142. package/dist/inspector/sketch/model.d.ts +104 -0
  143. package/dist/inspector/sketch/model.js +282 -0
  144. package/dist/inspector/sketch/persistence.d.ts +21 -0
  145. package/dist/inspector/sketch/persistence.js +205 -0
  146. package/dist/inspector/sketch/raster.d.ts +22 -0
  147. package/dist/inspector/sketch/raster.js +203 -0
  148. package/dist/inspector/sketch/sketchNote.d.ts +10 -0
  149. package/dist/inspector/sketch/sketchNote.js +30 -0
  150. package/dist/inspector/sketch/store.d.ts +47 -0
  151. package/dist/inspector/sketch/store.js +409 -0
  152. package/dist/inspector/styleEditors/BorderEditor.js +15 -19
  153. package/dist/inspector/styleEditors/BorderRadiusEditor.js +6 -6
  154. package/dist/inspector/styleEditors/BoxShadowEditor.js +12 -1
  155. package/dist/inspector/styleEditors/ColorPicker.js +11 -36
  156. package/dist/inspector/styleEditors/GapField.d.ts +3 -2
  157. package/dist/inspector/styleEditors/GapField.js +2 -2
  158. package/dist/inspector/styleEditors/GridSection.js +1 -1
  159. package/dist/inspector/styleEditors/LayoutSection.js +11 -8
  160. package/dist/inspector/styleEditors/SpacingBox.js +23 -30
  161. package/dist/inspector/styleEditors/layoutPreviewState.d.ts +5 -0
  162. package/dist/inspector/styleEditors/layoutPreviewState.js +19 -0
  163. package/dist/inspector/styleEditors/layoutValue.js +3 -0
  164. package/dist/inspector/styleEditors/nudgeValue.d.ts +11 -0
  165. package/dist/inspector/styleEditors/nudgeValue.js +91 -5
  166. package/dist/inspector/styleEditors/stylePresence.d.ts +7 -0
  167. package/dist/inspector/styleEditors/stylePresence.js +22 -0
  168. package/dist/inspector/styleEditors/textRelevance.d.ts +3 -0
  169. package/dist/inspector/styleEditors/textRelevance.js +35 -0
  170. package/dist/inspector/styleEditors/useFieldVisibility.d.ts +6 -0
  171. package/dist/inspector/styleEditors/useFieldVisibility.js +26 -0
  172. package/dist/inspector/tokens/TokenField.js +111 -7
  173. package/dist/inspector/tokens/editActions.d.ts +2 -0
  174. package/dist/inspector/tokens/editActions.js +2 -2
  175. package/dist/inspector/tokens/resolution/cssomCollector.d.ts +1 -1
  176. package/dist/inspector/tokens/resolution/cssomCollector.js +9 -5
  177. package/dist/inspector/tokens/resolution/ruleMatching.d.ts +40 -0
  178. package/dist/inspector/tokens/resolution/ruleMatching.js +423 -0
  179. package/dist/inspector/tokens/resolution/selectorSemantics.d.ts +19 -3
  180. package/dist/inspector/tokens/resolution/selectorSemantics.js +378 -4
  181. package/dist/inspector/tokens/resolution.d.ts +3 -26
  182. package/dist/inspector/tokens/resolution.js +44 -735
  183. package/dist/inspector/tokens/tokenAvailability.d.ts +18 -0
  184. package/dist/inspector/tokens/tokenAvailability.js +204 -0
  185. package/dist/inspector/ui/Button.d.ts +1 -1
  186. package/dist/inspector/ui/SideValuesField.js +2 -2
  187. package/dist/inspector/ui/StatusCallout.d.ts +4 -1
  188. package/dist/inspector/ui/StatusCallout.js +2 -2
  189. package/dist/inspector/ui/styles.js +13 -11
  190. package/dist/internal/agent-protocol.d.ts +65 -1
  191. package/dist/internal/agent-protocol.js +183 -3
  192. package/dist/nudge-ui.mjs +261 -57
  193. package/dist/transport/editor.d.ts +28 -0
  194. package/dist/transport/editor.js +132 -0
  195. package/dist/transport/index.d.ts +1 -0
  196. package/dist/transport/index.js +1 -0
  197. package/dist/transport/routes.d.ts +7 -0
  198. package/dist/transport/routes.js +7 -0
  199. package/package.json +3 -1
  200. package/dist/inspector/shell/panelLayout.d.ts +0 -2
  201. package/dist/inspector/shell/panelLayout.js +0 -29
package/dist/nudge-ui.mjs CHANGED
@@ -1349,7 +1349,7 @@ var require_container = __commonJS({
1349
1349
  var Node2 = require_node();
1350
1350
  var { isClean, my } = require_symbols();
1351
1351
  var AtRule2;
1352
- var parse3;
1352
+ var parse4;
1353
1353
  var Root2;
1354
1354
  var Rule2;
1355
1355
  function cleanSource(nodes) {
@@ -1516,7 +1516,7 @@ var require_container = __commonJS({
1516
1516
  }
1517
1517
  normalize(nodes, sample) {
1518
1518
  if (typeof nodes === "string") {
1519
- nodes = cleanSource(parse3(nodes).nodes);
1519
+ nodes = cleanSource(parse4(nodes).nodes);
1520
1520
  } else if (typeof nodes === "undefined") {
1521
1521
  nodes = [];
1522
1522
  } else if (Array.isArray(nodes)) {
@@ -1725,7 +1725,7 @@ var require_container = __commonJS({
1725
1725
  }
1726
1726
  };
1727
1727
  Container2.registerParse = (dependant) => {
1728
- parse3 = dependant;
1728
+ parse4 = dependant;
1729
1729
  };
1730
1730
  Container2.registerRule = (dependant) => {
1731
1731
  Rule2 = dependant;
@@ -2064,7 +2064,7 @@ var require_util = __commonJS({
2064
2064
  return path;
2065
2065
  });
2066
2066
  exports.normalize = normalize;
2067
- function join4(aRoot, aPath) {
2067
+ function join6(aRoot, aPath) {
2068
2068
  if (aRoot === "") {
2069
2069
  aRoot = ".";
2070
2070
  }
@@ -2096,7 +2096,7 @@ var require_util = __commonJS({
2096
2096
  }
2097
2097
  return joined;
2098
2098
  }
2099
- exports.join = join4;
2099
+ exports.join = join6;
2100
2100
  exports.isAbsolute = function(aPath) {
2101
2101
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
2102
2102
  };
@@ -2310,7 +2310,7 @@ var require_util = __commonJS({
2310
2310
  parsed.path = parsed.path.substring(0, index + 1);
2311
2311
  }
2312
2312
  }
2313
- sourceURL = join4(urlGenerate(parsed), sourceURL);
2313
+ sourceURL = join6(urlGenerate(parsed), sourceURL);
2314
2314
  }
2315
2315
  return normalize(sourceURL);
2316
2316
  }
@@ -3750,8 +3750,8 @@ var require_source_map = __commonJS({
3750
3750
  var require_previous_map = __commonJS({
3751
3751
  "../../node_modules/.pnpm/postcss@8.5.26/node_modules/postcss/lib/previous-map.js"(exports, module) {
3752
3752
  "use strict";
3753
- var { existsSync: existsSync2, readFileSync, realpathSync: realpathSync3 } = __require("fs");
3754
- var { dirname: dirname3, isAbsolute: isAbsolute4, join: join4, relative: relative4, sep: sep3 } = __require("path");
3753
+ var { existsSync: existsSync4, readFileSync, realpathSync: realpathSync3 } = __require("fs");
3754
+ var { dirname: dirname5, isAbsolute: isAbsolute4, join: join6, relative: relative4, sep: sep3 } = __require("path");
3755
3755
  var { SourceMapConsumer, SourceMapGenerator } = require_source_map();
3756
3756
  function realPath(path) {
3757
3757
  try {
@@ -3778,7 +3778,7 @@ var require_previous_map = __commonJS({
3778
3778
  if (!this.mapFile && opts.from) {
3779
3779
  this.mapFile = opts.from;
3780
3780
  }
3781
- if (this.mapFile) this.root = dirname3(this.mapFile);
3781
+ if (this.mapFile) this.root = dirname5(this.mapFile);
3782
3782
  if (text) this.text = text;
3783
3783
  }
3784
3784
  consumer() {
@@ -3824,13 +3824,13 @@ var require_previous_map = __commonJS({
3824
3824
  if (!trusted && !this.unsafeMap) {
3825
3825
  if (!/\.map$/i.test(path)) return void 0;
3826
3826
  if (!cssFile) return void 0;
3827
- let rel = relative4(realPath(dirname3(cssFile)), realPath(path));
3827
+ let rel = relative4(realPath(dirname5(cssFile)), realPath(path));
3828
3828
  if (rel === ".." || rel.startsWith(".." + sep3) || isAbsolute4(rel)) {
3829
3829
  return void 0;
3830
3830
  }
3831
3831
  }
3832
- this.root = dirname3(path);
3833
- if (existsSync2(path)) {
3832
+ this.root = dirname5(path);
3833
+ if (existsSync4(path)) {
3834
3834
  this.mapFile = path;
3835
3835
  return readFileSync(path, "utf-8").toString().trim();
3836
3836
  }
@@ -3866,7 +3866,7 @@ var require_previous_map = __commonJS({
3866
3866
  return this.decodeInline(this.annotation);
3867
3867
  } else if (this.annotation) {
3868
3868
  let map = this.annotation;
3869
- if (file) map = join4(dirname3(file), map);
3869
+ if (file) map = join6(dirname5(file), map);
3870
3870
  let unknown = this.loadFile(map, file, false);
3871
3871
  if (unknown) {
3872
3872
  try {
@@ -3898,7 +3898,7 @@ var require_input = __commonJS({
3898
3898
  var { nanoid } = require_non_secure();
3899
3899
  var { isAbsolute: isAbsolute4, resolve: resolve5 } = __require("path");
3900
3900
  var { SourceMapConsumer, SourceMapGenerator } = require_source_map();
3901
- var { fileURLToPath, pathToFileURL } = __require("url");
3901
+ var { fileURLToPath, pathToFileURL: pathToFileURL2 } = __require("url");
3902
3902
  var CssSyntaxError2 = require_css_syntax_error();
3903
3903
  var PreviousMap = require_previous_map();
3904
3904
  var terminalHighlight = require_terminal_highlight();
@@ -4017,8 +4017,8 @@ var require_input = __commonJS({
4017
4017
  source: this.css
4018
4018
  };
4019
4019
  if (this.file) {
4020
- if (pathToFileURL) {
4021
- result.input.url = pathToFileURL(this.file).toString();
4020
+ if (pathToFileURL2) {
4021
+ result.input.url = pathToFileURL2(this.file).toString();
4022
4022
  }
4023
4023
  result.input.file = this.file;
4024
4024
  }
@@ -4076,11 +4076,11 @@ var require_input = __commonJS({
4076
4076
  }
4077
4077
  let fromUrl;
4078
4078
  if (isAbsolute4(from.source)) {
4079
- fromUrl = pathToFileURL(from.source);
4079
+ fromUrl = pathToFileURL2(from.source);
4080
4080
  } else {
4081
4081
  fromUrl = new URL(
4082
4082
  from.source,
4083
- this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
4083
+ this.map.consumer().sourceRoot || pathToFileURL2(this.map.mapFile)
4084
4084
  );
4085
4085
  }
4086
4086
  let result = {
@@ -4369,12 +4369,12 @@ var require_fromJSON = __commonJS({
4369
4369
  var require_map_generator = __commonJS({
4370
4370
  "../../node_modules/.pnpm/postcss@8.5.26/node_modules/postcss/lib/map-generator.js"(exports, module) {
4371
4371
  "use strict";
4372
- var { dirname: dirname3, relative: relative4, resolve: resolve5, sep: sep3 } = __require("path");
4372
+ var { dirname: dirname5, relative: relative4, resolve: resolve5, sep: sep3 } = __require("path");
4373
4373
  var { SourceMapConsumer, SourceMapGenerator } = require_source_map();
4374
- var { pathToFileURL } = __require("url");
4374
+ var { pathToFileURL: pathToFileURL2 } = __require("url");
4375
4375
  var Input2 = require_input();
4376
4376
  var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
4377
- var pathAvailable = Boolean(dirname3 && resolve5 && relative4 && sep3);
4377
+ var pathAvailable = Boolean(dirname5 && resolve5 && relative4 && sep3);
4378
4378
  var MapGenerator = class {
4379
4379
  constructor(stringify2, root2, opts, cssString) {
4380
4380
  this.stringify = stringify2;
@@ -4406,7 +4406,7 @@ var require_map_generator = __commonJS({
4406
4406
  applyPrevMaps() {
4407
4407
  for (let prev of this.previous()) {
4408
4408
  let from = this.toUrl(this.path(prev.file));
4409
- let root2 = prev.root || dirname3(prev.file);
4409
+ let root2 = prev.root || dirname5(prev.file);
4410
4410
  let map;
4411
4411
  if (this.mapOpts.sourcesContent === false) {
4412
4412
  map = new SourceMapConsumer(prev.text);
@@ -4601,9 +4601,9 @@ var require_map_generator = __commonJS({
4601
4601
  if (/^\w+:\/\//.test(file)) return file;
4602
4602
  let cached = this.memoizedPaths.get(file);
4603
4603
  if (cached) return cached;
4604
- let from = this.opts.to ? dirname3(this.opts.to) : ".";
4604
+ let from = this.opts.to ? dirname5(this.opts.to) : ".";
4605
4605
  if (typeof this.mapOpts.annotation === "string") {
4606
- from = dirname3(resolve5(from, this.mapOpts.annotation));
4606
+ from = dirname5(resolve5(from, this.mapOpts.annotation));
4607
4607
  }
4608
4608
  let path = relative4(from, file);
4609
4609
  this.memoizedPaths.set(file, path);
@@ -4665,8 +4665,8 @@ var require_map_generator = __commonJS({
4665
4665
  toFileUrl(path) {
4666
4666
  let cached = this.memoizedFileURLs.get(path);
4667
4667
  if (cached) return cached;
4668
- if (pathToFileURL) {
4669
- let fileURL = pathToFileURL(path).toString();
4668
+ if (pathToFileURL2) {
4669
+ let fileURL = pathToFileURL2(path).toString();
4670
4670
  this.memoizedFileURLs.set(path, fileURL);
4671
4671
  return fileURL;
4672
4672
  } else {
@@ -5237,7 +5237,7 @@ var require_parse = __commonJS({
5237
5237
  var Container2 = require_container();
5238
5238
  var Input2 = require_input();
5239
5239
  var Parser2 = require_parser();
5240
- function parse3(css, opts) {
5240
+ function parse4(css, opts) {
5241
5241
  let input = new Input2(css, opts);
5242
5242
  let parser = new Parser2(input);
5243
5243
  try {
@@ -5258,9 +5258,9 @@ var require_parse = __commonJS({
5258
5258
  }
5259
5259
  return parser.root;
5260
5260
  }
5261
- module.exports = parse3;
5262
- parse3.default = parse3;
5263
- Container2.registerParse(parse3);
5261
+ module.exports = parse4;
5262
+ parse4.default = parse4;
5263
+ Container2.registerParse(parse4);
5264
5264
  }
5265
5265
  });
5266
5266
 
@@ -5366,7 +5366,7 @@ var require_lazy_result = __commonJS({
5366
5366
  var Container2 = require_container();
5367
5367
  var Document2 = require_document();
5368
5368
  var MapGenerator = require_map_generator();
5369
- var parse3 = require_parse();
5369
+ var parse4 = require_parse();
5370
5370
  var Result2 = require_result();
5371
5371
  var Root2 = require_root();
5372
5372
  var stringify2 = require_stringify();
@@ -5500,7 +5500,7 @@ var require_lazy_result = __commonJS({
5500
5500
  opts.map.prev = css.map;
5501
5501
  }
5502
5502
  } else {
5503
- let parser = parse3;
5503
+ let parser = parse4;
5504
5504
  if (opts.syntax) parser = opts.syntax.parse;
5505
5505
  if (opts.parser) parser = opts.parser;
5506
5506
  if (parser.parse) parser = parser.parse;
@@ -5891,7 +5891,7 @@ var require_no_work_result = __commonJS({
5891
5891
  "../../node_modules/.pnpm/postcss@8.5.26/node_modules/postcss/lib/no-work-result.js"(exports, module) {
5892
5892
  "use strict";
5893
5893
  var MapGenerator = require_map_generator();
5894
- var parse3 = require_parse();
5894
+ var parse4 = require_parse();
5895
5895
  var Result2 = require_result();
5896
5896
  var stringify2 = require_stringify();
5897
5897
  var warnOnce = require_warn_once();
@@ -5919,7 +5919,7 @@ var require_no_work_result = __commonJS({
5919
5919
  return this._root;
5920
5920
  }
5921
5921
  let root2;
5922
- let parser = parse3;
5922
+ let parser = parse4;
5923
5923
  try {
5924
5924
  root2 = parser(this._css, this._opts);
5925
5925
  } catch (error) {
@@ -6074,7 +6074,7 @@ var require_postcss = __commonJS({
6074
6074
  var LazyResult = require_lazy_result();
6075
6075
  var list2 = require_list();
6076
6076
  var Node2 = require_node();
6077
- var parse3 = require_parse();
6077
+ var parse4 = require_parse();
6078
6078
  var Processor2 = require_processor();
6079
6079
  var Result2 = require_result();
6080
6080
  var Root2 = require_root();
@@ -6119,7 +6119,7 @@ var require_postcss = __commonJS({
6119
6119
  return creator;
6120
6120
  };
6121
6121
  postcss2.stringify = stringify2;
6122
- postcss2.parse = parse3;
6122
+ postcss2.parse = parse4;
6123
6123
  postcss2.fromJSON = fromJSON2;
6124
6124
  postcss2.list = list2;
6125
6125
  postcss2.comment = (defaults) => new Comment2(defaults);
@@ -6150,6 +6150,60 @@ var require_postcss = __commonJS({
6150
6150
  // src/hosts/static/cli.ts
6151
6151
  import { resolve as resolve4 } from "node:path";
6152
6152
 
6153
+ // src/cli/agentCommand.ts
6154
+ import { spawnSync } from "node:child_process";
6155
+ import { existsSync } from "node:fs";
6156
+ import { createRequire } from "node:module";
6157
+ import { dirname, join } from "node:path";
6158
+ function planAgentCommand(args, projectRoot, packageVersion) {
6159
+ const projectRequire = createRequire(join(projectRoot, "package.json"));
6160
+ if (args[0] === "setup") {
6161
+ if (!packageVersion || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(packageVersion)) {
6162
+ throw new Error("Run agent setup through the installed nudge-ui executable.");
6163
+ }
6164
+ return {
6165
+ executable: process.platform === "win32" ? "npx.cmd" : "npx",
6166
+ args: ["--yes", `create-nudge-ui@${packageVersion}`, "--agent-only", ...args.slice(1)]
6167
+ };
6168
+ }
6169
+ if (args[0] === "doctor") {
6170
+ let entry;
6171
+ try {
6172
+ const packageEntry = projectRequire.resolve(findLocalMcp(projectRoot, projectRequire));
6173
+ entry = join(dirname(packageEntry), "cli.mjs");
6174
+ } catch {
6175
+ throw new Error("Nudge agent integration is not installed. Run nudge-ui agent setup.");
6176
+ }
6177
+ return {
6178
+ executable: process.execPath,
6179
+ args: [entry, "doctor", "--workspace-root", projectRoot, ...args.slice(1)]
6180
+ };
6181
+ }
6182
+ throw new Error("Usage: nudge-ui agent <setup|doctor> [options]");
6183
+ }
6184
+ function findLocalMcp(projectRoot, projectRequire) {
6185
+ let directory = projectRoot;
6186
+ while (true) {
6187
+ const candidate = join(directory, "node_modules", "@nudge-ui", "mcp");
6188
+ if (existsSync(join(candidate, "package.json"))) return candidate;
6189
+ const parent = dirname(directory);
6190
+ if (parent === directory) break;
6191
+ directory = parent;
6192
+ }
6193
+ if (process.versions.pnp) {
6194
+ return projectRequire.resolve("@nudge-ui/mcp");
6195
+ }
6196
+ throw new Error("MCP is not installed in this project.");
6197
+ }
6198
+ function runAgentCommand(args, packageVersion) {
6199
+ const command = planAgentCommand(args, process.cwd(), packageVersion);
6200
+ const result = spawnSync(command.executable, command.args, { cwd: process.cwd(), stdio: "inherit" });
6201
+ if (result.error) throw result.error;
6202
+ if (result.status !== 0) {
6203
+ throw new Error(`Nudge agent command exited with status ${result.status ?? "unknown"}.`);
6204
+ }
6205
+ }
6206
+
6153
6207
  // src/hosts/static/server.ts
6154
6208
  import { createHash as createHash2 } from "node:crypto";
6155
6209
  import {
@@ -6157,13 +6211,13 @@ import {
6157
6211
  } from "node:http";
6158
6212
  import {
6159
6213
  constants,
6160
- existsSync,
6214
+ existsSync as existsSync3,
6161
6215
  realpathSync as realpathSync2,
6162
6216
  statSync as statSync2
6163
6217
  } from "node:fs";
6164
6218
  import { open, stat as stat2 } from "node:fs/promises";
6165
- import { dirname as dirname2, extname as extname2, isAbsolute as isAbsolute3, join as join3, relative as relative3, resolve as resolve3 } from "node:path";
6166
- import { createRequire } from "node:module";
6219
+ import { dirname as dirname4, extname as extname2, isAbsolute as isAbsolute3, join as join5, relative as relative3, resolve as resolve3 } from "node:path";
6220
+ import { createRequire as createRequire3 } from "node:module";
6167
6221
 
6168
6222
  // ../../node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/unicode.js
6169
6223
  var UNDEFINED_CODE_POINTS = /* @__PURE__ */ new Set([
@@ -14110,8 +14164,14 @@ function positionAt(positions, offset) {
14110
14164
  var NUDGE_UI_ROUTE_PREFIX = "/__nudge_ui__/";
14111
14165
  var NUDGE_UI_MANIFEST_PATH = `${NUDGE_UI_ROUTE_PREFIX}manifest`;
14112
14166
  var NUDGE_UI_CLIENT_PATH = `${NUDGE_UI_ROUTE_PREFIX}client.mjs`;
14167
+ var NUDGE_UI_EDITOR_PATH = `${NUDGE_UI_ROUTE_PREFIX}editor`;
14113
14168
  var NUDGE_UI_RELOAD_PATH = `${NUDGE_UI_ROUTE_PREFIX}reload`;
14114
14169
  var NUDGE_UI_MOUNT_ID = "nudge-ui-root";
14170
+ var NUDGE_UI_EDITOR_QUERY_PARAM = "nudge-ui";
14171
+ var NUDGE_UI_EDITOR_QUERY_VALUE = "editor";
14172
+ function isReservedNudgeUiRoute(pathname) {
14173
+ return pathname === NUDGE_UI_ROUTE_PREFIX.slice(0, -1) || pathname.startsWith(NUDGE_UI_ROUTE_PREFIX);
14174
+ }
14115
14175
 
14116
14176
  // src/html/identity.ts
14117
14177
  function runIdentityPass(source, pass) {
@@ -14212,6 +14272,39 @@ function instrumentSourceHtml(source, file) {
14212
14272
  });
14213
14273
  }
14214
14274
 
14275
+ // src/transport/editor.ts
14276
+ function isNudgeUiEditorDocumentRequest(requestHref, method, headers) {
14277
+ const normalizedMethod = (method ?? "GET").toUpperCase();
14278
+ if (normalizedMethod !== "GET" && normalizedMethod !== "HEAD") return false;
14279
+ const url = new URL(requestHref, "http://nudge-ui.local");
14280
+ if (url.pathname === NUDGE_UI_EDITOR_PATH) return true;
14281
+ if (!isApplicationUrl(url)) return false;
14282
+ if (!url.searchParams.getAll(NUDGE_UI_EDITOR_QUERY_PARAM).includes(NUDGE_UI_EDITOR_QUERY_VALUE)) return false;
14283
+ const header = (name) => {
14284
+ const value = headers?.[name] ?? headers?.[name.toLowerCase()];
14285
+ return typeof value === "string" ? value : value?.join(",") ?? "";
14286
+ };
14287
+ return header("sec-fetch-dest").toLowerCase() === "document" || header("accept").toLowerCase().includes("text/html");
14288
+ }
14289
+ function isApplicationUrl(url) {
14290
+ return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "" && !isReservedNudgeUiRoute(url.pathname);
14291
+ }
14292
+ function createNudgeUiEditorDocument() {
14293
+ return `<!doctype html>
14294
+ <html lang="en" data-nudge-ui-editor>
14295
+ <head>
14296
+ <meta charset="utf-8">
14297
+ <meta name="viewport" content="width=device-width, initial-scale=1">
14298
+ <title>Nudge UI</title>
14299
+ <style>html,body,#${NUDGE_UI_MOUNT_ID}{width:100%;height:100%;margin:0}body{overflow:hidden}</style>
14300
+ </head>
14301
+ <body>
14302
+ <div id="${NUDGE_UI_MOUNT_ID}"></div>
14303
+ <script type="module" src="${NUDGE_UI_CLIENT_PATH}" data-nudge-ui-client data-nudge-ui-manifest="${NUDGE_UI_MANIFEST_PATH}"></script>
14304
+ </body>
14305
+ </html>`;
14306
+ }
14307
+
14215
14308
  // src/transport/index.ts
14216
14309
  var NUDGE_UI_MANIFEST_VERSION = 1;
14217
14310
 
@@ -14327,6 +14420,80 @@ function escapeAttributeValue2(value) {
14327
14420
  return value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
14328
14421
  }
14329
14422
 
14423
+ // src/hosts/projectBridge.ts
14424
+ import { existsSync as existsSync2 } from "node:fs";
14425
+ import { createRequire as createRequire2 } from "node:module";
14426
+ import { dirname as dirname2, join as join2, parse as parse2 } from "node:path";
14427
+ import { pathToFileURL } from "node:url";
14428
+ var runningBridges = /* @__PURE__ */ new Map();
14429
+ async function startOptionalProjectBridge(input) {
14430
+ const key = `${input.appRoot}\0${input.origin}`;
14431
+ const running = runningBridges.get(key);
14432
+ if (running) return running;
14433
+ const starting = launchOptionalProjectBridge(input, key);
14434
+ runningBridges.set(key, starting);
14435
+ void starting.then((bridge) => {
14436
+ if (bridge === null && runningBridges.get(key) === starting) runningBridges.delete(key);
14437
+ });
14438
+ return starting;
14439
+ }
14440
+ async function launchOptionalProjectBridge(input, key) {
14441
+ let modulePath;
14442
+ try {
14443
+ if (!isPnpRuntime() && !hasProjectInstalledMcp(input.appRoot)) {
14444
+ runningBridges.delete(key);
14445
+ return null;
14446
+ }
14447
+ modulePath = createRequire2(join2(input.appRoot, "package.json")).resolve("@nudge-ui/mcp/project");
14448
+ } catch {
14449
+ runningBridges.delete(key);
14450
+ return null;
14451
+ }
14452
+ try {
14453
+ const loaded = await import(pathToFileURL(modulePath).href);
14454
+ if (typeof loaded.startProjectBridge !== "function") {
14455
+ throw new Error("the project bridge export is unavailable");
14456
+ }
14457
+ const runtime = await loaded.startProjectBridge({
14458
+ appRoot: input.appRoot,
14459
+ projectId: input.projectId,
14460
+ origin: input.origin,
14461
+ ...input.allowedOrigins ? { allowedOrigins: input.allowedOrigins } : {}
14462
+ });
14463
+ if (runtime.browser.projectId !== input.projectId || runtime.browser.origin !== input.origin) {
14464
+ await runtime.close().catch(() => void 0);
14465
+ throw new Error("the project bridge returned a different project or origin");
14466
+ }
14467
+ let closed = false;
14468
+ return {
14469
+ browser: { baseUrl: runtime.browser.bridgeUrl, autoConnect: true },
14470
+ close: async () => {
14471
+ if (closed) return;
14472
+ closed = true;
14473
+ runningBridges.delete(key);
14474
+ await runtime.close();
14475
+ }
14476
+ };
14477
+ } catch (error) {
14478
+ const detail = error instanceof Error ? error.message : String(error);
14479
+ input.warn?.(`[nudge-ui] MCP project bridge failed to start: ${detail}`);
14480
+ runningBridges.delete(key);
14481
+ return null;
14482
+ }
14483
+ }
14484
+ function isPnpRuntime() {
14485
+ return typeof process.versions.pnp === "string";
14486
+ }
14487
+ function hasProjectInstalledMcp(appRoot) {
14488
+ let directory = appRoot;
14489
+ const root2 = parse2(directory).root;
14490
+ for (; ; ) {
14491
+ if (existsSync2(join2(directory, "node_modules", "@nudge-ui", "mcp", "package.json"))) return true;
14492
+ if (directory === root2) return false;
14493
+ directory = dirname2(directory);
14494
+ }
14495
+ }
14496
+
14330
14497
  // src/project/tokens.ts
14331
14498
  import { createHash } from "node:crypto";
14332
14499
  import {
@@ -14335,7 +14502,7 @@ import {
14335
14502
  realpath,
14336
14503
  stat
14337
14504
  } from "node:fs/promises";
14338
- import { extname, isAbsolute, join, relative, resolve, sep } from "node:path";
14505
+ import { extname, isAbsolute, join as join3, relative, resolve, sep } from "node:path";
14339
14506
 
14340
14507
  // ../../node_modules/.pnpm/postcss@8.5.26/node_modules/postcss/lib/postcss.mjs
14341
14508
  var import_postcss = __toESM(require_postcss(), 1);
@@ -14343,7 +14510,7 @@ var postcss_default = import_postcss.default;
14343
14510
  var stringify = import_postcss.default.stringify;
14344
14511
  var fromJSON = import_postcss.default.fromJSON;
14345
14512
  var plugin = import_postcss.default.plugin;
14346
- var parse2 = import_postcss.default.parse;
14513
+ var parse3 = import_postcss.default.parse;
14347
14514
  var list = import_postcss.default.list;
14348
14515
  var document = import_postcss.default.document;
14349
14516
  var comment = import_postcss.default.comment;
@@ -14932,7 +15099,7 @@ async function walkDirectory(rootDirectory, directory, visitedDirectories, visit
14932
15099
  entries.sort((a, b) => comparePosixStrings(a.name, b.name));
14933
15100
  for (const entry of entries) {
14934
15101
  if (entry.isDirectory() && isExcludedDirectoryName(entry.name)) continue;
14935
- const absolutePath = join(directory, entry.name);
15102
+ const absolutePath = join3(directory, entry.name);
14936
15103
  const canonicalPath = await canonicalWithinRoot(rootDirectory, absolutePath);
14937
15104
  if (!canonicalPath) continue;
14938
15105
  let stats;
@@ -15031,7 +15198,7 @@ function comparePosixStrings(a, b) {
15031
15198
  import { watch } from "node:fs";
15032
15199
  import { readdir as readdir2 } from "node:fs/promises";
15033
15200
  import { realpathSync, statSync } from "node:fs";
15034
- import { dirname, isAbsolute as isAbsolute2, join as join2, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
15201
+ import { dirname as dirname3, isAbsolute as isAbsolute2, join as join4, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
15035
15202
  function createProjectFileWatcher(options) {
15036
15203
  const rootDirectory = realpathSync(resolve2(options.rootDirectory));
15037
15204
  const debounceMs = Math.max(0, options.debounceMs ?? 60);
@@ -15084,7 +15251,7 @@ function createProjectFileWatcher(options) {
15084
15251
  try {
15085
15252
  directoryWatcher = watch(directory, { persistent: true }, (eventType, filename) => {
15086
15253
  const changedName = filename?.toString();
15087
- const changedPath = changedName ? join2(directory, changedName) : directory;
15254
+ const changedPath = changedName ? join4(directory, changedName) : directory;
15088
15255
  if (!isProjectPath(rootDirectory, changedPath)) return;
15089
15256
  if (isProjectDirectory(rootDirectory, changedPath)) watchDirectory(changedPath);
15090
15257
  else if (!exists(changedPath)) closeDescendants(changedPath);
@@ -15113,7 +15280,7 @@ function createProjectFileWatcher(options) {
15113
15280
  for (const entry of entries) {
15114
15281
  if (closed) return;
15115
15282
  if (!entry.isDirectory() || isExcludedDirectoryName(entry.name)) continue;
15116
- const child = join2(directory, entry.name);
15283
+ const child = join4(directory, entry.name);
15117
15284
  if (!isProjectPath(rootDirectory, child)) continue;
15118
15285
  watchDirectory(child);
15119
15286
  }
@@ -15177,7 +15344,7 @@ function canonicalProjectPath(rootDirectory, path) {
15177
15344
  const canonical = realpathSync(path);
15178
15345
  return isWithin(rootDirectory, canonical) && !isSensitiveProjectPath(relative2(rootDirectory, canonical).split(sep2).join("/")) ? canonical : null;
15179
15346
  } catch {
15180
- const parent = dirname(path);
15347
+ const parent = dirname3(path);
15181
15348
  if (parent === path) return null;
15182
15349
  try {
15183
15350
  const canonicalParent = realpathSync(parent);
@@ -15202,7 +15369,7 @@ function comparePosixStrings2(a, b) {
15202
15369
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "localhost"]);
15203
15370
  var HTML_EXTENSIONS = /* @__PURE__ */ new Set([".html", ".htm"]);
15204
15371
  var DEFAULT_PORT = 4173;
15205
- var packageRequire = createRequire(import.meta.url);
15372
+ var packageRequire = createRequire3(import.meta.url);
15206
15373
  function createStandaloneServer(options) {
15207
15374
  const rootDirectory = canonicalDirectory(options.rootDirectory);
15208
15375
  const host = options.host ?? "127.0.0.1";
@@ -15219,6 +15386,7 @@ function createStandaloneServer(options) {
15219
15386
  EMPTY_PROJECT_TOKEN_SNAPSHOT,
15220
15387
  revision
15221
15388
  );
15389
+ let projectBridge = null;
15222
15390
  const initialTokens = createProjectTokenSnapshot({ rootDirectory, generationLabel: "static-html" }).then((tokens) => {
15223
15391
  manifest = createStandaloneRuntimeManifest(projectId, tokens, revision);
15224
15392
  return tokens;
@@ -15255,7 +15423,10 @@ data: ${JSON.stringify({ revision })}
15255
15423
  const processSettledChanges = (_changes) => {
15256
15424
  changeQueue = changeQueue.then(async () => {
15257
15425
  const tokens = await createProjectTokenSnapshot({ rootDirectory, generationLabel: "static-html" });
15258
- manifest = createStandaloneRuntimeManifest(projectId, tokens, revision + 1);
15426
+ manifest = {
15427
+ ...createStandaloneRuntimeManifest(projectId, tokens, revision + 1),
15428
+ ...projectBridge ? { agentBridge: projectBridge.browser } : {}
15429
+ };
15259
15430
  revision += 1;
15260
15431
  notifyReload();
15261
15432
  }).catch((error) => {
@@ -15322,7 +15493,21 @@ data: ${JSON.stringify({ revision })}
15322
15493
  rejectStart(new Error("Standalone server closed during startup."));
15323
15494
  return;
15324
15495
  }
15325
- resolveStart(readAddress(httpServer, host));
15496
+ const address = readAddress(httpServer, host);
15497
+ void startOptionalProjectBridge({
15498
+ appRoot: rootDirectory,
15499
+ projectId,
15500
+ origin: address.url.replace(/\/$/, ""),
15501
+ warn: (message) => console.warn(message)
15502
+ }).then((bridge) => {
15503
+ projectBridge = bridge;
15504
+ if (bridge) manifest = { ...manifest, agentBridge: bridge.browser };
15505
+ if (closeRequested) {
15506
+ rejectStart(new Error("Standalone server closed during startup."));
15507
+ return;
15508
+ }
15509
+ resolveStart(address);
15510
+ });
15326
15511
  });
15327
15512
  };
15328
15513
  httpServer.once("error", onError);
@@ -15339,7 +15524,10 @@ data: ${JSON.stringify({ revision })}
15339
15524
  const closeWatcher = fileWatcher?.close() ?? Promise.resolve();
15340
15525
  fileWatcher = null;
15341
15526
  closeReloadClients();
15342
- const closing = closeWatcher.then(() => pendingStart?.catch(() => void 0)).then(() => changeQueue).then(() => {
15527
+ const closing = closeWatcher.then(() => pendingStart?.catch(() => void 0)).then(async () => {
15528
+ await projectBridge?.close();
15529
+ projectBridge = null;
15530
+ }).then(() => changeQueue).then(() => {
15343
15531
  if (!httpServer.listening) return;
15344
15532
  return new Promise((resolveClose, rejectClose) => {
15345
15533
  httpServer.close((error) => {
@@ -15369,13 +15557,13 @@ function resolveDecodedStaticFile(root2, decodedPath) {
15369
15557
  if (!isWithin2(root2, candidate)) return null;
15370
15558
  const canonicalCandidate = canonicalExistingAncestor(candidate);
15371
15559
  if (!canonicalCandidate || !isWithin2(root2, canonicalCandidate)) return null;
15372
- if (!existsSync(candidate)) return null;
15560
+ if (!existsSync3(candidate)) return null;
15373
15561
  let filePath = canonicalCandidate;
15374
15562
  const stats = statSync2(filePath);
15375
15563
  if (stats.isDirectory()) {
15376
- const indexCandidate = join3(filePath, "index.html");
15564
+ const indexCandidate = join5(filePath, "index.html");
15377
15565
  const canonicalIndex = canonicalExistingAncestor(indexCandidate);
15378
- if (!canonicalIndex || !isWithin2(root2, canonicalIndex) || !existsSync(indexCandidate)) {
15566
+ if (!canonicalIndex || !isWithin2(root2, canonicalIndex) || !existsSync3(indexCandidate)) {
15379
15567
  return null;
15380
15568
  }
15381
15569
  if (!statSync2(canonicalIndex).isFile()) return null;
@@ -15396,7 +15584,7 @@ function contentTypeForPath(filePath) {
15396
15584
  const extension = extname2(filePath).toLowerCase();
15397
15585
  return MIME_TYPES2[extension] ?? "application/octet-stream";
15398
15586
  }
15399
- function isReservedNudgeUiRoute(pathname) {
15587
+ function isReservedNudgeUiRoute2(pathname) {
15400
15588
  return pathname === NUDGE_UI_ROUTE_PREFIX.slice(0, -1) || pathname.startsWith(NUDGE_UI_ROUTE_PREFIX);
15401
15589
  }
15402
15590
  function canonicalDirectory(directory) {
@@ -15455,7 +15643,7 @@ function canonicalExistingAncestor(candidate) {
15455
15643
  return realpathSync2(current);
15456
15644
  } catch (error) {
15457
15645
  if (!isMissingPathError(error)) return null;
15458
- const parent = dirname2(current);
15646
+ const parent = dirname4(current);
15459
15647
  if (parent === current) return null;
15460
15648
  current = parent;
15461
15649
  }
@@ -15479,10 +15667,15 @@ async function handleRequest(input) {
15479
15667
  sendText(response, 400, "Bad Request");
15480
15668
  return;
15481
15669
  }
15482
- if (isReservedNudgeUiRoute(decodedPath)) {
15670
+ if (isReservedNudgeUiRoute2(decodedPath)) {
15483
15671
  await handleNudgeUiRoute(input, decodedPath);
15484
15672
  return;
15485
15673
  }
15674
+ if (isNudgeUiEditorDocumentRequest(request.url ?? "/", request.method, request.headers)) {
15675
+ const body2 = request.method === "HEAD" ? Buffer.alloc(0) : Buffer.from(createNudgeUiEditorDocument(), "utf8");
15676
+ sendBody(response, 200, body2, "text/html; charset=utf-8", { "Cache-Control": "no-store" });
15677
+ return;
15678
+ }
15486
15679
  const resolution = resolveDecodedStaticFile(input.rootDirectory, decodedPath);
15487
15680
  if (!resolution) {
15488
15681
  sendText(response, 404, "Not Found");
@@ -15533,6 +15726,13 @@ async function handleNudgeUiRoute(input, pathname) {
15533
15726
  });
15534
15727
  return;
15535
15728
  }
15729
+ if (pathname === NUDGE_UI_EDITOR_PATH) {
15730
+ const body = input.request.method === "HEAD" ? Buffer.alloc(0) : Buffer.from(createNudgeUiEditorDocument(), "utf8");
15731
+ sendBody(input.response, 200, body, "text/html; charset=utf-8", {
15732
+ "Cache-Control": "no-store"
15733
+ });
15734
+ return;
15735
+ }
15536
15736
  if (pathname === NUDGE_UI_CLIENT_PATH) {
15537
15737
  try {
15538
15738
  const body = await readFileFromDescriptor(input.clientPath ?? resolveDefaultClientPath());
@@ -15687,7 +15887,11 @@ async function runServeCommand(options) {
15687
15887
  console.log(`Nudge UI serving ${server.rootDirectory} at ${address.url}`);
15688
15888
  await waitForTermination(server);
15689
15889
  }
15690
- async function main(args = process.argv.slice(2)) {
15890
+ async function main(args = process.argv.slice(2), packageVersion) {
15891
+ if (args[0] === "agent") {
15892
+ runAgentCommand(args.slice(1), packageVersion);
15893
+ return;
15894
+ }
15691
15895
  const options = parseServeArguments(args);
15692
15896
  await runServeCommand(options);
15693
15897
  }