@contractspec/app.cli-contractspec 0.0.0-canary-20260113170453

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.
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "./contractsrc.schema.json",
3
+ "aiProvider": "claude",
4
+ "aiModel": "claude-3-7-sonnet-20250219",
5
+ "agentMode": "claude-code",
6
+ "customEndpoint": null,
7
+ "customApiKey": null,
8
+ "outputDir": "./src",
9
+ "conventions": {
10
+ "operations": "interactions/commands|queries",
11
+ "events": "events",
12
+ "presentations": "presentations",
13
+ "forms": "forms"
14
+ },
15
+ "defaultOwners": ["@team"],
16
+ "defaultTags": ["auto-generated"],
17
+
18
+ "_comments": {
19
+ "aiProvider": "Options: 'claude', 'openai', 'ollama', 'custom'",
20
+ "agentMode": "Options: 'simple', 'cursor', 'claude-code', 'openai-codex'. Controls code generation strategy.",
21
+ "aiModel": "Specific model to use. Defaults vary by provider.",
22
+ "customEndpoint": "For custom providers. Example: 'https://your-llm-endpoint.com'",
23
+ "customApiKey": "Optional. Can also use CONTRACTSPEC_LLM_API_KEY env var"
24
+ }
25
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,102 @@
1
+ # AI Agent Guide — `@contractspec/app.cli-contractspec`
2
+
3
+ Scope: `packages/apps/cli-contractspec/*`
4
+
5
+ This is the ContractSpec CLI (`contractspec`).
6
+
7
+ ## Architecture
8
+
9
+ The CLI is a **thin wrapper** around business logic in `@contractspec/bundle.workspace`. The separation is:
10
+
11
+ ### CLI Layer (this package)
12
+
13
+ - **Commands** (`src/commands/`) - Thin wrappers that call bundle services
14
+ - **Prompts** (`src/commands/create/wizards/`) - Interactive UI using `@inquirer/prompts`
15
+ - **CLI setup** (`src/index.ts`, `src/cli.ts`) - Commander.js configuration
16
+ - **Types** (`src/types.ts`) - CLI-specific types
17
+
18
+ ### Business Logic (bundle)
19
+
20
+ - **Services** (`@contractspec/bundle.workspace/services/`) - Core use-cases
21
+ - `create.ts` - Spec creation logic
22
+ - `build.ts` - Code generation from specs
23
+ - `openapi.ts` - OpenAPI export
24
+ - `registry.ts` - Registry client
25
+ - `examples.ts` - Examples management
26
+ - `validate.ts`, `diff.ts`, `deps.ts`, etc.
27
+ - **Templates** (`@contractspec/bundle.workspace/templates/`) - Spec templates
28
+ - **AI** (`@contractspec/bundle.workspace/ai/`) - AI agents and prompts
29
+ - **Adapters** (`@contractspec/bundle.workspace/adapters/`) - Infrastructure
30
+
31
+ ## Build System
32
+
33
+ The CLI is bundled with `bun build`:
34
+
35
+ - Single executable output: `dist/cli.js`
36
+ - Target: `bun` runtime
37
+ - Minified for production
38
+ - Type declarations generated separately with `tsc`
39
+
40
+ ## Test System
41
+
42
+ Tests use `bun:test` (not vitest):
43
+
44
+ - Run: `bun test`
45
+ - Watch: `bun test --watch`
46
+ - All test files import from `bun:test`
47
+
48
+ ## Docs consumed by MCP
49
+
50
+ The CLI MCP server serves these markdown files by path:
51
+
52
+ - `packages/apps/cli-contractspec/QUICK_START.md`
53
+ - `packages/apps/cli-contractspec/QUICK_REFERENCE.md`
54
+ - `packages/apps/cli-contractspec/README.md`
55
+
56
+ If you rename/move them, update `packages/bundles/contractspec-studio/src/application/mcp/cliMcp.ts` (`CLI_DOC_PATHS`).
57
+
58
+ ## Local commands
59
+
60
+ - **Dev/watch**: `bun run dev` - Watch mode, rebuilds on changes
61
+ - **Build**: `bun run build` - Bundles CLI + generates types
62
+ - **Test**: `bun test` - Run all tests
63
+ - **Lint**: `bun run lint` - Fix linting issues
64
+
65
+ ## Prompt Library
66
+
67
+ The CLI uses `@inquirer/prompts` (not legacy `inquirer`):
68
+
69
+ - `select` - List selection
70
+ - `input` - Text input
71
+ - `confirm` - Yes/no confirmation
72
+ - `number` - Numeric input
73
+
74
+ ## Adding a New Command
75
+
76
+ 1. **Create service in bundle** (`@contractspec/bundle.workspace/services/`)
77
+ 2. **Create CLI wrapper** (`src/commands/new-command.ts`)
78
+ 3. **Add to index.ts** (`src/index.ts`)
79
+ 4. **Add prompts if needed** (`src/commands/new-command/prompts.ts`)
80
+ 5. **Write tests** (`src/commands/new-command/index.test.ts`)
81
+
82
+ Example CLI wrapper:
83
+
84
+ ```typescript
85
+ import { Command } from 'commander';
86
+ import { myService } from '@contractspec/bundle.workspace';
87
+ import { createFsAdapter } from '@contractspec/bundle.workspace/adapters';
88
+
89
+ export const myCommand = new Command('my-command')
90
+ .description('Do something')
91
+ .action(async () => {
92
+ const fs = createFsAdapter();
93
+ const logger = createLoggerAdapter();
94
+
95
+ await myService(
96
+ {
97
+ /* options */
98
+ },
99
+ { fs, logger }
100
+ );
101
+ });
102
+ ```