Commit 6b45c80
feat(hooks): token optimization — dedup, auto-route, prewarm, script-suggest (#14)
* feat(teleop): add native voice control prototype
* feat(cli): add scaffold command for Company OS folder structure
stackmemory scaffold creates company/, wiki/, skills/, clients/, raw/,
and .stackmemory/config.yml. Enables local context management with
file-based skill rot detection and tenant isolation.
* feat(daemon): add opt-out telemetry service
New DaemonTelemetryService collects anonymous usage snapshots:
- Daemon health (uptime, context saves, memory triggers, errors)
- Session counts (total heartbeats, active now)
- Skill audit entries, handoff counts
- No PII — instance ID is random hex
Runs daily (default 24h interval, first at boot+30s).
Stores rolling 90-snapshot history in ~/.stackmemory/telemetry.json.
Opt out: STACKMEMORY_TELEMETRY=0 or telemetry.enabled: false in config.
* feat(hooks): add self-healing daemon health check for SessionStart
* feat(daemon): add desire-path detector — auto-discover workflows, suggest skills
Three-component system in DaemonDesirePathService:
1. ActionStreamLogger — PostToolUse hook captures tool:target pairs
to ~/.stackmemory/desire-paths/action-stream.jsonl (no data/content)
2. PatternDetector — sliding window extracts repeated sequences,
filters by min 3 occurrences across 2+ sessions, scores by freq×sessions
3. SkillSuggester — generates skill.md files from top patterns with
inputs/outputs inferred from sequence endpoints
- 10MB JSONL rotation, 10K entry scan cap for performance
- Opt out: STACKMEMORY_DESIRE_PATHS=0 or desirePaths.enabled: false
- Scans every 6h, first at boot+2m
- Suggestions written to ~/.stackmemory/desire-paths/suggestions/
- 3 adversarial review rounds: fixed separator injection, added scan cap,
improved skill naming with target directory context
* fix(desire-paths): adaptive backoff — hourly when active, exponential to 12h when idle
* feat(cli): add hermes-sm wrapper with StackMemory integration
- Auto-starts daemon on session boot
- Writes session heartbeats for telemetry tracking
- Restores handoff context from previous sessions
- Sets STACKMEMORY_SESSION env for desire-path hook
- Determinism watcher + tracing
- bin/hermes-sm and bin/hermes-smd registered in package.json
* feat(desire-paths): auto-promote skills above 0.8 confidence + 5 sessions
* feat(daemon): add research stream scanner for market signal detection
* fix(test): replace bun:test import with vitest in desire-path-service test
* feat(tokens): replace char/4 heuristic with js-tiktoken (cl100k_base)
Centralizes token estimation across 14 files through
src/core/cache/token-estimator.ts and packages/sdk/src/token-estimator.ts.
Lazy-loads cl100k_base encoder with char/4 fallback if WASM fails.
Also ports context-budget hook to codex-sm exit handler for
compact/restart nudges matching Claude Code behavior.
* feat(skill-packs): add content licenses (CC-BY-4.0) to registry metadata
Skills are often prompt text (content) not code — content licenses like
CC-BY-4.0 fit better than MIT for these. Adds KnownLicenseSchema enum
with both code (MIT, Apache-2.0, ISC, BSD) and content (CC-BY-4.0,
CC-BY-SA-4.0, CC0-1.0) licenses while keeping the field open for custom
SPDX identifiers.
* feat(tasks): add local-first master-tasks.md task management
Markdown table parser + CLI commands + MCP tools for local-first task
steering. Tasks live in master-tasks.md, optionally sync to Linear/GH.
- Parser: parse/serialize/update/add/getNext for pipe-delimited md tables
- CLI: stackmemory tasks init/md list/md next/md add/md update
- MCP: get_next_master_task, update_master_task, create_master_task
- 19 tests covering parse, round-trip, priority sorting, file ops
* feat(hooks): token optimization — dedup escalation, auto-route, prewarm, script-suggest
- dedup-reads: escalate to [STOP] at 5+ reads (was soft-only at 3+)
- desire-path-hook: auto-route Bash→Glob/Read/Grep with inline suggestions
- prewarm-tools: SessionStart hook emits top deferred tool pre-fetch hint
- script-suggest: detects multi-tool patterns matching existing scripts
* feat(bench): add hook benchmark script + baseline report
Replays 7,589 action-stream entries through hook logic.
Result: 324K token savings projected (22% waste reduction).
---------
Co-authored-by: StackMemory Bot (CLI) <bot@stackmemory.ai>1 parent 8d59fb0 commit 6b45c80
56 files changed
Lines changed: 4717 additions & 109 deletions
File tree
- apps/teleop-native
- Sources
- TeleopMac
- TeleopUI
- bin
- docs
- packages/sdk
- src
- __tests__
- scripts
- src
- cli
- commands
- core
- cache
- context
- retrieval
- skill-packs
- __tests__
- tasks
- __tests__
- daemon
- services
- __tests__
- features/tasks
- hooks
- integrations
- anthropic
- claude-code
- mcp
- ralph
- context
- patterns
- orchestrators/multimodal
- skills
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 135 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments