Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
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
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See [API documentation](https://octomind.dev/docs/api-reference/)

# octomind

Octomind cli tool. Version: 1.0.5. Additional documentation see https://octomind.dev/docs/api-reference/
Octomind cli tool. Version: 1.1.1. Additional documentation see https://octomind.dev/docs/api-reference/

**Usage:** `octomind [options] [command]`

Expand All @@ -26,7 +26,7 @@ Octomind cli tool. Version: 1.0.5. Additional documentation see https://octomind

# octomind CLI Documentation

Octomind cli tool. Version: 1.0.5. Additional documentation see https://octomind.dev/docs/api-reference/
Octomind cli tool. Version: 1.1.1. Additional documentation see https://octomind.dev/docs/api-reference/

## Commands

Expand All @@ -44,6 +44,12 @@ Initialize configuration by setting up API key
| `-k, --api-key <key>` | the api key for authentication | Yes | |
| `-f, --force` | Force overwrite existing configuration | No | |

## switch-test-target

Switch to a different test target

**Usage:** `switch-test-target [options]`

## debug

run test cases against local build
Expand Down Expand Up @@ -287,6 +293,18 @@ List all test cases
| `-j, --json` | Output raw JSON response | No | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |

## list-test-targets

List all test targets

**Usage:** `list-test-targets [options]`

### Options

| Option | Description | Required | Default |
|--------|-------------|----------|--------|
| `-j, --json` | Output raw JSON response | No | |



## Output Formats
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@octomind/octomind",
"version": "1.0.5",
"version": "1.1.1",
"description": "a command line client for octomind apis",
"main": "./dist/index.js",
"packageManager": "pnpm@10.13.1",
Expand Down
29 changes: 20 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import path from "path";
import fs from "fs/promises";
import { homedir } from 'os';
import { join } from 'path';
import { existsSync } from 'fs';

const OCTOMIND_CONFIG_FILE = "octomind.json";
const CONFIG_DIR = ".config";

export async function getConfigPath(ensureDir?: boolean): Promise<string> {
const homeDir = homedir();
const configDir = join(homeDir, CONFIG_DIR);
const configPath = join(configDir, OCTOMIND_CONFIG_FILE);

if (ensureDir && !existsSync(configDir)) {
await fs.mkdir(configDir, { recursive: true });
}

return configPath;
}

export interface Config {
apiKey?: string;
testTargetId?: string;
}

const OCTOMIND_CONFIG_FILE = "octomind.config.json";

export function getConfigPath(): string {
return path.join(process.cwd(), OCTOMIND_CONFIG_FILE);
}

export async function loadConfig(force?: boolean): Promise<Config> {
try {
const configPath = getConfigPath();
const configPath = await getConfigPath();
const data = await fs.readFile(configPath, "utf8");
return JSON.parse(data);
} catch (error) {
Expand All @@ -32,7 +43,7 @@ export async function loadConfig(force?: boolean): Promise<Config> {

export async function saveConfig(config: Config): Promise<void> {
try {
const configPath = getConfigPath();
const configPath = await getConfigPath(true);
await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf8");
console.log(`✅ Configuration saved to ${configPath}`);
} catch (error) {
Expand Down
16 changes: 8 additions & 8 deletions src/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ export const getUrl = async (
): Promise<string> => {
const relevantBaseUrl = new URL(BASE_URL).origin;
const config = await loadConfig();
const testTargetId = config.testTargetId;
if (!testTargetId) {
throw new Error("Test target id is not set");
const configuredTestTargetId = config.testTargetId;
if (!configuredTestTargetId && input.entityType !== "test-target") {
return "";
}
switch (input.entityType) {
case "test-case":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testcases?testCaseId=${input.testCaseId}`;
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testcases?testCaseId=${input.testCaseId}`;
case "test-target":
return `${relevantBaseUrl}/testtargets/${testTargetId}`;
return `${relevantBaseUrl}/testtargets/${input.testTargetId}`;
case "test-report":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testreports/${input.testReportId}`;
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testreports/${input.testReportId}`;
case "test-result":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testreports/${input.testReportId}/testresults/${input.testResultId}`;
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testreports/${input.testReportId}/testresults/${input.testResultId}`;
case "discovery":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testcases/${input.testCaseId}`;
return `${relevantBaseUrl}/testtargets/${configuredTestTargetId}/testcases/${input.testCaseId}`;
}
};
4 changes: 2 additions & 2 deletions tests/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs/promises";
import path from "path";
import { loadConfig, Config } from "../src/config";

import { homedir } from "os";
jest.mock("fs/promises");
const mockedFs = fs as jest.Mocked<typeof fs>;

Expand Down Expand Up @@ -29,7 +29,7 @@ describe("Config", () => {

expect(result).toEqual(mockConfig);
expect(mockedFs.readFile).toHaveBeenCalledWith(
path.join(process.cwd(), "octomind.config.json"),
path.join(homedir(), ".config", "octomind.json"),
"utf8",
);
});
Expand Down