@leftium/gg 0.0.24 → 0.0.26

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.
@@ -419,17 +419,20 @@ export function createGgPlugin(options, gg) {
419
419
  const entries = allEntries.filter((entry) => enabledNamespaces.has(entry.namespace));
420
420
  const text = entries
421
421
  .map((e) => {
422
- const timestamp = new Date(e.timestamp).toISOString();
423
- // Format args: stringify objects, keep primitives as-is
422
+ // Extract just HH:MM:SS from timestamp (compact for LLMs)
423
+ const time = new Date(e.timestamp).toISOString().slice(11, 19);
424
+ // Trim namespace and strip 'gg:' prefix to save tokens
425
+ const ns = e.namespace.trim().replace(/^gg:/, '');
426
+ // Format args: compact JSON for objects, primitives as-is
424
427
  const argsStr = e.args
425
428
  .map((arg) => {
426
429
  if (typeof arg === 'object' && arg !== null) {
427
- return JSON.stringify(arg, null, 2);
430
+ return JSON.stringify(arg);
428
431
  }
429
432
  return String(arg);
430
433
  })
431
434
  .join(' ');
432
- return `[${timestamp}] ${e.namespace} ${argsStr}`;
435
+ return `${time} ${ns} ${argsStr}`;
433
436
  })
434
437
  .join('\n');
435
438
  try {
package/dist/gg.js CHANGED
@@ -1,6 +1,33 @@
1
1
  import debugFactory from './debug.js';
2
2
  import ErrorStackParser from 'error-stack-parser';
3
3
  import { BROWSER, DEV } from 'esm-env';
4
+ /**
5
+ * Creates a debug instance with custom formatArgs to add namespace padding
6
+ * Padding is done at format time, not in the namespace itself, to keep colors stable
7
+ */
8
+ function createGgDebugger(namespace) {
9
+ const dbg = debugFactory(namespace);
10
+ // Store the original formatArgs (if it exists)
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ const originalFormatArgs = dbg.formatArgs;
13
+ // Override formatArgs to add padding to the namespace display
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ dbg.formatArgs = function (args) {
16
+ // Call original formatArgs first
17
+ if (originalFormatArgs) {
18
+ originalFormatArgs.call(this, args);
19
+ }
20
+ // Extract the callpoint from namespace (strip 'gg:' prefix and any URL suffix)
21
+ const nsMatch = this.namespace.match(/^gg:([^h]+?)(?:http|$)/);
22
+ const callpoint = nsMatch ? nsMatch[1] : this.namespace.replace(/^gg:/, '');
23
+ const paddedCallpoint = callpoint.padEnd(maxCallpointLength, ' ');
24
+ // Replace the namespace in the formatted string with padded version
25
+ if (typeof args[0] === 'string') {
26
+ args[0] = args[0].replace(this.namespace, `gg:${paddedCallpoint}`);
27
+ }
28
+ };
29
+ return dbg;
30
+ }
4
31
  // Helper to detect if we're running in CloudFlare Workers
5
32
  const isCloudflareWorker = () => {
6
33
  // Check for CloudFlare Workers-specific global
@@ -176,10 +203,12 @@ export function gg(...args) {
176
203
  if (callpoint.length < 80 && callpoint.length > maxCallpointLength) {
177
204
  maxCallpointLength = callpoint.length;
178
205
  }
179
- namespace = `gg:${callpoint.padEnd(maxCallpointLength, ' ')}${ggConfig.editorLink ? url : ''}`;
206
+ // Namespace without padding - keeps colors stable
207
+ // Editor link appended if enabled
208
+ namespace = `gg:${callpoint}${ggConfig.editorLink ? url : ''}`;
180
209
  }
181
210
  const ggLogFunction = namespaceToLogFunction.get(namespace) ||
182
- namespaceToLogFunction.set(namespace, debugFactory(namespace)).get(namespace);
211
+ namespaceToLogFunction.set(namespace, createGgDebugger(namespace)).get(namespace);
183
212
  if (!args.length) {
184
213
  ggLogFunction(` 📝📝 ${url} 👀👀`);
185
214
  return {
@@ -200,6 +229,7 @@ export function gg(...args) {
200
229
  if (gg._onLog) {
201
230
  // Don't stringify args - keep them as-is for expandable objects
202
231
  const message = args.length === 1 ? String(args[0]) : args.map(String).join(' ');
232
+ // Use debug's native color (now deterministic since namespace has no padding)
203
233
  gg._onLog({
204
234
  namespace,
205
235
  color: ggLogFunction.color,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leftium/gg",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Leftium/gg.git"