gipity 1.1.28 → 1.1.30

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.
@@ -1,7 +1,6 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { LOCAL_DIR, LOCAL_ENTRY, LOCAL_PKG_DIR, writeState, readState } from './state.js';
4
- import { npmInstallGipity, isWedged, resetLocalTree, acquireUpdateLock, releaseUpdateLock } from './install.js';
1
+ import { existsSync } from 'fs';
2
+ import { LOCAL_ENTRY, LOCAL_PKG_DIR, writeState, readState } from './state.js';
3
+ import { ensureLocalTree, npmInstallGipity, isWedged, resetLocalTree, acquireUpdateLock, releaseUpdateLock } from './install.js';
5
4
  export function isBootstrapped() {
6
5
  return existsSync(LOCAL_ENTRY);
7
6
  }
@@ -15,11 +14,7 @@ export function isBootstrapped() {
15
14
  * `gipity`, `gipity claude`, and `gipity --version`.
16
15
  */
17
16
  export function bootstrap(version, quiet = false) {
18
- mkdirSync(LOCAL_DIR, { recursive: true });
19
- const pkgJsonPath = join(LOCAL_DIR, 'package.json');
20
- if (!existsSync(pkgJsonPath)) {
21
- writeFileSync(pkgJsonPath, JSON.stringify({ name: 'gipity-local', private: true, version: '0.0.0' }, null, 2));
22
- }
17
+ ensureLocalTree();
23
18
  if (!acquireUpdateLock()) {
24
19
  // A background updater is mid-install; run from the current build now and
25
20
  // pick up the local install on a later invocation.
@@ -7,8 +7,9 @@ import { appendFileSync } from "fs";
7
7
 
8
8
  // src/updater/state.ts
9
9
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
10
- import { join } from "path";
10
+ import { dirname, join, resolve } from "path";
11
11
  import { homedir } from "os";
12
+ import { fileURLToPath } from "url";
12
13
  var GIPITY_DIR = join(homedir(), ".gipity");
13
14
  var LOCAL_DIR = join(GIPITY_DIR, "local");
14
15
  var LOCAL_PKG_DIR = join(LOCAL_DIR, "node_modules", "gipity");
@@ -16,6 +17,22 @@ var LOCAL_ENTRY = join(LOCAL_PKG_DIR, "dist", "index.js");
16
17
  var STATE_FILE = join(GIPITY_DIR, "update-state.json");
17
18
  var SETTINGS_FILE = join(GIPITY_DIR, "settings.json");
18
19
  var UPDATE_LOG = join(GIPITY_DIR, "update.log");
20
+ function findPkgRoot() {
21
+ let dir = dirname(fileURLToPath(import.meta.url));
22
+ for (; ; ) {
23
+ try {
24
+ if (JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")).name === "gipity") return dir;
25
+ } catch {
26
+ }
27
+ const up = dirname(dir);
28
+ if (up === dir) return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
29
+ dir = up;
30
+ }
31
+ }
32
+ var PKG_ROOT = findPkgRoot();
33
+ function isDevLink() {
34
+ return existsSync(join(PKG_ROOT, "src"));
35
+ }
19
36
  var DEFAULT_STATE = {
20
37
  installedVersion: null,
21
38
  lastCheckAt: 0,
@@ -57,7 +74,7 @@ function updatesDisabled() {
57
74
 
58
75
  // src/updater/install.ts
59
76
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, statSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
60
- import { dirname, join as join2 } from "path";
77
+ import { dirname as dirname2, join as join2 } from "path";
61
78
 
62
79
  // src/platform.ts
63
80
  import { execSync, spawn, spawnSync } from "child_process";
@@ -91,6 +108,7 @@ function spawnSyncCommand(cmd, args = [], options = {}) {
91
108
  var UPDATE_LOCK = join2(GIPITY_DIR, "update.lock");
92
109
  var LOCK_STALE_MS = 10 * 60 * 1e3;
93
110
  function npmInstallGipity(version) {
111
+ ensureLocalTree();
94
112
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
95
113
  cwd: LOCAL_DIR,
96
114
  stdio: ["ignore", "ignore", "pipe"],
@@ -107,6 +125,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
107
125
  function isWedged(stderr) {
108
126
  return WEDGE_CODES.test(stderr);
109
127
  }
128
+ function ensureLocalTree(dir = LOCAL_DIR) {
129
+ mkdirSync2(dir, { recursive: true });
130
+ const pkgJson = join2(dir, "package.json");
131
+ if (!existsSync2(pkgJson)) {
132
+ writeFileSync2(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
133
+ }
134
+ }
110
135
  function resetLocalTree(dir = LOCAL_DIR) {
111
136
  mkdirSync2(dir, { recursive: true });
112
137
  rmSync(join2(dir, "node_modules"), { recursive: true, force: true });
@@ -114,7 +139,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
114
139
  writeFileSync2(join2(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
115
140
  }
116
141
  function acquireUpdateLock(lockPath = UPDATE_LOCK) {
117
- mkdirSync2(dirname(lockPath), { recursive: true });
142
+ mkdirSync2(dirname2(lockPath), { recursive: true });
118
143
  try {
119
144
  writeFileSync2(lockPath, String(process.pid), { flag: "wx" });
120
145
  return true;
@@ -186,6 +211,7 @@ ${res.stderr.trim().slice(-2e3)}`);
186
211
  return { ok: false, detail: firstLine.length > 160 ? firstLine.slice(0, 157) + "..." : firstLine };
187
212
  }
188
213
  async function runCheck(opts = {}) {
214
+ if (isDevLink()) return { updated: false, reason: "dev-link" };
189
215
  const state = readState();
190
216
  if (!opts.force) {
191
217
  const dis = updatesDisabled();
@@ -17,6 +17,10 @@ const LOCK_STALE_MS = 10 * 60 * 1000;
17
17
  * precompiled (dist/) and its deps need no build step, so nothing is lost.
18
18
  */
19
19
  export function npmInstallGipity(version) {
20
+ // A missing cwd makes spawnSync fail with "spawnSync npm ENOENT", which reads
21
+ // as "npm is not installed". The tree can be gone because the user deleted it
22
+ // (our own recovery hint says to), so create it rather than mislead.
23
+ ensureLocalTree();
20
24
  const res = spawnSyncCommand(resolveCommand('npm'), ['install', '--no-audit', '--no-fund', '--ignore-scripts', `gipity@${version}`], {
21
25
  cwd: LOCAL_DIR,
22
26
  stdio: ['ignore', 'ignore', 'pipe'],
@@ -39,6 +43,15 @@ const WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
39
43
  export function isWedged(stderr) {
40
44
  return WEDGE_CODES.test(stderr);
41
45
  }
46
+ /** Make sure the local install dir and its package.json exist.
47
+ * `dir` is overridable for tests only. */
48
+ export function ensureLocalTree(dir = LOCAL_DIR) {
49
+ mkdirSync(dir, { recursive: true });
50
+ const pkgJson = join(dir, 'package.json');
51
+ if (!existsSync(pkgJson)) {
52
+ writeFileSync(pkgJson, JSON.stringify({ name: 'gipity-local', private: true, version: '0.0.0' }, null, 2));
53
+ }
54
+ }
42
55
  /** Wipe the local install tree back to a pristine, installable state.
43
56
  * `dir` is overridable for tests only. */
44
57
  export function resetLocalTree(dir = LOCAL_DIR) {
@@ -38,14 +38,15 @@ function spawnSyncCommand(cmd, args = [], options = {}) {
38
38
  }
39
39
 
40
40
  // src/updater/shim.ts
41
- import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
42
- import { fileURLToPath, pathToFileURL } from "url";
43
- import { dirname as dirname2, resolve, join as join5 } from "path";
41
+ import { readFileSync as readFileSync2 } from "fs";
42
+ import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
43
+ import { dirname as dirname3, resolve as resolve2, join as join4 } from "path";
44
44
 
45
45
  // src/updater/state.ts
46
46
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
47
- import { join } from "path";
47
+ import { dirname, join, resolve } from "path";
48
48
  import { homedir } from "os";
49
+ import { fileURLToPath } from "url";
49
50
  var GIPITY_DIR = join(homedir(), ".gipity");
50
51
  var LOCAL_DIR = join(GIPITY_DIR, "local");
51
52
  var LOCAL_PKG_DIR = join(LOCAL_DIR, "node_modules", "gipity");
@@ -53,6 +54,22 @@ var LOCAL_ENTRY = join(LOCAL_PKG_DIR, "dist", "index.js");
53
54
  var STATE_FILE = join(GIPITY_DIR, "update-state.json");
54
55
  var SETTINGS_FILE = join(GIPITY_DIR, "settings.json");
55
56
  var UPDATE_LOG = join(GIPITY_DIR, "update.log");
57
+ function findPkgRoot() {
58
+ let dir = dirname(fileURLToPath(import.meta.url));
59
+ for (; ; ) {
60
+ try {
61
+ if (JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")).name === "gipity") return dir;
62
+ } catch {
63
+ }
64
+ const up = dirname(dir);
65
+ if (up === dir) return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
66
+ dir = up;
67
+ }
68
+ }
69
+ var PKG_ROOT = findPkgRoot();
70
+ function isDevLink() {
71
+ return existsSync(join(PKG_ROOT, "src"));
72
+ }
56
73
  var DEFAULT_STATE = {
57
74
  installedVersion: null,
58
75
  lastCheckAt: 0,
@@ -76,15 +93,15 @@ function writeState(state) {
76
93
  }
77
94
 
78
95
  // src/updater/bootstrap.ts
79
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
80
- import { join as join3 } from "path";
96
+ import { existsSync as existsSync3 } from "fs";
81
97
 
82
98
  // src/updater/install.ts
83
99
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, statSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
84
- import { dirname, join as join2 } from "path";
100
+ import { dirname as dirname2, join as join2 } from "path";
85
101
  var UPDATE_LOCK = join2(GIPITY_DIR, "update.lock");
86
102
  var LOCK_STALE_MS = 10 * 60 * 1e3;
87
103
  function npmInstallGipity(version) {
104
+ ensureLocalTree();
88
105
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
89
106
  cwd: LOCAL_DIR,
90
107
  stdio: ["ignore", "ignore", "pipe"],
@@ -101,6 +118,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
101
118
  function isWedged(stderr) {
102
119
  return WEDGE_CODES.test(stderr);
103
120
  }
121
+ function ensureLocalTree(dir = LOCAL_DIR) {
122
+ mkdirSync2(dir, { recursive: true });
123
+ const pkgJson = join2(dir, "package.json");
124
+ if (!existsSync2(pkgJson)) {
125
+ writeFileSync2(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
126
+ }
127
+ }
104
128
  function resetLocalTree(dir = LOCAL_DIR) {
105
129
  mkdirSync2(dir, { recursive: true });
106
130
  rmSync(join2(dir, "node_modules"), { recursive: true, force: true });
@@ -108,7 +132,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
108
132
  writeFileSync2(join2(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
109
133
  }
110
134
  function acquireUpdateLock(lockPath = UPDATE_LOCK) {
111
- mkdirSync2(dirname(lockPath), { recursive: true });
135
+ mkdirSync2(dirname2(lockPath), { recursive: true });
112
136
  try {
113
137
  writeFileSync2(lockPath, String(process.pid), { flag: "wx" });
114
138
  return true;
@@ -136,11 +160,7 @@ function isBootstrapped() {
136
160
  return existsSync3(LOCAL_ENTRY);
137
161
  }
138
162
  function bootstrap(version, quiet = false) {
139
- mkdirSync3(LOCAL_DIR, { recursive: true });
140
- const pkgJsonPath = join3(LOCAL_DIR, "package.json");
141
- if (!existsSync3(pkgJsonPath)) {
142
- writeFileSync3(pkgJsonPath, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
143
- }
163
+ ensureLocalTree();
144
164
  if (!acquireUpdateLock()) {
145
165
  if (!quiet) process.stderr.write(`gipity: another update is in progress - using the currently installed build.
146
166
  `);
@@ -182,8 +202,8 @@ function bootstrap(version, quiet = false) {
182
202
  }
183
203
 
184
204
  // src/trace.ts
185
- import { openSync, writeSync, mkdirSync as mkdirSync4 } from "fs";
186
- import { join as join4 } from "path";
205
+ import { openSync, writeSync, mkdirSync as mkdirSync3 } from "fs";
206
+ import { join as join3 } from "path";
187
207
  import { homedir as homedir2 } from "os";
188
208
  var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
189
209
  function installOutputTrace(label) {
@@ -195,10 +215,10 @@ function installOutputTrace(label) {
195
215
  existing.emit({ event: "reenter", label });
196
216
  return;
197
217
  }
198
- const dir = join4(process.env.GIPITY_DIR || join4(homedir2(), ".gipity"), "trace");
199
- mkdirSync4(dir, { recursive: true });
218
+ const dir = join3(process.env.GIPITY_DIR || join3(homedir2(), ".gipity"), "trace");
219
+ mkdirSync3(dir, { recursive: true });
200
220
  const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
201
- const fd = openSync(join4(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
221
+ const fd = openSync(join3(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
202
222
  const emit = (rec) => {
203
223
  try {
204
224
  writeSync(fd, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
@@ -233,12 +253,12 @@ function installOutputTrace(label) {
233
253
 
234
254
  // src/updater/shim.ts
235
255
  installOutputTrace("shim");
236
- var __dirname = dirname2(fileURLToPath(import.meta.url));
237
- var pkgRoot = resolve(__dirname, "..", "..");
238
- var shimPkg = JSON.parse(readFileSync2(join5(pkgRoot, "package.json"), "utf-8"));
239
- var isDevLink = existsSync4(join5(pkgRoot, "src"));
256
+ var __dirname = dirname3(fileURLToPath2(import.meta.url));
257
+ var pkgRoot = resolve2(__dirname, "..", "..");
258
+ var shimPkg = JSON.parse(readFileSync2(join4(pkgRoot, "package.json"), "utf-8"));
259
+ var devLink = isDevLink();
240
260
  function startBackgroundUpdater() {
241
- const checkScript = join5(__dirname, "check.js");
261
+ const checkScript = join4(__dirname, "check.js");
242
262
  try {
243
263
  const child = spawnCommand(process.execPath, [checkScript], {
244
264
  detached: true,
@@ -260,11 +280,11 @@ async function runEntry(entry) {
260
280
  }
261
281
  }
262
282
  var execLocal = () => runEntry(LOCAL_ENTRY);
263
- var execSelf = () => runEntry(resolve(__dirname, "..", "index.js"));
283
+ var execSelf = () => runEntry(resolve2(__dirname, "..", "index.js"));
264
284
  var rawArgs = process.argv.slice(2);
265
285
  var firstArg = rawArgs[0];
266
286
  var isLoud = rawArgs.length === 0 || firstArg === "claude" || firstArg === "--version" || firstArg === "-v" || firstArg === "version";
267
- if (isDevLink) {
287
+ if (devLink) {
268
288
  await execSelf();
269
289
  } else if (!isBootstrapped() && !bootstrap(shimPkg.version, !isLoud)) {
270
290
  await execSelf();
@@ -1,6 +1,7 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
2
- import { join } from 'path';
2
+ import { dirname, join, resolve } from 'path';
3
3
  import { homedir } from 'os';
4
+ import { fileURLToPath } from 'url';
4
5
  export const GIPITY_DIR = join(homedir(), '.gipity');
5
6
  export const LOCAL_DIR = join(GIPITY_DIR, 'local');
6
7
  export const LOCAL_PKG_DIR = join(LOCAL_DIR, 'node_modules', 'gipity');
@@ -8,6 +9,31 @@ export const LOCAL_ENTRY = join(LOCAL_PKG_DIR, 'dist', 'index.js');
8
9
  export const STATE_FILE = join(GIPITY_DIR, 'update-state.json');
9
10
  export const SETTINGS_FILE = join(GIPITY_DIR, 'settings.json');
10
11
  export const UPDATE_LOG = join(GIPITY_DIR, 'update.log');
12
+ /** Root of the gipity package this code runs from. Walks up to its
13
+ * package.json because the depth differs: dist/updater/*.js are separate
14
+ * files, while dist/index.js is a bundle that inlines this module. */
15
+ function findPkgRoot() {
16
+ let dir = dirname(fileURLToPath(import.meta.url));
17
+ for (;;) {
18
+ try {
19
+ if (JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8')).name === 'gipity')
20
+ return dir;
21
+ }
22
+ catch { /* no package.json here */ }
23
+ const up = dirname(dir);
24
+ if (up === dir)
25
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
26
+ dir = up;
27
+ }
28
+ }
29
+ export const PKG_ROOT = findPkgRoot();
30
+ /** Published tarballs ship `dist/**` only (package.json `files`), so a sibling
31
+ * `src/` means `gipity` was `npm link`ed from a source checkout. A dev link
32
+ * runs that checkout's own build and never auto-updates: installing a
33
+ * published copy into ~/.gipity/local would be pointless (nothing runs it). */
34
+ export function isDevLink() {
35
+ return existsSync(join(PKG_ROOT, 'src'));
36
+ }
11
37
  const DEFAULT_STATE = {
12
38
  installedVersion: null,
13
39
  lastCheckAt: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gipity",
3
- "version": "1.1.28",
3
+ "version": "1.1.30",
4
4
  "description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
5
5
  "bin": {
6
6
  "gipity": "dist/updater/shim.js",