Merge branch 'main' into test-strats
This commit is contained in:
commit
53d4616e82
17 changed files with 763 additions and 128 deletions
33
.github/workflows/ci.yml
vendored
33
.github/workflows/ci.yml
vendored
|
|
@ -1,33 +0,0 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Run linting
|
||||
run: npm run lint
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
51
.github/workflows/pr_checks.yml
vendored
Normal file
51
.github/workflows/pr_checks.yml
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "npm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Run linting
|
||||
run: npm run lint
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
# GitHub does not have a way of requiring that all checks pass (you must manually select each job)
|
||||
# This action at least lets us manage the list of required tests via source control
|
||||
# so that creators of new jobs can add them to this list
|
||||
require-all-checks-to-pass:
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- test
|
||||
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
uses: re-actors/alls-green@release/v1
|
||||
with:
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
242
package-lock.json
generated
242
package-lock.json
generated
|
|
@ -16,7 +16,6 @@
|
|||
"@types/react": "^19.1.8",
|
||||
"@types/turndown": "^5.0.5",
|
||||
"@workos-inc/node": "^7.45.0",
|
||||
"axios": "^1.8.4",
|
||||
"chalk": "^5.4.1",
|
||||
"commander": "^14.0.0",
|
||||
"diff": "^7.0.0",
|
||||
|
|
@ -33,6 +32,7 @@
|
|||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1",
|
||||
"winston": "^3.17.0",
|
||||
"yaml": "^2.8.0"
|
||||
},
|
||||
"bin": {
|
||||
|
|
@ -50,7 +50,6 @@
|
|||
"@types/jest": "^29.5.14",
|
||||
"@types/nock": "^10.0.3",
|
||||
"@types/readline-sync": "^1.4.8",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"conventional-changelog-conventionalcommits": "^9.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"execa": "^9.6.0",
|
||||
|
|
@ -1471,6 +1470,16 @@
|
|||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@dabh/diagnostics": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz",
|
||||
"integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==",
|
||||
"dependencies": {
|
||||
"colorspace": "1.1.x",
|
||||
"enabled": "2.0.x",
|
||||
"kuler": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.25.6",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.6.tgz",
|
||||
|
|
@ -4346,6 +4355,11 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/triple-beam": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
|
||||
"integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw=="
|
||||
},
|
||||
"node_modules/@types/turndown": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/turndown/-/turndown-5.0.5.tgz",
|
||||
|
|
@ -4599,7 +4613,6 @@
|
|||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
|
||||
"integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
|
|
@ -4619,17 +4632,6 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz",
|
||||
"integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-jest": {
|
||||
"version": "29.7.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz",
|
||||
|
|
@ -5382,6 +5384,15 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/color": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz",
|
||||
"integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==",
|
||||
"dependencies": {
|
||||
"color-convert": "^1.9.3",
|
||||
"color-string": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
|
|
@ -5400,6 +5411,37 @@
|
|||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/color-string": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz",
|
||||
"integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
|
||||
"dependencies": {
|
||||
"color-name": "^1.0.0",
|
||||
"simple-swizzle": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/color/node_modules/color-convert": {
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||
"dependencies": {
|
||||
"color-name": "1.1.3"
|
||||
}
|
||||
},
|
||||
"node_modules/color/node_modules/color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
|
||||
},
|
||||
"node_modules/colorspace": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz",
|
||||
"integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==",
|
||||
"dependencies": {
|
||||
"color": "^3.1.3",
|
||||
"text-hex": "1.0.x"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
|
|
@ -6086,6 +6128,11 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/enabled": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz",
|
||||
"integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ=="
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
|
|
@ -6684,6 +6731,11 @@
|
|||
"bser": "2.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/fecha": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
|
||||
"integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw=="
|
||||
},
|
||||
"node_modules/fetch-blob": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||
|
|
@ -6829,6 +6881,11 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/fn.name": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
|
||||
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.9",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
||||
|
|
@ -8069,7 +8126,6 @@
|
|||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz",
|
||||
"integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
|
|
@ -9611,6 +9667,11 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/kuler": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
|
||||
"integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A=="
|
||||
},
|
||||
"node_modules/leb": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/leb/-/leb-1.0.0.tgz",
|
||||
|
|
@ -9743,6 +9804,30 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/logform": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz",
|
||||
"integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==",
|
||||
"dependencies": {
|
||||
"@colors/colors": "1.6.0",
|
||||
"@types/triple-beam": "^1.3.2",
|
||||
"fecha": "^4.2.0",
|
||||
"ms": "^2.1.1",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"triple-beam": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/logform/node_modules/@colors/colors": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz",
|
||||
"integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==",
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
}
|
||||
},
|
||||
"node_modules/loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
|
|
@ -12985,6 +13070,14 @@
|
|||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/one-time": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz",
|
||||
"integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==",
|
||||
"dependencies": {
|
||||
"fn.name": "1.x.x"
|
||||
}
|
||||
},
|
||||
"node_modules/onetime": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
|
||||
|
|
@ -13618,12 +13711,6 @@
|
|||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pure-rand": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz",
|
||||
|
|
@ -14090,6 +14177,14 @@
|
|||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safe-stable-stringify": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
|
||||
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
|
|
@ -14550,6 +14645,19 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/simple-swizzle": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
|
||||
"integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==",
|
||||
"dependencies": {
|
||||
"is-arrayish": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/simple-swizzle/node_modules/is-arrayish": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
|
||||
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
|
||||
},
|
||||
"node_modules/sisteransi": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
|
||||
|
|
@ -14701,6 +14809,14 @@
|
|||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/stack-trace": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
|
||||
"integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/stack-utils": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz",
|
||||
|
|
@ -14744,7 +14860,6 @@
|
|||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
|
|
@ -14754,7 +14869,6 @@
|
|||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string-length": {
|
||||
|
|
@ -15036,6 +15150,11 @@
|
|||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/text-hex": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
||||
"integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
|
||||
},
|
||||
"node_modules/thenify": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
|
||||
|
|
@ -15134,6 +15253,14 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/triple-beam": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz",
|
||||
"integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==",
|
||||
"engines": {
|
||||
"node": ">= 14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-jest": {
|
||||
"version": "29.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.2.tgz",
|
||||
|
|
@ -15478,7 +15605,6 @@
|
|||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
|
|
@ -15658,6 +15784,74 @@
|
|||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/winston": {
|
||||
"version": "3.17.0",
|
||||
"resolved": "https://registry.npmjs.org/winston/-/winston-3.17.0.tgz",
|
||||
"integrity": "sha512-DLiFIXYC5fMPxaRg832S6F5mJYvePtmO5G9v9IgUFPhXm9/GkXarH/TUrBAVzhTCzAj9anE/+GjrgXp/54nOgw==",
|
||||
"dependencies": {
|
||||
"@colors/colors": "^1.6.0",
|
||||
"@dabh/diagnostics": "^2.0.2",
|
||||
"async": "^3.2.3",
|
||||
"is-stream": "^2.0.0",
|
||||
"logform": "^2.7.0",
|
||||
"one-time": "^1.0.0",
|
||||
"readable-stream": "^3.4.0",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"stack-trace": "0.0.x",
|
||||
"triple-beam": "^1.3.0",
|
||||
"winston-transport": "^4.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/winston-transport": {
|
||||
"version": "4.9.0",
|
||||
"resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz",
|
||||
"integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==",
|
||||
"dependencies": {
|
||||
"logform": "^2.7.0",
|
||||
"readable-stream": "^3.6.2",
|
||||
"triple-beam": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/winston-transport/node_modules/readable-stream": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/winston/node_modules/@colors/colors": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz",
|
||||
"integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==",
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
}
|
||||
},
|
||||
"node_modules/winston/node_modules/readable-stream": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/wordwrap": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
"@types/react": "^19.1.8",
|
||||
"@types/turndown": "^5.0.5",
|
||||
"@workos-inc/node": "^7.45.0",
|
||||
"axios": "^1.8.4",
|
||||
"chalk": "^5.4.1",
|
||||
"commander": "^14.0.0",
|
||||
"diff": "^7.0.0",
|
||||
|
|
@ -55,6 +54,7 @@
|
|||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1",
|
||||
"winston": "^3.17.0",
|
||||
"yaml": "^2.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
@ -69,7 +69,6 @@
|
|||
"@types/jest": "^29.5.14",
|
||||
"@types/nock": "^10.0.3",
|
||||
"@types/readline-sync": "^1.4.8",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"conventional-changelog-conventionalcommits": "^9.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"execa": "^9.6.0",
|
||||
|
|
|
|||
|
|
@ -4,3 +4,57 @@ export const CONTINUE_ASCII_ART = `
|
|||
/ /__/ /_/ / / / / _/ // / /_/ / _/
|
||||
\\___/\\____/_/|_/ /_/ /___/_/|_/\\____/___/
|
||||
`;
|
||||
|
||||
export const CONTINUE_LOGO_ASCII_ART = `
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@ @
|
||||
@@@@@@@@@@@@ @@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@
|
||||
@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ @@@@@@@@@@@ @@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@ @@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@ @@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ @@@@@@@@@@@ @@@@@@
|
||||
@@@@@@@@@@@@ @@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@
|
||||
@@@@@@@@@@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@ @
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@
|
||||
@@@@@@@@@@@@ @@@@@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -2,16 +2,20 @@ import {
|
|||
Configuration,
|
||||
DefaultApi,
|
||||
} from "@continuedev/sdk/dist/api/dist/index.js";
|
||||
import axios from "axios";
|
||||
import chalk from "chalk";
|
||||
import * as fs from "fs";
|
||||
import open from "open";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { createInterface } from "readline";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { env } from "../env.js";
|
||||
|
||||
// Polyfill fetch for Node < 18
|
||||
import nodeFetch from "node-fetch";
|
||||
if (!globalThis.fetch) {
|
||||
globalThis.fetch = nodeFetch as unknown as typeof globalThis.fetch;
|
||||
}
|
||||
|
||||
// Config file path
|
||||
const AUTH_CONFIG_PATH = path.join(os.homedir(), ".continue", "auth.json");
|
||||
|
||||
|
|
@ -209,25 +213,146 @@ function prompt(question: string): Promise<string> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the auth URL for the token page
|
||||
* Device authorization response from WorkOS
|
||||
*/
|
||||
function getAuthUrlForTokenPage(useOnboarding: boolean = false): string {
|
||||
const url = new URL("https://api.workos.com/user_management/authorize");
|
||||
const params = {
|
||||
response_type: "code",
|
||||
client_id: env.workOsClientId,
|
||||
redirect_uri: `${env.appUrl}/tokens/${
|
||||
useOnboarding ? "onboarding-" : ""
|
||||
}callback/cli`,
|
||||
state: uuidv4(),
|
||||
provider: "authkit",
|
||||
};
|
||||
interface DeviceAuthorizationResponse {
|
||||
device_code: string;
|
||||
user_code: string;
|
||||
verification_uri: string;
|
||||
verification_uri_complete: string;
|
||||
expires_in: number;
|
||||
interval: number;
|
||||
}
|
||||
|
||||
Object.keys(params).forEach((key) =>
|
||||
url.searchParams.append(key, params[key as keyof typeof params])
|
||||
);
|
||||
/**
|
||||
* Request device authorization from WorkOS
|
||||
*/
|
||||
async function requestDeviceAuthorization(): Promise<DeviceAuthorizationResponse> {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
client_id: env.workOsClientId,
|
||||
});
|
||||
|
||||
return url.toString();
|
||||
// Use WorkOS User Management device authorization endpoint
|
||||
const response = await fetch(
|
||||
"https://api.workos.com/user_management/authorize/device",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: params,
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error(
|
||||
chalk.red("Device authorization error:"),
|
||||
error.message || error
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Poll for device authorization completion
|
||||
*/
|
||||
async function pollForDeviceToken(
|
||||
deviceCode: string,
|
||||
interval: number,
|
||||
expiresIn: number
|
||||
): Promise<AuthenticatedConfig> {
|
||||
const startTime = Date.now();
|
||||
const expirationTime = startTime + expiresIn * 1000;
|
||||
let currentInterval = interval;
|
||||
|
||||
while (Date.now() < expirationTime) {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
||||
device_code: deviceCode,
|
||||
client_id: env.workOsClientId,
|
||||
});
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
};
|
||||
|
||||
// Poll WorkOS User Management token endpoint
|
||||
const response = await fetch(
|
||||
"https://api.workos.com/user_management/authenticate",
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: params,
|
||||
}
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const { access_token, refresh_token, user } = data;
|
||||
|
||||
// Calculate token expiration (assuming 1 hour validity)
|
||||
const tokenExpiresAt = Date.now() + 60 * 60 * 1000;
|
||||
|
||||
const authConfig: AuthenticatedConfig = {
|
||||
userId: user.id,
|
||||
userEmail: user.email,
|
||||
accessToken: access_token,
|
||||
refreshToken: refresh_token,
|
||||
expiresAt: tokenExpiresAt,
|
||||
organizationId: null,
|
||||
};
|
||||
|
||||
// Save the config
|
||||
saveAuthConfig(authConfig);
|
||||
|
||||
return authConfig;
|
||||
} else {
|
||||
// Handle HTTP error responses
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
const errorCode = errorData.error;
|
||||
|
||||
// Log response details for debugging
|
||||
if (response.status === 401) {
|
||||
throw new Error(
|
||||
"Oops! We had trouble authenticating. Please try again and reach out if the error persists."
|
||||
);
|
||||
}
|
||||
|
||||
if (errorCode === "authorization_pending") {
|
||||
// Continue polling
|
||||
await new Promise((resolve) =>
|
||||
setTimeout(resolve, currentInterval * 1000)
|
||||
);
|
||||
continue;
|
||||
} else if (errorCode === "slow_down") {
|
||||
// Increase polling interval
|
||||
currentInterval += 5;
|
||||
await new Promise((resolve) =>
|
||||
setTimeout(resolve, currentInterval * 1000)
|
||||
);
|
||||
continue;
|
||||
} else if (errorCode === "access_denied") {
|
||||
throw new Error("User denied access");
|
||||
} else if (errorCode === "expired_token") {
|
||||
throw new Error("Device code has expired");
|
||||
} else {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(chalk.red("Token polling error:"), error.message || error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("Device authorization timeout");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -240,14 +365,22 @@ async function refreshToken(
|
|||
// Load existing config to preserve organizationId and other fields
|
||||
const existingConfig = loadAuthConfig();
|
||||
|
||||
const response = await axios.post(
|
||||
new URL("auth/refresh", env.apiBase).toString(),
|
||||
{
|
||||
const response = await fetch(new URL("auth/refresh", env.apiBase), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
refreshToken,
|
||||
}
|
||||
);
|
||||
}),
|
||||
});
|
||||
|
||||
const { accessToken, refreshToken: newRefreshToken, user } = response.data;
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const { accessToken, refreshToken: newRefreshToken, user } = data;
|
||||
|
||||
// Calculate token expiration (assuming 1 hour validity)
|
||||
const tokenExpiresAt = Date.now() + 60 * 60 * 1000;
|
||||
|
|
@ -273,21 +406,15 @@ async function refreshToken(
|
|||
|
||||
return authConfig;
|
||||
} catch (error: any) {
|
||||
console.error(
|
||||
chalk.red("Token refresh error:"),
|
||||
error.response?.data?.message || error.message || error
|
||||
);
|
||||
console.error(chalk.red("Token refresh error:"), error.message || error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates using the Continue web flow
|
||||
* Authenticates using the WorkOS device flow
|
||||
*/
|
||||
export async function login(
|
||||
useOnboarding: boolean = false,
|
||||
onPrompt?: (promptText: string) => Promise<string>
|
||||
): Promise<AuthConfig> {
|
||||
export async function login(): Promise<AuthConfig> {
|
||||
// If CONTINUE_API_KEY environment variable exists, use that instead
|
||||
if (process.env.CONTINUE_API_KEY) {
|
||||
console.info(
|
||||
|
|
@ -302,31 +429,41 @@ export async function login(
|
|||
try {
|
||||
console.info(chalk.cyan("\nStarting authentication with Continue..."));
|
||||
|
||||
// Get auth URL using the direct implementation
|
||||
const authUrl = getAuthUrlForTokenPage(useOnboarding);
|
||||
console.info(chalk.gray(`Opening browser to sign in at: ${authUrl}`));
|
||||
await open(authUrl);
|
||||
// Request device authorization
|
||||
const deviceAuth = await requestDeviceAuthorization();
|
||||
|
||||
console.info(chalk.yellow("\nAfter signing in, you'll receive a token."));
|
||||
console.info(
|
||||
chalk.yellow(
|
||||
`Your authentication code: ${chalk.bold(deviceAuth.user_code)}`
|
||||
)
|
||||
);
|
||||
console.info(
|
||||
chalk.dim(
|
||||
`If the browser doesn't automatically open, use this link: ${deviceAuth.verification_uri_complete}`
|
||||
)
|
||||
);
|
||||
|
||||
// Get token from user
|
||||
const token = onPrompt
|
||||
? await onPrompt(chalk.yellow("Paste your sign-in token here: "))
|
||||
: await prompt(chalk.yellow("Paste your sign-in token here: "));
|
||||
// Try to open the complete verification URL in browser
|
||||
try {
|
||||
await open(deviceAuth.verification_uri_complete);
|
||||
} catch (error) {
|
||||
console.info(chalk.yellow("Unable to open browser automatically"));
|
||||
}
|
||||
|
||||
console.info(chalk.cyan("Verifying token..."));
|
||||
console.info(chalk.cyan("\nWaiting for confirmation..."));
|
||||
|
||||
// Exchange token for session
|
||||
const response = await refreshToken(token);
|
||||
// Poll for token
|
||||
const authConfig = await pollForDeviceToken(
|
||||
deviceAuth.device_code,
|
||||
deviceAuth.interval,
|
||||
deviceAuth.expires_in
|
||||
);
|
||||
|
||||
console.info(chalk.green("\nAuthentication successful!"));
|
||||
|
||||
return response;
|
||||
return authConfig;
|
||||
} catch (error: any) {
|
||||
console.error(
|
||||
chalk.red("Authentication error:"),
|
||||
error.response?.data?.message || error.message || error
|
||||
);
|
||||
console.error(chalk.red("Authentication error:"), error.message || error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { streamChatResponse } from "../streamChatResponse.js";
|
|||
import { constructSystemMessage } from "../systemMessage.js";
|
||||
import { startTUIChat } from "../ui/index.js";
|
||||
import { formatError } from "../util/formatError.js";
|
||||
import logger from "../util/logger.js";
|
||||
|
||||
export interface ChatOptions {
|
||||
headless?: boolean;
|
||||
|
|
@ -74,9 +75,9 @@ export async function chat(prompt?: string, options: ChatOptions = {}) {
|
|||
const savedHistory = loadSession();
|
||||
if (savedHistory) {
|
||||
chatHistory = savedHistory;
|
||||
console.log(chalk.yellow("Resuming previous session..."));
|
||||
logger.info(chalk.yellow("Resuming previous session..."));
|
||||
} else {
|
||||
console.log(
|
||||
logger.info(
|
||||
chalk.yellow("No previous session found, starting fresh...")
|
||||
);
|
||||
}
|
||||
|
|
@ -125,22 +126,22 @@ export async function chat(prompt?: string, options: ChatOptions = {}) {
|
|||
|
||||
// In headless mode, only print the final response
|
||||
if (options.headless && finalResponse.trim()) {
|
||||
console.log(finalResponse);
|
||||
logger.info(finalResponse);
|
||||
}
|
||||
|
||||
// Save session after each successful response
|
||||
saveSession(chatHistory);
|
||||
} catch (e: any) {
|
||||
console.error(`\n${chalk.red(`Error: ${formatError(e)}`)}`);
|
||||
logger.error(`\n${chalk.red(`Error: ${formatError(e)}`)}`);
|
||||
if (!options.headless) {
|
||||
console.info(
|
||||
logger.info(
|
||||
chalk.dim(`Chat history:\n${JSON.stringify(chatHistory, null, 2)}`)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(chalk.red(`Fatal error: ${formatError(error)}`));
|
||||
logger.error(chalk.red(`Fatal error: ${formatError(error)}`));
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
15
src/index.ts
15
src/index.ts
|
|
@ -5,15 +5,16 @@ import { chat } from "./commands/chat.js";
|
|||
import { login } from "./commands/login.js";
|
||||
import { logout } from "./commands/logout.js";
|
||||
import { getVersion } from "./version.js";
|
||||
import logger from "./util/logger.js";
|
||||
|
||||
// Add global error handlers to prevent uncaught errors from crashing the process
|
||||
process.on("unhandledRejection", (reason, promise) => {
|
||||
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
||||
logger.error("Unhandled Rejection at:", { promise, reason });
|
||||
// Don't exit the process, just log the error
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error("Uncaught Exception:", error);
|
||||
logger.error("Uncaught Exception:", error);
|
||||
// Don't exit the process, just log the error
|
||||
});
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ program
|
|||
.option("--resume", "Resume from last session")
|
||||
.option("--readonly", "Only allow readonly tools")
|
||||
.option("--no-tools", "Disable all tools")
|
||||
.option("-v, --verbose", "Enable verbose logging")
|
||||
.option(
|
||||
"--rule <rule>",
|
||||
"Add a rule (can be a file path, hub slug, or string content). Can be specified multiple times.",
|
||||
|
|
@ -45,6 +47,15 @@ program
|
|||
[] as string[]
|
||||
)
|
||||
.action(async (prompt, options) => {
|
||||
if (options.verbose) {
|
||||
logger.setLevel('debug');
|
||||
const logPath = logger.getLogPath();
|
||||
const sessionId = logger.getSessionId();
|
||||
console.log(`Verbose logging enabled (session: ${sessionId})`);
|
||||
console.log(`Logs: ${logPath}`);
|
||||
console.log(`Filter this session: grep '\\[${sessionId}\\]' ${logPath}`);
|
||||
logger.debug('Verbose logging enabled');
|
||||
}
|
||||
await chat(prompt, options);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { type AssistantConfig } from "@continuedev/sdk";
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
||||
import logger from "./util/logger.js";
|
||||
|
||||
export class MCPService {
|
||||
private readonly connections: MCPConnection[] = [];
|
||||
|
|
@ -20,11 +21,13 @@ export class MCPService {
|
|||
const service = new MCPService(assistant);
|
||||
|
||||
if (assistant.mcpServers?.length) {
|
||||
logger.debug('Creating MCP connections', { serverCount: assistant.mcpServers.length });
|
||||
const connectionPromises = assistant.mcpServers.map((server) =>
|
||||
MCPConnection.create(server)
|
||||
);
|
||||
const connections = await Promise.all(connectionPromises);
|
||||
service.connections.push(...connections);
|
||||
logger.debug('MCP connections established', { connectionCount: connections.length });
|
||||
}
|
||||
|
||||
// Store the instance and return it
|
||||
|
|
@ -93,8 +96,10 @@ export class MCPConnection {
|
|||
|
||||
// Connect and get all prompts and tools
|
||||
const connection = new MCPConnection(client);
|
||||
logger.debug('Connecting to MCP server', { command: config.command });
|
||||
await client.connect(transport);
|
||||
const capabilities = client.getServerCapabilities();
|
||||
logger.debug('MCP server capabilities', { hasPrompts: !!capabilities?.prompts, hasTools: !!capabilities?.tools });
|
||||
|
||||
if (capabilities?.prompts) {
|
||||
connection.prompts = (await client.listPrompts()).prompts;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { ChatCompletionMessageParam } from "openai/resources.mjs";
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import logger from "./util/logger.js";
|
||||
|
||||
/**
|
||||
* Get a unique session identifier for the current terminal session
|
||||
|
|
@ -60,7 +61,7 @@ export function saveSession(chatHistory: ChatCompletionMessageParam[]): void {
|
|||
|
||||
fs.writeFileSync(sessionFilePath, JSON.stringify(sessionData, null, 2));
|
||||
} catch (error) {
|
||||
console.error('Error saving session:', error);
|
||||
logger.error('Error saving session:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ export function loadSession(): ChatCompletionMessageParam[] | null {
|
|||
const sessionData = JSON.parse(fs.readFileSync(sessionFilePath, 'utf8'));
|
||||
return sessionData.chatHistory || null;
|
||||
} catch (error) {
|
||||
console.error('Error loading session:', error);
|
||||
logger.error('Error loading session:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +94,7 @@ export function clearSession(): void {
|
|||
fs.unlinkSync(sessionFilePath);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error clearing session:', error);
|
||||
logger.error('Error clearing session:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export async function handleSlashCommands(
|
|||
case "config":
|
||||
return { openConfigSelector: true };
|
||||
case "login":
|
||||
login(false, onLoginPrompt)
|
||||
login()
|
||||
.then(async (config) => {
|
||||
if (config && isAuthenticatedConfig(config)) {
|
||||
console.info(
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { MCPService } from "./mcp.js";
|
|||
import { executeToolCall } from "./tools.js";
|
||||
import { BUILTIN_TOOLS } from "./tools/index.js";
|
||||
import { chatCompletionStreamWithBackoff, withExponentialBackoff } from "./util/exponentialBackoff.js";
|
||||
import logger from "./util/logger.js";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
|
@ -86,8 +87,10 @@ export async function streamChatResponse(
|
|||
let shouldContinueConversation = true;
|
||||
|
||||
while (shouldContinueConversation) {
|
||||
logger.debug('Starting new conversation iteration', { hasToolCalls: currentToolCalls.length > 0 });
|
||||
// Factory function to create the stream generator
|
||||
const streamFactory = async () => {
|
||||
logger.debug('Creating chat completion stream', { model, messageCount: chatHistory.length, toolCount: toolsForRequest.length });
|
||||
return await chatCompletionStreamWithBackoff(
|
||||
llmApi,
|
||||
{
|
||||
|
|
@ -113,6 +116,7 @@ export async function streamChatResponse(
|
|||
);
|
||||
|
||||
for await (const chunk of streamWithBackoff) {
|
||||
logger.debug('Received stream chunk', { hasContent: !!chunk.choices[0].delta.content, hasToolCalls: !!chunk.choices[0].delta.tool_calls });
|
||||
// Check if we should abort
|
||||
if (abortController?.signal.aborted) {
|
||||
break;
|
||||
|
|
@ -201,15 +205,15 @@ export async function streamChatResponse(
|
|||
return fullResponse;
|
||||
}
|
||||
// For other errors, re-throw them
|
||||
console.error(
|
||||
logger.error(
|
||||
chalk.red("Error in streamChatResponse:"),
|
||||
chalk.red(error.message)
|
||||
error
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!callbacks?.onContent && !isHeadless) {
|
||||
console.info(); // Add a newline after the response
|
||||
logger.info(""); // Add a newline after the response
|
||||
}
|
||||
|
||||
// Notify that content is complete if we have content and are about to process tool calls
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { searchCodeTool } from "./searchCode.js";
|
|||
import { type Tool, type ToolParameters } from "./types.js";
|
||||
import { viewDiffTool } from "./viewDiff.js";
|
||||
import { writeFileTool } from "./writeFile.js";
|
||||
import logger from "../util/logger.js";
|
||||
|
||||
export type { Tool, ToolParameters };
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ export function extractToolCalls(
|
|||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to parse tool call:", match[1]);
|
||||
logger.error("Failed to parse tool call:", { toolCall: match[1] });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +165,10 @@ export async function executeToolCall(toolCall: {
|
|||
}
|
||||
|
||||
try {
|
||||
return await tool.run(toolCall.arguments);
|
||||
logger.debug('Executing tool', { toolName: toolCall.name, arguments: toolCall.arguments });
|
||||
const result = await tool.run(toolCall.arguments);
|
||||
logger.debug('Tool execution completed', { toolName: toolCall.name, resultLength: result?.length || 0 });
|
||||
return result;
|
||||
} catch (error) {
|
||||
return `Error executing tool "${toolCall.name}": ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,119 @@ const SPINNER_DOUBLE_BARS = [
|
|||
"▃▁",
|
||||
"▂▁",
|
||||
];
|
||||
const SPINNER_SHADES = "░▒▓█▓▒░";
|
||||
const SPINNER_RINGS = "○◔◑◕●◐◓◑◒";
|
||||
const SPINNER_SPARKLES = "✢✣✤✥✦✧✬✱✲✳✴✵✶✷✸";
|
||||
const SPINNER_PULSE = "·∙●⬤●∙·";
|
||||
const MITOSIS_FRAMES = [
|
||||
"●",
|
||||
"●●",
|
||||
"● ●", // regular space
|
||||
"●\u2004●", // 1/3 em space
|
||||
"●\u2002●", // 1/2 em space
|
||||
"● ●", // regular space
|
||||
"●●",
|
||||
"●",
|
||||
];
|
||||
|
||||
const SPINNER: string | string[] = SPINNER_CORNERS;
|
||||
const DANCING_NOTES_FRAMES = [
|
||||
"♪ ",
|
||||
"♫ ",
|
||||
"♪ ♫ ",
|
||||
"♫ ♪ ",
|
||||
"♬ ♩ ",
|
||||
"♩ ♬ ",
|
||||
"♫ ♪ ",
|
||||
"♪ ♫ ",
|
||||
"♫ ",
|
||||
"♪ ",
|
||||
];
|
||||
const MITOSIS_2 = [
|
||||
"⚬ ",
|
||||
"⚭ ",
|
||||
"⚮ ",
|
||||
"⚯ ",
|
||||
"○ ○",
|
||||
"⚯ ",
|
||||
"⚮ ",
|
||||
"⚭ ",
|
||||
"⚬ ",
|
||||
];
|
||||
|
||||
// Generate all possible Braille characters (from U+2800 to U+28FF)
|
||||
const BRAILLE_CHARS = Array.from({ length: 256 }, (_, i) =>
|
||||
String.fromCharCode(0x2800 + i)
|
||||
);
|
||||
|
||||
const BRAILLE_BY_DENSITY: { [key: number]: string[] } = {
|
||||
0: ["⠀"], // No dots
|
||||
1: ["⠁", "⠂", "⠄", "⠈", "⠐", "⠠", "⡀", "⢀"], // 1 dot
|
||||
2: ["⠃", "⠅", "⠉", "⠑", "⠡", "⠊", "⠒", "⠔"], // 2 dots
|
||||
3: ["⠇", "⠋", "⠍", "⠕", "⠣", "⠱", "⠪", "⠜"], // 3 dots
|
||||
4: ["⠏", "⠗", "⠛", "⠝", "⠧", "⠯", "⠳", "⠵"], // 4 dots
|
||||
5: ["⠟", "⠫", "⠭", "⠷", "⠽", "⠾", "⠻", "⠺"], // 5 dots
|
||||
6: ["⠿", "⡷", "⡾", "⡻", "⡯", "⡧", "⢿", "⣷"], // 6 dots
|
||||
7: ["⣿", "⣾", "⣽", "⣻", "⣯", "⣧", "⣏", "⡿"], // 7 dots
|
||||
8: ["⣿"], // All dots (8)
|
||||
};
|
||||
|
||||
// Function to generate frame with specific dot density
|
||||
const generateDensityFrame = (dotCount: number): string => {
|
||||
const chars = BRAILLE_BY_DENSITY[Math.min(8, Math.max(0, dotCount))];
|
||||
return Array.from(
|
||||
{ length: 3 },
|
||||
() => chars[Math.floor(Math.random() * chars.length)]
|
||||
).join("");
|
||||
};
|
||||
|
||||
// Helper function to generate eased static fade animation with full timing control
|
||||
const generateEasedStaticFade = (
|
||||
timingCurve: number[] = [3, 3, 2, 1, 1, 1, 2, 3, 3]
|
||||
): string[] => {
|
||||
const frames: string[] = [];
|
||||
|
||||
// timingCurve[0] = frames at density 8
|
||||
// timingCurve[1] = frames at density 7
|
||||
// timingCurve[2] = frames at density 6
|
||||
// ... and so on
|
||||
// timingCurve[8] = frames at density 0
|
||||
|
||||
// Going down (8 -> 0)
|
||||
for (let density = 8; density >= 0; density--) {
|
||||
const frameCount = timingCurve[8 - density];
|
||||
for (let i = 0; i < frameCount; i++) {
|
||||
frames.push(generateDensityFrame(density));
|
||||
}
|
||||
}
|
||||
|
||||
// Going up (1 -> 8) - skip 0 to avoid double-holding at the bottom
|
||||
for (let density = 1; density <= 8; density++) {
|
||||
const frameCount = timingCurve[8 - density];
|
||||
for (let i = 0; i < frameCount; i++) {
|
||||
frames.push(generateDensityFrame(density));
|
||||
}
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
|
||||
// Usage examples:
|
||||
|
||||
// Default ease-in-ease-out
|
||||
const TIMING_CURVE = [3, 3, 2, 1, 1, 0, 1, 2, 3];
|
||||
const STATIC_FADE = [
|
||||
...generateEasedStaticFade(TIMING_CURVE),
|
||||
...generateEasedStaticFade(TIMING_CURVE),
|
||||
...generateEasedStaticFade(TIMING_CURVE),
|
||||
...generateEasedStaticFade(TIMING_CURVE),
|
||||
];
|
||||
|
||||
// Linear (same speed throughout)
|
||||
const STATIC_FADE_LINEAR = generateEasedStaticFade([2, 2, 2, 2, 2, 2, 2, 2, 2]);
|
||||
|
||||
const STARS = "·+✣✤✻✽❊❈❈❈❈❊✽✻✤✣+";
|
||||
|
||||
const SPINNER: string | string[] = STATIC_FADE;
|
||||
|
||||
interface LoadingAnimationProps {
|
||||
visible?: boolean;
|
||||
|
|
@ -50,7 +161,7 @@ const LoadingAnimation: React.FC<LoadingAnimationProps> = ({
|
|||
|
||||
const interval = setInterval(() => {
|
||||
setCurrentIndex((prev) => (prev + 1) % animationChars.length);
|
||||
}, 300);
|
||||
}, 150);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [visible, animationChars.length]);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
import { constructSystemMessage } from "../../systemMessage.js";
|
||||
import { getToolDisplayName } from "../../tools.js";
|
||||
import { formatError } from "../../util/formatError.js";
|
||||
import logger from "../../util/logger.js";
|
||||
|
||||
import { DisplayMessage } from "../types.js";
|
||||
|
||||
|
|
@ -185,6 +186,7 @@ export function useChat({
|
|||
setAbortController(controller);
|
||||
setIsWaitingForResponse(true);
|
||||
setInputMode(false);
|
||||
logger.debug('Starting chat response stream', { messageLength: message.length, historyLength: newHistory.length });
|
||||
|
||||
try {
|
||||
let currentStreamingMessage: DisplayMessage | null = null;
|
||||
|
|
@ -310,9 +312,12 @@ export function useChat({
|
|||
|
||||
// Update the chat history with the complete conversation after streaming
|
||||
setChatHistory(finalHistory);
|
||||
logger.debug('Chat history updated', { finalHistoryLength: finalHistory.length });
|
||||
|
||||
// Save the updated history to session
|
||||
logger.debug('Saving session', { historyLength: finalHistory.length });
|
||||
saveSession(finalHistory);
|
||||
logger.debug('Session saved');
|
||||
} catch (error: any) {
|
||||
const errorMessage = `Error: ${formatError(error)}`;
|
||||
setMessages((prev) => [
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { BaseLlmApi } from "@continuedev/openai-adapters";
|
|||
import type { ChatCompletionCreateParamsStreaming } from "openai/resources.mjs";
|
||||
import { error, warn } from "../logging.js";
|
||||
import { formatError } from "./formatError.js";
|
||||
import logger from "./logger.js";
|
||||
|
||||
export interface ExponentialBackoffOptions {
|
||||
/** Maximum number of retry attempts */
|
||||
|
|
@ -198,6 +199,7 @@ export async function* withExponentialBackoff<T>(
|
|||
}
|
||||
|
||||
const delay = calculateDelay(attempt, opts);
|
||||
logger.debug('Retry attempt', { attempt, delay, error: err.message });
|
||||
|
||||
// Only log retry attempts after the first opts.hiddenRetries attempts
|
||||
if (attempt >= opts.hiddenRetries) {
|
||||
|
|
@ -209,6 +211,7 @@ export async function* withExponentialBackoff<T>(
|
|||
}
|
||||
|
||||
// Wait before retrying
|
||||
logger.debug('Waiting before retry', { delayMs: delay });
|
||||
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
88
src/util/logger.ts
Normal file
88
src/util/logger.ts
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import winston from 'winston';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import fs from 'fs';
|
||||
import crypto from 'crypto';
|
||||
|
||||
const { combine, timestamp, printf, errors } = winston.format;
|
||||
|
||||
// Generate a unique session ID for this process
|
||||
const SESSION_ID = crypto.randomBytes(4).toString('hex');
|
||||
|
||||
// Get log directory
|
||||
function getLogDir(): string {
|
||||
const homeDir = os.homedir();
|
||||
const logDir = path.join(homeDir, '.continue', 'logs');
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
if (!fs.existsSync(logDir)) {
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
}
|
||||
|
||||
return logDir;
|
||||
}
|
||||
|
||||
// Get current log file path
|
||||
function getLogFilePath(): string {
|
||||
const logDir = getLogDir();
|
||||
return path.join(logDir, 'cn.log');
|
||||
}
|
||||
|
||||
// Custom format for log output
|
||||
const logFormat = printf(({ level, message, timestamp, stack, ...metadata }) => {
|
||||
let msg = `${timestamp} [${SESSION_ID}] [${level}]: ${message}`;
|
||||
|
||||
// Add metadata if present
|
||||
if (Object.keys(metadata).length > 0) {
|
||||
msg += ` ${JSON.stringify(metadata)}`;
|
||||
}
|
||||
|
||||
// Add stack trace for errors
|
||||
if (stack) {
|
||||
msg += `\n${stack}`;
|
||||
}
|
||||
|
||||
return msg;
|
||||
});
|
||||
|
||||
// Create the logger instance
|
||||
const logger = winston.createLogger({
|
||||
level: 'info', // Default level
|
||||
format: combine(
|
||||
errors({ stack: true }),
|
||||
timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
|
||||
logFormat
|
||||
),
|
||||
transports: [
|
||||
// File transport for all logs
|
||||
new winston.transports.File({
|
||||
filename: getLogFilePath(),
|
||||
maxsize: 10 * 1024 * 1024, // 10MB
|
||||
maxFiles: 5,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
// Function to set log level
|
||||
export function setLogLevel(level: string) {
|
||||
logger.level = level;
|
||||
}
|
||||
|
||||
// Export logger methods
|
||||
export default {
|
||||
debug: (message: string, meta?: any) => logger.debug(message, meta),
|
||||
info: (message: string, meta?: any) => logger.info(message, meta),
|
||||
warn: (message: string, meta?: any) => logger.warn(message, meta),
|
||||
error: (message: string, error?: Error | any, meta?: any) => {
|
||||
if (error instanceof Error) {
|
||||
logger.error(message, { ...meta, error: error.message, stack: error.stack });
|
||||
} else if (error) {
|
||||
logger.error(message, { ...meta, error });
|
||||
} else {
|
||||
logger.error(message, meta);
|
||||
}
|
||||
},
|
||||
setLevel: setLogLevel,
|
||||
getLogPath: getLogFilePath,
|
||||
getSessionId: () => SESSION_ID,
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue