@jagit/hook-copilot 0.0.0

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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @jagit/hook-copilot
2
+
3
+ Reports per-invocation GitHub Copilot CLI usage to JaGit.
4
+
5
+ ## Setup
6
+
7
+ The Copilot CLI has no hook mechanism and no persistent session telemetry, so
8
+ install a shell function that wraps the real `copilot` binary and reports
9
+ after each invocation ends:
10
+
11
+ copilot() {
12
+ command copilot "$@"
13
+ local status=$?
14
+ npx -y @jagit/hook-copilot >/dev/null 2>&1 || true
15
+ return $status
16
+ }
17
+
18
+ Add that function to your shell rc (`~/.zshrc`, `~/.bashrc`, etc.) — it must
19
+ appear before any `alias`/`PATH` entry that would otherwise shadow it. (Users
20
+ on the legacy `gh copilot` preview wrapper can apply the same pattern to a
21
+ `gh` function instead.) Uninstall by removing the shell function.
22
+
23
+ For a permanent binary instead of `npx -y`:
24
+ `npm i -g @jagit/hook-copilot`, then call `jagit-hook-copilot` in the wrapper.
25
+
26
+ ## Environment
27
+
28
+ export JAGIT_BASE_URL="https://your-jagit-host"
29
+ export JAGIT_API_KEY="<your DASHBOARD_API_TOKEN>"
30
+
31
+ Identity defaults to `git config user.email`; override with `JAGIT_GIT_USERNAME`.
32
+
33
+ ## Notes
34
+
35
+ - Copilot CLI exposes no local token/usage telemetry (billing is seat-based),
36
+ so each report uses a synthetic session id (`copilot-<timestamp>-<pid>`),
37
+ zero token counts, and `model: "copilot"` unless a future CLI version
38
+ surfaces real usage data.
39
+ - `costUsd` is always `null` and will remain so — there is no per-invocation
40
+ cost to report under seat-based billing.
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { type AgentSessionPayload } from "@jagit/agent-reporter";
3
+ export interface CopilotInfo {
4
+ model?: string;
5
+ inputTokens?: number;
6
+ outputTokens?: number;
7
+ cachedInputTokens?: number;
8
+ toolCallCount?: number | null;
9
+ }
10
+ export declare function buildPayload(cwd: string | undefined, info?: CopilotInfo): AgentSessionPayload;
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ import { resolveGitUsername, reportSession } from "@jagit/agent-reporter";
5
+ export function buildPayload(cwd, info) {
6
+ return {
7
+ tool: "copilot",
8
+ sessionId: `copilot-${Date.now()}-${process.pid}`,
9
+ gitUsername: resolveGitUsername(cwd),
10
+ model: info?.model ?? "copilot",
11
+ inputTokens: info?.inputTokens ?? 0,
12
+ cachedInputTokens: info?.cachedInputTokens ?? 0,
13
+ outputTokens: info?.outputTokens ?? 0,
14
+ costUsd: null,
15
+ toolCallCount: info?.toolCallCount ?? null,
16
+ startedAt: new Date().toISOString(),
17
+ };
18
+ }
19
+ async function main() {
20
+ try {
21
+ await reportSession(buildPayload(process.cwd()));
22
+ }
23
+ catch (err) {
24
+ console.error("[hook-copilot]", err instanceof Error ? err.message : err);
25
+ }
26
+ finally {
27
+ process.exit(0);
28
+ }
29
+ }
30
+ const isMain = import.meta.url.startsWith("file://") &&
31
+ realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
32
+ if (isMain)
33
+ void main();
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@jagit/hook-copilot",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "bin": {
6
+ "jagit-hook-copilot": "dist/index.js"
7
+ },
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.json",
13
+ "typecheck": "tsc -p tsconfig.json --noEmit",
14
+ "test": "vitest run"
15
+ },
16
+ "dependencies": {
17
+ "@jagit/agent-reporter": "workspace:*"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^25.9.3",
21
+ "vitest": "^2.1.9"
22
+ }
23
+ }