@harmonyos-arkts/opencode-plugin 0.0.8 → 0.0.9

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 +54 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14814,16 +14814,67 @@ await Promise.all([
14814
14814
 
14815
14815
  // src/shared/log.ts
14816
14816
  var logFile = path3.join(HMGlobal.Path.log, "plugin.log");
14817
+ var logDir = path3.dirname(logFile);
14818
+ var MAX_LOG_SIZE_BYTES = 5 * 1024 * 1024;
14819
+ var MAX_LOG_AGE_DAYS = 7;
14820
+ var MAX_ROTATED_FILES = 5;
14817
14821
  var buffer = [];
14818
14822
  var flushTimer = null;
14819
14823
  var FLUSH_INTERVAL_MS = 500;
14820
14824
  var BUFFER_SIZE_LIMIT = 50;
14825
+ function cleanupRotatedLogs() {
14826
+ try {
14827
+ const entries = fs2.readdirSync(logDir);
14828
+ const rotated = entries.filter((f) => f.startsWith("plugin.") && f.endsWith(".log") && f !== "plugin.log").map((f) => {
14829
+ const full = path3.join(logDir, f);
14830
+ try {
14831
+ return { file: full, mtimeMs: fs2.statSync(full).mtimeMs };
14832
+ } catch {
14833
+ return null;
14834
+ }
14835
+ }).filter((e) => e !== null);
14836
+ const now = Date.now();
14837
+ const maxAgeMs = MAX_LOG_AGE_DAYS * 24 * 60 * 60 * 1e3;
14838
+ for (const entry of rotated) {
14839
+ if (now - entry.mtimeMs > maxAgeMs) {
14840
+ try {
14841
+ fs2.unlinkSync(entry.file);
14842
+ } catch {
14843
+ }
14844
+ }
14845
+ }
14846
+ const surviving = rotated.filter((e) => now - e.mtimeMs <= maxAgeMs).sort((a, b) => a.mtimeMs - b.mtimeMs);
14847
+ if (surviving.length > MAX_ROTATED_FILES) {
14848
+ const doomed = surviving.slice(0, surviving.length - MAX_ROTATED_FILES);
14849
+ for (const entry of doomed) {
14850
+ try {
14851
+ fs2.unlinkSync(entry.file);
14852
+ } catch {
14853
+ }
14854
+ }
14855
+ }
14856
+ } catch {
14857
+ }
14858
+ }
14859
+ function rotateIfNeeded() {
14860
+ try {
14861
+ const stat3 = fs2.statSync(logFile);
14862
+ if (stat3.size >= MAX_LOG_SIZE_BYTES) {
14863
+ const now = /* @__PURE__ */ new Date();
14864
+ const pad = (n) => String(n).padStart(2, "0");
14865
+ const ts = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
14866
+ fs2.renameSync(logFile, path3.join(logDir, `plugin.${ts}.log`));
14867
+ }
14868
+ } catch {
14869
+ }
14870
+ }
14821
14871
  function flush() {
14822
14872
  if (buffer.length === 0) return;
14823
14873
  const data = buffer.join("");
14824
14874
  buffer = [];
14825
14875
  try {
14826
14876
  fs2.appendFileSync(logFile, data);
14877
+ rotateIfNeeded();
14827
14878
  } catch {
14828
14879
  }
14829
14880
  }
@@ -14850,6 +14901,7 @@ function log(message, data) {
14850
14901
  } catch {
14851
14902
  }
14852
14903
  }
14904
+ cleanupRotatedLogs();
14853
14905
 
14854
14906
  // src/agents/prompt.ts
14855
14907
  var HM_DESIGN = `
@@ -28330,7 +28382,7 @@ var filter_default = [
28330
28382
 
28331
28383
  // src/tools/skill-search/build-sdk-index.ts
28332
28384
  import { readdir as readdir2, readFile as readFile3, writeFile } from "node:fs/promises";
28333
- import { join as join3, relative, basename, dirname } from "node:path";
28385
+ import { join as join3, relative, basename, dirname as dirname2 } from "node:path";
28334
28386
  var SCAN_DIRS = [
28335
28387
  "openharmony/js/api",
28336
28388
  "openharmony/ets/api",
@@ -28362,7 +28414,7 @@ function extractSummary(content, filename, relPath) {
28362
28414
  if (rawName.startsWith("@")) {
28363
28415
  moduleName = rawName.replace(/^@/, "");
28364
28416
  } else {
28365
- const dirParts = dirname(relPath).split("/").filter(Boolean);
28417
+ const dirParts = dirname2(relPath).split("/").filter(Boolean);
28366
28418
  moduleName = [...dirParts, rawName].join(".");
28367
28419
  }
28368
28420
  const symbols = [];
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.8",
4
+ "version": "0.0.9",
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",