ask-pro 0.1.71 → 0.2.80
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/.codex-plugin/plugin.json +1 -1
- package/README.md +27 -38
- package/SKILL.md +229 -0
- package/dist/bin/ask-pro-cli.js +10 -3
- package/dist/src/ask-pro/browserRunner.js +9 -10
- package/dist/src/browser/chromeLifecycle.js +4 -2
- package/dist/src/browser/index.js +1 -1
- package/dist/src/browser/profileMigration.js +299 -0
- package/dist/src/browser/profilePaths.js +27 -213
- package/dist/src/browser/profileState.js +29 -29
- package/dist/src/browser/reattach.js +3 -1
- package/package.json +3 -4
- package/skills/ask-pro/SKILL.md +4 -229
- package/scripts/refresh-local-plugin.mjs +0 -179
- package/scripts/refresh-local-plugin.ps1 +0 -93
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ask-pro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.80",
|
|
4
4
|
"description": "Browser-backed ChatGPT Pro escalation for hard engineering questions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dist/src/browser/liveTabs.js",
|
|
42
42
|
"dist/src/browser/modelStrategy.js",
|
|
43
43
|
"dist/src/browser/pageActions.js",
|
|
44
|
+
"dist/src/browser/profileMigration.js",
|
|
44
45
|
"dist/src/browser/profilePaths.js",
|
|
45
46
|
"dist/src/browser/profileState.js",
|
|
46
47
|
"dist/src/browser/providerDomFlow.js",
|
|
@@ -51,10 +52,9 @@
|
|
|
51
52
|
"dist/src/browser/providers/chatgptDomProvider.js",
|
|
52
53
|
"dist/src/browserMode.js",
|
|
53
54
|
"dist/src/version.js",
|
|
54
|
-
"scripts/refresh-local-plugin.mjs",
|
|
55
|
-
"scripts/refresh-local-plugin.ps1",
|
|
56
55
|
".codex-plugin/plugin.json",
|
|
57
56
|
"assets/ask-pro_logo.png",
|
|
57
|
+
"SKILL.md",
|
|
58
58
|
"skills/ask-pro/SKILL.md",
|
|
59
59
|
"README.md",
|
|
60
60
|
"LICENSE"
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"format:diff": "oxfmt --write . && git --no-pager diff",
|
|
73
73
|
"lint": "pnpm run typecheck && oxlint",
|
|
74
74
|
"lint:fix": "oxlint --fix && pnpm run format",
|
|
75
|
-
"plugin:refresh": "pnpm run build && node scripts/refresh-local-plugin.mjs",
|
|
76
75
|
"test": "pnpm run test:ask-pro",
|
|
77
76
|
"test:ask-pro": "vitest run tests/ask-pro tests/browser",
|
|
78
77
|
"test:coverage": "vitest run --coverage",
|
package/skills/ask-pro/SKILL.md
CHANGED
|
@@ -5,232 +5,7 @@ description: Escalate hard engineering questions to ChatGPT Pro through browser
|
|
|
5
5
|
|
|
6
6
|
# $ask-pro
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Trigger
|
|
13
|
-
|
|
14
|
-
Use this skill when the user explicitly asks for `$ask-pro`, or when a second opinion would materially reduce risk for:
|
|
15
|
-
|
|
16
|
-
- backend architecture
|
|
17
|
-
- schema or data migrations
|
|
18
|
-
- auth, sessions, permissions, or billing
|
|
19
|
-
- queues, workers, idempotency, caching, scaling, or latency
|
|
20
|
-
- production debugging and observability
|
|
21
|
-
- ambiguous implementation paths where a second opinion would reduce risk
|
|
22
|
-
|
|
23
|
-
Do not use it for trivial syntax fixes, formatting, obvious dependency updates, or small bugs with a clear cause.
|
|
24
|
-
|
|
25
|
-
## Critical Reminders
|
|
26
|
-
|
|
27
|
-
- Long waits are normal. ask-pro can take a super long time to run; do not
|
|
28
|
-
close or kill the browser window/run until at least 3 hours have passed unless
|
|
29
|
-
the CLI has completed, failed, or explicitly asks for human action.
|
|
30
|
-
|
|
31
|
-
## Workflow
|
|
32
|
-
|
|
33
|
-
When invoked:
|
|
34
|
-
|
|
35
|
-
1. Inspect the repo and the relevant files.
|
|
36
|
-
2. Identify the exact decision Pro should answer.
|
|
37
|
-
3. For committed code on GitHub, prefer `--github` and give Pro the repository,
|
|
38
|
-
ref, relevant paths, and question. Let it retrieve the code instead of assembling
|
|
39
|
-
a source bundle. Add a small `--files` bundle only for uncommitted changes,
|
|
40
|
-
local-only evidence, or repository content the connection cannot access.
|
|
41
|
-
4. Write the prompt yourself using the Prompt Shape below.
|
|
42
|
-
5. Run the smallest useful command: `ask-pro --github "<prompt>"` for GitHub
|
|
43
|
-
evidence, or `ask-pro --no-temporary --files "<glob>" "<prompt>"` for a file bundle.
|
|
44
|
-
For multiline prompts, write a temporary prompt file and use
|
|
45
|
-
`ask-pro --no-temporary --prompt-file <path> --files "<glob>"`; do not rely
|
|
46
|
-
on shell multiline quoting.
|
|
47
|
-
If installed through the skills CLI and `ask-pro` is not on `PATH`, install
|
|
48
|
-
the standalone CLI from the [README](https://github.com/JJLiebig/ask-pro#skills-cli-codex-and-other-supported-agents)
|
|
49
|
-
first. For Codex plugin installs without `ask-pro` on `PATH`, use the cached
|
|
50
|
-
plugin runner. Locate it under the installed plugin cache,
|
|
51
|
-
usually
|
|
52
|
-
`~/.codex/plugins/cache/<marketplace-name>/ask-pro/<version>/scripts/run-cached-cli.mjs`,
|
|
53
|
-
then call it with:
|
|
54
|
-
`node <cached-runner> -- --cwd <target-repo-root> --no-temporary --prompt-file <path> --files "<repo-relative-glob>"`.
|
|
55
|
-
On Git marketplace installs, the first cached-runner call may bootstrap the
|
|
56
|
-
content-addressed runtime under `$CODEX_HOME/plugin-runtimes/ask-pro/` by
|
|
57
|
-
installing dependencies and building `dist`; wait for that to finish. The
|
|
58
|
-
installed plugin cache stays immutable.
|
|
59
|
-
6. If auth is required, stop and ask the human to log in in the opened browser.
|
|
60
|
-
7. Read the CLI's compact `ask_pro` record and run the emitted `resume` or
|
|
61
|
-
`harvest` command when that is the next action.
|
|
62
|
-
8. Treat the answer as advisory; turn it into your own plan before editing code.
|
|
63
|
-
|
|
64
|
-
`ask-pro` selects `Latest` when available, otherwise the highest numbered available
|
|
65
|
-
GPT model, then `Pro` intelligence. Do not require a
|
|
66
|
-
different dated model label or a separate thinking-effort control in the prompt
|
|
67
|
-
or workflow.
|
|
68
|
-
|
|
69
|
-
Fresh runs try ChatGPT Temporary Chat by default and automatically fall back to
|
|
70
|
-
normal ChatGPT if the current account/UI does not expose Pro there. For repo
|
|
71
|
-
advisories, large bundles, review rounds, or anything where recovery matters,
|
|
72
|
-
prefer `--no-temporary` from the start. Add `--temporary` only when Temporary
|
|
73
|
-
Chat is required and falling back would be wrong. Temporary Chat is less
|
|
74
|
-
recoverable after browser/tab loss.
|
|
75
|
-
|
|
76
|
-
On Windows, ordinary managed Chrome runs start minimized. First login,
|
|
77
|
-
resume/recovery, and stale-auth paths stay visible or are restored for human
|
|
78
|
-
action. Local managed Chrome guards browser input while Pro is answering.
|
|
79
|
-
If login, MFA, a browser challenge, or incomplete-answer debugging needs human
|
|
80
|
-
attention, ask-pro should restore or retain the browser and emit the next
|
|
81
|
-
action.
|
|
82
|
-
|
|
83
|
-
Do not set `ASK_PRO_AGENT_ID` for ordinary or concurrent use; the shared
|
|
84
|
-
`ask-pro` browser profile under `$CODEX_HOME/state/ask-pro/` handles concurrent
|
|
85
|
-
agents automatically. Set `ASK_PRO_AGENT_ID` only when explicitly testing an
|
|
86
|
-
isolated profile or when the human requests a separate browser login. Use a
|
|
87
|
-
stable reusable lowercase id like `review-t1`, not a one-off task slug, because
|
|
88
|
-
each new id creates a new Chrome profile and may require the human to log in
|
|
89
|
-
again. Example:
|
|
90
|
-
`ASK_PRO_AGENT_ID=review-t1 ask-pro ...`.
|
|
91
|
-
|
|
92
|
-
## Prompt Shape
|
|
93
|
-
|
|
94
|
-
Assume Pro has no caller context or local checkout. Include each material fact and
|
|
95
|
-
instruction once: the goal, current state, hard constraints, evidence, success
|
|
96
|
-
criteria, and required output. Do not rely on the agent's conversation context, repo
|
|
97
|
-
folklore, prior ask-pro runs, branch names, or unstated user preferences.
|
|
98
|
-
Keep advisory design consults as plain answer requests. Start advisory prompts
|
|
99
|
-
with:
|
|
100
|
-
|
|
101
|
-
```text
|
|
102
|
-
Return final Markdown only, with no preamble or implementation package.
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
The CLI wrapper already tells Pro to read `CONTEXT.zip` and call out missing or
|
|
106
|
-
conflicting context. Do not repeat that instruction. Add task-specific output
|
|
107
|
-
requirements only when needed. For risk or review work, ask Pro to rank
|
|
108
|
-
findings by severity. For architecture or design consults, ask directly for the
|
|
109
|
-
recommendation and tradeoffs.
|
|
110
|
-
|
|
111
|
-
Use `--artifacts` only when the standard implementation package is needed. The
|
|
112
|
-
wrapper supplies the zip name, standard files, and markdown fallback; add only
|
|
113
|
-
task-specific deliverables not covered by that package. Keep advisory consults
|
|
114
|
-
inline by default.
|
|
115
|
-
Keep bundles focused: source files under review, focused tests, relevant docs,
|
|
116
|
-
known recent changes, and validation status. Avoid whole-repo bundles unless the
|
|
117
|
-
question is explicitly architectural.
|
|
118
|
-
|
|
119
|
-
## Connected GitHub (optional)
|
|
120
|
-
|
|
121
|
-
Prefer `--github` for remote repository evidence. It checks
|
|
122
|
-
the connection before uploading or submitting, and defaults to normal ChatGPT.
|
|
123
|
-
Do not require GitHub for file-based consults. Availability varies by account,
|
|
124
|
-
workspace, model, and ChatGPT experience.
|
|
125
|
-
|
|
126
|
-
If the CLI returns `needs_github_connection` / `connect_github_then_resume`,
|
|
127
|
-
direct the human to the opened GitHub page in ask-pro's browser. They install the
|
|
128
|
-
plugin if needed, complete sign-in, review permissions, and select repositories;
|
|
129
|
-
organization approval may be needed. Wait for them to finish, then run the
|
|
130
|
-
emitted resume command without adding `--github`. The requirement is saved with
|
|
131
|
-
the session and checked again. Do not start a second session or submit through
|
|
132
|
-
the browser yourself. Never collect GitHub credentials or automate authorization.
|
|
133
|
-
|
|
134
|
-
If available, GitHub's **Allow read actions** permission can avoid read approval
|
|
135
|
-
prompts. The human chooses that setting. It controls approval behavior, not the
|
|
136
|
-
underlying permissions of a write-capable app; see
|
|
137
|
-
[app permissions](https://help.openai.com/en/articles/20001495-managing-app-permissions-in-chatgpt).
|
|
138
|
-
The live GitHub plugin advertises write capabilities despite the Help Center's
|
|
139
|
-
read-only description. `--github` requests read-only work; it does not restrict
|
|
140
|
-
the provider's permissions or prove that writes are impossible.
|
|
141
|
-
|
|
142
|
-
If GitHub is already connected, proceed without a setup question or source-file
|
|
143
|
-
bundle. For the consult, name the repository (`owner/repo`), relevant paths, and
|
|
144
|
-
requested branch or commit in the prompt. Explicitly ask Pro
|
|
145
|
-
to answer the specific question. The wrapper requests the connected GitHub app,
|
|
146
|
-
read-only work, citations, the revision inspected, and access gaps. Do not
|
|
147
|
-
infer repository access from ChatGPT login or a successful CLI exit.
|
|
148
|
-
|
|
149
|
-
Keep `--files` for local/uncommitted changes, non-GitHub evidence, and snapshots
|
|
150
|
-
that the app cannot retrieve. Distinguish
|
|
151
|
-
uploaded evidence from GitHub evidence, and ask Pro to flag revision conflicts.
|
|
152
|
-
If the app or requested revision is unavailable, offer a new consult with a
|
|
153
|
-
focused file bundle and
|
|
154
|
-
disclose that limitation. Do not silently switch away from Pro. The CLI submits
|
|
155
|
-
text; it does not select an app in the composer or handle app approval prompts.
|
|
156
|
-
Until a live run demonstrates retrieval, describe this as an available setup
|
|
157
|
-
path, not a verified connection. Confirm material claims against the repo.
|
|
158
|
-
|
|
159
|
-
## Output
|
|
160
|
-
|
|
161
|
-
Normal `ask-pro` stdout is compact TOON-style telemetry. Use `state`, `action`,
|
|
162
|
-
`resume`, and `harvest` to decide the next command. Browser progress may appear
|
|
163
|
-
on stderr and can be ignored unless diagnosing a stuck run.
|
|
164
|
-
|
|
165
|
-
`AWAITING_ANSWERS` / `answer_questions` means Pro is asking native interactive
|
|
166
|
-
questions. Read the printed questions/options or `QUESTIONS.json`, answer from
|
|
167
|
-
the caller's context, and ask the human only for decisions you cannot infer.
|
|
168
|
-
Write UTF-8 JSON `{"requestId":"<request_id>","answers":[2,3,"free text"]}`
|
|
169
|
-
with one answer per question in order, then run the emitted
|
|
170
|
-
`ask-pro --resume <session-id> --answers <answers.json>` command. Numbers select
|
|
171
|
-
1-based choices; strings enter the native free-text field. `--answers -` accepts
|
|
172
|
-
piped JSON. Do not submit defaults or treat the question preamble as the answer.
|
|
173
|
-
Repeat for further question rounds, then harvest the final answer normally.
|
|
174
|
-
|
|
175
|
-
When present, use `profile`, `profile_path`, `chrome`, and `language` only as
|
|
176
|
-
diagnostic hints. They tell you whether the run used the shared profile, an
|
|
177
|
-
isolated agent profile, saved DevTools state, and English browser steering.
|
|
178
|
-
When present, `conversation_url` is a recoverable non-temporary ChatGPT
|
|
179
|
-
conversation URL.
|
|
180
|
-
|
|
181
|
-
`ask-pro --harvest <session-id>` prints the raw markdown answer only for
|
|
182
|
-
answer-bearing states such as `COMPLETED` or `HARVESTED`.
|
|
183
|
-
For pending/incomplete sessions it prints compact status/action instead. For
|
|
184
|
-
sessions run with `--artifacts`, any provided `ask-pro-response.zip` is
|
|
185
|
-
extracted under the session's `pro-output/` directory and described in
|
|
186
|
-
`PRO_OUTPUT_MANIFEST.json`. Inline-default sessions should not expect a zip.
|
|
187
|
-
|
|
188
|
-
`INCOMPLETE_ANSWER` / `stopped_without_answer` means ChatGPT stopped without
|
|
189
|
-
an answer after ask-pro attempted one automatic `continue`. Present the caller
|
|
190
|
-
with the emitted resume command or a full retry of the original request in a new
|
|
191
|
-
chat, and wait for their choice. Do not automatically resume or retry this state.
|
|
192
|
-
An explicit `--resume` allows one more continuation attempt.
|
|
193
|
-
|
|
194
|
-
`COMPLETED` means harvest now; the run browser may already be closed. If the
|
|
195
|
-
state is `INCOMPLETE_ANSWER` / `preamble_without_artifacts`, do not treat
|
|
196
|
-
`ANSWER.md` as final. Try resume/harvest if recoverable; otherwise rerun with
|
|
197
|
-
`--no-temporary`, a tighter bundle, and a more direct prompt.
|
|
198
|
-
|
|
199
|
-
## Commands
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
ask-pro "Review the async billing webhook migration plan and return an implementation plan."
|
|
203
|
-
ask-pro --no-temporary --prompt-file question.md --files src --files tests
|
|
204
|
-
ask-pro --github "In owner/repo at <commit>, inspect src/auth and explain token validation."
|
|
205
|
-
ask-pro --temporary "Review this sensitive migration plan, and fail if Temporary Chat cannot use Pro."
|
|
206
|
-
ask-pro --no-temporary "Review this in normal ChatGPT instead of Temporary Chat."
|
|
207
|
-
ask-pro --prompt-file question.md --files .\src
|
|
208
|
-
ask-pro --artifacts --prompt-file implementation-plan.md --files src
|
|
209
|
-
ask-pro --files "src/api/stripe/**" --files "prisma/**" --files "src/lib/billing/**" \
|
|
210
|
-
"Review whether this Stripe webhook flow should use a queue or transactional outbox."
|
|
211
|
-
ask-pro --dry-run "Prepare the Pro handoff but do not open the browser."
|
|
212
|
-
ask-pro --resume <session-id>
|
|
213
|
-
ask-pro --harvest <session-id>
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
If the binary is not on `PATH`, skills CLI installs need the standalone CLI from
|
|
217
|
-
the README. Codex plugin installs can use the cached plugin runner. Do not run
|
|
218
|
-
the plugin from a mutable development checkout; it may contain in-flight changes
|
|
219
|
-
that have not been synced for agents.
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
node <cached-runner> -- --cwd /path/to/repo --no-temporary --prompt-file question.md --files src
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
In cached-runner fallback mode, `--files` must be inside `--cwd`. Use
|
|
226
|
-
repo-relative `--files`; do not point at files outside the target repo cwd.
|
|
227
|
-
|
|
228
|
-
## Safety
|
|
229
|
-
|
|
230
|
-
Never ask for, read, store, type, or log passwords, MFA codes, recovery codes, session cookies, or raw auth tokens.
|
|
231
|
-
|
|
232
|
-
Browser auth is human-controlled. Continue only after the human says the ChatGPT composer is visible.
|
|
233
|
-
|
|
234
|
-
After submit, avoid interacting with any retained Chrome run window while Pro is
|
|
235
|
-
thinking. ask-pro guards input after submit, but the safest agent behavior is to
|
|
236
|
-
let the run finish or resume/harvest from CLI telemetry.
|
|
8
|
+
This is the Codex plugin entry for ask-pro. The full instructions are in
|
|
9
|
+
`SKILL.md` at the plugin root, two folders above this file. Read that file and
|
|
10
|
+
follow it. Its `<skill-folder>` is the plugin root, so the launcher is
|
|
11
|
+
`node <plugin-root>/scripts/ask-pro.mjs`.
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
const args = parseArgs(process.argv.slice(2));
|
|
8
|
-
const pluginName = args.pluginName ?? "ask-pro";
|
|
9
|
-
const codexHome = args.codexHome ?? process.env.CODEX_HOME ?? path.join(os.homedir(), ".codex");
|
|
10
|
-
const marketplacePath = args.marketplacePath ?? (await findCodexMarketplace(codexHome, pluginName));
|
|
11
|
-
|
|
12
|
-
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
const repoRoot = path.resolve(scriptDir, "..");
|
|
14
|
-
const marketplaceFile = path.resolve(marketplacePath);
|
|
15
|
-
const marketplace = JSON.parse(await fs.readFile(marketplaceFile, "utf8"));
|
|
16
|
-
const marketplaceName = String(marketplace.name ?? "").trim();
|
|
17
|
-
if (!marketplaceName) {
|
|
18
|
-
throw new Error("Marketplace file must include a top-level name.");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const plugin = Array.isArray(marketplace.plugins)
|
|
22
|
-
? marketplace.plugins.find((entry) => entry?.name === pluginName)
|
|
23
|
-
: null;
|
|
24
|
-
if (!plugin) {
|
|
25
|
-
throw new Error(`Plugin '${pluginName}' was not found in ${marketplaceFile}.`);
|
|
26
|
-
}
|
|
27
|
-
if (plugin.source?.source === "local") {
|
|
28
|
-
const configuredSourcePath = plugin.source?.path;
|
|
29
|
-
if (typeof configuredSourcePath !== "string" || !configuredSourcePath.trim()) {
|
|
30
|
-
throw new Error(`Plugin '${pluginName}' local source must include a path.`);
|
|
31
|
-
}
|
|
32
|
-
const configuredSourceRoot = resolveConfiguredSourceRoot(configuredSourcePath, marketplaceFile);
|
|
33
|
-
if (!samePath(configuredSourceRoot, repoRoot)) {
|
|
34
|
-
throw new Error(
|
|
35
|
-
`Plugin '${pluginName}' marketplace path resolves to ${configuredSourceRoot}, not this checkout ${repoRoot}.`,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
} else if (plugin.source?.source !== "url") {
|
|
39
|
-
throw new Error(`Plugin '${pluginName}' must come from a local or URL marketplace source.`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const manifestPath = path.join(repoRoot, ".codex-plugin", "plugin.json");
|
|
43
|
-
const manifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
|
|
44
|
-
if (manifest.name !== pluginName) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Plugin manifest name '${manifest.name}' does not match requested plugin '${pluginName}'.`,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const cacheRoot = path.resolve(codexHome, "plugins", "cache");
|
|
51
|
-
const pluginCacheRoot = path.resolve(cacheRoot, marketplaceName, pluginName);
|
|
52
|
-
const cacheVersion = plugin.source?.source === "local" ? "local" : manifest.version;
|
|
53
|
-
if (typeof cacheVersion !== "string" || !cacheVersion.trim()) {
|
|
54
|
-
throw new Error(`Plugin '${pluginName}' manifest must include a version.`);
|
|
55
|
-
}
|
|
56
|
-
const targetRoot = path.resolve(pluginCacheRoot, cacheVersion);
|
|
57
|
-
assertInside(
|
|
58
|
-
pluginCacheRoot,
|
|
59
|
-
cacheRoot,
|
|
60
|
-
"Resolved plugin cache path is outside Codex plugin cache",
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const requiredDistEntry = path.join(repoRoot, "dist", "bin", "ask-pro-cli.js");
|
|
64
|
-
if (!(await exists(requiredDistEntry))) {
|
|
65
|
-
throw new Error("dist is missing. Run `pnpm run build` before refreshing the plugin cache.");
|
|
66
|
-
}
|
|
67
|
-
const repoNodeModules = path.join(repoRoot, "node_modules");
|
|
68
|
-
if (!(await exists(repoNodeModules))) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
"node_modules is missing. Run `pnpm install` before refreshing the plugin cache.",
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
await removeNodeModulesLink(path.join(targetRoot, "node_modules"));
|
|
75
|
-
await fs.rm(targetRoot, { recursive: true, force: true });
|
|
76
|
-
await fs.mkdir(targetRoot, { recursive: true });
|
|
77
|
-
|
|
78
|
-
for (const item of [
|
|
79
|
-
".codex-plugin",
|
|
80
|
-
"assets",
|
|
81
|
-
"skills",
|
|
82
|
-
"references",
|
|
83
|
-
"README.md",
|
|
84
|
-
"LICENSE",
|
|
85
|
-
"package.json",
|
|
86
|
-
"pnpm-lock.yaml",
|
|
87
|
-
"pnpm-workspace.yaml",
|
|
88
|
-
"dist",
|
|
89
|
-
]) {
|
|
90
|
-
const source = path.join(repoRoot, item);
|
|
91
|
-
if (!(await exists(source))) continue;
|
|
92
|
-
await fs.cp(source, path.join(targetRoot, item), { recursive: true, force: true });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
await fs.mkdir(path.join(targetRoot, "scripts"), { recursive: true });
|
|
96
|
-
await fs.cp(
|
|
97
|
-
path.join(repoRoot, "scripts", "run-cached-cli.mjs"),
|
|
98
|
-
path.join(targetRoot, "scripts", "run-cached-cli.mjs"),
|
|
99
|
-
{ force: true },
|
|
100
|
-
);
|
|
101
|
-
await fs.symlink(repoNodeModules, path.join(targetRoot, "node_modules"), "junction");
|
|
102
|
-
|
|
103
|
-
console.log("Refreshed local Codex plugin cache:");
|
|
104
|
-
console.log(` source: ${repoRoot}`);
|
|
105
|
-
console.log(` target: ${targetRoot}`);
|
|
106
|
-
console.log("");
|
|
107
|
-
console.log("Restart or reload Codex to pick up refreshed plugin skills.");
|
|
108
|
-
|
|
109
|
-
function parseArgs(argv) {
|
|
110
|
-
const result = {};
|
|
111
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
112
|
-
const arg = argv[i];
|
|
113
|
-
const value = argv[i + 1];
|
|
114
|
-
if (!arg.startsWith("--") || !value || value.startsWith("--")) {
|
|
115
|
-
throw new Error(`Expected --name value argument, got '${arg}'.`);
|
|
116
|
-
}
|
|
117
|
-
i += 1;
|
|
118
|
-
if (arg === "--marketplace-path") result.marketplacePath = value;
|
|
119
|
-
else if (arg === "--codex-home") result.codexHome = value;
|
|
120
|
-
else if (arg === "--plugin-name") result.pluginName = value;
|
|
121
|
-
else throw new Error(`Unknown argument '${arg}'.`);
|
|
122
|
-
}
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function assertInside(child, parent, message) {
|
|
127
|
-
const relative = path.relative(parent, child);
|
|
128
|
-
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
129
|
-
throw new Error(`${message}: ${child}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function exists(filePath) {
|
|
134
|
-
try {
|
|
135
|
-
await fs.access(filePath);
|
|
136
|
-
return true;
|
|
137
|
-
} catch {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async function removeNodeModulesLink(filePath) {
|
|
143
|
-
try {
|
|
144
|
-
const stat = await fs.lstat(filePath);
|
|
145
|
-
if (stat.isSymbolicLink()) {
|
|
146
|
-
await fs.unlink(filePath);
|
|
147
|
-
}
|
|
148
|
-
} catch {
|
|
149
|
-
// Missing or non-removable links are handled by the full target cleanup.
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async function findCodexMarketplace(codexHome, pluginName) {
|
|
154
|
-
const codexMarketplace = path.join(
|
|
155
|
-
codexHome,
|
|
156
|
-
".tmp",
|
|
157
|
-
"marketplaces",
|
|
158
|
-
pluginName,
|
|
159
|
-
".agents",
|
|
160
|
-
"plugins",
|
|
161
|
-
"marketplace.json",
|
|
162
|
-
);
|
|
163
|
-
if (await exists(codexMarketplace)) return codexMarketplace;
|
|
164
|
-
return path.join(os.homedir(), ".agents", "plugins", "marketplace.json");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function resolveConfiguredSourceRoot(sourcePath, marketplaceFile) {
|
|
168
|
-
const candidates = [
|
|
169
|
-
path.resolve(path.dirname(marketplaceFile), sourcePath),
|
|
170
|
-
path.resolve(os.homedir(), sourcePath),
|
|
171
|
-
];
|
|
172
|
-
return candidates.find((candidate) => samePath(candidate, repoRoot)) ?? candidates[0];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function samePath(left, right) {
|
|
176
|
-
const a = path.resolve(left);
|
|
177
|
-
const b = path.resolve(right);
|
|
178
|
-
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
179
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[string]$MarketplacePath = "",
|
|
3
|
-
[string]$CodexHome = $(if ($env:CODEX_HOME) { $env:CODEX_HOME } else { "$HOME/.codex" }),
|
|
4
|
-
[string]$PluginName = "ask-pro"
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
$ErrorActionPreference = "Stop"
|
|
8
|
-
|
|
9
|
-
function Resolve-StrictPath([string]$Path) {
|
|
10
|
-
return [System.IO.Path]::GetFullPath((Resolve-Path -LiteralPath $Path).Path)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function Join-And-Normalize([string]$Base, [string[]]$Parts) {
|
|
14
|
-
return [System.IO.Path]::GetFullPath((Join-Path -Path $Base -ChildPath ([System.IO.Path]::Combine($Parts))))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
$repoRoot = Resolve-StrictPath (Join-Path $PSScriptRoot "..")
|
|
18
|
-
if ([string]::IsNullOrWhiteSpace($MarketplacePath)) {
|
|
19
|
-
$codexMarketplace = Join-And-Normalize $CodexHome @(".tmp", "marketplaces", $PluginName, ".agents", "plugins", "marketplace.json")
|
|
20
|
-
if (Test-Path -LiteralPath $codexMarketplace) {
|
|
21
|
-
$MarketplacePath = $codexMarketplace
|
|
22
|
-
} else {
|
|
23
|
-
$MarketplacePath = "$HOME/.agents/plugins/marketplace.json"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
$marketplaceFile = Resolve-StrictPath $MarketplacePath
|
|
27
|
-
$marketplace = Get-Content -LiteralPath $marketplaceFile -Raw | ConvertFrom-Json
|
|
28
|
-
$marketplaceName = [string]$marketplace.name
|
|
29
|
-
if ([string]::IsNullOrWhiteSpace($marketplaceName)) {
|
|
30
|
-
throw "Marketplace file must include a top-level name."
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
$plugin = @($marketplace.plugins) | Where-Object { $_.name -eq $PluginName } | Select-Object -First 1
|
|
34
|
-
if (-not $plugin) {
|
|
35
|
-
throw "Plugin '$PluginName' was not found in $marketplaceFile."
|
|
36
|
-
}
|
|
37
|
-
if (($plugin.source.source -ne "local") -and ($plugin.source.source -ne "url")) {
|
|
38
|
-
throw "Plugin '$PluginName' must come from a local or URL marketplace source."
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
$sourceRoot = Resolve-StrictPath $repoRoot
|
|
42
|
-
$manifestPath = Join-Path $sourceRoot ".codex-plugin/plugin.json"
|
|
43
|
-
if (-not (Test-Path -LiteralPath $manifestPath)) {
|
|
44
|
-
throw "Missing plugin manifest at $manifestPath."
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
$manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json
|
|
48
|
-
if ($manifest.name -ne $PluginName) {
|
|
49
|
-
throw "Plugin manifest name '$($manifest.name)' does not match requested plugin '$PluginName'."
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
$codexHomePath = [System.IO.Path]::GetFullPath($CodexHome)
|
|
53
|
-
$cacheRoot = Join-And-Normalize $codexHomePath @("plugins", "cache")
|
|
54
|
-
$pluginCacheRoot = Join-And-Normalize $cacheRoot @($marketplaceName, $PluginName)
|
|
55
|
-
$cacheVersion = $(if ($plugin.source.source -eq "local") { "local" } else { [string]$manifest.version })
|
|
56
|
-
if ([string]::IsNullOrWhiteSpace($cacheVersion)) {
|
|
57
|
-
throw "Plugin '$PluginName' manifest must include a version."
|
|
58
|
-
}
|
|
59
|
-
$targetRoot = Join-And-Normalize $pluginCacheRoot @($cacheVersion)
|
|
60
|
-
|
|
61
|
-
$cacheRootWithSeparator = $cacheRoot.TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar) + [System.IO.Path]::DirectorySeparatorChar
|
|
62
|
-
if (-not $pluginCacheRoot.StartsWith($cacheRootWithSeparator, [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
63
|
-
throw "Resolved plugin cache path is outside Codex plugin cache: $pluginCacheRoot"
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (Test-Path -LiteralPath $targetRoot) {
|
|
67
|
-
Remove-Item -LiteralPath $targetRoot -Recurse -Force
|
|
68
|
-
}
|
|
69
|
-
New-Item -ItemType Directory -Path $targetRoot -Force | Out-Null
|
|
70
|
-
|
|
71
|
-
$itemsToCopy = @(
|
|
72
|
-
".codex-plugin",
|
|
73
|
-
"skills",
|
|
74
|
-
"references",
|
|
75
|
-
"README.md",
|
|
76
|
-
"LICENSE",
|
|
77
|
-
"package.json",
|
|
78
|
-
"dist"
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
foreach ($item in $itemsToCopy) {
|
|
82
|
-
$source = Join-Path $sourceRoot $item
|
|
83
|
-
if (-not (Test-Path -LiteralPath $source)) {
|
|
84
|
-
continue
|
|
85
|
-
}
|
|
86
|
-
Copy-Item -LiteralPath $source -Destination $targetRoot -Recurse -Force
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
Write-Host "Refreshed local Codex plugin cache:"
|
|
90
|
-
Write-Host " source: $sourceRoot"
|
|
91
|
-
Write-Host " target: $targetRoot"
|
|
92
|
-
Write-Host ""
|
|
93
|
-
Write-Host "Restart or reload Codex to pick up refreshed plugin skills."
|