Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions calm-ai/tools/calm-cli-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Run `calm` with no arguments to see the top-level help:
calm
```

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

## Generate Architectures from Patterns

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

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

## CLI Server (Experimental)

Expose CLI functionality over HTTP:

```shell
calm server --schema-directory <path>
```

Endpoints (default `http://127.0.0.1:3000`):

- `GET /health` for health checks
- `POST /calm/validate` with a CALM model payload to validate

## Template Command

Generate arbitrary files from CALM models using Handlebars bundles:
Expand Down
6 changes: 2 additions & 4 deletions cli/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ npm run copy-ai-tools # Copy AI agent files from ../calm-ai/
1. **generate** - Generate architecture from CALM pattern
2. **validate** - Validate architecture against pattern
3. **init-ai** - Install AI Assistant support for CALM
4. **server** - HTTP server proxy (experimental)
5. **template** - Generate files from Handlebars templates
6. **docify** - Generate documentation websites (supports `--scaffold` for two-stage workflow)
4. **template** - Generate files from Handlebars templates
5. **docify** - Generate documentation websites (supports `--scaffold` for two-stage workflow)

### Important Directories
```
Expand All @@ -59,7 +58,6 @@ src/
├── cli-config.ts # Configuration helpers
├── index.ts # Entry point
├── command-helpers/ # Shared utilities for commands
├── server/ # HTTP server implementation (experimental)
└── test_helpers/ # Test utilities
```

Expand Down
27 changes: 0 additions & 27 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Options:
Commands:
generate [options] Generate an architecture from a CALM pattern file.
validate [options] Validate that an architecture conforms to a given CALM pattern.
server [options] Start a HTTP server to proxy CLI commands. (experimental)
template [options] Generate files from a CALM model using a Handlebars template bundle.
docify [options] Generate a documentation website off your CALM model.
init-ai [options] Augment a git repository with AI assistance for CALM
Expand Down Expand Up @@ -240,32 +239,6 @@ WARN issues:
which is just letting you know that you have left in some placeholder values which might have been generated with the generate command.
This isn't a full break, but it implies that you've forgotten to fill out a detail in your architecture.

## Calm CLI server (Experimental)

It may be required to have the operations of the CALM CLI available over rest.
The `validate` command has been made available over an API.

```shell
calm server --schema-directory calm
```

Note that CalmHub can be used by setting the `-c, --calm-hub-url` argument.

```shell
curl http://127.0.0.1:3000/health

# Missing schema key
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

# Schema value is invalid
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

# instantiation is valid
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


```

## CALM init-ai

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.
Expand Down
5 changes: 1 addition & 4 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"commander": "^14.0.0",
"copyfiles": "^2.4.1",
"execa": "^9.6.0",
"express-rate-limit": "^8.0.0",
"mkdirp": "^3.0.1",
"ts-node": "10.9.2"
},
Expand All @@ -52,13 +51,11 @@
"@semantic-release/exec": "^7.1.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^12.0.0",
"@types/supertest": "^6.0.3",
"@types/xml2js": "^0.4.14",
"axios": "^1.13.5",
"chokidar": "^4.0.3",
"semantic-release": "^25.0.0",
"supertest": "^7.1.0",
"tsup": "^8.4.0",
"xml2js": "^0.6.2"
}
}
}
56 changes: 0 additions & 56 deletions cli/src/cli.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import * as fs from 'fs';
import * as os from 'os';
import { execa } from 'execa';
import { parseStringPromise } from 'xml2js';
import axios from 'axios';
import { expectDirectoryMatch, expectFilesMatch } from '@finos/calm-shared';
import { spawn } from 'node:child_process';
import { STATIC_GETTING_STARTED_MAPPING_PATH } from './test_helpers/getting-started-url-mapping';

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

test('server command starts and responds to /health', async () => {
const schemaDir = path.resolve(__dirname, '../../calm');
const serverProcess = spawn(
calm(), ['server', '--port', '3002', '--schema-directory', schemaDir],
{
cwd: tempDir,
stdio: 'inherit',
detached: true,
}
);
await new Promise((r) => setTimeout(r, 5 * millisPerSecond));
try {
const res = await axios.get('http://127.0.0.1:3002/health');
expect(res.status).toBe(200);
expect(res.data.status).toBe('OK');
} finally {
if (serverProcess.pid) process.kill(-serverProcess.pid);
}
});

test('server command starts and validates an architecture', async () => {
const schemaDir = path.resolve(__dirname, '../test_fixtures/api-gateway');
const serverProcess = spawn(
calm(), ['server', '--port', '3003', '--schema-directory', schemaDir],
{
cwd: tempDir,
stdio: 'inherit',
detached: true,
}
);

const validArchitecture = fs.readFileSync(
path.join(__dirname, '../test_fixtures/validation_route/valid_instantiation.json'),
'utf8'
);

await new Promise((r) => setTimeout(r, 5 * millisPerSecond));

try {
const res = await axios.post(
'http://127.0.0.1:3003/calm/validate',
JSON.parse(validArchitecture),
{ headers: { 'Content-Type': 'application/json' } }
);
expect(res.status).toBe(201);
expect(JSON.stringify(res.data)).toContain('jsonSchemaValidationOutputs');
expect(JSON.stringify(res.data)).toContain('spectralSchemaValidationOutputs');
expect(JSON.stringify(res.data)).toContain('hasErrors');
expect(JSON.stringify(res.data)).toContain('hasWarnings');
} finally {
if (serverProcess.pid) process.kill(-serverProcess.pid);
}
});

test('template command generates expected output', async () => {
const fixtureDir = path.resolve(__dirname, '../test_fixtures/template');
const testModelPath = path.join(
Expand Down
20 changes: 0 additions & 20 deletions cli/src/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { parseDocumentLoaderConfig } from './cli';

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

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

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

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

vi.spyOn(optionsModule, 'promptUserForOptions').mockResolvedValue([]);
Expand Down Expand Up @@ -98,23 +95,6 @@ describe('CLI Commands', () => {
});
});

describe('Server Command', () => {
it('should call startServer with correct options', async () => {
await program.parseAsync([
'node', 'cli.js', 'server',
'--port', '4000',
'--schema-directory', 'mySchemas',
'--verbose',
]);

expect(serverModule.startServer).toHaveBeenCalledWith(
'4000',
expect.any(calmShared.SchemaDirectory),
true,
);
});
});

describe('Template Command', () => {
let processorConstructorSpy: MockInstance<(this: TemplateProcessor, inputPath: string, templateBundlePath: string, outputPath: string, urlToLocalPathMapping: Map<string, string>, mode?: TemplateProcessingMode) => TemplateProcessor>;

Expand Down
19 changes: 0 additions & 19 deletions cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const CALMHUB_URL_OPTION = '-c, --calm-hub-url <url>';
const FORMAT_OPTION = '-f, --format <format>';
const STRICT_OPTION = '--strict';

// Server command options
const PORT_OPTION = '--port <port>';

// Template and Docify command options
const BUNDLE_OPTION = '-b, --bundle <path>';
const TEMPLATE_OPTION = '-t, --template <path>';
Expand Down Expand Up @@ -105,22 +102,6 @@ Validation requires:
});
});

program
.command('server')
.description('Start a HTTP server to proxy CLI commands. (experimental)')
.option(PORT_OPTION, 'Port to run the server on', '3000')
.requiredOption(SCHEMAS_OPTION, 'Path to the directory containing the meta schemas to use.')
.option(VERBOSE_OPTION, 'Enable verbose logging.', false)
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.action(async (options) => {
const { startServer } = await import('./server/cli-server');
const debug = !!options.verbose;
const docLoaderOpts = await parseDocumentLoaderConfig(options);
const docLoader = buildDocumentLoader(docLoaderOpts);
const schemaDirectory = await buildSchemaDirectory(docLoader, debug);
startServer(options.port, schemaDirectory, debug);
});

program
.command('template')
.description('Generate files from a CALM model using a template bundle, a single file, or a directory of templates')
Expand Down
29 changes: 0 additions & 29 deletions cli/src/server/cli-server.integration.spec.ts

This file was deleted.

18 changes: 0 additions & 18 deletions cli/src/server/cli-server.ts

This file was deleted.

27 changes: 0 additions & 27 deletions cli/src/server/routes/health-route.spec.ts

This file was deleted.

22 changes: 0 additions & 22 deletions cli/src/server/routes/health-route.ts

This file was deleted.

Loading
Loading