nstantpage-agent 0.5.24 → 0.5.25

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/dist/agentSync.js CHANGED
@@ -148,11 +148,11 @@ export class AgentSync {
148
148
  }
149
149
  // ─── Disk Dirty State ─────────────────────────────────────
150
150
  markDiskDirty() {
151
- const wasDirty = this.diskDirty;
152
151
  this.diskDirty = true;
153
152
  this.diskChecksumCache = null; // Force recompute
154
- // Only notify on transition from clean to dirty
155
- if (!wasDirty && this.onSyncDirty) {
153
+ // Notify on every change the debounce timer in the file watcher
154
+ // already batches rapid changes, so this fires at most once per debounce window.
155
+ if (this.onSyncDirty) {
156
156
  this.onSyncDirty(this.projectId);
157
157
  }
158
158
  }
@@ -26,7 +26,7 @@ import { LocalServer } from '../localServer.js';
26
26
  import { PackageInstaller } from '../packageInstaller.js';
27
27
  import { probeLocalPostgres, ensureLocalProjectDb, closeAdminPool, writeDatabaseUrlToEnv } from '../projectDb.js';
28
28
  import { StatusServer } from '../statusServer.js';
29
- const VERSION = '0.5.22';
29
+ const VERSION = '0.5.24';
30
30
  /**
31
31
  * Resolve the backend API base URL.
32
32
  * - If --backend is passed, use it
@@ -82,7 +82,7 @@ async function fetchProjectFiles(backendUrl, projectId, projectDir, token) {
82
82
  : null;
83
83
  if (existingVersion === String(data.versionId)) {
84
84
  console.log(chalk.gray(` Files up-to-date (version ${data.version})`));
85
- return { fileCount: data.files.length, isNew: false };
85
+ return { fileCount: data.files.length, isNew: false, versionId: String(data.versionId) };
86
86
  }
87
87
  // Write all files to disk in parallel (batch I/O for speed)
88
88
  // First, collect unique directories to create
@@ -111,7 +111,7 @@ async function fetchProjectFiles(backendUrl, projectId, projectDir, token) {
111
111
  // Write version marker
112
112
  fs.writeFileSync(versionFile, String(data.versionId), 'utf-8');
113
113
  console.log(chalk.green(` ✓ ${written} files downloaded (version ${data.version})`));
114
- return { fileCount: written, isNew: true };
114
+ return { fileCount: written, isNew: true, versionId: String(data.versionId) };
115
115
  }
116
116
  /**
117
117
  * Kill any process listening on the given port.
@@ -242,8 +242,10 @@ export async function startCommand(directory, options) {
242
242
  console.log(chalk.gray(` Backend: ${backendUrl}\n`));
243
243
  // 1. Fetch project files from the backend
244
244
  const installer = new PackageInstaller({ projectDir });
245
+ let fetchedVersionId;
245
246
  try {
246
- const { fileCount, isNew } = await fetchProjectFiles(backendUrl, projectId, projectDir, token);
247
+ const { fileCount, isNew, versionId } = await fetchProjectFiles(backendUrl, projectId, projectDir, token);
248
+ fetchedVersionId = versionId;
247
249
  // 2. Install dependencies if needed (verifies actual packages, not just folder)
248
250
  if (!installer.areDependenciesInstalled()) {
249
251
  if (fs.existsSync(path.join(projectDir, 'package.json'))) {
@@ -424,6 +426,10 @@ export async function startCommand(directory, options) {
424
426
  console.log(chalk.gray(' Starting local API server...'));
425
427
  await localServer.start();
426
428
  console.log(chalk.green(` ✓ API server on port ${apiPort}`));
429
+ // Set sync baseline so file watcher knows what "clean" looks like
430
+ if (fetchedVersionId) {
431
+ localServer.markSynced(fetchedVersionId);
432
+ }
427
433
  // Start dev server unless --no-dev flag
428
434
  if (!options.noDev) {
429
435
  if (installer.areDependenciesInstalled()) {
@@ -81,6 +81,11 @@ export declare class LocalServer {
81
81
  */
82
82
  private ensureDatabase;
83
83
  getDevServer(): DevServer;
84
+ /**
85
+ * Set initial sync baseline after fetching project files.
86
+ * This tells agentSync what "clean" looks like so it can detect local edits.
87
+ */
88
+ markSynced(versionId: string): void;
84
89
  getApiPort(): number;
85
90
  getDevPort(): number;
86
91
  start(): Promise<void>;
@@ -162,6 +162,16 @@ export class LocalServer {
162
162
  getDevServer() {
163
163
  return this.devServer;
164
164
  }
165
+ /**
166
+ * Set initial sync baseline after fetching project files.
167
+ * This tells agentSync what "clean" looks like so it can detect local edits.
168
+ */
169
+ markSynced(versionId) {
170
+ if (this.agentSync) {
171
+ this.agentSync.markSynced(versionId);
172
+ console.log(` [LocalServer] Sync baseline set (version ${versionId})`);
173
+ }
174
+ }
165
175
  getApiPort() {
166
176
  return this.options.apiPort;
167
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nstantpage-agent",
3
- "version": "0.5.24",
3
+ "version": "0.5.25",
4
4
  "description": "Local development agent for nstantpage.com — run your projects locally, preview in the cloud. Replaces cloud containers for faster builds.",
5
5
  "type": "module",
6
6
  "bin": {