Skip to content

Commit 3028726

Browse files
committed
feat: close last two caveman gaps
skills/tok-compress/SKILL.md Previously advertised in skills/tok-help/SKILL.md:32 and routed in hooks/tok-mode-tracker.js:58, but the SKILL.md itself was missing — /tok-compress invocations had no skill to load. Added. Points Claude at the existing `tok md` CLI (deterministic, offline) instead of calling out to a separate Python pipeline like caveman-compress does. tok cheatsheet (alias: modes, quickref) One-shot reference card for shell users. Caveman's /caveman-help only served Claude Code users; shell users had to read --help output or wade through docs. This prints the six modes, the CLI entry points, skill-family mapping, activation env vars, and deactivation. Verified twice (build + vet + test -count=1) across touched packages.
1 parent 7a84c22 commit 3028726

2 files changed

Lines changed: 165 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package core
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/lakshmanpatel/tok/internal/commands/registry"
9+
)
10+
11+
var cheatsheetCmd = &cobra.Command{
12+
Use: "cheatsheet",
13+
Aliases: []string{"modes", "quickref"},
14+
Short: "One-shot reference card for tok compression modes and commands",
15+
Long: `Print a terse reference card covering:
16+
• the six compression modes (lite/full/ultra/wenyan-*)
17+
• the skill family (commit, review, compress, help)
18+
• activation from env and config file
19+
20+
Non-persistent — does not change mode or write flag files.`,
21+
RunE: runCheatsheet,
22+
}
23+
24+
const cheatsheetBody = `
25+
TOK CHEATSHEET
26+
==============
27+
28+
MODES
29+
-----
30+
lite drop filler. keep grammar.
31+
full drop articles + filler + hedging. fragments OK. (default)
32+
ultra extreme compression. abbreviations. arrows for causality.
33+
wenyan-lite classical register, filler stripped, grammar kept.
34+
wenyan-full fragments + arrow causality + tech-term abbreviations.
35+
wenyan-ultra extreme abbreviation, no connectives, symbolic chains.
36+
37+
Env var: export TOK_DEFAULT_MODE=ultra
38+
Config: ~/.config/tok/config.json → {"defaultMode":"lite"}
39+
Resolution order: env > config file > "full"
40+
41+
COMMANDS YOU INVOKE
42+
-------------------
43+
tok <cmd> ... wrap any supported CLI (git, kubectl, npm, etc.)
44+
tok md <file> compress a markdown file in place; --mode=<mode>
45+
tok md <file> --restore revert a compressed file from its .original.md
46+
tok commit-msg read staged diff, emit Conventional Commits subject
47+
tok review-diff scan a diff, emit one-line review comments
48+
tok learn inspect/export the learned-rule database
49+
tok savings token-savings report
50+
tok doctor diagnose filter TOML files
51+
tok cheatsheet this card
52+
53+
SKILL FAMILY (Claude Code plugin)
54+
---------------------------------
55+
/tok [mode] set persistent compression mode
56+
/tok-commit caveman-style commit-message persona
57+
/tok-review caveman-style PR-review persona
58+
/tok:compress <file> invoke tok-compress skill (calls tok md)
59+
/tok-help long-form help card
60+
61+
DEACTIVATE
62+
----------
63+
"stop tok" / "normal mode" or unset TOK_DEFAULT_MODE
64+
/tok off turn off for the session
65+
66+
MORE
67+
----
68+
Plugin authoring: docs/plugin-dev.md
69+
Benchmarks: evals/bench.sh
70+
Source: https://github.com/lakshmanpatel/tok
71+
`
72+
73+
func runCheatsheet(cmd *cobra.Command, args []string) error {
74+
fmt.Print(cheatsheetBody)
75+
return nil
76+
}
77+
78+
func init() {
79+
registry.Add(func() { registry.Register(cheatsheetCmd) })
80+
}

skills/tok-compress/SKILL.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: tok-compress
3+
description: >
4+
Compress natural language memory files (CLAUDE.md, todos, preferences) into tok format
5+
to save input tokens. Preserves all technical substance, code, URLs, and structure.
6+
Compressed version overwrites the original file. Human-readable backup saved as FILE.original.md.
7+
Trigger: /tok:compress <filepath> or "compress memory file"
8+
---
9+
10+
# Tok Compress
11+
12+
## Purpose
13+
14+
Compress natural language files (CLAUDE.md, todos, preferences) into tok-speak to
15+
reduce input tokens. Compressed version overwrites original. Human-readable backup
16+
saved as `<filename>.original.md`.
17+
18+
## Trigger
19+
20+
`/tok:compress <filepath>` or when user asks to compress a memory file.
21+
22+
## Process
23+
24+
The `tok` CLI provides this directly — no separate script or LLM call required.
25+
Prefer the CLI path; it's deterministic and offline.
26+
27+
1. Resolve the absolute path of the target file.
28+
29+
2. Run:
30+
31+
tok md <absolute_filepath> --mode full
32+
33+
Other `--mode` values: `lite`, `full` (default), `ultra`, `wenyan-lite`,
34+
`wenyan-full`, `wenyan-ultra`.
35+
36+
3. The CLI will:
37+
- preserve code blocks, URLs, file paths, headings, and tables exactly
38+
- compress prose lines per the selected mode
39+
- write the compressed version in place
40+
- back up the original as `<filename>.original.md` (only on first run)
41+
- print a token-savings summary
42+
43+
4. Report the summary to the user. Mention the backup path.
44+
45+
## Restore
46+
47+
To revert:
48+
49+
tok md <filepath> --restore
50+
51+
This copies `<filepath>.original.md` back to `<filepath>`.
52+
53+
## Compression Rules
54+
55+
These are encoded in the CLI; this list is informational.
56+
57+
### Remove
58+
- Articles: a, an, the
59+
- Filler: just, really, basically, actually, simply
60+
- Pleasantries: "sure", "certainly", "of course", "happy to"
61+
- Hedging: "it might be worth", "you could consider"
62+
- Redundant phrasing: "in order to" → "to", "due to the fact that" → "because"
63+
64+
### Preserve exactly (never modify)
65+
- Fenced code blocks (``` blocks)
66+
- Inline code (`backtick`)
67+
- URLs and markdown links
68+
- File paths and shell commands
69+
- Headings (keep text; compress body below)
70+
- Tables (full rows preserved)
71+
- Dates, version numbers, numeric literals
72+
73+
### Wenyan modes (CJK-aware)
74+
- Strips modern particles (的, 了, 吧, 呢)
75+
- Maps causal words to arrows (because → →, therefore → →)
76+
- Abbreviates common tech terms (configuration → config, function → fn)
77+
78+
## Boundaries
79+
80+
Refuse to compress:
81+
- Files under `.git/`, `node_modules/`, `vendor/`
82+
- Binary files (non-text)
83+
- Files > 10 MB (warn and ask)
84+
85+
Report errors from the CLI exit code verbatim.

0 commit comments

Comments
 (0)