@ulpi/codemap 0.3.11 → 0.3.12
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 +29 -0
- package/dist/index.js +153 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,6 +111,35 @@ codemap watch --debounce 500
|
|
|
111
111
|
|--------|-------------|---------|
|
|
112
112
|
| `--debounce <ms>` | Debounce interval | `300` |
|
|
113
113
|
|
|
114
|
+
### `codemap statusline`
|
|
115
|
+
|
|
116
|
+
Install a CodeMap status indicator into Claude Code's statusline. It extends your existing statusline (if any) and appends CodeMap info.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
codemap statusline # Install
|
|
120
|
+
codemap statusline --uninstall # Remove and restore previous statusline
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The statusline shows at a glance:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
MyProject | git:main | Opus (1M context) | ctx:8%
|
|
127
|
+
CodeMap: ● 842 files · ◆12.4k chunks | 23m ago
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
With multiple codemap MCP servers registered in `.mcp.json`, each gets its own line:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
MyProject | git:main | Opus (1M context) | ctx:8%
|
|
134
|
+
CodeMap: ● 842 files · ◆12.4k chunks | 23m ago
|
|
135
|
+
CodeMap (frontend): ○ 360 files · ◆1.9k chunks · ⚠3 stale | 2h ago
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- **●/○** — `codemap watch` running or not
|
|
139
|
+
- **◆** — indexed chunks (search units)
|
|
140
|
+
- **⚠N stale** — files modified since last index
|
|
141
|
+
- **IDX** — indexing in progress
|
|
142
|
+
|
|
114
143
|
### `codemap deps <file>`
|
|
115
144
|
|
|
116
145
|
Show files this file depends on (outgoing imports).
|
package/dist/index.js
CHANGED
|
@@ -6137,14 +6137,24 @@ function registerIndex(program2) {
|
|
|
6137
6137
|
console.log(chalk4.bold("Indexing ") + chalk4.cyan(projectDir));
|
|
6138
6138
|
console.log(chalk4.dim(`Branch: ${branch} | Provider: ${config.embedding.provider} | Model: ${config.embedding.model}`));
|
|
6139
6139
|
console.log();
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6140
|
+
let stats;
|
|
6141
|
+
try {
|
|
6142
|
+
stats = await runInitPipeline(projectDir, config, {
|
|
6143
|
+
branch,
|
|
6144
|
+
dataDir: getDataDir2(),
|
|
6145
|
+
onProgress: (progress) => {
|
|
6146
|
+
const pct = progress.total ? ` (${progress.current ?? 0}/${progress.total})` : "";
|
|
6147
|
+
console.log(chalk4.dim(`[${progress.phase}]`) + ` ${progress.message}${pct}`);
|
|
6148
|
+
}
|
|
6149
|
+
});
|
|
6150
|
+
} catch (err) {
|
|
6151
|
+
if (err instanceof Error && err.message.includes("Failed to acquire codemap lock")) {
|
|
6152
|
+
console.log(chalk4.yellow("Another codemap process is already indexing this project."));
|
|
6153
|
+
console.log(chalk4.dim("Wait for it to finish, or run `codemap status` to check."));
|
|
6154
|
+
return;
|
|
6146
6155
|
}
|
|
6147
|
-
|
|
6156
|
+
throw err;
|
|
6157
|
+
}
|
|
6148
6158
|
console.log();
|
|
6149
6159
|
console.log(chalk4.green("Index complete:"));
|
|
6150
6160
|
console.log(` Files: ${stats.totalFiles}`);
|
|
@@ -7051,7 +7061,11 @@ import { homedir as homedir3 } from "os";
|
|
|
7051
7061
|
function buildStatuslineScript(originalCommand) {
|
|
7052
7062
|
const escapedCmd = originalCommand.replace(/'/g, "'\\''");
|
|
7053
7063
|
const originalSection = originalCommand ? `ORIGINAL_CMD='${escapedCmd}'
|
|
7054
|
-
echo "$SESSION_JSON" | eval "$ORIGINAL_CMD" 2>/dev/null || true
|
|
7064
|
+
original_out=$(echo "$SESSION_JSON" | eval "$ORIGINAL_CMD" 2>/dev/null || true)
|
|
7065
|
+
if [ -n "$original_out" ]; then
|
|
7066
|
+
echo "$original_out"
|
|
7067
|
+
has_line1=true
|
|
7068
|
+
fi` : "";
|
|
7055
7069
|
return `#!/bin/bash
|
|
7056
7070
|
# CodeMap statusline for Claude Code
|
|
7057
7071
|
# Generated by: codemap statusline
|
|
@@ -7062,34 +7076,49 @@ set -euo pipefail
|
|
|
7062
7076
|
# Read session JSON from stdin (Claude Code pipes it)
|
|
7063
7077
|
SESSION_JSON=$(cat)
|
|
7064
7078
|
|
|
7065
|
-
|
|
7079
|
+
has_line1=false
|
|
7080
|
+
|
|
7081
|
+
# --- Original statusline command (if any) ---
|
|
7066
7082
|
${originalSection}
|
|
7067
7083
|
|
|
7068
|
-
# ---
|
|
7069
|
-
# Resolve the working directory from session JSON
|
|
7084
|
+
# --- Reconstruct Claude Code default status (line 1) ---
|
|
7070
7085
|
current_dir=$(echo "$SESSION_JSON" | ${jsonExtract("cwd")} 2>/dev/null || pwd)
|
|
7071
7086
|
|
|
7072
|
-
|
|
7073
|
-
|
|
7087
|
+
if [ "$has_line1" = "false" ]; then
|
|
7088
|
+
project_name=$(basename "$current_dir")
|
|
7089
|
+
git_branch=$(cd "$current_dir" && git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
|
|
7090
|
+
model_display=$(echo "$SESSION_JSON" | ${jsonExtract("display_name")} 2>/dev/null || echo "")
|
|
7091
|
+
ctx_size=$(echo "$SESSION_JSON" | ${jsonExtract("context_window_size")} 2>/dev/null || echo "")
|
|
7092
|
+
ctx_label=""
|
|
7093
|
+
if [ -n "$ctx_size" ]; then
|
|
7094
|
+
if [ "$ctx_size" -ge 1000000 ] 2>/dev/null; then
|
|
7095
|
+
ctx_label="1M context"
|
|
7096
|
+
elif [ "$ctx_size" -ge 100000 ] 2>/dev/null; then
|
|
7097
|
+
ctx_label="200k context"
|
|
7098
|
+
fi
|
|
7099
|
+
fi
|
|
7100
|
+
ctx_pct=$(echo "$SESSION_JSON" | ${jsonExtract("used_percentage")} 2>/dev/null || echo "")
|
|
7074
7101
|
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7102
|
+
line1="$project_name"
|
|
7103
|
+
if [ -n "$git_branch" ]; then
|
|
7104
|
+
line1="\${line1} | git:$git_branch"
|
|
7105
|
+
fi
|
|
7106
|
+
if [ -n "$model_display" ]; then
|
|
7107
|
+
if [ -n "$ctx_label" ]; then
|
|
7108
|
+
line1="\${line1} | \${model_display} (\${ctx_label})"
|
|
7109
|
+
else
|
|
7110
|
+
line1="\${line1} | \${model_display}"
|
|
7111
|
+
fi
|
|
7112
|
+
fi
|
|
7113
|
+
if [ -n "$ctx_pct" ]; then
|
|
7114
|
+
line1="\${line1} | ctx:\${ctx_pct}%"
|
|
7115
|
+
fi
|
|
7078
7116
|
|
|
7079
|
-
|
|
7080
|
-
stats_null=$(echo "$cm_json" | ${jsonExtract("stats")} 2>/dev/null || echo "null")
|
|
7081
|
-
if [ "$stats_null" = "null" ] || [ -z "$stats_null" ]; then
|
|
7082
|
-
echo "CM: \u2014 no index (run: codemap index)"
|
|
7083
|
-
exit 0
|
|
7117
|
+
echo "$line1"
|
|
7084
7118
|
fi
|
|
7085
7119
|
|
|
7086
|
-
|
|
7087
|
-
total_chunks=$(echo "$cm_json" | ${jsonPath("stats", "totalChunks")} 2>/dev/null || echo "0")
|
|
7088
|
-
stale_files=$(echo "$cm_json" | ${jsonPath("stats", "staleFiles")} 2>/dev/null || echo "0")
|
|
7089
|
-
last_updated=$(echo "$cm_json" | ${jsonPath("stats", "lastUpdated")} 2>/dev/null || echo "")
|
|
7090
|
-
indexing=$(echo "$cm_json" | ${jsonExtract("indexing")} 2>/dev/null || echo "false")
|
|
7120
|
+
# --- Helper functions ---
|
|
7091
7121
|
|
|
7092
|
-
# Format chunks (e.g. 12400 \u2192 12.4k)
|
|
7093
7122
|
format_chunks() {
|
|
7094
7123
|
local n=$1
|
|
7095
7124
|
if [ "$n" -ge 1000 ]; then
|
|
@@ -7102,7 +7131,6 @@ format_chunks() {
|
|
|
7102
7131
|
fi
|
|
7103
7132
|
}
|
|
7104
7133
|
|
|
7105
|
-
# Calculate time ago
|
|
7106
7134
|
time_ago() {
|
|
7107
7135
|
local updated="$1"
|
|
7108
7136
|
if [ -z "$updated" ]; then
|
|
@@ -7112,7 +7140,6 @@ time_ago() {
|
|
|
7112
7140
|
local now
|
|
7113
7141
|
now=$(date +%s)
|
|
7114
7142
|
local then_ts
|
|
7115
|
-
# macOS date -j vs GNU date
|
|
7116
7143
|
if date -j -f "%Y-%m-%dT%H:%M:%S" "$(echo "$updated" | cut -c1-19)" +%s >/dev/null 2>&1; then
|
|
7117
7144
|
then_ts=$(date -j -f "%Y-%m-%dT%H:%M:%S" "$(echo "$updated" | cut -c1-19)" +%s 2>/dev/null || echo "$now")
|
|
7118
7145
|
else
|
|
@@ -7130,36 +7157,104 @@ time_ago() {
|
|
|
7130
7157
|
fi
|
|
7131
7158
|
}
|
|
7132
7159
|
|
|
7133
|
-
#
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
fi
|
|
7160
|
+
# Print one CodeMap status line for a given project directory and label
|
|
7161
|
+
print_codemap_status() {
|
|
7162
|
+
local label="$1"
|
|
7163
|
+
local target_dir="$2"
|
|
7138
7164
|
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
if [ "$
|
|
7142
|
-
|
|
7143
|
-
fi
|
|
7165
|
+
local cm_json
|
|
7166
|
+
cm_json=$(codemap status --json --cwd "$target_dir" 2>/dev/null || true)
|
|
7167
|
+
if [ -z "$cm_json" ]; then
|
|
7168
|
+
return
|
|
7169
|
+
fi
|
|
7144
7170
|
|
|
7145
|
-
|
|
7171
|
+
local stats_null
|
|
7172
|
+
stats_null=$(echo "$cm_json" | ${jsonExtract("stats")} 2>/dev/null || echo "null")
|
|
7173
|
+
if [ "$stats_null" = "null" ] || [ -z "$stats_null" ]; then
|
|
7174
|
+
echo "\${label} \u2014 no index (run: codemap index)"
|
|
7175
|
+
return
|
|
7176
|
+
fi
|
|
7146
7177
|
|
|
7147
|
-
|
|
7148
|
-
|
|
7178
|
+
local total_files total_chunks stale_files last_updated indexing
|
|
7179
|
+
total_files=$(echo "$cm_json" | ${jsonPath("stats", "totalFiles")} 2>/dev/null || echo "0")
|
|
7180
|
+
total_chunks=$(echo "$cm_json" | ${jsonPath("stats", "totalChunks")} 2>/dev/null || echo "0")
|
|
7181
|
+
stale_files=$(echo "$cm_json" | ${jsonPath("stats", "staleFiles")} 2>/dev/null || echo "0")
|
|
7182
|
+
last_updated=$(echo "$cm_json" | ${jsonPath("stats", "lastUpdated")} 2>/dev/null || echo "")
|
|
7183
|
+
indexing=$(echo "$cm_json" | ${jsonExtract("indexing")} 2>/dev/null || echo "false")
|
|
7149
7184
|
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7185
|
+
local watcher_icon="\u25CB"
|
|
7186
|
+
if pgrep -f "codemap watch" >/dev/null 2>&1; then
|
|
7187
|
+
watcher_icon="\u25CF"
|
|
7188
|
+
fi
|
|
7189
|
+
|
|
7190
|
+
local idx_icon=""
|
|
7191
|
+
if [ "$indexing" = "true" ]; then
|
|
7192
|
+
idx_icon=" \xB7 IDX"
|
|
7193
|
+
fi
|
|
7194
|
+
|
|
7195
|
+
local chunks_fmt
|
|
7196
|
+
chunks_fmt=$(format_chunks "$total_chunks")
|
|
7197
|
+
|
|
7198
|
+
local line="\${label} \${watcher_icon} \${total_files} files \xB7 \u25C6\${chunks_fmt} chunks"
|
|
7199
|
+
|
|
7200
|
+
if [ "$stale_files" -gt 0 ] 2>/dev/null; then
|
|
7201
|
+
line="\${line} \xB7 \u26A0\${stale_files} stale"
|
|
7202
|
+
fi
|
|
7203
|
+
|
|
7204
|
+
line="\${line}\${idx_icon} | $(time_ago "$last_updated")"
|
|
7205
|
+
|
|
7206
|
+
echo "$line"
|
|
7207
|
+
}
|
|
7153
7208
|
|
|
7154
|
-
|
|
7209
|
+
# --- CodeMap status lines ---
|
|
7155
7210
|
|
|
7156
|
-
|
|
7211
|
+
# Discover codemap MCP servers from .mcp.json
|
|
7212
|
+
mcp_file="$current_dir/.mcp.json"
|
|
7213
|
+
found_servers=false
|
|
7214
|
+
|
|
7215
|
+
if [ -f "$mcp_file" ]; then
|
|
7216
|
+
# Use node to reliably parse JSON \u2014 extract "name|cwd" pairs for codemap servers
|
|
7217
|
+
codemap_servers=$(node -e "
|
|
7218
|
+
const fs = require('fs');
|
|
7219
|
+
try {
|
|
7220
|
+
const mcp = JSON.parse(fs.readFileSync(process.argv[1], 'utf-8'));
|
|
7221
|
+
const servers = mcp.mcpServers || {};
|
|
7222
|
+
for (const [name, config] of Object.entries(servers)) {
|
|
7223
|
+
if (config.command !== 'codemap') continue;
|
|
7224
|
+
const args = config.args || [];
|
|
7225
|
+
const cwdIdx = args.indexOf('--cwd');
|
|
7226
|
+
const cwd = cwdIdx >= 0 && cwdIdx + 1 < args.length ? args[cwdIdx + 1] : '';
|
|
7227
|
+
console.log(name + '|' + cwd);
|
|
7228
|
+
}
|
|
7229
|
+
} catch {}
|
|
7230
|
+
" "$mcp_file" 2>/dev/null || true)
|
|
7231
|
+
|
|
7232
|
+
if [ -n "$codemap_servers" ]; then
|
|
7233
|
+
found_servers=true
|
|
7234
|
+
while IFS='|' read -r server_name server_cwd; do
|
|
7235
|
+
target_dir="\${server_cwd:-$current_dir}"
|
|
7236
|
+
# Derive label: "codemap" \u2192 "CodeMap:", "codemap-frontend" \u2192 "CodeMap (frontend):"
|
|
7237
|
+
suffix=$(echo "$server_name" | sed 's/^codemap-//' | sed 's/^codemap$//')
|
|
7238
|
+
if [ -n "$suffix" ]; then
|
|
7239
|
+
label="CodeMap (\${suffix}):"
|
|
7240
|
+
else
|
|
7241
|
+
label="CodeMap:"
|
|
7242
|
+
fi
|
|
7243
|
+
print_codemap_status "$label" "$target_dir"
|
|
7244
|
+
done <<< "$codemap_servers"
|
|
7245
|
+
fi
|
|
7246
|
+
fi
|
|
7247
|
+
|
|
7248
|
+
# Fallback: no .mcp.json or no codemap entries \u2014 show status for current dir
|
|
7249
|
+
if [ "$found_servers" = "false" ]; then
|
|
7250
|
+
print_codemap_status "CodeMap:" "$current_dir"
|
|
7251
|
+
fi
|
|
7157
7252
|
`;
|
|
7158
7253
|
}
|
|
7159
7254
|
function jsonExtract(field) {
|
|
7160
7255
|
return `grep -o '"${field}"[[:space:]]*:[[:space:]]*[^,}]*' | sed 's/.*:[[:space:]]*//' | sed 's/"//g' | head -1`;
|
|
7161
7256
|
}
|
|
7162
|
-
function jsonPath(
|
|
7257
|
+
function jsonPath(_parent, child) {
|
|
7163
7258
|
return `grep -o '"${child}"[[:space:]]*:[[:space:]]*[^,}]*' | sed 's/.*:[[:space:]]*//' | sed 's/"//g' | head -1`;
|
|
7164
7259
|
}
|
|
7165
7260
|
|
|
@@ -7221,11 +7316,16 @@ function install() {
|
|
|
7221
7316
|
console.log(chalk17.dim("Your existing statusline is preserved \u2014 CodeMap appends to it."));
|
|
7222
7317
|
}
|
|
7223
7318
|
console.log();
|
|
7224
|
-
console.log("
|
|
7225
|
-
console.log(
|
|
7226
|
-
console.log(chalk17.cyan("
|
|
7227
|
-
console.log(chalk17.cyan("
|
|
7228
|
-
console.log(
|
|
7319
|
+
console.log("The statusline will show:");
|
|
7320
|
+
console.log();
|
|
7321
|
+
console.log(" " + chalk17.cyan("MyProject | git:main | Opus (1M context) | ctx:8%"));
|
|
7322
|
+
console.log(" " + chalk17.cyan("CodeMap: \u25CF 842 files \xB7 \u25C612.4k chunks | 23m ago"));
|
|
7323
|
+
console.log();
|
|
7324
|
+
console.log(" With multiple codemap MCP servers:");
|
|
7325
|
+
console.log();
|
|
7326
|
+
console.log(" " + chalk17.cyan("MyProject | git:main | Opus (1M context) | ctx:8%"));
|
|
7327
|
+
console.log(" " + chalk17.cyan("CodeMap: \u25CF 842 files \xB7 \u25C612.4k chunks | 23m ago"));
|
|
7328
|
+
console.log(" " + chalk17.cyan("CodeMap (frontend): \u25CB 360 files \xB7 \u25C61.9k chunks \xB7 \u26A03 stale | 2h ago"));
|
|
7229
7329
|
console.log();
|
|
7230
7330
|
console.log(chalk17.dim("Restart Claude Code to see the statusline."));
|
|
7231
7331
|
console.log(chalk17.dim("Run `codemap statusline --uninstall` to remove."));
|