codexmate 0.1.39 → 0.1.40
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/cli/doctor-core.js +1 -1
- package/cli.js +89 -78
- package/lib/shared-knowledge.js +86 -0
- package/package.json +3 -1
- package/web-ui/app.js +3 -2
- package/web-ui/index.html +2 -0
- package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
- package/web-ui/modules/app.methods.navigation.mjs +2 -1
- package/web-ui/modules/i18n/locales/en.mjs +25 -1
- package/web-ui/modules/i18n/locales/ja.mjs +25 -1
- package/web-ui/modules/i18n/locales/keys.mjs +24 -0
- package/web-ui/modules/i18n/locales/vi.mjs +25 -1
- package/web-ui/modules/i18n/locales/zh-tw.mjs +25 -1
- package/web-ui/modules/i18n/locales/zh.mjs +25 -1
- package/web-ui/modules/shared-knowledge.mjs +139 -0
- package/web-ui/partials/index/layout-header.html +21 -4
- package/web-ui/partials/index/panel-knowledge.html +68 -0
- package/web-ui/res/reicon-knowledge.LICENSE.txt +20 -0
- package/web-ui/res/reicon-knowledge.svg +18 -0
- package/web-ui/res/web-ui-render.precompiled.js +1 -1
- package/web-ui/styles/base-theme.css +2 -2
- package/web-ui/styles/navigation-panels.css +5 -11
- package/web-ui/styles/responsive.css +1 -9
- package/web-ui/styles/shared-knowledge.css +227 -0
- package/web-ui/styles/theme-violet.css +0 -21
- package/web-ui/styles/titles-cards.css +0 -23
- package/web-ui/styles.css +1 -0
package/cli/doctor-core.js
CHANGED
|
@@ -536,7 +536,7 @@ async function buildDoctorReport(params = {}, deps = {}) {
|
|
|
536
536
|
|
|
537
537
|
sources.status = getStatusPayload();
|
|
538
538
|
if (options.includeInstall !== false) {
|
|
539
|
-
sources.install = buildInstallStatusReport();
|
|
539
|
+
sources.install = await buildInstallStatusReport();
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
if (buildConfigHealthReport) {
|
package/cli.js
CHANGED
|
@@ -12,7 +12,10 @@ const JSON5 = require('json5');
|
|
|
12
12
|
const zipLib = require('zip-lib');
|
|
13
13
|
const yauzl = require('yauzl');
|
|
14
14
|
const zlib = require('node:zlib');
|
|
15
|
-
const { exec, execSync, execFileSync, spawn, spawnSync } = require('child_process');
|
|
15
|
+
const { exec, execFile, execSync, execFileSync, spawn, spawnSync } = require('child_process');
|
|
16
|
+
const { promisify } = require('util');
|
|
17
|
+
const execAsync = promisify(exec);
|
|
18
|
+
const execFileAsync = promisify(execFile);
|
|
16
19
|
const http = require('http');
|
|
17
20
|
const https = require('https');
|
|
18
21
|
const net = require('net');
|
|
@@ -149,6 +152,7 @@ const { createPluginConfigController } = require('./cli/plugin-config');
|
|
|
149
152
|
const { createSessionContextHealthController } = require('./lib/session-context-health');
|
|
150
153
|
const { createSessionUsageReportController, exportSessionUsageReport } = require('./lib/session-usage-report');
|
|
151
154
|
const { createSessionFeatures } = require('./lib/session-features');
|
|
155
|
+
const { createSharedKnowledge } = require('./lib/shared-knowledge');
|
|
152
156
|
const { listHandoffs } = require('./lib/thread-handoff');
|
|
153
157
|
const { discoverServers, probeServer } = require('./lib/handoff-mcp');
|
|
154
158
|
const {
|
|
@@ -1172,7 +1176,7 @@ function normalizeSettingsTabPreference(value) {
|
|
|
1172
1176
|
|
|
1173
1177
|
function normalizeMainTabPreference(value) {
|
|
1174
1178
|
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
1175
|
-
const allowed = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
|
|
1179
|
+
const allowed = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts', 'knowledge']);
|
|
1176
1180
|
return allowed.has(normalized) ? normalized : 'dashboard';
|
|
1177
1181
|
}
|
|
1178
1182
|
|
|
@@ -10037,6 +10041,7 @@ const { readSessionContextHealth, readSessionContextNode, iterateSessionContextN
|
|
|
10037
10041
|
|
|
10038
10042
|
const sessionUsageReport = createSessionUsageReportController({ fs, listSessionUsage, iterateSessionUsageRecords });
|
|
10039
10043
|
|
|
10044
|
+
const sharedKnowledge = createSharedKnowledge(path.join(CODEXMATE_DIR, 'shared-knowledge.json'));
|
|
10040
10045
|
const sessionFeatures = createSessionFeatures({ root: path.join(CODEXMATE_DIR, 'session-features'),
|
|
10041
10046
|
usageReport: sessionUsageReport,
|
|
10042
10047
|
readNode: readSessionContextNode, nodes: iterateSessionContextNodes,
|
|
@@ -13415,7 +13420,7 @@ function isPrivateNetworkHost(hostname) {
|
|
|
13415
13420
|
return false;
|
|
13416
13421
|
}
|
|
13417
13422
|
|
|
13418
|
-
function detectPreferredPackageManager() {
|
|
13423
|
+
async function detectPreferredPackageManager() {
|
|
13419
13424
|
const userAgent = typeof process.env.npm_config_user_agent === 'string'
|
|
13420
13425
|
? process.env.npm_config_user_agent.trim().toLowerCase()
|
|
13421
13426
|
: '';
|
|
@@ -13423,8 +13428,14 @@ function detectPreferredPackageManager() {
|
|
|
13423
13428
|
if (userAgent.startsWith('bun/')) return 'bun';
|
|
13424
13429
|
if (userAgent.startsWith('npm/')) return 'npm';
|
|
13425
13430
|
|
|
13426
|
-
|
|
13427
|
-
|
|
13431
|
+
for (const manager of ['pnpm', 'bun']) {
|
|
13432
|
+
const options = { windowsHide: true, timeout: 5000 };
|
|
13433
|
+
try {
|
|
13434
|
+
if (process.platform === 'win32') await execAsync(`${manager} --version`, options);
|
|
13435
|
+
else await execFileAsync(manager, ['--version'], options);
|
|
13436
|
+
return manager;
|
|
13437
|
+
} catch (_) { /* Try the next available package manager. */ }
|
|
13438
|
+
}
|
|
13428
13439
|
return 'npm';
|
|
13429
13440
|
}
|
|
13430
13441
|
|
|
@@ -13450,12 +13461,14 @@ function resolveCommandPath(command) {
|
|
|
13450
13461
|
}
|
|
13451
13462
|
}
|
|
13452
13463
|
|
|
13453
|
-
function
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13464
|
+
async function locateInstallBinary(command) {
|
|
13465
|
+
const locator = process.platform === 'win32' ? 'where' : 'which';
|
|
13466
|
+
try {
|
|
13467
|
+
const { stdout } = await execFileAsync(locator, [command], { windowsHide: true, timeout: 2500 });
|
|
13468
|
+
return stdout.split(/\r?\n/).map(line => line.trim()).find(Boolean) || '';
|
|
13469
|
+
} catch (_) {
|
|
13470
|
+
return '';
|
|
13457
13471
|
}
|
|
13458
|
-
return resolveCommandPath(command) || command;
|
|
13459
13472
|
}
|
|
13460
13473
|
|
|
13461
13474
|
function parseBinaryVersionOutput(text) {
|
|
@@ -13468,71 +13481,45 @@ function parseBinaryVersionOutput(text) {
|
|
|
13468
13481
|
return line.length > 120 ? `${line.slice(0, 117)}...` : line;
|
|
13469
13482
|
}
|
|
13470
13483
|
|
|
13471
|
-
function probeCliBinary(binName) {
|
|
13472
|
-
const
|
|
13484
|
+
async function probeCliBinary(binName) {
|
|
13485
|
+
const isWindows = process.platform === 'win32';
|
|
13486
|
+
const executable = isWindows ? binName : (await locateInstallBinary(binName) || binName);
|
|
13487
|
+
const options = { windowsHide: true, timeout: 5000 };
|
|
13473
13488
|
let lastError = '';
|
|
13474
13489
|
|
|
13475
|
-
for (const
|
|
13490
|
+
for (const flag of ['--version', '-v', 'version']) {
|
|
13491
|
+
let output;
|
|
13476
13492
|
try {
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
const argString = args.join(' ').trim();
|
|
13481
|
-
const commandLine = argString ? `${binName} ${argString}` : binName;
|
|
13482
|
-
const stdout = execSync(commandLine, {
|
|
13483
|
-
encoding: 'utf8',
|
|
13484
|
-
windowsHide: true,
|
|
13485
|
-
timeout: 5000,
|
|
13486
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
13487
|
-
shell: true
|
|
13488
|
-
});
|
|
13489
|
-
output = String(stdout || '');
|
|
13493
|
+
if (isWindows) {
|
|
13494
|
+
const { stdout } = await execAsync(`${executable} ${flag}`, options);
|
|
13495
|
+
output = stdout;
|
|
13490
13496
|
} else {
|
|
13491
|
-
const
|
|
13492
|
-
|
|
13493
|
-
encoding: 'utf8',
|
|
13494
|
-
windowsHide: true,
|
|
13495
|
-
timeout: 5000,
|
|
13496
|
-
stdio: ['ignore', 'pipe', 'pipe']
|
|
13497
|
-
});
|
|
13498
|
-
status = Number.isFinite(probe.status) ? probe.status : (probe.error ? 1 : 0);
|
|
13499
|
-
output = `${probe.stdout || ''}\n${probe.stderr || ''}`.trim();
|
|
13497
|
+
const { stdout, stderr } = await execFileAsync(executable, [flag], options);
|
|
13498
|
+
output = `${stdout}\n${stderr}`;
|
|
13500
13499
|
}
|
|
13501
|
-
const version = parseBinaryVersionOutput(output);
|
|
13502
|
-
return {
|
|
13503
|
-
installed: true,
|
|
13504
|
-
bin: binName,
|
|
13505
|
-
version: version || 'unknown',
|
|
13506
|
-
path: resolveCommandPath(binName),
|
|
13507
|
-
error: ''
|
|
13508
|
-
};
|
|
13509
13500
|
} catch (error) {
|
|
13510
|
-
const
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
error: ''
|
|
13523
|
-
};
|
|
13524
|
-
}
|
|
13525
|
-
if (version) {
|
|
13526
|
-
lastError = status !== null
|
|
13527
|
-
? `${binName} exited with ${status}: ${version}`
|
|
13528
|
-
: `${binName} failed: ${version}`;
|
|
13501
|
+
const version = parseBinaryVersionOutput(`${error.stdout || ''}\n${error.stderr || ''}`);
|
|
13502
|
+
if (!isWindows && Number.isInteger(error.code)) {
|
|
13503
|
+
// The executable exists even if its version flag exits nonzero.
|
|
13504
|
+
output = version;
|
|
13505
|
+
} else {
|
|
13506
|
+
if (version) {
|
|
13507
|
+
lastError = Number.isInteger(error.code)
|
|
13508
|
+
? `${binName} exited with ${error.code}: ${version}`
|
|
13509
|
+
: `${binName} failed: ${version}`;
|
|
13510
|
+
} else if (error.message && !/ENOENT/i.test(error.message)) {
|
|
13511
|
+
lastError = error.message;
|
|
13512
|
+
}
|
|
13529
13513
|
continue;
|
|
13530
13514
|
}
|
|
13531
|
-
const message = err && err.message ? String(err.message) : '';
|
|
13532
|
-
if (message && !/ENOENT/i.test(message)) {
|
|
13533
|
-
lastError = message;
|
|
13534
|
-
}
|
|
13535
13515
|
}
|
|
13516
|
+
return {
|
|
13517
|
+
installed: true,
|
|
13518
|
+
bin: binName,
|
|
13519
|
+
version: parseBinaryVersionOutput(output) || 'unknown',
|
|
13520
|
+
path: await locateInstallBinary(binName),
|
|
13521
|
+
error: ''
|
|
13522
|
+
};
|
|
13536
13523
|
}
|
|
13537
13524
|
|
|
13538
13525
|
return {
|
|
@@ -13582,13 +13569,15 @@ function resolveInstallCommandsByPackageManager(packageManager) {
|
|
|
13582
13569
|
};
|
|
13583
13570
|
}
|
|
13584
13571
|
|
|
13585
|
-
function buildInstallStatusReport() {
|
|
13586
|
-
|
|
13587
|
-
const
|
|
13572
|
+
async function buildInstallStatusReport() {
|
|
13573
|
+
// Version probes must not block the server while startup reads its configuration.
|
|
13574
|
+
const packageManager = await detectPreferredPackageManager();
|
|
13575
|
+
const targetReports = [];
|
|
13576
|
+
for (const target of CLI_INSTALL_TARGETS) {
|
|
13588
13577
|
let hit = null;
|
|
13589
13578
|
let lastError = '';
|
|
13590
13579
|
for (const binName of target.bins) {
|
|
13591
|
-
const probe = probeCliBinary(binName);
|
|
13580
|
+
const probe = await probeCliBinary(binName);
|
|
13592
13581
|
if (probe.installed) {
|
|
13593
13582
|
hit = probe;
|
|
13594
13583
|
break;
|
|
@@ -13597,7 +13586,7 @@ function buildInstallStatusReport() {
|
|
|
13597
13586
|
lastError = probe.error;
|
|
13598
13587
|
}
|
|
13599
13588
|
}
|
|
13600
|
-
|
|
13589
|
+
targetReports.push({
|
|
13601
13590
|
id: target.id,
|
|
13602
13591
|
name: target.name,
|
|
13603
13592
|
packageName: target.packageName,
|
|
@@ -13606,8 +13595,8 @@ function buildInstallStatusReport() {
|
|
|
13606
13595
|
version: hit ? hit.version : '',
|
|
13607
13596
|
commandPath: hit ? hit.path : '',
|
|
13608
13597
|
error: hit ? '' : lastError
|
|
13609
|
-
};
|
|
13610
|
-
}
|
|
13598
|
+
});
|
|
13599
|
+
}
|
|
13611
13600
|
|
|
13612
13601
|
const commandSpec = resolveInstallCommandsByPackageManager(packageManager);
|
|
13613
13602
|
return {
|
|
@@ -14558,7 +14547,7 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14558
14547
|
sendJson(405, { error: 'Method Not Allowed' });
|
|
14559
14548
|
return;
|
|
14560
14549
|
}
|
|
14561
|
-
|
|
14550
|
+
const bodyChunks = [];
|
|
14562
14551
|
let bodySize = 0;
|
|
14563
14552
|
let bodyTooLarge = false;
|
|
14564
14553
|
req.on('data', chunk => {
|
|
@@ -14572,13 +14561,13 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14572
14561
|
req.destroy();
|
|
14573
14562
|
return;
|
|
14574
14563
|
}
|
|
14575
|
-
|
|
14564
|
+
bodyChunks.push(chunk);
|
|
14576
14565
|
});
|
|
14577
14566
|
req.on('end', async () => {
|
|
14578
14567
|
if (bodyTooLarge) return;
|
|
14579
14568
|
let leaveToolConfigWriteGuard = null;
|
|
14580
14569
|
try {
|
|
14581
|
-
const { action, params } = JSON.parse(
|
|
14570
|
+
const { action, params } = JSON.parse(Buffer.concat(bodyChunks, bodySize).toString('utf8') || '{}');
|
|
14582
14571
|
leaveToolConfigWriteGuard = typeof enterToolConfigWriteGuard === 'function'
|
|
14583
14572
|
? enterToolConfigWriteGuard()
|
|
14584
14573
|
: () => {};
|
|
@@ -14616,6 +14605,14 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14616
14605
|
case 'get-tool-config-permissions':
|
|
14617
14606
|
result = { permissions: readToolConfigPermissions() };
|
|
14618
14607
|
break;
|
|
14608
|
+
case 'knowledge-list':
|
|
14609
|
+
case 'knowledge-get':
|
|
14610
|
+
case 'knowledge-create':
|
|
14611
|
+
case 'knowledge-update': {
|
|
14612
|
+
const { status, payload } = sharedKnowledge(action, params);
|
|
14613
|
+
sendJson(status, payload);
|
|
14614
|
+
return;
|
|
14615
|
+
}
|
|
14619
14616
|
case 'get-web-ui-preferences':
|
|
14620
14617
|
result = { preferences: readWebUiPreferences() };
|
|
14621
14618
|
break;
|
|
@@ -14708,7 +14705,7 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14708
14705
|
break;
|
|
14709
14706
|
}
|
|
14710
14707
|
case 'install-status':
|
|
14711
|
-
result = buildInstallStatusReport();
|
|
14708
|
+
result = await buildInstallStatusReport();
|
|
14712
14709
|
break;
|
|
14713
14710
|
case 'version-status': {
|
|
14714
14711
|
const currentVersion = (() => {
|
|
@@ -15568,6 +15565,20 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15568
15565
|
fileName: path.basename(legacyFilePath),
|
|
15569
15566
|
deleteAfterDownload: false
|
|
15570
15567
|
});
|
|
15568
|
+
} else if (requestPath === '/res/geist/index.css' || /^\/res\/geist\/files\/geist-(?:latin|latin-ext|vietnamese|cyrillic|cyrillic-ext)-wght-normal\.woff2$/.test(requestPath)) {
|
|
15569
|
+
const asset = requestPath.slice('/res/geist/'.length);
|
|
15570
|
+
try {
|
|
15571
|
+
const fontPath = require.resolve(`@fontsource-variable/geist/${asset}`);
|
|
15572
|
+
const mime = asset === 'index.css' ? 'text/css; charset=utf-8' : 'font/woff2';
|
|
15573
|
+
const stream = fs.createReadStream(fontPath);
|
|
15574
|
+
stream.once('error', error => writeWebUiAssetError(res, requestPath, error));
|
|
15575
|
+
stream.once('open', () => {
|
|
15576
|
+
res.writeHead(200, { 'Content-Type': mime, 'Cache-Control': 'no-store, max-age=0' });
|
|
15577
|
+
stream.pipe(res);
|
|
15578
|
+
});
|
|
15579
|
+
} catch (error) {
|
|
15580
|
+
writeWebUiAssetError(res, requestPath, error);
|
|
15581
|
+
}
|
|
15571
15582
|
} else if (requestPath.startsWith('/res/')) {
|
|
15572
15583
|
const normalized = path.normalize(requestPath.slice('/res/'.length)).replace(/^([\\.\\/])+/, '');
|
|
15573
15584
|
const filePath = path.join(assetsDir, normalized);
|
|
@@ -15588,7 +15599,7 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15588
15599
|
? 'text/html; charset=utf-8'
|
|
15589
15600
|
: ext === '.json'
|
|
15590
15601
|
? 'application/json; charset=utf-8'
|
|
15591
|
-
: 'application/octet-stream';
|
|
15602
|
+
: ext === '.svg' ? 'image/svg+xml' : 'application/octet-stream';
|
|
15592
15603
|
res.writeHead(200, {
|
|
15593
15604
|
'Content-Type': mime,
|
|
15594
15605
|
'Cache-Control': 'no-store, max-age=0'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { randomBytes } = require('crypto');
|
|
4
|
+
const { createLocalFeatureStore } = require('./local-feature-store');
|
|
5
|
+
|
|
6
|
+
const MAX_CONTENT_BYTES = 256 * 1024;
|
|
7
|
+
const MAX_TITLE_LENGTH = 160;
|
|
8
|
+
const MAX_FILENAME_LENGTH = 255;
|
|
9
|
+
const ID_PATTERN = /^[a-f0-9]{32}$/;
|
|
10
|
+
const TEXT_FILENAME = /\.(md|txt)$/i;
|
|
11
|
+
const UNSAFE_FILENAME = /[\\/\x00-\x1f\x7f]/;
|
|
12
|
+
|
|
13
|
+
function knowledgeError(status, errorCode) {
|
|
14
|
+
return { status, payload: { error: errorCode, errorCode } };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function entryMetadata({ content, ...metadata }) {
|
|
18
|
+
return metadata;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function readDraft(params) {
|
|
22
|
+
const title = typeof params.title === 'string' ? params.title.trim() : '';
|
|
23
|
+
const { content } = params;
|
|
24
|
+
if (!title || title.length > MAX_TITLE_LENGTH || typeof content !== 'string') return null;
|
|
25
|
+
return { title, content };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createSharedKnowledge(filePath) {
|
|
29
|
+
const store = createLocalFeatureStore(filePath, { version: 1, entries: [] });
|
|
30
|
+
|
|
31
|
+
function dispatch(action, params) {
|
|
32
|
+
const { value, revision } = store.read();
|
|
33
|
+
if (action === 'knowledge-list') {
|
|
34
|
+
if (params.query !== undefined && (typeof params.query !== 'string' || params.query.length > MAX_FILENAME_LENGTH)) {
|
|
35
|
+
return knowledgeError(400, 'knowledge-invalid');
|
|
36
|
+
}
|
|
37
|
+
const query = (params.query || '').trim().toLowerCase();
|
|
38
|
+
const entries = value.entries.filter(entry => [entry.title, entry.filename, entry.content]
|
|
39
|
+
.some(field => field.toLowerCase().includes(query))).map(entryMetadata);
|
|
40
|
+
return { status: 200, payload: { entries } };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isNew = action === 'knowledge-create';
|
|
44
|
+
const index = isNew ? -1 : value.entries.findIndex(entry => entry.id === params.id);
|
|
45
|
+
const existing = value.entries[index];
|
|
46
|
+
if (!isNew && (typeof params.id !== 'string' || !ID_PATTERN.test(params.id))) return knowledgeError(400, 'knowledge-invalid');
|
|
47
|
+
if (!isNew && !existing) return knowledgeError(404, 'knowledge-not-found');
|
|
48
|
+
if (action === 'knowledge-get') return { status: 200, payload: { entry: existing } };
|
|
49
|
+
|
|
50
|
+
const draft = readDraft(params);
|
|
51
|
+
if (!draft || (!isNew && (typeof params.revision !== 'string' || !ID_PATTERN.test(params.revision)))) {
|
|
52
|
+
return knowledgeError(400, 'knowledge-invalid');
|
|
53
|
+
}
|
|
54
|
+
if (!isNew && existing.revision !== params.revision) return knowledgeError(409, 'knowledge-conflict');
|
|
55
|
+
const filename = isNew ? (params.filename === undefined ? '' : params.filename) : existing.filename;
|
|
56
|
+
if (typeof filename !== 'string' || filename.length > MAX_FILENAME_LENGTH ||
|
|
57
|
+
(filename && (!TEXT_FILENAME.test(filename) || UNSAFE_FILENAME.test(filename)))) {
|
|
58
|
+
return knowledgeError(400, 'knowledge-invalid');
|
|
59
|
+
}
|
|
60
|
+
if (Buffer.byteLength(draft.content, 'utf8') > MAX_CONTENT_BYTES) return knowledgeError(413, 'knowledge-entry-too-large');
|
|
61
|
+
|
|
62
|
+
const entry = {
|
|
63
|
+
...draft, filename,
|
|
64
|
+
id: isNew ? randomBytes(16).toString('hex') : existing.id,
|
|
65
|
+
revision: randomBytes(16).toString('hex'),
|
|
66
|
+
updatedAt: new Date().toISOString()
|
|
67
|
+
};
|
|
68
|
+
if (!isNew) value.entries.splice(index, 1);
|
|
69
|
+
value.entries.unshift(entry);
|
|
70
|
+
store.write(value, revision);
|
|
71
|
+
return { status: isNew ? 201 : 200, payload: { entry } };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (action, params = {}) => {
|
|
75
|
+
if (!params || typeof params !== 'object' || Array.isArray(params)) return knowledgeError(400, 'knowledge-invalid');
|
|
76
|
+
try {
|
|
77
|
+
return dispatch(action, params);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error.message === 'feature-store-full') return knowledgeError(413, 'knowledge-store-full');
|
|
80
|
+
if (error.message === 'feature-store-conflict') return knowledgeError(409, 'knowledge-conflict');
|
|
81
|
+
return knowledgeError(500, 'knowledge-store-error');
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { createSharedKnowledge };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexmate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "Codex/Claude Code/OpenClaw 配置、会话与任务编排 CLI + Web 工具",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"pretest": "node tools/ci/ensure-test-deps.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
+
"@fontsource-variable/geist": "5.3.0",
|
|
58
59
|
"@iarna/toml": "^2.2.5",
|
|
59
60
|
"json5": "^2.2.3",
|
|
60
61
|
"yauzl": "^3.2.1",
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
"@vue/compiler-dom": "^3.5.34",
|
|
86
87
|
"e2e": "0.22.0",
|
|
87
88
|
"opencc-js": "^1.3.1",
|
|
89
|
+
"reicon": "1.2.6",
|
|
88
90
|
"vitepress": "^1.6.4"
|
|
89
91
|
}
|
|
90
92
|
}
|
package/web-ui/app.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sharedKnowledgeMixin } from './modules/shared-knowledge.mjs';
|
|
1
2
|
import { modelTestMixin } from './modules/model-test.mjs';
|
|
2
3
|
import { configChangeMixin } from './modules/app.methods.config-changes.mjs';
|
|
3
4
|
import { threadHandoffMixin } from './modules/thread-handoff.mjs';
|
|
@@ -61,7 +62,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
const appOptions = {
|
|
64
|
-
mixins: [threadHandoffMixin, configChangeMixin],
|
|
65
|
+
mixins: [threadHandoffMixin, configChangeMixin, sharedKnowledgeMixin],
|
|
65
66
|
data() {
|
|
66
67
|
return {
|
|
67
68
|
workflowDefinitions: [], workflowRuns: [], workflowId: 'diagnose-config',
|
|
@@ -707,7 +708,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
707
708
|
this.agentsModalHint = this.t('modal.agents.hint');
|
|
708
709
|
}
|
|
709
710
|
{
|
|
710
|
-
const mainTabSet = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
|
|
711
|
+
const mainTabSet = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts', 'knowledge']);
|
|
711
712
|
let urlMainTab = '';
|
|
712
713
|
try {
|
|
713
714
|
const url = new URL(window.location.href);
|
package/web-ui/index.html
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<script src="/res/json5.min.js"></script>
|
|
11
11
|
<script src="/res/marked.min.js"></script>
|
|
12
12
|
<script src="/res/purify.min.js"></script>
|
|
13
|
+
<link rel="stylesheet" href="/res/geist/index.css">
|
|
13
14
|
<link rel="stylesheet" href="/web-ui/styles.css">
|
|
14
15
|
<script>
|
|
15
16
|
// Render hint: restore the selected theme before the
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
<!-- @include ./partials/index/panel-sessions.html -->
|
|
40
41
|
<!-- @include ./partials/index/panel-usage.html -->
|
|
41
42
|
<!-- @include ./partials/index/panel-docs.html -->
|
|
43
|
+
<!-- @include ./partials/index/panel-knowledge.html -->
|
|
42
44
|
<!-- @include ./partials/index/panel-settings.html -->
|
|
43
45
|
<!-- @include ./partials/index/panel-trash.html -->
|
|
44
46
|
<!-- @include ./partials/index/panel-market.html -->
|
|
@@ -23,6 +23,7 @@ export function createMainTabsComputed() {
|
|
|
23
23
|
if (this.mainTab === 'docs') return this.t('kicker.docs');
|
|
24
24
|
if (this.mainTab === 'trash') return this.t('kicker.trash');
|
|
25
25
|
if (this.mainTab === 'prompts') return this.t('kicker.prompts');
|
|
26
|
+
if (this.mainTab === 'knowledge') return '';
|
|
26
27
|
return this.t('kicker.settings');
|
|
27
28
|
},
|
|
28
29
|
mainTabTitle() {
|
|
@@ -36,6 +37,7 @@ export function createMainTabsComputed() {
|
|
|
36
37
|
if (this.mainTab === 'docs') return this.t('title.docs');
|
|
37
38
|
if (this.mainTab === 'trash') return this.t('settings.trash.title');
|
|
38
39
|
if (this.mainTab === 'prompts') return this.t('title.prompts');
|
|
40
|
+
if (this.mainTab === 'knowledge') return this.t('tab.knowledge');
|
|
39
41
|
return this.t('title.settings');
|
|
40
42
|
},
|
|
41
43
|
mainTabSubtitle() {
|
|
@@ -49,6 +51,7 @@ export function createMainTabsComputed() {
|
|
|
49
51
|
if (this.mainTab === 'docs') return this.t('subtitle.docs');
|
|
50
52
|
if (this.mainTab === 'trash') return this.t('settings.trash.meta');
|
|
51
53
|
if (this.mainTab === 'prompts') return this.t('subtitle.prompts');
|
|
54
|
+
if (this.mainTab === 'knowledge') return '';
|
|
52
55
|
return this.t('subtitle.settings');
|
|
53
56
|
}
|
|
54
57
|
};
|
|
@@ -2,7 +2,31 @@
|
|
|
2
2
|
import { expandWebLocale } from './expand.mjs';
|
|
3
3
|
import { zh } from './zh.mjs';
|
|
4
4
|
|
|
5
|
-
const en = expandWebLocale([[0,
|
|
5
|
+
const en = expandWebLocale([[0,826],[830,53],[826,4],[883,609],[1494,4],[1492,2],[1498,466]], [
|
|
6
|
+
"Shared Knowledge",
|
|
7
|
+
"Search",
|
|
8
|
+
"Search titles, filenames, or content",
|
|
9
|
+
"Search / Refresh",
|
|
10
|
+
"Loading…",
|
|
11
|
+
"No matching entries.",
|
|
12
|
+
"New text entry",
|
|
13
|
+
"Choose a file",
|
|
14
|
+
"Title",
|
|
15
|
+
"Content",
|
|
16
|
+
"View latest version",
|
|
17
|
+
"Saved content",
|
|
18
|
+
"Keep draft and edit against this version",
|
|
19
|
+
"Saving…",
|
|
20
|
+
"Save",
|
|
21
|
+
"Entry saved.",
|
|
22
|
+
"Check the title and filename, then try again.",
|
|
23
|
+
"Entry not found.",
|
|
24
|
+
"Another client updated this entry. Review the latest version and merge changes before saving.",
|
|
25
|
+
"Content exceeds 256 KiB.",
|
|
26
|
+
"Knowledge storage is full.",
|
|
27
|
+
"Knowledge operation failed. Try again.",
|
|
28
|
+
"Access denied. Reopen the app through an authorized Web entry point.",
|
|
29
|
+
"Choose a valid UTF-8 .md or .txt file.",
|
|
6
30
|
"Live test",
|
|
7
31
|
"Choose a test model",
|
|
8
32
|
"Configuration source",
|
|
@@ -2,7 +2,31 @@
|
|
|
2
2
|
import { expandWebLocale } from './expand.mjs';
|
|
3
3
|
import { zh } from './zh.mjs';
|
|
4
4
|
|
|
5
|
-
const ja = expandWebLocale([[0,
|
|
5
|
+
const ja = expandWebLocale([[0,1053],[1056,14],[1053,3],[1964,1],[1070,894]], [
|
|
6
|
+
"共有ナレッジ",
|
|
7
|
+
"検索",
|
|
8
|
+
"タイトル、ファイル名、本文を検索",
|
|
9
|
+
"検索/更新",
|
|
10
|
+
"読み込み中…",
|
|
11
|
+
"一致する項目がありません。",
|
|
12
|
+
"テキストを作成",
|
|
13
|
+
"ファイルを選択",
|
|
14
|
+
"タイトル",
|
|
15
|
+
"本文",
|
|
16
|
+
"最新版を表示",
|
|
17
|
+
"保存済みの本文",
|
|
18
|
+
"下書きを保持してこの版を基に編集",
|
|
19
|
+
"保存中…",
|
|
20
|
+
0,
|
|
21
|
+
"保存しました。",
|
|
22
|
+
"タイトルとファイル名を確認してから再試行してください。",
|
|
23
|
+
"項目が見つかりません。",
|
|
24
|
+
"別のクライアントがこの項目を更新しました。最新版を確認し、変更を取り込んでから保存してください。",
|
|
25
|
+
"本文が 256 KiB を超えています。",
|
|
26
|
+
"ナレッジの保存容量が上限に達しました。",
|
|
27
|
+
"操作に失敗しました。再試行してください。",
|
|
28
|
+
"アクセスが拒否されました。認証済みの Web 入口から開き直してください。",
|
|
29
|
+
"有効な UTF-8 の .md または .txt ファイルを選択してください。",
|
|
6
30
|
"実際の応答テスト",
|
|
7
31
|
"テストするモデルを選択",
|
|
8
32
|
"設定元",
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
// Generated by tools/dev/generate-web-locales.mjs from tools/i18n/locales/.
|
|
2
2
|
const localeKeys = Object.freeze([
|
|
3
|
+
"tab.knowledge",
|
|
4
|
+
"knowledge.searchPlaceholder",
|
|
5
|
+
"knowledge.searchLabel",
|
|
6
|
+
"knowledge.search",
|
|
7
|
+
"knowledge.loading",
|
|
8
|
+
"knowledge.empty",
|
|
9
|
+
"knowledge.new",
|
|
10
|
+
"knowledge.upload",
|
|
11
|
+
"knowledge.title",
|
|
12
|
+
"knowledge.content",
|
|
13
|
+
"knowledge.loadLatest",
|
|
14
|
+
"knowledge.latest",
|
|
15
|
+
"knowledge.keepDraft",
|
|
16
|
+
"knowledge.saving",
|
|
17
|
+
"knowledge.save",
|
|
18
|
+
"knowledge.saved",
|
|
19
|
+
"knowledge.invalid",
|
|
20
|
+
"knowledge.notFound",
|
|
21
|
+
"knowledge.conflict",
|
|
22
|
+
"knowledge.tooLarge",
|
|
23
|
+
"knowledge.full",
|
|
24
|
+
"knowledge.failed",
|
|
25
|
+
"knowledge.unauthorized",
|
|
26
|
+
"knowledge.invalidFile",
|
|
3
27
|
"modelTest.title",
|
|
4
28
|
"modelTest.selection",
|
|
5
29
|
"modelTest.source",
|
|
@@ -2,7 +2,31 @@
|
|
|
2
2
|
import { expandWebLocale } from './expand.mjs';
|
|
3
3
|
import { zh } from './zh.mjs';
|
|
4
4
|
|
|
5
|
-
const vi = expandWebLocale([[0,
|
|
5
|
+
const vi = expandWebLocale([[0,333],[704,32],[791,6],[333,55],[1397,1],[388,17],[1395,1],[445,6],[454,65],[1326,6],[1260,51],[1433,1],[519,7],[527,2],[526,1],[529,79],[1488,4],[1531,2],[1544,2],[1557,1],[1504,27],[1443,45],[1578,12],[608,4],[1678,7],[797,13],[830,49],[1674,4],[879,4],[1421,3],[1073,1],[1590,9],[899,4],[911,1],[913,1],[1352,6],[915,2],[405,40],[451,3],[612,92],[736,55],[810,20],[883,8],[1333,1],[891,1],[1334,1],[892,7],[903,8],[912,1],[914,1],[917,43],[1721,1],[960,2],[1722,1],[962,111],[1074,76],[1401,1],[1150,110],[1311,15],[1332,1],[1335,17],[1358,37],[1396,1],[1398,3],[1402,19],[1424,9],[1434,9],[1494,4],[1492,2],[1498,6],[1533,11],[1546,11],[1558,20],[1599,75],[1685,23],[1709,2],[1708,1],[1711,10],[1723,241]], [
|
|
6
|
+
"Kho tri thức",
|
|
7
|
+
"Tìm kiếm",
|
|
8
|
+
"Tìm theo tiêu đề, tên tệp hoặc nội dung",
|
|
9
|
+
"Tìm / Làm mới",
|
|
10
|
+
"Đang tải…",
|
|
11
|
+
"Không tìm thấy mục phù hợp.",
|
|
12
|
+
"Tạo mục văn bản",
|
|
13
|
+
"Chọn tệp",
|
|
14
|
+
"Tiêu đề",
|
|
15
|
+
"Nội dung",
|
|
16
|
+
"Xem phiên bản mới nhất",
|
|
17
|
+
"Nội dung đã lưu",
|
|
18
|
+
"Giữ bản nháp và chỉnh sửa dựa trên phiên bản này",
|
|
19
|
+
"Đang lưu…",
|
|
20
|
+
"Lưu",
|
|
21
|
+
"Đã lưu mục.",
|
|
22
|
+
"Kiểm tra tiêu đề và tên tệp rồi thử lại.",
|
|
23
|
+
"Không tìm thấy mục này.",
|
|
24
|
+
"Một ứng dụng khác đã cập nhật mục này. Xem phiên bản mới nhất và gộp thay đổi trước khi lưu.",
|
|
25
|
+
"Nội dung vượt quá 256 KiB.",
|
|
26
|
+
"Kho tri thức đã đầy.",
|
|
27
|
+
"Thao tác thất bại. Hãy thử lại.",
|
|
28
|
+
"Truy cập bị từ chối. Hãy mở lại qua đường dẫn Web đã xác thực.",
|
|
29
|
+
"Chọn tệp UTF-8 .md hoặc .txt hợp lệ.",
|
|
6
30
|
"Kiểm thử thực tế",
|
|
7
31
|
"Chọn mô hình kiểm thử",
|
|
8
32
|
"Nguồn cấu hình",
|