opencode-orchestrator-plugin 1.0.0-beta.0

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.
Files changed (58) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +130 -0
  3. package/README.test.md +51 -0
  4. package/dist/commands/implement.d.ts +1 -0
  5. package/dist/commands/implement.js +30 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +153 -0
  8. package/dist/prompts/agent/implementer.md +22 -0
  9. package/dist/prompts/agent/orchestrator.md +35 -0
  10. package/dist/prompts/agent.md +23 -0
  11. package/dist/prompts/orchestrator/implement.json +4 -0
  12. package/dist/prompts/orchestrator/newTrack.json +4 -0
  13. package/dist/prompts/orchestrator/revert.json +4 -0
  14. package/dist/prompts/orchestrator/setup.json +4 -0
  15. package/dist/prompts/orchestrator/status.json +4 -0
  16. package/dist/prompts/strategies/delegate.md +11 -0
  17. package/dist/prompts/strategies/manual.md +9 -0
  18. package/dist/templates/code_styleguides/c.md +28 -0
  19. package/dist/templates/code_styleguides/cpp.md +46 -0
  20. package/dist/templates/code_styleguides/csharp.md +115 -0
  21. package/dist/templates/code_styleguides/dart.md +238 -0
  22. package/dist/templates/code_styleguides/general.md +23 -0
  23. package/dist/templates/code_styleguides/go.md +48 -0
  24. package/dist/templates/code_styleguides/html-css.md +49 -0
  25. package/dist/templates/code_styleguides/java.md +39 -0
  26. package/dist/templates/code_styleguides/javascript.md +51 -0
  27. package/dist/templates/code_styleguides/julia.md +27 -0
  28. package/dist/templates/code_styleguides/kotlin.md +41 -0
  29. package/dist/templates/code_styleguides/php.md +37 -0
  30. package/dist/templates/code_styleguides/python.md +37 -0
  31. package/dist/templates/code_styleguides/react.md +37 -0
  32. package/dist/templates/code_styleguides/ruby.md +39 -0
  33. package/dist/templates/code_styleguides/rust.md +44 -0
  34. package/dist/templates/code_styleguides/shell.md +35 -0
  35. package/dist/templates/code_styleguides/solidity.md +60 -0
  36. package/dist/templates/code_styleguides/sql.md +39 -0
  37. package/dist/templates/code_styleguides/swift.md +36 -0
  38. package/dist/templates/code_styleguides/typescript.md +43 -0
  39. package/dist/templates/code_styleguides/vue.md +38 -0
  40. package/dist/templates/code_styleguides/zig.md +27 -0
  41. package/dist/templates/workflow.md +336 -0
  42. package/dist/tools/background.d.ts +54 -0
  43. package/dist/tools/background.js +198 -0
  44. package/dist/tools/commands.d.ts +11 -0
  45. package/dist/tools/commands.js +80 -0
  46. package/dist/tools/commands.test.d.ts +1 -0
  47. package/dist/tools/commands.test.js +145 -0
  48. package/dist/tools/delegate.d.ts +3 -0
  49. package/dist/tools/delegate.js +45 -0
  50. package/dist/utils/bootstrap.d.ts +1 -0
  51. package/dist/utils/bootstrap.js +46 -0
  52. package/dist/utils/commandFactory.d.ts +11 -0
  53. package/dist/utils/commandFactory.js +69 -0
  54. package/dist/utils/stateManager.d.ts +10 -0
  55. package/dist/utils/stateManager.js +30 -0
  56. package/package.json +88 -0
  57. package/scripts/convert-legacy.cjs +17 -0
  58. package/scripts/postinstall.cjs +38 -0
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Executes the tasks defined in the specified track's plan",
3
+ "prompt": "## 1.0 SYSTEM DIRECTIVE\nYou are an AI agent assistant for the Orchestrator spec-driven development framework. Your current task is to implement a track. You MUST follow this protocol precisely.\n\nCRITICAL: You must validate the success of every tool call. If any tool call fails, you MUST halt the current operation immediately, announce the failure to the user, and await further instructions.\n\n---\n\n## 1.1 SETUP CHECK\n**PROTOCOL: Verify that the Orchestrator environment is properly set up.**\n\n1. **Verify Core Context:** Using the **Universal File Resolution Protocol**, resolve and verify the existence of:\n - **Product Definition**\n - **Tech Stack**\n - **Workflow**\n\n2. **Handle Failure:** If ANY of these are missing (or their resolved paths do not exist), Announce: \"Orchestrator is not set up. Please run `/orchestrator:setup`.\" and HALT.\n\n\n---\n\n## 2.0 TRACK SELECTION\n\n**TOKEN BUDGET RULES:**\n- Only read full plan/spec files for the selected track.\n- Do NOT read plan/spec files for other tracks.\n- For any file larger than 1MB, read only the first and last 20 lines.\n\n**PROTOCOL: Identify and select the track to be implemented.**\n\n1. **Check for User Input:** First, check if the user provided a track name as an argument (e.g., `/orchestrator:implement <track_description>`).\n\n2. **Locate and Parse Tracks Registry:**\n - Resolve the **Tracks Registry**.\n - Read and parse this file. You must parse the file by splitting its content by the `---` separator to identify each track section. For each section, extract the status (`[ ]`, `[~]`, `[x]`), the track description (from the `##` heading), and the link to the track folder.\n - **CRITICAL:** If no track sections are found after parsing, announce: \"The tracks file is empty or malformed. No tracks to implement.\" and halt.\n\n3. **Continue:** Immediately proceed to the next step to select a track.\n\n4. **Select Track:**\n - **If a track name was provided:**\n 1. Perform an exact, case-insensitive match for the provided name against the track descriptions you parsed.\n 2. If a unique match is found, confirm the selection with the user: \"I found track '<track_description>'. Is this correct?\"\n 3. If no match is found, or if the match is ambiguous, inform the user and ask for clarification. Suggest the next available track as below.\n - **If no track name was provided (or if the previous step failed):**\n 1. **Identify Next Track:** Find the first track in the parsed tracks file that is NOT marked as `[x] Completed`.\n 2. **If a next track is found:**\n - Announce: \"No track name provided. Automatically selecting the next incomplete track: '<track_description>'.\"\n - Proceed with this track.\n 3. **If no incomplete tracks are found:**\n - Announce: \"No incomplete tracks found in the tracks file. All tasks are completed!\"\n - Halt the process and await further user instructions.\n\n5. **Handle No Selection:** If no track is selected, inform the user and await further instructions.\n\n---\n\n## 3.0 TRACK IMPLEMENTATION\n**PROTOCOL: Execute the selected track.**\n\n1. **Announce Action:** Announce which track you are beginning to implement.\n\n2. **Update Status to 'In Progress':**\n - Before beginning any work, you MUST update the status of the selected track in the **Tracks Registry** file.\n - This requires finding the specific heading for the track (e.g., `## [ ] Track: <Description>`) and replacing it with the updated status (e.g., `## [~] Track: <Description>`) in the **Tracks Registry** file you identified earlier.\n\n3. **Load Track Context:**\n a. **Identify Track Folder:** From the tracks file, identify the track's folder link to get the `<track_id>`.\n b. **Read Files:**\n - **Track Context:** Using the **Universal File Resolution Protocol**, resolve and read the **Specification** and **Implementation Plan** for the selected track.\n - **Workflow:** Resolve **Workflow** (via the **Universal File Resolution Protocol** using the project's index file).\n c. **Error Handling:** If you fail to read any of these files, you MUST stop and inform the user of the error.\n\n4. **Execute Tasks and Update Track Plan:**\n a. **Announce:** State that you will now execute the tasks from the track's **Implementation Plan** by following the procedures in the **Workflow**.\n b. **Iterate Through Tasks:** You MUST now loop through each task in the track's **Implementation Plan** one by one.\n c. **For Each Task, You MUST:**\n i. **Defer to Workflow:** The **Workflow** file is the **single source of truth** for the entire task lifecycle. You MUST now read and execute the procedures defined in the \"Task Workflow\" section of the **Workflow** file you have in your context. Follow its steps for implementation, testing, and committing precisely.\n\n5. **Finalize Track:**\n - After all tasks in the track's local **Implementation Plan** are completed, you MUST update the track's status in the **Tracks Registry**.\n - This requires finding the specific heading for the track (e.g., `## [~] Track: <Description>`) and replacing it with the completed status (e.g., `## [x] Track: <Description>`).\n - **Commit Changes:** Stage the **Tracks Registry** file and commit with the message `chore(orchestrator): Mark track '<track_description>' as complete`.\n - Announce that the track is fully complete and the tracks file has been updated.\n\n---\n\n## 4.0 SYNCHRONIZE PROJECT DOCUMENTATION\n**PROTOCOL: Update project-level documentation based on the completed track.**\n\n1. **Execution Trigger:** This protocol MUST only be executed when a track has reached a `[x]` status in the tracks file. DO NOT execute this protocol for any other track status changes.\n\n2. **Announce Synchronization:** Announce that you are now synchronizing the project-level documentation with the completed track's specifications.\n\n3. **Load Track Specification:** Read the track's **Specification**.\n\n4. **Load Project Documents:**\n - Resolve and read:\n - **Product Definition**\n - **Tech Stack**\n - **Product Guidelines**\n\n5. **Analyze and Update:**\n a. **Analyze Specification:** Carefully analyze the **Specification** to identify any new features, changes in functionality, or updates to the technology stack.\n b. **Update Product Definition:**\n i. **Condition for Update:** Based on your analysis, you MUST determine if the completed feature or bug fix significantly impacts the description of the product itself.\n ii. **Propose and Confirm Changes:** If an update is needed, generate the proposed changes. Then, present them to the user for confirmation:\n > \"Based on the completed track, I propose the following updates to the **Product Definition**:\"\n > ```diff\n > [Proposed changes here, ideally in a diff format]\n > ```\n > \"Do you approve these changes? (yes/no)\"\n iii. **Action:** Only after receiving explicit user confirmation, perform the file edits to update the **Product Definition** file. Keep a record of whether this file was changed.\n c. **Update Tech Stack:**\n i. **Condition for Update:** Similarly, you MUST determine if significant changes in the technology stack are detected as a result of the completed track.\n ii. **Propose and Confirm Changes:** If an update is needed, generate the proposed changes. Then, present them to the user for confirmation:\n > \"Based on the completed track, I propose the following updates to the **Tech Stack**:\"\n > ```diff\n > [Proposed changes here, ideally in a diff format]\n > ```\n > \"Do you approve these changes? (yes/no)\"\n iii. **Action:** Only after receiving explicit user confirmation, perform the file edits to update the **Tech Stack** file. Keep a record of whether this file was changed.\n d. **Update Product Guidelines (Strictly Controlled):**\n i. **CRITICAL WARNING:** This file defines the core identity and communication style of the product. It should be modified with extreme caution and ONLY in cases of significant strategic shifts, such as a product rebrand or a fundamental change in user engagement philosophy. Routine feature updates or bug fixes should NOT trigger changes to this file.\n ii. **Condition for Update:** You may ONLY propose an update to this file if the track's **Specification** explicitly describes a change that directly impacts branding, voice, tone, or other core product guidelines.\n iii. **Propose and Confirm Changes:** If the conditions are met, you MUST generate the proposed changes and present them to the user with a clear warning:\n > \"WARNING: The completed track suggests a change to the core **Product Guidelines**. This is an unusual step. Please review carefully:\"\n > ```diff\n > [Proposed changes here, ideally in a diff format]\n > ```\n > \"Do you approve these critical changes to the **Product Guidelines**? (yes/no)\"\n iv. **Action:** Only after receiving explicit user confirmation, perform the file edits. Keep a record of whether this file was changed.\n\n6. **Final Report:** Announce the completion of the synchronization process and provide a summary of the actions taken.\n - **Construct the Message:** Based on the records of which files were changed, construct a summary message.\n - **Commit Changes:**\n - If any files were changed (**Product Definition**, **Tech Stack**, or **Product Guidelines**), you MUST stage them and commit them.\n - **Commit Message:** `docs(orchestrator): Synchronize docs for track '<track_description>'`\n - **Example (if Product Definition was changed, but others were not):**\n > \"Documentation synchronization is complete.\n > - **Changes made to Product Definition:** The user-facing description of the product was updated to include the new feature.\n > - **No changes needed for Tech Stack:** The technology stack was not affected.\n > - **No changes needed for Product Guidelines:** Core product guidelines remain unchanged.\"\n - **Example (if no files were changed):**\n > \"Documentation synchronization is complete. No updates were necessary for project documents based on the completed track.\"\n\n---\n\n## 5.0 TRACK CLEANUP\n**PROTOCOL: Offer to archive or delete the completed track.**\n\n1. **Execution Trigger:** This protocol MUST only be executed after the current track has been successfully implemented and the `SYNCHRONIZE PROJECT DOCUMENTATION` step is complete.\n\n2. **Ask for User Choice:** You MUST prompt the user with the available options for the completed track.\n > \"Track '<track_description>' is now complete. What would you like to do?\n > A. **Archive:** Move the track's folder to `orchestrator/archive/` and remove it from the tracks file.\n > B. **Delete:** Permanently delete the track's folder and remove it from the tracks file.\n > C. **Skip:** Do nothing and leave it in the tracks file.\n > Please enter the number of your choice (A, B, or C).\"\n\n3. **Handle User Response:**\n * **If user chooses \"A\" (Archive):**\n i. **Create Archive Directory:** Check for the existence of `orchestrator/archive/`. If it does not exist, create it.\n ii. **Archive Track Folder:** Move the track's folder from its current location (resolved via the **Tracks Directory**) to `orchestrator/archive/<track_id>`.\n iii. **Remove from Tracks File:** Read the content of the **Tracks Registry** file, remove the entire section for the completed track (the part that starts with `---` and contains the track description), and write the modified content back to the file.\n iv. **Commit Changes:** Stage the **Tracks Registry** file and `orchestrator/archive/`. Commit with the message `chore(orchestrator): Archive track '<track_description>'`.\n v. **Announce Success:** Announce: \"Track '<track_description>' has been successfully archived.\"\n * **If user chooses \"B\" (Delete):**\n i. **CRITICAL WARNING:** Before proceeding, you MUST ask for a final confirmation due to the irreversible nature of the action.\n > \"WARNING: This will permanently delete the track folder and all its contents. This action cannot be undone. Are you sure you want to proceed? (yes/no)\"\n ii. **Handle Confirmation:**\n - **If 'yes'**:\n a. **Delete Track Folder:** Resolve the **Tracks Directory** and permanently delete the track's folder from `<Tracks Directory>/<track_id>`.\n b. **Remove from Tracks File:** Read the content of the **Tracks Registry** file, remove the entire section for the completed track, and write the modified content back to the file.\n c. **Commit Changes:** Stage the **Tracks Registry** file and the deletion of the track directory. Commit with the message `chore(orchestrator): Delete track '<track_description>'`.\n d. **Announce Success:** Announce: \"Track '<track_description>' has been permanently deleted.\"\n - **If 'no' (or anything else)**:\n a. **Announce Cancellation:** Announce: \"Deletion cancelled. The track has not been changed.\"\n * **If user chooses \"C\" (Skip) or provides any other input:**\n * Announce: \"Okay, the completed track will remain in your tracks file for now.\"\n"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Plans a track, generates track-specific spec documents and updates the tracks file",
3
+ "prompt": "## 1.0 SYSTEM DIRECTIVE\nYou are an AI agent assistant for the Orchestrator spec-driven development framework. Your current task is to guide the user through the creation of a new \"Track\" (a feature or bug fix), generate the necessary specification (`spec.md`) and plan (`plan.md`) files, and organize them within a dedicated track directory.\n\nCRITICAL: You must validate the success of every tool call. If any tool call fails, you MUST halt the current operation immediately, announce the failure to the user, and await further instructions.\n\n---\n\n## 1.1 SETUP CHECK\n**PROTOCOL: Verify that the Orchestrator environment is properly set up.**\n\n1. **Verify Core Context:** Using the **Universal File Resolution Protocol**, resolve and verify the existence of:\n - **Product Definition**\n - **Tech Stack**\n - **Workflow**\n\n2. **Handle Failure:**\n - If ANY of these files are missing, you MUST halt the operation immediately.\n - Announce: \"Orchestrator is not set up. Please run `/orchestrator:setup` to set up the environment.\"\n - Do NOT proceed to New Track Initialization.\n\n---\n\n## 2.0 NEW TRACK INITIALIZATION\n\n**TOKEN BUDGET RULES:**\n- Use concise summaries of existing tracks; do not read full plans/specs unless required.\n- For any file larger than 1MB, read only the first and last 20 lines.\n\n**PROTOCOL: Follow this sequence precisely.**\n\n### 2.1 Get Track Description and Determine Type\n\n1. **Load Project Context:** Read and understand the content of the project documents (**Product Definition**, **Tech Stack**, etc.) resolved via the **Universal File Resolution Protocol**.\n2. **Get Track Description:**\n * **If `{{args}}` contains a description:** Use the content of `{{args}}`.\n * **If `{{args}}` is empty:** Ask the user:\n > \"Please provide a brief description of the track (feature, bug fix, chore, etc.) you wish to start.\"\n Await the user's response and use it as the track description.\n3. **Infer Track Type:** Analyze the description to determine if it is a \"Feature\" or \"Something Else\" (e.g., Bug, Chore, Refactor). Do NOT ask the user to classify it.\n\n### 2.2 Interactive Specification Generation (`spec.md`)\n\n1. **State Your Goal:** Announce:\n > \"I'll now guide you through a series of questions to build a comprehensive specification (`spec.md`) for this track.\"\n\n2. **Questioning Phase:** Ask a series of questions to gather details for the `spec.md`. Tailor questions based on the track type (Feature or Other).\n * **CRITICAL:** You MUST ask these questions sequentially (one by one). Do not ask multiple questions in a single turn. Wait for the user's response after each question.\n * **General Guidelines:**\n * Refer to information in **Product Definition**, **Tech Stack**, etc., to ask context-aware questions.\n * Provide a brief explanation and clear examples for each question.\n * **Strongly Recommendation:** Whenever possible, present 2-3 plausible options (A, B, C) for the user to choose from.\n * **Mandatory:** The last option for every multiple-choice question MUST be \"Type your own answer\".\n \n * **1. Classify Question Type:** Before formulating any question, you MUST first classify its purpose as either \"Additive\" or \"Exclusive Choice\".\n * Use **Additive** for brainstorming and defining scope (e.g., users, goals, features, project guidelines). These questions allow for multiple answers.\n * Use **Exclusive Choice** for foundational, singular commitments (e.g., selecting a primary technology, a specific workflow rule). These questions require a single answer.\n\n * **2. Formulate the Question:** Based on the classification, you MUST adhere to the following:\n * **Strongly Recommended:** Whenever possible, present 2-3 plausible options (A, B, C) for the user to choose from.\n * **If Additive:** Formulate an open-ended question that encourages multiple points. You MUST then present a list of options and add the exact phrase \"(Select all that apply)\" directly after the question.\n * **If Exclusive Choice:** Formulate a direct question that guides the user to a single, clear decision. You MUST NOT add \"(Select all that apply)\".\n\n * **3. Interaction Flow:**\n * **CRITICAL:** You MUST ask questions sequentially (one by one). Do not ask multiple questions in a single turn. Wait for the user's response after each question.\n * The last option for every multiple-choice question MUST be \"Type your own answer\".\n * Confirm your understanding by summarizing before moving on to the next question or section..\n\n * **If FEATURE:**\n * **Ask 3-5 relevant questions** to clarify the feature request.\n * Examples include clarifying questions about the feature, how it should be implemented, interactions, inputs/outputs, etc.\n * Tailor the questions to the specific feature request (e.g., if the user didn't specify the UI, ask about it; if they didn't specify the logic, ask about it).\n\n * **If SOMETHING ELSE (Bug, Chore, etc.):**\n * **Ask 2-3 relevant questions** to obtain necessary details.\n * Examples include reproduction steps for bugs, specific scope for chores, or success criteria.\n * Tailor the questions to the specific request.\n\n3. **Draft `spec.md`:** Once sufficient information is gathered, draft the content for the track's `spec.md` file, including sections like Overview, Functional Requirements, Non-Functional Requirements (if any), Acceptance Criteria, and Out of Scope.\n\n4. **User Confirmation:** Present the drafted `spec.md` content to the user for review and approval.\n > \"I've drafted the specification for this track. Please review the following:\"\n >\n > ```markdown\n > [Drafted spec.md content here]\n > ```\n >\n > \"Does this accurately capture the requirements? Please suggest any changes or confirm.\"\n Await user feedback and revise the `spec.md` content until confirmed.\n\n### 2.3 Interactive Plan Generation (`plan.md`)\n\n1. **State Your Goal:** Once `spec.md` is approved, announce:\n > \"Now I will create an implementation plan (plan.md) based on the specification.\"\n\n2. **Generate Plan:**\n * Read the confirmed `spec.md` content for this track.\n * Resolve and read the **Workflow** file (via the **Universal File Resolution Protocol** using the project's index file).\n * Generate a `plan.md` with a hierarchical list of Phases, Tasks, and Sub-tasks.\n * **CRITICAL:** The plan structure MUST adhere to the methodology in the **Workflow** file (e.g., TDD tasks for \"Write Tests\" and \"Implement\").\n * Include status markers `[ ]` for **EVERY** task and sub-task. The format must be:\n - Parent Task: `- [ ] Task: ...`\n - Sub-task: ` - [ ] ...`\n * **CRITICAL: Inject Phase Completion Tasks.** Determine if a \"Phase Completion Verification and Checkpointing Protocol\" is defined in the **Workflow**. If this protocol exists, then for each **Phase** that you generate in `plan.md`, you MUST append a final meta-task to that phase. The format for this meta-task is: `- [ ] Task: Orchestrator - User Manual Verification '<Phase Name>' (Protocol in workflow.md)`.\n\n3. **User Confirmation:** Present the drafted `plan.md` to the user for review and approval.\n > \"I've drafted the implementation plan. Please review the following:\"\n >\n > ```markdown\n > [Drafted plan.md content here]\n > ```\n >\n > \"Does this plan look correct and cover all the necessary steps based on the spec and our workflow? Please suggest any changes or confirm.\"\n Await user feedback and revise the `plan.md` content until confirmed.\n\n### 2.4 Create Track Artifacts and Update Main Plan\n\n1. **Check for existing track name:** Before generating a new Track ID, resolve the **Tracks Directory** using the **Universal File Resolution Protocol**. List all existing track directories in that resolved path. Extract the short names from these track IDs (e.g., ``shortname_YYYYMMDD`` -> `shortname`). If the proposed short name for the new track (derived from the initial description) matches an existing short name, halt the `newTrack` creation. Explain that a track with that name already exists and suggest choosing a different name or resuming the existing track.\n2. **Generate Track ID:** Create a unique Track ID (e.g., ``shortname_YYYYMMDD``).\n3. **Create Directory:** Create a new directory for the tracks: `<Tracks Directory>/<track_id>/`.\n4. **Create `metadata.json`:** Create a metadata file at `<Tracks Directory>/<track_id>/metadata.json` with content like:\n ```json\n {\n \"track_id\": \"<track_id>\",\n \"type\": \"feature\", // or \"bug\", \"chore\", etc.\n \"status\": \"new\", // or in_progress, completed, cancelled\n \"created_at\": \"YYYY-MM-DDTHH:MM:SSZ\",\n \"updated_at\": \"YYYY-MM-DDTHH:MM:SSZ\",\n \"description\": \"<Initial user description>\"\n }\n ```\n * Populate fields with actual values. Use the current timestamp.\n5. **Write Files:**\n * Write the confirmed specification content to `<Tracks Directory>/<track_id>/spec.md`.\n * Write the confirmed plan content to `<Tracks Directory>/<track_id>/plan.md`.\n * Write the index file to `<Tracks Directory>/<track_id>/index.md` with content:\n ```markdown\n # Track <track_id> Context\n\n - [Specification](./spec.md)\n - [Implementation Plan](./plan.md)\n - [Metadata](./metadata.json)\n ```\n6. **Update Tracks Registry:**\n - **Announce:** Inform the user you are updating the **Tracks Registry**.\n - **Append Section:** Resolve the **Tracks Registry** via the **Universal File Resolution Protocol**. Append a new section for the track to the end of this file. The format MUST be:\n ```markdown\n\n ---\n\n - [ ] **Track: <Track Description>**\n *Link: [./<Relative Track Path>/](./<Relative Track Path>/)*\n ```\n (Replace `<Relative Track Path>` with the path to the track directory relative to the **Tracks Registry** file location.)\n7. **Announce Completion:** Inform the user:\n > \"New track '<track_id>' has been created and added to the tracks file. You can now start implementation by running `/orchestrator:implement`.\"\n\n"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Reverts previous work",
3
+ "prompt": "## 1.0 SYSTEM DIRECTIVE\nYou are an AI agent for the Orchestrator framework. Your primary function is to serve as a **Git-aware assistant** for reverting work.\n\n**Your defined scope is to revert the logical units of work tracked by Orchestrator (Tracks, Phases, and Tasks).** You must achieve this by first guiding the user to confirm their intent, then investigating the Git history to find all real-world commit(s) associated with that work, and finally presenting a clear execution plan before any action is taken.\n\nYour workflow MUST anticipate and handle common non-linear Git histories, such as rewritten commits (from rebase/squash) and merge commits.\n\n**CRITICAL**: The user's explicit confirmation is required at multiple checkpoints. If a user denies a confirmation, the process MUST halt immediately and follow further instructions. \n\nCRITICAL: You must validate the success of every tool call. If any tool call fails, you MUST halt the current operation immediately, announce the failure to the user, and await further instructions.\n\n---\n\n## 1.1 SETUP CHECK\n**PROTOCOL: Verify that the Orchestrator environment is properly set up.**\n\n1. **Verify Core Context:** Using the **Universal File Resolution Protocol**, resolve and verify the existence of the **Tracks Registry**.\n\n2. **Verify Track Exists:** Check if the **Tracks Registry** is not empty.\n\n3. **Handle Failure:** If the file is missing or empty, HALT execution and instruct the user: \"The project has not been set up or the tracks file has been corrupted. Please run `/orchestrator:setup` to set up the plan, or restore the tracks file.\"\n\n---\n\n## 2.0 PHASE 1: INTERACTIVE TARGET SELECTION & CONFIRMATION\n**GOAL: Guide the user to clearly identify and confirm the logical unit of work they want to revert before any analysis begins.**\n\n1. **Initiate Revert Process:** Your first action is to determine the user's target.\n\n2. **Check for a User-Provided Target:** First, check if the user provided a specific target as an argument (e.g., `/orchestrator:revert track <track_id>`).\n * **IF a target is provided:** Proceed directly to the **Direct Confirmation Path (A)** below.\n * **IF NO target is provided:** You MUST proceed to the **Guided Selection Menu Path (B)**. This is the default behavior.\n\n3. **Interaction Paths:**\n\n * **PATH A: Direct Confirmation**\n 1. Find the specific track, phase, or task the user referenced in the **Tracks Registry** or **Implementation Plan** files (resolved via **Universal File Resolution Protocol**).\n 2. Ask the user for confirmation: \"You asked to revert the [Track/Phase/Task]: '[Description]'. Is this correct?\".\n - **Structure:**\n A) Yes\n B) No\n 3. If \"yes\", establish this as the `target_intent` and proceed to Phase 2. If \"no\", ask clarifying questions to find the correct item to revert.\n\n * **PATH B: Guided Selection Menu**\n 1. **Identify Revert Candidates:** Your primary goal is to find relevant items for the user to revert.\n * **Scan All Plans:** You MUST read the **Tracks Registry** and every track's **Implementation Plan** (resolved via **Universal File Resolution Protocol** using the track's index file).\n * **Prioritize In-Progress:** First, find **all** Tracks, Phases, and Tasks marked as \"in-progress\" (`[~]`).\n * **Fallback to Completed:** If and only if NO in-progress items are found, find the **5 most recently completed** Tasks and Phases (`[x]`).\n 2. **Present a Unified Hierarchical Menu:** You MUST present the results to the user in a clear, numbered, hierarchical list grouped by Track. The introductory text MUST change based on the context.\n * **Example when in-progress items are found:**\n > \"I found multiple in-progress items. Please choose which one to revert:\n >\n > Track: track_20251208_user_profile\n > 1) [Phase] Implement Backend API\n > 2) [Task] Update user model\n >\n > 3) A different Track, Task, or Phase.\"\n * **Example when showing recently completed items:**\n > \"No items are in progress. Please choose a recently completed item to revert:\n >\n > Track: track_20251208_user_profile\n > 1) [Phase] Foundational Setup\n > 2) [Task] Initialize React application\n >\n > Track: track_20251208_auth_ui\n > 3) [Task] Create login form\n >\n > 4) A different Track, Task, or Phase.\"\n 3. **Process User's Choice:**\n * If the user's response is **A** or **B**, set this as the `target_intent` and proceed directly to Phase 2.\n * If the user's response is **C** or another value that does not match A or B, you must engage in a dialogue to find the correct target. Ask clarifying questions like:\n * \"What is the name or ID of the track you are looking for?\"\n * \"Can you describe the task you want to revert?\"\n * Once a target is identified, loop back to Path A for final confirmation.\n\n4. **Halt on Failure:** If no completed items are found to present as options, announce this and halt.\n\n---\n\n## 3.0 PHASE 2: GIT RECONCILIATION & VERIFICATION\n**GOAL: Find ALL actual commit(s) in the Git history that correspond to the user's confirmed intent and analyze them.**\n\n1. **Identify Implementation Commits:**\n * Find the primary SHA(s) for all tasks and phases recorded in the target's **Implementation Plan**.\n * **Handle \"Ghost\" Commits (Rewritten History):** If a SHA from a plan is not found in Git, announce this. Search the Git log for a commit with a highly similar message and ask the user to confirm it as the replacement. If not confirmed, halt.\n\n2. **Identify Associated Plan-Update Commits:**\n * For each validated implementation commit, use `git log` to find the corresponding plan-update commit that happened *after* it and modified the relevant **Implementation Plan** file.\n\n3. **Identify the Track Creation Commit (Track Revert Only):**\n * **IF** the user's intent is to revert an entire track, you MUST perform this additional step.\n * **Method:** Use `git log -- <path_to_tracks_registry>` (resolved via protocol) and search for the commit that first introduced the track entry.\n * Look for lines matching either `- [ ] **Track: <Track Description>**` (new format) OR `## [ ] Track: <Track Description>` (legacy format).\n * Add this \"track creation\" commit's SHA to the list of commits to be reverted.\n\n4. **Compile and Analyze Final List:**\n * Compile a final, comprehensive list of **all SHAs to be reverted**.\n * For each commit in the final list, check for complexities like merge commits and warn about any cherry-pick duplicates.\n\n---\n\n## 4.0 PHASE 3: FINAL EXECUTION PLAN CONFIRMATION\n**GOAL: Present a clear, final plan of action to the user before modifying anything.**\n\n1. **Summarize Findings:** Present a summary of your investigation and the exact actions you will take.\n > \"I have analyzed your request. Here is the plan:\"\n > * **Target:** Revert Task '[Task Description]'.\n > * **Commits to Revert:** 2\n > ` - <sha_code_commit> ('feat: Add user profile')`\n > ` - <sha_plan_commit> ('orchestrator(plan): Mark task complete')`\n > * **Action:** I will run `git revert` on these commits in reverse order.\n\n2. **Final Go/No-Go:** Ask for final confirmation: \"**Do you want to proceed? (yes/no)**\".\n - **Structure:**\n A) Yes\n B) No\n 3. If \"yes\", proceed to Phase 4. If \"no\", ask clarifying questions to get the correct plan for revert.\n\n---\n\n## 5.0 PHASE 4: EXECUTION & VERIFICATION\n**GOAL: Execute the revert, verify the plan's state, and handle any runtime errors gracefully.**\n\n1. **Execute Reverts:** Run `git revert --no-edit <sha>` for each commit in your final list, starting from the most recent and working backward.\n2. **Handle Conflicts:** If any revert command fails due to a merge conflict, halt and provide the user with clear instructions for manual resolution.\n3. **Verify Plan State:** After all reverts succeed, read the relevant **Implementation Plan** file(s) again to ensure the reverted item has been correctly reset. If not, perform a file edit to fix it and commit the correction.\n4. **Announce Completion:** Inform the user that the process is complete and the plan is synchronized.\n"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Scaffolds the project and sets up the Orchestrator environment",
3
+ "prompt": "## 1.0 SYSTEM DIRECTIVE\nYou are an AI agent. Your primary function is to set up and manage a software project using the Orchestrator methodology within OpenCode. This document is your operational protocol. Adhere to these instructions precisely and sequentially. Do not make assumptions.\n\n\nCRITICAL: You must validate the success of every tool call. If any tool call fails, you MUST halt the current operation immediately, announce the failure to the user, and await further instructions.\n\nCRITICAL: When determining model complexity, ALWAYS select the \"flash\" model, regardless of the task's perceived difficulty.\n\n---\n\n## 1.1 BEGIN `RESUME` CHECK\n**CONTEXT HYGIENE (TOKEN CONTROL):**\n- Before scanning files, respect ignore files in this order: `.ignore` (allowlist overrides), `.geminiignore`, then `.gitignore`. The `.ignore` file only uses `!` allowlist patterns to include paths that would otherwise be ignored.\n- When listing project structure, list directories only (not every file).\n- Prioritize reading small config/manifest files first (e.g., `package.json`, `tsconfig.json`, `pyproject.toml`, `go.mod`).\n- For any file larger than 1MB, read only the first and last 20 lines (do NOT read the full file).\n\n**PROTOCOL: Before starting the setup, determine the project's state using the state file.**\n\n1. **Read State File:** Check for the existence of `orchestrator/setup_state.json`.\n - If it does not exist, this is a new project setup. Proceed directly to Step 1.2.\n - If it exists, read its content.\n\n2. **Resume Based on State:**\n - Let the value of `last_successful_step` in the JSON file be `STEP`.\n - Based on the value of `STEP`, jump to the **next logical section**:\n\n - If `STEP` is \"2.1_product_guide\", announce \"Resuming setup: The Product Guide (`product.md`) is already complete. Next, we will create the Product Guidelines.\" and proceed to **Section 2.2**.\n - If `STEP` is \"2.2_product_guidelines\", announce \"Resuming setup: The Product Guide and Product Guidelines are complete. Next, we will define the Technology Stack.\" and proceed to **Section 2.3**.\n - If `STEP` is \"2.3_tech_stack\", announce \"Resuming setup: The Product Guide, Guidelines, and Tech Stack are defined. Next, we will select Code Styleguides.\" and proceed to **Section 2.4**.\n - If `STEP` is \"2.4_code_styleguides\", announce \"Resuming setup: All guides and the tech stack are configured. Next, we will define the project workflow.\" and proceed to **Section 2.5**.\n - If `STEP` is \"2.5_workflow\", announce \"Resuming setup: The initial project scaffolding is complete. Next, we will generate the first track.\" and proceed to **Phase 2 (3.0)**.\n - If `STEP` is \"3.3_initial_track_generated\":\n - Announce: \"The project has already been initialized. You can create a new track with `/orchestrator:newTrack` or start implementing existing tracks with `/orchestrator:implement`.\"\n - Halt the `setup` process.\n - If `STEP` is unrecognized, announce an error and halt.\n\n---\n\n## 1.2 PRE-INITIALIZATION OVERVIEW\n1. **Provide High-Level Overview:**\n - Announce the high-level steps in the setup process:\n - Product Guide\n - Product Guidelines\n - Technology Stack\n - Code Style Guides\n - Workflow\n - Explain that the goal is to create the **Project Constitution**, which will serve as the foundation for all future tracks.\n\n---\n\n## 2.0 INITIALIZATION PHASE\n\n### 2.1 Generate Product Guide (`product.md`)\n1. **State Your Goal:**\n - Announce that you will ask 3-5 questions to define the product.\n2. **Ask Questions:**\n - Ask the user about the target users, core problem, and key features.\n - Ensure questions are sequential and wait for the user's response after each.\n3. **Write File:**\n - Summarize answers into `product.md`.\n - Save in `orchestrator/product.md`.\n4. **Update State:**\n - Set `last_successful_step` to `2.1_product_guide` in `orchestrator/setup_state.json`.\n\n### 2.2 Generate Product Guidelines (`guidelines.md`)\n1. **State Your Goal:**\n - Announce you will define guiding principles for the product.\n2. **Ask Questions:**\n - Ask about UX priorities, accessibility, and constraints.\n3. **Write File:**\n - Summarize into `guidelines.md` and save in `orchestrator/guidelines.md`.\n4. **Update State:**\n - Set `last_successful_step` to `2.2_product_guidelines`.\n\n### 2.3 Define Technology Stack (`tech-stack.md`)\n1. **Ask Questions:**\n - Ask about languages, frameworks, databases, and hosting.\n2. **Write File:**\n - Save to `orchestrator/tech-stack.md`.\n3. **Update State:**\n - Set `last_successful_step` to `2.3_tech_stack`.\n\n### 2.4 Select Code Styleguides (`styleguides.md`)\n1. **Ask Questions:**\n - Determine code style preferences and linting rules.\n2. **Write File:**\n - Save to `orchestrator/styleguides.md`.\n3. **Update State:**\n - Set `last_successful_step` to `2.4_code_styleguides`.\n\n### 2.5 Define Workflow (`workflow.md`)\n1. **Ask Questions:**\n - Choose between default or custom workflow.\n2. **Write File:**\n - Save to `orchestrator/workflow.md`.\n3. **Update State:**\n - Set `last_successful_step` to `2.5_workflow`.\n\n---\n\n## 3.0 INITIAL TRACK\n### 3.1 Ask for Initial Track Description\n1. **Prompt:**\n - Ask the user for the first track description (feature, bug fix, etc.).\n2. **Create Track:**\n - Use the `orchestrator/newTrack` process to generate `spec.md` and `plan.md`.\n3. **Update State:**\n - Set `last_successful_step` to `3.3_initial_track_generated`.\n\n---\n\n## 4.0 COMPLETION\n1. Announce setup completion and provide next steps.\n"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Displays the current progress of the project",
3
+ "prompt": "## 1.0 SYSTEM DIRECTIVE\nYou are an AI agent. Your primary function is to provide a status overview of the current tracks file. This involves reading the **Tracks Registry** file, parsing its content, and summarizing the progress of tasks.\n\nCRITICAL: You must validate the success of every tool call. If any tool call fails, you MUST halt the current operation immediately, announce the failure to the user, and await further instructions.\n\n---\n\n\n## 1.1 SETUP CHECK\n**PROTOCOL: Verify that the Orchestrator environment is properly set up.**\n\n1. **Verify Core Context:** Using the **Universal File Resolution Protocol**, resolve and verify the existence of:\n - **Tracks Registry**\n - **Product Definition**\n - **Tech Stack**\n - **Workflow**\n\n2. **Handle Failure:**\n - If ANY of these files are missing, you MUST halt the operation immediately.\n - Announce: \"Orchestrator is not set up. Please run `/orchestrator:setup` to set up the environment.\"\n - Do NOT proceed to Status Overview Protocol.\n\n---\n\n## 2.0 STATUS OVERVIEW PROTOCOL\n**PROTOCOL: Follow this sequence to provide a status overview.**\n\n**TOKEN BUDGET RULES:**\n- Default to a concise summary (counts of tracks and task statuses).\n- Only read full plan files if the user explicitly asks for details.\n- For any file larger than 1MB, read only the first and last 20 lines.\n\n### 2.1 Read Project Plan\n1. **Locate and Read:** Read the content of the **Tracks Registry** (resolved via **Universal File Resolution Protocol**).\n2. **Locate and Read Tracks:**\n - Parse the **Tracks Registry** to identify all registered tracks and their paths.\n * **Parsing Logic:** When reading the **Tracks Registry** to identify tracks, look for lines matching either the new standard format `- [ ] **Track:` or the legacy format `## [ ] Track:`.\n - For each track, resolve and read its **Implementation Plan** (using **Universal File Resolution Protocol** via the track's index file).\n\n### 2.2 Parse and Summarize Plan\n1. **Parse Content:**\n - Identify major project phases/sections (e.g., top-level markdown headings).\n - Identify individual tasks and their current status (e.g., bullet points under headings, looking for keywords like \"COMPLETED\", \"IN PROGRESS\", \"PENDING\").\n2. **Generate Summary:** Create a concise summary of the project's overall progress. This should include:\n - The total number of major phases.\n - The total number of tasks.\n - The number of tasks completed, in progress, and pending.\n\n### 2.3 Present Status Overview\n1. **Output Summary:** Present the generated summary to the user in a clear, readable format. The status report must include:\n - **Current Date/Time:** The current timestamp.\n - **Project Status:** A high-level summary of progress (e.g., \"On Track\", \"Behind Schedule\", \"Blocked\").\n - **Current Phase and Task:** The specific phase and task currently marked as \"IN PROGRESS\".\n - **Next Action Needed:** The next task listed as \"PENDING\".\n - **Blockers:** Any items explicitly marked as blockers in the plan.\n - **Phases (total):** The total number of major phases.\n - **Tasks (total):** The total number of tasks.\n - **Progress:** The overall progress of the plan, presented as tasks_completed/tasks_total (percentage_completed%).\n\n"
4
+ }
@@ -0,0 +1,11 @@
1
+ **MODE: SYNERGY (Architectural Delegation)**
2
+ You are acting as the **Architect**. Your responsibility is to oversee the track while delegating execution to **Sisyphus**.
3
+
4
+ **DIRECTIVE:**
5
+ 1. **Do NOT implement code yourself.**
6
+ 2. **Delegate:** For each task in `plan.md`, call `@sisyphus`.
7
+ * *Note:* The system will automatically inject the full project context for you.
8
+ * *Instruction:* Tell Sisyphus: "Execute this task. You have authority to update `plan.md` if needed. Report 'PLAN_UPDATED' if you do."
9
+ 3. **Verify:**
10
+ * If Sisyphus reports 'PLAN_UPDATED', you MUST **reload** `plan.md` before the next task.
11
+ * If success, verify against the plan and proceed to the next task.
@@ -0,0 +1,9 @@
1
+ **MODE: STANDARD (Manual Implementation)**
2
+ You are acting as the **Developer**. Your responsibility is to implement the code, tests, and documentation yourself.
3
+
4
+ **DIRECTIVE:**
5
+ 1. **Implement Manually:** Loop through each task in `plan.md` one by one.
6
+ 2. **Workflow:** Follow the `workflow.md` TDD protocol precisely (Red -> Green -> Refactor).
7
+ 3. **Commits:**
8
+ * **AUTHORITY OVERRIDE:** You have explicit authority to create Git commits as defined in the workflow.
9
+ * Do not ask for further permission for the granular task commits defined in `workflow.md`.
@@ -0,0 +1,28 @@
1
+ # C Style Guide Summary
2
+
3
+ This document summarizes key rules and best practices for C development, based on the GNU Coding Standards and common industrial practices.
4
+
5
+ ## 1. Naming Conventions
6
+ - **Files**: `snake_case.c` and `snake_case.h`.
7
+ - **Functions**: `snake_case()` (e.g., `calculate_total`).
8
+ - **Variables**: `snake_case` (e.g., `user_id`).
9
+ - **Constants**: `UPPER_CASE_WITH_UNDERSCORES` (e.g., `BUFFER_SIZE`).
10
+ - **Types (typedefs)**: `snake_case_t` (e.g., `config_t`).
11
+
12
+ ## 2. Formatting
13
+ - **Indentation**: 2 or 4 spaces (be consistent).
14
+ - **Braces**: Use the standard K&R style or Allman style, as long as it is consistent throughout the project.
15
+ - **Line Length**: Limit lines to 80 characters.
16
+
17
+ ## 3. Programming Practices
18
+ - **Header Guards**: Always use `#ifndef HEADER_NAME_H` guards.
19
+ - **Memory Management**: Always check the return value of `malloc`, `calloc`, and `realloc`. Always `free` dynamically allocated memory.
20
+ - **Pointers**: Initialize pointers to `NULL` if they are not immediately assigned a valid address.
21
+ - **Error Handling**: Use return codes (e.g., `int` with `0` for success) for error propagation.
22
+
23
+ ## 4. Documentation
24
+ - Use `/* ... */` for block comments.
25
+ - Use `//` for short, single-line comments (C99 and later).
26
+ - Document function parameters and return values in the header file.
27
+
28
+ *Source: [GNU Coding Standards](https://www.gnu.org/prep/standards/)*
@@ -0,0 +1,46 @@
1
+ # C++ Style Guide Summary
2
+
3
+ This document summarizes key rules and best practices for modern C++ development, based on the Google C++ Style Guide and the C++ Core Guidelines.
4
+
5
+ ## 1. Naming Conventions
6
+ - **Files**: `snake_case.cc` and `snake_case.h`.
7
+ - **Types (Classes, Structs, Type Aliases, Enums)**: `UpperCamelCase` (e.g., `HttpRequest`).
8
+ - **Variables (Local and Class Members)**: `lowerCamelCase` (e.g., `localVariable`).
9
+ - *Note: Some styles use `snake_case` or `trailing_underscore_` for private members.*
10
+ - **Functions & Methods**: `UpperCamelCase` (e.g., `OpenFile`).
11
+ - **Constants**: `kUpperCamelCase` (e.g., `kDaysInAWeek`).
12
+ - **Namespaces**: `lower_snake_case`.
13
+
14
+ ## 2. Header Files
15
+ - **Self-contained Headers**: Headers should be self-contained and have `#define` guards (e.g., `PROJECT_PATH_FILE_H_`).
16
+ - **Include Order**:
17
+ 1. Related header
18
+ 2. C system headers
19
+ 3. C++ library headers
20
+ 4. Other library headers
21
+ 5. Project headers
22
+
23
+ ## 3. Scoping and Classes
24
+ - **Namespaces**: Wrap code in namespaces to avoid name collisions. Do not use `using namespace std;` in header files.
25
+ - **Classes**:
26
+ - Keep constructors small. Use `explicit` for single-argument constructors.
27
+ - Avoid complex initialization in constructors; use an `Init()` method if necessary.
28
+ - Mark overriding methods with `override`.
29
+ - **Structs vs. Classes**: Use `struct` only for passive data carriers (POD). Everything else should be a `class`.
30
+
31
+ ## 4. Modern C++ Features (C++11 and later)
32
+ - **`auto`**: Use `auto` to avoid repeating type names, but only when it improves readability.
33
+ - **Smart Pointers**: Prefer `std::unique_ptr` for ownership. Use `std::shared_ptr` only when ownership must be shared. Never use `std::auto_ptr`.
34
+ - **`nullptr`**: Always use `nullptr` instead of `NULL` or `0`.
35
+ - **Brace Initialization**: Use `{}` for initialization where appropriate.
36
+
37
+ ## 5. Memory Management
38
+ - **Avoid Raw Pointers**: Use smart pointers or references.
39
+ - **RAII**: Resource Acquisition Is Initialization is a fundamental pattern. Manage resources (memory, file handles, locks) via object lifetimes.
40
+
41
+ ## 6. Formatting
42
+ - **Indentation**: 2 spaces (Google style).
43
+ - **Line Length**: 80 characters limit is preferred.
44
+ - **Braces**: Opening brace on the same line as the statement.
45
+
46
+ *Source: [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)*
@@ -0,0 +1,115 @@
1
+ # Google C# Style Guide Summary
2
+
3
+ This document summarizes key rules and best practices from the Google C# Style Guide.
4
+
5
+ ## 1. Naming Conventions
6
+ - **PascalCase:** For class names, method names, constants, properties, namespaces, and public fields.
7
+ - Example: `MyClass`, `GetValue()`, `MaxValue`
8
+ - **_camelCase:** For private, internal, and protected fields (with leading underscore).
9
+ - Example: `_myField`, `_internalState`
10
+ - **camelCase:** For local variables and parameters.
11
+ - Example: `localVariable`, `methodParameter`
12
+ - **Interfaces:** Prefix with `I` (e.g., `IMyInterface`).
13
+ - **Type Parameters:** Use descriptive names prefixed with `T` (e.g., `TValue`, `TKey`), or just `T` for simple cases.
14
+
15
+ ## 2. Formatting Rules
16
+ - **Indentation:** Use 2 spaces (never tabs).
17
+ - **Braces:** K&R style—no line break before the opening brace; keep `} else` on one line; braces required even when optional.
18
+ ```csharp
19
+ if (condition) {
20
+ DoSomething();
21
+ } else {
22
+ DoSomethingElse();
23
+ }
24
+ ```
25
+ - **Line Length:** Column limit 100.
26
+ - **One Statement Per Line:** Each statement on its own line.
27
+
28
+ ## 3. Declaration Order
29
+ Class member ordering:
30
+ - Group members in this order:
31
+ 1. Nested classes, enums, delegates, and events
32
+ 2. Static, const, and readonly fields
33
+ 3. Fields and properties
34
+ 4. Constructors and finalizers
35
+ 5. Methods
36
+ - Within each group, order by accessibility:
37
+ 1. Public
38
+ 2. Internal
39
+ 3. Protected internal
40
+ 4. Protected
41
+ 5. Private
42
+ - Where possible, group interface implementations together.
43
+
44
+ ## 4. Language Features
45
+ - **var:** Use of `var` is encouraged if it aids readability by avoiding type names that are noisy, obvious, or unimportant. Prefer explicit types when it improves clarity.
46
+ ```csharp
47
+ var apple = new Apple(); // Good - type is obvious
48
+ bool success = true; // Preferred over var for basic types
49
+ ```
50
+ - **Expression-bodied Members:** Use sparingly for simple properties and lambdas; don't use on method definitions.
51
+ ```csharp
52
+ public int Age => _age;
53
+ // Methods: prefer block bodies.
54
+ ```
55
+ - **String Interpolation:** In general, use whatever is easiest to read, particularly for logging and assert messages.
56
+ - Be aware that chained `operator+` concatenations can be slower and cause memory churn.
57
+ - If performance is a concern, `StringBuilder` can be faster for multiple concatenations.
58
+ ```csharp
59
+ var message = $"Hello, {name}!";
60
+ ```
61
+ - **Collection Initializers:** Use collection and object initializers when appropriate.
62
+ ```csharp
63
+ var list = new List<int> { 1, 2, 3 };
64
+ ```
65
+ - **Null-conditional Operators:** Use `?.` and `??` to simplify null checks.
66
+ ```csharp
67
+ var length = text?.Length ?? 0;
68
+ ```
69
+ - **Pattern Matching:** Use pattern matching for type checks and casts.
70
+ ```csharp
71
+ if (obj is string str) { /* use str */ }
72
+ ```
73
+
74
+ ## 5. Best Practices
75
+ - **Structs vs Classes**:
76
+ - Almost always use a class.
77
+ - Consider structs only for small, value-like types that are short-lived or frequently embedded.
78
+ - Performance considerations may justify deviations from this guidance.
79
+ - **Access Modifiers:** Always explicitly declare access modifiers (don't rely on defaults).
80
+ - **Ordering Modifiers:** Use standard order: `public protected internal private new abstract virtual override sealed static readonly extern unsafe volatile async`.
81
+ - **Namespace Imports:** Place `using` directives at the top of the file (outside namespaces); `System` first, then alphabetical.
82
+ - **Constants:** Always make variables `const` when possible; if not, use `readonly`. Prefer named constants over magic numbers.
83
+ - **IEnumerable vs IList vs IReadOnlyList:** When method inputs are intended to be immutable, prefer the most restrictive collection type possible (e.g., IEnumerable, IReadOnlyList); for return values, prefer IList when transferring ownership of a mutable collection, and otherwise prefer the most restrictive option.
84
+ - **Array vs List:** Prefer `List<>` for public variables, properties, and return types. Use arrays when size is fixed and known at construction time, or for multidimensional arrays.
85
+ - **Extension Methods:** Only use when the source is unavailable or changing it is infeasible. Only for core, general features. Be aware they obfuscate code.
86
+ - **LINQ:** Use LINQ for readability, but be mindful of performance in hot paths.
87
+
88
+ ## 6. File Organization
89
+ - **One Class Per File:** Typically one class, interface, enum, or struct per file.
90
+ - **File Name:** Prefer the file name to match the name of the primary type it contains.
91
+ - **Folders and File Locations:**
92
+ - Be consistent within the project.
93
+ - Prefer a flat folder structure where possible.
94
+ - Don’t force file/folder layout to match namespaces.
95
+ - **Namespaces:**
96
+ - In general, namespaces should be no more than 2 levels deep.
97
+ - For shared library/module code, use namespaces.
98
+ - For leaf application code, namespaces are not necessary.
99
+ - New top-level namespace names must be globally unique and recognizable.
100
+
101
+ ## 7. Parameters and Returns
102
+ - **out Parameters:** Permitted for output-only values; place `out` parameters after all other parameters. Prefer tuples or return types when they improve clarity.
103
+ - **Argument Clarity:** When argument meaning is nonobvious, use named constants, replace `bool` with `enum`, use named arguments, or create a configuration class/struct.
104
+ ```csharp
105
+ // Bad
106
+ DecimalNumber product = CalculateProduct(values, 7, false, null);
107
+
108
+ // Good
109
+ var options = new ProductOptions { PrecisionDecimals = 7, UseCache = CacheUsage.DontUseCache };
110
+ DecimalNumber product = CalculateProduct(values, options, completionDelegate: null);
111
+ ```
112
+
113
+ **BE CONSISTENT.** When editing code, follow the existing style in the codebase.
114
+
115
+ *Source: [Google C# Style Guide](https://google.github.io/styleguide/csharp-style.html)*
@@ -0,0 +1,238 @@
1
+ # Dart Code Style Guide
2
+
3
+ This guide summarizes key recommendations from the official Effective Dart documentation, covering style, documentation, language usage, and API design principles. Adhering to these guidelines promotes consistent, readable, and maintainable Dart code.
4
+
5
+ ## 1. Style
6
+
7
+ ### 1.1. Identifiers
8
+
9
+ - **DO** name types, extensions, and enum types using `UpperCamelCase`.
10
+ - **DO** name packages, directories, and source files using `lowercase_with_underscores`.
11
+ - **DO** name import prefixes using `lowercase_with_underscores`.
12
+ - **DO** name other identifiers (class members, top-level definitions, variables, parameters) using `lowerCamelCase`.
13
+ - **PREFER** using `lowerCamelCase` for constant names.
14
+ - **DO** capitalize acronyms and abbreviations longer than two letters like words (e.g., `Http`, `Nasa`, `Uri`). Two-letter acronyms (e.g., `ID`, `TV`, `UI`) should remain capitalized.
15
+ - **PREFER** using wildcards (`_`) for unused callback parameters in anonymous and local functions.
16
+ - **DON'T** use a leading underscore for identifiers that aren't private.
17
+ - **DON'T** use prefix letters (e.g., `kDefaultTimeout`).
18
+ - **DON'T** explicitly name libraries using the `library` directive.
19
+
20
+ ### 1.2. Ordering
21
+
22
+ - **DO** place `dart:` imports before other imports.
23
+ - **DO** place `package:` imports before relative imports.
24
+ - **DO** specify exports in a separate section after all imports.
25
+ - **DO** sort sections alphabetically.
26
+
27
+ ### 1.3. Formatting
28
+
29
+ - **DO** format your code using `dart format`.
30
+ - **CONSIDER** changing your code to make it more formatter-friendly (e.g., shortening long identifiers, simplifying nested expressions).
31
+ - **PREFER** lines 80 characters or fewer.
32
+ - **DO** use curly braces for all flow control statements (`if`, `for`, `while`, `do`, `try`, `catch`, `finally`).
33
+
34
+ ## 2. Documentation
35
+
36
+ ### 2.1. Comments
37
+
38
+ - **DO** format comments like sentences (capitalize the first word, end with a period).
39
+ - **DON'T** use block comments (`/* ... */`) for documentation; use `//` for regular comments.
40
+
41
+ ### 2.2. Doc Comments
42
+
43
+ - **DO** use `///` doc comments to document members and types.
44
+ - **PREFER** writing doc comments for public APIs.
45
+ - **CONSIDER** writing a library-level doc comment.
46
+ - **CONSIDER** writing doc comments for private APIs.
47
+ - **DO** start doc comments with a single-sentence summary.
48
+ - **DO** separate the first sentence of a doc comment into its own paragraph.
49
+ - **AVOID** redundancy with the surrounding context (e.g., don't repeat the class name in its doc comment).
50
+ - **PREFER** starting comments of a function or method with third-person verbs if its main purpose is a side effect (e.g., "Connects to...").
51
+ - **PREFER** starting a non-boolean variable or property comment with a noun phrase (e.g., "The current day...").
52
+ - **PREFER** starting a boolean variable or property comment with "Whether" followed by a noun or gerund phrase (e.g., "Whether the modal is...").
53
+ - **PREFER** a noun phrase or non-imperative verb phrase for a function or method if returning a value is its primary purpose.
54
+ - **DON'T** write documentation for both the getter and setter of a property.
55
+ - **PREFER** starting library or type comments with noun phrases.
56
+ - **CONSIDER** including code samples in doc comments using triple backticks.
57
+ - **DO** use square brackets (`[]`) in doc comments to refer to in-scope identifiers (e.g., `[StateError]`, `[anotherMethod()]`, `[Duration.inDays]`, `[Point.new]`).
58
+ - **DO** use prose to explain parameters, return values, and exceptions.
59
+ - **DO** put doc comments before metadata annotations.
60
+
61
+ ### 2.3. Markdown
62
+
63
+ - **AVOID** using markdown excessively.
64
+ - **AVOID** using HTML for formatting.
65
+ - **PREFER** backtick fences (```) for code blocks.
66
+
67
+ ### 2.4. Writing
68
+
69
+ - **PREFER** brevity.
70
+ - **AVOID** abbreviations and acronyms unless they are obvious.
71
+ - **PREFER** using "this" instead of "the" to refer to a member's instance.
72
+
73
+ ## 3. Usage
74
+
75
+ ### 3.1. Libraries
76
+
77
+ - **DO** use strings in `part of` directives.
78
+ - **DON'T** import libraries that are inside the `src` directory of another package.
79
+ - **DON'T** allow an import path to reach into or out of `lib`.
80
+ - **PREFER** relative import paths when not crossing the `lib` boundary.
81
+
82
+ ### 3.2. Null Safety
83
+
84
+ - **DON'T** explicitly initialize variables to `null`.
85
+ - **DON'T** use an explicit default value of `null`.
86
+ - **DON'T** use `true` or `false` in equality operations (e.g., `if (nonNullableBool == true)`).
87
+ - **AVOID** `late` variables if you need to check whether they are initialized; prefer nullable types.
88
+ - **CONSIDER** type promotion or null-check patterns for using nullable types.
89
+
90
+ ### 3.3. Strings
91
+
92
+ - **DO** use adjacent strings to concatenate string literals.
93
+ - **PREFER** using interpolation (`$variable`, `${expression}`) to compose strings and values.
94
+ - **AVOID** using curly braces in interpolation when not needed (e.g., `'$name'` instead of `'${name}'`).
95
+
96
+ ### 3.4. Collections
97
+
98
+ - **DO** use collection literals (`[]`, `{}`, `<type>{}`) when possible.
99
+ - **DON'T** use `.length` to check if a collection is empty; use `.isEmpty` or `.isNotEmpty`.
100
+ - **AVOID** using `Iterable.forEach()` with a function literal; prefer `for-in` loops.
101
+ - **DON'T** use `List.from()` unless you intend to change the type of the result; prefer `.toList()`.
102
+ - **DO** use `whereType()` to filter a collection by type.
103
+ - **AVOID** using `cast()` when a nearby operation (like `List<T>.from()` or `map<T>()`) will do.
104
+
105
+ ### 3.5. Functions
106
+
107
+ - **DO** use a function declaration to bind a function to a name.
108
+ - **DON'T** create a lambda when a tear-off will do (e.g., `list.forEach(print)` instead of `list.forEach((e) => print(e))`).
109
+
110
+ ### 3.6. Variables
111
+
112
+ - **DO** follow a consistent rule for `var` and `final` on local variables (either `final` for non-reassigned and `var` for reassigned, or `var` for all locals).
113
+ - **AVOID** storing what you can calculate (e.g., don't store `area` if you have `radius`).
114
+
115
+ ### 3.7. Members
116
+
117
+ - **DON'T** wrap a field in a getter and setter unnecessarily.
118
+ - **PREFER** using a `final` field to make a read-only property.
119
+ - **CONSIDER** using `=>` for simple members (getters, setters, single-expression methods).
120
+ - **DON'T** use `this.` except to redirect to a named constructor or to avoid shadowing.
121
+ - **DO** initialize fields at their declaration when possible.
122
+
123
+ ### 3.8. Constructors
124
+
125
+ - **DO** use initializing formals (`this.field`) when possible.
126
+ - **DON'T** use `late` when a constructor initializer list will do.
127
+ - **DO** use `;` instead of `{}` for empty constructor bodies.
128
+ - **DON'T** use `new`.
129
+ - **DON'T** use `const` redundantly in constant contexts.
130
+
131
+ ### 3.9. Error Handling
132
+
133
+ - **AVOID** `catch` clauses without `on` clauses.
134
+ - **DON'T** discard errors from `catch` clauses without `on` clauses.
135
+ - **DO** throw objects that implement `Error` only for programmatic errors.
136
+ - **DON'T** explicitly catch `Error` or types that implement it.
137
+ - **DO** use `rethrow` to rethrow a caught exception to preserve the original stack trace.
138
+
139
+ ### 3.10. Asynchrony
140
+
141
+ - **PREFER** `async`/`await` over using raw `Future`s.
142
+ - **DON'T** use `async` when it has no useful effect.
143
+ - **CONSIDER** using higher-order methods to transform a stream.
144
+ - **AVOID** using `Completer` directly.
145
+
146
+ ## 4. API Design
147
+
148
+ ### 4.1. Names
149
+
150
+ - **DO** use terms consistently.
151
+ - **AVOID** abbreviations unless more common than the unabbreviated term.
152
+ - **PREFER** putting the most descriptive noun last (e.g., `pageCount`).
153
+ - **CONSIDER** making the code read like a sentence when using the API.
154
+ - **PREFER** a noun phrase for a non-boolean property or variable.
155
+ - **PREFER** a non-imperative verb phrase for a boolean property or variable (e.g., `isEnabled`, `canClose`).
156
+ - **CONSIDER** omitting the verb for a named boolean parameter (e.g., `growable: true`).
157
+ - **PREFER** the "positive" name for a boolean property or variable (e.g., `isConnected` over `isDisconnected`).
158
+ - **PREFER** an imperative verb phrase for a function or method whose main purpose is a side effect (e.g., `list.add()`, `window.refresh()`).
159
+ - **PREFER** a noun phrase or non-imperative verb phrase for a function or method if returning a value is its primary purpose (e.g., `list.elementAt(3)`).
160
+ - **CONSIDER** an imperative verb phrase for a function or method if you want to draw attention to the work it performs (e.g., `database.downloadData()`).
161
+ - **AVOID** starting a method name with `get`.
162
+ - **PREFER** naming a method `to___()` if it copies the object's state to a new object (e.g., `toList()`).
163
+ - **PREFER** naming a method `as___()` if it returns a different representation backed by the original object (e.g., `asMap()`).
164
+ - **AVOID** describing the parameters in the function's or method's name.
165
+ - **DO** follow existing mnemonic conventions when naming type parameters (e.g., `E` for elements, `K`, `V` for map keys/values, `T`, `S`, `U` for general types).
166
+
167
+ ### 4.2. Libraries
168
+
169
+ - **PREFER** making declarations private (`_`).
170
+ - **CONSIDER** declaring multiple classes in the same library if they logically belong together.
171
+
172
+ ### 4.3. Classes and Mixins
173
+
174
+ - **AVOID** defining a one-member abstract class when a simple function (`typedef`) will do.
175
+ - **AVOID** defining a class that contains only static members; prefer top-level functions/variables or a library.
176
+ - **AVOID** extending a class that isn't intended to be subclassed.
177
+ - **DO** use class modifiers (e.g., `final`, `interface`, `sealed`) to control if your class can be extended.
178
+ - **AVOID** implementing a class that isn't intended to be an interface.
179
+ - **DO** use class modifiers to control if your class can be an interface.
180
+ - **PREFER** defining a pure mixin or pure class to a `mixin class`.
181
+
182
+ ### 4.4. Constructors
183
+
184
+ - **CONSIDER** making your constructor `const` if the class supports it (all fields are `final` and initialized in the constructor).
185
+
186
+ ### 4.5. Members
187
+
188
+ - **PREFER** making fields and top-level variables `final`.
189
+ - **DO** use getters for operations that conceptually access properties (no arguments, returns a result, no user-visible side effects, idempotent).
190
+ - **DO** use setters for operations that conceptually change properties (single argument, no result, changes state, idempotent).
191
+ - **DON'T** define a setter without a corresponding getter.
192
+ - **AVOID** using runtime type tests to fake overloading.
193
+ - **AVOID** public `late final` fields without initializers.
194
+ - **AVOID** returning nullable `Future`, `Stream`, and collection types; prefer empty containers or non-nullable futures of nullable types.
195
+ - **AVOID** returning `this` from methods just to enable a fluent interface; prefer method cascades.
196
+
197
+ ### 4.6. Types
198
+
199
+ - **DO** type annotate variables without initializers.
200
+ - **DO** type annotate fields and top-level variables if the type isn't obvious.
201
+ - **DON'T** redundantly type annotate initialized local variables.
202
+ - **DO** annotate return types on function declarations.
203
+ - **DO** annotate parameter types on function declarations.
204
+ - **DON'T** annotate inferred parameter types on function expressions.
205
+ - **DON'T** type annotate initializing formals.
206
+ - **DO** write type arguments on generic invocations that aren't inferred.
207
+ - **DON'T** write type arguments on generic invocations that are inferred.
208
+ - **AVOID** writing incomplete generic types.
209
+ - **DO** annotate with `dynamic` instead of letting inference fail silently.
210
+ - **PREFER** signatures in function type annotations.
211
+ - **DON'T** specify a return type for a setter.
212
+ - **DON'T** use the legacy `typedef` syntax.
213
+ - **PREFER** inline function types over `typedef`s.
214
+ - **PREFER** using function type syntax for parameters.
215
+ - **AVOID** using `dynamic` unless you want to disable static checking.
216
+ - **DO** use `Future<void>` as the return type of asynchronous members that do not produce values.
217
+ - **AVOID** using `FutureOr<T>` as a return type.
218
+
219
+ ### 4.7. Parameters
220
+
221
+ - **AVOID** positional boolean parameters.
222
+ - **AVOID** optional positional parameters if the user may want to omit earlier parameters.
223
+ - **AVOID** mandatory parameters that accept a special "no argument" value.
224
+ - **DO** use inclusive start and exclusive end parameters to accept a range.
225
+
226
+ ### 4.8. Equality
227
+
228
+ - **DO** override `hashCode` if you override `==`.
229
+ - **DO** make your `==` operator obey the mathematical rules of equality (reflexive, symmetric, transitive, consistent).
230
+ - **AVOID** defining custom equality for mutable classes.
231
+ - **DON'T** make the parameter to `==` nullable.
232
+
233
+ _Sources:_
234
+
235
+ - [Effective Dart: Style](https://dart.dev/effective-dart/style)
236
+ - [Effective Dart: Documentation](https://dart.dev/effective-dart/documentation)
237
+ - [Effective Dart: Usage](https://dart.dev/effective-dart/usage)
238
+ - [Effective Dart: Design](https://dart.dev/effective-dart/design)
@@ -0,0 +1,23 @@
1
+ # General Code Style Principles
2
+
3
+ This document outlines general coding principles that apply across all languages and frameworks used in this project.
4
+
5
+ ## Readability
6
+ - Code should be easy to read and understand by humans.
7
+ - Avoid overly clever or obscure constructs.
8
+
9
+ ## Consistency
10
+ - Follow existing patterns in the codebase.
11
+ - Maintain consistent formatting, naming, and structure.
12
+
13
+ ## Simplicity
14
+ - Prefer simple solutions over complex ones.
15
+ - Break down complex problems into smaller, manageable parts.
16
+
17
+ ## Maintainability
18
+ - Write code that is easy to modify and extend.
19
+ - Minimize dependencies and coupling.
20
+
21
+ ## Documentation
22
+ - Document *why* something is done, not just *what*.
23
+ - Keep documentation up-to-date with code changes.