@harmonyos-arkts/opencode-plugin 0.0.17 → 0.0.19

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 +61 -30
  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: {
@@ -44874,8 +44871,8 @@ function createHmTemplateTool(managers) {
44874
44871
  return tool({
44875
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.",
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().describe("Absolute path of the target directory where the template will be created. Defaults to the current working directory if not specified."),
44875
+ mode: tool.schema.string().describe("Template type: 'application' (\u5E94\u7528), 'module' (\u6A21\u5757), or 'atomic' (\u5143\u670D\u52A1)")
44879
44876
  },
44880
44877
  execute: async (args, context) => {
44881
44878
  try {
@@ -45586,9 +45583,9 @@ function skillSearchTool(managers) {
45586
45583
  return tool({
45587
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.",
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().describe("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'."),
45587
+ query: tool.schema.string().describe("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'."),
45588
+ topK: tool.schema.number().describe("Maximum number of top-ranked documents to return. Actual results may be fewer depending on query relevance.").min(1).max(3).default(3)
45592
45589
  },
45593
45590
  execute: async (args, context) => {
45594
45591
  const [localResults, docResults] = await Promise.all([
@@ -45699,11 +45696,9 @@ function htmlPreviewTool(_managers) {
45699
45696
  return tool({
45700
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.",
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
- ),
45699
+ filePath: tool.schema.string().describe("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."),
45705
45700
  title: tool.schema.optional(
45706
- tool.schema.string("Optional title shown in the preview panel")
45701
+ tool.schema.string().describe("Optional title shown in the preview panel")
45707
45702
  )
45708
45703
  },
45709
45704
  execute: async (args, context) => {
@@ -46805,8 +46800,8 @@ function harmonyDocViewTool(_managers) {
46805
46800
  return tool({
46806
46801
  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.",
46807
46802
  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)
46803
+ url: tool.schema.string().describe("Full URL of the document to view. Must be a developer.huawei.com URL, typically from skillSearch results."),
46804
+ page: tool.schema.number().describe("Page number for long documents. Starts at 1.").min(1).default(1)
46810
46805
  },
46811
46806
  execute: async (args, _context) => {
46812
46807
  return executeView(args.url, args.page);
@@ -47531,6 +47526,7 @@ function createToolHooks(sessionManager, projectDir) {
47531
47526
  injectAiCodeChange(input, output);
47532
47527
  await injectHtmlPreview(input, output, projectDir);
47533
47528
  await updateEtsCount(sessionManager, projectDir, input);
47529
+ markCompactAfterHtmlPreview(input, sessionManager);
47534
47530
  }
47535
47531
  };
47536
47532
  }
@@ -47620,28 +47616,63 @@ function injectAiCodeChange(input, output) {
47620
47616
  log("aiCodeChange after hook error", { tool: input.tool, error: String(e) });
47621
47617
  }
47622
47618
  }
47619
+ function markCompactAfterHtmlPreview(input, sessionManager) {
47620
+ if (input.tool !== "html_preview") return;
47621
+ const sessionID = input.sessionID;
47622
+ if (!sessionID) return;
47623
+ let session = sessionManager.get(sessionID);
47624
+ if (!session) {
47625
+ session = sessionManager.create(sessionID);
47626
+ }
47627
+ session.data.set("compactAfterPreviewActive", true);
47628
+ log("Activated persistent context compaction after html_preview", { sessionID });
47629
+ }
47623
47630
 
47624
47631
  // src/commands/env-check.ts
47625
47632
  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) {
47633
+ import { readFileSync as readFileSync2, unlinkSync as unlinkSync2 } from "fs";
47634
+ import { join as join7 } from "path";
47635
+ import { tmpdir as tmpdir2 } from "os";
47636
+ function runCmdRaw(cmd) {
47637
+ try {
47638
+ const output = execSync(`${cmd} 2>&1`, { timeout: 1e4, encoding: "utf-8" });
47639
+ return output.split(/\r?\n/)[0]?.trim() || void 0;
47640
+ } catch (err) {
47641
+ const output = (err.stderr?.toString() || err.stdout?.toString() || "").trim();
47642
+ return output.split(/\r?\n/)[0]?.trim() || void 0;
47643
+ }
47644
+ }
47645
+ function runCmdToFile(cmd) {
47646
+ const tmpFile = join7(tmpdir2(), `hm-env-${Date.now()}.txt`);
47647
+ try {
47648
+ execSync(`${cmd} > "${tmpFile}" 2>&1`, { timeout: 1e4 });
47649
+ const content = readFileSync2(tmpFile, "utf-8");
47650
+ return content.split(/\r?\n/)[0]?.trim() || void 0;
47651
+ } catch {
47652
+ return void 0;
47653
+ } finally {
47636
47654
  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`);
47655
+ unlinkSync2(tmpFile);
47656
+ } catch {
47643
47657
  }
47644
47658
  }
47659
+ }
47660
+ function runCmd(cmd, { retry = false } = {}) {
47661
+ const result = runCmdRaw(cmd) || runCmdToFile(cmd);
47662
+ if (result || !retry) return result;
47663
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2e3);
47664
+ return runCmdRaw(cmd) || runCmdToFile(cmd);
47665
+ }
47666
+ function runEnvCheck() {
47667
+ const lines = [];
47668
+ lines.push("HarmonyOS Development Environment Check\uFF1A");
47669
+ const java = runCmd("java -version", { retry: true });
47670
+ lines.push(`[Java] ${java ?? "NOT FOUND"}${java ? " (requires >= 17)" : ""}`);
47671
+ lines.push(`[Node.js] ${process.version}`);
47672
+ const ohpm = runCmd("ohpm -v");
47673
+ lines.push(`[ohpm] ${ohpm ?? "NOT FOUND"}`);
47674
+ const hvigorw = runCmd("hvigorw -v") || runCmdToFile("hvigorw -v");
47675
+ lines.push(`[hvigorw] ${hvigorw ?? "NOT FOUND"}`);
47645
47676
  const sdkHome = process.env.DEVECO_SDK_HOME;
47646
47677
  lines.push(`[DEVECO_SDK_HOME] ${sdkHome ?? "NOT SET"}`);
47647
47678
  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.17",
4
+ "version": "0.0.19",
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",