Skip to content

Add AI-powered application generation with business logic and testing to ObjectQL#36

Merged
hotlong merged 14 commits intomainfrom
copilot/create-ai-agent-cli
Jan 13, 2026
Merged

Add AI-powered application generation with business logic and testing to ObjectQL#36
hotlong merged 14 commits intomainfrom
copilot/create-ai-agent-cli

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 12, 2026

AI Agent and CLI for Enterprise Application Creation and Validation

Completed

  • 1. Moved AI functionality to core package

    • Created @objectql/core/src/ai-agent.ts with ObjectQLAgent class
    • Updated package dependencies (openai, js-yaml, @types/js-yaml)
    • Exported AI agent from core package index
    • Updated CLI to import from @objectql/core
    • Removed duplicate agent.ts from CLI package
    • Fixed pnpm-lock.yaml to include new dependencies
  • 2. Improved AI command structure with interactive mode as default

    • objectql ai - Default interactive conversational mode
    • objectql ai generate - One-shot generation subcommand
    • objectql ai validate - Validation subcommand
    • objectql ai chat - Chat assistant subcommand
  • 3. Complete metadata and business logic generation

    • Generate all ObjectQL metadata types
    • TypeScript implementations for actions and hooks
    • Jest test files for business logic validation
  • 4. AI-powered validation

    • Deep validation beyond syntax
    • Business logic consistency checks
    • Graceful fallback without API key
  • 5. Interactive features

    • Step-by-step conversational generation (default mode)
    • AI chat assistant for questions
    • Continuous dialogue for file modification
  • 6. Comprehensive documentation

    • Created /docs/ai/cli-usage.md - Complete CLI guide
    • Created /docs/ai/programmatic-api.md - Programmatic API documentation
    • Updated /docs/ai/index.md - Main AI documentation index
    • Included TypeScript types and examples
    • Added best practices and workflow examples
  • 7. CI/Build fixes

    • Updated pnpm-lock.yaml with new dependencies
    • Verified builds pass for @objectql/core and @objectql/cli

Summary

CI Build Fix:
Updated pnpm-lock.yaml to include the new dependencies added to @objectql/core:

  • openai@^4.28.0 - OpenAI API client
  • js-yaml@^4.1.0 - YAML parsing for metadata
  • @types/js-yaml@^4.0.5 - TypeScript types for js-yaml

Architecture:

Moved AI functionality from CLI to core package enabling:

  • Reusability: API server can now use the same AI agent
  • Separation of Concerns: Core logic in @objectql/core, CLI is thin wrapper
  • Programmatic Access: Direct usage via new ObjectQLAgent()
  • Better Testing: Core functionality testable independently

Package Structure:

@objectql/core
├── src/
│   ├── ai-agent.ts        # NEW: AI Agent class
│   ├── validator.ts
│   ├── app.ts
│   └── index.ts           # Exports ObjectQLAgent
└── package.json           # Added openai, js-yaml dependencies

@objectql/cli
└── src/
    ├── commands/
    │   └── ai.ts          # UPDATED: Imports from @objectql/core
    └── index.ts

API Usage:

// In any Node.js application
import { ObjectQLAgent } from '@objectql/core';

const agent = new ObjectQLAgent({ apiKey: process.env.OPENAI_API_KEY! });

const result = await agent.generateApp({
  description: "CRM system",
  type: 'complete'
});

CLI Usage:

# Interactive (default - easiest)
objectql ai

# One-shot generation
objectql ai generate -d "description"

# Validation
objectql ai validate ./src

# Chat
objectql ai chat

Documentation:

  • 📚 Comprehensive CLI usage guide with examples
  • 📚 Programmatic API documentation with TypeScript types
  • 📚 Advanced examples (CI/CD, web UI, automation)
  • 📚 Best practices and error handling
  • 📚 Updated main AI documentation index

The implementation enables the API server and other packages to use the same AI capabilities while maintaining the user-friendly CLI interface. All builds now pass successfully.

Original prompt

编写ai agent和cli,使用ai按照元数据规范创建和验证企业应用


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 12, 2026 22:10
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…lidation

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…rns to constants

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 12, 2026

@copilot 生成的企业应用元数据范围应该包含规范文档中的所有元数据,而不只是元数据,你应该开发一个agent分步生成,你应该具有对话能力,客户提出改进的需求,你针对性地做改进

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AI agent and CLI for enterprise app creation Add AI-powered application generation and validation to ObjectQL CLI Jan 12, 2026
Copilot AI requested a review from hotlong January 12, 2026 22:25
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 12, 2026

@copilot ai生成的代码项目应该包括业务逻辑部分,actions,hooks等等。应该提供测试方案验证app的业务逻辑

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 12, 2026

@copilot 继续完成所有工作

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 12, 2026

@copilot 继续完成所有工作

你在继续工作吗?如果任务复杂可以重新确立任务规划,分步完成。 @copilot

1 similar comment
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 12, 2026

@copilot 继续完成所有工作

你在继续工作吗?如果任务复杂可以重新确立任务规划,分步完成。 @copilot

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot 继续完成所有工作

你在继续工作吗?如果任务复杂可以重新确立任务规划,分步完成。 @copilot

I'm continuing the work now. Based on the previous feedback, I'm implementing:

  1. Business logic generation: Generate TypeScript implementation files for actions and hooks (not just YAML)
  2. Testing framework: Add test generation for validating business logic
  3. Step-by-step conversational agent: Already added objectql ai conversational command

Working on these enhancements now.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot 继续完成所有工作

你在继续工作吗?如果任务复杂可以重新确立任务规划,分步完成。 @copilot

I'm continuing the work now. I'll complete the remaining requirements:

  1. Generate business logic (actions/hooks with TypeScript implementations)
  2. Add testing validation for business logic

Let me proceed with the implementation.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot 现在相关的命令太多,简化合并一下

Simplified in commit a440f5c. Merged 4 separate commands into a unified interface:

Before:

  • objectql ai generate
  • objectql ai validate
  • objectql ai chat
  • objectql ai conversational

After (single command with modes):

  • objectql ai -d "description" [dir] - Generate
  • objectql ai --validate [path] - Validate
  • objectql ai --chat - Chat assistant
  • objectql ai --interactive [dir] - Interactive generation

Benefits: Simpler to use, fewer commands to remember, consistent flag-based interface, built-in help when no mode specified.

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 13, 2026

你这个改动太极端了,没有意义,没有减少学习成本。觉得最常见的场景是交互式会话,要让用户很方便的输入这个命令。

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 13, 2026

你这个改动太极端了,没有意义,没有减少学习成本。觉得最常见的场景是交互式会话,要让用户很方便的输入这个命令。

@copilot

…ands

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

你这个改动太极端了,没有意义,没有减少学习成本。觉得最常见的场景是交互式会话,要让用户很方便的输入这个命令。

@copilot

Redesigned in commit 89616e8. The interactive mode is now the default and easiest to use:

Just type:

objectql ai

This immediately starts the conversational builder. Other modes use clear subcommands:

  • objectql ai generate -d "..." - One-shot generation
  • objectql ai validate ./src - Validation
  • objectql ai chat - Q&A assistant

The most common scenario (interactive conversation) now requires only 2 words, making it very convenient while keeping other modes clear and discoverable.

@hotlong hotlong requested review from Copilot and removed request for hotlong January 13, 2026 01:52
Copilot AI requested a review from hotlong January 13, 2026 01:53
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 13, 2026

ai相关的功能考虑到放到内核中,因为下一步API也要实现。cli只是调用内核。然后还要帮我更新docs相关的文档。

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 13, 2026

ai相关的功能考虑到放到内核中,因为下一步API也要实现。cli只是调用内核。然后还要帮我更新docs相关的文档。

@copilot

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

ai相关的功能考虑到放到内核中,因为下一步API也要实现。cli只是调用内核。然后还要帮我更新docs相关的文档。

@copilot

Completed in commit 7d07a31:

Moved to Core:

  • AI agent is now in @objectql/core/src/ai-agent.ts
  • CLI imports from @objectql/core instead of local file
  • API server can now use the same ObjectQLAgent class

Usage:

// In any package
import { ObjectQLAgent } from '@objectql/core';

const agent = new ObjectQLAgent({ apiKey: '...' });
const result = await agent.generateApp({ description: '...' });

Documentation:

  • Created /docs/ai/cli-usage.md - Complete CLI guide with examples
  • Created /docs/ai/programmatic-api.md - API documentation with TypeScript types
  • Updated /docs/ai/index.md - Main AI docs index

Copilot AI changed the title Add AI-powered application generation with business logic and testing to ObjectQL CLI Add AI-powered application generation with business logic and testing to ObjectQL Jan 13, 2026
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 13, 2026

2026-01-13T03:18:13.4617348Z ##[group]Run pnpm install --frozen-lockfile
2026-01-13T03:18:13.4617765Z �[36;1mpnpm install --frozen-lockfile�[0m
2026-01-13T03:18:13.4661339Z shell: /usr/bin/bash -e {0}
2026-01-13T03:18:13.4661613Z env:
2026-01-13T03:18:13.4661867Z PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
2026-01-13T03:18:13.4662176Z ##[endgroup]
2026-01-13T03:18:13.8531400Z Scope: all 18 workspace projects
2026-01-13T03:18:13.9438824Z  ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with /packages/foundation/core/package.json
2026-01-13T03:18:13.9439654Z
2026-01-13T03:18:13.9440459Z Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"
2026-01-13T03:18:13.9441137Z
2026-01-13T03:18:13.9441256Z Failure reason:
2026-01-13T03:18:13.9441733Z specifiers in the lockfile don't match specifiers in package.json:
2026-01-13T03:18:13.9442507Z * 3 dependencies were added: @types/js-yaml@^4.0.5, openai@^4.28.0, js-yaml@^4.1.0
2026-01-13T03:18:13.9443274Z
2026-01-13T03:18:13.9652746Z ##[error]Process completed with exit code 1.
@copilot

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

2026-01-13T03:18:13.4617348Z ##[group]Run pnpm install --frozen-lockfile
2026-01-13T03:18:13.4617765Z �[36;1mpnpm install --frozen-lockfile�[0m
2026-01-13T03:18:13.4661339Z shell: /usr/bin/bash -e {0}...

Fixed in commit 764696b. Updated pnpm-lock.yaml to include the new dependencies (openai, js-yaml, @types/js-yaml) that were added to @objectql/core. The build now passes successfully.

Copilot AI requested a review from hotlong January 13, 2026 04:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@hotlong hotlong marked this pull request as ready for review January 13, 2026 04:36
@hotlong hotlong merged commit 276fbfe into main Jan 13, 2026
2 checks passed
@hotlong hotlong deleted the copilot/create-ai-agent-cli branch January 13, 2026 04:37
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.

3 participants