@sugar-crash-studios/vibe-forge 0.4.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 (201) hide show
  1. package/.claude/commands/clear-attention.md +63 -0
  2. package/.claude/commands/compact-context.md +52 -0
  3. package/.claude/commands/configure-vcs.md +102 -0
  4. package/.claude/commands/forge.md +171 -0
  5. package/.claude/commands/need-help.md +77 -0
  6. package/.claude/commands/update-status.md +64 -0
  7. package/.claude/commands/worker-loop.md +106 -0
  8. package/.claude/hooks/worker-loop.js +198 -0
  9. package/.claude/scripts/setup-worker-loop.sh +45 -0
  10. package/.claude/settings.local.json +46 -0
  11. package/LICENSE +21 -0
  12. package/README.md +238 -0
  13. package/agents/aegis/personality.md +294 -0
  14. package/agents/anvil/personality.md +276 -0
  15. package/agents/architect/personality.md +258 -0
  16. package/agents/crucible/personality.md +360 -0
  17. package/agents/ember/personality.md +291 -0
  18. package/agents/forge-master/capabilities.md +144 -0
  19. package/agents/forge-master/context-template.md +128 -0
  20. package/agents/forge-master/personality.md +138 -0
  21. package/agents/furnace/personality.md +340 -0
  22. package/agents/herald/personality.md +247 -0
  23. package/agents/loki/personality.md +108 -0
  24. package/agents/oracle/personality.md +283 -0
  25. package/agents/pixel/personality.md +113 -0
  26. package/agents/planning-hub/personality.md +320 -0
  27. package/agents/scribe/personality.md +251 -0
  28. package/agents/temper/personality.md +218 -0
  29. package/bin/cli.js +375 -0
  30. package/bin/dashboard/api/agents.js +333 -0
  31. package/bin/dashboard/api/dispatch.js +483 -0
  32. package/bin/dashboard/api/tasks.js +416 -0
  33. package/bin/dashboard/frontend/index.html +13 -0
  34. package/bin/dashboard/frontend/package.json +16 -0
  35. package/bin/dashboard/frontend/src/App.svelte +222 -0
  36. package/bin/dashboard/frontend/src/app.css +1777 -0
  37. package/bin/dashboard/frontend/src/lib/components/AgentCard.svelte +60 -0
  38. package/bin/dashboard/frontend/src/lib/components/AgentsPanel.svelte +57 -0
  39. package/bin/dashboard/frontend/src/lib/components/DispatchModal.svelte +180 -0
  40. package/bin/dashboard/frontend/src/lib/components/Footer.svelte +33 -0
  41. package/bin/dashboard/frontend/src/lib/components/Header.svelte +84 -0
  42. package/bin/dashboard/frontend/src/lib/components/IssueCard.svelte +33 -0
  43. package/bin/dashboard/frontend/src/lib/components/IssuesPanel.svelte +73 -0
  44. package/bin/dashboard/frontend/src/lib/components/KeyboardShortcutsModal.svelte +108 -0
  45. package/bin/dashboard/frontend/src/lib/components/MobileTabs.svelte +52 -0
  46. package/bin/dashboard/frontend/src/lib/components/NotificationCard.svelte +60 -0
  47. package/bin/dashboard/frontend/src/lib/components/NotificationsPanel.svelte +44 -0
  48. package/bin/dashboard/frontend/src/lib/components/TaskCard.svelte +63 -0
  49. package/bin/dashboard/frontend/src/lib/components/TasksPanel.svelte +82 -0
  50. package/bin/dashboard/frontend/src/lib/components/Toast.svelte +45 -0
  51. package/bin/dashboard/frontend/src/lib/stores/agents.js +34 -0
  52. package/bin/dashboard/frontend/src/lib/stores/issues.js +54 -0
  53. package/bin/dashboard/frontend/src/lib/stores/notifications.js +48 -0
  54. package/bin/dashboard/frontend/src/lib/stores/tasks.js +63 -0
  55. package/bin/dashboard/frontend/src/lib/stores/theme.js +33 -0
  56. package/bin/dashboard/frontend/src/lib/stores/toast.js +35 -0
  57. package/bin/dashboard/frontend/src/lib/stores/ui.js +25 -0
  58. package/bin/dashboard/frontend/src/lib/stores/voice.js +275 -0
  59. package/bin/dashboard/frontend/src/lib/stores/websocket.js +295 -0
  60. package/bin/dashboard/frontend/src/lib/utils/api.js +101 -0
  61. package/bin/dashboard/frontend/src/lib/utils/formatters.js +54 -0
  62. package/bin/dashboard/frontend/src/main.js +9 -0
  63. package/bin/dashboard/frontend/svelte.config.js +5 -0
  64. package/bin/dashboard/frontend/vite.config.js +20 -0
  65. package/bin/dashboard/public/assets/index-DnfVj9Ce.css +1 -0
  66. package/bin/dashboard/public/assets/index-Ze5h0kXQ.js +2 -0
  67. package/bin/dashboard/public/index.html +14 -0
  68. package/bin/dashboard/server.js +566 -0
  69. package/bin/forge-daemon.sh +463 -0
  70. package/bin/forge-setup.sh +645 -0
  71. package/bin/forge-spawn.sh +164 -0
  72. package/bin/forge.cmd +83 -0
  73. package/bin/forge.sh +533 -0
  74. package/bin/lib/agents.sh +177 -0
  75. package/bin/lib/colors.sh +44 -0
  76. package/bin/lib/config.sh +347 -0
  77. package/bin/lib/constants.sh +241 -0
  78. package/bin/lib/daemon/display.sh +128 -0
  79. package/bin/lib/daemon/notifications.sh +263 -0
  80. package/bin/lib/daemon/routing.sh +77 -0
  81. package/bin/lib/daemon/state.sh +115 -0
  82. package/bin/lib/daemon/sync.sh +95 -0
  83. package/bin/lib/database.sh +310 -0
  84. package/bin/lib/heimdall-setup.js +113 -0
  85. package/bin/lib/heimdall.js +265 -0
  86. package/bin/lib/json.sh +264 -0
  87. package/bin/lib/terminal.js +451 -0
  88. package/bin/lib/util.sh +126 -0
  89. package/bin/lib/vcs.js +349 -0
  90. package/config/agent-manifest.yaml +203 -0
  91. package/config/agents.json +168 -0
  92. package/config/task-template.md +159 -0
  93. package/config/task-types.yaml +106 -0
  94. package/context/agent-status/aegis.json +7 -0
  95. package/context/agent-status/anvil.json +7 -0
  96. package/context/agent-status/architect.json +7 -0
  97. package/context/agent-status/crucible.json +7 -0
  98. package/context/agent-status/ember.json +7 -0
  99. package/context/agent-status/furnace.json +7 -0
  100. package/context/agent-status/loki.json +7 -0
  101. package/context/agent-status/oracle.json +7 -0
  102. package/context/agent-status/pixel.json +7 -0
  103. package/context/agent-status/planning-hub.json +7 -0
  104. package/context/agent-status/scribe.json +7 -0
  105. package/context/agent-status/temper.json +7 -0
  106. package/context/feature-brainstorm.md +426 -0
  107. package/context/forge-state.yaml +19 -0
  108. package/context/modern-conventions.md +129 -0
  109. package/context/project-context-template.md +122 -0
  110. package/context/project-context.md +122 -0
  111. package/docs/TODO.md +150 -0
  112. package/docs/agents.md +409 -0
  113. package/docs/architecture/decisions/ADR-001-daemon-modularization.md +122 -0
  114. package/docs/architecture/vibe-lab-integration.md +684 -0
  115. package/docs/architecture.md +194 -0
  116. package/docs/bmad-gap-analysis-2026-03-31.md +444 -0
  117. package/docs/cleanup-workflow.md +329 -0
  118. package/docs/commands.md +451 -0
  119. package/docs/dashboard-mockup.html +989 -0
  120. package/docs/getting-started.md +261 -0
  121. package/docs/integration/forge-ownership-policy.md +112 -0
  122. package/docs/npm-publishing.md +132 -0
  123. package/docs/roadmap-2026.md +519 -0
  124. package/docs/security.md +144 -0
  125. package/docs/wireframes/dashboard-mvp.md +1164 -0
  126. package/docs/workflows/README.md +32 -0
  127. package/docs/workflows/azure-devops.md +108 -0
  128. package/docs/workflows/bitbucket.md +104 -0
  129. package/docs/workflows/git-only.md +130 -0
  130. package/docs/workflows/gitea.md +168 -0
  131. package/docs/workflows/github.md +103 -0
  132. package/docs/workflows/gitlab.md +105 -0
  133. package/docs/workflows.md +454 -0
  134. package/package.json +73 -0
  135. package/tasks/completed/ARCH-001-duplicate-agent-config.md +121 -0
  136. package/tasks/completed/ARCH-002-mixed-bash-node-implementation.md +88 -0
  137. package/tasks/completed/ARCH-003-worker-loop-hook-duplication.md +77 -0
  138. package/tasks/completed/ARCH-009-test-organization.md +78 -0
  139. package/tasks/completed/ARCH-011-jq-vs-nodejs-json.md +94 -0
  140. package/tasks/completed/ARCH-012-tmp-files-in-root.md +71 -0
  141. package/tasks/completed/ARCH-013-exit-code-constants.md +65 -0
  142. package/tasks/completed/ARCH-014-sed-incompatibility.md +96 -0
  143. package/tasks/completed/ARCH-015-docs-todo-tracking.md +83 -0
  144. package/tasks/completed/BUG-dash-001-tasks-filter-error.md +31 -0
  145. package/tasks/completed/BUG-dash-002-agents-unknown.md +41 -0
  146. package/tasks/completed/CLEAN-001.md +38 -0
  147. package/tasks/completed/CLEAN-002.md +43 -0
  148. package/tasks/completed/CLEAN-003.md +47 -0
  149. package/tasks/completed/CLEAN-004.md +56 -0
  150. package/tasks/completed/CLEAN-005.md +75 -0
  151. package/tasks/completed/CLEAN-006.md +47 -0
  152. package/tasks/completed/CLEAN-007.md +34 -0
  153. package/tasks/completed/CLEAN-008.md +49 -0
  154. package/tasks/completed/CLEAN-012.md +58 -0
  155. package/tasks/completed/CLEAN-013.md +45 -0
  156. package/tasks/completed/FEATURE-001a-dashboard-wireframes.md +162 -0
  157. package/tasks/completed/IMPL-007a-daemon-notifications-module.md +82 -0
  158. package/tasks/completed/IMPL-007b-daemon-sync-module.md +71 -0
  159. package/tasks/completed/IMPL-007c-daemon-state-module.md +80 -0
  160. package/tasks/completed/IMPL-007d-daemon-routing-module.md +77 -0
  161. package/tasks/completed/IMPL-007e-daemon-display-module.md +77 -0
  162. package/tasks/completed/IMPL-007f-daemon-integration.md +124 -0
  163. package/tasks/completed/PLAT-1-heimdall.md +420 -0
  164. package/tasks/completed/SEC-001-sql-injection-fix.md +58 -0
  165. package/tasks/completed/SEC-002-notification-injection-fix.md +45 -0
  166. package/tasks/completed/SEC-003-eval-injection-fix.md +54 -0
  167. package/tasks/completed/SEC-004-pid-race-condition-fix.md +49 -0
  168. package/tasks/completed/SEC-005-worker-loop-path-fix.md +51 -0
  169. package/tasks/completed/SEC-006-eval-agent-names.md +55 -0
  170. package/tasks/completed/SEC-007-spawn-escaping.md +67 -0
  171. package/tasks/completed/TASK-DASH-001-server-infrastructure.md +185 -0
  172. package/tasks/completed/TASK-anvil-001-dashboard-frontend.md +133 -0
  173. package/tasks/completed/review-bmad-aegis.md +89 -0
  174. package/tasks/completed/review-bmad-anvil.md +80 -0
  175. package/tasks/completed/review-bmad-crucible.md +81 -0
  176. package/tasks/completed/review-bmad-ember.md +90 -0
  177. package/tasks/completed/review-bmad-furnace.md +79 -0
  178. package/tasks/completed/review-bmad-pixel.md +82 -0
  179. package/tasks/completed/review-bmad-scribe.md +92 -0
  180. package/tasks/completed/review-bmad-sentinel.md +83 -0
  181. package/tasks/pending/ARCH-004-git-bash-detection-duplication.md +72 -0
  182. package/tasks/pending/ARCH-005-missing-src-directory.md +95 -0
  183. package/tasks/pending/ARCH-006-task-template-location.md +64 -0
  184. package/tasks/pending/ARCH-008-forge-master-vs-hub.md +81 -0
  185. package/tasks/pending/ARCH-010-missing-index-files.md +84 -0
  186. package/tasks/pending/CLEAN-009.md +31 -0
  187. package/tasks/pending/CLEAN-010.md +30 -0
  188. package/tasks/pending/CLEAN-011.md +30 -0
  189. package/tasks/pending/CLEAN-014.md +32 -0
  190. package/tasks/pending/DESIGN-dash-001-layout-review.md +45 -0
  191. package/tasks/pending/FEATURE-001-dashboard-mvp.md +268 -0
  192. package/tasks/review/ARCH-007-daemon-monolith.md +162 -0
  193. package/tasks/review/bmad-review-aegis.md +349 -0
  194. package/tasks/review/bmad-review-anvil.md +259 -0
  195. package/tasks/review/bmad-review-crucible.md +277 -0
  196. package/tasks/review/bmad-review-ember.md +307 -0
  197. package/tasks/review/bmad-review-furnace.md +285 -0
  198. package/tasks/review/bmad-review-pixel.md +329 -0
  199. package/tasks/review/bmad-review-scribe.md +361 -0
  200. package/tasks/review/bmad-review-sentinel.md +242 -0
  201. package/tasks/review/task-001.md +78 -0
@@ -0,0 +1,162 @@
1
+ ---
2
+ id: FEATURE-001a
3
+ title: "Dashboard wireframes and UX specification"
4
+ type: design
5
+ priority: critical
6
+ status: completed
7
+ created_at: 2026-01-16T21:00:00Z
8
+ created_by: planning-hub
9
+ assigned_to: pixel
10
+ parent_task: FEATURE-001
11
+ completed_at: 2026-01-16T22:30:00Z
12
+ completed_by: pixel
13
+ ---
14
+
15
+ # Dashboard Wireframes and UX Specification
16
+
17
+ ## Summary
18
+
19
+ Create wireframes and UX specification for the Dashboard MVP. This guides Anvil's implementation and ensures a cohesive user experience.
20
+
21
+ ## Deliverables
22
+
23
+ ### 1. Main Dashboard Wireframe
24
+ - Three-panel layout (Tasks, Agents, Notifications)
25
+ - Issues/Actionable panel placement
26
+ - Header with settings and theme toggle
27
+ - Responsive breakpoints (desktop, tablet, mobile)
28
+
29
+ ### 2. Interaction Specifications
30
+ - Task card click -> detail view or expand?
31
+ - Agent status -> what info on hover?
32
+ - Notification -> dismiss behavior?
33
+ - Dispatch button -> confirmation or immediate?
34
+
35
+ ### 3. State Documentation
36
+ - Empty states ("No pending tasks")
37
+ - Loading states (skeleton or spinner?)
38
+ - Error states (connection lost, API error)
39
+ - Success states (task dispatched)
40
+
41
+ ### 4. Actionable Items UX
42
+ - How issues are displayed
43
+ - Dispatch button placement and style
44
+ - Confirmation flow (if any)
45
+ - Feedback after dispatch
46
+
47
+ ### 5. Dark Mode Specification
48
+ - Color palette (backgrounds, text, accents)
49
+ - Ensure WCAG AA contrast ratios
50
+ - Agent colors visible in dark mode
51
+
52
+ ### 6. Accessibility Notes
53
+ - Keyboard navigation flow
54
+ - Focus indicators
55
+ - Screen reader announcements
56
+ - Skip links if needed
57
+
58
+ ## User Flows to Document
59
+
60
+ 1. **Morning Check-in**: Open dashboard -> scan issues -> dispatch if needed
61
+ 2. **Dispatch Flow**: See issue -> click dispatch -> confirm -> see task created
62
+ 3. **Monitor Progress**: Watch agent status -> see task move through columns
63
+ 4. **Re-open Dashboard**: Dashboard was closed -> `forge dashboard` -> browser opens
64
+
65
+ ## Output Format
66
+
67
+ Create wireframes in:
68
+ - ASCII art (for task file / markdown docs)
69
+ - Or simple HTML/CSS mockup in `docs/wireframes/`
70
+ - Or describe in detail with component specifications
71
+
72
+ ## Design Principles (from brainstorm)
73
+
74
+ 1. **Progressive Disclosure** - summary first, details on demand
75
+ 2. **Immediate Feedback** - every action confirms within 100ms
76
+ 3. **Error Prevention** - dangerous actions require confirmation
77
+ 4. **Mobile Responsive** - status checks from anywhere
78
+
79
+ ## Acceptance Criteria
80
+
81
+ - [x] Main dashboard wireframe complete
82
+ - [x] All states documented (empty, loading, error, success)
83
+ - [x] Actionable items dispatch flow specified
84
+ - [x] Dark mode colors defined
85
+ - [x] Accessibility considerations documented
86
+ - [x] Anvil can implement without ambiguity
87
+
88
+ ## Completion Summary
89
+
90
+ ### Output Created
91
+
92
+ The comprehensive UX specification was created at: `docs/wireframes/dashboard-mvp.md`
93
+
94
+ ### What Was Delivered
95
+
96
+ 1. **Main Dashboard Wireframe (ASCII Art)**
97
+ - Desktop layout with 3-panel top row (Tasks 40%, Agents 30%, Notifications 30%)
98
+ - Full-width Issues panel at bottom (the killer feature)
99
+ - Header with logo, settings, and theme toggle
100
+ - Footer with connection status
101
+
102
+ 2. **Component Specifications**
103
+ - Header component with logo, title, settings, theme toggle
104
+ - Tasks panel with filter tabs (Pending/Progress/Review/Done) and task cards
105
+ - Agents panel with status indicators and progress bars
106
+ - Notifications panel with type icons and action buttons
107
+ - Issues panel with category badges and dispatch buttons
108
+
109
+ 3. **Interaction Flows (4 Documented)**
110
+ - Morning Check-in Flow
111
+ - Dispatch Agent Flow (detailed step-by-step)
112
+ - Task Card Expansion Flow
113
+ - Theme Toggle Flow
114
+
115
+ 4. **State Documentation**
116
+ - Loading states: Skeleton animation with shimmer effect
117
+ - Empty states: Friendly messages with icons for each panel
118
+ - Error states: Connection lost banner, panel-specific errors, dispatch failures
119
+ - Success states: Toast notifications with actions
120
+
121
+ 5. **Actionable Items UX (The Killer Feature)**
122
+ - Issue card anatomy with category icons
123
+ - Dispatch button states (default, hover, active, loading, disabled)
124
+ - Confirmation modal design
125
+ - Post-dispatch feedback sequence (0ms -> 200-500ms timeline)
126
+
127
+ 6. **Dark Mode Specification**
128
+ - Complete color palette with 15+ tokens
129
+ - Agent colors optimized for dark backgrounds
130
+ - Light mode alternative palette
131
+ - WCAG AA contrast ratios verified
132
+ - CSS variable implementation example
133
+
134
+ 7. **Accessibility**
135
+ - Keyboard navigation with global and panel shortcuts
136
+ - Focus indicators (2px outline with offset)
137
+ - ARIA live regions for announcements
138
+ - Semantic landmarks
139
+ - Color-independent information design
140
+ - Skip links
141
+
142
+ 8. **Responsive Design**
143
+ - Desktop (1200px+): Full 3-column layout
144
+ - Tablet (768-1199px): 2-column stacked layout
145
+ - Mobile (320-767px): Single column with tab bar
146
+
147
+ 9. **Keyboard Shortcuts**
148
+ - Quick reference card design
149
+ - Navigation: 1-4 for panels, j/k for lists
150
+ - Actions: d for dispatch, r for refresh, t for theme
151
+
152
+ 10. **Implementation Notes for Anvil**
153
+ - Priority order for implementation
154
+ - Animation guidelines with durations and easing
155
+ - Testing checklist
156
+
157
+ ## References
158
+
159
+ - Parent feature: `tasks/pending/FEATURE-001-dashboard-mvp.md`
160
+ - Brainstorm: `context/feature-brainstorm.md`
161
+ - Pixel personality: `agents/pixel/personality.md`
162
+ - **Output file: `docs/wireframes/dashboard-mvp.md`**
@@ -0,0 +1,82 @@
1
+ ---
2
+ id: IMPL-007a
3
+ title: "Extract daemon notifications module"
4
+ type: implementation
5
+ priority: medium
6
+ assigned_to: anvil
7
+ created_at: 2026-01-17T10:00:00Z
8
+ created_by: architect
9
+ parent_task: ARCH-007
10
+ ---
11
+
12
+ ## Summary
13
+
14
+ Extract notification-related functions from `forge-daemon.sh` into a dedicated module `bin/lib/daemon/notifications.sh`.
15
+
16
+ ## Context
17
+
18
+ See ADR-001: docs/architecture/decisions/ADR-001-daemon-modularization.md
19
+
20
+ ## Functions to Extract
21
+
22
+ From `bin/forge-daemon.sh`, move these functions:
23
+
24
+ 1. `sanitize_notification_message()` (lines 122-134)
25
+ 2. `notify()` (lines 136-155)
26
+ 3. `send_system_notification()` (lines 158-192)
27
+ 4. `check_new_pending_tasks()` (lines 194-254)
28
+ 5. `check_attention_needed()` (lines 257-288)
29
+
30
+ ## Implementation
31
+
32
+ ### 1. Create module file
33
+
34
+ ```bash
35
+ #!/usr/bin/env bash
36
+ # bin/lib/daemon/notifications.sh
37
+ #
38
+ # Daemon notification functions
39
+ #
40
+ # Dependencies: colors.sh, constants.sh
41
+ # Globals required: FORGE_ROOT, NOTIFY_FILE, NOTIFIED_FILE, LOG_FILE,
42
+ # TASKS_PENDING, TASKS_NEEDS_CHANGES, TASKS_ATTENTION
43
+
44
+ # Prevent double-sourcing
45
+ [[ -n "${_DAEMON_NOTIFICATIONS_LOADED:-}" ]] && return 0
46
+ _DAEMON_NOTIFICATIONS_LOADED=1
47
+
48
+ # [paste functions here, maintaining exact implementation]
49
+ ```
50
+
51
+ ### 2. Update forge-daemon.sh
52
+
53
+ Add after existing library sources:
54
+ ```bash
55
+ # shellcheck source=lib/daemon/notifications.sh
56
+ source "$SCRIPT_DIR/lib/daemon/notifications.sh"
57
+ ```
58
+
59
+ Remove the extracted functions from forge-daemon.sh.
60
+
61
+ ### 3. Test
62
+
63
+ ```bash
64
+ # Verify daemon still starts
65
+ ./bin/forge-daemon.sh start
66
+ ./bin/forge-daemon.sh status
67
+ ./bin/forge-daemon.sh stop
68
+
69
+ # Run existing tests
70
+ npm test
71
+ ```
72
+
73
+ ## Acceptance Criteria
74
+
75
+ - [ ] `bin/lib/daemon/notifications.sh` created with all 5 functions
76
+ - [ ] Module has proper header with dependencies documented
77
+ - [ ] Module has double-source protection
78
+ - [ ] `forge-daemon.sh` sources the new module
79
+ - [ ] Functions removed from `forge-daemon.sh`
80
+ - [ ] Daemon starts/stops/status works correctly
81
+ - [ ] All existing tests pass
82
+ - [ ] ShellCheck passes on new module
@@ -0,0 +1,71 @@
1
+ ---
2
+ id: IMPL-007b
3
+ title: "Extract daemon sync module"
4
+ type: implementation
5
+ priority: medium
6
+ assigned_to: furnace
7
+ created_at: 2026-01-17T10:00:00Z
8
+ created_by: architect
9
+ parent_task: ARCH-007
10
+ depends_on: []
11
+ ---
12
+
13
+ ## Summary
14
+
15
+ Extract agent status synchronization functions from `forge-daemon.sh` into `bin/lib/daemon/sync.sh`.
16
+
17
+ ## Context
18
+
19
+ See ADR-001: docs/architecture/decisions/ADR-001-daemon-modularization.md
20
+
21
+ ## Functions to Extract
22
+
23
+ From `bin/forge-daemon.sh`:
24
+
25
+ 1. `sync_agent_status_to_db()` (lines 291-328)
26
+ 2. `build_worker_status()` (lines 331-370)
27
+
28
+ ## Implementation
29
+
30
+ ### 1. Create module file
31
+
32
+ ```bash
33
+ #!/usr/bin/env bash
34
+ # bin/lib/daemon/sync.sh
35
+ #
36
+ # Agent status synchronization functions
37
+ #
38
+ # Dependencies: json.sh, database.sh, constants.sh
39
+ # Globals required: FORGE_ROOT, FORGE_DB, AGENT_STATUS_DIR, LOG_FILE,
40
+ # STALE_STATUS_THRESHOLD
41
+
42
+ # Prevent double-sourcing
43
+ [[ -n "${_DAEMON_SYNC_LOADED:-}" ]] && return 0
44
+ _DAEMON_SYNC_LOADED=1
45
+
46
+ # [paste functions here]
47
+ ```
48
+
49
+ ### 2. Update forge-daemon.sh
50
+
51
+ Add source line and remove extracted functions.
52
+
53
+ ### 3. Test
54
+
55
+ ```bash
56
+ ./bin/forge-daemon.sh start
57
+ ./bin/forge-daemon.sh status # Should show workers if status files exist
58
+ ./bin/forge-daemon.sh stop
59
+ npm test
60
+ ```
61
+
62
+ ## Acceptance Criteria
63
+
64
+ - [ ] `bin/lib/daemon/sync.sh` created with both functions
65
+ - [ ] Module has proper header with dependencies
66
+ - [ ] Module has double-source protection
67
+ - [ ] `forge-daemon.sh` sources the new module
68
+ - [ ] Functions removed from `forge-daemon.sh`
69
+ - [ ] Worker status displays correctly in `forge daemon status`
70
+ - [ ] All existing tests pass
71
+ - [ ] ShellCheck passes
@@ -0,0 +1,80 @@
1
+ ---
2
+ id: IMPL-007c
3
+ title: "Extract daemon state module"
4
+ type: implementation
5
+ priority: medium
6
+ assigned_to: ember
7
+ created_at: 2026-01-17T10:00:00Z
8
+ created_by: architect
9
+ parent_task: ARCH-007
10
+ depends_on: [IMPL-007b]
11
+ ---
12
+
13
+ ## Summary
14
+
15
+ Extract state management functions from `forge-daemon.sh` into `bin/lib/daemon/state.sh`.
16
+
17
+ ## Context
18
+
19
+ See ADR-001: docs/architecture/decisions/ADR-001-daemon-modularization.md
20
+
21
+ ## Functions to Extract
22
+
23
+ From `bin/forge-daemon.sh`:
24
+
25
+ 1. `update_state()` (lines 376-429)
26
+ 2. `build_attention_details()` (lines 431-447)
27
+ 3. `determine_daemon_state()` (lines 474-488)
28
+ 4. `get_poll_interval()` (lines 491-496)
29
+
30
+ **Note:** `update_state()` calls `build_attention_details()` and `build_worker_status()` (from sync.sh), so this module depends on IMPL-007b being completed first.
31
+
32
+ ## Implementation
33
+
34
+ ### 1. Create module file
35
+
36
+ ```bash
37
+ #!/usr/bin/env bash
38
+ # bin/lib/daemon/state.sh
39
+ #
40
+ # Daemon state management functions
41
+ #
42
+ # Dependencies: database.sh, constants.sh
43
+ # Requires: sync.sh (for build_worker_status)
44
+ # Globals required: FORGE_ROOT, STATE_FILE, TASKS_*, AGENT_STATUS_DIR
45
+
46
+ # Prevent double-sourcing
47
+ [[ -n "${_DAEMON_STATE_LOADED:-}" ]] && return 0
48
+ _DAEMON_STATE_LOADED=1
49
+
50
+ # [paste functions here]
51
+ ```
52
+
53
+ ### 2. Update forge-daemon.sh
54
+
55
+ Source order matters - sync.sh must come before state.sh:
56
+ ```bash
57
+ source "$SCRIPT_DIR/lib/daemon/sync.sh"
58
+ source "$SCRIPT_DIR/lib/daemon/state.sh"
59
+ ```
60
+
61
+ ### 3. Test
62
+
63
+ ```bash
64
+ ./bin/forge-daemon.sh start
65
+ # Wait a few seconds
66
+ cat context/forge-state.yaml # Should have valid YAML
67
+ ./bin/forge-daemon.sh stop
68
+ npm test
69
+ ```
70
+
71
+ ## Acceptance Criteria
72
+
73
+ - [ ] `bin/lib/daemon/state.sh` created with all 4 functions
74
+ - [ ] Module has proper header with dependencies
75
+ - [ ] Module has double-source protection
76
+ - [ ] Source order correct in forge-daemon.sh
77
+ - [ ] Functions removed from `forge-daemon.sh`
78
+ - [ ] `forge-state.yaml` updates correctly when daemon runs
79
+ - [ ] All existing tests pass
80
+ - [ ] ShellCheck passes
@@ -0,0 +1,77 @@
1
+ ---
2
+ id: IMPL-007d
3
+ title: "Extract daemon routing module"
4
+ type: implementation
5
+ priority: medium
6
+ assigned_to: anvil
7
+ created_at: 2026-01-17T10:00:00Z
8
+ created_by: architect
9
+ parent_task: ARCH-007
10
+ depends_on: []
11
+ ---
12
+
13
+ ## Summary
14
+
15
+ Extract task routing functions from `forge-daemon.sh` into `bin/lib/daemon/routing.sh`.
16
+
17
+ ## Context
18
+
19
+ See ADR-001: docs/architecture/decisions/ADR-001-daemon-modularization.md
20
+
21
+ ## Functions to Extract
22
+
23
+ From `bin/forge-daemon.sh`:
24
+
25
+ 1. `safe_move_task()` (lines 85-114) - Currently in Utility Functions section
26
+ 2. `route_completed_to_review()` (lines 449-459)
27
+ 3. `route_approved_to_merged()` (lines 461-471)
28
+
29
+ ## Implementation
30
+
31
+ ### 1. Create module file
32
+
33
+ ```bash
34
+ #!/usr/bin/env bash
35
+ # bin/lib/daemon/routing.sh
36
+ #
37
+ # Task routing functions
38
+ #
39
+ # Dependencies: constants.sh
40
+ # Globals required: FORGE_ROOT, LOG_FILE, TASKS_COMPLETED, TASKS_REVIEW,
41
+ # TASKS_APPROVED, TASKS_MERGED
42
+
43
+ # Prevent double-sourcing
44
+ [[ -n "${_DAEMON_ROUTING_LOADED:-}" ]] && return 0
45
+ _DAEMON_ROUTING_LOADED=1
46
+
47
+ # [paste functions here]
48
+ ```
49
+
50
+ ### 2. Update forge-daemon.sh
51
+
52
+ Add source and remove functions.
53
+
54
+ ### 3. Test
55
+
56
+ ```bash
57
+ # Create a test task in completed/
58
+ echo "test" > tasks/completed/test-routing.md
59
+ ./bin/forge-daemon.sh start
60
+ sleep 5
61
+ ls tasks/review/ # Should contain test-routing.md
62
+ ./bin/forge-daemon.sh stop
63
+ rm tasks/review/test-routing.md
64
+ npm test
65
+ ```
66
+
67
+ ## Acceptance Criteria
68
+
69
+ - [ ] `bin/lib/daemon/routing.sh` created with all 3 functions
70
+ - [ ] Module has proper header with dependencies
71
+ - [ ] Module has double-source protection
72
+ - [ ] `forge-daemon.sh` sources the new module
73
+ - [ ] Functions removed from `forge-daemon.sh`
74
+ - [ ] Task routing works (completed -> review -> approved -> merged)
75
+ - [ ] Security checks in `safe_move_task` preserved
76
+ - [ ] All existing tests pass
77
+ - [ ] ShellCheck passes
@@ -0,0 +1,77 @@
1
+ ---
2
+ id: IMPL-007e
3
+ title: "Extract daemon display module"
4
+ type: implementation
5
+ priority: medium
6
+ assigned_to: furnace
7
+ created_at: 2026-01-17T10:00:00Z
8
+ created_by: architect
9
+ parent_task: ARCH-007
10
+ depends_on: []
11
+ ---
12
+
13
+ ## Summary
14
+
15
+ Extract status display functions from `forge-daemon.sh` into `bin/lib/daemon/display.sh`.
16
+
17
+ ## Context
18
+
19
+ See ADR-001: docs/architecture/decisions/ADR-001-daemon-modularization.md
20
+
21
+ ## Functions to Extract
22
+
23
+ From `bin/forge-daemon.sh`:
24
+
25
+ 1. `display_daemon_status()` (lines 663-675)
26
+ 2. `display_task_counts()` (lines 678-683)
27
+ 3. `display_attention_needed()` (lines 686-700)
28
+ 4. `get_status_icon()` (lines 703-714)
29
+ 5. `display_worker_status()` (lines 717-762)
30
+ 6. `display_recent_notifications()` (lines 765-775)
31
+
32
+ ## Implementation
33
+
34
+ ### 1. Create module file
35
+
36
+ ```bash
37
+ #!/usr/bin/env bash
38
+ # bin/lib/daemon/display.sh
39
+ #
40
+ # Status display functions for daemon status command
41
+ #
42
+ # Dependencies: colors.sh, constants.sh, json.sh
43
+ # Globals required: FORGE_ROOT, PID_FILE, STATE_FILE, NOTIFY_FILE,
44
+ # AGENT_STATUS_DIR, TASKS_ATTENTION, STALE_STATUS_THRESHOLD
45
+
46
+ # Prevent double-sourcing
47
+ [[ -n "${_DAEMON_DISPLAY_LOADED:-}" ]] && return 0
48
+ _DAEMON_DISPLAY_LOADED=1
49
+
50
+ # [paste functions here]
51
+ ```
52
+
53
+ ### 2. Update forge-daemon.sh
54
+
55
+ Add source and remove functions. The `cmd_status()` function stays in forge-daemon.sh but calls the display functions.
56
+
57
+ ### 3. Test
58
+
59
+ ```bash
60
+ ./bin/forge-daemon.sh start
61
+ ./bin/forge-daemon.sh status # Should show all sections with colors
62
+ ./bin/forge-daemon.sh stop
63
+ ./bin/forge-daemon.sh status # Should show stopped status
64
+ npm test
65
+ ```
66
+
67
+ ## Acceptance Criteria
68
+
69
+ - [ ] `bin/lib/daemon/display.sh` created with all 6 functions
70
+ - [ ] Module has proper header with dependencies
71
+ - [ ] Module has double-source protection
72
+ - [ ] `forge-daemon.sh` sources the new module
73
+ - [ ] Functions removed from `forge-daemon.sh`
74
+ - [ ] `forge daemon status` displays all sections correctly
75
+ - [ ] Colors and icons display properly
76
+ - [ ] All existing tests pass
77
+ - [ ] ShellCheck passes
@@ -0,0 +1,124 @@
1
+ ---
2
+ id: IMPL-007f
3
+ title: "Integrate daemon modules and verify"
4
+ type: implementation
5
+ priority: medium
6
+ assigned_to: ember
7
+ created_at: 2026-01-17T10:00:00Z
8
+ created_by: architect
9
+ parent_task: ARCH-007
10
+ depends_on: [IMPL-007a, IMPL-007b, IMPL-007c, IMPL-007d, IMPL-007e]
11
+ ---
12
+
13
+ ## Summary
14
+
15
+ Final integration task: ensure all daemon modules work together, verify the main daemon file is under 200 lines, and run comprehensive tests.
16
+
17
+ ## Context
18
+
19
+ See ADR-001: docs/architecture/decisions/ADR-001-daemon-modularization.md
20
+
21
+ After IMPL-007a through IMPL-007e are complete, `forge-daemon.sh` should:
22
+ 1. Be significantly smaller (~150-200 lines)
23
+ 2. Source all modules from `bin/lib/daemon/`
24
+ 3. Contain only: config, daemon_loop, commands, main
25
+
26
+ ## Verification Steps
27
+
28
+ ### 1. Line count check
29
+
30
+ ```bash
31
+ wc -l bin/forge-daemon.sh # Should be < 200 lines
32
+ wc -l bin/lib/daemon/*.sh # Each module should be < 200 lines
33
+ ```
34
+
35
+ ### 2. Source order verification
36
+
37
+ `forge-daemon.sh` should source in this order:
38
+ ```bash
39
+ # Standard libraries
40
+ source "$SCRIPT_DIR/lib/colors.sh"
41
+ source "$SCRIPT_DIR/lib/constants.sh"
42
+ source "$SCRIPT_DIR/lib/config.sh"
43
+ source "$SCRIPT_DIR/lib/json.sh"
44
+ source "$SCRIPT_DIR/lib/database.sh"
45
+ source "$SCRIPT_DIR/lib/util.sh"
46
+
47
+ # Daemon modules
48
+ source "$SCRIPT_DIR/lib/daemon/routing.sh"
49
+ source "$SCRIPT_DIR/lib/daemon/notifications.sh"
50
+ source "$SCRIPT_DIR/lib/daemon/sync.sh"
51
+ source "$SCRIPT_DIR/lib/daemon/state.sh"
52
+ source "$SCRIPT_DIR/lib/daemon/display.sh"
53
+ ```
54
+
55
+ ### 3. Comprehensive test
56
+
57
+ ```bash
58
+ # Start daemon
59
+ ./bin/forge-daemon.sh start
60
+ echo "Started"
61
+
62
+ # Check status
63
+ ./bin/forge-daemon.sh status
64
+
65
+ # Create test task to trigger routing
66
+ echo -e "---\nid: TEST-001\ntitle: Test\n---\nTest" > tasks/completed/test-integration.md
67
+ sleep 5
68
+
69
+ # Verify routing
70
+ ls tasks/review/test-integration.md && echo "Routing works"
71
+
72
+ # Check notifications
73
+ ./bin/forge-daemon.sh notifications 5
74
+
75
+ # Stop daemon
76
+ ./bin/forge-daemon.sh stop
77
+ echo "Stopped"
78
+
79
+ # Verify state file
80
+ cat context/forge-state.yaml
81
+
82
+ # Cleanup
83
+ rm -f tasks/review/test-integration.md
84
+
85
+ # Run unit tests
86
+ npm test
87
+ ```
88
+
89
+ ### 4. ShellCheck all modules
90
+
91
+ ```bash
92
+ shellcheck bin/forge-daemon.sh
93
+ shellcheck bin/lib/daemon/*.sh
94
+ ```
95
+
96
+ ## Final Structure
97
+
98
+ After completion:
99
+ ```
100
+ bin/
101
+ forge-daemon.sh # ~150-200 lines, orchestration only
102
+ lib/
103
+ daemon/
104
+ notifications.sh # ~170 lines
105
+ sync.sh # ~80 lines
106
+ state.sh # ~120 lines
107
+ routing.sh # ~50 lines
108
+ display.sh # ~120 lines
109
+ ```
110
+
111
+ ## Acceptance Criteria
112
+
113
+ - [ ] `forge-daemon.sh` is under 200 lines
114
+ - [ ] All 5 modules exist in `bin/lib/daemon/`
115
+ - [ ] Each module has proper header and double-source protection
116
+ - [ ] Source order is correct (dependencies before dependents)
117
+ - [ ] Daemon starts, stops, and reports status correctly
118
+ - [ ] Task routing works (completed -> review)
119
+ - [ ] Notifications appear in log
120
+ - [ ] State file updates correctly
121
+ - [ ] Worker status displays (if status files exist)
122
+ - [ ] All existing tests pass
123
+ - [ ] ShellCheck passes on all files
124
+ - [ ] docs/architecture.md updated to reflect new structure