diff --git a/jetbrains b/jetbrains
index f42e1cf..6c0d7f6 160000
--- a/jetbrains
+++ b/jetbrains
@@ -1 +1 @@
-Subproject commit f42e1cf676c5c18e7a6990fed7d84ff4b41ae3cc
+Subproject commit 6c0d7f671ba5000db78b56faa5366331cfea837f
diff --git a/media/gettingStarted/visual-workflow.svg b/media/gettingStarted/visual-workflow.svg
new file mode 100644
index 0000000..c89189e
--- /dev/null
+++ b/media/gettingStarted/visual-workflow.svg
@@ -0,0 +1,24 @@
+
diff --git a/package.json b/package.json
index 4554e94..3854fb1 100644
--- a/package.json
+++ b/package.json
@@ -35,12 +35,19 @@
"activationEvents": [
"onLanguage:python",
"onLanguage:json",
- "onLanguage:jsonc"
+ "onLanguage:jsonc",
+ "workspaceContains:config.py",
+ "workspaceContains:src/config.py"
],
- "main": "./out/extension.js",
+ "main": "./out/entrypoint.js",
"l10n": "./l10n",
"contributes": {
"commands": [
+ {
+ "command": "okScriptToolkit.openGettingStarted",
+ "title": "%command.openGettingStarted%",
+ "category": "%command.category%"
+ },
{
"command": "okScriptToolkit.showTemplates",
"title": "%command.showTemplates%",
@@ -66,6 +73,11 @@
"title": "%command.openTemplateAssets%",
"category": "%command.category%"
},
+ {
+ "command": "okScriptToolkit.openResourcePublisher",
+ "title": "%command.openResourcePublisher%",
+ "category": "%command.category%"
+ },
{
"command": "okScriptToolkit.openAnnotationEditor",
"title": "%command.openAnnotationEditor%",
@@ -87,6 +99,81 @@
"category": "%command.category%"
}
],
+ "walkthroughs": [
+ {
+ "id": "okScriptToolkit.getStarted",
+ "title": "%walkthrough.title%",
+ "description": "%walkthrough.description%",
+ "steps": [
+ {
+ "id": "chooseGoal",
+ "title": "%walkthrough.goal.title%",
+ "description": "%walkthrough.goal.description%",
+ "media": {
+ "image": "media/gettingStarted/visual-workflow.svg",
+ "altText": "%walkthrough.visual.mediaAlt%"
+ }
+ },
+ {
+ "id": "loadProject",
+ "title": "%walkthrough.project.title%",
+ "description": "%walkthrough.project.description%",
+ "media": {
+ "image": "media/gettingStarted/visual-workflow.svg",
+ "altText": "%walkthrough.visual.mediaAlt%"
+ },
+ "completionEvents": [
+ "onContext:okScriptToolkit.projectReady"
+ ]
+ },
+ {
+ "id": "visualResources",
+ "title": "%walkthrough.visual.title%",
+ "description": "%walkthrough.visual.description%",
+ "media": {
+ "image": "media/gettingStarted/visual-workflow.svg",
+ "altText": "%walkthrough.visual.mediaAlt%"
+ },
+ "completionEvents": [
+ "onCommand:okScriptToolkit.openTemplateAssets"
+ ]
+ },
+ {
+ "id": "publishResources",
+ "title": "%walkthrough.publish.title%",
+ "description": "%walkthrough.publish.description%",
+ "media": {
+ "image": "media/gettingStarted/visual-workflow.svg",
+ "altText": "%walkthrough.visual.mediaAlt%"
+ },
+ "completionEvents": [
+ "onCommand:okScriptToolkit.openResourcePublisher"
+ ]
+ },
+ {
+ "id": "runTask",
+ "title": "%walkthrough.run.title%",
+ "description": "%walkthrough.run.description%",
+ "media": {
+ "image": "media/gettingStarted/visual-workflow.svg",
+ "altText": "%walkthrough.visual.mediaAlt%"
+ },
+ "completionEvents": [
+ "onCommand:okScriptToolkit.showTaskLauncher"
+ ]
+ },
+ {
+ "id": "resources",
+ "title": "%walkthrough.links.title%",
+ "description": "%walkthrough.links.description%",
+ "media": {
+ "image": "media/gettingStarted/visual-workflow.svg",
+ "altText": "%walkthrough.visual.mediaAlt%"
+ }
+ }
+ ]
+ }
+ ],
"viewsContainers": {
"activitybar": [
{
diff --git a/package.nls.es.json b/package.nls.es.json
index c4614ae..7657d3a 100644
--- a/package.nls.es.json
+++ b/package.nls.es.json
@@ -2,15 +2,32 @@
"extension.displayName": "ok-script Toolkit",
"extension.description": "Autocompletado, sugerencias en línea, vista previa de plantillas, lanzamiento de tareas, herramientas de datos de personajes y más para proyectos ok-script.",
"command.category": "ok-script Toolkit",
+ "command.openGettingStarted": "Primeros pasos",
"command.showTemplates": "Abrir galería de plantillas",
"command.screenshotToTemplate": "Capturar en Recursos de Plantilla",
"command.openTemplatesEditor": "Abrir galería de plantillas en el editor",
"command.showTaskLauncher": "Abrir consola",
"command.openCharacterManager": "Abrir gestor de personajes y habilidades",
"command.openTemplateAssets": "Abrir recursos de plantillas",
+ "command.openResourcePublisher": "Abrir publicación de recursos",
"command.openAnnotationEditor": "Abrir editor de anotaciones",
"command.showTempScreenshots": "Abrir capturas temporales",
"command.showConventionSources": "Convención del proyecto vs. mi configuración",
+ "walkthrough.title": "Primeros pasos con ok-script Toolkit",
+ "walkthrough.description": "Elige lo que quieres hacer y sigue el flujo proyecto → recursos → ejecución.",
+ "walkthrough.goal.title": "¿Qué quieres hacer?",
+ "walkthrough.goal.description": "[Escribir o ejecutar tareas](command:okScriptToolkit.showTaskLauncher) · [Crear recursos visuales](command:okScriptToolkit.openTemplateAssets) · [Publicar recursos](command:okScriptToolkit.openResourcePublisher)",
+ "walkthrough.project.title": "1. Cargar un proyecto ok-script",
+ "walkthrough.project.description": "Abre un espacio de trabajo con `config.py` o `src/config.py`, o configura `okScriptToolkit.okScriptProjectPath`. Este paso se completa automáticamente al detectar un proyecto compatible.",
+ "walkthrough.visual.title": "2. Crear recursos visuales",
+ "walkthrough.visual.description": "[Abrir gestión de anotaciones](command:okScriptToolkit.openTemplateAssets) para capturar o importar imágenes y crear anotaciones Template, Rect y Point en un único editor.",
+ "walkthrough.visual.mediaAlt": "Flujo de imagen a anotaciones Template, Rect y Point y publicación",
+ "walkthrough.publish.title": "3. Publicar recursos",
+ "walkthrough.publish.description": "[Abrir publicación de recursos](command:okScriptToolkit.openResourcePublisher), selecciona Template / Rect / Point y publica. Los recursos de posición pueden exportarse como JSON o Python.",
+ "walkthrough.run.title": "4. Ejecutar y depurar",
+ "walkthrough.run.description": "[Abrir el ejecutor](command:okScriptToolkit.showTaskLauncher), elige una tarea, ajusta parámetros, ejecútala y consulta el estado y los registros.",
+ "walkthrough.links.title": "Seguir explorando",
+ "walkthrough.links.description": "[Documentación](https://github.com/AliceJump/ok-script-toolkit#readme) · [GitHub](https://github.com/AliceJump/ok-script-toolkit) · [Issues / Comentarios](https://github.com/AliceJump/ok-script-toolkit/issues) · [Notas de versión](https://github.com/AliceJump/ok-script-toolkit/releases)",
"viewContainer.title": "Herramientas de ok-script",
"viewContainer.tools.title": "Herramientas de ok-script",
"viewContainer.templates.title": "Plantillas de ok-script",
diff --git a/package.nls.ja.json b/package.nls.ja.json
index 01917fa..100113c 100644
--- a/package.nls.ja.json
+++ b/package.nls.ja.json
@@ -2,15 +2,32 @@
"extension.displayName": "ok-script ツールキット",
"extension.description": "ok-script プロジェクト向けの補完、インラインヒント、テンプレートプレビュー、タスク起動、キャラクターデータツールなど。",
"command.category": "ok-script ツールキット",
+ "command.openGettingStarted": "はじめに",
"command.showTemplates": "テンプレートギャラリーを開く",
"command.screenshotToTemplate": "スクリーンショットをテンプレート素材へ",
"command.openTemplatesEditor": "テンプレートギャラリーをエディターで開く",
"command.showTaskLauncher": "コンソールを開く",
"command.openCharacterManager": "キャラクター・スキル管理を開く",
"command.openTemplateAssets": "テンプレートアセットを開く",
+ "command.openResourcePublisher": "リソース公開を開く",
"command.openAnnotationEditor": "アノテーションエディターを開く",
"command.showTempScreenshots": "一時スクリーンショットを開く",
"command.showConventionSources": "プロジェクト規約と自分の設定",
+ "walkthrough.title": "ok-script ツールキットを始める",
+ "walkthrough.description": "やりたいことを選び、プロジェクト → リソース → 実行の流れで進めます。",
+ "walkthrough.goal.title": "何をしますか?",
+ "walkthrough.goal.description": "[タスクを書く・実行する](command:okScriptToolkit.showTaskLauncher) · [ビジュアルリソースを作る](command:okScriptToolkit.openTemplateAssets) · [リソースを公開する](command:okScriptToolkit.openResourcePublisher)",
+ "walkthrough.project.title": "1. ok-script プロジェクトを読み込む",
+ "walkthrough.project.description": "`config.py` または `src/config.py` を含むワークスペースを開くか、`okScriptToolkit.okScriptProjectPath` を設定します。対応プロジェクトを検出すると自動で完了します。",
+ "walkthrough.visual.title": "2. ビジュアルリソースを作る",
+ "walkthrough.visual.description": "[アノテーション管理を開く](command:okScriptToolkit.openTemplateAssets)と、画像のキャプチャやインポート、Template・Rect・Point の注釈を 1 つのエディターで行えます。",
+ "walkthrough.visual.mediaAlt": "画像から Template、Rect、Point の注釈を作り公開するワークフロー",
+ "walkthrough.publish.title": "3. リソースを公開する",
+ "walkthrough.publish.description": "[リソース公開を開く](command:okScriptToolkit.openResourcePublisher)から Template / Rect / Point を選択して公開します。位置リソースは JSON または Python で出力できます。",
+ "walkthrough.run.title": "4. 実行とデバッグ",
+ "walkthrough.run.description": "[ランナーを開く](command:okScriptToolkit.showTaskLauncher)からタスクを選び、パラメータを調整して起動し、実行状態とログを確認します。",
+ "walkthrough.links.title": "さらに使う",
+ "walkthrough.links.description": "[ドキュメント](https://github.com/AliceJump/ok-script-toolkit#readme) · [GitHub](https://github.com/AliceJump/ok-script-toolkit) · [Issue / フィードバック](https://github.com/AliceJump/ok-script-toolkit/issues) · [リリースノート](https://github.com/AliceJump/ok-script-toolkit/releases)",
"viewContainer.title": "ok-script ツール",
"viewContainer.tools.title": "ok-script ツール",
"viewContainer.templates.title": "ok-script テンプレート",
diff --git a/package.nls.json b/package.nls.json
index 4982db4..f68f49a 100644
--- a/package.nls.json
+++ b/package.nls.json
@@ -2,15 +2,32 @@
"extension.displayName": "ok-script Toolkit",
"extension.description": "IntelliSense, inline hints, template previews, task launching, character data tools, and more for ok-script projects.",
"command.category": "ok-script Toolkit",
+ "command.openGettingStarted": "Getting Started",
"command.showTemplates": "Open Resource Preview",
"command.screenshotToTemplate": "Screenshot to Annotation Management",
"command.openTemplatesEditor": "Open Resource Preview in Editor",
"command.showTaskLauncher": "Open Console",
"command.openCharacterManager": "Open Character & Skill Manager",
"command.openTemplateAssets": "Open Annotation Management",
+ "command.openResourcePublisher": "Open Resource Publishing",
"command.openAnnotationEditor": "Open Annotation Editor",
"command.showTempScreenshots": "Open Temp Screenshots",
"command.showConventionSources": "Project Convention vs My Settings",
+ "walkthrough.title": "Get Started with ok-script Toolkit",
+ "walkthrough.description": "Choose what you want to do and follow the project → resources → run workflow.",
+ "walkthrough.goal.title": "What do you want to do?",
+ "walkthrough.goal.description": "[Write or run tasks](command:okScriptToolkit.showTaskLauncher) · [Create visual resources](command:okScriptToolkit.openTemplateAssets) · [Publish resources](command:okScriptToolkit.openResourcePublisher)",
+ "walkthrough.project.title": "1. Load an ok-script project",
+ "walkthrough.project.description": "Open a workspace containing `config.py` or `src/config.py`, or configure `okScriptToolkit.okScriptProjectPath`. This step completes automatically when a supported project is detected.",
+ "walkthrough.visual.title": "2. Create visual resources",
+ "walkthrough.visual.description": "[Open Annotation Management](command:okScriptToolkit.openTemplateAssets) to capture or import images and create Template, Rect, and Point annotations in one editor.",
+ "walkthrough.visual.mediaAlt": "Image to Template, Rect, and Point annotation and publishing workflow",
+ "walkthrough.publish.title": "3. Publish resources",
+ "walkthrough.publish.description": "[Open Resource Publishing](command:okScriptToolkit.openResourcePublisher), select Template / Rect / Point, then publish. Position resources can be exported as JSON or Python.",
+ "walkthrough.run.title": "4. Run and debug",
+ "walkthrough.run.description": "[Open the runner](command:okScriptToolkit.showTaskLauncher), choose a task, adjust parameters, start it, and follow runtime status and logs.",
+ "walkthrough.links.title": "Keep exploring",
+ "walkthrough.links.description": "[Documentation](https://github.com/AliceJump/ok-script-toolkit#readme) · [GitHub](https://github.com/AliceJump/ok-script-toolkit) · [Issues / Feedback](https://github.com/AliceJump/ok-script-toolkit/issues) · [Release Notes](https://github.com/AliceJump/ok-script-toolkit/releases)",
"viewContainer.title": "ok-script Tools",
"viewContainer.tools.title": "ok-script Tools",
"viewContainer.templates.title": "ok-script Resources",
diff --git a/package.nls.ko.json b/package.nls.ko.json
index 0dc8f7c..f063125 100644
--- a/package.nls.ko.json
+++ b/package.nls.ko.json
@@ -2,15 +2,32 @@
"extension.displayName": "ok-script 툴킷",
"extension.description": "ok-script 프로젝트용 자동 완성, 인라인 힌트, 템플릿 미리보기, 작업 실행, 캐릭터 데이터 도구 등.",
"command.category": "ok-script 툴킷",
+ "command.openGettingStarted": "시작하기",
"command.showTemplates": "템플릿 갤러리 열기",
"command.screenshotToTemplate": "스크린샷을 템플릿 에셋으로",
"command.openTemplatesEditor": "편집기에서 템플릿 갤러리 열기",
"command.showTaskLauncher": "콘솔 열기",
"command.openCharacterManager": "캐릭터·스킬 관리자 열기",
"command.openTemplateAssets": "템플릿 에셋 열기",
+ "command.openResourcePublisher": "리소스 게시 열기",
"command.openAnnotationEditor": "어노테이션 편집기 열기",
"command.showTempScreenshots": "임시 스크린샷 열기",
"command.showConventionSources": "프로젝트 규약과 내 설정",
+ "walkthrough.title": "ok-script 툴킷 시작하기",
+ "walkthrough.description": "원하는 작업을 선택하고 프로젝트 → 리소스 → 실행 흐름을 따라가세요.",
+ "walkthrough.goal.title": "무엇을 하시겠어요?",
+ "walkthrough.goal.description": "[작업 작성 또는 실행](command:okScriptToolkit.showTaskLauncher) · [시각 리소스 제작](command:okScriptToolkit.openTemplateAssets) · [리소스 게시](command:okScriptToolkit.openResourcePublisher)",
+ "walkthrough.project.title": "1. ok-script 프로젝트 불러오기",
+ "walkthrough.project.description": "`config.py` 또는 `src/config.py`가 있는 작업 영역을 열거나 `okScriptToolkit.okScriptProjectPath`를 설정하세요. 지원 프로젝트가 감지되면 자동으로 완료됩니다.",
+ "walkthrough.visual.title": "2. 시각 리소스 제작",
+ "walkthrough.visual.description": "[주석 관리 열기](command:okScriptToolkit.openTemplateAssets)에서 이미지를 캡처하거나 가져오고 하나의 편집기에서 Template, Rect, Point 주석을 만드세요.",
+ "walkthrough.visual.mediaAlt": "이미지에서 Template, Rect, Point 주석을 만들고 게시하는 워크플로",
+ "walkthrough.publish.title": "3. 리소스 게시",
+ "walkthrough.publish.description": "[리소스 게시 열기](command:okScriptToolkit.openResourcePublisher)에서 Template / Rect / Point를 선택해 게시하세요. 위치 리소스는 JSON 또는 Python으로 내보낼 수 있습니다.",
+ "walkthrough.run.title": "4. 실행 및 디버깅",
+ "walkthrough.run.description": "[러너 열기](command:okScriptToolkit.showTaskLauncher)에서 작업을 선택하고 매개변수를 조정해 실행한 뒤 상태와 로그를 확인하세요.",
+ "walkthrough.links.title": "더 알아보기",
+ "walkthrough.links.description": "[문서](https://github.com/AliceJump/ok-script-toolkit#readme) · [GitHub](https://github.com/AliceJump/ok-script-toolkit) · [Issue / 피드백](https://github.com/AliceJump/ok-script-toolkit/issues) · [릴리스 노트](https://github.com/AliceJump/ok-script-toolkit/releases)",
"viewContainer.title": "ok-script 도구",
"viewContainer.tools.title": "ok-script 도구",
"viewContainer.templates.title": "ok-script 템플릿",
diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json
index 0db3fcf..3d8ca9f 100644
--- a/package.nls.zh-cn.json
+++ b/package.nls.zh-cn.json
@@ -2,15 +2,32 @@
"extension.displayName": "ok-script 工具箱",
"extension.description": "为 ok-script 项目提供智能补全、行内提示、模板预览、任务启动、角色数据工具等完整开发辅助。",
"command.category": "ok-script 工具箱",
+ "command.openGettingStarted": "入门指南",
"command.showTemplates": "打开资源预览",
"command.screenshotToTemplate": "截图并打开标注管理",
"command.openTemplatesEditor": "在编辑器中打开资源预览",
"command.showTaskLauncher": "打开控制台",
"command.openCharacterManager": "打开角色技能管理面板",
"command.openTemplateAssets": "打开标注管理",
+ "command.openResourcePublisher": "打开资源发布",
"command.openAnnotationEditor": "打开标注编辑器",
"command.showTempScreenshots": "打开临时截图",
"command.showConventionSources": "项目约定 vs 我的设置",
+ "walkthrough.title": "开始使用 ok-script 工具箱",
+ "walkthrough.description": "先选择你想做的事,再按“项目 → 资源 → 运行”的流程开始工作。",
+ "walkthrough.goal.title": "你想做什么?",
+ "walkthrough.goal.description": "[编写或运行任务](command:okScriptToolkit.showTaskLauncher) · [制作视觉资源](command:okScriptToolkit.openTemplateAssets) · [发布资源](command:okScriptToolkit.openResourcePublisher)",
+ "walkthrough.project.title": "1. 加载 ok-script 项目",
+ "walkthrough.project.description": "打开包含 `config.py` 或 `src/config.py` 的工作区,或配置 `okScriptToolkit.okScriptProjectPath`。识别到支持的项目后本步骤会自动完成。",
+ "walkthrough.visual.title": "2. 制作视觉资源",
+ "walkthrough.visual.description": "[打开标注管理](command:okScriptToolkit.openTemplateAssets),截图或导入图片,并在一个编辑器中创建 Template、Rect、Point 标注。",
+ "walkthrough.visual.mediaAlt": "图片经过 Template、Rect、Point 标注后进入统一发布流程",
+ "walkthrough.publish.title": "3. 发布资源",
+ "walkthrough.publish.description": "[打开资源发布](command:okScriptToolkit.openResourcePublisher),选择 Template / Rect / Point 后发布;位置资源可导出为 JSON 或 Python。",
+ "walkthrough.run.title": "4. 运行和调试",
+ "walkthrough.run.description": "[打开运行器](command:okScriptToolkit.showTaskLauncher),选择任务、调整参数、启动,并查看运行状态与日志。",
+ "walkthrough.links.title": "长期入口",
+ "walkthrough.links.description": "[文档](https://github.com/AliceJump/ok-script-toolkit#readme) · [GitHub](https://github.com/AliceJump/ok-script-toolkit) · [Issue / 反馈](https://github.com/AliceJump/ok-script-toolkit/issues) · [更新日志](https://github.com/AliceJump/ok-script-toolkit/releases)",
"viewContainer.title": "ok-script 工具",
"viewContainer.tools.title": "ok-script 工具",
"viewContainer.templates.title": "ok-script 资源",
diff --git a/package.nls.zh-tw.json b/package.nls.zh-tw.json
index 06aa241..022d01d 100644
--- a/package.nls.zh-tw.json
+++ b/package.nls.zh-tw.json
@@ -2,15 +2,32 @@
"extension.displayName": "ok-script 工具箱",
"extension.description": "為 ok-script 專案提供智慧補全、行內提示、模板預覽、任務啟動、角色資料工具等完整開發輔助。",
"command.category": "ok-script 工具箱",
+ "command.openGettingStarted": "入門指南",
"command.showTemplates": "開啟模板面板",
"command.screenshotToTemplate": "截圖並開啟模板素材",
"command.openTemplatesEditor": "在編輯器中開啟模板面板",
"command.showTaskLauncher": "開啟控制台",
"command.openCharacterManager": "開啟角色技能管理面板",
"command.openTemplateAssets": "開啟模板素材",
+ "command.openResourcePublisher": "開啟資源發布",
"command.openAnnotationEditor": "開啟標註編輯器",
"command.showTempScreenshots": "開啟臨時截圖",
"command.showConventionSources": "專案約定 vs 我的設定",
+ "walkthrough.title": "開始使用 ok-script 工具箱",
+ "walkthrough.description": "先選擇你想做的事,再依照「專案 → 資源 → 執行」的流程開始工作。",
+ "walkthrough.goal.title": "你想做什麼?",
+ "walkthrough.goal.description": "[編寫或執行任務](command:okScriptToolkit.showTaskLauncher) · [製作視覺資源](command:okScriptToolkit.openTemplateAssets) · [發布資源](command:okScriptToolkit.openResourcePublisher)",
+ "walkthrough.project.title": "1. 載入 ok-script 專案",
+ "walkthrough.project.description": "開啟包含 `config.py` 或 `src/config.py` 的工作區,或設定 `okScriptToolkit.okScriptProjectPath`。偵測到支援的專案後本步驟會自動完成。",
+ "walkthrough.visual.title": "2. 製作視覺資源",
+ "walkthrough.visual.description": "[開啟標註管理](command:okScriptToolkit.openTemplateAssets),截圖或匯入圖片,並在同一個編輯器中建立 Template、Rect、Point 標註。",
+ "walkthrough.visual.mediaAlt": "圖片經過 Template、Rect、Point 標註後進入統一發布流程",
+ "walkthrough.publish.title": "3. 發布資源",
+ "walkthrough.publish.description": "[開啟資源發布](command:okScriptToolkit.openResourcePublisher),選擇 Template / Rect / Point 後發布;位置資源可匯出為 JSON 或 Python。",
+ "walkthrough.run.title": "4. 執行和除錯",
+ "walkthrough.run.description": "[開啟執行器](command:okScriptToolkit.showTaskLauncher),選擇任務、調整參數、啟動,並查看執行狀態與日誌。",
+ "walkthrough.links.title": "長期入口",
+ "walkthrough.links.description": "[文件](https://github.com/AliceJump/ok-script-toolkit#readme) · [GitHub](https://github.com/AliceJump/ok-script-toolkit) · [Issue / 回饋](https://github.com/AliceJump/ok-script-toolkit/issues) · [更新日誌](https://github.com/AliceJump/ok-script-toolkit/releases)",
"viewContainer.title": "ok-script 工具",
"viewContainer.tools.title": "ok-script 工具",
"viewContainer.templates.title": "ok-script 模板",
diff --git a/src/entrypoint.ts b/src/entrypoint.ts
new file mode 100644
index 0000000..606a961
--- /dev/null
+++ b/src/entrypoint.ts
@@ -0,0 +1,105 @@
+import * as fs from 'fs';
+import * as path from 'path';
+import * as vscode from 'vscode';
+import { activate as activateCore, deactivate as deactivateCore } from './extension';
+import { resolveProjectDir } from './projectConfig';
+
+const WALKTHROUGH_ID = 'okScriptToolkit.getStarted';
+const PROJECT_READY_CONTEXT = 'okScriptToolkit.projectReady';
+
+function isSupportedProject(projectDir: string): boolean {
+ if (!projectDir) return false;
+ try {
+ if (!fs.statSync(projectDir).isDirectory()) return false;
+ } catch {
+ return false;
+ }
+
+ return [
+ path.join(projectDir, 'config.py'),
+ path.join(projectDir, 'src', 'config.py'),
+ ].some((file) => {
+ try {
+ return fs.statSync(file).isFile();
+ } catch {
+ return false;
+ }
+ });
+}
+
+export function activate(context: vscode.ExtensionContext): void {
+ activateCore(context);
+
+ const updateProjectReady = () => vscode.commands.executeCommand(
+ 'setContext',
+ PROJECT_READY_CONTEXT,
+ isSupportedProject(resolveProjectDir()),
+ );
+
+ let configWatcherDisposables: vscode.Disposable[] = [];
+
+ const disposeConfigWatchers = () => {
+ for (const disposable of configWatcherDisposables) disposable.dispose();
+ configWatcherDisposables = [];
+ };
+
+ const addConfigWatcher = (pattern: string | vscode.RelativePattern) => {
+ const watcher = vscode.workspace.createFileSystemWatcher(pattern);
+ configWatcherDisposables.push(
+ watcher,
+ watcher.onDidCreate(() => { void updateProjectReady(); }),
+ watcher.onDidDelete(() => { void updateProjectReady(); }),
+ );
+ };
+
+ const bindConfigWatchers = () => {
+ disposeConfigWatchers();
+
+ // Workspace globs keep automatic project detection responsive.
+ addConfigWatcher('**/config.py');
+ addConfigWatcher('**/src/config.py');
+
+ // A configured project may live outside the open workspace. String globs only
+ // watch workspace folders, so bind additional RelativePatterns to that directory.
+ const configuredPath = vscode.workspace
+ .getConfiguration('okScriptToolkit')
+ .get('okScriptProjectPath')
+ ?.trim();
+ if (configuredPath) {
+ const configuredProjectDir = resolveProjectDir();
+ if (configuredProjectDir) {
+ addConfigWatcher(new vscode.RelativePattern(configuredProjectDir, 'config.py'));
+ addConfigWatcher(new vscode.RelativePattern(configuredProjectDir, 'src/config.py'));
+ }
+ }
+ };
+
+ bindConfigWatchers();
+
+ context.subscriptions.push(
+ vscode.commands.registerCommand('okScriptToolkit.openGettingStarted', () => {
+ const walkthrough = `${context.extension.id}#${WALKTHROUGH_ID}`;
+ return vscode.commands.executeCommand('workbench.action.openWalkthrough', walkthrough);
+ }),
+ vscode.commands.registerCommand('okScriptToolkit.openResourcePublisher', () => {
+ return vscode.commands.executeCommand('okScriptToolkit.openTemplateAssets');
+ }),
+ vscode.workspace.onDidChangeWorkspaceFolders(() => {
+ bindConfigWatchers();
+ void updateProjectReady();
+ }),
+ vscode.workspace.onDidChangeConfiguration((event) => {
+ if (event.affectsConfiguration('okScriptToolkit.okScriptProjectPath')) {
+ bindConfigWatchers();
+ void updateProjectReady();
+ }
+ }),
+ new vscode.Disposable(disposeConfigWatchers),
+ );
+
+ void updateProjectReady();
+}
+
+export function deactivate(): void {
+ deactivateCore();
+}