httpcat-cli 0.0.27 → 0.1.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.
Files changed (69) hide show
  1. package/.github/workflows/README.md +37 -4
  2. package/.github/workflows/ci.yml +31 -20
  3. package/.github/workflows/homebrew-tap.yml +1 -1
  4. package/.github/workflows/publish-switch.yml +41 -0
  5. package/.github/workflows/rc-publish.yml +196 -0
  6. package/.github/workflows/release.yml +260 -81
  7. package/README.md +107 -108
  8. package/bun.lock +2933 -0
  9. package/dist/commands/account.d.ts.map +1 -1
  10. package/dist/commands/account.js +14 -7
  11. package/dist/commands/account.js.map +1 -1
  12. package/dist/commands/balances.d.ts.map +1 -0
  13. package/dist/commands/balances.js +171 -0
  14. package/dist/commands/balances.js.map +1 -0
  15. package/dist/commands/buy.d.ts.map +1 -1
  16. package/dist/commands/buy.js +743 -35
  17. package/dist/commands/buy.js.map +1 -1
  18. package/dist/commands/chat.d.ts.map +1 -1
  19. package/dist/commands/chat.js +467 -906
  20. package/dist/commands/chat.js.map +1 -1
  21. package/dist/commands/claim.d.ts.map +1 -0
  22. package/dist/commands/claim.js +65 -0
  23. package/dist/commands/claim.js.map +1 -0
  24. package/dist/commands/create.d.ts.map +1 -1
  25. package/dist/commands/create.js +0 -1
  26. package/dist/commands/create.js.map +1 -1
  27. package/dist/commands/info.d.ts.map +1 -1
  28. package/dist/commands/info.js +143 -38
  29. package/dist/commands/info.js.map +1 -1
  30. package/dist/commands/list.d.ts.map +1 -1
  31. package/dist/commands/list.js +31 -27
  32. package/dist/commands/list.js.map +1 -1
  33. package/dist/commands/positions.d.ts.map +1 -1
  34. package/dist/commands/positions.js +178 -106
  35. package/dist/commands/positions.js.map +1 -1
  36. package/dist/commands/sell.d.ts.map +1 -1
  37. package/dist/commands/sell.js +720 -28
  38. package/dist/commands/sell.js.map +1 -1
  39. package/dist/index.js +321 -104
  40. package/dist/index.js.map +1 -1
  41. package/dist/interactive/shell.d.ts.map +1 -1
  42. package/dist/interactive/shell.js +328 -179
  43. package/dist/interactive/shell.js.map +1 -1
  44. package/dist/mcp/tools.d.ts.map +1 -1
  45. package/dist/mcp/tools.js +8 -8
  46. package/dist/mcp/tools.js.map +1 -1
  47. package/dist/utils/constants.d.ts.map +1 -0
  48. package/dist/utils/constants.js +66 -0
  49. package/dist/utils/constants.js.map +1 -0
  50. package/dist/utils/formatting.d.ts.map +1 -1
  51. package/dist/utils/formatting.js +3 -5
  52. package/dist/utils/formatting.js.map +1 -1
  53. package/dist/utils/token-resolver.d.ts.map +1 -1
  54. package/dist/utils/token-resolver.js +70 -68
  55. package/dist/utils/token-resolver.js.map +1 -1
  56. package/dist/utils/validation.d.ts.map +1 -1
  57. package/dist/utils/validation.js +4 -3
  58. package/dist/utils/validation.js.map +1 -1
  59. package/jest.config.js +1 -1
  60. package/package.json +19 -13
  61. package/tests/README.md +0 -1
  62. package/.claude/settings.local.json +0 -41
  63. package/dist/commands/balance.d.ts.map +0 -1
  64. package/dist/commands/balance.js +0 -112
  65. package/dist/commands/balance.js.map +0 -1
  66. package/homebrew-httpcat/Formula/httpcat.rb +0 -18
  67. package/homebrew-httpcat/README.md +0 -31
  68. package/homebrew-httpcat/homebrew-httpcat/Formula/httpcat.rb +0 -18
  69. package/homebrew-httpcat/homebrew-httpcat/README.md +0 -31
@@ -11,9 +11,23 @@ Continuous Integration workflow that runs on every push and pull request:
11
11
  - Security audits
12
12
  - Code coverage reporting
13
13
 
14
+ ### `publish-switch.yml`
15
+ Entry point workflow for npm trusted publishing (OIDC). This is the workflow that npm validates against.
16
+ - Routes to either `rc-publish.yml` (for develop branch) or `release.yml` (for main branch/tags)
17
+ - Contains OIDC permissions required for trusted publishing
18
+ - This is the workflow file that must be configured in npm's Trusted Publishers settings
19
+
20
+ ### `rc-publish.yml`
21
+ Reusable workflow for publishing Release Candidate versions:
22
+ - Called by `publish-switch.yml` when pushing to `develop` branch
23
+ - Automatically increments RC version number
24
+ - Publishes to npm with `rc` tag
25
+ - Does not create GitHub releases
26
+
14
27
  ### `release.yml`
15
- Automated release workflow that:
16
- - Triggers on version tags (v*.*.*) or manual dispatch
28
+ Reusable workflow for publishing official releases:
29
+ - Called by `publish-switch.yml` when pushing to `main` branch or version tags
30
+ - Auto-detects version bump from conventional commits (BREAKING/feat/fix)
17
31
  - Validates version format
18
32
  - Runs tests and builds
19
33
  - Publishes to npm
@@ -25,9 +39,28 @@ Manual workflow to update the Homebrew formula in the tap repository.
25
39
 
26
40
  ## Secrets Required
27
41
 
28
- Configure these in Repository Settings Secrets and variables Actions:
42
+ **No secrets needed for publishing!** We use npm's [trusted publishing](https://docs.npmjs.com/trusted-publishers) with OIDC.
43
+
44
+ ### Setting up Trusted Publishing
45
+
46
+ 1. Go to your package settings: https://www.npmjs.com/package/httpcat-cli/settings
47
+ 2. Navigate to **"Trusted Publishers"** section
48
+ 3. Click **"Add Trusted Publisher"**
49
+ 4. Select **"GitHub Actions"**
50
+ 5. Configure:
51
+ - **Repository**: `hathbanger/httpcat-cli`
52
+ - **Workflow file**: `.github/workflows/publish-switch.yml` (this is the entry point that routes to RC or release)
53
+ - **Environment name**: `npm-publish` (optional, if using environments)
54
+ 6. Save the configuration
55
+
56
+ **Important:** Only `publish-switch.yml` needs to be configured as the trusted publisher. It will automatically route to the correct workflow (RC or release) based on the trigger.
29
57
 
30
- - `NPM_TOKEN`: npm authentication token with publish permissions
58
+ **Benefits:**
59
+ - ✅ No tokens needed - uses OIDC authentication
60
+ - ✅ Bypasses 2FA requirements automatically
61
+ - ✅ Automatic provenance generation
62
+ - ✅ More secure - short-lived credentials
63
+ - ✅ No token management or rotation needed
31
64
  - Generate at: https://www.npmjs.com/settings/YOUR_USERNAME/tokens
32
65
  - Required scopes: `read:packages`, `write:packages`
33
66
 
@@ -7,7 +7,7 @@ on:
7
7
  branches: [main, develop]
8
8
 
9
9
  env:
10
- NODE_VERSION: '20'
10
+ NODE_VERSION: "20"
11
11
 
12
12
  jobs:
13
13
  test:
@@ -15,29 +15,33 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- node-version: ['18', '20', '22']
18
+ node-version: ["18", "20", "22"]
19
19
  steps:
20
20
  - name: Checkout code
21
- uses: actions/checkout@v4
21
+ uses: actions/checkout@v6
22
+
23
+ - name: Setup Bun
24
+ uses: oven-sh/setup-bun@v1
25
+ with:
26
+ bun-version: latest
22
27
 
23
28
  - name: Setup Node.js ${{ matrix.node-version }}
24
- uses: actions/setup-node@v4
29
+ uses: actions/setup-node@v6
25
30
  with:
26
31
  node-version: ${{ matrix.node-version }}
27
- cache: 'yarn'
28
32
 
29
33
  - name: Install dependencies
30
- run: yarn install --frozen-lockfile
34
+ run: bun install --frozen-lockfile
31
35
 
32
36
  - name: Run tests
33
- run: yarn test
37
+ run: bun run test
34
38
 
35
39
  - name: Build
36
- run: yarn build
40
+ run: bun run build
37
41
 
38
42
  - name: Upload coverage reports
39
43
  if: matrix.node-version == '20'
40
- uses: codecov/codecov-action@v4
44
+ uses: codecov/codecov-action@v5
41
45
  with:
42
46
  files: ./coverage/lcov.info
43
47
  flags: unittests
@@ -49,19 +53,23 @@ jobs:
49
53
  runs-on: ubuntu-latest
50
54
  steps:
51
55
  - name: Checkout code
52
- uses: actions/checkout@v4
56
+ uses: actions/checkout@v6
57
+
58
+ - name: Setup Bun
59
+ uses: oven-sh/setup-bun@v1
60
+ with:
61
+ bun-version: latest
53
62
 
54
63
  - name: Setup Node.js
55
- uses: actions/setup-node@v4
64
+ uses: actions/setup-node@v6
56
65
  with:
57
66
  node-version: ${{ env.NODE_VERSION }}
58
- cache: 'yarn'
59
67
 
60
68
  - name: Install dependencies
61
- run: yarn install --frozen-lockfile
69
+ run: bun install --frozen-lockfile
62
70
 
63
71
  - name: Type check
64
- run: yarn build --noEmit || npx tsc --noEmit
72
+ run: bun run build --noEmit || npx tsc --noEmit
65
73
 
66
74
  - name: Check formatting (if configured)
67
75
  continue-on-error: true
@@ -77,19 +85,23 @@ jobs:
77
85
  runs-on: ubuntu-latest
78
86
  steps:
79
87
  - name: Checkout code
80
- uses: actions/checkout@v4
88
+ uses: actions/checkout@v6
89
+
90
+ - name: Setup Bun
91
+ uses: oven-sh/setup-bun@v1
92
+ with:
93
+ bun-version: latest
81
94
 
82
95
  - name: Setup Node.js
83
- uses: actions/setup-node@v4
96
+ uses: actions/setup-node@v6
84
97
  with:
85
98
  node-version: ${{ env.NODE_VERSION }}
86
- cache: 'yarn'
87
99
 
88
100
  - name: Install dependencies
89
- run: yarn install --frozen-lockfile
101
+ run: bun install --frozen-lockfile
90
102
 
91
103
  - name: Run security audit
92
- run: yarn audit --level moderate || true
104
+ run: bun audit --audit-level moderate || true
93
105
 
94
106
  - name: Check for known vulnerabilities
95
107
  uses: snyk/actions/node@master
@@ -98,4 +110,3 @@ jobs:
98
110
  SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
99
111
  with:
100
112
  args: --severity-threshold=high
101
-
@@ -14,7 +14,7 @@ jobs:
14
14
  runs-on: ubuntu-latest
15
15
  steps:
16
16
  - name: Checkout homebrew tap
17
- uses: actions/checkout@v4
17
+ uses: actions/checkout@v6
18
18
  with:
19
19
  repository: hathbanger/homebrew-httpcat
20
20
  token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,41 @@
1
+ name: Publish Switch
2
+
3
+ # This is the entry point workflow that npm will trust for OIDC publishing
4
+ # It conditionally calls either the RC or Release workflow based on the trigger
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - develop # RC publishing
10
+ - main # Release publishing
11
+ tags:
12
+ - "v*.*.*" # Release publishing via tags
13
+ workflow_dispatch:
14
+ inputs:
15
+ version:
16
+ description: "Version to release (e.g., 1.2.3). Leave empty for auto-detection from commits."
17
+ required: false
18
+ type: string
19
+
20
+ permissions:
21
+ id-token: write # Required for OIDC to request ID token to authenticate workflow
22
+ contents: write # Required for creating tags and releases
23
+
24
+ jobs:
25
+ publish-rc:
26
+ if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
27
+ uses: ./.github/workflows/rc-publish.yml
28
+ permissions:
29
+ id-token: write
30
+ contents: read
31
+
32
+ publish-release:
33
+ if: |
34
+ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))) ||
35
+ github.event_name == 'workflow_dispatch'
36
+ uses: ./.github/workflows/release.yml
37
+ with:
38
+ version: ${{ github.event.inputs.version }}
39
+ permissions:
40
+ id-token: write
41
+ contents: write
@@ -0,0 +1,196 @@
1
+ name: RC Publish
2
+
3
+ # This is a reusable workflow called by publish-switch.yml
4
+ on:
5
+ workflow_call:
6
+ # No inputs needed for RC publishing
7
+
8
+ env:
9
+ NODE_VERSION: "20"
10
+ REGISTRY_URL: "https://registry.npmjs.org"
11
+
12
+ jobs:
13
+ # Job 1: Determine RC version
14
+ prepare:
15
+ name: Prepare RC Version
16
+ runs-on: ubuntu-latest
17
+ outputs:
18
+ version: ${{ steps.version.outputs.version }}
19
+ base-version: ${{ steps.version.outputs.base-version }}
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v6
23
+
24
+ - name: Setup Node.js
25
+ uses: actions/setup-node@v6
26
+ with:
27
+ node-version: ${{ env.NODE_VERSION }}
28
+ registry-url: ${{ env.REGISTRY_URL }}
29
+
30
+ - name: Get base version from package.json
31
+ id: base-version
32
+ run: |
33
+ BASE_VERSION=$(node -p "require('./package.json').version")
34
+ # Remove any existing prerelease suffix (e.g., 0.0.28-rc.1 -> 0.0.28)
35
+ BASE_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*$//')
36
+ echo "base-version=$BASE_VERSION" >> $GITHUB_OUTPUT
37
+ echo "✅ Base version: $BASE_VERSION"
38
+
39
+ - name: Find latest RC version and increment
40
+ id: version
41
+ run: |
42
+ BASE_VERSION="${{ steps.base-version.outputs.base-version }}"
43
+
44
+ echo "Querying npm for existing RC versions..."
45
+ # Get all versions from npm
46
+ ALL_VERSIONS=$(npm view httpcat-cli versions --json 2>/dev/null || echo "[]")
47
+
48
+ # Filter for versions matching base version with RC suffix
49
+ RC_VERSIONS=$(echo "$ALL_VERSIONS" | node -e "
50
+ const versions = JSON.parse(require('fs').readFileSync(0, 'utf-8'));
51
+ const base = process.argv[1];
52
+ const rcVersions = versions
53
+ .filter(v => v.startsWith(base + '-rc.'))
54
+ .map(v => {
55
+ const match = v.match(/-rc\.(\d+)$/);
56
+ return match ? parseInt(match[1]) : 0;
57
+ })
58
+ .filter(n => n > 0)
59
+ .sort((a, b) => b - a);
60
+ console.log(rcVersions.length > 0 ? rcVersions[0] : 0);
61
+ " "$BASE_VERSION")
62
+
63
+ # Increment RC number
64
+ NEXT_RC=$((RC_VERSIONS + 1))
65
+ RC_VERSION="${BASE_VERSION}-rc.${NEXT_RC}"
66
+
67
+ echo "version=$RC_VERSION" >> $GITHUB_OUTPUT
68
+ echo "✅ Next RC version: $RC_VERSION"
69
+
70
+ # Job 2: Build and test
71
+ test:
72
+ name: Build & Test
73
+ runs-on: ubuntu-latest
74
+ needs: prepare
75
+ steps:
76
+ - name: Checkout code
77
+ uses: actions/checkout@v6
78
+
79
+ - name: Setup Bun
80
+ uses: oven-sh/setup-bun@v1
81
+ with:
82
+ bun-version: latest
83
+
84
+ - name: Setup Node.js
85
+ uses: actions/setup-node@v6
86
+ with:
87
+ node-version: ${{ env.NODE_VERSION }}
88
+
89
+ - name: Install dependencies
90
+ run: bun install
91
+
92
+ - name: Run tests
93
+ run: bun run test
94
+ # Note: Using Vitest now instead of Jest
95
+
96
+ - name: Build
97
+ run: bun run build
98
+
99
+ - name: Verify build output
100
+ run: |
101
+ if [ ! -f "dist/index.js" ]; then
102
+ echo "❌ Build failed: dist/index.js not found"
103
+ exit 1
104
+ fi
105
+ echo "✅ Build successful"
106
+
107
+ # Job 3: Publish RC to npm
108
+ publish-npm:
109
+ name: Publish RC to npm
110
+ runs-on: ubuntu-latest
111
+ needs: [prepare, test]
112
+ environment:
113
+ name: npm-publish
114
+ url: https://www.npmjs.com/package/httpcat-cli
115
+ permissions:
116
+ contents: read
117
+ id-token: write # Required for OIDC trusted publishing (no token needed!)
118
+ steps:
119
+ - name: Checkout code
120
+ uses: actions/checkout@v6
121
+
122
+ - name: Setup Node.js
123
+ uses: actions/setup-node@v6
124
+ with:
125
+ node-version: ${{ env.NODE_VERSION }}
126
+ registry-url: ${{ env.REGISTRY_URL }}
127
+
128
+ - name: Update npm to latest
129
+ run: npm install -g npm@latest
130
+ # npm 11.5.1+ required for trusted publishing (OIDC)
131
+
132
+ - name: Update package.json version
133
+ run: |
134
+ npm version "${{ needs.prepare.outputs.version }}" --no-git-tag-version --allow-same-version
135
+
136
+ - name: Setup Bun
137
+ uses: oven-sh/setup-bun@v1
138
+ with:
139
+ bun-version: latest
140
+
141
+ - name: Install dependencies
142
+ run: bun install
143
+
144
+ - name: Build
145
+ run: bun run build
146
+
147
+ - name: Publish RC to npm
148
+ run: npm publish --tag rc --access public
149
+ # Uses trusted publishing (OIDC) - no token needed!
150
+ # Configure trusted publisher at: https://www.npmjs.com/package/httpcat-cli/settings
151
+ # Provenance is automatically generated when using trusted publishing
152
+
153
+ - name: Verify npm publication
154
+ run: |
155
+ VERSION="${{ needs.prepare.outputs.version }}"
156
+ MAX_ATTEMPTS=10
157
+ INITIAL_WAIT=5
158
+ ATTEMPT=1
159
+
160
+ echo "Waiting for npm CDN propagation for httpcat-cli@$VERSION..."
161
+
162
+ while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
163
+ # Exponential backoff: 5s, 10s, 20s, 40s, etc. (capped at 60s)
164
+ WAIT_TIME=$((INITIAL_WAIT * (2 ** (ATTEMPT - 1))))
165
+ if [ $WAIT_TIME -gt 60 ]; then
166
+ WAIT_TIME=60
167
+ fi
168
+
169
+ if [ $ATTEMPT -gt 1 ]; then
170
+ echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Waiting ${WAIT_TIME}s before retry..."
171
+ sleep $WAIT_TIME
172
+ else
173
+ echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Initial wait ${WAIT_TIME}s..."
174
+ sleep $WAIT_TIME
175
+ fi
176
+
177
+ if npm view httpcat-cli@$VERSION version > /dev/null 2>&1; then
178
+ echo "✅ Successfully verified httpcat-cli@$VERSION is available on npm (rc tag)"
179
+ exit 0
180
+ else
181
+ echo "⚠️ Package not yet available on npm CDN (attempt $ATTEMPT/$MAX_ATTEMPTS)"
182
+ fi
183
+
184
+ ATTEMPT=$((ATTEMPT + 1))
185
+ done
186
+
187
+ echo "❌ Failed to verify npm publication after $MAX_ATTEMPTS attempts"
188
+ echo "Package may still be propagating. Check manually: npm view httpcat-cli@$VERSION"
189
+ exit 1
190
+
191
+ - name: RC summary
192
+ run: |
193
+ echo "✅ RC published successfully!"
194
+ echo "Version: ${{ needs.prepare.outputs.version }}"
195
+ echo "npm: https://www.npmjs.com/package/httpcat-cli/v/${{ needs.prepare.outputs.version }}"
196
+ echo "Install: npm install -g httpcat-cli@${{ needs.prepare.outputs.version }}"