@tt-a1i/hive 1.4.0 → 1.4.3
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/CHANGELOG.md +39 -0
- package/NOTICE +15 -0
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/TRADEMARK.md +41 -0
- package/dist/src/cli/hive-update.d.ts +3 -0
- package/dist/src/cli/hive-update.js +59 -7
- package/dist/src/server/app.d.ts +2 -1
- package/dist/src/server/app.js +68 -1
- package/dist/src/server/hive-team-guidance.js +1 -0
- package/dist/src/server/marketplace-store.js +21 -5
- package/package.json +3 -1
- package/web/dist/assets/AddWorkerDialog-DmkDOdp6.js +2 -0
- package/web/dist/assets/{AddWorkspaceDialog-DVqabcvo.js → AddWorkspaceDialog-BsVnH3Xe.js} +1 -1
- package/web/dist/assets/{FirstRunWizard-DOM6bcpn.js → FirstRunWizard-SAd1wsH4.js} +1 -1
- package/web/dist/assets/MarketplaceDrawer-B_8aG2uT.js +76 -0
- package/web/dist/assets/WorkerModal-CQmjiPme.js +1 -0
- package/web/dist/assets/WorkspaceTaskDrawer-B0DmCWcV.js +1 -0
- package/web/dist/assets/WorkspaceTerminalPanels-BReWh1YL.js +1 -0
- package/web/dist/assets/WorkspaceTerminalPanels-DDGTF8rc.css +1 -0
- package/web/dist/assets/{chevron-right-39MYBReb.js → chevron-right-CtLjVEl7.js} +1 -1
- package/web/dist/assets/index-BEsTmfrO.css +1 -0
- package/web/dist/assets/index-Cn8X3get.js +76 -0
- package/web/dist/bilibili.ico +0 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/AddWorkerDialog-TAWWMQti.js +0 -75
- package/web/dist/assets/WorkerModal-ALxWif7E.js +0 -1
- package/web/dist/assets/WorkspaceTaskDrawer-8IVJMUe-.js +0 -1
- package/web/dist/assets/index-7NLKrr1z.js +0 -81
- package/web/dist/assets/index-DsdHICGY.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
All notable user-facing changes will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 1.4.3 - 2026-05-28
|
|
6
|
+
|
|
7
|
+
Update hardening for multi-Node installs.
|
|
8
|
+
|
|
9
|
+
- Fixes `hive update` on machines with multiple global npm prefixes. Hive now
|
|
10
|
+
updates the same npm prefix as the currently running `hive` binary, avoiding
|
|
11
|
+
cases where npm installs a new copy elsewhere while PATH still resolves an
|
|
12
|
+
older copy with stale native dependencies.
|
|
13
|
+
- Updates the `hive update --help` copy to explain how custom npm prefixes are
|
|
14
|
+
handled.
|
|
15
|
+
|
|
16
|
+
## 1.4.2 - 2026-05-27
|
|
17
|
+
|
|
18
|
+
Demo video, worker naming, and small UI polish.
|
|
19
|
+
|
|
20
|
+
- Adds a Bilibili demo video entry to the sidebar footer and replaces the demo
|
|
21
|
+
workspace mockup with the actual demo video embed.
|
|
22
|
+
- Links the Hive logo and version in the topbar to `hivehq.dev`.
|
|
23
|
+
- Uses role glyph avatars for workers instead of two-letter placeholders.
|
|
24
|
+
- Auto-fills a generated worker name when the Add Member dialog opens and
|
|
25
|
+
prevents the name from regenerating while the dialog stays open.
|
|
26
|
+
- Trims random worker-name pools to well-known figures for clearer,
|
|
27
|
+
localized names.
|
|
28
|
+
- Improves the empty Tasks panel with a stronger add-task call to action.
|
|
29
|
+
- Serves the sidebar Bilibili icon from a packaged static asset instead of an
|
|
30
|
+
inline data URL.
|
|
31
|
+
|
|
32
|
+
## 1.4.1 - 2026-05-26
|
|
33
|
+
|
|
34
|
+
Private release-source housekeeping.
|
|
35
|
+
|
|
36
|
+
- Keeps the packaged product release train on the private release-source
|
|
37
|
+
repository.
|
|
38
|
+
- Adds attribution and trademark notices to the packaged npm tarball.
|
|
39
|
+
- Documents the private/public repository split so future release work does
|
|
40
|
+
not accidentally expose internal implementation notes or unreleased product
|
|
41
|
+
work.
|
|
42
|
+
- Stabilizes the manual startup-command smoke test under full-suite PTY load.
|
|
43
|
+
|
|
5
44
|
## 1.4.0 - 2026-05-22
|
|
6
45
|
|
|
7
46
|
Template marketplace and agent picker polish.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Hive
|
|
2
|
+
Copyright (c) 2026 Shaokun Tu (tt-a1i) and contributors.
|
|
3
|
+
|
|
4
|
+
This product includes software licensed under the Business Source License 1.1.
|
|
5
|
+
See LICENSE.BSL for the source license and LICENSE for historical Apache-2.0
|
|
6
|
+
terms that apply only to versions covered by that file.
|
|
7
|
+
|
|
8
|
+
Redistributions, forks, and modified versions must preserve this notice and
|
|
9
|
+
the applicable license files. The Hive name, logo, and visual identity are
|
|
10
|
+
covered by the trademark guidelines in TRADEMARK.md and are not granted by the
|
|
11
|
+
source license.
|
|
12
|
+
|
|
13
|
+
Hive includes optional marketplace prompt snapshots from third-party projects.
|
|
14
|
+
Their upstream license files are preserved under the packaged vendor
|
|
15
|
+
marketplace directories when those snapshots are included in a release.
|
package/README.en.md
CHANGED
|
@@ -365,4 +365,6 @@ Upstream content is mirrored verbatim, license files are kept under `vendor/mark
|
|
|
365
365
|
|
|
366
366
|
## License
|
|
367
367
|
|
|
368
|
-
Hive is
|
|
368
|
+
Hive source is available under the Business Source License 1.1. Personal use, internal deployment, embedding, and forks are permitted — see [LICENSE.BSL](LICENSE.BSL) for the exact boundary.
|
|
369
|
+
|
|
370
|
+
Forks and redistributions must preserve [NOTICE](NOTICE), [LICENSE.BSL](LICENSE.BSL), and the applicable license files. The Hive name, logo, and visual identity are not licensed by the source license; see [TRADEMARK.md](TRADEMARK.md) for brand usage boundaries.
|
package/README.md
CHANGED
|
@@ -278,4 +278,6 @@ Hive 的"模板市场"内置了两份社区角色 prompt 库的快照,两份
|
|
|
278
278
|
|
|
279
279
|
## License
|
|
280
280
|
|
|
281
|
-
Hive
|
|
281
|
+
Hive 源码在 Business Source License 1.1 下提供。个人使用、内部部署、嵌入、fork 都可以;详细边界见 [LICENSE.BSL](LICENSE.BSL)。
|
|
282
|
+
|
|
283
|
+
Fork 或再分发版本必须保留 [NOTICE](NOTICE)、[LICENSE.BSL](LICENSE.BSL) 和相关许可证文件。Hive 名称、logo 和视觉识别不随源码许可证授权;品牌使用边界见 [TRADEMARK.md](TRADEMARK.md)。
|
package/TRADEMARK.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Trademark Guidelines
|
|
2
|
+
|
|
3
|
+
These guidelines apply to the Hive name, logo, icons, visual identity, and
|
|
4
|
+
other brand assets owned by Shaokun Tu (tt-a1i).
|
|
5
|
+
|
|
6
|
+
The source license for Hive grants rights to use, modify, and distribute the
|
|
7
|
+
software under the terms of LICENSE.BSL. It does not grant trademark rights.
|
|
8
|
+
|
|
9
|
+
## Permitted Uses
|
|
10
|
+
|
|
11
|
+
You may:
|
|
12
|
+
|
|
13
|
+
- Refer to Hive by name when describing compatibility, attribution, or that a
|
|
14
|
+
project is based on Hive.
|
|
15
|
+
- Use phrases such as "forked from Hive", "based on Hive", or "compatible with
|
|
16
|
+
Hive" when the relationship is accurate.
|
|
17
|
+
- Link to the upstream Hive repository and documentation.
|
|
18
|
+
|
|
19
|
+
## Uses That Need Permission
|
|
20
|
+
|
|
21
|
+
You need prior written permission to:
|
|
22
|
+
|
|
23
|
+
- Use the Hive name, logo, or icons as the primary name or identity of a fork,
|
|
24
|
+
distribution, hosted service, or commercial product.
|
|
25
|
+
- Present a fork or derivative work in a way that suggests it is official,
|
|
26
|
+
endorsed, sponsored, or maintained by tt-a1i.
|
|
27
|
+
- Register domains, social accounts, packages, apps, or marketplaces names that
|
|
28
|
+
are likely to confuse users about whether they are official Hive properties.
|
|
29
|
+
- Use Hive brand assets in paid advertising, product packaging, or hosted
|
|
30
|
+
service branding.
|
|
31
|
+
|
|
32
|
+
## Forks And Derivative Products
|
|
33
|
+
|
|
34
|
+
Forks should use a distinct product name and distinct visual identity. They
|
|
35
|
+
must preserve the applicable license files and NOTICE file, and should clearly
|
|
36
|
+
state that they are independent from upstream Hive unless a separate written
|
|
37
|
+
agreement says otherwise.
|
|
38
|
+
|
|
39
|
+
These guidelines do not change the software license. If there is a conflict
|
|
40
|
+
between this document and LICENSE.BSL, LICENSE.BSL controls software license
|
|
41
|
+
rights and this document controls brand usage.
|
|
@@ -5,11 +5,14 @@ export interface RunUpdateResult {
|
|
|
5
5
|
}
|
|
6
6
|
export type RunUpdate = (command: string, args: readonly string[]) => Promise<RunUpdateResult>;
|
|
7
7
|
export declare const defaultRunUpdate: RunUpdate;
|
|
8
|
+
export declare const resolveHiveUpdateInstallArgs: (moduleUrl?: string) => string[];
|
|
8
9
|
interface RunHiveUpdateOptions {
|
|
9
10
|
/** Inject a fake spawn for tests. */
|
|
10
11
|
runUpdate?: RunUpdate;
|
|
11
12
|
/** Override platform detection for tests. */
|
|
12
13
|
platform?: NodeJS.Platform;
|
|
14
|
+
/** Override the current module URL for install-prefix detection in tests. */
|
|
15
|
+
moduleUrl?: string;
|
|
13
16
|
}
|
|
14
17
|
export declare const runHiveUpdateCommand: (argv: string[], options?: RunHiveUpdateOptions) => Promise<number>;
|
|
15
18
|
export {};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { getNpmCommand, INSTALL_COMMAND_ARGS, INSTALL_COMMAND_DISPLAY, PACKAGE_NAME, } from '../server/package-version.js';
|
|
3
6
|
export const HIVE_UPDATE_USAGE = [
|
|
4
7
|
'Usage:',
|
|
5
8
|
' hive update',
|
|
6
9
|
'',
|
|
7
10
|
`Runs \`${INSTALL_COMMAND_DISPLAY}\` to upgrade Hive in place.`,
|
|
11
|
+
'When Hive was installed under a custom npm prefix, the update is applied',
|
|
12
|
+
'to that same prefix so the `hive` on your PATH actually changes.',
|
|
8
13
|
'Restart any running Hive process afterwards to pick up the new version.',
|
|
9
14
|
'',
|
|
10
15
|
'Note: only npm-installed Hive can be upgraded this way. If you installed',
|
|
@@ -44,9 +49,54 @@ export const defaultRunUpdate = (command, args) => new Promise((resolve) => {
|
|
|
44
49
|
finalize({ exitCode: typeof code === 'number' ? code : 1 });
|
|
45
50
|
});
|
|
46
51
|
});
|
|
47
|
-
const
|
|
48
|
-
|
|
52
|
+
const shellQuote = (value) => {
|
|
53
|
+
if (/^[A-Za-z0-9_/:=.,@+-]+$/.test(value))
|
|
54
|
+
return value;
|
|
55
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
49
56
|
};
|
|
57
|
+
const findPackageRoot = (moduleUrl) => {
|
|
58
|
+
let dir = dirname(fileURLToPath(moduleUrl));
|
|
59
|
+
for (let depth = 0; depth < 12; depth += 1) {
|
|
60
|
+
const candidate = join(dir, 'package.json');
|
|
61
|
+
if (existsSync(candidate)) {
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(readFileSync(candidate, 'utf8'));
|
|
64
|
+
if (parsed.name === PACKAGE_NAME)
|
|
65
|
+
return dir;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Keep walking. A malformed unrelated package.json should not break update.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const parent = dirname(dir);
|
|
72
|
+
if (parent === dir)
|
|
73
|
+
return undefined;
|
|
74
|
+
dir = parent;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
};
|
|
78
|
+
const findPrefixFromPackageRoot = (packageRoot) => {
|
|
79
|
+
let dir = packageRoot;
|
|
80
|
+
for (let depth = 0; depth < 8; depth += 1) {
|
|
81
|
+
if (basename(dir) === 'node_modules') {
|
|
82
|
+
const parent = dirname(dir);
|
|
83
|
+
return basename(parent) === 'lib' ? dirname(parent) : parent;
|
|
84
|
+
}
|
|
85
|
+
const parent = dirname(dir);
|
|
86
|
+
if (parent === dir)
|
|
87
|
+
return undefined;
|
|
88
|
+
dir = parent;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
};
|
|
92
|
+
export const resolveHiveUpdateInstallArgs = (moduleUrl = import.meta.url) => {
|
|
93
|
+
const packageRoot = findPackageRoot(moduleUrl);
|
|
94
|
+
const prefix = packageRoot ? findPrefixFromPackageRoot(packageRoot) : undefined;
|
|
95
|
+
if (!prefix)
|
|
96
|
+
return [...INSTALL_COMMAND_ARGS];
|
|
97
|
+
return [...INSTALL_COMMAND_ARGS, '--prefix', prefix];
|
|
98
|
+
};
|
|
99
|
+
const formatInstallCommand = (args) => `npm ${args.map(shellQuote).join(' ')}`;
|
|
50
100
|
export const runHiveUpdateCommand = async (argv, options = {}) => {
|
|
51
101
|
if (argv.includes('--help') || argv.includes('-h')) {
|
|
52
102
|
console.log(HIVE_UPDATE_USAGE);
|
|
@@ -62,11 +112,13 @@ export const runHiveUpdateCommand = async (argv, options = {}) => {
|
|
|
62
112
|
}
|
|
63
113
|
const run = options.runUpdate ?? defaultRunUpdate;
|
|
64
114
|
const command = getNpmCommand(options.platform);
|
|
65
|
-
|
|
66
|
-
const
|
|
115
|
+
const args = resolveHiveUpdateInstallArgs(options.moduleUrl);
|
|
116
|
+
const displayCommand = formatInstallCommand(args);
|
|
117
|
+
console.log(`Running: ${displayCommand}`);
|
|
118
|
+
const result = await run(command, args);
|
|
67
119
|
if (result.spawnError) {
|
|
68
120
|
console.error(`Failed to spawn npm: ${result.spawnError.message}`);
|
|
69
|
-
|
|
121
|
+
console.error(`You can run the upgrade manually: ${displayCommand}`);
|
|
70
122
|
return 1;
|
|
71
123
|
}
|
|
72
124
|
if (result.exitCode === 0) {
|
|
@@ -76,6 +128,6 @@ export const runHiveUpdateCommand = async (argv, options = {}) => {
|
|
|
76
128
|
console.error(`npm install exited with code ${result.exitCode}.`);
|
|
77
129
|
// Permission failures (EACCES on root-owned /usr/bin/npm) and other
|
|
78
130
|
// non-spawn errors leave the user with copy-paste recovery either way.
|
|
79
|
-
|
|
131
|
+
console.error(`You can run the upgrade manually: ${displayCommand}`);
|
|
80
132
|
return result.exitCode;
|
|
81
133
|
};
|
package/dist/src/server/app.d.ts
CHANGED
|
@@ -8,10 +8,11 @@ interface CreateAppOptions {
|
|
|
8
8
|
store: RuntimeStore;
|
|
9
9
|
pickFolderService?: () => Promise<PickFolderResponse>;
|
|
10
10
|
openWorkspaceService?: OpenWorkspaceService;
|
|
11
|
+
packageVersionReader?: () => string;
|
|
11
12
|
tasksFileService?: TasksFileService;
|
|
12
13
|
versionService?: VersionService;
|
|
13
14
|
}
|
|
14
|
-
export declare const createApp: ({ store, pickFolderService, openWorkspaceService, tasksFileService, versionService, }: CreateAppOptions) => {
|
|
15
|
+
export declare const createApp: ({ store, pickFolderService, openWorkspaceService, packageVersionReader, tasksFileService, versionService, }: CreateAppOptions) => {
|
|
15
16
|
server: import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
|
|
16
17
|
store: RuntimeStore;
|
|
17
18
|
};
|
package/dist/src/server/app.js
CHANGED
|
@@ -7,6 +7,7 @@ import { pickFolder } from './fs-pick-folder.js';
|
|
|
7
7
|
import { HttpError } from './http-errors.js';
|
|
8
8
|
import { assertLocalRequest } from './local-request-guard.js';
|
|
9
9
|
import { openWorkspace } from './open-target-commands.js';
|
|
10
|
+
import { readPackageVersion } from './package-version.js';
|
|
10
11
|
import { matchRoute } from './routes.js';
|
|
11
12
|
import { createTasksFileService } from './tasks-file.js';
|
|
12
13
|
import { createTerminalWebSocketServer } from './terminal-ws-server.js';
|
|
@@ -87,8 +88,64 @@ const sendJson = (response, statusCode, body) => {
|
|
|
87
88
|
response.setHeader('content-type', 'application/json; charset=utf-8');
|
|
88
89
|
response.end(JSON.stringify(body));
|
|
89
90
|
};
|
|
90
|
-
|
|
91
|
+
const escapeHtml = (value) => value
|
|
92
|
+
.replaceAll('&', '&')
|
|
93
|
+
.replaceAll('<', '<')
|
|
94
|
+
.replaceAll('>', '>')
|
|
95
|
+
.replaceAll('"', '"')
|
|
96
|
+
.replaceAll("'", ''');
|
|
97
|
+
const createVersionMismatchBody = (runtimeVersion, installedVersion) => `<!doctype html>
|
|
98
|
+
<html lang="en">
|
|
99
|
+
<head>
|
|
100
|
+
<meta charset="utf-8" />
|
|
101
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
102
|
+
<title>Restart Hive</title>
|
|
103
|
+
<style>
|
|
104
|
+
:root { color-scheme: dark; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
105
|
+
body { align-items: center; background: #0d0f12; color: #f4f4f5; display: flex; justify-content: center; margin: 0; min-height: 100vh; }
|
|
106
|
+
main { border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: #17191d; box-shadow: 0 18px 64px rgba(0,0,0,.4); max-width: 520px; padding: 28px; }
|
|
107
|
+
h1 { font-size: 22px; line-height: 1.2; margin: 0 0 10px; }
|
|
108
|
+
p { color: #a1a1aa; font-size: 14px; line-height: 1.6; margin: 0 0 14px; }
|
|
109
|
+
code { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); border-radius: 6px; color: #e5e7eb; padding: 2px 6px; }
|
|
110
|
+
</style>
|
|
111
|
+
</head>
|
|
112
|
+
<body>
|
|
113
|
+
<main>
|
|
114
|
+
<h1>Restart Hive</h1>
|
|
115
|
+
<p>Hive was updated on disk while this runtime process was still running.</p>
|
|
116
|
+
<p>Running runtime: <code>${escapeHtml(runtimeVersion)}</code><br />Installed package: <code>${escapeHtml(installedVersion)}</code></p>
|
|
117
|
+
<p>Stop the current <code>hive</code> process and start it again to load the new UI and API together.</p>
|
|
118
|
+
</main>
|
|
119
|
+
</body>
|
|
120
|
+
</html>`;
|
|
121
|
+
const readVersionMismatch = (runtimeVersion, packageVersionReader) => {
|
|
122
|
+
const installedVersion = packageVersionReader();
|
|
123
|
+
if (runtimeVersion === 'unknown' ||
|
|
124
|
+
installedVersion === 'unknown' ||
|
|
125
|
+
installedVersion === runtimeVersion) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return { installedVersion, runtimeVersion };
|
|
129
|
+
};
|
|
130
|
+
const sendVersionMismatchJson = (response, mismatch) => {
|
|
131
|
+
sendJson(response, 409, {
|
|
132
|
+
code: 'runtime_version_mismatch',
|
|
133
|
+
current_version: mismatch.runtimeVersion,
|
|
134
|
+
error: 'Hive was updated on disk. Restart the running hive process to use the new version.',
|
|
135
|
+
installed_version: mismatch.installedVersion,
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const sendVersionMismatchPage = (response, request, mismatch) => {
|
|
139
|
+
response.statusCode = 409;
|
|
140
|
+
response.setHeader('content-type', 'text/html; charset=utf-8');
|
|
141
|
+
response.setHeader('cache-control', 'no-store');
|
|
142
|
+
response.end(request.method === 'HEAD'
|
|
143
|
+
? undefined
|
|
144
|
+
: createVersionMismatchBody(mismatch.runtimeVersion, mismatch.installedVersion));
|
|
145
|
+
};
|
|
146
|
+
export const createApp = ({ store, pickFolderService = pickFolder, openWorkspaceService = (input) => openWorkspace(input), packageVersionReader = readPackageVersion, tasksFileService = createTasksFileService(), versionService = createVersionService(), }) => {
|
|
91
147
|
const staticDir = process.env.HIVE_STATIC_DIR ?? getDefaultStaticDir();
|
|
148
|
+
const runtimeVersion = packageVersionReader();
|
|
92
149
|
const staticAvailablePromise = canServeStatic(staticDir);
|
|
93
150
|
const server = createServer(async (request, response) => {
|
|
94
151
|
const method = request.method ?? 'GET';
|
|
@@ -110,10 +167,20 @@ export const createApp = ({ store, pickFolderService = pickFolder, openWorkspace
|
|
|
110
167
|
return;
|
|
111
168
|
}
|
|
112
169
|
if (isReservedPath(url.pathname)) {
|
|
170
|
+
const mismatch = readVersionMismatch(runtimeVersion, packageVersionReader);
|
|
171
|
+
if (mismatch) {
|
|
172
|
+
sendVersionMismatchJson(response, mismatch);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
113
175
|
sendJson(response, 404, { error: 'Not found' });
|
|
114
176
|
return;
|
|
115
177
|
}
|
|
116
178
|
if (await staticAvailablePromise) {
|
|
179
|
+
const mismatch = readVersionMismatch(runtimeVersion, packageVersionReader);
|
|
180
|
+
if (mismatch) {
|
|
181
|
+
sendVersionMismatchPage(response, request, mismatch);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
117
184
|
const served = await sendStatic(response, staticDir, url.pathname, request);
|
|
118
185
|
if (served)
|
|
119
186
|
return;
|
|
@@ -31,6 +31,7 @@ const ORCHESTRATOR_RULES = [
|
|
|
31
31
|
'普通、低风险、几分钟内能直接完成的小任务可以自己做;不要为了形式感派 worker。需要并行、长时间执行、独立 review/test、专门角色,或 user 明确要求 worker/成员处理时,再用 `team send`。',
|
|
32
32
|
'如果只有一个可用 worker,直接用 `team send <worker-name> "<task>"` 派给它;不要把选择题丢回给 user。',
|
|
33
33
|
'当 user 要你“让 worker ...”时,必须用 `team send <worker-name> "<task>"` 派给 Hive worker。',
|
|
34
|
+
'派单时如果任务明显需要某种角色能力(例如代码评审、测试、安全审查),但 `team list` 中没有匹配 role 的成员,可以在回复 user 的自然语言部分(而非 `team send` 的任务正文)末尾用一句话建议添加该角色,例如:“如果这类任务后续会变多,可以考虑添加一个 reviewer”。仅在明显缺失时提;同一缺口在 user 未响应前不要重复建议。',
|
|
34
35
|
'方向变更或 user 明确取消某个未完成派单时,使用 `team cancel --dispatch <id> "<reason>"` 显式关闭旧 dispatch;不要只用自然语言说“取消”。',
|
|
35
36
|
'不要使用你所在 CLI 的内置 subagent / 子代理工具(如 Task / Explore 等)来代替 Hive worker;它们不会出现在 Hive UI,也不会更新 Hive 调度状态。',
|
|
36
37
|
'`team list` 返回的 `last_pty_line` 是该 worker PTY 终端的最后一行原始输出(含任意 stdout / help / 控制序列噪声),**不是** worker 的正式汇报。正式汇报只来自 stdin 注入的 `[Hive 系统消息:来自 @<name> 的汇报]` 或 `[Hive 系统消息:来自 @<name> 的状态更新]`——只把这两种来源当作 reply。',
|
|
@@ -32,20 +32,30 @@ export const getMarketplaceVendorRoot = () => {
|
|
|
32
32
|
const override = process.env.HIVE_MARKETPLACE_VENDOR_ROOT;
|
|
33
33
|
return override && override.length > 0 ? resolve(override) : defaultVendorRoot();
|
|
34
34
|
};
|
|
35
|
-
const languageRoot = (language) => resolve(
|
|
35
|
+
const languageRoot = (language, vendorRoot = getMarketplaceVendorRoot()) => resolve(vendorRoot, language);
|
|
36
|
+
const manifestCache = new Map();
|
|
37
|
+
const agentCache = new Map();
|
|
36
38
|
export const loadManifest = (language) => {
|
|
37
|
-
const
|
|
39
|
+
const vendorRoot = getMarketplaceVendorRoot();
|
|
40
|
+
const cacheKey = `${vendorRoot}\0${language}`;
|
|
41
|
+
const cached = manifestCache.get(cacheKey);
|
|
42
|
+
if (cached)
|
|
43
|
+
return cached;
|
|
44
|
+
const manifestPath = resolve(languageRoot(language, vendorRoot), 'manifest.json');
|
|
38
45
|
if (!existsSync(manifestPath)) {
|
|
39
46
|
throw new MarketplaceNotFoundError(`Marketplace manifest missing for language: ${language}`);
|
|
40
47
|
}
|
|
41
48
|
const raw = readFileSync(manifestPath, 'utf8');
|
|
42
|
-
|
|
49
|
+
const manifest = JSON.parse(raw);
|
|
50
|
+
manifestCache.set(cacheKey, manifest);
|
|
51
|
+
return manifest;
|
|
43
52
|
};
|
|
44
53
|
export const readAgent = (language, relativePath) => {
|
|
45
54
|
if (!relativePath.endsWith('.md')) {
|
|
46
55
|
throw new MarketplaceNotFoundError(`Marketplace agent path must end with .md: ${relativePath}`);
|
|
47
56
|
}
|
|
48
|
-
const
|
|
57
|
+
const vendorRoot = getMarketplaceVendorRoot();
|
|
58
|
+
const root = languageRoot(language, vendorRoot);
|
|
49
59
|
const candidate = resolve(root, relativePath);
|
|
50
60
|
if (!isPathWithinRoot(root, candidate)) {
|
|
51
61
|
throw new MarketplaceNotFoundError(`Marketplace agent path escapes language root: ${relativePath}`);
|
|
@@ -59,11 +69,17 @@ export const readAgent = (language, relativePath) => {
|
|
|
59
69
|
if (!statSync(candidate).isFile()) {
|
|
60
70
|
throw new MarketplaceNotFoundError(`Marketplace agent not a file: ${language}/${relativePath}`);
|
|
61
71
|
}
|
|
72
|
+
const cacheKey = `${vendorRoot}\0${language}\0${relativePath}`;
|
|
73
|
+
const cached = agentCache.get(cacheKey);
|
|
74
|
+
if (cached)
|
|
75
|
+
return cached;
|
|
62
76
|
const raw = readFileSync(candidate, 'utf8');
|
|
63
77
|
const parsed = matter(raw);
|
|
64
|
-
|
|
78
|
+
const detail = {
|
|
65
79
|
path: relativePath,
|
|
66
80
|
frontmatter: parsed.data,
|
|
67
81
|
body: parsed.content,
|
|
68
82
|
};
|
|
83
|
+
agentCache.set(cacheKey, detail);
|
|
84
|
+
return detail;
|
|
69
85
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tt-a1i/hive",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Browser-native hive-mind for CLI coding agents — Claude Code, Codex, Gemini, and OpenCode collaborate as real PTY processes via a team protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.30.3",
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
"CHANGELOG.md",
|
|
32
32
|
"LICENSE",
|
|
33
33
|
"LICENSE.BSL",
|
|
34
|
+
"NOTICE",
|
|
34
35
|
"README.md",
|
|
35
36
|
"README.en.md",
|
|
36
37
|
"SECURITY.md",
|
|
38
|
+
"TRADEMARK.md",
|
|
37
39
|
"dist/bin/",
|
|
38
40
|
"dist/src/",
|
|
39
41
|
"dist/vendor/",
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-B_8aG2uT.js","assets/index-Cn8X3get.js","assets/index-BEsTmfrO.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as W,j as e,u as j,r as c,e as z,i as M,m as X,z as Y,A as Z,B as R,F as ee,G as te,a as ae,P as re,O as se,C as ne,b as le,D as oe,d as ie,_ as de}from"./index-Cn8X3get.js";const ce=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ue=W("bookmark-plus",ce);const xe=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],me=W("dices",xe);const pe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],he=W("search",pe);const fe=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],be=W("square-terminal",fe);const ge=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],ke=W("store",ge),ve=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],F=t=>`role.${t}`,C=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),je=({active:t,spec:a,onSelect:l})=>{const{t:n}=j();return e.jsxs("button",{type:"button",onClick:l,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(R,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:n(F(a.value))}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},ye=({onRoleChange:t,workerRole:a})=>{const{t:l}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:l("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(n=>e.jsx(je,{active:a===n.value,spec:n,onSelect:()=>t(n.value)},n.value))})]})},Ne=({customTemplates:t,disabledReason:a,onDeleteTemplate:l,onSelect:n,selectedTemplateId:i})=>{const{t:o}=j(),[f,x]=c.useState(!1),[m,u]=c.useState(""),[b,k]=c.useState(null),y=c.useRef(null),g=c.useMemo(()=>t.find(r=>r.id===i)??null,[t,i]),v=c.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(s=>s.name.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)):t},[t,m]);return c.useEffect(()=>{if(!f)return;const r=h=>{h.key==="Escape"&&x(!1)},s=h=>{const w=y.current;w&&!w.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",s),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",s)}},[f]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":f,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:g?g.name:o("addWorker.templatePickPlaceholder")}),e.jsx(z,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),f?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(he,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const s=r.id===i;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":s,"data-testid":`role-template-option-${r.id}`,onClick:()=>{n(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:s?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(X,{size:14,"aria-hidden":!0})})]},r.id)})}),i!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{n(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),l(r)}})]})},Ce=({canSaveAsTemplate:t,modified:a,onChange:l,onReset:n,onSaveAsTemplate:i,roleDescription:o,templateBusy:f,workerRole:x,writeDisabledReason:m})=>{const{t:u}=j(),[b,k]=c.useState(!1),[y,g]=c.useState(!1),[v,r]=c.useState("");return c.useEffect(()=>{(x==="custom"||a)&&k(!0)},[a,x]),c.useEffect(()=>{t||(g(!1),r(""))},[t]),e.jsxs("details",{open:b,onToggle:s=>k(s.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-sm text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(F(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-1",children:[t&&!y?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:s=>{s.preventDefault(),s.stopPropagation(),g(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ue,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:s=>{s.preventDefault(),s.stopPropagation(),n()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:s=>l(s.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:v,onChange:s=>r(s.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:f||!v.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const s=v.trim();if(s)try{await i(s),g(!1),r("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{g(!1),r("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:l,logoPresetId:n,notFound:i=!1,testId:o,onSelect:f})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(be,{size:13})});return e.jsxs("button",{type:"button",onClick:f,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(ee,{commandPresetId:n,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:l}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,i?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},We=({active:t,preset:a,onSelect:l})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:l}),we=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>e.jsx(Se,{commandPresetId:t,commandPresets:a,onPresetChange:l}),Se=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:n("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:n("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.map(i=>e.jsx(We,{active:t===i.id,preset:i,onSelect:()=>l(i.id)},i.id)),e.jsx(D,{active:t==="",command:n("addWorker.genericCommand"),displayName:n("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>l("")})]})]})},ze=({onChange:t,value:a})=>{const{t:l}=j(),n=a.trim();return e.jsxs("details",{className:"group flex flex-col gap-2",children:[e.jsx("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 shrink-0 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:l("addWorker.startupCommand")}),n?e.jsxs("span",{className:"truncate text-sm text-ter",children:["· ",l("addWorker.startupOverrides")]}):null]})}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:i=>t(i.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:l("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Me=c.lazy(()=>de(()=>import("./MarketplaceDrawer-B_8aG2uT.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:l=!1,customTemplates:n,onApplyMarketplaceImport:i,onClose:o,onDeleteTemplate:f,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:g,onStartupCommandChange:v,onSubmit:r,onTemplateChange:s,roleDescription:h,roleDescriptionDefault:w,selectedTemplateId:_,startupCommand:P,templateBusy:I,workerName:A,workerRole:S,writeDisabledReason:N})=>{const{t:d}=j(),L=te(),[B,O]=c.useState(!1),[q,H]=c.useState(!1),K=c.useMemo(()=>new Set(n.map(p=>p.name)),[n]),V=p=>{i(p),L.show({kind:"success",message:d("marketplace.imported",{name:p.name})})},G=p=>{p||o()},Q=h!==w,E=t.find(p=>p.id===a),$=P.trim(),J=()=>N||(A.trim()?!a&&!$?d("addWorker.pickCliOrStartup"):E?.available===!1&&!$?d("addWorker.unavailable",{name:E.displayName}):h.trim()?null:d("addWorker.emptyInstructions"):d("addWorker.enterName")),U=p=>{const T=J();if(T){p.preventDefault(),L.show({kind:"warning",message:T});return}r(p)};return e.jsxs(ae,{open:!0,onOpenChange:G,children:[e.jsxs(re,{children:[e.jsx(se,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ne,{"data-testid":"add-worker-content",className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:e.jsxs("form",{onSubmit:U,"aria-label":d("addWorker.title"),className:"flex flex-col",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx(le,{className:"text-lg font-semibold text-pri",children:d("addWorker.title")}),e.jsx(oe,{className:"text-sm text-ter",children:d("addWorker.description",{command:"team send"})})]}),e.jsxs("div",{className:"flex flex-col gap-4 overflow-y-auto px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(C,{children:d("addWorker.name")}),e.jsx(ie,{label:d("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":d("addWorker.randomAria"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(me,{size:12,"aria-hidden":!0}),d("addWorker.random")]})})]}),e.jsx("input",{autoFocus:!0,value:A,onChange:p=>x(p.target.value),placeholder:d("addWorker.namePlaceholder"),className:"input"})]}),e.jsx(ye,{workerRole:S,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{H(!0),O(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-md border px-3 py-1.5 text-xs text-sec outline-none transition-colors focus-visible:ring-2",style:{background:"var(--bg-0)",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(ke,{size:14,"aria-hidden":!0}),d("marketplace.openFromAddWorker")]}),S==="custom"?e.jsx(Ne,{customTemplates:n,disabledReason:N,onDeleteTemplate:f,onSelect:s,selectedTemplateId:_}):null,e.jsx(Ce,{canSaveAsTemplate:S==="custom"&&!_&&h.trim().length>0,modified:Q,onChange:b,onReset:k,onSaveAsTemplate:g,roleDescription:h,templateBusy:I,workerRole:S,writeDisabledReason:N}),e.jsx(we,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(ze,{value:P,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:"icon-btn","data-testid":"add-worker-cancel",children:d("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:l||!!N,title:N??void 0,className:"icon-btn icon-btn--primary","data-testid":"add-worker-submit",children:d(l?"addWorker.creating":"addWorker.create")})]})]})})})]}),q?e.jsx(c.Suspense,{fallback:null,children:e.jsx(Me,{open:B,onClose:()=>O(!1),onImport:V,importedNames:K})}):null]})},Ae=Object.freeze(Object.defineProperty({__proto__:null,AddWorkerDialog:_e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,he as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as V,u as D,r as c,j as e,i as se,C as A,e as Z,k as T,m as I,O as q,n as U,o as W,q as K,s as ae,t as re,v as ne,X as ce,w as le,x as oe,T as ie}from"./index-7NLKrr1z.js";import{C as L}from"./chevron-right-39MYBReb.js";const de=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],pe=V("arrow-up",de);const xe=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],ue=V("folder-search",xe);const me=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",me);const he=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Q=V("git-branch",he),ee=({error:t,onChange:o,presets:p,value:a})=>{const{t:i}=D(),[d,r]=c.useState(!1),s=c.useRef(null),u=p.find(l=>l.id===a),n=a==="",k=u?[u.command,...u.args].join(" ").trim():i(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=u?.displayName??(n?i("workspace.preset.generic"):"Claude Code (CC)"),j=p.length===0&&!n;return c.useEffect(()=>{if(!d)return;const l=f=>{s.current?.contains(f.target)||r(!1)},m=f=>{f.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m)}},[d]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:i("workspace.preset.label")}),e.jsxs("div",{ref:s,className:"cli-select group relative",children:[e.jsx(se,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":d,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":a,disabled:j,onClick:()=>r(l=>!l),children:g}),e.jsx(A,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),d&&p.length>0?e.jsxs("div",{role:"listbox","aria-label":i("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[p.map(l=>{const m=l.id===a,f=l.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${l.id}`,className:"cli-select__option",onClick:()=>{o(l.id),r(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[l.displayName,f?i("workspace.preset.notFoundSuffix"):""]})]},l.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{o(""),r(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:i("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),fe=({probe:t,pasteFallbackDefault:o=!1,commandPresetError:p,commandPresetId:a,commandPresets:i,onCancel:d,onCommandPresetChange:r,onCreate:s,onOpenServerBrowse:u})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,l]=c.useState(g),[m,f]=c.useState(""),[C,P]=c.useState(o),[w,E]=c.useState(!1),[_,h]=c.useState("");c.useEffect(()=>{l(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const y=m.trim(),x=C&&y.length>0?y:t?.path??"",N=_.trim(),S=i.find(v=>v.id===a),R=i.length===0&&!p,B=!a&&N.length===0,F=S?.available===!1&&N.length===0,O=B?n("workspace.preset.genericRequiresStartup"):F?n("workspace.preset.notInstalled",{name:S.displayName}):null,$=j.trim().length>0&&x.length>0&&!R&&!B&&!F,H=()=>{$&&s({commandPresetId:a||null,name:j.trim(),path:x,...N?{startupCommand:N}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&d(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(Q,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>l(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(ee,{error:p??O,onChange:r,presets:i,value:a}),e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[w?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),w?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[C?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:d,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:H,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},be=({entries:t,error:o,loading:p,onNavigate:a,onSelect:i,selected:d})=>{const{t:r}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:p?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:r("common.loading")}):o?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:o}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:r("workspace.browse.empty")}):e.jsx("ul",{children:t.map(s=>{const u=d===s.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${s.name}`,onClick:()=>i(s.path),onDoubleClick:()=>a(s.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:u?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:s.is_git_repository?e.jsx(Q,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:s.name}),s.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:r("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${s.name}`,onClick:()=>a(s.path),"aria-label":r("workspace.browse.openAria",{name:s.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},s.path)})})})},ge=({probe:t,suggestedName:o,onSuggestedNameChange:p})=>{const{t:a}=D(),i=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:a("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:a("workspace.git.short",{branch:t.current_branch??a("workspace.git.detached")})}):i?e.jsx("span",{className:"text-ter text-xs",children:a("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:a("workspace.field.name")}),e.jsx("input",{type:"text",value:o,onChange:d=>p(d.target.value),disabled:!i,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ke=t=>{const p=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),a=p[p.length-1];return a?`~ (${a})`:t},ve=(t,o)=>{if(!o||!t)return[];const p=[{label:ke(o),path:o}];if(t===o)return p;const a=o.replace(/[\\/]+$/,""),i=t.startsWith(a)?t.slice(a.length).replace(/^[\\/]+/,""):"";if(!i)return p;const d=i.split(/[\\/]/).filter(Boolean);let r=a;for(const s of d)r=`${r}/${s}`,p.push({label:s,path:r});return p},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},je=t=>{const[o,p]=c.useState(J),[a,i]=c.useState(!1),[d,r]=c.useState(null),[s,u]=c.useState(null),n=c.useRef(0),k=c.useRef(0),g=c.useCallback(async l=>{const m=++n.current;i(!0);try{const f=await ae(l);if(n.current!==m)return;p(f),f.ok&&r(f.current_path)}catch{}finally{n.current===m&&i(!1)}},[]);c.useEffect(()=>{if(!t){n.current++,k.current++,p(J),r(null),u(null);return}g("")},[t,g]),c.useEffect(()=>{if(!d){u(null);return}const l=++k.current;re(d).then(m=>{k.current===l&&u(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[d]);const j=c.useCallback(l=>{r(l)},[]);return{browse:o,loading:a,navigate:g,probe:s,selectEntry:j,selected:d}},we=({commandPresetError:t,commandPresetId:o,commandPresets:p,onClose:a,onCommandPresetChange:i,onCreate:d,open:r})=>{const{t:s}=D(),{browse:u,loading:n,navigate:k,probe:g,selectEntry:j,selected:l}=je(r),[m,f]=c.useState(""),[C,P]=c.useState(!1),[w,E]=c.useState(""),[_,h]=c.useState(!1),[y,x]=c.useState("");if(c.useEffect(()=>{r||(f(""),P(!1),E(""),h(!1),x(""))},[r]),c.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!r)return null;const N=ve(u.current_path,u.root_path),S=p.find(b=>b.id===o),R=y.trim(),B=p.length===0&&!t,F=!o&&R.length===0,O=S?.available===!1&&R.length===0,$=F?s("workspace.preset.genericRequiresStartup"):O?s("workspace.preset.notInstalled",{name:S.displayName}):null,H=m.trim().length>0&&(g?.is_dir===!0||C&&w.trim().length>0)&&!B&&!F&&!O,v=()=>{const b=C&&w.trim().length>0?w.trim():g?.path??"";b&&d({commandPresetId:o||null,name:m.trim(),path:b,...R?{startupCommand:R}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&a(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:s("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:u.root_path?s("workspace.browse.root",{path:u.root_path}):s("workspace.browse.rootLoading")})]}),e.jsx(ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":s("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(ce,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":s("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>u.parent_path?k(u.parent_path):null,disabled:!u.parent_path,"aria-label":s("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(pe,{size:12,"aria-hidden":!0})," ",s("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),N.map((b,Y)=>{const te=Y===N.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:"/"}):null,te?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(be,{entries:u.entries,error:u.ok?null:u.error,loading:n,onNavigate:k,onSelect:j,selected:l})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(ge,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(ee,{error:t??$,onChange:i,presets:p,value:o}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.startup"),e.jsx("input",{type:"text",value:y,onChange:b=>x(b.target.value),placeholder:s("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:s("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[C?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:w,onChange:b=>E(b.target.value),placeholder:s("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:v,disabled:!H,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:s("workspace.confirm.create")})]})]})})]})})},z="claude",ye=t=>t.some(o=>o.id===z&&o.available)?z:t.find(o=>o.available)?.id??t[0]?.id??z,_e=({trigger:t,onClose:o,onCreate:p})=>{const{t:a}=D(),i=c.useRef(a);c.useEffect(()=>{i.current=a},[a]);const[d,r]=c.useState({kind:"idle"}),[s,u]=c.useState([]),[n,k]=c.useState(z),[g,j]=c.useState(null),l=c.useRef({error:null,id:z,presets:[]}),m=c.useRef(o);c.useEffect(()=>{m.current=o},[o]),c.useEffect(()=>{if(t===0)return;let h=!1;j(null);const y=le().then(x=>{if(h)return;const N=x.some(S=>S.id===l.current.id&&S.available)?l.current.id:ye(x);l.current={error:null,id:N,presets:x},u(x),k(N)}).catch(()=>{if(h)return;const x=i.current("workspace.preset.loadFailed");l.current={error:x,id:z,presets:[]},u([]),k(z),j(x)});return r({kind:"picking"}),oe().then(async x=>{if(await y,!h){if(x.canceled){if(x.error){r({kind:"error",message:x.error});return}r({kind:"idle"}),m.current();return}if(!x.supported){r({kind:"confirm",probe:null,pasteDefault:!0});return}if(!x.probe?.ok||!x.probe.is_dir){r({kind:"error",message:x.error??i.current("workspace.error.outsideSandbox")});return}r({kind:"confirm",probe:x.probe,pasteDefault:!1})}}).catch(x=>{if(h)return;const N=x instanceof Error?x.message:i.current("workspace.error.pickerFailed");r({kind:"error",message:N})}),()=>{h=!0}},[t]);const f=()=>{r({kind:"idle"}),o()},C=h=>{Promise.resolve(p(h)).then(()=>r({kind:"idle"})).catch(y=>{const x=y instanceof Error?y.message:a("workspace.error.createFailed");r({kind:"error",title:a("workspace.error.createTitle"),message:x})})},P=h=>{l.current={...l.current,id:h},k(h)},w=s.length>0||g?s:l.current.presets,E=n===""?"":w.length>0&&!w.some(h=>h.id===n&&h.available)?l.current.id:n,_=g??l.current.error;if(d.kind==="idle")return null;if(d.kind==="picking"){const h=()=>r({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:y=>!y&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:a("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(ue,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:a("workspace.picking.message")})]})]})]})})}return d.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ie,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:d.title??a("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:d.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:a("common.close")}),e.jsx("button",{type:"button",onClick:()=>r({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:a("workspace.error.pastePathInstead")})]})]})})]})}):d.kind==="browse"?e.jsx(we,{commandPresetError:_,commandPresetId:E,commandPresets:w,onClose:f,onCommandPresetChange:P,onCreate:C,open:!0}):e.jsx(fe,{commandPresetError:_,commandPresetId:E,commandPresets:w,pasteFallbackDefault:d.pasteDefault,probe:d.probe,onCancel:f,onCommandPresetChange:P,onCreate:C,onOpenServerBrowse:()=>r({kind:"browse"})})};export{_e as AddWorkspaceDialog};
|
|
1
|
+
import{c as V,u as D,r as c,j as e,o as se,e as A,i as Z,a as T,P as I,O as q,C as U,b as W,D as K,q as ae,s as re,t as ne,X as ce,v as le,w as oe,T as ie}from"./index-Cn8X3get.js";import{C as L}from"./chevron-right-CtLjVEl7.js";const de=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],pe=V("arrow-up",de);const xe=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],ue=V("folder-search",xe);const me=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",me);const he=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Q=V("git-branch",he),ee=({error:t,onChange:o,presets:p,value:a})=>{const{t:i}=D(),[d,r]=c.useState(!1),s=c.useRef(null),u=p.find(l=>l.id===a),n=a==="",k=u?[u.command,...u.args].join(" ").trim():i(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=u?.displayName??(n?i("workspace.preset.generic"):"Claude Code (CC)"),j=p.length===0&&!n;return c.useEffect(()=>{if(!d)return;const l=f=>{s.current?.contains(f.target)||r(!1)},m=f=>{f.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m)}},[d]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:i("workspace.preset.label")}),e.jsxs("div",{ref:s,className:"cli-select group relative",children:[e.jsx(se,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":d,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":a,disabled:j,onClick:()=>r(l=>!l),children:g}),e.jsx(A,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),d&&p.length>0?e.jsxs("div",{role:"listbox","aria-label":i("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[p.map(l=>{const m=l.id===a,f=l.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${l.id}`,className:"cli-select__option",onClick:()=>{o(l.id),r(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[l.displayName,f?i("workspace.preset.notFoundSuffix"):""]})]},l.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{o(""),r(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:i("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),fe=({probe:t,pasteFallbackDefault:o=!1,commandPresetError:p,commandPresetId:a,commandPresets:i,onCancel:d,onCommandPresetChange:r,onCreate:s,onOpenServerBrowse:u})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,l]=c.useState(g),[m,f]=c.useState(""),[C,P]=c.useState(o),[w,E]=c.useState(!1),[_,h]=c.useState("");c.useEffect(()=>{l(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const y=m.trim(),x=C&&y.length>0?y:t?.path??"",N=_.trim(),S=i.find(v=>v.id===a),R=i.length===0&&!p,B=!a&&N.length===0,F=S?.available===!1&&N.length===0,O=B?n("workspace.preset.genericRequiresStartup"):F?n("workspace.preset.notInstalled",{name:S.displayName}):null,$=j.trim().length>0&&x.length>0&&!R&&!B&&!F,H=()=>{$&&s({commandPresetId:a||null,name:j.trim(),path:x,...N?{startupCommand:N}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&d(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(Q,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>l(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(ee,{error:p??O,onChange:r,presets:i,value:a}),e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[w?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),w?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[C?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:d,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:H,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},be=({entries:t,error:o,loading:p,onNavigate:a,onSelect:i,selected:d})=>{const{t:r}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:p?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:r("common.loading")}):o?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:o}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:r("workspace.browse.empty")}):e.jsx("ul",{children:t.map(s=>{const u=d===s.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${s.name}`,onClick:()=>i(s.path),onDoubleClick:()=>a(s.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:u?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:s.is_git_repository?e.jsx(Q,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:s.name}),s.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:r("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${s.name}`,onClick:()=>a(s.path),"aria-label":r("workspace.browse.openAria",{name:s.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},s.path)})})})},ge=({probe:t,suggestedName:o,onSuggestedNameChange:p})=>{const{t:a}=D(),i=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:a("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:a("workspace.git.short",{branch:t.current_branch??a("workspace.git.detached")})}):i?e.jsx("span",{className:"text-ter text-xs",children:a("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:a("workspace.field.name")}),e.jsx("input",{type:"text",value:o,onChange:d=>p(d.target.value),disabled:!i,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ke=t=>{const p=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),a=p[p.length-1];return a?`~ (${a})`:t},ve=(t,o)=>{if(!o||!t)return[];const p=[{label:ke(o),path:o}];if(t===o)return p;const a=o.replace(/[\\/]+$/,""),i=t.startsWith(a)?t.slice(a.length).replace(/^[\\/]+/,""):"";if(!i)return p;const d=i.split(/[\\/]/).filter(Boolean);let r=a;for(const s of d)r=`${r}/${s}`,p.push({label:s,path:r});return p},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},je=t=>{const[o,p]=c.useState(J),[a,i]=c.useState(!1),[d,r]=c.useState(null),[s,u]=c.useState(null),n=c.useRef(0),k=c.useRef(0),g=c.useCallback(async l=>{const m=++n.current;i(!0);try{const f=await ae(l);if(n.current!==m)return;p(f),f.ok&&r(f.current_path)}catch{}finally{n.current===m&&i(!1)}},[]);c.useEffect(()=>{if(!t){n.current++,k.current++,p(J),r(null),u(null);return}g("")},[t,g]),c.useEffect(()=>{if(!d){u(null);return}const l=++k.current;re(d).then(m=>{k.current===l&&u(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[d]);const j=c.useCallback(l=>{r(l)},[]);return{browse:o,loading:a,navigate:g,probe:s,selectEntry:j,selected:d}},we=({commandPresetError:t,commandPresetId:o,commandPresets:p,onClose:a,onCommandPresetChange:i,onCreate:d,open:r})=>{const{t:s}=D(),{browse:u,loading:n,navigate:k,probe:g,selectEntry:j,selected:l}=je(r),[m,f]=c.useState(""),[C,P]=c.useState(!1),[w,E]=c.useState(""),[_,h]=c.useState(!1),[y,x]=c.useState("");if(c.useEffect(()=>{r||(f(""),P(!1),E(""),h(!1),x(""))},[r]),c.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!r)return null;const N=ve(u.current_path,u.root_path),S=p.find(b=>b.id===o),R=y.trim(),B=p.length===0&&!t,F=!o&&R.length===0,O=S?.available===!1&&R.length===0,$=F?s("workspace.preset.genericRequiresStartup"):O?s("workspace.preset.notInstalled",{name:S.displayName}):null,H=m.trim().length>0&&(g?.is_dir===!0||C&&w.trim().length>0)&&!B&&!F&&!O,v=()=>{const b=C&&w.trim().length>0?w.trim():g?.path??"";b&&d({commandPresetId:o||null,name:m.trim(),path:b,...R?{startupCommand:R}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&a(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:s("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:u.root_path?s("workspace.browse.root",{path:u.root_path}):s("workspace.browse.rootLoading")})]}),e.jsx(ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":s("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(ce,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":s("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>u.parent_path?k(u.parent_path):null,disabled:!u.parent_path,"aria-label":s("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(pe,{size:12,"aria-hidden":!0})," ",s("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),N.map((b,Y)=>{const te=Y===N.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:"/"}):null,te?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(be,{entries:u.entries,error:u.ok?null:u.error,loading:n,onNavigate:k,onSelect:j,selected:l})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(ge,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(ee,{error:t??$,onChange:i,presets:p,value:o}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.startup"),e.jsx("input",{type:"text",value:y,onChange:b=>x(b.target.value),placeholder:s("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:s("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[C?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:w,onChange:b=>E(b.target.value),placeholder:s("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:v,disabled:!H,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:s("workspace.confirm.create")})]})]})})]})})},z="claude",ye=t=>t.some(o=>o.id===z&&o.available)?z:t.find(o=>o.available)?.id??t[0]?.id??z,_e=({trigger:t,onClose:o,onCreate:p})=>{const{t:a}=D(),i=c.useRef(a);c.useEffect(()=>{i.current=a},[a]);const[d,r]=c.useState({kind:"idle"}),[s,u]=c.useState([]),[n,k]=c.useState(z),[g,j]=c.useState(null),l=c.useRef({error:null,id:z,presets:[]}),m=c.useRef(o);c.useEffect(()=>{m.current=o},[o]),c.useEffect(()=>{if(t===0)return;let h=!1;j(null);const y=le().then(x=>{if(h)return;const N=x.some(S=>S.id===l.current.id&&S.available)?l.current.id:ye(x);l.current={error:null,id:N,presets:x},u(x),k(N)}).catch(()=>{if(h)return;const x=i.current("workspace.preset.loadFailed");l.current={error:x,id:z,presets:[]},u([]),k(z),j(x)});return r({kind:"picking"}),oe().then(async x=>{if(await y,!h){if(x.canceled){if(x.error){r({kind:"error",message:x.error});return}r({kind:"idle"}),m.current();return}if(!x.supported){r({kind:"confirm",probe:null,pasteDefault:!0});return}if(!x.probe?.ok||!x.probe.is_dir){r({kind:"error",message:x.error??i.current("workspace.error.outsideSandbox")});return}r({kind:"confirm",probe:x.probe,pasteDefault:!1})}}).catch(x=>{if(h)return;const N=x instanceof Error?x.message:i.current("workspace.error.pickerFailed");r({kind:"error",message:N})}),()=>{h=!0}},[t]);const f=()=>{r({kind:"idle"}),o()},C=h=>{Promise.resolve(p(h)).then(()=>r({kind:"idle"})).catch(y=>{const x=y instanceof Error?y.message:a("workspace.error.createFailed");r({kind:"error",title:a("workspace.error.createTitle"),message:x})})},P=h=>{l.current={...l.current,id:h},k(h)},w=s.length>0||g?s:l.current.presets,E=n===""?"":w.length>0&&!w.some(h=>h.id===n&&h.available)?l.current.id:n,_=g??l.current.error;if(d.kind==="idle")return null;if(d.kind==="picking"){const h=()=>r({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:y=>!y&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:a("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(ue,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:a("workspace.picking.message")})]})]})]})})}return d.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ie,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:d.title??a("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:d.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:a("common.close")}),e.jsx("button",{type:"button",onClick:()=>r({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:a("workspace.error.pastePathInstead")})]})]})})]})}):d.kind==="browse"?e.jsx(we,{commandPresetError:_,commandPresetId:E,commandPresets:w,onClose:f,onCommandPresetChange:P,onCreate:C,open:!0}):e.jsx(fe,{commandPresetError:_,commandPresetId:E,commandPresets:w,pasteFallbackDefault:d.pasteDefault,probe:d.probe,onCancel:f,onCommandPresetChange:P,onCreate:C,onOpenServerBrowse:()=>r({kind:"browse"})})};export{_e as AddWorkspaceDialog};
|