@clinebot/core 0.0.22 → 0.0.24
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/dist/ClineCore.d.ts +110 -0
- package/dist/ClineCore.d.ts.map +1 -0
- package/dist/account/cline-account-service.d.ts +2 -1
- package/dist/account/cline-account-service.d.ts.map +1 -1
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/rpc.d.ts +3 -1
- package/dist/account/rpc.d.ts.map +1 -1
- package/dist/account/types.d.ts +3 -0
- package/dist/account/types.d.ts.map +1 -1
- package/dist/agents/plugin-loader.d.ts.map +1 -1
- package/dist/agents/plugin-sandbox-bootstrap.js +17 -17
- package/dist/auth/client.d.ts +1 -1
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/cline.d.ts +1 -1
- package/dist/auth/cline.d.ts.map +1 -1
- package/dist/auth/codex.d.ts +1 -1
- package/dist/auth/codex.d.ts.map +1 -1
- package/dist/auth/oca.d.ts +1 -1
- package/dist/auth/oca.d.ts.map +1 -1
- package/dist/auth/utils.d.ts +2 -2
- package/dist/auth/utils.d.ts.map +1 -1
- package/dist/index.d.ts +50 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +949 -0
- package/dist/providers/local-provider-service.d.ts +4 -4
- package/dist/providers/local-provider-service.d.ts.map +1 -1
- package/dist/runtime/runtime-builder.d.ts +1 -0
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/session-runtime.d.ts +2 -1
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/runtime/team-runtime-registry.d.ts +13 -0
- package/dist/runtime/team-runtime-registry.d.ts.map +1 -0
- package/dist/session/default-session-manager.d.ts +2 -2
- package/dist/session/default-session-manager.d.ts.map +1 -1
- package/dist/session/rpc-runtime-ensure.d.ts +53 -0
- package/dist/session/rpc-runtime-ensure.d.ts.map +1 -0
- package/dist/session/session-config-builder.d.ts +2 -3
- package/dist/session/session-config-builder.d.ts.map +1 -1
- package/dist/session/session-host.d.ts +8 -18
- package/dist/session/session-host.d.ts.map +1 -1
- package/dist/session/session-manager.d.ts +1 -1
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manifest.d.ts +1 -2
- package/dist/session/session-manifest.d.ts.map +1 -1
- package/dist/session/unified-session-persistence-service.d.ts +2 -2
- package/dist/session/unified-session-persistence-service.d.ts.map +1 -1
- package/dist/session/utils/helpers.d.ts +1 -1
- package/dist/session/utils/helpers.d.ts.map +1 -1
- package/dist/session/utils/types.d.ts +1 -1
- package/dist/session/utils/types.d.ts.map +1 -1
- package/dist/storage/provider-settings-legacy-migration.d.ts.map +1 -1
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -1
- package/dist/telemetry/distinct-id.d.ts +2 -0
- package/dist/telemetry/distinct-id.d.ts.map +1 -0
- package/dist/telemetry/{opentelemetry.d.ts → index.d.ts} +1 -1
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +28 -0
- package/dist/tools/constants.d.ts +1 -1
- package/dist/tools/constants.d.ts.map +1 -1
- package/dist/tools/definitions.d.ts +3 -3
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/executors/apply-patch.d.ts +1 -1
- package/dist/tools/executors/apply-patch.d.ts.map +1 -1
- package/dist/tools/executors/bash.d.ts +1 -1
- package/dist/tools/executors/bash.d.ts.map +1 -1
- package/dist/tools/executors/editor.d.ts +1 -1
- package/dist/tools/executors/editor.d.ts.map +1 -1
- package/dist/tools/executors/file-read.d.ts +1 -1
- package/dist/tools/executors/file-read.d.ts.map +1 -1
- package/dist/tools/executors/index.d.ts +14 -14
- package/dist/tools/executors/index.d.ts.map +1 -1
- package/dist/tools/executors/search.d.ts +1 -1
- package/dist/tools/executors/search.d.ts.map +1 -1
- package/dist/tools/executors/web-fetch.d.ts +1 -1
- package/dist/tools/executors/web-fetch.d.ts.map +1 -1
- package/dist/tools/helpers.d.ts +1 -1
- package/dist/tools/helpers.d.ts.map +1 -1
- package/dist/tools/index.d.ts +10 -10
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/model-tool-routing.d.ts +1 -1
- package/dist/tools/model-tool-routing.d.ts.map +1 -1
- package/dist/tools/presets.d.ts +1 -1
- package/dist/tools/presets.d.ts.map +1 -1
- package/dist/types/common.d.ts +17 -8
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/config.d.ts +4 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/provider-settings.d.ts +1 -1
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/types.d.ts +5 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +44 -38
- package/src/ClineCore.ts +137 -0
- package/src/account/cline-account-service.test.ts +101 -0
- package/src/account/cline-account-service.ts +300 -0
- package/src/account/featurebase-token.test.ts +175 -0
- package/src/account/index.ts +23 -0
- package/src/account/rpc.test.ts +63 -0
- package/src/account/rpc.ts +185 -0
- package/src/account/types.ts +102 -0
- package/src/agents/agent-config-loader.test.ts +236 -0
- package/src/agents/agent-config-loader.ts +108 -0
- package/src/agents/agent-config-parser.ts +198 -0
- package/src/agents/hooks-config-loader.test.ts +20 -0
- package/src/agents/hooks-config-loader.ts +118 -0
- package/src/agents/index.ts +85 -0
- package/src/agents/plugin-config-loader.test.ts +140 -0
- package/src/agents/plugin-config-loader.ts +97 -0
- package/src/agents/plugin-loader.test.ts +210 -0
- package/src/agents/plugin-loader.ts +175 -0
- package/src/agents/plugin-sandbox-bootstrap.ts +448 -0
- package/src/agents/plugin-sandbox.test.ts +296 -0
- package/src/agents/plugin-sandbox.ts +341 -0
- package/src/agents/unified-config-file-watcher.test.ts +196 -0
- package/src/agents/unified-config-file-watcher.ts +483 -0
- package/src/agents/user-instruction-config-loader.test.ts +158 -0
- package/src/agents/user-instruction-config-loader.ts +438 -0
- package/src/auth/client.test.ts +40 -0
- package/src/auth/client.ts +25 -0
- package/src/auth/cline.test.ts +130 -0
- package/src/auth/cline.ts +420 -0
- package/src/auth/codex.test.ts +170 -0
- package/src/auth/codex.ts +491 -0
- package/src/auth/oca.test.ts +215 -0
- package/src/auth/oca.ts +573 -0
- package/src/auth/server.ts +216 -0
- package/src/auth/types.ts +81 -0
- package/src/auth/utils.test.ts +128 -0
- package/src/auth/utils.ts +247 -0
- package/src/chat/chat-schema.ts +82 -0
- package/src/index.ts +479 -0
- package/src/input/file-indexer.d.ts +11 -0
- package/src/input/file-indexer.test.ts +127 -0
- package/src/input/file-indexer.ts +327 -0
- package/src/input/index.ts +7 -0
- package/src/input/mention-enricher.test.ts +85 -0
- package/src/input/mention-enricher.ts +122 -0
- package/src/mcp/config-loader.test.ts +238 -0
- package/src/mcp/config-loader.ts +219 -0
- package/src/mcp/index.ts +26 -0
- package/src/mcp/manager.test.ts +106 -0
- package/src/mcp/manager.ts +262 -0
- package/src/mcp/types.ts +88 -0
- package/src/providers/local-provider-registry.ts +232 -0
- package/src/providers/local-provider-service.test.ts +783 -0
- package/src/providers/local-provider-service.ts +471 -0
- package/src/runtime/commands.test.ts +98 -0
- package/src/runtime/commands.ts +83 -0
- package/src/runtime/hook-file-hooks.test.ts +237 -0
- package/src/runtime/hook-file-hooks.ts +859 -0
- package/src/runtime/index.ts +37 -0
- package/src/runtime/rules.ts +34 -0
- package/src/runtime/runtime-builder.team-persistence.test.ts +245 -0
- package/src/runtime/runtime-builder.test.ts +371 -0
- package/src/runtime/runtime-builder.ts +631 -0
- package/src/runtime/runtime-parity.test.ts +143 -0
- package/src/runtime/sandbox/subprocess-sandbox.ts +231 -0
- package/src/runtime/session-runtime.ts +49 -0
- package/src/runtime/skills.ts +44 -0
- package/src/runtime/team-runtime-registry.ts +46 -0
- package/src/runtime/tool-approval.ts +104 -0
- package/src/runtime/workflows.test.ts +119 -0
- package/src/runtime/workflows.ts +45 -0
- package/src/session/default-session-manager.e2e.test.ts +384 -0
- package/src/session/default-session-manager.test.ts +1931 -0
- package/src/session/default-session-manager.ts +1422 -0
- package/src/session/file-session-service.ts +280 -0
- package/src/session/index.ts +45 -0
- package/src/session/rpc-runtime-ensure.ts +521 -0
- package/src/session/rpc-session-service.ts +107 -0
- package/src/session/rpc-spawn-lease.test.ts +49 -0
- package/src/session/rpc-spawn-lease.ts +122 -0
- package/src/session/runtime-oauth-token-manager.test.ts +137 -0
- package/src/session/runtime-oauth-token-manager.ts +272 -0
- package/src/session/session-agent-events.ts +248 -0
- package/src/session/session-artifacts.ts +106 -0
- package/src/session/session-config-builder.ts +113 -0
- package/src/session/session-graph.ts +92 -0
- package/src/session/session-host.test.ts +89 -0
- package/src/session/session-host.ts +205 -0
- package/src/session/session-manager.ts +69 -0
- package/src/session/session-manifest.ts +29 -0
- package/src/session/session-service.team-persistence.test.ts +48 -0
- package/src/session/session-service.ts +673 -0
- package/src/session/session-team-coordination.ts +229 -0
- package/src/session/session-telemetry.ts +100 -0
- package/src/session/sqlite-rpc-session-backend.ts +303 -0
- package/src/session/unified-session-persistence-service.test.ts +85 -0
- package/src/session/unified-session-persistence-service.ts +994 -0
- package/src/session/utils/helpers.ts +139 -0
- package/src/session/utils/types.ts +57 -0
- package/src/session/utils/usage.ts +32 -0
- package/src/session/workspace-manager.ts +98 -0
- package/src/session/workspace-manifest.ts +100 -0
- package/src/storage/artifact-store.ts +1 -0
- package/src/storage/file-team-store.ts +257 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/provider-settings-legacy-migration.test.ts +424 -0
- package/src/storage/provider-settings-legacy-migration.ts +826 -0
- package/src/storage/provider-settings-manager.test.ts +191 -0
- package/src/storage/provider-settings-manager.ts +152 -0
- package/src/storage/session-store.ts +1 -0
- package/src/storage/sqlite-session-store.ts +275 -0
- package/src/storage/sqlite-team-store.ts +454 -0
- package/src/storage/team-store.ts +40 -0
- package/src/team/index.ts +4 -0
- package/src/team/projections.ts +285 -0
- package/src/telemetry/ITelemetryAdapter.ts +94 -0
- package/src/telemetry/LoggerTelemetryAdapter.test.ts +42 -0
- package/src/telemetry/LoggerTelemetryAdapter.ts +114 -0
- package/src/telemetry/OpenTelemetryAdapter.test.ts +157 -0
- package/src/telemetry/OpenTelemetryAdapter.ts +348 -0
- package/src/telemetry/OpenTelemetryProvider.test.ts +113 -0
- package/src/telemetry/OpenTelemetryProvider.ts +325 -0
- package/src/telemetry/TelemetryService.test.ts +134 -0
- package/src/telemetry/TelemetryService.ts +141 -0
- package/src/telemetry/core-events.ts +400 -0
- package/src/telemetry/distinct-id.test.ts +57 -0
- package/src/telemetry/distinct-id.ts +58 -0
- package/src/telemetry/index.ts +20 -0
- package/src/tools/constants.ts +35 -0
- package/src/tools/definitions.test.ts +704 -0
- package/src/tools/definitions.ts +709 -0
- package/src/tools/executors/apply-patch-parser.ts +520 -0
- package/src/tools/executors/apply-patch.ts +359 -0
- package/src/tools/executors/bash.test.ts +87 -0
- package/src/tools/executors/bash.ts +207 -0
- package/src/tools/executors/editor.test.ts +35 -0
- package/src/tools/executors/editor.ts +219 -0
- package/src/tools/executors/file-read.test.ts +49 -0
- package/src/tools/executors/file-read.ts +110 -0
- package/src/tools/executors/index.ts +87 -0
- package/src/tools/executors/search.ts +278 -0
- package/src/tools/executors/web-fetch.ts +259 -0
- package/src/tools/helpers.ts +130 -0
- package/src/tools/index.ts +169 -0
- package/src/tools/model-tool-routing.test.ts +86 -0
- package/src/tools/model-tool-routing.ts +132 -0
- package/src/tools/presets.test.ts +62 -0
- package/src/tools/presets.ts +168 -0
- package/src/tools/schemas.ts +327 -0
- package/src/tools/types.ts +329 -0
- package/src/types/common.ts +26 -0
- package/src/types/config.ts +86 -0
- package/src/types/events.ts +74 -0
- package/src/types/index.ts +24 -0
- package/src/types/provider-settings.ts +43 -0
- package/src/types/sessions.ts +16 -0
- package/src/types/storage.ts +64 -0
- package/src/types/workspace.ts +7 -0
- package/src/types.ts +132 -0
- package/src/version.ts +3 -0
- package/dist/index.node.d.ts +0 -47
- package/dist/index.node.d.ts.map +0 -1
- package/dist/index.node.js +0 -948
- package/dist/telemetry/opentelemetry.d.ts.map +0 -1
- package/dist/telemetry/opentelemetry.js +0 -27
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const ChatSessionConfigSchema = z.object({
|
|
4
|
+
workspaceRoot: z.string().min(1),
|
|
5
|
+
cwd: z.string().optional(),
|
|
6
|
+
provider: z.string().min(1),
|
|
7
|
+
model: z.string().min(1),
|
|
8
|
+
mode: z.enum(["act", "plan"]).default("act"),
|
|
9
|
+
apiKey: z.string(),
|
|
10
|
+
systemPrompt: z.string().optional(),
|
|
11
|
+
rules: z.string().optional(),
|
|
12
|
+
maxIterations: z.number().int().positive().optional(),
|
|
13
|
+
enableTools: z.boolean(),
|
|
14
|
+
enableSpawn: z.boolean(),
|
|
15
|
+
enableTeams: z.boolean(),
|
|
16
|
+
autoApproveTools: z.boolean().optional(),
|
|
17
|
+
teamName: z.string().min(1),
|
|
18
|
+
missionStepInterval: z.number().int().positive(),
|
|
19
|
+
missionTimeIntervalMs: z.number().int().positive(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const ChatSessionStatusSchema = z.enum([
|
|
23
|
+
"idle",
|
|
24
|
+
"starting",
|
|
25
|
+
"running",
|
|
26
|
+
"stopping",
|
|
27
|
+
"completed",
|
|
28
|
+
"cancelled",
|
|
29
|
+
"failed",
|
|
30
|
+
"error",
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
export const ChatMessageRoleSchema = z.enum([
|
|
34
|
+
"user",
|
|
35
|
+
"assistant",
|
|
36
|
+
"tool",
|
|
37
|
+
"system",
|
|
38
|
+
"status",
|
|
39
|
+
"error",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export const ChatMessageSchema = z.object({
|
|
43
|
+
id: z.string().min(1),
|
|
44
|
+
sessionId: z.string().nullable(),
|
|
45
|
+
role: ChatMessageRoleSchema,
|
|
46
|
+
content: z.string(),
|
|
47
|
+
createdAt: z.number().int().nonnegative(),
|
|
48
|
+
meta: z
|
|
49
|
+
.object({
|
|
50
|
+
stream: z.enum(["stdout", "stderr"]).optional(),
|
|
51
|
+
toolName: z.string().optional(),
|
|
52
|
+
iteration: z.number().int().nonnegative().optional(),
|
|
53
|
+
agentId: z.string().optional(),
|
|
54
|
+
conversationId: z.string().optional(),
|
|
55
|
+
hookEventName: z.string().optional(),
|
|
56
|
+
inputTokens: z.number().int().nonnegative().optional(),
|
|
57
|
+
outputTokens: z.number().int().nonnegative().optional(),
|
|
58
|
+
})
|
|
59
|
+
.optional(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const ChatSummarySchema = z.object({
|
|
63
|
+
toolCalls: z.number().int().nonnegative(),
|
|
64
|
+
tokensIn: z.number().int().nonnegative(),
|
|
65
|
+
tokensOut: z.number().int().nonnegative(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const ChatViewStateSchema = z.object({
|
|
69
|
+
sessionId: z.string().nullable(),
|
|
70
|
+
status: ChatSessionStatusSchema,
|
|
71
|
+
config: ChatSessionConfigSchema,
|
|
72
|
+
messages: z.array(ChatMessageSchema),
|
|
73
|
+
rawTranscript: z.string(),
|
|
74
|
+
error: z.string().nullable(),
|
|
75
|
+
summary: ChatSummarySchema,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export type ChatSessionConfig = z.infer<typeof ChatSessionConfigSchema>;
|
|
79
|
+
export type ChatSessionStatus = z.infer<typeof ChatSessionStatusSchema>;
|
|
80
|
+
export type ChatMessage = z.infer<typeof ChatMessageSchema>;
|
|
81
|
+
export type ChatSummary = z.infer<typeof ChatSummarySchema>;
|
|
82
|
+
export type ChatViewState = z.infer<typeof ChatViewStateSchema>;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @clinebot/core
|
|
3
|
+
*
|
|
4
|
+
* Core contracts, shared state utilities, and Node runtime services.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
type AgentConfig,
|
|
9
|
+
type CreateMcpToolsOptions,
|
|
10
|
+
createMcpTools,
|
|
11
|
+
createTool,
|
|
12
|
+
getClineDefaultSystemPrompt,
|
|
13
|
+
type Tool,
|
|
14
|
+
type ToolApprovalRequest,
|
|
15
|
+
type ToolApprovalResult,
|
|
16
|
+
type ToolContext,
|
|
17
|
+
} from "@clinebot/agents";
|
|
18
|
+
export * as LlmsModels from "@clinebot/llms/models";
|
|
19
|
+
export * as LlmsProviders from "@clinebot/llms/providers";
|
|
20
|
+
// Shared contracts and path helpers re-exported for app consumers.
|
|
21
|
+
export type {
|
|
22
|
+
AgentMode,
|
|
23
|
+
BasicLogger,
|
|
24
|
+
ConnectorHookEvent,
|
|
25
|
+
HookSessionContext,
|
|
26
|
+
ITelemetryService,
|
|
27
|
+
RpcAddProviderActionRequest,
|
|
28
|
+
RpcChatMessage,
|
|
29
|
+
RpcChatRunTurnRequest,
|
|
30
|
+
RpcChatRuntimeConfigBase,
|
|
31
|
+
RpcChatRuntimeLoggerConfig,
|
|
32
|
+
RpcChatStartSessionArtifacts,
|
|
33
|
+
RpcChatStartSessionRequest,
|
|
34
|
+
RpcChatTurnResult,
|
|
35
|
+
RpcClineAccountActionRequest,
|
|
36
|
+
RpcOAuthProviderId,
|
|
37
|
+
RpcProviderActionRequest,
|
|
38
|
+
RpcProviderCapability,
|
|
39
|
+
RpcProviderCatalogResponse,
|
|
40
|
+
RpcProviderListItem,
|
|
41
|
+
RpcProviderModel,
|
|
42
|
+
RpcProviderOAuthLoginResponse,
|
|
43
|
+
RpcSaveProviderSettingsActionRequest,
|
|
44
|
+
SessionLineage,
|
|
45
|
+
TeamProgressProjectionEvent,
|
|
46
|
+
TelemetryArray,
|
|
47
|
+
TelemetryMetadata,
|
|
48
|
+
TelemetryObject,
|
|
49
|
+
TelemetryPrimitive,
|
|
50
|
+
TelemetryProperties,
|
|
51
|
+
TelemetryValue,
|
|
52
|
+
ToolPolicy,
|
|
53
|
+
} from "@clinebot/shared";
|
|
54
|
+
export {
|
|
55
|
+
normalizeUserInput,
|
|
56
|
+
RPC_TEAM_LIFECYCLE_EVENT_TYPE,
|
|
57
|
+
RPC_TEAM_PROGRESS_EVENT_TYPE,
|
|
58
|
+
resolveHookLogPath,
|
|
59
|
+
} from "@clinebot/shared";
|
|
60
|
+
export * from "@clinebot/shared/storage";
|
|
61
|
+
export {
|
|
62
|
+
type ClineAccountBalance,
|
|
63
|
+
type ClineAccountOperations,
|
|
64
|
+
type ClineAccountOrganization,
|
|
65
|
+
type ClineAccountOrganizationBalance,
|
|
66
|
+
type ClineAccountOrganizationUsageTransaction,
|
|
67
|
+
type ClineAccountPaymentTransaction,
|
|
68
|
+
ClineAccountService,
|
|
69
|
+
type ClineAccountServiceOptions,
|
|
70
|
+
type ClineAccountUsageTransaction,
|
|
71
|
+
type ClineAccountUser,
|
|
72
|
+
type ClineOrganization,
|
|
73
|
+
executeRpcClineAccountAction,
|
|
74
|
+
type FeaturebaseTokenResponse,
|
|
75
|
+
isRpcClineAccountActionRequest,
|
|
76
|
+
RpcClineAccountService,
|
|
77
|
+
type RpcProviderActionExecutor,
|
|
78
|
+
type UserRemoteConfigResponse,
|
|
79
|
+
} from "./account";
|
|
80
|
+
export type {
|
|
81
|
+
AgentConfigWatcher,
|
|
82
|
+
AgentConfigWatcherEvent,
|
|
83
|
+
AgentYamlConfig,
|
|
84
|
+
BuildAgentConfigOverridesOptions,
|
|
85
|
+
CreateAgentConfigWatcherOptions,
|
|
86
|
+
CreateInstructionWatcherOptions,
|
|
87
|
+
CreateRulesConfigDefinitionOptions,
|
|
88
|
+
CreateSkillsConfigDefinitionOptions,
|
|
89
|
+
CreateUserInstructionConfigWatcherOptions,
|
|
90
|
+
CreateWorkflowsConfigDefinitionOptions,
|
|
91
|
+
HookConfigFileEntry,
|
|
92
|
+
LoadAgentPluginFromPathOptions,
|
|
93
|
+
ParseMarkdownFrontmatterResult,
|
|
94
|
+
ParseYamlFrontmatterResult,
|
|
95
|
+
ResolveAgentPluginPathsOptions,
|
|
96
|
+
RuleConfig,
|
|
97
|
+
SkillConfig,
|
|
98
|
+
UnifiedConfigDefinition,
|
|
99
|
+
UnifiedConfigFileCandidate,
|
|
100
|
+
UnifiedConfigFileContext,
|
|
101
|
+
UnifiedConfigRecord,
|
|
102
|
+
UnifiedConfigWatcherEvent,
|
|
103
|
+
UnifiedConfigWatcherOptions,
|
|
104
|
+
UserInstructionConfig,
|
|
105
|
+
UserInstructionConfigType,
|
|
106
|
+
UserInstructionConfigWatcher,
|
|
107
|
+
UserInstructionConfigWatcherEvent,
|
|
108
|
+
WorkflowConfig,
|
|
109
|
+
} from "./agents";
|
|
110
|
+
export {
|
|
111
|
+
createAgentConfigDefinition,
|
|
112
|
+
createAgentConfigWatcher,
|
|
113
|
+
createRulesConfigDefinition,
|
|
114
|
+
createSkillsConfigDefinition,
|
|
115
|
+
createUserInstructionConfigWatcher,
|
|
116
|
+
createWorkflowsConfigDefinition,
|
|
117
|
+
discoverPluginModulePaths,
|
|
118
|
+
HOOK_CONFIG_FILE_EVENT_MAP,
|
|
119
|
+
HOOKS_CONFIG_DIRECTORY_NAME,
|
|
120
|
+
HookConfigFileName,
|
|
121
|
+
listHookConfigFiles,
|
|
122
|
+
loadAgentPluginFromPath,
|
|
123
|
+
loadAgentPluginsFromPaths,
|
|
124
|
+
parseAgentConfigFromYaml,
|
|
125
|
+
parsePartialAgentConfigFromYaml,
|
|
126
|
+
parseRuleConfigFromMarkdown,
|
|
127
|
+
parseSkillConfigFromMarkdown,
|
|
128
|
+
parseWorkflowConfigFromMarkdown,
|
|
129
|
+
RULES_CONFIG_DIRECTORY_NAME,
|
|
130
|
+
resolveAgentPluginPaths,
|
|
131
|
+
resolveAgentTools,
|
|
132
|
+
resolveAndLoadAgentPlugins,
|
|
133
|
+
resolveDocumentsHooksDirectoryPath,
|
|
134
|
+
resolveDocumentsRulesDirectoryPath,
|
|
135
|
+
resolveDocumentsWorkflowsDirectoryPath,
|
|
136
|
+
resolveHooksConfigSearchPaths,
|
|
137
|
+
resolvePluginConfigSearchPaths,
|
|
138
|
+
resolveRulesConfigSearchPaths,
|
|
139
|
+
resolveSkillsConfigSearchPaths,
|
|
140
|
+
resolveWorkflowsConfigSearchPaths,
|
|
141
|
+
SKILLS_CONFIG_DIRECTORY_NAME,
|
|
142
|
+
toHookConfigFileName,
|
|
143
|
+
toPartialAgentConfig,
|
|
144
|
+
UnifiedConfigFileWatcher,
|
|
145
|
+
WORKFLOWS_CONFIG_DIRECTORY_NAME,
|
|
146
|
+
} from "./agents";
|
|
147
|
+
export {
|
|
148
|
+
createOAuthClientCallbacks,
|
|
149
|
+
type OAuthClientCallbacksOptions,
|
|
150
|
+
} from "./auth/client";
|
|
151
|
+
export {
|
|
152
|
+
createClineOAuthProvider,
|
|
153
|
+
getValidClineCredentials,
|
|
154
|
+
loginClineOAuth,
|
|
155
|
+
refreshClineToken,
|
|
156
|
+
} from "./auth/cline";
|
|
157
|
+
export {
|
|
158
|
+
getValidOpenAICodexCredentials,
|
|
159
|
+
isOpenAICodexTokenExpired,
|
|
160
|
+
loginOpenAICodex,
|
|
161
|
+
normalizeOpenAICodexCredentials,
|
|
162
|
+
openaiCodexOAuthProvider,
|
|
163
|
+
refreshOpenAICodexToken,
|
|
164
|
+
} from "./auth/codex";
|
|
165
|
+
export {
|
|
166
|
+
createOcaOAuthProvider,
|
|
167
|
+
createOcaRequestHeaders,
|
|
168
|
+
DEFAULT_EXTERNAL_IDCS_CLIENT_ID,
|
|
169
|
+
DEFAULT_EXTERNAL_IDCS_SCOPES,
|
|
170
|
+
DEFAULT_EXTERNAL_IDCS_URL,
|
|
171
|
+
DEFAULT_EXTERNAL_OCA_BASE_URL,
|
|
172
|
+
DEFAULT_INTERNAL_IDCS_CLIENT_ID,
|
|
173
|
+
DEFAULT_INTERNAL_IDCS_SCOPES,
|
|
174
|
+
DEFAULT_INTERNAL_IDCS_URL,
|
|
175
|
+
DEFAULT_INTERNAL_OCA_BASE_URL,
|
|
176
|
+
generateOcaOpcRequestId,
|
|
177
|
+
getValidOcaCredentials,
|
|
178
|
+
loginOcaOAuth,
|
|
179
|
+
OCI_HEADER_OPC_REQUEST_ID,
|
|
180
|
+
refreshOcaToken,
|
|
181
|
+
} from "./auth/oca";
|
|
182
|
+
export { startLocalOAuthServer } from "./auth/server";
|
|
183
|
+
export type {
|
|
184
|
+
OAuthCredentials,
|
|
185
|
+
OAuthLoginCallbacks,
|
|
186
|
+
OAuthPrompt,
|
|
187
|
+
OAuthProviderInterface,
|
|
188
|
+
OcaClientMetadata,
|
|
189
|
+
OcaMode,
|
|
190
|
+
OcaOAuthConfig,
|
|
191
|
+
OcaOAuthEnvironmentConfig,
|
|
192
|
+
OcaOAuthProviderOptions,
|
|
193
|
+
OcaTokenResolution,
|
|
194
|
+
} from "./auth/types";
|
|
195
|
+
export {
|
|
196
|
+
ClineCore,
|
|
197
|
+
type ClineCoreOptions,
|
|
198
|
+
type RpcOptions,
|
|
199
|
+
} from "./ClineCore";
|
|
200
|
+
export type {
|
|
201
|
+
ChatMessage,
|
|
202
|
+
ChatSessionConfig,
|
|
203
|
+
ChatSessionStatus,
|
|
204
|
+
ChatSummary,
|
|
205
|
+
ChatViewState,
|
|
206
|
+
} from "./chat/chat-schema";
|
|
207
|
+
export {
|
|
208
|
+
ChatMessageRoleSchema,
|
|
209
|
+
ChatMessageSchema,
|
|
210
|
+
ChatSessionConfigSchema,
|
|
211
|
+
ChatSessionStatusSchema,
|
|
212
|
+
ChatSummarySchema,
|
|
213
|
+
ChatViewStateSchema,
|
|
214
|
+
} from "./chat/chat-schema";
|
|
215
|
+
export type {
|
|
216
|
+
FastFileIndexOptions,
|
|
217
|
+
MentionEnricherOptions,
|
|
218
|
+
MentionEnrichmentResult,
|
|
219
|
+
} from "./input";
|
|
220
|
+
export {
|
|
221
|
+
enrichPromptWithMentions,
|
|
222
|
+
getFileIndex,
|
|
223
|
+
prewarmFileIndex,
|
|
224
|
+
} from "./input";
|
|
225
|
+
export {
|
|
226
|
+
hasMcpSettingsFile,
|
|
227
|
+
InMemoryMcpManager,
|
|
228
|
+
type LoadMcpSettingsOptions,
|
|
229
|
+
loadMcpSettingsFile,
|
|
230
|
+
type McpConnectionStatus,
|
|
231
|
+
type McpManager,
|
|
232
|
+
type McpManagerOptions,
|
|
233
|
+
type McpServerClient,
|
|
234
|
+
type McpServerClientFactory,
|
|
235
|
+
type McpServerRegistration,
|
|
236
|
+
type McpServerSnapshot,
|
|
237
|
+
type McpServerTransportConfig,
|
|
238
|
+
type McpSettingsFile,
|
|
239
|
+
type McpSseTransportConfig,
|
|
240
|
+
type McpStdioTransportConfig,
|
|
241
|
+
type McpStreamableHttpTransportConfig,
|
|
242
|
+
type RegisterMcpServersFromSettingsOptions,
|
|
243
|
+
registerMcpServersFromSettingsFile,
|
|
244
|
+
resolveDefaultMcpSettingsPath,
|
|
245
|
+
resolveMcpServerRegistrations,
|
|
246
|
+
} from "./mcp";
|
|
247
|
+
export {
|
|
248
|
+
addLocalProvider,
|
|
249
|
+
ensureCustomProvidersLoaded,
|
|
250
|
+
getLocalProviderModels,
|
|
251
|
+
listLocalProviders,
|
|
252
|
+
loginLocalProvider,
|
|
253
|
+
normalizeOAuthProvider,
|
|
254
|
+
resolveLocalClineAuthToken,
|
|
255
|
+
saveLocalProviderOAuthCredentials,
|
|
256
|
+
saveLocalProviderSettings,
|
|
257
|
+
} from "./providers/local-provider-service";
|
|
258
|
+
export type { AvailableRuntimeCommand } from "./runtime/commands";
|
|
259
|
+
export {
|
|
260
|
+
listAvailableRuntimeCommandsFromWatcher,
|
|
261
|
+
resolveRuntimeSlashCommandFromWatcher,
|
|
262
|
+
} from "./runtime/commands";
|
|
263
|
+
export {
|
|
264
|
+
formatRulesForSystemPrompt,
|
|
265
|
+
isRuleEnabled,
|
|
266
|
+
listEnabledRulesFromWatcher,
|
|
267
|
+
loadRulesForSystemPromptFromWatcher,
|
|
268
|
+
} from "./runtime/rules";
|
|
269
|
+
export {
|
|
270
|
+
createTeamName,
|
|
271
|
+
DefaultRuntimeBuilder,
|
|
272
|
+
} from "./runtime/runtime-builder";
|
|
273
|
+
export {
|
|
274
|
+
type SandboxCallOptions,
|
|
275
|
+
SubprocessSandbox,
|
|
276
|
+
type SubprocessSandboxOptions,
|
|
277
|
+
} from "./runtime/sandbox/subprocess-sandbox";
|
|
278
|
+
export type {
|
|
279
|
+
BuiltRuntime,
|
|
280
|
+
RuntimeBuilder,
|
|
281
|
+
RuntimeBuilderInput,
|
|
282
|
+
SessionRuntime,
|
|
283
|
+
} from "./runtime/session-runtime";
|
|
284
|
+
export type { AvailableSkill } from "./runtime/skills";
|
|
285
|
+
export {
|
|
286
|
+
listAvailableSkillsFromWatcher,
|
|
287
|
+
resolveSkillsSlashCommandFromWatcher,
|
|
288
|
+
} from "./runtime/skills";
|
|
289
|
+
export {
|
|
290
|
+
type DesktopToolApprovalOptions,
|
|
291
|
+
requestDesktopToolApproval,
|
|
292
|
+
} from "./runtime/tool-approval";
|
|
293
|
+
export type { AvailableWorkflow } from "./runtime/workflows";
|
|
294
|
+
export {
|
|
295
|
+
listAvailableWorkflowsFromWatcher,
|
|
296
|
+
resolveWorkflowSlashCommandFromWatcher,
|
|
297
|
+
} from "./runtime/workflows";
|
|
298
|
+
export { DefaultSessionManager } from "./session/default-session-manager";
|
|
299
|
+
export {
|
|
300
|
+
clearRpcDiscoveryIfAddressMatches,
|
|
301
|
+
type EnsureRpcRuntimeOptions,
|
|
302
|
+
ensureRpcRuntimeAddress,
|
|
303
|
+
isCompatibleRuntime,
|
|
304
|
+
type ResolveRpcRuntimeResult,
|
|
305
|
+
RPC_BUILD_ID_ENV,
|
|
306
|
+
RPC_DISCOVERY_PATH_ENV,
|
|
307
|
+
RPC_OWNER_ID_ENV,
|
|
308
|
+
RPC_STARTUP_LOCK_BYPASS_ENV,
|
|
309
|
+
type RpcDiscoveryRecord,
|
|
310
|
+
type RpcOwnerContext,
|
|
311
|
+
recordRpcDiscovery,
|
|
312
|
+
resolveEnsuredRpcRuntime,
|
|
313
|
+
resolveRpcOwnerContext,
|
|
314
|
+
resolveRpcRuntimeBuildKey,
|
|
315
|
+
waitForCompatibleRpcRuntime,
|
|
316
|
+
withRpcStartupLock,
|
|
317
|
+
} from "./session/rpc-runtime-ensure";
|
|
318
|
+
export { RpcCoreSessionService } from "./session/rpc-session-service";
|
|
319
|
+
export {
|
|
320
|
+
type RpcSpawnLease,
|
|
321
|
+
tryAcquireRpcSpawnLease,
|
|
322
|
+
} from "./session/rpc-spawn-lease";
|
|
323
|
+
export {
|
|
324
|
+
deriveSubsessionStatus,
|
|
325
|
+
makeSubSessionId,
|
|
326
|
+
makeTeamTaskSubSessionId,
|
|
327
|
+
sanitizeSessionToken,
|
|
328
|
+
} from "./session/session-graph";
|
|
329
|
+
export type {
|
|
330
|
+
SessionBackend,
|
|
331
|
+
SessionHost,
|
|
332
|
+
} from "./session/session-host";
|
|
333
|
+
export {
|
|
334
|
+
createSessionHost,
|
|
335
|
+
resolveSessionBackend,
|
|
336
|
+
} from "./session/session-host";
|
|
337
|
+
export type {
|
|
338
|
+
SendSessionInput,
|
|
339
|
+
SessionAccumulatedUsage,
|
|
340
|
+
SessionManager,
|
|
341
|
+
StartSessionInput,
|
|
342
|
+
StartSessionResult,
|
|
343
|
+
} from "./session/session-manager";
|
|
344
|
+
export type { SessionManifest } from "./session/session-manifest";
|
|
345
|
+
export type {
|
|
346
|
+
CreateRootSessionWithArtifactsInput,
|
|
347
|
+
RootSessionArtifacts,
|
|
348
|
+
} from "./session/session-service";
|
|
349
|
+
export { CoreSessionService } from "./session/session-service";
|
|
350
|
+
export {
|
|
351
|
+
createSqliteRpcSessionBackend,
|
|
352
|
+
SqliteRpcSessionBackend,
|
|
353
|
+
type SqliteRpcSessionBackendOptions,
|
|
354
|
+
} from "./session/sqlite-rpc-session-backend";
|
|
355
|
+
export {
|
|
356
|
+
accumulateUsageTotals,
|
|
357
|
+
createInitialAccumulatedUsage,
|
|
358
|
+
} from "./session/utils/usage";
|
|
359
|
+
export type {
|
|
360
|
+
WorkspaceManager,
|
|
361
|
+
WorkspaceManagerEvent,
|
|
362
|
+
} from "./session/workspace-manager";
|
|
363
|
+
export { InMemoryWorkspaceManager } from "./session/workspace-manager";
|
|
364
|
+
export type { WorkspaceManifest } from "./session/workspace-manifest";
|
|
365
|
+
export {
|
|
366
|
+
buildWorkspaceMetadata,
|
|
367
|
+
emptyWorkspaceManifest,
|
|
368
|
+
generateWorkspaceInfo,
|
|
369
|
+
normalizeWorkspacePath,
|
|
370
|
+
upsertWorkspaceInfo,
|
|
371
|
+
WorkspaceInfoSchema,
|
|
372
|
+
WorkspaceManifestSchema,
|
|
373
|
+
} from "./session/workspace-manifest";
|
|
374
|
+
export {
|
|
375
|
+
type MigrateLegacyProviderSettingsOptions,
|
|
376
|
+
type MigrateLegacyProviderSettingsResult,
|
|
377
|
+
migrateLegacyProviderSettings,
|
|
378
|
+
} from "./storage/provider-settings-legacy-migration";
|
|
379
|
+
export { ProviderSettingsManager } from "./storage/provider-settings-manager";
|
|
380
|
+
export { SqliteSessionStore } from "./storage/sqlite-session-store";
|
|
381
|
+
export {
|
|
382
|
+
SqliteTeamStore,
|
|
383
|
+
type SqliteTeamStoreOptions,
|
|
384
|
+
} from "./storage/team-store";
|
|
385
|
+
export {
|
|
386
|
+
buildTeamProgressSummary,
|
|
387
|
+
toTeamProgressLifecycleEvent,
|
|
388
|
+
} from "./team";
|
|
389
|
+
export type {
|
|
390
|
+
TelemetryAgentIdentityProperties,
|
|
391
|
+
TelemetryAgentKind,
|
|
392
|
+
} from "./telemetry/core-events";
|
|
393
|
+
export {
|
|
394
|
+
CORE_TELEMETRY_EVENTS,
|
|
395
|
+
captureAgentCreated,
|
|
396
|
+
captureAgentTeamCreated,
|
|
397
|
+
captureAuthFailed,
|
|
398
|
+
captureAuthLoggedOut,
|
|
399
|
+
captureAuthStarted,
|
|
400
|
+
captureAuthSucceeded,
|
|
401
|
+
captureConversationTurnEvent,
|
|
402
|
+
captureDiffEditFailure,
|
|
403
|
+
captureHookDiscovery,
|
|
404
|
+
captureMentionFailed,
|
|
405
|
+
captureMentionSearchResults,
|
|
406
|
+
captureMentionUsed,
|
|
407
|
+
captureModeSwitch,
|
|
408
|
+
captureProviderApiError,
|
|
409
|
+
captureSkillUsed,
|
|
410
|
+
captureSubagentExecution,
|
|
411
|
+
captureTaskCompleted,
|
|
412
|
+
captureTaskCreated,
|
|
413
|
+
captureTaskRestarted,
|
|
414
|
+
captureTokenUsage,
|
|
415
|
+
captureToolUsage,
|
|
416
|
+
identifyAccount,
|
|
417
|
+
} from "./telemetry/core-events";
|
|
418
|
+
export type { ITelemetryAdapter } from "./telemetry/ITelemetryAdapter";
|
|
419
|
+
export {
|
|
420
|
+
LoggerTelemetryAdapter,
|
|
421
|
+
type LoggerTelemetryAdapterOptions,
|
|
422
|
+
} from "./telemetry/LoggerTelemetryAdapter";
|
|
423
|
+
export { CORE_BUILD_VERSION } from "./version";
|
|
424
|
+
export async function loadOpenTelemetryAdapter() {
|
|
425
|
+
return import("./telemetry/index.js");
|
|
426
|
+
}
|
|
427
|
+
export {
|
|
428
|
+
TelemetryService,
|
|
429
|
+
type TelemetryServiceOptions,
|
|
430
|
+
} from "./telemetry/TelemetryService";
|
|
431
|
+
export {
|
|
432
|
+
ALL_DEFAULT_TOOL_NAMES,
|
|
433
|
+
type AskQuestionExecutor,
|
|
434
|
+
type CreateBuiltinToolsOptions,
|
|
435
|
+
type CreateDefaultToolsOptions,
|
|
436
|
+
createBuiltinTools,
|
|
437
|
+
createDefaultExecutors,
|
|
438
|
+
createDefaultTools,
|
|
439
|
+
createDefaultToolsWithPreset,
|
|
440
|
+
createToolPoliciesWithPreset,
|
|
441
|
+
type DefaultExecutorsOptions,
|
|
442
|
+
type DefaultToolName,
|
|
443
|
+
DefaultToolNames,
|
|
444
|
+
type DefaultToolsConfig,
|
|
445
|
+
type ToolExecutors,
|
|
446
|
+
type ToolPolicyPresetName,
|
|
447
|
+
type ToolPresetName,
|
|
448
|
+
ToolPresets,
|
|
449
|
+
} from "./tools";
|
|
450
|
+
// Compatibility barrel (legacy imports).
|
|
451
|
+
export type { RuntimeEnvironment, SessionEvent, StoredMessages } from "./types";
|
|
452
|
+
export type { SessionStatus } from "./types/common";
|
|
453
|
+
export { SESSION_STATUSES, SessionSource } from "./types/common";
|
|
454
|
+
export type {
|
|
455
|
+
CoreAgentMode,
|
|
456
|
+
CoreModelConfig,
|
|
457
|
+
CoreRuntimeFeatures,
|
|
458
|
+
CoreSessionConfig,
|
|
459
|
+
} from "./types/config";
|
|
460
|
+
export type {
|
|
461
|
+
CoreSessionEvent,
|
|
462
|
+
SessionChunkEvent,
|
|
463
|
+
SessionEndedEvent,
|
|
464
|
+
SessionTeamProgressEvent,
|
|
465
|
+
SessionToolEvent,
|
|
466
|
+
} from "./types/events";
|
|
467
|
+
export type {
|
|
468
|
+
ProviderTokenSource,
|
|
469
|
+
StoredProviderSettings,
|
|
470
|
+
StoredProviderSettingsEntry,
|
|
471
|
+
} from "./types/provider-settings";
|
|
472
|
+
export {
|
|
473
|
+
emptyStoredProviderSettings,
|
|
474
|
+
StoredProviderSettingsEntrySchema,
|
|
475
|
+
StoredProviderSettingsSchema,
|
|
476
|
+
} from "./types/provider-settings";
|
|
477
|
+
export type { SessionRecord, SessionRef } from "./types/sessions";
|
|
478
|
+
export type { ArtifactStore, SessionStore, TeamStore } from "./types/storage";
|
|
479
|
+
export type { WorkspaceInfo } from "./types/workspace";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FastFileIndexOptions {
|
|
2
|
+
ttlMs?: number;
|
|
3
|
+
}
|
|
4
|
+
export declare function getFileIndex(
|
|
5
|
+
cwd: string,
|
|
6
|
+
options?: FastFileIndexOptions,
|
|
7
|
+
): Promise<Set<string>>;
|
|
8
|
+
export declare function prewarmFileIndex(
|
|
9
|
+
cwd: string,
|
|
10
|
+
options?: FastFileIndexOptions,
|
|
11
|
+
): Promise<void>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { getFileIndex, prewarmFileIndex } from "./file-indexer";
|
|
6
|
+
|
|
7
|
+
vi.mock("node:worker_threads", async () => {
|
|
8
|
+
const actual = await vi.importActual<typeof import("node:worker_threads")>(
|
|
9
|
+
"node:worker_threads",
|
|
10
|
+
);
|
|
11
|
+
return {
|
|
12
|
+
...actual,
|
|
13
|
+
isMainThread: false,
|
|
14
|
+
parentPort: null,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
async function createTempWorkspace(): Promise<string> {
|
|
19
|
+
return mkdtemp(path.join(os.tmpdir(), "core-file-index-"));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe("file indexer", () => {
|
|
23
|
+
it("indexes files by relative posix path", async () => {
|
|
24
|
+
const cwd = await createTempWorkspace();
|
|
25
|
+
try {
|
|
26
|
+
await mkdir(path.join(cwd, "src"), { recursive: true });
|
|
27
|
+
await writeFile(path.join(cwd, "src", "main.ts"), "export {}\n", "utf8");
|
|
28
|
+
await writeFile(path.join(cwd, "README.md"), "# Demo\n", "utf8");
|
|
29
|
+
|
|
30
|
+
const index = await getFileIndex(cwd, { ttlMs: 0 });
|
|
31
|
+
expect(index.has("src/main.ts")).toBe(true);
|
|
32
|
+
expect(index.has("README.md")).toBe(true);
|
|
33
|
+
} finally {
|
|
34
|
+
await rm(cwd, { recursive: true, force: true });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("always excludes .git files from index", async () => {
|
|
39
|
+
const cwd = await createTempWorkspace();
|
|
40
|
+
try {
|
|
41
|
+
await mkdir(path.join(cwd, ".git"), { recursive: true });
|
|
42
|
+
await mkdir(path.join(cwd, "node_modules", "pkg"), { recursive: true });
|
|
43
|
+
await writeFile(path.join(cwd, ".git", "config"), "[core]\n", "utf8");
|
|
44
|
+
await writeFile(
|
|
45
|
+
path.join(cwd, "node_modules", "pkg", "index.js"),
|
|
46
|
+
"module.exports = {}\n",
|
|
47
|
+
"utf8",
|
|
48
|
+
);
|
|
49
|
+
await writeFile(
|
|
50
|
+
path.join(cwd, "app.ts"),
|
|
51
|
+
"export const app = 1\n",
|
|
52
|
+
"utf8",
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const index = await getFileIndex(cwd, { ttlMs: 0 });
|
|
56
|
+
expect(index.has("app.ts")).toBe(true);
|
|
57
|
+
expect(index.has(".git/config")).toBe(false);
|
|
58
|
+
} finally {
|
|
59
|
+
await rm(cwd, { recursive: true, force: true });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("prewarm rebuilds index and includes new files", async () => {
|
|
64
|
+
const cwd = await createTempWorkspace();
|
|
65
|
+
try {
|
|
66
|
+
await writeFile(
|
|
67
|
+
path.join(cwd, "first.ts"),
|
|
68
|
+
"export const first = 1\n",
|
|
69
|
+
"utf8",
|
|
70
|
+
);
|
|
71
|
+
const firstIndex = await getFileIndex(cwd, { ttlMs: 60_000 });
|
|
72
|
+
expect(firstIndex.has("first.ts")).toBe(true);
|
|
73
|
+
|
|
74
|
+
await writeFile(
|
|
75
|
+
path.join(cwd, "second.ts"),
|
|
76
|
+
"export const second = 2\n",
|
|
77
|
+
"utf8",
|
|
78
|
+
);
|
|
79
|
+
await prewarmFileIndex(cwd, { ttlMs: 60_000 });
|
|
80
|
+
|
|
81
|
+
const rebuilt = await getFileIndex(cwd, { ttlMs: 60_000 });
|
|
82
|
+
expect(rebuilt.has("second.ts")).toBe(true);
|
|
83
|
+
} finally {
|
|
84
|
+
await rm(cwd, { recursive: true, force: true });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("evicts stale workspace indexes after 10 minutes when multiple workspaces exist", async () => {
|
|
89
|
+
vi.useFakeTimers();
|
|
90
|
+
const firstWorkspace = await createTempWorkspace();
|
|
91
|
+
const secondWorkspace = await createTempWorkspace();
|
|
92
|
+
try {
|
|
93
|
+
await writeFile(
|
|
94
|
+
path.join(firstWorkspace, "first.ts"),
|
|
95
|
+
"export const first = 1\n",
|
|
96
|
+
"utf8",
|
|
97
|
+
);
|
|
98
|
+
await writeFile(
|
|
99
|
+
path.join(secondWorkspace, "second.ts"),
|
|
100
|
+
"export const second = 2\n",
|
|
101
|
+
"utf8",
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const firstIndex = await getFileIndex(firstWorkspace, { ttlMs: 60_000 });
|
|
105
|
+
expect(firstIndex.has("first.ts")).toBe(true);
|
|
106
|
+
|
|
107
|
+
await getFileIndex(secondWorkspace, { ttlMs: 60_000 });
|
|
108
|
+
vi.advanceTimersByTime(10 * 60_000 + 1);
|
|
109
|
+
|
|
110
|
+
await getFileIndex(secondWorkspace, { ttlMs: 60_000 });
|
|
111
|
+
await writeFile(
|
|
112
|
+
path.join(firstWorkspace, "later.ts"),
|
|
113
|
+
"export const later = 3\n",
|
|
114
|
+
"utf8",
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const rebuiltFirstIndex = await getFileIndex(firstWorkspace, {
|
|
118
|
+
ttlMs: 60_000,
|
|
119
|
+
});
|
|
120
|
+
expect(rebuiltFirstIndex.has("later.ts")).toBe(true);
|
|
121
|
+
} finally {
|
|
122
|
+
vi.useRealTimers();
|
|
123
|
+
await rm(firstWorkspace, { recursive: true, force: true });
|
|
124
|
+
await rm(secondWorkspace, { recursive: true, force: true });
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|