@hop-top/kit 0.5.0-alpha.7 → 0.5.0-alpha.9
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 +38 -0
- package/dist/alias-D9_qFlyP.d.ts +174 -0
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +8 -2
- package/dist/{chunk-263IZ6Z6.js → chunk-B4ULGCCN.js} +43 -154
- package/dist/{chunk-DIDN4X5C.js → chunk-BLS2OBIQ.js} +99 -20
- package/dist/{chunk-JTMPNXVQ.js → chunk-P6GRX4RV.js} +486 -83
- package/dist/chunk-UZ65A27P.js +147 -0
- package/dist/{completion-sDKVXPUL.d.ts → completion-csVun6SP.d.ts} +4 -1
- package/dist/completion.d.ts +1 -1
- package/dist/{index-B-pqGHhU.d.ts → index-CaOXdl38.d.ts} +337 -24
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -4
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +31 -2
- package/dist/{toolspec-UrWnoJ3Y.d.ts → toolspec-96rkLfsh.d.ts} +7 -2
- package/dist/toolspec.d.ts +1 -1
- package/dist/toolspec.js +3 -2
- package/package.json +1 -1
- package/src/alias.conformance.test.ts +250 -0
- package/src/alias.test.ts +96 -1
- package/src/alias.ts +179 -19
- package/src/completion.ts +4 -1
- package/src/mcp/README.md +6 -0
- package/src/mcp/args-separator.test.ts +164 -0
- package/src/mcp/args.test.ts +223 -0
- package/src/mcp/args.ts +160 -0
- package/src/mcp/audit.test.ts +520 -0
- package/src/mcp/audit.ts +70 -0
- package/src/mcp/bridge.test.ts +72 -0
- package/src/mcp/bridge.ts +50 -5
- package/src/mcp/conformance.test.ts +1 -1
- package/src/mcp/dispatch.ts +48 -2
- package/src/mcp/index.ts +33 -1
- package/src/mcp/legacy-notify.test.ts +59 -0
- package/src/mcp/legacy.ts +55 -15
- package/src/mcp/modern-confirm.ts +42 -10
- package/src/mcp/modern.ts +99 -35
- package/src/mcp/stdio.test.ts +313 -0
- package/src/mcp/stdio.ts +254 -0
- package/src/mcp/toolname.test.ts +147 -0
- package/src/mcp/types.ts +125 -18
- package/src/toolspec-internal.ts +24 -0
- package/src/toolspec-manifest.test.ts +25 -0
- package/src/toolspec-manifest.ts +5 -1
- package/src/toolspec.from-command.test.ts +51 -0
- package/src/toolspec.ts +29 -15
- package/dist/alias-BsJ2jGqQ.d.ts +0 -96
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var _chunkGGWJRWWAjs = require('./chunk-GGWJRWWA.js');
|
|
|
6
6
|
var _chunkBRNEKPWXjs = require('./chunk-BRNEKPWX.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkB4ULGCCNjs = require('./chunk-B4ULGCCN.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkWWUKGJB5js = require('./chunk-WWUKGJB5.js');
|
|
@@ -15,7 +15,8 @@ var _chunkWWUKGJB5js = require('./chunk-WWUKGJB5.js');
|
|
|
15
15
|
var _chunkL23O2FFEjs = require('./chunk-L23O2FFE.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkP6GRX4RVjs = require('./chunk-P6GRX4RV.js');
|
|
19
|
+
require('./chunk-UZ65A27P.js');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
var _chunkYOBAUCVNjs = require('./chunk-YOBAUCVN.js');
|
|
@@ -70,7 +71,7 @@ var _chunkQJVSKKRQjs = require('./chunk-QJVSKKRQ.js');
|
|
|
70
71
|
var _chunk4UE5TCMQjs = require('./chunk-4UE5TCMQ.js');
|
|
71
72
|
|
|
72
73
|
|
|
73
|
-
var
|
|
74
|
+
var _chunkBLS2OBIQjs = require('./chunk-BLS2OBIQ.js');
|
|
74
75
|
|
|
75
76
|
|
|
76
77
|
var _chunkCSJWB6D3js = require('./chunk-CSJWB6D3.js');
|
|
@@ -128,4 +129,4 @@ require('./chunk-R5U7XKVJ.js');
|
|
|
128
129
|
|
|
129
130
|
|
|
130
131
|
|
|
131
|
-
exports.aim = _chunkQJVSKKRQjs.aim_exports; exports.alias =
|
|
132
|
+
exports.aim = _chunkQJVSKKRQjs.aim_exports; exports.alias = _chunkBLS2OBIQjs.alias_exports; exports.anthropic = _chunkT46YPHKNjs.llm_anthropic_exports; exports.api = _chunkCSJWB6D3js.api_exports; exports.auth = _chunkUKZIAQA7js.auth_exports; exports.cli = _chunkGHPJJV5Ljs.cli_exports; exports.completion = _chunkJZ22ZUFAjs.completion_exports; exports.completionValues = _chunkJKMQSAJPjs.completion_values_exports; exports.compliance = _chunkXJTRY453js.compliance_exports; exports.config = _chunkQQQYCWSCjs.config_exports; exports.errcorrect = _chunk3FIKGFKIjs.errcorrect_exports; exports.id = _chunkL23O2FFEjs.id_exports; exports.llm = _chunkPSFYJGDGjs.llm_exports; exports.log = _chunkNLMS7HGPjs.log_exports; exports.mcp = _chunkP6GRX4RVjs.mcp_exports; exports.netpolicy = _chunkKVG7YCTSjs.netpolicy_exports; exports.openai = _chunkABQSE7AIjs.llm_openai_exports; exports.output = _chunkIXVQ62NZjs.output_exports; exports.progress = _chunkBDNNPRX6js.progress_exports; exports.provenance = _chunk6SVOHNICjs.provenance_exports; exports.routellm = _chunkMUIQVU6Ejs.routellm_exports; exports.rpc = _chunkWUOAQVOAjs.rpc_exports; exports.safety = _chunk6HFAEZ52js.safety_exports; exports.scope = _chunkWBVO43HUjs.scope_exports; exports.serve = _chunkMQXYDYRDjs.serve_exports; exports.stream = _chunkBRNEKPWXjs.stream_exports; exports.telemetry = _chunkYOBAUCVNjs.telemetry_exports; exports.toolspec = _chunkB4ULGCCNjs.toolspec_exports; exports.tui = _chunkGGWJRWWAjs.tui_exports; exports.upgrade = _chunkWWUKGJB5js.upgrade_exports; exports.xdg = _chunk4UE5TCMQjs.xdg_exports;
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { C as CommanderBridgeOptions, D as DEFAULT_MCP_PATH, a as DEFAULT_MCP_SERVER_NAME, b as DEFAULT_MCP_SERVER_VERSION, c as DestructiveBlockedError, E as ElicitationConfirmGate, F as FlagSchema, H as HEADER_MCP_METHOD,
|
|
1
|
+
export { C as CommanderBridgeOptions, D as DEFAULT_MCP_PATH, a as DEFAULT_MCP_SERVER_NAME, b as DEFAULT_MCP_SERVER_VERSION, c as DEFAULT_TOOL_NAME_SEPARATOR, d as DestructiveBlockedError, E as ElicitationConfirmGate, F as FlagSchema, H as HEADER_MCP_METHOD, e as HEADER_MCP_NAME, f as HEADER_MCP_PROTOCOL_VERSION, I as Invocation, g as InvocationMeta, h as InvokeResult, J as JsonRpcErrorObject, j as JsonRpcRequest, L as Leaf, k as LeafArg, l as LegacyMcpHandler, M as MCP_ARGS_PROPERTY, m as MCP_AUDIT_AUTH_REFUSED, n as MCP_AUDIT_CONFIRMATION_DECLINED, o as MCP_AUDIT_CONFIRMATION_REQUIRED, p as MCP_AUDIT_CONFIRMATION_STATE_REJECTED, q as MCP_AUDIT_DESTRUCTIVE_BLOCKED, r as MCP_AUTH_CHALLENGE, s as MCP_CONFIRM_KEY, t as MCP_CONFIRM_REJECTION_STATE, u as MCP_CONFIRM_STATE_TTL_SECONDS, v as MCP_CONFIRM_STATE_VERSION, w as MCP_ERR_HEADER_MISMATCH, x as MCP_ERR_INTERNAL, y as MCP_ERR_INVALID_PARAMS, z as MCP_ERR_INVALID_REQUEST, A as MCP_ERR_METHOD_NOT_FOUND, B as MCP_ERR_MISSING_CLIENT_CAPABILITY, G as MCP_ERR_PARSE, K as MCP_ERR_UNSUPPORTED_VERSION, N as MCP_SPEC_2024_11_05, O as MCP_SPEC_2026_07_28, P as META_KEY_CLIENT_CAPABILITIES, Q as META_KEY_CLIENT_INFO, R as META_KEY_PROTOCOL_VERSION, S as META_KEY_SERVER_INFO, T as McpAuditHook, U as McpAuditRecord, V as McpBridge, W as McpCacheScope, X as McpConfirmBinding, Y as McpConfirmDecision, Z as McpConfirmRejection, _ as McpConfirmStateStatus, $ as McpDispatcher, a0 as McpEra, a1 as McpEstablishment, a2 as McpHandler, a3 as McpHttpRequest, a4 as McpHttpResponse, a5 as McpIdentity, a6 as McpMountOptions, a7 as McpSpecVersion, a8 as McpSplitResult, a9 as McpStdioOptions, aa as McpStdioServer, ab as McpTransport, ac as McpVerifier, ad as ModernMcpHandler, ae as ModernRequestMeta, af as Policy, ag as RESULT_TYPE_COMPLETE, ah as RESULT_TYPE_INPUT_REQUIRED, ai as RawJSON, aj as ResolvedMcpConfig, ak as SCOPES_EXTRA_KEY, al as SURFACE_CLI, am as SURFACE_LIB, an as SURFACE_MCP, ao as SafetyClass, ap as Surface, aq as SurfaceNotEnabledError, ar as TASKS_EXTENSION, as as TASKS_SUPPORTED, at as TASK_METHODS, au as TaskMethod, av as UnknownCommandError, aw as auditRefusal, ax as buildToolEnvelope, ay as canonicalJSONStringify, az as clientSupportsFormElicitation, aA as commanderBridge, aB as createMcpHandler, aC as decodeMcpSentinel, aD as defaultPolicy, aE as detectMcpEra, aF as discoverCapabilities, aG as encodeEnvelope, aH as errorResultBlock, aI as establishCaller, aJ as hasModernMetaMarker, aK as headerConfirmationGate, aL as invocationMeta, aM as isTaskMethod, aN as mcpArgsPublished, aO as mcpConfirmArgsDigest, aP as mcpConfirmPrincipal, aQ as mcpInputSchema, aR as mcpMountConfig, aS as mcpSplitArguments, aT as mcpToolDescription, aU as methodNotAllowedResponse, aV as mintMcpConfirmState, aW as modernInvocationExtra, aX as parseJsonRpcRequest, aY as parseMcpConfirmRetry, aZ as parseModernMeta, a_ as pathFromToolName, a$ as policyAllowed, b0 as rawToolCallName, b1 as renderCallResult, b2 as resolveMcpConfig, b3 as serveStdio, b4 as singleHeaderValue, b5 as toolName, b6 as validModernRequestId, b7 as verifyMcpConfirmState } from '../index-CaOXdl38.js';
|
|
2
2
|
import '@modelcontextprotocol/server';
|
|
3
|
+
import 'node:stream';
|
|
3
4
|
import 'commander';
|
package/dist/mcp/index.js
CHANGED
|
@@ -74,7 +74,22 @@
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
var _chunkP6GRX4RVjs = require('../chunk-P6GRX4RV.js');
|
|
92
|
+
require('../chunk-UZ65A27P.js');
|
|
78
93
|
require('../chunk-R5U7XKVJ.js');
|
|
79
94
|
|
|
80
95
|
|
|
@@ -152,4 +167,18 @@ require('../chunk-R5U7XKVJ.js');
|
|
|
152
167
|
|
|
153
168
|
|
|
154
169
|
|
|
155
|
-
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
exports.DEFAULT_MCP_PATH = _chunkP6GRX4RVjs.DEFAULT_MCP_PATH; exports.DEFAULT_MCP_SERVER_NAME = _chunkP6GRX4RVjs.DEFAULT_MCP_SERVER_NAME; exports.DEFAULT_MCP_SERVER_VERSION = _chunkP6GRX4RVjs.DEFAULT_MCP_SERVER_VERSION; exports.DEFAULT_TOOL_NAME_SEPARATOR = _chunkP6GRX4RVjs.DEFAULT_TOOL_NAME_SEPARATOR; exports.DestructiveBlockedError = _chunkP6GRX4RVjs.DestructiveBlockedError; exports.ElicitationConfirmGate = _chunkP6GRX4RVjs.ElicitationConfirmGate; exports.HEADER_MCP_METHOD = _chunkP6GRX4RVjs.HEADER_MCP_METHOD; exports.HEADER_MCP_NAME = _chunkP6GRX4RVjs.HEADER_MCP_NAME; exports.HEADER_MCP_PROTOCOL_VERSION = _chunkP6GRX4RVjs.HEADER_MCP_PROTOCOL_VERSION; exports.LegacyMcpHandler = _chunkP6GRX4RVjs.LegacyMcpHandler; exports.MCP_ARGS_PROPERTY = _chunkP6GRX4RVjs.MCP_ARGS_PROPERTY; exports.MCP_AUDIT_AUTH_REFUSED = _chunkP6GRX4RVjs.MCP_AUDIT_AUTH_REFUSED; exports.MCP_AUDIT_CONFIRMATION_DECLINED = _chunkP6GRX4RVjs.MCP_AUDIT_CONFIRMATION_DECLINED; exports.MCP_AUDIT_CONFIRMATION_REQUIRED = _chunkP6GRX4RVjs.MCP_AUDIT_CONFIRMATION_REQUIRED; exports.MCP_AUDIT_CONFIRMATION_STATE_REJECTED = _chunkP6GRX4RVjs.MCP_AUDIT_CONFIRMATION_STATE_REJECTED; exports.MCP_AUDIT_DESTRUCTIVE_BLOCKED = _chunkP6GRX4RVjs.MCP_AUDIT_DESTRUCTIVE_BLOCKED; exports.MCP_AUTH_CHALLENGE = _chunkP6GRX4RVjs.MCP_AUTH_CHALLENGE; exports.MCP_CONFIRM_KEY = _chunkP6GRX4RVjs.MCP_CONFIRM_KEY; exports.MCP_CONFIRM_REJECTION_STATE = _chunkP6GRX4RVjs.MCP_CONFIRM_REJECTION_STATE; exports.MCP_CONFIRM_STATE_TTL_SECONDS = _chunkP6GRX4RVjs.MCP_CONFIRM_STATE_TTL_SECONDS; exports.MCP_CONFIRM_STATE_VERSION = _chunkP6GRX4RVjs.MCP_CONFIRM_STATE_VERSION; exports.MCP_ERR_HEADER_MISMATCH = _chunkP6GRX4RVjs.MCP_ERR_HEADER_MISMATCH; exports.MCP_ERR_INTERNAL = _chunkP6GRX4RVjs.MCP_ERR_INTERNAL; exports.MCP_ERR_INVALID_PARAMS = _chunkP6GRX4RVjs.MCP_ERR_INVALID_PARAMS; exports.MCP_ERR_INVALID_REQUEST = _chunkP6GRX4RVjs.MCP_ERR_INVALID_REQUEST; exports.MCP_ERR_METHOD_NOT_FOUND = _chunkP6GRX4RVjs.MCP_ERR_METHOD_NOT_FOUND; exports.MCP_ERR_MISSING_CLIENT_CAPABILITY = _chunkP6GRX4RVjs.MCP_ERR_MISSING_CLIENT_CAPABILITY; exports.MCP_ERR_PARSE = _chunkP6GRX4RVjs.MCP_ERR_PARSE; exports.MCP_ERR_UNSUPPORTED_VERSION = _chunkP6GRX4RVjs.MCP_ERR_UNSUPPORTED_VERSION; exports.MCP_SPEC_2024_11_05 = _chunkP6GRX4RVjs.MCP_SPEC_2024_11_05; exports.MCP_SPEC_2026_07_28 = _chunkP6GRX4RVjs.MCP_SPEC_2026_07_28; exports.META_KEY_CLIENT_CAPABILITIES = _chunkP6GRX4RVjs.META_KEY_CLIENT_CAPABILITIES; exports.META_KEY_CLIENT_INFO = _chunkP6GRX4RVjs.META_KEY_CLIENT_INFO; exports.META_KEY_PROTOCOL_VERSION = _chunkP6GRX4RVjs.META_KEY_PROTOCOL_VERSION; exports.META_KEY_SERVER_INFO = _chunkP6GRX4RVjs.META_KEY_SERVER_INFO; exports.McpDispatcher = _chunkP6GRX4RVjs.McpDispatcher; exports.ModernMcpHandler = _chunkP6GRX4RVjs.ModernMcpHandler; exports.RESULT_TYPE_COMPLETE = _chunkP6GRX4RVjs.RESULT_TYPE_COMPLETE; exports.RESULT_TYPE_INPUT_REQUIRED = _chunkP6GRX4RVjs.RESULT_TYPE_INPUT_REQUIRED; exports.RawJSON = _chunkP6GRX4RVjs.RawJSON; exports.SCOPES_EXTRA_KEY = _chunkP6GRX4RVjs.SCOPES_EXTRA_KEY; exports.SURFACE_CLI = _chunkP6GRX4RVjs.SURFACE_CLI; exports.SURFACE_LIB = _chunkP6GRX4RVjs.SURFACE_LIB; exports.SURFACE_MCP = _chunkP6GRX4RVjs.SURFACE_MCP; exports.SurfaceNotEnabledError = _chunkP6GRX4RVjs.SurfaceNotEnabledError; exports.TASKS_EXTENSION = _chunkP6GRX4RVjs.TASKS_EXTENSION; exports.TASKS_SUPPORTED = _chunkP6GRX4RVjs.TASKS_SUPPORTED; exports.TASK_METHODS = _chunkP6GRX4RVjs.TASK_METHODS; exports.UnknownCommandError = _chunkP6GRX4RVjs.UnknownCommandError; exports.auditRefusal = _chunkP6GRX4RVjs.auditRefusal; exports.buildToolEnvelope = _chunkP6GRX4RVjs.buildToolEnvelope; exports.canonicalJSONStringify = _chunkP6GRX4RVjs.canonicalJSONStringify; exports.clientSupportsFormElicitation = _chunkP6GRX4RVjs.clientSupportsFormElicitation; exports.commanderBridge = _chunkP6GRX4RVjs.commanderBridge; exports.createMcpHandler = _chunkP6GRX4RVjs.createMcpHandler; exports.decodeMcpSentinel = _chunkP6GRX4RVjs.decodeMcpSentinel; exports.defaultPolicy = _chunkP6GRX4RVjs.defaultPolicy; exports.detectMcpEra = _chunkP6GRX4RVjs.detectMcpEra; exports.discoverCapabilities = _chunkP6GRX4RVjs.discoverCapabilities; exports.encodeEnvelope = _chunkP6GRX4RVjs.encodeEnvelope; exports.errorResultBlock = _chunkP6GRX4RVjs.errorResultBlock; exports.establishCaller = _chunkP6GRX4RVjs.establishCaller; exports.hasModernMetaMarker = _chunkP6GRX4RVjs.hasModernMetaMarker; exports.headerConfirmationGate = _chunkP6GRX4RVjs.headerConfirmationGate; exports.invocationMeta = _chunkP6GRX4RVjs.invocationMeta; exports.isTaskMethod = _chunkP6GRX4RVjs.isTaskMethod; exports.mcpArgsPublished = _chunkP6GRX4RVjs.mcpArgsPublished; exports.mcpConfirmArgsDigest = _chunkP6GRX4RVjs.mcpConfirmArgsDigest; exports.mcpConfirmPrincipal = _chunkP6GRX4RVjs.mcpConfirmPrincipal; exports.mcpInputSchema = _chunkP6GRX4RVjs.mcpInputSchema; exports.mcpMountConfig = _chunkP6GRX4RVjs.mcpMountConfig; exports.mcpSplitArguments = _chunkP6GRX4RVjs.mcpSplitArguments; exports.mcpToolDescription = _chunkP6GRX4RVjs.mcpToolDescription; exports.methodNotAllowedResponse = _chunkP6GRX4RVjs.methodNotAllowedResponse; exports.mintMcpConfirmState = _chunkP6GRX4RVjs.mintMcpConfirmState; exports.modernInvocationExtra = _chunkP6GRX4RVjs.modernInvocationExtra; exports.parseJsonRpcRequest = _chunkP6GRX4RVjs.parseJsonRpcRequest; exports.parseMcpConfirmRetry = _chunkP6GRX4RVjs.parseMcpConfirmRetry; exports.parseModernMeta = _chunkP6GRX4RVjs.parseModernMeta; exports.pathFromToolName = _chunkP6GRX4RVjs.pathFromToolName; exports.policyAllowed = _chunkP6GRX4RVjs.policyAllowed; exports.rawToolCallName = _chunkP6GRX4RVjs.rawToolCallName; exports.renderCallResult = _chunkP6GRX4RVjs.renderCallResult; exports.resolveMcpConfig = _chunkP6GRX4RVjs.resolveMcpConfig; exports.serveStdio = _chunkP6GRX4RVjs.serveStdio; exports.singleHeaderValue = _chunkP6GRX4RVjs.singleHeaderValue; exports.toolName = _chunkP6GRX4RVjs.toolName; exports.validModernRequestId = _chunkP6GRX4RVjs.validModernRequestId; exports.verifyMcpConfirmState = _chunkP6GRX4RVjs.verifyMcpConfirmState;
|
|
@@ -281,12 +281,17 @@ interface FromCommandOptions {
|
|
|
281
281
|
annotations?: Record<string, CommandAnnotation>;
|
|
282
282
|
/** Defaults to "1", the version the YAML toolspecs declare. */
|
|
283
283
|
schemaVersion?: string;
|
|
284
|
+
/** Keep hidden commands (Go WithIncludeHidden). Hidden options stay omitted. */
|
|
285
|
+
includeHidden?: boolean;
|
|
284
286
|
}
|
|
285
287
|
/**
|
|
286
288
|
* Build a ToolSpec from a constructed commander tree, so CLIs with
|
|
287
289
|
* dynamically registered subcommands need no hand-synced YAML.
|
|
288
|
-
* Mirrors Go's WalkCobra projection: hidden commands
|
|
289
|
-
*
|
|
290
|
+
* Mirrors Go's WalkCobra projection: hidden commands (unless
|
|
291
|
+
* includeHidden) and hidden options are omitted, framework builtins
|
|
292
|
+
* (help, completion and its shells, man, __complete,
|
|
293
|
+
* __completeNoDesc) and kit/spec-command commands are skipped, flag
|
|
294
|
+
* names are undashed, root options become spec.flags.
|
|
290
295
|
*/
|
|
291
296
|
declare function toolSpecFromCommand(program: Command$1, opts?: FromCommandOptions): ToolSpec;
|
|
292
297
|
|
package/dist/toolspec.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'commander';
|
|
2
|
-
export { A as Arg, B as BuildManifestOptions, C as Command, a as CommandAnnotation, b as Contract, c as CoverageOptions, d as CoverageReport, E as ErrorPattern, F as Flag, e as FromCommandOptions, I as IDEMPOTENT_UNKNOWN, f as Intent, L as LATEST_SCHEMA_VERSION, M as Manifest, g as ManifestArg, h as ManifestCommand, i as ManifestExample, j as ManifestFlag, k as ManifestNextStep, O as OutputSchema, P as Provenance, R as RegisterSpecOptions, S as SCHEMA_VERSION_ENV, l as SIDE_EFFECT_UNKNOWN, m as SPEC_COMMAND_ANNOTATION, n as Safety, o as SafetyLevel, p as StateIntrospection, T as ToolSpec, W as Workflow, q as buildManifest, r as coverageOf, s as findCommand, u as loadToolSpec, v as negotiateSchemaVersion, w as registerSpecCommand, x as renderManifestJSON, y as toolSpecFromCommand, z as validateToolSpec } from './toolspec-
|
|
2
|
+
export { A as Arg, B as BuildManifestOptions, C as Command, a as CommandAnnotation, b as Contract, c as CoverageOptions, d as CoverageReport, E as ErrorPattern, F as Flag, e as FromCommandOptions, I as IDEMPOTENT_UNKNOWN, f as Intent, L as LATEST_SCHEMA_VERSION, M as Manifest, g as ManifestArg, h as ManifestCommand, i as ManifestExample, j as ManifestFlag, k as ManifestNextStep, O as OutputSchema, P as Provenance, R as RegisterSpecOptions, S as SCHEMA_VERSION_ENV, l as SIDE_EFFECT_UNKNOWN, m as SPEC_COMMAND_ANNOTATION, n as Safety, o as SafetyLevel, p as StateIntrospection, T as ToolSpec, W as Workflow, q as buildManifest, r as coverageOf, s as findCommand, u as loadToolSpec, v as negotiateSchemaVersion, w as registerSpecCommand, x as renderManifestJSON, y as toolSpecFromCommand, z as validateToolSpec } from './toolspec-96rkLfsh.js';
|
package/dist/toolspec.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkB4ULGCCNjs = require('./chunk-B4ULGCCN.js');
|
|
17
|
+
require('./chunk-UZ65A27P.js');
|
|
17
18
|
require('./chunk-IXVQ62NZ.js');
|
|
18
19
|
require('./chunk-72XZWQX7.js');
|
|
19
20
|
require('./chunk-POR5L2DG.js');
|
|
@@ -33,4 +34,4 @@ require('./chunk-R5U7XKVJ.js');
|
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
exports.IDEMPOTENT_UNKNOWN =
|
|
37
|
+
exports.IDEMPOTENT_UNKNOWN = _chunkB4ULGCCNjs.IDEMPOTENT_UNKNOWN; exports.LATEST_SCHEMA_VERSION = _chunkB4ULGCCNjs.LATEST_SCHEMA_VERSION; exports.SCHEMA_VERSION_ENV = _chunkB4ULGCCNjs.SCHEMA_VERSION_ENV; exports.SIDE_EFFECT_UNKNOWN = _chunkB4ULGCCNjs.SIDE_EFFECT_UNKNOWN; exports.SPEC_COMMAND_ANNOTATION = _chunkB4ULGCCNjs.SPEC_COMMAND_ANNOTATION; exports.buildManifest = _chunkB4ULGCCNjs.buildManifest; exports.coverageOf = _chunkB4ULGCCNjs.coverageOf; exports.findCommand = _chunkB4ULGCCNjs.findCommand; exports.loadToolSpec = _chunkB4ULGCCNjs.loadToolSpec; exports.negotiateSchemaVersion = _chunkB4ULGCCNjs.negotiateSchemaVersion; exports.registerSpecCommand = _chunkB4ULGCCNjs.registerSpecCommand; exports.renderManifestJSON = _chunkB4ULGCCNjs.renderManifestJSON; exports.toolSpecFromCommand = _chunkB4ULGCCNjs.toolSpecFromCommand; exports.validateToolSpec = _chunkB4ULGCCNjs.validateToolSpec;
|
package/package.json
CHANGED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Runs the shared alias corpus in contracts/alias-v1. The vectors are
|
|
2
|
+
// the source of truth: a failure means this port drifted from the
|
|
3
|
+
// contract, not that a vector should be edited to fit.
|
|
4
|
+
//
|
|
5
|
+
// Strict: unknown fields fail, `version` must be `v1` and every JSON
|
|
6
|
+
// file in the corpus must have a runner here.
|
|
7
|
+
|
|
8
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { Command, CommanderError } from 'commander';
|
|
11
|
+
import { describe, expect, it } from 'vitest';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
AliasNameError, type AliasMap, type BridgeOptions,
|
|
15
|
+
bridgeAliases, detectCycles, findCommand, validateAliasName,
|
|
16
|
+
} from './alias';
|
|
17
|
+
import { completeRequest } from './completion';
|
|
18
|
+
|
|
19
|
+
const PORT = 'ts';
|
|
20
|
+
const CORPUS = join(__dirname, '..', '..', '..', 'contracts', 'alias-v1');
|
|
21
|
+
const FILES = ['bridge.json', 'cycles.json', 'validate.json'];
|
|
22
|
+
|
|
23
|
+
function strictKeys(o: object, allowed: string[], where: string): void {
|
|
24
|
+
for (const k of Object.keys(o)) {
|
|
25
|
+
if (!allowed.includes(k)) throw new Error(`${where}: unknown field ${k}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function load<T>(name: string, top: string[]): T {
|
|
30
|
+
for (const n of readdirSync(CORPUS)) {
|
|
31
|
+
if (n.endsWith('.json') && !FILES.includes(n)) {
|
|
32
|
+
throw new Error(`${n} has no runner`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const f = JSON.parse(readFileSync(join(CORPUS, name), 'utf8'));
|
|
36
|
+
strictKeys(f, ['version', 'description', 'cases', ...top], name);
|
|
37
|
+
if (f.version !== 'v1') throw new Error(`${name}: version ${f.version}`);
|
|
38
|
+
if (!Array.isArray(f.cases) || f.cases.length === 0) {
|
|
39
|
+
throw new Error(`${name}: cases section is empty`);
|
|
40
|
+
}
|
|
41
|
+
return f as T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ── validate.json ───────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
interface ValidateCase {
|
|
47
|
+
name: string; alias: string; builtins?: string[];
|
|
48
|
+
existing?: AliasMap; expect: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('alias-v1 validate', () => {
|
|
52
|
+
const f = load<{ cases: ValidateCase[] }>('validate.json', []);
|
|
53
|
+
for (const c of f.cases) {
|
|
54
|
+
it(c.name, () => {
|
|
55
|
+
strictKeys(c, ['name', 'alias', 'builtins', 'existing', 'expect'], c.name);
|
|
56
|
+
let got = 'ok';
|
|
57
|
+
try {
|
|
58
|
+
validateAliasName(c.alias, { builtins: c.builtins, existing: c.existing });
|
|
59
|
+
} catch (e) {
|
|
60
|
+
expect(e).toBeInstanceOf(AliasNameError);
|
|
61
|
+
got = (e as AliasNameError).kind;
|
|
62
|
+
}
|
|
63
|
+
expect(got).toBe(c.expect);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ── cycles.json ─────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
describe('alias-v1 cycles', () => {
|
|
71
|
+
const f = load<{ cases: { name: string; aliases: AliasMap; cycles: string[][] }[] }>(
|
|
72
|
+
'cycles.json', [],
|
|
73
|
+
);
|
|
74
|
+
for (const c of f.cases) {
|
|
75
|
+
it(c.name, () => {
|
|
76
|
+
strictKeys(c, ['name', 'aliases', 'cycles'], c.name);
|
|
77
|
+
expect(detectCycles(c.aliases)).toEqual(c.cycles);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// ── bridge.json ─────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
interface Node {
|
|
85
|
+
name: string; description: string;
|
|
86
|
+
flags?: { name: string; default: string }[];
|
|
87
|
+
commands?: Node[];
|
|
88
|
+
}
|
|
89
|
+
interface Entry { kind: string; hidden?: boolean; description?: string }
|
|
90
|
+
interface Run {
|
|
91
|
+
ran: string; path?: string; env?: string | null; args?: string[];
|
|
92
|
+
name?: string; target?: string;
|
|
93
|
+
}
|
|
94
|
+
interface Check {
|
|
95
|
+
alias?: string; argv?: string[]; entry?: Entry; run?: Run; help?: string;
|
|
96
|
+
complete?: string[]; candidates?: string[];
|
|
97
|
+
by_port?: Record<string, Partial<Check>>;
|
|
98
|
+
}
|
|
99
|
+
interface BridgeCase {
|
|
100
|
+
name: string; aliases: AliasMap;
|
|
101
|
+
options?: { hidden?: boolean; describe?: boolean; help?: string; dispatch?: string };
|
|
102
|
+
skip?: Record<string, string>;
|
|
103
|
+
proxy_flags?: { name: string; short: string }[];
|
|
104
|
+
checks: Check[];
|
|
105
|
+
}
|
|
106
|
+
interface BridgeFile {
|
|
107
|
+
tree: Node; describe_template: string; cases: BridgeCase[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// What a target or handler saw.
|
|
111
|
+
interface Seen {
|
|
112
|
+
ran: string; path?: string; env?: string | null; args?: string[];
|
|
113
|
+
name?: string; target?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function build(
|
|
117
|
+
parent: Command, nodes: Node[], prefix: string, rec: { r: Seen },
|
|
118
|
+
descs: Map<string, string>,
|
|
119
|
+
): void {
|
|
120
|
+
for (const n of nodes) {
|
|
121
|
+
strictKeys(n, ['name', 'description', 'flags', 'commands'], n.name);
|
|
122
|
+
const path = `${prefix} ${n.name}`.trim();
|
|
123
|
+
descs.set(path, n.description);
|
|
124
|
+
const c = parent.command(n.name).description(n.description);
|
|
125
|
+
const hasEnv = (n.flags ?? []).some(fl => fl.name === 'env');
|
|
126
|
+
for (const fl of n.flags ?? []) c.option(`--${fl.name} <v>`, '', fl.default);
|
|
127
|
+
if (!n.commands?.length) {
|
|
128
|
+
c.argument('[args...]').action((args: string[], opts: Record<string, string>) => {
|
|
129
|
+
rec.r = { ran: 'target', path, env: hasEnv ? opts.env : null, args };
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
build(c, n.commands ?? [], path, rec, descs);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function bridgeOptions(f: BridgeFile, c: BridgeCase, rec: { r: Seen }): BridgeOptions | undefined {
|
|
137
|
+
const o = c.options;
|
|
138
|
+
if (!o) return undefined;
|
|
139
|
+
strictKeys(o, ['hidden', 'describe', 'help', 'dispatch'], c.name);
|
|
140
|
+
const opts: BridgeOptions = {};
|
|
141
|
+
if (o.hidden !== undefined) opts.hidden = o.hidden;
|
|
142
|
+
if (o.describe) {
|
|
143
|
+
opts.describe = (name, target) =>
|
|
144
|
+
f.describe_template.replace('{name}', name).replace('{target}', target);
|
|
145
|
+
}
|
|
146
|
+
if (o.help === 'own') opts.helpOption = true;
|
|
147
|
+
else if (o.help === 'passthrough') opts.helpOption = false;
|
|
148
|
+
else if (o.help !== undefined) throw new Error(`unknown help ${o.help}`);
|
|
149
|
+
if (o.dispatch === 'handler') {
|
|
150
|
+
opts.dispatch = (name, target, cmd) => {
|
|
151
|
+
rec.r = { ran: 'handler', name, target, args: [...cmd.args] };
|
|
152
|
+
};
|
|
153
|
+
} else if (o.dispatch === 'register-only') {
|
|
154
|
+
opts.dispatch = false;
|
|
155
|
+
} else if (o.dispatch !== undefined) {
|
|
156
|
+
throw new Error(`unknown dispatch ${o.dispatch}`);
|
|
157
|
+
}
|
|
158
|
+
return opts;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
describe('alias-v1 bridge', () => {
|
|
162
|
+
const f = load<BridgeFile>('bridge.json', ['tree', 'describe_template']);
|
|
163
|
+
|
|
164
|
+
function setup(c: BridgeCase) {
|
|
165
|
+
const rec: { r: Seen } = { r: { ran: 'none' } };
|
|
166
|
+
const descs = new Map<string, string>();
|
|
167
|
+
let out = '';
|
|
168
|
+
const program = new Command(f.tree.name)
|
|
169
|
+
.exitOverride()
|
|
170
|
+
.configureOutput({ writeOut: s => { out += s; }, writeErr: s => { out += s; } });
|
|
171
|
+
build(program, f.tree.commands ?? [], '', rec, descs);
|
|
172
|
+
const sorted = Object.fromEntries(Object.entries(c.aliases).sort(([a], [b]) => (a < b ? -1 : 1)));
|
|
173
|
+
bridgeAliases(program, sorted, bridgeOptions(f, c, rec));
|
|
174
|
+
for (const fl of c.proxy_flags ?? []) {
|
|
175
|
+
strictKeys(fl, ['name', 'short'], c.name);
|
|
176
|
+
for (const alias of Object.keys(c.aliases)) {
|
|
177
|
+
const proxy = program.commands.find(x => x.name() === alias);
|
|
178
|
+
if (!proxy) throw new Error(`${c.name}: ${alias} has no proxy`);
|
|
179
|
+
proxy.option(`-${fl.short}, --${fl.name} <v>`, fl.name);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return { program, rec, descs, output: () => out };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
for (const c of f.cases) {
|
|
186
|
+
const skip = c.skip?.[PORT];
|
|
187
|
+
(skip ? it.skip : it)(skip ? `${c.name} (${skip})` : c.name, async () => {
|
|
188
|
+
strictKeys(c, ['name', 'aliases', 'options', 'skip', 'proxy_flags', 'checks'], c.name);
|
|
189
|
+
for (const raw of c.checks) {
|
|
190
|
+
strictKeys(
|
|
191
|
+
raw, ['alias', 'argv', 'entry', 'run', 'help', 'complete', 'candidates', 'by_port'], c.name,
|
|
192
|
+
);
|
|
193
|
+
const chk: Check = { ...raw, ...(raw.by_port?.[PORT] ?? {}) };
|
|
194
|
+
const { program, rec, descs, output } = setup(c);
|
|
195
|
+
|
|
196
|
+
if (chk.entry) {
|
|
197
|
+
const alias = chk.alias!;
|
|
198
|
+
const proxy = program.commands.find(x => x.name() === alias);
|
|
199
|
+
if (proxy) {
|
|
200
|
+
expect(chk.entry.kind, alias).toBe('proxy');
|
|
201
|
+
if (chk.entry.hidden !== undefined) {
|
|
202
|
+
expect((proxy as unknown as { _hidden: boolean })._hidden, alias)
|
|
203
|
+
.toBe(chk.entry.hidden);
|
|
204
|
+
}
|
|
205
|
+
if (chk.entry.description !== undefined) {
|
|
206
|
+
expect(proxy.description(), alias).toBe(chk.entry.description);
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
const target = findCommand(program, c.aliases[alias]);
|
|
210
|
+
expect(target?.aliases().includes(alias) ? 'native' : 'missing', alias)
|
|
211
|
+
.toBe(chk.entry.kind);
|
|
212
|
+
}
|
|
213
|
+
} else if (chk.run) {
|
|
214
|
+
await program.parseAsync(chk.argv!, { from: 'user' });
|
|
215
|
+
const r = rec.r;
|
|
216
|
+
expect(r.ran, chk.argv!.join(' ')).toBe(chk.run.ran);
|
|
217
|
+
if (chk.run.ran === 'target') {
|
|
218
|
+
expect({ path: r.path, env: r.env, args: r.args })
|
|
219
|
+
.toEqual({ path: chk.run.path, env: chk.run.env, args: chk.run.args });
|
|
220
|
+
} else if (chk.run.ran === 'handler') {
|
|
221
|
+
expect({ name: r.name, target: r.target, args: r.args })
|
|
222
|
+
.toEqual({ name: chk.run.name, target: chk.run.target, args: chk.run.args });
|
|
223
|
+
}
|
|
224
|
+
} else if (chk.help) {
|
|
225
|
+
const err = await program.parseAsync(chk.argv!, { from: 'user' })
|
|
226
|
+
.then(() => undefined, (e: unknown) => e);
|
|
227
|
+
expect(err, chk.argv!.join(' ')).toBeInstanceOf(CommanderError);
|
|
228
|
+
expect((err as CommanderError).code).toBe('commander.helpDisplayed');
|
|
229
|
+
const alias = chk.argv![0];
|
|
230
|
+
const text = output();
|
|
231
|
+
const proxy = program.commands.find(x => x.name() === alias);
|
|
232
|
+
let got = 'unknown';
|
|
233
|
+
if (text.includes(descs.get(c.aliases[alias])!)) got = 'target';
|
|
234
|
+
else if (proxy && text.includes(proxy.description())) got = 'alias';
|
|
235
|
+
expect(got, text).toBe(chk.help);
|
|
236
|
+
expect(rec.r.ran).toBe('none');
|
|
237
|
+
} else if (chk.complete) {
|
|
238
|
+
let out = '';
|
|
239
|
+
await completeRequest(program, chk.complete, true, {
|
|
240
|
+
out: s => { out += s; }, err: () => {},
|
|
241
|
+
});
|
|
242
|
+
const got = out.split('\n').filter(l => l !== '' && !l.startsWith(':')).sort();
|
|
243
|
+
expect(got, chk.complete.join(' ')).toEqual([...chk.candidates!].sort());
|
|
244
|
+
} else {
|
|
245
|
+
throw new Error(`${c.name}: check has no observable`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
});
|
package/src/alias.test.ts
CHANGED
|
@@ -4,8 +4,9 @@ import * as path from 'path';
|
|
|
4
4
|
import * as os from 'os';
|
|
5
5
|
import {
|
|
6
6
|
AliasStore, loadFrom, saveTo, findFirstNonFlag, Expander,
|
|
7
|
-
bridgeAliases, findCommand,
|
|
7
|
+
bridgeAliases, findCommand, validateAliasName, AliasNameError,
|
|
8
8
|
} from './alias';
|
|
9
|
+
import { completeRequest } from './completion';
|
|
9
10
|
import { Command, CommanderError } from 'commander';
|
|
10
11
|
|
|
11
12
|
let tmpDir: string;
|
|
@@ -530,3 +531,97 @@ describe('bridgeAliases proxy dispatch', () => {
|
|
|
530
531
|
.rejects.toMatchObject({ code: 'commander.unknownCommand' });
|
|
531
532
|
});
|
|
532
533
|
});
|
|
534
|
+
|
|
535
|
+
// ── validateAliasName / bridge options ─────────────────────
|
|
536
|
+
|
|
537
|
+
describe('validateAliasName', () => {
|
|
538
|
+
it('keeps the Expander texts and adds duplicate', () => {
|
|
539
|
+
const msg = (name: string, rules = {}) => {
|
|
540
|
+
try { validateAliasName(name, rules); } catch (e) { return (e as Error).message; }
|
|
541
|
+
return 'ok';
|
|
542
|
+
};
|
|
543
|
+
expect(msg('')).toBe('alias name must not be empty');
|
|
544
|
+
expect(msg('a b')).toBe('alias name must not contain whitespace');
|
|
545
|
+
expect(msg('task', { builtins: ['task'] }))
|
|
546
|
+
.toBe('alias "task" conflicts with a built-in command');
|
|
547
|
+
expect(msg('d', { existing: { d: 'deploy' } }))
|
|
548
|
+
.toBe('alias "d" is already registered for "deploy"');
|
|
549
|
+
expect(msg('tl', { builtins: new Set(['task']) })).toBe('ok');
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
it('throws AliasNameError carrying the kind', () => {
|
|
553
|
+
expect(() => validateAliasName('task', { builtins: ['task'] }))
|
|
554
|
+
.toThrow(AliasNameError);
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
describe('bridgeAliases options', () => {
|
|
559
|
+
it('accepts a plain map and an empty options object keeps defaults', () => {
|
|
560
|
+
const program = new Command('test');
|
|
561
|
+
program.command('deploy').description('Deploy');
|
|
562
|
+
bridgeAliases(program, { d: 'deploy' }, {});
|
|
563
|
+
expect(findCommand(program, 'deploy')?.aliases()).toContain('d');
|
|
564
|
+
expect(program.commands.find(c => c.name() === 'd')).toBeUndefined();
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
it('options make a single-word alias a proxy', () => {
|
|
568
|
+
const program = new Command('test');
|
|
569
|
+
program.command('deploy').description('Deploy');
|
|
570
|
+
bridgeAliases(program, { d: 'deploy' }, {
|
|
571
|
+
hidden: false, describe: (n, t) => `${n} -> ${t}`,
|
|
572
|
+
});
|
|
573
|
+
const proxy = program.commands.find(c => c.name() === 'd');
|
|
574
|
+
expect(proxy?.description()).toBe('d -> deploy');
|
|
575
|
+
expect(findCommand(program, 'deploy')?.aliases()).not.toContain('d');
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
it('dispatch handler result is awaited by parseAsync', async () => {
|
|
579
|
+
const program = new Command('test').exitOverride();
|
|
580
|
+
program.command('deploy').action(() => {});
|
|
581
|
+
let done = false;
|
|
582
|
+
bridgeAliases(program, { d: 'deploy' }, {
|
|
583
|
+
dispatch: async () => { await new Promise(r => setTimeout(r, 5)); done = true; },
|
|
584
|
+
});
|
|
585
|
+
await program.parseAsync(['d'], { from: 'user' });
|
|
586
|
+
expect(done).toBe(true);
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
describe('bridgeAliases completion', () => {
|
|
591
|
+
async function complete(program: Command, words: string[]): Promise<string[]> {
|
|
592
|
+
let out = '';
|
|
593
|
+
await completeRequest(program, words, true, { out: s => { out += s; }, err: () => {} });
|
|
594
|
+
return out.split('\n').filter(l => l !== '' && !l.startsWith(':')).sort();
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function tree(): Command {
|
|
598
|
+
const program = new Command('test');
|
|
599
|
+
program.command('deploy').description('Deploy').option('--env <e>');
|
|
600
|
+
return program;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
it('a hidden proxy is a stand-in, offered once by name', async () => {
|
|
604
|
+
for (const dispatch of [undefined, false] as const) {
|
|
605
|
+
const program = tree();
|
|
606
|
+
bridgeAliases(program, { d: 'deploy' }, { describe: () => 'x', dispatch });
|
|
607
|
+
expect(await complete(program, ['d'])).toEqual(['d', 'deploy']);
|
|
608
|
+
expect(await complete(program, ['d', '--'])).toEqual(['--help']);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
it('a hidden proxy with a dispatch handler completes its own flags', async () => {
|
|
613
|
+
const program = tree();
|
|
614
|
+
bridgeAliases(program, { d: 'deploy' }, { dispatch: () => {} });
|
|
615
|
+
program.commands.find(c => c.name() === 'd')!.option('-p, --path <p>');
|
|
616
|
+
expect(await complete(program, ['d'])).toEqual(['deploy']);
|
|
617
|
+
expect(await complete(program, ['d', '--'])).toEqual(['--path']);
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
it('a visible proxy is offered once, with its own flags', async () => {
|
|
621
|
+
const program = tree();
|
|
622
|
+
bridgeAliases(program, { d: 'deploy' }, { hidden: false, helpOption: true });
|
|
623
|
+
program.commands.find(c => c.name() === 'd')!.option('-p, --path <p>');
|
|
624
|
+
expect(await complete(program, ['d'])).toEqual(['d', 'deploy']);
|
|
625
|
+
expect(await complete(program, ['d', '--'])).toEqual(['--help', '--path']);
|
|
626
|
+
});
|
|
627
|
+
});
|