Metadata-Version: 2.4
Name: metsuke
Version: 0.1.0
Summary: AI-Assisted Development Task Manager using YAML plans.
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License. 
Project-URL: Homepage, https://github.com/your_username/metsuke
Project-URL: Bug Tracker, https://github.com/your_username/metsuke/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Requires-Dist: pydantic>=2.0
Requires-Dist: click>=8.0
Requires-Dist: toml>=0.10.0
Requires-Dist: textual>=0.50.0
Requires-Dist: watchdog>=2.0.0
Requires-Dist: pyperclip>=1.8.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Dynamic: license-file

# Metsuke ✨

**Metsuke (目つけ): AI-Assisted Development Task Manager**

The name "Metsuke" comes from Japanese, often translated as "gaze" or "looking". However, in disciplines like martial arts (Budo), it signifies much more than just physical sight. Metsuke refers to the *correct way of seeing* – encompassing not just *what* you look at, but *how* you perceive the whole situation, maintain focus, anticipate movement, and understand intent without being fixated on minor details. It implies focused awareness and comprehensive perception.

This project aims to bring that spirit of focused awareness and clear perception to the collaboration between human developers and AI assistants. By providing a structured plan and context (`PROJECT_PLAN.yaml`), Metsuke helps both human and AI maintain focus on the overall goals and current tasks, improving understanding and leading to more intentional, effective development.

## Why Metsuke? Enhancing Human-AI Collaboration 🤝

Working effectively with AI coding assistants requires clear communication and shared context. Metsuke is designed to work synergistically with AI coding assistants. Its structured approach using `PROJECT_PLAN.yaml` is particularly effective when the AI assistant also operates under a structured protocol (like RIPER-5) that emphasizes clear planning, execution, and review phases. This combination helps ensure predictable, reliable, and aligned collaboration. Metsuke bridges the gap by providing a structured framework based on a `PROJECT_PLAN.yaml` file, leading to significant benefits for both the human developer and the AI:

**For the Human Developer:** 🧑‍💻

*   **Clarity & Overview:** Get a clear, persistent view of project goals, context, and task status, reducing mental overhead.
*   **Structured Planning:** Define tasks, dependencies, and priorities explicitly.
*   **Improved AI Guidance:** Formulate requests to the AI with less ambiguity by referencing specific tasks and context from the plan.
*   **Reliable Context:** Avoid losing critical context buried in long chat histories.
*   **Easier Verification:** Quickly check if AI actions align with the planned tasks.
*   **Interactive TUI Dashboard (`metsuke tui`):** Gain real-time visibility into the project's status through an optional terminal interface. Visually track task completion progress, view status/priority breakdowns, explore dependencies, check suggested next steps, and monitor internal logs—all providing a convenient, high-level overview of the ongoing work and the AI's activity.

**For the AI Assistant:** 🤖

*   **Structured Input:** Receive project state, context, and task details in a predictable, machine-readable format.
*   **Focused Tasks:** Understand the specific goal of each request within the larger project plan.
*   **Relevant Context:** Access necessary background information directly from the plan file.
*   **Improved Accuracy:** Generate more relevant code and suggestions based on clear context and task definitions.
*   **Reduced Deviation:** Minimize guesswork and actions outside the scope of the agreed-upon plan.

**Synergy & Performance:** 👍

*   **Shared Understanding:** Creates a single source of truth for the project plan, minimizing miscommunication.
*   **Predictable Collaboration:** Makes the AI's behavior more aligned with the developer's intent.
*   **Faster Progress:** Reduces time spent on clarifying instructions or correcting off-track AI work.
*   **Higher Quality:** Promotes better outcomes through structured planning and focused execution.

By using Metsuke, the human-AI development team can collaborate more effectively, leading to faster, more robust, and more predictable results.

### Example: Metsuke in Action ▶️

Imagine the following exchange without Metsuke:

> **User:** Can you update the status bar to show the date?
> **AI:** Sure, I'll modify the `StatusBar` widget... *(Proceeds to edit code that might not exist yet or is in the wrong place)*

Now, contrast that with a Metsuke-guided interaction:

> **User:** Please work on **Task 16** (Enhance TUI StatusBar Display).
>
> **AI Assistant (using Metsuke):** Okay, I see Task 16 is to enhance the `StatusBar` display with the date. Let me check the plan...
> ```yaml
> - id: 16
>   title: Enhance TUI StatusBar Display
>   # ...
>   status: pending
>   dependencies: [ 9 ]
> - id: 9
>   title: Structure TUI Code within Package
>   # ...
>   status: pending
> ```
> **AI Assistant:** Task 16 depends on **Task 9** (`Structure TUI Code within Package`), which is still `pending`. We need to complete Task 9 first by refactoring the TUI code into `src/metsuke/tui/` before I can safely modify the `StatusBar`. Shall we proceed with Task 9 instead?

This example demonstrates how Metsuke provides:

*   **Unambiguous Task Reference:** The user clearly specifies Task 16.
*   **Dependency Awareness:** The AI checks `PROJECT_PLAN.yaml` and correctly identifies the prerequisite (Task 9).
*   **Error Prevention:** The AI avoids potentially harmful actions by respecting the planned dependencies.
*   **Guided Workflow:** The collaboration stays focused and follows the logical development order.

## Features (Planned) 💡

*   **YAML-based Planning:** Define project context, goals, and tasks in a human-readable and machine-parseable format.
*   **CLI Interface:** View project info, list tasks, check status (including TUI via `metsuke tui`).
*   **Library API:** Programmatically load, validate, and potentially modify project plans.
*   **Task Management:** Track task status (pending, in_progress, done, etc.) and dependencies.
*   **Context Awareness:** Provides a central place for project context, easily accessible by both humans and AI.

## Installation 📦

```bash
# Core CLI/Library (includes TUI)
pip install metsuke

# For development:
pip install -e .
```

## Usage ⌨️

**Command Line Interface (CLI):**

```bash
# View project info
metsuke show-info

# List tasks
metsuke list-tasks

# Launch Terminal UI (Requires TUI dependencies)
metsuke tui

# (More commands to come)
```

**Library Usage:**

```python
from metsuke import load_plan, PlanLoadingError, PlanValidationError

try:
    project_plan = load_plan("PROJECT_PLAN.yaml")
    print(f"Project Name: {project_plan.project.name}")
    for task in project_plan.tasks:
        print(f"- Task {task.id}: {task.title} ({task.status})")
except (PlanLoadingError, PlanValidationError) as e:
    print(f"Error loading plan: {e}")
```

## Terminal User Interface (TUI)  TUI

The Metsuke TUI provides a visual and interactive way to explore the `PROJECT_PLAN.yaml` content directly in your terminal. It automatically monitors the plan file for changes and updates the display in real-time.

<!-- TODO: Add a screenshot or GIF of the TUI in action -->

**Launching the TUI:**

To launch the TUI, simply run the command:
```bash
metsuke tui
```

**Interface Overview:**

*   **Top Area:** Displays the project title (`Metsuke`) and project metadata (Version, Name, License) loaded from the plan.
*   **Dashboard:** A panel showing high-level statistics:
    *   *Left Panel:* Overall task progress bar, counts of tasks by status (Done, In Progress, Pending, Blocked), and a breakdown of tasks by priority (High, Medium, Low).
    *   *Right Panel:* Dependency metrics (e.g., number of ready tasks, blocked tasks) and a suggestion for the next task to work on based on priority and readiness.
*   **Task Table:** A scrollable table listing all tasks with their ID, Title, Status, Priority, and Dependencies.
*   **Log View (Hidden by default):** A panel at the bottom (toggle with `Ctrl+D`) that shows internal TUI logging messages, useful for debugging.
*   **Status Bar:** Docked at the very bottom, showing the current time and author information.
*   **Footer:** Displays the primary key bindings for quick reference.

**Key Features & Bindings:**

*   **Navigation:** Use the `Up`/`Down` arrow keys to navigate through the Task Table.
*   **Help / Context (`?`):** Press `?` to open a modal screen. This screen displays:
    *   The full project `context` defined in `PROJECT_PLAN.yaml`.
    *   A detailed list of all available key bindings.
    *   Press `Esc` or `Q` to close the Help screen.
*   **Log Panel:**
    *   `Ctrl+D`: Toggles the visibility of the Log View panel at the bottom.
    *   `Ctrl+L`: Copies the entire content of the Log View to your system clipboard (requires `pyperclip` to be functional).
*   **Command Palette (`Ctrl+P`):** Opens Textual's built-in command palette, allowing access to actions like changing the color theme, toggling dark/light mode, etc.
*   **Quit (`Q`):** Press `Q` to exit the TUI application.

**File Monitoring:**

The TUI automatically watches the `PROJECT_PLAN.yaml` file. If you modify and save the file while the TUI is running, it will detect the change, reload the data, and refresh the display with the updated information.

## Tutorial: Getting Started & AI Collaboration Workflow 🚀

This tutorial guides you through the entire process of setting up Metsuke for a new project and using it to collaborate effectively with an AI coding assistant.

**1. Get the Code**

First, clone the Metsuke repository (or your project's repository if Metsuke is added as a dependency later):
```bash
# Replace with the actual repository URL if different
git clone https://github.com/your_username/metsuke.git 
cd metsuke
```

**2. Setup Environment & Install**

It's highly recommended to use a Python virtual environment.
(Requires Anaconda or Miniconda installed)
```bash
# python -m venv .venv # Old venv command
# source .venv/bin/activate # On Windows use `.venv\Scripts\activate` # Old venv command
conda create --name metsuke-env python=3.9 -y # Or choose another Python version >= 3.8
conda activate metsuke-env
```
Install Metsuke in editable mode (includes TUI dependencies):
```bash
pip install -e .
```

**3. Initialize the Plan**

Navigate to your project's root directory (if you cloned Metsuke, you are already there) and run:
```bash
metsuke init
```
This command:
*   Checks if a `PROJECT_PLAN.yaml` already exists (and exits if it does).
*   Attempts to detect your project's name and version from `pyproject.toml` (but uses placeholders in the generated file).
*   Creates a `PROJECT_PLAN.yaml` file containing:
    *   Collaboration guidelines (comments at the top).
    *   Placeholder project metadata (`name: Your Project Name`, `version: '0.1.0'`).
    *   A default project context section (you should edit this!).
    *   A list of common starting tasks (you should customize these!).

**Important:** Open the newly created `PROJECT_PLAN.yaml` and customize the `project`, `context`, and initial `tasks` to match your actual project requirements.

**4. Open in AI-Powered Editor**

Open your project folder in an AI-powered code editor that supports direct interaction with an AI assistant, such as Cursor or VS Code with appropriate extensions.

**5. Engage the AI Assistant**

This is a crucial step for enabling effective collaboration.
You need to **explicitly instruct your AI assistant to use the `PROJECT_PLAN.yaml` file** as the foundation for your work together.

Example prompts:

> *   "Please read the `PROJECT_PLAN.yaml` file to understand the project goals, context, and current tasks."*
> *   "Let's use `PROJECT_PLAN.yaml` as our single source of truth for planning and tasks."
> *   "Refer to the tasks and context in `PROJECT_PLAN.yaml` for our development work going forward."
> *   "I have a `PROJECT_PLAN.yaml` file defining our project. Please make sure you load and reference it."

Ensure the AI acknowledges that it has access to and will use the file. Some advanced AI integrations might detect and use the file automatically, but explicit instruction is the most reliable approach.

**6. Collaborative Workflow Example**

Here's how a typical interaction might look, assuming the AI assistant understands Metsuke and ideally follows a structured protocol (like RIPER-5):

> **You:** "We need a new feature to detect circular dependencies in the plan file itself. Please add this as a new task to `PROJECT_PLAN.yaml`, priority 'medium'."
>
> **AI Assistant (using Metsuke):** (Reads `PROJECT_PLAN.yaml`, finds last ID was 5) "Okay, I will add **Task 6: Implement dependency cycle detection**, priority 'medium', depending on Task 2 (Define core data models). Does this plan look good for the description: '**Plan:** 1. Represent task dependencies as a graph. 2. Implement a graph traversal algorithm (e.g., Depth First Search). 3. Detect back edges during traversal which indicate cycles. 4. Report cycles found.'?"
>
> **You:** "Yes, that plan looks good. Please add it."
>
> **AI Assistant:** (Uses file editing tool) "Okay, I have added Task 6 to `PROJECT_PLAN.yaml`."
>
> **You:** "Now, please implement Task 6."
>
> **AI Assistant:** "Acknowledged. Entering EXECUTE mode for **Task 6: Implement dependency cycle detection**. Based on the plan, I will first represent dependencies as a graph..." *(Proceeds with implementation, potentially involving further planning/review steps based on its protocol)*
>
> *(...Implementation happens...)*
>
> **AI Assistant:** "Implementation for Task 6 is complete. **Test Method:** Create a test plan file `PROJECT_PLAN_cycle.yaml` with a known dependency cycle (e.g., Task A depends on B, Task B depends on A). Call the new function `core.detect_cycles('PROJECT_PLAN_cycle.yaml')` and assert that it returns `True`."
>
> **You:** *(You run the test)* "Confirmed, the test passes."
>
> **You:** "Please mark Task 6 as Done in the plan file."
>
> **AI Assistant:** (Uses file editing tool) "Understood. Updating status for Task 6 to 'Done' in `PROJECT_PLAN.yaml`."

**Outcome:**

This workflow, facilitated by Metsuke and a cooperating AI, ensures:
*   **Clarity:** Both user and AI reference the same plan.
*   **Traceability:** Changes (like adding Task 6) are reflected in the plan.
*   **Structure:** Development follows defined tasks and dependencies.
*   **Verification:** The AI proposes a test method, and the user confirms completion.

This structured approach minimizes misunderstandings and keeps the development process focused and efficient.

## Development 🛠️

See `PROJECT_PLAN.yaml` for the development roadmap and task breakdown.

## License 📄

This project is licensed under the Apache License 2.0. See the `LICENSE` file for details.
