@chibitek/chibi 0.1.204 → 0.1.206
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/assets/{TerminalPanel-BR7_5v_A.js → TerminalPanel-BBJ8EeT7.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-CLlStcGS.js → abnfDiagram-O67JEVCF-a06YszXx.js} +1 -1
- package/dist/assets/{arc-BHbaT-sk.js → arc-Fe3WbFfc.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-WbYeclYS.js → architectureDiagram-NJMV4G6O-DYcb0ZrL.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-BjLSSFCv.js → blockDiagram-BEXU5L5S-xC5y8We2.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-BD0ADRml.js → c4Diagram-YGBWAQC7-Dm81dUJa.js} +1 -1
- package/dist/assets/channel-D3ihDYTR.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-6KX_NidY.js → chunk-2Q5K7J3B-CDVJUGUd.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-DD5c2wxN.js → chunk-3FUC2YCW-BvPx7oJb.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-CqVhfBe4.js → chunk-5VM5RSS4-kUQxxDSH.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-BkDNK4_N.js → chunk-GTNCS2PH-hmSLPBzT.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-18kKc3zf.js → chunk-GWA4HPMP-ivlnCC25.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-pq9dw6Nh.js → chunk-JWPE2WC7-hjxL5olg.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-o8wzQe-h.js → chunk-NETBCI7D-ClgHcSe7.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-iH237f6j.js → chunk-WEXAMYUT-1i-fNDpg.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-FW6F9gXF.js → chunk-XXDRQBXY-BhPdm5u4.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-DN_wA2Iu.js → classDiagram-v2-NBCMYWYE-BsL-gKkF.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BuC_Xux8.js → cose-bilkent-JH36ORCC-piSPlA0p.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-utuaVwac.js → cynefin-OW5HDTMX-D2T5q7wD.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-B5dHHkET.js → cynefinDiagram-VND7K2PF-CWHt2804.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-Dd4zswKZ.js → dagre-6A5THRUB-BNioVBDz.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-W1xZAePS.js → diagram-22UHCM2B-DULW9a3n.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-ytF3T-6m.js → diagram-3UASUU5V-EYvilvye.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DZUm9qqt.js → diagram-ATOU4E4O-BRkFLoxi.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-s0fp6jUL.js → diagram-CDSNMT55-B0IbbTpB.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-DyRhGqmG.js → diagram-MLGK6HIB-u7n_3e2v.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-CaIIQRhj.js → diagram-MPIPVDR6-NegomnHr.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-CsTrai7W.js → ebnfDiagram-ZINNZB2B-BPZmiseK.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-CRc9CYMO.js → elk-276RUBZZ-BcBEThvp.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-Ci3J3HOK.js → erDiagram-OPXOYQCR-BVAGByE5.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-CiNdncgv.js → flowDiagram-KWPJA3E3-ByZ1IyAE.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-B0fkV-ZJ.js → ganttDiagram-FUAMR5RP-CEa3O2pJ.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-CoxvyRBO.js → gitGraphDiagram-X574FWY7-dul-ZoaX.js} +1 -1
- package/dist/assets/index-Bi3hprmz.css +1 -0
- package/dist/assets/{index-DwuiJpCH.js → index-CFUbzTrj.js} +1 -1
- package/dist/assets/{index-DY2xQYkO.js → index-Tw4-5a-J.js} +155 -155
- package/dist/assets/{infoDiagram-VRGFBTTK-Cjwbpd4N.js → infoDiagram-VRGFBTTK-Bt9KS597.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BD2-4Y-q.js → ishikawaDiagram-OU5B5YK6-BjJTuEjh.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BHmIniXX.js → journeyDiagram-ZHPQQLJL-j07hDjg4.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DrCw5Y3V.js → kanban-definition-PNTS6WVX-DU8baSEs.js} +1 -1
- package/dist/assets/{linear-BZ0XZy8S.js → linear-Dj1tr9Bh.js} +1 -1
- package/dist/assets/{mermaid.core-D8Rkm6x8.js → mermaid.core-BeSGZMCl.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-BJNrLsxL.js → mindmap-definition-NLK3R4M7-LiRl-Bq2.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-vv5pMKB3.js → pegDiagram-GJSIUBJH-COL7EWof.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-BmKrvr-Q.js → pieDiagram-5QR66LMP-BnMXaara.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-BPbUBZ0J.js → quadrantDiagram-O4NWA36T-BjLcZ6bG.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-BAIvR6OT.js → railroadDiagram-XR7U4H2S-wKCzKLAA.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-19eXNruJ.js → requirementDiagram-PLB6GJNP-BjoTwmZ-.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-C9byyYhZ.js → sankeyDiagram-IPEJSGJF-CuGyR0Tn.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-J451N9gP.js → sequenceDiagram-PO4LG4MO-DxOzUuSx.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-h_eW-84j.js → sizeCapture-INFHLROL-B-bTrmx9.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-CbWBRuzI.js → stateDiagram-v2-GCMORJYK-D6ZflrZQ.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-BGWsOai2.js → swimlanes-2SLR337P-DKgdDJlH.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DSlLxTUH.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-M_CjZAFy.js → timeline-definition-EJHVYXUP-Dli4hqxc.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BPzYYGGa.js → usecaseDiagram-POWQR4AR-CQ8Cc1rN.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-Ch74mbiF.js → vennDiagram-UO4OBE2U-JEu7ZkzA.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-TAuQdz0L.js → wardleyDiagram-VNRHLVJA-DkFigbd0.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-Pb3KiukR.js → xychartDiagram-PMCCYNJV-DwOctln8.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/companion/src/routes.js +10 -0
- package/dist-server/container-mcp.js +81 -81
- package/dist-server/drivers/agents-proxy.js +183 -83
- package/dist-server/index.js +3608 -3149
- package/dist-server/openmausbot.js +576 -566
- package/dist-server/pair-cli.js +576 -566
- package/dist-server/server/apple-account-tools.js +83 -0
- package/dist-server/server/apple-data.js +236 -0
- package/dist-server/server/bot-package.js +3 -2
- package/dist-server/server/drivers/agents-catalog.js +2 -2
- package/dist-server/server/harness-import/adapters.js +13 -1
- package/dist-server/server/harness-import/apply.js +21 -41
- package/dist-server/server/harness-import/cli-skills.js +124 -0
- package/dist-server/server/harness-import/convert.js +2 -2
- package/dist-server/server/harness-import/grokbot.js +36 -0
- package/dist-server/server/harness-import/hermes.js +3 -2
- package/dist-server/server/index.js +15 -13
- package/dist-server/server/marketplace-search.js +25 -6
- package/dist-server/server/model-evidence-context.js +7 -0
- package/dist-server/server/model-evidence.js +6 -1
- package/dist-server/server/oauth-account-core.js +4 -1
- package/dist-server/server/oauth-account-internal.js +4 -2
- package/dist-server/server/oauth-account-tools.js +14 -11
- package/dist-server/server/personal-bot.js +3 -0
- package/dist-server/server/routes/accounts.js +22 -4
- package/dist-server/server/system-prompt.js +3 -3
- package/dist-server/shared/marketplace-match.js +16 -2
- package/dist-server/shared/model-evidence.js +13 -0
- package/dist-server/shared/oauth-providers.js +18 -5
- package/dist-server/vps-container-mcp.js +81 -81
- package/package.json +1 -1
- package/skills/reverse-engineer-anything/LICENSE-rea-agents.txt +21 -0
- package/skills/reverse-engineer-anything/SKILL.md +356 -0
- package/skills/reverse-engineer-anything/VENDORED.md +46 -0
- package/skills/reverse-engineer-anything/manifest.json +21 -0
- package/skills/reverse-engineer-anything/references/android-applications.md +36 -0
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
- package/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
- package/dist/assets/channel-ByXDKjNr.js +0 -1
- package/dist/assets/index-C36j3Mf7.css +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-Dye77wGY.js +0 -8
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// The atomic_accounts tools for the Apple account on this Mac. They run in
|
|
2
|
+
// oauth-account-tools.ts like the Google and Microsoft ones, but call the
|
|
3
|
+
// Apple data helper (apple-data.ts) instead of a web API: read only, and
|
|
4
|
+
// every result is labelled sensitivity: "personal".
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { APPLE_FAMILIES } from "../shared/oauth-providers.js";
|
|
7
|
+
import { AppleDataError } from "./apple-data.js";
|
|
8
|
+
import { missingFamilies } from "./oauth-accounts.js";
|
|
9
|
+
import { providerLabel } from "./oauth-account-core.js";
|
|
10
|
+
export { providerLabel };
|
|
11
|
+
const base = z.object({ account: z.string().max(320).optional() });
|
|
12
|
+
const instant = z.string().max(64);
|
|
13
|
+
const eventsArgs = base.extend({ timeMin: instant, timeMax: instant, calendar: z.string().min(1).max(320).optional(), max: z.number().int().min(1).max(100).optional() }).strict();
|
|
14
|
+
const remindersArgs = base.extend({ list: z.string().min(1).max(320).optional(), completed: z.boolean().optional(), max: z.number().int().min(1).max(200).optional() }).strict();
|
|
15
|
+
const contactsArgs = base.extend({ q: z.string().min(1).max(320), max: z.number().int().min(1).max(50).optional() }).strict();
|
|
16
|
+
const drivePath = z.string().max(1_024).refine((value) => !value.split("/").includes(".."), "path must stay inside iCloud Drive");
|
|
17
|
+
const listArgs = base.extend({ path: drivePath.optional() }).strict();
|
|
18
|
+
const readArgs = base.extend({ path: drivePath.min(1) }).strict();
|
|
19
|
+
const NOTE = " Read only. Personal data: never post it in a shared room or pass it to another bot.";
|
|
20
|
+
const READS = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
21
|
+
const schema = (properties, required = []) => ({
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: { account: { type: "string", description: "Leave out: there is one Apple account." }, ...properties },
|
|
24
|
+
...(required.length ? { required } : {}),
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
});
|
|
27
|
+
const tool = (name, family, description, inputSchema, args) => ({ name, provider: "apple", family, description: description + NOTE, inputSchema, annotations: READS, args });
|
|
28
|
+
export const APPLE_TOOLS = [
|
|
29
|
+
tool("apple_calendar_list_events", "appleCalendar", "List Apple Calendar events on this Mac between two times (every calendar the Mac syncs, including iCloud).", schema({
|
|
30
|
+
timeMin: { type: "string", description: "Start of the window, ISO 8601 with a time zone (e.g. 2026-10-01T00:00:00Z)." },
|
|
31
|
+
timeMax: { type: "string", description: "End of the window, ISO 8601 with a time zone." },
|
|
32
|
+
calendar: { type: "string", description: "Only this calendar, by name." },
|
|
33
|
+
max: { type: "integer", minimum: 1, maximum: 100, description: "Most events to return (default 25)." },
|
|
34
|
+
}, ["timeMin", "timeMax"]), eventsArgs),
|
|
35
|
+
tool("apple_reminders_list", "appleReminders", "List Apple Reminders on this Mac: open ones by due date, or completed ones.", schema({
|
|
36
|
+
list: { type: "string", description: "Only this Reminders list, by name." },
|
|
37
|
+
completed: { type: "boolean", description: "True for completed reminders instead of open ones." },
|
|
38
|
+
max: { type: "integer", minimum: 1, maximum: 200, description: "Most reminders to return (default 50)." },
|
|
39
|
+
}), remindersArgs),
|
|
40
|
+
tool("apple_contacts_search", "appleContacts", "Find Apple Contacts on this Mac by name or email address: names, organization, emails and phone numbers.", schema({
|
|
41
|
+
q: { type: "string", description: "A name, or a full email address." },
|
|
42
|
+
max: { type: "integer", minimum: 1, maximum: 50, description: "Most contacts to return (default 10)." },
|
|
43
|
+
}, ["q"]), contactsArgs),
|
|
44
|
+
tool("icloud_drive_list", "icloudDrive", "List one iCloud Drive folder on this Mac: names, sizes, dates and whether each file is downloaded.", schema({
|
|
45
|
+
path: { type: "string", description: "Folder path inside iCloud Drive, e.g. Documents/Taxes. Empty for the top." },
|
|
46
|
+
}), listArgs),
|
|
47
|
+
tool("icloud_drive_read", "icloudDrive", "Read a text file from iCloud Drive on this Mac by its path from icloud_drive_list. Other files return their details only.", schema({
|
|
48
|
+
path: { type: "string", description: "File path inside iCloud Drive." },
|
|
49
|
+
}, ["path"]), readArgs),
|
|
50
|
+
];
|
|
51
|
+
/** One helper call. The reply's own fields go back with the account and the
|
|
52
|
+
* personal label; helper error codes become plain sentences. */
|
|
53
|
+
async function apple(ctx, account, op, args) {
|
|
54
|
+
if (!ctx.apple)
|
|
55
|
+
throw new AppleDataError("helper-missing");
|
|
56
|
+
const { id: _id, ...reply } = await ctx.apple.call(op, args);
|
|
57
|
+
return JSON.stringify({ account: account.email, sensitivity: "personal", ...reply }, null, 1);
|
|
58
|
+
}
|
|
59
|
+
const events = (ctx, account, args) => apple(ctx, account, "events", { from: args.timeMin, to: args.timeMax, calendar: args.calendar, max: args.max ?? 25 });
|
|
60
|
+
const reminders = (ctx, account, args) => apple(ctx, account, "reminders", { list: args.list, completed: args.completed ?? false, max: args.max ?? 50 });
|
|
61
|
+
const contacts = (ctx, account, args) => apple(ctx, account, "contacts", { query: args.q, max: args.max ?? 10 });
|
|
62
|
+
const driveList = (ctx, account, args) => apple(ctx, account, "driveList", { path: args.path ?? "" });
|
|
63
|
+
const driveRead = (ctx, account, args) => apple(ctx, account, "driveRead", { path: args.path });
|
|
64
|
+
export const APPLE_RUNNERS = {
|
|
65
|
+
apple_calendar_list_events: events,
|
|
66
|
+
apple_reminders_list: reminders,
|
|
67
|
+
apple_contacts_search: contacts,
|
|
68
|
+
icloud_drive_list: driveList,
|
|
69
|
+
icloud_drive_read: driveRead,
|
|
70
|
+
};
|
|
71
|
+
export const APPLE_FAMILY_LABEL = {
|
|
72
|
+
appleCalendar: "Apple Calendar",
|
|
73
|
+
appleReminders: "Apple Reminders",
|
|
74
|
+
appleContacts: "Apple Contacts",
|
|
75
|
+
icloudDrive: "iCloud Drive",
|
|
76
|
+
};
|
|
77
|
+
/** The families an account cannot use yet. Apple keeps the ones turned on in
|
|
78
|
+
* `scopes`; Google and Microsoft keep real OAuth scopes there. */
|
|
79
|
+
export function accountMissing(account) {
|
|
80
|
+
if (account.provider === "apple")
|
|
81
|
+
return APPLE_FAMILIES.filter((family) => !account.scopes.includes(family));
|
|
82
|
+
return missingFamilies(account.provider, account.scopes);
|
|
83
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// The Apple account on this Mac: a client for the Apple data helper
|
|
2
|
+
// (electron/resources/apple-data-helper.swift, line-delimited JSON like
|
|
3
|
+
// apple-intelligence.ts) and the account record Settings → Accounts shows.
|
|
4
|
+
// There is no token: macOS's own permission for each family is the grant.
|
|
5
|
+
// The record lives in config.json (`appleAccount`), never in the token vault.
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { accessSync, constants } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { APPLE_ACCOUNT_ID, APPLE_FAMILIES } from "../shared/oauth-providers.js";
|
|
10
|
+
import { withPersonalConnection } from "./personal-bot.js";
|
|
11
|
+
import { SERVER_ROOT } from "./proxy-paths.js";
|
|
12
|
+
export class AppleDataError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
constructor(code) {
|
|
15
|
+
super(appleErrorMessage(code));
|
|
16
|
+
this.name = "AppleDataError";
|
|
17
|
+
this.code = code;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const MESSAGES = {
|
|
21
|
+
"helper-missing": "This build of Atomic cannot read Apple data on this computer.",
|
|
22
|
+
"helper-failed": "Atomic's Apple data reader stopped unexpectedly. Try again.",
|
|
23
|
+
"timeout": "Reading Apple data took too long.",
|
|
24
|
+
"not-authorized": "macOS has not allowed Atomic to read this. Ask the person to turn it on in Settings → Accounts, or allow Atomic in System Settings → Privacy & Security.",
|
|
25
|
+
"unavailable": "iCloud Drive is not set up on this Mac.",
|
|
26
|
+
"bad-date": "timeMin and timeMax must be ISO 8601 date-times with a time zone.",
|
|
27
|
+
"bad-window": "timeMax must be after timeMin.",
|
|
28
|
+
"bad-path": "That path is outside iCloud Drive.",
|
|
29
|
+
"bad-query": "Give a name or email address to look for.",
|
|
30
|
+
"no-such-calendar": "There is no calendar with that name.",
|
|
31
|
+
"no-such-list": "There is no Reminders list with that name.",
|
|
32
|
+
"not-a-folder": "That path is not a folder in iCloud Drive.",
|
|
33
|
+
"not-a-file": "That path is a folder, not a file.",
|
|
34
|
+
};
|
|
35
|
+
export function appleErrorMessage(code) {
|
|
36
|
+
return MESSAGES[code] ?? `Reading Apple data failed (${code}).`;
|
|
37
|
+
}
|
|
38
|
+
const HELPER = join("Atomic Apple Data.app", "Contents", "MacOS", "apple-data-helper");
|
|
39
|
+
/** Where the helper is, or null on a build or machine without it. */
|
|
40
|
+
export function resolveAppleDataHelper(env = process.env, platform = process.platform, arch = process.arch, serverRoot = SERVER_ROOT) {
|
|
41
|
+
if (platform !== "darwin")
|
|
42
|
+
return null;
|
|
43
|
+
const candidates = [
|
|
44
|
+
env.ATOMIC_APPLE_DATA_HELPER,
|
|
45
|
+
env.OMB_RESOURCES_PATH && join(env.OMB_RESOURCES_PATH, HELPER),
|
|
46
|
+
join(serverRoot, "..", HELPER),
|
|
47
|
+
join(serverRoot, "..", "dist-native", arch, HELPER),
|
|
48
|
+
];
|
|
49
|
+
for (const candidate of candidates) {
|
|
50
|
+
if (!candidate)
|
|
51
|
+
continue;
|
|
52
|
+
try {
|
|
53
|
+
accessSync(candidate, constants.X_OK);
|
|
54
|
+
return candidate;
|
|
55
|
+
}
|
|
56
|
+
catch { }
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/** A long-lived helper, started on first use and again after it exits. The
|
|
61
|
+
* helper answers in order, but replies are matched by id all the same. */
|
|
62
|
+
export function createAppleDataClient(options) {
|
|
63
|
+
const pending = new Map();
|
|
64
|
+
let child = null;
|
|
65
|
+
let counter = 0;
|
|
66
|
+
const failAll = (error) => {
|
|
67
|
+
for (const entry of pending.values())
|
|
68
|
+
entry.reject(error);
|
|
69
|
+
pending.clear();
|
|
70
|
+
};
|
|
71
|
+
const start = () => {
|
|
72
|
+
if (child)
|
|
73
|
+
return child;
|
|
74
|
+
const proc = spawn(options.command, options.args ?? [], { stdio: ["pipe", "pipe", "pipe"] });
|
|
75
|
+
child = proc;
|
|
76
|
+
let buffer = "";
|
|
77
|
+
proc.stdout.setEncoding("utf8");
|
|
78
|
+
proc.stdout.on("data", (chunk) => {
|
|
79
|
+
buffer += chunk;
|
|
80
|
+
if (buffer.length > 8_000_000)
|
|
81
|
+
return void proc.kill();
|
|
82
|
+
let newline;
|
|
83
|
+
while ((newline = buffer.indexOf("\n")) !== -1) {
|
|
84
|
+
const line = buffer.slice(0, newline).trim();
|
|
85
|
+
buffer = buffer.slice(newline + 1);
|
|
86
|
+
let message;
|
|
87
|
+
try {
|
|
88
|
+
message = JSON.parse(line);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (!message || typeof message !== "object" || Array.isArray(message))
|
|
94
|
+
continue;
|
|
95
|
+
const reply = message;
|
|
96
|
+
const entry = typeof reply.id === "string" ? pending.get(reply.id) : undefined;
|
|
97
|
+
if (!entry)
|
|
98
|
+
continue;
|
|
99
|
+
pending.delete(reply.id);
|
|
100
|
+
if (typeof reply.error === "string")
|
|
101
|
+
entry.reject(new AppleDataError(reply.error));
|
|
102
|
+
else
|
|
103
|
+
entry.resolve(reply);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
proc.stderr.resume();
|
|
107
|
+
const gone = () => {
|
|
108
|
+
if (child !== proc)
|
|
109
|
+
return;
|
|
110
|
+
child = null;
|
|
111
|
+
failAll(new AppleDataError("helper-failed"));
|
|
112
|
+
};
|
|
113
|
+
proc.on("error", gone);
|
|
114
|
+
proc.on("exit", gone);
|
|
115
|
+
proc.stdin.on("error", () => { });
|
|
116
|
+
return proc;
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
call(op, args = {}) {
|
|
120
|
+
if (!options.command)
|
|
121
|
+
return Promise.reject(new AppleDataError("helper-missing"));
|
|
122
|
+
const id = `a${++counter}`;
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
// A permission prompt waits for the person, so allow it minutes.
|
|
125
|
+
const timer = setTimeout(() => {
|
|
126
|
+
if (pending.delete(id))
|
|
127
|
+
reject(new AppleDataError("timeout"));
|
|
128
|
+
}, options.requestTimeoutMs ?? (op === "request" ? 300_000 : 60_000));
|
|
129
|
+
pending.set(id, {
|
|
130
|
+
resolve: (reply) => { clearTimeout(timer); resolve(reply); },
|
|
131
|
+
reject: (error) => { clearTimeout(timer); reject(error); },
|
|
132
|
+
});
|
|
133
|
+
try {
|
|
134
|
+
start().stdin.write(`${JSON.stringify({ ...args, op, id })}\n`);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
pending.delete(id);
|
|
138
|
+
clearTimeout(timer);
|
|
139
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
dispose() {
|
|
144
|
+
failAll(new AppleDataError("helper-failed"));
|
|
145
|
+
const proc = child;
|
|
146
|
+
child = null;
|
|
147
|
+
proc?.stdin.end();
|
|
148
|
+
proc?.kill();
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const isAppleFamily = (value) => APPLE_FAMILIES.includes(value);
|
|
153
|
+
export function appleAccountRecord(raw) {
|
|
154
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
155
|
+
return null;
|
|
156
|
+
const value = raw;
|
|
157
|
+
if (typeof value.addedAt !== "number" || !Number.isFinite(value.addedAt))
|
|
158
|
+
return null;
|
|
159
|
+
const families = Array.isArray(value.families) ? [...new Set(value.families.filter(isAppleFamily))] : [];
|
|
160
|
+
return { addedAt: value.addedAt, families };
|
|
161
|
+
}
|
|
162
|
+
/** The display name the person and bots see; there is no Apple ID email on
|
|
163
|
+
* this path, and a bot never needs one: there is only one Apple account. */
|
|
164
|
+
export const APPLE_ACCOUNT_LABEL = "iCloud on this Mac";
|
|
165
|
+
/** The account in the same shape the tools use for Google and Microsoft.
|
|
166
|
+
* `scopes` holds the families turned on, so a family check reads alike. */
|
|
167
|
+
export function appleAllowedAccount(record) {
|
|
168
|
+
return { id: APPLE_ACCOUNT_ID, provider: "apple", email: APPLE_ACCOUNT_LABEL, addedAt: record.addedAt, scopes: [...record.families] };
|
|
169
|
+
}
|
|
170
|
+
export function appleConnectedAccount(record) {
|
|
171
|
+
const missing = APPLE_FAMILIES.filter((family) => !record.families.includes(family));
|
|
172
|
+
return { id: APPLE_ACCOUNT_ID, provider: "apple", email: APPLE_ACCOUNT_LABEL, addedAt: record.addedAt, status: "ok", ...(missing.length ? { missing: missing } : {}) };
|
|
173
|
+
}
|
|
174
|
+
export function appleProviderStatus(record, configured) {
|
|
175
|
+
return { id: "apple", label: "Apple", configured, accounts: record ? [appleConnectedAccount(record)] : [] };
|
|
176
|
+
}
|
|
177
|
+
/** The record after one family is turned on. */
|
|
178
|
+
export function withAppleFamily(record, family, now) {
|
|
179
|
+
const current = record ?? { addedAt: now, families: [] };
|
|
180
|
+
return { ...current, families: current.families.includes(family) ? current.families : [...current.families, family] };
|
|
181
|
+
}
|
|
182
|
+
/** Everything index.ts needs for the Apple account: the account manager bots
|
|
183
|
+
* are checked against (OAuth plus Apple), the helper client, and the
|
|
184
|
+
* Settings → Accounts routes (only where the helper is). The record lives in
|
|
185
|
+
* the Personal settings, and the account is marked Personal when added, so
|
|
186
|
+
* only the Private Bot can be given it (connectionsFor keeps company bots out). */
|
|
187
|
+
export function createAppleAccount(deps) {
|
|
188
|
+
const helper = deps.helper === undefined ? resolveAppleDataHelper() : deps.helper;
|
|
189
|
+
const client = createAppleDataClient({ command: helper });
|
|
190
|
+
const stored = () => deps.personal().appleAccount ?? null;
|
|
191
|
+
const save = (record) => deps.savePersonal({ ...withPersonalConnection(deps.personal(), "accounts", APPLE_ACCOUNT_ID, record !== null), appleAccount: record ?? undefined });
|
|
192
|
+
const routes = helper ? {
|
|
193
|
+
status: () => appleProviderStatus(stored(), true),
|
|
194
|
+
turnOn: async (family) => {
|
|
195
|
+
let reply;
|
|
196
|
+
try {
|
|
197
|
+
reply = await client.call("request", { family });
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
return error instanceof AppleDataError ? error.message : "Atomic could not ask macOS for this. Try again.";
|
|
201
|
+
}
|
|
202
|
+
if (reply.granted !== true)
|
|
203
|
+
return "macOS did not allow Atomic to read this. Allow Atomic in System Settings → Privacy & Security, then try again.";
|
|
204
|
+
const before = stored();
|
|
205
|
+
// Turning on another family keeps whatever Personal choice the person made.
|
|
206
|
+
if (before)
|
|
207
|
+
deps.savePersonal({ ...deps.personal(), appleAccount: withAppleFamily(before, family, Date.now()) });
|
|
208
|
+
else
|
|
209
|
+
save(withAppleFamily(null, family, Date.now()));
|
|
210
|
+
return null;
|
|
211
|
+
},
|
|
212
|
+
remove: () => {
|
|
213
|
+
if (!stored())
|
|
214
|
+
return false;
|
|
215
|
+
save(null);
|
|
216
|
+
return true;
|
|
217
|
+
},
|
|
218
|
+
} : undefined;
|
|
219
|
+
const accounts = {
|
|
220
|
+
account: (id) => {
|
|
221
|
+
if (id !== APPLE_ACCOUNT_ID)
|
|
222
|
+
return deps.oauth.account(id);
|
|
223
|
+
const current = stored();
|
|
224
|
+
return current ? appleAllowedAccount(current) : null;
|
|
225
|
+
},
|
|
226
|
+
accessToken: (id) => deps.oauth.accessToken(id),
|
|
227
|
+
invalidate: (id) => deps.oauth.invalidate(id),
|
|
228
|
+
};
|
|
229
|
+
return {
|
|
230
|
+
accounts,
|
|
231
|
+
client,
|
|
232
|
+
routes,
|
|
233
|
+
connectedIds: () => (stored() ? [APPLE_ACCOUNT_ID] : []),
|
|
234
|
+
status: () => appleProviderStatus(stored(), Boolean(helper)),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
@@ -148,7 +148,8 @@ const packageSchema = z.object({
|
|
|
148
148
|
}),
|
|
149
149
|
playbooks: z.array(key).max(40).optional(),
|
|
150
150
|
skills: z.array(skillName).max(BOT_PACKAGE_MAX_SKILLS).optional(),
|
|
151
|
-
|
|
151
|
+
// Empty for a harness import that brought skills alone (command-line tools).
|
|
152
|
+
})).max(200),
|
|
152
153
|
chiefOfStaff: key.optional(),
|
|
153
154
|
rooms: z.array(z.object({
|
|
154
155
|
key,
|
|
@@ -367,7 +368,7 @@ export function renderBotPackageMarkdown(document) {
|
|
|
367
368
|
const connections = pkg.requirements.apps.length
|
|
368
369
|
? pkg.requirements.apps.map((app) => `- **${app.label}${app.optional ? " (optional)" : ""}:** ${app.reason}`).join("\n")
|
|
369
370
|
: "- No connected apps are required.";
|
|
370
|
-
const markdown = `---\n${frontmatter}\n---\n\n# ${pkg.name}\n\n${pkg.tagline}\n\n> **Give this file to your Chief of Staff.** It is the complete team blueprint. Any agent system can run it; Atomic can also install it directly.\n\n## Activation\n\nYou are the Chief of Staff for this blueprint. Read the whole document before acting. Confirm the user's goal and any missing inputs, then create or delegate to the specialist roles below. Preserve their names, ownership, boundaries, shared-room rules, and playbooks. If your platform cannot literally spawn agents, perform the roles one at a time and keep their outputs clearly separated.\n\nNever request pasted passwords or secret keys. Use the platform's normal connection flow. Do not send messages, publish content, spend money, delete data, or enable a schedule without the user's explicit approval. All routines start paused.\n\n## Mission\n\n${pkg.summary}\n\n## Outcomes\n\n${list(pkg.outcomes)}\n\n## Connections\n\n${connections}\n\n## Team\n\n${agents}\n\n## Chief of Staff\n\nThe Chief of Staff role is \`${pkg.chiefOfStaff ?? pkg.agents[0]
|
|
371
|
+
const markdown = `---\n${frontmatter}\n---\n\n# ${pkg.name}\n\n${pkg.tagline}\n\n> **Give this file to your Chief of Staff.** It is the complete team blueprint. Any agent system can run it; Atomic can also install it directly.\n\n## Activation\n\nYou are the Chief of Staff for this blueprint. Read the whole document before acting. Confirm the user's goal and any missing inputs, then create or delegate to the specialist roles below. Preserve their names, ownership, boundaries, shared-room rules, and playbooks. If your platform cannot literally spawn agents, perform the roles one at a time and keep their outputs clearly separated.\n\nNever request pasted passwords or secret keys. Use the platform's normal connection flow. Do not send messages, publish content, spend money, delete data, or enable a schedule without the user's explicit approval. All routines start paused.\n\n## Mission\n\n${pkg.summary}\n\n## Outcomes\n\n${list(pkg.outcomes)}\n\n## Connections\n\n${connections}\n\n## Team\n\n${agents}\n\n## Chief of Staff\n\nThe Chief of Staff role is \`${pkg.chiefOfStaff ?? pkg.agents[0]?.key ?? "chibi"}\`. This role owns delegation, synthesis, conflict resolution, and the final answer to the user.\n${rooms ? `\n## Shared rooms\n\n${rooms}\n` : ""}${routines ? `\n## Suggested routines\n\n${routines}\n` : ""}${playbooks ? `\n## Playbooks\n\n${playbooks}\n` : ""}${examples ? `\n## Example job\n\n${examples}\n` : ""}\n## Completion rule\n\nReturn one clear result to the user, distinguish evidence from inference, cite source links when the work uses external material, and state what still needs human approval or a connected app.\n`;
|
|
371
372
|
if (Buffer.byteLength(markdown) > BOT_PACKAGE_MARKDOWN_MAX_BYTES)
|
|
372
373
|
throw new Error("The bot playbook is too large");
|
|
373
374
|
return markdown;
|
|
@@ -453,7 +453,7 @@ const toolDefinitions = (externalRuntime) => [
|
|
|
453
453
|
credentialTool, ...vaultTools,
|
|
454
454
|
{
|
|
455
455
|
name: "marketplace_search",
|
|
456
|
-
description: "Find an app or service the person wants connected in Atomic's Marketplace: official servers Atomic connects, and official apps through their Claude account. Then call open_marketplace. Never offer to build a connection or a community server.",
|
|
456
|
+
description: "Find an app or service the person wants connected in Atomic's Marketplace: accounts built into Atomic (Google, Microsoft, Apple iCloud on a Mac), official servers Atomic connects, and official apps through their Claude account. Then call open_marketplace. Never offer to build a connection or a community server.",
|
|
457
457
|
inputSchema: {
|
|
458
458
|
type: "object",
|
|
459
459
|
additionalProperties: false,
|
|
@@ -463,7 +463,7 @@ const toolDefinitions = (externalRuntime) => [
|
|
|
463
463
|
},
|
|
464
464
|
{
|
|
465
465
|
name: "open_marketplace",
|
|
466
|
-
description: "Show the person a button that opens Settings > Marketplace on this service. With no match it offers to send the request to Chibitek as an idea. Then reply in one or two plain sentences.",
|
|
466
|
+
description: "Show the person a button that opens Settings > Marketplace on this service (Settings > Accounts for an account built into Atomic). With no match it offers to send the request to Chibitek as an idea. Then reply in one or two plain sentences.",
|
|
467
467
|
inputSchema: {
|
|
468
468
|
type: "object",
|
|
469
469
|
additionalProperties: false,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// (model.ts), and says where its conversations are. Conversion, preview and
|
|
4
4
|
// apply are shared.
|
|
5
5
|
import { appRules, checkBackupFolder } from "./apply.js";
|
|
6
|
+
import { checkCliSkillsFolder, CLI_SKILLS_HISTORY, CLI_SKILLS_KIND, CLI_SKILLS_LABEL, detectCliSkills, readCliSkills } from "./cli-skills.js";
|
|
6
7
|
import { convertHarness } from "./convert.js";
|
|
7
8
|
import { readGrokBackup } from "./grokbot.js";
|
|
8
9
|
import { checkHermesFolder, detectHermes, hermesRules, readHermesHome } from "./hermes.js";
|
|
@@ -26,7 +27,18 @@ export const HERMES_ADAPTER = {
|
|
|
26
27
|
rules: hermesRules,
|
|
27
28
|
history: HERMES_HISTORY,
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
+
/** Skills from Claude Code, Codex, Gemini CLI and Grok CLI on this computer.
|
|
31
|
+
* They land on Chibi, who routes work to the bot that holds a skill. */
|
|
32
|
+
export const CLI_SKILLS_ADAPTER = {
|
|
33
|
+
id: CLI_SKILLS_KIND,
|
|
34
|
+
label: CLI_SKILLS_LABEL,
|
|
35
|
+
detect: () => detectCliSkills().map((found) => ({ root: found.root, bots: 0, skills: found.skills })),
|
|
36
|
+
checkFolder: checkCliSkillsFolder,
|
|
37
|
+
read: (root) => readCliSkills(root),
|
|
38
|
+
rules: hermesRules,
|
|
39
|
+
history: CLI_SKILLS_HISTORY,
|
|
40
|
+
};
|
|
41
|
+
export const HARNESS_ADAPTERS = [HERMES_ADAPTER, GROKBOT_ADAPTER, CLI_SKILLS_ADAPTER];
|
|
30
42
|
export const harnessAdapter = (id) => HARNESS_ADAPTERS.find((adapter) => adapter.id === id);
|
|
31
43
|
/** The in-app conversion: credentials as references, disabled jobs and
|
|
32
44
|
* skipped items offered unticked. */
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
// rest of the app uses. The client only ever names package keys; the server
|
|
4
4
|
// re-reads the backup for both steps, so no persona text or credential
|
|
5
5
|
// crosses the wire, and every credential arrives as an `${ENV}` reference.
|
|
6
|
-
import { existsSync, statSync } from "node:fs";
|
|
7
|
-
import { homedir } from "node:os";
|
|
8
|
-
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
9
6
|
import { packageAgentAsMember } from "../bot-package.js";
|
|
10
7
|
import { parseSkillMd, SKILL_FILE_MAX_BYTES } from "../skills.js";
|
|
11
8
|
import { maskedMcpTarget, mcpTargetKey } from "../mcp-import-detect.js";
|
|
@@ -28,41 +25,20 @@ export const importIdentity = (result) => ({
|
|
|
28
25
|
label: result.report.source.label ?? GROKBOT_IDENTITY.label,
|
|
29
26
|
packageId: result.pkg.package.id,
|
|
30
27
|
});
|
|
28
|
+
/** A source with no bots (skills from command-line tools) puts its skills on
|
|
29
|
+
* Chibi, the Primary Bot, who routes work to the bot that holds a skill. */
|
|
30
|
+
export function skillsOnlyHome(report, bots) {
|
|
31
|
+
return report.bots.length ? undefined : bots.find((bot) => bot.builtin === "chibi");
|
|
32
|
+
}
|
|
33
|
+
/** `grokbot:workflows/<slug>`, `hermes:skills/<slug>`, `cli-skills:.claude/skills/<slug>`:
|
|
34
|
+
* where an installed skill came from. */
|
|
35
|
+
export const skillProvenance = (identity, skill) => identity.kind === "grokbot" ? `grokbot:workflows/${skill.slug}`
|
|
36
|
+
: identity.kind === "cli-skills" ? `cli-skills:${skill.sourcePath}`
|
|
37
|
+
: `${identity.kind}:skills/${skill.slug}`;
|
|
31
38
|
/** `grokbot:<uuid>`, `hermes:<profile>`: the source bot an Atomic bot came from. */
|
|
32
39
|
export const sourceRefFor = (identity, sourceId) => `${identity.kind}:${sourceId}`;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export function checkBackupFolder(input) {
|
|
36
|
-
if (typeof input !== "string" || !input.trim()) {
|
|
37
|
-
return { ok: false, code: "path_required", error: "Choose the folder that holds your Grok Bot backup." };
|
|
38
|
-
}
|
|
39
|
-
if (input.length > 4096 || input.includes("\0"))
|
|
40
|
-
return { ok: false, code: "not_found", error: "That folder does not exist." };
|
|
41
|
-
let path = input.trim();
|
|
42
|
-
if (path === "~" || path.startsWith("~/"))
|
|
43
|
-
path = join(homedir(), path.slice(1));
|
|
44
|
-
if (!isAbsolute(path)) {
|
|
45
|
-
return { ok: false, code: "not_absolute", error: "Enter the full path to the backup folder, for example /Users/you/Downloads/grokbot-backup." };
|
|
46
|
-
}
|
|
47
|
-
path = resolve(path);
|
|
48
|
-
if (!existsSync(path))
|
|
49
|
-
return { ok: false, code: "not_found", error: "That folder does not exist." };
|
|
50
|
-
if (!statSync(path).isDirectory())
|
|
51
|
-
return { ok: false, code: "not_folder", error: "That path is a file. Choose the backup folder instead." };
|
|
52
|
-
const isBackup = (root) => {
|
|
53
|
-
const agents = join(root, "agent-data", "agents");
|
|
54
|
-
return existsSync(agents) && statSync(agents).isDirectory();
|
|
55
|
-
};
|
|
56
|
-
if (isBackup(path))
|
|
57
|
-
return { ok: true, root: path };
|
|
58
|
-
if (basename(path) === "agent-data" && isBackup(dirname(path)))
|
|
59
|
-
return { ok: true, root: dirname(path) };
|
|
60
|
-
return {
|
|
61
|
-
ok: false,
|
|
62
|
-
code: "not_grokbot",
|
|
63
|
-
error: "This folder is not a Grok Bot backup. Choose the folder that contains agent-data.",
|
|
64
|
-
};
|
|
65
|
-
}
|
|
40
|
+
// ── the backup folder ──────────────────────────────────────────────────
|
|
41
|
+
export { checkBackupFolder } from "./grokbot.js";
|
|
66
42
|
/** The conversion the in-app import uses: credentials as references, disabled
|
|
67
43
|
* automations included (offered unticked), and plain schedules in the zone
|
|
68
44
|
* Grok Bot ran them in (Eastern), whatever this computer's zone is. */
|
|
@@ -257,14 +233,15 @@ export function buildPreview(result, root, deps, candidates = []) {
|
|
|
257
233
|
apps: (botApps.get(bot.key) ?? []).map((app) => ({ slug: app.slug, label: app.label, status: app.status })),
|
|
258
234
|
notes: (bot.notes ?? []).map(safe),
|
|
259
235
|
}));
|
|
236
|
+
const skillHome = skillsOnlyHome(report, botsNow);
|
|
260
237
|
const skills = report.skills.map((skill) => {
|
|
261
|
-
const targets = skill.ownerKeys.map((key) => botIdByKey.get(key)).filter((id) => Boolean(id));
|
|
238
|
+
const targets = skillHome ? [skillHome.id] : skill.ownerKeys.map((key) => botIdByKey.get(key)).filter((id) => Boolean(id));
|
|
262
239
|
return {
|
|
263
240
|
slug: skill.slug,
|
|
264
241
|
offered: skill.offered ?? null,
|
|
265
242
|
description: safe(descriptionOf(result, skill.slug)),
|
|
266
|
-
owners: skill.ownerKeys.map((key) => safe(botName.get(key) ?? key)),
|
|
267
|
-
alreadyImported:
|
|
243
|
+
owners: skillHome ? [safe(skillHome.name)] : skill.ownerKeys.map((key) => safe(botName.get(key) ?? key)),
|
|
244
|
+
alreadyImported: targets.length > 0 && (skillHome || targets.length === skill.ownerKeys.length) &&
|
|
268
245
|
targets.every((id) => deps.listSkills(id).some((installed) => installed.name === skill.slug)),
|
|
269
246
|
secrets: refCount(result, "skill", skill.slug),
|
|
270
247
|
};
|
|
@@ -720,9 +697,12 @@ export async function applyImport(result, selection, deps) {
|
|
|
720
697
|
out.needsAttention.playbookTriggers.push(safe(`${name} (${target.name}): ${trigger}`));
|
|
721
698
|
}
|
|
722
699
|
// Skills install switched off, the way every imported skill does.
|
|
700
|
+
const skillHome = skillsOnlyHome(report, botsNow);
|
|
723
701
|
for (const slug of selection.skills) {
|
|
724
702
|
const skill = reportSkill.get(slug);
|
|
725
|
-
const owners =
|
|
703
|
+
const owners = skillHome
|
|
704
|
+
? [{ id: skillHome.id, name: skillHome.name, created: false }]
|
|
705
|
+
: skill.ownerKeys.map((key) => targets.get(key)).filter((target) => Boolean(target));
|
|
726
706
|
if (!owners.length) {
|
|
727
707
|
out.skipped.push({ kind: "skill", name: slug, reason: "None of the bots that use it were selected" });
|
|
728
708
|
continue;
|
|
@@ -741,7 +721,7 @@ export async function applyImport(result, selection, deps) {
|
|
|
741
721
|
out.alreadyImported.skills++;
|
|
742
722
|
continue;
|
|
743
723
|
}
|
|
744
|
-
const installed = deps.installSkill(owner.id, identity
|
|
724
|
+
const installed = deps.installSkill(owner.id, skillProvenance(identity, skill), [{ path: "SKILL.md", content }]);
|
|
745
725
|
if ("error" in installed) {
|
|
746
726
|
out.skipped.push({ kind: "skill", name: slug, reason: `Could not be added to ${owner.name}: ${installed.error}` });
|
|
747
727
|
continue;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Skills from the command-line tools on this computer: Claude Code
|
|
2
|
+
// (~/.claude/skills), Codex (~/.codex/skills and the shared ~/.agents/skills),
|
|
3
|
+
// Gemini CLI (~/.gemini/skills) and Grok CLI (~/.grok/skills). Read-only: the
|
|
4
|
+
// source folders are never changed. Atomic keeps one copy of each skill, so
|
|
5
|
+
// the same skill found in several tools is offered once; the copies are
|
|
6
|
+
// listed unticked as exact copies.
|
|
7
|
+
import { existsSync, statSync } from "node:fs";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
10
|
+
import { fingerprint, readSkillFolder } from "./hermes.js";
|
|
11
|
+
import { createSourceReader } from "./source-reader.js";
|
|
12
|
+
export const CLI_SKILLS_KIND = "cli-skills";
|
|
13
|
+
export const CLI_SKILLS_LABEL = "Command-line tools";
|
|
14
|
+
/** Where each tool keeps its skills, relative to the home folder. Order is
|
|
15
|
+
* precedence: when the same skill name differs between tools, the first wins. */
|
|
16
|
+
export const CLI_SKILL_HOMES = [
|
|
17
|
+
{ tool: "Claude Code", dir: ".claude/skills" },
|
|
18
|
+
{ tool: "Codex", dir: ".codex/skills" },
|
|
19
|
+
{ tool: "Codex", dir: ".agents/skills" },
|
|
20
|
+
{ tool: "Gemini CLI", dir: ".gemini/skills" },
|
|
21
|
+
{ tool: "Grok CLI", dir: ".grok/skills" },
|
|
22
|
+
];
|
|
23
|
+
// ponytail: $CODEX_HOME / $GROK_HOME / $CLAUDE_CONFIG_DIR overrides are not followed; type the folder instead.
|
|
24
|
+
const SLUG = "[A-Za-z0-9][A-Za-z0-9._-]*";
|
|
25
|
+
const HOME_DIRS = CLI_SKILL_HOMES.map((home) => home.dir.replace(/\./g, "\\.")).join("|");
|
|
26
|
+
/** `<skills dir>/<slug>` in a home folder, or `<slug>` in a plain skills folder. */
|
|
27
|
+
const SKILL = `(?:(?:${HOME_DIRS})/)?${SLUG}`;
|
|
28
|
+
export const CLI_SKILLS_ALLOWLIST = {
|
|
29
|
+
files: [
|
|
30
|
+
new RegExp(`^${SKILL}/SKILL\\.md$`),
|
|
31
|
+
new RegExp(`^${SKILL}/(?:references|scripts)/${SLUG}$`),
|
|
32
|
+
],
|
|
33
|
+
dirs: [
|
|
34
|
+
/^$/,
|
|
35
|
+
new RegExp(`^(?:${HOME_DIRS})$`),
|
|
36
|
+
new RegExp(`^${SKILL}$`),
|
|
37
|
+
new RegExp(`^${SKILL}/(?:references|scripts)$`),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
const isSlug = (name) => new RegExp(`^${SLUG}$`).test(name);
|
|
41
|
+
/** Skill folders under `base` ("" for the root itself). */
|
|
42
|
+
function skillDirs(reader, base) {
|
|
43
|
+
const out = [];
|
|
44
|
+
for (const entry of reader.list(base, "dir")) {
|
|
45
|
+
const dir = base ? `${base}/${entry}` : entry;
|
|
46
|
+
if (isSlug(entry) && reader.exists(`${dir}/SKILL.md`))
|
|
47
|
+
out.push(dir);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
/** The tool skill folders present in `root`, or `[""]` when `root` is itself a folder of skills. */
|
|
52
|
+
function layout(reader) {
|
|
53
|
+
// The reader's exists() is for files; a tool folder counts when it lists.
|
|
54
|
+
const homes = CLI_SKILL_HOMES.map((home) => home.dir).filter((dir) => reader.list(dir, "dir").length);
|
|
55
|
+
if (homes.length)
|
|
56
|
+
return homes;
|
|
57
|
+
return skillDirs(reader, "").length ? [""] : [];
|
|
58
|
+
}
|
|
59
|
+
export function readCliSkills(root, fs) {
|
|
60
|
+
const reader = createSourceReader(root, CLI_SKILLS_ALLOWLIST, fs);
|
|
61
|
+
const found = new Map();
|
|
62
|
+
const skills = [];
|
|
63
|
+
for (const base of layout(reader)) {
|
|
64
|
+
for (const dir of skillDirs(reader, base)) {
|
|
65
|
+
const files = readSkillFolder(reader, dir);
|
|
66
|
+
if (!files)
|
|
67
|
+
continue;
|
|
68
|
+
const slug = dir.slice(dir.lastIndexOf("/") + 1);
|
|
69
|
+
const print = fingerprint(files);
|
|
70
|
+
const first = found.get(slug);
|
|
71
|
+
// Same name, same content elsewhere: offered as an exact copy by the
|
|
72
|
+
// shared dedupe. Same name, different content: the first tool wins.
|
|
73
|
+
const name = !first ? slug : first.print === print ? `${slug}-copy-${skills.length}` : "";
|
|
74
|
+
if (!name)
|
|
75
|
+
continue;
|
|
76
|
+
if (!first)
|
|
77
|
+
found.set(slug, { dir, print });
|
|
78
|
+
skills.push({ slug: name, sourcePath: dir, files });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { kind: CLI_SKILLS_KIND, label: CLI_SKILLS_LABEL, root: reader.root, bots: [], routines: [], rooms: [], vendorSkills: [], skills };
|
|
82
|
+
}
|
|
83
|
+
export function checkCliSkillsFolder(input) {
|
|
84
|
+
if (typeof input !== "string" || !input.trim()) {
|
|
85
|
+
return { ok: false, code: "path_required", error: "Choose your home folder, or a folder of skills." };
|
|
86
|
+
}
|
|
87
|
+
if (input.length > 4096 || input.includes("\0"))
|
|
88
|
+
return { ok: false, code: "not_found", error: "That folder does not exist." };
|
|
89
|
+
let path = input.trim();
|
|
90
|
+
if (path === "~" || path.startsWith("~/"))
|
|
91
|
+
path = join(homedir(), path.slice(1));
|
|
92
|
+
if (!isAbsolute(path))
|
|
93
|
+
return { ok: false, code: "not_absolute", error: "Enter the full path, for example /Users/you." };
|
|
94
|
+
path = resolve(path);
|
|
95
|
+
if (!existsSync(path))
|
|
96
|
+
return { ok: false, code: "not_found", error: "That folder does not exist." };
|
|
97
|
+
if (!statSync(path).isDirectory())
|
|
98
|
+
return { ok: false, code: "not_folder", error: "That path is a file. Choose a folder instead." };
|
|
99
|
+
try {
|
|
100
|
+
if (layout(createSourceReader(path, CLI_SKILLS_ALLOWLIST)).length)
|
|
101
|
+
return { ok: true, root: path };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Unreadable: reported below.
|
|
105
|
+
}
|
|
106
|
+
return { ok: false, code: "not_skills", error: "No skills here. Choose your home folder (it holds .claude/skills, .codex/skills, .agents/skills, .gemini/skills or .grok/skills) or a folder whose subfolders each have a SKILL.md." };
|
|
107
|
+
}
|
|
108
|
+
export function detectCliSkills(home = homedir(), fs) {
|
|
109
|
+
try {
|
|
110
|
+
const count = readCliSkills(home, fs).skills.length;
|
|
111
|
+
return count ? [{ root: home, skills: count }] : [];
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Skills have no conversations. */
|
|
118
|
+
export const CLI_SKILLS_HISTORY = {
|
|
119
|
+
project: "",
|
|
120
|
+
receiptPrefix: "cli-skills:",
|
|
121
|
+
available: () => false,
|
|
122
|
+
plan: () => ({ plan: null, unreadable: false }),
|
|
123
|
+
reader: (root, fs) => createSourceReader(root, { files: [], dirs: [] }, fs),
|
|
124
|
+
};
|
|
@@ -623,7 +623,7 @@ export function convertHarness(source, options = {}) {
|
|
|
623
623
|
...(offeredSkill.has(skill.slug) ? { offered: offeredSkill.get(skill.slug) } : {}),
|
|
624
624
|
});
|
|
625
625
|
}
|
|
626
|
-
if (converted.length > packageSkills.length) {
|
|
626
|
+
if (source.bots.length && converted.length > packageSkills.length) {
|
|
627
627
|
report.limits.push(`Team files carry at most ${rules.maxEmbeddedSkills} skills; ${converted.length - packageSkills.length} converted skill(s) are only in skills/ and must be installed per bot.`);
|
|
628
628
|
}
|
|
629
629
|
// ── rooms and vendor skills ─────────────────────────────────────────
|
|
@@ -704,7 +704,7 @@ export function convertHarness(source, options = {}) {
|
|
|
704
704
|
flags: spec.refs.length ? ["secrets-referenced"] : [],
|
|
705
705
|
});
|
|
706
706
|
}
|
|
707
|
-
if (!agents.length)
|
|
707
|
+
if (source.bots.length && !agents.length)
|
|
708
708
|
throw new Error("Nothing to convert: every bot was dropped or held back");
|
|
709
709
|
if (!orchestratorKey)
|
|
710
710
|
report.limits.push("No Chief of Staff could be set: the orchestrator bot was not converted.");
|