@straion/cli 0.0.2 → 0.0.4
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.
- package/CHANGELOG.md +16 -3
- package/README.md +35 -22
- package/dist/auth/credentials.d.ts +7 -34
- package/dist/auth/credentials.d.ts.map +1 -1
- package/dist/auth/credentials.js +16 -83
- package/dist/auth/credentials.js.map +1 -1
- package/dist/auth/graphql-client.d.ts.map +1 -1
- package/dist/auth/graphql-client.js +3 -0
- package/dist/auth/graphql-client.js.map +1 -1
- package/dist/cli.d.ts +0 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/default.d.ts +1 -2
- package/dist/commands/default.d.ts.map +1 -1
- package/dist/commands/default.js +11 -45
- package/dist/commands/default.js.map +1 -1
- package/dist/commands/find-requirements.d.ts.map +1 -1
- package/dist/commands/find-requirements.integration.test.js +17 -56
- package/dist/commands/find-requirements.integration.test.js.map +1 -1
- package/dist/commands/find-requirements.js +20 -32
- package/dist/commands/find-requirements.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.integration.test.js +21 -142
- package/dist/commands/login.integration.test.js.map +1 -1
- package/dist/commands/login.js +15 -8
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +13 -27
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +1 -8
- package/dist/commands/session-start.js.map +1 -1
- package/dist/commands/setup.d.ts +3 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +23 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/components/banner.d.ts +3 -0
- package/dist/components/banner.d.ts.map +1 -0
- package/dist/components/banner.js +13 -0
- package/dist/components/banner.js.map +1 -0
- package/dist/components/default-flow.d.ts +11 -0
- package/dist/components/default-flow.d.ts.map +1 -0
- package/dist/components/default-flow.js +64 -0
- package/dist/components/default-flow.js.map +1 -0
- package/dist/components/hero.d.ts.map +1 -1
- package/dist/components/hero.js +23 -34
- package/dist/components/hero.js.map +1 -1
- package/dist/components/login/login-error.d.ts.map +1 -1
- package/dist/components/login/login-error.js +2 -4
- package/dist/components/login/login-error.js.map +1 -1
- package/dist/components/login/login-flow.d.ts +1 -3
- package/dist/components/login/login-flow.d.ts.map +1 -1
- package/dist/components/login/login-flow.js +21 -51
- package/dist/components/login/login-flow.js.map +1 -1
- package/dist/components/login/login-flow.test.js +23 -8
- package/dist/components/login/login-flow.test.js.map +1 -1
- package/dist/components/login/user-settings-link.d.ts +3 -0
- package/dist/components/login/user-settings-link.d.ts.map +1 -0
- package/dist/components/login/user-settings-link.js +8 -0
- package/dist/components/login/user-settings-link.js.map +1 -0
- package/dist/components/multi-select.d.ts +16 -0
- package/dist/components/multi-select.d.ts.map +1 -0
- package/dist/components/multi-select.js +105 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/org-selector.d.ts.map +1 -1
- package/dist/components/org-selector.js +3 -1
- package/dist/components/org-selector.js.map +1 -1
- package/dist/components/pat-input.js +1 -1
- package/dist/components/pat-input.js.map +1 -1
- package/dist/components/setup/agent-setup.d.ts +9 -0
- package/dist/components/setup/agent-setup.d.ts.map +1 -0
- package/dist/components/setup/agent-setup.js +65 -0
- package/dist/components/setup/agent-setup.js.map +1 -0
- package/dist/components/setup/agents/agent-registry.d.ts +44 -0
- package/dist/components/setup/agents/agent-registry.d.ts.map +1 -0
- package/dist/components/setup/agents/agent-registry.js +64 -0
- package/dist/components/setup/agents/agent-registry.js.map +1 -0
- package/dist/components/setup/agents/command-helpers.d.ts +5 -0
- package/dist/components/setup/agents/command-helpers.d.ts.map +1 -0
- package/dist/components/setup/agents/command-helpers.js +28 -0
- package/dist/components/setup/agents/command-helpers.js.map +1 -0
- package/dist/components/setup/checking-agents.d.ts +16 -0
- package/dist/components/setup/checking-agents.d.ts.map +1 -0
- package/dist/components/setup/checking-agents.js +30 -0
- package/dist/components/setup/checking-agents.js.map +1 -0
- package/dist/components/setup/download-skills-and-plugins.d.ts +9 -0
- package/dist/components/setup/download-skills-and-plugins.d.ts.map +1 -0
- package/dist/components/setup/download-skills-and-plugins.js +29 -0
- package/dist/components/setup/download-skills-and-plugins.js.map +1 -0
- package/dist/components/setup/perform-setup.d.ts +23 -0
- package/dist/components/setup/perform-setup.d.ts.map +1 -0
- package/dist/components/setup/perform-setup.js +45 -0
- package/dist/components/setup/perform-setup.js.map +1 -0
- package/dist/components/spinner.d.ts +6 -2
- package/dist/components/spinner.d.ts.map +1 -1
- package/dist/components/spinner.js +12 -3
- package/dist/components/spinner.js.map +1 -1
- package/dist/hooks/use-credentials.d.ts +13 -0
- package/dist/hooks/use-credentials.d.ts.map +1 -0
- package/dist/hooks/use-credentials.js +33 -0
- package/dist/hooks/use-credentials.js.map +1 -0
- package/dist/lib/graphql.d.ts +57 -41
- package/dist/lib/graphql.d.ts.map +1 -1
- package/dist/lib/graphql.js +7 -0
- package/dist/lib/graphql.js.map +1 -1
- package/dist/lib/ink-render.d.ts +1 -1
- package/dist/lib/ink-render.d.ts.map +1 -1
- package/dist/lib/ink-render.js +1 -1
- package/dist/lib/ink-render.js.map +1 -1
- package/dist/lib/logger.d.ts +13 -8
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +6 -29
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/login.d.ts.map +1 -1
- package/dist/lib/middleware.d.ts +4 -8
- package/dist/lib/middleware.d.ts.map +1 -1
- package/dist/lib/middleware.js +7 -11
- package/dist/lib/middleware.js.map +1 -1
- package/dist/lib/skills-manager.d.ts +33 -0
- package/dist/lib/skills-manager.d.ts.map +1 -0
- package/dist/lib/skills-manager.js +233 -0
- package/dist/lib/skills-manager.js.map +1 -0
- package/dist/lib/skills-manager.test.d.ts +7 -0
- package/dist/lib/skills-manager.test.d.ts.map +1 -0
- package/dist/lib/skills-manager.test.js +248 -0
- package/dist/lib/skills-manager.test.js.map +1 -0
- package/dist/state/global-config.d.ts +23 -9
- package/dist/state/global-config.d.ts.map +1 -1
- package/dist/state/global-config.js +42 -36
- package/dist/state/global-config.js.map +1 -1
- package/dist/state/session-manager.js +2 -2
- package/dist/state/session-manager.js.map +1 -1
- package/dist/test/integration-helpers.d.ts +0 -5
- package/dist/test/integration-helpers.d.ts.map +1 -1
- package/dist/test/integration-helpers.js +1 -18
- package/dist/test/integration-helpers.js.map +1 -1
- package/package.json +16 -8
- package/dist/lib/output.d.ts +0 -16
- package/dist/lib/output.d.ts.map +0 -1
- package/dist/lib/output.js +0 -14
- package/dist/lib/output.js.map +0 -1
- package/dist/state/directory-config.d.ts +0 -21
- package/dist/state/directory-config.d.ts.map +0 -1
- package/dist/state/directory-config.js +0 -59
- package/dist/state/directory-config.js.map +0 -1
- /package/{LICENSE.txt → LICENSE} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
## 0.0.4 (February 9, 2026)
|
|
2
|
+
|
|
3
|
+
- chore: Updates and cleans up dependencies.
|
|
4
|
+
- fix: Switches credentials to use locally encrypted file instead of accessing keychain using sunsetted `keytar` dependency. Keychain access caused exceptions in some cases where some libraries from the operating system where incompatible and caused exceptions.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## 0.0.3 (February 4, 2026)
|
|
8
|
+
|
|
9
|
+
- feat: Adds first time setup flow and setup command.
|
|
10
|
+
- chore: Uses SPDX identifier for license reference.
|
|
11
|
+
- chore: Removes `--output-format` flag since it was not useful and introduced unnecessary complexity.
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## 0.0.2 (January 30, 2026)
|
|
2
15
|
|
|
3
|
-
- Fixes issues when running in non interactive terminals
|
|
4
|
-
- Adds support to login with the STRAION_API_KEY environment variable
|
|
5
|
-
- Adds `--output-format` flag to all commands that accepts `json` and `text` values. It uses `text` by default which renders a rich terminal user interface.
|
|
16
|
+
- fix: Fixes issues when running in non interactive terminals
|
|
17
|
+
- feat: Adds support to login with the STRAION_API_KEY environment variable
|
|
18
|
+
- feat: Adds `--output-format` flag to all commands that accepts `json` and `text` values. It uses `text` by default which renders a rich terminal user interface.
|
|
6
19
|
|
|
7
20
|
|
|
8
21
|
## 0.0.1 (January 26, 2026)
|
package/README.md
CHANGED
|
@@ -19,18 +19,10 @@ The Straion CLI provides command-line access to the Straion platform, enabling s
|
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
# npm
|
|
22
|
-
# globally
|
|
23
22
|
npm install -g @straion/cli
|
|
24
23
|
|
|
25
|
-
#
|
|
26
|
-
npm install -save-dev @straion/cli
|
|
27
|
-
|
|
28
|
-
#pnpm
|
|
29
|
-
# globally
|
|
24
|
+
# pnpm
|
|
30
25
|
pnpm install -g @straion/cli
|
|
31
|
-
|
|
32
|
-
# inside project
|
|
33
|
-
pnpm install -save-dev @straion/cli
|
|
34
26
|
```
|
|
35
27
|
|
|
36
28
|
## Requirements
|
|
@@ -40,24 +32,27 @@ pnpm install -save-dev @straion/cli
|
|
|
40
32
|
## Quick Start
|
|
41
33
|
|
|
42
34
|
```bash
|
|
43
|
-
# Display the interactive welcome screen
|
|
35
|
+
# Display the interactive welcome screen (includes first-time setup wizard)
|
|
44
36
|
straion
|
|
45
37
|
|
|
46
38
|
# Or authenticate with your Personal Access Token
|
|
47
39
|
# This stores login information securely and makes it available on your machine.
|
|
48
40
|
straion login
|
|
41
|
+
|
|
42
|
+
# Set up your coding agents to use Straion
|
|
43
|
+
straion setup
|
|
49
44
|
```
|
|
50
45
|
|
|
51
46
|
## Commands
|
|
52
47
|
|
|
53
|
-
| Command
|
|
54
|
-
|
|
|
55
|
-
| `straion`
|
|
56
|
-
| `straion login`
|
|
57
|
-
| `straion
|
|
58
|
-
| `straion
|
|
59
|
-
| `straion --help`
|
|
60
|
-
| `straion --version`
|
|
48
|
+
| Command | Description |
|
|
49
|
+
| ------------------- | --------------------------------------------------------------------------------- |
|
|
50
|
+
| `straion` | Display the interactive welcome screen with status |
|
|
51
|
+
| `straion login` | Authenticate with a Personal Access Token. Also accepts a `--token <token>` flag. |
|
|
52
|
+
| `straion logout` | Log out and clear stored credentials |
|
|
53
|
+
| `straion setup` | Set up your coding agents to use Straion |
|
|
54
|
+
| `straion --help` | Show all available commands |
|
|
55
|
+
| `straion --version` | Display the current version |
|
|
61
56
|
|
|
62
57
|
## Authentication
|
|
63
58
|
|
|
@@ -67,6 +62,28 @@ The CLI uses Personal Access Tokens (PAT) for authentication. Credentials are se
|
|
|
67
62
|
2. Run `straion login` and enter your token when prompted
|
|
68
63
|
3. Your credentials will be securely stored for future sessions
|
|
69
64
|
|
|
65
|
+
You can also authenticate using the `STRAION_API_KEY` environment variable:
|
|
66
|
+
_Note:_ This will use your global organization or your default organization.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
export STRAION_API_KEY=<your_personal_access_token>
|
|
70
|
+
straion login # Will use the environment variable automatically
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Agent Setup
|
|
74
|
+
|
|
75
|
+
The `straion setup` command helps you configure your coding agents to work with Straion. It downloads the necessary skills and plugins, then guides you through selecting which agents to configure.
|
|
76
|
+
|
|
77
|
+
### Supported Agents
|
|
78
|
+
|
|
79
|
+
| Agent | Description |
|
|
80
|
+
| -------------- | ---------------------------- |
|
|
81
|
+
| Claude Code | Anthropic's CLI for Claude |
|
|
82
|
+
| GitHub Copilot | GitHub's AI coding assistant |
|
|
83
|
+
| Cursor | AI-powered code editor |
|
|
84
|
+
|
|
85
|
+
Run `straion setup` to interactively set up your preferred agents, or run `straion` for the first-time setup wizard which includes agent configuration.
|
|
86
|
+
|
|
70
87
|
## Multi-Organization Support
|
|
71
88
|
|
|
72
89
|
If you belong to multiple organizations, the CLI allows you to switch between them:
|
|
@@ -77,7 +94,3 @@ If you belong to multiple organizations, the CLI allows you to switch between th
|
|
|
77
94
|
## Learn More
|
|
78
95
|
|
|
79
96
|
Visit [https://www.straion.com](https://www.straion.com) for additional information.
|
|
80
|
-
|
|
81
|
-
## License
|
|
82
|
-
|
|
83
|
-
See [LICENSE.txt](./LICENSE.txt) for details.
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* -
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Auth credentials stored in the secure keychain.
|
|
9
|
-
* Organization preferences are stored separately in src/state/.
|
|
2
|
+
* Secure credential storage using encrypted local files.
|
|
3
|
+
* Similar approach to AWS CLI but with AES-256-GCM encryption.
|
|
4
|
+
*
|
|
5
|
+
* Location: ~/.straion/credentials.enc
|
|
10
6
|
*/
|
|
11
7
|
export interface StoredCredentials {
|
|
12
8
|
userId: string;
|
|
@@ -14,34 +10,15 @@ export interface StoredCredentials {
|
|
|
14
10
|
accessToken: string;
|
|
15
11
|
}
|
|
16
12
|
export declare class CredentialManager {
|
|
17
|
-
|
|
18
|
-
* Store credentials securely in the system keychain
|
|
19
|
-
*/
|
|
20
|
-
setCredentials(credentials: StoredCredentials): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Retrieve the currently stored credentials
|
|
23
|
-
*/
|
|
24
|
-
getCredentials(): Promise<StoredCredentials | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Get the access token only (convenience method)
|
|
27
|
-
*/
|
|
28
|
-
getAccessToken(): Promise<string | null>;
|
|
29
|
-
/**
|
|
30
|
-
* Delete all stored credentials for the current user
|
|
31
|
-
*/
|
|
32
|
-
deleteCredentials(): Promise<boolean>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Fallback credential manager using a config file
|
|
36
|
-
* Use this when keytar is unavailable (e.g., headless Linux without libsecret)
|
|
37
|
-
*/
|
|
38
|
-
export declare class FileCredentialManager {
|
|
13
|
+
private configDir;
|
|
39
14
|
private configPath;
|
|
40
15
|
private encryptionKey;
|
|
41
16
|
constructor();
|
|
17
|
+
private ensureConfigDir;
|
|
42
18
|
private encrypt;
|
|
43
19
|
private decrypt;
|
|
44
20
|
setCredentials(credentials: StoredCredentials): Promise<void>;
|
|
21
|
+
getAccessToken(): Promise<string | null>;
|
|
45
22
|
getCredentials(): Promise<StoredCredentials | null>;
|
|
46
23
|
deleteCredentials(): Promise<boolean>;
|
|
47
24
|
/**
|
|
@@ -49,8 +26,4 @@ export declare class FileCredentialManager {
|
|
|
49
26
|
*/
|
|
50
27
|
isAuthenticated(): Promise<boolean>;
|
|
51
28
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Factory function to create the appropriate credential manager
|
|
54
|
-
*/
|
|
55
|
-
export declare function createCredentialManager(): Promise<CredentialManager | FileCredentialManager>;
|
|
56
29
|
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/auth/credentials.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/auth/credentials.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;;IAa9B,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,OAAO;IAUT,cAAc,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKxC,cAAc,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAcnD,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAY3C;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAI1C"}
|
package/dist/auth/credentials.js
CHANGED
|
@@ -2,80 +2,24 @@ import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from 'node:
|
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { homedir, hostname, userInfo } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** File permission: owner read/write only (rw-------) */
|
|
6
|
+
const FILE_MODE = 0o600;
|
|
7
7
|
export class CredentialManager {
|
|
8
|
-
|
|
9
|
-
* Store credentials securely in the system keychain
|
|
10
|
-
*/
|
|
11
|
-
async setCredentials(credentials) {
|
|
12
|
-
const payload = JSON.stringify(credentials);
|
|
13
|
-
// Store the credentials as a JSON blob under the username key
|
|
14
|
-
try {
|
|
15
|
-
await keytar.setPassword(StraionCLIConfig.serviceName, '__current_login__', payload);
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
if (error instanceof Error) {
|
|
19
|
-
console.error(error.message || 'Failed to store credentials in system keychain');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Retrieve the currently stored credentials
|
|
25
|
-
*/
|
|
26
|
-
async getCredentials() {
|
|
27
|
-
try {
|
|
28
|
-
// Retrive the current login credentials
|
|
29
|
-
const payload = await keytar.getPassword(StraionCLIConfig.serviceName, '__current_login__');
|
|
30
|
-
if (!payload) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const credentials = JSON.parse(payload);
|
|
34
|
-
return credentials;
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
console.error('Failed to retrieve credentials from system keychain');
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get the access token only (convenience method)
|
|
43
|
-
*/
|
|
44
|
-
async getAccessToken() {
|
|
45
|
-
const credentials = await this.getCredentials();
|
|
46
|
-
return credentials?.accessToken ?? null;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Delete all stored credentials for the current user
|
|
50
|
-
*/
|
|
51
|
-
async deleteCredentials() {
|
|
52
|
-
try {
|
|
53
|
-
await keytar.deletePassword(StraionCLIConfig.serviceName, '__current_login__');
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Fallback credential manager using a config file
|
|
63
|
-
* Use this when keytar is unavailable (e.g., headless Linux without libsecret)
|
|
64
|
-
*/
|
|
65
|
-
export class FileCredentialManager {
|
|
8
|
+
configDir;
|
|
66
9
|
configPath;
|
|
67
10
|
encryptionKey;
|
|
68
11
|
constructor() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!existsSync(configDir)) {
|
|
72
|
-
mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
73
|
-
}
|
|
74
|
-
this.configPath = join(configDir, 'credentials.enc');
|
|
12
|
+
this.configDir = join(homedir(), '.straion');
|
|
13
|
+
this.configPath = join(this.configDir, 'credentials.enc');
|
|
75
14
|
// Derive encryption key from machine-specific data
|
|
76
|
-
// In production, consider a more robust key derivation strategy
|
|
77
15
|
const machineId = hostname() + userInfo().username;
|
|
78
16
|
this.encryptionKey = scryptSync(machineId, 'salt', 32);
|
|
17
|
+
this.ensureConfigDir();
|
|
18
|
+
}
|
|
19
|
+
ensureConfigDir() {
|
|
20
|
+
if (!existsSync(this.configDir)) {
|
|
21
|
+
mkdirSync(this.configDir, { recursive: true });
|
|
22
|
+
}
|
|
79
23
|
}
|
|
80
24
|
encrypt(text) {
|
|
81
25
|
const iv = randomBytes(16);
|
|
@@ -95,7 +39,11 @@ export class FileCredentialManager {
|
|
|
95
39
|
}
|
|
96
40
|
async setCredentials(credentials) {
|
|
97
41
|
const encrypted = this.encrypt(JSON.stringify(credentials));
|
|
98
|
-
writeFileSync(this.configPath, encrypted, { mode:
|
|
42
|
+
writeFileSync(this.configPath, encrypted, { mode: FILE_MODE });
|
|
43
|
+
}
|
|
44
|
+
async getAccessToken() {
|
|
45
|
+
const credentials = await this.getCredentials();
|
|
46
|
+
return credentials?.accessToken ?? null;
|
|
99
47
|
}
|
|
100
48
|
async getCredentials() {
|
|
101
49
|
try {
|
|
@@ -129,19 +77,4 @@ export class FileCredentialManager {
|
|
|
129
77
|
return credentials !== null;
|
|
130
78
|
}
|
|
131
79
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Factory function to create the appropriate credential manager
|
|
134
|
-
*/
|
|
135
|
-
export async function createCredentialManager() {
|
|
136
|
-
try {
|
|
137
|
-
// Test if keytar works
|
|
138
|
-
await keytar.getPassword(StraionCLIConfig.serviceName, '__test__');
|
|
139
|
-
return new CredentialManager();
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
// Fall back to file-based storage
|
|
143
|
-
console.warn('System keychain unavailable, falling back to encrypted file storage.');
|
|
144
|
-
return new FileCredentialManager();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
80
|
//# sourceMappingURL=credentials.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/auth/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO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IACjE,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,OAAO,WAAW,EAAE,WAAW,IAAI,IAAI,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACxD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAsB,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,IAAI,CAAC;YACH,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBAChC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,OAAO,WAAW,KAAK,IAAI,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/auth/graphql-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/auth/graphql-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAShD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,aAAa,CAapF"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { env } from 'node:process';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
import { createLogger } from '../lib/logger.js';
|
|
3
4
|
const BASE_URL = env.STRAION_API_BASEURL || 'https://api.straion.app';
|
|
5
|
+
const logger = createLogger();
|
|
4
6
|
let initializedClient = null;
|
|
5
7
|
export function getGraphqlClient(pat, organizationId) {
|
|
6
8
|
if (!initializedClient) {
|
|
9
|
+
logger.info({ BASE_URL, organizationId }, 'Initializing GraphQL client');
|
|
7
10
|
initializedClient = new GraphQLClient(BASE_URL, {
|
|
8
11
|
credentials: 'include',
|
|
9
12
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-client.js","sourceRoot":"","sources":["../../src/auth/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,QAAQ,GAAG,GAAG,CAAC,mBAAmB,IAAI,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"graphql-client.js","sourceRoot":"","sources":["../../src/auth/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,QAAQ,GAAG,GAAG,CAAC,mBAAmB,IAAI,yBAAyB,CAAC;AACtE,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAE9B,IAAI,iBAAiB,GAAyB,IAAI,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,cAAuB;IACnE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,6BAA6B,CAAC,CAAC;QACzE,iBAAiB,GAAG,IAAI,aAAa,CAAC,QAAQ,EAAE;YAC9C,WAAW,EAAE,SAAS;YACtB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,GAAG,EAAE;gBAC9B,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClE;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import type { OutputFormat } from './lib/output.js';
|
|
4
|
-
export interface GlobalOptions {
|
|
5
|
-
outputFormat: OutputFormat;
|
|
6
|
-
}
|
|
7
3
|
export declare function createProgram(): Command;
|
|
8
4
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,aAAa,IAAI,OAAO,CAYvC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import packageJson from '../package.json' with { type: 'json' };
|
|
4
|
+
import { runDefaultCommand } from './commands/default.js';
|
|
4
5
|
import { registerCommands } from './commands/index.js';
|
|
5
6
|
export function createProgram() {
|
|
6
7
|
const program = new Command();
|
|
7
8
|
program
|
|
8
9
|
.name('straion')
|
|
9
10
|
.description('Straion CLI - The Missing Piece for AI-Era Software Engineering at Scale')
|
|
10
|
-
.version(packageJson.version)
|
|
11
|
-
.option('-o, --output-format <format>', 'Output format: "text" for human-readable TUI, "json" for machine-readable', 'text');
|
|
11
|
+
.version(packageJson.version);
|
|
12
12
|
registerCommands(program);
|
|
13
|
-
program.action(
|
|
14
|
-
const opts = this.optsWithGlobals();
|
|
15
|
-
const { runDefaultCommand } = await import('./commands/default.js');
|
|
16
|
-
await runDefaultCommand(opts.outputFormat);
|
|
17
|
-
});
|
|
13
|
+
program.action(runDefaultCommand);
|
|
18
14
|
return program;
|
|
19
15
|
}
|
|
20
16
|
createProgram()
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACJ,IAAI,CAAC,SAAS,CAAC;SACf,WAAW,CAAC,0EAA0E,CAAC;SACvF,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAEhC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE1B,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,aAAa,EAAE;KACZ,UAAU,EAAE;KACZ,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/commands/default.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/commands/default.tsx"],"names":[],"mappings":"AAQA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBvD"}
|
package/dist/commands/default.js
CHANGED
|
@@ -1,53 +1,19 @@
|
|
|
1
|
+
import { render } from 'ink';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { resolveOrg } from '../state/directory-config.js';
|
|
9
|
-
export async function runDefaultCommand(outputFormat) {
|
|
10
|
-
const logger = createDefaultCommandLogger();
|
|
11
|
-
const isJsonOutput = outputFormat === 'json';
|
|
3
|
+
import { CredentialManager } from '../auth/credentials.js';
|
|
4
|
+
import { DefaultFlow } from '../components/default-flow.js';
|
|
5
|
+
import { createLogger } from '../lib/logger.js';
|
|
6
|
+
import { config } from '../state/global-config.js';
|
|
7
|
+
export async function runDefaultCommand() {
|
|
8
|
+
const logger = createLogger();
|
|
12
9
|
try {
|
|
13
|
-
|
|
14
|
-
const credentialManager = await createCredentialManager();
|
|
10
|
+
const credentialManager = new CredentialManager();
|
|
15
11
|
const credentials = await credentialManager.getCredentials();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (credentials) {
|
|
19
|
-
try {
|
|
20
|
-
const result = await loginUser(credentials.accessToken);
|
|
21
|
-
const resolvedOrg = resolveOrg(process.cwd());
|
|
22
|
-
// check with a successful login whether the user still has access to the local org
|
|
23
|
-
const stillHasAccessToOrg = resolvedOrg !== null &&
|
|
24
|
-
result.me.organizations.nodes.some((org) => org.id === resolvedOrg.id);
|
|
25
|
-
// set org to null if user no longer has access
|
|
26
|
-
localOrg = stillHasAccessToOrg ? resolvedOrg : null;
|
|
27
|
-
organizations = result.me.organizations.nodes;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
logger.error({
|
|
31
|
-
error: error instanceof Error ? error.message : String(error),
|
|
32
|
-
}, 'Error during login or organization resolution');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (isJsonOutput) {
|
|
36
|
-
outputJson({
|
|
37
|
-
authenticated: !!credentials,
|
|
38
|
-
user: credentials ? { name: credentials.name } : null,
|
|
39
|
-
organization: localOrg,
|
|
40
|
-
organizations: organizations,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
await renderInk(React.createElement(Hero, { localOrg: localOrg, credentials: credentials, organizations: organizations }));
|
|
45
|
-
}
|
|
12
|
+
const instance = render(React.createElement(DefaultFlow, { logger: logger, credentials: credentials, defaultSetupDismissed: config.setupDismissed }));
|
|
13
|
+
await instance.waitUntilExit();
|
|
46
14
|
}
|
|
47
15
|
catch (error) {
|
|
48
|
-
logger.error({
|
|
49
|
-
error: error instanceof Error ? error.message : String(error),
|
|
50
|
-
}, 'Error during rendering');
|
|
16
|
+
logger.error({ error: error instanceof Error ? error.message : String(error) }, 'Error during rendering');
|
|
51
17
|
process.exit(1);
|
|
52
18
|
}
|
|
53
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/commands/default.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/commands/default.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAClD,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,cAAc,EAAE,CAAC;QAE7D,MAAM,QAAQ,GAAG,MAAM,CACrB,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,qBAAqB,EAAE,MAAM,CAAC,cAAc,GAC5C,CACH,CAAC;QACF,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CACV,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACjE,wBAAwB,CACzB,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-requirements.d.ts","sourceRoot":"","sources":["../../src/commands/find-requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"find-requirements.d.ts","sourceRoot":"","sources":["../../src/commands/find-requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,6BAA6B,IAAI,OAAO,CA6DvD"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { graphql, HttpResponse } from 'msw';
|
|
5
5
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
|
6
6
|
import { RequirementScopeClassification } from '../lib/graphql.js';
|
|
7
|
-
import { createMeHandler, IntegrationTestContext
|
|
7
|
+
import { createMeHandler, IntegrationTestContext } from '../test/integration-helpers.js';
|
|
8
8
|
// Mock requirements data
|
|
9
9
|
const mockRequirements = [
|
|
10
10
|
{
|
|
@@ -69,63 +69,24 @@ afterAll(() => {
|
|
|
69
69
|
ctx.cleanup();
|
|
70
70
|
});
|
|
71
71
|
describe('find-requirements command', () => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'--session',
|
|
79
|
-
'test-session',
|
|
80
|
-
'--title',
|
|
81
|
-
'authentication',
|
|
82
|
-
], { env: { STRAION_API_KEY: 'valid-test-token' } });
|
|
83
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
84
|
-
expect(parsed).not.toBeNull();
|
|
85
|
-
expect(Array.isArray(parsed)).toBe(true);
|
|
86
|
-
expect(parsed).toHaveLength(3);
|
|
87
|
-
expect(parsed?.at(0)?.content).toContain('Users must be able to log in with email and password');
|
|
88
|
-
expect(parsed?.at(0)?.collectionName).toBe('Security Requirements');
|
|
89
|
-
});
|
|
90
|
-
it('returns empty array when no requirements match', async () => {
|
|
91
|
-
const result = await ctx.runCLI(['-o', 'json', 'find-requirements', '--session', 'test-session'], { env: { STRAION_API_KEY: 'valid-test-token' } });
|
|
92
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
93
|
-
expect(parsed).not.toBeNull();
|
|
94
|
-
expect(Array.isArray(parsed)).toBe(true);
|
|
95
|
-
expect(parsed).toHaveLength(0);
|
|
96
|
-
});
|
|
97
|
-
it('includes all requirement fields in response', async () => {
|
|
98
|
-
const result = await ctx.runCLI(['-o', 'json', 'find-requirements', '--session', 'test-session', '--title', 'test'], { env: { STRAION_API_KEY: 'valid-test-token' } });
|
|
99
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
100
|
-
expect(parsed).not.toBeNull();
|
|
101
|
-
const firstReq = parsed?.at(0);
|
|
102
|
-
expect(firstReq).toHaveProperty('requirementId');
|
|
103
|
-
expect(firstReq).toHaveProperty('content');
|
|
104
|
-
expect(firstReq).toHaveProperty('scope');
|
|
105
|
-
expect(firstReq).toHaveProperty('scopeReasoning');
|
|
106
|
-
expect(firstReq).toHaveProperty('collectionName');
|
|
107
|
-
});
|
|
72
|
+
it('shows formatted requirements list', async () => {
|
|
73
|
+
const result = await ctx.runCLI(['find-requirements', '--session', 'test-session', '--title', 'authentication'], { env: { STRAION_API_KEY: 'valid-test-token' } });
|
|
74
|
+
expect(result.stdout).toContain('Found 3 matching requirement(s)');
|
|
75
|
+
expect(result.stdout).toContain('Security Requirements');
|
|
76
|
+
expect(result.stdout).toContain('Performance Requirements');
|
|
77
|
+
expect(result.stdout).toContain('Users must be able to log in with email and password');
|
|
108
78
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
expect(result.stdout).toContain('Found 3 matching requirement(s)');
|
|
113
|
-
expect(result.stdout).toContain('Security Requirements');
|
|
114
|
-
expect(result.stdout).toContain('Performance Requirements');
|
|
115
|
-
expect(result.stdout).toContain('Users must be able to log in with email and password');
|
|
116
|
-
});
|
|
117
|
-
it('shows message when no requirements found', async () => {
|
|
118
|
-
const result = await ctx.runCLI(['find-requirements', '--session', 'test-session'], {
|
|
119
|
-
env: { STRAION_API_KEY: 'valid-test-token' },
|
|
120
|
-
});
|
|
121
|
-
expect(result.stdout).toContain('No matching requirements found');
|
|
122
|
-
});
|
|
123
|
-
it('groups requirements by collection', async () => {
|
|
124
|
-
const result = await ctx.runCLI(['find-requirements', '--session', 'test-session', '--title', 'test'], { env: { STRAION_API_KEY: 'valid-test-token' } });
|
|
125
|
-
// Should show collection headers
|
|
126
|
-
expect(result.stdout).toContain('Security Requirements');
|
|
127
|
-
expect(result.stdout).toContain('Performance Requirements');
|
|
79
|
+
it('shows message when no requirements found', async () => {
|
|
80
|
+
const result = await ctx.runCLI(['find-requirements', '--session', 'test-session'], {
|
|
81
|
+
env: { STRAION_API_KEY: 'valid-test-token' },
|
|
128
82
|
});
|
|
83
|
+
expect(result.stdout).toContain('No matching requirements found');
|
|
84
|
+
});
|
|
85
|
+
it('groups requirements by collection', async () => {
|
|
86
|
+
const result = await ctx.runCLI(['find-requirements', '--session', 'test-session', '--title', 'test'], { env: { STRAION_API_KEY: 'valid-test-token' } });
|
|
87
|
+
// Should show collection headers
|
|
88
|
+
expect(result.stdout).toContain('Security Requirements');
|
|
89
|
+
expect(result.stdout).toContain('Performance Requirements');
|
|
129
90
|
});
|
|
130
91
|
});
|
|
131
92
|
//# sourceMappingURL=find-requirements.integration.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-requirements.integration.test.js","sourceRoot":"","sources":["../../src/commands/find-requirements.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAAE,8BAA8B,EAAyB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,
|
|
1
|
+
{"version":3,"file":"find-requirements.integration.test.js","sourceRoot":"","sources":["../../src/commands/find-requirements.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAAE,8BAA8B,EAAyB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAEzF,yBAAyB;AACzB,MAAM,gBAAgB,GAAuB;IAC3C;QACE,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,sDAAsD;QAC/D,KAAK,EAAE,8BAA8B,CAAC,OAAO;QAC7C,cAAc,EAAE,yBAAyB;QACzC,cAAc,EAAE,uBAAuB;QACvC,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,uCAAuC;QAChD,KAAK,EAAE,8BAA8B,CAAC,OAAO;QAC7C,cAAc,EAAE,wBAAwB;QACxC,cAAc,EAAE,uBAAuB;QACvC,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,GAAG;QACf,eAAe,EAAE,GAAG;KACrB;IACD;QACE,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,sCAAsC;QAC/C,KAAK,EAAE,8BAA8B,CAAC,SAAS;QAC/C,cAAc,EAAE,iBAAiB;QACjC,cAAc,EAAE,0BAA0B;QAC1C,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,GAAG;KACrB;CACF,CAAC;AAEF,mCAAmC;AACnC,MAAM,mBAAmB,GAAG,OAAO,CA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