argsbarg 6.1.6 → 6.1.8
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 +15 -1
- package/docs/README.md +1 -1
- package/docs/cli-program.md +3 -3
- package/docs/config-schema.md +12 -9
- package/docs/decisions.md +1 -1
- package/docs/json-schema-subset.md +38 -12
- package/docs/output-schema.md +1 -1
- package/package.json +3 -2
- package/src/builtins/builtins.test.ts +4 -4
- package/src/builtins/completion-bash.ts +1 -1
- package/src/builtins/completion-fish.ts +1 -1
- package/src/builtins/completion-group.ts +3 -3
- package/src/builtins/completion-zsh.ts +1 -1
- package/src/builtins/config.test.ts +3 -3
- package/src/builtins/config.ts +9 -9
- package/src/builtins/configure-copy.ts +2 -2
- package/src/builtins/configure.ts +3 -3
- package/src/builtins/dispatch.ts +10 -10
- package/src/builtins/export.ts +4 -4
- package/src/builtins/http.ts +5 -5
- package/src/builtins/mcp.ts +3 -3
- package/src/builtins/presentation.ts +5 -5
- package/src/builtins/registry.ts +3 -3
- package/src/builtins/scopes.ts +2 -2
- package/src/builtins/version.ts +1 -1
- package/src/cli-tool/full-example-capabilities.test.ts +2 -2
- package/src/cli-tool/main.ts +1 -1
- package/src/cli-tool/program.ts +1 -1
- package/src/cli-tool/prompt.ts +1 -1
- package/src/config/bindings.test.ts +1 -1
- package/src/config/bindings.ts +1 -1
- package/src/config/bootstrap.test.ts +1 -1
- package/src/config/bootstrap.ts +3 -3
- package/src/config/context.test.ts +1 -1
- package/src/config/context.ts +1 -1
- package/src/config/entry.ts +1 -1
- package/src/config/file.test.ts +1 -1
- package/src/config/file.ts +3 -3
- package/src/config/manifest.ts +1 -1
- package/src/config/resolve.test.ts +1 -1
- package/src/config/resolve.ts +1 -1
- package/src/config/schema.ts +1 -1
- package/src/config/validate.test.ts +45 -1
- package/src/config/validate.ts +138 -203
- package/src/configure/artifacts/binary-placement.test.ts +1 -1
- package/src/configure/artifacts/binary-placement.ts +1 -1
- package/src/configure/artifacts/gh-release-update.ts +1 -1
- package/src/configure/artifacts/install-validate.test.ts +3 -3
- package/src/configure/artifacts/mcp-config.ts +1 -1
- package/src/configure/artifacts/mcp-opencode.test.ts +1 -1
- package/src/configure/artifacts/mcp-opencode.ts +1 -1
- package/src/configure/artifacts/paths.ts +5 -5
- package/src/configure/artifacts/plan.ts +1 -1
- package/src/configure/artifacts/status.test.ts +1 -1
- package/src/configure/artifacts/status.ts +2 -2
- package/src/configure/artifacts/target-base.ts +1 -1
- package/src/configure/artifacts/target-detect.ts +1 -1
- package/src/configure/artifacts/target-effective.ts +3 -3
- package/src/configure/artifacts/target-mcp-cli.ts +1 -1
- package/src/configure/artifacts/target-mcp-json.ts +1 -1
- package/src/configure/artifacts/target-plan-build.ts +2 -2
- package/src/configure/artifacts/target-scope.ts +3 -3
- package/src/configure/artifacts/target-skill.ts +1 -1
- package/src/configure/artifacts/target-types.ts +2 -2
- package/src/configure/artifacts/targets/app.ts +5 -5
- package/src/configure/artifacts/targets/chatgpt-mcp.ts +2 -2
- package/src/configure/artifacts/targets/claude-code-mcp.ts +2 -2
- package/src/configure/artifacts/targets/claude-desktop-mcp.ts +2 -2
- package/src/configure/artifacts/targets/claude-skill.ts +2 -2
- package/src/configure/artifacts/targets/codex-mcp.ts +2 -2
- package/src/configure/artifacts/targets/codex-skill.ts +2 -2
- package/src/configure/artifacts/targets/configure.ts +5 -5
- package/src/configure/artifacts/targets/cursor-mcp.ts +2 -2
- package/src/configure/artifacts/targets/cursor-skill.ts +2 -2
- package/src/configure/artifacts/targets/index.ts +1 -1
- package/src/configure/artifacts/targets/openclaw-mcp.ts +2 -2
- package/src/configure/artifacts/targets/openclaw-skill.ts +3 -3
- package/src/configure/artifacts/targets/opencode-mcp.ts +5 -5
- package/src/configure/artifacts/targets/opencode-skill.ts +3 -3
- package/src/configure/artifacts/targets.test.ts +1 -1
- package/src/configure/artifacts/uninstall.ts +1 -1
- package/src/configure/configure.test.ts +9 -9
- package/src/configure/index.ts +5 -5
- package/src/configure/prompt.ts +1 -1
- package/src/core/context.ts +3 -3
- package/src/core/json-leaf.test.ts +1 -1
- package/src/core/leaf-inputs.test.ts +1 -1
- package/src/core/leaf-inputs.ts +2 -2
- package/src/core/parse.test.ts +9 -9
- package/src/core/parse.ts +2 -2
- package/src/core/schema.ts +3 -3
- package/src/core/types.ts +1 -1
- package/src/core/validate.ts +6 -6
- package/src/docs/builtin.ts +3 -3
- package/src/docs/cli-guide.test.ts +3 -3
- package/src/docs/cli-guide.ts +5 -5
- package/src/docs/docs.test.ts +8 -8
- package/src/docs/http-guide.ts +7 -7
- package/src/docs/mcp-guide.ts +7 -7
- package/src/docs/mcp-resources.test.ts +1 -1
- package/src/docs/mcp-resources.ts +1 -1
- package/src/docs/resolve.ts +4 -4
- package/src/docs/save.ts +2 -2
- package/src/exports/cli.ts +9 -9
- package/src/exports/headless.ts +2 -2
- package/src/exports/http.ts +2 -2
- package/src/exports/mcp.ts +2 -2
- package/src/headless/routing.ts +2 -2
- package/src/headless/tool-call.ts +11 -11
- package/src/hooks/run.ts +6 -6
- package/src/http/openapi.ts +3 -3
- package/src/http/paths.ts +1 -1
- package/src/http/readiness.ts +3 -3
- package/src/http/result.ts +1 -1
- package/src/http/routes.ts +4 -4
- package/src/http/server.ts +6 -6
- package/src/log/emitter.ts +1 -1
- package/src/mcp/bundle.ts +2 -2
- package/src/mcp/claude.test.ts +1 -1
- package/src/mcp/claude.ts +4 -4
- package/src/mcp/hidden-mcpb.test.ts +5 -5
- package/src/mcp/result.ts +2 -2
- package/src/mcp/server.ts +3 -3
- package/src/mcp/tools.ts +7 -7
- package/src/runtime/capabilities.ts +2 -2
- package/src/runtime/cli-errors.ts +3 -3
- package/src/runtime/cli.ts +22 -22
- package/src/runtime/exposure.ts +2 -2
- package/src/runtime/invoke.test.ts +6 -6
- package/src/server/context.ts +3 -3
- package/src/server/overrides.ts +3 -3
- package/src/skill/generate.ts +5 -5
- package/src/skill/hint.ts +1 -1
- package/src/skill/install.ts +2 -2
- package/src/skill/naming.ts +1 -1
- package/src/test/fixtures.ts +2 -2
- package/src/test/integration/config.test.ts +3 -3
- package/src/test/integration/http.test.ts +10 -10
- package/src/test/integration/mcp.test.ts +6 -6
package/src/docs/mcp-guide.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defaultConfigEntryTitle } from "
|
|
2
|
-
import { displayAppConfigPath } from "
|
|
3
|
-
import { expectedOpenCodeMcpEntry, OPENCODE_CONFIG_SCHEMA } from "
|
|
4
|
-
import { collectOptionDefs } from "
|
|
5
|
-
import { CliOptionKind, type CliProgram } from "
|
|
6
|
-
import { collectMcpTools, type McpToolDef, mcpServerId, resolveMcpSchemaUri } from "
|
|
7
|
-
import { resolveCapabilities } from "
|
|
1
|
+
import { defaultConfigEntryTitle } from "../config/entry.ts";
|
|
2
|
+
import { displayAppConfigPath } from "../config/file.ts";
|
|
3
|
+
import { expectedOpenCodeMcpEntry, OPENCODE_CONFIG_SCHEMA } from "../configure/artifacts/mcp-opencode.ts";
|
|
4
|
+
import { collectOptionDefs } from "../core/parse.ts";
|
|
5
|
+
import { CliOptionKind, type CliProgram } from "../core/types.ts";
|
|
6
|
+
import { collectMcpTools, type McpToolDef, mcpServerId, resolveMcpSchemaUri } from "../mcp/tools.ts";
|
|
7
|
+
import { resolveCapabilities } from "../runtime/capabilities.ts";
|
|
8
8
|
import { resolveDocsTopicResourceUri } from "./mcp-resources.ts";
|
|
9
9
|
import { docsEnabled, docsUserTopicKeys, resolveDocsConfig } from "./resolve.ts";
|
|
10
10
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Auto MCP resources for user docs.topics when docs and MCP are both enabled.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { CliProgram } from "
|
|
5
|
+
import type { CliProgram } from "../core/types.ts";
|
|
6
6
|
import { docsEnabled, docsTopicDescription, docsTopicText, docsUserTopicKeys, resolveDocsConfig } from "./resolve.ts";
|
|
7
7
|
|
|
8
8
|
/** Default URI pattern for a docs topic MCP resource (`<mcpId>://docs/<topicKey>`). */
|
package/src/docs/resolve.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cliSchemaJson } from "
|
|
2
|
-
import type { CliDocsConfig, CliProgram } from "
|
|
3
|
-
import { openApiJson } from "
|
|
4
|
-
import { generateSkillBundle } from "
|
|
1
|
+
import { cliSchemaJson } from "../core/schema.ts";
|
|
2
|
+
import type { CliDocsConfig, CliProgram } from "../core/types.ts";
|
|
3
|
+
import { openApiJson } from "../http/openapi.ts";
|
|
4
|
+
import { generateSkillBundle } from "../skill/generate.ts";
|
|
5
5
|
import { generateCliGuide } from "./cli-guide.ts";
|
|
6
6
|
import { generateHttpGuide } from "./http-guide.ts";
|
|
7
7
|
import { generateMcpGuide } from "./mcp-guide.ts";
|
package/src/docs/save.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import type { CliProgram } from "
|
|
4
|
-
import { generatedFileHtmlComment, insertGeneratedHint } from "
|
|
3
|
+
import type { CliProgram } from "../core/types.ts";
|
|
4
|
+
import { generatedFileHtmlComment, insertGeneratedHint } from "../skill/hint.ts";
|
|
5
5
|
import { docsTopicContent } from "./resolve.ts";
|
|
6
6
|
|
|
7
7
|
/** Relative output directory for `docs --save`. */
|
package/src/exports/cli.ts
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Public CLI runtime export (`argsbarg/cli`).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export { displayAppConfigPath, resolveAppConfigPath } from "
|
|
6
|
-
export type { CliLeafInputs } from "
|
|
7
|
-
export { CliContext } from "
|
|
5
|
+
export { displayAppConfigPath, resolveAppConfigPath } from "../config/file.ts";
|
|
6
|
+
export type { CliLeafInputs } from "../core/context.ts";
|
|
7
|
+
export { CliContext } from "../core/context.ts";
|
|
8
8
|
export {
|
|
9
9
|
parseCommaList,
|
|
10
10
|
parseDate,
|
|
11
11
|
parseDateTime,
|
|
12
12
|
parseDurationMs,
|
|
13
|
-
} from "
|
|
13
|
+
} from "../core/formats.ts";
|
|
14
14
|
export type {
|
|
15
15
|
CliAppConfig,
|
|
16
16
|
CliAppConfigEntry,
|
|
@@ -35,13 +35,13 @@ export type {
|
|
|
35
35
|
InstallAgentIntegration,
|
|
36
36
|
InstallTargetSpec,
|
|
37
37
|
ResolvedInstallTarget,
|
|
38
|
-
} from "
|
|
38
|
+
} from "../core/types.ts";
|
|
39
39
|
export {
|
|
40
40
|
CliOptionKind,
|
|
41
41
|
CliSchemaValidationError,
|
|
42
42
|
CliValueFormat,
|
|
43
43
|
isJsonLeaf,
|
|
44
|
-
} from "
|
|
45
|
-
export { Cli, type CliInvokeKind, type CliInvokeResult } from "
|
|
46
|
-
export { cliErrWithHelp } from "
|
|
47
|
-
export { isInteractiveTty } from "
|
|
44
|
+
} from "../core/types.ts";
|
|
45
|
+
export { Cli, type CliInvokeKind, type CliInvokeResult } from "../runtime/cli.ts";
|
|
46
|
+
export { cliErrWithHelp } from "../runtime/cli-errors.ts";
|
|
47
|
+
export { isInteractiveTty } from "../utils.ts";
|
package/src/exports/headless.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Headless routing helpers (`argsbarg/headless`).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export type { HeadlessContext } from "
|
|
5
|
+
export type { HeadlessContext } from "../headless/routing.ts";
|
|
6
6
|
export {
|
|
7
7
|
formatDryRunMessage,
|
|
8
8
|
requireYesInNonTty,
|
|
@@ -10,4 +10,4 @@ export {
|
|
|
10
10
|
shouldRunHeadlessWithPositionals,
|
|
11
11
|
shouldRunHeadlessWithYes,
|
|
12
12
|
wantsExplicitJson,
|
|
13
|
-
} from "
|
|
13
|
+
} from "../headless/routing.ts";
|
package/src/exports/http.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
HTTP/OpenAPI export (`argsbarg/http`).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export { generateOpenApi, openApiJson } from "
|
|
6
|
-
export { handleApiRequest, httpServeHttp, resolveHttpListenAddress } from "
|
|
5
|
+
export { generateOpenApi, openApiJson } from "../http/openapi.ts";
|
|
6
|
+
export { handleApiRequest, httpServeHttp, resolveHttpListenAddress } from "../http/server.ts";
|
package/src/exports/mcp.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
MCP bundle export (`argsbarg/mcp`). @experimental
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export type { McpBundlePaths, PackMcpBundleOpts } from "
|
|
6
|
-
export { defaultMcpBundlePaths, generateMcpManifest, packMcpBundle } from "
|
|
5
|
+
export type { McpBundlePaths, PackMcpBundleOpts } from "../mcp/bundle.ts";
|
|
6
|
+
export { defaultMcpBundlePaths, generateMcpManifest, packMcpBundle } from "../mcp/bundle.ts";
|
package/src/headless/routing.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CliContext } from "
|
|
2
|
-
import { isInteractiveTty } from "
|
|
1
|
+
import type { CliContext } from "../core/context.ts";
|
|
2
|
+
import { isInteractiveTty } from "../utils.ts";
|
|
3
3
|
|
|
4
4
|
/** Minimal context for headless routing helpers. */
|
|
5
5
|
export type HeadlessContext = Pick<CliContext, "invocation">;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Shared headless tool dispatch for MCP and HTTP: config bootstrap, argv conversion, and invoke.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { bootstrapAppConfig } from "
|
|
6
|
-
import { formatMcpMissingConfigMessage, missingRequiredConfig } from "
|
|
7
|
-
import type { CliInvocation, CliProgram, InvokeFailureKind } from "
|
|
8
|
-
import { failureKindHttpStatus } from "
|
|
9
|
-
import { apiErrorResponse, apiSuccessResponse, firstErrorLine } from "
|
|
10
|
-
import { type HttpRouteDef, httpRequestToArgv } from "
|
|
11
|
-
import { obscureUnexpectedClientMessage } from "
|
|
12
|
-
import { buildToolCallSuccessFromResponse } from "
|
|
13
|
-
import { collectMcpTools, type McpToolDef, mcpToolCallToArgv } from "
|
|
14
|
-
import type { Cli, CliInvokeResult } from "
|
|
5
|
+
import { bootstrapAppConfig } from "../config/bootstrap.ts";
|
|
6
|
+
import { formatMcpMissingConfigMessage, missingRequiredConfig } from "../config/resolve.ts";
|
|
7
|
+
import type { CliInvocation, CliProgram, InvokeFailureKind } from "../core/types.ts";
|
|
8
|
+
import { failureKindHttpStatus } from "../hooks/run.ts";
|
|
9
|
+
import { apiErrorResponse, apiSuccessResponse, firstErrorLine } from "../http/result.ts";
|
|
10
|
+
import { type HttpRouteDef, httpRequestToArgv } from "../http/routes.ts";
|
|
11
|
+
import { obscureUnexpectedClientMessage } from "../log/emitter.ts";
|
|
12
|
+
import { buildToolCallSuccessFromResponse } from "../mcp/result.ts";
|
|
13
|
+
import { collectMcpTools, type McpToolDef, mcpToolCallToArgv } from "../mcp/tools.ts";
|
|
14
|
+
import type { Cli, CliInvokeResult } from "../runtime/cli.ts";
|
|
15
15
|
|
|
16
16
|
/** Outcome of resolving a tool name against the program schema. */
|
|
17
17
|
export type ToolLookupResult =
|
|
@@ -179,7 +179,7 @@ export async function executeHttpRouteCall(
|
|
|
179
179
|
/** Maps a headless success result to an HTTP Response. */
|
|
180
180
|
export function headlessSuccessToHttpResponse(
|
|
181
181
|
result: HeadlessToolCallSuccess,
|
|
182
|
-
leafApiResponse?: import("
|
|
182
|
+
leafApiResponse?: import("../core/types.ts").CliHttpResponseConfig,
|
|
183
183
|
defaultStatus?: number,
|
|
184
184
|
): Response {
|
|
185
185
|
return apiSuccessResponse(result.response, leafApiResponse, defaultStatus);
|
package/src/hooks/run.ts
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Safe async hook runner, failure classification, and invoke error pipeline.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { CliContext } from "
|
|
6
|
-
import { LeafInputError } from "
|
|
5
|
+
import type { CliContext } from "../core/context.ts";
|
|
6
|
+
import { LeafInputError } from "../core/leaf-inputs.ts";
|
|
7
7
|
import type {
|
|
8
8
|
ClientErrorOverride,
|
|
9
9
|
ErrorHookContext,
|
|
10
10
|
InvokeFailureKind,
|
|
11
11
|
InvokeHookContext,
|
|
12
12
|
ServerRuntime,
|
|
13
|
-
} from "
|
|
14
|
-
import { firstErrorLine } from "
|
|
15
|
-
import { type LogEmitter, obscureUnexpectedClientMessage } from "
|
|
13
|
+
} from "../core/types.ts";
|
|
14
|
+
import { firstErrorLine } from "../http/result.ts";
|
|
15
|
+
import { type LogEmitter, obscureUnexpectedClientMessage } from "../log/emitter.ts";
|
|
16
16
|
|
|
17
17
|
/** Runs a hook without letting hook throws escape uncaught. */
|
|
18
18
|
export async function runHook<T>(hook: (() => T | Promise<T>) | undefined, label: string): Promise<T | undefined> {
|
|
@@ -106,7 +106,7 @@ export async function runErrorPipeline(
|
|
|
106
106
|
hookCtx: InvokeHookContext,
|
|
107
107
|
err: unknown,
|
|
108
108
|
failureKind: InvokeFailureKind,
|
|
109
|
-
hooks: import("
|
|
109
|
+
hooks: import("../core/types.ts").CliProgramHooks | undefined,
|
|
110
110
|
emitter: LogEmitter | undefined,
|
|
111
111
|
obscureUnexpected: boolean,
|
|
112
112
|
): Promise<ErrorPipelineResult> {
|
package/src/http/openapi.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Hand-built OpenAPI 3.1 document from exposed HTTP REST routes.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { collectOptionDefs } from "
|
|
6
|
-
import type { CliHttpMethod, CliNode, CliProgram } from "
|
|
7
|
-
import { CliOptionKind, isCliLeaf, isJsonLeaf } from "
|
|
5
|
+
import { collectOptionDefs } from "../core/parse.ts";
|
|
6
|
+
import type { CliHttpMethod, CliNode, CliProgram } from "../core/types.ts";
|
|
7
|
+
import { CliOptionKind, isCliLeaf, isJsonLeaf } from "../core/types.ts";
|
|
8
8
|
import { collectHttpRoutes, defaultSuccessStatus } from "./routes.ts";
|
|
9
9
|
import { dereferenceJsonSchema } from "./schema-deref.ts";
|
|
10
10
|
|
package/src/http/paths.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
HTTP path prefix helpers and framework route guards.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { CliProgram } from "
|
|
5
|
+
import type { CliProgram } from "../core/types.ts";
|
|
6
6
|
|
|
7
7
|
/** Top-level segments reserved for framework routes when `pathPrefix` is empty. */
|
|
8
8
|
export const HTTP_RESERVED_TOP_LEVEL_SEGMENTS = new Set(["health", "openapi.json", "swagger", "tools"]);
|
package/src/http/readiness.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
HTTP/MCP readiness checks for GET /health/readiness (orchestrator probes only).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { AnyAppConfigSnapshot } from "
|
|
6
|
-
import { missingRequiredConfig } from "
|
|
7
|
-
import type { CliProgram, ReadinessContext, ServerRuntime } from "
|
|
5
|
+
import type { AnyAppConfigSnapshot } from "../config/context.ts";
|
|
6
|
+
import { missingRequiredConfig } from "../config/resolve.ts";
|
|
7
|
+
import type { CliProgram, ReadinessContext, ServerRuntime } from "../core/types.ts";
|
|
8
8
|
|
|
9
9
|
const READINESS_CACHE_MS = 3000;
|
|
10
10
|
|
package/src/http/result.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Maps headless respond payloads to native HTTP Response objects.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { CliHttpResponseConfig, CliRespondOptions } from "
|
|
5
|
+
import type { CliHttpResponseConfig, CliRespondOptions } from "../core/types.ts";
|
|
6
6
|
|
|
7
7
|
/** JSON body for a failed HTTP tool invocation. */
|
|
8
8
|
export interface ApiToolCallErrorBody {
|
package/src/http/routes.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
HTTP REST route collection and request matching from the CLI command tree.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { collectOptionDefs } from "
|
|
5
|
+
import { collectOptionDefs } from "../core/parse.ts";
|
|
6
6
|
import {
|
|
7
7
|
type CliHttpMethod,
|
|
8
8
|
type CliLeaf,
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
isCliLeaf,
|
|
12
12
|
isJsonLeaf,
|
|
13
13
|
CliOptionKind as OptKind,
|
|
14
|
-
} from "
|
|
15
|
-
import { formatMcpOptionValue } from "
|
|
16
|
-
import { isHttpDisabled, isHttpHidden } from "
|
|
14
|
+
} from "../core/types.ts";
|
|
15
|
+
import { formatMcpOptionValue } from "../mcp/tools.ts";
|
|
16
|
+
import { isHttpDisabled, isHttpHidden } from "../runtime/exposure.ts";
|
|
17
17
|
import { buildHttpUserPath, httpUserPathRegexPrefix, resolveHttpPathPrefix } from "./paths.ts";
|
|
18
18
|
|
|
19
19
|
const VERB_KEYS = new Set(["get", "post", "put", "patch", "delete"]);
|
package/src/http/server.ts
CHANGED
|
@@ -3,15 +3,15 @@ HTTP tool server for ArgsBarg programs: health, OpenAPI, and REST API invocation
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
|
-
import type { CliHttpWireContext, CliProgram } from "
|
|
6
|
+
import type { CliHttpWireContext, CliProgram } from "../core/types.ts";
|
|
7
7
|
import {
|
|
8
8
|
executeHttpRouteCall,
|
|
9
9
|
headlessFailureToHttpResponse,
|
|
10
10
|
headlessSuccessToHttpResponse,
|
|
11
|
-
} from "
|
|
12
|
-
import type { Cli } from "
|
|
13
|
-
import { leafHttpResponseDefaults } from "
|
|
14
|
-
import type { ResolvedHttpServeConfig } from "
|
|
11
|
+
} from "../headless/tool-call.ts";
|
|
12
|
+
import type { Cli } from "../runtime/cli.ts";
|
|
13
|
+
import { leafHttpResponseDefaults } from "../runtime/exposure.ts";
|
|
14
|
+
import type { ResolvedHttpServeConfig } from "../server/overrides.ts";
|
|
15
15
|
import { generateOpenApi } from "./openapi.ts";
|
|
16
16
|
import { evaluateReadiness } from "./readiness.ts";
|
|
17
17
|
import { API_CORS_HEADERS, apiDocsHtml, apiErrorResponse, apiOptionsResponse } from "./result.ts";
|
|
@@ -86,7 +86,7 @@ export async function handleApiRequest(
|
|
|
86
86
|
if (failureKind && error !== undefined) {
|
|
87
87
|
await hooks?.onError?.({
|
|
88
88
|
...wireCtx,
|
|
89
|
-
failureKind: failureKind as import("
|
|
89
|
+
failureKind: failureKind as import("../core/types.ts").InvokeFailureKind,
|
|
90
90
|
error,
|
|
91
91
|
});
|
|
92
92
|
} else {
|
package/src/log/emitter.ts
CHANGED
|
@@ -4,7 +4,7 @@ Framework log emitter: ECS json or human text to stderr with optional file tee.
|
|
|
4
4
|
|
|
5
5
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
6
6
|
import { dirname } from "node:path";
|
|
7
|
-
import type { CliProgram } from "
|
|
7
|
+
import type { CliProgram } from "../core/types.ts";
|
|
8
8
|
import { type EcsLogEvent, type EcsLogLevel, formatEcsLine } from "./ecs.ts";
|
|
9
9
|
|
|
10
10
|
/** Resolved logging options for a server or invoke session. */
|
package/src/mcp/bundle.ts
CHANGED
|
@@ -6,8 +6,8 @@ Expects `dist/<program.key>` as the compiled binary input.
|
|
|
6
6
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { basename, join, resolve } from "node:path";
|
|
9
|
-
import { buildProgramUserConfig } from "
|
|
10
|
-
import type { CliMcpBundleConfig, CliProgram } from "
|
|
9
|
+
import { buildProgramUserConfig } from "../config/manifest.ts";
|
|
10
|
+
import type { CliMcpBundleConfig, CliProgram } from "../core/types.ts";
|
|
11
11
|
import { packClaudePlugin } from "./claude.ts";
|
|
12
12
|
import { collectMcpTools, mcpServerId } from "./tools.ts";
|
|
13
13
|
import { zipStore } from "./zip.ts";
|
package/src/mcp/claude.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { execSync } from "node:child_process";
|
|
|
7
7
|
import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { tmpdir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
|
-
import type { CliProgram } from "
|
|
10
|
+
import type { CliProgram } from "../core/types.ts";
|
|
11
11
|
import {
|
|
12
12
|
defaultClaudePluginPaths,
|
|
13
13
|
generatePluginManifest,
|
package/src/mcp/claude.ts
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
} from "node:fs";
|
|
18
18
|
import { tmpdir } from "node:os";
|
|
19
19
|
import { basename, join, relative, resolve } from "node:path";
|
|
20
|
-
import { buildPluginMcpEnvMapping, buildProgramUserConfig } from "
|
|
21
|
-
import type { CliMcpBundleConfig, CliProgram } from "
|
|
22
|
-
import { generatePluginSkillBundle } from "
|
|
23
|
-
import { applyPluginSkillHint } from "
|
|
20
|
+
import { buildPluginMcpEnvMapping, buildProgramUserConfig } from "../config/manifest.ts";
|
|
21
|
+
import type { CliMcpBundleConfig, CliProgram } from "../core/types.ts";
|
|
22
|
+
import { generatePluginSkillBundle } from "../skill/generate.ts";
|
|
23
|
+
import { applyPluginSkillHint } from "../skill/hint.ts";
|
|
24
24
|
import { defaultMcpBundlePaths, type PackMcpBundleOpts } from "./bundle.ts";
|
|
25
25
|
import { mcpServerId } from "./tools.ts";
|
|
26
26
|
import { type ZipFileEntry, zipStore } from "./zip.ts";
|
|
@@ -6,11 +6,11 @@ import { describe, expect, test } from "bun:test";
|
|
|
6
6
|
import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
-
import { exportPresentationBuiltins } from "
|
|
10
|
-
import { cliParseRoot, cliPresentationRoot } from "
|
|
11
|
-
import { cliSchemaExport } from "
|
|
12
|
-
import { CliOptionKind, type CliProgram } from "
|
|
13
|
-
import { cliHelpRender } from "
|
|
9
|
+
import { exportPresentationBuiltins } from "../builtins/export.ts";
|
|
10
|
+
import { cliParseRoot, cliPresentationRoot } from "../builtins/presentation.ts";
|
|
11
|
+
import { cliSchemaExport } from "../core/schema.ts";
|
|
12
|
+
import { CliOptionKind, type CliProgram } from "../core/types.ts";
|
|
13
|
+
import { cliHelpRender } from "../help.ts";
|
|
14
14
|
import { defaultMcpBundlePaths, generateMcpManifest, packMcpBundle, runMcpBundle } from "./bundle.ts";
|
|
15
15
|
import { collectMcpTools } from "./tools.ts";
|
|
16
16
|
|
package/src/mcp/result.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
This module builds MCP tools/call success results from handler respond payloads.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { encodeRespondBodyBase64 } from "
|
|
6
|
-
import type { CliRespondOptions } from "
|
|
5
|
+
import { encodeRespondBodyBase64 } from "../core/respond.ts";
|
|
6
|
+
import type { CliRespondOptions } from "../core/types.ts";
|
|
7
7
|
|
|
8
8
|
/** Text content block in an MCP tool result. */
|
|
9
9
|
export interface McpTextContent {
|
package/src/mcp/server.ts
CHANGED
|
@@ -4,8 +4,8 @@ resources, and ping. Responses are newline-delimited JSON on stdout only.
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
|
-
import { executeHeadlessToolCall, headlessFailureMcpMessage, lookupHeadlessTool } from "
|
|
8
|
-
import type { Cli } from "
|
|
7
|
+
import { executeHeadlessToolCall, headlessFailureMcpMessage, lookupHeadlessTool } from "../headless/tool-call.ts";
|
|
8
|
+
import type { Cli } from "../runtime/cli.ts";
|
|
9
9
|
import { allMcpResources, collectMcpTools, resolveMcpServerInfo } from "./tools.ts";
|
|
10
10
|
|
|
11
11
|
const MCP_PROTOCOL_VERSION = "2024-11-05";
|
|
@@ -64,7 +64,7 @@ async function handleRequestLine(cli: Cli, line: string): Promise<void> {
|
|
|
64
64
|
if (failureKind && error !== undefined) {
|
|
65
65
|
await hooks?.onError?.({
|
|
66
66
|
...wireCtx,
|
|
67
|
-
failureKind: failureKind as import("
|
|
67
|
+
failureKind: failureKind as import("../core/types.ts").InvokeFailureKind,
|
|
68
68
|
error,
|
|
69
69
|
});
|
|
70
70
|
} else {
|
package/src/mcp/tools.ts
CHANGED
|
@@ -3,8 +3,8 @@ This module maps CliProgram leaf nodes to MCP tool definitions and converts
|
|
|
3
3
|
flat JSON tool arguments into argv for Cli.invoke.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { collectOptionDefs } from "
|
|
7
|
-
import { cliSchemaJson } from "
|
|
6
|
+
import { collectOptionDefs } from "../core/parse.ts";
|
|
7
|
+
import { cliSchemaJson } from "../core/schema.ts";
|
|
8
8
|
import {
|
|
9
9
|
type CliLeaf,
|
|
10
10
|
type CliNode,
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
isCliLeaf,
|
|
17
17
|
isJsonLeaf,
|
|
18
18
|
leafOutputSchema,
|
|
19
|
-
} from "
|
|
20
|
-
import { docsMcpResources } from "
|
|
21
|
-
import { cliResolveNotes } from "
|
|
22
|
-
import { isMcpHidden, visibleOptions } from "
|
|
19
|
+
} from "../core/types.ts";
|
|
20
|
+
import { docsMcpResources } from "../docs/mcp-resources.ts";
|
|
21
|
+
import { cliResolveNotes } from "../help.ts";
|
|
22
|
+
import { isMcpHidden, visibleOptions } from "../runtime/exposure.ts";
|
|
23
23
|
|
|
24
24
|
const DURATION_PATTERN = "^\\d+[hdms]?$";
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ export function defaultMcpSchemaUri(mcpId: string): string {
|
|
|
28
28
|
return `${mcpId}://schema`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export { defaultDocsTopicResourceUri, resolveDocsTopicResourceUri } from "
|
|
31
|
+
export { defaultDocsTopicResourceUri, resolveDocsTopicResourceUri } from "../docs/mcp-resources.ts";
|
|
32
32
|
|
|
33
33
|
/** Sanitizes a command key segment for MCP tool names and server identity. */
|
|
34
34
|
export function sanitizeToolSegment(key: string): string {
|
|
@@ -3,8 +3,8 @@ Internal capability resolver — decides which platform builtins are active for
|
|
|
3
3
|
Not exported from the public package barrel.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { configCommandsEnabled } from "
|
|
7
|
-
import type { CliProgram } from "
|
|
6
|
+
import { configCommandsEnabled } from "../config/entry.ts";
|
|
7
|
+
import type { CliProgram } from "../core/types.ts";
|
|
8
8
|
|
|
9
9
|
/** Platform builtins derived from program config and runtime. */
|
|
10
10
|
export interface CliCapabilities {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Handler error helper with contextual help.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { cliPresentationRoot } from "
|
|
6
|
-
import type { CliContext } from "
|
|
7
|
-
import { cliHelpRender } from "
|
|
5
|
+
import { cliPresentationRoot } from "../builtins/presentation.ts";
|
|
6
|
+
import type { CliContext } from "../core/context.ts";
|
|
7
|
+
import { cliHelpRender } from "../help.ts";
|
|
8
8
|
|
|
9
9
|
export function cliErrWithHelp(ctx: CliContext, msg: string): never {
|
|
10
10
|
if (ctx.invocation === "http" || ctx.invocation === "mcp") {
|
package/src/runtime/cli.ts
CHANGED
|
@@ -4,16 +4,16 @@ Runtime entry point: validate program, cache derived state, run / invoke / MCP s
|
|
|
4
4
|
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { format } from "node:util";
|
|
7
|
-
import { builtinInterceptRoot, dispatchBuiltin } from "
|
|
8
|
-
import { cliParseRoot, cliPresentationRoot } from "
|
|
9
|
-
import { bootstrapAppConfig, type EnsureAppConfigOpts, ensureAppConfig } from "
|
|
10
|
-
import { type AnyAppConfigSnapshot, createAppConfigSnapshot } from "
|
|
11
|
-
import { readAppConfigFileRaw, resolveAppConfigPath } from "
|
|
12
|
-
import { effectiveJsonSchema } from "
|
|
13
|
-
import { CliContext } from "
|
|
14
|
-
import { LeafInputError, preloadPipableJson } from "
|
|
15
|
-
import { ParseKind, type ParseResult, parse, postParseValidate } from "
|
|
16
|
-
import { type CliSchemaRootExport, cliSchemaExport } from "
|
|
7
|
+
import { builtinInterceptRoot, dispatchBuiltin } from "../builtins/dispatch.ts";
|
|
8
|
+
import { cliParseRoot, cliPresentationRoot } from "../builtins/presentation.ts";
|
|
9
|
+
import { bootstrapAppConfig, type EnsureAppConfigOpts, ensureAppConfig } from "../config/bootstrap.ts";
|
|
10
|
+
import { type AnyAppConfigSnapshot, createAppConfigSnapshot } from "../config/context.ts";
|
|
11
|
+
import { readAppConfigFileRaw, resolveAppConfigPath } from "../config/file.ts";
|
|
12
|
+
import { effectiveJsonSchema } from "../config/schema.ts";
|
|
13
|
+
import { CliContext } from "../core/context.ts";
|
|
14
|
+
import { LeafInputError, preloadPipableJson } from "../core/leaf-inputs.ts";
|
|
15
|
+
import { ParseKind, type ParseResult, parse, postParseValidate } from "../core/parse.ts";
|
|
16
|
+
import { type CliSchemaRootExport, cliSchemaExport } from "../core/schema.ts";
|
|
17
17
|
import type {
|
|
18
18
|
CliHandler,
|
|
19
19
|
CliInvocation,
|
|
@@ -24,18 +24,18 @@ import type {
|
|
|
24
24
|
CliRespondOptions,
|
|
25
25
|
CliRouter,
|
|
26
26
|
InvokeFailureKind,
|
|
27
|
-
} from "
|
|
28
|
-
import { isCliLeaf, isCliRouter } from "
|
|
29
|
-
import { cliValidateProgram } from "
|
|
30
|
-
import { cliHelpRender } from "
|
|
31
|
-
import { isBuiltinInvokePath } from "
|
|
32
|
-
import { buildInvokeHookContext, classifyFailureKind, runErrorPipeline, runHook } from "
|
|
33
|
-
import { httpServeHttp } from "
|
|
34
|
-
import { LogEmitter } from "
|
|
35
|
-
import { bootstrapMcpEnv } from "
|
|
36
|
-
import { mcpServeStdioLoop } from "
|
|
37
|
-
import { createServerRuntime, type ServerHandleContext } from "
|
|
38
|
-
import { resolveHttpServeConfig, resolveMcpServeConfig, type ServeOverrides } from "
|
|
27
|
+
} from "../core/types.ts";
|
|
28
|
+
import { isCliLeaf, isCliRouter } from "../core/types.ts";
|
|
29
|
+
import { cliValidateProgram } from "../core/validate.ts";
|
|
30
|
+
import { cliHelpRender } from "../help.ts";
|
|
31
|
+
import { isBuiltinInvokePath } from "../hooks/builtin.ts";
|
|
32
|
+
import { buildInvokeHookContext, classifyFailureKind, runErrorPipeline, runHook } from "../hooks/run.ts";
|
|
33
|
+
import { httpServeHttp } from "../http/server.ts";
|
|
34
|
+
import { LogEmitter } from "../log/emitter.ts";
|
|
35
|
+
import { bootstrapMcpEnv } from "../mcp/env.ts";
|
|
36
|
+
import { mcpServeStdioLoop } from "../mcp/server.ts";
|
|
37
|
+
import { createServerRuntime, type ServerHandleContext } from "../server/context.ts";
|
|
38
|
+
import { resolveHttpServeConfig, resolveMcpServeConfig, type ServeOverrides } from "../server/overrides.ts";
|
|
39
39
|
import {
|
|
40
40
|
assertBuiltinAllowed,
|
|
41
41
|
type CliCapabilities,
|
package/src/runtime/exposure.ts
CHANGED
|
@@ -3,8 +3,8 @@ Per-surface exposure helpers (cli, http, mcpTool).
|
|
|
3
3
|
Parsing uses the full tree; presentation/schema/MCP/HTTP discovery use these filters.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { CliLeaf, CliNode, CliNodeBase, CliOption } from "
|
|
7
|
-
import { isCliRouter } from "
|
|
6
|
+
import type { CliLeaf, CliNode, CliNodeBase, CliOption } from "../core/types.ts";
|
|
7
|
+
import { isCliRouter } from "../core/types.ts";
|
|
8
8
|
|
|
9
9
|
/** True when the node is omitted from CLI help, schema, and completions (still invocable). */
|
|
10
10
|
export function isCliHidden(node: CliNodeBase): boolean {
|
|
@@ -5,12 +5,12 @@ Domain-specific regression tests (split from index.test.ts).
|
|
|
5
5
|
import { expect, test } from "bun:test";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { $ } from "bun";
|
|
8
|
-
import { ParseKind, parse, postParseValidate } from "
|
|
9
|
-
import type { CliLeaf } from "
|
|
10
|
-
import { isCliRouter } from "
|
|
11
|
-
import { cliValidateProgram } from "
|
|
12
|
-
import { Cli, type CliContext, CliOptionKind } from "
|
|
13
|
-
import { testProgram, varargsReadFixture } from "
|
|
8
|
+
import { ParseKind, parse, postParseValidate } from "../core/parse.ts";
|
|
9
|
+
import type { CliLeaf } from "../core/types.ts";
|
|
10
|
+
import { isCliRouter } from "../core/types.ts";
|
|
11
|
+
import { cliValidateProgram } from "../core/validate.ts";
|
|
12
|
+
import { Cli, type CliContext, CliOptionKind } from "../index.ts";
|
|
13
|
+
import { testProgram, varargsReadFixture } from "../test/fixtures.ts";
|
|
14
14
|
|
|
15
15
|
/** Tests that ctx.invocation is cli via Cli.run. */
|
|
16
16
|
test("ctx.invocation is cli via Cli.run", async () => {
|
package/src/server/context.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Per-server mutable handle context passed through HTTP/MCP dispatch.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { CliHttpWireHooks, CliMcpWireHooks, ServerRuntime, ServerState } from "
|
|
6
|
-
import type { LogEmitter } from "
|
|
5
|
+
import type { CliHttpWireHooks, CliMcpWireHooks, ServerRuntime, ServerState } from "../core/types.ts";
|
|
6
|
+
import type { LogEmitter } from "../log/emitter.ts";
|
|
7
7
|
import type { ResolvedHttpServeConfig, ResolvedMcpServeConfig } from "./overrides.ts";
|
|
8
8
|
|
|
9
9
|
/** Shared server state for one HTTP or MCP serve session. */
|
|
@@ -18,7 +18,7 @@ export interface ServerHandleContext {
|
|
|
18
18
|
|
|
19
19
|
/** Creates a fresh {@link ServerRuntime} for HTTP or MCP. */
|
|
20
20
|
export function createServerRuntime(
|
|
21
|
-
program: import("
|
|
21
|
+
program: import("../core/types.ts").CliProgram,
|
|
22
22
|
surface: "http" | "mcp",
|
|
23
23
|
): ServerRuntime {
|
|
24
24
|
return { state: {} as ServerState, program, surface };
|
package/src/server/overrides.ts
CHANGED
|
@@ -3,9 +3,9 @@ CLI flag and programmatic overrides merged into HTTP/MCP server runtime config.
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { resolveAppConfigDir } from "
|
|
7
|
-
import type { CliProgram } from "
|
|
8
|
-
import type { ResolvedLogConfig } from "
|
|
6
|
+
import { resolveAppConfigDir } from "../config/file.ts";
|
|
7
|
+
import type { CliProgram } from "../core/types.ts";
|
|
8
|
+
import type { ResolvedLogConfig } from "../log/emitter.ts";
|
|
9
9
|
|
|
10
10
|
/** Overrides from `myapp http` / `serveHttp()` flags and embedders. */
|
|
11
11
|
export interface ServeOverrides {
|