@tom2012/cc-web 1.5.93 → 1.5.94

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 (45) hide show
  1. package/README.md +1 -1
  2. package/backend/dist/memory-pool/global-pool-manager.d.ts +2 -11
  3. package/backend/dist/memory-pool/global-pool-manager.d.ts.map +1 -1
  4. package/backend/dist/memory-pool/global-pool-manager.js +126 -232
  5. package/backend/dist/memory-pool/global-pool-manager.js.map +1 -1
  6. package/backend/dist/memory-pool/pool-lock.d.ts +2 -0
  7. package/backend/dist/memory-pool/pool-lock.d.ts.map +1 -0
  8. package/backend/dist/memory-pool/pool-lock.js +31 -0
  9. package/backend/dist/memory-pool/pool-lock.js.map +1 -0
  10. package/backend/dist/memory-pool/pool-manager.d.ts +34 -0
  11. package/backend/dist/memory-pool/pool-manager.d.ts.map +1 -1
  12. package/backend/dist/memory-pool/pool-manager.js +91 -0
  13. package/backend/dist/memory-pool/pool-manager.js.map +1 -1
  14. package/backend/dist/memory-pool/templates.d.ts.map +1 -1
  15. package/backend/dist/memory-pool/templates.js +97 -131
  16. package/backend/dist/memory-pool/templates.js.map +1 -1
  17. package/backend/dist/memory-pool/types.d.ts +4 -8
  18. package/backend/dist/memory-pool/types.d.ts.map +1 -1
  19. package/backend/dist/routes/hooks.d.ts.map +1 -1
  20. package/backend/dist/routes/hooks.js +14 -0
  21. package/backend/dist/routes/hooks.js.map +1 -1
  22. package/backend/dist/routes/memory-pool.d.ts.map +1 -1
  23. package/backend/dist/routes/memory-pool.js +505 -95
  24. package/backend/dist/routes/memory-pool.js.map +1 -1
  25. package/frontend/dist/assets/{GraphPreview-CSZTNhQX.js → GraphPreview-BFYA_WA5.js} +1 -1
  26. package/frontend/dist/assets/{OfficePreview-DZmKFnER.js → OfficePreview-DN-it4Af.js} +2 -2
  27. package/frontend/dist/assets/{PlanPanel-DuAa0AZZ.js → PlanPanel-DYupjf3X.js} +1 -1
  28. package/frontend/dist/assets/{ProjectPage-BxuE0x69.js → ProjectPage-B6tVjIYr.js} +5 -5
  29. package/frontend/dist/assets/{SettingsPage-DSnQze4Z.js → SettingsPage-CQL_FfkR.js} +1 -1
  30. package/frontend/dist/assets/{ShareViewPage-Dmur70tT.js → ShareViewPage-C_x31zAw.js} +1 -1
  31. package/frontend/dist/assets/{SkillHubPage-DnGb0OHx.js → SkillHubPage-Cgoxl30L.js} +2 -2
  32. package/frontend/dist/assets/{bot-DKy4a5yK.js → bot-Dst2XqWX.js} +1 -1
  33. package/frontend/dist/assets/{chevron-down-B-GU2wv8.js → chevron-down-DsAldQb3.js} +1 -1
  34. package/frontend/dist/assets/{download-CsOUNuPy.js → download-YA6lXM4C.js} +1 -1
  35. package/frontend/dist/assets/index-BDYnq-Fr.css +1 -0
  36. package/frontend/dist/assets/{index-C202jcvT.js → index-CY9Au1bg.js} +4 -4
  37. package/frontend/dist/assets/{index-I4_xf4g_.js → index-_m8u9esJ.js} +1 -1
  38. package/frontend/dist/assets/{jszip.min-Dc0FmeMP.js → jszip.min-BC9RCrTS.js} +1 -1
  39. package/frontend/dist/assets/{matter-Da3rDMpe.js → matter-Mm9BJmx6.js} +1 -1
  40. package/frontend/dist/assets/{maximize-2-BEyzEiyH.js → maximize-2-CuzznumM.js} +1 -1
  41. package/frontend/dist/assets/{save-BYSx9fYK.js → save-Q2W6S7fk.js} +1 -1
  42. package/frontend/dist/assets/{user-D3KuBJwv.js → user-BM9GY1Xb.js} +1 -1
  43. package/frontend/dist/index.html +2 -2
  44. package/package.json +1 -1
  45. package/frontend/dist/assets/index-BiVVvGoh.css +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A self-hosted web application (distributed as npm package) that provides a browser-based interface for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI sessions. Create projects, each with a persistent terminal running Claude Code, and interact with them through a real-time terminal UI.
4
4
 
5
- **Current version**: v1.5.90 | [GitHub](https://github.com/zbc0315/cc-web) | MIT License
5
+ **Current version**: v1.5.94 | [GitHub](https://github.com/zbc0315/cc-web) | MIT License
6
6
 
7
7
  ## Features
8
8
 
@@ -1,4 +1,4 @@
1
- import { PoolJson, SourcesJson, SyncResult, ImportPreviewBall } from './types';
1
+ import { PoolJson, SourcesJson, SyncResult } from './types';
2
2
  export declare function getGlobalPoolDir(): string;
3
3
  export declare function readSources(): SourcesJson;
4
4
  export declare function writeSources(data: SourcesJson): void;
@@ -8,14 +8,5 @@ export declare function readGlobalPool(): PoolJson | null;
8
8
  export declare function computeGlobalT(initializedAt: string): number;
9
9
  export declare function registerProject(projectId: string, projectName: string, poolPath: string): void;
10
10
  export declare function removeSource(projectId: string): boolean;
11
- export declare function syncToGlobal(): SyncResult;
12
- export declare function getImportPreview(projectPoolDir: string): ImportPreviewBall[];
13
- export declare function importFromGlobal(projectPoolDir: string, selectedGlobalIds: string[]): {
14
- imported: number;
15
- balls: Array<{
16
- local_id: string;
17
- global_id: string;
18
- summary: string;
19
- }>;
20
- };
11
+ export declare function syncToGlobal(): Promise<SyncResult>;
21
12
  //# sourceMappingURL=global-pool-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-pool-manager.d.ts","sourceRoot":"","sources":["../../src/memory-pool/global-pool-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAe,UAAU,EAAgB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAU1G,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAQD,wBAAgB,WAAW,IAAI,WAAW,CAQzC;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEpD;AAID,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAmBvC;AAED,wBAAgB,cAAc,IAAI,QAAQ,GAAG,IAAI,CAEhD;AAID,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAI5D;AAID,wBAAgB,eAA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,wBAAsB,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC,CA8JxD"}
@@ -44,13 +44,12 @@ exports.computeGlobalT = computeGlobalT;
44
44
  exports.registerProject = registerProject;
45
45
  exports.removeSource = removeSource;
46
46
  exports.syncToGlobal = syncToGlobal;
47
- exports.getImportPreview = getImportPreview;
48
- exports.importFromGlobal = importFromGlobal;
49
47
  const fs = __importStar(require("fs"));
50
48
  const path = __importStar(require("path"));
51
49
  const os = __importStar(require("os"));
52
50
  const config_1 = require("../config");
53
51
  const pool_manager_1 = require("./pool-manager");
52
+ const pool_lock_1 = require("./pool-lock");
54
53
  const buoyancy_1 = require("./buoyancy");
55
54
  const GLOBAL_POOL_DIR = path.join(os.homedir(), '.ccweb', 'memory-pool');
56
55
  const SOURCES_FILE = 'sources.json';
@@ -92,6 +91,7 @@ function ensureGlobalPool() {
92
91
  lambda: 0.99,
93
92
  alpha: 1.0,
94
93
  active_capacity: 40,
94
+ surface_width: 10000,
95
95
  next_id: 1,
96
96
  pool: 'global',
97
97
  initialized_at: now,
@@ -144,253 +144,147 @@ function removeSource(projectId) {
144
144
  return true;
145
145
  }
146
146
  // ── Sync (global operation) ──
147
- function syncToGlobal() {
147
+ async function syncToGlobal() {
148
148
  if (syncInProgress) {
149
149
  throw new Error('SYNC_IN_PROGRESS');
150
150
  }
151
151
  syncInProgress = true;
152
152
  try {
153
- ensureGlobalPool();
154
- const globalPool = readGlobalPool();
155
- const sources = readSources();
156
- const globalT = computeGlobalT(globalPool.initialized_at);
157
- globalPool.t = globalT;
158
- const result = {
159
- added: 0,
160
- updated: 0,
161
- skipped: 0,
162
- orphaned: 0,
163
- unreachable_projects: [],
164
- synced_projects: [],
165
- };
166
- // Build origin lookup: "projectId:ballId" → global ball index
167
- const originMap = new Map();
168
- globalPool.balls.forEach((gb, idx) => {
169
- if (gb.origins) {
170
- for (const o of gb.origins) {
171
- originMap.set(`${o.source_project}:${o.source_ball_id}`, idx);
153
+ return await (0, pool_lock_1.withPoolLock)(GLOBAL_POOL_DIR, () => {
154
+ ensureGlobalPool();
155
+ const globalPool = readGlobalPool();
156
+ const sources = readSources();
157
+ const globalT = computeGlobalT(globalPool.initialized_at);
158
+ globalPool.t = globalT;
159
+ const result = {
160
+ added: 0,
161
+ updated: 0,
162
+ skipped: 0,
163
+ orphaned: 0,
164
+ unreachable_projects: [],
165
+ synced_projects: [],
166
+ };
167
+ // Build origin lookup: "projectId:ballId" → global ball index
168
+ const originMap = new Map();
169
+ globalPool.balls.forEach((gb, idx) => {
170
+ if (gb.origins) {
171
+ for (const o of gb.origins) {
172
+ originMap.set(`${o.source_project}:${o.source_ball_id}`, idx);
173
+ }
172
174
  }
173
- }
174
- });
175
- // Track which origins are still alive (from synced projects only)
176
- const aliveOrigins = new Set();
177
- // Track projects that were actually synced (for orphan detection scoping)
178
- const syncedProjectIds = new Set();
179
- // Step 1 & 2: Collect and merge
180
- for (const source of sources.sources) {
181
- if (source.status === 'unreachable')
182
- continue;
183
- const projectPool = (0, pool_manager_1.readPool)(source.pool_path);
184
- if (!projectPool) {
185
- source.unreachable_count = (source.unreachable_count ?? 0) + 1;
186
- if (source.unreachable_count >= 3) {
187
- source.status = 'unreachable';
175
+ });
176
+ // Track which origins are still alive (from synced projects only)
177
+ const aliveOrigins = new Set();
178
+ // Track projects that were actually synced (for orphan detection scoping)
179
+ const syncedProjectIds = new Set();
180
+ // Step 1 & 2: Collect and merge
181
+ for (const source of sources.sources) {
182
+ if (source.status === 'unreachable')
183
+ continue;
184
+ const projectPool = (0, pool_manager_1.readPool)(source.pool_path);
185
+ if (!projectPool) {
186
+ source.unreachable_count = (source.unreachable_count ?? 0) + 1;
187
+ if (source.unreachable_count >= 3) {
188
+ source.status = 'unreachable';
189
+ }
190
+ result.unreachable_projects.push(source.project_name);
191
+ continue;
188
192
  }
189
- result.unreachable_projects.push(source.project_name);
190
- continue;
191
- }
192
- // Reset unreachable count on success
193
- source.unreachable_count = 0;
194
- source.last_synced_at = new Date().toISOString();
195
- result.synced_projects.push(source.project_name);
196
- syncedProjectIds.add(source.project_id);
197
- for (const ball of projectPool.balls) {
198
- const originKey = `${source.project_id}:${ball.id}`;
199
- aliveOrigins.add(originKey);
200
- const existingIdx = originMap.get(originKey);
201
- if (existingIdx !== undefined) {
202
- // Already exists check content change
203
- const globalBall = globalPool.balls[existingIdx];
204
- const projectContent = (0, pool_manager_1.readBallContent)(source.pool_path, ball.id);
205
- const globalContent = (0, pool_manager_1.readBallContent)(GLOBAL_POOL_DIR, globalBall.id);
206
- if (projectContent !== null && projectContent !== globalContent) {
207
- // Content changed — update content, keep global H
208
- (0, pool_manager_1.writeBallContent)(GLOBAL_POOL_DIR, globalBall.id, projectContent);
209
- globalBall.summary = ball.summary;
210
- globalBall.t_last = globalT;
211
- result.updated++;
193
+ // Reset unreachable count on success
194
+ source.unreachable_count = 0;
195
+ source.last_synced_at = new Date().toISOString();
196
+ result.synced_projects.push(source.project_name);
197
+ syncedProjectIds.add(source.project_id);
198
+ for (const ball of projectPool.balls) {
199
+ const originKey = `${source.project_id}:${ball.id}`;
200
+ aliveOrigins.add(originKey);
201
+ const existingIdx = originMap.get(originKey);
202
+ if (existingIdx !== undefined) {
203
+ // Already exists — check content change
204
+ const globalBall = globalPool.balls[existingIdx];
205
+ const projectContent = (0, pool_manager_1.readBallContent)(source.pool_path, ball.id);
206
+ const globalContent = (0, pool_manager_1.readBallContent)(GLOBAL_POOL_DIR, globalBall.id);
207
+ if (projectContent !== null && projectContent !== globalContent) {
208
+ // Content changed update content, keep global H
209
+ (0, pool_manager_1.writeBallContent)(GLOBAL_POOL_DIR, globalBall.id, projectContent);
210
+ globalBall.summary = ball.summary;
211
+ globalBall.t_last = globalT;
212
+ result.updated++;
213
+ }
214
+ else {
215
+ // Touch: refresh t_last
216
+ globalBall.t_last = globalT;
217
+ result.skipped++;
218
+ }
212
219
  }
213
220
  else {
214
- // Touch: refresh t_last
215
- globalBall.t_last = globalT;
216
- result.skipped++;
217
- }
218
- }
219
- else {
220
- // New ball — compute project buoyancy as B0
221
- const projectBuoyancy = (0, buoyancy_1.computeBuoyancy)(ball.B0, ball.H, projectPool.alpha, projectPool.lambda, projectPool.t, ball.t_last, ball.permanent);
222
- const newId = `ball_${String(globalPool.next_id).padStart(4, '0')}`;
223
- globalPool.next_id++;
224
- const newBall = {
225
- id: newId,
226
- type: ball.type,
227
- summary: ball.summary,
228
- B0: Math.round(projectBuoyancy * 100) / 100,
229
- H: 0,
230
- t_last: globalT,
231
- hardness: ball.hardness,
232
- permanent: ball.permanent,
233
- links: [], // Links resolved separately
234
- created_at: ball.created_at,
235
- origins: [{
236
- source_project: source.project_id,
237
- source_ball_id: ball.id,
238
- synced_at: new Date().toISOString(),
239
- }],
240
- };
241
- // Write ball content first (gate pattern)
242
- const content = (0, pool_manager_1.readBallContent)(source.pool_path, ball.id);
243
- if (content !== null) {
244
- (0, pool_manager_1.writeBallContent)(GLOBAL_POOL_DIR, newId, content);
221
+ // New ball — compute project buoyancy as B0
222
+ const projectBuoyancy = (0, buoyancy_1.computeBuoyancy)(ball.B0, ball.H, projectPool.alpha, projectPool.lambda, projectPool.t, ball.t_last, ball.permanent);
223
+ const newId = `ball_${String(globalPool.next_id).padStart(4, '0')}`;
224
+ globalPool.next_id++;
225
+ const newBall = {
226
+ id: newId,
227
+ type: ball.type,
228
+ summary: ball.summary,
229
+ B0: Math.round(projectBuoyancy * 100) / 100,
230
+ H: 0,
231
+ t_last: globalT,
232
+ hardness: ball.hardness,
233
+ permanent: ball.permanent,
234
+ links: [], // Links resolved separately
235
+ created_at: ball.created_at,
236
+ origins: [{
237
+ source_project: source.project_id,
238
+ source_ball_id: ball.id,
239
+ synced_at: new Date().toISOString(),
240
+ }],
241
+ };
242
+ // Write ball content first (gate pattern)
243
+ const content = (0, pool_manager_1.readBallContent)(source.pool_path, ball.id);
244
+ if (content !== null) {
245
+ (0, pool_manager_1.writeBallContent)(GLOBAL_POOL_DIR, newId, content);
246
+ }
247
+ globalPool.balls.push(newBall);
248
+ originMap.set(originKey, globalPool.balls.length - 1);
249
+ result.added++;
245
250
  }
246
- globalPool.balls.push(newBall);
247
- originMap.set(originKey, globalPool.balls.length - 1);
248
- result.added++;
249
251
  }
250
252
  }
251
- }
252
- // Step 3: Orphan detection (only check origins from synced projects)
253
- for (const gb of globalPool.balls) {
254
- if (!gb.origins || gb.origins.length === 0)
255
- continue;
256
- // Only remove origins whose source project was actually synced and ball is gone
257
- gb.origins = gb.origins.filter((o) => {
258
- if (!syncedProjectIds.has(o.source_project))
259
- return true; // preserve unreachable/unsynced origins
260
- return aliveOrigins.has(`${o.source_project}:${o.source_ball_id}`);
261
- });
262
- if (gb.origins.length === 0 && !gb.orphaned) {
263
- gb.pre_orphan_B0 = gb.B0;
264
- gb.orphaned = true;
265
- gb.B0 = Math.round(gb.B0 * 0.5 * 100) / 100;
266
- result.orphaned++;
267
- }
268
- else if (gb.origins.length > 0 && gb.orphaned) {
269
- // Restore orphaned ball when origins reappear
270
- if (gb.pre_orphan_B0 !== undefined) {
271
- gb.B0 = gb.pre_orphan_B0;
272
- delete gb.pre_orphan_B0;
253
+ // Step 3: Orphan detection (only check origins from synced projects)
254
+ for (const gb of globalPool.balls) {
255
+ if (!gb.origins || gb.origins.length === 0)
256
+ continue;
257
+ // Only remove origins whose source project was actually synced and ball is gone
258
+ gb.origins = gb.origins.filter((o) => {
259
+ if (!syncedProjectIds.has(o.source_project))
260
+ return true; // preserve unreachable/unsynced origins
261
+ return aliveOrigins.has(`${o.source_project}:${o.source_ball_id}`);
262
+ });
263
+ if (gb.origins.length === 0 && !gb.orphaned) {
264
+ gb.pre_orphan_B0 = gb.B0;
265
+ gb.orphaned = true;
266
+ gb.B0 = Math.round(gb.B0 * 0.5 * 100) / 100;
267
+ result.orphaned++;
268
+ }
269
+ else if (gb.origins.length > 0 && gb.orphaned) {
270
+ // Restore orphaned ball when origins reappear
271
+ if (gb.pre_orphan_B0 !== undefined) {
272
+ gb.B0 = gb.pre_orphan_B0;
273
+ delete gb.pre_orphan_B0;
274
+ }
275
+ gb.orphaned = false;
273
276
  }
274
- gb.orphaned = false;
275
277
  }
276
- }
277
- // Step 4: Write pool.json LAST (gate)
278
- (0, pool_manager_1.writePool)(GLOBAL_POOL_DIR, globalPool);
279
- writeSources(sources);
280
- return result;
278
+ // Step 4: Write pool.json LAST (gate)
279
+ (0, pool_manager_1.writePool)(GLOBAL_POOL_DIR, globalPool);
280
+ writeSources(sources);
281
+ // Step 5: Rebuild global surface.md
282
+ (0, pool_manager_1.buildSurface)(GLOBAL_POOL_DIR);
283
+ return result;
284
+ });
281
285
  }
282
286
  finally {
283
287
  syncInProgress = false;
284
288
  }
285
289
  }
286
- // ── Import preview ──
287
- function getImportPreview(projectPoolDir) {
288
- const globalPool = readGlobalPool();
289
- if (!globalPool)
290
- return [];
291
- // Use fresh calendar-based t for accurate buoyancy
292
- globalPool.t = computeGlobalT(globalPool.initialized_at);
293
- const projectPool = (0, pool_manager_1.readPool)(projectPoolDir);
294
- if (!projectPool)
295
- return [];
296
- // Get global active balls sorted by buoyancy
297
- const enriched = (0, pool_manager_1.enrichBallsWithBuoyancy)(globalPool);
298
- const activeBalls = enriched.slice(0, globalPool.active_capacity);
299
- // Find which global balls are already imported into this project
300
- const importedGlobalIds = new Set(projectPool.balls.filter((b) => b.global_ball_id).map((b) => b.global_ball_id));
301
- return activeBalls
302
- .filter((b) => !importedGlobalIds.has(b.id) && !b.orphaned)
303
- .map((b) => ({
304
- global_ball_id: b.id,
305
- type: b.type,
306
- summary: b.summary,
307
- buoyancy: b.buoyancy,
308
- origins_count: b.origins?.length ?? 0,
309
- }));
310
- }
311
- // ── Import from global ──
312
- function importFromGlobal(projectPoolDir, selectedGlobalIds) {
313
- const globalPool = readGlobalPool();
314
- if (!globalPool)
315
- throw new Error('Global pool not initialized');
316
- // Use fresh calendar-based t for accurate buoyancy
317
- globalPool.t = computeGlobalT(globalPool.initialized_at);
318
- const projectPool = (0, pool_manager_1.readPool)(projectPoolDir);
319
- if (!projectPool)
320
- throw new Error('Project pool not initialized');
321
- // Compute global buoyancies
322
- const enriched = (0, pool_manager_1.enrichBallsWithBuoyancy)(globalPool);
323
- const globalBallMap = new Map(enriched.map((b) => [b.id, b]));
324
- // Compute project active layer lowest buoyancy for B0 normalization
325
- const projectEnriched = (0, pool_manager_1.enrichBallsWithBuoyancy)(projectPool);
326
- const projectActiveBalls = projectEnriched.slice(0, projectPool.active_capacity);
327
- const lowestActiveB = projectActiveBalls.length > 0
328
- ? projectActiveBalls[projectActiveBalls.length - 1].buoyancy
329
- : 5;
330
- // Default B0 by type
331
- const defaultB0 = { feedback: 8, user: 5, project: 4, reference: 2 };
332
- // Build global→local ID mapping for links (include previously imported balls)
333
- const globalToLocal = new Map();
334
- for (const b of projectPool.balls) {
335
- if (b.global_ball_id) {
336
- globalToLocal.set(b.global_ball_id, b.id);
337
- }
338
- }
339
- const imported = [];
340
- // First pass: assign local IDs for new imports
341
- for (const gid of selectedGlobalIds) {
342
- const gb = globalBallMap.get(gid);
343
- if (!gb)
344
- continue;
345
- // Skip if already imported
346
- if (globalToLocal.has(gid))
347
- continue;
348
- const localId = `ball_${String(projectPool.next_id).padStart(4, '0')}`;
349
- projectPool.next_id++;
350
- globalToLocal.set(gid, localId);
351
- }
352
- // Collect newly assigned IDs (exclude previously imported)
353
- const previouslyImported = new Set(projectPool.balls.filter((b) => b.global_ball_id).map((b) => b.global_ball_id));
354
- // Second pass: create balls with mapped links
355
- for (const gid of selectedGlobalIds) {
356
- const gb = globalBallMap.get(gid);
357
- if (!gb)
358
- continue;
359
- // Skip if this was previously imported
360
- if (previouslyImported.has(gid))
361
- continue;
362
- const localId = globalToLocal.get(gid);
363
- if (!localId)
364
- continue;
365
- // B0 normalization
366
- const normalizedB0 = Math.max(defaultB0[gb.type] ?? 4, Math.min(gb.buoyancy, lowestActiveB * 1.5));
367
- // Map links: only keep links to simultaneously imported balls
368
- const mappedLinks = (gb.links || [])
369
- .map((linkGid) => globalToLocal.get(linkGid))
370
- .filter((id) => id !== undefined);
371
- const newBall = {
372
- id: localId,
373
- type: gb.type,
374
- summary: gb.summary,
375
- B0: Math.round(normalizedB0 * 100) / 100,
376
- H: 0,
377
- t_last: projectPool.t,
378
- hardness: gb.hardness,
379
- permanent: gb.permanent,
380
- links: mappedLinks,
381
- created_at: new Date().toISOString(),
382
- global_ball_id: gid,
383
- };
384
- // Copy ball content
385
- const content = (0, pool_manager_1.readBallContent)(GLOBAL_POOL_DIR, gid);
386
- if (content !== null) {
387
- (0, pool_manager_1.writeBallContent)(projectPoolDir, localId, content);
388
- }
389
- projectPool.balls.push(newBall);
390
- imported.push({ local_id: localId, global_id: gid, summary: gb.summary });
391
- }
392
- // Write project pool
393
- (0, pool_manager_1.writePool)(projectPoolDir, projectPool);
394
- return { imported: imported.length, balls: imported };
395
- }
396
290
  //# sourceMappingURL=global-pool-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-pool-manager.js","sourceRoot":"","sources":["../../src/memory-pool/global-pool-manager.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBjD,4CAEC;AAQD,kCAQC;AAED,oCAEC;AAID,0DAEC;AAED,4CAmBC;AAED,wCAEC;AAID,wCAIC;AAID,0CAsBC;AAED,oCAOC;AAID,oCAyJC;AAID,4CA4BC;AAID,4CAsGC;AArZD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,sCAA4C;AAE5C,iDAAiH;AACjH,yCAA6C;AAE7C,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AACzE,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,oBAAoB;AACpB,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B,SAAgB,gBAAgB;IAC9B,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,2BAA2B;AAE3B,SAAS,WAAW;IAClB,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AAG,GAAG,CAAC,GAAG,GAAG,CAAC;oBAC5C,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,CAAC;qBAAM,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;oBAChD,8CAA8C;oBAC9C,IAAI,EAAE,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;wBACnC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC;wBACzB,OAAO,EAAE,CAAC,aAAa,CAAC;oBAC1B,CAAC;oBACD,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACtB,CAAC;YACH,CAAC;YAED,sCAAsC;YACtC,IAAA,wBAAS,EAAC,eAAe,EAAE,UAAU,CAAC,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC,CAAC;YAEtB,oCAAoC;YACpC,IAAA,2BAAY,EAAC,eAAe,CAAC,CAAC;YAE9B,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,cAAc,GAAG,KAAK,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function withPoolLock<T>(poolDir: string, fn: () => T): Promise<T>;
2
+ //# sourceMappingURL=pool-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool-lock.d.ts","sourceRoot":"","sources":["../../src/memory-pool/pool-lock.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA4BxE"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // backend/src/memory-pool/pool-lock.ts
3
+ // Per-project Promise-chain mutex for serializing pool.json writes.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.withPoolLock = withPoolLock;
6
+ const locks = new Map();
7
+ function withPoolLock(poolDir, fn) {
8
+ const prev = locks.get(poolDir) ?? Promise.resolve();
9
+ let resolve;
10
+ let reject;
11
+ const resultPromise = new Promise((res, rej) => { resolve = res; reject = rej; });
12
+ const next = prev.then(() => {
13
+ try {
14
+ const result = fn();
15
+ if (result instanceof Promise) {
16
+ return result.then((v) => resolve(v), (e) => reject(e));
17
+ }
18
+ resolve(result);
19
+ }
20
+ catch (e) {
21
+ reject(e);
22
+ }
23
+ });
24
+ // Keep chain alive (swallow rejections so next caller can proceed)
25
+ const chain = next.catch(() => { });
26
+ locks.set(poolDir, chain);
27
+ chain.then(() => { if (locks.get(poolDir) === chain)
28
+ locks.delete(poolDir); });
29
+ return resultPromise;
30
+ }
31
+ //# sourceMappingURL=pool-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool-lock.js","sourceRoot":"","sources":["../../src/memory-pool/pool-lock.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,oEAAoE;;AAIpE,oCA4BC;AA9BD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;AAE/C,SAAgB,YAAY,CAAI,OAAe,EAAE,EAAW;IAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAErD,IAAI,OAAwB,CAAC;IAC7B,IAAI,MAA6B,CAAC;IAClC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAErF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,EAAE,EAAE,CAAC;YACpB,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;gBAC9B,OAAQ,MAA2B,CAAC,IAAI,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAM,CAAC,EACtB,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CACjB,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,mEAAmE;IACnE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACnC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK;QAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/E,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -5,6 +5,40 @@ export declare function readBallContent(poolDir: string, ballId: string): string
5
5
  export declare function writeBallContent(poolDir: string, ballId: string, content: string): void;
6
6
  export declare function enrichBallsWithBuoyancy(pool: PoolJson): PoolBallWithBuoyancy[];
7
7
  export declare function generateSnapshot(pool: PoolJson): string;
8
+ /**
9
+ * Estimate token count from text content (rough: ~4 chars per token for mixed CJK/EN).
10
+ */
11
+ export declare function estimateTokens(text: string): number;
12
+ export interface SurfaceBall {
13
+ id: string;
14
+ type: string;
15
+ summary: string;
16
+ buoyancy: number;
17
+ diameter: number;
18
+ links: string[];
19
+ }
20
+ /**
21
+ * Build surface.md — the set of top-buoyancy balls whose total token diameter
22
+ * fits within the wedge top width (surface_width). Writes surface.md to poolDir.
23
+ * MUST be called within withPoolLock when pool.json may be concurrently modified.
24
+ */
25
+ export declare function buildSurface(poolDir: string): {
26
+ surfaceBalls: SurfaceBall[];
27
+ totalTokens: number;
28
+ };
29
+ /**
30
+ * Compute and cache the diameter (token estimate) for a ball.
31
+ */
32
+ export declare function computeDiameter(poolDir: string, ballId: string): number;
33
+ /**
34
+ * Tick the pool: increment t with session-based dedup.
35
+ * Returns { t, deduplicated } or null if pool not found.
36
+ * MUST be called within withPoolLock to prevent concurrent read-modify-write races.
37
+ */
38
+ export declare function tickPool(poolDir: string, session?: string): {
39
+ t: number;
40
+ deduplicated: boolean;
41
+ } | null;
8
42
  /**
9
43
  * Migrate from v1 (state.json + index.json + frontmatter balls) to v2 (pool.json + pure content balls).
10
44
  * Idempotent: if pool.json already exists with version >= 2, returns empty changes.
@@ -1 +1 @@
1
- {"version":3,"file":"pool-manager.d.ts","sourceRoot":"","sources":["../../src/memory-pool/pool-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAgB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAOvE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAQzD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAE/D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ9E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIvF;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,GAAG,oBAAoB,EAAE,CAQ9E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAkBvD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAqGpE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAA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