codiedev 0.7.7 → 0.7.8

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const versionCheck_1 = require("../versionCheck");
5
+ (0, vitest_1.describe)("parseSemver", () => {
6
+ (0, vitest_1.it)("parses a normal version", () => {
7
+ (0, vitest_1.expect)((0, versionCheck_1.parseSemver)("0.7.7")).toEqual({ major: 0, minor: 7, patch: 7 });
8
+ });
9
+ (0, vitest_1.it)("strips a leading v", () => {
10
+ (0, vitest_1.expect)((0, versionCheck_1.parseSemver)("v1.2.3")).toEqual({ major: 1, minor: 2, patch: 3 });
11
+ });
12
+ (0, vitest_1.it)("ignores prerelease/build suffixes", () => {
13
+ (0, vitest_1.expect)((0, versionCheck_1.parseSemver)("1.2.3-beta.1+build.99")).toEqual({
14
+ major: 1,
15
+ minor: 2,
16
+ patch: 3,
17
+ });
18
+ });
19
+ (0, vitest_1.it)("returns null for malformed input", () => {
20
+ (0, vitest_1.expect)((0, versionCheck_1.parseSemver)("")).toBe(null);
21
+ (0, vitest_1.expect)((0, versionCheck_1.parseSemver)("not.a.version")).toBe(null);
22
+ (0, vitest_1.expect)((0, versionCheck_1.parseSemver)("1.2")).toBe(null);
23
+ });
24
+ });
25
+ (0, vitest_1.describe)("compareSemver", () => {
26
+ (0, vitest_1.it)("returns -1 when current is older (patch)", () => {
27
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("0.7.6", "0.7.7")).toBe(-1);
28
+ });
29
+ (0, vitest_1.it)("returns -1 when current is older (minor)", () => {
30
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("0.6.99", "0.7.0")).toBe(-1);
31
+ });
32
+ (0, vitest_1.it)("returns -1 when current is older (major)", () => {
33
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("0.99.99", "1.0.0")).toBe(-1);
34
+ });
35
+ (0, vitest_1.it)("returns 0 when equal", () => {
36
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("0.7.7", "0.7.7")).toBe(0);
37
+ });
38
+ (0, vitest_1.it)("returns 1 when current is ahead of latest (e.g. local dev build)", () => {
39
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("0.8.0", "0.7.7")).toBe(1);
40
+ });
41
+ (0, vitest_1.it)("treats malformed inputs as equal — never warn on garbage", () => {
42
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("garbage", "0.7.7")).toBe(0);
43
+ (0, vitest_1.expect)((0, versionCheck_1.compareSemver)("0.7.7", "garbage")).toBe(0);
44
+ });
45
+ });
46
+ (0, vitest_1.describe)("shouldShowUpdateWarning", () => {
47
+ const now = 1_777_777_777_000;
48
+ const dayMs = 24 * 60 * 60 * 1000;
49
+ (0, vitest_1.it)("warns when current is older AND cache is fresh", () => {
50
+ (0, vitest_1.expect)((0, versionCheck_1.shouldShowUpdateWarning)({
51
+ current: "0.7.6",
52
+ latest: "0.7.7",
53
+ lastChecked: now - 1000,
54
+ nowMs: now,
55
+ cacheTtlMs: dayMs,
56
+ })).toBe(true);
57
+ });
58
+ (0, vitest_1.it)("does not warn when current matches latest", () => {
59
+ (0, vitest_1.expect)((0, versionCheck_1.shouldShowUpdateWarning)({
60
+ current: "0.7.7",
61
+ latest: "0.7.7",
62
+ lastChecked: now,
63
+ nowMs: now,
64
+ cacheTtlMs: dayMs,
65
+ })).toBe(false);
66
+ });
67
+ (0, vitest_1.it)("does not warn when latest is unknown (no fetch yet)", () => {
68
+ (0, vitest_1.expect)((0, versionCheck_1.shouldShowUpdateWarning)({
69
+ current: "0.7.6",
70
+ latest: null,
71
+ lastChecked: 0,
72
+ nowMs: now,
73
+ cacheTtlMs: dayMs,
74
+ })).toBe(false);
75
+ });
76
+ (0, vitest_1.it)("does not warn when current is ahead of latest (dev build)", () => {
77
+ (0, vitest_1.expect)((0, versionCheck_1.shouldShowUpdateWarning)({
78
+ current: "0.8.0",
79
+ latest: "0.7.7",
80
+ lastChecked: now,
81
+ nowMs: now,
82
+ cacheTtlMs: dayMs,
83
+ })).toBe(false);
84
+ });
85
+ });
@@ -40,6 +40,8 @@ const os = __importStar(require("os"));
40
40
  const child_process_1 = require("child_process");
41
41
  const shared_1 = require("./shared");
42
42
  const utils_1 = require("../utils");
43
+ const version_1 = require("../version");
44
+ const upgradeNudge_1 = require("../upgradeNudge");
43
45
  const CLAUDE_SETTINGS_PATH = path.join(os.homedir(), ".claude", "settings.json");
44
46
  const CLAUDE_INSTRUCTIONS_PATH = path.join(os.homedir(), ".claude", "CLAUDE.md");
45
47
  const CODEX_HOOKS_PATH = path.join(os.homedir(), ".codex", "hooks.json");
@@ -151,6 +153,7 @@ function hasGlabCli() {
151
153
  async function runDoctor(_args) {
152
154
  const checks = [];
153
155
  console.log("\nCodieDev doctor — checking your setup…\n");
156
+ await (0, upgradeNudge_1.maybePrintUpgradeNudge)();
154
157
  // 1. Config file
155
158
  const config = (0, utils_1.readConfig)();
156
159
  if (!config) {
@@ -171,7 +174,10 @@ async function runDoctor(_args) {
171
174
  try {
172
175
  const res = await fetch(`${config.backendUrl}/api/cli/validateToken`, {
173
176
  method: "POST",
174
- headers: { "Content-Type": "application/json" },
177
+ headers: {
178
+ "Content-Type": "application/json",
179
+ "X-Codiedev-Cli-Version": version_1.CLI_VERSION,
180
+ },
175
181
  body: JSON.stringify({ token: config.token }),
176
182
  });
177
183
  if (res.ok) {
@@ -40,6 +40,7 @@ exports.stripQuotes = stripQuotes;
40
40
  const https = __importStar(require("https"));
41
41
  const http = __importStar(require("http"));
42
42
  const utils_1 = require("../utils");
43
+ const version_1 = require("../version");
43
44
  /**
44
45
  * Require a connected CodieDev config. Exits the process with a helpful
45
46
  * message if the user hasn't run `codiedev connect` yet.
@@ -75,6 +76,7 @@ function apiRequest(method, path, options) {
75
76
  method,
76
77
  headers: {
77
78
  Authorization: `Bearer ${options.config.token}`,
79
+ "X-Codiedev-Cli-Version": version_1.CLI_VERSION,
78
80
  ...(data
79
81
  ? {
80
82
  "Content-Type": "application/json",
package/dist/connect.js CHANGED
@@ -39,6 +39,8 @@ const https = __importStar(require("https"));
39
39
  const http = __importStar(require("http"));
40
40
  const utils_1 = require("./utils");
41
41
  const connectFlow_1 = require("./connectFlow");
42
+ const version_1 = require("./version");
43
+ const upgradeNudge_1 = require("./upgradeNudge");
42
44
  const BACKEND_URL = process.env.CODIEDEV_URL || "https://judicious-falcon-861.convex.site";
43
45
  function prompt(rl, question) {
44
46
  return new Promise((resolve) => {
@@ -59,6 +61,7 @@ function postJson(url, body) {
59
61
  headers: {
60
62
  "Content-Type": "application/json",
61
63
  "Content-Length": Buffer.byteLength(data),
64
+ "X-Codiedev-Cli-Version": version_1.CLI_VERSION,
62
65
  },
63
66
  };
64
67
  const lib = parsed.protocol === "https:" ? https : http;
@@ -95,6 +98,7 @@ async function runConnect(args = []) {
95
98
  // engineer when he interpreted "no visible token" as "the old one is gone".
96
99
  const force = args.includes("--force") || args.includes("-f");
97
100
  console.log("\nWelcome to CodieDev CLI\n");
101
+ await (0, upgradeNudge_1.maybePrintUpgradeNudge)();
98
102
  console.log("This will connect your coding agent to your CodieDev workspace and install");
99
103
  console.log("the session capture hook for org-wide session sharing.\n");
100
104
  const saved = (0, utils_1.readConfig)();
package/dist/hook.js CHANGED
@@ -38,6 +38,7 @@ const fs = __importStar(require("fs"));
38
38
  const https = __importStar(require("https"));
39
39
  const http = __importStar(require("http"));
40
40
  const utils_1 = require("./utils");
41
+ const version_1 = require("./version");
41
42
  function postJson(url, body, bearerToken) {
42
43
  return new Promise((resolve, reject) => {
43
44
  const parsed = new URL(url);
@@ -51,6 +52,7 @@ function postJson(url, body, bearerToken) {
51
52
  "Content-Type": "application/json",
52
53
  "Content-Length": Buffer.byteLength(data),
53
54
  Authorization: `Bearer ${bearerToken}`,
55
+ "X-Codiedev-Cli-Version": version_1.CLI_VERSION,
54
56
  },
55
57
  };
56
58
  const lib = parsed.protocol === "https:" ? https : http;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Fail-silent — never throws, never blocks on network. If the registry is
3
+ * unreachable or the cache is corrupt, the warning just doesn't print. The
4
+ * worst outcome is "user keeps running an old version" — same as before
5
+ * this feature existed.
6
+ */
7
+ export declare function maybePrintUpgradeNudge(): Promise<void>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ // Client-side "you're outdated" warning. Prints at the top of connect/doctor
3
+ // when there's a newer `codiedev` published on npm. Pure helpers tested in
4
+ // __tests__/versionCheck.test.ts; this module does the IO (registry fetch +
5
+ // disk cache) and is exercised by manual smoke.
6
+ //
7
+ // Cache lives at ~/.codiedev/.update-cache.json. 24h TTL — long enough that
8
+ // the registry isn't hit on every command, short enough that newly-published
9
+ // versions surface the day after release.
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
23
+ }) : function(o, v) {
24
+ o["default"] = v;
25
+ });
26
+ var __importStar = (this && this.__importStar) || (function () {
27
+ var ownKeys = function(o) {
28
+ ownKeys = Object.getOwnPropertyNames || function (o) {
29
+ var ar = [];
30
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31
+ return ar;
32
+ };
33
+ return ownKeys(o);
34
+ };
35
+ return function (mod) {
36
+ if (mod && mod.__esModule) return mod;
37
+ var result = {};
38
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39
+ __setModuleDefault(result, mod);
40
+ return result;
41
+ };
42
+ })();
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.maybePrintUpgradeNudge = maybePrintUpgradeNudge;
45
+ const fs = __importStar(require("fs"));
46
+ const path = __importStar(require("path"));
47
+ const os = __importStar(require("os"));
48
+ const version_1 = require("./version");
49
+ const versionCheck_1 = require("./versionCheck");
50
+ const CACHE_PATH = path.join(os.homedir(), ".codiedev", ".update-cache.json");
51
+ const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
52
+ const REGISTRY_URL = "https://registry.npmjs.org/codiedev/latest";
53
+ const FETCH_TIMEOUT_MS = 1500;
54
+ function readCache() {
55
+ try {
56
+ const raw = fs.readFileSync(CACHE_PATH, "utf8");
57
+ const parsed = JSON.parse(raw);
58
+ if (typeof parsed.fetchedAt !== "number")
59
+ return null;
60
+ return parsed;
61
+ }
62
+ catch {
63
+ return null;
64
+ }
65
+ }
66
+ function writeCache(entry) {
67
+ try {
68
+ const dir = path.dirname(CACHE_PATH);
69
+ if (!fs.existsSync(dir))
70
+ fs.mkdirSync(dir, { recursive: true });
71
+ fs.writeFileSync(CACHE_PATH, JSON.stringify(entry), "utf8");
72
+ }
73
+ catch {
74
+ // ignore — cache is best-effort
75
+ }
76
+ }
77
+ async function fetchLatestFromNpm() {
78
+ try {
79
+ const controller = new AbortController();
80
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
81
+ const res = await fetch(REGISTRY_URL, {
82
+ headers: { Accept: "application/json" },
83
+ signal: controller.signal,
84
+ });
85
+ clearTimeout(timer);
86
+ if (!res.ok)
87
+ return null;
88
+ const json = (await res.json());
89
+ return json.version ?? null;
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ }
95
+ /**
96
+ * Fail-silent — never throws, never blocks on network. If the registry is
97
+ * unreachable or the cache is corrupt, the warning just doesn't print. The
98
+ * worst outcome is "user keeps running an old version" — same as before
99
+ * this feature existed.
100
+ */
101
+ async function maybePrintUpgradeNudge() {
102
+ const now = Date.now();
103
+ const cache = readCache();
104
+ let latest = cache?.latest ?? null;
105
+ const cacheStale = !cache || now - cache.fetchedAt > CACHE_TTL_MS;
106
+ if (cacheStale) {
107
+ latest = await fetchLatestFromNpm();
108
+ writeCache({ latest, fetchedAt: now });
109
+ }
110
+ const warn = (0, versionCheck_1.shouldShowUpdateWarning)({
111
+ current: version_1.CLI_VERSION,
112
+ latest,
113
+ lastChecked: cache?.fetchedAt ?? 0,
114
+ nowMs: now,
115
+ cacheTtlMs: CACHE_TTL_MS,
116
+ });
117
+ if (warn && latest) {
118
+ console.log("");
119
+ console.log(`⚠️ codiedev ${latest} available (you're on ${version_1.CLI_VERSION})`);
120
+ console.log(` Upgrade: npm i -g codiedev@latest`);
121
+ console.log("");
122
+ }
123
+ }
@@ -0,0 +1 @@
1
+ export declare const CLI_VERSION: string;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ // Resolves the running CLI version. Read once at startup so subsequent
3
+ // auth calls don't pay an fs.readFile per request.
4
+ //
5
+ // We could `import packageJson from "../package.json"` but that requires
6
+ // `resolveJsonModule` and emits the JSON into dist. Reading at runtime
7
+ // keeps the bundle smaller and works regardless of tsconfig settings.
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.CLI_VERSION = void 0;
43
+ const fs = __importStar(require("fs"));
44
+ const path = __importStar(require("path"));
45
+ function resolveCliVersion() {
46
+ // dist/version.js sits alongside dist/cli.js. The package.json is one
47
+ // directory up from dist/, i.e. `../package.json` relative to this file.
48
+ // In TS source we're at src/version.ts so the path is `../package.json`.
49
+ const candidates = [
50
+ path.join(__dirname, "..", "package.json"),
51
+ path.join(__dirname, "..", "..", "package.json"),
52
+ ];
53
+ for (const p of candidates) {
54
+ try {
55
+ const raw = fs.readFileSync(p, "utf8");
56
+ const json = JSON.parse(raw);
57
+ if (json.name === "codiedev" && typeof json.version === "string") {
58
+ return json.version;
59
+ }
60
+ }
61
+ catch {
62
+ // try next candidate
63
+ }
64
+ }
65
+ return "0.0.0";
66
+ }
67
+ exports.CLI_VERSION = resolveCliVersion();
@@ -0,0 +1,28 @@
1
+ export interface Semver {
2
+ major: number;
3
+ minor: number;
4
+ patch: number;
5
+ }
6
+ export declare function parseSemver(input: string): Semver | null;
7
+ /**
8
+ * Returns -1 if a < b, 0 if equal, 1 if a > b.
9
+ *
10
+ * Malformed input on either side returns 0 — we never want to nag a user
11
+ * because of garbage version strings (corrupt cache, registry returned
12
+ * something weird, prerelease format we don't recognize).
13
+ */
14
+ export declare function compareSemver(a: string, b: string): -1 | 0 | 1;
15
+ export interface UpdateWarningInput {
16
+ current: string;
17
+ latest: string | null;
18
+ lastChecked: number;
19
+ nowMs: number;
20
+ cacheTtlMs: number;
21
+ }
22
+ /**
23
+ * Warning policy: only show when we have a known-newer `latest` from a
24
+ * recent-enough cache. Stale-cache freshness is enforced by the *caller*
25
+ * (which decides whether to refetch); this helper takes the cache state
26
+ * as-given and answers a single question — should the user see a nag?
27
+ */
28
+ export declare function shouldShowUpdateWarning(input: UpdateWarningInput): boolean;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // Pure version-comparison helpers for the "is your CLI outdated" warning.
3
+ // The IO (fetching npm registry, reading/writing the cache file) lives in
4
+ // connect.ts/doctor.ts and is exercised by manual smoke. Keeping the policy
5
+ // pure means the truth table is unit-testable without mocking fetch or fs.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.parseSemver = parseSemver;
8
+ exports.compareSemver = compareSemver;
9
+ exports.shouldShowUpdateWarning = shouldShowUpdateWarning;
10
+ function parseSemver(input) {
11
+ if (!input)
12
+ return null;
13
+ const stripped = input.replace(/^v/i, "");
14
+ const m = stripped.match(/^(\d+)\.(\d+)\.(\d+)/);
15
+ if (!m)
16
+ return null;
17
+ return { major: Number(m[1]), minor: Number(m[2]), patch: Number(m[3]) };
18
+ }
19
+ /**
20
+ * Returns -1 if a < b, 0 if equal, 1 if a > b.
21
+ *
22
+ * Malformed input on either side returns 0 — we never want to nag a user
23
+ * because of garbage version strings (corrupt cache, registry returned
24
+ * something weird, prerelease format we don't recognize).
25
+ */
26
+ function compareSemver(a, b) {
27
+ const pa = parseSemver(a);
28
+ const pb = parseSemver(b);
29
+ if (!pa || !pb)
30
+ return 0;
31
+ if (pa.major !== pb.major)
32
+ return pa.major < pb.major ? -1 : 1;
33
+ if (pa.minor !== pb.minor)
34
+ return pa.minor < pb.minor ? -1 : 1;
35
+ if (pa.patch !== pb.patch)
36
+ return pa.patch < pb.patch ? -1 : 1;
37
+ return 0;
38
+ }
39
+ /**
40
+ * Warning policy: only show when we have a known-newer `latest` from a
41
+ * recent-enough cache. Stale-cache freshness is enforced by the *caller*
42
+ * (which decides whether to refetch); this helper takes the cache state
43
+ * as-given and answers a single question — should the user see a nag?
44
+ */
45
+ function shouldShowUpdateWarning(input) {
46
+ if (!input.latest)
47
+ return false;
48
+ return compareSemver(input.current, input.latest) === -1;
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codiedev",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "Connect Claude Code, Codex, Cursor, or VS Code Copilot to CodieDev for org-wide session capture and artifact collaboration",
5
5
  "bin": {
6
6
  "codiedev": "./dist/cli.js",