chatccc 0.2.160 → 0.2.161

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": "chatccc",
3
- "version": "0.2.160",
3
+ "version": "0.2.161",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -46,6 +46,16 @@ describe("truncateContent", () => {
46
46
  expect(resultLines[resultLines.length - 1]).toBe("line 10");
47
47
  expect(resultLines.length).toBe(6); // 1 first + "..." + 4 last
48
48
  });
49
+
50
+ it("skips leading empty lines, preserves first non-empty line", () => {
51
+ const lines = Array.from({ length: 25 }, (_, i) => `line ${i + 1}`);
52
+ const text = "\n\n\n" + lines.join("\n");
53
+ const result = truncateContent(text);
54
+ const resultLines = result.split("\n");
55
+ expect(resultLines[0]).toBe("line 1");
56
+ expect(resultLines[1]).toBe("...");
57
+ expect(resultLines.length).toBe(21); // 1 first + "..." + 19 last
58
+ });
49
59
  });
50
60
 
51
61
  // ---------------------------------------------------------------------------
package/src/cards.ts CHANGED
@@ -32,10 +32,16 @@ export function isCodeBlockOpen(text: string): boolean {
32
32
 
33
33
  export function truncateContent(text: string, maxLines = 20, maxChars = 8000): string {
34
34
  const lines = text.split("\n");
35
+ // 跳过开头空行
36
+ let startIdx = 0;
37
+ while (startIdx < lines.length && lines[startIdx].trim() === "") {
38
+ startIdx++;
39
+ }
40
+ const effectiveLines = lines.slice(startIdx);
35
41
  let displayText: string;
36
- if (lines.length > maxLines) {
37
- const firstLine = lines[0];
38
- const lastLines = lines.slice(-(maxLines - 1)).join("\n");
42
+ if (effectiveLines.length > maxLines) {
43
+ const firstLine = effectiveLines[0];
44
+ const lastLines = effectiveLines.slice(-(maxLines - 1)).join("\n");
39
45
  displayText = firstLine + "\n...\n" + lastLines;
40
46
  } else {
41
47
  displayText = text;