context-mode 1.0.54 → 1.0.57
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/README.md +20 -6
- package/build/adapters/antigravity/index.d.ts +1 -3
- package/build/adapters/antigravity/index.js +0 -30
- package/build/adapters/claude-code/index.d.ts +1 -3
- package/build/adapters/claude-code/index.js +15 -34
- package/build/adapters/codex/index.d.ts +1 -3
- package/build/adapters/codex/index.js +1 -31
- package/build/adapters/cursor/index.d.ts +1 -3
- package/build/adapters/cursor/index.js +0 -11
- package/build/adapters/gemini-cli/index.d.ts +1 -3
- package/build/adapters/gemini-cli/index.js +0 -30
- package/build/adapters/kiro/index.d.ts +1 -3
- package/build/adapters/kiro/index.js +0 -30
- package/build/adapters/openclaw/index.d.ts +1 -3
- package/build/adapters/openclaw/index.js +0 -38
- package/build/adapters/opencode/index.d.ts +1 -3
- package/build/adapters/opencode/index.js +15 -34
- package/build/adapters/types.d.ts +0 -13
- package/build/adapters/vscode-copilot/index.d.ts +1 -3
- package/build/adapters/vscode-copilot/index.js +0 -32
- package/build/adapters/zed/index.d.ts +1 -3
- package/build/adapters/zed/index.js +0 -30
- package/build/executor.d.ts +0 -1
- package/build/executor.js +26 -14
- package/build/openclaw-plugin.js +0 -30
- package/build/opencode-plugin.d.ts +1 -0
- package/build/opencode-plugin.js +1 -8
- package/build/server.js +82 -19
- package/build/truncate.d.ts +4 -17
- package/build/truncate.js +4 -52
- package/cli.bundle.mjs +110 -137
- package/hooks/ensure-deps.mjs +80 -2
- package/hooks/routing-block.mjs +12 -1
- package/hooks/session-helpers.mjs +13 -0
- package/hooks/session-snapshot.bundle.mjs +13 -13
- package/hooks/sessionstart.mjs +5 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +83 -107
- package/skills/context-mode-ops/SKILL.md +111 -0
- package/skills/context-mode-ops/agent-teams.md +198 -0
- package/skills/context-mode-ops/communication.md +224 -0
- package/skills/context-mode-ops/release.md +199 -0
- package/skills/context-mode-ops/review-pr.md +269 -0
- package/skills/context-mode-ops/tdd.md +329 -0
- package/skills/context-mode-ops/triage-issue.md +218 -0
- package/skills/context-mode-ops/validation.md +238 -0
- package/start.mjs +5 -52
package/build/truncate.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* truncate — Pure string and
|
|
2
|
+
* truncate — Pure string truncation and escaping utilities for context-mode.
|
|
3
3
|
*
|
|
4
|
-
* These helpers are used by
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* in the full store or executor.
|
|
4
|
+
* These helpers are used by the core ContentStore (chunking) and
|
|
5
|
+
* SessionDB (snapshot building). They are extracted here so any
|
|
6
|
+
* consumer can import them without pulling in the full store or executor.
|
|
8
7
|
*/
|
|
9
8
|
// ─────────────────────────────────────────────────────────
|
|
10
9
|
// String truncation
|
|
@@ -24,53 +23,6 @@ export function truncateString(str, maxChars) {
|
|
|
24
23
|
return str.slice(0, Math.max(0, maxChars - 3)) + "...";
|
|
25
24
|
}
|
|
26
25
|
// ─────────────────────────────────────────────────────────
|
|
27
|
-
// Byte-aware smart truncation (head + tail)
|
|
28
|
-
// ─────────────────────────────────────────────────────────
|
|
29
|
-
/**
|
|
30
|
-
* Smart truncation that keeps the head (60%) and tail (40%) of output,
|
|
31
|
-
* preserving both initial context and final error messages.
|
|
32
|
-
* Snaps to line boundaries and handles UTF-8 safely via `Buffer.byteLength`.
|
|
33
|
-
*
|
|
34
|
-
* Used by PolyglotExecutor to cap stdout/stderr before returning to context.
|
|
35
|
-
*
|
|
36
|
-
* @param raw - Raw output string.
|
|
37
|
-
* @param maxBytes - Soft cap in bytes. Output below this threshold is returned as-is.
|
|
38
|
-
* @returns The original string if within budget, otherwise head + separator + tail.
|
|
39
|
-
*/
|
|
40
|
-
export function smartTruncate(raw, maxBytes) {
|
|
41
|
-
if (Buffer.byteLength(raw) <= maxBytes)
|
|
42
|
-
return raw;
|
|
43
|
-
const lines = raw.split("\n");
|
|
44
|
-
// Budget: 60% head, 40% tail (errors/results are usually at the end)
|
|
45
|
-
const headBudget = Math.floor(maxBytes * 0.6);
|
|
46
|
-
const tailBudget = maxBytes - headBudget;
|
|
47
|
-
// Collect head lines
|
|
48
|
-
const headLines = [];
|
|
49
|
-
let headBytes = 0;
|
|
50
|
-
for (const line of lines) {
|
|
51
|
-
const lineBytes = Buffer.byteLength(line) + 1; // +1 for \n
|
|
52
|
-
if (headBytes + lineBytes > headBudget)
|
|
53
|
-
break;
|
|
54
|
-
headLines.push(line);
|
|
55
|
-
headBytes += lineBytes;
|
|
56
|
-
}
|
|
57
|
-
// Collect tail lines (from end)
|
|
58
|
-
const tailLines = [];
|
|
59
|
-
let tailBytes = 0;
|
|
60
|
-
for (let i = lines.length - 1; i >= headLines.length; i--) {
|
|
61
|
-
const lineBytes = Buffer.byteLength(lines[i]) + 1;
|
|
62
|
-
if (tailBytes + lineBytes > tailBudget)
|
|
63
|
-
break;
|
|
64
|
-
tailLines.unshift(lines[i]);
|
|
65
|
-
tailBytes += lineBytes;
|
|
66
|
-
}
|
|
67
|
-
const skippedLines = lines.length - headLines.length - tailLines.length;
|
|
68
|
-
const skippedBytes = Buffer.byteLength(raw) - headBytes - tailBytes;
|
|
69
|
-
const separator = `\n\n... [${skippedLines} lines / ${(skippedBytes / 1024).toFixed(1)}KB truncated` +
|
|
70
|
-
` — showing first ${headLines.length} + last ${tailLines.length} lines] ...\n\n`;
|
|
71
|
-
return headLines.join("\n") + separator + tailLines.join("\n");
|
|
72
|
-
}
|
|
73
|
-
// ─────────────────────────────────────────────────────────
|
|
74
26
|
// JSON truncation
|
|
75
27
|
// ─────────────────────────────────────────────────────────
|
|
76
28
|
/**
|