@izkac/forgekit 0.3.11 → 0.3.13

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 (116) hide show
  1. package/bin/forge.mjs +107 -107
  2. package/bin/forgekit.mjs +83 -83
  3. package/bin/review.mjs +81 -81
  4. package/package.json +1 -1
  5. package/scripts/prepack.mjs +78 -78
  6. package/scripts/run-tests.mjs +50 -50
  7. package/src/adr.mjs +236 -236
  8. package/src/adr.test.mjs +170 -170
  9. package/src/change.mjs +327 -234
  10. package/src/change.test.mjs +145 -83
  11. package/src/cleanup-sessions.mjs +84 -84
  12. package/src/config.mjs +103 -103
  13. package/src/defer.mjs +75 -75
  14. package/src/doctor.mjs +350 -341
  15. package/src/doctor.test.mjs +114 -114
  16. package/src/init.mjs +680 -621
  17. package/src/install.mjs +815 -815
  18. package/src/install.test.mjs +180 -180
  19. package/src/integrity-check.mjs +60 -60
  20. package/src/integrity.mjs +682 -682
  21. package/src/integrity.test.mjs +566 -566
  22. package/src/lib.mjs +143 -143
  23. package/src/models.defaults.json +41 -41
  24. package/src/new-session.mjs +99 -99
  25. package/src/openspec-overlays/README.md +19 -19
  26. package/src/openspec-overlays/openspec-apply-change-footer.md +14 -14
  27. package/src/openspec-overlays/opsx-apply-completion-step.md +1 -1
  28. package/src/openspec-overlays/opsx-apply-implement-step.md +11 -11
  29. package/src/paths.mjs +92 -92
  30. package/src/plan-engine.mjs +321 -278
  31. package/src/plan-engine.test.mjs +447 -283
  32. package/src/preferences.defaults.json +78 -78
  33. package/src/preferences.mjs +438 -438
  34. package/src/preferences.test.mjs +174 -174
  35. package/src/record-evidence.mjs +204 -204
  36. package/src/resolve-model.mjs +312 -312
  37. package/src/resolve-model.test.mjs +194 -194
  38. package/src/review/cli.test.mjs +117 -117
  39. package/src/review/export.mjs +172 -172
  40. package/src/review/export.test.mjs +197 -197
  41. package/src/review/fixtures/valid-review.json +42 -42
  42. package/src/review/lib.mjs +894 -894
  43. package/src/review/lib.test.mjs +266 -266
  44. package/src/review/schema.json +196 -196
  45. package/src/review/signals.test.mjs +62 -62
  46. package/src/score-cli.mjs +68 -68
  47. package/src/score.mjs +568 -566
  48. package/src/score.test.mjs +366 -340
  49. package/src/session-reminder.mjs +207 -207
  50. package/src/session-status.mjs +70 -70
  51. package/src/set-models.mjs +186 -186
  52. package/src/set-phase.mjs +205 -205
  53. package/src/set-prefs.mjs +294 -294
  54. package/src/specs-sync.mjs +234 -0
  55. package/src/specs-sync.test.mjs +114 -0
  56. package/src/spine.mjs +93 -93
  57. package/src/triage-prompt.mjs +175 -175
  58. package/src/triage-prompt.test.mjs +50 -50
  59. package/src/vendor-openspec-overlays.mjs +176 -176
  60. package/src/vendor-openspec-overlays.test.mjs +62 -62
  61. package/vendor/skills/archive-to-adr/SKILL.md +149 -149
  62. package/vendor/skills/forge/SKILL.md +136 -136
  63. package/vendor/skills/forge/docs/forge.md +650 -647
  64. package/vendor/skills/forge/phases/brainstorm.md +23 -23
  65. package/vendor/skills/forge/phases/finish.md +90 -87
  66. package/vendor/skills/forge/phases/implement.md +77 -77
  67. package/vendor/skills/forge/phases/plan-openspec.md +60 -60
  68. package/vendor/skills/forge/phases/plan-specs.md +163 -117
  69. package/vendor/skills/forge/phases/review.md +25 -25
  70. package/vendor/skills/forge/phases/verify.md +124 -124
  71. package/vendor/skills/forge/references/forge-layout.md +85 -85
  72. package/vendor/skills/forge/references/pace.md +115 -115
  73. package/vendor/skills/forge/references/plan-routing.md +52 -51
  74. package/vendor/skills/forge/references/runtime-integrity.md +232 -225
  75. package/vendor/skills/forge/references/substantial-work.md +37 -37
  76. package/vendor/skills/forge/references/test-evidence.md +30 -30
  77. package/vendor/skills/forge/references/test-strategy.md +68 -68
  78. package/vendor/skills/forge/skills/subagent-driven-development/SKILL.md +87 -87
  79. package/vendor/skills/forge/subagents/final-reviewer-prompt.md +56 -56
  80. package/vendor/skills/forge/subagents/implementer-prompt.md +38 -38
  81. package/vendor/skills/git-resolve-adr-conflict/SKILL.md +132 -132
  82. package/vendor/skills/thorough-code-review/SKILL.md +290 -290
  83. package/vendor/skills/thorough-code-review/examples.md +133 -133
  84. package/vendor/skills/thorough-code-review/reference/accepted-risks.md +26 -26
  85. package/vendor/skills/thorough-code-review/reference/lenses.md +96 -96
  86. package/vendor/skills/thorough-code-review/reference/phase1-scout.md +62 -62
  87. package/vendor/skills/thorough-code-review/reference/phase2-skeptic.md +105 -105
  88. package/vendor/skills/thorough-code-review/reference/report-schema.json +222 -222
  89. package/vendor/skills/thorough-code-review/reference/report-template.md +115 -115
  90. package/vendor/skills/thorough-code-review/reference/severity-rubric.md +49 -49
  91. package/vendor/skills/thorough-code-review/reference/signals-preflight.md +55 -55
  92. package/vendor/templates/adr/README.md +7 -7
  93. package/vendor/templates/adr/decisions.md +141 -141
  94. package/vendor/templates/adr/hooks/check-pending-adrs.mjs +74 -74
  95. package/vendor/templates/adr/hooks/check-pending-adrs.sh +3 -3
  96. package/vendor/templates/adr/hooks/openspec-archive-agent-message.mjs +52 -52
  97. package/vendor/templates/adr/hooks/openspec-archive-agent-message.sh +3 -3
  98. package/vendor/templates/project/claude/commands/forge-apply.md +75 -75
  99. package/vendor/templates/project/claude/commands/forge-brainstorm.md +7 -7
  100. package/vendor/templates/project/claude/commands/forge-build.md +17 -17
  101. package/vendor/templates/project/claude/commands/forge-plan.md +12 -12
  102. package/vendor/templates/project/claude/commands/forge-skip.md +14 -14
  103. package/vendor/templates/project/claude/commands/forge-status.md +16 -16
  104. package/vendor/templates/project/claude/commands/forge.md +16 -16
  105. package/vendor/templates/project/claude/hooks/forge-prompt-hook.mjs +73 -73
  106. package/vendor/templates/project/claude/hooks/forge-session-start.mjs +19 -19
  107. package/vendor/templates/project/claude/hooks/forge-triage-hook.mjs +77 -77
  108. package/vendor/templates/project/cursor/commands/forge-apply.md +75 -75
  109. package/vendor/templates/project/cursor/commands/forge-brainstorm.md +10 -10
  110. package/vendor/templates/project/cursor/commands/forge-build.md +17 -17
  111. package/vendor/templates/project/cursor/commands/forge-plan.md +15 -15
  112. package/vendor/templates/project/cursor/commands/forge-skip.md +14 -14
  113. package/vendor/templates/project/cursor/commands/forge-status.md +16 -16
  114. package/vendor/templates/project/cursor/commands/forge.md +16 -16
  115. package/vendor/templates/project/cursor/hooks/forge-session-start.mjs +30 -30
  116. package/vendor/templates/project/cursor/hooks/forge-session-start.sh +3 -3
@@ -1,207 +1,207 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Build Forge session reminders for agent hooks.
4
- *
5
- * Usage:
6
- * forge reminder --format cursor
7
- * forge reminder --format claude-session-start
8
- * forge reminder --format plain
9
- */
10
-
11
- import { FORGE_DIR, loadSession, readActive, REPO_ROOT } from './lib.mjs';
12
- import {
13
- drainInbox,
14
- liveOverlaps,
15
- queueMessage,
16
- sessionDirFor,
17
- touchSession,
18
- } from './lib/fleet.mjs';
19
- import { resolveEffectivePreferences } from './preferences.mjs';
20
-
21
- function getActiveSessionInfo() {
22
- const active = readActive();
23
- if (!active?.sessionId) return null;
24
- try {
25
- const { dir, session } = loadSession(active.sessionId);
26
- return { active, dir, session };
27
- } catch {
28
- return null;
29
- }
30
- }
31
-
32
- /**
33
- * @param {Record<string, unknown>} session
34
- */
35
- export function formatPaceLine(session) {
36
- try {
37
- const eff = resolveEffectivePreferences({
38
- forgeDir: FORGE_DIR,
39
- session,
40
- signalText:
41
- (typeof session.paceSignal === 'string' && session.paceSignal) ||
42
- (typeof session.slug === 'string' && session.slug) ||
43
- '',
44
- });
45
- const requested = eff.requestedPace;
46
- const resolved = eff.resolvedPace;
47
- if (requested === 'auto') {
48
- return `Pace: auto → ${resolved} (${eff.paceReason})`;
49
- }
50
- return `Pace: ${resolved}`;
51
- } catch {
52
- const requested = session.pace ?? 'auto';
53
- const resolved = session.resolvedPace;
54
- if (resolved) return `Pace: ${requested} → ${resolved}`;
55
- return `Pace: ${requested}`;
56
- }
57
- }
58
-
59
- export const OPENSPEC_PLAN_REMINDER =
60
- 'Planning: Forge always uses OpenSpec. After brainstorm approval, run /opsx:propose (openspec-propose). Do not ask for a plan mode. See forge references/plan-routing.md.';
61
-
62
- /** @deprecated use OPENSPEC_PLAN_REMINDER */
63
- export const PLAN_MODE_PROMPT_REMINDER = OPENSPEC_PLAN_REMINDER;
64
-
65
- export function needsOpenSpecPlan(session) {
66
- return (
67
- !session.planType &&
68
- (session.phase === 'brainstorm' || session.phase === 'plan')
69
- );
70
- }
71
-
72
- /** @deprecated use needsOpenSpecPlan */
73
- export const needsPlanModePrompt = needsOpenSpecPlan;
74
-
75
- export const RUNTIME_INTEGRITY_REMINDER =
76
- 'Integrity: spine.json mandatory every change (rows or notApplicable); no stubs/false success; specs beat task wording; product-loop when spine has rows; defer wiring only via `forge defer` — `forge phase done` runs `forge integrity-check` (forge references/runtime-integrity.md).';
77
-
78
- export function buildForgeMessage(info) {
79
- const { session } = info;
80
- const lines = [];
81
- lines.push(`[forge] Active Forge session: ${session.id}`);
82
- lines.push(
83
- `Phase: ${session.phase} | Plan: ${session.planType ?? 'pending'}${
84
- session.openspecChange ? ` (${session.openspecChange})` : ''
85
- }`,
86
- );
87
- lines.push(formatPaceLine(session));
88
- if (session.tasksTotal > 0) {
89
- lines.push(`Tasks: ${session.tasksComplete}/${session.tasksTotal}`);
90
- }
91
- if (needsOpenSpecPlan(session)) {
92
- lines.push(OPENSPEC_PLAN_REMINDER);
93
- }
94
- lines.push(RUNTIME_INTEGRITY_REMINDER);
95
- lines.push('Resume: invoke the forge skill for the current phase.');
96
- lines.push('Honor pace: see forge references/pace.md (`forge prefs`).');
97
- lines.push('Skip Forge for this task only: /forge:skip');
98
- lines.push('Guide: Forge skill + docs/forge.md (under the installed forge skill)');
99
- return lines.join('\n');
100
- }
101
-
102
- export function buildForgePromptMessage(info, prompt) {
103
- const base = buildForgeMessage(info);
104
- const trimmed = (prompt || '').trim();
105
- if (/^\/forge:skip\b/i.test(trimmed)) {
106
- return `${base}\n\nUser invoked /forge:skip — execute directly; do not start brainstorm/plan.`;
107
- }
108
- if (/^\/forge:status\b/i.test(trimmed)) {
109
- return `${base}\n\nRun: forge status — then summarize for the user.`;
110
- }
111
- if (/^\/forge:plan\b/i.test(trimmed)) {
112
- return `${base}\n\nPlan phase: ${OPENSPEC_PLAN_REMINDER}`;
113
- }
114
- if (/^\/forge:brainstorm\b/i.test(trimmed)) {
115
- return `${base}\n\nBrainstorm terminal state: proceed to OpenSpec propose — do not implement until artefacts are approved.`;
116
- }
117
- return `${base}\n\nUser invoked Forge — follow forge skill from phase "${info.session.phase}".`;
118
- }
119
-
120
- function emitCursor(message) {
121
- const payload = JSON.stringify({ agent_message: message });
122
- process.stdout.write(`${payload}\n`);
123
- }
124
-
125
- function emitClaudeSessionStart(message) {
126
- const payload = {
127
- hookSpecificOutput: {
128
- hookEventName: 'SessionStart',
129
- additionalContext: `<system-reminder>\n${message}\n</system-reminder>`,
130
- },
131
- };
132
- process.stdout.write(`${JSON.stringify(payload)}\n`);
133
- }
134
-
135
- function emitPlain(message) {
136
- process.stdout.write(`${message}\n`);
137
- }
138
-
139
- const args = process.argv.slice(2);
140
- let format = 'plain';
141
- let prompt = '';
142
-
143
- for (let i = 0; i < args.length; i += 1) {
144
- if (args[i] === '--format' && args[i + 1]) {
145
- format = args[i + 1];
146
- i += 1;
147
- } else if (args[i] === '--prompt' && args[i + 1]) {
148
- prompt = args[i + 1];
149
- i += 1;
150
- }
151
- }
152
-
153
- const info = getActiveSessionInfo();
154
- if (!info) {
155
- process.exit(0);
156
- }
157
-
158
- // Fleet heartbeat: this hook fires on every agent turn, so lastSeen in the
159
- // registry tracks "agent actually running", not just the last saveSession.
160
- touchSession(REPO_ROOT, info.session.id);
161
-
162
- let message = prompt
163
- ? buildForgePromptMessage(info, prompt)
164
- : buildForgeMessage(info);
165
-
166
- // Overlap check on resume: another live session in this same working tree
167
- // means potentially conflicting edits. Warn this agent and drop a note in the
168
- // other sessions' inboxes. Session-start only — per-turn would spam.
169
- if (format === 'claude-session-start') {
170
- const overlaps = liveOverlaps(REPO_ROOT, info.session.id);
171
- if (overlaps.length > 0) {
172
- message += `\n\nFleet overlap — other live session(s) in this project:\n${overlaps
173
- .map((o) => `- ${o.slug} (${o.sessionId}) · ${o.engine ?? 'unknown'} · phase ${o.phase}`)
174
- .join('\n')}\nTell the user and ask how to proceed: continue anyway, move this work to a git worktree, or pause one session.`;
175
- for (const o of overlaps) {
176
- queueMessage(
177
- sessionDirFor(o),
178
- `Fleet overlap: session "${info.session.slug}" (${info.session.id}) just resumed in this project. Coordinate with the user to avoid conflicting edits.`,
179
- );
180
- }
181
- }
182
- }
183
-
184
- // Deliver queued `forge fleet send` messages exactly once (drain moves them
185
- // to inbox/delivered/). This is the fleet command bus: control terminal →
186
- // inbox file → injected into the agent's next turn via this hook.
187
- const fleetMessages = drainInbox(info.dir);
188
- if (fleetMessages.length > 0) {
189
- message += `\n\nFleet messages from the control terminal — acknowledge and act on these first:\n${fleetMessages
190
- .map((m) => `- ${m.text}`)
191
- .join('\n')}`;
192
- }
193
-
194
- switch (format) {
195
- case 'cursor':
196
- emitCursor(message);
197
- break;
198
- case 'claude-session-start':
199
- emitClaudeSessionStart(message);
200
- break;
201
- case 'plain':
202
- emitPlain(message);
203
- break;
204
- default:
205
- process.stderr.write(`Unknown format: ${format}\n`);
206
- process.exit(1);
207
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Build Forge session reminders for agent hooks.
4
+ *
5
+ * Usage:
6
+ * forge reminder --format cursor
7
+ * forge reminder --format claude-session-start
8
+ * forge reminder --format plain
9
+ */
10
+
11
+ import { FORGE_DIR, loadSession, readActive, REPO_ROOT } from './lib.mjs';
12
+ import {
13
+ drainInbox,
14
+ liveOverlaps,
15
+ queueMessage,
16
+ sessionDirFor,
17
+ touchSession,
18
+ } from './lib/fleet.mjs';
19
+ import { resolveEffectivePreferences } from './preferences.mjs';
20
+
21
+ function getActiveSessionInfo() {
22
+ const active = readActive();
23
+ if (!active?.sessionId) return null;
24
+ try {
25
+ const { dir, session } = loadSession(active.sessionId);
26
+ return { active, dir, session };
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @param {Record<string, unknown>} session
34
+ */
35
+ export function formatPaceLine(session) {
36
+ try {
37
+ const eff = resolveEffectivePreferences({
38
+ forgeDir: FORGE_DIR,
39
+ session,
40
+ signalText:
41
+ (typeof session.paceSignal === 'string' && session.paceSignal) ||
42
+ (typeof session.slug === 'string' && session.slug) ||
43
+ '',
44
+ });
45
+ const requested = eff.requestedPace;
46
+ const resolved = eff.resolvedPace;
47
+ if (requested === 'auto') {
48
+ return `Pace: auto → ${resolved} (${eff.paceReason})`;
49
+ }
50
+ return `Pace: ${resolved}`;
51
+ } catch {
52
+ const requested = session.pace ?? 'auto';
53
+ const resolved = session.resolvedPace;
54
+ if (resolved) return `Pace: ${requested} → ${resolved}`;
55
+ return `Pace: ${requested}`;
56
+ }
57
+ }
58
+
59
+ export const OPENSPEC_PLAN_REMINDER =
60
+ 'Planning: Forge always uses OpenSpec. After brainstorm approval, run /opsx:propose (openspec-propose). Do not ask for a plan mode. See forge references/plan-routing.md.';
61
+
62
+ /** @deprecated use OPENSPEC_PLAN_REMINDER */
63
+ export const PLAN_MODE_PROMPT_REMINDER = OPENSPEC_PLAN_REMINDER;
64
+
65
+ export function needsOpenSpecPlan(session) {
66
+ return (
67
+ !session.planType &&
68
+ (session.phase === 'brainstorm' || session.phase === 'plan')
69
+ );
70
+ }
71
+
72
+ /** @deprecated use needsOpenSpecPlan */
73
+ export const needsPlanModePrompt = needsOpenSpecPlan;
74
+
75
+ export const RUNTIME_INTEGRITY_REMINDER =
76
+ 'Integrity: spine.json mandatory every change (rows or notApplicable); no stubs/false success; specs beat task wording; product-loop when spine has rows; defer wiring only via `forge defer` — `forge phase done` runs `forge integrity-check` (forge references/runtime-integrity.md).';
77
+
78
+ export function buildForgeMessage(info) {
79
+ const { session } = info;
80
+ const lines = [];
81
+ lines.push(`[forge] Active Forge session: ${session.id}`);
82
+ lines.push(
83
+ `Phase: ${session.phase} | Plan: ${session.planType ?? 'pending'}${
84
+ session.openspecChange ? ` (${session.openspecChange})` : ''
85
+ }`,
86
+ );
87
+ lines.push(formatPaceLine(session));
88
+ if (session.tasksTotal > 0) {
89
+ lines.push(`Tasks: ${session.tasksComplete}/${session.tasksTotal}`);
90
+ }
91
+ if (needsOpenSpecPlan(session)) {
92
+ lines.push(OPENSPEC_PLAN_REMINDER);
93
+ }
94
+ lines.push(RUNTIME_INTEGRITY_REMINDER);
95
+ lines.push('Resume: invoke the forge skill for the current phase.');
96
+ lines.push('Honor pace: see forge references/pace.md (`forge prefs`).');
97
+ lines.push('Skip Forge for this task only: /forge:skip');
98
+ lines.push('Guide: Forge skill + docs/forge.md (under the installed forge skill)');
99
+ return lines.join('\n');
100
+ }
101
+
102
+ export function buildForgePromptMessage(info, prompt) {
103
+ const base = buildForgeMessage(info);
104
+ const trimmed = (prompt || '').trim();
105
+ if (/^\/forge:skip\b/i.test(trimmed)) {
106
+ return `${base}\n\nUser invoked /forge:skip — execute directly; do not start brainstorm/plan.`;
107
+ }
108
+ if (/^\/forge:status\b/i.test(trimmed)) {
109
+ return `${base}\n\nRun: forge status — then summarize for the user.`;
110
+ }
111
+ if (/^\/forge:plan\b/i.test(trimmed)) {
112
+ return `${base}\n\nPlan phase: ${OPENSPEC_PLAN_REMINDER}`;
113
+ }
114
+ if (/^\/forge:brainstorm\b/i.test(trimmed)) {
115
+ return `${base}\n\nBrainstorm terminal state: proceed to OpenSpec propose — do not implement until artefacts are approved.`;
116
+ }
117
+ return `${base}\n\nUser invoked Forge — follow forge skill from phase "${info.session.phase}".`;
118
+ }
119
+
120
+ function emitCursor(message) {
121
+ const payload = JSON.stringify({ agent_message: message });
122
+ process.stdout.write(`${payload}\n`);
123
+ }
124
+
125
+ function emitClaudeSessionStart(message) {
126
+ const payload = {
127
+ hookSpecificOutput: {
128
+ hookEventName: 'SessionStart',
129
+ additionalContext: `<system-reminder>\n${message}\n</system-reminder>`,
130
+ },
131
+ };
132
+ process.stdout.write(`${JSON.stringify(payload)}\n`);
133
+ }
134
+
135
+ function emitPlain(message) {
136
+ process.stdout.write(`${message}\n`);
137
+ }
138
+
139
+ const args = process.argv.slice(2);
140
+ let format = 'plain';
141
+ let prompt = '';
142
+
143
+ for (let i = 0; i < args.length; i += 1) {
144
+ if (args[i] === '--format' && args[i + 1]) {
145
+ format = args[i + 1];
146
+ i += 1;
147
+ } else if (args[i] === '--prompt' && args[i + 1]) {
148
+ prompt = args[i + 1];
149
+ i += 1;
150
+ }
151
+ }
152
+
153
+ const info = getActiveSessionInfo();
154
+ if (!info) {
155
+ process.exit(0);
156
+ }
157
+
158
+ // Fleet heartbeat: this hook fires on every agent turn, so lastSeen in the
159
+ // registry tracks "agent actually running", not just the last saveSession.
160
+ touchSession(REPO_ROOT, info.session.id);
161
+
162
+ let message = prompt
163
+ ? buildForgePromptMessage(info, prompt)
164
+ : buildForgeMessage(info);
165
+
166
+ // Overlap check on resume: another live session in this same working tree
167
+ // means potentially conflicting edits. Warn this agent and drop a note in the
168
+ // other sessions' inboxes. Session-start only — per-turn would spam.
169
+ if (format === 'claude-session-start') {
170
+ const overlaps = liveOverlaps(REPO_ROOT, info.session.id);
171
+ if (overlaps.length > 0) {
172
+ message += `\n\nFleet overlap — other live session(s) in this project:\n${overlaps
173
+ .map((o) => `- ${o.slug} (${o.sessionId}) · ${o.engine ?? 'unknown'} · phase ${o.phase}`)
174
+ .join('\n')}\nTell the user and ask how to proceed: continue anyway, move this work to a git worktree, or pause one session.`;
175
+ for (const o of overlaps) {
176
+ queueMessage(
177
+ sessionDirFor(o),
178
+ `Fleet overlap: session "${info.session.slug}" (${info.session.id}) just resumed in this project. Coordinate with the user to avoid conflicting edits.`,
179
+ );
180
+ }
181
+ }
182
+ }
183
+
184
+ // Deliver queued `forge fleet send` messages exactly once (drain moves them
185
+ // to inbox/delivered/). This is the fleet command bus: control terminal →
186
+ // inbox file → injected into the agent's next turn via this hook.
187
+ const fleetMessages = drainInbox(info.dir);
188
+ if (fleetMessages.length > 0) {
189
+ message += `\n\nFleet messages from the control terminal — acknowledge and act on these first:\n${fleetMessages
190
+ .map((m) => `- ${m.text}`)
191
+ .join('\n')}`;
192
+ }
193
+
194
+ switch (format) {
195
+ case 'cursor':
196
+ emitCursor(message);
197
+ break;
198
+ case 'claude-session-start':
199
+ emitClaudeSessionStart(message);
200
+ break;
201
+ case 'plain':
202
+ emitPlain(message);
203
+ break;
204
+ default:
205
+ process.stderr.write(`Unknown format: ${format}\n`);
206
+ process.exit(1);
207
+ }
@@ -1,70 +1,70 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Print the active Forge session or a specific session by id.
4
- *
5
- * Usage:
6
- * forge status
7
- * forge status [--session <id>]
8
- */
9
-
10
- import fs from 'node:fs';
11
- import path from 'node:path';
12
- import {
13
- FORGE_DIR,
14
- loadSession,
15
- readActive,
16
- REPO_ROOT,
17
- } from './lib.mjs';
18
- import { resolveEffectivePreferences } from './preferences.mjs';
19
-
20
- const args = process.argv.slice(2);
21
- let sessionId = null;
22
- for (let i = 0; i < args.length; i += 1) {
23
- if (args[i] === '--session' && args[i + 1]) {
24
- sessionId = args[i + 1];
25
- i += 1;
26
- }
27
- }
28
-
29
- if (!sessionId) {
30
- const active = readActive();
31
- if (!active?.sessionId) {
32
- process.stdout.write(JSON.stringify({ status: 'none', message: 'No active Forge session.' }, null, 2));
33
- process.stdout.write('\n');
34
- process.exit(0);
35
- }
36
- sessionId = active.sessionId;
37
- }
38
-
39
- const { dir, session } = loadSession(sessionId);
40
- const statusPath = path.join(dir, 'status.json');
41
- const status = fs.existsSync(statusPath) ? JSON.parse(fs.readFileSync(statusPath, 'utf8')) : null;
42
-
43
- const pace = resolveEffectivePreferences({
44
- forgeDir: FORGE_DIR,
45
- session,
46
- signalText: session.paceSignal || session.slug || '',
47
- });
48
-
49
- process.stdout.write(
50
- JSON.stringify(
51
- {
52
- status: 'ok',
53
- sessionId,
54
- sessionPath: path.relative(REPO_ROOT, dir).replace(/\\/g, '/'),
55
- session,
56
- progress: status,
57
- pace: {
58
- requested: pace.requestedPace,
59
- resolved: pace.resolvedPace,
60
- reason: pace.paceReason,
61
- source: pace.source,
62
- effective: pace.effective,
63
- },
64
- integrity: pace.integrity,
65
- },
66
- null,
67
- 2,
68
- ),
69
- );
70
- process.stdout.write('\n');
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Print the active Forge session or a specific session by id.
4
+ *
5
+ * Usage:
6
+ * forge status
7
+ * forge status [--session <id>]
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import {
13
+ FORGE_DIR,
14
+ loadSession,
15
+ readActive,
16
+ REPO_ROOT,
17
+ } from './lib.mjs';
18
+ import { resolveEffectivePreferences } from './preferences.mjs';
19
+
20
+ const args = process.argv.slice(2);
21
+ let sessionId = null;
22
+ for (let i = 0; i < args.length; i += 1) {
23
+ if (args[i] === '--session' && args[i + 1]) {
24
+ sessionId = args[i + 1];
25
+ i += 1;
26
+ }
27
+ }
28
+
29
+ if (!sessionId) {
30
+ const active = readActive();
31
+ if (!active?.sessionId) {
32
+ process.stdout.write(JSON.stringify({ status: 'none', message: 'No active Forge session.' }, null, 2));
33
+ process.stdout.write('\n');
34
+ process.exit(0);
35
+ }
36
+ sessionId = active.sessionId;
37
+ }
38
+
39
+ const { dir, session } = loadSession(sessionId);
40
+ const statusPath = path.join(dir, 'status.json');
41
+ const status = fs.existsSync(statusPath) ? JSON.parse(fs.readFileSync(statusPath, 'utf8')) : null;
42
+
43
+ const pace = resolveEffectivePreferences({
44
+ forgeDir: FORGE_DIR,
45
+ session,
46
+ signalText: session.paceSignal || session.slug || '',
47
+ });
48
+
49
+ process.stdout.write(
50
+ JSON.stringify(
51
+ {
52
+ status: 'ok',
53
+ sessionId,
54
+ sessionPath: path.relative(REPO_ROOT, dir).replace(/\\/g, '/'),
55
+ session,
56
+ progress: status,
57
+ pace: {
58
+ requested: pace.requestedPace,
59
+ resolved: pace.resolvedPace,
60
+ reason: pace.paceReason,
61
+ source: pace.source,
62
+ effective: pace.effective,
63
+ },
64
+ integrity: pace.integrity,
65
+ },
66
+ null,
67
+ 2,
68
+ ),
69
+ );
70
+ process.stdout.write('\n');