argsbarg 6.1.5 → 6.1.7
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 -3
- package/docs/http-server.md +3 -3
- package/examples/full-example/docs/cli-schema.json +9 -9
- package/examples/full-example/docs/cli.md +9 -9
- package/examples/full-example/docs/http.md +3 -3
- package/examples/full-example/docs/openapi.json +6 -35
- package/package.json +1 -1
- 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 +6 -6
- 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.ts +1 -1
- 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 +10 -10
- 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 +23 -15
- 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 +7 -7
- 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 +18 -14
- package/src/test/integration/mcp.test.ts +6 -6
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 {
|
|
@@ -112,7 +112,7 @@ export async function handleApiRequest(
|
|
|
112
112
|
const root = cli.program;
|
|
113
113
|
const path = url.pathname;
|
|
114
114
|
|
|
115
|
-
if (request.method === "GET" &&
|
|
115
|
+
if (request.method === "GET" && path === "/health/liveness") {
|
|
116
116
|
return finish(jsonResponse(200, { ok: true }));
|
|
117
117
|
}
|
|
118
118
|
|
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 {
|
package/src/skill/generate.ts
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
This module generates Agent Skills content (SKILL.md + reference.md) from a CLI schema.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { defaultConfigEntryTitle } from "
|
|
6
|
-
import { collectOptionDefs } from "
|
|
7
|
-
import { CliOptionKind, type CliProgram } from "
|
|
8
|
-
import { generateCliGuide } from "
|
|
5
|
+
import { defaultConfigEntryTitle } from "../config/entry.ts";
|
|
6
|
+
import { collectOptionDefs } from "../core/parse.ts";
|
|
7
|
+
import { CliOptionKind, type CliProgram } from "../core/types.ts";
|
|
8
|
+
import { generateCliGuide } from "../docs/cli-guide.ts";
|
|
9
9
|
import {
|
|
10
10
|
collectMcpTools,
|
|
11
11
|
type McpToolDef,
|
|
12
12
|
mcpServerId,
|
|
13
13
|
resolveMcpSchemaUri,
|
|
14
14
|
sanitizeToolSegment,
|
|
15
|
-
} from "
|
|
15
|
+
} from "../mcp/tools.ts";
|
|
16
16
|
import type { SkillTarget } from "./naming.ts";
|
|
17
17
|
import { skillDirNameForTarget, skillFrontmatterName } from "./naming.ts";
|
|
18
18
|
|
package/src/skill/hint.ts
CHANGED
package/src/skill/install.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import type { CliProgram } from "
|
|
4
|
-
import { userHome } from "
|
|
3
|
+
import type { CliProgram } from "../core/types.ts";
|
|
4
|
+
import { userHome } from "../paths/host.ts";
|
|
5
5
|
import { generateSkillBundle, type SkillTarget } from "./generate.ts";
|
|
6
6
|
import { applySkillInstallHints } from "./hint.ts";
|
|
7
7
|
|
package/src/skill/naming.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Agent skill install targets. */
|
|
2
2
|
export type SkillTarget = "cursor" | "claude" | "codex" | "opencode" | "openclaw";
|
|
3
3
|
|
|
4
|
-
import { sanitizeToolSegment } from "
|
|
4
|
+
import { sanitizeToolSegment } from "../mcp/tools.ts";
|
|
5
5
|
|
|
6
6
|
/** Kebab-case skill folder + frontmatter name for agents that require hyphen slugs. */
|
|
7
7
|
export function skillSlug(programKey: string): string {
|
package/src/test/fixtures.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CliProgram } from "
|
|
2
|
-
import { CliFallbackMode, CliOptionKind } from "
|
|
1
|
+
import type { CliProgram } from "../core/types.ts";
|
|
2
|
+
import { CliFallbackMode, CliOptionKind } from "../core/types.ts";
|
|
3
3
|
|
|
4
4
|
export function testProgram(prog: Record<string, unknown> & { key: string; description: string }): CliProgram {
|
|
5
5
|
return { version: "0.0.0", ...prog } as CliProgram;
|
|
@@ -6,9 +6,9 @@ import { expect, test } from "bun:test";
|
|
|
6
6
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
|
-
import { bootstrapAppConfig } from "
|
|
10
|
-
import { resolveAppConfigPath } from "
|
|
11
|
-
import { mcpRequest, testProgram } from "
|
|
9
|
+
import { bootstrapAppConfig } from "../../config/bootstrap.ts";
|
|
10
|
+
import { resolveAppConfigPath } from "../../config/file.ts";
|
|
11
|
+
import { mcpRequest, testProgram } from "../fixtures.ts";
|
|
12
12
|
|
|
13
13
|
/** Tests that bootstrapAppConfig prefers host env over config file. */
|
|
14
14
|
test("bootstrapAppConfig prefers host env over config file", () => {
|
|
@@ -5,15 +5,15 @@ HTTP API integration tests: routes, tool invocation, CORS, OpenAPI, and validati
|
|
|
5
5
|
import { describe, expect, test } from "bun:test";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { $ } from "bun";
|
|
8
|
-
import { cliValidateProgram } from "
|
|
9
|
-
import { generateOpenApi } from "
|
|
10
|
-
import { API_CORS_HEADERS } from "
|
|
11
|
-
import { handleApiRequest } from "
|
|
12
|
-
import { Cli, CliContext, type CliContext as CliContextType, CliOptionKind, cliErrWithHelp } from "
|
|
13
|
-
import { LogEmitter } from "
|
|
14
|
-
import { createServerRuntime } from "
|
|
15
|
-
import { resolveHttpServeConfig } from "
|
|
16
|
-
import { nestedMcpFixture, testProgram } from "
|
|
8
|
+
import { cliValidateProgram } from "../../core/validate.ts";
|
|
9
|
+
import { generateOpenApi } from "../../http/openapi.ts";
|
|
10
|
+
import { API_CORS_HEADERS } from "../../http/result.ts";
|
|
11
|
+
import { handleApiRequest } from "../../http/server.ts";
|
|
12
|
+
import { Cli, CliContext, type CliContext as CliContextType, CliOptionKind, cliErrWithHelp } from "../../index.ts";
|
|
13
|
+
import { LogEmitter } from "../../log/emitter.ts";
|
|
14
|
+
import { createServerRuntime } from "../../server/context.ts";
|
|
15
|
+
import { resolveHttpServeConfig } from "../../server/overrides.ts";
|
|
16
|
+
import { nestedMcpFixture, testProgram } from "../fixtures.ts";
|
|
17
17
|
|
|
18
18
|
/** Program with HTTP API enabled and handlers that return values. */
|
|
19
19
|
function nestedApiFixture() {
|
|
@@ -175,7 +175,7 @@ describe("httpServer validation", () => {
|
|
|
175
175
|
handler: () => {},
|
|
176
176
|
},
|
|
177
177
|
],
|
|
178
|
-
} as unknown as import("
|
|
178
|
+
} as unknown as import("../../core/types.ts").CliProgram;
|
|
179
179
|
expect(() => cliValidateProgram(root)).toThrow(/httpServer is only supported on the program root/);
|
|
180
180
|
});
|
|
181
181
|
|
|
@@ -289,8 +289,8 @@ describe("HTTP API routes", () => {
|
|
|
289
289
|
expect(body.error).toBe("An unexpected error occurred.");
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
-
test("GET /health includes CORS headers", async () => {
|
|
293
|
-
const res = await apiRequest(program, new Request("http://127.0.0.1/health"));
|
|
292
|
+
test("GET /health/liveness includes CORS headers", async () => {
|
|
293
|
+
const res = await apiRequest(program, new Request("http://127.0.0.1/health/liveness"));
|
|
294
294
|
expect(res.status).toBe(200);
|
|
295
295
|
expect(res.headers.get("access-control-allow-origin")).toBe("*");
|
|
296
296
|
expect(await res.json()).toEqual({ ok: true });
|
|
@@ -449,9 +449,9 @@ describe("HTTP API routes", () => {
|
|
|
449
449
|
const doc = (await res.json()) as { openapi: string; paths: Record<string, unknown> };
|
|
450
450
|
expect(doc.openapi).toBe("3.1.0");
|
|
451
451
|
expect(doc.paths["/stat/owner/lookup"]).toBeDefined();
|
|
452
|
-
expect(doc.paths["/health"]).toBeDefined();
|
|
453
452
|
expect(doc.paths["/health/liveness"]).toBeDefined();
|
|
454
453
|
expect(doc.paths["/health/readiness"]).toBeDefined();
|
|
454
|
+
expect(doc.paths["/health"]).toBeUndefined();
|
|
455
455
|
});
|
|
456
456
|
|
|
457
457
|
test("GET /swagger returns Swagger UI HTML", async () => {
|
|
@@ -480,13 +480,17 @@ test("generateOpenApi includes health probe paths", () => {
|
|
|
480
480
|
{
|
|
481
481
|
get: {
|
|
482
482
|
tags: string[];
|
|
483
|
+
summary: string;
|
|
483
484
|
responses: Record<string, { content: Record<string, { schema: Record<string, unknown> }> }>;
|
|
484
485
|
};
|
|
485
486
|
}
|
|
486
487
|
>;
|
|
487
488
|
};
|
|
488
489
|
expect(doc.tags.some((t) => t.name === "health")).toBe(true);
|
|
489
|
-
expect(doc.paths["/health"]
|
|
490
|
+
expect(doc.paths["/health"]).toBeUndefined();
|
|
491
|
+
expect(doc.paths["/health/liveness"]?.get.tags).toContain("health");
|
|
492
|
+
expect(doc.paths["/health/liveness"]?.get.summary).toBe("Liveness probe");
|
|
493
|
+
expect(doc.paths["/health/readiness"]?.get.summary).toBe("Readiness probe");
|
|
490
494
|
expect(doc.paths["/health/liveness"]?.get.responses["200"]).toBeDefined();
|
|
491
495
|
expect(doc.paths["/health/readiness"]?.get.responses["200"]).toBeDefined();
|
|
492
496
|
expect(doc.paths["/health/readiness"]?.get.responses["503"]).toBeDefined();
|
|
@@ -5,18 +5,18 @@ 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 { cliSchemaExport } from "
|
|
9
|
-
import { cliValidateProgram } from "
|
|
10
|
-
import type { CliProgram } from "
|
|
11
|
-
import { buildToolCallSuccessFromResponse } from "
|
|
8
|
+
import { cliSchemaExport } from "../../core/schema.ts";
|
|
9
|
+
import { cliValidateProgram } from "../../core/validate.ts";
|
|
10
|
+
import type { CliProgram } from "../../index.ts";
|
|
11
|
+
import { buildToolCallSuccessFromResponse } from "../../mcp/result.ts";
|
|
12
12
|
import {
|
|
13
13
|
collectMcpTools,
|
|
14
14
|
mcpToolCallToArgv,
|
|
15
15
|
mcpToolDescription,
|
|
16
16
|
mcpToolName,
|
|
17
17
|
sanitizeToolSegment,
|
|
18
|
-
} from "
|
|
19
|
-
import { mcpRequest, nestedMcpFixture, testProgram } from "
|
|
18
|
+
} from "../../mcp/tools.ts";
|
|
19
|
+
import { mcpRequest, nestedMcpFixture, testProgram } from "../fixtures.ts";
|
|
20
20
|
|
|
21
21
|
test("sanitizeToolSegment normalizes dotted app keys", () => {
|
|
22
22
|
expect(sanitizeToolSegment("minimal.ts")).toBe("minimal_ts");
|