tokenfreez 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ ---
2
+ description: Silent build agent - outputs only a task checklist and a final change summary. No narration, no code echo.
3
+ mode: primary
4
+ ---
5
+
6
+ You are the build agent. Work silently. Output discipline is absolute.
7
+
8
+ ## Forbidden in responses
9
+
10
+ - Restating or summarizing context back to the user
11
+ - Explaining what you are about to do before doing it
12
+ - Echoing, quoting, or reading out code you write, edit, or delete (diffs already render in the UI)
13
+ - Long explanations, preamble, postamble, apologies, filler
14
+ - Announcing tool calls in prose
15
+
16
+ ## Required output format
17
+
18
+ While working, your ONLY text output is a plain-text task checklist:
19
+
20
+ ```
21
+ [ ] task one
22
+ [ ] task two
23
+ ```
24
+
25
+ Mark items done as work completes and reprint the updated list when statuses change:
26
+
27
+ ```
28
+ [x] task one
29
+ [x] task two
30
+ ```
31
+
32
+ No other prose between steps.
33
+
34
+ ## End of task
35
+
36
+ After the last item is checked, output ONLY a change summary:
37
+
38
+ ```
39
+ Changes:
40
+ - path/to/file — what changed (one line per file)
41
+ ```
42
+
43
+ Nothing else. No conclusions, no explanations, no next-step suggestions unless asked.
44
+
45
+ ## Exceptions
46
+
47
+ - Errors, blockers, and security findings: state them plainly and briefly.
48
+ - Questions requiring user decisions: ask in one sentence.
49
+
50
+ ## Debug loops
51
+
52
+ On the second failed fix attempt for the same error, invoke the debuglock skill and
53
+ follow its protocol exactly. Do not attempt a third blind fix.
54
+
55
+ ## Exploration
56
+
57
+ Before any multi-file exploration, invoke the scoutlock skill and follow its
58
+ protocol - docs first, then targeted search.
59
+
60
+ ## Verbose tool output
61
+
62
+ Before running a command or web fetch likely to produce long output (install,
63
+ build, test, logs, page content), invoke the outputlock skill and follow its
64
+ protocol - silence, redirect, or extract instead of dumping.
@@ -0,0 +1,3 @@
1
+ // ponytail: empty entrypoint so npm package satisfies the opencode plugin contract;
2
+ // all behavior lives in skills/ which opencode scans from the installed package.
3
+ export default async () => ({})
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fdhill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # TokenFreez
2
+
3
+ opencode skills that cut token waste in AI coding sessions. Each skill targets one of
4
+ the four ways coding agents quietly burn tokens — so small tasks stop costing big money.
5
+
6
+ ## Why
7
+
8
+ LLM APIs are stateless: every turn resends the whole conversation as input tokens.
9
+ Anything that grows context — long histories, retry loops, broad searches, verbose tool
10
+ output — gets paid for again on every subsequent turn. TokenFreez attacks all four.
11
+
12
+ | Problem | Fix | Component |
13
+ |---|---|---|
14
+ | History resent every turn grows cost | Freeze session state to a file, restart cheap | [tokenfreez](skills/tokenfreez/SKILL.md) |
15
+ | Retry-debug loops multiply cost | Stop blind fixes, hypothesize first, hard budget | [debuglock](skills/debuglock/SKILL.md) |
16
+ | Unstructured codebase exploration | Docs first, narrow search, subagent delegation | [scoutlock](skills/scoutlock/SKILL.md) |
17
+ | Verbose tool results flood context | Silence, redirect-and-grep, extract the one fact | [outputlock](skills/outputlock/SKILL.md) |
18
+ | Narration and code echo during work | Silent `[ ]`/`[x]` checklist output only | [build agent override](.opencode/agent/build.md) |
19
+
20
+ ## Install
21
+
22
+ Requires [opencode](https://opencode.ai).
23
+
24
+ ### One line (recommended)
25
+
26
+ Add the package to your `opencode.json`:
27
+
28
+ ```json
29
+ {
30
+ "$schema": "https://opencode.ai/config.json",
31
+ "plugin": ["tokenfreez"]
32
+ }
33
+ ```
34
+
35
+ Restart opencode — all four skills are available in every project.
36
+
37
+ ### Manual
38
+
39
+ Copy the skills you want into your project, or globally into `~/.config/opencode/skills/`:
40
+
41
+ ```bash
42
+ cp -r skills/tokenfreez your-project/.opencode/skills/
43
+ cp -r skills/debuglock your-project/.opencode/skills/
44
+ cp -r skills/scoutlock your-project/.opencode/skills/
45
+ cp -r skills/outputlock your-project/.opencode/skills/
46
+ ```
47
+
48
+ Optionally adopt the silent build agent:
49
+
50
+ ```bash
51
+ mkdir -p your-project/.opencode/agent
52
+ cp .opencode/agent/build.md your-project/.opencode/agent/
53
+ ```
54
+
55
+ Restart opencode so the skills load.
56
+
57
+ ## Usage
58
+
59
+ Skills auto-trigger from natural language — no slash commands needed:
60
+
61
+ | Say / situation | Skill that kicks in |
62
+ |---|---|
63
+ | "freeze", "save session" | tokenfreez writes `FREEZE.md` |
64
+ | "masih error", second failed fix on the same bug | debuglock stops blind retries |
65
+ | multi-file exploration, "dimana", "carikan" | scoutlock reads docs before code |
66
+ | install/build/test runs, web lookups | outputlock keeps logs out of context |
67
+
68
+ ### Freeze / resume cycle
69
+
70
+ ```
71
+ (long session getting expensive)
72
+
73
+ you: freeze → AI writes FREEZE.md with state, decisions, next steps
74
+ you: /new → fresh, cheap session
75
+ you: resume → AI reads FREEZE.md — context restored at one file-read price
76
+ ```
77
+
78
+ `FREEZE.md` is gitignored by default so session state never gets committed.
79
+
80
+ ## Notes
81
+
82
+ - Skills are plain markdown (`SKILL.md`) — portable to any tool that uses the same convention.
83
+ - scoutlock prefers an Obsidian vault when one is connected; otherwise it falls back to `README.md` / `docs/`.
84
+ - The build agent override is opencode-specific.
85
+
86
+ ## License
87
+
88
+ [MIT](LICENSE) © fdhill
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "tokenfreez",
3
+ "version": "0.1.0",
4
+ "description": "TokenFreez - opencode skills that cut token waste in AI coding sessions.",
5
+ "keywords": [
6
+ "opencode-plugin",
7
+ "opencode",
8
+ "tokenfreez",
9
+ "tokens",
10
+ "skills"
11
+ ],
12
+ "license": "MIT",
13
+ "author": {
14
+ "name": "fdhill",
15
+ "url": "https://github.com/fdhill"
16
+ },
17
+ "homepage": "https://github.com/fdhill/TokenFreez",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/fdhill/TokenFreez.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/fdhill/TokenFreez/issues"
24
+ },
25
+ "main": "./.opencode/plugins/tokenfreez.mjs",
26
+ "exports": {
27
+ ".": "./.opencode/plugins/tokenfreez.mjs",
28
+ "./plugin": "./.opencode/plugins/tokenfreez.mjs"
29
+ },
30
+ "files": [
31
+ "skills/",
32
+ ".opencode/",
33
+ "LICENSE",
34
+ "README.md"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ }
39
+ }
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: debuglock
3
+ description: >
4
+ Breaks retry-debug loops: stops blind fix attempts, forces root-cause analysis with
5
+ ranked hypotheses before touching code again. Use when the same error has been fixed
6
+ unsuccessfully twice in a row, when user says "masih error", "error lagi", "debug",
7
+ "loop", or whenever you notice you have made 2+ consecutive failed fix attempts on
8
+ the same issue. Auto-trigger; do not wait to be asked.
9
+ ---
10
+
11
+ Retry loops burn tokens multiplicatively: error → fix → error → re-read → fix.
12
+ When triggered, stop paying that tax and find the root cause instead.
13
+
14
+ ## Trigger
15
+
16
+ - You have made 2+ consecutive failed fix attempts on the same error, OR
17
+ - The user reports the error persists ("masih error", "error lagi", "debug", "loop").
18
+
19
+ ## Protocol (in order, no skipping)
20
+
21
+ 1. **STOP editing.** No more fixes until this protocol completes.
22
+ 2. **Inventory from history** (no re-running anything): list every attempt already
23
+ tried and the exact error each produced.
24
+ 3. **Read once, fully.** Read the complete relevant file(s) and full stack trace one
25
+ time. Never re-read a file that has not changed since your last read.
26
+ 4. **Ranked hypotheses.** Write a numbered list of hypotheses with evidence for and
27
+ against each. Rank by likelihood.
28
+ 5. **Verify cheapest first.** Discriminate hypotheses with logging, an assert, or a
29
+ minimal repro BEFORE editing any code.
30
+ 6. **Fix at the root.** Apply the fix at the choke point (the shared function all
31
+ callers route through), not per-caller symptom patches. Grep every caller first.
32
+ 7. **One change per cycle.** Each edit→test cycle changes exactly one thing, so
33
+ results isolate variables.
34
+ 8. **Trim logs.** From long output, extract only failing assertion/error lines;
35
+ never paste whole logs into context.
36
+
37
+ ## Hard budget
38
+
39
+ After activation, if 2 fix attempts fail: STOP permanently on this bug. Report:
40
+
41
+ - Attempts made and their errors
42
+ - Hypothesis status (confirmed / refuted / untested)
43
+ - What you need from the user (decision, access, or information)
44
+
45
+ Never continue solo past this point.
46
+
47
+ ## Rules
48
+
49
+ - No blind retries: never re-attempt a fix whose hypothesis is already refuted.
50
+ - No shotgun edits: multiple simultaneous changes destroy signal.
51
+ - If new evidence invalidates the hypothesis list mid-cycle, return to step 4,
52
+ not to editing.
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: outputlock
3
+ description: >
4
+ Keeps verbose tool results out of context: silences or truncates bash output,
5
+ extracts single facts from web results, and summarizes oversized tool dumps instead
6
+ of echoing them. Use BEFORE running commands known to produce long output (install,
7
+ build, test, tail logs), before web search/fetch, when only one small fact is needed
8
+ from a big source, or when a huge tool result has just landed.
9
+ ---
10
+
11
+ Tool results enter context whole and are resent every turn. One careless dump is paid
12
+ for the rest of the session.
13
+
14
+ ## Bash discipline
15
+
16
+ 1. Prefer commands that are quiet by default; add flags when needed (`-q`, `--silent`,
17
+ `--no-progress`, `2>&1 | tail -n 20`).
18
+ 2. If long output is unavoidable, redirect it to a temp file and grep/tail only the
19
+ relevant part into context:
20
+ `npm install > /tmp/install.log 2>&1; tail -n 5 /tmp/install.log`
21
+ 3. Stack traces: keep the full trace in a file if needed, but read only the header
22
+ and the first error frames - never paste hundreds of lines into context.
23
+ 4. Never run a command again just to "see the output again" - grep the saved file.
24
+
25
+ ## Web discipline
26
+
27
+ 1. One search per question. Extract the fact as a one-line note immediately.
28
+ 2. Do not re-search or re-fetch the same topic; do not open the page when the search
29
+ snippet already answers the question.
30
+ 3. Never quote a whole page back into context - the extracted line is the record.
31
+
32
+ ## File reads
33
+
34
+ Follow scoutlock: segment reads (offset/limit) before full reads, never re-read
35
+ unchanged files.
36
+
37
+ ## When a huge result lands anyway
38
+
39
+ Summarize it to one line internally and reason from that summary onward. Never echo,
40
+ quote, or re-read the raw blob.
41
+
42
+ ## Rules
43
+
44
+ - Extraction over ingestion: get the 1 fact, leave the 10k tokens behind.
45
+ - Silence is free: a flag that prevents output costs nothing; filtering it later
46
+ still pays for generating it.
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: scoutlock
3
+ description: >
4
+ Token-efficient codebase exploration: read documentation before code, search with
5
+ narrow targeted queries, batch parallel lookups, and delegate broad hunts to a
6
+ subagent. Use BEFORE any multi-file exploration, when about to run the 3rd search
7
+ for the same thing, when user says "cari", "dimana", "explore", "carikan", or when
8
+ you notice grep/read results piling up without answering the question.
9
+ ---
10
+
11
+ Exploration burns more tokens than writing code. Search with intent or not at all.
12
+
13
+ ## Step 0 - Docs first
14
+
15
+ Before touching any code-search tool, check documentation in this order:
16
+
17
+ 1. Obsidian vault if connected: project index, architecture notes (backend/frontend),
18
+ progress file - these state what exists and where by design.
19
+ 2. Otherwise: `README.md`, `docs/` folder, root-level `*.md`.
20
+
21
+ Code search only fills gaps the docs do not answer. If docs name the exact file or
22
+ module, go straight to it - skip searching entirely.
23
+
24
+ ## Protocol
25
+
26
+ 1. **State the target** in one line before the first tool call: what symbol/fact is
27
+ needed and why.
28
+ 2. **Cheapest tool first:** glob for filenames → narrow grep (specific identifier +
29
+ file-pattern filter like `*.ts`) → read a segment (offset/limit) → full file read
30
+ only if it is small or genuinely needed whole.
31
+ 3. **Batch parallel:** send independent searches in one turn, not one per turn.
32
+ 4. **Never re-read** a file that has not changed since you last read it.
33
+ 5. **Delegate broad hunts:** if finding the answer needs more than 3 search rounds,
34
+ hand it to an explore subagent with a precise question; only its final answer
35
+ enters main context, not the search noise.
36
+ 6. **Tests smallest-first:** run one test function/file to verify locally; full
37
+ suite at most once, at the end.
38
+ 7. **Stop-rule:** the same search failing 3 times → stop, report what was tried and
39
+ what is known so far, ask the user.
40
+
41
+ ## Rules
42
+
43
+ - No fishing expeditions: never grep a generic word ("data", "handler") unfiltered.
44
+ - One question per search: know what answer would end the hunt before running it.
45
+ - If mid-hunt the target changes, restate it - do not drift into reading whatever
46
+ looks interesting.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: tokenfreez
3
+ description: >
4
+ Freezes session state into FREEZE.md at project root so long conversations can be
5
+ restarted cheaply in a fresh session. Replaces expensive chat history with one small
6
+ file read. Use when user says "freeze", "tokenfreez", "freeze session", "save session",
7
+ "resume", "lanjutkan dari freeze", or complains about long/expensive context. Also
8
+ proactively suggest freezing when context grows large, a task completes, or the
9
+ topic switches.
10
+ ---
11
+
12
+ Freeze session state into a file. Chat history is resent as input tokens every turn
13
+ and grows costly; FREEZE.md is read once. Swap expensive storage for cheap storage.
14
+
15
+ ## Freeze Procedure
16
+
17
+ Triggered by explicit request ("freeze", "tokenfreez") or when the user accepts an
18
+ auto-suggestion. Do this:
19
+
20
+ 1. Summarize the current session state.
21
+ 2. Overwrite `FREEZE.md` at the project root using this exact format:
22
+
23
+ ```markdown
24
+ # FREEZE — <project> — <YYYY-MM-DD HH:MM>
25
+
26
+ ## Active Task
27
+ <one line: what is being worked on right now>
28
+
29
+ ## Decisions
30
+ - <decision> — <why>
31
+
32
+ ## Done
33
+ - [x] <completed item>
34
+
35
+ ## Pending / Next Steps
36
+ - [ ] <next action>
37
+
38
+ ## Key Files
39
+ - <path> — <why it matters>
40
+ ```
41
+
42
+ 3. Tell the user exactly: run `/new`, then say "resume from FREEZE.md".
43
+
44
+ ## Restore Procedure
45
+
46
+ When a session starts and the user says "resume", "lanjutkan", or mentions FREEZE.md:
47
+
48
+ 1. Read `FREEZE.md` from the project root before answering anything else.
49
+ 2. Treat it as the source of truth for prior context.
50
+ 3. If its claims look stale (files moved, checklist items already done), verify
51
+ against the actual files and refresh FREEZE.md.
52
+
53
+ ## Auto-Suggest Rules
54
+
55
+ Proactively offer a freeze (one short sentence, do not nag) when:
56
+
57
+ - A task or milestone just completed.
58
+ - Large tool outputs have accumulated this session.
59
+ - The user switches to an unrelated topic.
60
+
61
+ ## Rules
62
+
63
+ - **Overwrite, never append.** One file, always current. Keep it under ~100 lines.
64
+ - **No secrets** in FREEZE.md: no keys, tokens, passwords, credentials.
65
+ - Compress ruthlessly: decisions and next steps over narrative.
66
+ - If FREEZE.md already exists, update it in place rather than asking.