forge-workflow 0.0.7 → 0.0.9
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.
- package/.claude/commands/premerge.md +2 -2
- package/.claude/commands/review.md +5 -2
- package/.claude/commands/ship.md +4 -3
- package/.claude/rules/greptile-review-process.md +4 -4
- package/.cline/workflows/premerge.md +2 -2
- package/.cline/workflows/review.md +5 -2
- package/.cline/workflows/ship.md +4 -3
- package/.codex/skills/premerge/SKILL.md +2 -2
- package/.codex/skills/review/SKILL.md +5 -2
- package/.codex/skills/ship/SKILL.md +4 -3
- package/.cursor/commands/premerge.md +2 -2
- package/.cursor/commands/review.md +5 -2
- package/.cursor/commands/ship.md +4 -3
- package/.github/prompts/premerge.prompt.md +2 -2
- package/.github/prompts/review.prompt.md +5 -2
- package/.github/prompts/ship.prompt.md +4 -3
- package/.github/workflows/beads-to-github.yml +1 -1
- package/.github/workflows/github-to-beads.yml +1 -1
- package/.kilocode/workflows/premerge.md +2 -2
- package/.kilocode/workflows/review.md +5 -2
- package/.kilocode/workflows/ship.md +4 -3
- package/.opencode/commands/premerge.md +2 -2
- package/.opencode/commands/review.md +5 -2
- package/.opencode/commands/ship.md +4 -3
- package/.roo/commands/premerge.md +2 -2
- package/.roo/commands/review.md +5 -2
- package/.roo/commands/ship.md +4 -3
- package/AGENTS.md +9 -9
- package/README.md +12 -6
- package/bin/forge.js +21 -3
- package/docs/BEADS_GITHUB_SYNC.md +6 -2
- package/docs/EXAMPLES.md +22 -22
- package/docs/ROADMAP.md +3 -3
- package/docs/TOOLCHAIN.md +60 -52
- package/lib/agents/codex.plugin.json +3 -0
- package/lib/agents-config.js +18 -12
- package/lib/codex-skills.js +54 -1
- package/lib/commands/_issue.js +172 -0
- package/lib/commands/claim.js +5 -0
- package/lib/commands/close.js +5 -0
- package/lib/commands/create.js +5 -0
- package/lib/commands/issue.js +5 -0
- package/lib/commands/list.js +5 -0
- package/lib/commands/plan.js +5 -2
- package/lib/commands/ready.js +5 -0
- package/lib/commands/setup.js +231 -17
- package/lib/commands/ship.js +188 -5
- package/lib/commands/show.js +5 -0
- package/lib/commands/status.js +20 -33
- package/lib/commands/sync.js +3 -1
- package/lib/commands/test.js +90 -25
- package/lib/commands/update.js +5 -0
- package/lib/commands/validate.js +218 -1
- package/lib/setup-action-log.js +2 -0
- package/lib/setup-summary-renderer.js +15 -11
- package/lib/workflow/enforce-stage.js +12 -8
- package/lib/workflow/state-manager.js +193 -0
- package/package.json +1 -1
- package/scripts/dep-guard.sh +11 -1
- package/scripts/forge-team/lib/hooks.sh +1 -1
- package/scripts/forge-team/lib/verify.sh +1 -1
- package/scripts/forge-team/lib/workload.sh +56 -27
- package/scripts/forge-team/tests/workload.test.sh +35 -4
- package/scripts/github-beads-sync/run-bd.mjs +4 -2
- package/scripts/lib/eval-runner.js +50 -0
- package/scripts/smart-status.sh +10 -1
- package/scripts/sync-utils.sh +39 -0
- package/scripts/test.js +144 -38
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require('node:child_process');
|
|
4
|
+
|
|
5
|
+
const SUBCOMMANDS = {
|
|
6
|
+
create: {
|
|
7
|
+
description: 'Create a Beads issue via Forge',
|
|
8
|
+
usage: 'forge create [title] [bd-create-flags]',
|
|
9
|
+
helpCommand: 'create',
|
|
10
|
+
buildBdArgs: (args) => ['create', ...args],
|
|
11
|
+
},
|
|
12
|
+
update: {
|
|
13
|
+
description: 'Update a Beads issue via Forge',
|
|
14
|
+
usage: 'forge update <id...> [bd-update-flags]',
|
|
15
|
+
helpCommand: 'update',
|
|
16
|
+
buildBdArgs: (args) => ['update', ...args],
|
|
17
|
+
},
|
|
18
|
+
claim: {
|
|
19
|
+
description: 'Claim a Beads issue via Forge',
|
|
20
|
+
usage: 'forge claim <id> [bd-update-flags]',
|
|
21
|
+
helpCommand: 'update',
|
|
22
|
+
buildBdArgs: (args) => {
|
|
23
|
+
const [issueId, ...rest] = args;
|
|
24
|
+
if (!issueId) {
|
|
25
|
+
return { error: 'Missing issue id. Usage: forge claim <id> [bd-update-flags]' };
|
|
26
|
+
}
|
|
27
|
+
return ['update', issueId, '--claim', ...rest];
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
close: {
|
|
31
|
+
description: 'Close a Beads issue via Forge',
|
|
32
|
+
usage: 'forge close <id...> [bd-close-flags]',
|
|
33
|
+
helpCommand: 'close',
|
|
34
|
+
buildBdArgs: (args) => ['close', ...args],
|
|
35
|
+
},
|
|
36
|
+
show: {
|
|
37
|
+
description: 'Show a Beads issue via Forge',
|
|
38
|
+
usage: 'forge show <id> [bd-show-flags]',
|
|
39
|
+
helpCommand: 'show',
|
|
40
|
+
buildBdArgs: (args) => ['show', ...args],
|
|
41
|
+
},
|
|
42
|
+
list: {
|
|
43
|
+
description: 'List Beads issues via Forge',
|
|
44
|
+
usage: 'forge list [bd-list-flags]',
|
|
45
|
+
helpCommand: 'list',
|
|
46
|
+
buildBdArgs: (args) => ['list', ...args],
|
|
47
|
+
},
|
|
48
|
+
ready: {
|
|
49
|
+
description: 'Show ready Beads issues via Forge',
|
|
50
|
+
usage: 'forge ready [bd-ready-flags]',
|
|
51
|
+
helpCommand: 'ready',
|
|
52
|
+
buildBdArgs: (args) => ['ready', ...args],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function normalizeArgs(args = []) {
|
|
57
|
+
return args.filter(arg => arg !== '--');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getExecOptions(projectRoot) {
|
|
61
|
+
return {
|
|
62
|
+
cwd: projectRoot,
|
|
63
|
+
stdio: 'inherit',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function formatIssueHelp() {
|
|
68
|
+
const lines = [
|
|
69
|
+
'Usage: forge issue <subcommand> [...]',
|
|
70
|
+
'',
|
|
71
|
+
'Supported subcommands:',
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
for (const [name, spec] of Object.entries(SUBCOMMANDS)) {
|
|
75
|
+
lines.push(` ${name.padEnd(6)} ${spec.description}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push('Examples:');
|
|
80
|
+
lines.push(' forge create --title "Add feature" --type feature');
|
|
81
|
+
lines.push(' forge claim forge-abc');
|
|
82
|
+
lines.push(' forge update forge-abc --priority 1');
|
|
83
|
+
lines.push(' forge close forge-abc --reason "Done"');
|
|
84
|
+
lines.push(' forge issue show forge-abc --json');
|
|
85
|
+
|
|
86
|
+
return lines.join('\n');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function extractErrorMessage(error) {
|
|
90
|
+
if (error?.code === 'ENOENT') {
|
|
91
|
+
return 'Beads (bd) command not found. Install or initialize Beads before using Forge issue commands.';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// With stdio: 'inherit', error.stderr and error.stdout are always null.
|
|
95
|
+
// Only error.message is available for diagnostics.
|
|
96
|
+
return error?.message?.trim() || 'Beads command failed';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function buildBdArgs(subcommand, rawArgs) {
|
|
100
|
+
const spec = SUBCOMMANDS[subcommand];
|
|
101
|
+
if (!spec) {
|
|
102
|
+
return { error: `Unknown issue subcommand '${subcommand}'.\n\n${formatIssueHelp()}` };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const args = normalizeArgs(rawArgs);
|
|
106
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
107
|
+
return [spec.helpCommand, '--help'];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return spec.buildBdArgs(args);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function runIssueSubcommand(subcommand, args, projectRoot, opts = {}) {
|
|
114
|
+
const exec = opts._exec || execFileSync;
|
|
115
|
+
const bdArgs = buildBdArgs(subcommand, args);
|
|
116
|
+
|
|
117
|
+
if (!Array.isArray(bdArgs)) {
|
|
118
|
+
return { success: false, error: bdArgs.error };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
exec('bd', bdArgs, getExecOptions(projectRoot));
|
|
123
|
+
return { success: true, subcommand };
|
|
124
|
+
} catch (error) {
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
error: extractErrorMessage(error),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function makeAliasCommand(subcommand) {
|
|
133
|
+
const spec = SUBCOMMANDS[subcommand];
|
|
134
|
+
if (!spec) {
|
|
135
|
+
throw new Error(`Unknown issue subcommand '${subcommand}'`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
name: subcommand,
|
|
140
|
+
description: spec.description,
|
|
141
|
+
usage: spec.usage,
|
|
142
|
+
flags: {},
|
|
143
|
+
handler: async (args, _flags, projectRoot, opts = {}) =>
|
|
144
|
+
runIssueSubcommand(subcommand, args, projectRoot, opts),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function createIssueCommand() {
|
|
149
|
+
return {
|
|
150
|
+
name: 'issue',
|
|
151
|
+
description: 'Manage Beads issues through the Forge command surface',
|
|
152
|
+
usage: 'forge issue <create|update|claim|close|show|list|ready> [...]',
|
|
153
|
+
flags: {},
|
|
154
|
+
handler: async (args, _flags, projectRoot, opts = {}) => {
|
|
155
|
+
const [subcommand, ...rest] = normalizeArgs(args);
|
|
156
|
+
|
|
157
|
+
if (!subcommand || subcommand === '--help' || subcommand === '-h') {
|
|
158
|
+
return { success: true, output: formatIssueHelp() };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return runIssueSubcommand(subcommand, rest, projectRoot, opts);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
module.exports = {
|
|
167
|
+
SUBCOMMANDS,
|
|
168
|
+
buildBdArgs,
|
|
169
|
+
createIssueCommand,
|
|
170
|
+
makeAliasCommand,
|
|
171
|
+
runIssueSubcommand,
|
|
172
|
+
};
|
package/lib/commands/plan.js
CHANGED
|
@@ -254,8 +254,11 @@ function createBeadsIssue(featureName, researchPath, scope) {
|
|
|
254
254
|
getExecOptions()
|
|
255
255
|
);
|
|
256
256
|
|
|
257
|
-
// Extract issue ID from output (format: "Created issue: forge-xxx")
|
|
258
|
-
|
|
257
|
+
// Extract issue ID from output (format: "Created issue: forge-xxx" or "forge-xxx.N" for dotted sub-IDs).
|
|
258
|
+
// Character class is [a-z0-9] (not [a-zA-Z0-9]) because the /i flag makes A-Z redundant.
|
|
259
|
+
const createPattern = /Created issue:\s*(forge-[a-z0-9]+(?:\.[a-z0-9]+)*)/i;
|
|
260
|
+
const fallbackPattern = /(forge-[a-z0-9]+(?:\.[a-z0-9]+)*)/i;
|
|
261
|
+
const match = createPattern.exec(result) || fallbackPattern.exec(result);
|
|
259
262
|
|
|
260
263
|
if (!match) {
|
|
261
264
|
return {
|
package/lib/commands/setup.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const fs = require('node:fs');
|
|
13
|
+
const os = require('node:os');
|
|
13
14
|
const path = require('node:path');
|
|
14
15
|
const readline = require('node:readline');
|
|
15
16
|
const { execSync, execFileSync } = require('node:child_process');
|
|
@@ -46,7 +47,11 @@ const { renderSetupSummary } = require('../setup-summary-renderer');
|
|
|
46
47
|
const { smartMergeAgentsMd } = require('../smart-merge');
|
|
47
48
|
const { checkLefthookStatus } = require('../lefthook-check');
|
|
48
49
|
const { resolveShellRuntime } = require('../runtime-health');
|
|
49
|
-
const {
|
|
50
|
+
const {
|
|
51
|
+
buildCodexSkillInstallPlan,
|
|
52
|
+
formatCodexSkillsInstallDir,
|
|
53
|
+
listCodexSkillEntries,
|
|
54
|
+
} = require('../codex-skills');
|
|
50
55
|
const {
|
|
51
56
|
generateCopilotConfig,
|
|
52
57
|
generateCursorConfig,
|
|
@@ -69,6 +74,8 @@ let SYMLINK_ONLY = false;
|
|
|
69
74
|
let SYNC_ENABLED = false;
|
|
70
75
|
let actionLog = new SetupActionLog();
|
|
71
76
|
let PKG_MANAGER = 'npm';
|
|
77
|
+
let SETUP_NOTES = [];
|
|
78
|
+
let CODEX_SETUP_REPORT = null;
|
|
72
79
|
|
|
73
80
|
/**
|
|
74
81
|
* Load agent definitions from plugin architecture
|
|
@@ -81,7 +88,7 @@ function loadAgentsFromPlugins() {
|
|
|
81
88
|
agents[id] = {
|
|
82
89
|
name: plugin.name,
|
|
83
90
|
description: plugin.description || '',
|
|
84
|
-
dirs:
|
|
91
|
+
dirs: getRepoRelativePluginDirectories(plugin),
|
|
85
92
|
hasCommands: plugin.capabilities?.commands || plugin.setup?.copyCommands || false,
|
|
86
93
|
hasSkill: plugin.capabilities?.skills || plugin.setup?.createSkill || false,
|
|
87
94
|
linkFile: plugin.files?.rootConfig || '',
|
|
@@ -95,6 +102,17 @@ function loadAgentsFromPlugins() {
|
|
|
95
102
|
return agents;
|
|
96
103
|
}
|
|
97
104
|
|
|
105
|
+
function isRepoRelativePluginPath(candidate) {
|
|
106
|
+
return typeof candidate === 'string'
|
|
107
|
+
&& candidate.length > 0
|
|
108
|
+
&& !path.isAbsolute(candidate)
|
|
109
|
+
&& !/^[~$%]/.test(candidate);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function getRepoRelativePluginDirectories(plugin) {
|
|
113
|
+
return Object.values(plugin.directories || {}).filter(isRepoRelativePluginPath);
|
|
114
|
+
}
|
|
115
|
+
|
|
98
116
|
const AGENTS = loadAgentsFromPlugins();
|
|
99
117
|
Object.freeze(AGENTS);
|
|
100
118
|
Object.values(AGENTS).forEach(agent => Object.freeze(agent));
|
|
@@ -187,11 +205,112 @@ function validateAgents(agentList) {
|
|
|
187
205
|
return valid;
|
|
188
206
|
}
|
|
189
207
|
|
|
208
|
+
function parseDoltRemoteNames(remoteListOutput) {
|
|
209
|
+
const output = String(remoteListOutput || '').trim();
|
|
210
|
+
if (!output || /^No remotes configured\.?$/i.test(output)) {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return output
|
|
215
|
+
.split(/\r?\n/)
|
|
216
|
+
.map(line => line.trim())
|
|
217
|
+
.filter(Boolean)
|
|
218
|
+
.map(line => line.split(/\s+/)[0])
|
|
219
|
+
.filter(Boolean);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function readBeadsSyncRemoteConfig(projectDir = projectRoot) {
|
|
223
|
+
const jsonConfigPath = path.join(projectDir, '.beads', 'config.json');
|
|
224
|
+
if (fs.existsSync(jsonConfigPath)) {
|
|
225
|
+
try {
|
|
226
|
+
const parsed = JSON.parse(fs.readFileSync(jsonConfigPath, 'utf8'));
|
|
227
|
+
if (typeof parsed.sync_remote === 'string' && parsed.sync_remote.trim()) {
|
|
228
|
+
return parsed.sync_remote.trim();
|
|
229
|
+
}
|
|
230
|
+
} catch (_error) {
|
|
231
|
+
// Ignore malformed config and fall back to other sources.
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const yamlConfigPath = path.join(projectDir, '.beads', 'config.yaml');
|
|
236
|
+
if (fs.existsSync(yamlConfigPath)) {
|
|
237
|
+
const configuredRemote = parseBeadsYamlSyncRemote(fs.readFileSync(yamlConfigPath, 'utf8'));
|
|
238
|
+
if (configuredRemote) {
|
|
239
|
+
return configuredRemote;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return '';
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function parseBeadsYamlSyncRemote(content) {
|
|
247
|
+
for (const rawLine of String(content || '').split(/\r?\n/)) {
|
|
248
|
+
const trimmedLine = rawLine.trimStart();
|
|
249
|
+
if (!trimmedLine.startsWith('sync-remote:')) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const rawValue = trimmedLine.slice('sync-remote:'.length).trim();
|
|
254
|
+
if (!rawValue) {
|
|
255
|
+
return '';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const quote = rawValue[0];
|
|
259
|
+
if ((quote === '"' || quote === '\'') && rawValue.length > 1) {
|
|
260
|
+
const closingQuoteIndex = rawValue.indexOf(quote, 1);
|
|
261
|
+
if (closingQuoteIndex > 1) {
|
|
262
|
+
return rawValue.slice(1, closingQuoteIndex).trim();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const commentIndex = rawValue.indexOf('#');
|
|
267
|
+
const unquotedValue = commentIndex === -1 ? rawValue : rawValue.slice(0, commentIndex);
|
|
268
|
+
return unquotedValue.trim();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return '';
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function resolveExpectedBeadsRemote(options = {}) {
|
|
275
|
+
const projectDir = options.projectDir || projectRoot;
|
|
276
|
+
const env = options.env || process.env;
|
|
277
|
+
const configuredRemote = readBeadsSyncRemoteConfig(projectDir);
|
|
278
|
+
if (configuredRemote) {
|
|
279
|
+
return configuredRemote;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (typeof env.BD_SYNC_REMOTE === 'string' && env.BD_SYNC_REMOTE.trim()) {
|
|
283
|
+
return env.BD_SYNC_REMOTE.trim();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const gitRemoteProbe = options.gitRemoteProbe
|
|
287
|
+
|| ((remoteName) => safeExec(`git -C "${projectDir}" remote get-url ${remoteName}`));
|
|
288
|
+
if (gitRemoteProbe('upstream')) {
|
|
289
|
+
return 'upstream';
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return 'origin';
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function hasBeadsDoltRemote(commandRunner, remoteName = 'origin') {
|
|
296
|
+
const output = commandRunner('bd dolt remote list');
|
|
297
|
+
if (!output) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return parseDoltRemoteNames(output).includes(remoteName);
|
|
302
|
+
}
|
|
303
|
+
|
|
190
304
|
// Prerequisite check function
|
|
191
305
|
function checkPrerequisites(options = {}) {
|
|
192
306
|
const requireGithubCli = options.requireGithubCli !== false;
|
|
193
307
|
const requireBeadsCli = options.requireBeadsCli === true;
|
|
194
308
|
const requireJq = options.requireJq === true;
|
|
309
|
+
const expectedBeadsRemote = options.expectedBeadsRemote || resolveExpectedBeadsRemote({
|
|
310
|
+
env: options.env,
|
|
311
|
+
gitRemoteProbe: options.gitRemoteProbe,
|
|
312
|
+
projectDir: options.projectDir,
|
|
313
|
+
});
|
|
195
314
|
const commandRunner = options.commandRunner || safeExec;
|
|
196
315
|
const errors = [];
|
|
197
316
|
const warnings = [];
|
|
@@ -230,6 +349,20 @@ function checkPrerequisites(options = {}) {
|
|
|
230
349
|
const bdVersion = commandRunner('bd --version');
|
|
231
350
|
if (bdVersion) {
|
|
232
351
|
console.log(` ✓ ${bdVersion.split('\n')[0]}`);
|
|
352
|
+
if (requireBeadsCli) {
|
|
353
|
+
const hasRemote = hasBeadsDoltRemote(commandRunner, expectedBeadsRemote);
|
|
354
|
+
if (hasRemote === false) {
|
|
355
|
+
warnings.push(
|
|
356
|
+
`Beads Dolt remote '${expectedBeadsRemote}' is not configured. ` +
|
|
357
|
+
`Sync will remain local until you run: bd dolt remote add ${expectedBeadsRemote} <url>`
|
|
358
|
+
);
|
|
359
|
+
} else if (hasRemote === null) {
|
|
360
|
+
warnings.push(
|
|
361
|
+
`Unable to inspect Beads Dolt remotes. ` +
|
|
362
|
+
`Sync may remain local until '${expectedBeadsRemote}' is configured and bd dolt remote list succeeds.`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
233
366
|
} else if (requireBeadsCli) {
|
|
234
367
|
errors.push('bd (Beads CLI) - Install from https://github.com/steveyegge/beads');
|
|
235
368
|
}
|
|
@@ -343,12 +476,60 @@ function writeFile(filePath, content) {
|
|
|
343
476
|
return fileUtils.writeFile(filePath, content, projectRoot);
|
|
344
477
|
}
|
|
345
478
|
|
|
479
|
+
function writeManagedAbsoluteFile(absolutePath, content, displayPath) {
|
|
480
|
+
try {
|
|
481
|
+
if (!FORCE_MODE && fileMatchesContent(absolutePath, content)) {
|
|
482
|
+
actionLog.add(displayPath, 'skipped', 'identical content');
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const dir = path.dirname(absolutePath);
|
|
487
|
+
if (!fs.existsSync(dir)) {
|
|
488
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const existed = fs.existsSync(absolutePath);
|
|
492
|
+
fs.writeFileSync(absolutePath, content, { mode: 0o644 });
|
|
493
|
+
actionLog.add(displayPath, FORCE_MODE ? 'force-created' : (existed ? 'updated' : 'created'));
|
|
494
|
+
return true;
|
|
495
|
+
} catch (err) {
|
|
496
|
+
console.error(` × Failed to write ${displayPath}: ${err.message}`);
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
346
501
|
|
|
347
502
|
|
|
348
503
|
function readFile(filePath) {
|
|
349
504
|
return fileUtils.readFile(filePath);
|
|
350
505
|
}
|
|
351
506
|
|
|
507
|
+
function resetSetupNotes() {
|
|
508
|
+
SETUP_NOTES = [];
|
|
509
|
+
CODEX_SETUP_REPORT = null;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function addSetupNote(message) {
|
|
513
|
+
if (!message || SETUP_NOTES.includes(message)) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
SETUP_NOTES.push(message);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function getSetupSummaryStatus() {
|
|
520
|
+
return SETUP_NOTES.length > 0 ? 'partial' : 'complete';
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function printSetupNotes() {
|
|
524
|
+
if (SETUP_NOTES.length === 0) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
for (const note of SETUP_NOTES) {
|
|
529
|
+
console.log(` Warning: ${note}`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
352
533
|
|
|
353
534
|
|
|
354
535
|
function copyFile(src, dest) { // NOSONAR — Extracted as-is from bin/forge.js; complexity reduction deferred
|
|
@@ -1741,15 +1922,42 @@ function createAgentSkill(agent, agentKey) {
|
|
|
1741
1922
|
|
|
1742
1923
|
// Helper: Create Codex per-stage skills from canonical commands
|
|
1743
1924
|
function createCodexSkills() {
|
|
1744
|
-
const
|
|
1925
|
+
const installPlan = buildCodexSkillInstallPlan(packageDir, { env: process.env, homeDir: os.homedir() });
|
|
1926
|
+
const installRoot = formatCodexSkillsInstallDir({ env: process.env, homeDir: os.homedir() });
|
|
1927
|
+
|
|
1928
|
+
CODEX_SETUP_REPORT = {
|
|
1929
|
+
installRoot,
|
|
1930
|
+
skillCount: installPlan.length,
|
|
1931
|
+
status: 'complete',
|
|
1932
|
+
message: '',
|
|
1933
|
+
};
|
|
1745
1934
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1935
|
+
if (installPlan.length === 0) {
|
|
1936
|
+
CODEX_SETUP_REPORT.status = 'partial';
|
|
1937
|
+
CODEX_SETUP_REPORT.message = 'Codex setup could not find the packaged stage skill templates.';
|
|
1938
|
+
addSetupNote(CODEX_SETUP_REPORT.message);
|
|
1939
|
+
console.log(' Warning: Codex stage skill templates were not found in the Forge package');
|
|
1940
|
+
return CODEX_SETUP_REPORT;
|
|
1748
1941
|
}
|
|
1749
1942
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1943
|
+
let failed = 0;
|
|
1944
|
+
for (const entry of installPlan) {
|
|
1945
|
+
if (!writeManagedAbsoluteFile(entry.absolutePath, entry.content, entry.displayPath)) {
|
|
1946
|
+
failed += 1;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
if (failed > 0) {
|
|
1951
|
+
CODEX_SETUP_REPORT.status = 'partial';
|
|
1952
|
+
CODEX_SETUP_REPORT.message = `Codex repo instructions installed, but skills are not discoverable in this environment. Forge could not install ${failed}/${installPlan.length} Codex skills into ${installRoot}. Use \`bunx forge status\`, \`bunx forge plan\`, and the other Forge CLI stages until global Codex skills can be installed.`;
|
|
1953
|
+
addSetupNote(CODEX_SETUP_REPORT.message);
|
|
1954
|
+
console.log(` Warning: Codex skill install incomplete (${installPlan.length - failed}/${installPlan.length}) -> ${installRoot}`);
|
|
1955
|
+
return CODEX_SETUP_REPORT;
|
|
1752
1956
|
}
|
|
1957
|
+
|
|
1958
|
+
CODEX_SETUP_REPORT.message = `Codex setup complete — installed ${installPlan.length} stage skills to ${installRoot}`;
|
|
1959
|
+
console.log(` Installed: Codex stage skills (${installPlan.length}) -> ${installRoot}`);
|
|
1960
|
+
return CODEX_SETUP_REPORT;
|
|
1753
1961
|
}
|
|
1754
1962
|
|
|
1755
1963
|
// Helper: Setup MCP config for Claude
|
|
@@ -2210,9 +2418,10 @@ async function setupAgentsWithProgress(selectedAgents, claudeCommands, skipFiles
|
|
|
2210
2418
|
* Display final setup summary
|
|
2211
2419
|
*/
|
|
2212
2420
|
function displaySetupSummary(selectedAgents) {
|
|
2421
|
+
const partial = getSetupSummaryStatus() === 'partial';
|
|
2213
2422
|
console.log('');
|
|
2214
2423
|
console.log('==============================================');
|
|
2215
|
-
console.log(` Forge v${VERSION} Setup Complete!`);
|
|
2424
|
+
console.log(` Forge v${VERSION} Setup ${partial ? 'Partially Complete' : 'Complete'}!`);
|
|
2216
2425
|
console.log('==============================================');
|
|
2217
2426
|
console.log('');
|
|
2218
2427
|
console.log('What\'s installed:');
|
|
@@ -2230,8 +2439,9 @@ function displaySetupSummary(selectedAgents) {
|
|
|
2230
2439
|
console.log(` - ${agent.dirs[0]}/ (${workflowCount} workflow commands)`);
|
|
2231
2440
|
}
|
|
2232
2441
|
if (key === 'codex') {
|
|
2233
|
-
const skillCount = listCodexSkillEntries(packageDir).length;
|
|
2234
|
-
|
|
2442
|
+
const skillCount = CODEX_SETUP_REPORT?.skillCount ?? listCodexSkillEntries(packageDir).length;
|
|
2443
|
+
const codexRoot = CODEX_SETUP_REPORT?.installRoot || formatCodexSkillsInstallDir({ env: process.env, homeDir: os.homedir() });
|
|
2444
|
+
console.log(` - ${codexRoot}/<stage>/SKILL.md (${skillCount} stage skills)`);
|
|
2235
2445
|
} else if (agent.hasSkill) {
|
|
2236
2446
|
const skillDir = agent.dirs.find(d => d.includes('/skills/'));
|
|
2237
2447
|
if (skillDir) {
|
|
@@ -2263,10 +2473,11 @@ function displaySetupSummary(selectedAgents) {
|
|
|
2263
2473
|
console.log('');
|
|
2264
2474
|
console.log('Project Tools Status:');
|
|
2265
2475
|
console.log('');
|
|
2476
|
+
printSetupNotes();
|
|
2266
2477
|
|
|
2267
2478
|
// Beads status
|
|
2268
2479
|
if (isBeadsInitialized()) {
|
|
2269
|
-
console.log(' ✓ Beads initialized - Track work:
|
|
2480
|
+
console.log(' ✓ Beads initialized - Track work: forge ready');
|
|
2270
2481
|
} else if (checkForBeads()) {
|
|
2271
2482
|
console.log(' ! Beads available - Run: bd init');
|
|
2272
2483
|
} else {
|
|
@@ -3018,7 +3229,7 @@ async function setupProjectTools(rl, question) {
|
|
|
3018
3229
|
console.log('');
|
|
3019
3230
|
console.log('• Beads - Git-backed issue tracking');
|
|
3020
3231
|
console.log(' Persists tasks across sessions, tracks dependencies.');
|
|
3021
|
-
console.log(' Command:
|
|
3232
|
+
console.log(' Command: forge ready, forge create, forge close');
|
|
3022
3233
|
console.log('');
|
|
3023
3234
|
console.log('• Skills - Universal SKILL.md management');
|
|
3024
3235
|
console.log(' Manage AI agent skills across all agents.');
|
|
@@ -3250,7 +3461,8 @@ async function quickSetup(selectedAgents, skipExternal) {
|
|
|
3250
3461
|
|
|
3251
3462
|
// Progressive setup summary
|
|
3252
3463
|
console.log('');
|
|
3253
|
-
console.log(renderSetupSummary(actionLog, selectedAgents, VERBOSE_MODE));
|
|
3464
|
+
console.log(renderSetupSummary(actionLog, selectedAgents, VERBOSE_MODE, { status: getSetupSummaryStatus() }));
|
|
3465
|
+
printSetupNotes();
|
|
3254
3466
|
console.log('');
|
|
3255
3467
|
}
|
|
3256
3468
|
|
|
@@ -3752,9 +3964,9 @@ function dryRunSetup(agents) { // NOSONAR — Extracted as-is from bin/forge.js;
|
|
|
3752
3964
|
|
|
3753
3965
|
// Agent skill
|
|
3754
3966
|
if (agentKey === 'codex') {
|
|
3755
|
-
const skillEntries =
|
|
3967
|
+
const skillEntries = buildCodexSkillInstallPlan(packageDir, { env: process.env, homeDir: os.homedir() });
|
|
3756
3968
|
for (const entry of skillEntries) {
|
|
3757
|
-
addFileAction(
|
|
3969
|
+
addFileAction(entry.displayPath, 'Codex stage skill');
|
|
3758
3970
|
}
|
|
3759
3971
|
} else if (agent.hasSkill) {
|
|
3760
3972
|
const skillDir = agent.dirs.find(d => d.includes('/skills/'));
|
|
@@ -3853,7 +4065,8 @@ async function executeSetup(config) {
|
|
|
3853
4065
|
|
|
3854
4066
|
// Progressive setup summary
|
|
3855
4067
|
console.log('');
|
|
3856
|
-
console.log(renderSetupSummary(actionLog, agents, VERBOSE_MODE));
|
|
4068
|
+
console.log(renderSetupSummary(actionLog, agents, VERBOSE_MODE, { status: getSetupSummaryStatus() }));
|
|
4069
|
+
printSetupNotes();
|
|
3857
4070
|
console.log('');
|
|
3858
4071
|
}
|
|
3859
4072
|
|
|
@@ -3976,7 +4189,7 @@ function detectConfiguredAgents(dir) {
|
|
|
3976
4189
|
};
|
|
3977
4190
|
|
|
3978
4191
|
pluginManager.getAllPlugins().forEach((plugin, id) => {
|
|
3979
|
-
const dirs =
|
|
4192
|
+
const dirs = getRepoRelativePluginDirectories(plugin);
|
|
3980
4193
|
const files = Object.values(plugin.files || {});
|
|
3981
4194
|
const markers = [...dirs, ...files].filter(Boolean);
|
|
3982
4195
|
const isConfigured = markers.some((marker) => fs.existsSync(path.join(dir, marker)));
|
|
@@ -4198,6 +4411,7 @@ module.exports = {
|
|
|
4198
4411
|
if (flags.symlink) SYMLINK_ONLY = true;
|
|
4199
4412
|
if (flags.sync) SYNC_ENABLED = true;
|
|
4200
4413
|
actionLog = new SetupActionLog();
|
|
4414
|
+
resetSetupNotes();
|
|
4201
4415
|
PKG_MANAGER = detectPackageManager();
|
|
4202
4416
|
|
|
4203
4417
|
// Determine agents to install
|