harnesstap 1.2.0 → 1.3.1
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/README.md +28 -15
- package/dist/apply-2GRNKR5H.js +67 -0
- package/dist/apply-2GRNKR5H.js.map +1 -0
- package/dist/approve-KQNCNH2R.js +181 -0
- package/dist/approve-KQNCNH2R.js.map +1 -0
- package/dist/audit-SLYOZCMI.js +434 -0
- package/dist/audit-SLYOZCMI.js.map +1 -0
- package/dist/auth-3IEVICFT.js +220 -0
- package/dist/auth-3IEVICFT.js.map +1 -0
- package/dist/bin.js +166 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-2EIJYDNI.js +10945 -0
- package/dist/chunk-2EIJYDNI.js.map +1 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-37E5M4JX.js +34 -0
- package/dist/chunk-37E5M4JX.js.map +1 -0
- package/dist/chunk-3FIWOI3H.js +98 -0
- package/dist/chunk-3FIWOI3H.js.map +1 -0
- package/dist/chunk-3IWTJCPA.js +6448 -0
- package/dist/chunk-3IWTJCPA.js.map +1 -0
- package/dist/chunk-3IZ7SEGT.js +346 -0
- package/dist/chunk-3IZ7SEGT.js.map +1 -0
- package/dist/chunk-3RBYT7QN.js +540 -0
- package/dist/chunk-3RBYT7QN.js.map +1 -0
- package/dist/chunk-4KNQZDZC.js +115 -0
- package/dist/chunk-4KNQZDZC.js.map +1 -0
- package/dist/chunk-5F3LNDZG.js +9 -0
- package/dist/chunk-5F3LNDZG.js.map +1 -0
- package/dist/chunk-63U7QWNY.js +364 -0
- package/dist/chunk-63U7QWNY.js.map +1 -0
- package/dist/chunk-6BY4BV5G.js +998 -0
- package/dist/chunk-6BY4BV5G.js.map +1 -0
- package/dist/chunk-7L2K4N25.js +610 -0
- package/dist/chunk-7L2K4N25.js.map +1 -0
- package/dist/chunk-7LWH5SWH.js +18 -0
- package/dist/chunk-7LWH5SWH.js.map +1 -0
- package/dist/chunk-BIBUCC2E.js +696 -0
- package/dist/chunk-BIBUCC2E.js.map +1 -0
- package/dist/chunk-BSOBXLYI.js +172 -0
- package/dist/chunk-BSOBXLYI.js.map +1 -0
- package/dist/chunk-C4QBVVEH.js +32 -0
- package/dist/chunk-C4QBVVEH.js.map +1 -0
- package/dist/chunk-CHQGE2HF.js +283 -0
- package/dist/chunk-CHQGE2HF.js.map +1 -0
- package/dist/chunk-DV74UZJI.js +87 -0
- package/dist/chunk-DV74UZJI.js.map +1 -0
- package/dist/chunk-DWVAR4BP.js +656 -0
- package/dist/chunk-DWVAR4BP.js.map +1 -0
- package/dist/chunk-DXKAKKLP.js +302 -0
- package/dist/chunk-DXKAKKLP.js.map +1 -0
- package/dist/chunk-EIWXS4RM.js +235 -0
- package/dist/chunk-EIWXS4RM.js.map +1 -0
- package/dist/chunk-EWBCFAF3.js +681 -0
- package/dist/chunk-EWBCFAF3.js.map +1 -0
- package/dist/chunk-F2L4VNQK.js +1759 -0
- package/dist/chunk-F2L4VNQK.js.map +1 -0
- package/dist/chunk-G26HZZDJ.js +1359 -0
- package/dist/chunk-G26HZZDJ.js.map +1 -0
- package/dist/chunk-GQKKX7OE.js +818 -0
- package/dist/chunk-GQKKX7OE.js.map +1 -0
- package/dist/chunk-GRJY22U6.js +691 -0
- package/dist/chunk-GRJY22U6.js.map +1 -0
- package/dist/chunk-H6DVP2SI.js +682 -0
- package/dist/chunk-H6DVP2SI.js.map +1 -0
- package/dist/chunk-HVVPTCKR.js +1173 -0
- package/dist/chunk-HVVPTCKR.js.map +1 -0
- package/dist/chunk-I6XFZLTJ.js +9 -0
- package/dist/chunk-I6XFZLTJ.js.map +1 -0
- package/dist/chunk-IBOABSIA.js +17 -0
- package/dist/chunk-IBOABSIA.js.map +1 -0
- package/dist/chunk-IK524ZDW.js +691 -0
- package/dist/chunk-IK524ZDW.js.map +1 -0
- package/dist/chunk-IRU7NBOT.js +141 -0
- package/dist/chunk-IRU7NBOT.js.map +1 -0
- package/dist/chunk-J4CKQXQ6.js +806 -0
- package/dist/chunk-J4CKQXQ6.js.map +1 -0
- package/dist/chunk-JKGSJGCC.js +311 -0
- package/dist/chunk-JKGSJGCC.js.map +1 -0
- package/dist/chunk-JQOKQKQT.js +158 -0
- package/dist/chunk-JQOKQKQT.js.map +1 -0
- package/dist/chunk-JRFUTIEH.js +426 -0
- package/dist/chunk-JRFUTIEH.js.map +1 -0
- package/dist/chunk-K2BPYEH5.js +491 -0
- package/dist/chunk-K2BPYEH5.js.map +1 -0
- package/dist/chunk-KCQC7YBK.js +7795 -0
- package/dist/chunk-KCQC7YBK.js.map +1 -0
- package/dist/chunk-KDAV2GUT.js +1357 -0
- package/dist/chunk-KDAV2GUT.js.map +1 -0
- package/dist/chunk-KDDXZBMC.js +583 -0
- package/dist/chunk-KDDXZBMC.js.map +1 -0
- package/dist/chunk-KMWHZSEG.js +41 -0
- package/dist/chunk-KMWHZSEG.js.map +1 -0
- package/dist/chunk-KRI4R7EM.js +25 -0
- package/dist/chunk-KRI4R7EM.js.map +1 -0
- package/dist/chunk-LNJ3WZZX.js +186 -0
- package/dist/chunk-LNJ3WZZX.js.map +1 -0
- package/dist/chunk-MWXA4PFE.js +103 -0
- package/dist/chunk-MWXA4PFE.js.map +1 -0
- package/dist/chunk-MY62SSKC.js +183 -0
- package/dist/chunk-MY62SSKC.js.map +1 -0
- package/dist/chunk-NAGAJ5UM.js +145 -0
- package/dist/chunk-NAGAJ5UM.js.map +1 -0
- package/dist/chunk-NJ7WRKIQ.js +532 -0
- package/dist/chunk-NJ7WRKIQ.js.map +1 -0
- package/dist/chunk-OS6NUIBJ.js +38 -0
- package/dist/chunk-OS6NUIBJ.js.map +1 -0
- package/dist/chunk-PXU2OS26.js +238 -0
- package/dist/chunk-PXU2OS26.js.map +1 -0
- package/dist/chunk-QO4LBDVI.js +496 -0
- package/dist/chunk-QO4LBDVI.js.map +1 -0
- package/dist/chunk-QRZPQNLX.js +65 -0
- package/dist/chunk-QRZPQNLX.js.map +1 -0
- package/dist/chunk-SNVAMWB7.js +40 -0
- package/dist/chunk-SNVAMWB7.js.map +1 -0
- package/dist/chunk-SPRVUATR.js +430 -0
- package/dist/chunk-SPRVUATR.js.map +1 -0
- package/dist/chunk-SY7G5QEI.js +35 -0
- package/dist/chunk-SY7G5QEI.js.map +1 -0
- package/dist/chunk-SZNBUIDR.js +6438 -0
- package/dist/chunk-SZNBUIDR.js.map +1 -0
- package/dist/chunk-TQ2NA4Z4.js +24 -0
- package/dist/chunk-TQ2NA4Z4.js.map +1 -0
- package/dist/chunk-TYULB6ZY.js +2959 -0
- package/dist/chunk-TYULB6ZY.js.map +1 -0
- package/dist/chunk-UJYFTXHV.js +296 -0
- package/dist/chunk-UJYFTXHV.js.map +1 -0
- package/dist/chunk-VC6OKCJF.js +184 -0
- package/dist/chunk-VC6OKCJF.js.map +1 -0
- package/dist/chunk-VL2NWCZV.js +118 -0
- package/dist/chunk-VL2NWCZV.js.map +1 -0
- package/dist/chunk-VL7BGD47.js +514 -0
- package/dist/chunk-VL7BGD47.js.map +1 -0
- package/dist/chunk-VQVUJYYY.js +244 -0
- package/dist/chunk-VQVUJYYY.js.map +1 -0
- package/dist/chunk-VZQG2JDV.js +9 -0
- package/dist/chunk-VZQG2JDV.js.map +1 -0
- package/dist/chunk-XFZQVYIN.js +115 -0
- package/dist/chunk-XFZQVYIN.js.map +1 -0
- package/dist/chunk-XGTTOO4R.js +84 -0
- package/dist/chunk-XGTTOO4R.js.map +1 -0
- package/dist/chunk-XQFT4PEP.js +60 -0
- package/dist/chunk-XQFT4PEP.js.map +1 -0
- package/dist/chunk-YDD3ES2K.js +571 -0
- package/dist/chunk-YDD3ES2K.js.map +1 -0
- package/dist/chunk-ZY2MZ2KQ.js +1140 -0
- package/dist/chunk-ZY2MZ2KQ.js.map +1 -0
- package/dist/compile-57EEIUMB.js +161 -0
- package/dist/compile-57EEIUMB.js.map +1 -0
- package/dist/config-4EJ3D7QJ.js +438 -0
- package/dist/config-4EJ3D7QJ.js.map +1 -0
- package/dist/doctor-EEV6P5CH.js +111 -0
- package/dist/doctor-EEV6P5CH.js.map +1 -0
- package/dist/environment-WFEG4DAT.js +2745 -0
- package/dist/environment-WFEG4DAT.js.map +1 -0
- package/dist/github-BSMQD72A.js +114 -0
- package/dist/github-BSMQD72A.js.map +1 -0
- package/dist/harness-VX3PNVQW.js +746 -0
- package/dist/harness-VX3PNVQW.js.map +1 -0
- package/dist/help-AW2HKX63.js +2079 -0
- package/dist/help-AW2HKX63.js.map +1 -0
- package/dist/help-BVFOZD7E.js +1892 -0
- package/dist/help-BVFOZD7E.js.map +1 -0
- package/dist/index.d.ts +164 -1
- package/dist/index.js +50 -59246
- package/dist/index.js.map +1 -1
- package/dist/init-SPN2GEZ4.js +873 -0
- package/dist/init-SPN2GEZ4.js.map +1 -0
- package/dist/lock-K2LLUU7H.js +455 -0
- package/dist/lock-K2LLUU7H.js.map +1 -0
- package/dist/marketplace-VEKSWGX3.js +495 -0
- package/dist/marketplace-VEKSWGX3.js.map +1 -0
- package/dist/mcp-T6DKIKSF.js +202 -0
- package/dist/mcp-T6DKIKSF.js.map +1 -0
- package/dist/migrate-OO37WSB2.js +1043 -0
- package/dist/migrate-OO37WSB2.js.map +1 -0
- package/dist/open-3V3QK5RK.js +32 -0
- package/dist/open-3V3QK5RK.js.map +1 -0
- package/dist/pack-V32UPC7W.js +99 -0
- package/dist/pack-V32UPC7W.js.map +1 -0
- package/dist/plugin-KOBNQ7GT.js +64 -0
- package/dist/plugin-KOBNQ7GT.js.map +1 -0
- package/dist/plugin-from-project-X3VO3MB6.js +16 -0
- package/dist/plugin-from-project-X3VO3MB6.js.map +1 -0
- package/dist/policy-F5MKZNOC.js +105 -0
- package/dist/policy-F5MKZNOC.js.map +1 -0
- package/dist/profile-H4PMH4XT.js +1886 -0
- package/dist/profile-H4PMH4XT.js.map +1 -0
- package/dist/project-QVNEJJGH.js +1392 -0
- package/dist/project-QVNEJJGH.js.map +1 -0
- package/dist/resource-GL4RLSGI.js +555 -0
- package/dist/resource-GL4RLSGI.js.map +1 -0
- package/dist/version-PBHZK44K.js +17 -0
- package/dist/version-PBHZK44K.js.map +1 -0
- package/package.json +21 -14
- package/schemas/ap-package.v1.json +36 -0
- package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
- package/schemas/fixtures/confidence.ap.json +13 -0
- package/schemas/fixtures/context7.ap.json +13 -0
- package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
- package/schemas/fixtures/superpowers.ap.json +13 -0
- package/schemas/fixtures/third-party-skills.ap.json +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/migrate-scope.ts","../src/services/migrate.ts","../src/services/resource-import-export.ts","../src/services/order-to-override-migration.ts","../src/services/wizards/migrate-export.ts","../src/services/wizards/migrate-import.ts","../src/cli/commands/migrate.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { extname, join, resolve } from \"node:path\";\nimport { getPlugin, getPluginResources } from \"../models/plugin-model.js\";\nimport type { Plugin } from \"../types.js\";\nimport {\n buildApPackageFiles,\n writeApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport { importApPackageFiles } from \"./agent-plugins/import.js\";\nimport {\n isApEnvelopePath,\n writeApEnvelope,\n} from \"./agent-plugins/envelope.js\";\nimport { slugifyApName } from \"./agent-plugins/name.js\";\nimport { loadVerifiedPackageFiles } from \"./apm-bundle.js\";\nimport {\n isLegacyTomlTransportPath,\n legacyTomlTransportRejection,\n} from \"./legacy-toml-transport.js\";\nimport type { AnyMigrateManifest, MigrateManifest } from \"./migrate.js\";\nimport { exportMigrationState, importMigrationState } from \"./migrate.js\";\nimport { assertPluginsCleanForShare } from \"./plugin-versioning.js\";\nimport {\n exportResourceToFile,\n formatResourceSelector,\n importResourceFromFile,\n} from \"./resource-import-export.js\";\n\nexport type MigrateScope = \"workspace\" | \"plugin\" | \"resource\";\n\nexport interface MigrateExportCliOpts {\n file?: string;\n outputFile?: string;\n workspace?: boolean;\n plugin?: string;\n resource?: string;\n /** Deprecated: rejected by {@link rejectEnvironmentScope}. */\n environment?: string;\n includePlugins?: boolean;\n embedPlugins?: boolean;\n singleFile?: boolean;\n onSkip?: (message: string) => void;\n}\n\nexport interface MigrateImportCliOpts {\n file?: string;\n workspace?: boolean;\n plugin?: boolean;\n resource?: boolean;\n /** Deprecated: rejected by {@link rejectEnvironmentScope}. */\n environment?: boolean | string;\n}\n\nexport type WorkspaceExportResult = {\n scope: \"workspace\";\n output: string;\n manifest: MigrateManifest;\n};\n\nexport type PluginExportResult = {\n scope: \"plugin\";\n output: string;\n plugins: string[];\n files: string[];\n};\n\nexport type ResourceExportResult = {\n scope: \"resource\";\n output: string;\n resource: string;\n files: string[];\n};\n\nexport type ScopedExportResult =\n | WorkspaceExportResult\n | PluginExportResult\n | ResourceExportResult;\n\nexport type WorkspaceImportResult = {\n scope: \"workspace\";\n manifest: AnyMigrateManifest;\n plugins_imported: number;\n environments_imported: number;\n};\n\nexport type PluginImportResult = {\n scope: \"plugin\";\n plugin: string;\n plugins: string[];\n resources_imported: number;\n};\n\nexport type ResourceImportResult = {\n scope: \"resource\";\n resource: string;\n action: \"created\" | \"updated\" | \"unchanged\";\n};\n\nexport type ScopedImportResult =\n | WorkspaceImportResult\n | PluginImportResult\n | ResourceImportResult;\n\nfunction countScopeFlags(opts: {\n workspace?: boolean;\n plugin?: string | boolean;\n resource?: string | boolean;\n}): number {\n let count = 0;\n if (opts.workspace) count++;\n if (opts.plugin) count++;\n if (opts.resource) count++;\n return count;\n}\n\nexport function assertExclusiveScopeFlags(opts: {\n workspace?: boolean;\n plugin?: string | boolean;\n resource?: string | boolean;\n}): void {\n if (countScopeFlags(opts) > 1) {\n throw new Error(\"Choose only one of --workspace, --plugin, or --resource.\");\n }\n}\n\nexport function rejectEnvironmentScope(opts: { environment?: string | boolean }): void {\n if (opts.environment) {\n throw new Error(\n \"Environments are no longer exported on their own: they are machine-local \" +\n \"secret references. Use --workspace to back them up with everything else.\",\n );\n }\n}\n\nfunction embedPlugins(opts: MigrateExportCliOpts): boolean {\n return opts.includePlugins ?? opts.embedPlugins ?? false;\n}\n\nfunction resolvePluginOrThrow(selector: string): Plugin {\n const first = selector.split(\",\")[0]?.trim() ?? selector;\n const plugin = getPlugin(first);\n if (!plugin) {\n throw new Error(`Plugin not found: ${first}`);\n }\n return plugin;\n}\n\nexport function resolveExportScope(opts: MigrateExportCliOpts): {\n scope: MigrateScope;\n outputPath: string;\n pluginSelector?: string;\n resourceSelector?: string;\n singleFile: boolean;\n} {\n rejectEnvironmentScope(opts);\n assertExclusiveScopeFlags(opts);\n const outputPath = opts.outputFile ?? opts.file;\n const resolvedExplicit =\n outputPath && outputPath.length > 0 ? resolve(outputPath) : undefined;\n const singleFile =\n opts.singleFile === true\n || (resolvedExplicit != null && isApEnvelopePath(resolvedExplicit));\n\n if (opts.plugin) {\n const firstPlugin = opts.plugin.split(\",\")[0]?.trim() ?? \"plugin\";\n const apName = slugifyApName(firstPlugin);\n const path = resolvedExplicit ?? resolve(singleFile ? `${apName}.ap.json` : apName);\n return {\n scope: \"plugin\",\n outputPath: path,\n pluginSelector: opts.plugin,\n singleFile,\n };\n }\n\n if (opts.resource) {\n const colon = opts.resource.indexOf(\":\");\n const rest = colon === -1 ? opts.resource : opts.resource.slice(colon + 1);\n const name = slugifyApName(rest.split(\"@\")[0] ?? \"export\");\n const path = resolvedExplicit ?? resolve(singleFile ? `${name}.ap.json` : name);\n return {\n scope: \"resource\",\n outputPath: path,\n resourceSelector: opts.resource,\n singleFile,\n };\n }\n\n if (opts.workspace) {\n if (!outputPath || outputPath.length === 0) {\n throw new Error(\"Output path is required for workspace export.\");\n }\n return { scope: \"workspace\", outputPath: resolve(outputPath), singleFile: false };\n }\n\n if (outputPath && outputPath.length > 0) {\n const resolvedOutput = resolve(outputPath);\n const lower = resolvedOutput.toLowerCase();\n if (lower.endsWith(\".tar.gz\")) {\n return { scope: \"workspace\", outputPath: resolvedOutput, singleFile: false };\n }\n if (\n extname(resolvedOutput).toLowerCase() === \".json\"\n && !isApEnvelopePath(resolvedOutput)\n ) {\n return { scope: \"workspace\", outputPath: resolvedOutput, singleFile: false };\n }\n }\n\n throw new Error(\n \"Specify export scope: --workspace, --plugin <name>, or --resource <selector>.\",\n );\n}\n\nexport function detectImportScopeFromFile(filePath: string): MigrateScope {\n const resolved = resolve(filePath);\n if (statSync(resolved).isDirectory()) {\n if (!existsSync(join(resolved, \"plugin.json\"))) {\n throw new Error(\n `${resolved} is a directory but has no plugin.json: expected an Agent Plugins package.`,\n );\n }\n return \"plugin\";\n }\n const lower = resolved.toLowerCase();\n if (lower.endsWith(\".tar.gz\")) return \"workspace\";\n if (isApEnvelopePath(resolved) || lower.endsWith(\".zip\")) return \"plugin\";\n if (isLegacyTomlTransportPath(resolved)) {\n throw new Error(legacyTomlTransportRejection(resolved));\n }\n throw new Error(\n `Cannot tell what ${resolved} is. Pass an Agent Plugins package directory, ` +\n \"an .ap.json envelope, or a .tar.gz workspace archive.\",\n );\n}\n\nexport function resolveImportScope(opts: MigrateImportCliOpts): MigrateScope {\n rejectEnvironmentScope(opts);\n assertExclusiveScopeFlags({\n workspace: opts.workspace,\n plugin: opts.plugin,\n resource: opts.resource,\n });\n if (!opts.file || opts.file.length === 0) {\n throw new Error(\"Import file path is required.\");\n }\n\n let scope: MigrateScope;\n if (opts.workspace) {\n scope = \"workspace\";\n } else if (opts.plugin) {\n scope = \"plugin\";\n } else if (opts.resource) {\n scope = \"resource\";\n } else {\n return detectImportScopeFromFile(opts.file);\n }\n\n const detected = detectImportScopeFromFile(opts.file);\n if (detected !== scope) {\n throw new Error(\n `Import file looks like ${detected} data but --${scope} was specified.`,\n );\n }\n return scope;\n}\n\nexport function exportScopedMigration(\n resolved: ReturnType<typeof resolveExportScope>,\n opts: MigrateExportCliOpts,\n): ScopedExportResult {\n const includePlugins = embedPlugins(opts);\n\n switch (resolved.scope) {\n case \"workspace\": {\n const manifest = exportMigrationState({\n outputPath: resolved.outputPath,\n includePlugins,\n ...(opts.onSkip ? { onSkip: opts.onSkip } : {}),\n });\n return {\n scope: \"workspace\",\n output: resolved.outputPath,\n manifest,\n };\n }\n case \"plugin\": {\n if (!resolved.pluginSelector) {\n throw new Error(\"Plugin selector is required for plugin export.\");\n }\n const plugin = resolvePluginOrThrow(resolved.pluginSelector);\n assertPluginsCleanForShare([plugin]);\n const files = buildApPackageFiles(plugin.id);\n let written: string[];\n if (resolved.singleFile) {\n writeApEnvelope(files, resolved.outputPath);\n written = Object.keys(files).sort();\n } else {\n written = writeApPackageFiles(files, resolved.outputPath);\n }\n return {\n scope: \"plugin\",\n output: resolved.outputPath,\n plugins: [plugin.name],\n files: written,\n };\n }\n case \"resource\": {\n if (!resolved.resourceSelector) {\n throw new Error(\"Resource selector is required for resource export.\");\n }\n const exportDoc = exportResourceToFile(\n resolved.resourceSelector,\n resolved.outputPath,\n { singleFile: resolved.singleFile },\n );\n return {\n scope: \"resource\",\n output: resolved.outputPath,\n resource: formatResourceSelector(exportDoc),\n files: exportDoc.files,\n };\n }\n default: {\n const neverScope: never = resolved.scope;\n throw new Error(`Unsupported export scope: ${neverScope}`);\n }\n }\n}\n\nexport function importScopedMigration(\n scope: MigrateScope,\n filePath: string,\n): ScopedImportResult {\n const resolved = resolve(filePath);\n\n switch (scope) {\n case \"workspace\": {\n const result = importMigrationState({ archivePath: resolved });\n return {\n scope: \"workspace\",\n manifest: result.manifest,\n plugins_imported: result.plugins_imported,\n environments_imported: result.environments_imported,\n };\n }\n case \"plugin\": {\n const files = loadVerifiedPackageFiles(resolved);\n const plugin = importApPackageFiles(files);\n return {\n scope: \"plugin\",\n plugin: plugin.name,\n plugins: [plugin.name],\n resources_imported: getPluginResources(plugin.id).length,\n };\n }\n case \"resource\": {\n const result = importResourceFromFile(resolved);\n return {\n scope: \"resource\",\n resource: formatResourceSelector(result.resource),\n action: result.action,\n };\n }\n default: {\n const neverScope: never = scope;\n throw new Error(`Unsupported import scope: ${neverScope}`);\n }\n }\n}\n","import {\n cpSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { execSync } from \"node:child_process\";\nimport { getHarnesstapDir } from \"../db/connection.js\";\nimport { getHarnessPreference, setHarnessPreference } from \"../models/harness.js\";\nimport { listPlugins } from \"../models/plugin-model.js\";\nimport { loadSettings } from \"../config/settings.js\";\nimport type { HarnesstapSettings } from \"../config/settings.js\";\nimport type { HarnessPreference, HarnessSelection } from \"../types.js\";\nimport { registeredFromLegacyParts } from \"./harness-targets.js\";\nimport {\n formatEnvironmentToml,\n importEnvironmentToml,\n listEnvironmentDocuments,\n} from \"./environment-import-export.js\";\nimport { listContainedFiles, assertArchiveMembersContained } from \"../utils/path-containment.js\";\nimport {\n buildApPackageFiles,\n writeApPackageFiles,\n readApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport { importApPackageFiles } from \"./agent-plugins/import.js\";\nimport { slugifyApName } from \"./agent-plugins/name.js\";\nimport { ManifestValidationError } from \"./agent-plugins/validate.js\";\nimport { skippedInvalidPluginExport } from \"../copy/cli.js\";\nimport {\n envelopeFromFiles,\n parseApEnvelope,\n} from \"./agent-plugins/envelope.js\";\nimport { isLegacyPluginTomlPath } from \"./legacy-toml-transport.js\";\n\nfunction selectionFromArchive(raw: unknown): HarnessSelection {\n const rec = (raw ?? {}) as Record<string, unknown>;\n if (Array.isArray(rec.registered_harnesses)) {\n return {\n registered_harnesses: rec.registered_harnesses.filter(\n (entry): entry is string => typeof entry === \"string\",\n ),\n };\n }\n return {\n registered_harnesses: registeredFromLegacyParts(\n typeof rec.main_harness === \"string\" ? rec.main_harness : null,\n Array.isArray(rec.alias_harnesses)\n ? rec.alias_harnesses.filter((entry): entry is string => typeof entry === \"string\")\n : [],\n ),\n };\n}\n\nexport const MIGRATE_MANIFEST_VERSION_V1 = 1 as const;\nexport const MIGRATE_MANIFEST_VERSION = 2 as const;\n\nexport interface MigrateManifestV1 {\n version: typeof MIGRATE_MANIFEST_VERSION_V1;\n exported_at: string;\n plugin_count: number;\n include_plugins: boolean;\n includes_active_profile: boolean;\n}\n\nexport interface MigrateManifest {\n version: typeof MIGRATE_MANIFEST_VERSION;\n exported_at: string;\n plugin_count: number;\n environment_count: number;\n /** Slugified plugin directory names packed under `plugins/`. */\n plugins: string[];\n include_plugins: boolean;\n includes_active_profile: boolean;\n}\n\nexport type AnyMigrateManifest = MigrateManifestV1 | MigrateManifest;\n\nexport interface MigrateExportOptions {\n outputPath: string;\n includePlugins?: boolean;\n onSkip?: (message: string) => void;\n}\n\nexport interface MigrateImportOptions {\n archivePath: string;\n}\n\nfunction writeJson(path: string, data: unknown): void {\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n\nfunction listArchiveMembers(archivePath: string): string[] {\n const listing = execSync(`tar -tzf \"${archivePath}\"`, {\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return listing\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n}\n\nfunction extractArchive(archivePath: string, destDir: string): void {\n const resolved = resolve(archivePath);\n if (resolved.endsWith(\".json\") && !resolved.endsWith(\".ap.json\")) {\n mkdirSync(join(destDir, \"state\"), { recursive: true });\n cpSync(resolved, join(destDir, \"state\", \"migrate.json\"));\n return;\n }\n // Reject path-traversal members before write; post-walk only sees files under destDir.\n assertArchiveMembersContained(destDir, listArchiveMembers(resolved));\n execSync(`tar -xzf \"${resolved}\" -C \"${destDir}\"`, { stdio: \"pipe\" });\n // Catch in-tree symlink escapes that resolve outside the destination.\n listContainedFiles(destDir);\n}\n\nfunction createArchive(sourceDir: string, outputPath: string): void {\n const resolved = resolve(outputPath);\n if (resolved.endsWith(\".json\") && !resolved.endsWith(\".ap.json\")) {\n const manifest = readFileSync(join(sourceDir, \"manifest.json\"), \"utf-8\");\n const environmentsDir = join(sourceDir, \"environments\");\n const pluginsDir = join(sourceDir, \"plugins\");\n const plugins: unknown[] = [];\n if (existsSync(pluginsDir)) {\n for (const entry of readdirSync(pluginsDir)) {\n const packageDir = join(pluginsDir, entry);\n if (!statSync(packageDir).isDirectory()) continue;\n if (!existsSync(join(packageDir, \"plugin.json\"))) {\n throw new Error(\n `Archive plugin directory ${entry} is missing plugin.json`,\n );\n }\n plugins.push(envelopeFromFiles(readApPackageFiles(packageDir)));\n }\n }\n const state: Record<string, unknown> = {\n manifest: JSON.parse(manifest) as AnyMigrateManifest,\n harness: existsSync(join(sourceDir, \"harness.json\"))\n ? JSON.parse(readFileSync(join(sourceDir, \"harness.json\"), \"utf-8\"))\n : null,\n config: existsSync(join(sourceDir, \"config.json\"))\n ? JSON.parse(readFileSync(join(sourceDir, \"config.json\"), \"utf-8\"))\n : null,\n active_profile: existsSync(join(sourceDir, \"active-profile.json\"))\n ? JSON.parse(readFileSync(join(sourceDir, \"active-profile.json\"), \"utf-8\"))\n : null,\n plugins,\n };\n if (existsSync(environmentsDir)) {\n state.environments = readdirSync(environmentsDir)\n .filter((f) => f.endsWith(\".toml\"))\n .map((f) => readFileSync(join(environmentsDir, f), \"utf-8\"));\n }\n writeFileSync(resolved, JSON.stringify(state, null, 2), \"utf-8\");\n return;\n }\n execSync(`tar -czf \"${resolved}\" -C \"${sourceDir}\" .`, { stdio: \"pipe\" });\n}\n\nfunction dirnameSafe(path: string): string {\n const idx = path.lastIndexOf(\"/\");\n return idx >= 0 ? path.slice(0, idx) : \".\";\n}\n\nfunction isMigrateManifestV1(manifest: AnyMigrateManifest): manifest is MigrateManifestV1 {\n return manifest.version === MIGRATE_MANIFEST_VERSION_V1;\n}\n\n/**\n * Export all plugins, environments, harness preferences, and config into an archive.\n */\nexport function exportMigrationState(opts: MigrateExportOptions): MigrateManifest {\n const workDir = mkdtempSync(join(tmpdir(), \"harnesstap-migrate-\"));\n const pluginsDir = join(workDir, \"plugins\");\n const environmentsDir = join(workDir, \"environments\");\n mkdirSync(pluginsDir, { recursive: true });\n mkdirSync(environmentsDir, { recursive: true });\n\n const plugins = listPlugins();\n const pluginNames: string[] = [];\n for (const plugin of plugins) {\n const slug = slugifyApName(plugin.name);\n const packageDir = join(pluginsDir, slug);\n try {\n writeApPackageFiles(buildApPackageFiles(plugin.id), packageDir);\n pluginNames.push(slug);\n } catch (error) {\n if (error instanceof ManifestValidationError) {\n opts.onSkip?.(skippedInvalidPluginExport(plugin.name));\n continue;\n }\n throw error;\n }\n }\n\n const environments = listEnvironmentDocuments();\n for (const environment of environments) {\n writeFileSync(\n join(environmentsDir, `${environment.name}.toml`),\n formatEnvironmentToml(environment),\n \"utf-8\",\n );\n }\n\n const harness = getHarnessPreference();\n if (harness) {\n writeJson(join(workDir, \"harness.json\"), harness);\n }\n\n const config = loadSettings(getHarnesstapDir());\n writeJson(join(workDir, \"config.json\"), config);\n const harnesstapDir = getHarnesstapDir();\n const activeProfilePath = join(harnesstapDir, \"active-profile.json\");\n const includesActiveProfile = existsSync(activeProfilePath);\n if (includesActiveProfile) {\n cpSync(activeProfilePath, join(workDir, \"active-profile.json\"));\n }\n\n const manifest: MigrateManifest = {\n version: MIGRATE_MANIFEST_VERSION,\n exported_at: new Date().toISOString(),\n plugin_count: plugins.length,\n environment_count: environments.length,\n plugins: pluginNames,\n include_plugins: opts.includePlugins ?? false,\n includes_active_profile: includesActiveProfile,\n };\n writeJson(join(workDir, \"manifest.json\"), manifest);\n\n mkdirSync(dirnameSafe(resolve(opts.outputPath)), { recursive: true });\n createArchive(workDir, opts.outputPath);\n rmSync(workDir, { recursive: true, force: true });\n\n return manifest;\n}\n\nfunction importEnvironmentsFromDir(environmentsDir: string): number {\n if (!existsSync(environmentsDir)) {\n return 0;\n }\n let imported = 0;\n for (const file of readdirSync(environmentsDir)) {\n if (!file.endsWith(\".toml\")) continue;\n importEnvironmentToml(readFileSync(join(environmentsDir, file), \"utf-8\"));\n imported++;\n }\n return imported;\n}\n\nfunction importPluginsFromDir(pluginsDir: string): number {\n if (!existsSync(pluginsDir)) {\n return 0;\n }\n let imported = 0;\n for (const entry of readdirSync(pluginsDir)) {\n const packageDir = join(pluginsDir, entry);\n if (!statSync(packageDir).isDirectory()) {\n if (isLegacyPluginTomlPath(entry) || entry.endsWith(\".toml\")) {\n throw new Error(\n \"This archive stores plugins as TOML, which is no longer supported. \" +\n \"Re-export with a current CLI to produce Agent Plugins packages.\",\n );\n }\n continue;\n }\n if (!existsSync(join(packageDir, \"plugin.json\"))) {\n throw new Error(\n `Archive plugin directory ${entry} is missing plugin.json`,\n );\n }\n importApPackageFiles(readApPackageFiles(packageDir));\n imported++;\n }\n return imported;\n}\n\n/**\n * Import a migration archive produced by exportMigrationState.\n */\nexport function importMigrationState(opts: MigrateImportOptions): {\n manifest: AnyMigrateManifest;\n plugins_imported: number;\n environments_imported: number;\n} {\n const workDir = mkdtempSync(join(tmpdir(), \"harnesstap-migrate-import-\"));\n\n try {\n extractArchive(opts.archivePath, workDir);\n\n let manifest: AnyMigrateManifest;\n let pluginsDir: string;\n let environmentsDir: string;\n let harnessPath: string;\n let configPath: string;\n\n if (existsSync(join(workDir, \"state\", \"migrate.json\"))) {\n const state = JSON.parse(\n readFileSync(join(workDir, \"state\", \"migrate.json\"), \"utf-8\"),\n ) as {\n manifest: AnyMigrateManifest;\n harness: HarnessPreference | null;\n config: HarnesstapSettings;\n active_profile: { name?: string } | null;\n plugins: unknown[];\n environments?: string[];\n };\n manifest = state.manifest;\n pluginsDir = join(workDir, \"import-plugins\");\n environmentsDir = join(workDir, \"import-environments\");\n mkdirSync(pluginsDir, { recursive: true });\n mkdirSync(environmentsDir, { recursive: true });\n for (let i = 0; i < state.plugins.length; i++) {\n const packageDir = join(pluginsDir, `plugin-${i}`);\n const envelopeRaw = JSON.stringify(state.plugins[i]);\n const files = parseApEnvelope(envelopeRaw, `archive plugin ${i}`);\n writeApPackageFiles(files, packageDir);\n }\n if (state.environments) {\n for (let i = 0; i < state.environments.length; i++) {\n writeFileSync(\n join(environmentsDir, `environment-${i}.toml`),\n state.environments[i] ?? \"\",\n \"utf-8\",\n );\n }\n }\n if (state.harness) {\n writeJson(join(workDir, \"harness.json\"), state.harness);\n }\n writeJson(join(workDir, \"config.json\"), state.config);\n if (state.active_profile) {\n writeJson(join(workDir, \"active-profile.json\"), state.active_profile);\n }\n harnessPath = join(workDir, \"harness.json\");\n configPath = join(workDir, \"config.json\");\n } else {\n manifest = JSON.parse(\n readFileSync(join(workDir, \"manifest.json\"), \"utf-8\"),\n ) as AnyMigrateManifest;\n pluginsDir = join(workDir, \"plugins\");\n environmentsDir = join(workDir, \"environments\");\n harnessPath = join(workDir, \"harness.json\");\n configPath = join(workDir, \"config.json\");\n }\n const activeProfilePath = join(workDir, \"active-profile.json\");\n\n if (isMigrateManifestV1(manifest)) {\n throw new Error(\n \"This archive uses manifest version 1, which stored plugins as TOML. \" +\n \"Version 1 archives were never released and are not supported.\",\n );\n }\n\n const manifestVersion = manifest.version;\n if (manifestVersion !== MIGRATE_MANIFEST_VERSION) {\n throw new Error(`Unsupported migration manifest version: ${manifestVersion}`);\n }\n\n const pluginsImported = importPluginsFromDir(pluginsDir);\n const environmentsImported = importEnvironmentsFromDir(environmentsDir);\n\n if (existsSync(harnessPath)) {\n const harness = JSON.parse(\n readFileSync(harnessPath, \"utf-8\"),\n ) as HarnessPreference;\n setHarnessPreference(selectionFromArchive(harness));\n }\n\n if (existsSync(configPath)) {\n const config = JSON.parse(\n readFileSync(configPath, \"utf-8\"),\n ) as HarnesstapSettings;\n const targetDir = getHarnesstapDir();\n mkdirSync(targetDir, { recursive: true });\n writeJson(join(targetDir, \"config.json\"), config);\n }\n if (existsSync(activeProfilePath)) {\n const activeProfile = JSON.parse(\n readFileSync(activeProfilePath, \"utf-8\"),\n ) as { name?: string };\n const targetDir = getHarnesstapDir();\n mkdirSync(targetDir, { recursive: true });\n writeJson(join(targetDir, \"active-profile.json\"), activeProfile);\n }\n\n return {\n manifest,\n plugins_imported: pluginsImported,\n environments_imported: environmentsImported,\n };\n } finally {\n rmSync(workDir, { recursive: true, force: true });\n }\n}\n","import { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getPluginResources } from \"../models/plugin-model.js\";\nimport { getResource, resolveResource } from \"../models/resource.js\";\nimport type { Resource } from \"../types.js\";\nimport {\n buildApPackageFilesForResource,\n readApPackageFiles,\n writeApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport {\n isApEnvelopePath,\n readApEnvelope,\n writeApEnvelope,\n} from \"./agent-plugins/envelope.js\";\nimport { importApPackageFiles } from \"./agent-plugins/import.js\";\nimport { isCompositionResourceType } from \"./plugin-composition.js\";\nimport { parseResourceSelector } from \"./resource-selector.js\";\n\nexport interface ResourcePackageExportResult {\n type: Resource[\"type\"];\n name: string;\n description: string;\n content: string;\n metadata: Resource[\"metadata\"];\n namespace: string;\n origin_kind: Resource[\"origin_kind\"];\n origin_ref: string;\n content_hash: string;\n content_blob_ref: string;\n files: string[];\n}\n\nexport function formatResourceSelector(\n resource: Pick<Resource, \"type\" | \"name\" | \"namespace\">,\n): string {\n const namePart = resource.namespace\n ? `${resource.name}@${resource.namespace}`\n : resource.name;\n return `${resource.type}:${namePart}`;\n}\n\nexport function exportResourceToFile(\n selector: string,\n filePath: string,\n options?: { singleFile?: boolean },\n): ResourcePackageExportResult {\n const parsed = parseResourceSelector(selector);\n if (parsed.type && isCompositionResourceType(parsed.type)) {\n throw new Error(\n `Cannot export composition resource type: ${parsed.type}`,\n );\n }\n const resolved = resolveResource(selector);\n if (resolved.status !== \"found\") {\n throw new Error(\n resolved.status === \"ambiguous\"\n ? `Ambiguous resource selector: ${selector}`\n : `Resource not found: ${selector}`,\n );\n }\n if (isCompositionResourceType(resolved.resource.type)) {\n throw new Error(\n `Cannot export composition resource type: ${resolved.resource.type}`,\n );\n }\n const out = resolve(filePath);\n const files = buildApPackageFilesForResource(resolved.resource.id);\n const singleFile = options?.singleFile === true || isApEnvelopePath(out);\n const written = singleFile\n ? (writeApEnvelope(files, out), Object.keys(files).sort())\n : writeApPackageFiles(files, out);\n const { id: _id, created_at: _c, updated_at: _u, source: _s, ...payload } =\n resolved.resource;\n return {\n ...payload,\n files: written,\n };\n}\n\nexport function importResourceFromFile(filePath: string): {\n resource: Resource;\n action: \"created\" | \"updated\" | \"unchanged\";\n} {\n const resolved = resolve(filePath);\n if (!existsSync(resolved)) {\n throw new Error(`Path not found: ${resolved}`);\n }\n const packageFiles = statSync(resolved).isDirectory()\n ? readApPackageFiles(resolved)\n : isApEnvelopePath(resolved)\n ? readApEnvelope(resolved)\n : (() => {\n throw new Error(\n `${resolved} is not an Agent Plugins package directory or .ap.json envelope.`,\n );\n })();\n\n const plugin = importApPackageFiles(packageFiles);\n const resources = getPluginResources(plugin.id);\n const resource = resources[0];\n if (!resource) {\n throw new Error(`Package ${resolved} did not contain any resources.`);\n }\n const stored = getResource(resource.id) ?? resource;\n return {\n resource: stored,\n action: \"created\",\n };\n}\n","import {\n getPluginById,\n getPluginResources,\n listPluginDependencies,\n listPlugins,\n} from \"../models/plugin-model.js\";\nimport { listProjects } from \"../models/project.js\";\nimport { getLatestSnapshot } from \"../models/snapshot.js\";\nimport type { SnapshotState } from \"../types.js\";\nimport { setPluginResourceOverride } from \"./plugin-overrides.js\";\nimport {\n type ResolutionResult,\n resolutionKey,\n resolveComposition,\n} from \"./resolve/index.js\";\n\nexport interface OrderMigrationReport {\n projectsWithSnapshot: number;\n projectsWithoutSnapshot: number;\n overridesWritten: Array<{ root: string; key: string; winner: string }>;\n warnings: string[];\n}\n\nexport interface MigrateOrderToOverridesOptions {\n /** When true, report overrides that would be written without persisting them. */\n dryRun?: boolean;\n}\n\n/**\n * Reproduce previously applied results under nearest-to-root precedence.\n *\n * For every project with a recorded apply snapshot, compare the resource that\n * the old ordered merge materialized against the one resolution now picks. Where\n * they differ, write an explicit `overrides.resources` entry on the root so the\n * applied result is unchanged. Projects with no snapshot get a warning listing\n * the resources whose winner may change.\n */\nexport function migrateOrderToOverrides(\n options: MigrateOrderToOverridesOptions = {},\n): OrderMigrationReport {\n const report: OrderMigrationReport = {\n projectsWithSnapshot: 0,\n projectsWithoutSnapshot: 0,\n overridesWritten: [],\n warnings: [],\n };\n const dryRun = options.dryRun === true;\n\n for (const project of listProjects()) {\n const snapshot = getLatestSnapshot(project.id);\n const state = snapshot?.state as SnapshotState | undefined;\n const rootPlugin = state?.plugins?.[state.plugins.length - 1];\n if (!rootPlugin) {\n report.projectsWithoutSnapshot += 1;\n continue;\n }\n report.projectsWithSnapshot += 1;\n\n let resolution: ResolutionResult;\n try {\n resolution = resolveComposition({ rootSelectors: [rootPlugin.name] });\n } catch {\n report.warnings.push(\n `${project.name}: ${rootPlugin.name} no longer resolves; run ` +\n `\\`ht plugin apply ${rootPlugin.name} --explain\\` to inspect.`,\n );\n continue;\n }\n\n const previousWinnerByKey = new Map<string, string>();\n for (const resource of state?.resources ?? []) {\n const owner = ownerPluginName(resource.id, resolution.selected);\n if (owner) {\n previousWinnerByKey.set(resolutionKey(resource), owner);\n }\n }\n\n for (const decision of resolution.decisions) {\n const previous = previousWinnerByKey.get(decision.key);\n if (!previous || previous === decision.winner.pluginName) continue;\n if (!dryRun) {\n setPluginResourceOverride(resolution.root.pluginId, decision.key, previous);\n }\n report.overridesWritten.push({\n root: resolution.root.name,\n key: decision.key,\n winner: previous,\n });\n }\n }\n\n // Projects with no snapshot: name the resources whose winner may change.\n if (report.projectsWithoutSnapshot > 0) {\n for (const project of listProjects()) {\n if (getLatestSnapshot(project.id)) continue;\n const contested = collectContestedKeys();\n if (contested.keys.length > 0) {\n report.warnings.push(\n `${project.name}: no apply snapshot recorded, so previous winners are unknown. ` +\n `Contested: ${contested.keys.join(\", \")}. ` +\n `Run \\`ht plugin apply ${contested.explainRoot} --explain\\` to inspect.`,\n );\n } else {\n report.warnings.push(\n `${project.name}: no apply snapshot recorded, so previous winners are unknown.`,\n );\n }\n }\n }\n\n return report;\n}\n\nfunction collectContestedKeys(): { keys: string[]; explainRoot: string } {\n const keys: string[] = [];\n let explainRoot = \"<root>\";\n for (const plugin of listPlugins()) {\n if (listPluginDependencies(plugin.id).length === 0) continue;\n try {\n const resolution = resolveComposition({ rootSelectors: [plugin.name] });\n for (const decision of resolution.decisions) {\n if (decision.losers.length === 0) continue;\n if (!keys.includes(decision.key)) {\n keys.push(decision.key);\n }\n }\n if (explainRoot === \"<root>\") {\n explainRoot = plugin.name;\n }\n } catch {\n // Skip plugins that no longer resolve; the project-level warning still fires.\n }\n }\n return { keys, explainRoot };\n}\n\nfunction ownerPluginName(\n resourceId: string,\n selected: ReturnType<typeof resolveComposition>[\"selected\"],\n): string | undefined {\n for (const frame of selected) {\n const plugin = getPluginById(frame.pluginId);\n if (!plugin) continue;\n if (getPluginResources(plugin.id).some((resource) => resource.id === resourceId)) {\n return plugin.name;\n }\n }\n return undefined;\n}\n","import inquirer from \"inquirer\";\nimport { listResources } from \"../../models/resource.js\";\nimport { toPluginChoices } from \"../completion/choices.js\";\nimport type { MigrateScope } from \"../migrate-scope.js\";\nimport { isCompositionResourceType } from \"../plugin-composition.js\";\nimport { slugifyApName } from \"../agent-plugins/name.js\";\nimport {\n formatResourceSelectionLabel,\n sortResourcesByUpdatedAt,\n toResourceListRows,\n} from \"../../ui/resource-list-render.js\";\nimport { promptForSearchableChoice, promptForValue } from \"./shared.js\";\n\nexport type MigrateExportWizardResult = {\n scope: MigrateScope;\n outputPath: string;\n plugin?: string;\n resource?: string;\n embedPlugins?: boolean;\n singleFile?: boolean;\n};\n\nexport async function runMigrateExportWizard(): Promise<MigrateExportWizardResult> {\n const { scope } = await inquirer.prompt<{ scope: MigrateScope }>([\n {\n type: \"list\",\n name: \"scope\",\n message: \"What should be exported?\",\n choices: [\n { name: \"Workspace (full local library)\", value: \"workspace\" },\n { name: \"Plugin\", value: \"plugin\" },\n { name: \"Resource\", value: \"resource\" },\n ],\n },\n ]);\n\n if (scope === \"plugin\") {\n const choices = toPluginChoices();\n const plugin = choices.length > 0\n ? await promptForSearchableChoice({ message: \"Which plugin?\", choices })\n : await promptForValue({ message: \"Plugin name or ID\" });\n const firstPlugin = plugin.split(\",\")[0]?.trim() ?? \"plugin\";\n const apName = slugifyApName(firstPlugin);\n const { singleFile } = await inquirer.prompt<{ singleFile: boolean }>([\n {\n type: \"confirm\",\n name: \"singleFile\",\n message: \"Write a single .ap.json envelope?\",\n default: false,\n },\n ]);\n const outputPath = await promptForValue({\n message: \"Output path\",\n default: singleFile ? `./${apName}.ap.json` : `./${apName}`,\n });\n return { scope, plugin, outputPath, singleFile };\n }\n\n if (scope === \"resource\") {\n const resources = sortResourcesByUpdatedAt(\n toResourceListRows(listResources()).filter(\n (resource) => !isCompositionResourceType(resource.type),\n ),\n );\n if (resources.length === 0) {\n throw new Error(\n \"No exportable resources in workspace. Scan or create resources first.\",\n );\n }\n const choices = resources.map((resource) => ({\n name: formatResourceSelectionLabel(resource),\n value: `${resource.type}:${resource.name}${resource.namespace ? `@${resource.namespace}` : \"\"}`,\n }));\n const resource = await promptForSearchableChoice({\n message: \"Which resource?\",\n choices,\n });\n const rest = resource.split(\":\")[1] ?? \"resource\";\n const name = slugifyApName(rest.split(\"@\")[0] ?? \"resource\");\n const { singleFile } = await inquirer.prompt<{ singleFile: boolean }>([\n {\n type: \"confirm\",\n name: \"singleFile\",\n message: \"Write a single .ap.json envelope?\",\n default: false,\n },\n ]);\n const outputPath = await promptForValue({\n message: \"Output path\",\n default: singleFile ? `./${name}.ap.json` : `./${name}`,\n });\n return { scope, resource, outputPath, singleFile };\n }\n\n const outputPath = await promptForValue({\n message: \"Output archive path\",\n default: \"./harnesstap-backup.tar.gz\",\n });\n const { embed } = await inquirer.prompt<{ embed: boolean }>([\n {\n type: \"confirm\",\n name: \"embed\",\n message: \"Embed plugin trees in plugin exports?\",\n default: false,\n },\n ]);\n return { scope, outputPath, embedPlugins: embed };\n}\n","import {\n detectImportScopeFromFile,\n type MigrateScope,\n} from \"../migrate-scope.js\";\nimport { promptForValue } from \"./shared.js\";\n\nexport async function runMigrateImportWizard(): Promise<{\n file: string;\n scope: MigrateScope;\n}> {\n const file = await promptForValue({ message: \"Import file path\" });\n const scope = detectImportScopeFromFile(file);\n return { file, scope };\n}\n","import type { Command } from \"commander\";\nimport { getDb } from \"../../db/connection.js\";\nimport { initializeSchema } from \"../../db/schema.js\";\nimport {\n exportScopedMigration,\n importScopedMigration,\n resolveExportScope,\n resolveImportScope,\n type ScopedExportResult,\n type ScopedImportResult,\n} from \"../../services/migrate-scope.js\";\nimport {\n migrateOrderToOverrides,\n type OrderMigrationReport,\n} from \"../../services/order-to-override-migration.js\";\nimport { runMigrateExportWizard } from \"../../services/wizards/migrate-export.js\";\nimport { runMigrateImportWizard } from \"../../services/wizards/migrate-import.js\";\nimport { shouldUseWizard } from \"../../services/wizards/shared.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { formatCount } from \"../formatting.js\";\nimport { configureCommandGroup } from \"../help.js\";\nimport { fail, failCaught } from \"../shared.js\";\n\nfunction printMigrateExportHuman(result: ScopedExportResult): void {\n switch (result.scope) {\n case \"workspace\":\n ui.success(\n `Exported migration archive ${ui.icons.hint} ${result.output} ${ui.icons.bullet} ${result.manifest.plugin_count} plugins, ${result.manifest.environment_count} environments`,\n );\n return;\n case \"plugin\":\n ui.success(\n `Exported plugin ${ui.theme.accent(result.plugins.join(\", \"))} ${ui.icons.hint} ${result.output}`,\n );\n return;\n case \"resource\":\n ui.success(\n `Exported resource ${ui.theme.accent(result.resource)} ${ui.icons.hint} ${result.output}`,\n );\n return;\n default: {\n const neverResult: never = result;\n throw new Error(`Unsupported export result: ${String(neverResult)}`);\n }\n }\n}\n\nfunction printMigrateImportHuman(result: ScopedImportResult): void {\n switch (result.scope) {\n case \"workspace\":\n ui.success(\n `Imported migration archive ${ui.icons.bullet} ${formatCount(result.plugins_imported, \"plugin\")}, ${formatCount(result.environments_imported, \"environment\")}`,\n );\n return;\n case \"plugin\":\n ui.success(\n `Imported plugin ${ui.theme.accent(result.plugin)} ${ui.icons.bullet} ${formatCount(result.resources_imported, \"resource\")}`,\n );\n return;\n case \"resource\":\n ui.success(\n `Imported resource ${ui.theme.accent(result.resource)} ${ui.icons.bullet} ${result.action}`,\n );\n return;\n default: {\n const neverResult: never = result;\n throw new Error(`Unsupported import result: ${String(neverResult)}`);\n }\n }\n}\n\nasync function handleMigrateExportCommand(\n file: string | undefined,\n opts: {\n file?: string;\n workspace?: boolean;\n plugin?: string;\n resource?: string;\n environment?: string;\n includePlugins?: boolean;\n embedPlugins?: boolean;\n singleFile?: boolean;\n format?: string;\n noInteractive?: boolean;\n interactive?: boolean;\n },\n): Promise<void> {\n const db = getDb();\n initializeSchema(db, { allowLegacyRead: true });\n const format = parseOutputFormat(opts.format);\n\n let exportOpts = {\n ...opts,\n file: opts.file ?? file,\n };\n\n const useWizard = shouldUseWizard({\n interactive: opts.interactive,\n noInteractive: opts.noInteractive,\n format: opts.format,\n missingRequiredArgs:\n !exportOpts.file\n && !exportOpts.plugin\n && !exportOpts.resource\n && !exportOpts.environment\n && !exportOpts.workspace,\n });\n\n if (useWizard) {\n const wizard = await runMigrateExportWizard();\n exportOpts = {\n ...exportOpts,\n file: wizard.outputPath,\n workspace: wizard.scope === \"workspace\" ? true : undefined,\n plugin: wizard.plugin,\n resource: wizard.resource,\n includePlugins: wizard.embedPlugins,\n singleFile: wizard.singleFile,\n };\n }\n\n try {\n const resolved = resolveExportScope(exportOpts);\n const result = exportScopedMigration(resolved, {\n ...exportOpts,\n onSkip: (message) => ui.warn(message),\n });\n if (format === \"json\") {\n if (result.scope === \"workspace\") {\n printJson({ ...result.manifest, output: result.output, scope: result.scope });\n return;\n }\n printJson(result);\n return;\n }\n printMigrateExportHuman(result);\n } catch (err) {\n fail(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n }\n}\n\nasync function handleMigrateImportCommand(\n file: string | undefined,\n opts: {\n workspace?: boolean;\n plugin?: boolean;\n resource?: boolean;\n environment?: boolean;\n format?: string;\n noInteractive?: boolean;\n interactive?: boolean;\n } = {},\n): Promise<void> {\n const db = getDb();\n initializeSchema(db);\n const format = parseOutputFormat(opts.format);\n\n let importFile = file;\n let scopeOverride: ReturnType<typeof resolveImportScope> | undefined;\n\n const useWizard = shouldUseWizard({\n interactive: opts.interactive,\n noInteractive: opts.noInteractive,\n format: opts.format,\n missingRequiredArgs: !importFile,\n });\n\n if (useWizard) {\n const wizard = await runMigrateImportWizard();\n importFile = wizard.file;\n scopeOverride = wizard.scope;\n }\n\n if (!importFile) {\n fail(\"Import file path is required.\");\n process.exitCode = 1;\n return;\n }\n\n try {\n const scope = scopeOverride ?? resolveImportScope({ ...opts, file: importFile });\n const result = importScopedMigration(scope, importFile);\n if (format === \"json\") {\n printJson(result);\n return;\n }\n printMigrateImportHuman(result);\n } catch (err) {\n failCaught(err);\n }\n}\n\nfunction printMigrateResolveOrderHuman(\n report: OrderMigrationReport,\n dryRun: boolean,\n): void {\n const dryRunSuffix = dryRun ? ` ${ui.icons.bullet} dry-run` : \"\";\n if (report.overridesWritten.length === 0) {\n const aligned =\n report.projectsWithSnapshot > 0\n ? \"Last applied winners already match current resolution. No overrides to write\"\n : \"No apply snapshots to compare. No overrides to write\";\n ui.success(`${aligned}${dryRunSuffix}`);\n } else {\n const overrideCount = formatCount(report.overridesWritten.length, \"override\");\n const projectCount = formatCount(report.projectsWithSnapshot, \"project\");\n const verb = dryRun ? \"Would write\" : \"Wrote\";\n ui.success(\n `${verb} ${overrideCount} across ${projectCount}${dryRunSuffix}`,\n );\n }\n for (const warning of report.warnings) {\n ui.warn(warning);\n }\n}\n\nfunction handleMigrateResolveOrderCommand(opts: {\n dryRun?: boolean;\n format?: string;\n}): void {\n const db = getDb();\n initializeSchema(db, { allowLegacyRead: true });\n const format = parseOutputFormat(opts.format);\n const dryRun = opts.dryRun === true;\n const report = migrateOrderToOverrides({ dryRun });\n if (format === \"json\") {\n printJson(report);\n return;\n }\n printMigrateResolveOrderHuman(report, dryRun);\n}\n\nexport function registerMigrateCommands(root: Command): void {\n const migrateCmd = configureCommandGroup(\n root\n .command(\"migrate\")\n .alias(\"m\")\n .description(\"Export or import workspace, plugins, or resources for offline sharing\"),\n );\n\n migrateCmd\n .command(\"export\")\n .argument(\n \"[file]\",\n \"Output path (package directory, .ap.json envelope, or .tar.gz workspace archive)\",\n )\n .option(\"--workspace\", \"Export full workspace archive\")\n .option(\"--plugin <name>\", \"Export plugin(s); comma-separated names or IDs\")\n .option(\"--resource <selector>\", \"Export one resource (type:name or type:name@namespace)\")\n .option(\n \"--environment <name>\",\n \"Removed: environments are machine-local; use --workspace\",\n )\n .option(\"--single-file\", \"Write a .ap.json envelope instead of a package directory\")\n .option(\"-o, --file <path>\", \"Output path (overrides positional)\")\n .option(\"--include-plugins\", \"Embed plugin trees (workspace scope)\")\n .option(\"--embed-plugins\", \"Alias for --include-plugins\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .description(\"Export workspace, plugin, or resource for offline sharing\")\n .action(handleMigrateExportCommand);\n\n migrateCmd\n .command(\"import\")\n .argument(\n \"[file]\",\n \"package directory, .ap.json envelope, or .tar.gz workspace archive\",\n )\n .option(\"--workspace\", \"Force workspace archive import\")\n .option(\"--plugin\", \"Force Agent Plugins package import\")\n .option(\"--resource\", \"Force single-resource package import\")\n .option(\n \"--environment\",\n \"Removed: environments are machine-local; use --workspace\",\n )\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .description(\"Import workspace, plugin, or resource from file\")\n .action(handleMigrateImportCommand);\n\n migrateCmd\n .command(\"resolve-order\")\n .option(\"--dry-run\", \"Report what would be written without writing\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .description(\n \"Pin last-applied resource winners as overrides where current resolution would pick a different plugin\",\n )\n .action(handleMigrateResolveOrderCommand);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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AO,EACjE,YAAY,2DAA2D,EACvE,OAAO,0BAA0B;AAEpC,aACG,QAAQ,QAAQ,EAChB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,eAAe,gCAAgC,EACtD,OAAO,YAAY,oCAAoC,EACvD,OAAO,cAAc,sCAAsC,EAC3D;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,mBAAmB,gCAAgC,OAAO,EACjE,YAAY,iDAAiD,EAC7D,OAAO,0BAA0B;AAEpC,aACG,QAAQ,eAAe,EACvB,OAAO,aAAa,8CAA8C,EAClE,OAAO,mBAAmB,gCAAgC,OAAO,EACjE;AAAA,IACC;AAAA,EACF,EACC,OAAO,gCAAgC;AAC5C;","names":["existsSync","statSync","join","resolve","existsSync","statSync","resolve","resolve","existsSync","statSync","resolve","statSync","existsSync","join","outputPath","resource"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerOpenCommand
|
|
3
|
+
} from "./chunk-QRZPQNLX.js";
|
|
4
|
+
import "./chunk-4KNQZDZC.js";
|
|
5
|
+
import "./chunk-JKGSJGCC.js";
|
|
6
|
+
import "./chunk-QO4LBDVI.js";
|
|
7
|
+
import "./chunk-KCQC7YBK.js";
|
|
8
|
+
import "./chunk-PXU2OS26.js";
|
|
9
|
+
import "./chunk-NAGAJ5UM.js";
|
|
10
|
+
import "./chunk-IK524ZDW.js";
|
|
11
|
+
import "./chunk-SY7G5QEI.js";
|
|
12
|
+
import "./chunk-XQFT4PEP.js";
|
|
13
|
+
import "./chunk-JRFUTIEH.js";
|
|
14
|
+
import "./chunk-UJYFTXHV.js";
|
|
15
|
+
import "./chunk-3IWTJCPA.js";
|
|
16
|
+
import "./chunk-SPRVUATR.js";
|
|
17
|
+
import "./chunk-EWBCFAF3.js";
|
|
18
|
+
import "./chunk-2EIJYDNI.js";
|
|
19
|
+
import "./chunk-6BY4BV5G.js";
|
|
20
|
+
import "./chunk-GQKKX7OE.js";
|
|
21
|
+
import "./chunk-K2BPYEH5.js";
|
|
22
|
+
import "./chunk-G26HZZDJ.js";
|
|
23
|
+
import "./chunk-TQ2NA4Z4.js";
|
|
24
|
+
import "./chunk-DXKAKKLP.js";
|
|
25
|
+
import "./chunk-YDD3ES2K.js";
|
|
26
|
+
import "./chunk-ZY2MZ2KQ.js";
|
|
27
|
+
import "./chunk-VQVUJYYY.js";
|
|
28
|
+
import "./chunk-DWVAR4BP.js";
|
|
29
|
+
export {
|
|
30
|
+
registerOpenCommand
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=open-3V3QK5RK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PackError,
|
|
3
|
+
packProject
|
|
4
|
+
} from "./chunk-GRJY22U6.js";
|
|
5
|
+
import "./chunk-3IZ7SEGT.js";
|
|
6
|
+
import "./chunk-I6XFZLTJ.js";
|
|
7
|
+
import "./chunk-7L2K4N25.js";
|
|
8
|
+
import "./chunk-JRFUTIEH.js";
|
|
9
|
+
import "./chunk-UJYFTXHV.js";
|
|
10
|
+
import "./chunk-3IWTJCPA.js";
|
|
11
|
+
import "./chunk-HVVPTCKR.js";
|
|
12
|
+
import "./chunk-SPRVUATR.js";
|
|
13
|
+
import "./chunk-EWBCFAF3.js";
|
|
14
|
+
import "./chunk-2EIJYDNI.js";
|
|
15
|
+
import "./chunk-6BY4BV5G.js";
|
|
16
|
+
import "./chunk-GQKKX7OE.js";
|
|
17
|
+
import {
|
|
18
|
+
parseOutputFormat,
|
|
19
|
+
printJson
|
|
20
|
+
} from "./chunk-TQ2NA4Z4.js";
|
|
21
|
+
import {
|
|
22
|
+
fail,
|
|
23
|
+
formatCommand,
|
|
24
|
+
isVerboseMode
|
|
25
|
+
} from "./chunk-DXKAKKLP.js";
|
|
26
|
+
import {
|
|
27
|
+
formatCount,
|
|
28
|
+
ui
|
|
29
|
+
} from "./chunk-YDD3ES2K.js";
|
|
30
|
+
import "./chunk-ZY2MZ2KQ.js";
|
|
31
|
+
import "./chunk-VQVUJYYY.js";
|
|
32
|
+
import "./chunk-DWVAR4BP.js";
|
|
33
|
+
|
|
34
|
+
// src/cli/commands/pack.ts
|
|
35
|
+
import { resolve } from "path";
|
|
36
|
+
function handlePackCommand(opts) {
|
|
37
|
+
const format = parseOutputFormat(opts.format);
|
|
38
|
+
const verbose = Boolean(opts.verbose) || isVerboseMode();
|
|
39
|
+
try {
|
|
40
|
+
const result = packProject({
|
|
41
|
+
projectRoot: resolve(opts.project ?? "."),
|
|
42
|
+
outputDir: opts.output,
|
|
43
|
+
archive: opts.archive,
|
|
44
|
+
dryRun: opts.dryRun,
|
|
45
|
+
verbose
|
|
46
|
+
});
|
|
47
|
+
if (format === "json") {
|
|
48
|
+
printJson({
|
|
49
|
+
name: result.name,
|
|
50
|
+
version: result.version,
|
|
51
|
+
output: result.outputPath,
|
|
52
|
+
archive: result.archive,
|
|
53
|
+
dry_run: result.dryRun,
|
|
54
|
+
file_count: result.fileCount,
|
|
55
|
+
files: result.files,
|
|
56
|
+
warnings: result.warnings
|
|
57
|
+
});
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
for (const warning of result.warnings) {
|
|
61
|
+
ui.warn(warning);
|
|
62
|
+
}
|
|
63
|
+
if (verbose) {
|
|
64
|
+
for (const file of result.files) {
|
|
65
|
+
const remap = file.remappedFrom ? ` \u2190 ${file.remappedFrom}` : "";
|
|
66
|
+
console.log(` ${file.path}${remap}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const dest = result.dryRun ? `${result.outputPath} (dry run)` : result.outputPath;
|
|
70
|
+
ui.success(`Packed ${formatCount(result.fileCount, "file")} -> ${dest}`);
|
|
71
|
+
console.log(
|
|
72
|
+
ui.theme.muted(
|
|
73
|
+
"Plugin bundle ready: contains plugin.json plus plugin-native directories (agents/, skills/, commands/, hooks/) and an embedded apm.lock.yaml for install-time integrity verification."
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
ui.info(`Share with: ${formatCommand(["apply", result.outputPath])}`);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
if (error instanceof PackError) {
|
|
80
|
+
fail(error.message, {
|
|
81
|
+
hints: [formatCommand("config init"), formatCommand("apply")]
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function registerPackCommand(root) {
|
|
89
|
+
root.command("pack").description(
|
|
90
|
+
"Pack an apm.yml project into an Agent Plugins 1.0 bundle (plugin.json + primitives + apm.lock.yaml)"
|
|
91
|
+
).option("--project <path>", "Project directory", ".").option("-o, --output <dir>", "Bundle output directory", "build").option("--archive", "Write a .zip archive instead of a directory").option("--dry-run", "Print what would be packed without writing").option("--verbose", "List every packed file and remapping").option("--format <mode>", "Output format: human or json", "human").action((opts) => {
|
|
92
|
+
handlePackCommand(opts);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
handlePackCommand,
|
|
97
|
+
registerPackCommand
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=pack-V32UPC7W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/pack.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { resolve } from \"node:path\";\nimport { packProject, PackError } from \"../../services/apm-pack.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { formatCount } from \"../formatting.js\";\nimport {\n fail,\n formatCommand,\n isVerboseMode,\n} from \"../shared.js\";\n\nexport interface PackCommandOpts {\n project?: string;\n output?: string;\n archive?: boolean;\n dryRun?: boolean;\n verbose?: boolean;\n format?: string;\n}\n\nexport function handlePackCommand(opts: PackCommandOpts): void {\n const format = parseOutputFormat(opts.format);\n const verbose = Boolean(opts.verbose) || isVerboseMode();\n\n try {\n const result = packProject({\n projectRoot: resolve(opts.project ?? \".\"),\n outputDir: opts.output,\n archive: opts.archive,\n dryRun: opts.dryRun,\n verbose,\n });\n\n if (format === \"json\") {\n printJson({\n name: result.name,\n version: result.version,\n output: result.outputPath,\n archive: result.archive,\n dry_run: result.dryRun,\n file_count: result.fileCount,\n files: result.files,\n warnings: result.warnings,\n });\n return;\n }\n\n for (const warning of result.warnings) {\n ui.warn(warning);\n }\n if (verbose) {\n for (const file of result.files) {\n const remap = file.remappedFrom ? ` ← ${file.remappedFrom}` : \"\";\n console.log(` ${file.path}${remap}`);\n }\n }\n\n const dest = result.dryRun ? `${result.outputPath} (dry run)` : result.outputPath;\n ui.success(`Packed ${formatCount(result.fileCount, \"file\")} -> ${dest}`);\n console.log(\n ui.theme.muted(\n \"Plugin bundle ready: contains plugin.json plus plugin-native directories (agents/, skills/, commands/, hooks/) and an embedded apm.lock.yaml for install-time integrity verification.\",\n ),\n );\n ui.info(`Share with: ${formatCommand([\"apply\", result.outputPath])}`);\n } catch (error) {\n process.exitCode = 1;\n if (error instanceof PackError) {\n fail(error.message, {\n hints: [formatCommand(\"config init\"), formatCommand(\"apply\")],\n });\n return;\n }\n fail(error instanceof Error ? error.message : String(error));\n }\n}\n\nexport function registerPackCommand(root: Command): void {\n root\n .command(\"pack\")\n .description(\n \"Pack an apm.yml project into an Agent Plugins 1.0 bundle (plugin.json + primitives + apm.lock.yaml)\",\n )\n .option(\"--project <path>\", \"Project directory\", \".\")\n .option(\"-o, --output <dir>\", \"Bundle output directory\", \"build\")\n .option(\"--archive\", \"Write a .zip archive instead of a directory\")\n .option(\"--dry-run\", \"Print what would be packed without writing\")\n .option(\"--verbose\", \"List every packed file and remapping\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .action((opts: PackCommandOpts) => {\n handlePackCommand(opts);\n });\n}\n"],"mappings":";;;;;;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A,QAClB,OAAO,CAAC,cAAc,aAAa,GAAG,cAAc,OAAO,CAAC;AAAA,MAC9D,CAAC;AACD;AAAA,IACF;AACA,SAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,EAC7D;AACF;AAEO,SAAS,oBAAoB,MAAqB;AACvD,OACG,QAAQ,MAAM,EACd;AAAA,IACC;AAAA,EACF,EACC,OAAO,oBAAoB,qBAAqB,GAAG,EACnD,OAAO,sBAAsB,2BAA2B,OAAO,EAC/D,OAAO,aAAa,6CAA6C,EACjE,OAAO,aAAa,4CAA4C,EAChE,OAAO,aAAa,sCAAsC,EAC1D,OAAO,mBAAmB,gCAAgC,OAAO,EACjE,OAAO,CAAC,SAA0B;AACjC,sBAAkB,IAAI;AAAA,EACxB,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleProjectApplyCommand,
|
|
3
|
+
registerDeprecatedLayerAlias,
|
|
4
|
+
registerPluginCommands
|
|
5
|
+
} from "./chunk-SZNBUIDR.js";
|
|
6
|
+
import "./chunk-3RBYT7QN.js";
|
|
7
|
+
import "./chunk-BIBUCC2E.js";
|
|
8
|
+
import "./chunk-TYULB6ZY.js";
|
|
9
|
+
import "./chunk-VL7BGD47.js";
|
|
10
|
+
import "./chunk-MY62SSKC.js";
|
|
11
|
+
import "./chunk-4KNQZDZC.js";
|
|
12
|
+
import "./chunk-GRJY22U6.js";
|
|
13
|
+
import "./chunk-KDAV2GUT.js";
|
|
14
|
+
import "./chunk-J4CKQXQ6.js";
|
|
15
|
+
import "./chunk-IRU7NBOT.js";
|
|
16
|
+
import "./chunk-VZQG2JDV.js";
|
|
17
|
+
import "./chunk-VL2NWCZV.js";
|
|
18
|
+
import "./chunk-IBOABSIA.js";
|
|
19
|
+
import "./chunk-NJ7WRKIQ.js";
|
|
20
|
+
import "./chunk-KRI4R7EM.js";
|
|
21
|
+
import "./chunk-H6DVP2SI.js";
|
|
22
|
+
import "./chunk-EIWXS4RM.js";
|
|
23
|
+
import "./chunk-JKGSJGCC.js";
|
|
24
|
+
import "./chunk-KMWHZSEG.js";
|
|
25
|
+
import "./chunk-XGTTOO4R.js";
|
|
26
|
+
import "./chunk-37E5M4JX.js";
|
|
27
|
+
import "./chunk-JQOKQKQT.js";
|
|
28
|
+
import "./chunk-3FIWOI3H.js";
|
|
29
|
+
import "./chunk-CHQGE2HF.js";
|
|
30
|
+
import "./chunk-QO4LBDVI.js";
|
|
31
|
+
import "./chunk-KCQC7YBK.js";
|
|
32
|
+
import "./chunk-PXU2OS26.js";
|
|
33
|
+
import "./chunk-NAGAJ5UM.js";
|
|
34
|
+
import "./chunk-IK524ZDW.js";
|
|
35
|
+
import "./chunk-SY7G5QEI.js";
|
|
36
|
+
import "./chunk-XQFT4PEP.js";
|
|
37
|
+
import "./chunk-MWXA4PFE.js";
|
|
38
|
+
import "./chunk-3IZ7SEGT.js";
|
|
39
|
+
import "./chunk-I6XFZLTJ.js";
|
|
40
|
+
import "./chunk-7L2K4N25.js";
|
|
41
|
+
import "./chunk-JRFUTIEH.js";
|
|
42
|
+
import "./chunk-UJYFTXHV.js";
|
|
43
|
+
import "./chunk-3IWTJCPA.js";
|
|
44
|
+
import "./chunk-KDDXZBMC.js";
|
|
45
|
+
import "./chunk-HVVPTCKR.js";
|
|
46
|
+
import "./chunk-SPRVUATR.js";
|
|
47
|
+
import "./chunk-EWBCFAF3.js";
|
|
48
|
+
import "./chunk-2EIJYDNI.js";
|
|
49
|
+
import "./chunk-6BY4BV5G.js";
|
|
50
|
+
import "./chunk-GQKKX7OE.js";
|
|
51
|
+
import "./chunk-K2BPYEH5.js";
|
|
52
|
+
import "./chunk-G26HZZDJ.js";
|
|
53
|
+
import "./chunk-TQ2NA4Z4.js";
|
|
54
|
+
import "./chunk-DXKAKKLP.js";
|
|
55
|
+
import "./chunk-YDD3ES2K.js";
|
|
56
|
+
import "./chunk-ZY2MZ2KQ.js";
|
|
57
|
+
import "./chunk-VQVUJYYY.js";
|
|
58
|
+
import "./chunk-DWVAR4BP.js";
|
|
59
|
+
export {
|
|
60
|
+
handleProjectApplyCommand,
|
|
61
|
+
registerDeprecatedLayerAlias,
|
|
62
|
+
registerPluginCommands
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=plugin-KOBNQ7GT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPluginFromProject,
|
|
3
|
+
previewPluginFromProject
|
|
4
|
+
} from "./chunk-MWXA4PFE.js";
|
|
5
|
+
import "./chunk-3IWTJCPA.js";
|
|
6
|
+
import "./chunk-2EIJYDNI.js";
|
|
7
|
+
import "./chunk-6BY4BV5G.js";
|
|
8
|
+
import "./chunk-GQKKX7OE.js";
|
|
9
|
+
import "./chunk-ZY2MZ2KQ.js";
|
|
10
|
+
import "./chunk-VQVUJYYY.js";
|
|
11
|
+
import "./chunk-DWVAR4BP.js";
|
|
12
|
+
export {
|
|
13
|
+
createPluginFromProject,
|
|
14
|
+
previewPluginFromProject
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=plugin-from-project-X3VO3MB6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXEC_TYPES,
|
|
3
|
+
buildExecutableTrustContext,
|
|
4
|
+
evaluateExecutableType,
|
|
5
|
+
exactGrantMatch,
|
|
6
|
+
execStatusFromDecisions,
|
|
7
|
+
installedTrustReports
|
|
8
|
+
} from "./chunk-KDDXZBMC.js";
|
|
9
|
+
import "./chunk-HVVPTCKR.js";
|
|
10
|
+
import {
|
|
11
|
+
readLockfile
|
|
12
|
+
} from "./chunk-SPRVUATR.js";
|
|
13
|
+
import "./chunk-EWBCFAF3.js";
|
|
14
|
+
import "./chunk-2EIJYDNI.js";
|
|
15
|
+
import "./chunk-6BY4BV5G.js";
|
|
16
|
+
import "./chunk-GQKKX7OE.js";
|
|
17
|
+
import {
|
|
18
|
+
parseOutputFormat,
|
|
19
|
+
printJson
|
|
20
|
+
} from "./chunk-TQ2NA4Z4.js";
|
|
21
|
+
import {
|
|
22
|
+
ui
|
|
23
|
+
} from "./chunk-YDD3ES2K.js";
|
|
24
|
+
import "./chunk-ZY2MZ2KQ.js";
|
|
25
|
+
import "./chunk-VQVUJYYY.js";
|
|
26
|
+
import "./chunk-DWVAR4BP.js";
|
|
27
|
+
|
|
28
|
+
// src/cli/commands/policy.ts
|
|
29
|
+
import { resolve } from "path";
|
|
30
|
+
function shadowedLine(decision) {
|
|
31
|
+
if (decision.shadowed.length === 0) {
|
|
32
|
+
return "none";
|
|
33
|
+
}
|
|
34
|
+
return decision.shadowed.map((entry) => `${entry.layer} (${entry.outcome})`).join(", ");
|
|
35
|
+
}
|
|
36
|
+
function printExplain(report, optedIn) {
|
|
37
|
+
if (!optedIn) {
|
|
38
|
+
ui.info(`${report.ref} gate off`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
ui.info(`${report.ref} ${report.execStatus}`);
|
|
42
|
+
const types = report.gatedTypes.length > 0 ? report.gatedTypes : EXEC_TYPES;
|
|
43
|
+
for (const type of types) {
|
|
44
|
+
const decision = report.decisions.find((entry) => entry.type === type);
|
|
45
|
+
if (!decision) continue;
|
|
46
|
+
ui.info(
|
|
47
|
+
` ${type} ${decision.outcome} layer ${decision.layer} shadowed ${shadowedLine(decision)}`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function reportForRef(packageRef, installed, context) {
|
|
52
|
+
const existing = installed.find(
|
|
53
|
+
(entry) => exactGrantMatch(packageRef, [entry.ref, entry.name, ...entry.identities])
|
|
54
|
+
);
|
|
55
|
+
if (existing) {
|
|
56
|
+
return existing;
|
|
57
|
+
}
|
|
58
|
+
const identities = [packageRef];
|
|
59
|
+
const decisions = EXEC_TYPES.map((type) => evaluateExecutableType(context, identities, type));
|
|
60
|
+
return {
|
|
61
|
+
ref: packageRef,
|
|
62
|
+
name: packageRef,
|
|
63
|
+
version: "",
|
|
64
|
+
identities,
|
|
65
|
+
gatedTypes: [...EXEC_TYPES],
|
|
66
|
+
decisions,
|
|
67
|
+
execStatus: execStatusFromDecisions([...EXEC_TYPES], decisions)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function handlePolicyExplainCommand(packageRef, opts) {
|
|
71
|
+
const format = parseOutputFormat(opts.format);
|
|
72
|
+
const projectRoot = resolve(opts.project ?? ".");
|
|
73
|
+
const context = buildExecutableTrustContext({ projectRoot });
|
|
74
|
+
const lock = readLockfile(projectRoot);
|
|
75
|
+
const installed = installedTrustReports(context, { ...lock ? { lock } : {} });
|
|
76
|
+
const report = reportForRef(packageRef, installed, context);
|
|
77
|
+
if (format === "json") {
|
|
78
|
+
printJson({
|
|
79
|
+
ref: report.ref,
|
|
80
|
+
name: report.name,
|
|
81
|
+
version: report.version,
|
|
82
|
+
exec_status: report.execStatus,
|
|
83
|
+
opted_in: context.optedIn,
|
|
84
|
+
deciding_layer: report.decisions[0]?.layer,
|
|
85
|
+
decisions: report.decisions,
|
|
86
|
+
warnings: context.warnings
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
for (const warning of context.warnings) {
|
|
91
|
+
ui.warn(warning);
|
|
92
|
+
}
|
|
93
|
+
printExplain(report, context.optedIn);
|
|
94
|
+
}
|
|
95
|
+
function registerPolicyCommands(root) {
|
|
96
|
+
const policy = root.command("policy").description("Inspect executable-trust and apm-policy.yml decisions");
|
|
97
|
+
policy.command("explain").description("Print the effective executable-trust decision for a package").argument("<PACKAGE_REF>", "Package to explain (owner/repo)").option("--project <path>", "Project directory", ".").option("--format <mode>", "Output format: human or json", "human").action((ref, explainOpts) => {
|
|
98
|
+
handlePolicyExplainCommand(ref, explainOpts);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
handlePolicyExplainCommand,
|
|
103
|
+
registerPolicyCommands
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=policy-F5MKZNOC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/policy.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { resolve } from \"node:path\";\nimport {\n buildExecutableTrustContext,\n evaluateExecutableType,\n exactGrantMatch,\n EXEC_TYPES,\n execStatusFromDecisions,\n installedTrustReports,\n type PackageTrustReport,\n} from \"../../services/executable-trust.js\";\nimport { readLockfile } from \"../../services/lockfile.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { ui } from \"../../ui/index.js\";\n\nexport interface PolicyExplainOpts {\n project?: string;\n format?: string;\n}\n\nfunction shadowedLine(decision: PackageTrustReport[\"decisions\"][number]): string {\n if (decision.shadowed.length === 0) {\n return \"none\";\n }\n return decision.shadowed\n .map((entry) => `${entry.layer} (${entry.outcome})`)\n .join(\", \");\n}\n\nfunction printExplain(report: PackageTrustReport, optedIn: boolean): void {\n if (!optedIn) {\n ui.info(`${report.ref} gate off`);\n return;\n }\n ui.info(`${report.ref} ${report.execStatus}`);\n const types = report.gatedTypes.length > 0 ? report.gatedTypes : EXEC_TYPES;\n for (const type of types) {\n const decision = report.decisions.find((entry) => entry.type === type);\n if (!decision) continue;\n ui.info(\n ` ${type} ${decision.outcome} layer ${decision.layer} shadowed ${shadowedLine(decision)}`,\n );\n }\n}\n\nfunction reportForRef(\n packageRef: string,\n installed: PackageTrustReport[],\n context: ReturnType<typeof buildExecutableTrustContext>,\n): PackageTrustReport {\n const existing = installed.find((entry) =>\n exactGrantMatch(packageRef, [entry.ref, entry.name, ...entry.identities]),\n );\n if (existing) {\n return existing;\n }\n const identities = [packageRef];\n const decisions = EXEC_TYPES.map((type) => evaluateExecutableType(context, identities, type));\n return {\n ref: packageRef,\n name: packageRef,\n version: \"\",\n identities,\n gatedTypes: [...EXEC_TYPES],\n decisions,\n execStatus: execStatusFromDecisions([...EXEC_TYPES], decisions),\n };\n}\n\nexport function handlePolicyExplainCommand(\n packageRef: string,\n opts: PolicyExplainOpts,\n): void {\n const format = parseOutputFormat(opts.format);\n const projectRoot = resolve(opts.project ?? \".\");\n const context = buildExecutableTrustContext({ projectRoot });\n const lock = readLockfile(projectRoot);\n const installed = installedTrustReports(context, { ...(lock ? { lock } : {}) });\n const report = reportForRef(packageRef, installed, context);\n\n if (format === \"json\") {\n printJson({\n ref: report.ref,\n name: report.name,\n version: report.version,\n exec_status: report.execStatus,\n opted_in: context.optedIn,\n deciding_layer: report.decisions[0]?.layer,\n decisions: report.decisions,\n warnings: context.warnings,\n });\n return;\n }\n for (const warning of context.warnings) {\n ui.warn(warning);\n }\n printExplain(report, context.optedIn);\n}\n\nexport function registerPolicyCommands(root: Command): void {\n const policy = root\n .command(\"policy\")\n .description(\"Inspect executable-trust and apm-policy.yml decisions\");\n\n policy\n .command(\"explain\")\n .description(\"Print the effective executable-trust decision for a package\")\n .argument(\"<PACKAGE_REF>\", \"Package to explain (owner/repo)\")\n .option(\"--project <path>\", \"Project directory\", \".\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .action((ref: string, explainOpts: PolicyExplainOpts) => {\n handlePolicyExplainCommand(ref, explainOpts);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,eAAe;AAmBxB,SAAS,aAAa,UAA2D;AAC/E,MAAI,SAAS,SAAS,WAAW,GAAG;AAClC,WAAO;AAAA,EACT;AACA,SAAO,SAAS,SACb,IAAI,CAAC,UAAU,GAAG,MAAM,KAAK,KAAK,MAAM,OAAO,GAAG,EAClD,KAAK,IAAI;AACd;AAEA,SAAS,aAAa,QAA4B,SAAwB;AACxE,MAAI,CAAC,SAAS;AACZ,OAAG,KAAK,GAAG,OAAO,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