waypoint-codex 0.8.0 → 0.8.1

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 CHANGED
@@ -98,6 +98,12 @@ From there, start your Codex session in the repo and follow the generated bootst
98
98
  waypoint init
99
99
  ```
100
100
 
101
+ By default, `waypoint init` updates the global CLI to the latest published `waypoint-codex` first, then scaffolds with that fresh version. If you want to scaffold with the currently installed binary instead, use:
102
+
103
+ ```bash
104
+ waypoint init --skip-cli-update
105
+ ```
106
+
101
107
  ### Full local workflow setup
102
108
 
103
109
  ```bash
@@ -116,10 +122,11 @@ Flags you can combine:
116
122
  - `--with-roles`
117
123
  - `--with-rules`
118
124
  - `--with-automations`
125
+ - `--skip-cli-update`
119
126
 
120
127
  ## Main commands
121
128
 
122
- - `waypoint init` — scaffold or refresh the repo
129
+ - `waypoint init` — update the CLI to latest by default, then scaffold or refresh the repo
123
130
  - `waypoint doctor` — validate health and report drift
124
131
  - `waypoint sync` — rebuild the docs index and sync optional user-home artifacts
125
132
  - `waypoint upgrade` — update the CLI and refresh the current repo using its saved config
package/dist/src/cli.js CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
5
5
  import path from "node:path";
6
6
  import process from "node:process";
7
7
  import { doctorRepository, importLegacyRepo, initRepository, loadWaypointConfig, syncRepository } from "./core.js";
8
- import { upgradeWaypoint } from "./upgrade.js";
8
+ import { maybeUpgradeWaypointBeforeInit, upgradeWaypoint } from "./upgrade.js";
9
9
  const VERSION = JSON.parse(readFileSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../package.json"), "utf8")).version;
10
10
  function resolveRepo(input) {
11
11
  return path.resolve(input ?? ".");
@@ -27,7 +27,7 @@ function printHelp() {
27
27
  console.log(`usage: waypoint [--version] <command> [options]
28
28
 
29
29
  Commands:
30
- init Initialize a repository with Waypoint scaffolding
30
+ init Initialize a repository with Waypoint scaffolding (auto-updates CLI unless skipped)
31
31
  doctor Validate repository health and report drift
32
32
  sync Rebuild docs index and sync optional user-home artifacts
33
33
  upgrade Update the global Waypoint CLI and refresh this repo using existing config
@@ -52,11 +52,22 @@ async function main() {
52
52
  "app-friendly": { type: "boolean", default: false },
53
53
  "with-roles": { type: "boolean", default: false },
54
54
  "with-rules": { type: "boolean", default: false },
55
- "with-automations": { type: "boolean", default: false }
55
+ "with-automations": { type: "boolean", default: false },
56
+ "skip-cli-update": { type: "boolean", default: false }
56
57
  },
57
58
  allowPositionals: true
58
59
  });
59
60
  const projectRoot = resolveRepo(positionals[0]);
61
+ if (!values["skip-cli-update"]) {
62
+ const status = maybeUpgradeWaypointBeforeInit({
63
+ currentVersion: VERSION,
64
+ cliEntry: process.argv[1] ? path.resolve(process.argv[1]) : fileURLToPath(import.meta.url),
65
+ initArgs: argv.slice(1),
66
+ });
67
+ if (status !== null) {
68
+ return status;
69
+ }
70
+ }
60
71
  const results = initRepository(projectRoot, {
61
72
  profile: values["app-friendly"] ? "app-friendly" : "universal",
62
73
  withRoles: values["with-roles"],
@@ -21,6 +21,83 @@ export function buildInitArgs(projectRoot, config) {
21
21
  }
22
22
  return args;
23
23
  }
24
+ function parseVersion(version) {
25
+ const trimmed = version.trim().replace(/^v/, "");
26
+ const match = trimmed.match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);
27
+ if (!match) {
28
+ return null;
29
+ }
30
+ return {
31
+ core: [Number(match[1]), Number(match[2]), Number(match[3])],
32
+ prerelease: match[4] ? match[4].split(".") : [],
33
+ };
34
+ }
35
+ function compareIdentifiers(left, right) {
36
+ const leftNumeric = /^\d+$/.test(left);
37
+ const rightNumeric = /^\d+$/.test(right);
38
+ if (leftNumeric && rightNumeric) {
39
+ return Number(left) - Number(right);
40
+ }
41
+ if (leftNumeric) {
42
+ return -1;
43
+ }
44
+ if (rightNumeric) {
45
+ return 1;
46
+ }
47
+ return left.localeCompare(right);
48
+ }
49
+ export function compareVersions(left, right) {
50
+ const leftParsed = parseVersion(left);
51
+ const rightParsed = parseVersion(right);
52
+ if (!leftParsed || !rightParsed) {
53
+ return left.localeCompare(right);
54
+ }
55
+ for (let index = 0; index < leftParsed.core.length; index += 1) {
56
+ const difference = leftParsed.core[index] - rightParsed.core[index];
57
+ if (difference !== 0) {
58
+ return difference;
59
+ }
60
+ }
61
+ const leftPrerelease = leftParsed.prerelease;
62
+ const rightPrerelease = rightParsed.prerelease;
63
+ if (leftPrerelease.length === 0 && rightPrerelease.length === 0) {
64
+ return 0;
65
+ }
66
+ if (leftPrerelease.length === 0) {
67
+ return 1;
68
+ }
69
+ if (rightPrerelease.length === 0) {
70
+ return -1;
71
+ }
72
+ const length = Math.max(leftPrerelease.length, rightPrerelease.length);
73
+ for (let index = 0; index < length; index += 1) {
74
+ const leftIdentifier = leftPrerelease[index];
75
+ const rightIdentifier = rightPrerelease[index];
76
+ if (leftIdentifier === undefined) {
77
+ return -1;
78
+ }
79
+ if (rightIdentifier === undefined) {
80
+ return 1;
81
+ }
82
+ const difference = compareIdentifiers(leftIdentifier, rightIdentifier);
83
+ if (difference !== 0) {
84
+ return difference;
85
+ }
86
+ }
87
+ return 0;
88
+ }
89
+ function latestWaypointVersion(options) {
90
+ const npmBinary = options.npmBinary ?? process.env.WAYPOINT_NPM_COMMAND ?? npmBinaryForPlatform();
91
+ const latest = spawnSync(npmBinary, ["view", "waypoint-codex", "version"], {
92
+ stdio: "pipe",
93
+ encoding: "utf8",
94
+ });
95
+ if ((latest.status ?? 1) !== 0) {
96
+ return null;
97
+ }
98
+ const version = latest.stdout?.trim();
99
+ return version ? version : null;
100
+ }
24
101
  function hasWaypointConfig(projectRoot) {
25
102
  return existsSync(path.join(projectRoot, ".waypoint/config.toml"));
26
103
  }
@@ -53,3 +130,26 @@ export function upgradeWaypoint(options) {
53
130
  });
54
131
  return doctor.status ?? 1;
55
132
  }
133
+ export function maybeUpgradeWaypointBeforeInit(options) {
134
+ const nodeBinary = options.nodeBinary ?? process.execPath;
135
+ const npmBinary = options.npmBinary ?? process.env.WAYPOINT_NPM_COMMAND ?? npmBinaryForPlatform();
136
+ const stdio = options.stdio ?? "inherit";
137
+ const latestVersion = latestWaypointVersion({ npmBinary });
138
+ if (!latestVersion || compareVersions(latestVersion, options.currentVersion) <= 0) {
139
+ return null;
140
+ }
141
+ console.log(`Waypoint CLI ${options.currentVersion} is older than latest ${latestVersion}. Updating before init...`);
142
+ const update = spawnSync(npmBinary, ["install", "-g", "waypoint-codex@latest"], {
143
+ stdio,
144
+ });
145
+ if ((update.status ?? 1) !== 0) {
146
+ return update.status ?? 1;
147
+ }
148
+ const reexecArgs = options.initArgs.includes("--skip-cli-update")
149
+ ? options.initArgs
150
+ : [...options.initArgs, "--skip-cli-update"];
151
+ const init = spawnSync(nodeBinary, [options.cliEntry, "init", ...reexecArgs], {
152
+ stdio,
153
+ });
154
+ return init.status ?? 1;
155
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waypoint-codex",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Codex-native repository operating system: scaffolding, docs routing, repo-local skills, doctor, and sync.",
5
5
  "license": "MIT",
6
6
  "type": "module",