@pmate/cli 0.5.6 → 0.6.1
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/README.md +26 -5
- package/dist/alioss.d.ts +4 -2
- package/dist/alioss.js +53 -12
- package/dist/alioss.js.map +1 -1
- package/dist/commands/AddDnsCommandHandler.js +5 -3
- package/dist/commands/AddDnsCommandHandler.js.map +1 -1
- package/dist/commands/DeployCommandHandler.js +4 -3
- package/dist/commands/DeployCommandHandler.js.map +1 -1
- package/dist/commands/LinearCommandHandler.d.ts +5 -0
- package/dist/commands/LinearCommandHandler.js +159 -24
- package/dist/commands/LinearCommandHandler.js.map +1 -1
- package/dist/commands/LoginCommandHandler.js +5 -3
- package/dist/commands/LoginCommandHandler.js.map +1 -1
- package/dist/commands/NotionCommandHandler.d.ts +5 -0
- package/dist/commands/NotionCommandHandler.js +49 -0
- package/dist/commands/NotionCommandHandler.js.map +1 -0
- package/dist/commands/PrCommandHandler.js +65 -12
- package/dist/commands/PrCommandHandler.js.map +1 -1
- package/dist/commands/SummaryCommandHandler.js +6 -4
- package/dist/commands/SummaryCommandHandler.js.map +1 -1
- package/dist/config.d.ts +48 -1
- package/dist/config.js +139 -16
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +98 -6
- package/dist/index.js.map +1 -1
- package/dist/services/AliyunService.d.ts +0 -2
- package/dist/services/AliyunService.js +129 -66
- package/dist/services/AliyunService.js.map +1 -1
- package/dist/services/NotionService.d.ts +43 -0
- package/dist/services/NotionService.js +268 -0
- package/dist/services/NotionService.js.map +1 -0
- package/dist/types.d.ts +15 -2
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -31,19 +31,40 @@ pmate login
|
|
|
31
31
|
pmate sts
|
|
32
32
|
pmate oss list
|
|
33
33
|
pmate oss upload --file ./path/to/file --key assets/file.txt
|
|
34
|
+
pmate pr
|
|
34
35
|
```
|
|
35
36
|
|
|
37
|
+
Notes:
|
|
38
|
+
- `pmate pr` normalizes generated PR titles to start with `feat: `, `fix: `, or `chore: ` (exactly one space after `:`).
|
|
39
|
+
|
|
36
40
|
## Aliyun credentials config
|
|
37
41
|
|
|
38
|
-
You can set Aliyun credentials in `~/.pmate/config
|
|
42
|
+
You can set Aliyun credentials in `~/.pmate/config.yaml`:
|
|
39
43
|
|
|
40
44
|
```bash
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
aliyun:
|
|
46
|
+
ak: your_ak
|
|
47
|
+
sk: your_sk
|
|
48
|
+
region: cn-hangzhou
|
|
49
|
+
domain: example.com
|
|
45
50
|
```
|
|
46
51
|
|
|
52
|
+
## Linear config
|
|
53
|
+
|
|
54
|
+
Add one or more Linear accounts to `~/.pmate/config.yaml`:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
linear:
|
|
58
|
+
teamKey: ENG
|
|
59
|
+
accounts:
|
|
60
|
+
- title: work
|
|
61
|
+
apiKey: your_linear_api_key
|
|
62
|
+
- title: personal
|
|
63
|
+
apiKey: your_other_linear_api_key
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
When multiple accounts exist, `pmate linear` will ask you to choose once per working directory and cache it in `~/.pmate/linear-selection.json`.
|
|
67
|
+
|
|
47
68
|
## Auth session
|
|
48
69
|
|
|
49
70
|
`pmate login` stores a session token in `~/.pmate/session.json`. Commands like
|
package/dist/alioss.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import OSS from "ali-oss";
|
|
|
2
2
|
export declare class POSS {
|
|
3
3
|
private client;
|
|
4
4
|
constructor(options: OSS.Options);
|
|
5
|
-
static
|
|
6
|
-
static
|
|
5
|
+
private static publicInstance;
|
|
6
|
+
private static privateInstance;
|
|
7
|
+
static get publicOSS(): POSS;
|
|
8
|
+
static get privateOSS(): POSS;
|
|
7
9
|
uploadJsonToOSS(key: string, jsonData: any): Promise<OSS.PutObjectResult>;
|
|
8
10
|
removeOSS(key: string): Promise<OSS.DeleteResult>;
|
|
9
11
|
copyOSS(sourceKey: string, targetKey: string): Promise<OSS.CopyAndPutMetaResult>;
|
package/dist/alioss.js
CHANGED
|
@@ -4,10 +4,61 @@ exports.POSS = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const ali_oss_1 = tslib_1.__importDefault(require("ali-oss"));
|
|
6
6
|
const cli_1 = require("./cli");
|
|
7
|
+
const config_1 = require("./config");
|
|
7
8
|
class POSS {
|
|
8
9
|
constructor(options) {
|
|
9
10
|
this.client = new ali_oss_1.default(options);
|
|
10
11
|
}
|
|
12
|
+
static get publicOSS() {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
14
|
+
if (!this.publicInstance) {
|
|
15
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
16
|
+
const region = (_c = (_b = (_a = config.oss) === null || _a === void 0 ? void 0 : _a.public) === null || _b === void 0 ? void 0 : _b.region) === null || _c === void 0 ? void 0 : _c.trim();
|
|
17
|
+
const bucket = (_f = (_e = (_d = config.oss) === null || _d === void 0 ? void 0 : _d.public) === null || _e === void 0 ? void 0 : _e.bucket) === null || _f === void 0 ? void 0 : _f.trim();
|
|
18
|
+
const accessKeyId = (_h = (_g = config.aliyun) === null || _g === void 0 ? void 0 : _g.ak) === null || _h === void 0 ? void 0 : _h.trim();
|
|
19
|
+
const accessKeySecret = (_k = (_j = config.aliyun) === null || _j === void 0 ? void 0 : _j.sk) === null || _k === void 0 ? void 0 : _k.trim();
|
|
20
|
+
if (!region)
|
|
21
|
+
throw new Error("Missing oss.public.region in ~/.pmate/config.yaml.");
|
|
22
|
+
if (!bucket)
|
|
23
|
+
throw new Error("Missing oss.public.bucket in ~/.pmate/config.yaml.");
|
|
24
|
+
if (!accessKeyId)
|
|
25
|
+
throw new Error("Missing aliyun.ak in ~/.pmate/config.yaml.");
|
|
26
|
+
if (!accessKeySecret)
|
|
27
|
+
throw new Error("Missing aliyun.sk in ~/.pmate/config.yaml.");
|
|
28
|
+
this.publicInstance = new POSS({
|
|
29
|
+
region,
|
|
30
|
+
accessKeyId,
|
|
31
|
+
accessKeySecret,
|
|
32
|
+
bucket,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return this.publicInstance;
|
|
36
|
+
}
|
|
37
|
+
static get privateOSS() {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
39
|
+
if (!this.privateInstance) {
|
|
40
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
41
|
+
const region = (_c = (_b = (_a = config.oss) === null || _a === void 0 ? void 0 : _a.private) === null || _b === void 0 ? void 0 : _b.region) === null || _c === void 0 ? void 0 : _c.trim();
|
|
42
|
+
const bucket = (_f = (_e = (_d = config.oss) === null || _d === void 0 ? void 0 : _d.private) === null || _e === void 0 ? void 0 : _e.bucket) === null || _f === void 0 ? void 0 : _f.trim();
|
|
43
|
+
const accessKeyId = (_h = (_g = config.aliyun) === null || _g === void 0 ? void 0 : _g.ak) === null || _h === void 0 ? void 0 : _h.trim();
|
|
44
|
+
const accessKeySecret = (_k = (_j = config.aliyun) === null || _j === void 0 ? void 0 : _j.sk) === null || _k === void 0 ? void 0 : _k.trim();
|
|
45
|
+
if (!region)
|
|
46
|
+
throw new Error("Missing oss.private.region in ~/.pmate/config.yaml.");
|
|
47
|
+
if (!bucket)
|
|
48
|
+
throw new Error("Missing oss.private.bucket in ~/.pmate/config.yaml.");
|
|
49
|
+
if (!accessKeyId)
|
|
50
|
+
throw new Error("Missing aliyun.ak in ~/.pmate/config.yaml.");
|
|
51
|
+
if (!accessKeySecret)
|
|
52
|
+
throw new Error("Missing aliyun.sk in ~/.pmate/config.yaml.");
|
|
53
|
+
this.privateInstance = new POSS({
|
|
54
|
+
region,
|
|
55
|
+
accessKeyId,
|
|
56
|
+
accessKeySecret,
|
|
57
|
+
bucket,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return this.privateInstance;
|
|
61
|
+
}
|
|
11
62
|
async uploadJsonToOSS(key, jsonData) {
|
|
12
63
|
try {
|
|
13
64
|
const result = await this.client.put(key, Buffer.from(JSON.stringify(jsonData)), {
|
|
@@ -225,16 +276,6 @@ class POSS {
|
|
|
225
276
|
}
|
|
226
277
|
}
|
|
227
278
|
exports.POSS = POSS;
|
|
228
|
-
POSS.
|
|
229
|
-
|
|
230
|
-
accessKeyId: process.env.ALIYUN_AK,
|
|
231
|
-
accessKeySecret: process.env.ALIYUN_SK,
|
|
232
|
-
bucket: process.env.OSS_BUCKET,
|
|
233
|
-
});
|
|
234
|
-
POSS.privateOSS = new POSS({
|
|
235
|
-
region: process.env.PRV_OSS_REGION,
|
|
236
|
-
accessKeyId: process.env.ALIYUN_AK,
|
|
237
|
-
accessKeySecret: process.env.ALIYUN_SK,
|
|
238
|
-
bucket: process.env.PRV_BUCKET,
|
|
239
|
-
});
|
|
279
|
+
POSS.publicInstance = null;
|
|
280
|
+
POSS.privateInstance = null;
|
|
240
281
|
//# sourceMappingURL=alioss.js.map
|
package/dist/alioss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alioss.js","sourceRoot":"","sources":["../src/alioss.ts"],"names":[],"mappings":";;;;AAAA,8DAAkD;AAClD,+BAA0B;
|
|
1
|
+
{"version":3,"file":"alioss.js","sourceRoot":"","sources":["../src/alioss.ts"],"names":[],"mappings":";;;;AAAA,8DAAkD;AAClD,+BAA0B;AAC1B,qCAA0C;AAE1C,MAAa,IAAI;IAGf,YAAY,OAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,iBAAG,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAKD,MAAM,KAAK,SAAS;;QAClB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAA,wBAAe,GAAE,CAAA;YAChC,MAAM,MAAM,GAAG,MAAA,MAAA,MAAA,MAAM,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CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAA;gBAC1D,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBACjC,IAAI,KAAK,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;oBAC1C,MAAK;gBACP,CAAC;gBAED,iDAAiD;gBACjD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAA;YAC5B,CAAC,QAAQ,MAAM,EAAC;YAEhB,OAAO,QAAQ,CAAA;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;;AAlRH,oBAmRC;AA5QgB,mBAAc,GAAgB,IAAI,CAAA;AAClC,oBAAe,GAAgB,IAAI,CAAA"}
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AddDnsCommandHandler = void 0;
|
|
4
4
|
const AliyunService_1 = require("../services/AliyunService");
|
|
5
5
|
const cli_1 = require("../cli");
|
|
6
|
+
const config_1 = require("../config");
|
|
6
7
|
class AddDnsCommandHandler {
|
|
7
8
|
async handle(args) {
|
|
8
|
-
var _a;
|
|
9
|
-
const
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
11
|
+
const domainName = (_a = args.dnsDomain) !== null && _a !== void 0 ? _a : (_c = (_b = config.aliyun) === null || _b === void 0 ? void 0 : _b.domain) === null || _c === void 0 ? void 0 : _c.trim();
|
|
10
12
|
if (!domainName) {
|
|
11
|
-
throw new Error('Missing domain name. Use --domain or set
|
|
13
|
+
throw new Error('Missing domain name. Use --domain or set aliyun.domain in ~/.pmate/config.yaml.');
|
|
12
14
|
}
|
|
13
15
|
await AliyunService_1.AliyunService.addRecord({
|
|
14
16
|
domainName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddDnsCommandHandler.js","sourceRoot":"","sources":["../../src/commands/AddDnsCommandHandler.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAC1D,gCAA4B;
|
|
1
|
+
{"version":3,"file":"AddDnsCommandHandler.js","sourceRoot":"","sources":["../../src/commands/AddDnsCommandHandler.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAC1D,gCAA4B;AAC5B,sCAA4C;AAE5C,MAAa,oBAAoB;IAC/B,KAAK,CAAC,MAAM,CAAC,IAAuB;;QAClC,MAAM,MAAM,GAAG,IAAA,wBAAe,GAAE,CAAC;QACjC,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,MAAM,0CAAE,IAAI,EAAE,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;QACJ,CAAC;QAED,MAAM,6BAAa,CAAC,SAAS,CAAC;YAC5B,UAAU;YACV,EAAE,EAAE,IAAI,CAAC,KAAK;YACd,IAAI,EAAE,IAAI,CAAC,OAAO;YAClB,KAAK,EAAE,IAAI,CAAC,QAAQ;YACpB,GAAG,EAAE,IAAI,CAAC,MAAM;SACjB,CAAC,CAAC;QAEH,QAAE,CAAC,OAAO,CACR,oBAAoB,IAAI,CAAC,KAAK,IAAI,UAAU,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAChF,CAAC;IACJ,CAAC;CACF;AAtBD,oDAsBC"}
|
|
@@ -7,6 +7,7 @@ const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
|
7
7
|
const node_child_process_1 = require("node:child_process");
|
|
8
8
|
const yaml_1 = tslib_1.__importDefault(require("yaml"));
|
|
9
9
|
const AliyunService_1 = require("../services/AliyunService");
|
|
10
|
+
const config_1 = require("../config");
|
|
10
11
|
class DeployCommandHandler {
|
|
11
12
|
async handle(args) {
|
|
12
13
|
const appName = args.deployApp.trim();
|
|
@@ -175,13 +176,13 @@ class DeployCommandHandler {
|
|
|
175
176
|
return `https://github.com/${trimmed}`;
|
|
176
177
|
}
|
|
177
178
|
withToken(repositoryOrUrl) {
|
|
178
|
-
var _a;
|
|
179
|
+
var _a, _b;
|
|
179
180
|
const trimmed = repositoryOrUrl.trim();
|
|
180
181
|
const repoUrl = /^https?:\/\//i.test(trimmed)
|
|
181
182
|
? trimmed
|
|
182
183
|
: `https://github.com/${trimmed.replace(/^\/+|\/+$/g, "")}`;
|
|
183
|
-
|
|
184
|
-
const token = (_a =
|
|
184
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
185
|
+
const token = (_b = (_a = config.github) === null || _a === void 0 ? void 0 : _a.token) === null || _b === void 0 ? void 0 : _b.trim();
|
|
185
186
|
if (!token) {
|
|
186
187
|
return repoUrl;
|
|
187
188
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployCommandHandler.js","sourceRoot":"","sources":["../../src/commands/DeployCommandHandler.ts"],"names":[],"mappings":";;;;AAAA,qCAAkD;AAClD,kEAA4B;AAC5B,2DAA0C;AAC1C,wDAAuB;AAQvB,6DAAyD;
|
|
1
|
+
{"version":3,"file":"DeployCommandHandler.js","sourceRoot":"","sources":["../../src/commands/DeployCommandHandler.ts"],"names":[],"mappings":";;;;AAAA,qCAAkD;AAClD,kEAA4B;AAC5B,2DAA0C;AAC1C,wDAAuB;AAQvB,6DAAyD;AACzD,sCAA2C;AAM3C,MAAa,oBAAoB;IAC/B,KAAK,CAAC,MAAM,CAAC,IAAuB;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QACrC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;QACH,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC3C,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AA;QACtC,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;YAC3C,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,sBAAsB,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,CAAA;QAC7D,MAAM,MAAM,GAAG,IAAA,wBAAe,GAAE,CAAA;QAChC,MAAM,KAAK,GAAG,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,KAAK,0CAAE,IAAI,EAAE,CAAA;QAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,WAAW,KAAK,GAAG,CAAC,CAAA;IAC7D,CAAC;CACF;AAzOD,oDAyOC"}
|
|
@@ -4,6 +4,10 @@ export declare class LinearCommandHandler {
|
|
|
4
4
|
private getCurrentPr;
|
|
5
5
|
private buildDescription;
|
|
6
6
|
private resolveTeamId;
|
|
7
|
+
private resolveLinearAccount;
|
|
8
|
+
private getLinearSelectionPath;
|
|
9
|
+
private readCachedLinearSelection;
|
|
10
|
+
private writeCachedLinearSelection;
|
|
7
11
|
private lookupIssue;
|
|
8
12
|
private lookupIssueId;
|
|
9
13
|
private extractIssueIdentifier;
|
|
@@ -11,6 +15,7 @@ export declare class LinearCommandHandler {
|
|
|
11
15
|
private fetchIssueById;
|
|
12
16
|
private printIssueDetails;
|
|
13
17
|
private collectReplInput;
|
|
18
|
+
private collectScreenshotInput;
|
|
14
19
|
private readMultiline;
|
|
15
20
|
private parseImageInput;
|
|
16
21
|
private readClipboardImage;
|
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LinearCommandHandler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_os_1 = tslib_1.__importDefault(require("node:os"));
|
|
6
8
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
9
|
const promises_1 = require("node:readline/promises");
|
|
8
10
|
const openai_1 = tslib_1.__importDefault(require("openai"));
|
|
9
11
|
const sdk_1 = require("@linear/sdk");
|
|
10
12
|
const cli_1 = require("../cli");
|
|
13
|
+
const config_1 = require("../config");
|
|
11
14
|
const ISSUE_SUMMARY_FIELDS = `
|
|
12
15
|
id
|
|
13
16
|
identifier
|
|
@@ -83,17 +86,16 @@ const ISSUE_CHILDREN_QUERY = `
|
|
|
83
86
|
`;
|
|
84
87
|
class LinearCommandHandler {
|
|
85
88
|
async handle(args) {
|
|
86
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
87
90
|
const cwd = this.resolveCwd(args.cwd);
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
throw new Error("Missing LINEAR_API_KEY in ~/.pmate/config or environment.");
|
|
91
|
-
}
|
|
92
|
-
const client = new sdk_1.LinearClient({ apiKey });
|
|
91
|
+
const account = await this.resolveLinearAccount(cwd);
|
|
92
|
+
const client = new sdk_1.LinearClient({ apiKey: account.apiKey });
|
|
93
93
|
if (args.action === "create") {
|
|
94
94
|
const teamId = await this.resolveTeamId(client, {
|
|
95
95
|
teamId: args.teamId,
|
|
96
96
|
teamKey: args.teamKey,
|
|
97
|
+
defaultTeamId: account.teamId,
|
|
98
|
+
defaultTeamKey: account.teamKey,
|
|
97
99
|
});
|
|
98
100
|
if (args.mode === "repl") {
|
|
99
101
|
const replInput = await this.collectReplInput();
|
|
@@ -119,9 +121,28 @@ class LinearCommandHandler {
|
|
|
119
121
|
cli_1.ui.success(`Created Linear issue ${issue.identifier}`, issue.url);
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
124
|
+
if (args.mode === "screenshot") {
|
|
125
|
+
const images = await this.collectScreenshotInput();
|
|
126
|
+
const ticket = await this.getAiTicketFromNotes({ text: "", images });
|
|
127
|
+
const payload = await client.createIssue({
|
|
128
|
+
teamId,
|
|
129
|
+
title: ticket.title,
|
|
130
|
+
description: ticket.description,
|
|
131
|
+
priority: args.priority,
|
|
132
|
+
parentId: args.parentId,
|
|
133
|
+
stateId: args.stateId,
|
|
134
|
+
});
|
|
135
|
+
const issue = await payload.issue;
|
|
136
|
+
if (!issue) {
|
|
137
|
+
throw new Error("Linear issue creation returned no issue.");
|
|
138
|
+
}
|
|
139
|
+
await this.attachImages(client, issue.id, images);
|
|
140
|
+
cli_1.ui.success(`Created Linear issue ${issue.identifier}`, issue.url);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
122
143
|
const payload = await client.createIssue({
|
|
123
144
|
teamId,
|
|
124
|
-
title: (
|
|
145
|
+
title: (_a = args.title) !== null && _a !== void 0 ? _a : "",
|
|
125
146
|
description: args.description,
|
|
126
147
|
priority: args.priority,
|
|
127
148
|
parentId: args.parentId,
|
|
@@ -158,14 +179,14 @@ class LinearCommandHandler {
|
|
|
158
179
|
process.exitCode = 1;
|
|
159
180
|
return;
|
|
160
181
|
}
|
|
161
|
-
const children = (
|
|
182
|
+
const children = (_c = (_b = parent.children) === null || _b === void 0 ? void 0 : _b.nodes) !== null && _c !== void 0 ? _c : [];
|
|
162
183
|
if (children.length === 0) {
|
|
163
184
|
cli_1.ui.info(`No sub-issues found for ${parent.identifier}.`);
|
|
164
185
|
return;
|
|
165
186
|
}
|
|
166
187
|
cli_1.ui.info(`Sub-issues for ${parent.identifier}: ${parent.title}`);
|
|
167
188
|
for (const child of children) {
|
|
168
|
-
const stateLabel = (
|
|
189
|
+
const stateLabel = (_e = (_d = child.state) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : "Unknown state";
|
|
169
190
|
const updatedAt = new Date(child.updatedAt).toLocaleString();
|
|
170
191
|
cli_1.ui.info(`${child.identifier} | ${stateLabel} | ${child.priorityLabel} | Updated: ${updatedAt}`);
|
|
171
192
|
cli_1.ui.info(` ${child.title}`);
|
|
@@ -176,7 +197,10 @@ class LinearCommandHandler {
|
|
|
176
197
|
if (args.action !== "pr") {
|
|
177
198
|
throw new Error("Missing linear action. Use linear create or linear pr.");
|
|
178
199
|
}
|
|
179
|
-
const teamId = await this.resolveTeamId(client
|
|
200
|
+
const teamId = await this.resolveTeamId(client, {
|
|
201
|
+
defaultTeamId: account.teamId,
|
|
202
|
+
defaultTeamKey: account.teamKey,
|
|
203
|
+
});
|
|
180
204
|
await this.ensureGitRepo(cwd);
|
|
181
205
|
await this.ensureGhCli();
|
|
182
206
|
await this.ensureGhAuth();
|
|
@@ -184,12 +208,12 @@ class LinearCommandHandler {
|
|
|
184
208
|
const diff = await this.getPrDiff(cwd);
|
|
185
209
|
const description = await this.getAiDescription({
|
|
186
210
|
title: pr.title,
|
|
187
|
-
body: (
|
|
211
|
+
body: (_f = pr.body) !== null && _f !== void 0 ? _f : "",
|
|
188
212
|
url: pr.url,
|
|
189
|
-
repository: (
|
|
213
|
+
repository: (_h = (_g = pr.headRepository) === null || _g === void 0 ? void 0 : _g.nameWithOwner) !== null && _h !== void 0 ? _h : "",
|
|
190
214
|
headRefName: pr.headRefName,
|
|
191
215
|
baseRefName: pr.baseRefName,
|
|
192
|
-
author: (
|
|
216
|
+
author: (_k = (_j = pr.author) === null || _j === void 0 ? void 0 : _j.login) !== null && _k !== void 0 ? _k : "",
|
|
193
217
|
diff,
|
|
194
218
|
});
|
|
195
219
|
const payload = await client.createIssue({
|
|
@@ -238,18 +262,19 @@ class LinearCommandHandler {
|
|
|
238
262
|
return lines.join("\n");
|
|
239
263
|
}
|
|
240
264
|
async resolveTeamId(client, options = {}) {
|
|
241
|
-
var _a, _b, _c, _d, _e, _f;
|
|
242
|
-
const
|
|
265
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
266
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
267
|
+
const explicitTeamId = ((_a = options.teamId) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = options.defaultTeamId) === null || _b === void 0 ? void 0 : _b.trim());
|
|
243
268
|
if (explicitTeamId) {
|
|
244
269
|
return explicitTeamId;
|
|
245
270
|
}
|
|
246
|
-
const teamId = (
|
|
271
|
+
const teamId = (_d = (_c = config.linear) === null || _c === void 0 ? void 0 : _c.teamId) === null || _d === void 0 ? void 0 : _d.trim();
|
|
247
272
|
if (teamId) {
|
|
248
273
|
return teamId;
|
|
249
274
|
}
|
|
250
|
-
const teamKey = (
|
|
275
|
+
const teamKey = (_h = (_f = (_e = options.teamKey) === null || _e === void 0 ? void 0 : _e.trim()) !== null && _f !== void 0 ? _f : (_g = options.defaultTeamKey) === null || _g === void 0 ? void 0 : _g.trim()) !== null && _h !== void 0 ? _h : (_k = (_j = config.linear) === null || _j === void 0 ? void 0 : _j.teamKey) === null || _k === void 0 ? void 0 : _k.trim();
|
|
251
276
|
const teams = await client.teams();
|
|
252
|
-
const nodes = (
|
|
277
|
+
const nodes = (_l = teams.nodes) !== null && _l !== void 0 ? _l : [];
|
|
253
278
|
if (nodes.length === 0) {
|
|
254
279
|
throw new Error("No Linear teams available for this account.");
|
|
255
280
|
}
|
|
@@ -257,14 +282,108 @@ class LinearCommandHandler {
|
|
|
257
282
|
const match = nodes.find((team) => team.key.toLowerCase() === teamKey.toLowerCase() ||
|
|
258
283
|
team.name.toLowerCase() === teamKey.toLowerCase());
|
|
259
284
|
if (!match) {
|
|
260
|
-
throw new Error(`No Linear team found for
|
|
285
|
+
throw new Error(`No Linear team found for linear.teamKey=${teamKey}.`);
|
|
261
286
|
}
|
|
262
287
|
return match.id;
|
|
263
288
|
}
|
|
264
289
|
if (nodes.length === 1) {
|
|
265
290
|
return nodes[0].id;
|
|
266
291
|
}
|
|
267
|
-
throw new Error("Multiple Linear teams found.
|
|
292
|
+
throw new Error("Multiple Linear teams found. Use --team-id/--team-key, set linear.teamId/linear.teamKey in ~/.pmate/config.yaml, or set teamId/teamKey on the selected linear account.");
|
|
293
|
+
}
|
|
294
|
+
async resolveLinearAccount(cwd) {
|
|
295
|
+
var _a, _b;
|
|
296
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
297
|
+
const accounts = (_b = (_a = config.linear) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
|
|
298
|
+
if (accounts.length === 0) {
|
|
299
|
+
throw new Error("Missing Linear config. Add linear.accounts to ~/.pmate/config.yaml.");
|
|
300
|
+
}
|
|
301
|
+
const titles = accounts.map((account) => account.title);
|
|
302
|
+
const normalized = titles.map((title) => title.toLowerCase());
|
|
303
|
+
const unique = new Set(normalized);
|
|
304
|
+
if (unique.size !== normalized.length) {
|
|
305
|
+
throw new Error("Duplicate Linear account titles in ~/.pmate/config.yaml. Each linear entry must have a unique title.");
|
|
306
|
+
}
|
|
307
|
+
if (accounts.length === 1) {
|
|
308
|
+
return accounts[0];
|
|
309
|
+
}
|
|
310
|
+
const cached = this.readCachedLinearSelection(cwd);
|
|
311
|
+
if (cached) {
|
|
312
|
+
const index = normalized.indexOf(cached.toLowerCase());
|
|
313
|
+
if (index >= 0) {
|
|
314
|
+
return accounts[index];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const rl = (0, promises_1.createInterface)({
|
|
318
|
+
input: process.stdin,
|
|
319
|
+
output: process.stdout,
|
|
320
|
+
});
|
|
321
|
+
try {
|
|
322
|
+
cli_1.ui.title("Select Linear account:");
|
|
323
|
+
accounts.forEach((account, index) => {
|
|
324
|
+
cli_1.ui.plain(`${index + 1}) ${account.title}`);
|
|
325
|
+
});
|
|
326
|
+
while (true) {
|
|
327
|
+
const answer = (await rl.question(`Select account (1-${accounts.length}): `))
|
|
328
|
+
.trim()
|
|
329
|
+
.toLowerCase();
|
|
330
|
+
const index = Number.parseInt(answer, 10);
|
|
331
|
+
if (Number.isFinite(index) && index >= 1 && index <= accounts.length) {
|
|
332
|
+
const account = accounts[index - 1];
|
|
333
|
+
this.writeCachedLinearSelection(cwd, account.title);
|
|
334
|
+
return account;
|
|
335
|
+
}
|
|
336
|
+
const titleIndex = normalized.indexOf(answer);
|
|
337
|
+
if (titleIndex >= 0) {
|
|
338
|
+
const account = accounts[titleIndex];
|
|
339
|
+
this.writeCachedLinearSelection(cwd, account.title);
|
|
340
|
+
return account;
|
|
341
|
+
}
|
|
342
|
+
cli_1.ui.warn("Please choose a valid account number or title.");
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
rl.close();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
getLinearSelectionPath() {
|
|
350
|
+
return node_path_1.default.join(node_os_1.default.homedir(), ".pmate", "linear-selection.json");
|
|
351
|
+
}
|
|
352
|
+
readCachedLinearSelection(cwd) {
|
|
353
|
+
const selectionPath = this.getLinearSelectionPath();
|
|
354
|
+
if (!(0, node_fs_1.existsSync)(selectionPath)) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
const raw = (0, node_fs_1.readFileSync)(selectionPath, "utf8").trim();
|
|
359
|
+
if (!raw)
|
|
360
|
+
return undefined;
|
|
361
|
+
const parsed = JSON.parse(raw);
|
|
362
|
+
const value = parsed[cwd];
|
|
363
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
364
|
+
}
|
|
365
|
+
catch {
|
|
366
|
+
return undefined;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
writeCachedLinearSelection(cwd, title) {
|
|
370
|
+
const selectionPath = this.getLinearSelectionPath();
|
|
371
|
+
const dir = node_path_1.default.dirname(selectionPath);
|
|
372
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
373
|
+
let data = {};
|
|
374
|
+
if ((0, node_fs_1.existsSync)(selectionPath)) {
|
|
375
|
+
try {
|
|
376
|
+
const raw = (0, node_fs_1.readFileSync)(selectionPath, "utf8").trim();
|
|
377
|
+
if (raw) {
|
|
378
|
+
data = JSON.parse(raw);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
data = {};
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
data[cwd] = title;
|
|
386
|
+
(0, node_fs_1.writeFileSync)(selectionPath, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
268
387
|
}
|
|
269
388
|
async lookupIssue(client, issueRef) {
|
|
270
389
|
const identifier = this.extractIssueIdentifier(issueRef);
|
|
@@ -369,6 +488,21 @@ class LinearCommandHandler {
|
|
|
369
488
|
}
|
|
370
489
|
return { text, images };
|
|
371
490
|
}
|
|
491
|
+
async collectScreenshotInput() {
|
|
492
|
+
cli_1.ui.info("Copy a screenshot to your clipboard, then press Enter.");
|
|
493
|
+
const rl = (0, promises_1.createInterface)({
|
|
494
|
+
input: process.stdin,
|
|
495
|
+
output: process.stdout,
|
|
496
|
+
});
|
|
497
|
+
try {
|
|
498
|
+
await rl.question("Press Enter when ready: ");
|
|
499
|
+
}
|
|
500
|
+
finally {
|
|
501
|
+
rl.close();
|
|
502
|
+
}
|
|
503
|
+
const image = await this.readClipboardImage(1);
|
|
504
|
+
return [image];
|
|
505
|
+
}
|
|
372
506
|
async readMultiline(rl, prompt) {
|
|
373
507
|
cli_1.ui.info(prompt);
|
|
374
508
|
const lines = [];
|
|
@@ -741,12 +875,13 @@ class LinearCommandHandler {
|
|
|
741
875
|
return value ? node_path_1.default.resolve(process.cwd(), value) : process.cwd();
|
|
742
876
|
}
|
|
743
877
|
createOpenAiClient() {
|
|
744
|
-
var _a, _b;
|
|
745
|
-
const
|
|
878
|
+
var _a, _b, _c, _d;
|
|
879
|
+
const config = (0, config_1.loadPmateConfig)();
|
|
880
|
+
const apiKey = (_b = (_a = config.openAI) === null || _a === void 0 ? void 0 : _a.apiKey) === null || _b === void 0 ? void 0 : _b.trim();
|
|
746
881
|
if (!apiKey) {
|
|
747
|
-
throw new Error("Missing
|
|
882
|
+
throw new Error("Missing openAI.apiKey in ~/.pmate/config.yaml.");
|
|
748
883
|
}
|
|
749
|
-
const baseUrl = (
|
|
884
|
+
const baseUrl = (_d = (_c = config.openAI) === null || _c === void 0 ? void 0 : _c.baseUrl) === null || _d === void 0 ? void 0 : _d.trim();
|
|
750
885
|
return new openai_1.default({
|
|
751
886
|
apiKey,
|
|
752
887
|
baseURL: baseUrl ? `${baseUrl}/v1` : undefined,
|