@google/gemini-cli 0.0.4 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/commands/extensions/install.js +1 -1
  3. package/dist/src/commands/extensions/install.js.map +1 -1
  4. package/dist/src/commands/extensions/link.js +1 -1
  5. package/dist/src/commands/extensions/link.js.map +1 -1
  6. package/dist/src/commands/extensions/uninstall.js +1 -1
  7. package/dist/src/commands/extensions/uninstall.js.map +1 -1
  8. package/dist/src/config/config.js +1 -4
  9. package/dist/src/config/config.js.map +1 -1
  10. package/dist/src/config/extension.d.ts +8 -2
  11. package/dist/src/config/extension.js +87 -43
  12. package/dist/src/config/extension.js.map +1 -1
  13. package/dist/src/config/settings.js +1 -1
  14. package/dist/src/config/settings.js.map +1 -1
  15. package/dist/src/config/settingsSchema.d.ts +9 -9
  16. package/dist/src/config/settingsSchema.js +9 -9
  17. package/dist/src/config/settingsSchema.js.map +1 -1
  18. package/dist/src/gemini.js +1 -2
  19. package/dist/src/gemini.js.map +1 -1
  20. package/dist/src/generated/git-commit.d.ts +2 -2
  21. package/dist/src/generated/git-commit.js +2 -2
  22. package/dist/src/generated/git-commit.js.map +1 -1
  23. package/dist/src/ui/AppContainer.js +4 -10
  24. package/dist/src/ui/AppContainer.js.map +1 -1
  25. package/dist/src/ui/IdeIntegrationNudge.d.ts +2 -2
  26. package/dist/src/ui/IdeIntegrationNudge.js +2 -1
  27. package/dist/src/ui/IdeIntegrationNudge.js.map +1 -1
  28. package/dist/src/ui/commands/clearCommand.js +1 -1
  29. package/dist/src/ui/commands/clearCommand.js.map +1 -1
  30. package/dist/src/ui/commands/ideCommand.js +1 -1
  31. package/dist/src/ui/commands/ideCommand.js.map +1 -1
  32. package/dist/src/ui/commands/mcpCommand.js +2 -9
  33. package/dist/src/ui/commands/mcpCommand.js.map +1 -1
  34. package/dist/src/ui/components/Composer.js +10 -9
  35. package/dist/src/ui/components/Composer.js.map +1 -1
  36. package/dist/src/ui/components/Composer.test.js +21 -18
  37. package/dist/src/ui/components/Composer.test.js.map +1 -1
  38. package/dist/src/ui/components/HistoryItemDisplay.js +1 -2
  39. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
  40. package/dist/src/ui/components/InputPrompt.d.ts +0 -6
  41. package/dist/src/ui/components/InputPrompt.js +14 -42
  42. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  43. package/dist/src/ui/components/SettingsDialog.test.js +4 -4
  44. package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
  45. package/dist/src/ui/components/messages/ToolGroupMessage.js +5 -7
  46. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
  47. package/dist/src/ui/components/messages/ToolMessage.js +4 -11
  48. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -1
  49. package/dist/src/ui/components/shared/text-buffer.d.ts +0 -6
  50. package/dist/src/ui/components/shared/text-buffer.js +4 -71
  51. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  52. package/dist/src/ui/constants.d.ts +0 -1
  53. package/dist/src/ui/constants.js +0 -1
  54. package/dist/src/ui/constants.js.map +1 -1
  55. package/dist/src/ui/contexts/SessionContext.d.ts +0 -6
  56. package/dist/src/ui/contexts/SessionContext.js +5 -107
  57. package/dist/src/ui/contexts/SessionContext.js.map +1 -1
  58. package/dist/src/ui/contexts/UIStateContext.d.ts +3 -2
  59. package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
  60. package/dist/src/ui/hooks/shellCommandProcessor.js +5 -7
  61. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
  62. package/dist/src/ui/hooks/shellCommandProcessor.test.js +1 -1
  63. package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
  64. package/dist/src/ui/hooks/useGeminiStream.js +5 -2
  65. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  66. package/dist/src/ui/hooks/useStateAndRef.d.ts +1 -1
  67. package/dist/src/ui/hooks/useStateAndRef.js +2 -2
  68. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -1
  69. package/dist/src/ui/types.d.ts +1 -6
  70. package/dist/src/ui/types.js +0 -1
  71. package/dist/src/ui/types.js.map +1 -1
  72. package/dist/src/ui/utils/highlight.d.ts +0 -1
  73. package/dist/src/ui/utils/highlight.js +0 -28
  74. package/dist/src/ui/utils/highlight.js.map +1 -1
  75. package/dist/src/utils/events.d.ts +1 -2
  76. package/dist/src/utils/events.js +0 -1
  77. package/dist/src/utils/events.js.map +1 -1
  78. package/dist/tsconfig.tsbuildinfo +1 -1
  79. package/npm-shrinkwrap.json +7 -22
  80. package/package.json +3 -3
  81. package/dist/src/config/extensions/github.d.ts +0 -25
  82. package/dist/src/config/extensions/github.js +0 -258
  83. package/dist/src/config/extensions/github.js.map +0 -1
  84. package/dist/src/config/extensions/github.test.d.ts +0 -6
  85. package/dist/src/config/extensions/github.test.js +0 -232
  86. package/dist/src/config/extensions/github.test.js.map +0 -1
  87. package/dist/src/config/policy-engine.integration.test.d.ts +0 -6
  88. package/dist/src/config/policy-engine.integration.test.js +0 -270
  89. package/dist/src/config/policy-engine.integration.test.js.map +0 -1
  90. package/dist/src/config/policy.d.ts +0 -8
  91. package/dist/src/config/policy.js +0 -150
  92. package/dist/src/config/policy.js.map +0 -1
  93. package/dist/src/config/policy.test.d.ts +0 -6
  94. package/dist/src/config/policy.test.js +0 -336
  95. package/dist/src/config/policy.test.js.map +0 -1
  96. package/dist/src/ui/components/QueuedMessageDisplay.d.ts +0 -9
  97. package/dist/src/ui/components/QueuedMessageDisplay.js +0 -20
  98. package/dist/src/ui/components/QueuedMessageDisplay.js.map +0 -1
  99. package/dist/src/ui/components/QueuedMessageDisplay.test.d.ts +0 -6
  100. package/dist/src/ui/components/QueuedMessageDisplay.test.js +0 -56
  101. package/dist/src/ui/components/QueuedMessageDisplay.test.js.map +0 -1
  102. package/dist/src/ui/components/messages/WarningMessage.d.ts +0 -11
  103. package/dist/src/ui/components/messages/WarningMessage.js +0 -10
  104. package/dist/src/ui/components/messages/WarningMessage.js.map +0 -1
  105. package/dist/src/ui/contexts/FocusContext.d.ts +0 -7
  106. package/dist/src/ui/contexts/FocusContext.js +0 -9
  107. package/dist/src/ui/contexts/FocusContext.js.map +0 -1
  108. package/dist/src/ui/hooks/useMemoryMonitor.d.ts +0 -13
  109. package/dist/src/ui/hooks/useMemoryMonitor.js +0 -28
  110. package/dist/src/ui/hooks/useMemoryMonitor.js.map +0 -1
  111. package/dist/src/ui/hooks/useMemoryMonitor.test.d.ts +0 -6
  112. package/dist/src/ui/hooks/useMemoryMonitor.test.js +0 -57
  113. package/dist/src/ui/hooks/useMemoryMonitor.test.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@google/gemini-cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.77",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@google/gemini-cli",
9
- "version": "0.0.4",
9
+ "version": "0.0.77",
10
10
  "workspaces": [
11
11
  "packages/*"
12
12
  ],
@@ -34,7 +34,6 @@
34
34
  "eslint-plugin-react-hooks": "^5.2.0",
35
35
  "glob": "^10.4.5",
36
36
  "globals": "^16.0.0",
37
- "google-artifactregistry-auth": "^3.4.0",
38
37
  "json": "^11.0.0",
39
38
  "memfs": "^4.17.2",
40
39
  "mnemonist": "^0.40.3",
@@ -8981,20 +8980,6 @@
8981
8980
  "url": "https://github.com/sponsors/sindresorhus"
8982
8981
  }
8983
8982
  },
8984
- "node_modules/google-artifactregistry-auth": {
8985
- "version": "3.4.0",
8986
- "resolved": "https://registry.npmjs.org/google-artifactregistry-auth/-/google-artifactregistry-auth-3.4.0.tgz",
8987
- "integrity": "sha512-Z2EmP7gbKtTmK5k846tfF7dQqeU2vREIcfCI79FKRTAdkbUZ/BFGJwwTvC2ss0vYSySvK7h6I1JsqBFqIXABBg==",
8988
- "dev": true,
8989
- "license": "Apache-2.0",
8990
- "dependencies": {
8991
- "google-auth-library": "^9.14.0",
8992
- "yargs": "^17.1.1"
8993
- },
8994
- "bin": {
8995
- "artifactregistry-auth": "src/main.js"
8996
- }
8997
- },
8998
8983
  "node_modules/google-auth-library": {
8999
8984
  "version": "9.15.1",
9000
8985
  "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz",
@@ -16294,7 +16279,7 @@
16294
16279
  },
16295
16280
  "packages/a2a-server": {
16296
16281
  "name": "@google/gemini-cli-a2a-server",
16297
- "version": "0.0.4",
16282
+ "version": "0.0.77",
16298
16283
  "dependencies": {
16299
16284
  "@a2a-js/sdk": "^0.3.2",
16300
16285
  "@google-cloud/storage": "^7.16.0",
@@ -16565,7 +16550,7 @@
16565
16550
  },
16566
16551
  "packages/cli": {
16567
16552
  "name": "@google/gemini-cli",
16568
- "version": "0.0.4",
16553
+ "version": "0.0.77",
16569
16554
  "dependencies": {
16570
16555
  "@google/gemini-cli-core": "file:../core",
16571
16556
  "@google/genai": "1.16.0",
@@ -16757,7 +16742,7 @@
16757
16742
  },
16758
16743
  "packages/core": {
16759
16744
  "name": "@google/gemini-cli-core",
16760
- "version": "0.0.4",
16745
+ "version": "0.0.77",
16761
16746
  "dependencies": {
16762
16747
  "@google-cloud/logging": "^11.2.1",
16763
16748
  "@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
@@ -16902,7 +16887,7 @@
16902
16887
  },
16903
16888
  "packages/test-utils": {
16904
16889
  "name": "@google/gemini-cli-test-utils",
16905
- "version": "0.0.4",
16890
+ "version": "0.0.77",
16906
16891
  "license": "Apache-2.0",
16907
16892
  "devDependencies": {
16908
16893
  "typescript": "^5.3.3"
@@ -16913,7 +16898,7 @@
16913
16898
  },
16914
16899
  "packages/vscode-ide-companion": {
16915
16900
  "name": "gemini-cli-vscode-ide-companion",
16916
- "version": "0.0.4",
16901
+ "version": "0.0.77",
16917
16902
  "license": "LICENSE",
16918
16903
  "dependencies": {
16919
16904
  "@modelcontextprotocol/sdk": "^1.15.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/gemini-cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.77",
4
4
  "description": "Gemini CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "npm-shrinkwrap.json"
27
27
  ],
28
28
  "config": {
29
- "sandboxImageUri": "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.0.4"
29
+ "sandboxImageUri": "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.0.77"
30
30
  },
31
31
  "dependencies": {
32
- "@google/gemini-cli-core": "0.0.4",
32
+ "@google/gemini-cli-core": "0.0.77",
33
33
  "@google/genai": "1.16.0",
34
34
  "@iarna/toml": "^2.2.5",
35
35
  "@modelcontextprotocol/sdk": "^1.15.1",
@@ -1,25 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { ExtensionInstallMetadata } from '@google/gemini-cli-core';
7
- import { ExtensionUpdateState } from '../../ui/state/extensions.js';
8
- /**
9
- * Clones a Git repository to a specified local path.
10
- * @param installMetadata The metadata for the extension to install.
11
- * @param destination The destination path to clone the repository to.
12
- */
13
- export declare function cloneFromGit(installMetadata: ExtensionInstallMetadata, destination: string): Promise<void>;
14
- export declare function parseGitHubRepoForReleases(source: string): {
15
- owner: string;
16
- repo: string;
17
- };
18
- export declare function checkForExtensionUpdate(installMetadata: ExtensionInstallMetadata): Promise<ExtensionUpdateState>;
19
- export declare function downloadFromGitHubRelease(installMetadata: ExtensionInstallMetadata, destination: string): Promise<string>;
20
- interface Asset {
21
- name: string;
22
- browser_download_url: string;
23
- }
24
- export declare function findReleaseAsset(assets: Asset[]): Asset | undefined;
25
- export {};
@@ -1,258 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { simpleGit } from 'simple-git';
7
- import { getErrorMessage } from '../../utils/errors.js';
8
- import { ExtensionUpdateState } from '../../ui/state/extensions.js';
9
- import * as os from 'node:os';
10
- import * as https from 'node:https';
11
- import * as fs from 'node:fs';
12
- import * as path from 'node:path';
13
- import { execSync } from 'node:child_process';
14
- function getGitHubToken() {
15
- return process.env['GITHUB_TOKEN'];
16
- }
17
- /**
18
- * Clones a Git repository to a specified local path.
19
- * @param installMetadata The metadata for the extension to install.
20
- * @param destination The destination path to clone the repository to.
21
- */
22
- export async function cloneFromGit(installMetadata, destination) {
23
- try {
24
- const git = simpleGit(destination);
25
- let sourceUrl = installMetadata.source;
26
- const token = getGitHubToken();
27
- if (token) {
28
- try {
29
- const parsedUrl = new URL(sourceUrl);
30
- if (parsedUrl.protocol === 'https:' &&
31
- parsedUrl.hostname === 'github.com') {
32
- if (!parsedUrl.username) {
33
- parsedUrl.username = token;
34
- }
35
- sourceUrl = parsedUrl.toString();
36
- }
37
- }
38
- catch {
39
- // If source is not a valid URL, we don't inject the token.
40
- // We let git handle the source as is.
41
- }
42
- }
43
- await git.clone(sourceUrl, './', ['--depth', '1']);
44
- const remotes = await git.getRemotes(true);
45
- if (remotes.length === 0) {
46
- throw new Error(`Unable to find any remotes for repo ${installMetadata.source}`);
47
- }
48
- const refToFetch = installMetadata.ref || 'HEAD';
49
- await git.fetch(remotes[0].name, refToFetch);
50
- // After fetching, checkout FETCH_HEAD to get the content of the fetched ref.
51
- // This results in a detached HEAD state, which is fine for this purpose.
52
- await git.checkout('FETCH_HEAD');
53
- }
54
- catch (error) {
55
- throw new Error(`Failed to clone Git repository from ${installMetadata.source}`, {
56
- cause: error,
57
- });
58
- }
59
- }
60
- export function parseGitHubRepoForReleases(source) {
61
- // Default to a github repo path, so `source` can be just an org/repo
62
- const parsedUrl = URL.parse(source, 'https://github.com');
63
- // The pathname should be "/owner/repo".
64
- const parts = parsedUrl?.pathname.substring(1).split('/');
65
- if (parts?.length !== 2) {
66
- throw new Error(`Invalid GitHub repository source: ${source}. Expected "owner/repo" or a github repo uri.`);
67
- }
68
- const owner = parts[0];
69
- const repo = parts[1].replace('.git', '');
70
- if (owner.startsWith('git@github.com')) {
71
- throw new Error(`GitHub release-based extensions are not supported for SSH. You must use an HTTPS URI with a personal access token to download releases from private repositories. You can set your personal access token in the GITHUB_TOKEN environment variable and install the extension via SSH.`);
72
- }
73
- return { owner, repo };
74
- }
75
- async function fetchFromGithub(owner, repo, ref) {
76
- const endpoint = ref ? `releases/tags/${ref}` : 'releases/latest';
77
- const url = `https://api.github.com/repos/${owner}/${repo}/${endpoint}`;
78
- return await fetchJson(url);
79
- }
80
- export async function checkForExtensionUpdate(installMetadata) {
81
- if (installMetadata.type !== 'git' &&
82
- installMetadata.type !== 'github-release') {
83
- return ExtensionUpdateState.NOT_UPDATABLE;
84
- }
85
- try {
86
- if (installMetadata.type === 'git') {
87
- const git = simpleGit(installMetadata.source);
88
- const remotes = await git.getRemotes(true);
89
- if (remotes.length === 0) {
90
- console.error('No git remotes found.');
91
- return ExtensionUpdateState.ERROR;
92
- }
93
- const remoteUrl = remotes[0].refs.fetch;
94
- if (!remoteUrl) {
95
- console.error(`No fetch URL found for git remote ${remotes[0].name}.`);
96
- return ExtensionUpdateState.ERROR;
97
- }
98
- // Determine the ref to check on the remote.
99
- const refToCheck = installMetadata.ref || 'HEAD';
100
- const lsRemoteOutput = await git.listRemote([
101
- remotes[0].name,
102
- refToCheck,
103
- ]);
104
- if (typeof lsRemoteOutput !== 'string' || lsRemoteOutput.trim() === '') {
105
- console.error(`Git ref ${refToCheck} not found.`);
106
- return ExtensionUpdateState.ERROR;
107
- }
108
- const remoteHash = lsRemoteOutput.split('\t')[0];
109
- const localHash = await git.revparse(['HEAD']);
110
- if (!remoteHash) {
111
- console.error(`Unable to parse hash from git ls-remote output "${lsRemoteOutput}"`);
112
- return ExtensionUpdateState.ERROR;
113
- }
114
- if (remoteHash === localHash) {
115
- return ExtensionUpdateState.UP_TO_DATE;
116
- }
117
- return ExtensionUpdateState.UPDATE_AVAILABLE;
118
- }
119
- else {
120
- const { source, ref } = installMetadata;
121
- if (!source) {
122
- return ExtensionUpdateState.ERROR;
123
- }
124
- const { owner, repo } = parseGitHubRepoForReleases(source);
125
- const releaseData = await fetchFromGithub(owner, repo, installMetadata.ref);
126
- if (releaseData.tag_name !== ref) {
127
- return ExtensionUpdateState.UPDATE_AVAILABLE;
128
- }
129
- return ExtensionUpdateState.UP_TO_DATE;
130
- }
131
- }
132
- catch (error) {
133
- console.error(`Failed to check for updates for extension "${installMetadata.source}": ${getErrorMessage(error)}`);
134
- return ExtensionUpdateState.ERROR;
135
- }
136
- }
137
- export async function downloadFromGitHubRelease(installMetadata, destination) {
138
- const { source, ref } = installMetadata;
139
- const { owner, repo } = parseGitHubRepoForReleases(source);
140
- try {
141
- const releaseData = await fetchFromGithub(owner, repo, ref);
142
- if (!releaseData ||
143
- !releaseData.assets ||
144
- releaseData.assets.length === 0) {
145
- throw new Error(`No release assets found for ${owner}/${repo} at tag ${ref}`);
146
- }
147
- const asset = findReleaseAsset(releaseData.assets);
148
- if (!asset) {
149
- throw new Error(`No suitable release asset found for platform ${os.platform()}-${os.arch()}`);
150
- }
151
- const downloadedAssetPath = path.join(destination, path.basename(asset.browser_download_url));
152
- await downloadFile(asset.browser_download_url, downloadedAssetPath);
153
- extractFile(downloadedAssetPath, destination);
154
- const files = await fs.promises.readdir(destination);
155
- const extractedDirName = files.find((file) => {
156
- const filePath = path.join(destination, file);
157
- return fs.statSync(filePath).isDirectory();
158
- });
159
- if (extractedDirName) {
160
- const extractedDirPath = path.join(destination, extractedDirName);
161
- const extractedDirFiles = await fs.promises.readdir(extractedDirPath);
162
- for (const file of extractedDirFiles) {
163
- await fs.promises.rename(path.join(extractedDirPath, file), path.join(destination, file));
164
- }
165
- await fs.promises.rmdir(extractedDirPath);
166
- }
167
- await fs.promises.unlink(downloadedAssetPath);
168
- return releaseData.tag_name;
169
- }
170
- catch (error) {
171
- throw new Error(`Failed to download release from ${installMetadata.source}: ${getErrorMessage(error)}`);
172
- }
173
- }
174
- export function findReleaseAsset(assets) {
175
- const platform = os.platform();
176
- const arch = os.arch();
177
- const platformArchPrefix = `${platform}.${arch}.`;
178
- const platformPrefix = `${platform}.`;
179
- // Check for platform + architecture specific asset
180
- const platformArchAsset = assets.find((asset) => asset.name.toLowerCase().startsWith(platformArchPrefix));
181
- if (platformArchAsset) {
182
- return platformArchAsset;
183
- }
184
- // Check for platform specific asset
185
- const platformAsset = assets.find((asset) => asset.name.toLowerCase().startsWith(platformPrefix));
186
- if (platformAsset) {
187
- return platformAsset;
188
- }
189
- // Check for generic asset if only one is available
190
- const genericAsset = assets.find((asset) => !asset.name.toLowerCase().includes('darwin') &&
191
- !asset.name.toLowerCase().includes('linux') &&
192
- !asset.name.toLowerCase().includes('win32'));
193
- if (assets.length === 1) {
194
- return genericAsset;
195
- }
196
- return undefined;
197
- }
198
- async function fetchJson(url) {
199
- const headers = {
200
- 'User-Agent': 'gemini-cli',
201
- };
202
- const token = getGitHubToken();
203
- if (token) {
204
- headers.Authorization = `token ${token}`;
205
- }
206
- return new Promise((resolve, reject) => {
207
- https
208
- .get(url, { headers }, (res) => {
209
- if (res.statusCode !== 200) {
210
- return reject(new Error(`Request failed with status code ${res.statusCode}`));
211
- }
212
- const chunks = [];
213
- res.on('data', (chunk) => chunks.push(chunk));
214
- res.on('end', () => {
215
- const data = Buffer.concat(chunks).toString();
216
- resolve(JSON.parse(data));
217
- });
218
- })
219
- .on('error', reject);
220
- });
221
- }
222
- async function downloadFile(url, dest) {
223
- const headers = {
224
- 'User-agent': 'gemini-cli',
225
- };
226
- const token = getGitHubToken();
227
- if (token) {
228
- headers.Authorization = `token ${token}`;
229
- }
230
- return new Promise((resolve, reject) => {
231
- https
232
- .get(url, { headers }, (res) => {
233
- if (res.statusCode === 302 || res.statusCode === 301) {
234
- downloadFile(res.headers.location, dest).then(resolve).catch(reject);
235
- return;
236
- }
237
- if (res.statusCode !== 200) {
238
- return reject(new Error(`Request failed with status code ${res.statusCode}`));
239
- }
240
- const file = fs.createWriteStream(dest);
241
- res.pipe(file);
242
- file.on('finish', () => file.close(resolve));
243
- })
244
- .on('error', reject);
245
- });
246
- }
247
- function extractFile(file, dest) {
248
- if (file.endsWith('.tar.gz')) {
249
- execSync(`tar -xzf ${file} -C ${dest}`);
250
- }
251
- else if (file.endsWith('.zip')) {
252
- execSync(`unzip ${file} -d ${dest}`);
253
- }
254
- else {
255
- throw new Error(`Unsupported file extension for extraction: ${file}`);
256
- }
257
- }
258
- //# sourceMappingURL=github.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"github.js","sourceRoot":"","sources":["../../../../src/config/extensions/github.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,SAAS,cAAc;IACrB,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,eAAyC,EACzC,WAAmB;IAEnB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC;QACvC,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;QAC/B,IAAI,KAAK,EAAE,CAAC;YACV,IA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,CAAC,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAqB,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,IAAY;IAC7C,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,QAAQ,CAAC,YAAY,IAAI,OAAO,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;SAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,QAAQ,CAAC,SAAS,IAAI,OAAO,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,8CAA8C,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- export {};
@@ -1,232 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
- import { checkForExtensionUpdate, cloneFromGit, findReleaseAsset, parseGitHubRepoForReleases, } from './github.js';
8
- import { simpleGit } from 'simple-git';
9
- import { ExtensionUpdateState } from '../../ui/state/extensions.js';
10
- const mockPlatform = vi.hoisted(() => vi.fn());
11
- const mockArch = vi.hoisted(() => vi.fn());
12
- vi.mock('node:os', async (importOriginal) => {
13
- const actual = await importOriginal();
14
- return {
15
- ...actual,
16
- platform: mockPlatform,
17
- arch: mockArch,
18
- };
19
- });
20
- vi.mock('simple-git');
21
- describe('git extension helpers', () => {
22
- afterEach(() => {
23
- vi.restoreAllMocks();
24
- });
25
- describe('cloneFromGit', () => {
26
- const mockGit = {
27
- clone: vi.fn(),
28
- getRemotes: vi.fn(),
29
- fetch: vi.fn(),
30
- checkout: vi.fn(),
31
- };
32
- beforeEach(() => {
33
- vi.mocked(simpleGit).mockReturnValue(mockGit);
34
- });
35
- it('should clone, fetch and checkout a repo', async () => {
36
- const installMetadata = {
37
- source: 'http://my-repo.com',
38
- ref: 'my-ref',
39
- type: 'git',
40
- };
41
- const destination = '/dest';
42
- mockGit.getRemotes.mockResolvedValue([
43
- { name: 'origin', refs: { fetch: 'http://my-repo.com' } },
44
- ]);
45
- await cloneFromGit(installMetadata, destination);
46
- expect(mockGit.clone).toHaveBeenCalledWith('http://my-repo.com', './', [
47
- '--depth',
48
- '1',
49
- ]);
50
- expect(mockGit.getRemotes).toHaveBeenCalledWith(true);
51
- expect(mockGit.fetch).toHaveBeenCalledWith('origin', 'my-ref');
52
- expect(mockGit.checkout).toHaveBeenCalledWith('FETCH_HEAD');
53
- });
54
- it('should use HEAD if ref is not provided', async () => {
55
- const installMetadata = {
56
- source: 'http://my-repo.com',
57
- type: 'git',
58
- };
59
- const destination = '/dest';
60
- mockGit.getRemotes.mockResolvedValue([
61
- { name: 'origin', refs: { fetch: 'http://my-repo.com' } },
62
- ]);
63
- await cloneFromGit(installMetadata, destination);
64
- expect(mockGit.fetch).toHaveBeenCalledWith('origin', 'HEAD');
65
- });
66
- it('should throw if no remotes are found', async () => {
67
- const installMetadata = {
68
- source: 'http://my-repo.com',
69
- type: 'git',
70
- };
71
- const destination = '/dest';
72
- mockGit.getRemotes.mockResolvedValue([]);
73
- await expect(cloneFromGit(installMetadata, destination)).rejects.toThrow('Failed to clone Git repository from http://my-repo.com');
74
- });
75
- it('should throw on clone error', async () => {
76
- const installMetadata = {
77
- source: 'http://my-repo.com',
78
- type: 'git',
79
- };
80
- const destination = '/dest';
81
- mockGit.clone.mockRejectedValue(new Error('clone failed'));
82
- await expect(cloneFromGit(installMetadata, destination)).rejects.toThrow('Failed to clone Git repository from http://my-repo.com');
83
- });
84
- });
85
- describe('checkForExtensionUpdate', () => {
86
- const mockGit = {
87
- getRemotes: vi.fn(),
88
- listRemote: vi.fn(),
89
- revparse: vi.fn(),
90
- };
91
- beforeEach(() => {
92
- vi.mocked(simpleGit).mockReturnValue(mockGit);
93
- });
94
- it('should return NOT_UPDATABLE for non-git extensions', async () => {
95
- const installMetadata = {
96
- type: 'local',
97
- source: '',
98
- };
99
- const result = await checkForExtensionUpdate(installMetadata);
100
- expect(result).toBe(ExtensionUpdateState.NOT_UPDATABLE);
101
- });
102
- it('should return ERROR if no remotes found', async () => {
103
- const installMetadata = {
104
- type: 'git',
105
- source: '',
106
- };
107
- mockGit.getRemotes.mockResolvedValue([]);
108
- const result = await checkForExtensionUpdate(installMetadata);
109
- expect(result).toBe(ExtensionUpdateState.ERROR);
110
- });
111
- it('should return UPDATE_AVAILABLE when remote hash is different', async () => {
112
- const installMetadata = {
113
- type: 'git',
114
- source: '/ext',
115
- };
116
- mockGit.getRemotes.mockResolvedValue([
117
- { name: 'origin', refs: { fetch: 'http://my-repo.com' } },
118
- ]);
119
- mockGit.listRemote.mockResolvedValue('remote-hash\tHEAD');
120
- mockGit.revparse.mockResolvedValue('local-hash');
121
- const result = await checkForExtensionUpdate(installMetadata);
122
- expect(result).toBe(ExtensionUpdateState.UPDATE_AVAILABLE);
123
- });
124
- it('should return UP_TO_DATE when remote and local hashes are the same', async () => {
125
- const installMetadata = {
126
- type: 'git',
127
- source: '/ext',
128
- };
129
- mockGit.getRemotes.mockResolvedValue([
130
- { name: 'origin', refs: { fetch: 'http://my-repo.com' } },
131
- ]);
132
- mockGit.listRemote.mockResolvedValue('same-hash\tHEAD');
133
- mockGit.revparse.mockResolvedValue('same-hash');
134
- const result = await checkForExtensionUpdate(installMetadata);
135
- expect(result).toBe(ExtensionUpdateState.UP_TO_DATE);
136
- });
137
- it('should return ERROR on git error', async () => {
138
- const installMetadata = {
139
- type: 'git',
140
- source: '/ext',
141
- };
142
- mockGit.getRemotes.mockRejectedValue(new Error('git error'));
143
- const result = await checkForExtensionUpdate(installMetadata);
144
- expect(result).toBe(ExtensionUpdateState.ERROR);
145
- });
146
- });
147
- describe('findReleaseAsset', () => {
148
- const assets = [
149
- { name: 'darwin.arm64.extension.tar.gz', browser_download_url: 'url1' },
150
- { name: 'darwin.x64.extension.tar.gz', browser_download_url: 'url2' },
151
- { name: 'linux.x64.extension.tar.gz', browser_download_url: 'url3' },
152
- { name: 'win32.x64.extension.tar.gz', browser_download_url: 'url4' },
153
- { name: 'extension-generic.tar.gz', browser_download_url: 'url5' },
154
- ];
155
- it('should find asset matching platform and architecture', () => {
156
- mockPlatform.mockReturnValue('darwin');
157
- mockArch.mockReturnValue('arm64');
158
- const result = findReleaseAsset(assets);
159
- expect(result).toEqual(assets[0]);
160
- });
161
- it('should find asset matching platform if arch does not match', () => {
162
- mockPlatform.mockReturnValue('linux');
163
- mockArch.mockReturnValue('arm64');
164
- const result = findReleaseAsset(assets);
165
- expect(result).toEqual(assets[2]);
166
- });
167
- it('should return undefined if no matching asset is found', () => {
168
- mockPlatform.mockReturnValue('sunos');
169
- mockArch.mockReturnValue('x64');
170
- const result = findReleaseAsset(assets);
171
- expect(result).toBeUndefined();
172
- });
173
- it('should find generic asset if it is the only one', () => {
174
- const singleAsset = [
175
- { name: 'extension.tar.gz', browser_download_url: 'url' },
176
- ];
177
- mockPlatform.mockReturnValue('darwin');
178
- mockArch.mockReturnValue('arm64');
179
- const result = findReleaseAsset(singleAsset);
180
- expect(result).toEqual(singleAsset[0]);
181
- });
182
- it('should return undefined if multiple generic assets exist', () => {
183
- const multipleGenericAssets = [
184
- { name: 'extension-1.tar.gz', browser_download_url: 'url1' },
185
- { name: 'extension-2.tar.gz', browser_download_url: 'url2' },
186
- ];
187
- mockPlatform.mockReturnValue('darwin');
188
- mockArch.mockReturnValue('arm64');
189
- const result = findReleaseAsset(multipleGenericAssets);
190
- expect(result).toBeUndefined();
191
- });
192
- });
193
- describe('parseGitHubRepoForReleases', () => {
194
- it('should parse owner and repo from a full GitHub URL', () => {
195
- const source = 'https://github.com/owner/repo.git';
196
- const { owner, repo } = parseGitHubRepoForReleases(source);
197
- expect(owner).toBe('owner');
198
- expect(repo).toBe('repo');
199
- });
200
- it('should parse owner and repo from a full GitHub UR without .git', () => {
201
- const source = 'https://github.com/owner/repo';
202
- const { owner, repo } = parseGitHubRepoForReleases(source);
203
- expect(owner).toBe('owner');
204
- expect(repo).toBe('repo');
205
- });
206
- it('should fail on a GitHub SSH URL', () => {
207
- const source = 'git@github.com:owner/repo.git';
208
- expect(() => parseGitHubRepoForReleases(source)).toThrow('GitHub release-based extensions are not supported for SSH. You must use an HTTPS URI with a personal access token to download releases from private repositories. You can set your personal access token in the GITHUB_TOKEN environment variable and install the extension via SSH.');
209
- });
210
- it('should parse owner and repo from a shorthand string', () => {
211
- const source = 'owner/repo';
212
- const { owner, repo } = parseGitHubRepoForReleases(source);
213
- expect(owner).toBe('owner');
214
- expect(repo).toBe('repo');
215
- });
216
- it('should handle .git suffix in repo name', () => {
217
- const source = 'owner/repo.git';
218
- const { owner, repo } = parseGitHubRepoForReleases(source);
219
- expect(owner).toBe('owner');
220
- expect(repo).toBe('repo');
221
- });
222
- it('should throw error for invalid source format', () => {
223
- const source = 'invalid-format';
224
- expect(() => parseGitHubRepoForReleases(source)).toThrow('Invalid GitHub repository source: invalid-format. Expected "owner/repo" or a github repo uri.');
225
- });
226
- it('should throw error for source with too many parts', () => {
227
- const source = 'https://github.com/owner/repo/extra';
228
- expect(() => parseGitHubRepoForReleases(source)).toThrow('Invalid GitHub repository source: https://github.com/owner/repo/extra. Expected "owner/repo" or a github repo uri.');
229
- });
230
- });
231
- });
232
- //# sourceMappingURL=github.test.js.map