Skip to content

feat: Add api example in new abi module creation#787

Merged
Dr0p42 merged 1 commit into
mainfrom
abi-cli-new-project
Mar 3, 2026
Merged

feat: Add api example in new abi module creation#787
Dr0p42 merged 1 commit into
mainfrom
abi-cli-new-project

Conversation

@Dr0p42

@Dr0p42 Dr0p42 commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extend the module scaffold template to include an optional api(self, app: FastAPI) -> None hook.
  • Add FastAPI import in the template so generated modules can expose API wiring points out of the box.
  • Include inline examples showing how to attach services to app.state and how to mount module routes/app factories.

Why

  • Makes new modules API-ready by default without forcing implementation.
  • Reduces friction for developers who want to expose HTTP endpoints from a generated module.
  • Aligns generated module structure with the existing BaseModule.api(...) extension point.

Notes

  • No behavioral change for existing modules.
  • The default implementation remains a no-op (pass) until overridden by the module author.

Note

Low Risk
Low risk: only updates the module scaffold template used by naas-abi-cli, adding an optional no-op method and import with no runtime behavior changes unless newly generated modules override it.

Overview
New modules generated from the naas-abi-cli template are now API-ready by default: the scaffold imports FastAPI and includes an optional ABIModule.api(self, app: FastAPI) hook.

The new api method is a no-op with inline examples showing how to attach engine services to app.state and how to mount module routes/app factories when a module chooses to expose HTTP endpoints.

Written by Cursor Bugbot for commit 735931e. This will update automatically on new commits. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Free Tier Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@@ -1,3 +1,4 @@
from fastapi import FastAPI

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unconditional Import for Optional API Hook

Low Severity

from fastapi import FastAPI is an unconditional top-level import in the template, while every other optional import (ObjectStorageService, Secret, TripleStoreService, VectorStoreService) is commented out. The api method it supports is explicitly documented as optional, yet the import it depends on is always active. This breaks the template's established convention: optional capabilities are shown as commented examples that developers uncomment when needed. As a result, every generated module carries a live fastapi import regardless of whether the author ever uses the API hook.

Additional Locations (1)

Fix in Cursor Fix in Web

@Dr0p42 Dr0p42 merged commit 5c30cbb into main Mar 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant