log-llm-config 1.0.3 → 1.0.5

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/dist/cli.js CHANGED
@@ -61,174 +61,179 @@ const main = async () => {
61
61
  return;
62
62
  }
63
63
  if (args[0] === 'log_config_files') {
64
- await import('./log_config_files.js');
64
+ const { main } = await import('./log_config_files.js');
65
+ await main();
65
66
  return;
66
67
  }
67
- };
68
- void main();
69
- const fileCategories = [
70
- {
71
- label: 'Cursor: mcp.json',
72
- targets: ['./.cursor/mcp.json', '$HOME/.cursor/mcp.json']
73
- },
74
- {
75
- label: 'Claude: .mcp.json',
76
- targets: ['./mcp.json', './.mcp.json', '/Library/Application Support/ClaudeCode/managed-mcp.json']
77
- },
78
- {
79
- label: 'Claude: settings.json',
80
- targets: [
81
- './.claude/settings.json',
82
- './.claude/settings.local.json',
83
- '$HOME/.claude/settings.json',
84
- '/Library/Application Support/ClaudeCode/managed-settings.json'
85
- ]
86
- },
87
- {
88
- label: 'Cursor: hooks.json',
89
- targets: [
90
- './.cursor/hooks.json',
91
- '$HOME/.cursor/hooks.json',
92
- '/Library/Application Support/Cursor/hooks.json'
93
- ]
94
- }
95
- ];
96
- const sqliteCategories = [
97
- {
98
- label: 'Cursor: state.vscdb (composerState)',
99
- dbPath: '$HOME/Library/Application Support/Cursor/User/globalStorage/state.vscdb',
100
- table: 'ItemTable',
101
- key: 'src.vs.platform.reactivestorage.browser.reactiveStorageServiceImpl.persistentStorage.applicationUser',
102
- jsonPaths: [['composerState'], []]
68
+ // If no command matched, output bash script (legacy behavior)
69
+ // This should only happen when running the main command without subcommands
70
+ if (args.length === 0 || !['log_uuid', 'log_config_files'].includes(args[0])) {
71
+ const fileCategories = [
72
+ {
73
+ label: 'Cursor: mcp.json',
74
+ targets: ['./.cursor/mcp.json', '$HOME/.cursor/mcp.json']
75
+ },
76
+ {
77
+ label: 'Claude: .mcp.json',
78
+ targets: ['./mcp.json', './.mcp.json', '/Library/Application Support/ClaudeCode/managed-mcp.json']
79
+ },
80
+ {
81
+ label: 'Claude: settings.json',
82
+ targets: [
83
+ './.claude/settings.json',
84
+ './.claude/settings.local.json',
85
+ '$HOME/.claude/settings.json',
86
+ '/Library/Application Support/ClaudeCode/managed-settings.json'
87
+ ]
88
+ },
89
+ {
90
+ label: 'Cursor: hooks.json',
91
+ targets: [
92
+ './.cursor/hooks.json',
93
+ '$HOME/.cursor/hooks.json',
94
+ '/Library/Application Support/Cursor/hooks.json'
95
+ ]
96
+ }
97
+ ];
98
+ const sqliteCategories = [
99
+ {
100
+ label: 'Cursor: state.vscdb (composerState)',
101
+ dbPath: '$HOME/Library/Application Support/Cursor/User/globalStorage/state.vscdb',
102
+ table: 'ItemTable',
103
+ key: 'src.vs.platform.reactivestorage.browser.reactiveStorageServiceImpl.persistentStorage.applicationUser',
104
+ jsonPaths: [['composerState'], []]
105
+ }
106
+ ];
107
+ const buildFileCategoryLines = (category) => [
108
+ `echo "===== ${category.label} ====="`,
109
+ 'files=(',
110
+ ...category.targets.map((target) => ` "${target}"`),
111
+ ')',
112
+ 'expanded_files=()',
113
+ 'paths=()',
114
+ 'display_paths=()',
115
+ 'for f in "${files[@]}"; do',
116
+ ' expanded=$(eval echo "$f")',
117
+ ' expanded_dir=$(dirname "$expanded")',
118
+ ' expanded_base=$(basename "$expanded")',
119
+ ' abs_dir=$(cd "$expanded_dir" 2>/dev/null && pwd || echo "$expanded_dir")',
120
+ ' abs_path="$abs_dir/$expanded_base"',
121
+ ' expanded_files+=("$abs_path")',
122
+ ' relative_path="$(to_relative "$abs_path")"',
123
+ ' paths+=("$relative_path")',
124
+ ' display_paths+=("$relative_path")',
125
+ 'done',
126
+ 'echo ""',
127
+ 'if [ ${#paths[@]} -gt 0 ]; then',
128
+ ' echo "Paths:"',
129
+ ' printf "%s\\n" "${paths[@]}" | awk \'!seen[$0]++\' | while IFS= read -r dir; do',
130
+ ' echo "$dir"',
131
+ ' done',
132
+ ' echo ""',
133
+ 'else',
134
+ ' echo "Paths: (none)"',
135
+ 'fi',
136
+ 'echo ""',
137
+ 'for idx in "${!expanded_files[@]}"; do',
138
+ ' expanded="${expanded_files[$idx]}"',
139
+ ' display="${display_paths[$idx]}"',
140
+ ' if [ -f "$expanded" ]; then',
141
+ ` echo "===== ${category.label}: $display ====="`,
142
+ ' cat "$expanded"',
143
+ ' else',
144
+ ` echo "===== ${category.label}: missing: $display ====="`,
145
+ ' fi',
146
+ 'done',
147
+ 'echo ""'
148
+ ];
149
+ const buildSqliteCategoryLines = (category) => {
150
+ const jsonPathsLiteral = JSON.stringify(category.jsonPaths);
151
+ return [
152
+ `echo "===== ${category.label} ====="`,
153
+ `db_path="${category.dbPath}"`,
154
+ 'expanded=$(eval echo "$db_path")',
155
+ 'if [ -f "$expanded" ]; then',
156
+ ' if command -v sqlite3 >/dev/null 2>&1; then',
157
+ ' echo "===== $expanded ====="',
158
+ ` query_result=$(sqlite3 "$expanded" "SELECT value FROM ${category.table} WHERE key='${category.key}'")`,
159
+ ' if [ -n "$query_result" ]; then',
160
+ ` echo "===== key: ${category.key} ====="`,
161
+ ` LOG_CONFIG_JSON_VALUE="$query_result" python3 - <<'PY'`,
162
+ 'import json',
163
+ 'import os',
164
+ '',
165
+ 'raw = os.environ.get("LOG_CONFIG_JSON_VALUE", "")',
166
+ 'if not raw:',
167
+ ' print("{}")',
168
+ ' raise SystemExit',
169
+ `paths = ${jsonPathsLiteral}`,
170
+ 'try:',
171
+ ' data = json.loads(raw)',
172
+ 'except json.JSONDecodeError as exc:',
173
+ ' print(f"failed to parse JSON: {exc}")',
174
+ ' raise SystemExit',
175
+ 'def walk(obj, path):',
176
+ ' cur = obj',
177
+ ' for segment in path:',
178
+ ' if isinstance(cur, dict):',
179
+ ' cur = cur.get(segment)',
180
+ ' else:',
181
+ ' return None',
182
+ ' return cur',
183
+ 'selected_value = None',
184
+ 'selected_label = None',
185
+ 'for path in paths:',
186
+ ' value = walk(data, path)',
187
+ ' if value is not None:',
188
+ ' selected_value = value',
189
+ ' selected_label = ".".join(path) if path else "root"',
190
+ ' break',
191
+ 'if selected_value is None:',
192
+ ' print("{}")',
193
+ 'else:',
194
+ ' print(f"[path: {selected_label}]")',
195
+ ' print(json.dumps(selected_value, indent=2, sort_keys=True))',
196
+ 'PY',
197
+ ' else',
198
+ ` echo "===== key not found: ${category.key} ====="`,
199
+ ' fi',
200
+ ' else',
201
+ ' echo "===== sqlite3 not found; skipping ====="',
202
+ ' fi',
203
+ 'else',
204
+ ' echo "===== missing: $expanded ====="',
205
+ 'fi',
206
+ 'echo ""'
207
+ ];
208
+ };
209
+ const scriptLines = [
210
+ '#!/usr/bin/env bash',
211
+ 'set -euo pipefail',
212
+ 'output_file="$(pwd)/configs.txt"',
213
+ ': > "$output_file"',
214
+ 'exec >"$output_file"',
215
+ 'exec 2>&1',
216
+ '',
217
+ 'repo_root="$(pwd)"',
218
+ 'to_relative() {',
219
+ ' local path="$1"',
220
+ ' if [[ "$path" == "$repo_root"* ]]; then',
221
+ ' local suffix="${path#"$repo_root"}"',
222
+ ' if [ -z "$suffix" ]; then',
223
+ ' echo "<project_root>"',
224
+ ' else',
225
+ ' echo "<project_root>${suffix}"',
226
+ ' fi',
227
+ ' else',
228
+ ' echo "$path"',
229
+ ' fi',
230
+ '}',
231
+ '',
232
+ ...fileCategories.flatMap(buildFileCategoryLines),
233
+ ...sqliteCategories.flatMap(buildSqliteCategoryLines)
234
+ ];
235
+ console.log(scriptLines.join('\n'));
103
236
  }
104
- ];
105
- const buildFileCategoryLines = (category) => [
106
- `echo "===== ${category.label} ====="`,
107
- 'files=(',
108
- ...category.targets.map((target) => ` "${target}"`),
109
- ')',
110
- 'expanded_files=()',
111
- 'paths=()',
112
- 'display_paths=()',
113
- 'for f in "${files[@]}"; do',
114
- ' expanded=$(eval echo "$f")',
115
- ' expanded_dir=$(dirname "$expanded")',
116
- ' expanded_base=$(basename "$expanded")',
117
- ' abs_dir=$(cd "$expanded_dir" 2>/dev/null && pwd || echo "$expanded_dir")',
118
- ' abs_path="$abs_dir/$expanded_base"',
119
- ' expanded_files+=("$abs_path")',
120
- ' relative_path="$(to_relative "$abs_path")"',
121
- ' paths+=("$relative_path")',
122
- ' display_paths+=("$relative_path")',
123
- 'done',
124
- 'echo ""',
125
- 'if [ ${#paths[@]} -gt 0 ]; then',
126
- ' echo "Paths:"',
127
- ' printf "%s\\n" "${paths[@]}" | awk \'!seen[$0]++\' | while IFS= read -r dir; do',
128
- ' echo "$dir"',
129
- ' done',
130
- ' echo ""',
131
- 'else',
132
- ' echo "Paths: (none)"',
133
- 'fi',
134
- 'echo ""',
135
- 'for idx in "${!expanded_files[@]}"; do',
136
- ' expanded="${expanded_files[$idx]}"',
137
- ' display="${display_paths[$idx]}"',
138
- ' if [ -f "$expanded" ]; then',
139
- ` echo "===== ${category.label}: $display ====="`,
140
- ' cat "$expanded"',
141
- ' else',
142
- ` echo "===== ${category.label}: missing: $display ====="`,
143
- ' fi',
144
- 'done',
145
- 'echo ""'
146
- ];
147
- const buildSqliteCategoryLines = (category) => {
148
- const jsonPathsLiteral = JSON.stringify(category.jsonPaths);
149
- return [
150
- `echo "===== ${category.label} ====="`,
151
- `db_path="${category.dbPath}"`,
152
- 'expanded=$(eval echo "$db_path")',
153
- 'if [ -f "$expanded" ]; then',
154
- ' if command -v sqlite3 >/dev/null 2>&1; then',
155
- ' echo "===== $expanded ====="',
156
- ` query_result=$(sqlite3 "$expanded" "SELECT value FROM ${category.table} WHERE key='${category.key}'")`,
157
- ' if [ -n "$query_result" ]; then',
158
- ` echo "===== key: ${category.key} ====="`,
159
- ` LOG_CONFIG_JSON_VALUE="$query_result" python3 - <<'PY'`,
160
- 'import json',
161
- 'import os',
162
- '',
163
- 'raw = os.environ.get("LOG_CONFIG_JSON_VALUE", "")',
164
- 'if not raw:',
165
- ' print("{}")',
166
- ' raise SystemExit',
167
- `paths = ${jsonPathsLiteral}`,
168
- 'try:',
169
- ' data = json.loads(raw)',
170
- 'except json.JSONDecodeError as exc:',
171
- ' print(f"failed to parse JSON: {exc}")',
172
- ' raise SystemExit',
173
- 'def walk(obj, path):',
174
- ' cur = obj',
175
- ' for segment in path:',
176
- ' if isinstance(cur, dict):',
177
- ' cur = cur.get(segment)',
178
- ' else:',
179
- ' return None',
180
- ' return cur',
181
- 'selected_value = None',
182
- 'selected_label = None',
183
- 'for path in paths:',
184
- ' value = walk(data, path)',
185
- ' if value is not None:',
186
- ' selected_value = value',
187
- ' selected_label = ".".join(path) if path else "root"',
188
- ' break',
189
- 'if selected_value is None:',
190
- ' print("{}")',
191
- 'else:',
192
- ' print(f"[path: {selected_label}]")',
193
- ' print(json.dumps(selected_value, indent=2, sort_keys=True))',
194
- 'PY',
195
- ' else',
196
- ` echo "===== key not found: ${category.key} ====="`,
197
- ' fi',
198
- ' else',
199
- ' echo "===== sqlite3 not found; skipping ====="',
200
- ' fi',
201
- 'else',
202
- ' echo "===== missing: $expanded ====="',
203
- 'fi',
204
- 'echo ""'
205
- ];
206
237
  };
207
- const scriptLines = [
208
- '#!/usr/bin/env bash',
209
- 'set -euo pipefail',
210
- 'output_file="$(pwd)/configs.txt"',
211
- ': > "$output_file"',
212
- 'exec >"$output_file"',
213
- 'exec 2>&1',
214
- '',
215
- 'repo_root="$(pwd)"',
216
- 'to_relative() {',
217
- ' local path="$1"',
218
- ' if [[ "$path" == "$repo_root"* ]]; then',
219
- ' local suffix="${path#"$repo_root"}"',
220
- ' if [ -z "$suffix" ]; then',
221
- ' echo "<project_root>"',
222
- ' else',
223
- ' echo "<project_root>${suffix}"',
224
- ' fi',
225
- ' else',
226
- ' echo "$path"',
227
- ' fi',
228
- '}',
229
- '',
230
- ...fileCategories.flatMap(buildFileCategoryLines),
231
- ...sqliteCategories.flatMap(buildSqliteCategoryLines)
232
- ];
233
- console.log(scriptLines.join('\n'));
238
+ void main();
234
239
  export {};
@@ -489,6 +489,7 @@ async function main() {
489
489
  console.log('Authentication verified, proceeding with config file logging.');
490
490
  // Collect all config files
491
491
  const configFiles = collectConfigFiles();
492
+ console.log(`Collected ${configFiles.length} configuration file(s).`);
492
493
  if (configFiles.length === 0) {
493
494
  console.log('No configuration files found to log.');
494
495
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {