@difflab/difflab-cli 0.2.0 → 0.4.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 (3) hide show
  1. package/README.md +38 -0
  2. package/dist/index.js +32555 -10868
  3. package/package.json +5 -1
package/README.md CHANGED
@@ -8,6 +8,31 @@ A Bun command-line application with a local Difflab MCP server.
8
8
  bunx @difflab/difflab-cli
9
9
  ```
10
10
 
11
+ ## Local Projects
12
+
13
+ A Project can contain multiple GitHub repositories. Its key is the sole project identifier and directory name; there is no separate slug or UUID. All Projects and repositories share one user-wide SQLite database at `~/.difflab/difflab.sqlite`. The CLI keeps repository artifacts separately under `~/.difflab/projects/<PROJECT_KEY>/<github-owner>--<github-repo>/`. The database migrations run locally on write operations.
14
+
15
+ Create a Project, repeating `--repo` for each repository:
16
+
17
+ ```bash
18
+ difflab project add <PROJECT_KEY> --name 'My Project' --repo https://github.com/org/repo
19
+ ```
20
+
21
+ Then link a repository to the existing Project:
22
+
23
+ ```bash
24
+ cd /path/to/existing/github-repository
25
+ difflab init <PROJECT_KEY>
26
+ ```
27
+
28
+ The `project add` command requires a project key, name, and at least one repository. If any value is missing, it returns command guidance instead of prompting. `difflab init <PROJECT_KEY>` only links the current repository to an existing Project; it never creates one. The existing `difflab-cli` command is an alias for `difflab`.
29
+
30
+ Initialization requires a GitHub HTTPS or SSH origin and never creates a Git repository. It writes a tracked `difflab.yaml` containing only the Project key without staging it. The repo-root `.difflab` symlink points at the Project's per-repository artifact directory. Existing conflicting paths are never overwritten. Do not commit the symlink or SQLite files. A repository config copied to another machine needs explicit local setup; the read-only MCP tool will not import or repair it.
31
+
32
+ If initialization is interrupted, retry `difflab init <PROJECT_KEY>`; matching partial links and database rows can be reused, but conflicting paths require manual inspection. Do not delete the shared database to repair a repository link.
33
+
34
+ The `project_context({ cwd })` MCP tool inspects initialized repositories without creating files or applying migrations. If it reports missing or inconsistent setup, load the portable `skills/difflab-init/SKILL.md` in your client's Agent Skills directory and follow its CLI steps. Existing `todo_*` MCP tools remain available.
35
+
11
36
  ## MCP setup
12
37
 
13
38
  After installing the CLI so `difflab-cli` is on your PATH, register it with the MCP clients you use:
@@ -21,6 +46,19 @@ Clients are selected explicitly. Supported names: `pi`, `cursor`, `codex`, `clau
21
46
 
22
47
  MCP clients launch `npx -y @difflab/difflab-cli mcp serve` over stdio, so no daemon or port is needed. Bun must be on the client's PATH.
23
48
 
49
+ ## Document templates
50
+
51
+ List the available templates or scaffold a new document from one:
52
+
53
+ ```bash
54
+ difflab-cli templates list
55
+ difflab-cli templates scaffold spec-driven-plan docs/plans first-plan.md --cwd /absolute/project/path
56
+ ```
57
+
58
+ The CLI defaults `--cwd` to its current directory. The MCP server exposes `template_list({})` and `scaffold({"name":"spec-driven-plan","cwd":"/absolute/project/path","path":"docs/plans","filename":"first-plan.md"})`. Both interfaces take a hyphenated template name, a relative destination **directory** (`path`, or `.` for `cwd`), and a separate **filename**. MCP always requires an absolute existing `cwd`. Missing destination directories are created. Available names: `spec-driven-plan`, `software-architecture-design`, `architecture-decision-record`, `product-requirements-document`, `code-review`, `planning-intent`, `ui-component-architecture`, and `pull-request-description` (adapted from Diffpi's PR template).
59
+
60
+ On first use, missing bundled templates and filled examples are copied to `~/.difflab/templates` and `~/.difflab/templates/examples`. Edit the installed templates to customize future documents. Later runs add missing files but never replace existing ones, even after an upgrade. Examples are for reference, not selectable templates. Copying is literal: prompts and placeholders are not substituted. An unknown name, missing or invalid source, unsafe path, symlink, or existing destination causes an error; destination files are never overwritten. The target directory must remain inside `cwd` and the filename must be a single file name without separators. To restore a bundled default, move your installed copy aside before listing again.
61
+
24
62
  ## Develop
25
63
 
26
64
  ```bash