@crafter/cli-tree 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.
- package/LICENSE +21 -0
- package/README.md +328 -0
- package/dist/archaeology/cache.d.ts +11 -0
- package/dist/archaeology/delegate.d.ts +43 -0
- package/dist/archaeology/index.d.ts +12 -0
- package/dist/archaeology/index.js +61 -0
- package/dist/archaeology/index.js.map +9 -0
- package/dist/archaeology/llm.d.ts +1 -0
- package/dist/archaeology/merge.d.ts +3 -0
- package/dist/archaeology/orchestrator.d.ts +25 -0
- package/dist/archaeology/prompts.d.ts +13 -0
- package/dist/archaeology/types.d.ts +101 -0
- package/dist/archaeology/validate.d.ts +18 -0
- package/dist/chunk-57gtsvhb.js +434 -0
- package/dist/chunk-57gtsvhb.js.map +16 -0
- package/dist/chunk-5aahbfr2.js +293 -0
- package/dist/chunk-5aahbfr2.js.map +10 -0
- package/dist/chunk-pkfpaae1.js +678 -0
- package/dist/chunk-pkfpaae1.js.map +15 -0
- package/dist/chunk-q4se2rwe.js +181 -0
- package/dist/chunk-q4se2rwe.js.map +14 -0
- package/dist/chunk-v5w3w6bd.js +168 -0
- package/dist/chunk-v5w3w6bd.js.map +11 -0
- package/dist/chunk-ykze151b.js +770 -0
- package/dist/chunk-ykze151b.js.map +16 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +433 -0
- package/dist/cli.js.map +10 -0
- package/dist/encoders/ansi.d.ts +2 -0
- package/dist/encoders/html.d.ts +10 -0
- package/dist/encoders/string.d.ts +2 -0
- package/dist/flow/encode.d.ts +5 -0
- package/dist/flow/index.d.ts +8 -0
- package/dist/flow/index.js +25 -0
- package/dist/flow/index.js.map +9 -0
- package/dist/flow/layout.d.ts +30 -0
- package/dist/flow/parse.d.ts +2 -0
- package/dist/flow/render.d.ts +3 -0
- package/dist/flow/types.d.ts +42 -0
- package/dist/flow/validate.d.ts +3 -0
- package/dist/flow/yaml.d.ts +4 -0
- package/dist/grid.d.ts +14 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +9 -0
- package/dist/miner/history.d.ts +6 -0
- package/dist/miner/index.d.ts +18 -0
- package/dist/miner/index.js +38 -0
- package/dist/miner/index.js.map +9 -0
- package/dist/miner/sessions.d.ts +3 -0
- package/dist/miner/stats.d.ts +2 -0
- package/dist/miner/suggest.d.ts +11 -0
- package/dist/miner/transitions.d.ts +6 -0
- package/dist/miner/types.d.ts +46 -0
- package/dist/miner/workflows.d.ts +11 -0
- package/dist/parse.d.ts +3 -0
- package/dist/render.d.ts +3 -0
- package/dist/types.d.ts +39 -0
- package/package.json +85 -0
- package/skill/SKILL.md +263 -0
- package/skill/evals/evals.json +26 -0
- package/skill/install.sh +38 -0
- package/skill/references/archaeology-guide.md +157 -0
- package/skill/references/skill-template.md +120 -0
- package/src/archaeology/cache.ts +107 -0
- package/src/archaeology/delegate.ts +113 -0
- package/src/archaeology/index.ts +48 -0
- package/src/archaeology/llm.ts +10 -0
- package/src/archaeology/merge.ts +155 -0
- package/src/archaeology/orchestrator.ts +185 -0
- package/src/archaeology/prompts.ts +178 -0
- package/src/archaeology/types.ts +139 -0
- package/src/archaeology/validate.ts +157 -0
- package/src/cli.ts +451 -0
- package/src/encoders/ansi.ts +32 -0
- package/src/encoders/html.ts +78 -0
- package/src/encoders/string.ts +20 -0
- package/src/flow/encode.ts +21 -0
- package/src/flow/index.ts +15 -0
- package/src/flow/layout.ts +150 -0
- package/src/flow/parse.ts +100 -0
- package/src/flow/render.ts +186 -0
- package/src/flow/types.ts +45 -0
- package/src/flow/validate.ts +111 -0
- package/src/flow/yaml.ts +235 -0
- package/src/grid.ts +59 -0
- package/src/index.ts +24 -0
- package/src/miner/history.ts +156 -0
- package/src/miner/index.ts +76 -0
- package/src/miner/sessions.ts +39 -0
- package/src/miner/stats.ts +43 -0
- package/src/miner/suggest.ts +101 -0
- package/src/miner/transitions.ts +62 -0
- package/src/miner/types.ts +45 -0
- package/src/miner/workflows.ts +96 -0
- package/src/parse.ts +321 -0
- package/src/render.ts +182 -0
- package/src/types.ts +62 -0
- package/workflows/docker-deploy.yml +42 -0
- package/workflows/docker-parallel.yml +36 -0
- package/workflows/gh-issue-to-pr.yml +48 -0
- package/workflows/git-pr-flow.yml +36 -0
- package/workflows/kubectl-rollout.yml +37 -0
- package/workflows/npm-publish.yml +42 -0
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clitree
|
|
3
|
+
description: Explore and map any CLI tool deeply. Parses --help trees, mines the user's shell history for repeated workflows, and uses your own knowledge as the coding agent to surface hidden flags and canonical patterns — validating every finding against the real CLI so nothing is hallucinated. Use this proactively whenever the user wants to understand a CLI more deeply than --help alone, asks about workflows they could automate from their shell history, mentions hidden/undocumented flags, wants to skillify repeated commands, or explores an unfamiliar tool like docker/kubectl/stripe/bun/gh. Also triggers on explicit invocations like "/clitree docker", "/clitree git", or asks like "map docker fully", "what git workflows do I repeat", "what can I automate from my history", "deep dive into kubectl".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# clitree — CLI Archaeology
|
|
7
|
+
|
|
8
|
+
You help the user understand a command-line tool by combining three sources:
|
|
9
|
+
|
|
10
|
+
1. **`--help` parsing** — what's documented
|
|
11
|
+
2. **Shell history mining** — what the user actually does
|
|
12
|
+
3. **Your own knowledge + validation** — hidden/undocumented/canonical patterns, verified against the real binary
|
|
13
|
+
|
|
14
|
+
You're not just running a tool. You're acting as an **archaeologist**: proposing hypotheses from your training knowledge, then excavating the real CLI to confirm or reject them. Hallucinations are the #1 failure mode, so every proposed flag gets validated before making it into the report.
|
|
15
|
+
|
|
16
|
+
## Why this exists
|
|
17
|
+
|
|
18
|
+
`--help` is shallow. Users don't know what they don't know. They run the same 4 git commands every day and never discover `--fixup`. They learn docker from one tutorial and miss `--platform` or `--gpus`. They install kubectl and stare at 106 commands with no idea where to start.
|
|
19
|
+
|
|
20
|
+
This skill fixes that by producing a personalized report: *"here's the tool, here's how YOU use it, here's what you're missing, here's what you could automate."*
|
|
21
|
+
|
|
22
|
+
## The pipeline
|
|
23
|
+
|
|
24
|
+
All phases run in sequence. Each phase's output feeds the next.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
[1] parse --help → documented tree
|
|
28
|
+
[2] mine shell history → usage patterns + workflow suggestions
|
|
29
|
+
[3] propose (you) → hidden flags + canonical workflows
|
|
30
|
+
[4] validate (code) → run --help / man to confirm proposals
|
|
31
|
+
[5] render report → full picture
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Phase 3 is your unique contribution as the agent. Phases 1, 2, 4 are handled by the cli-tree library — you just call it.
|
|
35
|
+
|
|
36
|
+
## Setup
|
|
37
|
+
|
|
38
|
+
The skill depends on a local install of the `cli-tree` library. On installation, the install script substitutes the real path into this file:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
CLITREE_LIB=CLITREE_LIB_PATH
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
At the start of every run, verify setup:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
test -d "$CLITREE_LIB" && which bun && which "$TARGET_BINARY"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If any check fails, explain what's missing and stop. Don't try to guess paths — tell the user clearly.
|
|
51
|
+
|
|
52
|
+
## Phase 1 — Parse the --help tree
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd "$CLITREE_LIB" && bun src/cli.ts "$TARGET_BINARY" --format json --depth 2
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Read the JSON. Note: total commands, top subcommands, total flags. This gives you the documented surface area.
|
|
59
|
+
|
|
60
|
+
If the parse fails completely (empty output, error), try:
|
|
61
|
+
- `$TARGET_BINARY help --help`
|
|
62
|
+
- `$TARGET_BINARY -h`
|
|
63
|
+
- `man $TARGET_BINARY` as last resort
|
|
64
|
+
|
|
65
|
+
## Phase 2 — Mine shell history
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cd "$CLITREE_LIB" && bun src/cli.ts mine "$TARGET_BINARY" --format json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Read the result. You get:
|
|
72
|
+
- `stats.totalInvocations` — how much the user uses this CLI
|
|
73
|
+
- `stats.topSubcommands` — their most-used commands
|
|
74
|
+
- `workflows` — sequences that repeat (≥3 times)
|
|
75
|
+
- `suggestions` — candidate skills to create
|
|
76
|
+
|
|
77
|
+
Three scenarios from the invocation count:
|
|
78
|
+
|
|
79
|
+
| Invocations | What it means | What to do |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `> 50` | Heavy user, rich signal | Use real workflows as ground truth |
|
|
82
|
+
| `10–50` | Casual user | Present workflows tentatively, augment with canonical patterns |
|
|
83
|
+
| `< 10` | New tool, no signal | Skip mined workflows, present canonical patterns from your knowledge |
|
|
84
|
+
|
|
85
|
+
## Phase 3 — Archaeology (your part)
|
|
86
|
+
|
|
87
|
+
This is where you earn your keep. For the top 5 most-used subcommands (or the 5 most interesting commands if history is sparse), think:
|
|
88
|
+
|
|
89
|
+
**"What exists for this command that the user doesn't see in `--help`?"**
|
|
90
|
+
|
|
91
|
+
Categories to hunt for:
|
|
92
|
+
- **Hidden flags** — work but undocumented (e.g. `docker run --gpus`, `git commit --fixup`)
|
|
93
|
+
- **Experimental flags** — gated, marked as experimental in source
|
|
94
|
+
- **Deprecated flags** — still functional, hidden from new docs
|
|
95
|
+
- **Man-page-only flags** — visible in `man <cli>` but not `<cli> --help`
|
|
96
|
+
- **Canonical workflows** — patterns that aren't in any help but every experienced user knows (e.g. `git stash → pull → stash pop`)
|
|
97
|
+
|
|
98
|
+
Only propose things you're **confident** about (>70%). Your training contains blog posts, PRs, issues, source code — draw on the signal, not guesses. Omit rather than invent.
|
|
99
|
+
|
|
100
|
+
For detailed prompt templates that help you think through each category systematically, read `references/archaeology-guide.md`.
|
|
101
|
+
|
|
102
|
+
## Phase 4 — Validate every proposal
|
|
103
|
+
|
|
104
|
+
This is the step that separates archaeology from hallucination. For each flag you propose, verify it exists:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Primary check: is it in --help?
|
|
108
|
+
"$TARGET_BINARY" "$SUBCOMMAND" --help 2>&1 | grep -E "(--<flag>|-<short>\\b)"
|
|
109
|
+
|
|
110
|
+
# Fallback: man page
|
|
111
|
+
man "$TARGET_BINARY" 2>/dev/null | grep -E "(--<flag>|-<short>\\b)" | head -5
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Mark each finding:
|
|
115
|
+
- **`verified`** — appears in `--help`
|
|
116
|
+
- **`verified-by-man`** — not in help, but man confirms
|
|
117
|
+
- **`unconfirmed`** — neither confirms; keep only if you're highly confident AND can explain the evidence (e.g. "shown in docker/docker#12345")
|
|
118
|
+
- **`rejected`** — fail to validate → drop it silently, never include in final output
|
|
119
|
+
|
|
120
|
+
Better to surface 3 verified flags than 10 unconfirmed ones. **Your credibility is built on rejection rate.** When you mark something unconfirmed, explain why you still believe it.
|
|
121
|
+
|
|
122
|
+
## Phase 5 — Render the report
|
|
123
|
+
|
|
124
|
+
Produce this exact structure. Consistency matters — the user learns the shape and scans it quickly on future runs.
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
# <binary> — archaeology report
|
|
128
|
+
|
|
129
|
+
## Tree
|
|
130
|
+
<one-line summary: N commands, M flags>
|
|
131
|
+
|
|
132
|
+
## Your usage
|
|
133
|
+
<from history: invocations, top subcommands, sessions>
|
|
134
|
+
<or: "No usage detected — showing canonical patterns from my knowledge">
|
|
135
|
+
|
|
136
|
+
## Workflows you repeat
|
|
137
|
+
<from mining — top 5, with frequency>
|
|
138
|
+
<or omit section entirely if no history>
|
|
139
|
+
|
|
140
|
+
## Hidden / undocumented findings
|
|
141
|
+
✓ --flag-a (verified) — what it does
|
|
142
|
+
✓ --flag-b (verified by man) — what it does
|
|
143
|
+
? --flag-c (unconfirmed) — evidence: "..."
|
|
144
|
+
|
|
145
|
+
## Canonical workflows
|
|
146
|
+
<from your knowledge — patterns every expert knows>
|
|
147
|
+
<e.g. "git: rebase-interactive → squash → force-with-lease-push">
|
|
148
|
+
|
|
149
|
+
## Skill suggestions
|
|
150
|
+
<from mining + your analysis>
|
|
151
|
+
💡 /ship — <what it does> — seen N times
|
|
152
|
+
💡 /deploy — <what it does> — seen N times
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Five sections, in this order. Omit sections that are empty (no workflows → skip the section, don't write "none found").
|
|
156
|
+
|
|
157
|
+
After rendering, **offer to create the top skill suggestion**. If the user says yes:
|
|
158
|
+
|
|
159
|
+
- Write `~/.claude/skills/<name>/SKILL.md` using the template in `references/skill-template.md`
|
|
160
|
+
- Substitute the command sequence from the mined workflow
|
|
161
|
+
- Tell the user the file path and how to invoke it (e.g., "type `/ship` in any conversation")
|
|
162
|
+
|
|
163
|
+
## Output modes
|
|
164
|
+
|
|
165
|
+
Support these argument flavors. If the user didn't specify, default to full report.
|
|
166
|
+
|
|
167
|
+
| Invocation | Behavior |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `/clitree <binary>` | Full report (all 5 sections) |
|
|
170
|
+
| `/clitree <binary> tree` | Only the --help tree, skip mining + archaeology |
|
|
171
|
+
| `/clitree <binary> flows` | Only mined workflows, skip tree + archaeology |
|
|
172
|
+
| `/clitree <binary> suggest` | Only skill suggestions, minimal context |
|
|
173
|
+
| `/clitree <binary> raw` | JSON output, no narrative |
|
|
174
|
+
|
|
175
|
+
## Principles
|
|
176
|
+
|
|
177
|
+
These exist because specific failure modes were observed while building the skill. Break them only if you have a specific reason.
|
|
178
|
+
|
|
179
|
+
- **Validate everything.** Unvalidated LLM proposals poison the output. Always prefer verified over comprehensive.
|
|
180
|
+
- **Mark provenance.** Every finding gets tagged `help`, `history`, `verified`, `verified-by-man`, or `unconfirmed`. The user deserves to know the confidence of each fact.
|
|
181
|
+
- **Fail phase-by-phase.** If phase 1 fails, still run 2. If 2 fails, still run 3. A partial report is more useful than no report.
|
|
182
|
+
- **Be honest about absence.** If the user has 0 shell history for this CLI, say so. Don't fabricate "probable workflows" — use canonical patterns and mark them clearly.
|
|
183
|
+
- **Respect the user's time.** The report should be scannable in 30 seconds. Use the 5-section structure exactly, with short bullets, no prose walls.
|
|
184
|
+
|
|
185
|
+
## Cache
|
|
186
|
+
|
|
187
|
+
Archaeology is slow. The library caches enriched trees at `~/.clitree/cache/<binary>.json` with CLI version as part of the key. If the cache is fresh and the user isn't passing `--no-cache`, use it. Version mismatch invalidates automatically.
|
|
188
|
+
|
|
189
|
+
## Edge cases
|
|
190
|
+
|
|
191
|
+
- **Binary wraps another** (e.g. `npm` runs `node` scripts) — analyze the wrapper, not the wrapped runtime.
|
|
192
|
+
- **Aliases in history** (`g` for `git`, `k` for `kubectl`) — check the user's shell config if the history seems sparse for a CLI they should be using heavily.
|
|
193
|
+
- **HISTFILE disabled or empty** — skip phase 2 gracefully, say so in the report.
|
|
194
|
+
- **Binary not found** — don't try to install. Tell the user the binary isn't available and suggest `brew install <name>` or equivalent.
|
|
195
|
+
- **Wrapper binaries** (e.g. `docker` is a symlink, `git` uses an extensive system) — run the actual `--help`, the library handles it.
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
### Full report — `/clitree git`
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
# git — archaeology report
|
|
203
|
+
|
|
204
|
+
## Tree
|
|
205
|
+
23 top-level commands, 91 documented flags, 3 archaeology findings
|
|
206
|
+
|
|
207
|
+
## Your usage
|
|
208
|
+
1,257 invocations across 483 sessions
|
|
209
|
+
Top commands: commit (277), checkout (237), push (183), add (167), pull (124)
|
|
210
|
+
|
|
211
|
+
## Workflows you repeat
|
|
212
|
+
1. add → commit → push (64×)
|
|
213
|
+
2. checkout → pull (38×)
|
|
214
|
+
3. stash → pull → stash pop (12×)
|
|
215
|
+
|
|
216
|
+
## Hidden / undocumented findings
|
|
217
|
+
✓ --no-verify (verified) — skip pre-commit hooks
|
|
218
|
+
✓ commit --fixup=<ref> (verified by man) — create a fixup commit for rebase
|
|
219
|
+
? push --force-with-lease (unconfirmed) — safer force push, confirmed in git docs but not in this version's --help
|
|
220
|
+
|
|
221
|
+
## Canonical workflows
|
|
222
|
+
• rebase-interactive → squash → force-with-lease-push (clean up feature branch)
|
|
223
|
+
• bisect start → good → bad → reset (find regressions)
|
|
224
|
+
• worktree add → cd → work → worktree remove (parallel branches)
|
|
225
|
+
|
|
226
|
+
## Skill suggestions
|
|
227
|
+
💡 /ship — git add + commit + push seen 64 times — create this skill? [y/n]
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Sparse history — `/clitree kubectl`
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
# kubectl — archaeology report
|
|
234
|
+
|
|
235
|
+
## Tree
|
|
236
|
+
106 commands, 787 documented flags
|
|
237
|
+
|
|
238
|
+
## Your usage
|
|
239
|
+
No usage detected in shell history — showing canonical patterns instead.
|
|
240
|
+
|
|
241
|
+
## Canonical workflows
|
|
242
|
+
• deploy : apply → rollout status → logs
|
|
243
|
+
• debug pod : get → describe → logs → exec
|
|
244
|
+
• scale : scale → get → top
|
|
245
|
+
|
|
246
|
+
## Hidden / undocumented findings
|
|
247
|
+
✓ get -o=custom-columns (verified) — pick exact columns to show
|
|
248
|
+
✓ logs --since-time (verified by man) — logs after a timestamp
|
|
249
|
+
? drain --delete-emptydir-data (unconfirmed) — known safe in v1.24+
|
|
250
|
+
|
|
251
|
+
## Skill suggestions
|
|
252
|
+
No suggestions — no repeated usage detected yet.
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Follow-up behavior
|
|
256
|
+
|
|
257
|
+
After the user sees the report, they'll often ask:
|
|
258
|
+
- *"Create the /ship skill"* → write `~/.claude/skills/ship/SKILL.md` per `references/skill-template.md`
|
|
259
|
+
- *"Tell me more about --fixup"* → run `git help commit` or `man git-commit | grep -A5 fixup`
|
|
260
|
+
- *"Do this for docker too"* → re-run the pipeline with the new binary
|
|
261
|
+
- *"Show me just the workflows"* → re-run with `flows` mode
|
|
262
|
+
|
|
263
|
+
Handle these inline without making the user re-invoke the skill.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "clitree",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 0,
|
|
6
|
+
"name": "direct-git",
|
|
7
|
+
"prompt": "/clitree git",
|
|
8
|
+
"expected_output": "A 5-section archaeology report for git: tree summary, shell history usage, repeated workflows (add→commit→push should appear), hidden findings with verified status, canonical workflows, and skill suggestions (ship or similar) — matching the exact section order and naming in the skill spec.",
|
|
9
|
+
"files": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": 1,
|
|
13
|
+
"name": "indirect-bun",
|
|
14
|
+
"prompt": "I've been using bun a ton lately and I feel like I'm typing the same 3 commands over and over. Is there any pattern I could turn into a one-shot skill? I want you to actually look at what I'm doing, not guess.",
|
|
15
|
+
"expected_output": "The skill should trigger without /clitree being mentioned. The agent should (1) recognize this is a job for clitree, (2) run the pipeline against bun, (3) produce the full report, (4) identify the repeated bun workflows from shell history (install → dev or similar), (5) offer to create a skill from the top suggestion.",
|
|
16
|
+
"files": []
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 2,
|
|
20
|
+
"name": "unknown-stripe",
|
|
21
|
+
"prompt": "I just installed the stripe CLI. Can you help me understand everything it can do — including hidden or advanced stuff I wouldn't get from just running `stripe --help`?",
|
|
22
|
+
"expected_output": "The agent should trigger clitree, detect that shell history has little or no stripe usage, skip the 'workflows you repeat' section, produce canonical workflows from training knowledge, and surface hidden/advanced findings with validation against the real binary. No hallucinated commands.",
|
|
23
|
+
"files": []
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
package/skill/install.sh
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
6
|
+
|
|
7
|
+
# Detect the coding agent config dir
|
|
8
|
+
AGENT_DIRS=(
|
|
9
|
+
"$HOME/.claude/skills"
|
|
10
|
+
"$HOME/.cursor/skills"
|
|
11
|
+
"$HOME/.config/codex/skills"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
TARGET=""
|
|
15
|
+
for dir in "${AGENT_DIRS[@]}"; do
|
|
16
|
+
if [ -d "$(dirname "$dir")" ]; then
|
|
17
|
+
TARGET="$dir/clitree"
|
|
18
|
+
break
|
|
19
|
+
fi
|
|
20
|
+
done
|
|
21
|
+
|
|
22
|
+
if [ -z "$TARGET" ]; then
|
|
23
|
+
echo "Error: could not detect a coding agent config directory."
|
|
24
|
+
echo "Tried: ${AGENT_DIRS[*]}"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
mkdir -p "$TARGET"
|
|
29
|
+
|
|
30
|
+
# Copy SKILL.md with CLITREE_LIB_PATH substituted
|
|
31
|
+
sed "s|CLITREE_LIB_PATH|$REPO_ROOT|g" "$SCRIPT_DIR/SKILL.md" > "$TARGET/SKILL.md"
|
|
32
|
+
|
|
33
|
+
# Copy helper scripts
|
|
34
|
+
cp "$SCRIPT_DIR"/*.ts "$TARGET/" 2>/dev/null || true
|
|
35
|
+
|
|
36
|
+
echo "✓ clitree skill installed at: $TARGET"
|
|
37
|
+
echo ""
|
|
38
|
+
echo "Try it with: /clitree git"
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Archaeology guide — prompt templates for each phase
|
|
2
|
+
|
|
3
|
+
Read this when you're doing phase 3 (archaeology) and need structured help thinking through flag discovery.
|
|
4
|
+
|
|
5
|
+
## When to use this file
|
|
6
|
+
|
|
7
|
+
- You just ran phases 1 and 2 and have the --help tree + mining results
|
|
8
|
+
- You're about to propose hidden/undocumented flags for the top subcommands
|
|
9
|
+
- You want a mental checklist to avoid missing categories of findings
|
|
10
|
+
|
|
11
|
+
## Phase 3a — Hidden flag hunt
|
|
12
|
+
|
|
13
|
+
For each of the top 5 subcommands, run through this mental checklist:
|
|
14
|
+
|
|
15
|
+
### Question 1: What does this command do in one sentence?
|
|
16
|
+
|
|
17
|
+
Write it in your head. If you can't, look up `<cli> <sub> --help`. This grounds you.
|
|
18
|
+
|
|
19
|
+
### Question 2: What are the 3 most common real-world use cases?
|
|
20
|
+
|
|
21
|
+
Think about blog posts, tutorials, and Stack Overflow answers you've seen. For each use case, what flags does it typically use?
|
|
22
|
+
|
|
23
|
+
### Question 3: What flags would an expert use that a beginner wouldn't?
|
|
24
|
+
|
|
25
|
+
- Performance: `-j`, `--parallel`, `--workers`
|
|
26
|
+
- Safety: `--dry-run`, `--no-verify`, `--force-with-lease`
|
|
27
|
+
- Debug: `--verbose`, `--trace`, `--debug`
|
|
28
|
+
- Power: `--interactive`, `--patch`, `--amend`
|
|
29
|
+
|
|
30
|
+
### Question 4: What's been added recently?
|
|
31
|
+
|
|
32
|
+
Newer flags often aren't in `--help` well. Check: has this CLI had a major release in the last year? Are there known flags from the release notes?
|
|
33
|
+
|
|
34
|
+
### Question 5: What's been deprecated?
|
|
35
|
+
|
|
36
|
+
Still-functional but hidden flags are goldmines. Check your memory for "the old way to do X".
|
|
37
|
+
|
|
38
|
+
### Output format for proposals
|
|
39
|
+
|
|
40
|
+
For each subcommand, produce a block like:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"subcommand": "<name>",
|
|
45
|
+
"proposedFlags": [
|
|
46
|
+
{
|
|
47
|
+
"name": "flag-name",
|
|
48
|
+
"short": "f",
|
|
49
|
+
"type": "boolean|string|number|enum",
|
|
50
|
+
"description": "<one line>",
|
|
51
|
+
"confidence": 0.85,
|
|
52
|
+
"evidence": "source-code|blog|official-docs|man-page|pr-thread|personal-experience",
|
|
53
|
+
"category": "hidden|experimental|deprecated|man-only|power-user"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Skip flags with confidence < 0.7. Empty proposals are fine — don't pad.
|
|
60
|
+
|
|
61
|
+
## Phase 3b — Canonical workflow hunt
|
|
62
|
+
|
|
63
|
+
This is different from mined workflows (phase 2). Mined workflows come from the user's shell history. Canonical workflows come from your training knowledge — they're patterns every expert knows, even if the user has never run them.
|
|
64
|
+
|
|
65
|
+
### Categories of canonical workflows
|
|
66
|
+
|
|
67
|
+
For each CLI, think about workflows in these categories:
|
|
68
|
+
|
|
69
|
+
1. **Bootstrap** — how you start using the tool from scratch
|
|
70
|
+
2. **Daily driver** — the 3-4 commands that make up 80% of expert usage
|
|
71
|
+
3. **Cleanup / hygiene** — commands experts run periodically
|
|
72
|
+
4. **Recovery** — commands for when things go wrong
|
|
73
|
+
5. **Power user** — non-obvious combos that unlock significant productivity
|
|
74
|
+
|
|
75
|
+
### Example — git
|
|
76
|
+
|
|
77
|
+
| Category | Workflow |
|
|
78
|
+
|---|---|
|
|
79
|
+
| Bootstrap | `init → add → commit → remote add → push -u` |
|
|
80
|
+
| Daily driver | `add → commit → push` |
|
|
81
|
+
| Cleanup | `fetch --prune → branch -d <merged>` |
|
|
82
|
+
| Recovery | `reflog → reset --hard <sha>` |
|
|
83
|
+
| Power user | `rebase -i → squash → force-with-lease` |
|
|
84
|
+
|
|
85
|
+
### Example — docker
|
|
86
|
+
|
|
87
|
+
| Category | Workflow |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Bootstrap | `pull → run → exec` |
|
|
90
|
+
| Daily driver | `build → run` |
|
|
91
|
+
| Cleanup | `system prune -a` |
|
|
92
|
+
| Recovery | `logs → inspect → exec` |
|
|
93
|
+
| Power user | `buildx build --platform linux/amd64,linux/arm64 --push` |
|
|
94
|
+
|
|
95
|
+
### Rules for canonical workflows
|
|
96
|
+
|
|
97
|
+
- Only include patterns you're confident are canonical (seen in multiple independent sources)
|
|
98
|
+
- Omit workflows specific to one framework/ecosystem unless it's mainstream
|
|
99
|
+
- Keep to 3-5 workflows per CLI, not an exhaustive list
|
|
100
|
+
- Order by how frequently an expert would use them
|
|
101
|
+
|
|
102
|
+
## Phase 3c — Flag constraint hunt
|
|
103
|
+
|
|
104
|
+
Last, think about interactions between flags. Which flags:
|
|
105
|
+
|
|
106
|
+
- Are **mutually exclusive** (can't use together)?
|
|
107
|
+
- **Require** another flag?
|
|
108
|
+
- **Imply** another flag?
|
|
109
|
+
|
|
110
|
+
These rarely appear in `--help`. They come from source code comments, issue threads, or trial and error.
|
|
111
|
+
|
|
112
|
+
Example for `docker run`:
|
|
113
|
+
- `--detach` and `--interactive` → mutually exclusive (one is fg, one is bg)
|
|
114
|
+
- `--gpus` → requires `--runtime=nvidia` in older versions
|
|
115
|
+
- `--privileged` → implies `--cap-add=ALL`
|
|
116
|
+
|
|
117
|
+
Format:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"constraints": [
|
|
122
|
+
{
|
|
123
|
+
"type": "mutually-exclusive|requires|implies",
|
|
124
|
+
"flags": ["--flag-a", "--flag-b"],
|
|
125
|
+
"description": "<human explanation>",
|
|
126
|
+
"confidence": 0.9
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Only include high-confidence constraints. Uncertain → omit.
|
|
133
|
+
|
|
134
|
+
## Validation workflow
|
|
135
|
+
|
|
136
|
+
After you have proposals from 3a/3b/3c, validate them in this order:
|
|
137
|
+
|
|
138
|
+
1. **Flags from 3a** — highest value, highest hallucination risk. Run:
|
|
139
|
+
```bash
|
|
140
|
+
<cli> <sub> --help 2>&1 | grep -E "(--<flag>|-<short>\b)"
|
|
141
|
+
```
|
|
142
|
+
If no match, try man page:
|
|
143
|
+
```bash
|
|
144
|
+
man <cli> 2>/dev/null | grep -A2 -E "(--<flag>|-<short>\b)" | head -10
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
2. **Workflows from 3b** — these don't need validation; they're composed of commands that already validated in phase 1.
|
|
148
|
+
|
|
149
|
+
3. **Constraints from 3c** — hardest to validate programmatically. Mark as `unconfirmed` unless you have specific evidence.
|
|
150
|
+
|
|
151
|
+
## Common mistakes to avoid
|
|
152
|
+
|
|
153
|
+
- **Listing `--help` / `-h` as hidden** — it's not. Every tool has it.
|
|
154
|
+
- **Listing flags that are in `--help` but you missed reading** — always read the help output carefully before proposing.
|
|
155
|
+
- **Proposing flags from a different CLI** — `docker -v` and `git -v` both exist but mean different things. Be precise.
|
|
156
|
+
- **Confusing subcommands with flags** — `docker ps -a` uses flag `-a`, not subcommand `a`.
|
|
157
|
+
- **Outdated flags** — a flag that existed in `git 1.x` may have been removed in `2.x`. When possible, check `<cli> --version` and match your knowledge to that major version.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Template for skills generated from clitree workflow detection
|
|
2
|
+
|
|
3
|
+
When the user accepts a skill suggestion from clitree, write a new SKILL.md file using this template.
|
|
4
|
+
|
|
5
|
+
## File location
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
~/.claude/skills/<name>/SKILL.md
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Template
|
|
12
|
+
|
|
13
|
+
```markdown
|
|
14
|
+
---
|
|
15
|
+
name: <name>
|
|
16
|
+
description: <one-line description>. Use when the user says "/<name>" or asks to <action verb that captures the workflow>.
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# <name>
|
|
20
|
+
|
|
21
|
+
<one-paragraph description of what this skill automates and why it exists>
|
|
22
|
+
|
|
23
|
+
## The workflow
|
|
24
|
+
|
|
25
|
+
This skill automates this sequence:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
<command 1>
|
|
29
|
+
<command 2>
|
|
30
|
+
<command 3>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## When to trigger
|
|
34
|
+
|
|
35
|
+
- User types `/<name>`
|
|
36
|
+
- User asks "<natural phrasing 1>"
|
|
37
|
+
- User asks "<natural phrasing 2>"
|
|
38
|
+
|
|
39
|
+
## Steps
|
|
40
|
+
|
|
41
|
+
When invoked, run these commands in order. Stop and ask the user if any step is ambiguous.
|
|
42
|
+
|
|
43
|
+
1. **<step 1 name>** — `<command>`
|
|
44
|
+
2. **<step 2 name>** — `<command>`
|
|
45
|
+
3. **<step 3 name>** — `<command>`
|
|
46
|
+
|
|
47
|
+
## Error handling
|
|
48
|
+
|
|
49
|
+
- If step 1 fails, explain to the user what went wrong and don't proceed.
|
|
50
|
+
- If any step produces unexpected output, show it to the user and ask before continuing.
|
|
51
|
+
|
|
52
|
+
## Provenance
|
|
53
|
+
|
|
54
|
+
Created by clitree on <YYYY-MM-DD>.
|
|
55
|
+
Based on a sequence seen <N> times in the user's shell history (confidence: <support/total>).
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Example — generated /ship skill
|
|
59
|
+
|
|
60
|
+
```markdown
|
|
61
|
+
---
|
|
62
|
+
name: ship
|
|
63
|
+
description: Stage all changes, commit with a message, and push in one step. Use when the user says "/ship" or asks to "commit and push", "ship this", "push the latest", or describes finishing a piece of work.
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
# ship
|
|
67
|
+
|
|
68
|
+
Automates the git add → commit → push sequence that you repeat frequently.
|
|
69
|
+
|
|
70
|
+
## The workflow
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git add .
|
|
74
|
+
git commit -m "<message>"
|
|
75
|
+
git push
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## When to trigger
|
|
79
|
+
|
|
80
|
+
- User types `/ship`
|
|
81
|
+
- User asks "commit and push this"
|
|
82
|
+
- User says "ship it"
|
|
83
|
+
- User asks to "push my latest changes"
|
|
84
|
+
|
|
85
|
+
## Steps
|
|
86
|
+
|
|
87
|
+
1. **Check for changes** — `git status --porcelain` (if empty, tell the user there's nothing to ship and stop)
|
|
88
|
+
2. **Stage** — `git add .`
|
|
89
|
+
3. **Commit** — ask the user for a commit message, then `git commit -m "<message>"`
|
|
90
|
+
4. **Push** — `git push` (if no upstream is set, run `git push -u origin HEAD` instead)
|
|
91
|
+
|
|
92
|
+
## Error handling
|
|
93
|
+
|
|
94
|
+
- If there are no changes, say so and stop.
|
|
95
|
+
- If the commit fails (e.g., pre-commit hook), show the error and don't push.
|
|
96
|
+
- If push is rejected (diverged branch), show the error and suggest `git pull --rebase` but don't run it automatically.
|
|
97
|
+
|
|
98
|
+
## Provenance
|
|
99
|
+
|
|
100
|
+
Created by clitree on 2026-04-10.
|
|
101
|
+
Based on a sequence seen 64 times in shell history (confidence: 64/1257 = 5.1% of all git usage).
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Fields to customize
|
|
105
|
+
|
|
106
|
+
When generating a skill, fill in:
|
|
107
|
+
|
|
108
|
+
- `<name>` — short, snake-case or kebab-case (e.g. `ship`, `push-latest`, `deploy-web`)
|
|
109
|
+
- `<description>` — one line, "Use when..." part is critical for triggering
|
|
110
|
+
- `<command N>` — the actual shell commands from the mined workflow
|
|
111
|
+
- `<natural phrasing>` — 2-3 ways the user might ask for this
|
|
112
|
+
- `<YYYY-MM-DD>` — today's date
|
|
113
|
+
- `<N>` — the number of times this sequence appeared in history
|
|
114
|
+
|
|
115
|
+
## Principles
|
|
116
|
+
|
|
117
|
+
- **Always include "When to trigger"** — this is how Claude decides to invoke the skill
|
|
118
|
+
- **Error handling matters** — users hate skills that blow through failures
|
|
119
|
+
- **Be honest about provenance** — users should know the skill came from their own usage, not from canned templates
|
|
120
|
+
- **Keep it minimal** — a skill with 3 clear steps beats one with 20 configurations
|