@sanqianx/project-knowledge 4.6.1
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/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +17 -0
- package/CHANGELOG.md +780 -0
- package/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +266 -0
- package/_site/README.md +30 -0
- package/_site/_test/ai-profile-resolver-test.js +137 -0
- package/_site/_test/ai-profile-test.js +75 -0
- package/_site/_test/ai-vendor-presets-test.js +91 -0
- package/_site/_test/automation-queue-test.js +14 -0
- package/_site/_test/automation-ui-test.js +40 -0
- package/_site/_test/background-task-registry-test.js +43 -0
- package/_site/_test/baseline-schema-test.js +91 -0
- package/_site/_test/bin-cli-test.js +218 -0
- package/_site/_test/bridge-adapter-test.js +95 -0
- package/_site/_test/bridge-consumer-service-test.js +310 -0
- package/_site/_test/cdp-browser-failure-test.js +100 -0
- package/_site/_test/chat-claudecodeui-match-test.js +92 -0
- package/_site/_test/claude-executable-discovery-test.js +90 -0
- package/_site/_test/claude-session-lifecycle-sweep-test.js +252 -0
- package/_site/_test/claude-workbench-test.js +170 -0
- package/_site/_test/client-capture-restart-e2e-test.js +189 -0
- package/_site/_test/codex-conversation-projection-test.js +59 -0
- package/_site/_test/codex-notify-fanout-test.js +45 -0
- package/_site/_test/commit-boundary-freeze-test.js +147 -0
- package/_site/_test/commit-conversation-binding-test.js +99 -0
- package/_site/_test/commit-evidence-test.js +110 -0
- package/_site/_test/context-pack-test.js +198 -0
- package/_site/_test/conversation-api-test.js +119 -0
- package/_site/_test/conversation-store-test.js +136 -0
- package/_site/_test/cross-repo-isolation-e2e-test.js +187 -0
- package/_site/_test/data-dir-migration-test.js +77 -0
- package/_site/_test/desktop-browser-compat-test.js +28 -0
- package/_site/_test/desktop-hook-runtime-regression-test.js +204 -0
- package/_site/_test/embedding-config-test.js +32 -0
- package/_site/_test/explicit-commit-processor-test.js +37 -0
- package/_site/_test/fixtures/fake-browser-exit.js +10 -0
- package/_site/_test/fixtures/fake-browser-hang.js +10 -0
- package/_site/_test/fixtures/make-git-repos.js +89 -0
- package/_site/_test/folder-picker-output-test.js +19 -0
- package/_site/_test/full-integration-e2e-test.js +165 -0
- package/_site/_test/git-validation-test.js +81 -0
- package/_site/_test/hook-runtime-endpoint-test.js +88 -0
- package/_site/_test/hook-status-repair-api-test.js +152 -0
- package/_site/_test/hook-trigger-test.js +85 -0
- package/_site/_test/hook-worktree-test.js +42 -0
- package/_site/_test/import-preflight-api-test.js +233 -0
- package/_site/_test/import-ui-flow-test.js +171 -0
- package/_site/_test/index-builder-test.js +41 -0
- package/_site/_test/index-writer-concurrency-test.js +135 -0
- package/_site/_test/integration-adapters-test.js +243 -0
- package/_site/_test/integration-capture-setup-test.js +108 -0
- package/_site/_test/integration-surface-coverage-test.js +165 -0
- package/_site/_test/kb-framework-test.js +57 -0
- package/_site/_test/kbpath-follow-test.js +63 -0
- package/_site/_test/knowledge-db-test.js +144 -0
- package/_site/_test/knowledge-language-control-test.js +170 -0
- package/_site/_test/knowledge-maintenance-test.js +40 -0
- package/_site/_test/knowledge-migration-test.js +75 -0
- package/_site/_test/knowledge-promotion-recovery-test.js +260 -0
- package/_site/_test/knowledge-query-test.js +54 -0
- package/_site/_test/knowledge-retrieval-service-test.js +77 -0
- package/_site/_test/knowledge-scopes-test.js +37 -0
- package/_site/_test/knowledge-storage-location-test.js +28 -0
- package/_site/_test/knowledge-storage-startup-test.js +52 -0
- package/_site/_test/knowledge-store-logs-supervision-test.js +89 -0
- package/_site/_test/legacy-claude-session-alias-test.js +106 -0
- package/_site/_test/legacy-forward-compat-test.js +257 -0
- package/_site/_test/legacy-project-upgrade-e2e-test.js +363 -0
- package/_site/_test/legacy-routes-removed-test.js +47 -0
- package/_site/_test/legacy-workbench-exclusion-test.js +92 -0
- package/_site/_test/log-redaction-test.js +58 -0
- package/_site/_test/logging-api-test.js +89 -0
- package/_site/_test/logging-sse-no-gap-test.js +88 -0
- package/_site/_test/logging-ui-test.js +104 -0
- package/_site/_test/markdown-delta-overlay-test.js +85 -0
- package/_site/_test/markdown-maintenance-api-test.js +75 -0
- package/_site/_test/markdown-maintenance-test.js +11 -0
- package/_site/_test/mcp-server-test.js +149 -0
- package/_site/_test/model-context-windows-test.js +89 -0
- package/_site/_test/module-bridge-eventbridge-test.js +193 -0
- package/_site/_test/non-release-ci-test.js +34 -0
- package/_site/_test/offline-boundary-isolation-test.js +32 -0
- package/_site/_test/orphaned-claim-recovery-test.js +80 -0
- package/_site/_test/p0-data-migration-characterization-test.js +37 -0
- package/_site/_test/p0-e2e-gate-test.js +347 -0
- package/_site/_test/package-boundary-test.js +42 -0
- package/_site/_test/package-startup-test.js +56 -0
- package/_site/_test/packaged-ui-smoke-test.js +79 -0
- package/_site/_test/path-consistency-test.js +151 -0
- package/_site/_test/pending-sweep-test.js +9 -0
- package/_site/_test/post-commit-automation-test.js +87 -0
- package/_site/_test/pr-consumer-contract-test.js +55 -0
- package/_site/_test/project-control-panel-task14-test.js +63 -0
- package/_site/_test/project-delete-recovery-test.js +64 -0
- package/_site/_test/project-goal-editor-test.js +145 -0
- package/_site/_test/project-layout-v2-migration-test.js +127 -0
- package/_site/_test/project-lifecycle-transaction-test.js +106 -0
- package/_site/_test/project-remove-running-guard-test.js +79 -0
- package/_site/_test/project-store-test.js +90 -0
- package/_site/_test/prompt-settings-test.js +115 -0
- package/_site/_test/protected-architecture-gate-test.js +123 -0
- package/_site/_test/refactor-characterization-test.js +36 -0
- package/_site/_test/release-version-sync-test.js +98 -0
- package/_site/_test/requirement-binding-test.js +113 -0
- package/_site/_test/requirement-recorder-test.js +173 -0
- package/_site/_test/run-all-tests.js +156 -0
- package/_site/_test/runtime-endpoint-test.js +64 -0
- package/_site/_test/scanner-test.js +83 -0
- package/_site/_test/server-runtime-migration-safety-test.js +27 -0
- package/_site/_test/server-security-test.js +96 -0
- package/_site/_test/sessions-stream-test.js +92 -0
- package/_site/_test/shared-contracts-test.js +58 -0
- package/_site/_test/simple-import-test.js +97 -0
- package/_site/_test/startup-analysis-disabled-test.js +16 -0
- package/_site/_test/storage-foundation-test.js +78 -0
- package/_site/_test/structured-logger-test.js +101 -0
- package/_site/_test/task15-20-ui-flow-test.js +148 -0
- package/_site/_test/team-knowledge-store-sparse-checkout-test.js +196 -0
- package/_site/_test/team-knowledge-store-test.js +131 -0
- package/_site/_test/tracking-start-test.js +143 -0
- package/_site/_test/ui-i18n-toggle-test.js +114 -0
- package/_site/_test/ui-smoke-test.js +73 -0
- package/_site/_test/v4122-upgrade-data-contract-test.js +56 -0
- package/_site/_test/workbench-permission-test.js +118 -0
- package/_site/_test/workspace-ui-contract-test.js +43 -0
- package/_site/lib/ai-profile-resolver.js +78 -0
- package/_site/lib/ai-vendor-presets.js +83 -0
- package/_site/lib/ai-workspace.js +104 -0
- package/_site/lib/atomic-file.js +204 -0
- package/_site/lib/automation-config.js +140 -0
- package/_site/lib/bridge-adapter.js +256 -0
- package/_site/lib/bridge-consumer-service.js +402 -0
- package/_site/lib/claude-cli-runner.js +1599 -0
- package/_site/lib/commit-conversation-binder.js +246 -0
- package/_site/lib/commit-processing-ledger.js +27 -0
- package/_site/lib/commit-prompt.js +202 -0
- package/_site/lib/commit-reconciler.js +444 -0
- package/_site/lib/context-pack-builder.js +299 -0
- package/_site/lib/contracts.js +279 -0
- package/_site/lib/conversation-exclusions.js +204 -0
- package/_site/lib/conversation-query-service.js +161 -0
- package/_site/lib/conversation-store.js +385 -0
- package/_site/lib/data-dir.js +81 -0
- package/_site/lib/data-state-classifier.js +40 -0
- package/_site/lib/embedding-service.js +85 -0
- package/_site/lib/evidence-bundle.js +228 -0
- package/_site/lib/folder-picker-output.js +24 -0
- package/_site/lib/git-runner.js +62 -0
- package/_site/lib/github-team-store.js +1175 -0
- package/_site/lib/hook-manager.js +202 -0
- package/_site/lib/index-builder.js +157 -0
- package/_site/lib/index-service.js +173 -0
- package/_site/lib/integration-installer.js +907 -0
- package/_site/lib/kb-framework.js +191 -0
- package/_site/lib/kb-validator.js +124 -0
- package/_site/lib/knowledge-db.js +363 -0
- package/_site/lib/knowledge-promotion.js +435 -0
- package/_site/lib/knowledge-retrieval-service.js +401 -0
- package/_site/lib/knowledge-schema.js +121 -0
- package/_site/lib/knowledge-tool-runtime.js +359 -0
- package/_site/lib/legacy-data-manifest.js +26 -0
- package/_site/lib/llm-client.js +173 -0
- package/_site/lib/markdown-knowledge-indexer.js +230 -0
- package/_site/lib/migration-service.js +442 -0
- package/_site/lib/model-context-windows.js +82 -0
- package/_site/lib/module-bridge.js +496 -0
- package/_site/lib/post-commit-automation.js +141 -0
- package/_site/lib/project-lifecycle-service.js +511 -0
- package/_site/lib/project-registry-store.js +129 -0
- package/_site/lib/project-store.js +262 -0
- package/_site/lib/prompt-registry.js +148 -0
- package/_site/lib/requirement-adapters.js +10 -0
- package/_site/lib/requirement-binder.js +112 -0
- package/_site/lib/requirement-recorder.js +278 -0
- package/_site/lib/runtime-endpoint.js +160 -0
- package/_site/lib/scanner.js +298 -0
- package/_site/lib/server-app.js +1520 -0
- package/_site/lib/settings-store.js +113 -0
- package/_site/lib/storage-layout.js +162 -0
- package/_site/lib/structured-logger.js +574 -0
- package/_site/scripts/codex-notify-fanout.cjs +51 -0
- package/_site/scripts/folder-picker.ps1 +156 -0
- package/_site/scripts/hook-trigger.js +156 -0
- package/_site/scripts/sync-release-version.js +158 -0
- package/_site/server.js +12 -0
- package/_site/start.bat +26 -0
- package/_site/stop.bat +11 -0
- package/bin/project-knowledge-integrations.js +241 -0
- package/bin/project-knowledge-kb.js +65 -0
- package/bin/project-knowledge-mcp.js +195 -0
- package/bin/project-knowledge.js +439 -0
- package/claude-prompts.json +21 -0
- package/docs/README.zh-CN.md +175 -0
- package/docs/assets/architecture.svg +182 -0
- package/docs/assets/dashboard.png +0 -0
- package/docs/assets/draft-review.png +0 -0
- package/docs/assets/logo.svg +50 -0
- package/docs/assets/runs-drafts.png +0 -0
- package/docs/assets/settings.png +0 -0
- package/docs/project-registry-schema.md +33 -0
- package/docs/team-knowledge-mode-a-plan.md +73 -0
- package/docs/testing-strategy.md +33 -0
- package/package.json +100 -0
- package/plugins/project-knowledge/.claude-plugin/plugin.json +19 -0
- package/plugins/project-knowledge/.codex-plugin/plugin.json +38 -0
- package/plugins/project-knowledge/.mcp.json +14 -0
- package/plugins/project-knowledge/opencode/project-knowledge.md +3 -0
- package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +28 -0
- package/plugins/project-knowledge/skills/project-knowledge/agents/openai.yaml +11 -0
- package/templates/change.md +30 -0
- package/templates/project-readme.md +52 -0
- package/ui/app.css +58 -0
- package/ui/app.js +607 -0
- package/ui/favicon.svg +38 -0
- package/ui/i18n.js +146 -0
- package/ui/index.html +162 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// _site/_test/ui-i18n-toggle-test.js
|
|
2
|
+
//
|
|
3
|
+
// T10: UI language toggle + persistence + smoke check that key labels
|
|
4
|
+
// actually change after switching zh-CN -> en-US. The test boots a real
|
|
5
|
+
// server, drives a headless Chromium, and inspects label textContent.
|
|
6
|
+
|
|
7
|
+
const assert = require('assert');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { spawnServer } = require('./helpers/spawn-server');
|
|
12
|
+
const { findChrome } = require('./helpers/find-chrome');
|
|
13
|
+
const { launchCdpBrowser, waitFor } = require('./helpers/cdp-browser');
|
|
14
|
+
|
|
15
|
+
const ROOT = path.resolve(__dirname, '..', '..');
|
|
16
|
+
const sitePort = 7980 + (process.pid % 200);
|
|
17
|
+
const profileDir = path.join(os.tmpdir(), 'pk-i18n-' + process.pid);
|
|
18
|
+
|
|
19
|
+
async function waitForLanguage(browser, language, label) {
|
|
20
|
+
await waitFor(async () => {
|
|
21
|
+
const state = await browser.evaluate(`(() => ({
|
|
22
|
+
appReady: Boolean(window.__PK_APP__),
|
|
23
|
+
active: window.I18N && window.I18N.activeLanguage(),
|
|
24
|
+
select: document.getElementById('ui-language')?.value,
|
|
25
|
+
documentLanguage: document.documentElement.lang,
|
|
26
|
+
}))()`);
|
|
27
|
+
return state.appReady && state.active === language && state.select === language && state.documentLanguage === (language === 'en-US' ? 'en' : 'zh-CN')
|
|
28
|
+
? { ok: true }
|
|
29
|
+
: null;
|
|
30
|
+
}, label, 20000);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
(async () => {
|
|
34
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pk-i18n-data-' + process.pid + '-'));
|
|
35
|
+
const server = spawnServer({
|
|
36
|
+
root: ROOT, port: sitePort, dataDir, tag: 'ui-i18n', stdio: 'ignore',
|
|
37
|
+
extraEnv: { KB_SKIP_MIGRATION: '1' },
|
|
38
|
+
});
|
|
39
|
+
let browser;
|
|
40
|
+
try {
|
|
41
|
+
await waitFor(async () => {
|
|
42
|
+
try {
|
|
43
|
+
const r = await fetch(`http://127.0.0.1:${sitePort}/api/health`);
|
|
44
|
+
return r.ok ? { ok: true } : null;
|
|
45
|
+
} catch { return null; }
|
|
46
|
+
}, 'isolated server', 20000);
|
|
47
|
+
browser = await launchCdpBrowser({
|
|
48
|
+
chrome: findChrome(), profileDir, url: `http://127.0.0.1:${sitePort}/`, width: 1440, height: 900,
|
|
49
|
+
});
|
|
50
|
+
// Wait for i18n.js to be available on window
|
|
51
|
+
await waitFor(async () => {
|
|
52
|
+
const ready = await browser.evaluate('Boolean(window.I18N)');
|
|
53
|
+
return ready ? { ok: true } : null;
|
|
54
|
+
}, 'window.I18N available', 20000);
|
|
55
|
+
|
|
56
|
+
// Case 1: default language is zh-CN.
|
|
57
|
+
{
|
|
58
|
+
const lang = await browser.evaluate('window.I18N.activeLanguage()');
|
|
59
|
+
assert.strictEqual(lang, 'zh-CN', 'default language must be zh-CN when no preference exists');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Case 2: switch to en-US via the settings drawer toggle.
|
|
63
|
+
await browser.evaluate(`(() => {
|
|
64
|
+
// Open settings drawer (data-settings='ai' button)
|
|
65
|
+
const btn = document.querySelector('[data-settings="ai"]') || document.getElementById('open-settings');
|
|
66
|
+
if (btn) btn.click();
|
|
67
|
+
})()`);
|
|
68
|
+
await waitFor(async () => {
|
|
69
|
+
const open = await browser.evaluate('Boolean(document.getElementById("ui-language"))');
|
|
70
|
+
return open ? { ok: true } : null;
|
|
71
|
+
}, 'ui-language select visible', 5000);
|
|
72
|
+
await browser.evaluate(`(() => {
|
|
73
|
+
const sel = document.getElementById('ui-language');
|
|
74
|
+
sel.value = 'en-US';
|
|
75
|
+
sel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
76
|
+
})()`);
|
|
77
|
+
await waitForLanguage(browser, 'en-US', 'language switched to en-US');
|
|
78
|
+
assert.strictEqual(await browser.evaluate('document.querySelector("label[for=ui-language]").textContent'), 'UI language');
|
|
79
|
+
|
|
80
|
+
// Case 3: persistence across reload — preference must survive a hard
|
|
81
|
+
// reload. The browser context keeps localStorage across reloads.
|
|
82
|
+
await browser.evaluate('location.reload()');
|
|
83
|
+
await waitForLanguage(browser, 'en-US', 'language persists after reload');
|
|
84
|
+
|
|
85
|
+
// Case 4: switch back to zh-CN and verify activeLanguage reflects it.
|
|
86
|
+
await browser.evaluate(`(() => {
|
|
87
|
+
document.getElementById('ui-language').value = 'zh-CN';
|
|
88
|
+
document.getElementById('ui-language').dispatchEvent(new Event('change', { bubbles: true }));
|
|
89
|
+
})()`);
|
|
90
|
+
await waitForLanguage(browser, 'zh-CN', 'switch back to zh-CN');
|
|
91
|
+
assert.strictEqual(await browser.evaluate('document.querySelector("label[for=ui-language]").textContent'), '界面语言');
|
|
92
|
+
|
|
93
|
+
// Case 5: unknown key returns the key string (no missing-key placeholder).
|
|
94
|
+
{
|
|
95
|
+
const missing = await browser.evaluate('window.I18N.t("does.not.exist")');
|
|
96
|
+
assert.strictEqual(missing, 'does.not.exist', 'unknown keys must return the key string, not a placeholder');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Case 6: availableLanguages contains both zh-CN and en-US.
|
|
100
|
+
{
|
|
101
|
+
const list = await browser.evaluate('window.I18N.availableLanguages().sort().join(",")');
|
|
102
|
+
assert.strictEqual(list, 'en-US,zh-CN', 'availableLanguages must include zh-CN and en-US');
|
|
103
|
+
}
|
|
104
|
+
} finally {
|
|
105
|
+
if (browser) await browser.close();
|
|
106
|
+
server.child.kill();
|
|
107
|
+
await new Promise(resolve => server.child.once('exit', resolve));
|
|
108
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
console.log('ui-i18n-toggle-test PASS');
|
|
111
|
+
})().catch(error => {
|
|
112
|
+
console.error(error.stack || error.message);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnServer } = require('./helpers/spawn-server');
|
|
6
|
+
const { findChrome } = require('./helpers/find-chrome');
|
|
7
|
+
const { launchCdpBrowser, requestJson, waitFor } = require('./helpers/cdp-browser');
|
|
8
|
+
const { createLoggingUiFixture } = require('./helpers/logging-ui-fixture');
|
|
9
|
+
|
|
10
|
+
const ROOT = path.resolve(__dirname, '..', '..');
|
|
11
|
+
const sitePort = 7900 + (process.pid % 300);
|
|
12
|
+
const profileDir = path.join(os.tmpdir(), 'pk-ui-smoke-profile-' + process.pid);
|
|
13
|
+
const screenshotPath = path.join(os.tmpdir(), 'pk-ui-smoke-' + process.pid + '.png');
|
|
14
|
+
|
|
15
|
+
(async () => {
|
|
16
|
+
const fixture = await createLoggingUiFixture({ totalLogs: 18 });
|
|
17
|
+
const server = spawnServer({ root: ROOT, port: sitePort, dataDir: fixture.dataDir, tag: 'ui-smoke-v13', stdio: 'ignore' });
|
|
18
|
+
let browser;
|
|
19
|
+
try {
|
|
20
|
+
await waitFor(() => requestJson(`http://127.0.0.1:${sitePort}/api/health`).then(payload => payload.ok), 'isolated server', 20000);
|
|
21
|
+
browser = await launchCdpBrowser({ chrome: findChrome(), profileDir, url: `http://127.0.0.1:${sitePort}/`, width: 1440, height: 900 });
|
|
22
|
+
await waitFor(() => browser.evaluate('window.__PK_APP__ && window.__PK_APP__.getState().projects === 1'), 'v13 shell', 20000);
|
|
23
|
+
|
|
24
|
+
const snapshot = await browser.evaluate(`(() => ({
|
|
25
|
+
title: document.title,
|
|
26
|
+
shell: document.querySelectorAll('.shell').length,
|
|
27
|
+
sidebar: getComputedStyle(document.querySelector('.sidebar')).display,
|
|
28
|
+
terminalView: document.getElementById('view-terminal').classList.contains('active'),
|
|
29
|
+
projects: document.querySelectorAll('#project-list .project-card').length,
|
|
30
|
+
unsafeImages: document.querySelectorAll('img').length,
|
|
31
|
+
xss: window.__xss,
|
|
32
|
+
bodyWidth: document.body.scrollWidth,
|
|
33
|
+
viewportWidth: document.documentElement.clientWidth
|
|
34
|
+
}))()`);
|
|
35
|
+
assert.strictEqual(snapshot.title, 'Project Knowledge');
|
|
36
|
+
assert.strictEqual(snapshot.shell, 1);
|
|
37
|
+
assert.notStrictEqual(snapshot.sidebar, 'none');
|
|
38
|
+
assert.strictEqual(snapshot.terminalView, true);
|
|
39
|
+
assert.strictEqual(snapshot.projects, 1);
|
|
40
|
+
assert.strictEqual(snapshot.unsafeImages, 0);
|
|
41
|
+
assert.strictEqual(snapshot.xss, undefined);
|
|
42
|
+
assert(snapshot.bodyWidth <= snapshot.viewportWidth + 1, 'desktop shell must not overflow horizontally');
|
|
43
|
+
|
|
44
|
+
await browser.evaluate("document.getElementById('theme-button').click()");
|
|
45
|
+
assert.strictEqual(await browser.evaluate('document.documentElement.dataset.theme'), 'dark');
|
|
46
|
+
|
|
47
|
+
await browser.setViewport(390, 844);
|
|
48
|
+
const mobile = await browser.evaluate(`(() => ({
|
|
49
|
+
sidebar: getComputedStyle(document.querySelector('.sidebar')).display,
|
|
50
|
+
mobileBar: getComputedStyle(document.querySelector('.mobile-strip')).display,
|
|
51
|
+
bodyWidth: document.body.scrollWidth,
|
|
52
|
+
viewportWidth: document.documentElement.clientWidth,
|
|
53
|
+
projectUsable: document.getElementById('mobile-project').getBoundingClientRect().width > 100
|
|
54
|
+
}))()`);
|
|
55
|
+
assert.strictEqual(mobile.sidebar, 'none');
|
|
56
|
+
assert.notStrictEqual(mobile.mobileBar, 'none');
|
|
57
|
+
assert.strictEqual(mobile.projectUsable, true);
|
|
58
|
+
assert(mobile.bodyWidth <= mobile.viewportWidth + 1, 'mobile shell must not overflow horizontally');
|
|
59
|
+
|
|
60
|
+
await browser.screenshot(screenshotPath);
|
|
61
|
+
assert(fs.statSync(screenshotPath).size > 10000, 'real browser screenshot should contain rendered UI');
|
|
62
|
+
assert.strictEqual(browser.exceptions.length, 0, 'browser runtime exceptions: ' + JSON.stringify(browser.exceptions));
|
|
63
|
+
console.log('ui smoke test PASS');
|
|
64
|
+
} finally {
|
|
65
|
+
if (browser) await browser.close();
|
|
66
|
+
await server.cleanup();
|
|
67
|
+
fixture.cleanup();
|
|
68
|
+
try { fs.rmSync(screenshotPath, { force: true }); } catch {}
|
|
69
|
+
}
|
|
70
|
+
})().catch(error => {
|
|
71
|
+
console.error(error.stack || error.message);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { StorageLayout } = require('../lib/storage-layout');
|
|
6
|
+
const { MigrationService } = require('../lib/migration-service');
|
|
7
|
+
const { publicAiProfilesConfig } = require('../lib/contracts');
|
|
8
|
+
|
|
9
|
+
function fixture() {
|
|
10
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pk-v4122-upgrade-'));
|
|
11
|
+
const knowledgeRoot = path.join(dataDir, 'knowledge-root');
|
|
12
|
+
const projects = {};
|
|
13
|
+
for (const slug of ['alpha', 'beta', 'gamma']) {
|
|
14
|
+
const repoPath = path.join(dataDir, 'repos', slug);
|
|
15
|
+
const knowledgePath = path.join(knowledgeRoot, `preserved-${slug}`);
|
|
16
|
+
fs.mkdirSync(knowledgePath, { recursive: true });
|
|
17
|
+
fs.writeFileSync(path.join(knowledgePath, 'README.md'), `# ${slug}\n`);
|
|
18
|
+
projects[slug] = { repoPath, kbPath: knowledgePath, aiProfileId: slug === 'alpha' ? 'primary' : 'secondary' };
|
|
19
|
+
}
|
|
20
|
+
fs.writeFileSync(path.join(dataDir, 'projects.json'), JSON.stringify(projects));
|
|
21
|
+
fs.writeFileSync(path.join(dataDir, 'knowledge-store.json'), JSON.stringify({ rootPath: knowledgeRoot }));
|
|
22
|
+
fs.writeFileSync(path.join(dataDir, 'ai-profiles.json'), JSON.stringify({ profiles: [
|
|
23
|
+
{ id: 'primary', apiKey: 'fixture-secret-one', model: 'model-a' },
|
|
24
|
+
{ id: 'secondary', apiKey: 'fixture-secret-two', model: 'model-b' },
|
|
25
|
+
] }));
|
|
26
|
+
fs.writeFileSync(path.join(dataDir, 'embedding-config.json'), JSON.stringify({ modelId: 'embedding-v4122', localFilesOnly: true, localModelPath: path.join(dataDir, 'models') }));
|
|
27
|
+
fs.mkdirSync(path.join(dataDir, 'models', 'A', 'B'), { recursive: true });
|
|
28
|
+
fs.writeFileSync(path.join(dataDir, 'models', 'A', 'B', 'model.onnx'), 'exact-model-content');
|
|
29
|
+
return { dataDir, knowledgeRoot, projects };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
(async () => {
|
|
33
|
+
const { dataDir, knowledgeRoot, projects } = fixture();
|
|
34
|
+
try {
|
|
35
|
+
const layout = new StorageLayout({ dataDir });
|
|
36
|
+
const result = await new MigrationService({ layout, legacyDataDir: dataDir }).migrateIfNeeded({ migrationRunId: 'v4122-contract' });
|
|
37
|
+
assert.equal(result.ok, true);
|
|
38
|
+
const registry = JSON.parse(fs.readFileSync(layout.getProjectRegistryPath(), 'utf8'));
|
|
39
|
+
assert.equal(registry.projectOrder.length, 3);
|
|
40
|
+
const settings = JSON.parse(fs.readFileSync(layout.getSettingsPath(), 'utf8'));
|
|
41
|
+
assert.equal(settings.knowledge.rootPath, knowledgeRoot);
|
|
42
|
+
assert.deepEqual(settings.embedding, { modelId: 'embedding-v4122', localFilesOnly: true, localModelPath: path.join(dataDir, 'models') });
|
|
43
|
+
assert.equal(settings.ai.profiles.length, 2);
|
|
44
|
+
assert.equal(publicAiProfilesConfig(settings.ai).profiles.every(profile => profile.hasApiKey && !Object.hasOwn(profile, 'apiKey')), true);
|
|
45
|
+
for (const projectId of registry.projectOrder) {
|
|
46
|
+
const config = JSON.parse(fs.readFileSync(layout.getProjectConfigPath(projectId), 'utf8'));
|
|
47
|
+
const legacy = projects[config.legacyExtensions.slug];
|
|
48
|
+
assert.equal(config.repoPath, legacy.repoPath);
|
|
49
|
+
assert.equal(config.knowledgePath, legacy.kbPath);
|
|
50
|
+
}
|
|
51
|
+
assert.equal(fs.readFileSync(path.join(dataDir, 'cache', 'models', 'A', 'B', 'model.onnx'), 'utf8'), 'exact-model-content');
|
|
52
|
+
assert.equal(result.marker.projectCount, 3);
|
|
53
|
+
assert.equal(result.marker.aiProfileCount, 2);
|
|
54
|
+
} finally { fs.rmSync(dataDir, { recursive: true, force: true }); }
|
|
55
|
+
console.log('v4122-upgrade-data-contract-test PASS');
|
|
56
|
+
})().catch(error => { console.error(error.stack || error.message); process.exit(1); });
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// _site/_test/workbench-permission-test.js
|
|
2
|
+
//
|
|
3
|
+
// T14: Claude Workbench permission lifecycle is preserved. The backend
|
|
4
|
+
// already exposes /api/claude/sessions/:id/permission (Allow/Deny) and
|
|
5
|
+
// a permission-mode selector (default/acceptEdits/auto/bypassPermissions/plan).
|
|
6
|
+
// This test verifies:
|
|
7
|
+
// - the permission endpoint is reachable for a real session;
|
|
8
|
+
// - the mode selector is accepted at session start;
|
|
9
|
+
// - Workbench / Workbench chat messages do NOT auto-append Development
|
|
10
|
+
// Conversation events (internal-only contract per I-06 / I-07).
|
|
11
|
+
|
|
12
|
+
const assert = require('assert');
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const os = require('os');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { spawnSync } = require('child_process');
|
|
17
|
+
const { spawnServer } = require('./helpers/spawn-server');
|
|
18
|
+
|
|
19
|
+
const ROOT = path.resolve(__dirname, '..', '..');
|
|
20
|
+
const sitePort = 8010 + (process.pid % 200);
|
|
21
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pk-workbench-' + process.pid + '-'));
|
|
22
|
+
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'pk-workbench-repo-' + process.pid + '-'));
|
|
23
|
+
|
|
24
|
+
function git(args) {
|
|
25
|
+
const result = spawnSync('git', ['-C', repo, ...args], {
|
|
26
|
+
encoding: 'utf8', windowsHide: true,
|
|
27
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
28
|
+
});
|
|
29
|
+
if (result.status !== 0) throw new Error(result.stderr || `git ${args.join(' ')} failed: ${result.status}`);
|
|
30
|
+
return String(result.stdout || '').trim();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function serverFetch(url, init, timeoutMs = 10000) {
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
return { status: response.status, body: text ? JSON.parse(text) : {} };
|
|
40
|
+
} finally {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
(async () => {
|
|
46
|
+
git(['init', '-q', '-b', 'main']);
|
|
47
|
+
git(['config', 'user.email', 'wb@example.local']);
|
|
48
|
+
git(['config', 'user.name', 'WB']);
|
|
49
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# wb\n');
|
|
50
|
+
git(['add', 'README.md']);
|
|
51
|
+
git(['commit', '-q', '-m', 'baseline']);
|
|
52
|
+
const knowledgeRoot = path.join(dataDir, 'knowledge');
|
|
53
|
+
fs.mkdirSync(knowledgeRoot, { recursive: true });
|
|
54
|
+
const server = spawnServer({
|
|
55
|
+
root: ROOT, port: sitePort, dataDir, tag: 'wb',
|
|
56
|
+
extraEnv: { KB_AUTOMATION_FAKE_CLAUDE: '1', KB_EMBEDDING_FAKE: '1', KB_SKIP_MIGRATION: '1' },
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
60
|
+
try { const r = await serverFetch(`http://127.0.0.1:${sitePort}/api/health`); if (r.body.ok) break; } catch {}
|
|
61
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
62
|
+
}
|
|
63
|
+
await serverFetch(`http://127.0.0.1:${sitePort}/api/settings`, {
|
|
64
|
+
method: 'PATCH', headers: { 'content-type': 'application/json' },
|
|
65
|
+
body: JSON.stringify({ knowledge: { rootPath: knowledgeRoot } }),
|
|
66
|
+
});
|
|
67
|
+
await serverFetch(`http://127.0.0.1:${sitePort}/api/ai-profiles`, {
|
|
68
|
+
method: 'PUT', headers: { 'content-type': 'application/json' },
|
|
69
|
+
body: JSON.stringify({
|
|
70
|
+
schema: 'ai-profiles/v1', defaultProfileId: 'fake',
|
|
71
|
+
profiles: [{ id: 'fake', name: 'Fake', enabled: true, vendor: 'anthropic', model: 'fake', apiKeyUpdate: { mode: 'replace', value: 'k' } }],
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
const importR = await serverFetch(`http://127.0.0.1:${sitePort}/api/projects/import`, {
|
|
75
|
+
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
76
|
+
body: JSON.stringify({ localPath: repo, aiProfileId: 'fake' }),
|
|
77
|
+
});
|
|
78
|
+
assert.strictEqual(importR.status, 201, JSON.stringify(importR.body));
|
|
79
|
+
const projectId = importR.body.projectId;
|
|
80
|
+
|
|
81
|
+
// Case 1: permission modes are accepted at session start.
|
|
82
|
+
for (const mode of ['default', 'acceptEdits', 'auto', 'bypassPermissions', 'plan']) {
|
|
83
|
+
const r = await serverFetch(`http://127.0.0.1:${sitePort}/api/claude/sessions`, {
|
|
84
|
+
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
85
|
+
body: JSON.stringify({ projectId, permissionMode: mode }),
|
|
86
|
+
});
|
|
87
|
+
// We only assert the endpoint accepts the request; the Claude CLI
|
|
88
|
+
// binary may not be present, so the session may end up missing/idle.
|
|
89
|
+
assert(r.status === 201 || r.status === 400 || r.status === 503, `unexpected status for mode=${mode}: ${r.status}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Case 2: Workbench messages MUST NOT auto-append Development
|
|
93
|
+
// Conversation events. We snapshot the conversation store via the
|
|
94
|
+
// server API and confirm no Workbench events are present for the
|
|
95
|
+
// freshly imported project.
|
|
96
|
+
const convoR = await serverFetch(`http://127.0.0.1:${sitePort}/api/conversations/projects`, undefined);
|
|
97
|
+
assert.strictEqual(convoR.status, 200);
|
|
98
|
+
// The project MAY appear in the conversation project list because
|
|
99
|
+
// import initializes the Bridge baseline cursor. What matters is
|
|
100
|
+
// that NO Workbench messages were recorded: the bridge cursor at
|
|
101
|
+
// this point is 0 (no events captured), and no turns should exist.
|
|
102
|
+
// We assert by reading the list and confirming the entry's
|
|
103
|
+
// lastCapturedCursor is 0.
|
|
104
|
+
const entry = (convoR.body.projects || []).find(p => p.projectId === projectId);
|
|
105
|
+
if (entry) {
|
|
106
|
+
assert.strictEqual(entry.lastCapturedCursor || 0, 0, 'Bridge cursor must be 0 for a project with no Bridge events');
|
|
107
|
+
}
|
|
108
|
+
} finally {
|
|
109
|
+
server.child.kill();
|
|
110
|
+
await new Promise(resolve => server.child.once('exit', resolve));
|
|
111
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
112
|
+
fs.rmSync(repo, { recursive: true, force: true });
|
|
113
|
+
}
|
|
114
|
+
console.log('workbench-permission-test PASS');
|
|
115
|
+
})().catch(error => {
|
|
116
|
+
console.error(error.stack || error.message);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const ROOT = path.resolve(__dirname, '..', '..');
|
|
6
|
+
const html = fs.readFileSync(path.join(ROOT, 'ui', 'index.html'), 'utf8');
|
|
7
|
+
const css = fs.readFileSync(path.join(ROOT, 'ui', 'app.css'), 'utf8');
|
|
8
|
+
const script = fs.readFileSync(path.join(ROOT, 'ui', 'app.js'), 'utf8');
|
|
9
|
+
|
|
10
|
+
for (const contract of [
|
|
11
|
+
'id="project-list"',
|
|
12
|
+
'id="view-terminal"',
|
|
13
|
+
'id="view-search"',
|
|
14
|
+
'id="view-import"',
|
|
15
|
+
'id="settings-drawer"',
|
|
16
|
+
'data-settings="logs"',
|
|
17
|
+
'id="delete-dialog"',
|
|
18
|
+
]) assert(html.includes(contract), 'missing v13 shell contract: ' + contract);
|
|
19
|
+
|
|
20
|
+
const desktopNav = html.slice(html.indexOf('<aside class="sidebar">'), html.indexOf('</aside>'));
|
|
21
|
+
assert(desktopNav.includes('data-go="terminal"') && desktopNav.includes('data-go="search"') && desktopNav.includes('data-go="import"'));
|
|
22
|
+
assert(!/开发对话|运行记录|系统日志/.test(desktopNav), 'conversation and logs must not be duplicated in main navigation');
|
|
23
|
+
assert(!html.includes('data-install-hook') && !html.includes('data-analyze') && !html.includes('data-simulate'), 'manual Hook/analysis controls are forbidden');
|
|
24
|
+
|
|
25
|
+
// 开发对话已迁移到 ai-coding-event-bridge 模块,设置抽屉不再保留该入口
|
|
26
|
+
assert(!html.includes('data-settings="conversation"') && !html.includes('settings-conversation') && !html.includes('conversation-project'), 'development-conversation settings entry must be absent (moved to event-bridge module)');
|
|
27
|
+
|
|
28
|
+
for (const required of ['logs-date', 'logs-project', 'logs-scope', 'logs-limit', 'logs-search', 'logs-export']) assert(html.includes(`id="${required}"`), 'missing logs toolbar control: ' + required);
|
|
29
|
+
for (const forbidden of ['pause-button', 'level-filter', 'setting-retention', 'setting-capacity', 'health-pill', 'data-log-table']) assert(!html.includes(forbidden), 'legacy logs-only control must be absent: ' + forbidden);
|
|
30
|
+
assert(!/>Level</i.test(html) && !/>级别</i.test(html.slice(html.indexOf('class="record-toolbar"'), html.indexOf('class="record-shell"'))), 'logs toolbar must not expose a level filter/column');
|
|
31
|
+
|
|
32
|
+
assert(css.includes('grid-template-columns:minmax(0,1fr) 88px') && css.includes('grid-template-columns:minmax(0,1fr) 76px'), 'desktop/mobile log row geometry is required');
|
|
33
|
+
assert(css.includes('.record-list{flex:1;min-height:0;max-height:none;overflow-y:auto;overflow-x:hidden}'), 'record list must own logs scrolling');
|
|
34
|
+
assert(!css.includes('max-height:520px'), 'fixed legacy record height is forbidden');
|
|
35
|
+
for (const level of ['warn', 'error', 'fatal']) assert(css.includes(`[data-level="${level}"]`), 'whole-row severity color missing: ' + level);
|
|
36
|
+
assert(css.includes('html[data-theme="dark"]') && css.includes('@media(max-width:760px)'), 'dark and responsive layouts are required');
|
|
37
|
+
|
|
38
|
+
assert(!script.includes('.innerHTML') && !script.includes('insertAdjacentHTML'), 'business data must never render through an HTML sink');
|
|
39
|
+
assert(script.includes('.textContent = record.message') && script.includes('.textContent = value'), 'logs must render as plain text');
|
|
40
|
+
assert(script.includes("stream.addEventListener('logs/appended'") && script.includes('state.newLogs += 1'), 'SSE append/new-record behavior is required');
|
|
41
|
+
assert(script.includes('window.__PK_APP__'), 'browser test surface is required');
|
|
42
|
+
|
|
43
|
+
console.log('workspace UI contract test PASS');
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// _site/lib/ai-profile-resolver.js
|
|
2
|
+
//
|
|
3
|
+
// Single source of truth for "what AI profile does this project use right now".
|
|
4
|
+
// Replaces the inconsistent fallback logic that used to live separately in
|
|
5
|
+
// Workbench start-session / send-input, the analyzer, the CommitReconciler,
|
|
6
|
+
// and import default assignment.
|
|
7
|
+
//
|
|
8
|
+
// Resolution order (per T01):
|
|
9
|
+
// 1. projectConfig.aiProfileId, when it references a usable configured profile
|
|
10
|
+
// 2. settings.ai.defaultProfileId, when it references a usable configured profile
|
|
11
|
+
// 3. first usable configured profile in stable configured order
|
|
12
|
+
// 4. otherwise an explicit AI_PROFILE_REQUIRED failure
|
|
13
|
+
//
|
|
14
|
+
// "Usable" matches the current runtime's minimum contract: the profile exists,
|
|
15
|
+
// is enabled, and references a vendor/implementation that the runtime can use.
|
|
16
|
+
// We do NOT invent additional requirements (e.g. "must have a non-empty apiKey")
|
|
17
|
+
// — that is the runtime's job to evaluate when it actually starts a session.
|
|
18
|
+
|
|
19
|
+
const { DomainError } = require('./contracts');
|
|
20
|
+
|
|
21
|
+
function profileById(settings, profileId) {
|
|
22
|
+
if (!profileId) return null;
|
|
23
|
+
const list = settings && settings.ai && Array.isArray(settings.ai.profiles) ? settings.ai.profiles : [];
|
|
24
|
+
return list.find(profile => profile && profile.id === profileId) || null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isUsable(profile) {
|
|
28
|
+
return Boolean(profile) && profile.enabled !== false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function listUsable(settings) {
|
|
32
|
+
const list = settings && settings.ai && Array.isArray(settings.ai.profiles) ? settings.ai.profiles : [];
|
|
33
|
+
return list.filter(isUsable);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolveEffectiveAiProfile(settings, projectConfig) {
|
|
37
|
+
const safeSettings = settings || { ai: { profiles: [] } };
|
|
38
|
+
const safeProject = projectConfig || {};
|
|
39
|
+
const configured = safeSettings.ai && Array.isArray(safeSettings.ai.profiles) ? safeSettings.ai.profiles : [];
|
|
40
|
+
|
|
41
|
+
const projectId = safeProject.aiProfileId || null;
|
|
42
|
+
if (projectId) {
|
|
43
|
+
const projectProfile = profileById(safeSettings, projectId);
|
|
44
|
+
if (isUsable(projectProfile)) {
|
|
45
|
+
return { profile: projectProfile, profileId: projectProfile.id, source: 'project' };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const defaultId = safeSettings.ai && safeSettings.ai.defaultProfileId || null;
|
|
50
|
+
if (defaultId) {
|
|
51
|
+
const defaultProfile = profileById(safeSettings, defaultId);
|
|
52
|
+
if (isUsable(defaultProfile)) {
|
|
53
|
+
return { profile: defaultProfile, profileId: defaultProfile.id, source: 'default' };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const firstUsable = listUsable(safeSettings)[0];
|
|
58
|
+
if (firstUsable) {
|
|
59
|
+
return { profile: firstUsable, profileId: firstUsable.id, source: 'first-usable' };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new DomainError('AI_PROFILE_REQUIRED', 'A usable AI profile is required for this operation.', {
|
|
63
|
+
status: 409,
|
|
64
|
+
details: {
|
|
65
|
+
hint: 'Configure at least one enabled AI profile, or assign an aiProfileId to the project.',
|
|
66
|
+
configuredProfileCount: configured.length,
|
|
67
|
+
projectProfileId: projectId || null,
|
|
68
|
+
defaultProfileId: defaultId || null,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
resolveEffectiveAiProfile,
|
|
75
|
+
profileById,
|
|
76
|
+
isUsable,
|
|
77
|
+
listUsable,
|
|
78
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Built-in vendor presets for common Anthropic-compatible providers.
|
|
2
|
+
// baseUrl and model names verified against each vendor's public docs (2026-06).
|
|
3
|
+
// When a user picks one of these vendor names in the profile form, all fields
|
|
4
|
+
// below are auto-filled — they only need to supply an API key.
|
|
5
|
+
//
|
|
6
|
+
// baseUrl MUST be the /anthropic-compatible endpoint, not the OpenAI-compatible
|
|
7
|
+
// one, because the runner speaks the Anthropic Messages API. Wrong path → 404.
|
|
8
|
+
const AI_VENDOR_PRESETS = [
|
|
9
|
+
{
|
|
10
|
+
id: 'anthropic',
|
|
11
|
+
name: 'Anthropic Claude',
|
|
12
|
+
baseUrl: 'https://api.anthropic.com',
|
|
13
|
+
mainModel: 'claude-sonnet-4-5',
|
|
14
|
+
thinkingModel: 'claude-opus-4-7',
|
|
15
|
+
haikuModel: 'claude-haiku-4-5',
|
|
16
|
+
sonnetModel: 'claude-sonnet-4-5',
|
|
17
|
+
opusModel: 'claude-opus-4-7',
|
|
18
|
+
contextWindow: 200000,
|
|
19
|
+
website: 'https://www.anthropic.com',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'minimax',
|
|
23
|
+
name: 'MiniMax',
|
|
24
|
+
// Domestic (China) endpoint. minimax.io is the overseas domain with a
|
|
25
|
+
// separate account system — API keys are NOT interchangeable. Domestic
|
|
26
|
+
// users register at minimaxi.com, so we default to that.
|
|
27
|
+
baseUrl: 'https://api.minimaxi.com/anthropic',
|
|
28
|
+
mainModel: 'MiniMax-M3',
|
|
29
|
+
thinkingModel: 'MiniMax-M3',
|
|
30
|
+
haikuModel: 'MiniMax-M3',
|
|
31
|
+
sonnetModel: 'MiniMax-M3',
|
|
32
|
+
opusModel: 'MiniMax-M3',
|
|
33
|
+
contextWindow: 1048576,
|
|
34
|
+
website: 'https://platform.minimaxi.com',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'zhipu',
|
|
38
|
+
name: '智谱 GLM',
|
|
39
|
+
// Anthropic-compatible endpoint, not the OpenAI-style /api/paas/v4.
|
|
40
|
+
baseUrl: 'https://open.bigmodel.cn/api/anthropic',
|
|
41
|
+
mainModel: 'glm-4.6',
|
|
42
|
+
thinkingModel: 'glm-4.6',
|
|
43
|
+
haikuModel: 'glm-4.5-air',
|
|
44
|
+
sonnetModel: 'glm-4.6',
|
|
45
|
+
opusModel: 'glm-4.6',
|
|
46
|
+
contextWindow: 1048576,
|
|
47
|
+
website: 'https://open.bigmodel.cn',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'deepseek',
|
|
51
|
+
name: 'DeepSeek',
|
|
52
|
+
// Anthropic-compatible endpoint at /anthropic, not the bare domain.
|
|
53
|
+
baseUrl: 'https://api.deepseek.com/anthropic',
|
|
54
|
+
mainModel: 'deepseek-chat',
|
|
55
|
+
thinkingModel: 'deepseek-reasoner',
|
|
56
|
+
haikuModel: 'deepseek-chat',
|
|
57
|
+
sonnetModel: 'deepseek-chat',
|
|
58
|
+
opusModel: 'deepseek-reasoner',
|
|
59
|
+
contextWindow: 128000,
|
|
60
|
+
website: 'https://platform.deepseek.com',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
function listVendorPresetNames() {
|
|
65
|
+
return AI_VENDOR_PRESETS.map(v => v.name);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Match by name (case-insensitive) or id (case-insensitive). Returns the
|
|
69
|
+
// preset object or null. Custom vendor names that don't match return null —
|
|
70
|
+
// the caller then leaves the user-typed value alone.
|
|
71
|
+
function findVendorPresetByName(name) {
|
|
72
|
+
const norm = String(name || '').trim().toLowerCase();
|
|
73
|
+
if (!norm) return null;
|
|
74
|
+
return AI_VENDOR_PRESETS.find(v =>
|
|
75
|
+
v.name.toLowerCase() === norm || v.id.toLowerCase() === norm
|
|
76
|
+
) || null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
AI_VENDOR_PRESETS,
|
|
81
|
+
listVendorPresetNames,
|
|
82
|
+
findVendorPresetByName,
|
|
83
|
+
};
|