From 32fca2c43b82561c99a17476c33439b5a38a6d59 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 04:55:06 +0000 Subject: [PATCH 1/3] Initial plan From c097e0e385ce30b36b333c4b070a6e429839595d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 04:57:40 +0000 Subject: [PATCH 2/3] feat: configure AI secrets and polish code Co-authored-by: asperpharma <252395498+asperpharma@users.noreply.github.com> --- .eslintrc.json | 42 ++++++++--------- .github/workflows/datadog-synthetics.yml | 20 ++++++++ CHANGELOG.md | 6 ++- README.md | 10 ++-- extension.js | 15 +++--- test/extension.test.js | 17 ++++--- test/index.js | 8 ++-- vsc-extension-quickstart.md | 59 +++++++++++++++--------- 8 files changed, 107 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/datadog-synthetics.yml diff --git a/.eslintrc.json b/.eslintrc.json index 02509e2..52f9f8d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,23 +1,23 @@ { - "env": { - "browser": false, - "commonjs": true, - "es6": true, - "node": true + "env": { + "browser": false, + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true }, - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "sourceType": "module" - }, - "rules": { - "no-const-assign": "warn", - "no-this-before-super": "warn", - "no-undef": "warn", - "no-unreachable": "warn", - "no-unused-vars": "warn", - "constructor-super": "warn", - "valid-typeof": "warn" - } -} \ No newline at end of file + "sourceType": "module" + }, + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "warn", + "no-unreachable": "warn", + "no-unused-vars": "warn", + "constructor-super": "warn", + "valid-typeof": "warn" + } +} diff --git a/.github/workflows/datadog-synthetics.yml b/.github/workflows/datadog-synthetics.yml new file mode 100644 index 0000000..9856bdc --- /dev/null +++ b/.github/workflows/datadog-synthetics.yml @@ -0,0 +1,20 @@ +name: Datadog Synthetics CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + synthetics-ci: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run Datadog Synthetics tests + uses: datadog/synthetics-ci-github-action@v0.1.0 + with: + api_key: ${{ secrets.DATADOG_API_KEY }} + app_key: ${{ secrets.DATADOG_APP_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ba0392..ae00f26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,8 @@ ### Bug Fixes -- **syntax:** avoid generating import statements when selecting text which is not a valid variable name +- **syntax:** avoid generating import statements when selecting text which is + not a valid variable name ### Improvements @@ -54,7 +55,8 @@ ### Bug Fixes -- **syntax:** avoid generating import statements when selecting text which contains "\n" +- **syntax:** avoid generating import statements when selecting text which + contains "\n" ### Improvements diff --git a/README.md b/README.md index b8ef64e..77830a0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Python Path -This extension adds a set of tools which help you generate internal import statements in a python project. +This extension adds a set of tools which help you generate internal import +statements in a python project. ## Features @@ -19,8 +20,8 @@ Copies the full module name of the current file to the clipboard. ### Generate import statement -Copies an import statement for the selected text to the clipboard. -In case of a simple selection, the generated statement will be: +Copies an import statement for the selected text to the clipboard. In case of a +simple selection, the generated statement will be: ``` from module.name import selected_text @@ -41,7 +42,8 @@ from module.name import ( ## Miscellaneous -Inspiration from the Sublime Package: https://github.com/pokidovea/copy_python_path +Inspiration from the Sublime Package: +https://github.com/pokidovea/copy_python_path ## Credits diff --git a/extension.js b/extension.js index 8ada7b3..75d29a3 100644 --- a/extension.js +++ b/extension.js @@ -14,10 +14,9 @@ function getPythonPath(filePath) { const fileName = splittedPath.pop(); // removing extension - let pythonPath = - fileName !== "__init__.py" - ? [fileName.substring(0, fileName.lastIndexOf("."))] - : []; + let pythonPath = fileName !== "__init__.py" + ? [fileName.substring(0, fileName.lastIndexOf("."))] + : []; while ( splittedPath.length > 0 && @@ -36,8 +35,8 @@ function copyPythonPath(uri) { : vscode.window.activeTextEditor.document.fileName; const pythonPath = getPythonPath(filePath); const selections = vscode.window.activeTextEditor.selections - .map(s => vscode.window.activeTextEditor.document.getText(s)) - .filter(s => !!s && !s.includes("\n") && !s.trim().includes(" ")); + .map((s) => vscode.window.activeTextEditor.document.getText(s)) + .filter((s) => !!s && !s.includes("\n") && !s.trim().includes(" ")); if (pythonPath && selections.length > 0) { const importStatement = generateImportStatement(pythonPath, selections); vscode.env.clipboard.writeText(importStatement); @@ -57,14 +56,14 @@ function generateImportStatement(pythonPath, selections) { const selection = selections[0].trim(); return `from ${pythonPath} import ${selection}`; } - const selection = selections.map(s => `\t${s.trim()},`).join("\n"); + const selection = selections.map((s) => `\t${s.trim()},`).join("\n"); return `from ${pythonPath} import (\n${selection}\n)`; } function activate(context) { let disposable = vscode.commands.registerCommand( "extension.copyPythonPath", - copyPythonPath + copyPythonPath, ); context.subscriptions.push(disposable); } diff --git a/test/extension.test.js b/test/extension.test.js index f9e915b..d5f3bce 100644 --- a/test/extension.test.js +++ b/test/extension.test.js @@ -6,7 +6,7 @@ // // The module 'assert' provides assertion methods from node -const assert = require('assert'); +const assert = require("assert"); // You can import and use all API from the 'vscode' module // as well as import your extension to test it @@ -14,11 +14,10 @@ const assert = require('assert'); // const myExtension = require('../extension'); // Defines a Mocha test suite to group tests of similar kind together -suite("Extension Tests", function() { - - // Defines a Mocha unit test - test("Something 1", function() { - assert.equal(-1, [1, 2, 3].indexOf(5)); - assert.equal(-1, [1, 2, 3].indexOf(0)); - }); -}); \ No newline at end of file +suite("Extension Tests", function () { + // Defines a Mocha unit test + test("Something 1", function () { + assert.equal(-1, [1, 2, 3].indexOf(5)); + assert.equal(-1, [1, 2, 3].indexOf(0)); + }); +}); diff --git a/test/index.js b/test/index.js index a0c8b63..be47a56 100644 --- a/test/index.js +++ b/test/index.js @@ -10,13 +10,13 @@ // to report the results back to the caller. When the tests are finished, return // a possible error to the callback or null if none. -const testRunner = require('vscode/lib/testrunner'); +const testRunner = require("vscode/lib/testrunner"); // You can directly control Mocha options by uncommenting the following lines // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info testRunner.configure({ - ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.) - useColors: true // colored output from test results + ui: "tdd", // the TDD UI is being used in extension.test.js (suite, test, etc.) + useColors: true, // colored output from test results }); -module.exports = testRunner; \ No newline at end of file +module.exports = testRunner; diff --git a/vsc-extension-quickstart.md b/vsc-extension-quickstart.md index ac7079a..13cffa5 100644 --- a/vsc-extension-quickstart.md +++ b/vsc-extension-quickstart.md @@ -1,33 +1,48 @@ # Welcome to your VS Code Extension ## What's in the folder -* This folder contains all of the files necessary for your extension. -* `package.json` - this is the manifest file in which you declare your extension and command. -The sample plugin registers a command and defines its title and command name. With this information -VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. -* `extension.js` - this is the main file where you will provide the implementation of your command. -The file exports one function, `activate`, which is called the very first time your extension is -activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. -We pass the function containing the implementation of the command as the second parameter to -`registerCommand`. + +- This folder contains all of the files necessary for your extension. +- `package.json` - this is the manifest file in which you declare your extension + and command. The sample plugin registers a command and defines its title and + command name. With this information VS Code can show the command in the + command palette. It doesn’t yet need to load the plugin. +- `extension.js` - this is the main file where you will provide the + implementation of your command. The file exports one function, `activate`, + which is called the very first time your extension is activated (in this case + by executing the command). Inside the `activate` function we call + `registerCommand`. We pass the function containing the implementation of the + command as the second parameter to `registerCommand`. ## Get up and running straight away -* Press `F5` to open a new window with your extension loaded. -* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. -* Set breakpoints in your code inside `extension.js` to debug your extension. -* Find output from your extension in the debug console. + +- Press `F5` to open a new window with your extension loaded. +- Run your command from the command palette by pressing (`Ctrl+Shift+P` or + `Cmd+Shift+P` on Mac) and typing `Hello World`. +- Set breakpoints in your code inside `extension.js` to debug your extension. +- Find output from your extension in the debug console. ## Make changes -* You can relaunch the extension from the debug toolbar after changing code in `extension.js`. -* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. + +- You can relaunch the extension from the debug toolbar after changing code in + `extension.js`. +- You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your + extension to load your changes. ## Explore the API -* You can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`. + +- You can open the full set of our API when you open the file + `node_modules/vscode/vscode.d.ts`. ## Run tests -* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`. -* Press `F5` to run the tests in a new window with your extension loaded. -* See the output of the test result in the debug console. -* Make changes to `test/extension.test.js` or create new test files inside the `test` folder. - * By convention, the test runner will only consider files matching the name pattern `**.test.js`. - * You can create folders inside the `test` folder to structure your tests any way you want. + +- Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the + launch configuration dropdown pick `Launch Tests`. +- Press `F5` to run the tests in a new window with your extension loaded. +- See the output of the test result in the debug console. +- Make changes to `test/extension.test.js` or create new test files inside the + `test` folder. + - By convention, the test runner will only consider files matching the name + pattern `**.test.js`. + - You can create folders inside the `test` folder to structure your tests any + way you want. From 7017d6b6a1f22108dbca3f6c9c02a3be59f3f95b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 04:59:31 +0000 Subject: [PATCH 3/3] security: add explicit permissions to workflow Co-authored-by: asperpharma <252395498+asperpharma@users.noreply.github.com> --- .github/workflows/datadog-synthetics.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/datadog-synthetics.yml b/.github/workflows/datadog-synthetics.yml index 9856bdc..d97d930 100644 --- a/.github/workflows/datadog-synthetics.yml +++ b/.github/workflows/datadog-synthetics.yml @@ -9,6 +9,8 @@ on: jobs: synthetics-ci: runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout code uses: actions/checkout@v3