Commit 51a1081
authored
* feat: add `icm wake-up` command + `icm_wake_up` MCP tool
Adds a compact critical-facts pack generator for LLM system-prompt
injection, inspired by MemPalace's wake-up command but grounded in ICM's
importance/decay model.
The command selects critical/high memories (plus global preferences)
optionally scoped by project, ranks by importance × recency × weight,
categorizes into Identity / Decisions / Constraints / Errors / Milestones
/ Context sections, and truncates to fit a token budget.
- `icm-core`: new `wake_up` module with pure, testable `build_wake_up()`
and `build_wake_up_from_memories()` APIs. 14 unit tests cover filtering,
project scoping, budget truncation, formatting, and categorization.
- `icm-cli`: new `wake-up` subcommand with `--project`, `--max-tokens`,
`--format markdown|plain`, `--no-preferences`. Auto-detects project
from PWD/git remote; use `--project -` to disable.
- `icm-mcp`: new `icm_wake_up` tool with the same parameters, clamped
token budget [20, 4000]. 7 MCP integration tests cover empty store,
filtering, project scoping, plain format, budget clamping, preference
opt-out, and tool listing.
Total: 21 new tests, all green. Clippy clean.
* refactor(wake-up): address review feedback
- project_matches is now segment-aware: the topic and the project filter
are both split on `-./_:/` and every project segment must appear as a
complete topic segment. Rejects false positives like "icm" matching
"icmp-notes" while still allowing "icm" -> "decisions-icm-core" and
"icm-core" -> "decisions-icm-core".
- compute_score now uses max(created_at, last_accessed) so frequently
recalled memories stay fresh under decay.
- truncate_by_budget and approx_tokens now count chars (not bytes) so
multibyte summaries are not over-penalized and the token count printed
in the header is honest for non-ASCII.
- sanitize_summary flattens newlines and collapses runs of spaces, so a
user-stored summary containing "\n## Fake header" cannot break the
rendered section structure.
- render_body trailing-newline loop fixed (was "\n\n\n" check that never
triggered — now "\n\n").
- cmd_wake_up prints "Project: <detected>" to stderr when auto-detecting,
so users understand why specific topics appear or not.
- tool_wake_up accepts "" and "-" as project-disable sentinels, matching
the CLI.
- build_wake_up_from_memories marked #[must_use].
- +6 new unit tests covering segment matching, include_preferences=false,
multiline sanitization, multibyte budget, access-aware recency, and
plain format header suppression (20 core tests total).
1 parent 34b6c88 commit 51a1081
File tree
4 files changed
+1026
-4
lines changed- crates
- icm-cli/src
- icm-core/src
- icm-mcp/src
4 files changed
+1026
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
282 | 306 | | |
283 | 307 | | |
284 | 308 | | |
| |||
633 | 657 | | |
634 | 658 | | |
635 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
636 | 675 | | |
637 | 676 | | |
638 | 677 | | |
| |||
923 | 962 | | |
924 | 963 | | |
925 | 964 | | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
926 | 971 | | |
927 | 972 | | |
928 | 973 | | |
| |||
2578 | 2623 | | |
2579 | 2624 | | |
2580 | 2625 | | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
2581 | 2668 | | |
2582 | 2669 | | |
2583 | 2670 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
0 commit comments