expandai 0.0.4 → 0.0.6
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/README.md +2 -2
- package/build/{esm/Install/Opencode → assets/opencode}/expandai-webfetch.js +22 -4
- package/build/dts/Mcp/RequestHeaders.d.ts +0 -1
- package/build/dts/Mcp/Server.d.ts +1 -2
- package/build/dts/index.d.ts +0 -1
- package/build/esm/index.js +193 -2
- package/build/esm/main.js +691 -200
- package/build/skills/expandai/SKILL.md +100 -8
- package/package.json +20 -12
- package/build/dts/ApiClient.d.ts +0 -165
- package/build/dts/ApiClient.d.ts.map +0 -1
- package/build/dts/Auth/Domain.d.ts +0 -95
- package/build/dts/Auth/Domain.d.ts.map +0 -1
- package/build/dts/Auth/ManualAuthorization.d.ts +0 -107
- package/build/dts/Auth/ManualAuthorization.d.ts.map +0 -1
- package/build/dts/Auth/PendingInit.d.ts +0 -35
- package/build/dts/Auth/PendingInit.d.ts.map +0 -1
- package/build/dts/Auth/Pkce.d.ts +0 -10
- package/build/dts/Auth/Pkce.d.ts.map +0 -1
- package/build/dts/Auth/SetupGrantAuthorization.d.ts +0 -34
- package/build/dts/Auth/SetupGrantAuthorization.d.ts.map +0 -1
- package/build/dts/Authentication.d.ts +0 -24
- package/build/dts/Authentication.d.ts.map +0 -1
- package/build/dts/BrowserOAuth.d.ts +0 -99
- package/build/dts/BrowserOAuth.d.ts.map +0 -1
- package/build/dts/CommandPath.d.ts +0 -2
- package/build/dts/CommandPath.d.ts.map +0 -1
- package/build/dts/Commands/Fetch.d.ts +0 -30
- package/build/dts/Commands/Fetch.d.ts.map +0 -1
- package/build/dts/Commands/Hook.d.ts +0 -17
- package/build/dts/Commands/Hook.d.ts.map +0 -1
- package/build/dts/Commands/Init.d.ts +0 -55
- package/build/dts/Commands/Init.d.ts.map +0 -1
- package/build/dts/Commands/Mcp.d.ts +0 -11
- package/build/dts/Commands/Mcp.d.ts.map +0 -1
- package/build/dts/Commands/McpRun.d.ts +0 -5
- package/build/dts/Commands/McpRun.d.ts.map +0 -1
- package/build/dts/Commands/Search.d.ts +0 -21
- package/build/dts/Commands/Search.d.ts.map +0 -1
- package/build/dts/Commands/Skill.d.ts +0 -12
- package/build/dts/Commands/Skill.d.ts.map +0 -1
- package/build/dts/Commands/Status.d.ts +0 -27
- package/build/dts/Commands/Status.d.ts.map +0 -1
- package/build/dts/Commands/Telemetry.d.ts +0 -7
- package/build/dts/Commands/Telemetry.d.ts.map +0 -1
- package/build/dts/Commands/Uninstall.d.ts +0 -9
- package/build/dts/Commands/Uninstall.d.ts.map +0 -1
- package/build/dts/Config.d.ts +0 -196
- package/build/dts/Config.d.ts.map +0 -1
- package/build/dts/Hook/Claude.d.ts +0 -13
- package/build/dts/Hook/Claude.d.ts.map +0 -1
- package/build/dts/Hook/Errors.d.ts +0 -20
- package/build/dts/Hook/Errors.d.ts.map +0 -1
- package/build/dts/Hook/Opencode.d.ts +0 -13
- package/build/dts/Hook/Opencode.d.ts.map +0 -1
- package/build/dts/Hook/SnapshotNote.d.ts +0 -12
- package/build/dts/Hook/SnapshotNote.d.ts.map +0 -1
- package/build/dts/Init/ClaudeAdapter.d.ts +0 -61
- package/build/dts/Init/ClaudeAdapter.d.ts.map +0 -1
- package/build/dts/Init/ClaudeProfile.d.ts +0 -77
- package/build/dts/Init/ClaudeProfile.d.ts.map +0 -1
- package/build/dts/Init/Domain.d.ts +0 -139
- package/build/dts/Init/Domain.d.ts.map +0 -1
- package/build/dts/Init/HarnessAdapter.d.ts +0 -33
- package/build/dts/Init/HarnessAdapter.d.ts.map +0 -1
- package/build/dts/Init/HarnessDetector.d.ts +0 -19
- package/build/dts/Init/HarnessDetector.d.ts.map +0 -1
- package/build/dts/Init/HarnessRegistry.d.ts +0 -50
- package/build/dts/Init/HarnessRegistry.d.ts.map +0 -1
- package/build/dts/Init/MutationTransaction.d.ts +0 -96
- package/build/dts/Init/MutationTransaction.d.ts.map +0 -1
- package/build/dts/Init/Service.d.ts +0 -72
- package/build/dts/Init/Service.d.ts.map +0 -1
- package/build/dts/Init/StandardAdapters.d.ts +0 -42
- package/build/dts/Init/StandardAdapters.d.ts.map +0 -1
- package/build/dts/Init/Status.d.ts +0 -149
- package/build/dts/Init/Status.d.ts.map +0 -1
- package/build/dts/Install/Claude/Hook.d.ts +0 -88
- package/build/dts/Install/Claude/Hook.d.ts.map +0 -1
- package/build/dts/Install/Claude/Mcp.d.ts +0 -48
- package/build/dts/Install/Claude/Mcp.d.ts.map +0 -1
- package/build/dts/Install/Claude/Skill.d.ts +0 -23
- package/build/dts/Install/Claude/Skill.d.ts.map +0 -1
- package/build/dts/Install/Codex/Mcp.d.ts +0 -45
- package/build/dts/Install/Codex/Mcp.d.ts.map +0 -1
- package/build/dts/Install/Codex/Skill.d.ts +0 -22
- package/build/dts/Install/Codex/Skill.d.ts.map +0 -1
- package/build/dts/Install/Cursor/Mcp.d.ts +0 -45
- package/build/dts/Install/Cursor/Mcp.d.ts.map +0 -1
- package/build/dts/Install/Cursor/Skill.d.ts +0 -29
- package/build/dts/Install/Cursor/Skill.d.ts.map +0 -1
- package/build/dts/Install/Domain.d.ts +0 -103
- package/build/dts/Install/Domain.d.ts.map +0 -1
- package/build/dts/Install/Hook.d.ts +0 -30
- package/build/dts/Install/Hook.d.ts.map +0 -1
- package/build/dts/Install/Mcp.d.ts +0 -28
- package/build/dts/Install/Mcp.d.ts.map +0 -1
- package/build/dts/Install/Opencode/Hook.d.ts +0 -24
- package/build/dts/Install/Opencode/Hook.d.ts.map +0 -1
- package/build/dts/Install/Opencode/Mcp.d.ts +0 -47
- package/build/dts/Install/Opencode/Mcp.d.ts.map +0 -1
- package/build/dts/Install/Opencode/Skill.d.ts +0 -26
- package/build/dts/Install/Opencode/Skill.d.ts.map +0 -1
- package/build/dts/Install/Skill.d.ts +0 -32
- package/build/dts/Install/Skill.d.ts.map +0 -1
- package/build/dts/Install/Uninstall.d.ts +0 -32
- package/build/dts/Install/Uninstall.d.ts.map +0 -1
- package/build/dts/MarkdownAnsi.d.ts +0 -29
- package/build/dts/MarkdownAnsi.d.ts.map +0 -1
- package/build/dts/Mcp/ExpandDocs.d.ts +0 -19
- package/build/dts/Mcp/ExpandDocs.d.ts.map +0 -1
- package/build/dts/Mcp/RequestHeaders.d.ts.map +0 -1
- package/build/dts/Mcp/Server.d.ts.map +0 -1
- package/build/dts/Mcp/Toolkit.d.ts +0 -3
- package/build/dts/Mcp/Toolkit.d.ts.map +0 -1
- package/build/dts/Mcp/tools/Citations.d.ts +0 -266
- package/build/dts/Mcp/tools/Citations.d.ts.map +0 -1
- package/build/dts/Mcp/tools/Fetch.d.ts +0 -168
- package/build/dts/Mcp/tools/Fetch.d.ts.map +0 -1
- package/build/dts/SecureFile.d.ts +0 -23
- package/build/dts/SecureFile.d.ts.map +0 -1
- package/build/dts/Snippets.d.ts +0 -18
- package/build/dts/Snippets.d.ts.map +0 -1
- package/build/dts/Telemetry.d.ts +0 -30
- package/build/dts/Telemetry.d.ts.map +0 -1
- package/build/dts/Version.d.ts +0 -2
- package/build/dts/Version.d.ts.map +0 -1
- package/build/dts/Xdg.d.ts +0 -11
- package/build/dts/Xdg.d.ts.map +0 -1
- package/build/dts/index.d.ts.map +0 -1
- package/build/dts/main.d.ts +0 -3
- package/build/dts/main.d.ts.map +0 -1
- package/build/esm/ApiClient.js +0 -305
- package/build/esm/ApiClient.js.map +0 -1
- package/build/esm/Auth/Domain.js +0 -56
- package/build/esm/Auth/Domain.js.map +0 -1
- package/build/esm/Auth/ManualAuthorization.js +0 -253
- package/build/esm/Auth/ManualAuthorization.js.map +0 -1
- package/build/esm/Auth/PendingInit.js +0 -267
- package/build/esm/Auth/PendingInit.js.map +0 -1
- package/build/esm/Auth/Pkce.js +0 -23
- package/build/esm/Auth/Pkce.js.map +0 -1
- package/build/esm/Auth/SetupGrantAuthorization.js +0 -91
- package/build/esm/Auth/SetupGrantAuthorization.js.map +0 -1
- package/build/esm/Authentication.js +0 -143
- package/build/esm/Authentication.js.map +0 -1
- package/build/esm/BrowserOAuth.js +0 -251
- package/build/esm/BrowserOAuth.js.map +0 -1
- package/build/esm/CommandPath.js +0 -31
- package/build/esm/CommandPath.js.map +0 -1
- package/build/esm/Commands/Fetch.js +0 -119
- package/build/esm/Commands/Fetch.js.map +0 -1
- package/build/esm/Commands/Hook.js +0 -20
- package/build/esm/Commands/Hook.js.map +0 -1
- package/build/esm/Commands/Init.js +0 -371
- package/build/esm/Commands/Init.js.map +0 -1
- package/build/esm/Commands/Mcp.js +0 -19
- package/build/esm/Commands/Mcp.js.map +0 -1
- package/build/esm/Commands/McpRun.js +0 -15
- package/build/esm/Commands/McpRun.js.map +0 -1
- package/build/esm/Commands/Search.js +0 -46
- package/build/esm/Commands/Search.js.map +0 -1
- package/build/esm/Commands/Skill.js +0 -17
- package/build/esm/Commands/Skill.js.map +0 -1
- package/build/esm/Commands/Status.js +0 -186
- package/build/esm/Commands/Status.js.map +0 -1
- package/build/esm/Commands/Telemetry.js +0 -23
- package/build/esm/Commands/Telemetry.js.map +0 -1
- package/build/esm/Commands/Uninstall.js +0 -28
- package/build/esm/Commands/Uninstall.js.map +0 -1
- package/build/esm/Config.js +0 -619
- package/build/esm/Config.js.map +0 -1
- package/build/esm/Hook/Claude.js +0 -74
- package/build/esm/Hook/Claude.js.map +0 -1
- package/build/esm/Hook/Errors.js +0 -18
- package/build/esm/Hook/Errors.js.map +0 -1
- package/build/esm/Hook/Opencode.js +0 -50
- package/build/esm/Hook/Opencode.js.map +0 -1
- package/build/esm/Hook/SnapshotNote.js +0 -65
- package/build/esm/Hook/SnapshotNote.js.map +0 -1
- package/build/esm/Init/ClaudeAdapter.js +0 -137
- package/build/esm/Init/ClaudeAdapter.js.map +0 -1
- package/build/esm/Init/ClaudeProfile.js +0 -344
- package/build/esm/Init/ClaudeProfile.js.map +0 -1
- package/build/esm/Init/Domain.js +0 -118
- package/build/esm/Init/Domain.js.map +0 -1
- package/build/esm/Init/HarnessAdapter.js +0 -21
- package/build/esm/Init/HarnessAdapter.js.map +0 -1
- package/build/esm/Init/HarnessDetector.js +0 -65
- package/build/esm/Init/HarnessDetector.js.map +0 -1
- package/build/esm/Init/HarnessRegistry.js +0 -58
- package/build/esm/Init/HarnessRegistry.js.map +0 -1
- package/build/esm/Init/MutationTransaction.js +0 -494
- package/build/esm/Init/MutationTransaction.js.map +0 -1
- package/build/esm/Init/Service.js +0 -319
- package/build/esm/Init/Service.js.map +0 -1
- package/build/esm/Init/StandardAdapters.js +0 -116
- package/build/esm/Init/StandardAdapters.js.map +0 -1
- package/build/esm/Init/Status.js +0 -215
- package/build/esm/Init/Status.js.map +0 -1
- package/build/esm/Install/Claude/Hook.js +0 -77
- package/build/esm/Install/Claude/Hook.js.map +0 -1
- package/build/esm/Install/Claude/Mcp.js +0 -101
- package/build/esm/Install/Claude/Mcp.js.map +0 -1
- package/build/esm/Install/Claude/Skill.js +0 -56
- package/build/esm/Install/Claude/Skill.js.map +0 -1
- package/build/esm/Install/Codex/Mcp.js +0 -97
- package/build/esm/Install/Codex/Mcp.js.map +0 -1
- package/build/esm/Install/Codex/Skill.js +0 -33
- package/build/esm/Install/Codex/Skill.js.map +0 -1
- package/build/esm/Install/Cursor/Mcp.js +0 -74
- package/build/esm/Install/Cursor/Mcp.js.map +0 -1
- package/build/esm/Install/Cursor/Skill.js +0 -40
- package/build/esm/Install/Cursor/Skill.js.map +0 -1
- package/build/esm/Install/Domain.js +0 -162
- package/build/esm/Install/Domain.js.map +0 -1
- package/build/esm/Install/Hook.js +0 -38
- package/build/esm/Install/Hook.js.map +0 -1
- package/build/esm/Install/Mcp.js +0 -40
- package/build/esm/Install/Mcp.js.map +0 -1
- package/build/esm/Install/Opencode/Hook.js +0 -44
- package/build/esm/Install/Opencode/Hook.js.map +0 -1
- package/build/esm/Install/Opencode/Mcp.js +0 -76
- package/build/esm/Install/Opencode/Mcp.js.map +0 -1
- package/build/esm/Install/Opencode/Skill.js +0 -37
- package/build/esm/Install/Opencode/Skill.js.map +0 -1
- package/build/esm/Install/Skill.js +0 -41
- package/build/esm/Install/Skill.js.map +0 -1
- package/build/esm/Install/Uninstall.js +0 -49
- package/build/esm/Install/Uninstall.js.map +0 -1
- package/build/esm/MarkdownAnsi.js +0 -142
- package/build/esm/MarkdownAnsi.js.map +0 -1
- package/build/esm/Mcp/ExpandDocs.js +0 -56
- package/build/esm/Mcp/ExpandDocs.js.map +0 -1
- package/build/esm/Mcp/RequestHeaders.js +0 -13
- package/build/esm/Mcp/RequestHeaders.js.map +0 -1
- package/build/esm/Mcp/Server.js +0 -12
- package/build/esm/Mcp/Server.js.map +0 -1
- package/build/esm/Mcp/Toolkit.js +0 -16
- package/build/esm/Mcp/Toolkit.js.map +0 -1
- package/build/esm/Mcp/tools/Citations.js +0 -193
- package/build/esm/Mcp/tools/Citations.js.map +0 -1
- package/build/esm/Mcp/tools/Fetch.js +0 -165
- package/build/esm/Mcp/tools/Fetch.js.map +0 -1
- package/build/esm/SecureFile.js +0 -36
- package/build/esm/SecureFile.js.map +0 -1
- package/build/esm/Snippets.js +0 -29
- package/build/esm/Snippets.js.map +0 -1
- package/build/esm/Telemetry.js +0 -157
- package/build/esm/Telemetry.js.map +0 -1
- package/build/esm/Version.js +0 -4
- package/build/esm/Version.js.map +0 -1
- package/build/esm/Xdg.js +0 -15
- package/build/esm/Xdg.js.map +0 -1
- package/build/esm/index.js.map +0 -1
- package/build/esm/main.js.map +0 -1
- package/src/ApiClient.ts +0 -450
- package/src/Auth/Domain.ts +0 -63
- package/src/Auth/ManualAuthorization.ts +0 -296
- package/src/Auth/PendingInit.ts +0 -338
- package/src/Auth/Pkce.ts +0 -26
- package/src/Auth/SetupGrantAuthorization.ts +0 -116
- package/src/Authentication.ts +0 -202
- package/src/BrowserOAuth.ts +0 -359
- package/src/CommandPath.ts +0 -30
- package/src/Commands/Fetch.ts +0 -188
- package/src/Commands/Hook.ts +0 -48
- package/src/Commands/Init.ts +0 -489
- package/src/Commands/Mcp.ts +0 -30
- package/src/Commands/McpRun.ts +0 -25
- package/src/Commands/Search.ts +0 -97
- package/src/Commands/Skill.ts +0 -30
- package/src/Commands/Status.ts +0 -228
- package/src/Commands/Telemetry.ts +0 -42
- package/src/Commands/Uninstall.ts +0 -38
- package/src/Config.ts +0 -840
- package/src/Hook/Claude.ts +0 -81
- package/src/Hook/Errors.ts +0 -19
- package/src/Hook/Opencode.ts +0 -58
- package/src/Hook/SnapshotNote.ts +0 -66
- package/src/Init/ClaudeAdapter.ts +0 -191
- package/src/Init/ClaudeProfile.ts +0 -453
- package/src/Init/Domain.ts +0 -153
- package/src/Init/HarnessAdapter.ts +0 -35
- package/src/Init/HarnessDetector.ts +0 -77
- package/src/Init/HarnessRegistry.ts +0 -87
- package/src/Init/MutationTransaction.ts +0 -747
- package/src/Init/Service.ts +0 -385
- package/src/Init/StandardAdapters.ts +0 -141
- package/src/Init/Status.ts +0 -253
- package/src/Install/Claude/Hook.ts +0 -123
- package/src/Install/Claude/Mcp.ts +0 -129
- package/src/Install/Claude/Skill.ts +0 -77
- package/src/Install/Codex/Mcp.ts +0 -114
- package/src/Install/Codex/Skill.ts +0 -44
- package/src/Install/Cursor/Mcp.ts +0 -85
- package/src/Install/Cursor/Skill.ts +0 -51
- package/src/Install/Domain.ts +0 -221
- package/src/Install/Hook.ts +0 -50
- package/src/Install/Mcp.ts +0 -71
- package/src/Install/Opencode/Hook.ts +0 -55
- package/src/Install/Opencode/Mcp.ts +0 -87
- package/src/Install/Opencode/Skill.ts +0 -48
- package/src/Install/Opencode/expandai-webfetch.d.ts +0 -23
- package/src/Install/Opencode/expandai-webfetch.js +0 -56
- package/src/Install/Skill.ts +0 -57
- package/src/Install/Uninstall.ts +0 -82
- package/src/MarkdownAnsi.ts +0 -162
- package/src/Mcp/ExpandDocs.ts +0 -62
- package/src/Mcp/RequestHeaders.ts +0 -16
- package/src/Mcp/Server.ts +0 -15
- package/src/Mcp/Toolkit.ts +0 -21
- package/src/Mcp/tools/Citations.ts +0 -219
- package/src/Mcp/tools/Fetch.ts +0 -203
- package/src/SecureFile.ts +0 -70
- package/src/Snippets.ts +0 -39
- package/src/Telemetry.ts +0 -186
- package/src/Version.ts +0 -3
- package/src/Xdg.ts +0 -18
- package/src/index.ts +0 -1
- package/src/main.ts +0 -305
package/src/Init/Status.ts
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { DateTime, Effect, Option, Schema } from 'effect'
|
|
2
|
-
import {
|
|
3
|
-
CLI_AUTHORIZATION_CLIENT_ID,
|
|
4
|
-
PendingInitCorrupt,
|
|
5
|
-
type PendingInitKey,
|
|
6
|
-
PendingInitRecord,
|
|
7
|
-
} from '../Auth/Domain.js'
|
|
8
|
-
import { PendingInitStore } from '../Auth/PendingInit.js'
|
|
9
|
-
import { authMethodState } from '../Authentication.js'
|
|
10
|
-
import { ConfigManager, ConfigParseError, CredentialStoreInsecure, NotAuthenticated } from '../Config.js'
|
|
11
|
-
import { CLI_VERSION } from '../Version.js'
|
|
12
|
-
import { CLAUDE_POLICY_READ_ONLY } from './ClaudeProfile.js'
|
|
13
|
-
import { InitHarness, InitScope } from './Domain.js'
|
|
14
|
-
import type { HarnessInspection } from './HarnessAdapter.js'
|
|
15
|
-
import { HarnessRegistry } from './HarnessRegistry.js'
|
|
16
|
-
|
|
17
|
-
const VERSION_PATTERN = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u
|
|
18
|
-
const BoundedVersion = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(64), Schema.pattern(VERSION_PATTERN))
|
|
19
|
-
|
|
20
|
-
export class StatusRequest extends Schema.Class<StatusRequest>('StatusRequest')({
|
|
21
|
-
harness: InitHarness,
|
|
22
|
-
scope: InitScope,
|
|
23
|
-
}) {}
|
|
24
|
-
|
|
25
|
-
const StatusAuth = Schema.Struct({
|
|
26
|
-
// `healthy` means a call would authenticate right now. An expired access
|
|
27
|
-
// token with a refresh token on disk reports `refresh_required`, because the
|
|
28
|
-
// renewal has not happened and can fail.
|
|
29
|
-
state: Schema.Literal('absent', 'unusable', 'refresh_required', 'healthy'),
|
|
30
|
-
healthy: Schema.Boolean,
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const PendingAuthorization = Schema.Union(
|
|
34
|
-
Schema.Struct({ state: Schema.Literal('none'), count: Schema.Literal(0) }),
|
|
35
|
-
Schema.Struct({
|
|
36
|
-
state: Schema.Literal('approval_pending'),
|
|
37
|
-
count: Schema.Literal(1),
|
|
38
|
-
approvalExpiresAt: Schema.DateTimeUtc,
|
|
39
|
-
}),
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const StatusInstallation = Schema.Struct({
|
|
43
|
-
configured: Schema.Boolean,
|
|
44
|
-
integrationVersion: Schema.optional(BoundedVersion),
|
|
45
|
-
components: Schema.Struct({
|
|
46
|
-
webfetchHook: Schema.Boolean,
|
|
47
|
-
runtimeSkill: Schema.Boolean,
|
|
48
|
-
mcp: Schema.Boolean,
|
|
49
|
-
}),
|
|
50
|
-
runtimeState: Schema.Literal('unverified', 'reload_required', 'blocked'),
|
|
51
|
-
reloadState: Schema.Literal('not_required', 'required'),
|
|
52
|
-
consentState: Schema.Literal('not_required', 'may_be_required'),
|
|
53
|
-
policyState: Schema.Literal('unverified', 'blocked'),
|
|
54
|
-
policyCodes: Schema.Array(Schema.Literal('managed_policy_blocked', 'target_read_only')).pipe(Schema.maxItems(1)),
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
export class StatusResult extends Schema.Class<StatusResult>('StatusResult')({
|
|
58
|
-
schemaVersion: Schema.Literal(1),
|
|
59
|
-
status: Schema.Literal('ok'),
|
|
60
|
-
harness: InitHarness,
|
|
61
|
-
scope: InitScope,
|
|
62
|
-
cli: Schema.Struct({ version: BoundedVersion }),
|
|
63
|
-
auth: StatusAuth,
|
|
64
|
-
pendingAuthorization: PendingAuthorization,
|
|
65
|
-
installation: StatusInstallation,
|
|
66
|
-
}) {}
|
|
67
|
-
|
|
68
|
-
export const StatusServiceErrorCode = Schema.Literal(
|
|
69
|
-
'credential_config_malformed',
|
|
70
|
-
'credential_storage_insecure',
|
|
71
|
-
'credential_health_failed',
|
|
72
|
-
'pending_state_malformed',
|
|
73
|
-
'pending_state_unavailable',
|
|
74
|
-
'harness_inspection_failed',
|
|
75
|
-
'invalid_status_result',
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
export class StatusServiceError extends Schema.TaggedError<StatusServiceError>()('StatusServiceError', {
|
|
79
|
-
code: StatusServiceErrorCode,
|
|
80
|
-
recoverable: Schema.Boolean,
|
|
81
|
-
}) {
|
|
82
|
-
get message() {
|
|
83
|
-
switch (this.code) {
|
|
84
|
-
case 'credential_config_malformed':
|
|
85
|
-
return 'Stored credential configuration is malformed.'
|
|
86
|
-
case 'credential_storage_insecure':
|
|
87
|
-
return 'Credential storage is not secure enough to inspect.'
|
|
88
|
-
case 'credential_health_failed':
|
|
89
|
-
return 'Stored credentials could not be inspected safely.'
|
|
90
|
-
case 'pending_state_malformed':
|
|
91
|
-
return 'Pending authorization state is malformed.'
|
|
92
|
-
case 'pending_state_unavailable':
|
|
93
|
-
return 'Pending authorization state could not be inspected safely.'
|
|
94
|
-
case 'harness_inspection_failed':
|
|
95
|
-
return 'The harness configuration could not be inspected safely.'
|
|
96
|
-
case 'invalid_status_result':
|
|
97
|
-
return 'Local diagnostics returned an invalid result.'
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function statusError(code: typeof StatusServiceErrorCode.Type, recoverable: boolean): StatusServiceError {
|
|
103
|
-
return new StatusServiceError({ code, recoverable })
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function mapCredentialError(error: unknown): StatusServiceError {
|
|
107
|
-
if (error instanceof ConfigParseError) return statusError('credential_config_malformed', false)
|
|
108
|
-
if (error instanceof CredentialStoreInsecure) return statusError('credential_storage_insecure', false)
|
|
109
|
-
return statusError('credential_health_failed', false)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function mapPendingError(error: unknown): StatusServiceError {
|
|
113
|
-
if (error instanceof CredentialStoreInsecure) return statusError('credential_storage_insecure', false)
|
|
114
|
-
return error instanceof PendingInitCorrupt
|
|
115
|
-
? statusError('pending_state_malformed', true)
|
|
116
|
-
: statusError('pending_state_unavailable', true)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function authStatus(configManager: ConfigManager) {
|
|
120
|
-
return Effect.gen(function* () {
|
|
121
|
-
const loaded = yield* Effect.either(configManager.loadConfig())
|
|
122
|
-
if (loaded._tag === 'Left') {
|
|
123
|
-
if (loaded.left instanceof NotAuthenticated) return { state: 'absent' as const, healthy: false }
|
|
124
|
-
return yield* mapCredentialError(loaded.left)
|
|
125
|
-
}
|
|
126
|
-
const now = yield* DateTime.now
|
|
127
|
-
const state = authMethodState(loaded.right.authMethod, now)
|
|
128
|
-
return { state, healthy: state === 'healthy' }
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function pendingStatus(record: Option.Option<PendingInitRecord>) {
|
|
133
|
-
return Effect.gen(function* () {
|
|
134
|
-
if (Option.isNone(record)) return { state: 'none' as const, count: 0 as const }
|
|
135
|
-
const now = DateTime.toEpochMillis(yield* DateTime.now)
|
|
136
|
-
if (DateTime.toEpochMillis(record.value.approvalExpiresAt) <= now) {
|
|
137
|
-
return { state: 'none' as const, count: 0 as const }
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
state: 'approval_pending' as const,
|
|
141
|
-
count: 1 as const,
|
|
142
|
-
approvalExpiresAt: DateTime.formatIso(record.value.approvalExpiresAt),
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function validateInspection(
|
|
148
|
-
harness: typeof InitHarness.Type,
|
|
149
|
-
inspection: HarnessInspection,
|
|
150
|
-
): Effect.Effect<HarnessInspection, StatusServiceError> {
|
|
151
|
-
const componentSet = new Set(inspection.components)
|
|
152
|
-
// Only the harnesses with a web-fetch hook install three components; cursor
|
|
153
|
-
// and codex are complete with two. Demanding three of them reported a
|
|
154
|
-
// correctly configured machine as an invalid result.
|
|
155
|
-
const expectsHook = harness === 'opencode'
|
|
156
|
-
const allComponents =
|
|
157
|
-
componentSet.has('runtime-skill') &&
|
|
158
|
-
componentSet.has('mcp') &&
|
|
159
|
-
(expectsHook ? componentSet.has('webfetch-hook') && componentSet.size === 3 : componentSet.size === 2)
|
|
160
|
-
const versionValid =
|
|
161
|
-
inspection.integrationVersion === undefined ||
|
|
162
|
-
(inspection.integrationVersion.length <= 64 && VERSION_PATTERN.test(inspection.integrationVersion))
|
|
163
|
-
const configuredValid = inspection.configured === allComponents
|
|
164
|
-
const runtimeValid = inspection.runtimeState !== 'observed'
|
|
165
|
-
return componentSet.size === inspection.components.length && versionValid && configuredValid && runtimeValid
|
|
166
|
-
? Effect.succeed(inspection)
|
|
167
|
-
: statusError('invalid_status_result', false)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function installationStatus(inspection: HarnessInspection, scope: typeof InitScope.Type) {
|
|
171
|
-
const components = new Set(inspection.components)
|
|
172
|
-
const policyBlocked = inspection.policyBlock !== undefined || inspection.runtimeState === 'blocked'
|
|
173
|
-
const policyCodes =
|
|
174
|
-
inspection.policyBlock === CLAUDE_POLICY_READ_ONLY
|
|
175
|
-
? (['target_read_only'] as const)
|
|
176
|
-
: policyBlocked
|
|
177
|
-
? (['managed_policy_blocked'] as const)
|
|
178
|
-
: []
|
|
179
|
-
const reloadRequired = !policyBlocked && inspection.runtimeState === 'reload_required'
|
|
180
|
-
return {
|
|
181
|
-
configured: inspection.configured,
|
|
182
|
-
...(inspection.integrationVersion === undefined ? {} : { integrationVersion: inspection.integrationVersion }),
|
|
183
|
-
components: {
|
|
184
|
-
webfetchHook: components.has('webfetch-hook'),
|
|
185
|
-
runtimeSkill: components.has('runtime-skill'),
|
|
186
|
-
mcp: components.has('mcp'),
|
|
187
|
-
},
|
|
188
|
-
runtimeState: policyBlocked
|
|
189
|
-
? ('blocked' as const)
|
|
190
|
-
: reloadRequired
|
|
191
|
-
? ('reload_required' as const)
|
|
192
|
-
: ('unverified' as const),
|
|
193
|
-
reloadState: reloadRequired ? ('required' as const) : ('not_required' as const),
|
|
194
|
-
consentState: scope === 'project' ? ('may_be_required' as const) : ('not_required' as const),
|
|
195
|
-
policyState: policyBlocked ? ('blocked' as const) : ('unverified' as const),
|
|
196
|
-
policyCodes,
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export class StatusService extends Effect.Service<StatusService>()('@expandai/cli/Init/StatusService', {
|
|
201
|
-
dependencies: [ConfigManager.Default, PendingInitStore.Default, HarnessRegistry.Default],
|
|
202
|
-
effect: Effect.gen(function* () {
|
|
203
|
-
const configManager = yield* ConfigManager
|
|
204
|
-
const pendingStore = yield* PendingInitStore
|
|
205
|
-
const registry = yield* HarnessRegistry
|
|
206
|
-
|
|
207
|
-
const run = Effect.fn('StatusService.run')(function* (request: StatusRequest) {
|
|
208
|
-
yield* Effect.annotateCurrentSpan({ harness: request.harness, scope: request.scope })
|
|
209
|
-
return yield* Effect.gen(function* () {
|
|
210
|
-
yield* configManager
|
|
211
|
-
.inspectSecureStorage()
|
|
212
|
-
.pipe(Effect.withTracerEnabled(false), Effect.mapError(mapCredentialError))
|
|
213
|
-
const auth = yield* authStatus(configManager).pipe(Effect.withTracerEnabled(false))
|
|
214
|
-
const apiUrl = yield* configManager
|
|
215
|
-
.getApiUrl()
|
|
216
|
-
.pipe(Effect.withTracerEnabled(false), Effect.mapError(mapCredentialError))
|
|
217
|
-
const canonicalScopeRoot = yield* pendingStore
|
|
218
|
-
.canonicalScopeRoot(request.scope)
|
|
219
|
-
.pipe(Effect.withTracerEnabled(false), Effect.mapError(mapPendingError))
|
|
220
|
-
const key: PendingInitKey = {
|
|
221
|
-
apiOrigin: apiUrl.origin,
|
|
222
|
-
clientId: CLI_AUTHORIZATION_CLIENT_ID,
|
|
223
|
-
harness: 'agent-harnesses',
|
|
224
|
-
scope: request.scope,
|
|
225
|
-
canonicalScopeRoot,
|
|
226
|
-
}
|
|
227
|
-
const pending = yield* pendingStore
|
|
228
|
-
.peek(key)
|
|
229
|
-
.pipe(Effect.withTracerEnabled(false), Effect.mapError(mapPendingError))
|
|
230
|
-
const inspection = yield* registry.inspect(request.harness, request.scope).pipe(
|
|
231
|
-
Effect.withTracerEnabled(false),
|
|
232
|
-
Effect.mapError(() => statusError('harness_inspection_failed', true)),
|
|
233
|
-
Effect.flatMap((inspection) => validateInspection(request.harness, inspection)),
|
|
234
|
-
)
|
|
235
|
-
const candidate = {
|
|
236
|
-
schemaVersion: 1 as const,
|
|
237
|
-
status: 'ok' as const,
|
|
238
|
-
harness: request.harness,
|
|
239
|
-
scope: request.scope,
|
|
240
|
-
cli: { version: CLI_VERSION },
|
|
241
|
-
auth,
|
|
242
|
-
pendingAuthorization: yield* pendingStatus(pending),
|
|
243
|
-
installation: installationStatus(inspection, request.scope),
|
|
244
|
-
}
|
|
245
|
-
return yield* Schema.decodeUnknown(StatusResult)(candidate).pipe(
|
|
246
|
-
Effect.mapError(() => statusError('invalid_status_result', false)),
|
|
247
|
-
)
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
return { run } as const
|
|
252
|
-
}),
|
|
253
|
-
}) {}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os'
|
|
2
|
-
import { Config, Console, Effect, Match, Schema } from 'effect'
|
|
3
|
-
import { type CliCommand, ConfigIo, cliShellCommand, DIRECT_CLI } from '../Domain.js'
|
|
4
|
-
import type { InstallScope } from '../Mcp.js'
|
|
5
|
-
|
|
6
|
-
/** Claude Code WebFetch hook invocation persisted in harness settings. */
|
|
7
|
-
export const HOOK_INVOCATION = 'expandai hook claude-code'
|
|
8
|
-
export const HOOK_COMMAND = HOOK_INVOCATION
|
|
9
|
-
const HOOK_ARGS = ['hook', 'claude-code'] as const
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The hook line for a resolved CLI. Defaults to the bare `expandai` command;
|
|
13
|
-
* when the CLI is not on PATH — an `npx expandai init` with no global install —
|
|
14
|
-
* `CliInvocation` resolves to the npx form and the written hook stays runnable.
|
|
15
|
-
*/
|
|
16
|
-
export function hookCommandFor(cli: CliCommand = DIRECT_CLI): string {
|
|
17
|
-
return cliShellCommand(cli, HOOK_ARGS)
|
|
18
|
-
}
|
|
19
|
-
export const WEBFETCH_MATCHER = 'WebFetch'
|
|
20
|
-
|
|
21
|
-
export const HookCommandEntry = Schema.Struct(
|
|
22
|
-
{
|
|
23
|
-
type: Schema.Literal('command'),
|
|
24
|
-
command: Schema.String,
|
|
25
|
-
expandaiProfileVersion: Schema.optional(Schema.String),
|
|
26
|
-
/** Whether this install added the `WebFetch` deny rule — see `makeExpandaiMatcher`. */
|
|
27
|
-
expandaiManagedDeny: Schema.optional(Schema.Boolean),
|
|
28
|
-
},
|
|
29
|
-
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
export const HookMatcher = Schema.Struct(
|
|
33
|
-
{
|
|
34
|
-
matcher: Schema.optional(Schema.String),
|
|
35
|
-
hooks: Schema.Array(HookCommandEntry),
|
|
36
|
-
},
|
|
37
|
-
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
const HooksSection = Schema.Struct(
|
|
41
|
-
{ PreToolUse: Schema.optional(Schema.Array(HookMatcher)) },
|
|
42
|
-
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
const PermissionsSection = Schema.Struct(
|
|
46
|
-
{ deny: Schema.optional(Schema.Array(Schema.String)) },
|
|
47
|
-
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
export const SettingsSchema = Schema.parseJson(
|
|
51
|
-
Schema.Struct(
|
|
52
|
-
{
|
|
53
|
-
hooks: Schema.optionalWith(HooksSection, { default: () => ({}) as typeof HooksSection.Type }),
|
|
54
|
-
permissions: Schema.optional(PermissionsSection),
|
|
55
|
-
},
|
|
56
|
-
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
57
|
-
),
|
|
58
|
-
{ space: 2 },
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
export interface ClaudeHookPlan {
|
|
62
|
-
readonly changed: boolean
|
|
63
|
-
readonly settings: typeof SettingsSchema.Type
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function isExpandaiHookCommand(command: string): boolean {
|
|
67
|
-
const value = command.trim()
|
|
68
|
-
const invocation = String.raw`expandai(?:\.exe)?\s+hook\s+(?:claude-code|claude)`
|
|
69
|
-
const direct = new RegExp(String.raw`^(?:npx\s+-y\s+)?${invocation}$`, 'u')
|
|
70
|
-
const absolute = new RegExp(
|
|
71
|
-
String.raw`^(?:"(?:[A-Za-z]:\\|/)[^"]*[\\/]expandai(?:\.exe)?"|'(?:[A-Za-z]:\\|/)[^']*[\\/]expandai(?:\.exe)?'|(?:[A-Za-z]:\\|/)[^\s]*[\\/]expandai(?:\.exe)?)\s+hook\s+(?:claude-code|claude)$`,
|
|
72
|
-
'u',
|
|
73
|
-
)
|
|
74
|
-
const shellFallback =
|
|
75
|
-
/^if\s+command\s+-v\s+expandai\s+>\/dev\/null\s+2>&1;\s*then\s+expandai\s+hook\s+(?:claude-code|claude);\s*else\s+npx\s+-y\s+expandai\s+hook\s+(?:claude-code|claude);\s*fi$/u
|
|
76
|
-
return direct.test(value) || absolute.test(value) || shellFallback.test(value)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Nothing here writes to `settings.json`, and nothing here removes from it.
|
|
81
|
-
*
|
|
82
|
-
* A `WebFetch` deny entry is a bare string with nowhere to record who wrote it,
|
|
83
|
-
* and our hook is not proof either: `hook install` used to write the hook on its
|
|
84
|
-
* own, so a settings file carrying our hook and a `WebFetch` deny may well hold a
|
|
85
|
-
* rule the user added afterwards. Removing it would revoke a restriction its
|
|
86
|
-
* owner chose. Since Claude Code no longer gets a hook or a deny rule from us,
|
|
87
|
-
* there is nothing of ours left to clean up, and guessing is the only thing a
|
|
88
|
-
* cleanup pass could do.
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
export class ClaudeHook extends Effect.Service<ClaudeHook>()('@expandai/cli/Install/Claude/Hook', {
|
|
92
|
-
dependencies: [ConfigIo.Default],
|
|
93
|
-
effect: Effect.gen(function* () {
|
|
94
|
-
const home = yield* Config.string('HOME').pipe(Config.withDefault(homedir()))
|
|
95
|
-
const cwd = yield* Config.string('PWD').pipe(Config.withDefault(process.cwd()))
|
|
96
|
-
|
|
97
|
-
const pathFor = Effect.fn(function* (scope: InstallScope) {
|
|
98
|
-
return yield* Match.value(scope).pipe(
|
|
99
|
-
Match.when('global', () => Effect.succeed(`${home}/.claude/settings.json`)),
|
|
100
|
-
Match.when('project', () => Effect.succeed(`${cwd}/.claude/settings.json`)),
|
|
101
|
-
Match.exhaustive,
|
|
102
|
-
)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
const NOTICE =
|
|
106
|
-
'expandai does not install a WebFetch hook for Claude Code — the MCP server and runtime skill replace it, and neither can disable a built-in tool.'
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Kept as a no-op rather than deleted so `hook install|uninstall claude-code`
|
|
110
|
-
* still resolves. Both say what the profile is instead of touching
|
|
111
|
-
* `settings.json`, which expandai no longer writes for Claude Code.
|
|
112
|
-
*/
|
|
113
|
-
const install = Effect.fn('ClaudeHook.install')(function* (_scope: InstallScope) {
|
|
114
|
-
yield* Console.log(NOTICE)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const uninstall = Effect.fn('ClaudeHook.uninstall')(function* (_scope: InstallScope) {
|
|
118
|
-
yield* Console.log(NOTICE)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
return { install, uninstall, pathFor } as const
|
|
122
|
-
}),
|
|
123
|
-
}) {}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os'
|
|
2
|
-
import { Config, Console, Effect, Match, Record, Schema } from 'effect'
|
|
3
|
-
import {
|
|
4
|
-
type CliCommand,
|
|
5
|
-
ConfigIo,
|
|
6
|
-
DIRECT_CLI,
|
|
7
|
-
McpParseError,
|
|
8
|
-
McpServersConfigSchema,
|
|
9
|
-
McpWriteError,
|
|
10
|
-
SERVER_KEY,
|
|
11
|
-
} from '../Domain.js'
|
|
12
|
-
import type { InstallScope } from '../Mcp.js'
|
|
13
|
-
|
|
14
|
-
/** Claude Code MCP descriptor stored under the Expand-owned server key. */
|
|
15
|
-
export class Entry extends Schema.Class<Entry>('ClaudeMcpEntry')({
|
|
16
|
-
type: Schema.Literal('stdio'),
|
|
17
|
-
command: Schema.NonEmptyTrimmedString,
|
|
18
|
-
args: Schema.Array(Schema.String),
|
|
19
|
-
env: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.String })),
|
|
20
|
-
}) {}
|
|
21
|
-
|
|
22
|
-
export interface ClaudeMcpPlan {
|
|
23
|
-
readonly changed: boolean
|
|
24
|
-
readonly config: typeof McpServersConfigSchema.Type
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const MCP_ARGS = ['mcp', 'run'] as const
|
|
28
|
-
|
|
29
|
-
/** Claude execs the descriptor directly, so `command`/`args` stay separate. */
|
|
30
|
-
export function claudeMcpEntry(cli: CliCommand = DIRECT_CLI): Entry {
|
|
31
|
-
return new Entry({
|
|
32
|
-
type: 'stdio',
|
|
33
|
-
command: cli.command,
|
|
34
|
-
args: [...cli.args, ...MCP_ARGS],
|
|
35
|
-
env: { EXPANDAI_HARNESS: 'claude-code' },
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const CLAUDE_MCP_ENTRY = claudeMcpEntry()
|
|
40
|
-
|
|
41
|
-
function isUnknownRecord(value: unknown): value is Record<string, unknown> {
|
|
42
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function isCurrentEntry(value: unknown, expected: Entry): boolean {
|
|
46
|
-
if (!isUnknownRecord(value)) return false
|
|
47
|
-
const args = value.args
|
|
48
|
-
const env = value.env
|
|
49
|
-
return (
|
|
50
|
-
value.type === expected.type &&
|
|
51
|
-
value.command === expected.command &&
|
|
52
|
-
Array.isArray(args) &&
|
|
53
|
-
args.length === expected.args.length &&
|
|
54
|
-
args.every((arg, index) => arg === expected.args[index]) &&
|
|
55
|
-
isUnknownRecord(env) &&
|
|
56
|
-
env.EXPANDAI_HARNESS === 'claude-code'
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function planClaudeMcp(config: typeof McpServersConfigSchema.Type, cli: CliCommand = DIRECT_CLI): ClaudeMcpPlan {
|
|
61
|
-
const entry = claudeMcpEntry(cli)
|
|
62
|
-
if (isCurrentEntry(config.mcpServers[SERVER_KEY], entry)) return { changed: false, config }
|
|
63
|
-
return {
|
|
64
|
-
changed: true,
|
|
65
|
-
config: {
|
|
66
|
-
...config,
|
|
67
|
-
mcpServers: { ...config.mcpServers, [SERVER_KEY]: entry },
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function planClaudeMcpRemoval(config: typeof McpServersConfigSchema.Type): ClaudeMcpPlan {
|
|
73
|
-
if (!(SERVER_KEY in config.mcpServers)) return { changed: false, config }
|
|
74
|
-
return {
|
|
75
|
-
changed: true,
|
|
76
|
-
config: { ...config, mcpServers: Record.remove(config.mcpServers, SERVER_KEY) },
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class ClaudeMcp extends Effect.Service<ClaudeMcp>()('@expandai/cli/Install/Claude/Mcp', {
|
|
81
|
-
dependencies: [ConfigIo.Default],
|
|
82
|
-
effect: Effect.gen(function* () {
|
|
83
|
-
const io = yield* ConfigIo
|
|
84
|
-
const home = yield* Config.string('HOME').pipe(Config.withDefault(homedir()))
|
|
85
|
-
const cwd = yield* Config.string('PWD').pipe(Config.withDefault(process.cwd()))
|
|
86
|
-
|
|
87
|
-
const pathFor = Effect.fn(function* (scope: InstallScope) {
|
|
88
|
-
return yield* Match.value(scope).pipe(
|
|
89
|
-
Match.when('global', () => Effect.succeed(`${home}/.claude.json`)),
|
|
90
|
-
Match.when('project', () => Effect.succeed(`${cwd}/.mcp.json`)),
|
|
91
|
-
Match.exhaustive,
|
|
92
|
-
)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
const readConfig = Effect.fn(function* (file: string) {
|
|
96
|
-
return yield* io
|
|
97
|
-
.read(file, McpServersConfigSchema)
|
|
98
|
-
.pipe(Effect.mapError((error) => new McpParseError({ path: file, error })))
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const writeConfig = Effect.fn(function* (file: string, value: unknown) {
|
|
102
|
-
yield* io
|
|
103
|
-
.write(file, value, McpServersConfigSchema)
|
|
104
|
-
.pipe(Effect.mapError((error) => new McpWriteError({ path: file, error })))
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
const install = Effect.fn(function* (scope: InstallScope) {
|
|
108
|
-
const file = yield* pathFor(scope)
|
|
109
|
-
const plan = planClaudeMcp(yield* readConfig(file))
|
|
110
|
-
if (plan.changed) yield* writeConfig(file, plan.config)
|
|
111
|
-
yield* Console.log(`Installed expandai MCP server into ${file}`)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
const uninstall = Effect.fn(function* (scope: InstallScope) {
|
|
115
|
-
const file = yield* pathFor(scope)
|
|
116
|
-
const plan = planClaudeMcpRemoval(yield* readConfig(file))
|
|
117
|
-
if (!plan.changed) return
|
|
118
|
-
yield* writeConfig(file, plan.config)
|
|
119
|
-
yield* Console.log(`Removed expandai MCP server from ${file}`)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
const isInstalled = Effect.fn(function* (scope: InstallScope) {
|
|
123
|
-
const file = yield* pathFor(scope)
|
|
124
|
-
return SERVER_KEY in (yield* readConfig(file)).mcpServers
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
return { install, uninstall, isInstalled, pathFor } as const
|
|
128
|
-
}),
|
|
129
|
-
}) {}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os'
|
|
2
|
-
import { FileSystem, Path } from '@effect/platform'
|
|
3
|
-
import { NodeFileSystem, NodePath } from '@effect/platform-node'
|
|
4
|
-
import { Config, Effect, Match } from 'effect'
|
|
5
|
-
import { CLI_VERSION } from '../../Version.js'
|
|
6
|
-
import type { InstallScope } from '../Mcp.js'
|
|
7
|
-
|
|
8
|
-
export const SKILL_NAME = 'expandai'
|
|
9
|
-
export const SKILL_FILE_NAME = 'SKILL.md'
|
|
10
|
-
const PROFILE_VERSION_LINE = /^(\s*expandai-profile-version:\s*).+$/mu
|
|
11
|
-
|
|
12
|
-
export interface ClaudeSkillPlan {
|
|
13
|
-
readonly changed: boolean
|
|
14
|
-
readonly text: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function renderClaudeSkill(source: string, profileVersion: string = CLI_VERSION): string {
|
|
18
|
-
if (!PROFILE_VERSION_LINE.test(source)) {
|
|
19
|
-
throw new Error('Bundled Expand skill is missing expandai-profile-version metadata')
|
|
20
|
-
}
|
|
21
|
-
return source.replace(PROFILE_VERSION_LINE, `$1${profileVersion}`)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function planClaudeSkill(
|
|
25
|
-
current: string | undefined,
|
|
26
|
-
source: string,
|
|
27
|
-
profileVersion: string = CLI_VERSION,
|
|
28
|
-
): ClaudeSkillPlan {
|
|
29
|
-
const text = renderClaudeSkill(source, profileVersion)
|
|
30
|
-
return { changed: current !== text, text }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const makeClaudeSkill = Effect.gen(function* () {
|
|
34
|
-
const fileSystem = yield* FileSystem.FileSystem
|
|
35
|
-
const path = yield* Path.Path
|
|
36
|
-
const home = yield* Config.string('HOME').pipe(Config.withDefault(homedir()))
|
|
37
|
-
const cwd = yield* Config.string('PWD').pipe(Config.withDefault(process.cwd()))
|
|
38
|
-
const moduleFile = yield* path.fromFileUrl(new URL(import.meta.url))
|
|
39
|
-
const sourceFile = path.resolve(path.dirname(moduleFile), '..', '..', '..', 'skills', SKILL_NAME, SKILL_FILE_NAME)
|
|
40
|
-
|
|
41
|
-
const pathFor = Effect.fn(function* (scope: InstallScope) {
|
|
42
|
-
return yield* Match.value(scope).pipe(
|
|
43
|
-
Match.when('global', () => Effect.succeed(path.join(home, '.claude', 'skills', SKILL_NAME))),
|
|
44
|
-
Match.when('project', () => Effect.succeed(path.join(cwd, '.claude', 'skills', SKILL_NAME))),
|
|
45
|
-
Match.exhaustive,
|
|
46
|
-
)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const source = Effect.fn('ClaudeSkill.source')(function* () {
|
|
50
|
-
return yield* fileSystem.readFileString(sourceFile)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const install = Effect.fn('ClaudeSkill.install')(function* (scope: InstallScope) {
|
|
54
|
-
const target = yield* pathFor(scope)
|
|
55
|
-
const targetFile = path.join(target, SKILL_FILE_NAME)
|
|
56
|
-
const current = (yield* fileSystem.exists(targetFile)) ? yield* fileSystem.readFileString(targetFile) : undefined
|
|
57
|
-
const plan = planClaudeSkill(current, yield* source())
|
|
58
|
-
if (plan.changed) {
|
|
59
|
-
yield* fileSystem.makeDirectory(target, { recursive: true })
|
|
60
|
-
yield* fileSystem.writeFileString(targetFile, plan.text)
|
|
61
|
-
}
|
|
62
|
-
return target
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const uninstall = Effect.fn('ClaudeSkill.uninstall')(function* (scope: InstallScope) {
|
|
66
|
-
const target = yield* pathFor(scope)
|
|
67
|
-
if (yield* fileSystem.exists(target)) yield* fileSystem.remove(target, { recursive: true })
|
|
68
|
-
return target
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
return { install, uninstall, pathFor, source } as const
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
export class ClaudeSkill extends Effect.Service<ClaudeSkill>()('@expandai/cli/Install/Claude/Skill', {
|
|
75
|
-
dependencies: [NodeFileSystem.layer, NodePath.layer],
|
|
76
|
-
effect: makeClaudeSkill,
|
|
77
|
-
}) {}
|