zrb 1.17.4__py3-none-any.whl → 1.18.1__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.
- zrb/builtin/llm/chat_session.py +17 -17
- zrb/builtin/llm/llm_ask.py +8 -6
- zrb/config/config.py +22 -8
- zrb/config/default_prompt/interactive_system_prompt.md +1 -1
- zrb/config/default_prompt/system_prompt.md +1 -1
- zrb/config/llm_config.py +14 -14
- zrb/config/llm_context/config.py +27 -4
- zrb/task/llm/agent.py +1 -1
- zrb/task/llm/default_workflow/coding/cpp.md +33 -0
- zrb/task/llm/default_workflow/coding/csharp.md +35 -0
- zrb/task/llm/default_workflow/coding/git.md +58 -0
- zrb/task/llm/default_workflow/coding/golang.md +43 -0
- zrb/task/llm/default_workflow/coding/html-css.md +34 -0
- zrb/task/llm/default_workflow/coding/java.md +37 -0
- zrb/task/llm/default_workflow/coding/javascript.md +45 -0
- zrb/task/llm/default_workflow/coding/kotlin.md +41 -0
- zrb/task/llm/default_workflow/coding/php.md +30 -0
- zrb/task/llm/default_workflow/coding/python.md +44 -0
- zrb/task/llm/default_workflow/coding/ruby-on-rails.md +34 -0
- zrb/task/llm/default_workflow/coding/ruby.md +33 -0
- zrb/task/llm/default_workflow/coding/rust.md +38 -0
- zrb/task/llm/default_workflow/coding/shell.md +49 -0
- zrb/task/llm/default_workflow/coding/sql.md +38 -0
- zrb/task/llm/default_workflow/coding/swift.md +38 -0
- zrb/task/llm/default_workflow/coding/workflow.md +85 -0
- zrb/task/llm/default_workflow/copywriting/workflow.md +40 -0
- zrb/task/llm/default_workflow/researching/workflow.md +41 -0
- zrb/task/llm/prompt.py +82 -76
- zrb/task/llm/tool_wrapper.py +20 -14
- zrb/task/llm_task.py +8 -9
- zrb/task/rsync_task.py +5 -4
- {zrb-1.17.4.dist-info → zrb-1.18.1.dist-info}/METADATA +1 -1
- {zrb-1.17.4.dist-info → zrb-1.18.1.dist-info}/RECORD +35 -19
- zrb/task/llm/default_workflow/coding.md +0 -64
- zrb/task/llm/default_workflow/copywriting.md +0 -17
- zrb/task/llm/default_workflow/researching.md +0 -18
- {zrb-1.17.4.dist-info → zrb-1.18.1.dist-info}/WHEEL +0 -0
- {zrb-1.17.4.dist-info → zrb-1.18.1.dist-info}/entry_points.txt +0 -0
zrb/builtin/llm/chat_session.py
CHANGED
|
@@ -32,7 +32,7 @@ async def read_user_prompt(ctx: AnyContext) -> str:
|
|
|
32
32
|
reader: PromptSession[Any] | StreamReader = await _setup_input_reader(is_tty)
|
|
33
33
|
multiline_mode = False
|
|
34
34
|
is_first_time = True
|
|
35
|
-
|
|
35
|
+
current_workflows: str = ctx.input.workflows
|
|
36
36
|
current_yolo_mode: bool | str = ctx.input.yolo
|
|
37
37
|
user_inputs: list[str] = []
|
|
38
38
|
final_result: str = ""
|
|
@@ -59,7 +59,7 @@ async def read_user_prompt(ctx: AnyContext) -> str:
|
|
|
59
59
|
result = await _trigger_ask_and_wait_for_result(
|
|
60
60
|
ctx=ctx,
|
|
61
61
|
user_prompt=user_prompt,
|
|
62
|
-
|
|
62
|
+
workflows=current_workflows,
|
|
63
63
|
yolo_mode=current_yolo_mode,
|
|
64
64
|
previous_session_name=previous_session_name,
|
|
65
65
|
start_new=start_new,
|
|
@@ -77,7 +77,7 @@ async def read_user_prompt(ctx: AnyContext) -> str:
|
|
|
77
77
|
result = await _trigger_ask_and_wait_for_result(
|
|
78
78
|
ctx=ctx,
|
|
79
79
|
user_prompt=user_prompt,
|
|
80
|
-
|
|
80
|
+
workflows=current_workflows,
|
|
81
81
|
yolo_mode=current_yolo_mode,
|
|
82
82
|
previous_session_name=previous_session_name,
|
|
83
83
|
start_new=start_new,
|
|
@@ -86,18 +86,18 @@ async def read_user_prompt(ctx: AnyContext) -> str:
|
|
|
86
86
|
final_result = result
|
|
87
87
|
if ctx.is_web_mode or not is_tty:
|
|
88
88
|
return final_result
|
|
89
|
-
elif user_input.strip().lower().startswith("/
|
|
90
|
-
|
|
91
|
-
if len(
|
|
92
|
-
|
|
93
|
-
ctx.print(f"Current
|
|
89
|
+
elif user_input.strip().lower().startswith("/workflow"):
|
|
90
|
+
workflow_parts = user_input.split(" ", maxsplit=2)
|
|
91
|
+
if len(workflow_parts) > 1:
|
|
92
|
+
current_workflows = workflow_parts[1]
|
|
93
|
+
ctx.print(f"Current workflows: {current_workflows}", plain=True)
|
|
94
94
|
ctx.print("", plain=True)
|
|
95
95
|
continue
|
|
96
96
|
elif user_input.strip().lower().startswith("/yolo"):
|
|
97
97
|
yolo_mode_parts = user_input.split(" ", maxsplit=2)
|
|
98
98
|
if len(yolo_mode_parts) > 1:
|
|
99
99
|
current_yolo_mode = to_boolean(yolo_mode_parts[1])
|
|
100
|
-
ctx.print(f"
|
|
100
|
+
ctx.print(f"Current YOLO mode: {current_yolo_mode}", plain=True)
|
|
101
101
|
ctx.print("", plain=True)
|
|
102
102
|
continue
|
|
103
103
|
elif user_input.strip().lower() in ("/help", "/info"):
|
|
@@ -112,7 +112,7 @@ async def read_user_prompt(ctx: AnyContext) -> str:
|
|
|
112
112
|
result = await _trigger_ask_and_wait_for_result(
|
|
113
113
|
ctx=ctx,
|
|
114
114
|
user_prompt=user_prompt,
|
|
115
|
-
|
|
115
|
+
workflows=current_workflows,
|
|
116
116
|
yolo_mode=current_yolo_mode,
|
|
117
117
|
previous_session_name=previous_session_name,
|
|
118
118
|
start_new=start_new,
|
|
@@ -136,8 +136,8 @@ def _show_info(ctx: AnyContext):
|
|
|
136
136
|
_show_command("/bye", "Quit from chat session"),
|
|
137
137
|
_show_command("/multi", "Start multiline input"),
|
|
138
138
|
_show_command("/end", "End multiline input"),
|
|
139
|
-
_show_command("/
|
|
140
|
-
_show_subcommand("<
|
|
139
|
+
_show_command("/workflows", "Show current workflows"),
|
|
140
|
+
_show_subcommand("<wf1,wf2,..>", "Set current workflows"),
|
|
141
141
|
_show_command("/yolo", "Get current YOLO mode"),
|
|
142
142
|
_show_subcommand("<true|false|list-of-tools>", "Set YOLO mode"),
|
|
143
143
|
_show_command("/help", "Show this message"),
|
|
@@ -179,7 +179,7 @@ async def _setup_input_reader(
|
|
|
179
179
|
async def _trigger_ask_and_wait_for_result(
|
|
180
180
|
ctx: AnyContext,
|
|
181
181
|
user_prompt: str,
|
|
182
|
-
|
|
182
|
+
workflows: str,
|
|
183
183
|
yolo_mode: bool | str,
|
|
184
184
|
previous_session_name: str | None = None,
|
|
185
185
|
start_new: bool = False,
|
|
@@ -199,7 +199,7 @@ async def _trigger_ask_and_wait_for_result(
|
|
|
199
199
|
if user_prompt.strip() == "":
|
|
200
200
|
return None
|
|
201
201
|
await _trigger_ask(
|
|
202
|
-
ctx, user_prompt,
|
|
202
|
+
ctx, user_prompt, workflows, yolo_mode, previous_session_name, start_new
|
|
203
203
|
)
|
|
204
204
|
result = await _wait_ask_result(ctx)
|
|
205
205
|
md_result = render_markdown(result) if result is not None else ""
|
|
@@ -231,7 +231,7 @@ def get_llm_ask_input_mapping(callback_ctx: AnyContext):
|
|
|
231
231
|
"start-new": data.get("start_new"),
|
|
232
232
|
"previous-session": data.get("previous_session_name"),
|
|
233
233
|
"message": data.get("message"),
|
|
234
|
-
"
|
|
234
|
+
"workflows": data.get("workflows"),
|
|
235
235
|
"yolo": data.get("yolo"),
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -239,7 +239,7 @@ def get_llm_ask_input_mapping(callback_ctx: AnyContext):
|
|
|
239
239
|
async def _trigger_ask(
|
|
240
240
|
ctx: AnyContext,
|
|
241
241
|
user_prompt: str,
|
|
242
|
-
|
|
242
|
+
workflows: str,
|
|
243
243
|
yolo_mode: bool | str,
|
|
244
244
|
previous_session_name: str | None = None,
|
|
245
245
|
start_new: bool = False,
|
|
@@ -260,7 +260,7 @@ async def _trigger_ask(
|
|
|
260
260
|
"previous_session_name": previous_session_name,
|
|
261
261
|
"start_new": start_new,
|
|
262
262
|
"message": user_prompt,
|
|
263
|
-
"
|
|
263
|
+
"workflows": workflows,
|
|
264
264
|
"yolo": yolo_mode,
|
|
265
265
|
}
|
|
266
266
|
)
|
zrb/builtin/llm/llm_ask.py
CHANGED
|
@@ -152,10 +152,10 @@ def _get_inputs(require_message: bool = True) -> list[AnyInput | None]:
|
|
|
152
152
|
always_prompt=False,
|
|
153
153
|
),
|
|
154
154
|
TextInput(
|
|
155
|
-
"
|
|
156
|
-
description="
|
|
157
|
-
prompt="
|
|
158
|
-
default=lambda ctx: ",".join(llm_config.
|
|
155
|
+
"workflows",
|
|
156
|
+
description="Workflows",
|
|
157
|
+
prompt="Workflows",
|
|
158
|
+
default=lambda ctx: ",".join(llm_config.default_workflows),
|
|
159
159
|
allow_positional_parsing=False,
|
|
160
160
|
always_prompt=False,
|
|
161
161
|
),
|
|
@@ -210,8 +210,10 @@ llm_ask: LLMTask = llm_group.add_task(
|
|
|
210
210
|
system_prompt=lambda ctx: (
|
|
211
211
|
None if ctx.input.system_prompt.strip() == "" else ctx.input.system_prompt
|
|
212
212
|
),
|
|
213
|
-
|
|
214
|
-
None
|
|
213
|
+
workflows=lambda ctx: (
|
|
214
|
+
None
|
|
215
|
+
if ctx.input.workflows.strip() == ""
|
|
216
|
+
else ctx.input.workflows.split(",")
|
|
215
217
|
),
|
|
216
218
|
message="{ctx.input.message}",
|
|
217
219
|
tools=_get_tool,
|
zrb/config/config.py
CHANGED
|
@@ -275,12 +275,26 @@ class Config:
|
|
|
275
275
|
return None if value == "" else value
|
|
276
276
|
|
|
277
277
|
@property
|
|
278
|
-
def
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
278
|
+
def LLM_WORKFLOWS(self) -> list[str]:
|
|
279
|
+
"""Get a list of LLM workflows from environment variables."""
|
|
280
|
+
workflows = []
|
|
281
|
+
for workflow in self._getenv("LLM_WORKFLOWS", "coding").split(","):
|
|
282
|
+
workflow = workflow.strip()
|
|
283
|
+
if workflow != "":
|
|
284
|
+
workflows.append(workflow)
|
|
285
|
+
return workflows
|
|
286
|
+
|
|
287
|
+
@property
|
|
288
|
+
def LLM_BUILTIN_WORKFLOW_PATHS(self) -> list[str]:
|
|
289
|
+
"""Get a list of additional builtin workflow paths from environment variables."""
|
|
290
|
+
builtin_workflow_paths_str = self._getenv("LLM_BUILTIN_WORKFLOW_PATHS", "")
|
|
291
|
+
if builtin_workflow_paths_str != "":
|
|
292
|
+
return [
|
|
293
|
+
path.strip()
|
|
294
|
+
for path in builtin_workflow_paths_str.split(":")
|
|
295
|
+
if path.strip() != ""
|
|
296
|
+
]
|
|
297
|
+
return []
|
|
284
298
|
|
|
285
299
|
@property
|
|
286
300
|
def LLM_SPECIAL_INSTRUCTION_PROMPT(self) -> str | None:
|
|
@@ -479,8 +493,8 @@ class Config:
|
|
|
479
493
|
return int(self._getenv("SEARXNG_SAFE", "0"))
|
|
480
494
|
|
|
481
495
|
@property
|
|
482
|
-
def SEARXNG_LANG(self) ->
|
|
483
|
-
return
|
|
496
|
+
def SEARXNG_LANG(self) -> str:
|
|
497
|
+
return self._getenv("SEARXNG_LANG", "en")
|
|
484
498
|
|
|
485
499
|
@property
|
|
486
500
|
def BANNER(self) -> str:
|
|
@@ -20,7 +20,7 @@ You are an expert interactive AI agent. You MUST follow this workflow for this i
|
|
|
20
20
|
|
|
21
21
|
3. **Execute and Verify (The E+V Loop):**
|
|
22
22
|
* Execute the action.
|
|
23
|
-
* **CRITICAL:** After each step, you MUST use a tool to verify the outcome (e.g., check command exit codes,
|
|
23
|
+
* **CRITICAL:** After each step, you MUST use a tool to verify the outcome (e.g., check command exit codes, verify changes has been applied, or new files has been created).
|
|
24
24
|
|
|
25
25
|
4. **Handle Errors (The Debugging Loop):**
|
|
26
26
|
* If an action fails, you MUST NOT give up. You MUST enter a persistent debugging loop until the error is resolved.
|
|
@@ -16,7 +16,7 @@ You are an expert AI agent fulfilling a single request. You must provide a compl
|
|
|
16
16
|
|
|
17
17
|
3. **Execute and Verify (The E+V Loop):**
|
|
18
18
|
* Execute each step of your plan.
|
|
19
|
-
* **CRITICAL:** After each step, you MUST use a tool to verify the outcome (e.g., check command exit codes,
|
|
19
|
+
* **CRITICAL:** After each step, you MUST use a tool to verify the outcome (e.g., check command exit codes, verify changes has been applied, or new files has been created).
|
|
20
20
|
|
|
21
21
|
4. **Handle Errors (The Debugging Loop):**
|
|
22
22
|
* If an action fails, you MUST NOT give up. You MUST enter a persistent debugging loop until the error is resolved.
|
zrb/config/llm_config.py
CHANGED
|
@@ -25,7 +25,7 @@ class LLMConfig:
|
|
|
25
25
|
default_summarization_prompt: str | None = None,
|
|
26
26
|
default_summarize_history: bool | None = None,
|
|
27
27
|
default_history_summarization_token_threshold: int | None = None,
|
|
28
|
-
|
|
28
|
+
default_workflows: list[str] | None = None,
|
|
29
29
|
default_model: "Model | None" = None,
|
|
30
30
|
default_model_settings: "ModelSettings | None" = None,
|
|
31
31
|
default_model_provider: "Provider | None" = None,
|
|
@@ -53,7 +53,7 @@ class LLMConfig:
|
|
|
53
53
|
self._default_history_summarization_token_threshold = (
|
|
54
54
|
default_history_summarization_token_threshold
|
|
55
55
|
)
|
|
56
|
-
self.
|
|
56
|
+
self._default_workflows = default_workflows
|
|
57
57
|
self._default_model = default_model
|
|
58
58
|
self._default_model_settings = default_model_settings
|
|
59
59
|
self._default_model_provider = default_model_provider
|
|
@@ -191,9 +191,9 @@ class LLMConfig:
|
|
|
191
191
|
)
|
|
192
192
|
|
|
193
193
|
@property
|
|
194
|
-
def
|
|
194
|
+
def default_workflows(self) -> list[str]:
|
|
195
195
|
return self._get_property(
|
|
196
|
-
self.
|
|
196
|
+
self._default_workflows, CFG.LLM_WORKFLOWS, lambda: ["coding"]
|
|
197
197
|
)
|
|
198
198
|
|
|
199
199
|
@property
|
|
@@ -279,18 +279,18 @@ class LLMConfig:
|
|
|
279
279
|
def set_default_special_instruction_prompt(self, special_instruction_prompt: str):
|
|
280
280
|
self._default_special_instruction_prompt = special_instruction_prompt
|
|
281
281
|
|
|
282
|
-
def
|
|
283
|
-
self.
|
|
282
|
+
def set_default_workflows(self, workflows: list[str]):
|
|
283
|
+
self._default_workflows = workflows
|
|
284
284
|
|
|
285
|
-
def
|
|
286
|
-
if self.
|
|
287
|
-
self.
|
|
288
|
-
self.
|
|
285
|
+
def add_default_workflow(self, workflow: str):
|
|
286
|
+
if self._default_workflows is None:
|
|
287
|
+
self._default_workflows = []
|
|
288
|
+
self._default_workflows.append(workflow)
|
|
289
289
|
|
|
290
|
-
def
|
|
291
|
-
if self.
|
|
292
|
-
self.
|
|
293
|
-
self.
|
|
290
|
+
def remove_default_workflow(self, workflow: str):
|
|
291
|
+
if self._default_workflows is None:
|
|
292
|
+
self._default_workflows = []
|
|
293
|
+
self._default_workflows.remove(workflow)
|
|
294
294
|
|
|
295
295
|
def set_default_summarization_prompt(self, summarization_prompt: str):
|
|
296
296
|
self._default_summarization_prompt = summarization_prompt
|
zrb/config/llm_context/config.py
CHANGED
|
@@ -5,6 +5,25 @@ from zrb.config.llm_context.config_parser import markdown_to_dict
|
|
|
5
5
|
from zrb.util.llm.prompt import demote_markdown_headers
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
class LLMWorkflow:
|
|
9
|
+
def __init__(self, name: str, path: str, content: str):
|
|
10
|
+
self._name = name
|
|
11
|
+
self._path = path
|
|
12
|
+
self._content = content
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def name(self) -> str:
|
|
16
|
+
return self._name
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def path(self) -> str:
|
|
20
|
+
return self._path
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def content(self) -> str:
|
|
24
|
+
return self._content
|
|
25
|
+
|
|
26
|
+
|
|
8
27
|
class LLMContextConfig:
|
|
9
28
|
"""High-level API for interacting with cascaded configurations."""
|
|
10
29
|
|
|
@@ -75,20 +94,24 @@ class LLMContextConfig:
|
|
|
75
94
|
notes[abs_context_path] = value
|
|
76
95
|
return notes
|
|
77
96
|
|
|
78
|
-
def get_workflows(self, cwd: str | None = None) -> dict[str,
|
|
97
|
+
def get_workflows(self, cwd: str | None = None) -> dict[str, LLMWorkflow]:
|
|
79
98
|
"""Gathers all relevant workflows for a given path."""
|
|
80
99
|
if cwd is None:
|
|
81
100
|
cwd = os.getcwd()
|
|
82
101
|
all_sections = self._get_all_sections(cwd)
|
|
83
|
-
workflows: dict[str,
|
|
102
|
+
workflows: dict[str, LLMWorkflow] = {}
|
|
84
103
|
# Iterate from closest to farthest
|
|
85
|
-
for
|
|
104
|
+
for config_dir, sections in all_sections:
|
|
86
105
|
for key, value in sections.items():
|
|
87
106
|
if key.lower().startswith("workflow:"):
|
|
88
107
|
workflow_name = key[len("workflow:") :].strip().lower()
|
|
89
108
|
# First one found wins
|
|
90
109
|
if workflow_name not in workflows:
|
|
91
|
-
workflows[workflow_name] =
|
|
110
|
+
workflows[workflow_name] = LLMWorkflow(
|
|
111
|
+
name=workflow_name,
|
|
112
|
+
content=value,
|
|
113
|
+
path=config_dir,
|
|
114
|
+
)
|
|
92
115
|
return workflows
|
|
93
116
|
|
|
94
117
|
def get_contexts(self, cwd: str | None = None) -> dict[str, str]:
|
zrb/task/llm/agent.py
CHANGED
|
@@ -106,7 +106,7 @@ def create_agent_instance(
|
|
|
106
106
|
return Agent[None, Any](
|
|
107
107
|
model=model,
|
|
108
108
|
output_type=output_type,
|
|
109
|
-
|
|
109
|
+
instructions=system_prompt,
|
|
110
110
|
tools=tool_list,
|
|
111
111
|
toolsets=wrapped_toolsets,
|
|
112
112
|
model_settings=model_settings,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# C++ Development Guide
|
|
2
|
+
|
|
3
|
+
This guide provides the baseline for C++ development. It is superseded by project-specific conventions.
|
|
4
|
+
|
|
5
|
+
## 1. Project Analysis Checklist
|
|
6
|
+
|
|
7
|
+
Before coding, inspect the project for these files to determine its conventions:
|
|
8
|
+
|
|
9
|
+
- **Build System:** `CMakeLists.txt` (CMake), `Makefile` (Make), or a Visual Studio solution file (`*.sln`).
|
|
10
|
+
- **C++ Standard:** Look for flags like `-std=c++11`, `-std=c++14`, `-std=c++17`, or `-std=c++20` in the build files.
|
|
11
|
+
- **Style & Linting Config:** `.clang-format`, `.clang-tidy`. These define the coding standard.
|
|
12
|
+
- **Testing Framework:** Look for a `tests/` directory and check the build files for dependencies like `gtest` or `catch2`.
|
|
13
|
+
|
|
14
|
+
## 2. Core Principles
|
|
15
|
+
|
|
16
|
+
- **Style:** Strictly adhere to the project's configured formatter (e.g., clang-format) and linter (e.g., clang-tidy). If none exist, default to the Google C++ Style Guide.
|
|
17
|
+
- **Modern C++:** Use modern C++ features, such as smart pointers, range-based for loops, and auto.
|
|
18
|
+
- **RAII (Resource Acquisition Is Initialization):** Use RAII to manage resources like memory, files, and network connections.
|
|
19
|
+
|
|
20
|
+
## 3. Implementation Patterns
|
|
21
|
+
|
|
22
|
+
- **Error Handling:** Replicate existing patterns for error handling. Use exceptions for errors that cannot be handled locally.
|
|
23
|
+
- **Testing:** Use the project's existing test structure. Write unit tests for all new code.
|
|
24
|
+
|
|
25
|
+
## 4. Common Commands
|
|
26
|
+
|
|
27
|
+
- **CMake:**
|
|
28
|
+
- **Configure:** `cmake -B build`
|
|
29
|
+
- **Build:** `cmake --build build`
|
|
30
|
+
- **Test:** `cd build && ctest`
|
|
31
|
+
- **Make:**
|
|
32
|
+
- **Build:** `make`
|
|
33
|
+
- **Test:** `make test`
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# C# Development Guide
|
|
2
|
+
|
|
3
|
+
This guide provides the baseline for C# development. It is superseded by project-specific conventions.
|
|
4
|
+
|
|
5
|
+
## 1. Project Analysis Checklist
|
|
6
|
+
|
|
7
|
+
Before coding, inspect the project for these files to determine its conventions:
|
|
8
|
+
|
|
9
|
+
- **Project File:** `*.csproj`. This defines the project structure, dependencies, and build settings.
|
|
10
|
+
- **Solution File:** `*.sln`. This defines the solution that contains one or more projects.
|
|
11
|
+
- **.NET Version:** Look for a `global.json` file, or check the `*.csproj` file.
|
|
12
|
+
- **Style & Linting Config:** `.editorconfig`, `.stylecop.json`. These define the coding standard.
|
|
13
|
+
- **Testing Framework:** Look for a `*Tests` directory and check the project file for dependencies like `xunit`, `nunit`, or `mstest`.
|
|
14
|
+
|
|
15
|
+
## 2. Core Principles
|
|
16
|
+
|
|
17
|
+
- **Style:** Strictly adhere to the project's configured linter (e.g., StyleCop). If none exists, default to the .NET coding conventions.
|
|
18
|
+
- **Idiomatic C#:** Embrace C#'s core features:
|
|
19
|
+
- Use properties instead of public fields.
|
|
20
|
+
- Use LINQ for data manipulation.
|
|
21
|
+
- Use `async/await` for asynchronous programming.
|
|
22
|
+
- **Object-Oriented Design:** Follow SOLID principles and use design patterns where appropriate.
|
|
23
|
+
|
|
24
|
+
## 3. Implementation Patterns
|
|
25
|
+
|
|
26
|
+
- **Error Handling:** Replicate existing patterns for exceptions. Use `try-catch-finally` blocks for exception handling.
|
|
27
|
+
- **Testing:** Use the project's existing test structure. Write unit tests for all new code.
|
|
28
|
+
|
|
29
|
+
## 4. Common Commands
|
|
30
|
+
|
|
31
|
+
- **Build:** `dotnet build`
|
|
32
|
+
- **Run:** `dotnet run`
|
|
33
|
+
- **Test:** `dotnet test`
|
|
34
|
+
- **Clean:** `dotnet clean`
|
|
35
|
+
- **Publish:** `dotnet publish`
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Git Workflow Guide
|
|
2
|
+
|
|
3
|
+
This guide governs all version control operations. Adhere to it for safety and consistency.
|
|
4
|
+
|
|
5
|
+
## 1. Core Principles & Safety
|
|
6
|
+
|
|
7
|
+
- **Atomic Commits:** One logical change per commit. Use `git add -p` for precision.
|
|
8
|
+
- **Descriptive Messages:** Explain the "why" in the imperative mood (e.g., "Add feature"). Follow the 50/72 format.
|
|
9
|
+
- **Safety First:**
|
|
10
|
+
- Always run `git status` before operations.
|
|
11
|
+
- Use `git push --force-with-lease`, not `--force`.
|
|
12
|
+
- Ensure the working directory is clean before `git rebase`.
|
|
13
|
+
|
|
14
|
+
## 2. Standard Workflow
|
|
15
|
+
|
|
16
|
+
This is the primary development cycle.
|
|
17
|
+
|
|
18
|
+
1. **Branch:** `git checkout -b <branch-name>`
|
|
19
|
+
2. **Code & Verify:** Make changes, then run all tests, linters, and builds.
|
|
20
|
+
3. **Stage:** `git add <file>` or, for more precision, `git add -p`.
|
|
21
|
+
4. **Commit:** `git commit` with a descriptive message.
|
|
22
|
+
```
|
|
23
|
+
feat: Add user authentication endpoint
|
|
24
|
+
|
|
25
|
+
Implement the /login endpoint using JWT for token-based auth.
|
|
26
|
+
This resolves issue #123 by providing a mechanism for users to
|
|
27
|
+
log in and receive an access token.
|
|
28
|
+
```
|
|
29
|
+
5. **Review/Amend:** Use `git log -1` to review. If needed, fix with `git commit --amend`.
|
|
30
|
+
6. **Push:** `git push origin <branch-name>`
|
|
31
|
+
|
|
32
|
+
## 3. Command Reference
|
|
33
|
+
|
|
34
|
+
### Status & History
|
|
35
|
+
- `git status`: Check working directory status.
|
|
36
|
+
- `git diff`: See uncommitted changes to tracked files.
|
|
37
|
+
- `git diff --staged`: See staged changes.
|
|
38
|
+
- `git log --oneline --graph -10`: View recent commit history.
|
|
39
|
+
- `git blame <file>`: See who changed what in a file.
|
|
40
|
+
|
|
41
|
+
### Branching & Merging
|
|
42
|
+
- `git checkout -b <name>`: Create and switch to a new branch.
|
|
43
|
+
- `git switch <name>`: Switch to an existing branch.
|
|
44
|
+
- `git rebase main`: Update the current branch from `main`. **(Use with care)**.
|
|
45
|
+
- `git merge --no-ff <branch>`: Merge a branch without fast-forwarding.
|
|
46
|
+
|
|
47
|
+
### Stashing
|
|
48
|
+
- `git stash push -m "msg"`: Save uncommitted changes temporarily.
|
|
49
|
+
- `git stash list`: List all stashes.
|
|
50
|
+
- `git stash pop`: Apply and remove the last stash.
|
|
51
|
+
|
|
52
|
+
### Remote Operations
|
|
53
|
+
- `git fetch origin`: Fetch updates from the remote repository.
|
|
54
|
+
- `git push origin <branch>`: Push a branch to the remote.
|
|
55
|
+
- `git push origin --delete <branch>`: Delete a remote branch.
|
|
56
|
+
|
|
57
|
+
### Advanced
|
|
58
|
+
- `git cherry-pick <commit-hash>`: Apply a specific commit from another branch. **(Use with caution to avoid duplicate commits)**.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Go Development Guide
|
|
2
|
+
|
|
3
|
+
This guide provides the baseline for Go development. It is superseded by project-specific conventions.
|
|
4
|
+
|
|
5
|
+
## 1. Project Analysis Checklist
|
|
6
|
+
|
|
7
|
+
Before coding, inspect the project for these files to determine its conventions:
|
|
8
|
+
|
|
9
|
+
- **Module Information:** `go.mod` to identify the module path and dependencies. `go.sum` for dependency checksums.
|
|
10
|
+
- **Workspace:** `go.work` to see if the project is part of a multi-module workspace.
|
|
11
|
+
- **Tooling:** A `Makefile` is common for defining build, test, and lint commands.
|
|
12
|
+
- **CI/CD Configuration:** Files like `.github/workflows/go.yml` can reveal the exact commands used for verification.
|
|
13
|
+
- **Linting Config:** `.golangci.yml` defines the linting rules for `golangci-lint`.
|
|
14
|
+
- **Package Structure:** Analyze the `pkg/` and `internal/` directories to understand the project's layout.
|
|
15
|
+
|
|
16
|
+
## 2. Core Principles
|
|
17
|
+
|
|
18
|
+
- **Formatting:** `go fmt` is mandatory. All code must be formatted before committing.
|
|
19
|
+
- **Linting:** Adhere to the project's `golangci-lint` configuration. If none exists, use a sensible default.
|
|
20
|
+
- **Package Naming:** Use short, concise, all-lowercase package names.
|
|
21
|
+
- **Simplicity:** Write clear, simple, and readable code. Avoid unnecessary complexity or "clever" tricks.
|
|
22
|
+
|
|
23
|
+
## 3. Project Structure
|
|
24
|
+
|
|
25
|
+
- **`cmd/`:** Main applications for the project. Each subdirectory is a separate command.
|
|
26
|
+
- **`pkg/`:** Library code that's okay to be used by external applications.
|
|
27
|
+
- **`internal/`:** Private application and library code. It's not importable by other projects.
|
|
28
|
+
|
|
29
|
+
## 4. Implementation Patterns
|
|
30
|
+
|
|
31
|
+
- **Error Handling:** Match the existing error handling strategy. Check if the project uses a library like `pkg/errors` for wrapping or if it relies on the standard library's `fmt.Errorf` with `%w`.
|
|
32
|
+
- **Testing:** Replicate the existing test structure. Use table-driven tests if they are prevalent in the codebase. Place tests in `_test.go` files within the same package.
|
|
33
|
+
- **Concurrency:** Follow existing concurrency patterns. Pay close attention to how goroutines, channels, and mutexes are used.
|
|
34
|
+
- **Debugging:** Use the `delve` debugger for debugging Go applications.
|
|
35
|
+
|
|
36
|
+
## 5. Common Commands
|
|
37
|
+
|
|
38
|
+
- **Tidy Dependencies:** `go mod tidy`
|
|
39
|
+
- **Formatting:** `go fmt ./...`
|
|
40
|
+
- **Linting:** `golangci-lint run`
|
|
41
|
+
- **Testing:** `go test ./...`
|
|
42
|
+
- **Building:** `go build ./...`
|
|
43
|
+
- **Run:** `go run ./cmd/my-app`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# HTML/CSS Development Guide
|
|
2
|
+
|
|
3
|
+
This guide provides the baseline for HTML and CSS development. It is superseded by project-specific conventions.
|
|
4
|
+
|
|
5
|
+
## 1. Project Analysis Checklist
|
|
6
|
+
|
|
7
|
+
Before coding, inspect the project for these files to determine its conventions:
|
|
8
|
+
|
|
9
|
+
- **HTML Files:** `*.html`. Look for the overall structure, doctype, and meta tags.
|
|
10
|
+
- **CSS Files:** `*.css`. Look for the CSS architecture (e.g., BEM, SMACSS), preprocessors (e.g., Sass, Less), and frameworks (e.g., Bootstrap, Tailwind CSS).
|
|
11
|
+
- **Style & Linting Config:** `.stylelintrc`, `.prettierrc`. These define the coding standard.
|
|
12
|
+
|
|
13
|
+
## 2. Core Principles
|
|
14
|
+
|
|
15
|
+
- **HTML:**
|
|
16
|
+
- **Semantic HTML:** Use HTML elements for their intended purpose. For example, use `<nav>` for navigation, `<main>` for the main content, and `<article>` for articles.
|
|
17
|
+
- **Accessibility:** Follow accessibility best practices, such as using `alt` attributes for images and `aria-*` attributes for dynamic content.
|
|
18
|
+
- **CSS:**
|
|
19
|
+
- **Separation of Concerns:** Keep your CSS separate from your HTML. Use external stylesheets instead of inline styles.
|
|
20
|
+
- **Responsive Design:** Use media queries to create a responsive design that works on all screen sizes.
|
|
21
|
+
- **CSS Methodologies:** If the project uses a CSS methodology like BEM or SMACSS, follow it.
|
|
22
|
+
|
|
23
|
+
## 3. Implementation Patterns
|
|
24
|
+
|
|
25
|
+
- **HTML:**
|
|
26
|
+
- **Validation:** Validate your HTML using the W3C Markup Validation Service.
|
|
27
|
+
- **CSS:**
|
|
28
|
+
- **Prefixing:** Use a tool like Autoprefixer to add vendor prefixes to your CSS.
|
|
29
|
+
- **Minification:** Use a tool like cssnano to minify your CSS for production.
|
|
30
|
+
|
|
31
|
+
## 4. Common Commands
|
|
32
|
+
|
|
33
|
+
- **Linting:** `stylelint "**/*.css"`, `prettier --check "**/*.html"`
|
|
34
|
+
- **Formatting:** `prettier --write "**/*.{html,css}"`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Java Development Guide
|
|
2
|
+
|
|
3
|
+
This guide provides the baseline for Java development. It is superseded by project-specific conventions.
|
|
4
|
+
|
|
5
|
+
## 1. Project Analysis Checklist
|
|
6
|
+
|
|
7
|
+
Before coding, inspect the project for these files to determine its conventions:
|
|
8
|
+
|
|
9
|
+
- **Build System:** `pom.xml` (Maven) or `build.gradle` (Gradle). Note the dependencies, plugins, and build lifecycle.
|
|
10
|
+
- **Java Version:** Look for a `.java-version` file, or check the `pom.xml` or `build.gradle` file.
|
|
11
|
+
- **Style & Linting Config:** `.checkstyle.xml`, `.pmd.xml`. These define the coding standard.
|
|
12
|
+
- **Testing Framework:** Look for a `src/test/java` directory and check the build file for dependencies like `junit` or `testng`.
|
|
13
|
+
|
|
14
|
+
## 2. Core Principles
|
|
15
|
+
|
|
16
|
+
- **Style:** Strictly adhere to the project's configured linter (e.g., Checkstyle, PMD). If none exist, default to the Google Java Style Guide.
|
|
17
|
+
- **Object-Oriented Design:** Follow SOLID principles and use design patterns where appropriate.
|
|
18
|
+
- **API Design:** Follow the principles of good API design, such as keeping APIs small and focused.
|
|
19
|
+
|
|
20
|
+
## 3. Implementation Patterns
|
|
21
|
+
|
|
22
|
+
- **Error Handling:** Replicate existing patterns for exceptions. Use checked exceptions for recoverable errors and unchecked exceptions for programming errors.
|
|
23
|
+
- **Testing:** Use the project's existing test structure. Write unit tests for all new code.
|
|
24
|
+
- **Concurrency:** Follow existing concurrency patterns. Use the `java.util.concurrent` package for high-level concurrency abstractions.
|
|
25
|
+
|
|
26
|
+
## 4. Common Commands
|
|
27
|
+
|
|
28
|
+
- **Maven:**
|
|
29
|
+
- **Clean:** `mvn clean`
|
|
30
|
+
- **Compile:** `mvn compile`
|
|
31
|
+
- **Test:** `mvn test`
|
|
32
|
+
- **Package:** `mvn package`
|
|
33
|
+
- **Install:** `mvn install`
|
|
34
|
+
- **Gradle:**
|
|
35
|
+
- **Clean:** `./gradlew clean`
|
|
36
|
+
- **Build:** `./gradlew build`
|
|
37
|
+
- **Test:** `./gradlew test`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# JavaScript/TypeScript Development Guide
|
|
2
|
+
|
|
3
|
+
This guide provides the baseline for JS/TS development. It is superseded by project-specific conventions.
|
|
4
|
+
|
|
5
|
+
## 1. Project Analysis Checklist
|
|
6
|
+
|
|
7
|
+
Before coding, inspect the project for these files to determine its conventions:
|
|
8
|
+
|
|
9
|
+
- **Package Manager:** `package.json` (and `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`). Note the `scripts` and `dependencies`.
|
|
10
|
+
- **TypeScript/JavaScript Config:** `tsconfig.json` or `jsconfig.json`. This defines module system, strictness, and paths.
|
|
11
|
+
- **Style & Linting Config:** `.eslintrc.js`, `.prettierrc`, `package.json` (for `eslintConfig`, `prettier`). These define the coding standard.
|
|
12
|
+
- **Build/Vite Config:** `webpack.config.js`, `vite.config.ts`, `rollup.config.js`.
|
|
13
|
+
- **Testing Framework:** Look for a `tests/` or `__tests__/` directory, and config files like `jest.config.js` or `vitest.config.ts`.
|
|
14
|
+
|
|
15
|
+
## 2. Core Principles
|
|
16
|
+
|
|
17
|
+
- **Style:** Strictly adhere to the project's configured linter (`ESLint`) and formatter (`Prettier`).
|
|
18
|
+
- **TypeScript:** If the project uses TypeScript (`tsconfig.json` exists), you MUST use it for all new code. Adhere to the configured strictness level.
|
|
19
|
+
- **Module System:** Match the project's module system (e.g., ES Modules `import/export` or CommonJS `require/module.exports`). This is usually defined in `package.json` (`"type": "module"`) or `tsconfig.json`.
|
|
20
|
+
|
|
21
|
+
## 3. Package Management
|
|
22
|
+
|
|
23
|
+
- **`npm`:** If the project uses `package-lock.json`, add new dependencies using `npm install <package-name>`.
|
|
24
|
+
- **`yarn`:** If the project uses `yarn.lock`, add new dependencies using `yarn add <package-name>`.
|
|
25
|
+
- **`pnpm`:** If the project uses `pnpm-lock.yaml`, add new dependencies using `pnpm add <package-name>`.
|
|
26
|
+
|
|
27
|
+
## 4. Framework Conventions
|
|
28
|
+
|
|
29
|
+
- **React:** If the project uses React, follow its component structure (e.g., functional components with hooks), state management (e.g., `useState`, `useReducer`, Redux), and JSX syntax.
|
|
30
|
+
- **Vue:** If the project uses Vue, follow its single-file component structure, `v-` directives, and state management patterns (e.g., Pinia).
|
|
31
|
+
- **Angular:** If the project uses Angular, follow its module and component structure, dependency injection, and RxJS-based patterns.
|
|
32
|
+
|
|
33
|
+
## 5. Implementation Patterns
|
|
34
|
+
|
|
35
|
+
- **Error Handling:** Replicate existing patterns for `try/catch`, Promises (`.catch()`), and async/await error handling.
|
|
36
|
+
- **Testing:** Use the project's existing test runner (`Jest`, `Vitest`, `Mocha`), assertion library, and mocking patterns. Add tests for all new code.
|
|
37
|
+
- **Debugging:** Use the browser's developer tools for front-end code and the Node.js debugger (`node --inspect`) for back-end code.
|
|
38
|
+
|
|
39
|
+
## 6. Common Commands
|
|
40
|
+
|
|
41
|
+
- **Install Dependencies:** `npm install`, `yarn install`, `pnpm install`
|
|
42
|
+
- **Linting/Formatting:** `npm run lint`, `npm run format`
|
|
43
|
+
- **Type Checking:** `npm run typecheck`, `tsc --noEmit`
|
|
44
|
+
- **Testing:** `npm test`, `npm run test`
|
|
45
|
+
- **Building:** `npm run build`
|