@harmonyos-arkts/opencode-plugin 0.0.18 → 0.0.20

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -36
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31911,9 +31911,6 @@ function createHmAgent() {
31911
31911
  permission: {
31912
31912
  "*": "allow",
31913
31913
  doom_loop: "ask",
31914
- external_directory: {
31915
- "*": "ask"
31916
- },
31917
31914
  "skillSearch": "allow",
31918
31915
  ascf_build: "deny",
31919
31916
  skill: {
@@ -44872,10 +44869,10 @@ async function updateEtsCache(sessionManager, sessionID, directory) {
44872
44869
  var CHECK_ETS_TEMPLATE_MODES = /* @__PURE__ */ new Set(["atomic", "application"]);
44873
44870
  function createHmTemplateTool(managers) {
44874
44871
  return tool({
44875
- description: "Create an empty HarmonyOS project template. Supports three modes: 'application' (full app), 'module' (sub-module), 'atomic' (atomic service). Defaults to the current working directory unless the user specifies a different directory.",
44872
+ description: "Create an empty HarmonyOS project template. Supports three modes: 'application' (full app), 'module' (sub-module), 'atomic' (atomic service). Defaults to the current working directory unless the user specifies a different directory.\n\nParameters:\n- filePath: Absolute path of the target directory where the template will be created. Defaults to the current working directory if not specified.\n- mode: Template type: 'application' (\u5E94\u7528), 'module' (\u6A21\u5757), or 'atomic' (\u5143\u670D\u52A1).",
44876
44873
  args: {
44877
- filePath: tool.schema.string("Absolute path of the target directory where the template will be created. Defaults to the current working directory if not specified."),
44878
- mode: tool.schema.string("Template type: 'application' (\u5E94\u7528), 'module' (\u6A21\u5757), or 'atomic' (\u5143\u670D\u52A1)")
44874
+ filePath: tool.schema.string(),
44875
+ mode: tool.schema.string()
44879
44876
  },
44880
44877
  execute: async (args, context) => {
44881
44878
  try {
@@ -45584,11 +45581,11 @@ function formatUpdateTime(utcTimeStr) {
45584
45581
  // src/tools/skill-search/skill-search-tool.ts
45585
45582
  function skillSearchTool(managers) {
45586
45583
  return tool({
45587
- description: "Search HarmonyOS development knowledge across BOTH local skill documents AND official Huawei documentation. Returns two sections: (1) Local Skill Results \u2014 file paths to curated code examples, best practices, and SDK API info from the harmonyos-atomic-dev skill directory; (2) Official Documentation \u2014 search results from developer.huawei.com with titles, URLs, breadcrumbs, and excerpts. Use this tool for any HarmonyOS API, component, Kit, or development pattern lookup. After reviewing results, read local skill files for code patterns and use harmony-doc-view to read full official documents by URL. IMPORTANT: This tool already searches official documentation \u2014 do NOT also call harmony-doc-view for the same purpose. Only use harmony-doc-view to read a specific document page from the URLs listed below. Each scenario only supports ONE tool call. Do NOT call this tool multiple times.",
45584
+ description: "Search HarmonyOS development knowledge across BOTH local skill documents AND official Huawei documentation. Returns two sections: (1) Local Skill Results \u2014 file paths to curated code examples, best practices, and SDK API info from the harmonyos-atomic-dev skill directory; (2) Official Documentation \u2014 search results from developer.huawei.com with titles, URLs, breadcrumbs, and excerpts. Use this tool for any HarmonyOS API, component, Kit, or development pattern lookup. After reviewing results, read local skill files for code patterns and use harmony-doc-view to read full official documents by URL. IMPORTANT: This tool already searches official documentation \u2014 do NOT also call harmony-doc-view for the same purpose. Only use harmony-doc-view to read a specific document page from the URLs listed below. Each scenario only supports ONE tool call. Do NOT call this tool multiple times.\n\nParameters:\n- skill_path: The COMPLETE absolute filesystem path to the harmonyos-atomic-dev skill directory (e.g. '/home/user/.opencode/skills/harmonyos-atomic-dev'). Do NOT pass just the skill name 'harmonyos-atomic-dev' \u2014 you MUST resolve and provide the full absolute path. Do NOT include any prefix like 'file://' or suffix like 'SKILL.md' or 'index.json'.\n- query: A decomposed requirement or intent describing what you want to find, broken down into searchable keywords separated by spaces. QUERY TIPS: For best results, decompose your intent into short space-separated keywords instead of long sentences. Include: 1) Kit or component name (e.g. ScanKit, AdsKit, ShareKit), 2) specific API or method names (e.g. scanBarcode, loadAd, ShareController), 3) feature keywords (e.g. \u626B\u7801, \u5E7F\u544A\u52A0\u8F7D, \u5206\u4EAB). Example: 'ScanKit \u626B\u7801 scanBarcode startScanForResult' instead of '\u5E2E\u6211\u5B9E\u73B0\u4E00\u4E2A\u626B\u7801\u529F\u80FD'.\n- topK: Maximum number of top-ranked documents to return (1-3, default 3). Actual results may be fewer depending on query relevance.",
45588
45585
  args: {
45589
- skill_path: tool.schema.string("Absolute path to the harmonyos-atomic-dev skill directory. IMPORTANT: this path should not contain any prefix or suffix like 'file://' or 'SKILL.md'."),
45590
- query: tool.schema.string("A decomposed requirement or intent describing what you want to find, broken down into searchable keywords separated by spaces. QUERY TIPS: For best results, decompose your intent into short space-separated keywords instead of long sentences. Include: 1) Kit or component name (e.g. ScanKit, AdsKit, ShareKit), 2) specific API or method names (e.g. scanBarcode, loadAd, ShareController), 3) feature keywords (e.g. \u626B\u7801, \u5E7F\u544A\u52A0\u8F7D, \u5206\u4EAB). Example: 'ScanKit \u626B\u7801 scanBarcode startScanForResult' instead of '\u5E2E\u6211\u5B9E\u73B0\u4E00\u4E2A\u626B\u7801\u529F\u80FD'. "),
45591
- topK: tool.schema.number("Maximum number of top-ranked documents to return. Actual results may be fewer depending on query relevance.").min(1).max(3).default(3)
45586
+ skill_path: tool.schema.string(),
45587
+ query: tool.schema.string(),
45588
+ topK: tool.schema.number().min(1).max(3).default(3)
45592
45589
  },
45593
45590
  execute: async (args, context) => {
45594
45591
  const [localResults, docResults] = await Promise.all([
@@ -45697,14 +45694,10 @@ async function resolvePrototypePreview(directory, filePathInput) {
45697
45694
  }
45698
45695
  function htmlPreviewTool(_managers) {
45699
45696
  return tool({
45700
- description: "Send the UX prototype preview to the frontend. Call this immediately after writing prototype.html. You MUST pass filePath with the exact local path of the written file so the frontend can locate and preview it.",
45697
+ description: "Send the UX prototype preview to the frontend. Call this immediately after writing prototype.html. You MUST pass filePath with the exact local path of the written file so the frontend can locate and preview it.\n\nParameters:\n- filePath: Local path to prototype.html. Use the same path from the write step, e.g. prototype.html, /Users/yanqing/coding/your-project/prototype.html, or file:///.../prototype.html.\n- title: (optional) Title shown in the preview panel.",
45701
45698
  args: {
45702
- filePath: tool.schema.string(
45703
- "Local path to prototype.html. Use the same path from the write step, e.g. prototype.html, /Users/yanqing/coding/your-project/prototype.html, or file:///.../prototype.html."
45704
- ),
45705
- title: tool.schema.optional(
45706
- tool.schema.string("Optional title shown in the preview panel")
45707
- )
45699
+ filePath: tool.schema.string(),
45700
+ title: tool.schema.optional(tool.schema.string())
45708
45701
  },
45709
45702
  execute: async (args, context) => {
45710
45703
  try {
@@ -46803,10 +46796,10 @@ function setCache(objectId, doc, markdown, breadcrumb) {
46803
46796
  }
46804
46797
  function harmonyDocViewTool(_managers) {
46805
46798
  return tool({
46806
- description: "View a HarmonyOS official documentation page by URL with full Markdown content and pagination. Use this tool to read official API references, guides, and best practices from developer.huawei.com. Typically used with URLs obtained from skillSearch's Official Documentation results. Supports pagination for long documents \u2014 use the 'page' parameter to continue reading.",
46799
+ description: "View a HarmonyOS official documentation page by URL with full Markdown content and pagination. Use this tool to read official API references, guides, and best practices from developer.huawei.com. Typically used with URLs obtained from skillSearch's Official Documentation results. Supports pagination for long documents \u2014 use the 'page' parameter to continue reading.\n\nParameters:\n- url: Full URL of the document to view. Must be a developer.huawei.com URL, typically from skillSearch results.\n- page: Page number for long documents. Starts at 1. Default is 1.",
46807
46800
  args: {
46808
- url: tool.schema.string("Full URL of the document to view. Must be a developer.huawei.com URL, typically from skillSearch results."),
46809
- page: tool.schema.number("Page number for long documents. Starts at 1.").min(1).default(1)
46801
+ url: tool.schema.string(),
46802
+ page: tool.schema.number().min(1).default(1)
46810
46803
  },
46811
46804
  execute: async (args, _context) => {
46812
46805
  return executeView(args.url, args.page);
@@ -47531,6 +47524,7 @@ function createToolHooks(sessionManager, projectDir) {
47531
47524
  injectAiCodeChange(input, output);
47532
47525
  await injectHtmlPreview(input, output, projectDir);
47533
47526
  await updateEtsCount(sessionManager, projectDir, input);
47527
+ markCompactAfterHtmlPreview(input, sessionManager);
47534
47528
  }
47535
47529
  };
47536
47530
  }
@@ -47620,28 +47614,63 @@ function injectAiCodeChange(input, output) {
47620
47614
  log("aiCodeChange after hook error", { tool: input.tool, error: String(e) });
47621
47615
  }
47622
47616
  }
47617
+ function markCompactAfterHtmlPreview(input, sessionManager) {
47618
+ if (input.tool !== "html_preview") return;
47619
+ const sessionID = input.sessionID;
47620
+ if (!sessionID) return;
47621
+ let session = sessionManager.get(sessionID);
47622
+ if (!session) {
47623
+ session = sessionManager.create(sessionID);
47624
+ }
47625
+ session.data.set("compactAfterPreviewActive", true);
47626
+ log("Activated persistent context compaction after html_preview", { sessionID });
47627
+ }
47623
47628
 
47624
47629
  // src/commands/env-check.ts
47625
47630
  import { execSync } from "child_process";
47626
- function runEnvCheck() {
47627
- const checks = [
47628
- { name: "Java", cmd: "java -version" },
47629
- { name: "Node.js", cmd: "node -v" },
47630
- { name: "ohpm", cmd: "ohpm -v" },
47631
- { name: "hvigorw", cmd: "hvigorw -v" }
47632
- ];
47633
- const lines = [];
47634
- lines.push("HarmonyOS Development Environment Check\uFF1A");
47635
- for (const check3 of checks) {
47631
+ import { readFileSync as readFileSync2, unlinkSync as unlinkSync2 } from "fs";
47632
+ import { join as join7 } from "path";
47633
+ import { tmpdir as tmpdir2 } from "os";
47634
+ function runCmdRaw(cmd) {
47635
+ try {
47636
+ const output = execSync(`${cmd} 2>&1`, { timeout: 1e4, encoding: "utf-8" });
47637
+ return output.split(/\r?\n/)[0]?.trim() || void 0;
47638
+ } catch (err) {
47639
+ const output = (err.stderr?.toString() || err.stdout?.toString() || "").trim();
47640
+ return output.split(/\r?\n/)[0]?.trim() || void 0;
47641
+ }
47642
+ }
47643
+ function runCmdToFile(cmd) {
47644
+ const tmpFile = join7(tmpdir2(), `hm-env-${Date.now()}.txt`);
47645
+ try {
47646
+ execSync(`${cmd} > "${tmpFile}" 2>&1`, { timeout: 1e4 });
47647
+ const content = readFileSync2(tmpFile, "utf-8");
47648
+ return content.split(/\r?\n/)[0]?.trim() || void 0;
47649
+ } catch {
47650
+ return void 0;
47651
+ } finally {
47636
47652
  try {
47637
- const output = execSync(`${check3.cmd} 2>&1`, { timeout: 1e4, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
47638
- const firstLine = output.split(/\r?\n/)[0]?.trim() || "";
47639
- const suffix = check3.name === "Java" ? " (requires >= 17)" : "";
47640
- lines.push(`[${check3.name}] ${firstLine}${suffix}`);
47641
- } catch (err) {
47642
- lines.push(`[${check3.name}] NOT FOUND`);
47653
+ unlinkSync2(tmpFile);
47654
+ } catch {
47643
47655
  }
47644
47656
  }
47657
+ }
47658
+ function runCmd(cmd, { retry = false } = {}) {
47659
+ const result = runCmdRaw(cmd) || runCmdToFile(cmd);
47660
+ if (result || !retry) return result;
47661
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2e3);
47662
+ return runCmdRaw(cmd) || runCmdToFile(cmd);
47663
+ }
47664
+ function runEnvCheck() {
47665
+ const lines = [];
47666
+ lines.push("HarmonyOS Development Environment Check\uFF1A");
47667
+ const java = runCmd("java -version", { retry: true });
47668
+ lines.push(`[Java] ${java ?? "NOT FOUND"}${java ? " (requires >= 17)" : ""}`);
47669
+ lines.push(`[Node.js] ${process.version}`);
47670
+ const ohpm = runCmd("ohpm -v");
47671
+ lines.push(`[ohpm] ${ohpm ?? "NOT FOUND"}`);
47672
+ const hvigorw = runCmd("hvigorw -v") || runCmdToFile("hvigorw -v");
47673
+ lines.push(`[hvigorw] ${hvigorw ?? "NOT FOUND"}`);
47645
47674
  const sdkHome = process.env.DEVECO_SDK_HOME;
47646
47675
  lines.push(`[DEVECO_SDK_HOME] ${sdkHome ?? "NOT SET"}`);
47647
47676
  return lines.join("\n\n");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@harmonyos-arkts/opencode-plugin",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "description": "HarmonyOS Full-Lifecycle Development Assistant. Specialized in the complete development lifecycle of HarmonyOS applications, including project creation, UI development, state management, network requests, data storage, permission requests, performance optimization, testing, and release.",
6
6
  "type": "module",
7
7
  "license": "MIT",