glirastes 0.2.1 → 0.3.1
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.
- package/CHANGELOG.md +96 -0
- package/CODE_OF_CONDUCT.md +85 -0
- package/CONTRIBUTING.md +87 -0
- package/README.md +268 -23
- package/SECURITY.md +46 -0
- package/codegen/package.json +5 -0
- package/dist/cjs/codegen/asset-sync.d.ts +20 -0
- package/dist/cjs/codegen/asset-sync.js +28 -0
- package/dist/cjs/codegen/coverage.d.ts +66 -0
- package/dist/cjs/codegen/coverage.js +408 -0
- package/dist/cjs/codegen/endpoint-scanner.d.ts +16 -0
- package/dist/cjs/codegen/endpoint-scanner.js +197 -0
- package/dist/cjs/codegen/format.d.ts +17 -0
- package/dist/cjs/codegen/format.js +34 -0
- package/dist/cjs/codegen/fs-utils.d.ts +45 -0
- package/dist/cjs/codegen/fs-utils.js +165 -0
- package/dist/cjs/codegen/index.d.ts +13 -0
- package/dist/cjs/codegen/index.js +33 -0
- package/dist/cjs/codegen/mcp-generator.d.ts +50 -0
- package/dist/cjs/codegen/mcp-generator.js +803 -0
- package/dist/cjs/codegen/module-generator.d.ts +11 -0
- package/dist/cjs/codegen/module-generator.js +353 -0
- package/dist/cjs/codegen/nestjs-scanner.d.ts +43 -0
- package/dist/cjs/codegen/nestjs-scanner.js +241 -0
- package/dist/cjs/codegen/output-recommender.d.ts +23 -0
- package/dist/cjs/codegen/output-recommender.js +33 -0
- package/dist/cjs/codegen/scaffolder.d.ts +36 -0
- package/dist/cjs/codegen/scaffolder.js +262 -0
- package/dist/cjs/codegen/skill-generator.d.ts +49 -0
- package/dist/cjs/codegen/skill-generator.js +967 -0
- package/dist/cjs/codegen/types.d.ts +52 -0
- package/dist/cjs/codegen/types.js +16 -0
- package/dist/cjs/codegen/ui-scanner.d.ts +24 -0
- package/dist/cjs/codegen/ui-scanner.js +202 -0
- package/dist/cjs/codegen/validator.d.ts +35 -0
- package/dist/cjs/codegen/validator.js +292 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/openapi/index.d.ts +78 -0
- package/dist/cjs/openapi/index.js +347 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/react/audio-worklet-processor.d.ts +16 -0
- package/dist/cjs/react/audio-worklet-processor.js +27 -0
- package/dist/cjs/react/bridges/rest-session-bridge.d.ts +113 -0
- package/dist/cjs/react/bridges/rest-session-bridge.js +209 -0
- package/dist/cjs/react/components/ai-chat-panel.d.ts +12 -0
- package/dist/cjs/react/components/ai-chat-panel.js +67 -0
- package/dist/cjs/react/components/ai-trigger-button.d.ts +2 -0
- package/dist/cjs/react/components/ai-trigger-button.js +239 -0
- package/dist/cjs/react/components/approval-card.d.ts +9 -0
- package/dist/cjs/react/components/approval-card.js +24 -0
- package/dist/cjs/react/components/bulk-approval-card.d.ts +9 -0
- package/dist/cjs/react/components/bulk-approval-card.js +36 -0
- package/dist/cjs/react/components/chat-input.d.ts +10 -0
- package/dist/cjs/react/components/chat-input.js +60 -0
- package/dist/cjs/react/components/chat-window.d.ts +2 -0
- package/dist/cjs/react/components/chat-window.js +134 -0
- package/dist/cjs/react/components/confirm-dialog.d.ts +32 -0
- package/dist/cjs/react/components/confirm-dialog.js +48 -0
- package/dist/cjs/react/components/floating-chat-ui.d.ts +90 -0
- package/dist/cjs/react/components/floating-chat-ui.js +163 -0
- package/dist/cjs/react/components/mention-chip.d.ts +16 -0
- package/dist/cjs/react/components/mention-chip.js +42 -0
- package/dist/cjs/react/components/mention-input.d.ts +8 -0
- package/dist/cjs/react/components/mention-input.js +117 -0
- package/dist/cjs/react/components/message-bubble.d.ts +11 -0
- package/dist/cjs/react/components/message-bubble.js +171 -0
- package/dist/cjs/react/components/message-list.d.ts +8 -0
- package/dist/cjs/react/components/message-list.js +52 -0
- package/dist/cjs/react/components/pipeline-timeline.d.ts +7 -0
- package/dist/cjs/react/components/pipeline-timeline.js +72 -0
- package/dist/cjs/react/components/recording-bar.d.ts +2 -0
- package/dist/cjs/react/components/recording-bar.js +81 -0
- package/dist/cjs/react/components/recording-controls.d.ts +18 -0
- package/dist/cjs/react/components/recording-controls.js +38 -0
- package/dist/cjs/react/components/rich-mention-input.d.ts +2 -0
- package/dist/cjs/react/components/rich-mention-input.js +571 -0
- package/dist/cjs/react/components/session-switcher.d.ts +14 -0
- package/dist/cjs/react/components/session-switcher.js +133 -0
- package/dist/cjs/react/components/suggestion-bar.d.ts +9 -0
- package/dist/cjs/react/components/suggestion-bar.js +47 -0
- package/dist/cjs/react/components/suggestion-chip.d.ts +9 -0
- package/dist/cjs/react/components/suggestion-chip.js +14 -0
- package/dist/cjs/react/components/voice-input-addon.d.ts +13 -0
- package/dist/cjs/react/components/voice-input-addon.js +31 -0
- package/dist/cjs/react/components/voice-input-button.d.ts +2 -0
- package/dist/cjs/react/components/voice-input-button.js +55 -0
- package/dist/cjs/react/components/wavesurfer-loader.d.ts +5 -0
- package/dist/cjs/react/components/wavesurfer-loader.js +36 -0
- package/dist/cjs/react/hooks/use-ai-chat.d.ts +22 -0
- package/dist/cjs/react/hooks/use-ai-chat.js +51 -0
- package/dist/cjs/react/hooks/use-approvals.d.ts +23 -0
- package/dist/cjs/react/hooks/use-approvals.js +63 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +2 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.js +329 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +48 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.js +308 -0
- package/dist/cjs/react/hooks/use-draggable-position.d.ts +25 -0
- package/dist/cjs/react/hooks/use-draggable-position.js +134 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.d.ts +20 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.js +93 -0
- package/dist/cjs/react/hooks/use-mentions.d.ts +23 -0
- package/dist/cjs/react/hooks/use-mentions.js +42 -0
- package/dist/cjs/react/hooks/use-suggestions.d.ts +22 -0
- package/dist/cjs/react/hooks/use-suggestions.js +39 -0
- package/dist/cjs/react/index.d.ts +43 -0
- package/dist/cjs/react/index.js +111 -0
- package/dist/cjs/react/provider/ai-chat-provider.d.ts +45 -0
- package/dist/cjs/react/provider/ai-chat-provider.js +1024 -0
- package/dist/cjs/react/provider/chat-context.d.ts +84 -0
- package/dist/cjs/react/provider/chat-context.js +13 -0
- package/dist/cjs/react/template.d.ts +84 -0
- package/dist/cjs/react/template.js +90 -0
- package/dist/cjs/react/themes.d.ts +24 -0
- package/dist/cjs/react/themes.js +273 -0
- package/dist/cjs/react/transports/langgraph/index.d.ts +2 -0
- package/dist/cjs/react/transports/langgraph/index.js +8 -0
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +62 -0
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +94 -0
- package/dist/cjs/react/transports/langgraph.d.ts +71 -0
- package/dist/cjs/react/transports/langgraph.js +369 -0
- package/dist/cjs/react/transports/vercel/index.d.ts +2 -0
- package/dist/cjs/react/transports/vercel/index.js +8 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +49 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +81 -0
- package/dist/cjs/react/transports/vercel.d.ts +30 -0
- package/dist/cjs/react/transports/vercel.js +69 -0
- package/dist/cjs/react/types.d.ts +760 -0
- package/dist/cjs/react/types.js +2 -0
- package/dist/cjs/react/ui.d.ts +73 -0
- package/dist/cjs/react/ui.js +183 -0
- package/dist/cjs/react/utils/create-approval-description.d.ts +53 -0
- package/dist/cjs/react/utils/create-approval-description.js +122 -0
- package/dist/cjs/react/utils/create-tool-result-handler.d.ts +90 -0
- package/dist/cjs/react/utils/create-tool-result-handler.js +168 -0
- package/dist/cjs/react/utils/mention-markup.d.ts +13 -0
- package/dist/cjs/react/utils/mention-markup.js +117 -0
- package/dist/cjs/react/utils/merge-pipeline-steps.d.ts +19 -0
- package/dist/cjs/react/utils/merge-pipeline-steps.js +81 -0
- package/dist/cjs/react/utils/sanitize-stored-messages.d.ts +23 -0
- package/dist/cjs/react/utils/sanitize-stored-messages.js +52 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +10 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +42 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +32 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +4 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +11 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +80 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +119 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +13 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +131 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +7 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +52 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +19 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +108 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +8 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +59 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +3 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +3 -0
- package/dist/cjs/server/adapters/nestjs/chat/index.js +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +4 -0
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +73 -0
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +72 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +6 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +13 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +5 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +15 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +6 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +22 -0
- package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +4 -0
- package/dist/cjs/server/adapters/nestjs/decorators/constants.js +7 -0
- package/dist/cjs/server/adapters/nestjs/index.d.ts +14 -0
- package/dist/cjs/server/adapters/nestjs/index.js +42 -0
- package/dist/cjs/server/adapters/nestjs/metadata.d.ts +39 -0
- package/dist/cjs/server/adapters/nestjs/metadata.js +36 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +36 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +159 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +37 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +44 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +28 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +41 -0
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +16 -0
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +117 -0
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +26 -0
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +259 -0
- package/dist/cjs/server/adapters/nestjs/swagger.d.ts +7 -0
- package/dist/cjs/server/adapters/nestjs/swagger.js +39 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +22 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.js +60 -0
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +94 -0
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +965 -0
- package/dist/cjs/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
- package/dist/cjs/server/adapters/nextjs/filter-fallback-error.js +41 -0
- package/dist/cjs/server/adapters/nextjs/index.d.ts +8 -0
- package/dist/cjs/server/adapters/nextjs/index.js +22 -0
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +58 -0
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +114 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.d.ts +64 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +489 -0
- package/dist/cjs/server/adapters/nextjs/server-action-helper.d.ts +7 -0
- package/dist/cjs/server/adapters/nextjs/server-action-helper.js +40 -0
- package/dist/cjs/server/adapters/nextjs/types.d.ts +246 -0
- package/dist/cjs/server/adapters/nextjs/types.js +2 -0
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +9 -0
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.js +12 -0
- package/dist/cjs/server/core/followup-tool.d.ts +9 -0
- package/dist/cjs/server/core/followup-tool.js +82 -0
- package/dist/cjs/server/core/index.d.ts +139 -0
- package/dist/cjs/server/core/index.js +818 -0
- package/dist/cjs/server/core/intent-classifier.d.ts +94 -0
- package/dist/cjs/server/core/intent-classifier.js +324 -0
- package/dist/cjs/server/core/model-selector.d.ts +12 -0
- package/dist/cjs/server/core/model-selector.js +48 -0
- package/dist/cjs/server/core/module-router.d.ts +14 -0
- package/dist/cjs/server/core/module-router.js +110 -0
- package/dist/cjs/server/core/zod-compact.d.ts +18 -0
- package/dist/cjs/server/core/zod-compact.js +129 -0
- package/dist/cjs/server/index.d.ts +6 -0
- package/dist/cjs/server/index.js +28 -0
- package/dist/cjs/server/lancer/cache.d.ts +9 -0
- package/dist/cjs/server/lancer/cache.js +33 -0
- package/dist/cjs/server/lancer/client.d.ts +2 -0
- package/dist/cjs/server/lancer/client.js +279 -0
- package/dist/cjs/server/lancer/errors.d.ts +13 -0
- package/dist/cjs/server/lancer/errors.js +21 -0
- package/dist/cjs/server/lancer/index.d.ts +3 -0
- package/dist/cjs/server/lancer/index.js +7 -0
- package/dist/cjs/server/lancer/telemetry-buffer.d.ts +15 -0
- package/dist/cjs/server/lancer/telemetry-buffer.js +64 -0
- package/dist/cjs/server/lancer/types.d.ts +201 -0
- package/dist/cjs/server/lancer/types.js +5 -0
- package/dist/cjs/server/pii-shield/aegis-detector.d.ts +26 -0
- package/dist/cjs/server/pii-shield/aegis-detector.js +26 -0
- package/dist/cjs/server/pii-shield/create-pii-shield.d.ts +2 -0
- package/dist/cjs/server/pii-shield/create-pii-shield.js +191 -0
- package/dist/cjs/server/pii-shield/deep-walk.d.ts +1 -0
- package/dist/cjs/server/pii-shield/deep-walk.js +19 -0
- package/dist/cjs/server/pii-shield/fake-data.d.ts +5 -0
- package/dist/cjs/server/pii-shield/fake-data.js +170 -0
- package/dist/cjs/server/pii-shield/index.d.ts +4 -0
- package/dist/cjs/server/pii-shield/index.js +9 -0
- package/dist/cjs/server/pii-shield/leakage.d.ts +1 -0
- package/dist/cjs/server/pii-shield/leakage.js +15 -0
- package/dist/cjs/server/pii-shield/session-mapping.d.ts +12 -0
- package/dist/cjs/server/pii-shield/session-mapping.js +70 -0
- package/dist/cjs/server/pipeline.d.ts +26 -0
- package/dist/cjs/server/pipeline.js +127 -0
- package/dist/cjs/server/testing/approvals.d.ts +11 -0
- package/dist/cjs/server/testing/approvals.js +41 -0
- package/dist/cjs/server/testing/combination.d.ts +3 -0
- package/dist/cjs/server/testing/combination.js +83 -0
- package/dist/cjs/server/testing/create-test-suite.d.ts +29 -0
- package/dist/cjs/server/testing/create-test-suite.js +81 -0
- package/dist/cjs/server/testing/edge-cases.d.ts +8 -0
- package/dist/cjs/server/testing/edge-cases.js +277 -0
- package/dist/cjs/server/testing/guardrails.d.ts +14 -0
- package/dist/cjs/server/testing/guardrails.js +152 -0
- package/dist/cjs/server/testing/helpers.d.ts +14 -0
- package/dist/cjs/server/testing/helpers.js +119 -0
- package/dist/cjs/server/testing/index.d.ts +12 -0
- package/dist/cjs/server/testing/index.js +37 -0
- package/dist/cjs/server/testing/mock-executor.d.ts +8 -0
- package/dist/cjs/server/testing/mock-executor.js +40 -0
- package/dist/cjs/server/testing/regression.d.ts +7 -0
- package/dist/cjs/server/testing/regression.js +27 -0
- package/dist/cjs/server/testing/routing.d.ts +12 -0
- package/dist/cjs/server/testing/routing.js +63 -0
- package/dist/cjs/server/testing/schema-consistency.d.ts +6 -0
- package/dist/cjs/server/testing/schema-consistency.js +56 -0
- package/dist/cjs/server/testing/smoke.d.ts +11 -0
- package/dist/cjs/server/testing/smoke.js +64 -0
- package/dist/cjs/server/testing/types.d.ts +156 -0
- package/dist/cjs/server/testing/types.js +2 -0
- package/dist/cjs/types.d.ts +696 -0
- package/dist/cjs/types.js +91 -0
- package/dist/cli/commands/install-skills.d.ts +17 -0
- package/dist/cli/commands/install-skills.js +185 -0
- package/dist/cli/commands/install-skills.js.map +1 -0
- package/dist/cli/index.js +25 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/react/components/ai-trigger-button.js +4 -6
- package/dist/react/components/ai-trigger-button.js.map +1 -1
- package/dist/react/components/recording-bar.js +4 -6
- package/dist/react/components/recording-bar.js.map +1 -1
- package/dist/react/components/wavesurfer-loader.d.ts +5 -0
- package/dist/react/components/wavesurfer-loader.js +34 -0
- package/dist/react/components/wavesurfer-loader.js.map +1 -0
- package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +1 -1
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js +3 -2
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +1 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +1 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +10 -8
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +1 -1
- package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
- package/dist/server/adapters/nestjs/chat/ws-loader.js +37 -0
- package/dist/server/adapters/nestjs/chat/ws-loader.js.map +1 -0
- package/dist/server/adapters/nextjs/create-ai-chat-handler.d.ts +16 -0
- package/dist/server/adapters/nextjs/create-ai-chat-handler.js +14 -3
- package/dist/server/adapters/nextjs/create-ai-chat-handler.js.map +1 -1
- package/dist/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
- package/dist/server/adapters/nextjs/filter-fallback-error.js +38 -0
- package/dist/server/adapters/nextjs/filter-fallback-error.js.map +1 -0
- package/openapi/package.json +5 -0
- package/package.json +66 -21
- package/react/langgraph/package.json +5 -0
- package/react/package.json +5 -0
- package/react/vercel/package.json +5 -0
- package/server/nestjs/package.json +5 -0
- package/server/nextjs/package.json +5 -0
- package/server/package.json +5 -0
- package/server/testing/package.json +5 -0
- package/skills/README.md +107 -0
- package/skills/building-glirastes-chat-ui/SKILL.md +378 -0
- package/skills/integrating-glirastes-nestjs/SKILL.md +346 -0
- package/skills/integrating-glirastes-nextjs/SKILL.md +306 -0
- package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
- package/skills/maintaining-glirastes-tools/SKILL.md +463 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.scanEndpointTools = scanEndpointTools;
|
|
37
|
+
exports.generateEndpointRegistry = generateEndpointRegistry;
|
|
38
|
+
const promises_1 = require("node:fs/promises");
|
|
39
|
+
const node_path_1 = require("node:path");
|
|
40
|
+
const fs_utils_js_1 = require("./fs-utils.js");
|
|
41
|
+
const types_js_1 = require("./types.js");
|
|
42
|
+
/**
|
|
43
|
+
* Scan for endpoint tool files (ai-tool.ts) in the API directory.
|
|
44
|
+
* Also detects route.ts files using withAiTool() from glirastes/server/nextjs.
|
|
45
|
+
*/
|
|
46
|
+
async function scanEndpointTools(options) {
|
|
47
|
+
const opts = (0, types_js_1.resolveDefaults)(options);
|
|
48
|
+
const apiDir = (0, node_path_1.join)(opts.rootDir, opts.apiDir);
|
|
49
|
+
const files = await (0, fs_utils_js_1.findFiles)(apiDir, opts.endpointToolFileName);
|
|
50
|
+
const discovered = [];
|
|
51
|
+
const discoveredDirs = new Set();
|
|
52
|
+
// 1. Standard ai-tool.ts files
|
|
53
|
+
for (const absolutePath of files) {
|
|
54
|
+
const content = await (0, fs_utils_js_1.readFileSafe)(absolutePath);
|
|
55
|
+
if (content.includes('@ai-ignore'))
|
|
56
|
+
continue;
|
|
57
|
+
if (await (0, fs_utils_js_1.isDirAiIgnored)((0, node_path_1.dirname)(absolutePath)))
|
|
58
|
+
continue;
|
|
59
|
+
const hasArray = /export\s+const\s+aiTools\s*[=:]/m.test(content);
|
|
60
|
+
const hasSingle = /export\s+const\s+aiTool\s*[=:]/m.test(content);
|
|
61
|
+
if (!hasArray && !hasSingle)
|
|
62
|
+
continue;
|
|
63
|
+
discovered.push({
|
|
64
|
+
absolutePath,
|
|
65
|
+
relativePath: absolutePath.replace(opts.rootDir + '/', ''),
|
|
66
|
+
importPath: (0, fs_utils_js_1.toImportPath)(absolutePath, opts.rootDir),
|
|
67
|
+
exportType: hasArray ? 'array' : 'single',
|
|
68
|
+
});
|
|
69
|
+
discoveredDirs.add((0, node_path_1.dirname)(absolutePath));
|
|
70
|
+
}
|
|
71
|
+
// 2. route.ts files with withAiTool() (inline tool definitions)
|
|
72
|
+
const routeFiles = await (0, fs_utils_js_1.findRouteFiles)(apiDir);
|
|
73
|
+
for (const routeFile of routeFiles) {
|
|
74
|
+
const routeDir = (0, node_path_1.dirname)(routeFile);
|
|
75
|
+
if (discoveredDirs.has(routeDir))
|
|
76
|
+
continue; // Already has ai-tool.ts
|
|
77
|
+
const content = await (0, fs_utils_js_1.readFileSafe)(routeFile);
|
|
78
|
+
if (content.includes('@ai-ignore'))
|
|
79
|
+
continue;
|
|
80
|
+
if (await (0, fs_utils_js_1.isDirAiIgnored)(routeDir))
|
|
81
|
+
continue;
|
|
82
|
+
if (!content.includes('withAiTool('))
|
|
83
|
+
continue;
|
|
84
|
+
discovered.push({
|
|
85
|
+
absolutePath: routeFile,
|
|
86
|
+
relativePath: routeFile.replace(opts.rootDir + '/', ''),
|
|
87
|
+
importPath: (0, fs_utils_js_1.toImportPath)(routeFile, opts.rootDir),
|
|
88
|
+
exportType: 'single', // withAiTool wraps a single handler
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// Count tools (rough estimate: arrays have multiple, singles have 1)
|
|
92
|
+
let toolCount = 0;
|
|
93
|
+
for (const file of discovered) {
|
|
94
|
+
if (file.exportType === 'array') {
|
|
95
|
+
const content = await (0, fs_utils_js_1.readFileSafe)(file.absolutePath);
|
|
96
|
+
// Count defineEndpointTool or defineAiEndpointTool calls
|
|
97
|
+
const matches = content.match(/define(?:Ai)?EndpointTool\(/g);
|
|
98
|
+
toolCount += matches?.length ?? 1;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
toolCount += 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { files: discovered, toolCount };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Generate the endpoint tools registry file.
|
|
108
|
+
*
|
|
109
|
+
* Output: a TypeScript file that imports all discovered endpoint tools and
|
|
110
|
+
* combines them into a single registry via endpointToolsToRegistry().
|
|
111
|
+
*/
|
|
112
|
+
async function generateEndpointRegistry(options) {
|
|
113
|
+
const opts = (0, types_js_1.resolveDefaults)(options);
|
|
114
|
+
const scan = await scanEndpointTools(options);
|
|
115
|
+
// NestJS @AiTool decorated controllers
|
|
116
|
+
let nestTools = [];
|
|
117
|
+
if (opts.nestjsDirs.length > 0) {
|
|
118
|
+
const { scanNestControllers } = await Promise.resolve().then(() => __importStar(require('./nestjs-scanner.js')));
|
|
119
|
+
const nestResult = await scanNestControllers(opts.nestjsDirs, opts.nestjsApiPrefix);
|
|
120
|
+
nestTools = nestResult.tools;
|
|
121
|
+
}
|
|
122
|
+
const imports = [];
|
|
123
|
+
const spreadParts = [];
|
|
124
|
+
scan.files.forEach((file, index) => {
|
|
125
|
+
if (file.exportType === 'array') {
|
|
126
|
+
const alias = `endpointTools${index}`;
|
|
127
|
+
imports.push(`import { aiTools as ${alias} } from '${file.importPath}';`);
|
|
128
|
+
spreadParts.push(`...${alias}`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const alias = `endpointTool${index}`;
|
|
132
|
+
imports.push(`import { aiTool as ${alias} } from '${file.importPath}';`);
|
|
133
|
+
spreadParts.push(alias);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
// Generate inline defineEndpointTool() calls for NestJS tools
|
|
137
|
+
const nestInlineDefs = [];
|
|
138
|
+
const nestSpreadParts = [];
|
|
139
|
+
nestTools.forEach((tool, index) => {
|
|
140
|
+
const alias = `nestTool${index}`;
|
|
141
|
+
const desc = tool.description.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
142
|
+
// Build path param schema fields (e.g. { id: z.string() })
|
|
143
|
+
const paramFields = tool.pathParams.map(p => `${p}: z.string()`).join(', ');
|
|
144
|
+
const inputSchema = paramFields
|
|
145
|
+
? `z.object({ ${paramFields} }).passthrough()`
|
|
146
|
+
: 'z.object({}).passthrough()';
|
|
147
|
+
const lines = [
|
|
148
|
+
` id: '${tool.name}'`,
|
|
149
|
+
` toolName: '${tool.name}'`,
|
|
150
|
+
` description: '${desc}'`,
|
|
151
|
+
` path: '${tool.path}'`,
|
|
152
|
+
` method: '${tool.method}'`,
|
|
153
|
+
` inputSchema: ${inputSchema}`,
|
|
154
|
+
];
|
|
155
|
+
if (tool.module)
|
|
156
|
+
lines.push(` module: '${tool.module}'`);
|
|
157
|
+
if (tool.needsApproval !== undefined)
|
|
158
|
+
lines.push(` needsApproval: ${tool.needsApproval}`);
|
|
159
|
+
if (tool.allowedRoles && tool.allowedRoles.length > 0) {
|
|
160
|
+
lines.push(` allowedRoles: ${JSON.stringify(tool.allowedRoles)}`);
|
|
161
|
+
}
|
|
162
|
+
nestInlineDefs.push(`const ${alias} = defineEndpointTool({\n${lines.join(',\n')},\n});`);
|
|
163
|
+
nestSpreadParts.push(alias);
|
|
164
|
+
});
|
|
165
|
+
const allSpreadParts = [...spreadParts, ...nestSpreadParts];
|
|
166
|
+
const totalToolCount = scan.toolCount + nestTools.length;
|
|
167
|
+
const contractsImport = nestTools.length > 0
|
|
168
|
+
? `import { z } from 'zod';\nimport { defineEndpointTool } from 'glirastes';\n`
|
|
169
|
+
: '';
|
|
170
|
+
const nestInlineBlock = nestInlineDefs.length > 0
|
|
171
|
+
? `\n// From NestJS @AiTool decorators\n${nestInlineDefs.join('\n\n')}\n`
|
|
172
|
+
: '';
|
|
173
|
+
const code = `/* eslint-disable */
|
|
174
|
+
/**
|
|
175
|
+
* AUTO-GENERATED FILE — do not edit manually.
|
|
176
|
+
* Generated by glirastes
|
|
177
|
+
*
|
|
178
|
+
* Sources: ${scan.files.length} ai-tool.ts files, ${nestTools.length} NestJS @AiTool decorators
|
|
179
|
+
* Tools: ${totalToolCount}
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
${imports.join('\n')}
|
|
183
|
+
import { endpointToolsToRegistry } from 'glirastes/server';
|
|
184
|
+
${contractsImport}${nestInlineBlock}
|
|
185
|
+
const endpointTools = [${allSpreadParts.join(', ')}] as const;
|
|
186
|
+
|
|
187
|
+
export { endpointTools };
|
|
188
|
+
export const endpointToolRegistry = endpointToolsToRegistry(endpointTools);
|
|
189
|
+
`;
|
|
190
|
+
const outputPath = (0, node_path_1.join)(opts.rootDir, opts.outputDir, 'endpoint.generated.ts');
|
|
191
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(outputPath), { recursive: true });
|
|
192
|
+
await (0, promises_1.writeFile)(outputPath, code, 'utf-8');
|
|
193
|
+
if (!opts.quiet) {
|
|
194
|
+
console.log(`✓ Generated ${outputPath} (${totalToolCount} endpoint tools from ${scan.files.length} files + ${nestTools.length} NestJS controllers)`);
|
|
195
|
+
}
|
|
196
|
+
return { outputPath, toolCount: totalToolCount };
|
|
197
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ANSI color codes and formatting utilities for CLI output.
|
|
3
|
+
*/
|
|
4
|
+
export declare const colors: {
|
|
5
|
+
reset: string;
|
|
6
|
+
bold: string;
|
|
7
|
+
dim: string;
|
|
8
|
+
red: string;
|
|
9
|
+
green: string;
|
|
10
|
+
yellow: string;
|
|
11
|
+
blue: string;
|
|
12
|
+
cyan: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function separator(width?: number): string;
|
|
15
|
+
export declare function header(title: string): string;
|
|
16
|
+
export declare function sectionHeader(title: string, count: number, color: string): string;
|
|
17
|
+
export declare function metricLine(icon: string, iconColor: string, label: string, value: string | number, detail?: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared ANSI color codes and formatting utilities for CLI output.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.colors = void 0;
|
|
7
|
+
exports.separator = separator;
|
|
8
|
+
exports.header = header;
|
|
9
|
+
exports.sectionHeader = sectionHeader;
|
|
10
|
+
exports.metricLine = metricLine;
|
|
11
|
+
exports.colors = {
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
bold: '\x1b[1m',
|
|
14
|
+
dim: '\x1b[2m',
|
|
15
|
+
red: '\x1b[31m',
|
|
16
|
+
green: '\x1b[32m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
blue: '\x1b[34m',
|
|
19
|
+
cyan: '\x1b[36m',
|
|
20
|
+
};
|
|
21
|
+
function separator(width = 50) {
|
|
22
|
+
return `${exports.colors.dim}${'─'.repeat(width)}${exports.colors.reset}`;
|
|
23
|
+
}
|
|
24
|
+
function header(title) {
|
|
25
|
+
return `\n${exports.colors.blue}${exports.colors.bold}${title}${exports.colors.reset}\n\n${separator()}\n`;
|
|
26
|
+
}
|
|
27
|
+
function sectionHeader(title, count, color) {
|
|
28
|
+
return `${color}${exports.colors.bold}${title} (${count}):${exports.colors.reset}\n`;
|
|
29
|
+
}
|
|
30
|
+
function metricLine(icon, iconColor, label, value, detail) {
|
|
31
|
+
const paddedLabel = label.padEnd(35);
|
|
32
|
+
const detailStr = detail ? ` ${exports.colors.dim}(${detail})${exports.colors.reset}` : '';
|
|
33
|
+
return ` ${iconColor}${icon}${exports.colors.reset} ${paddedLabel}${exports.colors.bold}${value}${exports.colors.reset}${detailStr}`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively find all files matching a given name in a directory.
|
|
3
|
+
*/
|
|
4
|
+
export declare function findFiles(dir: string, fileName: string): Promise<string[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Check if a file contains the @ai-ignore marker.
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasAiIgnore(filePath: string): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a directory should be ignored for AI tool coverage.
|
|
11
|
+
* Checks for @ai-ignore in index.ts/index.tsx or .ai-ignore marker file.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isDirAiIgnored(dirPath: string): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Convert an absolute file path to a module import path.
|
|
16
|
+
* e.g., /project/src/app/api/tasks/ai-tool.ts → @/app/api/tasks/ai-tool
|
|
17
|
+
*/
|
|
18
|
+
export declare function toImportPath(absolutePath: string, rootDir: string, srcPrefix?: string, alias?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Convert an absolute file path to a relative import path from a given output directory.
|
|
21
|
+
* Used when source and output are in different parts of a monorepo where @/ aliases don't work.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toRelativeImportPath(absolutePath: string, outputDir: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Read file contents, returns empty string if file doesn't exist.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readFileSafe(filePath: string): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Find all route.ts files in a directory.
|
|
30
|
+
*/
|
|
31
|
+
export declare function findRouteFiles(dir: string): Promise<string[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Extract all top-level brace-balanced blocks for a given function call.
|
|
34
|
+
* Handles nested braces correctly (e.g., z.object({...}), uiAction: { payload: {...} }).
|
|
35
|
+
*
|
|
36
|
+
* @param content Source file content
|
|
37
|
+
* @param fnPattern Regex that matches the function call prefix up to (but not including) the opening `{`.
|
|
38
|
+
* Must NOT have the `g` flag — it is added internally.
|
|
39
|
+
* @returns Array of the inner content of each matched block (between the outermost `{` and `}`).
|
|
40
|
+
*/
|
|
41
|
+
export declare function extractBalancedBlocks(content: string, fnPattern: RegExp): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Get all immediate subdirectories of a directory.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getSubdirectories(dir: string): Promise<string[]>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFiles = findFiles;
|
|
4
|
+
exports.hasAiIgnore = hasAiIgnore;
|
|
5
|
+
exports.isDirAiIgnored = isDirAiIgnored;
|
|
6
|
+
exports.toImportPath = toImportPath;
|
|
7
|
+
exports.toRelativeImportPath = toRelativeImportPath;
|
|
8
|
+
exports.readFileSafe = readFileSafe;
|
|
9
|
+
exports.findRouteFiles = findRouteFiles;
|
|
10
|
+
exports.extractBalancedBlocks = extractBalancedBlocks;
|
|
11
|
+
exports.getSubdirectories = getSubdirectories;
|
|
12
|
+
const promises_1 = require("node:fs/promises");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
/**
|
|
15
|
+
* Recursively find all files matching a given name in a directory.
|
|
16
|
+
*/
|
|
17
|
+
async function findFiles(dir, fileName) {
|
|
18
|
+
const results = [];
|
|
19
|
+
async function walk(currentDir) {
|
|
20
|
+
let entries;
|
|
21
|
+
try {
|
|
22
|
+
entries = await (0, promises_1.readdir)(currentDir, { withFileTypes: true });
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return; // Directory doesn't exist or is inaccessible
|
|
26
|
+
}
|
|
27
|
+
for (const entry of entries) {
|
|
28
|
+
const fullPath = (0, node_path_1.join)(currentDir, entry.name);
|
|
29
|
+
if (entry.isDirectory()) {
|
|
30
|
+
if (entry.name === 'node_modules' || entry.name === '.git')
|
|
31
|
+
continue;
|
|
32
|
+
await walk(fullPath);
|
|
33
|
+
}
|
|
34
|
+
else if (entry.name === fileName) {
|
|
35
|
+
results.push(fullPath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
await walk(dir);
|
|
40
|
+
return results.sort();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if a file contains the @ai-ignore marker.
|
|
44
|
+
*/
|
|
45
|
+
async function hasAiIgnore(filePath) {
|
|
46
|
+
try {
|
|
47
|
+
const content = await (0, promises_1.readFile)(filePath, 'utf-8');
|
|
48
|
+
return content.includes('@ai-ignore');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if a directory should be ignored for AI tool coverage.
|
|
56
|
+
* Checks for @ai-ignore in index.ts/index.tsx or .ai-ignore marker file.
|
|
57
|
+
*/
|
|
58
|
+
async function isDirAiIgnored(dirPath) {
|
|
59
|
+
// Check for .ai-ignore marker file
|
|
60
|
+
try {
|
|
61
|
+
await (0, promises_1.stat)((0, node_path_1.join)(dirPath, '.ai-ignore'));
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Not found, continue
|
|
66
|
+
}
|
|
67
|
+
// Check for @ai-ignore in index.ts or index.tsx
|
|
68
|
+
for (const indexFile of ['index.ts', 'index.tsx']) {
|
|
69
|
+
const indexPath = (0, node_path_1.join)(dirPath, indexFile);
|
|
70
|
+
if (await hasAiIgnore(indexPath))
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Convert an absolute file path to a module import path.
|
|
77
|
+
* e.g., /project/src/app/api/tasks/ai-tool.ts → @/app/api/tasks/ai-tool
|
|
78
|
+
*/
|
|
79
|
+
function toImportPath(absolutePath, rootDir, srcPrefix = 'src', alias = '@') {
|
|
80
|
+
const rel = (0, node_path_1.relative)(rootDir, absolutePath);
|
|
81
|
+
// Remove src/ prefix and .ts extension
|
|
82
|
+
const withoutSrc = rel.startsWith(srcPrefix + node_path_1.sep)
|
|
83
|
+
? rel.slice(srcPrefix.length + 1)
|
|
84
|
+
: rel;
|
|
85
|
+
const withoutExt = withoutSrc.replace(/\.tsx?$/, '');
|
|
86
|
+
return `${alias}/${withoutExt.split(node_path_1.sep).join('/')}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Convert an absolute file path to a relative import path from a given output directory.
|
|
90
|
+
* Used when source and output are in different parts of a monorepo where @/ aliases don't work.
|
|
91
|
+
*/
|
|
92
|
+
function toRelativeImportPath(absolutePath, outputDir) {
|
|
93
|
+
const rel = (0, node_path_1.relative)(outputDir, absolutePath);
|
|
94
|
+
const withoutExt = rel.replace(/\.tsx?$/, '');
|
|
95
|
+
const normalized = withoutExt.split(node_path_1.sep).join('/');
|
|
96
|
+
return normalized.startsWith('.') ? normalized : `./${normalized}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Read file contents, returns empty string if file doesn't exist.
|
|
100
|
+
*/
|
|
101
|
+
async function readFileSafe(filePath) {
|
|
102
|
+
try {
|
|
103
|
+
return await (0, promises_1.readFile)(filePath, 'utf-8');
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Find all route.ts files in a directory.
|
|
111
|
+
*/
|
|
112
|
+
async function findRouteFiles(dir) {
|
|
113
|
+
return findFiles(dir, 'route.ts');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Extract all top-level brace-balanced blocks for a given function call.
|
|
117
|
+
* Handles nested braces correctly (e.g., z.object({...}), uiAction: { payload: {...} }).
|
|
118
|
+
*
|
|
119
|
+
* @param content Source file content
|
|
120
|
+
* @param fnPattern Regex that matches the function call prefix up to (but not including) the opening `{`.
|
|
121
|
+
* Must NOT have the `g` flag — it is added internally.
|
|
122
|
+
* @returns Array of the inner content of each matched block (between the outermost `{` and `}`).
|
|
123
|
+
*/
|
|
124
|
+
function extractBalancedBlocks(content, fnPattern) {
|
|
125
|
+
const results = [];
|
|
126
|
+
const globalPattern = new RegExp(fnPattern.source, 'g');
|
|
127
|
+
let prefixMatch;
|
|
128
|
+
while ((prefixMatch = globalPattern.exec(content)) !== null) {
|
|
129
|
+
// Find the opening { after the function call prefix
|
|
130
|
+
const searchStart = prefixMatch.index + prefixMatch[0].length;
|
|
131
|
+
const braceStart = content.indexOf('{', searchStart);
|
|
132
|
+
if (braceStart === -1)
|
|
133
|
+
continue;
|
|
134
|
+
// Walk forward counting braces
|
|
135
|
+
let depth = 0;
|
|
136
|
+
let i = braceStart;
|
|
137
|
+
for (; i < content.length; i++) {
|
|
138
|
+
if (content[i] === '{')
|
|
139
|
+
depth++;
|
|
140
|
+
else if (content[i] === '}')
|
|
141
|
+
depth--;
|
|
142
|
+
if (depth === 0)
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (depth === 0) {
|
|
146
|
+
// Extract inner content (between outermost braces)
|
|
147
|
+
results.push(content.slice(braceStart + 1, i));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return results;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get all immediate subdirectories of a directory.
|
|
154
|
+
*/
|
|
155
|
+
async function getSubdirectories(dir) {
|
|
156
|
+
try {
|
|
157
|
+
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
158
|
+
return entries
|
|
159
|
+
.filter((e) => e.isDirectory() && e.name !== 'node_modules' && e.name !== '.git')
|
|
160
|
+
.map((e) => (0, node_path_1.join)(dir, e.name));
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { scanEndpointTools, generateEndpointRegistry } from './endpoint-scanner.js';
|
|
2
|
+
export { scanUiTools, generateUiRegistry, generateActionIdRegistry } from './ui-scanner.js';
|
|
3
|
+
export { generateModuleRegistry } from './module-generator.js';
|
|
4
|
+
export { validateAiTools, formatValidationReport, type ValidationResult, type ValidationIssue } from './validator.js';
|
|
5
|
+
export { checkAiCoverage, formatCoverageReport, type CoverageReport } from './coverage.js';
|
|
6
|
+
export { scaffoldAiTool, formatScaffoldResult, type ScaffoldResult } from './scaffolder.js';
|
|
7
|
+
export { colors } from './format.js';
|
|
8
|
+
export { generateAgentSkills, type GenerateSkillsOptions, type GenerateSkillsResult } from './skill-generator.js';
|
|
9
|
+
export { generateMcpServer, type GenerateMcpOptions, type GenerateMcpResult } from './mcp-generator.js';
|
|
10
|
+
export { recommendOutputFormat, type OutputFormat, type RecommendationInput } from './output-recommender.js';
|
|
11
|
+
export { syncAssetToGlirastes, type AssetSyncOptions, type AssetSyncResult } from './asset-sync.js';
|
|
12
|
+
export { scanNestControllers, type DiscoveredNestTool, type NestScanResult } from './nestjs-scanner.js';
|
|
13
|
+
export type { ScanResult, GenerateOptions } from './types.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanNestControllers = exports.syncAssetToGlirastes = exports.recommendOutputFormat = exports.generateMcpServer = exports.generateAgentSkills = exports.colors = exports.formatScaffoldResult = exports.scaffoldAiTool = exports.formatCoverageReport = exports.checkAiCoverage = exports.formatValidationReport = exports.validateAiTools = exports.generateModuleRegistry = exports.generateActionIdRegistry = exports.generateUiRegistry = exports.scanUiTools = exports.generateEndpointRegistry = exports.scanEndpointTools = void 0;
|
|
4
|
+
var endpoint_scanner_js_1 = require("./endpoint-scanner.js");
|
|
5
|
+
Object.defineProperty(exports, "scanEndpointTools", { enumerable: true, get: function () { return endpoint_scanner_js_1.scanEndpointTools; } });
|
|
6
|
+
Object.defineProperty(exports, "generateEndpointRegistry", { enumerable: true, get: function () { return endpoint_scanner_js_1.generateEndpointRegistry; } });
|
|
7
|
+
var ui_scanner_js_1 = require("./ui-scanner.js");
|
|
8
|
+
Object.defineProperty(exports, "scanUiTools", { enumerable: true, get: function () { return ui_scanner_js_1.scanUiTools; } });
|
|
9
|
+
Object.defineProperty(exports, "generateUiRegistry", { enumerable: true, get: function () { return ui_scanner_js_1.generateUiRegistry; } });
|
|
10
|
+
Object.defineProperty(exports, "generateActionIdRegistry", { enumerable: true, get: function () { return ui_scanner_js_1.generateActionIdRegistry; } });
|
|
11
|
+
var module_generator_js_1 = require("./module-generator.js");
|
|
12
|
+
Object.defineProperty(exports, "generateModuleRegistry", { enumerable: true, get: function () { return module_generator_js_1.generateModuleRegistry; } });
|
|
13
|
+
var validator_js_1 = require("./validator.js");
|
|
14
|
+
Object.defineProperty(exports, "validateAiTools", { enumerable: true, get: function () { return validator_js_1.validateAiTools; } });
|
|
15
|
+
Object.defineProperty(exports, "formatValidationReport", { enumerable: true, get: function () { return validator_js_1.formatValidationReport; } });
|
|
16
|
+
var coverage_js_1 = require("./coverage.js");
|
|
17
|
+
Object.defineProperty(exports, "checkAiCoverage", { enumerable: true, get: function () { return coverage_js_1.checkAiCoverage; } });
|
|
18
|
+
Object.defineProperty(exports, "formatCoverageReport", { enumerable: true, get: function () { return coverage_js_1.formatCoverageReport; } });
|
|
19
|
+
var scaffolder_js_1 = require("./scaffolder.js");
|
|
20
|
+
Object.defineProperty(exports, "scaffoldAiTool", { enumerable: true, get: function () { return scaffolder_js_1.scaffoldAiTool; } });
|
|
21
|
+
Object.defineProperty(exports, "formatScaffoldResult", { enumerable: true, get: function () { return scaffolder_js_1.formatScaffoldResult; } });
|
|
22
|
+
var format_js_1 = require("./format.js");
|
|
23
|
+
Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return format_js_1.colors; } });
|
|
24
|
+
var skill_generator_js_1 = require("./skill-generator.js");
|
|
25
|
+
Object.defineProperty(exports, "generateAgentSkills", { enumerable: true, get: function () { return skill_generator_js_1.generateAgentSkills; } });
|
|
26
|
+
var mcp_generator_js_1 = require("./mcp-generator.js");
|
|
27
|
+
Object.defineProperty(exports, "generateMcpServer", { enumerable: true, get: function () { return mcp_generator_js_1.generateMcpServer; } });
|
|
28
|
+
var output_recommender_js_1 = require("./output-recommender.js");
|
|
29
|
+
Object.defineProperty(exports, "recommendOutputFormat", { enumerable: true, get: function () { return output_recommender_js_1.recommendOutputFormat; } });
|
|
30
|
+
var asset_sync_js_1 = require("./asset-sync.js");
|
|
31
|
+
Object.defineProperty(exports, "syncAssetToGlirastes", { enumerable: true, get: function () { return asset_sync_js_1.syncAssetToGlirastes; } });
|
|
32
|
+
var nestjs_scanner_js_1 = require("./nestjs-scanner.js");
|
|
33
|
+
Object.defineProperty(exports, "scanNestControllers", { enumerable: true, get: function () { return nestjs_scanner_js_1.scanNestControllers; } });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { GenerateOptions } from './types.js';
|
|
2
|
+
import type { AgentSkillConfig } from '../types.js';
|
|
3
|
+
export interface GenerateMcpOptions extends GenerateOptions {
|
|
4
|
+
/** Skill configuration (app name, base URL, auth) */
|
|
5
|
+
skillConfig: AgentSkillConfig;
|
|
6
|
+
/** Custom output directory for MCP server files (default: mcp-server/) */
|
|
7
|
+
mcpOutputDir?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GenerateMcpResult {
|
|
10
|
+
/** Generated files with their relative paths and content */
|
|
11
|
+
files: Array<{
|
|
12
|
+
path: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** Number of MCP tools generated */
|
|
16
|
+
toolCount: number;
|
|
17
|
+
/** Module names that contain tools */
|
|
18
|
+
modulesUsed: string[];
|
|
19
|
+
/** Full extracted tool metadata for syncing to Glirastes */
|
|
20
|
+
tools: Array<{
|
|
21
|
+
toolName: string;
|
|
22
|
+
description: string;
|
|
23
|
+
method: string;
|
|
24
|
+
path: string;
|
|
25
|
+
module?: string;
|
|
26
|
+
allowedRoles?: string[];
|
|
27
|
+
needsApproval?: boolean;
|
|
28
|
+
inputFields: Array<{
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
required: boolean;
|
|
32
|
+
description?: string;
|
|
33
|
+
}>;
|
|
34
|
+
outputFields: Array<{
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generate an MCP server project from discovered tool definitions.
|
|
42
|
+
*
|
|
43
|
+
* Scans the project for endpoint and UI tool definitions and produces
|
|
44
|
+
* a complete MCP server project as in-memory file contents. The caller
|
|
45
|
+
* is responsible for writing the files to disk.
|
|
46
|
+
*
|
|
47
|
+
* The generated server uses stdio transport and registers one MCP tool
|
|
48
|
+
* per discovered endpoint/UI tool, grouped by module.
|
|
49
|
+
*/
|
|
50
|
+
export declare function generateMcpServer(options: GenerateMcpOptions): Promise<GenerateMcpResult>;
|