@octp/cli 0.1.0
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/bin/octopus.js +2 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +86 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/knowledge/add.d.ts +2 -0
- package/dist/commands/knowledge/add.js +33 -0
- package/dist/commands/knowledge/add.js.map +1 -0
- package/dist/commands/knowledge/index.d.ts +2 -0
- package/dist/commands/knowledge/index.js +10 -0
- package/dist/commands/knowledge/index.js.map +1 -0
- package/dist/commands/knowledge/list.d.ts +2 -0
- package/dist/commands/knowledge/list.js +32 -0
- package/dist/commands/knowledge/list.js.map +1 -0
- package/dist/commands/knowledge/remove.d.ts +2 -0
- package/dist/commands/knowledge/remove.js +20 -0
- package/dist/commands/knowledge/remove.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +142 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pr/index.d.ts +2 -0
- package/dist/commands/pr/index.js +6 -0
- package/dist/commands/pr/index.js.map +1 -0
- package/dist/commands/pr/review.d.ts +2 -0
- package/dist/commands/pr/review.js +47 -0
- package/dist/commands/pr/review.js.map +1 -0
- package/dist/commands/repo/analyze.d.ts +2 -0
- package/dist/commands/repo/analyze.js +48 -0
- package/dist/commands/repo/analyze.js.map +1 -0
- package/dist/commands/repo/chat.d.ts +2 -0
- package/dist/commands/repo/chat.js +67 -0
- package/dist/commands/repo/chat.js.map +1 -0
- package/dist/commands/repo/index-cmd.d.ts +2 -0
- package/dist/commands/repo/index-cmd.js +47 -0
- package/dist/commands/repo/index-cmd.js.map +1 -0
- package/dist/commands/repo/index.d.ts +2 -0
- package/dist/commands/repo/index.js +14 -0
- package/dist/commands/repo/index.js.map +1 -0
- package/dist/commands/repo/list.d.ts +2 -0
- package/dist/commands/repo/list.js +32 -0
- package/dist/commands/repo/list.js.map +1 -0
- package/dist/commands/repo/status.d.ts +2 -0
- package/dist/commands/repo/status.js +45 -0
- package/dist/commands/repo/status.js.map +1 -0
- package/dist/commands/usage.d.ts +2 -0
- package/dist/commands/usage.js +41 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.js +27 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-client.d.ts +11 -0
- package/dist/lib/api-client.js +90 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/config-store.d.ts +8 -0
- package/dist/lib/config-store.js +57 -0
- package/dist/lib/config-store.js.map +1 -0
- package/dist/lib/output.d.ts +11 -0
- package/dist/lib/output.js +103 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/repo-resolver.d.ts +7 -0
- package/dist/lib/repo-resolver.js +64 -0
- package/dist/lib/repo-resolver.js.map +1 -0
- package/dist/lib/spinner.d.ts +3 -0
- package/dist/lib/spinner.js +17 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { apiGet } from "./api-client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Extract repo full name from git remote URL.
|
|
5
|
+
* Supports both SSH and HTTPS formats:
|
|
6
|
+
* - git@github.com:owner/repo.git
|
|
7
|
+
* - https://github.com/owner/repo.git
|
|
8
|
+
* - git@bitbucket.org:owner/repo.git
|
|
9
|
+
*/
|
|
10
|
+
function parseGitRemote(url) {
|
|
11
|
+
// SSH format: git@github.com:owner/repo.git
|
|
12
|
+
const sshMatch = url.match(/git@[^:]+:([^/]+\/[^/]+?)(?:\.git)?$/);
|
|
13
|
+
if (sshMatch)
|
|
14
|
+
return sshMatch[1];
|
|
15
|
+
// HTTPS format: https://github.com/owner/repo.git
|
|
16
|
+
const httpsMatch = url.match(/https?:\/\/[^/]+\/([^/]+\/[^/]+?)(?:\.git)?$/);
|
|
17
|
+
if (httpsMatch)
|
|
18
|
+
return httpsMatch[1];
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function getGitRemoteUrl() {
|
|
22
|
+
try {
|
|
23
|
+
return execSync("git remote get-url origin", {
|
|
24
|
+
encoding: "utf-8",
|
|
25
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
26
|
+
}).trim();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a repo argument to an API repo.
|
|
34
|
+
* - If repoArg is provided, search by name/fullName
|
|
35
|
+
* - If not provided, detect from CWD git remote
|
|
36
|
+
*/
|
|
37
|
+
export async function resolveRepo(repoArg) {
|
|
38
|
+
const { repos } = await apiGet("/api/cli/repos");
|
|
39
|
+
if (repoArg) {
|
|
40
|
+
const match = repos.find((r) => r.fullName === repoArg ||
|
|
41
|
+
r.name === repoArg ||
|
|
42
|
+
r.fullName.toLowerCase() === repoArg.toLowerCase() ||
|
|
43
|
+
r.name.toLowerCase() === repoArg.toLowerCase());
|
|
44
|
+
if (!match) {
|
|
45
|
+
throw new Error(`Repository "${repoArg}" not found. Run 'octopus repo list' to see available repos.`);
|
|
46
|
+
}
|
|
47
|
+
return match;
|
|
48
|
+
}
|
|
49
|
+
// Try to detect from CWD
|
|
50
|
+
const remoteUrl = getGitRemoteUrl();
|
|
51
|
+
if (!remoteUrl) {
|
|
52
|
+
throw new Error("Not in a git repository. Provide a repo name or run from a git directory.");
|
|
53
|
+
}
|
|
54
|
+
const fullName = parseGitRemote(remoteUrl);
|
|
55
|
+
if (!fullName) {
|
|
56
|
+
throw new Error(`Could not parse git remote URL: ${remoteUrl}`);
|
|
57
|
+
}
|
|
58
|
+
const match = repos.find((r) => r.fullName.toLowerCase() === fullName.toLowerCase());
|
|
59
|
+
if (!match) {
|
|
60
|
+
throw new Error(`Repository "${fullName}" is not connected to your Octopus organization. Run 'octopus repo list' to see available repos.`);
|
|
61
|
+
}
|
|
62
|
+
return match;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=repo-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-resolver.js","sourceRoot":"","sources":["../../src/lib/repo-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,4CAA4C;IAC5C,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACnE,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEjC,kDAAkD;IAClD,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAC7E,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IAErC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,eAAe;IACtB,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,2BAA2B,EAAE;YAC3C,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAgB;IAChD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,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inner: "dots" });
|
|
4
|
+
}
|
|
5
|
+
export async function withSpinner(text, fn) {
|
|
6
|
+
const spinner = createSpinner(text).start();
|
|
7
|
+
try {
|
|
8
|
+
const result = await fn(spinner);
|
|
9
|
+
spinner.succeed();
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
spinner.fail();
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/lib/spinner.ts"],"names":[],"mappings":"AAAA,OAAO,GAAiB,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAY,EACZ,EAAgC;IAEhC,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IAC5C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface CliConfig {
|
|
2
|
+
profiles: Record<string, CliProfile>;
|
|
3
|
+
activeProfile: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CliProfile {
|
|
6
|
+
apiUrl: string;
|
|
7
|
+
token: string;
|
|
8
|
+
orgSlug: string;
|
|
9
|
+
orgId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiRepo {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
fullName: string;
|
|
15
|
+
provider: string;
|
|
16
|
+
defaultBranch: string;
|
|
17
|
+
indexStatus: string;
|
|
18
|
+
indexedAt: string | null;
|
|
19
|
+
indexedFiles: number;
|
|
20
|
+
totalFiles: number;
|
|
21
|
+
totalChunks: number;
|
|
22
|
+
totalVectors?: number;
|
|
23
|
+
indexDurationMs?: number;
|
|
24
|
+
analysisStatus: string;
|
|
25
|
+
analyzedAt: string | null;
|
|
26
|
+
analysis?: string;
|
|
27
|
+
summary: string | null;
|
|
28
|
+
purpose: string | null;
|
|
29
|
+
autoReview: boolean;
|
|
30
|
+
contributorCount?: number;
|
|
31
|
+
_count: {
|
|
32
|
+
pullRequests: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface UsageBreakdown {
|
|
36
|
+
model: string;
|
|
37
|
+
operation: string;
|
|
38
|
+
count: number;
|
|
39
|
+
inputTokens: number;
|
|
40
|
+
outputTokens: number;
|
|
41
|
+
cacheReadTokens: number;
|
|
42
|
+
cacheWriteTokens: number;
|
|
43
|
+
cost: number;
|
|
44
|
+
}
|
|
45
|
+
export interface KnowledgeDocument {
|
|
46
|
+
id: string;
|
|
47
|
+
title: string;
|
|
48
|
+
sourceType: string;
|
|
49
|
+
fileName: string | null;
|
|
50
|
+
status: string;
|
|
51
|
+
totalChunks: number;
|
|
52
|
+
totalVectors: number;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octp/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI tool for Octopus — AI-powered PR review and codebase intelligence",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"octopus": "./bin/octopus.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"lint": "echo 'no lint configured'",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"clean": "rm -rf dist .turbo node_modules"
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist", "bin"],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"chalk": "^5.4.1",
|
|
21
|
+
"commander": "^13.1.0",
|
|
22
|
+
"ora": "^8.2.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@octopus/tsconfig": "workspace:*",
|
|
26
|
+
"@types/node": "^20",
|
|
27
|
+
"typescript": "^5"
|
|
28
|
+
}
|
|
29
|
+
}
|