argsbarg 6.1.1 → 6.1.3
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 +72 -1
- package/README.md +17 -19
- package/bin/argsbarg +10 -0
- package/docs/README.md +4 -3
- package/docs/ai-skills.md +4 -2
- package/docs/bundled-docs.md +50 -25
- package/docs/cli-program.md +76 -10
- package/docs/config-schema.md +10 -11
- package/docs/configure.md +2 -0
- package/docs/decisions.md +40 -0
- package/docs/developing.md +43 -5
- package/docs/http-server.md +171 -0
- package/docs/json-schema-subset.md +51 -0
- package/docs/mcp.md +4 -2
- package/docs/output-schema.md +55 -62
- package/examples/formats.ts +6 -6
- package/examples/full-example/Formula/full-example.rb +35 -0
- package/examples/full-example/README.md +20 -21
- package/examples/full-example/docs/README.md +1 -1
- package/examples/full-example/docs/cli-schema.json +1790 -98
- package/examples/full-example/docs/cli.md +1990 -0
- package/examples/full-example/docs/http.md +28 -29
- package/examples/full-example/docs/mcp.md +8 -22
- package/examples/full-example/docs/openapi.json +783 -50
- package/examples/full-example/docs/skill.md +10 -10
- package/examples/full-example/justfile +11 -1
- package/examples/full-example/src/commands/render-json/__generated__/RenderJsonInputSchema.json +15 -0
- package/examples/full-example/src/commands/render-json/__generated__/index.ts +5 -0
- package/examples/full-example/src/commands/render-json/command.test.ts +46 -0
- package/examples/full-example/src/commands/render-json/command.ts +30 -0
- package/examples/full-example/src/commands/render-json/types.ts +9 -0
- package/examples/full-example/src/commands/status/__generated__/StatusJsonOutputSchema.json +15 -0
- package/examples/full-example/src/commands/status/__generated__/index.ts +2 -2
- package/examples/full-example/src/commands/status/command.ts +5 -13
- package/examples/full-example/src/commands/status/types.ts +1 -14
- package/examples/full-example/src/commands/workspaces/__generated__/WorkspaceNameInputSchema.json +15 -0
- package/examples/full-example/src/commands/workspaces/__generated__/index.ts +5 -0
- package/examples/full-example/src/commands/workspaces/command.test.ts +58 -0
- package/examples/full-example/src/commands/workspaces/command.ts +94 -0
- package/examples/full-example/src/commands/workspaces/types.ts +6 -0
- package/examples/full-example/src/db/index.test.ts +86 -0
- package/examples/full-example/src/db/index.ts +101 -0
- package/examples/full-example/src/db/migrate.test.ts +35 -0
- package/examples/full-example/src/db/migrate.ts +69 -0
- package/examples/full-example/src/db/migrations/001_workspaces.sql +6 -0
- package/examples/full-example/src/db/tables/workspaces.ts +66 -0
- package/examples/full-example/src/program.ts +11 -36
- package/examples/full-example/src/types/argsbarg.d.ts +11 -0
- package/examples/full-example/src/types/md.d.ts +4 -0
- package/examples/full-example/tsconfig.json +5 -2
- package/examples/mcp-test.ts +1 -2
- package/examples/minimal.ts +1 -7
- package/examples/nested.ts +1 -2
- package/examples/option-required.ts +1 -1
- package/examples/servers.ts +4 -5
- package/index.d.ts +440 -136
- package/package.json +19 -2
- package/src/builtins/builtins.test.ts +7 -7
- package/src/builtins/completion-bash.ts +1 -1
- package/src/builtins/completion-fish.ts +1 -1
- package/src/builtins/completion-group.ts +4 -4
- package/src/builtins/completion-simulate-shared.ts +9 -0
- 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 +4 -4
- package/src/builtins/dispatch.ts +19 -18
- package/src/builtins/export.ts +7 -5
- package/src/builtins/http.ts +68 -0
- package/src/builtins/mcp.ts +28 -4
- package/src/builtins/presentation.ts +6 -6
- package/src/builtins/registry.ts +6 -6
- package/src/builtins/scopes.ts +2 -2
- package/src/builtins/version.ts +1 -1
- package/src/cli-tool/full-example-capabilities.test.ts +10 -15
- package/src/cli-tool/main.ts +1 -1
- package/src/cli-tool/program.ts +3 -2
- package/src/cli-tool/prompt.ts +1 -1
- package/src/cli-tool/run-schemagen.ts +1 -3
- package/src/cli-tool/schemagen/cleanup.ts +6 -7
- package/src/cli-tool/schemagen/discover-schema-roots.ts +66 -120
- package/src/cli-tool/schemagen/index.ts +2 -2
- package/src/cli-tool/schemagen/names.ts +8 -13
- package/src/cli-tool/schemagen/run.ts +21 -28
- package/src/cli-tool/schemagen/schemagen.test.ts +136 -46
- 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 +36 -4
- 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/{install → configure/artifacts}/binary-placement.test.ts +1 -1
- package/src/{install → configure/artifacts}/binary-placement.ts +1 -1
- package/src/{install → configure/artifacts}/gh-release-update.ts +1 -1
- package/src/{install → configure/artifacts}/install-validate.test.ts +3 -3
- package/src/{install → configure/artifacts}/mcp-config.ts +1 -1
- package/src/{install → configure/artifacts}/mcp-opencode.test.ts +1 -1
- package/src/{install → configure/artifacts}/mcp-opencode.ts +1 -1
- package/src/{install → configure/artifacts}/paths.ts +5 -5
- package/src/configure/artifacts/plan.ts +24 -0
- package/src/{install → configure/artifacts}/status.test.ts +1 -1
- package/src/{install → configure/artifacts}/status.ts +2 -2
- package/src/{install → configure/artifacts}/target-base.ts +1 -1
- package/src/{install → configure/artifacts}/target-detect.ts +1 -1
- package/src/{install → configure/artifacts}/target-effective.ts +3 -9
- package/src/{install → configure/artifacts}/target-mcp-cli.ts +1 -1
- package/src/{install → configure/artifacts}/target-mcp-json.ts +1 -1
- package/src/{install → configure/artifacts}/target-plan-build.ts +2 -2
- package/src/{install → configure/artifacts}/target-registry.ts +2 -2
- package/src/{install → configure/artifacts}/target-scope.ts +3 -3
- package/src/{install → configure/artifacts}/target-skill.ts +1 -1
- package/src/{install → configure/artifacts}/target-types.ts +2 -2
- package/src/{install → configure/artifacts}/targets/app.ts +5 -5
- package/src/{install → configure/artifacts}/targets/chatgpt-mcp.ts +2 -2
- package/src/{install → configure/artifacts}/targets/claude-code-mcp.ts +2 -2
- package/src/{install → configure/artifacts}/targets/claude-desktop-mcp.ts +2 -2
- package/src/{install → configure/artifacts}/targets/claude-skill.ts +2 -2
- package/src/{install → configure/artifacts}/targets/codex-mcp.ts +2 -2
- package/src/{install → configure/artifacts}/targets/codex-skill.ts +2 -2
- package/src/{install → configure/artifacts}/targets/configure.ts +5 -5
- package/src/{install → configure/artifacts}/targets/cursor-mcp.ts +2 -2
- package/src/{install → configure/artifacts}/targets/cursor-skill.ts +2 -2
- package/src/{install → configure/artifacts}/targets/index.ts +1 -1
- package/src/{install → configure/artifacts}/targets/openclaw-mcp.ts +2 -2
- package/src/{install → configure/artifacts}/targets/openclaw-skill.ts +3 -3
- package/src/{install → configure/artifacts}/targets/opencode-mcp.ts +5 -5
- package/src/{install → configure/artifacts}/targets/opencode-skill.ts +3 -3
- package/src/{install → configure/artifacts}/targets.test.ts +1 -1
- package/src/{install → configure/artifacts}/uninstall.ts +1 -1
- package/src/configure/configure.test.ts +11 -11
- package/src/configure/index.ts +14 -14
- package/src/configure/prompt.ts +2 -2
- package/src/{context.ts → core/context.ts} +26 -20
- package/src/core/json-leaf.test.ts +156 -0
- package/src/{leaf-inputs.test.ts → core/leaf-inputs.test.ts} +7 -7
- package/src/{leaf-inputs.ts → core/leaf-inputs.ts} +76 -16
- package/src/{parse.test.ts → core/parse.test.ts} +97 -109
- package/src/{parse.ts → core/parse.ts} +173 -25
- package/src/{schema.ts → core/schema.ts} +25 -13
- package/src/{types.ts → core/types.ts} +238 -35
- package/src/{validate.ts → core/validate.ts} +51 -29
- package/src/docs/builtin.ts +8 -19
- package/src/docs/{api-guide.test.ts → cli-guide.test.ts} +21 -21
- package/src/docs/{api-guide.ts → cli-guide.ts} +45 -16
- package/src/docs/docs.test.ts +76 -41
- package/src/docs/http-guide.ts +37 -34
- package/src/docs/mcp-guide.ts +12 -14
- package/src/docs/mcp-resources.test.ts +2 -3
- package/src/docs/mcp-resources.ts +6 -11
- package/src/docs/resolve.ts +22 -30
- package/src/docs/save.ts +3 -3
- package/src/exports/cli.ts +47 -0
- package/src/exports/headless.ts +13 -0
- package/src/exports/http.ts +6 -0
- package/src/exports/mcp.ts +6 -0
- package/src/{headless.test.ts → headless/routing.test.ts} +3 -3
- package/src/{headless.ts → headless/routing.ts} +3 -3
- package/src/headless/tool-call.ts +114 -46
- package/src/help.test.ts +152 -0
- package/src/help.ts +54 -18
- package/src/hooks/builtin.ts +20 -0
- package/src/hooks/run.ts +142 -0
- package/src/http/openapi.ts +182 -0
- package/src/http/readiness.ts +78 -0
- package/src/{api → http}/result.ts +16 -5
- package/src/http/routes.ts +329 -0
- package/src/http/server.ts +225 -0
- package/src/index.ts +38 -25
- package/src/log/ecs.test.ts +43 -0
- package/src/log/ecs.ts +59 -0
- package/src/log/emitter.ts +166 -0
- package/src/mcp/bundle.ts +2 -2
- package/src/mcp/claude.test.ts +1 -1
- package/src/mcp/claude.ts +4 -4
- package/src/{hidden-mcpb.test.ts → mcp/hidden-mcpb.test.ts} +10 -9
- package/src/mcp/result.ts +2 -2
- package/src/mcp/server.ts +54 -6
- package/src/mcp/tools.ts +18 -20
- package/src/{capabilities.ts → runtime/capabilities.ts} +11 -11
- package/src/{cli-errors.ts → runtime/cli-errors.ts} +4 -4
- package/src/{cli.ts → runtime/cli.ts} +160 -50
- package/src/runtime/exposure.ts +102 -0
- package/src/{invoke.test.ts → runtime/invoke.test.ts} +31 -7
- package/src/server/context.ts +25 -0
- package/src/server/overrides.ts +112 -0
- package/src/skill/generate.ts +8 -8
- 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 → test/fixtures.ts} +3 -2
- package/src/{config.integration.test.ts → test/integration/config.test.ts} +8 -8
- package/src/{api.integration.test.ts → test/integration/http.test.ts} +170 -67
- package/src/{mcp.integration.test.ts → test/integration/mcp.test.ts} +11 -57
- package/docs/api-server.md +0 -141
- package/examples/full-example/docs/api.md +0 -511
- package/examples/full-example/src/commands/status/__generated__/outputSchema.json +0 -28
- package/examples/full-example/src/config/__generated__/configSchema.json +0 -40
- package/examples/full-example/src/config/__generated__/index.ts +0 -5
- package/examples/full-example/src/config/types.ts +0 -24
- package/src/api/openapi.ts +0 -117
- package/src/api/server.ts +0 -120
- package/src/builtins/api.ts +0 -38
- package/src/hidden.ts +0 -30
- package/src/install/plan.ts +0 -53
- /package/src/{install → configure/artifacts}/detect-installed.ts +0 -0
- /package/src/{install → configure/artifacts}/gh-release-update.test.ts +0 -0
- /package/src/{install → configure/artifacts}/mcp-codex.test.ts +0 -0
- /package/src/{install → configure/artifacts}/mcp-codex.ts +0 -0
- /package/src/{install → configure/artifacts}/mcp-openclaw.test.ts +0 -0
- /package/src/{install → configure/artifacts}/mcp-openclaw.ts +0 -0
- /package/src/{install → configure/artifacts}/normalize-uninstall.ts +0 -0
- /package/src/{install → configure/artifacts}/normalize.ts +0 -0
- /package/src/{install → configure/artifacts}/opts.ts +0 -0
- /package/src/{install → configure/artifacts}/shell.ts +0 -0
- /package/src/{formats.test.ts → core/formats.test.ts} +0 -0
- /package/src/{formats.ts → core/formats.ts} +0 -0
- /package/src/{respond.ts → core/respond.ts} +0 -0
- /package/src/{types.test.ts → core/types.test.ts} +0 -0
- /package/src/{api → http}/schema-deref.test.ts +0 -0
- /package/src/{api → http}/schema-deref.ts +0 -0
|
@@ -5,16 +5,16 @@ 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 {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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";
|
|
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 () => {
|
|
17
|
-
const indexPath = join(import.meta.dir, "index.ts");
|
|
17
|
+
const indexPath = join(import.meta.dir, "../index.ts");
|
|
18
18
|
const { stdout } = await $`bun -e ${`
|
|
19
19
|
import { Cli, CliProgram } from ${JSON.stringify(indexPath)};
|
|
20
20
|
const program = {
|
|
@@ -45,6 +45,30 @@ test("ctx.invocation is mcp via Cli.invoke", async () => {
|
|
|
45
45
|
expect(seen).toBe("mcp");
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
/** Tests that ctx.locals.requestId is seeded before handler on invoke. */
|
|
49
|
+
test("Cli.invoke seeds ctx.locals.requestId", async () => {
|
|
50
|
+
let requestId = "";
|
|
51
|
+
const root = testProgram({
|
|
52
|
+
key: "app",
|
|
53
|
+
description: "",
|
|
54
|
+
hooks: {
|
|
55
|
+
beforeInvoke: (ctx: CliContext) => {
|
|
56
|
+
requestId = String(ctx.locals.requestId ?? "");
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
handler: () => {},
|
|
60
|
+
});
|
|
61
|
+
cliValidateProgram(root);
|
|
62
|
+
const wireId = "00000000-0000-4000-8000-000000000001";
|
|
63
|
+
const result = await new Cli(root).invoke([], {
|
|
64
|
+
invocation: "http",
|
|
65
|
+
requestId: wireId,
|
|
66
|
+
http: { request: new Request("http://localhost/"), clientIp: "127.0.0.1", requestId: wireId },
|
|
67
|
+
});
|
|
68
|
+
expect(result.kind).toBe("ok");
|
|
69
|
+
expect(requestId).toBe(wireId);
|
|
70
|
+
});
|
|
71
|
+
|
|
48
72
|
/** Cli.invoke rejects invalid Enum value. */
|
|
49
73
|
test("Cli.invoke rejects invalid Enum value", async () => {
|
|
50
74
|
const root = testProgram({
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Per-server mutable handle context passed through HTTP/MCP dispatch.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { CliHttpWireHooks, CliMcpWireHooks, ServerRuntime, ServerState } from "~/core/types.ts";
|
|
6
|
+
import type { LogEmitter } from "~/log/emitter.ts";
|
|
7
|
+
import type { ResolvedHttpServeConfig, ResolvedMcpServeConfig } from "./overrides.ts";
|
|
8
|
+
|
|
9
|
+
/** Shared server state for one HTTP or MCP serve session. */
|
|
10
|
+
export interface ServerHandleContext {
|
|
11
|
+
runtime: ServerRuntime;
|
|
12
|
+
emitter: LogEmitter;
|
|
13
|
+
http?: ResolvedHttpServeConfig;
|
|
14
|
+
mcp?: ResolvedMcpServeConfig;
|
|
15
|
+
httpHooks?: CliHttpWireHooks;
|
|
16
|
+
mcpHooks?: CliMcpWireHooks;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Creates a fresh {@link ServerRuntime} for HTTP or MCP. */
|
|
20
|
+
export function createServerRuntime(
|
|
21
|
+
program: import("~/core/types.ts").CliProgram,
|
|
22
|
+
surface: "http" | "mcp",
|
|
23
|
+
): ServerRuntime {
|
|
24
|
+
return { state: {} as ServerState, program, surface };
|
|
25
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CLI flag and programmatic overrides merged into HTTP/MCP server runtime config.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { resolveAppConfigDir } from "~/config/file.ts";
|
|
7
|
+
import type { CliProgram } from "~/core/types.ts";
|
|
8
|
+
import type { ResolvedLogConfig } from "~/log/emitter.ts";
|
|
9
|
+
|
|
10
|
+
/** Overrides from `myapp http` / `serveHttp()` flags and embedders. */
|
|
11
|
+
export interface ServeOverrides {
|
|
12
|
+
host?: string;
|
|
13
|
+
port?: number;
|
|
14
|
+
trustProxy?: boolean;
|
|
15
|
+
obscureErrors?: boolean;
|
|
16
|
+
logFormat?: "json" | "text";
|
|
17
|
+
logFile?: string;
|
|
18
|
+
noAccessLog?: boolean;
|
|
19
|
+
dev?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Resolved HTTP listen and error options after merging schema + overrides. */
|
|
23
|
+
export interface ResolvedHttpServeConfig {
|
|
24
|
+
hostname: string;
|
|
25
|
+
port: number;
|
|
26
|
+
trustProxy: boolean;
|
|
27
|
+
obscureUnexpected: boolean;
|
|
28
|
+
log: ResolvedLogConfig;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Resolved MCP serve options after merging schema + overrides. */
|
|
32
|
+
export interface ResolvedMcpServeConfig {
|
|
33
|
+
obscureUnexpected: boolean;
|
|
34
|
+
log: ResolvedLogConfig;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function resolveLogFile(program: CliProgram, logFile: string | undefined): string | undefined {
|
|
38
|
+
if (!logFile) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
if (logFile.startsWith("/") || logFile.startsWith("~")) {
|
|
42
|
+
return logFile;
|
|
43
|
+
}
|
|
44
|
+
return join(resolveAppConfigDir(program), logFile);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Builds resolved HTTP server config (CLI flags > program schema). */
|
|
48
|
+
export function resolveHttpServeConfig(program: CliProgram, overrides: ServeOverrides = {}): ResolvedHttpServeConfig {
|
|
49
|
+
const http = program.httpServer;
|
|
50
|
+
const obscureUnexpected = overrides.obscureErrors ?? http?.errors?.obscureUnexpected ?? false;
|
|
51
|
+
return {
|
|
52
|
+
hostname: overrides.host ?? http?.host ?? "127.0.0.1",
|
|
53
|
+
port: overrides.port ?? http?.port ?? 3000,
|
|
54
|
+
trustProxy: overrides.trustProxy ?? http?.trustProxy ?? false,
|
|
55
|
+
obscureUnexpected,
|
|
56
|
+
log: {
|
|
57
|
+
format: overrides.logFormat ?? program.log?.format ?? "json",
|
|
58
|
+
file: resolveLogFile(program, overrides.logFile ?? program.log?.file),
|
|
59
|
+
access: overrides.noAccessLog ? false : (program.log?.access ?? true),
|
|
60
|
+
errors: program.log?.errors ?? true,
|
|
61
|
+
dev: overrides.dev ?? false,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Builds resolved MCP server config (CLI flags > program schema). */
|
|
67
|
+
export function resolveMcpServeConfig(program: CliProgram, overrides: ServeOverrides = {}): ResolvedMcpServeConfig {
|
|
68
|
+
const mcp = program.mcpServer;
|
|
69
|
+
return {
|
|
70
|
+
obscureUnexpected: overrides.obscureErrors ?? mcp?.errors?.obscureUnexpected ?? false,
|
|
71
|
+
log: {
|
|
72
|
+
format: overrides.logFormat ?? program.log?.format ?? "json",
|
|
73
|
+
file: resolveLogFile(program, overrides.logFile ?? program.log?.file),
|
|
74
|
+
access: program.log?.access ?? true,
|
|
75
|
+
errors: program.log?.errors ?? true,
|
|
76
|
+
dev: overrides.dev ?? false,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Parses `http` / `mcp serve` CLI opts into {@link ServeOverrides}. */
|
|
82
|
+
export function serveOverridesFromOpts(opts: Record<string, string>, surface: "http" | "mcp"): ServeOverrides {
|
|
83
|
+
const out: ServeOverrides = {};
|
|
84
|
+
if (opts.host) {
|
|
85
|
+
out.host = opts.host;
|
|
86
|
+
}
|
|
87
|
+
if (opts.port) {
|
|
88
|
+
const port = Number(opts.port);
|
|
89
|
+
if (!Number.isNaN(port)) {
|
|
90
|
+
out.port = port;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (opts["trust-proxy"]) {
|
|
94
|
+
out.trustProxy = true;
|
|
95
|
+
}
|
|
96
|
+
if (opts["obscure-errors"]) {
|
|
97
|
+
out.obscureErrors = true;
|
|
98
|
+
}
|
|
99
|
+
if (opts["log-format"] === "json" || opts["log-format"] === "text") {
|
|
100
|
+
out.logFormat = opts["log-format"];
|
|
101
|
+
}
|
|
102
|
+
if (opts["log-file"]) {
|
|
103
|
+
out.logFile = opts["log-file"];
|
|
104
|
+
}
|
|
105
|
+
if (opts["no-access-log"] && surface === "http") {
|
|
106
|
+
out.noAccessLog = true;
|
|
107
|
+
}
|
|
108
|
+
if (opts.dev) {
|
|
109
|
+
out.dev = true;
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
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 {
|
|
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";
|
|
7
9
|
import {
|
|
8
10
|
collectMcpTools,
|
|
9
11
|
type McpToolDef,
|
|
10
12
|
mcpServerId,
|
|
11
13
|
resolveMcpSchemaUri,
|
|
12
14
|
sanitizeToolSegment,
|
|
13
|
-
} from "
|
|
14
|
-
import { collectOptionDefs } from "../parse.ts";
|
|
15
|
-
import { CliOptionKind, type CliProgram } from "../types.ts";
|
|
15
|
+
} from "~/mcp/tools.ts";
|
|
16
16
|
import type { SkillTarget } from "./naming.ts";
|
|
17
17
|
import { skillDirNameForTarget, skillFrontmatterName } from "./naming.ts";
|
|
18
18
|
|
|
@@ -149,7 +149,7 @@ function buildSkillMd(root: CliProgram, target: SkillTarget, dirName: string): s
|
|
|
149
149
|
"",
|
|
150
150
|
"## Reference",
|
|
151
151
|
"",
|
|
152
|
-
`For full detail, open \`reference.md\` in this skill directory (same as \`${root.key} docs
|
|
152
|
+
`For full detail, open \`reference.md\` in this skill directory (same as \`${root.key} docs cli\`).`,
|
|
153
153
|
"",
|
|
154
154
|
);
|
|
155
155
|
|
|
@@ -190,9 +190,9 @@ function buildSkillMd(root: CliProgram, target: SkillTarget, dirName: string): s
|
|
|
190
190
|
return lines.join("\n");
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
/** Builds reference.md with the
|
|
193
|
+
/** Builds reference.md with the compact `docs cli` markdown guide. */
|
|
194
194
|
function buildReferenceMd(root: CliProgram): string {
|
|
195
|
-
return
|
|
195
|
+
return generateCliGuide(root, { compact: true });
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
/** Builds MCP routing SKILL.md for Claude Code plugin zips. */
|
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 {
|
|
4
|
-
import
|
|
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 {
|
|
@@ -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;
|
|
@@ -166,6 +166,7 @@ export function nestedDocsFallbackFixture(): CliProgram {
|
|
|
166
166
|
return testProgram({
|
|
167
167
|
key: "app",
|
|
168
168
|
description: "",
|
|
169
|
+
docs: { enabled: false },
|
|
169
170
|
commands: [
|
|
170
171
|
{
|
|
171
172
|
key: "docs",
|
|
@@ -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 "~/test/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", () => {
|
|
@@ -124,13 +124,13 @@ test("MCP config file loads and exports vars for tool handlers", async () => {
|
|
|
124
124
|
rmSync(dir, { recursive: true, force: true });
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
/** Cli.run docs
|
|
128
|
-
test("Cli.run docs
|
|
127
|
+
/** Cli.run docs cli skips required appConfig exit. */
|
|
128
|
+
test("Cli.run docs cli skips required appConfig exit", async () => {
|
|
129
129
|
const dir = mkdtempSync(join(tmpdir(), "argsbarg-docs-skip-"));
|
|
130
130
|
const configFile = join(dir, ".local", "lib", "docs_skip_test", "config");
|
|
131
131
|
mkdirSync(dirname(configFile), { recursive: true });
|
|
132
132
|
writeFileSync(configFile, "{}\n");
|
|
133
|
-
const entry = join(import.meta.dir, "index.ts");
|
|
133
|
+
const entry = join(import.meta.dir, "..", "..", "index.ts");
|
|
134
134
|
const mainPath = join(dir, "run-docs.ts");
|
|
135
135
|
writeFileSync(
|
|
136
136
|
mainPath,
|
|
@@ -139,7 +139,7 @@ const program = {
|
|
|
139
139
|
key: "docs-skip-test",
|
|
140
140
|
version: "1.0.0",
|
|
141
141
|
description: "test",
|
|
142
|
-
docs: {
|
|
142
|
+
docs: { topics: { readme: { text: "# readme\\n" } } },
|
|
143
143
|
appConfig: {
|
|
144
144
|
entries: { token: { description: "Token.", env: "DOCS_SKIP_RUN_TOKEN" } },
|
|
145
145
|
},
|
|
@@ -151,7 +151,7 @@ await new Cli(program).run(process.argv.slice(2));
|
|
|
151
151
|
const env = { ...process.env, HOME: dir } as Record<string, string | undefined>;
|
|
152
152
|
delete env.DOCS_SKIP_RUN_TOKEN;
|
|
153
153
|
try {
|
|
154
|
-
const proc = Bun.spawn(["bun", "run", mainPath, "docs", "
|
|
154
|
+
const proc = Bun.spawn(["bun", "run", mainPath, "docs", "cli"], {
|
|
155
155
|
stdout: "pipe",
|
|
156
156
|
stderr: "pipe",
|
|
157
157
|
env,
|