<commit_before>import * as path from "path";
import * as vs from "vscode";
import { safeSpawn } from "../debug/utils";
import { pubPath } from "../sdk/utils";
import { Sdks } from "../utils";
import { PubGlobal } from "./global";

const packageName = "Stagehand";
const packageID = "stagehand";

export class Stagehand {
	constructor(private sdks: Sdks, private pubGlobal: PubGlobal) { }

	public promptToInstallIfRequired() {
		return this.pubGlobal.promptToInstallIfRequired(packageName, packageID);
	}

	public async getTemplates(): Promise<StagehandTemplate[]> {
		const json = await this.getTemplateJson();
		return JSON.parse(json);
	}

	private async getTemplateJson(): Promise<string> {
		return this.runCommandWithProgress("Fetching Stagehand templates...", ["global", "run", "stagehand", "--machine"]);
	}

	private runCommandWithProgress(title: string, args: string[]): Thenable<string> {
		return vs.window.withProgress({
			location: vs.ProgressLocation.Notification,
			title,<commit_msg>Add missing help URL for Stagehand + add min version<commit_after>import * as path from "path";
import * as vs from "vscode";
import { stagehandInstallationInstructionsUrl } from "../constants";
import { safeSpawn } from "../debug/utils";
import { pubPath } from "../sdk/utils";
import { Sdks } from "../utils";
import { PubGlobal } from "./global";

const packageName = "Stagehand";
const packageID = "stagehand";

export class Stagehand {
	constructor(private sdks: Sdks, private pubGlobal: PubGlobal) { }

	public promptToInstallIfRequired() {
		return this.pubGlobal.promptToInstallIfRequired(packageName, packageID, stagehandInstallationInstructionsUrl, "1.0.0");
	}

	public async getTemplates(): Promise<StagehandTemplate[]> {
		const json = await this.getTemplateJson();
		return JSON.parse(json);
	}

	private async getTemplateJson(): Promise<string> {
		return this.runCommandWithProgress("Fetching Stagehand templates...", ["global", "run", "stagehand", "--machine"]);
	}

	private runCommandWithProgress(title: string, args: string[]): Thenable<string> {
		return vs.window.withProgress({
			location: vs.ProgressLocation.Notification,
			title,
{'fraction_non_alphanumeric': 0.13663733209819362, 'fraction_numerical': 0.0013895321908290875, 'mean_word_length': 5.371681415929204, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '194797', 'n_tokens_mistral': 645, 'n_tokens_neox': 621, 'n_words': 171}