Commit df3ee28
fix: add wing param to diary_write/diary_read, derive from transcript path (#659)
* fix: add wing param to diary_write/diary_read, derive from transcript path
Without a wing override, all diary entries from the stop hook land in
wing_session-hook regardless of which project the session is in, making
per-project diary search impossible.
- tool_diary_write(): add optional `wing` param; sanitize and use it when
provided, fall back to wing_{agent_name} when omitted
- tool_diary_read(): add optional `wing` param for filtering by target wing
- TOOLS dict: expose `wing` in input_schema for both diary tools
- hooks_cli: add _wing_from_transcript_path() helper that extracts the
project name from Claude Code paths like
~/.claude/projects/-home-jp-Projects-kiyo-xhci-fix/... → kiyo-xhci-fix
- hook_stop: derive project wing and append wing= hint to block reason so
Claude writes diary entries to the correct per-project wing
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
* fix: sanitize wing param, cross-platform paths, tighten test assertions
Addresses Copilot review feedback on #659.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* fix: wing_ prefix + agent filter on diary_read
Addresses bensig's 2-issue review on this PR.
1. _wing_from_transcript_path() was returning bare project names
(e.g. "myproject") while all existing wings follow the wing_*
convention from AAAK_SPEC. Entries landed in wing="myproject"
while diary_read defaulted to wing="wing_<agent_name>" —
orphaning every diary entry written by the stop hook. Now
returns "wing_<project>" and falls back to "wing_sessions".
2. tool_diary_read() did not include agent_name in the ChromaDB
where filter when a custom wing was provided — any caller with
a shared wing could read entries written by other agents.
Add {"agent": agent_name} to the $and clause. Also flagged by
Qudo and left unresolved until now.
Tests updated to expect the wing_ prefix (6 tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
---------
Co-authored-by: Claude Sonnet 4.6 <[email protected]>1 parent 818b7f4 commit df3ee28
3 files changed
Lines changed: 107 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| 382 | + | |
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
386 | 391 | | |
387 | 392 | | |
388 | 393 | | |
| |||
407 | 412 | | |
408 | 413 | | |
409 | 414 | | |
| 415 | + | |
410 | 416 | | |
411 | 417 | | |
412 | 418 | | |
| |||
481 | 487 | | |
482 | 488 | | |
483 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
484 | 508 | | |
485 | 509 | | |
486 | 510 | | |
| |||
543 | 567 | | |
544 | 568 | | |
545 | 569 | | |
| 570 | + | |
| 571 | + | |
546 | 572 | | |
547 | 573 | | |
548 | 574 | | |
549 | 575 | | |
550 | | - | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
551 | 579 | | |
552 | 580 | | |
553 | 581 | | |
| |||
580 | 608 | | |
581 | 609 | | |
582 | 610 | | |
583 | | - | |
| 611 | + | |
| 612 | + | |
584 | 613 | | |
585 | 614 | | |
586 | 615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
921 | | - | |
| 921 | + | |
922 | 922 | | |
923 | | - | |
924 | | - | |
| 923 | + | |
| 924 | + | |
925 | 925 | | |
926 | 926 | | |
927 | 927 | | |
| |||
932 | 932 | | |
933 | 933 | | |
934 | 934 | | |
935 | | - | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
936 | 939 | | |
937 | 940 | | |
938 | 941 | | |
| |||
987 | 990 | | |
988 | 991 | | |
989 | 992 | | |
990 | | - | |
| 993 | + | |
991 | 994 | | |
992 | 995 | | |
993 | 996 | | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
994 | 1002 | | |
995 | 1003 | | |
996 | 1004 | | |
| 1005 | + | |
| 1006 | + | |
997 | 1007 | | |
998 | 1008 | | |
999 | 1009 | | |
1000 | | - | |
| 1010 | + | |
| 1011 | + | |
1001 | 1012 | | |
1002 | 1013 | | |
1003 | 1014 | | |
1004 | 1015 | | |
1005 | 1016 | | |
1006 | 1017 | | |
1007 | | - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
1008 | 1025 | | |
1009 | 1026 | | |
1010 | 1027 | | |
| |||
1497 | 1514 | | |
1498 | 1515 | | |
1499 | 1516 | | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
1500 | 1521 | | |
1501 | 1522 | | |
1502 | 1523 | | |
| |||
1515 | 1536 | | |
1516 | 1537 | | |
1517 | 1538 | | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
1518 | 1543 | | |
1519 | 1544 | | |
1520 | 1545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
236 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
237 | 258 | | |
238 | 259 | | |
239 | 260 | | |
| |||
281 | 302 | | |
282 | 303 | | |
283 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
284 | 327 | | |
285 | 328 | | |
286 | 329 | | |
| |||
0 commit comments