Polish VS Code extension: three toolbar actions and CLI checks.

Add Run/View/Debug title icons, logo cover art, version/stdlib install prompts, and LiveServer for view + debug hosts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-05 17:13:58 +08:00
1 parent 2406059fc2
commit cb2f4e4618
10 files changed
+268 -70

No files matched your search

+1
View File
@@ -7,3 +7,4 @@ node_modules/**
**/*.map **/*.map
**/*.ts **/*.ts
!out/**/*.js !out/**/*.js
media/logo-source.*
+5 -5
View File
@@ -46,13 +46,13 @@ path:line:col: message
## CLI 安装(扩展侧) ## CLI 安装(扩展侧)
- 启动时(`onStartupFinished`)检测 CLI + `lib/`;缺失则提示 **Install CLI + stdlib**。 - 启动时(`onStartupFinished`)检测:**CLI 是否存在**、**版本是否 ≥ `marqdo.minCliVersion`(默认 0.1.0)**、**stdlib (`lib/`) 是否可用**。
- 从 GitHub Releases 下载推荐 zip(`marqdo.exe` + `lib/`)到扩展 `globalStorage/cli/`,并写入 `marqdo.cliPath` / `marqdo.libPath`(spawn 时带 `MARQDO_LIB`)。 - 任一不满足 → 提示用户,由其选择安装 / 打开 Releases / 不再询问。
- 手动命令:`Marqdo: Install / Repair CLI`、`Marqdo: Check CLI Status`。 - 安装物落到扩展 `globalStorage/cli/`,并写入 `marqdo.cliPath` / `marqdo.libPath`(spawn 时带 `MARQDO_LIB`)。
- 当前自动安装预编译包以 **Windows x64** 为主(与现有 Release 资产一致);其它平台无匹配资产时会提示打开 Releases。 - 命令:`Marqdo: Install / Repair CLI`、`Marqdo: Check CLI Status`。
- 预编译自动安装以 **Windows x64** Release zip 为主。
## 调试(P3 → 现有入口) ## 调试(P3 → 现有入口)
- **已落地**:命令 `Marqdo: Open Debugger` 子进程启动 `marqdo debug --no-open`,再打开浏览器 / Simple Browser。 - **已落地**:命令 `Marqdo: Open Debugger` 子进程启动 `marqdo debug --no-open`,再打开浏览器 / Simple Browser。
- **中期**:DAP 适配器包装现有 debug session API(`src/view/debug_api.rs` 语义),避免第三套断点模型。 - **中期**:DAP 适配器包装现有 debug session API(`src/view/debug_api.rs` 语义),避免第三套断点模型。
+1 -1
View File
@@ -2,7 +2,7 @@
| | | | | |
|---|---| |---|---|
| 状态 | **P0 高亮 + P1 Run/Problems + 轻量 Debug 入口**(伴随 Marqdo **v0.1.0**) | | 状态 | **三按钮 Run / View / Debug + CLI 检测**(扩展 v0.0.5;封面 logo;需 CLI ≥ **0.1.0**) |
| 日期 | 2026-08-05 | | 日期 | 2026-08-05 |
| 语言仓 | [`cflmy/marqdo`](https://github.com/cflmy/marqdo) `main` | | 语言仓 | [`cflmy/marqdo`](https://github.com/cflmy/marqdo) `main` |
| 扩展仓形态 | **同仓库专用分支** `vscode-extension`(本目录);`main` **不跟踪**本目录 | | 扩展仓形态 | **同仓库专用分支** `vscode-extension`(本目录);`main` **不跟踪**本目录 |
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

+81 -20
View File
@@ -2,8 +2,9 @@
"name": "marqdo", "name": "marqdo",
"displayName": "Marqdo", "displayName": "Marqdo",
"description": "Language support for Marqdo (.mq.md) — code as documentation.", "description": "Language support for Marqdo (.mq.md) — code as documentation.",
"version": "0.0.3", "version": "0.0.5",
"publisher": "cflmy", "publisher": "cflmy",
"icon": "media/icon.png",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/cflmy/marqdo.git" "url": "https://github.com/cflmy/marqdo.git"
@@ -55,57 +56,93 @@
"commands": [ "commands": [
{ {
"command": "marqdo.run", "command": "marqdo.run",
"title": "Marqdo: Run File", "title": "Run File",
"category": "Marqdo" "shortTitle": "Run",
"category": "Marqdo",
"icon": "$(play)"
},
{
"command": "marqdo.view",
"title": "Open View",
"shortTitle": "View",
"category": "Marqdo",
"icon": "$(open-preview)"
}, },
{ {
"command": "marqdo.debug", "command": "marqdo.debug",
"title": "Marqdo: Open Debugger", "title": "Open Debugger",
"category": "Marqdo" "shortTitle": "Debug",
"category": "Marqdo",
"icon": "$(debug-alt)"
},
{
"command": "marqdo.view.stop",
"title": "Stop View",
"category": "Marqdo",
"icon": "$(close)"
}, },
{ {
"command": "marqdo.debug.stop", "command": "marqdo.debug.stop",
"title": "Marqdo: Stop Debugger", "title": "Stop Debugger",
"category": "Marqdo" "shortTitle": "Stop Debug",
"category": "Marqdo",
"icon": "$(debug-stop)"
}, },
{ {
"command": "marqdo.catalog", "command": "marqdo.catalog",
"title": "Marqdo: Generate Catalog", "title": "Generate Catalog",
"category": "Marqdo" "category": "Marqdo",
"icon": "$(book)"
}, },
{ {
"command": "marqdo.showOutput", "command": "marqdo.showOutput",
"title": "Marqdo: Show Output", "title": "Show Output",
"category": "Marqdo" "category": "Marqdo",
"icon": "$(output)"
}, },
{ {
"command": "marqdo.installCli", "command": "marqdo.installCli",
"title": "Marqdo: Install / Repair CLI", "title": "Install / Repair CLI",
"category": "Marqdo" "category": "Marqdo",
"icon": "$(cloud-download)"
}, },
{ {
"command": "marqdo.checkCli", "command": "marqdo.checkCli",
"title": "Marqdo: Check CLI Status", "title": "Check CLI Status",
"category": "Marqdo" "category": "Marqdo",
"icon": "$(info)"
} }
], ],
"menus": { "menus": {
"editor/title": [ "editor/title": [
{ {
"command": "marqdo.run", "command": "marqdo.run",
"when": "resourceFilename =~ /\\.mq\\.md$/ || editorLangId == marqdo", "when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
"group": "navigation@1" "group": "navigation@90"
},
{
"command": "marqdo.view",
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
"group": "navigation@91"
}, },
{ {
"command": "marqdo.debug", "command": "marqdo.debug",
"when": "resourceFilename =~ /\\.mq\\.md$/ || editorLangId == marqdo", "when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
"group": "navigation@2" "group": "navigation@92"
} }
], ],
"commandPalette": [ "commandPalette": [
{ {
"command": "marqdo.run", "command": "marqdo.run",
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/" "when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/"
},
{
"command": "marqdo.view",
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/"
},
{
"command": "marqdo.debug",
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/"
} }
] ]
}, },
@@ -138,7 +175,12 @@
"marqdo.autoInstall.checkOnStartup": { "marqdo.autoInstall.checkOnStartup": {
"type": "boolean", "type": "boolean",
"default": true, "default": true,
"description": "On startup, detect missing CLI/stdlib and offer one-click install from GitHub Releases." "description": "On startup, detect missing/outdated CLI or missing stdlib and offer install from GitHub Releases."
},
"marqdo.minCliVersion": {
"type": "string",
"default": "0.1.0",
"description": "Minimum required Marqdo CLI version (semver). Older installs trigger an upgrade prompt."
}, },
"marqdo.diagnoseOnSave": { "marqdo.diagnoseOnSave": {
"type": "boolean", "type": "boolean",
@@ -150,6 +192,25 @@
"default": 60000, "default": 60000,
"description": "Timeout for `marqdo run` / diagnose (milliseconds)." "description": "Timeout for `marqdo run` / diagnose (milliseconds)."
}, },
"marqdo.viewHost": {
"type": "string",
"default": "127.0.0.1",
"description": "Host for `marqdo view`."
},
"marqdo.viewPort": {
"type": "number",
"default": 7429,
"description": "Port for `marqdo view`."
},
"marqdo.viewOpen": {
"type": "string",
"enum": [
"external",
"simpleBrowser"
],
"default": "external",
"description": "How to open the view UI after starting the server."
},
"marqdo.debugHost": { "marqdo.debugHost": {
"type": "string", "type": "string",
"default": "127.0.0.1", "default": "127.0.0.1",
+16 -7
View File
@@ -129,28 +129,37 @@ export function probeMarqdo(
} }
} }
export class DebugServer { export class LiveServer {
private proc: ChildProcessWithoutNullStreams | null = null; private proc: ChildProcessWithoutNullStreams | null = null;
private output: vscode.OutputChannel; private output: vscode.OutputChannel;
private label: string;
constructor(output: vscode.OutputChannel) { constructor(output: vscode.OutputChannel, label: string) {
this.output = output; this.output = output;
this.label = label;
} }
get running(): boolean { get running(): boolean {
return this.proc !== null && this.proc.exitCode === null; return this.proc !== null && this.proc.exitCode === null;
} }
async start(targetPath: string, host: string, port: number): Promise<string> { async start(
subcommand: "view" | "debug",
targetPath: string,
host: string,
port: number
): Promise<string> {
if (this.running) { if (this.running) {
await this.stop(); await this.stop();
} }
const cli = resolveMarqdoCli(); const cli = resolveMarqdoCli();
const cwd = workspaceCwd(vscode.Uri.file(targetPath)); const cwd = workspaceCwd(vscode.Uri.file(targetPath));
this.output.appendLine(`$ ${cli} debug ${targetPath} --host ${host} --port ${port} --no-open`); this.output.appendLine(
`$ ${cli} ${subcommand} ${targetPath} --host ${host} --port ${port} --no-open`
);
this.proc = spawn( this.proc = spawn(
cli, cli,
["debug", targetPath, "--host", host, "--port", String(port), "--no-open"], [subcommand, targetPath, "--host", host, "--port", String(port), "--no-open"],
{ {
cwd, cwd,
shell: process.platform === "win32", shell: process.platform === "win32",
@@ -161,11 +170,11 @@ export class DebugServer {
this.proc.stdout.on("data", (d: Buffer) => this.output.append(d.toString())); this.proc.stdout.on("data", (d: Buffer) => this.output.append(d.toString()));
this.proc.stderr.on("data", (d: Buffer) => this.output.append(d.toString())); this.proc.stderr.on("data", (d: Buffer) => this.output.append(d.toString()));
this.proc.on("exit", (code) => { this.proc.on("exit", (code) => {
this.output.appendLine(`[debug] exited (${code})`); this.output.appendLine(`[${this.label}] exited (${code})`);
this.proc = null; this.proc = null;
}); });
this.proc.on("error", (err) => { this.proc.on("error", (err) => {
this.output.appendLine(`[debug] ${err.message}`); this.output.appendLine(`[${this.label}] ${err.message}`);
this.proc = null; this.proc = null;
}); });
await new Promise((r) => setTimeout(r, 600)); await new Promise((r) => setTimeout(r, 600));
+87 -26
View File
@@ -1,5 +1,5 @@
import * as vscode from "vscode"; import * as vscode from "vscode";
import { DebugServer, configureCliResolution, runMarqdo, workspaceCwd } from "./cli"; import { LiveServer, configureCliResolution, runMarqdo, workspaceCwd } from "./cli";
import { DiagnosticBag } from "./diagnostics"; import { DiagnosticBag } from "./diagnostics";
import { import {
checkInstallStatus, checkInstallStatus,
@@ -12,14 +12,16 @@ import {
let output: vscode.OutputChannel; let output: vscode.OutputChannel;
let diagnostics: DiagnosticBag; let diagnostics: DiagnosticBag;
let debugServer: DebugServer; let viewServer: LiveServer;
let debugServer: LiveServer;
let extContext: vscode.ExtensionContext; let extContext: vscode.ExtensionContext;
export function activate(context: vscode.ExtensionContext): void { export function activate(context: vscode.ExtensionContext): void {
extContext = context; extContext = context;
output = vscode.window.createOutputChannel("Marqdo"); output = vscode.window.createOutputChannel("Marqdo");
diagnostics = new DiagnosticBag(); diagnostics = new DiagnosticBag();
debugServer = new DebugServer(output); viewServer = new LiveServer(output, "view");
debugServer = new LiveServer(output, "debug");
configureCliResolution( configureCliResolution(
context, context,
@@ -31,12 +33,17 @@ export function activate(context: vscode.ExtensionContext): void {
output, output,
diagnostics.disposable, diagnostics.disposable,
vscode.commands.registerCommand("marqdo.run", () => runActiveFile()), vscode.commands.registerCommand("marqdo.run", () => runActiveFile()),
vscode.commands.registerCommand("marqdo.view", () => startView()),
vscode.commands.registerCommand("marqdo.debug", () => startDebug()), vscode.commands.registerCommand("marqdo.debug", () => startDebug()),
vscode.commands.registerCommand("marqdo.debug.stop", () => stopDebug()), vscode.commands.registerCommand("marqdo.debug.stop", () => stopDebug()),
vscode.commands.registerCommand("marqdo.view.stop", () => stopView()),
vscode.commands.registerCommand("marqdo.catalog", () => runCatalog()), vscode.commands.registerCommand("marqdo.catalog", () => runCatalog()),
vscode.commands.registerCommand("marqdo.showOutput", () => output.show(true)), vscode.commands.registerCommand("marqdo.showOutput", () => output.show(true)),
vscode.commands.registerCommand("marqdo.installCli", () => installCli()), vscode.commands.registerCommand("marqdo.installCli", () => installCli()),
vscode.commands.registerCommand("marqdo.checkCli", () => checkCli()), vscode.commands.registerCommand("marqdo.checkCli", () => checkCli())
);
context.subscriptions.push(
vscode.workspace.onDidSaveTextDocument((doc) => { vscode.workspace.onDidSaveTextDocument((doc) => {
if (doc.languageId === "marqdo" && autoDiagnose()) { if (doc.languageId === "marqdo" && autoDiagnose()) {
void diagnoseDocument(doc); void diagnoseDocument(doc);
@@ -48,6 +55,7 @@ export function activate(context: vscode.ExtensionContext): void {
} }
export function deactivate(): void { export function deactivate(): void {
void viewServer?.stop();
void debugServer?.stop(); void debugServer?.stop();
} }
@@ -59,11 +67,8 @@ async function installCli(): Promise<void> {
await resetSkipPrompt(extContext); await resetSkipPrompt(extContext);
const status = checkInstallStatus(extContext); const status = checkInstallStatus(extContext);
try { try {
if (status.cliOk && !status.libOk) { const mode = status.suggestedMode ?? "bundle";
await installFromGitHub(extContext, output, "stdlib"); await installFromGitHub(extContext, output, mode);
} else {
await installFromGitHub(extContext, output, "bundle");
}
} catch (e) { } catch (e) {
const err = e instanceof Error ? e.message : String(e); const err = e instanceof Error ? e.message : String(e);
output.appendLine(`[install] ${err}`); output.appendLine(`[install] ${err}`);
@@ -77,8 +82,10 @@ async function installCli(): Promise<void> {
async function checkCli(): Promise<void> { async function checkCli(): Promise<void> {
const status = checkInstallStatus(extContext); const status = checkInstallStatus(extContext);
output.appendLine(`[check] ${status.detail}`); output.appendLine(`[check] ${status.detail}`);
if (status.cliOk && status.libOk) { if (status.cliOk && status.versionOk && status.libOk) {
void vscode.window.showInformationMessage(`Marqdo ready: ${status.version}`); void vscode.window.showInformationMessage(
`Marqdo ready: ${status.parsedVersion ?? status.version} (≥ ${status.requiredVersion}), stdlib OK`
);
return; return;
} }
const choice = await vscode.window.showWarningMessage( const choice = await vscode.window.showWarningMessage(
@@ -106,20 +113,52 @@ function activeMqDoc(): vscode.TextDocument | undefined {
async function ensureCliOrOfferInstall(): Promise<boolean> { async function ensureCliOrOfferInstall(): Promise<boolean> {
const status = checkInstallStatus(extContext); const status = checkInstallStatus(extContext);
if (status.cliOk) { if (status.cliOk && status.versionOk && status.libOk) {
return true; return true;
} }
if (status.cliOk && status.versionOk && !status.libOk) {
const choice = await vscode.window.showWarningMessage( const choice = await vscode.window.showWarningMessage(
"Marqdo CLI not found. Install the official release (includes stdlib)?", "Standard library (lib/) is missing. Continue anyway, or install stdlib?",
"Install", "Install stdlib",
"Continue",
"Cancel" "Cancel"
); );
if (choice === "Install") { if (choice === "Install stdlib") {
await installCli(); await installCli();
return checkInstallStatus(extContext).cliOk; return true;
}
if (choice === "Continue") {
return true;
} }
return false; return false;
} }
const label = !status.cliOk
? "Marqdo CLI not found. Install the official release (includes stdlib)?"
: `Marqdo CLI is below ${status.requiredVersion}. Upgrade now?`;
const choice = await vscode.window.showWarningMessage(label, "Install", "Cancel");
if (choice === "Install") {
await installCli();
const again = checkInstallStatus(extContext);
return again.cliOk && again.versionOk;
}
return false;
}
function resolveTargetPath(): string | undefined {
const doc = activeMqDoc();
const folder = vscode.workspace.workspaceFolders?.[0];
return doc?.uri.fsPath ?? folder?.uri.fsPath;
}
async function openUrl(url: string, settingKey: "viewOpen" | "debugOpen"): Promise<void> {
const open =
vscode.workspace.getConfiguration("marqdo").get<string>(settingKey) ?? "external";
if (open === "simpleBrowser") {
await vscode.commands.executeCommand("simpleBrowser.show", url);
} else {
await vscode.env.openExternal(vscode.Uri.parse(url));
}
}
async function runActiveFile(): Promise<void> { async function runActiveFile(): Promise<void> {
if (!(await ensureCliOrOfferInstall())) { if (!(await ensureCliOrOfferInstall())) {
@@ -168,13 +207,35 @@ async function diagnoseDocument(doc: vscode.TextDocument): Promise<void> {
} }
} }
async function startView(): Promise<void> {
if (!(await ensureCliOrOfferInstall())) {
return;
}
const target = resolveTargetPath();
if (!target) {
void vscode.window.showWarningMessage("Open a folder or .mq.md file for view.");
return;
}
const cfg = vscode.workspace.getConfiguration("marqdo");
const host = cfg.get<string>("viewHost") ?? "127.0.0.1";
const port = cfg.get<number>("viewPort") ?? 7429;
output.show(true);
try {
const url = await viewServer.start("view", target, host, port);
await openUrl(url, "viewOpen");
void vscode.window.setStatusBarMessage(`Marqdo view: ${url}`, 5000);
} catch (e) {
void vscode.window.showErrorMessage(
`Marqdo view failed: ${e instanceof Error ? e.message : String(e)}`
);
}
}
async function startDebug(): Promise<void> { async function startDebug(): Promise<void> {
if (!(await ensureCliOrOfferInstall())) { if (!(await ensureCliOrOfferInstall())) {
return; return;
} }
const doc = activeMqDoc(); const target = resolveTargetPath();
const folder = vscode.workspace.workspaceFolders?.[0];
const target = doc?.uri.fsPath ?? folder?.uri.fsPath;
if (!target) { if (!target) {
void vscode.window.showWarningMessage("Open a folder or .mq.md file to debug."); void vscode.window.showWarningMessage("Open a folder or .mq.md file to debug.");
return; return;
@@ -184,13 +245,8 @@ async function startDebug(): Promise<void> {
const port = cfg.get<number>("debugPort") ?? 7430; const port = cfg.get<number>("debugPort") ?? 7430;
output.show(true); output.show(true);
try { try {
const url = await debugServer.start(target, host, port); const url = await debugServer.start("debug", target, host, port);
const open = cfg.get<string>("debugOpen") ?? "external"; await openUrl(url, "debugOpen");
if (open === "simpleBrowser") {
await vscode.commands.executeCommand("simpleBrowser.show", url);
} else {
await vscode.env.openExternal(vscode.Uri.parse(url));
}
void vscode.window.setStatusBarMessage(`Marqdo debug: ${url}`, 5000); void vscode.window.setStatusBarMessage(`Marqdo debug: ${url}`, 5000);
} catch (e) { } catch (e) {
void vscode.window.showErrorMessage( void vscode.window.showErrorMessage(
@@ -199,6 +255,11 @@ async function startDebug(): Promise<void> {
} }
} }
async function stopView(): Promise<void> {
await viewServer.stop();
void vscode.window.setStatusBarMessage("Marqdo view stopped", 3000);
}
async function stopDebug(): Promise<void> { async function stopDebug(): Promise<void> {
await debugServer.stop(); await debugServer.stop();
void vscode.window.setStatusBarMessage("Marqdo debug stopped", 3000); void vscode.window.setStatusBarMessage("Marqdo debug stopped", 3000);
+77 -11
View File
@@ -12,12 +12,40 @@ const MANAGED_DIR = "cli";
export type InstallStatus = { export type InstallStatus = {
cliOk: boolean; cliOk: boolean;
libOk: boolean; libOk: boolean;
versionOk: boolean;
version?: string; version?: string;
parsedVersion?: string;
requiredVersion: string;
cliPath?: string; cliPath?: string;
libRoot?: string; libRoot?: string;
detail: string; detail: string;
/** Suggested install mode when not fully ready */
suggestedMode?: "bundle" | "stdlib";
}; };
/** Parse first semver-like token from `marqdo --version` output. */
export function parseCliVersion(raw: string): string | undefined {
const m = raw.match(/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/);
return m?.[1];
}
/** Compare a.b.c semver (pre-release suffix ignored for ordering). Returns <0 if a<b. */
export function compareSemver(a: string, b: string): number {
const pa = a.split("-")[0].split(".").map((x) => Number.parseInt(x, 10) || 0);
const pb = b.split("-")[0].split(".").map((x) => Number.parseInt(x, 10) || 0);
for (let i = 0; i < 3; i++) {
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
if (d !== 0) {
return d;
}
}
return 0;
}
function requiredVersion(): string {
return cfg().get<string>("minCliVersion")?.trim() || "0.1.0";
}
type GhAsset = { name: string; browser_download_url: string }; type GhAsset = { name: string; browser_download_url: string };
type GhRelease = { type GhRelease = {
tag_name: string; tag_name: string;
@@ -131,26 +159,52 @@ function stdlibPresent(cliPath: string, context?: vscode.ExtensionContext): { ok
} }
export function checkInstallStatus(context: vscode.ExtensionContext): InstallStatus { export function checkInstallStatus(context: vscode.ExtensionContext): InstallStatus {
const need = requiredVersion();
const cliPath = resolveCliPath(context); const cliPath = resolveCliPath(context);
const probe = probeMarqdo(cliPath); const probe = probeMarqdo(cliPath);
if (!probe.ok) { if (!probe.ok) {
return { return {
cliOk: false, cliOk: false,
libOk: false, libOk: false,
versionOk: false,
requiredVersion: need,
cliPath, cliPath,
detail: probe.detail, detail: `Marqdo CLI not found (${probe.detail}). Need ≥ ${need} with stdlib.`,
suggestedMode: "bundle",
}; };
} }
const parsed = parseCliVersion(probe.version ?? "");
const versionOk = parsed !== undefined && compareSemver(parsed, need) >= 0;
const lib = stdlibPresent(cliPath, context); const lib = stdlibPresent(cliPath, context);
let suggestedMode: "bundle" | "stdlib" | undefined;
if (!versionOk) {
suggestedMode = "bundle";
} else if (!lib.ok) {
suggestedMode = "stdlib";
}
const parts: string[] = [`CLI ${probe.version}`];
if (!versionOk) {
parts.push(`version too old (need ≥ ${need}${parsed ? `, found ${parsed}` : ""})`);
}
if (lib.ok) {
parts.push(`stdlib at ${lib.root}`);
} else {
parts.push("stdlib missing (no lib/ next to binary / MARQDO_LIB)");
}
return { return {
cliOk: true, cliOk: true,
libOk: lib.ok, libOk: lib.ok,
versionOk,
version: probe.version, version: probe.version,
parsedVersion: parsed,
requiredVersion: need,
cliPath, cliPath,
libRoot: lib.root, libRoot: lib.root,
detail: lib.ok detail: parts.join("; "),
? `CLI ${probe.version}; stdlib at ${lib.root}` suggestedMode,
: `CLI ${probe.version}; stdlib missing (no lib/ next to binary, no MARQDO_LIB)`,
}; };
} }
@@ -325,9 +379,13 @@ export async function installFromGitHub(
const status = checkInstallStatus(context); const status = checkInstallStatus(context);
output.appendLine(status.detail); output.appendLine(status.detail);
if (status.cliOk && status.libOk) { if (status.cliOk && status.versionOk && status.libOk) {
void vscode.window.showInformationMessage( void vscode.window.showInformationMessage(
`Marqdo installed (${status.version}). Stdlib ready.` `Marqdo ready (${status.parsedVersion ?? status.version}). Stdlib OK.`
);
} else if (status.cliOk && !status.versionOk) {
void vscode.window.showWarningMessage(
`Marqdo CLI still below ${status.requiredVersion}. ${status.detail}`
); );
} else if (status.cliOk && !status.libOk) { } else if (status.cliOk && !status.libOk) {
void vscode.window.showWarningMessage( void vscode.window.showWarningMessage(
@@ -378,24 +436,32 @@ export async function promptIfNeeded(
const status = checkInstallStatus(context); const status = checkInstallStatus(context);
output.appendLine(`[install] ${status.detail}`); output.appendLine(`[install] ${status.detail}`);
if (status.cliOk && status.libOk) { if (status.cliOk && status.versionOk && status.libOk) {
output.appendLine(`[install] ready (CLI ≥ ${status.requiredVersion}, stdlib present)`);
return; return;
} }
let message: string; let message: string;
let primary: string; let primary: string;
const mode = status.suggestedMode ?? "bundle";
if (!status.cliOk) { if (!status.cliOk) {
message = message = `Marqdo CLI not detected. Install CLI ≥ ${status.requiredVersion} with the standard library?`;
"Marqdo CLI not found. Download the official release (includes standard library) into the extension?";
primary = "Install CLI + stdlib"; primary = "Install CLI + stdlib";
} else if (!status.versionOk) {
message = `Marqdo CLI version is too old (need ≥ ${status.requiredVersion}${
status.parsedVersion ? `, found ${status.parsedVersion}` : `, raw: ${status.version}`
}). Upgrade now (includes stdlib)?`;
primary = "Upgrade CLI + stdlib";
} else { } else {
message = message =
"Marqdo CLI found, but the standard library (lib/) is missing. Download stdlib into the extension?"; "Marqdo CLI is OK, but the standard library (lib/) is missing. Download stdlib into the extension?";
primary = "Install stdlib"; primary = "Install stdlib";
} }
const choice = await vscode.window.showWarningMessage( const choice = await vscode.window.showWarningMessage(
message, message,
{ modal: false },
primary, primary,
"Open Releases", "Open Releases",
"Don't ask again" "Don't ask again"
@@ -403,7 +469,7 @@ export async function promptIfNeeded(
if (choice === primary) { if (choice === primary) {
try { try {
await installFromGitHub(context, output, status.cliOk ? "stdlib" : "bundle"); await installFromGitHub(context, output, mode);
} catch (e) { } catch (e) {
const err = e instanceof Error ? e.message : String(e); const err = e instanceof Error ? e.message : String(e);
output.appendLine(`[install] ${err}`); output.appendLine(`[install] ${err}`);