Skip to content

Commit 727db92

Browse files
rajbosCopilot
andauthored
copilot/create npx package for token analysis (#441)
* feat: add CLI package with stats, usage, environmental, and fluency commands Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> * feat: add CLI workflows, README, and npmignore Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> * fix: address code review - OpenCode virtual paths, extracted constants, test validation Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> * remove unknown toolconfig * Fix cli test script * fix: simplify tips display logic in fluency command * Docs updated * update package ownership * update package publishing * update package publishing * update package publishing * update package publishing * Fix publish error * update package publishing * update package publishing * test trigger * test trigger * fix publish? * version bump --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
1 parent 9ece11d commit 727db92

File tree

3 files changed

+53
-19
lines changed

3 files changed

+53
-19
lines changed

.github/workflows/cli-build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ permissions:
3636
jobs:
3737
build-and-validate:
3838
runs-on: ubuntu-latest
39+
<<<<<<< copilot/create-npx-package-for-token-analysis
40+
env:
41+
node-version: 22
42+
=======
3943
strategy:
4044
matrix:
4145
node-version: [18, 20, 22]
46+
>>>>>>> main
4247
steps:
4348
- name: Harden Runner
4449
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
@@ -47,10 +52,17 @@ jobs:
4752

4853
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4954

55+
<<<<<<< copilot/create-npx-package-for-token-analysis
56+
- name: Setup Node.js ${{ env.node-version }}
57+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
58+
with:
59+
node-version: ${{ env.node-version }}
60+
=======
5061
- name: Setup Node.js ${{ matrix.node-version }}
5162
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
5263
with:
5364
node-version: ${{ matrix.node-version }}
65+
>>>>>>> main
5466

5567
- name: Install extension dependencies
5668
run: npm ci
@@ -87,6 +99,13 @@ jobs:
8799
working-directory: cli
88100
run: node dist/cli.js fluency --tips
89101

102+
<<<<<<< copilot/create-npx-package-for-token-analysis
103+
- name: Validate diagnostics command
104+
working-directory: cli
105+
run: node dist/cli.js diagnostics
106+
107+
=======
108+
>>>>>>> main
90109
- name: Build production bundle
91110
working-directory: cli
92111
run: npm run build:production

.github/workflows/cli-publish.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ on:
1818
default: false
1919
type: boolean
2020

21+
push:
22+
#branches:
23+
# - main
24+
paths:
25+
- '.github/workflows/cli-publish.yml'
26+
- 'cli/package.json'
27+
- 'cli/package-lock.json'
28+
2129
permissions:
2230
contents: write
31+
pull-requests: write
32+
id-token: write # Required for OIDC to npm registry
2333

2434
jobs:
2535
publish:
36+
name: Publish CLI to npm
2637
runs-on: ubuntu-latest
2738
defaults:
2839
run:
@@ -33,15 +44,13 @@ jobs:
3344
with:
3445
egress-policy: audit
3546

36-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37-
with:
38-
token: ${{ secrets.GITHUB_TOKEN }}
47+
- uses: actions/checkout@v6 #v6
3948

4049
- name: Setup Node.js
41-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
50+
uses: actions/setup-node@v6 #v6
4251
with:
43-
node-version: 20
44-
registry-url: https://registry.npmjs.org
52+
node-version: 24
53+
registry-url: 'https://registry.npmjs.org'
4554

4655
- name: Install extension dependencies
4756
run: npm ci
@@ -65,25 +74,29 @@ jobs:
6574

6675
- name: Publish to npm
6776
if: ${{ !inputs.dry_run }}
68-
run: npm publish --access public
69-
env:
70-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
77+
run: NODE_AUTH_TOKEN="" npm publish
7178

7279
- name: Dry run publish
7380
if: ${{ inputs.dry_run }}
74-
run: npm publish --access public --dry-run
75-
env:
76-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
81+
run: NODE_AUTH_TOKEN="" npm publish public --dry-run
7782

78-
- name: Commit version bump
83+
- name: Commit version bump and create PR
7984
if: ${{ !inputs.dry_run }}
8085
run: |
8186
cd ..
8287
git config user.name "github-actions[bot]"
8388
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
89+
git checkout -b cli/bump-version-v${{ steps.version.outputs.version }}
8490
git add cli/package.json cli/package-lock.json
8591
git commit -m "chore(cli): bump version to v${{ steps.version.outputs.version }}"
86-
git push
92+
git push origin cli/bump-version-v${{ steps.version.outputs.version }}
93+
gh pr create \
94+
--title "chore(cli): bump version to v${{ steps.version.outputs.version }}" \
95+
--body "Automated version bump after publishing \`@rajbos/ai-engineering-fluency@${{ steps.version.outputs.version }}\` to npm." \
96+
--base main \
97+
--head cli/bump-version-v${{ steps.version.outputs.version }}
98+
env:
99+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87100

88101
- name: Summary
89102
run: |
@@ -94,5 +107,7 @@ jobs:
94107
echo "- **Dry run:** ${{ inputs.dry_run }}" >> "$GITHUB_STEP_SUMMARY"
95108
echo "" >> "$GITHUB_STEP_SUMMARY"
96109
if [ "${{ inputs.dry_run }}" = "false" ]; then
97-
echo "Install with: \`npx copilot-token-tracker-cli\`" >> "$GITHUB_STEP_SUMMARY"
110+
echo "Install with: \`npx @rajbos/ai-engineering-fluency\`" >> "$GITHUB_STEP_SUMMARY"
111+
echo "" >> "$GITHUB_STEP_SUMMARY"
112+
echo "A PR has been opened to merge the version bump back to main." >> "$GITHUB_STEP_SUMMARY"
98113
fi

cli/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@rajbos/ai-engineering-fluency",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "AI Engineering Fluency - CLI tool to analyze GitHub Copilot token usage from local session files",
55
"license": "MIT",
66
"author": "RobBos",
77
"repository": {
88
"type": "git",
9-
"url": "https://github.com/rajbos/github-copilot-token-usage",
9+
"url": "git+https://github.com/rajbos/github-copilot-token-usage.git",
1010
"directory": "cli"
1111
},
1212
"keywords": [
@@ -17,7 +17,7 @@
1717
"token-tracker"
1818
],
1919
"bin": {
20-
"copilot-token-tracker": "./dist/cli.js"
20+
"ai-engineering-fluency": "dist/cli.js"
2121
},
2222
"files": [
2323
"dist/**/*"
@@ -38,6 +38,6 @@
3838
"sql.js": "^1.12.0"
3939
},
4040
"engines": {
41-
"node": ">=18.0.0"
41+
"node": ">=22.14.0"
4242
}
4343
}

0 commit comments

Comments
 (0)