@dibs.ai/dibs 0.1.0 → 0.1.1
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/package.json +3 -2
- package/src/cli/index.ts +4 -0
- package/src/core/tasks.ts +13 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dibs.ai/dibs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.4.4",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"test": "bun test",
|
|
38
38
|
"check": "tsc && bun test",
|
|
39
39
|
"build:agent": "bun scripts/build-agent.ts",
|
|
40
|
-
"pack:check": "bun pm pack --dry-run"
|
|
40
|
+
"pack:check": "bun pm pack --dry-run",
|
|
41
|
+
"release": "bun scripts/release.ts"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@earendil-works/pi-coding-agent": "^1.5.2",
|
package/src/cli/index.ts
CHANGED
package/src/core/tasks.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core task store for dibs: run task actions against a JSONL todos file.
|
|
3
|
+
* @example
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { runFile } from "jsr:@dibs/dibs";
|
|
6
|
+
* console.log(await runFile(".dibs/todos/dibs.todos.jsonl", ["list"]));
|
|
7
|
+
* ```
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
1
10
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
11
|
import { basename, dirname } from "node:path";
|
|
3
12
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
4
13
|
import { checkName, clean, parseTodo, todoLine, toTask, type Task } from "./todo.ts";
|
|
5
14
|
import { isAlive, withLock } from "./util.ts";
|
|
6
15
|
|
|
16
|
+
/** Thrown when a task's parent is missing, is the task itself, or is one of its descendants. */
|
|
7
17
|
export class ParentError extends Error {}
|
|
8
18
|
// A parent must exist and must not be the task itself or one of its descendants.
|
|
9
19
|
function checkParent(items: Task[], id: string, parent?: string) {
|
|
@@ -15,6 +25,7 @@ function checkParent(items: Task[], id: string, parent?: string) {
|
|
|
15
25
|
}
|
|
16
26
|
}
|
|
17
27
|
|
|
28
|
+
/** Thrown when a blocker is missing, is the task itself, or forms a cycle. */
|
|
18
29
|
export class BlockerError extends Error {}
|
|
19
30
|
// Blockers must exist, not include the task itself, and not lead back to it through their own blockers.
|
|
20
31
|
function checkBlockers(items: Task[], id: string, blockers: string[] = []) {
|
|
@@ -32,7 +43,7 @@ const ids = (s?: string) => (s ? s.split(",").map((x) => x.trim()).filter(Boolea
|
|
|
32
43
|
// Short project-prefixed ids (like Dex/Beads) so agents copy a few characters, not a UUID.
|
|
33
44
|
const prefix = (file: string) => (basename(file).replace(/\.todos\.jsonl$/, "").toLowerCase().replace(/[^a-z0-9]/g, "").slice(0, 4) || "task");
|
|
34
45
|
const newId = (file: string, items: Task[]): string => { for (;;) { const id = `${prefix(file)}-${randomBytes(4).toString("hex").slice(0, 6)}`; if (!items.some((t) => t.id === id)) return id; } };
|
|
35
|
-
|
|
46
|
+
/** Resolves an exact task id, or a unique id prefix (with or without the project prefix). Throws if none or several match. */
|
|
36
47
|
export function findId(items: Task[], ref: string, file: string): string {
|
|
37
48
|
if (items.some((t) => t.id === ref)) return ref;
|
|
38
49
|
const hits = items.filter((t) => t.id.startsWith(ref) || t.id.startsWith(`${prefix(file)}-${ref}`));
|
|
@@ -40,7 +51,7 @@ export function findId(items: Task[], ref: string, file: string): string {
|
|
|
40
51
|
throw new Error(hits.length ? `Ambiguous task id ${ref}: matches ${hits.map((t) => `${t.id} "${t.name}"`).join(", ")}` : `Task not found: ${ref}`);
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
|
|
54
|
+
/** Runs an action (list, ready, export, import, put, create, start, complete, edit, release) against a dibs JSONL todos file and returns its output. */
|
|
44
55
|
export function runFile(file: string, args: string[]): string | Promise<string> {
|
|
45
56
|
const [action, value] = args;
|
|
46
57
|
if (action !== "list" && action !== "export") mkdirSync(dirname(file), { recursive: true });
|