@demogo-cn/cli 0.3.3 → 0.3.5

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/README.md CHANGED
@@ -6,7 +6,7 @@ DemoGo CLI lets AI coding tools publish a local project to DemoGo and return a s
6
6
 
7
7
  Current MVP delivery uses a local install package.
8
8
 
9
- 1. Unzip `demogo-cli-v0.3.3.zip`.
9
+ 1. Unzip `demogo-cli-v0.3.5.zip`.
10
10
  2. Open a terminal in the extracted folder.
11
11
  3. Run:
12
12
 
@@ -58,7 +58,9 @@ Project names are used for display in the DemoGo workbench. Every first publish
58
58
 
59
59
  ## Current Boundary
60
60
 
61
- DemoGo supports static pages, single HTML pages, built frontend output, and frontend source projects that can build static output. It does not host long-running backend services, databases, payment systems, login systems, WebSocket services, or SSR runtimes.
61
+ DemoGo supports static pages, single HTML pages, built frontend output, frontend source projects that can build static output, and Node.js single-service trial projects when the platform reports that the Node runtime is available. Node.js projects must provide a start command and listen on `process.env.PORT`.
62
+
63
+ DemoGo does not currently allocate databases or Redis, run multi-service apps, support WebSocket, or host SSR runtimes such as Next/Nuxt/Remix server mode.
62
64
 
63
65
  ## npm / npx Status
64
66
 
package/bin/demogo.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  createProjectArchive,
13
13
  deployArchive,
14
14
  formatBytes,
15
+ checkAgentToken,
15
16
  checkApiHealth,
16
17
  normalizeApiBase,
17
18
  safeArchiveName,
@@ -161,9 +162,18 @@ async function handleDoctor(args) {
161
162
  console.log("DemoGo 正在检查平台地址...");
162
163
  const health = await checkApiHealth(apiBase);
163
164
  console.log(`平台连接正常:${health.service || "demogo-server"} ${health.version || ""}`.trim());
164
- console.log(`AI 发布口令:${token ? "已配置" : "未配置"}`);
165
165
  if (!token) {
166
+ console.log("AI 发布口令:未配置");
166
167
  console.log("提示:没有 AI 发布口令时只能检查平台地址,不能直接发布项目。");
168
+ return;
169
+ }
170
+ try {
171
+ const tokenCheck = await checkAgentToken(apiBase, token);
172
+ const prefix = tokenCheck.token?.prefix ? `(${tokenCheck.token.prefix})` : "";
173
+ const owner = tokenCheck.user?.email ? `,账号:${tokenCheck.user.email}` : "";
174
+ console.log(`AI 发布口令:有效${prefix}${owner}`);
175
+ } catch (error) {
176
+ fail(error instanceof Error ? `AI 发布口令:无效或已重置。\n${error.message}` : "AI 发布口令:无效或已重置。");
167
177
  }
168
178
  }
169
179
 
package/lib/core.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
 
5
- export const VERSION = "0.3.3";
5
+ export const VERSION = "0.3.5";
6
6
  export const MAX_FILES = 800;
7
7
  export const MAX_BYTES = 50 * 1024 * 1024;
8
8
 
@@ -206,7 +206,7 @@ export async function deployArchive({ apiBase, token, archivePath, projectName,
206
206
  return payload;
207
207
  }
208
208
 
209
- export async function checkApiHealth(apiBase) {
209
+ export async function checkApiHealth(apiBase) {
210
210
  let response;
211
211
  try {
212
212
  response = await fetch(`${normalizeApiBase(apiBase)}/api/health`, {
@@ -221,10 +221,31 @@ export async function checkApiHealth(apiBase) {
221
221
  if (!response.ok || !payload?.ok) {
222
222
  throw new Error(`DemoGo 平台地址不可用:HTTP ${response.status}`);
223
223
  }
224
- return payload;
225
- }
226
-
227
- export function normalizeApiBase(value) {
224
+ return payload;
225
+ }
226
+
227
+ export async function checkAgentToken(apiBase, token, userAgent = `demogo-cli/${VERSION}`) {
228
+ let response;
229
+ try {
230
+ response = await fetch(`${normalizeApiBase(apiBase)}/api/agent/token-check`, {
231
+ method: "GET",
232
+ headers: {
233
+ Authorization: `Bearer ${token}`,
234
+ "User-Agent": userAgent
235
+ }
236
+ });
237
+ } catch {
238
+ throw new Error(`无法连接 DemoGo:${normalizeApiBase(apiBase)}。请检查平台地址。`);
239
+ }
240
+ const text = await response.text();
241
+ const payload = parseJson(text);
242
+ if (!response.ok || !payload?.ok) {
243
+ throw new Error(payload?.error || readableHttpError(response.status, text));
244
+ }
245
+ return payload;
246
+ }
247
+
248
+ export function normalizeApiBase(value) {
228
249
  return String(value || "").trim().replace(/\/+$/, "");
229
250
  }
230
251
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@demogo-cn/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "DemoGo CLI for generating shareable trial links from AI-built pages.",
5
5
  "type": "module",
6
6
  "bin": {