@plannotator/opencode 0.27.5 → 0.27.6

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/dist/embedded.js CHANGED
@@ -105386,7 +105386,7 @@ var init_agent_terminal3 = __esm(() => {
105386
105386
  init_agent_terminal_runtime();
105387
105387
  });
105388
105388
 
105389
- // ../../packages/server/live-proxy.ts
105389
+ // ../../packages/shared/live-proxy-core.ts
105390
105390
  function isLoopbackHostname(hostname) {
105391
105391
  const host = hostname.toLowerCase();
105392
105392
  if (host === "localhost" || host === "::1" || host === "[::1]")
@@ -105404,6 +105404,12 @@ function isAllowedProxyHost(hostHeader, port) {
105404
105404
  function isAllowedProxyOrigin(origin, port) {
105405
105405
  return origin === `http://127.0.0.1:${port}` || origin === `http://localhost:${port}` || origin === `http://[::1]:${port}`;
105406
105406
  }
105407
+ function isAllowedWsUpgradeOrigin(origin, port) {
105408
+ return origin === null || isAllowedProxyOrigin(origin, port);
105409
+ }
105410
+ function isAllowedBridgeFetchSite(fetchSite) {
105411
+ return !fetchSite || fetchSite === "same-origin" || fetchSite === "none";
105412
+ }
105407
105413
  function rewriteLoopbackLocation(location, target, proxyOrigin) {
105408
105414
  if (!/^http:\/\//i.test(location))
105409
105415
  return null;
@@ -105426,6 +105432,18 @@ function isDocumentIntentRequest(headers) {
105426
105432
  const accept = headers.get("accept");
105427
105433
  return !!accept && accept.includes("text/html");
105428
105434
  }
105435
+ function isHtmlContentType(contentType) {
105436
+ return (contentType ?? "").toLowerCase().includes("text/html");
105437
+ }
105438
+ function buildFrameAncestorsPolicy(editorOrigins) {
105439
+ return `frame-ancestors ${editorOrigins.join(" ")}`;
105440
+ }
105441
+ function applyHtmlFramingHeaders(headers, frameAncestors) {
105442
+ headers.delete("x-frame-options");
105443
+ headers.delete("content-security-policy");
105444
+ headers.delete("content-security-policy-report-only");
105445
+ headers.set("content-security-policy", frameAncestors);
105446
+ }
105429
105447
  function createHtmlInjector(injection) {
105430
105448
  const encoder2 = new TextEncoder;
105431
105449
  const injectionBytes = encoder2.encode(injection);
@@ -105593,6 +105611,54 @@ function createHtmlInjector(injection) {
105593
105611
  }
105594
105612
  };
105595
105613
  }
105614
+ function composeLiveBridgeJs(sources) {
105615
+ return "window.__plannotatorLiveConfig = " + JSON.stringify({
105616
+ live: true,
105617
+ token: sources.token,
105618
+ editorOrigins: sources.editorOrigins,
105619
+ css: sources.annotationCss
105620
+ }) + `;
105621
+ ` + sources.bridgeBootstrap + `
105622
+ ` + sources.bridgeScript;
105623
+ }
105624
+ function buildLiveEditorOrigins(port) {
105625
+ return [`http://localhost:${port}`, `http://127.0.0.1:${port}`];
105626
+ }
105627
+ function buildLiveAppUrl(proxyPort, targetUrl) {
105628
+ let targetPath = "/";
105629
+ try {
105630
+ const parsedTarget = new URL(targetUrl);
105631
+ targetPath = parsedTarget.pathname + parsedTarget.search;
105632
+ } catch {
105633
+ targetPath = "/";
105634
+ }
105635
+ return `http://localhost:${proxyPort}${targetPath}`;
105636
+ }
105637
+ function liveAppDraftIdentity(targetUrl) {
105638
+ try {
105639
+ const url = new URL(targetUrl);
105640
+ const path3 = url.pathname.replace(/\/+$/, "");
105641
+ return `${url.origin}${path3}${url.search}`;
105642
+ } catch {
105643
+ return targetUrl.trim();
105644
+ }
105645
+ }
105646
+ var LIVE_PROXY_RESERVED_PREFIX = "/__plannotator__/", LIVE_PROXY_BRIDGE_PATH = "/__plannotator__/bridge.js", LIVE_PROXY_BRIDGE_TAG, HOP_BY_HOP_HEADERS, LIVE_PROXY_MAX_PENDING_WS_MESSAGES = 200, HEAD_OPEN = "<head", HEAD_CLOSE = "</head>", COMMENT_OPEN = "<!--", GT2 = 62, LT2 = 60, BANG = 33, QUESTION = 63, HYPHEN = 45, HOLDBACK = 8;
105647
+ var init_live_proxy_core = __esm(() => {
105648
+ LIVE_PROXY_BRIDGE_TAG = `<script src="${LIVE_PROXY_BRIDGE_PATH}"></script>`;
105649
+ HOP_BY_HOP_HEADERS = [
105650
+ "connection",
105651
+ "keep-alive",
105652
+ "proxy-authenticate",
105653
+ "proxy-authorization",
105654
+ "te",
105655
+ "trailer",
105656
+ "transfer-encoding",
105657
+ "upgrade"
105658
+ ];
105659
+ });
105660
+
105661
+ // ../../packages/server/live-proxy.ts
105596
105662
  function stripHopByHop(headers) {
105597
105663
  for (const name of HOP_BY_HOP_HEADERS)
105598
105664
  headers.delete(name);
@@ -105617,7 +105683,7 @@ function startLiveAppProxy(opts) {
105617
105683
  }
105618
105684
  const targetOrigin = target.origin;
105619
105685
  const targetHost = target.host;
105620
- const frameAncestors = `frame-ancestors ${opts.editorOrigins.join(" ")}`;
105686
+ const frameAncestors = buildFrameAncestorsPolicy(opts.editorOrigins);
105621
105687
  const wsUpstreams = new Set;
105622
105688
  let warnedEncodedHtml = false;
105623
105689
  const server2 = Bun.serve({
@@ -105636,8 +105702,7 @@ function startLiveAppProxy(opts) {
105636
105702
  }
105637
105703
  if (url.pathname.startsWith(LIVE_PROXY_RESERVED_PREFIX)) {
105638
105704
  if (url.pathname === LIVE_PROXY_BRIDGE_PATH && (req.method === "GET" || req.method === "HEAD")) {
105639
- const fetchSite = req.headers.get("sec-fetch-site");
105640
- if (fetchSite && fetchSite !== "same-origin" && fetchSite !== "none") {
105705
+ if (!isAllowedBridgeFetchSite(req.headers.get("sec-fetch-site"))) {
105641
105706
  return new Response("Forbidden", { status: 403, headers: { "Content-Type": "text/plain" } });
105642
105707
  }
105643
105708
  return new Response(req.method === "HEAD" ? null : opts.bridgeJs, {
@@ -105650,8 +105715,7 @@ function startLiveAppProxy(opts) {
105650
105715
  return new Response("Not found", { status: 404 });
105651
105716
  }
105652
105717
  if ((req.headers.get("upgrade") ?? "").toLowerCase() === "websocket") {
105653
- const wsOrigin = req.headers.get("origin");
105654
- if (wsOrigin !== null && !isAllowedProxyOrigin(wsOrigin, srv.port)) {
105718
+ if (!isAllowedWsUpgradeOrigin(req.headers.get("origin"), srv.port)) {
105655
105719
  return new Response("Forbidden", { status: 403, headers: { "Content-Type": "text/plain" } });
105656
105720
  }
105657
105721
  const upgraded = srv.upgrade(req, {
@@ -105695,13 +105759,9 @@ function startLiveAppProxy(opts) {
105695
105759
  if (rewritten !== null)
105696
105760
  responseHeaders.set("location", rewritten);
105697
105761
  }
105698
- const contentType = (responseHeaders.get("content-type") ?? "").toLowerCase();
105699
- const isHtml = contentType.includes("text/html");
105762
+ const isHtml = isHtmlContentType(responseHeaders.get("content-type"));
105700
105763
  if (isHtml) {
105701
- responseHeaders.delete("x-frame-options");
105702
- responseHeaders.delete("content-security-policy");
105703
- responseHeaders.delete("content-security-policy-report-only");
105704
- responseHeaders.set("content-security-policy", frameAncestors);
105764
+ applyHtmlFramingHeaders(responseHeaders, frameAncestors);
105705
105765
  }
105706
105766
  const hasEncoding = !!responseHeaders.get("content-encoding");
105707
105767
  if (!isHtml || hasEncoding || !upstreamResponse.body) {
@@ -105790,7 +105850,7 @@ function startLiveAppProxy(opts) {
105790
105850
  upstream.send(payload);
105791
105851
  return;
105792
105852
  }
105793
- if (ws.data.pending.length >= MAX_PENDING_WS_MESSAGES) {
105853
+ if (ws.data.pending.length >= LIVE_PROXY_MAX_PENDING_WS_MESSAGES) {
105794
105854
  ws.close();
105795
105855
  if (upstream)
105796
105856
  upstream.close();
@@ -105821,18 +105881,10 @@ function startLiveAppProxy(opts) {
105821
105881
  }
105822
105882
  };
105823
105883
  }
105824
- var LOOPBACK_HOST2 = "127.0.0.1", LIVE_PROXY_RESERVED_PREFIX = "/__plannotator__/", LIVE_PROXY_BRIDGE_PATH = "/__plannotator__/bridge.js", HOP_BY_HOP_HEADERS, MAX_PENDING_WS_MESSAGES = 200, HEAD_OPEN = "<head", HEAD_CLOSE = "</head>", COMMENT_OPEN = "<!--", GT2 = 62, LT2 = 60, BANG = 33, QUESTION = 63, HYPHEN = 45, HOLDBACK = 8;
105884
+ var LOOPBACK_HOST2 = "127.0.0.1";
105825
105885
  var init_live_proxy = __esm(() => {
105826
- HOP_BY_HOP_HEADERS = [
105827
- "connection",
105828
- "keep-alive",
105829
- "proxy-authenticate",
105830
- "proxy-authorization",
105831
- "te",
105832
- "trailer",
105833
- "transfer-encoding",
105834
- "upgrade"
105835
- ];
105886
+ init_live_proxy_core();
105887
+ init_live_proxy_core();
105836
105888
  });
105837
105889
 
105838
105890
  // ../../packages/server/annotate.ts
@@ -105852,15 +105904,6 @@ function runGuardedShutdown(steps, closeListener, log = (message, error) => cons
105852
105904
  closeListener();
105853
105905
  }
105854
105906
  }
105855
- function liveAppDraftIdentity(targetUrl) {
105856
- try {
105857
- const url = new URL(targetUrl);
105858
- const path3 = url.pathname.replace(/\/+$/, "");
105859
- return `${url.origin}${path3}${url.search}`;
105860
- } catch {
105861
- return targetUrl.trim();
105862
- }
105863
- }
105864
105907
  async function startAnnotateServer(options) {
105865
105908
  const {
105866
105909
  markdown,
@@ -106448,31 +106491,19 @@ async function startAnnotateServer(options) {
106448
106491
  const serverUrl = buildAdvertisedUrl(port);
106449
106492
  if (liveApp) {
106450
106493
  liveSessionToken = randomBytes2(16).toString("hex");
106451
- const editorOrigins = [
106452
- `http://localhost:${port}`,
106453
- `http://127.0.0.1:${port}`
106454
- ];
106455
- const bridgeJs = "window.__plannotatorLiveConfig = " + JSON.stringify({
106456
- live: true,
106457
- token: liveSessionToken,
106458
- editorOrigins,
106459
- css: liveApp.annotationCss
106460
- }) + `;
106461
- ` + liveApp.bridgeBootstrap + `
106462
- ` + liveApp.bridgeScript;
106494
+ const editorOrigins = buildLiveEditorOrigins(port);
106463
106495
  liveProxy = startLiveAppProxy({
106464
106496
  targetUrl: liveApp.targetUrl,
106465
106497
  editorOrigins,
106466
- bridgeJs
106498
+ bridgeJs: composeLiveBridgeJs({
106499
+ token: liveSessionToken,
106500
+ editorOrigins,
106501
+ annotationCss: liveApp.annotationCss,
106502
+ bridgeBootstrap: liveApp.bridgeBootstrap,
106503
+ bridgeScript: liveApp.bridgeScript
106504
+ })
106467
106505
  });
106468
- let targetPath = "/";
106469
- try {
106470
- const parsedTarget = new URL(liveApp.targetUrl);
106471
- targetPath = parsedTarget.pathname + parsedTarget.search;
106472
- } catch {
106473
- targetPath = "/";
106474
- }
106475
- liveAppUrl = `http://localhost:${liveProxy.port}${targetPath}`;
106506
+ liveAppUrl = buildLiveAppUrl(liveProxy.port, liveApp.targetUrl);
106476
106507
  }
106477
106508
  warmFileListCache(process.cwd(), "code");
106478
106509
  const stop2 = () => {
@@ -106529,10 +106560,12 @@ var init_annotate = __esm(() => {
106529
106560
  init_html_assets2();
106530
106561
  init_agent_terminal3();
106531
106562
  init_live_proxy();
106563
+ init_live_proxy_core();
106532
106564
  init_agent_terminal2();
106533
106565
  init_remote();
106534
106566
  init_browser();
106535
106567
  init_shared_handlers();
106568
+ init_live_proxy_core();
106536
106569
  });
106537
106570
 
106538
106571
  // ../../packages/shared/at-reference.ts
@@ -106553,9 +106586,10 @@ var init_at_reference = __esm(() => {
106553
106586
  });
106554
106587
 
106555
106588
  // ../../packages/shared/annotate-args.ts
106556
- function parseAnnotateArgs(raw2) {
106589
+ function parseAnnotateArgs(raw2, opts) {
106557
106590
  const s10 = (raw2 ?? "").trim();
106558
- const flags = { gate: false, json: false, hook: false, renderHtml: false, renderMarkdown: false, noJina: false };
106591
+ const flags = { gate: false, json: false, hook: false, renderHtml: false, renderMarkdown: false, noJina: false, app: false, static: false };
106592
+ const flagMap = opts?.liveFlags ? { ...FLAG_MAP, ...LIVE_FLAG_MAP } : { ...FLAG_MAP };
106559
106593
  const segments = [];
106560
106594
  for (let i7 = 0;i7 < s10.length; ) {
106561
106595
  const isWs = /\s/.test(s10[i7]);
@@ -106569,7 +106603,7 @@ function parseAnnotateArgs(raw2) {
106569
106603
  const seg = segments[j2];
106570
106604
  if (seg.type !== "tok")
106571
106605
  continue;
106572
- const key2 = FLAG_MAP[seg.text];
106606
+ const key2 = flagMap[seg.text];
106573
106607
  if (!key2)
106574
106608
  continue;
106575
106609
  flags[key2] = true;
@@ -106585,7 +106619,7 @@ function parseAnnotateArgs(raw2) {
106585
106619
  flags.gate = true;
106586
106620
  return { filePath: stripAtPrefix(rawFilePath), rawFilePath, ...flags };
106587
106621
  }
106588
- var FLAG_MAP;
106622
+ var FLAG_MAP, LIVE_FLAG_MAP;
106589
106623
  var init_annotate_args = __esm(() => {
106590
106624
  init_at_reference();
106591
106625
  init_resolve_file();
@@ -106597,6 +106631,10 @@ var init_annotate_args = __esm(() => {
106597
106631
  "--markdown": "renderMarkdown",
106598
106632
  "--no-jina": "noJina"
106599
106633
  };
106634
+ LIVE_FLAG_MAP = {
106635
+ "--app": "app",
106636
+ "--static": "static"
106637
+ };
106600
106638
  });
106601
106639
 
106602
106640
  // ../../packages/shared/annotate-target.ts
package/dist/index.js CHANGED
@@ -12886,9 +12886,14 @@ var FLAG_MAP = {
12886
12886
  "--markdown": "renderMarkdown",
12887
12887
  "--no-jina": "noJina"
12888
12888
  };
12889
- function parseAnnotateArgs(raw) {
12889
+ var LIVE_FLAG_MAP = {
12890
+ "--app": "app",
12891
+ "--static": "static"
12892
+ };
12893
+ function parseAnnotateArgs(raw, opts) {
12890
12894
  const s = (raw ?? "").trim();
12891
- const flags = { gate: false, json: false, hook: false, renderHtml: false, renderMarkdown: false, noJina: false };
12895
+ const flags = { gate: false, json: false, hook: false, renderHtml: false, renderMarkdown: false, noJina: false, app: false, static: false };
12896
+ const flagMap = opts?.liveFlags ? { ...FLAG_MAP, ...LIVE_FLAG_MAP } : { ...FLAG_MAP };
12892
12897
  const segments = [];
12893
12898
  for (let i = 0;i < s.length; ) {
12894
12899
  const isWs = /\s/.test(s[i]);
@@ -12902,7 +12907,7 @@ function parseAnnotateArgs(raw) {
12902
12907
  const seg = segments[j];
12903
12908
  if (seg.type !== "tok")
12904
12909
  continue;
12905
- const key = FLAG_MAP[seg.text];
12910
+ const key = flagMap[seg.text];
12906
12911
  if (!key)
12907
12912
  continue;
12908
12913
  flags[key] = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plannotator/opencode",
3
- "version": "0.27.5",
3
+ "version": "0.27.6",
4
4
  "type": "module",
5
5
  "description": "Plannotator plugin for OpenCode - interactive plan review with visual annotation",
6
6
  "author": "backnotprop",