claude-code-rust 0.12.1 → 0.12.3
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/README.md +3 -7
- package/agent-sdk/README.md +1 -1
- package/agent-sdk/dist/bridge/account_metadata.js +44 -0
- package/agent-sdk/dist/bridge/available_commands.js +129 -0
- package/agent-sdk/dist/bridge/commands.js +58 -36
- package/agent-sdk/dist/bridge/error_classification.js +20 -7
- package/agent-sdk/dist/bridge/events.js +18 -0
- package/agent-sdk/dist/bridge/history.js +183 -11
- package/agent-sdk/dist/bridge/logger.js +3 -0
- package/agent-sdk/dist/bridge/mcp.js +49 -79
- package/agent-sdk/dist/bridge/mcp_metadata.js +369 -0
- package/agent-sdk/dist/bridge/message_handlers.js +401 -57
- package/agent-sdk/dist/bridge/model_metadata.js +228 -0
- package/agent-sdk/dist/bridge/session_lifecycle.js +197 -326
- package/agent-sdk/dist/bridge/state_parsing.js +7 -1
- package/agent-sdk/dist/bridge/task_links.js +34 -0
- package/agent-sdk/dist/bridge/tasks.js +862 -0
- package/agent-sdk/dist/bridge/tool_calls.js +88 -31
- package/agent-sdk/dist/bridge/tooling.js +1278 -42
- package/agent-sdk/dist/bridge.js +96 -44
- package/agent-sdk/dist/bridge.test.js +3691 -252
- package/package.json +8 -3
- package/scripts/jscpd-warning-summary.mjs +132 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-rust",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "Claude Code Rust - native Rust terminal interface for Claude Code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -29,14 +29,19 @@
|
|
|
29
29
|
"README.md"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
32
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.177",
|
|
33
33
|
"@anthropic-ai/sdk": "0.97.1",
|
|
34
34
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
35
35
|
"zod": "4.4.3"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"postinstall": "node ./scripts/postinstall.js",
|
|
39
|
-
"prepack": "npm --prefix agent-sdk run build"
|
|
39
|
+
"prepack": "npm --prefix agent-sdk run build",
|
|
40
|
+
"quality:duplicates": "jscpd --config .jscpd.json src agent-sdk/src scripts bin --no-tips --no-colors",
|
|
41
|
+
"quality:duplicates:summary": "node scripts/jscpd-warning-summary.mjs jscpd-report/jscpd-report.json"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"jscpd": "5.0.9"
|
|
40
45
|
},
|
|
41
46
|
"engines": {
|
|
42
47
|
"node": ">=18"
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
|
|
4
|
+
const reportPath = process.argv[2] ?? "jscpd-report/jscpd-report.json";
|
|
5
|
+
const warningThreshold = Number.parseFloat(process.env.JSCPD_WARNING_THRESHOLD ?? "3.0");
|
|
6
|
+
|
|
7
|
+
function escapeWorkflowCommand(value) {
|
|
8
|
+
return String(value).replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function markdownCell(value) {
|
|
12
|
+
return String(value).replaceAll("|", "\\|").replaceAll("\n", " ");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function asNumber(value, fallback = 0) {
|
|
16
|
+
const number = Number(value);
|
|
17
|
+
return Number.isFinite(number) ? number : fallback;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatPercent(value) {
|
|
21
|
+
return `${asNumber(value).toFixed(2)}%`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function formatLocation(location) {
|
|
25
|
+
if (!location?.name) {
|
|
26
|
+
return "unknown";
|
|
27
|
+
}
|
|
28
|
+
const name = String(location.name).replaceAll("\\", "/");
|
|
29
|
+
const start = asNumber(location.start, asNumber(location.startLoc?.line, 1));
|
|
30
|
+
const end = asNumber(location.end, asNumber(location.endLoc?.line, start));
|
|
31
|
+
return `${name}:${start}-${end}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function appendSummary(markdown) {
|
|
35
|
+
const summaryPath = process.env.GITHUB_STEP_SUMMARY;
|
|
36
|
+
if (summaryPath) {
|
|
37
|
+
fs.appendFileSync(summaryPath, `${markdown}\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function emitWarning(message) {
|
|
42
|
+
console.log(`::warning title=Duplicate code soft threshold::${escapeWorkflowCommand(message)}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!fs.existsSync(reportPath)) {
|
|
46
|
+
const message = `jscpd report not found at ${reportPath}; duplicate-code summary was skipped.`;
|
|
47
|
+
emitWarning(message);
|
|
48
|
+
appendSummary(`### Duplicate Code Scan\n\n${message}\n`);
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const report = JSON.parse(fs.readFileSync(reportPath, "utf8"));
|
|
53
|
+
const total = report.statistics?.total ?? {};
|
|
54
|
+
const formats = report.statistics?.formats ?? {};
|
|
55
|
+
const duplicates = Array.isArray(report.duplicates) ? report.duplicates : [];
|
|
56
|
+
|
|
57
|
+
const percentage = asNumber(total.percentage);
|
|
58
|
+
const clones = asNumber(total.clones, duplicates.length);
|
|
59
|
+
const duplicatedLines = asNumber(total.duplicatedLines);
|
|
60
|
+
const totalLines = asNumber(total.lines);
|
|
61
|
+
const duplicatedTokens = asNumber(total.duplicatedTokens);
|
|
62
|
+
const totalTokens = asNumber(total.tokens);
|
|
63
|
+
|
|
64
|
+
const status =
|
|
65
|
+
percentage >= warningThreshold
|
|
66
|
+
? `Warning: duplicated lines are ${formatPercent(percentage)}, above the ${formatPercent(warningThreshold)} soft threshold.`
|
|
67
|
+
: `OK: duplicated lines are ${formatPercent(percentage)}, below the ${formatPercent(warningThreshold)} soft threshold.`;
|
|
68
|
+
|
|
69
|
+
console.log(status);
|
|
70
|
+
console.log(
|
|
71
|
+
`jscpd found ${clones} clones across ${totalLines} lines and ${totalTokens} tokens ` +
|
|
72
|
+
`(${duplicatedLines} duplicated lines, ${duplicatedTokens} duplicated tokens).`,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (percentage >= warningThreshold) {
|
|
76
|
+
emitWarning(
|
|
77
|
+
`jscpd found ${formatPercent(percentage)} duplicated lines (${clones} clones), ` +
|
|
78
|
+
`above the ${formatPercent(warningThreshold)} advisory threshold. ` +
|
|
79
|
+
"This workflow is warning-only and does not block the PR.",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const formatRows = Object.entries(formats)
|
|
84
|
+
.sort(([, left], [, right]) => asNumber(right.percentage) - asNumber(left.percentage))
|
|
85
|
+
.map(([format, stats]) =>
|
|
86
|
+
[
|
|
87
|
+
markdownCell(format),
|
|
88
|
+
asNumber(stats.sources),
|
|
89
|
+
asNumber(stats.clones),
|
|
90
|
+
asNumber(stats.duplicatedLines),
|
|
91
|
+
formatPercent(stats.percentage),
|
|
92
|
+
].join(" | "),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const topDuplicates = [...duplicates]
|
|
96
|
+
.sort((left, right) => asNumber(right.lines) - asNumber(left.lines))
|
|
97
|
+
.slice(0, 10)
|
|
98
|
+
.map((duplicate) =>
|
|
99
|
+
[
|
|
100
|
+
asNumber(duplicate.lines),
|
|
101
|
+
asNumber(duplicate.tokens),
|
|
102
|
+
markdownCell(duplicate.format ?? "unknown"),
|
|
103
|
+
markdownCell(formatLocation(duplicate.firstFile)),
|
|
104
|
+
markdownCell(formatLocation(duplicate.secondFile)),
|
|
105
|
+
].join(" | "),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const summary = [
|
|
109
|
+
"### Duplicate Code Scan",
|
|
110
|
+
"",
|
|
111
|
+
status,
|
|
112
|
+
"",
|
|
113
|
+
"| Metric | Value |",
|
|
114
|
+
"| --- | ---: |",
|
|
115
|
+
`| Clones | ${clones} |`,
|
|
116
|
+
`| Duplicated lines | ${duplicatedLines} / ${totalLines} (${formatPercent(percentage)}) |`,
|
|
117
|
+
`| Duplicated tokens | ${duplicatedTokens} / ${totalTokens} (${formatPercent(total.percentageTokens)}) |`,
|
|
118
|
+
`| Soft threshold | ${formatPercent(warningThreshold)} |`,
|
|
119
|
+
"",
|
|
120
|
+
"| Format | Files | Clones | Duplicated lines | Duplicated lines % |",
|
|
121
|
+
"| --- | ---: | ---: | ---: | ---: |",
|
|
122
|
+
...formatRows,
|
|
123
|
+
"",
|
|
124
|
+
"| Lines | Tokens | Format | First location | Second location |",
|
|
125
|
+
"| ---: | ---: | --- | --- | --- |",
|
|
126
|
+
...(topDuplicates.length > 0 ? topDuplicates : ["| 0 | 0 | none | n/a | n/a |"]),
|
|
127
|
+
"",
|
|
128
|
+
"The complete JSON and HTML reports are attached as the `jscpd-report` workflow artifact.",
|
|
129
|
+
"",
|
|
130
|
+
].join("\n");
|
|
131
|
+
|
|
132
|
+
appendSummary(summary);
|