From 30e9e65854483115e6f944ef3ead0b62ec2600ac Mon Sep 17 00:00:00 2001 From: Hare Date: Sun, 31 May 2026 09:52:04 +0900 Subject: [PATCH] cli: define workspace memory lint ticket --- .../item.md | 58 +++++++++++++++---- .../thread.md | 15 +++++ 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/work-items/open/20260527-000019-workspace-memory-lint-cli/item.md b/work-items/open/20260527-000019-workspace-memory-lint-cli/item.md index da897960..0276a564 100644 --- a/work-items/open/20260527-000019-workspace-memory-lint-cli/item.md +++ b/work-items/open/20260527-000019-workspace-memory-lint-cli/item.md @@ -5,24 +5,60 @@ title: ワークスペースのメモリーをLintするヘッドレスCLI status: open kind: task priority: P2 -labels: [migrated] +labels: [migrated, memory, cli] created_at: 2026-05-27T00:00:19Z -updated_at: 2026-05-27T00:00:19Z +updated_at: 2026-05-31T00:51:55Z assignee: null legacy_ticket: null --- -## Migration reference - -- legacy_ticket: null -- migrated_from: TODO.md / tickets directory migration on 2026-05-27 - -# ワークスペースのメモリーをLintするヘッドレスCLI - ## Background -This work item was migrated from an unfinished TODO.md entry that did not have a dedicated legacy ticket file. +The memory linter currently exists as library/pre-write validation used by memory tools, but there is no headless command to check all existing workspace memory/knowledge records at once. This makes it hard to validate `.insomnia/memory` and `.insomnia/knowledge` before commits, migrations, or manual edits. + +The installed user-facing binary is currently produced by the `tui` crate as `insomnia`. It is acceptable for this ticket to add the headless lint command to that crate/binary instead of introducing a separate binary. A future rename from `tui` crate to `insomnia`, or a more explicit single-binary CLI structure, can be handled separately. + +## Requirements + +- Add a headless CLI mode to the existing `insomnia` binary in the `tui` crate. +- Preferred invocation shape: `insomnia memory lint [--workspace ] [--json] [--warnings-as-errors]`. + - `insomnia memory` without `lint` should remain available as a normal positional Pod name if possible. + - If this shape is awkward with the current parser, keep the command unambiguous and document the chosen shape in tests/help text. +- Default workspace root is the current working directory. +- `--workspace ` overrides the workspace root passed to `memory::WorkspaceLayout::new`. +- Lint all existing records classified by `memory::WorkspaceLayout`: + - `.insomnia/memory/summary.md` when present; + - `.insomnia/memory/decisions/*.md`; + - `.insomnia/memory/requests/*.md`; + - `.insomnia/knowledge/*.md`. +- Do not lint subsystem-owned opaque trees such as `.insomnia/memory/_staging`, `_logs`, `_usage`. +- Use the existing `memory::Linter` and `WriteMode::Update` for existing files so the CLI matches tool pre-write validation semantics without triggering create-only duplicate slug checks on the file itself. +- Print a deterministic, human-readable report by default: + - file path; + - errors; + - warnings; + - summary counts. +- Exit status: + - `0` if no errors, and no warnings when `--warnings-as-errors` is set; + - `1` if lint errors are found, or warnings are found with `--warnings-as-errors`; + - `2` for CLI usage / I/O / unexpected runtime failures. +- `--json` may be simple but should be machine-readable and stable enough for scripts: include workspace, files, errors, warnings, and counts. +- The command must not start a Pod, connect to sockets, enter raw terminal mode, or mutate files. + +## Non-goals + +- Renaming the `tui` crate to `insomnia`. +- Adding a separate installed binary. +- Linting Workflow files; workflow linting can be a future command. +- Auto-fixing memory/knowledge records. +- Changing memory schema/linter rules. ## Acceptance criteria -- Define the concrete requirements before implementation. +- `insomnia memory lint` runs headlessly against the current directory and reports existing memory/knowledge lint results. +- `insomnia memory lint --workspace ` works in tests/fixtures. +- The command exits non-zero for lint errors. +- `--warnings-as-errors` makes warnings fail. +- `--json` returns valid JSON containing counts and per-file diagnostics. +- Existing Pod/TUI argument parsing behavior remains covered by tests, especially positional Pod names and `--multi`/`--resume` conflicts. +- `cargo fmt --check`, focused `cargo test -p tui` tests, `cargo check -p tui`, `./tickets.sh doctor`, and `git diff --check` pass. diff --git a/work-items/open/20260527-000019-workspace-memory-lint-cli/thread.md b/work-items/open/20260527-000019-workspace-memory-lint-cli/thread.md index 022593fd..d9a46c0c 100644 --- a/work-items/open/20260527-000019-workspace-memory-lint-cli/thread.md +++ b/work-items/open/20260527-000019-workspace-memory-lint-cli/thread.md @@ -4,4 +4,19 @@ Migrated from TODO.md entry without a legacy ticket file. No legacy review file was present at migration time. +--- + + + +## Plan + +Planning note: + +- Keep this in the existing user-facing `insomnia` binary implemented by the `tui` crate. Do not add another installed command for this ticket. +- The command should be headless: parse args, lint files, print report, exit. It must not initialize terminal UI or connect to a Pod. +- `insomnia memory lint` is preferred, but `insomnia memory` alone should continue to be a valid Pod-name attach/create path if practical with the current parser. +- Use `memory::Linter` directly so CLI behavior tracks tool pre-write validation. Existing files should be linted with `WriteMode::Update`. +- Keep crate rename / single-binary architecture as future cleanup, not part of this ticket. + + ---