@lesliechan721/aw 0.1.0-beta.58 → 0.1.0-beta.60

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 (79) hide show
  1. package/dist/authoring/scripts/lib/plugin-version-check.mjs +1 -1
  2. package/dist/authoring/scripts/validate-plugin.mjs +22 -4
  3. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  4. package/dist/native-runtime/reader-runtime.mjs +34 -0
  5. package/dist/native-runtime/reader.d.mts +6 -0
  6. package/dist/native-runtime/reader.mjs +11 -0
  7. package/dist/scripts/bundle-plugins.js +4 -13
  8. package/dist/scripts/bundle-plugins.js.map +1 -1
  9. package/dist/scripts/test-plugin-scripts.d.ts +3 -0
  10. package/dist/scripts/test-plugin-scripts.js +89 -10
  11. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  12. package/dist/src/authoring/workspace-commands.d.ts +2 -0
  13. package/dist/src/authoring/workspace-commands.js +3 -1
  14. package/dist/src/authoring/workspace-commands.js.map +1 -1
  15. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  16. package/dist/src/commands/aw-capabilities.js +1 -0
  17. package/dist/src/commands/aw-capabilities.js.map +1 -1
  18. package/dist/src/commands/managed-commands.d.ts +2 -0
  19. package/dist/src/commands/managed-commands.js +41 -3
  20. package/dist/src/commands/managed-commands.js.map +1 -1
  21. package/dist/src/commands/operation-plan.d.ts +8 -1
  22. package/dist/src/commands/operation-plan.js.map +1 -1
  23. package/dist/src/commands/plugin-capabilities.js +13 -0
  24. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  25. package/dist/src/commands/rebuild-command.js +67 -21
  26. package/dist/src/commands/rebuild-command.js.map +1 -1
  27. package/dist/src/commands/rebuild-integration.js +33 -6
  28. package/dist/src/commands/rebuild-integration.js.map +1 -1
  29. package/dist/src/commands/runtime.js +3 -3
  30. package/dist/src/commands/runtime.js.map +1 -1
  31. package/dist/src/commands/sync-command.js +4 -0
  32. package/dist/src/commands/sync-command.js.map +1 -1
  33. package/dist/src/commands/write-commands.js +17 -8
  34. package/dist/src/commands/write-commands.js.map +1 -1
  35. package/dist/src/generators/local-plugin.js +10 -1
  36. package/dist/src/generators/local-plugin.js.map +1 -1
  37. package/dist/src/index.js +14 -4
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/output/command-receipt.d.ts +2 -0
  40. package/dist/src/output/command-receipt.js +5 -0
  41. package/dist/src/output/command-receipt.js.map +1 -1
  42. package/dist/src/portable/materializer.js +4 -0
  43. package/dist/src/portable/materializer.js.map +1 -1
  44. package/dist/src/review/skill-materialization.js +4 -0
  45. package/dist/src/review/skill-materialization.js.map +1 -1
  46. package/dist/src/tui/controller-runtime.js +7 -0
  47. package/dist/src/tui/controller-runtime.js.map +1 -1
  48. package/dist/src/tui/operation-review-planner.js +12 -1
  49. package/dist/src/tui/operation-review-planner.js.map +1 -1
  50. package/dist/src/utils/managed-command-materialization.d.ts +10 -1
  51. package/dist/src/utils/managed-command-materialization.js +56 -4
  52. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  53. package/dist/src/utils/managed-command-runtime.d.ts +10 -9
  54. package/dist/src/utils/managed-command-runtime.js +19 -8
  55. package/dist/src/utils/managed-command-runtime.js.map +1 -1
  56. package/dist/src/utils/managed-command-store.d.ts +6 -2
  57. package/dist/src/utils/managed-command-store.js +20 -7
  58. package/dist/src/utils/managed-command-store.js.map +1 -1
  59. package/dist/src/utils/native-cli.d.ts +6 -0
  60. package/dist/src/utils/native-cli.js +32 -6
  61. package/dist/src/utils/native-cli.js.map +1 -1
  62. package/dist/src/utils/native-tool-context.d.ts +14 -0
  63. package/dist/src/utils/native-tool-context.js +38 -0
  64. package/dist/src/utils/native-tool-context.js.map +1 -0
  65. package/dist/src/utils/native-tool-review.d.ts +21 -0
  66. package/dist/src/utils/native-tool-review.js +102 -0
  67. package/dist/src/utils/native-tool-review.js.map +1 -0
  68. package/dist/src/utils/plugin-config-write.js +30 -2
  69. package/dist/src/utils/plugin-config-write.js.map +1 -1
  70. package/dist/src/utils/plugin-scripts.js +14 -7
  71. package/dist/src/utils/plugin-scripts.js.map +1 -1
  72. package/dist/src/utils/process-lock.js +3 -1
  73. package/dist/src/utils/process-lock.js.map +1 -1
  74. package/dist/src/utils/process-tree.d.ts +2 -2
  75. package/dist/src/utils/process-tree.js +1 -1
  76. package/dist/src/utils/process-tree.js.map +1 -1
  77. package/dist/vitest.config.js +10 -1
  78. package/dist/vitest.config.js.map +1 -1
  79. package/package.json +8 -7
@@ -1,10 +1,12 @@
1
1
  import crypto from 'node:crypto';
2
+ import { captureNativeToolChanges } from '../utils/native-tool-review.js';
3
+ import { forceOfflineCleanupEvidence } from './offline-cleanup-evidence.js';
2
4
  import path from 'node:path';
3
5
  import fs from 'fs-extra';
4
6
  import { catalogFileMode } from '@lesliechan721/aw-plugin-core';
5
7
  import { COMMAND_PRODUCER_RECORD_FILE, getManagedCommandArtifactTargets, getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
6
8
  import os from 'node:os';
7
- import { commandSetsForProducer, createManagedCommandReferenceResolver, discoverRetainedManagedCommandPackages, retainedManagedCommandPackageResult, managedCommandProducerIdentity, prepareManagedCommandPackage, resolveSkillManagedCommandReferences, } from '../utils/managed-command-materialization.js';
9
+ import { injectNativeToolClosureFiles, nativeToolsForCommandSets, commandSetsForProducer, createManagedCommandReferenceResolver, discoverRetainedManagedCommandPackages, retainedManagedCommandPackageResult, managedCommandProducerIdentity, prepareManagedCommandPackage, resolveSkillManagedCommandReferences, } from '../utils/managed-command-materialization.js';
8
10
  import { assertManagedCommandBindingIdentities, normalizeInstalledCommandProducer, managedCommandDiagnostic, ManagedCommandError, publishManagedCommandBindings, revokeManagedCommandBindings, syncManagedCommandPackage, readInstalledCommandProducer, listManagedCommands } from '../utils/managed-command-store.js';
9
11
  import { injectInstalledRuntimeConfig, carryRuntimeConfigNativeReceipt } from '../utils/runtime-config.js';
10
12
  import { resolveCodexSkillsRelativeRoot } from '../utils/codex-skills-root.js';
@@ -142,7 +144,7 @@ async function commandPackageActions(options) {
142
144
  }
143
145
  await visit(prepared.resourceRoot, '');
144
146
  files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
145
- return { action: { kind: 'syncManagedCommandPackage', pluginId: pluginActionId(options.plugin), scope: declaration.scope, producer: prepared.producer, sets: prepared.sets, files, contentDigest: `sha256:${crypto.createHash('sha256').update(JSON.stringify(files)).digest('hex')}` }, candidate: { producer: prepared.producer, sets: prepared.sets } };
147
+ return { action: { kind: 'syncManagedCommandPackage', pluginId: pluginActionId(options.plugin), scope: declaration.scope, producer: prepared.producer, sets: prepared.sets, nativeTools: prepared.nativeTools, files, contentDigest: `sha256:${crypto.createHash('sha256').update(JSON.stringify(files)).digest('hex')}` }, candidate: { producer: prepared.producer, sets: prepared.sets, nativeTools: prepared.nativeTools } };
146
148
  }
147
149
  finally {
148
150
  await prepared.cleanup();
@@ -172,8 +174,9 @@ async function prepareSkillCommandCandidate(options) {
172
174
  if (process.platform !== 'win32' && entry.runner === 'executable' && options.tree.fileModes?.[entry.entry] !== 0o755)
173
175
  throw new Error(`commandRunnerUnsupported: command entry ${entry.entry} has no executable source file.`);
174
176
  }
175
- options.tree.files[COMMAND_PRODUCER_RECORD_FILE] = Buffer.from(`${JSON.stringify({ schemaVersion: 1, producer, sets }, null, 2)}\n`);
176
- return { producer, sets };
177
+ const nativeTools = injectNativeToolClosureFiles(options.tree.files, await nativeToolsForCommandSets(options.plugin, sets));
178
+ options.tree.files[COMMAND_PRODUCER_RECORD_FILE] = Buffer.from(`${JSON.stringify({ schemaVersion: 1, producer, sets, ...(nativeTools ? { nativeTools } : {}) }, null, 2)}\n`);
179
+ return { producer, sets, nativeTools };
177
180
  }
178
181
  async function prepareStaticNativeSkillActions(options) {
179
182
  if (!options.plugin.manifest.skills)
@@ -3542,7 +3545,7 @@ function createNativeDriver(options) {
3542
3545
  for (const target of targets)
3543
3546
  for (const action of target.operationActions ?? []) {
3544
3547
  if (action.kind === 'syncManagedCommandPackage') {
3545
- producers.push({ producer: action.producer, sets: action.sets });
3548
+ producers.push({ producer: action.producer, sets: action.sets, nativeTools: action.nativeTools });
3546
3549
  }
3547
3550
  else if (action.kind === 'materializeNativeSkill'
3548
3551
  || (action.kind === 'writeOwnedArtifact' && action.artifactKind === 'skill-directory')) {
@@ -3597,7 +3600,7 @@ function createNativeDriver(options) {
3597
3600
  await fs.outputFile(destination, content);
3598
3601
  await fs.chmod(destination, file.mode);
3599
3602
  }
3600
- const result = await syncManagedCommandPackage({ producer: action.producer, sourceDirectory: resourceRoot, sets: action.sets, env: options.context.env });
3603
+ const result = await syncManagedCommandPackage({ producer: action.producer, sourceDirectory: resourceRoot, sets: action.sets, nativeTools: action.nativeTools, env: options.context.env });
3601
3604
  await options.context.reporter.event({ type: 'managed-command:producer', source: { plugin: action.producer.pluginName, scope: action.producer.scope }, data: { packageKey: action.producer.key, phase: 'success' } });
3602
3605
  return { producer: action.producer, state: 'completed', commandIds: result.commandIds, removedCommandIds: result.removedCommandIds, errors: [], recoveryActions: [] };
3603
3606
  }
@@ -4975,6 +4978,30 @@ export function createRebuildIntegration(options) {
4975
4978
  ...(write.additionalActions ?? []),
4976
4979
  ]));
4977
4980
  finalizeOwnedArtifactActions(operationActions);
4981
+ const removed = input.command === 'cleanup' || input.command === 'uninstall';
4982
+ if (input.readOnlyInspectionPlan !== true && (removed || operationActions.length > 0)) {
4983
+ let skillComponents = allComponents.filter((component) => component.kind === 'skill-directory');
4984
+ if (removed && skillComponents.length > 0) {
4985
+ const inspection = await inspectOwnedComponents({ components: skillComponents, executor: driver.ownership });
4986
+ skillComponents = inspection.components.flatMap((entry) => entry.state === 'present' && entry.component.kind === 'skill-directory' ? [entry.component] : []);
4987
+ }
4988
+ const nativeToolChanges = await captureNativeToolChanges({ actions: operationActions, sourceId: input.sourceId,
4989
+ pluginName: input.plugin.manifest.name, platform: input.platform, scope: input.scope, projectRoot: input.cwd,
4990
+ removed, env: options.context.env, resourceRoots: skillComponents.map((component) => component.path) });
4991
+ if (nativeToolChanges.length > 0 && removed && operationActions.length === 0) {
4992
+ // Ordinary owned Skill removal can have no renderer action. Reuse the
4993
+ // existing owner/path evidence so its native impact enters Review.
4994
+ const evidence = await forceOfflineCleanupEvidence({ reason: 'bundleUnavailable',
4995
+ pluginId: input.pluginId ?? pluginActionId(input.plugin), pluginName: input.plugin.manifest.name,
4996
+ sourceId: input.sourceId, sourceIdentity: input.sourceIdentity, platform: input.platform, scope: input.scope,
4997
+ components: skillComponents });
4998
+ operationActions.push(...evidence.plan.actions.map((action) => ({ kind: 'removeOwnedArtifact',
4999
+ pluginId: evidence.pluginId, platform: input.platform, scope: input.scope,
5000
+ path: action.target, ownerFingerprint: evidence.targetFingerprint })));
5001
+ }
5002
+ if (nativeToolChanges.length > 0)
5003
+ operationActions[0].nativeToolChanges = nativeToolChanges;
5004
+ }
4978
5005
  const target = {
4979
5006
  plugin: input.plugin,
4980
5007
  identity: {