@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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +328 -0
  3. package/dist/archaeology/cache.d.ts +11 -0
  4. package/dist/archaeology/delegate.d.ts +43 -0
  5. package/dist/archaeology/index.d.ts +12 -0
  6. package/dist/archaeology/index.js +61 -0
  7. package/dist/archaeology/index.js.map +9 -0
  8. package/dist/archaeology/llm.d.ts +1 -0
  9. package/dist/archaeology/merge.d.ts +3 -0
  10. package/dist/archaeology/orchestrator.d.ts +25 -0
  11. package/dist/archaeology/prompts.d.ts +13 -0
  12. package/dist/archaeology/types.d.ts +101 -0
  13. package/dist/archaeology/validate.d.ts +18 -0
  14. package/dist/chunk-57gtsvhb.js +434 -0
  15. package/dist/chunk-57gtsvhb.js.map +16 -0
  16. package/dist/chunk-5aahbfr2.js +293 -0
  17. package/dist/chunk-5aahbfr2.js.map +10 -0
  18. package/dist/chunk-pkfpaae1.js +678 -0
  19. package/dist/chunk-pkfpaae1.js.map +15 -0
  20. package/dist/chunk-q4se2rwe.js +181 -0
  21. package/dist/chunk-q4se2rwe.js.map +14 -0
  22. package/dist/chunk-v5w3w6bd.js +168 -0
  23. package/dist/chunk-v5w3w6bd.js.map +11 -0
  24. package/dist/chunk-ykze151b.js +770 -0
  25. package/dist/chunk-ykze151b.js.map +16 -0
  26. package/dist/cli.d.ts +2 -0
  27. package/dist/cli.js +433 -0
  28. package/dist/cli.js.map +10 -0
  29. package/dist/encoders/ansi.d.ts +2 -0
  30. package/dist/encoders/html.d.ts +10 -0
  31. package/dist/encoders/string.d.ts +2 -0
  32. package/dist/flow/encode.d.ts +5 -0
  33. package/dist/flow/index.d.ts +8 -0
  34. package/dist/flow/index.js +25 -0
  35. package/dist/flow/index.js.map +9 -0
  36. package/dist/flow/layout.d.ts +30 -0
  37. package/dist/flow/parse.d.ts +2 -0
  38. package/dist/flow/render.d.ts +3 -0
  39. package/dist/flow/types.d.ts +42 -0
  40. package/dist/flow/validate.d.ts +3 -0
  41. package/dist/flow/yaml.d.ts +4 -0
  42. package/dist/grid.d.ts +14 -0
  43. package/dist/index.d.ts +7 -0
  44. package/dist/index.js +21 -0
  45. package/dist/index.js.map +9 -0
  46. package/dist/miner/history.d.ts +6 -0
  47. package/dist/miner/index.d.ts +18 -0
  48. package/dist/miner/index.js +38 -0
  49. package/dist/miner/index.js.map +9 -0
  50. package/dist/miner/sessions.d.ts +3 -0
  51. package/dist/miner/stats.d.ts +2 -0
  52. package/dist/miner/suggest.d.ts +11 -0
  53. package/dist/miner/transitions.d.ts +6 -0
  54. package/dist/miner/types.d.ts +46 -0
  55. package/dist/miner/workflows.d.ts +11 -0
  56. package/dist/parse.d.ts +3 -0
  57. package/dist/render.d.ts +3 -0
  58. package/dist/types.d.ts +39 -0
  59. package/package.json +85 -0
  60. package/skill/SKILL.md +263 -0
  61. package/skill/evals/evals.json +26 -0
  62. package/skill/install.sh +38 -0
  63. package/skill/references/archaeology-guide.md +157 -0
  64. package/skill/references/skill-template.md +120 -0
  65. package/src/archaeology/cache.ts +107 -0
  66. package/src/archaeology/delegate.ts +113 -0
  67. package/src/archaeology/index.ts +48 -0
  68. package/src/archaeology/llm.ts +10 -0
  69. package/src/archaeology/merge.ts +155 -0
  70. package/src/archaeology/orchestrator.ts +185 -0
  71. package/src/archaeology/prompts.ts +178 -0
  72. package/src/archaeology/types.ts +139 -0
  73. package/src/archaeology/validate.ts +157 -0
  74. package/src/cli.ts +451 -0
  75. package/src/encoders/ansi.ts +32 -0
  76. package/src/encoders/html.ts +78 -0
  77. package/src/encoders/string.ts +20 -0
  78. package/src/flow/encode.ts +21 -0
  79. package/src/flow/index.ts +15 -0
  80. package/src/flow/layout.ts +150 -0
  81. package/src/flow/parse.ts +100 -0
  82. package/src/flow/render.ts +186 -0
  83. package/src/flow/types.ts +45 -0
  84. package/src/flow/validate.ts +111 -0
  85. package/src/flow/yaml.ts +235 -0
  86. package/src/grid.ts +59 -0
  87. package/src/index.ts +24 -0
  88. package/src/miner/history.ts +156 -0
  89. package/src/miner/index.ts +76 -0
  90. package/src/miner/sessions.ts +39 -0
  91. package/src/miner/stats.ts +43 -0
  92. package/src/miner/suggest.ts +101 -0
  93. package/src/miner/transitions.ts +62 -0
  94. package/src/miner/types.ts +45 -0
  95. package/src/miner/workflows.ts +96 -0
  96. package/src/parse.ts +321 -0
  97. package/src/render.ts +182 -0
  98. package/src/types.ts +62 -0
  99. package/workflows/docker-deploy.yml +42 -0
  100. package/workflows/docker-parallel.yml +36 -0
  101. package/workflows/gh-issue-to-pr.yml +48 -0
  102. package/workflows/git-pr-flow.yml +36 -0
  103. package/workflows/kubectl-rollout.yml +37 -0
  104. package/workflows/npm-publish.yml +42 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Crafter Station
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,328 @@
1
+ # cli-tree
2
+
3
+ **Visualize and explore any CLI.** Parse help output, mine your shell history for real usage patterns, and (via a coding-agent skill) run LLM archaeology to discover hidden flags and canonical workflows.
4
+
5
+ Zero dependencies. Bun-native. Works as a library, a binary, or a skill for Claude Code / Cursor / Codex.
6
+
7
+ ---
8
+
9
+ ## What it does
10
+
11
+ ```
12
+ ┌─────────────┐
13
+ │ cli-tree │
14
+ └──────┬──────┘
15
+
16
+ ┌───────────┼───────────┐
17
+ ▼ ▼ ▼
18
+ ┌──────┐ ┌────────┐ ┌───────────┐
19
+ │ tree │ │ mine │ │archaeology│
20
+ └──────┘ └────────┘ └───────────┘
21
+ │ │ │
22
+ --help shell history LLM
23
+ parser markov chain (via skill)
24
+ ```
25
+
26
+ Four things:
27
+
28
+ 1. **`tree`** — parse `--help` output of any CLI into a navigable box-drawing tree. 53+ real CLIs tested.
29
+ 2. **`flow`** — render workflow YAML files as terminal DAGs (6 curated examples).
30
+ 3. **`mine`** — analyze your shell history, detect repeated sequences, surface skill suggestions.
31
+ 4. **`archaeology`** — merge all three + LLM-proposed hidden flags, validated against real `--help`.
32
+
33
+ ---
34
+
35
+ ## Install
36
+
37
+ From npm (recommended):
38
+
39
+ ```bash
40
+ # One-shot (no install)
41
+ bunx @crafter/cli-tree git
42
+ npx @crafter/cli-tree git
43
+
44
+ # Global install
45
+ bun add -g @crafter/cli-tree
46
+ npm i -g @crafter/cli-tree
47
+
48
+ # Then
49
+ clitree git
50
+ clitree mine bun
51
+ clitree archaeology docker
52
+ ```
53
+
54
+ As a library in your project:
55
+
56
+ ```bash
57
+ bun add @crafter/cli-tree
58
+ ```
59
+
60
+ ```ts
61
+ import { parseHelpRecursive } from "@crafter/cli-tree";
62
+ import { mineCli } from "@crafter/cli-tree/miner";
63
+ import { runArchaeology } from "@crafter/cli-tree/archaeology";
64
+ ```
65
+
66
+ From source:
67
+
68
+ ```bash
69
+ git clone https://github.com/crafter-station/cli-tree
70
+ cd cli-tree
71
+ bun install
72
+ bun src/cli.ts --help
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Usage
78
+
79
+ ### Tree — parse any CLI's help output
80
+
81
+ ```bash
82
+ clitree git
83
+ clitree docker --depth 2
84
+ clitree kubectl --compact --no-flags
85
+ clitree bun --format html > bun-tree.html
86
+ docker --help | clitree --stdin docker
87
+ ```
88
+
89
+ ### Flow — render workflow YAML as DAG
90
+
91
+ ```bash
92
+ clitree flow workflows/git-pr-flow.yml
93
+ clitree flow workflows/docker-deploy.yml --format html
94
+ ```
95
+
96
+ Workflow YAML looks like:
97
+
98
+ ```yaml
99
+ name: pr-flow
100
+ cli: git
101
+ description: Typical flow for creating a pull request
102
+ nodes:
103
+ - id: add
104
+ command: git add .
105
+ - id: commit
106
+ command: git commit
107
+ - id: push
108
+ command: git push
109
+ - id: pr
110
+ command: gh pr create
111
+ optional: true
112
+ edges:
113
+ - add -> commit
114
+ - commit -> push
115
+ - push -> pr
116
+ ```
117
+
118
+ Output (ASCII, ANSI, or HTML):
119
+
120
+ ```
121
+ git · pr-flow
122
+ Typical flow for creating a pull request
123
+
124
+ ┌─────────────────┐
125
+ │ git add │
126
+ └─────────────────┘
127
+
128
+
129
+ ┌─────────────────┐
130
+ │ git commit │
131
+ └─────────────────┘
132
+
133
+
134
+ ┌─────────────────┐
135
+ │ git push │
136
+ └─────────────────┘
137
+
138
+
139
+ ┌┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┐
140
+ ┊ gh pr create ┊
141
+ └┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┘
142
+ ```
143
+
144
+ ### Mine — discover workflows from your shell history
145
+
146
+ ```bash
147
+ clitree mine git
148
+ clitree mine docker --min-support 5
149
+ clitree mine bun --format json > bun-flows.json
150
+ ```
151
+
152
+ Example output against real zsh history:
153
+
154
+ ```
155
+ git — shell history analysis
156
+
157
+ Usage:
158
+ Invocations: 1257
159
+ Subcommands: 31
160
+ Sessions: 483
161
+
162
+ Top subcommands:
163
+ commit ██████████████████████████████ 277
164
+ checkout ██████████████████████████ 237
165
+ push ████████████████████ 183
166
+ add ██████████████████ 167
167
+ pull █████████████ 124
168
+
169
+ Discovered workflows:
170
+ add → commit (116×)
171
+ commit → push (85×)
172
+ add → commit → push (64×)
173
+ checkout → pull (38×)
174
+
175
+ 💡 Skill suggestions:
176
+
177
+ [MED] /ship — Run git add, then commit, then push as one command
178
+ You run this exact sequence 64 times — that's a lot of repetition
179
+ git add && git commit && git push
180
+ ```
181
+
182
+ ### Archaeology — full analysis
183
+
184
+ ```bash
185
+ clitree archaeology git # deterministic phases
186
+ clitree archaeology docker --no-cache
187
+ ```
188
+
189
+ Without the skill, archaeology runs `--help` parsing + history mining. For LLM-backed hidden-flag discovery, install the clitree skill (see below).
190
+
191
+ ---
192
+
193
+ ## The clitree skill
194
+
195
+ The LLM-archaeology phase lives in a coding-agent skill. It is **agent-agnostic**: the skill is just markdown instructions that any coding agent (Claude Code, Cursor, Codex, Aider) can execute.
196
+
197
+ Install:
198
+
199
+ ```bash
200
+ bash ./skill/install.sh
201
+ ```
202
+
203
+ Then, inside your coding agent:
204
+
205
+ ```
206
+ /clitree git
207
+ ```
208
+
209
+ The agent will:
210
+
211
+ 1. Parse `git --help` recursively.
212
+ 2. Mine your shell history for real workflows.
213
+ 3. **Use its own LLM** to propose hidden/undocumented flags.
214
+ 4. **Validate every proposal** by running `git <sub> --help` and checking man pages.
215
+ 5. **Reject hallucinations** automatically — only flags that actually exist make it into the final tree.
216
+ 6. **Suggest new skills** based on workflows you repeat often.
217
+
218
+ No API keys. No external services. Works entirely inside your coding agent.
219
+
220
+ ---
221
+
222
+ ## How archaeology works
223
+
224
+ The key insight is that an LLM's knowledge of a CLI is **unreliable alone** but **rich when validated**. Archaeology uses a closed loop:
225
+
226
+ ```
227
+ ┌─────────────┐ proposes ┌───────────────┐
228
+ │ The LLM │ ─────────────────► │ cli-tree │
229
+ │ (in agent) │ │ validator │
230
+ └─────────────┘ └───────┬───────┘
231
+ ▲ │
232
+ │ next proposal │ runs
233
+ │ ▼
234
+ │ ┌──────────────────┐
235
+ │ │ <cli> <sub> │
236
+ └────── verdict ─────────│ --help / man │
237
+ └──────────────────┘
238
+ verify or reject
239
+ ```
240
+
241
+ - **LLM proposes** → hidden flags, canonical workflows, constraint maps
242
+ - **Code executes** → `git commit --fixup` → real output → compare
243
+ - **Truth survives** → only verified facts become part of the enriched tree
244
+
245
+ Every piece of data carries a **source tag**:
246
+
247
+ | Source | Confidence | Behavior |
248
+ |--------|-----------|----------|
249
+ | `help` | 1.0 | From parsed `--help` output |
250
+ | `llm-validated` | 0.9 | LLM proposed, confirmed by `--help` |
251
+ | `man` | 0.85 | From man page |
252
+ | `llm-deep-dive` | 0.6 | LLM proposed, not confirmed (shown with `--include-unverified`) |
253
+ | `llm-survey` | 0.2 | LLM hypothesis, rejected by validation |
254
+
255
+ By default, only sources above `llm-validated` are shown.
256
+
257
+ ---
258
+
259
+ ## Architecture
260
+
261
+ ```
262
+ src/
263
+ ├── parse.ts # --help parser (53 CLIs tested)
264
+ ├── tree.ts # tree renderer (box-drawing)
265
+ ├── compile.ts # chart primitives
266
+
267
+ ├── miner/ # shell history mining
268
+ │ ├── history.ts # zsh/bash/fish parser
269
+ │ ├── sessions.ts # temporal segmentation
270
+ │ ├── transitions.ts # markov chain
271
+ │ ├── workflows.ts # path clustering
272
+ │ ├── stats.ts # usage statistics
273
+ │ └── suggest.ts # skill suggestions
274
+
275
+ ├── archaeology/ # LLM-backed exploration
276
+ │ ├── types.ts # Source/EnrichedCLINode
277
+ │ ├── prompts.ts # 4-phase prompt templates
278
+ │ ├── validate.ts # closed-loop validation
279
+ │ ├── merge.ts # multi-source merge
280
+ │ ├── cache.ts # ~/.clitree/cache/
281
+ │ ├── delegate.ts # agent-agnostic delegate
282
+ │ └── orchestrator.ts # runs all phases
283
+
284
+ ├── flow/ # workflow DAG rendering
285
+ │ ├── types.ts
286
+ │ ├── yaml.ts # zero-dep YAML parser
287
+ │ ├── layout.ts # rank-based layout
288
+ │ ├── render.ts # box-drawing DAG
289
+ │ └── encode.ts
290
+
291
+ └── cli.ts # binary entrypoint
292
+ ```
293
+
294
+ ---
295
+
296
+ ## Tests
297
+
298
+ ```bash
299
+ bun test # run all (~290 tests)
300
+ bun test tests/flow # flow subsystem
301
+ bun test tests/miner # miner subsystem
302
+ bun test tests/archaeology # archaeology subsystem
303
+ bun test tests/parse-real-clis # 53+ real CLIs
304
+ ```
305
+
306
+ Recent run: **287 tests passing, 0 fails** across 8 test files.
307
+
308
+ ---
309
+
310
+ ## Roadmap
311
+
312
+ - [x] `--help` parser (53 CLIs)
313
+ - [x] Box-drawing tree renderer (ANSI / string / HTML)
314
+ - [x] Workflow YAML DAG renderer
315
+ - [x] Shell history miner (zsh / bash / fish)
316
+ - [x] Skill suggestions from repeated workflows
317
+ - [x] Archaeology types + validation loop + merge
318
+ - [x] Disk cache
319
+ - [x] Agent-agnostic skill
320
+ - [ ] Makefile / package.json / Dockerfile scraping
321
+ - [ ] Interactive TUI mode
322
+ - [ ] Mermaid export for flows
323
+
324
+ ---
325
+
326
+ ## License
327
+
328
+ MIT
@@ -0,0 +1,11 @@
1
+ import type { ArchaeologyCache, EnrichedCLINode } from "./types";
2
+ export interface CacheOptions {
3
+ cacheDir?: string;
4
+ ttlDays?: number;
5
+ }
6
+ export declare function loadCache(cli: string, opts?: CacheOptions): Promise<ArchaeologyCache | null>;
7
+ export declare function saveCache(cli: string, cache: ArchaeologyCache, opts?: CacheOptions): Promise<void>;
8
+ export declare function invalidateCache(cli: string, opts?: CacheOptions): Promise<void>;
9
+ export declare function isCacheStale(cache: ArchaeologyCache, currentVersion?: string, ttlDays?: number): boolean;
10
+ export declare function detectCliVersion(binary: string): Promise<string | undefined>;
11
+ export declare function createEmptyCache(cli: string, tree: EnrichedCLINode, cliVersion?: string): ArchaeologyCache;
@@ -0,0 +1,43 @@
1
+ import type { DeepDiveProposal, SurveyHypothesis, FlagConstraint } from "./types";
2
+ export interface ArchaeologyDelegate {
3
+ readonly name: string;
4
+ readonly available: boolean;
5
+ survey?(cli: string, version?: string): Promise<SurveyHypothesis>;
6
+ proposeHiddenFlags?(cli: string, subcommand: string[]): Promise<DeepDiveProposal>;
7
+ proposeConstraints?(cli: string, subcommand: string[]): Promise<FlagConstraint[]>;
8
+ }
9
+ export declare class NullDelegate implements ArchaeologyDelegate {
10
+ readonly name = "null";
11
+ readonly available = false;
12
+ }
13
+ export declare class BridgeFileDelegate implements ArchaeologyDelegate {
14
+ readonly name = "bridge-file";
15
+ readonly available = true;
16
+ private requestsPath;
17
+ private responsesPath;
18
+ private timeoutMs;
19
+ constructor(opts?: {
20
+ requestsPath?: string;
21
+ responsesPath?: string;
22
+ timeoutMs?: number;
23
+ });
24
+ survey(cli: string, version?: string): Promise<SurveyHypothesis>;
25
+ proposeHiddenFlags(cli: string, subcommand: string[]): Promise<DeepDiveProposal>;
26
+ proposeConstraints(cli: string, subcommand: string[]): Promise<FlagConstraint[]>;
27
+ private writeRequest;
28
+ private awaitResponse;
29
+ private readFile;
30
+ }
31
+ export declare class InlineDelegate implements ArchaeologyDelegate {
32
+ private handlers;
33
+ readonly name = "inline";
34
+ readonly available = true;
35
+ constructor(handlers: {
36
+ survey?: (cli: string, version?: string) => Promise<SurveyHypothesis>;
37
+ proposeHiddenFlags?: (cli: string, subcommand: string[]) => Promise<DeepDiveProposal>;
38
+ proposeConstraints?: (cli: string, subcommand: string[]) => Promise<FlagConstraint[]>;
39
+ });
40
+ survey(cli: string, version?: string): Promise<SurveyHypothesis>;
41
+ proposeHiddenFlags(cli: string, subcommand: string[]): Promise<DeepDiveProposal>;
42
+ proposeConstraints(cli: string, subcommand: string[]): Promise<FlagConstraint[]>;
43
+ }
@@ -0,0 +1,12 @@
1
+ export type { Source, SourceKind, EnrichedCLINode, EnrichedFlag, EnrichedArg, Example, FlagConstraint, SurveyHypothesis, DeepDiveProposal, ValidationVerdict, ArchaeologyCache, ArchaeologyOptions, } from "./types";
2
+ export { toCLINode, fromCLINode } from "./types";
3
+ export { surveyPrompt, excavationPrompt, deepDivePrompt, cartographyPrompt, validationInstructions, extractJsonFromLlmResponse, } from "./prompts";
4
+ export { runHelpCommand, validateSubcommandExists, validateSurvey, excavateCommand, validateDeepDive, summarizeValidation, } from "./validate";
5
+ export type { ValidationSummary } from "./validate";
6
+ export { mergeNodes, filterUnverified } from "./merge";
7
+ export { loadCache, saveCache, invalidateCache, isCacheStale, detectCliVersion, createEmptyCache } from "./cache";
8
+ export type { CacheOptions } from "./cache";
9
+ export type { ArchaeologyDelegate } from "./delegate";
10
+ export { NullDelegate, BridgeFileDelegate, InlineDelegate } from "./delegate";
11
+ export { runArchaeology, enrichedToTree } from "./orchestrator";
12
+ export type { ArchaeologyProgress, ArchaeologyResult } from "./orchestrator";
@@ -0,0 +1,61 @@
1
+ import {
2
+ BridgeFileDelegate,
3
+ InlineDelegate,
4
+ NullDelegate,
5
+ cartographyPrompt,
6
+ createEmptyCache,
7
+ deepDivePrompt,
8
+ detectCliVersion,
9
+ enrichedToTree,
10
+ excavateCommand,
11
+ excavationPrompt,
12
+ extractJsonFromLlmResponse,
13
+ filterUnverified,
14
+ fromCLINode,
15
+ invalidateCache,
16
+ isCacheStale,
17
+ loadCache,
18
+ mergeNodes,
19
+ runArchaeology,
20
+ runHelpCommand,
21
+ saveCache,
22
+ summarizeValidation,
23
+ surveyPrompt,
24
+ toCLINode,
25
+ validateDeepDive,
26
+ validateSubcommandExists,
27
+ validateSurvey,
28
+ validationInstructions
29
+ } from "../chunk-ykze151b.js";
30
+ import"../chunk-5aahbfr2.js";
31
+ export {
32
+ validationInstructions,
33
+ validateSurvey,
34
+ validateSubcommandExists,
35
+ validateDeepDive,
36
+ toCLINode,
37
+ surveyPrompt,
38
+ summarizeValidation,
39
+ saveCache,
40
+ runHelpCommand,
41
+ runArchaeology,
42
+ mergeNodes,
43
+ loadCache,
44
+ isCacheStale,
45
+ invalidateCache,
46
+ fromCLINode,
47
+ filterUnverified,
48
+ extractJsonFromLlmResponse,
49
+ excavationPrompt,
50
+ excavateCommand,
51
+ enrichedToTree,
52
+ detectCliVersion,
53
+ deepDivePrompt,
54
+ createEmptyCache,
55
+ cartographyPrompt,
56
+ NullDelegate,
57
+ InlineDelegate,
58
+ BridgeFileDelegate
59
+ };
60
+
61
+ //# debugId=EAE38CC12C5BE71664756E2164756E21
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "EAE38CC12C5BE71664756E2164756E21",
8
+ "names": []
9
+ }
@@ -0,0 +1 @@
1
+ export { type ArchaeologyDelegate, NullDelegate, BridgeFileDelegate, InlineDelegate, } from "./delegate";
@@ -0,0 +1,3 @@
1
+ import type { EnrichedCLINode } from "./types";
2
+ export declare function mergeNodes(a: EnrichedCLINode, b: EnrichedCLINode): EnrichedCLINode;
3
+ export declare function filterUnverified(node: EnrichedCLINode): EnrichedCLINode;
@@ -0,0 +1,25 @@
1
+ import { type EnrichedCLINode, type ArchaeologyOptions } from "./types";
2
+ import type { ArchaeologyDelegate } from "./delegate";
3
+ import type { CLINode } from "../types";
4
+ export interface ArchaeologyProgress {
5
+ phase: "cache" | "excavation" | "survey" | "deep-dive" | "cartography" | "merge" | "done";
6
+ message: string;
7
+ percent?: number;
8
+ }
9
+ export interface ArchaeologyResult {
10
+ tree: EnrichedCLINode;
11
+ stats: {
12
+ helpCommands: number;
13
+ llmProposed: number;
14
+ verified: number;
15
+ rejected: number;
16
+ unconfirmed: number;
17
+ hallucinations: string[];
18
+ };
19
+ fromCache: boolean;
20
+ }
21
+ export declare function runArchaeology(binary: string, delegate?: ArchaeologyDelegate, opts?: ArchaeologyOptions & {
22
+ onProgress?: (p: ArchaeologyProgress) => void;
23
+ maxHelpDepth?: number;
24
+ }): Promise<ArchaeologyResult>;
25
+ export declare function enrichedToTree(enriched: EnrichedCLINode): CLINode;
@@ -0,0 +1,13 @@
1
+ import type { EnrichedCLINode } from "./types";
2
+ export interface PromptContext {
3
+ cli: string;
4
+ version?: string;
5
+ knownCommands?: string[];
6
+ knownTree?: EnrichedCLINode;
7
+ }
8
+ export declare function surveyPrompt(ctx: PromptContext): string;
9
+ export declare function excavationPrompt(ctx: PromptContext, subcommandPath: string[]): string;
10
+ export declare function deepDivePrompt(ctx: PromptContext, subcommandPath: string[]): string;
11
+ export declare function cartographyPrompt(ctx: PromptContext, subcommandPath: string[]): string;
12
+ export declare function validationInstructions(cli: string): string;
13
+ export declare function extractJsonFromLlmResponse(response: string): unknown;
@@ -0,0 +1,101 @@
1
+ import type { CLINode, Flag, Arg } from "../types";
2
+ export type SourceKind = "help" | "llm-survey" | "llm-deep-dive" | "llm-cartography" | "llm-validated" | "man" | "completion" | "user";
3
+ export interface Source {
4
+ type: SourceKind;
5
+ confidence: number;
6
+ verifiedAt?: string;
7
+ note?: string;
8
+ }
9
+ export interface EnrichedFlag extends Flag {
10
+ hidden?: boolean;
11
+ deprecated?: boolean;
12
+ experimental?: boolean;
13
+ source?: Source;
14
+ examples?: string[];
15
+ excludes?: string[];
16
+ requires?: string[];
17
+ }
18
+ export interface EnrichedArg extends Arg {
19
+ source?: Source;
20
+ }
21
+ export interface Example {
22
+ command: string;
23
+ description?: string;
24
+ source?: Source;
25
+ }
26
+ export interface FlagConstraint {
27
+ type: "mutually-exclusive" | "requires" | "implies";
28
+ flags: string[];
29
+ description?: string;
30
+ }
31
+ export interface EnrichedCLINode {
32
+ name: string;
33
+ description?: string;
34
+ aliases?: string[];
35
+ hidden?: boolean;
36
+ deprecated?: boolean;
37
+ experimental?: boolean;
38
+ subcommands?: EnrichedCLINode[];
39
+ flags?: EnrichedFlag[];
40
+ args?: EnrichedArg[];
41
+ constraints?: FlagConstraint[];
42
+ examples?: Example[];
43
+ source?: Source;
44
+ }
45
+ export interface SurveyHypothesis {
46
+ cli: string;
47
+ description: string;
48
+ families: Array<{
49
+ name: string;
50
+ description: string;
51
+ subcommands: string[];
52
+ }>;
53
+ topLevelFlags: string[];
54
+ }
55
+ export interface DeepDiveProposal {
56
+ command: string[];
57
+ flags: Array<{
58
+ name: string;
59
+ short?: string;
60
+ type: "boolean" | "string" | "number" | "enum";
61
+ hidden?: boolean;
62
+ deprecated?: boolean;
63
+ description?: string;
64
+ }>;
65
+ examples: string[];
66
+ }
67
+ export interface ValidationVerdict {
68
+ command: string[];
69
+ exists: boolean;
70
+ verifiedFlags: string[];
71
+ rejectedFlags: string[];
72
+ unconfirmedFlags: string[];
73
+ rawHelp?: string;
74
+ error?: string;
75
+ }
76
+ export interface ArchaeologyCache {
77
+ cli: string;
78
+ cliVersion?: string;
79
+ createdAt: string;
80
+ tree: EnrichedCLINode;
81
+ phases: {
82
+ survey: boolean;
83
+ excavation: boolean;
84
+ deepDive: boolean;
85
+ cartography: boolean;
86
+ };
87
+ }
88
+ export interface ArchaeologyOptions {
89
+ cacheDir?: string;
90
+ skipCache?: boolean;
91
+ includeUnverified?: boolean;
92
+ maxDepth?: number;
93
+ phases?: {
94
+ survey?: boolean;
95
+ excavation?: boolean;
96
+ deepDive?: boolean;
97
+ cartography?: boolean;
98
+ };
99
+ }
100
+ export declare function toCLINode(node: EnrichedCLINode): CLINode;
101
+ export declare function fromCLINode(node: CLINode, source?: Source): EnrichedCLINode;
@@ -0,0 +1,18 @@
1
+ import type { CLINode } from "../types";
2
+ import type { ValidationVerdict, SurveyHypothesis, DeepDiveProposal } from "./types";
3
+ export declare function runHelpCommand(binary: string, subcommandPath: string[]): Promise<string | null>;
4
+ export declare function validateSubcommandExists(binary: string, subcommandPath: string[]): Promise<boolean>;
5
+ export declare function validateSurvey(binary: string, survey: SurveyHypothesis): Promise<{
6
+ confirmed: string[];
7
+ rejected: string[];
8
+ }>;
9
+ export declare function excavateCommand(binary: string, subcommandPath: string[]): Promise<CLINode | null>;
10
+ export declare function validateDeepDive(binary: string, proposal: DeepDiveProposal): Promise<ValidationVerdict>;
11
+ export interface ValidationSummary {
12
+ totalProposed: number;
13
+ verified: number;
14
+ rejected: number;
15
+ unconfirmed: number;
16
+ hallucinations: string[];
17
+ }
18
+ export declare function summarizeValidation(verdicts: ValidationVerdict[]): ValidationSummary;