@rdmind/rdmind 0.0.9-alpha.2 → 0.0.11
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.
- package/dist/package.json +2 -2
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +1 -1
- package/dist/src/config/settingsSchema.js +1 -1
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +0 -4
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.test.js +0 -1
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
- package/dist/src/services/McpPromptLoader.js +1 -1
- package/dist/src/services/McpPromptLoader.js.map +1 -1
- package/dist/src/services/prompt-processors/atFileProcessor.js +1 -1
- package/dist/src/services/prompt-processors/atFileProcessor.js.map +1 -1
- package/dist/src/ui/App.js +2 -11
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/docsCommand.js +1 -1
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +1 -1
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/Tips.js +1 -1
- package/dist/src/ui/components/Tips.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +1 -1
- package/dist/src/ui/components/subagents/create/CreationSummary.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +1 -5
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useDialogClose.d.ts +0 -2
- package/dist/src/ui/hooks/useDialogClose.js +0 -5
- package/dist/src/ui/hooks/useDialogClose.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/utils/installationInfo.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/ui/commands/privacyCommand.d.ts +0 -7
- package/dist/src/ui/commands/privacyCommand.js +0 -16
- package/dist/src/ui/commands/privacyCommand.js.map +0 -1
- package/dist/src/ui/commands/setupGithubCommand.d.ts +0 -9
- package/dist/src/ui/commands/setupGithubCommand.js +0 -154
- package/dist/src/ui/commands/setupGithubCommand.js.map +0 -1
- package/dist/src/ui/commands/setupGithubCommand.test.d.ts +0 -6
- package/dist/src/ui/commands/setupGithubCommand.test.js +0 -167
- package/dist/src/ui/commands/setupGithubCommand.test.js.map +0 -1
- package/dist/src/ui/hooks/usePrivacySettings.d.ts +0 -16
- package/dist/src/ui/hooks/usePrivacySettings.js +0 -119
- package/dist/src/ui/hooks/usePrivacySettings.js.map +0 -1
- package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +0 -6
- package/dist/src/ui/hooks/usePrivacySettings.test.js +0 -154
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +0 -1
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +0 -12
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +0 -41
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +0 -1
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +0 -10
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +0 -18
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +0 -1
- package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +0 -10
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js +0 -18
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +0 -1
- package/dist/src/ui/privacy/PrivacyNotice.d.ts +0 -12
- package/dist/src/ui/privacy/PrivacyNotice.js +0 -25
- package/dist/src/ui/privacy/PrivacyNotice.js.map +0 -1
- package/dist/src/utils/gitUtils.d.ts +0 -30
- package/dist/src/utils/gitUtils.js +0 -89
- package/dist/src/utils/gitUtils.js.map +0 -1
- package/dist/src/utils/gitUtils.test.d.ts +0 -6
- package/dist/src/utils/gitUtils.test.js +0 -113
- package/dist/src/utils/gitUtils.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdmind/rdmind",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "RDMind",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@google/genai": "1.9.0",
|
|
33
33
|
"@iarna/toml": "^2.2.5",
|
|
34
|
-
"@rdmind/rdmind-core": "^0.0.
|
|
34
|
+
"@rdmind/rdmind-core": "^0.0.11",
|
|
35
35
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
36
36
|
"@types/update-notifier": "^6.0.8",
|
|
37
37
|
"command-exists": "^1.2.9",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { CommandKind } from './types.js';
|
|
7
|
-
export const privacyCommand = {
|
|
8
|
-
name: 'privacy',
|
|
9
|
-
description: '隐私声明',
|
|
10
|
-
kind: CommandKind.BUILT_IN,
|
|
11
|
-
action: () => ({
|
|
12
|
-
type: 'dialog',
|
|
13
|
-
dialog: 'privacy',
|
|
14
|
-
}),
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=privacyCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"privacyCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/privacyCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,WAAW,CAAC,QAAQ;IAC1B,MAAM,EAAE,GAA2B,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,SAAS;KAClB,CAAC;CACH,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { SlashCommand } from './types.js';
|
|
7
|
-
export declare const GITHUB_WORKFLOW_PATHS: string[];
|
|
8
|
-
export declare function updateGitignore(gitRepoRoot: string): Promise<void>;
|
|
9
|
-
export declare const setupGithubCommand: SlashCommand;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import * as fs from 'node:fs';
|
|
8
|
-
import { Writable } from 'node:stream';
|
|
9
|
-
import { ProxyAgent } from 'undici';
|
|
10
|
-
import { getGitRepoRoot, getLatestGitHubRelease, isGitHubRepository, getGitHubRepoInfo, } from '../../utils/gitUtils.js';
|
|
11
|
-
import { CommandKind } from './types.js';
|
|
12
|
-
import { getUrlOpenCommand } from '../../ui/utils/commandUtils.js';
|
|
13
|
-
export const GITHUB_WORKFLOW_PATHS = [
|
|
14
|
-
'gemini-dispatch/gemini-dispatch.yml',
|
|
15
|
-
'gemini-assistant/gemini-invoke.yml',
|
|
16
|
-
'issue-triage/gemini-triage.yml',
|
|
17
|
-
'issue-triage/gemini-scheduled-triage.yml',
|
|
18
|
-
'pr-review/gemini-review.yml',
|
|
19
|
-
];
|
|
20
|
-
// Generate OS-specific commands to open the GitHub pages needed for setup.
|
|
21
|
-
function getOpenUrlsCommands(readmeUrl) {
|
|
22
|
-
// Determine the OS-specific command to open URLs, ex: 'open', 'xdg-open', etc
|
|
23
|
-
const openCmd = getUrlOpenCommand();
|
|
24
|
-
// Build a list of URLs to open
|
|
25
|
-
const urlsToOpen = [readmeUrl];
|
|
26
|
-
const repoInfo = getGitHubRepoInfo();
|
|
27
|
-
if (repoInfo) {
|
|
28
|
-
urlsToOpen.push(`https://github.com/${repoInfo.owner}/${repoInfo.repo}/settings/secrets/actions`);
|
|
29
|
-
}
|
|
30
|
-
// Create and join the individual commands
|
|
31
|
-
const commands = urlsToOpen.map((url) => `${openCmd} "${url}"`);
|
|
32
|
-
return commands;
|
|
33
|
-
}
|
|
34
|
-
// Add Gemini CLI specific entries to .gitignore file
|
|
35
|
-
export async function updateGitignore(gitRepoRoot) {
|
|
36
|
-
const gitignoreEntries = ['.gemini/', 'gha-creds-*.json'];
|
|
37
|
-
const gitignorePath = path.join(gitRepoRoot, '.gitignore');
|
|
38
|
-
try {
|
|
39
|
-
// Check if .gitignore exists and read its content
|
|
40
|
-
let existingContent = '';
|
|
41
|
-
let fileExists = true;
|
|
42
|
-
try {
|
|
43
|
-
existingContent = await fs.promises.readFile(gitignorePath, 'utf8');
|
|
44
|
-
}
|
|
45
|
-
catch (_error) {
|
|
46
|
-
// File doesn't exist
|
|
47
|
-
fileExists = false;
|
|
48
|
-
}
|
|
49
|
-
if (!fileExists) {
|
|
50
|
-
// Create new .gitignore file with the entries
|
|
51
|
-
const contentToWrite = gitignoreEntries.join('\n') + '\n';
|
|
52
|
-
await fs.promises.writeFile(gitignorePath, contentToWrite);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
// Check which entries are missing
|
|
56
|
-
const missingEntries = gitignoreEntries.filter((entry) => !existingContent
|
|
57
|
-
.split(/\r?\n/)
|
|
58
|
-
.some((line) => line.split('#')[0].trim() === entry));
|
|
59
|
-
if (missingEntries.length > 0) {
|
|
60
|
-
const contentToAdd = '\n' + missingEntries.join('\n') + '\n';
|
|
61
|
-
await fs.promises.appendFile(gitignorePath, contentToAdd);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.debug('Failed to update .gitignore:', error);
|
|
67
|
-
// Continue without failing the whole command
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export const setupGithubCommand = {
|
|
71
|
-
name: 'setup-github',
|
|
72
|
-
description: '设置 GitHub Actions',
|
|
73
|
-
kind: CommandKind.BUILT_IN,
|
|
74
|
-
action: async (context) => {
|
|
75
|
-
const abortController = new AbortController();
|
|
76
|
-
if (!isGitHubRepository()) {
|
|
77
|
-
throw new Error('Unable to determine the GitHub repository. /setup-github must be run from a git repository.');
|
|
78
|
-
}
|
|
79
|
-
// Find the root directory of the repo
|
|
80
|
-
let gitRepoRoot;
|
|
81
|
-
try {
|
|
82
|
-
gitRepoRoot = getGitRepoRoot();
|
|
83
|
-
}
|
|
84
|
-
catch (_error) {
|
|
85
|
-
console.debug(`Failed to get git repo root:`, _error);
|
|
86
|
-
throw new Error('Unable to determine the GitHub repository. /setup-github must be run from a git repository.');
|
|
87
|
-
}
|
|
88
|
-
// Get the latest release tag from GitHub
|
|
89
|
-
const proxy = context?.services?.config?.getProxy();
|
|
90
|
-
const releaseTag = await getLatestGitHubRelease(proxy);
|
|
91
|
-
const readmeUrl = `https://github.com/google-github-actions/run-gemini-cli/blob/${releaseTag}/README.md#quick-start`;
|
|
92
|
-
// Create the .github/workflows directory to download the files into
|
|
93
|
-
const githubWorkflowsDir = path.join(gitRepoRoot, '.github', 'workflows');
|
|
94
|
-
try {
|
|
95
|
-
await fs.promises.mkdir(githubWorkflowsDir, { recursive: true });
|
|
96
|
-
}
|
|
97
|
-
catch (_error) {
|
|
98
|
-
console.debug(`Failed to create ${githubWorkflowsDir} directory:`, _error);
|
|
99
|
-
throw new Error(`Unable to create ${githubWorkflowsDir} directory. Do you have file permissions in the current directory?`);
|
|
100
|
-
}
|
|
101
|
-
// Download each workflow in parallel - there aren't enough files to warrant
|
|
102
|
-
// a full workerpool model here.
|
|
103
|
-
const downloads = [];
|
|
104
|
-
for (const workflow of GITHUB_WORKFLOW_PATHS) {
|
|
105
|
-
downloads.push((async () => {
|
|
106
|
-
const endpoint = `https://raw.githubusercontent.com/google-github-actions/run-gemini-cli/refs/tags/${releaseTag}/examples/workflows/${workflow}`;
|
|
107
|
-
const response = await fetch(endpoint, {
|
|
108
|
-
method: 'GET',
|
|
109
|
-
dispatcher: proxy ? new ProxyAgent(proxy) : undefined,
|
|
110
|
-
signal: AbortSignal.any([
|
|
111
|
-
AbortSignal.timeout(30_000),
|
|
112
|
-
abortController.signal,
|
|
113
|
-
]),
|
|
114
|
-
});
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
throw new Error(`Invalid response code downloading ${endpoint}: ${response.status} - ${response.statusText}`);
|
|
117
|
-
}
|
|
118
|
-
const body = response.body;
|
|
119
|
-
if (!body) {
|
|
120
|
-
throw new Error(`Empty body while downloading ${endpoint}: ${response.status} - ${response.statusText}`);
|
|
121
|
-
}
|
|
122
|
-
const destination = path.resolve(githubWorkflowsDir, path.basename(workflow));
|
|
123
|
-
const fileStream = fs.createWriteStream(destination, {
|
|
124
|
-
mode: 0o644, // -rw-r--r--, user(rw), group(r), other(r)
|
|
125
|
-
flags: 'w', // write and overwrite
|
|
126
|
-
flush: true,
|
|
127
|
-
});
|
|
128
|
-
await body.pipeTo(Writable.toWeb(fileStream));
|
|
129
|
-
})());
|
|
130
|
-
}
|
|
131
|
-
// Wait for all downloads to complete
|
|
132
|
-
await Promise.all(downloads).finally(() => {
|
|
133
|
-
// Stop existing downloads
|
|
134
|
-
abortController.abort();
|
|
135
|
-
});
|
|
136
|
-
// Add entries to .gitignore file
|
|
137
|
-
await updateGitignore(gitRepoRoot);
|
|
138
|
-
// Print out a message
|
|
139
|
-
const commands = [];
|
|
140
|
-
commands.push('set -eEuo pipefail');
|
|
141
|
-
commands.push(`echo "Successfully downloaded ${GITHUB_WORKFLOW_PATHS.length} workflows and updated .gitignore. Follow the steps in ${readmeUrl} (skipping the /setup-github step) to complete setup."`);
|
|
142
|
-
commands.push(...getOpenUrlsCommands(readmeUrl));
|
|
143
|
-
const command = `(${commands.join(' && ')})`;
|
|
144
|
-
return {
|
|
145
|
-
type: 'tool',
|
|
146
|
-
toolName: 'run_shell_command',
|
|
147
|
-
toolArgs: {
|
|
148
|
-
description: 'Setting up GitHub Actions to triage issues and review PRs with Gemini.',
|
|
149
|
-
command,
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
//# sourceMappingURL=setupGithubCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupGithubCommand.js","sourceRoot":"","sources":["../../../../src/ui/commands/setupGithubCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,qCAAqC;IACrC,oCAAoC;IACpC,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ACpB,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACpC,QAAQ,CAAC,IAAI,CACX,iCAAiC,qBAAqB,CAAC,MAAM,0DAA0D,SAAS,wDAAwD,CACzL,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;QAEjD,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC7C,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,mBAAmB;YAC7B,QAAQ,EAAE;gBACR,WAAW,EACT,wEAAwE;gBAC1E,OAAO;aACR;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import os from 'node:os';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import fs from 'node:fs/promises';
|
|
9
|
-
import { vi, describe, expect, it, afterEach, beforeEach } from 'vitest';
|
|
10
|
-
import * as gitUtils from '../../utils/gitUtils.js';
|
|
11
|
-
import { setupGithubCommand, updateGitignore, GITHUB_WORKFLOW_PATHS, } from './setupGithubCommand.js';
|
|
12
|
-
import * as commandUtils from '../utils/commandUtils.js';
|
|
13
|
-
vi.mock('child_process');
|
|
14
|
-
// Mock fetch globally
|
|
15
|
-
global.fetch = vi.fn();
|
|
16
|
-
vi.mock('../../utils/gitUtils.js', () => ({
|
|
17
|
-
isGitHubRepository: vi.fn(),
|
|
18
|
-
getGitRepoRoot: vi.fn(),
|
|
19
|
-
getLatestGitHubRelease: vi.fn(),
|
|
20
|
-
getGitHubRepoInfo: vi.fn(),
|
|
21
|
-
}));
|
|
22
|
-
vi.mock('../utils/commandUtils.js', () => ({
|
|
23
|
-
getUrlOpenCommand: vi.fn(),
|
|
24
|
-
}));
|
|
25
|
-
describe('setupGithubCommand', async () => {
|
|
26
|
-
let scratchDir = '';
|
|
27
|
-
beforeEach(async () => {
|
|
28
|
-
vi.resetAllMocks();
|
|
29
|
-
scratchDir = await fs.mkdtemp(path.join(os.tmpdir(), 'setup-github-command-'));
|
|
30
|
-
});
|
|
31
|
-
afterEach(async () => {
|
|
32
|
-
vi.restoreAllMocks();
|
|
33
|
-
if (scratchDir)
|
|
34
|
-
await fs.rm(scratchDir, { recursive: true });
|
|
35
|
-
});
|
|
36
|
-
it('returns a tool action to download github workflows and handles paths', async () => {
|
|
37
|
-
const fakeRepoOwner = 'fake';
|
|
38
|
-
const fakeRepoName = 'repo';
|
|
39
|
-
const fakeRepoRoot = scratchDir;
|
|
40
|
-
const fakeReleaseVersion = 'v1.2.3';
|
|
41
|
-
const workflows = GITHUB_WORKFLOW_PATHS.map((p) => path.basename(p));
|
|
42
|
-
for (const workflow of workflows) {
|
|
43
|
-
vi.mocked(global.fetch).mockReturnValueOnce(Promise.resolve(new Response(workflow)));
|
|
44
|
-
}
|
|
45
|
-
vi.mocked(gitUtils.isGitHubRepository).mockReturnValueOnce(true);
|
|
46
|
-
vi.mocked(gitUtils.getGitRepoRoot).mockReturnValueOnce(fakeRepoRoot);
|
|
47
|
-
vi.mocked(gitUtils.getLatestGitHubRelease).mockResolvedValueOnce(fakeReleaseVersion);
|
|
48
|
-
vi.mocked(gitUtils.getGitHubRepoInfo).mockReturnValue({
|
|
49
|
-
owner: fakeRepoOwner,
|
|
50
|
-
repo: fakeRepoName,
|
|
51
|
-
});
|
|
52
|
-
vi.mocked(commandUtils.getUrlOpenCommand).mockReturnValueOnce('fakeOpenCommand');
|
|
53
|
-
const result = (await setupGithubCommand.action?.({}, ''));
|
|
54
|
-
const { command } = result.toolArgs;
|
|
55
|
-
const expectedSubstrings = [
|
|
56
|
-
`set -eEuo pipefail`,
|
|
57
|
-
`fakeOpenCommand "https://github.com/google-github-actions/run-gemini-cli`,
|
|
58
|
-
];
|
|
59
|
-
for (const substring of expectedSubstrings) {
|
|
60
|
-
expect(command).toContain(substring);
|
|
61
|
-
}
|
|
62
|
-
for (const workflow of workflows) {
|
|
63
|
-
const workflowFile = path.join(scratchDir, '.github', 'workflows', workflow);
|
|
64
|
-
const contents = await fs.readFile(workflowFile, 'utf8');
|
|
65
|
-
expect(contents).toContain(workflow);
|
|
66
|
-
}
|
|
67
|
-
// Verify that .gitignore was created with the expected entries
|
|
68
|
-
const gitignorePath = path.join(scratchDir, '.gitignore');
|
|
69
|
-
const gitignoreExists = await fs
|
|
70
|
-
.access(gitignorePath)
|
|
71
|
-
.then(() => true)
|
|
72
|
-
.catch(() => false);
|
|
73
|
-
expect(gitignoreExists).toBe(true);
|
|
74
|
-
if (gitignoreExists) {
|
|
75
|
-
const gitignoreContent = await fs.readFile(gitignorePath, 'utf8');
|
|
76
|
-
expect(gitignoreContent).toContain('.gemini/');
|
|
77
|
-
expect(gitignoreContent).toContain('gha-creds-*.json');
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe('updateGitignore', () => {
|
|
82
|
-
let scratchDir = '';
|
|
83
|
-
beforeEach(async () => {
|
|
84
|
-
scratchDir = await fs.mkdtemp(path.join(os.tmpdir(), 'update-gitignore-'));
|
|
85
|
-
});
|
|
86
|
-
afterEach(async () => {
|
|
87
|
-
if (scratchDir)
|
|
88
|
-
await fs.rm(scratchDir, { recursive: true });
|
|
89
|
-
});
|
|
90
|
-
it('creates a new .gitignore file when none exists', async () => {
|
|
91
|
-
await updateGitignore(scratchDir);
|
|
92
|
-
const gitignorePath = path.join(scratchDir, '.gitignore');
|
|
93
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
94
|
-
expect(content).toBe('.gemini/\ngha-creds-*.json\n');
|
|
95
|
-
});
|
|
96
|
-
it('appends entries to existing .gitignore file', async () => {
|
|
97
|
-
const gitignorePath = path.join(scratchDir, '.gitignore');
|
|
98
|
-
const existingContent = '# Existing content\nnode_modules/\n';
|
|
99
|
-
await fs.writeFile(gitignorePath, existingContent);
|
|
100
|
-
await updateGitignore(scratchDir);
|
|
101
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
102
|
-
expect(content).toBe('# Existing content\nnode_modules/\n\n.gemini/\ngha-creds-*.json\n');
|
|
103
|
-
});
|
|
104
|
-
it('does not add duplicate entries', async () => {
|
|
105
|
-
const gitignorePath = path.join(scratchDir, '.gitignore');
|
|
106
|
-
const existingContent = '.gemini/\nsome-other-file\ngha-creds-*.json\n';
|
|
107
|
-
await fs.writeFile(gitignorePath, existingContent);
|
|
108
|
-
await updateGitignore(scratchDir);
|
|
109
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
110
|
-
expect(content).toBe(existingContent);
|
|
111
|
-
});
|
|
112
|
-
it('adds only missing entries when some already exist', async () => {
|
|
113
|
-
const gitignorePath = path.join(scratchDir, '.gitignore');
|
|
114
|
-
const existingContent = '.gemini/\nsome-other-file\n';
|
|
115
|
-
await fs.writeFile(gitignorePath, existingContent);
|
|
116
|
-
await updateGitignore(scratchDir);
|
|
117
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
118
|
-
// Should add only the missing gha-creds-*.json entry
|
|
119
|
-
expect(content).toBe('.gemini/\nsome-other-file\n\ngha-creds-*.json\n');
|
|
120
|
-
expect(content).toContain('gha-creds-*.json');
|
|
121
|
-
// Should not duplicate .gemini/ entry
|
|
122
|
-
expect((content.match(/\.gemini\//g) || []).length).toBe(1);
|
|
123
|
-
});
|
|
124
|
-
it('does not get confused by entries in comments or as substrings', async () => {
|
|
125
|
-
const gitignorePath = path.join(scratchDir, '.gitignore');
|
|
126
|
-
const existingContent = [
|
|
127
|
-
'# This is a comment mentioning .gemini/ folder',
|
|
128
|
-
'my-app.gemini/config',
|
|
129
|
-
'# Another comment with gha-creds-*.json pattern',
|
|
130
|
-
'some-other-gha-creds-file.json',
|
|
131
|
-
'',
|
|
132
|
-
].join('\n');
|
|
133
|
-
await fs.writeFile(gitignorePath, existingContent);
|
|
134
|
-
await updateGitignore(scratchDir);
|
|
135
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
136
|
-
// Should add both entries since they don't actually exist as gitignore rules
|
|
137
|
-
expect(content).toContain('.gemini/');
|
|
138
|
-
expect(content).toContain('gha-creds-*.json');
|
|
139
|
-
// Verify the entries were added (not just mentioned in comments)
|
|
140
|
-
const lines = content
|
|
141
|
-
.split('\n')
|
|
142
|
-
.map((line) => line.split('#')[0].trim())
|
|
143
|
-
.filter((line) => line);
|
|
144
|
-
expect(lines).toContain('.gemini/');
|
|
145
|
-
expect(lines).toContain('gha-creds-*.json');
|
|
146
|
-
expect(lines).toContain('my-app.gemini/config');
|
|
147
|
-
expect(lines).toContain('some-other-gha-creds-file.json');
|
|
148
|
-
});
|
|
149
|
-
it('handles file system errors gracefully', async () => {
|
|
150
|
-
// Try to update gitignore in a non-existent directory
|
|
151
|
-
const nonExistentDir = path.join(scratchDir, 'non-existent');
|
|
152
|
-
// This should not throw an error
|
|
153
|
-
await expect(updateGitignore(nonExistentDir)).resolves.toBeUndefined();
|
|
154
|
-
});
|
|
155
|
-
it('handles permission errors gracefully', async () => {
|
|
156
|
-
const consoleSpy = vi.spyOn(console, 'debug').mockImplementation(() => { });
|
|
157
|
-
const fsModule = await import('node:fs');
|
|
158
|
-
const writeFileSpy = vi
|
|
159
|
-
.spyOn(fsModule.promises, 'writeFile')
|
|
160
|
-
.mockRejectedValue(new Error('Permission denied'));
|
|
161
|
-
await expect(updateGitignore(scratchDir)).resolves.toBeUndefined();
|
|
162
|
-
expect(consoleSpy).toHaveBeenCalledWith('Failed to update .gitignore:', expect.any(Error));
|
|
163
|
-
writeFileSpy.mockRestore();
|
|
164
|
-
consoleSpy.mockRestore();
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
//# sourceMappingURL=setupGithubCommand.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"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PDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { Config } from '@rdmind/rdmind-core';
|
|
7
|
-
export interface PrivacyState {
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
error?: string;
|
|
10
|
-
isFreeTier?: boolean;
|
|
11
|
-
dataCollectionOptIn?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare const usePrivacySettings: (config: Config) => {
|
|
14
|
-
privacyState: PrivacyState;
|
|
15
|
-
updateDataCollectionOptIn: (optIn: boolean) => Promise<void>;
|
|
16
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
7
|
-
import { CodeAssistServer, UserTierId, LoggingContentGenerator, } from '@rdmind/rdmind-core';
|
|
8
|
-
export const usePrivacySettings = (config) => {
|
|
9
|
-
const [privacyState, setPrivacyState] = useState({
|
|
10
|
-
isLoading: true,
|
|
11
|
-
});
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const fetchInitialState = async () => {
|
|
14
|
-
setPrivacyState({
|
|
15
|
-
isLoading: true,
|
|
16
|
-
});
|
|
17
|
-
try {
|
|
18
|
-
const server = getCodeAssistServer(config);
|
|
19
|
-
const tier = await getTier(server);
|
|
20
|
-
if (tier !== UserTierId.FREE) {
|
|
21
|
-
// We don't need to fetch opt-out info since non-free tier
|
|
22
|
-
// data gathering is already worked out some other way.
|
|
23
|
-
setPrivacyState({
|
|
24
|
-
isLoading: false,
|
|
25
|
-
isFreeTier: false,
|
|
26
|
-
});
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const optIn = await getRemoteDataCollectionOptIn(server);
|
|
30
|
-
setPrivacyState({
|
|
31
|
-
isLoading: false,
|
|
32
|
-
isFreeTier: true,
|
|
33
|
-
dataCollectionOptIn: optIn,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
setPrivacyState({
|
|
38
|
-
isLoading: false,
|
|
39
|
-
error: e instanceof Error ? e.message : String(e),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
fetchInitialState();
|
|
44
|
-
}, [config]);
|
|
45
|
-
const updateDataCollectionOptIn = useCallback(async (optIn) => {
|
|
46
|
-
try {
|
|
47
|
-
const server = getCodeAssistServer(config);
|
|
48
|
-
const updatedOptIn = await setRemoteDataCollectionOptIn(server, optIn);
|
|
49
|
-
setPrivacyState({
|
|
50
|
-
isLoading: false,
|
|
51
|
-
isFreeTier: true,
|
|
52
|
-
dataCollectionOptIn: updatedOptIn,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
setPrivacyState({
|
|
57
|
-
isLoading: false,
|
|
58
|
-
error: e instanceof Error ? e.message : String(e),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}, [config]);
|
|
62
|
-
return {
|
|
63
|
-
privacyState,
|
|
64
|
-
updateDataCollectionOptIn,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
function getCodeAssistServer(config) {
|
|
68
|
-
let server = config.getGeminiClient().getContentGenerator();
|
|
69
|
-
// Unwrap LoggingContentGenerator if present
|
|
70
|
-
if (server instanceof LoggingContentGenerator) {
|
|
71
|
-
server = server.getWrapped();
|
|
72
|
-
}
|
|
73
|
-
// Neither of these cases should ever happen.
|
|
74
|
-
if (!(server instanceof CodeAssistServer)) {
|
|
75
|
-
throw new Error('Oauth not being used');
|
|
76
|
-
}
|
|
77
|
-
else if (!server.projectId) {
|
|
78
|
-
throw new Error('Oauth not being used');
|
|
79
|
-
}
|
|
80
|
-
return server;
|
|
81
|
-
}
|
|
82
|
-
async function getTier(server) {
|
|
83
|
-
const loadRes = await server.loadCodeAssist({
|
|
84
|
-
cloudaicompanionProject: server.projectId,
|
|
85
|
-
metadata: {
|
|
86
|
-
ideType: 'IDE_UNSPECIFIED',
|
|
87
|
-
platform: 'PLATFORM_UNSPECIFIED',
|
|
88
|
-
pluginType: 'GEMINI',
|
|
89
|
-
duetProject: server.projectId,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
if (!loadRes.currentTier) {
|
|
93
|
-
throw new Error('User does not have a current tier');
|
|
94
|
-
}
|
|
95
|
-
return loadRes.currentTier.id;
|
|
96
|
-
}
|
|
97
|
-
async function getRemoteDataCollectionOptIn(server) {
|
|
98
|
-
try {
|
|
99
|
-
const resp = await server.getCodeAssistGlobalUserSetting();
|
|
100
|
-
return resp.freeTierDataCollectionOptin;
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
if (error && typeof error === 'object' && 'response' in error) {
|
|
104
|
-
const gaxiosError = error;
|
|
105
|
-
if (gaxiosError.response?.status === 404) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function setRemoteDataCollectionOptIn(server, optIn) {
|
|
113
|
-
const resp = await server.setCodeAssistGlobalUserSetting({
|
|
114
|
-
cloudaicompanionProject: server.projectId,
|
|
115
|
-
freeTierDataCollectionOptin: optIn,
|
|
116
|
-
});
|
|
117
|
-
return resp.freeTierDataCollectionOptin;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=usePrivacySettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePrivacySettings.js","sourceRoot":"","sources":["../../../../src/ui/hooks/usePrivacySettings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAS7B,MAAM,CAAC,MAAM,k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