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,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Write a REFERENCES.md using the project's source code"
|
|
3
|
+
argument-hint: "No arguments utilized by the prompt logic"
|
|
4
|
+
usage: >
|
|
5
|
+
Use when the user asks to create, regenerate, or update REFERENCES.md as a source-derived repository navigation and symbol index. Change only that document and commit the update. Use /req-workflow for the runtime execution model, /req-flowchart for a Mermaid runtime diagram, or /req-analyze for an investigation without file edits. Do not select for general reference research, requirements changes, implementation, tests, or edits to other documents.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Write a REFERENCES.md 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: REFERENCES.md.
|
|
22
|
+
- Load when present: 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
|
+
Maintain a machine-usable reference index (`{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`) derived from repository evidence so downstream LLM Agents MUST quickly discover entrypoints, modules, dependencies, and other navigational anchors during SRS-driven work.
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
In scope: generate/update only `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md` in English (following the prompt’s `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --references` workflow) and commit that doc change. Out of scope: changes to requirements, workflow docs, source code, or tests.
|
|
34
|
+
|
|
35
|
+
## Professional Personas
|
|
36
|
+
- **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.
|
|
37
|
+
- **Act as a Senior System Engineer** when analyzing source code and directory structures to understand the system's architecture and logic.
|
|
38
|
+
- **Act as a Technical Writer** when producing the final reference index, ensuring clarity, technical precision, and structured formatting.
|
|
39
|
+
- **Act as an Expert GitOps Engineer** when executing git workflows, especially when creating/removing/managing git worktrees to isolate changes safely.
|
|
40
|
+
|
|
41
|
+
## Iteration and Context Economy
|
|
42
|
+
- **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.
|
|
43
|
+
- **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.
|
|
44
|
+
- **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.
|
|
45
|
+
- **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.
|
|
46
|
+
- **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.
|
|
47
|
+
- **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.
|
|
48
|
+
- **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.
|
|
49
|
+
- **CRITICAL**: These rules MUST govern how the agent organizes and sequences the work described in the `## Steps` section.
|
|
50
|
+
|
|
51
|
+
## Pre-requisite: Execution Context
|
|
52
|
+
- **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.
|
|
53
|
+
- 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.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Absolute Rules, Non-Negotiable
|
|
57
|
+
- **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.
|
|
58
|
+
- **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.
|
|
59
|
+
- **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>`.
|
|
60
|
+
- You can read, write, or edit `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`.
|
|
61
|
+
- Treat static analysis as safe. Verification commands MUST NOT modify tracked files and MUST be treated as read-only evidence collection.
|
|
62
|
+
- **CRITICAL**: Do not modify any project files except creating/updating `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`.
|
|
63
|
+
- **CRITICAL**: GIT operations and GIT rules:
|
|
64
|
+
- 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.
|
|
65
|
+
- 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).
|
|
66
|
+
- If the repository is NOT clean (modified files, staged changes, OR untracked files), exit immediately without changing anything.
|
|
67
|
+
- At the end you MUST commit only the intended changes with a unique identifier and change description in the commit message.
|
|
68
|
+
- Leave the working tree AND index clean (git `status --porcelain` must be empty).
|
|
69
|
+
- Do NOT “fix” a dirty repo by force (no `git reset --hard`, no `git clean -fd`, no stash) unless explicitly requested. If dirty: abort.
|
|
70
|
+
|
|
71
|
+
## Behavior
|
|
72
|
+
- Do not perform unrelated edits.
|
|
73
|
+
- If `.venv/bin/python` exists in the project root, use it for Python executions (eg, `PYTHONPATH=src .venv/bin/python -m <program name>`).
|
|
74
|
+
- Non-Python tooling should use the project's standard commands.
|
|
75
|
+
- 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%%/REFERENCES.md`. Avoid in-place edits on any other path. Prefer read-only commands for analysis.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Execution Protocol (Global vs Local)
|
|
79
|
+
You must manage the execution flow using two distinct methods:
|
|
80
|
+
- **Global Roadmap** (*check-list*):
|
|
81
|
+
- You MUST maintain a *check-list* internally with `6` Steps (one item per Step).
|
|
82
|
+
- **Do NOT** use the *task-list tool* for this high-level roadmap.
|
|
83
|
+
- **Local Sub-tasks** (Tool Usage):
|
|
84
|
+
- 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").
|
|
85
|
+
- Clear or reset the tool's state when transitioning between high-level steps.
|
|
86
|
+
|
|
87
|
+
## Execution Directives (absolute rules, non-negotiable)
|
|
88
|
+
During the execution flow you MUST follow these directives:
|
|
89
|
+
- **CRITICAL** Autonomous Execution:
|
|
90
|
+
- 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.
|
|
91
|
+
- 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.
|
|
92
|
+
- 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.
|
|
93
|
+
- After the prompt's execution: Strictly omit all concluding remarks and do not propose any other steps/actions.
|
|
94
|
+
- **CRITICAL**: Order of Execution:
|
|
95
|
+
- 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.
|
|
96
|
+
- **CRITICAL**: Immediate start and never stop:
|
|
97
|
+
- 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.
|
|
98
|
+
- After successful pre-flight resolution, create a *check-list* for the **Global Roadmap** and start following the roadmap from Step 1.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Steps
|
|
102
|
+
After successful pre-flight resolution, create internally a *check-list* for the **Global Roadmap** including all the numbered steps below: `1..6`, 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.
|
|
103
|
+
1. **CRITICAL**: Check GIT Status
|
|
104
|
+
- 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.
|
|
105
|
+
2. **CRITICAL**: Worktree Generation & Isolation
|
|
106
|
+
- 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.
|
|
107
|
+
- 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.
|
|
108
|
+
- If the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Worktree generation failed!", and then terminate the execution.
|
|
109
|
+
- 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.
|
|
110
|
+
|
|
111
|
+
3. Update `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md` references file
|
|
112
|
+
- Create/update the references file with `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --references >"{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md"`
|
|
113
|
+
4. **CRITICAL**: Stage & commit
|
|
114
|
+
- Show a summary of changes with `git diff` and `git diff --stat`.
|
|
115
|
+
- Stage changes explicitly (prefer targeted add; avoid `git add -A` if it may include unintended files): `git add <file...>` (ensure to include only `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`).
|
|
116
|
+
- 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.
|
|
117
|
+
- Commit a structured commit message with: `git commit -m "docs(<COMPONENT>)<BREAKING>: <DESCRIPTION> [useReq]"`
|
|
118
|
+
- 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`.
|
|
119
|
+
- 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.
|
|
120
|
+
- 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.
|
|
121
|
+
- Include main features added, requirements changes, or a bug-fix description adding a multi-line comment (maximum 10 lines).
|
|
122
|
+
- Do not include the 'Co-authored-by' trailer or any AI attribution. A GPG-signed commit is not required.
|
|
123
|
+
- 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: References request completed with unclean git repository!".
|
|
124
|
+
5. **CRITICAL**: Merge Conflict Management
|
|
125
|
+
- Return to the original repository directory (the sibling directory of the worktree).
|
|
126
|
+
- 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>`.
|
|
127
|
+
- Merge the isolated branch into the original branch: `git merge <WORKTREE_NAME>`
|
|
128
|
+
- 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.
|
|
129
|
+
- If the merge fails or results in conflicts, do NOT remove the worktree directory and override the final line with EXACTLY "WARNING: References request completed with merge conflicting!".
|
|
130
|
+
6. Present results
|
|
131
|
+
- 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,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Deterministically renumber requirement IDs in the Software Requirements Specification without changing requirement text or order"
|
|
3
|
+
argument-hint: "No arguments utilized by the prompt logic (English only)"
|
|
4
|
+
usage: >
|
|
5
|
+
Use when the user asks to normalize or renumber requirement IDs in REQUIREMENTS.md into a deterministic sequence in document order. Change only IDs and their internal cross-references; preserve all other text, headings, and ordering. Use /req-recreate to reorganize the SRS while preserving existing IDs; /req-change or /req-new to change requirements and implement behavior. Do not select for rewriting requirement content, reordering sections, or changing other files.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deterministically renumber requirement IDs in the Software Requirements Specification
|
|
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.
|
|
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
|
+
Deterministically renumber requirement IDs in `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` to produce a clean, progressive numbering scheme while preserving the exact requirement text and document order so downstream LLM Agents MUST rely on stable, sequential identifiers.
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
In scope: renumbering requirement identifiers in `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` in document order and updating internal cross-references to those identifiers, without modifying any requirement text, headings, or ordering. 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
|
+
- **Act as an Expert GitOps Engineer** when executing git workflows, especially when creating/removing/managing git worktrees to isolate changes safely.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Iteration and Context Economy
|
|
45
|
+
- **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.
|
|
46
|
+
- **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.
|
|
47
|
+
- **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.
|
|
48
|
+
- **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.
|
|
49
|
+
- **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.
|
|
50
|
+
- **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.
|
|
51
|
+
- **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.
|
|
52
|
+
- **CRITICAL**: These rules MUST govern how the agent organizes and sequences the work described in the `## Steps` section.
|
|
53
|
+
|
|
54
|
+
## Pre-requisite: Execution Context
|
|
55
|
+
- **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.
|
|
56
|
+
- 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.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Absolute Rules, Non-Negotiable
|
|
60
|
+
- **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.
|
|
61
|
+
- **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.
|
|
62
|
+
- **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>`.
|
|
63
|
+
- You can read, write, or edit `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
64
|
+
- Treat static analysis as safe. Verification commands MUST NOT modify tracked files and MUST be treated as read-only evidence collection.
|
|
65
|
+
- **CRITICAL**: Do not modify any project files except creating/updating `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
66
|
+
- **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.
|
|
67
|
+
- **CRITICAL**: Do NOT add, delete, split, merge, or edit requirement content; only change requirement IDs and requirement-ID cross-references.
|
|
68
|
+
- **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.
|
|
69
|
+
|
|
70
|
+
## Behavior
|
|
71
|
+
- Write the document in English.
|
|
72
|
+
- Do not perform unrelated edits.
|
|
73
|
+
- Do NOT change any requirement content or document structure; only change requirement IDs and requirement-ID cross-references.
|
|
74
|
+
- If `.venv/bin/python` exists in the project root, use it for Python executions (eg, `PYTHONPATH=src .venv/bin/python -m <program name>`).
|
|
75
|
+
- Non-Python tooling should use the project's standard commands.
|
|
76
|
+
- 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.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Execution Protocol (Global vs Local)
|
|
80
|
+
You must manage the execution flow using two distinct methods:
|
|
81
|
+
- **Global Roadmap** (*check-list*):
|
|
82
|
+
- You MUST maintain a *check-list* internally with `8` Steps (one item per Step).
|
|
83
|
+
- **Do NOT** use the *task-list tool* for this high-level roadmap.
|
|
84
|
+
- **Local Sub-tasks** (Tool Usage):
|
|
85
|
+
- 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").
|
|
86
|
+
- Clear or reset the tool's state when transitioning between high-level steps.
|
|
87
|
+
|
|
88
|
+
## Execution Directives (absolute rules, non-negotiable)
|
|
89
|
+
During the execution flow you MUST follow these directives:
|
|
90
|
+
- **CRITICAL** Autonomous Execution:
|
|
91
|
+
- 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.
|
|
92
|
+
- 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.
|
|
93
|
+
- 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.
|
|
94
|
+
- After the prompt's execution: Strictly omit all concluding remarks and do not propose any other steps/actions.
|
|
95
|
+
- **CRITICAL**: Order of Execution:
|
|
96
|
+
- 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.
|
|
97
|
+
- **CRITICAL**: Immediate start and never stop:
|
|
98
|
+
- 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.
|
|
99
|
+
- After successful pre-flight resolution, create a *check-list* for the **Global Roadmap** and start following the roadmap from Step 1.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## Steps
|
|
103
|
+
After successful pre-flight resolution, create internally a *check-list* for the **Global Roadmap** including all the numbered steps below: `1..8`, and start following the roadmap at the same time, following the instructions of Step 1. Do not add extra intent-adjustment checks unless explicitly listed in the Steps section.
|
|
104
|
+
1. **CRITICAL**: Check GIT Status
|
|
105
|
+
- 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.
|
|
106
|
+
2. **CRITICAL**: Check `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`, `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` and `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md` file presence
|
|
107
|
+
- 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.
|
|
108
|
+
3. **CRITICAL**: Worktree Generation & Isolation
|
|
109
|
+
- 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.
|
|
110
|
+
- 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.
|
|
111
|
+
- If the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Worktree generation failed!", and then terminate the execution.
|
|
112
|
+
- 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.
|
|
113
|
+
|
|
114
|
+
4. **CRITICAL**: Renumber requirement IDs in the **Software Requirements Specification**
|
|
115
|
+
- Read the **Software Requirements Specification** document `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
116
|
+
- Determine the existing requirement ID scheme, if any (prefix + numeric width). If multiple schemes exist, select the most common one as the canonical output scheme; if no clear scheme exists, use `REQ-001`, `REQ-002`, ... as the output scheme.
|
|
117
|
+
- Renumber requirements in strict document order (top-to-bottom, as they appear in the file) to a progressive sequence starting at 1.
|
|
118
|
+
- You MUST NOT modify any requirement text after `:`, any headings, any ordering, or any non-ID content.
|
|
119
|
+
- You MUST NOT add, delete, split, merge, or reorganize requirements.
|
|
120
|
+
- You MUST ensure the final set of requirement IDs is unique and strictly progressive (no gaps) in the chosen scheme.
|
|
121
|
+
- Update every internal cross-reference to requirement identifiers so that references still point to the correct renumbered requirement.
|
|
122
|
+
- Cross-references MUST be updated wherever requirement IDs are referenced in `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`.
|
|
123
|
+
- If an internal reference points to a non-existent requirement (before or after renumbering), treat this as an error and report it.
|
|
124
|
+
- Produce and include in the final report an explicit old-ID → new-ID mapping in document order.
|
|
125
|
+
- Save changes by overwriting `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` with only the ID and cross-reference updates applied.
|
|
126
|
+
5. Validate the **Software Requirements Specification**
|
|
127
|
+
- Review `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` and validate the renumbering invariants:
|
|
128
|
+
- Only requirement IDs and requirement-ID cross-references changed; all other text is identical.
|
|
129
|
+
- Requirement IDs are unique and strictly progressive in document order.
|
|
130
|
+
- All internal cross-references point to an existing renumbered requirement ID.
|
|
131
|
+
- Report `OK` if the invariants hold. Report `FAIL` if any invariant is violated.
|
|
132
|
+
6. **CRITICAL**: Stage & commit
|
|
133
|
+
- Show a summary of changes with `git diff` and `git diff --stat`.
|
|
134
|
+
- Stage changes explicitly (prefer targeted add; avoid `git add -A` if it may include unintended files): `git add <file...>` (ensure to include only `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md`).
|
|
135
|
+
- 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.
|
|
136
|
+
- Commit a structured commit message with: `git commit -m "docs(<COMPONENT>)<BREAKING>: <DESCRIPTION> [useReq]"`
|
|
137
|
+
- 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`.
|
|
138
|
+
- 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.
|
|
139
|
+
- 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.
|
|
140
|
+
- Include main features added, requirements changes, or a bug-fix description adding a multi-line comment (maximum 10 lines).
|
|
141
|
+
- Do not include the 'Co-authored-by' trailer or any AI attribution. A GPG-signed commit is not required.
|
|
142
|
+
- 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: Renumber request completed with unclean git repository!".
|
|
143
|
+
7. **CRITICAL**: Merge Conflict Management
|
|
144
|
+
- Return to the original repository directory (the sibling directory of the worktree).
|
|
145
|
+
- 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>`.
|
|
146
|
+
- Merge the isolated branch into the original branch: `git merge <WORKTREE_NAME>`
|
|
147
|
+
- 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.
|
|
148
|
+
- If the merge fails or results in conflicts, do NOT remove the worktree directory and override the final line with EXACTLY "WARNING: Renumber request completed with merge conflicting!".
|
|
149
|
+
8. Present results
|
|
150
|
+
- 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,254 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Write a WORKFLOW.md using the project's source code"
|
|
3
|
+
argument-hint: "No arguments utilized by the prompt logic"
|
|
4
|
+
usage: >
|
|
5
|
+
Use when the user asks to create, regenerate, or update WORKFLOW.md as a source-derived runtime execution model: processes, threads, internal call-traces, and communication edges under the project source directories. Change only that document and commit the update. Use /req-flowchart for a Mermaid runtime diagram, /req-references for the source index, or /req-analyze for an explanation without file edits. Do not select for CI/CD workflow changes, implementation, requirements changes, or other document edits.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Write a WORKFLOW.md 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: REQUIREMENTS.md, REFERENCES.md.
|
|
21
|
+
- Creatable targets: WORKFLOW.md.
|
|
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
|
+
Maintain an LLM-oriented runtime/workflow model (`{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`) derived from repository evidence so downstream LLM Agents MUST reason about execution units, communication edges, and internal call-traces during SRS-driven design/implementation.
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
In scope: static analysis of source under {{PRJ_BASE}}/%%SRC_PATHS%% to generate/overwrite only `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` in English only, following the mandated schema, then commit that doc change. Out of scope: changes to requirements, references, source code, or tests.
|
|
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 System Engineer** when analyzing source code; your primary goal is to trace the execution flow (call stack) across files and modules, identifying exactly how data and control move from one function to another.
|
|
39
|
+
- **Act as a Business Analyst** when cross-referencing code findings with `{{PRJ_BASE}}/%%DOC_PATH%%/REQUIREMENTS.md` to ensure functional alignment.
|
|
40
|
+
- **Act as a Technical Writer** when producing the final analysis report or workflow descriptions, ensuring clarity, technical precision, and structured formatting.
|
|
41
|
+
- **Act as a QA Auditor** when reporting facts, requiring concrete evidence as declaration file paths only (excluding line numbers and line ranges) for every finding.
|
|
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 can read, write, or edit `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`.
|
|
65
|
+
- Treat static analysis as safe. Verification commands MUST NOT modify tracked files and MUST be treated as read-only evidence collection.
|
|
66
|
+
- **CRITICAL**: Do not modify any project files except creating/updating `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`.
|
|
67
|
+
- **CRITICAL**: GIT operations and GIT rules:
|
|
68
|
+
- 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.
|
|
69
|
+
- 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).
|
|
70
|
+
- If the repository is NOT clean (modified files, staged changes, OR untracked files), exit immediately without changing anything.
|
|
71
|
+
- At the end you MUST commit only the intended changes with a unique identifier and change description in the commit message.
|
|
72
|
+
- Leave the working tree AND index clean (git `status --porcelain` must be empty).
|
|
73
|
+
- Do NOT “fix” a dirty repo by force (no `git reset --hard`, no `git clean -fd`, no stash) unless explicitly requested. If dirty: abort.
|
|
74
|
+
- **CRITICAL**: Formulate 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
|
+
|
|
76
|
+
## Behavior
|
|
77
|
+
- Write the `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` document in English.
|
|
78
|
+
- Do not perform unrelated edits.
|
|
79
|
+
- If `.venv/bin/python` exists in the project root, use it for Python executions (eg, `PYTHONPATH=src .venv/bin/python -m <program name>`).
|
|
80
|
+
- Non-Python tooling should use the project's standard commands.
|
|
81
|
+
- 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%%/WORKFLOW.md`. Avoid in-place edits on any other path. Prefer read-only commands for analysis.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Canonical Terminology (MUST use these exact terms)
|
|
85
|
+
- **Process**: an OS process execution unit (MUST include the main process).
|
|
86
|
+
- **Thread**: an OS thread execution unit within a process.
|
|
87
|
+
- **Execution Unit**: a Process or a Thread.
|
|
88
|
+
- **Internal function**: a function/method defined in repository source under {{PRJ_BASE}}/%%SRC_PATHS%% (only these can appear as call-trace nodes).
|
|
89
|
+
- **External boundary**: any call/interaction whose target implementation is not defined under {{PRJ_BASE}}/%%SRC_PATHS%% (libraries/frameworks/OS/network/DB/etc.). External boundaries MUST NOT appear as call-trace nodes.
|
|
90
|
+
- **Communication Edge**: an explicit runtime interaction between two execution units (direction + mechanism + endpoint/channel + payload/data-shape reference).
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## WORKFLOW.md Output Contract (MUST preserve this schema)
|
|
94
|
+
- The generated {{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md MUST be parser-stable and token-efficient: fixed section order, atomic bullets, deterministic key names, and zero narrative filler.
|
|
95
|
+
- The generated {{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md MUST NOT include line numbers, line ranges, or internal file-reference pointers; it MUST include only declaration file paths for internal symbols.
|
|
96
|
+
- The document MUST be structured as:
|
|
97
|
+
- `## Execution Units Index`
|
|
98
|
+
- `## Execution Units` (one subsection per execution unit ID)
|
|
99
|
+
- `## Communication Edges`
|
|
100
|
+
- The model MUST cover:
|
|
101
|
+
- ALL processes and threads used at runtime (static analysis), including the main process.
|
|
102
|
+
- For EACH execution unit: a complete internal call-trace tree from entrypoint(s) down to internal leaf functions (internal functions only).
|
|
103
|
+
- ALL explicit communication/interconnection paths between execution units.
|
|
104
|
+
|
|
105
|
+
## Source Code Analysis Toolkit
|
|
106
|
+
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.
|
|
107
|
+
|
|
108
|
+
### 1. Runtime Model: `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`
|
|
109
|
+
Compact document — read in full. Contains:
|
|
110
|
+
- **Execution Units Index**: all OS processes and threads with roles and entrypoints.
|
|
111
|
+
- **Execution Units**: per-unit internal call-trace trees showing function call order, defining file paths, and external boundaries.
|
|
112
|
+
- **Communication Edges**: inter-unit data flow (direction, mechanism, payload).
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
### 2. Symbol Index: `{{PRJ_BASE}}/%%DOC_PATH%%/REFERENCES.md`
|
|
117
|
+
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:
|
|
118
|
+
- `@brief`: single-line technical description of the symbol's action.
|
|
119
|
+
- `@details`: high-density algorithmic summary (LLM-optimized, not prose).
|
|
120
|
+
- `@param` / `@param[out]`: input parameters with type constraints; mutated reference/pointer arguments.
|
|
121
|
+
- `@return` / `@retval`: output data structure or specific return values.
|
|
122
|
+
- `@exception` / `@throws`: error states and specific exception classes.
|
|
123
|
+
- `@satisfies`: linked requirement IDs (e.g., `@satisfies REQ-026, REQ-045`).
|
|
124
|
+
- `@pre` / `@post`: pre-conditions and post-conditions.
|
|
125
|
+
- `@warning`: critical usage hazards.
|
|
126
|
+
- `@note`: vital implementation details.
|
|
127
|
+
- `@see` / `@sa`: related symbols for context linkage.
|
|
128
|
+
- `@deprecated`: replacement API link.
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
### 3. Code Extraction: `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find` / `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find`
|
|
133
|
+
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.
|
|
134
|
+
#### What these commands do (and what they don't)
|
|
135
|
+
- Extract named constructs (e.g., CLASS, FUNCTION, STRUCT, INTERFACE, IMPORT, …) filtered by TAG and name-regex.
|
|
136
|
+
- Regex (PATTERN) matches construct name only (not body). For body-content search, use rg/git grep (pillar 4).
|
|
137
|
+
- Output per file: header `@@@ <filepath> | <language>`, per-construct blocks with:
|
|
138
|
+
- `### <TAG>: <name>` + optional Signature + `Lines: <start>-<end>`
|
|
139
|
+
- optional extracted Doxygen fields (if present in/around the construct)
|
|
140
|
+
- fenced code block with the complete construct slice (comments stripped, strings preserved)
|
|
141
|
+
#### Choose the right mode
|
|
142
|
+
- Project-wide scan: use --find (the mandatory `--prj-base`/`--git-base` prefix is required; `--base` is forbidden)
|
|
143
|
+
- Syntax: `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --find <TAG_FILTER> <NAME_REGEX>`
|
|
144
|
+
- Note: --find scans all files under configured source dirs; does not take a filename.
|
|
145
|
+
- Target specific files: use --files-find (standalone with the mandatory `--prj-base`/`--git-base` prefix)
|
|
146
|
+
- Syntax: `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --files-find <TAG_FILTER> <NAME_REGEX> <FILE1> [FILE2 ...]`
|
|
147
|
+
#### Enable line-numbered code for evidence citation
|
|
148
|
+
Add --enable-line-numbers (code lines prefixed as `<n>:`):
|
|
149
|
+
- `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --enable-line-numbers --find "<TAG_FILTER>" "<NAME_REGEX>"`
|
|
150
|
+
- `req --prj-base={{PRJ_BASE}} --git-base={{GIT_BASE}} --enable-line-numbers --files-find "<TAG_FILTER>" "<NAME_REGEX>" <FILE...>`
|
|
151
|
+
#### TAGs and filters
|
|
152
|
+
- TAG_FILTER: pipe-separated, case-insensitive (e.g., `CLASS|FUNCTION|IMPORT`).
|
|
153
|
+
- Tags are language-dependent; unsupported tags are ignored. Run `req -h` for supported TAGs per language.
|
|
154
|
+
- 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`
|
|
155
|
+
#### Regex rules (NAME_REGEX)
|
|
156
|
+
- Regex matching follows `re.search()` semantics against construct names (tool behavior, independent of repository language).
|
|
157
|
+
- Prefer anchored patterns: exact `^Foo$`, prefix `^parse_`, suffix `Service$`. Use `.*` only when scope is already constrained by files/TAGs.
|
|
158
|
+
#### Failure modes you must handle
|
|
159
|
+
- "No constructs found": adjust TAGs (supported?), file paths, or NAME_REGEX (valid regex?).
|
|
160
|
+
- Regex-based extractor (not full AST): treat results as evidence pointers; confirm edge cases by opening referenced file/lines.
|
|
161
|
+
|
|
162
|
+
### 4. Supplementary Search: `rg` / `git grep`
|
|
163
|
+
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.
|
|
164
|
+
|
|
165
|
+
### Recommended Analysis Workflow
|
|
166
|
+
1. **Read `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`** (full read) → identify execution units, call-trace paths, and function names relevant to the task.
|
|
167
|
+
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.
|
|
168
|
+
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.
|
|
169
|
+
4. **Search code bodies** via `rg`/`git grep` → find patterns, references, or values not captured by construct-level extraction.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Execution Protocol (Global vs Local)
|
|
173
|
+
You must manage the execution flow using two distinct methods:
|
|
174
|
+
- **Global Roadmap** (*check-list*):
|
|
175
|
+
- You MUST maintain a *check-list* internally with `7` Steps (one item per Step).
|
|
176
|
+
- **Do NOT** use the *task-list tool* for this high-level roadmap.
|
|
177
|
+
- **Local Sub-tasks** (Tool Usage):
|
|
178
|
+
- 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").
|
|
179
|
+
- Clear or reset the tool's state when transitioning between high-level steps.
|
|
180
|
+
|
|
181
|
+
## Execution Directives (absolute rules, non-negotiable)
|
|
182
|
+
During the execution flow you MUST follow these directives:
|
|
183
|
+
- **CRITICAL** Autonomous Execution:
|
|
184
|
+
- 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.
|
|
185
|
+
- 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.
|
|
186
|
+
- 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.
|
|
187
|
+
- After the prompt's execution: Strictly omit all concluding remarks and do not propose any other steps/actions.
|
|
188
|
+
- **CRITICAL**: Order of Execution:
|
|
189
|
+
- 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.
|
|
190
|
+
- **CRITICAL**: Immediate start and never stop:
|
|
191
|
+
- 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.
|
|
192
|
+
- After successful pre-flight resolution, create a *check-list* for the **Global Roadmap** and start following the roadmap from Step 1.
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
## Steps
|
|
196
|
+
After successful pre-flight resolution, create internally a *check-list* for the **Global Roadmap** including all the numbered steps below: `1..7`, 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.
|
|
197
|
+
1. **CRITICAL**: Check GIT Status
|
|
198
|
+
- 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.
|
|
199
|
+
2. **CRITICAL**: Worktree Generation & Isolation
|
|
200
|
+
- 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.
|
|
201
|
+
- 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.
|
|
202
|
+
- If the command returns an error code or prints any text containing "ERROR", OUTPUT exactly "ERROR: Worktree generation failed!", and then terminate the execution.
|
|
203
|
+
- 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.
|
|
204
|
+
|
|
205
|
+
3. Static analysis: build the runtime model from {{PRJ_BASE}}/%%SRC_PATHS%%
|
|
206
|
+
- Analyze only files under {{PRJ_BASE}}/%%SRC_PATHS%%; treat all files outside {{PRJ_BASE}}/%%SRC_PATHS%% as out of scope and never document them.
|
|
207
|
+
- Identify ALL execution units used at runtime:
|
|
208
|
+
- OS processes (MUST include the main process).
|
|
209
|
+
- OS threads (per process), including their entry functions/methods.
|
|
210
|
+
- If no explicit thread creation is present, record "no explicit threads detected" for that process.
|
|
211
|
+
- For EACH execution unit, derive entrypoint(s) and build a complete internal call-trace tree:
|
|
212
|
+
- Include ONLY internal functions as call-trace nodes (defined under {{PRJ_BASE}}/%%SRC_PATHS%%).
|
|
213
|
+
- Do NOT include external boundaries (system/library/framework calls) as nodes; annotate them only as external boundaries where relevant.
|
|
214
|
+
- No maximum depth: expand until an internal leaf function or an external boundary is reached.
|
|
215
|
+
- Identify ALL explicit communication edges between execution units and record for each edge:
|
|
216
|
+
- Direction (source -> destination), mechanism (IPC/thread communication), endpoint/channel (queue/topic/path/socket/etc.), and payload/data-shape references.
|
|
217
|
+
4. Generate and overwrite `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` document using declaration file paths only, excluding line numbers, line ranges, and internal file-reference pointers
|
|
218
|
+
- Read any existing `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md` to preserve stable IDs and minimize unnecessary churn, then update it to strictly conform to the Output Contract above.
|
|
219
|
+
- Generate {{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md in English only using deterministic, machine-interpretable Markdown with the required schema and stable field order.
|
|
220
|
+
- During generation/update, include declaration file paths only; MUST NOT include line numbers, line ranges, or internal file-reference pointers.
|
|
221
|
+
- `## Execution Units Index` (stable IDs)
|
|
222
|
+
- Use stable IDs: `PROC:main`, `PROC:<name>` for processes; `THR:<proc_id>#<name>` for threads.
|
|
223
|
+
- For each execution unit: ID, type (process/thread), parent process (for threads), role, entrypoint symbol(s), and defining file(s).
|
|
224
|
+
- `## Execution Units`
|
|
225
|
+
- One subsection per execution unit ID including:
|
|
226
|
+
- Entrypoint(s)
|
|
227
|
+
- Lifecycle/trigger (how it starts, stops, and loops/blocks)
|
|
228
|
+
- Internal Call-Trace Tree (internal functions only; no maximum depth)
|
|
229
|
+
- External Boundaries (file I/O, network, DB, external APIs, OS interaction)
|
|
230
|
+
- `## Communication Edges`
|
|
231
|
+
- List ALL `Communication Edge` items with direction + mechanism + endpoint/channel + payload/data-shape reference + declaration file path references only.
|
|
232
|
+
- Call-trace node format (MUST be consistent):
|
|
233
|
+
- `symbol_name(...)`: `<single-line role>` [`<defining filepath>`]
|
|
234
|
+
- `<optional: brief invariants/external boundaries>`
|
|
235
|
+
- `<child internal calls as nested bullet list, in call order>`
|
|
236
|
+
5. **CRITICAL**: Stage & commit
|
|
237
|
+
- Show a summary of changes with `git diff` and `git diff --stat`.
|
|
238
|
+
- Stage changes explicitly (prefer targeted add; avoid `git add -A` if it may include unintended files): `git add <file...>` (ensure to include only `{{PRJ_BASE}}/%%DOC_PATH%%/WORKFLOW.md`).
|
|
239
|
+
- 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.
|
|
240
|
+
- Commit a structured commit message with: `git commit -m "docs(<COMPONENT>)<BREAKING>: <DESCRIPTION> [useReq]"`
|
|
241
|
+
- 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`.
|
|
242
|
+
- 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.
|
|
243
|
+
- 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.
|
|
244
|
+
- Include main features added, requirements changes, or a bug-fix description adding a multi-line comment (maximum 10 lines).
|
|
245
|
+
- Do not include the 'Co-authored-by' trailer or any AI attribution. A GPG-signed commit is not required.
|
|
246
|
+
- 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: Workflow request completed with unclean git repository!".
|
|
247
|
+
6. **CRITICAL**: Merge Conflict Management
|
|
248
|
+
- Return to the original repository directory (the sibling directory of the worktree).
|
|
249
|
+
- 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>`.
|
|
250
|
+
- Merge the isolated branch into the original branch: `git merge <WORKTREE_NAME>`
|
|
251
|
+
- 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.
|
|
252
|
+
- If the merge fails or results in conflicts, do NOT remove the worktree directory and override the final line with EXACTLY "WARNING: Workflow request completed with merge conflicting!".
|
|
253
|
+
7. Present results
|
|
254
|
+
- 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.
|