Skip to content

fix: Gist URL capture and human-readable file size display#14

Merged
konard merged 5 commits intomainfrom
issue-13-24bbeb1aa441
Dec 25, 2025
Merged

fix: Gist URL capture and human-readable file size display#14
konard merged 5 commits intomainfrom
issue-13-24bbeb1aa441

Conversation

@konard
Copy link
Member

@konard konard commented Dec 25, 2025

Summary

  • Fix gist URL not being captured: The gh gist create command was failing to capture the URL due to empty string interpolation issues in the command-stream template literal when creating private gists
  • Add human-readable file size display: Added formatFileSize() function that properly formats file sizes (e.g., "1.90 KB" instead of "0.00 MB" for small files)
  • Improve CLI output: Enhanced user experience with better formatting and file info display before upload starts

Root Cause Analysis

The issue was in src/index.js line 211-213:

const visibility = isPublic ? '--public' : '';
const result = await $`gh gist create ${filePath} ${visibility} --desc ${desc}`;

When visibility was an empty string for private gists, the command-stream template literal interpreted this incorrectly, causing a shell pattern matching error (no matches found for \``) and losing the gist URL from stdout.

Solution

Changed to use conditional command execution:

let result;
if (isPublic) {
  result = await $`gh gist create ${filePath} --public --desc ${desc}`;
} else {
  result = await $`gh gist create ${filePath} --desc ${desc}`;
}

Changes Made

  • src/index.js: Fixed gist upload command, added formatFileSize() function
  • src/cli.js: Improved CLI output with file info before upload
  • test/index.test.js: Added 7 new tests for formatFileSize function
  • experiments/: Added experiment scripts documenting the issue and solution

Test plan

  • Unit tests pass locally (37 tests)
  • End-to-end test confirms gist URL is captured correctly
  • File size now displays correctly (e.g., "1.90 KB" for a 1.9KB file)
  • Lint and format checks pass

Fixes #13

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #13
@konard konard self-assigned this Dec 25, 2025
konard and others added 2 commits December 25, 2025 12:13
- Fix gist URL not being captured due to empty string interpolation
  in command-stream template literal (issue #13)
- Add formatFileSize() function for human-readable file sizes
  (e.g., "1.90 KB" instead of "0.00 MB")
- Improve CLI output with better formatting and file info display
- Add comprehensive tests for formatFileSize function
- Add experiment scripts documenting the issue and solution

Fixes #13

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] First issues fix: Gist URL capture and human-readable file size display Dec 25, 2025
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard marked this pull request as ready for review December 25, 2025 11:19
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.814165 USD
  • Calculated by Anthropic: $3.973374 USD
  • Difference: $-1.840791 (-31.66%)
    📎 Log file uploaded as GitHub Gist (680KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit f77d0ac into main Dec 25, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First issues

1 participant