dsh-open-artifact 0.9.1 → 0.9.2

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/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // dsh-open-artifact 0.9.1: the DSH plugin (server half). Built by scripts/build.mjs; do not edit.
1
+ // dsh-open-artifact 0.9.2: the DSH plugin (server half). Built by scripts/build.mjs; do not edit.
2
2
 
3
3
  // packages/daemon/src/client.ts
4
4
  import { spawn } from "node:child_process";
@@ -358,7 +358,7 @@ function readJson(file, fallback) {
358
358
  // packages/daemon/package.json
359
359
  var package_default = {
360
360
  name: "@open-artifact/daemon",
361
- version: "0.9.1",
361
+ version: "0.9.2",
362
362
  private: true,
363
363
  type: "module",
364
364
  description: "The Open Artifact daemon (`open-artifact`): type registry, artifact library, type servers, agent tools, wake routing, the Harness API, MCP and the Shell.",
@@ -370,7 +370,7 @@ var package_default = {
370
370
  "./client": "./src/client.ts"
371
371
  },
372
372
  dependencies: {
373
- "@open-artifact/protocol": "0.9.1"
373
+ "@open-artifact/protocol": "0.9.2"
374
374
  },
375
375
  license: "Apache-2.0"
376
376
  };
@@ -596,6 +596,160 @@ function service(ctx, name2) {
596
596
  }
597
597
  }
598
598
 
599
+ // plugins/dsh/src/server/changelog.ts
600
+ import { existsSync, readFileSync as readFileSync2 } from "node:fs";
601
+ import { join as join3 } from "node:path";
602
+
603
+ // plugins/dsh/src/shared/routes.ts
604
+ var ROUTE_BASE = "/api/open-artifact.artifacts";
605
+ var PATHS = Object.freeze({
606
+ /** GET: every artifact in the library and the types a new session can make ({@link ArtifactList}). */
607
+ list: ROUTE_BASE,
608
+ /** POST `?id=`: count it as opened and start its page (`{ url, sessionId, title }`; `url` is the Shell). */
609
+ open: `${ROUTE_BASE}.open`,
610
+ /** POST `?id=`: start its page without counting an opening (`{ url }`, the page itself): for a thumbnail. */
611
+ preview: `${ROUTE_BASE}.preview`,
612
+ /** GET `?id=&v=`: the saved thumbnail (a JPEG). POST the bytes to save one (`{ thumbnail }`). */
613
+ thumbnail: `${ROUTE_BASE}.thumbnail`,
614
+ /** POST `?id=` with `{ pinned?, title? }`: the artifact as it is now. */
615
+ update: `${ROUTE_BASE}.update`,
616
+ /** POST `?id=`: take it off the library (`{ trash, path }`); its folder stays where it is. */
617
+ delete: `${ROUTE_BASE}.delete`,
618
+ /** POST `?trash=<id>`: put back what the delete route took away. */
619
+ restore: `${ROUTE_BASE}.restore`,
620
+ /** GET: the daemon's library events as server-sent events (`data:` is a `LibraryEvent`). */
621
+ events: `${ROUTE_BASE}.events`,
622
+ /** GET: the daemon's `host.open` requests as server-sent events (`data:` is a {@link HostOpenRequest}). */
623
+ hostOpens: `${ROUTE_BASE}.host-opens`,
624
+ /** POST `?id=&opened=1|0`: whether a browser half showed the artifact of one {@link HostOpenRequest}. */
625
+ hostOpened: `${ROUTE_BASE}.host-opened`,
626
+ /** GET: whether this plugin has a newer release on its registry ({@link UpdateCheck}). */
627
+ updates: `${ROUTE_BASE}.updates`,
628
+ /** GET `?upcoming=1`: the release notes of the version installed and the ones before it, and with `upcoming` of a newer release offered (`ChangelogAnswer`, src/shared/changelog.ts). */
629
+ changelog: `${ROUTE_BASE}.changelog`
630
+ });
631
+ function isNewer(a, b) {
632
+ const parts = (version) => {
633
+ const [core = "", pre] = version.split("+")[0].split(/-(.*)/s);
634
+ return { numbers: core.split(".").map((n) => Number.parseInt(n, 10) || 0), pre };
635
+ };
636
+ const left = parts(a);
637
+ const right = parts(b);
638
+ for (let i = 0; i < 3; i++) {
639
+ const difference = (left.numbers[i] ?? 0) - (right.numbers[i] ?? 0);
640
+ if (difference !== 0) return difference > 0;
641
+ }
642
+ if (left.pre === void 0 || right.pre === void 0) return left.pre === void 0 && right.pre !== void 0;
643
+ return left.pre.localeCompare(right.pre, "en", { numeric: true }) > 0;
644
+ }
645
+
646
+ // plugins/dsh/src/shared/changelog.ts
647
+ var RELEASE = /^## \[([^\]]+)\](?:\s*-\s*(\S+))?/;
648
+ var LINK_REFERENCE = /^\[[^\]]+\]:\s/;
649
+ function parseChangelog(text) {
650
+ const releases = [];
651
+ let release = null;
652
+ let section = null;
653
+ let open = null;
654
+ for (const raw of text.split(/\r?\n/)) {
655
+ const line = raw.trimEnd();
656
+ const head = RELEASE.exec(line);
657
+ if (head) {
658
+ release = { version: head[1].replace(/^v/, ""), date: head[2] ?? "", summary: [], sections: [] };
659
+ releases.push(release);
660
+ section = null;
661
+ open = null;
662
+ continue;
663
+ }
664
+ if (release === null) continue;
665
+ if (line.startsWith("## ") || LINK_REFERENCE.test(line)) {
666
+ release = null;
667
+ continue;
668
+ }
669
+ if (line.startsWith("### ")) {
670
+ section = { title: line.slice(4).trim(), items: [] };
671
+ release.sections.push(section);
672
+ open = null;
673
+ continue;
674
+ }
675
+ const text2 = line.trim();
676
+ if (text2 === "") {
677
+ if (open === "summary") open = null;
678
+ continue;
679
+ }
680
+ const item = /^[-*]\s+(.*)$/.exec(text2);
681
+ if (item && section !== null) {
682
+ section.items.push(item[1]);
683
+ open = "item";
684
+ } else if (open === "item" && section !== null && section.items.length > 0) {
685
+ section.items[section.items.length - 1] += ` ${text2}`;
686
+ } else if (section === null) {
687
+ if (open === "summary") release.summary[release.summary.length - 1] += ` ${text2}`;
688
+ else release.summary.push(text2);
689
+ open = "summary";
690
+ }
691
+ }
692
+ return releases.filter((r) => r.summary.length > 0 || r.sections.some((s) => s.items.length > 0));
693
+ }
694
+ function releasesBetween(releases, after, upTo) {
695
+ return releases.filter((r) => !isNewer(r.version, upTo) && (after === "" || isNewer(r.version, after))).sort((a, b) => isNewer(a.version, b.version) ? -1 : isNewer(b.version, a.version) ? 1 : 0);
696
+ }
697
+
698
+ // plugins/dsh/src/server/changelog.ts
699
+ var LOOKUP_MS = 8e3;
700
+ var REPOSITORY_RAW = "https://raw.githubusercontent.com/JimLiu/open-artifact";
701
+ function changelogSources(name2, version, registry) {
702
+ const sources = [];
703
+ if (/^https:\/\/registry\.npmmirror\.com\/?$/.test(registry)) sources.push(`https://registry.npmmirror.com/${name2}/${version}/files/CHANGELOG.md`);
704
+ sources.push(`https://cdn.jsdelivr.net/npm/${name2}@${version}/CHANGELOG.md`, `${REPOSITORY_RAW}/v${version}/CHANGELOG.md`);
705
+ return sources;
706
+ }
707
+ function changelogReader({ name: name2, root, updates, fetcher = fetch }) {
708
+ let local = null;
709
+ const remote = /* @__PURE__ */ new Map();
710
+ const installed = () => {
711
+ let version = "";
712
+ try {
713
+ version = JSON.parse(readFileSync2(join3(root, "package.json"), "utf8")).version ?? "";
714
+ } catch {
715
+ }
716
+ if (local?.version === version) return local;
717
+ const file = [join3(root, "CHANGELOG.md"), join3(root, "..", "..", "CHANGELOG.md")].find((path) => existsSync(path));
718
+ let releases = [];
719
+ try {
720
+ if (file && version) releases = releasesBetween(parseChangelog(readFileSync2(file, "utf8")), "", version);
721
+ } catch {
722
+ releases = [];
723
+ }
724
+ return local = { version, releases };
725
+ };
726
+ const notesOf = async (latest, registry) => {
727
+ const kept = remote.get(latest);
728
+ if (kept) return kept;
729
+ for (const url of changelogSources(name2, latest, registry)) {
730
+ try {
731
+ const response = await fetcher(url, { signal: AbortSignal.timeout(LOOKUP_MS) });
732
+ if (!response.ok) continue;
733
+ const releases = parseChangelog(await response.text());
734
+ if (!releases.some((r) => r.version === latest)) continue;
735
+ remote.set(latest, releases);
736
+ return releases;
737
+ } catch {
738
+ }
739
+ }
740
+ return [];
741
+ };
742
+ return async (upcoming) => {
743
+ const { version, releases } = installed();
744
+ let ahead = [];
745
+ if (upcoming && updates !== void 0 && version) {
746
+ const offer = (await updates().catch(() => null))?.updates.find((u) => u.name === name2);
747
+ if (offer) ahead = releasesBetween(await notesOf(offer.latest, offer.registry), version, offer.latest);
748
+ }
749
+ return { version, releases, upcoming: ahead };
750
+ };
751
+ }
752
+
599
753
  // plugins/dsh/src/server/host-open.ts
600
754
  import { randomUUID } from "node:crypto";
601
755
  var HOST_OPEN_WAIT_MS = 8e3;
@@ -648,47 +802,6 @@ var HostOpens = class {
648
802
  }
649
803
  };
650
804
 
651
- // plugins/dsh/src/shared/routes.ts
652
- var ROUTE_BASE = "/api/open-artifact.artifacts";
653
- var PATHS = Object.freeze({
654
- /** GET: every artifact in the library and the types a new session can make ({@link ArtifactList}). */
655
- list: ROUTE_BASE,
656
- /** POST `?id=`: count it as opened and start its page (`{ url, sessionId, title }`; `url` is the Shell). */
657
- open: `${ROUTE_BASE}.open`,
658
- /** POST `?id=`: start its page without counting an opening (`{ url }`, the page itself): for a thumbnail. */
659
- preview: `${ROUTE_BASE}.preview`,
660
- /** GET `?id=&v=`: the saved thumbnail (a JPEG). POST the bytes to save one (`{ thumbnail }`). */
661
- thumbnail: `${ROUTE_BASE}.thumbnail`,
662
- /** POST `?id=` with `{ pinned?, title? }`: the artifact as it is now. */
663
- update: `${ROUTE_BASE}.update`,
664
- /** POST `?id=`: take it off the library (`{ trash, path }`); its folder stays where it is. */
665
- delete: `${ROUTE_BASE}.delete`,
666
- /** POST `?trash=<id>`: put back what the delete route took away. */
667
- restore: `${ROUTE_BASE}.restore`,
668
- /** GET: the daemon's library events as server-sent events (`data:` is a `LibraryEvent`). */
669
- events: `${ROUTE_BASE}.events`,
670
- /** GET: the daemon's `host.open` requests as server-sent events (`data:` is a {@link HostOpenRequest}). */
671
- hostOpens: `${ROUTE_BASE}.host-opens`,
672
- /** POST `?id=&opened=1|0`: whether a browser half showed the artifact of one {@link HostOpenRequest}. */
673
- hostOpened: `${ROUTE_BASE}.host-opened`,
674
- /** GET: whether this plugin has a newer release on its registry ({@link UpdateCheck}). */
675
- updates: `${ROUTE_BASE}.updates`
676
- });
677
- function isNewer(a, b) {
678
- const parts = (version) => {
679
- const [core = "", pre] = version.split("+")[0].split(/-(.*)/s);
680
- return { numbers: core.split(".").map((n) => Number.parseInt(n, 10) || 0), pre };
681
- };
682
- const left = parts(a);
683
- const right = parts(b);
684
- for (let i = 0; i < 3; i++) {
685
- const difference = (left.numbers[i] ?? 0) - (right.numbers[i] ?? 0);
686
- if (difference !== 0) return difference > 0;
687
- }
688
- if (left.pre === void 0 || right.pre === void 0) return left.pre === void 0 && right.pre !== void 0;
689
- return left.pre.localeCompare(right.pre, "en", { numeric: true }) > 0;
690
- }
691
-
692
805
  // plugins/dsh/src/server/routes.ts
693
806
  var HARNESS = "dsh";
694
807
  var NO_STORE = { "cache-control": "no-store" };
@@ -847,6 +960,8 @@ function registerRoutes(routes, options = {}) {
847
960
  });
848
961
  const updates = options.updates;
849
962
  if (updates !== void 0) route(PATHS.updates, ["GET"], async () => json(await updates()));
963
+ const changelog = options.changelog;
964
+ if (changelog !== void 0) route(PATHS.changelog, ["GET"], async (request) => json(await changelog(param(request, "upcoming") === "1")));
850
965
  const hostOpens = options.hostOpens;
851
966
  if (hostOpens === void 0) return;
852
967
  route(PATHS.hostOpens, ["GET"], async (request) => {
@@ -891,7 +1006,7 @@ function registerRoutes(routes, options = {}) {
891
1006
 
892
1007
  // plugins/dsh/src/server/updates.ts
893
1008
  var NPM = "https://registry.npmjs.org/";
894
- var LOOKUP_MS = 8e3;
1009
+ var LOOKUP_MS2 = 8e3;
895
1010
  var FRESH_MS = 60 * 6e4;
896
1011
  var TARBALL = /^https?:\/\/.+\.tgz$/i;
897
1012
  function fromRegistry(name2, source) {
@@ -903,7 +1018,7 @@ async function releaseOn(fetcher, registry, name2) {
903
1018
  try {
904
1019
  const response = await fetcher(`${registry}${name2}`, {
905
1020
  headers: { accept: "application/vnd.npm.install-v1+json" },
906
- signal: AbortSignal.timeout(LOOKUP_MS)
1021
+ signal: AbortSignal.timeout(LOOKUP_MS2)
907
1022
  });
908
1023
  if (!response.ok) return null;
909
1024
  const doc = await response.json();
@@ -965,7 +1080,7 @@ function updateChecker(names, manager, fetcher = fetch) {
965
1080
 
966
1081
  // plugins/dsh/src/server/skill.ts
967
1082
  import { readFile } from "node:fs/promises";
968
- import { join as join3, sep as sep2 } from "node:path";
1083
+ import { join as join4, sep as sep2 } from "node:path";
969
1084
  var SKILL_NAME = "open-artifact";
970
1085
  var BUNDLED_SKILL_RANK = 600;
971
1086
  var DESCRIPTION = "Make a new artifact of one Open Artifact type (design, slides, whiteboard, data, sheets, docs, design-system, …) with the Artifact tool. Usage: /open-artifact <type> <what to make>.";
@@ -992,7 +1107,7 @@ function typesSection(types) {
992
1107
  ${lines.join("\n")}`;
993
1108
  }
994
1109
  function skillProvider({ packageRoot: packageRoot2, types, provider = "dsh-open-artifact" }) {
995
- const directory = join3(packageRoot2, "skills", SKILL_NAME);
1110
+ const directory = join4(packageRoot2, "skills", SKILL_NAME);
996
1111
  const candidate = {
997
1112
  name: SKILL_NAME,
998
1113
  description: DESCRIPTION,
@@ -1000,7 +1115,7 @@ function skillProvider({ packageRoot: packageRoot2, types, provider = "dsh-open-
1000
1115
  provider,
1001
1116
  source: "bundled",
1002
1117
  rank: BUNDLED_SKILL_RANK,
1003
- path: join3(directory, "SKILL.md"),
1118
+ path: join4(directory, "SKILL.md"),
1004
1119
  resourceBase: { kind: "directory", path: directory.split(sep2).join("/") }
1005
1120
  };
1006
1121
  return {
@@ -1024,15 +1139,15 @@ ${typesSection(listed)}
1024
1139
  }
1025
1140
 
1026
1141
  // plugins/dsh/src/server/vendor.ts
1027
- import { existsSync, readFileSync as readFileSync2 } from "node:fs";
1028
- import { dirname as dirname3, join as join4, resolve as resolve3 } from "node:path";
1142
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
1143
+ import { dirname as dirname3, join as join5, resolve as resolve3 } from "node:path";
1029
1144
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1030
1145
  var PACKAGE_NAME = "dsh-open-artifact";
1031
1146
  function packageRoot(from = dirname3(fileURLToPath2(import.meta.url))) {
1032
1147
  let dir = from;
1033
1148
  for (; ; ) {
1034
1149
  try {
1035
- const pkg = JSON.parse(readFileSync2(join4(dir, "package.json"), "utf8"));
1150
+ const pkg = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
1036
1151
  if (pkg.name === PACKAGE_NAME) return dir;
1037
1152
  } catch {
1038
1153
  }
@@ -1042,26 +1157,26 @@ function packageRoot(from = dirname3(fileURLToPath2(import.meta.url))) {
1042
1157
  }
1043
1158
  }
1044
1159
  function vendorPaths(root = packageRoot()) {
1045
- const vendor = join4(root, "vendor");
1160
+ const vendor = join5(root, "vendor");
1046
1161
  return {
1047
- bin: join4(vendor, "open-artifact.mjs"),
1048
- shell: join4(vendor, "shell"),
1049
- home: join4(vendor, "home"),
1050
- types: join4(vendor, "artifact-types"),
1051
- harnesses: join4(vendor, "harnesses")
1162
+ bin: join5(vendor, "open-artifact.mjs"),
1163
+ shell: join5(vendor, "shell"),
1164
+ home: join5(vendor, "home"),
1165
+ types: join5(vendor, "artifact-types"),
1166
+ harnesses: join5(vendor, "harnesses")
1052
1167
  };
1053
1168
  }
1054
1169
  function daemonOptions(root = packageRoot(), env = process.env) {
1055
1170
  const paths = vendorPaths(root);
1056
1171
  const daemonEnv = { ...env };
1057
1172
  const folder = (name2, dir) => {
1058
- if (!daemonEnv[name2] && existsSync(dir)) daemonEnv[name2] = dir;
1173
+ if (!daemonEnv[name2] && existsSync2(dir)) daemonEnv[name2] = dir;
1059
1174
  };
1060
1175
  folder("OPEN_ARTIFACT_SHELL_DIR", paths.shell);
1061
1176
  folder("OPEN_ARTIFACT_HOME_DIR", paths.home);
1062
1177
  folder("OPEN_ARTIFACT_BUILTIN_TYPES", paths.types);
1063
1178
  folder("OPEN_ARTIFACT_HARNESS_PROFILES", paths.harnesses);
1064
- return { env: daemonEnv, ...existsSync(paths.bin) ? { bin: paths.bin } : {} };
1179
+ return { env: daemonEnv, ...existsSync2(paths.bin) ? { bin: paths.bin } : {} };
1065
1180
  }
1066
1181
 
1067
1182
  // plugins/dsh/src/server/wake.ts
@@ -1287,10 +1402,11 @@ function setup(ctx, config = {}, deps = {}) {
1287
1402
  const prompt = service(ctx, "systemPrompt");
1288
1403
  if (typeof prompt?.section === "function") prompt.section({ name: "open-artifact", order: 900, text: AGENT_PROMPT, interpolate: false });
1289
1404
  const updates = updateChecker([PACKAGE_NAME], () => service(ctx, "pluginManager"));
1405
+ const changelog = changelogReader({ name: PACKAGE_NAME, root: packageRoot(), updates });
1290
1406
  const routes = deps.registerRoutes ?? registerRoutes;
1291
1407
  ctx.inject?.(["connection"], (sub) => {
1292
1408
  try {
1293
- routes({ register: (route) => sub.connection.fetch.register(route) }, { daemonOptions: daemon, library, hostOpens, updates });
1409
+ routes({ register: (route) => sub.connection.fetch.register(route) }, { daemonOptions: daemon, library, hostOpens, updates, changelog });
1294
1410
  } catch (error) {
1295
1411
  log("warn", `the Open Artifact page's routes: ${error.message}`);
1296
1412
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-open-artifact",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Open Artifact in DeepSeek Harness: the Artifact, ArtifactData and ArtifactComments tools, comments on artifact pages waking the session that owns them, the Open Artifact page in the sidebar listing the open-artifact library, artifacts the agent opens shown in the session's Browser, and /open-artifact <type> to make a new one.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -19,6 +19,7 @@
19
19
  "icon.svg",
20
20
  "cordis.patch.yml",
21
21
  "NOTICE",
22
+ "CHANGELOG.md",
22
23
  "LICENSE"
23
24
  ],
24
25
  "dsh": {
@@ -663,7 +663,7 @@ var init_package = __esm({
663
663
  "packages/daemon/package.json"() {
664
664
  package_default = {
665
665
  name: "@open-artifact/daemon",
666
- version: "0.9.1",
666
+ version: "0.9.2",
667
667
  private: true,
668
668
  type: "module",
669
669
  description: "The Open Artifact daemon (`open-artifact`): type registry, artifact library, type servers, agent tools, wake routing, the Harness API, MCP and the Shell.",
@@ -675,7 +675,7 @@ var init_package = __esm({
675
675
  "./client": "./src/client.ts"
676
676
  },
677
677
  dependencies: {
678
- "@open-artifact/protocol": "0.9.1"
678
+ "@open-artifact/protocol": "0.9.2"
679
679
  },
680
680
  license: "Apache-2.0"
681
681
  };