pi-oracle 0.1.5 → 0.1.7
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
CHANGED
|
@@ -12,10 +12,14 @@ Normal oracle jobs run in an isolated browser profile, not in the user’s activ
|
|
|
12
12
|
|
|
13
13
|
Status: experimental public beta, validated primarily on macOS.
|
|
14
14
|
|
|
15
|
+
Compatibility target: current lifecycle/event model in `pi` 0.65.0+.
|
|
16
|
+
This package intentionally uses the current `session_start`-based session lifecycle and does not ship backward-compatibility shims for removed extension events.
|
|
17
|
+
|
|
15
18
|
## What it does
|
|
16
19
|
|
|
17
20
|
The extension adds:
|
|
18
21
|
- `/oracle <request>`
|
|
22
|
+
- implemented as a prompt template so it keeps native pi queueing behavior during streaming and compaction
|
|
19
23
|
- `/oracle-auth`
|
|
20
24
|
- `/oracle-status [job-id]`
|
|
21
25
|
- `/oracle-cancel [job-id]`
|
|
@@ -68,7 +72,7 @@ Not promised yet:
|
|
|
68
72
|
- macOS
|
|
69
73
|
- Google Chrome installed
|
|
70
74
|
- ChatGPT already signed into a local Chrome profile
|
|
71
|
-
- `pi` installed
|
|
75
|
+
- `pi` 0.65.0 or newer installed
|
|
72
76
|
- `agent-browser` available on the machine
|
|
73
77
|
- `tar` and `zstd` available
|
|
74
78
|
|
|
@@ -5,7 +5,7 @@ import { loadOracleConfig } from "./lib/config.js";
|
|
|
5
5
|
import { registerOracleCommands } from "./lib/commands.js";
|
|
6
6
|
import { pruneTerminalOracleJobs, reconcileStaleOracleJobs } from "./lib/jobs.js";
|
|
7
7
|
import { isLockTimeoutError, withGlobalReconcileLock } from "./lib/locks.js";
|
|
8
|
-
import { refreshOracleStatus, startPoller, stopPoller
|
|
8
|
+
import { refreshOracleStatus, startPoller, stopPoller } from "./lib/poller.js";
|
|
9
9
|
import { registerOracleTools } from "./lib/tools.js";
|
|
10
10
|
|
|
11
11
|
export default function oracleExtension(pi: ExtensionAPI) {
|
|
@@ -27,8 +27,7 @@ export default function oracleExtension(pi: ExtensionAPI) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function startPollerForContext(
|
|
31
|
-
stopPollerForSession(previousSessionFile, ctx.cwd);
|
|
30
|
+
function startPollerForContext(ctx: ExtensionContext) {
|
|
32
31
|
try {
|
|
33
32
|
const config = loadOracleConfig(ctx.cwd);
|
|
34
33
|
void runStartupMaintenance(ctx).catch((error) => {
|
|
@@ -45,15 +44,7 @@ export default function oracleExtension(pi: ExtensionAPI) {
|
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
pi.on("session_start", async (_event, ctx) => {
|
|
48
|
-
startPollerForContext(
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
pi.on("session_switch", async (event, ctx) => {
|
|
52
|
-
startPollerForContext(event.previousSessionFile, ctx);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
pi.on("session_fork", async (event, ctx) => {
|
|
56
|
-
startPollerForContext(event.previousSessionFile, ctx);
|
|
47
|
+
startPollerForContext(ctx);
|
|
57
48
|
});
|
|
58
49
|
|
|
59
50
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
|
|
3
3
|
import { loadOracleConfig } from "./config.js";
|
|
4
|
-
import { buildOracleDispatchPrompt } from "./instructions.js";
|
|
5
4
|
import {
|
|
6
5
|
cancelOracleJob,
|
|
7
6
|
isActiveOracleJob,
|
|
@@ -86,25 +85,6 @@ async function runAuthBootstrap(authWorkerPath: string, cwd: string): Promise<st
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
export function registerOracleCommands(pi: ExtensionAPI, authWorkerPath: string): void {
|
|
89
|
-
pi.registerCommand("oracle", {
|
|
90
|
-
description: "Ask the agent to prepare and dispatch a ChatGPT web oracle job",
|
|
91
|
-
handler: async (args, ctx) => {
|
|
92
|
-
const request = args.trim();
|
|
93
|
-
if (!request) {
|
|
94
|
-
ctx.ui.notify("Usage: /oracle <request>", "warning");
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const message = buildOracleDispatchPrompt(request);
|
|
99
|
-
if (ctx.isIdle()) {
|
|
100
|
-
pi.sendUserMessage(message);
|
|
101
|
-
} else {
|
|
102
|
-
pi.sendUserMessage(message, { deliverAs: "followUp" });
|
|
103
|
-
ctx.ui.notify("Queued oracle preparation as a follow-up", "info");
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
88
|
pi.registerCommand("oracle-auth", {
|
|
109
89
|
description: "Sync ChatGPT cookies from real Chrome into the oracle auth seed profile",
|
|
110
90
|
handler: async (_args, ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-oracle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "ChatGPT web-oracle extension for pi with isolated browser auth, async jobs, and project-context archives.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,12 +27,16 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"extensions",
|
|
30
|
+
"prompts",
|
|
30
31
|
"README.md",
|
|
31
32
|
"LICENSE"
|
|
32
33
|
],
|
|
33
34
|
"pi": {
|
|
34
35
|
"extensions": [
|
|
35
36
|
"./extensions/oracle/index.ts"
|
|
37
|
+
],
|
|
38
|
+
"prompts": [
|
|
39
|
+
"./prompts"
|
|
36
40
|
]
|
|
37
41
|
},
|
|
38
42
|
"scripts": {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Prepare and dispatch a ChatGPT web oracle job
|
|
3
|
+
---
|
|
4
|
+
You are preparing an /oracle job.
|
|
5
|
+
|
|
6
|
+
Do not answer the user's request directly yet.
|
|
7
|
+
|
|
8
|
+
Required workflow:
|
|
9
|
+
1. Understand the request.
|
|
10
|
+
2. Gather repo context first by reading files and searching the codebase.
|
|
11
|
+
3. Select the exact relevant files/directories for the oracle archive.
|
|
12
|
+
4. Craft a concise but complete oracle prompt for ChatGPT web.
|
|
13
|
+
5. Call oracle_submit with the prompt and exact archive inputs.
|
|
14
|
+
6. Stop immediately after dispatching the oracle job.
|
|
15
|
+
|
|
16
|
+
Rules:
|
|
17
|
+
- Always include an archive. Do not submit without context files.
|
|
18
|
+
- Keep the archive narrowly scoped and relevant.
|
|
19
|
+
- Prefer the configured default model/effort unless the task clearly needs something else.
|
|
20
|
+
- Only use autoSwitchToThinking with the instant model family.
|
|
21
|
+
- If oracle_submit fails, stop and report the error. Do not retry automatically.
|
|
22
|
+
- After oracle_submit returns, end your turn. Do not keep working while the oracle runs.
|
|
23
|
+
|
|
24
|
+
User request:
|
|
25
|
+
$@
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function buildOracleDispatchPrompt(request: string): string {
|
|
2
|
-
return [
|
|
3
|
-
"You are preparing an /oracle job.",
|
|
4
|
-
"",
|
|
5
|
-
"Do not answer the user's request directly yet.",
|
|
6
|
-
"",
|
|
7
|
-
"Required workflow:",
|
|
8
|
-
"1. Understand the request.",
|
|
9
|
-
"2. Gather repo context first by reading files and searching the codebase.",
|
|
10
|
-
"3. Select the exact relevant files/directories for the oracle archive.",
|
|
11
|
-
"4. Craft a concise but complete oracle prompt for ChatGPT web.",
|
|
12
|
-
"5. Call oracle_submit with the prompt and exact archive inputs.",
|
|
13
|
-
"6. Stop immediately after dispatching the oracle job.",
|
|
14
|
-
"",
|
|
15
|
-
"Rules:",
|
|
16
|
-
"- Always include an archive. Do not submit without context files.",
|
|
17
|
-
"- Keep the archive narrowly scoped and relevant.",
|
|
18
|
-
"- Prefer the configured default model/effort unless the task clearly needs something else.",
|
|
19
|
-
"- Only use autoSwitchToThinking with the instant model family.",
|
|
20
|
-
"- If oracle_submit fails, stop and report the error. Do not retry automatically.",
|
|
21
|
-
"- After oracle_submit returns, end your turn. Do not keep working while the oracle runs.",
|
|
22
|
-
"",
|
|
23
|
-
"User request:",
|
|
24
|
-
request,
|
|
25
|
-
].join("\n");
|
|
26
|
-
}
|