Skip to content

Commit 1ce8615

Browse files
Merge pull request #2195 from markscott-ms/issues/2051-delete-cli-server
feat(cli): remove server functionality (now in @finos/calm-server package)
2 parents 8aae7cd + 0f20678 commit 1ce8615

23 files changed

+353
-510
lines changed

calm-ai/tools/calm-cli-instructions.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Run `calm` with no arguments to see the top-level help:
2121
calm
2222
```
2323

24-
This displays available commands such as `generate`, `validate`, `init-ai`, `server`, `template`, and `docify`.
24+
This displays available commands such as `generate`, `validate`, `init-ai`, `template`, and `docify`.
2525

2626
## Generate Architectures from Patterns
2727

@@ -134,19 +134,6 @@ At present Github Copilot (`copilot`), AWS Kiro (`kiro`), and Claude Code (`clau
134134

135135
This generates custom prompts for the specified <provider> to use CALM-aware tools (nodes, relationships, interfaces, controls, flows, patterns, metadata).
136136

137-
## CLI Server (Experimental)
138-
139-
Expose CLI functionality over HTTP:
140-
141-
```shell
142-
calm server --schema-directory <path>
143-
```
144-
145-
Endpoints (default `http://127.0.0.1:3000`):
146-
147-
- `GET /health` for health checks
148-
- `POST /calm/validate` with a CALM model payload to validate
149-
150137
## Template Command
151138

152139
Generate arbitrary files from CALM models using Handlebars bundles:

cli/AGENTS.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ npm run copy-ai-tools # Copy AI agent files from ../calm-ai/
4848
1. **generate** - Generate architecture from CALM pattern
4949
2. **validate** - Validate architecture against pattern
5050
3. **init-ai** - Install AI Assistant support for CALM
51-
4. **server** - HTTP server proxy (experimental)
52-
5. **template** - Generate files from Handlebars templates
53-
6. **docify** - Generate documentation websites (supports `--scaffold` for two-stage workflow)
51+
4. **template** - Generate files from Handlebars templates
52+
5. **docify** - Generate documentation websites (supports `--scaffold` for two-stage workflow)
5453

5554
### Important Directories
5655
```
@@ -59,7 +58,6 @@ src/
5958
├── cli-config.ts # Configuration helpers
6059
├── index.ts # Entry point
6160
├── command-helpers/ # Shared utilities for commands
62-
├── server/ # HTTP server implementation (experimental)
6361
└── test_helpers/ # Test utilities
6462
```
6563

cli/README.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Options:
3333
Commands:
3434
generate [options] Generate an architecture from a CALM pattern file.
3535
validate [options] Validate that an architecture conforms to a given CALM pattern.
36-
server [options] Start a HTTP server to proxy CLI commands. (experimental)
3736
template [options] Generate files from a CALM model using a Handlebars template bundle.
3837
docify [options] Generate a documentation website off your CALM model.
3938
init-ai [options] Augment a git repository with AI assistance for CALM
@@ -240,32 +239,6 @@ WARN issues:
240239
which is just letting you know that you have left in some placeholder values which might have been generated with the generate command.
241240
This isn't a full break, but it implies that you've forgotten to fill out a detail in your architecture.
242241
243-
## Calm CLI server (Experimental)
244-
245-
It may be required to have the operations of the CALM CLI available over rest.
246-
The `validate` command has been made available over an API.
247-
248-
```shell
249-
calm server --schema-directory calm
250-
```
251-
252-
Note that CalmHub can be used by setting the `-c, --calm-hub-url` argument.
253-
254-
```shell
255-
curl http://127.0.0.1:3000/health
256-
257-
# Missing schema key
258-
curl -H "Content-Type: application/json" -X POST http://127.0.0.1:3000/calm/validate --data @cli/test_fixtures/validation_route/invalid_api_gateway_instantiation_missing_schema_key.json
259-
260-
# Schema value is invalid
261-
curl -H "Content-Type: application/json" -X POST http://127.0.0.1:3000/calm/validate --data @cli/test_fixtures/validation_route/invalid_api_gateway_instantiation_schema_points_to_missing_schema.json
262-
263-
# instantiation is valid
264-
curl -H "Content-Type: application/json" -X POST http://127.0.0.1:3000/calm/validate --data @cli/test_fixtures/validation_route/valid_instantiation.json
265-
266-
267-
```
268-
269242
## CALM init-ai
270243
271244
The `init-ai` command sets up AI-powered development assistance for CALM architecture modeling by configuring a specialized VSCode agent with comprehensive tool prompts. At present two AI Assistant providers are supported: Github Copilot and AWS Kiro.

cli/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"commander": "^14.0.0",
4444
"copyfiles": "^2.4.1",
4545
"execa": "^9.6.0",
46-
"express-rate-limit": "^8.0.0",
4746
"mkdirp": "^3.0.1",
4847
"ts-node": "10.9.2"
4948
},
@@ -52,13 +51,11 @@
5251
"@semantic-release/exec": "^7.1.0",
5352
"@semantic-release/git": "^10.0.1",
5453
"@semantic-release/github": "^12.0.0",
55-
"@types/supertest": "^6.0.3",
5654
"@types/xml2js": "^0.4.14",
5755
"axios": "^1.13.5",
5856
"chokidar": "^4.0.3",
5957
"semantic-release": "^25.0.0",
60-
"supertest": "^7.1.0",
6158
"tsup": "^8.4.0",
6259
"xml2js": "^0.6.2"
6360
}
64-
}
61+
}

cli/src/cli.e2e.spec.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import * as fs from 'fs';
44
import * as os from 'os';
55
import { execa } from 'execa';
66
import { parseStringPromise } from 'xml2js';
7-
import axios from 'axios';
87
import { expectDirectoryMatch, expectFilesMatch } from '@finos/calm-shared';
9-
import { spawn } from 'node:child_process';
108
import { STATIC_GETTING_STARTED_MAPPING_PATH } from './test_helpers/getting-started-url-mapping';
119

1210
const millisPerSecond = 1000;
@@ -436,60 +434,6 @@ describe('CLI Integration Tests', () => {
436434
expect(actual).toEqual(expected);
437435
});
438436

439-
test('server command starts and responds to /health', async () => {
440-
const schemaDir = path.resolve(__dirname, '../../calm');
441-
const serverProcess = spawn(
442-
calm(), ['server', '--port', '3002', '--schema-directory', schemaDir],
443-
{
444-
cwd: tempDir,
445-
stdio: 'inherit',
446-
detached: true,
447-
}
448-
);
449-
await new Promise((r) => setTimeout(r, 5 * millisPerSecond));
450-
try {
451-
const res = await axios.get('http://127.0.0.1:3002/health');
452-
expect(res.status).toBe(200);
453-
expect(res.data.status).toBe('OK');
454-
} finally {
455-
if (serverProcess.pid) process.kill(-serverProcess.pid);
456-
}
457-
});
458-
459-
test('server command starts and validates an architecture', async () => {
460-
const schemaDir = path.resolve(__dirname, '../test_fixtures/api-gateway');
461-
const serverProcess = spawn(
462-
calm(), ['server', '--port', '3003', '--schema-directory', schemaDir],
463-
{
464-
cwd: tempDir,
465-
stdio: 'inherit',
466-
detached: true,
467-
}
468-
);
469-
470-
const validArchitecture = fs.readFileSync(
471-
path.join(__dirname, '../test_fixtures/validation_route/valid_instantiation.json'),
472-
'utf8'
473-
);
474-
475-
await new Promise((r) => setTimeout(r, 5 * millisPerSecond));
476-
477-
try {
478-
const res = await axios.post(
479-
'http://127.0.0.1:3003/calm/validate',
480-
JSON.parse(validArchitecture),
481-
{ headers: { 'Content-Type': 'application/json' } }
482-
);
483-
expect(res.status).toBe(201);
484-
expect(JSON.stringify(res.data)).toContain('jsonSchemaValidationOutputs');
485-
expect(JSON.stringify(res.data)).toContain('spectralSchemaValidationOutputs');
486-
expect(JSON.stringify(res.data)).toContain('hasErrors');
487-
expect(JSON.stringify(res.data)).toContain('hasWarnings');
488-
} finally {
489-
if (serverProcess.pid) process.kill(-serverProcess.pid);
490-
}
491-
});
492-
493437
test('template command generates expected output', async () => {
494438
const fixtureDir = path.resolve(__dirname, '../test_fixtures/template');
495439
const testModelPath = path.join(

cli/src/cli.spec.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { parseDocumentLoaderConfig } from './cli';
1111

1212
let calmShared: typeof import('@finos/calm-shared');
1313
let validateModule: typeof import('./command-helpers/validate');
14-
let serverModule: typeof import('./server/cli-server');
1514
let templateModule: typeof import('./command-helpers/template');
1615
let optionsModule: typeof import('./command-helpers/generate-options');
1716
let setupCLI: typeof import('./cli').setupCLI;
@@ -27,7 +26,6 @@ describe('CLI Commands', () => {
2726

2827
calmShared = await import('@finos/calm-shared');
2928
validateModule = await import('./command-helpers/validate');
30-
serverModule = await import('./server/cli-server');
3129
templateModule = await import('./command-helpers/template');
3230
optionsModule = await import('./command-helpers/generate-options');
3331

@@ -38,7 +36,6 @@ describe('CLI Commands', () => {
3836
vi.spyOn(validateModule, 'runValidate').mockResolvedValue(undefined);
3937
vi.spyOn(validateModule, 'checkValidateOptions').mockResolvedValue(undefined);
4038

41-
vi.spyOn(serverModule, 'startServer').mockImplementation(vi.fn());
4239
vi.spyOn(templateModule, 'getUrlToLocalFileMap').mockReturnValue(new Map());
4340

4441
vi.spyOn(optionsModule, 'promptUserForOptions').mockResolvedValue([]);
@@ -98,23 +95,6 @@ describe('CLI Commands', () => {
9895
});
9996
});
10097

101-
describe('Server Command', () => {
102-
it('should call startServer with correct options', async () => {
103-
await program.parseAsync([
104-
'node', 'cli.js', 'server',
105-
'--port', '4000',
106-
'--schema-directory', 'mySchemas',
107-
'--verbose',
108-
]);
109-
110-
expect(serverModule.startServer).toHaveBeenCalledWith(
111-
'4000',
112-
expect.any(calmShared.SchemaDirectory),
113-
true,
114-
);
115-
});
116-
});
117-
11898
describe('Template Command', () => {
11999
let processorConstructorSpy: MockInstance<(this: TemplateProcessor, inputPath: string, templateBundlePath: string, outputPath: string, urlToLocalPathMapping: Map<string, string>, mode?: TemplateProcessingMode) => TemplateProcessor>;
120100

cli/src/cli.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ const CALMHUB_URL_OPTION = '-c, --calm-hub-url <url>';
2121
const FORMAT_OPTION = '-f, --format <format>';
2222
const STRICT_OPTION = '--strict';
2323

24-
// Server command options
25-
const PORT_OPTION = '--port <port>';
26-
2724
// Template and Docify command options
2825
const BUNDLE_OPTION = '-b, --bundle <path>';
2926
const TEMPLATE_OPTION = '-t, --template <path>';
@@ -105,22 +102,6 @@ Validation requires:
105102
});
106103
});
107104

108-
program
109-
.command('server')
110-
.description('Start a HTTP server to proxy CLI commands. (experimental)')
111-
.option(PORT_OPTION, 'Port to run the server on', '3000')
112-
.requiredOption(SCHEMAS_OPTION, 'Path to the directory containing the meta schemas to use.')
113-
.option(VERBOSE_OPTION, 'Enable verbose logging.', false)
114-
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
115-
.action(async (options) => {
116-
const { startServer } = await import('./server/cli-server');
117-
const debug = !!options.verbose;
118-
const docLoaderOpts = await parseDocumentLoaderConfig(options);
119-
const docLoader = buildDocumentLoader(docLoaderOpts);
120-
const schemaDirectory = await buildSchemaDirectory(docLoader, debug);
121-
startServer(options.port, schemaDirectory, debug);
122-
});
123-
124105
program
125106
.command('template')
126107
.description('Generate files from a CALM model using a template bundle, a single file, or a directory of templates')

cli/src/server/cli-server.integration.spec.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

cli/src/server/cli-server.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

cli/src/server/routes/health-route.spec.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)