pi-codex-image-gen 0.1.5 → 0.1.7
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/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +4 -4
- package/README.md +2 -0
- package/index.ts +58 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ This project follows the spirit of [Keep a Changelog](https://keepachangelog.com
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.7] - 2026-05-10
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Install/update telemetry ping to `mocito.dev`, gated by Pi telemetry/offline settings and deduplicated per package version.
|
|
14
|
+
|
|
15
|
+
## [0.1.6] - 2026-05-09
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Switched development, CI, and publish workflows from Bun to npm with `package-lock.json` for better Pi package consistency.
|
|
20
|
+
|
|
9
21
|
## [0.1.5] - 2026-05-07
|
|
10
22
|
|
|
11
23
|
### Added
|
package/CONTRIBUTING.md
CHANGED
|
@@ -5,8 +5,8 @@ Thanks for your interest in contributing to `pi-codex-image-gen`.
|
|
|
5
5
|
## Development setup
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
npm install
|
|
9
|
+
npm run check
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
The package is source-distributed: Pi loads the TypeScript extension file directly. There is no build step for runtime use.
|
|
@@ -41,8 +41,8 @@ python3 skills/imagegen/scripts/remove_chroma_key.py --help
|
|
|
41
41
|
|
|
42
42
|
Before opening a pull request:
|
|
43
43
|
|
|
44
|
-
- Run `
|
|
45
|
-
- Run `
|
|
44
|
+
- Run `npm run check`.
|
|
45
|
+
- Run `npm run pack:dry-run` and confirm the package contents are intentional.
|
|
46
46
|
- Update `README.md` if user-facing behavior changes.
|
|
47
47
|
- Update `CHANGELOG.md` for notable changes.
|
|
48
48
|
- Keep examples and paths generic; do not commit machine-specific paths or credentials.
|
package/README.md
CHANGED
|
@@ -67,6 +67,8 @@ Project config overrides global config. Example:
|
|
|
67
67
|
| ---------------------------- | ------------------------------------------------ |
|
|
68
68
|
| `PI_CODEX_IMAGE_SAVE_MODE` | Overrides the `save` config key. |
|
|
69
69
|
| `PI_CODEX_IMAGE_SAVE_DIR` | Overrides the `saveDir` config key (custom mode).|
|
|
70
|
+
| `PI_OFFLINE=1` | Disables install/update telemetry. |
|
|
71
|
+
| `PI_TELEMETRY=0` | Disables install/update telemetry. |
|
|
70
72
|
|
|
71
73
|
## Save modes
|
|
72
74
|
|
package/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { StringEnum } from "@earendil-works/pi-ai";
|
|
|
13
13
|
import { type ExtensionAPI, getAgentDir, withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
14
14
|
import { type Static, Type } from "typebox";
|
|
15
15
|
|
|
16
|
+
const PACKAGE_NAME = "pi-codex-image-gen";
|
|
16
17
|
const PROVIDER = "openai-codex";
|
|
17
18
|
const DEFAULT_MODEL = "gpt-5.5";
|
|
18
19
|
const CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
@@ -21,6 +22,8 @@ const DEFAULT_SAVE_MODE = "global";
|
|
|
21
22
|
const OPENAI_BETA_HEADER = "responses=experimental";
|
|
22
23
|
const MAX_RETRIES = 3;
|
|
23
24
|
const BASE_DELAY_MS = 1000;
|
|
25
|
+
const INSTALL_TELEMETRY_URL = "https://mocito.dev/api/report-install";
|
|
26
|
+
const INSTALL_TELEMETRY_TIMEOUT_MS = 5000;
|
|
24
27
|
|
|
25
28
|
const SAVE_MODES = ["none", "project", "global", "custom"] as const;
|
|
26
29
|
type SaveMode = (typeof SAVE_MODES)[number];
|
|
@@ -85,6 +88,10 @@ interface ParsedCodexResponse {
|
|
|
85
88
|
usage?: unknown;
|
|
86
89
|
}
|
|
87
90
|
|
|
91
|
+
interface InstallTelemetryState {
|
|
92
|
+
lastReportedVersion?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
88
95
|
// --- #11: Typed SSE event discriminated union ---
|
|
89
96
|
|
|
90
97
|
type CodexSseEvent =
|
|
@@ -147,6 +154,55 @@ function loadConfig(cwd: string): ExtensionConfig {
|
|
|
147
154
|
return { ...globalConfig, ...projectConfig };
|
|
148
155
|
}
|
|
149
156
|
|
|
157
|
+
function isTruthyEnvFlag(value: string | undefined): boolean {
|
|
158
|
+
if (!value) return false;
|
|
159
|
+
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function isInstallTelemetryEnabled(): boolean {
|
|
163
|
+
if (isTruthyEnvFlag(process.env.PI_OFFLINE)) return false;
|
|
164
|
+
if (process.env.PI_TELEMETRY !== undefined) return isTruthyEnvFlag(process.env.PI_TELEMETRY);
|
|
165
|
+
const settings = readConfigFile(join(getAgentDir(), "settings.json")) as { enableInstallTelemetry?: unknown };
|
|
166
|
+
return settings.enableInstallTelemetry !== false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getPackageVersion(): string {
|
|
170
|
+
try {
|
|
171
|
+
const packageJson = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8")) as { version?: unknown };
|
|
172
|
+
return typeof packageJson.version === "string" && packageJson.version.length > 0 ? packageJson.version : "0.0.0";
|
|
173
|
+
} catch {
|
|
174
|
+
return "0.0.0";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getInstallTelemetryUserAgent(version: string): string {
|
|
179
|
+
const runtimeVersions = process.versions as NodeJS.ProcessVersions & { bun?: string };
|
|
180
|
+
const runtime = runtimeVersions.bun ? `bun/${runtimeVersions.bun}` : `node/${process.version}`;
|
|
181
|
+
return `${PACKAGE_NAME}/${version} (${process.platform}; ${runtime}; ${process.arch})`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function reportInstallTelemetry(): Promise<void> {
|
|
185
|
+
try {
|
|
186
|
+
if (!isInstallTelemetryEnabled()) return;
|
|
187
|
+
|
|
188
|
+
const version = getPackageVersion();
|
|
189
|
+
const statePath = join(getAgentDir(), "extensions", "codex-image-gen-install.json");
|
|
190
|
+
const state = readConfigFile(statePath) as InstallTelemetryState;
|
|
191
|
+
if (state.lastReportedVersion === version) return;
|
|
192
|
+
|
|
193
|
+
await mkdir(join(getAgentDir(), "extensions"), { recursive: true });
|
|
194
|
+
await writeFile(statePath, `${JSON.stringify({ lastReportedVersion: version }, null, 2)}\n`);
|
|
195
|
+
|
|
196
|
+
const params = new URLSearchParams({ tool: PACKAGE_NAME, version });
|
|
197
|
+
await fetch(`${INSTALL_TELEMETRY_URL}?${params.toString()}`, {
|
|
198
|
+
headers: { "User-Agent": getInstallTelemetryUserAgent(version) },
|
|
199
|
+
signal: AbortSignal.timeout(INSTALL_TELEMETRY_TIMEOUT_MS),
|
|
200
|
+
});
|
|
201
|
+
} catch {
|
|
202
|
+
// Best-effort telemetry: ignore settings, filesystem, and network failures.
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
150
206
|
// --- Path helpers ---
|
|
151
207
|
|
|
152
208
|
function resolveUnderCwd(cwd: string, path: string): string {
|
|
@@ -385,6 +441,8 @@ async function requestImage(
|
|
|
385
441
|
// --- Extension entry point ---
|
|
386
442
|
|
|
387
443
|
export default function codexImageGen(pi: ExtensionAPI) {
|
|
444
|
+
void reportInstallTelemetry();
|
|
445
|
+
|
|
388
446
|
pi.registerTool({
|
|
389
447
|
name: "codex_generate_image",
|
|
390
448
|
label: "Codex Image",
|