@tom2012/cc-web 1.5.91 → 1.5.93
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/backend/dist/memory-pool/buoyancy.d.ts +2 -0
- package/backend/dist/memory-pool/buoyancy.d.ts.map +1 -0
- package/backend/dist/memory-pool/buoyancy.js +12 -0
- package/backend/dist/memory-pool/buoyancy.js.map +1 -0
- package/backend/dist/memory-pool/global-pool-manager.d.ts +21 -0
- package/backend/dist/memory-pool/global-pool-manager.d.ts.map +1 -0
- package/backend/dist/memory-pool/global-pool-manager.js +396 -0
- package/backend/dist/memory-pool/global-pool-manager.js.map +1 -0
- package/backend/dist/memory-pool/pool-manager.d.ts +23 -0
- package/backend/dist/memory-pool/pool-manager.d.ts.map +1 -0
- package/backend/dist/memory-pool/pool-manager.js +230 -0
- package/backend/dist/memory-pool/pool-manager.js.map +1 -0
- package/backend/dist/memory-pool/templates.d.ts.map +1 -1
- package/backend/dist/memory-pool/templates.js +98 -133
- package/backend/dist/memory-pool/templates.js.map +1 -1
- package/backend/dist/memory-pool/types.d.ts +65 -0
- package/backend/dist/memory-pool/types.d.ts.map +1 -0
- package/backend/dist/memory-pool/types.js +4 -0
- package/backend/dist/memory-pool/types.js.map +1 -0
- package/backend/dist/routes/memory-pool.d.ts.map +1 -1
- package/backend/dist/routes/memory-pool.js +273 -15
- package/backend/dist/routes/memory-pool.js.map +1 -1
- package/frontend/dist/assets/{GraphPreview-5Ad7E5P5.js → GraphPreview-CSZTNhQX.js} +1 -1
- package/frontend/dist/assets/{OfficePreview-BtdfzoUf.js → OfficePreview-DZmKFnER.js} +2 -2
- package/frontend/dist/assets/{PlanPanel-BzxuZna7.js → PlanPanel-DuAa0AZZ.js} +1 -1
- package/frontend/dist/assets/{ProjectPage-DJSpIIb2.js → ProjectPage-BxuE0x69.js} +5 -5
- package/frontend/dist/assets/{SettingsPage-CufDI4cE.js → SettingsPage-DSnQze4Z.js} +2 -2
- package/frontend/dist/assets/{ShareViewPage-CLuAfYtv.js → ShareViewPage-Dmur70tT.js} +1 -1
- package/frontend/dist/assets/{SkillHubPage-DOXGJ-X_.js → SkillHubPage-DnGb0OHx.js} +2 -2
- package/frontend/dist/assets/{bot-CMOVWzMR.js → bot-DKy4a5yK.js} +1 -1
- package/frontend/dist/assets/{chevron-down-pBWSO11H.js → chevron-down-B-GU2wv8.js} +1 -1
- package/frontend/dist/assets/{download-A2dvNFij.js → download-CsOUNuPy.js} +1 -1
- package/frontend/dist/assets/index-BiVVvGoh.css +1 -0
- package/frontend/dist/assets/{index-DduZUNeK.js → index-C202jcvT.js} +9 -9
- package/frontend/dist/assets/{index-DLG7lJu-.js → index-I4_xf4g_.js} +1 -1
- package/frontend/dist/assets/{jszip.min-DAk2qj6r.js → jszip.min-Dc0FmeMP.js} +1 -1
- package/frontend/dist/assets/{matter-Egqv9e3Y.js → matter-Da3rDMpe.js} +1 -1
- package/frontend/dist/assets/{maximize-2-Dw4chVid.js → maximize-2-BEyzEiyH.js} +1 -1
- package/frontend/dist/assets/{save-Dbdk54Dm.js → save-BYSx9fYK.js} +1 -1
- package/frontend/dist/assets/{user-CT9EiLL3.js → user-D3KuBJwv.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/index-DCC68aQn.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buoyancy.d.ts","sourceRoot":"","sources":["../../src/memory-pool/buoyancy.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,OAAO,GACjB,MAAM,CAKR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// backend/src/memory-pool/buoyancy.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.computeBuoyancy = computeBuoyancy;
|
|
5
|
+
function computeBuoyancy(B0, H, alpha, lambda, t, t_last, permanent) {
|
|
6
|
+
const base = B0 + alpha * H;
|
|
7
|
+
if (permanent)
|
|
8
|
+
return Math.round(base * 100) / 100;
|
|
9
|
+
const decay = Math.pow(lambda, Math.max(0, t - t_last));
|
|
10
|
+
return Math.round(base * decay * 100) / 100;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=buoyancy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buoyancy.js","sourceRoot":"","sources":["../../src/memory-pool/buoyancy.ts"],"names":[],"mappings":";AAAA,sCAAsC;;AAEtC,0CAaC;AAbD,SAAgB,eAAe,CAC7B,EAAU,EACV,CAAS,EACT,KAAa,EACb,MAAc,EACd,CAAS,EACT,MAAc,EACd,SAAkB;IAElB,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;IAC5B,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PoolJson, SourcesJson, SyncResult, ImportPreviewBall } from './types';
|
|
2
|
+
export declare function getGlobalPoolDir(): string;
|
|
3
|
+
export declare function readSources(): SourcesJson;
|
|
4
|
+
export declare function writeSources(data: SourcesJson): void;
|
|
5
|
+
export declare function isGlobalPoolInitialized(): boolean;
|
|
6
|
+
export declare function ensureGlobalPool(): void;
|
|
7
|
+
export declare function readGlobalPool(): PoolJson | null;
|
|
8
|
+
export declare function computeGlobalT(initializedAt: string): number;
|
|
9
|
+
export declare function registerProject(projectId: string, projectName: string, poolPath: string): void;
|
|
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
|
+
};
|
|
21
|
+
//# sourceMappingURL=global-pool-manager.d.ts.map
|
|
@@ -0,0 +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,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAsB9F;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAOvD;AAID,wBAAgB,YAAY,IAAI,UAAU,CAyJzC;AAID,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA4B5E;AAID,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,EAAE,GAC1B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAmG9F"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// backend/src/memory-pool/global-pool-manager.ts
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.getGlobalPoolDir = getGlobalPoolDir;
|
|
38
|
+
exports.readSources = readSources;
|
|
39
|
+
exports.writeSources = writeSources;
|
|
40
|
+
exports.isGlobalPoolInitialized = isGlobalPoolInitialized;
|
|
41
|
+
exports.ensureGlobalPool = ensureGlobalPool;
|
|
42
|
+
exports.readGlobalPool = readGlobalPool;
|
|
43
|
+
exports.computeGlobalT = computeGlobalT;
|
|
44
|
+
exports.registerProject = registerProject;
|
|
45
|
+
exports.removeSource = removeSource;
|
|
46
|
+
exports.syncToGlobal = syncToGlobal;
|
|
47
|
+
exports.getImportPreview = getImportPreview;
|
|
48
|
+
exports.importFromGlobal = importFromGlobal;
|
|
49
|
+
const fs = __importStar(require("fs"));
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const os = __importStar(require("os"));
|
|
52
|
+
const config_1 = require("../config");
|
|
53
|
+
const pool_manager_1 = require("./pool-manager");
|
|
54
|
+
const buoyancy_1 = require("./buoyancy");
|
|
55
|
+
const GLOBAL_POOL_DIR = path.join(os.homedir(), '.ccweb', 'memory-pool');
|
|
56
|
+
const SOURCES_FILE = 'sources.json';
|
|
57
|
+
// Concurrency guard
|
|
58
|
+
let syncInProgress = false;
|
|
59
|
+
function getGlobalPoolDir() {
|
|
60
|
+
return GLOBAL_POOL_DIR;
|
|
61
|
+
}
|
|
62
|
+
// ── Sources management ──
|
|
63
|
+
function sourcesPath() {
|
|
64
|
+
return path.join(GLOBAL_POOL_DIR, SOURCES_FILE);
|
|
65
|
+
}
|
|
66
|
+
function readSources() {
|
|
67
|
+
const file = sourcesPath();
|
|
68
|
+
if (!fs.existsSync(file))
|
|
69
|
+
return { version: 1, sources: [] };
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return { version: 1, sources: [] };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function writeSources(data) {
|
|
78
|
+
(0, config_1.atomicWriteSync)(sourcesPath(), JSON.stringify(data, null, 2));
|
|
79
|
+
}
|
|
80
|
+
// ── Global pool init ──
|
|
81
|
+
function isGlobalPoolInitialized() {
|
|
82
|
+
return fs.existsSync(path.join(GLOBAL_POOL_DIR, 'pool.json'));
|
|
83
|
+
}
|
|
84
|
+
function ensureGlobalPool() {
|
|
85
|
+
if (isGlobalPoolInitialized())
|
|
86
|
+
return;
|
|
87
|
+
fs.mkdirSync(path.join(GLOBAL_POOL_DIR, 'balls'), { recursive: true });
|
|
88
|
+
const now = new Date().toISOString();
|
|
89
|
+
const pool = {
|
|
90
|
+
version: 2,
|
|
91
|
+
t: 0,
|
|
92
|
+
lambda: 0.99,
|
|
93
|
+
alpha: 1.0,
|
|
94
|
+
active_capacity: 40,
|
|
95
|
+
next_id: 1,
|
|
96
|
+
pool: 'global',
|
|
97
|
+
initialized_at: now,
|
|
98
|
+
balls: [],
|
|
99
|
+
};
|
|
100
|
+
(0, pool_manager_1.writePool)(GLOBAL_POOL_DIR, pool);
|
|
101
|
+
writeSources({ version: 1, sources: [] });
|
|
102
|
+
}
|
|
103
|
+
function readGlobalPool() {
|
|
104
|
+
return (0, pool_manager_1.readPool)(GLOBAL_POOL_DIR);
|
|
105
|
+
}
|
|
106
|
+
// ── Calendar-based t ──
|
|
107
|
+
function computeGlobalT(initializedAt) {
|
|
108
|
+
const epochDay = Math.floor(new Date(initializedAt).getTime() / 86400000);
|
|
109
|
+
const nowDay = Math.floor(Date.now() / 86400000);
|
|
110
|
+
return Math.max(0, nowDay - epochDay);
|
|
111
|
+
}
|
|
112
|
+
// ── Register project ──
|
|
113
|
+
function registerProject(projectId, projectName, poolPath) {
|
|
114
|
+
ensureGlobalPool();
|
|
115
|
+
const sources = readSources();
|
|
116
|
+
const existing = sources.sources.find((s) => s.pool_path === poolPath);
|
|
117
|
+
if (existing) {
|
|
118
|
+
// Refresh metadata
|
|
119
|
+
existing.project_id = projectId;
|
|
120
|
+
existing.project_name = projectName;
|
|
121
|
+
existing.status = 'active';
|
|
122
|
+
existing.unreachable_count = 0;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
sources.sources.push({
|
|
126
|
+
project_id: projectId,
|
|
127
|
+
project_name: projectName,
|
|
128
|
+
pool_path: poolPath,
|
|
129
|
+
registered_at: new Date().toISOString(),
|
|
130
|
+
last_synced_at: null,
|
|
131
|
+
status: 'active',
|
|
132
|
+
unreachable_count: 0,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
writeSources(sources);
|
|
136
|
+
}
|
|
137
|
+
function removeSource(projectId) {
|
|
138
|
+
const sources = readSources();
|
|
139
|
+
const idx = sources.sources.findIndex((s) => s.project_id === projectId);
|
|
140
|
+
if (idx === -1)
|
|
141
|
+
return false;
|
|
142
|
+
sources.sources.splice(idx, 1);
|
|
143
|
+
writeSources(sources);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
// ── Sync (global operation) ──
|
|
147
|
+
function syncToGlobal() {
|
|
148
|
+
if (syncInProgress) {
|
|
149
|
+
throw new Error('SYNC_IN_PROGRESS');
|
|
150
|
+
}
|
|
151
|
+
syncInProgress = true;
|
|
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);
|
|
172
|
+
}
|
|
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';
|
|
188
|
+
}
|
|
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++;
|
|
212
|
+
}
|
|
213
|
+
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);
|
|
245
|
+
}
|
|
246
|
+
globalPool.balls.push(newBall);
|
|
247
|
+
originMap.set(originKey, globalPool.balls.length - 1);
|
|
248
|
+
result.added++;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
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;
|
|
273
|
+
}
|
|
274
|
+
gb.orphaned = false;
|
|
275
|
+
}
|
|
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;
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
syncInProgress = false;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
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
|
+
//# sourceMappingURL=global-pool-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-pool-manager.js","sourceRoot":"","sources":["../../src/memory-pool/global-pool-manager.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;;;;;;;;;;;;;;;;;;;;;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}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PoolJson, PoolBallWithBuoyancy } from './types';
|
|
2
|
+
export declare function readPool(poolDir: string): PoolJson | null;
|
|
3
|
+
export declare function writePool(poolDir: string, pool: PoolJson): void;
|
|
4
|
+
export declare function readBallContent(poolDir: string, ballId: string): string | null;
|
|
5
|
+
export declare function writeBallContent(poolDir: string, ballId: string, content: string): void;
|
|
6
|
+
export declare function enrichBallsWithBuoyancy(pool: PoolJson): PoolBallWithBuoyancy[];
|
|
7
|
+
export declare function generateSnapshot(pool: PoolJson): string;
|
|
8
|
+
/**
|
|
9
|
+
* Migrate from v1 (state.json + index.json + frontmatter balls) to v2 (pool.json + pure content balls).
|
|
10
|
+
* Idempotent: if pool.json already exists with version >= 2, returns empty changes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function migrateV1toV2(poolDir: string): {
|
|
13
|
+
changes: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Check if pool directory uses v1 format (has state.json but no pool.json).
|
|
17
|
+
*/
|
|
18
|
+
export declare function needsUpgrade(poolDir: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if pool is initialized (either v1 or v2 format).
|
|
21
|
+
*/
|
|
22
|
+
export declare function isInitialized(poolDir: string): boolean;
|
|
23
|
+
//# sourceMappingURL=pool-manager.d.ts.map
|
|
@@ -0,0 +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,MAAM,GAAG,OAAO,CAIrD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKtD"}
|