From 78e5fddae992c7740bfcafd7e711b674dda06d5e Mon Sep 17 00:00:00 2001 From: Justin Xu Date: Wed, 8 Oct 2025 20:29:13 +0000 Subject: [PATCH 1/3] Replace bun with Node.js (part 1) - Update package.json scripts to use npm/node instead of bun - Change shebang in src/index.ts from bun to node - Add build script to compile TypeScript to JavaScript - Update action.yml to run compiled .js files instead of .ts - Remove bun.lock and add package-lock.json - Update RELEASE.md documentation to reference npm - Remove bun engine requirement from package.json - Include compiled JavaScript files for GitHub Actions execution Note: Workflow files will be updated in a follow-up commit Addresses AU-14631 --- RELEASE.md | 12 +- action.yml | 6 +- bun.lock | 92 ---- package-lock.json | 403 ++++++++++++++++++ package.json | 10 +- src/config/constants.d.ts | 40 ++ src/config/constants.d.ts.map | 1 + src/config/constants.js | 58 +++ src/config/constants.js.map | 1 + src/index.d.ts | 7 + src/index.d.ts.map | 1 + src/index.js | 157 +++++++ src/index.js.map | 1 + src/index.ts | 2 +- src/services/github-service.d.ts | 18 + src/services/github-service.d.ts.map | 1 + src/services/github-service.js | 135 ++++++ src/services/github-service.js.map | 1 + src/template/context-builder.d.ts | 15 + src/template/context-builder.d.ts.map | 1 + src/template/context-builder.js | 51 +++ src/template/context-builder.js.map | 1 + src/template/extractors/base-extractor.d.ts | 26 ++ .../extractors/base-extractor.d.ts.map | 1 + src/template/extractors/base-extractor.js | 39 ++ src/template/extractors/base-extractor.js.map | 1 + .../extractors/custom-context-extractor.d.ts | 21 + .../custom-context-extractor.d.ts.map | 1 + .../extractors/custom-context-extractor.js | 46 ++ .../custom-context-extractor.js.map | 1 + src/template/extractors/pr-extractor.d.ts | 25 ++ src/template/extractors/pr-extractor.d.ts.map | 1 + src/template/extractors/pr-extractor.js | 123 ++++++ src/template/extractors/pr-extractor.js.map | 1 + src/template/template-engine.d.ts | 20 + src/template/template-engine.d.ts.map | 1 + src/template/template-engine.js | 108 +++++ src/template/template-engine.js.map | 1 + src/template/template-processor.d.ts | 15 + src/template/template-processor.d.ts.map | 1 + src/template/template-processor.js | 55 +++ src/template/template-processor.js.map | 1 + src/types/context.d.ts | 31 ++ src/types/context.d.ts.map | 1 + src/types/context.js | 5 + src/types/context.js.map | 1 + src/types/github.d.ts | 47 ++ src/types/github.d.ts.map | 1 + src/types/github.js | 5 + src/types/github.js.map | 1 + src/types/inputs.d.ts | 29 ++ src/types/inputs.d.ts.map | 1 + src/types/inputs.js | 5 + src/types/inputs.js.map | 1 + src/utils/file-utils.d.ts | 10 + src/utils/file-utils.d.ts.map | 1 + src/utils/file-utils.js | 83 ++++ src/utils/file-utils.js.map | 1 + src/utils/logger.d.ts | 39 ++ src/utils/logger.d.ts.map | 1 + src/utils/logger.js | 74 ++++ src/utils/logger.js.map | 1 + src/utils/validation.d.ts | 18 + src/utils/validation.d.ts.map | 1 + src/utils/validation.js | 200 +++++++++ src/utils/validation.js.map | 1 + 66 files changed, 1951 insertions(+), 109 deletions(-) delete mode 100644 bun.lock create mode 100644 package-lock.json create mode 100644 src/config/constants.d.ts create mode 100644 src/config/constants.d.ts.map create mode 100644 src/config/constants.js create mode 100644 src/config/constants.js.map create mode 100644 src/index.d.ts create mode 100644 src/index.d.ts.map create mode 100644 src/index.js create mode 100644 src/index.js.map create mode 100644 src/services/github-service.d.ts create mode 100644 src/services/github-service.d.ts.map create mode 100644 src/services/github-service.js create mode 100644 src/services/github-service.js.map create mode 100644 src/template/context-builder.d.ts create mode 100644 src/template/context-builder.d.ts.map create mode 100644 src/template/context-builder.js create mode 100644 src/template/context-builder.js.map create mode 100644 src/template/extractors/base-extractor.d.ts create mode 100644 src/template/extractors/base-extractor.d.ts.map create mode 100644 src/template/extractors/base-extractor.js create mode 100644 src/template/extractors/base-extractor.js.map create mode 100644 src/template/extractors/custom-context-extractor.d.ts create mode 100644 src/template/extractors/custom-context-extractor.d.ts.map create mode 100644 src/template/extractors/custom-context-extractor.js create mode 100644 src/template/extractors/custom-context-extractor.js.map create mode 100644 src/template/extractors/pr-extractor.d.ts create mode 100644 src/template/extractors/pr-extractor.d.ts.map create mode 100644 src/template/extractors/pr-extractor.js create mode 100644 src/template/extractors/pr-extractor.js.map create mode 100644 src/template/template-engine.d.ts create mode 100644 src/template/template-engine.d.ts.map create mode 100644 src/template/template-engine.js create mode 100644 src/template/template-engine.js.map create mode 100644 src/template/template-processor.d.ts create mode 100644 src/template/template-processor.d.ts.map create mode 100644 src/template/template-processor.js create mode 100644 src/template/template-processor.js.map create mode 100644 src/types/context.d.ts create mode 100644 src/types/context.d.ts.map create mode 100644 src/types/context.js create mode 100644 src/types/context.js.map create mode 100644 src/types/github.d.ts create mode 100644 src/types/github.d.ts.map create mode 100644 src/types/github.js create mode 100644 src/types/github.js.map create mode 100644 src/types/inputs.d.ts create mode 100644 src/types/inputs.d.ts.map create mode 100644 src/types/inputs.js create mode 100644 src/types/inputs.js.map create mode 100644 src/utils/file-utils.d.ts create mode 100644 src/utils/file-utils.d.ts.map create mode 100644 src/utils/file-utils.js create mode 100644 src/utils/file-utils.js.map create mode 100644 src/utils/logger.d.ts create mode 100644 src/utils/logger.d.ts.map create mode 100644 src/utils/logger.js create mode 100644 src/utils/logger.js.map create mode 100644 src/utils/validation.d.ts create mode 100644 src/utils/validation.d.ts.map create mode 100644 src/utils/validation.js create mode 100644 src/utils/validation.js.map diff --git a/RELEASE.md b/RELEASE.md index 41f2fb3..395abe6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -8,13 +8,13 @@ Use the built-in npm scripts for easy version bumping: ```bash # For patch releases (bug fixes): 0.1.0 -> 0.1.1 -bun run version:patch +npm run version:patch # For minor releases (new features): 0.1.0 -> 0.2.0 -bun run version:minor +npm run version:minor # For major releases (breaking changes): 0.1.0 -> 1.0.0 -bun run version:major +npm run version:major ``` These scripts will: @@ -31,13 +31,13 @@ If you prefer manual control: 1. **Update the version in package.json:** ```bash - bun version 0.1.1 # or whatever version you want + npm version 0.1.1 # or whatever version you want ``` 2. **Type check the project:** ```bash - bun run typecheck + npm run typecheck ``` 3. **Commit the changes:** @@ -93,7 +93,7 @@ This allows users to pin to major versions for automatic updates: **Type check failures:** -- Run `bun run typecheck` locally to check for TypeScript errors +- Run `npm run typecheck` locally to check for TypeScript errors - Ensure all dependencies are properly installed **Release not created:** diff --git a/action.yml b/action.yml index 46e9098..dc18171 100644 --- a/action.yml +++ b/action.yml @@ -60,12 +60,8 @@ runs: - name: Setup Auggie run: npm install -g @augmentcode/auggie shell: bash - - name: Setup Bun - uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 - with: - bun-version: latest - name: Run Augment Agent - run: bun run $GITHUB_ACTION_PATH/src/index.ts + run: node $GITHUB_ACTION_PATH/src/index.js shell: bash env: INPUT_AUGMENT_SESSION_AUTH: ${{ inputs.augment_session_auth }} diff --git a/bun.lock b/bun.lock deleted file mode 100644 index 6f40ef3..0000000 --- a/bun.lock +++ /dev/null @@ -1,92 +0,0 @@ -{ - "lockfileVersion": 1, - "workspaces": { - "": { - "name": "augment-agent", - "dependencies": { - "@actions/core": "^1.10.1", - "@octokit/rest": "^20.0.2", - "nunjucks": "^3.2.4", - "yaml": "^2.3.4", - "zod": "^3.22.4", - }, - "devDependencies": { - "@types/node": "^22.16.4", - "@types/nunjucks": "^3.2.6", - "prettier": "^3.6.2", - "typescript": "^5.8.3", - }, - }, - }, - "packages": { - "@actions/core": ["@actions/core@1.11.1", "", { "dependencies": { "@actions/exec": "^1.1.1", "@actions/http-client": "^2.0.1" } }, "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A=="], - - "@actions/exec": ["@actions/exec@1.1.1", "", { "dependencies": { "@actions/io": "^1.0.1" } }, "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w=="], - - "@actions/http-client": ["@actions/http-client@2.2.3", "", { "dependencies": { "tunnel": "^0.0.6", "undici": "^5.25.4" } }, "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA=="], - - "@actions/io": ["@actions/io@1.1.3", "", {}, "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="], - - "@fastify/busboy": ["@fastify/busboy@2.1.1", "", {}, "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA=="], - - "@octokit/auth-token": ["@octokit/auth-token@4.0.0", "", {}, "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA=="], - - "@octokit/core": ["@octokit/core@5.2.2", "", { "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.1.0", "@octokit/request": "^8.4.1", "@octokit/request-error": "^5.1.1", "@octokit/types": "^13.0.0", "before-after-hook": "^2.2.0", "universal-user-agent": "^6.0.0" } }, "sha512-/g2d4sW9nUDJOMz3mabVQvOGhVa4e/BN/Um7yca9Bb2XTzPPnfTWHWQg+IsEYO7M3Vx+EXvaM/I2pJWIMun1bg=="], - - "@octokit/endpoint": ["@octokit/endpoint@9.0.6", "", { "dependencies": { "@octokit/types": "^13.1.0", "universal-user-agent": "^6.0.0" } }, "sha512-H1fNTMA57HbkFESSt3Y9+FBICv+0jFceJFPWDePYlR/iMGrwM5ph+Dd4XRQs+8X+PUFURLQgX9ChPfhJ/1uNQw=="], - - "@octokit/graphql": ["@octokit/graphql@7.1.1", "", { "dependencies": { "@octokit/request": "^8.4.1", "@octokit/types": "^13.0.0", "universal-user-agent": "^6.0.0" } }, "sha512-3mkDltSfcDUoa176nlGoA32RGjeWjl3K7F/BwHwRMJUW/IteSa4bnSV8p2ThNkcIcZU2umkZWxwETSSCJf2Q7g=="], - - "@octokit/openapi-types": ["@octokit/openapi-types@24.2.0", "", {}, "sha512-9sIH3nSUttelJSXUrmGzl7QUBFul0/mB8HRYl3fOlgHbIWG+WnYDXU3v/2zMtAvuzZ/ed00Ei6on975FhBfzrg=="], - - "@octokit/plugin-paginate-rest": ["@octokit/plugin-paginate-rest@11.4.4-cjs.2", "", { "dependencies": { "@octokit/types": "^13.7.0" }, "peerDependencies": { "@octokit/core": "5" } }, "sha512-2dK6z8fhs8lla5PaOTgqfCGBxgAv/le+EhPs27KklPhm1bKObpu6lXzwfUEQ16ajXzqNrKMujsFyo9K2eaoISw=="], - - "@octokit/plugin-request-log": ["@octokit/plugin-request-log@4.0.1", "", { "peerDependencies": { "@octokit/core": "5" } }, "sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA=="], - - "@octokit/plugin-rest-endpoint-methods": ["@octokit/plugin-rest-endpoint-methods@13.3.2-cjs.1", "", { "dependencies": { "@octokit/types": "^13.8.0" }, "peerDependencies": { "@octokit/core": "^5" } }, "sha512-VUjIjOOvF2oELQmiFpWA1aOPdawpyaCUqcEBc/UOUnj3Xp6DJGrJ1+bjUIIDzdHjnFNO6q57ODMfdEZnoBkCwQ=="], - - "@octokit/request": ["@octokit/request@8.4.1", "", { "dependencies": { "@octokit/endpoint": "^9.0.6", "@octokit/request-error": "^5.1.1", "@octokit/types": "^13.1.0", "universal-user-agent": "^6.0.0" } }, "sha512-qnB2+SY3hkCmBxZsR/MPCybNmbJe4KAlfWErXq+rBKkQJlbjdJeS85VI9r8UqeLYLvnAenU8Q1okM/0MBsAGXw=="], - - "@octokit/request-error": ["@octokit/request-error@5.1.1", "", { "dependencies": { "@octokit/types": "^13.1.0", "deprecation": "^2.0.0", "once": "^1.4.0" } }, "sha512-v9iyEQJH6ZntoENr9/yXxjuezh4My67CBSu9r6Ve/05Iu5gNgnisNWOsoJHTP6k0Rr0+HQIpnH+kyammu90q/g=="], - - "@octokit/rest": ["@octokit/rest@20.1.2", "", { "dependencies": { "@octokit/core": "^5.0.2", "@octokit/plugin-paginate-rest": "11.4.4-cjs.2", "@octokit/plugin-request-log": "^4.0.0", "@octokit/plugin-rest-endpoint-methods": "13.3.2-cjs.1" } }, "sha512-GmYiltypkHHtihFwPRxlaorG5R9VAHuk/vbszVoRTGXnAsY60wYLkh/E2XiFmdZmqrisw+9FaazS1i5SbdWYgA=="], - - "@octokit/types": ["@octokit/types@13.10.0", "", { "dependencies": { "@octokit/openapi-types": "^24.2.0" } }, "sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA=="], - - "@types/node": ["@types/node@22.16.4", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-PYRhNtZdm2wH/NT2k/oAJ6/f2VD2N2Dag0lGlx2vWgMSJXGNmlce5MiTQzoWAiIJtso30mjnfQCOKVH+kAQC/g=="], - - "@types/nunjucks": ["@types/nunjucks@3.2.6", "", {}, "sha512-pHiGtf83na1nCzliuAdq8GowYiXvH5l931xZ0YEHaLMNFgynpEqx+IPStlu7UaDkehfvl01e4x/9Tpwhy7Ue3w=="], - - "a-sync-waterfall": ["a-sync-waterfall@1.0.1", "", {}, "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA=="], - - "asap": ["asap@2.0.6", "", {}, "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA=="], - - "before-after-hook": ["before-after-hook@2.2.3", "", {}, "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="], - - "commander": ["commander@5.1.0", "", {}, "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg=="], - - "deprecation": ["deprecation@2.3.1", "", {}, "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="], - - "nunjucks": ["nunjucks@3.2.4", "", { "dependencies": { "a-sync-waterfall": "^1.0.0", "asap": "^2.0.3", "commander": "^5.1.0" }, "peerDependencies": { "chokidar": "^3.3.0" }, "optionalPeers": ["chokidar"], "bin": { "nunjucks-precompile": "bin/precompile" } }, "sha512-26XRV6BhkgK0VOxfbU5cQI+ICFUtMLixv1noZn1tGU38kQH5A5nmmbk/O45xdyBhD1esk47nKrY0mvQpZIhRjQ=="], - - "once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="], - - "prettier": ["prettier@3.6.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="], - - "tunnel": ["tunnel@0.0.6", "", {}, "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="], - - "typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="], - - "undici": ["undici@5.29.0", "", { "dependencies": { "@fastify/busboy": "^2.0.0" } }, "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg=="], - - "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="], - - "universal-user-agent": ["universal-user-agent@6.0.1", "", {}, "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ=="], - - "wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="], - - "yaml": ["yaml@2.8.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ=="], - - "zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="], - } -} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..aa362d8 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,403 @@ +{ + "name": "augment-agent", + "version": "0.1.2", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "augment-agent", + "version": "0.1.2", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.10.1", + "@octokit/rest": "^20.0.2", + "nunjucks": "^3.2.4", + "yaml": "^2.3.4", + "zod": "^3.22.4" + }, + "devDependencies": { + "@types/node": "^22.16.4", + "@types/nunjucks": "^3.2.6", + "prettier": "^3.6.2", + "typescript": "^5.8.3" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@actions/core": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz", + "integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==", + "license": "MIT", + "dependencies": { + "@actions/exec": "^1.1.1", + "@actions/http-client": "^2.0.1" + } + }, + "node_modules/@actions/exec": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", + "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", + "license": "MIT", + "dependencies": { + "@actions/io": "^1.0.1" + } + }, + "node_modules/@actions/http-client": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz", + "integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==", + "license": "MIT", + "dependencies": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, + "node_modules/@actions/io": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", + "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==", + "license": "MIT" + }, + "node_modules/@fastify/busboy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", + "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/@octokit/auth-token": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", + "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/core": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.2.tgz", + "integrity": "sha512-/g2d4sW9nUDJOMz3mabVQvOGhVa4e/BN/Um7yca9Bb2XTzPPnfTWHWQg+IsEYO7M3Vx+EXvaM/I2pJWIMun1bg==", + "license": "MIT", + "dependencies": { + "@octokit/auth-token": "^4.0.0", + "@octokit/graphql": "^7.1.0", + "@octokit/request": "^8.4.1", + "@octokit/request-error": "^5.1.1", + "@octokit/types": "^13.0.0", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.6.tgz", + "integrity": "sha512-H1fNTMA57HbkFESSt3Y9+FBICv+0jFceJFPWDePYlR/iMGrwM5ph+Dd4XRQs+8X+PUFURLQgX9ChPfhJ/1uNQw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.1.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.1.tgz", + "integrity": "sha512-3mkDltSfcDUoa176nlGoA32RGjeWjl3K7F/BwHwRMJUW/IteSa4bnSV8p2ThNkcIcZU2umkZWxwETSSCJf2Q7g==", + "license": "MIT", + "dependencies": { + "@octokit/request": "^8.4.1", + "@octokit/types": "^13.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "24.2.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-24.2.0.tgz", + "integrity": "sha512-9sIH3nSUttelJSXUrmGzl7QUBFul0/mB8HRYl3fOlgHbIWG+WnYDXU3v/2zMtAvuzZ/ed00Ei6on975FhBfzrg==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "11.4.4-cjs.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.4.4-cjs.2.tgz", + "integrity": "sha512-2dK6z8fhs8lla5PaOTgqfCGBxgAv/le+EhPs27KklPhm1bKObpu6lXzwfUEQ16ajXzqNrKMujsFyo9K2eaoISw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.7.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": "5" + } + }, + "node_modules/@octokit/plugin-request-log": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-4.0.1.tgz", + "integrity": "sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": "5" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "13.3.2-cjs.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.3.2-cjs.1.tgz", + "integrity": "sha512-VUjIjOOvF2oELQmiFpWA1aOPdawpyaCUqcEBc/UOUnj3Xp6DJGrJ1+bjUIIDzdHjnFNO6q57ODMfdEZnoBkCwQ==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.8.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": "^5" + } + }, + "node_modules/@octokit/request": { + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.4.1.tgz", + "integrity": "sha512-qnB2+SY3hkCmBxZsR/MPCybNmbJe4KAlfWErXq+rBKkQJlbjdJeS85VI9r8UqeLYLvnAenU8Q1okM/0MBsAGXw==", + "license": "MIT", + "dependencies": { + "@octokit/endpoint": "^9.0.6", + "@octokit/request-error": "^5.1.1", + "@octokit/types": "^13.1.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/request-error": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.1.1.tgz", + "integrity": "sha512-v9iyEQJH6ZntoENr9/yXxjuezh4My67CBSu9r6Ve/05Iu5gNgnisNWOsoJHTP6k0Rr0+HQIpnH+kyammu90q/g==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.1.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/rest": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.1.2.tgz", + "integrity": "sha512-GmYiltypkHHtihFwPRxlaorG5R9VAHuk/vbszVoRTGXnAsY60wYLkh/E2XiFmdZmqrisw+9FaazS1i5SbdWYgA==", + "license": "MIT", + "dependencies": { + "@octokit/core": "^5.0.2", + "@octokit/plugin-paginate-rest": "11.4.4-cjs.2", + "@octokit/plugin-request-log": "^4.0.0", + "@octokit/plugin-rest-endpoint-methods": "13.3.2-cjs.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/types": { + "version": "13.10.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.10.0.tgz", + "integrity": "sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^24.2.0" + } + }, + "node_modules/@types/node": { + "version": "22.18.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.8.tgz", + "integrity": "sha512-pAZSHMiagDR7cARo/cch1f3rXy0AEXwsVsVH09FcyeJVAzCnGgmYis7P3JidtTUjyadhTeSo8TgRPswstghDaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/nunjucks": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/@types/nunjucks/-/nunjucks-3.2.6.tgz", + "integrity": "sha512-pHiGtf83na1nCzliuAdq8GowYiXvH5l931xZ0YEHaLMNFgynpEqx+IPStlu7UaDkehfvl01e4x/9Tpwhy7Ue3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/a-sync-waterfall": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz", + "integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==", + "license": "MIT" + }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "license": "MIT" + }, + "node_modules/before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", + "license": "Apache-2.0" + }, + "node_modules/commander": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", + "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", + "license": "ISC" + }, + "node_modules/nunjucks": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.4.tgz", + "integrity": "sha512-26XRV6BhkgK0VOxfbU5cQI+ICFUtMLixv1noZn1tGU38kQH5A5nmmbk/O45xdyBhD1esk47nKrY0mvQpZIhRjQ==", + "license": "BSD-2-Clause", + "dependencies": { + "a-sync-waterfall": "^1.0.0", + "asap": "^2.0.3", + "commander": "^5.1.0" + }, + "bin": { + "nunjucks-precompile": "bin/precompile" + }, + "engines": { + "node": ">= 6.9.0" + }, + "peerDependencies": { + "chokidar": "^3.3.0" + }, + "peerDependenciesMeta": { + "chokidar": { + "optional": true + } + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "license": "MIT", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici": { + "version": "5.29.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz", + "integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==", + "license": "MIT", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/universal-user-agent": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", + "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==", + "license": "ISC" + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/yaml": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + } + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/package.json b/package.json index 2f39d63..2fde26b 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,15 @@ "main": "action.yml", "type": "module", "scripts": { - "test": "bun test", - "typecheck": "bun --bun tsc --noEmit", + "build": "tsc", + "test": "node --test", + "typecheck": "tsc --noEmit", "format": "prettier --write .", "format:check": "prettier --check .", "format:staged": "prettier --write --cache --ignore-unknown", "lint": "prettier --check .", "lint:fix": "prettier --write .", - "dev": "bun --watch src/index.ts", + "dev": "node --watch src/index.ts", "version:patch": "npm version patch && git push && git push --tags", "version:minor": "npm version minor && git push && git push --tags", "version:major": "npm version major && git push && git push --tags" @@ -38,8 +39,7 @@ }, "homepage": "https://github.com/augmentcode/augment-agent#readme", "engines": { - "node": ">=22.0.0", - "bun": ">=1.0.0" + "node": ">=22.0.0" }, "files": [ "action.yml", diff --git a/src/config/constants.d.ts b/src/config/constants.d.ts new file mode 100644 index 0000000..405e2f1 --- /dev/null +++ b/src/config/constants.d.ts @@ -0,0 +1,40 @@ +/** + * Configuration constants for the Augment Agent + */ +import type { InputField } from '../types/inputs.js'; +export declare const ACTION_CONFIG: { + NAME: string; +}; +export declare const INPUT_FIELD_MAP: Record; +export declare const TEMPLATE_CONFIG: { + DEFAULT_TEMPLATE_NAME: string; + MAX_TEMPLATE_SIZE: number; + MAX_DIFF_SIZE: number; +}; +export declare const PATHS: { + TEMP_DIR: string; + DIFF_FILE_PATTERN: string; + INSTRUCTION_FILE: string; +}; +export declare const ERROR: { + readonly GITHUB: { + readonly API_ERROR: "GitHub API request failed"; + }; + readonly INPUT: { + readonly CONFLICTING_INSTRUCTION_INPUTS: "Cannot specify both instruction and instruction_file"; + readonly CONFLICTING_INSTRUCTION_TEMPLATE: "Cannot use both instruction inputs and template inputs simultaneously"; + readonly INVALID: "Invalid action inputs"; + readonly INVALID_CONTEXT_JSON: "Invalid JSON in custom_context"; + readonly MISMATCHED_PR_FIELDS: "Both pull_number and repo_name are required for PR extraction"; + readonly MISSING_INSTRUCTION_OR_TEMPLATE: "Either instruction/instruction_file or template_directory must be provided"; + readonly REPO_FORMAT: "Repository name must be in format \"owner/repo\""; + }; + readonly TEMPLATE: { + readonly MISSING_DIRECTORY: "template_directory is required when using templates"; + readonly NOT_FOUND: "Template file not found"; + readonly PATH_OUTSIDE_DIRECTORY: "Template path is outside template directory"; + readonly RENDER_ERROR: "Failed to render template"; + readonly TOO_LARGE: "Template file exceeds maximum size"; + }; +}; +//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/src/config/constants.d.ts.map b/src/config/constants.d.ts.map new file mode 100644 index 0000000..2a1f836 --- /dev/null +++ b/src/config/constants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAmBtD,CAAC;AAEF,eAAO,MAAM,eAAe;;;;CAI3B,CAAC;AAEF,eAAO,MAAM,KAAK;;;;CAIjB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;CAsBR,CAAC"} \ No newline at end of file diff --git a/src/config/constants.js b/src/config/constants.js new file mode 100644 index 0000000..adc4a0f --- /dev/null +++ b/src/config/constants.js @@ -0,0 +1,58 @@ +/** + * Configuration constants for the Augment Agent + */ +export const ACTION_CONFIG = { + NAME: 'Augment Agent', +}; +export const INPUT_FIELD_MAP = { + augmentSessionAuth: { envVar: 'INPUT_AUGMENT_SESSION_AUTH', required: false }, + augmentApiToken: { envVar: 'INPUT_AUGMENT_API_TOKEN', required: false }, + augmentApiUrl: { envVar: 'INPUT_AUGMENT_API_URL', required: false }, + customContext: { envVar: 'INPUT_CUSTOM_CONTEXT', required: false }, + githubToken: { envVar: 'INPUT_GITHUB_TOKEN', required: false }, + instruction: { envVar: 'INPUT_INSTRUCTION', required: false }, + instructionFile: { envVar: 'INPUT_INSTRUCTION_FILE', required: false }, + pullNumber: { + envVar: 'INPUT_PULL_NUMBER', + required: false, + transform: (val) => parseInt(val, 10), + }, + repoName: { envVar: 'INPUT_REPO_NAME', required: false }, + templateDirectory: { envVar: 'INPUT_TEMPLATE_DIRECTORY', required: false }, + templateName: { envVar: 'INPUT_TEMPLATE_NAME', required: false }, + model: { envVar: 'INPUT_MODEL', required: false }, + rules: { envVar: 'INPUT_RULES', required: false }, + mcpConfigs: { envVar: 'INPUT_MCP_CONFIGS', required: false }, +}; +export const TEMPLATE_CONFIG = { + DEFAULT_TEMPLATE_NAME: 'prompt.njk', + MAX_TEMPLATE_SIZE: 128 * 1024, // 128KB + MAX_DIFF_SIZE: 128 * 1024, // 128KB +}; +export const PATHS = { + TEMP_DIR: '/tmp', + DIFF_FILE_PATTERN: 'pr-{pullNumber}-diff.patch', + INSTRUCTION_FILE: '/tmp/generated-instruction.txt', +}; +export const ERROR = { + GITHUB: { + API_ERROR: 'GitHub API request failed', + }, + INPUT: { + CONFLICTING_INSTRUCTION_INPUTS: 'Cannot specify both instruction and instruction_file', + CONFLICTING_INSTRUCTION_TEMPLATE: 'Cannot use both instruction inputs and template inputs simultaneously', + INVALID: 'Invalid action inputs', + INVALID_CONTEXT_JSON: 'Invalid JSON in custom_context', + MISMATCHED_PR_FIELDS: 'Both pull_number and repo_name are required for PR extraction', + MISSING_INSTRUCTION_OR_TEMPLATE: 'Either instruction/instruction_file or template_directory must be provided', + REPO_FORMAT: 'Repository name must be in format "owner/repo"', + }, + TEMPLATE: { + MISSING_DIRECTORY: 'template_directory is required when using templates', + NOT_FOUND: 'Template file not found', + PATH_OUTSIDE_DIRECTORY: 'Template path is outside template directory', + RENDER_ERROR: 'Failed to render template', + TOO_LARGE: 'Template file exceeds maximum size', + }, +}; +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/src/config/constants.js.map b/src/config/constants.js.map new file mode 100644 index 0000000..2226428 --- /dev/null +++ b/src/config/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAA+B;IACzD,kBAAkB,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE;IAC7E,eAAe,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE,QAAQ,EAAE,KAAK,EAAE;IACvE,aAAa,EAAE,EAAE,MAAM,EAAE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,4BAA4B;IAC/C,gBAAgB,EAAE,gCAAgC;CACnD,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE;QACN,SAAS,EAAE,2BAA2B;KACvC;IACD,KAAK,EAAE;QACL,8BAA8B,EAAE,sDAAsD;QACtF,gCAAgC,EAC9B,uEAAuE;QACzE,OAAO,EAAE,uBAAuB;QAChC,oBAAoB,EAAE,gCAAgC;QACtD,oBAAoB,EAAE,+DAA+D;QACrF,+BAA+B,EAC7B,4EAA4E;QAC9E,WAAW,EAAE,gDAAgD;KAC9D;IACD,QAAQ,EAAE;QACR,iBAAiB,EAAE,qDAAqD;QACxE,SAAS,EAAE,yBAAyB;QACpC,sBAAsB,EAAE,6CAA6C;QACrE,YAAY,EAAE,2BAA2B;QACzC,SAAS,EAAE,oCAAoC;KAChD;CACO,CAAC"} \ No newline at end of file diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..f035206 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,7 @@ +#!/usr/bin/env node +/** + * Augment Agent GitHub Action + * Main entry point for the action + */ +export {}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/src/index.d.ts.map b/src/index.d.ts.map new file mode 100644 index 0000000..d0cfa4f --- /dev/null +++ b/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAEA;;;GAGG"} \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..2270121 --- /dev/null +++ b/src/index.js @@ -0,0 +1,157 @@ +#!/usr/bin/env node +/** + * Augment Agent GitHub Action + * Main entry point for the action + */ +import { spawn } from 'child_process'; +import process from 'process'; +import { ValidationUtils } from './utils/validation.js'; +import { TemplateProcessor } from './template/template-processor.js'; +import { logger } from './utils/logger.js'; +/** + * Execute a shell command and return a promise + */ +function execCommand(command, args = [], options = {}) { + return new Promise((resolve, reject) => { + // Join command and args into a single shell command for proper quoting + const fullCommand = `${command} ${args + .map(arg => { + // Properly quote arguments that contain spaces or special characters + if (arg.includes(' ') || arg.includes('"') || arg.includes("'")) { + return `"${arg.replace(/"/g, '\\"')}"`; + } + return arg; + }) + .join(' ')}`; + const child = spawn(fullCommand, [], { + stdio: 'inherit', + shell: true, + ...options, + }); + child.on('close', code => { + if (code === 0) { + resolve(code); + } + else { + reject(new Error(`Command failed with exit code ${code}`)); + } + }); + child.on('error', error => { + reject(error); + }); + }); +} +/** + * Set up environment variables for the augment script + */ +function setupEnvironment(inputs) { + // Set authentication environment variables + if (inputs.augmentSessionAuth) { + // Use session authentication + process.env.AUGMENT_SESSION_AUTH = inputs.augmentSessionAuth; + } + else { + // Use token + URL authentication + process.env.AUGMENT_API_TOKEN = inputs.augmentApiToken; + process.env.AUGMENT_API_URL = inputs.augmentApiUrl; + } + // Set GitHub token if provided + if (inputs.githubToken) { + process.env.GITHUB_API_TOKEN = inputs.githubToken; + } +} +/** + * Process templates and generate instruction file + */ +async function processTemplate(inputs) { + logger.info('Preparing template', { + templateDirectory: inputs.templateDirectory, + templateName: inputs.templateName, + }); + // Create and run template processor + const processor = TemplateProcessor.create(inputs); + const instructionFilePath = await processor.processTemplate(inputs); + logger.info('Template processing completed', { + instructionFile: instructionFilePath, + }); + return instructionFilePath; +} +/** + * Run the augment script with appropriate arguments + */ +async function runAugmentScript(inputs) { + let instruction_value; + let is_file; + if (inputs.instruction) { + instruction_value = inputs.instruction; + is_file = false; + logger.debug('Using direct instruction', { instruction: inputs.instruction }); + } + else if (inputs.instructionFile) { + instruction_value = inputs.instructionFile; + is_file = true; + logger.debug('Using instruction file', { instructionFile: inputs.instructionFile }); + } + else { + instruction_value = await processTemplate(inputs); + is_file = true; + logger.debug('Using template-generated instruction file', { + instructionFile: instruction_value, + }); + } + const args = ['--print']; + if (inputs.model && inputs.model.trim().length > 0) { + args.push('--model', inputs.model.trim()); + } + if (is_file) { + logger.info(`📄 Using instruction file: ${instruction_value}`); + args.push('--instruction-file', instruction_value); + } + else { + logger.info('📝 Using direct instruction'); + args.push('--instruction', instruction_value); + } + const uniqueRules = Array.from(new Set(inputs.rules ?? [])).filter(rule => rule.length > 0); + if (uniqueRules.length > 0) { + logger.info(`🔧 Applying ${uniqueRules.length} rule file(s)`); + for (const rulePath of uniqueRules) { + logger.info(` - ${rulePath}`); + args.push('--rules', rulePath); + } + } + const uniqueMcpConfigs = Array.from(new Set(inputs.mcpConfigs ?? [])).filter(config => config.length > 0); + if (uniqueMcpConfigs.length > 0) { + logger.info(`🧩 Applying ${uniqueMcpConfigs.length} MCP config file(s)`); + for (const configPath of uniqueMcpConfigs) { + logger.info(` - ${configPath}`); + args.push('--mcp-config', configPath); + } + } + await execCommand('auggie', args); + logger.info('✅ Augment Agent completed successfully'); +} +/** + * Main function + */ +async function main() { + try { + logger.info('🔍 Validating inputs...'); + const inputs = ValidationUtils.validateInputs(); + logger.info('⚙️ Setting up environment...'); + setupEnvironment(inputs); + logger.info('🚀 Starting Augment Agent...'); + await runAugmentScript(inputs); + } + catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + logger.setFailed(errorMessage); + } +} +// Run the action only if this file is executed directly +if (import.meta.url === `file://${process.argv[1]}`) { + main().catch(error => { + const errorMessage = error instanceof Error ? error.message : String(error); + logger.setFailed(`Unexpected error: ${errorMessage}`); + }); +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/index.js.map b/src/index.js.map new file mode 100644 index 0000000..c06d361 --- /dev/null +++ b/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EA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AM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC5C,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACnB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,CAAC,SAAS,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 94ed55f..fab338d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env bun +#!/usr/bin/env node /** * Augment Agent GitHub Action diff --git a/src/services/github-service.d.ts b/src/services/github-service.d.ts new file mode 100644 index 0000000..c6627fd --- /dev/null +++ b/src/services/github-service.d.ts @@ -0,0 +1,18 @@ +/** + * GitHub API service for PR information extraction + */ +import { PullRequestInfo, PullRequestFile, PullRequestDiff } from '../types/github.js'; +export declare class GitHubService { + private octokit; + private owner; + private repo; + constructor(config: { + token: string; + owner: string; + repo: string; + }); + getPullRequest(pullNumber: number): Promise; + getPullRequestFiles(pullNumber: number): Promise; + getPullRequestDiff(pullNumber: number): Promise; +} +//# sourceMappingURL=github-service.d.ts.map \ No newline at end of file diff --git a/src/services/github-service.d.ts.map b/src/services/github-service.d.ts.map new file mode 100644 index 0000000..e9a77d7 --- /dev/null +++ b/src/services/github-service.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"github-service.d.ts","sourceRoot":"","sources":["github-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIvF,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;gBAET,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAM5D,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA6C5D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA8DnE,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAyBvE"} \ No newline at end of file diff --git a/src/services/github-service.js b/src/services/github-service.js new file mode 100644 index 0000000..1ba4e1c --- /dev/null +++ b/src/services/github-service.js @@ -0,0 +1,135 @@ +/** + * GitHub API service for PR information extraction + */ +import { Octokit } from '@octokit/rest'; +import { TEMPLATE_CONFIG, ERROR } from '../config/constants.js'; +import { logger } from '../utils/logger.js'; +export class GitHubService { + octokit; + owner; + repo; + constructor(config) { + this.octokit = new Octokit({ auth: config.token }); + this.owner = config.owner; + this.repo = config.repo; + } + async getPullRequest(pullNumber) { + try { + logger.debug(`Fetching PR ${pullNumber} from ${this.owner}/${this.repo}`); + const { data } = await this.octokit.rest.pulls.get({ + owner: this.owner, + repo: this.repo, + pull_number: pullNumber, + }); + return { + number: data.number, + title: data.title, + body: data.body, + state: data.state, + user: { login: data.user?.login || 'unknown' }, + head: { + ref: data.head.ref, + sha: data.head.sha, + repo: { + full_name: data.head.repo.full_name, + name: data.head.repo.name, + owner: { + login: data.head.repo.owner.login, + }, + }, + }, + base: { + ref: data.base.ref, + sha: data.base.sha, + repo: { + full_name: data.base.repo.full_name, + name: data.base.repo.name, + owner: { + login: data.base.repo.owner.login, + }, + }, + }, + }; + } + catch (error) { + logger.error(`${ERROR.GITHUB.API_ERROR}: Failed to fetch PR ${pullNumber}`, error); + throw error; + } + } + async getPullRequestFiles(pullNumber) { + try { + logger.debug(`Fetching files for PR ${pullNumber}`); + const allFiles = []; + let page = 1; + const perPage = 100; // GitHub's maximum per page + while (true) { + logger.debug(`Fetching PR files page ${page}`, { + pullNumber, + page, + perPage, + }); + const { data } = await this.octokit.rest.pulls.listFiles({ + owner: this.owner, + repo: this.repo, + pull_number: pullNumber, + per_page: perPage, + page, + }); + // Map and add files from this page + const pageFiles = data.map(file => ({ + filename: file.filename, + status: file.status, + additions: file.additions, + deletions: file.deletions, + changes: file.changes, + })); + allFiles.push(...pageFiles); + logger.debug(`Fetched ${pageFiles.length} files from page ${page}`, { + pullNumber, + page, + filesOnPage: pageFiles.length, + totalFilesSoFar: allFiles.length, + }); + // If we got fewer files than the page size, we've reached the end + if (data.length < perPage) { + break; + } + page++; + } + logger.info(`Successfully fetched all PR files`, { + pullNumber, + totalFiles: allFiles.length, + totalPages: page, + }); + return allFiles; + } + catch (error) { + logger.error(`${ERROR.GITHUB.API_ERROR}: Failed to fetch PR files`, error); + throw error; + } + } + async getPullRequestDiff(pullNumber) { + try { + logger.debug(`Fetching diff for PR ${pullNumber}`); + const { data } = await this.octokit.rest.pulls.get({ + owner: this.owner, + repo: this.repo, + pull_number: pullNumber, + mediaType: { format: 'diff' }, + }); + const content = data; + const size = Buffer.byteLength(content, 'utf8'); + const truncated = size > TEMPLATE_CONFIG.MAX_DIFF_SIZE; + return { + content: truncated ? content.substring(0, TEMPLATE_CONFIG.MAX_DIFF_SIZE) : content, + size, + truncated, + }; + } + catch (error) { + logger.error(`${ERROR.GITHUB.API_ERROR}: Failed to fetch PR diff`, error); + throw error; + } + } +} +//# sourceMappingURL=github-service.js.map \ No newline at end of file diff --git a/src/services/github-service.js.map b/src/services/github-service.js.map new file mode 100644 index 0000000..dfe2c9b --- /dev/null +++ b/src/services/github-service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"github-service.js","sourceRoot":"","sources":["github-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,OAAO,aAAa;IAChB,OAAO,CAAU;IACjB,KAAK,CAAS;IACd,IAAI,CAAS;IAErB,YAAY,MAAsD;QAChE,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkB;QACrC,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,eAAe,UAAU,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAE1E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;gBACjD,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,UAAU;aACxB,CAAC,CAAC;YAEH,OAAO;gBACL,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,IAAI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,CAAC,CAAC;YAC1E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/context-builder.d.ts b/src/template/context-builder.d.ts new file mode 100644 index 0000000..4c21677 --- /dev/null +++ b/src/template/context-builder.d.ts @@ -0,0 +1,15 @@ +/** + * Context builder - responsible for aggregating context from multiple sources + */ +import { PRExtractor } from './extractors/pr-extractor.js'; +import { CustomContextExtractor } from './extractors/custom-context-extractor.js'; +import type { TemplateContext } from '../types/context.js'; +import type { ActionInputs } from '../types/inputs.js'; +export declare class ContextBuilder { + private prExtractor; + private customContextExtractor; + constructor(prExtractor: PRExtractor, customContextExtractor: CustomContextExtractor); + static create(inputs: ActionInputs): ContextBuilder; + buildContext(inputs: ActionInputs): Promise; +} +//# sourceMappingURL=context-builder.d.ts.map \ No newline at end of file diff --git a/src/template/context-builder.d.ts.map b/src/template/context-builder.d.ts.map new file mode 100644 index 0000000..3add95c --- /dev/null +++ b/src/template/context-builder.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["context-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,cAAc;IAEvB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,sBAAsB;gBADtB,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB;IAGxD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc;IAI7C,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC;CAqCnE"} \ No newline at end of file diff --git a/src/template/context-builder.js b/src/template/context-builder.js new file mode 100644 index 0000000..7b6097e --- /dev/null +++ b/src/template/context-builder.js @@ -0,0 +1,51 @@ +/** + * Context builder - responsible for aggregating context from multiple sources + */ +import { logger } from '../utils/logger.js'; +import { PRExtractor } from './extractors/pr-extractor.js'; +import { CustomContextExtractor } from './extractors/custom-context-extractor.js'; +export class ContextBuilder { + prExtractor; + customContextExtractor; + constructor(prExtractor, customContextExtractor) { + this.prExtractor = prExtractor; + this.customContextExtractor = customContextExtractor; + } + static create(inputs) { + return new ContextBuilder(PRExtractor.create(inputs), CustomContextExtractor.create(inputs)); + } + async buildContext(inputs) { + try { + logger.debug('Building template context from inputs'); + const context = {}; + // Extract PR data (extractor decides if it should run) + const prData = await this.prExtractor.extract(inputs); + if (prData) { + context.pr = prData; + logger.debug('PR data extracted and added to context', { + prNumber: prData.number, + title: prData.title, + }); + } + // Extract custom context if available + const customContext = await this.customContextExtractor.extract(inputs); + if (customContext) { + context.custom = customContext; + logger.debug('Custom context extracted and added', { + customContextKeys: Object.keys(customContext), + }); + } + logger.info('Template context built successfully', { + hasPR: !!context.pr, + hasCustom: !!context.custom, + customKeys: context.custom ? Object.keys(context.custom) : [], + }); + return context; + } + catch (error) { + logger.error('Failed to build template context', error); + throw error; + } + } +} +//# sourceMappingURL=context-builder.js.map \ No newline at end of file diff --git a/src/template/context-builder.js.map b/src/template/context-builder.js.map new file mode 100644 index 0000000..0c24a31 --- /dev/null +++ b/src/template/context-builder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"context-builder.js","sourceRoot":"","sources":["context-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAIlF,MAAM,OAAO,cAAc;IAEf;IACA;IAFV,YACU,WAAwB,EACxB,sBAA8C;QAD9C,gBAA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AI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;aAC9D,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/extractors/base-extractor.d.ts b/src/template/extractors/base-extractor.d.ts new file mode 100644 index 0000000..0e94f6d --- /dev/null +++ b/src/template/extractors/base-extractor.d.ts @@ -0,0 +1,26 @@ +/** + * Base extractor class that defines the common interface for all data extractors + */ +import type { ActionInputs } from '../../types/inputs.js'; +export declare abstract class BaseExtractor { + protected readonly extractorName: string; + constructor(extractorName: string); + /** + * Static factory method that each extractor must implement + * Creates an instance of the extractor configured for the given inputs + */ + static create(_inputs: ActionInputs): BaseExtractor; + /** + * Determines if extraction should be performed based on the action inputs + */ + abstract shouldExtract(inputs: ActionInputs): boolean; + /** + * Performs the actual data extraction + */ + protected abstract performExtraction(inputs: ActionInputs): Promise | TOutput; + /** + * Main extraction method that handles logging and error handling + */ + extract(inputs: ActionInputs): Promise; +} +//# sourceMappingURL=base-extractor.d.ts.map \ No newline at end of file diff --git a/src/template/extractors/base-extractor.d.ts.map b/src/template/extractors/base-extractor.d.ts.map new file mode 100644 index 0000000..a9c0468 --- /dev/null +++ b/src/template/extractors/base-extractor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"base-extractor.d.ts","sourceRoot":"","sources":["base-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,8BAAsB,aAAa,CAAC,OAAO;IACzC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;gBAE7B,aAAa,EAAE,MAAM;IAIjC;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC;IAIxD;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAErD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO;IAEtF;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;CAmBlE"} \ No newline at end of file diff --git a/src/template/extractors/base-extractor.js b/src/template/extractors/base-extractor.js new file mode 100644 index 0000000..d517aac --- /dev/null +++ b/src/template/extractors/base-extractor.js @@ -0,0 +1,39 @@ +/** + * Base extractor class that defines the common interface for all data extractors + */ +import { logger } from '../../utils/logger.js'; +export class BaseExtractor { + extractorName; + constructor(extractorName) { + this.extractorName = extractorName; + } + /** + * Static factory method that each extractor must implement + * Creates an instance of the extractor configured for the given inputs + */ + static create(_inputs) { + throw new Error('Subclasses must implement the static create method'); + } + /** + * Main extraction method that handles logging and error handling + */ + async extract(inputs) { + try { + if (!this.shouldExtract(inputs)) { + logger.debug(`${this.extractorName} extraction skipped`, { + reason: 'shouldExtract returned false', + }); + return undefined; + } + logger.debug(`Starting ${this.extractorName} extraction`); + const result = await this.performExtraction(inputs); + logger.debug(`${this.extractorName} extraction completed successfully`); + return result; + } + catch (error) { + logger.error(`${this.extractorName} extraction failed`, error); + throw error; + } + } +} +//# sourceMappingURL=base-extractor.js.map \ No newline at end of file diff --git a/src/template/extractors/base-extractor.js.map b/src/template/extractors/base-extractor.js.map new file mode 100644 index 0000000..cfbf4a2 --- /dev/null +++ b/src/template/extractors/base-extractor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base-extractor.js","sourceRoot":"","sources":["base-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/C,MAAM,OAAgB,aAAa;IACd,aAAa,CAAS;IAEzC,YAAY,aAAqB;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,OAAqB;QACjC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAYD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAAoB;QAChC,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,aAAa,qBAAqB,EAAE;oBACvD,MAAM,EAAE,8BAA8B;iBACvC,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,aAAa,aAAa,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAEpD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,aAAa,oCAAoC,CAAC,CAAC;YACxE,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,aAAa,oBAAoB,EAAE,KAAK,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.d.ts b/src/template/extractors/custom-context-extractor.d.ts new file mode 100644 index 0000000..f2f390f --- /dev/null +++ b/src/template/extractors/custom-context-extractor.d.ts @@ -0,0 +1,21 @@ +/** + * Custom context extractor - handles parsing JSON strings into context objects + */ +import { BaseExtractor } from './base-extractor.js'; +import type { ActionInputs } from '../../types/inputs.js'; +export declare class CustomContextExtractor extends BaseExtractor> { + constructor(); + /** + * Creates a CustomContextExtractor instance + */ + static create(_inputs: ActionInputs): CustomContextExtractor; + /** + * Determines if custom context extraction should be performed + */ + shouldExtract(inputs: ActionInputs): boolean; + /** + * Performs custom context extraction by parsing JSON string + */ + protected performExtraction(inputs: ActionInputs): Record; +} +//# sourceMappingURL=custom-context-extractor.d.ts.map \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.d.ts.map b/src/template/extractors/custom-context-extractor.d.ts.map new file mode 100644 index 0000000..286f50c --- /dev/null +++ b/src/template/extractors/custom-context-extractor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"custom-context-extractor.d.ts","sourceRoot":"","sources":["custom-context-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;IAK5E;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,sBAAsB;IAI5D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAI5C;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAuBvE"} \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.js b/src/template/extractors/custom-context-extractor.js new file mode 100644 index 0000000..f3c5b74 --- /dev/null +++ b/src/template/extractors/custom-context-extractor.js @@ -0,0 +1,46 @@ +/** + * Custom context extractor - handles parsing JSON strings into context objects + */ +import { BaseExtractor } from './base-extractor.js'; +import { logger } from '../../utils/logger.js'; +import { ERROR } from '../../config/constants.js'; +export class CustomContextExtractor extends BaseExtractor { + constructor() { + super('Custom Context'); + } + /** + * Creates a CustomContextExtractor instance + */ + static create(_inputs) { + return new CustomContextExtractor(); + } + /** + * Determines if custom context extraction should be performed + */ + shouldExtract(inputs) { + return !!(inputs.customContext && inputs.customContext.trim().length > 0); + } + /** + * Performs custom context extraction by parsing JSON string + */ + performExtraction(inputs) { + const jsonString = inputs.customContext; + try { + const parsed = JSON.parse(jsonString); + if (typeof parsed !== 'object' || parsed === null) { + throw new Error('Parsed JSON must be an object'); + } + logger.debug('Custom context parsed successfully', { + keys: Object.keys(parsed), + keyCount: Object.keys(parsed).length, + }); + return parsed; + } + catch (error) { + const message = `${ERROR.INPUT.INVALID_CONTEXT_JSON}: ${error instanceof Error ? error.message : String(error)}`; + logger.error('Failed to parse custom context JSON', error); + throw new Error(message); + } + } +} +//# sourceMappingURL=custom-context-extractor.js.map \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.js.map b/src/template/extractors/custom-context-extractor.js.map new file mode 100644 index 0000000..3749453 --- /dev/null +++ b/src/template/extractors/custom-context-extractor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"custom-context-extractor.js","sourceRoot":"","sources":["custom-context-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,MAAM,OAAO,sBAAuB,SAAQ,aAAkC;IAC5E;QACE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAqB;QACjC,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,MAAoB;QAChC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,MAAoB;QAC9C,MAAM,UAAU,GAAG,MAAM,CAAC,aAAc,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAEtC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACnD,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE;gBACjD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;gBACzB,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM;aACrC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,KACjD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.d.ts b/src/template/extractors/pr-extractor.d.ts new file mode 100644 index 0000000..eb02673 --- /dev/null +++ b/src/template/extractors/pr-extractor.d.ts @@ -0,0 +1,25 @@ +/** + * PR data extractor - responsible for extracting and formatting PR data from GitHub API + */ +import { BaseExtractor } from './base-extractor.js'; +import { GitHubService } from '../../services/github-service.js'; +import type { PRData } from '../../types/context.js'; +import type { ActionInputs } from '../../types/inputs.js'; +export declare class PRExtractor extends BaseExtractor { + private githubService?; + constructor(githubService?: GitHubService | undefined); + /** + * Creates a PRExtractor instance configured for the given inputs + */ + static create(inputs: ActionInputs): PRExtractor; + /** + * Determines if PR extraction should be performed + */ + shouldExtract(inputs: ActionInputs): boolean; + /** + * Performs the actual PR data extraction + */ + protected performExtraction(inputs: ActionInputs): Promise; + private writeDiffFile; +} +//# sourceMappingURL=pr-extractor.d.ts.map \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.d.ts.map b/src/template/extractors/pr-extractor.d.ts.map new file mode 100644 index 0000000..c5abeff --- /dev/null +++ b/src/template/extractors/pr-extractor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"pr-extractor.d.ts","sourceRoot":"","sources":["pr-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAMjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,WAAY,SAAQ,aAAa,CAAC,MAAM,CAAC;IACxC,OAAO,CAAC,aAAa,CAAC;gBAAd,aAAa,CAAC,EAAE,aAAa,YAAA;IAIjD;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IA4BhD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAI5C;;OAEG;cACa,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;YAmD1D,aAAa;CAwB5B"} \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.js b/src/template/extractors/pr-extractor.js new file mode 100644 index 0000000..de77fd6 --- /dev/null +++ b/src/template/extractors/pr-extractor.js @@ -0,0 +1,123 @@ +/** + * PR data extractor - responsible for extracting and formatting PR data from GitHub API + */ +import { join } from 'node:path'; +import { BaseExtractor } from './base-extractor.js'; +import { GitHubService } from '../../services/github-service.js'; +import { FileUtils } from '../../utils/file-utils.js'; +import { logger } from '../../utils/logger.js'; +import { ValidationUtils } from '../../utils/validation.js'; +import { PATHS } from '../../config/constants.js'; +export class PRExtractor extends BaseExtractor { + githubService; + constructor(githubService) { + super('PR Data'); + this.githubService = githubService; + } + /** + * Creates a PRExtractor instance configured for the given inputs + */ + static create(inputs) { + // If we have complete repo information, create with pre-configured GitHub service + if (inputs.repoName && inputs.githubToken) { + try { + const repoInfo = ValidationUtils.parseRepoName(inputs.repoName); + const githubService = new GitHubService({ + token: inputs.githubToken, + owner: repoInfo.owner, + repo: repoInfo.repo, + }); + logger.debug('PRExtractor created with pre-configured GitHubService', { + owner: repoInfo.owner, + repo: repoInfo.repo, + }); + return new PRExtractor(githubService); + } + catch (error) { + logger.debug('Failed to create pre-configured GitHubService, will create lazily', { + error: error instanceof Error ? error.message : 'Unknown error', + }); + // Fall through to create without GitHubService + } + } + // Create without GitHubService for lazy configuration + logger.debug('PRExtractor created without GitHubService (will be created lazily)'); + return new PRExtractor(); + } + /** + * Determines if PR extraction should be performed + */ + shouldExtract(inputs) { + return !!(inputs.pullNumber && inputs.pullNumber > 0 && inputs.repoName && inputs.githubToken); + } + /** + * Performs the actual PR data extraction + */ + async performExtraction(inputs) { + const pullNumber = inputs.pullNumber; + // Get or create GitHubService lazily + const githubService = this.githubService; + if (!githubService) { + throw new Error('GitHubService not provided'); + } + const prData = await githubService.getPullRequest(pullNumber); + const files = await githubService.getPullRequestFiles(pullNumber); + const diffFilePath = await this.writeDiffFile(pullNumber, githubService); + const extractedData = { + number: prData.number, + title: prData.title, + author: prData.user.login, + head: { + ref: prData.head.ref, + sha: prData.head.sha, + repo: { + full_name: prData.head.repo.full_name, + name: prData.head.repo.name, + owner: prData.head.repo.owner.login, + }, + }, + base: { + ref: prData.base.ref, + sha: prData.base.sha, + repo: { + full_name: prData.base.repo.full_name, + name: prData.base.repo.name, + owner: prData.base.repo.owner.login, + }, + }, + body: prData.body || '', + state: prData.state, + changed_files: files.map(file => file.filename).join('\n'), + changed_files_list: files, + diff_file: diffFilePath, + }; + logger.info('PR data extraction completed', { + pullNumber, + fileCount: files.length, + diffFile: diffFilePath, + }); + return extractedData; + } + async writeDiffFile(pullNumber, githubService) { + try { + const diff = await githubService.getPullRequestDiff(pullNumber); + if (diff.truncated) { + logger.warning('PR diff was truncated due to size', { + originalSize: diff.size, + truncated: diff.truncated, + }); + } + const diffFileName = PATHS.DIFF_FILE_PATTERN.replace('{pullNumber}', pullNumber.toString()); + const diffFilePath = join(PATHS.TEMP_DIR, diffFileName); + await FileUtils.ensureDirectoryExists(PATHS.TEMP_DIR); + await FileUtils.writeFile(diffFilePath, diff.content); + logger.debug('Diff file written', { diffFilePath, size: diff.size }); + return diffFilePath; + } + catch (error) { + logger.error('Failed to write diff file', error); + throw error; + } + } +} +//# sourceMappingURL=pr-extractor.js.map \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.js.map b/src/template/extractors/pr-extractor.js.map new file mode 100644 index 0000000..eb173e9 --- /dev/null +++ b/src/template/extractors/pr-extractor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pr-extractor.js","sourceRoot":"","sources":["pr-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAKlD,MAAM,OAAO,WAAY,SAAQ,aAAqB;IAChC;IAApB,YAAoB,aAA6B;QAC/C,KAAK,CAAC,SAAS,CAAC,CAAC;Q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IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACrE,OAAO,YAAY,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;YACjD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/template-engine.d.ts b/src/template/template-engine.d.ts new file mode 100644 index 0000000..2307a73 --- /dev/null +++ b/src/template/template-engine.d.ts @@ -0,0 +1,20 @@ +/** + * Template engine for rendering Nunjucks templates + */ +import type { TemplateContext } from '../types/context.js'; +import { ActionInputs } from '../types/inputs.js'; +export declare class TemplateEngine { + private env; + private templateDirectory; + constructor(templateDirectory: string); + static create(inputs: ActionInputs): TemplateEngine; + renderTemplate(templateName: string, context: TemplateContext): Promise; + private resolveFilePath; + maybeReadFile(filePath: string): string; + formatFiles(files: Array<{ + filename: string; + status: string; + }>): string; + private setupCustomFilters; +} +//# sourceMappingURL=template-engine.d.ts.map \ No newline at end of file diff --git a/src/template/template-engine.d.ts.map b/src/template/template-engine.d.ts.map new file mode 100644 index 0000000..aaf4eec --- /dev/null +++ b/src/template/template-engine.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"template-engine.d.ts","sourceRoot":"","sources":["template-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,iBAAiB,EAAE,MAAM;IAgBrC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc;IAI7C,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBrF,OAAO,CAAC,eAAe;IAyBvB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IA8BvC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,MAAM;IAOvE,OAAO,CAAC,kBAAkB;CAK3B"} \ No newline at end of file diff --git a/src/template/template-engine.js b/src/template/template-engine.js new file mode 100644 index 0000000..4e09ca7 --- /dev/null +++ b/src/template/template-engine.js @@ -0,0 +1,108 @@ +/** + * Template engine for rendering Nunjucks templates + */ +import * as nunjucks from 'nunjucks'; +import { resolve } from 'node:path'; +import { FileUtils } from '../utils/file-utils.js'; +import { logger } from '../utils/logger.js'; +import { ERROR, PATHS } from '../config/constants.js'; +export class TemplateEngine { + env; + templateDirectory; + constructor(templateDirectory) { + this.templateDirectory = resolve(templateDirectory); + // Configure Nunjucks environment + this.env = nunjucks.configure(this.templateDirectory, { + autoescape: false, + throwOnUndefined: true, + trimBlocks: true, + lstripBlocks: true, + noCache: true, // Ensure fresh reads in CI environment + }); + this.setupCustomFilters(); + logger.debug(`Template engine initialized with directory: ${this.templateDirectory}`); + } + static create(inputs) { + return new TemplateEngine(inputs.templateDirectory); + } + async renderTemplate(templateName, context) { + try { + // Validate template file exists and is safe + await FileUtils.validateTemplateFile(this.templateDirectory, templateName); + logger.debug(`Rendering template: ${templateName}`, { contextKeys: Object.keys(context) }); + // Render template + const rendered = this.env.render(templateName, context); + logger.info(`Template rendered successfully`, { + templateName, + contentLength: rendered.length, + }); + return rendered; + } + catch (error) { + const message = `${ERROR.TEMPLATE.RENDER_ERROR}: ${error instanceof Error ? error.message : String(error)}`; + logger.error(message, error); + throw new Error(message); + } + } + resolveFilePath(filePath) { + const fs = require('fs'); + // Try using the path as absolute if it's within allowed directories + const absolutePath = resolve(filePath); + if ((absolutePath.startsWith(this.templateDirectory) || + absolutePath.startsWith(PATHS.TEMP_DIR)) && + fs.existsSync(absolutePath)) { + return absolutePath; + } + // Try resolving relative to template directory + const templatePath = resolve(this.templateDirectory, filePath); + if (templatePath.startsWith(this.templateDirectory) && fs.existsSync(templatePath)) { + return templatePath; + } + // Try resolving relative to tmp directory + const tmpPath = resolve(PATHS.TEMP_DIR, filePath); + if (tmpPath.startsWith(PATHS.TEMP_DIR) && fs.existsSync(tmpPath)) { + return tmpPath; + } + return undefined; + } + maybeReadFile(filePath) { + try { + if (!filePath) { + logger.warning('Empty file path provided to maybe_read_file filter'); + return ''; + } + const resolvedPath = this.resolveFilePath(filePath); + if (!resolvedPath) { + logger.warning(`File path ${filePath} not found in allowed directories (template: ${this.templateDirectory}, tmp: ${PATHS.TEMP_DIR})`); + return filePath; // Return original path as fallback + } + const fs = require('fs'); + // Synchronous read for template rendering + const content = fs.readFileSync(resolvedPath, 'utf8'); + logger.debug('File read successfully via filter', { + originalPath: filePath, + resolvedPath: resolvedPath, + contentLength: content.length, + }); + return content; + } + catch (_error) { + logger.warning('Failed to read file via filter, returning original path', { + filePath, + }); + return filePath; // Return original path as fallback + } + } + formatFiles(files) { + if (!Array.isArray(files) || files.length === 0) { + return 'No files changed'; + } + return files.map(file => `${file.status.toUpperCase()}: ${file.filename}`).join('\n'); + } + setupCustomFilters() { + this.env.addFilter('maybe_read_file', this.maybeReadFile.bind(this)); + this.env.addFilter('format_files', this.formatFiles.bind(this)); + logger.debug('Custom filters setup complete'); + } +} +//# sourceMappingURL=template-engine.js.map \ No newline at end of file diff --git a/src/template/template-engine.js.map b/src/template/template-engine.js.map new file mode 100644 index 0000000..5d0e302 --- /dev/null +++ b/src/template/template-engine.js.map @@ -0,0 +1 @@ +{"version":3,"file":"template-engine.js","sourceRoot":"","sources":["template-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,E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O,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxF,CAAC;IAEO,kBAAkB;QACxB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChE,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAChD,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/template-processor.d.ts b/src/template/template-processor.d.ts new file mode 100644 index 0000000..2594385 --- /dev/null +++ b/src/template/template-processor.d.ts @@ -0,0 +1,15 @@ +/** + * Template processor - orchestrates the entire template processing pipeline + */ +import { TemplateEngine } from './template-engine.js'; +import { ContextBuilder } from './context-builder.js'; +import type { ActionInputs } from '../types/inputs.js'; +export declare class TemplateProcessor { + private templateEngine; + private contextBuilder; + constructor(templateEngine: TemplateEngine, contextBuilder: ContextBuilder); + static create(inputs: ActionInputs): TemplateProcessor; + processTemplate(inputs: ActionInputs): Promise; + private writeInstructionFile; +} +//# sourceMappingURL=template-processor.d.ts.map \ No newline at end of file diff --git a/src/template/template-processor.d.ts.map b/src/template/template-processor.d.ts.map new file mode 100644 index 0000000..367a52f --- /dev/null +++ b/src/template/template-processor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"template-processor.d.ts","sourceRoot":"","sources":["template-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;gBADd,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc;IAGxC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,iBAAiB;IAIhD,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;YAuB9C,oBAAoB;CAgBnC"} \ No newline at end of file diff --git a/src/template/template-processor.js b/src/template/template-processor.js new file mode 100644 index 0000000..a375894 --- /dev/null +++ b/src/template/template-processor.js @@ -0,0 +1,55 @@ +/** + * Template processor - orchestrates the entire template processing pipeline + */ +import { TemplateEngine } from './template-engine.js'; +import { ContextBuilder } from './context-builder.js'; +import { FileUtils } from '../utils/file-utils.js'; +import { logger } from '../utils/logger.js'; +import { PATHS } from '../config/constants.js'; +export class TemplateProcessor { + templateEngine; + contextBuilder; + constructor(templateEngine, contextBuilder) { + this.templateEngine = templateEngine; + this.contextBuilder = contextBuilder; + } + static create(inputs) { + return new TemplateProcessor(TemplateEngine.create(inputs), ContextBuilder.create(inputs)); + } + async processTemplate(inputs) { + try { + logger.info('Starting template processing pipeline', { + templateDirectory: inputs.templateDirectory, + templateName: inputs.templateName, + }); + const context = await this.contextBuilder.buildContext(inputs); + const content = await this.templateEngine.renderTemplate(inputs.templateName, context); + const instructionFilePath = await this.writeInstructionFile(content); + logger.info('Template processing pipeline completed', { + instructionFile: instructionFilePath, + contentLength: content.length, + }); + return instructionFilePath; + } + catch (error) { + logger.error('Template processing pipeline failed', error); + throw error; + } + } + async writeInstructionFile(content) { + try { + await FileUtils.ensureDirectoryExists(PATHS.TEMP_DIR); + await FileUtils.writeFile(PATHS.INSTRUCTION_FILE, content); + logger.info('Instruction file written', { + filePath: PATHS.INSTRUCTION_FILE, + contentLength: content.length, + }); + return PATHS.INSTRUCTION_FILE; + } + catch (error) { + logger.error('Failed to write instruction file', error); + throw error; + } + } +} +//# sourceMappingURL=template-processor.js.map \ No newline at end of file diff --git a/src/template/template-processor.js.map b/src/template/template-processor.js.map new file mode 100644 index 0000000..ff16ac1 --- /dev/null +++ b/src/template/template-processor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"template-processor.js","sourceRoot":"","sources":["template-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C,MAAM,OAAO,iBAAiB;IAElB;IACA;IAFV,YACU,cAA8B,EAC9B,cAA8B;QAD9B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAEJ,MAAM,CAAC,MAAM,CAAC,MAAoB;QAChC,OAAO,IAAI,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAAoB;QACxC,IAAI,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,uCAAuC,EAAE;gBACnD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;aAClC,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC/D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,YAAa,EAAE,OAAO,CAAC,CAAC;YACxF,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAErE,MAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE;gBACpD,eAAe,EAAE,mBAAmB;gBACpC,aAAa,EAAE,OAAO,CAAC,MAAM;aAC9B,CAAC,CAAC;YAEH,OAAO,mBAAmB,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,OAAe;QAChD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACtD,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;YAE3D,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;gBACtC,QAAQ,EAAE,KAAK,CAAC,gBAAgB;gBAChC,aAAa,EAAE,OAAO,CAAC,MAAM;aAC9B,CAAC,CAAC;YAEH,OAAO,KAAK,CAAC,gBAAgB,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/types/context.d.ts b/src/types/context.d.ts new file mode 100644 index 0000000..86fa7c9 --- /dev/null +++ b/src/types/context.d.ts @@ -0,0 +1,31 @@ +/** + * Context-related type definitions + */ +import { PullRequestFile } from './github'; +export interface GithubRepo { + full_name: string; + name: string; + owner: string; +} +export interface GitRef { + ref: string; + sha: string; + repo: GithubRepo; +} +export interface PRData { + number: number; + title: string; + author: string; + head: GitRef; + base: GitRef; + body: string; + state: string; + changed_files: string; + changed_files_list: Array; + diff_file: string; +} +export interface TemplateContext { + pr?: PRData; + custom?: Record; +} +//# sourceMappingURL=context.d.ts.map \ No newline at end of file diff --git a/src/types/context.d.ts.map b/src/types/context.d.ts.map new file mode 100644 index 0000000..eef6e98 --- /dev/null +++ b/src/types/context.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAE9B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B"} \ No newline at end of file diff --git a/src/types/context.js b/src/types/context.js new file mode 100644 index 0000000..ed6e91f --- /dev/null +++ b/src/types/context.js @@ -0,0 +1,5 @@ +/** + * Context-related type definitions + */ +export {}; +//# sourceMappingURL=context.js.map \ No newline at end of file diff --git a/src/types/context.js.map b/src/types/context.js.map new file mode 100644 index 0000000..3b5f80e --- /dev/null +++ b/src/types/context.js.map @@ -0,0 +1 @@ +{"version":3,"file":"context.js","sourceRoot":"","sources":["context.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/src/types/github.d.ts b/src/types/github.d.ts new file mode 100644 index 0000000..b10a190 --- /dev/null +++ b/src/types/github.d.ts @@ -0,0 +1,47 @@ +/** + * GitHub API types for PR information extraction + */ +export interface PullRequestInfo { + number: number; + title: string; + body: string | null; + state: string; + user: { + login: string; + }; + head: { + ref: string; + sha: string; + repo: { + full_name: string; + name: string; + owner: { + login: string; + }; + }; + }; + base: { + ref: string; + sha: string; + repo: { + full_name: string; + name: string; + owner: { + login: string; + }; + }; + }; +} +export interface PullRequestFile { + filename: string; + status: string; + additions: number; + deletions: number; + changes: number; +} +export interface PullRequestDiff { + content: string; + size: number; + truncated: boolean; +} +//# sourceMappingURL=github.d.ts.map \ No newline at end of file diff --git a/src/types/github.d.ts.map b/src/types/github.d.ts.map new file mode 100644 index 0000000..58ed437 --- /dev/null +++ b/src/types/github.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["github.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE;YACJ,SAAS,EAAE,MAAM,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE;gBACL,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;KACH,CAAC;IACF,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE;YACJ,SAAS,EAAE,MAAM,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE;gBACL,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB"} \ No newline at end of file diff --git a/src/types/github.js b/src/types/github.js new file mode 100644 index 0000000..89ceae2 --- /dev/null +++ b/src/types/github.js @@ -0,0 +1,5 @@ +/** + * GitHub API types for PR information extraction + */ +export {}; +//# sourceMappingURL=github.js.map \ No newline at end of file diff --git a/src/types/github.js.map b/src/types/github.js.map new file mode 100644 index 0000000..8b065b9 --- /dev/null +++ b/src/types/github.js.map @@ -0,0 +1 @@ +{"version":3,"file":"github.js","sourceRoot":"","sources":["github.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/src/types/inputs.d.ts b/src/types/inputs.d.ts new file mode 100644 index 0000000..0100023 --- /dev/null +++ b/src/types/inputs.d.ts @@ -0,0 +1,29 @@ +/** + * Action input types for the Augment Agent with template support + */ +export interface InputField { + envVar: string; + required: boolean; + transform?: (value: string) => any; +} +export interface ActionInputs { + augmentSessionAuth?: string | undefined; + augmentApiToken?: string | undefined; + augmentApiUrl?: string | undefined; + githubToken?: string | undefined; + instruction?: string | undefined; + instructionFile?: string | undefined; + model?: string | undefined; + templateDirectory?: string | undefined; + templateName?: string | undefined; + customContext?: string | undefined; + pullNumber?: number | undefined; + repoName?: string | undefined; + rules?: string[] | undefined; + mcpConfigs?: string[] | undefined; +} +export interface RepoInfo { + owner: string; + repo: string; +} +//# sourceMappingURL=inputs.d.ts.map \ No newline at end of file diff --git a/src/types/inputs.d.ts.map b/src/types/inputs.d.ts.map new file mode 100644 index 0000000..5c02f2f --- /dev/null +++ b/src/types/inputs.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["inputs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAE3B,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAG3B,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAG9B,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"} \ No newline at end of file diff --git a/src/types/inputs.js b/src/types/inputs.js new file mode 100644 index 0000000..4d07951 --- /dev/null +++ b/src/types/inputs.js @@ -0,0 +1,5 @@ +/** + * Action input types for the Augment Agent with template support + */ +export {}; +//# sourceMappingURL=inputs.js.map \ No newline at end of file diff --git a/src/types/inputs.js.map b/src/types/inputs.js.map new file mode 100644 index 0000000..3d562f4 --- /dev/null +++ b/src/types/inputs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"inputs.js","sourceRoot":"","sources":["inputs.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/src/utils/file-utils.d.ts b/src/utils/file-utils.d.ts new file mode 100644 index 0000000..af8da4e --- /dev/null +++ b/src/utils/file-utils.d.ts @@ -0,0 +1,10 @@ +/** + * File system utilities + */ +export declare class FileUtils { + static writeFile(filePath: string, content: string): Promise; + static readFile(filePath: string): Promise; + static validateTemplateFile(templateDir: string, templateName: string): Promise; + static ensureDirectoryExists(dirPath: string): Promise; +} +//# sourceMappingURL=file-utils.d.ts.map \ No newline at end of file diff --git a/src/utils/file-utils.d.ts.map b/src/utils/file-utils.d.ts.map new file mode 100644 index 0000000..e71f932 --- /dev/null +++ b/src/utils/file-utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["file-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,qBAAa,SAAS;WACP,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAW3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAY3C,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAwChF,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcnE"} \ No newline at end of file diff --git a/src/utils/file-utils.js b/src/utils/file-utils.js new file mode 100644 index 0000000..1f4b79b --- /dev/null +++ b/src/utils/file-utils.js @@ -0,0 +1,83 @@ +/** + * File system utilities + */ +import { promises as fs } from 'node:fs'; +import { resolve } from 'node:path'; +import { TEMPLATE_CONFIG, ERROR } from '../config/constants.js'; +import { logger } from './logger.js'; +export class FileUtils { + static async writeFile(filePath, content) { + try { + logger.debug('Writing file', { filePath, contentLength: content.length }); + await fs.writeFile(filePath, content, 'utf8'); + logger.debug('File written successfully', { filePath }); + } + catch (error) { + logger.error('Failed to write file', error, { filePath }); + throw error; + } + } + static async readFile(filePath) { + try { + logger.debug('Reading file', { filePath }); + const content = await fs.readFile(filePath, 'utf8'); + logger.debug('File read successfully', { filePath, contentLength: content.length }); + return content; + } + catch (error) { + logger.error('Failed to read file', error, { filePath }); + throw error; + } + } + static async validateTemplateFile(templateDir, templateName) { + logger.debug('Validating template file', { templateDir, templateName }); + const templatePath = resolve(templateDir, templateName); + // Security check - ensure template is within template directory + if (!templatePath.startsWith(resolve(templateDir))) { + const message = `${ERROR.TEMPLATE.PATH_OUTSIDE_DIRECTORY}: ${templateName}`; + logger.error(message, undefined, { templateDir, templateName, templatePath }); + throw new Error(message); + } + try { + await fs.access(templatePath); + logger.debug('Template file exists', { templatePath }); + } + catch (error) { + const message = `${ERROR.TEMPLATE.NOT_FOUND}: ${templatePath}`; + logger.error(message, error, { templateDir, templateName, templatePath }); + throw new Error(message); + } + // Check file size + const stats = await fs.stat(templatePath); + if (stats.size > TEMPLATE_CONFIG.MAX_TEMPLATE_SIZE) { + const message = `${ERROR.TEMPLATE.TOO_LARGE}: ${stats.size} bytes`; + logger.error(message, undefined, { + templatePath, + fileSize: stats.size, + maxSize: TEMPLATE_CONFIG.MAX_TEMPLATE_SIZE, + }); + throw new Error(message); + } + logger.debug('Template file validation successful', { + templatePath, + fileSize: stats.size, + }); + return templatePath; + } + static async ensureDirectoryExists(dirPath) { + try { + logger.debug('Ensuring directory exists', { dirPath }); + await fs.mkdir(dirPath, { recursive: true }); + logger.debug('Directory ensured', { dirPath }); + } + catch (error) { + // Ignore error if directory already exists + if (error.code !== 'EEXIST') { + logger.error('Failed to create directory', error, { dirPath }); + throw error; + } + logger.debug('Directory already exists', { dirPath }); + } + } +} +//# sourceMappingURL=file-utils.js.map \ No newline at end of file diff --git a/src/utils/file-utils.js.map b/src/utils/file-utils.js.map new file mode 100644 index 0000000..37bafa4 --- /dev/null +++ b/src/utils/file-utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["file-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,SAAS;IACpB,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,OAAe;QACtD,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1E,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAC9C,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC1D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CA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AAC,OAAO,KAAK,EAAE,CAAC;YACf,2CAA2C;YAC3C,IAAK,KAAa,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBAC/D,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/utils/logger.d.ts b/src/utils/logger.d.ts new file mode 100644 index 0000000..1d9048a --- /dev/null +++ b/src/utils/logger.d.ts @@ -0,0 +1,39 @@ +/** + * Logging utilities for the Augment Agent + */ +/** + * Structured logger for GitHub Actions + */ +export declare class Logger { + private context; + constructor(context?: string); + /** + * Log debug information + */ + debug(message: string, data?: Record): void; + /** + * Log informational message + */ + info(message: string, data?: Record): void; + /** + * Log warning message + */ + warning(message: string, data?: Record): void; + /** + * Log error message + */ + error(message: string, error?: Error | unknown, data?: Record): void; + /** + * Set a failed status with error message + */ + setFailed(message: string, error?: Error | unknown): void; + /** + * Format log message with context and optional data + */ + private formatMessage; +} +/** + * Default logger instance + */ +export declare const logger: Logger; +//# sourceMappingURL=logger.d.ts.map \ No newline at end of file diff --git a/src/utils/logger.d.ts.map b/src/utils/logger.d.ts.map new file mode 100644 index 0000000..db078eb --- /dev/null +++ b/src/utils/logger.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,GAAE,MAA2B;IAIhD;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK5D;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK3D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK9D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAUrF;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI;IAUzD;;OAEG;IACH,OAAO,CAAC,aAAa;CAUtB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC"} \ No newline at end of file diff --git a/src/utils/logger.js b/src/utils/logger.js new file mode 100644 index 0000000..fb592e0 --- /dev/null +++ b/src/utils/logger.js @@ -0,0 +1,74 @@ +/** + * Logging utilities for the Augment Agent + */ +import * as core from '@actions/core'; +import { ACTION_CONFIG } from '../config/constants.js'; +/** + * Structured logger for GitHub Actions + */ +export class Logger { + context; + constructor(context = ACTION_CONFIG.NAME) { + this.context = context; + } + /** + * Log debug information + */ + debug(message, data) { + const logMessage = this.formatMessage(message, data); + core.debug(logMessage); + } + /** + * Log informational message + */ + info(message, data) { + const logMessage = this.formatMessage(message, data); + core.info(logMessage); + } + /** + * Log warning message + */ + warning(message, data) { + const logMessage = this.formatMessage(message, data); + core.warning(logMessage); + } + /** + * Log error message + */ + error(message, error, data) { + const errorData = error instanceof Error + ? { error: error.message, stack: error.stack, ...data } + : { error: String(error), ...data }; + const logMessage = this.formatMessage(message, errorData); + core.error(logMessage); + } + /** + * Set a failed status with error message + */ + setFailed(message, error) { + if (error instanceof Error) { + this.error(message, error); + core.setFailed(`${message}: ${error.message}`); + } + else { + this.error(message, error); + core.setFailed(message); + } + } + /** + * Format log message with context and optional data + */ + formatMessage(message, data) { + const timestamp = new Date().toISOString(); + let formattedMessage = `[${timestamp}] [${this.context}] ${message}`; + if (data && Object.keys(data).length > 0) { + formattedMessage += ` | Data: ${JSON.stringify(data, null, 2)}`; + } + return formattedMessage; + } +} +/** + * Default logger instance + */ +export const logger = new Logger(); +//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/src/utils/logger.js.map b/src/utils/logger.js.map new file mode 100644 index 0000000..c008773 --- /dev/null +++ b/src/utils/logger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,MAAM;IACT,OAAO,CAAS;IAExB,YAAY,UAAkB,aAAa,CAAC,IAAI;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,IAA8B;QACnD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,IAA8B;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,OAAe,EAAE,IAA8B;QACrD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,CAAC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E,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAClE,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC"} \ No newline at end of file diff --git a/src/utils/validation.d.ts b/src/utils/validation.d.ts new file mode 100644 index 0000000..e01382c --- /dev/null +++ b/src/utils/validation.d.ts @@ -0,0 +1,18 @@ +/** + * Input validation utilities + */ +import type { ActionInputs, RepoInfo } from '../types/inputs.js'; +/** + * Validation utilities + */ +export declare class ValidationUtils { + /** + * Validate action inputs from environment variables + */ + static validateInputs(): ActionInputs; + /** + * Parse repository name into owner and repo + */ + static parseRepoName(repoName: string): RepoInfo; +} +//# sourceMappingURL=validation.d.ts.map \ No newline at end of file diff --git a/src/utils/validation.d.ts.map b/src/utils/validation.d.ts.map new file mode 100644 index 0000000..54e93f9 --- /dev/null +++ b/src/utils/validation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AA0KjE;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,YAAY;IAwCrC;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ;CAqBjD"} \ No newline at end of file diff --git a/src/utils/validation.js b/src/utils/validation.js new file mode 100644 index 0000000..3f910e9 --- /dev/null +++ b/src/utils/validation.js @@ -0,0 +1,200 @@ +/** + * Input validation utilities + */ +import { z } from 'zod'; +import { logger } from './logger.js'; +import { ERROR, INPUT_FIELD_MAP } from '../config/constants.js'; +const createJsonStringArraySchema = (invalidTypeMessage, emptyEntryMessage) => z.preprocess(value => { + if (value === undefined || value === null) { + return undefined; + } + if (typeof value === 'string') { + const trimmed = value.trim(); + if (trimmed.length === 0) { + return undefined; + } + try { + return JSON.parse(trimmed); + } + catch { + return value; + } + } + return value; +}, z + .array(z + .string() + .transform(val => val.trim()) + .refine(val => val.length > 0, { message: emptyEntryMessage }), { invalid_type_error: invalidTypeMessage }) + .optional()); +/** + * Zod schema for action inputs validation + */ +const ActionInputsSchema = z + .object({ + augmentSessionAuth: z.string().optional(), + augmentApiToken: z.string().optional(), + augmentApiUrl: z.string().optional(), + githubToken: z.string().optional(), + instruction: z.string().optional(), + instructionFile: z.string().optional(), + model: z.string().optional(), + templateDirectory: z.string().optional(), + templateName: z.string().default('prompt.njk'), + customContext: z.string().optional(), + pullNumber: z.number().int().positive('Pull number must be a positive integer').optional(), + repoName: z + .string() + .regex(/^[^\/]+\/[^\/]+$/, ERROR.INPUT.REPO_FORMAT) + .optional(), + rules: createJsonStringArraySchema('rules must be a JSON array of strings', 'Rule file paths cannot be empty'), + mcpConfigs: createJsonStringArraySchema('mcp_configs must be a JSON array of strings', 'MCP config file paths cannot be empty'), +}) + .refine(data => { + const hasInstruction = data.instruction || data.instructionFile; + const hasTemplate = data.templateDirectory; + return hasInstruction || hasTemplate; +}, { + message: ERROR.INPUT.MISSING_INSTRUCTION_OR_TEMPLATE, + path: ['instruction', 'instructionFile', 'templateDirectory'], +}) + .refine(data => { + const hasInstruction = data.instruction || data.instructionFile; + const hasTemplate = data.templateDirectory; + return !(hasInstruction && hasTemplate); +}, { + message: ERROR.INPUT.CONFLICTING_INSTRUCTION_TEMPLATE, + path: ['instruction', 'instructionFile', 'templateDirectory'], +}) + .refine(data => !(data.instruction && data.instructionFile), { + message: ERROR.INPUT.CONFLICTING_INSTRUCTION_INPUTS, + path: ['instruction', 'instructionFile'], +}) + .refine(data => { + const hasPullNumber = data.pullNumber !== undefined; + const hasRepoName = data.repoName !== undefined; + return hasPullNumber === hasRepoName; +}, { + message: ERROR.INPUT.MISMATCHED_PR_FIELDS, + path: ['pullNumber', 'repoName'], +}) + .refine(data => { + if (!data.customContext) + return true; + try { + JSON.parse(data.customContext); + return true; + } + catch { + return false; + } +}, { + message: ERROR.INPUT.INVALID_CONTEXT_JSON, + path: ['customContext'], +}) + .refine(data => { + const hasSessionAuth = data.augmentSessionAuth; + const hasTokenAuth = data.augmentApiToken && data.augmentApiUrl; + return hasSessionAuth || hasTokenAuth; +}, { + message: 'Either augment_session_auth or both augment_api_token and augment_api_url must be provided', + path: ['augmentSessionAuth', 'augmentApiToken', 'augmentApiUrl'], +}) + .refine(data => { + const hasSessionAuth = data.augmentSessionAuth; + const hasTokenAuth = data.augmentApiToken || data.augmentApiUrl; + return !(hasSessionAuth && hasTokenAuth); +}, { + message: 'Cannot use both augment_session_auth and augment_api_token/augment_api_url simultaneously', + path: ['augmentSessionAuth', 'augmentApiToken', 'augmentApiUrl'], +}) + .refine(data => { + if (!data.augmentSessionAuth) + return true; + try { + JSON.parse(data.augmentSessionAuth); + return true; + } + catch { + return false; + } +}, { + message: 'augment_session_auth must be valid JSON', + path: ['augmentSessionAuth'], +}) + .refine(data => { + if (!data.augmentApiUrl) + return true; + try { + new URL(data.augmentApiUrl); + return true; + } + catch { + return false; + } +}, { + message: 'Augment API URL must be a valid URL', + path: ['augmentApiUrl'], +}); +/** + * Validation utilities + */ +export class ValidationUtils { + /** + * Validate action inputs from environment variables + */ + static validateInputs() { + try { + logger.debug('Reading action inputs from environment variables'); + // Build inputs object from field map + const inputs = Object.fromEntries(Object.entries(INPUT_FIELD_MAP) + .map(([key, fieldDef]) => { + const value = process.env[fieldDef.envVar]; + // Skip optional fields if no value set + if (!fieldDef.required && !value) { + return null; + } + // Apply transformation if defined + const transformedValue = fieldDef.transform && value ? fieldDef.transform(value) : value; + return [key, transformedValue]; + }) + .filter((entry) => entry !== null)); + logger.debug('Validating action inputs'); + const validated = ActionInputsSchema.parse(inputs); + logger.debug('Action inputs validated successfully'); + return validated; + } + catch (error) { + if (error instanceof z.ZodError) { + const errorMessages = error.errors.map(err => `${err.path.join('.')}: ${err.message}`); + const message = `${ERROR.INPUT.INVALID}: ${errorMessages.join(', ')}`; + logger.error(message, error); + throw new Error(message); + } + logger.error('Unexpected validation error', error); + throw error; + } + } + /** + * Parse repository name into owner and repo + */ + static parseRepoName(repoName) { + logger.debug('Parsing repository name', { repoName }); + const parts = repoName.split('/'); + if (parts.length !== 2) { + const message = `${ERROR.INPUT.REPO_FORMAT}: ${repoName}`; + logger.error(message); + throw new Error(message); + } + const [owner, repo] = parts; + if (!owner || !repo) { + const message = `${ERROR.INPUT.REPO_FORMAT}: ${repoName}. Owner and repo cannot be empty`; + logger.error(message); + throw new Error(message); + } + const result = { owner, repo }; + logger.debug('Repository name parsed successfully', result); + return result; + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/src/utils/validation.js.map b/src/utils/validation.js.map new file mode 100644 index 0000000..1d7f25b --- /dev/null +++ b/src/utils/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,2BAA2B,GAAG,CAAC,kBAA0B,EAAE,iBAAyB,EAAE,EAAE,CAC5F,CAAC,CAAC,UAAU,CACV,KAAK,CAAC,EAAE;IACN,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,O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,aAAa,CAAC,QAAgB;QACnC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEtD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC1D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QAED,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,KAAK,QAAQ,kCAAkC,CAAC;YAC1F,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QAED,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"} \ No newline at end of file From acf657cb99e573ee2ca730b4779e09045e4c8ce5 Mon Sep 17 00:00:00 2001 From: Justin Xu Date: Wed, 8 Oct 2025 20:42:35 +0000 Subject: [PATCH 2/3] Use tsx to run TypeScript directly, remove compiled files - Add tsx as dev dependency to run TypeScript without compilation - Update action.yml to use 'npx tsx' instead of 'node' - Add step to install action dependencies in action.yml - Remove all compiled .js, .d.ts, .js.map, .d.ts.map files from src/ - Add compiled files to .gitignore - Remove build script from package.json (no longer needed) This approach is cleaner as we don't need to commit compiled files. Note: Workflow files still need to be updated separately due to OAuth scope limitations. --- .gitignore | 6 + action.yml | 6 +- package-lock.json | 543 ++++++++++++++++++ package.json | 4 +- src/config/constants.d.ts | 40 -- src/config/constants.d.ts.map | 1 - src/config/constants.js | 58 -- src/config/constants.js.map | 1 - src/index.d.ts | 7 - src/index.d.ts.map | 1 - src/index.js | 157 ----- src/index.js.map | 1 - src/services/github-service.d.ts | 18 - src/services/github-service.d.ts.map | 1 - src/services/github-service.js | 135 ----- src/services/github-service.js.map | 1 - src/template/context-builder.d.ts | 15 - src/template/context-builder.d.ts.map | 1 - src/template/context-builder.js | 51 -- src/template/context-builder.js.map | 1 - src/template/extractors/base-extractor.d.ts | 26 - .../extractors/base-extractor.d.ts.map | 1 - src/template/extractors/base-extractor.js | 39 -- src/template/extractors/base-extractor.js.map | 1 - .../extractors/custom-context-extractor.d.ts | 21 - .../custom-context-extractor.d.ts.map | 1 - .../extractors/custom-context-extractor.js | 46 -- .../custom-context-extractor.js.map | 1 - src/template/extractors/pr-extractor.d.ts | 25 - src/template/extractors/pr-extractor.d.ts.map | 1 - src/template/extractors/pr-extractor.js | 123 ---- src/template/extractors/pr-extractor.js.map | 1 - src/template/template-engine.d.ts | 20 - src/template/template-engine.d.ts.map | 1 - src/template/template-engine.js | 108 ---- src/template/template-engine.js.map | 1 - src/template/template-processor.d.ts | 15 - src/template/template-processor.d.ts.map | 1 - src/template/template-processor.js | 55 -- src/template/template-processor.js.map | 1 - src/types/context.d.ts | 31 - src/types/context.d.ts.map | 1 - src/types/context.js | 5 - src/types/context.js.map | 1 - src/types/github.d.ts | 47 -- src/types/github.d.ts.map | 1 - src/types/github.js | 5 - src/types/github.js.map | 1 - src/types/inputs.d.ts | 29 - src/types/inputs.d.ts.map | 1 - src/types/inputs.js | 5 - src/types/inputs.js.map | 1 - src/utils/file-utils.d.ts | 10 - src/utils/file-utils.d.ts.map | 1 - src/utils/file-utils.js | 83 --- src/utils/file-utils.js.map | 1 - src/utils/logger.d.ts | 39 -- src/utils/logger.d.ts.map | 1 - src/utils/logger.js | 74 --- src/utils/logger.js.map | 1 - src/utils/validation.d.ts | 18 - src/utils/validation.d.ts.map | 1 - src/utils/validation.js | 200 ------- src/utils/validation.js.map | 1 - 64 files changed, 556 insertions(+), 1538 deletions(-) delete mode 100644 src/config/constants.d.ts delete mode 100644 src/config/constants.d.ts.map delete mode 100644 src/config/constants.js delete mode 100644 src/config/constants.js.map delete mode 100644 src/index.d.ts delete mode 100644 src/index.d.ts.map delete mode 100644 src/index.js delete mode 100644 src/index.js.map delete mode 100644 src/services/github-service.d.ts delete mode 100644 src/services/github-service.d.ts.map delete mode 100644 src/services/github-service.js delete mode 100644 src/services/github-service.js.map delete mode 100644 src/template/context-builder.d.ts delete mode 100644 src/template/context-builder.d.ts.map delete mode 100644 src/template/context-builder.js delete mode 100644 src/template/context-builder.js.map delete mode 100644 src/template/extractors/base-extractor.d.ts delete mode 100644 src/template/extractors/base-extractor.d.ts.map delete mode 100644 src/template/extractors/base-extractor.js delete mode 100644 src/template/extractors/base-extractor.js.map delete mode 100644 src/template/extractors/custom-context-extractor.d.ts delete mode 100644 src/template/extractors/custom-context-extractor.d.ts.map delete mode 100644 src/template/extractors/custom-context-extractor.js delete mode 100644 src/template/extractors/custom-context-extractor.js.map delete mode 100644 src/template/extractors/pr-extractor.d.ts delete mode 100644 src/template/extractors/pr-extractor.d.ts.map delete mode 100644 src/template/extractors/pr-extractor.js delete mode 100644 src/template/extractors/pr-extractor.js.map delete mode 100644 src/template/template-engine.d.ts delete mode 100644 src/template/template-engine.d.ts.map delete mode 100644 src/template/template-engine.js delete mode 100644 src/template/template-engine.js.map delete mode 100644 src/template/template-processor.d.ts delete mode 100644 src/template/template-processor.d.ts.map delete mode 100644 src/template/template-processor.js delete mode 100644 src/template/template-processor.js.map delete mode 100644 src/types/context.d.ts delete mode 100644 src/types/context.d.ts.map delete mode 100644 src/types/context.js delete mode 100644 src/types/context.js.map delete mode 100644 src/types/github.d.ts delete mode 100644 src/types/github.d.ts.map delete mode 100644 src/types/github.js delete mode 100644 src/types/github.js.map delete mode 100644 src/types/inputs.d.ts delete mode 100644 src/types/inputs.d.ts.map delete mode 100644 src/types/inputs.js delete mode 100644 src/types/inputs.js.map delete mode 100644 src/utils/file-utils.d.ts delete mode 100644 src/utils/file-utils.d.ts.map delete mode 100644 src/utils/file-utils.js delete mode 100644 src/utils/file-utils.js.map delete mode 100644 src/utils/logger.d.ts delete mode 100644 src/utils/logger.d.ts.map delete mode 100644 src/utils/logger.js delete mode 100644 src/utils/logger.js.map delete mode 100644 src/utils/validation.d.ts delete mode 100644 src/utils/validation.d.ts.map delete mode 100644 src/utils/validation.js delete mode 100644 src/utils/validation.js.map diff --git a/.gitignore b/.gitignore index 2b32b64..ccbb47e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,12 @@ yarn-error.log* # TypeScript build info (but keep dist/ for GitHub Actions) *.tsbuildinfo +# TypeScript compiled output in src/ (we use tsx to run directly) +src/**/*.js +src/**/*.d.ts +src/**/*.js.map +src/**/*.d.ts.map + # Test coverage coverage/ diff --git a/action.yml b/action.yml index dc18171..02911cb 100644 --- a/action.yml +++ b/action.yml @@ -60,8 +60,12 @@ runs: - name: Setup Auggie run: npm install -g @augmentcode/auggie shell: bash + - name: Install Action Dependencies + run: npm install --production=false + shell: bash + working-directory: ${{ github.action_path }} - name: Run Augment Agent - run: node $GITHUB_ACTION_PATH/src/index.js + run: npx tsx $GITHUB_ACTION_PATH/src/index.ts shell: bash env: INPUT_AUGMENT_SESSION_AUTH: ${{ inputs.augment_session_auth }} diff --git a/package-lock.json b/package-lock.json index aa362d8..8e60c8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@types/node": "^22.16.4", "@types/nunjucks": "^3.2.6", "prettier": "^3.6.2", + "tsx": "^4.20.6", "typescript": "^5.8.3" }, "engines": { @@ -60,6 +61,448 @@ "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==", "license": "MIT" }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.10.tgz", + "integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.10.tgz", + "integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.10.tgz", + "integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.10.tgz", + "integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.10.tgz", + "integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.10.tgz", + "integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.10.tgz", + "integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.10.tgz", + "integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.10.tgz", + "integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.10.tgz", + "integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.10.tgz", + "integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.10.tgz", + "integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.10.tgz", + "integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.10.tgz", + "integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.10.tgz", + "integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.10.tgz", + "integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.10.tgz", + "integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.10.tgz", + "integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.10.tgz", + "integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.10.tgz", + "integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.10.tgz", + "integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.10.tgz", + "integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.10.tgz", + "integrity": "sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.10.tgz", + "integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.10.tgz", + "integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.10.tgz", + "integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@fastify/busboy": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", @@ -274,6 +717,76 @@ "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", "license": "ISC" }, + "node_modules/esbuild": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz", + "integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.10", + "@esbuild/android-arm": "0.25.10", + "@esbuild/android-arm64": "0.25.10", + "@esbuild/android-x64": "0.25.10", + "@esbuild/darwin-arm64": "0.25.10", + "@esbuild/darwin-x64": "0.25.10", + "@esbuild/freebsd-arm64": "0.25.10", + "@esbuild/freebsd-x64": "0.25.10", + "@esbuild/linux-arm": "0.25.10", + "@esbuild/linux-arm64": "0.25.10", + "@esbuild/linux-ia32": "0.25.10", + "@esbuild/linux-loong64": "0.25.10", + "@esbuild/linux-mips64el": "0.25.10", + "@esbuild/linux-ppc64": "0.25.10", + "@esbuild/linux-riscv64": "0.25.10", + "@esbuild/linux-s390x": "0.25.10", + "@esbuild/linux-x64": "0.25.10", + "@esbuild/netbsd-arm64": "0.25.10", + "@esbuild/netbsd-x64": "0.25.10", + "@esbuild/openbsd-arm64": "0.25.10", + "@esbuild/openbsd-x64": "0.25.10", + "@esbuild/openharmony-arm64": "0.25.10", + "@esbuild/sunos-x64": "0.25.10", + "@esbuild/win32-arm64": "0.25.10", + "@esbuild/win32-ia32": "0.25.10", + "@esbuild/win32-x64": "0.25.10" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-tsconfig": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.11.0.tgz", + "integrity": "sha512-sNsqf7XKQ38IawiVGPOoAlqZo1DMrO7TU+ZcZwi7yLl7/7S0JwmoBMKz/IkUPhSoXM0Ng3vT0yB1iCe5XavDeQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/nunjucks": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.4.tgz", @@ -324,6 +837,36 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/tsx": { + "version": "4.20.6", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.6.tgz", + "integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/tunnel": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", diff --git a/package.json b/package.json index 2fde26b..216e7d8 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "main": "action.yml", "type": "module", "scripts": { - "build": "tsc", "test": "node --test", "typecheck": "tsc --noEmit", "format": "prettier --write .", @@ -49,8 +48,8 @@ ], "dependencies": { "@actions/core": "^1.10.1", - "nunjucks": "^3.2.4", "@octokit/rest": "^20.0.2", + "nunjucks": "^3.2.4", "yaml": "^2.3.4", "zod": "^3.22.4" }, @@ -58,6 +57,7 @@ "@types/node": "^22.16.4", "@types/nunjucks": "^3.2.6", "prettier": "^3.6.2", + "tsx": "^4.20.6", "typescript": "^5.8.3" } } diff --git a/src/config/constants.d.ts b/src/config/constants.d.ts deleted file mode 100644 index 405e2f1..0000000 --- a/src/config/constants.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Configuration constants for the Augment Agent - */ -import type { InputField } from '../types/inputs.js'; -export declare const ACTION_CONFIG: { - NAME: string; -}; -export declare const INPUT_FIELD_MAP: Record; -export declare const TEMPLATE_CONFIG: { - DEFAULT_TEMPLATE_NAME: string; - MAX_TEMPLATE_SIZE: number; - MAX_DIFF_SIZE: number; -}; -export declare const PATHS: { - TEMP_DIR: string; - DIFF_FILE_PATTERN: string; - INSTRUCTION_FILE: string; -}; -export declare const ERROR: { - readonly GITHUB: { - readonly API_ERROR: "GitHub API request failed"; - }; - readonly INPUT: { - readonly CONFLICTING_INSTRUCTION_INPUTS: "Cannot specify both instruction and instruction_file"; - readonly CONFLICTING_INSTRUCTION_TEMPLATE: "Cannot use both instruction inputs and template inputs simultaneously"; - readonly INVALID: "Invalid action inputs"; - readonly INVALID_CONTEXT_JSON: "Invalid JSON in custom_context"; - readonly MISMATCHED_PR_FIELDS: "Both pull_number and repo_name are required for PR extraction"; - readonly MISSING_INSTRUCTION_OR_TEMPLATE: "Either instruction/instruction_file or template_directory must be provided"; - readonly REPO_FORMAT: "Repository name must be in format \"owner/repo\""; - }; - readonly TEMPLATE: { - readonly MISSING_DIRECTORY: "template_directory is required when using templates"; - readonly NOT_FOUND: "Template file not found"; - readonly PATH_OUTSIDE_DIRECTORY: "Template path is outside template directory"; - readonly RENDER_ERROR: "Failed to render template"; - readonly TOO_LARGE: "Template file exceeds maximum size"; - }; -}; -//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/src/config/constants.d.ts.map b/src/config/constants.d.ts.map deleted file mode 100644 index 2a1f836..0000000 --- a/src/config/constants.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAmBtD,CAAC;AAEF,eAAO,MAAM,eAAe;;;;CAI3B,CAAC;AAEF,eAAO,MAAM,KAAK;;;;CAIjB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;CAsBR,CAAC"} \ No newline at end of file diff --git a/src/config/constants.js b/src/config/constants.js deleted file mode 100644 index adc4a0f..0000000 --- a/src/config/constants.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Configuration constants for the Augment Agent - */ -export const ACTION_CONFIG = { - NAME: 'Augment Agent', -}; -export const INPUT_FIELD_MAP = { - augmentSessionAuth: { envVar: 'INPUT_AUGMENT_SESSION_AUTH', required: false }, - augmentApiToken: { envVar: 'INPUT_AUGMENT_API_TOKEN', required: false }, - augmentApiUrl: { envVar: 'INPUT_AUGMENT_API_URL', required: false }, - customContext: { envVar: 'INPUT_CUSTOM_CONTEXT', required: false }, - githubToken: { envVar: 'INPUT_GITHUB_TOKEN', required: false }, - instruction: { envVar: 'INPUT_INSTRUCTION', required: false }, - instructionFile: { envVar: 'INPUT_INSTRUCTION_FILE', required: false }, - pullNumber: { - envVar: 'INPUT_PULL_NUMBER', - required: false, - transform: (val) => parseInt(val, 10), - }, - repoName: { envVar: 'INPUT_REPO_NAME', required: false }, - templateDirectory: { envVar: 'INPUT_TEMPLATE_DIRECTORY', required: false }, - templateName: { envVar: 'INPUT_TEMPLATE_NAME', required: false }, - model: { envVar: 'INPUT_MODEL', required: false }, - rules: { envVar: 'INPUT_RULES', required: false }, - mcpConfigs: { envVar: 'INPUT_MCP_CONFIGS', required: false }, -}; -export const TEMPLATE_CONFIG = { - DEFAULT_TEMPLATE_NAME: 'prompt.njk', - MAX_TEMPLATE_SIZE: 128 * 1024, // 128KB - MAX_DIFF_SIZE: 128 * 1024, // 128KB -}; -export const PATHS = { - TEMP_DIR: '/tmp', - DIFF_FILE_PATTERN: 'pr-{pullNumber}-diff.patch', - INSTRUCTION_FILE: '/tmp/generated-instruction.txt', -}; -export const ERROR = { - GITHUB: { - API_ERROR: 'GitHub API request failed', - }, - INPUT: { - CONFLICTING_INSTRUCTION_INPUTS: 'Cannot specify both instruction and instruction_file', - CONFLICTING_INSTRUCTION_TEMPLATE: 'Cannot use both instruction inputs and template inputs simultaneously', - INVALID: 'Invalid action inputs', - INVALID_CONTEXT_JSON: 'Invalid JSON in custom_context', - MISMATCHED_PR_FIELDS: 'Both pull_number and repo_name are required for PR extraction', - MISSING_INSTRUCTION_OR_TEMPLATE: 'Either instruction/instruction_file or template_directory must be provided', - REPO_FORMAT: 'Repository name must be in format "owner/repo"', - }, - TEMPLATE: { - MISSING_DIRECTORY: 'template_directory is required when using templates', - NOT_FOUND: 'Template file not found', - PATH_OUTSIDE_DIRECTORY: 'Template path is outside template directory', - RENDER_ERROR: 'Failed to render template', - TOO_LARGE: 'Template file exceeds maximum size', - }, -}; -//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/src/config/constants.js.map b/src/config/constants.js.map deleted file mode 100644 index 2226428..0000000 --- a/src/config/constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAA+B;IACzD,kBAAkB,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE;IAC7E,eAAe,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE,QAAQ,EAAE,KAAK,EAAE;IACvE,aAAa,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE;IACnE,aAAa,EAAE,EAAE,MAAM,EAAE,sBAAsB,EAAE,Q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,MAAM,EAAE;QACN,SAAS,EAAE,2BAA2B;KACvC;IACD,KAAK,EAAE;QACL,8BAA8B,EAAE,sDAAsD;QACtF,gCAAgC,EAC9B,uEAAuE;QACzE,OAAO,EAAE,uBAAuB;QAChC,oBAAoB,EAAE,gCAAgC;QACtD,oBAAoB,EAAE,+DAA+D;QACrF,+BAA+B,EAC7B,4EAA4E;QAC9E,WAAW,EAAE,gDAAgD;KAC9D;IACD,QAAQ,EAAE;QACR,iBAAiB,EAAE,qDAAqD;QACxE,SAAS,EAAE,yBAAyB;QACpC,sBAAsB,EAAE,6CAA6C;QACrE,YAAY,EAAE,2BAA2B;QACzC,SAAS,EAAE,oCAAoC;KAChD;CACO,CAAC"} \ No newline at end of file diff --git a/src/index.d.ts b/src/index.d.ts deleted file mode 100644 index f035206..0000000 --- a/src/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env node -/** - * Augment Agent GitHub Action - * Main entry point for the action - */ -export {}; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/src/index.d.ts.map b/src/index.d.ts.map deleted file mode 100644 index d0cfa4f..0000000 --- a/src/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAEA;;;GAGG"} \ No newline at end of file diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 2270121..0000000 --- a/src/index.js +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env node -/** - * Augment Agent GitHub Action - * Main entry point for the action - */ -import { spawn } from 'child_process'; -import process from 'process'; -import { ValidationUtils } from './utils/validation.js'; -import { TemplateProcessor } from './template/template-processor.js'; -import { logger } from './utils/logger.js'; -/** - * Execute a shell command and return a promise - */ -function execCommand(command, args = [], options = {}) { - return new Promise((resolve, reject) => { - // Join command and args into a single shell command for proper quoting - const fullCommand = `${command} ${args - .map(arg => { - // Properly quote arguments that contain spaces or special characters - if (arg.includes(' ') || arg.includes('"') || arg.includes("'")) { - return `"${arg.replace(/"/g, '\\"')}"`; - } - return arg; - }) - .join(' ')}`; - const child = spawn(fullCommand, [], { - stdio: 'inherit', - shell: true, - ...options, - }); - child.on('close', code => { - if (code === 0) { - resolve(code); - } - else { - reject(new Error(`Command failed with exit code ${code}`)); - } - }); - child.on('error', error => { - reject(error); - }); - }); -} -/** - * Set up environment variables for the augment script - */ -function setupEnvironment(inputs) { - // Set authentication environment variables - if (inputs.augmentSessionAuth) { - // Use session authentication - process.env.AUGMENT_SESSION_AUTH = inputs.augmentSessionAuth; - } - else { - // Use token + URL authentication - process.env.AUGMENT_API_TOKEN = inputs.augmentApiToken; - process.env.AUGMENT_API_URL = inputs.augmentApiUrl; - } - // Set GitHub token if provided - if (inputs.githubToken) { - process.env.GITHUB_API_TOKEN = inputs.githubToken; - } -} -/** - * Process templates and generate instruction file - */ -async function processTemplate(inputs) { - logger.info('Preparing template', { - templateDirectory: inputs.templateDirectory, - templateName: inputs.templateName, - }); - // Create and run template processor - const processor = TemplateProcessor.create(inputs); - const instructionFilePath = await processor.processTemplate(inputs); - logger.info('Template processing completed', { - instructionFile: instructionFilePath, - }); - return instructionFilePath; -} -/** - * Run the augment script with appropriate arguments - */ -async function runAugmentScript(inputs) { - let instruction_value; - let is_file; - if (inputs.instruction) { - instruction_value = inputs.instruction; - is_file = false; - logger.debug('Using direct instruction', { instruction: inputs.instruction }); - } - else if (inputs.instructionFile) { - instruction_value = inputs.instructionFile; - is_file = true; - logger.debug('Using instruction file', { instructionFile: inputs.instructionFile }); - } - else { - instruction_value = await processTemplate(inputs); - is_file = true; - logger.debug('Using template-generated instruction file', { - instructionFile: instruction_value, - }); - } - const args = ['--print']; - if (inputs.model && inputs.model.trim().length > 0) { - args.push('--model', inputs.model.trim()); - } - if (is_file) { - logger.info(`📄 Using instruction file: ${instruction_value}`); - args.push('--instruction-file', instruction_value); - } - else { - logger.info('📝 Using direct instruction'); - args.push('--instruction', instruction_value); - } - const uniqueRules = Array.from(new Set(inputs.rules ?? [])).filter(rule => rule.length > 0); - if (uniqueRules.length > 0) { - logger.info(`🔧 Applying ${uniqueRules.length} rule file(s)`); - for (const rulePath of uniqueRules) { - logger.info(` - ${rulePath}`); - args.push('--rules', rulePath); - } - } - const uniqueMcpConfigs = Array.from(new Set(inputs.mcpConfigs ?? [])).filter(config => config.length > 0); - if (uniqueMcpConfigs.length > 0) { - logger.info(`🧩 Applying ${uniqueMcpConfigs.length} MCP config file(s)`); - for (const configPath of uniqueMcpConfigs) { - logger.info(` - ${configPath}`); - args.push('--mcp-config', configPath); - } - } - await execCommand('auggie', args); - logger.info('✅ Augment Agent completed successfully'); -} -/** - * Main function - */ -async function main() { - try { - logger.info('🔍 Validating inputs...'); - const inputs = ValidationUtils.validateInputs(); - logger.info('⚙️ Setting up environment...'); - setupEnvironment(inputs); - logger.info('🚀 Starting Augment Agent...'); - await runAugmentScript(inputs); - } - catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - logger.setFailed(errorMessage); - } -} -// Run the action only if this file is executed directly -if (import.meta.url === `file://${process.argv[1]}`) { - main().catch(error => { - const errorMessage = error instanceof Error ? error.message : String(error); - logger.setFailed(`Unexpected error: ${errorMessage}`); - }); -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/index.js.map b/src/index.js.map deleted file mode 100644 index c06d361..0000000 --- a/src/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C;;GAEG;AACH,SAAS,WAAW,CAClB,OAAe,EACf,O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C;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACnB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,CAAC,SAAS,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/src/services/github-service.d.ts b/src/services/github-service.d.ts deleted file mode 100644 index c6627fd..0000000 --- a/src/services/github-service.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * GitHub API service for PR information extraction - */ -import { PullRequestInfo, PullRequestFile, PullRequestDiff } from '../types/github.js'; -export declare class GitHubService { - private octokit; - private owner; - private repo; - constructor(config: { - token: string; - owner: string; - repo: string; - }); - getPullRequest(pullNumber: number): Promise; - getPullRequestFiles(pullNumber: number): Promise; - getPullRequestDiff(pullNumber: number): Promise; -} -//# sourceMappingURL=github-service.d.ts.map \ No newline at end of file diff --git a/src/services/github-service.d.ts.map b/src/services/github-service.d.ts.map deleted file mode 100644 index e9a77d7..0000000 --- a/src/services/github-service.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"github-service.d.ts","sourceRoot":"","sources":["github-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIvF,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;gBAET,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAM5D,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA6C5D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA8DnE,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAyBvE"} \ No newline at end of file diff --git a/src/services/github-service.js b/src/services/github-service.js deleted file mode 100644 index 1ba4e1c..0000000 --- a/src/services/github-service.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * GitHub API service for PR information extraction - */ -import { Octokit } from '@octokit/rest'; -import { TEMPLATE_CONFIG, ERROR } from '../config/constants.js'; -import { logger } from '../utils/logger.js'; -export class GitHubService { - octokit; - owner; - repo; - constructor(config) { - this.octokit = new Octokit({ auth: config.token }); - this.owner = config.owner; - this.repo = config.repo; - } - async getPullRequest(pullNumber) { - try { - logger.debug(`Fetching PR ${pullNumber} from ${this.owner}/${this.repo}`); - const { data } = await this.octokit.rest.pulls.get({ - owner: this.owner, - repo: this.repo, - pull_number: pullNumber, - }); - return { - number: data.number, - title: data.title, - body: data.body, - state: data.state, - user: { login: data.user?.login || 'unknown' }, - head: { - ref: data.head.ref, - sha: data.head.sha, - repo: { - full_name: data.head.repo.full_name, - name: data.head.repo.name, - owner: { - login: data.head.repo.owner.login, - }, - }, - }, - base: { - ref: data.base.ref, - sha: data.base.sha, - repo: { - full_name: data.base.repo.full_name, - name: data.base.repo.name, - owner: { - login: data.base.repo.owner.login, - }, - }, - }, - }; - } - catch (error) { - logger.error(`${ERROR.GITHUB.API_ERROR}: Failed to fetch PR ${pullNumber}`, error); - throw error; - } - } - async getPullRequestFiles(pullNumber) { - try { - logger.debug(`Fetching files for PR ${pullNumber}`); - const allFiles = []; - let page = 1; - const perPage = 100; // GitHub's maximum per page - while (true) { - logger.debug(`Fetching PR files page ${page}`, { - pullNumber, - page, - perPage, - }); - const { data } = await this.octokit.rest.pulls.listFiles({ - owner: this.owner, - repo: this.repo, - pull_number: pullNumber, - per_page: perPage, - page, - }); - // Map and add files from this page - const pageFiles = data.map(file => ({ - filename: file.filename, - status: file.status, - additions: file.additions, - deletions: file.deletions, - changes: file.changes, - })); - allFiles.push(...pageFiles); - logger.debug(`Fetched ${pageFiles.length} files from page ${page}`, { - pullNumber, - page, - filesOnPage: pageFiles.length, - totalFilesSoFar: allFiles.length, - }); - // If we got fewer files than the page size, we've reached the end - if (data.length < perPage) { - break; - } - page++; - } - logger.info(`Successfully fetched all PR files`, { - pullNumber, - totalFiles: allFiles.length, - totalPages: page, - }); - return allFiles; - } - catch (error) { - logger.error(`${ERROR.GITHUB.API_ERROR}: Failed to fetch PR files`, error); - throw error; - } - } - async getPullRequestDiff(pullNumber) { - try { - logger.debug(`Fetching diff for PR ${pullNumber}`); - const { data } = await this.octokit.rest.pulls.get({ - owner: this.owner, - repo: this.repo, - pull_number: pullNumber, - mediaType: { format: 'diff' }, - }); - const content = data; - const size = Buffer.byteLength(content, 'utf8'); - const truncated = size > TEMPLATE_CONFIG.MAX_DIFF_SIZE; - return { - content: truncated ? content.substring(0, TEMPLATE_CONFIG.MAX_DIFF_SIZE) : content, - size, - truncated, - }; - } - catch (error) { - logger.error(`${ERROR.GITHUB.API_ERROR}: Failed to fetch PR diff`, error); - throw error; - } - } -} -//# sourceMappingURL=github-service.js.map \ No newline at end of file diff --git a/src/services/github-service.js.map b/src/services/github-service.js.map deleted file mode 100644 index dfe2c9b..0000000 --- a/src/services/github-service.js.map +++ /dev/null @@ -1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,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,4BAA4B,EAAE,KAAK,CAAC,CAAC;YAC3E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,UAAkB;QACzC,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;YAEnD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;gBACjD,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,UAAU;gBACvB,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;aAC9B,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,IAAyB,CAAC;YAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAChD,MAAM,SAAS,GAAG,IAAI,GAAG,eAAe,CAAC,aAAa,CAAC;YAEvD,OAAO;gBACL,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO;gBAClF,IAAI;gBACJ,SAAS;aACV,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,2BAA2B,EAAE,KAAK,CAAC,CAAC;YAC1E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/context-builder.d.ts b/src/template/context-builder.d.ts deleted file mode 100644 index 4c21677..0000000 --- a/src/template/context-builder.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Context builder - responsible for aggregating context from multiple sources - */ -import { PRExtractor } from './extractors/pr-extractor.js'; -import { CustomContextExtractor } from './extractors/custom-context-extractor.js'; -import type { TemplateContext } from '../types/context.js'; -import type { ActionInputs } from '../types/inputs.js'; -export declare class ContextBuilder { - private prExtractor; - private customContextExtractor; - constructor(prExtractor: PRExtractor, customContextExtractor: CustomContextExtractor); - static create(inputs: ActionInputs): ContextBuilder; - buildContext(inputs: ActionInputs): Promise; -} -//# sourceMappingURL=context-builder.d.ts.map \ No newline at end of file diff --git a/src/template/context-builder.d.ts.map b/src/template/context-builder.d.ts.map deleted file mode 100644 index 3add95c..0000000 --- a/src/template/context-builder.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["context-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,cAAc;IAEvB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,sBAAsB;gBADtB,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB;IAGxD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc;IAI7C,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC;CAqCnE"} \ No newline at end of file diff --git a/src/template/context-builder.js b/src/template/context-builder.js deleted file mode 100644 index 7b6097e..0000000 --- a/src/template/context-builder.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Context builder - responsible for aggregating context from multiple sources - */ -import { logger } from '../utils/logger.js'; -import { PRExtractor } from './extractors/pr-extractor.js'; -import { CustomContextExtractor } from './extractors/custom-context-extractor.js'; -export class ContextBuilder { - prExtractor; - customContextExtractor; - constructor(prExtractor, customContextExtractor) { - this.prExtractor = prExtractor; - this.customContextExtractor = customContextExtractor; - } - static create(inputs) { - return new ContextBuilder(PRExtractor.create(inputs), CustomContextExtractor.create(inputs)); - } - async buildContext(inputs) { - try { - logger.debug('Building template context from inputs'); - const context = {}; - // Extract PR data (extractor decides if it should run) - const prData = await this.prExtractor.extract(inputs); - if (prData) { - context.pr = prData; - logger.debug('PR data extracted and added to context', { - prNumber: prData.number, - title: prData.title, - }); - } - // Extract custom context if available - const customContext = await this.customContextExtractor.extract(inputs); - if (customContext) { - context.custom = customContext; - logger.debug('Custom context extracted and added', { - customContextKeys: Object.keys(customContext), - }); - } - logger.info('Template context built successfully', { - hasPR: !!context.pr, - hasCustom: !!context.custom, - customKeys: context.custom ? Object.keys(context.custom) : [], - }); - return context; - } - catch (error) { - logger.error('Failed to build template context', error); - throw error; - } - } -} -//# sourceMappingURL=context-builder.js.map \ No newline at end of file diff --git a/src/template/context-builder.js.map b/src/template/context-builder.js.map deleted file mode 100644 index 0c24a31..0000000 --- a/src/template/context-builder.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"context-builder.js","sourceRoot":"","sources":["context-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAIlF,MAAM,OAAO,cAAc;IAEf;IACA;IAFV,YACU,WAAwB,EACxB,sBAA8C;QAD9C,gBAAW,GAAX,WAAW,CAAa;QACxB,2BAAsB,GAAtB,sBAAsB,CAAwB;IACrD,CAAC;IAEJ,MAAM,CAAC,MAAM,CAAC,MAAoB;QAChC,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC,MAAM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AAC;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/extractors/base-extractor.d.ts b/src/template/extractors/base-extractor.d.ts deleted file mode 100644 index 0e94f6d..0000000 --- a/src/template/extractors/base-extractor.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Base extractor class that defines the common interface for all data extractors - */ -import type { ActionInputs } from '../../types/inputs.js'; -export declare abstract class BaseExtractor { - protected readonly extractorName: string; - constructor(extractorName: string); - /** - * Static factory method that each extractor must implement - * Creates an instance of the extractor configured for the given inputs - */ - static create(_inputs: ActionInputs): BaseExtractor; - /** - * Determines if extraction should be performed based on the action inputs - */ - abstract shouldExtract(inputs: ActionInputs): boolean; - /** - * Performs the actual data extraction - */ - protected abstract performExtraction(inputs: ActionInputs): Promise | TOutput; - /** - * Main extraction method that handles logging and error handling - */ - extract(inputs: ActionInputs): Promise; -} -//# sourceMappingURL=base-extractor.d.ts.map \ No newline at end of file diff --git a/src/template/extractors/base-extractor.d.ts.map b/src/template/extractors/base-extractor.d.ts.map deleted file mode 100644 index a9c0468..0000000 --- a/src/template/extractors/base-extractor.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"base-extractor.d.ts","sourceRoot":"","sources":["base-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,8BAAsB,aAAa,CAAC,OAAO;IACzC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;gBAE7B,aAAa,EAAE,MAAM;IAIjC;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC;IAIxD;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAErD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO;IAEtF;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;CAmBlE"} \ No newline at end of file diff --git a/src/template/extractors/base-extractor.js b/src/template/extractors/base-extractor.js deleted file mode 100644 index d517aac..0000000 --- a/src/template/extractors/base-extractor.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Base extractor class that defines the common interface for all data extractors - */ -import { logger } from '../../utils/logger.js'; -export class BaseExtractor { - extractorName; - constructor(extractorName) { - this.extractorName = extractorName; - } - /** - * Static factory method that each extractor must implement - * Creates an instance of the extractor configured for the given inputs - */ - static create(_inputs) { - throw new Error('Subclasses must implement the static create method'); - } - /** - * Main extraction method that handles logging and error handling - */ - async extract(inputs) { - try { - if (!this.shouldExtract(inputs)) { - logger.debug(`${this.extractorName} extraction skipped`, { - reason: 'shouldExtract returned false', - }); - return undefined; - } - logger.debug(`Starting ${this.extractorName} extraction`); - const result = await this.performExtraction(inputs); - logger.debug(`${this.extractorName} extraction completed successfully`); - return result; - } - catch (error) { - logger.error(`${this.extractorName} extraction failed`, error); - throw error; - } - } -} -//# sourceMappingURL=base-extractor.js.map \ No newline at end of file diff --git a/src/template/extractors/base-extractor.js.map b/src/template/extractors/base-extractor.js.map deleted file mode 100644 index cfbf4a2..0000000 --- a/src/template/extractors/base-extractor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"base-extractor.js","sourceRoot":"","sources":["base-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/C,MAAM,OAAgB,aAAa;IACd,aAAa,CAAS;IAEzC,YAAY,aAAqB;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,OAAqB;QACjC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAYD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAAoB;QAChC,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,aAAa,qBAAqB,EAAE;oBACvD,MAAM,EAAE,8BAA8B;iBACvC,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,aAAa,aAAa,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAEpD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,aAAa,oCAAoC,CAAC,CAAC;YACxE,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,aAAa,oBAAoB,EAAE,KAAK,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.d.ts b/src/template/extractors/custom-context-extractor.d.ts deleted file mode 100644 index f2f390f..0000000 --- a/src/template/extractors/custom-context-extractor.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Custom context extractor - handles parsing JSON strings into context objects - */ -import { BaseExtractor } from './base-extractor.js'; -import type { ActionInputs } from '../../types/inputs.js'; -export declare class CustomContextExtractor extends BaseExtractor> { - constructor(); - /** - * Creates a CustomContextExtractor instance - */ - static create(_inputs: ActionInputs): CustomContextExtractor; - /** - * Determines if custom context extraction should be performed - */ - shouldExtract(inputs: ActionInputs): boolean; - /** - * Performs custom context extraction by parsing JSON string - */ - protected performExtraction(inputs: ActionInputs): Record; -} -//# sourceMappingURL=custom-context-extractor.d.ts.map \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.d.ts.map b/src/template/extractors/custom-context-extractor.d.ts.map deleted file mode 100644 index 286f50c..0000000 --- a/src/template/extractors/custom-context-extractor.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"custom-context-extractor.d.ts","sourceRoot":"","sources":["custom-context-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;IAK5E;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,sBAAsB;IAI5D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAI5C;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAuBvE"} \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.js b/src/template/extractors/custom-context-extractor.js deleted file mode 100644 index f3c5b74..0000000 --- a/src/template/extractors/custom-context-extractor.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Custom context extractor - handles parsing JSON strings into context objects - */ -import { BaseExtractor } from './base-extractor.js'; -import { logger } from '../../utils/logger.js'; -import { ERROR } from '../../config/constants.js'; -export class CustomContextExtractor extends BaseExtractor { - constructor() { - super('Custom Context'); - } - /** - * Creates a CustomContextExtractor instance - */ - static create(_inputs) { - return new CustomContextExtractor(); - } - /** - * Determines if custom context extraction should be performed - */ - shouldExtract(inputs) { - return !!(inputs.customContext && inputs.customContext.trim().length > 0); - } - /** - * Performs custom context extraction by parsing JSON string - */ - performExtraction(inputs) { - const jsonString = inputs.customContext; - try { - const parsed = JSON.parse(jsonString); - if (typeof parsed !== 'object' || parsed === null) { - throw new Error('Parsed JSON must be an object'); - } - logger.debug('Custom context parsed successfully', { - keys: Object.keys(parsed), - keyCount: Object.keys(parsed).length, - }); - return parsed; - } - catch (error) { - const message = `${ERROR.INPUT.INVALID_CONTEXT_JSON}: ${error instanceof Error ? error.message : String(error)}`; - logger.error('Failed to parse custom context JSON', error); - throw new Error(message); - } - } -} -//# sourceMappingURL=custom-context-extractor.js.map \ No newline at end of file diff --git a/src/template/extractors/custom-context-extractor.js.map b/src/template/extractors/custom-context-extractor.js.map deleted file mode 100644 index 3749453..0000000 --- a/src/template/extractors/custom-context-extractor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"custom-context-extractor.js","sourceRoot":"","sources":["custom-context-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,MAAM,OAAO,sBAAuB,SAAQ,aAAkC;IAC5E;QACE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAqB;QACjC,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,MAAoB;QAChC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,MAAoB;QAC9C,MAAM,UAAU,GAAG,MAAM,CAAC,aAAc,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAEtC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACnD,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE;gBACjD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;gBACzB,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM;aACrC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,KACjD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.d.ts b/src/template/extractors/pr-extractor.d.ts deleted file mode 100644 index eb02673..0000000 --- a/src/template/extractors/pr-extractor.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * PR data extractor - responsible for extracting and formatting PR data from GitHub API - */ -import { BaseExtractor } from './base-extractor.js'; -import { GitHubService } from '../../services/github-service.js'; -import type { PRData } from '../../types/context.js'; -import type { ActionInputs } from '../../types/inputs.js'; -export declare class PRExtractor extends BaseExtractor { - private githubService?; - constructor(githubService?: GitHubService | undefined); - /** - * Creates a PRExtractor instance configured for the given inputs - */ - static create(inputs: ActionInputs): PRExtractor; - /** - * Determines if PR extraction should be performed - */ - shouldExtract(inputs: ActionInputs): boolean; - /** - * Performs the actual PR data extraction - */ - protected performExtraction(inputs: ActionInputs): Promise; - private writeDiffFile; -} -//# sourceMappingURL=pr-extractor.d.ts.map \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.d.ts.map b/src/template/extractors/pr-extractor.d.ts.map deleted file mode 100644 index c5abeff..0000000 --- a/src/template/extractors/pr-extractor.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pr-extractor.d.ts","sourceRoot":"","sources":["pr-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAMjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,WAAY,SAAQ,aAAa,CAAC,MAAM,CAAC;IACxC,OAAO,CAAC,aAAa,CAAC;gBAAd,aAAa,CAAC,EAAE,aAAa,YAAA;IAIjD;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IA4BhD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAI5C;;OAEG;cACa,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;YAmD1D,aAAa;CAwB5B"} \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.js b/src/template/extractors/pr-extractor.js deleted file mode 100644 index de77fd6..0000000 --- a/src/template/extractors/pr-extractor.js +++ /dev/null @@ -1,123 +0,0 @@ -/** - * PR data extractor - responsible for extracting and formatting PR data from GitHub API - */ -import { join } from 'node:path'; -import { BaseExtractor } from './base-extractor.js'; -import { GitHubService } from '../../services/github-service.js'; -import { FileUtils } from '../../utils/file-utils.js'; -import { logger } from '../../utils/logger.js'; -import { ValidationUtils } from '../../utils/validation.js'; -import { PATHS } from '../../config/constants.js'; -export class PRExtractor extends BaseExtractor { - githubService; - constructor(githubService) { - super('PR Data'); - this.githubService = githubService; - } - /** - * Creates a PRExtractor instance configured for the given inputs - */ - static create(inputs) { - // If we have complete repo information, create with pre-configured GitHub service - if (inputs.repoName && inputs.githubToken) { - try { - const repoInfo = ValidationUtils.parseRepoName(inputs.repoName); - const githubService = new GitHubService({ - token: inputs.githubToken, - owner: repoInfo.owner, - repo: repoInfo.repo, - }); - logger.debug('PRExtractor created with pre-configured GitHubService', { - owner: repoInfo.owner, - repo: repoInfo.repo, - }); - return new PRExtractor(githubService); - } - catch (error) { - logger.debug('Failed to create pre-configured GitHubService, will create lazily', { - error: error instanceof Error ? error.message : 'Unknown error', - }); - // Fall through to create without GitHubService - } - } - // Create without GitHubService for lazy configuration - logger.debug('PRExtractor created without GitHubService (will be created lazily)'); - return new PRExtractor(); - } - /** - * Determines if PR extraction should be performed - */ - shouldExtract(inputs) { - return !!(inputs.pullNumber && inputs.pullNumber > 0 && inputs.repoName && inputs.githubToken); - } - /** - * Performs the actual PR data extraction - */ - async performExtraction(inputs) { - const pullNumber = inputs.pullNumber; - // Get or create GitHubService lazily - const githubService = this.githubService; - if (!githubService) { - throw new Error('GitHubService not provided'); - } - const prData = await githubService.getPullRequest(pullNumber); - const files = await githubService.getPullRequestFiles(pullNumber); - const diffFilePath = await this.writeDiffFile(pullNumber, githubService); - const extractedData = { - number: prData.number, - title: prData.title, - author: prData.user.login, - head: { - ref: prData.head.ref, - sha: prData.head.sha, - repo: { - full_name: prData.head.repo.full_name, - name: prData.head.repo.name, - owner: prData.head.repo.owner.login, - }, - }, - base: { - ref: prData.base.ref, - sha: prData.base.sha, - repo: { - full_name: prData.base.repo.full_name, - name: prData.base.repo.name, - owner: prData.base.repo.owner.login, - }, - }, - body: prData.body || '', - state: prData.state, - changed_files: files.map(file => file.filename).join('\n'), - changed_files_list: files, - diff_file: diffFilePath, - }; - logger.info('PR data extraction completed', { - pullNumber, - fileCount: files.length, - diffFile: diffFilePath, - }); - return extractedData; - } - async writeDiffFile(pullNumber, githubService) { - try { - const diff = await githubService.getPullRequestDiff(pullNumber); - if (diff.truncated) { - logger.warning('PR diff was truncated due to size', { - originalSize: diff.size, - truncated: diff.truncated, - }); - } - const diffFileName = PATHS.DIFF_FILE_PATTERN.replace('{pullNumber}', pullNumber.toString()); - const diffFilePath = join(PATHS.TEMP_DIR, diffFileName); - await FileUtils.ensureDirectoryExists(PATHS.TEMP_DIR); - await FileUtils.writeFile(diffFilePath, diff.content); - logger.debug('Diff file written', { diffFilePath, size: diff.size }); - return diffFilePath; - } - catch (error) { - logger.error('Failed to write diff file', error); - throw error; - } - } -} -//# sourceMappingURL=pr-extractor.js.map \ No newline at end of file diff --git a/src/template/extractors/pr-extractor.js.map b/src/template/extractors/pr-extractor.js.map deleted file mode 100644 index eb173e9..0000000 --- a/src/template/extractors/pr-extractor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"pr-extractor.js","sourceRoot":"","sources":["pr-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAKlD,MAAM,OAAO,WAAY,SAAQ,aAAqB;IAChC;IAApB,YAAoB,aAA6B;QAC/C,KAAK,CAAC,SAAS,CAAC,CAAC;QADC,kBAAa,GAAb,aAAa,CAAgB;IAEjD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAoB;QAChC,kFAAkF;QAClF,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YA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YACjD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/template-engine.d.ts b/src/template/template-engine.d.ts deleted file mode 100644 index 2307a73..0000000 --- a/src/template/template-engine.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Template engine for rendering Nunjucks templates - */ -import type { TemplateContext } from '../types/context.js'; -import { ActionInputs } from '../types/inputs.js'; -export declare class TemplateEngine { - private env; - private templateDirectory; - constructor(templateDirectory: string); - static create(inputs: ActionInputs): TemplateEngine; - renderTemplate(templateName: string, context: TemplateContext): Promise; - private resolveFilePath; - maybeReadFile(filePath: string): string; - formatFiles(files: Array<{ - filename: string; - status: string; - }>): string; - private setupCustomFilters; -} -//# sourceMappingURL=template-engine.d.ts.map \ No newline at end of file diff --git a/src/template/template-engine.d.ts.map b/src/template/template-engine.d.ts.map deleted file mode 100644 index aaf4eec..0000000 --- a/src/template/template-engine.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"template-engine.d.ts","sourceRoot":"","sources":["template-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,iBAAiB,EAAE,MAAM;IAgBrC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc;IAI7C,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBrF,OAAO,CAAC,eAAe;IAyBvB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IA8BvC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,MAAM;IAOvE,OAAO,CAAC,kBAAkB;CAK3B"} \ No newline at end of file diff --git a/src/template/template-engine.js b/src/template/template-engine.js deleted file mode 100644 index 4e09ca7..0000000 --- a/src/template/template-engine.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Template engine for rendering Nunjucks templates - */ -import * as nunjucks from 'nunjucks'; -import { resolve } from 'node:path'; -import { FileUtils } from '../utils/file-utils.js'; -import { logger } from '../utils/logger.js'; -import { ERROR, PATHS } from '../config/constants.js'; -export class TemplateEngine { - env; - templateDirectory; - constructor(templateDirectory) { - this.templateDirectory = resolve(templateDirectory); - // Configure Nunjucks environment - this.env = nunjucks.configure(this.templateDirectory, { - autoescape: false, - throwOnUndefined: true, - trimBlocks: true, - lstripBlocks: true, - noCache: true, // Ensure fresh reads in CI environment - }); - this.setupCustomFilters(); - logger.debug(`Template engine initialized with directory: ${this.templateDirectory}`); - } - static create(inputs) { - return new TemplateEngine(inputs.templateDirectory); - } - async renderTemplate(templateName, context) { - try { - // Validate template file exists and is safe - await FileUtils.validateTemplateFile(this.templateDirectory, templateName); - logger.debug(`Rendering template: ${templateName}`, { contextKeys: Object.keys(context) }); - // Render template - const rendered = this.env.render(templateName, context); - logger.info(`Template rendered successfully`, { - templateName, - contentLength: rendered.length, - }); - return rendered; - } - catch (error) { - const message = `${ERROR.TEMPLATE.RENDER_ERROR}: ${error instanceof Error ? error.message : String(error)}`; - logger.error(message, error); - throw new Error(message); - } - } - resolveFilePath(filePath) { - const fs = require('fs'); - // Try using the path as absolute if it's within allowed directories - const absolutePath = resolve(filePath); - if ((absolutePath.startsWith(this.templateDirectory) || - absolutePath.startsWith(PATHS.TEMP_DIR)) && - fs.existsSync(absolutePath)) { - return absolutePath; - } - // Try resolving relative to template directory - const templatePath = resolve(this.templateDirectory, filePath); - if (templatePath.startsWith(this.templateDirectory) && fs.existsSync(templatePath)) { - return templatePath; - } - // Try resolving relative to tmp directory - const tmpPath = resolve(PATHS.TEMP_DIR, filePath); - if (tmpPath.startsWith(PATHS.TEMP_DIR) && fs.existsSync(tmpPath)) { - return tmpPath; - } - return undefined; - } - maybeReadFile(filePath) { - try { - if (!filePath) { - logger.warning('Empty file path provided to maybe_read_file filter'); - return ''; - } - const resolvedPath = this.resolveFilePath(filePath); - if (!resolvedPath) { - logger.warning(`File path ${filePath} not found in allowed directories (template: ${this.templateDirectory}, tmp: ${PATHS.TEMP_DIR})`); - return filePath; // Return original path as fallback - } - const fs = require('fs'); - // Synchronous read for template rendering - const content = fs.readFileSync(resolvedPath, 'utf8'); - logger.debug('File read successfully via filter', { - originalPath: filePath, - resolvedPath: resolvedPath, - contentLength: content.length, - }); - return content; - } - catch (_error) { - logger.warning('Failed to read file via filter, returning original path', { - filePath, - }); - return filePath; // Return original path as fallback - } - } - formatFiles(files) { - if (!Array.isArray(files) || files.length === 0) { - return 'No files changed'; - } - return files.map(file => `${file.status.toUpperCase()}: ${file.filename}`).join('\n'); - } - setupCustomFilters() { - this.env.addFilter('maybe_read_file', this.maybeReadFile.bind(this)); - this.env.addFilter('format_files', this.formatFiles.bind(this)); - logger.debug('Custom filters setup complete'); - } -} -//# sourceMappingURL=template-engine.js.map \ No newline at end of file diff --git a/src/template/template-engine.js.map b/src/template/template-engine.js.map deleted file mode 100644 index 5d0e302..0000000 --- a/src/template/template-engine.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"template-engine.js","sourceRoot":"","sources":["template-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAItD,MAAM,OAAO,cAAc;IAC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IACxF,CAAC;IAEO,kBAAkB;QACxB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChE,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAChD,CAAC;CACF"} \ No newline at end of file diff --git a/src/template/template-processor.d.ts b/src/template/template-processor.d.ts deleted file mode 100644 index 2594385..0000000 --- a/src/template/template-processor.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Template processor - orchestrates the entire template processing pipeline - */ -import { TemplateEngine } from './template-engine.js'; -import { ContextBuilder } from './context-builder.js'; -import type { ActionInputs } from '../types/inputs.js'; -export declare class TemplateProcessor { - private templateEngine; - private contextBuilder; - constructor(templateEngine: TemplateEngine, contextBuilder: ContextBuilder); - static create(inputs: ActionInputs): TemplateProcessor; - processTemplate(inputs: ActionInputs): Promise; - private writeInstructionFile; -} -//# sourceMappingURL=template-processor.d.ts.map \ No newline at end of file diff --git a/src/template/template-processor.d.ts.map b/src/template/template-processor.d.ts.map deleted file mode 100644 index 367a52f..0000000 --- a/src/template/template-processor.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"template-processor.d.ts","sourceRoot":"","sources":["template-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;gBADd,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc;IAGxC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,iBAAiB;IAIhD,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;YAuB9C,oBAAoB;CAgBnC"} \ No newline at end of file diff --git a/src/template/template-processor.js b/src/template/template-processor.js deleted file mode 100644 index a375894..0000000 --- a/src/template/template-processor.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Template processor - orchestrates the entire template processing pipeline - */ -import { TemplateEngine } from './template-engine.js'; -import { ContextBuilder } from './context-builder.js'; -import { FileUtils } from '../utils/file-utils.js'; -import { logger } from '../utils/logger.js'; -import { PATHS } from '../config/constants.js'; -export class TemplateProcessor { - templateEngine; - contextBuilder; - constructor(templateEngine, contextBuilder) { - this.templateEngine = templateEngine; - this.contextBuilder = contextBuilder; - } - static create(inputs) { - return new TemplateProcessor(TemplateEngine.create(inputs), ContextBuilder.create(inputs)); - } - async processTemplate(inputs) { - try { - logger.info('Starting template processing pipeline', { - templateDirectory: inputs.templateDirectory, - templateName: inputs.templateName, - }); - const context = await this.contextBuilder.buildContext(inputs); - const content = await this.templateEngine.renderTemplate(inputs.templateName, context); - const instructionFilePath = await this.writeInstructionFile(content); - logger.info('Template processing pipeline completed', { - instructionFile: instructionFilePath, - contentLength: content.length, - }); - return instructionFilePath; - } - catch (error) { - logger.error('Template processing pipeline failed', error); - throw error; - } - } - async writeInstructionFile(content) { - try { - await FileUtils.ensureDirectoryExists(PATHS.TEMP_DIR); - await FileUtils.writeFile(PATHS.INSTRUCTION_FILE, content); - logger.info('Instruction file written', { - filePath: PATHS.INSTRUCTION_FILE, - contentLength: content.length, - }); - return PATHS.INSTRUCTION_FILE; - } - catch (error) { - logger.error('Failed to write instruction file', error); - throw error; - } - } -} -//# sourceMappingURL=template-processor.js.map \ No newline at end of file diff --git a/src/template/template-processor.js.map b/src/template/template-processor.js.map deleted file mode 100644 index ff16ac1..0000000 --- a/src/template/template-processor.js.map +++ /dev/null @@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AAC,MAAM;aAC9B,CAAC,CAAC;YAEH,OAAO,mBAAmB,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,OAAe;QAChD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACtD,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;YAE3D,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;gBACtC,QAAQ,EAAE,KAAK,CAAC,gBAAgB;gBAChC,aAAa,EAAE,OAAO,CAAC,MAAM;aAC9B,CAAC,CAAC;YAEH,OAAO,KAAK,CAAC,gBAAgB,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/types/context.d.ts b/src/types/context.d.ts deleted file mode 100644 index 86fa7c9..0000000 --- a/src/types/context.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Context-related type definitions - */ -import { PullRequestFile } from './github'; -export interface GithubRepo { - full_name: string; - name: string; - owner: string; -} -export interface GitRef { - ref: string; - sha: string; - repo: GithubRepo; -} -export interface PRData { - number: number; - title: string; - author: string; - head: GitRef; - base: GitRef; - body: string; - state: string; - changed_files: string; - changed_files_list: Array; - diff_file: string; -} -export interface TemplateContext { - pr?: PRData; - custom?: Record; -} -//# sourceMappingURL=context.d.ts.map \ No newline at end of file diff --git a/src/types/context.d.ts.map b/src/types/context.d.ts.map deleted file mode 100644 index eef6e98..0000000 --- a/src/types/context.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAE9B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B"} \ No newline at end of file diff --git a/src/types/context.js b/src/types/context.js deleted file mode 100644 index ed6e91f..0000000 --- a/src/types/context.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Context-related type definitions - */ -export {}; -//# sourceMappingURL=context.js.map \ No newline at end of file diff --git a/src/types/context.js.map b/src/types/context.js.map deleted file mode 100644 index 3b5f80e..0000000 --- a/src/types/context.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"context.js","sourceRoot":"","sources":["context.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/src/types/github.d.ts b/src/types/github.d.ts deleted file mode 100644 index b10a190..0000000 --- a/src/types/github.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * GitHub API types for PR information extraction - */ -export interface PullRequestInfo { - number: number; - title: string; - body: string | null; - state: string; - user: { - login: string; - }; - head: { - ref: string; - sha: string; - repo: { - full_name: string; - name: string; - owner: { - login: string; - }; - }; - }; - base: { - ref: string; - sha: string; - repo: { - full_name: string; - name: string; - owner: { - login: string; - }; - }; - }; -} -export interface PullRequestFile { - filename: string; - status: string; - additions: number; - deletions: number; - changes: number; -} -export interface PullRequestDiff { - content: string; - size: number; - truncated: boolean; -} -//# sourceMappingURL=github.d.ts.map \ No newline at end of file diff --git a/src/types/github.d.ts.map b/src/types/github.d.ts.map deleted file mode 100644 index 58ed437..0000000 --- a/src/types/github.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["github.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE;YACJ,SAAS,EAAE,MAAM,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE;gBACL,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;KACH,CAAC;IACF,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE;YACJ,SAAS,EAAE,MAAM,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE;gBACL,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB"} \ No newline at end of file diff --git a/src/types/github.js b/src/types/github.js deleted file mode 100644 index 89ceae2..0000000 --- a/src/types/github.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * GitHub API types for PR information extraction - */ -export {}; -//# sourceMappingURL=github.js.map \ No newline at end of file diff --git a/src/types/github.js.map b/src/types/github.js.map deleted file mode 100644 index 8b065b9..0000000 --- a/src/types/github.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"github.js","sourceRoot":"","sources":["github.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/src/types/inputs.d.ts b/src/types/inputs.d.ts deleted file mode 100644 index 0100023..0000000 --- a/src/types/inputs.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Action input types for the Augment Agent with template support - */ -export interface InputField { - envVar: string; - required: boolean; - transform?: (value: string) => any; -} -export interface ActionInputs { - augmentSessionAuth?: string | undefined; - augmentApiToken?: string | undefined; - augmentApiUrl?: string | undefined; - githubToken?: string | undefined; - instruction?: string | undefined; - instructionFile?: string | undefined; - model?: string | undefined; - templateDirectory?: string | undefined; - templateName?: string | undefined; - customContext?: string | undefined; - pullNumber?: number | undefined; - repoName?: string | undefined; - rules?: string[] | undefined; - mcpConfigs?: string[] | undefined; -} -export interface RepoInfo { - owner: string; - repo: string; -} -//# sourceMappingURL=inputs.d.ts.map \ No newline at end of file diff --git a/src/types/inputs.d.ts.map b/src/types/inputs.d.ts.map deleted file mode 100644 index 5c02f2f..0000000 --- a/src/types/inputs.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["inputs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAE3B,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAG3B,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAG9B,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"} \ No newline at end of file diff --git a/src/types/inputs.js b/src/types/inputs.js deleted file mode 100644 index 4d07951..0000000 --- a/src/types/inputs.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Action input types for the Augment Agent with template support - */ -export {}; -//# sourceMappingURL=inputs.js.map \ No newline at end of file diff --git a/src/types/inputs.js.map b/src/types/inputs.js.map deleted file mode 100644 index 3d562f4..0000000 --- a/src/types/inputs.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"inputs.js","sourceRoot":"","sources":["inputs.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/src/utils/file-utils.d.ts b/src/utils/file-utils.d.ts deleted file mode 100644 index af8da4e..0000000 --- a/src/utils/file-utils.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * File system utilities - */ -export declare class FileUtils { - static writeFile(filePath: string, content: string): Promise; - static readFile(filePath: string): Promise; - static validateTemplateFile(templateDir: string, templateName: string): Promise; - static ensureDirectoryExists(dirPath: string): Promise; -} -//# sourceMappingURL=file-utils.d.ts.map \ No newline at end of file diff --git a/src/utils/file-utils.d.ts.map b/src/utils/file-utils.d.ts.map deleted file mode 100644 index e71f932..0000000 --- a/src/utils/file-utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["file-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,qBAAa,SAAS;WACP,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAW3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAY3C,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAwChF,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcnE"} \ No newline at end of file diff --git a/src/utils/file-utils.js b/src/utils/file-utils.js deleted file mode 100644 index 1f4b79b..0000000 --- a/src/utils/file-utils.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * File system utilities - */ -import { promises as fs } from 'node:fs'; -import { resolve } from 'node:path'; -import { TEMPLATE_CONFIG, ERROR } from '../config/constants.js'; -import { logger } from './logger.js'; -export class FileUtils { - static async writeFile(filePath, content) { - try { - logger.debug('Writing file', { filePath, contentLength: content.length }); - await fs.writeFile(filePath, content, 'utf8'); - logger.debug('File written successfully', { filePath }); - } - catch (error) { - logger.error('Failed to write file', error, { filePath }); - throw error; - } - } - static async readFile(filePath) { - try { - logger.debug('Reading file', { filePath }); - const content = await fs.readFile(filePath, 'utf8'); - logger.debug('File read successfully', { filePath, contentLength: content.length }); - return content; - } - catch (error) { - logger.error('Failed to read file', error, { filePath }); - throw error; - } - } - static async validateTemplateFile(templateDir, templateName) { - logger.debug('Validating template file', { templateDir, templateName }); - const templatePath = resolve(templateDir, templateName); - // Security check - ensure template is within template directory - if (!templatePath.startsWith(resolve(templateDir))) { - const message = `${ERROR.TEMPLATE.PATH_OUTSIDE_DIRECTORY}: ${templateName}`; - logger.error(message, undefined, { templateDir, templateName, templatePath }); - throw new Error(message); - } - try { - await fs.access(templatePath); - logger.debug('Template file exists', { templatePath }); - } - catch (error) { - const message = `${ERROR.TEMPLATE.NOT_FOUND}: ${templatePath}`; - logger.error(message, error, { templateDir, templateName, templatePath }); - throw new Error(message); - } - // Check file size - const stats = await fs.stat(templatePath); - if (stats.size > TEMPLATE_CONFIG.MAX_TEMPLATE_SIZE) { - const message = `${ERROR.TEMPLATE.TOO_LARGE}: ${stats.size} bytes`; - logger.error(message, undefined, { - templatePath, - fileSize: stats.size, - maxSize: TEMPLATE_CONFIG.MAX_TEMPLATE_SIZE, - }); - throw new Error(message); - } - logger.debug('Template file validation successful', { - templatePath, - fileSize: stats.size, - }); - return templatePath; - } - static async ensureDirectoryExists(dirPath) { - try { - logger.debug('Ensuring directory exists', { dirPath }); - await fs.mkdir(dirPath, { recursive: true }); - logger.debug('Directory ensured', { dirPath }); - } - catch (error) { - // Ignore error if directory already exists - if (error.code !== 'EEXIST') { - logger.error('Failed to create directory', error, { dirPath }); - throw error; - } - logger.debug('Directory already exists', { dirPath }); - } - } -} -//# sourceMappingURL=file-utils.js.map \ No newline at end of file diff --git a/src/utils/file-utils.js.map b/src/utils/file-utils.js.map deleted file mode 100644 index 37bafa4..0000000 --- a/src/utils/file-utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["file-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,SAAS;IACpB,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,OAAe;QACtD,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1E,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAC9C,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC1D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAgB;QACpC,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC3C,MAAM,OAAO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AAK,CAAC,4BAA4B,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBAC/D,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/src/utils/logger.d.ts b/src/utils/logger.d.ts deleted file mode 100644 index 1d9048a..0000000 --- a/src/utils/logger.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Logging utilities for the Augment Agent - */ -/** - * Structured logger for GitHub Actions - */ -export declare class Logger { - private context; - constructor(context?: string); - /** - * Log debug information - */ - debug(message: string, data?: Record): void; - /** - * Log informational message - */ - info(message: string, data?: Record): void; - /** - * Log warning message - */ - warning(message: string, data?: Record): void; - /** - * Log error message - */ - error(message: string, error?: Error | unknown, data?: Record): void; - /** - * Set a failed status with error message - */ - setFailed(message: string, error?: Error | unknown): void; - /** - * Format log message with context and optional data - */ - private formatMessage; -} -/** - * Default logger instance - */ -export declare const logger: Logger; -//# sourceMappingURL=logger.d.ts.map \ No newline at end of file diff --git a/src/utils/logger.d.ts.map b/src/utils/logger.d.ts.map deleted file mode 100644 index db078eb..0000000 --- a/src/utils/logger.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,GAAE,MAA2B;IAIhD;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK5D;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK3D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK9D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAUrF;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI;IAUzD;;OAEG;IACH,OAAO,CAAC,aAAa;CAUtB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC"} \ No newline at end of file diff --git a/src/utils/logger.js b/src/utils/logger.js deleted file mode 100644 index fb592e0..0000000 --- a/src/utils/logger.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Logging utilities for the Augment Agent - */ -import * as core from '@actions/core'; -import { ACTION_CONFIG } from '../config/constants.js'; -/** - * Structured logger for GitHub Actions - */ -export class Logger { - context; - constructor(context = ACTION_CONFIG.NAME) { - this.context = context; - } - /** - * Log debug information - */ - debug(message, data) { - const logMessage = this.formatMessage(message, data); - core.debug(logMessage); - } - /** - * Log informational message - */ - info(message, data) { - const logMessage = this.formatMessage(message, data); - core.info(logMessage); - } - /** - * Log warning message - */ - warning(message, data) { - const logMessage = this.formatMessage(message, data); - core.warning(logMessage); - } - /** - * Log error message - */ - error(message, error, data) { - const errorData = error instanceof Error - ? { error: error.message, stack: error.stack, ...data } - : { error: String(error), ...data }; - const logMessage = this.formatMessage(message, errorData); - core.error(logMessage); - } - /** - * Set a failed status with error message - */ - setFailed(message, error) { - if (error instanceof Error) { - this.error(message, error); - core.setFailed(`${message}: ${error.message}`); - } - else { - this.error(message, error); - core.setFailed(message); - } - } - /** - * Format log message with context and optional data - */ - formatMessage(message, data) { - const timestamp = new Date().toISOString(); - let formattedMessage = `[${timestamp}] [${this.context}] ${message}`; - if (data && Object.keys(data).length > 0) { - formattedMessage += ` | Data: ${JSON.stringify(data, null, 2)}`; - } - return formattedMessage; - } -} -/** - * Default logger instance - */ -export const logger = new Logger(); -//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/src/utils/logger.js.map b/src/utils/logger.js.map deleted file mode 100644 index c008773..0000000 --- a/src/utils/logger.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,MAAM;IACT,OAAO,CAAS;IAExB,YAAY,UAAkB,aAAa,CAAC,IAAI;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,IAA8B;QACnD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,IAA8B;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,OAAe,EAAE,IAA8B;QACrD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,KAAuB,EAAE,IAA8B;QAC5E,MAAM,SAA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MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC"} \ No newline at end of file diff --git a/src/utils/validation.d.ts b/src/utils/validation.d.ts deleted file mode 100644 index e01382c..0000000 --- a/src/utils/validation.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Input validation utilities - */ -import type { ActionInputs, RepoInfo } from '../types/inputs.js'; -/** - * Validation utilities - */ -export declare class ValidationUtils { - /** - * Validate action inputs from environment variables - */ - static validateInputs(): ActionInputs; - /** - * Parse repository name into owner and repo - */ - static parseRepoName(repoName: string): RepoInfo; -} -//# sourceMappingURL=validation.d.ts.map \ No newline at end of file diff --git a/src/utils/validation.d.ts.map b/src/utils/validation.d.ts.map deleted file mode 100644 index 54e93f9..0000000 --- a/src/utils/validation.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AA0KjE;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,YAAY;IAwCrC;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ;CAqBjD"} \ No newline at end of file diff --git a/src/utils/validation.js b/src/utils/validation.js deleted file mode 100644 index 3f910e9..0000000 --- a/src/utils/validation.js +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Input validation utilities - */ -import { z } from 'zod'; -import { logger } from './logger.js'; -import { ERROR, INPUT_FIELD_MAP } from '../config/constants.js'; -const createJsonStringArraySchema = (invalidTypeMessage, emptyEntryMessage) => z.preprocess(value => { - if (value === undefined || value === null) { - return undefined; - } - if (typeof value === 'string') { - const trimmed = value.trim(); - if (trimmed.length === 0) { - return undefined; - } - try { - return JSON.parse(trimmed); - } - catch { - return value; - } - } - return value; -}, z - .array(z - .string() - .transform(val => val.trim()) - .refine(val => val.length > 0, { message: emptyEntryMessage }), { invalid_type_error: invalidTypeMessage }) - .optional()); -/** - * Zod schema for action inputs validation - */ -const ActionInputsSchema = z - .object({ - augmentSessionAuth: z.string().optional(), - augmentApiToken: z.string().optional(), - augmentApiUrl: z.string().optional(), - githubToken: z.string().optional(), - instruction: z.string().optional(), - instructionFile: z.string().optional(), - model: z.string().optional(), - templateDirectory: z.string().optional(), - templateName: z.string().default('prompt.njk'), - customContext: z.string().optional(), - pullNumber: z.number().int().positive('Pull number must be a positive integer').optional(), - repoName: z - .string() - .regex(/^[^\/]+\/[^\/]+$/, ERROR.INPUT.REPO_FORMAT) - .optional(), - rules: createJsonStringArraySchema('rules must be a JSON array of strings', 'Rule file paths cannot be empty'), - mcpConfigs: createJsonStringArraySchema('mcp_configs must be a JSON array of strings', 'MCP config file paths cannot be empty'), -}) - .refine(data => { - const hasInstruction = data.instruction || data.instructionFile; - const hasTemplate = data.templateDirectory; - return hasInstruction || hasTemplate; -}, { - message: ERROR.INPUT.MISSING_INSTRUCTION_OR_TEMPLATE, - path: ['instruction', 'instructionFile', 'templateDirectory'], -}) - .refine(data => { - const hasInstruction = data.instruction || data.instructionFile; - const hasTemplate = data.templateDirectory; - return !(hasInstruction && hasTemplate); -}, { - message: ERROR.INPUT.CONFLICTING_INSTRUCTION_TEMPLATE, - path: ['instruction', 'instructionFile', 'templateDirectory'], -}) - .refine(data => !(data.instruction && data.instructionFile), { - message: ERROR.INPUT.CONFLICTING_INSTRUCTION_INPUTS, - path: ['instruction', 'instructionFile'], -}) - .refine(data => { - const hasPullNumber = data.pullNumber !== undefined; - const hasRepoName = data.repoName !== undefined; - return hasPullNumber === hasRepoName; -}, { - message: ERROR.INPUT.MISMATCHED_PR_FIELDS, - path: ['pullNumber', 'repoName'], -}) - .refine(data => { - if (!data.customContext) - return true; - try { - JSON.parse(data.customContext); - return true; - } - catch { - return false; - } -}, { - message: ERROR.INPUT.INVALID_CONTEXT_JSON, - path: ['customContext'], -}) - .refine(data => { - const hasSessionAuth = data.augmentSessionAuth; - const hasTokenAuth = data.augmentApiToken && data.augmentApiUrl; - return hasSessionAuth || hasTokenAuth; -}, { - message: 'Either augment_session_auth or both augment_api_token and augment_api_url must be provided', - path: ['augmentSessionAuth', 'augmentApiToken', 'augmentApiUrl'], -}) - .refine(data => { - const hasSessionAuth = data.augmentSessionAuth; - const hasTokenAuth = data.augmentApiToken || data.augmentApiUrl; - return !(hasSessionAuth && hasTokenAuth); -}, { - message: 'Cannot use both augment_session_auth and augment_api_token/augment_api_url simultaneously', - path: ['augmentSessionAuth', 'augmentApiToken', 'augmentApiUrl'], -}) - .refine(data => { - if (!data.augmentSessionAuth) - return true; - try { - JSON.parse(data.augmentSessionAuth); - return true; - } - catch { - return false; - } -}, { - message: 'augment_session_auth must be valid JSON', - path: ['augmentSessionAuth'], -}) - .refine(data => { - if (!data.augmentApiUrl) - return true; - try { - new URL(data.augmentApiUrl); - return true; - } - catch { - return false; - } -}, { - message: 'Augment API URL must be a valid URL', - path: ['augmentApiUrl'], -}); -/** - * Validation utilities - */ -export class ValidationUtils { - /** - * Validate action inputs from environment variables - */ - static validateInputs() { - try { - logger.debug('Reading action inputs from environment variables'); - // Build inputs object from field map - const inputs = Object.fromEntries(Object.entries(INPUT_FIELD_MAP) - .map(([key, fieldDef]) => { - const value = process.env[fieldDef.envVar]; - // Skip optional fields if no value set - if (!fieldDef.required && !value) { - return null; - } - // Apply transformation if defined - const transformedValue = fieldDef.transform && value ? fieldDef.transform(value) : value; - return [key, transformedValue]; - }) - .filter((entry) => entry !== null)); - logger.debug('Validating action inputs'); - const validated = ActionInputsSchema.parse(inputs); - logger.debug('Action inputs validated successfully'); - return validated; - } - catch (error) { - if (error instanceof z.ZodError) { - const errorMessages = error.errors.map(err => `${err.path.join('.')}: ${err.message}`); - const message = `${ERROR.INPUT.INVALID}: ${errorMessages.join(', ')}`; - logger.error(message, error); - throw new Error(message); - } - logger.error('Unexpected validation error', error); - throw error; - } - } - /** - * Parse repository name into owner and repo - */ - static parseRepoName(repoName) { - logger.debug('Parsing repository name', { repoName }); - const parts = repoName.split('/'); - if (parts.length !== 2) { - const message = `${ERROR.INPUT.REPO_FORMAT}: ${repoName}`; - logger.error(message); - throw new Error(message); - } - const [owner, repo] = parts; - if (!owner || !repo) { - const message = `${ERROR.INPUT.REPO_FORMAT}: ${repoName}. Owner and repo cannot be empty`; - logger.error(message); - throw new Error(message); - } - const result = { owner, repo }; - logger.debug('Repository name parsed successfully', result); - return result; - } -} -//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/src/utils/validation.js.map b/src/utils/validation.js.map deleted file mode 100644 index 1d7f25b..0000000 --- a/src/utils/validation.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"validation.js","sourceRoot":"","sources":["validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,2BAA2B,GAAG,CAAC,kBAA0B,EAAE,iBAAyB,EAAE,EAAE,CAC5F,CAAC,CAAC,UAAU,CACV,KAAK,CAAC,EAAE;IACN,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC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tD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC1D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QAED,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,KAAK,QAAQ,kCAAkC,CAAC;YAC1F,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QAED,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"} \ No newline at end of file From d26b0d41bf4021c914eabfa7ba4dc03269578989 Mon Sep 17 00:00:00 2001 From: Justin Xu Date: Thu, 9 Oct 2025 03:36:39 +0000 Subject: [PATCH 3/3] fix import syntax --- src/template/template-engine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template/template-engine.ts b/src/template/template-engine.ts index 4b818d8..a166232 100644 --- a/src/template/template-engine.ts +++ b/src/template/template-engine.ts @@ -2,7 +2,7 @@ * Template engine for rendering Nunjucks templates */ -import * as nunjucks from 'nunjucks'; +import nunjucks from 'nunjucks'; import { resolve } from 'node:path'; import { FileUtils } from '../utils/file-utils.js'; import { logger } from '../utils/logger.js';