@pragma-sh/junie-plugin 0.1.0-alpha.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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "pragma-junie",
3
+ "version": "0.0.0",
4
+ "description": "Reports Junie CLI agent status (running / done / attention) to Pragma automatically.",
5
+ "author": {
6
+ "name": "Pragma"
7
+ }
8
+ }
@@ -0,0 +1,17 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2506_1549)">
3
+ <g clip-path="url(#clip1_2506_1549)">
4
+ <path d="M21 11.0001L31 11V12.6638C31 24.3042 25.9621 31 12.6638 31H11V21H12.6638C18.4811 21 21 18.4749 21 12.6576V11.0001Z" fill="#48E054"/>
5
+ <path d="M11 11H1V21H11V11Z" fill="#48E054"/>
6
+ <path d="M21 1H11V11H21V1Z" fill="#48E054"/>
7
+ </g>
8
+ </g>
9
+ <defs>
10
+ <clipPath id="clip0_2506_1549">
11
+ <rect width="32" height="32" fill="white"/>
12
+ </clipPath>
13
+ <clipPath id="clip1_2506_1549">
14
+ <rect width="32" height="32" fill="white"/>
15
+ </clipPath>
16
+ </defs>
17
+ </svg>
@@ -0,0 +1,61 @@
1
+ // scripts/install-local.ts
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ var JUNIE_HOME = process.env.JUNIE_HOME ?? join(homedir(), ".junie");
7
+ var CONFIG_PATH = join(JUNIE_HOME, "config.json");
8
+ var HOOK_SCRIPT_MARKER = join("packages", "junie-plugin", "hooks", "report.sh");
9
+ var root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
10
+ var template = readFileSync(join(root, "hooks", "hooks.json"), "utf8");
11
+ var ours = JSON.parse(template.replaceAll("${JUNIE_PLUGIN_ROOT}", root)).hooks;
12
+ if (ours === undefined) {
13
+ throw new Error("hooks/hooks.json has no `hooks` object");
14
+ }
15
+ var existing = readConfig(CONFIG_PATH);
16
+ var installed = { ...existing, hooks: mergeHooks(existing.hooks ?? {}, ours, root) };
17
+ mkdirSync(JUNIE_HOME, { recursive: true });
18
+ writeFileSync(CONFIG_PATH, `${JSON.stringify(installed, null, 2)}
19
+ `);
20
+ process.stdout.write(`Installed the Pragma Junie hooks into ${CONFIG_PATH}
21
+ `);
22
+ process.stdout.write(`They run \`${join(root, "hooks", "report.sh")}\`.
23
+ `);
24
+ process.stdout.write(`Start a new Junie session to load them.
25
+ `);
26
+ function readConfig(path) {
27
+ if (!existsSync(path)) {
28
+ return {};
29
+ }
30
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
31
+ if (!isPlainObject(parsed)) {
32
+ throw new Error(`${path} is not a JSON object`);
33
+ }
34
+ return parsed;
35
+ }
36
+ function mergeHooks(existingHooks, ownHooks, pluginRoot) {
37
+ const merged = dropOwnEntries(existingHooks, pluginRoot);
38
+ for (const [event, entries] of Object.entries(ownHooks)) {
39
+ merged[event] = [...merged[event] ?? [], ...entries];
40
+ }
41
+ return merged;
42
+ }
43
+ function dropOwnEntries(existingHooks, pluginRoot) {
44
+ const merged = {};
45
+ for (const [event, entries] of Object.entries(existingHooks)) {
46
+ const kept = entries.filter((entry) => !isOwnEntry(entry, pluginRoot));
47
+ if (kept.length > 0) {
48
+ merged[event] = kept;
49
+ }
50
+ }
51
+ return merged;
52
+ }
53
+ function isOwnEntry(entry, pluginRoot) {
54
+ return (entry.hooks ?? []).some((hook) => {
55
+ const command = hook.command ?? "";
56
+ return command.includes(pluginRoot) || command.includes(HOOK_SCRIPT_MARKER);
57
+ });
58
+ }
59
+ function isPlainObject(value) {
60
+ return typeof value === "object" && value !== null && !Array.isArray(value);
61
+ }