codmir 0.3.3 → 0.4.1
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/dist/{chunk-LXEEBTWT.mjs → chunk-GU32P57R.mjs} +70 -0
- package/dist/cli/index.js +198 -45
- package/dist/cli/index.mjs +129 -46
- package/dist/index.d.mts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +70 -0
- package/dist/index.mjs +1 -1
- package/dist/voice-agent/index.d.mts +134 -0
- package/dist/voice-agent/index.d.ts +134 -0
- package/dist/voice-agent/index.js +220 -0
- package/dist/voice-agent/index.mjs +187 -0
- package/dist/voice-daemon/index.d.mts +354 -0
- package/dist/voice-daemon/index.d.ts +354 -0
- package/dist/voice-daemon/index.js +1089 -0
- package/dist/voice-daemon/index.mjs +1046 -0
- package/package.json +33 -16
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CodmirClient
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GU32P57R.mjs";
|
|
5
5
|
import {
|
|
6
6
|
analyzeCommand,
|
|
7
7
|
clearConfig,
|
|
@@ -25,8 +25,8 @@ var require_package = __commonJS({
|
|
|
25
25
|
"package.json"(exports, module) {
|
|
26
26
|
module.exports = {
|
|
27
27
|
name: "codmir",
|
|
28
|
-
version: "0.
|
|
29
|
-
description: "Official codmir SDK -
|
|
28
|
+
version: "0.4.1",
|
|
29
|
+
description: "Official codmir SDK - AI that prevents wasted engineering time. CLI, SDK, voice assistant, codebase analysis, and intelligent automation.",
|
|
30
30
|
main: "dist/index.js",
|
|
31
31
|
module: "dist/index.mjs",
|
|
32
32
|
types: "dist/index.d.ts",
|
|
@@ -38,6 +38,16 @@ var require_package = __commonJS({
|
|
|
38
38
|
types: "./dist/index.d.ts",
|
|
39
39
|
require: "./dist/index.js",
|
|
40
40
|
import: "./dist/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./voice-agent": {
|
|
43
|
+
types: "./dist/voice-agent/index.d.ts",
|
|
44
|
+
require: "./dist/voice-agent/index.js",
|
|
45
|
+
import: "./dist/voice-agent/index.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./voice-daemon": {
|
|
48
|
+
types: "./dist/voice-daemon/index.d.ts",
|
|
49
|
+
require: "./dist/voice-daemon/index.js",
|
|
50
|
+
import: "./dist/voice-daemon/index.mjs"
|
|
41
51
|
}
|
|
42
52
|
},
|
|
43
53
|
files: [
|
|
@@ -47,7 +57,7 @@ var require_package = __commonJS({
|
|
|
47
57
|
"runkit-example.js"
|
|
48
58
|
],
|
|
49
59
|
scripts: {
|
|
50
|
-
build: "tsup src/index.ts src/cli/index.ts --format cjs,esm --dts --clean",
|
|
60
|
+
build: "tsup src/index.ts src/cli/index.ts src/voice-agent/index.ts src/voice-daemon/index.ts --format cjs,esm --dts --clean",
|
|
51
61
|
dev: "tsup src/index.ts src/cli/index.ts --format cjs,esm --dts --watch",
|
|
52
62
|
prepublishOnly: "pnpm build",
|
|
53
63
|
test: "jest",
|
|
@@ -73,7 +83,11 @@ var require_package = __commonJS({
|
|
|
73
83
|
"tasks",
|
|
74
84
|
"automation",
|
|
75
85
|
"multi-agent",
|
|
76
|
-
"ai-assistant"
|
|
86
|
+
"ai-assistant",
|
|
87
|
+
"voice-assistant",
|
|
88
|
+
"speech-recognition",
|
|
89
|
+
"voice-daemon",
|
|
90
|
+
"wake-word"
|
|
77
91
|
],
|
|
78
92
|
author: "codmir",
|
|
79
93
|
license: "MIT",
|
|
@@ -98,12 +112,16 @@ var require_package = __commonJS({
|
|
|
98
112
|
"@semantic-release/release-notes-generator": "^14.0.0",
|
|
99
113
|
"@types/node": "^20.10.0",
|
|
100
114
|
"@types/prompts": "^2.4.9",
|
|
115
|
+
"@types/ws": "^8.18.1",
|
|
116
|
+
"@types/blessed": "^0.1.25",
|
|
101
117
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
102
118
|
"semantic-release": "^24.0.0",
|
|
103
119
|
tsup: "^8.0.1",
|
|
104
120
|
typescript: "^5.8.3"
|
|
105
121
|
},
|
|
106
122
|
dependencies: {
|
|
123
|
+
blessed: "^0.1.81",
|
|
124
|
+
"blessed-contrib": "^4.11.0",
|
|
107
125
|
chalk: "^5.3.0",
|
|
108
126
|
clipboardy: "^5.0.1",
|
|
109
127
|
commander: "^12.0.0",
|
|
@@ -579,24 +597,61 @@ import clipboardy from "clipboardy";
|
|
|
579
597
|
import fs3 from "fs";
|
|
580
598
|
import path3 from "path";
|
|
581
599
|
import FormData from "form-data";
|
|
600
|
+
import readline2 from "readline";
|
|
601
|
+
function renderLogo() {
|
|
602
|
+
const c1 = chalk7.hex("#00D4FF");
|
|
603
|
+
const c2 = chalk7.hex("#0099FF");
|
|
604
|
+
const c3 = chalk7.hex("#7C3AED");
|
|
605
|
+
const c4 = chalk7.hex("#EC4899");
|
|
606
|
+
const c5 = chalk7.hex("#F472B6");
|
|
607
|
+
const logo = `
|
|
608
|
+
${c1(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557")}${c2(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ")}${c2("\u2588\u2588\u2588\u2588\u2588\u2588\u2557 ")}${c3("\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557")}${c4("\u2588\u2588\u2557")}${c5("\u2588\u2588\u2588\u2588\u2588\u2588\u2557 ")}
|
|
609
|
+
${c1(" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D")}${c2("\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557")}${c2("\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557")}${c3("\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551")}${c4("\u2588\u2588\u2551")}${c5("\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557")}
|
|
610
|
+
${c1(" \u2588\u2588\u2551 ")}${c2("\u2588\u2588\u2551 \u2588\u2588\u2551")}${c2("\u2588\u2588\u2551 \u2588\u2588\u2551")}${c3("\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551")}${c4("\u2588\u2588\u2551")}${c5("\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D")}
|
|
611
|
+
${c1(" \u2588\u2588\u2551 ")}${c2("\u2588\u2588\u2551 \u2588\u2588\u2551")}${c2("\u2588\u2588\u2551 \u2588\u2588\u2551")}${c3("\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551")}${c4("\u2588\u2588\u2551")}${c5("\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557")}
|
|
612
|
+
${c1(" \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557")}${c2("\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D")}${c2("\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D")}${c3("\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551")}${c4("\u2588\u2588\u2551")}${c5("\u2588\u2588\u2551 \u2588\u2588\u2551")}
|
|
613
|
+
${c1(" \u255A\u2550\u2550\u2550\u2550\u2550\u255D")}${c2(" \u255A\u2550\u2550\u2550\u2550\u2550\u255D ")}${c2("\u255A\u2550\u2550\u2550\u2550\u2550\u255D ")}${c3("\u255A\u2550\u255D \u255A\u2550\u255D")}${c4("\u255A\u2550\u255D")}${c5("\u255A\u2550\u255D \u255A\u2550\u255D")}
|
|
614
|
+
`;
|
|
615
|
+
console.log(logo);
|
|
616
|
+
}
|
|
617
|
+
function renderTips() {
|
|
618
|
+
console.log(chalk7.white("Tips for getting started:"));
|
|
619
|
+
console.log(chalk7.dim("1. Ask questions, edit files, or run commands."));
|
|
620
|
+
console.log(chalk7.dim("2. Be specific for the best results."));
|
|
621
|
+
console.log(chalk7.dim("3. Create ") + chalk7.cyan("CODMIR.md") + chalk7.dim(" files to customize your interactions with codmir."));
|
|
622
|
+
console.log(chalk7.dim("4. ") + chalk7.cyan("/help") + chalk7.dim(" for more information."));
|
|
623
|
+
console.log();
|
|
624
|
+
}
|
|
625
|
+
function renderStatusBar(context, model) {
|
|
626
|
+
const termWidth = process.stdout.columns || 80;
|
|
627
|
+
const projectInfo = context.isLinkedProject ? chalk7.cyan(`~/${context.projectConfig?.projectName || "project"}`) : chalk7.yellow("~/global");
|
|
628
|
+
const sandboxStatus = chalk7.dim("no sandbox") + chalk7.dim(" (see /docs)");
|
|
629
|
+
const modelInfo = chalk7.green(`${model}`) + chalk7.dim(" (100% context left)");
|
|
630
|
+
console.log();
|
|
631
|
+
console.log(chalk7.dim("\u2500".repeat(termWidth)));
|
|
632
|
+
console.log(`${projectInfo} ${sandboxStatus} ${modelInfo}`);
|
|
633
|
+
}
|
|
634
|
+
function renderEditHint() {
|
|
635
|
+
const termWidth = process.stdout.columns || 80;
|
|
636
|
+
const hint = chalk7.dim("accepting edits") + chalk7.dim(" (shift + tab to toggle)");
|
|
637
|
+
const padding = " ".repeat(Math.max(0, termWidth - 35));
|
|
638
|
+
console.log(padding + hint);
|
|
639
|
+
}
|
|
582
640
|
async function assistantCommand(query, options = {}) {
|
|
583
641
|
const token = getToken();
|
|
642
|
+
const context = getExecutionContext();
|
|
643
|
+
const model = options.model || "gpt-4-turbo";
|
|
644
|
+
console.clear();
|
|
645
|
+
renderLogo();
|
|
584
646
|
if (!token) {
|
|
585
|
-
console.
|
|
586
|
-
console.log(chalk7.dim(" Run")
|
|
647
|
+
console.log(chalk7.red("\n\u274C Not authenticated"));
|
|
648
|
+
console.log(chalk7.dim(" Run ") + chalk7.cyan("codmir login") + chalk7.dim(" to get started.\n"));
|
|
587
649
|
process.exit(1);
|
|
588
650
|
}
|
|
651
|
+
renderTips();
|
|
652
|
+
renderEditHint();
|
|
589
653
|
const baseUrl = getBaseUrl();
|
|
590
654
|
const conversationHistory = [];
|
|
591
|
-
const context = getExecutionContext();
|
|
592
|
-
if (context.isLinkedProject) {
|
|
593
|
-
console.log(chalk7.dim(` \u{1F4C1} Project: ${context.projectConfig?.projectName || context.projectConfig?.projectId}`));
|
|
594
|
-
console.log(chalk7.dim(` \u{1F517} Mode: ${chalk7.cyan("local")} (linked project)
|
|
595
|
-
`));
|
|
596
|
-
} else {
|
|
597
|
-
console.log(chalk7.dim(` \u{1F310} Mode: ${chalk7.yellow("global")}
|
|
598
|
-
`));
|
|
599
|
-
}
|
|
600
655
|
conversationHistory.push({
|
|
601
656
|
role: "system",
|
|
602
657
|
content: `You are codmir, an AI assistant for developers. You help with:
|
|
@@ -607,28 +662,47 @@ async function assistantCommand(query, options = {}) {
|
|
|
607
662
|
|
|
608
663
|
Be concise, practical, and code-focused. Use lowercase "codmir" for the brand.`
|
|
609
664
|
});
|
|
610
|
-
console.log(chalk7.bold("\n\u{1F916} codmir"));
|
|
611
|
-
console.log(chalk7.dim(" AI assistant for developers\n"));
|
|
612
665
|
if (query) {
|
|
613
666
|
await handleQuery(query, conversationHistory, baseUrl, token, options);
|
|
667
|
+
renderStatusBar(context, model);
|
|
614
668
|
return;
|
|
615
669
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
670
|
+
const rl = readline2.createInterface({
|
|
671
|
+
input: process.stdin,
|
|
672
|
+
output: process.stdout
|
|
673
|
+
});
|
|
674
|
+
const promptUser = () => {
|
|
675
|
+
rl.question(chalk7.cyan("> ") + chalk7.dim("Type your message or @path/to/file "), async (userInput) => {
|
|
676
|
+
if (!userInput || userInput.toLowerCase() === "exit" || userInput.toLowerCase() === "quit" || userInput === "/exit") {
|
|
677
|
+
console.log(chalk7.dim("\nGoodbye! \u{1F44B}\n"));
|
|
678
|
+
rl.close();
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (userInput === "/help") {
|
|
682
|
+
console.log("\n" + chalk7.bold("Available commands:"));
|
|
683
|
+
console.log(chalk7.cyan(" /help") + chalk7.dim(" - Show this help message"));
|
|
684
|
+
console.log(chalk7.cyan(" /clear") + chalk7.dim(" - Clear conversation history"));
|
|
685
|
+
console.log(chalk7.cyan(" /exit") + chalk7.dim(" - Exit codmir"));
|
|
686
|
+
console.log(chalk7.cyan(" @file") + chalk7.dim(" - Reference a file in your message"));
|
|
687
|
+
console.log();
|
|
688
|
+
promptUser();
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (userInput === "/clear") {
|
|
692
|
+
conversationHistory.length = 1;
|
|
693
|
+
console.log(chalk7.dim("\n\u2713 Conversation cleared\n"));
|
|
694
|
+
promptUser();
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
await handleQuery(userInput, conversationHistory, baseUrl, token, options);
|
|
698
|
+
console.log();
|
|
699
|
+
promptUser();
|
|
625
700
|
});
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
701
|
+
};
|
|
702
|
+
promptUser();
|
|
703
|
+
rl.on("close", () => {
|
|
704
|
+
renderStatusBar(context, model);
|
|
705
|
+
});
|
|
632
706
|
}
|
|
633
707
|
async function handleQuery(query, conversationHistory, baseUrl, token, options) {
|
|
634
708
|
let imagePaths;
|
|
@@ -1190,30 +1264,34 @@ function handleCouncilMessage(message, context) {
|
|
|
1190
1264
|
console.log("");
|
|
1191
1265
|
break;
|
|
1192
1266
|
case "round-start":
|
|
1193
|
-
printRoundHeader(message.round);
|
|
1267
|
+
printRoundHeader(message.round ?? 0);
|
|
1194
1268
|
roundResponses.length = 0;
|
|
1195
1269
|
break;
|
|
1196
|
-
case "member-thinking":
|
|
1270
|
+
case "member-thinking": {
|
|
1271
|
+
const role = message.role ?? "architect";
|
|
1197
1272
|
const thinkSpinner = ora2({
|
|
1198
|
-
text: `${ROLE_ICONS[
|
|
1273
|
+
text: `${ROLE_ICONS[role]} ${capitalize(role)} is analyzing...`,
|
|
1199
1274
|
color: "yellow"
|
|
1200
1275
|
}).start();
|
|
1201
1276
|
onSpinnerUpdate(thinkSpinner);
|
|
1202
1277
|
break;
|
|
1203
|
-
|
|
1278
|
+
}
|
|
1279
|
+
case "member-response": {
|
|
1204
1280
|
if (currentSpinner) currentSpinner.stop();
|
|
1205
|
-
const
|
|
1206
|
-
const
|
|
1281
|
+
const role = message.role ?? "architect";
|
|
1282
|
+
const roleColor = ROLE_COLORS[role] || chalk9.white;
|
|
1283
|
+
const icon = ROLE_ICONS[role] || "\u{1F916}";
|
|
1207
1284
|
console.log("");
|
|
1208
|
-
console.log(roleColor.bold(`${icon} ${capitalize(
|
|
1209
|
-
const formatted = formatResponse(message.content);
|
|
1285
|
+
console.log(roleColor.bold(`${icon} ${capitalize(role)}:`));
|
|
1286
|
+
const formatted = formatResponse(typeof message.content === "string" ? message.content : "");
|
|
1210
1287
|
console.log(chalk9.gray(` ${formatted}`));
|
|
1211
1288
|
console.log("");
|
|
1212
1289
|
roundResponses.push(message);
|
|
1213
1290
|
break;
|
|
1291
|
+
}
|
|
1214
1292
|
case "round-complete":
|
|
1215
|
-
const agreementCount = message.agreements
|
|
1216
|
-
const totalMembers = message.totalMembers
|
|
1293
|
+
const agreementCount = typeof message.agreements === "number" ? message.agreements : 0;
|
|
1294
|
+
const totalMembers = typeof message.totalMembers === "number" ? message.totalMembers : roundResponses.length;
|
|
1217
1295
|
const agreementPercent = Math.round(agreementCount / totalMembers * 100);
|
|
1218
1296
|
console.log(chalk9.gray(` Agreement: ${agreementCount}/${totalMembers} (${agreementPercent}%)`));
|
|
1219
1297
|
console.log("");
|
|
@@ -1444,7 +1522,12 @@ program.command("council [task...]").description("\u{1F3AD} Assemble a council o
|
|
|
1444
1522
|
const taskString = task ? task.join(" ") : void 0;
|
|
1445
1523
|
councilCommand(taskString, options);
|
|
1446
1524
|
});
|
|
1447
|
-
|
|
1448
|
-
if (
|
|
1449
|
-
|
|
1525
|
+
if (!process.argv.slice(2).length || process.argv[2] === "--help" || process.argv[2] === "-h") {
|
|
1526
|
+
if (process.argv[2] === "--help" || process.argv[2] === "-h") {
|
|
1527
|
+
program.parse(process.argv);
|
|
1528
|
+
} else {
|
|
1529
|
+
assistantCommand(void 0, {});
|
|
1530
|
+
}
|
|
1531
|
+
} else {
|
|
1532
|
+
program.parse(process.argv);
|
|
1450
1533
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -88,6 +88,51 @@ interface CreateTestCaseInput {
|
|
|
88
88
|
interface UpdateTestCaseInput extends Partial<CreateTestCaseInput> {
|
|
89
89
|
status?: TestCaseStatus;
|
|
90
90
|
}
|
|
91
|
+
interface TestRunArtifact {
|
|
92
|
+
label?: string;
|
|
93
|
+
type?: string;
|
|
94
|
+
url: string;
|
|
95
|
+
}
|
|
96
|
+
interface TestRunSummaryInput {
|
|
97
|
+
projectId: string;
|
|
98
|
+
sprintId?: string;
|
|
99
|
+
suite: string;
|
|
100
|
+
framework?: string;
|
|
101
|
+
passCount: number;
|
|
102
|
+
failCount: number;
|
|
103
|
+
flakyCount?: number;
|
|
104
|
+
durationMs?: number;
|
|
105
|
+
commitSha?: string;
|
|
106
|
+
releaseTrainId?: string;
|
|
107
|
+
artifacts?: TestRunArtifact[];
|
|
108
|
+
}
|
|
109
|
+
interface TestRunRecord extends TestRunSummaryInput {
|
|
110
|
+
id: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
}
|
|
113
|
+
interface CoverageFeatureBreakdown {
|
|
114
|
+
name: string;
|
|
115
|
+
coverage: number;
|
|
116
|
+
risk?: string;
|
|
117
|
+
}
|
|
118
|
+
interface CoverageInsightRequest {
|
|
119
|
+
projectId: string;
|
|
120
|
+
sprintId?: string;
|
|
121
|
+
linesPct: number;
|
|
122
|
+
branchesPct?: number;
|
|
123
|
+
statementsPct?: number;
|
|
124
|
+
functionsPct?: number;
|
|
125
|
+
features?: CoverageFeatureBreakdown[];
|
|
126
|
+
}
|
|
127
|
+
interface CoverageSuggestedTest {
|
|
128
|
+
title: string;
|
|
129
|
+
reason?: string;
|
|
130
|
+
}
|
|
131
|
+
interface CoverageInsight extends CoverageInsightRequest {
|
|
132
|
+
id: string;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
suggestedTests?: CoverageSuggestedTest[] | null;
|
|
135
|
+
}
|
|
91
136
|
interface ApiResponse<T> {
|
|
92
137
|
data?: T;
|
|
93
138
|
error?: string;
|
|
@@ -132,6 +177,7 @@ declare class CodmirClient {
|
|
|
132
177
|
private readonly config;
|
|
133
178
|
readonly tickets: TicketsAPI;
|
|
134
179
|
readonly testCases: TestCasesAPI;
|
|
180
|
+
readonly testing: TestingAPI;
|
|
135
181
|
constructor(config: CodmirClientConfig);
|
|
136
182
|
/**
|
|
137
183
|
* Make an HTTP request to the codmir API
|
|
@@ -216,5 +262,34 @@ declare class TestCasesAPI {
|
|
|
216
262
|
*/
|
|
217
263
|
delete(projectId: string, testCaseId: string | number): Promise<void>;
|
|
218
264
|
}
|
|
265
|
+
declare class TestingAPI {
|
|
266
|
+
private config;
|
|
267
|
+
constructor(config: Required<CodmirClientConfig>);
|
|
268
|
+
private request;
|
|
269
|
+
submitTestRun(payload: TestRunSummaryInput): Promise<{
|
|
270
|
+
run: TestRunRecord;
|
|
271
|
+
summary: {
|
|
272
|
+
framework: string;
|
|
273
|
+
passRate: number;
|
|
274
|
+
totalDurationMs: number;
|
|
275
|
+
};
|
|
276
|
+
}>;
|
|
277
|
+
listTestRuns(projectId: string, options?: {
|
|
278
|
+
limit?: number;
|
|
279
|
+
suite?: string;
|
|
280
|
+
}): Promise<TestRunRecord[]>;
|
|
281
|
+
requestCoverageInsight(payload: CoverageInsightRequest): Promise<{
|
|
282
|
+
report: CoverageInsight;
|
|
283
|
+
insights: {
|
|
284
|
+
coverageGauge: number;
|
|
285
|
+
featureBreakdown?: CoverageInsightRequest['features'];
|
|
286
|
+
suggestedTests: {
|
|
287
|
+
title: string;
|
|
288
|
+
reason?: string;
|
|
289
|
+
}[];
|
|
290
|
+
};
|
|
291
|
+
}>;
|
|
292
|
+
listCoverageInsights(projectId: string, limit?: number): Promise<CoverageInsight[]>;
|
|
293
|
+
}
|
|
219
294
|
|
|
220
|
-
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
|
295
|
+
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CoverageFeatureBreakdown, type CoverageInsight, type CoverageInsightRequest, type CoverageSuggestedTest, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type TestRunArtifact, type TestRunRecord, type TestRunSummaryInput, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,51 @@ interface CreateTestCaseInput {
|
|
|
88
88
|
interface UpdateTestCaseInput extends Partial<CreateTestCaseInput> {
|
|
89
89
|
status?: TestCaseStatus;
|
|
90
90
|
}
|
|
91
|
+
interface TestRunArtifact {
|
|
92
|
+
label?: string;
|
|
93
|
+
type?: string;
|
|
94
|
+
url: string;
|
|
95
|
+
}
|
|
96
|
+
interface TestRunSummaryInput {
|
|
97
|
+
projectId: string;
|
|
98
|
+
sprintId?: string;
|
|
99
|
+
suite: string;
|
|
100
|
+
framework?: string;
|
|
101
|
+
passCount: number;
|
|
102
|
+
failCount: number;
|
|
103
|
+
flakyCount?: number;
|
|
104
|
+
durationMs?: number;
|
|
105
|
+
commitSha?: string;
|
|
106
|
+
releaseTrainId?: string;
|
|
107
|
+
artifacts?: TestRunArtifact[];
|
|
108
|
+
}
|
|
109
|
+
interface TestRunRecord extends TestRunSummaryInput {
|
|
110
|
+
id: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
}
|
|
113
|
+
interface CoverageFeatureBreakdown {
|
|
114
|
+
name: string;
|
|
115
|
+
coverage: number;
|
|
116
|
+
risk?: string;
|
|
117
|
+
}
|
|
118
|
+
interface CoverageInsightRequest {
|
|
119
|
+
projectId: string;
|
|
120
|
+
sprintId?: string;
|
|
121
|
+
linesPct: number;
|
|
122
|
+
branchesPct?: number;
|
|
123
|
+
statementsPct?: number;
|
|
124
|
+
functionsPct?: number;
|
|
125
|
+
features?: CoverageFeatureBreakdown[];
|
|
126
|
+
}
|
|
127
|
+
interface CoverageSuggestedTest {
|
|
128
|
+
title: string;
|
|
129
|
+
reason?: string;
|
|
130
|
+
}
|
|
131
|
+
interface CoverageInsight extends CoverageInsightRequest {
|
|
132
|
+
id: string;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
suggestedTests?: CoverageSuggestedTest[] | null;
|
|
135
|
+
}
|
|
91
136
|
interface ApiResponse<T> {
|
|
92
137
|
data?: T;
|
|
93
138
|
error?: string;
|
|
@@ -132,6 +177,7 @@ declare class CodmirClient {
|
|
|
132
177
|
private readonly config;
|
|
133
178
|
readonly tickets: TicketsAPI;
|
|
134
179
|
readonly testCases: TestCasesAPI;
|
|
180
|
+
readonly testing: TestingAPI;
|
|
135
181
|
constructor(config: CodmirClientConfig);
|
|
136
182
|
/**
|
|
137
183
|
* Make an HTTP request to the codmir API
|
|
@@ -216,5 +262,34 @@ declare class TestCasesAPI {
|
|
|
216
262
|
*/
|
|
217
263
|
delete(projectId: string, testCaseId: string | number): Promise<void>;
|
|
218
264
|
}
|
|
265
|
+
declare class TestingAPI {
|
|
266
|
+
private config;
|
|
267
|
+
constructor(config: Required<CodmirClientConfig>);
|
|
268
|
+
private request;
|
|
269
|
+
submitTestRun(payload: TestRunSummaryInput): Promise<{
|
|
270
|
+
run: TestRunRecord;
|
|
271
|
+
summary: {
|
|
272
|
+
framework: string;
|
|
273
|
+
passRate: number;
|
|
274
|
+
totalDurationMs: number;
|
|
275
|
+
};
|
|
276
|
+
}>;
|
|
277
|
+
listTestRuns(projectId: string, options?: {
|
|
278
|
+
limit?: number;
|
|
279
|
+
suite?: string;
|
|
280
|
+
}): Promise<TestRunRecord[]>;
|
|
281
|
+
requestCoverageInsight(payload: CoverageInsightRequest): Promise<{
|
|
282
|
+
report: CoverageInsight;
|
|
283
|
+
insights: {
|
|
284
|
+
coverageGauge: number;
|
|
285
|
+
featureBreakdown?: CoverageInsightRequest['features'];
|
|
286
|
+
suggestedTests: {
|
|
287
|
+
title: string;
|
|
288
|
+
reason?: string;
|
|
289
|
+
}[];
|
|
290
|
+
};
|
|
291
|
+
}>;
|
|
292
|
+
listCoverageInsights(projectId: string, limit?: number): Promise<CoverageInsight[]>;
|
|
293
|
+
}
|
|
219
294
|
|
|
220
|
-
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
|
295
|
+
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CoverageFeatureBreakdown, type CoverageInsight, type CoverageInsightRequest, type CoverageSuggestedTest, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type TestRunArtifact, type TestRunRecord, type TestRunSummaryInput, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var CodmirClient = class {
|
|
|
35
35
|
};
|
|
36
36
|
this.tickets = new TicketsAPI(this.config);
|
|
37
37
|
this.testCases = new TestCasesAPI(this.config);
|
|
38
|
+
this.testing = new TestingAPI(this.config);
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Make an HTTP request to the codmir API
|
|
@@ -293,6 +294,75 @@ var TestCasesAPI = class {
|
|
|
293
294
|
);
|
|
294
295
|
}
|
|
295
296
|
};
|
|
297
|
+
var TestingAPI = class {
|
|
298
|
+
constructor(config) {
|
|
299
|
+
this.config = config;
|
|
300
|
+
}
|
|
301
|
+
async request(method, path, body) {
|
|
302
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
303
|
+
const headers = {
|
|
304
|
+
"Content-Type": "application/json",
|
|
305
|
+
...this.config.headers
|
|
306
|
+
};
|
|
307
|
+
if (this.config.apiKey) {
|
|
308
|
+
headers["X-API-Key"] = this.config.apiKey;
|
|
309
|
+
}
|
|
310
|
+
const controller = new AbortController();
|
|
311
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
312
|
+
try {
|
|
313
|
+
const response = await fetch(url, {
|
|
314
|
+
method,
|
|
315
|
+
headers,
|
|
316
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
317
|
+
signal: controller.signal
|
|
318
|
+
});
|
|
319
|
+
clearTimeout(timeoutId);
|
|
320
|
+
if (!response.ok) {
|
|
321
|
+
const errorData = await response.json().catch(() => ({}));
|
|
322
|
+
const error = new Error(errorData.error || `HTTP ${response.status}`);
|
|
323
|
+
error.statusCode = response.status;
|
|
324
|
+
error.response = errorData;
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
if (response.status === 204) {
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
330
|
+
return await response.json();
|
|
331
|
+
} catch (error) {
|
|
332
|
+
clearTimeout(timeoutId);
|
|
333
|
+
if (error.name === "AbortError") {
|
|
334
|
+
const timeoutError = new Error("Request timeout");
|
|
335
|
+
timeoutError.statusCode = 408;
|
|
336
|
+
throw timeoutError;
|
|
337
|
+
}
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async submitTestRun(payload) {
|
|
342
|
+
return this.request("POST", "/api/testing/test-runs", payload);
|
|
343
|
+
}
|
|
344
|
+
async listTestRuns(projectId, options) {
|
|
345
|
+
const params = new URLSearchParams({ projectId });
|
|
346
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
347
|
+
if (options?.suite) params.set("suite", options.suite);
|
|
348
|
+
const response = await this.request(
|
|
349
|
+
"GET",
|
|
350
|
+
`/api/testing/test-runs?${params.toString()}`
|
|
351
|
+
);
|
|
352
|
+
return response.runs || [];
|
|
353
|
+
}
|
|
354
|
+
async requestCoverageInsight(payload) {
|
|
355
|
+
return this.request("POST", "/api/testing/coverage-insight", payload);
|
|
356
|
+
}
|
|
357
|
+
async listCoverageInsights(projectId, limit = 5) {
|
|
358
|
+
const params = new URLSearchParams({ projectId, limit: String(limit) });
|
|
359
|
+
const response = await this.request(
|
|
360
|
+
"GET",
|
|
361
|
+
`/api/testing/coverage-insight?${params.toString()}`
|
|
362
|
+
);
|
|
363
|
+
return response.reports || [];
|
|
364
|
+
}
|
|
365
|
+
};
|
|
296
366
|
// Annotate the CommonJS export names for ESM import in node:
|
|
297
367
|
0 && (module.exports = {
|
|
298
368
|
CodmirClient
|