Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions inc/Engine/Bundle/AgentBundleArtifactDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function package_artifact_type( string $type ): string {

public static function bundle_artifact_type( string $type ): string {
if ( str_starts_with( $type, 'datamachine-extension/' ) ) {
return substr( $type, strlen( 'datamachine-extension/' ) );
return self::normalize_artifact_type( substr( $type, strlen( 'datamachine-extension/' ) ) );
}

foreach ( self::file_artifacts() as $definition ) {
Expand All @@ -80,9 +80,14 @@ public static function bundle_artifact_type( string $type ): string {
}
}

$type = self::normalize_artifact_type( $type );
if ( str_contains( $type, '/' ) && ! str_starts_with( $type, 'datamachine/' ) ) {
return $type;
}

$type = str_starts_with( $type, 'datamachine/' ) ? substr( $type, strlen( 'datamachine/' ) ) : $type;

return str_replace( '-', '_', self::normalize_artifact_type( $type ) );
return str_replace( '-', '_', $type );
}

public static function artifact_id_from_payload( mixed $payload, string $relative_path ): string {
Expand Down
4 changes: 4 additions & 0 deletions tests/agent-bundle-extension-artifacts-smoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function extension_json_encode( array $value ): string {
static function ( array $types ): array {
$types[] = 'fake_plugin_artifact';
$types[] = 'intelligence/wiki-brain';
$types[] = 'datamachine-code/workspace_preload';
return $types;
},
10,
Expand Down Expand Up @@ -221,6 +222,7 @@ static function ( $result, array $artifact, array $agent, array $context ) use (
$types = DataMachine\Engine\Bundle\BundleSchema::artifact_types();
assert_extension_bundle( 'fake plugin type is registered', in_array( 'fake_plugin_artifact', $types, true ) );
assert_extension_bundle( 'namespaced plugin type is registered', in_array( 'intelligence/wiki-brain', $types, true ) );
assert_extension_bundle( 'hyphenated namespaced plugin type is registered', in_array( 'datamachine-code/workspace_preload', $types, true ) );

$agent = array( 'agent_id' => 7, 'agent_slug' => 'bundle-agent' );
$export_artifacts = AgentBundleArtifactExtensions::export_artifacts( $agent, array( 'phase' => 'export' ) );
Expand Down Expand Up @@ -278,6 +280,8 @@ static function ( $result, array $artifact, array $agent, array $context ) use (
echo "\n[3] Planner treats plugin artifacts like core artifacts and redacts secrets\n";
$target_artifact = extension_artifact( 'seed', array( 'label' => 'Target', 'api_token' => 'target-secret-token' ) );
$installed = AgentBundleInstalledArtifact::from_installed_payload( $manifest, 'fake_plugin_artifact', 'seed', 'extensions/fake-plugin/seed.json', $export_artifacts[0]['payload'], '2026-04-28T00:00:00Z' );
$hyphenated = AgentBundleInstalledArtifact::from_installed_payload( $manifest, 'datamachine-code/workspace_preload', 'repos', 'extensions/datamachine-code/workspace_preload/repos.json', array( 'repositories' => array() ), '2026-04-28T00:00:00Z' );
assert_extension_bundle_equals( 'hyphenated namespaced installed artifact type is preserved', 'datamachine-code/workspace_preload', $hyphenated->to_array()['artifact_type'] ?? null );
$current_payload = $export_artifacts[0]['payload'];
$clean_plan = AgentBundleUpgradePlanner::plan( array( $installed ), AgentBundleArtifactExtensions::current_artifacts( $agent, array( $installed->to_array() ) ), array( $target_artifact ) )->to_array();
assert_extension_bundle_equals( 'clean installed plugin artifact auto-applies', 'fake_plugin_artifact:seed', $clean_plan['auto_apply'][0]['artifact_key'] ?? null );
Expand Down
Loading