@harmonyos-arkts/opencode-plugin 0.0.13 → 0.0.15
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.
- package/dist/index.js +132 -87
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31452,31 +31452,28 @@ import path2 from "path";
|
|
|
31452
31452
|
import fs from "fs/promises";
|
|
31453
31453
|
import os2 from "os";
|
|
31454
31454
|
var paths = envPaths("hm-plugin");
|
|
31455
|
-
var
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31466
|
-
|
|
31467
|
-
state: paths.data
|
|
31468
|
-
};
|
|
31469
|
-
})(HMGlobal || (HMGlobal = {}));
|
|
31455
|
+
var Path = {
|
|
31456
|
+
// Allow override via OPENCODE_TEST_HOME for test isolation
|
|
31457
|
+
get home() {
|
|
31458
|
+
return process.env.OPENCODE_TEST_HOME || os2.homedir();
|
|
31459
|
+
},
|
|
31460
|
+
data: paths.data,
|
|
31461
|
+
bin: path2.join(paths.data, "bin"),
|
|
31462
|
+
log: paths.log,
|
|
31463
|
+
cache: paths.cache,
|
|
31464
|
+
config: paths.config,
|
|
31465
|
+
state: paths.data
|
|
31466
|
+
};
|
|
31470
31467
|
await Promise.all([
|
|
31471
|
-
fs.mkdir(
|
|
31472
|
-
fs.mkdir(
|
|
31473
|
-
fs.mkdir(
|
|
31474
|
-
fs.mkdir(
|
|
31475
|
-
fs.mkdir(
|
|
31468
|
+
fs.mkdir(Path.data, { recursive: true }),
|
|
31469
|
+
fs.mkdir(Path.config, { recursive: true }),
|
|
31470
|
+
fs.mkdir(Path.state, { recursive: true }),
|
|
31471
|
+
fs.mkdir(Path.log, { recursive: true }),
|
|
31472
|
+
fs.mkdir(Path.bin, { recursive: true })
|
|
31476
31473
|
]);
|
|
31477
31474
|
|
|
31478
31475
|
// src/shared/log.ts
|
|
31479
|
-
var logFile = path3.join(
|
|
31476
|
+
var logFile = path3.join(Path.log, "plugin.log");
|
|
31480
31477
|
var logDir = path3.dirname(logFile);
|
|
31481
31478
|
var MAX_LOG_SIZE_BYTES = 5 * 1024 * 1024;
|
|
31482
31479
|
var MAX_LOG_AGE_DAYS = 7;
|
|
@@ -31568,7 +31565,7 @@ cleanupRotatedLogs();
|
|
|
31568
31565
|
|
|
31569
31566
|
// src/agents/prompt.ts
|
|
31570
31567
|
var HM_DESIGN = `
|
|
31571
|
-
###
|
|
31568
|
+
### Design Phase
|
|
31572
31569
|
- Use the \`harmonyos-prd-design\` skill to create prd desgin documents
|
|
31573
31570
|
- Reference design patterns and best practices from the skill documentation
|
|
31574
31571
|
- Design documents should be stored in the project's \`.harmonyos/\` directory
|
|
@@ -31603,11 +31600,57 @@ var HM_BUILD = `
|
|
|
31603
31600
|
5. If still failing after 3 attempts, report the remaining errors to the user and ask for guidance
|
|
31604
31601
|
- Only after a successful build should the development cycle be considered complete
|
|
31605
31602
|
`;
|
|
31606
|
-
var
|
|
31607
|
-
|
|
31608
|
-
|
|
31609
|
-
-
|
|
31610
|
-
|
|
31603
|
+
var HM_MULTI_DEVICE = `
|
|
31604
|
+
## Role
|
|
31605
|
+
|
|
31606
|
+
You are an expert in HarmonyOS "Deploy Once, Run Everywhere" (\u4E00\u591A) multi-device adaptation. Your job is to help developers adapt phone-first ArkTS applications to work correctly across phones, tablets, foldables, and PCs \u2014 and to diagnose and fix adaptation-related bugs in existing code.
|
|
31607
|
+
|
|
31608
|
+
You are **not** a general HarmonyOS assistant. Decline requests outside your domain (e.g., backend services, non-UI logic, Ability lifecycle unrelated to window management) and suggest the developer seek a broader assistant for those.
|
|
31609
|
+
|
|
31610
|
+
---
|
|
31611
|
+
|
|
31612
|
+
## Execution Workflow
|
|
31613
|
+
|
|
31614
|
+
At the start of every task, load and follow:
|
|
31615
|
+
|
|
31616
|
+
\`\`\`
|
|
31617
|
+
harmonyos-multi-device-adaptation/harmonyos-adaptation-workflow/SKILL.md
|
|
31618
|
+
\`\`\`
|
|
31619
|
+
|
|
31620
|
+
That skill defines the full execution flow for both new adaptation (Path A) and bug fixing (Path B), including project scanning, domain routing, build verification, and the mandatory implementation checklist. Do not proceed without loading it.
|
|
31621
|
+
|
|
31622
|
+
---
|
|
31623
|
+
|
|
31624
|
+
## Skill Files
|
|
31625
|
+
|
|
31626
|
+
Domain knowledge lives in skill files under \`harmonyos-multi-device-adaptation/\`. Each file's **Agent Interface** section contains:
|
|
31627
|
+
|
|
31628
|
+
- \`symptom_keywords\` \u2014 match against user-reported symptoms to identify the relevant domain
|
|
31629
|
+
- \`hard_constraints\` \u2014 verify every item before generating any code for that domain
|
|
31630
|
+
- \`diagnostic_checklist\` \u2014 walk through item-by-item when diagnosing a bug
|
|
31631
|
+
|
|
31632
|
+
When a new skill is added to the folder, it is automatically available \u2014 no changes to this prompt are needed.
|
|
31633
|
+
|
|
31634
|
+
---
|
|
31635
|
+
|
|
31636
|
+
## Universal Hard Constraints
|
|
31637
|
+
|
|
31638
|
+
These rules apply across all domains and all phases. Never deviate.
|
|
31639
|
+
|
|
31640
|
+
1. **ArkTS only.** Never output Java, JavaScript, or Kotlin.
|
|
31641
|
+
2. **No invented APIs.** If you are not certain an API exists, say so explicitly rather than guessing.
|
|
31642
|
+
3. **Window object.** Always obtain the window via \`AppStorage.get<window.WindowStage>('windowStage')!.getMainWindowSync()\`. Never use \`window.getLastWindow()\`.
|
|
31643
|
+
4. **avoidAreaChange callback.** Always read \`opts.area\` directly. Never call \`getWindowAvoidArea()\` inside the callback.
|
|
31644
|
+
|
|
31645
|
+
---
|
|
31646
|
+
|
|
31647
|
+
## Output Format
|
|
31648
|
+
|
|
31649
|
+
- **Lead with domain identification** \u2014 always name the domain(s) before proposing code.
|
|
31650
|
+
- **Use \u274C/\u2705 comparisons** for all code changes, with a one-line reason for each change.
|
|
31651
|
+
- **If uncertain about an API**, say: *"I'm not certain this API exists at the required level \u2014 please verify in the official HarmonyOS documentation."*
|
|
31652
|
+
- **If a request is outside your domains**, say: *"This falls outside multi-device adaptation. You may want to consult a general HarmonyOS assistant for this."*
|
|
31653
|
+
- **Never output a wall of code** without explaining what changed and why.
|
|
31611
31654
|
`;
|
|
31612
31655
|
var HM_PLAN = `
|
|
31613
31656
|
### Plan Phase
|
|
@@ -31723,8 +31766,8 @@ function buildPlanPrompt(type) {
|
|
|
31723
31766
|
return HM_DESIGN;
|
|
31724
31767
|
case "build":
|
|
31725
31768
|
return HM_BUILD;
|
|
31726
|
-
case "
|
|
31727
|
-
return
|
|
31769
|
+
case "multi-device":
|
|
31770
|
+
return HM_MULTI_DEVICE;
|
|
31728
31771
|
case "plan":
|
|
31729
31772
|
return HM_PLAN;
|
|
31730
31773
|
case "all":
|
|
@@ -31734,33 +31777,29 @@ function buildPlanPrompt(type) {
|
|
|
31734
31777
|
}
|
|
31735
31778
|
}
|
|
31736
31779
|
function buildAllAgentPrompt() {
|
|
31737
|
-
return
|
|
31780
|
+
return `- **New project (greenfield)**: Design \u2192 Development \u2192 Build. Do not skip the design phase, as it is critical for planning and architectural decisions.
|
|
31781
|
+
- **Complex tasks**: List a plan \u2192 Discuss plan details with the user if needed \u2192 Development \u2192 Build.
|
|
31782
|
+
- **Simple tasks**: Development \u2192 Build directly.
|
|
31783
|
+
|
|
31784
|
+
Each phase has its own set of best practices and workflows to ensure efficient and successful project completion.
|
|
31785
|
+
|
|
31738
31786
|
${HM_DESIGN}
|
|
31739
31787
|
${HM_DEVELOP}
|
|
31740
31788
|
${HM_BUILD}
|
|
31741
|
-
|
|
31742
|
-
Follow these workflows:
|
|
31743
|
-
- **New project (greenfield)**: PRD Design \u2192 Development \u2192 Build.
|
|
31744
|
-
- **Complex tasks**: List a plan \u2192 Discuss plan details with the user if needed \u2192 Development \u2192 Build.
|
|
31745
|
-
- **Simple tasks**: Development \u2192 Build directly.
|
|
31746
31789
|
`;
|
|
31747
31790
|
}
|
|
31748
31791
|
function buildHmAgentPrompt(type) {
|
|
31749
31792
|
return `You are HarmonyOS Dev Assistant(HDACode), an expert coding agent specialized in HarmonyOS development.
|
|
31750
|
-
|
|
31751
31793
|
You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
31752
|
-
|
|
31753
31794
|
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
31754
|
-
|
|
31755
31795
|
When the user directly asks about HDACode (eg. "can HDACode do...", "does HDACode have..."), or asks in second person (eg. "are you able...", "can you do..."), or asks how to use a specific HDACode feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from HDACode docs.
|
|
31756
|
-
|
|
31757
31796
|
**IMPORTANT**: All HarmonyOS development tasks must follow these workflows:
|
|
31758
31797
|
|
|
31759
31798
|
${buildPlanPrompt(type)}
|
|
31760
31799
|
|
|
31761
31800
|
# Tone and style
|
|
31762
31801
|
- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
|
|
31763
|
-
-
|
|
31802
|
+
- You MUST reply in Chinese (\u7B80\u4F53\u4E2D\u6587) at all times; code, technical identifiers, and file paths are excluded from this rule.
|
|
31764
31803
|
- Your output will be displayed on a command line interface. You can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
31765
31804
|
- Keep your responses brief and direct. Lead with the answer or action, not the reasoning. Skip preamble and postamble (e.g., "The answer is...", "Based on the information provided..."). Only elaborate when the user asks for detail.
|
|
31766
31805
|
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
|
|
@@ -31797,24 +31836,6 @@ The first item has been fixed, let me mark the first todo as completed, and move
|
|
|
31797
31836
|
</example>
|
|
31798
31837
|
In the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.
|
|
31799
31838
|
|
|
31800
|
-
<example>
|
|
31801
|
-
user: Help me write a new feature that allows users to track their usage metrics and export them to various formats
|
|
31802
|
-
assistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task.
|
|
31803
|
-
Adding the following todos to the todo list:
|
|
31804
|
-
1. Research existing metrics tracking in the codebase
|
|
31805
|
-
2. Design the metrics collection system
|
|
31806
|
-
3. Implement core metrics tracking functionality
|
|
31807
|
-
4. Create export functionality for different formats
|
|
31808
|
-
|
|
31809
|
-
Let me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.
|
|
31810
|
-
|
|
31811
|
-
I'm going to search for any existing metrics or telemetry code in the project.
|
|
31812
|
-
|
|
31813
|
-
I've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...
|
|
31814
|
-
|
|
31815
|
-
[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]
|
|
31816
|
-
</example>
|
|
31817
|
-
|
|
31818
31839
|
|
|
31819
31840
|
# Doing tasks
|
|
31820
31841
|
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
@@ -31891,6 +31912,13 @@ function createHmAgent() {
|
|
|
31891
31912
|
doom_loop: "ask",
|
|
31892
31913
|
external_directory: {
|
|
31893
31914
|
"*": "ask"
|
|
31915
|
+
},
|
|
31916
|
+
"skillSearch": "allow",
|
|
31917
|
+
skill: {
|
|
31918
|
+
"*": "deny",
|
|
31919
|
+
"harmonyos-atomic-dev": "allow",
|
|
31920
|
+
"harmonyos-hvigor": "allow",
|
|
31921
|
+
"harmonyos-prd-design": "allow"
|
|
31894
31922
|
}
|
|
31895
31923
|
},
|
|
31896
31924
|
metadata: void 0
|
|
@@ -31939,30 +31967,34 @@ function createHmDevelopmentAgent() {
|
|
|
31939
31967
|
prompt: buildHmAgentPrompt("dev"),
|
|
31940
31968
|
temperature: 0.3,
|
|
31941
31969
|
permission: {
|
|
31942
|
-
"skillSearch": "allow"
|
|
31970
|
+
"skillSearch": "allow",
|
|
31971
|
+
skill: {
|
|
31972
|
+
"*": "deny",
|
|
31973
|
+
"harmonyos-atomic-dev": "allow",
|
|
31974
|
+
"harmonyos-hvigor": "allow",
|
|
31975
|
+
"harmonyos-prd-design": "allow"
|
|
31976
|
+
}
|
|
31943
31977
|
},
|
|
31944
31978
|
metadata: void 0
|
|
31945
31979
|
};
|
|
31946
31980
|
return agent;
|
|
31947
31981
|
}
|
|
31948
31982
|
|
|
31949
|
-
// src/agents/
|
|
31950
|
-
function
|
|
31983
|
+
// src/agents/multi-device-agent.ts
|
|
31984
|
+
function getHmMultiDeviceDescription() {
|
|
31951
31985
|
return `
|
|
31952
31986
|
HarmonyOS One-to-Many Adaptation \u2014 adapts applications for multiple device types (phone, tablet, foldable, 2-in-1, wearable, TV)
|
|
31953
31987
|
`;
|
|
31954
31988
|
}
|
|
31955
|
-
function
|
|
31989
|
+
function createMultiDeviceAgent() {
|
|
31956
31990
|
const agent = {
|
|
31957
|
-
id: "harmonyos-
|
|
31958
|
-
name: "harmonyos-
|
|
31959
|
-
description:
|
|
31991
|
+
id: "harmonyos-multi-device",
|
|
31992
|
+
name: "harmonyos-multi-device",
|
|
31993
|
+
description: getHmMultiDeviceDescription(),
|
|
31960
31994
|
mode: "primary",
|
|
31961
|
-
prompt: buildHmAgentPrompt("
|
|
31995
|
+
prompt: buildHmAgentPrompt("multi-device"),
|
|
31962
31996
|
temperature: 0.3,
|
|
31963
|
-
permission: {
|
|
31964
|
-
"skillSearch": "deny"
|
|
31965
|
-
},
|
|
31997
|
+
permission: {},
|
|
31966
31998
|
metadata: void 0
|
|
31967
31999
|
};
|
|
31968
32000
|
return agent;
|
|
@@ -31975,7 +32007,7 @@ var AgentRegistry = class {
|
|
|
31975
32007
|
this.register(createHmAgent());
|
|
31976
32008
|
this.register(createDesignAgent());
|
|
31977
32009
|
this.register(createHmDevelopmentAgent());
|
|
31978
|
-
this.register(
|
|
32010
|
+
this.register(createMultiDeviceAgent());
|
|
31979
32011
|
}
|
|
31980
32012
|
register(agent) {
|
|
31981
32013
|
this.agents.set(agent.id, agent);
|
|
@@ -44631,7 +44663,7 @@ function tool(input) {
|
|
|
44631
44663
|
tool.schema = external_exports2;
|
|
44632
44664
|
|
|
44633
44665
|
// src/tools/create-template/download-template.ts
|
|
44634
|
-
import { cpSync,
|
|
44666
|
+
import { cpSync, existsSync } from "fs";
|
|
44635
44667
|
import path6 from "path";
|
|
44636
44668
|
import { fileURLToPath } from "url";
|
|
44637
44669
|
|
|
@@ -44721,7 +44753,9 @@ async function downloadTemplate(mode, filePath) {
|
|
|
44721
44753
|
}
|
|
44722
44754
|
const targetDir = path6.resolve(filePath);
|
|
44723
44755
|
const templateDir = path6.join(__dirname, "templates", templateType);
|
|
44724
|
-
|
|
44756
|
+
if (!existsSync(targetDir)) {
|
|
44757
|
+
throw new Error(`Directory does not exist: ${targetDir}. Please create it first.`);
|
|
44758
|
+
}
|
|
44725
44759
|
cpSync(templateDir, targetDir, { recursive: true });
|
|
44726
44760
|
const sdkInfo = getSdkVersion();
|
|
44727
44761
|
if (sdkInfo) {
|
|
@@ -44836,15 +44870,15 @@ async function updateEtsCache(sessionManager, sessionID, directory) {
|
|
|
44836
44870
|
var CHECK_ETS_TEMPLATE_MODES = /* @__PURE__ */ new Set(["atomic", "application"]);
|
|
44837
44871
|
function createHmTemplateTool(managers) {
|
|
44838
44872
|
return tool({
|
|
44839
|
-
description: "Create an empty HarmonyOS project template. Supports three modes: 'application' (full app), 'module' (sub-module), 'atomic' (atomic service).
|
|
44873
|
+
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.",
|
|
44840
44874
|
args: {
|
|
44841
|
-
filePath: tool.schema.string("Absolute path of the target directory where the template will be created"),
|
|
44875
|
+
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."),
|
|
44842
44876
|
mode: tool.schema.string("Template type: 'application' (\u5E94\u7528), 'module' (\u6A21\u5757), or 'atomic' (\u5143\u670D\u52A1)")
|
|
44843
44877
|
},
|
|
44844
44878
|
execute: async (args, context) => {
|
|
44845
44879
|
try {
|
|
44846
44880
|
if (CHECK_ETS_TEMPLATE_MODES.has(args.mode)) {
|
|
44847
|
-
const fileCount = await checkEtsExists(
|
|
44881
|
+
const fileCount = await checkEtsExists(args.filePath);
|
|
44848
44882
|
if (fileCount > 0) {
|
|
44849
44883
|
log("[createHmTemplate] skipped, ets files exist", { fileCount });
|
|
44850
44884
|
return `Skipped: Current directory already contains ${fileCount} .ets file(s). Template download is not needed.`;
|
|
@@ -44861,7 +44895,7 @@ function createHmTemplateTool(managers) {
|
|
|
44861
44895
|
}
|
|
44862
44896
|
|
|
44863
44897
|
// src/tools/skill-search/search-skill.ts
|
|
44864
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
44898
|
+
import { readFileSync, existsSync as existsSync2 } from "node:fs";
|
|
44865
44899
|
import { join as join4 } from "node:path";
|
|
44866
44900
|
|
|
44867
44901
|
// src/tools/skill-search/tokenizer.ts
|
|
@@ -44896,7 +44930,10 @@ function tokenize(text) {
|
|
|
44896
44930
|
var BM25Retriever = class {
|
|
44897
44931
|
k1;
|
|
44898
44932
|
b;
|
|
44899
|
-
|
|
44933
|
+
_documents = [];
|
|
44934
|
+
get documents() {
|
|
44935
|
+
return this._documents;
|
|
44936
|
+
}
|
|
44900
44937
|
tokenizedDocs = [];
|
|
44901
44938
|
df = /* @__PURE__ */ new Map();
|
|
44902
44939
|
tfMaps = [];
|
|
@@ -44906,7 +44943,7 @@ var BM25Retriever = class {
|
|
|
44906
44943
|
this.b = opts?.b ?? 0.75;
|
|
44907
44944
|
}
|
|
44908
44945
|
addDocuments(docs, tokenized) {
|
|
44909
|
-
this.
|
|
44946
|
+
this._documents = [...this._documents, ...docs];
|
|
44910
44947
|
this.tokenizedDocs = [...this.tokenizedDocs, ...tokenized];
|
|
44911
44948
|
const totalLen = this.tokenizedDocs.reduce(
|
|
44912
44949
|
(sum, doc) => sum + doc.length,
|
|
@@ -44991,12 +45028,12 @@ var HybridRetriever = class {
|
|
|
44991
45028
|
this.keyword.addDocuments(docs, tokenized);
|
|
44992
45029
|
}
|
|
44993
45030
|
search(query, topK = 5) {
|
|
44994
|
-
if (this.bm25
|
|
45031
|
+
if (this.bm25.documents.length === 0) return [];
|
|
44995
45032
|
const poolSize = topK * 3;
|
|
44996
45033
|
const bm25Results = this.bm25.search(query, poolSize);
|
|
44997
45034
|
const keywordResults = this.keyword.search(query, poolSize);
|
|
44998
45035
|
const rrfK = 60;
|
|
44999
|
-
const documents = this.bm25
|
|
45036
|
+
const documents = this.bm25.documents;
|
|
45000
45037
|
const scores = /* @__PURE__ */ new Map();
|
|
45001
45038
|
for (let rank = 0; rank < bm25Results.length; rank++) {
|
|
45002
45039
|
const idx = bm25Results[rank].index;
|
|
@@ -45227,7 +45264,7 @@ async function loadAndCache(resolvedPath) {
|
|
|
45227
45264
|
log("start load sdk cache", sdk_path);
|
|
45228
45265
|
if (sdk_path !== void 0) {
|
|
45229
45266
|
const sdkIndexPath = join4(import.meta.dirname, "sdk-index.json");
|
|
45230
|
-
if (!
|
|
45267
|
+
if (!existsSync2(sdkIndexPath)) {
|
|
45231
45268
|
log("sdk path is not exist, need to build");
|
|
45232
45269
|
await buildSDKIndex(sdk_path);
|
|
45233
45270
|
}
|
|
@@ -45254,7 +45291,7 @@ async function loadAndCache(resolvedPath) {
|
|
|
45254
45291
|
function loadSdkIndex() {
|
|
45255
45292
|
if (cachedSdkRetriever) return true;
|
|
45256
45293
|
const sdkIndexPath = join4(import.meta.dirname, "sdk-index.json");
|
|
45257
|
-
if (!
|
|
45294
|
+
if (!existsSync2(sdkIndexPath)) return false;
|
|
45258
45295
|
try {
|
|
45259
45296
|
const raw = readFileSync(sdkIndexPath, "utf-8");
|
|
45260
45297
|
const entries = JSON.parse(raw);
|
|
@@ -45286,7 +45323,8 @@ async function searchSkill(skill_path, query, topK = 3) {
|
|
|
45286
45323
|
preFiltered.push({
|
|
45287
45324
|
ets_file_path: "",
|
|
45288
45325
|
experience_file_path: join4(prefix, entry.path),
|
|
45289
|
-
sdk_file_path: ""
|
|
45326
|
+
sdk_file_path: "",
|
|
45327
|
+
score: 0
|
|
45290
45328
|
});
|
|
45291
45329
|
query = (query.slice(0, idx) + query.slice(idx + category.length)).trim();
|
|
45292
45330
|
}
|
|
@@ -45298,7 +45336,8 @@ async function searchSkill(skill_path, query, topK = 3) {
|
|
|
45298
45336
|
const sdkResults = loadSdkIndex() ? cachedSdkRetriever.search(query, topK).filter((r) => r.score >= MIN_SCORE).map((r) => ({
|
|
45299
45337
|
ets_file_path: "",
|
|
45300
45338
|
experience_file_path: "",
|
|
45301
|
-
sdk_file_path: cachedSdkEntries[r.index].path
|
|
45339
|
+
sdk_file_path: cachedSdkEntries[r.index].path,
|
|
45340
|
+
score: r.score
|
|
45302
45341
|
})) : [];
|
|
45303
45342
|
const searchResults = cachedRetriever.search(query, topK);
|
|
45304
45343
|
const filtered = searchResults.filter((r) => r.score >= MIN_SCORE);
|
|
@@ -45314,6 +45353,9 @@ function aggregateByExperience(results) {
|
|
|
45314
45353
|
if (r.ets_file_path) {
|
|
45315
45354
|
existing.ets_file_path = existing.ets_file_path ? existing.ets_file_path + "\n" + r.ets_file_path : r.ets_file_path;
|
|
45316
45355
|
}
|
|
45356
|
+
if (r.score > existing.score) {
|
|
45357
|
+
existing.score = r.score;
|
|
45358
|
+
}
|
|
45317
45359
|
} else {
|
|
45318
45360
|
map3.set(key, { ...r });
|
|
45319
45361
|
}
|
|
@@ -45329,7 +45371,8 @@ function convert_search_result(searchResults, prefix) {
|
|
|
45329
45371
|
return {
|
|
45330
45372
|
ets_file_path: join4(prefix, entry.path),
|
|
45331
45373
|
experience_file_path: experience?.path ? join4(prefix, experience.path) : "",
|
|
45332
|
-
sdk_file_path: ""
|
|
45374
|
+
sdk_file_path: "",
|
|
45375
|
+
score: result.score
|
|
45333
45376
|
};
|
|
45334
45377
|
});
|
|
45335
45378
|
}
|
|
@@ -45564,6 +45607,7 @@ ${localResults.message}`);
|
|
|
45564
45607
|
} else {
|
|
45565
45608
|
const localInfo = localResults.map((r) => {
|
|
45566
45609
|
const lines = [];
|
|
45610
|
+
lines.push(`score ${r.score.toFixed(4)}`);
|
|
45567
45611
|
if (r.experience_file_path) lines.push(`- experience path: ${r.experience_file_path}`);
|
|
45568
45612
|
if (r.ets_file_path) lines.push(`- sample code path: ${r.ets_file_path}`);
|
|
45569
45613
|
if (r.sdk_file_path) lines.push(`- sdk info path: ${r.sdk_file_path}`);
|
|
@@ -47590,7 +47634,8 @@ function runEnvCheck() {
|
|
|
47590
47634
|
try {
|
|
47591
47635
|
const output = execSync(`${check3.cmd} 2>&1`, { timeout: 1e4, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
47592
47636
|
const firstLine = output.split(/\r?\n/)[0]?.trim() || "";
|
|
47593
|
-
|
|
47637
|
+
const suffix = check3.name === "Java" ? " (requires >= 17)" : "";
|
|
47638
|
+
lines.push(`[${check3.name}] ${firstLine}${suffix}`);
|
|
47594
47639
|
} catch (err) {
|
|
47595
47640
|
lines.push(`[${check3.name}] NOT FOUND`);
|
|
47596
47641
|
}
|
|
@@ -47677,7 +47722,7 @@ function createHooks(args) {
|
|
|
47677
47722
|
["tool.execute.before", () => toolHooks["tool.execute.before"]],
|
|
47678
47723
|
["tool.execute.after", () => toolHooks["tool.execute.after"]],
|
|
47679
47724
|
["command.execute.before", () => commandHooks["command.execute.before"]],
|
|
47680
|
-
["event", () => sessionHooks
|
|
47725
|
+
["event", () => sessionHooks.event],
|
|
47681
47726
|
["chat.params", () => createChatParamsHandler(config3)],
|
|
47682
47727
|
["chat.message", () => createChatMessageHandler(ctx, managers)]
|
|
47683
47728
|
];
|
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.
|
|
4
|
+
"version": "0.0.15",
|
|
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",
|