codexmate 0.1.38 → 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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/README.vi.md +1 -1
  3. package/README.zh.md +1 -1
  4. package/cli/doctor-core.js +1 -1
  5. package/cli.js +93 -79
  6. package/lib/model-test.js +126 -21
  7. package/lib/shared-knowledge.js +86 -0
  8. package/package.json +5 -1
  9. package/plugins/prompt-templates/overview.mjs +1 -7
  10. package/web-ui/app.js +3 -2
  11. package/web-ui/index.html +2 -0
  12. package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
  13. package/web-ui/modules/app.methods.navigation.mjs +2 -1
  14. package/web-ui/modules/i18n/locales/en.mjs +1969 -2018
  15. package/web-ui/modules/i18n/locales/expand.mjs +18 -0
  16. package/web-ui/modules/i18n/locales/ja.mjs +1970 -2019
  17. package/web-ui/modules/i18n/locales/keys.mjs +1969 -0
  18. package/web-ui/modules/i18n/locales/vi.mjs +1969 -1987
  19. package/web-ui/modules/i18n/locales/zh-tw.mjs +1969 -2016
  20. package/web-ui/modules/i18n/locales/zh.mjs +1968 -2016
  21. package/web-ui/modules/model-test.mjs +114 -26
  22. package/web-ui/modules/shared-knowledge.mjs +139 -0
  23. package/web-ui/partials/index/layout-header.html +22 -5
  24. package/web-ui/partials/index/panel-knowledge.html +68 -0
  25. package/web-ui/partials/index/panel-plugins.html +12 -27
  26. package/web-ui/partials/index/plugin-file-sharing.html +1 -1
  27. package/web-ui/partials/index/routing-model-test.html +29 -9
  28. package/web-ui/res/reicon-knowledge.LICENSE.txt +20 -0
  29. package/web-ui/res/reicon-knowledge.svg +18 -0
  30. package/web-ui/res/web-ui-render.precompiled.js +1 -14783
  31. package/web-ui/styles/base-theme.css +2 -2
  32. package/web-ui/styles/navigation-panels.css +11 -18
  33. package/web-ui/styles/plugins-panel.css +16 -91
  34. package/web-ui/styles/responsive.css +8 -16
  35. package/web-ui/styles/routing.css +8 -0
  36. package/web-ui/styles/shared-knowledge.css +227 -0
  37. package/web-ui/styles/sub-tabs.css +13 -0
  38. package/web-ui/styles/theme-violet.css +0 -21
  39. package/web-ui/styles/titles-cards.css +0 -23
  40. package/web-ui/styles.css +1 -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.38",
3
+ "version": "0.1.40",
4
4
  "description": "Codex/Claude Code/OpenClaw 配置、会话与任务编排 CLI + Web 工具",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -31,6 +31,8 @@
31
31
  "start": "node cli.js",
32
32
  "reset": "node tools/dev/reset-main.js",
33
33
  "release:npm": "node tools/release/publish-npm.js",
34
+ "generate:web-render": "node tools/dev/generate-web-render.js",
35
+ "generate:web-locales": "node tools/dev/generate-web-locales.mjs",
34
36
  "docs:dev": "node ./node_modules/vitepress/dist/node/cli.js dev site",
35
37
  "docs:build": "node ./node_modules/vitepress/dist/node/cli.js build site",
36
38
  "docs:preview": "node ./node_modules/vitepress/dist/node/cli.js preview site",
@@ -53,6 +55,7 @@
53
55
  "pretest": "node tools/ci/ensure-test-deps.js"
54
56
  },
55
57
  "dependencies": {
58
+ "@fontsource-variable/geist": "5.3.0",
56
59
  "@iarna/toml": "^2.2.5",
57
60
  "json5": "^2.2.3",
58
61
  "yauzl": "^3.2.1",
@@ -83,6 +86,7 @@
83
86
  "@vue/compiler-dom": "^3.5.34",
84
87
  "e2e": "0.22.0",
85
88
  "opencc-js": "^1.3.1",
89
+ "reicon": "1.2.6",
86
90
  "vitepress": "^1.6.4"
87
91
  }
88
92
  }
@@ -42,17 +42,11 @@ export async function loadPromptTemplatesOverview(ctx, options = {}) {
42
42
 
43
43
  app.promptTemplatesLoadedOnce = true;
44
44
 
45
- if (!app.promptTemplatesMode) {
46
- app.promptTemplatesMode = 'compose';
47
- }
48
45
  if (app.promptTemplatesMode !== 'compose' && app.promptTemplatesMode !== 'manage') {
49
46
  app.promptTemplatesMode = 'compose';
50
47
  }
51
- if (app.mainTab === 'plugins') {
52
- app.promptTemplatesMode = 'compose';
53
- }
54
48
 
55
- if (app.mainTab === 'plugins' && app.promptTemplatesMode === 'compose') {
49
+ if (app.mainTab === 'plugins') {
56
50
  const list = Array.isArray(app.promptTemplatesList) ? app.promptTemplatesList : [];
57
51
  const storedSelected = readPromptTemplateSelectedIdFromStorage(localStorage);
58
52
  const exists = list.some((item) => item && item.id === app.promptComposerSelectedTemplateId);
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
  };
@@ -15,7 +15,8 @@
15
15
  'docs',
16
16
  'settings',
17
17
  'trash',
18
- 'prompts'
18
+ 'prompts',
19
+ 'knowledge'
19
20
  ];
20
21
  const MAIN_TAB_SET = new Set(MAIN_TAB_ORDER);
21
22
  const DISABLED_MAIN_TAB_SET = new Set();