@kaynooo/cli-code 0.15.1 → 0.17.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/README.md +19 -19
- package/dist/cli.js +675 -210
- package/package.json +10 -16
- package/dist/hotspots-cli.js +0 -1661
- package/dist/peek-cli.js +0 -1885
- package/dist/todo-scan-cli.js +0 -1654
package/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# src
|
|
2
2
|
|
|
3
|
-
Reads source for Claude Code in fewer calls and fewer tokens: `peek` prints the spans, declarations, usages and outlines a session would otherwise get from `sed -n N,Mp`, `grep -n` chains and whole-file reads, and `todo-scan` lists the TODO and issue-reference comments of a repository, flagging the ones whose issue is closed.
|
|
3
|
+
Reads source for Claude Code in fewer calls and fewer tokens: `src peek` prints the spans, declarations, usages and outlines a session would otherwise get from `sed -n N,Mp`, `grep -n` chains and whole-file reads, and `src todo-scan` lists the TODO and issue-reference comments of a repository, flagging the ones whose issue is closed.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
bun install -g @kaynooo/cli-code
|
|
7
|
-
peek src/a.ts:120-140 src/b.ts:1-40
|
|
8
|
-
peek --def parseCommand
|
|
9
|
-
peek --refs parseCommand packages/guard
|
|
10
|
-
peek --outline src/cli.ts README.md
|
|
11
|
-
peek --around 'TODO|FIXME' -C 2 src
|
|
12
|
-
errs -- bun check | peek
|
|
13
|
-
todo-scan
|
|
14
|
-
todo-scan --stale
|
|
15
|
-
hotspots --since '3 months ago' --limit 10
|
|
7
|
+
src peek src/a.ts:120-140 src/b.ts:1-40
|
|
8
|
+
src peek --def parseCommand
|
|
9
|
+
src peek --refs parseCommand packages/guard
|
|
10
|
+
src peek --outline src/cli.ts README.md
|
|
11
|
+
src peek --around 'TODO|FIXME' -C 2 src
|
|
12
|
+
errs -- bun check | src peek
|
|
13
|
+
src todo-scan
|
|
14
|
+
src todo-scan --stale
|
|
15
|
+
src hotspots --since '3 months ago' --limit 10
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## peek
|
|
18
|
+
## src peek
|
|
19
19
|
|
|
20
|
-
- `peek <file[:from-to]>...` prints each span under a `<file>:<from>-<to>` header, each line with its number, so an edit can target it; `<file>:<n>` is one line, a bare `<file>` the whole file. A line past 300 characters is cut.
|
|
20
|
+
- `src peek <file[:from-to]>...` prints each span under a `<file>:<from>-<to>` header, each line with its number, so an edit can target it; `<file>:<n>` is one line, a bare `<file>` the whole file. A line past 300 characters is cut.
|
|
21
21
|
- `--def <symbol>` prints each declaration of the symbol, the comments and decorators right above it included: a `function`, `class`, `interface`, `type`, `enum`, `const`/`let`/`var` or `namespace` (and Python's `def`/`class`, Go's `func`, Rust's `fn`/`struct`/`trait`), or a class member whose parameters follow its name. Its end is where its braces close, strings and line comments left out of the count, or for Python and YAML where its indentation ends.
|
|
22
22
|
- `--refs <symbol>` lists the lines naming the symbol as a whole word, grouped by file, one trimmed line each, at most 100 (`--limit <n>`, `--full` for all, the count of the rest after them). `--defs-first` prints the symbol's declarations before them (`{definitions, references}` under `--json`).
|
|
23
|
-
- `--def` repeats for several symbols in one call (`peek --def a --def b src`); one with no declaration is named and exits 1.
|
|
23
|
+
- `--def` repeats for several symbols in one call (`src peek --def a --def b src`); one with no declaration is named and exits 1.
|
|
24
24
|
- `--outline <file>...` lists the declarations at the top of each file and the members one level inside its classes, with their line numbers; a Markdown file lists its headings.
|
|
25
25
|
- `--around <regex> -C <n>` prints the `n` (3) lines on each side of each matching line, spans that touch merged, at most 20 spans (`--limit`, `--full`, the count of the rest after them).
|
|
26
26
|
- Piped into with no file and no mode, it reads the `path:line` opening each line of the input (`errs`, `rg -n`, `grep -n`, a linter's `path:line:col`, tsc's `path(line,col)`) and prints the `-C` (3) lines around each, spans that touch merged and files in the order first named; a path outside the repository or not readable is skipped, and nothing readable exits 1.
|
|
@@ -29,17 +29,17 @@ hotspots --since '3 months ago' --limit 10
|
|
|
29
29
|
- The symbols are found by pattern, not by a type checker: a name declared twice in a file shows twice, and a symbol re-exported under another name is not followed.
|
|
30
30
|
- A path must lie inside the repository (a symlink out of it counts as outside), absolute or relative. Exits 1 when nothing is found, a file cannot be read or a span starts past the end, 2 on a usage error or a path outside the repository.
|
|
31
31
|
|
|
32
|
-
## todo-scan
|
|
32
|
+
## src todo-scan
|
|
33
33
|
|
|
34
|
-
- `todo-scan [path...]` prints `<file>:<line>: <comment>` for each comment holding `TODO`, `FIXME` or an `owner/repo#N` reference, over the same files as `peek`. A comment opens with `//` (not a URL's), `/*`, `<!--`, a `#` or `--` standing alone, or the `*` of a block comment's line; in Markdown and HTML only `<!--` does.
|
|
34
|
+
- `src todo-scan [path...]` prints `<file>:<line>: <comment>` for each comment holding `TODO`, `FIXME` or an `owner/repo#N` reference, over the same files as `src peek`. A comment opens with `//` (not a URL's), `/*`, `<!--`, a `#` or `--` standing alone, or the `*` of a block comment's line; in Markdown and HTML only `<!--` does.
|
|
35
35
|
- `--stale` looks each referenced issue up with `ft issue <n>... -r <owner/repo> --json`, one call per repository, or with `gh api` for a repository Forgejo does not have (a GitHub one), keeps the comments naming a closed issue (`src/a.ts:3: kaynooo/kayjs#823 closed: ...`) and exits 1 when it finds one; a repository neither can reach is named on stderr and makes the run exit 2 when no stale comment was found, so a clean exit never hides an unchecked issue. `ft` is needed only for a reference it can look up.
|
|
36
36
|
- `--json` prints `[{path, line, kind, text, refs}]`, each ref with its `state` under `--stale`.
|
|
37
37
|
|
|
38
|
-
## hotspots
|
|
38
|
+
## src hotspots
|
|
39
39
|
|
|
40
|
-
- `hotspots [dir]` ranks the source files by complexity times churn, so the files both hard to read and often edited come first: rank, score, churn, recent, complexity, lines, file and the file's most complex declaration. The files are the ones git keeps (`.gitignore` honoured).
|
|
40
|
+
- `src hotspots [dir]` ranks the source files by complexity times churn, so the files both hard to read and often edited come first: rank, score, churn, recent, complexity, lines, file and the file's most complex declaration. The files are the ones git keeps (`.gitignore` honoured).
|
|
41
41
|
- Churn is the commits touching the file since `--since` (any date git reads, `6 months ago` by default), counted from one `git log`. The score uses `recent`, the commits weighted by age (half as much every `--half-life`, `90d` by default, `0` to count them alike), and leaves out the commits touching more than `--bulk` files (25), the format and rename sweeps. Complexity is the decision points of the file (`if`, loops, `case`, `catch`, `&&`, `||`, `??`, ternaries, `and`/`or`) plus one, counted with comments and strings blanked; it is computed in-house (js, ts, vue, svelte, astro, kay, php, py, go, rs, rb, java, kt, swift, cs, c, cpp, scala, dart, lua and shell files are ranked) so the bin needs no dependency and reads any language the same way.
|
|
42
42
|
- `--limit <n>` (`-n`) sets how many files are listed (20, the count of the rest after them), `--full` lists all, `--json` is never cut unless `--limit` is given. `--all` keeps test files and generated files (`dist/`, `*.d.ts`, `*.min.js`, snapshots, files whose first lines say generated), `--json` prints `[{rank, path, score, churn, recent, complexity, worst, lines}]`. The most complex declaration is found from the indentation alone (a class is opened into its methods), so it reads any language the same way.
|
|
43
43
|
- Exits 1 when no file has commits in the window, 2 on a usage error or outside a git repository.
|
|
44
44
|
|
|
45
|
-
`~/.config/kaynooo-cli/hotspots.json` (`$XDG_CONFIG_HOME/kaynooo-cli/` when set) changes the defaults of `hotspots`: `since` (a date as git reads it, `6 months ago`), `bulk` (25) and `limit` (20, the files listed).
|
|
45
|
+
`~/.config/kaynooo-cli/hotspots.json` (`$XDG_CONFIG_HOME/kaynooo-cli/` when set) changes the defaults of `src hotspots`: `since` (a date as git reads it, `6 months ago`), `bulk` (25) and `limit` (20, the files listed).
|