pi2dsh 0.12.1 → 0.12.3

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.
Files changed (35) hide show
  1. package/README.md +37 -7
  2. package/README.zh.md +32 -6
  3. package/dist/{analyzer-CsrBeS8r.mjs → analyzer-2Nx5XYOA.mjs} +3 -3
  4. package/dist/{analyzer-CsrBeS8r.mjs.map → analyzer-2Nx5XYOA.mjs.map} +1 -1
  5. package/dist/cli.mjs +7 -44
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/client.js +139 -0
  8. package/dist/compat/pi-coding-agent.d.mts +82 -14
  9. package/dist/compat/pi-coding-agent.d.mts.map +1 -1
  10. package/dist/compat/pi-coding-agent.mjs +1 -1
  11. package/dist/credentials-oauth.mjs +1 -1
  12. package/dist/host.d.mts +1 -11
  13. package/dist/host.d.mts.map +1 -1
  14. package/dist/host.mjs +3 -98
  15. package/dist/host.mjs.map +1 -1
  16. package/dist/index.d.mts +18 -19
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +5 -14
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/mcp-config-Cjae0vot.mjs +766 -0
  21. package/dist/mcp-config-Cjae0vot.mjs.map +1 -0
  22. package/dist/{pi-coding-agent-Ctw-BhoY.mjs → pi-coding-agent-CYnmeJEx.mjs} +0 -0
  23. package/dist/pi-coding-agent-CYnmeJEx.mjs.map +1 -0
  24. package/dist/{runtime-Xy8yU8wO.mjs → runtime-B_Ig28og.mjs} +1122 -223
  25. package/dist/runtime-B_Ig28og.mjs.map +1 -0
  26. package/dist/runtime.d.mts +33 -0
  27. package/dist/runtime.d.mts.map +1 -1
  28. package/dist/runtime.mjs +1 -1
  29. package/package.json +23 -9
  30. package/dist/generator-CSOv6wYT.mjs +0 -298
  31. package/dist/generator-CSOv6wYT.mjs.map +0 -1
  32. package/dist/mcp-config-Cn5gWemZ.mjs +0 -707
  33. package/dist/mcp-config-Cn5gWemZ.mjs.map +0 -1
  34. package/dist/pi-coding-agent-Ctw-BhoY.mjs.map +0 -1
  35. package/dist/runtime-Xy8yU8wO.mjs.map +0 -1
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { a as GeneratedRuntimeManifest } from "./types-7IWJPPvS.mjs";
3
+ import { ContentBlock } from "@deepseek-ai/dsh-llm";
3
4
  import { Context } from "@deepseek-ai/cordis";
4
5
  //#region src/runtime.d.ts
5
6
  type UnknownRecord = Record<string, unknown>;
@@ -17,6 +18,35 @@ declare function normalizeToolSchema(schema: unknown): {
17
18
  schema: UnknownRecord;
18
19
  warnings: string[];
19
20
  };
21
+ declare function isSubagentOrigin(subject: UnknownRecord | undefined): boolean;
22
+ /**
23
+ * What triggered a compaction, in Pi's vocabulary.
24
+ *
25
+ * DSH's durable lifecycle events say two things about the trigger: a manual
26
+ * compaction runs with no open turn (`turn: null`), and one a command drove
27
+ * cites that command. Both are Pi's "manual".
28
+ *
29
+ * The limit, stated rather than papered over: DSH's automatic trigger is
30
+ * `'pressure' | 'context-overflow'` at the call site but is NOT written to the
31
+ * log, so Pi's `threshold` and `overflow` cannot be told apart after the fact.
32
+ * Automatic compactions report `threshold`, the far more common of the two —
33
+ * and `willRetry` stays false for the same reason. A package keying behavior
34
+ * on `overflow` specifically will not see it.
35
+ * @param data - the `compaction/start` or `compaction/summary` event data.
36
+ */
37
+ declare function compactionReason(data: UnknownRecord): 'manual' | 'threshold' | 'overflow';
38
+ /**
39
+ * DSH content → the Pi content blocks packages read.
40
+ *
41
+ * Asynchronous because Pi's image block carries the bytes inline while DSH's
42
+ * carries only an attachment reference, and the bytes come from the attachment
43
+ * service. The sync version this replaced projected an image as a bare
44
+ * `{type:'image'}` — a block that announces an image and contains none, which
45
+ * is the exact shape a package cannot tell from a real one.
46
+ * @param ctx - context used to reach the attachment service.
47
+ * @param content - the DSH blocks to project.
48
+ */
49
+ declare function dshToPiContent(ctx: Context, content: readonly ContentBlock[]): Promise<Array<UnknownRecord>>;
20
50
  /** Companion configuration: default (auto), `false` (off), or an explicit narrow map. */
21
51
  type VisionCompanionsConfig = false | Record<string, readonly string[]> | undefined;
22
52
  /**
@@ -41,7 +71,10 @@ declare function splitArguments(input: string): string[];
41
71
  declare function expandPrompt(text: string, rawInput: string): string;
42
72
  declare function applyPiPackage(ctx: Context, options: RuntimeOptions): Promise<void>;
43
73
  declare const runtimeInternals: {
74
+ compactionReason: typeof compactionReason;
75
+ dshToPiContent: typeof dshToPiContent;
44
76
  expandPrompt: typeof expandPrompt;
77
+ isSubagentOrigin: typeof isSubagentOrigin;
45
78
  normalizeToolResult: typeof normalizeToolResult;
46
79
  splitArguments: typeof splitArguments;
47
80
  textBlocks: typeof textBlocks;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime.ts"],"mappings":";;;;KAkCK,gBAAgB;UAGX;EACR,SAAS;EACT,UAAU;EACV,SAAS;;iBAuJF,WAAW,mBAAmB;EAAQ;EAAc;;iBAcpD,oBAAoB,kBAAkB;iBAuH/B,oBAAoB;EAAoB,QAAQ;EAAe;;;KA+xCnE,iCAAiC;;;;;;;;;;;;;;;;;;iBAmB7B,yBAAyB,KAAK,SAAS,QAAQ;iBAmrBtD,eAAe;iBA+Bf,aAAa,cAAc;iBA2Id,eAAe,KAAK,SAAS,SAAS,iBAAiB;cAsKhE"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime.ts"],"mappings":";;;;;KAuCK,gBAAgB;UAGX;EACR,SAAS;EACT,UAAU;EACV,SAAS;;iBAkLF,WAAW,mBAAmB;EAAQ;EAAc;;iBAcpD,oBAAoB,kBAAkB;iBAuH/B,oBAAoB;EAAoB,QAAQ;EAAe;;iBA8EtE,iBAAiB,SAAS;;;;;;;;;;;;;;;;iBAquB1B,iBAAiB,MAAM;;;;;;;;;;;;iBAgBjB,eAAe,KAAK,SAAS,kBAAkB,iBAAiB,QAAQ,MAAM;;KA+tBjF,iCAAiC;;;;;;;;;;;;;;;;;;iBAmB7B,yBAAyB,KAAK,SAAS,QAAQ;iBAo6BtD,eAAe;iBA+Bf,aAAa,cAAc;iBA2Id,eAAe,KAAK,SAAS,SAAS,iBAAiB;cAqMhE"}
package/dist/runtime.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
 
2
- import { i as runtimeInternals, n as normalizeToolSchema, r as registerVisionCompanions, t as applyPiPackage } from "./runtime-Xy8yU8wO.mjs";
2
+ import { i as runtimeInternals, n as normalizeToolSchema, r as registerVisionCompanions, t as applyPiPackage } from "./runtime-B_Ig28og.mjs";
3
3
  export { applyPiPackage, normalizeToolSchema, registerVisionCompanions, runtimeInternals };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi2dsh",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "Bridge the Pi and DeepSeek Harness ecosystems: a general Pi Host ABI that runs unmodified Pi extensions as native DSH plugins, plus per-package conversion and MCP config translation.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,11 @@
30
30
  "./credentials-oauth": {
31
31
  "types": "./dist/credentials-oauth.d.mts",
32
32
  "default": "./dist/credentials-oauth.mjs"
33
- }
33
+ },
34
+ "./client": {
35
+ "default": "./dist/client.js"
36
+ },
37
+ "./package.json": "./package.json"
34
38
  },
35
39
  "files": [
36
40
  "dist",
@@ -39,19 +43,22 @@
39
43
  "LICENSE"
40
44
  ],
41
45
  "scripts": {
46
+ "audit:community": "pnpm build && node scripts/audit-community.mjs",
42
47
  "build": "tsdown",
43
- "prepare": "tsdown",
44
48
  "check": "tsc --noEmit",
49
+ "check:docs": "pnpm build && node scripts/generate-capability-docs.mjs --check",
50
+ "check:pack": "pnpm build && publint && node scripts/check-pack.mjs",
51
+ "docs:capabilities": "node scripts/generate-capability-docs.mjs",
52
+ "prepare": "tsdown",
45
53
  "test": "pnpm build && vitest run",
46
- "test:coverage": "pnpm build && vitest run --coverage",
47
- "test:dsh": "pnpm build && vitest run tests/dsh-runtime.spec.ts tests/generated-bundle.spec.ts",
48
- "audit:community": "pnpm build && node scripts/audit-community.mjs",
49
54
  "test:community": "pnpm build && node scripts/verify-community.mjs --generate community/runtime-results.json",
55
+ "test:coverage": "pnpm build && vitest run --coverage",
56
+ "test:dsh": "pnpm build && vitest run tests/dsh-runtime.spec.ts",
57
+ "test:examples": "pnpm build && node scripts/verify-examples-e2e.mjs",
50
58
  "test:live": "pnpm build && node scripts/verify-live-deepseek.mjs community/live-deepseek-results.json",
51
- "check:pack": "pnpm build && publint && node scripts/check-pack.mjs",
59
+ "test:seams": "pnpm build && node scripts/verify-step-seams-e2e.mjs",
52
60
  "verify": "pnpm check && pnpm test:coverage && pnpm check:docs && pnpm check:pack",
53
- "docs:capabilities": "node scripts/generate-capability-docs.mjs",
54
- "check:docs": "pnpm build && node scripts/generate-capability-docs.mjs --check"
61
+ "verify:release": "pnpm verify && PI2DSH_ENGINE_SPEC=pi2dsh@$(node -p \"require('./package.json').version\") node scripts/verify-examples-e2e.mjs && node scripts/verify-step-seams-e2e.mjs"
55
62
  },
56
63
  "keywords": [
57
64
  "deepseek-harness",
@@ -95,6 +102,7 @@
95
102
  "@deepseek-ai/dsh-attachment": "^0.1.0-rc.6",
96
103
  "@deepseek-ai/dsh-commands": "^0.1.0-rc.6",
97
104
  "@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
105
+ "@deepseek-ai/dsh-session": "^0.1.0-rc.6",
98
106
  "@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.6",
99
107
  "@deepseek-ai/dsh-subprocess": "^0.1.0-rc.6",
100
108
  "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6",
@@ -157,6 +165,12 @@
157
165
  "dsh": {
158
166
  "bundle": {
159
167
  "patch": "./cordis.patch.yml"
168
+ },
169
+ "client": {
170
+ "inject": [
171
+ "slots"
172
+ ],
173
+ "platform": "web"
160
174
  }
161
175
  }
162
176
  }
@@ -1,298 +0,0 @@
1
-
2
- import { analyzePackage, n as collectLocalClosure, r as runtimeExternalPackages, t as SCRIPT_EXTENSIONS } from "./analyzer-CsrBeS8r.mjs";
3
- import { cp, lstat, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
4
- import { basename, dirname, extname, join, relative, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { parse } from "yaml";
7
- //#region src/generator.ts
8
- const SHIMMED_PI_HOST_PACKAGES = /* @__PURE__ */ new Set([
9
- "@earendil-works/pi-coding-agent",
10
- "@mariozechner/pi-coding-agent",
11
- "@earendil-works/pi-tui",
12
- "@mariozechner/pi-tui",
13
- "@earendil-works/pi-ai",
14
- "@mariozechner/pi-ai",
15
- "typebox",
16
- "@sinclair/typebox"
17
- ]);
18
- function packageSlug(name) {
19
- return name.replace(/^@/u, "").replaceAll("/", "-").replace(/[^a-zA-Z0-9._-]+/gu, "-").toLowerCase().replace(/^-+|-+$/gu, "") || "package";
20
- }
21
- function stringRecord(value) {
22
- if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
23
- return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
24
- }
25
- async function assertEmptyOrMissing(path) {
26
- try {
27
- if (!(await stat(path)).isDirectory()) throw new Error(`output exists and is not a directory: ${path}`);
28
- if ((await readdir(path)).length > 0) throw new Error(`output directory is not empty: ${path}`);
29
- } catch (error) {
30
- if (error.code !== "ENOENT") throw error;
31
- }
32
- }
33
- function parseFrontmatter(text) {
34
- const normalized = text.replace(/\r\n?/gu, "\n");
35
- if (!normalized.startsWith("---")) return {
36
- attributes: {},
37
- body: normalized
38
- };
39
- const endIndex = normalized.indexOf("\n---", 3);
40
- if (endIndex === -1) return {
41
- attributes: {},
42
- body: normalized
43
- };
44
- const raw = parse(normalized.slice(4, endIndex));
45
- return {
46
- attributes: typeof raw === "object" && raw !== null && !Array.isArray(raw) ? stringRecord(raw) : {},
47
- body: normalized.slice(endIndex + 4).trim()
48
- };
49
- }
50
- async function assertNoSymlinks(path) {
51
- const info = await lstat(path);
52
- if (info.isSymbolicLink()) throw new Error(`refusing to copy symbolic link from Pi package: ${path}`);
53
- if (!info.isDirectory()) return;
54
- for (const entry of await readdir(path)) await assertNoSymlinks(join(path, entry));
55
- }
56
- async function copyExtensions(pkg, outDir) {
57
- const copied = [];
58
- const runtimePackages = /* @__PURE__ */ new Set();
59
- const closure = await collectLocalClosure(pkg.rootDir, pkg.resources.extensions);
60
- for (const issue of closure.issues) console.warn(`pi2dsh: unresolved ${issue.kind} reference ${JSON.stringify(issue.specifier)} from ${relative(pkg.rootDir, issue.file)} (${issue.lazy ? "lazy path — fails at feature use, as under Pi" : "load-time path"})`);
61
- for (const source of closure.files) {
62
- if (SCRIPT_EXTENSIONS.has(extname(source))) {
63
- const text = await readFile(source, "utf8");
64
- const lazyFile = !closure.loadTimeFiles.has(source);
65
- for (const use of runtimeExternalPackages(source, text)) if (!use.lazy && !lazyFile || use.name in stringRecord(pkg.packageJson.dependencies)) runtimePackages.add(use.name);
66
- }
67
- const targetRelative = `vendor/${relative(pkg.rootDir, source).replaceAll("\\", "/")}`;
68
- const target = join(outDir, targetRelative);
69
- await mkdir(dirname(target), { recursive: true });
70
- await cp(source, target, { dereference: false });
71
- if (pkg.resources.extensions.map((entry) => resolve(entry)).includes(source)) copied.push(targetRelative);
72
- }
73
- const skillScriptPackages = /* @__PURE__ */ new Set();
74
- for (const source of pkg.resources.skills) {
75
- if (!SCRIPT_EXTENSIONS.has(extname(source))) continue;
76
- const text = await readFile(source, "utf8");
77
- for (const use of runtimeExternalPackages(source, text)) skillScriptPackages.add(use.name);
78
- }
79
- return {
80
- entries: copied,
81
- runtimePackages,
82
- skillScriptPackages
83
- };
84
- }
85
- async function copySkills(pkg, outDir) {
86
- const entryFiles = pkg.resources.skills.filter((file) => basename(file) === "SKILL.md" || file.endsWith(".md"));
87
- if (entryFiles.length === 0) return [];
88
- const names = /* @__PURE__ */ new Set();
89
- for (const entry of entryFiles) {
90
- const isBundle = basename(entry) === "SKILL.md";
91
- let name = isBundle ? basename(dirname(entry)) : basename(entry, ".md");
92
- if (names.has(name)) {
93
- const candidate = `${basename(dirname(isBundle ? dirname(entry) : entry))}-${name}`.replace(/[^a-zA-Z0-9._-]+/gu, "-");
94
- name = names.has(candidate) ? `${candidate}-${names.size}` : candidate;
95
- }
96
- names.add(name);
97
- const target = join(outDir, "skills", isBundle ? name : `${name}.md`);
98
- await mkdir(dirname(target), { recursive: true });
99
- const source = isBundle ? dirname(entry) : entry;
100
- await assertNoSymlinks(source);
101
- await cp(source, target, {
102
- recursive: isBundle,
103
- dereference: false
104
- });
105
- }
106
- return ["skills"];
107
- }
108
- async function copyPrompts(pkg, outDir) {
109
- const prompts = [];
110
- const names = /* @__PURE__ */ new Set();
111
- for (const source of pkg.resources.prompts) {
112
- const name = basename(source, ".md").toLowerCase().replace(/[^a-z0-9_-]+/gu, "-");
113
- if (names.has(name)) throw new Error(`prompt command name collision while flattening Pi package: ${name}`);
114
- names.add(name);
115
- const targetRelative = `prompts/${name}.md`;
116
- const target = join(outDir, targetRelative);
117
- await mkdir(dirname(target), { recursive: true });
118
- await assertNoSymlinks(source);
119
- await cp(source, target, { dereference: false });
120
- const { attributes, body } = parseFrontmatter(await readFile(source, "utf8"));
121
- const firstLine = body.split(/\r?\n/u).map((line) => line.trim()).find(Boolean);
122
- prompts.push({
123
- name,
124
- description: attributes.description ?? firstLine ?? `Run migrated Pi prompt ${name}`,
125
- ...attributes["argument-hint"] !== void 0 ? { argumentHint: attributes["argument-hint"] } : {},
126
- path: targetRelative
127
- });
128
- }
129
- return prompts;
130
- }
131
- async function copyNotices(pkg, outDir) {
132
- const copied = [];
133
- for (const entry of await readdir(pkg.rootDir)) {
134
- if (!/^(?:licen[cs]e|notice|copying)(?:[._-].*)?$/iu.test(entry)) continue;
135
- const source = join(pkg.rootDir, entry);
136
- const info = await lstat(source);
137
- if (info.isSymbolicLink()) throw new Error(`refusing to copy symbolic link from Pi package: ${source}`);
138
- if (!info.isFile()) continue;
139
- await cp(source, join(outDir, entry), { dereference: false });
140
- copied.push(entry);
141
- }
142
- return copied.sort();
143
- }
144
- function generatedPackageJson(pkg, generatedName, runtimeSpec, runtimePackages, hasSkills) {
145
- const declaredDependencies = {
146
- ...stringRecord(pkg.packageJson.dependencies),
147
- ...stringRecord(pkg.packageJson.optionalDependencies),
148
- ...stringRecord(pkg.packageJson.peerDependencies)
149
- };
150
- const externalRuntimePackages = [...runtimePackages].filter((name) => !SHIMMED_PI_HOST_PACKAGES.has(name));
151
- const missing = externalRuntimePackages.filter((name) => declaredDependencies[name] === void 0);
152
- if (missing.length > 0) throw new Error(`runtime dependencies are imported but not declared by the Pi package: ${missing.join(", ")}`);
153
- const declaredRuntime = {
154
- ...stringRecord(pkg.packageJson.dependencies),
155
- ...stringRecord(pkg.packageJson.optionalDependencies)
156
- };
157
- const dependencies = {
158
- ...Object.fromEntries(Object.entries(declaredRuntime).filter(([name]) => !SHIMMED_PI_HOST_PACKAGES.has(name))),
159
- ...Object.fromEntries(externalRuntimePackages.sort().map((name) => [name, declaredDependencies[name]])),
160
- ...runtimeSpec === void 0 ? {
161
- jiti: "^2.7.0",
162
- "get-east-asian-width": "^1.6.0",
163
- marked: "^16.4.1",
164
- typebox: "^1.0.4",
165
- "cross-spawn": "^7.0.6",
166
- diff: "^9.0.0"
167
- } : {},
168
- openai: "^6.40.0",
169
- ...hasSkills ? { "@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.6" } : {},
170
- ...runtimeSpec !== void 0 ? { pi2dsh: runtimeSpec } : {}
171
- };
172
- const remapImports = (value) => {
173
- if (typeof value === "string") return value.startsWith("./") ? `./vendor/${value.slice(2)}` : value;
174
- if (typeof value === "object" && value !== null && !Array.isArray(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, remapImports(entry)]));
175
- return value;
176
- };
177
- const sourceImports = pkg.packageJson.imports;
178
- return {
179
- name: generatedName,
180
- version: pkg.identity.version,
181
- description: `DeepSeek Harness adapter generated from ${pkg.identity.name}`,
182
- type: "module",
183
- main: "./index.js",
184
- ...typeof sourceImports === "object" && sourceImports !== null ? { imports: remapImports(sourceImports) } : {},
185
- files: [
186
- "index.js",
187
- "cordis.patch.yml",
188
- "pi2dsh.manifest.json",
189
- "pi2dsh.report.json",
190
- "README.md",
191
- "LICENSE*",
192
- "NOTICE*",
193
- "COPYING*",
194
- "PI2DSH-LICENSE",
195
- "runtime",
196
- "vendor",
197
- "skills",
198
- "prompts"
199
- ],
200
- dependencies,
201
- ...runtimeSpec === void 0 ? { peerDependencies: {
202
- "@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
203
- "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6"
204
- } } : {},
205
- keywords: [
206
- "dsh-plugin",
207
- "deepseek-harness",
208
- "pi-package",
209
- "pi2dsh"
210
- ],
211
- license: typeof pkg.packageJson.license === "string" ? pkg.packageJson.license : "UNLICENSED",
212
- dsh: { bundle: { patch: "./cordis.patch.yml" } }
213
- };
214
- }
215
- function generatedReadme(pkg, packageName, report) {
216
- return `# ${packageName}\n\nGenerated by [pi2dsh](https://github.com/weijiafu14/pi2dsh) from \`${pkg.identity.name}@${pkg.identity.version}\`.\n\nCompatibility verdict: **${report.verdict}** (full ${report.summary.full}, partial ${report.summary.partial}, unsupported ${report.summary.unsupported}).\n\nReview \`pi2dsh.report.json\` before installation. This bundle executes the original Pi extension source and should only be installed when that source is trusted.\n\nInstall with DeepSeek Harness (keep the \`file:\` prefix so pnpm installs this bundle's dependencies instead of creating a bare link):\n\n\`\`\`sh\ndsh plugin --profile headless add file:$PWD\ndsh --profile headless --dump-config\n\`\`\`\n\nIf the install stops with \`ERR_PNPM_IGNORED_BUILDS\` (pnpm 10+ blocks dependency build scripts by default), approve the listed packages — either run \`pnpm approve-builds\` inside the profile directory, or set them to \`true\` under \`allowBuilds\` in the profile's \`pnpm-workspace.yaml\` — then re-run the add command.\n`;
217
- }
218
- function pluginSource(manifest, runtimeImport) {
219
- const injections = ["tools", "systemPrompt"];
220
- if (manifest.prompts.length > 0 || manifest.report?.findings.some((item) => item.capability === "registerCommand") === true) injections.push("commands");
221
- if (manifest.skillDirs.length > 0) injections.push("skills");
222
- return `import { applyPiPackage } from ${JSON.stringify(runtimeImport)}\n\nexport const name = ${JSON.stringify(`pi2dsh:${packageSlug(manifest.package.name)}`)}\nexport const inject = ${JSON.stringify(injections)}\n\nconst manifest = ${JSON.stringify(manifest, null, 2)}\n\nexport async function apply(ctx, config = {}) {\n await applyPiPackage(ctx, { rootUrl: new URL('.', import.meta.url), manifest, config })\n}\n`;
223
- }
224
- async function firstExisting(paths) {
225
- for (const path of paths) try {
226
- await stat(path);
227
- return path;
228
- } catch {}
229
- throw new Error(`cannot locate pi2dsh runtime artifact; tried: ${paths.join(", ")}`);
230
- }
231
- async function copyEmbeddedRuntime(outDir) {
232
- const moduleDir = dirname(fileURLToPath(import.meta.url));
233
- const runtimeSource = await firstExisting([join(moduleDir, "runtime.mjs"), join(moduleDir, "../dist/runtime.mjs")]);
234
- const runtimeRoot = dirname(runtimeSource);
235
- const targetRoot = join(outDir, "runtime");
236
- await mkdir(targetRoot, { recursive: true });
237
- for (const entry of await readdir(runtimeRoot)) if (entry.endsWith(".mjs")) await cp(join(runtimeRoot, entry), join(targetRoot, entry));
238
- for (const sub of ["compat", join("compat", "vendor")]) {
239
- const sourceDir = join(runtimeRoot, sub);
240
- try {
241
- const entries = await readdir(sourceDir);
242
- await mkdir(join(targetRoot, sub), { recursive: true });
243
- for (const entry of entries) if (entry.endsWith(".mjs")) await cp(join(sourceDir, entry), join(targetRoot, sub, entry));
244
- } catch {}
245
- }
246
- await cp(join(targetRoot, "runtime.mjs"), join(targetRoot, "pi2dsh-runtime.mjs"));
247
- const license = await firstExisting([join(moduleDir, "../LICENSE"), join(moduleDir, "../../LICENSE")]);
248
- await cp(license, join(outDir, "PI2DSH-LICENSE"));
249
- }
250
- function patchSource(generatedName, slug) {
251
- return `- insert:\n - id: pi2dsh-${slug}\n name: ${JSON.stringify(generatedName)}\n`;
252
- }
253
- function enforceReport(report, options) {
254
- if (report.summary.fatal > 0) throw new Error(`conversion blocked: ${report.summary.fatal} fatal finding(s) — the bundle cannot be built or trusted; run inspect for details`);
255
- if (options.strict && (report.summary.partial > 0 || report.summary.unsupported > 0)) throw new Error("strict conversion requires every detected Pi API use to have full compatibility");
256
- }
257
- async function generateBundle(pkg, options) {
258
- const outDir = resolve(options.outDir);
259
- const report = await analyzePackage(pkg);
260
- enforceReport(report, options);
261
- await assertEmptyOrMissing(outDir);
262
- await mkdir(outDir, { recursive: true });
263
- const slug = packageSlug(pkg.identity.name);
264
- const packageName = `dsh-pi-${slug}`;
265
- const extensionSnapshot = await copyExtensions(pkg, outDir);
266
- const skillDirs = await copySkills(pkg, outDir);
267
- const prompts = await copyPrompts(pkg, outDir);
268
- await copyNotices(pkg, outDir);
269
- const manifest = {
270
- schemaVersion: 1,
271
- package: pkg.identity,
272
- extensions: extensionSnapshot.entries,
273
- skillDirs,
274
- prompts,
275
- report
276
- };
277
- const runtimeSpec = options.runtimeSpec;
278
- if (runtimeSpec === void 0) await copyEmbeddedRuntime(outDir);
279
- const optionalSkillDeps = [...extensionSnapshot.skillScriptPackages].filter((name) => !SHIMMED_PI_HOST_PACKAGES.has(name) && !(name in stringRecord(pkg.packageJson.dependencies)));
280
- if (optionalSkillDeps.length > 0) console.warn(`pi2dsh: skill helper scripts reference ${optionalSkillDeps.join(", ")}; install them only if you use those skills`);
281
- await Promise.all([
282
- writeFile(join(outDir, "package.json"), `${JSON.stringify(generatedPackageJson(pkg, packageName, runtimeSpec, extensionSnapshot.runtimePackages, skillDirs.length > 0), null, 2)}\n`),
283
- writeFile(join(outDir, "pi2dsh.manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`),
284
- writeFile(join(outDir, "pi2dsh.report.json"), `${JSON.stringify(report, null, 2)}\n`),
285
- writeFile(join(outDir, "index.js"), pluginSource(manifest, runtimeSpec === void 0 ? "./runtime/pi2dsh-runtime.mjs" : "pi2dsh/runtime")),
286
- writeFile(join(outDir, "cordis.patch.yml"), patchSource(packageName, slug)),
287
- writeFile(join(outDir, "README.md"), generatedReadme(pkg, packageName, report))
288
- ]);
289
- return {
290
- outDir,
291
- report,
292
- packageName
293
- };
294
- }
295
- //#endregion
296
- export { generateBundle };
297
-
298
- //# sourceMappingURL=generator-CSOv6wYT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator-CSOv6wYT.mjs","names":["parseYaml"],"sources":["../src/generator.ts"],"sourcesContent":["import { cp, lstat, mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises'\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { parse as parseYaml } from 'yaml'\nimport { analyzePackage } from './analyzer.js'\nimport { collectLocalClosure, runtimeExternalPackages, SCRIPT_EXTENSIONS } from './module-graph.js'\nimport type {\n CompatibilityReport,\n GenerateOptions,\n GeneratedRuntimeManifest,\n ResolvedPiPackage,\n} from './types.js'\n\ninterface PromptMetadata {\n name: string\n description: string\n argumentHint?: string\n path: string\n}\n\nconst SHIMMED_PI_HOST_PACKAGES = new Set([\n '@earendil-works/pi-coding-agent',\n '@mariozechner/pi-coding-agent',\n '@earendil-works/pi-tui',\n '@mariozechner/pi-tui',\n '@earendil-works/pi-ai',\n '@mariozechner/pi-ai',\n // Host-provided in Pi's loader whitelist; the runtime aliases them too.\n 'typebox',\n '@sinclair/typebox',\n])\n\nfunction packageSlug(name: string): string {\n const slug = name.replace(/^@/u, '').replaceAll('/', '-').replace(/[^a-zA-Z0-9._-]+/gu, '-').toLowerCase()\n return slug.replace(/^-+|-+$/gu, '') || 'package'\n}\n\nfunction stringRecord(value: unknown): Record<string, string> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return {}\n return Object.fromEntries(Object.entries(value).filter((entry): entry is [string, string] => typeof entry[1] === 'string'))\n}\n\nasync function assertEmptyOrMissing(path: string): Promise<void> {\n try {\n const info = await stat(path)\n if (!info.isDirectory()) throw new Error(`output exists and is not a directory: ${path}`)\n const entries = await readdir(path)\n if (entries.length > 0) throw new Error(`output directory is not empty: ${path}`)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n}\n\nfunction parseFrontmatter(text: string): { attributes: Record<string, string>; body: string } {\n const normalized = text.replace(/\\r\\n?/gu, '\\n')\n if (!normalized.startsWith('---')) return { attributes: {}, body: normalized }\n const endIndex = normalized.indexOf('\\n---', 3)\n if (endIndex === -1) return { attributes: {}, body: normalized }\n const raw: unknown = parseYaml(normalized.slice(4, endIndex))\n const attributes = typeof raw === 'object' && raw !== null && !Array.isArray(raw)\n ? stringRecord(raw)\n : {}\n return { attributes, body: normalized.slice(endIndex + 4).trim() }\n}\n\nasync function assertNoSymlinks(path: string): Promise<void> {\n const info = await lstat(path)\n if (info.isSymbolicLink()) throw new Error(`refusing to copy symbolic link from Pi package: ${path}`)\n if (!info.isDirectory()) return\n for (const entry of await readdir(path)) await assertNoSymlinks(join(path, entry))\n}\n\nasync function copyExtensions(pkg: ResolvedPiPackage, outDir: string): Promise<{ entries: string[]; runtimePackages: Set<string>; skillScriptPackages: Set<string> }> {\n const copied: string[] = []\n const runtimePackages = new Set<string>()\n const closure = await collectLocalClosure(pkg.rootDir, pkg.resources.extensions)\n // Unresolved references never block the snapshot here: the analyzer grades\n // them (fatal only on the load-time path) and enforceReport is the gate.\n // The copy below preserves the published layout, so lazy dead references\n // behave exactly as they would under Pi.\n for (const issue of closure.issues) {\n console.warn(`pi2dsh: unresolved ${issue.kind} reference ${JSON.stringify(issue.specifier)} from ${relative(pkg.rootDir, issue.file)} (${issue.lazy ? 'lazy path — fails at feature use, as under Pi' : 'load-time path'})`)\n }\n for (const source of closure.files) {\n if (SCRIPT_EXTENSIONS.has(extname(source))) {\n const text = await readFile(source, 'utf8')\n // Lazy undeclared imports stay out of bundle dependencies: the package\n // works without them (Pi semantics) and they may not even be installable.\n // Lazy means the import site OR the whole file only evaluates on demand\n // (a top-level import inside a dynamically-imported module loads lazily).\n const lazyFile = !closure.loadTimeFiles.has(source)\n for (const use of runtimeExternalPackages(source, text)) {\n if ((!use.lazy && !lazyFile) || use.name in stringRecord(pkg.packageJson.dependencies)) runtimePackages.add(use.name)\n }\n }\n const sourceRelative = relative(pkg.rootDir, source).replaceAll('\\\\', '/')\n const targetRelative = `vendor/${sourceRelative}`\n const target = join(outDir, targetRelative)\n await mkdir(dirname(target), { recursive: true })\n await cp(source, target, { dereference: false })\n if (pkg.resources.extensions.map(entry => resolve(entry)).includes(source)) copied.push(targetRelative)\n }\n // Skill helper scripts run on the user's explicit request, not at extension\n // load; their imports (often themselves try/catch-guarded) are informational,\n // never a conversion blocker (mitsupi ships googleapis-using skill scripts\n // this way and works fine in Pi).\n const skillScriptPackages = new Set<string>()\n for (const source of pkg.resources.skills) {\n if (!SCRIPT_EXTENSIONS.has(extname(source))) continue\n const text = await readFile(source, 'utf8')\n for (const use of runtimeExternalPackages(source, text)) skillScriptPackages.add(use.name)\n }\n return { entries: copied, runtimePackages, skillScriptPackages }\n}\n\nasync function copySkills(pkg: ResolvedPiPackage, outDir: string): Promise<string[]> {\n const entryFiles = pkg.resources.skills.filter(file => basename(file) === 'SKILL.md' || file.endsWith('.md'))\n if (entryFiles.length === 0) return []\n const names = new Set<string>()\n for (const entry of entryFiles) {\n const isBundle = basename(entry) === 'SKILL.md'\n let name = isBundle ? basename(dirname(entry)) : basename(entry, '.md')\n if (names.has(name)) {\n // Same-named skills under different parents (piolium ships several):\n // disambiguate with the parent directory instead of refusing the package.\n const parent = basename(dirname(isBundle ? dirname(entry) : entry))\n const candidate = `${parent}-${name}`.replace(/[^a-zA-Z0-9._-]+/gu, '-')\n name = names.has(candidate) ? `${candidate}-${names.size}` : candidate\n }\n names.add(name)\n const target = join(outDir, 'skills', isBundle ? name : `${name}.md`)\n await mkdir(dirname(target), { recursive: true })\n const source = isBundle ? dirname(entry) : entry\n await assertNoSymlinks(source)\n await cp(source, target, { recursive: isBundle, dereference: false })\n }\n return ['skills']\n}\n\nasync function copyPrompts(pkg: ResolvedPiPackage, outDir: string): Promise<PromptMetadata[]> {\n const prompts: PromptMetadata[] = []\n const names = new Set<string>()\n for (const source of pkg.resources.prompts) {\n const name = basename(source, '.md').toLowerCase().replace(/[^a-z0-9_-]+/gu, '-')\n if (names.has(name)) throw new Error(`prompt command name collision while flattening Pi package: ${name}`)\n names.add(name)\n const targetRelative = `prompts/${name}.md`\n const target = join(outDir, targetRelative)\n await mkdir(dirname(target), { recursive: true })\n await assertNoSymlinks(source)\n await cp(source, target, { dereference: false })\n const { attributes, body } = parseFrontmatter(await readFile(source, 'utf8'))\n const firstLine = body.split(/\\r?\\n/u).map(line => line.trim()).find(Boolean)\n prompts.push({\n name,\n description: attributes.description ?? firstLine ?? `Run migrated Pi prompt ${name}`,\n ...(attributes['argument-hint'] !== undefined ? { argumentHint: attributes['argument-hint'] } : {}),\n path: targetRelative,\n })\n }\n return prompts\n}\n\nasync function copyNotices(pkg: ResolvedPiPackage, outDir: string): Promise<string[]> {\n const copied: string[] = []\n for (const entry of await readdir(pkg.rootDir)) {\n if (!/^(?:licen[cs]e|notice|copying)(?:[._-].*)?$/iu.test(entry)) continue\n const source = join(pkg.rootDir, entry)\n const info = await lstat(source)\n if (info.isSymbolicLink()) throw new Error(`refusing to copy symbolic link from Pi package: ${source}`)\n if (!info.isFile()) continue\n await cp(source, join(outDir, entry), { dereference: false })\n copied.push(entry)\n }\n return copied.sort()\n}\n\nfunction generatedPackageJson(\n pkg: ResolvedPiPackage,\n generatedName: string,\n runtimeSpec: string | undefined,\n runtimePackages: ReadonlySet<string>,\n hasSkills: boolean,\n): Record<string, unknown> {\n const declaredDependencies = {\n ...stringRecord(pkg.packageJson.dependencies),\n ...stringRecord(pkg.packageJson.optionalDependencies),\n ...stringRecord(pkg.packageJson.peerDependencies),\n }\n const externalRuntimePackages = [...runtimePackages].filter(name => !SHIMMED_PI_HOST_PACKAGES.has(name))\n const missing = externalRuntimePackages.filter(name => declaredDependencies[name] === undefined)\n if (missing.length > 0) {\n throw new Error(`runtime dependencies are imported but not declared by the Pi package: ${missing.join(', ')}`)\n }\n // Carry EVERY declared runtime dependency, not only statically detected\n // imports: packages load their own deps dynamically (computed require,\n // optional native backends) and the original manifest is the authority on\n // what they need.\n const declaredRuntime = {\n ...stringRecord(pkg.packageJson.dependencies),\n ...stringRecord(pkg.packageJson.optionalDependencies),\n }\n const dependencies = {\n ...Object.fromEntries(Object.entries(declaredRuntime).filter(([name]) => !SHIMMED_PI_HOST_PACKAGES.has(name))),\n ...Object.fromEntries(externalRuntimePackages.sort().map(name => [name, declaredDependencies[name]])),\n // The embedded runtime's own runtime dependencies (vendored Pi width math\n // uses get-east-asian-width; the pi-tui shim re-exports marked; typebox is\n // the host-provided schema library Pi's loader gives every extension;\n // vendored Pi bash tooling spawns through cross-spawn exactly as Pi does).\n ...(runtimeSpec === undefined\n ? { jiti: '^2.7.0', 'get-east-asian-width': '^1.6.0', marked: '^16.4.1', typebox: '^1.0.4', 'cross-spawn': '^7.0.6', diff: '^9.0.0' }\n : {}),\n // The bridge's own openai-completions client (openai SDK) backs the\n // single model directory's most common wire protocol; the rarer apis\n // lazily use a real pi-ai when a mounted package's dependency tree\n // carries one. Depending on pi-ai here would drag @google/genai →\n // protobufjs, whose blocked install script fails `dsh plugin add`\n // for transitive dependencies.\n openai: '^6.40.0',\n ...(hasSkills ? { '@deepseek-ai/dsh-skill-filesystem': '^0.1.0-rc.6' } : {}),\n ...(runtimeSpec !== undefined ? { pi2dsh: runtimeSpec } : {}),\n }\n // Re-point the package's Node subpath-imports map (\"#x\": \"./src/x.js\") at\n // the vendored snapshot so '#'-imports keep resolving inside the bundle.\n const remapImports = (value: unknown): unknown => {\n if (typeof value === 'string') return value.startsWith('./') ? `./vendor/${value.slice(2)}` : value\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, remapImports(entry)]))\n }\n return value\n }\n const sourceImports = pkg.packageJson.imports\n return {\n name: generatedName,\n version: pkg.identity.version,\n description: `DeepSeek Harness adapter generated from ${pkg.identity.name}`,\n type: 'module',\n main: './index.js',\n ...(typeof sourceImports === 'object' && sourceImports !== null\n ? { imports: remapImports(sourceImports) as Record<string, unknown> }\n : {}),\n files: ['index.js', 'cordis.patch.yml', 'pi2dsh.manifest.json', 'pi2dsh.report.json', 'README.md', 'LICENSE*', 'NOTICE*', 'COPYING*', 'PI2DSH-LICENSE', 'runtime', 'vendor', 'skills', 'prompts'],\n dependencies,\n ...(runtimeSpec === undefined\n ? {\n peerDependencies: {\n '@deepseek-ai/dsh-llm': '^0.1.0-rc.6',\n '@deepseek-ai/dsh-system-prompt': '^0.1.0-rc.6',\n },\n }\n : {}),\n keywords: ['dsh-plugin', 'deepseek-harness', 'pi-package', 'pi2dsh'],\n license: typeof pkg.packageJson.license === 'string' ? pkg.packageJson.license : 'UNLICENSED',\n dsh: { bundle: { patch: './cordis.patch.yml' } },\n }\n}\n\nfunction generatedReadme(pkg: ResolvedPiPackage, packageName: string, report: CompatibilityReport): string {\n return `# ${packageName}\\n\\n`\n + `Generated by [pi2dsh](https://github.com/weijiafu14/pi2dsh) from \\`${pkg.identity.name}@${pkg.identity.version}\\`.\\n\\n`\n + `Compatibility verdict: **${report.verdict}** (full ${report.summary.full}, partial ${report.summary.partial}, unsupported ${report.summary.unsupported}).\\n\\n`\n + `Review \\`pi2dsh.report.json\\` before installation. This bundle executes the original Pi extension source and should only be installed when that source is trusted.\\n\\n`\n + `Install with DeepSeek Harness (keep the \\`file:\\` prefix so pnpm installs this bundle's dependencies instead of creating a bare link):\\n\\n`\n + `\\`\\`\\`sh\\ndsh plugin --profile headless add file:$PWD\\ndsh --profile headless --dump-config\\n\\`\\`\\`\\n\\n`\n + `If the install stops with \\`ERR_PNPM_IGNORED_BUILDS\\` (pnpm 10+ blocks dependency build scripts by default), approve the listed packages — either run \\`pnpm approve-builds\\` inside the profile directory, or set them to \\`true\\` under \\`allowBuilds\\` in the profile's \\`pnpm-workspace.yaml\\` — then re-run the add command.\\n`\n}\n\nfunction pluginSource(manifest: GeneratedRuntimeManifest, runtimeImport: string): string {\n const injections = ['tools', 'systemPrompt']\n if (manifest.prompts.length > 0 || manifest.report?.findings.some(item => item.capability === 'registerCommand') === true) {\n injections.push('commands')\n }\n if (manifest.skillDirs.length > 0) injections.push('skills')\n return `import { applyPiPackage } from ${JSON.stringify(runtimeImport)}\\n\\n`\n + `export const name = ${JSON.stringify(`pi2dsh:${packageSlug(manifest.package.name)}`)}\\n`\n + `export const inject = ${JSON.stringify(injections)}\\n\\n`\n + `const manifest = ${JSON.stringify(manifest, null, 2)}\\n\\n`\n + `export async function apply(ctx, config = {}) {\\n`\n + ` await applyPiPackage(ctx, { rootUrl: new URL('.', import.meta.url), manifest, config })\\n`\n + `}\\n`\n}\n\nasync function firstExisting(paths: string[]): Promise<string> {\n for (const path of paths) {\n try {\n await stat(path)\n return path\n } catch {\n // Try the next package/source layout.\n }\n }\n throw new Error(`cannot locate pi2dsh runtime artifact; tried: ${paths.join(', ')}`)\n}\n\nasync function copyEmbeddedRuntime(outDir: string): Promise<void> {\n const moduleDir = dirname(fileURLToPath(import.meta.url))\n const runtimeSource = await firstExisting([\n join(moduleDir, 'runtime.mjs'),\n join(moduleDir, '../dist/runtime.mjs'),\n ])\n const runtimeRoot = dirname(runtimeSource)\n const targetRoot = join(outDir, 'runtime')\n await mkdir(targetRoot, { recursive: true })\n // Copy every emitted module, including bundler-named shared chunks — a\n // fixed file list silently breaks whenever the bundler re-splits chunks.\n for (const entry of await readdir(runtimeRoot)) {\n if (entry.endsWith('.mjs')) await cp(join(runtimeRoot, entry), join(targetRoot, entry))\n }\n for (const sub of ['compat', join('compat', 'vendor')]) {\n const sourceDir = join(runtimeRoot, sub)\n try {\n const entries = await readdir(sourceDir)\n await mkdir(join(targetRoot, sub), { recursive: true })\n for (const entry of entries) {\n if (entry.endsWith('.mjs')) await cp(join(sourceDir, entry), join(targetRoot, sub, entry))\n }\n } catch {\n // dist layout without that subdirectory\n }\n }\n await cp(join(targetRoot, 'runtime.mjs'), join(targetRoot, 'pi2dsh-runtime.mjs'))\n const license = await firstExisting([join(moduleDir, '../LICENSE'), join(moduleDir, '../../LICENSE')])\n await cp(license, join(outDir, 'PI2DSH-LICENSE'))\n}\n\nfunction patchSource(generatedName: string, slug: string): string {\n return `- insert:\\n - id: pi2dsh-${slug}\\n name: ${JSON.stringify(generatedName)}\\n`\n}\n\nfunction enforceReport(report: CompatibilityReport, options: GenerateOptions): void {\n // Fatal findings (incomplete module closure, undeclared runtime deps,\n // resource escapes) mean the bundle cannot be built or trusted; no flag\n // bypasses them. Unsupported findings are explicit, load-safe degradations\n // — the bundle installs and the black-box run decides real usability.\n if (report.summary.fatal > 0) {\n throw new Error(\n `conversion blocked: ${report.summary.fatal} fatal finding(s) — the bundle cannot be built or trusted; run inspect for details`,\n )\n }\n if (options.strict && (report.summary.partial > 0 || report.summary.unsupported > 0)) {\n throw new Error('strict conversion requires every detected Pi API use to have full compatibility')\n }\n}\n\nexport async function generateBundle(\n pkg: ResolvedPiPackage,\n options: GenerateOptions,\n): Promise<{ outDir: string; report: CompatibilityReport; packageName: string }> {\n const outDir = resolve(options.outDir)\n const report = await analyzePackage(pkg)\n enforceReport(report, options)\n await assertEmptyOrMissing(outDir)\n await mkdir(outDir, { recursive: true })\n\n const slug = packageSlug(pkg.identity.name)\n const packageName = `dsh-pi-${slug}`\n const extensionSnapshot = await copyExtensions(pkg, outDir)\n const skillDirs = await copySkills(pkg, outDir)\n const prompts = await copyPrompts(pkg, outDir)\n await copyNotices(pkg, outDir)\n const manifest: GeneratedRuntimeManifest = {\n schemaVersion: 1,\n package: pkg.identity,\n extensions: extensionSnapshot.entries,\n skillDirs,\n prompts,\n report,\n }\n const runtimeSpec = options.runtimeSpec\n if (runtimeSpec === undefined) await copyEmbeddedRuntime(outDir)\n const optionalSkillDeps = [...extensionSnapshot.skillScriptPackages]\n .filter(name => !SHIMMED_PI_HOST_PACKAGES.has(name) && !(name in stringRecord(pkg.packageJson.dependencies)))\n if (optionalSkillDeps.length > 0) {\n console.warn(`pi2dsh: skill helper scripts reference ${optionalSkillDeps.join(', ')}; install them only if you use those skills`)\n }\n\n await Promise.all([\n writeFile(join(outDir, 'package.json'), `${JSON.stringify(generatedPackageJson(pkg, packageName, runtimeSpec, extensionSnapshot.runtimePackages, skillDirs.length > 0), null, 2)}\\n`),\n writeFile(join(outDir, 'pi2dsh.manifest.json'), `${JSON.stringify(manifest, null, 2)}\\n`),\n writeFile(join(outDir, 'pi2dsh.report.json'), `${JSON.stringify(report, null, 2)}\\n`),\n writeFile(join(outDir, 'index.js'), pluginSource(manifest, runtimeSpec === undefined ? './runtime/pi2dsh-runtime.mjs' : 'pi2dsh/runtime')),\n writeFile(join(outDir, 'cordis.patch.yml'), patchSource(packageName, slug)),\n writeFile(join(outDir, 'README.md'), generatedReadme(pkg, packageName, report)),\n ])\n return { outDir, report, packageName }\n}\n"],"mappings":";;;;;;;AAoBA,MAAM,2CAA2B,IAAI,IAAI;CACvC;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;AACF,CAAC;AAED,SAAS,YAAY,MAAsB;CAEzC,OADa,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,WAAW,KAAK,GAAG,CAAC,CAAC,QAAQ,sBAAsB,GAAG,CAAC,CAAC,YACnF,CAAC,CAAC,QAAQ,aAAa,EAAE,KAAK;AAC1C;AAEA,SAAS,aAAa,OAAwC;CAC5D,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACjF,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,UAAqC,OAAO,MAAM,OAAO,QAAQ,CAAC;AAC5H;AAEA,eAAe,qBAAqB,MAA6B;CAC/D,IAAI;EAEF,IAAI,EAAC,MADc,KAAK,IAAI,EAAA,CAClB,YAAY,GAAG,MAAM,IAAI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