@jmcombs/pi-1password 1.0.1 → 1.0.2
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/index.ts +11 -14
- package/package.json +2 -2
- package/ui/bordered-popups.ts +2 -2
package/index.ts
CHANGED
|
@@ -13,16 +13,19 @@
|
|
|
13
13
|
* - https://pi.dev/docs/extensions
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
17
|
-
import { createBashTool, createLocalBashOperations } from "@earendil-works/pi-coding-agent";
|
|
18
|
-
import { Type, type Static } from "typebox";
|
|
19
|
-
import { promisify } from "node:util";
|
|
20
16
|
import { exec } from "node:child_process";
|
|
21
17
|
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
22
18
|
import { homedir } from "node:os";
|
|
23
19
|
import { dirname, join } from "node:path";
|
|
24
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
25
20
|
import { fileURLToPath } from "node:url";
|
|
21
|
+
import { promisify } from "node:util";
|
|
22
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
23
|
+
import {
|
|
24
|
+
createBashTool,
|
|
25
|
+
createLocalBashOperations,
|
|
26
|
+
getAgentDir,
|
|
27
|
+
} from "@earendil-works/pi-coding-agent";
|
|
28
|
+
import { type Static, Type } from "typebox";
|
|
26
29
|
|
|
27
30
|
import {
|
|
28
31
|
confirmInBorderedPopup,
|
|
@@ -133,7 +136,6 @@ async function inspectPluginIfRelevant(command: string): Promise<PluginInspectio
|
|
|
133
136
|
return { plugin: firstWord, output: (stdout || "").trim() };
|
|
134
137
|
} catch (e: unknown) {
|
|
135
138
|
const error = e as { stderr?: string; message?: string };
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
137
139
|
const msg = (error.stderr?.trim() ?? error.message) || "Unknown error";
|
|
138
140
|
return { plugin: firstWord, error: msg };
|
|
139
141
|
}
|
|
@@ -238,7 +240,6 @@ async function loadShellEnvMap(): Promise<Record<string, string>> {
|
|
|
238
240
|
const map = new Map<string, string>();
|
|
239
241
|
|
|
240
242
|
try {
|
|
241
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
242
243
|
const raw = await readFile(authPath, "utf8");
|
|
243
244
|
const parsed = JSON.parse(raw) as AuthJson;
|
|
244
245
|
|
|
@@ -298,12 +299,10 @@ async function addAuthEntry(
|
|
|
298
299
|
const authDir = getAgentDir();
|
|
299
300
|
const authPath = join(authDir, "auth.json");
|
|
300
301
|
|
|
301
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
302
302
|
await mkdir(authDir, { recursive: true });
|
|
303
303
|
|
|
304
304
|
const existing = new Map<string, unknown>();
|
|
305
305
|
try {
|
|
306
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
307
306
|
const raw = await readFile(authPath, "utf8");
|
|
308
307
|
const parsed: unknown = JSON.parse(raw);
|
|
309
308
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -328,10 +327,8 @@ async function addAuthEntry(
|
|
|
328
327
|
// Convention: single quotes around the op:// ref
|
|
329
328
|
existing.set(envVar, `!op read '${opRef}'`);
|
|
330
329
|
|
|
331
|
-
const content = JSON.stringify(Object.fromEntries(existing), null, 2)
|
|
332
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
330
|
+
const content = `${JSON.stringify(Object.fromEntries(existing), null, 2)}\n`;
|
|
333
331
|
await writeFile(authPath, content, "utf8");
|
|
334
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
335
332
|
await chmod(authPath, 0o600);
|
|
336
333
|
|
|
337
334
|
return { success: true, message: "Entry added.", path: authPath };
|
|
@@ -467,7 +464,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
467
464
|
if (info) inspections.push(info);
|
|
468
465
|
}
|
|
469
466
|
|
|
470
|
-
let report = formatOpStatus(status)
|
|
467
|
+
let report = `${formatOpStatus(status)}\n\n`;
|
|
471
468
|
|
|
472
469
|
if (inspections.length > 0) {
|
|
473
470
|
report += "Plugin configuration:\n";
|
|
@@ -601,7 +598,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
601
598
|
const itemItems = [
|
|
602
599
|
...items.map((it) => ({
|
|
603
600
|
value: it.id,
|
|
604
|
-
label: `${it.title}${it.category ?
|
|
601
|
+
label: `${it.title}${it.category ? ` — ${it.category}` : ""}`,
|
|
605
602
|
})),
|
|
606
603
|
{ value: "__cancel", label: "Cancel" },
|
|
607
604
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jmcombs/pi-1password",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "1Password integration for the Pi coding agent. Read secrets and run commands with 1Password credential injection via the op CLI.",
|
|
5
5
|
"homepage": "https://github.com/jmcombs/pi-extensions/tree/main/packages/1password",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typebox": "*"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
49
|
+
"@earendil-works/pi-coding-agent": "^0.80.2",
|
|
50
50
|
"@earendil-works/pi-tui": "*",
|
|
51
51
|
"typebox": "^1.1.37"
|
|
52
52
|
}
|
package/ui/bordered-popups.ts
CHANGED
|
@@ -70,8 +70,8 @@ export function renderBorderedBox(
|
|
|
70
70
|
truncateToWidthFn: (s: string, w: number, e?: string, pad?: boolean) => string,
|
|
71
71
|
): string[] {
|
|
72
72
|
const innerWidth = Math.max(20, width - 4);
|
|
73
|
-
const top = theme.fg("accent", "
|
|
74
|
-
const bottom = theme.fg("accent", "
|
|
73
|
+
const top = theme.fg("accent", `╭${"─".repeat(width - 2)}╮`);
|
|
74
|
+
const bottom = theme.fg("accent", `╰${"─".repeat(width - 2)}╯`);
|
|
75
75
|
|
|
76
76
|
const rawTitle = theme.fg("accent", theme.bold(title));
|
|
77
77
|
const titlePadded = truncateToWidthFn(rawTitle, innerWidth, "", true);
|