waypoint-codex 1.0.17 → 1.0.18

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.
Files changed (2) hide show
  1. package/dist/src/upgrade.js +86 -11
  2. package/package.json +1 -1
@@ -76,18 +76,90 @@ export function compareVersions(left, right) {
76
76
  }
77
77
  return 0;
78
78
  }
79
- function latestWaypointVersion(options) {
80
- const npmBinary = options.npmBinary ?? process.env.WAYPOINT_NPM_COMMAND ?? npmBinaryForPlatform();
81
- const latest = spawnSync(npmBinary, ["view", "waypoint-codex", "version"], {
79
+ function spawnNpmPipe(npmBinary, args) {
80
+ const result = spawnSync(npmBinary, args, {
82
81
  stdio: "pipe",
83
82
  encoding: "utf8",
84
83
  });
85
- if ((latest.status ?? 1) !== 0) {
84
+ return {
85
+ status: result.status ?? 1,
86
+ stdout: result.stdout ?? "",
87
+ stderr: result.stderr ?? "",
88
+ };
89
+ }
90
+ function writePipedOutput(result, stdio) {
91
+ if (stdio !== "inherit") {
92
+ return;
93
+ }
94
+ if (result.stdout.length > 0) {
95
+ process.stdout.write(result.stdout);
96
+ }
97
+ if (result.stderr.length > 0) {
98
+ process.stderr.write(result.stderr);
99
+ }
100
+ }
101
+ function latestWaypointVersion(options) {
102
+ const npmBinary = options.npmBinary ?? process.env.WAYPOINT_NPM_COMMAND ?? npmBinaryForPlatform();
103
+ const latest = spawnNpmPipe(npmBinary, ["view", "waypoint-codex", "version"]);
104
+ if (latest.status !== 0) {
86
105
  return null;
87
106
  }
88
- const version = latest.stdout?.trim();
107
+ const version = latest.stdout.trim();
89
108
  return version ? version : null;
90
109
  }
110
+ function latestWaypointTarballUrl(options) {
111
+ const tarball = spawnNpmPipe(options.npmBinary, ["view", `waypoint-codex@${options.version}`, "dist.tarball"]);
112
+ if (tarball.status !== 0) {
113
+ return null;
114
+ }
115
+ const tarballUrl = tarball.stdout.trim();
116
+ return tarballUrl.length > 0 ? tarballUrl : null;
117
+ }
118
+ function appendCacheBust(url) {
119
+ try {
120
+ const parsed = new URL(url);
121
+ parsed.searchParams.set("waypointCacheBust", `${Date.now()}`);
122
+ return parsed.toString();
123
+ }
124
+ catch {
125
+ const separator = url.includes("?") ? "&" : "?";
126
+ return `${url}${separator}waypointCacheBust=${Date.now()}`;
127
+ }
128
+ }
129
+ function isTransientTarball404(result) {
130
+ const combined = `${result.stdout}\n${result.stderr}`;
131
+ return /E404/.test(combined) && /waypoint-codex-.*\.tgz/i.test(combined);
132
+ }
133
+ function installLatestWaypointCli(options) {
134
+ const primary = spawnNpmPipe(options.npmBinary, ["install", "-g", "waypoint-codex@latest"]);
135
+ if (primary.status === 0) {
136
+ writePipedOutput(primary, options.stdio);
137
+ return 0;
138
+ }
139
+ if (!isTransientTarball404(primary)) {
140
+ writePipedOutput(primary, options.stdio);
141
+ return primary.status;
142
+ }
143
+ const latestVersion = options.knownLatestVersion ?? latestWaypointVersion({ npmBinary: options.npmBinary });
144
+ if (!latestVersion) {
145
+ writePipedOutput(primary, options.stdio);
146
+ return primary.status;
147
+ }
148
+ const tarballUrl = latestWaypointTarballUrl({
149
+ npmBinary: options.npmBinary,
150
+ version: latestVersion,
151
+ });
152
+ if (!tarballUrl) {
153
+ writePipedOutput(primary, options.stdio);
154
+ return primary.status;
155
+ }
156
+ if (options.stdio === "inherit") {
157
+ console.log(`Waypoint npm install hit a transient tarball 404 for ${latestVersion}. Retrying with cache-busted URL...`);
158
+ }
159
+ const fallback = spawnNpmPipe(options.npmBinary, ["install", "-g", appendCacheBust(tarballUrl)]);
160
+ writePipedOutput(fallback, options.stdio);
161
+ return fallback.status;
162
+ }
91
163
  function hasWaypointConfig(projectRoot) {
92
164
  return existsSync(path.join(projectRoot, ".waypoint/config.toml"));
93
165
  }
@@ -95,11 +167,12 @@ export function upgradeWaypoint(options) {
95
167
  const nodeBinary = options.nodeBinary ?? process.execPath;
96
168
  const npmBinary = options.npmBinary ?? process.env.WAYPOINT_NPM_COMMAND ?? npmBinaryForPlatform();
97
169
  const stdio = options.stdio ?? "inherit";
98
- const update = spawnSync(npmBinary, ["install", "-g", "waypoint-codex@latest"], {
170
+ const updateStatus = installLatestWaypointCli({
171
+ npmBinary,
99
172
  stdio,
100
173
  });
101
- if ((update.status ?? 1) !== 0) {
102
- return update.status ?? 1;
174
+ if (updateStatus !== 0) {
175
+ return updateStatus;
103
176
  }
104
177
  if (options.skipRepoRefresh) {
105
178
  console.log("Waypoint CLI updated. Skipped repo refresh.");
@@ -129,11 +202,13 @@ export function maybeUpgradeWaypointBeforeInit(options) {
129
202
  return null;
130
203
  }
131
204
  console.log(`Waypoint CLI ${options.currentVersion} is older than latest ${latestVersion}. Updating before init...`);
132
- const update = spawnSync(npmBinary, ["install", "-g", "waypoint-codex@latest"], {
205
+ const updateStatus = installLatestWaypointCli({
206
+ npmBinary,
133
207
  stdio,
208
+ knownLatestVersion: latestVersion,
134
209
  });
135
- if ((update.status ?? 1) !== 0) {
136
- return update.status ?? 1;
210
+ if (updateStatus !== 0) {
211
+ return updateStatus;
137
212
  }
138
213
  const reexecArgs = options.initArgs.includes("--skip-cli-update")
139
214
  ? options.initArgs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waypoint-codex",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Make Codex better by default with stronger planning, code quality, reviews, tracking, and repo guidance.",
5
5
  "license": "MIT",
6
6
  "type": "module",