@dibs.ai/dibs 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +100 -2
- package/package.json +78 -4
- package/schema.json +33 -0
- package/src/cli/index.ts +94 -0
- package/src/cli/mcp.ts +79 -0
- package/src/core/adapters/dex/README.md +40 -0
- package/src/core/adapters/dex/dex.schema.json +17 -0
- package/src/core/adapters/dex/index.ts +82 -0
- package/src/core/adapters/sync-all.ts +15 -0
- package/src/core/adapters/sync.ts +81 -0
- package/src/core/adapters/things/README.md +49 -0
- package/src/core/adapters/things/index.ts +73 -0
- package/src/core/adapters/things/things.schema.json +17 -0
- package/src/core/ctx.ts +6 -0
- package/src/core/identity.ts +19 -0
- package/src/core/panel.ts +39 -0
- package/src/core/store.ts +184 -0
- package/src/core/tasks.ts +150 -0
- package/src/core/todo.ts +80 -0
- package/src/core/util.ts +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Add `dibs mcp`: an MCP server over stdio (`src/cli/mcp.ts`) with six tools, `todo_list`, `todo_create`, `todo_edit`, `todo_status`, `todo_link` and `todo_resolve`. The Claude Code plugin registers it; the Codex, opencode and Cursor READMEs show the config.
|
|
6
|
+
|
|
7
|
+
- Add task attribution: `created_by` and `human` fields (todo.txt `dibsby:`/`dibshuman:`), `--human` on `create`/`edit`/`list`/`ready`, `DIBS_AGENT`/`DIBS_USER`, and `adapters.<name>.human` to sync only one human's tasks.
|
|
8
|
+
- Add `dibs sync`: syncs every adapter enabled in config; shares `syncAll` (`src/core/adapters/sync-all.ts`) with the Pi extension.
|
|
9
|
+
- Add `dibs` CLI (`src/cli`) over the shared core: `list`, `ready`, `create`, `start`, `complete`, `edit`, `import`, `export`, `link`, `scope`, `migrate`. Trusted if `DIBS_TRUST=1` or the project has an `.dibs/` folder; otherwise it uses the temp store.
|
|
10
|
+
- Split code into layers: `src/core` (shared, host-free), `src/cli`, `agents/shared` (skill and assets reused by agents), and `agents/<name>` (Pi extension, Claude Code plugin, Codex, opencode and Cursor integrations).
|
|
11
|
+
- Add `bun run build:agent <name>`: writes `dist/<name>/` from `agents/shared/`, then `agents/<name>/` on top, so an agent file at the same path replaces the shared one.
|
|
12
|
+
- Add Claude Code, Codex, opencode and Cursor integrations shipping the `dibs` skill, which shells out to the CLI.
|
|
13
|
+
- Breaking: rename pi-do to dibs: package `dibs`, folders `.dibs/` and `~/.dibs/`, env vars `DIBS_*`, todo.txt tags `dibsid:`/`dibsstart:`/`dibsdesc:`/`dibsparent:`/`dibsresult:`, `dibs://` links. An existing `.pi-do/` or `~/.pi-do/` is still used when the new folder is missing, and import still reads the old `pi*:` tags.
|
|
14
|
+
- Config is now `config.json` (JSONC) with a `$schema` pinned to the installed version (`schema.json`, plus `src/adapters/<name>/<name>.schema.json` per adapter) for editor autocomplete and validation. `config.jsonl` files are converted on first read.
|
|
15
|
+
- Add Things 3 adapter (macOS): each pi-do project syncs with a Things project of the same name; two-way sync of name, notes and completion via the Things URL scheme; `/todos connect things <token>` stores the auth token.
|
|
16
|
+
- Replace backends with adapters: the pi-do file store always holds tasks; Dex becomes an adapter with two-way `sync` (`"adapters": {"dex": {"sync": true}}`). `backend` config and `PI_DO_BACKEND` are removed.
|
|
17
|
+
- Default file backend stores todos in trusted projects at `.pi-do/` (or `.agents/pi-do/` if present): `config.jsonl`, `todos/lists.jsonl` index and `todos/<name>.todos.jsonl`, starting with a "Hello World" todo. Untrusted projects keep the temporary session file.
|
|
18
|
+
- Each JSONL line maps 1:1 to a todo.txt line; new `/todos import <path>` complements export (skips duplicate lines and `piid:`s).
|
|
19
|
+
- `~/.pi-do/` holds the global `config.jsonl` and `projects/projects.jsonl`, which tracks every project (`id`, `name`, `path`, `scope`, `created`). Projects are matched by the id in their local `config.jsonl`.
|
|
20
|
+
- `/todos scope project|global` moves a project's todos to or from `~/.pi-do/projects/<name>.<id>/`.
|
|
21
|
+
- `/todos migrate .pi-do|.agents/pi-do` moves the project store between folders. Trusted projects only.
|
|
22
|
+
- `--global` on export/import targets the global store.
|
|
23
|
+
- Temp and untrusted sessions use the same layout under `$TMPDIR/pi-do/<session-hash>/.pi-do/` and start empty; Hello World is added only on first install (no `~/.pi-do/` yet) or when a new permanent todos file is created.
|
|
24
|
+
- Breaking: `config.jsonl` (global < project < `PI_DO_*` env) replaces the `piDo` block in Pi `settings.json`. New env vars `PI_DO_SCOPE`, `PI_DO_HOME`.
|
|
25
|
+
|
|
26
|
+
## 0.1.0
|
|
27
|
+
|
|
28
|
+
- Extract the existing Dex task tool and panel into a standalone Pi package; behavior unchanged.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 arobida
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dibs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A task store for coding agents. In Pi it adds task tools and a panel above the editor. Other agents reach the same store through the `dibs` CLI or an MCP server.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Task panel: a live task list above the editor, collapsible, with current, project and completed views.
|
|
8
|
+
- Task tools: the Pi agent creates, lists, edits, starts and completes tasks through the `todo_list`, `todo_create`, `todo_edit` and `todo_status` tools (plus `todo_link` and `todo_resolve`).
|
|
9
|
+
- todo.txt format: import and export todo.txt lines. Priority, dates and dibs fields are stored as separate JSON keys.
|
|
10
|
+
- One store, synced adapters: tasks live in dibs's JSONL file, and the optional Dex and Things adapters sync both ways.
|
|
11
|
+
- Export: `/todos export <path>` writes the store to a plain todo.txt file.
|
|
12
|
+
- Live reload: the panel watches task storage and refreshes when other agents change it.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Pi coding agent for the panel and tools; [Bun](https://bun.sh) 1.4 or later for the CLI
|
|
17
|
+
- Optional: `dex` on PATH for the Dex adapter
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Once published:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pi install @dibs.ai/pi
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Until then, install from a local checkout (see [Contributing](CONTRIBUTING.md)).
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
- Ask the agent to create, list, start, edit, or complete tasks.
|
|
32
|
+
- `/todos [current|project|completed]` selects and displays a view.
|
|
33
|
+
- `/todos export <path> [--global]` exports to todo.txt, without overwriting an existing file.
|
|
34
|
+
- `/todos import <path> [--global]` appends todo.txt lines as records, skipping `dibsid:`s already present.
|
|
35
|
+
- `/todos connect things <token>` saves the Things auth token (see the Things adapter docs).
|
|
36
|
+
- `/todos migrate .dibs|.agents/dibs` moves the project-scope store folder (todos, config, index). Trusted projects only; refuses to overwrite.
|
|
37
|
+
- `/todos scope project|global` switches scope and moves the `todos/` folder between the project folder (`.dibs/` or `.agents/dibs/`) and `~/.dibs/projects/<name>.<id>/`. Refuses if the target already has todos. Trusted projects only.
|
|
38
|
+
- `--global` targets this project's store under `~/.dibs/projects/<name>.<id>/` instead of the active one.
|
|
39
|
+
- `ctrl+shift+t` collapses or expands the panel.
|
|
40
|
+
- `ctrl+shift+v` cycles views.
|
|
41
|
+
|
|
42
|
+
Current shows tasks worked on in this session. Newly created top-level tasks remain in the project backlog until started. Tasks are stored as JSONL, one JSON object per task: `id`, `name`, `completed`, `started_at`, and optional `priority` (A-Z), `created` and `completed_date` (YYYY-MM-DD), `description`, `parent`, `blocked_by` (ids of tasks that must complete first; local only), `result`, `created_by` (agent name, or `@user` for a human) and `human` (GitHub username of the human in the loop; CLI/Pi create default it to you via `DIBS_USER`, `git config github.user` or `gh`; `DIBS_AGENT` names the CLI creator) (schema: `Task` in `src/core/todo.ts`). `+projects`, `@contexts` and other `key:value` tags stay in `name`. Export renders each record as a [todo.txt](https://github.com/todotxt/todo.txt) line, with dibs fields as `dibsid:`, `dibsstart:`, `dibsdesc:`, `dibsparent:`, `dibsresult:`, `dibsby:` and `dibshuman:` tags, so import reads it back. Older `{"todo":"..."}` stores are converted on the next write.
|
|
43
|
+
|
|
44
|
+
## CLI
|
|
45
|
+
|
|
46
|
+
Requires [Bun](https://bun.sh) (the `dibs` binary is TypeScript run by Bun; `npx` without Bun will not work).
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
bun link # from a checkout; or: bun add -g @dibs.ai/dibs
|
|
50
|
+
dibs --help
|
|
51
|
+
dibs create "Write tests" && dibs list
|
|
52
|
+
dibs sync # two-way sync with adapters enabled in config (Dex, Things)
|
|
53
|
+
dibs mcp # serve the task tools over MCP (stdio)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The CLI runs in the current directory. It is trusted if `DIBS_TRUST=1` is set or the project has an `.dibs/` (or `.agents/dibs/`) folder; otherwise it uses the temp store. `DIBS_AGENT` names the task creator, `DIBS_USER` sets your GitHub user, and `DIBS_SESSION` overrides the session id.
|
|
57
|
+
|
|
58
|
+
## Supported agents
|
|
59
|
+
|
|
60
|
+
| Agent | Integration | Install |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| [Pi](agents/pi/index.ts) | Extension (`agents/pi/package.json` `pi` field) | `pi install @dibs.ai/pi` (see [Installation](#installation)) |
|
|
63
|
+
| [Claude Code](agents/claude-code/README.md) | Plugin with the `dibs` skill | `/plugin install dibs --marketplace arobida/dibs` (Claude Code 2.1.275+), or `/plugin marketplace add arobida/dibs` then `/plugin install dibs@dibs` |
|
|
64
|
+
| [Codex](agents/codex/README.md) | Skill | Copy to `~/.agents/skills/` |
|
|
65
|
+
| [opencode](agents/opencode/README.md) | Skill | Copy to `.opencode/skills/` or `~/.config/opencode/skills/` |
|
|
66
|
+
| [Cursor](agents/cursor/README.md) | Skill | Copy to `.cursor/skills/` or `~/.cursor/skills/` |
|
|
67
|
+
|
|
68
|
+
Non-Pi agents need the `dibs` CLI on PATH. Build a target with `bun run build:agent <name>`, which writes `dist/<name>/`. It copies `agents/shared/` first, then `agents/<name>/` on top, so a file at the same path in `agents/<name>/` replaces the shared one.
|
|
69
|
+
|
|
70
|
+
## Storage
|
|
71
|
+
|
|
72
|
+
| Scope | Todos file |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `project` (default, trusted projects) | `.dibs/todos/<project>.todos.jsonl`, or `.agents/dibs/...` if that exists |
|
|
75
|
+
| `global` | `~/.dibs/projects/<project>.<id>/todos/<project>.todos.jsonl` |
|
|
76
|
+
| `temp` (and untrusted projects) | same layout under `$TMPDIR/dibs/<session-hash>/.dibs/`; may be removed by the OS |
|
|
77
|
+
|
|
78
|
+
On first use dibs creates the folder with a `config.json`, a `todos/lists.jsonl` index (`id`, `name`, `file`, `created` per todos file) and a starter `Hello World` todo. New permanent stores get the todo, and so does the first run after install even in temp. Other temp stores start empty. Each project's id is stored in its local `config.json` (which stays in the project in both scopes) and keys its record in `~/.dibs/projects/projects.jsonl` (`id`, `name`, `path`, `scope`, `created`). `scope: "global"` projects keep their store in `~/.dibs/projects/<name>.<id>/`; `project` scope creates no global folder. `<project>` is the working directory's name.
|
|
79
|
+
|
|
80
|
+
Adapters sync dibs's store with other todo apps. Each has its own connect instructions, capabilities and limitations:
|
|
81
|
+
|
|
82
|
+
- [Dex](src/core/adapters/dex/README.md)
|
|
83
|
+
- [Things 3](src/core/adapters/things/README.md)
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
`config.json` files are JSONC (comments and trailing commas allowed) and start with a `$schema` URL pinned to your installed version, so editors autocomplete and check every option ([`schema.json`](schema.json); each adapter's options are in `src/core/adapters/<name>/<name>.schema.json`). dibs keeps that URL current when you upgrade. Precedence: `~/.dibs/config.json` (global) < the project's dibs `config.json` < environment (`DIBS_FILE`, `DIBS_SCOPE`). `DIBS_HOME` moves `~/.dibs`.
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{"adapters": {"dex": {"sync": true}}, "scope": "project"}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `adapters`: per-adapter options; `dex` or `things`, each with `sync` (boolean) and `human` (`"me"` or a GitHub username: sync only tasks whose `human` matches; tasks with no human stay local).
|
|
94
|
+
- `scope`: `project` (default), `global` or `temp`; read from the global config or `DIBS_SCOPE`.
|
|
95
|
+
- `file`: explicit todos file, overriding scope. `~/` supported; relative paths resolve from Pi's working directory.
|
|
96
|
+
|
|
97
|
+
Changing scope or file selects a different store and does not migrate tasks; use export and import. Invalid config raises an error. Run `/reload` after editing config.
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
Tech stack, project structure, local development and publishing are in [CONTRIBUTING.md](CONTRIBUTING.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dibs.ai/dibs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared task store for coding agents: CLI, MCP server and todo.txt, with plugins for Claude Code, opencode, Pi, Codex and Cursor.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"packageManager": "bun@1.4.4",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"dibs",
|
|
9
|
+
"ai-agents",
|
|
10
|
+
"coding-agent",
|
|
11
|
+
"task-manager",
|
|
12
|
+
"todo",
|
|
13
|
+
"todo.txt",
|
|
14
|
+
"mcp",
|
|
15
|
+
"mcp-server",
|
|
16
|
+
"claude-code",
|
|
17
|
+
"claude-code-plugin",
|
|
18
|
+
"opencode",
|
|
19
|
+
"opencode-plugin",
|
|
20
|
+
"pi-package",
|
|
21
|
+
"pi",
|
|
22
|
+
"codex",
|
|
23
|
+
"cursor",
|
|
24
|
+
"dex",
|
|
25
|
+
"things"
|
|
26
|
+
],
|
|
27
|
+
"bin": {
|
|
28
|
+
"dibs": "./src/cli/index.ts"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"src/",
|
|
32
|
+
"schema.json",
|
|
33
|
+
"README.md",
|
|
34
|
+
"CHANGELOG.md"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "bun test",
|
|
38
|
+
"check": "tsc && bun test",
|
|
39
|
+
"build:agent": "bun scripts/build-agent.ts",
|
|
40
|
+
"pack:check": "bun pm pack --dry-run"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@earendil-works/pi-coding-agent": "^1.5.2",
|
|
44
|
+
"@earendil-works/pi-tui": "^1.5.2",
|
|
45
|
+
"@types/bun": "^1.4.4",
|
|
46
|
+
"typebox": "^1.4.7",
|
|
47
|
+
"typescript": "^7.0.2"
|
|
48
|
+
},
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"author": {
|
|
51
|
+
"name": "arobida",
|
|
52
|
+
"url": "https://github.com/arobida"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"bun": ">=1.4"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
59
|
+
"zod": "^4.6.7"
|
|
60
|
+
},
|
|
61
|
+
"workspaces": [
|
|
62
|
+
"agents/pi",
|
|
63
|
+
"agents/opencode"
|
|
64
|
+
],
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/arobida/dibs.git"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://github.com/arobida/dibs#readme",
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/arobida/dibs/issues"
|
|
75
|
+
},
|
|
76
|
+
"exports": {
|
|
77
|
+
".": "./src/core/tasks.ts",
|
|
78
|
+
"./core/*": "./src/core/*"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/schema.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "dibs config",
|
|
4
|
+
"description": "~/.dibs/config.json (global) or a project's .dibs/config.json. Project overrides global; DIBS_* env overrides both.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": { "type": "string" },
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^[\\w-]+$",
|
|
12
|
+
"description": "Project id, written by dibs. Links this project to its record in ~/.dibs/projects/projects.jsonl; don't edit."
|
|
13
|
+
},
|
|
14
|
+
"scope": {
|
|
15
|
+
"enum": ["project", "global", "temp"],
|
|
16
|
+
"description": "Where todos live: in the project (.dibs), in ~/.dibs/projects, or a temporary per-session file. Set per project with /todos scope."
|
|
17
|
+
},
|
|
18
|
+
"file": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"minLength": 1,
|
|
21
|
+
"description": "Explicit todos file path; ~ is expanded. Overridden by DIBS_FILE."
|
|
22
|
+
},
|
|
23
|
+
"adapters": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"description": "Sync dibs todos with other task apps.",
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"properties": {
|
|
28
|
+
"dex": { "$ref": "src/core/adapters/dex/dex.schema.json" },
|
|
29
|
+
"things": { "$ref": "src/core/adapters/things/things.schema.json" }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
import { checkName } from "../core/todo.ts";
|
|
6
|
+
import { home } from "../core/util.ts";
|
|
7
|
+
import { link, migrate, resolveLink, setScope, settings, storeFile } from "../core/store.ts";
|
|
8
|
+
import { agentName, ghUser } from "../core/identity.ts";
|
|
9
|
+
import { runFile } from "../core/tasks.ts";
|
|
10
|
+
import { syncAll } from "../core/adapters/sync-all.ts";
|
|
11
|
+
import type { Ctx } from "../core/ctx.ts";
|
|
12
|
+
import { panel, panelText, views, type View } from "../core/panel.ts";
|
|
13
|
+
|
|
14
|
+
const usage = `usage: dibs [--global] [--json] <command>
|
|
15
|
+
list [--query q] [--human u|me] | ready [--human u|me]
|
|
16
|
+
create <name> [--description d] [--parent id] [--blocked-by a,b] [--human u]
|
|
17
|
+
start <id> | complete <id> [--result r]
|
|
18
|
+
edit <id> [--name n] [--description d] [--blocked-by a,b] [--human u ("" clears)]
|
|
19
|
+
import <file> | export [file]
|
|
20
|
+
sync sync enabled adapters (dex, things)
|
|
21
|
+
link <id> | resolve <url>
|
|
22
|
+
panel [current|project|completed] [--mine a,b] task panel text (--json: rows)
|
|
23
|
+
mcp serve the task tools over MCP (stdio)
|
|
24
|
+
scope project|global | migrate .dibs|.agents/dibs
|
|
25
|
+
env: DIBS_AGENT names the creator; DIBS_USER sets your GitHub user; DIBS_TRUST=1 trusts cwd; DIBS_SESSION overrides the session id`;
|
|
26
|
+
|
|
27
|
+
const cwd = process.cwd();
|
|
28
|
+
const ctx: Ctx = {
|
|
29
|
+
cwd,
|
|
30
|
+
trusted: () => process.env.DIBS_TRUST === "1" || existsSync(`${cwd}/.dibs`) || existsSync(`${cwd}/.agents/dibs`),
|
|
31
|
+
sessionId: () => process.env.DIBS_SESSION ?? String(process.ppid),
|
|
32
|
+
exec: async (cmd, args, opts) => {
|
|
33
|
+
const p = Bun.spawn([cmd, ...args], { cwd: opts?.cwd ?? cwd, stdout: "pipe", stderr: "pipe", signal: opts?.signal });
|
|
34
|
+
const [stdout, stderr, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited]);
|
|
35
|
+
return { stdout, stderr, code };
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const { values: v, positionals: [cmd, arg] } = parseArgs({
|
|
41
|
+
allowPositionals: true,
|
|
42
|
+
options: { global: { type: "boolean" }, json: { type: "boolean" }, help: { type: "boolean" }, query: { type: "string" }, description: { type: "string" }, parent: { type: "string" }, "blocked-by": { type: "string" }, human: { type: "string" }, name: { type: "string" }, result: { type: "string" }, mine: { type: "string" } },
|
|
43
|
+
});
|
|
44
|
+
if (v.help || !cmd) { console.log(usage); process.exit(0); }
|
|
45
|
+
const need = () => arg ?? (() => { throw new Error(`${cmd} needs an argument`); })();
|
|
46
|
+
const out = (s: string) => console.log(s);
|
|
47
|
+
if (cmd === "mcp") await (await import("./mcp.ts")).serveMcp(ctx);
|
|
48
|
+
else if (cmd === "link") out(link(ctx, need()));
|
|
49
|
+
else if (cmd === "resolve") out(resolveLink(need()));
|
|
50
|
+
else if (cmd === "scope") out(setScope(ctx, need()));
|
|
51
|
+
else if (cmd === "migrate") out(migrate(ctx, need()));
|
|
52
|
+
else if (cmd === "panel") {
|
|
53
|
+
const view = (arg ?? "project") as View;
|
|
54
|
+
if (!views.includes(view)) throw new Error(`panel view must be one of ${views.join(", ")}`);
|
|
55
|
+
const tasks = JSON.parse(await runFile(storeFile(ctx, settings(ctx, v.global)), ["list", "--all", "--json"]));
|
|
56
|
+
const p = panel(tasks, view, new Set(v.mine?.split(",").filter(Boolean)));
|
|
57
|
+
out(v.json ? JSON.stringify(p) : panelText(p));
|
|
58
|
+
}
|
|
59
|
+
else if (cmd === "sync") {
|
|
60
|
+
const s = settings(ctx, v.global), res = await syncAll(ctx, s, storeFile(ctx, s));
|
|
61
|
+
for (const r of res) (r.error ? console.error : out)(r.error ? `${r.name}: sync failed: ${(r.error as Error).message ?? r.error}` : `${r.name}: synced`);
|
|
62
|
+
if (!res.length) out("no adapters enabled");
|
|
63
|
+
if (res.some((r) => r.error)) process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const opt = (k: string, flag = k) => v[k as "name"] === undefined ? [] : [`--${flag}`, v[k as "name"]!];
|
|
67
|
+
let args: string[];
|
|
68
|
+
const who = v.human === "me" ? await ghUser(ctx) ?? (() => { throw new Error("Cannot resolve --human me: set DIBS_USER or git config github.user"); })() : v.human;
|
|
69
|
+
if (cmd === "list") args = ["list", ...opt("query"), ...(who === undefined ? [] : ["--human", who])];
|
|
70
|
+
else if (cmd === "ready") args = ["ready", ...(who === undefined ? [] : ["--human", who])];
|
|
71
|
+
else if (cmd === "create") { checkName(need()); args = ["create", arg, ...opt("description"), ...opt("parent"), ...opt("blocked-by"), "--created-by", agentName(), "--human", v.human ?? await ghUser(ctx) ?? ""]; }
|
|
72
|
+
else if (cmd === "edit") {
|
|
73
|
+
if (!v.name && v.description === undefined && v["blocked-by"] === undefined && v.human === undefined) throw new Error("edit needs --name, --description, --blocked-by or --human");
|
|
74
|
+
args = ["edit", need(), ...opt("name"), ...opt("description"), ...opt("blocked-by"), ...opt("human")];
|
|
75
|
+
}
|
|
76
|
+
else if (cmd === "start") args = ["start", need(), "--claim", `${ctx.sessionId()}:${process.pid}`];
|
|
77
|
+
else if (cmd === "complete") args = ["complete", need(), "--result", v.result || "Completed", "--no-commit"];
|
|
78
|
+
else if (cmd === "import") args = ["import", readFileSync(resolve(cwd, home(need())), "utf8")];
|
|
79
|
+
else if (cmd === "export") args = ["export"];
|
|
80
|
+
else throw new Error(`Unknown command: ${cmd}\n${usage}`);
|
|
81
|
+
const raw = await runFile(storeFile(ctx, settings(ctx, v.global)), args);
|
|
82
|
+
if (cmd === "export") {
|
|
83
|
+
const { text, skipped } = JSON.parse(raw);
|
|
84
|
+
if (arg) writeFileSync(resolve(cwd, home(arg)), text, { flag: "wx" }); // wx: never overwrite
|
|
85
|
+
else process.stdout.write(text);
|
|
86
|
+
if (skipped.length) console.error(`Not exported (todo.txt would misread these names):\n${skipped.join("\n")}`);
|
|
87
|
+
} else if (cmd === "list" || cmd === "ready") {
|
|
88
|
+
out(v.json ? raw : JSON.parse(raw).map((t: any) => `[${t.completed ? "x" : t.started_at ? "~" : " "}] ${t.id} ${t.name}${t.human ? ` @${t.human}` : ""}`).join("\n"));
|
|
89
|
+
} else out(raw);
|
|
90
|
+
}
|
|
91
|
+
} catch (e: any) {
|
|
92
|
+
console.error(e.message ?? String(e));
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
package/src/cli/mcp.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { checkName } from "../core/todo.ts";
|
|
5
|
+
import { link, resolveLink, settings, storeFile } from "../core/store.ts";
|
|
6
|
+
import { agentName, ghUser } from "../core/identity.ts";
|
|
7
|
+
import { runFile } from "../core/tasks.ts";
|
|
8
|
+
import { syncAll } from "../core/adapters/sync-all.ts";
|
|
9
|
+
import type { Ctx } from "../core/ctx.ts";
|
|
10
|
+
|
|
11
|
+
export async function serveMcp(ctx: Ctx) {
|
|
12
|
+
const claim = () => `${ctx.sessionId()}:${process.pid}`;
|
|
13
|
+
|
|
14
|
+
// Sync failures go to stderr only; stdout is the protocol.
|
|
15
|
+
async function sync() {
|
|
16
|
+
try {
|
|
17
|
+
const s = settings(ctx);
|
|
18
|
+
for (const r of await syncAll(ctx, s, storeFile(ctx, s))) if (r.error) console.error(`${r.name}: sync failed: ${(r.error as Error).message ?? r.error}`);
|
|
19
|
+
} catch (e) { console.error(`sync failed: ${e}`); }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function act(action: string, p: Record<string, any>): Promise<string> {
|
|
23
|
+
for (const k of Object.keys(p)) if (p[k] === "" || p[k] === null) delete p[k];
|
|
24
|
+
const { id, name, description, parent, result, url, force, query } = p;
|
|
25
|
+
const human = p.human === "me" ? await ghUser(ctx) ?? "" : p.human;
|
|
26
|
+
const blocked_by = Array.isArray(p.blocked_by) ? p.blocked_by.join(",") : p.blocked_by;
|
|
27
|
+
if (action === "link") return link(ctx, id);
|
|
28
|
+
if (action === "resolve") return resolveLink(url);
|
|
29
|
+
if (action === "edit" && name === undefined && description === undefined && blocked_by === undefined && human === undefined) throw new Error("todo_edit needs at least one of name, description, blocked_by, human");
|
|
30
|
+
if (name !== undefined) checkName(name);
|
|
31
|
+
let args: string[];
|
|
32
|
+
if (action === "list") args = [...(p.ready ? ["ready"] : ["list", ...(query?.trim() ? ["--query", query] : [])]), ...(human ? ["--human", human] : [])];
|
|
33
|
+
else if (action === "create") args = ["create", name, ...(description !== undefined ? ["--description", description] : []), ...(parent ? ["--parent", parent] : []), ...(blocked_by !== undefined ? ["--blocked-by", blocked_by] : []), "--created-by", agentName(), "--human", await ghUser(ctx) ?? ""];
|
|
34
|
+
else if (action === "edit") args = ["edit", id, ...(name !== undefined ? ["--name", name] : []), ...(description !== undefined ? ["--description", description] : []), ...(blocked_by !== undefined ? ["--blocked-by", blocked_by] : []), ...(human !== undefined ? ["--human", human] : [])];
|
|
35
|
+
else if (p.status === "completed") args = ["complete", id, "--result", result || "Completed", "--claim", claim(), "--no-commit"];
|
|
36
|
+
else if (result !== undefined) throw new Error("result is only for status completed");
|
|
37
|
+
else args = ["start", id, "--claim", claim()];
|
|
38
|
+
if (force && action === "status") args.push("--force");
|
|
39
|
+
if (action === "list") await sync();
|
|
40
|
+
const out = await runFile(storeFile(ctx, settings(ctx)), args);
|
|
41
|
+
if (action !== "list") await sync();
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const Id = z.string().describe("Task id, or any unique prefix (e.g. a1b2c3 for proj-a1b2c3)");
|
|
46
|
+
const server = new McpServer({ name: "dibs", version: "0.1.0" });
|
|
47
|
+
const tool = (name: string, description: string, inputSchema: z.ZodRawShape) => server.registerTool(name, { description, inputSchema }, async (params: any) => {
|
|
48
|
+
try { return { content: [{ type: "text" as const, text: await act(name.slice(5), { ...params }) }] }; }
|
|
49
|
+
catch (e: any) { return { content: [{ type: "text" as const, text: e.message ?? String(e) }], isError: true }; }
|
|
50
|
+
});
|
|
51
|
+
tool("todo_list", "List tasks as a JSON array. ready: true lists only open, unclaimed, unblocked tasks. Ids are short and project-prefixed (e.g. proj-a1b2c3).", {
|
|
52
|
+
query: z.string().optional().describe("Case-insensitive text to match in task name or description"),
|
|
53
|
+
ready: z.boolean().optional().describe("Only tasks ready to work on"),
|
|
54
|
+
human: z.string().optional().describe("Only tasks for this GitHub user; \"me\" for the current user"),
|
|
55
|
+
});
|
|
56
|
+
tool("todo_create", "Create a task. Returns its id.", {
|
|
57
|
+
name: z.string().describe("Task name, one line"),
|
|
58
|
+
description: z.string().describe("Task details; \"\" if none"),
|
|
59
|
+
parent: z.string().optional().describe("Id of an existing task to nest under"),
|
|
60
|
+
blocked_by: z.array(z.string()).optional().describe("Ids (or unique prefixes) of tasks that must complete first"),
|
|
61
|
+
});
|
|
62
|
+
tool("todo_edit", "Change a task. Give only the fields to change; at least one is required.", {
|
|
63
|
+
id: Id,
|
|
64
|
+
name: z.string().optional().describe("New task name"),
|
|
65
|
+
description: z.string().optional().describe("New task details"),
|
|
66
|
+
human: z.string().optional().describe("GitHub user in the loop; \"me\" for the current user; \"\" clears it"),
|
|
67
|
+
blocked_by: z.array(z.string()).optional().describe("Replaces the blocker list; [] clears it"),
|
|
68
|
+
});
|
|
69
|
+
tool("todo_status", "Start or complete a task. Starting claims it for this session.", {
|
|
70
|
+
id: Id,
|
|
71
|
+
status: z.enum(["started", "completed"]),
|
|
72
|
+
result: z.string().optional().describe("Only with completed: what was done (default: Completed)"),
|
|
73
|
+
force: z.boolean().optional().describe("Override another live session's claim"),
|
|
74
|
+
});
|
|
75
|
+
tool("todo_link", "Get a Markdown dibs:// link to a task, for use in notes or other projects.", { id: Id });
|
|
76
|
+
tool("todo_resolve", "Read the task behind a dibs:// link, from any project.", { url: z.string().describe("A dibs://<project-id>/<task-id> link") });
|
|
77
|
+
|
|
78
|
+
await server.connect(new StdioServerTransport());
|
|
79
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Dex adapter
|
|
2
|
+
|
|
3
|
+
Syncs dibs's todo store with [Dex](https://github.com/dcramer/dex) through the `dex` CLI.
|
|
4
|
+
|
|
5
|
+
## Connect
|
|
6
|
+
|
|
7
|
+
1. Install `dex` and make sure it is on `PATH` (`dex --version`).
|
|
8
|
+
2. Optional: run `dex init` (global `~/.config/dex/dex.toml`) or add a project `.dex/config.toml` to choose where Dex stores tasks. Without either, dibs uses temporary per-session Dex storage.
|
|
9
|
+
3. Turn sync on in an dibs `config.json` (global `~/.dibs/config.json` or the project's):
|
|
10
|
+
```json
|
|
11
|
+
{"adapters": {"dex": {"sync": true}}}
|
|
12
|
+
```
|
|
13
|
+
4. Run `/reload` in Pi. Existing Dex tasks are pulled into dibs on the first sync, and dibs tasks are pushed to Dex.
|
|
14
|
+
|
|
15
|
+
To disconnect, set `"sync": false` or remove the entry. Tasks already synced stay on both sides.
|
|
16
|
+
|
|
17
|
+
## Capabilities
|
|
18
|
+
|
|
19
|
+
| Field | dibs → Dex | Dex → dibs |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| Create task | yes | yes |
|
|
22
|
+
| Name (todo.txt priority, `+project`, `@context` as text) | yes | yes |
|
|
23
|
+
| Description | yes | yes |
|
|
24
|
+
| Parent (subtasks) | yes | yes |
|
|
25
|
+
| Started | yes | yes |
|
|
26
|
+
| Completed + result | yes | yes |
|
|
27
|
+
|
|
28
|
+
- Two-way: each list or change in dibs syncs both ways. dibs pulls changes that other agents make in Dex when Dex's storage folder changes (file storage engine only) and before each prompt.
|
|
29
|
+
- Conflicts: per field, a change on one side since the last sync is copied across. If both sides changed the same field, dibs wins.
|
|
30
|
+
- State: links and last-synced copies live in `sync/dex.jsonl` next to the store's `config.json`.
|
|
31
|
+
- Completing in Dex uses `--no-commit --force`.
|
|
32
|
+
|
|
33
|
+
## Limitations
|
|
34
|
+
|
|
35
|
+
- Deletions are never propagated in either direction.
|
|
36
|
+
- Dex cannot un-complete or un-start a task, or change a completed task's result; those changes stay in dibs only.
|
|
37
|
+
- Clearing a description in dibs does not clear it in Dex.
|
|
38
|
+
- Not synced: Dex's numeric priority, blockers (`blockedBy`/`blocks`), linked commits, metadata, archived tasks, and GitHub/Shortcut sync.
|
|
39
|
+
- Dex storage outside the file engine (no local folder) re-syncs only on dibs actions and before each prompt, not live.
|
|
40
|
+
- A sync failure shows as a notice and does not block the local change. dibs retries on the next sync.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "dibs Dex adapter",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"properties": {
|
|
7
|
+
"sync": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"description": "Two-way sync dibs todos with Dex tasks."
|
|
10
|
+
},
|
|
11
|
+
"human": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"description": "Only sync tasks whose human matches this GitHub username; \"me\" is you. Tasks with no human are skipped."
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Ctx } from "../../ctx.ts";
|
|
2
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { homedir, tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { type Task } from "../../todo.ts";
|
|
7
|
+
import type { Adapter } from "../sync.ts";
|
|
8
|
+
import { home } from "../../util.ts";
|
|
9
|
+
|
|
10
|
+
// Validates a Dex task record; todo.txt rendering is left to export so names it cannot carry don't break listing.
|
|
11
|
+
export function checkDex(task: any) {
|
|
12
|
+
if (typeof task.id !== "string" || typeof task.name !== "string" || typeof task.completed !== "boolean") throw new Error("Invalid Dex task");
|
|
13
|
+
const name = task.name.replace(/[\r\n]+/g, " ").trim();
|
|
14
|
+
if (!name) throw new Error(`Dex task ${task.id} has no name`);
|
|
15
|
+
const date = typeof task.completed_at === "string" && /^\d{4}-\d{2}-\d{2}/.test(task.completed_at) ? task.completed_at.slice(0, 10) : undefined;
|
|
16
|
+
if (task.completed && !date) throw new Error(`Dex task ${task.id} has no completion date`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function configured(cwd: string): boolean {
|
|
20
|
+
let dir = resolve(cwd);
|
|
21
|
+
while (true) {
|
|
22
|
+
if (existsSync(join(dir, ".dex", "config.toml"))) return true;
|
|
23
|
+
const parent = dirname(dir);
|
|
24
|
+
if (parent === dir) break;
|
|
25
|
+
dir = parent;
|
|
26
|
+
}
|
|
27
|
+
return existsSync(join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "dex", "dex.toml"));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function storageArgs(ctx: Ctx): string[] {
|
|
31
|
+
if (configured(ctx.cwd)) return [];
|
|
32
|
+
const id = createHash("sha256").update(ctx.sessionId()).digest("hex");
|
|
33
|
+
return ["--storage-path", join(tmpdir(), "pi-dex", id)];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function dex(ctx: Ctx, args: string[], signal?: AbortSignal): Promise<string> {
|
|
37
|
+
const result = await ctx.exec("dex", [...storageArgs(ctx), ...args], { cwd: ctx.cwd, signal });
|
|
38
|
+
if (result.code !== 0) throw new Error(result.stderr || result.stdout || `dex exited ${result.code}`);
|
|
39
|
+
return result.stdout;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const fromDex = (t: any): Task => { checkDex(t); return { id: t.id, name: t.name, completed: t.completed, started_at: t.started_at ?? null, description: t.description ?? undefined, parent: t.parent_id ?? undefined, result: t.result ?? undefined }; };
|
|
43
|
+
|
|
44
|
+
export function dexAdapter(ctx: Ctx): Adapter {
|
|
45
|
+
const run = (args: string[]) => dex(ctx, args);
|
|
46
|
+
return {
|
|
47
|
+
name: "dex",
|
|
48
|
+
async list() {
|
|
49
|
+
const data = JSON.parse(await run(["list", "--all", "--json"]));
|
|
50
|
+
if (!Array.isArray(data)) throw new Error("Invalid Dex task list");
|
|
51
|
+
return data.map(fromDex);
|
|
52
|
+
},
|
|
53
|
+
async create(task) {
|
|
54
|
+
const out = await run(["create", "-n", task.name, ...(task.description ? ["--description", task.description] : []), ...(task.parent ? ["--parent", task.parent] : [])]);
|
|
55
|
+
const id = out.match(/Created task (\S+)/)?.[1];
|
|
56
|
+
if (!id) throw new Error(`Unexpected dex create output: ${out}`);
|
|
57
|
+
if (task.started_at || task.completed) await this.update(id, { started_at: task.started_at, completed: task.completed, result: task.result });
|
|
58
|
+
return id;
|
|
59
|
+
},
|
|
60
|
+
// shortcut: Dex has no uncomplete/unstart or result edit on completed tasks; those changes stay local.
|
|
61
|
+
async update(id, patch) {
|
|
62
|
+
if (patch.name !== undefined || patch.description !== undefined || patch.parent !== undefined) await run(["edit", id, ...(patch.name !== undefined ? ["--name", patch.name] : []), ...(patch.description !== undefined ? ["--description", patch.description ?? ""] : []), ...(patch.parent ? ["--parent", patch.parent] : [])]);
|
|
63
|
+
if (patch.started_at && !patch.completed) await run(["start", id, "--force"]);
|
|
64
|
+
if (patch.completed) await run(["complete", id, "--result", patch.result || "done", "--no-commit", "--force"]);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Folders holding Dex's task storage, or undefined when the engine has nothing local to watch.
|
|
70
|
+
export async function dexWatchDirs(ctx: Ctx): Promise<string[] | undefined> {
|
|
71
|
+
const custom = storageArgs(ctx)[1];
|
|
72
|
+
if (custom) { mkdirSync(custom, { recursive: true }); return [custom]; }
|
|
73
|
+
// Ask Dex for its effective config: `dex dir` ignores storage.file.path and centralized mode.
|
|
74
|
+
const get = async (key: string) => { const v = (await ctx.exec("dex", ["config", key], { cwd: ctx.cwd })).stdout.trim(); return v && v !== "(not set)" ? v : undefined; };
|
|
75
|
+
const engine = await get("storage.engine");
|
|
76
|
+
if (engine && engine !== "file") return; // non-file engines have nothing local to watch; panel keeps its event-based reloads
|
|
77
|
+
const path = await get("storage.file.path");
|
|
78
|
+
if (path) return [resolve(ctx.cwd, home(path))];
|
|
79
|
+
// shortcut: watches every project's centralized store (slug comes from the git remote), so other projects' edits also trigger a reload.
|
|
80
|
+
if ((await get("storage.file.mode")) === "centralized") return [join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "dex", "projects")];
|
|
81
|
+
return [(await ctx.exec("dex", ["dir"], { cwd: ctx.cwd })).stdout.trim()];
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Ctx } from "../ctx.ts";
|
|
2
|
+
import type { Settings } from "../store.ts";
|
|
3
|
+
import { dexAdapter } from "./dex/index.ts";
|
|
4
|
+
import { ghUser } from "../identity.ts";
|
|
5
|
+
import { type Adapter, sync } from "./sync.ts";
|
|
6
|
+
import { thingsAdapter } from "./things/index.ts";
|
|
7
|
+
|
|
8
|
+
// Syncs every adapter with `sync` on, in order. A failing adapter doesn't stop the rest; its error is returned.
|
|
9
|
+
export async function syncAll(ctx: Ctx, s: Settings, file: string, make: Record<string, () => Adapter> = { dex: () => dexAdapter(ctx), things: () => thingsAdapter(ctx, s.name) }): Promise<{ name: string; error?: unknown }[]> {
|
|
10
|
+
const out: { name: string; error?: unknown }[] = [];
|
|
11
|
+
for (const name of Object.keys(s.adapters).filter((n) => s.adapters[n].sync)) {
|
|
12
|
+
try { const h = s.adapters[name].human; await sync(file, s.base, make[name](), h === "me" ? (await ghUser(ctx) ?? (() => { throw new Error('human "me" could not be resolved: set DIBS_USER or git config github.user'); })()) : h); out.push({ name }); } catch (error) { out.push({ name, error }); }
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|