Specification driven code generation method and system based on intent understanding
By using intent understanding and normative constraint sets, this approach addresses the issues of inaccurate code generation and insufficient iteration capabilities in existing technologies, achieving a high-quality, maintainable code generation process suitable for complex and existing projects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHIJIA ARTIFICIAL INTELLIGENCE TECH (TIANJIN) CO LTD
- Filing Date
- 2026-01-20
- Publication Date
- 2026-05-01
AI Technical Summary
When generating code in complex and established projects, existing technologies rely on rigid design documents and lack an understanding of the developer's intent, resulting in inaccurate and low-quality code generation, as well as a lack of iterative capabilities and adaptability.
By understanding intent, we can construct an intent hierarchy tree and a set of specification constraints, generate an accurate set of specification constraints, perform architectural reasoning and verification, select the optimal code solution, and support iterative refinement to form a closed-loop development process.
It improves the accuracy, quality, and maintainability of code generation, adapts to the iterative needs of large and complex projects, and ensures that the generated code meets functional, performance, and security constraints.
Smart Images

Figure CN121560301B_ABST
Abstract
Description
Intent-based specification-driven code generation method and system Technical Field
[0001] This invention relates to the field of artificial intelligence, and more specifically, to a specification-driven code generation method and system based on intent understanding. Background Technology
[0002] With Large Language Models (LLMs) demonstrating remarkable capabilities in code generation, AI-assisted development has become an inevitable trend. However, this trend also brings new challenges: the collaboration model between software developers and AI has fundamentally changed. Traditionally, programmers and product managers engaged in extensive interpersonal communication to internalize requirements into designs before coding. Now, AI has become a "partner" for programmers, requiring them to possess stronger design and abstraction skills to clearly and accurately communicate development goals to the AI. If programmers cannot provide high-quality design input, even the most powerful AI cannot complete complex development tasks. Against this backdrop, Spec-Driven Development (SDD) has emerged as a promising new paradigm. Its core idea is to use a specification document "written for AI" to guide the AI's work. Tools such as Spec-kit and OpenSpec have emerged, but these tools are still imperfect and mostly only suitable for small new projects, making them difficult to apply to large amounts of existing, complex legacy code projects within enterprises.
[0003] The closest prior art to this invention is Chinese patent application CN120743238A, which discloses a "software development system, method, and storage medium." The technical solution of this prior art includes: setting up a process management module and multiple software development robots. Its core workflow is: obtaining the "development design document" of the software to be developed according to user instructions; constructing a "file tree" based on the logical relationships of development tasks in the document; creating a code file for each functional node in the file tree and creating a corresponding "prompt" for it, which indicates the functional content and logical relationship of the node; and determining the "matching software development robot" based on the functional content to execute the development process of the corresponding code file.
[0004] The applicant identified the following deficiencies in the existing technology: When facing modern complex software development, especially large, existing projects, the reliance on "development design documents" is too rigid: Existing solutions rely on a single, existing, structured "development design document." In agile development practices, such documents are often missing, outdated, or overly macro-level. They lack an understanding of the "why" behind the document, i.e., the developer's true "intent." The "file tree" structure is too superficial: The "file tree" constructed by existing solutions merely reflects the physical storage structure of the code. It cannot express the system's logical architecture (such as MVC, microservices, event-driven architecture), the dependencies between modules, and design patterns, causing AI to "see the trees but not the forest" when generating code. The "hint word"-driven approach lacks precise constraints: Existing solutions create "hint words" for functional nodes. This simple text prompt is vague and imprecise for AI. It cannot support complex non-functional requirements, such as performance (response time <200ms), security (mandatory JWT authentication), and quality (code cyclomatic complexity <10) hard constraints. The execution mode of the "matching robot" lacks verification and optimal selection: the existing solution adopts the "matching robot execution" mode, which is a "black box" execution process. It lacks a mechanism to guarantee that the code generated by the robot is correct (i.e., satisfies all constraints), and cannot select the optimal one from multiple possible implementations. It also lacks adaptability and iterative capabilities for existing projects: the existing solution is more suitable for new projects starting from scratch, and does not provide an effective mechanism to analyze and utilize the context of the existing codebase. Furthermore, it lacks an effective closed-loop feedback mechanism to handle changes and iterations in requirements.
[0005] Therefore, improving the accuracy, quality, and maintainability of code generated by AI in complex and existing projects has become a technical problem that needs to be solved. Summary of the Invention
[0006] This invention aims to solve at least one of the technical problems existing in the prior art or related technologies, and discloses a specification-driven code generation method and system based on intent understanding. It is a closed-loop code generation method that goes "from intent understanding to architecture reasoning and then to specification verification", which greatly improves the accuracy, quality and maintainability of the generated code.
[0007] Terminology Explanation:
[0008] Specification (Spec): A structured document (such as a Markdown file) that describes the functional requirements, non-functional requirements, constraints, and design decisions of a software system using natural or semi-formal language.
[0009] Intent: The true purpose of the developer or user behind the specification. It is divided into user intent (what they want to do), system intent (how it should be implemented), and constraint intent (what must be satisfied).
[0010] Intent Hierarchy Tree: A data structure that decomposes high-level abstract intentions into mid-level and low-level concrete executable intentions.
[0011] Specification Constraint Set: A precise and verifiable set of rules extracted from a specification and associated with a specific intent, including constraints related to functionality, performance, security, and quality.
[0012] Large Language Models (LLMs): These are artificial intelligence models with powerful code generation and understanding capabilities.
[0013] Specification-Driven Development (SDD): A new software development paradigm that uses software specifications as the core driver and leverages AI to assist in the generation, verification, and iteration of code.
[0014] The first aspect of this invention discloses a specification-driven code generation method based on intent understanding, comprising: intent extraction: receiving a specification document and performing semantic analysis on the specification document using natural language processing technology to obtain user intent, system intent, and constraint intent; constructing an intent hierarchy tree based on the user intent, system intent, and constraint intent; specification decomposition: traversing each node of the intent hierarchy tree and extracting the specification fragment corresponding to the node from the specification document; decomposing the specification fragment into a set of specification constraints; establishing a mapping table between the set of specification constraints and each node in the intent hierarchy tree; architecture reasoning: quantitatively extracting a set of architecture feature vectors from the intent hierarchy tree and the mapping table, mapping the architecture feature vectors to recommended architecture patterns according to predefined rules, thereby reasoning out the most suitable system architecture pattern and generating a recommended architecture; specification-driven generation: calling a large language model, generating multiple candidate solutions for code implementation based on the recommended architecture, the nodes to be implemented in the mapping table, and the corresponding set of specification constraints; verifying the candidate solutions using the set of specification constraints; and selecting an optimal solution from all verified candidate solutions according to a preset quality standard.
[0015] According to the specification-driven code generation method based on intent understanding disclosed in this invention, preferably, it further includes: iterative refinement: receiving specification change information or modification information of candidate solutions or optimal solutions; invoking a large language model and using semantic similarity search to find nodes related to the modification information or specification change information in the current intent hierarchy tree; and programmatically manipulating the JSON structure of the intent hierarchy tree to perform node update or node addition operations.
[0016] According to the specification-driven code generation method based on intent understanding disclosed in this invention, preferably, the iterative refinement step further includes:
[0017] Based on the large language model, structured specification fragments are extracted from modification information or specification change information, and these structured specification fragments are merged into the specification constraint set of the corresponding added or updated node in the mapping table.
[0018] According to the specification-driven code generation method based on intent understanding disclosed in this invention, preferably, the iterative refinement step further includes: collecting the updated node and all its downstream dependent nodes to form a change set, so that the specification decomposition step, the architecture reasoning step, and the specification-driven generation step can regenerate the optimal solution based on the updated node.
[0019] According to the specification-driven code generation method based on intent understanding disclosed in this invention, preferably, a change log of specification documents or mapping tables is generated.
[0020] According to the specification-driven code generation method based on intent understanding disclosed in this invention, preferably, the architecture reasoning step further includes: for existing projects, firstly analyzing existing codebases to identify the architecture of existing projects, and then performing module partitioning: converting the intent hierarchy tree into a graph structure to generate a collaboration graph, where nodes are low-level intents and edge weights represent collaboration strength; using graph clustering or community detection algorithms to cluster cohesive nodes together according to the edge weights of the collaboration graph; using the clustering results as the initial solution, and then optimizing and adjusting according to the hard constraints in the mapping table, thereby generating the recommended architecture of existing projects.
[0021] According to the specification-driven code generation method based on intent understanding disclosed in this invention, preferably, the architecture reasoning step further includes: generating an architecture decision record, which explains why this architecture and / or module partitioning scheme was chosen.
[0022] A second aspect of the present invention discloses a specification-driven code generation system based on intent understanding, comprising: a memory for storing program instructions; and a processor for calling the program instructions stored in the memory to implement the specification-driven code generation method based on intent understanding as described above.
[0023] The beneficial effects of the present invention include at least the following:
[0024] (1) Paradigm shift from “passive execution” to “active understanding”: This invention can truly understand the “why” behind the specification by building an intent extraction engine (intent extraction steps), instead of passively executing rigid “design documents” like existing technologies.
[0025] (2) From “file stacking” to “architecture-driven” system construction: This invention builds an architecture reasoning engine, which can understand and follow the macro architecture of the project (especially existing projects), ensuring that newly generated code can be correctly integrated, rather than just building a superficial “file tree” like existing technologies.
[0026] (3) High-quality generation from “fuzzy prompts” to “precise constraints”: This invention provides precise and verifiable “guardrails” for the AI generation process by standardizing the constraint set, which fundamentally ensures the high quality of the code in terms of functionality, performance and security, and overcomes the defect of the existing technology that the “prompt words” are too vague.
[0027] (4) From “black box generation” to “verifiable optimal selection”: This invention ensures that the delivered code is the verified and highest quality one through the mechanism of “multiple candidates + standard verification + optimal selection”, which solves the problem of uncontrollable execution process and unreliable results of existing “matching robot” technology.
[0028] (5) Strong project adaptability and iteration capability: The entire mechanism of this invention (especially architectural reasoning and iterative refinement) enables it to be seamlessly applied to large, existing complex projects and to respond efficiently to changes in requirements, which is difficult to achieve with existing technologies. Attached Figure Description
[0029] Figure 1 shows a flowchart of a specification-driven code generation method based on intent understanding according to an embodiment of the present invention.
[0030] Figure 2 shows a schematic block diagram of a specification-driven code generation system based on intent understanding according to an embodiment of the present invention. Detailed Implementation
[0031] To better understand the above-described objects, features, and advantages of the present invention, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Many specific details are set forth in the following description to provide a thorough understanding of the invention; however, the invention may be practiced in other ways different from those described herein, and therefore, the invention is not limited to the specific embodiments disclosed below.
[0032] As shown in Figure 1, according to an embodiment of the present invention, a specification-driven code generation method based on intent understanding is disclosed, including:
[0033] Step 1, Intent Extraction (Establishing an Intent Extraction Engine): Receive the specification document and use natural language processing technology to perform semantic analysis on the specification document to obtain user intent, system intent, and constraint intent; construct an intent hierarchy tree based on user intent, system intent, and constraint intent; the intent hierarchy tree is a tree-shaped data structure, where each node represents an intent, and the relationships between nodes are mainly parent-child decomposition relationships and sibling combination relationships.
[0034] In this step, a specification document (specification.md) written in natural language or semi-formal language is input. This document can describe new features or modify existing features. First, intent recognition is performed. Natural Language Processing (NLP) techniques are used to perform semantic analysis on the specification document to identify different types of intents. These include:
[0035] User intent: Describes the functionality that users want to achieve, such as "users can log in via email".
[0036] System intent: Describe how the system should implement its functions, such as "the login service needs to call the authentication center".
[0037] Constraint intent: Describes non-functional conditions that must be met, such as "the login interface response time must be less than 200ms".
[0038] Then, intent hierarchy is performed: the identified discrete intents are constructed into an "intent hierarchy tree". High-level intents (such as "implement user authentication module") are decomposed into mid-level intents (such as "implement login" and "implement registration"), and then into low-level intents (such as "verify password format" and "generate JWT token"). Finally, a structured intent hierarchy tree (such as JSON format) is output as the "skeleton" for all subsequent steps.
[0039] Step 2, Specification Decomposition (Establishing a Specification Decomposition Engine): Traverse each node of the intent hierarchy tree and extract the specification fragments corresponding to the nodes from the specification documents; decompose the specification fragments into a set of specification constraints; establish a mapping table between the set of specification constraints and each node in the intent hierarchy tree; this mapping table is a table that maps "what to do" (intent tree node) to "to what extent" (specification constraints).
[0040] In this step, the intent hierarchy tree (from step one) and the specification document are input. Intent-specification association is performed, meaning a specification decomposition engine is built to traverse each node of the intent hierarchy tree (especially leaf nodes), extracting and associating the corresponding specific specification fragments from the specification document. Then, a constraint set is constructed, further decomposing the associated specification fragments into a precise and verifiable set of "specification constraints." This constraint set includes:
[0041] Functional Specification: Describes the input, output, preconditions, postconditions, and core behaviors of a function.
[0042] Performance specifications: such as time complexity, space complexity, response time, concurrency, etc.
[0043] Security standards include access control, encryption algorithms, input validation, and injection prevention.
[0044] Quality standards include code maintainability, testability, comment rate, and cyclomatic complexity.
[0045] Finally, an intent-canonical mapping table is output, where each intent node is associated with a precise set of canonical constraints.
[0046] Step 3, Architecture Reasoning (Building an Architecture Reasoning Engine): A set of architecture feature vectors is quantitatively extracted from the intent hierarchy tree and mapping table. These feature vectors are mapped to recommended architecture patterns according to predefined rules, thereby inferring the most suitable system architecture pattern and generating a recommended architecture. For existing projects, existing codebases are analyzed first to identify the existing project architecture, followed by module partitioning: the intent hierarchy tree is converted into a graph structure to generate a collaboration graph, where nodes represent low-level intents and edge weights represent collaboration strength. Graph clustering or community detection algorithms are used to group cohesive nodes together based on the edge weights of the collaboration graph. The clustering results are used as the initial solution, and further optimized and adjusted according to the hard constraints in the mapping table to generate the recommended architecture for the existing project. An architecture decision record is generated, explaining why this architecture and / or module partitioning scheme was chosen.
[0047] In this step, the intent hierarchy tree (from step one) and the intent-canonical mapping table (from step two) are input. Then, architecture pattern recognition is performed. The engine analyzes the overall structure of the intent hierarchy tree and the intent-canonical mapping table, quantitatively extracting a set of architecture feature vectors from the input. Based on a predefined set of rules, these features are mapped to recommended architecture patterns, thus inferring the most suitable system architecture pattern. Quantitative extraction refers to scoring the intent hierarchy tree and mapping table based on factors such as project size, performance requirements, team collaboration requirements, frequency of feature changes, and technical complexity to obtain architecture feature vectors. Then, the recommended architecture is determined according to predefined rules (which architecture pattern best matches the score of each project). For existing projects, this step prioritizes analyzing the project's existing codebase (through static analysis) to identify the current architecture (e.g., MVC, microservices, event-driven). Then, module partitioning is performed. First, a collaboration graph is constructed, converting the intent hierarchy tree into a graph structure, where nodes are low-level intents, and edge weights represent the collaboration strength between them. Then, graph clustering or community detection algorithms are used to group highly cohesive nodes together based on the edge weights of the collaboration graph. Finally, the clustering results are used as the initial solution, and then optimized and adjusted according to the hard constraints in the intent-norm mapping table to achieve the goal of automatic module partitioning. Finally, a decision record (ADR) is generated, explaining why this architecture and module partitioning scheme was chosen.
[0048] The final output includes a system architecture diagram and Architecture Decision Record (ADR), providing a macro-level, global context for code generation.
[0049] Step 4, Specification-Driven Generation (Establishing a Specification-Driven Generation Engine): Invoke the large language model, generate multiple candidate solutions for code implementation based on the recommendation architecture and the nodes to be implemented in the mapping table and the specification constraint sets corresponding to the nodes; verify the candidate solutions using the specification constraint sets; select the optimal solution from all verified candidate solutions according to preset quality standards.
[0050] In this step, input a low-level intent node to be implemented, its corresponding set of specification constraints (from step two), and the system architecture (from step three). Then perform the following processing steps:
[0051] Candidate implementation generation: The engine calls the large language model and instructs it to generate multiple different code implementation candidates based on intent and architecture.
[0052] Specification verification: The engine automatically verifies each candidate implementation scheme using a set of specification constraints.
[0053] Functional specifications: Verify by generating and executing unit tests.
[0054] Performance / security / quality specifications: verified through static code analysis tools, security scanning, performance testing, etc.
[0055] Optimal selection: Select the optimal implementation from all verified candidate implementations based on preset quality criteria (such as the most concise code and the best performance).
[0056] The final output is the selected best code, along with an implementation document (explaining why this implementation was chosen and how it meets all specifications).
[0057] Step 5, Iterative Refinement (Establishing an Iterative Refinement Mechanism): Receive specification change information or modification information for candidate or optimal solutions; invoke the large language model and use semantic similarity search to find nodes related to the modification or specification change information in the current intent hierarchy tree; programmatically manipulate the JSON structure of the intent hierarchy tree to update or add nodes. Extract structured specification fragments from the modification or specification change information based on the large language model, and merge these fragments into the specification constraint set corresponding to the added or updated nodes in the mapping table. Collect the updated nodes and all their downstream dependent nodes to form a changeset, so that the specification decomposition step, architecture reasoning step, and specification-driven generation step can regenerate the optimal solution based on the updated nodes. Generate a change log for the specification document or mapping table.
[0058] In this step, input user feedback on the generated code (e.g., "OAuth 2.0 login needs to be added") or new specification changes. The input information is processed as follows:
[0059] Intent Update: The system invokes the LLM using a finely tuned text classification model or carefully crafted cue words. Then, a semantic similarity search (e.g., via word embedding models) is used to find the most relevant node to the feedback within the current intent hierarchy tree. Simultaneously, the LLM infers the scope of the change's impact. Based on this analysis, the system programmatically manipulates the JSON structure of the intent hierarchy tree, updating it or adding new nodes.
[0060] Specification Refinement: Using LLM, structured specification fragments are extracted from the feedback. The JSON results extracted by LLM are automatically merged into the "specification constraint set" of the corresponding new or modified node in the intent-specification mapping table.
[0061] Change tracking: Records the evolution history of intent, forming a traceable development archive.
[0062] Regeneration: The system collects the nodes marked "to be updated" and all their downstream dependent nodes (obtained by traversing the intent tree's relationship graph) to form a changeset. The updated intent and specification are then resubmitted to steps two, three, and four, triggering the regeneration and verification of the affected code.
[0063] Finally, the refined new code, along with a record of intent evolution, will be output.
[0064] According to another embodiment of the present invention, a specific application process of the specification-driven code generation method based on intent understanding of the above embodiments is also disclosed: a development engine is built according to the specification-driven code generation method based on intent understanding provided in the above embodiments, and the following steps are performed based on this development engine:
[0065] 1. Input: The developer adds the intent "As a new user, I want to register an account so I can log in" to the specification.md file and adds the following constraints: "- Password must be encrypted using the bcrypt algorithm. - 'EmailService' must be called asynchronously to send a welcome email. - Response time must be <300ms."
[0066] 2. Intent Extraction: The development engine understands the high-level "user intent" mentioned above and automatically decomposes it into a specific, logically ordered task execution tree (intent tree). That is, the engine parses this into a high-level "user intent" and decomposes it into lower-level intents such as "validate input", "check if the user already exists", "hash password", "create user record", and "send email", forming an intent tree.
[0067] 3. Standardization Decomposition: The engine associates each specific step in the intent tree with the corresponding rule defined in the first step. For example, the engine associates the "Hash Password" node with "Standardization Constraint Set: { method: 'bcrypt', saltRounds:10}", and the "Send Email" node with "{ service: 'EmailService', async: true}".
[0068] 4. Architectural Reasoning: The engine analyzes the entire existing codebase to understand the current system's architectural style and designs a suitable implementation plan accordingly. For example, the engine first analyzes the existing codebase and identifies it as a "microservice architecture." It determines that "creating a user" should be implemented in "UserService," while "sending emails" should communicate with "EmailService" via a message queue (MQ).
[0069] 5. Standardized Generation: Based on the preceding analysis, the engine generates multiple possible code implementation schemes and, like a rigorous architect, verifies each one to ensure it conforms to all rules, ultimately selecting the optimal solution. Example: The engine generates three candidate implementations for the "Create User" intent.
[0070] Candidate 1: Direct connection to the database. Validation failed (violation of microservice architecture constraints).
[0071] Candidate 2: "UserService" was called, but the password hash was not bcrypt. Verification failed (security constraint violated).
[0072] Candidate 3: "UserService" was correctly invoked, using bcrypt hashing, and "EmailService" was triggered via MQ. Verification passed.
[0073] The engine ultimately selects candidate 3 as the optimal implementation and outputs the code.
[0074] 6. Iteration: When new requirements arise, the process can be updated intelligently and securely. For example, if developers later report that "SMS verification is still required during registration," the iteration mechanism will update the intent tree, adding an "SMS verification" node and related constraints. Based on this, the engine will only regenerate the affected code, ensuring that the new implementation remains compatible with all existing architectures and security rules. This avoids errors and inconsistencies that might be introduced by manual modifications, and securely regenerates the relevant process code.
[0075] As shown in Figure 2, according to another embodiment of the present invention, a specification-driven code generation system 200 based on intent understanding is also disclosed, including: a memory 201 for storing program instructions; and a processor 202 for calling the program instructions stored in the memory to implement the specification-driven code generation method based on intent understanding as described in the above embodiment.
[0076] In summary, this invention aims to address the problems caused by existing technologies' "passive execution," "surface-level structure," "vague constraints," and "lack of verification," proposing a novel specification-driven development paradigm based on "intent understanding." This significantly improves the accuracy, quality, and maintainability of code generated by AI in complex and existing projects. Specifically: This invention provides a method for extracting and constructing an intent hierarchy tree from specification documents: unlike existing technologies that rely on rigid "design documents," this invention proactively understands the developer's multi-layered "intents" from the specification. This invention provides a method for decomposing intent and specification into a precise set of specification constraints: unlike vague guidance using "hint words," this invention provides verifiable and precise (functional, performance, security, quality) constraints for each step of AI generation. This invention provides a method for reasoning about system architecture based on the intent hierarchy tree: unlike existing technologies that construct surface "document trees," this invention can infer the system's logical architecture and module division, providing a global context for code generation. This invention provides a method for optimal code generation and selection based on specification verification: unlike the black-box execution of "matching robots," this invention generates multiple candidate implementations and verifies them through the specification constraint set, selecting the optimal solution. This invention provides an iterative refinement mechanism that supports intent evolution: it provides a complete feedback loop, enabling the tracking and updating of intents based on user feedback, and achieving continuous iteration and refinement of code.
[0077] All or part of the steps in the various methods of the above embodiments can be implemented by a program controlling the relevant hardware. The program can be stored in a readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other readable medium that can be used to carry or store data.
[0078] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A specification-driven code generation method based on intent understanding, characterized in that, Includes: Intent extraction: receiving a specification document and performing semantic analysis on the specification document using natural language processing technology to obtain user intent, system intent, and constraint intent; An intent hierarchy tree is constructed based on the user intent, the system intent, and the constraint intent; Specification decomposition: Each node of the intent hierarchy tree is traversed, and the specification fragment corresponding to the node is extracted from the specification document; The specification fragment is decomposed into a set of specification constraints; A mapping table is established between the set of specification constraints and each node in the intent hierarchy tree; Architecture reasoning: A set of architecture feature vectors is quantitatively extracted from the intent hierarchy tree and the mapping table, and the architecture feature vectors are mapped to recommended architecture patterns according to predefined rules, thereby reasoning out the most suitable system architecture pattern and generating a recommended architecture; For existing projects, the existing codebase is analyzed first to identify the existing project architecture, followed by module partitioning: the intent hierarchy tree is converted into a graph structure to generate a collaboration graph, where nodes are low-level intents and edge weights represent collaboration strength; graph clustering or community detection algorithms are used to group cohesive nodes together based on the edge weights of the collaboration graph; the clustering results are used as the initial solution, and then optimized and adjusted according to the hard constraints in the mapping table to generate the recommended architecture for the existing project; specification-driven generation: a large language model is invoked to generate multiple candidate code implementation schemes based on the recommended architecture and the nodes to be implemented and their corresponding specification constraint sets in the mapping table; the candidate schemes are then validated using the specification constraint sets; From all the verified candidate solutions, select the optimal solution based on the preset quality criteria.
2. The specification-driven code generation method based on intent understanding according to claim 1, characterized in that, It also includes: iteration Detailed: Receive information on specification changes or modifications to the candidate or optimal solutions; The large language model is invoked, and semantic similarity search is used to find nodes in the current intent hierarchy tree that are related to the modified information or the specification change information. Manipulate the JSON structure of the intent hierarchy tree programmatically to update or add nodes.
3. The specification-driven code generation method based on intent understanding according to claim 2, characterized in that, The iterative refinement step further includes: extracting structured specification fragments from the modification information or specification change information based on the large language model, and merging the structured specification fragments into the specification constraint set of the corresponding added or updated node in the mapping table.
4. The specification-driven code generation method based on intent understanding according to claim 2, characterized in that, The iterative refinement step further includes: collecting the updated node and all its downstream dependent nodes to form a change set, so that the specification decomposition step, the architecture reasoning step, and the specification-driven generation step can regenerate the optimal solution based on the updated nodes.
5. The specification-driven code generation method based on intent understanding according to any one of claims 2 to 4, characterized in that, Generate a change log for the specification document or the mapping table.
6. The specification-driven code generation method based on intent understanding according to claim 1, characterized in that, It also includes: generating an architecture decision record, which explains why this architecture and / or module partitioning scheme was chosen.
7. A specification-driven code generation system based on intent understanding, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke the program instructions stored in the memory to implement the specification-driven code generation method based on intent understanding as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Software development system and method and storage medium
CN120743238A
Business module source code generation method and system based on large model business reasoning
CN120929089A
Three-normal-form automatic modeling method and system, electronic equipment and storage medium
CN121255762A