codetyper-cli 0.1.78 → 0.1.79
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/index.js +369 -57
- package/package.json +1 -1
- package/src/version.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6285,10 +6285,11 @@ var init_boxen = __esm(() => {
|
|
|
6285
6285
|
var STATUS_HINTS, TIME_UNITS, TOKEN_DISPLAY, STATUS_SEPARATOR = " · ", TERMINAL_SEQUENCES, PROGRESS_BAR;
|
|
6286
6286
|
var init_ui = __esm(() => {
|
|
6287
6287
|
STATUS_HINTS = {
|
|
6288
|
-
INTERRUPT: "
|
|
6289
|
-
INTERRUPT_CONFIRM: "ctrl+c again to
|
|
6288
|
+
INTERRUPT: "esc to interrupt",
|
|
6289
|
+
INTERRUPT_CONFIRM: "ctrl+c again to exit",
|
|
6290
6290
|
TOGGLE_TODOS: "ctrl+t to hide todos",
|
|
6291
|
-
TOGGLE_TODOS_SHOW: "ctrl+t to show todos"
|
|
6291
|
+
TOGGLE_TODOS_SHOW: "ctrl+t to show todos",
|
|
6292
|
+
TOGGLE_PLAN: "ctrl+p to toggle plan"
|
|
6292
6293
|
};
|
|
6293
6294
|
TIME_UNITS = {
|
|
6294
6295
|
SECOND: 1000,
|
|
@@ -64839,6 +64840,9 @@ var init_themes = __esm(() => {
|
|
|
64839
64840
|
diffContext: "#808080",
|
|
64840
64841
|
diffHeader: "#ffffff",
|
|
64841
64842
|
diffHunk: "#00ffff",
|
|
64843
|
+
diffLineBgAdded: "#1a3d1a",
|
|
64844
|
+
diffLineBgRemoved: "#3d1a1a",
|
|
64845
|
+
diffLineText: "#ffffff",
|
|
64842
64846
|
roleUser: "#00ffff",
|
|
64843
64847
|
roleAssistant: "#00ff00",
|
|
64844
64848
|
roleSystem: "#ffff00",
|
|
@@ -64881,6 +64885,9 @@ var init_themes = __esm(() => {
|
|
|
64881
64885
|
diffContext: "#6272a4",
|
|
64882
64886
|
diffHeader: "#f8f8f2",
|
|
64883
64887
|
diffHunk: "#8be9fd",
|
|
64888
|
+
diffLineBgAdded: "#1a3d2a",
|
|
64889
|
+
diffLineBgRemoved: "#3d1a2a",
|
|
64890
|
+
diffLineText: "#f8f8f2",
|
|
64884
64891
|
roleUser: "#8be9fd",
|
|
64885
64892
|
roleAssistant: "#50fa7b",
|
|
64886
64893
|
roleSystem: "#f1fa8c",
|
|
@@ -64923,6 +64930,9 @@ var init_themes = __esm(() => {
|
|
|
64923
64930
|
diffContext: "#4c566a",
|
|
64924
64931
|
diffHeader: "#eceff4",
|
|
64925
64932
|
diffHunk: "#81a1c1",
|
|
64933
|
+
diffLineBgAdded: "#2e3d35",
|
|
64934
|
+
diffLineBgRemoved: "#3d2e35",
|
|
64935
|
+
diffLineText: "#eceff4",
|
|
64926
64936
|
roleUser: "#88c0d0",
|
|
64927
64937
|
roleAssistant: "#a3be8c",
|
|
64928
64938
|
roleSystem: "#ebcb8b",
|
|
@@ -64965,6 +64975,9 @@ var init_themes = __esm(() => {
|
|
|
64965
64975
|
diffContext: "#565f89",
|
|
64966
64976
|
diffHeader: "#c0caf5",
|
|
64967
64977
|
diffHunk: "#7dcfff",
|
|
64978
|
+
diffLineBgAdded: "#1a2d1a",
|
|
64979
|
+
diffLineBgRemoved: "#2d1a2a",
|
|
64980
|
+
diffLineText: "#c0caf5",
|
|
64968
64981
|
roleUser: "#7dcfff",
|
|
64969
64982
|
roleAssistant: "#9ece6a",
|
|
64970
64983
|
roleSystem: "#e0af68",
|
|
@@ -65007,6 +65020,9 @@ var init_themes = __esm(() => {
|
|
|
65007
65020
|
diffContext: "#665c54",
|
|
65008
65021
|
diffHeader: "#ebdbb2",
|
|
65009
65022
|
diffHunk: "#8ec07c",
|
|
65023
|
+
diffLineBgAdded: "#3d3a1a",
|
|
65024
|
+
diffLineBgRemoved: "#3d1a1a",
|
|
65025
|
+
diffLineText: "#ebdbb2",
|
|
65010
65026
|
roleUser: "#83a598",
|
|
65011
65027
|
roleAssistant: "#b8bb26",
|
|
65012
65028
|
roleSystem: "#fabd2f",
|
|
@@ -65049,6 +65065,9 @@ var init_themes = __esm(() => {
|
|
|
65049
65065
|
diffContext: "#75715e",
|
|
65050
65066
|
diffHeader: "#f8f8f2",
|
|
65051
65067
|
diffHunk: "#66d9ef",
|
|
65068
|
+
diffLineBgAdded: "#2d3d1a",
|
|
65069
|
+
diffLineBgRemoved: "#3d1a2a",
|
|
65070
|
+
diffLineText: "#f8f8f2",
|
|
65052
65071
|
roleUser: "#66d9ef",
|
|
65053
65072
|
roleAssistant: "#a6e22e",
|
|
65054
65073
|
roleSystem: "#e6db74",
|
|
@@ -65091,6 +65110,9 @@ var init_themes = __esm(() => {
|
|
|
65091
65110
|
diffContext: "#6c7086",
|
|
65092
65111
|
diffHeader: "#cdd6f4",
|
|
65093
65112
|
diffHunk: "#89dceb",
|
|
65113
|
+
diffLineBgAdded: "#1a3d2a",
|
|
65114
|
+
diffLineBgRemoved: "#3d1a2a",
|
|
65115
|
+
diffLineText: "#cdd6f4",
|
|
65094
65116
|
roleUser: "#89dceb",
|
|
65095
65117
|
roleAssistant: "#a6e3a1",
|
|
65096
65118
|
roleSystem: "#f9e2af",
|
|
@@ -65133,6 +65155,9 @@ var init_themes = __esm(() => {
|
|
|
65133
65155
|
diffContext: "#5c6370",
|
|
65134
65156
|
diffHeader: "#abb2bf",
|
|
65135
65157
|
diffHunk: "#56b6c2",
|
|
65158
|
+
diffLineBgAdded: "#2a3d2a",
|
|
65159
|
+
diffLineBgRemoved: "#3d2a2a",
|
|
65160
|
+
diffLineText: "#abb2bf",
|
|
65136
65161
|
roleUser: "#56b6c2",
|
|
65137
65162
|
roleAssistant: "#98c379",
|
|
65138
65163
|
roleSystem: "#e5c07b",
|
|
@@ -65175,6 +65200,9 @@ var init_themes = __esm(() => {
|
|
|
65175
65200
|
diffContext: "#586e75",
|
|
65176
65201
|
diffHeader: "#93a1a1",
|
|
65177
65202
|
diffHunk: "#2aa198",
|
|
65203
|
+
diffLineBgAdded: "#0a2a1a",
|
|
65204
|
+
diffLineBgRemoved: "#2a0a1a",
|
|
65205
|
+
diffLineText: "#93a1a1",
|
|
65178
65206
|
roleUser: "#2aa198",
|
|
65179
65207
|
roleAssistant: "#859900",
|
|
65180
65208
|
roleSystem: "#b58900",
|
|
@@ -65217,6 +65245,9 @@ var init_themes = __esm(() => {
|
|
|
65217
65245
|
diffContext: "#8b949e",
|
|
65218
65246
|
diffHeader: "#c9d1d9",
|
|
65219
65247
|
diffHunk: "#58a6ff",
|
|
65248
|
+
diffLineBgAdded: "#0d2818",
|
|
65249
|
+
diffLineBgRemoved: "#2d0d0d",
|
|
65250
|
+
diffLineText: "#c9d1d9",
|
|
65220
65251
|
roleUser: "#58a6ff",
|
|
65221
65252
|
roleAssistant: "#3fb950",
|
|
65222
65253
|
roleSystem: "#d29922",
|
|
@@ -65259,6 +65290,9 @@ var init_themes = __esm(() => {
|
|
|
65259
65290
|
diffContext: "#6e6a86",
|
|
65260
65291
|
diffHeader: "#e0def4",
|
|
65261
65292
|
diffHunk: "#9ccfd8",
|
|
65293
|
+
diffLineBgAdded: "#1a2a3d",
|
|
65294
|
+
diffLineBgRemoved: "#3d1a2a",
|
|
65295
|
+
diffLineText: "#e0def4",
|
|
65262
65296
|
roleUser: "#9ccfd8",
|
|
65263
65297
|
roleAssistant: "#31748f",
|
|
65264
65298
|
roleSystem: "#f6c177",
|
|
@@ -65301,6 +65335,9 @@ var init_themes = __esm(() => {
|
|
|
65301
65335
|
diffContext: "#727169",
|
|
65302
65336
|
diffHeader: "#dcd7ba",
|
|
65303
65337
|
diffHunk: "#7fb4ca",
|
|
65338
|
+
diffLineBgAdded: "#2a3d2a",
|
|
65339
|
+
diffLineBgRemoved: "#3d2a2a",
|
|
65340
|
+
diffLineText: "#dcd7ba",
|
|
65304
65341
|
roleUser: "#7fb4ca",
|
|
65305
65342
|
roleAssistant: "#98bb6c",
|
|
65306
65343
|
roleSystem: "#dca561",
|
|
@@ -65343,6 +65380,9 @@ var init_themes = __esm(() => {
|
|
|
65343
65380
|
diffContext: "#636e78",
|
|
65344
65381
|
diffHeader: "#bfbdb6",
|
|
65345
65382
|
diffHunk: "#59c2ff",
|
|
65383
|
+
diffLineBgAdded: "#1a3d1a",
|
|
65384
|
+
diffLineBgRemoved: "#3d1a1a",
|
|
65385
|
+
diffLineText: "#bfbdb6",
|
|
65346
65386
|
roleUser: "#59c2ff",
|
|
65347
65387
|
roleAssistant: "#7fd962",
|
|
65348
65388
|
roleSystem: "#ffb454",
|
|
@@ -65385,6 +65425,9 @@ var init_themes = __esm(() => {
|
|
|
65385
65425
|
diffContext: "#666666",
|
|
65386
65426
|
diffHeader: "#f8f8f2",
|
|
65387
65427
|
diffHunk: "#8be9fd",
|
|
65428
|
+
diffLineBgAdded: "#0d2a1a",
|
|
65429
|
+
diffLineBgRemoved: "#2a0d1a",
|
|
65430
|
+
diffLineText: "#f8f8f2",
|
|
65388
65431
|
roleUser: "#8be9fd",
|
|
65389
65432
|
roleAssistant: "#50fa7b",
|
|
65390
65433
|
roleSystem: "#ffb86c",
|
|
@@ -65851,14 +65894,12 @@ var init_app = __esm(async () => {
|
|
|
65851
65894
|
return;
|
|
65852
65895
|
}
|
|
65853
65896
|
const newContent = store.streamingLog.content + content;
|
|
65897
|
+
const logIndex = store.logs.findIndex((l) => l.id === logId2);
|
|
65854
65898
|
batch(() => {
|
|
65855
65899
|
setStore("streamingLog", "content", newContent);
|
|
65856
|
-
|
|
65857
|
-
|
|
65858
|
-
|
|
65859
|
-
log2.content = newContent;
|
|
65860
|
-
}
|
|
65861
|
-
}));
|
|
65900
|
+
if (logIndex !== -1) {
|
|
65901
|
+
setStore("logs", logIndex, "content", newContent);
|
|
65902
|
+
}
|
|
65862
65903
|
});
|
|
65863
65904
|
};
|
|
65864
65905
|
const completeStreaming = () => {
|
|
@@ -65866,19 +65907,18 @@ var init_app = __esm(async () => {
|
|
|
65866
65907
|
return;
|
|
65867
65908
|
}
|
|
65868
65909
|
const logId2 = store.streamingLog.logId;
|
|
65910
|
+
const logIndex = store.logs.findIndex((l) => l.id === logId2);
|
|
65869
65911
|
batch(() => {
|
|
65870
65912
|
setStore("streamingLog", createInitialStreamingState());
|
|
65871
|
-
|
|
65872
|
-
const
|
|
65873
|
-
|
|
65874
|
-
|
|
65875
|
-
|
|
65876
|
-
|
|
65877
|
-
|
|
65878
|
-
|
|
65879
|
-
|
|
65880
|
-
}
|
|
65881
|
-
}));
|
|
65913
|
+
if (logIndex !== -1) {
|
|
65914
|
+
const currentMetadata = store.logs[logIndex].metadata ?? {};
|
|
65915
|
+
setStore("logs", logIndex, "type", "assistant");
|
|
65916
|
+
setStore("logs", logIndex, "metadata", {
|
|
65917
|
+
...currentMetadata,
|
|
65918
|
+
isStreaming: false,
|
|
65919
|
+
streamComplete: true
|
|
65920
|
+
});
|
|
65921
|
+
}
|
|
65882
65922
|
});
|
|
65883
65923
|
};
|
|
65884
65924
|
const cancelStreaming = () => {
|
|
@@ -66551,6 +66591,7 @@ var formatMessages = (messages) => messages.map((msg) => {
|
|
|
66551
66591
|
}
|
|
66552
66592
|
if (delta?.tool_calls) {
|
|
66553
66593
|
for (const tc of delta.tool_calls) {
|
|
66594
|
+
addDebugLog("api", `Tool call chunk: ${JSON.stringify(tc)}`);
|
|
66554
66595
|
onChunk({ type: "tool_call", toolCall: tc });
|
|
66555
66596
|
}
|
|
66556
66597
|
}
|
|
@@ -66773,6 +66814,7 @@ var init_ollama = __esm(() => {
|
|
|
66773
66814
|
};
|
|
66774
66815
|
OLLAMA_TIMEOUTS = {
|
|
66775
66816
|
VALIDATION: 5000,
|
|
66817
|
+
TAGS: 1e4,
|
|
66776
66818
|
CHAT: 120000
|
|
66777
66819
|
};
|
|
66778
66820
|
OLLAMA_CHAT_OPTIONS = {
|
|
@@ -73624,7 +73666,7 @@ var init_semantic_search = __esm(() => {
|
|
|
73624
73666
|
var version_default;
|
|
73625
73667
|
var init_version = __esm(() => {
|
|
73626
73668
|
version_default = {
|
|
73627
|
-
version: "0.1.
|
|
73669
|
+
version: "0.1.79"
|
|
73628
73670
|
};
|
|
73629
73671
|
});
|
|
73630
73672
|
|
|
@@ -75364,10 +75406,19 @@ You are an AUTONOMOUS agent. When given a task:
|
|
|
75364
75406
|
## When to Use Tools Proactively
|
|
75365
75407
|
|
|
75366
75408
|
Before answering questions or making changes, ALWAYS:
|
|
75409
|
+
- **Detect project type first**: Use glob to find config files (tsconfig.json, package.json, pom.xml, Cargo.toml, go.mod)
|
|
75367
75410
|
- **Use glob** to find relevant files when you need to understand project structure
|
|
75368
75411
|
- **Use grep** to search for patterns, function definitions, or implementations
|
|
75369
75412
|
- **Use read** to understand existing code before making changes
|
|
75370
|
-
- **Use bash** for git operations, running tests, builds, and
|
|
75413
|
+
- **Use bash** for git operations, running tests, builds, type-checking, and compiling
|
|
75414
|
+
|
|
75415
|
+
## CRITICAL: Execute Commands When Requested
|
|
75416
|
+
|
|
75417
|
+
When the user explicitly asks you to run a command (e.g., "run tree", "run ls", "execute bash"), you MUST:
|
|
75418
|
+
1. **Actually run the command** using the bash tool - do NOT just explain what it would do
|
|
75419
|
+
2. Show the real output from the command
|
|
75420
|
+
3. Never substitute a command request with a text explanation
|
|
75421
|
+
4. If a command fails, show the actual error
|
|
75371
75422
|
|
|
75372
75423
|
## Examples of Agentic Behavior
|
|
75373
75424
|
|
|
@@ -75398,6 +75449,15 @@ assistant: [Uses grep to find auth middleware]
|
|
|
75398
75449
|
The auth middleware in src/middleware/auth.ts:15 validates JWT tokens and attaches the user object to the request.
|
|
75399
75450
|
</example>
|
|
75400
75451
|
|
|
75452
|
+
<example>
|
|
75453
|
+
user: create tests for the validation module
|
|
75454
|
+
assistant: [Uses read to understand src/utils/validation.ts]
|
|
75455
|
+
[Uses glob to check existing test patterns]
|
|
75456
|
+
[Uses write to create tests/validation.test.ts]
|
|
75457
|
+
[Uses bash to run bun test tests/validation.test.ts]
|
|
75458
|
+
Created tests/validation.test.ts with 12 tests covering all validation functions. All tests pass.
|
|
75459
|
+
</example>
|
|
75460
|
+
|
|
75401
75461
|
# Tone and Style
|
|
75402
75462
|
|
|
75403
75463
|
- Be concise. Keep responses under 4 lines unless the task requires more detail
|
|
@@ -75425,6 +75485,17 @@ assistant: [Uses bash to run ls src/]
|
|
|
75425
75485
|
foo.ts, bar.ts, index.ts
|
|
75426
75486
|
</example>
|
|
75427
75487
|
|
|
75488
|
+
<example>
|
|
75489
|
+
user: run tree to show me the project structure
|
|
75490
|
+
assistant: [Uses bash to run tree -L 2]
|
|
75491
|
+
.
|
|
75492
|
+
├── src
|
|
75493
|
+
│ ├── components
|
|
75494
|
+
│ └── utils
|
|
75495
|
+
├── package.json
|
|
75496
|
+
└── tsconfig.json
|
|
75497
|
+
</example>
|
|
75498
|
+
|
|
75428
75499
|
# Tool Usage Policy
|
|
75429
75500
|
|
|
75430
75501
|
You have access to these tools - use them proactively:
|
|
@@ -75460,7 +75531,81 @@ When performing software engineering tasks:
|
|
|
75460
75531
|
2. **Read existing code**: Understand patterns and conventions before changes
|
|
75461
75532
|
3. **Make incremental changes**: One logical change at a time
|
|
75462
75533
|
4. **Follow conventions**: Match existing code style and patterns
|
|
75463
|
-
5. **
|
|
75534
|
+
5. **ALWAYS verify your work**: Run tests, builds, or linters to confirm changes work
|
|
75535
|
+
|
|
75536
|
+
## CRITICAL: Always Verify Your Work
|
|
75537
|
+
|
|
75538
|
+
### Step 1: Understand Project Context
|
|
75539
|
+
Before making changes, detect the project type by checking for config files:
|
|
75540
|
+
- \`tsconfig.json\` → TypeScript project → validate with \`tsc --noEmit\` or \`npx tsc --noEmit\`
|
|
75541
|
+
- \`package.json\` → Node.js project → check scripts for test/build commands
|
|
75542
|
+
- \`pom.xml\` → Java Maven → validate with \`mvn compile\`
|
|
75543
|
+
- \`build.gradle\` → Java Gradle → validate with \`./gradlew build\`
|
|
75544
|
+
- \`Cargo.toml\` → Rust → validate with \`cargo check\`
|
|
75545
|
+
- \`go.mod\` → Go → validate with \`go build ./...\`
|
|
75546
|
+
- \`pyproject.toml\` or \`setup.py\` → Python → validate with \`python -m py_compile\`
|
|
75547
|
+
|
|
75548
|
+
If you haven't examined the project structure yet, do it first with glob/read.
|
|
75549
|
+
|
|
75550
|
+
### Step 2: Validate After Every Change
|
|
75551
|
+
After creating or modifying code, you MUST run the appropriate validation:
|
|
75552
|
+
|
|
75553
|
+
| Project Type | Validation Command |
|
|
75554
|
+
|--------------|-------------------|
|
|
75555
|
+
| TypeScript | \`tsc --noEmit\` or \`bun build --dry-run\` |
|
|
75556
|
+
| JavaScript | \`node --check <file>\` or run tests |
|
|
75557
|
+
| Java | \`mvn compile\` or \`./gradlew compileJava\` |
|
|
75558
|
+
| Rust | \`cargo check\` |
|
|
75559
|
+
| Go | \`go build ./...\` |
|
|
75560
|
+
| Python | \`python -m py_compile <file>\` |
|
|
75561
|
+
|
|
75562
|
+
### Step 3: Run Tests
|
|
75563
|
+
- **Created tests?** → Run them immediately
|
|
75564
|
+
- **Modified code?** → Run existing tests to ensure nothing broke
|
|
75565
|
+
- **Added new feature?** → Test it manually or run relevant test suites
|
|
75566
|
+
|
|
75567
|
+
NEVER say "let me know if you want me to run the tests" - just run them yourself.
|
|
75568
|
+
NEVER leave work unverified. Complete the full loop: create → type-check → test → confirm.
|
|
75569
|
+
|
|
75570
|
+
### Validation Order (TypeScript Projects)
|
|
75571
|
+
For TypeScript projects, ALWAYS run in this order:
|
|
75572
|
+
1. \`tsc --noEmit\` - Catch type errors first
|
|
75573
|
+
2. \`bun test <file>\` or \`npm test\` - Run tests
|
|
75574
|
+
3. If either fails, fix and re-run both
|
|
75575
|
+
|
|
75576
|
+
<example>
|
|
75577
|
+
user: create a utility function for string formatting
|
|
75578
|
+
assistant: [Uses glob to find tsconfig.json - confirms TypeScript project]
|
|
75579
|
+
[Uses read to understand existing utils]
|
|
75580
|
+
[Uses write to create src/utils/format.ts]
|
|
75581
|
+
[Uses bash: tsc --noEmit] → No errors
|
|
75582
|
+
[Uses write to create tests/format.test.ts]
|
|
75583
|
+
[Uses bash: bun test tests/format.test.ts] → 8 tests pass
|
|
75584
|
+
Created format.ts with formatCurrency, formatDate, formatNumber. Types check. All 8 tests pass.
|
|
75585
|
+
</example>
|
|
75586
|
+
|
|
75587
|
+
<example>
|
|
75588
|
+
user: add a new field to the User type
|
|
75589
|
+
assistant: [Uses glob to find tsconfig.json - TypeScript project]
|
|
75590
|
+
[Uses read to examine src/types/user.ts]
|
|
75591
|
+
[Uses edit to add the new field]
|
|
75592
|
+
[Uses bash: tsc --noEmit] → Error: Property 'newField' missing in 3 files
|
|
75593
|
+
[Uses edit to fix src/services/user.ts]
|
|
75594
|
+
[Uses edit to fix src/api/users.ts]
|
|
75595
|
+
[Uses bash: tsc --noEmit] → No errors
|
|
75596
|
+
[Uses bash: bun test] → All tests pass
|
|
75597
|
+
Added 'email' field to User type. Fixed 3 files that needed the new field. Types check. Tests pass.
|
|
75598
|
+
</example>
|
|
75599
|
+
|
|
75600
|
+
<example>
|
|
75601
|
+
user: fix the bug in UserService.java
|
|
75602
|
+
assistant: [Uses glob to find pom.xml - confirms Maven project]
|
|
75603
|
+
[Uses read to examine UserService.java]
|
|
75604
|
+
[Uses edit to fix the bug]
|
|
75605
|
+
[Uses bash: mvn compile] → BUILD SUCCESS
|
|
75606
|
+
[Uses bash: mvn test -Dtest=UserServiceTest] → Tests pass
|
|
75607
|
+
Fixed null pointer in UserService.java:45. Compiles successfully. Tests pass.
|
|
75608
|
+
</example>
|
|
75464
75609
|
|
|
75465
75610
|
## Task Tracking
|
|
75466
75611
|
|
|
@@ -93582,6 +93727,7 @@ async function refreshMCPTools() {
|
|
|
93582
93727
|
|
|
93583
93728
|
// src/constants/agent.ts
|
|
93584
93729
|
var MAX_ITERATIONS = 50;
|
|
93730
|
+
var MAX_CONSECUTIVE_ERRORS = 3;
|
|
93585
93731
|
|
|
93586
93732
|
// src/types/streaming.ts
|
|
93587
93733
|
var createStreamAccumulator = () => ({
|
|
@@ -93611,26 +93757,30 @@ var processStreamChunk = (chunk2, accumulator, callbacks) => {
|
|
|
93611
93757
|
if (!chunk2.toolCall)
|
|
93612
93758
|
return;
|
|
93613
93759
|
const tc = chunk2.toolCall;
|
|
93614
|
-
const
|
|
93615
|
-
let partial2 = accumulator.toolCalls.get(
|
|
93616
|
-
if (!partial2
|
|
93760
|
+
const chunkIndex = tc.index ?? (tc.id ? getToolCallIndex(tc.id, accumulator) : 0);
|
|
93761
|
+
let partial2 = accumulator.toolCalls.get(chunkIndex);
|
|
93762
|
+
if (!partial2) {
|
|
93617
93763
|
partial2 = {
|
|
93618
|
-
index,
|
|
93619
|
-
id: tc.id
|
|
93764
|
+
index: chunkIndex,
|
|
93765
|
+
id: tc.id ?? `tool_${chunkIndex}_${Date.now()}`,
|
|
93620
93766
|
name: tc.function?.name ?? "",
|
|
93621
93767
|
argumentsBuffer: "",
|
|
93622
93768
|
isComplete: false
|
|
93623
93769
|
};
|
|
93624
|
-
accumulator.toolCalls.set(
|
|
93770
|
+
accumulator.toolCalls.set(chunkIndex, partial2);
|
|
93771
|
+
if (tc.id) {
|
|
93772
|
+
callbacks.onToolCallStart?.(partial2);
|
|
93773
|
+
}
|
|
93774
|
+
}
|
|
93775
|
+
if (tc.id && partial2.id.startsWith("tool_")) {
|
|
93776
|
+
partial2.id = tc.id;
|
|
93625
93777
|
callbacks.onToolCallStart?.(partial2);
|
|
93626
93778
|
}
|
|
93627
|
-
if (
|
|
93628
|
-
|
|
93629
|
-
|
|
93630
|
-
|
|
93631
|
-
|
|
93632
|
-
partial2.argumentsBuffer += tc.function.arguments;
|
|
93633
|
-
}
|
|
93779
|
+
if (tc.function?.name) {
|
|
93780
|
+
partial2.name = tc.function.name;
|
|
93781
|
+
}
|
|
93782
|
+
if (tc.function?.arguments) {
|
|
93783
|
+
partial2.argumentsBuffer += tc.function.arguments;
|
|
93634
93784
|
}
|
|
93635
93785
|
},
|
|
93636
93786
|
model_switched: () => {
|
|
@@ -93672,10 +93822,19 @@ var getToolCallIndex = (id, accumulator) => {
|
|
|
93672
93822
|
};
|
|
93673
93823
|
var finalizeToolCall = (partial2) => {
|
|
93674
93824
|
let args = {};
|
|
93675
|
-
|
|
93676
|
-
|
|
93677
|
-
|
|
93678
|
-
|
|
93825
|
+
const rawBuffer = partial2.argumentsBuffer || "";
|
|
93826
|
+
if (!rawBuffer) {
|
|
93827
|
+
args = { __debug_error: "Empty arguments buffer" };
|
|
93828
|
+
} else {
|
|
93829
|
+
try {
|
|
93830
|
+
args = JSON.parse(rawBuffer);
|
|
93831
|
+
} catch (e) {
|
|
93832
|
+
args = {
|
|
93833
|
+
__debug_error: "JSON parse failed",
|
|
93834
|
+
__debug_buffer: rawBuffer.substring(0, 200),
|
|
93835
|
+
__debug_parseError: e instanceof Error ? e.message : String(e)
|
|
93836
|
+
};
|
|
93837
|
+
}
|
|
93679
93838
|
}
|
|
93680
93839
|
return {
|
|
93681
93840
|
id: partial2.id,
|
|
@@ -93705,12 +93864,14 @@ var executeTool = async (state3, toolCall2) => {
|
|
|
93705
93864
|
const validatedArgs = tool.parameters.parse(toolCall2.arguments);
|
|
93706
93865
|
return await tool.execute(validatedArgs, ctx);
|
|
93707
93866
|
} catch (error49) {
|
|
93867
|
+
const receivedArgs = JSON.stringify(toolCall2.arguments);
|
|
93708
93868
|
const errorMessage2 = error49 instanceof Error ? error49.message : String(error49);
|
|
93709
93869
|
return {
|
|
93710
93870
|
success: false,
|
|
93711
|
-
title: "Tool error",
|
|
93871
|
+
title: "Tool validation error",
|
|
93712
93872
|
output: "",
|
|
93713
|
-
error: errorMessage2
|
|
93873
|
+
error: `${toolCall2.name}: ${errorMessage2}
|
|
93874
|
+
Received: ${receivedArgs}`
|
|
93714
93875
|
};
|
|
93715
93876
|
}
|
|
93716
93877
|
};
|
|
@@ -93761,6 +93922,7 @@ var runAgentLoopStream = async (state3, messages) => {
|
|
|
93761
93922
|
const allToolCalls = [];
|
|
93762
93923
|
let iterations = 0;
|
|
93763
93924
|
let finalResponse = "";
|
|
93925
|
+
let consecutiveErrors = 0;
|
|
93764
93926
|
await initializePermissions();
|
|
93765
93927
|
await refreshMCPTools();
|
|
93766
93928
|
const agentMessages = [...messages];
|
|
@@ -93785,11 +93947,16 @@ var runAgentLoopStream = async (state3, messages) => {
|
|
|
93785
93947
|
if (response2.content) {
|
|
93786
93948
|
state3.options.onText?.(response2.content);
|
|
93787
93949
|
}
|
|
93950
|
+
let allFailed = true;
|
|
93788
93951
|
for (const toolCall2 of response2.toolCalls) {
|
|
93789
93952
|
state3.options.onToolCall?.(toolCall2);
|
|
93790
93953
|
const result = await executeTool(state3, toolCall2);
|
|
93791
93954
|
allToolCalls.push({ call: toolCall2, result });
|
|
93792
93955
|
state3.options.onToolResult?.(toolCall2.id, result);
|
|
93956
|
+
if (result.success) {
|
|
93957
|
+
allFailed = false;
|
|
93958
|
+
consecutiveErrors = 0;
|
|
93959
|
+
}
|
|
93793
93960
|
const toolResultMessage = {
|
|
93794
93961
|
role: "tool",
|
|
93795
93962
|
tool_call_id: toolCall2.id,
|
|
@@ -93799,6 +93966,19 @@ ${result.output}` : result.output
|
|
|
93799
93966
|
};
|
|
93800
93967
|
agentMessages.push(toolResultMessage);
|
|
93801
93968
|
}
|
|
93969
|
+
if (allFailed) {
|
|
93970
|
+
consecutiveErrors++;
|
|
93971
|
+
if (consecutiveErrors >= MAX_CONSECUTIVE_ERRORS) {
|
|
93972
|
+
const errorMsg = `Stopping: ${consecutiveErrors} consecutive tool errors. Check model compatibility with tool calling.`;
|
|
93973
|
+
state3.options.onError?.(errorMsg);
|
|
93974
|
+
return {
|
|
93975
|
+
success: false,
|
|
93976
|
+
finalResponse: errorMsg,
|
|
93977
|
+
iterations,
|
|
93978
|
+
toolCalls: allToolCalls
|
|
93979
|
+
};
|
|
93980
|
+
}
|
|
93981
|
+
}
|
|
93802
93982
|
} else {
|
|
93803
93983
|
finalResponse = response2.content || "";
|
|
93804
93984
|
state3.options.onText?.(finalResponse);
|
|
@@ -95732,6 +95912,100 @@ var parseAuditResponse = (response2) => {
|
|
|
95732
95912
|
// src/services/chat-tui/message-handler.ts
|
|
95733
95913
|
await init_chat3();
|
|
95734
95914
|
await init_debug_log_panel();
|
|
95915
|
+
|
|
95916
|
+
// src/services/command-detection.ts
|
|
95917
|
+
var COMMAND_PATTERNS = [
|
|
95918
|
+
/^run\s+(.+)$/i,
|
|
95919
|
+
/^execute\s+(.+)$/i,
|
|
95920
|
+
/^exec\s+(.+)$/i,
|
|
95921
|
+
/^run\s+(?:a\s+|the\s+)?(.+?)\s+command$/i,
|
|
95922
|
+
/^use\s+(\S+)\s+to\s+/i,
|
|
95923
|
+
/^show\s+me\s+(?:the\s+)?(?:output\s+of\s+)?(.+)$/i,
|
|
95924
|
+
/^(?:can\s+you\s+)?(?:please\s+)?run\s+(.+?)(?:\s+for\s+me)?$/i
|
|
95925
|
+
];
|
|
95926
|
+
var DIRECT_COMMANDS = new Set([
|
|
95927
|
+
"ls",
|
|
95928
|
+
"tree",
|
|
95929
|
+
"pwd",
|
|
95930
|
+
"cat",
|
|
95931
|
+
"head",
|
|
95932
|
+
"tail",
|
|
95933
|
+
"find",
|
|
95934
|
+
"grep",
|
|
95935
|
+
"wc",
|
|
95936
|
+
"du",
|
|
95937
|
+
"df",
|
|
95938
|
+
"ps",
|
|
95939
|
+
"top",
|
|
95940
|
+
"which",
|
|
95941
|
+
"whoami",
|
|
95942
|
+
"date",
|
|
95943
|
+
"echo",
|
|
95944
|
+
"env",
|
|
95945
|
+
"printenv",
|
|
95946
|
+
"uname"
|
|
95947
|
+
]);
|
|
95948
|
+
var detectCommand = (message2) => {
|
|
95949
|
+
const trimmed = message2.trim();
|
|
95950
|
+
for (const pattern of COMMAND_PATTERNS) {
|
|
95951
|
+
const match = trimmed.match(pattern);
|
|
95952
|
+
if (match) {
|
|
95953
|
+
const command = match[1].trim();
|
|
95954
|
+
if (command && command.length > 0 && command.length < 500) {
|
|
95955
|
+
return {
|
|
95956
|
+
detected: true,
|
|
95957
|
+
command: normalizeCommand(command),
|
|
95958
|
+
originalMessage: message2
|
|
95959
|
+
};
|
|
95960
|
+
}
|
|
95961
|
+
}
|
|
95962
|
+
}
|
|
95963
|
+
const firstWord = trimmed.split(/\s+/)[0].toLowerCase();
|
|
95964
|
+
if (DIRECT_COMMANDS.has(firstWord)) {
|
|
95965
|
+
return {
|
|
95966
|
+
detected: true,
|
|
95967
|
+
command: trimmed,
|
|
95968
|
+
originalMessage: message2
|
|
95969
|
+
};
|
|
95970
|
+
}
|
|
95971
|
+
return {
|
|
95972
|
+
detected: false,
|
|
95973
|
+
originalMessage: message2
|
|
95974
|
+
};
|
|
95975
|
+
};
|
|
95976
|
+
var normalizeCommand = (command) => {
|
|
95977
|
+
if (command.startsWith('"') && command.endsWith('"') || command.startsWith("'") && command.endsWith("'")) {
|
|
95978
|
+
command = command.slice(1, -1);
|
|
95979
|
+
}
|
|
95980
|
+
if (command.endsWith(" command")) {
|
|
95981
|
+
command = command.slice(0, -8).trim();
|
|
95982
|
+
}
|
|
95983
|
+
if (command.startsWith("the ")) {
|
|
95984
|
+
command = command.slice(4);
|
|
95985
|
+
}
|
|
95986
|
+
if (command.startsWith("a ")) {
|
|
95987
|
+
command = command.slice(2);
|
|
95988
|
+
}
|
|
95989
|
+
return command;
|
|
95990
|
+
};
|
|
95991
|
+
var executeDetectedCommand = async (command, workingDir3, abortController) => {
|
|
95992
|
+
const ctx = {
|
|
95993
|
+
sessionId: v4_default(),
|
|
95994
|
+
messageId: v4_default(),
|
|
95995
|
+
workingDir: workingDir3,
|
|
95996
|
+
abort: abortController ?? new AbortController,
|
|
95997
|
+
autoApprove: true,
|
|
95998
|
+
onMetadata: () => {}
|
|
95999
|
+
};
|
|
96000
|
+
const result = await executeBash({ command }, ctx);
|
|
96001
|
+
return {
|
|
96002
|
+
success: result.success,
|
|
96003
|
+
output: result.output,
|
|
96004
|
+
error: result.error
|
|
96005
|
+
};
|
|
96006
|
+
};
|
|
96007
|
+
|
|
96008
|
+
// src/services/chat-tui/message-handler.ts
|
|
95735
96009
|
var lastResponseContext = null;
|
|
95736
96010
|
var currentAgent = null;
|
|
95737
96011
|
var abortCurrentOperation = () => {
|
|
@@ -95801,8 +96075,7 @@ var createStreamCallbacks = () => {
|
|
|
95801
96075
|
});
|
|
95802
96076
|
},
|
|
95803
96077
|
onComplete: () => {
|
|
95804
|
-
addDebugLog("stream", `Stream
|
|
95805
|
-
appStore.completeStreaming();
|
|
96078
|
+
addDebugLog("stream", `Stream iteration done (${chunkCount} chunks total)`);
|
|
95806
96079
|
},
|
|
95807
96080
|
onError: (error49) => {
|
|
95808
96081
|
addDebugLog("error", `Stream error: ${error49}`);
|
|
@@ -95854,6 +96127,39 @@ var checkUserFeedback = async (message2, callbacks) => {
|
|
|
95854
96127
|
};
|
|
95855
96128
|
var handleMessage = async (state3, message2, callbacks) => {
|
|
95856
96129
|
await checkUserFeedback(message2, callbacks);
|
|
96130
|
+
const detected = detectCommand(message2);
|
|
96131
|
+
if (detected.detected && detected.command) {
|
|
96132
|
+
addDebugLog("info", `Detected command: ${detected.command}`);
|
|
96133
|
+
appStore.addLog({
|
|
96134
|
+
type: "user",
|
|
96135
|
+
content: message2
|
|
96136
|
+
});
|
|
96137
|
+
appStore.addLog({
|
|
96138
|
+
type: "tool",
|
|
96139
|
+
content: detected.command,
|
|
96140
|
+
metadata: {
|
|
96141
|
+
toolName: "bash",
|
|
96142
|
+
toolStatus: "running",
|
|
96143
|
+
toolDescription: `Running: ${detected.command}`
|
|
96144
|
+
}
|
|
96145
|
+
});
|
|
96146
|
+
appStore.setMode("tool_execution");
|
|
96147
|
+
const result = await executeDetectedCommand(detected.command, process.cwd());
|
|
96148
|
+
appStore.setMode("idle");
|
|
96149
|
+
if (result.success && result.output) {
|
|
96150
|
+
appStore.addLog({
|
|
96151
|
+
type: "assistant",
|
|
96152
|
+
content: result.output
|
|
96153
|
+
});
|
|
96154
|
+
} else if (!result.success) {
|
|
96155
|
+
appStore.addLog({
|
|
96156
|
+
type: "error",
|
|
96157
|
+
content: result.error || "Command failed"
|
|
96158
|
+
});
|
|
96159
|
+
}
|
|
96160
|
+
await saveSession();
|
|
96161
|
+
return;
|
|
96162
|
+
}
|
|
95857
96163
|
const { interactionMode, cascadeEnabled } = appStore.getState();
|
|
95858
96164
|
const isReadOnlyMode = interactionMode === "ask" || interactionMode === "code-review";
|
|
95859
96165
|
if (isReadOnlyMode) {
|
|
@@ -95949,7 +96255,8 @@ ${commentsContext}` : ""}`;
|
|
|
95949
96255
|
}
|
|
95950
96256
|
}
|
|
95951
96257
|
}
|
|
95952
|
-
|
|
96258
|
+
const effectiveModel = effectiveProvider === state3.provider ? state3.model : getDefaultModel2(effectiveProvider);
|
|
96259
|
+
addDebugLog("state", `Starting request: provider=${effectiveProvider}, model=${effectiveModel}`);
|
|
95953
96260
|
addDebugLog("state", `Mode: ${appStore.getState().interactionMode}, Cascade: ${cascadeEnabled}`);
|
|
95954
96261
|
appStore.setMode("thinking");
|
|
95955
96262
|
appStore.startThinking();
|
|
@@ -95958,7 +96265,7 @@ ${commentsContext}` : ""}`;
|
|
|
95958
96265
|
const streamState = createStreamCallbacks();
|
|
95959
96266
|
const agent = createStreamingAgent(process.cwd(), {
|
|
95960
96267
|
provider: effectiveProvider,
|
|
95961
|
-
model:
|
|
96268
|
+
model: effectiveModel,
|
|
95962
96269
|
verbose: state3.verbose,
|
|
95963
96270
|
autoApprove: state3.autoApprove,
|
|
95964
96271
|
chatMode: isReadOnlyMode,
|
|
@@ -96008,6 +96315,9 @@ ${commentsContext}` : ""}`;
|
|
|
96008
96315
|
type: "assistant",
|
|
96009
96316
|
content: finalResponse
|
|
96010
96317
|
});
|
|
96318
|
+
} else {
|
|
96319
|
+
addDebugLog("info", "Completing streaming with received content");
|
|
96320
|
+
appStore.completeStreaming();
|
|
96011
96321
|
}
|
|
96012
96322
|
addMessage("user", message2);
|
|
96013
96323
|
addMessage("assistant", finalResponse);
|
|
@@ -98902,7 +99212,7 @@ function DiffLine(props) {
|
|
|
98902
99212
|
const theme = useTheme();
|
|
98903
99213
|
const lineColor = () => {
|
|
98904
99214
|
if (props.line.type === "add" || props.line.type === "remove") {
|
|
98905
|
-
return theme.colors.
|
|
99215
|
+
return theme.colors.diffLineText;
|
|
98906
99216
|
}
|
|
98907
99217
|
const colorMap = {
|
|
98908
99218
|
context: theme.colors.diffContext,
|
|
@@ -98925,9 +99235,9 @@ function DiffLine(props) {
|
|
|
98925
99235
|
};
|
|
98926
99236
|
const bgColor = () => {
|
|
98927
99237
|
if (props.line.type === "add")
|
|
98928
|
-
return theme.colors.
|
|
99238
|
+
return theme.colors.diffLineBgAdded;
|
|
98929
99239
|
if (props.line.type === "remove")
|
|
98930
|
-
return theme.colors.
|
|
99240
|
+
return theme.colors.diffLineBgRemoved;
|
|
98931
99241
|
return;
|
|
98932
99242
|
};
|
|
98933
99243
|
return (() => {
|
|
@@ -102547,7 +102857,7 @@ function ErrorFallback(props) {
|
|
|
102547
102857
|
insertNode(_el$2, createTextNode(`Application Error`));
|
|
102548
102858
|
setProp(_el$4, "marginTop", 1);
|
|
102549
102859
|
insert(_el$4, () => props.error.message);
|
|
102550
|
-
insertNode(_el$5, createTextNode(`Press Ctrl+C to exit`));
|
|
102860
|
+
insertNode(_el$5, createTextNode(`Press Ctrl+C twice to exit`));
|
|
102551
102861
|
setProp(_el$5, "marginTop", 2);
|
|
102552
102862
|
effect((_p$) => {
|
|
102553
102863
|
var _v$ = theme.colors.error, _v$2 = TextAttributes.BOLD, _v$3 = theme.colors.error, _v$4 = theme.colors.textDim;
|
|
@@ -102608,18 +102918,20 @@ function AppContent(props) {
|
|
|
102608
102918
|
}, 100);
|
|
102609
102919
|
}
|
|
102610
102920
|
useKeyboard((evt) => {
|
|
102611
|
-
if (evt.
|
|
102612
|
-
if (app.interruptPending()) {
|
|
102613
|
-
exit.exit(0);
|
|
102614
|
-
evt.preventDefault();
|
|
102615
|
-
return;
|
|
102616
|
-
}
|
|
102921
|
+
if (evt.name === "escape") {
|
|
102617
102922
|
const aborted2 = abortCurrentOperation();
|
|
102618
102923
|
if (aborted2) {
|
|
102619
102924
|
toast.info("Operation cancelled");
|
|
102620
102925
|
evt.preventDefault();
|
|
102621
102926
|
return;
|
|
102622
102927
|
}
|
|
102928
|
+
}
|
|
102929
|
+
if (evt.ctrl && evt.name === "c") {
|
|
102930
|
+
if (app.interruptPending()) {
|
|
102931
|
+
exit.exit(0);
|
|
102932
|
+
evt.preventDefault();
|
|
102933
|
+
return;
|
|
102934
|
+
}
|
|
102623
102935
|
app.setInterruptPending(true);
|
|
102624
102936
|
toast.warning("Press Ctrl+C again to exit");
|
|
102625
102937
|
setTimeout(() => {
|
|
@@ -105489,4 +105801,4 @@ ${plan.steps.map((s) => `${s.id}. ${s.description}`).join(`
|
|
|
105489
105801
|
});
|
|
105490
105802
|
program2.parse(process.argv);
|
|
105491
105803
|
|
|
105492
|
-
//# debugId=
|
|
105804
|
+
//# debugId=186053DF86B65DD864756E2164756E21
|
package/package.json
CHANGED
package/src/version.json
CHANGED