@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
|
@@ -2,7 +2,6 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { getGraphqlClient } from '../auth/graphql-client.js';
|
|
3
3
|
import { GetMatchingRequirementsForTaskDocument, } from '../lib/graphql.js';
|
|
4
4
|
import { withAuthAndLogging } from '../lib/middleware.js';
|
|
5
|
-
import { outputJson } from '../lib/output.js';
|
|
6
5
|
export function createFindRequirementsCommand() {
|
|
7
6
|
return new Command('find-requirements')
|
|
8
7
|
.requiredOption('--session <id>', 'Session ID from the calling agent')
|
|
@@ -10,8 +9,7 @@ export function createFindRequirementsCommand() {
|
|
|
10
9
|
.option('--body <body>', 'Body/content of the task', '')
|
|
11
10
|
.option('--summary <summary>', 'Summary of the entire plan', '')
|
|
12
11
|
.description('Find requirements matching a given task description')
|
|
13
|
-
.action(withAuthAndLogging(async (options, { organization, accessToken, logger
|
|
14
|
-
const isJsonOutput = outputFormat === 'json';
|
|
12
|
+
.action(withAuthAndLogging(async (options, { organization, accessToken, logger }) => {
|
|
15
13
|
try {
|
|
16
14
|
const client = getGraphqlClient(accessToken, organization.id);
|
|
17
15
|
const response = await client.request(GetMatchingRequirementsForTaskDocument, {
|
|
@@ -20,32 +18,27 @@ export function createFindRequirementsCommand() {
|
|
|
20
18
|
summary: options.summary,
|
|
21
19
|
});
|
|
22
20
|
const requirements = response.getMatchingRequirementsForTask;
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
// Text output: display requirements in readable format
|
|
22
|
+
if (requirements.length === 0) {
|
|
23
|
+
console.log('No matching requirements found.');
|
|
25
24
|
}
|
|
26
25
|
else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const byCollection = new Map();
|
|
35
|
-
for (const req of requirements) {
|
|
36
|
-
const collectionName = req.collectionName;
|
|
37
|
-
if (!byCollection.has(collectionName)) {
|
|
38
|
-
byCollection.set(collectionName, []);
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
41
|
-
byCollection.get(collectionName).push(req);
|
|
26
|
+
console.log(`Found ${requirements.length} matching requirement(s):\n`);
|
|
27
|
+
// Group requirements by collection
|
|
28
|
+
const byCollection = new Map();
|
|
29
|
+
for (const req of requirements) {
|
|
30
|
+
const collectionName = req.collectionName;
|
|
31
|
+
if (!byCollection.has(collectionName)) {
|
|
32
|
+
byCollection.set(collectionName, []);
|
|
42
33
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
35
|
+
byCollection.get(collectionName).push(req);
|
|
36
|
+
}
|
|
37
|
+
for (const [collectionName, reqs] of byCollection) {
|
|
38
|
+
console.log(`Collection name: ${collectionName}`);
|
|
39
|
+
console.log('Requirements:');
|
|
40
|
+
for (const req of reqs) {
|
|
41
|
+
console.log(`- ${req.content} [${req.scope}] Reason: ${req.scopeReasoning}`);
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
44
|
}
|
|
@@ -53,12 +46,7 @@ export function createFindRequirementsCommand() {
|
|
|
53
46
|
}
|
|
54
47
|
catch (error) {
|
|
55
48
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
56
|
-
|
|
57
|
-
outputJson({ error: errorMessage });
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
console.error(`Error: ${errorMessage}`);
|
|
61
|
-
}
|
|
49
|
+
console.error(`Error: ${errorMessage}`);
|
|
62
50
|
process.exit(1);
|
|
63
51
|
}
|
|
64
52
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-requirements.js","sourceRoot":"","sources":["../../src/commands/find-requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,sCAAsC,GAGvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-requirements.js","sourceRoot":"","sources":["../../src/commands/find-requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,sCAAsC,GAGvC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC;SACpC,cAAc,CAAC,gBAAgB,EAAE,mCAAmC,CAAC;SACrE,MAAM,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,EAAE,CAAC;SAClD,MAAM,CAAC,e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;gBAED,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC;oBAClD,OAAO,CAAC,GAAG,CAAC,oBAAoB,cAAc,EAAE,CAAC,CAAC;oBAClD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;oBAC7B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;wBACvB,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,KAAK,aAAa,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;oBAC/E,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,CAAC,IAAI,CACT,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EACpF,+BAA+B,CAChC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAE9E,OAAO,CAAC,KAAK,CAAC,UAAU,YAAY,EAAE,CAAC,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAMvD"}
|
package/dist/commands/index.js
CHANGED
|
@@ -2,10 +2,12 @@ import { createFindRequirementsCommand } from './find-requirements.js';
|
|
|
2
2
|
import { createLoginCommand } from './login.js';
|
|
3
3
|
import { createLogoutCommand } from './logout.js';
|
|
4
4
|
import { createSessionStartCommand } from './session-start.js';
|
|
5
|
+
import { createSetupCommand } from './setup.js';
|
|
5
6
|
export function registerCommands(program) {
|
|
6
7
|
program.addCommand(createSessionStartCommand());
|
|
7
8
|
program.addCommand(createLoginCommand());
|
|
8
9
|
program.addCommand(createLogoutCommand());
|
|
9
10
|
program.addCommand(createFindRequirementsCommand());
|
|
11
|
+
program.addCommand(createSetupCommand());
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,6BAA6B,EAAE,CAAC,CAAC;IACpD,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,kBAAkB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,kBAAkB,IAAI,OAAO,CA+D5C"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Run with: pnpm nx test cli -- --run src/commands/login.integration.test.ts
|
|
11
11
|
*/
|
|
12
12
|
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
13
|
-
import { createMeHandler, IntegrationTestContext
|
|
13
|
+
import { createMeHandler, IntegrationTestContext } from '../test/integration-helpers.js';
|
|
14
14
|
const ctx = new IntegrationTestContext();
|
|
15
15
|
beforeAll(async () => {
|
|
16
16
|
await ctx.setupServer([createMeHandler()]);
|
|
@@ -39,150 +39,29 @@ function runLoginCLI(args, options = {}) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
describe('login command (non-interactive/integration)', () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
// Should not output JSON (no -o json flag)
|
|
50
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
51
|
-
expect(parsed).toBeNull();
|
|
52
|
-
// Should exit with error
|
|
53
|
-
expect(result.exitCode).not.toBe(0);
|
|
54
|
-
});
|
|
55
|
-
it('shows text success message with valid token', async () => {
|
|
56
|
-
const result = await runLoginCLI(['login', '--token', 'valid-test-token']);
|
|
57
|
-
// Should not output JSON
|
|
58
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
59
|
-
expect(parsed).toBeNull();
|
|
60
|
-
// Should show TUI success message
|
|
61
|
-
expect(result.stdout).toContain('Hello');
|
|
62
|
-
expect(result.stdout).toContain('Test');
|
|
63
|
-
expect(result.stdout).toContain('logged in successfully');
|
|
64
|
-
expect(result.exitCode).toBe(0);
|
|
65
|
-
});
|
|
66
|
-
it('shows text error message with invalid token', async () => {
|
|
67
|
-
const result = await runLoginCLI(['login', '--token', 'invalid-token']);
|
|
68
|
-
// Should not output JSON
|
|
69
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
70
|
-
expect(parsed).toBeNull();
|
|
71
|
-
// Should show TUI error message
|
|
72
|
-
expect(result.stdout).toContain('Login failed');
|
|
73
|
-
expect(result.exitCode).not.toBe(0);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe('without token', () => {
|
|
77
|
-
it('outputs JSON error when no token is provided in non-TTY mode', async () => {
|
|
78
|
-
const result = await runLoginCLI(['-o', 'json', 'login'], {
|
|
79
|
-
env: {
|
|
80
|
-
// Explicitly clear STRAION_API_KEY to ensure no token is available
|
|
81
|
-
STRAION_API_KEY: '',
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
// In non-TTY mode without a token, should output JSON error
|
|
85
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
86
|
-
expect(parsed).not.toBeNull();
|
|
87
|
-
expect(parsed?.success).toBe(false);
|
|
88
|
-
expect(parsed?.error).toContain('Token required in non-interactive mode');
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe('with STRAION_API_KEY env var', () => {
|
|
92
|
-
it('authenticates successfully with valid token from env var', async () => {
|
|
93
|
-
const result = await runLoginCLI(['-o', 'json', 'login'], {
|
|
94
|
-
env: {
|
|
95
|
-
STRAION_API_KEY: 'valid-test-token',
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
99
|
-
expect(parsed).not.toBeNull();
|
|
100
|
-
expect(parsed?.success).toBe(true);
|
|
101
|
-
expect(parsed?.user?.id).toBe('user-123');
|
|
102
|
-
expect(parsed?.user?.name).toBe('Test User');
|
|
103
|
-
expect(parsed?.organization?.id).toBe('org-456');
|
|
104
|
-
expect(parsed?.organization?.name).toBe('Test Organization');
|
|
105
|
-
});
|
|
106
|
-
it('outputs error for invalid token from env var', async () => {
|
|
107
|
-
const result = await runLoginCLI(['-o', 'json', 'login'], {
|
|
108
|
-
env: {
|
|
109
|
-
STRAION_API_KEY: 'invalid-test-token',
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
113
|
-
expect(parsed).not.toBeNull();
|
|
114
|
-
expect(parsed?.success).toBe(false);
|
|
115
|
-
expect(parsed?.error).toContain('Authentication failed');
|
|
116
|
-
});
|
|
117
|
-
it('token flag takes precedence over STRAION_API_KEY', async () => {
|
|
118
|
-
// Pass invalid flag token but valid env token - should fail because flag takes precedence
|
|
119
|
-
const result = await runLoginCLI(['-o', 'json', 'login', '--token', 'invalid-flag-token'], {
|
|
120
|
-
env: {
|
|
121
|
-
STRAION_API_KEY: 'valid-test-token',
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
125
|
-
// Should fail because flag-token (invalid) takes precedence over env (valid)
|
|
126
|
-
expect(parsed).not.toBeNull();
|
|
127
|
-
expect(parsed?.success).toBe(false);
|
|
42
|
+
it('exits with error when no token is provided in non-TTY mode', async () => {
|
|
43
|
+
const result = await runLoginCLI(['login'], {
|
|
44
|
+
env: {
|
|
45
|
+
STRAION_API_KEY: '',
|
|
46
|
+
},
|
|
128
47
|
});
|
|
48
|
+
// Should exit with error
|
|
49
|
+
expect(result.exitCode).not.toBe(0);
|
|
129
50
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
expect(parsed?.user?.firstName).toBe('Test');
|
|
139
|
-
expect(parsed?.organization?.id).toBe('org-456');
|
|
140
|
-
expect(parsed?.organization?.name).toBe('Test Organization');
|
|
141
|
-
expect(parsed?.organization?.subdomain).toBe('test-org');
|
|
142
|
-
});
|
|
143
|
-
it('outputs JSON error for invalid token', async () => {
|
|
144
|
-
const result = await runLoginCLI(['-o', 'json', 'login', '--token', 'invalid-token']);
|
|
145
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
146
|
-
expect(parsed).not.toBeNull();
|
|
147
|
-
expect(parsed?.success).toBe(false);
|
|
148
|
-
expect(parsed?.error).toContain('Authentication failed');
|
|
149
|
-
});
|
|
51
|
+
it('shows text success message with valid token', async () => {
|
|
52
|
+
const result = await runLoginCLI(['login', '--token', 'valid-test-token']);
|
|
53
|
+
console.log(result);
|
|
54
|
+
// Should show TUI success message
|
|
55
|
+
expect(result.stdout).toContain('Hello');
|
|
56
|
+
expect(result.stdout).toContain('Test');
|
|
57
|
+
expect(result.stdout).toContain('logged in successfully');
|
|
58
|
+
expect(result.exitCode).toBe(0);
|
|
150
59
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
STRAION_API_KEY: '',
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
// Should be parseable as JSON
|
|
160
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
161
|
-
expect(parsed).not.toBeNull();
|
|
162
|
-
// Should have expected shape
|
|
163
|
-
expect(typeof parsed?.success).toBe('boolean');
|
|
164
|
-
if (!parsed?.success) {
|
|
165
|
-
expect(typeof parsed?.error).toBe('string');
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
it('success response includes all required fields', async () => {
|
|
169
|
-
const result = await runLoginCLI(['-o', 'json', 'login', '--token', 'valid-test-token']);
|
|
170
|
-
const parsed = parseJSONOutput(result.stdout);
|
|
171
|
-
expect(parsed).toEqual({
|
|
172
|
-
success: true,
|
|
173
|
-
user: {
|
|
174
|
-
id: 'user-123',
|
|
175
|
-
name: 'Test User',
|
|
176
|
-
firstName: 'Test',
|
|
177
|
-
},
|
|
178
|
-
organization: {
|
|
179
|
-
id: 'org-456',
|
|
180
|
-
name: 'Test Organization',
|
|
181
|
-
subdomain: 'test-org',
|
|
182
|
-
},
|
|
183
|
-
tokenSource: 'flag',
|
|
184
|
-
});
|
|
185
|
-
});
|
|
60
|
+
it('shows text error message with invalid token', async () => {
|
|
61
|
+
const result = await runLoginCLI(['login', '--token', 'invalid-token']);
|
|
62
|
+
// Should show TUI error message
|
|
63
|
+
expect(result.stdout).toContain('Login failed');
|
|
64
|
+
expect(result.exitCode).not.toBe(0);
|
|
186
65
|
});
|
|
187
66
|
});
|
|
188
67
|
//# sourceMappingURL=login.integration.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.integration.test.js","sourceRoot":"","sources":["../../src/commands/login.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9E,OAAO,
|
|
1
|
+
{"version":3,"file":"login.integration.test.js","sourceRoot":"","sources":["../../src/commands/login.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9E,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAEzF,MAAM,GAAG,GAA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AClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;QAExE,gCAAgC;QAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/commands/login.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CredentialManager } from '../auth/credentials.js';
|
|
4
4
|
import { LoginFlow } from '../components/login/login-flow.js';
|
|
5
5
|
import {} from '../lib/graphql.js';
|
|
6
|
-
import {
|
|
6
|
+
import { createPromise, renderInkWithControl } from '../lib/ink-render.js';
|
|
7
7
|
import { withLogging } from '../lib/middleware.js';
|
|
8
|
-
import {
|
|
8
|
+
import { config, saveConfig } from '../state/global-config.js';
|
|
9
9
|
export function createLoginCommand() {
|
|
10
10
|
return new Command('login')
|
|
11
11
|
.description('Authenticate with a Personal Access Token')
|
|
12
12
|
.option('--token <token>', 'Personal Access Token')
|
|
13
|
-
.action(withLogging(async (options, { logger
|
|
13
|
+
.action(withLogging(async (options, { logger }) => {
|
|
14
14
|
try {
|
|
15
15
|
// Token resolution: --token flag takes precedence over env var
|
|
16
16
|
const token = options.token || process.env.STRAION_API_KEY;
|
|
@@ -20,18 +20,25 @@ export function createLoginCommand() {
|
|
|
20
20
|
? 'env'
|
|
21
21
|
: 'input';
|
|
22
22
|
const skipOrgSelection = !!token;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
logger.info({ tokenSource }, 'Starting login process');
|
|
24
|
+
const { promise, resolve, reject } = createPromise();
|
|
25
|
+
logger.debug('Rendering TUI for login flow');
|
|
26
|
+
const instance = renderInkWithControl(React.createElement(LoginFlow, { defaultPat: token, tokenSource: tokenSource, skipOrgSelection: skipOrgSelection, onComplete: (user, org, pat) => resolve({ user, org, pat }), onError: (error) => reject(error ?? new Error('Login failed')) }));
|
|
25
27
|
const { user, org, pat } = await promise;
|
|
28
|
+
instance.unmount();
|
|
29
|
+
logger.info({ userId: user.id, orgId: org.id }, 'Login successful');
|
|
26
30
|
// Store credentials in secure storage
|
|
27
|
-
const credentialManager =
|
|
31
|
+
const credentialManager = new CredentialManager();
|
|
28
32
|
await credentialManager.setCredentials({
|
|
29
33
|
userId: user.id,
|
|
30
34
|
name: user.firstName ?? user.name,
|
|
31
35
|
accessToken: pat,
|
|
32
36
|
});
|
|
37
|
+
logger.debug('Stored user credentials in credential manager');
|
|
33
38
|
// Store global org
|
|
34
|
-
|
|
39
|
+
config.globalOrg = org;
|
|
40
|
+
saveConfig();
|
|
41
|
+
logger.debug(`Set global organization to ${org.name} (${org.id})`);
|
|
35
42
|
}
|
|
36
43
|
catch (error) {
|
|
37
44
|
logger.error({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;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K,CACV;gBACE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,EACD,oBAAoB,CACrB,CAAC;YACF,2DAA2D;YAC3D,YAAY,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,mBAAmB,IAAI,OAAO,CA4B7C"}
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,39 +1,25 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
2
|
+
import { Box, render, Text } from 'ink';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { renderInk } from '../lib/ink-render.js';
|
|
4
|
+
import { CredentialManager } from '../auth/credentials.js';
|
|
6
5
|
import { withLogging } from '../lib/middleware.js';
|
|
7
|
-
import { outputJson } from '../lib/output.js';
|
|
8
|
-
import { globalConfig } from '../state/global-config.js';
|
|
9
6
|
export function createLogoutCommand() {
|
|
10
|
-
return new Command('logout').description('Log out and clear stored credentials').action(withLogging(async (_, { logger
|
|
11
|
-
const isJsonOutput = outputFormat === 'json';
|
|
7
|
+
return new Command('logout').description('Log out and clear stored credentials').action(withLogging(async (_, { logger }) => {
|
|
12
8
|
try {
|
|
13
|
-
// Clear credentials
|
|
14
|
-
const credentialManager =
|
|
9
|
+
// Clear stored credentials
|
|
10
|
+
const credentialManager = new CredentialManager();
|
|
15
11
|
await credentialManager.deleteCredentials();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
outputJson({ success: true });
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
await renderInk(React.createElement(Box, { flexDirection: "column", borderStyle: "single", paddingLeft: 1 },
|
|
23
|
-
React.createElement(Text, { color: "green" }, "\u2713 Logged out successfully.")));
|
|
24
|
-
}
|
|
12
|
+
const instance = render(React.createElement(Box, { flexDirection: "column", borderStyle: "single", paddingLeft: 1 },
|
|
13
|
+
React.createElement(Text, { color: "green" }, "\u2713 Logged out successfully.")));
|
|
14
|
+
await instance.waitUntilExit();
|
|
25
15
|
}
|
|
26
16
|
catch (error) {
|
|
27
17
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
React.createElement(Text, { color: "red" },
|
|
34
|
-
"\u2717 Logout failed: ",
|
|
35
|
-
errorMessage)));
|
|
36
|
-
}
|
|
18
|
+
const instance = render(React.createElement(Box, { flexDirection: "column", borderStyle: "single", paddingLeft: 1 },
|
|
19
|
+
React.createElement(Text, { color: "red" },
|
|
20
|
+
"\u2717 Logout failed: ",
|
|
21
|
+
errorMessage)));
|
|
22
|
+
await instance.waitUntilExit();
|
|
37
23
|
logger.error({ error: errorMessage }, 'Logout command failed');
|
|
38
24
|
process.exit(1);
|
|
39
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names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AC;YAC/B,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,uBAAuB,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-start.d.ts","sourceRoot":"","sources":["../../src/commands/session-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"session-start.d.ts","sourceRoot":"","sources":["../../src/commands/session-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,yBAAyB,IAAI,OAAO,CAWnD"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { withAuthAndLogging } from '../lib/middleware.js';
|
|
3
|
-
import { outputJson } from '../lib/output.js';
|
|
4
3
|
export function createSessionStartCommand() {
|
|
5
4
|
return new Command('session-start')
|
|
6
5
|
.description('Initialize a Straion session for the current directory')
|
|
7
6
|
.requiredOption('--session <id>', 'Session ID from the calling agent')
|
|
8
|
-
.action(withAuthAndLogging(async (
|
|
7
|
+
.action(withAuthAndLogging(async (_, { logger, organization }) => {
|
|
9
8
|
logger.info('Session start initiated');
|
|
10
9
|
logger.info({ orgId: organization.id }, 'Session started successfully');
|
|
11
|
-
if (outputFormat === 'json') {
|
|
12
|
-
outputJson({ success: true, organizationId: organization.id });
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
console.log(`${String.fromCodePoint(0x1f43f)} Straion session started...`);
|
|
16
|
-
}
|
|
17
10
|
}));
|
|
18
11
|
}
|
|
19
12
|
//# sourceMappingURL=session-start.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-start.js","sourceRoot":"","sources":["../../src/commands/session-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-start.js","sourceRoot":"","sources":["../../src/commands/session-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,yBAAyB;IACvC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;SAChC,WAAW,CAAC,wDAAwD,CAAC;SACrE,cAAc,CAAC,gBAAgB,EAAE,mCAAmC,CAAC;SACrE,MAAM,CACL,kBAAkB,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;QACvD,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAEvC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,8BAA8B,CAAC,CAAC;IAC1E,CAAC,CAAC,CACH,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BpC,wBAAgB,kBAAkB,IAAI,OAAO,CAQ5C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Box, render, useApp } from 'ink';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Banner } from '../components/banner.js';
|
|
5
|
+
import { AgentSetup } from '../components/setup/agent-setup.js';
|
|
6
|
+
import { withLogging } from '../lib/middleware.js';
|
|
7
|
+
function SetupCommand({ logger }) {
|
|
8
|
+
const { exit } = useApp();
|
|
9
|
+
return (React.createElement(Box, { flexDirection: "column", paddingY: 1, paddingX: 2 },
|
|
10
|
+
React.createElement(Banner, null),
|
|
11
|
+
React.createElement(AgentSetup, { logger: logger, onComplete: () => {
|
|
12
|
+
logger.info('Setup completed.');
|
|
13
|
+
exit();
|
|
14
|
+
} })));
|
|
15
|
+
}
|
|
16
|
+
export function createSetupCommand() {
|
|
17
|
+
return new Command('setup').description('Set up your coding agents to use Straion').action(withLogging(async (options, { logger }) => {
|
|
18
|
+
logger.info('Setup started.');
|
|
19
|
+
const instance = render(React.createElement(SetupCommand, { logger: logger }));
|
|
20
|
+
await instance.waitUntilExit();
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,SAAS,YAAY,CAAC,EAAE,MAAM,EAAsB;IAClD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAE1B,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC;QAClD,oBAAC,MAAM,OAAG;QACV,oBAAC,UAAU,IACT,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,GAAG,EAAE;gBACf,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBAChC,IAAI,EAAE,CAAC;YACT,CAAC,GACD,CACE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,0CAA0C,CAAC,CAAC,MAAM,CACxF,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,CAAC,CAAC;QAC1D,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/components/banner.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,eAAO,MAAM,MAAM,yBAElB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Text } from 'ink';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const straionAscii = `
|
|
4
|
+
███████╗████████╗██████╗ █████╗ ██╗ ██████╗ ███╗ ██╗
|
|
5
|
+
██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║██╔═══██╗████╗ ██║
|
|
6
|
+
███████╗ ██║ ██████╔╝███████║██║██║ ██║██╔██╗ ██║
|
|
7
|
+
╚════██║ ██║ ██╔══██╗██╔══██║██║██║ ██║██║╚██╗██║
|
|
8
|
+
███████║ ██║ ██║ ██║██║ ██║██║╚██████╔╝██║ ╚████║
|
|
9
|
+
╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝`;
|
|
10
|
+
export const Banner = () => {
|
|
11
|
+
return React.createElement(Text, null, straionAscii);
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/components/banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,YAAY,GAAG;;;;;;wDAMmC,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE;IACzB,OAAO,oBAAC,IAAI,QAAE,YAAY,CAAQ,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type StoredCredentials } from '../auth/credentials.js';
|
|
4
|
+
interface DefaultFlowProps {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
credentials: StoredCredentials | null;
|
|
7
|
+
defaultSetupDismissed: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function DefaultFlow({ logger, credentials, defaultSetupDismissed }: DefaultFlowProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=default-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-flow.d.ts","sourceRoot":"","sources":["../../src/components/default-flow.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAgC,MAAM,OAAO,CAAC;AAErD,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAWnF,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,EAAE,gBAAgB,qBA0F3F"}
|