cli-usereq 0.68.0__py3-none-any.whl
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.
- cli_usereq-0.68.0.dist-info/METADATA +1134 -0
- cli_usereq-0.68.0.dist-info/RECORD +37 -0
- cli_usereq-0.68.0.dist-info/WHEEL +5 -0
- cli_usereq-0.68.0.dist-info/entry_points.txt +4 -0
- cli_usereq-0.68.0.dist-info/licenses/LICENSE +674 -0
- cli_usereq-0.68.0.dist-info/top_level.txt +1 -0
- usereq/__init__.py +62 -0
- usereq/__main__.py +17 -0
- usereq/cli.py +4963 -0
- usereq/compress.py +393 -0
- usereq/compress_files.py +134 -0
- usereq/doxygen_parser.py +172 -0
- usereq/find_constructs.py +394 -0
- usereq/generate_markdown.py +158 -0
- usereq/resources/docs/Document_Source_Code_in_Doxygen_Style.md +130 -0
- usereq/resources/docs/HDT_Test_Authoring_Guide.md +318 -0
- usereq/resources/docs/Requirements_Template.md +78 -0
- usereq/resources/prompts/analyze.md +191 -0
- usereq/resources/prompts/change.md +279 -0
- usereq/resources/prompts/check.md +190 -0
- usereq/resources/prompts/cover.md +271 -0
- usereq/resources/prompts/create.md +134 -0
- usereq/resources/prompts/fix.md +273 -0
- usereq/resources/prompts/flowchart.md +272 -0
- usereq/resources/prompts/implement.md +194 -0
- usereq/resources/prompts/new.md +278 -0
- usereq/resources/prompts/readme.md +234 -0
- usereq/resources/prompts/recreate.md +265 -0
- usereq/resources/prompts/refactor.md +265 -0
- usereq/resources/prompts/references.md +131 -0
- usereq/resources/prompts/renumber.md +150 -0
- usereq/resources/prompts/workflow.md +254 -0
- usereq/resources/prompts/write.md +129 -0
- usereq/resources/prompts-version.txt +1 -0
- usereq/source_analyzer.py +2280 -0
- usereq/static_check.py +812 -0
- usereq/token_counter.py +123 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Write a Software Requirements Specification using the project's source code"
|
|
3
|
+
argument-hint: "No arguments utilized by the prompt logic (English only)"
|
|
4
|
+
usage: >
|
|
5
|
+
Use when the user asks to create or complete REQUIREMENTS.md from an existing implementation under the project source directories. Capture implemented behavior with repository evidence; change only the SRS, not source code or tests. Use /req-write when the source of requirements is the user's description rather than code; /req-recreate to reorganize an existing SRS while preserving IDs; /req-renumber to change only IDs and internal cross-references. Do not select to implement new or changed behavior.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Write a Software Requirements Specification using the project's source code
|
|
9
|
+
|
|
10
|
+
## Pre-Flight: Context Keyword Resolution
|
|
11
|
+
- **CRITICAL**: Complete this read-only gate before any path-dependent action or numbered Step. Immediate-start directives apply only after success; autonomous disambiguation MUST NOT guess `{{PRJ_BASE}}` or `{{GIT_BASE}}`.
|
|
12
|
+
- Runtime keywords: resolve exactly two LLM-resolved path keywords in fixed order: `{{PRJ_BASE}}` first, `{{GIT_BASE}}` second. Installation has already supplied the documentation, source, and test paths; use them as fixed relative suffixes, not values to discover or replace.
|
|
13
|
+
- Project base: `{{PRJ_BASE}}` is the absolute base directory of the unique target project containing its installation-supplied `%%DOC_PATH%%`, `%%SRC_PATHS%%`, and `%%TEST_PATH%%` directories.
|
|
14
|
+
- Git base: `{{GIT_BASE}}` is the absolute base directory of the git repository containing `{{PRJ_BASE}}`. One git repository can contain multiple projects; repository identity alone never identifies the project.
|
|
15
|
+
- Resolution order: identify `{{PRJ_BASE}}` first and uniquely from current invocation routing and explicit task scope; use uniquely corroborated project path metadata only for missing evidence. The current directory is a candidate, not a default. Conflicting bindings, multiple plausible projects, or stale cross-project values fail resolution. Source-free workflows inspect path metadata only. After `{{PRJ_BASE}}` is bound, derive `{{GIT_BASE}}` as the git repository root containing the bound project base.
|
|
16
|
+
- Binding: retain `{{PRJ_BASE}}`, `{{GIT_BASE}}`, active worktree root, project identity, evidence, directory existence states, and document provenance throughout this invocation. Start fresh for each invocation; replace the bindings only after a validated context transition.
|
|
17
|
+
- Paths: substitute the resolved base in each prefixed path. For an installation-supplied source list, apply the base separately to every entry; preserve order and explicit list boundaries, never split on spaces or commas. Treat paths as data and quote each resulting literal argument separately, with option termination where supported.
|
|
18
|
+
- Containment: validate the base and resulting paths inside the active worktree, including symlink targets and existing ancestors of prospective paths. Accept absent directories only for authorized creation or explicitly unused source/test scopes; absence is not an unresolved base. Create nothing during pre-flight.
|
|
19
|
+
- Document contract below: filenames are relative to the installation-supplied documentation path under `{{PRJ_BASE}}`. Required inputs MUST exist; creatable targets MAY be absent. Load exactly the listed existing documents in full before Steps, including existing targets; defer reads of absent creatable targets until generated. Unlisted canonical documents are not prerequisites.
|
|
20
|
+
- Required inputs: none.
|
|
21
|
+
- Creatable targets: REQUIREMENTS.md.
|
|
22
|
+
- Load when present: REQUIREMENTS.md.
|
|
23
|
+
- Context reuse: treat injected or previously read content as loaded only when repository, worktree, project-area, path, and revision provenance match this binding. Current runtime attestation or unchanged-file evidence can establish a match; a basename alone cannot. Refresh stale or unverified content from the resolved path; reuse matching content without re-reading. After an edit, retain the verified updated content and invalidate superseded evidence.
|
|
24
|
+
- Operation scope: run cwd-sensitive commands and configured tools from `{{PRJ_BASE}}` only when their effective scope matches the target project; otherwise use a documented explicit-path equivalent or fail resolution.
|
|
25
|
+
- Activity routing: reference all project-modification and requirements-modification activities exclusively to `{{PRJ_BASE}}`; reference only working-tree creation and git-management activities to `{{GIT_BASE}}`.
|
|
26
|
+
- Context transitions: after an authorized worktree change, rebase `{{PRJ_BASE}}` to the same project-relative location in the new worktree and rebase `{{GIT_BASE}}` to the new worktree's repository root. Revalidate containment and document provenance before project operations; discard old absolute paths. Reuse document contents only with verified unchanged-file evidence. A different target project requires a fresh invocation.
|
|
27
|
+
- **CRITICAL**: If `{{PRJ_BASE}}` or `{{GIT_BASE}}`, required document, containment check, or effective tool scope remains unresolved or conflicting, OUTPUT exactly "ERROR: Unable to resolve context keywords!", and then terminate the execution.
|
|
28
|
+
|
|
29
|
+
## Purpose
|
|
30
|
+
Bootstrap an SRS (`{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`) from repository evidence so downstream LLM Agents MUST start SRS-driven work grounded in what the code actually does (requirements → design → implementation → verification), without guessing undocumented behavior.
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
In scope: static analysis of source under {{PRJ_BASE}}/%%SRC_PATHS%% (and targeted tests only as evidence when needed) to create/update `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` in English. Out of scope: any changes to source code, tests, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`, or `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Professional Personas
|
|
37
|
+
- **Act as a Prompt Engineer and LLM Optimization Specialist** whenever you design, write, modify, or analyze prompts, agents, skills, or documents whose target audience is an LLM Agent instead of a human reader.
|
|
38
|
+
- **Act as a Senior Technical Requirements Engineer** when analyzing source code to infer behavior: ensure every software requirement generated is atomic, unambiguous, and empirically testable.
|
|
39
|
+
- **Act as a Technical Writer** when structuring the SRS document `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`: use RFC 2119 keywords exclusively (MUST, MUST NOT, SHOULD, SHOULD NOT, MAY) and never use "shall"; maintain a clean, hierarchical Markdown structure with a maximum depth of 3 levels.
|
|
40
|
+
- **Act as a Business Analyst** when verifying the "True State": ensure the draft accurately reflects implemented logic, including limitations or bugs.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Iteration and Context Economy
|
|
44
|
+
- **CRITICAL**: Plan every Step to complete in the minimum number of iterations; batch independent reads, searches, and edits into a single response and dispatch parallel tool calls whenever no dependency forces sequencing.
|
|
45
|
+
- **CRITICAL**: Reuse injected or previously read file evidence only when repository, worktree, project-area, path, and revision identity match the active binding; do not re-read matching content. Refresh stale or unverified evidence under the pre-flight context-reuse rules.
|
|
46
|
+
- **CRITICAL**: MUST NOT restate requirement text, prior tool output, or unchanged file contents into the context; cite them by file path, symbol, and line range, quoting only the minimal changed snippet.
|
|
47
|
+
- **CRITICAL**: MUST add only information required by the active Step, a requirement ID, or explicit user-request text; omit narration, filler, restatements, and speculative commentary.
|
|
48
|
+
- **CRITICAL**: MUST choose the most token-efficient evidence path in order: `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`, then `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find`/`req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find`, then `rg`/`git grep` fallback, reading only targeted constructs and line ranges.
|
|
49
|
+
- **CRITICAL**: MUST gather all evidence a Step needs before producing its output and MUST NOT split a single logical operation across multiple iterations when one suffices.
|
|
50
|
+
- **CRITICAL**: MUST pause and wait for a tool response only when a Step explicitly depends on it; otherwise proceed autonomously to the next Step without requesting confirmation.
|
|
51
|
+
- **CRITICAL**: These rules MUST govern how the agent organizes and sequences the work described in the `## Steps` section.
|
|
52
|
+
|
|
53
|
+
## Absolute Rules, Non-Negotiable
|
|
54
|
+
- **CRITICAL**: When instructions generate shell commands, they MUST generate only linear shell commands compatible with restrictive filtering systems, MUST verify and apply correct quoting, escaping, or option termination for literal arguments that could be parsed as options or flags, MUST use explicit option termination for `rg` and `git grep` patterns beginning with `-` or `--`, MUST NOT rely on quoting or backslash escaping alone for those patterns, and MUST NOT use command substitution (`$()` or backticks), complex variable expansion, nested substitution, shell-derived helper composition, nested shell logic, or nested pipelines.
|
|
55
|
+
- **CRITICAL**: Every `req` invocation MUST carry the mandatory parameters `--prj-base={{PRJ_BASE}}` and `--git-base={{GIT_BASE}}` with the resolved values; the removed `--base` parameter MUST NOT be used.
|
|
56
|
+
- **CRITICAL**: NEVER write, modify, edit, or delete files outside of the project’s home directory, except under `/tmp`, where creating temporary files and writing outputs is allowed (the only permitted location outside the project).
|
|
57
|
+
- You can read, write, or edit `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
58
|
+
- Treat static analysis as safe. Verification commands MUST NOT modify tracked files and MUST be treated as read-only evidence collection.
|
|
59
|
+
- **CRITICAL**: Do not modify any project files except creating/updating `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
60
|
+
- **CRITICAL**: Do NOT generate or modify source code or source-code documentation in this workflow. Only create/update the requirements document(s) explicitly in scope.
|
|
61
|
+
- **CRITICAL**: Formulate all new or edited requirements using a highly structured, machine-interpretable Markdown format with unambiguous, atomic syntax to ensure maximum reliability for downstream LLM agentic reasoning, avoiding any conversational filler or subjective adjectives; the **target audience** is other **LLM Agents** and Automated Parsers, NOT humans, use high semantic density, optimized to contextually enable an LLM to perform future refactoring or extension.
|
|
62
|
+
- **CRITICAL**: NEVER add requirements to the SRS regarding how comments are handled (added/edited/deleted) within the source code, including the format, style, or language to be used, even if explicitly requested.
|
|
63
|
+
|
|
64
|
+
## Behavior
|
|
65
|
+
- Write the document in English.
|
|
66
|
+
- Do not perform unrelated edits.
|
|
67
|
+
- If `.venv/bin/python` exists in the project root, use it for Python executions (eg, `PYTHONPATH=src .venv/bin/python -m <program name>`).
|
|
68
|
+
- Non-Python tooling should use the project's standard commands.
|
|
69
|
+
- Use filesystem/shell tools to read/write/delete files as needed (e.g., `cat`, `sed`, `perl -pi`, `printf > file`, `rm -f`, ...), but only to read project files and to write/update `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`. Avoid in-place edits on any other path. Prefer read-only commands for analysis.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Execution Protocol (Global vs Local)
|
|
73
|
+
You must manage the execution flow using two distinct methods:
|
|
74
|
+
- **Global Roadmap** (*check-list*):
|
|
75
|
+
- You MUST maintain a *check-list* internally with `3` Steps (one item per Step).
|
|
76
|
+
- **Do NOT** use the *task-list tool* for this high-level roadmap.
|
|
77
|
+
- **Local Sub-tasks** (Tool Usage):
|
|
78
|
+
- If a *task-list tool* is available, use it **exclusively** to manage granular sub-tasks *within* a specific step (e.g., in Step X: "1. Edit file A", "2. Edit file B"; or in Step Y: "1. Fix test K", "2. Fix test L").
|
|
79
|
+
- Clear or reset the tool's state when transitioning between high-level steps.
|
|
80
|
+
|
|
81
|
+
## Execution Directives (absolute rules, non-negotiable)
|
|
82
|
+
During the execution flow you MUST follow these directives:
|
|
83
|
+
- **CRITICAL** Autonomous Execution:
|
|
84
|
+
- Implicit Autonomy: Execute all tasks with full autonomy. Do not request permission, confirmation, or feedback. Make executive decisions based on logic and technical best practices.
|
|
85
|
+
- Tool-Aware Workflow: Proceed through the Steps sequentially; when a tool call is required, stop and wait for the tool response before continuing. Never fabricate tool outputs or tool results. Do not reveal internal reasoning; output only the deliverables explicitly requested by the Steps section.
|
|
86
|
+
- Autonomous Resolution: Resolve `{{PRJ_BASE}}` ambiguity only through the pre-flight evidence rules; unresolved bindings trigger the context-resolution failure branch. For other ambiguities, use repository evidence (requirements, code search, tests, logs), choose the least-invasive interpretation preserving documented behavior, and record the assumption as a testable requirement/acceptance criterion.
|
|
87
|
+
- After the prompt's execution: Strictly omit all concluding remarks and do not propose any other steps/actions.
|
|
88
|
+
- **CRITICAL**: Order of Execution:
|
|
89
|
+
- Execute the numbered steps below sequentially and strictly, one at a time, without skipping or merging steps. Create and maintain a *check-list* internally while executing the Steps. Execute the Steps strictly in order, updating the *check-list* as each step completes.
|
|
90
|
+
- **CRITICAL**: Immediate start and never stop:
|
|
91
|
+
- Complete all Steps in order; you may pause only to perform required tool calls and to wait for their responses. Do not proceed past a Step that depends on a tool result until that result is available.
|
|
92
|
+
- After successful pre-flight resolution, create a *check-list* for the **Global Roadmap** and start following the roadmap from Step 1.
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Steps
|
|
96
|
+
After successful pre-flight resolution, create internally a *check-list* for the **Global Roadmap** including all the numbered steps below: `1..3`, and start following the roadmap at the same time, following the instructions of Step 1 (Generate the Software Requirements Specification). Do not add extra intent-adjustment checks unless explicitly listed in the Steps section.
|
|
97
|
+
1. Generate the **Software Requirements Specification**
|
|
98
|
+
- Read the template at `.req/docs/Requirements_Template.md` and apply its guidelines to the requirement draft.
|
|
99
|
+
- Analyze the project's main existing source code, ignoring unit test source code, documentation automation source code, and any companion scripts (e.g., launching scripts, environment management scripts, example scripts, ...), to infer the software’s behavior and main features, then produce a hierarchical requirements structure with a maximum depth of 3 levels.
|
|
100
|
+
- Requirements for the output:
|
|
101
|
+
- Describe any text-based UI and/or GUI functionality implemented.
|
|
102
|
+
- Describe the application's functionalities and configurability implemented.
|
|
103
|
+
- Describe the organization of components, objects, classes and their relationships.
|
|
104
|
+
- Include the project’s file/folder structure (tree view) with a sensible depth limit (max depth 3, or 4 for {{PRJ_BASE}}/%%SRC_PATHS%% directories) and exclude large/generated directories (e.g., `node_modules/`, `dist/`, `build/`, `target/`, `.venv/`, `.git/`).
|
|
105
|
+
- Only report performance optimizations if there is explicit evidence (e.g., comments, benchmarks, complexity-relevant changes, profiling notes, or clearly optimized code patterns). Otherwise, state ‘No explicit performance optimizations identified’.
|
|
106
|
+
- Use only this canonical requirement line format: - **<ID>**: <RFC2119 keyword> <single-sentence requirement>. Target <= 35 words per requirement; split compound behavior into separate requirement IDs. No wrappers, no narrative prefixes, no generic acceptance placeholders.
|
|
107
|
+
- Ensure every requirement is atomic, unambiguous, and formatted for maximum testability using RFC 2119 keywords (MUST, MUST NOT, SHOULD, SHOULD NOT, MAY)
|
|
108
|
+
- Write each requirement for other LLM **Agents** and Automated Parsers, NOT humans.
|
|
109
|
+
- Must be optimized for machine comprehension. Do not write flowery prose. Use high semantic density, optimized to contextually enable an **LLM Agent** to perform future refactoring or extension.
|
|
110
|
+
- Require evidence for every newly added requirement: file path + symbol/function + short excerpt (or a test that demonstrates behavior).
|
|
111
|
+
- If evidence is weak or ambiguous (e.g., based solely on naming conventions or commented-out code), strictly exclude the requirement to avoid documenting non-existent features.
|
|
112
|
+
- When describing existing functionality, describe the actual implementation logic, not the implied intent based on function names. If the code implies a feature but implements it partially, describe the partial state.
|
|
113
|
+
- Follow the template’s section schema; use headings to encode grouping.
|
|
114
|
+
- Do NOT add per-section "Scope/Grouping" requirements.
|
|
115
|
+
- Preserve Requirement IDs and keep requirements short and atomic; split compound requirements into multiple IDs.
|
|
116
|
+
- Keep document-authoring rules only in the dedicated section (no duplication).
|
|
117
|
+
- List used components and libraries ONLY if evidenced by manifest/lock/config files or direct imports; cite the file path(s) used as evidence and do not guess.
|
|
118
|
+
- Locate and read only the unit tests relevant to the inferred features/requirements; summarize test coverage at a high level and deep-dive only into failing or high-risk areas. Analyze them and provide a concise summary of the high-level functional requirements and business logic being tested.
|
|
119
|
+
- Create the **Software Requirements Specification** document at `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
120
|
+
- Ensure every requirement remains atomic, single-sentence, and testable (target <= 35 words per requirement). If acceptance criteria/procedures are needed, express them as separate requirement IDs (prefer `TST-` test requirements), not as multi-sentence sub-bullets under a single requirement.
|
|
121
|
+
- Use only this canonical requirement line format: - **<ID>**: <RFC2119 keyword> <single-sentence requirement>. Target <= 35 words per requirement; split compound behavior into separate requirement IDs. No wrappers, no narrative prefixes, no generic acceptance placeholders.
|
|
122
|
+
- Ensure every requirement is atomic, unambiguous, and formatted for maximum testability using RFC 2119 keywords (MUST, MUST NOT, SHOULD, SHOULD NOT, MAY)
|
|
123
|
+
- Write each requirement for other LLM **Agents** and Automated Parsers, NOT humans.
|
|
124
|
+
- Must be optimized for machine comprehension. Do not write flowery prose. Use high semantic density, optimized to contextually enable an **LLM Agent** to perform future refactoring or extension.
|
|
125
|
+
- Write requirements, section titles, tables, and other content in **English language**.
|
|
126
|
+
- Follow `.req/docs/Requirements_Template.md`.
|
|
127
|
+
- Output the entire response in clean, properly formatted Markdown.
|
|
128
|
+
2. Validate the **Software Requirements Specification**
|
|
129
|
+
- Review `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`. If previously read and present in context, use that content; otherwise read the file and cross-reference with the source code.
|
|
130
|
+
- Verify that the drafted requirements **accurately reflect the actual code behavior** (True State).
|
|
131
|
+
- If the code contains obvious bugs or partial implementations, ensure the requirement draft explicitly notes these limitations.
|
|
132
|
+
- Report `OK` if the draft accurately describes the code (even if the code is buggy). Report `FAIL` only if the draft makes assertions that are not present or contradicted by the source code.
|
|
133
|
+
3. Present results
|
|
134
|
+
- PRINT, in the response, the results for a human reader using clear, easily understandable sentences and readable Markdown formatting that highlight key findings, file paths, and concise evidence. Use the fixed report schema: ## **Outcome**, ## **Requirement Delta**, ## **Design Delta**, ## **Implementation Delta**, ## **Verification Delta**, ## **Evidence**, ## **Assumptions**, ## **Next Workflow**. Final line MUST be exactly: STATUS: OK or STATUS: ERROR.
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Fix a defect without changing the requirements"
|
|
3
|
+
argument-hint: "Description of the defect/bug to fix"
|
|
4
|
+
usage: >
|
|
5
|
+
Use when the user asks to fix a bug, regression, crash, or other evidenced defect without changing REQUIREMENTS.md. Restore behavior required by the SRS or supported by concrete defect evidence against documented behavior; apply the smallest safe correction and verify it. Use /req-analyze for diagnosis without edits; /req-change or /req-new when intended behavior or requirements must change; /req-refactor for behavior-preserving internal improvements; /req-cover for targeted requirement-coverage gaps.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Fix a defect without changing the requirements
|
|
9
|
+
|
|
10
|
+
## Pre-Flight: Context Keyword Resolution
|
|
11
|
+
- **CRITICAL**: Complete this read-only gate before any path-dependent action or numbered Step. Immediate-start directives apply only after success; autonomous disambiguation MUST NOT guess `{{PRJ_BASE}}` or `{{GIT_BASE}}`.
|
|
12
|
+
- Runtime keywords: resolve exactly two LLM-resolved path keywords in fixed order: `{{PRJ_BASE}}` first, `{{GIT_BASE}}` second. Installation has already supplied the documentation, source, and test paths; use them as fixed relative suffixes, not values to discover or replace.
|
|
13
|
+
- Project base: `{{PRJ_BASE}}` is the absolute base directory of the unique target project containing its installation-supplied `%%DOC_PATH%%`, `%%SRC_PATHS%%`, and `%%TEST_PATH%%` directories.
|
|
14
|
+
- Git base: `{{GIT_BASE}}` is the absolute base directory of the git repository containing `{{PRJ_BASE}}`. One git repository can contain multiple projects; repository identity alone never identifies the project.
|
|
15
|
+
- Resolution order: identify `{{PRJ_BASE}}` first and uniquely from current invocation routing and explicit task scope; use uniquely corroborated project path metadata only for missing evidence. The current directory is a candidate, not a default. Conflicting bindings, multiple plausible projects, or stale cross-project values fail resolution. Source-free workflows inspect path metadata only. After `{{PRJ_BASE}}` is bound, derive `{{GIT_BASE}}` as the git repository root containing the bound project base.
|
|
16
|
+
- Binding: retain `{{PRJ_BASE}}`, `{{GIT_BASE}}`, active worktree root, project identity, evidence, directory existence states, and document provenance throughout this invocation. Start fresh for each invocation; replace the bindings only after a validated context transition.
|
|
17
|
+
- Paths: substitute the resolved base in each prefixed path. For an installation-supplied source list, apply the base separately to every entry; preserve order and explicit list boundaries, never split on spaces or commas. Treat paths as data and quote each resulting literal argument separately, with option termination where supported.
|
|
18
|
+
- Containment: validate the base and resulting paths inside the active worktree, including symlink targets and existing ancestors of prospective paths. Accept absent directories only for authorized creation or explicitly unused source/test scopes; absence is not an unresolved base. Create nothing during pre-flight.
|
|
19
|
+
- Document contract below: filenames are relative to the installation-supplied documentation path under `{{PRJ_BASE}}`. Required inputs MUST exist; creatable targets MAY be absent. Load exactly the listed existing documents in full before Steps, including existing targets; defer reads of absent creatable targets until generated. Unlisted canonical documents are not prerequisites.
|
|
20
|
+
- Required inputs: REQUIREMENTS.md, WORKFLOW.md, REFERENCES.md.
|
|
21
|
+
- Creatable targets: none.
|
|
22
|
+
- Load when present: REQUIREMENTS.md, WORKFLOW.md, REFERENCES.md.
|
|
23
|
+
- Context reuse: treat injected or previously read content as loaded only when repository, worktree, project-area, path, and revision provenance match this binding. Current runtime attestation or unchanged-file evidence can establish a match; a basename alone cannot. Refresh stale or unverified content from the resolved path; reuse matching content without re-reading. After an edit, retain the verified updated content and invalidate superseded evidence.
|
|
24
|
+
- Operation scope: run cwd-sensitive commands and configured tools from `{{PRJ_BASE}}` only when their effective scope matches the target project; otherwise use a documented explicit-path equivalent or fail resolution.
|
|
25
|
+
- Activity routing: reference all project-modification and requirements-modification activities exclusively to `{{PRJ_BASE}}`; reference only working-tree creation and git-management activities to `{{GIT_BASE}}`.
|
|
26
|
+
- Context transitions: after an authorized worktree change, rebase `{{PRJ_BASE}}` to the same project-relative location in the new worktree and rebase `{{GIT_BASE}}` to the new worktree's repository root. Revalidate containment and document provenance before project operations; discard old absolute paths. Reuse document contents only with verified unchanged-file evidence. A different target project requires a fresh invocation.
|
|
27
|
+
- **CRITICAL**: If `{{PRJ_BASE}}` or `{{GIT_BASE}}`, required document, containment check, or effective tool scope remains unresolved or conflicting, OUTPUT exactly "ERROR: Unable to resolve context keywords!". Before isolation, terminate without cleanup; after successful isolation, follow the context-resolution failure cleanup in the isolation Step before terminating.
|
|
28
|
+
|
|
29
|
+
## Purpose
|
|
30
|
+
Restore required behavior by diagnosing and fixing a defect while keeping the normative SRS (`{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`) unchanged, so downstream LLM Agents MUST treat the fix as a semantics-correcting change rather than a requirements change.
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
In scope: reproduce/triage the defect with concrete evidence and prefer an evidence-oriented test-first flow when relevant unit-test suites exist (analyze defect -> create one failing reproducer unit test -> design and implement smallest safe fix under {{PRJ_BASE}}/%%SRC_PATHS%% -> verify reproducer passes with requirement evidence, static analysis, and conditional execution of existing unit tests via language-specific test-suite priority policy), with fallback to analyze -> implement fix -> verify only when no relevant suite exists, building that test is too costly, or one-test defect isolation is not feasible; then update `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` and `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`, and commit. Out of scope: editing requirements, adding new features, or refactoring beyond what is necessary to implement the fix safely.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Professional Personas
|
|
37
|
+
- **Act as a Prompt Engineer and LLM Optimization Specialist** whenever you design, write, modify, or analyze prompts, agents, skills, or documents whose target audience is an LLM Agent instead of a human reader.
|
|
38
|
+
- **Act as an Expert Debugger** when diagnosing defects: you MUST identify the failure symptom with concrete evidence (failure evidence, stack trace) before proposing the fix.
|
|
39
|
+
- **Act as a Senior Software Developer** when implementing a defect fix: apply the smallest safe change that restores required behavior while preserving public interfaces.
|
|
40
|
+
- **Act as a Business Analyst** when reading `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` to ensure that fixes or refactors never violate or change existing documented behaviors.
|
|
41
|
+
- **Act as a QA Automation Engineer** when validating the fix/refactor: ensure that static-analysis results are clean (or no-source positive) and no regressions in documented behavior are introduced.
|
|
42
|
+
- **Act as an Expert GitOps Engineer** when executing git workflows, especially when creating/removing/managing git worktrees to isolate changes safely.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Iteration and Context Economy
|
|
46
|
+
- **CRITICAL**: Plan every Step to complete in the minimum number of iterations; batch independent reads, searches, and edits into a single response and dispatch parallel tool calls whenever no dependency forces sequencing.
|
|
47
|
+
- **CRITICAL**: Reuse injected or previously read file evidence only when repository, worktree, project-area, path, and revision identity match the active binding; do not re-read matching content. Refresh stale or unverified evidence under the pre-flight context-reuse rules.
|
|
48
|
+
- **CRITICAL**: MUST NOT restate requirement text, prior tool output, or unchanged file contents into the context; cite them by file path, symbol, and line range, quoting only the minimal changed snippet.
|
|
49
|
+
- **CRITICAL**: MUST add only information required by the active Step, a requirement ID, or explicit user-request text; omit narration, filler, restatements, and speculative commentary.
|
|
50
|
+
- **CRITICAL**: MUST choose the most token-efficient evidence path in order: `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`, then `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find`/`req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find`, then `rg`/`git grep` fallback, reading only targeted constructs and line ranges.
|
|
51
|
+
- **CRITICAL**: MUST gather all evidence a Step needs before producing its output and MUST NOT split a single logical operation across multiple iterations when one suffices.
|
|
52
|
+
- **CRITICAL**: MUST pause and wait for a tool response only when a Step explicitly depends on it; otherwise proceed autonomously to the next Step without requesting confirmation.
|
|
53
|
+
- **CRITICAL**: These rules MUST govern how the agent organizes and sequences the work described in the `## Steps` section.
|
|
54
|
+
|
|
55
|
+
## Pre-requisite: Execution Context
|
|
56
|
+
- **CRITICAL**: All information declared in this `Pre-requisite: Execution Context` section MUST remain continuously available in the active execution context for the entire workflow and MUST NEVER be dropped, forgotten, or overwritten.
|
|
57
|
+
- Generate <WORKTREE_NAME> with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-name`, retain the literal result for later steps, and use simple sequential execution with only linear shell commands compatible with restrictive filtering systems for all worktree operations in this workflow.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Absolute Rules, Non-Negotiable
|
|
61
|
+
- **CRITICAL**: When instructions generate shell commands, they MUST generate only linear shell commands compatible with restrictive filtering systems, MUST verify and apply correct quoting, escaping, or option termination for literal arguments that could be parsed as options or flags, MUST use explicit option termination for `rg` and `git grep` patterns beginning with `-` or `--`, MUST NOT rely on quoting or backslash escaping alone for those patterns, and MUST NOT use command substitution (`$()` or backticks), complex variable expansion, nested substitution, shell-derived helper composition, nested shell logic, or nested pipelines.
|
|
62
|
+
- **CRITICAL**: Every `req` invocation MUST carry the mandatory parameters `--prj-base={{PRJ_BASE}}` and `--git-base={{GIT_BASE}}` with the resolved values; the removed `--base` parameter MUST NOT be used.
|
|
63
|
+
- **CRITICAL**: NEVER write, modify, edit, or delete files outside of the active git worktree directory, except under `/tmp`, and except for worktree operations executed through `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-create <WORKTREE_NAME>` and `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`.
|
|
64
|
+
- You MUST read `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, but you MUST NOT modify it in this workflow.
|
|
65
|
+
- Treat static analysis as safe. Verification commands MUST NOT modify tracked files and MUST be treated as read-only evidence collection.
|
|
66
|
+
- **CRITICAL**: GIT operations and GIT rules:
|
|
67
|
+
- Do not run any shell/git commands and do not modify any files before starting Step 1 (including creating/modifying files, installing deps, formatting, etc.), except the read-only repository checks required by the `## Pre-Flight: Context Keyword Resolution` section: **CRITICAL**: Check GIT Status.
|
|
68
|
+
- Step 1 may run only the git commands `git rev-parse --is-inside-work-tree`, `git rev-parse --verify HEAD`, `git status --porcelain`, and `git symbolic-ref -q HEAD` (plus minimal shell built-ins to combine their outputs into a single cleanliness check).
|
|
69
|
+
- If the repository is NOT clean (modified files, staged changes, OR untracked files), exit immediately without changing anything.
|
|
70
|
+
- At the end you MUST commit only the intended changes with a unique identifier and change description in the commit message.
|
|
71
|
+
- Leave the working tree AND index clean (git `status --porcelain` must be empty).
|
|
72
|
+
- Do NOT “fix” a dirty repo by force (no `git reset --hard`, no `git clean -fd`, no stash) unless explicitly requested. If dirty: abort.
|
|
73
|
+
- **CRITICAL**: Generate, update, and maintain comprehensive **Doxygen-style documentation** for **ALL** code components (functions, classes, objects, structures, modules, variables, and new implementations), according to the **guidelines** in `.req/docs/Document_Source_Code_in_Doxygen_Style.md`. When writing documentation, adopt a "Parser-First" mindset. Your output is not prose; it is semantic metadata. Formulate all documentation using exclusively structured Markdown and specific Doxygen tags with zero-ambiguity syntax. Eliminate conversational filler ("This function...", "Basically..."). Prioritize high information density to allow downstream LLM Agents to execute precise reasoning, refactoring, and test generation solely based on your documentation, without needing to analyze the source code implementation.
|
|
74
|
+
- **CRITICAL**: Formulate all new or edited requirements and all source code information using a highly structured, machine-interpretable Markdown format with unambiguous, atomic syntax to ensure maximum reliability for downstream LLM agentic reasoning, avoiding any conversational filler or subjective adjectives; the **target audience** is other **LLM Agents** and Automated Parsers, NOT humans, use high semantic density, optimized to contextually enable an LLM to perform future refactoring or extension.
|
|
75
|
+
- **CRITICAL**: NEVER add requirements to SRS regarding how comments are handled (added/edited/deleted) within the source code, including the format, style, or language to be used, even if explicitly requested. Ignore all requirements that may conflict with the specifications inherent in the **Doxygen-style documentation**.
|
|
76
|
+
|
|
77
|
+
## Behavior
|
|
78
|
+
- Do not modify `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
79
|
+
- Always strictly respect requirements.
|
|
80
|
+
- Use `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`, and `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md` as the primary technical inputs; keep decisions traceable to requirements and repository evidence.
|
|
81
|
+
- When relevant unit-test suites exist, prefer this fix sequence: analyze and identify defect -> create one failing reproducer unit test -> design and implement source fix -> verify reproducer passes using requirement evidence, static analysis, and selected unit-test suites.
|
|
82
|
+
- Only if no relevant suite exists, creating that test is too costly under test guidelines, or one-test defect isolation is not feasible, use fallback sequence: analyze and identify defect -> implement source fix -> verify resolution with explicit concrete evidence.
|
|
83
|
+
- All newly written or edited content MUST be in English. Do NOT translate existing text outside the minimal change surface required by this workflow; if you detect non-English text elsewhere, report it in **Evidence** instead of rewriting it.
|
|
84
|
+
- Prioritize backward compatibility. Do not introduce breaking changes; preserve existing interfaces, data formats, and features.
|
|
85
|
+
- If maintaining compatibility would require migrations/auto-upgrades conversion logic, report the conflict instead of implementing, and then terminate the execution.
|
|
86
|
+
- If `.venv/bin/python` exists in the project root, use it for Python executions (eg, `PYTHONPATH=src .venv/bin/python -m <program name>`).
|
|
87
|
+
- Non-Python tooling should use the project's standard commands.
|
|
88
|
+
- Use filesystem/shell tools to read/write/delete files as needed (e.g., `cat`, `sed`, `perl -pi`, `printf > file`, `rm -f`, ...). Prefer read-only commands for analysis.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## WORKFLOW.md Runtime Model (canonical)
|
|
92
|
+
- **Execution Unit** = OS process or OS thread (MUST include the main process).
|
|
93
|
+
- **Internal function** = defined under {{PRJ_BASE}}/%%SRC_PATHS%% (only these can appear as call-trace nodes).
|
|
94
|
+
- **External boundary** = not defined under {{PRJ_BASE}}/%%SRC_PATHS%% (MUST NOT appear as call-trace nodes).
|
|
95
|
+
- `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` MUST always be written and maintained in English and MUST preserve the schema: `Execution Units Index` / `Execution Units` / `Communication Edges`.
|
|
96
|
+
|
|
97
|
+
## Source Code Analysis Toolkit
|
|
98
|
+
Four complementary pillars provide a complete, token-efficient source code analysis pipeline. Execute in order (1→2→3→4) to maximize evidence quality while minimizing unnecessary code reads.
|
|
99
|
+
|
|
100
|
+
### 1. Runtime Model: `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`
|
|
101
|
+
Compact document — read in full. Contains:
|
|
102
|
+
- **Execution Units Index**: all OS processes and threads with roles and entrypoints.
|
|
103
|
+
- **Execution Units**: per-unit internal call-trace trees showing function call order, defining file paths, and external boundaries.
|
|
104
|
+
- **Communication Edges**: inter-unit data flow (direction, mechanism, payload).
|
|
105
|
+
|
|
106
|
+
Use to: identify which execution units (processes/threads) are involved, trace call-order through internal functions, understand data flow between components. Build a runtime mental model before reading any code.
|
|
107
|
+
|
|
108
|
+
### 2. Symbol Index: `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`
|
|
109
|
+
Structured index of all source-defined symbols (functions, classes, structs, objects, data structures) with file paths and line numbers. Per-symbol Doxygen-style fields may include:
|
|
110
|
+
- `@brief`: single-line technical description of the symbol's action.
|
|
111
|
+
- `@details`: high-density algorithmic summary (LLM-optimized, not prose).
|
|
112
|
+
- `@param` / `@param[out]`: input parameters with type constraints; mutated reference/pointer arguments.
|
|
113
|
+
- `@return` / `@retval`: output data structure or specific return values.
|
|
114
|
+
- `@exception` / `@throws`: error states and specific exception classes.
|
|
115
|
+
- `@satisfies`: linked requirement IDs (e.g., `@satisfies REQ-026, REQ-045`).
|
|
116
|
+
- `@pre` / `@post`: pre-conditions and post-conditions.
|
|
117
|
+
- `@warning`: critical usage hazards.
|
|
118
|
+
- `@note`: vital implementation details.
|
|
119
|
+
- `@see` / `@sa`: related symbols for context linkage.
|
|
120
|
+
- `@deprecated`: replacement API link.
|
|
121
|
+
|
|
122
|
+
Use to: identify candidate symbols by name, description, or `@satisfies` link; obtain exact file paths and line ranges; understand function signatures and contracts before extracting code. Cross-reference with WORKFLOW.md call-traces to narrow scope.
|
|
123
|
+
|
|
124
|
+
### 3. Code Extraction: `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find` / `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find`
|
|
125
|
+
Extract actual source constructs as structured markdown with signatures, line ranges, and optional line-numbered code. Use after pillars 1-2 to extract only the targeted constructs identified during analysis.
|
|
126
|
+
#### What these commands do (and what they don't)
|
|
127
|
+
- Extract named constructs (e.g., CLASS, FUNCTION, STRUCT, INTERFACE, IMPORT, …) filtered by TAG and name-regex.
|
|
128
|
+
- Regex (PATTERN) matches construct name only (not body). For body-content search, use rg/git grep (pillar 4).
|
|
129
|
+
- Output per file: header `@@@ <filepath> | <language>`, per-construct blocks with:
|
|
130
|
+
- `### <TAG>: <name>` + optional Signature + `Lines: <start>-<end>`
|
|
131
|
+
- optional extracted Doxygen fields (if present in/around the construct)
|
|
132
|
+
- fenced code block with the complete construct slice (comments stripped, strings preserved)
|
|
133
|
+
#### Choose the right mode
|
|
134
|
+
- Project-wide scan: use --find (the mandatory `--prj-base`/`--git-base` prefix is required; `--base` is forbidden)
|
|
135
|
+
- Syntax: `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find <TAG_FILTER> <NAME_REGEX>`
|
|
136
|
+
- Note: --find scans all files under configured source dirs; does not take a filename.
|
|
137
|
+
- Target specific files: use --files-find (standalone with the mandatory `--prj-base`/`--git-base` prefix)
|
|
138
|
+
- Syntax: `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find <TAG_FILTER> <NAME_REGEX> <FILE1> [FILE2 ...]`
|
|
139
|
+
#### Enable line-numbered code for evidence citation
|
|
140
|
+
Add --enable-line-numbers (code lines prefixed as `<n>:`):
|
|
141
|
+
- `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --enable-line-numbers --find "<TAG_FILTER>" "<NAME_REGEX>"`
|
|
142
|
+
- `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --enable-line-numbers --files-find "<TAG_FILTER>" "<NAME_REGEX>" <FILE...>`
|
|
143
|
+
#### TAGs and filters
|
|
144
|
+
- TAG_FILTER: pipe-separated, case-insensitive (e.g., `CLASS|FUNCTION|IMPORT`).
|
|
145
|
+
- Tags are language-dependent; unsupported tags are ignored. Run `req -h` for supported TAGs per language.
|
|
146
|
+
- Broad cross-language TAG_FILTER: `CLASS|STRUCT|ENUM|INTERFACE|TRAIT|IMPL|FUNCTION|METHOD|MODULE|NAMESPACE|TYPE_ALIAS|TYPEDEF|IMPORT|CONSTANT|VARIABLE|MACRO|DECORATOR|COMPONENT|PROPERTY|PROTOCOL|EXTENSION|UNION`
|
|
147
|
+
#### Regex rules (NAME_REGEX)
|
|
148
|
+
- Regex matching follows `re.search()` semantics against construct names (tool behavior, independent of repository language).
|
|
149
|
+
- Prefer anchored patterns: exact `^Foo$`, prefix `^parse_`, suffix `Service$`. Use `.*` only when scope is already constrained by files/TAGs.
|
|
150
|
+
#### Failure modes you must handle
|
|
151
|
+
- "No constructs found": adjust TAGs (supported?), file paths, or NAME_REGEX (valid regex?).
|
|
152
|
+
- Regex-based extractor (not full AST): treat results as evidence pointers; confirm edge cases by opening referenced file/lines.
|
|
153
|
+
|
|
154
|
+
### 4. Supplementary Search: `rg` / `git grep`
|
|
155
|
+
Use for: string/pattern searches inside code bodies, cross-file references, configuration values, error messages, or any content not captured by construct-name-based extraction.
|
|
156
|
+
|
|
157
|
+
### Recommended Analysis Workflow
|
|
158
|
+
1. **Read `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`** (full read) → identify execution units, call-trace paths, and function names relevant to the task.
|
|
159
|
+
2. **Read `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`** (full read or targeted search) → locate candidate symbols by name/description/`@satisfies`, obtain file paths and line ranges, understand function contracts.
|
|
160
|
+
3. **Extract code** via `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find`/`req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find` → use symbol names from steps 1-2 as NAME_REGEX, file paths as --files-find targets; enable --enable-line-numbers when citing evidence.
|
|
161
|
+
4. **Search code bodies** via `rg`/`git grep` → find patterns, references, or values not captured by construct-level extraction.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## Execution Protocol (Global vs Local)
|
|
165
|
+
You must manage the execution flow using two distinct methods:
|
|
166
|
+
- **Global Roadmap** (*check-list*):
|
|
167
|
+
- You MUST maintain a *check-list* internally with `10` Steps (one item per Step).
|
|
168
|
+
- **Do NOT** use the *task-list tool* for this high-level roadmap.
|
|
169
|
+
- **Local Sub-tasks** (Tool Usage):
|
|
170
|
+
- If a *task-list tool* is available, use it **exclusively** to manage granular sub-tasks *within* a specific step (e.g., in Step X: "1. Edit file A", "2. Edit file B"; or in Step Y: "1. Fix test K", "2. Fix test L").
|
|
171
|
+
- Clear or reset the tool's state when transitioning between high-level steps.
|
|
172
|
+
|
|
173
|
+
## Execution Directives (absolute rules, non-negotiable)
|
|
174
|
+
During the execution flow you MUST follow these directives:
|
|
175
|
+
- **CRITICAL** Autonomous Execution:
|
|
176
|
+
- Implicit Autonomy: Execute all tasks with full autonomy. Do not request permission, confirmation, or feedback. Make executive decisions based on logic and technical best practices.
|
|
177
|
+
- Tool-Aware Workflow: Proceed through the Steps sequentially; when a tool call is required, stop and wait for the tool response before continuing. Never fabricate tool outputs or tool results. Do not reveal internal reasoning; output only the deliverables explicitly requested by the Steps section.
|
|
178
|
+
- Autonomous Resolution: Resolve `{{PRJ_BASE}}` ambiguity only through the pre-flight evidence rules; unresolved bindings trigger the context-resolution failure branch. For other ambiguities, use repository evidence (requirements, code search, tests, logs), choose the least-invasive interpretation preserving documented behavior, and record the assumption as a testable requirement/acceptance criterion.
|
|
179
|
+
- After the prompt's execution: Strictly omit all concluding remarks and do not propose any other steps/actions.
|
|
180
|
+
- **CRITICAL**: Order of Execution:
|
|
181
|
+
- Execute the numbered steps below sequentially and strictly, one at a time, without skipping or merging steps. Create and maintain a *check-list* internally while executing the Steps. Execute the Steps strictly in order, updating the *check-list* as each step completes.
|
|
182
|
+
- **CRITICAL**: Immediate start and never stop:
|
|
183
|
+
- Complete all Steps in order; you may pause only to perform required tool calls and to wait for their responses. Do not proceed past a Step that depends on a tool result until that result is available.
|
|
184
|
+
- After successful pre-flight resolution, create a *check-list* for the **Global Roadmap** and start following the roadmap from Step 1.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Steps
|
|
188
|
+
After successful pre-flight resolution, create internally a *check-list* for the **Global Roadmap** including all the numbered steps below: `1..10`, and start following the roadmap at the same time, executing the tool call of Step 1 (Check GIT Status). If a tool call is required in Step 1, invoke it immediately; otherwise proceed to Step 1 without additional commentary. Do not add extra intent-adjustment checks unless explicitly listed in the Steps section.
|
|
189
|
+
1. **CRITICAL**: Check GIT Status
|
|
190
|
+
- Check GIT status with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-check`. If the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Git status unclear!", and then terminate the execution.
|
|
191
|
+
2. **CRITICAL**: Check `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` and `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md` file presence
|
|
192
|
+
- Check required docs presence with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --docs-check`. If the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Required docs check failed!", and then terminate the execution.
|
|
193
|
+
3. **CRITICAL**: Worktree Generation & Isolation
|
|
194
|
+
- Derive <BASE_PATH> with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --get-base-path`, derive <GIT_PATH> with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-path`, and generate <WORKTREE_NAME> with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-name` using literal `req` commands executed sequentially without shell composition.
|
|
195
|
+
- Create the dedicated isolated worktree with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-create <WORKTREE_NAME>`, then execute `cd <GIT_PATH>/../<WORKTREE_NAME>` before proceeding to the next step.
|
|
196
|
+
- If the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Worktree generation failed!", and then terminate the execution.
|
|
197
|
+
- After successful worktree creation and directory change, apply the pre-flight context-transition rules before the next project operation. If rebinding fails, OUTPUT exactly "ERROR: Unable to resolve context keywords!", delete the isolated worktree and branch with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`, and then terminate the execution. Apply this same failure cleanup to later context-resolution failures before merge-phase cleanup.
|
|
198
|
+
|
|
199
|
+
4. Read requirements, generate **Design Delta** and implement the **Implementation Delta** to fix the defect
|
|
200
|
+
- Using [User Request](#users-request) as a unified semantic framework, extract all directly and tangentially related information from `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` and `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`, prioritizing high recall to capture every borderline connection across both sources, to identify the most likely related files and functions based on explicit evidence, and treat any uncertain links as candidates without claiming completeness, then analyze the involved source code from {{PRJ_BASE}}/%%SRC_PATHS%% and GENERATE a detailed **Implementation Delta** documenting the exact modifications to the source code that fix the bug/defect described by the [User Request](#users-request). The **Implementation Delta** MUST be implementation-only and patch-oriented: for each file, list exact edits (functions/classes touched), include only changed snippets, and map each change to the requirement ID(s) it satisfies (no narrative summary)
|
|
201
|
+
- **ENFORCEMENT**: The definition of "valid code" strictly includes its documentation. You are mandatorily required to apply the Doxygen-LLM Standard defined in `.req/docs/Document_Source_Code_in_Doxygen_Style.md` to every single code component. Any code block generated without this specific documentation format is considered a compilation error and must be rejected/regenerated.
|
|
202
|
+
- Read %%GUIDELINES_FILES%% files and apply those **guidelines**; ensure the proposed code changes conform to those **guidelines**, and adjust the **Implementation Delta** if needed. Do not apply unrelated **guidelines**.
|
|
203
|
+
- Locate existing unit tests in {{PRJ_BASE}}/%%TEST_PATH%% that map to touched modules and requirement IDs; when relevant suites exist, add one targeted failing reproducer unit test for the defect before implementing source fixes. Define in the **Implementation Delta** which suites will run during verification using language-specific test-suite priority policy, and treat verification tests as N/A when no relevant unit tests exist.
|
|
204
|
+
- **CRITICAL**: All tests MUST implement these instructions: `.req/docs/HDT_Test_Authoring_Guide.md`.
|
|
205
|
+
- Read %%GUIDELINES_FILES%% files and apply those **guidelines**; ensure the proposed code changes conform to those **guidelines**, and adjust the **Implementation Delta** if needed. Do not apply unrelated **guidelines**.
|
|
206
|
+
- A change is allowed ONLY if it corrects behavior that is: (a) explicitly required by `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` (cite requirement ID/section) OR (b) a defect with concrete evidence (crash, security flaw, data corruption, failure evidence, or incorrect output that contradicts a specific documented behavior). If the request implies new requirements or changing documented behavior, recommend `/req-new` or `/req-change`; before terminating, OUTPUT a Markdown table with exactly three columns in this order: `Requirement ID`, `Conflicting Excerpt`, `Conflict Reason + Interrupted Implementation Intent`; each row MUST map one conflicting requirement to the implementation-contrast rationale and intended interrupted modification; then OUTPUT exactly "ERROR: Defect fix failed due to incompatible requirements!", and then delete the isolated worktree and branch with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`, and then terminate the execution.
|
|
207
|
+
- Preferred execution order for Step 4 when relevant suites exist: analyze and identify defect -> create one failing reproducer unit test -> design and implement source fix -> verify reproducer and full selected suites.
|
|
208
|
+
- IMPLEMENT the **Implementation Delta** in the source code (creating new files/directories if necessary). You may make minimal mechanical adjustments needed to fit the actual codebase (file paths, symbol names), but you MUST NOT add new features or scope beyond the **Implementation Delta**.
|
|
209
|
+
5. Generate **Verification Delta** by verifying static-analysis results and implementing needed bug fixes
|
|
210
|
+
- Read `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` and cross-reference with the source code from {{PRJ_BASE}}/%%SRC_PATHS%%, {{PRJ_BASE}}/%%TEST_PATH%% to check ALL requirements, but use progressive disclosure: provide full evidence only for `FAIL` items and a compact pointer-only index for `OK` items. For each requirement, use tools (e.g., `git grep`, `find`, `ls`) to locate the relevant source code files used as evidence, read only the identified files to verify compliance and do not assume compliance without locating the specific code implementation.
|
|
211
|
+
- For each requirement, report `OK` if satisfied or `FAIL` if not.
|
|
212
|
+
- Do not mark a requirement as `OK` without code evidence; for `OK` items provide only a compact pointer (file path + symbol + line range). For each requirement, provide a concise evidence pointer (file path + symbol + line range) excerpts only for `FAIL` requirements or when requirement is architectural, structural, or negative (e.g., "MUST NOT ..."). For such high-level requirements, cite the specific file paths or directory structures that prove compliance. Line ranges MUST be obtained from tooling output (e.g., `nl -ba` / `sed -n`) and MUST NOT be estimated. If evidence is missing, you MUST report `FAIL`. Do not assume implicit behavior.
|
|
213
|
+
- For every `FAIL`, provide evidence with a short explanation. Provide file path(s) and line numbers where possible.
|
|
214
|
+
- Perform a static analysis check by executing `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --static-check`.
|
|
215
|
+
- Review the produced output and fix every reported issue in source code.
|
|
216
|
+
- Re-run `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --static-check` until it produces no issues. If output is exactly `Error: no source files found in configured directories.`, treat it as successful no-source completion and continue without retries.
|
|
217
|
+
- If relevant unit tests already exist in the repository, run them during verification using language-specific test-suite priority policy: project-defined test command first, language-default unit-test command second; if a reproducer unit test was created in Step 4, require explicit evidence that it now passes; if no relevant tests exist, record test execution as N/A and continue.
|
|
218
|
+
- Verify that the implemented changes satisfy requirements evidence, static-analysis output, and unit-test outputs when tests are executed.
|
|
219
|
+
- For Step 4, include before/after evidence that links the observed defect to the applied source fix.
|
|
220
|
+
- Provide explicit concrete verification evidence that the defect is resolved, using requirement evidence and static-analysis output.
|
|
221
|
+
- If static analysis reports issues or executed unit tests fail, analyze whether they are caused by source defects or requirement-implementation mismatch. Assume requirement evidence is authoritative; when static analysis reports issues, fix source code unless requirements explicitly justify alternative handling.
|
|
222
|
+
- Fix the source code to resolve valid verification findings autonomously without asking for user intervention. Execute a strict fix loop: 1) analyze static-check output and unit-test failures (when tests ran), 2) determine root cause from evidence, 3) fix code, 4) re-run `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --static-check` and re-run the selected unit-test suites when applicable. Repeat up to 2 times. If static analysis still reports issues after the second attempt, report the failure, OUTPUT exactly "ERROR: Defect fix failed due to inability to complete static analysis!", delete the isolated worktree and branch with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`, and then terminate the execution.
|
|
223
|
+
- Limitations: Do not introduce new features or change the architecture logic during this fix phase; if a fix requires substantial refactoring or requirements changes, report the failure, then OUTPUT exactly "ERROR: Defect fix failed due to requirements incompatible with static-analysis constraints!", delete the isolated worktree and branch with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`, and then terminate the execution.
|
|
224
|
+
- Do NOT create or modify tests outside the defect-focused scope; only the targeted reproducer test and strictly related assertions/fixtures may be changed when required by updated behavior.
|
|
225
|
+
6. Update `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` via targeted edits using the canonical WORKFLOW.md contract (same terminology, same schema, same call-trace rules) and declaration file paths only, excluding line numbers, line ranges, and internal file-reference pointers.
|
|
226
|
+
- Update `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` as an LLM-first runtime model (English only) using a TARGETED EDIT policy.
|
|
227
|
+
- During generation/update, include declaration file paths only; MUST NOT include line numbers, line ranges, or internal file-reference pointers.
|
|
228
|
+
- Determine the change surface from repository evidence: run `git diff --name-only` and `git diff` to identify the modified files/symbols under {{PRJ_BASE}}/%%SRC_PATHS%%.
|
|
229
|
+
- Modify ONLY the WORKFLOW.md sections impacted by those changes (execution unit index entries, execution unit subsections, and communication edges); preserve stable IDs and do not rewrite unrelated content.
|
|
230
|
+
- Ensure global consistency: if a changed internal symbol appears in any call-trace, update all affected call-trace nodes; if a unit/edge is added/removed, reflect it.
|
|
231
|
+
- Analyze only files under {{PRJ_BASE}}/%%SRC_PATHS%% (everything else is out of scope) and identify ALL runtime execution units:
|
|
232
|
+
- OS processes (MUST include the main process).
|
|
233
|
+
- OS threads (per process), including their entry functions/methods.
|
|
234
|
+
- If no explicit thread creation is present, record "no explicit threads detected" for that process.
|
|
235
|
+
- For EACH execution unit, generate a complete internal call-trace tree starting from its entrypoint(s):
|
|
236
|
+
- Include ONLY internal functions/methods defined in repository source under {{PRJ_BASE}}/%%SRC_PATHS%%.
|
|
237
|
+
- Do NOT include external boundaries (system/library/framework calls) as nodes; annotate them only as external boundaries where relevant.
|
|
238
|
+
- No maximum depth: expand until an internal leaf function or an external boundary is reached.
|
|
239
|
+
- Identify and document ALL Communication Edges between Execution Units:
|
|
240
|
+
- For each edge: direction (source -> destination), mechanism, endpoint/channel, payload/data-shape reference, and declaration file path references only.
|
|
241
|
+
- Preserve and maintain the canonical `WORKFLOW.md` schema:
|
|
242
|
+
- `## Execution Units Index`
|
|
243
|
+
- `## Execution Units`
|
|
244
|
+
- `## Communication Edges`
|
|
245
|
+
- Use stable execution unit IDs: `PROC:main`, `PROC:<name>` for processes; `THR:<proc_id>#<name>` for threads.
|
|
246
|
+
- Call-trace node format (MUST be consistent):
|
|
247
|
+
- `symbol_name(...)`: `<single-line role>` [`<defining filepath>`]
|
|
248
|
+
- `<optional: brief invariants/external boundaries>`
|
|
249
|
+
- `<child internal calls as nested bullet list, in call order>`
|
|
250
|
+
7. Update `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md` references file
|
|
251
|
+
- Create/update the references file with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --references >"{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md"`
|
|
252
|
+
8. **CRITICAL**: Stage & commit
|
|
253
|
+
- Show a summary of changes with `git diff` and `git diff --stat`.
|
|
254
|
+
- Stage changes explicitly (prefer targeted add; avoid `git add -A` if it may include unintended files): `git add <file...>` (ensure to include all modified source code & test and WORKFLOW.md only if it was modified/created).
|
|
255
|
+
- Ensure there is something to commit with: `git diff --cached --quiet && echo "Nothing to commit. Aborting."`. If command output contains "Aborting", OUTPUT exactly "No changes to commit.", and then delete the isolated worktree and branch with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`, and then terminate the execution.
|
|
256
|
+
- Commit a structured commit message with: `git commit -m "fix(<COMPONENT>)<BREAKING>: <DESCRIPTION> [useReq]"`
|
|
257
|
+
- Set `<COMPONENT>` to the most specific component, module, or function affected. If multiple areas are touched, choose the primary one. If you cannot identify a unique component, use `core`.
|
|
258
|
+
- Set `<DESCRIPTION>` to a short, clear summary in **English language** of what changed, including (when applicable) updates to: requirements/specs, source code, tests. Use present tense, avoid vague wording, and keep it under ~80 characters if possible.
|
|
259
|
+
- Set `<BREAKING>` to `!` if a breaking change was implemented (a modification to an API, library, or system that breaks backward compatibility, causing dependent client applications or code to fail or behave incorrectly), set empty otherwise.
|
|
260
|
+
- Include main features added, requirements changes, or a bug-fix description adding a multi-line comment (maximum 10 lines).
|
|
261
|
+
- Do not include the 'Co-authored-by' trailer or any AI attribution. A GPG-signed commit is not required.
|
|
262
|
+
- Confirm the repo is clean with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-check`. If the command returns an error code or prints any text containing "ERROR", override the final line with EXACTLY "WARNING: Defect fix completed with unclean git repository!".
|
|
263
|
+
9. **CRITICAL**: Merge Conflict Management
|
|
264
|
+
- Return to the original repository directory (the sibling directory of the worktree).
|
|
265
|
+
- Ensure you are on the original branch used before worktree creation by deriving `<BASE_PATH>` with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --get-base-path` if needed and executing `cd <BASE_PATH>`.
|
|
266
|
+
- Merge the isolated branch into the original branch: `git merge <WORKTREE_NAME>`
|
|
267
|
+
- If the merge completes successfully, delete the isolated worktree and branch with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --git-wt-delete <WORKTREE_NAME>`; if the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Worktree cleanup verification failed!", and then terminate the execution.
|
|
268
|
+
- If the merge fails or results in conflicts, do NOT remove the worktree directory and override the final line with EXACTLY "WARNING: Defect fix completed with merge conflicting!".
|
|
269
|
+
10. Present results
|
|
270
|
+
- PRINT, in the response, the results for a human reader using clear, easily understandable sentences and readable Markdown formatting that highlight key findings, file paths, and concise evidence. Use the fixed report schema: ## **Outcome**, ## **Requirement Delta**, ## **Design Delta**, ## **Implementation Delta**, ## **Verification Delta**, ## **Evidence**, ## **Assumptions**, ## **Next Workflow**. Final line MUST be exactly: STATUS: OK or STATUS: ERROR.
|
|
271
|
+
|
|
272
|
+
<h2 id="users-request">User's Request</h2>
|
|
273
|
+
%%ARGS%%
|