@introspection-ai/recipes 0.36.2 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ask-user-question.d.ts +82 -0
- package/dist/ask-user-question.d.ts.map +1 -0
- package/dist/ask-user-question.js +314 -0
- package/dist/ask-user-question.js.map +1 -0
- package/dist/connector-tools.d.ts.map +1 -1
- package/dist/connector-tools.js +10 -2
- package/dist/connector-tools.js.map +1 -1
- package/dist/documents/index.d.ts +7 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +4 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/module.d.ts +61 -0
- package/dist/documents/module.d.ts.map +1 -0
- package/dist/documents/module.js +133 -0
- package/dist/documents/module.js.map +1 -0
- package/dist/documents/profile.d.ts +34 -0
- package/dist/documents/profile.d.ts.map +1 -0
- package/dist/documents/profile.js +94 -0
- package/dist/documents/profile.js.map +1 -0
- package/dist/documents/tools.d.ts +40 -0
- package/dist/documents/tools.d.ts.map +1 -0
- package/dist/documents/tools.js +327 -0
- package/dist/documents/tools.js.map +1 -0
- package/dist/documents/types.d.ts +144 -0
- package/dist/documents/types.d.ts.map +1 -0
- package/dist/documents/types.js +10 -0
- package/dist/documents/types.js.map +1 -0
- package/dist/extensions.d.ts +2 -0
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +3 -0
- package/dist/extensions.js.map +1 -1
- package/dist/interaction-tui.d.ts +1 -1
- package/dist/interaction-tui.d.ts.map +1 -1
- package/dist/interaction-tui.js +2 -2
- package/dist/interaction-tui.js.map +1 -1
- package/dist/mcp-chunks/{auth-command-GMMLBU24.js → auth-command-M7TQE3AL.js} +26 -23
- package/dist/mcp-chunks/call-arguments-GCXZA4HC.js +16 -0
- package/dist/mcp-chunks/{call-command-2VF6IKAZ.js → call-command-7LD7UEFK.js} +33 -33
- package/dist/mcp-chunks/{chunk-TYL2NVXI.js → chunk-2AKSS7WR.js} +2 -2
- package/dist/mcp-chunks/{chunk-LZUKBEQZ.js → chunk-2YV72LUA.js} +12 -12
- package/dist/mcp-chunks/{chunk-2JTXIMGE.js → chunk-3ETUDW7N.js} +1 -1
- package/dist/mcp-chunks/{chunk-5UK2JLTN.js → chunk-3FRLDHVD.js} +5 -5
- package/dist/mcp-chunks/{chunk-ENBJFQ6H.js → chunk-3HSC6NHZ.js} +1 -1
- package/dist/mcp-chunks/{chunk-IHOU2BEL.js → chunk-3LENTPGE.js} +2 -2
- package/dist/mcp-chunks/{chunk-ZJWZY54X.js → chunk-3P3KGT4H.js} +2 -2
- package/dist/mcp-chunks/{chunk-IMXPLUKE.js → chunk-3SXP4S2A.js} +2 -2
- package/dist/mcp-chunks/{chunk-22WCLO4D.js → chunk-5Z6WSV5D.js} +5 -5
- package/dist/mcp-chunks/{chunk-QNZGFUKC.js → chunk-63L6SHK3.js} +2 -2
- package/dist/mcp-chunks/{chunk-OI3RTQXY.js → chunk-66VSGFXA.js} +1 -1
- package/dist/mcp-chunks/{chunk-DUBQHYW4.js → chunk-6O42UGLI.js} +9 -9
- package/dist/mcp-chunks/{chunk-R4OYHQ4V.js → chunk-6P3KAQ5N.js} +1 -1
- package/dist/mcp-chunks/{chunk-5OO6WVPL.js → chunk-7U5NSQ5T.js} +1 -1
- package/dist/mcp-chunks/{chunk-O2C3HXGS.js → chunk-B6S43WID.js} +1 -1
- package/dist/mcp-chunks/{chunk-VWPKJFK4.js → chunk-BHXCAVFP.js} +1 -1
- package/dist/mcp-chunks/{chunk-WXNGATQ7.js → chunk-BUOGKTKK.js} +2 -1
- package/dist/mcp-chunks/{chunk-4U4BUXQD.js → chunk-CXST5CVH.js} +33 -17
- package/dist/mcp-chunks/{chunk-YWFQPA4D.js → chunk-DU4SDPEV.js} +2 -2
- package/dist/mcp-chunks/{chunk-ZI5XYM4C.js → chunk-E76ZUBOJ.js} +4 -4
- package/dist/mcp-chunks/{chunk-D2SZ7KRY.js → chunk-ELHS763C.js} +1 -1
- package/dist/mcp-chunks/chunk-EQCSXVQ7.js +10650 -0
- package/dist/mcp-chunks/{chunk-RHXZKYM7.js → chunk-F2X4Y2TQ.js} +1 -1
- package/dist/mcp-chunks/{chunk-6XC5JJWD.js → chunk-GTETFUPQ.js} +28 -25
- package/dist/mcp-chunks/{chunk-UQUM7ICD.js → chunk-GZ53GNFP.js} +10 -10
- package/dist/mcp-chunks/{chunk-LUVLTUKR.js → chunk-H5PBSJP3.js} +1 -1
- package/dist/mcp-chunks/{chunk-FLUF2FRN.js → chunk-HNQSUT44.js} +3 -3
- package/dist/mcp-chunks/{chunk-CN5KSNWG.js → chunk-I6UFV7RW.js} +1 -1
- package/dist/mcp-chunks/{chunk-OSTHIELS.js → chunk-IRARVOUM.js} +1 -1
- package/dist/mcp-chunks/{webapi-NNCZGUMZ.js → chunk-IRSL7JRH.js} +255 -249
- package/dist/mcp-chunks/{chunk-ZXIF7MKN.js → chunk-IWCVZ46B.js} +2 -2
- package/dist/mcp-chunks/{chunk-RZZO3ZD4.js → chunk-JEHI2YU4.js} +3 -3
- package/dist/mcp-chunks/{chunk-ANNJGB6F.js → chunk-JTPTAO4M.js} +13 -13
- package/dist/mcp-chunks/{chunk-U5QZHPCC.js → chunk-KJ5FPQF6.js} +1 -1
- package/dist/mcp-chunks/{chunk-7IVXKYTI.js → chunk-L2MSWQDL.js} +1 -1
- package/dist/mcp-chunks/{chunk-DBNBEWRX.js → chunk-MEQXX43K.js} +1 -1
- package/dist/mcp-chunks/{chunk-3AAF3FSI.js → chunk-MHUMLEBO.js} +1 -1
- package/dist/mcp-chunks/{chunk-HFHIY5TO.js → chunk-N2U2FODH.js} +4 -4
- package/dist/mcp-chunks/{chunk-YFCNRWLV.js → chunk-N6YUOYDS.js} +2 -2
- package/dist/mcp-chunks/{chunk-C4TJGC4F.js → chunk-O3RTM5HD.js} +1 -1
- package/dist/mcp-chunks/{chunk-35LLRCRA.js → chunk-O7SIXJM6.js} +1308 -912
- package/dist/mcp-chunks/{chunk-QDFL757K.js → chunk-PSE442BC.js} +91 -77
- package/dist/mcp-chunks/{chunk-YPSODIQX.js → chunk-QNXOIF5U.js} +15 -14
- package/dist/mcp-chunks/{chunk-RKQC2EE6.js → chunk-RUF27IUF.js} +2 -2
- package/dist/mcp-chunks/{chunk-SS7V7GVT.js → chunk-S2F7DDP5.js} +4 -4
- package/dist/mcp-chunks/{chunk-D65GOMYV.js → chunk-TC2JPBFB.js} +2 -2
- package/dist/mcp-chunks/{chunk-7BVYBZ4J.js → chunk-THRMUZZD.js} +39 -14
- package/dist/mcp-chunks/{chunk-P5YLK5G2.js → chunk-UFV6SVQG.js} +11 -11
- package/dist/mcp-chunks/{chunk-LISNXOIQ.js → chunk-US63Y6XE.js} +1 -1
- package/dist/mcp-chunks/{chunk-HI6VG5LR.js → chunk-UVRJ3AAD.js} +2 -2
- package/dist/mcp-chunks/{chunk-6TIU2CDB.js → chunk-V42T3QNK.js} +456 -64
- package/dist/mcp-chunks/{chunk-347GOMV4.js → chunk-WDWSA7RL.js} +4 -4
- package/dist/mcp-chunks/{chunk-4PN2J74H.js → chunk-WQL7FJQ3.js} +4 -4
- package/dist/mcp-chunks/{chunk-LRGMFF5S.js → chunk-ZEA3Y5ZD.js} +7 -7
- package/dist/mcp-chunks/{cli-4OQD3H4N.js → cli-IYD7Y7MO.js} +67 -67
- package/dist/mcp-chunks/client-5MNBV3Z7.js +32 -0
- package/dist/mcp-chunks/{config-command-72TCIWPV.js → config-command-6DXILFNO.js} +129 -34
- package/dist/mcp-chunks/daemon-command-V3B3EMXD.js +32 -0
- package/dist/mcp-chunks/{dist-74UCKZK5.js → dist-Q7WSCBBK.js} +74 -55
- package/dist/mcp-chunks/{emit-ts-command-KD4ON2SE.js → emit-ts-command-NDCDFDRM.js} +17 -17
- package/dist/mcp-chunks/{generate-cli-runner-HWGI6HPL.js → generate-cli-runner-PW5WJ7KI.js} +136 -92
- package/dist/mcp-chunks/generated-daemon-runtime-3C4NWGAU.js +32 -0
- package/dist/mcp-chunks/{inspect-cli-command-FT5JSB7V.js → inspect-cli-command-4MGF5CPP.js} +9 -9
- package/dist/mcp-chunks/{launch-AHLKP2VM.js → launch-UG7IH27P.js} +1 -1
- package/dist/mcp-chunks/{lifecycle-BJDITFWN.js → lifecycle-QBYGUHQ3.js} +1 -1
- package/dist/mcp-chunks/{list-command-YKF7RN6Y.js → list-command-SDITI3ZM.js} +36 -35
- package/dist/mcp-chunks/{output-utils-LYB5IJRD.js → output-utils-YTMZTA7J.js} +3 -3
- package/dist/mcp-chunks/{prompt-CH6TK0bC-B3USYOND.js → prompt-DkftHXS7-N7UENQ4C.js} +1 -1
- package/dist/mcp-chunks/{record-command-MJW3Z5E5.js → record-command-JGTMATYI.js} +5 -5
- package/dist/mcp-chunks/{replay-command-5ZHBUOLE.js → replay-command-S2VAC4RW.js} +6 -6
- package/dist/mcp-chunks/{resource-command-L4I24AX5.js → resource-command-SRFQQROJ.js} +9 -9
- package/dist/mcp-chunks/{result-utils-5WRI66KV.js → result-utils-JASGNHXK.js} +3 -3
- package/dist/mcp-chunks/runtime-RMI3XCYJ.js +39 -0
- package/dist/mcp-chunks/{runtime-wrapper-WFMNIHD5.js → runtime-wrapper-7HYO3NM5.js} +3 -3
- package/dist/mcp-chunks/{serve-command-KNCSJUXS.js → serve-command-UF5SVREV.js} +1111 -697
- package/dist/mcp-chunks/{timeouts-2ZHGSB3R.js → timeouts-BJWDJEMH.js} +3 -3
- package/dist/mcp-chunks/{vault-command-7EDL45AA.js → vault-command-EYOIFWEY.js} +5 -4
- package/dist/mcp-chunks/webapi-WMMA3OEC.js +82 -0
- package/dist/mcp-daemon.js +28 -27
- package/dist/mcp-run-worker.js +28 -27
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +6 -0
- package/dist/pi-extension.js.map +1 -1
- package/dist/recipe/package.d.ts +15 -0
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +96 -2
- package/dist/recipe/package.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +6 -0
- package/dist/session.js.map +1 -1
- package/docs/documents.md +344 -0
- package/docs/index.md +1 -0
- package/docs/interactions.md +76 -8
- package/docs/mcp-configuration.md +10 -5
- package/docs/recipe-format.md +69 -1
- package/documents/SKILL.md +63 -0
- package/package.json +16 -11
- package/dist/mcp-chunks/call-arguments-WSURHOLV.js +0 -16
- package/dist/mcp-chunks/chunk-BIVX2WFX.js +0 -3349
- package/dist/mcp-chunks/client-LXKCCVMT.js +0 -31
- package/dist/mcp-chunks/daemon-command-QHS3ACBM.js +0 -31
- package/dist/mcp-chunks/generated-daemon-runtime-7ORS5KBR.js +0 -31
- package/dist/mcp-chunks/runtime-IKWDQLZF.js +0 -38
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { loadRecipeModule } from "../recipe/extensions.js";
|
|
3
|
+
import { recipeDocumentPackageName } from "../recipe/package.js";
|
|
4
|
+
import { DOCUMENT_COMMANDS, documentCommandsFor, documentConnectorTools, registerDocumentTools, } from "./tools.js";
|
|
5
|
+
import { resolveDocumentProfile } from "./profile.js";
|
|
6
|
+
/** The core `documents` skill, offered to every agent that selects the tool. It ships beside `dist/`. */
|
|
7
|
+
export const DOCUMENTS_SKILL = fileURLToPath(new URL("../../documents/SKILL.md", import.meta.url));
|
|
8
|
+
function sameCapabilities(left, right) {
|
|
9
|
+
const a = documentCommandsFor(left);
|
|
10
|
+
const b = documentCommandsFor(right);
|
|
11
|
+
return a.length === b.length && a.every((command, index) => command === b[index]);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build a format module from an adapter factory. The neutral tool, its
|
|
15
|
+
* schemas, the path policy and the capability filtering live in the host.
|
|
16
|
+
*/
|
|
17
|
+
export function createDocumentFormatModule(options) {
|
|
18
|
+
if (!options.capabilities.read)
|
|
19
|
+
throw new Error(`Document format '${options.format}' must support read`);
|
|
20
|
+
if (options.extensions.length === 0)
|
|
21
|
+
throw new Error(`Document format '${options.format}' opens no extensions`);
|
|
22
|
+
return {
|
|
23
|
+
kind: "documents",
|
|
24
|
+
format: options.format,
|
|
25
|
+
extensions: options.extensions.map((extension) => extension.toLowerCase()),
|
|
26
|
+
capabilities: options.capabilities,
|
|
27
|
+
profiles: { ...options.profiles },
|
|
28
|
+
createAdapter(createOptions) {
|
|
29
|
+
const adapter = options.createAdapter(createOptions);
|
|
30
|
+
if (adapter.format !== options.format) {
|
|
31
|
+
throw new Error(`Document adapter for '${options.format}' returned format '${adapter.format}'`);
|
|
32
|
+
}
|
|
33
|
+
if (!sameCapabilities(adapter.capabilities, options.capabilities)) {
|
|
34
|
+
throw new Error(`Document adapter '${options.format}' returned capabilities that differ from its declared catalog`);
|
|
35
|
+
}
|
|
36
|
+
return adapter;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function parseFormatModule(value, declaration) {
|
|
41
|
+
const packageName = recipeDocumentPackageName(declaration.format);
|
|
42
|
+
const module = (value && typeof value === "object" && "default" in value ? value.default : value);
|
|
43
|
+
if (!module ||
|
|
44
|
+
module.kind !== "documents" ||
|
|
45
|
+
module.format !== declaration.format ||
|
|
46
|
+
!Array.isArray(module.extensions) ||
|
|
47
|
+
!module.capabilities?.read ||
|
|
48
|
+
typeof module.createAdapter !== "function") {
|
|
49
|
+
throw new Error(`Recipe document package ${packageName} has an invalid module contract`);
|
|
50
|
+
}
|
|
51
|
+
return module;
|
|
52
|
+
}
|
|
53
|
+
const knownCommands = new Set(DOCUMENT_COMMANDS);
|
|
54
|
+
/**
|
|
55
|
+
* Load every `pi.documents` format package and the profile each declaration
|
|
56
|
+
* names (only those) and, when the agent selects `documents`, one extension
|
|
57
|
+
* registering the shared tool and offering the core `documents` skill with
|
|
58
|
+
* each profile's hints beside it.
|
|
59
|
+
*
|
|
60
|
+
* Each declaration's `commands` allowlist narrows what that format may do;
|
|
61
|
+
* the tool exposes the union of what the formats allow.
|
|
62
|
+
*/
|
|
63
|
+
export async function loadRecipeDocuments(declarations, agentTools, options) {
|
|
64
|
+
if (declarations.length === 0)
|
|
65
|
+
return { toolNames: [] };
|
|
66
|
+
const modules = await Promise.all(declarations.map(async (declaration) => {
|
|
67
|
+
const packageName = recipeDocumentPackageName(declaration.format);
|
|
68
|
+
let imported;
|
|
69
|
+
try {
|
|
70
|
+
imported = await loadRecipeModule(options.recipeDir, packageName);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new Error(`Recipe document format '${declaration.format}' requires ${packageName} in the Recipe dependencies`, {
|
|
74
|
+
cause: error,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const module = parseFormatModule(imported, declaration);
|
|
78
|
+
const supported = documentCommandsFor(module.capabilities);
|
|
79
|
+
for (const command of declaration.commands ?? []) {
|
|
80
|
+
if (!knownCommands.has(command))
|
|
81
|
+
throw new Error(`Unknown documents command in pi.documents allowlist: ${command}`);
|
|
82
|
+
if (!supported.includes(command)) {
|
|
83
|
+
throw new Error(`Document format '${declaration.format}' does not support command: ${command}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const profile = declaration.profile === undefined
|
|
87
|
+
? undefined
|
|
88
|
+
: resolveDocumentProfile(declaration.profile, { format: declaration.format, shipped: module.profiles, recipeDir: options.recipeDir });
|
|
89
|
+
return { declaration, module, profile };
|
|
90
|
+
}));
|
|
91
|
+
const enabled = modules.filter(({ declaration }) => declaration.commands?.length !== 0);
|
|
92
|
+
if (!agentTools.includes("documents") || enabled.length === 0)
|
|
93
|
+
return { toolNames: [] };
|
|
94
|
+
const skillPaths = [DOCUMENTS_SKILL];
|
|
95
|
+
for (const { profile } of enabled) {
|
|
96
|
+
if (profile && !skillPaths.includes(profile))
|
|
97
|
+
skillPaths.push(profile);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
toolNames: ["documents"],
|
|
101
|
+
skillPaths,
|
|
102
|
+
extension: {
|
|
103
|
+
owner: `<documents:${enabled.map(({ declaration }) => declaration.format).join(",")}>`,
|
|
104
|
+
factory: (pi) => {
|
|
105
|
+
const env = options.env ?? process.env;
|
|
106
|
+
const cwd = options.cwd ?? process.cwd();
|
|
107
|
+
const adapters = enabled.map(({ declaration, module }) => {
|
|
108
|
+
const adapter = module.createAdapter({ env, cwd });
|
|
109
|
+
const allowed = declaration.commands;
|
|
110
|
+
if (allowed === undefined)
|
|
111
|
+
return adapter;
|
|
112
|
+
// Narrow the descriptor to the allowlist so the shared tool filters on it.
|
|
113
|
+
const has = (command) => allowed.includes(command);
|
|
114
|
+
return Object.assign(Object.create(adapter), {
|
|
115
|
+
capabilities: {
|
|
116
|
+
read: true,
|
|
117
|
+
revise: Boolean(adapter.capabilities.revise && has("revise")),
|
|
118
|
+
proposeEdits: Boolean(adapter.capabilities.proposeEdits && has("propose_edits")),
|
|
119
|
+
comment: Boolean(adapter.capabilities.comment && has("comment")),
|
|
120
|
+
respond: Boolean(adapter.capabilities.respond && has("respond")),
|
|
121
|
+
removeSection: Boolean(adapter.capabilities.removeSection && has("remove_section")),
|
|
122
|
+
render: Boolean(adapter.capabilities.render && has("render")),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
registerDocumentTools(pi, adapters, { cwd });
|
|
127
|
+
pi.on("resources_discover", () => ({ skillPaths }));
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export { documentConnectorTools };
|
|
133
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/documents/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAA8B,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EACL,iBAAiB,EACjB,mBAA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AAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YACtD,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document profile is a skill: a folder holding a `SKILL.md` whose
|
|
3
|
+
* frontmatter `name` is the folder's name, in lower case, with a
|
|
4
|
+
* `description`. A format package ships some by name; a Recipe can bring its
|
|
5
|
+
* own by a relative path to the folder (or its `SKILL.md`). A profile is only
|
|
6
|
+
* read, never run. See docs/documents.md, "Write your own profile".
|
|
7
|
+
*/
|
|
8
|
+
/** A profile name a format ships, such as `legal-redlining-en-US`. */
|
|
9
|
+
export declare const DOCUMENT_PROFILE_NAME: RegExp;
|
|
10
|
+
/** A relative path to a profile folder or its SKILL.md, rather than a shipped name. */
|
|
11
|
+
export declare function isDocumentProfilePath(profile: string): boolean;
|
|
12
|
+
/** Why a `pi.documents[].profile` value has the wrong shape, or undefined when the shape is right. */
|
|
13
|
+
export declare function documentProfileShapeProblem(profile: unknown): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Check a profile's SKILL.md follows the contract: frontmatter whose `name`
|
|
16
|
+
* is its folder's name in lower case, and a `description`. Returns the problem,
|
|
17
|
+
* or undefined when it follows the contract.
|
|
18
|
+
*/
|
|
19
|
+
export declare function documentProfileSkillProblem(skillPath: string): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The SKILL.md of a profile a Recipe brings by path: the folder or the file,
|
|
22
|
+
* inside the Recipe by its real path, following the contract.
|
|
23
|
+
*/
|
|
24
|
+
export declare function recipeProfileSkill(profile: string, recipeDir: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* The SKILL.md a declaration's `profile` selects: one the format ships, by
|
|
27
|
+
* name (case-insensitive), or the Recipe's own, by relative path.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveDocumentProfile(profile: string, options: {
|
|
30
|
+
format: string;
|
|
31
|
+
shipped?: Readonly<Record<string, string>>;
|
|
32
|
+
recipeDir: string;
|
|
33
|
+
}): string;
|
|
34
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/documents/profile.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AAEH,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,QAA+B,CAAC;AAElE,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,sGAAsG;AACtG,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOhF;AAUD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASjF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAc7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACzF,MAAM,CAUR"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { assertRecipePathContained } from "../recipe/package.js";
|
|
5
|
+
/**
|
|
6
|
+
* A document profile is a skill: a folder holding a `SKILL.md` whose
|
|
7
|
+
* frontmatter `name` is the folder's name, in lower case, with a
|
|
8
|
+
* `description`. A format package ships some by name; a Recipe can bring its
|
|
9
|
+
* own by a relative path to the folder (or its `SKILL.md`). A profile is only
|
|
10
|
+
* read, never run. See docs/documents.md, "Write your own profile".
|
|
11
|
+
*/
|
|
12
|
+
/** A profile name a format ships, such as `legal-redlining-en-US`. */
|
|
13
|
+
export const DOCUMENT_PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
14
|
+
/** A relative path to a profile folder or its SKILL.md, rather than a shipped name. */
|
|
15
|
+
export function isDocumentProfilePath(profile) {
|
|
16
|
+
return profile.includes("/") || profile.includes("\\") || profile.startsWith(".");
|
|
17
|
+
}
|
|
18
|
+
/** Why a `pi.documents[].profile` value has the wrong shape, or undefined when the shape is right. */
|
|
19
|
+
export function documentProfileShapeProblem(profile) {
|
|
20
|
+
const usage = "must be the name of a profile the format ships, such as legal-redlining-en-US, or a relative path to a profile folder in the Recipe";
|
|
21
|
+
if (typeof profile !== "string" || !profile.trim())
|
|
22
|
+
return usage;
|
|
23
|
+
if (!isDocumentProfilePath(profile))
|
|
24
|
+
return DOCUMENT_PROFILE_NAME.test(profile) ? undefined : usage;
|
|
25
|
+
const absolute = isAbsolute(profile) || profile.startsWith("\\") || /^[A-Za-z]:/.test(profile);
|
|
26
|
+
if (absolute || profile.split(/[\\/]/).includes(".."))
|
|
27
|
+
return `'${profile}' must be a relative path inside the Recipe`;
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The frontmatter of a SKILL.md, or undefined when it has none. */
|
|
31
|
+
function frontmatter(text) {
|
|
32
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
|
|
33
|
+
if (!match)
|
|
34
|
+
return undefined;
|
|
35
|
+
const parsed = parse(match[1] ?? "");
|
|
36
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check a profile's SKILL.md follows the contract: frontmatter whose `name`
|
|
40
|
+
* is its folder's name in lower case, and a `description`. Returns the problem,
|
|
41
|
+
* or undefined when it follows the contract.
|
|
42
|
+
*/
|
|
43
|
+
export function documentProfileSkillProblem(skillPath) {
|
|
44
|
+
const folder = basename(dirname(skillPath));
|
|
45
|
+
const fields = frontmatter(readFileSync(skillPath, "utf8"));
|
|
46
|
+
if (!fields)
|
|
47
|
+
return "has no frontmatter; start it with --- name and description ---";
|
|
48
|
+
if (fields.name !== folder || folder !== folder.toLowerCase()) {
|
|
49
|
+
return `frontmatter name must be its folder's name in lower case ('${folder.toLowerCase()}'), not '${String(fields.name ?? "")}'`;
|
|
50
|
+
}
|
|
51
|
+
if (typeof fields.description !== "string" || !fields.description.trim())
|
|
52
|
+
return "frontmatter needs a description";
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The SKILL.md of a profile a Recipe brings by path: the folder or the file,
|
|
57
|
+
* inside the Recipe by its real path, following the contract.
|
|
58
|
+
*/
|
|
59
|
+
export function recipeProfileSkill(profile, recipeDir) {
|
|
60
|
+
const shape = documentProfileShapeProblem(profile);
|
|
61
|
+
if (shape)
|
|
62
|
+
throw new Error(`Document profile ${shape}`);
|
|
63
|
+
const target = resolve(recipeDir, profile);
|
|
64
|
+
if (!existsSync(target))
|
|
65
|
+
throw new Error(`Document profile ${profile} doesn't exist in the Recipe`);
|
|
66
|
+
// Where it really resolves: a symlink inside the Recipe can point outside it.
|
|
67
|
+
assertRecipePathContained(recipeDir, target, `document profile ${profile}`);
|
|
68
|
+
const skill = statSync(target).isDirectory() ? join(target, "SKILL.md") : target;
|
|
69
|
+
if (basename(skill) !== "SKILL.md")
|
|
70
|
+
throw new Error(`Document profile ${profile} must be a folder holding a SKILL.md, or that SKILL.md`);
|
|
71
|
+
if (!existsSync(skill))
|
|
72
|
+
throw new Error(`Document profile ${profile} has no SKILL.md`);
|
|
73
|
+
assertRecipePathContained(recipeDir, skill, `document profile ${profile}`);
|
|
74
|
+
const problem = documentProfileSkillProblem(skill);
|
|
75
|
+
if (problem)
|
|
76
|
+
throw new Error(`Document profile ${profile}: SKILL.md ${problem}`);
|
|
77
|
+
return skill;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The SKILL.md a declaration's `profile` selects: one the format ships, by
|
|
81
|
+
* name (case-insensitive), or the Recipe's own, by relative path.
|
|
82
|
+
*/
|
|
83
|
+
export function resolveDocumentProfile(profile, options) {
|
|
84
|
+
if (isDocumentProfilePath(profile))
|
|
85
|
+
return recipeProfileSkill(profile, options.recipeDir);
|
|
86
|
+
const shipped = options.shipped ?? {};
|
|
87
|
+
const found = Object.keys(shipped).find((name) => name.toLowerCase() === profile.toLowerCase());
|
|
88
|
+
if (found)
|
|
89
|
+
return shipped[found];
|
|
90
|
+
const names = Object.keys(shipped);
|
|
91
|
+
throw new Error(`Unknown document profile '${profile}': the ${options.format} format ships ${names.length ? names.join(", ") : "no profiles"}. ` +
|
|
92
|
+
"Bring your own as a relative path to a profile folder in the Recipe.");
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/documents/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;;;;;GAMG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAElE,uFAAuF;AACvF,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,OAAO,CAAC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|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { DocumentAdapter, DocumentCapabilities } from "./types.js";
|
|
3
|
+
/** Commands of the registered `documents` tool. */
|
|
4
|
+
export declare const DOCUMENT_COMMANDS: readonly ["read", "revise", "propose_edits", "comment", "respond", "remove_section", "render"];
|
|
5
|
+
export type DocumentCommand = (typeof DOCUMENT_COMMANDS)[number];
|
|
6
|
+
/** Which commands a capability descriptor supports. */
|
|
7
|
+
export declare function documentCommandsFor(capabilities: DocumentCapabilities): DocumentCommand[];
|
|
8
|
+
export declare function documentConnectorTools(_capabilities: DocumentCapabilities): {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
defaultActive: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
export interface RegisterDocumentToolsOptions {
|
|
14
|
+
/** The task workspace. Every path the tool takes must resolve inside it. */
|
|
15
|
+
cwd: string;
|
|
16
|
+
/** Where results may be written. Defaults to `<cwd>/outputs`. */
|
|
17
|
+
outputsDir?: string;
|
|
18
|
+
/** Where `render` writes page images. Defaults to a fresh directory under the system temp dir. */
|
|
19
|
+
pagesDir?: string;
|
|
20
|
+
/** Restrict commands; defaults to every command some format supports. An empty list exposes no tool. */
|
|
21
|
+
commands?: readonly DocumentCommand[];
|
|
22
|
+
}
|
|
23
|
+
/** Host surface used here. Opaque so Pi's TypeBox copy stays behind this seam. */
|
|
24
|
+
export interface DocumentToolHost {
|
|
25
|
+
registerTool(...args: never[]): unknown;
|
|
26
|
+
on?: ExtensionAPI["on"];
|
|
27
|
+
}
|
|
28
|
+
/** The workspace file a path names, refusing anything outside the workspace, through a symlink too. */
|
|
29
|
+
export declare function workspacePath(path: unknown, cwd: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Register ONE `documents` tool over every declared format.
|
|
32
|
+
*
|
|
33
|
+
* Unlike channels, where each provider owns a whole conversation, a Recipe
|
|
34
|
+
* reads a PDF brief and edits a Word contract in the same turn, so formats
|
|
35
|
+
* share one tool and the file extension picks the adapter. A command is
|
|
36
|
+
* registered when at least one format supports it; calling it on a format
|
|
37
|
+
* that does not fails before the adapter runs and names the formats that do.
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerDocumentTools(pi: DocumentToolHost, adapters: readonly DocumentAdapter[], options: RegisterDocumentToolsOptions): void;
|
|
40
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/documents/tools.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAIpE,OAAO,KAAK,EACV,eAAe,EAEf,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,YAC5B,MAAM,EACN,QAAQ,EACR,eAAe,EACf,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,QAAQ,CACA,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAUjE,uDAAuD;AACvD,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,GAAG,eAAe,EAAE,CASzF;AAED,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,oBAAoB;;;;IAEzE;AAwBD,MAAM,WAAW,4BAA4B;IAC3C,4EAA4E;IAC5E,GAAG,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wGAAwG;IACxG,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CACvC;AAED,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACxC,EAAE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