trekoon 0.4.1 → 0.4.2

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 (54) hide show
  1. package/.agents/skills/trekoon/SKILL.md +20 -577
  2. package/.agents/skills/trekoon/reference/execution-with-team.md +21 -9
  3. package/.agents/skills/trekoon/reference/execution.md +246 -7
  4. package/.agents/skills/trekoon/reference/planning.md +138 -1
  5. package/.agents/skills/trekoon/reference/status-machine.md +21 -0
  6. package/.agents/skills/trekoon/reference/sync.md +129 -0
  7. package/README.md +8 -1
  8. package/docs/ai-agents.md +17 -2
  9. package/docs/commands.md +147 -3
  10. package/docs/machine-contracts.md +123 -0
  11. package/docs/quickstart.md +52 -0
  12. package/package.json +1 -1
  13. package/src/board/assets/app.js +45 -13
  14. package/src/board/assets/components/Component.js +22 -8
  15. package/src/board/assets/components/Workspace.js +9 -3
  16. package/src/board/assets/components/helpers.js +4 -0
  17. package/src/board/assets/runtime/delegation.js +8 -0
  18. package/src/board/assets/runtime/focus-trap.js +48 -0
  19. package/src/board/assets/state/actions.js +42 -4
  20. package/src/board/assets/state/api.js +284 -11
  21. package/src/board/assets/state/store.js +79 -11
  22. package/src/board/assets/state/url.js +10 -0
  23. package/src/board/assets/state/utils.js +2 -1
  24. package/src/board/event-bus.ts +72 -0
  25. package/src/board/routes.ts +412 -33
  26. package/src/board/server.ts +77 -8
  27. package/src/board/wal-watcher.ts +302 -0
  28. package/src/commands/board.ts +52 -17
  29. package/src/commands/epic.ts +7 -9
  30. package/src/commands/error-utils.ts +54 -1
  31. package/src/commands/help.ts +69 -4
  32. package/src/commands/migrate.ts +153 -24
  33. package/src/commands/quickstart.ts +7 -0
  34. package/src/commands/subtask.ts +71 -10
  35. package/src/commands/suggest.ts +6 -13
  36. package/src/commands/task.ts +137 -88
  37. package/src/domain/batch-validation.ts +329 -0
  38. package/src/domain/cascade-planner.ts +412 -0
  39. package/src/domain/dependency-rules.ts +15 -0
  40. package/src/domain/mutation-service.ts +828 -192
  41. package/src/domain/search.ts +113 -0
  42. package/src/domain/tracker-domain.ts +150 -680
  43. package/src/domain/types.ts +53 -2
  44. package/src/index.ts +37 -0
  45. package/src/runtime/cli-shell.ts +44 -0
  46. package/src/runtime/daemon.ts +639 -0
  47. package/src/storage/backup.ts +166 -0
  48. package/src/storage/database.ts +261 -4
  49. package/src/storage/migrations.ts +422 -20
  50. package/src/storage/path.ts +8 -0
  51. package/src/storage/schema.ts +5 -1
  52. package/src/sync/event-writes.ts +38 -11
  53. package/src/sync/git-context.ts +226 -8
  54. package/src/sync/service.ts +650 -147
@@ -0,0 +1,113 @@
1
+ import {
2
+ type SearchEntityMatch,
3
+ type SearchField,
4
+ type SearchFieldMatch,
5
+ type SearchNode,
6
+ type SearchSummary,
7
+ } from "./types";
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // Pure search helpers — no DB access, no class state.
11
+ // Used by TrackerDomain (search methods) and MutationService (replace methods).
12
+ // ---------------------------------------------------------------------------
13
+
14
+ export function countMatches(value: string, searchText: string): number {
15
+ if (searchText.length === 0) {
16
+ return 0;
17
+ }
18
+
19
+ let count = 0;
20
+ let offset = 0;
21
+ while (offset <= value.length - searchText.length) {
22
+ const nextIndex = value.indexOf(searchText, offset);
23
+ if (nextIndex === -1) {
24
+ return count;
25
+ }
26
+
27
+ count += 1;
28
+ offset = nextIndex + searchText.length;
29
+ }
30
+
31
+ return count;
32
+ }
33
+
34
+ export function buildMatchSnippet(value: string, searchText: string, contextSize = 24): string {
35
+ if (searchText.length === 0) {
36
+ return "";
37
+ }
38
+
39
+ const matchIndex = value.indexOf(searchText);
40
+ if (matchIndex === -1) {
41
+ return "";
42
+ }
43
+
44
+ const start = Math.max(0, matchIndex - contextSize);
45
+ const end = Math.min(value.length, matchIndex + searchText.length + contextSize);
46
+ const rawSnippet = value.slice(start, end).replace(/\s+/g, " ").trim();
47
+ const prefix = start > 0 ? "…" : "";
48
+ const suffix = end < value.length ? "…" : "";
49
+ return `${prefix}${rawSnippet}${suffix}`;
50
+ }
51
+
52
+ export function summarizeMatches(matches: readonly SearchEntityMatch[]): SearchSummary {
53
+ return {
54
+ matchedEntities: matches.length,
55
+ matchedFields: matches.reduce((total, match) => total + match.fields.length, 0),
56
+ totalMatches: matches.reduce(
57
+ (total, match) => total + match.fields.reduce((fieldTotal, field) => fieldTotal + field.count, 0),
58
+ 0,
59
+ ),
60
+ };
61
+ }
62
+
63
+ export function replaceMatches(value: string, searchText: string, replacement: string): string {
64
+ return searchText.length === 0 ? value : value.split(searchText).join(replacement);
65
+ }
66
+
67
+ export function buildReplacementSnippet(
68
+ value: string,
69
+ replacementIndex: number,
70
+ replacementLength: number,
71
+ contextSize = 24,
72
+ ): string {
73
+ const start = Math.max(0, replacementIndex - contextSize);
74
+ const end = Math.min(value.length, replacementIndex + replacementLength + contextSize);
75
+ const rawSnippet = value.slice(start, end).replace(/\s+/g, " ").trim();
76
+ const prefix = start > 0 ? "…" : "";
77
+ const suffix = end < value.length ? "…" : "";
78
+ return `${prefix}${rawSnippet}${suffix}`;
79
+ }
80
+
81
+ export function collectSearchMatches(
82
+ nodes: readonly SearchNode[],
83
+ searchText: string,
84
+ fields: readonly SearchField[],
85
+ ): readonly SearchEntityMatch[] {
86
+ const matches: SearchEntityMatch[] = [];
87
+
88
+ for (const node of nodes) {
89
+ const matchedFields: SearchFieldMatch[] = [];
90
+ for (const field of fields) {
91
+ const count = countMatches(node[field], searchText);
92
+ if (count > 0) {
93
+ matchedFields.push({
94
+ field,
95
+ count,
96
+ snippet: buildMatchSnippet(node[field], searchText),
97
+ });
98
+ }
99
+ }
100
+
101
+ if (matchedFields.length === 0) {
102
+ continue;
103
+ }
104
+
105
+ matches.push({
106
+ kind: node.kind,
107
+ id: node.id,
108
+ fields: matchedFields,
109
+ });
110
+ }
111
+
112
+ return matches;
113
+ }