dsh-seework 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -3017,6 +3017,8 @@ function isNewer(candidate, current) {
3017
3017
  //#region src/update.ts
3018
3018
  /** The package name this plugin is published under. */
3019
3019
  const PACKAGE_NAME = "dsh-seework";
3020
+ /** Where to ask when the host names no registry. */
3021
+ const DEFAULT_REGISTRY = "https://registry.npmjs.org";
3020
3022
  /** The spec an update installs. */
3021
3023
  const UPDATE_SPEC = `${PACKAGE_NAME}@latest`;
3022
3024
  /**
@@ -3068,13 +3070,48 @@ function readInstallKind(profileDir, packageName = PACKAGE_NAME) {
3068
3070
  }
3069
3071
  }
3070
3072
  /**
3073
+ * The registry to ask, out of the host's configuration.
3074
+ *
3075
+ * `resolved` is what pnpm itself reads now; `registry` is the configured one,
3076
+ * and `null` there means "pnpm's own configuration decides" — in which case the
3077
+ * public registry is the honest guess rather than an error.
3078
+ *
3079
+ * @param registries - the host's answer.
3080
+ * @returns a registry base URL.
3081
+ */
3082
+ function registryOf(registries) {
3083
+ return registries.resolved ?? registries.registry ?? DEFAULT_REGISTRY;
3084
+ }
3085
+ /**
3086
+ * Read the newest published version out of a registry's `latest` document.
3087
+ *
3088
+ * `/<name>/latest` is the one endpoint that answers "what is the newest
3089
+ * release" without pulling the whole packument, and it is what `npm view
3090
+ * <name> version` reads.
3091
+ *
3092
+ * @param query - the registry, the package, and an optional fetch stub.
3093
+ * @returns the version string.
3094
+ * @throws when the registry refuses, answers with a non-JSON body, or carries no
3095
+ * version — each of which must surface as an error rather than as "up to date".
3096
+ */
3097
+ async function latestVersionFrom(query) {
3098
+ const base = query.registry.replace(/\/+$/, "");
3099
+ const path$1 = query.packageName.replace("/", "%2F");
3100
+ const response = await (query.fetchFn ?? fetch)(`${base}/${path$1}/latest`, { headers: { accept: "application/json" } });
3101
+ if (!response.ok) throw new Error(`注册表返回 HTTP ${response.status}`);
3102
+ const version = (await response.json()).version;
3103
+ if (typeof version !== "string" || version === "") throw new Error("注册表返回的文档里没有版本号");
3104
+ return version;
3105
+ }
3106
+ /**
3071
3107
  * Ask the registry what the newest version is, and compare it with ours.
3072
3108
  *
3073
3109
  * Never throws: the settings card has to keep rendering when the registry is
3074
3110
  * unreachable, when the host has no plugin manager, and when this is a local
3075
3111
  * install that has no update to offer.
3076
3112
  *
3077
- * @param deps - the host seam, the running version, and how it was installed.
3113
+ * @param deps - the host seam, the running version, how it was installed, and an
3114
+ * optional fetch stub.
3078
3115
  * @returns the status the card renders.
3079
3116
  */
3080
3117
  async function checkForUpdate(deps) {
@@ -3089,15 +3126,15 @@ async function checkForUpdate(deps) {
3089
3126
  error: "宿主没有提供插件管理服务。"
3090
3127
  };
3091
3128
  try {
3092
- const inspection = await deps.host.inspect(PACKAGE_NAME);
3093
- if (inspection.status !== "accepted" || inspection.version === void 0) return {
3094
- ...base,
3095
- error: inspection.reason ?? "注册表上没有这个包。"
3096
- };
3129
+ const latest = await latestVersionFrom({
3130
+ registry: registryOf(await deps.host.registries()),
3131
+ packageName: PACKAGE_NAME,
3132
+ ...deps.fetchFn === void 0 ? {} : { fetchFn: deps.fetchFn }
3133
+ });
3097
3134
  return {
3098
3135
  ...base,
3099
- latest: inspection.version,
3100
- updateAvailable: isNewer(inspection.version, deps.current)
3136
+ latest,
3137
+ updateAvailable: isNewer(latest, deps.current)
3101
3138
  };
3102
3139
  } catch (error) {
3103
3140
  return {
@@ -3894,7 +3931,7 @@ function probeUpdateHost(ctx) {
3894
3931
  const service = ctx.get("pluginManager");
3895
3932
  if (service === null || service === void 0) return void 0;
3896
3933
  const candidate = service;
3897
- if (typeof candidate.inspect !== "function" || typeof candidate.installBundle !== "function") return void 0;
3934
+ if (typeof candidate.registries !== "function" || typeof candidate.installBundle !== "function") return void 0;
3898
3935
  return candidate;
3899
3936
  }
3900
3937
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-seework",
3
3
  "description": "SeeWork — DeepSeek Harness plugin for SeeAI Hub: generate images inside the agent conversation with your own SeeAI Hub API key (OpenAI-compatible /v1/images/generations), browse everything you generated in the sidebar material library, and arrange it on a canvas.",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",