Repository navigation
Commit 5e09518
committed
fix(mcode-island): the pill never renders raw tool JSON (round-20 #6)
The running-state message was built as
"$verb " + (ConvertTo-Json $args -Compress) truncated to 60 chars
so the always-on-top pill showed things like
Running {"command":"$ErrorActionPreference=\u0027Continue\u0027\n...
Reading task {"task_id":"bg_0f858500-...","wai...
Escaped quotes, a JSON key, and a truncation that lands mid-token. It was
the noisiest thing on screen and the least informative.
The `done` and `fail` branches were always fine -- they render the verb
alone. Only the `running` branch serialised arguments.
Format-ToolArgs now returns the single most informative field per tool:
command for shell, file_path for read/write/edit, pattern for
grep/glob, query for web_search, url for web_fetch, name for skill,
task_id for the task-output family. Unknown tools get a generic sweep of
the common field names before giving up.
`skill` is not in $TOOL_ACTIONS or $TOOL_FAMILIES, so it always took the
JSON path -- one of the most frequent tools on screen was the least
readable. That is the case that made this worth fixing rather than
tuning.
There is no fallback to JSON. If Format-ToolArgs returns nothing the pill
wears the bare verb: "Using" reads fine, "Using {\"name\":...}" does not.
An unknown tool should degrade to less information, never to a dump.
Also fixes the display of multi-line commands. A PowerShell command is
frequently several lines; the old code collapsed and truncated the whole
thing, so the visible text was usually the middle of a script fragment.
It now takes the first non-empty line.
Redaction is unchanged and still applied on this path -- the summary runs
through Protect-SecretText exactly as the JSON did, so a credential in a
command still cannot reach the pill or island.log by this route.
Tests: 16 new assertions in test-substep-progress.mjs, negative-first.
The blanket rule is asserted per case: no result may contain a JSON key,
an escaped quote, or a \uXXXX sequence. Cases cover bash, multi-line
bash, read/write/edit, grep, glob, web_search, web_fetch, skill,
task_output, an unknown tool with an unrecognised argument shape, and a
bearer token inside a command.
Validation: sub-step suite 47 pass / 0 fail, smoke 116 pass / 0 fail, all
30 .ps1 parse, and the detector still initialises cleanly under Windows
PowerShell 5.1 (exit 0) -- which is the interpreter it runs under in
production, and the one that breaks on a malformed file.
One trap worth recording, because it produced a very misleading failure:
the second parameter is deliberately NOT named `$args`. That is a
reserved automatic variable in PowerShell, and binding a parameter to it
yields the unbound-argument Object[] rather than the object passed in.
The symptom was an empty summary for every single tool, which reads as
"no data" rather than "bad binding". Verified directly:
function T($n, $args) { $args.command }
T bash ([PSCustomObject]@{ command = 'npm test' }) # -> ''1 parent 4876ef1 commit 5e09518
2 files changed
Lines changed: 202 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
449 | 526 | | |
450 | 527 | | |
451 | 528 | | |
| |||
543 | 620 | | |
544 | 621 | | |
545 | 622 | | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
557 | 629 | | |
558 | 630 | | |
559 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
481 | 600 | | |
482 | 601 | | |
483 | 602 | | |
| |||
0 commit comments