Skip to content

Add registry functions that return raw schema information #21

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

corymhall
Copy link

@corymhall corymhall commented Jun 13, 2025

This PR updates the get-resource function to return the JSON schema instead of a formatted string.
It also adds a new function get-type to return information on a specific type.

fixes #20

return {
description: 'Returns information about Pulumi Registry resources', // Consider making this more specific, e.g., "Resource not found"
content: [
{
type: 'text' as const,
text: `No information found for ${args.resource}${args.module ? ` in module ${args.module}` : ''}. Available resources: ${availableResources.join(', ')}` // Slightly improved message
text: `No information found for ${args.resource}${args.module ? ` in module ${args.module}` : ''}. You can call list-resources to get a list of resources` // Slightly improved message
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to just let the LLM decide to call list-resources? It may even have already called list-resources. I've been running into a lot of context exceeded issues so have been trying to limit it.

@@ -51,8 +86,44 @@ export const registryCommands = function (cacheDir: string) {
}

return {
'get-type': {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is pretty low-level because it requires knowledge of the specific $ref. The idea is that it would have already called get-resource which would contain the $ref.

Another option would be to either add a separate function or update this one to also be more generic and take

{
  provider: string,
  module: string,
  propertyName?: string,
  ref?: string,
}

So then it could try and find the type if it only knew the property name (which it would know from looking at code).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this tool have the same arguments as get-resource - provider, version, module, name? Or what's the difference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should definitely have version, i'll add that.

For the others, that's what I was asking about. If get-resource returns something like

"inputProperties": {
    "nestedProp": {
        "type": "object",
        "$ref": "#/types/provider:module/SomeType:SomeType"
    }
}

Then the LLM would have the exact type token to call get-type.

The question is whether there is a use case for calling get-type on it's own. For example if the LLM were evaluating some code:

new aws.s3.Bucket('my-bucket', {
  acl: 'read',
});

It could potentially call just get-type with

{
  "provider": "aws",
  "module": "s3",
  "name": "acl"
}

But that has very limited usefulness. The LLM would probably want to see all the properties on Bucket so would probably need to call get-resource anyway. Also if the type returned had any nested types then it would need to call get-type for those as well.

@corymhall corymhall marked this pull request as ready for review June 20, 2025 13:43
@corymhall corymhall requested a review from mikhailshilkov June 20, 2025 13:43
@corymhall
Copy link
Author

text: JSON.stringify({
// for now leaving out:
// - `description`: Can be pretty large and contains all language examples (if we knew the language we could extract the specific language example)
// - `properties`: contains a lot of duplicated properties with `inputProperties` and is probably less useful
Copy link
Member

@mikhailshilkov mikhailshilkov Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

properties may be important to read the right resource outputs. Should we filter out the inputProperties keys from properties and return the remaining set?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

/**
* A type with additional properties
*/
additionalProperties?: ResourcePropertyItems;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to define all these properties? Won't we just serialize whatever properties we read from the schema as-is?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, i'll remove

@@ -51,8 +86,44 @@ export const registryCommands = function (cacheDir: string) {
}

return {
'get-type': {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this tool have the same arguments as get-resource - provider, version, module, name? Or what's the difference?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New registry functions that return raw schema information
2 participants