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:
1 parent
3887205ebb
commit
d1b75d88c5
10 files changed
+270
-72
No files matched your search
@@ -7,3 +7,4 @@ node_modules/**
|
||||
**/*.map
|
||||
**/*.ts
|
||||
!out/**/*.js
|
||||
media/logo-source.*
|
||||
@@ -46,13 +46,13 @@ path:line:col: message
|
||||
|
||||
## CLI 安装(扩展侧)
|
||||
|
||||
- 启动时(`onStartupFinished`)检测 CLI + `lib/`;缺失则提示 **Install CLI + stdlib**。
|
||||
- 从 GitHub Releases 下载推荐 zip(`marqdo.exe` + `lib/`)到扩展 `globalStorage/cli/`,并写入 `marqdo.cliPath` / `marqdo.libPath`(spawn 时带 `MARQDO_LIB`)。
|
||||
- 手动命令:`Marqdo: Install / Repair CLI`、`Marqdo: Check CLI Status`。
|
||||
- 当前自动安装预编译包以 **Windows x64** 为主(与现有 Release 资产一致);其它平台无匹配资产时会提示打开 Releases。
|
||||
- 启动时(`onStartupFinished`)检测:**CLI 是否存在**、**版本是否 ≥ `marqdo.minCliVersion`(默认 0.1.0)**、**stdlib (`lib/`) 是否可用**。
|
||||
- 任一不满足 → 提示用户,由其选择安装 / 打开 Releases / 不再询问。
|
||||
- 安装物落到扩展 `globalStorage/cli/`,并写入 `marqdo.cliPath` / `marqdo.libPath`(spawn 时带 `MARQDO_LIB`)。
|
||||
- 命令:`Marqdo: Install / Repair CLI`、`Marqdo: Check CLI Status`。
|
||||
- 预编译自动安装以 **Windows x64** Release zip 为主。
|
||||
|
||||
## 调试(P3 → 现有入口)
|
||||
|
||||
- **已落地**:命令 `Marqdo: Open Debugger` 子进程启动 `marqdo debug --no-open`,再打开浏览器 / Simple Browser。
|
||||
- **中期**:DAP 适配器包装现有 debug session API(`src/view/debug_api.rs` 语义),避免第三套断点模型。
|
||||
|
||||
|
||||
@@ -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 |
|
||||
| 语言仓 | [`cflmy/marqdo`](https://github.com/cflmy/marqdo) `main` |
|
||||
| 扩展仓形态 | **同仓库专用分支** `vscode-extension`(本目录);`main` **不跟踪**本目录 |
|
||||
|
||||
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 |
@@ -2,8 +2,9 @@
|
||||
"name": "marqdo",
|
||||
"displayName": "Marqdo",
|
||||
"description": "Language support for Marqdo (.mq.md) — code as documentation.",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.5",
|
||||
"publisher": "cflmy",
|
||||
"icon": "media/icon.png",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cflmy/marqdo.git"
|
||||
@@ -55,57 +56,93 @@
|
||||
"commands": [
|
||||
{
|
||||
"command": "marqdo.run",
|
||||
"title": "Marqdo: Run File",
|
||||
"category": "Marqdo"
|
||||
"title": "Run File",
|
||||
"shortTitle": "Run",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(play)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.view",
|
||||
"title": "Open View",
|
||||
"shortTitle": "View",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(open-preview)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.debug",
|
||||
"title": "Marqdo: Open Debugger",
|
||||
"category": "Marqdo"
|
||||
"title": "Open Debugger",
|
||||
"shortTitle": "Debug",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(debug-alt)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.view.stop",
|
||||
"title": "Stop View",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(close)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.debug.stop",
|
||||
"title": "Marqdo: Stop Debugger",
|
||||
"category": "Marqdo"
|
||||
"title": "Stop Debugger",
|
||||
"shortTitle": "Stop Debug",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(debug-stop)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.catalog",
|
||||
"title": "Marqdo: Generate Catalog",
|
||||
"category": "Marqdo"
|
||||
"title": "Generate Catalog",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(book)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.showOutput",
|
||||
"title": "Marqdo: Show Output",
|
||||
"category": "Marqdo"
|
||||
"title": "Show Output",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(output)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.installCli",
|
||||
"title": "Marqdo: Install / Repair CLI",
|
||||
"category": "Marqdo"
|
||||
"title": "Install / Repair CLI",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(cloud-download)"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.checkCli",
|
||||
"title": "Marqdo: Check CLI Status",
|
||||
"category": "Marqdo"
|
||||
"title": "Check CLI Status",
|
||||
"category": "Marqdo",
|
||||
"icon": "$(info)"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"editor/title": [
|
||||
{
|
||||
"command": "marqdo.run",
|
||||
"when": "resourceFilename =~ /\\.mq\\.md$/ || editorLangId == marqdo",
|
||||
"group": "navigation@1"
|
||||
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
|
||||
"group": "navigation@90"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.view",
|
||||
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
|
||||
"group": "navigation@91"
|
||||
},
|
||||
{
|
||||
"command": "marqdo.debug",
|
||||
"when": "resourceFilename =~ /\\.mq\\.md$/ || editorLangId == marqdo",
|
||||
"group": "navigation@2"
|
||||
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
|
||||
"group": "navigation@92"
|
||||
}
|
||||
],
|
||||
"commandPalette": [
|
||||
{
|
||||
"command": "marqdo.run",
|
||||
"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": {
|
||||
"type": "boolean",
|
||||
"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": {
|
||||
"type": "boolean",
|
||||
@@ -150,6 +192,25 @@
|
||||
"default": 60000,
|
||||
"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": {
|
||||
"type": "string",
|
||||
"default": "127.0.0.1",
|
||||
|
||||
@@ -129,28 +129,37 @@ export function probeMarqdo(
|
||||
}
|
||||
}
|
||||
|
||||
export class DebugServer {
|
||||
export class LiveServer {
|
||||
private proc: ChildProcessWithoutNullStreams | null = null;
|
||||
private output: vscode.OutputChannel;
|
||||
private label: string;
|
||||
|
||||
constructor(output: vscode.OutputChannel) {
|
||||
constructor(output: vscode.OutputChannel, label: string) {
|
||||
this.output = output;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
get running(): boolean {
|
||||
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) {
|
||||
await this.stop();
|
||||
}
|
||||
const cli = resolveMarqdoCli();
|
||||
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(
|
||||
cli,
|
||||
["debug", targetPath, "--host", host, "--port", String(port), "--no-open"],
|
||||
[subcommand, targetPath, "--host", host, "--port", String(port), "--no-open"],
|
||||
{
|
||||
cwd,
|
||||
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.stderr.on("data", (d: Buffer) => this.output.append(d.toString()));
|
||||
this.proc.on("exit", (code) => {
|
||||
this.output.appendLine(`[debug] exited (${code})`);
|
||||
this.output.appendLine(`[${this.label}] exited (${code})`);
|
||||
this.proc = null;
|
||||
});
|
||||
this.proc.on("error", (err) => {
|
||||
this.output.appendLine(`[debug] ${err.message}`);
|
||||
this.output.appendLine(`[${this.label}] ${err.message}`);
|
||||
this.proc = null;
|
||||
});
|
||||
await new Promise((r) => setTimeout(r, 600));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as vscode from "vscode";
|
||||
import { DebugServer, configureCliResolution, runMarqdo, workspaceCwd } from "./cli";
|
||||
import { LiveServer, configureCliResolution, runMarqdo, workspaceCwd } from "./cli";
|
||||
import { DiagnosticBag } from "./diagnostics";
|
||||
import {
|
||||
checkInstallStatus,
|
||||
@@ -12,14 +12,16 @@ import {
|
||||
|
||||
let output: vscode.OutputChannel;
|
||||
let diagnostics: DiagnosticBag;
|
||||
let debugServer: DebugServer;
|
||||
let viewServer: LiveServer;
|
||||
let debugServer: LiveServer;
|
||||
let extContext: vscode.ExtensionContext;
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): void {
|
||||
extContext = context;
|
||||
output = vscode.window.createOutputChannel("Marqdo");
|
||||
diagnostics = new DiagnosticBag();
|
||||
debugServer = new DebugServer(output);
|
||||
viewServer = new LiveServer(output, "view");
|
||||
debugServer = new LiveServer(output, "debug");
|
||||
|
||||
configureCliResolution(
|
||||
context,
|
||||
@@ -31,12 +33,17 @@ export function activate(context: vscode.ExtensionContext): void {
|
||||
output,
|
||||
diagnostics.disposable,
|
||||
vscode.commands.registerCommand("marqdo.run", () => runActiveFile()),
|
||||
vscode.commands.registerCommand("marqdo.view", () => startView()),
|
||||
vscode.commands.registerCommand("marqdo.debug", () => startDebug()),
|
||||
vscode.commands.registerCommand("marqdo.debug.stop", () => stopDebug()),
|
||||
vscode.commands.registerCommand("marqdo.view.stop", () => stopView()),
|
||||
vscode.commands.registerCommand("marqdo.catalog", () => runCatalog()),
|
||||
vscode.commands.registerCommand("marqdo.showOutput", () => output.show(true)),
|
||||
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) => {
|
||||
if (doc.languageId === "marqdo" && autoDiagnose()) {
|
||||
void diagnoseDocument(doc);
|
||||
@@ -48,6 +55,7 @@ export function activate(context: vscode.ExtensionContext): void {
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
void viewServer?.stop();
|
||||
void debugServer?.stop();
|
||||
}
|
||||
|
||||
@@ -59,11 +67,8 @@ async function installCli(): Promise<void> {
|
||||
await resetSkipPrompt(extContext);
|
||||
const status = checkInstallStatus(extContext);
|
||||
try {
|
||||
if (status.cliOk && !status.libOk) {
|
||||
await installFromGitHub(extContext, output, "stdlib");
|
||||
} else {
|
||||
await installFromGitHub(extContext, output, "bundle");
|
||||
}
|
||||
const mode = status.suggestedMode ?? "bundle";
|
||||
await installFromGitHub(extContext, output, mode);
|
||||
} catch (e) {
|
||||
const err = e instanceof Error ? e.message : String(e);
|
||||
output.appendLine(`[install] ${err}`);
|
||||
@@ -77,8 +82,10 @@ async function installCli(): Promise<void> {
|
||||
async function checkCli(): Promise<void> {
|
||||
const status = checkInstallStatus(extContext);
|
||||
output.appendLine(`[check] ${status.detail}`);
|
||||
if (status.cliOk && status.libOk) {
|
||||
void vscode.window.showInformationMessage(`Marqdo ready: ${status.version}`);
|
||||
if (status.cliOk && status.versionOk && status.libOk) {
|
||||
void vscode.window.showInformationMessage(
|
||||
`Marqdo ready: ${status.parsedVersion ?? status.version} (≥ ${status.requiredVersion}), stdlib OK`
|
||||
);
|
||||
return;
|
||||
}
|
||||
const choice = await vscode.window.showWarningMessage(
|
||||
@@ -106,21 +113,53 @@ function activeMqDoc(): vscode.TextDocument | undefined {
|
||||
|
||||
async function ensureCliOrOfferInstall(): Promise<boolean> {
|
||||
const status = checkInstallStatus(extContext);
|
||||
if (status.cliOk) {
|
||||
if (status.cliOk && status.versionOk && status.libOk) {
|
||||
return true;
|
||||
}
|
||||
const choice = await vscode.window.showWarningMessage(
|
||||
"Marqdo CLI not found. Install the official release (includes stdlib)?",
|
||||
"Install",
|
||||
"Cancel"
|
||||
);
|
||||
if (status.cliOk && status.versionOk && !status.libOk) {
|
||||
const choice = await vscode.window.showWarningMessage(
|
||||
"Standard library (lib/) is missing. Continue anyway, or install stdlib?",
|
||||
"Install stdlib",
|
||||
"Continue",
|
||||
"Cancel"
|
||||
);
|
||||
if (choice === "Install stdlib") {
|
||||
await installCli();
|
||||
return true;
|
||||
}
|
||||
if (choice === "Continue") {
|
||||
return true;
|
||||
}
|
||||
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();
|
||||
return checkInstallStatus(extContext).cliOk;
|
||||
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> {
|
||||
if (!(await ensureCliOrOfferInstall())) {
|
||||
return;
|
||||
@@ -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> {
|
||||
if (!(await ensureCliOrOfferInstall())) {
|
||||
return;
|
||||
}
|
||||
const doc = activeMqDoc();
|
||||
const folder = vscode.workspace.workspaceFolders?.[0];
|
||||
const target = doc?.uri.fsPath ?? folder?.uri.fsPath;
|
||||
const target = resolveTargetPath();
|
||||
if (!target) {
|
||||
void vscode.window.showWarningMessage("Open a folder or .mq.md file to debug.");
|
||||
return;
|
||||
@@ -184,13 +245,8 @@ async function startDebug(): Promise<void> {
|
||||
const port = cfg.get<number>("debugPort") ?? 7430;
|
||||
output.show(true);
|
||||
try {
|
||||
const url = await debugServer.start(target, host, port);
|
||||
const open = cfg.get<string>("debugOpen") ?? "external";
|
||||
if (open === "simpleBrowser") {
|
||||
await vscode.commands.executeCommand("simpleBrowser.show", url);
|
||||
} else {
|
||||
await vscode.env.openExternal(vscode.Uri.parse(url));
|
||||
}
|
||||
const url = await debugServer.start("debug", target, host, port);
|
||||
await openUrl(url, "debugOpen");
|
||||
void vscode.window.setStatusBarMessage(`Marqdo debug: ${url}`, 5000);
|
||||
} catch (e) {
|
||||
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> {
|
||||
await debugServer.stop();
|
||||
void vscode.window.setStatusBarMessage("Marqdo debug stopped", 3000);
|
||||
|
||||
@@ -12,12 +12,40 @@ const MANAGED_DIR = "cli";
|
||||
export type InstallStatus = {
|
||||
cliOk: boolean;
|
||||
libOk: boolean;
|
||||
versionOk: boolean;
|
||||
version?: string;
|
||||
parsedVersion?: string;
|
||||
requiredVersion: string;
|
||||
cliPath?: string;
|
||||
libRoot?: 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 GhRelease = {
|
||||
tag_name: string;
|
||||
@@ -131,26 +159,52 @@ function stdlibPresent(cliPath: string, context?: vscode.ExtensionContext): { ok
|
||||
}
|
||||
|
||||
export function checkInstallStatus(context: vscode.ExtensionContext): InstallStatus {
|
||||
const need = requiredVersion();
|
||||
const cliPath = resolveCliPath(context);
|
||||
const probe = probeMarqdo(cliPath);
|
||||
if (!probe.ok) {
|
||||
return {
|
||||
cliOk: false,
|
||||
libOk: false,
|
||||
versionOk: false,
|
||||
requiredVersion: need,
|
||||
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);
|
||||
|
||||
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 {
|
||||
cliOk: true,
|
||||
libOk: lib.ok,
|
||||
versionOk,
|
||||
version: probe.version,
|
||||
parsedVersion: parsed,
|
||||
requiredVersion: need,
|
||||
cliPath,
|
||||
libRoot: lib.root,
|
||||
detail: lib.ok
|
||||
? `CLI ${probe.version}; stdlib at ${lib.root}`
|
||||
: `CLI ${probe.version}; stdlib missing (no lib/ next to binary, no MARQDO_LIB)`,
|
||||
detail: parts.join("; "),
|
||||
suggestedMode,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -325,9 +379,13 @@ export async function installFromGitHub(
|
||||
|
||||
const status = checkInstallStatus(context);
|
||||
output.appendLine(status.detail);
|
||||
if (status.cliOk && status.libOk) {
|
||||
if (status.cliOk && status.versionOk && status.libOk) {
|
||||
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) {
|
||||
void vscode.window.showWarningMessage(
|
||||
@@ -378,24 +436,32 @@ export async function promptIfNeeded(
|
||||
const status = checkInstallStatus(context);
|
||||
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;
|
||||
}
|
||||
|
||||
let message: string;
|
||||
let primary: string;
|
||||
const mode = status.suggestedMode ?? "bundle";
|
||||
|
||||
if (!status.cliOk) {
|
||||
message =
|
||||
"Marqdo CLI not found. Download the official release (includes standard library) into the extension?";
|
||||
message = `Marqdo CLI not detected. Install CLI ≥ ${status.requiredVersion} with the standard library?`;
|
||||
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 {
|
||||
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";
|
||||
}
|
||||
|
||||
const choice = await vscode.window.showWarningMessage(
|
||||
message,
|
||||
{ modal: false },
|
||||
primary,
|
||||
"Open Releases",
|
||||
"Don't ask again"
|
||||
@@ -403,7 +469,7 @@ export async function promptIfNeeded(
|
||||
|
||||
if (choice === primary) {
|
||||
try {
|
||||
await installFromGitHub(context, output, status.cliOk ? "stdlib" : "bundle");
|
||||
await installFromGitHub(context, output, mode);
|
||||
} catch (e) {
|
||||
const err = e instanceof Error ? e.message : String(e);
|
||||
output.appendLine(`[install] ${err}`);
|
||||
|
||||
Reference in new issue
Block a user