@kaynooo/cli-code 0.15.0 → 0.16.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 +93 -36
- package/package.json +9 -15
- package/dist/hotspots-cli.js +0 -1580
- package/dist/peek-cli.js +0 -1804
- package/dist/todo-scan-cli.js +0 -1573
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).
|
package/dist/cli.js
CHANGED
|
@@ -652,7 +652,7 @@ class Completing {
|
|
|
652
652
|
}
|
|
653
653
|
var completion = { active: false };
|
|
654
654
|
var OUTPUT_OPTIONS = {
|
|
655
|
-
color: { type: "string", description: "auto (on a terminal alone
|
|
655
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
656
656
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
657
657
|
};
|
|
658
658
|
function applyOutput(color, plain, env = process9.env) {
|
|
@@ -948,6 +948,66 @@ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs
|
|
|
948
948
|
import { dirname as dirname3, join as join5 } from "path";
|
|
949
949
|
import process14 from "process";
|
|
950
950
|
|
|
951
|
+
// ../kit/src/completions.ts
|
|
952
|
+
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
953
|
+
var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
|
|
954
|
+
set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
|
|
955
|
+
set -l current (commandline -ct)
|
|
956
|
+
for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
|
|
957
|
+
if test "$line" = __files__
|
|
958
|
+
__fish_complete_path $current
|
|
959
|
+
else
|
|
960
|
+
echo $line
|
|
961
|
+
end
|
|
962
|
+
end
|
|
963
|
+
end`;
|
|
964
|
+
var BASH_FUNCTION = `__kaynooo_cli_complete() {
|
|
965
|
+
local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
|
|
966
|
+
local -a lines
|
|
967
|
+
COMPREPLY=()
|
|
968
|
+
lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
969
|
+
for line in "\${lines[@]}"; do
|
|
970
|
+
if [[ $line == __files__ ]]; then
|
|
971
|
+
COMPREPLY+=($(compgen -f -- "$cur"))
|
|
972
|
+
else
|
|
973
|
+
words+="\${line%%$'\\t'*}"$'\\n'
|
|
974
|
+
fi
|
|
975
|
+
done
|
|
976
|
+
COMPREPLY+=($(compgen -W "$words" -- "$cur"))
|
|
977
|
+
}`;
|
|
978
|
+
var ZSH_FUNCTION = `__kaynooo_cli_complete() {
|
|
979
|
+
local line
|
|
980
|
+
local -a described plain
|
|
981
|
+
for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
|
|
982
|
+
if [[ $line == __files__ ]]; then
|
|
983
|
+
_files
|
|
984
|
+
elif [[ $line == *$'\\t'* ]]; then
|
|
985
|
+
described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
|
|
986
|
+
else
|
|
987
|
+
plain+=("$line")
|
|
988
|
+
fi
|
|
989
|
+
done
|
|
990
|
+
(( \${#described} )) && _describe -V value described
|
|
991
|
+
(( \${#plain} )) && compadd -- "\${plain[@]}"
|
|
992
|
+
return 0
|
|
993
|
+
}`;
|
|
994
|
+
function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
|
|
995
|
+
if (shell === "fish")
|
|
996
|
+
return `${header}
|
|
997
|
+
${FISH_FUNCTION}
|
|
998
|
+
${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
|
|
999
|
+
`).join("")}`;
|
|
1000
|
+
if (shell === "bash")
|
|
1001
|
+
return `${header}
|
|
1002
|
+
${BASH_FUNCTION}
|
|
1003
|
+
complete -F __kaynooo_cli_complete ${bins.join(" ")}
|
|
1004
|
+
`;
|
|
1005
|
+
return `${header}
|
|
1006
|
+
${ZSH_FUNCTION}
|
|
1007
|
+
compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
1008
|
+
`;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
951
1011
|
// ../kit/src/notify.ts
|
|
952
1012
|
import process12 from "process";
|
|
953
1013
|
var NOTIFY_AFTER_MS = 1e4;
|
|
@@ -1021,7 +1081,11 @@ var LEVEL_OPTIONS = {
|
|
|
1021
1081
|
...OUTPUT_OPTIONS,
|
|
1022
1082
|
help: { type: "boolean", short: "h", description: "show this help" }
|
|
1023
1083
|
};
|
|
1024
|
-
var TOP_OPTIONS = {
|
|
1084
|
+
var TOP_OPTIONS = {
|
|
1085
|
+
...LEVEL_OPTIONS,
|
|
1086
|
+
version: { type: "boolean", short: "v", description: "print the version" },
|
|
1087
|
+
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
1088
|
+
};
|
|
1025
1089
|
async function commandRows(all, colors) {
|
|
1026
1090
|
const commands = shown(all);
|
|
1027
1091
|
const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
|
|
@@ -1254,6 +1318,19 @@ async function candidates(scope, defaultCommand, words, before = []) {
|
|
|
1254
1318
|
}
|
|
1255
1319
|
return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
|
|
1256
1320
|
}
|
|
1321
|
+
var COMPLETIONS = "--completions";
|
|
1322
|
+
function flagValue([flag = "", ...rest]) {
|
|
1323
|
+
return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
|
|
1324
|
+
}
|
|
1325
|
+
function printCompletionScript(name, args) {
|
|
1326
|
+
const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
|
|
1327
|
+
if (shell === undefined || args.length !== 1) {
|
|
1328
|
+
printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
|
|
1329
|
+
return 2;
|
|
1330
|
+
}
|
|
1331
|
+
console.log(completionScript(shell, [name]).trimEnd());
|
|
1332
|
+
return 0;
|
|
1333
|
+
}
|
|
1257
1334
|
async function printCandidates(found) {
|
|
1258
1335
|
for (const line of await found)
|
|
1259
1336
|
console.log(line);
|
|
@@ -1278,6 +1355,8 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1278
1355
|
const version = cli.version ?? packageVersion();
|
|
1279
1356
|
if (argv[0] === COMPLETE)
|
|
1280
1357
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1358
|
+
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
1359
|
+
return printCompletionScript(cli.name, flagValue(argv));
|
|
1281
1360
|
const started = performance.now();
|
|
1282
1361
|
const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
|
|
1283
1362
|
const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
|
|
@@ -1304,28 +1383,6 @@ function commandPath(scope, argv) {
|
|
|
1304
1383
|
}
|
|
1305
1384
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1306
1385
|
}
|
|
1307
|
-
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1308
|
-
if (argv[0] === COMPLETE)
|
|
1309
|
-
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1310
|
-
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
1311
|
-
console.log(version ?? packageVersion());
|
|
1312
|
-
return 0;
|
|
1313
|
-
}
|
|
1314
|
-
let code;
|
|
1315
|
-
const started = performance.now();
|
|
1316
|
-
try {
|
|
1317
|
-
code = await run(argv);
|
|
1318
|
-
} catch (error) {
|
|
1319
|
-
code = reportThrown(name, error, redact, wantsJson(argv));
|
|
1320
|
-
}
|
|
1321
|
-
notifyEnd(name, code, performance.now() - started);
|
|
1322
|
-
if (usage !== false) {
|
|
1323
|
-
try {
|
|
1324
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1325
|
-
} catch {}
|
|
1326
|
-
}
|
|
1327
|
-
return code;
|
|
1328
|
-
}
|
|
1329
1386
|
// ../kit/src/folders.ts
|
|
1330
1387
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1331
1388
|
function ignoredFolders(extra = [], where = {}) {
|
|
@@ -1508,7 +1565,7 @@ var DEFAULT_BULK = configuredNumber("hotspots", "bulk", 25);
|
|
|
1508
1565
|
var DAY_MS2 = 86400000;
|
|
1509
1566
|
var DEFAULT_HALF_LIFE = "90d";
|
|
1510
1567
|
var DEFAULT_COUNT = configuredNumber("hotspots", "limit", 20);
|
|
1511
|
-
var USAGE = `hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
|
|
1568
|
+
var USAGE = `src hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
|
|
1512
1569
|
|
|
1513
1570
|
Complexity is the count of decision points in the file (branches, loops, cases, catches, boolean operators, ternaries) plus one, churn the commits touching it since --since (${DEFAULT_SINCE}), score their product. A commit counts for less the older it is (half as much every --half-life, 0 for all alike) and a commit touching more than --bulk files, a format or rename sweep, is left out. --by-lines scores the lines changed instead of the commits. Each file also shows how many lines changed, its author count ("solo" when one author wrote every change) and its most complex declaration, found by indentation. Test files and generated or built files are left out unless --all.
|
|
1514
1571
|
|
|
@@ -1526,7 +1583,7 @@ var OPTIONS = {
|
|
|
1526
1583
|
var HOT = 0.66;
|
|
1527
1584
|
var WARM = 0.33;
|
|
1528
1585
|
async function hotspots(args) {
|
|
1529
|
-
const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, positionals: ["[dir]"], replaces: "guessing which files are worth splitting first", examples: ["hotspots", 'hotspots src --since "3 months ago" --limit 10'] });
|
|
1586
|
+
const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, positionals: ["[dir]"], replaces: "guessing which files are worth splitting first", examples: ["hotspots", 'src hotspots src --since "3 months ago" --limit 10'] });
|
|
1530
1587
|
if (positionals.length > 1)
|
|
1531
1588
|
badUsage("give one folder");
|
|
1532
1589
|
const count = limitOf(values, DEFAULT_COUNT);
|
|
@@ -1756,14 +1813,14 @@ function locations(text) {
|
|
|
1756
1813
|
}
|
|
1757
1814
|
|
|
1758
1815
|
// src/peek.ts
|
|
1759
|
-
var USAGE2 = `peek [options] <file[:from-to]>...: prints files or line spans with their line numbers, several in one call
|
|
1816
|
+
var USAGE2 = `src peek [options] <file[:from-to]>...: prints files or line spans with their line numbers, several in one call
|
|
1760
1817
|
|
|
1761
|
-
peek src/a.ts:120-140 src/b.ts:1-40 the spans, src/a.ts:120 the one line, src/a.ts the whole file
|
|
1762
|
-
peek --def <symbol> [path...] the whole declaration of the symbol, its comments included, --def again for more symbols
|
|
1763
|
-
peek --refs <symbol> [path...] the lines naming the symbol, grouped by file, --defs-first printing its declarations before
|
|
1764
|
-
peek --outline <file>... the declarations and class members, a Markdown file's headings
|
|
1765
|
-
peek --around <regex> [-C 3] [path...] the lines around each match, overlapping ones merged
|
|
1766
|
-
<output> | peek [-C 3] the lines around each path:line the output opens a line with (errs, rg -n, grep -n, tsc, linters)
|
|
1818
|
+
src peek src/a.ts:120-140 src/b.ts:1-40 the spans, src/a.ts:120 the one line, src/a.ts the whole file
|
|
1819
|
+
src peek --def <symbol> [path...] the whole declaration of the symbol, its comments included, --def again for more symbols
|
|
1820
|
+
src peek --refs <symbol> [path...] the lines naming the symbol, grouped by file, --defs-first printing its declarations before
|
|
1821
|
+
src peek --outline <file>... the declarations and class members, a Markdown file's headings
|
|
1822
|
+
src peek --around <regex> [-C 3] [path...] the lines around each match, overlapping ones merged
|
|
1823
|
+
<output> | src peek [-C 3] the lines around each path:line the output opens a line with (errs, rg -n, grep -n, tsc, linters)
|
|
1767
1824
|
The paths default to the files git keeps here (.gitignore holds).
|
|
1768
1825
|
--refs lists at most 100 lines and --around prints at most 20 spans, the count of the rest after them (--limit <n>, --full for all).
|
|
1769
1826
|
--json prints spans as [{path, from, to, lines}], --refs as [{path, line, text}] ({definitions, references} with --defs-first), --outline as [{path, line, depth, text}], the lines never cut and the rows never counted off unless --limit is given.`;
|
|
@@ -1900,7 +1957,7 @@ async function definitionsOf(symbols, paths) {
|
|
|
1900
1957
|
return [...found.values()].flat();
|
|
1901
1958
|
}
|
|
1902
1959
|
async function peek(args) {
|
|
1903
|
-
const { values, positionals } = parse(args, USAGE2, OPTIONS2, { exits: EXITS2, positionals: ["[target...]"], replaces: "sed -n N,Mp, grep -n chains and whole-file reads", examples: [["peek src/a.ts:120-140 src/b.ts:1-40", "two spans in one call"], ["peek --def parseArgs src", "a whole declaration"]] });
|
|
1960
|
+
const { values, positionals } = parse(args, USAGE2, OPTIONS2, { exits: EXITS2, positionals: ["[target...]"], replaces: "sed -n N,Mp, grep -n chains and whole-file reads", examples: [["src peek src/a.ts:120-140 src/b.ts:1-40", "two spans in one call"], ["src peek --def parseArgs src", "a whole declaration"]] });
|
|
1904
1961
|
const modes = [values.def?.length === 0 ? undefined : values.def, values.refs, values.outline, values.around].filter((mode) => mode !== undefined && mode !== false);
|
|
1905
1962
|
const json = values.json === true;
|
|
1906
1963
|
if (values["defs-first"] === true && values.refs === undefined)
|
|
@@ -2082,7 +2139,7 @@ async function lookUp(refs, cwd) {
|
|
|
2082
2139
|
}
|
|
2083
2140
|
|
|
2084
2141
|
// src/todo-scan.ts
|
|
2085
|
-
var USAGE3 = `todo-scan [options] [path...]: lists the TODO, FIXME, HACK, XXX and owner/repo#N comments under the paths (here by default), each as <file>:<line>: <comment>, honouring .gitignore
|
|
2142
|
+
var USAGE3 = `src todo-scan [options] [path...]: lists the TODO, FIXME, HACK, XXX and owner/repo#N comments under the paths (here by default), each as <file>:<line>: <comment>, honouring .gitignore
|
|
2086
2143
|
|
|
2087
2144
|
--older <duration> keeps only the comments whose line last changed longer ago than that (30d, 12w, 6m: git blame dates each one, a file git cannot blame is left out) and shows each one's age.
|
|
2088
2145
|
|
|
@@ -2105,7 +2162,7 @@ function printLines(lines, footer) {
|
|
|
2105
2162
|
`));
|
|
2106
2163
|
}
|
|
2107
2164
|
async function todoScan(args) {
|
|
2108
|
-
const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[path...]"], replaces: "grep -rn TODO, then opening each issue it names", examples: ["todo-scan src", ["todo-scan --stale", "only the comments naming a closed issue"]] });
|
|
2165
|
+
const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[path...]"], replaces: "grep -rn TODO, then opening each issue it names", examples: ["src todo-scan src", ["src todo-scan --stale", "only the comments naming a closed issue"]] });
|
|
2109
2166
|
const cwd = process18.cwd();
|
|
2110
2167
|
const limit = limitOf(values, LIST_LIMIT);
|
|
2111
2168
|
const found = [];
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-code",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.16.0",
|
|
5
|
+
"description": "src: source read by spans, symbols and outlines in one call, the TODO and issue-reference comments of a repository with stale ones flagged, and the files ranked by complexity times git churn.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://
|
|
8
|
+
"homepage": "https://github.com/Kayno0o/cli/tree/main/packages/code#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://
|
|
11
|
+
"url": "git+https://github.com/Kayno0o/cli.git",
|
|
12
12
|
"directory": "packages/code"
|
|
13
13
|
},
|
|
14
|
-
"bugs": "https://
|
|
14
|
+
"bugs": "https://github.com/Kayno0o/cli/issues",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"claude-code",
|
|
17
17
|
"cli",
|
|
@@ -21,10 +21,7 @@
|
|
|
21
21
|
"hotspots"
|
|
22
22
|
],
|
|
23
23
|
"bin": {
|
|
24
|
-
"src": "./dist/cli.js"
|
|
25
|
-
"peek": "./dist/peek-cli.js",
|
|
26
|
-
"todo-scan": "./dist/todo-scan-cli.js",
|
|
27
|
-
"hotspots": "./dist/hotspots-cli.js"
|
|
24
|
+
"src": "./dist/cli.js"
|
|
28
25
|
},
|
|
29
26
|
"files": [
|
|
30
27
|
"dist"
|
|
@@ -36,16 +33,13 @@
|
|
|
36
33
|
"registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
|
|
37
34
|
},
|
|
38
35
|
"scripts": {
|
|
39
|
-
"build": "$npm_execpath build src/cli.ts
|
|
40
|
-
"src": "$npm_execpath src/cli.ts"
|
|
41
|
-
"peek": "$npm_execpath src/peek-cli.ts",
|
|
42
|
-
"todo-scan": "$npm_execpath src/todo-scan-cli.ts",
|
|
43
|
-
"hotspots": "$npm_execpath src/hotspots-cli.ts"
|
|
36
|
+
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist",
|
|
37
|
+
"src": "$npm_execpath src/cli.ts"
|
|
44
38
|
},
|
|
45
39
|
"dependencies": {
|
|
46
40
|
"@kaynooo/utils": "3.0.0"
|
|
47
41
|
},
|
|
48
42
|
"devDependencies": {
|
|
49
|
-
"@kaynooo/cli-kit": "0.
|
|
43
|
+
"@kaynooo/cli-kit": "0.41.0"
|
|
50
44
|
}
|
|
51
45
|
}
|