@lazyingart/agintiflow 0.20.70 → 0.20.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.70",
3
+ "version": "0.20.71",
4
4
  "type": "module",
5
5
  "description": "Low-cost, project-aware Web and CLI agents with DeepSeek/Venice/OpenAI routing, visible tool calls, durable sessions, scouts, AAPS, SCS, and guarded local execution.",
6
6
  "license": "Apache-2.0",
@@ -24,6 +24,44 @@ const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "agintiflow-cli-chat-")
24
24
  const agintiflowHome = path.join(tempRoot, ".agintiflow-home");
25
25
  const binPath = path.join(repoRoot, "bin/aginti-cli.js");
26
26
 
27
+ function charCellWidth(char = "") {
28
+ const code = char.codePointAt(0);
29
+ if (!code) return 0;
30
+ if (code < 32 || (code >= 0x7f && code < 0xa0)) return 0;
31
+ if (
32
+ (code >= 0x0300 && code <= 0x036f) ||
33
+ (code >= 0x1ab0 && code <= 0x1aff) ||
34
+ (code >= 0x1dc0 && code <= 0x1dff) ||
35
+ (code >= 0x20d0 && code <= 0x20ff) ||
36
+ (code >= 0xfe20 && code <= 0xfe2f)
37
+ ) {
38
+ return 0;
39
+ }
40
+ if (
41
+ code >= 0x1100 &&
42
+ (code <= 0x115f ||
43
+ code === 0x2329 ||
44
+ code === 0x232a ||
45
+ (code >= 0x2e80 && code <= 0xa4cf && code !== 0x303f) ||
46
+ (code >= 0xac00 && code <= 0xd7a3) ||
47
+ (code >= 0xf900 && code <= 0xfaff) ||
48
+ (code >= 0xfe10 && code <= 0xfe19) ||
49
+ (code >= 0xfe30 && code <= 0xfe6f) ||
50
+ (code >= 0xff00 && code <= 0xff60) ||
51
+ (code >= 0xffe0 && code <= 0xffe6) ||
52
+ (code >= 0x1f300 && code <= 0x1f64f) ||
53
+ (code >= 0x1f900 && code <= 0x1f9ff) ||
54
+ (code >= 0x20000 && code <= 0x3fffd))
55
+ ) {
56
+ return 2;
57
+ }
58
+ return 1;
59
+ }
60
+
61
+ function cellWidth(value = "") {
62
+ return [...String(value || "").replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "")].reduce((sum, char) => sum + charCellWidth(char), 0);
63
+ }
64
+
27
65
  function runChat(inputText) {
28
66
  return runCli(["chat", "--provider", "mock", "--routing", "manual", "--profile", "code"], inputText);
29
67
  }
@@ -221,6 +259,14 @@ try {
221
259
  if (!jaLaunchHeader.includes("低コストでプロジェクトを理解するエージェント")) {
222
260
  throw new Error("launch header did not localize by language option");
223
261
  }
262
+ const zhLaunchHeader = buildLaunchHeaderLines({ width: 80, packageVersion: "0.0.0", animated: false, language: "zh-Hans" });
263
+ if (zhLaunchHeader.some((line) => cellWidth(line) > 80)) {
264
+ throw new Error("launch header did not account for CJK terminal cell width");
265
+ }
266
+ const jaNarrowHeader = buildLaunchHeaderLines({ width: 80, packageVersion: "0.0.0", animated: false, language: "ja" });
267
+ if (jaNarrowHeader.some((line) => cellWidth(line) > 80)) {
268
+ throw new Error("Japanese launch header overflowed narrow terminal width");
269
+ }
224
270
  const hugePromptLayout = buildPromptLayout(Array.from({ length: 30 }, (_unused, index) => `line ${index + 1}`).join("\n"), 120, 80, 20);
225
271
  if (hugePromptLayout.renderedRows.length > 12 || !hugePromptLayout.renderedRows.some((line) => line.includes("earlier input row"))) {
226
272
  throw new Error("terminal prompt layout did not bound redraw size for large prompts");
@@ -175,8 +175,62 @@ function promptViewportRows(height = terminalHeight()) {
175
175
  return Math.max(Math.min(Math.floor(Number(height) * 0.42), 10), 4);
176
176
  }
177
177
 
178
+ function stripAnsi(value) {
179
+ return String(value || "").replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "");
180
+ }
181
+
182
+ function charCellWidth(char = "") {
183
+ const code = char.codePointAt(0);
184
+ if (!code) return 0;
185
+ if (code < 32 || (code >= 0x7f && code < 0xa0)) return 0;
186
+ if (
187
+ (code >= 0x0300 && code <= 0x036f) ||
188
+ (code >= 0x1ab0 && code <= 0x1aff) ||
189
+ (code >= 0x1dc0 && code <= 0x1dff) ||
190
+ (code >= 0x20d0 && code <= 0x20ff) ||
191
+ (code >= 0xfe20 && code <= 0xfe2f)
192
+ ) {
193
+ return 0;
194
+ }
195
+ if (
196
+ code >= 0x1100 &&
197
+ (code <= 0x115f ||
198
+ code === 0x2329 ||
199
+ code === 0x232a ||
200
+ (code >= 0x2e80 && code <= 0xa4cf && code !== 0x303f) ||
201
+ (code >= 0xac00 && code <= 0xd7a3) ||
202
+ (code >= 0xf900 && code <= 0xfaff) ||
203
+ (code >= 0xfe10 && code <= 0xfe19) ||
204
+ (code >= 0xfe30 && code <= 0xfe6f) ||
205
+ (code >= 0xff00 && code <= 0xff60) ||
206
+ (code >= 0xffe0 && code <= 0xffe6) ||
207
+ (code >= 0x1f300 && code <= 0x1f64f) ||
208
+ (code >= 0x1f900 && code <= 0x1f9ff) ||
209
+ (code >= 0x20000 && code <= 0x3fffd))
210
+ ) {
211
+ return 2;
212
+ }
213
+ return 1;
214
+ }
215
+
216
+ function stringCellWidth(value = "") {
217
+ return [...String(value || "")].reduce((sum, char) => sum + charCellWidth(char), 0);
218
+ }
219
+
220
+ function sliceToVisualWidth(value = "", width = 0) {
221
+ let used = 0;
222
+ let result = "";
223
+ for (const char of String(value || "")) {
224
+ const next = used + charCellWidth(char);
225
+ if (next > width) break;
226
+ result += char;
227
+ used = next;
228
+ }
229
+ return result;
230
+ }
231
+
178
232
  function visualLength(value) {
179
- return stripAnsi(value).length;
233
+ return stringCellWidth(stripAnsi(value));
180
234
  }
181
235
 
182
236
  function padVisible(value, width) {
@@ -186,7 +240,7 @@ function padVisible(value, width) {
186
240
 
187
241
  function panelLine(content = "", bgCode = ansi.systemBg, width = editorWidth()) {
188
242
  const raw = String(content || "");
189
- const safeContent = visualLength(raw) > width ? stripAnsi(raw).slice(0, width) : raw;
243
+ const safeContent = visualLength(raw) > width ? sliceToVisualWidth(stripAnsi(raw), width) : raw;
190
244
  if (!useColor) return padVisible(safeContent, width);
191
245
  const padded = padVisible(safeContent, width).replaceAll(ansi.reset, `${ansi.reset}${bgCode}`);
192
246
  return `${bgCode}${padded}${ansi.reset}`;
@@ -203,10 +257,6 @@ function commandCompleter(line = "") {
203
257
  return [hits.length > 0 ? hits : SLASH_COMMANDS, trimmed];
204
258
  }
205
259
 
206
- function stripAnsi(value) {
207
- return String(value || "").replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "");
208
- }
209
-
210
260
  function promptGutter() {
211
261
  const visible = stripAnsi(userPrompt()).replace(/^\n/, "").length;
212
262
  return " ".repeat(Math.max(visible - 2, 0)) + `${color("|", ansi.userBg)} `;
@@ -253,7 +303,7 @@ function clamp(value, min, max) {
253
303
 
254
304
  function compactLine(value = "", limit = 96) {
255
305
  const text = stripAnsi(String(value || "").replace(/\s+/g, " ").trim());
256
- return text.length <= limit ? text : `${text.slice(0, Math.max(limit - 1, 1))}…`;
306
+ return visualLength(text) <= limit ? text : `${sliceToVisualWidth(text, Math.max(limit - 1, 1))}…`;
257
307
  }
258
308
 
259
309
  export function formatElapsedDuration(ms = 0) {