ia_rewrite_ntapp 1.0.7 → 1.0.8

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/index.js +18 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -80,6 +80,21 @@ async function writeClipboard(text) {
80
80
  }
81
81
  }
82
82
 
83
+ async function writeClipboardWithVerify(text, maxWaitMs = 1500) {
84
+ await writeClipboard(text);
85
+ const start = Date.now();
86
+ let current = await readClipboard();
87
+ while (Date.now() - start < maxWaitMs) {
88
+ if (current === text) return true;
89
+ await new Promise((r) => setTimeout(r, 100));
90
+ current = await readClipboard();
91
+ }
92
+ // força fallback se não confirmou
93
+ writeClipboardFallback(text);
94
+ current = await readClipboard();
95
+ return current === text;
96
+ }
97
+
83
98
  function loadConfig() {
84
99
  if (!fs.existsSync(CONFIG_FILE)) return null;
85
100
  const raw = fs.readFileSync(CONFIG_FILE, "utf8").trim();
@@ -136,7 +151,9 @@ async function main() {
136
151
  log("Chamando API...");
137
152
  const rewritten = await callModel(config, original);
138
153
  log(`Resposta recebida. Tamanho: ${rewritten.length}`);
139
- await writeClipboard(rewritten);
154
+ const ok = await writeClipboardWithVerify(rewritten);
155
+ log(`Clipboard gravado: ${ok ? "ok" : "falha"}`);
156
+ await new Promise((r) => setTimeout(r, 150));
140
157
  runVbsSendKeys("^v");
141
158
  notify("ia_rewrite_ntapp", "Texto reescrito e colado com sucesso.");
142
159
  log("Sucesso: texto colado.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ia_rewrite_ntapp",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "CLI para reescrever texto selecionado via IA",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",