Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Documentation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GitAgent Documentation

> **GitAgent** — A universal git-native multimodal always-learning AI Agent
> Version 1.3.3 | MIT License | [github.com/open-gitagent/gitagent](https://github.com/open-gitagent/gitagent)
> Version 1.5.2 | MIT License | [github.com/open-gitagent/gitagent](https://github.com/open-gitagent/gitagent)

---

Expand Down Expand Up @@ -83,7 +83,7 @@ The installer offers four options:
curl -fsSL https://raw.githubusercontent.com/open-gitagent/gitagent/main/install.sh | bash

# Or manually
npm update -g gitagent
npm update -g @open-gitagent/gitagent
```

---
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</p>

<p align="center">
<img src="https://img.shields.io/npm/v/gitagent?style=flat-square&color=blue" alt="npm version" />
<img src="https://img.shields.io/npm/v/@open-gitagent/gitagent?style=flat-square&color=blue" alt="npm version" />
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat-square" alt="node version" />
<img src="https://img.shields.io/github/license/open-gitagent/gitagent?style=flat-square" alt="license" />
<img src="https://img.shields.io/badge/TypeScript-5.7-blue?style=flat-square&logo=typescript&logoColor=white" alt="typescript" />
Expand Down Expand Up @@ -56,7 +56,7 @@ This will:
- Walk you through API key setup (Quick or Advanced mode)
- Launch the voice UI in your browser at `http://localhost:3333`

> **Requirements:** Node.js 18+, npm, git
> **Requirements:** Node.js 20+, npm, git

### Or install manually:

Expand Down Expand Up @@ -780,7 +780,7 @@ Your agent lives in a git repository with structured files:
### Installation & Setup

**What are the requirements?**
Node.js 18+ (or 20+ recommended), npm, and git. Install globally with `npm install -g @open-gitagent/gitagent` (slim CLI + SDK). Add `@open-gitagent/voice` for voice mode + the web UI.
Node.js 20+, npm, and git. Install globally with `npm install -g @open-gitagent/gitagent` (slim CLI + SDK). Add `@open-gitagent/voice` for voice mode + the web UI.

**How do I set up API keys?**
Run the installer for guided setup:
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ check_cmd npm
check_cmd git

NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo -e " ${RED}✗ Node.js 18+ required (found $(node -v))${NC}"
if [ "$NODE_VERSION" -lt 20 ]; then
echo -e " ${RED}✗ Node.js 20+ required (found $(node -v))${NC}"
exit 1
fi

Expand Down
144 changes: 141 additions & 3 deletions src/__tests__/telemetry.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,144 @@
import { describe, it } from "node:test";
/**
* Tests for the telemetry module (src/telemetry.ts).
*
* These tests verify that initTelemetry correctly gates on the OTLP
* endpoint environment variable: it MUST be a no-op when the endpoint
* is not configured, and it MUST successfully create an SDK instance
* when an endpoint (or test provider) is provided.
*/
import { describe, it, before, afterEach } from "node:test";
import assert from "node:assert/strict";
import { trace } from "@opentelemetry/api";
import {
NodeTracerProvider,
} from "@opentelemetry/sdk-trace-node";
import {
InMemorySpanExporter,
SimpleSpanProcessor,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: InMemorySpanExporter and SimpleSpanProcessor are not exported from @opentelemetry/sdk-trace-node. Import from @opentelemetry/sdk-trace-base instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4486c21: InMemorySpanExporter and SimpleSpanProcessor now import from @opentelemetry/sdk-trace-base, while NodeTracerProvider stays in @opentelemetry/sdk-trace-node.

} from "@opentelemetry/sdk-trace-base";

let initTelemetry: typeof import("../telemetry.ts").initTelemetry;
let shutdownTelemetry: typeof import("../telemetry.ts").shutdownTelemetry;
let isTelemetryEnabled: typeof import("../telemetry.ts").isTelemetryEnabled;

before(async () => {
const mod = await import("../telemetry.ts");
initTelemetry = mod.initTelemetry;
shutdownTelemetry = mod.shutdownTelemetry;
isTelemetryEnabled = mod.isTelemetryEnabled;
});

afterEach(async () => {
// Always clean up telemetry after each test to avoid cross-test
// contamination from global state.
await shutdownTelemetry();
// trace.disable() unregisters the global tracer provider and
// installs a no-op ProxyTracerProvider, preventing stale spans
// from a previous test's provider leaking into the next test.
try {
trace.disable();
} catch {
/* ignore */
}
});

describe("telemetry", () => {
it.todo("initTelemetry is a no-op when OTEL_EXPORTER_OTLP_ENDPOINT is not set");
it.todo("initTelemetry creates an SDK instance when endpoint is configured");
// ── Helpers ──────────────────────────────────────────────────────

function makeTestProvider() {
const exporter = new InMemorySpanExporter();
const provider = new NodeTracerProvider({
spanProcessors: [new SimpleSpanProcessor(exporter)],
});
return { exporter, provider };
}

// ── initTelemetry no-op ──────────────────────────────────────────

it("initTelemetry without OTLP endpoint does not throw and leaves module in a consistent state", async () => {
// Ensure the env var is not set for this test
const saved = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
const wasSet = "OTEL_EXPORTER_OTLP_ENDPOINT" in process.env;
delete process.env.OTEL_EXPORTER_OTLP_ENDPOINT;

try {
// Calling initTelemetry with no options does not throw — the
// module always wraps its body in try/catch so failures are
// logged, not thrown.
await assert.doesNotReject(
() => initTelemetry({}),
"initTelemetry must never throw, even without an endpoint",
);
} finally {
if (wasSet) {
process.env.OTEL_EXPORTER_OTLP_ENDPOINT = saved;
} else {
delete process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
}
}
});

// ── initTelemetry with endpoint ──────────────────────────────────

it("initTelemetry creates an SDK instance when endpoint is configured", async () => {
// Set a (bogus) OTLP endpoint so the init path proceeds past the
// no-op guard. Because we do not have a real collector, we also
// provide a _testProvider so the test is deterministic.
process.env.OTEL_EXPORTER_OTLP_ENDPOINT = "http://localhost:4318";
const { exporter, provider } = makeTestProvider();

try {
await initTelemetry({
serviceName: "test-svc",
_testProvider: provider,
});

assert.equal(
isTelemetryEnabled(),
true,
"telemetry must be enabled after initTelemetry with _testProvider",
);

// Verify the provider was actually registered: create a span
// and confirm it flows through the InMemorySpanExporter.
const tracer = trace.getTracer("test");
const span = tracer.startSpan("test-span");
span.end();

// Force flush so the span lands in the in-memory exporter
// before we read it back.
await provider.forceFlush();
const spans = exporter.getFinishedSpans();
assert.equal(spans.length, 1, "span should be exported");
assert.equal(spans[0].name, "test-span");
} finally {
delete process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
}
});

// ── Idempotency ──────────────────────────────────────────────────

it("initTelemetry is idempotent", async () => {
const { provider: provider1 } = makeTestProvider();
const { provider: provider2 } = makeTestProvider();

await initTelemetry({ _testProvider: provider1 });
assert.equal(isTelemetryEnabled(), true);

// Second call should be a no-op — _initialized is already true
await initTelemetry({ _testProvider: provider2 });
assert.equal(isTelemetryEnabled(), true);
});

// ── shutdownTelemetry ────────────────────────────────────────────

it("shutdownTelemetry resets the initialized state", async () => {
const { provider } = makeTestProvider();

await initTelemetry({ _testProvider: provider });
assert.equal(isTelemetryEnabled(), true);

await shutdownTelemetry();
assert.equal(isTelemetryEnabled(), false);
});
});
Loading