@agent-plan/core 0.2.19-next.13 → 0.2.19-next.14
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/dist/checklist.d.ts +16 -0
- package/dist/checklist.d.ts.map +1 -0
- package/dist/checklist.js +52 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChecklistItem } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Granular per-task checklist helpers. Each item has a stable unique `id`
|
|
4
|
+
* (the robust handle for add/remove/toggle) plus a progressive `number`
|
|
5
|
+
* (C1..Cn display label, renumbered on remove for readability). Selectors
|
|
6
|
+
* accept C{n} (e.g. C2), the item id, or a title (case-insensitive, first
|
|
7
|
+
* exact then partial match).
|
|
8
|
+
*/
|
|
9
|
+
export declare function findChecklistItem(items: ChecklistItem[], selector: string): ChecklistItem | undefined;
|
|
10
|
+
/** Append a new item. number = max(existing)+1 (stable, never reused). Mutates nothing; returns the new item. */
|
|
11
|
+
export declare function addChecklistItem(items: ChecklistItem[], taskId: string, title: string): ChecklistItem;
|
|
12
|
+
/** Remove the matched item in place (splice) and renumber the rest 1..n. Returns the removed item, or undefined. */
|
|
13
|
+
export declare function removeChecklistItem(items: ChecklistItem[], selector: string): ChecklistItem | undefined;
|
|
14
|
+
/** Tick/untick the matched item in place. checked omitted → toggle. Returns the item, or undefined. */
|
|
15
|
+
export declare function toggleChecklistItem(items: ChecklistItem[], selector: string, checked?: boolean): ChecklistItem | undefined;
|
|
16
|
+
//# sourceMappingURL=checklist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checklist.d.ts","sourceRoot":"","sources":["../src/checklist.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAerG;AAED,iHAAiH;AACjH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAKrG;AAED,oHAAoH;AACpH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CASvG;AAED,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAK1H"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createChecklistItemId } from "./naming.js";
|
|
2
|
+
/**
|
|
3
|
+
* Granular per-task checklist helpers. Each item has a stable unique `id`
|
|
4
|
+
* (the robust handle for add/remove/toggle) plus a progressive `number`
|
|
5
|
+
* (C1..Cn display label, renumbered on remove for readability). Selectors
|
|
6
|
+
* accept C{n} (e.g. C2), the item id, or a title (case-insensitive, first
|
|
7
|
+
* exact then partial match).
|
|
8
|
+
*/
|
|
9
|
+
export function findChecklistItem(items, selector) {
|
|
10
|
+
const s = selector.trim();
|
|
11
|
+
if (!s)
|
|
12
|
+
return undefined;
|
|
13
|
+
const cMatch = /^C(\d+)$/i.exec(s);
|
|
14
|
+
if (cMatch) {
|
|
15
|
+
const n = parseInt(cMatch[1], 10);
|
|
16
|
+
return items.find((i) => i.number === n);
|
|
17
|
+
}
|
|
18
|
+
const byId = items.find((i) => i.id === s);
|
|
19
|
+
if (byId)
|
|
20
|
+
return byId;
|
|
21
|
+
const needle = s.toLowerCase();
|
|
22
|
+
return (items.find((i) => i.title.trim().toLowerCase() === needle) ??
|
|
23
|
+
items.find((i) => i.title.trim().toLowerCase().includes(needle)));
|
|
24
|
+
}
|
|
25
|
+
/** Append a new item. number = max(existing)+1 (stable, never reused). Mutates nothing; returns the new item. */
|
|
26
|
+
export function addChecklistItem(items, taskId, title) {
|
|
27
|
+
const clean = title.trim();
|
|
28
|
+
const number = items.length === 0 ? 1 : Math.max(...items.map((i) => i.number)) + 1;
|
|
29
|
+
const id = createChecklistItemId(taskId, number, clean);
|
|
30
|
+
return { id, number, title: clean, checked: false };
|
|
31
|
+
}
|
|
32
|
+
/** Remove the matched item in place (splice) and renumber the rest 1..n. Returns the removed item, or undefined. */
|
|
33
|
+
export function removeChecklistItem(items, selector) {
|
|
34
|
+
const found = findChecklistItem(items, selector);
|
|
35
|
+
if (!found)
|
|
36
|
+
return undefined;
|
|
37
|
+
const idx = items.findIndex((i) => i.id === found.id);
|
|
38
|
+
if (idx >= 0)
|
|
39
|
+
items.splice(idx, 1);
|
|
40
|
+
items.forEach((i, n) => {
|
|
41
|
+
i.number = n + 1;
|
|
42
|
+
});
|
|
43
|
+
return found;
|
|
44
|
+
}
|
|
45
|
+
/** Tick/untick the matched item in place. checked omitted → toggle. Returns the item, or undefined. */
|
|
46
|
+
export function toggleChecklistItem(items, selector, checked) {
|
|
47
|
+
const found = findChecklistItem(items, selector);
|
|
48
|
+
if (!found)
|
|
49
|
+
return undefined;
|
|
50
|
+
found.checked = checked ?? !found.checked;
|
|
51
|
+
return found;
|
|
52
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./naming.js";
|
|
2
2
|
export * from "./refs.js";
|
|
3
3
|
export * from "./schema.js";
|
|
4
|
+
export * from "./checklist.js";
|
|
4
5
|
export * from "./recap.js";
|
|
5
6
|
export { PlanStore, PlanStoreError, setWriteBusyHook, setWriteNotifyHook, migrateToUuids, migrateToGlobalSequence, withFeatureLock, type PhaseHandoffSummary } from "./plan-store.js";
|
|
6
7
|
export { PlanRenderer } from "./renderer.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,uBAAuB,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtL,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,uBAAuB,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtL,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./naming.js";
|
|
2
2
|
export * from "./refs.js";
|
|
3
3
|
export * from "./schema.js";
|
|
4
|
+
export * from "./checklist.js";
|
|
4
5
|
export * from "./recap.js";
|
|
5
6
|
export { PlanStore, PlanStoreError, setWriteBusyHook, setWriteNotifyHook, migrateToUuids, migrateToGlobalSequence, withFeatureLock } from "./plan-store.js";
|
|
6
7
|
export { PlanRenderer } from "./renderer.js";
|
package/package.json
CHANGED