@lesliechan721/aw 0.1.0-beta.7 → 0.1.0-beta.8

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 (237) hide show
  1. package/dist/authoring/scripts/init-plugin.mjs +4 -33
  2. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  3. package/dist/authoring/scripts/lib/plugin-version-check.mjs +1 -1
  4. package/dist/authoring/scripts/plugin-status.mjs +8 -11
  5. package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
  6. package/dist/authoring/scripts/remove-plugin.mjs +1 -0
  7. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  8. package/dist/authoring/scripts/validate-plugin.mjs +104 -54
  9. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  10. package/dist/scripts/codex-eval-app-server.d.ts +2 -0
  11. package/dist/scripts/codex-eval-app-server.js +107 -1
  12. package/dist/scripts/codex-eval-app-server.js.map +1 -1
  13. package/dist/scripts/eval-plugin-skills.js +5 -2
  14. package/dist/scripts/eval-plugin-skills.js.map +1 -1
  15. package/dist/scripts/plugin-eval-contract.d.ts +5 -1
  16. package/dist/scripts/plugin-eval-contract.js +54 -4
  17. package/dist/scripts/plugin-eval-contract.js.map +1 -1
  18. package/dist/scripts/plugin-staging.d.ts +6 -7
  19. package/dist/scripts/plugin-staging.js +11 -23
  20. package/dist/scripts/plugin-staging.js.map +1 -1
  21. package/dist/scripts/test-plugin-scripts.js +2 -33
  22. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  23. package/dist/src/adapters/helpers.js +2 -2
  24. package/dist/src/adapters/helpers.js.map +1 -1
  25. package/dist/src/authoring/workspace-commands.d.ts +17 -2
  26. package/dist/src/authoring/workspace-commands.js +21 -4
  27. package/dist/src/authoring/workspace-commands.js.map +1 -1
  28. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  29. package/dist/src/commands/aw-capabilities.js +259 -0
  30. package/dist/src/commands/aw-capabilities.js.map +1 -0
  31. package/dist/src/commands/catalog-context.d.ts +52 -0
  32. package/dist/src/commands/catalog-context.js +156 -0
  33. package/dist/src/commands/catalog-context.js.map +1 -0
  34. package/dist/src/commands/catalog-dev-source.d.ts +112 -0
  35. package/dist/src/commands/catalog-dev-source.js +481 -0
  36. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  37. package/dist/src/commands/catalog-generation.d.ts +26 -0
  38. package/dist/src/commands/catalog-generation.js +14 -0
  39. package/dist/src/commands/catalog-generation.js.map +1 -0
  40. package/dist/src/commands/catalog-publication-inspection.d.ts +1 -1
  41. package/dist/src/commands/catalog-publication-inspection.js +4 -5
  42. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  43. package/dist/src/commands/catalog-publication-target.d.ts +17 -0
  44. package/dist/src/commands/catalog-publication-target.js +60 -0
  45. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  46. package/dist/src/commands/catalog-publish.d.ts +8 -1
  47. package/dist/src/commands/catalog-publish.js +25 -2
  48. package/dist/src/commands/catalog-publish.js.map +1 -1
  49. package/dist/src/commands/catalog-source.d.ts +23 -1
  50. package/dist/src/commands/catalog-source.js +126 -40
  51. package/dist/src/commands/catalog-source.js.map +1 -1
  52. package/dist/src/commands/catalog-status.d.ts +18 -2
  53. package/dist/src/commands/catalog-status.js +122 -18
  54. package/dist/src/commands/catalog-status.js.map +1 -1
  55. package/dist/src/commands/init.js +1 -1
  56. package/dist/src/commands/init.js.map +1 -1
  57. package/dist/src/commands/offline-cleanup-evidence.d.ts +23 -0
  58. package/dist/src/commands/offline-cleanup-evidence.js +38 -0
  59. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  60. package/dist/src/commands/options.d.ts +1 -0
  61. package/dist/src/commands/options.js +1 -0
  62. package/dist/src/commands/options.js.map +1 -1
  63. package/dist/src/commands/plugin-capabilities.js +1 -1
  64. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  65. package/dist/src/commands/rebuild-command.d.ts +19 -7
  66. package/dist/src/commands/rebuild-command.js +415 -205
  67. package/dist/src/commands/rebuild-command.js.map +1 -1
  68. package/dist/src/commands/rebuild-integration.d.ts +10 -3
  69. package/dist/src/commands/rebuild-integration.js +71 -76
  70. package/dist/src/commands/rebuild-integration.js.map +1 -1
  71. package/dist/src/commands/rebuild-operations.d.ts +0 -8
  72. package/dist/src/commands/rebuild-operations.js +17 -115
  73. package/dist/src/commands/rebuild-operations.js.map +1 -1
  74. package/dist/src/commands/runtime.js +21 -34
  75. package/dist/src/commands/runtime.js.map +1 -1
  76. package/dist/src/commands/{status-v4.d.ts → status-v5.d.ts} +67 -21
  77. package/dist/src/commands/{status-v4.js → status-v5.js} +260 -30
  78. package/dist/src/commands/status-v5.js.map +1 -0
  79. package/dist/src/commands/wizard.d.ts +2 -2
  80. package/dist/src/commands/wizard.js +2 -2
  81. package/dist/src/commands/wizard.js.map +1 -1
  82. package/dist/src/commands/write-commands.js +73 -17
  83. package/dist/src/commands/write-commands.js.map +1 -1
  84. package/dist/src/constants.d.ts +6 -1
  85. package/dist/src/constants.js +6 -1
  86. package/dist/src/constants.js.map +1 -1
  87. package/dist/src/generators/local-plugin.js +57 -3
  88. package/dist/src/generators/local-plugin.js.map +1 -1
  89. package/dist/src/index.d.ts +4 -1
  90. package/dist/src/index.js +562 -85
  91. package/dist/src/index.js.map +1 -1
  92. package/dist/src/output/model.d.ts +1 -34
  93. package/dist/src/output/model.js +1 -144
  94. package/dist/src/output/model.js.map +1 -1
  95. package/dist/src/output/rebuild-progress.js +0 -3
  96. package/dist/src/output/rebuild-progress.js.map +1 -1
  97. package/dist/src/portable/commands.d.ts +4 -0
  98. package/dist/src/portable/commands.js +61 -4
  99. package/dist/src/portable/commands.js.map +1 -1
  100. package/dist/src/portable/materializer.d.ts +3 -0
  101. package/dist/src/portable/materializer.js +61 -10
  102. package/dist/src/portable/materializer.js.map +1 -1
  103. package/dist/src/tui/catalog-generation.d.ts +56 -0
  104. package/dist/src/tui/catalog-generation.js +244 -0
  105. package/dist/src/tui/catalog-generation.js.map +1 -0
  106. package/dist/src/tui/console-app-v4.d.ts +1 -1
  107. package/dist/src/tui/console-app-v4.js +446 -126
  108. package/dist/src/tui/console-app-v4.js.map +1 -1
  109. package/dist/src/tui/controller-runtime.d.ts +8 -2
  110. package/dist/src/tui/controller-runtime.js +606 -92
  111. package/dist/src/tui/controller-runtime.js.map +1 -1
  112. package/dist/src/tui/controller.d.ts +71 -6
  113. package/dist/src/tui/controller.js +377 -83
  114. package/dist/src/tui/controller.js.map +1 -1
  115. package/dist/src/tui/index.d.ts +1 -0
  116. package/dist/src/tui/index.js +1 -0
  117. package/dist/src/tui/index.js.map +1 -1
  118. package/dist/src/tui/input-display.d.ts +8 -0
  119. package/dist/src/tui/input-display.js +36 -0
  120. package/dist/src/tui/input-display.js.map +1 -0
  121. package/dist/src/tui/model.d.ts +27 -7
  122. package/dist/src/tui/model.js +273 -65
  123. package/dist/src/tui/model.js.map +1 -1
  124. package/dist/src/tui/router.d.ts +26 -0
  125. package/dist/src/tui/router.js.map +1 -1
  126. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  127. package/dist/src/tui/source-ref-presets.js +11 -0
  128. package/dist/src/tui/source-ref-presets.js.map +1 -0
  129. package/dist/src/tui/views.js +31 -3
  130. package/dist/src/tui/views.js.map +1 -1
  131. package/dist/src/types.d.ts +90 -6
  132. package/dist/src/types.js.map +1 -1
  133. package/dist/src/utils/agent-version.d.ts +3 -0
  134. package/dist/src/utils/agent-version.js +13 -5
  135. package/dist/src/utils/agent-version.js.map +1 -1
  136. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  137. package/dist/src/utils/aw-home-mutation-lock.js +32 -4
  138. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  139. package/dist/src/utils/bundle-integrity.d.ts +0 -1
  140. package/dist/src/utils/bundle-integrity.js +0 -25
  141. package/dist/src/utils/bundle-integrity.js.map +1 -1
  142. package/dist/src/utils/bundle-layout.js +8 -6
  143. package/dist/src/utils/bundle-layout.js.map +1 -1
  144. package/dist/src/utils/catalog-digests.js +13 -2
  145. package/dist/src/utils/catalog-digests.js.map +1 -1
  146. package/dist/src/utils/catalog-generation-error.d.ts +12 -0
  147. package/dist/src/utils/catalog-generation-error.js +16 -0
  148. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  149. package/dist/src/utils/catalog-generation-resolver.d.ts +13 -0
  150. package/dist/src/utils/catalog-generation-resolver.js +129 -0
  151. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  152. package/dist/src/utils/catalog-generation-service.d.ts +52 -0
  153. package/dist/src/utils/catalog-generation-service.js +620 -0
  154. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  155. package/dist/src/utils/catalog-generation-state.d.ts +13 -0
  156. package/dist/src/utils/catalog-generation-state.js +201 -0
  157. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  158. package/dist/src/utils/catalog-generation-store.d.ts +44 -0
  159. package/dist/src/utils/catalog-generation-store.js +387 -0
  160. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  161. package/dist/src/utils/catalog-manifest-v5.d.ts +5 -0
  162. package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v5.js} +39 -35
  163. package/dist/src/utils/{catalog-manifest-v4.js.map → catalog-manifest-v5.js.map} +1 -1
  164. package/dist/src/utils/catalog-operation-context.d.ts +28 -0
  165. package/dist/src/utils/catalog-operation-context.js +242 -0
  166. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  167. package/dist/src/utils/catalog-public-error.d.ts +7 -3
  168. package/dist/src/utils/catalog-public-error.js +20 -4
  169. package/dist/src/utils/catalog-public-error.js.map +1 -1
  170. package/dist/src/utils/catalog-snapshot.d.ts +5 -3
  171. package/dist/src/utils/catalog-snapshot.js +11 -3
  172. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  173. package/dist/src/utils/catalog-source-cache.d.ts +1 -1
  174. package/dist/src/utils/catalog-source-cache.js +37 -12
  175. package/dist/src/utils/catalog-source-cache.js.map +1 -1
  176. package/dist/src/utils/catalog-source-identity.d.ts +1 -0
  177. package/dist/src/utils/catalog-source-identity.js +21 -2
  178. package/dist/src/utils/catalog-source-identity.js.map +1 -1
  179. package/dist/src/utils/catalog-sources.d.ts +1 -0
  180. package/dist/src/utils/catalog-sources.js +30 -11
  181. package/dist/src/utils/catalog-sources.js.map +1 -1
  182. package/dist/src/utils/codex-config.js +4 -4
  183. package/dist/src/utils/codex-config.js.map +1 -1
  184. package/dist/src/utils/codex-manager.d.ts +33 -0
  185. package/dist/src/utils/codex-manager.js +656 -0
  186. package/dist/src/utils/codex-manager.js.map +1 -0
  187. package/dist/src/utils/codex-skill-staging.d.ts +2 -0
  188. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  189. package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
  190. package/dist/src/utils/dynamic-skill-tree.js +35 -5
  191. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  192. package/dist/src/utils/git-catalog-provider.js +10 -25
  193. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  194. package/dist/src/utils/lifecycle-active-store.d.ts +0 -28
  195. package/dist/src/utils/lifecycle-active-store.js +35 -247
  196. package/dist/src/utils/lifecycle-active-store.js.map +1 -1
  197. package/dist/src/utils/multi-source-catalog.d.ts +3 -0
  198. package/dist/src/utils/multi-source-catalog.js +120 -10
  199. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  200. package/dist/src/utils/native-cli.d.ts +15 -6
  201. package/dist/src/utils/native-cli.js +31 -39
  202. package/dist/src/utils/native-cli.js.map +1 -1
  203. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -3
  204. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  205. package/dist/src/utils/ownership.d.ts +10 -1
  206. package/dist/src/utils/ownership.js +52 -24
  207. package/dist/src/utils/ownership.js.map +1 -1
  208. package/dist/src/utils/path-catalog-provider.js +12 -8
  209. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  210. package/dist/src/utils/plugin-config-write.js +18 -35
  211. package/dist/src/utils/plugin-config-write.js.map +1 -1
  212. package/dist/src/utils/plugin-config.d.ts +1 -12
  213. package/dist/src/utils/plugin-config.js +107 -226
  214. package/dist/src/utils/plugin-config.js.map +1 -1
  215. package/dist/src/utils/plugin-scripts.d.ts +1 -1
  216. package/dist/src/utils/plugin-scripts.js +1 -1
  217. package/dist/src/utils/plugin-scripts.js.map +1 -1
  218. package/dist/src/utils/state-paths.js +7 -2
  219. package/dist/src/utils/state-paths.js.map +1 -1
  220. package/dist/src/utils/target-eligibility.d.ts +7 -2
  221. package/dist/src/utils/target-eligibility.js +6 -3
  222. package/dist/src/utils/target-eligibility.js.map +1 -1
  223. package/package.json +4 -3
  224. package/dist/authoring/scripts/check-plugin-versions.d.mts +0 -2
  225. package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
  226. package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
  227. package/dist/src/commands/status-v4.js.map +0 -1
  228. package/dist/src/commands/status.d.ts +0 -93
  229. package/dist/src/commands/status.js +0 -442
  230. package/dist/src/commands/status.js.map +0 -1
  231. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
  232. package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
  233. package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
  234. package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
  235. package/dist/src/utils/catalog-manifest-v3.js +0 -3
  236. package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
  237. package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
@@ -14,12 +14,11 @@ import { buildCodexMarketplaceAddInvocation, buildCodexMarketplaceListInvocation
14
14
  import { OWNED_TEXT_HEADER_PREFIX, createSharedOwnerToken, createSkillOwnerMarkerContent, parseSharedOwnerToken, parseOwnedTextHeader, readSkillOwnerMarker, inspectOwnedComponents, writeOwnedTextFile, } from '../utils/ownership.js';
15
15
  import { resolveArtifactRenderConfig, runArtifactRenderer } from '../utils/artifact-renderer.js';
16
16
  import { validateArtifactPlan } from '../utils/artifact-plan.js';
17
- import { readPluginManifest } from '../utils/manifest.js';
17
+ import { createAwPluginRequirementsReceipt, readPluginManifest, } from '../utils/manifest.js';
18
18
  import { resolvePlatformEntries } from '../utils/platform-entries.js';
19
19
  import { resolveAwHome, resolveClaudePaths, resolveCodexPaths, resolveRepoRoot, getCodexHome, } from '../utils/paths.js';
20
20
  import { runLifecycleScript } from '../utils/plugin-scripts.js';
21
- import { atomicRemoveConfigFile, atomicReplaceConfigFile, withConfigFileLock, } from '../utils/plugin-config.js';
22
- import { withActiveMarketplaceLifecycleLease, withActiveMarketplaceRuntimeLease, } from '../utils/active-marketplace-runtime-lock.js';
21
+ import { atomicRemoveConfigFile, atomicReplaceConfigFile, withConfigFileMutation, } from '../utils/plugin-config.js';
23
22
  import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
24
23
  import { getNamespacedMarketplaceName, projectMarketplaceManifestForPlatform, replayNamespacedCodexSkillOverlays, } from '../utils/local-marketplace.js';
25
24
  import { cleanupOrphanNamespacedMarketplaceRoot, commitMarketplaceGenerationBackup, } from '../utils/orphan-marketplace-cleanup.js';
@@ -29,6 +28,17 @@ import { assertCanonicalProjectManagedRoots } from '../utils/project-boundary.js
29
28
  import { findCodexRoleNameConflict, resolveCodexRoleNamespace, } from '../utils/codex-roles.js';
30
29
  const MARKETPLACE_NAME = 'aw';
31
30
  const MCP_OWNER_ENV = 'AW_AGENT_WORKFLOWS_OWNER';
31
+ function requirementsReceipt(plugin) {
32
+ const receipt = createAwPluginRequirementsReceipt({ name: plugin.manifest.name, version: plugin.manifest.version }, plugin.manifest.requires?.aw.capabilities ?? []);
33
+ return Buffer.from(`${JSON.stringify(receipt, null, 2)}\n`, 'utf8');
34
+ }
35
+ function requireCodexManager(manager) {
36
+ if (!manager) {
37
+ throw new Error('codexManagerRequired: Codex native operation has no resolved manager.');
38
+ }
39
+ return manager;
40
+ }
41
+ const CODEX_REMOVE_RECOVERY = 'Codex residue was retained. Retry cleanup or uninstall, upgrade AW, or install a compatible official Codex CLI.';
32
42
  function ownerIdentity(plugin, artifactKey, platform, scope) {
33
43
  return { owner: 'agent-workflows', plugin, artifactKey, platform, scope };
34
44
  }
@@ -60,7 +70,7 @@ function pathComponent(options) {
60
70
  return {
61
71
  ...options,
62
72
  validateHealth: async () => {
63
- await validateSkillDirectory(options.path, options.identity.platform === 'codex' ? 'codex.skill' : 'claude.skill', { ownerMarkerPolicy: 'ignore' });
73
+ await validateSkillDirectory(options.path, options.identity.platform === 'codex' ? 'codex.skill' : 'claude.skill', { ownerMarkerPolicy: 'ignore', requirementsReceiptPolicy: 'allow' });
64
74
  },
65
75
  };
66
76
  }
@@ -278,7 +288,7 @@ function renderCodexHookGroups(groups) {
278
288
  return `${JSON.stringify({ hooks }, null, 2)}\n`;
279
289
  }
280
290
  export async function applyCodexHookGroupsTransactionFile(hooksPath, update, testHooks) {
281
- return withConfigFileLock({
291
+ return withConfigFileMutation({
282
292
  filePath: hooksPath,
283
293
  allowedRoot: path.dirname(hooksPath),
284
294
  action: async () => {
@@ -536,6 +546,8 @@ async function scanOwnedTextFiles(options) {
536
546
  }
537
547
  if (parsed?.identity.plugin !== options.pluginName
538
548
  || (options.sourceId !== undefined && parsed.identity.sourceId !== options.sourceId)
549
+ || (options.sourceIdentity !== undefined
550
+ && parsed.identity.sourceIdentity !== options.sourceIdentity)
539
551
  || parsed.identity.platform !== options.platform
540
552
  || parsed.identity.scope !== options.scope)
541
553
  continue;
@@ -566,6 +578,7 @@ async function scanOwnedSkills(options) {
566
578
  }).catch(() => null);
567
579
  if (marker?.plugin === options.pluginName
568
580
  && (options.sourceId === undefined || marker.sourceId === options.sourceId)
581
+ && (options.sourceIdentity === undefined || marker.sourceIdentity === options.sourceIdentity)
569
582
  && marker.platform === options.platform
570
583
  && marker.scope === options.scope) {
571
584
  output.push(pathComponent({
@@ -853,6 +866,7 @@ async function buildBundledCodexSkillWrites(options) {
853
866
  content: { files: {} },
854
867
  },
855
868
  sourceDirs: [skillSource],
869
+ sourceRequirementsReceiptPolicy: 'allow',
856
870
  });
857
871
  const skillPath = path.join(targetRoot, entry.name);
858
872
  const canRecoverPristine = options.scope === 'user'
@@ -903,6 +917,8 @@ async function buildClaudeWrites(options) {
903
917
  artifact,
904
918
  sourceDirs: dynamic.sourceDirs(artifact),
905
919
  requireReadme: true,
920
+ requirementsReceipt: requirementsReceipt(options.plugin),
921
+ sourceRequirementsReceiptPolicy: 'allow',
906
922
  });
907
923
  writes.push(dynamicSkillWrite({
908
924
  ...options,
@@ -971,6 +987,8 @@ async function buildCodexWrites(options) {
971
987
  artifact,
972
988
  sourceDirs: dynamic.sourceDirs(artifact),
973
989
  requireReadme: true,
990
+ requirementsReceipt: requirementsReceipt(options.plugin),
991
+ sourceRequirementsReceiptPolicy: 'allow',
974
992
  });
975
993
  writes.push(dynamicSkillWrite({
976
994
  ...options,
@@ -1608,6 +1626,23 @@ async function inspectCodexNativeResidue(options) {
1608
1626
  installedVersions: [], cacheVersions: [], enabled: false,
1609
1627
  };
1610
1628
  }
1629
+ export async function codexNativeRemovalRequired(options) {
1630
+ const residue = await inspectCodexNativeResidue(options);
1631
+ if (residue.state === 'present')
1632
+ return true;
1633
+ if (residue.state === 'foreign')
1634
+ return false;
1635
+ const marketplaceName = options.marketplaceName ?? MARKETPLACE_NAME;
1636
+ const marketplaceRoot = options.marketplaceRoot ?? resolveAwHome(options.env);
1637
+ const config = await readCodexConfigFile(resolveCodexPaths(options.cwd, 'user', options.env).configTomlPath);
1638
+ const marketplace = config.snapshot.marketplaces[marketplaceName];
1639
+ const canonical = marketplace?.sourceType === 'local'
1640
+ && !marketplace.sourcePointsToManifest
1641
+ && path.normalize(marketplace.source ?? '') === path.normalize(marketplaceRoot);
1642
+ if (!canonical)
1643
+ return false;
1644
+ return (await discoverCodexNativeResidueNames(options)).length === 0;
1645
+ }
1611
1646
  export async function discoverCodexNativeResidueNames(options) {
1612
1647
  const marketplaceName = options.marketplaceName ?? MARKETPLACE_NAME;
1613
1648
  const marketplaceRoot = options.marketplaceRoot ?? resolveAwHome(options.env);
@@ -1809,8 +1844,13 @@ function createCodexMarketplaceComponent(options) {
1809
1844
  || currentResidue.state === 'present'
1810
1845
  || await hasRemainingPlugins())
1811
1846
  return;
1812
- await runNativeCliChecked(buildCodexMarketplaceRemoveInvocation(options.marketplaceName, options.cwd, options.env), options.runner);
1813
- await runNativeCliChecked(buildCodexMarketplaceListInvocation(options.cwd, options.env), options.runner);
1847
+ try {
1848
+ await runNativeCliChecked(buildCodexMarketplaceRemoveInvocation(requireCodexManager(options.codexManager), options.marketplaceName, options.cwd, options.env), options.runner);
1849
+ await runNativeCliChecked(buildCodexMarketplaceListInvocation(requireCodexManager(options.codexManager), options.cwd, options.env), options.runner);
1850
+ }
1851
+ catch {
1852
+ throw new Error(`codexNativeRemoveFailed: ${CODEX_REMOVE_RECOVERY}`);
1853
+ }
1814
1854
  },
1815
1855
  };
1816
1856
  }
@@ -2414,7 +2454,7 @@ async function mirrorCatalog(catalog, env, target) {
2414
2454
  }
2415
2455
  function createNativeDriver(options) {
2416
2456
  const runner = options.context.nativeCliRunner;
2417
- const materializeLeaseHeld = new WeakSet();
2457
+ const codexManager = options.context.codexManager;
2418
2458
  const mirrorTransactions = new WeakMap();
2419
2459
  const finalizeNamespacedCleanup = async (target) => {
2420
2460
  const { sourceId, sourceIdentity, marketplaceRoot, marketplaceName } = target.identity;
@@ -2429,53 +2469,13 @@ function createNativeDriver(options) {
2429
2469
  });
2430
2470
  };
2431
2471
  return {
2432
- withOwnershipLease: (target, operation) => (!options.context.runtimeLeaseHeld
2433
- && target.identity.platform === 'codex'
2434
- && target.identity.scope === 'user'
2435
- && !materializeLeaseHeld.has(target)
2436
- ? withActiveMarketplaceRuntimeLease(options.context.env, operation)
2437
- : operation()),
2438
- withMaterializeLease: (target, operation) => {
2439
- if (!target.identity.sourceId)
2440
- return operation();
2441
- if (options.context.runtimeLeaseHeld && !options.context.lifecycleLeaseHeld) {
2442
- throw new Error('lockOrderViolation: namespaced materialization cannot acquire lifecycle after runtime.');
2443
- }
2444
- const runOperation = async () => {
2445
- const previousRuntimeHeld = options.context.runtimeLeaseHeld;
2446
- options.context.runtimeLeaseHeld = true;
2447
- materializeLeaseHeld.add(target);
2448
- try {
2449
- if (options.context.expectedCatalogConfigDigest) {
2450
- const current = await readCatalogSourcesConfigSnapshot(options.context.env);
2451
- if (current.digest !== options.context.expectedCatalogConfigDigest) {
2452
- throw new Error('catalogSourceConflict: catalog source config changed before owner publication.');
2453
- }
2454
- }
2455
- return await operation();
2456
- }
2457
- finally {
2458
- materializeLeaseHeld.delete(target);
2459
- options.context.runtimeLeaseHeld = previousRuntimeHeld;
2460
- }
2461
- };
2462
- const withRuntime = () => options.context.runtimeLeaseHeld
2463
- ? runOperation()
2464
- : withActiveMarketplaceRuntimeLease(options.context.env, runOperation);
2465
- if (options.context.lifecycleLeaseHeld)
2466
- return withRuntime();
2467
- return withActiveMarketplaceLifecycleLease(options.context.env, async () => {
2468
- const previousLifecycleHeld = options.context.lifecycleLeaseHeld;
2469
- options.context.lifecycleLeaseHeld = true;
2470
- try {
2471
- return await withRuntime();
2472
- }
2473
- finally {
2474
- options.context.lifecycleLeaseHeld = previousLifecycleHeld;
2475
- }
2476
- });
2477
- },
2478
2472
  preflightMaterialize: async (target) => {
2473
+ if (target.identity.sourceId && options.context.expectedCatalogConfigDigest) {
2474
+ const current = await readCatalogSourcesConfigSnapshot(options.context.env);
2475
+ if (current.digest !== options.context.expectedCatalogConfigDigest) {
2476
+ throw new Error('catalogSourceConflict: catalog source config changed before owner publication.');
2477
+ }
2478
+ }
2479
2479
  if (target.identity.platform === 'claude') {
2480
2480
  await assertNoClaudeUnboundNativeNameCollision({
2481
2481
  pluginName: target.identity.pluginName,
@@ -2596,7 +2596,12 @@ function createNativeDriver(options) {
2596
2596
  }
2597
2597
  if (before.state === 'absent')
2598
2598
  return;
2599
- await runNativeCliChecked(buildCodexPluginRemoveInvocation(component.pluginId, target.identity.cwd, options.context.env), runner);
2599
+ try {
2600
+ await runNativeCliChecked(buildCodexPluginRemoveInvocation(requireCodexManager(codexManager), component.pluginId, target.identity.cwd, options.context.env), runner);
2601
+ }
2602
+ catch {
2603
+ throw new Error(`codexNativeRemoveFailed: ${CODEX_REMOVE_RECOVERY}`);
2604
+ }
2600
2605
  const residue = await inspectCodexNativeResidue({
2601
2606
  pluginName: target.identity.pluginName,
2602
2607
  cwd: target.identity.cwd,
@@ -2605,7 +2610,7 @@ function createNativeDriver(options) {
2605
2610
  marketplaceRoot: target.identity.marketplaceRoot,
2606
2611
  });
2607
2612
  if (residue.state !== 'absent') {
2608
- throw new Error(`Codex native remove 后仍有残留:${residue.labels.join(',')}`);
2613
+ throw new Error(`codexNativeRemoveIncomplete: ${CODEX_REMOVE_RECOVERY}`);
2609
2614
  }
2610
2615
  }
2611
2616
  else {
@@ -2688,11 +2693,11 @@ function createNativeDriver(options) {
2688
2693
  const config = await readCodexConfigFile(resolveCodexPaths(target.identity.cwd, 'user', options.context.env).configTomlPath);
2689
2694
  const marketplace = config.snapshot.marketplaces[marketplaceName];
2690
2695
  if (path.normalize(marketplace?.source ?? '') !== path.normalize(marketplaceRoot)) {
2691
- await runNativeCliChecked(buildCodexMarketplaceAddInvocation(marketplaceRoot, target.identity.cwd, options.context.env), runner);
2696
+ await runNativeCliChecked(buildCodexMarketplaceAddInvocation(requireCodexManager(codexManager), marketplaceRoot, target.identity.cwd, options.context.env), runner);
2692
2697
  }
2693
- await runNativeCliChecked(buildCodexMarketplaceListInvocation(target.identity.cwd, options.context.env), runner);
2694
- await runNativeCliChecked(buildCodexPluginAddInvocation(pluginId, target.identity.cwd, options.context.env), runner);
2695
- await runNativeCliChecked(buildCodexPluginListInvocation(target.identity.cwd, options.context.env), runner);
2698
+ await runNativeCliChecked(buildCodexMarketplaceListInvocation(requireCodexManager(codexManager), target.identity.cwd, options.context.env), runner);
2699
+ await runNativeCliChecked(buildCodexPluginAddInvocation(requireCodexManager(codexManager), pluginId, target.identity.cwd, options.context.env), runner);
2700
+ await runNativeCliChecked(buildCodexPluginListInvocation(requireCodexManager(codexManager), target.identity.cwd, options.context.env), runner);
2696
2701
  await assertCodexNativeInstallState({
2697
2702
  pluginName: target.identity.pluginName,
2698
2703
  pluginVersion: target.identity.pluginVersion,
@@ -2741,11 +2746,7 @@ function createNativeDriver(options) {
2741
2746
  }
2742
2747
  }
2743
2748
  };
2744
- await (target.identity.sourceId
2745
- && !options.context.runtimeLeaseHeld
2746
- && !materializeLeaseHeld.has(target)
2747
- ? withActiveMarketplaceRuntimeLease(options.context.env, writeGeneration)
2748
- : writeGeneration());
2749
+ await writeGeneration();
2749
2750
  },
2750
2751
  writeArtifacts: async (target) => {
2751
2752
  const plan = options.plans.get(target);
@@ -2756,11 +2757,7 @@ function createNativeDriver(options) {
2756
2757
  await write.write();
2757
2758
  return plan.writes.map((write) => write.artifact);
2758
2759
  };
2759
- return !options.context.runtimeLeaseHeld
2760
- && !materializeLeaseHeld.has(target)
2761
- && target.identity.platform === 'codex' && target.identity.scope === 'user'
2762
- ? withActiveMarketplaceRuntimeLease(options.context.env, writeAll)
2763
- : writeAll();
2760
+ return writeAll();
2764
2761
  },
2765
2762
  runLifecycle: async (invocation) => {
2766
2763
  await runLifecycleScript({
@@ -2903,11 +2900,7 @@ export function createRebuildIntegration(options) {
2903
2900
  platform: input.platform,
2904
2901
  scope: input.scope,
2905
2902
  })));
2906
- const scannedSkills = (await (input.platform === 'codex'
2907
- && input.scope === 'user'
2908
- && input.readOnlyInspectionPlan !== true
2909
- ? withActiveMarketplaceRuntimeLease(options.context.env, scanSkills)
2910
- : scanSkills())).flat();
2903
+ const scannedSkills = (await scanSkills()).flat();
2911
2904
  const historicalComponents = await buildHistoricalComponents({
2912
2905
  sourceId: input.sourceId,
2913
2906
  sourceIdentity: input.sourceIdentity,
@@ -2941,7 +2934,8 @@ export function createRebuildIntegration(options) {
2941
2934
  });
2942
2935
  const nativeRequired = input.platform === 'claude'
2943
2936
  || (input.scope === 'user' && requiresCodexNativePlugin(input.plugin, input.scope));
2944
- const nativeCleanupCandidate = input.platform === 'claude' || input.scope === 'user';
2937
+ const nativeCleanupCandidate = (input.platform === 'claude' || input.scope === 'user')
2938
+ && input.includeNativeCleanupCandidate !== false;
2945
2939
  const nativePlugin = (nativeRequired || nativeCleanupCandidate)
2946
2940
  ? [{
2947
2941
  kind: 'native-plugin',
@@ -2955,6 +2949,7 @@ export function createRebuildIntegration(options) {
2955
2949
  const marketplace = input.platform === 'codex' && input.scope === 'user'
2956
2950
  ? [createCodexMarketplaceComponent({
2957
2951
  pluginName: input.plugin.manifest.name,
2952
+ codexManager: options.context.codexManager,
2958
2953
  cwd: input.cwd,
2959
2954
  env: options.context.env,
2960
2955
  runner: options.context.nativeCliRunner,