@izkac/forgekit 0.3.12 → 0.3.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.
Files changed (120) hide show
  1. package/bin/forge.mjs +119 -107
  2. package/bin/forgekit.mjs +83 -83
  3. package/bin/review.mjs +81 -81
  4. package/package.json +2 -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/fleet.test.mjs +50 -0
  17. package/src/init.mjs +680 -621
  18. package/src/install.mjs +815 -815
  19. package/src/install.test.mjs +180 -180
  20. package/src/integrity-check.mjs +60 -60
  21. package/src/integrity.mjs +688 -682
  22. package/src/integrity.test.mjs +612 -566
  23. package/src/lib/fleet.mjs +61 -4
  24. package/src/lib.mjs +160 -143
  25. package/src/lib.test.mjs +128 -0
  26. package/src/models.defaults.json +41 -41
  27. package/src/new-session.mjs +99 -99
  28. package/src/openspec-overlays/README.md +19 -19
  29. package/src/openspec-overlays/openspec-apply-change-footer.md +14 -14
  30. package/src/openspec-overlays/opsx-apply-completion-step.md +1 -1
  31. package/src/openspec-overlays/opsx-apply-implement-step.md +11 -11
  32. package/src/paths.mjs +92 -92
  33. package/src/plan-engine.mjs +321 -278
  34. package/src/plan-engine.test.mjs +447 -283
  35. package/src/preferences.defaults.json +78 -78
  36. package/src/preferences.mjs +438 -438
  37. package/src/preferences.test.mjs +174 -174
  38. package/src/record-evidence.mjs +204 -204
  39. package/src/repo-root.mjs +33 -0
  40. package/src/resolve-model.mjs +312 -312
  41. package/src/resolve-model.test.mjs +194 -194
  42. package/src/review/cli.test.mjs +117 -117
  43. package/src/review/export.mjs +172 -172
  44. package/src/review/export.test.mjs +197 -197
  45. package/src/review/fixtures/valid-review.json +42 -42
  46. package/src/review/lib.mjs +894 -894
  47. package/src/review/lib.test.mjs +266 -266
  48. package/src/review/schema.json +196 -196
  49. package/src/review/signals.test.mjs +62 -62
  50. package/src/score-cli.mjs +68 -68
  51. package/src/score.mjs +568 -568
  52. package/src/score.test.mjs +366 -366
  53. package/src/session-reminder.mjs +207 -207
  54. package/src/session-status.mjs +70 -70
  55. package/src/set-models.mjs +186 -186
  56. package/src/set-phase.mjs +205 -205
  57. package/src/set-prefs.mjs +294 -294
  58. package/src/specs-sync.mjs +232 -0
  59. package/src/specs-sync.test.mjs +114 -0
  60. package/src/spine.mjs +93 -93
  61. package/src/triage-prompt.mjs +175 -175
  62. package/src/triage-prompt.test.mjs +50 -50
  63. package/src/vendor-openspec-overlays.mjs +176 -176
  64. package/src/vendor-openspec-overlays.test.mjs +62 -62
  65. package/vendor/skills/archive-to-adr/SKILL.md +149 -149
  66. package/vendor/skills/forge/SKILL.md +136 -136
  67. package/vendor/skills/forge/docs/forge.md +650 -647
  68. package/vendor/skills/forge/phases/brainstorm.md +23 -23
  69. package/vendor/skills/forge/phases/finish.md +90 -87
  70. package/vendor/skills/forge/phases/implement.md +77 -77
  71. package/vendor/skills/forge/phases/plan-openspec.md +60 -60
  72. package/vendor/skills/forge/phases/plan-specs.md +163 -117
  73. package/vendor/skills/forge/phases/review.md +25 -25
  74. package/vendor/skills/forge/phases/verify.md +124 -124
  75. package/vendor/skills/forge/references/forge-layout.md +85 -85
  76. package/vendor/skills/forge/references/pace.md +115 -115
  77. package/vendor/skills/forge/references/plan-routing.md +52 -51
  78. package/vendor/skills/forge/references/runtime-integrity.md +232 -232
  79. package/vendor/skills/forge/references/substantial-work.md +37 -37
  80. package/vendor/skills/forge/references/test-evidence.md +30 -30
  81. package/vendor/skills/forge/references/test-strategy.md +68 -68
  82. package/vendor/skills/forge/skills/subagent-driven-development/SKILL.md +87 -87
  83. package/vendor/skills/forge/subagents/final-reviewer-prompt.md +56 -56
  84. package/vendor/skills/forge/subagents/implementer-prompt.md +38 -38
  85. package/vendor/skills/git-resolve-adr-conflict/SKILL.md +132 -132
  86. package/vendor/skills/thorough-code-review/SKILL.md +290 -290
  87. package/vendor/skills/thorough-code-review/examples.md +133 -133
  88. package/vendor/skills/thorough-code-review/reference/accepted-risks.md +26 -26
  89. package/vendor/skills/thorough-code-review/reference/lenses.md +96 -96
  90. package/vendor/skills/thorough-code-review/reference/phase1-scout.md +62 -62
  91. package/vendor/skills/thorough-code-review/reference/phase2-skeptic.md +105 -105
  92. package/vendor/skills/thorough-code-review/reference/report-schema.json +222 -222
  93. package/vendor/skills/thorough-code-review/reference/report-template.md +115 -115
  94. package/vendor/skills/thorough-code-review/reference/severity-rubric.md +49 -49
  95. package/vendor/skills/thorough-code-review/reference/signals-preflight.md +55 -55
  96. package/vendor/templates/adr/README.md +7 -7
  97. package/vendor/templates/adr/decisions.md +141 -141
  98. package/vendor/templates/adr/hooks/check-pending-adrs.mjs +74 -74
  99. package/vendor/templates/adr/hooks/check-pending-adrs.sh +3 -3
  100. package/vendor/templates/adr/hooks/openspec-archive-agent-message.mjs +52 -52
  101. package/vendor/templates/adr/hooks/openspec-archive-agent-message.sh +3 -3
  102. package/vendor/templates/project/claude/commands/forge-apply.md +75 -75
  103. package/vendor/templates/project/claude/commands/forge-brainstorm.md +7 -7
  104. package/vendor/templates/project/claude/commands/forge-build.md +17 -17
  105. package/vendor/templates/project/claude/commands/forge-plan.md +12 -12
  106. package/vendor/templates/project/claude/commands/forge-skip.md +14 -14
  107. package/vendor/templates/project/claude/commands/forge-status.md +16 -16
  108. package/vendor/templates/project/claude/commands/forge.md +16 -16
  109. package/vendor/templates/project/claude/hooks/forge-prompt-hook.mjs +73 -73
  110. package/vendor/templates/project/claude/hooks/forge-session-start.mjs +19 -19
  111. package/vendor/templates/project/claude/hooks/forge-triage-hook.mjs +77 -77
  112. package/vendor/templates/project/cursor/commands/forge-apply.md +75 -75
  113. package/vendor/templates/project/cursor/commands/forge-brainstorm.md +10 -10
  114. package/vendor/templates/project/cursor/commands/forge-build.md +17 -17
  115. package/vendor/templates/project/cursor/commands/forge-plan.md +15 -15
  116. package/vendor/templates/project/cursor/commands/forge-skip.md +14 -14
  117. package/vendor/templates/project/cursor/commands/forge-status.md +16 -16
  118. package/vendor/templates/project/cursor/commands/forge.md +16 -16
  119. package/vendor/templates/project/cursor/hooks/forge-session-start.mjs +30 -30
  120. package/vendor/templates/project/cursor/hooks/forge-session-start.sh +3 -3
@@ -1,175 +1,175 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Heuristics for Forge auto-triage on agent UserPromptSubmit hooks.
4
- * Mirrors references/substantial-work.md — err toward Forge when unsure.
5
- */
6
-
7
- import path from 'node:path';
8
- import { pathToFileURL } from 'node:url';
9
-
10
- export function isForgeSkip(prompt) {
11
- return /^\s*\/forge:skip\b/i.test((prompt || '').trim());
12
- }
13
-
14
- export function isForgeInvocation(prompt) {
15
- return /^\s*\/forge(?::|\s|$)/i.test((prompt || '').trim());
16
- }
17
-
18
- export function isTrivialEdit(prompt) {
19
- const p = (prompt || '').trim();
20
- if (!p) return true;
21
- return (
22
- /\b(typo|formatting only|whitespace only|comment only|rename only|no behavior change|zero behavior)\b/i.test(p)
23
- || /^\s*fix(ed)?\s+(a|the)?\s*typo\b/i.test(p)
24
- );
25
- }
26
-
27
- export function isReadOnlyQuestion(prompt) {
28
- const p = (prompt || '').trim();
29
- if (!p) return true;
30
-
31
- const implementVerb =
32
- /\b(add|build|implement|create|fix|update|wire|integrate|migrate|refactor|change|modify|delete|remove|make|enable|support|debug|investigate)\b/i;
33
- const diagnosticFix =
34
- /\b(doesn'?t|does not|isn'?t|not)\s+(seem to|work|fire|load|trigger|run)\b/i.test(p)
35
- || /\b(wired correctly|not wired|broken wiring|misconfigured)\b/i.test(p);
36
-
37
- if (diagnosticFix) return false;
38
-
39
- const questionLead =
40
- /^(what|how does|how do|why|where|when|who|explain|describe|tell me about|can you explain|is there|are there|does the|do we|show me|list|summarize)\b/i;
41
- if (questionLead.test(p) && !implementVerb.test(p)) return true;
42
-
43
- if (/\?\s*$/.test(p) && !implementVerb.test(p) && !/\b(check if|verify that|audit)\b/i.test(p)) {
44
- return true;
45
- }
46
-
47
- return false;
48
- }
49
-
50
- export function isSubstantialWork(prompt) {
51
- const p = (prompt || '').trim();
52
- if (!p) return false;
53
- if (isForgeSkip(p)) return false;
54
- if (isForgeInvocation(p)) return true;
55
- if (isTrivialEdit(p)) return false;
56
- if (isReadOnlyQuestion(p)) return false;
57
-
58
- const patterns = [
59
- /^\s*(please\s+)?(add|build|create|implement|develop|wire|integrate|migrate|port|enable|support|make|change|modify|update|remove|delete|refactor|fix|debug|investigate|set up|setup)\b/i,
60
- /\b(add|build|implement|create|wire up|hook up)\s+(a|an|the|new)\b/i,
61
- /\b(doesn'?t|does not|isn'?t)\s+(seem to|work|fire|load|trigger|run)\b/i,
62
- /\b(bug|regression|broken|misconfigured|not wired)\b/i,
63
- /\bnew feature\b/i,
64
- /\bcheck if\b.*\b(wired|configured|working|hook)\b/i,
65
- /\b(ensure|make sure)\b.*\b(wired|configured|working|fires?)\b/i,
66
- ];
67
-
68
- return patterns.some((re) => re.test(p));
69
- }
70
-
71
- export function shouldForgeTriage(prompt) {
72
- if (isForgeInvocation(prompt)) return false;
73
- return isSubstantialWork(prompt);
74
- }
75
-
76
- export function buildForgeTriageMessage(options = {}) {
77
- const {
78
- hasActiveSession = false,
79
- skillPath = 'forge skill (SKILL.md)',
80
- sessionLines = [],
81
- } = options;
82
-
83
- const lines = [];
84
- lines.push('[forge] Substantial work detected — triage before implementation.');
85
- lines.push('');
86
- lines.push(`1. Read the Forge skill (\`${skillPath}\`) and follow triage (references/substantial-work.md).`);
87
- if (!hasActiveSession) {
88
- lines.push('2. If entering Forge: `forge new <slug>` then continue the current phase.');
89
- } else if (sessionLines.length > 0) {
90
- lines.push('2. Active session:');
91
- for (const line of sessionLines) lines.push(` ${line}`);
92
- }
93
- lines.push('3. Skip Forge for this task only: `/forge:skip`');
94
- lines.push('Guide: Forge skill + docs/forge.md (under the installed forge skill)');
95
- return lines.join('\n');
96
- }
97
-
98
- /**
99
- * CLI:
100
- * forge triage --check "<prompt>" exit 0 if should triage, else 1
101
- * forge triage --message "<prompt>" print triage reminder (always)
102
- * forge triage --message --has-session "<prompt>"
103
- */
104
- function parseTriageArgs(argv) {
105
- const opts = {
106
- check: false,
107
- message: false,
108
- hasSession: false,
109
- help: false,
110
- prompt: '',
111
- };
112
- const rest = [];
113
- for (let i = 0; i < argv.length; i += 1) {
114
- const arg = argv[i];
115
- if (arg === '--check') opts.check = true;
116
- else if (arg === '--message') opts.message = true;
117
- else if (arg === '--has-session') opts.hasSession = true;
118
- else if (arg === '--help' || arg === '-h') opts.help = true;
119
- else rest.push(arg);
120
- }
121
- opts.prompt = rest.join(' ').trim();
122
- return opts;
123
- }
124
-
125
- function printTriageHelp() {
126
- process.stdout.write(`Usage:
127
- forge triage --check "<prompt>"
128
- forge triage --message [--has-session] "<prompt>"
129
- `);
130
- }
131
-
132
- async function triageMain(argv = process.argv.slice(2)) {
133
- const opts = parseTriageArgs(argv);
134
- if (opts.help || (!opts.check && !opts.message)) {
135
- printTriageHelp();
136
- return opts.help ? 0 : 1;
137
- }
138
-
139
- let prompt = opts.prompt;
140
- if (!prompt && !process.stdin.isTTY) {
141
- prompt = await new Promise((resolve) => {
142
- let data = '';
143
- process.stdin.setEncoding('utf8');
144
- process.stdin.on('data', (c) => {
145
- data += c;
146
- });
147
- process.stdin.on('end', () => resolve(data.trim()));
148
- setTimeout(() => resolve(data.trim()), 1000);
149
- });
150
- }
151
-
152
- if (opts.check) {
153
- return shouldForgeTriage(prompt) ? 0 : 1;
154
- }
155
-
156
- process.stdout.write(
157
- `${buildForgeTriageMessage({
158
- hasActiveSession: opts.hasSession,
159
- sessionLines: [],
160
- })}\n`,
161
- );
162
- return 0;
163
- }
164
-
165
- const isDirect =
166
- process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url;
167
-
168
- if (isDirect) {
169
- triageMain()
170
- .then((code) => process.exit(code))
171
- .catch((err) => {
172
- process.stderr.write(`${err.message || err}\n`);
173
- process.exit(1);
174
- });
175
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Heuristics for Forge auto-triage on agent UserPromptSubmit hooks.
4
+ * Mirrors references/substantial-work.md — err toward Forge when unsure.
5
+ */
6
+
7
+ import path from 'node:path';
8
+ import { pathToFileURL } from 'node:url';
9
+
10
+ export function isForgeSkip(prompt) {
11
+ return /^\s*\/forge:skip\b/i.test((prompt || '').trim());
12
+ }
13
+
14
+ export function isForgeInvocation(prompt) {
15
+ return /^\s*\/forge(?::|\s|$)/i.test((prompt || '').trim());
16
+ }
17
+
18
+ export function isTrivialEdit(prompt) {
19
+ const p = (prompt || '').trim();
20
+ if (!p) return true;
21
+ return (
22
+ /\b(typo|formatting only|whitespace only|comment only|rename only|no behavior change|zero behavior)\b/i.test(p)
23
+ || /^\s*fix(ed)?\s+(a|the)?\s*typo\b/i.test(p)
24
+ );
25
+ }
26
+
27
+ export function isReadOnlyQuestion(prompt) {
28
+ const p = (prompt || '').trim();
29
+ if (!p) return true;
30
+
31
+ const implementVerb =
32
+ /\b(add|build|implement|create|fix|update|wire|integrate|migrate|refactor|change|modify|delete|remove|make|enable|support|debug|investigate)\b/i;
33
+ const diagnosticFix =
34
+ /\b(doesn'?t|does not|isn'?t|not)\s+(seem to|work|fire|load|trigger|run)\b/i.test(p)
35
+ || /\b(wired correctly|not wired|broken wiring|misconfigured)\b/i.test(p);
36
+
37
+ if (diagnosticFix) return false;
38
+
39
+ const questionLead =
40
+ /^(what|how does|how do|why|where|when|who|explain|describe|tell me about|can you explain|is there|are there|does the|do we|show me|list|summarize)\b/i;
41
+ if (questionLead.test(p) && !implementVerb.test(p)) return true;
42
+
43
+ if (/\?\s*$/.test(p) && !implementVerb.test(p) && !/\b(check if|verify that|audit)\b/i.test(p)) {
44
+ return true;
45
+ }
46
+
47
+ return false;
48
+ }
49
+
50
+ export function isSubstantialWork(prompt) {
51
+ const p = (prompt || '').trim();
52
+ if (!p) return false;
53
+ if (isForgeSkip(p)) return false;
54
+ if (isForgeInvocation(p)) return true;
55
+ if (isTrivialEdit(p)) return false;
56
+ if (isReadOnlyQuestion(p)) return false;
57
+
58
+ const patterns = [
59
+ /^\s*(please\s+)?(add|build|create|implement|develop|wire|integrate|migrate|port|enable|support|make|change|modify|update|remove|delete|refactor|fix|debug|investigate|set up|setup)\b/i,
60
+ /\b(add|build|implement|create|wire up|hook up)\s+(a|an|the|new)\b/i,
61
+ /\b(doesn'?t|does not|isn'?t)\s+(seem to|work|fire|load|trigger|run)\b/i,
62
+ /\b(bug|regression|broken|misconfigured|not wired)\b/i,
63
+ /\bnew feature\b/i,
64
+ /\bcheck if\b.*\b(wired|configured|working|hook)\b/i,
65
+ /\b(ensure|make sure)\b.*\b(wired|configured|working|fires?)\b/i,
66
+ ];
67
+
68
+ return patterns.some((re) => re.test(p));
69
+ }
70
+
71
+ export function shouldForgeTriage(prompt) {
72
+ if (isForgeInvocation(prompt)) return false;
73
+ return isSubstantialWork(prompt);
74
+ }
75
+
76
+ export function buildForgeTriageMessage(options = {}) {
77
+ const {
78
+ hasActiveSession = false,
79
+ skillPath = 'forge skill (SKILL.md)',
80
+ sessionLines = [],
81
+ } = options;
82
+
83
+ const lines = [];
84
+ lines.push('[forge] Substantial work detected — triage before implementation.');
85
+ lines.push('');
86
+ lines.push(`1. Read the Forge skill (\`${skillPath}\`) and follow triage (references/substantial-work.md).`);
87
+ if (!hasActiveSession) {
88
+ lines.push('2. If entering Forge: `forge new <slug>` then continue the current phase.');
89
+ } else if (sessionLines.length > 0) {
90
+ lines.push('2. Active session:');
91
+ for (const line of sessionLines) lines.push(` ${line}`);
92
+ }
93
+ lines.push('3. Skip Forge for this task only: `/forge:skip`');
94
+ lines.push('Guide: Forge skill + docs/forge.md (under the installed forge skill)');
95
+ return lines.join('\n');
96
+ }
97
+
98
+ /**
99
+ * CLI:
100
+ * forge triage --check "<prompt>" exit 0 if should triage, else 1
101
+ * forge triage --message "<prompt>" print triage reminder (always)
102
+ * forge triage --message --has-session "<prompt>"
103
+ */
104
+ function parseTriageArgs(argv) {
105
+ const opts = {
106
+ check: false,
107
+ message: false,
108
+ hasSession: false,
109
+ help: false,
110
+ prompt: '',
111
+ };
112
+ const rest = [];
113
+ for (let i = 0; i < argv.length; i += 1) {
114
+ const arg = argv[i];
115
+ if (arg === '--check') opts.check = true;
116
+ else if (arg === '--message') opts.message = true;
117
+ else if (arg === '--has-session') opts.hasSession = true;
118
+ else if (arg === '--help' || arg === '-h') opts.help = true;
119
+ else rest.push(arg);
120
+ }
121
+ opts.prompt = rest.join(' ').trim();
122
+ return opts;
123
+ }
124
+
125
+ function printTriageHelp() {
126
+ process.stdout.write(`Usage:
127
+ forge triage --check "<prompt>"
128
+ forge triage --message [--has-session] "<prompt>"
129
+ `);
130
+ }
131
+
132
+ async function triageMain(argv = process.argv.slice(2)) {
133
+ const opts = parseTriageArgs(argv);
134
+ if (opts.help || (!opts.check && !opts.message)) {
135
+ printTriageHelp();
136
+ return opts.help ? 0 : 1;
137
+ }
138
+
139
+ let prompt = opts.prompt;
140
+ if (!prompt && !process.stdin.isTTY) {
141
+ prompt = await new Promise((resolve) => {
142
+ let data = '';
143
+ process.stdin.setEncoding('utf8');
144
+ process.stdin.on('data', (c) => {
145
+ data += c;
146
+ });
147
+ process.stdin.on('end', () => resolve(data.trim()));
148
+ setTimeout(() => resolve(data.trim()), 1000);
149
+ });
150
+ }
151
+
152
+ if (opts.check) {
153
+ return shouldForgeTriage(prompt) ? 0 : 1;
154
+ }
155
+
156
+ process.stdout.write(
157
+ `${buildForgeTriageMessage({
158
+ hasActiveSession: opts.hasSession,
159
+ sessionLines: [],
160
+ })}\n`,
161
+ );
162
+ return 0;
163
+ }
164
+
165
+ const isDirect =
166
+ process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url;
167
+
168
+ if (isDirect) {
169
+ triageMain()
170
+ .then((code) => process.exit(code))
171
+ .catch((err) => {
172
+ process.stderr.write(`${err.message || err}\n`);
173
+ process.exit(1);
174
+ });
175
+ }
@@ -1,50 +1,50 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import {
4
- isForgeSkip,
5
- isForgeInvocation,
6
- isReadOnlyQuestion,
7
- isSubstantialWork,
8
- shouldForgeTriage,
9
- } from './triage-prompt.mjs';
10
-
11
- test('isForgeSkip matches /forge:skip', () => {
12
- assert.equal(isForgeSkip('/forge:skip fix typo'), true);
13
- assert.equal(isForgeSkip(' /forge:skip'), true);
14
- });
15
-
16
- test('isForgeInvocation matches forge commands', () => {
17
- assert.equal(isForgeInvocation('/forge'), true);
18
- assert.equal(isForgeInvocation('/forge:brainstorm'), true);
19
- });
20
-
21
- test('read-only questions skip triage', () => {
22
- assert.equal(isReadOnlyQuestion('How does auth work?'), true);
23
- assert.equal(isReadOnlyQuestion('What is forge?'), true);
24
- });
25
-
26
- test('diagnostic fix requests are substantial', () => {
27
- const prompt =
28
- 'Check if Claude is wired correctly. It does not seem to fire the forge flow automatically';
29
- assert.equal(isReadOnlyQuestion(prompt), false);
30
- assert.equal(isSubstantialWork(prompt), true);
31
- assert.equal(shouldForgeTriage(prompt), true);
32
- });
33
-
34
- test('implementation prompts triage', () => {
35
- assert.equal(shouldForgeTriage('Add login to mercury console'), true);
36
- assert.equal(shouldForgeTriage('Fix the bug in callback verification'), true);
37
- });
38
-
39
- test('explicit /forge handled by prompt hook not triage hook', () => {
40
- assert.equal(shouldForgeTriage('/forge:brainstorm'), false);
41
- assert.equal(isSubstantialWork('/forge:brainstorm'), true);
42
- });
43
-
44
- test('/forge:skip is not substantial', () => {
45
- assert.equal(isSubstantialWork('/forge:skip rename variable'), false);
46
- });
47
-
48
- test('trivial edits skip', () => {
49
- assert.equal(isSubstantialWork('Fix the typo in README'), false);
50
- });
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {
4
+ isForgeSkip,
5
+ isForgeInvocation,
6
+ isReadOnlyQuestion,
7
+ isSubstantialWork,
8
+ shouldForgeTriage,
9
+ } from './triage-prompt.mjs';
10
+
11
+ test('isForgeSkip matches /forge:skip', () => {
12
+ assert.equal(isForgeSkip('/forge:skip fix typo'), true);
13
+ assert.equal(isForgeSkip(' /forge:skip'), true);
14
+ });
15
+
16
+ test('isForgeInvocation matches forge commands', () => {
17
+ assert.equal(isForgeInvocation('/forge'), true);
18
+ assert.equal(isForgeInvocation('/forge:brainstorm'), true);
19
+ });
20
+
21
+ test('read-only questions skip triage', () => {
22
+ assert.equal(isReadOnlyQuestion('How does auth work?'), true);
23
+ assert.equal(isReadOnlyQuestion('What is forge?'), true);
24
+ });
25
+
26
+ test('diagnostic fix requests are substantial', () => {
27
+ const prompt =
28
+ 'Check if Claude is wired correctly. It does not seem to fire the forge flow automatically';
29
+ assert.equal(isReadOnlyQuestion(prompt), false);
30
+ assert.equal(isSubstantialWork(prompt), true);
31
+ assert.equal(shouldForgeTriage(prompt), true);
32
+ });
33
+
34
+ test('implementation prompts triage', () => {
35
+ assert.equal(shouldForgeTriage('Add login to mercury console'), true);
36
+ assert.equal(shouldForgeTriage('Fix the bug in callback verification'), true);
37
+ });
38
+
39
+ test('explicit /forge handled by prompt hook not triage hook', () => {
40
+ assert.equal(shouldForgeTriage('/forge:brainstorm'), false);
41
+ assert.equal(isSubstantialWork('/forge:brainstorm'), true);
42
+ });
43
+
44
+ test('/forge:skip is not substantial', () => {
45
+ assert.equal(isSubstantialWork('/forge:skip rename variable'), false);
46
+ });
47
+
48
+ test('trivial edits skip', () => {
49
+ assert.equal(isSubstantialWork('Fix the typo in README'), false);
50
+ });