(workDir: string)
| 21 | /** |
| 22 | * Package the pack as a lightweight zip file. |
| 23 | * Includes: skillpack.json, optional job.json, optional app.html, |
| 24 | * optional AGENTS.md / SOUL.md, start.sh, start.bat, skills/ |
| 25 | * Does NOT include server/, web/, or any other runtime files. |
| 26 | */ |
| 27 | export async function zipCommand( |
| 28 | workDir: string, |
| 29 | options: ZipCommandOptions = {}, |
| 30 | ): Promise<string> { |
| 31 | const config = loadConfig(workDir); |
| 32 | const slug = config.name.toLowerCase().replace(/\s+/g, "-"); |
| 33 | const zipName = `${slug}.zip`; |
| 34 | const zipPath = path.join(workDir, zipName); |
| 35 | |
| 36 | if (!options.skipSkillInstall) { |
| 37 | // Reinstall each skill independently so one failure does not block the rest. |
| 38 | for (const skill of config.skills) { |
| 39 | try { |
| 40 | installSkills(workDir, [skill]); |
| 41 | } catch (err) { |
| 42 | console.warn( |
| 43 | chalk.yellow(`Warning: Could not install skill "${skill.name}": ${err}`), |
| 44 | ); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | syncSkillDescriptions(workDir, config); |
| 49 | saveConfig(workDir, config); |
| 50 | |
| 51 | console.log(chalk.blue(`Packaging ${config.name}...`)); |
| 52 | |
| 53 | const output = fs.createWriteStream(zipPath); |
| 54 | const archive = archiver("zip", { zlib: { level: 9 } }); |
| 55 | |
| 56 | return new Promise((resolve, reject) => { |
| 57 | output.on("close", () => { |
| 58 | console.log( |
| 59 | chalk.green( |
| 60 | `Packaging complete: ${zipName} (${(archive.pointer() / 1024).toFixed(1)} KB)`, |
| 61 | ), |
| 62 | ); |
| 63 | resolve(zipPath); |
| 64 | }); |
| 65 | |
| 66 | archive.on("error", (err) => reject(err)); |
| 67 | archive.pipe(output); |
| 68 | |
| 69 | const prefix = slug; |
| 70 | |
| 71 | // 1. skillpack.json |
| 72 | archive.file(getPackPath(workDir), { |
| 73 | name: `${prefix}/${PACK_FILE}`, |
| 74 | }); |
| 75 | |
| 76 | // 2. optional scheduled jobs |
| 77 | const jobFilePath = getJobFilePath(workDir); |
| 78 | if (fs.existsSync(jobFilePath)) { |
| 79 | archive.file(jobFilePath, { name: `${prefix}/${JOB_FILE}` }); |
| 80 | } |
no test coverage detected