summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--package.json3
-rw-r--r--packages/cli/src/ui/components/AboutBox.tsx13
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.test.ts2
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts2
-rw-r--r--packages/cli/tsconfig.json3
-rwxr-xr-xscripts/clean.sh1
-rwxr-xr-xscripts/generate-git-commit-info.sh44
8 files changed, 67 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 63a276bb..9aa528c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,6 @@ bundle
# Test report files
junit.xml
packages/*/coverage/
+
+# Generated files
+packages/cli/src/generated/
diff --git a/package.json b/package.json
index 46ec34be..a1159cf2 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"packages/*"
],
"scripts": {
+ "generate": "scripts/generate-git-commit-info.sh",
"build": "scripts/build.sh",
"build:sandbox": "scripts/build_sandbox.sh",
"build:all": "npm run build && npm run build:sandbox",
@@ -24,7 +25,7 @@
"auth:docker": "gcloud auth configure-docker us-west1-docker.pkg.dev",
"auth": "npm run auth:npm && npm run auth:docker",
"prerelease:dev": "npm run prerelease:version --workspaces && npm run prerelease:deps --workspaces",
- "bundle": "node_modules/.bin/esbuild packages/cli/index.ts --bundle --outfile=bundle/gemini.js --platform=node --format=esm --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);\" && bash scripts/copy_bundle_assets.sh"
+ "bundle": "npm run generate && node_modules/.bin/esbuild packages/cli/index.ts --bundle --outfile=bundle/gemini.js --platform=node --format=esm --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);\" && bash scripts/copy_bundle_assets.sh"
},
"bin": {
"gemini": "bundle/gemini.js"
diff --git a/packages/cli/src/ui/components/AboutBox.tsx b/packages/cli/src/ui/components/AboutBox.tsx
index 9ffa1a90..472bf979 100644
--- a/packages/cli/src/ui/components/AboutBox.tsx
+++ b/packages/cli/src/ui/components/AboutBox.tsx
@@ -7,6 +7,7 @@
import React from 'react';
import { Box, Text } from 'ink';
import { Colors } from '../colors.js';
+import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
interface AboutBoxProps {
cliVersion: string;
@@ -44,6 +45,18 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
<Text>{cliVersion}</Text>
</Box>
</Box>
+ {GIT_COMMIT_INFO && !['N/A'].includes(GIT_COMMIT_INFO) && (
+ <Box flexDirection="row">
+ <Box width="35%">
+ <Text bold color={Colors.LightBlue}>
+ Git Commit
+ </Text>
+ </Box>
+ <Box>
+ <Text>{GIT_COMMIT_INFO}</Text>
+ </Box>
+ </Box>
+ )}
<Box flexDirection="row">
<Box width="35%">
<Text bold color={Colors.LightBlue}>
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
index 4c630d10..1f049658 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
@@ -31,6 +31,7 @@ import { MessageType } from '../types.js';
import { type Config } from '@gemini-code/server';
import * as ShowMemoryCommandModule from './useShowMemoryCommand.js';
+import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
vi.mock('./useShowMemoryCommand.js', () => ({
SHOW_MEMORY_COMMAND_NAME: '/memory show',
@@ -244,6 +245,7 @@ Add any other context about the problem here.
## Diagnostic Information
* **CLI Version:** ${cliVersion}
+* **Git Commit:** ${GIT_COMMIT_INFO}
* **Operating System:** ${osVersion}
* **Sandbox Environment:** ${sandboxEnvStr}
* **Model Version:** ${modelVersion}
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index 4573303e..d4daa5c9 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -11,6 +11,7 @@ import { UseHistoryManagerReturn } from './useHistoryManager.js';
import { Config } from '@gemini-code/server';
import { Message, MessageType, HistoryItemWithoutId } from '../types.js';
import { createShowMemoryAction } from './useShowMemoryCommand.js';
+import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
export interface SlashCommandActionReturn {
shouldScheduleTool?: boolean;
@@ -215,6 +216,7 @@ Add any other context about the problem here.
## Diagnostic Information
* **CLI Version:** ${cliVersion}
+* **Git Commit:** ${GIT_COMMIT_INFO}
* **Operating System:** ${osVersion}
* **Sandbox Environment:** ${sandboxEnv}
* **Model Version:** ${modelVersion}
diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json
index 7c7539e3..38ef1972 100644
--- a/packages/cli/tsconfig.json
+++ b/packages/cli/tsconfig.json
@@ -4,9 +4,6 @@
"outDir": "dist",
"jsx": "react-jsx",
"lib": ["DOM", "DOM.Iterable", "ES2020"],
- "paths": {
- "@gemini-code/*": ["./packages/*"]
- },
"types": ["node", "vitest/globals"]
},
"include": ["index.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
diff --git a/scripts/clean.sh b/scripts/clean.sh
index 2dc0232d..2f6bc3c0 100755
--- a/scripts/clean.sh
+++ b/scripts/clean.sh
@@ -17,4 +17,5 @@ set -euo pipefail
# remove npm install/build artifacts
rm -rf node_modules
+rm -rf packages/cli/src/generated/
npm run clean --workspaces
diff --git a/scripts/generate-git-commit-info.sh b/scripts/generate-git-commit-info.sh
new file mode 100755
index 00000000..2a64830f
--- /dev/null
+++ b/scripts/generate-git-commit-info.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -euo pipefail
+
+GENERATED_DIR="packages/cli/src/generated"
+GIT_COMMIT_FILE="$GENERATED_DIR/git-commit.ts"
+GIT_COMMIT_INFO="N/A"
+
+mkdir -p "$GENERATED_DIR"
+
+if command -v git &> /dev/null && git rev-parse --is-inside-work-tree &> /dev/null; then
+ GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "")
+ if [ -n "$GIT_HASH" ]; then
+ GIT_COMMIT_INFO="$GIT_HASH"
+ if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
+ GIT_COMMIT_INFO="$GIT_HASH (local modifications)"
+ fi
+ fi
+fi
+
+cat <<EOL > "$GIT_COMMIT_FILE"
+/**
+ * @license
+ * Copyright $(date +%Y) Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+// This file is auto-generated by the build script (scripts/build.sh)
+// Do not edit this file manually.
+export const GIT_COMMIT_INFO = '$GIT_COMMIT_INFO';
+EOL