@alasano/pi-linear 0.1.0 → 0.1.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/extensions/index.ts
CHANGED
package/extensions/settings.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import type { ExtensionAPI, ExtensionContext } from '@mariozechner/pi-coding-agent';
|
|
4
4
|
import { getAgentDir, getSettingsListTheme } from '@mariozechner/pi-coding-agent';
|
|
@@ -172,12 +172,9 @@ function createDefaultSettings(): ToolSettings {
|
|
|
172
172
|
return { disabledTools: [] };
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
function loadSettings(): ToolSettings {
|
|
176
|
-
if (!existsSync(SETTINGS_PATH)) {
|
|
177
|
-
return createDefaultSettings();
|
|
178
|
-
}
|
|
175
|
+
async function loadSettings(): Promise<ToolSettings> {
|
|
179
176
|
try {
|
|
180
|
-
const raw = JSON.parse(
|
|
177
|
+
const raw = JSON.parse(await fs.readFile(SETTINGS_PATH, 'utf8'));
|
|
181
178
|
if (!raw || typeof raw !== 'object' || !Array.isArray(raw.disabledTools)) {
|
|
182
179
|
return createDefaultSettings();
|
|
183
180
|
}
|
|
@@ -189,10 +186,10 @@ function loadSettings(): ToolSettings {
|
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
188
|
|
|
192
|
-
function saveSettings(settings: ToolSettings): boolean {
|
|
189
|
+
async function saveSettings(settings: ToolSettings): Promise<boolean> {
|
|
193
190
|
try {
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
await fs.mkdir(dirname(SETTINGS_PATH), { recursive: true });
|
|
192
|
+
await fs.writeFile(SETTINGS_PATH, `${JSON.stringify(settings, null, 2)}\n`, 'utf8');
|
|
196
193
|
return true;
|
|
197
194
|
} catch {
|
|
198
195
|
return false;
|
|
@@ -320,7 +317,7 @@ async function showToolSettingsOverlay(
|
|
|
320
317
|
items,
|
|
321
318
|
maxVisibleItems,
|
|
322
319
|
settingsTheme,
|
|
323
|
-
(id, newValue) => {
|
|
320
|
+
async (id, newValue) => {
|
|
324
321
|
const nextEnabled = newValue === '[x]';
|
|
325
322
|
|
|
326
323
|
if (id.startsWith('category:')) {
|
|
@@ -354,7 +351,7 @@ async function showToolSettingsOverlay(
|
|
|
354
351
|
}
|
|
355
352
|
}
|
|
356
353
|
|
|
357
|
-
saveSettings(settings);
|
|
354
|
+
await saveSettings(settings);
|
|
358
355
|
applySettings(pi, settings);
|
|
359
356
|
},
|
|
360
357
|
() => done(undefined),
|
|
@@ -392,24 +389,24 @@ async function showToolSettingsOverlay(
|
|
|
392
389
|
);
|
|
393
390
|
}
|
|
394
391
|
|
|
395
|
-
export function registerLinearSettings(pi: ExtensionAPI): void {
|
|
396
|
-
let settings = loadSettings();
|
|
392
|
+
export async function registerLinearSettings(pi: ExtensionAPI): Promise<void> {
|
|
393
|
+
let settings = await loadSettings();
|
|
397
394
|
|
|
398
395
|
pi.registerCommand('linear-settings', {
|
|
399
396
|
description: 'Open Linear tool settings',
|
|
400
397
|
handler: async (_args, ctx) => {
|
|
401
|
-
settings = loadSettings();
|
|
398
|
+
settings = await loadSettings();
|
|
402
399
|
await showToolSettingsOverlay(pi, ctx, settings);
|
|
403
400
|
},
|
|
404
401
|
});
|
|
405
402
|
|
|
406
403
|
pi.on('session_start', async (_event, _ctx) => {
|
|
407
|
-
settings = loadSettings();
|
|
404
|
+
settings = await loadSettings();
|
|
408
405
|
applySettings(pi, settings);
|
|
409
406
|
});
|
|
410
407
|
|
|
411
408
|
pi.on('session_before_switch', async (_event, _ctx) => {
|
|
412
|
-
settings = loadSettings();
|
|
409
|
+
settings = await loadSettings();
|
|
413
410
|
applySettings(pi, settings);
|
|
414
411
|
});
|
|
415
412
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineTool } from '@mariozechner/pi-coding-agent';
|
|
2
2
|
import { Type } from '@sinclair/typebox';
|
|
3
|
-
import { withLinearAuth, linearGraphQL } from '../client';
|
|
3
|
+
import { withLinearAuth, linearGraphQL, resolveIssueId } from '../client';
|
|
4
4
|
import { PaginationParams } from '../params';
|
|
5
5
|
import { ISSUE_RELATION_SELECTION } from '../selections';
|
|
6
6
|
import type { JsonObject } from '../types';
|
|
@@ -81,8 +81,8 @@ export function issueRelationTools() {
|
|
|
81
81
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
82
82
|
return withLinearAuth(ctx, signal, async (apiKey) => {
|
|
83
83
|
const input = {
|
|
84
|
-
issueId: params.issueId,
|
|
85
|
-
relatedIssueId: params.relatedIssueId,
|
|
84
|
+
issueId: await resolveIssueId(apiKey, params.issueId, signal),
|
|
85
|
+
relatedIssueId: await resolveIssueId(apiKey, params.relatedIssueId, signal),
|
|
86
86
|
type: params.type,
|
|
87
87
|
};
|
|
88
88
|
|
|
@@ -129,10 +129,17 @@ export function issueRelationTools() {
|
|
|
129
129
|
}),
|
|
130
130
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
131
131
|
return withLinearAuth(ctx, signal, async (apiKey) => {
|
|
132
|
+
const [resolvedIssueId, resolvedRelatedIssueId] = await Promise.all([
|
|
133
|
+
params.issueId ? resolveIssueId(apiKey, params.issueId, signal) : undefined,
|
|
134
|
+
params.relatedIssueId
|
|
135
|
+
? resolveIssueId(apiKey, params.relatedIssueId, signal)
|
|
136
|
+
: undefined,
|
|
137
|
+
]);
|
|
138
|
+
|
|
132
139
|
const input = compactObject({
|
|
133
140
|
type: params.type,
|
|
134
|
-
issueId:
|
|
135
|
-
relatedIssueId:
|
|
141
|
+
issueId: resolvedIssueId,
|
|
142
|
+
relatedIssueId: resolvedRelatedIssueId,
|
|
136
143
|
});
|
|
137
144
|
|
|
138
145
|
if (Object.keys(input).length === 0) {
|
|
@@ -105,7 +105,7 @@ export function projectTools() {
|
|
|
105
105
|
name: 'linear_save_project',
|
|
106
106
|
label: 'Linear Save Project',
|
|
107
107
|
description:
|
|
108
|
-
'Create or update a project.
|
|
108
|
+
'Create or update a project. Pass projectId to update an existing project; omit it to create. The id param is only for pre-setting a UUID on create.',
|
|
109
109
|
parameters: Type.Object({
|
|
110
110
|
projectId: Type.Optional(Type.String({ description: 'Project id for update mode.' })),
|
|
111
111
|
id: Type.Optional(Type.String({ description: 'ProjectCreateInput.id' })),
|