beflow 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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/config.example.json +68 -0
  4. package/config.schema.json +413 -0
  5. package/package.json +72 -0
  6. package/src/agent/acpx.ts +197 -0
  7. package/src/agent/driver.ts +38 -0
  8. package/src/agent/events.ts +228 -0
  9. package/src/agent/issuefence.ts +42 -0
  10. package/src/agent/report.ts +44 -0
  11. package/src/cli.ts +910 -0
  12. package/src/config/load.ts +45 -0
  13. package/src/config/persist.ts +58 -0
  14. package/src/config/schema.ts +181 -0
  15. package/src/config/store.ts +119 -0
  16. package/src/core/accept.ts +25 -0
  17. package/src/core/continuation.ts +57 -0
  18. package/src/core/deadletter.ts +55 -0
  19. package/src/core/decision.ts +8 -0
  20. package/src/core/doctor.ts +223 -0
  21. package/src/core/drift.ts +59 -0
  22. package/src/core/gc.ts +223 -0
  23. package/src/core/inputquality.ts +30 -0
  24. package/src/core/issuetemplate.ts +175 -0
  25. package/src/core/mcp.ts +191 -0
  26. package/src/core/newissue.ts +343 -0
  27. package/src/core/notify.ts +151 -0
  28. package/src/core/prompts.ts +165 -0
  29. package/src/core/qualitygate.ts +70 -0
  30. package/src/core/queue.ts +40 -0
  31. package/src/core/review.ts +266 -0
  32. package/src/core/run.ts +1075 -0
  33. package/src/core/runstore.ts +144 -0
  34. package/src/core/runsview.ts +111 -0
  35. package/src/core/setup.ts +203 -0
  36. package/src/core/sla.ts +39 -0
  37. package/src/core/template.ts +65 -0
  38. package/src/core/watch.ts +825 -0
  39. package/src/core/worktree.ts +74 -0
  40. package/src/core/writeback.ts +88 -0
  41. package/src/index.ts +154 -0
  42. package/src/model/types.ts +35 -0
  43. package/src/prompts/defaults/continuation.md +9 -0
  44. package/src/prompts/defaults/implement.md +13 -0
  45. package/src/prompts/defaults/issue-enrich.md +30 -0
  46. package/src/prompts/defaults/issues/bug.md +35 -0
  47. package/src/prompts/defaults/issues/feature.md +24 -0
  48. package/src/prompts/defaults/issues/generic.md +16 -0
  49. package/src/prompts/defaults/issues/spike.md +24 -0
  50. package/src/prompts/defaults/report.md +20 -0
  51. package/src/prompts/defaults/review.md +34 -0
  52. package/src/prompts/defaults/spec.md +11 -0
  53. package/src/prompts/defaults/task.md +6 -0
  54. package/src/prompts/defaults/triage.md +11 -0
  55. package/src/prompts/text-modules.d.ts +4 -0
  56. package/src/resolve/jobkind.ts +11 -0
  57. package/src/resolve/metadata.ts +103 -0
  58. package/src/resolve/precedence.ts +104 -0
  59. package/src/trackers/factory.ts +17 -0
  60. package/src/trackers/linear/adapter.ts +416 -0
  61. package/src/trackers/linear/client.ts +264 -0
  62. package/src/trackers/linear/map.ts +113 -0
  63. package/src/trackers/linear/types.ts +44 -0
  64. package/src/trackers/marker.ts +20 -0
  65. package/src/trackers/plane/adapter.ts +754 -0
  66. package/src/trackers/plane/client.ts +302 -0
  67. package/src/trackers/plane/map.ts +168 -0
  68. package/src/trackers/plane/types.ts +134 -0
  69. package/src/trackers/tracker.ts +135 -0
@@ -0,0 +1,135 @@
1
+ import type { Issue, IssueMeta, StateGroup } from "../model/types.ts";
2
+
3
+ export class IssueNotFoundError extends Error {
4
+ public constructor(public readonly key: string) {
5
+ super(`beflow: work item "${key}" not found`);
6
+ this.name = "IssueNotFoundError";
7
+ }
8
+ }
9
+
10
+ export interface Comment {
11
+ id: string;
12
+ body: string;
13
+ createdAt: string;
14
+ isBot: boolean;
15
+ authorId?: string;
16
+ }
17
+
18
+ export interface BlockerRef {
19
+ key: string; // the blocking issue's key, e.g. "CG-5"
20
+ done: boolean; // true when the blocker is in the completed OR cancelled state group
21
+ }
22
+
23
+ export interface Attachment {
24
+ name: string;
25
+ url: string;
26
+ }
27
+
28
+ export interface ParentContext {
29
+ body: string;
30
+ key: string;
31
+ title: string;
32
+ type?: string;
33
+ }
34
+
35
+ export interface IssueContext {
36
+ attachments: Attachment[];
37
+ parent?: ParentContext;
38
+ }
39
+
40
+ export interface QueueFilter {
41
+ project: string; // Project KEY e.g. "CG" (matches registry key === Plane project identifier)
42
+ state?: string; // Filter by exact state name, e.g. "Todo"
43
+ stateGroup?: StateGroup; // OR filter by group
44
+ }
45
+
46
+ export interface IssueDraft {
47
+ title: string;
48
+ body: string; // Mapped to Plane description_html as a passthrough string (format-agnostic — no markdown→HTML conversion here)
49
+ type?: string; // Work-item type NAME (e.g. "Bug")
50
+ priority?: string; // urgent|high|medium|low|none
51
+ labels?: string[]; // Label NAMES
52
+ assigneeId?: string; // Tracker user id (uuid)
53
+ state?: string; // State NAME; omitted ⇒ tracker default state
54
+ }
55
+
56
+ export interface IntakeItem {
57
+ id: string; // Intake-issue id
58
+ status: number; // Plane intake status code (1 = accepted, etc.)
59
+ title: string;
60
+ body: string;
61
+ issueId: string; // The wrapped work item id
62
+ priority?: string;
63
+ }
64
+
65
+ export interface BoardTemplate {
66
+ states: { name: string; color: string; group: StateGroup; sequence?: number }[];
67
+ types: { name: string; description?: string }[];
68
+ labels: { name: string; color?: string; description?: string }[];
69
+ modules: { name: string; description?: string }[];
70
+ }
71
+
72
+ export interface BoardState {
73
+ states: string[];
74
+ labels: string[];
75
+ modules: string[];
76
+ types: string[];
77
+ }
78
+
79
+ export interface ProjectCreateSpec {
80
+ description?: string;
81
+ identifier: string;
82
+ name: string;
83
+ }
84
+
85
+ export interface ProjectCreateResult {
86
+ trackerProjectId?: string;
87
+ }
88
+
89
+ export interface EnsureBoardResult {
90
+ created: string[]; // E.g. "state:In Review"
91
+ updated: string[]; // Existed but a tracked property drifted and was PATCHed
92
+ skipped: string[]; // Already existed and matched (by name + tracked properties)
93
+ warnings: string[]; // E.g. work-item-types feature toggle is off
94
+ orphans: string[]; // E.g. "module:OldName" — exists in Plane but not in template
95
+ pruned: string[]; // Orphans actually deleted this run (only when prune is on)
96
+ }
97
+
98
+ export interface EnsureBoardOptions {
99
+ prune?: boolean;
100
+ resolveModuleChanges?: ResolveModuleChanges;
101
+ }
102
+
103
+ export interface ModuleChange {
104
+ removed: string[]; // orphan module names: present in the tracker, absent from config
105
+ added: string[]; // template module names not yet present in the tracker
106
+ }
107
+
108
+ export type ModuleChangeAction = { kind: "rename"; to: string } | { kind: "remove" } | { kind: "keep" };
109
+
110
+ export type ResolveModuleChanges = (change: ModuleChange) => Promise<Record<string, ModuleChangeAction>>;
111
+
112
+ export interface Tracker {
113
+ getIssue(key: string): Promise<Issue>;
114
+ blockedBy(issue: Issue): Promise<BlockerRef[]>; // the issues that BLOCK this one (its blocked_by relations), tagged with whether each is resolved
115
+ issueContext(issue: Issue): Promise<IssueContext>; // linked context (parent epic + attachments) to inline into the agent task; degrade-safe
116
+
117
+ createIssue(project: string, draft: IssueDraft): Promise<Issue>; // create a work item from a draft; returns the created Issue fully populated
118
+ listQueue(filter: QueueFilter): Promise<Issue[]>; // Returned priority-ranked (urgent→none)
119
+ activeCycleIssueIds(project: string): Promise<Set<string> | null>; // work-item ids in the project's active cycle, or null when none is determinable (no active cycle, unsupported, or error)
120
+ updateState(issue: Issue, stateName: string): Promise<void>;
121
+ assign(issue: Issue, assigneeId: string): Promise<void>;
122
+ addProperty(issue: Issue, name: string): Promise<void>;
123
+ removeProperty(issue: Issue, name: string): Promise<void>;
124
+ createProperty(project: string, name: string, opts?: { color?: string; description?: string }): Promise<void>;
125
+ deleteProperty(project: string, name: string): Promise<void>;
126
+ comment(issue: Issue, body: string): Promise<void>;
127
+ listComments(issue: Issue): Promise<Comment[]>;
128
+ linkPR(issue: Issue, url: string, title?: string): Promise<void>;
129
+ readMetadata(issue: Issue): IssueMeta;
130
+ listInbox(project: string): Promise<IntakeItem[]>;
131
+ acceptInbox(project: string, item: IntakeItem): Promise<void>;
132
+ inspectBoard(project: string): Promise<BoardState>;
133
+ ensureBoard(project: string, template: BoardTemplate, opts?: EnsureBoardOptions): Promise<EnsureBoardResult>;
134
+ createProject(spec: ProjectCreateSpec): Promise<ProjectCreateResult>;
135
+ }