amicooked 0.1.3 → 0.1.4
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/dist/cli/afterQuit.js +55 -0
- package/dist/cli/setup.js +106 -51
- package/dist/cli.js +4 -0
- package/dist/clients/apps.js +111 -0
- package/dist/clients/claudeDesktop.js +0 -35
- package/dist/clients/codex.js +4 -0
- package/dist/skill.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -2
- package/skill/SKILL.md +9 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import { APPS, isRunning, open } from "../clients/apps.js";
|
|
3
|
+
import { claudeDesktopDir, installClaudeDesktop } from "../clients/claudeDesktop.js";
|
|
4
|
+
import { selfCommand } from "../clients/self.js";
|
|
5
|
+
// When setup runs inside Claude Desktop (an agent in it, say), it can't quit the app without ending that
|
|
6
|
+
// session, and Claude Desktop would save over our config when it quits anyway. So setup leaves this
|
|
7
|
+
// running in the background: it waits for the student to quit Claude, writes the config again, and
|
|
8
|
+
// reopens Claude, so one Cmd+Q finishes the job.
|
|
9
|
+
const POLL_MS = 2000;
|
|
10
|
+
const GIVE_UP_MS = 12 * 60 * 60 * 1000;
|
|
11
|
+
/** Starts the background helper, detached so it outlives setup. */
|
|
12
|
+
export function scheduleAfterQuit() {
|
|
13
|
+
try {
|
|
14
|
+
const self = selfCommand(["finish-after-quit"]);
|
|
15
|
+
const child = spawn(self.command, self.args, {
|
|
16
|
+
stdio: "ignore",
|
|
17
|
+
detached: true,
|
|
18
|
+
env: { ...process.env, ...self.env },
|
|
19
|
+
});
|
|
20
|
+
child.on("error", () => { });
|
|
21
|
+
child.unref();
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** The hidden `finish-after-quit` command the helper runs. */
|
|
29
|
+
export async function finishAfterQuit(steps = defaultSteps()) {
|
|
30
|
+
if (!steps)
|
|
31
|
+
return 1;
|
|
32
|
+
const end = steps.now() + GIVE_UP_MS;
|
|
33
|
+
while (steps.running()) {
|
|
34
|
+
if (steps.now() > end)
|
|
35
|
+
return 1;
|
|
36
|
+
await steps.wait(POLL_MS);
|
|
37
|
+
}
|
|
38
|
+
// Give the app a moment to finish writing its own copy before ours goes on top
|
|
39
|
+
await steps.wait(1500);
|
|
40
|
+
steps.write();
|
|
41
|
+
steps.reopen();
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
function defaultSteps() {
|
|
45
|
+
const dir = claudeDesktopDir();
|
|
46
|
+
if (!dir)
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
running: () => isRunning(APPS.claude),
|
|
50
|
+
write: () => installClaudeDesktop(dir, selfCommand(["mcp"])),
|
|
51
|
+
reopen: () => void open(APPS.claude),
|
|
52
|
+
wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
53
|
+
now: () => Date.now(),
|
|
54
|
+
};
|
|
55
|
+
}
|
package/dist/cli/setup.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
2
4
|
import { hasActiveSession, login } from "../auth.js";
|
|
3
5
|
import { detectChannel } from "../browser.js";
|
|
4
|
-
import {
|
|
6
|
+
import { APPS, CLAUDE_CODE_DOWNLOAD, desktopAppsSupported, isRunning, isRunningInside, open, openUrl, quit } from "../clients/apps.js";
|
|
7
|
+
import { claudeDesktopDir, installClaudeDesktop, InvalidConfigError, manualSnippet } from "../clients/claudeDesktop.js";
|
|
8
|
+
import { scheduleAfterQuit } from "./afterQuit.js";
|
|
5
9
|
import { hasClaudeCode, installClaudeCode, installSkill } from "../clients/claudeCode.js";
|
|
6
10
|
import { chatgptSteps, installChatGPT } from "../clients/chatgpt.js";
|
|
7
|
-
import { hasCodex, installCodex, installCodexSkill } from "../clients/codex.js";
|
|
11
|
+
import { codexEntryIs, codexSkillPath, hasCodex, installCodex, installCodexSkill } from "../clients/codex.js";
|
|
12
|
+
import { SKILL_MD } from "../skill.js";
|
|
8
13
|
import { selfCommand } from "../clients/self.js";
|
|
9
14
|
import { client } from "../client.js";
|
|
10
15
|
import { getConfig, writeConfig } from "../config.js";
|
|
@@ -92,71 +97,103 @@ async function chooseClients(flag, detected, yes) {
|
|
|
92
97
|
throw new SetupStop("Setup cancelled.");
|
|
93
98
|
return chosen;
|
|
94
99
|
}
|
|
95
|
-
|
|
96
|
-
async function
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
const quitHow = () => (process.platform === "darwin" ? "with Cmd+Q" : "fully, from its icon by the clock if it has one");
|
|
101
|
+
async function missingApp(app, name, url) {
|
|
102
|
+
if (interactive()) {
|
|
103
|
+
const ok = await p.confirm({ message: `${name} isn't installed. Open its download page?` });
|
|
104
|
+
if (ok === true)
|
|
105
|
+
openUrl(url);
|
|
106
|
+
}
|
|
107
|
+
return { app, next: `install ${name} from ${url}, then run \`amicooked setup\` again.`, ready: false };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Connects a desktop app and leaves it open with the new config loaded, or says exactly what's left.
|
|
111
|
+
* `write` adds our server to the app's config; `current` says whether it's already there.
|
|
112
|
+
*/
|
|
113
|
+
async function connectDesktopApp(app, label, write, current) {
|
|
114
|
+
const ask = "Ask it: am I cooked?";
|
|
115
|
+
if (current()) {
|
|
116
|
+
// Already set up. Make sure it's open; no restart needed
|
|
117
|
+
if (isRunning(app))
|
|
118
|
+
return { app: label, next: `already set up. ${ask}`, ready: true };
|
|
119
|
+
return open(app)
|
|
120
|
+
? { app: label, next: `already set up, and opening now. ${ask}`, ready: true }
|
|
121
|
+
: { app: label, next: `already set up. Open ${app.name} and ask: am I cooked?`, ready: false };
|
|
122
|
+
}
|
|
123
|
+
let running = isRunning(app);
|
|
124
|
+
const inside = running && isRunningInside(app);
|
|
125
|
+
// An open app only loads the change after a restart. Offer one, unless setup is running inside that app
|
|
126
|
+
// (an agent there) or nobody's at the keyboard to say yes
|
|
127
|
+
if (running && !inside && interactive()) {
|
|
128
|
+
const ok = await p.confirm({ message: `${app.name} is open and needs a restart to pick this up. Restart it now?` });
|
|
129
|
+
if (ok === true)
|
|
130
|
+
running = !(await quit(app));
|
|
131
|
+
}
|
|
132
|
+
write();
|
|
133
|
+
if (running && app.overwritesOnQuit) {
|
|
134
|
+
// Quitting it would save its old config over ours, so a background helper waits for the quit, writes
|
|
135
|
+
// the config again and reopens the app
|
|
136
|
+
return scheduleAfterQuit()
|
|
137
|
+
? { app: label, next: `quit ${app.name} ${quitHow()}. Am I Cooked finishes setting it up and reopens it. Then ask it: am I cooked?`, ready: false }
|
|
138
|
+
: { app: label, next: `quit ${app.name} ${quitHow()}, then run \`amicooked setup\` again.`, ready: false };
|
|
139
|
+
}
|
|
140
|
+
if (running)
|
|
141
|
+
return { app: label, next: `quit ${app.name} ${quitHow()} and open it again. Then ask it: am I cooked?`, ready: false };
|
|
142
|
+
return open(app)
|
|
143
|
+
? { app: label, next: `set up, and opening now. ${ask}`, ready: true }
|
|
144
|
+
: { app: label, next: `set up. Open ${app.name} and ask: am I cooked?`, ready: false };
|
|
106
145
|
}
|
|
107
146
|
async function configureClients(clients) {
|
|
108
|
-
const
|
|
147
|
+
const outcomes = [];
|
|
109
148
|
const launch = selfCommand(["mcp"]);
|
|
110
149
|
if (clients.includes("desktop")) {
|
|
111
150
|
const dir = claudeDesktopDir();
|
|
112
|
-
if (!
|
|
113
|
-
|
|
151
|
+
if (!desktopAppsSupported()) {
|
|
152
|
+
outcomes.push({ app: "Claude Desktop", next: `isn't available on Linux. Use Claude Code instead: ${CLAUDE_CODE_DOWNLOAD}`, ready: false });
|
|
153
|
+
}
|
|
154
|
+
else if (!dir) {
|
|
155
|
+
outcomes.push(await missingApp("Claude Desktop", "Claude Desktop", APPS.claude.download));
|
|
114
156
|
}
|
|
115
157
|
else {
|
|
116
158
|
try {
|
|
117
|
-
|
|
118
|
-
const result = installClaudeDesktop(dir, launch);
|
|
119
|
-
if (state === "left_open" && result !== "unchanged") {
|
|
120
|
-
// Written, but the open app will save its own copy over it when it quits
|
|
121
|
-
p.log.warn("Claude Desktop is open, so it will undo this when it quits. Quit it, then run `amicooked setup --clients desktop`.");
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
p.log.success(`Claude Desktop: ${result === "unchanged" ? "already set up" : "set up"}`);
|
|
125
|
-
done.push(state === "closed" && openClaudeDesktop() ? "desktop-reopened" : "desktop");
|
|
126
|
-
}
|
|
159
|
+
outcomes.push(await connectDesktopApp(APPS.claude, "Claude Desktop", () => installClaudeDesktop(dir, launch), () => desktopHas(dir, launch)));
|
|
127
160
|
}
|
|
128
161
|
catch (error) {
|
|
129
162
|
if (!(error instanceof InvalidConfigError))
|
|
130
163
|
throw error;
|
|
131
164
|
p.log.warn(`${error.message}\nAdd this to it yourself:\n${manualSnippet(launch)}`);
|
|
165
|
+
outcomes.push({ app: "Claude Desktop", next: "add the snippet above to its config, then restart it.", ready: false });
|
|
132
166
|
}
|
|
133
167
|
}
|
|
134
168
|
}
|
|
135
169
|
if (clients.includes("code")) {
|
|
136
170
|
if (!hasClaudeCode()) {
|
|
137
|
-
|
|
171
|
+
outcomes.push(await missingApp("Claude Code", "Claude Code", CLAUDE_CODE_DOWNLOAD));
|
|
138
172
|
}
|
|
139
173
|
else {
|
|
140
174
|
installClaudeCode(launch);
|
|
141
175
|
installSkill();
|
|
142
|
-
|
|
143
|
-
|
|
176
|
+
// Claude Code loads servers when a session starts, so an agent already running needs a new one
|
|
177
|
+
outcomes.push({ app: "Claude Code", next: "set up. Start a new Claude Code session and ask: am I cooked?", ready: true });
|
|
144
178
|
}
|
|
145
179
|
}
|
|
146
180
|
if (clients.includes("chatgpt-desktop")) {
|
|
147
|
-
if (!hasCodex()) {
|
|
148
|
-
|
|
181
|
+
if (!hasCodex() && !desktopAppsSupported()) {
|
|
182
|
+
outcomes.push({ app: "ChatGPT app", next: `isn't available on Linux. Use Claude Code instead: ${CLAUDE_CODE_DOWNLOAD}`, ready: false });
|
|
183
|
+
}
|
|
184
|
+
else if (!hasCodex()) {
|
|
185
|
+
outcomes.push(await missingApp("ChatGPT app", "the ChatGPT app", APPS.chatgpt.download));
|
|
149
186
|
}
|
|
150
187
|
else {
|
|
151
188
|
// Runs on this computer like Claude Desktop does; no tunnel or domain involved
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
189
|
+
outcomes.push(await connectDesktopApp(APPS.chatgpt, "ChatGPT app", () => {
|
|
190
|
+
installCodex(launch);
|
|
191
|
+
installCodexSkill();
|
|
192
|
+
}, () => codexHas(launch)));
|
|
156
193
|
}
|
|
157
194
|
}
|
|
158
195
|
if (clients.includes("chatgpt") && !process.env.AMICOOKED_TUNNEL_API) {
|
|
159
|
-
|
|
196
|
+
outcomes.push({ app: "ChatGPT on the web", next: "isn't available yet. Use the ChatGPT app instead: `--clients chatgpt-desktop`.", ready: false });
|
|
160
197
|
}
|
|
161
198
|
else if (clients.includes("chatgpt")) {
|
|
162
199
|
const spin = p.spinner();
|
|
@@ -165,13 +202,39 @@ async function configureClients(clients) {
|
|
|
165
202
|
const { url, pairingCode } = await installChatGPT();
|
|
166
203
|
spin.stop("ChatGPT: running in the background");
|
|
167
204
|
p.note(chatgptSteps(url, pairingCode), "Connect ChatGPT");
|
|
168
|
-
|
|
205
|
+
outcomes.push({ app: "ChatGPT on the web", next: "finish connecting with the steps above, then ask: am I cooked?", ready: false });
|
|
169
206
|
}
|
|
170
207
|
catch (error) {
|
|
171
208
|
spin.stop(`ChatGPT: ${error instanceof Error ? error.message : error}`);
|
|
172
209
|
}
|
|
173
210
|
}
|
|
174
|
-
return
|
|
211
|
+
return outcomes;
|
|
212
|
+
}
|
|
213
|
+
/** True when Claude Desktop's config already starts this exact install. */
|
|
214
|
+
function desktopHas(dir, launch) {
|
|
215
|
+
try {
|
|
216
|
+
const config = JSON.parse(fs.readFileSync(path.join(dir, "claude_desktop_config.json"), "utf8"));
|
|
217
|
+
const entry = { command: launch.command, args: launch.args, ...(launch.env ? { env: launch.env } : {}) };
|
|
218
|
+
return JSON.stringify(config.mcpServers?.amicooked) === JSON.stringify(entry);
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/** True when the ChatGPT app's config already starts this exact install, and the skill is in place. */
|
|
225
|
+
function codexHas(launch) {
|
|
226
|
+
return codexEntryIs(launch) && fs.existsSync(codexSkillPath()) && fs.readFileSync(codexSkillPath(), "utf8") === SKILL_MD;
|
|
227
|
+
}
|
|
228
|
+
/** The end of setup: every app's next step, then one line saying whether they're done. */
|
|
229
|
+
export function finishMessage(outcomes) {
|
|
230
|
+
if (!outcomes.length) {
|
|
231
|
+
return {
|
|
232
|
+
steps: null,
|
|
233
|
+
outro: `Nothing was set up. Get Claude Desktop (${APPS.claude.download}) or the ChatGPT app (${APPS.chatgpt.download}), then run \`amicooked setup\` again.`,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const steps = outcomes.map((o) => `${o.app}: ${o.next}`).join("\n");
|
|
237
|
+
return { steps, outro: outcomes.some((o) => o.ready) ? "You're set." : "Almost there. Do the step above." };
|
|
175
238
|
}
|
|
176
239
|
async function firstRoast() {
|
|
177
240
|
const spin = p.spinner();
|
|
@@ -206,21 +269,13 @@ export async function setup(options) {
|
|
|
206
269
|
p.log.success(`Signed in${me.FirstName ? ` as ${me.FirstName}` : ""}. Found ${courses.length} course${courses.length === 1 ? "" : "s"}.`);
|
|
207
270
|
}
|
|
208
271
|
const detected = { desktop: Boolean(claudeDesktopDir()), code: hasClaudeCode(), "chatgpt-desktop": hasCodex(), chatgpt: false };
|
|
209
|
-
const
|
|
272
|
+
const outcomes = await configureClients(await chooseClients(options.clients, detected, Boolean(options.yes)));
|
|
210
273
|
if (options.login !== false)
|
|
211
274
|
await firstRoast();
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
: done.includes("chatgpt-desktop")
|
|
217
|
-
? "Restart the ChatGPT desktop app, then ask: am I cooked?"
|
|
218
|
-
: done.includes("code")
|
|
219
|
-
? "Start Claude Code and ask: am I cooked?"
|
|
220
|
-
: done.includes("chatgpt")
|
|
221
|
-
? "Finish connecting in ChatGPT, then ask: am I cooked?"
|
|
222
|
-
: "Nothing was set up. Run `amicooked setup` again and pick an app.";
|
|
223
|
-
p.outro(next);
|
|
275
|
+
const { steps, outro } = finishMessage(outcomes);
|
|
276
|
+
if (steps)
|
|
277
|
+
p.note(steps, "Next");
|
|
278
|
+
p.outro(outro);
|
|
224
279
|
return 0;
|
|
225
280
|
}
|
|
226
281
|
catch (error) {
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { parseArgs } from "util";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { loginCommand, pairCommand, statusCommand, uninstallCommand } from "./cli/manage.js";
|
|
5
|
+
import { finishAfterQuit } from "./cli/afterQuit.js";
|
|
5
6
|
import { serveCommand } from "./cli/serve.js";
|
|
6
7
|
import { setup } from "./cli/setup.js";
|
|
7
8
|
import { serverInstructions } from "./instructions.js";
|
|
@@ -65,6 +66,9 @@ async function main(argv) {
|
|
|
65
66
|
return serveCommand({ quick: values.quick, local: values.local, port: values.port ? Number(values.port) : undefined });
|
|
66
67
|
case "status":
|
|
67
68
|
return statusCommand(Boolean(values.json));
|
|
69
|
+
case "finish-after-quit":
|
|
70
|
+
// Hidden: setup starts this in the background when it can't restart Claude Desktop itself
|
|
71
|
+
return finishAfterQuit();
|
|
68
72
|
case "uninstall":
|
|
69
73
|
return uninstallCommand(Boolean(values.purge));
|
|
70
74
|
default:
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "child_process";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
export const APPS = {
|
|
5
|
+
claude: {
|
|
6
|
+
id: "claude",
|
|
7
|
+
name: "Claude Desktop",
|
|
8
|
+
download: "https://claude.ai/download",
|
|
9
|
+
macName: "Claude",
|
|
10
|
+
// Claude Code ships a lowercase claude.app inside Claude's support folder; only the real app counts
|
|
11
|
+
macExe: /\/Claude\.app\/Contents\/MacOS\/Claude$/m,
|
|
12
|
+
winProcess: "Claude.exe",
|
|
13
|
+
winExe: (env) => (env.LOCALAPPDATA ? path.join(env.LOCALAPPDATA, "AnthropicClaude", "claude.exe") : null),
|
|
14
|
+
overwritesOnQuit: true,
|
|
15
|
+
},
|
|
16
|
+
chatgpt: {
|
|
17
|
+
id: "chatgpt",
|
|
18
|
+
name: "the ChatGPT app",
|
|
19
|
+
download: "https://chatgpt.com/download",
|
|
20
|
+
macName: "ChatGPT",
|
|
21
|
+
macExe: /\/ChatGPT\.app\/Contents\/MacOS\/ChatGPT$/m,
|
|
22
|
+
winProcess: "ChatGPT.exe",
|
|
23
|
+
// The Windows app comes from the Microsoft Store, which has no fixed path to launch
|
|
24
|
+
winExe: () => null,
|
|
25
|
+
overwritesOnQuit: false,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const CLAUDE_CODE_DOWNLOAD = "https://code.claude.com/docs/en/overview";
|
|
29
|
+
/** Desktop apps exist for macOS and Windows only. */
|
|
30
|
+
export const desktopAppsSupported = (platform = process.platform) => platform === "darwin" || platform === "win32";
|
|
31
|
+
const run = (command, args) => {
|
|
32
|
+
const r = spawnSync(command, args, { encoding: "utf8", timeout: 10000 });
|
|
33
|
+
return { status: r.error ? null : r.status, stdout: r.stdout ?? "" };
|
|
34
|
+
};
|
|
35
|
+
const host = () => ({ platform: process.platform, run, env: process.env });
|
|
36
|
+
export function isRunning(app, h = host()) {
|
|
37
|
+
// ps, not pgrep: pgrep skips its own ancestors, so it misses the app when setup runs from inside it
|
|
38
|
+
if (h.platform === "darwin")
|
|
39
|
+
return app.macExe.test(h.run("ps", ["-axo", "comm="]).stdout);
|
|
40
|
+
if (h.platform === "win32") {
|
|
41
|
+
return h.run("tasklist", ["/FI", `IMAGENAME eq ${app.winProcess}`, "/NH"]).stdout.toLowerCase().includes(app.winProcess.toLowerCase());
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* True when this process was started by the app, e.g. an agent in Claude Desktop running setup.
|
|
47
|
+
* Quitting that app would end the very session asking for it, so setup must not.
|
|
48
|
+
*/
|
|
49
|
+
export function isRunningInside(app, h = host(), pid = process.pid) {
|
|
50
|
+
if (h.platform !== "darwin")
|
|
51
|
+
return false;
|
|
52
|
+
const table = new Map();
|
|
53
|
+
for (const line of h.run("ps", ["-axo", "pid=,ppid=,comm="]).stdout.split("\n")) {
|
|
54
|
+
const m = line.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);
|
|
55
|
+
if (m)
|
|
56
|
+
table.set(Number(m[1]), { ppid: Number(m[2]), comm: m[3] });
|
|
57
|
+
}
|
|
58
|
+
for (let p = pid, hops = 0; p > 1 && hops < 64; hops++) {
|
|
59
|
+
const row = table.get(p);
|
|
60
|
+
if (!row)
|
|
61
|
+
return false;
|
|
62
|
+
if (app.macExe.test(row.comm))
|
|
63
|
+
return true;
|
|
64
|
+
p = row.ppid;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/** Asks the app to quit and waits until it's gone. False if it's still open (unsaved work, a dialog). */
|
|
69
|
+
export async function quit(app, h = host(), waitMs = 15000) {
|
|
70
|
+
if (h.platform === "darwin")
|
|
71
|
+
h.run("osascript", ["-e", `tell application "${app.macName}" to quit`]);
|
|
72
|
+
else if (h.platform === "win32")
|
|
73
|
+
h.run("taskkill", ["/IM", app.winProcess]);
|
|
74
|
+
else
|
|
75
|
+
return false;
|
|
76
|
+
for (const end = Date.now() + waitMs; Date.now() < end;) {
|
|
77
|
+
if (!isRunning(app, h))
|
|
78
|
+
return true;
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
80
|
+
}
|
|
81
|
+
return !isRunning(app, h);
|
|
82
|
+
}
|
|
83
|
+
/** Opens the app. False when there's no reliable way to on this computer; then the student opens it. */
|
|
84
|
+
export function open(app, h = host(), launch = detachedLaunch) {
|
|
85
|
+
if (h.platform === "darwin")
|
|
86
|
+
return launch("open", ["-a", app.macName]);
|
|
87
|
+
if (h.platform === "win32") {
|
|
88
|
+
const exe = app.winExe(h.env);
|
|
89
|
+
return exe !== null && fs.existsSync(exe) && launch(exe, []);
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
/** Opens a web page in the default browser. */
|
|
94
|
+
export function openUrl(url, platform = process.platform, launch = detachedLaunch) {
|
|
95
|
+
if (platform === "darwin")
|
|
96
|
+
return launch("open", [url]);
|
|
97
|
+
if (platform === "win32")
|
|
98
|
+
return launch("cmd", ["/c", "start", "", url]);
|
|
99
|
+
return launch("xdg-open", [url]);
|
|
100
|
+
}
|
|
101
|
+
function detachedLaunch(command, args) {
|
|
102
|
+
try {
|
|
103
|
+
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
104
|
+
child.on("error", () => { });
|
|
105
|
+
child.unref();
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { spawn, spawnSync } from "child_process";
|
|
2
1
|
import * as fs from "fs";
|
|
3
2
|
import * as os from "os";
|
|
4
3
|
import * as path from "path";
|
|
@@ -82,37 +81,3 @@ export function manualSnippet(launch) {
|
|
|
82
81
|
const entry = { command: launch.command, args: launch.args, ...(launch.env ? { env: launch.env } : {}) };
|
|
83
82
|
return JSON.stringify({ mcpServers: { [SERVER_NAME]: entry } }, null, 2);
|
|
84
83
|
}
|
|
85
|
-
const probe = (command, args) => {
|
|
86
|
-
const r = spawnSync(command, args, { encoding: "utf8", timeout: 10000 });
|
|
87
|
-
return { status: r.error ? null : r.status, stdout: r.stdout ?? "" };
|
|
88
|
-
};
|
|
89
|
-
export function isClaudeDesktopRunning(platform = process.platform, run = probe) {
|
|
90
|
-
// ps, not pgrep: pgrep skips its own ancestors, so it misses the app when setup runs from inside it
|
|
91
|
-
if (platform === "darwin")
|
|
92
|
-
return /\/Claude\.app\/Contents\/MacOS\/Claude$/m.test(run("ps", ["-axo", "comm="]).stdout);
|
|
93
|
-
if (platform === "win32")
|
|
94
|
-
return /claude\.exe/i.test(run("tasklist", ["/FI", "IMAGENAME eq Claude.exe", "/NH"]).stdout);
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
/** Asks the app to quit (never forces it) and waits until it's gone. False if it's still open. */
|
|
98
|
-
export async function quitClaudeDesktop(platform = process.platform, run = probe, waitMs = 15000) {
|
|
99
|
-
if (platform === "darwin")
|
|
100
|
-
run("osascript", ["-e", 'tell application "Claude" to quit']);
|
|
101
|
-
else if (platform === "win32")
|
|
102
|
-
run("taskkill", ["/IM", "Claude.exe"]);
|
|
103
|
-
else
|
|
104
|
-
return false;
|
|
105
|
-
for (const end = Date.now() + waitMs; Date.now() < end;) {
|
|
106
|
-
if (!isClaudeDesktopRunning(platform, run))
|
|
107
|
-
return true;
|
|
108
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
109
|
-
}
|
|
110
|
-
return !isClaudeDesktopRunning(platform, run);
|
|
111
|
-
}
|
|
112
|
-
/** Opens the app again. Only macOS has a reliable way to find it; elsewhere the student opens it. */
|
|
113
|
-
export function openClaudeDesktop(platform = process.platform) {
|
|
114
|
-
if (platform !== "darwin")
|
|
115
|
-
return false;
|
|
116
|
-
spawn("open", ["-a", "Claude"], { stdio: "ignore", detached: true }).unref();
|
|
117
|
-
return true;
|
|
118
|
-
}
|
package/dist/clients/codex.js
CHANGED
|
@@ -94,6 +94,10 @@ export function uninstallCodex(file = codexConfigPath()) {
|
|
|
94
94
|
writeAtomic(file, `${rest.replace(/\s+$/, "")}\n`);
|
|
95
95
|
return "removed";
|
|
96
96
|
}
|
|
97
|
+
/** True when config.toml already starts exactly this command. */
|
|
98
|
+
export function codexEntryIs(launch, file = codexConfigPath()) {
|
|
99
|
+
return fs.existsSync(file) && splitOurTable(fs.readFileSync(file, "utf8")).ours === tomlEntry(launch);
|
|
100
|
+
}
|
|
97
101
|
export function codexConfigured(file = codexConfigPath()) {
|
|
98
102
|
return fs.existsSync(file) && splitOurTable(fs.readFileSync(file, "utf8")).ours !== null;
|
|
99
103
|
}
|
package/dist/skill.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated from skill/SKILL.md by scripts/sync-skill.mjs. Don't edit by hand.
|
|
2
|
-
export const SKILL_MD = "---\nname: amicooked\ndescription: Use when a student asks about their D2L Brightspace courses, grades, deadlines, assignments, announcements or course files, asks \"am I cooked?\", or wants to set up Am I Cooked.\n---\n\n# Am I Cooked\n\nAm I Cooked connects an AI assistant to a student's D2L Brightspace account (Avenue to Learn, LEARN, onQ, OWL Brightspace, CourseLink, MyLearningSpace and others). It runs on the student's own computer and is read-only.\n\n## Setting it up (for agents)\n\n1. Ask the student which school they go to. Presets: mcmaster, waterloo, western, queens, guelph, laurier, tmu, uottawa, carleton, brock, windsor, laurentian, lakehead. Any other Brightspace school works with the URL they log in through.\n2. Install it:\n - macOS / Linux: `curl -fsSL https://amicooked-mcp.vercel.app/install.sh | sh -s -- --no-setup`\n - Windows (PowerShell): `$env:AMICOOKED_NO_SETUP=1; irm https://amicooked-mcp.vercel.app/install.ps1 | iex`\n - With Node.js installed, `npx -y amicooked@0` works in place of `amicooked` below.\n3. Run setup with flags, and a long command timeout (at least 5 minutes), because the student signs in through a browser window that opens:\n `amicooked setup --school mcmaster --clients desktop,code`\n Use `--school https://...` for schools without a preset. Add `chatgpt-desktop` to `--clients` if they use the ChatGPT desktop app, then tell them to restart it. ChatGPT and Claude on the web or on phones aren't supported.\n4. Tell the student to sign in to their school in the browser window. Never ask for their password; you never need it.\n5. If something fails, run `amicooked status` and read what it says.\n\n<!-- server-instructions -->\n## Answering questions\n\n- Start broad questions (\"am I cooked?\", \"what should I work on?\", \"how am I doing?\", \"what's due?\") with `am_i_cooked`. It covers every current course in one call.\n- Other tools take a course code directly, like `course: \"3BB4\"`. Only call `get_my_courses` when a code is ambiguous or the student asks what they're enrolled in.\n- Check `get_announcements` for a course before a final verdict on it; deadlines and exam details often change there.\n- To read slides, handouts or assignment PDFs: `get_course_content` to find the file, then `download_file`. Use `read_file` for files already downloaded.\n- If a tool says a login window opened, tell the student to sign in there and ask again.\n\n## The verdict\n\nUse `summary.heatLabel` from `am_i_cooked` to set the tone. Be playful, never mean, and always useful.\n\n| heatLabel | Tone |\n|---|---|\n| raw | Relaxed. Nothing urgent; maybe get ahead on something. |\n| warming up | Light nudge. One or two things to handle soon. |\n| toasty | Focused. A real plan for the next few days. |\n| cooked | Direct and supportive. Triage what matters most. |\n| well done | Calm and practical. Damage control, and who to talk to. |\n\n1. Lead with a one-line verdict, e.g. \"Toasty, not cooked.\"\n2. Then the top 3 actions, each with course, item and due time in the student's local time (D2L times are UTC).\n3. Say whether a grade is `final_calculated` or `estimated_from_items`; estimates ignore dropped and bonus items.\n - For an estimate, say how much is left, like \"67.6% so far. 60% of your grade is still to come.\" Use `weightRemaining` for that number.\n - Name the `keyItems` when a grade needs explaining, with their weight: \"the midterm (59.5%, worth 25%) is pulling it down.\"\n - Never work weights out backwards from a result. Use the `weight` values the tools return.\n - `basis: \"points\"` means the gradebook has no weights. Say the estimate is by points and the real weighting may differ. If the student asks how the grade is calculated, find the course outline with `get_course_content` and read the weights from it.\n4. `late_window_open` means a missed assignment can still be submitted: say so first, it's the easiest win.\n5. If `partial_data` appears, mention that some of a course couldn't be loaded.\n6. For grades under 60%, suggest office hours, the TA, or an academic advisor.\n\n## Integrity\n\nAm I Cooked only reads. Help the student understand material and plan their time, but don't write graded work for them to submit.\n<!-- /server-instructions -->\n";
|
|
2
|
+
export const SKILL_MD = "---\nname: amicooked\ndescription: Use when a student asks about their D2L Brightspace courses, grades, deadlines, assignments, announcements or course files, asks \"am I cooked?\", or wants to set up Am I Cooked.\n---\n\n# Am I Cooked\n\nAm I Cooked connects an AI assistant to a student's D2L Brightspace account (Avenue to Learn, LEARN, onQ, OWL Brightspace, CourseLink, MyLearningSpace and others). It runs on the student's own computer and is read-only.\n\n## Setting it up (for agents)\n\n**First, check that you can run commands on the student's computer.** Setup installs a program there, so it only works from an agent with a terminal, like Claude Code, Codex or the ChatGPT desktop app. If you're on a website (chatgpt.com, claude.ai, gemini.google.com), in a phone app, or in a chat with no command tool, don't try. Tell the student instead:\n\n- Get an app that can do it: Claude Desktop (https://claude.ai/download) or the ChatGPT app (https://chatgpt.com/download), then paste the same request there. Or install it themselves by pasting this into Terminal (Mac): `curl -fsSL https://amicooked-mcp.vercel.app/install.sh | sh`, or this into PowerShell (Windows): `irm https://amicooked-mcp.vercel.app/install.ps1 | iex`.\n- Either way, it ends by opening their AI app, ready to ask \"am I cooked?\".\n\nIf you can run commands:\n\n1. Ask the student which school they go to. Presets: mcmaster, waterloo, western, queens, guelph, laurier, tmu, uottawa, carleton, brock, windsor, laurentian, lakehead. Any other Brightspace school works with the URL they log in through.\n2. Install it:\n - macOS / Linux: `curl -fsSL https://amicooked-mcp.vercel.app/install.sh | sh -s -- --no-setup`\n - Windows (PowerShell): `$env:AMICOOKED_NO_SETUP=1; irm https://amicooked-mcp.vercel.app/install.ps1 | iex`\n - With Node.js installed, `npx -y amicooked@0` works in place of `amicooked` below.\n3. Run setup with flags, and a long command timeout (at least 5 minutes), because the student signs in through a browser window that opens:\n `amicooked setup --school mcmaster --clients desktop,code`\n Use `--school https://...` for schools without a preset. Add `chatgpt-desktop` to `--clients` if they use the ChatGPT desktop app, then tell them to restart it. ChatGPT and Claude on the web or on phones aren't supported.\n4. Tell the student to sign in to their school in the browser window. Never ask for their password; you never need it.\n5. Setup ends with a \"Next\" list: one line per app saying it's open and ready, needs a restart, needs opening, or needs installing (with a link). Tell the student each line as written. If you're running inside Claude Desktop, they need to quit it; Am I Cooked then reopens it with everything set up.\n6. If something fails, run `amicooked status` and read what it says.\n\n<!-- server-instructions -->\n## Answering questions\n\n- Start broad questions (\"am I cooked?\", \"what should I work on?\", \"how am I doing?\", \"what's due?\") with `am_i_cooked`. It covers every current course in one call.\n- Other tools take a course code directly, like `course: \"3BB4\"`. Only call `get_my_courses` when a code is ambiguous or the student asks what they're enrolled in.\n- Check `get_announcements` for a course before a final verdict on it; deadlines and exam details often change there.\n- To read slides, handouts or assignment PDFs: `get_course_content` to find the file, then `download_file`. Use `read_file` for files already downloaded.\n- If a tool says a login window opened, tell the student to sign in there and ask again.\n\n## The verdict\n\nUse `summary.heatLabel` from `am_i_cooked` to set the tone. Be playful, never mean, and always useful.\n\n| heatLabel | Tone |\n|---|---|\n| raw | Relaxed. Nothing urgent; maybe get ahead on something. |\n| warming up | Light nudge. One or two things to handle soon. |\n| toasty | Focused. A real plan for the next few days. |\n| cooked | Direct and supportive. Triage what matters most. |\n| well done | Calm and practical. Damage control, and who to talk to. |\n\n1. Lead with a one-line verdict, e.g. \"Toasty, not cooked.\"\n2. Then the top 3 actions, each with course, item and due time in the student's local time (D2L times are UTC).\n3. Say whether a grade is `final_calculated` or `estimated_from_items`; estimates ignore dropped and bonus items.\n - For an estimate, say how much is left, like \"67.6% so far. 60% of your grade is still to come.\" Use `weightRemaining` for that number.\n - Name the `keyItems` when a grade needs explaining, with their weight: \"the midterm (59.5%, worth 25%) is pulling it down.\"\n - Never work weights out backwards from a result. Use the `weight` values the tools return.\n - `basis: \"points\"` means the gradebook has no weights. Say the estimate is by points and the real weighting may differ. If the student asks how the grade is calculated, find the course outline with `get_course_content` and read the weights from it.\n4. `late_window_open` means a missed assignment can still be submitted: say so first, it's the easiest win.\n5. If `partial_data` appears, mention that some of a course couldn't be loaded.\n6. For grades under 60%, suggest office hours, the TA, or an academic advisor.\n\n## Integrity\n\nAm I Cooked only reads. Help the student understand material and plan their time, but don't write graded work for them to submit.\n<!-- /server-instructions -->\n";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Must match package.json; a unit test checks this
|
|
2
|
-
export const VERSION = "0.1.
|
|
2
|
+
export const VERSION = "0.1.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amicooked",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Ask your AI if you're cooked. A local MCP server for D2L Brightspace: grades, deadlines and announcements in Claude and ChatGPT.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"test": "vitest run",
|
|
20
20
|
"test:watch": "vitest",
|
|
21
21
|
"prepack": "npm run build",
|
|
22
|
-
"build:bin": "node scripts/sync-skill.mjs && node scripts/build-binaries.mjs"
|
|
22
|
+
"build:bin": "node scripts/sync-skill.mjs && node scripts/build-binaries.mjs",
|
|
23
|
+
"preversion": "npm test",
|
|
24
|
+
"version": "node scripts/sync-version.mjs && git add src/version.ts"
|
|
23
25
|
},
|
|
24
26
|
"keywords": [
|
|
25
27
|
"mcp",
|
package/skill/SKILL.md
CHANGED
|
@@ -9,6 +9,13 @@ Am I Cooked connects an AI assistant to a student's D2L Brightspace account (Ave
|
|
|
9
9
|
|
|
10
10
|
## Setting it up (for agents)
|
|
11
11
|
|
|
12
|
+
**First, check that you can run commands on the student's computer.** Setup installs a program there, so it only works from an agent with a terminal, like Claude Code, Codex or the ChatGPT desktop app. If you're on a website (chatgpt.com, claude.ai, gemini.google.com), in a phone app, or in a chat with no command tool, don't try. Tell the student instead:
|
|
13
|
+
|
|
14
|
+
- Get an app that can do it: Claude Desktop (https://claude.ai/download) or the ChatGPT app (https://chatgpt.com/download), then paste the same request there. Or install it themselves by pasting this into Terminal (Mac): `curl -fsSL https://amicooked-mcp.vercel.app/install.sh | sh`, or this into PowerShell (Windows): `irm https://amicooked-mcp.vercel.app/install.ps1 | iex`.
|
|
15
|
+
- Either way, it ends by opening their AI app, ready to ask "am I cooked?".
|
|
16
|
+
|
|
17
|
+
If you can run commands:
|
|
18
|
+
|
|
12
19
|
1. Ask the student which school they go to. Presets: mcmaster, waterloo, western, queens, guelph, laurier, tmu, uottawa, carleton, brock, windsor, laurentian, lakehead. Any other Brightspace school works with the URL they log in through.
|
|
13
20
|
2. Install it:
|
|
14
21
|
- macOS / Linux: `curl -fsSL https://amicooked-mcp.vercel.app/install.sh | sh -s -- --no-setup`
|
|
@@ -18,7 +25,8 @@ Am I Cooked connects an AI assistant to a student's D2L Brightspace account (Ave
|
|
|
18
25
|
`amicooked setup --school mcmaster --clients desktop,code`
|
|
19
26
|
Use `--school https://...` for schools without a preset. Add `chatgpt-desktop` to `--clients` if they use the ChatGPT desktop app, then tell them to restart it. ChatGPT and Claude on the web or on phones aren't supported.
|
|
20
27
|
4. Tell the student to sign in to their school in the browser window. Never ask for their password; you never need it.
|
|
21
|
-
5. If
|
|
28
|
+
5. Setup ends with a "Next" list: one line per app saying it's open and ready, needs a restart, needs opening, or needs installing (with a link). Tell the student each line as written. If you're running inside Claude Desktop, they need to quit it; Am I Cooked then reopens it with everything set up.
|
|
29
|
+
6. If something fails, run `amicooked status` and read what it says.
|
|
22
30
|
|
|
23
31
|
<!-- server-instructions -->
|
|
24
32
|
## Answering questions
|