specli 0.0.20 → 0.0.22

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.
Files changed (96) hide show
  1. package/dist/ai/tools.d.ts +1 -1
  2. package/dist/cli/compile.js +1 -1
  3. package/dist/cli/main.js +2 -2
  4. package/dist/cli/{capabilities.d.ts → model/capabilities.d.ts} +3 -3
  5. package/dist/cli/{command-id.js → model/command-id.js} +1 -1
  6. package/dist/cli/{command-model.d.ts → model/command-model.d.ts} +9 -8
  7. package/dist/cli/{command-model.js → model/command-model.js} +4 -4
  8. package/dist/cli/{naming.d.ts → model/naming.d.ts} +1 -1
  9. package/dist/cli/{naming.js → model/naming.js} +2 -2
  10. package/dist/cli/{schema.d.ts → model/schema.d.ts} +6 -5
  11. package/dist/cli/{auth-schemes.d.ts → parse/auth-schemes.d.ts} +1 -1
  12. package/dist/cli/{auth-schemes.js → parse/auth-schemes.js} +1 -1
  13. package/dist/cli/{operations.d.ts → parse/operations.d.ts} +1 -1
  14. package/dist/cli/{params.d.ts → parse/params.d.ts} +4 -3
  15. package/dist/cli/{params.js → parse/params.js} +1 -1
  16. package/dist/cli/{positional.d.ts → parse/positional.d.ts} +3 -3
  17. package/dist/cli/{request-body.d.ts → parse/request-body.d.ts} +3 -2
  18. package/dist/cli/{request-body.js → parse/request-body.js} +1 -1
  19. package/dist/cli/{server.d.ts → parse/servers.d.ts} +1 -1
  20. package/dist/cli/runtime/auth/resolve.d.ts +3 -2
  21. package/dist/cli/runtime/context.d.ts +9 -9
  22. package/dist/cli/runtime/context.js +9 -9
  23. package/dist/cli/runtime/execute.d.ts +7 -5
  24. package/dist/cli/runtime/execute.js +1 -1
  25. package/dist/cli/runtime/generated.d.ts +3 -3
  26. package/dist/cli/runtime/request.d.ts +4 -3
  27. package/dist/cli/runtime/server-url.d.ts +1 -1
  28. package/dist/cli/runtime/validate/coerce.d.ts +1 -1
  29. package/dist/cli/runtime/validate/schema.d.ts +2 -2
  30. package/dist/cli/{spec-id.d.ts → spec/id.d.ts} +1 -1
  31. package/dist/cli/{spec-id.js → spec/id.js} +1 -1
  32. package/dist/cli/{spec-loader.d.ts → spec/loader.d.ts} +1 -1
  33. package/dist/cli/{spec-loader.js → spec/loader.js} +4 -4
  34. package/package.json +3 -2
  35. package/dist/ai/tools.test.d.ts +0 -1
  36. package/dist/ai/tools.test.js +0 -49
  37. package/dist/cli/auth-requirements.test.d.ts +0 -1
  38. package/dist/cli/auth-requirements.test.js +0 -16
  39. package/dist/cli/auth-schemes.test.d.ts +0 -1
  40. package/dist/cli/auth-schemes.test.js +0 -56
  41. package/dist/cli/capabilities.test.d.ts +0 -1
  42. package/dist/cli/capabilities.test.js +0 -84
  43. package/dist/cli/command-id.test.d.ts +0 -1
  44. package/dist/cli/command-id.test.js +0 -27
  45. package/dist/cli/command-model.test.d.ts +0 -1
  46. package/dist/cli/command-model.test.js +0 -40
  47. package/dist/cli/naming.test.d.ts +0 -1
  48. package/dist/cli/naming.test.js +0 -75
  49. package/dist/cli/operations.test.d.ts +0 -1
  50. package/dist/cli/operations.test.js +0 -51
  51. package/dist/cli/params.test.d.ts +0 -1
  52. package/dist/cli/params.test.js +0 -62
  53. package/dist/cli/positional.test.d.ts +0 -1
  54. package/dist/cli/positional.test.js +0 -60
  55. package/dist/cli/request-body.test.d.ts +0 -1
  56. package/dist/cli/request-body.test.js +0 -31
  57. package/dist/cli/runtime/body-flags.test.d.ts +0 -1
  58. package/dist/cli/runtime/body-flags.test.js +0 -192
  59. package/dist/cli/runtime/request.test.d.ts +0 -1
  60. package/dist/cli/runtime/request.test.js +0 -332
  61. package/dist/cli/runtime/validate/coerce.test.d.ts +0 -1
  62. package/dist/cli/runtime/validate/coerce.test.js +0 -75
  63. package/dist/cli/server.test.d.ts +0 -1
  64. package/dist/cli/server.test.js +0 -49
  65. package/dist/compiled.d.ts +0 -2
  66. package/dist/compiled.js +0 -21
  67. package/dist/macros/env.d.ts +0 -10
  68. package/dist/macros/env.js +0 -22
  69. package/dist/macros/spec.d.ts +0 -5
  70. package/dist/macros/spec.js +0 -16
  71. package/dist/macros/version.d.ts +0 -4
  72. package/dist/macros/version.js +0 -13
  73. /package/dist/cli/{crypto.d.ts → core/crypto.d.ts} +0 -0
  74. /package/dist/cli/{crypto.js → core/crypto.js} +0 -0
  75. /package/dist/cli/{pluralize.d.ts → core/pluralize.d.ts} +0 -0
  76. /package/dist/cli/{pluralize.js → core/pluralize.js} +0 -0
  77. /package/dist/cli/{stable-json.d.ts → core/stable-json.d.ts} +0 -0
  78. /package/dist/cli/{stable-json.js → core/stable-json.js} +0 -0
  79. /package/dist/cli/{strings.d.ts → core/strings.d.ts} +0 -0
  80. /package/dist/cli/{strings.js → core/strings.js} +0 -0
  81. /package/dist/cli/{types.d.ts → core/types.d.ts} +0 -0
  82. /package/dist/cli/{types.js → core/types.js} +0 -0
  83. /package/dist/cli/{capabilities.js → model/capabilities.js} +0 -0
  84. /package/dist/cli/{command-id.d.ts → model/command-id.d.ts} +0 -0
  85. /package/dist/cli/{command-index.d.ts → model/command-index.d.ts} +0 -0
  86. /package/dist/cli/{command-index.js → model/command-index.js} +0 -0
  87. /package/dist/cli/{schema.js → model/schema.js} +0 -0
  88. /package/dist/cli/{auth-requirements.d.ts → parse/auth-requirements.d.ts} +0 -0
  89. /package/dist/cli/{auth-requirements.js → parse/auth-requirements.js} +0 -0
  90. /package/dist/cli/{operations.js → parse/operations.js} +0 -0
  91. /package/dist/cli/{positional.js → parse/positional.js} +0 -0
  92. /package/dist/cli/{schema-shape.d.ts → parse/schema-shape.d.ts} +0 -0
  93. /package/dist/cli/{schema-shape.js → parse/schema-shape.js} +0 -0
  94. /package/dist/cli/{server.js → parse/servers.js} +0 -0
  95. /package/dist/cli/{derive-name.d.ts → spec/derive-name.d.ts} +0 -0
  96. /package/dist/cli/{derive-name.js → spec/derive-name.js} +0 -0
@@ -111,7 +111,7 @@ export declare function specli(options: SpecliToolOptions): Promise<import("ai")
111
111
  }[];
112
112
  flags: {
113
113
  name: string;
114
- type: import("../cli/schema-shape.js").ParamType;
114
+ type: import("../cli/parse/schema-shape.js").ParamType;
115
115
  required: boolean;
116
116
  description: string | undefined;
117
117
  }[];
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { deriveBinaryName } from "./derive-name.js";
5
+ import { deriveBinaryName } from "./spec/derive-name.js";
6
6
  // Resolve the package root directory (at runtime this file is at dist/cli/compile.js)
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
  const packageRoot = path.resolve(__dirname, "../..");
package/dist/cli/main.js CHANGED
@@ -19,13 +19,13 @@ function getPackageVersion() {
19
19
  return "0.0.0";
20
20
  }
21
21
  }
22
+ import { stableStringify } from "./core/stable-json.js";
23
+ import { toMinimalSchemaOutput } from "./model/schema.js";
22
24
  import { readStdinText } from "./runtime/compat.js";
23
25
  import { buildRuntimeContext } from "./runtime/context.js";
24
26
  import { addGeneratedCommands } from "./runtime/generated.js";
25
27
  import { deleteToken, getToken, setToken } from "./runtime/profile/secrets.js";
26
28
  import { readProfiles, upsertProfile, writeProfiles, } from "./runtime/profile/store.js";
27
- import { toMinimalSchemaOutput } from "./schema.js";
28
- import { stableStringify } from "./stable-json.js";
29
29
  export async function main(argv, options = {}) {
30
30
  const program = new Command();
31
31
  // Get version - use embedded version if available, otherwise read from package.json
@@ -1,7 +1,7 @@
1
- import type { AuthScheme, AuthSchemeKind } from "./auth-schemes.js";
1
+ import type { NormalizedOperation, OpenApiDoc } from "../core/types.js";
2
+ import type { AuthScheme, AuthSchemeKind } from "../parse/auth-schemes.js";
3
+ import type { ServerInfo } from "../parse/servers.js";
2
4
  import type { CommandModel } from "./command-model.js";
3
- import type { ServerInfo } from "./server.js";
4
- import type { NormalizedOperation, OpenApiDoc } from "./types.js";
5
5
  export type Capabilities = {
6
6
  servers: {
7
7
  count: number;
@@ -1,4 +1,4 @@
1
- import { kebabCase } from "./strings.js";
1
+ import { kebabCase } from "../core/strings.js";
2
2
  export function buildCommandId(parts) {
3
3
  // operationKey is the ultimate disambiguator, but we keep the id readable.
4
4
  // Example:
@@ -1,9 +1,10 @@
1
- import type { AuthSummary } from "./auth-requirements.js";
2
- import type { AuthScheme } from "./auth-schemes.js";
1
+ import type { JsonSchema, SecurityRequirement } from "../core/types.js";
2
+ import { type AuthSummary } from "../parse/auth-requirements.js";
3
+ import type { AuthScheme } from "../parse/auth-schemes.js";
4
+ import { type ParamSpec } from "../parse/params.js";
5
+ import { type PositionalArg } from "../parse/positional.js";
6
+ import { type RequestBodyInfo } from "../parse/request-body.js";
3
7
  import type { PlannedOperation } from "./naming.js";
4
- import type { ParamSpec } from "./params.js";
5
- import type { RequestBodyInfo } from "./request-body.js";
6
- import type { SecurityRequirement } from "./types.js";
7
8
  export type CommandAction = {
8
9
  id: string;
9
10
  key: string;
@@ -17,12 +18,12 @@ export type CommandAction = {
17
18
  description?: string;
18
19
  deprecated?: boolean;
19
20
  style: PlannedOperation["style"];
20
- positionals: Array<import("./positional.js").PositionalArg>;
21
- flags: Array<Pick<import("./params.js").ParamSpec, "in" | "name" | "flag" | "required" | "description" | "type" | "format" | "enum" | "itemType" | "itemFormat" | "itemEnum">>;
21
+ positionals: PositionalArg[];
22
+ flags: Array<Pick<ParamSpec, "in" | "name" | "flag" | "required" | "description" | "type" | "format" | "enum" | "itemType" | "itemFormat" | "itemEnum">>;
22
23
  params: ParamSpec[];
23
24
  auth: AuthSummary;
24
25
  requestBody?: RequestBodyInfo;
25
- requestBodySchema?: import("./types.js").JsonSchema;
26
+ requestBodySchema?: JsonSchema;
26
27
  };
27
28
  export type CommandResource = {
28
29
  resource: string;
@@ -1,8 +1,8 @@
1
- import { summarizeAuth } from "./auth-requirements.js";
1
+ import { summarizeAuth } from "../parse/auth-requirements.js";
2
+ import { deriveParamSpecs } from "../parse/params.js";
3
+ import { deriveFlags, derivePositionals, } from "../parse/positional.js";
4
+ import { deriveRequestBodyInfo, } from "../parse/request-body.js";
2
5
  import { buildCommandId } from "./command-id.js";
3
- import { deriveParamSpecs } from "./params.js";
4
- import { deriveFlags, derivePositionals } from "./positional.js";
5
- import { deriveRequestBodyInfo } from "./request-body.js";
6
6
  export function buildCommandModel(planned, options) {
7
7
  const byResource = new Map();
8
8
  for (const op of planned) {
@@ -1,4 +1,4 @@
1
- import type { NormalizedOperation } from "./types.js";
1
+ import type { NormalizedOperation } from "../core/types.js";
2
2
  export type PlannedOperation = NormalizedOperation & {
3
3
  resource: string;
4
4
  action: string;
@@ -1,5 +1,5 @@
1
- import { pluralize } from "./pluralize.js";
2
- import { kebabCase } from "./strings.js";
1
+ import { pluralize } from "../core/pluralize.js";
2
+ import { kebabCase } from "../core/strings.js";
3
3
  const GENERIC_TAGS = new Set(["default", "defaults", "api"]);
4
4
  function getPathSegments(path) {
5
5
  return path
@@ -1,9 +1,10 @@
1
- import type { AuthScheme } from "./auth-schemes.js";
1
+ import type { LoadedSpec, NormalizedOperation } from "../core/types.js";
2
+ import type { AuthScheme } from "../parse/auth-schemes.js";
3
+ import type { ServerInfo } from "../parse/servers.js";
2
4
  import type { Capabilities } from "./capabilities.js";
5
+ import type { CommandsIndex } from "./command-index.js";
3
6
  import type { CommandModel } from "./command-model.js";
4
7
  import type { PlannedOperation } from "./naming.js";
5
- import type { ServerInfo } from "./server.js";
6
- import type { LoadedSpec, NormalizedOperation } from "./types.js";
7
8
  export type SchemaOutput = {
8
9
  schemaVersion: 1;
9
10
  openapi: {
@@ -22,8 +23,8 @@ export type SchemaOutput = {
22
23
  operations: NormalizedOperation[];
23
24
  planned?: PlannedOperation[];
24
25
  commands?: CommandModel;
25
- commandsIndex?: import("./command-index.js").CommandsIndex;
26
+ commandsIndex?: CommandsIndex;
26
27
  };
27
28
  export type MinimalSchemaOutput = Pick<SchemaOutput, "schemaVersion" | "openapi" | "spec" | "capabilities" | "commands">;
28
- export declare function buildSchemaOutput(loaded: LoadedSpec, operations: NormalizedOperation[], planned: PlannedOperation[] | undefined, servers: ServerInfo[], authSchemes: AuthScheme[], commands: CommandModel | undefined, commandsIndex: import("./command-index.js").CommandsIndex | undefined, capabilities: Capabilities): SchemaOutput;
29
+ export declare function buildSchemaOutput(loaded: LoadedSpec, operations: NormalizedOperation[], planned: PlannedOperation[] | undefined, servers: ServerInfo[], authSchemes: AuthScheme[], commands: CommandModel | undefined, commandsIndex: CommandsIndex | undefined, capabilities: Capabilities): SchemaOutput;
29
30
  export declare function toMinimalSchemaOutput(output: SchemaOutput): MinimalSchemaOutput;
@@ -1,4 +1,4 @@
1
- import type { OpenApiDoc } from "./types.js";
1
+ import type { OpenApiDoc } from "../core/types.js";
2
2
  export type AuthSchemeKind = "http-bearer" | "http-basic" | "api-key" | "oauth2" | "openIdConnect" | "unknown";
3
3
  export type AuthScheme = {
4
4
  key: string;
@@ -1,4 +1,4 @@
1
- import { kebabCase } from "./strings.js";
1
+ import { kebabCase } from "../core/strings.js";
2
2
  function parseOAuthFlow(flow) {
3
3
  if (!flow)
4
4
  return undefined;
@@ -1,2 +1,2 @@
1
- import type { NormalizedOperation, OpenApiDoc } from "./types.js";
1
+ import type { NormalizedOperation, OpenApiDoc } from "../core/types.js";
2
2
  export declare function indexOperations(doc: OpenApiDoc): NormalizedOperation[];
@@ -1,5 +1,6 @@
1
- import type { NormalizedOperation, NormalizedParameter } from "./types.js";
2
- export type ParamType = import("./schema-shape.js").ParamType;
1
+ import type { JsonSchema, NormalizedOperation, NormalizedParameter } from "../core/types.js";
2
+ import { type ParamType } from "./schema-shape.js";
3
+ export type { ParamType };
3
4
  export type ParamSpec = {
4
5
  kind: "positional" | "flag";
5
6
  in: NormalizedParameter["in"];
@@ -13,6 +14,6 @@ export type ParamSpec = {
13
14
  itemType?: ParamType;
14
15
  itemFormat?: string;
15
16
  itemEnum?: string[];
16
- schema?: import("./types.js").JsonSchema;
17
+ schema?: JsonSchema;
17
18
  };
18
19
  export declare function deriveParamSpecs(op: NormalizedOperation): ParamSpec[];
@@ -1,5 +1,5 @@
1
+ import { kebabCase } from "../core/strings.js";
1
2
  import { getSchemaEnumStrings, getSchemaFormat, getSchemaType, } from "./schema-shape.js";
2
- import { kebabCase } from "./strings.js";
3
3
  export function deriveParamSpecs(op) {
4
4
  const out = [];
5
5
  for (const p of op.parameters) {
@@ -1,4 +1,4 @@
1
- import type { ParamSpec } from "./params.js";
1
+ import type { ParamSpec, ParamType } from "./params.js";
2
2
  export type ActionShapeForCli = {
3
3
  pathArgs: string[];
4
4
  params: ParamSpec[];
@@ -7,12 +7,12 @@ export type PositionalArg = {
7
7
  name: string;
8
8
  required: boolean;
9
9
  description?: string;
10
- type: import("./schema-shape.js").ParamType;
10
+ type: ParamType;
11
11
  format?: string;
12
12
  enum?: string[];
13
13
  };
14
14
  export type FlagsIndex = {
15
- flags: Array<Pick<import("./params.js").ParamSpec, "in" | "name" | "flag" | "required" | "description" | "type" | "format" | "enum" | "itemType" | "itemFormat" | "itemEnum">>;
15
+ flags: Array<Pick<ParamSpec, "in" | "name" | "flag" | "required" | "description" | "type" | "format" | "enum" | "itemType" | "itemFormat" | "itemEnum">>;
16
16
  };
17
17
  export declare function derivePositionals(action: ActionShapeForCli): PositionalArg[];
18
18
  export declare function deriveFlags(action: ActionShapeForCli): FlagsIndex;
@@ -1,8 +1,9 @@
1
- import type { JsonSchema, NormalizedOperation } from "./types.js";
1
+ import type { JsonSchema, NormalizedOperation } from "../core/types.js";
2
+ import { type ParamType } from "./schema-shape.js";
2
3
  export type RequestBodyContent = {
3
4
  contentType: string;
4
5
  required: boolean;
5
- schemaType: import("./schema-shape.js").ParamType;
6
+ schemaType: ParamType;
6
7
  schemaFormat?: string;
7
8
  schemaEnum?: string[];
8
9
  };
@@ -1,5 +1,5 @@
1
+ import { isJsonSchema } from "../core/types.js";
1
2
  import { getSchemaEnumStrings, getSchemaFormat, getSchemaType, } from "./schema-shape.js";
2
- import { isJsonSchema } from "./types.js";
3
3
  function getRequestBody(op) {
4
4
  return op.requestBody;
5
5
  }
@@ -1,4 +1,4 @@
1
- import type { OpenApiDoc } from "./types.js";
1
+ import type { OpenApiDoc } from "../core/types.js";
2
2
  export type ServerVariable = {
3
3
  name: string;
4
4
  default?: string;
@@ -1,8 +1,9 @@
1
- import type { AuthScheme } from "../../auth-schemes.js";
1
+ import type { AuthSummary } from "../../parse/auth-requirements.js";
2
+ import type { AuthScheme } from "../../parse/auth-schemes.js";
2
3
  export type AuthInputs = {
3
4
  flagAuthScheme?: string;
4
5
  profileAuthScheme?: string;
5
6
  embeddedAuthScheme?: string;
6
7
  hasStoredToken?: boolean;
7
8
  };
8
- export declare function resolveAuthScheme(authSchemes: AuthScheme[], required: import("../../auth-requirements.js").AuthSummary, inputs: AuthInputs): string | undefined;
9
+ export declare function resolveAuthScheme(authSchemes: AuthScheme[], required: AuthSummary, inputs: AuthInputs): string | undefined;
@@ -3,13 +3,13 @@ export type BuildRuntimeContextOptions = {
3
3
  embeddedSpecText?: string;
4
4
  };
5
5
  export declare function buildRuntimeContext(options: BuildRuntimeContextOptions): Promise<{
6
- loaded: import("../types.js").LoadedSpec;
7
- operations: import("../types.js").NormalizedOperation[];
8
- servers: import("../server.js").ServerInfo[];
9
- authSchemes: import("../auth-schemes.js").AuthScheme[];
10
- planned: import("../naming.js").PlannedOperation[];
11
- commands: import("../command-model.js").CommandModel;
12
- commandsIndex: import("../command-index.js").CommandsIndex;
13
- capabilities: import("../capabilities.js").Capabilities;
14
- schema: import("../schema.js").SchemaOutput;
6
+ loaded: import("../core/types.js").LoadedSpec;
7
+ operations: import("../core/types.js").NormalizedOperation[];
8
+ servers: import("../parse/servers.js").ServerInfo[];
9
+ authSchemes: import("../parse/auth-schemes.js").AuthScheme[];
10
+ planned: import("../model/naming.js").PlannedOperation[];
11
+ commands: import("../model/command-model.js").CommandModel;
12
+ commandsIndex: import("../model/command-index.js").CommandsIndex;
13
+ capabilities: import("../model/capabilities.js").Capabilities;
14
+ schema: import("../model/schema.js").SchemaOutput;
15
15
  }>;
@@ -1,12 +1,12 @@
1
- import { listAuthSchemes } from "../auth-schemes.js";
2
- import { deriveCapabilities } from "../capabilities.js";
3
- import { buildCommandsIndex } from "../command-index.js";
4
- import { buildCommandModel } from "../command-model.js";
5
- import { planOperations } from "../naming.js";
6
- import { indexOperations } from "../operations.js";
7
- import { buildSchemaOutput } from "../schema.js";
8
- import { listServers } from "../server.js";
9
- import { loadSpec } from "../spec-loader.js";
1
+ import { deriveCapabilities } from "../model/capabilities.js";
2
+ import { buildCommandsIndex } from "../model/command-index.js";
3
+ import { buildCommandModel } from "../model/command-model.js";
4
+ import { planOperations } from "../model/naming.js";
5
+ import { buildSchemaOutput } from "../model/schema.js";
6
+ import { listAuthSchemes } from "../parse/auth-schemes.js";
7
+ import { indexOperations } from "../parse/operations.js";
8
+ import { listServers } from "../parse/servers.js";
9
+ import { loadSpec } from "../spec/loader.js";
10
10
  export async function buildRuntimeContext(options) {
11
11
  const loaded = await loadSpec({
12
12
  spec: options.spec,
@@ -1,13 +1,15 @@
1
- import type { CommandAction } from "../command-model.js";
1
+ import type { CommandAction } from "../model/command-model.js";
2
+ import type { AuthScheme } from "../parse/auth-schemes.js";
3
+ import type { ServerInfo } from "../parse/servers.js";
2
4
  import type { BodyFlagDef } from "./body-flags.js";
3
- import { type EmbeddedDefaults } from "./request.js";
5
+ import { type EmbeddedDefaults, type RuntimeGlobals } from "./request.js";
4
6
  export type ExecuteInput = {
5
7
  action: CommandAction;
6
8
  positionalValues: string[];
7
9
  flagValues: Record<string, unknown>;
8
- globals: import("./request.js").RuntimeGlobals;
9
- servers: import("../server.js").ServerInfo[];
10
- authSchemes: import("../auth-schemes.js").AuthScheme[];
10
+ globals: RuntimeGlobals;
11
+ servers: ServerInfo[];
12
+ authSchemes: AuthScheme[];
11
13
  specId: string;
12
14
  embeddedDefaults?: EmbeddedDefaults;
13
15
  bodyFlagDefs?: BodyFlagDef[];
@@ -1,4 +1,4 @@
1
- import { buildRequest } from "./request.js";
1
+ import { buildRequest, } from "./request.js";
2
2
  /**
3
3
  * Format an error message with a help hint.
4
4
  */
@@ -1,7 +1,7 @@
1
1
  import { Command } from "commander";
2
- import type { AuthScheme } from "../auth-schemes.js";
3
- import type { CommandModel } from "../command-model.js";
4
- import type { ServerInfo } from "../server.js";
2
+ import type { CommandModel } from "../model/command-model.js";
3
+ import type { AuthScheme } from "../parse/auth-schemes.js";
4
+ import type { ServerInfo } from "../parse/servers.js";
5
5
  import type { EmbeddedDefaults } from "./request.js";
6
6
  export type GeneratedCliContext = {
7
7
  servers: ServerInfo[];
@@ -1,5 +1,6 @@
1
- import type { AuthScheme } from "../auth-schemes.js";
2
- import type { CommandAction } from "../command-model.js";
1
+ import type { CommandAction } from "../model/command-model.js";
2
+ import type { AuthScheme } from "../parse/auth-schemes.js";
3
+ import type { ServerInfo } from "../parse/servers.js";
3
4
  export type RuntimeGlobals = {
4
5
  spec?: string;
5
6
  server?: string;
@@ -24,7 +25,7 @@ export type BuildRequestInput = {
24
25
  positionalValues: string[];
25
26
  flagValues: Record<string, unknown>;
26
27
  globals: RuntimeGlobals;
27
- servers: import("../server.js").ServerInfo[];
28
+ servers: ServerInfo[];
28
29
  authSchemes: AuthScheme[];
29
30
  embeddedDefaults?: EmbeddedDefaults;
30
31
  bodyFlagDefs?: import("./body-flags.js").BodyFlagDef[];
@@ -1,4 +1,4 @@
1
- import type { ServerInfo } from "../server.js";
1
+ import type { ServerInfo } from "../parse/servers.js";
2
2
  export type ResolveServerInput = {
3
3
  serverOverride?: string;
4
4
  servers: ServerInfo[];
@@ -1,3 +1,3 @@
1
- import type { ParamType } from "../../schema-shape.js";
1
+ import type { ParamType } from "../../parse/schema-shape.js";
2
2
  export declare function coerceValue(raw: string, type: ParamType): unknown;
3
3
  export declare function coerceArrayInput(raw: string, itemType: ParamType): unknown[];
@@ -1,5 +1,5 @@
1
- import type { CommandAction } from "../../command-model.js";
2
- import type { JsonSchema } from "../../types.js";
1
+ import type { JsonSchema } from "../../core/types.js";
2
+ import type { CommandAction } from "../../model/command-model.js";
3
3
  export type ValidationSchemas = {
4
4
  querySchema?: JsonSchema;
5
5
  headerSchema?: JsonSchema;
@@ -1,2 +1,2 @@
1
- import type { LoadedSpec } from "./types.js";
1
+ import type { LoadedSpec } from "../core/types.js";
2
2
  export declare function getSpecId(loaded: Pick<LoadedSpec, "doc" | "fingerprint">): string;
@@ -1,4 +1,4 @@
1
- import { kebabCase } from "./strings.js";
1
+ import { kebabCase } from "../core/strings.js";
2
2
  export function getSpecId(loaded) {
3
3
  const title = loaded.doc.info?.title;
4
4
  const fromTitle = title ? kebabCase(title) : "";
@@ -1,4 +1,4 @@
1
- import type { LoadedSpec } from "./types.js";
1
+ import type { LoadedSpec } from "../core/types.js";
2
2
  export type LoadSpecOptions = {
3
3
  spec?: string;
4
4
  embeddedSpecText?: string;
@@ -1,8 +1,8 @@
1
1
  import SwaggerParser from "@apidevtools/swagger-parser";
2
- import { sha256Hex } from "./crypto.js";
3
- import { parseYamlContent } from "./runtime/compat.js";
4
- import { getSpecId } from "./spec-id.js";
5
- import { stableStringify } from "./stable-json.js";
2
+ import { sha256Hex } from "../core/crypto.js";
3
+ import { stableStringify } from "../core/stable-json.js";
4
+ import { parseYamlContent } from "../runtime/compat.js";
5
+ import { getSpecId } from "./id.js";
6
6
  function isProbablyUrl(input) {
7
7
  return /^https?:\/\//i.test(input);
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specli",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,7 +17,8 @@
17
17
  "bin",
18
18
  "dist",
19
19
  "README.md",
20
- "package.json"
20
+ "package.json",
21
+ "!**/*.test.*"
21
22
  ],
22
23
  "scripts": {
23
24
  "build": "tsc",
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { specli } from "./tools.js";
3
- const mockOptions = {
4
- toolCallId: "test-call-id",
5
- abortSignal: new AbortController().signal,
6
- messages: [],
7
- };
8
- describe("specli tool", () => {
9
- test("creates a tool with correct structure", async () => {
10
- const tool = await specli({
11
- spec: "https://petstore3.swagger.io/api/v3/openapi.json",
12
- });
13
- expect(tool).toHaveProperty("description");
14
- expect(tool).toHaveProperty("inputSchema");
15
- expect(tool).toHaveProperty("execute");
16
- expect(typeof tool.execute).toBe("function");
17
- });
18
- test("list command returns resources", async () => {
19
- const tool = await specli({
20
- spec: "https://petstore3.swagger.io/api/v3/openapi.json",
21
- });
22
- const result = (await tool.execute?.({ command: "list" }, mockOptions));
23
- expect(result).toHaveProperty("resources");
24
- expect(Array.isArray(result.resources)).toBe(true);
25
- });
26
- test("help command returns action details", async () => {
27
- const tool = await specli({
28
- spec: "https://petstore3.swagger.io/api/v3/openapi.json",
29
- });
30
- const result = (await tool.execute?.({ command: "help", resource: "pets", action: "get" }, mockOptions));
31
- expect(result).toHaveProperty("action");
32
- expect(result.action).toBe("get");
33
- });
34
- test("help command with missing resource returns error", async () => {
35
- const tool = await specli({
36
- spec: "https://petstore3.swagger.io/api/v3/openapi.json",
37
- });
38
- const result = (await tool.execute?.({ command: "help" }, mockOptions));
39
- expect(result).toHaveProperty("error");
40
- });
41
- test("exec command with missing args returns error", async () => {
42
- const tool = await specli({
43
- spec: "https://petstore3.swagger.io/api/v3/openapi.json",
44
- });
45
- const result = (await tool.execute?.({ command: "exec", resource: "pets", action: "get" }, mockOptions));
46
- expect(result).toHaveProperty("error");
47
- expect(result.error).toContain("Missing args");
48
- });
49
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { summarizeAuth } from "./auth-requirements.js";
3
- describe("summarizeAuth", () => {
4
- test("uses operation-level security when present", () => {
5
- const schemes = [{ key: "oauth", kind: "oauth2" }];
6
- const summary = summarizeAuth([{ oauth: ["read:ping"] }], [{ oauth: ["read:other"] }], schemes);
7
- expect(summary.alternatives).toEqual([
8
- [{ key: "oauth", scopes: ["read:ping"] }],
9
- ]);
10
- });
11
- test("empty operation security disables auth", () => {
12
- const schemes = [{ key: "oauth", kind: "oauth2" }];
13
- const summary = summarizeAuth([], [{ oauth: ["read:other"] }], schemes);
14
- expect(summary.alternatives).toEqual([]);
15
- });
16
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,56 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { listAuthSchemes } from "./auth-schemes.js";
3
- describe("listAuthSchemes", () => {
4
- test("parses bearer + apiKey", () => {
5
- const doc = {
6
- openapi: "3.0.3",
7
- components: {
8
- securitySchemes: {
9
- bearerAuth: {
10
- type: "http",
11
- scheme: "bearer",
12
- bearerFormat: "JWT",
13
- },
14
- apiKeyAuth: {
15
- type: "apiKey",
16
- in: "header",
17
- name: "X-API-Key",
18
- },
19
- },
20
- },
21
- };
22
- const schemes = listAuthSchemes(doc);
23
- expect(schemes).toHaveLength(2);
24
- const bearer = schemes.find((s) => s.key === "bearerAuth");
25
- expect(bearer?.kind).toBe("http-bearer");
26
- const apiKey = schemes.find((s) => s.key === "apiKeyAuth");
27
- expect(apiKey?.kind).toBe("api-key");
28
- expect(apiKey?.in).toBe("header");
29
- expect(apiKey?.name).toBe("X-API-Key");
30
- });
31
- test("parses oauth2 flows", () => {
32
- const doc = {
33
- openapi: "3.0.3",
34
- components: {
35
- securitySchemes: {
36
- oauth: {
37
- type: "oauth2",
38
- flows: {
39
- clientCredentials: {
40
- tokenUrl: "https://example.com/oauth/token",
41
- scopes: {
42
- "read:ping": "read ping",
43
- },
44
- },
45
- },
46
- },
47
- },
48
- },
49
- };
50
- const schemes = listAuthSchemes(doc);
51
- const oauth = schemes.find((s) => s.key === "oauth");
52
- expect(oauth?.kind).toBe("oauth2");
53
- expect(oauth?.oauthFlows?.clientCredentials?.tokenUrl).toBe("https://example.com/oauth/token");
54
- expect(oauth?.oauthFlows?.clientCredentials?.scopes).toEqual(["read:ping"]);
55
- });
56
- });
@@ -1 +0,0 @@
1
- export {};